diff mbox

[U-Boot,v3,13/28] sf: probe: Add support to clear flash BP# bits

Message ID 7ba57c38-73e6-411f-bd39-af16e675eef6@VA3EHSMHS018.ehs.local
State Superseded
Delegated to: Jagannadha Sutradharudu Teki
Headers show

Commit Message

Jagannadha Sutradharudu Teki Sept. 15, 2013, 6:15 p.m. UTC
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 v3:
	- none
Changes for v2:
	- none

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

Patch

diff --git a/drivers/mtd/spi/spi_flash_probe.c b/drivers/mtd/spi/spi_flash_probe.c
index f97097a..839ece5 100644
--- a/drivers/mtd/spi/spi_flash_probe.c
+++ b/drivers/mtd/spi/spi_flash_probe.c
@@ -203,6 +203,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 */