linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] musb fixes for v5.5-rc6
@ 2020-01-07 15:26 Bin Liu
  2020-01-07 15:26 ` [PATCH 1/2] usb: musb: fix idling for suspend after disconnect interrupt Bin Liu
  2020-01-07 15:26 ` [PATCH 2/2] usb: musb: Disable pullup at init Bin Liu
  0 siblings, 2 replies; 3+ messages in thread
From: Bin Liu @ 2020-01-07 15:26 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-usb, Bin Liu

Hi Greg,

Here are a couple musb fixes for v5.5-rc6. The DP/DM pullup fix is
applicable to the very first commit which brings in the musb drivers, so
the patch probably should apply to all active stable trees if possible.

Please let me know if any change is needed.

Thanks,
-Bin.
---

Paul Cercueil (1):
  usb: musb: Disable pullup at init

Tony Lindgren (1):
  usb: musb: fix idling for suspend after disconnect interrupt

 drivers/usb/musb/musb_core.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] usb: musb: fix idling for suspend after disconnect interrupt
  2020-01-07 15:26 [PATCH 0/2] musb fixes for v5.5-rc6 Bin Liu
@ 2020-01-07 15:26 ` Bin Liu
  2020-01-07 15:26 ` [PATCH 2/2] usb: musb: Disable pullup at init Bin Liu
  1 sibling, 0 replies; 3+ messages in thread
From: Bin Liu @ 2020-01-07 15:26 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-usb, Bin Liu

From: Tony Lindgren <tony@atomide.com>

When disconnected as USB B-device, suspend interrupt should come before
diconnect interrupt, because the DP/DM pins are shorter than the
VBUS/GND pins on the USB connectors. But we sometimes get a suspend
interrupt after disconnect interrupt. In that case we have devctl set to
99 with VBUS still valid and musb_pm_runtime_check_session() wrongly
thinks we have an active session. We have no other interrupts after
disconnect coming in this case at least with the omap2430 glue.

Let's fix the issue by checking the interrupt status again with
delayed work for the devctl 99 case. In the suspend after disconnect
case the devctl session bit has cleared by then and musb can idle.
For a typical USB B-device connect case we just continue with normal
interrupts.

Fixes: 467d5c980709 ("usb: musb: Implement session bit based runtime PM for musb-core")

Cc: Merlijn Wajer <merlijn@wizzup.org>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Sebastian Reichel <sre@kernel.org>
Cc: stable@vger.kernel.org
Signed-off-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Bin Liu <b-liu@ti.com>
---
 drivers/usb/musb/musb_core.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 15cca912c53e..0096fc303cd4 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -1840,6 +1840,9 @@ ATTRIBUTE_GROUPS(musb);
 #define MUSB_QUIRK_B_INVALID_VBUS_91	(MUSB_DEVCTL_BDEVICE | \
 					 (2 << MUSB_DEVCTL_VBUS_SHIFT) | \
 					 MUSB_DEVCTL_SESSION)
+#define MUSB_QUIRK_B_DISCONNECT_99	(MUSB_DEVCTL_BDEVICE | \
+					 (3 << MUSB_DEVCTL_VBUS_SHIFT) | \
+					 MUSB_DEVCTL_SESSION)
 #define MUSB_QUIRK_A_DISCONNECT_19	((3 << MUSB_DEVCTL_VBUS_SHIFT) | \
 					 MUSB_DEVCTL_SESSION)
 
@@ -1862,6 +1865,11 @@ static void musb_pm_runtime_check_session(struct musb *musb)
 	s = MUSB_DEVCTL_FSDEV | MUSB_DEVCTL_LSDEV |
 		MUSB_DEVCTL_HR;
 	switch (devctl & ~s) {
+	case MUSB_QUIRK_B_DISCONNECT_99:
+		musb_dbg(musb, "Poll devctl in case of suspend after disconnect\n");
+		schedule_delayed_work(&musb->irq_work,
+				      msecs_to_jiffies(1000));
+		break;
 	case MUSB_QUIRK_B_INVALID_VBUS_91:
 		if (musb->quirk_retries && !musb->flush_irq_work) {
 			musb_dbg(musb,
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] usb: musb: Disable pullup at init
  2020-01-07 15:26 [PATCH 0/2] musb fixes for v5.5-rc6 Bin Liu
  2020-01-07 15:26 ` [PATCH 1/2] usb: musb: fix idling for suspend after disconnect interrupt Bin Liu
@ 2020-01-07 15:26 ` Bin Liu
  1 sibling, 0 replies; 3+ messages in thread
From: Bin Liu @ 2020-01-07 15:26 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-usb, Bin Liu

From: Paul Cercueil <paul@crapouillou.net>

The pullup may be already enabled before the driver is initialized. This
happens for instance on JZ4740.

It has to be disabled at init time, as we cannot guarantee that a gadget
driver will be bound to the UDC.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Suggested-by: Bin Liu <b-liu@ti.com>
Cc: stable@vger.kernel.org
Signed-off-by: Bin Liu <b-liu@ti.com>
---
 drivers/usb/musb/musb_core.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 0096fc303cd4..5ebf30bd61bd 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -2318,6 +2318,9 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl)
 	musb_disable_interrupts(musb);
 	musb_writeb(musb->mregs, MUSB_DEVCTL, 0);
 
+	/* MUSB_POWER_SOFTCONN might be already set, JZ4740 does this. */
+	musb_writeb(musb->mregs, MUSB_POWER, 0);
+
 	/* Init IRQ workqueue before request_irq */
 	INIT_DELAYED_WORK(&musb->irq_work, musb_irq_work);
 	INIT_DELAYED_WORK(&musb->deassert_reset_work, musb_deassert_reset);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-01-07 15:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-07 15:26 [PATCH 0/2] musb fixes for v5.5-rc6 Bin Liu
2020-01-07 15:26 ` [PATCH 1/2] usb: musb: fix idling for suspend after disconnect interrupt Bin Liu
2020-01-07 15:26 ` [PATCH 2/2] usb: musb: Disable pullup at init Bin Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).