Loading drivers/power/supply/qcom/battery.c +75 −0 Original line number Diff line number Diff line Loading @@ -35,12 +35,15 @@ #define PARALLEL_PSY_VOTER "PARALLEL_PSY_VOTER" #define PL_HW_ABSENT_VOTER "PL_HW_ABSENT_VOTER" #define PL_VOTER "PL_VOTER" #define RESTRICT_CHG_VOTER "RESTRICT_CHG_VOTER" struct pl_data { int pl_mode; int slave_pct; int taper_pct; int slave_fcc_ua; int restricted_current; bool restricted_charging_enabled; struct votable *fcc_votable; struct votable *fv_votable; struct votable *pl_disable_votable; Loading Loading @@ -80,6 +83,8 @@ module_param_named(debug_mask, debug_mask, int, S_IRUSR | S_IWUSR); enum { VER = 0, SLAVE_PCT, RESTRICT_CHG_ENABLE, RESTRICT_CHG_CURRENT, }; /******* Loading Loading @@ -180,10 +185,78 @@ static ssize_t slave_pct_store(struct class *c, struct class_attribute *attr, return count; } /********************** * RESTICTED CHARGIGNG * ***********************/ static ssize_t restrict_chg_show(struct class *c, struct class_attribute *attr, char *ubuf) { struct pl_data *chip = container_of(c, struct pl_data, qcom_batt_class); return snprintf(ubuf, PAGE_SIZE, "%d\n", chip->restricted_charging_enabled); } static ssize_t restrict_chg_store(struct class *c, struct class_attribute *attr, const char *ubuf, size_t count) { struct pl_data *chip = container_of(c, struct pl_data, qcom_batt_class); unsigned long val; if (kstrtoul(ubuf, 10, &val)) return -EINVAL; if (chip->restricted_charging_enabled == !!val) goto no_change; chip->restricted_charging_enabled = !!val; vote(chip->fcc_votable, RESTRICT_CHG_VOTER, chip->restricted_charging_enabled, chip->restricted_current); no_change: return count; } static ssize_t restrict_cur_show(struct class *c, struct class_attribute *attr, char *ubuf) { struct pl_data *chip = container_of(c, struct pl_data, qcom_batt_class); return snprintf(ubuf, PAGE_SIZE, "%d\n", chip->restricted_current); } static ssize_t restrict_cur_store(struct class *c, struct class_attribute *attr, const char *ubuf, size_t count) { struct pl_data *chip = container_of(c, struct pl_data, qcom_batt_class); unsigned long val; if (kstrtoul(ubuf, 10, &val)) return -EINVAL; chip->restricted_current = val; vote(chip->fcc_votable, RESTRICT_CHG_VOTER, chip->restricted_charging_enabled, chip->restricted_current); return count; } static struct class_attribute pl_attributes[] = { [VER] = __ATTR_RO(version), [SLAVE_PCT] = __ATTR(parallel_pct, S_IRUGO | S_IWUSR, slave_pct_show, slave_pct_store), [RESTRICT_CHG_ENABLE] = __ATTR(restricted_charging, S_IRUGO | S_IWUSR, restrict_chg_show, restrict_chg_store), [RESTRICT_CHG_CURRENT] = __ATTR(restricted_current, S_IRUGO | S_IWUSR, restrict_cur_show, restrict_cur_store), __ATTR_NULL, }; Loading Loading @@ -750,6 +823,7 @@ static int pl_determine_initial_status(struct pl_data *chip) return 0; } #define DEFAULT_RESTRICTED_CURRENT_UA 1000000 static int pl_init(void) { struct pl_data *chip; Loading @@ -759,6 +833,7 @@ static int pl_init(void) if (!chip) return -ENOMEM; chip->slave_pct = 50; chip->restricted_current = DEFAULT_RESTRICTED_CURRENT_UA; chip->pl_ws = wakeup_source_register("qcom-battery"); if (!chip->pl_ws) Loading Loading
drivers/power/supply/qcom/battery.c +75 −0 Original line number Diff line number Diff line Loading @@ -35,12 +35,15 @@ #define PARALLEL_PSY_VOTER "PARALLEL_PSY_VOTER" #define PL_HW_ABSENT_VOTER "PL_HW_ABSENT_VOTER" #define PL_VOTER "PL_VOTER" #define RESTRICT_CHG_VOTER "RESTRICT_CHG_VOTER" struct pl_data { int pl_mode; int slave_pct; int taper_pct; int slave_fcc_ua; int restricted_current; bool restricted_charging_enabled; struct votable *fcc_votable; struct votable *fv_votable; struct votable *pl_disable_votable; Loading Loading @@ -80,6 +83,8 @@ module_param_named(debug_mask, debug_mask, int, S_IRUSR | S_IWUSR); enum { VER = 0, SLAVE_PCT, RESTRICT_CHG_ENABLE, RESTRICT_CHG_CURRENT, }; /******* Loading Loading @@ -180,10 +185,78 @@ static ssize_t slave_pct_store(struct class *c, struct class_attribute *attr, return count; } /********************** * RESTICTED CHARGIGNG * ***********************/ static ssize_t restrict_chg_show(struct class *c, struct class_attribute *attr, char *ubuf) { struct pl_data *chip = container_of(c, struct pl_data, qcom_batt_class); return snprintf(ubuf, PAGE_SIZE, "%d\n", chip->restricted_charging_enabled); } static ssize_t restrict_chg_store(struct class *c, struct class_attribute *attr, const char *ubuf, size_t count) { struct pl_data *chip = container_of(c, struct pl_data, qcom_batt_class); unsigned long val; if (kstrtoul(ubuf, 10, &val)) return -EINVAL; if (chip->restricted_charging_enabled == !!val) goto no_change; chip->restricted_charging_enabled = !!val; vote(chip->fcc_votable, RESTRICT_CHG_VOTER, chip->restricted_charging_enabled, chip->restricted_current); no_change: return count; } static ssize_t restrict_cur_show(struct class *c, struct class_attribute *attr, char *ubuf) { struct pl_data *chip = container_of(c, struct pl_data, qcom_batt_class); return snprintf(ubuf, PAGE_SIZE, "%d\n", chip->restricted_current); } static ssize_t restrict_cur_store(struct class *c, struct class_attribute *attr, const char *ubuf, size_t count) { struct pl_data *chip = container_of(c, struct pl_data, qcom_batt_class); unsigned long val; if (kstrtoul(ubuf, 10, &val)) return -EINVAL; chip->restricted_current = val; vote(chip->fcc_votable, RESTRICT_CHG_VOTER, chip->restricted_charging_enabled, chip->restricted_current); return count; } static struct class_attribute pl_attributes[] = { [VER] = __ATTR_RO(version), [SLAVE_PCT] = __ATTR(parallel_pct, S_IRUGO | S_IWUSR, slave_pct_show, slave_pct_store), [RESTRICT_CHG_ENABLE] = __ATTR(restricted_charging, S_IRUGO | S_IWUSR, restrict_chg_show, restrict_chg_store), [RESTRICT_CHG_CURRENT] = __ATTR(restricted_current, S_IRUGO | S_IWUSR, restrict_cur_show, restrict_cur_store), __ATTR_NULL, }; Loading Loading @@ -750,6 +823,7 @@ static int pl_determine_initial_status(struct pl_data *chip) return 0; } #define DEFAULT_RESTRICTED_CURRENT_UA 1000000 static int pl_init(void) { struct pl_data *chip; Loading @@ -759,6 +833,7 @@ static int pl_init(void) if (!chip) return -ENOMEM; chip->slave_pct = 50; chip->restricted_current = DEFAULT_RESTRICTED_CURRENT_UA; chip->pl_ws = wakeup_source_register("qcom-battery"); if (!chip->pl_ws) Loading