1
0
Fork 0

MLK-24475-2 usb: phy: mxs: add runtime PM support

Adding runtime PM control at .set_suspend API, then the controller
driver could align PHY's power status with its runtime PM status.
Power domain needs driver's runtime callback to call its runtime
callback and turn on/off power domain according. So, the runtime
pm callback is a must for power domain supported devices.

With this support added, the subsystem (USB PHY in it) with power
domain supported could enter low power mode, and save the power
accordingly.

Cc: Ranjani Vaidyanathan <ranjani.vaidyanathan@nxp.com>
Signed-off-by: Peter Chen <peter.chen@nxp.com>
5.4-rM2-2.2.x-imx-squashed
Peter Chen 2020-08-10 17:10:52 +08:00
parent c0fb4ffb96
commit 1d9f743ecc
No known key found for this signature in database
GPG Key ID: 4859298150D671BB
1 changed files with 32 additions and 3 deletions

View File

@ -20,6 +20,7 @@
#include <linux/mfd/syscon.h>
#include <linux/iopoll.h>
#include <linux/regulator/consumer.h>
#include <linux/pm_runtime.h>
#define DRIVER_NAME "mxs_phy"
@ -606,7 +607,9 @@ static int mxs_phy_suspend(struct usb_phy *x, int suspend)
if (!(mxs_phy->port_id == 1 &&
mxs_phy->hardware_control_phy2_clk))
clk_disable_unprepare(mxs_phy->clk);
pm_runtime_put(x->dev);
} else {
pm_runtime_get_sync(x->dev);
mxs_phy_clock_switch_delay();
if (!(mxs_phy->port_id == 1 &&
mxs_phy->hardware_control_phy2_clk)) {
@ -1124,6 +1127,10 @@ static int mxs_phy_probe(struct platform_device *pdev)
device_set_wakeup_capable(&pdev->dev, true);
pm_runtime_set_active(&pdev->dev);
pm_runtime_enable(&pdev->dev);
pm_runtime_get_noresume(&pdev->dev);
return usb_add_phy_dev(&mxs_phy->phy);
}
@ -1132,10 +1139,15 @@ static int mxs_phy_remove(struct platform_device *pdev)
struct mxs_phy *mxs_phy = platform_get_drvdata(pdev);
usb_remove_phy(&mxs_phy->phy);
pm_runtime_get_sync(&pdev->dev);
pm_runtime_disable(&pdev->dev);
pm_runtime_put_noidle(&pdev->dev);
return 0;
}
#ifdef CONFIG_PM
#ifdef CONFIG_PM_SLEEP
static void mxs_phy_wakeup_enable(struct mxs_phy *mxs_phy, bool on)
{
@ -1202,12 +1214,29 @@ static int mxs_phy_system_resume(struct device *dev)
mxs_phy_wakeup_enable(mxs_phy, false);
}
pm_runtime_disable(dev);
pm_runtime_set_active(dev);
pm_runtime_enable(dev);
return 0;
}
#endif /* CONFIG_PM_SLEEP */
static SIMPLE_DEV_PM_OPS(mxs_phy_pm, mxs_phy_system_suspend,
mxs_phy_system_resume);
static int mxs_phy_runtime_resume(struct device *dev)
{
return 0;
}
static int mxs_phy_runtime_suspend(struct device *dev)
{
return 0;
}
#endif /* CONFIG_PM */
static const struct dev_pm_ops mxs_phy_pm_ops = {
SET_SYSTEM_SLEEP_PM_OPS(mxs_phy_system_suspend, mxs_phy_system_resume)
SET_RUNTIME_PM_OPS(mxs_phy_runtime_suspend, mxs_phy_runtime_resume, NULL)
};
static struct platform_driver mxs_phy_driver = {
.probe = mxs_phy_probe,
@ -1215,7 +1244,7 @@ static struct platform_driver mxs_phy_driver = {
.driver = {
.name = DRIVER_NAME,
.of_match_table = mxs_phy_dt_ids,
.pm = &mxs_phy_pm,
.pm = &mxs_phy_pm_ops,
},
};