From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jagan Teki Date: Thu, 11 Aug 2016 13:37:31 +0530 Subject: [U-Boot] [PATCH v3 09/27] sf: Add JEDEC_ID and JEDEC_EXT macro In-Reply-To: <1470902869-22570-1-git-send-email-jteki@openedev.com> References: <1470902869-22570-1-git-send-email-jteki@openedev.com> Message-ID: <1470902869-22570-9-git-send-email-jteki@openedev.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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 Cc: Bin Meng Cc: York Sun Cc: Vignesh R Cc: Mugunthan V N Cc: Michal Simek Cc: Siva Durga Prasad Paladugu Signed-off-by: Jagan Teki --- 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