summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--firmware/export/usb.h2
-rw-r--r--firmware/target/arm/usb-fw-pp502x.c4
-rw-r--r--firmware/usb.c27
3 files changed, 13 insertions, 20 deletions
diff --git a/firmware/export/usb.h b/firmware/export/usb.h
index ca3f72eaa4..2dac4c75db 100644
--- a/firmware/export/usb.h
+++ b/firmware/export/usb.h
@@ -34,7 +34,7 @@ enum {
34 USB_EXTRACTED = 0, /* Event+State */ 34 USB_EXTRACTED = 0, /* Event+State */
35 USB_INSERTED, /* Event+State */ 35 USB_INSERTED, /* Event+State */
36 USB_POWERED, /* Event+State - transitional indicator if no power */ 36 USB_POWERED, /* Event+State - transitional indicator if no power */
37#if defined(USB_DETECT_BY_DRV) || defined(USB_DETECT_BY_CORE) 37#ifdef USB_DETECT_BY_CORE
38 USB_UNPOWERED, /* Event */ 38 USB_UNPOWERED, /* Event */
39#endif 39#endif
40#ifdef HAVE_LCD_BITMAP 40#ifdef HAVE_LCD_BITMAP
diff --git a/firmware/target/arm/usb-fw-pp502x.c b/firmware/target/arm/usb-fw-pp502x.c
index 19f21e12ed..f1d250d3ec 100644
--- a/firmware/target/arm/usb-fw-pp502x.c
+++ b/firmware/target/arm/usb-fw-pp502x.c
@@ -226,9 +226,7 @@ void usb_insert_int(void)
226 timeout_register(&usb_oneshot, usb_timeout_event, HZ/5, val); 226 timeout_register(&usb_oneshot, usb_timeout_event, HZ/5, val);
227} 227}
228 228
229/* USB_DETECT_BY_DRV: Called during the bus reset interrupt when in detect mode 229/* USB_DETECT_BY_CORE: Called when device descriptor is requested */
230 * USB_DETECT_BY_CORE: Called when device descriptor is requested
231 */
232void usb_drv_usb_detect_event(void) 230void usb_drv_usb_detect_event(void)
233{ 231{
234 /* Filter for invalid bus reset when unplugging by checking the pin state. */ 232 /* Filter for invalid bus reset when unplugging by checking the pin state. */
diff --git a/firmware/usb.c b/firmware/usb.c
index 298627c4a5..64e727330a 100644
--- a/firmware/usb.c
+++ b/firmware/usb.c
@@ -57,11 +57,6 @@
57#define USB_FULL_INIT 57#define USB_FULL_INIT
58#endif 58#endif
59 59
60#if defined(USB_DETECT_BY_DRV) || defined(USB_DETECT_BY_CORE)
61/* These aren't treated differently here */
62#define USB_DELAYED_INSERT
63#endif
64
65#ifdef HAVE_LCD_BITMAP 60#ifdef HAVE_LCD_BITMAP
66bool do_screendump_instead_of_usb = false; 61bool do_screendump_instead_of_usb = false;
67#endif 62#endif
@@ -370,7 +365,7 @@ static void usb_thread(void) NORETURN_ATTR;
370#endif 365#endif
371static void usb_thread(void) 366static void usb_thread(void)
372{ 367{
373#ifdef USB_DELAYED_INSERT 368#ifdef USB_DETECT_BY_CORE
374 bool host_detected = false; 369 bool host_detected = false;
375#endif 370#endif
376 int num_acks_to_expect = 0; 371 int num_acks_to_expect = 0;
@@ -392,7 +387,7 @@ static void usb_thread(void)
392#endif /* HAVE_USBSTACK */ 387#endif /* HAVE_USBSTACK */
393 388
394 case USB_INSERTED: 389 case USB_INSERTED:
395#ifdef USB_DELAYED_INSERT 390#ifdef USB_DETECT_BY_CORE
396 if(usb_state != USB_POWERED) 391 if(usb_state != USB_POWERED)
397 break; 392 break;
398 393
@@ -400,7 +395,7 @@ static void usb_thread(void)
400 break; /* Drivers configured but we're still USB_POWERED */ 395 break; /* Drivers configured but we're still USB_POWERED */
401 396
402 host_detected = true; 397 host_detected = true;
403#else /* !USB_DELAYED_INSERT */ 398#else /* !USB_DETECT_BY_CORE */
404 if(usb_state != USB_EXTRACTED) 399 if(usb_state != USB_EXTRACTED)
405 break; 400 break;
406 401
@@ -408,7 +403,7 @@ static void usb_thread(void)
408 break; 403 break;
409 404
410 usb_state = USB_POWERED; 405 usb_state = USB_POWERED;
411#endif /* USB_DELAYED_INSERT */ 406#endif /* USB_DETECT_BY_CORE */
412 407
413 if(usb_power_button()) 408 if(usb_power_button())
414 { 409 {
@@ -461,7 +456,7 @@ static void usb_thread(void)
461 break; 456 break;
462 /* SYS_USB_CONNECTED_ACK */ 457 /* SYS_USB_CONNECTED_ACK */
463 458
464#ifdef USB_DELAYED_INSERT 459#ifdef USB_DETECT_BY_CORE
465 /* In this case, these events handle cable insertion. USB driver or 460 /* In this case, these events handle cable insertion. USB driver or
466 core determines USB_INSERTED. */ 461 core determines USB_INSERTED. */
467 case USB_POWERED: 462 case USB_POWERED:
@@ -481,7 +476,7 @@ static void usb_thread(void)
481 usb_enable(false); 476 usb_enable(false);
482 /* Fall-through - other legal states can be USB_INSERTED or 477 /* Fall-through - other legal states can be USB_INSERTED or
483 USB_SCREENDUMP */ 478 USB_SCREENDUMP */
484#endif /* USB_DELAYED_INSERT */ 479#endif /* USB_DETECT_BY_CORE */
485 case USB_EXTRACTED: 480 case USB_EXTRACTED:
486 if(usb_state == USB_EXTRACTED) 481 if(usb_state == USB_EXTRACTED)
487 break; 482 break;
@@ -495,7 +490,7 @@ static void usb_thread(void)
495 490
496 /* Ok to broadcast disconnect now */ 491 /* Ok to broadcast disconnect now */
497 usb_configure_drivers(USB_EXTRACTED); 492 usb_configure_drivers(USB_EXTRACTED);
498#ifdef USB_DELAYED_INSERT 493#ifdef USB_DETECT_BY_CORE
499 host_detected = false; 494 host_detected = false;
500#endif 495#endif
501 break; 496 break;
@@ -549,9 +544,9 @@ void usb_status_event(int current_status)
549{ 544{
550 /* Caller isn't expected to filter for changes in status. 545 /* Caller isn't expected to filter for changes in status.
551 * current_status: 546 * current_status:
552 * USB_DETECT_BY_DRV/CORE: USB_POWERED, USB_UNPOWERED, 547 * USB_DETECT_BY_CORE: USB_POWERED, USB_UNPOWERED,
553 USB_INSERTED (driver/core) 548 USB_INSERTED (core)
554 * else: USB_INSERTED, USB_EXTRACTED 549 * else: USB_INSERTED, USB_EXTRACTED
555 */ 550 */
556 if(usb_monitor_enabled) 551 if(usb_monitor_enabled)
557 { 552 {
@@ -572,7 +567,7 @@ void usb_start_monitoring(void)
572 /* An event may have been missed because it was sent before monitoring 567 /* An event may have been missed because it was sent before monitoring
573 * was enabled due to the connector already having been inserted before 568 * was enabled due to the connector already having been inserted before
574 * before or during boot. */ 569 * before or during boot. */
575#ifdef USB_DELAYED_INSERT 570#ifdef USB_DETECT_BY_CORE
576 /* Filter the status - USB_INSERTED may happen later */ 571 /* Filter the status - USB_INSERTED may happen later */
577 status = (status == USB_EXTRACTED) ? USB_UNPOWERED : USB_POWERED; 572 status = (status == USB_EXTRACTED) ? USB_UNPOWERED : USB_POWERED;
578#endif 573#endif