charger: bq25180: Add threshold voltage for precharge

Charging a battery has three phases (compare Figure 8-2 in
https://www.ti.com/lit/ds/symlink/bq25180.pdf)

First is a pre-charge phase, then a constant current, then a constant
voltage phase.
During the pre-charge phase, the battery is only charged with a very low
current, to not damage the cells, because they are below a threshold,
that is considered healthy for the battery and need to be brought back
up to a healthy voltage.

Signed-off-by: Fabian Pflug <fabian.pflug@grandcentrix.net>
This commit is contained in:
Fabian Pflug 2024-08-14 17:10:25 +02:00 committed by Anas Nashif
parent 6b2442244d
commit cdfab15b99
2 changed files with 25 additions and 0 deletions

View File

@ -38,6 +38,9 @@ LOG_MODULE_REGISTER(bq25180, CONFIG_CHARGER_LOG_LEVEL);
#define BQ25180_IC_CTRL_VRCH_100 0x00
#define BQ25180_IC_CTRL_VRCH_200 BIT(5)
#define BQ25180_IC_CTRL_VRCH_MSK BIT(5)
#define BQ25180_VLOWV_SEL_2_8 BIT(6)
#define BQ25180_VLOWV_SEL_3_0 0x00
#define BQ25180_VLOWV_SEL_MSK BIT(6)
#define BQ25180_WATCHDOG_SEL_1_MSK GENMASK(1, 0)
#define BQ25180_WATCHDOG_DISABLE 0x03
#define BQ25180_DEVICE_ID_MSK GENMASK(3, 0)
@ -59,6 +62,7 @@ struct bq25180_config {
uint32_t initial_current_microamp;
uint32_t max_voltage_microvolt;
uint32_t recharge_voltage_microvolt;
uint32_t precharge_threshold_voltage_microvolt;
};
/*
@ -353,6 +357,18 @@ static int bq25180_init(const struct device *dev)
}
}
/* Precharge threshold voltage */
if (cfg->precharge_threshold_voltage_microvolt <= 2800000) {
val = BQ25180_VLOWV_SEL_2_8;
} else {
val = BQ25180_VLOWV_SEL_3_0;
}
ret = i2c_reg_update_byte_dt(&cfg->i2c, BQ25180_IC_CTRL, BQ25180_VLOWV_SEL_MSK, val);
if (ret < 0) {
return ret;
}
if (cfg->initial_current_microamp > 0) {
ret = bq25180_set_charge_current(dev, cfg->initial_current_microamp);
if (ret < 0) {
@ -372,6 +388,8 @@ static int bq25180_init(const struct device *dev)
DT_INST_PROP(inst, constant_charge_voltage_max_microvolt), \
.recharge_voltage_microvolt = \
DT_INST_PROP_OR(inst, re_charge_voltage_microvolt, 0), \
.precharge_threshold_voltage_microvolt = \
DT_INST_PROP(inst, precharge_voltage_threshold_microvolt), \
}; \
\
DEVICE_DT_INST_DEFINE(inst, bq25180_init, NULL, NULL, &bq25180_config_##inst, POST_KERNEL, \

View File

@ -31,3 +31,10 @@ properties:
constant-charge-voltage-max-microvolt:
required: true
precharge-voltage-threshold-microvolt:
type: int
default: 3000000
description: |
Threshold at which voltage to switch to constant current charge.
Must be either 3.0V or 2.8V