summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorWolfgang Denk <wd@pollux.denx.de>2006-06-14 18:14:56 +0200
committerWolfgang Denk <wd@pollux.denx.de>2006-06-14 18:14:56 +0200
commit386eda022473394ad8f36b86f2bdc9b4cb816291 (patch)
tree122f380d73af6fcf186e45cefb400e9e1603d4bb /drivers
parent007d67da94db86989c3d0ad0a9728391b7eed02b (diff)
downloadu-boot-imx-386eda022473394ad8f36b86f2bdc9b4cb816291.zip
u-boot-imx-386eda022473394ad8f36b86f2bdc9b4cb816291.tar.gz
u-boot-imx-386eda022473394ad8f36b86f2bdc9b4cb816291.tar.bz2
Code cleanup
Diffstat (limited to 'drivers')
-rw-r--r--drivers/usbdcore_ep0.c8
-rw-r--r--drivers/usbdcore_mpc8xx.c1124
-rw-r--r--drivers/usbdcore_omap1510.c4
-rw-r--r--drivers/usbtty.c164
-rw-r--r--drivers/usbtty.h4
5 files changed, 646 insertions, 658 deletions
diff --git a/drivers/usbdcore_ep0.c b/drivers/usbdcore_ep0.c
index 5e7443b..1e44f32 100644
--- a/drivers/usbdcore_ep0.c
+++ b/drivers/usbdcore_ep0.c
@@ -44,7 +44,7 @@
* XXX
*
* As alluded to above, a simple callback cdc_recv_setup has been implemented
- * in the usb_device data structure to facilicate passing
+ * in the usb_device data structure to facilicate passing
* Common Device Class packets to a function driver.
*
* XXX
@@ -221,7 +221,7 @@ static int ep0_get_descriptor (struct usb_device_instance *device,
(struct usb_device_descriptor *) urb->buffer;
}
- dbg_ep0(3, "copied device configuration, actual_length: 0x%x", urb->actual_length);
+ dbg_ep0(3, "copied device configuration, actual_length: 0x%x", urb->actual_length);
break;
case USB_DESCRIPTOR_TYPE_CONFIGURATION:
@@ -268,7 +268,7 @@ static int ep0_get_descriptor (struct usb_device_instance *device,
serial_printf("Invalid string index %d\n", index);
return -1;
}
- dbg_ep0(3, "string_descriptor: %p length %d", string_descriptor, string_descriptor->bLength);
+ dbg_ep0(3, "string_descriptor: %p length %d", string_descriptor, string_descriptor->bLength);
copy_config (urb, string_descriptor, string_descriptor->bLength, max);
}
break;
@@ -344,7 +344,7 @@ static int ep0_get_descriptor (struct usb_device_instance *device,
case USB_DESCRIPTOR_TYPE_DEVICE_QUALIFIER:
{
/* If a USB device supports both a full speed and low speed operation
- * we must send a Device_Qualifier descriptor here
+ * we must send a Device_Qualifier descriptor here
*/
return -1;
}
diff --git a/drivers/usbdcore_mpc8xx.c b/drivers/usbdcore_mpc8xx.c
index 9bd2c23..e87284b 100644
--- a/drivers/usbdcore_mpc8xx.c
+++ b/drivers/usbdcore_mpc8xx.c
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2006 by Bryan O'Donoghue, CodeHermit
- * bodonoghue@CodeHermit.ie
+ * bodonoghue@CodeHermit.ie
*
* References
* DasUBoot/drivers/usbdcore_omap1510.c, for design and implementation ideas.
@@ -12,7 +12,7 @@
*
* 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
@@ -24,12 +24,12 @@
/*
* Notes :
- * 1. #define __SIMULATE_ERROR__ to inject a CRC error into every 2nd TX
+ * 1. #define __SIMULATE_ERROR__ to inject a CRC error into every 2nd TX
* packet to force the USB re-transmit protocol.
*
* 2. #define __DEBUG_UDC__ to switch on debug tracing to serial console
- * be careful that tracing doesn't create Hiesen-bugs with respect to
- * response timeouts to control requests.
+ * be careful that tracing doesn't create Hiesen-bugs with respect to
+ * response timeouts to control requests.
*
* 3. This driver should be able to support any higher level driver that
* that wants to do either of the two standard UDC implementations
@@ -41,18 +41,18 @@
*
* 5. For some reason, cbd_datlen is *always* +2 the value it should be.
* this means that having an RX cbd of 16 bytes is not possible, since
- * the same size is reported for 14 bytes received as 16 bytes received
+ * the same size is reported for 14 bytes received as 16 bytes received
* until we can find out why this happens, RX cbds must be limited to 8
* bytes. TODO: check errata for this behaviour.
*
* 6. Right now this code doesn't support properly powering up with the USB
- * cable attached to the USB host my development board the Adder87x doesn't
- * have a pull-up fitted to allow this, so it is necessary to power the
- * board and *then* attached the USB cable to the host. However somebody
- * with a different design in their board may be able to keep the cable
- * constantly connected and simply enable/disable a pull-up re
- * figure 31.1 in MPC885RM.pdf instead of having to power up the board and
- * then attach the cable !
+ * cable attached to the USB host my development board the Adder87x doesn't
+ * have a pull-up fitted to allow this, so it is necessary to power the
+ * board and *then* attached the USB cable to the host. However somebody
+ * with a different design in their board may be able to keep the cable
+ * constantly connected and simply enable/disable a pull-up re
+ * figure 31.1 in MPC885RM.pdf instead of having to power up the board and
+ * then attach the cable !
*
*/
#include <common.h>
@@ -60,7 +60,7 @@
#if defined(CONFIG_MPC885_FAMILY) && defined(CONFIG_USB_DEVICE)
#include <commproc.h>
-#include "usbdcore.h"
+#include "usbdcore.h"
#include "usbdcore_mpc8xx.h"
#include "usbdcore_ep0.h"
@@ -68,24 +68,24 @@
serial_printf("ERROR : [%s] %s:%d: "fmt,\
__FILE__,__FUNCTION__,__LINE__, ##args)
#ifdef __DEBUG_UDC__
- #define DBG(fmt,args...)\
+#define DBG(fmt,args...)\
serial_printf("[%s] %s:%d: "fmt,\
__FILE__,__FUNCTION__,__LINE__, ##args)
#else
- #define DBG(fmt,args...)
+#define DBG(fmt,args...)
#endif
/* Static Data */
#ifdef __SIMULATE_ERROR__
- static char err_poison_test = 0;
+static char err_poison_test = 0;
#endif
static struct mpc8xx_ep ep_ref[MAX_ENDPOINTS];
static u32 address_base = STATE_NOT_READY;
static mpc8xx_udc_state_t udc_state = 0;
static struct usb_device_instance *udc_device = 0;
-static volatile usb_epb_t *endpoints[MAX_ENDPOINTS];
-static volatile cbd_t * tx_cbd[TX_RING_SIZE];
-static volatile cbd_t * rx_cbd[RX_RING_SIZE];
+static volatile usb_epb_t *endpoints[MAX_ENDPOINTS];
+static volatile cbd_t *tx_cbd[TX_RING_SIZE];
+static volatile cbd_t *rx_cbd[RX_RING_SIZE];
static volatile immap_t *immr = 0;
static volatile cpm8xx_t *cp = 0;
static volatile usb_pram_t *usb_paramp = 0;
@@ -95,87 +95,87 @@ static int tx_ct = 0;
/* Static Function Declarations */
static void mpc8xx_udc_state_transition_up (usb_device_state_t initial,
- usb_device_state_t final);
+ usb_device_state_t final);
static void mpc8xx_udc_state_transition_down (usb_device_state_t initial,
- usb_device_state_t final);
+ usb_device_state_t final);
static void mpc8xx_udc_stall (unsigned int ep);
-static void mpc8xx_udc_flush_tx_fifo(int epid);
-static void mpc8xx_udc_flush_rx_fifo(void);
+static void mpc8xx_udc_flush_tx_fifo (int epid);
+static void mpc8xx_udc_flush_rx_fifo (void);
static void mpc8xx_udc_clear_rxbd (volatile cbd_t * rx_cbdp);
-static void mpc8xx_udc_init_tx(struct usb_endpoint_instance *epi,
- struct urb * tx_urb);
-static void mpc8xx_udc_dump_request(struct usb_device_request *request);
-static void mpc8xx_udc_clock_init (volatile immap_t * immr,
- volatile cpm8xx_t * cp);
+static void mpc8xx_udc_init_tx (struct usb_endpoint_instance *epi,
+ struct urb *tx_urb);
+static void mpc8xx_udc_dump_request (struct usb_device_request *request);
+static void mpc8xx_udc_clock_init (volatile immap_t * immr,
+ volatile cpm8xx_t * cp);
static int mpc8xx_udc_ep_tx (struct usb_endpoint_instance *epi);
static int mpc8xx_udc_epn_rx (unsigned int epid, volatile cbd_t * rx_cbdp);
-static void mpc8xx_udc_ep0_rx(volatile cbd_t * rx_cbdp);
+static void mpc8xx_udc_ep0_rx (volatile cbd_t * rx_cbdp);
static void mpc8xx_udc_cbd_init (void);
static void mpc8xx_udc_endpoint_init (void);
static void mpc8xx_udc_cbd_attach (int ep, uchar tx_size, uchar rx_size);
static u32 mpc8xx_udc_alloc (u32 data_size, u32 alignment);
static int mpc8xx_udc_ep0_rx_setup (volatile cbd_t * rx_cbdp);
static void mpc8xx_udc_set_nak (unsigned int ep);
-static short mpc8xx_udc_handle_txerr(void);
-static void mpc8xx_udc_advance_rx(volatile cbd_t ** rx_cbdp, int epid);
+static short mpc8xx_udc_handle_txerr (void);
+static void mpc8xx_udc_advance_rx (volatile cbd_t ** rx_cbdp, int epid);
/******************************************************************************
- Global Linkage
+ Global Linkage
*****************************************************************************/
/* udc_init
*
* Do initial bus gluing
*/
-int udc_init(void)
+int udc_init (void)
{
/* Init various pointers */
immr = (immap_t *) CFG_IMMR;
- cp = (cpm8xx_t *)&(immr->im_cpm);
- usb_paramp = (usb_pram_t*)&(cp->cp_dparam[PROFF_USB]);
- usbp = (usb_t *) &(cp->cp_scc[0]);
+ cp = (cpm8xx_t *) & (immr->im_cpm);
+ usb_paramp = (usb_pram_t *) & (cp->cp_dparam[PROFF_USB]);
+ usbp = (usb_t *) & (cp->cp_scc[0]);
+
+ memset (ep_ref, 0x00, (sizeof (struct mpc8xx_ep) * MAX_ENDPOINTS));
- memset(ep_ref, 0x00, (sizeof(struct mpc8xx_ep) * MAX_ENDPOINTS));
-
udc_device = 0;
udc_state = STATE_NOT_READY;
-
- usbp->usmod= 0x00;
- usbp->uscom= 0;
-
+
+ usbp->usmod = 0x00;
+ usbp->uscom = 0;
+
/* Set USB Frame #0, Respond at Address & Get a clock source */
usbp->usaddr = 0x00;
mpc8xx_udc_clock_init (immr, cp);
-
+
/* PA15, PA14 as perhiperal USBRXD and USBOE */
- immr->im_ioport.iop_padir&= ~0x0003;
- immr->im_ioport.iop_papar|= 0x0003;
-
+ immr->im_ioport.iop_padir &= ~0x0003;
+ immr->im_ioport.iop_papar |= 0x0003;
+
/* PC11/PC10 as peripheral USBRXP USBRXN */
- immr->im_ioport.iop_pcso|= 0x0030;
-
+ immr->im_ioport.iop_pcso |= 0x0030;
+
/* PC7/PC6 as perhiperal USBTXP and USBTXN */
- immr->im_ioport.iop_pcdir|= 0x0300;
- immr->im_ioport.iop_pcpar|= 0x0300;
-
+ immr->im_ioport.iop_pcdir |= 0x0300;
+ immr->im_ioport.iop_pcpar |= 0x0300;
+
/* Set the base address */
- address_base = (u32)(cp->cp_dpmem + CPM_USB_BASE);
+ address_base = (u32) (cp->cp_dpmem + CPM_USB_BASE);
/* Initialise endpoints and circular buffers */
- mpc8xx_udc_endpoint_init();
- mpc8xx_udc_cbd_init();
-
+ mpc8xx_udc_endpoint_init ();
+ mpc8xx_udc_cbd_init ();
+
/* Assign allocated Dual Port Endpoint descriptors */
- usb_paramp->ep0ptr = (u32)endpoints[0];
- usb_paramp->ep1ptr = (u32)endpoints[1];
- usb_paramp->ep2ptr = (u32)endpoints[2];
- usb_paramp->ep3ptr = (u32)endpoints[3];
+ usb_paramp->ep0ptr = (u32) endpoints[0];
+ usb_paramp->ep1ptr = (u32) endpoints[1];
+ usb_paramp->ep2ptr = (u32) endpoints[2];
+ usb_paramp->ep3ptr = (u32) endpoints[3];
usb_paramp->frame_n = 0;
- DBG("ep0ptr=0x%08x ep1ptr=0x%08x ep2ptr=0x%08x ep3ptr=0x%08x\n",
- usb_paramp->ep0ptr, usb_paramp->ep1ptr, usb_paramp->ep2ptr,
- usb_paramp->ep3ptr);
-
+ DBG ("ep0ptr=0x%08x ep1ptr=0x%08x ep2ptr=0x%08x ep3ptr=0x%08x\n",
+ usb_paramp->ep0ptr, usb_paramp->ep1ptr, usb_paramp->ep2ptr,
+ usb_paramp->ep3ptr);
+
return 0;
}
@@ -183,149 +183,147 @@ int udc_init(void)
*
* Poll for whatever events may have occured
*/
-void udc_irq(void)
+void udc_irq (void)
{
int epid = 0;
- volatile cbd_t * rx_cbdp = 0;
- volatile cbd_t * rx_cbdp_base = 0;
+ volatile cbd_t *rx_cbdp = 0;
+ volatile cbd_t *rx_cbdp_base = 0;
- if(udc_state!=STATE_READY){
+ if (udc_state != STATE_READY) {
return;
}
-
- if(usbp->usber&USB_E_BSY){
+
+ if (usbp->usber & USB_E_BSY) {
/* This shouldn't happen. If it does then it's a bug ! */
- usbp->usber|=USB_E_BSY;
- mpc8xx_udc_flush_rx_fifo();
+ usbp->usber |= USB_E_BSY;
+ mpc8xx_udc_flush_rx_fifo ();
}
-
/* Scan all RX/Bidirectional Endpoints for RX data. */
- for(epid = 0; epid<MAX_ENDPOINTS; epid++){
-
- if(!ep_ref[epid].prx){
+ for (epid = 0; epid < MAX_ENDPOINTS; epid++) {
+ if (!ep_ref[epid].prx) {
continue;
}
-
rx_cbdp = rx_cbdp_base = ep_ref[epid].prx;
- do{
- if(!(rx_cbdp->cbd_sc&RX_BD_E)){
-
- if(rx_cbdp->cbd_sc&0x1F){
+
+ do {
+ if (!(rx_cbdp->cbd_sc & RX_BD_E)) {
+
+ if (rx_cbdp->cbd_sc & 0x1F) {
/* Corrupt data discard it.
- * Controller has NAK'd this packet.
+ * Controller has NAK'd this packet.
*/
- mpc8xx_udc_clear_rxbd(rx_cbdp);
+ mpc8xx_udc_clear_rxbd (rx_cbdp);
- }else{
- if(!epid){
- mpc8xx_udc_ep0_rx(rx_cbdp);
+ } else {
+ if (!epid) {
+ mpc8xx_udc_ep0_rx (rx_cbdp);
- }else{
+ } else {
/* Process data */
- mpc8xx_udc_set_nak(epid);
- mpc8xx_udc_epn_rx(epid,rx_cbdp);
- mpc8xx_udc_clear_rxbd(rx_cbdp);
- }
+ mpc8xx_udc_set_nak (epid);
+ mpc8xx_udc_epn_rx (epid, rx_cbdp);
+ mpc8xx_udc_clear_rxbd (rx_cbdp);
+ }
}
-
+
/* Advance RX CBD pointer */
- mpc8xx_udc_advance_rx(&rx_cbdp, epid);
+ mpc8xx_udc_advance_rx (&rx_cbdp, epid);
ep_ref[epid].prx = rx_cbdp;
- }else{
+ } else {
/* Advance RX CBD pointer */
- mpc8xx_udc_advance_rx(&rx_cbdp, epid);
+ mpc8xx_udc_advance_rx (&rx_cbdp, epid);
}
- }while(rx_cbdp != rx_cbdp_base);
+ } while (rx_cbdp != rx_cbdp_base);
}
/* Handle TX events as appropiate, the correct place to do this is
* in a tx routine. Perhaps TX on epn was pre-empted by ep0
*/
- if(usbp->usber&USB_E_TXB){
- usbp->usber|=USB_E_TXB;
+ if (usbp->usber & USB_E_TXB) {
+ usbp->usber |= USB_E_TXB;
}
-
- if(usbp->usber&(USB_TX_ERRMASK)){
- mpc8xx_udc_handle_txerr();
+
+ if (usbp->usber & (USB_TX_ERRMASK)) {
+ mpc8xx_udc_handle_txerr ();
}
/* Switch to the default state, respond at the default address */
- if(usbp->usber&USB_E_RESET){
- usbp->usber|=USB_E_RESET;
- usbp->usaddr = 0x00;
+ if (usbp->usber & USB_E_RESET) {
+ usbp->usber |= USB_E_RESET;
+ usbp->usaddr = 0x00;
udc_device->device_state = STATE_DEFAULT;
}
- /*if(usbp->usber&USB_E_IDLE){
- We could suspend here !
- usbp->usber|=USB_E_IDLE;
- DBG("idle state change\n");
- }
- if(usbp->usbs){
- We could resume here when IDLE is deasserted !
- Not worth doing, so long as we are self powered though.
- }*/
+ /* if(usbp->usber&USB_E_IDLE){
+ We could suspend here !
+ usbp->usber|=USB_E_IDLE;
+ DBG("idle state change\n");
+ }
+ if(usbp->usbs){
+ We could resume here when IDLE is deasserted !
+ Not worth doing, so long as we are self powered though.
+ }
+ */
return;
}
-
-
/* udc_endpoint_write
*
* Write some data to an endpoint
*/
-int udc_endpoint_write(struct usb_endpoint_instance *epi)
+int udc_endpoint_write (struct usb_endpoint_instance *epi)
{
int ep = 0;
short epid = 1, unnak = 0, ret = 0;
- if(udc_state != STATE_READY){
- ERR("invalid udc_state != STATE_READY!\n");
+ if (udc_state != STATE_READY) {
+ ERR ("invalid udc_state != STATE_READY!\n");
return -1;
}
- if(!udc_device || !epi){
+ if (!udc_device || !epi) {
return -1;
}
-
- if(udc_device->device_state!=STATE_CONFIGURED){
+
+ if (udc_device->device_state != STATE_CONFIGURED) {
return -1;
}
ep = epi->endpoint_address & 0x03;
- if(ep >= MAX_ENDPOINTS){
+ if (ep >= MAX_ENDPOINTS) {
return -1;
}
-
+
/* Set NAK for all RX endpoints during TX */
- for(epid = 1; epid<MAX_ENDPOINTS; epid++){
+ for (epid = 1; epid < MAX_ENDPOINTS; epid++) {
/* Don't set NAK on DATA IN/CONTROL endpoints */
- if(ep_ref[epid].sc & USB_DIR_IN){
+ if (ep_ref[epid].sc & USB_DIR_IN) {
continue;
}
- if(!(usbp->usep[epid]&( USEP_THS_NAK | USEP_RHS_NAK ))){
- unnak |= 1<<epid;
+ if (!(usbp->usep[epid] & (USEP_THS_NAK | USEP_RHS_NAK))) {
+ unnak |= 1 << epid;
}
- mpc8xx_udc_set_nak(epid);
+ mpc8xx_udc_set_nak (epid);
}
- mpc8xx_udc_init_tx(&udc_device->bus->endpoint_array[ep],epi->tx_urb);
- ret = mpc8xx_udc_ep_tx(&udc_device->bus->endpoint_array[ep]);
-
+ mpc8xx_udc_init_tx (&udc_device->bus->endpoint_array[ep],
+ epi->tx_urb);
+ ret = mpc8xx_udc_ep_tx (&udc_device->bus->endpoint_array[ep]);
+
/* Remove temporary NAK */
- for(epid = 1; epid<MAX_ENDPOINTS; epid++){
- if(unnak&(1<<epid)){
- udc_unset_nak(epid);
+ for (epid = 1; epid < MAX_ENDPOINTS; epid++) {
+ if (unnak & (1 << epid)) {
+ udc_unset_nak (epid);
}
}
-
+
return ret;
}
@@ -333,41 +331,40 @@ int udc_endpoint_write(struct usb_endpoint_instance *epi)
*
* Associate a given urb to an endpoint TX or RX transmit/receive buffers
*/
-static int mpc8xx_udc_assign_urb(int ep, char direction)
+static int mpc8xx_udc_assign_urb (int ep, char direction)
{
struct usb_endpoint_instance *epi = 0;
-
- if(ep >= MAX_ENDPOINTS){
+
+ if (ep >= MAX_ENDPOINTS) {
goto err;
}
epi = &udc_device->bus->endpoint_array[ep];
- if(!epi){
+ if (!epi) {
goto err;
}
- if(!ep_ref[ep].urb){
- ep_ref[ep].urb = usbd_alloc_urb(udc_device,
- udc_device->bus->endpoint_array);
- if(!ep_ref[ep].urb){
+ if (!ep_ref[ep].urb) {
+ ep_ref[ep].urb = usbd_alloc_urb (udc_device, udc_device->bus->endpoint_array);
+ if (!ep_ref[ep].urb) {
goto err;
}
- }else{
+ } else {
ep_ref[ep].urb->actual_length = 0;
}
- switch(direction){
- case USB_DIR_IN:
- epi->tx_urb = ep_ref[ep].urb;
- break;
- case USB_DIR_OUT:
- epi->rcv_urb = ep_ref[ep].urb;
- break;
- default:
- goto err;
+ switch (direction) {
+ case USB_DIR_IN:
+ epi->tx_urb = ep_ref[ep].urb;
+ break;
+ case USB_DIR_OUT:
+ epi->rcv_urb = ep_ref[ep].urb;
+ break;
+ default:
+ goto err;
}
return 0;
-err:
+ err:
udc_state = STATE_ERROR;
return -1;
}
@@ -377,83 +374,84 @@ err:
* Associate U-Boot software endpoints to mpc8xx endpoint parameter ram
* Isochronous endpoints aren't yet supported!
*/
-void udc_setup_ep(struct usb_device_instance *device, unsigned int ep,
- struct usb_endpoint_instance *epi)
+void udc_setup_ep (struct usb_device_instance *device, unsigned int ep,
+ struct usb_endpoint_instance *epi)
{
uchar direction = 0;
int ep_attrib = 0;
- if(epi && (ep < MAX_ENDPOINTS)){
-
- if(ep == 0){
- if (epi->rcv_attributes!=USB_ENDPOINT_XFER_CONTROL
- ||epi->tx_attributes!=
- USB_ENDPOINT_XFER_CONTROL){
+ if (epi && (ep < MAX_ENDPOINTS)) {
- /* ep0 must be a control endpoint*/
+ if (ep == 0) {
+ if (epi->rcv_attributes != USB_ENDPOINT_XFER_CONTROL
+ || epi->tx_attributes !=
+ USB_ENDPOINT_XFER_CONTROL) {
+
+ /* ep0 must be a control endpoint */
udc_state = STATE_ERROR;
return;
}
- if(!(ep_ref[ep].sc & EP_ATTACHED)){
- mpc8xx_udc_cbd_attach (ep, epi->tx_packetSize,
- epi->rcv_packetSize);
+ if (!(ep_ref[ep].sc & EP_ATTACHED)) {
+ mpc8xx_udc_cbd_attach (ep, epi->tx_packetSize,
+ epi->rcv_packetSize);
}
usbp->usep[ep] = 0x0000;
return;
}
-
- if ((epi->endpoint_address & USB_ENDPOINT_DIR_MASK)
- == USB_DIR_IN) {
+
+ if ((epi->endpoint_address & USB_ENDPOINT_DIR_MASK)
+ == USB_DIR_IN) {
direction = 1;
ep_attrib = epi->tx_attributes;
epi->rcv_packetSize = 0;
- ep_ref[ep].sc |= USB_DIR_IN;
+ ep_ref[ep].sc |= USB_DIR_IN;
} else {
-
+
direction = 0;
ep_attrib = epi->rcv_attributes;
- epi->tx_packetSize = 0;
+ epi->tx_packetSize = 0;
ep_ref[ep].sc &= ~USB_DIR_IN;
}
- if(mpc8xx_udc_assign_urb(ep, epi->endpoint_address
- &USB_ENDPOINT_DIR_MASK)){
+ if (mpc8xx_udc_assign_urb (ep, epi->endpoint_address
+ & USB_ENDPOINT_DIR_MASK)) {
return;
}
- switch(ep_attrib){
- case USB_ENDPOINT_XFER_CONTROL:
- if(!(ep_ref[ep].sc & EP_ATTACHED)){
+ switch (ep_attrib) {
+ case USB_ENDPOINT_XFER_CONTROL:
+ if (!(ep_ref[ep].sc & EP_ATTACHED)) {
+ mpc8xx_udc_cbd_attach (ep,
+ epi->tx_packetSize,
+ epi->rcv_packetSize);
+ }
+ usbp->usep[ep] = ep << 12;
+ epi->rcv_urb = epi->tx_urb = ep_ref[ep].urb;
+
+ break;
+ case USB_ENDPOINT_XFER_BULK:
+ case USB_ENDPOINT_XFER_INT:
+ if (!(ep_ref[ep].sc & EP_ATTACHED)) {
+ if (direction) {
mpc8xx_udc_cbd_attach (ep,
- epi->tx_packetSize,
- epi->rcv_packetSize);
+ epi->tx_packetSize,
+ 0);
+ } else {
+ mpc8xx_udc_cbd_attach (ep,
+ 0,
+ epi->rcv_packetSize);
}
- usbp->usep[ep] = ep<<12;
- epi->rcv_urb = epi->tx_urb = ep_ref[ep].urb;
+ }
+ usbp->usep[ep] = (ep << 12) | ((ep_attrib) << 8);
- break;
- case USB_ENDPOINT_XFER_BULK :
- case USB_ENDPOINT_XFER_INT:
- if(!(ep_ref[ep].sc & EP_ATTACHED)){
- if(direction){
- mpc8xx_udc_cbd_attach (ep,
- epi->tx_packetSize, 0);
- }else{
- mpc8xx_udc_cbd_attach (ep,
- 0, epi->rcv_packetSize);
- }
- }
- usbp->usep[ep]= (ep<<12)|((ep_attrib)<<8);
-
- break;
- case USB_ENDPOINT_XFER_ISOC:
- default:
- serial_printf("Error endpoint attrib %d>3\n",
- ep_attrib);
- udc_state = STATE_ERROR;
- break;
+ break;
+ case USB_ENDPOINT_XFER_ISOC:
+ default:
+ serial_printf ("Error endpoint attrib %d>3\n", ep_attrib);
+ udc_state = STATE_ERROR;
+ break;
}
}
@@ -463,54 +461,53 @@ void udc_setup_ep(struct usb_device_instance *device, unsigned int ep,
*
* Move state, switch on the USB
*/
-void udc_connect(void)
+void udc_connect (void)
{
- /* Enable pull-up resistor on D+
+ /* Enable pull-up resistor on D+
* TODO: fit a pull-up resistor to drive SE0 for > 2.5us
*/
-
- if(udc_state!=STATE_ERROR){
+
+ if (udc_state != STATE_ERROR) {
udc_state = STATE_READY;
- usbp->usmod|= USMOD_EN;
+ usbp->usmod |= USMOD_EN;
}
-}
+}
/* udc_disconnect
*
* Disconnect is not used but, is included for completeness
*/
-void udc_disconnect(void)
+void udc_disconnect (void)
{
/* Disable pull-up resistor on D-
* TODO: fix a pullup resistor to control this
*/
- if(udc_state!=STATE_ERROR){
+ if (udc_state != STATE_ERROR) {
udc_state = STATE_NOT_READY;
}
- usbp->usmod&=~USMOD_EN;
+ usbp->usmod &= ~USMOD_EN;
}
/* udc_enable
- *
+ *
* Grab an EP0 URB, register interest in a subset of USB events
*/
-void udc_enable(struct usb_device_instance *device)
+void udc_enable (struct usb_device_instance *device)
{
- if(udc_state == STATE_ERROR){
+ if (udc_state == STATE_ERROR) {
return;
}
udc_device = device;
-
- if(!ep_ref[0].urb){
- ep_ref[0].urb = usbd_alloc_urb(device,
- device->bus->endpoint_array);
+
+ if (!ep_ref[0].urb) {
+ ep_ref[0].urb = usbd_alloc_urb (device, device->bus->endpoint_array);
}
/* Register interest in all events except SOF, enable transceiver */
- usbp->usber= 0x03FF;
- usbp->usbmr= 0x02F7;
+ usbp->usber = 0x03FF;
+ usbp->usbmr = 0x02F7;
return;
}
@@ -519,26 +516,26 @@ void udc_enable(struct usb_device_instance *device)
*
* disable the currently hooked device
*/
-void udc_disable(void)
+void udc_disable (void)
{
int i = 0;
- if(udc_state == STATE_ERROR){
- DBG("Won't disable UDC. udc_state==STATE_ERROR !\n");
+ if (udc_state == STATE_ERROR) {
+ DBG ("Won't disable UDC. udc_state==STATE_ERROR !\n");
return;
}
udc_device = 0;
- for(;i<MAX_ENDPOINTS; i++){
- if(ep_ref[i].urb){
- usbd_dealloc_urb(ep_ref[i].urb);
+ for (; i < MAX_ENDPOINTS; i++) {
+ if (ep_ref[i].urb) {
+ usbd_dealloc_urb (ep_ref[i].urb);
ep_ref[i].urb = 0;
}
}
-
- usbp->usbmr= 0x00;
- usbp->usmod= ~USMOD_EN;
+
+ usbp->usbmr = 0x00;
+ usbp->usmod = ~USMOD_EN;
udc_state = STATE_NOT_READY;
}
@@ -546,46 +543,46 @@ void udc_disable(void)
*
* Enable the specified device
*/
-void udc_startup_events(struct usb_device_instance *device)
+void udc_startup_events (struct usb_device_instance *device)
{
- udc_enable(device);
- if(udc_state == STATE_READY){
+ udc_enable (device);
+ if (udc_state == STATE_READY) {
usbd_device_event_irq (device, DEVICE_CREATE, 0);
}
}
/* udc_set_nak
- *
+ *
* Allow upper layers to signal lower layers should not accept more RX data
*
*/
-void udc_set_nak(int epid)
+void udc_set_nak (int epid)
{
- if(epid){
- mpc8xx_udc_set_nak(epid);
+ if (epid) {
+ mpc8xx_udc_set_nak (epid);
}
}
-/* udc_unset_nak
- *
+/* udc_unset_nak
+ *
* Suspend sending of NAK tokens for DATA OUT tokens on a given endpoint.
* Switch off NAKing on this endpoint to accept more data output from host.
*
*/
void udc_unset_nak (int epid)
{
- if(epid > MAX_ENDPOINTS){
+ if (epid > MAX_ENDPOINTS) {
return;
}
- if(usbp->usep[epid]&(USEP_THS_NAK | USEP_RHS_NAK)){
- usbp->usep[epid]&= ~(USEP_THS_NAK | USEP_RHS_NAK);
+ if (usbp->usep[epid] & (USEP_THS_NAK | USEP_RHS_NAK)) {
+ usbp->usep[epid] &= ~(USEP_THS_NAK | USEP_RHS_NAK);
__asm__ ("eieio");
}
}
/******************************************************************************
- Static Linkage
+ Static Linkage
******************************************************************************/
/* udc_state_transition_up
@@ -633,10 +630,10 @@ void udc_unset_nak (int epid)
* state, then no state transitions will take place.
*
*/
-
+
static void mpc8xx_udc_state_transition_up (usb_device_state_t initial,
- usb_device_state_t final)
-{
+ usb_device_state_t final)
+{
if (initial < final) {
switch (initial) {
case STATE_ATTACHED:
@@ -665,13 +662,13 @@ static void mpc8xx_udc_state_transition_up (usb_device_state_t initial,
}
static void mpc8xx_udc_state_transition_down (usb_device_state_t initial,
- usb_device_state_t final)
+ usb_device_state_t final)
{
if (initial > final) {
switch (initial) {
case STATE_CONFIGURED:
- usbd_device_event_irq (udc_device,
- DEVICE_DE_CONFIGURED, 0);
+ usbd_device_event_irq (udc_device,
+ DEVICE_DE_CONFIGURED, 0);
if (final == STATE_ADDRESSED)
break;
case STATE_ADDRESSED:
@@ -679,13 +676,13 @@ static void mpc8xx_udc_state_transition_down (usb_device_state_t initial,
if (final == STATE_DEFAULT)
break;
case STATE_DEFAULT:
- usbd_device_event_irq (udc_device,
- DEVICE_POWER_INTERRUPTION, 0);
+ usbd_device_event_irq (udc_device,
+ DEVICE_POWER_INTERRUPTION, 0);
if (final == STATE_POWERED)
break;
case STATE_POWERED:
usbd_device_event_irq (udc_device, DEVICE_HUB_RESET,
- 0);
+ 0);
case STATE_ATTACHED:
break;
default:
@@ -708,7 +705,7 @@ static void mpc8xx_udc_stall (unsigned int ep)
*
* Force returning of NAK responses for the given endpoint as a kind of very
* simple flow control
- */
+ */
static void mpc8xx_udc_set_nak (unsigned int ep)
{
usbp->usep[ep] |= NAK_BITMASK;
@@ -720,27 +717,26 @@ static void mpc8xx_udc_set_nak (unsigned int ep)
* Handle errors relevant to TX. Return a status code to allow calling
* indicative of what if anything happened
*/
-static short mpc8xx_udc_handle_txerr()
+static short mpc8xx_udc_handle_txerr ()
{
short ep = 0, ret = 0;
-
- for(; ep<TX_RING_SIZE; ep++){
- if(usbp->usber&(0x10<<ep)){
-
+
+ for (; ep < TX_RING_SIZE; ep++) {
+ if (usbp->usber & (0x10 << ep)) {
+
/* Timeout or underrun */
- if(tx_cbd[ep]->cbd_sc&0x06){
+ if (tx_cbd[ep]->cbd_sc & 0x06) {
ret = 1;
- mpc8xx_udc_flush_tx_fifo(ep);
+ mpc8xx_udc_flush_tx_fifo (ep);
- }else{
- if(usbp->usep[ep]&STALL_BITMASK){
- if(!ep){
- usbp->usep[ep]&=
- ~STALL_BITMASK;
+ } else {
+ if (usbp->usep[ep] & STALL_BITMASK) {
+ if (!ep) {
+ usbp->usep[ep] &= ~STALL_BITMASK;
}
- }/* else NAK */
+ } /* else NAK */
}
- usbp->usber|=(0x10<<ep);
+ usbp->usber |= (0x10 << ep);
}
}
return ret;
@@ -750,13 +746,12 @@ static short mpc8xx_udc_handle_txerr()
*
* Advance cbd rx
*/
-static void mpc8xx_udc_advance_rx(volatile cbd_t ** rx_cbdp, int epid)
+static void mpc8xx_udc_advance_rx (volatile cbd_t ** rx_cbdp, int epid)
{
- if((*rx_cbdp)->cbd_sc & RX_BD_W){
- *rx_cbdp = (volatile cbd_t*)
- (endpoints[epid]->rbase + CFG_IMMR);
-
- }else{
+ if ((*rx_cbdp)->cbd_sc & RX_BD_W) {
+ *rx_cbdp = (volatile cbd_t *) (endpoints[epid]->rbase + CFG_IMMR);
+
+ } else {
(*rx_cbdp)++;
}
}
@@ -766,34 +761,34 @@ static void mpc8xx_udc_advance_rx(volatile cbd_t ** rx_cbdp, int epid)
*
* Flush a given TX fifo. Assumes one tx cbd per endpoint
*/
-static void mpc8xx_udc_flush_tx_fifo(int epid)
-{
- volatile cbd_t * tx_cbdp = 0;
+static void mpc8xx_udc_flush_tx_fifo (int epid)
+{
+ volatile cbd_t *tx_cbdp = 0;
- if(epid > MAX_ENDPOINTS){
+ if (epid > MAX_ENDPOINTS) {
return;
}
/* TX stop */
- immr->im_cpm.cp_cpcr = ((epid<<2) | 0x1D01);
+ immr->im_cpm.cp_cpcr = ((epid << 2) | 0x1D01);
__asm__ ("eieio");
- while(immr->im_cpm.cp_cpcr & 0x01);
-
+ while (immr->im_cpm.cp_cpcr & 0x01);
+
usbp->uscom = 0x40 | 0;
-
+
/* reset ring */
- tx_cbdp = (cbd_t*)(endpoints[epid]->tbptr + CFG_IMMR);
+ tx_cbdp = (cbd_t *) (endpoints[epid]->tbptr + CFG_IMMR);
tx_cbdp->cbd_sc = (TX_BD_I | TX_BD_W);
-
+
endpoints[epid]->tptr = endpoints[epid]->tbase;
- endpoints[epid]->tstate = 0x00;
- endpoints[epid]->tbcnt = 0x00;
+ endpoints[epid]->tstate = 0x00;
+ endpoints[epid]->tbcnt = 0x00;
/* TX start */
- immr->im_cpm.cp_cpcr = ((epid<<2) | 0x2D01);
+ immr->im_cpm.cp_cpcr = ((epid << 2) | 0x2D01);
__asm__ ("eieio");
- while(immr->im_cpm.cp_cpcr & 0x01);
+ while (immr->im_cpm.cp_cpcr & 0x01);
return;
}
@@ -807,28 +802,29 @@ static void mpc8xx_udc_flush_tx_fifo(int epid)
* we have accepted data but, the CPM found it had no-where to put that data
* which needless to say would be a bad thing.
*/
-static void mpc8xx_udc_flush_rx_fifo()
+static void mpc8xx_udc_flush_rx_fifo ()
{
int i = 0;
- for(i = 0;i<RX_RING_SIZE; i++){
- if(!(rx_cbd[i]->cbd_sc&RX_BD_E)){
- ERR("buf %p used rx data len = 0x%x sc=0x%x!\n",
- rx_cbd[i], rx_cbd[i]->cbd_datlen,
- rx_cbd[i]->cbd_sc);
+
+ for (i = 0; i < RX_RING_SIZE; i++) {
+ if (!(rx_cbd[i]->cbd_sc & RX_BD_E)) {
+ ERR ("buf %p used rx data len = 0x%x sc=0x%x!\n",
+ rx_cbd[i], rx_cbd[i]->cbd_datlen,
+ rx_cbd[i]->cbd_sc);
}
}
- ERR("BUG : Input over-run\n");
+ ERR ("BUG : Input over-run\n");
}
/* mpc8xx_udc_clear_rxbd
- *
+ *
* Release control of RX CBD to CP.
*/
-static void mpc8xx_udc_clear_rxbd(volatile cbd_t * rx_cbdp)
+static void mpc8xx_udc_clear_rxbd (volatile cbd_t * rx_cbdp)
{
rx_cbdp->cbd_datlen = 0x0000;
- rx_cbdp->cbd_sc= ((rx_cbdp->cbd_sc & RX_BD_W)|(RX_BD_E | RX_BD_I));
+ rx_cbdp->cbd_sc = ((rx_cbdp->cbd_sc & RX_BD_W) | (RX_BD_E | RX_BD_I));
__asm__ ("eieio");
}
@@ -837,27 +833,27 @@ static void mpc8xx_udc_clear_rxbd(volatile cbd_t * rx_cbdp)
* Parse for tx timeout, control RX or USB reset/busy conditions
* Return -1 on timeout, -2 on fatal error, else return zero
*/
-static int mpc8xx_udc_tx_irq(int ep)
+static int mpc8xx_udc_tx_irq (int ep)
{
int i = 0;
- if(usbp->usber&(USB_TX_ERRMASK)){
- if(mpc8xx_udc_handle_txerr()){
+ if (usbp->usber & (USB_TX_ERRMASK)) {
+ if (mpc8xx_udc_handle_txerr ()) {
/* Timeout, controlling function must retry send */
return -1;
}
}
- if(usbp->usber & (USB_E_RESET|USB_E_BSY)){
+ if (usbp->usber & (USB_E_RESET | USB_E_BSY)) {
/* Fatal, abandon TX transaction */
return -2;
}
-
- if(usbp->usber & USB_E_RXB){
- for(i = 0;i<RX_RING_SIZE; i++){
- if(!(rx_cbd[i]->cbd_sc&RX_BD_E)){
- if((rx_cbd[i] == ep_ref[0].prx) || ep){
- return -2;
+
+ if (usbp->usber & USB_E_RXB) {
+ for (i = 0; i < RX_RING_SIZE; i++) {
+ if (!(rx_cbd[i]->cbd_sc & RX_BD_E)) {
+ if ((rx_cbd[i] == ep_ref[0].prx) || ep) {
+ return -2;
}
}
}
@@ -875,106 +871,106 @@ static int mpc8xx_udc_tx_irq(int ep)
* devices to give up TX, however tx_retry stops us getting stuck in an endless
* TX loop.
*/
-static int mpc8xx_udc_ep_tx (struct usb_endpoint_instance *epi)
+static int mpc8xx_udc_ep_tx (struct usb_endpoint_instance *epi)
{
struct urb *urb = epi->tx_urb;
- volatile cbd_t * tx_cbdp = 0;
+ volatile cbd_t *tx_cbdp = 0;
unsigned int ep = 0, pkt_len = 0, x = 0, tx_retry = 0;
int ret = 0;
-
- if(!epi || (epi->endpoint_address&0x03)>=MAX_ENDPOINTS || !urb){
+
+ if (!epi || (epi->endpoint_address & 0x03) >= MAX_ENDPOINTS || !urb) {
return -1;
}
ep = epi->endpoint_address & 0x03;
- tx_cbdp = (cbd_t*)(endpoints[ep]->tbptr + CFG_IMMR);
-
- if(tx_cbdp->cbd_sc&TX_BD_R || usbp->usber&USB_E_TXB){
- mpc8xx_udc_flush_tx_fifo(ep);
+ tx_cbdp = (cbd_t *) (endpoints[ep]->tbptr + CFG_IMMR);
+
+ if (tx_cbdp->cbd_sc & TX_BD_R || usbp->usber & USB_E_TXB) {
+ mpc8xx_udc_flush_tx_fifo (ep);
usbp->usber |= USB_E_TXB;
};
- while(tx_retry++ < 100){
- ret = mpc8xx_udc_tx_irq(ep);
- if(ret == -1){
+ while (tx_retry++ < 100) {
+ ret = mpc8xx_udc_tx_irq (ep);
+ if (ret == -1) {
/* ignore timeout here */
- }else if(ret == -2){
+ } else if (ret == -2) {
/* Abandon TX */
- mpc8xx_udc_flush_tx_fifo(ep);
+ mpc8xx_udc_flush_tx_fifo (ep);
return -1;
- }
+ }
+
+ tx_cbdp = (cbd_t *) (endpoints[ep]->tbptr + CFG_IMMR);
+ while (tx_cbdp->cbd_sc & TX_BD_R) {
+ };
+ tx_cbdp->cbd_sc = (tx_cbdp->cbd_sc & TX_BD_W);
- tx_cbdp = (cbd_t*)(endpoints[ep]->tbptr + CFG_IMMR);
- while(tx_cbdp->cbd_sc&TX_BD_R){};
- tx_cbdp->cbd_sc = (tx_cbdp->cbd_sc&TX_BD_W);
-
pkt_len = urb->actual_length - epi->sent;
- if(pkt_len> epi->tx_packetSize || pkt_len > EP_MAX_PKT){
- pkt_len = MIN(epi->tx_packetSize, EP_MAX_PKT);
+ if (pkt_len > epi->tx_packetSize || pkt_len > EP_MAX_PKT) {
+ pkt_len = MIN (epi->tx_packetSize, EP_MAX_PKT);
}
- for(x=0; x<pkt_len; x++){
- *((unsigned char*)(tx_cbdp->cbd_bufaddr+x)) =
+ for (x = 0; x < pkt_len; x++) {
+ *((unsigned char *) (tx_cbdp->cbd_bufaddr + x)) =
urb->buffer[epi->sent + x];
}
tx_cbdp->cbd_datlen = pkt_len;
- tx_cbdp->cbd_sc|=(CBD_TX_BITMASK | ep_ref[ep].pid);
+ tx_cbdp->cbd_sc |= (CBD_TX_BITMASK | ep_ref[ep].pid);
__asm__ ("eieio");
- #ifdef __SIMULATE_ERROR__
- if(++err_poison_test == 2){
- err_poison_test = 0;
- tx_cbdp->cbd_sc&=~TX_BD_TC;
- }
- #endif
+#ifdef __SIMULATE_ERROR__
+ if (++err_poison_test == 2) {
+ err_poison_test = 0;
+ tx_cbdp->cbd_sc &= ~TX_BD_TC;
+ }
+#endif
- usbp->uscom = (USCOM_STR | ep);
+ usbp->uscom = (USCOM_STR | ep);
- while(!(usbp->usber&USB_E_TXB)){
- ret = mpc8xx_udc_tx_irq(ep);
- if(ret == -1){
+ while (!(usbp->usber & USB_E_TXB)) {
+ ret = mpc8xx_udc_tx_irq (ep);
+ if (ret == -1) {
/* TX timeout */
break;
- }else if(ret == -2){
- if(usbp->usber & USB_E_TXB){
- usbp->usber|=USB_E_TXB;
+ } else if (ret == -2) {
+ if (usbp->usber & USB_E_TXB) {
+ usbp->usber |= USB_E_TXB;
}
- mpc8xx_udc_flush_tx_fifo(ep);
+ mpc8xx_udc_flush_tx_fifo (ep);
return -1;
}
};
- if(usbp->usber & USB_E_TXB){
- usbp->usber|=USB_E_TXB;
+ if (usbp->usber & USB_E_TXB) {
+ usbp->usber |= USB_E_TXB;
}
/* ACK must be present <= 18bit times from TX */
- if(ret == -1){
+ if (ret == -1) {
continue;
}
-
+
/* TX ACK : USB 2.0 8.7.2, Toggle PID, Advance TX */
epi->sent += pkt_len;
- epi->last = MIN (urb->actual_length - epi->sent,
- epi->tx_packetSize);
- TOGGLE_TX_PID(ep_ref[ep].pid);
+ epi->last = MIN (urb->actual_length - epi->sent, epi->tx_packetSize);
+ TOGGLE_TX_PID (ep_ref[ep].pid);
+
+ if (epi->sent >= epi->tx_urb->actual_length) {
- if(epi->sent >= epi->tx_urb->actual_length){
-
epi->tx_urb->actual_length = 0;
epi->sent = 0;
-
- if(ep_ref[ep].sc & EP_SEND_ZLP){
+
+ if (ep_ref[ep].sc & EP_SEND_ZLP) {
ep_ref[ep].sc &= ~EP_SEND_ZLP;
- }else{
+ } else {
return 0;
}
}
}
-
- ERR("TX fail, endpoint 0x%x tx bytes 0x%x/0x%x\n",ep, epi->sent,
- epi->tx_urb->actual_length);
+
+ ERR ("TX fail, endpoint 0x%x tx bytes 0x%x/0x%x\n", ep, epi->sent,
+ epi->tx_urb->actual_length);
return -1;
}
@@ -983,126 +979,117 @@ static int mpc8xx_udc_ep_tx (struct usb_endpoint_instance *epi)
*
* Dump a control request to console
*/
-static void mpc8xx_udc_dump_request(struct usb_device_request *request)
+static void mpc8xx_udc_dump_request (struct usb_device_request *request)
{
- DBG(
- "bmRequestType:%02x bRequest:%02x wValue:%04x "
- "wIndex:%04x wLength:%04x ?\n",
- request->bmRequestType,
- request->bRequest,
- request->wValue,
- request->wIndex,
- request->wLength);
+ DBG ("bmRequestType:%02x bRequest:%02x wValue:%04x "
+ "wIndex:%04x wLength:%04x ?\n",
+ request->bmRequestType,
+ request->bRequest,
+ request->wValue, request->wIndex, request->wLength);
return;
}
-/* mpc8xx_udc_ep0_rx_setup
- *
+/* mpc8xx_udc_ep0_rx_setup
+ *
* Decode received ep0 SETUP packet. return non-zero on error
*/
static int mpc8xx_udc_ep0_rx_setup (volatile cbd_t * rx_cbdp)
{
unsigned int x = 0;
- struct urb * purb = ep_ref[0].urb;
- struct usb_endpoint_instance *epi =
+ struct urb *purb = ep_ref[0].urb;
+ struct usb_endpoint_instance *epi =
&udc_device->bus->endpoint_array[0];
- for(; x<rx_cbdp->cbd_datlen; x++){
- *(((unsigned char*)&ep_ref[0].urb->device_request)+x) =
- *((unsigned char*)(rx_cbdp->cbd_bufaddr+x));
+ for (; x < rx_cbdp->cbd_datlen; x++) {
+ *(((unsigned char *) &ep_ref[0].urb->device_request) + x) =
+ *((unsigned char *) (rx_cbdp->cbd_bufaddr + x));
}
-
- mpc8xx_udc_clear_rxbd(rx_cbdp);
- if (ep0_recv_setup(purb)) {
- mpc8xx_udc_dump_request(&purb->device_request);
+ mpc8xx_udc_clear_rxbd (rx_cbdp);
+
+ if (ep0_recv_setup (purb)) {
+ mpc8xx_udc_dump_request (&purb->device_request);
return -1;
}
- if ((purb->device_request.bmRequestType&USB_REQ_DIRECTION_MASK)
+ if ((purb->device_request.bmRequestType & USB_REQ_DIRECTION_MASK)
== USB_REQ_HOST2DEVICE) {
- switch (purb->device_request.bRequest){
- case USB_REQ_SET_ADDRESS:
- /* Send the Status OUT ZLP */
- ep_ref[0].pid = TX_BD_PID_DATA1;
- purb->actual_length = 0;
- mpc8xx_udc_init_tx(epi,purb);
- mpc8xx_udc_ep_tx(epi);
-
- /* Move to the addressed state */
- usbp->usaddr = udc_device->address;
- mpc8xx_udc_state_transition_up(udc_device->device_state,
- STATE_ADDRESSED);
- return 0;
-
- case USB_REQ_SET_CONFIGURATION:
- if(!purb->device_request.wValue){
-
- /* Respond at default address */
- usbp->usaddr = 0x00;
- mpc8xx_udc_state_transition_down(udc_device->device_state,
- STATE_ADDRESSED);
-
- } else {
-
- /* TODO: Support multiple configurations */
- mpc8xx_udc_state_transition_up(udc_device->device_state,STATE_CONFIGURED);
- for(x=1; x<MAX_ENDPOINTS; x++){
- if((udc_device->bus->endpoint_array[x].endpoint_address&USB_ENDPOINT_DIR_MASK)
- == USB_DIR_IN){
- ep_ref[x].pid = TX_BD_PID_DATA0;
- }else{
- ep_ref[x].pid = RX_BD_PID_DATA0;
- }
- /* Set configuration must unstall endpoints */
- usbp->usep[x]&=~STALL_BITMASK;
+ switch (purb->device_request.bRequest) {
+ case USB_REQ_SET_ADDRESS:
+ /* Send the Status OUT ZLP */
+ ep_ref[0].pid = TX_BD_PID_DATA1;
+ purb->actual_length = 0;
+ mpc8xx_udc_init_tx (epi, purb);
+ mpc8xx_udc_ep_tx (epi);
+
+ /* Move to the addressed state */
+ usbp->usaddr = udc_device->address;
+ mpc8xx_udc_state_transition_up (udc_device->device_state,
+ STATE_ADDRESSED);
+ return 0;
+
+ case USB_REQ_SET_CONFIGURATION:
+ if (!purb->device_request.wValue) {
+ /* Respond at default address */
+ usbp->usaddr = 0x00;
+ mpc8xx_udc_state_transition_down (udc_device->device_state,
+ STATE_ADDRESSED);
+ } else {
+ /* TODO: Support multiple configurations */
+ mpc8xx_udc_state_transition_up (udc_device->device_state,
+ STATE_CONFIGURED);
+ for (x = 1; x < MAX_ENDPOINTS; x++) {
+ if ((udc_device->bus->endpoint_array[x].endpoint_address & USB_ENDPOINT_DIR_MASK)
+ == USB_DIR_IN) {
+ ep_ref[x].pid = TX_BD_PID_DATA0;
+ } else {
+ ep_ref[x].pid = RX_BD_PID_DATA0;
}
-
+ /* Set configuration must unstall endpoints */
+ usbp->usep[x] &= ~STALL_BITMASK;
}
- break;
- default:
- /* CDC/Vendor specific */
- break;
+ }
+ break;
+ default:
+ /* CDC/Vendor specific */
+ break;
}
/* Send ZLP as ACK in Status OUT phase */
ep_ref[0].pid = TX_BD_PID_DATA1;
purb->actual_length = 0;
- mpc8xx_udc_init_tx(epi,purb);
- mpc8xx_udc_ep_tx(epi);
+ mpc8xx_udc_init_tx (epi, purb);
+ mpc8xx_udc_ep_tx (epi);
- }else{
- if(purb->actual_length){
+ } else {
+
+ if (purb->actual_length) {
ep_ref[0].pid = TX_BD_PID_DATA1;
- mpc8xx_udc_init_tx(epi,purb);
+ mpc8xx_udc_init_tx (epi, purb);
- if(!(purb->actual_length%EP0_MAX_PACKET_SIZE)){
+ if (!(purb->actual_length % EP0_MAX_PACKET_SIZE)) {
ep_ref[0].sc |= EP_SEND_ZLP;
}
- if(purb->device_request.wValue==
- USB_DESCRIPTOR_TYPE_DEVICE){
- if(le16_to_cpu(purb->device_request.wLength)>
- purb->actual_length){
+ if (purb->device_request.wValue ==
+ USB_DESCRIPTOR_TYPE_DEVICE) {
+ if (le16_to_cpu (purb->device_request.wLength)
+ > purb->actual_length) {
/* Send EP0_MAX_PACKET_SIZE bytes
* unless correct size requested.
*/
- if(purb->actual_length >
- epi->tx_packetSize){
-
- purb->actual_length =
- epi->tx_packetSize;
+ if (purb->actual_length > epi->tx_packetSize) {
+ purb->actual_length = epi->tx_packetSize;
}
-
}
}
- mpc8xx_udc_ep_tx(epi);
+ mpc8xx_udc_ep_tx (epi);
- }else{
+ } else {
/* Corrupt SETUP packet? */
- ERR("Zero length data or SETUP with DATA-IN phase ?\n");
+ ERR ("Zero length data or SETUP with DATA-IN phase ?\n");
return 1;
}
}
@@ -1113,8 +1100,8 @@ static int mpc8xx_udc_ep0_rx_setup (volatile cbd_t * rx_cbdp)
*
* Setup some basic parameters for a TX transaction
*/
-static void mpc8xx_udc_init_tx(struct usb_endpoint_instance *epi,
- struct urb * tx_urb)
+static void mpc8xx_udc_init_tx (struct usb_endpoint_instance *epi,
+ struct urb *tx_urb)
{
epi->sent = 0;
epi->last = 0;
@@ -1125,24 +1112,24 @@ static void mpc8xx_udc_init_tx(struct usb_endpoint_instance *epi,
*
* Receive ep0/control USB data. Parse and possibly send a response.
*/
-static void mpc8xx_udc_ep0_rx(volatile cbd_t * rx_cbdp)
+static void mpc8xx_udc_ep0_rx (volatile cbd_t * rx_cbdp)
{
- if(rx_cbdp->cbd_sc&RX_BD_PID_SETUP){
-
+ if (rx_cbdp->cbd_sc & RX_BD_PID_SETUP) {
+
/* Unconditionally accept SETUP packets */
- if(mpc8xx_udc_ep0_rx_setup(rx_cbdp)){
- mpc8xx_udc_stall (0);
+ if (mpc8xx_udc_ep0_rx_setup (rx_cbdp)) {
+ mpc8xx_udc_stall (0);
}
-
+
} else {
-
- mpc8xx_udc_clear_rxbd(rx_cbdp);
-
- if((rx_cbdp->cbd_datlen-2)){
+
+ mpc8xx_udc_clear_rxbd (rx_cbdp);
+
+ if ((rx_cbdp->cbd_datlen - 2)) {
/* SETUP with a DATA phase
- * outside of SETUP packet.
- * Reply with STALL.
- */
+ * outside of SETUP packet.
+ * Reply with STALL.
+ */
mpc8xx_udc_stall (0);
}
}
@@ -1151,7 +1138,7 @@ static void mpc8xx_udc_ep0_rx(volatile cbd_t * rx_cbdp)
/* mpc8xx_udc_epn_rx
*
* Receive some data from cbd into USB system urb data abstraction
- * Upper layers should NAK if there is insufficient RX data space
+ * Upper layers should NAK if there is insufficient RX data space
*/
static int mpc8xx_udc_epn_rx (unsigned int epid, volatile cbd_t * rx_cbdp)
{
@@ -1159,115 +1146,115 @@ static int mpc8xx_udc_epn_rx (unsigned int epid, volatile cbd_t * rx_cbdp)
struct urb *urb = 0;
unsigned int x = 0;
- if(epid >= MAX_ENDPOINTS || !rx_cbdp->cbd_datlen){
+ if (epid >= MAX_ENDPOINTS || !rx_cbdp->cbd_datlen) {
return 0;
}
-
- /* USB 2.0 PDF section 8.6.4
+
+ /* USB 2.0 PDF section 8.6.4
* Discard data with invalid PID it is a resend.
*/
- if(ep_ref[epid].pid!=(rx_cbdp->cbd_sc&0xC0)){
+ if (ep_ref[epid].pid != (rx_cbdp->cbd_sc & 0xC0)) {
return 1;
}
- TOGGLE_RX_PID(ep_ref[epid].pid);
-
+ TOGGLE_RX_PID (ep_ref[epid].pid);
+
epi = &udc_device->bus->endpoint_array[epid];
urb = epi->rcv_urb;
- for(; x<(rx_cbdp->cbd_datlen-2); x++){
- *((unsigned char*)(urb->buffer + urb->actual_length +x)) =
- *((unsigned char*)(rx_cbdp->cbd_bufaddr+x));
+ for (; x < (rx_cbdp->cbd_datlen - 2); x++) {
+ *((unsigned char *) (urb->buffer + urb->actual_length + x)) =
+ *((unsigned char *) (rx_cbdp->cbd_bufaddr + x));
}
- if(x){
+ if (x) {
usbd_rcv_complete (epi, x, 0);
- if(ep_ref[epid].urb->status == RECV_ERROR){
- DBG("RX error unset NAK\n");
- udc_unset_nak(epid);
+ if (ep_ref[epid].urb->status == RECV_ERROR) {
+ DBG ("RX error unset NAK\n");
+ udc_unset_nak (epid);
}
- }
+ }
return x;
}
/* mpc8xx_udc_clock_init
*
- * Obtain a clock reference for Full Speed Signaling
+ * Obtain a clock reference for Full Speed Signaling
*/
-static void mpc8xx_udc_clock_init (volatile immap_t * immr,
- volatile cpm8xx_t * cp)
+static void mpc8xx_udc_clock_init (volatile immap_t * immr,
+ volatile cpm8xx_t * cp)
{
#if defined(CFG_USB_EXTC_CLK)
/* This has been tested with a 48MHz crystal on CLK6 */
- switch(CFG_USB_EXTC_CLK){
- case 1:
- immr->im_ioport.iop_papar|= 0x0100;
- immr->im_ioport.iop_padir&= ~0x0100;
- cp->cp_sicr|= 0x24;
- break;
- case 2:
- immr->im_ioport.iop_papar|= 0x0200;
- immr->im_ioport.iop_padir&= ~0x0200;
- cp->cp_sicr|= 0x2D;
- break;
- case 3:
- immr->im_ioport.iop_papar|= 0x0400;
- immr->im_ioport.iop_padir&= ~0x0400;
- cp->cp_sicr|= 0x36;
- break;
- case 4:
- immr->im_ioport.iop_papar|= 0x0800;
- immr->im_ioport.iop_padir&= ~0x0800;
- cp->cp_sicr|= 0x3F;
- break;
- default:
- udc_state = STATE_ERROR;
- break;
+ switch (CFG_USB_EXTC_CLK) {
+ case 1:
+ immr->im_ioport.iop_papar |= 0x0100;
+ immr->im_ioport.iop_padir &= ~0x0100;
+ cp->cp_sicr |= 0x24;
+ break;
+ case 2:
+ immr->im_ioport.iop_papar |= 0x0200;
+ immr->im_ioport.iop_padir &= ~0x0200;
+ cp->cp_sicr |= 0x2D;
+ break;
+ case 3:
+ immr->im_ioport.iop_papar |= 0x0400;
+ immr->im_ioport.iop_padir &= ~0x0400;
+ cp->cp_sicr |= 0x36;
+ break;
+ case 4:
+ immr->im_ioport.iop_papar |= 0x0800;
+ immr->im_ioport.iop_padir &= ~0x0800;
+ cp->cp_sicr |= 0x3F;
+ break;
+ default:
+ udc_state = STATE_ERROR;
+ break;
}
#elif defined(CFG_USB_BRGCLK)
- /* This has been tested with brgclk == 50MHz */
+ /* This has been tested with brgclk == 50MHz */
DECLARE_GLOBAL_DATA_PTR;
int divisor = 0;
- if(gd->cpu_clk<48000000L){
- ERR("brgclk is too slow for full-speed USB!\n");
+ if (gd->cpu_clk < 48000000L) {
+ ERR ("brgclk is too slow for full-speed USB!\n");
udc_state = STATE_ERROR;
return;
}
/* Assume the brgclk is 'good enough', we want !(gd->cpu_clk%48Mhz)
* but, can /probably/ live with close-ish alternative rates.
- */
- divisor = (gd->cpu_clk/48000000L)-1;
+ */
+ divisor = (gd->cpu_clk / 48000000L) - 1;
cp->cp_sicr &= ~0x0000003F;
-
- switch(CFG_USB_BRGCLK){
- case 1:
- cp->cp_brgc1 |= (divisor|CPM_BRG_EN);
- cp->cp_sicr &= ~0x2F;
- break;
- case 2:
- cp->cp_brgc2 |= (divisor|CPM_BRG_EN);
- cp->cp_sicr |= 0x00000009;
- break;
- case 3:
- cp->cp_brgc3 |= (divisor|CPM_BRG_EN);
- cp->cp_sicr |= 0x00000012;
- break;
- case 4:
- cp->cp_brgc4 = (divisor|CPM_BRG_EN);
- cp->cp_sicr |= 0x0000001B;
- break;
- default:
- udc_state = STATE_ERROR;
- break;
+
+ switch (CFG_USB_BRGCLK) {
+ case 1:
+ cp->cp_brgc1 |= (divisor | CPM_BRG_EN);
+ cp->cp_sicr &= ~0x2F;
+ break;
+ case 2:
+ cp->cp_brgc2 |= (divisor | CPM_BRG_EN);
+ cp->cp_sicr |= 0x00000009;
+ break;
+ case 3:
+ cp->cp_brgc3 |= (divisor | CPM_BRG_EN);
+ cp->cp_sicr |= 0x00000012;
+ break;
+ case 4:
+ cp->cp_brgc4 = (divisor | CPM_BRG_EN);
+ cp->cp_sicr |= 0x0000001B;
+ break;
+ default:
+ udc_state = STATE_ERROR;
+ break;
}
#else
- #error "CFG_USB_EXTC_CLK or CFG_USB_BRGCLK must be defined"
+#error "CFG_USB_EXTC_CLK or CFG_USB_BRGCLK must be defined"
#endif
}
@@ -1278,51 +1265,51 @@ static void mpc8xx_udc_clock_init (volatile immap_t * immr,
*/
static void mpc8xx_udc_cbd_attach (int ep, uchar tx_size, uchar rx_size)
{
-
- if (!tx_cbd[ep] || !rx_cbd[ep] || ep >= MAX_ENDPOINTS){
+
+ if (!tx_cbd[ep] || !rx_cbd[ep] || ep >= MAX_ENDPOINTS) {
udc_state = STATE_ERROR;
return;
}
- if (tx_size>USB_MAX_PKT || rx_size>USB_MAX_PKT ||
- (!tx_size && !rx_size)){
+ if (tx_size > USB_MAX_PKT || rx_size > USB_MAX_PKT ||
+ (!tx_size && !rx_size)) {
udc_state = STATE_ERROR;
return;
}
/* Attach CBD to appropiate Parameter RAM Endpoint data structure */
- if(rx_size){
- endpoints[ep]->rbase = (u32)rx_cbd[rx_ct];
- endpoints[ep]->rbptr = (u32)rx_cbd[rx_ct];
+ if (rx_size) {
+ endpoints[ep]->rbase = (u32) rx_cbd[rx_ct];
+ endpoints[ep]->rbptr = (u32) rx_cbd[rx_ct];
rx_ct++;
- if(!ep){
-
- endpoints[ep]->rbptr = (u32)rx_cbd[rx_ct];
+ if (!ep) {
+
+ endpoints[ep]->rbptr = (u32) rx_cbd[rx_ct];
rx_cbd[rx_ct]->cbd_sc |= RX_BD_W;
rx_ct++;
- }else{
+ } else {
rx_ct += 2;
- endpoints[ep]->rbptr = (u32)rx_cbd[rx_ct];
+ endpoints[ep]->rbptr = (u32) rx_cbd[rx_ct];
rx_cbd[rx_ct]->cbd_sc |= RX_BD_W;
rx_ct++;
}
/* Where we expect to RX data on this endpoint */
- ep_ref[ep].prx = rx_cbd[rx_ct-1];
- }else{
+ ep_ref[ep].prx = rx_cbd[rx_ct - 1];
+ } else {
ep_ref[ep].prx = 0;
endpoints[ep]->rbase = 0;
endpoints[ep]->rbptr = 0;
}
- if(tx_size){
- endpoints[ep]->tbase = (u32)tx_cbd[tx_ct];
- endpoints[ep]->tbptr = (u32)tx_cbd[tx_ct];
+ if (tx_size) {
+ endpoints[ep]->tbase = (u32) tx_cbd[tx_ct];
+ endpoints[ep]->tbptr = (u32) tx_cbd[tx_ct];
tx_ct++;
- }else{
+ } else {
endpoints[ep]->tbase = 0;
endpoints[ep]->tbptr = 0;
}
@@ -1330,13 +1317,14 @@ static void mpc8xx_udc_cbd_attach (int ep, uchar tx_size, uchar rx_size)
endpoints[ep]->tstate = 0;
endpoints[ep]->tbcnt = 0;
endpoints[ep]->mrblr = EP_MAX_PKT;
- endpoints[ep]->rfcr = 0x18;
+ endpoints[ep]->rfcr = 0x18;
endpoints[ep]->tfcr = 0x18;
ep_ref[ep].sc |= EP_ATTACHED;
- DBG("ep %d rbase 0x%08x rbptr 0x%08x tbase 0x%08x tbptr 0x%08x prx = %p\n",
- ep, endpoints[ep]->rbase, endpoints[ep]->rbptr, endpoints[ep]->tbase,
- endpoints[ep]->tbptr, ep_ref[ep].prx);
+ DBG ("ep %d rbase 0x%08x rbptr 0x%08x tbase 0x%08x tbptr 0x%08x prx = %p\n",
+ ep, endpoints[ep]->rbase, endpoints[ep]->rbptr,
+ endpoints[ep]->tbase, endpoints[ep]->tbptr,
+ ep_ref[ep].prx);
return;
}
@@ -1349,28 +1337,28 @@ static void mpc8xx_udc_cbd_init (void)
{
int i = 0;
- for(; i<TX_RING_SIZE; i++){
- tx_cbd[i]= (cbd_t*)
- mpc8xx_udc_alloc(sizeof(cbd_t), sizeof(int));
+ for (; i < TX_RING_SIZE; i++) {
+ tx_cbd[i] = (cbd_t *)
+ mpc8xx_udc_alloc (sizeof (cbd_t), sizeof (int));
+ }
+
+ for (i = 0; i < RX_RING_SIZE; i++) {
+ rx_cbd[i] = (cbd_t *)
+ mpc8xx_udc_alloc (sizeof (cbd_t), sizeof (int));
}
- for(i=0; i<RX_RING_SIZE; i++){
- rx_cbd[i]= (cbd_t*)
- mpc8xx_udc_alloc(sizeof(cbd_t),sizeof(int));
- }
+ for (i = 0; i < TX_RING_SIZE; i++) {
+ tx_cbd[i]->cbd_bufaddr =
+ mpc8xx_udc_alloc (EP_MAX_PKT, sizeof (int));
- for(i=0; i< TX_RING_SIZE; i++){
- tx_cbd[i]->cbd_bufaddr =
- mpc8xx_udc_alloc(EP_MAX_PKT, sizeof(int));
-
- tx_cbd[i]->cbd_sc = (TX_BD_I | TX_BD_W);
+ tx_cbd[i]->cbd_sc = (TX_BD_I | TX_BD_W);
tx_cbd[i]->cbd_datlen = 0x0000;
}
- for(i=0; i< RX_RING_SIZE; i++){
- rx_cbd[i]->cbd_bufaddr =
- mpc8xx_udc_alloc(EP_MAX_PKT, sizeof(int));
+ for (i = 0; i < RX_RING_SIZE; i++) {
+ rx_cbd[i]->cbd_bufaddr =
+ mpc8xx_udc_alloc (EP_MAX_PKT, sizeof (int));
rx_cbd[i]->cbd_sc = (RX_BD_I | RX_BD_E);
rx_cbd[i]->cbd_datlen = 0x0000;
@@ -1387,25 +1375,25 @@ static void mpc8xx_udc_endpoint_init (void)
{
int i = 0;
- for(; i<MAX_ENDPOINTS; i++){
- endpoints[i]= (usb_epb_t*)
- mpc8xx_udc_alloc(sizeof(usb_epb_t) , 32);
+ for (; i < MAX_ENDPOINTS; i++) {
+ endpoints[i] = (usb_epb_t *)
+ mpc8xx_udc_alloc (sizeof (usb_epb_t), 32);
}
}
/* mpc8xx_udc_alloc
*
- * Grab the address of some dpram
+ * Grab the address of some dpram
*/
static u32 mpc8xx_udc_alloc (u32 data_size, u32 alignment)
{
u32 retaddr = address_base;
-
- while(retaddr%alignment){
+
+ while (retaddr % alignment) {
retaddr++;
- }
- address_base+= data_size;
-
+ }
+ address_base += data_size;
+
return retaddr;
}
diff --git a/drivers/usbdcore_omap1510.c b/drivers/usbdcore_omap1510.c
index 83d898f..84bb936 100644
--- a/drivers/usbdcore_omap1510.c
+++ b/drivers/usbdcore_omap1510.c
@@ -645,7 +645,7 @@ static void omap1510_udc_state_changed (void)
static void omap1510_udc_setup (struct usb_endpoint_instance *endpoint)
{
UDCDBG ("-> Entering device setup");
-
+
do {
const int setup_pktsize = 8;
unsigned char *datap =
@@ -1518,7 +1518,7 @@ void udc_startup_events (struct usb_device_instance *device)
}
/**
- * udc_irq - do pseudo interrupts
+ * udc_irq - do pseudo interrupts
*/
void udc_irq(void)
{
diff --git a/drivers/usbtty.c b/drivers/usbtty.c
index ed96999..d41a00b 100644
--- a/drivers/usbtty.c
+++ b/drivers/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
*
@@ -31,7 +31,7 @@
#include "usb_cdc_acm.h"
#include "usbdescriptors.h"
#include <config.h> /* If defined, override Linux identifiers with
- * vendor specific ones */
+ * vendor specific ones */
#if 0
#define TTYDBG(fmt,args...)\
@@ -142,10 +142,10 @@ static struct usb_device_descriptor device_descriptor = {
struct acm_config_desc {
struct usb_configuration_descriptor configuration_desc;
-
+
/* Master Interface */
struct usb_interface_descriptor interface_desc;
-
+
struct usb_class_header_function_descriptor usb_class_header;
struct usb_class_call_management_descriptor usb_class_call_mgt;
struct usb_class_abstract_control_descriptor usb_class_acm;
@@ -154,22 +154,22 @@ struct acm_config_desc {
/* Slave Interface */
struct usb_interface_descriptor data_class_interface;
- struct usb_endpoint_descriptor
+ struct usb_endpoint_descriptor
data_endpoints[NUM_ENDPOINTS-1] __attribute__((packed));
} __attribute__((packed));
static struct acm_config_desc acm_configuration_descriptors[NUM_CONFIGS] = {
{
.configuration_desc ={
- .bLength =
+ .bLength =
sizeof(struct usb_configuration_descriptor),
.bDescriptorType = USB_DT_CONFIG,
- .wTotalLength =
+ .wTotalLength =
cpu_to_le16(sizeof(struct acm_config_desc)),
.bNumInterfaces = NUM_ACM_INTERFACES,
.bConfigurationValue = 1,
.iConfiguration = STR_CONFIG,
- .bmAttributes =
+ .bmAttributes =
BMATTRIBUTE_SELF_POWERED|BMATTRIBUTE_RESERVED,
.bMaxPower = USBTTY_MAXPOWER
},
@@ -180,62 +180,62 @@ static struct acm_config_desc acm_configuration_descriptors[NUM_CONFIGS] = {
.bInterfaceNumber = 0,
.bAlternateSetting = 0,
.bNumEndpoints = 0x01,
- .bInterfaceClass =
+ .bInterfaceClass =
COMMUNICATIONS_INTERFACE_CLASS_CONTROL,
.bInterfaceSubClass = COMMUNICATIONS_ACM_SUBCLASS,
.bInterfaceProtocol = COMMUNICATIONS_V25TER_PROTOCOL,
.iInterface = STR_CTRL_INTERFACE,
},
.usb_class_header = {
- .bFunctionLength =
+ .bFunctionLength =
sizeof(struct usb_class_header_function_descriptor),
- .bDescriptorType = CS_INTERFACE,
+ .bDescriptorType = CS_INTERFACE,
.bDescriptorSubtype = USB_ST_HEADER,
.bcdCDC = cpu_to_le16(110),
},
.usb_class_call_mgt = {
- .bFunctionLength =
+ .bFunctionLength =
sizeof(struct usb_class_call_management_descriptor),
.bDescriptorType = CS_INTERFACE,
.bDescriptorSubtype = USB_ST_CMF,
- .bmCapabilities = 0x00,
- .bDataInterface = 0x01,
+ .bmCapabilities = 0x00,
+ .bDataInterface = 0x01,
},
.usb_class_acm = {
- .bFunctionLength =
+ .bFunctionLength =
sizeof(struct usb_class_abstract_control_descriptor),
.bDescriptorType = CS_INTERFACE,
- .bDescriptorSubtype = USB_ST_ACMF,
- .bmCapabilities = 0x00,
+ .bDescriptorSubtype = USB_ST_ACMF,
+ .bmCapabilities = 0x00,
},
.usb_class_union = {
- .bFunctionLength =
+ .bFunctionLength =
sizeof(struct usb_class_union_function_descriptor),
.bDescriptorType = CS_INTERFACE,
.bDescriptorSubtype = USB_ST_UF,
- .bMasterInterface = 0x00,
- .bSlaveInterface0 = 0x01,
+ .bMasterInterface = 0x00,
+ .bSlaveInterface0 = 0x01,
},
.notification_endpoint = {
- .bLength =
+ .bLength =
sizeof(struct usb_endpoint_descriptor),
.bDescriptorType = USB_DT_ENDPOINT,
.bEndpointAddress = 0x01 | USB_DIR_IN,
.bmAttributes = USB_ENDPOINT_XFER_INT,
- .wMaxPacketSize
+ .wMaxPacketSize
= cpu_to_le16(CONFIG_USBD_SERIAL_INT_PKTSIZE),
.bInterval = 0xFF,
},
/* Interface 2 */
.data_class_interface = {
- .bLength =
+ .bLength =
sizeof(struct usb_interface_descriptor),
.bDescriptorType = USB_DT_INTERFACE,
.bInterfaceNumber = 0x01,
.bAlternateSetting = 0x00,
.bNumEndpoints = 0x02,
- .bInterfaceClass =
+ .bInterfaceClass =
COMMUNICATIONS_INTERFACE_CLASS_DATA,
.bInterfaceSubClass = DATA_INTERFACE_SUBCLASS_NONE,
.bInterfaceProtocol = DATA_INTERFACE_PROTOCOL_NONE,
@@ -243,30 +243,30 @@ static struct acm_config_desc acm_configuration_descriptors[NUM_CONFIGS] = {
},
.data_endpoints = {
{
- .bLength =
+ .bLength =
sizeof(struct usb_endpoint_descriptor),
.bDescriptorType = USB_DT_ENDPOINT,
.bEndpointAddress = 0x02 | USB_DIR_OUT,
- .bmAttributes =
+ .bmAttributes =
USB_ENDPOINT_XFER_BULK,
- .wMaxPacketSize =
+ .wMaxPacketSize =
cpu_to_le16(CONFIG_USBD_SERIAL_BULK_PKTSIZE),
.bInterval = 0xFF,
},
{
- .bLength =
+ .bLength =
sizeof(struct usb_endpoint_descriptor),
.bDescriptorType = USB_DT_ENDPOINT,
.bEndpointAddress = 0x03 | USB_DIR_IN,
- .bmAttributes =
+ .bmAttributes =
USB_ENDPOINT_XFER_BULK,
- .wMaxPacketSize =
+ .wMaxPacketSize =
cpu_to_le16(CONFIG_USBD_SERIAL_BULK_PKTSIZE),
.bInterval = 0xFF,
},
},
},
-};
+};
static struct rs232_emu rs232_desc={
.dter = 115200,
@@ -282,75 +282,75 @@ static struct rs232_emu rs232_desc={
struct gserial_config_desc {
-
+
struct usb_configuration_descriptor configuration_desc;
- struct usb_interface_descriptor
+ struct usb_interface_descriptor
interface_desc[NUM_GSERIAL_INTERFACES] __attribute__((packed));
- struct usb_endpoint_descriptor
+ struct usb_endpoint_descriptor
data_endpoints[NUM_ENDPOINTS] __attribute__((packed));
} __attribute__((packed));
-static struct gserial_config_desc
+static struct gserial_config_desc
gserial_configuration_descriptors[NUM_CONFIGS] ={
{
.configuration_desc ={
.bLength = sizeof(struct usb_configuration_descriptor),
.bDescriptorType = USB_DT_CONFIG,
- .wTotalLength =
+ .wTotalLength =
cpu_to_le16(sizeof(struct gserial_config_desc)),
.bNumInterfaces = NUM_GSERIAL_INTERFACES,
.bConfigurationValue = 1,
.iConfiguration = STR_CONFIG,
- .bmAttributes =
+ .bmAttributes =
BMATTRIBUTE_SELF_POWERED|BMATTRIBUTE_RESERVED,
.bMaxPower = USBTTY_MAXPOWER
},
.interface_desc = {
{
- .bLength =
+ .bLength =
sizeof(struct usb_interface_descriptor),
.bDescriptorType = USB_DT_INTERFACE,
.bInterfaceNumber = 0,
.bAlternateSetting = 0,
.bNumEndpoints = NUM_ENDPOINTS,
- .bInterfaceClass =
+ .bInterfaceClass =
COMMUNICATIONS_INTERFACE_CLASS_VENDOR,
- .bInterfaceSubClass =
+ .bInterfaceSubClass =
COMMUNICATIONS_NO_SUBCLASS,
- .bInterfaceProtocol =
+ .bInterfaceProtocol =
COMMUNICATIONS_NO_PROTOCOL,
.iInterface = STR_DATA_INTERFACE
},
},
.data_endpoints = {
{
- .bLength =
+ .bLength =
sizeof(struct usb_endpoint_descriptor),
.bDescriptorType = USB_DT_ENDPOINT,
.bEndpointAddress = 0x01 | USB_DIR_OUT,
.bmAttributes = USB_ENDPOINT_XFER_BULK,
- .wMaxPacketSize =
+ .wMaxPacketSize =
cpu_to_le16(CONFIG_USBD_SERIAL_OUT_PKTSIZE),
.bInterval= 0xFF,
},
{
- .bLength =
+ .bLength =
sizeof(struct usb_endpoint_descriptor),
.bDescriptorType = USB_DT_ENDPOINT,
.bEndpointAddress = 0x02 | USB_DIR_IN,
.bmAttributes = USB_ENDPOINT_XFER_BULK,
- .wMaxPacketSize =
+ .wMaxPacketSize =
cpu_to_le16(CONFIG_USBD_SERIAL_IN_PKTSIZE),
.bInterval = 0xFF,
},
{
- .bLength =
+ .bLength =
sizeof(struct usb_endpoint_descriptor),
.bDescriptorType = USB_DT_ENDPOINT,
.bEndpointAddress = 0x03 | USB_DIR_IN,
.bmAttributes = USB_ENDPOINT_XFER_INT,
- .wMaxPacketSize =
+ .wMaxPacketSize =
cpu_to_le16(CONFIG_USBD_SERIAL_INT_PKTSIZE),
.bInterval = 0xFF,
},
@@ -368,7 +368,7 @@ static void usbtty_init_endpoints (void);
static void usbtty_init_terminal_type(short type);
static void usbtty_event_handler (struct usb_device_instance *device,
usb_device_event_t event, int data);
-static int usbtty_cdc_setup(struct usb_device_request *request,
+static int usbtty_cdc_setup(struct usb_device_request *request,
struct urb *urb);
static int usbtty_configured (void);
static int write_buffer (circbuf_t * buf);
@@ -477,12 +477,12 @@ static void __usbtty_puts (const char *str, int len)
/* Empty buffer here, if needed, to ensure space... */
if (space) {
write_buffer (&usbtty_output);
-
+
n = MIN (space, MIN (len, maxlen));
buf_push (&usbtty_output, str, n);
str += n;
- len -= n;
+ len -= n;
}
}
}
@@ -543,7 +543,7 @@ int drv_usbtty_init (void)
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);
@@ -579,7 +579,7 @@ static void usbtty_init_strings (void)
{
struct usb_string_descriptor *string;
- usbtty_string_table[STR_LANG] =
+ usbtty_string_table[STR_LANG] =
(struct usb_string_descriptor*)wstrLang;
string = (struct usb_string_descriptor *) wstrManufacturer;
@@ -624,7 +624,7 @@ static void usbtty_init_strings (void)
/* Now, initialize the string table for ep0 handling */
usb_strings = usbtty_string_table;
-}
+}
static void usbtty_init_instances (void)
{
@@ -690,7 +690,7 @@ static void usbtty_init_instances (void)
endpoint_instance[i].rcv_packetSize =
le16_to_cpu(ep_descriptor_ptrs[i - 1]->wMaxPacketSize);
-
+
endpoint_instance[i].tx_attributes =
ep_descriptor_ptrs[i - 1]->bmAttributes;
@@ -721,30 +721,30 @@ static void usbtty_init_endpoints (void)
int i;
bus_instance->max_endpoints = NUM_ENDPOINTS + 1;
- for (i = 1; i <= NUM_ENDPOINTS; i++) {
+ for (i = 1; i <= NUM_ENDPOINTS; i++) {
udc_setup_ep (device_instance, i, &endpoint_instance[i]);
}
}
/* usbtty_init_terminal_type
- *
+ *
* Do some late binding for our device type.
*/
static void usbtty_init_terminal_type(short type)
{
switch(type){
- /* CDC ACM */
+ /* CDC ACM */
case 0:
/* Assign endpoint descriptors */
- ep_descriptor_ptrs[0] =
+ ep_descriptor_ptrs[0] =
&acm_configuration_descriptors[0].notification_endpoint;
- ep_descriptor_ptrs[1] =
+ ep_descriptor_ptrs[1] =
&acm_configuration_descriptors[0].data_endpoints[0];
- ep_descriptor_ptrs[2] =
+ ep_descriptor_ptrs[2] =
&acm_configuration_descriptors[0].data_endpoints[1];
/* Enumerate Device Descriptor */
- device_descriptor.bDeviceClass =
+ device_descriptor.bDeviceClass =
COMMUNICATIONS_DEVICE_CLASS;
device_descriptor.idProduct =
cpu_to_le16(CONFIG_USBD_PRODUCTID_CDCACM);
@@ -752,7 +752,7 @@ static void usbtty_init_terminal_type(short type)
/* Assign endpoint indices */
tx_endpoint = ACM_TX_ENDPOINT;
rx_endpoint = ACM_RX_ENDPOINT;
-
+
/* Configuration Descriptor */
configuration_descriptor =
(struct usb_configuration_descriptor*)
@@ -766,11 +766,11 @@ static void usbtty_init_terminal_type(short type)
case 1:
default:
/* Assign endpoint descriptors */
- ep_descriptor_ptrs[0] =
+ ep_descriptor_ptrs[0] =
&gserial_configuration_descriptors[0].data_endpoints[0];
- ep_descriptor_ptrs[1] =
+ ep_descriptor_ptrs[1] =
&gserial_configuration_descriptors[0].data_endpoints[1];
- ep_descriptor_ptrs[2] =
+ ep_descriptor_ptrs[2] =
&gserial_configuration_descriptors[0].data_endpoints[2];
/* Enumerate Device Descriptor */
@@ -783,7 +783,7 @@ static void usbtty_init_terminal_type(short type)
rx_endpoint = GSERIAL_RX_ENDPOINT;
/* Configuration Descriptor */
- configuration_descriptor =
+ configuration_descriptor =
(struct usb_configuration_descriptor*)
&gserial_configuration_descriptors;
@@ -832,14 +832,14 @@ static int write_buffer (circbuf_t * buf)
if (!usbtty_configured ()) {
return 0;
}
-
+
struct usb_endpoint_instance *endpoint =
&endpoint_instance[tx_endpoint];
struct urb *current_urb = NULL;
current_urb = next_urb (device_instance, endpoint);
- /* TX data still exists - send it now
- */
+ /* TX data still exists - send it now
+ */
if(endpoint->sent < current_urb->actual_length){
if(udc_endpoint_write (endpoint)){
/* Write pre-empted by RX */
@@ -854,11 +854,11 @@ static int write_buffer (circbuf_t * buf)
int popnum, popped;
int total = 0;
- /* Break buffer into urb sized pieces,
- * and link each to the endpoint
+ /* Break buffer into urb sized pieces,
+ * and link each to the endpoint
*/
while (buf->size > 0) {
-
+
if (!current_urb) {
TTYERR ("current_urb is NULL, buf->size %d\n",
buf->size);
@@ -881,8 +881,8 @@ static int write_buffer (circbuf_t * buf)
current_urb->actual_length += popped;
total += popped;
- /* If endpoint->last == 0, then transfers have
- * not started on this endpoint
+ /* If endpoint->last == 0, then transfers have
+ * not started on this endpoint
*/
if (endpoint->last == 0) {
if(udc_endpoint_write (endpoint)){
@@ -904,7 +904,7 @@ static int fill_buffer (circbuf_t * buf)
&endpoint_instance[rx_endpoint];
if (endpoint->rcv_urb && endpoint->rcv_urb->actual_length) {
- unsigned int nb = 0;
+ unsigned int nb = 0;
char *src = (char *) endpoint->rcv_urb->buffer;
unsigned int rx_avail = buf->totalsize - buf->size;
@@ -913,7 +913,7 @@ static int fill_buffer (circbuf_t * buf)
nb = endpoint->rcv_urb->actual_length;
buf_push (buf, src, nb);
endpoint->rcv_urb->actual_length = 0;
-
+
}
return nb;
}
@@ -958,7 +958,7 @@ int usbtty_cdc_setup(struct usb_device_request *request, struct urb *urb)
case ACM_SEND_ENCAPSULATED_COMMAND : /* Required */
break;
case ACM_SET_LINE_ENCODING : /* DTE stop/parity bits
- * per character */
+ * per character */
break;
case ACM_GET_ENCAPSULATED_RESPONSE : /* request response */
break;
@@ -986,8 +986,8 @@ void usbtty_poll (void)
/* New interrupts? */
udc_irq();
- /* Write any output data to host buffer
- * (do this before checking interrupts to avoid missing one)
+ /* Write any output data to host buffer
+ * (do this before checking interrupts to avoid missing one)
*/
if (usbtty_configured ()) {
write_buffer (&usbtty_output);
@@ -995,9 +995,9 @@ void usbtty_poll (void)
/* New interrupts? */
udc_irq();
-
- /* Check for new data from host..
- * (do this after checking interrupts to get latest data)
+
+ /* Check for new data from host..
+ * (do this after checking interrupts to get latest data)
*/
if (usbtty_configured ()) {
fill_buffer (&usbtty_input);
diff --git a/drivers/usbtty.h b/drivers/usbtty.h
index 731b763..8154e30 100644
--- a/drivers/usbtty.h
+++ b/drivers/usbtty.h
@@ -33,7 +33,7 @@
#include <version_autogenerated.h>
-/* If no VendorID/ProductID is defined in config.h, pretend to be Linux
+/* If no VendorID/ProductID is defined in config.h, pretend to be Linux
* DO NOT Reuse this Vendor/Product setup with protocol incompatible devices */
#define CONFIG_USBD_VENDORID 0x0525 /* Linux/NetChip */
@@ -45,7 +45,7 @@
#define CONFIG_USBD_CONFIGURATION_STR "TTY via USB"
-#define CONFIG_USBD_SERIAL_OUT_ENDPOINT UDC_OUT_ENDPOINT
+#define CONFIG_USBD_SERIAL_OUT_ENDPOINT UDC_OUT_ENDPOINT
#define CONFIG_USBD_SERIAL_OUT_PKTSIZE UDC_OUT_PACKET_SIZE
#define CONFIG_USBD_SERIAL_IN_ENDPOINT UDC_IN_ENDPOINT
#define CONFIG_USBD_SERIAL_IN_PKTSIZE UDC_IN_PACKET_SIZE