usb: musb: honour initial transceiver state
authorGrazvydas Ignotas <notasas@gmail.com>
Tue, 26 Feb 2013 00:52:24 +0000 (02:52 +0200)
committerGrazvydas Ignotas <notasas@gmail.com>
Tue, 12 Mar 2013 21:45:56 +0000 (23:45 +0200)
As the OTG transceiver driver usually starts first, it should already
have default_a variable set according to ID pin state, so don't
override it. In case default_a was not changed by trasceiver, it will
default to 0 and this code will work as before.

drivers/usb/musb/musb_core.c

index 35e30e1..ad67cf9 100644 (file)
@@ -2066,9 +2066,13 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl)
                                ? 'B' : 'A'));
 
        } else /* peripheral is enabled */ {
-               MUSB_DEV_MODE(musb);
-               musb->xceiv->default_a = 0;
-               musb->xceiv->state = OTG_STATE_B_IDLE;
+               if (musb->xceiv->default_a) {
+                       MUSB_HST_MODE(musb);
+                       musb->xceiv->state = OTG_STATE_A_IDLE;
+               } else {
+                       MUSB_DEV_MODE(musb);
+                       musb->xceiv->state = OTG_STATE_B_IDLE;
+               }
 
                status = musb_gadget_setup(musb);