summaryrefslogtreecommitdiff
path: root/common/pmu_tps65090_charger.c
diff options
context:
space:
mode:
authorRong Chang <rongchang@chromium.org>2012-06-30 17:47:30 +0800
committerGerrit <chrome-bot@google.com>2012-07-01 15:45:09 -0700
commitf4297440050a9fcedad96645ae9ee1606f61bbd0 (patch)
tree01905d1a17a32370e098601ef62f296d66d92ab1 /common/pmu_tps65090_charger.c
parent6900449d0c4b40d2a12b74bc495fe441e18069e8 (diff)
downloadchrome-ec-f4297440050a9fcedad96645ae9ee1606f61bbd0.tar.gz
Fix multiple charging issues on snow
This change fixes mutiple snow charging issues. Including: - disable i2c host auto selection - i2c_read8 got wrong output value - pmu CHARGE_EN control workaround Signed-off-by: Rong Chang <rongchang@chromium.org> BUG=chrome-os-partner:11010 TEST=Only test on snow dvt with AP turned off plug/unplug ac adapter and check charging led check console command 'battery' Change-Id: I29d554b3daa4cfc538bd5bf5ba5233976d381861 Reviewed-on: https://gerrit.chromium.org/gerrit/26529 Tested-by: Rong Chang <rongchang@chromium.org> Commit-Ready: Rong Chang <rongchang@chromium.org> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'common/pmu_tps65090_charger.c')
-rw-r--r--common/pmu_tps65090_charger.c44
1 files changed, 29 insertions, 15 deletions
diff --git a/common/pmu_tps65090_charger.c b/common/pmu_tps65090_charger.c
index db13247050..bb473b5c2a 100644
--- a/common/pmu_tps65090_charger.c
+++ b/common/pmu_tps65090_charger.c
@@ -55,6 +55,8 @@ static void enable_charging(int enable)
enable = enable ? 1 : 0;
if (gpio_get_level(GPIO_CHARGER_EN) != enable)
gpio_set_level(GPIO_CHARGER_EN, enable);
+
+ pmu_enable_charger(enable);
}
@@ -168,45 +170,57 @@ static int notify_battery_low(void)
static int calc_next_state(int state)
{
- int batt_temp, alarm, capacity;
+ int batt_temp, alarm, capacity, charge;
switch (state) {
case ST_IDLE:
- /* Turn off charger */
- enable_charging(0);
/* Check AC and chiset state */
if (!get_ac()) {
if (chipset_in_state(CHIPSET_STATE_ON))
return ST_DISCHARGING;
- return ST_IDLE;
+
+ /* Enable charging and wait ac on */
+ enable_charging(1);
+ return wait_t1_idle();
}
/* Enable charging when battery doesn't respond */
- if (battery_temperature(&batt_temp))
+ if (battery_temperature(&batt_temp)) {
+ enable_charging(1);
+ wait_t1_idle();
return ST_PRE_CHARGING;
+ }
- if (!battery_start_charging_range(batt_temp))
+ /* Turn off charger when battery temperature is out
+ * of the start charging range.
+ */
+ if (!battery_start_charging_range(batt_temp)) {
+ enable_charging(0);
return wait_t1_idle();
+ }
+ /* Turn off charger on battery charging alarm */
if (battery_status(&alarm) || (alarm & ALARM_CHARGING)) {
if (!(alarm & ALARM_TERMINATE_CHARGE))
CPRINTF("[pmu] idle %016b\n", alarm);
+ enable_charging(0);
return wait_t1_idle();
}
- enable_charging(1);
- return ST_CHARGING;
+ /* Start charging only when battery charge lower than 100% */
+ if (!battery_state_of_charge(&charge) && charge < 100) {
+ enable_charging(1);
+ wait_t1_idle();
+ return ST_CHARGING;
+ }
+
+ return wait_t1_idle();
case ST_PRE_CHARGING:
if (!get_ac())
return wait_t1_idle();
- if (!gpio_get_level(GPIO_CHARGER_EN)) {
- CPUTS("[pmu] try charging\n");
- enable_charging(1);
- }
-
/* If the battery goes online after enable the charger,
* go into charging state.
*/
@@ -237,7 +251,7 @@ static int calc_next_state(int state)
case ST_DISCHARGING:
if (get_ac())
- return ST_IDLE;
+ return wait_t1_idle();
/* Check battery discharging temperature range */
if (battery_temperature(&batt_temp) == 0) {
@@ -259,7 +273,7 @@ static int calc_next_state(int state)
return wait_t3_discharging();
}
- return ST_IDLE;
+ return wait_t1_idle();
}
void pmu_charger_task(void)