Subject: [PATCH omap3-dev-usb] OMAP3: Clean up coding style From: Dirk Behme Clean up coding style: * Rename OMAP3530 -> OMAP3 * 80 chars limit * Reformat some comments * Use printf instead serial_printf * Replace spaces by tabs * Update copyright No functional change. Signed-off-by: Dirk Behme --- Note: I'd like to rename omap3530_usb.c to omap3_usb.c and omap3530_usb.h to omap3_usb.h, too. This would be easier in git than with a patch, no? If this is done by git, following files have to be touched, too: * drivers/usb/Makefile: omap3530_usb.o -> omap3_usb.o * drivers/usb/omap3_usb.c: #include "omap3530_usb.h" -> "omap3_usb.h" drivers/usb/Makefile | 2 drivers/usb/omap3530_usb.c | 15 - drivers/usb/omap3530_usb.h | 35 ++-- drivers/usb/twl4030_usb.c | 70 ++++---- drivers/usb/usbdcore_musb.c | 320 +++++++++++++++++++++++------------------ include/configs/omap3_beagle.h | 8 - include/configs/omap3_evm.h | 4 include/usb.h | 2 include/usbdcore_musb.h | 63 +++----- 9 files changed, 281 insertions(+), 238 deletions(-) Index: u-boot-steve-omap3/drivers/usb/omap3530_usb.c =================================================================== --- u-boot-steve-omap3.orig/drivers/usb/omap3530_usb.c +++ u-boot-steve-omap3/drivers/usb/omap3530_usb.c @@ -1,7 +1,7 @@ /* - * TI's OMAP3530 platform specific USB functions. + * TI's OMAP3 platform specific USB functions. * - * Copyright (c) 2008 Texas Instruments + * Copyright (c) 2009 Texas Instruments * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -31,20 +31,20 @@ /* MUSB platform configuration */ struct musb_config musb_cfg = { (struct musb_regs *)MENTOR_USB0_BASE, - OMAP3530_USB_TIMEOUT, + OMAP3_USB_TIMEOUT, 0 }; /* MUSB module register overlay */ -struct omap3530_usb_regs *regs; +struct omap3_usb_regs *regs; /* - * This function performs OMAP3530 platform specific initialization for Mentor + * This function performs OMAP3 platform specific initialization for Mentor * USB OTG controller. */ int musb_platform_init(void) { - regs = (struct omap3530_usb_regs *)OMAP3530_USB0_BASE; + regs = (struct omap3_usb_regs *)OMAP3_USB0_BASE; /* Disable force standby */ sr32((void *)®s->forcestdby, 0 , 1 , 0); /* Set configuration for clock and interface clock to be always on */ @@ -55,7 +55,7 @@ int musb_platform_init(void) } /* - * This function performs OMAP3530 platform specific deinitialization for + * This function performs OMAP3 platform specific deinitialization for * Mentor USB OTG controller. */ void musb_platform_deinit(void) @@ -63,4 +63,3 @@ void musb_platform_deinit(void) /* MUSB soft-reset */ writel(2, ®s->sysconfig); } - Index: u-boot-steve-omap3/drivers/usb/omap3530_usb.h =================================================================== --- u-boot-steve-omap3.orig/drivers/usb/omap3530_usb.h +++ u-boot-steve-omap3/drivers/usb/omap3530_usb.h @@ -1,7 +1,7 @@ /* - * TI's OMAP3530 platform specific USB functions. + * TI's OMAP3 platform specific USB functions. * - * Copyright (c) 2008 Texas Instruments + * Copyright (c) 2009 Texas Instruments * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -21,29 +21,28 @@ * Author: Thomas Abraham t-abraham@ti.com, Texas Instruments */ -#ifndef __OMAP3530_MUSB_H__ -#define __OMAP3530_MUSB_H__ +#ifndef __OMAP3_MUSB_H__ +#define __OMAP3_MUSB_H__ #include "musb_core.h" -/* Base address of OMAP3530 usb0 wrapper */ -#define OMAP3530_USB0_BASE 0x480AB400 -/* Base address of OMAP3530 musb core */ +/* Base address of OMAP3 usb0 wrapper */ +#define OMAP3_USB0_BASE 0x480AB400 +/* Base address of OMAP3 musb core */ #define MENTOR_USB0_BASE 0x480AB000 -/* Timeout for OMAP3530 USB module */ -#define OMAP3530_USB_TIMEOUT 0x3FFFFFF +/* Timeout for OMAP3 USB module */ +#define OMAP3_USB_TIMEOUT 0x3FFFFFF /* - * OMAP3530 platform USB register overlay. + * OMAP3 platform USB register overlay. */ -struct omap3530_usb_regs { - u32 revision; - u32 sysconfig; - u32 sysstatus; - u32 interfsel; - u32 simenable; +struct omap3_usb_regs { + u32 revision; + u32 sysconfig; + u32 sysstatus; + u32 interfsel; + u32 simenable; u32 forcestdby; }; -#endif /* __OMAP3530_MUSB_H__ */ - +#endif /* __OMAP3_MUSB_H__ */ Index: u-boot-steve-omap3/drivers/usb/twl4030_usb.c =================================================================== --- u-boot-steve-omap3.orig/drivers/usb/twl4030_usb.c +++ u-boot-steve-omap3/drivers/usb/twl4030_usb.c @@ -1,7 +1,7 @@ /* * twl4030_usb - TWL4030 USB transceiver, talking to OMAP OTG controller * - * (C) Copyright 2008 Atin Malaviya (atin.malaviya@gmail.com) + * (C) Copyright 2009 Atin Malaviya (atin.malaviya@gmail.com) * * Based on: twl4030_usb.c in linux 2.6 (drivers/i2c/chips/twl4030_usb.c) * Copyright (C) 2004-2007 Texas Instruments @@ -22,7 +22,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ @@ -30,28 +30,29 @@ #include #define FUNC_CTRL (0x04) -# define OPMODE_MASK (3 << 3) /* bits 3 and 4 */ -# define XCVRSELECT_MASK (3 << 0) /* bits 0 and 1 */ -#define IFC_CTRL (0x07) -# define CARKITMODE (1 << 2) +#define OPMODE_MASK (3 << 3) /* bits 3 and 4 */ +#define XCVRSELECT_MASK (3 << 0) /* bits 0 and 1 */ +#define IFC_CTRL (0x07) +#define CARKITMODE (1 << 2) #define POWER_CTRL (0xAC) -# define OTG_ENAB (1 << 5) +#define OTG_ENAB (1 << 5) #define PHY_PWR_CTRL (0xFD) -# define PHYPWD (1 << 0) +#define PHYPWD (1 << 0) #define PHY_CLK_CTRL (0xFE) -# define CLOCKGATING_EN (1 << 2) -# define CLK32K_EN (1 << 1) -# define REQ_PHY_DPLL_CLK (1 << 0) +#define CLOCKGATING_EN (1 << 2) +#define CLK32K_EN (1 << 1) +#define REQ_PHY_DPLL_CLK (1 << 0) #define PHY_CLK_CTRL_STS (0xFF) -# define PHY_DPLL_CLK (1 << 0) +#define PHY_DPLL_CLK (1 << 0) static int twl4030_i2c_write(u8 group, u8 reg, u8 data) { int ret = 0; ret = i2c_write(group, reg, 1, &data, 1); - if (ret != 0) { - serial_printf("TWL4030:I2C:Write[0x%x, 0x%x] Error %d\n", group, reg, ret); - } + if (ret != 0) + printf("TWL4030:I2C:Write[0x%x, 0x%x] Error %d\n", + group, reg, ret); + return ret; } @@ -59,9 +60,10 @@ static int twl4030_i2c_read(u8 group, u8 { int ret = 0; ret = i2c_read(group, reg, 1, data, 1); - if (ret != 0) { - serial_printf("TWL4030:I2C:Read[0x%x, 0x%x] Error %d\n", group, reg, ret); - } + if (ret != 0) + printf("TWL4030:I2C:Read[0x%x, 0x%x] Error %d\n", + group, reg, ret); + return ret; } @@ -69,9 +71,9 @@ static int twl4030_usb_write(u8 address, { int ret = 0; ret = twl4030_i2c_write(PWRMGT_ADDR_ID1, address, data); - if (ret != 0) { - serial_printf("TWL4030:USB:Write[0x%x] Error %d\n", address, ret); - } + if (ret != 0) + printf("TWL4030:USB:Write[0x%x] Error %d\n", address, ret); + return ret; } @@ -80,11 +82,11 @@ static int twl4030_usb_read(u8 address) u8 data; int ret = 0; ret = twl4030_i2c_read(PWRMGT_ADDR_ID1, address, &data); - if (ret == 0) { + if (ret == 0) ret = data; - } else { - serial_printf("TWL4030:USB:Read[0x%x] Error %d\n", address, ret); - } + else + printf("TWL4030:USB:Read[0x%x] Error %d\n", address, ret); + return ret; } @@ -133,9 +135,8 @@ static void twl4030_phy_power(void) pwr = twl4030_usb_read(PHY_PWR_CTRL); pwr &= ~PHYPWD; twl4030_usb_write(PHY_PWR_CTRL, pwr); - twl4030_usb_write(PHY_CLK_CTRL, - twl4030_usb_read(PHY_CLK_CTRL) | - (CLOCKGATING_EN | CLK32K_EN)); + twl4030_usb_write(PHY_CLK_CTRL, twl4030_usb_read(PHY_CLK_CTRL) | + (CLOCKGATING_EN | CLK32K_EN)); } int udc_musb_platform_init(void) @@ -149,21 +150,24 @@ int udc_musb_platform_init(void) twl4030_phy_power(); /* enable DPLL to access PHY registers over I2C */ - twl4030_usb_write(PHY_CLK_CTRL,twl4030_usb_read(PHY_CLK_CTRL) | REQ_PHY_DPLL_CLK); + twl4030_usb_write(PHY_CLK_CTRL, twl4030_usb_read(PHY_CLK_CTRL) | + REQ_PHY_DPLL_CLK); timeout = get_timer(0) + CONFIG_SYS_HZ; - while (!(twl4030_usb_read(PHY_CLK_CTRL_STS) & PHY_DPLL_CLK) && get_timer(0) < timeout) { + while (!(twl4030_usb_read(PHY_CLK_CTRL_STS) & PHY_DPLL_CLK) && + get_timer(0) < timeout) { udelay(10); } if (!(twl4030_usb_read(PHY_CLK_CTRL_STS) & PHY_DPLL_CLK)) { - serial_printf("Timeout setting T2 HSUSB PHY DPLL clock\n"); + printf("Timeout setting T2 HSUSB PHY DPLL clock\n"); return -1; } /* Enable ULPI mode */ twl4030_usb_clear_bits(IFC_CTRL, CARKITMODE); twl4030_usb_set_bits(POWER_CTRL, OTG_ENAB); - twl4030_usb_clear_bits(FUNC_CTRL,XCVRSELECT_MASK | OPMODE_MASK); + twl4030_usb_clear_bits(FUNC_CTRL, XCVRSELECT_MASK | OPMODE_MASK); /* let ULPI control the DPLL clock */ - twl4030_usb_write(PHY_CLK_CTRL,twl4030_usb_read(PHY_CLK_CTRL) & ~REQ_PHY_DPLL_CLK); + twl4030_usb_write(PHY_CLK_CTRL, twl4030_usb_read(PHY_CLK_CTRL) & + ~REQ_PHY_DPLL_CLK); return 0; } Index: u-boot-steve-omap3/drivers/usb/usbdcore_musb.c =================================================================== --- u-boot-steve-omap3.orig/drivers/usb/usbdcore_musb.c +++ u-boot-steve-omap3/drivers/usb/usbdcore_musb.c @@ -1,12 +1,12 @@ /* - * (C) Copyright 2008 Texas Instruments Incorporated. + * (C) Copyright 2009 Texas Instruments Incorporated. * * Based on * u-boot OMAP1510 USB drivers (drivers/usbdcore_omap1510.c) * twl4030 init based on linux (drivers/i2c/chips/twl4030_usb.c) * - * Author: Diego Dompe (diego.dompe@ridgerun.com) - * Atin Malaviya (atin.malaviya@gmail.com) + * Author: Diego Dompe (diego.dompe@ridgerun.com) + * Atin Malaviya (atin.malaviya@gmail.com) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -15,13 +15,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include @@ -44,17 +43,15 @@ static unsigned char do_set_address = 0; static struct urb *ep0_urb = NULL; /* Helper functions */ -/** TODO: Should these go in include/usbdcore.h?? */ -static void insl(u32 reg, u32 * data, u32 size) +static void insl(u32 reg, u32 *data, u32 size) { u32 t; - for (t = 0; t < size; t++, data++){ + for (t = 0; t < size; t++, data++) *data = inl(reg); - } } -static void outsl(u32 reg, u32 * data, u32 size) +static void outsl(u32 reg, u32 *data, u32 size) { u32 t; @@ -62,7 +59,7 @@ static void outsl(u32 reg, u32 * data, u outl(*data, reg); } -static void outsb(u32 reg, u8 * data, u32 size) +static void outsb(u32 reg, u8 *data, u32 size) { u32 t; @@ -70,14 +67,14 @@ static void outsb(u32 reg, u8 * data, u3 outb(*data, reg); } -static void musb_fifo_read(int epnumber, u8 * data, u32 size) +static void musb_fifo_read(int epnumber, u8 *data, u32 size) { - if ((u32)data & 0x3) { /* Not aligned data */ + if ((u32)data & 0x3) { /* Not aligned data */ insb((UDC_FIFO0 + (epnumber << 2)), data, size); - } else { /* 32 bits aligned data */ + } else { /* 32 bits aligned data */ int i; - insl(UDC_FIFO0 + (epnumber << 2),(u32 *)data,size>>2); + insl(UDC_FIFO0 + (epnumber << 2), (u32 *)data, size >> 2); data += size & ~0x3; i = size & 0x3; while (i--) { @@ -87,14 +84,14 @@ static void musb_fifo_read(int epnumber, } } -static void musb_fifo_write(int epnumber, u8 * data, u32 size) +static void musb_fifo_write(int epnumber, u8 *data, u32 size) { - if ((u32)data & 0x3) { /* Not aligned data */ + if ((u32)data & 0x3) { /* Not aligned data */ outsb(UDC_FIFO0 + (epnumber << 2), data, size); - } else { /* 32 bits aligned data */ + } else { /* 32 bits aligned data */ int i; - outsl(UDC_FIFO0 + (epnumber << 2), (u32 *)data, size>>2); + outsl(UDC_FIFO0 + (epnumber << 2), (u32 *)data, size >> 2); data += size & ~0x3; i = size & 0x3; while (i--) { @@ -155,8 +152,8 @@ static void musb_fifos_configure(struct ep_size = 6; break; default: - serial_printf("ep 0x%02x has bad packet size %d", - ep_addr, packet_size); + printf("ep 0x%02x has bad packet size %d", + ep_addr, packet_size); packet_size = 0; ep_size = 0; break; @@ -190,8 +187,8 @@ static void musb_fifos_configure(struct /* check to see if our packet buffer RAM is exhausted */ if ((ep_ptr + buffer_size) > UDC_MAX_FIFO_SIZE) { - serial_printf("out of packet RAM for ep 0x%02x buf size %d", - ep_addr, buffer_size); + printf("out of packet RAM for ep 0x%02x buf size %d", + ep_addr, buffer_size); buffer_size = packet_size = 0; } @@ -206,16 +203,18 @@ static void musb_fifos_configure(struct outb(ep & 0xF, UDC_INDEX); if ((ep_addr & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN) { /* IN endpoint */ - outb((ep_doublebuffer << 4) | (ep_size & 0xf), UDC_TXFIFOSZ); + outb((ep_doublebuffer << 4) | (ep_size & 0xf), + UDC_TXFIFOSZ); outw(ep_ptr >> 3, UDC_TXFIFOADDR); - if (!ep) { /* This only apply for ep != 0 */ + if (!ep) { /* This only apply for ep != 0 */ outw(packet_size & 0x3FF, UDC_TXMAXP); } } else { /* OUT endpoint */ - outb((ep_doublebuffer << 4) | (ep_size & 0xf), UDC_RXFIFOSZ); + outb((ep_doublebuffer << 4) | (ep_size & 0xf), + UDC_RXFIFOSZ); outw(ep_ptr >> 3, UDC_RXFIFOADDR); - if (!ep) { /* This only apply for ep != 0 */ + if (!ep) { /* This only apply for ep != 0 */ outw(packet_size & 0x3FF, UDC_RXMAXP); } } @@ -233,17 +232,18 @@ static void musb_ep0_tx(struct usb_endpo if (urb) { if ((size = - MIN(urb->actual_length - endpoint->sent, - endpoint->tx_packetSize))) { + MIN(urb->actual_length - endpoint->sent, + endpoint->tx_packetSize))) { - musb_fifo_write(0,urb->buffer + endpoint->sent,size); + musb_fifo_write(0, urb->buffer + endpoint->sent, size); } endpoint->last = size; if (((endpoint->sent + size) == ep0_urb->device_request.wLength) - || (size != endpoint->tx_packetSize)) { + || (size != endpoint->tx_packetSize)) { ep0status = DATA_COMPLETE; - outw(0xA, UDC_CSR0); /* Transmit packet and set dataend */ + /* Transmit packet and set data end */ + outw(0xA, UDC_CSR0); } else { outw(0x2, UDC_CSR0); /* Transmit packet */ } @@ -259,15 +259,15 @@ static void musb_ep0_handler(struct usb_ /* Check errors */ csr0 = inw(UDC_CSR0); - if (csr0 & 0x4) { /* SENTSTALL */ - outw(csr0 & ~0x4, UDC_CSR0); // Clear stall - serial_printf("%s: stall received on EP0!\n", __FUNCTION__); + if (csr0 & 0x4) { /* Sent stall */ + outw(csr0 & ~0x4, UDC_CSR0); /* Clear stall */ + printf("%s: stall received on EP0!\n", __FUNCTION__); } - if (csr0 & 0x10) { /* SETUPEND */ - outw(0x80, UDC_CSR0); /* Clear setupend */ - serial_printf("%s: setup END early happened! status is %d\n", - __FUNCTION__, ep0status); + if (csr0 & 0x10) { /* Setup end */ + outw(0x80, UDC_CSR0); /* Clear setup end */ + printf("%s: setup END early happened! status is %d\n", + __FUNCTION__, ep0status); ep0status = IDLE; return; } @@ -275,8 +275,10 @@ static void musb_ep0_handler(struct usb_ switch (ep0status) { case DATA_COMPLETE: if (do_set_address) { - /* We need to set the address only after - the status stage is complete */ + /* + * We need to set the address only after + * the status stage is complete + */ outb(udc_device->address, UDC_FADDR); do_set_address = 0; } @@ -284,28 +286,33 @@ static void musb_ep0_handler(struct usb_ /* Fallthrough */ case IDLE: /* Receiving a setup packet */ if (csr0 & 0x1) { - insl(UDC_FIFO0, (unsigned int *) &ep0_urb->device_request, - 2); + insl(UDC_FIFO0, + (unsigned int *) &ep0_urb->device_request, 2); /* If we have data, then don't go to IDLE state */ if (ep0_urb->device_request.wLength) { ep0status = DATA_STAGE; - outw(0x40, UDC_CSR0); // Clear RXPKTRDY + outw(0x40, UDC_CSR0); /* Clear RXPKTRDY */ if ((ep0_urb->device_request. - bmRequestType & USB_REQ_DIRECTION_MASK) - == USB_REQ_DEVICE2HOST) { + bmRequestType & USB_REQ_DIRECTION_MASK) + == USB_REQ_DEVICE2HOST) { /* Try to process setup packet */ if (ep0_recv_setup(ep0_urb)) { - /* Not a setup packet, stall next EP0 transaction */ + /* + * Not a setup packet, stall + * next EP0 transaction + */ outw(0x20, UDC_CSR0); ep0status = IDLE; return; } - /* If we are sending data, do it now, as - ep0_recv_setup should have prepare them - */ + /* + * If we are sending data, do it now, as + * ep0_recv_setup should have prepare + * them + */ endpoint->tx_urb = ep0_urb; endpoint->sent = 0; @@ -316,23 +323,32 @@ static void musb_ep0_handler(struct usb_ } } else { /* Processing zero-length packet */ /* - * The www.linux-usb.org/usbtest 'test 14' fails with error for zero - * length request. If the SETUP packet requests ZERO length data from - * device-to-host, the TXPKTRDY bit needs to be set in TXCSR otherwise - * the STATUS stage of control transfer will never complete. - * + * The www.linux-usb.org/usbtest 'test 14' + * fails with error for zero length request. + * If the SETUP packet requests ZERO length data + * from device-to-host, the TXPKTRDY bit needs + * to be set in TXCSR otherwise the STATUS stage + * of control transfer will never complete. */ if ((ep0_urb->device_request. - bmRequestType & USB_REQ_DIRECTION_MASK) - == USB_REQ_DEVICE2HOST) { - outw(0x4A, UDC_CSR0); // Clear RXPKTRDY and DATAEND and TXPKTRDY + bmRequestType & USB_REQ_DIRECTION_MASK) + == USB_REQ_DEVICE2HOST) { + /* + * Clear RXPKTRDY and DATAEND and + * TXPKTRDY + */ + outw(0x4A, UDC_CSR0); } else { - outw(0x48, UDC_CSR0); // Clear RXPKTRDY and DATAEND + /* Clear RXPKTRDY and DATAEND */ + outw(0x48, UDC_CSR0); } /* Try to process setup packet */ if (ep0_recv_setup(ep0_urb)) { - /* Not a setup packet, stall next EP0 transaction */ + /* + * Not a setup packet, stall next EP0 + * transaction + */ outw(0x20, UDC_CSR0); ep0status = IDLE; return; @@ -341,13 +357,12 @@ static void musb_ep0_handler(struct usb_ switch (ep0_urb->device_request.bRequest) { case USB_REQ_SET_ADDRESS: usbd_device_event_irq(udc_device, - DEVICE_ADDRESS_ASSIGNED, - 0); + DEVICE_ADDRESS_ASSIGNED, 0); do_set_address = 1; break; case USB_REQ_SET_CONFIGURATION: usbd_device_event_irq(udc_device, - DEVICE_CONFIGURED, 0); + DEVICE_CONFIGURED, 0); break; } @@ -357,12 +372,14 @@ static void musb_ep0_handler(struct usb_ break; case DATA_STAGE: if ((ep0_urb->device_request. - bmRequestType & USB_REQ_DIRECTION_MASK) - == USB_REQ_DEVICE2HOST) { - if (!(csr0 & 0x2)) { // There packet was send? + bmRequestType & USB_REQ_DIRECTION_MASK) + == USB_REQ_DEVICE2HOST) { + if (!(csr0 & 0x2)) { /* There packet was send? */ endpoint->sent += endpoint->last; - - /* If we finished sending data we would not be on the DATA_STAGE */ + /* + * If we finished sending data we would not + * be on the DATA_STAGE + */ musb_ep0_tx(endpoint); } } else { @@ -371,32 +388,39 @@ static void musb_ep0_handler(struct usb_ if (length) { if (ep0_urb->actual_length + length > - ep0_urb->device_request.wLength) + ep0_urb->device_request.wLength) length = - ep0_urb->device_request.wLength - - ep0_urb->actual_length; + ep0_urb->device_request.wLength - + ep0_urb->actual_length; endpoint->last = length; - musb_fifo_read(0,&ep0_urb->buffer[ep0_urb->actual_length],length); + musb_fifo_read(0, &ep0_urb-> + buffer[ep0_urb->actual_length], length); ep0_urb->actual_length += length; } - /* We finish if we received the amount of data expected, or less - of the packet size - */ - if ((ep0_urb->actual_length == ep0_urb->device_request.wLength) || - (endpoint->last != endpoint->tx_packetSize)) { + /* + * We finish if we received the amount of data expected, + * or less of the packet size + */ + if ((ep0_urb->actual_length == + ep0_urb->device_request.wLength) || + (endpoint->last != endpoint->tx_packetSize)) { ep0status = DATA_COMPLETE; - outw(0x48, UDC_CSR0); // Clear RXPKTRDY and DATAEND + /* Clear RXPKTRDY and DATAEND */ + outw(0x48, UDC_CSR0); /* This will process the incoming data */ if (ep0_recv_setup(ep0_urb)) { - /* Not a setup packet, stall next EP0 transaction */ + /* + * Not a setup packet, stall next EP0 + * transaction + */ outw(0x20, UDC_CSR0); return; } } else - outw(0x40, UDC_CSR0); // Clear RXPKTRDY + outw(0x40, UDC_CSR0); /* Clear RXPKTRDY */ } break; } @@ -411,14 +435,15 @@ static void musb_ep_tx(struct usb_endpoi outb(epnumber, UDC_INDEX); if (urb) { if ((size = - MIN(urb->actual_length - endpoint->sent, - endpoint->tx_packetSize))) { - musb_fifo_write(epnumber,urb->buffer + endpoint->sent,size); + MIN(urb->actual_length - endpoint->sent, + endpoint->tx_packetSize))) { + musb_fifo_write(epnumber, urb->buffer + endpoint->sent, + size); } endpoint->last = size; endpoint->state = 1; /* Transmit hardware is busy */ - outw(inw(UDC_TXCSR) | 0x1, UDC_TXCSR); // Transmit packet + outw(inw(UDC_TXCSR) | 0x1, UDC_TXCSR); /* Transmit packet */ } } @@ -442,21 +467,24 @@ static void musb_tx_handler(struct usb_e return; } - if (endpoint->tx_urb && !(txcsr & 0x1)) { // The packet was send? - if ((endpoint->sent+endpoint->last == endpoint->tx_urb->actual_length) /* Send a zero length packet? */ - && (endpoint->last == endpoint->tx_packetSize)) { + if (endpoint->tx_urb && !(txcsr & 0x1)) { /* The packet was send? */ + if ((endpoint->sent + endpoint->last == endpoint->tx_urb-> + actual_length) /* Send a zero length packet? */ + && (endpoint->last == endpoint->tx_packetSize)) { /* Prepare to transmit a zero-length packet. */ endpoint->sent += endpoint->last; musb_ep_tx(endpoint); } else if (endpoint->tx_urb->actual_length) { /* retire the data that was just sent */ - usbd_tx_complete (endpoint); + usbd_tx_complete(endpoint); endpoint->state = 0; /* Transmit hardware is free */ - /* Check to see if we have more data ready to transmit + /* + * Check to see if we have more data ready to transmit * now. */ - if (endpoint->tx_urb && endpoint->tx_urb->actual_length) { + if (endpoint->tx_urb && endpoint->tx_urb-> + actual_length) { musb_ep_tx(endpoint); } } @@ -486,13 +514,14 @@ static void musb_rx_handler(struct usb_e if (endpoint->rcv_urb) { /* Receiving data */ if (length) { - musb_fifo_read(epnumber,&endpoint->rcv_urb->buffer[endpoint->rcv_urb->actual_length],length); - + musb_fifo_read(epnumber, &endpoint->rcv_urb-> + buffer[endpoint->rcv_urb->actual_length], + length); outw(rxcsr & ~0x1, UDC_RXCSR); /* Clear RXPKTRDY */ usbd_rcv_complete(endpoint, length, 0); } } else { - serial_printf("%s: no receive URB!\n", __FUNCTION__); + printf("%s: no receive URB!\n", __FUNCTION__); } } @@ -521,9 +550,11 @@ void udc_irq(void) usbd_device_event_irq(udc_device, DEVICE_HUB_RESET, 0); } if (int_usb & 0x1) - usbd_device_event_irq (udc_device, DEVICE_BUS_INACTIVE, 0); + usbd_device_event_irq(udc_device, + DEVICE_BUS_INACTIVE, 0); if (int_usb & 0x2) - usbd_device_event_irq (udc_device, DEVICE_BUS_ACTIVITY, 0); + usbd_device_event_irq(udc_device, + DEVICE_BUS_ACTIVITY, 0); } /* Note: IRQ values auto clear so read just before processing */ @@ -531,9 +562,9 @@ void udc_irq(void) ep = 1; int_rx >>= 1; while (int_rx) { - if (int_rx & 1) { - musb_rx_handler(udc_device->bus->endpoint_array + ep); - } + if (int_rx & 1) + musb_rx_handler(udc_device->bus->endpoint_array + + ep); int_rx >>= 1; ep++; } @@ -545,9 +576,9 @@ void udc_irq(void) ep = 1; int_tx >>= 1; while (int_tx) { - if (int_tx & 1) { - musb_tx_handler(udc_device->bus->endpoint_array + ep); - } + if (int_tx & 1) + musb_tx_handler(udc_device->bus->endpoint_array + + ep); int_tx >>= 1; ep++; } @@ -560,7 +591,7 @@ void udc_connect(void) outb(0x1, UDC_DEVCTL); if (!(inb(UDC_DEVCTL) & 0x80)) { - serial_printf("Error, the USB hardware is not on B mode\n"); + printf("Error, the USB hardware is not on B mode\n"); outb(0x0, UDC_DEVCTL); return; } @@ -570,7 +601,7 @@ void udc_connect(void) void udc_disconnect(void) { if (!(inb(UDC_DEVCTL) & 0x80)) { - serial_printf("Error, the USB hardware is not on B mode"); + printf("Error, the USB hardware is not on B mode"); return; } @@ -580,9 +611,9 @@ void udc_disconnect(void) int udc_endpoint_write(struct usb_endpoint_instance *endpoint) { /* Transmit only if the hardware is available */ - if (endpoint->tx_urb && endpoint->state == 0) { + if (endpoint->tx_urb && endpoint->state == 0) musb_ep_tx(endpoint); - } + return 0; } @@ -592,13 +623,15 @@ int udc_endpoint_write(struct usb_endpoi * Associate a physical endpoint with endpoint_instance */ void udc_setup_ep(struct usb_device_instance *device, unsigned int ep, - struct usb_endpoint_instance *endpoint) + struct usb_endpoint_instance *endpoint) { int ep_addr; int attributes; - /* We dont' have a way to identify if the endpoint definitions changed, - so we have to always reconfigure the FIFOs to avoid problems */ + /* + * We dont' have a way to identify if the endpoint definitions changed, + * so we have to always reconfigure the FIFOs to avoid problems + */ musb_fifos_configure(device); ep_addr = endpoint->endpoint_address; @@ -615,13 +648,15 @@ void udc_setup_ep(struct usb_device_inst /* IN endpoint */ if (!ep) { /* This only apply for ep != 0 */ /* Empty fifo twice on case of previous double buffer */ - outw(1<<3,UDC_TXCSR); - outw(1<<3,UDC_TXCSR); + outw(1<<3, UDC_TXCSR); + outw(1<<3, UDC_TXCSR); if (attributes & USB_ENDPOINT_XFER_ISOC) - outw(inw(UDC_TXCSR) | (1 << 13) | (1 << 14) | 0x4, UDC_TXCSR); + outw(inw(UDC_TXCSR) | (1 << 13) | (1 << 14) | + 0x4, UDC_TXCSR); else - outw((inw(UDC_TXCSR) | (1 << 13) | 0x4) & ~(1 << 14), UDC_TXCSR); + outw((inw(UDC_TXCSR) | (1 << 13) | 0x4) & + ~(1 << 14), UDC_TXCSR); } /* Enable interrupt */ outw(inw(UDC_INTRTXE) | (1 << ep), UDC_INTRTXE); @@ -629,9 +664,11 @@ void udc_setup_ep(struct usb_device_inst /* OUT endpoint */ if (!ep) { /* This only apply for ep != 0 */ if (attributes & USB_ENDPOINT_XFER_ISOC) - outw((inw(UDC_RXCSR) | (1 << 14)) & ~(1 << 13), UDC_RXCSR); + outw((inw(UDC_RXCSR) | (1 << 14)) & ~(1 << 13), + UDC_RXCSR); else - outw(inw(UDC_RXCSR) & ~(1 << 14) & ~(1 << 13), UDC_RXCSR); + outw(inw(UDC_RXCSR) & ~(1 << 14) & ~(1 << 13), + UDC_RXCSR); } /* Enable interrupt */ outw(inw(UDC_INTRRXE) | (1 << ep), UDC_INTRRXE); @@ -646,12 +683,14 @@ void udc_startup_events(struct usb_devic /* The DEVICE_INIT event puts the USB device in the state STATE_INIT. */ usbd_device_event_irq(device, DEVICE_INIT, 0); - /* The DEVICE_CREATE event puts the USB device in the state + /* + * The DEVICE_CREATE event puts the USB device in the state * STATE_ATTACHED. */ usbd_device_event_irq(device, DEVICE_CREATE, 0); - /* Some USB controller driver implementations signal + /* + * Some USB controller driver implementations signal * DEVICE_HUB_CONFIGURED and DEVICE_RESET events here. * DEVICE_HUB_CONFIGURED causes a transition to the state STATE_POWERED, * and DEVICE_RESET causes a transition to the state STATE_DEFAULT. @@ -666,10 +705,10 @@ void udc_startup_events(struct usb_devic /* Setup ep0 urb */ if (!ep0_urb) { ep0_urb = - usbd_alloc_urb(udc_device, udc_device->bus->endpoint_array); + usbd_alloc_urb(udc_device, udc_device->bus-> + endpoint_array); } else { - serial_printf("udc_enable: ep0_urb already allocated %p\n", - ep0_urb); + printf("udc_enable: ep0_urb already allocated %p\n", ep0_urb); } /* Enable control interrupts */ @@ -678,18 +717,20 @@ void udc_startup_events(struct usb_devic void udc_set_nak(int epid) { -/* On MUSB the NAKing is controlled by the USB controller buffers, - so as long as we don't read data from the FIFO, the controller will NAK. - Nothing to see here, move along... -*/ +/* + * On MUSB the NAKing is controlled by the USB controller buffers, + * so as long as we don't read data from the FIFO, the controller will NAK. + * Nothing to see here, move along... + */ } void udc_unset_nak(int epid) { -/* On MUSB the NAKing is controlled by the USB controller buffers, - so as long as we don't read data from the FIFO, the controller will NAK. - Nothing to see here, move along... -*/ +/* + * On MUSB the NAKing is controlled by the USB controller buffers, + * so as long as we don't read data from the FIFO, the controller will NAK. + * Nothing to see here, move along... + */ } /* Start to initialize h/w stuff */ @@ -703,15 +744,15 @@ int udc_init(void) outb(0x0, UDC_DEVCTL); if (udc_musb_platform_init()) { - serial_printf("udc_init: platform init failed\n"); + printf("udc_init: platform init failed\n"); return -1; } - outl(inl(UDC_FORCESTDBY) & ~1,UDC_FORCESTDBY); /* disable MSTANDBY */ - outl(inl(UDC_SYSCONFIG) | (2<<12),UDC_SYSCONFIG); /* enable SMARTSTDBY */ - outl(inl(UDC_SYSCONFIG) & ~1,UDC_SYSCONFIG); /* disable AUTOIDLE */ - outl(inl(UDC_SYSCONFIG) | (2<<3),UDC_SYSCONFIG); /* enable SMARTIDLE */ - outl(inl(UDC_SYSCONFIG) | 1,UDC_SYSCONFIG); /* enable AUTOIDLE */ + outl(inl(UDC_FORCESTDBY) & ~1, UDC_FORCESTDBY); /* disable MSTANDBY */ + outl(inl(UDC_SYSCONFIG) | (2<<12), UDC_SYSCONFIG); /* ena SMARTSTDBY */ + outl(inl(UDC_SYSCONFIG) & ~1, UDC_SYSCONFIG); /* disable AUTOIDLE */ + outl(inl(UDC_SYSCONFIG) | (2<<3), UDC_SYSCONFIG); /* enable SMARTIDLE */ + outl(inl(UDC_SYSCONFIG) | 1, UDC_SYSCONFIG); /* enable AUTOIDLE */ /* Configure the PHY as PHY interface is 12-pin, 8-bit SDR ULPI */ sr32((void *)UDC_INTERFSEL, 0, 1, 1); @@ -721,13 +762,14 @@ int udc_init(void) outw(0x00, UDC_INTRRXE); #if CONFIG_MUSB_FULL_SPEED - /* Use Full speed for debugging proposes, useful so most USB - analyzers can catch the transactions - */ + /* + * Use Full speed for debugging proposes, useful so most USB + * analyzers can catch the transactions + */ outb(0, UDC_POWER); - serial_printf("MUSB: using full speed\n"); + printf("MUSB: using full speed\n"); #else - serial_printf("MUSB: using high speed\n"); + printf("MUSB: using high speed\n"); #endif return 0; Index: u-boot-steve-omap3/include/configs/omap3_beagle.h =================================================================== --- u-boot-steve-omap3.orig/include/configs/omap3_beagle.h +++ u-boot-steve-omap3/include/configs/omap3_beagle.h @@ -96,9 +96,9 @@ * I2C configuration */ #define CONFIG_HARD_I2C -#define CONFIG_SYS_I2C_SPEED 100000 -#define CONFIG_SYS_I2C_SLAVE 1 -#define CONFIG_DRIVER_OMAP34XX_I2C 1 +#define CONFIG_SYS_I2C_SPEED 100000 +#define CONFIG_SYS_I2C_SLAVE 1 +#define CONFIG_DRIVER_OMAP34XX_I2C 1 /* * USB Configuration @@ -106,7 +106,7 @@ #define CONFIG_USB_DEVICE 1 #define CONFIG_USB_TTY 1 #define CONFIG_MUSB 1 /* Enable USB driver*/ -#define CONFIG_TWL4030_USB 1 /* Enable TWL4030 USB */ +#define CONFIG_TWL4030_USB 1 /* Enable TWL4030 USB */ /* Allow console in serial and USB at the same time */ #define CONFIG_CONSOLE_MUX 1 Index: u-boot-steve-omap3/include/configs/omap3_evm.h =================================================================== --- u-boot-steve-omap3.orig/include/configs/omap3_evm.h +++ u-boot-steve-omap3/include/configs/omap3_evm.h @@ -159,10 +159,10 @@ /* * USB MSC and Keyboard support */ -#define CONFIG_USB_OMAP3530 +#define CONFIG_USB_OMAP3 #define CONFIG_MUSB_HCD -#ifdef CONFIG_USB_OMAP3530 +#ifdef CONFIG_USB_OMAP3 #define CONFIG_CMD_USB #ifdef CONFIG_MUSB_HCD #define CONFIG_USB_STORAGE Index: u-boot-steve-omap3/include/usbdcore_musb.h =================================================================== --- u-boot-steve-omap3.orig/include/usbdcore_musb.h +++ u-boot-steve-omap3/include/usbdcore_musb.h @@ -1,5 +1,5 @@ /* - * (C) Copyright 2009 + * (C) Copyright 2009 Texas Instruments Incorporated. * * Based on * u-boot OMAP1510 USB drivers (include/usbdcore_omap1510.h) @@ -18,8 +18,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef __USBDCORE_MUSB_H__ @@ -32,17 +31,17 @@ * specific cpu.h or related header. */ -#define UDC_OFFSET(offset) (UDC_BASE+(offset)) +#define UDC_OFFSET(offset) (UDC_BASE+(offset)) -#define UDC_INTSRCR UDC_OFFSET(0x0A) /* USB Interrupt src Reg*/ -#define UDC_INTCLRR UDC_OFFSET(0x0A) /* USB Interrupt src clr Reg*/ +#define UDC_INTSRCR UDC_OFFSET(0x0A) /* USB Interrupt src reg */ +#define UDC_INTCLRR UDC_OFFSET(0x0A) /* USB Interrupt src clr reg */ #define UDC_FADDR UDC_OFFSET(0x00) #define UDC_POWER UDC_OFFSET(0x01) #define UDC_INTRTX UDC_OFFSET(0x02) #define UDC_INTRRX UDC_OFFSET(0x04) -#define UDC_INTRTXE UDC_OFFSET(0x06) /* Enable register for INTRTX*/ -#define UDC_INTRRXE UDC_OFFSET(0x08) /* Enable Register for INTRRX*/ +#define UDC_INTRTXE UDC_OFFSET(0x06) /* Enable reg for INTRTX */ +#define UDC_INTRRXE UDC_OFFSET(0x08) /* Enable reg for INTRRX */ #define UDC_INTRUSB UDC_OFFSET(0x0A) #define UDC_INTRUSBE UDC_OFFSET(0x0B) #define UDC_INDEX UDC_OFFSET(0x0E) @@ -59,40 +58,40 @@ #define UDC_FIFO2 UDC_OFFSET(0x28) #define UDC_FIFO3 UDC_OFFSET(0x2C) #define UDC_FIFO4 UDC_OFFSET(0x30) -#define UDC_FIFO5 UDC_OFFSET(0x34) -#define UDC_FIFO6 UDC_OFFSET(0x38) -#define UDC_FIFO7 UDC_OFFSET(0x3C) -#define UDC_FIFO8 UDC_OFFSET(0x40) -#define UDC_FIFO9 UDC_OFFSET(0x44) -#define UDC_FIFO10 UDC_OFFSET(0x48) -#define UDC_FIFO11 UDC_OFFSET(0x4C) -#define UDC_FIFO12 UDC_OFFSET(0x50) -#define UDC_FIFO13 UDC_OFFSET(0x54) -#define UDC_FIFO14 UDC_OFFSET(0x58) -#define UDC_FIFO15 UDC_OFFSET(0x5C) +#define UDC_FIFO5 UDC_OFFSET(0x34) +#define UDC_FIFO6 UDC_OFFSET(0x38) +#define UDC_FIFO7 UDC_OFFSET(0x3C) +#define UDC_FIFO8 UDC_OFFSET(0x40) +#define UDC_FIFO9 UDC_OFFSET(0x44) +#define UDC_FIFO10 UDC_OFFSET(0x48) +#define UDC_FIFO11 UDC_OFFSET(0x4C) +#define UDC_FIFO12 UDC_OFFSET(0x50) +#define UDC_FIFO13 UDC_OFFSET(0x54) +#define UDC_FIFO14 UDC_OFFSET(0x58) +#define UDC_FIFO15 UDC_OFFSET(0x5C) #define UDC_DEVCTL UDC_OFFSET(0x60) #define UDC_TXFIFOSZ UDC_OFFSET(0x62) #define UDC_RXFIFOSZ UDC_OFFSET(0x63) #define UDC_TXFIFOADDR UDC_OFFSET(0x64) #define UDC_RXFIFOADDR UDC_OFFSET(0x66) -#define UDC_SYSCONFIG UDC_OFFSET(0x404) -#define UDC_INTERFSEL UDC_OFFSET(0x40C) -#define UDC_FORCESTDBY UDC_OFFSET(0x414) +#define UDC_SYSCONFIG UDC_OFFSET(0x404) +#define UDC_INTERFSEL UDC_OFFSET(0x40C) +#define UDC_FORCESTDBY UDC_OFFSET(0x414) /* MUSB Endpoint parameters */ -#define EP0_MAX_PACKET_SIZE 64 -#define UDC_OUT_ENDPOINT 3 /* Device RX endpoint */ -#define UDC_OUT_PACKET_SIZE 512 -#define UDC_IN_ENDPOINT 2 /* Device TX endpoint */ -#define UDC_IN_PACKET_SIZE 512 -#define UDC_INT_ENDPOINT 1 /* Device Interrupt/Status endpoint */ -#define UDC_INT_PACKET_SIZE 16 -#define UDC_BULK_PACKET_SIZE 512 +#define EP0_MAX_PACKET_SIZE 64 +#define UDC_OUT_ENDPOINT 3 /* Device RX endpoint */ +#define UDC_OUT_PACKET_SIZE 512 +#define UDC_IN_ENDPOINT 2 /* Device TX endpoint */ +#define UDC_IN_PACKET_SIZE 512 +#define UDC_INT_ENDPOINT 1 /* Device Interrupt/Status endpoint */ +#define UDC_INT_PACKET_SIZE 16 +#define UDC_BULK_PACKET_SIZE 512 #define UDC_MAX_FIFO_SIZE 16384 -#define DEV_CONFIG_VALUE 1 /* Only one i.e. CDC */ +#define DEV_CONFIG_VALUE 1 /* Only one i.e. CDC */ void udc_irq(void); /* Flow control */ @@ -112,7 +111,7 @@ void udc_disconnect(void); void udc_startup_events(struct usb_device_instance *device); void udc_setup_ep(struct usb_device_instance *device, unsigned int ep, - struct usb_endpoint_instance *endpoint); + struct usb_endpoint_instance *endpoint); /* platform specific initialization */ int udc_musb_platform_init(void); Index: u-boot-steve-omap3/include/usb.h =================================================================== --- u-boot-steve-omap3.orig/include/usb.h +++ u-boot-steve-omap3/include/usb.h @@ -184,7 +184,7 @@ struct usb_device { 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_OMAP3530) + defined(CONFIG_USB_OMAP3) int usb_lowlevel_init(void); int usb_lowlevel_stop(void); Index: u-boot-steve-omap3/drivers/usb/Makefile =================================================================== --- u-boot-steve-omap3.orig/drivers/usb/Makefile +++ u-boot-steve-omap3/drivers/usb/Makefile @@ -40,7 +40,7 @@ COBJS-$(CONFIG_USB_EHCI_IXP4XX) += usb_e COBJS-$(CONFIG_MUSB_HCD) += musb_hcd.o musb_core.o COBJS-$(CONFIG_USB_DAVINCI) += davinci_usb.o COBJS-$(CONFIG_USB_EHCI_VCT) += usb_ehci_vct.o -COBJS-$(CONFIG_USB_OMAP3530) += omap3530_usb.o +COBJS-$(CONFIG_USB_OMAP3) += omap3530_usb.o # device ifdef CONFIG_USB_DEVICE