* [U-Boot] [PATCH v3 1/5] sf: Get spi locally from spi_flash
@ 2015-12-14 9:51 Jagan Teki
2015-12-14 9:51 ` [U-Boot] [PATCH v3 2/5] spi: make mode visible to both dm and non-dm Jagan Teki
` (4 more replies)
0 siblings, 5 replies; 14+ messages in thread
From: Jagan Teki @ 2015-12-14 9:51 UTC (permalink / raw)
To: u-boot
For better code readabilty, get the spi pointer from
spi_flash{} locally and use it instead of direct
dereferring spi pinter as flash->spi->*
Signed-off-by: Jagan Teki <jteki@openedev.com>
---
Changes for v3:
- none
Changes for v2:
- Fixed missing spi declaration for sst_write_*
drivers/mtd/spi/spi_flash.c | 51 ++++++++++++++++++++++++++-------------------
1 file changed, 29 insertions(+), 22 deletions(-)
diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c
index 7ffa136..30a381b 100644
--- a/drivers/mtd/spi/spi_flash.c
+++ b/drivers/mtd/spi/spi_flash.c
@@ -177,13 +177,15 @@ bank_end:
#ifdef CONFIG_SF_DUAL_FLASH
static void spi_flash_dual(struct spi_flash *flash, u32 *addr)
{
+ struct spi_slave *spi = flash->spi;
+
switch (flash->dual_flash) {
case SF_DUAL_STACKED_FLASH:
if (*addr >= (flash->size >> 1)) {
*addr -= flash->size >> 1;
- flash->spi->flags |= SPI_XFER_U_PAGE;
+ spi->flags |= SPI_XFER_U_PAGE;
} else {
- flash->spi->flags &= ~SPI_XFER_U_PAGE;
+ spi->flags &= ~SPI_XFER_U_PAGE;
}
break;
case SF_DUAL_PARALLEL_FLASH:
@@ -268,7 +270,7 @@ int spi_flash_write_common(struct spi_flash *flash, const u8 *cmd,
if (buf == NULL)
timeout = SPI_FLASH_PAGE_ERASE_TIMEOUT;
- ret = spi_claim_bus(flash->spi);
+ ret = spi_claim_bus(spi);
if (ret) {
debug("SF: unable to claim SPI bus\n");
return ret;
@@ -353,6 +355,7 @@ int spi_flash_cmd_erase_ops(struct spi_flash *flash, u32 offset, size_t len)
int spi_flash_cmd_write_ops(struct spi_flash *flash, u32 offset,
size_t len, const void *buf)
{
+ struct spi_slave *spi = flash->spi;
unsigned long byte_addr, page_size;
u32 write_addr;
size_t chunk_len, actual;
@@ -385,9 +388,9 @@ int spi_flash_cmd_write_ops(struct spi_flash *flash, u32 offset,
byte_addr = offset % page_size;
chunk_len = min(len - actual, (size_t)(page_size - byte_addr));
- if (flash->spi->max_write_size)
+ if (spi->max_write_size)
chunk_len = min(chunk_len,
- (size_t)flash->spi->max_write_size);
+ (size_t)spi->max_write_size);
spi_flash_addr(write_addr, cmd);
@@ -413,7 +416,7 @@ int spi_flash_read_common(struct spi_flash *flash, const u8 *cmd,
struct spi_slave *spi = flash->spi;
int ret;
- ret = spi_claim_bus(flash->spi);
+ ret = spi_claim_bus(spi);
if (ret) {
debug("SF: unable to claim SPI bus\n");
return ret;
@@ -438,6 +441,7 @@ void __weak spi_flash_copy_mmap(void *data, void *offset, size_t len)
int spi_flash_cmd_read_ops(struct spi_flash *flash, u32 offset,
size_t len, void *data)
{
+ struct spi_slave *spi = flash->spi;
u8 *cmd, cmdsz;
u32 remain_len, read_len, read_addr;
int bank_sel = 0;
@@ -445,15 +449,15 @@ int spi_flash_cmd_read_ops(struct spi_flash *flash, u32 offset,
/* Handle memory-mapped SPI */
if (flash->memory_map) {
- ret = spi_claim_bus(flash->spi);
+ ret = spi_claim_bus(spi);
if (ret) {
debug("SF: unable to claim SPI bus\n");
return ret;
}
- spi_xfer(flash->spi, 0, NULL, NULL, SPI_XFER_MMAP);
+ spi_xfer(spi, 0, NULL, NULL, SPI_XFER_MMAP);
spi_flash_copy_mmap(data, flash->memory_map + offset, len);
- spi_xfer(flash->spi, 0, NULL, NULL, SPI_XFER_MMAP_END);
- spi_release_bus(flash->spi);
+ spi_xfer(spi, 0, NULL, NULL, SPI_XFER_MMAP_END);
+ spi_release_bus(spi);
return 0;
}
@@ -505,6 +509,7 @@ int spi_flash_cmd_read_ops(struct spi_flash *flash, u32 offset,
#ifdef CONFIG_SPI_FLASH_SST
static int sst_byte_write(struct spi_flash *flash, u32 offset, const void *buf)
{
+ struct spi_slave *spi = flash->spi;
int ret;
u8 cmd[4] = {
CMD_SST_BP,
@@ -514,13 +519,13 @@ static int sst_byte_write(struct spi_flash *flash, u32 offset, const void *buf)
};
debug("BP[%02x]: 0x%p => cmd = { 0x%02x 0x%06x }\n",
- spi_w8r8(flash->spi, CMD_READ_STATUS), buf, cmd[0], offset);
+ spi_w8r8(spi, CMD_READ_STATUS), buf, cmd[0], offset);
ret = spi_flash_cmd_write_enable(flash);
if (ret)
return ret;
- ret = spi_flash_cmd_write(flash->spi, cmd, sizeof(cmd), buf, 1);
+ ret = spi_flash_cmd_write(spi, cmd, sizeof(cmd), buf, 1);
if (ret)
return ret;
@@ -530,11 +535,12 @@ static int sst_byte_write(struct spi_flash *flash, u32 offset, const void *buf)
int sst_write_wp(struct spi_flash *flash, u32 offset, size_t len,
const void *buf)
{
+ struct spi_slave *spi = flash->spi;
size_t actual, cmd_len;
int ret;
u8 cmd[4];
- ret = spi_claim_bus(flash->spi);
+ ret = spi_claim_bus(spi);
if (ret) {
debug("SF: Unable to claim SPI bus\n");
return ret;
@@ -561,10 +567,10 @@ int sst_write_wp(struct spi_flash *flash, u32 offset, size_t len,
for (; actual < len - 1; actual += 2) {
debug("WP[%02x]: 0x%p => cmd = { 0x%02x 0x%06x }\n",
- spi_w8r8(flash->spi, CMD_READ_STATUS), buf + actual,
+ spi_w8r8(spi, CMD_READ_STATUS), buf + actual,
cmd[0], offset);
- ret = spi_flash_cmd_write(flash->spi, cmd, cmd_len,
+ ret = spi_flash_cmd_write(spi, cmd, cmd_len,
buf + actual, 2);
if (ret) {
debug("SF: sst word program failed\n");
@@ -590,17 +596,18 @@ int sst_write_wp(struct spi_flash *flash, u32 offset, size_t len,
debug("SF: sst: program %s %zu bytes @ 0x%zx\n",
ret ? "failure" : "success", len, offset - actual);
- spi_release_bus(flash->spi);
+ spi_release_bus(spi);
return ret;
}
int sst_write_bp(struct spi_flash *flash, u32 offset, size_t len,
const void *buf)
{
+ struct spi_slave *spi = flash->spi;
size_t actual;
int ret;
- ret = spi_claim_bus(flash->spi);
+ ret = spi_claim_bus(spi);
if (ret) {
debug("SF: Unable to claim SPI bus\n");
return ret;
@@ -621,7 +628,7 @@ int sst_write_bp(struct spi_flash *flash, u32 offset, size_t len,
debug("SF: sst: program %s %zu bytes @ 0x%zx\n",
ret ? "failure" : "success", len, offset - actual);
- spi_release_bus(flash->spi);
+ spi_release_bus(spi);
return ret;
}
#endif
@@ -950,7 +957,7 @@ int spi_flash_scan(struct spi_flash *flash)
/* Assign spi data */
flash->name = params->name;
flash->memory_map = spi->memory_map;
- flash->dual_flash = flash->spi->option;
+ flash->dual_flash = spi->option;
/* Assign spi flash flags */
if (params->flags & SST_WR)
@@ -961,7 +968,7 @@ int spi_flash_scan(struct spi_flash *flash)
flash->write = spi_flash_cmd_write_ops;
#if defined(CONFIG_SPI_FLASH_SST)
if (flash->flags & SNOR_F_SST_WR) {
- if (flash->spi->op_mode_tx & SPI_OPM_TX_BP)
+ if (spi->op_mode_tx & SPI_OPM_TX_BP)
flash->write = sst_write_bp;
else
flash->write = sst_write_wp;
@@ -1025,7 +1032,7 @@ int spi_flash_scan(struct spi_flash *flash)
flash->sector_size = flash->erase_size;
/* Look for the fastest read cmd */
- cmd = fls(params->e_rd_cmd & flash->spi->op_mode_rx);
+ cmd = fls(params->e_rd_cmd & spi->op_mode_rx);
if (cmd) {
cmd = spi_read_cmds_array[cmd - 1];
flash->read_cmd = cmd;
@@ -1035,7 +1042,7 @@ int spi_flash_scan(struct spi_flash *flash)
}
/* Not require to look for fastest only two write cmds yet */
- if (params->flags & WR_QPP && flash->spi->op_mode_tx & SPI_OPM_TX_QPP)
+ if (params->flags & WR_QPP && spi->op_mode_tx & SPI_OPM_TX_QPP)
flash->write_cmd = CMD_QUAD_PAGE_PROGRAM;
else
/* Go for default supported write cmd */
--
1.9.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [U-Boot] [PATCH v3 2/5] spi: make mode visible to both dm and non-dm
2015-12-14 9:51 [U-Boot] [PATCH v3 1/5] sf: Get spi locally from spi_flash Jagan Teki
@ 2015-12-14 9:51 ` Jagan Teki
2015-12-15 5:06 ` Bin Meng
2015-12-14 9:51 ` [U-Boot] [PATCH v3 3/5] spi: Use mode instead of op_mode_tx Jagan Teki
` (3 subsequent siblings)
4 siblings, 1 reply; 14+ messages in thread
From: Jagan Teki @ 2015-12-14 9:51 UTC (permalink / raw)
To: u-boot
Couldn't find the exact reason to define 'mode' for dm,
probably it is not using in non-dm drivers but it need
to visible both dm and non-dm as mode data is getting
dereferred in spi flash core ie common to both.
Cc: Bin Meng <bmeng.cn@gmail.com>
Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Jagan Teki <jteki@openedev.com>
---
Changes for v3:
- none
Changes for v2:
- Used uint instead u8 in mode
include/spi.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/spi.h b/include/spi.h
index b4d2723..05202d0 100644
--- a/include/spi.h
+++ b/include/spi.h
@@ -99,13 +99,13 @@ struct dm_spi_slave_platdata {
*
* @dev: SPI slave device
* @max_hz: Maximum speed for this slave
- * @mode: SPI mode to use for this slave (see SPI mode flags)
* @speed: Current bus speed. This is 0 until the bus is first
* claimed.
* @bus: ID of the bus that the slave is attached to. For
* driver model this is the sequence number of the SPI
* bus (bus->seq) so does not need to be stored
* @cs: ID of the chip select connected to the slave.
+ * @mode: SPI mode to use for this slave (see SPI mode flags)
* @op_mode_rx: SPI RX operation mode.
* @op_mode_tx: SPI TX operation mode.
* @wordlen: Size of SPI word in number of bits
@@ -120,11 +120,11 @@ struct spi_slave {
struct udevice *dev; /* struct spi_slave is dev->parentdata */
uint max_hz;
uint speed;
- uint mode;
#else
unsigned int bus;
unsigned int cs;
#endif
+ uint mode;
u8 op_mode_rx;
u8 op_mode_tx;
unsigned int wordlen;
--
1.9.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [U-Boot] [PATCH v3 3/5] spi: Use mode instead of op_mode_tx
2015-12-14 9:51 [U-Boot] [PATCH v3 1/5] sf: Get spi locally from spi_flash Jagan Teki
2015-12-14 9:51 ` [U-Boot] [PATCH v3 2/5] spi: make mode visible to both dm and non-dm Jagan Teki
@ 2015-12-14 9:51 ` Jagan Teki
2015-12-15 5:06 ` Bin Meng
2015-12-14 9:51 ` [U-Boot] [PATCH v3 4/5] spi: Rename SPI_TX_BP|QPP to SPI_TX_BYTE|QUAD Jagan Teki
` (2 subsequent siblings)
4 siblings, 1 reply; 14+ messages in thread
From: Jagan Teki @ 2015-12-14 9:51 UTC (permalink / raw)
To: u-boot
Used mode member from spi_slave{} instead of op_mode_tx.
Cc: Bin Meng <bmeng.cn@gmail.com>
Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Jagan Teki <jteki@openedev.com>
---
Changes for v3:
- none
Changes for v2:
- none
drivers/mtd/spi/sf_probe.c | 2 +-
drivers/mtd/spi/spi_flash.c | 4 ++--
drivers/spi/ich.c | 2 +-
include/spi.h | 8 ++------
4 files changed, 6 insertions(+), 10 deletions(-)
diff --git a/drivers/mtd/spi/sf_probe.c b/drivers/mtd/spi/sf_probe.c
index 0cafc29..3519ffd 100644
--- a/drivers/mtd/spi/sf_probe.c
+++ b/drivers/mtd/spi/sf_probe.c
@@ -128,7 +128,7 @@ static int spi_flash_std_write(struct udevice *dev, u32 offset, size_t len,
#if defined(CONFIG_SPI_FLASH_SST)
if (flash->flags & SNOR_F_SST_WR) {
- if (flash->spi->op_mode_tx & SPI_OPM_TX_BP)
+ if (flash->spi->mode & SPI_TX_BP)
return sst_write_bp(flash, offset, len, buf);
else
return sst_write_wp(flash, offset, len, buf);
diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c
index 30a381b..836aad9 100644
--- a/drivers/mtd/spi/spi_flash.c
+++ b/drivers/mtd/spi/spi_flash.c
@@ -968,7 +968,7 @@ int spi_flash_scan(struct spi_flash *flash)
flash->write = spi_flash_cmd_write_ops;
#if defined(CONFIG_SPI_FLASH_SST)
if (flash->flags & SNOR_F_SST_WR) {
- if (spi->op_mode_tx & SPI_OPM_TX_BP)
+ if (spi->mode & SPI_TX_BP)
flash->write = sst_write_bp;
else
flash->write = sst_write_wp;
@@ -1042,7 +1042,7 @@ int spi_flash_scan(struct spi_flash *flash)
}
/* Not require to look for fastest only two write cmds yet */
- if (params->flags & WR_QPP && spi->op_mode_tx & SPI_OPM_TX_QPP)
+ if (params->flags & WR_QPP && spi->mode & SPI_TX_QPP)
flash->write_cmd = CMD_QUAD_PAGE_PROGRAM;
else
/* Go for default supported write cmd */
diff --git a/drivers/spi/ich.c b/drivers/spi/ich.c
index f85af9c..64322dd 100644
--- a/drivers/spi/ich.c
+++ b/drivers/spi/ich.c
@@ -753,7 +753,7 @@ static int ich_spi_child_pre_probe(struct udevice *dev)
*/
if (plat->ich_version == 7) {
slave->op_mode_rx = SPI_OPM_RX_AS;
- slave->op_mode_tx = SPI_OPM_TX_BP;
+ slave->mode = SPI_TX_BP;
}
return 0;
diff --git a/include/spi.h b/include/spi.h
index 05202d0..67521721 100644
--- a/include/spi.h
+++ b/include/spi.h
@@ -23,6 +23,8 @@
#define SPI_LOOP 0x20 /* loopback mode */
#define SPI_SLAVE 0x40 /* slave mode */
#define SPI_PREAMBLE 0x80 /* Skip preamble bytes */
+#define SPI_TX_BP 0x100 /* transmit with 1 wire byte */
+#define SPI_TX_QPP 0x200 /* transmit with 4 wires */
/* SPI transfer flags */
#define SPI_XFER_BEGIN 0x01 /* Assert CS before transfer */
@@ -32,10 +34,6 @@
#define SPI_XFER_ONCE (SPI_XFER_BEGIN | SPI_XFER_END)
#define SPI_XFER_U_PAGE (1 << 5)
-/* SPI TX operation modes */
-#define SPI_OPM_TX_QPP (1 << 0)
-#define SPI_OPM_TX_BP (1 << 1)
-
/* SPI RX operation modes */
#define SPI_OPM_RX_AS (1 << 0)
#define SPI_OPM_RX_AF (1 << 1)
@@ -107,7 +105,6 @@ struct dm_spi_slave_platdata {
* @cs: ID of the chip select connected to the slave.
* @mode: SPI mode to use for this slave (see SPI mode flags)
* @op_mode_rx: SPI RX operation mode.
- * @op_mode_tx: SPI TX operation mode.
* @wordlen: Size of SPI word in number of bits
* @max_write_size: If non-zero, the maximum number of bytes which can
* be written@once, excluding command bytes.
@@ -126,7 +123,6 @@ struct spi_slave {
#endif
uint mode;
u8 op_mode_rx;
- u8 op_mode_tx;
unsigned int wordlen;
unsigned int max_write_size;
void *memory_map;
--
1.9.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [U-Boot] [PATCH v3 4/5] spi: Rename SPI_TX_BP|QPP to SPI_TX_BYTE|QUAD
2015-12-14 9:51 [U-Boot] [PATCH v3 1/5] sf: Get spi locally from spi_flash Jagan Teki
2015-12-14 9:51 ` [U-Boot] [PATCH v3 2/5] spi: make mode visible to both dm and non-dm Jagan Teki
2015-12-14 9:51 ` [U-Boot] [PATCH v3 3/5] spi: Use mode instead of op_mode_tx Jagan Teki
@ 2015-12-14 9:51 ` Jagan Teki
2015-12-15 5:06 ` Bin Meng
2015-12-14 9:51 ` [U-Boot] [PATCH v3 5/5] sf: Move spi_read_cmds_array locally Jagan Teki
2015-12-15 5:06 ` [U-Boot] [PATCH v3 1/5] sf: Get spi locally from spi_flash Bin Meng
4 siblings, 1 reply; 14+ messages in thread
From: Jagan Teki @ 2015-12-14 9:51 UTC (permalink / raw)
To: u-boot
Since SPI_TX_* are spi_slave{} members so use spi protocol
notation instead spi flash programming, like
SPI_TX_BP => SPI_TX_BYTE
SPI_TX_QPP => SPI_TX_QUAD
Cc: Bin Meng <bmeng.cn@gmail.com>
Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Jagan Teki <jteki@openedev.com>
---
Changes for v3:
- none
Changes for v2:
- none
drivers/mtd/spi/sf_probe.c | 2 +-
drivers/mtd/spi/spi_flash.c | 4 ++--
drivers/spi/ich.c | 2 +-
include/spi.h | 4 ++--
4 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/mtd/spi/sf_probe.c b/drivers/mtd/spi/sf_probe.c
index 3519ffd..daa1d5b 100644
--- a/drivers/mtd/spi/sf_probe.c
+++ b/drivers/mtd/spi/sf_probe.c
@@ -128,7 +128,7 @@ static int spi_flash_std_write(struct udevice *dev, u32 offset, size_t len,
#if defined(CONFIG_SPI_FLASH_SST)
if (flash->flags & SNOR_F_SST_WR) {
- if (flash->spi->mode & SPI_TX_BP)
+ if (flash->spi->mode & SPI_TX_BYTE)
return sst_write_bp(flash, offset, len, buf);
else
return sst_write_wp(flash, offset, len, buf);
diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c
index 836aad9..513d9ad 100644
--- a/drivers/mtd/spi/spi_flash.c
+++ b/drivers/mtd/spi/spi_flash.c
@@ -968,7 +968,7 @@ int spi_flash_scan(struct spi_flash *flash)
flash->write = spi_flash_cmd_write_ops;
#if defined(CONFIG_SPI_FLASH_SST)
if (flash->flags & SNOR_F_SST_WR) {
- if (spi->mode & SPI_TX_BP)
+ if (spi->mode & SPI_TX_BYTE)
flash->write = sst_write_bp;
else
flash->write = sst_write_wp;
@@ -1042,7 +1042,7 @@ int spi_flash_scan(struct spi_flash *flash)
}
/* Not require to look for fastest only two write cmds yet */
- if (params->flags & WR_QPP && spi->mode & SPI_TX_QPP)
+ if (params->flags & WR_QPP && spi->mode & SPI_TX_QUAD)
flash->write_cmd = CMD_QUAD_PAGE_PROGRAM;
else
/* Go for default supported write cmd */
diff --git a/drivers/spi/ich.c b/drivers/spi/ich.c
index 64322dd..d11132c 100644
--- a/drivers/spi/ich.c
+++ b/drivers/spi/ich.c
@@ -753,7 +753,7 @@ static int ich_spi_child_pre_probe(struct udevice *dev)
*/
if (plat->ich_version == 7) {
slave->op_mode_rx = SPI_OPM_RX_AS;
- slave->mode = SPI_TX_BP;
+ slave->mode = SPI_TX_BYTE;
}
return 0;
diff --git a/include/spi.h b/include/spi.h
index 67521721..b9a6e6f 100644
--- a/include/spi.h
+++ b/include/spi.h
@@ -23,8 +23,8 @@
#define SPI_LOOP 0x20 /* loopback mode */
#define SPI_SLAVE 0x40 /* slave mode */
#define SPI_PREAMBLE 0x80 /* Skip preamble bytes */
-#define SPI_TX_BP 0x100 /* transmit with 1 wire byte */
-#define SPI_TX_QPP 0x200 /* transmit with 4 wires */
+#define SPI_TX_BYTE 0x100 /* transmit with 1 wire byte */
+#define SPI_TX_QUAD 0x200 /* transmit with 4 wires */
/* SPI transfer flags */
#define SPI_XFER_BEGIN 0x01 /* Assert CS before transfer */
--
1.9.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [U-Boot] [PATCH v3 5/5] sf: Move spi_read_cmds_array locally
2015-12-14 9:51 [U-Boot] [PATCH v3 1/5] sf: Get spi locally from spi_flash Jagan Teki
` (2 preceding siblings ...)
2015-12-14 9:51 ` [U-Boot] [PATCH v3 4/5] spi: Rename SPI_TX_BP|QPP to SPI_TX_BYTE|QUAD Jagan Teki
@ 2015-12-14 9:51 ` Jagan Teki
2015-12-15 6:30 ` Jagan Teki
2015-12-15 5:06 ` [U-Boot] [PATCH v3 1/5] sf: Get spi locally from spi_flash Bin Meng
4 siblings, 1 reply; 14+ messages in thread
From: Jagan Teki @ 2015-12-14 9:51 UTC (permalink / raw)
To: u-boot
Since spi_read_cmds_array is used locally in
spi_flash_scan, so move array to locally used
function instead of defining global array.
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Signed-off-by: Jagan Teki <jteki@openedev.com>
---
Changes for v3:
- none
Changes for v2:
- none
drivers/mtd/spi/spi_flash.c | 20 ++++++++------------
1 file changed, 8 insertions(+), 12 deletions(-)
diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c
index 513d9ad..32b2d15 100644
--- a/drivers/mtd/spi/spi_flash.c
+++ b/drivers/mtd/spi/spi_flash.c
@@ -29,16 +29,6 @@ static void spi_flash_addr(u32 addr, u8 *cmd)
cmd[3] = addr >> 0;
}
-/* Read commands array */
-static u8 spi_read_cmds_array[] = {
- CMD_READ_ARRAY_SLOW,
- CMD_READ_ARRAY_FAST,
- CMD_READ_DUAL_OUTPUT_FAST,
- CMD_READ_DUAL_IO_FAST,
- CMD_READ_QUAD_OUTPUT_FAST,
- CMD_READ_QUAD_IO_FAST,
-};
-
static int read_sr(struct spi_flash *flash, u8 *rs)
{
int ret;
@@ -909,9 +899,15 @@ int spi_flash_scan(struct spi_flash *flash)
struct spi_slave *spi = flash->spi;
const struct spi_flash_params *params;
u16 jedec, ext_jedec;
- u8 idcode[5];
- u8 cmd;
+ u8 cmd, idcode[5];
int ret;
+ static u8 spi_read_cmds_array[] = {
+ CMD_READ_ARRAY_SLOW,
+ CMD_READ_ARRAY_FAST,
+ CMD_READ_DUAL_OUTPUT_FAST,
+ CMD_READ_DUAL_IO_FAST,
+ CMD_READ_QUAD_OUTPUT_FAST,
+ CMD_READ_QUAD_IO_FAST };
/* Read the ID codes */
ret = spi_flash_cmd(spi, CMD_READ_ID, idcode, sizeof(idcode));
--
1.9.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [U-Boot] [PATCH v3 1/5] sf: Get spi locally from spi_flash
2015-12-14 9:51 [U-Boot] [PATCH v3 1/5] sf: Get spi locally from spi_flash Jagan Teki
` (3 preceding siblings ...)
2015-12-14 9:51 ` [U-Boot] [PATCH v3 5/5] sf: Move spi_read_cmds_array locally Jagan Teki
@ 2015-12-15 5:06 ` Bin Meng
2015-12-15 6:28 ` Jagan Teki
4 siblings, 1 reply; 14+ messages in thread
From: Bin Meng @ 2015-12-15 5:06 UTC (permalink / raw)
To: u-boot
On Mon, Dec 14, 2015 at 5:51 PM, Jagan Teki <jteki@openedev.com> wrote:
> For better code readabilty, get the spi pointer from
> spi_flash{} locally and use it instead of direct
> dereferring spi pinter as flash->spi->*
>
> Signed-off-by: Jagan Teki <jteki@openedev.com>
> ---
> Changes for v3:
> - none
> Changes for v2:
> - Fixed missing spi declaration for sst_write_*
>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Bin Meng <bmeng.cn@gmail.com>
^ permalink raw reply [flat|nested] 14+ messages in thread
* [U-Boot] [PATCH v3 2/5] spi: make mode visible to both dm and non-dm
2015-12-14 9:51 ` [U-Boot] [PATCH v3 2/5] spi: make mode visible to both dm and non-dm Jagan Teki
@ 2015-12-15 5:06 ` Bin Meng
2015-12-15 6:29 ` Jagan Teki
0 siblings, 1 reply; 14+ messages in thread
From: Bin Meng @ 2015-12-15 5:06 UTC (permalink / raw)
To: u-boot
On Mon, Dec 14, 2015 at 5:51 PM, Jagan Teki <jteki@openedev.com> wrote:
> Couldn't find the exact reason to define 'mode' for dm,
> probably it is not using in non-dm drivers but it need
> to visible both dm and non-dm as mode data is getting
> dereferred in spi flash core ie common to both.
>
> Cc: Bin Meng <bmeng.cn@gmail.com>
> Cc: Simon Glass <sjg@chromium.org>
> Signed-off-by: Jagan Teki <jteki@openedev.com>
> ---
> Changes for v3:
> - none
> Changes for v2:
> - Used uint instead u8 in mode
>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Bin Meng <bmeng.cn@gmail.com>
^ permalink raw reply [flat|nested] 14+ messages in thread
* [U-Boot] [PATCH v3 3/5] spi: Use mode instead of op_mode_tx
2015-12-14 9:51 ` [U-Boot] [PATCH v3 3/5] spi: Use mode instead of op_mode_tx Jagan Teki
@ 2015-12-15 5:06 ` Bin Meng
2015-12-15 6:29 ` Jagan Teki
0 siblings, 1 reply; 14+ messages in thread
From: Bin Meng @ 2015-12-15 5:06 UTC (permalink / raw)
To: u-boot
On Mon, Dec 14, 2015 at 5:51 PM, Jagan Teki <jteki@openedev.com> wrote:
> Used mode member from spi_slave{} instead of op_mode_tx.
>
> Cc: Bin Meng <bmeng.cn@gmail.com>
> Cc: Simon Glass <sjg@chromium.org>
> Signed-off-by: Jagan Teki <jteki@openedev.com>
> ---
> Changes for v3:
> - none
> Changes for v2:
> - none
>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Bin Meng <bmeng.cn@gmail.com>
^ permalink raw reply [flat|nested] 14+ messages in thread
* [U-Boot] [PATCH v3 4/5] spi: Rename SPI_TX_BP|QPP to SPI_TX_BYTE|QUAD
2015-12-14 9:51 ` [U-Boot] [PATCH v3 4/5] spi: Rename SPI_TX_BP|QPP to SPI_TX_BYTE|QUAD Jagan Teki
@ 2015-12-15 5:06 ` Bin Meng
2015-12-15 6:29 ` Jagan Teki
0 siblings, 1 reply; 14+ messages in thread
From: Bin Meng @ 2015-12-15 5:06 UTC (permalink / raw)
To: u-boot
On Mon, Dec 14, 2015 at 5:51 PM, Jagan Teki <jteki@openedev.com> wrote:
> Since SPI_TX_* are spi_slave{} members so use spi protocol
> notation instead spi flash programming, like
>
> SPI_TX_BP => SPI_TX_BYTE
> SPI_TX_QPP => SPI_TX_QUAD
>
> Cc: Bin Meng <bmeng.cn@gmail.com>
> Cc: Simon Glass <sjg@chromium.org>
> Signed-off-by: Jagan Teki <jteki@openedev.com>
> ---
> Changes for v3:
> - none
> Changes for v2:
> - none
>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Bin Meng <bmeng.cn@gmail.com>
^ permalink raw reply [flat|nested] 14+ messages in thread
* [U-Boot] [PATCH v3 1/5] sf: Get spi locally from spi_flash
2015-12-15 5:06 ` [U-Boot] [PATCH v3 1/5] sf: Get spi locally from spi_flash Bin Meng
@ 2015-12-15 6:28 ` Jagan Teki
0 siblings, 0 replies; 14+ messages in thread
From: Jagan Teki @ 2015-12-15 6:28 UTC (permalink / raw)
To: u-boot
On 15 December 2015 at 10:36, Bin Meng <bmeng.cn@gmail.com> wrote:
> On Mon, Dec 14, 2015 at 5:51 PM, Jagan Teki <jteki@openedev.com> wrote:
>> For better code readabilty, get the spi pointer from
>> spi_flash{} locally and use it instead of direct
>> dereferring spi pinter as flash->spi->*
>>
>> Signed-off-by: Jagan Teki <jteki@openedev.com>
>> ---
>> Changes for v3:
>> - none
>> Changes for v2:
>> - Fixed missing spi declaration for sst_write_*
>>
>
> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
> Tested-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Jagan Teki <jteki@openedev.com>
Applied to u-boot-spi/master
thanks!
--
Jagan.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [U-Boot] [PATCH v3 2/5] spi: make mode visible to both dm and non-dm
2015-12-15 5:06 ` Bin Meng
@ 2015-12-15 6:29 ` Jagan Teki
0 siblings, 0 replies; 14+ messages in thread
From: Jagan Teki @ 2015-12-15 6:29 UTC (permalink / raw)
To: u-boot
On 15 December 2015 at 10:36, Bin Meng <bmeng.cn@gmail.com> wrote:
> On Mon, Dec 14, 2015 at 5:51 PM, Jagan Teki <jteki@openedev.com> wrote:
>> Couldn't find the exact reason to define 'mode' for dm,
>> probably it is not using in non-dm drivers but it need
>> to visible both dm and non-dm as mode data is getting
>> dereferred in spi flash core ie common to both.
>>
>> Cc: Bin Meng <bmeng.cn@gmail.com>
>> Cc: Simon Glass <sjg@chromium.org>
>> Signed-off-by: Jagan Teki <jteki@openedev.com>
>> ---
>> Changes for v3:
>> - none
>> Changes for v2:
>> - Used uint instead u8 in mode
>>
>
> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
> Tested-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Jagan Teki <jteki@openedev.com>
Applied to u-boot-spi/master
thanks!
--
Jagan.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [U-Boot] [PATCH v3 3/5] spi: Use mode instead of op_mode_tx
2015-12-15 5:06 ` Bin Meng
@ 2015-12-15 6:29 ` Jagan Teki
0 siblings, 0 replies; 14+ messages in thread
From: Jagan Teki @ 2015-12-15 6:29 UTC (permalink / raw)
To: u-boot
On 15 December 2015 at 10:36, Bin Meng <bmeng.cn@gmail.com> wrote:
> On Mon, Dec 14, 2015 at 5:51 PM, Jagan Teki <jteki@openedev.com> wrote:
>> Used mode member from spi_slave{} instead of op_mode_tx.
>>
>> Cc: Bin Meng <bmeng.cn@gmail.com>
>> Cc: Simon Glass <sjg@chromium.org>
>> Signed-off-by: Jagan Teki <jteki@openedev.com>
>> ---
>> Changes for v3:
>> - none
>> Changes for v2:
>> - none
>>
>
> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
> Tested-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Jagan Teki <jteki@openedev.com>
Applied to u-boot-spi/master
thanks!
--
Jagan.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [U-Boot] [PATCH v3 4/5] spi: Rename SPI_TX_BP|QPP to SPI_TX_BYTE|QUAD
2015-12-15 5:06 ` Bin Meng
@ 2015-12-15 6:29 ` Jagan Teki
0 siblings, 0 replies; 14+ messages in thread
From: Jagan Teki @ 2015-12-15 6:29 UTC (permalink / raw)
To: u-boot
On 15 December 2015 at 10:36, Bin Meng <bmeng.cn@gmail.com> wrote:
> On Mon, Dec 14, 2015 at 5:51 PM, Jagan Teki <jteki@openedev.com> wrote:
>> Since SPI_TX_* are spi_slave{} members so use spi protocol
>> notation instead spi flash programming, like
>>
>> SPI_TX_BP => SPI_TX_BYTE
>> SPI_TX_QPP => SPI_TX_QUAD
>>
>> Cc: Bin Meng <bmeng.cn@gmail.com>
>> Cc: Simon Glass <sjg@chromium.org>
>> Signed-off-by: Jagan Teki <jteki@openedev.com>
>> ---
>> Changes for v3:
>> - none
>> Changes for v2:
>> - none
>>
>
> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
> Tested-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Jagan Teki <jteki@openedev.com>
Applied to u-boot-spi/master
thanks!
--
Jagan.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [U-Boot] [PATCH v3 5/5] sf: Move spi_read_cmds_array locally
2015-12-14 9:51 ` [U-Boot] [PATCH v3 5/5] sf: Move spi_read_cmds_array locally Jagan Teki
@ 2015-12-15 6:30 ` Jagan Teki
0 siblings, 0 replies; 14+ messages in thread
From: Jagan Teki @ 2015-12-15 6:30 UTC (permalink / raw)
To: u-boot
On 14 December 2015 at 15:21, Jagan Teki <jteki@openedev.com> wrote:
> Since spi_read_cmds_array is used locally in
> spi_flash_scan, so move array to locally used
> function instead of defining global array.
>
> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
> Signed-off-by: Jagan Teki <jteki@openedev.com>
Tested-by: Jagan Teki <jteki@openedev.com>
Applied to u-boot-spi/master
thanks!
--
Jagan.
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2015-12-15 6:30 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-14 9:51 [U-Boot] [PATCH v3 1/5] sf: Get spi locally from spi_flash Jagan Teki
2015-12-14 9:51 ` [U-Boot] [PATCH v3 2/5] spi: make mode visible to both dm and non-dm Jagan Teki
2015-12-15 5:06 ` Bin Meng
2015-12-15 6:29 ` Jagan Teki
2015-12-14 9:51 ` [U-Boot] [PATCH v3 3/5] spi: Use mode instead of op_mode_tx Jagan Teki
2015-12-15 5:06 ` Bin Meng
2015-12-15 6:29 ` Jagan Teki
2015-12-14 9:51 ` [U-Boot] [PATCH v3 4/5] spi: Rename SPI_TX_BP|QPP to SPI_TX_BYTE|QUAD Jagan Teki
2015-12-15 5:06 ` Bin Meng
2015-12-15 6:29 ` Jagan Teki
2015-12-14 9:51 ` [U-Boot] [PATCH v3 5/5] sf: Move spi_read_cmds_array locally Jagan Teki
2015-12-15 6:30 ` Jagan Teki
2015-12-15 5:06 ` [U-Boot] [PATCH v3 1/5] sf: Get spi locally from spi_flash Bin Meng
2015-12-15 6:28 ` Jagan Teki
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.