summaryrefslogtreecommitdiff
path: root/firmware/target/arm/imx31/gigabeat-s
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2009-01-19 13:41:25 +0000
committerMichael Sevakis <jethead71@rockbox.org>2009-01-19 13:41:25 +0000
commit616c98b38f6ddac0ac3dde8ec0fa248f835717e2 (patch)
tree5eeeabb85fbefa162a438edca88611c1bc688269 /firmware/target/arm/imx31/gigabeat-s
parentcef6399c4c3bcaa35733bdab8b9016b66b71a6f0 (diff)
downloadrockbox-616c98b38f6ddac0ac3dde8ec0fa248f835717e2.tar.gz
rockbox-616c98b38f6ddac0ac3dde8ec0fa248f835717e2.zip
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
Diffstat (limited to 'firmware/target/arm/imx31/gigabeat-s')
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/system-target.h8
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/usb-imx31.c35
2 files changed, 33 insertions, 10 deletions
diff --git a/firmware/target/arm/imx31/gigabeat-s/system-target.h b/firmware/target/arm/imx31/gigabeat-s/system-target.h
index 847e6cfc51..b99b31d1b4 100644
--- a/firmware/target/arm/imx31/gigabeat-s/system-target.h
+++ b/firmware/target/arm/imx31/gigabeat-s/system-target.h
@@ -31,6 +31,14 @@
31#define CPUFREQ_MAX CPU_FREQ 31#define CPUFREQ_MAX CPU_FREQ
32#endif 32#endif
33 33
34/* For USB driver - no accuracy assurance */
35static inline void udelay(unsigned int usecs)
36{
37 unsigned int x;
38 for (x = 0; x < 300*usecs; x++)
39 asm volatile ("");
40}
41
34#if 0 42#if 0
35static inline void udelay(unsigned int usecs) 43static inline void udelay(unsigned int usecs)
36{ 44{
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 @@
29#include "usb-target.h" 29#include "usb-target.h"
30#include "clkctl-imx31.h" 30#include "clkctl-imx31.h"
31#include "power-imx31.h" 31#include "power-imx31.h"
32#include "avic-imx31.h"
32#include "mc13783.h" 33#include "mc13783.h"
33 34
34static int usb_status = USB_EXTRACTED; 35static int usb_status = USB_EXTRACTED;
@@ -75,11 +76,7 @@ bool usb_plugged(void)
75 76
76void usb_init_device(void) 77void usb_init_device(void)
77{ 78{
78 imx31_clkctl_module_clock_gating(CG_USBOTG, CGM_ON_ALL); 79 /* Do one-time inits */
79
80 enable_transceiver(true);
81
82 /* Module will be turned off later after firmware init */
83 usb_drv_startup(); 80 usb_drv_startup();
84 81
85 /* Initially poll */ 82 /* Initially poll */
@@ -91,19 +88,37 @@ void usb_init_device(void)
91 88
92void usb_enable(bool on) 89void usb_enable(bool on)
93{ 90{
91 /* Module clock should be on since since this could be called with
92 * OFF initially and writing module registers would hardlock otherwise. */
93 imx31_clkctl_module_clock_gating(CG_USBOTG, CGM_ON_ALL);
94 enable_transceiver(true);
95
94 if (on) 96 if (on)
95 { 97 {
96 imx31_clkctl_module_clock_gating(CG_USBOTG, CGM_ON_ALL);
97 enable_transceiver(true);
98 usb_core_init(); 98 usb_core_init();
99 } 99 }
100 else 100 else
101 { 101 {
102 /* Module clock should be on since this could be called first */
103 imx31_clkctl_module_clock_gating(CG_USBOTG, CGM_ON_ALL);
104 enable_transceiver(true);
105 usb_core_exit(); 102 usb_core_exit();
106 enable_transceiver(false); 103 enable_transceiver(false);
107 imx31_clkctl_module_clock_gating(CG_USBOTG, CGM_OFF); 104 imx31_clkctl_module_clock_gating(CG_USBOTG, CGM_OFF);
108 } 105 }
109} 106}
107
108void usb_attach(void)
109{
110 usb_enable(true);
111}
112
113static void __attribute__((interrupt("IRQ"))) USB_OTG_HANDLER(void)
114{
115 usb_drv_int(); /* Call driver handler */
116}
117
118void usb_drv_int_enable(bool enable)
119{
120 if (enable)
121 avic_enable_int(USB_OTG, IRQ, 7, USB_OTG_HANDLER);
122 else
123 avic_disable_int(USB_OTG);
124}