@@ -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
*
@@ -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;
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@chromium.org> Cc: Bin Meng <bmeng.cn@gmail.com> Cc: York Sun <york.sun@nxp.com> Cc: Vignesh R <vigneshr@ti.com> Cc: Mugunthan V N <mugunthanvnm@ti.com> Cc: Michal Simek <michal.simek@xilinx.com> Cc: Siva Durga Prasad Paladugu <sivadur@xilinx.com> Signed-off-by: Jagan Teki <jteki@openedev.com> --- drivers/mtd/spi/sf_internal.h | 4 ++++ drivers/mtd/spi/spi_flash.c | 10 ++++------ 2 files changed, 8 insertions(+), 6 deletions(-)