Patchwork [U-Boot] USB: Add usb_event_poll() to get keyboards working with EHCI

login
register
mail settings
Submitter Marek Vasut
Date Sept. 23, 2011, 3:36 p.m.
Message ID <1316792213-18385-1-git-send-email-marek.vasut@gmail.com>
Download mbox | patch
Permalink /patch/116111/
State Accepted
Delegated to: Marek Vasut
Headers show

Comments

Marek Vasut - Sept. 23, 2011, 3:36 p.m.
Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
Cc: Remy Bohmer <linux@bohmer.net>
---
 drivers/usb/host/ehci-hcd.c |   33 ++++++++++++++++++++++++++++++++-
 1 files changed, 32 insertions(+), 1 deletions(-)
Remy Bohmer - Sept. 24, 2011, 4:41 p.m.
Hi,

2011/9/23 Marek Vasut <marek.vasut@gmail.com>:
> Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
> Cc: Remy Bohmer <linux@bohmer.net>
> ---
>  drivers/usb/host/ehci-hcd.c |   33 ++++++++++++++++++++++++++++++++-
>  1 files changed, 32 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
> index 52b98c2..5b53b3a 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"
>
> @@ -914,5 +918,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);

Why is changing this line needed?

> +}
> +
> +#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 */

Patch does not apply to u-boot-usb master.
Please rebase this patch.

Kind regards,

Remy
Marek Vasut - Sept. 24, 2011, 4:50 p.m.
On Saturday, September 24, 2011 06:41:58 PM Remy Bohmer wrote:
> Hi,
> 
> 2011/9/23 Marek Vasut <marek.vasut@gmail.com>:
> > Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
> > Cc: Remy Bohmer <linux@bohmer.net>
> > ---
> >  drivers/usb/host/ehci-hcd.c |   33 ++++++++++++++++++++++++++++++++-
> >  1 files changed, 32 insertions(+), 1 deletions(-)
> > 
> > diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
> > index 52b98c2..5b53b3a 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"
> > 
> > @@ -914,5 +918,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);
> 
> Why is changing this line needed?

To actually submit the interrupt request ?

> 
> > +}
> > +
> > +#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 */
> 
> Patch does not apply to u-boot-usb master.
> Please rebase this patch.

Ah right ... there must be some changes in my repo or u-boot-imx/next ... will 
do in my next submission round.

Cheers

> 
> Kind regards,
> 
> Remy
Remy Bohmer - Sept. 24, 2011, 4:56 p.m.
Hi,

2011/9/24 Marek Vasut <marek.vasut@gmail.com>:
> On Saturday, September 24, 2011 06:41:58 PM Remy Bohmer wrote:
>> Hi,
>>
>> 2011/9/23 Marek Vasut <marek.vasut@gmail.com>:
>> > Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
>> > Cc: Remy Bohmer <linux@bohmer.net>
>> > ---
>> >  drivers/usb/host/ehci-hcd.c |   33 ++++++++++++++++++++++++++++++++-
>> >  1 files changed, 32 insertions(+), 1 deletions(-)
>> >
>> > diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
>> > index 52b98c2..5b53b3a 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"
>> >
>> > @@ -914,5 +918,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);
>>
>> Why is changing this line needed?
>
> To actually submit the interrupt request ?

Was just checking... at first impression it appeared to be some
unrelated change. While looking at it in its context it seems indeed
logical.

> Ah right ... there must be some changes in my repo or u-boot-imx/next ... will
> do in my next submission round.

OK. I will pull it in then.

Kind regards,

Remy

Patch

diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 52b98c2..5b53b3a 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"
 
@@ -914,5 +918,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 */