summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--firmware/drivers/usb/arcotg_dcd.c24
-rw-r--r--firmware/export/usb_ch9.h27
2 files changed, 30 insertions, 21 deletions
diff --git a/firmware/drivers/usb/arcotg_dcd.c b/firmware/drivers/usb/arcotg_dcd.c
index fe8ae803c0..c45a790c04 100644
--- a/firmware/drivers/usb/arcotg_dcd.c
+++ b/firmware/drivers/usb/arcotg_dcd.c
@@ -467,25 +467,17 @@ static void resume_int(void)
467 467
468static void reset_int(void) 468static void reset_int(void)
469{ 469{
470 struct timer t;
471
472 /* clear device address */ 470 /* clear device address */
473 UDC_DEVICEADDR = 0 << 25; 471 UDC_DEVICEADDR = 0 << 25;
474 472
475 /* update usb state */ 473 /* update usb state */
476 dcd_controller.usb_state = USB_STATE_DEFAULT; 474 dcd_controller.usb_state = USB_STATE_DEFAULT;
477 475
478 timer_set(&t, RESET_TIMER);
479
480 UDC_ENDPTSETUPSTAT = UDC_ENDPTSETUPSTAT; 476 UDC_ENDPTSETUPSTAT = UDC_ENDPTSETUPSTAT;
481 UDC_ENDPTCOMPLETE = UDC_ENDPTCOMPLETE; 477 UDC_ENDPTCOMPLETE = UDC_ENDPTCOMPLETE;
482 478
483 while (UDC_ENDPTPRIME) { /* prime and flush pending transfers */ 479 /* prime and flush pending transfers */
484 if (timer_expired(&t)) { 480 while (UDC_ENDPTPRIME);
485 logf("TIMEOUT->p&f");
486 }
487 }
488
489 UDC_ENDPTFLUSH = ~0; 481 UDC_ENDPTFLUSH = ~0;
490 482
491 if ((UDC_PORTSC1 & PORTSCX_PORT_RESET) == 0) { 483 if ((UDC_PORTSC1 & PORTSCX_PORT_RESET) == 0) {
@@ -493,19 +485,9 @@ static void reset_int(void)
493 } 485 }
494 486
495 /* clear USB Reset status bit */ 487 /* clear USB Reset status bit */
496 UDC_USBSTS = USB_STS_RESET; 488 UDC_USBSTS |= USB_STS_RESET;
497
498 /* wait for port change */
499 while ((UDC_USBSTS & USB_STS_PORT_CHANGE) == 0) {
500 if (timer_expired(&t)) {
501 logf("TIMEOUT->portchange");
502 }
503 }
504
505 UDC_USBSTS = (1 << 2);
506} 489}
507 490
508
509/*-------------------------------------------------------------------------*/ 491/*-------------------------------------------------------------------------*/
510/* usb controller ops */ 492/* usb controller ops */
511 493
diff --git a/firmware/export/usb_ch9.h b/firmware/export/usb_ch9.h
index a40bc4e4ae..b8fe181158 100644
--- a/firmware/export/usb_ch9.h
+++ b/firmware/export/usb_ch9.h
@@ -21,6 +21,33 @@
21 * 21 *
22 ****************************************************************************/ 22 ****************************************************************************/
23 23
24/*
25 * This file holds USB constants and structures that are needed for
26 * USB device APIs. These are used by the USB device model, which is
27 * defined in chapter 9 of the USB 2.0 specification and in the
28 * Wireless USB 1.0 (spread around).
29 *
30 * USB 2.0 adds an additional "On The Go" (OTG) mode, which lets systems
31 * act either as a USB master/host or as a USB slave/device. That means
32 * the master and slave side APIs benefit from working well together.
33 *
34 * There's also "Wireless USB", using low power short range radios for
35 * peripheral interconnection but otherwise building on the USB framework.
36 *
37 * Note all descriptors are declared '__attribute__((packed))' so that:
38 *
39 * [a] they never get padded, either internally (USB spec writers
40 * probably handled that) or externally;
41 *
42 * [b] so that accessing bigger-than-a-bytes fields will never
43 * generate bus errors on any platform, even when the location of
44 * its descriptor inside a bundle isn't "naturally aligned", and
45 *
46 * [c] for consistency, removing all doubt even when it appears to
47 * someone that the two other points are non-issues for that
48 * particular descriptor type.
49 */
50
24#ifndef _CH9_H_ 51#ifndef _CH9_H_
25#define _CH9_H_ 52#define _CH9_H_
26 53