diff options
author | Jenny Ho <hsiufangho@google.com> | 2023-11-29 17:59:58 +0800 |
---|---|---|
committer | Jenny Ho <hsiufangho@google.com> | 2023-11-30 01:18:32 +0000 |
commit | ba5886160fe4dc8660cfd1f3bc148139539eda7b (patch) | |
tree | 7f77183ba8824a4256676df33fdd60a5680bddc7 | |
parent | ccf717d6e84c62ecadca2f97b6c87a0f674a8dd4 (diff) | |
download | bms-ba5886160fe4dc8660cfd1f3bc148139539eda7b.tar.gz |
max1720x_battery: fix model loading retry process
model load work runs when model_reload >= MAX_M5_LOAD_MODEL_REQUEST,
accumulating model_reload is a reasonable approach. The POR bit is
only cleared when the model is loaded successfully
Bug: 313831863
Change-Id: I0125cd4b4710fa6c5ce832529b5c404445def545
Signed-off-by: Jenny Ho <hsiufangho@google.com>
-rw-r--r-- | max1720x_battery.c | 14 | ||||
-rw-r--r-- | max_m5.h | 2 |
2 files changed, 8 insertions, 8 deletions
diff --git a/max1720x_battery.c b/max1720x_battery.c index 2c7498f..896c157 100644 --- a/max1720x_battery.c +++ b/max1720x_battery.c @@ -2987,12 +2987,12 @@ static irqreturn_t max1720x_fg_irq_thread_fn(int irq, void *obj) } else { dev_warn(chip->dev, "POR is set(%04x), model reload:%d\n", fg_status, chip->model_reload); - /* trigger model load if not on-going */ - if (chip->model_reload != MAX_M5_LOAD_MODEL_REQUEST) { - err = max1720x_model_reload(chip, false); - if (err < 0) - fg_status_clr &= ~MAX1720X_STATUS_POR; - } + /* + * trigger model load if not on-going, clear POR only when + * model loading done successfully + */ + if (chip->model_reload != MAX_M5_LOAD_MODEL_REQUEST) + max1720x_model_reload(chip, false); } mutex_unlock(&chip->model_lock); } @@ -4530,7 +4530,7 @@ static void max1720x_model_work(struct work_struct *work) chip->model_reload = MAX_M5_LOAD_MODEL_DISABLED; chip->model_ok = false; } else if (chip->model_reload > MAX_M5_LOAD_MODEL_IDLE) { - chip->model_reload -= 1; + chip->model_reload += 1; } } @@ -25,7 +25,7 @@ /* change to 1 or 0 to load FG model with default parameters on startup */ #define MAX_M5_LOAD_MODEL_DISABLED -1 #define MAX_M5_LOAD_MODEL_IDLE 0 -#define MAX_M5_LOAD_MODEL_REQUEST 5 +#define MAX_M5_LOAD_MODEL_REQUEST 1 #define MAX_M5_FG_MODEL_START 0x80 #define MAX_M5_FG_MODEL_SIZE 48 |