diff options
author | Michael Sparmann <theseven@gmx.net> | 2014-07-19 18:32:55 +0200 |
---|---|---|
committer | Cástor Muñoz <cmvidal@gmail.com> | 2016-02-14 15:42:54 +0100 |
commit | bc56811a0e1df3e7902b85cf2250d970e0a929d5 (patch) | |
tree | 068be6ee573842517af522c78323739fc28cfd4f | |
parent | 929be521d4dd8a0ed3b3a42cd22e1659407ce83a (diff) | |
download | rockbox-bc56811a0e1df3e7902b85cf2250d970e0a929d5.tar.gz rockbox-bc56811a0e1df3e7902b85cf2250d970e0a929d5.zip |
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>
-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) | |||
61 | 61 | ||
62 | unsigned int power_input_status(void) | 62 | unsigned int power_input_status(void) |
63 | { | 63 | { |
64 | return (PDAT14 & 8) ? POWER_INPUT_NONE : POWER_INPUT_MAIN_CHARGER; | 64 | /* This checks if USB Vbus is present. */ |
65 | if (!(PDAT14 & 0x8)) return POWER_INPUT_USB_CHARGER; | ||
66 | |||
67 | /* If USB Vbus is not present, check if we have a positive power balance | ||
68 | regardless. This would indicate FireWire charging. Note that this will | ||
69 | drop to POWER_INPUT_NONE if FireWire isn't able to supply enough current | ||
70 | for device operation, e.g. during disk spinup. */ | ||
71 | if (PDAT11 & 0x20) return POWER_INPUT_NONE; | ||
72 | |||
73 | /* Looks like we have FireWire power. */ | ||
74 | return POWER_INPUT_MAIN_CHARGER; | ||
65 | } | 75 | } |
66 | 76 | ||
67 | bool charging_state(void) | 77 | bool charging_state(void) |
68 | { | 78 | { |
69 | return (PDAT11 & 0x10) ? false : true; | 79 | return (PDAT11 & 0x10) ? 0 : 1; |
70 | } | 80 | } |
71 | #endif /* CONFIG_CHARGING */ | 81 | #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) | |||
37 | 37 | ||
38 | int usb_detect(void) | 38 | int usb_detect(void) |
39 | { | 39 | { |
40 | if (charger_inserted()) | 40 | if (power_input_status() & POWER_INPUT_USB) |
41 | return USB_INSERTED; | 41 | return USB_INSERTED; |
42 | return USB_EXTRACTED; | 42 | return USB_EXTRACTED; |
43 | } | 43 | } |
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) | |||
117 | 117 | ||
118 | unsigned int power_input_status(void) | 118 | unsigned int power_input_status(void) |
119 | { | 119 | { |
120 | return (PDAT(12) & 8) ? POWER_INPUT_NONE : POWER_INPUT_MAIN_CHARGER; | 120 | /* This checks if USB Vbus is present. */ |
121 | if (!(PDAT(12) & 0x8)) return POWER_INPUT_USB_CHARGER; | ||
122 | |||
123 | /* If USB Vbus is not present, check if we have a positive power balance | ||
124 | regardless. This would indicate FireWire charging. Note that this will | ||
125 | drop to POWER_INPUT_NONE if FireWire isn't able to supply enough current | ||
126 | for device operation, e.g. during disk spinup. */ | ||
127 | if (PDAT(11) & 0x20) return POWER_INPUT_NONE; | ||
128 | |||
129 | /* Looks like we have FireWire power. */ | ||
130 | return POWER_INPUT_MAIN_CHARGER; | ||
121 | } | 131 | } |
122 | 132 | ||
123 | bool charging_state(void) | 133 | bool charging_state(void) |
124 | { | 134 | { |
125 | return false; //TODO: Figure out | 135 | return (PDAT(11) & 0x10) ? 0 : 1; |
126 | } | 136 | } |
127 | #endif /* CONFIG_CHARGING */ | 137 | #endif /* CONFIG_CHARGING */ |