From: Brian Norris <computersforpeace@gmail.com>
To: Zhiqiang Hou <B48286@freescale.com>
Cc: linux-mtd@lists.infradead.org, dwmw2@infradead.org, b21284@freescale.com
Subject: Re: [PATCH] mtd: m25p80: Add Power Management support
Date: Fri, 7 Aug 2015 15:59:11 -0700 [thread overview]
Message-ID: <20150807225911.GD60523@google.com> (raw)
In-Reply-To: <1437473933-11983-1-git-send-email-B48286@freescale.com>
On Tue, Jul 21, 2015 at 06:18:53PM +0800, Zhiqiang Hou wrote:
> From: Hou Zhiqiang <B48286@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@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);
No, this is not good. You need to be much more targeted than just
rerunning practically the entire driver init. Please introduce a
spi_nor_suspend() and spi_nor_resume() function, and have them do only
the steps that are necessary. e.g., re-set any flash modes, like 4-byte
addressing, etc. Then you can call them from the appropriate drivers,
like m25p80.c.
> +}
> +#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,
Brian
next prev parent reply other threads:[~2015-08-07 22:59 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-21 10:18 [PATCH] mtd: m25p80: Add Power Management support Zhiqiang Hou
2015-07-31 10:44 ` Hou Zhiqiang
2015-08-07 4:18 ` Hou Zhiqiang
2015-08-07 22:56 ` Brian Norris
2015-08-07 22:59 ` Brian Norris [this message]
-- strict thread matches above, loose matches on Subject: below --
2013-12-11 8:19 Hou Zhiqiang
2014-01-03 19:00 ` Brian Norris
2014-01-06 7:32 ` B48286
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150807225911.GD60523@google.com \
--to=computersforpeace@gmail.com \
--cc=B48286@freescale.com \
--cc=b21284@freescale.com \
--cc=dwmw2@infradead.org \
--cc=linux-mtd@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).