From 616c98b38f6ddac0ac3dde8ec0fa248f835717e2 Mon Sep 17 00:00:00 2001 From: Michael Sevakis Date: Mon, 19 Jan 2009 13:41:25 +0000 Subject: USB detection changes. c200/e200: Consider USB to be powered when charger is plugged but detect USB connection by bus reset. When received, disconnect and restart the driver fully enabled. imx31: Fix hack used to make initial connect succeeded-- set PHY type before initial reset. General: Move some target code out of usb-drv-arc.c and implement it in respective usb sources and CPU headers so things stay clean. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19797 a1c6a512-1295-4272-9138-f99709370657 --- firmware/target/arm/imx31/gigabeat-s/usb-imx31.c | 35 +++++++++++++++++------- 1 file changed, 25 insertions(+), 10 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 cd8b513ecd..c0d7cb8d2a 100644 --- a/firmware/target/arm/imx31/gigabeat-s/usb-imx31.c +++ b/firmware/target/arm/imx31/gigabeat-s/usb-imx31.c @@ -29,6 +29,7 @@ #include "usb-target.h" #include "clkctl-imx31.h" #include "power-imx31.h" +#include "avic-imx31.h" #include "mc13783.h" static int usb_status = USB_EXTRACTED; @@ -75,11 +76,7 @@ bool usb_plugged(void) void usb_init_device(void) { - imx31_clkctl_module_clock_gating(CG_USBOTG, CGM_ON_ALL); - - enable_transceiver(true); - - /* Module will be turned off later after firmware init */ + /* Do one-time inits */ usb_drv_startup(); /* Initially poll */ @@ -91,19 +88,37 @@ void usb_init_device(void) void usb_enable(bool on) { + /* Module clock should be on since since this could be called with + * OFF initially and writing module registers would hardlock otherwise. */ + imx31_clkctl_module_clock_gating(CG_USBOTG, CGM_ON_ALL); + enable_transceiver(true); + if (on) { - imx31_clkctl_module_clock_gating(CG_USBOTG, CGM_ON_ALL); - enable_transceiver(true); usb_core_init(); } else { - /* Module clock should be on since this could be called first */ - imx31_clkctl_module_clock_gating(CG_USBOTG, CGM_ON_ALL); - enable_transceiver(true); usb_core_exit(); enable_transceiver(false); imx31_clkctl_module_clock_gating(CG_USBOTG, CGM_OFF); } } + +void usb_attach(void) +{ + usb_enable(true); +} + +static void __attribute__((interrupt("IRQ"))) USB_OTG_HANDLER(void) +{ + usb_drv_int(); /* Call driver handler */ +} + +void usb_drv_int_enable(bool enable) +{ + if (enable) + avic_enable_int(USB_OTG, IRQ, 7, USB_OTG_HANDLER); + else + avic_disable_int(USB_OTG); +} -- cgit v1.2.3