Patchwork [U-Boot,v4,4/5] USB: Add usb_event_poll() to get keyboards working with EHCI

login
register
mail settings
Submitter Jana Rapava
Date Sept. 25, 2011, 11:55 a.m.
Message ID <1316951758-2235-4-git-send-email-fermata7@gmail.com>
Download mbox | patch
Permalink /patch/116280/
State Superseded
Headers show

Comments

Jana Rapava - Sept. 25, 2011, 11:55 a.m.
From: Marek Vasut <marek.vasut@gmail.com>

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>
Cc: Stefano Babic <sbabic@denx.de>
---
Changes for v2:
       - changed to proper patch
Changes for v3:
       - merged other USB patches from u-boot-pxa/efikasb
       - offset-based access changed to struct-based access
       - use {clrset,clr,set}bits_le32() calls
       - CodingStyle and naming cleanup
Changes for v4:
	- split into patchset
	- added usb_event_poll()

 drivers/usb/host/ehci-hcd.c |   33 ++++++++++++++++++++++++++++++++-
 1 files changed, 32 insertions(+), 1 deletions(-)
Marek Vasut - Sept. 25, 2011, 12:02 p.m.
On Sunday, September 25, 2011 01:55:57 PM Jana Rapava wrote:
> From: Marek Vasut <marek.vasut@gmail.com>
> 
> 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>
> Cc: Stefano Babic <sbabic@denx.de>

This patch is not part of this patchset.

Patch

diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index f420279..36f21f9 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -27,6 +27,10 @@ 
 #include <malloc.h>
 #include <watchdog.h>
 #include <usb/ehci-fsl.h>
+#ifdef CONFIG_USB_KEYBOARD
+#include <stdio_dev.h>
+extern unsigned char new[];
+#endif
 
 #include "ehci.h"
 
@@ -903,5 +907,32 @@  submit_int_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
 
 	debug("dev=%p, pipe=%lu, buffer=%p, length=%d, interval=%d",
 	      dev, pipe, buffer, length, interval);
-	return -1;
+	return ehci_submit_async(dev, pipe, buffer, length, NULL);
+}
+
+#ifdef CONFIG_SYS_USB_EVENT_POLL
+/*
+ * This function polls for USB keyboard data.
+ */
+void usb_event_poll()
+{
+	struct stdio_dev *dev;
+	struct usb_device *usb_kbd_dev;
+	struct usb_interface *iface;
+	struct usb_endpoint_descriptor *ep;
+	int pipe;
+	int maxp;
+
+	/* Get the pointer to USB Keyboard device pointer */
+	dev = stdio_get_by_name("usbkbd");
+	usb_kbd_dev = (struct usb_device *)dev->priv;
+	iface = &usb_kbd_dev->config.if_desc[0];
+	ep = &iface->ep_desc[0];
+	pipe = usb_rcvintpipe(usb_kbd_dev, ep->bEndpointAddress);
+
+	/* Submit a interrupt transfer request */
+	maxp = usb_maxpacket(usb_kbd_dev, pipe);
+	usb_submit_int_msg(usb_kbd_dev, pipe, &new[0],
+			maxp > 8 ? 8 : maxp, ep->bInterval);
 }
+#endif /* CONFIG_SYS_USB_EVENT_POLL */