diff options
author | Rong Chang <rongchang@chromium.org> | 2012-08-27 18:29:27 +0800 |
---|---|---|
committer | Gerrit <chrome-bot@google.com> | 2012-08-28 03:44:43 -0700 |
commit | 38454d7a161b28319bfa111e5ca8a89009699ae1 (patch) | |
tree | 7f87556cd7da5894cb9c23c20a99e9016f3d4e44 /common/pmu_tps65090.c | |
parent | a0f7b3dac8c1e72635f6266962a297bbc7c45bdd (diff) | |
download | chrome-ec-38454d7a161b28319bfa111e5ca8a89009699ae1.tar.gz |
snow: Change TPSCHROME fastcharge timeout to 6 hours
When battery temperature t in range 0C to 10C, default charging current
is 50%. And it will take longer than 3 hours to charge battery from 0%
to full.
Signed-off-by: Rong Chang <rongchang@chromium.org>
BRANCH=snow
BUG=chrome-os-partner:13172
TEST=manual
Check pmu register 0x4. FASTCHARGE bits[4:2] should be 0b100.
Change-Id: I133acee21c0886b0739b4b41766ca077bb4babbc
Reviewed-on: https://gerrit.chromium.org/gerrit/31458
Reviewed-by: Yung-Chieh Lo <yjlou@chromium.org>
Commit-Ready: Rong Chang <rongchang@chromium.org>
Tested-by: Rong Chang <rongchang@chromium.org>
Diffstat (limited to 'common/pmu_tps65090.c')
-rw-r--r-- | common/pmu_tps65090.c | 63 |
1 files changed, 58 insertions, 5 deletions
diff --git a/common/pmu_tps65090.c b/common/pmu_tps65090.c index d6c8b1f994..0fdbef1d89 100644 --- a/common/pmu_tps65090.c +++ b/common/pmu_tps65090.c @@ -49,7 +49,10 @@ #define TPSCHROME_VER 0x19 /* Charger control */ -#define CG_CTRL0_EN 1 +#define CG_EN (1 << 0) +#define CG_EXT_EN (1 << 1) +#define CG_FASTCHARGE_SHIFT 2 +#define CG_FASTCHARGE_MASK (7 << CG_FASTCHARGE_SHIFT) /* Charger termination voltage/current */ #define CG_VSET_SHIFT 3 @@ -164,6 +167,13 @@ int pmu_get_power_source(int *ac_good, int *battery_good) return EC_SUCCESS; } +/** + * Enable charger's charging function + * + * When enable, charger ignores external control and charge the + * battery directly. If EC wants to contorl charging, set the flag + * to 0. + */ int pmu_enable_charger(int enable) { int rv; @@ -173,11 +183,54 @@ int pmu_enable_charger(int enable) if (rv) return rv; - if (reg & CG_CTRL0_EN) - return EC_SUCCESS; + if (enable) + reg |= CG_EN; + else + reg &= ~CG_EN; + + return pmu_write(CG_CTRL0, reg); +} + +/** + * Set external charge enable pin + * + * @param enable boolean, set 1 to eanble external control + */ +int pmu_enable_ext_control(int enable) +{ + int rv; + int reg; + + rv = pmu_read(CG_CTRL0, ®); + if (rv) + return rv; + + if (enable) + reg |= CG_EXT_EN; + else + reg &= ~CG_EXT_EN; + + return pmu_write(CG_CTRL0, reg); +} + +/** + * Set fast charge timeout + * + * @param timeout enum FASTCHARGE_TIMEOUT + */ +int pmu_set_fastcharge(enum FASTCHARGE_TIMEOUT timeout) +{ + int rv; + int reg; + + rv = pmu_read(CG_CTRL0, ®); + if (rv) + return rv; + + reg &= ~CG_FASTCHARGE_MASK; + reg |= (timeout << CG_FASTCHARGE_SHIFT) & CG_FASTCHARGE_MASK; - return pmu_write(CG_CTRL0, enable ? (reg | CG_CTRL0_EN) : - (reg & ~CG_CTRL0)); + return pmu_write(CG_CTRL0, reg); } /** |