diff options
author | Jenny Ho <hsiufangho@google.com> | 2023-11-24 15:13:32 +0800 |
---|---|---|
committer | Jenny Ho <hsiufangho@google.com> | 2023-11-28 07:57:00 +0000 |
commit | ccf717d6e84c62ecadca2f97b6c87a0f674a8dd4 (patch) | |
tree | 06cc910a252e90e1f184bc2955014448783d7902 | |
parent | 9825bee4e2c660c92c4e469369fb266abba8ff42 (diff) | |
download | bms-ccf717d6e84c62ecadca2f97b6c87a0f674a8dd4.tar.gz |
max1720x_battery: update cycle_count after model loading
the cycle count reset to 0 when fg reset, need to read back after fg
reset and model loading done
Bug: 312098789
Change-Id: I5ce133a8c8df1b340961090aa94e031de0e0f507
Signed-off-by: Jenny Ho <hsiufangho@google.com>
-rw-r--r-- | max1720x_battery.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/max1720x_battery.c b/max1720x_battery.c index 76cf380..2c7498f 100644 --- a/max1720x_battery.c +++ b/max1720x_battery.c @@ -284,6 +284,7 @@ static irqreturn_t max1720x_fg_irq_thread_fn(int irq, void *obj); static int max1720x_set_next_update(struct max1720x_chip *chip); static int max1720x_monitor_log_data(struct max1720x_chip *chip, bool force_log); static int max17201_init_rc_switch(struct max1720x_chip *chip); +static int max1720x_update_cycle_count(struct max1720x_chip *chip); static bool max17x0x_reglog_init(struct max1720x_chip *chip) { @@ -1538,6 +1539,8 @@ static void max1720x_restore_battery_cycle(struct max1720x_chip *chip) ret = REGMAP_WRITE_VERIFY(&chip->regmap, MAX1720X_CYCLES, eeprom_cycle); if (ret < 0) dev_warn(chip->dev, "fail to update cycles (%d)", ret); + else + max1720x_update_cycle_count(chip); } } @@ -5125,6 +5128,7 @@ static int max1720x_init_chip(struct max1720x_chip *chip) /* max_m5 triggers loading of the model in the irq handler on POR */ if (!chip->por && chip->gauge_type == MAX_M5_GAUGE_TYPE) { + max1720x_update_cycle_count(chip); ret = max1720x_init_max_m5(chip); if (ret < 0) return ret; @@ -5852,8 +5856,6 @@ static void max1720x_init_work(struct work_struct *work) if (!chip->por) max1720x_monitor_log_data(chip, true); - max1720x_update_cycle_count(chip); - max1720x_update_timer_base(chip); dev_info(chip->dev, "init_work done\n"); |