]> Pileus Git - ~andy/linux/commitdiff
usb: musb: fix setting JZ4740 gadget periphal mode on reset
authorApelete Seketeli <apelete@seketeli.net>
Thu, 19 Dec 2013 20:42:27 +0000 (21:42 +0100)
committerFelipe Balbi <balbi@ti.com>
Fri, 20 Dec 2013 15:53:59 +0000 (09:53 -0600)
JZ4740 USB Device Controller is not OTG compatible and does not have
DEVCTL register in silicon.

During ethernet-over-usb transactions, on reset, musb driver tries to
read from DEVCTL and consequently sets device as host (A-Device)
instead of peripheral (B-Device), which makes it a composite device to
the USB gadget driver.
This induces a kernel panic during power down where the USB gadget
driver does a null pointer dereference when trying to access the
composite device configuration.

On reset, do not rely on DEVCTL value for setting gadget peripheral
mode. Use is_otg flag instead to set it to B-Device.

Signed-off-by: Apelete Seketeli <apelete@seketeli.net>
Signed-off-by: Felipe Balbi <balbi@ti.com>
drivers/usb/musb/musb_gadget.c

index c410a7ff150bb8b3942d24129d03569fdda9e42b..d4aa779339f1c8ed9af9573d1eb92f80ee22f3c0 100644 (file)
@@ -2119,7 +2119,15 @@ __acquires(musb->lock)
        /* Normal reset, as B-Device;
         * or else after HNP, as A-Device
         */
-       if (devctl & MUSB_DEVCTL_BDEVICE) {
+       if (!musb->g.is_otg) {
+               /* USB device controllers that are not OTG compatible
+                * may not have DEVCTL register in silicon.
+                * In that case, do not rely on devctl for setting
+                * peripheral mode.
+                */
+               musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
+               musb->g.is_a_peripheral = 0;
+       } else if (devctl & MUSB_DEVCTL_BDEVICE) {
                musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
                musb->g.is_a_peripheral = 0;
        } else {