* [PATCH v2] memory: renesas-rpc-if: Add suspend/resume support
@ 2025-09-23 15:14 Biju
2025-10-10 2:48 ` Krzysztof Kozlowski
0 siblings, 1 reply; 3+ messages in thread
From: Biju @ 2025-09-23 15:14 UTC (permalink / raw)
To: Krzysztof Kozlowski
Cc: Biju Das, linux-kernel, Geert Uytterhoeven,
Prabhakar Mahadev Lad, Biju Das, linux-renesas-soc
From: Biju Das <biju.das.jz@bp.renesas.com>
On RZ/G3E using PSCI, s2ram powers down the SoC. Add suspend/resume
callbacks to control spi/spix2 clocks.
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
v1->v2:
* Updated error messages in rpcif_resume().
---
drivers/memory/renesas-rpc-if.c | 57 ++++++++++++++++++++++++++++-----
1 file changed, 49 insertions(+), 8 deletions(-)
diff --git a/drivers/memory/renesas-rpc-if.c b/drivers/memory/renesas-rpc-if.c
index 4a417b693080..2bcb05559ccb 100644
--- a/drivers/memory/renesas-rpc-if.c
+++ b/drivers/memory/renesas-rpc-if.c
@@ -67,6 +67,8 @@ struct rpcif_priv {
void __iomem *dirmap;
struct regmap *regmap;
struct reset_control *rstc;
+ struct clk *spi_clk;
+ struct clk *spix2_clk;
struct platform_device *vdev;
size_t size;
const struct rpcif_info *info;
@@ -1025,16 +1027,14 @@ static int rpcif_probe(struct platform_device *pdev)
* disable it in remove().
*/
if (rpc->info->type == XSPI_RZ_G3E) {
- struct clk *spi_clk;
-
- spi_clk = devm_clk_get_enabled(dev, "spix2");
- if (IS_ERR(spi_clk))
- return dev_err_probe(dev, PTR_ERR(spi_clk),
+ rpc->spix2_clk = devm_clk_get_enabled(dev, "spix2");
+ if (IS_ERR(rpc->spix2_clk))
+ return dev_err_probe(dev, PTR_ERR(rpc->spix2_clk),
"cannot get enabled spix2 clk\n");
- spi_clk = devm_clk_get_enabled(dev, "spi");
- if (IS_ERR(spi_clk))
- return dev_err_probe(dev, PTR_ERR(spi_clk),
+ rpc->spi_clk = devm_clk_get_enabled(dev, "spi");
+ if (IS_ERR(rpc->spi_clk))
+ return dev_err_probe(dev, PTR_ERR(rpc->spi_clk),
"cannot get enabled spi clk\n");
}
@@ -1063,6 +1063,44 @@ static void rpcif_remove(struct platform_device *pdev)
platform_device_unregister(rpc->vdev);
}
+static int rpcif_suspend(struct device *dev)
+{
+ struct rpcif_priv *rpc = dev_get_drvdata(dev);
+
+ if (rpc->info->type == XSPI_RZ_G3E) {
+ clk_disable_unprepare(rpc->spi_clk);
+ clk_disable_unprepare(rpc->spix2_clk);
+ }
+
+ return 0;
+}
+
+static int rpcif_resume(struct device *dev)
+{
+ struct rpcif_priv *rpc = dev_get_drvdata(dev);
+
+ if (rpc->info->type == XSPI_RZ_G3E) {
+ int ret;
+
+ ret = clk_prepare_enable(rpc->spix2_clk);
+ if (ret) {
+ dev_err(dev, "failed to enable spix2 clock: %pe\n",
+ ERR_PTR(ret));
+ return ret;
+ }
+
+ ret = clk_prepare_enable(rpc->spi_clk);
+ if (ret) {
+ clk_disable_unprepare(rpc->spix2_clk);
+ dev_err(dev, "failed to enable spi clock: %pe\n",
+ ERR_PTR(ret));
+ return ret;
+ }
+ }
+
+ return 0;
+}
+
static const struct rpcif_impl rpcif_impl = {
.hw_init = rpcif_hw_init_impl,
.prepare = rpcif_prepare_impl,
@@ -1125,12 +1163,15 @@ static const struct of_device_id rpcif_of_match[] = {
};
MODULE_DEVICE_TABLE(of, rpcif_of_match);
+static DEFINE_SIMPLE_DEV_PM_OPS(rpcif_pm_ops, rpcif_suspend, rpcif_resume);
+
static struct platform_driver rpcif_driver = {
.probe = rpcif_probe,
.remove = rpcif_remove,
.driver = {
.name = "rpc-if",
.of_match_table = rpcif_of_match,
+ .pm = pm_sleep_ptr(&rpcif_pm_ops),
},
};
module_platform_driver(rpcif_driver);
--
2.43.0
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v2] memory: renesas-rpc-if: Add suspend/resume support
2025-09-23 15:14 [PATCH v2] memory: renesas-rpc-if: Add suspend/resume support Biju
@ 2025-10-10 2:48 ` Krzysztof Kozlowski
2025-10-19 18:06 ` Biju Das
0 siblings, 1 reply; 3+ messages in thread
From: Krzysztof Kozlowski @ 2025-10-10 2:48 UTC (permalink / raw)
To: Biju
Cc: Biju Das, linux-kernel, Geert Uytterhoeven,
Prabhakar Mahadev Lad, linux-renesas-soc
On 23/09/2025 17:14, Biju wrote:
> if (rpc->info->type == XSPI_RZ_G3E) {
> - struct clk *spi_clk;
> -
> - spi_clk = devm_clk_get_enabled(dev, "spix2");
> - if (IS_ERR(spi_clk))
> - return dev_err_probe(dev, PTR_ERR(spi_clk),
> + rpc->spix2_clk = devm_clk_get_enabled(dev, "spix2");
> + if (IS_ERR(rpc->spix2_clk))
> + return dev_err_probe(dev, PTR_ERR(rpc->spix2_clk),
> "cannot get enabled spix2 clk\n");
>
> - spi_clk = devm_clk_get_enabled(dev, "spi");
> - if (IS_ERR(spi_clk))
> - return dev_err_probe(dev, PTR_ERR(spi_clk),
> + rpc->spi_clk = devm_clk_get_enabled(dev, "spi");
> + if (IS_ERR(rpc->spi_clk))
> + return dev_err_probe(dev, PTR_ERR(rpc->spi_clk),
> "cannot get enabled spi clk\n");
> }
>
> @@ -1063,6 +1063,44 @@ static void rpcif_remove(struct platform_device *pdev)
> platform_device_unregister(rpc->vdev);
> }
>
> +static int rpcif_suspend(struct device *dev)
> +{
> + struct rpcif_priv *rpc = dev_get_drvdata(dev);
> +
> + if (rpc->info->type == XSPI_RZ_G3E) {
clk are null in other case, so you can simplify it by dropping this if().
> + clk_disable_unprepare(rpc->spi_clk);
> + clk_disable_unprepare(rpc->spix2_clk);
> + }
> +
> + return 0;
> +}
> +
> +static int rpcif_resume(struct device *dev)
> +{
> + struct rpcif_priv *rpc = dev_get_drvdata(dev);
> +
> + if (rpc->info->type == XSPI_RZ_G3E) {
... which would save you one indentation here making it a bit more readable.
> + int ret;
> +
> + ret = clk_prepare_enable(rpc->spix2_clk);
> + if (ret) {
> + dev_err(dev, "failed to enable spix2 clock: %pe\n",
> + ERR_PTR(ret));
> + return ret;
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 3+ messages in thread* RE: [PATCH v2] memory: renesas-rpc-if: Add suspend/resume support
2025-10-10 2:48 ` Krzysztof Kozlowski
@ 2025-10-19 18:06 ` Biju Das
0 siblings, 0 replies; 3+ messages in thread
From: Biju Das @ 2025-10-19 18:06 UTC (permalink / raw)
To: Krzysztof Kozlowski, biju.das.au
Cc: linux-kernel, Geert Uytterhoeven, Prabhakar Mahadev Lad,
linux-renesas-soc
Hi Krzysztof Kozlowski,
Thanks for the feedback.
> -----Original Message-----
> From: Krzysztof Kozlowski <krzk@kernel.org>
> Sent: 10 October 2025 03:49
> Subject: Re: [PATCH v2] memory: renesas-rpc-if: Add suspend/resume support
>
> On 23/09/2025 17:14, Biju wrote:
> > if (rpc->info->type == XSPI_RZ_G3E) {
> > - struct clk *spi_clk;
> > -
> > - spi_clk = devm_clk_get_enabled(dev, "spix2");
> > - if (IS_ERR(spi_clk))
> > - return dev_err_probe(dev, PTR_ERR(spi_clk),
> > + rpc->spix2_clk = devm_clk_get_enabled(dev, "spix2");
> > + if (IS_ERR(rpc->spix2_clk))
> > + return dev_err_probe(dev, PTR_ERR(rpc->spix2_clk),
> > "cannot get enabled spix2 clk\n");
> >
> > - spi_clk = devm_clk_get_enabled(dev, "spi");
> > - if (IS_ERR(spi_clk))
> > - return dev_err_probe(dev, PTR_ERR(spi_clk),
> > + rpc->spi_clk = devm_clk_get_enabled(dev, "spi");
> > + if (IS_ERR(rpc->spi_clk))
> > + return dev_err_probe(dev, PTR_ERR(rpc->spi_clk),
> > "cannot get enabled spi clk\n");
> > }
> >
> > @@ -1063,6 +1063,44 @@ static void rpcif_remove(struct platform_device *pdev)
> > platform_device_unregister(rpc->vdev);
> > }
> >
> > +static int rpcif_suspend(struct device *dev) {
> > + struct rpcif_priv *rpc = dev_get_drvdata(dev);
> > +
> > + if (rpc->info->type == XSPI_RZ_G3E) {
>
> clk are null in other case, so you can simplify it by dropping this if().
OK, will make the clk optional and drop the if().
>
> > + clk_disable_unprepare(rpc->spi_clk);
> > + clk_disable_unprepare(rpc->spix2_clk);
> > + }
> > +
> > + return 0;
> > +}
> > +
> > +static int rpcif_resume(struct device *dev) {
> > + struct rpcif_priv *rpc = dev_get_drvdata(dev);
> > +
> > + if (rpc->info->type == XSPI_RZ_G3E) {
>
>
> ... which would save you one indentation here making it a bit more readable.
Agreed.
Cheers,
Biju
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-10-19 18:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-23 15:14 [PATCH v2] memory: renesas-rpc-if: Add suspend/resume support Biju
2025-10-10 2:48 ` Krzysztof Kozlowski
2025-10-19 18:06 ` Biju Das
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®