diff options
author | Amaury Pouly <amaury.pouly@gmail.com> | 2016-05-02 21:14:11 +0100 |
---|---|---|
committer | Amaury Pouly <amaury.pouly@gmail.com> | 2016-05-28 17:07:11 +0200 |
commit | f182e2df66c9567a1b2dff3028ec6f5cc45b0f89 (patch) | |
tree | 761307c8ba884fbb19a406d25e1292adabc61826 | |
parent | eac1ca22bd4a6c1849880d0f8b6764befb60bc21 (diff) | |
download | rockbox-f182e2d.tar.gz rockbox-f182e2d.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.c | 16 |
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) * limit on the 4P2 rail. */ BF_WR(POWER_DCDC4P2, ENABLE_4P2(1)); BF_SET(POWER_CHARGE, ENABLE_LOAD); + BF_WR(POWER_5VCTRL, CHARGE_4P2_ILIMIT(1)); /* start by drawing 10mA only */ BF_CLR(POWER_5VCTRL, PWD_CHARGE_4P2);// FIXME: manual error ? BF_WR(POWER_DCDC4P2, ENABLE_DCDC(1)); #endif @@ -145,19 +146,19 @@ void charging_algorithm_step(void) timeout_charging = current_tick + IMX233_CHARGING_TIMEOUT; } } + /* charging -> error transition */ else if(charge_state == CHARGING && TIME_AFTER(current_tick, timeout_charging)) { /* we have charged for a too long time, declare charger broken */ logf("pwrmgmt: charging timeout exceeded!"); logf("pwrmgmt: charging -> error"); - /* stop charging */ -#if IMX233_SUBTARGET >= 3780 - BF_SET(POWER_5VCTRL, PWD_CHARGE_4P2); -#endif + /* stop charging, note that we leave the 4.2 rail active so that the DCDC + * keep drawing current from the 4.2 only and leave the battery untouched */ BF_SET(POWER_CHARGE, PWD_BATTCHRG); /* goto error state */ charge_state = CHARGE_STATE_ERROR; } + /* charging -> topoff transition */ else if(charge_state == CHARGING && !BF_RD(POWER_STS, CHRGSTS)) { logf("pwrmgmt: topping off"); @@ -165,14 +166,13 @@ void charging_algorithm_step(void) charge_state = TOPOFF; timeout_topping_off = current_tick + IMX233_TOPOFF_TIMEOUT; } + /* topoff -> disabled transition */ else if(charge_state == TOPOFF && TIME_AFTER(current_tick, timeout_topping_off)) { logf("pwrmgmt: charging finished"); logf("pwrmgmt: topoff -> disabled"); - /* stop charging */ -#if IMX233_SUBTARGET >= 3780 - BF_SET(POWER_5VCTRL, PWD_CHARGE_4P2); -#endif + /* stop charging, note that we leave the 4.2 rail active so that the DCDC + * keep drawing current from the 4.2 only and leave the battery untouched */ BF_SET(POWER_CHARGE, PWD_BATTCHRG); charge_state = CHARGE_STATE_DISABLED; } |