diff options
author | Sebastian Andrzej Siewior <bigeasy@linutronix.de> | 2013-08-19 14:39:44 +0400 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2013-10-01 18:31:11 +0400 |
commit | a12226394e7d19734d129766676a5668efd50d5c (patch) | |
tree | 29e62ed87e7641b9f2d210c661fd7b622fae171a /drivers/usb/phy/phy-am335x.c | |
parent | 4d175f340c9c055482688d2205038413dc7b6f1e (diff) | |
download | linux-a12226394e7d19734d129766676a5668efd50d5c.tar.xz |
usb: phy: am335x: add wakeup support
This is based on George Cherian's patch which added power & wakeup
support to am335x and does no longer apply since I took some if the code
apart in favor of the multi instance support.
This compiles and I boots and later it detects a device after I plug it in :)
Could somebody please test it so it does what it should?
Cc: George Cherian <george.cherian@ti.com>
Reviewed-by: Roger Quadros <rogerq@ti.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/phy/phy-am335x.c')
-rw-r--r-- | drivers/usb/phy/phy-am335x.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/drivers/usb/phy/phy-am335x.c b/drivers/usb/phy/phy-am335x.c index f836dc68104c..f3478a856edb 100644 --- a/drivers/usb/phy/phy-am335x.c +++ b/drivers/usb/phy/phy-am335x.c @@ -78,6 +78,40 @@ static int am335x_phy_remove(struct platform_device *pdev) return 0; } +#ifdef CONFIG_PM_RUNTIME + +static int am335x_phy_runtime_suspend(struct device *dev) +{ + struct platform_device *pdev = to_platform_device(dev); + struct am335x_phy *am_phy = platform_get_drvdata(pdev); + + if (device_may_wakeup(dev)) + phy_ctrl_wkup(am_phy->phy_ctrl, am_phy->id, true); + phy_ctrl_power(am_phy->phy_ctrl, am_phy->id, false); + return 0; +} + +static int am335x_phy_runtime_resume(struct device *dev) +{ + struct platform_device *pdev = to_platform_device(dev); + struct am335x_phy *am_phy = platform_get_drvdata(pdev); + + phy_ctrl_power(am_phy->phy_ctrl, am_phy->id, true); + if (device_may_wakeup(dev)) + phy_ctrl_wkup(am_phy->phy_ctrl, am_phy->id, false); + return 0; +} + +static const struct dev_pm_ops am335x_pm_ops = { + SET_RUNTIME_PM_OPS(am335x_phy_runtime_suspend, + am335x_phy_runtime_resume, NULL) +}; + +#define DEV_PM_OPS (&am335x_pm_ops) +#else +#define DEV_PM_OPS NULL +#endif + static const struct of_device_id am335x_phy_ids[] = { { .compatible = "ti,am335x-usb-phy" }, { } @@ -90,6 +124,7 @@ static struct platform_driver am335x_phy_driver = { .driver = { .name = "am335x-phy-driver", .owner = THIS_MODULE, + .pm = DEV_PM_OPS, .of_match_table = of_match_ptr(am335x_phy_ids), }, }; |