From a9c20f5789c13b486d217024a020f9d6163e2d51 Mon Sep 17 00:00:00 2001 From: Michael Sevakis Date: Wed, 21 May 2008 08:42:11 +0000 Subject: Gigabeat S: 1) Rework event handling and static registration mechanism. No target- specific code in mc13783 driver. GPIO event driver interfaces more cleanly. 2) Somewhat related - enable thread priority for bootloader which is desireable here (ffs is used for GPIO event enabling anyway and that goes along with priority). git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17593 a1c6a512-1295-4272-9138-f99709370657 --- firmware/target/arm/imx31/gigabeat-s/usb-imx31.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'firmware/target/arm/imx31/gigabeat-s/usb-imx31.c') diff --git a/firmware/target/arm/imx31/gigabeat-s/usb-imx31.c b/firmware/target/arm/imx31/gigabeat-s/usb-imx31.c index f12fd8f0b1..ad6c77138c 100644 --- a/firmware/target/arm/imx31/gigabeat-s/usb-imx31.c +++ b/firmware/target/arm/imx31/gigabeat-s/usb-imx31.c @@ -48,9 +48,10 @@ static void enable_transceiver(bool enable) } } -void usb_set_status(bool plugged) +void usb_connect_event(void) { - usb_status = plugged ? USB_INSERTED : USB_EXTRACTED; + uint32_t status = mc13783_read(MC13783_INTERRUPT_SENSE0); + usb_status = (status & MC13783_USB4V4S) ? USB_INSERTED : USB_EXTRACTED; } int usb_detect(void) @@ -73,7 +74,11 @@ void usb_init_device(void) /* Module will be turned off later after firmware init */ usb_drv_startup(); - mc13783_clear(MC13783_INTERRUPT_MASK0, MC13783_USB4V4M); + /* Initially poll */ + usb_connect_event(); + + /* Enable PMIC event */ + mc13783_enable_event(MC13783_USB4V4_EVENT); } void usb_enable(bool on) -- cgit v1.2.3