aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/spi-nor
diff options
context:
space:
mode:
authorHou Zhiqiang <Zhiqiang.Hou@nxp.com>2017-12-06 10:53:41 +0800
committerCyrille Pitchen <cyrille.pitchen@wedev4u.fr>2017-12-13 00:36:00 +0100
commit8dee1d971af9af2f7b5f54c2eac4ebd04c5c237c (patch)
tree72bdb63f2ed5a58b2e809f385c92b1b61edaefb1 /drivers/mtd/spi-nor
parentmtd: spi-nor: Check that BP bits are set properly (diff)
downloadlinux-dev-8dee1d971af9af2f7b5f54c2eac4ebd04c5c237c.tar.xz
linux-dev-8dee1d971af9af2f7b5f54c2eac4ebd04c5c237c.zip
mtd: spi-nor: add an API to restore the status of SPI flash chip
Add this API to restore the status of SPI flash chip to the default such as addressing mode, whenever detach the driver from device or reboot the system. Signed-off-by: Hou Zhiqiang <Zhiqiang.Hou@nxp.com> Signed-off-by: Cyrille Pitchen <cyrille.pitchen@wedev4u.fr>
Diffstat (limited to 'drivers/mtd/spi-nor')
-rw-r--r--drivers/mtd/spi-nor/spi-nor.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index 1e4b4dfe26b5..9178139a39d0 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -2740,6 +2740,16 @@ static void spi_nor_resume(struct mtd_info *mtd)
dev_err(dev, "resume() failed\n");
}
+void spi_nor_restore(struct spi_nor *nor)
+{
+ /* restore the addressing mode */
+ if ((nor->addr_width == 4) &&
+ (JEDEC_MFR(nor->info) != SNOR_MFR_SPANSION) &&
+ !(nor->info->flags & SPI_NOR_4B_OPCODES))
+ set_4byte(nor, nor->info, 0);
+}
+EXPORT_SYMBOL_GPL(spi_nor_restore);
+
int spi_nor_scan(struct spi_nor *nor, const char *name,
const struct spi_nor_hwcaps *hwcaps)
{