summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/mtd/spi-nor.txt3
-rw-r--r--drivers/mtd/spi-nor/spi-nor.c10
-rw-r--r--include/linux/mtd/spi-nor.h6
3 files changed, 19 insertions, 0 deletions
diff --git a/Documentation/mtd/spi-nor.txt b/Documentation/mtd/spi-nor.txt
index 548d6306ebca..da1fbff5a24c 100644
--- a/Documentation/mtd/spi-nor.txt
+++ b/Documentation/mtd/spi-nor.txt
@@ -60,3 +60,6 @@ The main API is spi_nor_scan(). Before you call the hook, a driver should
60initialize the necessary fields for spi_nor{}. Please see 60initialize the necessary fields for spi_nor{}. Please see
61drivers/mtd/spi-nor/spi-nor.c for detail. Please also refer to fsl-quadspi.c 61drivers/mtd/spi-nor/spi-nor.c for detail. Please also refer to fsl-quadspi.c
62when you want to write a new driver for a SPI NOR controller. 62when you want to write a new driver for a SPI NOR controller.
63Another API is spi_nor_restore(), this is used to restore the status of SPI
64flash chip such as addressing mode. Call it whenever detach the driver from
65device or reboot the system.
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)
2740 dev_err(dev, "resume() failed\n"); 2740 dev_err(dev, "resume() failed\n");
2741} 2741}
2742 2742
2743void spi_nor_restore(struct spi_nor *nor)
2744{
2745 /* restore the addressing mode */
2746 if ((nor->addr_width == 4) &&
2747 (JEDEC_MFR(nor->info) != SNOR_MFR_SPANSION) &&
2748 !(nor->info->flags & SPI_NOR_4B_OPCODES))
2749 set_4byte(nor, nor->info, 0);
2750}
2751EXPORT_SYMBOL_GPL(spi_nor_restore);
2752
2743int spi_nor_scan(struct spi_nor *nor, const char *name, 2753int spi_nor_scan(struct spi_nor *nor, const char *name,
2744 const struct spi_nor_hwcaps *hwcaps) 2754 const struct spi_nor_hwcaps *hwcaps)
2745{ 2755{
diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h
index c0836cca5280..de36969eb359 100644
--- a/include/linux/mtd/spi-nor.h
+++ b/include/linux/mtd/spi-nor.h
@@ -403,4 +403,10 @@ struct spi_nor_hwcaps {
403int spi_nor_scan(struct spi_nor *nor, const char *name, 403int spi_nor_scan(struct spi_nor *nor, const char *name,
404 const struct spi_nor_hwcaps *hwcaps); 404 const struct spi_nor_hwcaps *hwcaps);
405 405
406/**
407 * spi_nor_restore_addr_mode() - restore the status of SPI NOR
408 * @nor: the spi_nor structure
409 */
410void spi_nor_restore(struct spi_nor *nor);
411
406#endif 412#endif