diff options
author | Philip Chen <philipchen@google.com> | 2018-02-22 16:56:51 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-02-26 14:10:12 -0800 |
commit | c3deceae6aefd783aa1f1686c446ff6d2f228a95 (patch) | |
tree | fe40b8d61089a9324a2c8ff33c58ec519daccd7a /driver/battery | |
parent | 36679bb544f84307e9d93a36bf729c1b25ce3db2 (diff) | |
download | chrome-ec-c3deceae6aefd783aa1f1686c446ff6d2f228a95.tar.gz |
battery/max17055: Report battery presence properly
For boards using max17055 and dumb battery, we can always
read battery parameters from max17055 regs, even if the
read values are out of whack.
So it doesn't make sense to determine battery is present
because we can read these parameters from max17055.
Meanwhile, we have to set CONFIG.TSEL on max17055 as early
as possible because this is required for max17055 to detect
battery presense.
BUG=b:72697658
BRANCH=scarlet
TEST=boot scarlet rev3 w/o battery on Type-C/PD chargers
Change-Id: Id190f0c2aa5bcd62dbe3edccca6460bf145cff01
Signed-off-by: Philip Chen <philipchen@google.com>
Reviewed-on: https://chromium-review.googlesource.com/933702
Commit-Ready: Philip Chen <philipchen@chromium.org>
Tested-by: Philip Chen <philipchen@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'driver/battery')
-rw-r--r-- | driver/battery/max17055.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/driver/battery/max17055.c b/driver/battery/max17055.c index 1a38c2748f..4836cf242d 100644 --- a/driver/battery/max17055.c +++ b/driver/battery/max17055.c @@ -206,10 +206,6 @@ enum battery_present battery_is_present(void) void battery_get_params(struct batt_params *batt) { int reg = 0; - const uint32_t flags_to_check = BATT_FLAG_BAD_TEMPERATURE | - BATT_FLAG_BAD_STATE_OF_CHARGE | - BATT_FLAG_BAD_VOLTAGE | - BATT_FLAG_BAD_CURRENT; /* Reset flags */ batt->flags = 0; @@ -245,12 +241,14 @@ void battery_get_params(struct batt_params *batt) if (battery_full_charge_capacity(&batt->full_capacity)) batt->flags |= BATT_FLAG_BAD_FULL_CAPACITY; - /* If any of those reads worked, the battery is responsive */ - if ((batt->flags & flags_to_check) != flags_to_check) { + /* + * Assuming the battery is responsive as long as + * max17055 finds battery is present. + */ + batt->is_present = battery_is_present(); + + if (batt->is_present == BP_YES) batt->flags |= BATT_FLAG_RESPONSIVE; - batt->is_present = BP_YES; - } else - batt->is_present = BP_NOT_SURE; /* * Charging allowed if both desired voltage and current are nonzero @@ -369,6 +367,14 @@ static void max17055_init(void) return; } + /* + * Set CONFIG.TSEL to measure temperature using external thermistor. + * Set it as early as possible because max17055 takes up to 1000ms to + * have the first reliable external temperature reading. + */ + MAX17055_READ_DEBUG(REG_CONFIG, ®); + MAX17055_WRITE_DEBUG(REG_CONFIG, (reg | CONF_TSEL)); + MAX17055_READ_DEBUG(REG_STATUS, ®); /* Check for POR */ @@ -396,10 +402,6 @@ static void max17055_init(void) MAX17055_READ_DEBUG(REG_STATUS, ®); MAX17055_WRITE_DEBUG(REG_STATUS, (reg & ~STATUS_POR)); - /* Set CONFIG.TSEL to measure temperature using external thermistor */ - MAX17055_READ_DEBUG(REG_CONFIG, ®); - MAX17055_WRITE_DEBUG(REG_CONFIG, (reg | CONF_TSEL)); - CPRINTS("max17055 configuration succeeded!"); } DECLARE_HOOK(HOOK_INIT, max17055_init, HOOK_PRIO_DEFAULT); |