]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
mtd: spi-nor: add an API to restore the status of SPI flash chip
authorHou Zhiqiang <Zhiqiang.Hou@nxp.com>
Wed, 6 Dec 2017 02:53:41 +0000 (10:53 +0800)
committerCyrille Pitchen <cyrille.pitchen@wedev4u.fr>
Tue, 12 Dec 2017 23:36:00 +0000 (00:36 +0100)
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>
Documentation/mtd/spi-nor.txt
drivers/mtd/spi-nor/spi-nor.c
include/linux/mtd/spi-nor.h

index 548d6306ebcaebb2da08ab8eb52e8ccc975ac66d..da1fbff5a24c5b50d88f11e389dad08267f6b079 100644 (file)
@@ -60,3 +60,6 @@ The main API is spi_nor_scan(). Before you call the hook, a driver should
 initialize the necessary fields for spi_nor{}. Please see
 drivers/mtd/spi-nor/spi-nor.c for detail. Please also refer to fsl-quadspi.c
 when you want to write a new driver for a SPI NOR controller.
+Another API is spi_nor_restore(), this is used to restore the status of SPI
+flash chip such as addressing mode. Call it whenever detach the driver from
+device or reboot the system.
index 1e4b4dfe26b5f30a45c3a36b5f11b50fae73a549..9178139a39d021f44e7a84bd89d2d4e4fc9b37e3 100644 (file)
@@ -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)
 {
index c0836cca52807aa5ce7e2100e93bc7cdd99ece49..de36969eb3597b1b6290fecd6985f05dfa7cf4d8 100644 (file)
@@ -403,4 +403,10 @@ struct spi_nor_hwcaps {
 int spi_nor_scan(struct spi_nor *nor, const char *name,
                 const struct spi_nor_hwcaps *hwcaps);
 
+/**
+ * spi_nor_restore_addr_mode() - restore the status of SPI NOR
+ * @nor:       the spi_nor structure
+ */
+void spi_nor_restore(struct spi_nor *nor);
+
 #endif