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

mtd: spinand: add SPI-NAND MTD resume handler

After power up, all SPI NAND's blocks are locked. Only read operations
are allowed, write and erase operations are forbidden.
The SPI NAND framework unlocks all the blocks during its initialization.

During a standby low power, the memory is powered down, losing its
configuration.
During the resume, the QSPI driver state is restored but the SPI NAND
framework does not reconfigured the memory.

This patch adds SPI-NAND MTD PM handlers for resume ops.
SPI NAND resume op re-initializes SPI NAND flash to its probed state.

Signed-off-by: Christophe Kerello <christophe.kerello@foss.st.com>
Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210602094913.26472-4-patrice.chotard@foss.st.com

authored by

Patrice Chotard and committed by
Miquel Raynal
f145b9dc 41e005c2

+17
+17
drivers/mtd/nand/spi/core.c
··· 1129 1129 return ret; 1130 1130 } 1131 1131 1132 + static void spinand_mtd_resume(struct mtd_info *mtd) 1133 + { 1134 + struct spinand_device *spinand = mtd_to_spinand(mtd); 1135 + int ret; 1136 + 1137 + ret = spinand_reset_op(spinand); 1138 + if (ret) 1139 + return; 1140 + 1141 + ret = spinand_init_flash(spinand); 1142 + if (ret) 1143 + return; 1144 + 1145 + spinand_ecc_enable(spinand, false); 1146 + } 1147 + 1132 1148 static int spinand_init(struct spinand_device *spinand) 1133 1149 { 1134 1150 struct device *dev = &spinand->spimem->spi->dev; ··· 1215 1199 mtd->_block_isreserved = spinand_mtd_block_isreserved; 1216 1200 mtd->_erase = spinand_mtd_erase; 1217 1201 mtd->_max_bad_blocks = nanddev_mtd_max_bad_blocks; 1202 + mtd->_resume = spinand_mtd_resume; 1218 1203 1219 1204 if (nand->ecc.engine) { 1220 1205 ret = mtd_ooblayout_count_freebytes(mtd);