summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTorne Wuff <torne@wolfpuppy.org.uk>2010-06-06 13:01:19 +0000
committerTorne Wuff <torne@wolfpuppy.org.uk>2010-06-06 13:01:19 +0000
commit4a2cab6aa1008a4f5ac05dac44c99b7f1a05e8f4 (patch)
tree229c2d69c074b4fa5973ccc6050b7bba187a6d14
parent32a2b3e3fa36767fdad90b565fc52a1050b39926 (diff)
downloadrockbox-4a2cab6aa1008a4f5ac05dac44c99b7f1a05e8f4.tar.gz
rockbox-4a2cab6aa1008a4f5ac05dac44c99b7f1a05e8f4.zip
USB charging support for iPods.
This adds proper full speed charging support for iPod 4G, Color, Mini 1G, Mini 2G, Nano 1G, and Video. Nano 2G already has support, so now all ipods charge (except 1G-3G whose hardware doesn't support USB charging). USB charging defaults to on, but will only charge at full speed from a USB host. To charge from an AC charger, you need to set the USB charging mode to "force". It may be possible to detect AC chargers in a future version, at least on some models. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26626 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/export/config/ipod4g.h4
-rw-r--r--firmware/export/config/ipodcolor.h4
-rw-r--r--firmware/export/config/ipodmini1g.h5
-rw-r--r--firmware/export/config/ipodmini2g.h4
-rw-r--r--firmware/export/config/ipodnano1g.h4
-rw-r--r--firmware/export/config/ipodvideo.h4
-rw-r--r--firmware/target/arm/ipod/power-ipod.c62
7 files changed, 87 insertions, 0 deletions
diff --git a/firmware/export/config/ipod4g.h b/firmware/export/config/ipod4g.h
index b9251e72fe..2a08a710e7 100644
--- a/firmware/export/config/ipod4g.h
+++ b/firmware/export/config/ipod4g.h
@@ -146,6 +146,10 @@
146/* define this if the unit can be powered or charged via USB */ 146/* define this if the unit can be powered or charged via USB */
147#define HAVE_USB_POWER 147#define HAVE_USB_POWER
148 148
149/* define this if the unit can have USB charging disabled by user -
150 * if USB/MAIN power is discernable and hardware doesn't compel charging */
151#define HAVE_USB_CHARGING_ENABLE
152
149/* define current usage levels */ 153/* define current usage levels */
150#define CURRENT_NORMAL 100 /* MP3: ~10.5h out of 1100mAh battery */ 154#define CURRENT_NORMAL 100 /* MP3: ~10.5h out of 1100mAh battery */
151#define CURRENT_BACKLIGHT 20 /* FIXME: this needs adjusting */ 155#define CURRENT_BACKLIGHT 20 /* FIXME: this needs adjusting */
diff --git a/firmware/export/config/ipodcolor.h b/firmware/export/config/ipodcolor.h
index 5448cb76b7..2b4276257f 100644
--- a/firmware/export/config/ipodcolor.h
+++ b/firmware/export/config/ipodcolor.h
@@ -130,6 +130,10 @@
130/* define this if the unit can be powered or charged via USB */ 130/* define this if the unit can be powered or charged via USB */
131#define HAVE_USB_POWER 131#define HAVE_USB_POWER
132 132
133/* define this if the unit can have USB charging disabled by user -
134 * if USB/MAIN power is discernable and hardware doesn't compel charging */
135#define HAVE_USB_CHARGING_ENABLE
136
133/* define current usage levels */ 137/* define current usage levels */
134#define CURRENT_NORMAL 69 /* ~10h (700mAh), see FS#9072 */ 138#define CURRENT_NORMAL 69 /* ~10h (700mAh), see FS#9072 */
135#define CURRENT_BACKLIGHT 20 /* FIXME: this needs adjusting */ 139#define CURRENT_BACKLIGHT 20 /* FIXME: this needs adjusting */
diff --git a/firmware/export/config/ipodmini1g.h b/firmware/export/config/ipodmini1g.h
index 2f261a8886..81529a5de5 100644
--- a/firmware/export/config/ipodmini1g.h
+++ b/firmware/export/config/ipodmini1g.h
@@ -143,6 +143,11 @@
143/* define this if the unit can be powered or charged via USB */ 143/* define this if the unit can be powered or charged via USB */
144#define HAVE_USB_POWER 144#define HAVE_USB_POWER
145 145
146/* define this if the unit can have USB charging disabled by user -
147:Qa
148 * if USB/MAIN power is discernable and hardware doesn't compel charging */
149#define HAVE_USB_CHARGING_ENABLE
150
146/* Define this if you have a PortalPlayer PP5020 */ 151/* Define this if you have a PortalPlayer PP5020 */
147#define CONFIG_CPU PP5020 152#define CONFIG_CPU PP5020
148 153
diff --git a/firmware/export/config/ipodmini2g.h b/firmware/export/config/ipodmini2g.h
index b9b4f48555..0b6e7636c0 100644
--- a/firmware/export/config/ipodmini2g.h
+++ b/firmware/export/config/ipodmini2g.h
@@ -150,6 +150,10 @@
150/* define this if the unit can be powered or charged via USB */ 150/* define this if the unit can be powered or charged via USB */
151#define HAVE_USB_POWER 151#define HAVE_USB_POWER
152 152
153/* define this if the unit can have USB charging disabled by user -
154 * if USB/MAIN power is discernable and hardware doesn't compel charging */
155#define HAVE_USB_CHARGING_ENABLE
156
153/* Define this if you have a PortalPlayer PP5022 */ 157/* Define this if you have a PortalPlayer PP5022 */
154#define CONFIG_CPU PP5022 158#define CONFIG_CPU PP5022
155 159
diff --git a/firmware/export/config/ipodnano1g.h b/firmware/export/config/ipodnano1g.h
index 24ed973249..f60f3c975a 100644
--- a/firmware/export/config/ipodnano1g.h
+++ b/firmware/export/config/ipodnano1g.h
@@ -131,6 +131,10 @@
131/* define this if the unit can be powered or charged via USB */ 131/* define this if the unit can be powered or charged via USB */
132#define HAVE_USB_POWER 132#define HAVE_USB_POWER
133 133
134/* define this if the unit can have USB charging disabled by user -
135 * if USB/MAIN power is discernable and hardware doesn't compel charging */
136#define HAVE_USB_CHARGING_ENABLE
137
134#define CURRENT_NORMAL 32 /* MP3: ~9h playback out of 300mAh battery */ 138#define CURRENT_NORMAL 32 /* MP3: ~9h playback out of 300mAh battery */
135#define CURRENT_BACKLIGHT 20 /* FIXME: this needs adjusting */ 139#define CURRENT_BACKLIGHT 20 /* FIXME: this needs adjusting */
136#if defined(HAVE_RECORDING) 140#if defined(HAVE_RECORDING)
diff --git a/firmware/export/config/ipodvideo.h b/firmware/export/config/ipodvideo.h
index bad7195c32..54c604f38a 100644
--- a/firmware/export/config/ipodvideo.h
+++ b/firmware/export/config/ipodvideo.h
@@ -154,6 +154,10 @@
154/* define this if the unit can be powered or charged via USB */ 154/* define this if the unit can be powered or charged via USB */
155#define HAVE_USB_POWER 155#define HAVE_USB_POWER
156 156
157/* define this if the unit can have USB charging disabled by user -
158 * if USB/MAIN power is discernable and hardware doesn't compel charging */
159#define HAVE_USB_CHARGING_ENABLE
160
157/* define current usage levels */ 161/* define current usage levels */
158#define CURRENT_NORMAL 24 /* 30MHz clock, LCD off, accessory supply on */ 162#define CURRENT_NORMAL 24 /* 30MHz clock, LCD off, accessory supply on */
159#define CURRENT_BACKLIGHT 20 /* FIXME: this needs adjusting */ 163#define CURRENT_BACKLIGHT 20 /* FIXME: this needs adjusting */
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
187void 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 */