V2 of OMAP3 USB device Support
Subsystems (5)
The technical change is better handling of address setting on the usb handshaking setup phase.
Other changes from Jean's comments
2/8 USB add macros for debugging usb device setup.
static inline function replacing debug macros
3/8 TWL4030 Add usb PHY support
add empty lines between variables and statements
other empty lines added for readablity
4/8 OMAP3 Add usb device support
80+ char lines reduced
Used MUSB_FLAGS_PRINT macro suggestion
lowercased function names
multi-lined ep0_state_enum
Used suggestion on udelay to 1000 * 1000
add empty lines between variables and statements
inverted check of ep0_urb->device_request.wLength
other empty lines added for readablity
5/8 OMAP3 zoom1 Add usbtty configuration
This was ack-ed by Jean
6/8 OMAP3 beagle Add usbtty configuration
This was ack-ed by Jean
8/8 OMAP3 zoom2 Use usbtty if the debug board
cleanup using usbtty_* functions or their stubs without #define's
PATCH 1/8 USB Consolidate descriptor definitions
The header files usb.h and usbdescriptors.h have the same or similarly named structure definitions for
usb_device_descriptorusb_string_descriptorusb_endpoint_descriptorusb_config_descriptor vs usb_configuration_descriptor usb_interface_descriptor
There should only be one definition of these structures. Some of these structures are element-wise duplicates, one has unused elements that can be reduced to a duplicate, and some of the the structures have additional elements.
These are the element-wise duplicates in usb.h
usb_device_descriptorusb_string_descriptor
For these, the usb.h definition will be removed.
This definition in usb.h has extra unused elements
usb_endpoint_descriptor
unsigned char bRefresh unsigned char bSynchAddress;
The definition of usb_endpoint_descriptor in usb.h will be removed.
These definitions in usb.h have extra elements at the end of the usb 2.0 specified descriptor:
usb_config_descriptorusb_interface_descriptor
These structures will have their name shorted by removing the '_descriptor' suffix.
So
usb_config_descriptor -> usb_configusb_interface_descriptor -> usb_interface
The common descriptor elements are now defined by the macros
USB_CONFIG_DESCRIPTOR_DEFINITIONUSB_INTERFACE_DESCRIPTOR_DEFINITION
This has been compile tested on MAKEALL arm, ppc and mips.
--- common/cmd_usb.c | 12 ++++---- common/usb.c | 8 ++-- common/usb_kbd.c | 4 +- common/usb_storage.c | 2 +- cpu/ppc4xx/usbdev.c | 4 +- drivers/usb/host/ehci-hcd.c | 2 +- drivers/usb/musb/musb_hcd.c | 2 +- include/usb.h | 70 +++++------------------------------------- include/usbdescriptors.h | 40 ++++++++++++++---------- 9 files changed, 49 insertions(+), 95 deletions(-)
common/cmd_usb.c +6 -6
@@ -187,14 +187,14 @@ void usb_display_desc(struct usb_device *dev) } -void usb_display_conf_desc (struct usb_config_descriptor *config, +void usb_display_conf_desc (struct usb_config *config,struct usb_device *dev) {printf (" Configuration: %d\n" , config->bConfigurationValue);printf (" - Interfaces: %d %s%s%dmA\n" , config->bNumInterfaces, (config->bmAttributes &0x40 ) ?"Self Powered " :"Bus Powered " , (config->bmAttributes &0x20 ) ?"Remote Wakeup " :"" , - config->MaxPower*2 ); + config->bMaxPower*2 );if (config->iConfiguration) {printf (" - " );usb_display_string (dev, config->iConfiguration);
@@ -202,7 +202,7 @@ void usb_display_conf_desc(struct usb_config_descriptor *config, } } -void usb_display_if_desc (struct usb_interface_descriptor *ifdesc, +void usb_display_if_desc (struct usb_interface *ifdesc,struct usb_device *dev) {printf (" Interface: %d\n" , ifdesc->bInterfaceNumber);
@@ -246,8 +246,8 @@ void usb_display_ep_desc(struct usb_endpoint_descriptor *epdesc)/* main routine to diasplay the configs, interfaces and endpoints */ void usb_display_config (struct usb_device *dev) { -struct usb_config_descriptor *config; -struct usb_interface_descriptor *ifdesc; +struct usb_config *config; +struct usb_interface *ifdesc;struct usb_endpoint_descriptor *epdesc;int i, ii;
@@ -321,7 +321,7 @@ void usb_show_tree_graph(struct usb_device *dev, char *pre)printf (" %s (%s, %dmA)\n" ,usb_get_class_desc ( dev->config.if_desc[0 ].bInterfaceClass),portspeed (dev->speed), - dev->config.MaxPower *2 ); + dev->config.bMaxPower *2 );if (strlen (dev->mf) ||strlen (dev->prod) ||strlen (dev->serial))printf (" %s %s %s %s\n" , pre, dev->mf, dev->prod, dev->serial);printf (" %s\n" , pre);
common/usb.c +4 -4
@@ -440,10 +440,10 @@ int usb_get_configuration_no(struct usb_device *dev, {int result;unsigned int tmp; -struct usb_config_descriptor *config; +struct usb_config *config; - config = (struct usb_config_descriptor *)&buffer[0 ]; + config = (struct usb_config *)&buffer[0 ]; result =usb_get_descriptor (dev,USB_DT_CONFIG , cfgno, buffer,9 );if (result <9 ) {if (result <0 )
@@ -489,7 +489,7 @@ int usb_set_address(struct usb_device *dev)*/ int usb_set_interface (struct usb_device *dev,int interface,int alternate) { -struct usb_interface_descriptor *if_face =NULL ; +struct usb_interface *if_face =NULL ;int ret, i;for (i =0 ; i < dev->config.bNumInterfaces; i++) {
@@ -1347,7 +1347,7 @@ int usb_hub_configure(struct usb_device *dev)int usb_hub_probe (struct usb_device *dev,int ifnum) { -struct usb_interface_descriptor *iface; +struct usb_interface *iface;struct usb_endpoint_descriptor *ep;int ret;
common/usb_kbd.c +2 -2
@@ -229,7 +229,7 @@ int usb_kbd_deregister(void)static void usb_kbd_setled (struct usb_device *dev) { -struct usb_interface_descriptor *iface; +struct usb_interface *iface; iface = &dev->config.if_desc[0 ]; leds=0 ;if (scroll_lock!=0 )
@@ -348,7 +348,7 @@ static int usb_kbd_irq(struct usb_device *dev)/* probes the USB device dev for keyboard type */ static int usb_kbd_probe (struct usb_device *dev,unsigned int ifnum) { -struct usb_interface_descriptor *iface; +struct usb_interface *iface;struct usb_endpoint_descriptor *ep;int pipe,maxp;
common/usb_storage.c +1 -1
@@ -1070,7 +1070,7 @@ retry_it:int usb_storage_probe (struct usb_device *dev,unsigned int ifnum,struct us_data *ss) { -struct usb_interface_descriptor *iface; +struct usb_interface *iface;int i;unsigned int flags =0 ;
cpu/ppc4xx/usbdev.c +2 -2
@@ -21,7 +21,7 @@ void process_endpoints(unsigned short usb2d0_intrin) {/*will hold the packet received */ struct usb_device_descriptor usb_device_packet; -struct usb_config_descriptor usb_config_packet; +struct usb_configuration_descriptor usb_config_packet;struct usb_string_descriptor usb_string_packet;struct devrequest setup_packet;unsigned int *setup_packet_pt;
@@ -99,7 +99,7 @@ void process_endpoints(unsigned short usb2d0_intrin) usb_config_packet.bConfigurationValue =1 ; usb_config_packet.iConfiguration =0 ; usb_config_packet.bmAttributes =0x40 ; - usb_config_packet.MaxPower =0 ; + usb_config_packet.bMaxPower =0 ;/*put packet in fifo */ packet_pt = (unsigned char *)&usb_config_packet;
drivers/usb/host/ehci-hcd.c +1 -1
@@ -96,7 +96,7 @@ static struct descriptor {* UE_DIR_IN | EHCI_INTR_ENDPT */ 3, /* bmAttributes: UE_INTERRUPT */ - 8, 0, /* wMaxPacketSize */ + 8, /* wMaxPacketSize */255 /* bInterval */ }, };
drivers/usb/musb/musb_hcd.c +1 -1
@@ -803,7 +803,7 @@ void usb_event_poll() {struct stdio_dev *dev;struct usb_device *usb_kbd_dev; -struct usb_interface_descriptor *iface; +struct usb_interface *iface;struct usb_endpoint_descriptor *ep;int pipe;int maxp;
include/usb.h +9 -61
102 lines not on this page · raw message
include/usbdescriptors.h +23 -17
@@ -201,27 +201,33 @@ struct usb_endpoint_descriptor {u8 bInterval; } __attribute__ ((packed)); +#define USB_INTERFACE_DESCRIPTOR_DEFINITION \ + u8 bLength; \ + u8 bDescriptorType; /* 0x04 */ \ + u8 bInterfaceNumber; \ + u8 bAlternateSetting; \ + u8 bNumEndpoints; \ + u8 bInterfaceClass; \ + u8 bInterfaceSubClass; \ + u8 bInterfaceProtocol; \ + u8 iInterface +struct usb_interface_descriptor { -u8 bLength; -u8 bDescriptorType;/* 0x04 */ -u8 bInterfaceNumber; -u8 bAlternateSetting; -u8 bNumEndpoints; -u8 bInterfaceClass; -u8 bInterfaceSubClass; -u8 bInterfaceProtocol; -u8 iInterface; +USB_INTERFACE_DESCRIPTOR_DEFINITION ; } __attribute__ ((packed)); +#define USB_CONFIG_DESCRIPTOR_DEFINITION \ + u8 bLength; \ + u8 bDescriptorType; /* 0x2 */ \ + u16 wTotalLength; \ + u8 bNumInterfaces; \ + u8 bConfigurationValue; \ + u8 iConfiguration; \ + u8 bmAttributes; \ + u8 bMaxPower +struct usb_configuration_descriptor { -u8 bLength; -u8 bDescriptorType;/* 0x2 */ -u16 wTotalLength; -u8 bNumInterfaces; -u8 bConfigurationValue; -u8 iConfiguration; -u8 bmAttributes; -u8 bMaxPower; +USB_CONFIG_DESCRIPTOR_DEFINITION ; } __attribute__ ((packed));struct usb_device_descriptor {
Signature · 1 line
1.6.0.6
PATCH 2/8 USB add macros for debugging usb device setup.
When developing usb device features, it is useful to print out common usb structures.
--- include/usbdescriptors.h | 26 ++++++++++++ include/usbdevice.h | 103 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 129 insertions(+), 0 deletions(-)
include/usbdescriptors.h +26 -0
@@ -510,4 +510,30 @@ struct usb_class_descriptor { } __attribute__ ((packed)); +#ifdef DEBUG +static inline void print_device_descriptor (struct usb_device_descriptor *d) +{ +serial_printf ("usb device descriptor \n" ); +serial_printf ("\tbLength %2.2x\n" , d->bLength); +serial_printf ("\tbDescriptorType %2.2x\n" , d->bDescriptorType); +serial_printf ("\tbcdUSB %4.4x\n" , d->bcdUSB); +serial_printf ("\tbDeviceClass %2.2x\n" , d->bDeviceClass); +serial_printf ("\tbDeviceSubClass %2.2x\n" , d->bDeviceSubClass); +serial_printf ("\tbDeviceProtocol %2.2x\n" , d->bDeviceProtocol); +serial_printf ("\tbMaxPacketSize0 %2.2x\n" , d->bMaxPacketSize0); +serial_printf ("\tidVendor %4.4x\n" , d->idVendor); +serial_printf ("\tidProduct %4.4x\n" , d->idProduct); +serial_printf ("\tbcdDevice %4.4x\n" , d->bcdDevice); +serial_printf ("\tiManufacturer %2.2x\n" , d->iManufacturer); +serial_printf ("\tiProduct %2.2x\n" , d->iProduct); +serial_printf ("\tiSerialNumber %2.2x\n" , d->iSerialNumber); +serial_printf ("\tbNumConfigurations %2.2x\n" , d->bNumConfigurations); +} + +#else + +/* stubs */ +#define print_device_descriptor (d) + +#endif /* DEBUG */ #endif
include/usbdevice.h +103 -0
107 lines not on this page · raw message
Signature · 1 line
1.6.0.6
PATCH 3/8 TWL4030 Add usb PHY support
The twl4030 provides a PHY device for connecting a link device, like musb, to physical connection.
This change adds the twl4030 usb registers and functions for initializing the PHY as required by omap3.
--- Makefile | 1 + drivers/usb/phy/Makefile | 44 +++++++++++ drivers/usb/phy/twl4030.c | 189 +++++++++++++++++++++++++++++++++++++++++++++ include/twl4030.h | 143 ++++++++++++++++++++++++++++++---- 4 files changed, 362 insertions(+), 15 deletions(-) create mode 100644 drivers/usb/phy/Makefile create mode 100644 drivers/usb/phy/twl4030.c
Makefile +1 -0
@@ -243,6 +243,7 @@ LIBS += drivers/twserial/libtws.a LIBS += drivers/usb/gadget/libusb_gadget.a LIBS += drivers/usb/host/libusb_host.a LIBS += drivers/usb/musb/libusb_musb.a +LIBS += drivers/usb/phy/libusb_phy.a LIBS += drivers/video/libvideo.a LIBS += drivers/watchdog/libwatchdog.a LIBS += common/libcommon.a
drivers/usb/phy/Makefile new file +44 -0
44 lines not on this page · raw message
drivers/usb/phy/twl4030.c new file +189 -0
189 lines not on this page · raw message
include/twl4030.h +128 -15
153 lines not on this page · raw message
Signature · 1 line
1.6.0.6
PATCH 4/8 OMAP3 Add usb device support
This change adds the usb device support for musb.
Omap3 platform support added at the same level as davinci.
The interface for usbtty to use the musb device support was added.
Verified on omap3 beagle, zoom1 and zoom2.
--- drivers/serial/usbtty.h | 2 + drivers/usb/musb/Makefile | 2 + drivers/usb/musb/musb_core.c | 8 +- drivers/usb/musb/musb_core.h | 40 ++ drivers/usb/musb/musb_debug.h | 205 +++++++++ drivers/usb/musb/musb_udc.c | 963 +++++++++++++++++++++++++++++++++++++++++ drivers/usb/musb/omap3.c | 129 ++++++ drivers/usb/musb/omap3.h | 48 ++ include/usb.h | 3 +- include/usb/musb_udc.h | 54 +++ 10 files changed, 1451 insertions(+), 3 deletions(-) create mode 100644 drivers/usb/musb/musb_debug.h create mode 100644 drivers/usb/musb/musb_udc.c create mode 100644 drivers/usb/musb/omap3.c create mode 100644 drivers/usb/musb/omap3.h create mode 100644 include/usb/musb_udc.h
drivers/serial/usbtty.h +2 -0
@@ -29,6 +29,8 @@#include <usb/mpc8xx_udc.h> #elif defined(CONFIG_OMAP1510 )#include <usb/omap1510_udc.h> +#elif defined(CONFIG_MUSB_UDC ) +#include <usb/musb_udc.h> #elif defined(CONFIG_PXA27X )#include <usb/pxa27x_udc.h> #endif
drivers/usb/musb/Makefile +2 -0
@@ -26,7 +26,9 @@ include $(TOPDIR)/config.mk LIB := $(obj)libusb_musb.a COBJS-$(CONFIG_MUSB_HCD) += musb_hcd.o musb_core.o +COBJS-$(CONFIG_MUSB_UDC) += musb_udc.o musb_core.o COBJS-$(CONFIG_USB_DAVINCI) += davinci.o +COBJS-$(CONFIG_USB_OMAP3) += omap3.o COBJS := $(COBJS-y) SRCS := $(COBJS:.o=.c)
drivers/usb/musb/musb_core.c +6 -2
@@ -32,7 +32,9 @@ struct musb_regs *musbr;*/ void musb_start (void ) { +#if defined(CONFIG_MUSB_HCD )u8 devctl; +#endif /* disable all interrupts */ writew (0 , &musbr->intrtxe);
@@ -74,9 +76,10 @@ void musb_configure_ep(struct musb_epinfo *epinfo, u8 cnt)/* Configure fifo size and fifo base address */ writeb (idx, &musbr->txfifosz);writew (fifoaddr >>3 , &musbr->txfifoadd); + + csr =readw (&musbr->txcsr);#if defined(CONFIG_MUSB_HCD )/* clear the data toggle bit */ - csr =readw (&musbr->txcsr);writew (csr |MUSB_TXCSR_CLRDATATOG , &musbr->txcsr);#endif /* Flush fifo if required */
@@ -87,9 +90,10 @@ void musb_configure_ep(struct musb_epinfo *epinfo, u8 cnt)/* Configure fifo size and fifo base address */ writeb (idx, &musbr->rxfifosz);writew (fifoaddr >>3 , &musbr->rxfifoadd); + + csr =readw (&musbr->rxcsr);#if defined(CONFIG_MUSB_HCD )/* clear the data toggle bit */ - csr =readw (&musbr->rxcsr);writew (csr |MUSB_RXCSR_CLRDATATOG , &musbr->rxcsr);#endif /* Flush fifo if required */
drivers/usb/musb/musb_core.h +40 -0
@@ -40,6 +40,36 @@#define MUSB_EP0_FIFOSIZE 64/* This is non-configurable */ +/* EP0 */ +struct musb_ep0_regs { +u16 reserved4; +u16 csr0; +u16 reserved5; +u16 reserved6; +u16 count0; +u8 host_type0; +u8 host_naklimit0; +u8 reserved7; +u8 reserved8; +u8 reserved9; +u8 configdata; +}; + +/* EP 1-15 */ +struct musb_epN_regs { +u16 txmaxp; +u16 txcsr; +u16 rxmaxp; +u16 rxcsr; +u16 rxcount; +u8 txtype; +u8 txinterval; +u8 rxtype; +u8 rxinterval; +u8 reserved0; +u8 fifosize; +}; +/* Mentor USB core register overlay structure */ struct musb_regs {/* common registers */
@@ -97,6 +127,16 @@ struct musb_regs {u8 rxhubaddr;u8 rxhubport; } tar[16 ]; +/* +* end point registers +* ep0 elements are valid when array index is 0 +* otherwise epN is valid +*/ +union musb_ep_regs { +struct musb_ep0_regs ep0; +struct musb_epN_regs epN; + } ep[16 ]; + } __attribute__((aligned(32)));/*
drivers/usb/musb/musb_debug.h new file +205 -0
205 lines not on this page · raw message
drivers/usb/musb/musb_udc.c new file +963 -0
963 lines not on this page · raw message
drivers/usb/musb/omap3.c new file +129 -0
129 lines not on this page · raw message
drivers/usb/musb/omap3.h new file +48 -0
48 lines not on this page · raw message
include/usb.h +2 -1
@@ -131,7 +131,8 @@ struct usb_device {#if defined(CONFIG_USB_UHCI ) || defined(CONFIG_USB_OHCI ) || \ defined(CONFIG_USB_EHCI ) || defined(CONFIG_USB_OHCI_NEW ) || \ defined(CONFIG_USB_SL811HS ) || defined(CONFIG_USB_ISP116X_HCD ) || \ - defined(CONFIG_USB_R8A66597_HCD ) || defined(CONFIG_USB_DAVINCI ) + defined(CONFIG_USB_R8A66597_HCD ) || defined(CONFIG_USB_DAVINCI ) || \ + defined(CONFIG_USB_OMAP3 )int usb_lowlevel_init (void );int usb_lowlevel_stop (void );
include/usb/musb_udc.h new file +54 -0
54 lines not on this page · raw message
Signature · 1 line
1.6.0.6
PATCH 5/8 OMAP3 zoom1 Add usbtty configuration
The primary console of zoom1 is the serial out from the jumpers accessed by removing the back panel.
A secondary console is to use the usbtty. The user can set this manually by doing
setenv stdout usbtty; setenv stdin usbtty; setenv stderr usbtty saveenv
usbtty will be usable by accessing the /dev/ttyACM0 on a linux host.
--- include/configs/omap3_zoom1.h | 16 ++++++++++++++++ 1 files changed, 16 insertions(+), 0 deletions(-)
include/configs/omap3_zoom1.h +16 -0
@@ -99,6 +99,21 @@#define CONFIG_OMAP3_MMC 1#define CONFIG_DOS_PARTITION 1 +/* USB */ +#define CONFIG_MUSB_UDC 1 +#define CONFIG_USB_OMAP3 1 +#define CONFIG_TWL4030_USB 1 + +/* USB device configuration */ +#define CONFIG_USB_DEVICE 1 +#define CONFIG_USB_TTY 1 +#define CONFIG_SYS_CONSOLE_IS_IN_ENV 1 +/* Change these to suit your needs */ +#define CONFIG_USBD_VENDORID 0x0451 +#define CONFIG_USBD_PRODUCTID 0x5678 +#define CONFIG_USBD_MANUFACTURER "Texas Instruments" +#define CONFIG_USBD_PRODUCT_NAME "Zoom1" +/* commands to include */ #include <config_cmd_default.h>
@@ -161,6 +176,7 @@#define CONFIG_EXTRA_ENV_SETTINGS \ "loadaddr=0x82000000\0" \ + "usbtty=cdc_acm\0" \ "console=ttyS2,115200n8\0" \ "videomode=1024x768 at 60,vxres=1024,vyres=768\0" \ "videospec=omapfb:vram:2M,vram:4M\0" \
Signature · 1 line
1.6.0.6
PATCH 6/8 OMAP3 beagle Add usbtty configuration
The primary console of beagle is the serial header.
A secondary console is to use the usbtty. The user can set this manually by doing
setenv stdout usbtty; setenv stdin usbtty; setenv stderr usbtty saveenv
usbtty will be usable by accessing the /dev/ttyACM0 on a linux host.
--- include/configs/omap3_beagle.h | 16 ++++++++++++++++ 1 files changed, 16 insertions(+), 0 deletions(-)
include/configs/omap3_beagle.h +16 -0
@@ -98,6 +98,21 @@#define CONFIG_OMAP3_MMC 1#define CONFIG_DOS_PARTITION 1 +/* USB */ +#define CONFIG_MUSB_UDC 1 +#define CONFIG_USB_OMAP3 1 +#define CONFIG_TWL4030_USB 1 + +/* USB device configuration */ +#define CONFIG_USB_DEVICE 1 +#define CONFIG_USB_TTY 1 +#define CONFIG_SYS_CONSOLE_IS_IN_ENV 1 +/* Change these to suit your needs */ +#define CONFIG_USBD_VENDORID 0x0451 +#define CONFIG_USBD_PRODUCTID 0x5678 +#define CONFIG_USBD_MANUFACTURER "Texas Instruments" +#define CONFIG_USBD_PRODUCT_NAME "Beagle" +/* commands to include */ #include <config_cmd_default.h>
@@ -164,6 +179,7 @@#define CONFIG_EXTRA_ENV_SETTINGS \ "loadaddr=0x82000000\0" \ + "usbtty=cdc_acm\0" \ "console=ttyS2,115200n8\0" \ "videomode=1024x768 at 60,vxres=1024,vyres=768\0" \ "videospec=omapfb:vram:2M,vram:4M\0" \
Signature · 1 line
1.6.0.6
PATCH 7/8 USBTTY make some function declarations easier to use.
Zoom2 needs to use these declarations and the include directory is a better place from them than in the middle of the driver directory. It did not make sense to create a new file for just a couple of lines so they were appended to the serial.h
--- include/serial.h | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
include/serial.h +6 -0
@@ -59,4 +59,10 @@ extern void serial_stdio_init(void);extern int serial_assign (char * name);extern void serial_reinit_all (void ); +/* For usbtty */ +extern int usbtty_getc (void ); +extern void usbtty_putc (const char c); +extern void usbtty_puts (const char *str); +extern int usbtty_tstc (void ); +#endif
Signature · 1 line
1.6.0.6
PATCH 8/8 OMAP3 zoom2 Use usbtty if the debug board is not connected.
The preferred serial output comes from the debug board. When the debug board is disconnected, fall back on using usbtty from the usb connector on the Zoom2 board.
This shows up as /dev/ttyACM0 in a linux host.
--- board/logicpd/zoom2/zoom2_serial.c | 12 ++++++++---- include/configs/omap3_zoom2.h | 17 +++++++++++++++++ include/serial.h | 12 ++++++++++++ 3 files changed, 37 insertions(+), 4 deletions(-)
board/logicpd/zoom2/zoom2_serial.c +8 -4
@@ -86,6 +86,8 @@ void quad_putc_dev (unsigned long base, const char c)quad_putc_dev (base,'\r' );NS16550_putc ((NS16550_t ) base, c); + }else { +usbtty_putc (c); } }
@@ -94,6 +96,8 @@ void quad_puts_dev (unsigned long base, const char *s)if (zoom2_debug_board_connected ()) {while ((s !=NULL ) && (*s !='\0' ))quad_putc_dev (base, *s++); + }else { +usbtty_puts (s); } }
@@ -101,16 +105,16 @@ int quad_getc_dev (unsigned long base) {if (zoom2_debug_board_connected ())return NS16550_getc ((NS16550_t ) base); -else -return 0 ; + +return usbtty_getc (); }int quad_tstc_dev (unsigned long base) {if (zoom2_debug_board_connected ())return NS16550_tstc ((NS16550_t ) base); -else -return 0 ; + +return usbtty_tstc (); }void quad_setbrg_dev (unsigned long base)
include/configs/omap3_zoom2.h +17 -0
@@ -123,6 +123,20 @@#define CONFIG_OMAP3_GPIO_3 /* board revision */ #define CONFIG_OMAP3_GPIO_5 /* debug board detection, ZOOM2_LED_BLUE */ +/* USB */ +#define CONFIG_MUSB_UDC 1 +#define CONFIG_USB_OMAP3 1 +#define CONFIG_TWL4030_USB 1 + +/* USB device configuration */ +#define CONFIG_USB_DEVICE 1 +#define CONFIG_USB_TTY 1 +/* Change these to suit your needs */ +#define CONFIG_USBD_VENDORID 0x0451 +#define CONFIG_USBD_PRODUCTID 0x5678 +#define CONFIG_USBD_MANUFACTURER "Texas Instruments" +#define CONFIG_USBD_PRODUCT_NAME "Zoom2" +/* commands to include */ #include <config_cmd_default.h>
@@ -170,6 +184,9 @@/* Environment information */ #define CONFIG_BOOTDELAY 10 +#define CONFIG_EXTRA_ENV_SETTINGS \ + "usbtty=cdc_acm\0" \ +/* * Miscellaneous configurable options */
include/serial.h +12 -0
@@ -60,9 +60,21 @@ extern int serial_assign(char * name);extern void serial_reinit_all (void );/* For usbtty */ +#ifdef CONFIG_USB_TTY +extern int usbtty_getc (void );extern void usbtty_putc (const char c);extern void usbtty_puts (const char *str);extern int usbtty_tstc (void ); +#else + +/* stubs */ +#define usbtty_getc () 0 +#define usbtty_putc (a) +#define usbtty_puts (a) +#define usbtty_tstc () 0 + +#endif /* CONFIG_USB_TTY */ +#endif
Signature · 1 line
1.6.0.6
PATCH 1/8 USB Consolidate descriptor definitions
In reply to Tom RixHi Tom,
Sorry for not responding to this series very fast, because I wanted to look into it carefully.
Below my comments on this patch
2009/9/28 Tom Rix <[email protected]>:
Quoted 10 lines
The header files
usb.handusbdescriptors.hhave the same or similarly named structure definitions for
usb_device_descriptorusb_string_descriptorusb_endpoint_descriptorusb_config_descriptorvsusb_configuration_descriptorusb_interface_descriptorThere should only be one definition of these structures.
True, I agree with that.
Quoted 4 lines
Some of these structures are element-wise duplicates, one has unused elements that can be reduced to a duplicate, and some of the the structures have additional elements.
Quoted 8 lines
These are the element-wise duplicates in
usb.h
usb_device_descriptorusb_string_descriptorFor these, the
usb.hdefinition will be removed.This definition in
usb.hhas extra unused elements
Can these be merged to one global structure?
Quoted 19 lines
usb_endpoint_descriptor? ? ? ?unsigned char ? bRefresh
? ? ? ?unsigned char ? bSynchAddress;The definition of
usb_endpoint_descriptorinusb.hwill be removed.These definitions in
usb.hhave extra elements at the end of the usb 2.0 specified descriptor:
usb_config_descriptorusb_interface_descriptorThese structures will have their name shorted by removing the '
_descriptor' suffix.So
Quoted 7 lines
usb_config_descriptor->usb_configusb_interface_descriptor->usb_interfaceThe common descriptor elements are now defined by the macros
USB_CONFIG_DESCRIPTOR_DEFINITIONUSB_INTERFACE_DESCRIPTOR_DEFINITION
Personally I do not like the macros for these kind of definitions, I would prefer a solution by nesting the structures.
What do you think?
Kind regards,
Remy
PATCH 1/8 USB Consolidate descriptor definitions
Quoted 26 lines · Remy Bohmer
Hi Tom,
Sorry for not responding to this series very fast, because I wanted to look into it carefully.
Below my comments on this patch2009/9/28 Tom Rix <[email protected]>:
Quoted 10 lines
The header files
usb.handusbdescriptors.hhave the same or similarly named structure definitions for
usb_device_descriptorusb_string_descriptorusb_endpoint_descriptorusb_config_descriptorvsusb_configuration_descriptorusb_interface_descriptorThere should only be one definition of these structures.
True, I agree with that.
Quoted 6 lines
Some of these structures are element-wise duplicates, one has unused elements that can be reduced to a duplicate, and some of the the structures have additional elements.
These are the element-wise duplicates in
usb.h
Quoted 9 lines
Quoted 6 lines
usb_device_descriptorusb_string_descriptorFor these, the
usb.hdefinition will be removed.This definition in
usb.hhas extra unused elementsCan these be merged to one global structure?
No.
The size of the structure is kept in 'bLength' field. Have bLength = sizeof(struct bla_descriptor) is the right way to go.
Quoted 22 lines
Quoted 22 lines
usb_endpoint_descriptorunsigned char bRefresh
unsigned char bSynchAddress;The definition of
usb_endpoint_descriptorinusb.hwill be removed.These definitions in
usb.hhave extra elements at the end of the usb 2.0 specified descriptor:
usb_config_descriptorusb_interface_descriptorThese structures will have their name shorted by removing the '
_descriptor' suffix.So
usb_config_descriptor->usb_configusb_interface_descriptor->usb_interface
Quoted 8 lines
Quoted 4 lines
The common descriptor elements are now defined by the macros
USB_CONFIG_DESCRIPTOR_DEFINITIONUSB_INTERFACE_DESCRIPTOR_DEFINITIONPersonally I do not like the macros for these kind of definitions, I would prefer a solution by nesting the structures.
What do you think?
I have an early version of this patch that does use nested structures. After looking at the added '.desc.' that caused a good number of
changes in the c files, I went with the macro approach. It seemed like
the lesser of the evils as the changes seemed smaller and were limited to the h files. What I really wanted to do was to use nameless structures but had a problem getting them to work with gcc.
I do not mind reverting to the '.desc.' solution.
I will resend the patches when I have had a chance to test them.
Thanks
Tom
Quoted 10 lines
Kind regards,
Remy
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
Paulraj
Quoted 32 lines
The technical change is better handling of address setting on the usb handshaking setup phase.
Other changes from Jean's comments
2/8 USB add macros for debugging usb device setup.
static inline function replacing debug macros
3/8 TWL4030 Add usb PHY support
add empty lines between variables and statements
other empty lines added for readablity4/8 OMAP3 Add usb device support
80+ char lines reduced
UsedMUSB_FLAGS_PRINTmacro suggestion
lowercased function names
multi-linedep0_state_enum
Used suggestion on udelay to 1000 * 1000
add empty lines between variables and statements
inverted check ofep0_urb->device_request.wLength
other empty lines added for readablity5/8 OMAP3 zoom1 Add usbtty configuration
This was ack-ed by Jean
Quoted 7 lines
6/8 OMAP3 beagle Add usbtty configuration
This was ack-ed by Jean
8/8 OMAP3 zoom2 Use usbtty if the debug board
cleanup using usbtty_* functions or their stubs without #define's
Tom,
Some of these clearly say that they were Ack-ed by Jean.
Did he not push them?
How do we want to proceed with this set of patches?
Thanks,
Sandeep
Quoted 36 lines · Sandeep
Quoted 36 lines
The technical change is better handling of address setting on the usb handshaking setup phase.
Other changes from Jean's comments
2/8 USB add macros for debugging usb device setup.
static inline function replacing debug macros
3/8 TWL4030 Add usb PHY support
add empty lines between variables and statements
other empty lines added for readablity4/8 OMAP3 Add usb device support
80+ char lines reduced
UsedMUSB_FLAGS_PRINTmacro suggestion
lowercased function names
multi-linedep0_state_enum
Used suggestion on udelay to 1000 * 1000
add empty lines between variables and statements
inverted check ofep0_urb->device_request.wLength
other empty lines added for readablity5/8 OMAP3 zoom1 Add usbtty configuration
This was ack-ed by Jean
6/8 OMAP3 beagle Add usbtty configuration
This was ack-ed by Jean
8/8 OMAP3 zoom2 Use usbtty if the debug board
Quoted 8 lines
Quoted 1 line
cleanup using usbtty_* functions or their stubs without #define's
Tom,
Some of these clearly say that they were Ack-ed by Jean.
Did he not push them?
Because there were issues with other patches in the patch-set, these were not pushed.
Quoted 2 lines
How do we want to proceed with this set of patches?
There is some changes that may effect davinci. You should verify that davici targets behave the same.
I believe someone on beagle.org has verified that at least the usb console works for beagle. There was an issue with kermit over usbtty that was reported. I do not consider this to be a blocking issue. More verification that the patch works for other poeople would be helpful.
The top usb patch is general and should really be reviewed as a USB change.
These patches are the basis for my current usb development to get the cdc gadget support from the usb topic branch into the mainline.
So if changes are needed, it would be good to find out about them sooner rather than later when I have more code dependent on them.
Tom
Quoted 5 lines
Thanks,
Sandeep