Merge "power: qpnp-smb5: Modify the usage of INPUT_CURRENT_LIMIT in batt_psy"

This commit is contained in:
qctecmdr 2020-09-25 10:11:37 -07:00 • committed by Gerrit - the friendly Code Review server
commit 4e16ed70f3
3 changed files with 25 additions and 18 deletions

View file

@ -1218,8 +1218,7 @@ static int smb5_batt_get_prop(struct power_supply *psy,
rc = smblib_get_prop_batt_present(chg, pval);
break;
case POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT:
/* For battery, INPUT_CURRENT_LIMIT equates to INPUT_SUSPEND */
rc = smblib_get_prop_input_current_limit_usb(chg, pval);
rc = smblib_get_prop_input_suspend(chg, pval);
break;
case POWER_SUPPLY_PROP_CHARGE_TYPE:
rc = smblib_get_prop_batt_charge_type(chg, pval);
@ -1313,7 +1312,7 @@ static int smb5_batt_set_prop(struct power_supply *psy,
rc = smblib_set_prop_batt_status(chg, val);
break;
case POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT:
rc = smblib_set_prop_input_current_limit_usb(chg, val);
rc = smblib_set_prop_input_suspend(chg, val);
break;
case POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT:
rc = smblib_set_prop_system_temp_level(chg, val);

View file

@ -1971,10 +1971,12 @@ int smblib_vbus_regulator_is_enabled(struct regulator_dev *rdev)
/********************
* BATT PSY GETTERS *
********************/
int smblib_get_prop_input_current_limit_usb(struct smb_charger *chg,
int smblib_get_prop_input_suspend(struct smb_charger *chg,
union power_supply_propval *val)
{
val->intval = get_client_vote(chg->usb_icl_votable, USER_VOTER);
val->intval = (get_client_vote(chg->usb_icl_votable, USER_VOTER) == 0)
&& get_client_vote(chg->dc_suspend_votable, USER_VOTER);
return 0;
}
@ -2414,21 +2416,27 @@ int smblib_get_batt_current_now(struct smb_charger *chg,
/***********************
* BATTERY PSY SETTERS *
***********************/
int smblib_set_prop_input_current_limit_usb(struct smb_charger *chg,
const union power_supply_propval *val)
int smblib_set_prop_input_suspend(struct smb_charger *chg,
const union power_supply_propval *val)
{
int rc;
if (val->intval == 0)
rc = vote(chg->usb_icl_votable, USER_VOTER, true, 0);
else if (val->intval < 0)
rc = vote(chg->usb_icl_votable, USER_VOTER, false, 0);
else
rc = vote(chg->usb_icl_votable, USER_VOTER, true, val->intval);
/* vote 0mA when suspended */
rc = vote(chg->usb_icl_votable, USER_VOTER, (bool)val->intval, 0);
if (rc < 0) {
smblib_err(chg, "Couldn't vote to %s USB rc=%d\n",
(bool)val->intval ? "suspend" : "resume", rc);
return rc;
}
if (rc < 0)
smblib_err(chg, "Couldn't vote to set USB ICL to %d rc=%d\n",
val->intval, rc);
rc = vote(chg->dc_suspend_votable, USER_VOTER, (bool)val->intval, 0);
if (rc < 0) {
smblib_err(chg, "Couldn't vote to %s DC rc=%d\n",
(bool)val->intval ? "suspend" : "resume", rc);
return rc;
}
power_supply_changed(chg->batt_psy);
return rc;
}

View file

@ -673,7 +673,7 @@ irqreturn_t smb5_typec_or_rid_detection_change_irq_handler(int irq, void *data);
irqreturn_t smb5_temp_change_irq_handler(int irq, void *data);
irqreturn_t smb5_usbin_ov_irq_handler(int irq, void *data);
irqreturn_t smb5_sdam_sts_change_irq_handler(int irq, void *data);
int smblib_get_prop_input_current_limit_usb(struct smb_charger *chg,
int smblib_get_prop_input_suspend(struct smb_charger *chg,
union power_supply_propval *val);
int smblib_get_prop_batt_present(struct smb_charger *chg,
union power_supply_propval *val);
@ -697,7 +697,7 @@ int smblib_get_prop_input_current_limited(struct smb_charger *chg,
int *val);
int smblib_get_prop_batt_iterm(struct smb_charger *chg,
union power_supply_propval *val);
int smblib_set_prop_input_current_limit_usb(struct smb_charger *chg,
int smblib_set_prop_input_suspend(struct smb_charger *chg,
const union power_supply_propval *val);
int smblib_set_prop_batt_capacity(struct smb_charger *chg,
const union power_supply_propval *val);