summaryrefslogtreecommitdiff
path: root/firmware/target/arm/usb-fw-pp502x.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/usb-fw-pp502x.c')
-rw-r--r--firmware/target/arm/usb-fw-pp502x.c46
1 files changed, 35 insertions, 11 deletions
diff --git a/firmware/target/arm/usb-fw-pp502x.c b/firmware/target/arm/usb-fw-pp502x.c
index 7af699c064..0813ae1c59 100644
--- a/firmware/target/arm/usb-fw-pp502x.c
+++ b/firmware/target/arm/usb-fw-pp502x.c
@@ -33,18 +33,29 @@
33void usb_init_device(void) 33void usb_init_device(void)
34{ 34{
35 /* enable usb module */ 35 /* enable usb module */
36 GPO32_ENABLE |= 0x200;
37
38 outl(inl(0x7000002C) | 0x3000000, 0x7000002C); 36 outl(inl(0x7000002C) | 0x3000000, 0x7000002C);
39 DEV_EN |= DEV_USB; 37 DEV_EN |= DEV_USB0;
38 DEV_EN |= DEV_USB1;
40 39
41 DEV_RS |= DEV_USB; /* reset usb start */ 40 /* reset both USBs */
42 DEV_RS &=~DEV_USB;/* reset usb end */ 41 DEV_RS |= DEV_USB0;
42 DEV_RS &=~DEV_USB0;
43 DEV_RS |= DEV_USB1;
44 DEV_RS &=~DEV_USB1;
43 45
46#if CONFIG_CPU == PP5020
44 DEV_INIT2 |= INIT_USB; 47 DEV_INIT2 |= INIT_USB;
48#endif
45 while ((inl(0x70000028) & 0x80) == 0); 49 while ((inl(0x70000028) & 0x80) == 0);
46 outl(inl(0x70000028) | 0x2, 0x70000028); 50 outl(inl(0x70000028) | 0x2, 0x70000028);
47 udelay(0x186A0); 51 udelay(0x186A0);
52
53 /* disable USB-devices until USB is detected via GPIO */
54 DEV_EN &= ~DEV_USB0;
55 DEV_EN &= ~DEV_USB1;
56#if CONFIG_CPU == PP5020
57 DEV_INIT2 &= ~INIT_USB;
58#endif
48 59
49#if defined(IPOD_COLOR) || defined(IPOD_4G) \ 60#if defined(IPOD_COLOR) || defined(IPOD_4G) \
50 || defined(IPOD_MINI) || defined(IPOD_MINI2G) 61 || defined(IPOD_MINI) || defined(IPOD_MINI2G)
@@ -85,33 +96,46 @@ void usb_enable(bool on)
85 96
86static bool usb_pin_detect(void) 97static bool usb_pin_detect(void)
87{ 98{
99 bool retval = false;
100
88#if defined(IPOD_4G) || defined(IPOD_COLOR) \ 101#if defined(IPOD_4G) || defined(IPOD_COLOR) \
89 || defined(IPOD_MINI) || defined(IPOD_MINI2G) 102 || defined(IPOD_MINI) || defined(IPOD_MINI2G)
90 /* GPIO D bit 3 is usb detect */ 103 /* GPIO D bit 3 is usb detect */
91 if (GPIOD_INPUT_VAL & 0x08) 104 if (GPIOD_INPUT_VAL & 0x08)
92 return true; 105 retval = true;
93 106
94#elif defined(IPOD_NANO) || defined(IPOD_VIDEO) 107#elif defined(IPOD_NANO) || defined(IPOD_VIDEO)
95 /* GPIO L bit 4 is usb detect */ 108 /* GPIO L bit 4 is usb detect */
96 if (GPIOL_INPUT_VAL & 0x10) 109 if (GPIOL_INPUT_VAL & 0x10)
97 return true; 110 retval = true;
98 111
99#elif defined(SANSA_C200) 112#elif defined(SANSA_C200)
100 /* GPIO H bit 1 is usb detect */ 113 /* GPIO H bit 1 is usb detect */
101 if (GPIOH_INPUT_VAL & 0x02) 114 if (GPIOH_INPUT_VAL & 0x02)
102 return true; 115 retval = true;
103 116
104#elif defined(SANSA_E200) 117#elif defined(SANSA_E200)
105 /* GPIO B bit 4 is usb detect */ 118 /* GPIO B bit 4 is usb detect */
106 if (GPIOB_INPUT_VAL & 0x10) 119 if (GPIOB_INPUT_VAL & 0x10)
107 return true; 120 retval = true;
108 121
109#elif defined(IRIVER_H10) || defined(IRIVER_H10_5GB) 122#elif defined(IRIVER_H10) || defined(IRIVER_H10_5GB)
110 /* GPIO L bit 2 is usb detect */ 123 /* GPIO L bit 2 is usb detect */
111 if (GPIOL_INPUT_VAL & 0x4) 124 if (GPIOL_INPUT_VAL & 0x4)
112 return true; 125 retval = true;
113#endif 126#endif
114 return false; 127
128 /* if USB is detected, re-enable the USB-devices */
129 if (retval)
130 {
131 DEV_EN |= DEV_USB0;
132 DEV_EN |= DEV_USB1;
133#if CONFIG_CPU == PP5020
134 DEV_INIT2 |= INIT_USB;
135#endif
136 }
137
138 return retval;
115} 139}
116 140
117/* detect host or charger (INSERTED or POWERED) */ 141/* detect host or charger (INSERTED or POWERED) */