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 09:19:28 -0700
commit5d0b5ea0b7bf271ec3ebd06fd43f79fbea43acd1 (patch)
treefb889565b22eb31ca66b201cfa67219b2f9ec1ed
parentadc6e5afed75ed83b1d49a0577f2b649aa0441f7 (diff)
downloadchrome-ec-5d0b5ea0b7bf271ec3ebd06fd43f79fbea43acd1.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: Ie670086bea2c5f14119610e72a87a3977bddc933 Original-Change-Id: I838741e7283eb31ed76cf3979dbad7f070947aea Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/55721 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 b48fbe8f2d..279d7d93db 100644
--- a/common/pmu_tps65090.c
+++ b/common/pmu_tps65090.c
@@ -66,6 +66,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 */
@@ -171,6 +175,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 a506e32604..c79b97954a 100644
--- a/common/pmu_tps65090_charger.c
+++ b/common/pmu_tps65090_charger.c
@@ -306,6 +306,14 @@ static int calc_next_state(int state)
return ST_REINIT;
}
+#ifdef BOARD_spring
+ /* Re-init on charger timeout. */
+ if (pmu_is_charge_timeout()) {
+ CPUTS("[pmu] charging: timeout\n");
+ return ST_REINIT;
+ }
+#endif
+
return ST_CHARGING;
case ST_CHARGING_ERROR:
diff --git a/include/pmu_tpschrome.h b/include/pmu_tpschrome.h
index 6afc61fec3..ab176fcf76 100644
--- a/include/pmu_tpschrome.h
+++ b/include/pmu_tpschrome.h
@@ -137,6 +137,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