summaryrefslogtreecommitdiff
path: root/firmware/target/arm/as3525/usb-drv-as3525.c
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2011-03-02 08:49:38 +0000
committerMichael Sevakis <jethead71@rockbox.org>2011-03-02 08:49:38 +0000
commit12375d1d3aa41f7d277a9af584c7b810b636ec95 (patch)
treefc9ce8029a6910a8dac71b3bf60c71155a01eea4 /firmware/target/arm/as3525/usb-drv-as3525.c
parent05e180a1308a095d51d51d0e047fcd44425ea88f (diff)
downloadrockbox-12375d1d3aa41f7d277a9af584c7b810b636ec95.tar.gz
rockbox-12375d1d3aa41f7d277a9af584c7b810b636ec95.zip
Merge functionality of wakeups and semaphores-- fewer APIs and object types. semaphore_wait takes a timeout now so codecs and plugins have to be made incompatible. Don't make semaphores for targets not using them.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29492 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/as3525/usb-drv-as3525.c')
-rw-r--r--firmware/target/arm/as3525/usb-drv-as3525.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/firmware/target/arm/as3525/usb-drv-as3525.c b/firmware/target/arm/as3525/usb-drv-as3525.c
index 2e5330ec1b..69c50cda93 100644
--- a/firmware/target/arm/as3525/usb-drv-as3525.c
+++ b/firmware/target/arm/as3525/usb-drv-as3525.c
@@ -40,6 +40,7 @@
40static struct usb_endpoint endpoints[USB_NUM_EPS][2]; 40static struct usb_endpoint endpoints[USB_NUM_EPS][2];
41static int got_set_configuration = 0; 41static int got_set_configuration = 0;
42static int usb_enum_timeout = -1; 42static int usb_enum_timeout = -1;
43static bool initialized = false;
43 44
44/* 45/*
45 * dma/setup descriptors and buffers should avoid sharing 46 * dma/setup descriptors and buffers should avoid sharing
@@ -180,19 +181,19 @@ static void reset_endpoints(int init)
180 if (endpoints[i][0].state & EP_STATE_BUSY) { 181 if (endpoints[i][0].state & EP_STATE_BUSY) {
181 if (endpoints[i][0].state & EP_STATE_ASYNC) { 182 if (endpoints[i][0].state & EP_STATE_ASYNC) {
182 endpoints[i][0].rc = -1; 183 endpoints[i][0].rc = -1;
183 wakeup_signal(&endpoints[i][0].complete); 184 semaphore_release(&endpoints[i][0].complete);
184 } else { 185 } else {
185 usb_core_transfer_complete(i, USB_DIR_IN, -1, 0); 186 usb_core_transfer_complete(i, USB_DIR_IN, -1, 0);
186 } 187 }
187 } 188 }
188 endpoints[i][0].state = 0; 189 endpoints[i][0].state = 0;
189 wakeup_init(&endpoints[i][0].complete); 190 semaphore_wait(&endpoints[i][0].complete, TIMEOUT_NOBLOCK);
190 191
191 if (i != 2) { /* Skip the OUT EP0 alias */ 192 if (i != 2) { /* Skip the OUT EP0 alias */
192 if (endpoints[i][1].state & EP_STATE_BUSY) 193 if (endpoints[i][1].state & EP_STATE_BUSY)
193 usb_core_transfer_complete(i, USB_DIR_OUT, -1, 0); 194 usb_core_transfer_complete(i, USB_DIR_OUT, -1, 0);
194 endpoints[i][1].state = 0; 195 endpoints[i][1].state = 0;
195 wakeup_init(&endpoints[i][1].complete); 196 semaphore_wait(&endpoints[i][1].complete, TIMEOUT_NOBLOCK);
196 USB_OEP_SUP_PTR(i) = 0; 197 USB_OEP_SUP_PTR(i) = 0;
197 } 198 }
198 } 199 }
@@ -225,6 +226,18 @@ void usb_drv_init(void)
225{ 226{
226 logf("usb_drv_init() !!!!\n"); 227 logf("usb_drv_init() !!!!\n");
227 228
229 if (!initialized)
230 {
231 int i;
232 for (i = 0; i < USB_NUM_EPS; i++)
233 {
234 semaphore_init(&endpoints[i][0].complete, 1, 0);
235 semaphore_init(&endpoints[i][1].complete, 1, 0);
236 }
237
238 initialized = true;
239 }
240
228 usb_enable_pll(); 241 usb_enable_pll();
229 242
230 /* we have external power, so boost cpu */ 243 /* we have external power, so boost cpu */
@@ -322,6 +335,7 @@ void usb_drv_exit(void)
322 ascodec_write(AS3515_USB_UTIL, ascodec_read(AS3515_USB_UTIL) & ~(1<<4)); 335 ascodec_write(AS3515_USB_UTIL, ascodec_read(AS3515_USB_UTIL) & ~(1<<4));
323 usb_disable_pll(); 336 usb_disable_pll();
324 cpu_boost(0); 337 cpu_boost(0);
338 initialized = false;
325 logf("usb_drv_exit() !!!!\n"); 339 logf("usb_drv_exit() !!!!\n");
326} 340}
327 341
@@ -529,7 +543,7 @@ int usb_drv_send(int ep, void *ptr, int len)
529 } 543 }
530 544
531 ep_send(ep, ptr, len); 545 ep_send(ep, ptr, len);
532 if (wakeup_wait(&endpoints[ep][0].complete, HZ) == OBJ_WAIT_TIMEDOUT) 546 if (semaphore_wait(&endpoints[ep][0].complete, HZ) == OBJ_WAIT_TIMEDOUT)
533 logf("send timed out!\n"); 547 logf("send timed out!\n");
534 548
535 return endpoints[ep][0].rc; 549 return endpoints[ep][0].rc;
@@ -570,7 +584,7 @@ static void handle_in_ep(int ep)
570 endpoints[ep][0].state &= ~EP_STATE_ASYNC; 584 endpoints[ep][0].state &= ~EP_STATE_ASYNC;
571 usb_core_transfer_complete(ep, USB_DIR_IN, 0, endpoints[ep][0].len); 585 usb_core_transfer_complete(ep, USB_DIR_IN, 0, endpoints[ep][0].len);
572 } else { 586 } else {
573 wakeup_signal(&endpoints[ep][0].complete); 587 semaphore_release(&endpoints[ep][0].complete);
574 } 588 }
575 ep_sts &= ~USB_EP_STAT_TDC; 589 ep_sts &= ~USB_EP_STAT_TDC;
576 } 590 }