mirror of
https://xff.cz/git/u-boot/
synced 2025-09-01 08:42:12 +02:00
Code cleanup
This commit is contained in:
@@ -2,6 +2,8 @@
|
|||||||
Changes since U-Boot 1.1.4:
|
Changes since U-Boot 1.1.4:
|
||||||
======================================================================
|
======================================================================
|
||||||
|
|
||||||
|
* Code cleanup
|
||||||
|
|
||||||
* Various USB related patches
|
* Various USB related patches
|
||||||
- Add support for mpc8xx USB device.
|
- Add support for mpc8xx USB device.
|
||||||
- Add support for Common Device Class - Abstract Control Model USB console.
|
- Add support for Common Device Class - Abstract Control Model USB console.
|
||||||
|
@@ -199,15 +199,13 @@ void udc_irq(void)
|
|||||||
mpc8xx_udc_flush_rx_fifo ();
|
mpc8xx_udc_flush_rx_fifo ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Scan all RX/Bidirectional Endpoints for RX data. */
|
/* Scan all RX/Bidirectional Endpoints for RX data. */
|
||||||
for (epid = 0; epid < MAX_ENDPOINTS; epid++) {
|
for (epid = 0; epid < MAX_ENDPOINTS; epid++) {
|
||||||
|
|
||||||
if (!ep_ref[epid].prx) {
|
if (!ep_ref[epid].prx) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
rx_cbdp = rx_cbdp_base = ep_ref[epid].prx;
|
rx_cbdp = rx_cbdp_base = ep_ref[epid].prx;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (!(rx_cbdp->cbd_sc & RX_BD_E)) {
|
if (!(rx_cbdp->cbd_sc & RX_BD_E)) {
|
||||||
|
|
||||||
@@ -267,13 +265,12 @@ void udc_irq(void)
|
|||||||
if(usbp->usbs){
|
if(usbp->usbs){
|
||||||
We could resume here when IDLE is deasserted !
|
We could resume here when IDLE is deasserted !
|
||||||
Not worth doing, so long as we are self powered though.
|
Not worth doing, so long as we are self powered though.
|
||||||
}*/
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* udc_endpoint_write
|
/* udc_endpoint_write
|
||||||
*
|
*
|
||||||
* Write some data to an endpoint
|
* Write some data to an endpoint
|
||||||
@@ -316,7 +313,8 @@ int udc_endpoint_write(struct usb_endpoint_instance *epi)
|
|||||||
mpc8xx_udc_set_nak (epid);
|
mpc8xx_udc_set_nak (epid);
|
||||||
}
|
}
|
||||||
|
|
||||||
mpc8xx_udc_init_tx(&udc_device->bus->endpoint_array[ep],epi->tx_urb);
|
mpc8xx_udc_init_tx (&udc_device->bus->endpoint_array[ep],
|
||||||
|
epi->tx_urb);
|
||||||
ret = mpc8xx_udc_ep_tx (&udc_device->bus->endpoint_array[ep]);
|
ret = mpc8xx_udc_ep_tx (&udc_device->bus->endpoint_array[ep]);
|
||||||
|
|
||||||
/* Remove temporary NAK */
|
/* Remove temporary NAK */
|
||||||
@@ -346,8 +344,7 @@ static int mpc8xx_udc_assign_urb(int ep, char direction)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!ep_ref[ep].urb) {
|
if (!ep_ref[ep].urb) {
|
||||||
ep_ref[ep].urb = usbd_alloc_urb(udc_device,
|
ep_ref[ep].urb = usbd_alloc_urb (udc_device, udc_device->bus->endpoint_array);
|
||||||
udc_device->bus->endpoint_array);
|
|
||||||
if (!ep_ref[ep].urb) {
|
if (!ep_ref[ep].urb) {
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
@@ -439,10 +436,12 @@ void udc_setup_ep(struct usb_device_instance *device, unsigned int ep,
|
|||||||
if (!(ep_ref[ep].sc & EP_ATTACHED)) {
|
if (!(ep_ref[ep].sc & EP_ATTACHED)) {
|
||||||
if (direction) {
|
if (direction) {
|
||||||
mpc8xx_udc_cbd_attach (ep,
|
mpc8xx_udc_cbd_attach (ep,
|
||||||
epi->tx_packetSize, 0);
|
epi->tx_packetSize,
|
||||||
|
0);
|
||||||
} else {
|
} else {
|
||||||
mpc8xx_udc_cbd_attach (ep,
|
mpc8xx_udc_cbd_attach (ep,
|
||||||
0, epi->rcv_packetSize);
|
0,
|
||||||
|
epi->rcv_packetSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
usbp->usep[ep] = (ep << 12) | ((ep_attrib) << 8);
|
usbp->usep[ep] = (ep << 12) | ((ep_attrib) << 8);
|
||||||
@@ -450,8 +449,7 @@ void udc_setup_ep(struct usb_device_instance *device, unsigned int ep,
|
|||||||
break;
|
break;
|
||||||
case USB_ENDPOINT_XFER_ISOC:
|
case USB_ENDPOINT_XFER_ISOC:
|
||||||
default:
|
default:
|
||||||
serial_printf("Error endpoint attrib %d>3\n",
|
serial_printf ("Error endpoint attrib %d>3\n", ep_attrib);
|
||||||
ep_attrib);
|
|
||||||
udc_state = STATE_ERROR;
|
udc_state = STATE_ERROR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -504,8 +502,7 @@ void udc_enable(struct usb_device_instance *device)
|
|||||||
udc_device = device;
|
udc_device = device;
|
||||||
|
|
||||||
if (!ep_ref[0].urb) {
|
if (!ep_ref[0].urb) {
|
||||||
ep_ref[0].urb = usbd_alloc_urb(device,
|
ep_ref[0].urb = usbd_alloc_urb (device, device->bus->endpoint_array);
|
||||||
device->bus->endpoint_array);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Register interest in all events except SOF, enable transceiver */
|
/* Register interest in all events except SOF, enable transceiver */
|
||||||
@@ -735,8 +732,7 @@ static short mpc8xx_udc_handle_txerr()
|
|||||||
} else {
|
} else {
|
||||||
if (usbp->usep[ep] & STALL_BITMASK) {
|
if (usbp->usep[ep] & STALL_BITMASK) {
|
||||||
if (!ep) {
|
if (!ep) {
|
||||||
usbp->usep[ep]&=
|
usbp->usep[ep] &= ~STALL_BITMASK;
|
||||||
~STALL_BITMASK;
|
|
||||||
}
|
}
|
||||||
} /* else NAK */
|
} /* else NAK */
|
||||||
}
|
}
|
||||||
@@ -753,8 +749,7 @@ static short mpc8xx_udc_handle_txerr()
|
|||||||
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) {
|
if ((*rx_cbdp)->cbd_sc & RX_BD_W) {
|
||||||
*rx_cbdp = (volatile cbd_t*)
|
*rx_cbdp = (volatile cbd_t *) (endpoints[epid]->rbase + CFG_IMMR);
|
||||||
(endpoints[epid]->rbase + CFG_IMMR);
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
(*rx_cbdp)++;
|
(*rx_cbdp)++;
|
||||||
@@ -810,6 +805,7 @@ static void mpc8xx_udc_flush_tx_fifo(int epid)
|
|||||||
static void mpc8xx_udc_flush_rx_fifo ()
|
static void mpc8xx_udc_flush_rx_fifo ()
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
for (i = 0; i < RX_RING_SIZE; i++) {
|
for (i = 0; i < RX_RING_SIZE; i++) {
|
||||||
if (!(rx_cbd[i]->cbd_sc & RX_BD_E)) {
|
if (!(rx_cbd[i]->cbd_sc & RX_BD_E)) {
|
||||||
ERR ("buf %p used rx data len = 0x%x sc=0x%x!\n",
|
ERR ("buf %p used rx data len = 0x%x sc=0x%x!\n",
|
||||||
@@ -905,7 +901,8 @@ static int mpc8xx_udc_ep_tx (struct usb_endpoint_instance *epi)
|
|||||||
}
|
}
|
||||||
|
|
||||||
tx_cbdp = (cbd_t *) (endpoints[ep]->tbptr + CFG_IMMR);
|
tx_cbdp = (cbd_t *) (endpoints[ep]->tbptr + CFG_IMMR);
|
||||||
while(tx_cbdp->cbd_sc&TX_BD_R){};
|
while (tx_cbdp->cbd_sc & TX_BD_R) {
|
||||||
|
};
|
||||||
tx_cbdp->cbd_sc = (tx_cbdp->cbd_sc & TX_BD_W);
|
tx_cbdp->cbd_sc = (tx_cbdp->cbd_sc & TX_BD_W);
|
||||||
|
|
||||||
pkt_len = urb->actual_length - epi->sent;
|
pkt_len = urb->actual_length - epi->sent;
|
||||||
@@ -956,8 +953,7 @@ static int mpc8xx_udc_ep_tx (struct usb_endpoint_instance *epi)
|
|||||||
|
|
||||||
/* TX ACK : USB 2.0 8.7.2, Toggle PID, Advance TX */
|
/* TX ACK : USB 2.0 8.7.2, Toggle PID, Advance TX */
|
||||||
epi->sent += pkt_len;
|
epi->sent += pkt_len;
|
||||||
epi->last = MIN (urb->actual_length - epi->sent,
|
epi->last = MIN (urb->actual_length - epi->sent, epi->tx_packetSize);
|
||||||
epi->tx_packetSize);
|
|
||||||
TOGGLE_TX_PID (ep_ref[ep].pid);
|
TOGGLE_TX_PID (ep_ref[ep].pid);
|
||||||
|
|
||||||
if (epi->sent >= epi->tx_urb->actual_length) {
|
if (epi->sent >= epi->tx_urb->actual_length) {
|
||||||
@@ -985,14 +981,11 @@ static int mpc8xx_udc_ep_tx (struct usb_endpoint_instance *epi)
|
|||||||
*/
|
*/
|
||||||
static void mpc8xx_udc_dump_request (struct usb_device_request *request)
|
static void mpc8xx_udc_dump_request (struct usb_device_request *request)
|
||||||
{
|
{
|
||||||
DBG(
|
DBG ("bmRequestType:%02x bRequest:%02x wValue:%04x "
|
||||||
"bmRequestType:%02x bRequest:%02x wValue:%04x "
|
|
||||||
"wIndex:%04x wLength:%04x ?\n",
|
"wIndex:%04x wLength:%04x ?\n",
|
||||||
request->bmRequestType,
|
request->bmRequestType,
|
||||||
request->bRequest,
|
request->bRequest,
|
||||||
request->wValue,
|
request->wValue, request->wIndex, request->wLength);
|
||||||
request->wIndex,
|
|
||||||
request->wLength);
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1039,16 +1032,14 @@ static int mpc8xx_udc_ep0_rx_setup (volatile cbd_t * rx_cbdp)
|
|||||||
|
|
||||||
case USB_REQ_SET_CONFIGURATION:
|
case USB_REQ_SET_CONFIGURATION:
|
||||||
if (!purb->device_request.wValue) {
|
if (!purb->device_request.wValue) {
|
||||||
|
|
||||||
/* Respond at default address */
|
/* Respond at default address */
|
||||||
usbp->usaddr = 0x00;
|
usbp->usaddr = 0x00;
|
||||||
mpc8xx_udc_state_transition_down (udc_device->device_state,
|
mpc8xx_udc_state_transition_down (udc_device->device_state,
|
||||||
STATE_ADDRESSED);
|
STATE_ADDRESSED);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
/* TODO: Support multiple configurations */
|
/* TODO: Support multiple configurations */
|
||||||
mpc8xx_udc_state_transition_up(udc_device->device_state,STATE_CONFIGURED);
|
mpc8xx_udc_state_transition_up (udc_device->device_state,
|
||||||
|
STATE_CONFIGURED);
|
||||||
for (x = 1; x < MAX_ENDPOINTS; x++) {
|
for (x = 1; x < MAX_ENDPOINTS; x++) {
|
||||||
if ((udc_device->bus->endpoint_array[x].endpoint_address & USB_ENDPOINT_DIR_MASK)
|
if ((udc_device->bus->endpoint_array[x].endpoint_address & USB_ENDPOINT_DIR_MASK)
|
||||||
== USB_DIR_IN) {
|
== USB_DIR_IN) {
|
||||||
@@ -1059,7 +1050,6 @@ static int mpc8xx_udc_ep0_rx_setup (volatile cbd_t * rx_cbdp)
|
|||||||
/* Set configuration must unstall endpoints */
|
/* Set configuration must unstall endpoints */
|
||||||
usbp->usep[x] &= ~STALL_BITMASK;
|
usbp->usep[x] &= ~STALL_BITMASK;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -1074,6 +1064,7 @@ static int mpc8xx_udc_ep0_rx_setup (volatile cbd_t * rx_cbdp)
|
|||||||
mpc8xx_udc_ep_tx (epi);
|
mpc8xx_udc_ep_tx (epi);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (purb->actual_length) {
|
if (purb->actual_length) {
|
||||||
ep_ref[0].pid = TX_BD_PID_DATA1;
|
ep_ref[0].pid = TX_BD_PID_DATA1;
|
||||||
mpc8xx_udc_init_tx (epi, purb);
|
mpc8xx_udc_init_tx (epi, purb);
|
||||||
@@ -1084,18 +1075,14 @@ static int mpc8xx_udc_ep0_rx_setup (volatile cbd_t * rx_cbdp)
|
|||||||
|
|
||||||
if (purb->device_request.wValue ==
|
if (purb->device_request.wValue ==
|
||||||
USB_DESCRIPTOR_TYPE_DEVICE) {
|
USB_DESCRIPTOR_TYPE_DEVICE) {
|
||||||
if(le16_to_cpu(purb->device_request.wLength)>
|
if (le16_to_cpu (purb->device_request.wLength)
|
||||||
purb->actual_length){
|
> purb->actual_length) {
|
||||||
/* Send EP0_MAX_PACKET_SIZE bytes
|
/* Send EP0_MAX_PACKET_SIZE bytes
|
||||||
* unless correct size requested.
|
* unless correct size requested.
|
||||||
*/
|
*/
|
||||||
if(purb->actual_length >
|
if (purb->actual_length > epi->tx_packetSize) {
|
||||||
epi->tx_packetSize){
|
purb->actual_length = epi->tx_packetSize;
|
||||||
|
|
||||||
purb->actual_length =
|
|
||||||
epi->tx_packetSize;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mpc8xx_udc_ep_tx (epi);
|
mpc8xx_udc_ep_tx (epi);
|
||||||
@@ -1335,8 +1322,9 @@ static void mpc8xx_udc_cbd_attach (int ep, uchar tx_size, uchar rx_size)
|
|||||||
ep_ref[ep].sc |= EP_ATTACHED;
|
ep_ref[ep].sc |= EP_ATTACHED;
|
||||||
|
|
||||||
DBG ("ep %d rbase 0x%08x rbptr 0x%08x tbase 0x%08x tbptr 0x%08x prx = %p\n",
|
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,
|
ep, endpoints[ep]->rbase, endpoints[ep]->rbptr,
|
||||||
endpoints[ep]->tbptr, ep_ref[ep].prx);
|
endpoints[ep]->tbase, endpoints[ep]->tbptr,
|
||||||
|
ep_ref[ep].prx);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -769,8 +769,6 @@ typedef void (*ExcpHndlr) (void) ;
|
|||||||
#define UP2OCR __REG(0x40600020)
|
#define UP2OCR __REG(0x40600020)
|
||||||
#define UP3OCR __REG(0x40600024)
|
#define UP3OCR __REG(0x40600024)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* USB Host Controller
|
* USB Host Controller
|
||||||
*/
|
*/
|
||||||
|
@@ -321,7 +321,7 @@ struct usb_class_union_function_descriptor {
|
|||||||
u8 bDescriptorType;
|
u8 bDescriptorType;
|
||||||
u8 bDescriptorSubtype; /* 0x06 */
|
u8 bDescriptorSubtype; /* 0x06 */
|
||||||
u8 bMasterInterface;
|
u8 bMasterInterface;
|
||||||
//u8 bSlaveInterface0[0];
|
/* u8 bSlaveInterface0[0]; */
|
||||||
u8 bSlaveInterface0;
|
u8 bSlaveInterface0;
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user