Patchwork [U-Boot,RESEND,v2,13/20] sf: probe: Add support to clear flash BP# bits

login
register
mail settings
Submitter Jagannadha Sutradharudu Teki
Date Aug. 6, 2013, 4:17 p.m.
Message ID <52ade5fa-5868-4241-8f1a-d26dedecd3ff@TX2EHSMHS017.ehs.local>
Download mbox | patch
Permalink /patch/265160/
State Superseded
Delegated to: Jagannadha Sutradharudu Teki
Headers show

Comments

Jagannadha Sutradharudu Teki - Aug. 6, 2013, 4:17 p.m.
Few of the flashes(Atmel, Macronix and SST) require to
clear BP# bits in flash power ups.

So clear these BP# bits at probe time, so-that the flash
is ready for user operations.

Signed-off-by: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>
---
Changes for v2:
	- none

 drivers/mtd/spi/spi_flash_probe.c | 6 ++++++
 include/spi_flash.h               | 5 +++++
 2 files changed, 11 insertions(+)

Patch

diff --git a/drivers/mtd/spi/spi_flash_probe.c b/drivers/mtd/spi/spi_flash_probe.c
index e045e53..4368867 100644
--- a/drivers/mtd/spi/spi_flash_probe.c
+++ b/drivers/mtd/spi/spi_flash_probe.c
@@ -202,6 +202,12 @@  struct spi_flash *spi_flash_validate_ids(struct spi_slave *spi, u8 *idcode)
 	flash->sector_size = params->sector_size;
 	flash->size = flash->sector_size * params->nr_sectors;
 
+	/* Flash powers up read-only, so clear BP# bits */
+	if (((params->jedec >> 16) == SPI_FLASH_CFI_MFR_ATMEL) ||
+	    ((params->jedec >> 16) == SPI_FLASH_CFI_MFR_MACRONIX) ||
+	    ((params->jedec >> 16) == SPI_FLASH_CFI_MFR_SST))
+		spi_flash_cmd_write_status(flash, 0);
+
 	return flash;
 }
 
diff --git a/include/spi_flash.h b/include/spi_flash.h
index 4f35c30..8de4e8d 100644
--- a/include/spi_flash.h
+++ b/include/spi_flash.h
@@ -17,6 +17,11 @@ 
 #include <linux/types.h>
 #include <linux/compiler.h>
 
+/* SPI flash CFI Manufacture ID's */
+#define SPI_FLASH_CFI_MFR_ATMEL			0x1f
+#define SPI_FLASH_CFI_MFR_MACRONIX		0xc2
+#define SPI_FLASH_CFI_MFR_SST			0xbf
+
 /* SST specific macros */
 #ifdef CONFIG_SPI_FLASH_SST
 # define SST_WP			0x01	/* Supports AAI word program */