From: Ranjit Waghmode Date: Tue, 24 Nov 2015 05:46:28 +0000 (+0530) Subject: mtd: spi-nor: reset QSPI page on to 0 on reboot/shutdown X-Git-Tag: xilinx-v2015.4.01~39 X-Git-Url: https://rtime.felk.cvut.cz/gitweb/zynq/linux.git/commitdiff_plain/aab0b63545a1db7ece331cb4974ef7ef9dfe7252 mtd: spi-nor: reset QSPI page on to 0 on reboot/shutdown This patch adds functionality to reset the QSPI page on 0 on reboot or shutdown. Signed-off-by: Ranjit Waghmode Reviewed-by: Harini Katakam Signed-off-by: Michal Simek --- diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c index 7b7dea261106..ebc8d78f25cd 100644 --- a/drivers/mtd/devices/m25p80.c +++ b/drivers/mtd/devices/m25p80.c @@ -248,6 +248,13 @@ static int m25p_remove(struct spi_device *spi) return mtd_device_unregister(&flash->mtd); } +static void m25p_shutdown(struct spi_device *spi) +{ + struct m25p *flash = spi_get_drvdata(spi); + + spi_nor_shutdown(&flash->spi_nor); +} + /* * XXX This needs to be kept in sync with spi_nor_ids. We can't share * it with spi-nor, because if this is built as a module then modpost @@ -307,6 +314,7 @@ static struct spi_driver m25p80_driver = { .id_table = m25p_ids, .probe = m25p_probe, .remove = m25p_remove, + .shutdown = m25p_shutdown, /* REVISIT: many of these chips have deep power-down modes, which * should clearly be entered on suspend() to minimize power use. diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c index dd895452c403..1211fdd14d21 100644 --- a/drivers/mtd/spi-nor/spi-nor.c +++ b/drivers/mtd/spi-nor/spi-nor.c @@ -1796,6 +1796,14 @@ static const struct spi_device_id *spi_nor_match_id(const char *name) return NULL; } +void spi_nor_shutdown(struct spi_nor *nor) +{ + if (nor->addr_width == 3 && + (nor->mtd->size >> nor->shift) > 0x1000000) + write_ear(nor, 0); +} +EXPORT_SYMBOL_GPL(spi_nor_shutdown); + MODULE_LICENSE("GPL"); MODULE_AUTHOR("Huang Shijie "); MODULE_AUTHOR("Mike Lavender"); diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h index d752c5cb4215..a1001177cbff 100644 --- a/include/linux/mtd/spi-nor.h +++ b/include/linux/mtd/spi-nor.h @@ -236,4 +236,13 @@ struct spi_nor { */ int spi_nor_scan(struct spi_nor *nor, const char *name, enum read_mode mode); +/** + * spi_nor_shutdown() - prepare for reboot + * @nor: the spi_nor structure + * + * The drivers can use this fuction to get the address back to + * 0 as will be required for a ROM boot. + */ +void spi_nor_shutdown(struct spi_nor *nor); + #endif