Date:2013-12-12 01:06:13 (10 years 3 months ago)
Author:Apelete Seketeli
Commit:263ef8398eb7c01dbbb522cf0e5a1231b7c3feb7
Message:usb: musb: fix setting JZ4740 gadget periphal mode on reset

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: hardcode it instead to B-Device.

Signed-off-by: Apelete Seketeli <apelete@seketeli.net>
Files: drivers/usb/musb/musb_gadget.c (2 diffs)

Change Details

drivers/usb/musb/musb_gadget.c
21192119    /* Normal reset, as B-Device;
21202120     * or else after HNP, as A-Device
21212121     */
2122#if defined(CONFIG_USB_MUSB_JZ4740) || defined(CONFIG_USB_MUSB_JZ4740_MODULE)
2123    /* JZ4740 UDC Controller is not OTG compatible and does not
2124     * have DEVCTL register in silicon: do not rely on devctl for
2125     * setting peripheral mode.
2126     */
2127    musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
2128    musb->g.is_a_peripheral = 0;
2129#else
21222130    if (devctl & MUSB_DEVCTL_BDEVICE) {
21232131        musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
21242132        musb->g.is_a_peripheral = 0;
...... 
21262134        musb->xceiv->state = OTG_STATE_A_PERIPHERAL;
21272135        musb->g.is_a_peripheral = 1;
21282136    }
2137#endif
21292138
21302139    /* start with default limits on VBUS power draw */
21312140    (void) musb_gadget_vbus_draw(&musb->g, 8);

Archive Download the corresponding diff file



interactive