summaryrefslogtreecommitdiff
path: root/firmware/target/arm/as3525
diff options
context:
space:
mode:
authorRafaël Carré <rafael.carre@gmail.com>2011-12-31 20:38:44 +0000
committerRafaël Carré <rafael.carre@gmail.com>2011-12-31 20:38:44 +0000
commit12b70597a6112224c40b8e774809c7de49b4fdc3 (patch)
tree985a0cbe7a313ff23e0e1c04fb4d30159fd5fa5f /firmware/target/arm/as3525
parentba03cb4aea212553f47a9da672fdd897e9f2e620 (diff)
downloadrockbox-12b70597a6112224c40b8e774809c7de49b4fdc3.tar.gz
rockbox-12b70597a6112224c40b8e774809c7de49b4fdc3.zip
usb-s3c6400x: start factorization
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31506 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/as3525')
-rw-r--r--firmware/target/arm/as3525/usb-drv-as3525v2.c46
1 files changed, 2 insertions, 44 deletions
diff --git a/firmware/target/arm/as3525/usb-drv-as3525v2.c b/firmware/target/arm/as3525/usb-drv-as3525v2.c
index 51207d8e96..c9d687f910 100644
--- a/firmware/target/arm/as3525/usb-drv-as3525v2.c
+++ b/firmware/target/arm/as3525/usb-drv-as3525v2.c
@@ -39,17 +39,6 @@
39static const uint8_t in_ep_list[] = {0, 1, 3, 5}; 39static const uint8_t in_ep_list[] = {0, 1, 3, 5};
40static const uint8_t out_ep_list[] = {0, 2, 4}; 40static const uint8_t out_ep_list[] = {0, 2, 4};
41 41
42/* store per endpoint, per direction, information */
43struct ep_type
44{
45 unsigned int size; /* length of the data buffer */
46 struct semaphore complete; /* wait object */
47 int8_t status; /* completion status (0 for success) */
48 bool active; /* true is endpoint has been requested (true for EP0) */
49 bool done; /* transfer completed */
50 bool busy; /* true is a transfer is pending */
51};
52
53/* state of EP0 (to correctly schedule setup packet enqueing) */ 42/* state of EP0 (to correctly schedule setup packet enqueing) */
54enum ep0state 43enum ep0state
55{ 44{
@@ -423,7 +412,7 @@ void usb_drv_cancel_all_transfers()
423 cancel_all_transfers(false); 412 cancel_all_transfers(false);
424} 413}
425 414
426static void usb_drv_transfer(int ep, void *ptr, int len, bool out) 415static void ep_transfer(int ep, void *ptr, int len, bool out)
427{ 416{
428 /* disable interrupts to avoid any race */ 417 /* disable interrupts to avoid any race */
429 int oldlevel = disable_irq_save(); 418 int oldlevel = disable_irq_save();
@@ -458,51 +447,20 @@ static void usb_drv_transfer(int ep, void *ptr, int len, bool out)
458 restore_irq(oldlevel); 447 restore_irq(oldlevel);
459} 448}
460 449
461int usb_drv_recv(int ep, void *ptr, int len)
462{
463 usb_drv_transfer(EP_NUM(ep), ptr, len, true);
464 return 0;
465}
466
467int usb_drv_send(int ep, void *ptr, int len) 450int usb_drv_send(int ep, void *ptr, int len)
468{ 451{
469 ep = EP_NUM(ep); 452 ep = EP_NUM(ep);
470 struct ep_type *endpoint = &endpoints[ep][1]; 453 struct ep_type *endpoint = &endpoints[ep][1];
471 endpoint->done = false; 454 endpoint->done = false;
472 usb_drv_transfer(ep, ptr, len, false); 455 ep_transfer(ep, ptr, len, false);
473 while (endpoint->busy && !endpoint->done) 456 while (endpoint->busy && !endpoint->done)
474 semaphore_wait(&endpoint->complete, TIMEOUT_BLOCK); 457 semaphore_wait(&endpoint->complete, TIMEOUT_BLOCK);
475 return endpoint->status; 458 return endpoint->status;
476} 459}
477 460
478int usb_drv_send_nonblocking(int ep, void *ptr, int len)
479{
480 usb_drv_transfer(EP_NUM(ep), ptr, len, false);
481 return 0;
482}
483
484
485void usb_drv_set_test_mode(int mode) 461void usb_drv_set_test_mode(int mode)
486{ 462{
487 /* there is a perfect matching between usb test mode code 463 /* there is a perfect matching between usb test mode code
488 * and the register field value */ 464 * and the register field value */
489 DCTL = (DCTL & ~bitm(DCTL, tstctl)) | (mode << DCTL_tstctl_bitp); 465 DCTL = (DCTL & ~bitm(DCTL, tstctl)) | (mode << DCTL_tstctl_bitp);
490} 466}
491
492void usb_drv_set_address(int address)
493{
494 (void) address;
495}
496
497void usb_drv_stall(int ep, bool stall, bool in)
498{
499 if (stall)
500 DEPCTL(ep, !in) |= DEPCTL_stall;
501 else
502 DEPCTL(ep, !in) &= ~DEPCTL_stall;
503}
504
505bool usb_drv_stalled(int ep, bool in)
506{
507 return DEPCTL(ep, !in) & DEPCTL_stall;
508}