[PATCH 2/2] usb: chipidea: Wait 50 ms before reading ID bit

From: Mike Looijmans
Date: Fri Jun 26 2015 - 09:47:41 EST


The datasheet for the USB343x PHY mentions a 50ms wait time before
reading back the ID bit after enabling the internal pull-up or a
reset:
"To monitor the status of the ID pin, the Link activates the IdPullup
bit in the OTG Control register, waits 50mS and then reads the status
of the IdGnd bit in the USB Interrupt Status register."
Implement this by adding a 50ms sleep at the only point in the code
where the ID status is being read without IRQ trigger.

When starting the board with a USB cable connected to a PC, the
system would activate host mode, then in ~20ms get an ID IRQ and
attempt to switch to gadget mode. This then failed because the
VBUS will not drop to zero (because the host is supplying it).

After this patch, the system starts up correctly and selects
gadget mode immediately, and the USB link works. It also fixes
the issue that the VBUS supply was being activated while already
being supplied from the host PC.

Signed-off-by: Mike Looijmans <mike.looijmans@xxxxxxxx>
---
drivers/usb/chipidea/core.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index c865abe..4c6cf48 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -801,6 +801,7 @@ static int ci_hdrc_probe(struct platform_device *pdev)

if (ci->roles[CI_ROLE_HOST] && ci->roles[CI_ROLE_GADGET]) {
if (ci->is_otg) {
+ msleep(50); /* Datasheet: Wait 50ms to read ID */
ci->role = ci_otg_role(ci);
/* Enable ID change irq */
hw_write_otgsc(ci, OTGSC_IDIE, OTGSC_IDIE);
--
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/