diff options
author | Michael Sevakis <jethead71@rockbox.org> | 2011-09-14 14:05:07 +0000 |
---|---|---|
committer | Michael Sevakis <jethead71@rockbox.org> | 2011-09-14 14:05:07 +0000 |
commit | 207131c53b15e7b5956177e90932b7445ff5b4ce (patch) | |
tree | d9fa50afd9fac8c180dcbf82190b7c9d7d9a04aa /firmware/target/arm | |
parent | 08d285b414627851ca49f89a49e085fac83f1e89 (diff) | |
download | rockbox-207131c53b15e7b5956177e90932b7445ff5b4ce.tar.gz rockbox-207131c53b15e7b5956177e90932b7445ff5b4ce.zip |
Convert ARC USB driver code to always use setup packet detection and remove the bus-reset-based detection method for it. This prevents false USB detection from chargers or other accesories that aren't actually a host but can trigger the bus reset condition.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30546 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm')
-rw-r--r-- | firmware/target/arm/usb-drv-arc.c | 93 |
1 files changed, 31 insertions, 62 deletions
diff --git a/firmware/target/arm/usb-drv-arc.c b/firmware/target/arm/usb-drv-arc.c index f252f11f3e..855f67e4c3 100644 --- a/firmware/target/arm/usb-drv-arc.c +++ b/firmware/target/arm/usb-drv-arc.c | |||
@@ -428,9 +428,31 @@ void usb_drv_startup(void) | |||
428 | } | 428 | } |
429 | } | 429 | } |
430 | 430 | ||
431 | #ifdef LOGF_ENABLE | ||
432 | #define XFER_DIR_STR(dir) ((dir) ? "IN" : "OUT") | ||
433 | #define XFER_TYPE_STR(type) \ | ||
434 | ((type) == USB_ENDPOINT_XFER_CONTROL ? "CTRL" : \ | ||
435 | ((type) == USB_ENDPOINT_XFER_ISOC ? "ISOC" : \ | ||
436 | ((type) == USB_ENDPOINT_XFER_BULK ? "BULK" : \ | ||
437 | ((type) == USB_ENDPOINT_XFER_INT ? "INTR" : "INVL")))) | ||
438 | |||
439 | static void log_ep(int ep_num, int ep_dir, char* prefix) | ||
440 | { | ||
441 | usb_endpoint_t* endpoint = &endpoints[ep_num]; | ||
442 | |||
443 | logf("%s: ep%d %s %s %d", prefix, ep_num, XFER_DIR_STR(ep_dir), | ||
444 | XFER_TYPE_STR(endpoint->type[ep_dir]), | ||
445 | endpoint->max_pkt_size[ep_dir]); | ||
446 | } | ||
447 | #else | ||
448 | #undef log_ep | ||
449 | #define log_ep(...) | ||
450 | #endif | ||
451 | |||
431 | /* manual: 32.14.1 Device Controller Initialization */ | 452 | /* manual: 32.14.1 Device Controller Initialization */ |
432 | static void _usb_drv_init(bool attach) | 453 | void usb_drv_init(void) |
433 | { | 454 | { |
455 | /* USB core decides */ | ||
434 | usb_drv_reset(); | 456 | usb_drv_reset(); |
435 | 457 | ||
436 | REG_USBMODE = USBMODE_CTRL_MODE_DEVICE; | 458 | REG_USBMODE = USBMODE_CTRL_MODE_DEVICE; |
@@ -447,19 +469,12 @@ static void _usb_drv_init(bool attach) | |||
447 | REG_ENDPOINTLISTADDR = (unsigned int)qh_array; | 469 | REG_ENDPOINTLISTADDR = (unsigned int)qh_array; |
448 | REG_DEVICEADDR = 0; | 470 | REG_DEVICEADDR = 0; |
449 | 471 | ||
450 | if (!attach) { | 472 | /* enable USB interrupts */ |
451 | /* enable RESET interrupt */ | 473 | REG_USBINTR = |
452 | REG_USBINTR = USBINTR_RESET_EN; | 474 | USBINTR_INT_EN | |
453 | } | 475 | USBINTR_ERR_INT_EN | |
454 | else | 476 | USBINTR_PTC_DETECT_EN | |
455 | { | 477 | USBINTR_RESET_EN; |
456 | /* enable USB interrupts */ | ||
457 | REG_USBINTR = | ||
458 | USBINTR_INT_EN | | ||
459 | USBINTR_ERR_INT_EN | | ||
460 | USBINTR_PTC_DETECT_EN | | ||
461 | USBINTR_RESET_EN; | ||
462 | } | ||
463 | 478 | ||
464 | usb_drv_int_enable(true); | 479 | usb_drv_int_enable(true); |
465 | 480 | ||
@@ -472,49 +487,12 @@ static void _usb_drv_init(bool attach) | |||
472 | logf("usb dccparams %x", REG_DCCPARAMS); | 487 | logf("usb dccparams %x", REG_DCCPARAMS); |
473 | 488 | ||
474 | /* now a bus reset will occur. see bus_reset() */ | 489 | /* now a bus reset will occur. see bus_reset() */ |
475 | (void)attach; | ||
476 | } | ||
477 | |||
478 | #ifdef LOGF_ENABLE | ||
479 | #define XFER_DIR_STR(dir) ((dir) ? "IN" : "OUT") | ||
480 | #define XFER_TYPE_STR(type) \ | ||
481 | ((type) == USB_ENDPOINT_XFER_CONTROL ? "CTRL" : \ | ||
482 | ((type) == USB_ENDPOINT_XFER_ISOC ? "ISOC" : \ | ||
483 | ((type) == USB_ENDPOINT_XFER_BULK ? "BULK" : \ | ||
484 | ((type) == USB_ENDPOINT_XFER_INT ? "INTR" : "INVL")))) | ||
485 | |||
486 | static void log_ep(int ep_num, int ep_dir, char* prefix) | ||
487 | { | ||
488 | usb_endpoint_t* endpoint = &endpoints[ep_num]; | ||
489 | |||
490 | logf("%s: ep%d %s %s %d", prefix, ep_num, XFER_DIR_STR(ep_dir), | ||
491 | XFER_TYPE_STR(endpoint->type[ep_dir]), | ||
492 | endpoint->max_pkt_size[ep_dir]); | ||
493 | } | ||
494 | #else | ||
495 | #undef log_ep | ||
496 | #define log_ep(...) | ||
497 | #endif | ||
498 | |||
499 | void usb_drv_init(void) | ||
500 | { | ||
501 | #ifdef USB_DETECT_BY_CORE | ||
502 | /* USB core decides */ | ||
503 | _usb_drv_init(true); | ||
504 | #else | ||
505 | /* Use bus reset condition */ | ||
506 | _usb_drv_init(false); | ||
507 | #endif | ||
508 | } | 490 | } |
509 | 491 | ||
510 | /* fully enable driver */ | 492 | /* fully enable driver */ |
511 | void usb_drv_attach(void) | 493 | void usb_drv_attach(void) |
512 | { | 494 | { |
513 | logf("usb_drv_attach"); | 495 | logf("usb_drv_attach"); |
514 | #ifndef USB_DETECT_BY_CORE | ||
515 | sleep(HZ/10); | ||
516 | _usb_drv_init(true); | ||
517 | #endif | ||
518 | } | 496 | } |
519 | 497 | ||
520 | void usb_drv_exit(void) | 498 | void usb_drv_exit(void) |
@@ -563,17 +541,8 @@ void usb_drv_int(void) | |||
563 | /* reset interrupt */ | 541 | /* reset interrupt */ |
564 | if (status & USBSTS_RESET) { | 542 | if (status & USBSTS_RESET) { |
565 | REG_USBSTS = USBSTS_RESET; | 543 | REG_USBSTS = USBSTS_RESET; |
566 | 544 | bus_reset(); | |
567 | if (UNLIKELY(usbintr == USBINTR_RESET_EN)) { | 545 | usb_core_bus_reset(); /* tell mom */ |
568 | /* USB detected - detach and inform */ | ||
569 | usb_drv_stop(); | ||
570 | usb_drv_usb_detect_event(); | ||
571 | } | ||
572 | else | ||
573 | { | ||
574 | bus_reset(); | ||
575 | usb_core_bus_reset(); /* tell mom */ | ||
576 | } | ||
577 | } | 546 | } |
578 | 547 | ||
579 | /* port change */ | 548 | /* port change */ |