summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2016-05-02 21:14:11 +0100
committerAmaury Pouly <amaury.pouly@gmail.com>2016-05-28 17:07:11 +0200
commitf182e2df66c9567a1b2dff3028ec6f5cc45b0f89 (patch)
tree761307c8ba884fbb19a406d25e1292adabc61826
parenteac1ca22bd4a6c1849880d0f8b6764befb60bc21 (diff)
downloadrockbox-f182e2df66c9567a1b2dff3028ec6f5cc45b0f89.tar.gz
rockbox-f182e2df66c9567a1b2dff3028ec6f5cc45b0f89.zip
imx233: make sure not to discharge battery when charge is complete
The power management code was erroneously shuting down the 4.2V rail when charging is complete. This resulted in the DCDC draining the battery and thus the battery discharging with USB plugged... The new code keeps the 4.2V rail active so that battery remains untouched once charge is complete. Change-Id: I36e8d31e8115c12ce813c939c5d7bbf2c3490157
-rw-r--r--firmware/target/arm/imx233/powermgmt-imx233.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/firmware/target/arm/imx233/powermgmt-imx233.c b/firmware/target/arm/imx233/powermgmt-imx233.c
index 5db03d4127..50ab8451bb 100644
--- a/firmware/target/arm/imx233/powermgmt-imx233.c
+++ b/firmware/target/arm/imx233/powermgmt-imx233.c
@@ -108,6 +108,7 @@ void charging_algorithm_step(void)
108 * limit on the 4P2 rail. */ 108 * limit on the 4P2 rail. */
109 BF_WR(POWER_DCDC4P2, ENABLE_4P2(1)); 109 BF_WR(POWER_DCDC4P2, ENABLE_4P2(1));
110 BF_SET(POWER_CHARGE, ENABLE_LOAD); 110 BF_SET(POWER_CHARGE, ENABLE_LOAD);
111 BF_WR(POWER_5VCTRL, CHARGE_4P2_ILIMIT(1)); /* start by drawing 10mA only */
111 BF_CLR(POWER_5VCTRL, PWD_CHARGE_4P2);// FIXME: manual error ? 112 BF_CLR(POWER_5VCTRL, PWD_CHARGE_4P2);// FIXME: manual error ?
112 BF_WR(POWER_DCDC4P2, ENABLE_DCDC(1)); 113 BF_WR(POWER_DCDC4P2, ENABLE_DCDC(1));
113#endif 114#endif
@@ -145,19 +146,19 @@ void charging_algorithm_step(void)
145 timeout_charging = current_tick + IMX233_CHARGING_TIMEOUT; 146 timeout_charging = current_tick + IMX233_CHARGING_TIMEOUT;
146 } 147 }
147 } 148 }
149 /* charging -> error transition */
148 else if(charge_state == CHARGING && TIME_AFTER(current_tick, timeout_charging)) 150 else if(charge_state == CHARGING && TIME_AFTER(current_tick, timeout_charging))
149 { 151 {
150 /* we have charged for a too long time, declare charger broken */ 152 /* we have charged for a too long time, declare charger broken */
151 logf("pwrmgmt: charging timeout exceeded!"); 153 logf("pwrmgmt: charging timeout exceeded!");
152 logf("pwrmgmt: charging -> error"); 154 logf("pwrmgmt: charging -> error");
153 /* stop charging */ 155 /* stop charging, note that we leave the 4.2 rail active so that the DCDC
154#if IMX233_SUBTARGET >= 3780 156 * keep drawing current from the 4.2 only and leave the battery untouched */
155 BF_SET(POWER_5VCTRL, PWD_CHARGE_4P2);
156#endif
157 BF_SET(POWER_CHARGE, PWD_BATTCHRG); 157 BF_SET(POWER_CHARGE, PWD_BATTCHRG);
158 /* goto error state */ 158 /* goto error state */
159 charge_state = CHARGE_STATE_ERROR; 159 charge_state = CHARGE_STATE_ERROR;
160 } 160 }
161 /* charging -> topoff transition */
161 else if(charge_state == CHARGING && !BF_RD(POWER_STS, CHRGSTS)) 162 else if(charge_state == CHARGING && !BF_RD(POWER_STS, CHRGSTS))
162 { 163 {
163 logf("pwrmgmt: topping off"); 164 logf("pwrmgmt: topping off");
@@ -165,14 +166,13 @@ void charging_algorithm_step(void)
165 charge_state = TOPOFF; 166 charge_state = TOPOFF;
166 timeout_topping_off = current_tick + IMX233_TOPOFF_TIMEOUT; 167 timeout_topping_off = current_tick + IMX233_TOPOFF_TIMEOUT;
167 } 168 }
169 /* topoff -> disabled transition */
168 else if(charge_state == TOPOFF && TIME_AFTER(current_tick, timeout_topping_off)) 170 else if(charge_state == TOPOFF && TIME_AFTER(current_tick, timeout_topping_off))
169 { 171 {
170 logf("pwrmgmt: charging finished"); 172 logf("pwrmgmt: charging finished");
171 logf("pwrmgmt: topoff -> disabled"); 173 logf("pwrmgmt: topoff -> disabled");
172 /* stop charging */ 174 /* stop charging, note that we leave the 4.2 rail active so that the DCDC
173#if IMX233_SUBTARGET >= 3780 175 * keep drawing current from the 4.2 only and leave the battery untouched */
174 BF_SET(POWER_5VCTRL, PWD_CHARGE_4P2);
175#endif
176 BF_SET(POWER_CHARGE, PWD_BATTCHRG); 176 BF_SET(POWER_CHARGE, PWD_BATTCHRG);
177 charge_state = CHARGE_STATE_DISABLED; 177 charge_state = CHARGE_STATE_DISABLED;
178 } 178 }