diff options
author | Hou Zhiqiang <B48286@freescale.com> | 2014-11-21 06:50:23 (GMT) |
---|---|---|
committer | Matthew Weigel <Matthew.Weigel@freescale.com> | 2014-12-11 18:41:17 (GMT) |
commit | 014b9cffa2115e57e664cd16319c43e4b3eaef5a (patch) | |
tree | 26b8b2139f73a57fddf853828ca12839c0b6ad31 | |
parent | 183ff8c7dbca11a7b4321fec5748b1168ad89bde (diff) | |
download | linux-fsl-qoriq-014b9cffa2115e57e664cd16319c43e4b3eaef5a.tar.xz |
mtd: m25p80: Add Power Management support
Add the rescanning and initialization of SPI flash, to make the SPI
flash in the correct state. Because if the Power Management system
truns off power supply for SPI flash when system suspending, the SPI
flash will return to the reset state after system resume.
Signed-off-by: Hou Zhiqiang <B48286@freescale.com>
Change-Id: Ifa38f33f894ab43ce99cb8848e40c2193c0c1aa6
Reviewed-on: http://git.am.freescale.net:8181/24154
Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com>
Reviewed-by: Mingkai Hu <Mingkai.Hu@freescale.com>
Reviewed-by: Yang Li <LeoLi@freescale.com>
Reviewed-by: Richard Schmitt <richard.schmitt@freescale.com>
-rw-r--r-- | drivers/mtd/devices/m25p80.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c index 92a14fb..1839730 100644 --- a/drivers/mtd/devices/m25p80.c +++ b/drivers/mtd/devices/m25p80.c @@ -248,11 +248,42 @@ static int m25p_remove(struct spi_device *spi) return mtd_device_unregister(&flash->mtd); } +#ifdef CONFIG_PM_SLEEP +static int m25p_suspend(struct device *dev) +{ + struct m25p *flash = dev_get_drvdata(dev); + struct spi_nor *nor = &flash->spi_nor; + + /* Wait till previous write/erase is done. */ + if (nor->wait_till_ready) + return nor->wait_till_ready(nor); + + return 0; +} + +static int m25p_resume(struct device *dev) +{ + struct m25p *flash = dev_get_drvdata(dev); + struct spi_device *spi = flash->spi; + struct spi_nor *nor = &flash->spi_nor; + enum read_mode mode = SPI_NOR_NORMAL; + + if (spi->mode & SPI_RX_QUAD) + mode = SPI_NOR_QUAD; + else if (spi->mode & SPI_RX_DUAL) + mode = SPI_NOR_DUAL; + + return spi_nor_scan(nor, spi_get_device_id(spi), mode); +} +#endif /* CONFIG_PM_SLEEP */ + +static SIMPLE_DEV_PM_OPS(m25p_pm_ops, m25p_suspend, m25p_resume); static struct spi_driver m25p80_driver = { .driver = { .name = "m25p80", .owner = THIS_MODULE, + .pm = &m25p_pm_ops, }, .id_table = spi_nor_ids, .probe = m25p_probe, |