power: qpnp-fg-gen3: adjust ki coefficient for full soc dynamically

In certain conditions, after the battery SOC reaches 100%, SOC is
not getting updated during discharging. Based on the hardware
recommendation, adjust the Ki coefficient for full SOC so that
SOC can be updated faster during discharging.

While at it, remove prev_charge_status variable which is not
used really.

CRs-Fixed: 2089555
Change-Id: I54b7d86529c21c016ab777053895ccda9c7a2b35
Signed-off-by: Subbaraman Narayanamurthy <subbaram@codeaurora.org>
This commit is contained in:
Subbaraman Narayanamurthy 2017-08-08 19:28:37 -07:00
parent 491c46fc13
commit 092b095537
3 changed files with 15 additions and 4 deletions

View file

@ -309,6 +309,13 @@ First Level Node - FG Gen3 device
is specified to make it fully functional. Value has no
unit. Allowed range is 0 to 62200 in micro units.
- qcom,ki-coeff-full-dischg
Usage: optional
Value type: <u32>
Definition: Ki coefficient full SOC value that will be applied during
discharging. If not specified, a value of 0 will be set.
Allowed range is from 245 to 62256.
- qcom,fg-rconn-mohms
Usage: optional
Value type: <u32>

View file

@ -273,6 +273,7 @@ struct fg_dt_props {
int slope_limit_temp;
int esr_pulse_thresh_ma;
int esr_meas_curr_ma;
int ki_coeff_full_soc_dischg;
int jeita_thresholds[NUM_JEITA_LEVELS];
int ki_coeff_soc[KI_COEFF_SOC_LEVELS];
int ki_coeff_med_dischg[KI_COEFF_SOC_LEVELS];
@ -410,7 +411,6 @@ struct fg_chip {
int batt_id_ohms;
int ki_coeff_full_soc;
int charge_status;
int prev_charge_status;
int charge_done;
int charge_type;
int online_status;

View file

@ -1631,6 +1631,8 @@ static int fg_adjust_ki_coeff_full_soc(struct fg_chip *chip, int batt_temp)
if (batt_temp < 0)
ki_coeff_full_soc = 0;
else if (chip->charge_status == POWER_SUPPLY_STATUS_DISCHARGING)
ki_coeff_full_soc = chip->dt.ki_coeff_full_soc_dischg;
else
ki_coeff_full_soc = KI_COEFF_FULL_SOC_DEFAULT;
@ -2507,7 +2509,6 @@ static void status_change_work(struct work_struct *work)
goto out;
}
chip->prev_charge_status = chip->charge_status;
chip->charge_status = prop.intval;
rc = power_supply_get_property(chip->batt_psy,
POWER_SUPPLY_PROP_CHARGE_TYPE, &prop);
@ -4476,7 +4477,11 @@ static int fg_parse_slope_limit_coefficients(struct fg_chip *chip)
static int fg_parse_ki_coefficients(struct fg_chip *chip)
{
struct device_node *node = chip->dev->of_node;
int rc, i;
int rc, i, temp;
rc = of_property_read_u32(node, "qcom,ki-coeff-full-dischg", &temp);
if (!rc)
chip->dt.ki_coeff_full_soc_dischg = temp;
rc = fg_parse_dt_property_u32_array(node, "qcom,ki-coeff-soc-dischg",
chip->dt.ki_coeff_soc, KI_COEFF_SOC_LEVELS);
@ -4929,7 +4934,6 @@ static int fg_gen3_probe(struct platform_device *pdev)
chip->debug_mask = &fg_gen3_debug_mask;
chip->irqs = fg_irqs;
chip->charge_status = -EINVAL;
chip->prev_charge_status = -EINVAL;
chip->ki_coeff_full_soc = -EINVAL;
chip->online_status = -EINVAL;
chip->regmap = dev_get_regmap(chip->dev->parent, NULL);