From: Jonathan Cameron <jic23@kernel.org>
To: "Lad, Prabhakar" <prabhakar.csengg@gmail.com>
Cc: Claudiu <claudiu.beznea@tuxon.dev>,
prabhakar.mahadev-lad.rj@bp.renesas.com, lars@metafoo.de,
robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org,
geert+renesas@glider.be, magnus.damm@gmail.com,
mturquette@baylibre.com, sboyd@kernel.org,
p.zabel@pengutronix.de, linux-iio@vger.kernel.org,
linux-renesas-soc@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org,
Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Subject: Re: [PATCH v2 11/15] iio: adc: rzg2l_adc: Add suspend/resume support
Date: Wed, 11 Dec 2024 19:19:59 +0000 [thread overview]
Message-ID: <20241211191959.3bd377d9@jic23-huawei> (raw)
In-Reply-To: <CA+V-a8vHovd7L2bcY61n_Ox_hKvTvhUZMZPKgHFtd5DHQeZNMw@mail.gmail.com>
On Sun, 8 Dec 2024 21:35:50 +0000
"Lad, Prabhakar" <prabhakar.csengg@gmail.com> wrote:
> On Fri, Dec 6, 2024 at 11:16 AM Claudiu <claudiu.beznea@tuxon.dev> wrote:
> >
> > From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
> >
> > The Renesas RZ/G3S SoC features a power-saving mode where power to most of
> > the SoC components is turned off, including the ADC IP.
> >
> > Suspend/resume support has been added to the rzg2l_adc driver to restore
> > functionality after resuming from this power-saving mode. During suspend,
> > the ADC resets are asserted, and the ADC is powered down. On resume, the
> > ADC resets are de-asserted, the hardware is re-initialized, and the ADC
> > power is restored using the runtime PM APIs.
> >
> > Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
> > ---
> >
> > Changes in v2:
> > - none
> >
> > drivers/iio/adc/rzg2l_adc.c | 70 +++++++++++++++++++++++++++++++++++++
> > 1 file changed, 70 insertions(+)
> >
> Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Thanks. I've updated tags.
Jonathan
>
> Cheers,
> Prabhakar
>
> > diff --git a/drivers/iio/adc/rzg2l_adc.c b/drivers/iio/adc/rzg2l_adc.c
> > index e8dbc5dfbea1..2a911269a358 100644
> > --- a/drivers/iio/adc/rzg2l_adc.c
> > +++ b/drivers/iio/adc/rzg2l_adc.c
> > @@ -88,6 +88,7 @@ struct rzg2l_adc {
> > struct completion completion;
> > struct mutex lock;
> > u16 last_val[RZG2L_ADC_MAX_CHANNELS];
> > + bool was_rpm_active;
> > };
> >
> > /**
> > @@ -527,8 +528,77 @@ static int rzg2l_adc_pm_runtime_resume(struct device *dev)
> > return 0;
> > }
> >
> > +static int rzg2l_adc_suspend(struct device *dev)
> > +{
> > + struct iio_dev *indio_dev = dev_get_drvdata(dev);
> > + struct rzg2l_adc *adc = iio_priv(indio_dev);
> > + struct reset_control_bulk_data resets[] = {
> > + { .rstc = adc->presetn },
> > + { .rstc = adc->adrstn },
> > + };
> > + int ret;
> > +
> > + if (pm_runtime_suspended(dev)) {
> > + adc->was_rpm_active = false;
> > + } else {
> > + ret = pm_runtime_force_suspend(dev);
> > + if (ret)
> > + return ret;
> > + adc->was_rpm_active = true;
> > + }
> > +
> > + ret = reset_control_bulk_assert(ARRAY_SIZE(resets), resets);
> > + if (ret)
> > + goto rpm_restore;
> > +
> > + return 0;
> > +
> > +rpm_restore:
> > + if (adc->was_rpm_active)
> > + pm_runtime_force_resume(dev);
> > +
> > + return ret;
> > +}
> > +
> > +static int rzg2l_adc_resume(struct device *dev)
> > +{
> > + struct iio_dev *indio_dev = dev_get_drvdata(dev);
> > + struct rzg2l_adc *adc = iio_priv(indio_dev);
> > + struct reset_control_bulk_data resets[] = {
> > + { .rstc = adc->adrstn },
> > + { .rstc = adc->presetn },
> > + };
> > + int ret;
> > +
> > + ret = reset_control_bulk_deassert(ARRAY_SIZE(resets), resets);
> > + if (ret)
> > + return ret;
> > +
> > + if (adc->was_rpm_active) {
> > + ret = pm_runtime_force_resume(dev);
> > + if (ret)
> > + goto resets_restore;
> > + }
> > +
> > + ret = rzg2l_adc_hw_init(dev, adc);
> > + if (ret)
> > + goto rpm_restore;
> > +
> > + return 0;
> > +
> > +rpm_restore:
> > + if (adc->was_rpm_active) {
> > + pm_runtime_mark_last_busy(dev);
> > + pm_runtime_put_autosuspend(dev);
> > + }
> > +resets_restore:
> > + reset_control_bulk_assert(ARRAY_SIZE(resets), resets);
> > + return ret;
> > +}
> > +
> > static const struct dev_pm_ops rzg2l_adc_pm_ops = {
> > RUNTIME_PM_OPS(rzg2l_adc_pm_runtime_suspend, rzg2l_adc_pm_runtime_resume, NULL)
> > + SYSTEM_SLEEP_PM_OPS(rzg2l_adc_suspend, rzg2l_adc_resume)
> > };
> >
> > static struct platform_driver rzg2l_adc_driver = {
> > --
> > 2.39.2
> >
> >
next prev parent reply other threads:[~2024-12-11 19:20 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-06 11:13 [PATCH v2 00/15] iio: adc: rzg2l_adc: Add support for RZ/G3S Claudiu
2024-12-06 11:13 ` [PATCH v2 01/15] clk: renesas: r9a08g045: Add clocks, resets and power domain support for the ADC IP Claudiu
2024-12-06 13:54 ` Geert Uytterhoeven
2024-12-08 19:42 ` Lad, Prabhakar
2024-12-06 11:13 ` [PATCH v2 02/15] iio: adc: rzg2l_adc: Convert dev_err() to dev_err_probe() Claudiu
2024-12-07 18:10 ` Jonathan Cameron
2024-12-08 19:43 ` Lad, Prabhakar
2024-12-06 11:13 ` [PATCH v2 03/15] iio: adc: rzg2l_adc: Use devres helpers to request pre-deasserted reset controls Claudiu
2024-12-07 18:23 ` Jonathan Cameron
2024-12-08 19:44 ` Lad, Prabhakar
2024-12-06 11:13 ` [PATCH v2 04/15] iio: adc: rzg2l_adc: Simplify the runtime PM code Claudiu
2024-12-08 20:23 ` Lad, Prabhakar
2024-12-06 11:13 ` [PATCH v2 05/15] iio: adc: rzg2l_adc: Switch to RUNTIME_PM_OPS() and pm_ptr() Claudiu
2024-12-08 20:32 ` Lad, Prabhakar
2024-12-06 11:13 ` [PATCH v2 06/15] iio: adc: rzg2l_adc: Use read_poll_timeout() Claudiu
2024-12-08 20:53 ` Lad, Prabhakar
2024-12-06 11:13 ` [PATCH v2 07/15] iio: adc: rzg2l_adc: Simplify the locking scheme in rzg2l_adc_read_raw() Claudiu
2024-12-08 20:58 ` Lad, Prabhakar
2024-12-06 11:13 ` [PATCH v2 08/15] iio: adc: rzg2l_adc: Enable runtime PM autosuspend support Claudiu
2024-12-08 21:00 ` Lad, Prabhakar
2024-12-06 11:13 ` [PATCH v2 09/15] iio: adc: rzg2l_adc: Prepare for the addition of RZ/G3S support Claudiu
2024-12-08 21:06 ` Lad, Prabhakar
2024-12-06 11:13 ` [PATCH v2 10/15] iio: adc: rzg2l_adc: Add support for channel 8 Claudiu
2024-12-08 21:19 ` Lad, Prabhakar
2024-12-06 11:13 ` [PATCH v2 11/15] iio: adc: rzg2l_adc: Add suspend/resume support Claudiu
2024-12-08 21:35 ` Lad, Prabhakar
2024-12-11 19:19 ` Jonathan Cameron [this message]
2024-12-06 11:13 ` [PATCH v2 12/15] dt-bindings: iio: adc: renesas,rzg2l-adc: Document RZ/G3S SoC Claudiu
2024-12-06 11:13 ` [PATCH v2 13/15] iio: adc: rzg2l_adc: Add support for Renesas RZ/G3S Claudiu
2024-12-07 18:34 ` Jonathan Cameron
2024-12-09 8:51 ` Claudiu Beznea
2024-12-06 11:13 ` [PATCH v2 14/15] arm64: dts: renesas: r9a08g045: Add ADC node Claudiu
2024-12-11 13:27 ` Geert Uytterhoeven
2024-12-11 13:53 ` Claudiu Beznea
2024-12-06 11:13 ` [PATCH v2 15/15] arm64: dts: renesas: rzg3s-smarc-som: Enable ADC Claudiu
2024-12-11 13:32 ` Geert Uytterhoeven
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=20241211191959.3bd377d9@jic23-huawei \
--to=jic23@kernel.org \
--cc=claudiu.beznea.uj@bp.renesas.com \
--cc=claudiu.beznea@tuxon.dev \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=geert+renesas@glider.be \
--cc=krzk+dt@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-clk@vger.kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=magnus.damm@gmail.com \
--cc=mturquette@baylibre.com \
--cc=p.zabel@pengutronix.de \
--cc=prabhakar.csengg@gmail.com \
--cc=prabhakar.mahadev-lad.rj@bp.renesas.com \
--cc=robh@kernel.org \
--cc=sboyd@kernel.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