summaryrefslogtreecommitdiff
path: root/firmware/target/arm/imx31
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/imx31')
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/usb-imx31.c29
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/usb-target.h3
2 files changed, 17 insertions, 15 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}
diff --git a/firmware/target/arm/imx31/gigabeat-s/usb-target.h b/firmware/target/arm/imx31/gigabeat-s/usb-target.h
index 31b8080b57..1f96a9a7eb 100644
--- a/firmware/target/arm/imx31/gigabeat-s/usb-target.h
+++ b/firmware/target/arm/imx31/gigabeat-s/usb-target.h
@@ -25,9 +25,6 @@
25#define USB_DRIVER_CLOSE 25#define USB_DRIVER_CLOSE
26#endif 26#endif
27 27
28/* Connect by events, not by tick polling */
29#define USB_STATUS_BY_EVENT
30
31void usb_connect_event(void); 28void usb_connect_event(void);
32void usb_init_device(void); 29void usb_init_device(void);
33int usb_detect(void); 30int usb_detect(void);