diff options
-rw-r--r-- | firmware/target/arm/s5l8700/ipodnano2g/power-nano2g.c | 14 | ||||
-rw-r--r-- | firmware/target/arm/s5l8700/usb-nano2g-6g.c | 2 | ||||
-rw-r--r-- | firmware/target/arm/s5l8702/ipod6g/power-ipod6g.c | 14 |
3 files changed, 25 insertions, 5 deletions
diff --git a/firmware/target/arm/s5l8700/ipodnano2g/power-nano2g.c b/firmware/target/arm/s5l8700/ipodnano2g/power-nano2g.c index 10d96fd59c..989fb1550b 100644 --- a/firmware/target/arm/s5l8700/ipodnano2g/power-nano2g.c +++ b/firmware/target/arm/s5l8700/ipodnano2g/power-nano2g.c @@ -61,11 +61,21 @@ 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. */ + return POWER_INPUT_MAIN_CHARGER; } bool charging_state(void) { - return (PDAT11 & 0x10) ? false : true; + return (PDAT11 & 0x10) ? 0 : 1; } #endif /* CONFIG_CHARGING */ diff --git a/firmware/target/arm/s5l8700/usb-nano2g-6g.c b/firmware/target/arm/s5l8700/usb-nano2g-6g.c index 1807a39c76..db397f8fd5 100644 --- a/firmware/target/arm/s5l8700/usb-nano2g-6g.c +++ b/firmware/target/arm/s5l8700/usb-nano2g-6g.c @@ -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; } diff --git a/firmware/target/arm/s5l8702/ipod6g/power-ipod6g.c b/firmware/target/arm/s5l8702/ipod6g/power-ipod6g.c index 64e9457430..57358b8cb6 100644 --- a/firmware/target/arm/s5l8702/ipod6g/power-ipod6g.c +++ b/firmware/target/arm/s5l8702/ipod6g/power-ipod6g.c @@ -117,11 +117,21 @@ 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. */ + return POWER_INPUT_MAIN_CHARGER; } bool charging_state(void) { - return false; //TODO: Figure out + return (PDAT(11) & 0x10) ? 0 : 1; } #endif /* CONFIG_CHARGING */ |