summaryrefslogtreecommitdiff
path: root/drivers/mtd
diff options
context:
space:
mode:
authorTom Rini <trini@ti.com>2014-08-29 11:06:51 -0400
committerTom Rini <trini@ti.com>2014-08-29 11:06:51 -0400
commit5a1095a830299aef8dd32495e505e92ab1749e89 (patch)
tree9383de2534455119d51200bc87766a330591df27 /drivers/mtd
parent6af857c50df4e62ec08e51ad73c96f63f1480386 (diff)
parentd145878d59c80a44d8c6e6d606b898ab87d205ee (diff)
downloadu-boot-imx-5a1095a830299aef8dd32495e505e92ab1749e89.zip
u-boot-imx-5a1095a830299aef8dd32495e505e92ab1749e89.tar.gz
u-boot-imx-5a1095a830299aef8dd32495e505e92ab1749e89.tar.bz2
Merge branch 'master' of git://www.denx.de/git/u-boot-imx
Diffstat (limited to 'drivers/mtd')
-rw-r--r--drivers/mtd/spi/sf_internal.h4
-rw-r--r--drivers/mtd/spi/sf_probe.c30
2 files changed, 34 insertions, 0 deletions
diff --git a/drivers/mtd/spi/sf_internal.h b/drivers/mtd/spi/sf_internal.h
index 6bcd522..19d4914 100644
--- a/drivers/mtd/spi/sf_internal.h
+++ b/drivers/mtd/spi/sf_internal.h
@@ -60,6 +60,10 @@
#define STATUS_QEB_MXIC (1 << 6)
#define STATUS_PEC (1 << 7)
+#ifdef CONFIG_SYS_SPI_ST_ENABLE_WP_PIN
+#define STATUS_SRWD (1 << 7) /* SR write protect */
+#endif
+
/* Flash timeout values */
#define SPI_FLASH_PROG_TIMEOUT (2 * CONFIG_SYS_HZ)
#define SPI_FLASH_PAGE_ERASE_TIMEOUT (5 * CONFIG_SYS_HZ)
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);