summaryrefslogtreecommitdiffstats
path: root/firmware/target/arm/imx31/gigabeat-s/usb-imx31.c
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2009-01-22 22:05:04 +0000
committerMichael Sevakis <jethead71@rockbox.org>2009-01-22 22:05:04 +0000
commitda76a3469437261bd8857c6eddeaafcc601f373e (patch)
tree33e6c461aeb03d28575166c5ed5002aaf8ea9741 /firmware/target/arm/imx31/gigabeat-s/usb-imx31.c
parent81df953da55e75632b5efbe676f2b348e11b2c4b (diff)
downloadrockbox-da76a3469437261bd8857c6eddeaafcc601f373e.tar.gz
rockbox-da76a3469437261bd8857c6eddeaafcc601f373e.tar.bz2
rockbox-da76a3469437261bd8857c6eddeaafcc601f373e.zip
Use bus reset detection for all ARC OTG devices. Remove conflict from LV24020LP driver with some GPIO-by-number macros for PP502x. Start monitoring for USB stack once all core threads and queues are created otherwise queues will likely be registered after USB acks. Putting PP502x system_reboot in IRAM (unmapped, uncached) memory seems to help it work more consistently. Hopefully I got all the PP USB connect handlers in the right spot in irq_handler. If device seems unresponsive to cable, check there first.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19819 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/imx31/gigabeat-s/usb-imx31.c')
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/usb-imx31.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/firmware/target/arm/imx31/gigabeat-s/usb-imx31.c b/firmware/target/arm/imx31/gigabeat-s/usb-imx31.c
index c0d7cb8d2a..99f3e072eb 100644
--- a/firmware/target/arm/imx31/gigabeat-s/usb-imx31.c
+++ b/firmware/target/arm/imx31/gigabeat-s/usb-imx31.c
@@ -53,14 +53,19 @@ static void enable_transceiver(bool enable)
}
}
+/* Read the immediate state of the cable from the PMIC */
+bool usb_plugged(void)
+{
+ return mc13783_read(MC13783_INTERRUPT_SENSE0) & MC13783_USB4V4S;
+}
+
void usb_connect_event(void)
{
- uint32_t status = mc13783_read(MC13783_INTERRUPT_SENSE0);
- usb_status = (status & MC13783_USB4V4S) ?
- USB_INSERTED : USB_EXTRACTED;
+ int status = usb_plugged() ? USB_INSERTED : USB_EXTRACTED;
+ usb_status = status;
/* Notify power that USB charging is potentially available */
- charger_usb_detect_event(usb_status);
- usb_status_event(usb_status);
+ charger_usb_detect_event(status);
+ usb_status_event((status == USB_INSERTED) ? USB_POWERED : USB_UNPOWERED);
}
int usb_detect(void)
@@ -68,12 +73,6 @@ int usb_detect(void)
return usb_status;
}
-/* Read the immediate state of the cable from the PMIC */
-bool usb_plugged(void)
-{
- return mc13783_read(MC13783_INTERRUPT_SENSE0) & MC13783_USB4V4S;
-}
-
void usb_init_device(void)
{
/* Do one-time inits */
@@ -107,7 +106,7 @@ void usb_enable(bool on)
void usb_attach(void)
{
- usb_enable(true);
+ usb_drv_attach();
}
static void __attribute__((interrupt("IRQ"))) USB_OTG_HANDLER(void)
@@ -122,3 +121,9 @@ void usb_drv_int_enable(bool enable)
else
avic_disable_int(USB_OTG);
}
+
+/* Called during the bus reset interrupt when in detect mode */
+void usb_drv_usb_detect_event(void)
+{
+ usb_status_event(USB_INSERTED);
+}