Reset charge state machine on charge timeout

For Spring, the charging time can be quite long and TPS65090 ends up in
timeout state and stops charging. Let's put charge state machine back to
re-init so that the device continues charging after checking charging
condition is good.

BUG=chrome-os-partner:19405
TEST=Pass charger test
BRANCH=spring

Change-Id: I838741e7283eb31ed76cf3979dbad7f070947aea
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/55720
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
This commit is contained in:
Vic Yang
2013-05-20 16:25:57 +08:00
committed by ChromeBot
parent fbf619e3b5
commit 9fb93c09d3
3 changed files with 31 additions and 0 deletions

View File

@@ -67,6 +67,10 @@
/* A temperature threshold to force charger hardware error */
#define CG_TEMP_THRESHOLD_ERROR 0
/* Timeout indication */
#define STATUS_TIMEOUT_MASK 0xc
#define STATUS_PRECHARGE_TIMEOUT 0x4
#define STATUS_FASTCHARGE_TIMEOUT 0x8
/* IRQ events */
#define EVENT_VACG (1 << 1) /* AC voltage good */
@@ -194,6 +198,18 @@ int pmu_is_charger_alarm(void)
return 0;
}
int pmu_is_charge_timeout(void)
{
int status;
if (pmu_read(CG_STATUS1, &status))
return 0;
status &= STATUS_TIMEOUT_MASK;
return (status == STATUS_PRECHARGE_TIMEOUT) ||
(status == STATUS_FASTCHARGE_TIMEOUT);
}
int pmu_get_power_source(int *ac_good, int *battery_good)
{
int rv, event = 0;

View File

@@ -291,6 +291,14 @@ static int calc_next_state(int state)
return ST_IDLE0;
}
#ifdef CONFIG_EXTPOWER_USB
/* Re-init on charger timeout. */
if (pmu_is_charge_timeout()) {
CPUTS("[pmu] charging: timeout\n");
return ST_IDLE0;
}
#endif
return ST_CHARGING;
case ST_CHARGING_ERROR:

View File

@@ -151,6 +151,13 @@ int pmu_version(int *version);
*/
int pmu_is_charger_alarm(void);
/**
* Check pmu charge timeout
*
* @return 1 if charge timed out
*/
int pmu_is_charge_timeout(void);
/**
* Get pmu power source
*