diff options
Diffstat (limited to 'driver/battery/max17055.c')
-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); |