From: Piyush Mehta <piyush.mehta@amd.com>
To: <anurag.kumar.vulisha@xilinx.com>,
<laurent.pinchart@ideasonboard.com>, <vkoul@kernel.org>,
<kishon@kernel.org>, <michal.simek@amd.com>
Cc: <linux-kernel@vger.kernel.org>, <linux-phy@lists.infradead.org>,
<linux-arm-kernel@lists.infradead.org>, <git@amd.com>,
Piyush Mehta <piyush.mehta@amd.com>
Subject: [PATCH V2 1/2] phy: xilinx: add runtime PM support
Date: Tue, 13 Jun 2023 19:32:49 +0530 [thread overview]
Message-ID: <20230613140250.3018947-2-piyush.mehta@amd.com> (raw)
In-Reply-To: <20230613140250.3018947-1-piyush.mehta@amd.com>
Added Runtime power management support to the xilinx phy driver and using
DEFINE_RUNTIME_DEV_PM_OPS new macros allows the compiler to remove the
unused dev_pm_ops structure and related functions if !CONFIG_PM without
the need to mark the functions __maybe_unused.
Signed-off-by: Piyush Mehta <piyush.mehta@amd.com>
---
drivers/phy/xilinx/phy-zynqmp.c | 35 ++++++++++++++++++++++++++-------
1 file changed, 28 insertions(+), 7 deletions(-)
diff --git a/drivers/phy/xilinx/phy-zynqmp.c b/drivers/phy/xilinx/phy-zynqmp.c
index 8833680923a1..aada18123c19 100644
--- a/drivers/phy/xilinx/phy-zynqmp.c
+++ b/drivers/phy/xilinx/phy-zynqmp.c
@@ -20,6 +20,7 @@
#include <linux/of.h>
#include <linux/phy/phy.h>
#include <linux/platform_device.h>
+#include <linux/pm_runtime.h>
#include <linux/slab.h>
#include <dt-bindings/phy/phy.h>
@@ -820,7 +821,7 @@ static struct phy *xpsgtr_xlate(struct device *dev,
* Power Management
*/
-static int __maybe_unused xpsgtr_suspend(struct device *dev)
+static int xpsgtr_runtime_suspend(struct device *dev)
{
struct xpsgtr_dev *gtr_dev = dev_get_drvdata(dev);
unsigned int i;
@@ -835,7 +836,7 @@ static int __maybe_unused xpsgtr_suspend(struct device *dev)
return 0;
}
-static int __maybe_unused xpsgtr_resume(struct device *dev)
+static int xpsgtr_runtime_resume(struct device *dev)
{
struct xpsgtr_dev *gtr_dev = dev_get_drvdata(dev);
unsigned int icm_cfg0, icm_cfg1;
@@ -876,10 +877,8 @@ static int __maybe_unused xpsgtr_resume(struct device *dev)
return err;
}
-static const struct dev_pm_ops xpsgtr_pm_ops = {
- SET_SYSTEM_SLEEP_PM_OPS(xpsgtr_suspend, xpsgtr_resume)
-};
-
+static DEFINE_RUNTIME_DEV_PM_OPS(xpsgtr_pm_ops, xpsgtr_runtime_suspend,
+ xpsgtr_runtime_resume, NULL);
/*
* Probe & Platform Driver
*/
@@ -1005,6 +1004,16 @@ static int xpsgtr_probe(struct platform_device *pdev)
ret = PTR_ERR(provider);
goto err_clk_put;
}
+
+ pm_runtime_set_active(gtr_dev->dev);
+ pm_runtime_enable(gtr_dev->dev);
+
+ ret = pm_runtime_resume_and_get(gtr_dev->dev);
+ if (ret < 0) {
+ pm_runtime_disable(gtr_dev->dev);
+ goto err_clk_put;
+ }
+
return 0;
err_clk_put:
@@ -1014,6 +1023,17 @@ static int xpsgtr_probe(struct platform_device *pdev)
return ret;
}
+static int xpsgtr_remove(struct platform_device *pdev)
+{
+ struct xpsgtr_dev *gtr_dev = platform_get_drvdata(pdev);
+
+ pm_runtime_disable(gtr_dev->dev);
+ pm_runtime_put_noidle(gtr_dev->dev);
+ pm_runtime_set_suspended(gtr_dev->dev);
+
+ return 0;
+}
+
static const struct of_device_id xpsgtr_of_match[] = {
{ .compatible = "xlnx,zynqmp-psgtr", },
{ .compatible = "xlnx,zynqmp-psgtr-v1.1", },
@@ -1023,10 +1043,11 @@ MODULE_DEVICE_TABLE(of, xpsgtr_of_match);
static struct platform_driver xpsgtr_driver = {
.probe = xpsgtr_probe,
+ .remove = xpsgtr_remove,
.driver = {
.name = "xilinx-psgtr",
.of_match_table = xpsgtr_of_match,
- .pm = &xpsgtr_pm_ops,
+ .pm = pm_ptr(&xpsgtr_pm_ops),
},
};
--
2.25.1
next prev parent reply other threads:[~2023-06-13 14:06 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-13 14:02 [PATCH V2 0/2] phy: xilinx: phy-zynqmp: dynamic clock support Piyush Mehta
2023-06-13 14:02 ` Piyush Mehta [this message]
2023-06-13 14:02 ` [PATCH V2 2/2] phy: xilinx: phy-zynqmp: dynamic clock support for power-save Piyush Mehta
2023-07-11 7:44 ` [PATCH V2 0/2] phy: xilinx: phy-zynqmp: dynamic clock support Vinod Koul
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=20230613140250.3018947-2-piyush.mehta@amd.com \
--to=piyush.mehta@amd.com \
--cc=anurag.kumar.vulisha@xilinx.com \
--cc=git@amd.com \
--cc=kishon@kernel.org \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-phy@lists.infradead.org \
--cc=michal.simek@amd.com \
--cc=vkoul@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
all inboxes | Powered by JetHome®