forked from len0rd/rockbox
Fix Ingenic Jz4740 USB driver (USB IN <-> OUT) and some whitespace cleaning
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20996 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
e71c67f340
commit
8bcb4a6971
1 changed files with 122 additions and 122 deletions
|
@ -74,12 +74,13 @@ struct usb_endpoint
|
|||
static unsigned char ep0_rx_buf[64];
|
||||
static unsigned char ep0state = USB_EP0_IDLE;
|
||||
static struct usb_endpoint endpoints[] =
|
||||
{/* buf length sent busy type use_dma wait fifo_addr fifo_size */
|
||||
{&ep0_rx_buf, 0, {0}, false, ep_control, false, false, USB_FIFO_EP0, 64 },
|
||||
{
|
||||
/* buf length sent busy type use_dma wait fifo_addr fifo_size */
|
||||
{NULL, 0, {0}, false, ep_control, false, false, USB_FIFO_EP0, 64 },
|
||||
{NULL, 0, {0}, false, ep_interrupt, false, false, USB_FIFO_EP1, 64 },
|
||||
{&ep0_rx_buf, 0, {0}, false, ep_control, false, false, USB_FIFO_EP0, 64 },
|
||||
{NULL, 0, {0}, false, ep_bulk, false, false, USB_FIFO_EP1, 512},
|
||||
{NULL, 0, {0}, false, ep_bulk, false, false, USB_FIFO_EP2, 512}
|
||||
{NULL, 0, {0}, false, ep_bulk, false, false, USB_FIFO_EP1, 512},
|
||||
{NULL, 0, {0}, false, ep_interrupt, false, false, USB_FIFO_EP2, 64 }
|
||||
};
|
||||
static struct wakeup ep_wkup[TOTAL_EP()];
|
||||
|
||||
|
@ -177,7 +178,7 @@ static void flushFIFO(struct usb_endpoint *ep)
|
|||
|
||||
static void EP0_send(void)
|
||||
{
|
||||
struct usb_endpoint* ep = &endpoints[1];
|
||||
struct usb_endpoint* ep = &endpoints[0];
|
||||
unsigned int length;
|
||||
unsigned char csr0;
|
||||
|
||||
|
@ -204,7 +205,7 @@ static void EP0_send(void)
|
|||
REG_USB_REG_CSR0 = (csr0 | USB_CSR0_INPKTRDY | USB_CSR0_DATAEND); /* Set data end! */
|
||||
ep0state = USB_EP0_IDLE;
|
||||
if(ep->wait)
|
||||
wakeup_signal(&ep_wkup[1]);
|
||||
wakeup_signal(&ep_wkup[0]);
|
||||
}
|
||||
else
|
||||
REG_USB_REG_CSR0 = (csr0 | USB_CSR0_INPKTRDY);
|
||||
|
@ -247,11 +248,11 @@ static void EP0_handler(void)
|
|||
{
|
||||
if(csr0 & USB_CSR0_OUTPKTRDY) /* There is a packet in the fifo */
|
||||
{
|
||||
readFIFO(&endpoints[0], REG_USB_REG_COUNT0);
|
||||
readFIFO(&endpoints[1], REG_USB_REG_COUNT0);
|
||||
REG_USB_REG_CSR0 = csr0 | USB_CSR0_SVDOUTPKTRDY; /* clear OUTPKTRDY bit */
|
||||
usb_core_control_request((struct usb_ctrlrequest*)endpoints[0].buf);
|
||||
if(endpoints[0].wait)
|
||||
wakeup_signal(&ep_wkup[0]);
|
||||
usb_core_control_request((struct usb_ctrlrequest*)endpoints[1].buf);
|
||||
if(endpoints[1].wait)
|
||||
wakeup_signal(&ep_wkup[1]);
|
||||
}
|
||||
}
|
||||
else if(ep0state == USB_EP0_TX)
|
||||
|
@ -260,7 +261,7 @@ static void EP0_handler(void)
|
|||
|
||||
static void EPIN_handler(unsigned int endpoint)
|
||||
{
|
||||
struct usb_endpoint* ep = &endpoints[endpoint*2+1];
|
||||
struct usb_endpoint* ep = &endpoints[endpoint*2];
|
||||
unsigned int length, csr;
|
||||
|
||||
select_endpoint(endpoint);
|
||||
|
@ -300,7 +301,7 @@ static void EPIN_handler(unsigned int endpoint)
|
|||
{
|
||||
usb_core_transfer_complete(endpoint, USB_DIR_IN, 0, ep->sent);
|
||||
if(ep->wait)
|
||||
wakeup_signal(&ep_wkup[endpoint*2+1]);
|
||||
wakeup_signal(&ep_wkup[endpoint*2]);
|
||||
logf("sent complete");
|
||||
ep->sent = 0;
|
||||
ep->length = 0;
|
||||
|
@ -311,7 +312,7 @@ static void EPIN_handler(unsigned int endpoint)
|
|||
|
||||
static void EPOUT_handler(unsigned int endpoint)
|
||||
{
|
||||
struct usb_endpoint* ep = &endpoints[endpoint*2];
|
||||
struct usb_endpoint* ep = &endpoints[endpoint*2+1];
|
||||
unsigned int size, csr;
|
||||
|
||||
if(!ep->busy)
|
||||
|
@ -350,7 +351,7 @@ static void EPOUT_handler(unsigned int endpoint)
|
|||
{
|
||||
usb_core_transfer_complete(endpoint, USB_DIR_OUT, 0, ep->received);
|
||||
if(ep->wait)
|
||||
wakeup_signal(&ep_wkup[endpoint*2]);
|
||||
wakeup_signal(&ep_wkup[endpoint*2+1]);
|
||||
logf("receive transfer_complete");
|
||||
ep->received = 0;
|
||||
ep->length = 0;
|
||||
|
@ -714,9 +715,9 @@ int usb_drv_send_nonblocking(int endpoint, void* ptr, int length)
|
|||
if(endpoint == EP_CONTROL)
|
||||
{
|
||||
flags = disable_irq_save();
|
||||
endpoints[1].buf = ptr;
|
||||
endpoints[1].sent = 0;
|
||||
endpoints[1].length = length;
|
||||
endpoints[0].buf = ptr;
|
||||
endpoints[0].sent = 0;
|
||||
endpoints[0].length = length;
|
||||
ep0state = USB_EP0_TX;
|
||||
EP0_send();
|
||||
restore_irq(flags);
|
||||
|
@ -726,11 +727,11 @@ int usb_drv_send_nonblocking(int endpoint, void* ptr, int length)
|
|||
else
|
||||
{
|
||||
flags = disable_irq_save();
|
||||
endpoints[endpoint*2+1].buf = ptr;
|
||||
endpoints[endpoint*2+1].sent = 0;
|
||||
endpoints[endpoint*2+1].length = length;
|
||||
endpoints[endpoint*2+1].busy = true;
|
||||
if(endpoints[endpoint*2+1].use_dma)
|
||||
endpoints[endpoint*2].buf = ptr;
|
||||
endpoints[endpoint*2].sent = 0;
|
||||
endpoints[endpoint*2].length = length;
|
||||
endpoints[endpoint*2].busy = true;
|
||||
if(endpoints[endpoint*2].use_dma)
|
||||
{
|
||||
//dma_cache_wback_inv((unsigned long)ptr, length);
|
||||
__dcache_writeback_all();
|
||||
|
@ -756,10 +757,10 @@ int usb_drv_send(int endpoint, void* ptr, int length)
|
|||
if(endpoint == EP_CONTROL && ptr == NULL && length == 0)
|
||||
return 0; /* ACK request, handled by the USB controller */
|
||||
|
||||
endpoints[endpoint*2+1].wait = true;
|
||||
endpoints[endpoint*2].wait = true;
|
||||
ret = usb_drv_send_nonblocking(endpoint, ptr, length);
|
||||
wakeup_wait(&ep_wkup[endpoint*2+1], TIMEOUT_BLOCK);
|
||||
endpoints[endpoint*2+1].wait = false;
|
||||
wakeup_wait(&ep_wkup[endpoint*2], TIMEOUT_BLOCK);
|
||||
endpoints[endpoint*2].wait = false;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -776,11 +777,11 @@ int usb_drv_recv(int endpoint, void* ptr, int length)
|
|||
else
|
||||
{
|
||||
flags = disable_irq_save();
|
||||
endpoints[endpoint*2].buf = ptr;
|
||||
endpoints[endpoint*2].received = 0;
|
||||
endpoints[endpoint*2].length = length;
|
||||
endpoints[endpoint*2].busy = true;
|
||||
if(endpoints[endpoint*2].use_dma)
|
||||
endpoints[endpoint*2+1].buf = ptr;
|
||||
endpoints[endpoint*2+1].received = 0;
|
||||
endpoints[endpoint*2+1].length = length;
|
||||
endpoints[endpoint*2+1].busy = true;
|
||||
if(endpoints[endpoint*2+1].use_dma)
|
||||
{
|
||||
//dma_cache_wback_inv((unsigned long)ptr, length);
|
||||
__dcache_writeback_all();
|
||||
|
@ -836,7 +837,7 @@ void usb_drv_cancel_all_transfers(void)
|
|||
|
||||
for(i=0; i<TOTAL_EP(); i++)
|
||||
{
|
||||
if(i > 2)
|
||||
if(i >= 2)
|
||||
endpoints[i].buf = NULL;
|
||||
|
||||
endpoints[i].sent = 0;
|
||||
|
@ -864,18 +865,17 @@ int usb_drv_request_endpoint(int type, int dir)
|
|||
type &= USB_ENDPOINT_XFERTYPE_MASK;
|
||||
|
||||
/* There are only 3+2 endpoints, so hardcode this ... */
|
||||
/* Use the endpoint combinations from the Ingenic Linux USB driver */
|
||||
switch(type)
|
||||
{
|
||||
case USB_ENDPOINT_XFER_BULK:
|
||||
if(dir == USB_DIR_IN)
|
||||
return (2 | USB_DIR_IN);
|
||||
return (1 | USB_DIR_IN);
|
||||
else
|
||||
return (1 | USB_DIR_OUT);
|
||||
|
||||
case USB_ENDPOINT_XFER_INT:
|
||||
if(dir == USB_DIR_IN)
|
||||
return (1 | USB_DIR_IN);
|
||||
return (2 | USB_DIR_IN);
|
||||
|
||||
default:
|
||||
return -1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue