On Monday 06 January 2014 04:00 PM, Jagan Teki wrote:
On Mon, Jan 6, 2014 at 3:51 PM, Sourav Poddar<sourav.pod...@ti.com>  wrote:
On Monday 06 January 2014 03:48 PM, Jagan Teki wrote:
Hi Sourav,

On Mon, Jan 6, 2014 at 12:34 PM, Sourav Poddar<sourav.pod...@ti.com>
wrote:
On Saturday 04 January 2014 08:34 PM, Jagannadha Sutradharudu Teki wrote:
Discovered the read dummy_cycles based on the configured
read command.

Signed-off-by: Jagannadha Sutradharudu Teki<jaga...@xilinx.com>
---
    drivers/mtd/spi/sf_internal.h |  2 ++
    drivers/mtd/spi/sf_ops.c      | 10 ++++++----
    drivers/mtd/spi/sf_probe.c    | 12 ++++++++++++
    include/spi_flash.h           |  2 ++
    4 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/spi/sf_internal.h
b/drivers/mtd/spi/sf_internal.h
index 7be0292..a9f5a81 100644
--- a/drivers/mtd/spi/sf_internal.h
+++ b/drivers/mtd/spi/sf_internal.h
@@ -10,6 +10,8 @@
    #ifndef _SF_INTERNAL_H_
    #define _SF_INTERNAL_H_

+#define SPI_FLASH_3B_ADDR_LEN          3
+#define SPI_FLASH_CMD_LEN              (1 + SPI_FLASH_3B_ADDR_LEN)
    #define SPI_FLASH_16MB_BOUN           0x1000000

    /* CFI Manufacture ID's */
diff --git a/drivers/mtd/spi/sf_ops.c b/drivers/mtd/spi/sf_ops.c
index 827f719..dda75b1 100644
--- a/drivers/mtd/spi/sf_ops.c
+++ b/drivers/mtd/spi/sf_ops.c
@@ -9,6 +9,7 @@
     */

    #include<common.h>
+#include<malloc.h>
    #include<spi.h>
    #include<spi_flash.h>
    #include<watchdog.h>
@@ -216,7 +217,7 @@ int spi_flash_write_common(struct spi_flash *flash,
const u8 *cmd,
    int spi_flash_cmd_erase_ops(struct spi_flash *flash, u32 offset,
size_t
len)
    {
          u32 erase_size;
-       u8 cmd[4];
+       u8 cmd[SPI_FLASH_CMD_LEN];
          int ret = -1;

          erase_size = flash->erase_size;
@@ -255,7 +256,7 @@ int spi_flash_cmd_write_ops(struct spi_flash *flash,
u32 offset,
    {
          unsigned long byte_addr, page_size;
          size_t chunk_len, actual;
-       u8 cmd[4];
+       u8 cmd[SPI_FLASH_CMD_LEN];
          int ret = -1;

          page_size = flash->page_size;
@@ -317,7 +318,7 @@ int spi_flash_read_common(struct spi_flash *flash,
const u8 *cmd,
    int spi_flash_cmd_read_ops(struct spi_flash *flash, u32 offset,
                  size_t len, void *data)
    {
-       u8 cmd[5], bank_sel = 0;
+       u8 *cmd, bank_sel = 0;
          u32 remain_len, read_len;
          int ret = -1;

@@ -335,8 +336,9 @@ int spi_flash_cmd_read_ops(struct spi_flash *flash,
u32 offset,
                  return 0;
          }

+       cmd = malloc(SPI_FLASH_CMD_LEN + flash->dummy_cycles);
+       memset(cmd, 0, SPI_FLASH_CMD_LEN + flash->dummy_cycles);
          cmd[0] = flash->read_cmd;
-       cmd[4] = 0x00;

          while (len) {
    #ifdef CONFIG_SPI_FLASH_BAR
diff --git a/drivers/mtd/spi/sf_probe.c b/drivers/mtd/spi/sf_probe.c
index a049e72..b070adc 100644
--- a/drivers/mtd/spi/sf_probe.c
+++ b/drivers/mtd/spi/sf_probe.c
@@ -140,6 +140,18 @@ static struct spi_flash
*spi_flash_validate_params(struct spi_slave *spi,
                  }
          }

+       /* Read dummy cycles */
+       switch (flash->read_cmd) {
+       case CMD_READ_QUAD_IO_FAST:
+               flash->dummy_cycles = 2;
+               break;
+       case CMD_READ_ARRAY_SLOW:
+               flash->dummy_cycles = 0;
+               break;
+       default:
+               flash->dummy_cycles = 1;
+       }
+
what about dummy cycles for dual i/o(0xbb), it has 4 clock bit dummy
cycles(macronix), so
by your code you keep it to 1(8 bit) dummy cycle. ?
Yes- Actually i miss used the names here.
These are dummy_byte_count

Ex: Except fast reads (array, dual and quad fast)
dummy_byte_count = dummy_cycles * no.of lines
dual i/o (4 dummy_cycles) - 4 * 2 = 1 dummy_byte
quad i/o (4 dummy_cycles) - 4 * 4 = 2 dummy_byte

is this calculation documented in any of the flash sheet?
I haven't see the exact calculation but ie. how the I/O operation usually works.
quad read - cmd, 3byte_inst, 1 dummy_byte(8 dummy_cycles) goes on
single line and data goes in 4 lines
quad i/o - except cmd(1 lines) remaining goes in 4 lines.

Ok, got the point.
fast, dual and quad fast have 8 dummy_cycles means 1 byte dummy the
reason why I am not including
no.of lines here is irrespective of fast(1 line), dual(2 lines) and
quad(4 lines) only data can travel among the difference lines
but the cmd,inst, dummy can travel only on single line. this can be
opposite in i/o commands.

Hope you understand - I just said based on my knowledge.
I will change the dummy_cycles into dummy_bytes - nevertheless everything
same.


_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to