power: qpnp-fg-gen3: use the CC_STEP and CC_STEP_SEL properties
Add support for the CC_STEP and CC_STEP_SEL properties in the BMS power supply. These properties will be used to communicate the future charge currents for time to full calculations. Change-Id: I44087b42b31800d1885bdaf1f38815c8756bc9a8 Signed-off-by: Nicholas Troast <ntroast@codeaurora.org> Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
This commit is contained in:
parent
eb8700f685
commit
3c21390e3c
2 changed files with 44 additions and 0 deletions
|
@ -81,6 +81,8 @@
|
|||
|
||||
#define BATT_THERM_NUM_COEFFS 3
|
||||
|
||||
#define MAX_CC_STEPS 20
|
||||
|
||||
/* Debug flag definitions */
|
||||
enum fg_debug_flag {
|
||||
FG_IRQ = BIT(0), /* Show interrupts */
|
||||
|
@ -314,6 +316,11 @@ struct fg_circ_buf {
|
|||
int head;
|
||||
};
|
||||
|
||||
struct fg_cc_step_data {
|
||||
int arr[MAX_CC_STEPS];
|
||||
int sel;
|
||||
};
|
||||
|
||||
struct fg_pt {
|
||||
s32 x;
|
||||
s32 y;
|
||||
|
@ -374,6 +381,7 @@ struct fg_chip {
|
|||
struct fg_cyc_ctr_data cyc_ctr;
|
||||
struct notifier_block nb;
|
||||
struct fg_cap_learning cl;
|
||||
struct fg_cc_step_data cc_step;
|
||||
struct mutex bus_lock;
|
||||
struct mutex sram_rw_lock;
|
||||
struct mutex batt_avg_lock;
|
||||
|
|
|
@ -3193,6 +3193,19 @@ static int fg_psy_get_property(struct power_supply *psy,
|
|||
case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE:
|
||||
rc = fg_get_sram_prop(chip, FG_SRAM_VBATT_FULL, &pval->intval);
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_CC_STEP:
|
||||
if ((chip->cc_step.sel >= 0) &&
|
||||
(chip->cc_step.sel < MAX_CC_STEPS)) {
|
||||
pval->intval = chip->cc_step.arr[chip->cc_step.sel];
|
||||
} else {
|
||||
pr_err("cc_step_sel is out of bounds [0, %d]\n",
|
||||
chip->cc_step.sel);
|
||||
return -EINVAL;
|
||||
}
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_CC_STEP_SEL:
|
||||
pval->intval = chip->cc_step.sel;
|
||||
break;
|
||||
default:
|
||||
pr_err("unsupported property %d\n", psp);
|
||||
rc = -EINVAL;
|
||||
|
@ -3231,6 +3244,25 @@ static int fg_psy_set_property(struct power_supply *psy,
|
|||
case POWER_SUPPLY_PROP_CHARGE_QNOVO_ENABLE:
|
||||
rc = fg_prepare_for_qnovo(chip, pval->intval);
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_CC_STEP:
|
||||
if ((chip->cc_step.sel >= 0) &&
|
||||
(chip->cc_step.sel < MAX_CC_STEPS)) {
|
||||
chip->cc_step.arr[chip->cc_step.sel] = pval->intval;
|
||||
} else {
|
||||
pr_err("cc_step_sel is out of bounds [0, %d]\n",
|
||||
chip->cc_step.sel);
|
||||
return -EINVAL;
|
||||
}
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_CC_STEP_SEL:
|
||||
if ((pval->intval >= 0) && (pval->intval < MAX_CC_STEPS)) {
|
||||
chip->cc_step.sel = pval->intval;
|
||||
} else {
|
||||
pr_err("cc_step_sel is out of bounds [0, %d]\n",
|
||||
pval->intval);
|
||||
return -EINVAL;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -3244,6 +3276,8 @@ static int fg_property_is_writeable(struct power_supply *psy,
|
|||
switch (psp) {
|
||||
case POWER_SUPPLY_PROP_CYCLE_COUNT_ID:
|
||||
case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE:
|
||||
case POWER_SUPPLY_PROP_CC_STEP:
|
||||
case POWER_SUPPLY_PROP_CC_STEP_SEL:
|
||||
return 1;
|
||||
default:
|
||||
break;
|
||||
|
@ -3304,6 +3338,8 @@ static enum power_supply_property fg_psy_props[] = {
|
|||
POWER_SUPPLY_PROP_SOC_REPORTING_READY,
|
||||
POWER_SUPPLY_PROP_DEBUG_BATTERY,
|
||||
POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE,
|
||||
POWER_SUPPLY_PROP_CC_STEP,
|
||||
POWER_SUPPLY_PROP_CC_STEP_SEL,
|
||||
};
|
||||
|
||||
static const struct power_supply_desc fg_psy_desc = {
|
||||
|
|
Loading…
Add table
Reference in a new issue