[U-Boot] [PATCH 1/3] usb: properly re-initialize the USB keyboard.

From: Vincent Palatin vpalatin@chromium.org
Allow to reconfigure properly the USB keyboard driver when we enumerate several times the USB devices and its position in the device tree has changes.
Signed-off-by: Vincent Palatin vpalatin@chromium.org Signed-off-by: Simon Glass sjg@chromium.org Reviewed-by: Stefan Reinauer reinauer@chromium.org Tested-by: Vincent Palatin vpalatin@chromium.org --- common/usb_kbd.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/common/usb_kbd.c b/common/usb_kbd.c index b962849..188763d 100644 --- a/common/usb_kbd.c +++ b/common/usb_kbd.c @@ -496,6 +496,7 @@ int drv_usb_kbd_init(void) if (old_dev) { /* Already registered, just return ok. */ debug("USB KBD: is already registered.\n"); + usb_kbd_deregister(); return 1; }

From: Vincent Palatin vpalatin@chromium.org
If the USB keyboard is not answering properly the first request on its interrupt endpoint, just skip it and try the next one.
This workarounds an issue with a wireless mouse dongle which presents itself both as a keyboard and a mouse but has a non-functional keyboard interface.
Signed-off-by: Vincent Palatin vpalatin@chromium.org (cherry picked from commit 012bbf0ce0301be2482857e3f03b481dd15c2340) Rebased to upstream/master: Signed-off-by: Simon Glass sjg@chromium.org Reviewed-by: Stefan Reinauer reinauer@chromium.org Tested-by: Vincent Palatin vpalatin@chromium.org --- common/usb_kbd.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/common/usb_kbd.c b/common/usb_kbd.c index 188763d..3174b5e 100644 --- a/common/usb_kbd.c +++ b/common/usb_kbd.c @@ -461,8 +461,13 @@ static int usb_kbd_probe(struct usb_device *dev, unsigned int ifnum) usb_set_idle(dev, iface->desc.bInterfaceNumber, REPEAT_RATE, 0);
debug("USB KBD: enable interrupt pipe...\n"); - usb_submit_int_msg(dev, pipe, data->new, maxp > 8 ? 8 : maxp, - ep->bInterval); + if (usb_submit_int_msg(dev, pipe, data->new, maxp > 8 ? 8 : maxp, + ep->bInterval) < 0) { + printf("Failed to get keyboard state from device %04x:%04x\n", + dev->descriptor.idVendor, dev->descriptor.idProduct); + /* Abort, we don't want to use that non-functional keyboard. */ + return 0; + }
/* Success. */ return 1;

This commit broke USB2 on link (Chromebook Pixel):
020bbcb usb: hub: Power-cycle on root-hub ports
However the root cause seems to be a missing mask and missing 'break' in ehci-hcd.c. This patch fixes both.
On link, 'usb start' with a USB keyboard and memory stick inserted now finds both. The keyboard works as expected. Also ext2ls shows a directory listing from the memory stick.
Signed-off-by: Simon Glass sjg@chromium.org --- drivers/usb/host/ehci-hcd.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index e0f3e4b..445759b 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c @@ -809,21 +809,23 @@ ehci_submit_root(struct usb_device *dev, unsigned long pipe, void *buffer, break; case USB_REQ_CLEAR_FEATURE | ((USB_DIR_OUT | USB_RT_PORT) << 8): reg = ehci_readl(status_reg); + reg &= ~EHCI_PS_CLEAR; switch (le16_to_cpu(req->value)) { case USB_PORT_FEAT_ENABLE: reg &= ~EHCI_PS_PE; break; case USB_PORT_FEAT_C_ENABLE: - reg = (reg & ~EHCI_PS_CLEAR) | EHCI_PS_PE; + reg |= EHCI_PS_PE; break; case USB_PORT_FEAT_POWER: if (HCS_PPC(ehci_readl(&ctrl->hccr->cr_hcsparams))) - reg = reg & ~(EHCI_PS_CLEAR | EHCI_PS_PP); + reg &= ~EHCI_PS_PP; + break; case USB_PORT_FEAT_C_CONNECTION: - reg = (reg & ~EHCI_PS_CLEAR) | EHCI_PS_CSC; + reg |= EHCI_PS_CSC; break; case USB_PORT_FEAT_OVER_CURRENT: - reg = (reg & ~EHCI_PS_CLEAR) | EHCI_PS_OCC; + reg |= EHCI_PS_OCC; break; case USB_PORT_FEAT_C_RESET: ctrl->portreset &= ~(1 << port);

Dear Simon Glass,
This commit broke USB2 on link (Chromebook Pixel):
020bbcb usb: hub: Power-cycle on root-hub ports
However the root cause seems to be a missing mask and missing 'break' in ehci-hcd.c. This patch fixes both.
On link, 'usb start' with a USB keyboard and memory stick inserted now finds both. The keyboard works as expected. Also ext2ls shows a directory listing from the memory stick.
Signed-off-by: Simon Glass sjg@chromium.org
Picking up all three, thanks!
Best regards, Marek Vasut

On Sat, May 11, 2013 at 10:39 AM, Marek Vasut marex@denx.de wrote:
Dear Simon Glass,
This commit broke USB2 on link (Chromebook Pixel):
020bbcb usb: hub: Power-cycle on root-hub ports
However the root cause seems to be a missing mask and missing 'break' in ehci-hcd.c. This patch fixes both.
On link, 'usb start' with a USB keyboard and memory stick inserted now finds both. The keyboard works as expected. Also ext2ls shows a directory listing from the memory stick.
Signed-off-by: Simon Glass sjg@chromium.org
Picking up all three, thanks!
Thanks, also Julius may have some comments on Monday. Two of the patches were reviewed by him, but not the last one, although he suggested it.
Regards, Simon
Best regards, Marek Vasut

Dear Simon Glass,
On Sat, May 11, 2013 at 10:39 AM, Marek Vasut marex@denx.de wrote:
Dear Simon Glass,
This commit broke USB2 on link (Chromebook Pixel): 020bbcb usb: hub: Power-cycle on root-hub ports
However the root cause seems to be a missing mask and missing 'break' in ehci-hcd.c. This patch fixes both.
On link, 'usb start' with a USB keyboard and memory stick inserted now finds both. The keyboard works as expected. Also ext2ls shows a directory listing from the memory stick.
Signed-off-by: Simon Glass sjg@chromium.org
Picking up all three, thanks!
Thanks, also Julius may have some comments on Monday. Two of the patches were reviewed by him, but not the last one, although he suggested it.
I just build-tested them, seem OK.
btw. I might be less available this month, sorry about that.
Best regards, Marek Vasut

Thanks for taking charge of this Simon, looks good to me. Good catch with the missing break!
Now that I look at it, the FEAT_C_ENABLE section seems to be broken as well, it should be setting EHCI_PS_PEC instead of EHCI_PS_PE. Maybe that code path is never used in practice.
Acked-by: Julius Werner jwerner@chromium.org
participants (3)
-
Julius Werner
-
Marek Vasut
-
Simon Glass