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>
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 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 @@
 	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 @@
 	.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 @@
 	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,
 	},
 };