This is the bug/patch tracker for Rockbox. Click here for more information.
Quick links: Bugs · Patches · Rockbox frontpage
FS#12522 - iPod Classic/6G: charger detection
Attached to Project:
Rockbox
Opened by Cástor Muñoz (prof_wolfff) - Sunday, 08 January 2012, 23:17 GMT+2
Opened by Cástor Muñoz (prof_wolfff) - Sunday, 08 January 2012, 23:17 GMT+2
|
DetailsExternal/USB adapters are not correctly detected on my Classic 80Gb, this patch detects it so car mode functionality now works, also the iPod is powered-up when USB cable is inserted.
The function power_input_status() returns USB charger when both external and USB chargers are present. It is possible to detect the external adapter when USB cable is plugged but it is necesary to poll the PMU (not IRQ safe), and i think this information is not currently used at all. |
This task depends upon
This is what i found on my iPod:
PDAT(12) bit 3 -> USB plugged (Vbus detected is supposed)
PDAT(11) bits 4:5 -> charge status: CHARGING, DISCHARGING, TOPOFF and UNKNOWN (this state is infrequent and spurious so cannot figure what it means)
I didn't found a GPIO where the external adaptor presence is reflected but it cat be retrieved from PMU via I2C bus
When external adapter is present the charge status is *always* anything but DISCHARGING
Charging states are sometimes erratic for USB charging.
Using I2C on ISRs seems unsafe (see holdswitch-poll.patch), so i choose not to use it on this patch, what the patch does is:
1) usb_detect() returns USB_INSERTED/USB_EXTRACTED when USB is plugged/unplugged.
2) charging:state(), return true when charge state is CHARGING, false otherwise.
3) power_input_status() must return which chargers are present:
a) if usb is inserted -> return USB as the only charger present (external adapter may be present or not, i think currently there is no serious impact when this information is omitted)
b) if no usb inserted but charge status is anything but DISCHARGING -> return external adapter as present
4) Before entering standby state, the PMU is configured to powerup the iPod when USB insertion is detected, on my iPod EXT pins are: EXTON1=button press and holdswitch lock, EXTON2=USB Vbus, EXTON3=Dock Station, so PMU could also be configured to powerup when inserting on a dock station.
With the previous info the USB stack should work correctly, i think it does for me.
The PMU supports external adaptor/usb charging capabilities, but probably they are not using all of them, i read somewhere there is a 4066 inside.
I wrote some code to get complete charger information from PMU, but remember actually it isn't irq safe:
#define IPOD_6G_PRESENT_DOCK_STATION() (pmu_read(PCF5063X_REG_OOCSTAT) & 8)
#define IPOD_6G_PRESENT_USB() (pmu_read(PCF5063X_REG_OOCSTAT) & 4)
#define IPOD_6G_PRESENT_ADAPTOR() (pmu_read(PCF5063X_REG_MBCS1) & PCF5063X_MBCS1_ADAPTPRES)
unsigned int power_input_status(void)
{
unsigned int power_input = POWER_INPUT_NONE;
if (IPOD_6G_PRESENT_USB())
power_input |= POWER_INPUT_USB_CHARGER;
if (IPOD_6G_PRESENT_ADAPTOR())
power_input |= POWER_INPUT_MAIN_CHARGER;
return power_input;
}
I think your car adapter is charging the ipod using usb, to verify it you can power-off the iPod and if it boots when you connect your car power adaptor then it is charging as USB, A quick search reveals most car adapters are using usb, you can find a few for the Classic claiming they use firewire pins, some people says they works ok, other people had bad experience and heating issues, Apple says there is no FW support on Classic.
Still i believe my dock is charging the iPod using FW pins (not sure, don't have tools to verify it now), my AC adapter is 7V/800mA, probably this voltage is regulated into dock to 5V or so. If FW pins are active then I don't know if it is dangerous to use 12V FW car adapters, it depends on how hardware is designed, at this moment i think it is safe to stay away if voltage is more than 5V, some feedback of people using FW car adaptors (if any) will be helpful.
This patch doesn't work if you use USB car adaptors, it detects if there is USB and/or AC inserted, but cannot detect if USB is charger-only (there is no USB host connected) to bypass the charging/mounting screen, i suppose it could be done at usb generic driver but didn't look at that code and don't know if it is possible and should be done, must ask USB stack developers for that.
This patch should work on dock stations and FW(?) car adaptors but not in USB card adaptors, so please verify if you are really using an USB adaptor and let me know, i could be wrong and there is some configuration resistors or other things involved instead FW pins.
What probably i missed was to power-up the iPod when plugged into the dock/cradle, it is easy to include on a next v2 patch.
All this because standard is the usb cable and many users use the line out (if not headphone out) for signal and usb cable to charge.