This patch adds cdc_acm interoperability to u-boot usbtty. It was taken (almost blindly) from the Linux for Siemens SX1 project on handhelds.org. Please don't complain to me about coding style issues or whitespace changes in this one - HW. Index: u-boot/drivers/serial/usbtty.c =================================================================== --- u-boot.orig/drivers/serial/usbtty.c +++ u-boot/drivers/serial/usbtty.c @@ -1,7 +1,7 @@ /* * (C) Copyright 2003 * Gerry Hamel, geh@ti.com, Texas Instruments - * + * * (C) Copyright 2006 * Bryan O'Donoghue, bodonoghue@codehermit.ie * @@ -25,6 +25,7 @@ #ifdef CONFIG_USB_TTY +#include #include #include #include "usbtty.h" @@ -474,6 +475,12 @@ usbtty_poll (); space = maxlen - usbtty_output.size; + + /* If the USB is not configured, allow the circular buffer to + be overwritten. Otherwise this while() will loop forever. */ + if (!usbtty_configured()) + space = maxlen; + /* Empty buffer here, if needed, to ensure space... */ if (space) { write_buffer (&usbtty_output); @@ -544,6 +551,14 @@ } usbtty_init_terminal_type(strcmp(tt,"cdc_acm")); + /* Decide on which type of UDC device to be. + */ + + if(!(tt = getenv("usbtty"))) { + tt = "generic"; + } + usbtty_init_terminal_type(strcmp(tt,"cdc_acm")); + /* prepare buffers... */ buf_init (&usbtty_input, USBTTY_BUFFER_SIZE); buf_init (&usbtty_output, USBTTY_BUFFER_SIZE); Index: u-boot/drivers/serial/usbtty.h =================================================================== --- u-boot.orig/drivers/serial/usbtty.h +++ u-boot/drivers/serial/usbtty.h @@ -27,7 +27,7 @@ #include "usbdcore.h" #if defined(CONFIG_PPC) #include "usbdcore_mpc8xx.h" -#elif defined(CONFIG_ARM) +#elif defined(CONFIG_OMAP1510) #include "usbdcore_omap1510.h" #endif @@ -36,12 +36,13 @@ /* If no VendorID/ProductID is defined in config.h, pretend to be Linux * DO NOT Reuse this Vendor/Product setup with protocol incompatible devices */ +#ifndef CONFIG_USBD_VENDORID #define CONFIG_USBD_VENDORID 0x0525 /* Linux/NetChip */ #define CONFIG_USBD_PRODUCTID_GSERIAL 0xa4a6 /* gserial */ #define CONFIG_USBD_PRODUCTID_CDCACM 0xa4a7 /* CDC ACM */ #define CONFIG_USBD_MANUFACTURER "Das U-Boot" #define CONFIG_USBD_PRODUCT_NAME U_BOOT_VERSION - +#endif /* CONFIG_USBD_VENDORID */ #define CONFIG_USBD_CONFIGURATION_STR "TTY via USB" Index: u-boot/drivers/usb/usbdcore_omap1510.c =================================================================== --- u-boot.orig/drivers/usb/usbdcore_omap1510.c +++ u-boot/drivers/usb/usbdcore_omap1510.c @@ -960,7 +960,7 @@ /* Handle general USB interrupts and dispatch according to type. * This function implements TRM Figure 14-13. */ -void omap1510_udc_irq (void) +static void omap1510_udc_irq (void) { u16 irq_src = inw (UDC_IRQ_SRC); int valid_irq = 0; @@ -1000,7 +1000,7 @@ } /* This function implements TRM Figure 14-26. */ -void omap1510_udc_noniso_irq (void) +static void omap1510_udc_noniso_irq (void) { unsigned short epnum; unsigned short irq_src = inw (UDC_IRQ_SRC); @@ -1054,6 +1054,20 @@ irq_src); } +void udc_irq(void) +{ + /* Loop while we have interrupts. + * If we don't do this, the input chain + * polling delay is likely to miss + * host requests. + */ + while (inw (UDC_IRQ_SRC) & ~UDC_SOF_Flg) { + /* Handle any new IRQs */ + omap1510_udc_irq (); + omap1510_udc_noniso_irq (); + } +} + /* ------------------------------------------------------------------------------- */