mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Apelete Seketeli <apelete@seketeli.net>
To: linux-usb@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, Felipe Balbi <balbi@ti.com>,
	Lars-Peter Clausen <lars@metafoo.de>
Subject: [PATCH 3/3] usb: musb: fix setting JZ4740 gadget periphal mode on reset
Date: Sat, 14 Dec 2013 04:48:38 +0100	[thread overview]
Message-ID: <1386992918-1531-4-git-send-email-apelete@seketeli.net> (raw)
In-Reply-To: <1386992918-1531-1-git-send-email-apelete@seketeli.net>

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>
---
 drivers/usb/musb/musb_gadget.c |    9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
index 32fb057..b4bea7a 100644
--- a/drivers/usb/musb/musb_gadget.c
+++ b/drivers/usb/musb/musb_gadget.c
@@ -2119,6 +2119,14 @@ __acquires(musb->lock)
 	/* Normal reset, as B-Device;
 	 * or else after HNP, as A-Device
 	 */
+#if defined(CONFIG_USB_MUSB_JZ4740) || defined(CONFIG_USB_MUSB_JZ4740_MODULE)
+	/* JZ4740 UDC Controller is not OTG compatible and does not
+	 * have DEVCTL register in silicon: 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;
@@ -2126,6 +2134,7 @@ __acquires(musb->lock)
 		musb->xceiv->state = OTG_STATE_A_PERIPHERAL;
 		musb->g.is_a_peripheral = 1;
 	}
+#endif
 
 	/* start with default limits on VBUS power draw */
 	(void) musb_gadget_vbus_draw(&musb->g, 8);
-- 
1.7.10.4


  parent reply	other threads:[~2013-12-14  3:48 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-14  3:48 [PATCH 0/3] Add USB support for Ingenic JZ4740 Apelete Seketeli
2013-12-14  3:48 ` [PATCH 1/3] mips: qi_lb60: add defconfig for Ben NanoNote Apelete Seketeli
2013-12-14  3:48 ` [PATCH 2/3] usb: musb: add support for JZ4740 usb device controller Apelete Seketeli
2013-12-14  3:48 ` Apelete Seketeli [this message]
2013-12-16 21:20   ` [PATCH 3/3] usb: musb: fix setting JZ4740 gadget periphal mode on reset Felipe Balbi
2013-12-17  1:31     ` Apelete Seketeli
2013-12-17  2:14       ` Felipe Balbi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1386992918-1531-4-git-send-email-apelete@seketeli.net \
    --to=apelete@seketeli.net \
    --cc=balbi@ti.com \
    --cc=lars@metafoo.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®