diff options
Diffstat (limited to 'firmware/target/arm/ipod/power-ipod.c')
-rw-r--r-- | firmware/target/arm/ipod/power-ipod.c | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/firmware/target/arm/ipod/power-ipod.c b/firmware/target/arm/ipod/power-ipod.c index 4266aad896..0becedf2cd 100644 --- a/firmware/target/arm/ipod/power-ipod.c +++ b/firmware/target/arm/ipod/power-ipod.c | |||
@@ -182,3 +182,65 @@ void power_off(void) | |||
182 | #endif | 182 | #endif |
183 | #endif | 183 | #endif |
184 | } | 184 | } |
185 | |||
186 | #ifdef HAVE_USB_CHARGING_ENABLE | ||
187 | void usb_charging_maxcurrent_change(int maxcurrent) | ||
188 | { | ||
189 | bool suspend_charging = (maxcurrent < 100); | ||
190 | bool fast_charging = (maxcurrent >= 500); | ||
191 | |||
192 | /* This GPIO is connected to the LTC4066's SUSP pin */ | ||
193 | /* Setting it high prevents any power being drawn over USB */ | ||
194 | /* which supports USB suspend */ | ||
195 | #if defined(IPOD_VIDEO) || defined(IPOD_NANO) | ||
196 | if (suspend_charging) | ||
197 | GPIOL_OUTPUT_VAL |= 4; | ||
198 | else | ||
199 | GPIOL_OUTPUT_VAL &= ~4; | ||
200 | #elif defined(IPOD_MINI2G) | ||
201 | if (suspend_charging) | ||
202 | GPIOJ_OUTPUT_VAL |= 2; | ||
203 | else | ||
204 | GPIOJ_OUTPUT_VAL &= ~2; | ||
205 | #else | ||
206 | if (suspend_charging) | ||
207 | GPO32_VAL |= 0x8000000; | ||
208 | else | ||
209 | GPO32_VAL &= ~0x8000000; | ||
210 | #endif | ||
211 | |||
212 | /* This GPIO is connected to the LTC4066's HPWR pin */ | ||
213 | /* Setting it low limits current to 100mA, setting it high allows 500mA */ | ||
214 | #if defined(IPOD_VIDEO) || defined(IPOD_NANO) | ||
215 | if (fast_charging) | ||
216 | GPIOA_OUTPUT_VAL |= 4; | ||
217 | else | ||
218 | GPIOA_OUTPUT_VAL &= ~4; | ||
219 | #else | ||
220 | if (fast_charging) | ||
221 | GPO32_VAL |= 0x40; | ||
222 | else | ||
223 | GPO32_VAL &= ~0x40; | ||
224 | #endif | ||
225 | |||
226 | /* This GPIO is connected to the LTC4066's CLDIS pin */ | ||
227 | /* Setting it high allows up to 1.5A of current to be drawn */ | ||
228 | /* This doesn't appear to actually be safe even with an AC charger */ | ||
229 | /* so for now it is disabled. It's not known (or maybe doesn't exist) */ | ||
230 | /* on all models. */ | ||
231 | #if 0 | ||
232 | #if defined(IPOD_VIDEO) | ||
233 | if (unlimited_charging) | ||
234 | GPO32_VAL |= 0x10000000; | ||
235 | else | ||
236 | GPO32_VAL &= ~0x10000000; | ||
237 | #elif defined(IPOD_4G) || defined(IPOD_COLOR) | ||
238 | if (unlimited_charging) | ||
239 | GPO32_VAL |= 0x200; | ||
240 | else | ||
241 | GPO32_VAL &= ~0x200; | ||
242 | #endif | ||
243 | /* This might be GPIOD & 40 on 2G */ | ||
244 | #endif | ||
245 | } | ||
246 | #endif /* HAVE_USB_CHARGING_ENABLE */ | ||