Merge "power: qpnp-fg-gen3: add support for configuring cutoff current"
This commit is contained in:
commit
be48c04efd
3 changed files with 32 additions and 0 deletions
|
@ -104,6 +104,13 @@ First Level Node - FG Gen3 device
|
|||
this property is not specified, then the default value used
|
||||
will be 75mA.
|
||||
|
||||
- qcom,fg-cutoff-current
|
||||
Usage: optional
|
||||
Value type: <u32>
|
||||
Definition: Minimum Battery current (in mA) used for cutoff SOC
|
||||
estimate. If this property is not specified, then a default
|
||||
value of 500 mA will be applied.
|
||||
|
||||
- qcom,fg-delta-soc-thr
|
||||
Usage: optional
|
||||
Value type: <u32>
|
||||
|
|
|
@ -168,6 +168,7 @@ enum fg_sram_param_id {
|
|||
FG_SRAM_SYS_TERM_CURR,
|
||||
FG_SRAM_CHG_TERM_CURR,
|
||||
FG_SRAM_CHG_TERM_BASE_CURR,
|
||||
FG_SRAM_CUTOFF_CURR,
|
||||
FG_SRAM_DELTA_MSOC_THR,
|
||||
FG_SRAM_DELTA_BSOC_THR,
|
||||
FG_SRAM_RECHARGE_SOC_THR,
|
||||
|
@ -254,6 +255,7 @@ struct fg_dt_props {
|
|||
int chg_term_curr_ma;
|
||||
int chg_term_base_curr_ma;
|
||||
int sys_term_curr_ma;
|
||||
int cutoff_curr_ma;
|
||||
int delta_soc_thr;
|
||||
int recharge_soc_thr;
|
||||
int recharge_volt_thr_mv;
|
||||
|
|
|
@ -35,6 +35,8 @@
|
|||
#define ESR_PULSE_THRESH_OFFSET 3
|
||||
#define SLOPE_LIMIT_WORD 3
|
||||
#define SLOPE_LIMIT_OFFSET 0
|
||||
#define CUTOFF_CURR_WORD 4
|
||||
#define CUTOFF_CURR_OFFSET 0
|
||||
#define CUTOFF_VOLT_WORD 5
|
||||
#define CUTOFF_VOLT_OFFSET 0
|
||||
#define SYS_TERM_CURR_WORD 6
|
||||
|
@ -208,6 +210,8 @@ static struct fg_sram_param pmi8998_v1_sram_params[] = {
|
|||
1000000, 122070, 0, fg_encode_current, NULL),
|
||||
PARAM(CHG_TERM_CURR, CHG_TERM_CURR_WORD, CHG_TERM_CURR_OFFSET, 1,
|
||||
100000, 390625, 0, fg_encode_current, NULL),
|
||||
PARAM(CUTOFF_CURR, CUTOFF_CURR_WORD, CUTOFF_CURR_OFFSET, 3,
|
||||
1000000, 122070, 0, fg_encode_current, NULL),
|
||||
PARAM(DELTA_MSOC_THR, DELTA_MSOC_THR_WORD, DELTA_MSOC_THR_OFFSET, 1,
|
||||
2048, 100, 0, fg_encode_default, NULL),
|
||||
PARAM(DELTA_BSOC_THR, DELTA_BSOC_THR_WORD, DELTA_BSOC_THR_OFFSET, 1,
|
||||
|
@ -284,6 +288,8 @@ static struct fg_sram_param pmi8998_v2_sram_params[] = {
|
|||
PARAM(CHG_TERM_BASE_CURR, CHG_TERM_CURR_v2_WORD,
|
||||
CHG_TERM_BASE_CURR_v2_OFFSET, 1, 1024, 1000, 0,
|
||||
fg_encode_current, NULL),
|
||||
PARAM(CUTOFF_CURR, CUTOFF_CURR_WORD, CUTOFF_CURR_OFFSET, 3,
|
||||
1000000, 122070, 0, fg_encode_current, NULL),
|
||||
PARAM(DELTA_MSOC_THR, DELTA_MSOC_THR_v2_WORD, DELTA_MSOC_THR_v2_OFFSET,
|
||||
1, 2048, 100, 0, fg_encode_default, NULL),
|
||||
PARAM(DELTA_BSOC_THR, DELTA_BSOC_THR_v2_WORD, DELTA_BSOC_THR_v2_OFFSET,
|
||||
|
@ -4089,6 +4095,16 @@ static int fg_hw_init(struct fg_chip *chip)
|
|||
return rc;
|
||||
}
|
||||
|
||||
fg_encode(chip->sp, FG_SRAM_CUTOFF_CURR, chip->dt.cutoff_curr_ma,
|
||||
buf);
|
||||
rc = fg_sram_write(chip, chip->sp[FG_SRAM_CUTOFF_CURR].addr_word,
|
||||
chip->sp[FG_SRAM_CUTOFF_CURR].addr_byte, buf,
|
||||
chip->sp[FG_SRAM_CUTOFF_CURR].len, FG_IMA_DEFAULT);
|
||||
if (rc < 0) {
|
||||
pr_err("Error in writing cutoff_curr, rc=%d\n", rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
if (!(chip->wa_flags & PMI8998_V1_REV_WA)) {
|
||||
fg_encode(chip->sp, FG_SRAM_CHG_TERM_BASE_CURR,
|
||||
chip->dt.chg_term_base_curr_ma, buf);
|
||||
|
@ -4805,6 +4821,7 @@ static int fg_parse_ki_coefficients(struct fg_chip *chip)
|
|||
#define DEFAULT_CHG_TERM_CURR_MA 100
|
||||
#define DEFAULT_CHG_TERM_BASE_CURR_MA 75
|
||||
#define DEFAULT_SYS_TERM_CURR_MA -125
|
||||
#define DEFAULT_CUTOFF_CURR_MA 500
|
||||
#define DEFAULT_DELTA_SOC_THR 1
|
||||
#define DEFAULT_RECHARGE_SOC_THR 95
|
||||
#define DEFAULT_BATT_TEMP_COLD 0
|
||||
|
@ -4969,6 +4986,12 @@ static int fg_parse_dt(struct fg_chip *chip)
|
|||
else
|
||||
chip->dt.chg_term_base_curr_ma = temp;
|
||||
|
||||
rc = of_property_read_u32(node, "qcom,fg-cutoff-current", &temp);
|
||||
if (rc < 0)
|
||||
chip->dt.cutoff_curr_ma = DEFAULT_CUTOFF_CURR_MA;
|
||||
else
|
||||
chip->dt.cutoff_curr_ma = temp;
|
||||
|
||||
rc = of_property_read_u32(node, "qcom,fg-delta-soc-thr", &temp);
|
||||
if (rc < 0)
|
||||
chip->dt.delta_soc_thr = DEFAULT_DELTA_SOC_THR;
|
||||
|
|
Loading…
Add table
Reference in a new issue