summaryrefslogtreecommitdiff
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.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)
53 } 53 }
54} 54}
55 55
56/* Read the immediate state of the cable from the PMIC */
57bool usb_plugged(void)
58{
59 return mc13783_read(MC13783_INTERRUPT_SENSE0) & MC13783_USB4V4S;
60}
61
56void usb_connect_event(void) 62void usb_connect_event(void)
57{ 63{
58 uint32_t status = mc13783_read(MC13783_INTERRUPT_SENSE0); 64 int status = usb_plugged() ? USB_INSERTED : USB_EXTRACTED;
59 usb_status = (status & MC13783_USB4V4S) ? 65 usb_status = status;
60 USB_INSERTED : USB_EXTRACTED;
61 /* Notify power that USB charging is potentially available */ 66 /* Notify power that USB charging is potentially available */
62 charger_usb_detect_event(usb_status); 67 charger_usb_detect_event(status);
63 usb_status_event(usb_status); 68 usb_status_event((status == USB_INSERTED) ? USB_POWERED : USB_UNPOWERED);
64} 69}
65 70
66int usb_detect(void) 71int usb_detect(void)
@@ -68,12 +73,6 @@ int usb_detect(void)
68 return usb_status; 73 return usb_status;
69} 74}
70 75
71/* Read the immediate state of the cable from the PMIC */
72bool usb_plugged(void)
73{
74 return mc13783_read(MC13783_INTERRUPT_SENSE0) & MC13783_USB4V4S;
75}
76
77void usb_init_device(void) 76void usb_init_device(void)
78{ 77{
79 /* Do one-time inits */ 78 /* Do one-time inits */
@@ -107,7 +106,7 @@ void usb_enable(bool on)
107 106
108void usb_attach(void) 107void usb_attach(void)
109{ 108{
110 usb_enable(true); 109 usb_drv_attach();
111} 110}
112 111
113static void __attribute__((interrupt("IRQ"))) USB_OTG_HANDLER(void) 112static void __attribute__((interrupt("IRQ"))) USB_OTG_HANDLER(void)
@@ -122,3 +121,9 @@ void usb_drv_int_enable(bool enable)
122 else 121 else
123 avic_disable_int(USB_OTG); 122 avic_disable_int(USB_OTG);
124} 123}
124
125/* Called during the bus reset interrupt when in detect mode */
126void usb_drv_usb_detect_event(void)
127{
128 usb_status_event(USB_INSERTED);
129}