diff options
-rw-r--r-- | firmware/export/config/ipod4g.h | 4 | ||||
-rw-r--r-- | firmware/export/config/ipodcolor.h | 4 | ||||
-rw-r--r-- | firmware/export/config/ipodmini1g.h | 5 | ||||
-rw-r--r-- | firmware/export/config/ipodmini2g.h | 4 | ||||
-rw-r--r-- | firmware/export/config/ipodnano1g.h | 4 | ||||
-rw-r--r-- | firmware/export/config/ipodvideo.h | 4 | ||||
-rw-r--r-- | firmware/target/arm/ipod/power-ipod.c | 62 |
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 @@ /* define this if the unit can be powered or charged via USB */ #define HAVE_USB_POWER +/* define this if the unit can have USB charging disabled by user - + * if USB/MAIN power is discernable and hardware doesn't compel charging */ +#define HAVE_USB_CHARGING_ENABLE + /* define current usage levels */ #define CURRENT_NORMAL 100 /* MP3: ~10.5h out of 1100mAh battery */ #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 @@ /* define this if the unit can be powered or charged via USB */ #define HAVE_USB_POWER +/* define this if the unit can have USB charging disabled by user - + * if USB/MAIN power is discernable and hardware doesn't compel charging */ +#define HAVE_USB_CHARGING_ENABLE + /* define current usage levels */ #define CURRENT_NORMAL 69 /* ~10h (700mAh), see FS#9072 */ #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 @@ /* define this if the unit can be powered or charged via USB */ #define HAVE_USB_POWER +/* define this if the unit can have USB charging disabled by user - +:Qa + * if USB/MAIN power is discernable and hardware doesn't compel charging */ +#define HAVE_USB_CHARGING_ENABLE + /* Define this if you have a PortalPlayer PP5020 */ #define CONFIG_CPU PP5020 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 @@ /* define this if the unit can be powered or charged via USB */ #define HAVE_USB_POWER +/* define this if the unit can have USB charging disabled by user - + * if USB/MAIN power is discernable and hardware doesn't compel charging */ +#define HAVE_USB_CHARGING_ENABLE + /* Define this if you have a PortalPlayer PP5022 */ #define CONFIG_CPU PP5022 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 @@ /* define this if the unit can be powered or charged via USB */ #define HAVE_USB_POWER +/* define this if the unit can have USB charging disabled by user - + * if USB/MAIN power is discernable and hardware doesn't compel charging */ +#define HAVE_USB_CHARGING_ENABLE + #define CURRENT_NORMAL 32 /* MP3: ~9h playback out of 300mAh battery */ #define CURRENT_BACKLIGHT 20 /* FIXME: this needs adjusting */ #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 @@ /* define this if the unit can be powered or charged via USB */ #define HAVE_USB_POWER +/* define this if the unit can have USB charging disabled by user - + * if USB/MAIN power is discernable and hardware doesn't compel charging */ +#define HAVE_USB_CHARGING_ENABLE + /* define current usage levels */ #define CURRENT_NORMAL 24 /* 30MHz clock, LCD off, accessory supply on */ #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) #endif #endif } + +#ifdef HAVE_USB_CHARGING_ENABLE +void usb_charging_maxcurrent_change(int maxcurrent) +{ + bool suspend_charging = (maxcurrent < 100); + bool fast_charging = (maxcurrent >= 500); + + /* This GPIO is connected to the LTC4066's SUSP pin */ + /* Setting it high prevents any power being drawn over USB */ + /* which supports USB suspend */ +#if defined(IPOD_VIDEO) || defined(IPOD_NANO) + if (suspend_charging) + GPIOL_OUTPUT_VAL |= 4; + else + GPIOL_OUTPUT_VAL &= ~4; +#elif defined(IPOD_MINI2G) + if (suspend_charging) + GPIOJ_OUTPUT_VAL |= 2; + else + GPIOJ_OUTPUT_VAL &= ~2; +#else + if (suspend_charging) + GPO32_VAL |= 0x8000000; + else + GPO32_VAL &= ~0x8000000; +#endif + + /* This GPIO is connected to the LTC4066's HPWR pin */ + /* Setting it low limits current to 100mA, setting it high allows 500mA */ +#if defined(IPOD_VIDEO) || defined(IPOD_NANO) + if (fast_charging) + GPIOA_OUTPUT_VAL |= 4; + else + GPIOA_OUTPUT_VAL &= ~4; +#else + if (fast_charging) + GPO32_VAL |= 0x40; + else + GPO32_VAL &= ~0x40; +#endif + + /* This GPIO is connected to the LTC4066's CLDIS pin */ + /* Setting it high allows up to 1.5A of current to be drawn */ + /* This doesn't appear to actually be safe even with an AC charger */ + /* so for now it is disabled. It's not known (or maybe doesn't exist) */ + /* on all models. */ +#if 0 +#if defined(IPOD_VIDEO) + if (unlimited_charging) + GPO32_VAL |= 0x10000000; + else + GPO32_VAL &= ~0x10000000; +#elif defined(IPOD_4G) || defined(IPOD_COLOR) + if (unlimited_charging) + GPO32_VAL |= 0x200; + else + GPO32_VAL &= ~0x200; +#endif + /* This might be GPIOD & 40 on 2G */ +#endif +} +#endif /* HAVE_USB_CHARGING_ENABLE */ |