[PATCH 087/144] usb: musb: am35x: usb dev_pm_ops structure

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Felipe Balbi <balbi@xxxxxx>

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@xxxxxx>
---
 drivers/usb/musb/am35x.c |   62 +++++++++++++++++++++++++++++++++------------
 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,
 	},
 };
 
-- 
1.7.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux