diff --git a/common/pmu_tps65090.c b/common/pmu_tps65090.c index c7a34426a0..bf63998f33 100644 --- a/common/pmu_tps65090.c +++ b/common/pmu_tps65090.c @@ -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; diff --git a/common/pmu_tps65090_charger.c b/common/pmu_tps65090_charger.c index 6ee16dc493..36fb0d1989 100644 --- a/common/pmu_tps65090_charger.c +++ b/common/pmu_tps65090_charger.c @@ -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: diff --git a/include/pmu_tpschrome.h b/include/pmu_tpschrome.h index 58e2288ee6..27ea0ce074 100644 --- a/include/pmu_tpschrome.h +++ b/include/pmu_tpschrome.h @@ -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 *