mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-09 05:05:20 -05:00
iPod Nano 2G and Classic: Fix power and charging detection.
This should allow FireWire charging to work on these devices. It also adds charging state detection on the iPod Classic. (cherry picked from commit fa86fec4fb089b47f5c2c3b1f2f3dbc97551895b) On Classic (and probably Nano 2G), it seems that the 100/500mA limit applies only to USB chargers, when FW is connected it supplies all the power (even if USB is also connected) and USB current limit does not affect to FW charging, therefore the limit is only set when USB is connected. Change-Id: I7c6bab1b6a0f295367999c45faeda6085c3fb091 Signed-off-by: Cástor Muñoz <cmvidal@gmail.com>
This commit is contained in:
parent
929be521d4
commit
bc56811a0e
3 changed files with 25 additions and 5 deletions
|
|
@ -61,11 +61,21 @@ void usb_charging_maxcurrent_change(int maxcurrent)
|
||||||
|
|
||||||
unsigned int power_input_status(void)
|
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. */
|
||||||
|
return POWER_INPUT_MAIN_CHARGER;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool charging_state(void)
|
bool charging_state(void)
|
||||||
{
|
{
|
||||||
return (PDAT11 & 0x10) ? false : true;
|
return (PDAT11 & 0x10) ? 0 : 1;
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_CHARGING */
|
#endif /* CONFIG_CHARGING */
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ void usb_enable(bool on)
|
||||||
|
|
||||||
int usb_detect(void)
|
int usb_detect(void)
|
||||||
{
|
{
|
||||||
if (charger_inserted())
|
if (power_input_status() & POWER_INPUT_USB)
|
||||||
return USB_INSERTED;
|
return USB_INSERTED;
|
||||||
return USB_EXTRACTED;
|
return USB_EXTRACTED;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -117,11 +117,21 @@ void usb_charging_maxcurrent_change(int maxcurrent)
|
||||||
|
|
||||||
unsigned int power_input_status(void)
|
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. */
|
||||||
|
return POWER_INPUT_MAIN_CHARGER;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool charging_state(void)
|
bool charging_state(void)
|
||||||
{
|
{
|
||||||
return false; //TODO: Figure out
|
return (PDAT(11) & 0x10) ? 0 : 1;
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_CHARGING */
|
#endif /* CONFIG_CHARGING */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue