usb: musb: use musb->port_mode
authorDaniel Mack <zonque@gmail.com>
Wed, 10 Apr 2013 19:55:49 +0000 (21:55 +0200)
committerFelipe Balbi <balbi@ti.com>
Tue, 28 May 2013 16:22:25 +0000 (19:22 +0300)
Initialize the host and gadget subsystems of the musb driver only when
the appropriate mode is selected from platform data, or device-tree
information, respectively.

Signed-off-by: Daniel Mack <zonque@gmail.com>
Acked-by: Peter Korsgaard <jacmet@sunsite.dk>
Signed-off-by: Felipe Balbi <balbi@ti.com>
drivers/usb/musb/musb_core.c
drivers/usb/musb/musb_virthub.c

index a1aa75eb51e27f3c8149be899d36d41bf228b697..a04cf8b1678bb556b903c400f80ffae1da9301ab 100644 (file)
@@ -1904,11 +1904,23 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl)
                musb->xceiv->state = OTG_STATE_B_IDLE;
        }
 
-       status = musb_host_setup(musb, plat->power);
-       if (status < 0)
-               goto fail3;
-
-       status = musb_gadget_setup(musb);
+       switch (musb->port_mode) {
+       case MUSB_PORT_MODE_HOST:
+               status = musb_host_setup(musb, plat->power);
+               break;
+       case MUSB_PORT_MODE_GADGET:
+               status = musb_gadget_setup(musb);
+               break;
+       case MUSB_PORT_MODE_DUAL_ROLE:
+               status = musb_host_setup(musb, plat->power);
+               if (status < 0)
+                       goto fail3;
+               status = musb_gadget_setup(musb);
+               break;
+       default:
+               dev_err(dev, "unsupported port mode %d\n", musb->port_mode);
+               break;
+       }
 
        if (status < 0)
                goto fail3;
index 47ee430a13c929da5bc901bd07a4731367b210b5..104d22f7142d2e40d8410e165be19a88be176ae7 100644 (file)
@@ -79,7 +79,8 @@ static void musb_start(struct musb *musb)
         * (b) vbus present/connect IRQ, peripheral mode;
         * (c) peripheral initiates, using SRP
         */
-       if ((devctl & MUSB_DEVCTL_VBUS) == MUSB_DEVCTL_VBUS) {
+       if (musb->port_mode != MUSB_PORT_MODE_HOST &&
+           (devctl & MUSB_DEVCTL_VBUS) == MUSB_DEVCTL_VBUS) {
                musb->is_active = 1;
        } else {
                devctl |= MUSB_DEVCTL_SESSION;