summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--firmware/export/config.h10
-rw-r--r--firmware/target/arm/usb-drv-arc.c93
2 files changed, 33 insertions, 70 deletions
diff --git a/firmware/export/config.h b/firmware/export/config.h
index 8addb62e95..e6a87915fc 100644
--- a/firmware/export/config.h
+++ b/firmware/export/config.h
@@ -736,7 +736,7 @@ Lyre prototype 1 */
736/* Priority in bootloader is wanted */ 736/* Priority in bootloader is wanted */
737#define HAVE_PRIORITY_SCHEDULING 737#define HAVE_PRIORITY_SCHEDULING
738#define USB_STATUS_BY_EVENT 738#define USB_STATUS_BY_EVENT
739#define USB_DETECT_BY_DRV 739#define USB_DETECT_BY_CORE
740#if defined(HAVE_USBSTACK) && CONFIG_USBOTG == USBOTG_ARC 740#if defined(HAVE_USBSTACK) && CONFIG_USBOTG == USBOTG_ARC
741#define INCLUDE_TIMEOUT_API 741#define INCLUDE_TIMEOUT_API
742#endif 742#endif
@@ -763,7 +763,7 @@ Lyre prototype 1 */
763#ifdef HAVE_USBSTACK 763#ifdef HAVE_USBSTACK
764#if CONFIG_USBOTG == USBOTG_ARC 764#if CONFIG_USBOTG == USBOTG_ARC
765#define USB_STATUS_BY_EVENT 765#define USB_STATUS_BY_EVENT
766#define USB_DETECT_BY_DRV 766#define USB_DETECT_BY_CORE
767#define INCLUDE_TIMEOUT_API 767#define INCLUDE_TIMEOUT_API
768#elif CONFIG_USBOTG == USBOTG_AS3525 768#elif CONFIG_USBOTG == USBOTG_AS3525
769#define USB_STATUS_BY_EVENT 769#define USB_STATUS_BY_EVENT
@@ -779,12 +779,6 @@ Lyre prototype 1 */
779 779
780#endif /* BOOTLOADER */ 780#endif /* BOOTLOADER */
781 781
782#ifdef PHILIPS_SA9200
783/* Instead use the request for a device descriptor to detect a host */
784#undef USB_DETECT_BY_DRV
785#define USB_DETECT_BY_CORE
786#endif
787
788#if defined(HAVE_USBSTACK) || (CONFIG_CPU == JZ4732) \ 782#if defined(HAVE_USBSTACK) || (CONFIG_CPU == JZ4732) \
789 || (CONFIG_CPU == AS3525) || (CONFIG_CPU == AS3525v2) \ 783 || (CONFIG_CPU == AS3525) || (CONFIG_CPU == AS3525v2) \
790 || defined(CPU_S5L870X) || (CONFIG_CPU == S3C2440) \ 784 || defined(CPU_S5L870X) || (CONFIG_CPU == S3C2440) \
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
439static 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 */
432static void _usb_drv_init(bool attach) 453void 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
486static 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
499void 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 */
511void usb_drv_attach(void) 493void 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
520void usb_drv_exit(void) 498void 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 */