summaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorFelipe Balbi <balbi@ti.com>2010-12-02 12:53:22 +0200
committerFelipe Balbi <balbi@ti.com>2010-12-10 10:21:30 +0200
commit6f783e287c074afe1e9cf3f32ded9948e184b45e (patch)
tree01b0ba48afb04591e1131ad630866914c57d5b7e /drivers/usb
parentc20aebb92796cf54ae8171ad7f53a8fa7c61d2d8 (diff)
downloadop-kernel-dev-6f783e287c074afe1e9cf3f32ded9948e184b45e.zip
op-kernel-dev-6f783e287c074afe1e9cf3f32ded9948e184b45e.tar.gz
usb: musb: am35x: usb dev_pm_ops structure
instead of using musb_platform_suspend_resume, we can use dev_pm_ops and let platform_device core handle when to call musb_core's suspend and glue layer's suspend. Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/musb/am35x.c62
1 files changed, 45 insertions, 17 deletions
diff --git a/drivers/usb/musb/am35x.c b/drivers/usb/musb/am35x.c
index eacf1e0..fdc7c88 100644
--- a/drivers/usb/musb/am35x.c
+++ b/drivers/usb/musb/am35x.c
@@ -88,6 +88,7 @@ struct am35x_glue {
struct clk *phy_clk;
struct clk *clk;
};
+#define glue_to_musb(g) platform_get_drvdata(g->musb)
static inline void phy_on(void)
{
@@ -462,20 +463,6 @@ static int am35x_musb_exit(struct musb *musb)
return 0;
}
-static int am35x_musb_suspend(struct musb *musb)
-{
- phy_off();
-
- return 0;
-}
-
-static int am35x_musb_resume(struct musb *musb)
-{
- phy_on();
-
- return 0;
-}
-
/* AM35x supports only 32bit read operation */
void musb_read_fifo(struct musb_hw_ep *hw_ep, u16 len, u8 *dst)
{
@@ -516,9 +503,6 @@ static const struct musb_platform_ops am35x_ops = {
.set_mode = am35x_musb_set_mode,
.try_idle = am35x_musb_try_idle,
- .suspend = am35x_musb_suspend,
- .resume = am35x_musb_resume,
-
.set_vbus = am35x_musb_set_vbus,
};
@@ -644,10 +628,54 @@ static int __exit am35x_remove(struct platform_device *pdev)
return 0;
}
+#ifdef CONFIG_PM
+static int am35x_suspend(struct device *dev)
+{
+ struct am35x_glue *glue = dev_get_drvdata(dev);
+
+ phy_off();
+ clk_disable(glue->phy_clk);
+ clk_disable(glue->clk);
+
+ return 0;
+}
+
+static int am35x_resume(struct device *dev)
+{
+ struct am35x_glue *glue = dev_get_drvdata(dev);
+ int ret;
+
+ phy_on();
+ ret = clk_enable(glue->phy_clk);
+ if (ret) {
+ dev_err(dev, "failed to enable PHY clock\n");
+ return ret;
+ }
+
+ ret = clk_enable(glue->clk);
+ if (ret) {
+ dev_err(dev, "failed to enable clock\n");
+ return ret;
+ }
+
+ return 0;
+}
+
+static struct dev_pm_ops am35x_pm_ops = {
+ .suspend = am35x_suspend,
+ .resume = am35x_resume,
+};
+
+#define DEV_PM_OPS &am35x_pm_ops
+#else
+#define DEV_PM_OPS NULL
+#endif
+
static struct platform_driver am35x_driver = {
.remove = __exit_p(am35x_remove),
.driver = {
.name = "musb-am35x",
+ .pm = DEV_PM_OPS,
},
};
OpenPOWER on IntegriCloud