Loading drivers/power/supply/qcom/step-chg-jeita.c +36 −17 Original line number Diff line number Diff line Loading @@ -281,7 +281,7 @@ static int get_step_chg_jeita_setting_from_profile(struct step_chg_info *chip) u32 max_fv_uv, max_fcc_ma; const char *batt_type_str; const __be32 *handle; int batt_id_ohms = 0, rc; int batt_id_ohms, rc, hysteresis[2] = {0}; handle = of_get_property(chip->dev->of_node, "qcom,battery-data", NULL); Loading Loading @@ -350,7 +350,8 @@ static int get_step_chg_jeita_setting_from_profile(struct step_chg_info *chip) POWER_SUPPLY_PROP_CAPACITY; chip->step_chg_config->param.iio_prop = STEP_QG_CAPACITY; chip->step_chg_config->param.prop_name = "SOC"; chip->step_chg_config->param.hysteresis = 0; chip->step_chg_config->param.rise_hys = 0; chip->step_chg_config->param.fall_hys = 0; } chip->ocv_based_step_chg = Loading @@ -360,7 +361,8 @@ static int get_step_chg_jeita_setting_from_profile(struct step_chg_info *chip) POWER_SUPPLY_PROP_VOLTAGE_OCV; chip->step_chg_config->param.iio_prop = STEP_QG_VOLTAGE_OCV; chip->step_chg_config->param.prop_name = "OCV"; chip->step_chg_config->param.hysteresis = 0; chip->step_chg_config->param.rise_hys = 0; chip->step_chg_config->param.fall_hys = 0; chip->step_chg_config->param.use_bms = true; } Loading @@ -372,7 +374,8 @@ static int get_step_chg_jeita_setting_from_profile(struct step_chg_info *chip) POWER_SUPPLY_PROP_VOLTAGE_AVG; chip->step_chg_config->param.iio_prop = STEP_QG_VOLTAGE_AVG; chip->step_chg_config->param.prop_name = "VBAT_AVG"; chip->step_chg_config->param.hysteresis = 0; chip->step_chg_config->param.rise_hys = 0; chip->step_chg_config->param.fall_hys = 0; chip->step_chg_config->param.use_bms = true; } Loading @@ -399,6 +402,15 @@ static int get_step_chg_jeita_setting_from_profile(struct step_chg_info *chip) chip->sw_jeita_cfg_valid = false; } rc = of_property_read_u32_array(profile_node, "qcom,step-jeita-hysteresis", hysteresis, 2); if (!rc) { chip->jeita_fcc_config->param.rise_hys = hysteresis[0]; chip->jeita_fcc_config->param.fall_hys = hysteresis[1]; pr_debug("jeita-fcc-hys: rise_hys=%u, fall_hys=%u\n", hysteresis[0], hysteresis[1]); } rc = read_range_data_from_node(profile_node, "qcom,jeita-fv-ranges", chip->jeita_fv_config->fv_cfg, Loading Loading @@ -458,9 +470,8 @@ static void get_config_work(struct work_struct *work) } static int get_val(struct range_data *range, int hysteresis, int current_index, int threshold, int *new_index, int *val) static int get_val(struct range_data *range, int rise_hys, int fall_hys, int current_index, int threshold, int *new_index, int *val) { int i; Loading Loading @@ -518,7 +529,8 @@ static int get_val(struct range_data *range, int hysteresis, int current_index, * of our current index. */ if (*new_index == current_index + 1) { if (threshold < range[*new_index].low_threshold + hysteresis) { if (threshold < (range[*new_index].low_threshold + rise_hys)) { /* * Stay in the current index, threshold is not higher * by hysteresis amount Loading @@ -527,7 +539,8 @@ static int get_val(struct range_data *range, int hysteresis, int current_index, *val = range[current_index].value; } } else if (*new_index == current_index - 1) { if (threshold > range[*new_index].high_threshold - hysteresis) { if (threshold > range[*new_index].high_threshold - fall_hys) { /* * stay in the current index, threshold is not lower * by hysteresis amount Loading Loading @@ -557,7 +570,7 @@ static void taper_fcc_step_chg(struct step_chg_info *chip, int index, vote(chip->fcc_votable, STEP_CHG_VOTER, true, target_fcc); } else if (current_voltage > (chip->step_chg_config->fcc_cfg[index - 1].high_threshold + chip->step_chg_config->param.hysteresis)) { chip->step_chg_config->param.rise_hys)) { /* * Ramp down FCC in pre-configured steps till the current index * FCC configuration is reached, whenever the step charging Loading @@ -570,7 +583,7 @@ static void taper_fcc_step_chg(struct step_chg_info *chip, int index, chip->step_chg_config->fcc_cfg[index - 1].value) && (current_voltage > chip->step_chg_config->fcc_cfg[index - 1].low_threshold + chip->step_chg_config->param.hysteresis)) { chip->step_chg_config->param.fall_hys)) { /* * In case the step charging index switch to the next higher * index without FCCs saturation for the previous index, ramp Loading Loading @@ -618,7 +631,8 @@ static int handle_step_chg_config(struct step_chg_info *chip) current_index = chip->step_index; rc = get_val(chip->step_chg_config->fcc_cfg, chip->step_chg_config->param.hysteresis, chip->step_chg_config->param.rise_hys, chip->step_chg_config->param.fall_hys, chip->step_index, pval.intval, &chip->step_index, Loading Loading @@ -709,7 +723,8 @@ static int handle_jeita(struct step_chg_info *chip) } rc = get_val(chip->jeita_fcc_config->fcc_cfg, chip->jeita_fcc_config->param.hysteresis, chip->jeita_fcc_config->param.rise_hys, chip->jeita_fcc_config->param.fall_hys, chip->jeita_fcc_index, pval.intval, &chip->jeita_fcc_index, Loading @@ -726,7 +741,8 @@ static int handle_jeita(struct step_chg_info *chip) vote(chip->fcc_votable, JEITA_VOTER, fcc_ua ? true : false, fcc_ua); rc = get_val(chip->jeita_fv_config->fv_cfg, chip->jeita_fv_config->param.hysteresis, chip->jeita_fv_config->param.rise_hys, chip->jeita_fv_config->param.fall_hys, chip->jeita_fv_index, pval.intval, &chip->jeita_fv_index, Loading Loading @@ -921,7 +937,8 @@ int qcom_step_chg_init(struct device *dev, bool step_chg_enable, chip->step_chg_config->param.psy_prop = POWER_SUPPLY_PROP_VOLTAGE_NOW; chip->step_chg_config->param.iio_prop = STEP_QG_VOLTAGE_NOW; chip->step_chg_config->param.prop_name = "VBATT"; chip->step_chg_config->param.hysteresis = 100000; chip->step_chg_config->param.rise_hys = 100000; chip->step_chg_config->param.fall_hys = 100000; chip->jeita_fcc_config = devm_kzalloc(dev, sizeof(struct jeita_fcc_cfg), GFP_KERNEL); Loading @@ -933,11 +950,13 @@ int qcom_step_chg_init(struct device *dev, bool step_chg_enable, chip->jeita_fcc_config->param.psy_prop = POWER_SUPPLY_PROP_TEMP; chip->jeita_fcc_config->param.iio_prop = STEP_QG_TEMP; chip->jeita_fcc_config->param.prop_name = "BATT_TEMP"; chip->jeita_fcc_config->param.hysteresis = 10; chip->jeita_fcc_config->param.rise_hys = 10; chip->jeita_fcc_config->param.fall_hys = 10; chip->jeita_fv_config->param.psy_prop = POWER_SUPPLY_PROP_TEMP; chip->jeita_fv_config->param.iio_prop = STEP_QG_TEMP; chip->jeita_fv_config->param.prop_name = "BATT_TEMP"; chip->jeita_fv_config->param.hysteresis = 10; chip->jeita_fv_config->param.rise_hys = 10; chip->jeita_fv_config->param.fall_hys = 10; INIT_DELAYED_WORK(&chip->status_change_work, status_change_work); INIT_DELAYED_WORK(&chip->get_config_work, get_config_work); Loading drivers/power/supply/qcom/step-chg-jeita.h +2 −1 Original line number Diff line number Diff line Loading @@ -15,7 +15,8 @@ struct step_chg_jeita_param { u32 psy_prop; u32 iio_prop; char *prop_name; int hysteresis; int rise_hys; int fall_hys; bool use_bms; }; Loading Loading
drivers/power/supply/qcom/step-chg-jeita.c +36 −17 Original line number Diff line number Diff line Loading @@ -281,7 +281,7 @@ static int get_step_chg_jeita_setting_from_profile(struct step_chg_info *chip) u32 max_fv_uv, max_fcc_ma; const char *batt_type_str; const __be32 *handle; int batt_id_ohms = 0, rc; int batt_id_ohms, rc, hysteresis[2] = {0}; handle = of_get_property(chip->dev->of_node, "qcom,battery-data", NULL); Loading Loading @@ -350,7 +350,8 @@ static int get_step_chg_jeita_setting_from_profile(struct step_chg_info *chip) POWER_SUPPLY_PROP_CAPACITY; chip->step_chg_config->param.iio_prop = STEP_QG_CAPACITY; chip->step_chg_config->param.prop_name = "SOC"; chip->step_chg_config->param.hysteresis = 0; chip->step_chg_config->param.rise_hys = 0; chip->step_chg_config->param.fall_hys = 0; } chip->ocv_based_step_chg = Loading @@ -360,7 +361,8 @@ static int get_step_chg_jeita_setting_from_profile(struct step_chg_info *chip) POWER_SUPPLY_PROP_VOLTAGE_OCV; chip->step_chg_config->param.iio_prop = STEP_QG_VOLTAGE_OCV; chip->step_chg_config->param.prop_name = "OCV"; chip->step_chg_config->param.hysteresis = 0; chip->step_chg_config->param.rise_hys = 0; chip->step_chg_config->param.fall_hys = 0; chip->step_chg_config->param.use_bms = true; } Loading @@ -372,7 +374,8 @@ static int get_step_chg_jeita_setting_from_profile(struct step_chg_info *chip) POWER_SUPPLY_PROP_VOLTAGE_AVG; chip->step_chg_config->param.iio_prop = STEP_QG_VOLTAGE_AVG; chip->step_chg_config->param.prop_name = "VBAT_AVG"; chip->step_chg_config->param.hysteresis = 0; chip->step_chg_config->param.rise_hys = 0; chip->step_chg_config->param.fall_hys = 0; chip->step_chg_config->param.use_bms = true; } Loading @@ -399,6 +402,15 @@ static int get_step_chg_jeita_setting_from_profile(struct step_chg_info *chip) chip->sw_jeita_cfg_valid = false; } rc = of_property_read_u32_array(profile_node, "qcom,step-jeita-hysteresis", hysteresis, 2); if (!rc) { chip->jeita_fcc_config->param.rise_hys = hysteresis[0]; chip->jeita_fcc_config->param.fall_hys = hysteresis[1]; pr_debug("jeita-fcc-hys: rise_hys=%u, fall_hys=%u\n", hysteresis[0], hysteresis[1]); } rc = read_range_data_from_node(profile_node, "qcom,jeita-fv-ranges", chip->jeita_fv_config->fv_cfg, Loading Loading @@ -458,9 +470,8 @@ static void get_config_work(struct work_struct *work) } static int get_val(struct range_data *range, int hysteresis, int current_index, int threshold, int *new_index, int *val) static int get_val(struct range_data *range, int rise_hys, int fall_hys, int current_index, int threshold, int *new_index, int *val) { int i; Loading Loading @@ -518,7 +529,8 @@ static int get_val(struct range_data *range, int hysteresis, int current_index, * of our current index. */ if (*new_index == current_index + 1) { if (threshold < range[*new_index].low_threshold + hysteresis) { if (threshold < (range[*new_index].low_threshold + rise_hys)) { /* * Stay in the current index, threshold is not higher * by hysteresis amount Loading @@ -527,7 +539,8 @@ static int get_val(struct range_data *range, int hysteresis, int current_index, *val = range[current_index].value; } } else if (*new_index == current_index - 1) { if (threshold > range[*new_index].high_threshold - hysteresis) { if (threshold > range[*new_index].high_threshold - fall_hys) { /* * stay in the current index, threshold is not lower * by hysteresis amount Loading Loading @@ -557,7 +570,7 @@ static void taper_fcc_step_chg(struct step_chg_info *chip, int index, vote(chip->fcc_votable, STEP_CHG_VOTER, true, target_fcc); } else if (current_voltage > (chip->step_chg_config->fcc_cfg[index - 1].high_threshold + chip->step_chg_config->param.hysteresis)) { chip->step_chg_config->param.rise_hys)) { /* * Ramp down FCC in pre-configured steps till the current index * FCC configuration is reached, whenever the step charging Loading @@ -570,7 +583,7 @@ static void taper_fcc_step_chg(struct step_chg_info *chip, int index, chip->step_chg_config->fcc_cfg[index - 1].value) && (current_voltage > chip->step_chg_config->fcc_cfg[index - 1].low_threshold + chip->step_chg_config->param.hysteresis)) { chip->step_chg_config->param.fall_hys)) { /* * In case the step charging index switch to the next higher * index without FCCs saturation for the previous index, ramp Loading Loading @@ -618,7 +631,8 @@ static int handle_step_chg_config(struct step_chg_info *chip) current_index = chip->step_index; rc = get_val(chip->step_chg_config->fcc_cfg, chip->step_chg_config->param.hysteresis, chip->step_chg_config->param.rise_hys, chip->step_chg_config->param.fall_hys, chip->step_index, pval.intval, &chip->step_index, Loading Loading @@ -709,7 +723,8 @@ static int handle_jeita(struct step_chg_info *chip) } rc = get_val(chip->jeita_fcc_config->fcc_cfg, chip->jeita_fcc_config->param.hysteresis, chip->jeita_fcc_config->param.rise_hys, chip->jeita_fcc_config->param.fall_hys, chip->jeita_fcc_index, pval.intval, &chip->jeita_fcc_index, Loading @@ -726,7 +741,8 @@ static int handle_jeita(struct step_chg_info *chip) vote(chip->fcc_votable, JEITA_VOTER, fcc_ua ? true : false, fcc_ua); rc = get_val(chip->jeita_fv_config->fv_cfg, chip->jeita_fv_config->param.hysteresis, chip->jeita_fv_config->param.rise_hys, chip->jeita_fv_config->param.fall_hys, chip->jeita_fv_index, pval.intval, &chip->jeita_fv_index, Loading Loading @@ -921,7 +937,8 @@ int qcom_step_chg_init(struct device *dev, bool step_chg_enable, chip->step_chg_config->param.psy_prop = POWER_SUPPLY_PROP_VOLTAGE_NOW; chip->step_chg_config->param.iio_prop = STEP_QG_VOLTAGE_NOW; chip->step_chg_config->param.prop_name = "VBATT"; chip->step_chg_config->param.hysteresis = 100000; chip->step_chg_config->param.rise_hys = 100000; chip->step_chg_config->param.fall_hys = 100000; chip->jeita_fcc_config = devm_kzalloc(dev, sizeof(struct jeita_fcc_cfg), GFP_KERNEL); Loading @@ -933,11 +950,13 @@ int qcom_step_chg_init(struct device *dev, bool step_chg_enable, chip->jeita_fcc_config->param.psy_prop = POWER_SUPPLY_PROP_TEMP; chip->jeita_fcc_config->param.iio_prop = STEP_QG_TEMP; chip->jeita_fcc_config->param.prop_name = "BATT_TEMP"; chip->jeita_fcc_config->param.hysteresis = 10; chip->jeita_fcc_config->param.rise_hys = 10; chip->jeita_fcc_config->param.fall_hys = 10; chip->jeita_fv_config->param.psy_prop = POWER_SUPPLY_PROP_TEMP; chip->jeita_fv_config->param.iio_prop = STEP_QG_TEMP; chip->jeita_fv_config->param.prop_name = "BATT_TEMP"; chip->jeita_fv_config->param.hysteresis = 10; chip->jeita_fv_config->param.rise_hys = 10; chip->jeita_fv_config->param.fall_hys = 10; INIT_DELAYED_WORK(&chip->status_change_work, status_change_work); INIT_DELAYED_WORK(&chip->get_config_work, get_config_work); Loading
drivers/power/supply/qcom/step-chg-jeita.h +2 −1 Original line number Diff line number Diff line Loading @@ -15,7 +15,8 @@ struct step_chg_jeita_param { u32 psy_prop; u32 iio_prop; char *prop_name; int hysteresis; int rise_hys; int fall_hys; bool use_bms; }; Loading