diff mbox series

[v4,08/18] phy: ti: phy-j721e-wiz: add resume support

Message ID 20240102-j7200-pcie-s2r-v4-8-6f1f53390c85@bootlin.com (mailing list archive)
State New, archived
Headers show
Series Add suspend to ram support for PCIe on J7200 | expand

Commit Message

Thomas Richard March 4, 2024, 3:35 p.m. UTC
Add resume support.
It has been tested on J7200 SR1.0 and SR2.0.

Co-developed-by: Théo Lebrun <theo.lebrun@bootlin.com>
Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
Signed-off-by: Thomas Richard <thomas.richard@bootlin.com>
---
 drivers/phy/ti/phy-j721e-wiz.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

Comments

Vinod Koul April 5, 2024, 4:44 p.m. UTC | #1
On 04-03-24, 16:35, Thomas Richard wrote:
> Add resume support.
> It has been tested on J7200 SR1.0 and SR2.0.
> 
> Co-developed-by: Théo Lebrun <theo.lebrun@bootlin.com>
> Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
> Signed-off-by: Thomas Richard <thomas.richard@bootlin.com>
> ---
>  drivers/phy/ti/phy-j721e-wiz.c | 29 +++++++++++++++++++++++++++++
>  1 file changed, 29 insertions(+)
> 
> diff --git a/drivers/phy/ti/phy-j721e-wiz.c b/drivers/phy/ti/phy-j721e-wiz.c
> index 0e3cb1ed5a52..b2320f2efb72 100644
> --- a/drivers/phy/ti/phy-j721e-wiz.c
> +++ b/drivers/phy/ti/phy-j721e-wiz.c
> @@ -1660,12 +1660,41 @@ static void wiz_remove(struct platform_device *pdev)
>  	pm_runtime_disable(dev);
>  }
>  
> +static int wiz_resume_noirq(struct device *dev)

I think this should be annotated with __maybe_unused

> +{
> +	struct device_node *node = dev->of_node;
> +	struct wiz *wiz = dev_get_drvdata(dev);
> +	int ret;
> +
> +	/* Enable supplemental Control override if available */
> +	if (wiz->sup_legacy_clk_override)
> +		regmap_field_write(wiz->sup_legacy_clk_override, 1);
> +
> +	wiz_clock_init(wiz);
> +
> +	ret = wiz_init(wiz);
> +	if (ret) {
> +		dev_err(dev, "WIZ initialization failed\n");
> +		goto err_wiz_init;
> +	}
> +
> +	return 0;
> +
> +err_wiz_init:
> +	wiz_clock_cleanup(wiz, node);
> +
> +	return ret;
> +}
> +
> +static DEFINE_NOIRQ_DEV_PM_OPS(wiz_pm_ops, NULL, wiz_resume_noirq);
> +
>  static struct platform_driver wiz_driver = {
>  	.probe		= wiz_probe,
>  	.remove_new	= wiz_remove,
>  	.driver		= {
>  		.name	= "wiz",
>  		.of_match_table = wiz_id_table,
> +		.pm	= pm_sleep_ptr(&wiz_pm_ops),
>  	},
>  };
>  module_platform_driver(wiz_driver);
> 
> -- 
> 2.39.2
Andy Shevchenko April 5, 2024, 5:14 p.m. UTC | #2
On Fri, Apr 05, 2024 at 10:14:09PM +0530, Vinod Koul wrote:
> On 04-03-24, 16:35, Thomas Richard wrote:

...

> > +static int wiz_resume_noirq(struct device *dev)
> 
> I think this should be annotated with __maybe_unused

No...

> > +		.pm	= pm_sleep_ptr(&wiz_pm_ops),

...because of magic of PTR_IF() here.
diff mbox series

Patch

diff --git a/drivers/phy/ti/phy-j721e-wiz.c b/drivers/phy/ti/phy-j721e-wiz.c
index 0e3cb1ed5a52..b2320f2efb72 100644
--- a/drivers/phy/ti/phy-j721e-wiz.c
+++ b/drivers/phy/ti/phy-j721e-wiz.c
@@ -1660,12 +1660,41 @@  static void wiz_remove(struct platform_device *pdev)
 	pm_runtime_disable(dev);
 }
 
+static int wiz_resume_noirq(struct device *dev)
+{
+	struct device_node *node = dev->of_node;
+	struct wiz *wiz = dev_get_drvdata(dev);
+	int ret;
+
+	/* Enable supplemental Control override if available */
+	if (wiz->sup_legacy_clk_override)
+		regmap_field_write(wiz->sup_legacy_clk_override, 1);
+
+	wiz_clock_init(wiz);
+
+	ret = wiz_init(wiz);
+	if (ret) {
+		dev_err(dev, "WIZ initialization failed\n");
+		goto err_wiz_init;
+	}
+
+	return 0;
+
+err_wiz_init:
+	wiz_clock_cleanup(wiz, node);
+
+	return ret;
+}
+
+static DEFINE_NOIRQ_DEV_PM_OPS(wiz_pm_ops, NULL, wiz_resume_noirq);
+
 static struct platform_driver wiz_driver = {
 	.probe		= wiz_probe,
 	.remove_new	= wiz_remove,
 	.driver		= {
 		.name	= "wiz",
 		.of_match_table = wiz_id_table,
+		.pm	= pm_sleep_ptr(&wiz_pm_ops),
 	},
 };
 module_platform_driver(wiz_driver);