[U-Boot] [PATCH v2 08/22] sf: Add JEDEC_ID and JEDEC_EXT macro

Jagan Teki jteki at openedev.com
Tue Aug 9 22:04:00 CEST 2016


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 <sjg at chromium.org>
Cc: Bin Meng <bmeng.cn at gmail.com>
Cc: York Sun <york.sun at nxp.com>
Cc: Vignesh R <vigneshr at ti.com>
Cc: Mugunthan V N <mugunthanvnm at ti.com>
Cc: Michal Simek <michal.simek at xilinx.com>
Cc: Siva Durga Prasad Paladugu <sivadur at xilinx.com>
Signed-off-by: Jagan Teki <jteki at 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 3f20b67..a57c330 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 58d5a6a..c84c6b7 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



More information about the U-Boot mailing list