Commit 7555d5ec29a52290d706440ce64fa02a53a3c4cf
Committed by
Remy Bohmer
1 parent
26cc5129ee
Exists in
master
and in
54 other branches
USB: Add usb_event_poll() to get keyboards working with EHCI
Signed-off-by: Marek Vasut <marek.vasut@gmail.com> Cc: Remy Bohmer <linux@bohmer.net>
Showing 1 changed file with 32 additions and 1 deletions Side-by-side Diff
drivers/usb/host/ehci-hcd.c
... | ... | @@ -26,6 +26,10 @@ |
26 | 26 | #include <asm/io.h> |
27 | 27 | #include <malloc.h> |
28 | 28 | #include <watchdog.h> |
29 | +#ifdef CONFIG_USB_KEYBOARD | |
30 | +#include <stdio_dev.h> | |
31 | +extern unsigned char new[]; | |
32 | +#endif | |
29 | 33 | |
30 | 34 | #include "ehci.h" |
31 | 35 | |
32 | 36 | |
... | ... | @@ -895,6 +899,33 @@ |
895 | 899 | |
896 | 900 | debug("dev=%p, pipe=%lu, buffer=%p, length=%d, interval=%d", |
897 | 901 | dev, pipe, buffer, length, interval); |
898 | - return -1; | |
902 | + return ehci_submit_async(dev, pipe, buffer, length, NULL); | |
899 | 903 | } |
904 | + | |
905 | +#ifdef CONFIG_SYS_USB_EVENT_POLL | |
906 | +/* | |
907 | + * This function polls for USB keyboard data. | |
908 | + */ | |
909 | +void usb_event_poll() | |
910 | +{ | |
911 | + struct stdio_dev *dev; | |
912 | + struct usb_device *usb_kbd_dev; | |
913 | + struct usb_interface *iface; | |
914 | + struct usb_endpoint_descriptor *ep; | |
915 | + int pipe; | |
916 | + int maxp; | |
917 | + | |
918 | + /* Get the pointer to USB Keyboard device pointer */ | |
919 | + dev = stdio_get_by_name("usbkbd"); | |
920 | + usb_kbd_dev = (struct usb_device *)dev->priv; | |
921 | + iface = &usb_kbd_dev->config.if_desc[0]; | |
922 | + ep = &iface->ep_desc[0]; | |
923 | + pipe = usb_rcvintpipe(usb_kbd_dev, ep->bEndpointAddress); | |
924 | + | |
925 | + /* Submit a interrupt transfer request */ | |
926 | + maxp = usb_maxpacket(usb_kbd_dev, pipe); | |
927 | + usb_submit_int_msg(usb_kbd_dev, pipe, &new[0], | |
928 | + maxp > 8 ? 8 : maxp, ep->bInterval); | |
929 | +} | |
930 | +#endif /* CONFIG_SYS_USB_EVENT_POLL */ |