summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/usb-imx31.c3
-rw-r--r--firmware/target/arm/usb-drv-arc.c5
-rw-r--r--firmware/target/arm/usb-fw-pp502x.c15
3 files changed, 14 insertions, 9 deletions
diff --git a/firmware/target/arm/imx31/gigabeat-s/usb-imx31.c b/firmware/target/arm/imx31/gigabeat-s/usb-imx31.c
index 99f3e072eb..8682cff7c7 100644
--- a/firmware/target/arm/imx31/gigabeat-s/usb-imx31.c
+++ b/firmware/target/arm/imx31/gigabeat-s/usb-imx31.c
@@ -125,5 +125,6 @@ void usb_drv_int_enable(bool enable)
/* Called during the bus reset interrupt when in detect mode */
void usb_drv_usb_detect_event(void)
{
- usb_status_event(USB_INSERTED);
+ if (usb_drv_powered())
+ usb_status_event(USB_INSERTED);
}
diff --git a/firmware/target/arm/usb-drv-arc.c b/firmware/target/arm/usb-drv-arc.c
index 15f3bf2c6c..5a08acb348 100644
--- a/firmware/target/arm/usb-drv-arc.c
+++ b/firmware/target/arm/usb-drv-arc.c
@@ -509,10 +509,7 @@ void usb_drv_int(void)
if (UNLIKELY(usbintr == USBINTR_RESET_EN)) {
/* USB detected - detach and inform */
usb_drv_stop();
- /* A false reset may occur upon unplugging, be sure VBUS is above
- * the 4V4 threshold. */
- if (usb_drv_powered())
- usb_drv_usb_detect_event();
+ usb_drv_usb_detect_event();
}
else
{
diff --git a/firmware/target/arm/usb-fw-pp502x.c b/firmware/target/arm/usb-fw-pp502x.c
index 883ca1e8e2..cf5a82f37c 100644
--- a/firmware/target/arm/usb-fw-pp502x.c
+++ b/firmware/target/arm/usb-fw-pp502x.c
@@ -177,6 +177,11 @@ void usb_attach(void)
usb_drv_attach();
}
+static bool usb_pin_state(void)
+{
+ return (USB_GPIO_INPUT_VAL & USB_GPIO_MASK) == USB_GPIO_VAL;
+}
+
#ifdef USB_STATUS_BY_EVENT
/* Cannot always tell power pin from USB pin */
static int usb_status = USB_EXTRACTED;
@@ -197,10 +202,13 @@ void usb_insert_int(void)
timeout_register(&usb_oneshot, usb_timeout_event, HZ/5, val);
}
-/* Called during the bus reset interrupt when in detect mode */
+/* Called during the bus reset interrupt when in detect mode - filter for
+ * invalid bus reset when unplugging by checking the pin state. */
void usb_drv_usb_detect_event(void)
{
- usb_status_event(USB_INSERTED);
+ if(usb_pin_state()) {
+ usb_status_event(USB_INSERTED);
+ }
}
#endif /* USB_STATUS_BY_EVENT */
@@ -221,8 +229,7 @@ int usb_detect(void)
#ifdef USB_STATUS_BY_EVENT
return usb_status;
#else
- return ((USB_GPIO_INPUT_VAL & USB_GPIO_MASK) == USB_GPIO_VAL) ?
- USB_INSERTED : USB_EXTRACTED;
+ return usb_pin_state() ? USB_INSERTED : USB_EXTRACTED;
#endif
}