Few of the flash families with different ext_jedec
have changes in page_size so these macros check these
ext_jedec and assign page_size accordingly

Cc: Simon Glass <s...@chromium.org>
Cc: Bin Meng <bmeng...@gmail.com>
Cc: York Sun <york....@nxp.com>
Cc: Vignesh R <vigne...@ti.com>
Cc: Mugunthan V N <mugunthan...@ti.com>
Cc: Michal Simek <michal.si...@xilinx.com>
Cc: Siva Durga Prasad Paladugu <siva...@xilinx.com>
Signed-off-by: Jagan Teki <jt...@openedev.com>
---
 drivers/mtd/spi/sf_internal.h |  4 ++++
 drivers/mtd/spi/spi_flash.c   | 10 ++++------
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/mtd/spi/sf_internal.h b/drivers/mtd/spi/sf_internal.h
index e6cd6da..966fd21 100644
--- a/drivers/mtd/spi/sf_internal.h
+++ b/drivers/mtd/spi/sf_internal.h
@@ -103,6 +103,10 @@ int sst_write_bp(struct spi_flash *flash, u32 offset, 
size_t len,
 #define CMD_SPANSION_RDAR      0x65 /* Read any device register */
 #define CMD_SPANSION_WRAR      0x71 /* Write any device register */
 #endif
+
+#define JEDEC_ID(params)       (((params)->id[1]) << 8 | ((params)->id[2]))
+#define JEDEC_EXT(params)      (((params)->id[3]) << 8 | ((params)->id[4]))
+
 /**
  * struct spi_flash_params - SPI/QSPI flash device params structure
  *
diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c
index 680d1dc..e979b8e 100644
--- a/drivers/mtd/spi/spi_flash.c
+++ b/drivers/mtd/spi/spi_flash.c
@@ -1130,19 +1130,17 @@ int spi_flash_scan(struct spi_flash *flash)
 
        /* Compute the flash size */
        flash->shift = (flash->dual_flash & SF_DUAL_PARALLEL_FLASH) ? 1 : 0;
+       flash->page_size = params->page_size;
        /*
         * The Spansion S25FL032P and S25FL064P have 256b pages, yet use the
         * 0x4d00 Extended JEDEC code. The rest of the Spansion flashes with
         * the 0x4d00 Extended JEDEC code have 512b pages. All of the others
         * have 256b pages.
         */
-       if (ext_jedec == 0x4d00) {
-               if ((jedec == 0x0215) || (jedec == 0x216) || (jedec == 0x220))
-                       flash->page_size = 256;
-               else
+       if (JEDEC_EXT(params) == 0x4d00) {
+               if ((JEDEC_ID(params) != 0x0215) &&
+                   (JEDEC_ID(params) != 0x0216))
                        flash->page_size = 512;
-       } else {
-               flash->page_size = 256;
        }
        flash->page_size <<= flash->shift;
        flash->sector_size = params->sector_size << flash->shift;
-- 
2.7.4

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

Reply via email to