iPod Nano 2G and Classic: Fix power and charging detection.

This should allow FireWire charging to work on these devices (untested).
It also adds charging state detection on the iPod Classic.
This commit is contained in:
Michael Sparmann 2014-07-19 18:32:55 +02:00
parent 78478076a3
commit fa86fec4fb
3 changed files with 31 additions and 5 deletions

17
firmware/target/arm/s5l8700/ipodnano2g/power-nano2g.c Normal file → Executable file
View file

@ -61,11 +61,24 @@ void usb_charging_maxcurrent_change(int maxcurrent)
unsigned int power_input_status(void)
{
return (PDAT14 & 8) ? POWER_INPUT_NONE : POWER_INPUT_MAIN_CHARGER;
/* This checks if USB Vbus is present. */
if (!(PDAT14 & 0x8)) return POWER_INPUT_USB_CHARGER;
/* If USB Vbus is not present, check if we have a positive power balance
regardless. This would indicate FireWire charging. Note that this will
drop to POWER_INPUT_NONE if FireWire isn't able to supply enough current
for device operation, e.g. during disk spinup. */
if (PDAT11 & 0x20) return POWER_INPUT_NONE;
/* Looks like we have FireWire power. Allow drawing 500mA. */
#ifdef HAVE_USB_CHARGING_ENABLE
usb_charging_maxcurrent_change(500);
#endif
return POWER_INPUT_MAIN_CHARGER;
}
bool charging_state(void)
{
return (PDAT11 & 0x10) ? false : true;
return (PDAT11 & 0x10) ? 0 : 1;
}
#endif /* CONFIG_CHARGING */

2
firmware/target/arm/s5l8700/usb-nano2g-6g.c Normal file → Executable file
View file

@ -37,7 +37,7 @@ void usb_enable(bool on)
int usb_detect(void)
{
if (charger_inserted())
if (power_input_status() & POWER_INPUT_USB)
return USB_INSERTED;
return USB_EXTRACTED;
}

17
firmware/target/arm/s5l8702/ipod6g/power-ipod6g.c Normal file → Executable file
View file

@ -77,11 +77,24 @@ void usb_charging_maxcurrent_change(int maxcurrent)
unsigned int power_input_status(void)
{
return (PDAT(12) & 8) ? POWER_INPUT_NONE : POWER_INPUT_MAIN_CHARGER;
/* This checks if USB Vbus is present. */
if (!(PDAT(12) & 0x8)) return POWER_INPUT_USB_CHARGER;
/* If USB Vbus is not present, check if we have a positive power balance
regardless. This would indicate FireWire charging. Note that this will
drop to POWER_INPUT_NONE if FireWire isn't able to supply enough current
for device operation, e.g. during disk spinup. */
if (PDAT(11) & 0x20) return POWER_INPUT_NONE;
/* Looks like we have FireWire power. Allow drawing 500mA. */
#ifdef HAVE_USB_CHARGING_ENABLE
usb_charging_maxcurrent_change(500);
#endif
return POWER_INPUT_MAIN_CHARGER;
}
bool charging_state(void)
{
return false; //TODO: Figure out
return (PDAT(11) & 0x10) ? 0 : 1;
}
#endif /* CONFIG_CHARGING */