1
0
Fork 0
forked from len0rd/rockbox

FS#10226 - isp1583.c code cosmetics

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22866 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Tomer Shalev 2009-10-01 05:40:20 +00:00
parent 4221a7f22f
commit 9b2f4c3a65

View file

@ -92,8 +92,8 @@ static inline void usb_select_endpoint(int idx)
/* Select the endpoint */ /* Select the endpoint */
ISP1583_DFLOW_EPINDEX = idx; ISP1583_DFLOW_EPINDEX = idx;
/* The delay time from the Write Endpoint Index register to the Read Data Port register must be at least 190 ns. /* The delay time from the Write Endpoint Index register to the Read Data Port register must be at least 190 ns.
* The delay time from the Write Endpoint Index register to the Write Data Port register must be at least 100 ns. * The delay time from the Write Endpoint Index register to the Write Data Port register must be at least 100 ns.
*/ */
NOP; NOP;
} }
@ -102,14 +102,14 @@ static inline void usb_select_setup_endpoint(void)
/* Select the endpoint */ /* Select the endpoint */
ISP1583_DFLOW_EPINDEX = DFLOW_EPINDEX_EP0SETUP; ISP1583_DFLOW_EPINDEX = DFLOW_EPINDEX_EP0SETUP;
/* The delay time from the Write Endpoint Index register to the Read Data Port register must be at least 190 ns. /* The delay time from the Write Endpoint Index register to the Read Data Port register must be at least 190 ns.
* The delay time from the Write Endpoint Index register to the Write Data Port register must be at least 100 ns. * The delay time from the Write Endpoint Index register to the Write Data Port register must be at least 100 ns.
*/ */
NOP; NOP;
} }
static void usb_setup_endpoint(int idx, int max_pkt_size, int type) static void usb_setup_endpoint(int idx, int max_pkt_size, int type)
{ {
if(epidx_n(idx)!=0) if(epidx_n(idx)!=EP_CONTROL)
{ {
usb_select_endpoint(idx); usb_select_endpoint(idx);
ISP1583_DFLOW_MAXPKSZ = max_pkt_size & 0x7FF; ISP1583_DFLOW_MAXPKSZ = max_pkt_size & 0x7FF;
@ -135,7 +135,7 @@ static void usb_setup_endpoint(int idx, int max_pkt_size, int type)
static void usb_enable_endpoint(int idx) static void usb_enable_endpoint(int idx)
{ {
if(epidx_n(idx)!=0) if(epidx_n(idx)!=EP_CONTROL)
{ {
usb_select_endpoint(idx); usb_select_endpoint(idx);
/* Enable interrupt */ /* Enable interrupt */
@ -336,8 +336,8 @@ static void usb_handle_setup_rx(void)
} }
else else
{ {
usb_drv_stall(0, true, false); usb_drv_stall(EP_CONTROL, true, false);
usb_drv_stall(0, true, true); usb_drv_stall(EP_CONTROL, true, true);
logf("usb_handle_setup_rx() failed"); logf("usb_handle_setup_rx() failed");
return; return;
} }
@ -369,18 +369,24 @@ bool usb_drv_powered(void)
static void setup_endpoints(void) static void setup_endpoints(void)
{ {
usb_setup_endpoint(ep_index(0, DIR_RX), 64, 0);
usb_setup_endpoint(ep_index(0, DIR_TX), 64, 0);
int i; int i;
int max_pkt_size = (high_speed_mode ? 512 : 64);
usb_setup_endpoint(ep_index(EP_CONTROL, DIR_RX), 64,
USB_ENDPOINT_XFER_CONTROL);
usb_setup_endpoint(ep_index(EP_CONTROL, DIR_TX), 64,
USB_ENDPOINT_XFER_CONTROL);
for(i = 1; i < USB_NUM_ENDPOINTS-1; i++) for(i = 1; i < USB_NUM_ENDPOINTS-1; i++)
{ {
usb_setup_endpoint(ep_index(i, DIR_RX), (high_speed_mode ? 512 : 64), 2); /* 2 = TYPE_BULK */ usb_setup_endpoint(ep_index(i, DIR_RX), max_pkt_size,
usb_setup_endpoint(ep_index(i, DIR_TX), (high_speed_mode ? 512 : 64), 2); USB_ENDPOINT_XFER_BULK);
usb_setup_endpoint(ep_index(i, DIR_TX), max_pkt_size,
USB_ENDPOINT_XFER_BULK);
} }
usb_enable_endpoint(ep_index(0, DIR_RX)); usb_enable_endpoint(ep_index(EP_CONTROL, DIR_RX));
usb_enable_endpoint(ep_index(0, DIR_TX)); usb_enable_endpoint(ep_index(EP_CONTROL, DIR_TX));
for (i = 1; i < USB_NUM_ENDPOINTS-1; i++) for (i = 1; i < USB_NUM_ENDPOINTS-1; i++)
{ {
@ -418,17 +424,17 @@ void usb_drv_init(void)
/* Disable all OTG functions */ /* Disable all OTG functions */
ISP1583_INIT_OTG = 0; ISP1583_INIT_OTG = 0;
#ifdef DEBUG #ifdef DEBUG
logf("BUS_CONF/DA0:%d MODE0/DA1: %d MODE1: %d", (bool)(ISP1583_INIT_MODE & INIT_MODE_TEST0), (bool)(ISP1583_INIT_MODE & INIT_MODE_TEST1), (bool)(ISP1583_INIT_MODE & INIT_MODE_TEST2)); logf("BUS_CONF/DA0:%d MODE0/DA1: %d MODE1: %d", (bool)(ISP1583_INIT_MODE & INIT_MODE_TEST0), (bool)(ISP1583_INIT_MODE & INIT_MODE_TEST1), (bool)(ISP1583_INIT_MODE & INIT_MODE_TEST2));
logf("Chip ID: 0x%x", ISP1583_GEN_CHIPID); logf("Chip ID: 0x%x", ISP1583_GEN_CHIPID);
//logf("INV0: 0x% IRQEDGE: 0x%x IRQPORT: 0x%x", IO_GIO_INV0, IO_GIO_IRQEDGE, IO_GIO_IRQPORT); //logf("INV0: 0x% IRQEDGE: 0x%x IRQPORT: 0x%x", IO_GIO_INV0, IO_GIO_IRQEDGE, IO_GIO_IRQPORT);
#endif #endif
/*Set interrupt generation to target-specific mode + /*Set interrupt generation to target-specific mode +
* Set the control pipe to ACK only interrupt + * Set the control pipe to ACK only interrupt +
* Set the IN pipe to ACK only interrupt + * Set the IN pipe to ACK only interrupt +
* Set OUT pipe to ACK and NYET interrupt * Set OUT pipe to ACK and NYET interrupt
*/ */
ISP1583_INIT_INTCONF = 0x54 | INT_CONF_TARGET; ISP1583_INIT_INTCONF = 0x54 | INT_CONF_TARGET;
/* Clear all interrupts */ /* Clear all interrupts */
@ -517,7 +523,7 @@ static void in_callback(int ep, unsigned char *buf, int len)
int usb_drv_recv(int ep, void* ptr, int length) int usb_drv_recv(int ep, void* ptr, int length)
{ {
logf("usb_drv_recv(%d, 0x%x, %d)", ep, (int)ptr, length); logf("usb_drv_recv(%d, 0x%x, %d)", ep, (int)ptr, length);
if(ep == 0 && length == 0 && ptr == NULL) if(ep == EP_CONTROL && length == 0 && ptr == NULL)
{ {
usb_status_ack(ep, DIR_TX); usb_status_ack(ep, DIR_TX);
return 0; return 0;
@ -527,7 +533,7 @@ int usb_drv_recv(int ep, void* ptr, int length)
endpoints[ep].in_max_len = length; endpoints[ep].in_max_len = length;
endpoints[ep].in_min_len = length; endpoints[ep].in_min_len = length;
endpoints[ep].in_ptr = 0; endpoints[ep].in_ptr = 0;
if(ep == 0) if(ep == EP_CONTROL)
{ {
usb_data_stage_enable(ep, DIR_RX); usb_data_stage_enable(ep, DIR_RX);
return usb_receive(ep); return usb_receive(ep);
@ -560,7 +566,7 @@ static void usb_drv_wait(int ep, bool send)
int usb_drv_send(int ep, void* ptr, int length) int usb_drv_send(int ep, void* ptr, int length)
{ {
logf("usb_drv_send_nb(%d, 0x%x, %d)", ep, (int)ptr, length); logf("usb_drv_send_nb(%d, 0x%x, %d)", ep, (int)ptr, length);
if(ep == 0 && length == 0 && ptr == NULL) if(ep == EP_CONTROL && length == 0 && ptr == NULL)
{ {
usb_status_ack(ep, DIR_RX); usb_status_ack(ep, DIR_RX);
return 0; return 0;
@ -572,7 +578,7 @@ int usb_drv_send(int ep, void* ptr, int length)
endpoints[ep].out_len = length; endpoints[ep].out_len = length;
endpoints[ep].out_ptr = 0; endpoints[ep].out_ptr = 0;
endpoints[ep].out_in_progress = 1; endpoints[ep].out_in_progress = 1;
if(ep == 0) if(ep == EP_CONTROL)
{ {
int rc = usb_send(ep); int rc = usb_send(ep);
usb_data_stage_enable(ep, DIR_TX); usb_data_stage_enable(ep, DIR_TX);