From: Jon Loeliger Date: Thu, 22 Mar 2007 13:57:37 -0500 Subject: [U-Boot-Users] RFC About USB Keyboard Polling Message-ID: <1174589857.32390.52.camel@ld0161-tx32> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Wolfgang, We need to add USB Keyboard support to the 8641 HPCN board. We currently have this working in a mode that is polled rather than configuring any interrupts and handlers. However, to do so, we needed to extend the usb_kbd_getc() routine to possibly poll for interrupts as well. So as to avoid introducing extra code for platforms that do not need it, we propose the following two patches. Does this seem look a good approach to you? Thanks, jdl PS -- The actual USB OHCI driver is a separate patch too, but it is board specific. The patches below represent the changes to the common code. commit 78c25c38ba8786b12b5d08d2555493ad74564825 Author: Zhang Wei Date: Wed Feb 14 14:43:53 2007 +0800 Add CFG_USB_INTERRUPT_POLL support. Allow the USB controller to use interrupt polling in the input waiting loop in usb_kbd_getc() instead of asynchronous interrupts. Signed-off-by: Zhang Wei Signed-off-by: Jon Loeliger diff --git a/README b/README index ecfd1f8..93467a0 100644 --- a/README +++ b/README @@ -883,6 +883,9 @@ The following options need to be configured: for differential drivers: 0x00001000 for single ended drivers: 0x00005000 + CFG_USB_INTERRUPT_POLL + May be defined to allow interrupt polling + instead of using aysnchronous interrupts. - MMC Support: The MMC controller on the Intel PXA is supported. To diff --git a/common/usb_kbd.c b/common/usb_kbd.c index 56c2166..3464bd7 100644 --- a/common/usb_kbd.c +++ b/common/usb_kbd.c @@ -129,7 +129,11 @@ static int usb_kbd_testc(void) static int usb_kbd_getc(void) { char c; - while(usb_in_pointer==usb_out_pointer); + while(usb_in_pointer==usb_out_pointer) { +#ifdef CFG_USB_INTERRUPT_POLL + usb_interrupt_query(); +#endif + } if((usb_out_pointer+1)==USB_KBD_BUFFER_LEN) usb_out_pointer=0; else diff --git a/include/configs/MPC8641HPCN.h b/include/configs/MPC8641HPCN.h index 657162a..f663d72 100644 --- a/include/configs/MPC8641HPCN.h +++ b/include/configs/MPC8641HPCN.h @@ -337,6 +337,7 @@ #define CONFIG_USB_OHCI 1 #define CONFIG_USB_KEYBOARD 1 #define CFG_DEVICE_DEREGISTER +#define CFG_USB_INTERRUPT_POLL 1 #if !defined(CONFIG_PCI_PNP) #define PCI_ENET0_IOADDR 0xe0000000 And then the actual poll routine itself: commit f4a95829c0b9ef555d1ce750a5e501985e7c31b1 Author: Zhang Wei Date: Mon Feb 12 19:00:37 2007 +0800 Add interrupt query function to USB core. Without asynchronous interrupt support, it may be necessary to poll for USB keyboard interrupts. Signed-off-by: Zhang Wei Signed-off-by: Jon Loeliger diff --git a/common/usb.c b/common/usb.c index 0857494..a5062a6 100644 --- a/common/usb.c +++ b/common/usb.c @@ -143,6 +143,17 @@ void usb_disable_asynch(int disable) } +#ifdef CFG_USB_INTERRUPT_POLL +/* + * Poll for USB keyboard interrupts. + */ +void usb_interrupt_query(void) +{ + interrupt_poll(); +} +#endif + + /*------------------------------------------------------------------- * Message wrappers. * diff --git a/include/usb.h b/include/usb.h index bf71554..f6bf1aa 100644 --- a/include/usb.h +++ b/include/usb.h @@ -177,6 +177,7 @@ int submit_control_msg(struct usb_device *dev, unsigned long pipe, void *buffer, int transfer_len,struct devrequest *setup); int submit_int_msg(struct usb_device *dev, unsigned long pipe, void *buffer, int transfer_len, int interval); +void interrupt_poll(void); /* Might need to poll for interrupts */ /* Defines */ #define USB_UHCI_VEND_ID 0x8086 @@ -218,6 +219,7 @@ int usb_bulk_msg(struct usb_device *dev, unsigned int pipe, int usb_submit_int_msg(struct usb_device *dev, unsigned long pipe, void *buffer,int transfer_len, int interval); void usb_disable_asynch(int disable); +void usb_interrupt_query(void); int usb_maxpacket(struct usb_device *dev,unsigned long pipe); void __inline__ wait_ms(unsigned long ms); int usb_get_configuration_no(struct usb_device *dev,unsigned char *buffer,int cfgno);