* [PATCH 1/1] mtd: devices: m25p80: Add PM suspend resume support
@ 2016-09-09 19:13 Kamal Dasu
[not found] ` <1473448438-13245-1-git-send-email-kdasu.kdev-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: Kamal Dasu @ 2016-09-09 19:13 UTC (permalink / raw)
To: linux-spi-u79uwXL29TY76Z2rM5mHXA,
f.fainelli-Re5JQEeQqe8AvxtiuMwx3w,
linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
computersforpeace-Re5JQEeQqe8AvxtiuMwx3w
Cc: bcm-kernel-feedback-list-dY08KVG/lbpWk0Htik3J/w, Kamal Dasu
Adding PM support so as to be able to probe spi-nor flash
on resume. There are vendor specific commands to setup
the transfer mode and enable read/write as part of
spi_nor_scan(), done on intial probe and needed on resume().
The spi-nor stucture is private to the m25p driver and hence
is the only place this can be done without having to duplicate
code in controller driver.
Signed-off-by: Kamal Dasu <kdasu.kdev-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
drivers/mtd/devices/m25p80.c | 37 ++++++++++++++++++++++++++++++++++++-
1 file changed, 36 insertions(+), 1 deletion(-)
diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index 9cf7fcd..f8294b4 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -248,7 +248,6 @@ static int m25p_probe(struct spi_device *spi)
data ? data->nr_parts : 0);
}
-
static int m25p_remove(struct spi_device *spi)
{
struct m25p *flash = spi_get_drvdata(spi);
@@ -319,10 +318,46 @@ static const struct of_device_id m25p_of_table[] = {
};
MODULE_DEVICE_TABLE(of, m25p_of_table);
+#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 flash_platform_data *data;
+ char *flash_name = NULL;
+ enum read_mode mode = SPI_NOR_NORMAL;
+ int ret;
+
+ data = dev_get_platdata(&flash->spi->dev);
+
+ if (data && data->type)
+ flash_name = data->type;
+ else if (!strcmp(flash->spi->modalias, "spi-nor"))
+ flash_name = NULL; /* auto-detect */
+ else
+ flash_name = flash->spi->modalias;
+
+ if (flash->spi->mode & SPI_RX_QUAD)
+ mode = SPI_NOR_QUAD;
+ else if (flash->spi->mode & SPI_RX_DUAL)
+ mode = SPI_NOR_DUAL;
+
+ ret = spi_nor_scan(&flash->spi_nor, flash_name, mode);
+
+ return ret;
+}
+#endif
+static SIMPLE_DEV_PM_OPS(m25p_pm_ops, m25p_suspend, m25p_resume);
+
static struct spi_driver m25p80_driver = {
.driver = {
.name = "m25p80",
.of_match_table = m25p_of_table,
+ .pm = &m25p_pm_ops,
},
.id_table = m25p_ids,
.probe = m25p_probe,
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/1] mtd: devices: m25p80: Add PM suspend resume support
[not found] ` <1473448438-13245-1-git-send-email-kdasu.kdev-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2016-09-11 10:10 ` Geert Uytterhoeven
[not found] ` <CAMuHMdUb6nhzzkPy4z1tFouM+FAsNKhh=EXYFTSL00ziSUcKqw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: Geert Uytterhoeven @ 2016-09-11 10:10 UTC (permalink / raw)
To: Kamal Dasu
Cc: linux-spi, Florian Fainelli, MTD Maling List, Brian Norris,
bcm-kernel-feedback-list-dY08KVG/lbpWk0Htik3J/w
On Fri, Sep 9, 2016 at 9:13 PM, Kamal Dasu <kdasu.kdev-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> Adding PM support so as to be able to probe spi-nor flash
> on resume. There are vendor specific commands to setup
> the transfer mode and enable read/write as part of
> spi_nor_scan(), done on intial probe and needed on resume().
> The spi-nor stucture is private to the m25p driver and hence
> is the only place this can be done without having to duplicate
> code in controller driver.
>
> Signed-off-by: Kamal Dasu <kdasu.kdev-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> ---
> drivers/mtd/devices/m25p80.c | 37 ++++++++++++++++++++++++++++++++++++-
> 1 file changed, 36 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
> index 9cf7fcd..f8294b4 100644
> --- a/drivers/mtd/devices/m25p80.c
> +++ b/drivers/mtd/devices/m25p80.c
> +static int m25p_resume(struct device *dev)
> +{
> + struct m25p *flash = dev_get_drvdata(dev);
> + struct flash_platform_data *data;
> + char *flash_name = NULL;
> + enum read_mode mode = SPI_NOR_NORMAL;
> + int ret;
> +
> + data = dev_get_platdata(&flash->spi->dev);
> +
> + if (data && data->type)
> + flash_name = data->type;
> + else if (!strcmp(flash->spi->modalias, "spi-nor"))
> + flash_name = NULL; /* auto-detect */
> + else
> + flash_name = flash->spi->modalias;
> +
> + if (flash->spi->mode & SPI_RX_QUAD)
> + mode = SPI_NOR_QUAD;
> + else if (flash->spi->mode & SPI_RX_DUAL)
> + mode = SPI_NOR_DUAL;
> +
> + ret = spi_nor_scan(&flash->spi_nor, flash_name, mode);
All of the above is also done in m25p_probe(). Hence please factor out the
commonalities into its own function.
> +
> + return ret;
> +}
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/1] mtd: devices: m25p80: Add PM suspend resume support
[not found] ` <CAMuHMdUb6nhzzkPy4z1tFouM+FAsNKhh=EXYFTSL00ziSUcKqw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2016-09-12 20:06 ` Kamal Dasu
0 siblings, 0 replies; 3+ messages in thread
From: Kamal Dasu @ 2016-09-12 20:06 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: linux-spi, Florian Fainelli, MTD Maling List, Brian Norris,
Jayachandran C <jchandra-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>, bcm-kernel-feedback-list
Geert,
I agree that scan code can be refactored into a common function to be
called by probe and resume. Will send a v2 patch with the changes.
Thanks
Kamal
On Sun, Sep 11, 2016 at 6:10 AM, Geert Uytterhoeven
<geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org> wrote:
> On Fri, Sep 9, 2016 at 9:13 PM, Kamal Dasu <kdasu.kdev-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>> Adding PM support so as to be able to probe spi-nor flash
>> on resume. There are vendor specific commands to setup
>> the transfer mode and enable read/write as part of
>> spi_nor_scan(), done on intial probe and needed on resume().
>> The spi-nor stucture is private to the m25p driver and hence
>> is the only place this can be done without having to duplicate
>> code in controller driver.
>>
>> Signed-off-by: Kamal Dasu <kdasu.kdev-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>> ---
>> drivers/mtd/devices/m25p80.c | 37 ++++++++++++++++++++++++++++++++++++-
>> 1 file changed, 36 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
>> index 9cf7fcd..f8294b4 100644
>> --- a/drivers/mtd/devices/m25p80.c
>> +++ b/drivers/mtd/devices/m25p80.c
>
>> +static int m25p_resume(struct device *dev)
>> +{
>> + struct m25p *flash = dev_get_drvdata(dev);
>> + struct flash_platform_data *data;
>> + char *flash_name = NULL;
>> + enum read_mode mode = SPI_NOR_NORMAL;
>> + int ret;
>> +
>> + data = dev_get_platdata(&flash->spi->dev);
>> +
>> + if (data && data->type)
>> + flash_name = data->type;
>> + else if (!strcmp(flash->spi->modalias, "spi-nor"))
>> + flash_name = NULL; /* auto-detect */
>> + else
>> + flash_name = flash->spi->modalias;
>> +
>> + if (flash->spi->mode & SPI_RX_QUAD)
>> + mode = SPI_NOR_QUAD;
>> + else if (flash->spi->mode & SPI_RX_DUAL)
>> + mode = SPI_NOR_DUAL;
>> +
>> + ret = spi_nor_scan(&flash->spi_nor, flash_name, mode);
>
> All of the above is also done in m25p_probe(). Hence please factor out the
> commonalities into its own function.
>
>> +
>> + return ret;
>> +}
>
> Gr{oetje,eeting}s,
>
> Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org
>
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
> -- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-09-12 20:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-09 19:13 [PATCH 1/1] mtd: devices: m25p80: Add PM suspend resume support Kamal Dasu
[not found] ` <1473448438-13245-1-git-send-email-kdasu.kdev-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-09-11 10:10 ` Geert Uytterhoeven
[not found] ` <CAMuHMdUb6nhzzkPy4z1tFouM+FAsNKhh=EXYFTSL00ziSUcKqw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-09-12 20:06 ` Kamal Dasu
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).