Fix musb suspend behavior
- Add pm_ops to the MTK MUSB platform glue. In these, we enable/disable
the USB clocks and PHY. This gives us a nice behavior where the USB
device disconnects cleanly from the host machine, and then re-connects
when it exits suspend (previous behavior disconnected, and then tried
really hard to reconnect, but there was no one home.)
Change-Id: If975fcd2a7e1332f120c3f8997e81e21fd43c5cb
diff --git a/drivers/usb/musb/mediatek.c b/drivers/usb/musb/mediatek.c
index 0582041..89bb185 100644
--- a/drivers/usb/musb/mediatek.c
+++ b/drivers/usb/musb/mediatek.c
@@ -428,6 +428,30 @@
.set_mode = mtk_musb_set_mode,
};
+static int mtk_musb_suspend(struct device *dev) {
+ int ret;
+ struct mtk_glue *glue = dev_get_drvdata(dev);
+
+ ret = phy_power_off(glue->phy);
+ if (ret)
+ return ret;
+ mtk_musb_clks_disable(glue);
+
+ return 0;
+}
+
+static int mtk_musb_resume(struct device *dev) {
+ int ret;
+ struct mtk_glue *glue = dev_get_drvdata(dev);
+
+ ret = mtk_musb_clks_enable(glue);
+ if (ret)
+ return ret;
+ return phy_power_on(glue->phy);
+}
+
+static SIMPLE_DEV_PM_OPS(mtk_musb_pm_ops, mtk_musb_suspend, mtk_musb_resume);
+
#define MTK_MUSB_MAX_EP_NUM 8
#define MTK_MUSB_RAM_BITS 11
@@ -599,6 +623,7 @@
.remove = mtk_musb_remove,
.driver = {
.name = "musb-mtk",
+ .pm = &mtk_musb_pm_ops,
.of_match_table = of_match_ptr(mtk_musb_match),
},
};