summaryrefslogtreecommitdiff
path: root/drivers/mtd/spi/spi_flash.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2018-11-06 15:21:41 -0700
committerSimon Glass <sjg@chromium.org>2018-11-20 19:14:22 -0700
commita58986ca8b53d8c7a441397082f84edc7f47d19f (patch)
treec9ec3c59244371d8ad9992a2ba332a7b50d33950 /drivers/mtd/spi/spi_flash.c
parentf9d49f92f8cdf04a47704519a63368259595c3a0 (diff)
sf: Add a method to obtain the block-protect setting
It is useful to obtain the block-protect setting of the SPI flash, so we know whether it is fully open or (perhaps partially) write-protected. Add a method for this. Update the sandbox driver to process this operation and add a test. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/mtd/spi/spi_flash.c')
-rw-r--r--drivers/mtd/spi/spi_flash.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c
index a87bacd4ac7..0c2392f28a4 100644
--- a/drivers/mtd/spi/spi_flash.c
+++ b/drivers/mtd/spi/spi_flash.c
@@ -110,6 +110,18 @@ static int write_cr(struct spi_flash *flash, u8 wc)
}
#endif
+int spi_flash_cmd_get_sw_write_prot(struct spi_flash *flash)
+{
+ u8 status;
+ int ret;
+
+ ret = read_sr(flash, &status);
+ if (ret)
+ return ret;
+
+ return (status >> 2) & 7;
+}
+
#ifdef CONFIG_SPI_FLASH_BAR
/*
* This "clean_bar" is necessary in a situation when one was accessing