[PATCH] mtd: m25p80: Add Power Management support
Hou Zhiqiang
B48286 at freescale.com
Fri Jul 31 03:44:35 PDT 2015
Hi Brian,
Do you have any comment?
> -----Original Message-----
> From: Zhiqiang Hou [mailto:B48286 at freescale.com]
> Sent: 2015年7月21日 18:19
> To: linux-mtd at lists.infradead.org; computersforpeace at gmail.com;
> dwmw2 at infradead.org
> Cc: Hu Mingkai-B21284; Hou Zhiqiang-B48286
> Subject: [PATCH] mtd: m25p80: Add Power Management support
>
> From: Hou Zhiqiang <B48286 at freescale.com>
>
> 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 at freescale.com>
> ---
> drivers/mtd/devices/m25p80.c | 34 ++++++++++++++++++++++++++++++++++
> 1 file changed, 34 insertions(+)
>
> diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
> index d313f948b..f9d2b2e 100644
> --- a/drivers/mtd/devices/m25p80.c
> +++ b/drivers/mtd/devices/m25p80.c
> @@ -248,6 +248,39 @@ 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) {
> + 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;
> + struct flash_platform_data *data;
> + char *flash_name = NULL;
> +
> + if (spi->mode & SPI_RX_QUAD)
> + mode = SPI_NOR_QUAD;
> + else if (spi->mode & SPI_RX_DUAL)
> + mode = SPI_NOR_DUAL;
> +
> + data = dev_get_platdata(&spi->dev);
> + if (data && data->type)
> + flash_name = data->type;
> + else if (!strcmp(spi->modalias, "spi-nor"))
> + flash_name = NULL; /* auto-detect */
> + else
> + flash_name = spi->modalias;
> +
> + return spi_nor_scan(nor, flash_name, mode); } #endif /*
> +CONFIG_PM_SLEEP */
> +
> +static SIMPLE_DEV_PM_OPS(m25p_pm_ops, m25p_suspend, m25p_resume);
> /*
> * Do NOT add to this array without reading the following:
> *
> @@ -302,6 +335,7 @@ static struct spi_driver m25p80_driver = {
> .driver = {
> .name = "m25p80",
> .owner = THIS_MODULE,
> + .pm = &m25p_pm_ops,
> },
> .id_table = m25p_ids,
> .probe = m25p_probe,
> --
> 2.1.0.27.g96db324
Thanks,
Zhiqiang
More information about the linux-mtd
mailing list