mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-14 15:54:15 +08:00
phy: xilinx: add runtime PM support
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> Link: https://lore.kernel.org/r/20230613140250.3018947-2-piyush.mehta@amd.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
This commit is contained in:
parent
bd36b1ba20
commit
b3db66f624
@ -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 @@ err_clk_put:
|
||||
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 @@ err_clk_put:
|
||||
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),
|
||||
},
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user