sf: Flash power up read-only based on idcode0
authorJagan Teki <jteki@openedev.com>
Tue, 29 Sep 2015 20:31:23 +0000 (02:01 +0530)
committerJagan Teki <jteki@openedev.com>
Fri, 11 Dec 2015 16:42:24 +0000 (22:12 +0530)
Using macro's for flash power up read-only access code
leads wrong behaviour hence use idcode0 for runtime
detection, hence the flash which require this functionality
gets detected at runtime.

Tested-by: Jagan Teki <jteki@openedev.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Jagan Teki <jteki@openedev.com>
drivers/mtd/spi/sf_internal.h
drivers/mtd/spi/sf_ops.c

index 8f586eed0dac5623a253345d177681e0acd01102..b8692c6147f30a46c0412cb8f3cf964b9c3b9ebf 100644 (file)
@@ -66,6 +66,7 @@ enum spi_nor_option_flags {
 #define SPI_FLASH_CFI_MFR_MACRONIX     0xc2
 #define SPI_FLASH_CFI_MFR_SST          0xbf
 #define SPI_FLASH_CFI_MFR_WINBOND      0xef
+#define SPI_FLASH_CFI_MFR_ATMEL                0x1f
 
 /* Erase commands */
 #define CMD_ERASE_4K                   0x20
index 853759eeb5f814e293ca7369e374f8cb2dc3f378..e5514ab00f6224f74c927414ebc8b9fc4211f86f 100644 (file)
@@ -941,11 +941,10 @@ int spi_flash_scan(struct spi_slave *spi, struct spi_flash *flash)
        }
 
        /* Flash powers up read-only, so clear BP# bits */
-#if defined(CONFIG_SPI_FLASH_ATMEL) || \
-       defined(CONFIG_SPI_FLASH_MACRONIX) || \
-       defined(CONFIG_SPI_FLASH_SST)
+       if (idcode[0] == SPI_FLASH_CFI_MFR_ATMEL ||
+           idcode[0] == SPI_FLASH_CFI_MFR_MACRONIX ||
+           idcode[0] == SPI_FLASH_CFI_MFR_SST)
                write_sr(flash, 0);
-#endif
 
        /* Assign spi data */
        flash->spi = spi;