Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Hou Zhiqiang and committed by
Cyrille Pitchen
8dee1d97 2666067f

+19
+3
Documentation/mtd/spi-nor.txt
··· 60 60 initialize the necessary fields for spi_nor{}. Please see 61 61 drivers/mtd/spi-nor/spi-nor.c for detail. Please also refer to fsl-quadspi.c 62 62 when you want to write a new driver for a SPI NOR controller. 63 + Another API is spi_nor_restore(), this is used to restore the status of SPI 64 + flash chip such as addressing mode. Call it whenever detach the driver from 65 + device or reboot the system.
+10
drivers/mtd/spi-nor/spi-nor.c
··· 2740 2740 dev_err(dev, "resume() failed\n"); 2741 2741 } 2742 2742 2743 + void 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 + } 2751 + EXPORT_SYMBOL_GPL(spi_nor_restore); 2752 + 2743 2753 int spi_nor_scan(struct spi_nor *nor, const char *name, 2744 2754 const struct spi_nor_hwcaps *hwcaps) 2745 2755 {
+6
include/linux/mtd/spi-nor.h
··· 403 403 int spi_nor_scan(struct spi_nor *nor, const char *name, 404 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 + */ 410 + void spi_nor_restore(struct spi_nor *nor); 411 + 406 412 #endif