
Hi Jagan,
On Wed, Sep 2, 2015 at 2:09 PM, Jagan Teki jteki@openedev.com wrote:
Generic function for all spi-flash register reads.
Signed-off-by: Jagan Teki jteki@openedev.com
Changes for v3: - none Changes for v2: - none
drivers/mtd/spi/sf.c | 23 +++++++++++++++++++++++ drivers/mtd/spi/sf_internal.h | 3 +++ 2 files changed, 26 insertions(+)
diff --git a/drivers/mtd/spi/sf.c b/drivers/mtd/spi/sf.c index 664e860..cb36946 100644 --- a/drivers/mtd/spi/sf.c +++ b/drivers/mtd/spi/sf.c @@ -9,6 +9,7 @@
#include <common.h> #include <spi.h> +#include <spi_flash.h>
static int spi_flash_read_write(struct spi_slave *spi, const u8 *cmd, size_t cmd_len, @@ -56,3 +57,25 @@ int spi_flash_cmd_write(struct spi_slave *spi, const u8 *cmd, size_t cmd_len, { return spi_flash_read_write(spi, cmd, cmd_len, data, NULL, data_len); }
+int flash_read_reg(struct spi_flash *flash, u8 cmd, u8 *val, int len)
Should it be named as spi_flash_read_reg() to indicate this is for SPI flash only?
+{
struct spi_slave *spi = flash->spi;
int ret;
ret = spi_claim_bus(spi);
if (ret < 0) {
debug("SF: unable to claim SPI bus\n");
return ret;
}
ret = spi_flash_read_write(spi, &cmd, 1, NULL, val, len);
if (ret < 0) {
debug("SF: error %d reading register %x\n", ret, cmd);
return ret;
}
spi_release_bus(spi);
return ret;
+} diff --git a/drivers/mtd/spi/sf_internal.h b/drivers/mtd/spi/sf_internal.h index 8a3e5ec..14b8b55 100644 --- a/drivers/mtd/spi/sf_internal.h +++ b/drivers/mtd/spi/sf_internal.h @@ -156,6 +156,9 @@ int spi_flash_cmd(struct spi_slave *spi, u8 cmd, void *response, size_t len); int spi_flash_cmd_read(struct spi_slave *spi, const u8 *cmd, size_t cmd_len, void *data, size_t data_len);
+/* Read flash register - common call for all flash register reads */ +int flash_read_reg(struct spi_flash *flash, u8 cmd, u8 *val, int len);
/*
- Send a multi-byte command to the device followed by (optional)
- data. Used for programming the flash array, etc.
--
Regards, Bin