diff options
Diffstat (limited to 'firmware/target/arm/imx31/gigabeat-s/usb-gigabeat-s.c')
-rw-r--r-- | firmware/target/arm/imx31/gigabeat-s/usb-gigabeat-s.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/firmware/target/arm/imx31/gigabeat-s/usb-gigabeat-s.c b/firmware/target/arm/imx31/gigabeat-s/usb-gigabeat-s.c index b157544016..1584ffb574 100644 --- a/firmware/target/arm/imx31/gigabeat-s/usb-gigabeat-s.c +++ b/firmware/target/arm/imx31/gigabeat-s/usb-gigabeat-s.c | |||
@@ -59,16 +59,23 @@ bool usb_plugged(void) | |||
59 | return mc13783_read(MC13783_INTERRUPT_SENSE0) & MC13783_USB4V4S; | 59 | return mc13783_read(MC13783_INTERRUPT_SENSE0) & MC13783_USB4V4S; |
60 | } | 60 | } |
61 | 61 | ||
62 | void usb_connect_event(void) | 62 | /* Helper to update the USB cable status */ |
63 | static void update_usb_status(bool sense) | ||
63 | { | 64 | { |
64 | /* Read the immediate state of the cable from the PMIC */ | 65 | int status = sense ? USB_INSERTED : USB_EXTRACTED; |
65 | int status = usb_plugged() ? USB_INSERTED : USB_EXTRACTED; | ||
66 | usb_status = status; | 66 | usb_status = status; |
67 | /* Notify power that USB charging is potentially available */ | 67 | /* Notify power that USB charging is potentially available */ |
68 | charger_usb_detect_event(status); | 68 | charger_usb_detect_event(status); |
69 | usb_status_event(status); | 69 | usb_status_event(status); |
70 | } | 70 | } |
71 | 71 | ||
72 | /* Detect presence of USB bus - called from PMIC ISR */ | ||
73 | void usb_connect_event(void) | ||
74 | { | ||
75 | /* Read the associated sense value */ | ||
76 | update_usb_status(mc13783_event_sense(MC13783_USB_EVENT)); | ||
77 | } | ||
78 | |||
72 | int usb_detect(void) | 79 | int usb_detect(void) |
73 | { | 80 | { |
74 | return usb_status; | 81 | return usb_status; |
@@ -80,10 +87,10 @@ void usb_init_device(void) | |||
80 | usb_drv_startup(); | 87 | usb_drv_startup(); |
81 | 88 | ||
82 | /* Initially poll */ | 89 | /* Initially poll */ |
83 | usb_connect_event(); | 90 | update_usb_status(usb_plugged()); |
84 | 91 | ||
85 | /* Enable PMIC event */ | 92 | /* Enable PMIC event */ |
86 | mc13783_enable_event(MC13783_USB_EVENT); | 93 | mc13783_enable_event(MC13783_USB_EVENT, true); |
87 | } | 94 | } |
88 | 95 | ||
89 | void usb_enable(bool on) | 96 | void usb_enable(bool on) |