usb: musb: omap2430: use the new generic PHY framework
authorKishon Vijay Abraham I <kishon@ti.com>
Fri, 27 Sep 2013 06:23:30 +0000 (11:53 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 28 Sep 2013 00:36:58 +0000 (17:36 -0700)
Use the generic PHY framework API to get the PHY. The usb_phy_set_resume
and usb_phy_set_suspend is replaced with power_on and
power_off to align with the new PHY framework.

musb->xceiv can't be removed as of now because musb core uses xceiv.state and
xceiv.otg. Once there is a separate state machine to handle otg, these can be
moved out of xceiv and then we can start using the generic PHY framework.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Reviewed-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Acked-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/musb/Kconfig
drivers/usb/musb/musb_core.h
drivers/usb/musb/omap2430.c

index c258a97ef1b0050f41e02d0a8e08b0052af488e7..0440e2807280934a21a0f7e91f9cbec1a62a9190 100644 (file)
@@ -75,6 +75,7 @@ config USB_MUSB_TUSB6010
 config USB_MUSB_OMAP2PLUS
        tristate "OMAP2430 and onwards"
        depends on ARCH_OMAP2PLUS
+       select GENERIC_PHY
 
 config USB_MUSB_AM35X
        tristate "AM35x"
index 65f3917b4fc5fb55c95bf4157d70a1d7194a110d..d408a9962f66b83d90bed18673206aee58c3bb7c 100644 (file)
@@ -46,6 +46,7 @@
 #include <linux/usb.h>
 #include <linux/usb/otg.h>
 #include <linux/usb/musb.h>
+#include <linux/phy/phy.h>
 
 struct musb;
 struct musb_hw_ep;
@@ -341,6 +342,7 @@ struct musb {
        u16                     int_tx;
 
        struct usb_phy          *xceiv;
+       struct phy              *phy;
 
        int nIrq;
        unsigned                irq_wake:1;
index 59d2245db1c81ce228d7607aa1176e56bbfb9082..d0fc4d9c7b80fa0646ba6179a4a12c0ece0afb93 100644 (file)
@@ -348,11 +348,21 @@ static int omap2430_musb_init(struct musb *musb)
         * up through ULPI.  TWL4030-family PMICs include one,
         * which needs a driver, drivers aren't always needed.
         */
-       if (dev->parent->of_node)
+       if (dev->parent->of_node) {
+               musb->phy = devm_phy_get(dev->parent, "usb2-phy");
+
+               /* We can't totally remove musb->xceiv as of now because
+                * musb core uses xceiv.state and xceiv.otg. Once we have
+                * a separate state machine to handle otg, these can be moved
+                * out of xceiv and then we can start using the generic PHY
+                * framework
+                */
                musb->xceiv = devm_usb_get_phy_by_phandle(dev->parent,
                    "usb-phy", 0);
-       else
+       } else {
                musb->xceiv = devm_usb_get_phy_dev(dev, 0);
+               musb->phy = devm_phy_get(dev, "usb");
+       }
 
        if (IS_ERR(musb->xceiv)) {
                status = PTR_ERR(musb->xceiv);
@@ -364,6 +374,10 @@ static int omap2430_musb_init(struct musb *musb)
                return -EPROBE_DEFER;
        }
 
+       if (IS_ERR(musb->phy)) {
+               pr_err("HS USB OTG: no PHY configured\n");
+               return PTR_ERR(musb->phy);
+       }
        musb->isr = omap2430_musb_interrupt;
 
        status = pm_runtime_get_sync(dev);
@@ -397,7 +411,7 @@ static int omap2430_musb_init(struct musb *musb)
        if (glue->status != OMAP_MUSB_UNKNOWN)
                omap_musb_set_mailbox(glue);
 
-       usb_phy_init(musb->xceiv);
+       phy_init(musb->phy);
 
        pm_runtime_put_noidle(musb->controller);
        return 0;
@@ -460,6 +474,7 @@ static int omap2430_musb_exit(struct musb *musb)
        del_timer_sync(&musb_idle_timer);
 
        omap2430_low_level_exit(musb);
+       phy_exit(musb->phy);
 
        return 0;
 }
@@ -638,7 +653,7 @@ static int omap2430_runtime_suspend(struct device *dev)
                                OTG_INTERFSEL);
 
                omap2430_low_level_exit(musb);
-               usb_phy_set_suspend(musb->xceiv, 1);
+               phy_power_off(musb->phy);
        }
 
        return 0;
@@ -653,8 +668,7 @@ static int omap2430_runtime_resume(struct device *dev)
                omap2430_low_level_init(musb);
                musb_writel(musb->mregs, OTG_INTERFSEL,
                                musb->context.otg_interfsel);
-
-               usb_phy_set_suspend(musb->xceiv, 0);
+               phy_power_on(musb->phy);
        }
 
        return 0;