summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVic Yang <victoryang@chromium.org>2013-05-20 16:25:57 +0800
committerChromeBot <chrome-bot@google.com>2013-05-20 10:54:00 -0700
commit9fb93c09d30d83a4aae778887faaed72da5675b0 (patch)
tree18d8028bfaa9287059e2b5fffe73fd4533dde78a
parentfbf619e3b56c92f3ae1eac44cf1aa7576068aafa (diff)
downloadchrome-ec-9fb93c09d30d83a4aae778887faaed72da5675b0.tar.gz
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>
-rw-r--r--common/pmu_tps65090.c16
-rw-r--r--common/pmu_tps65090_charger.c8
-rw-r--r--include/pmu_tpschrome.h7
3 files changed, 31 insertions, 0 deletions
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
@@ -152,6 +152,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
*
* @param ac_good pointer to output value of ac voltage good