summaryrefslogtreecommitdiff
path: root/drivers/mtd/spi/sf_probe.c
diff options
context:
space:
mode:
authorHeiko Schocher <hs@denx.de>2014-07-18 04:07:21 (GMT)
committerStefano Babic <sbabic@denx.de>2014-07-23 10:26:45 (GMT)
commit562f8df18da62ae02c4ace1e530451fe82c3312d (patch)
treef3ac604fb5cc1a3865a91a99763f3d855c19bd4f /drivers/mtd/spi/sf_probe.c
parenta0ae0091d783b1140f8d321d8c6d221aeb0d39d0 (diff)
downloadu-boot-562f8df18da62ae02c4ace1e530451fe82c3312d.tar.xz
spi: add config option to enable the WP pin function on st micron flashes
enable the W#/Vpp signal to disable writing to the status register on ST MICRON flashes like the N25Q128 thorugh the new config option CONFIG_SYS_SPI_ST_ENABLE_WP_PIN Signed-off-by: Heiko Schocher <hs@denx.de> Cc: Jagannadha Sutradharudu Teki <jagannadh.teki@gmail.com>
Diffstat (limited to 'drivers/mtd/spi/sf_probe.c')
-rw-r--r--drivers/mtd/spi/sf_probe.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/drivers/mtd/spi/sf_probe.c b/drivers/mtd/spi/sf_probe.c
index 36ae5e0..4d148d1 100644
--- a/drivers/mtd/spi/sf_probe.c
+++ b/drivers/mtd/spi/sf_probe.c
@@ -281,6 +281,34 @@ int spi_flash_decode_fdt(const void *blob, struct spi_flash *flash)
}
#endif /* CONFIG_OF_CONTROL */
+#ifdef CONFIG_SYS_SPI_ST_ENABLE_WP_PIN
+/* enable the W#/Vpp signal to disable writing to the status register */
+static int spi_enable_wp_pin(struct spi_flash *flash)
+{
+ u8 status;
+ int ret;
+
+ ret = spi_flash_cmd_read_status(flash, &status);
+ if (ret < 0)
+ return ret;
+
+ ret = spi_flash_cmd_write_status(flash, STATUS_SRWD);
+ if (ret < 0)
+ return ret;
+
+ ret = spi_flash_cmd_write_disable(flash);
+ if (ret < 0)
+ return ret;
+
+ return 0;
+}
+#else
+static int spi_enable_wp_pin(struct spi_flash *flash)
+{
+ return 0;
+}
+#endif
+
static struct spi_flash *spi_flash_probe_slave(struct spi_slave *spi)
{
struct spi_flash *flash = NULL;
@@ -351,6 +379,8 @@ static struct spi_flash *spi_flash_probe_slave(struct spi_slave *spi)
puts(" Full access #define CONFIG_SPI_FLASH_BAR\n");
}
#endif
+ if (spi_enable_wp_pin(flash))
+ puts("Enable WP pin failed\n");
/* Release spi bus */
spi_release_bus(spi);