power: supply: Add support to report QC3+ adapter power rating

Report the QC3+ adapter power-rating via "power_now" in the usb
power-supply class.

Change-Id: I0d0e9a3e9d2f5d57f5e8696dea8f4e17a8f2df5f
Signed-off-by: Ashish Chavan <ashichav@codeaurora.org>
This commit is contained in:
Ashish Chavan 2021-03-23 17:37:02 +05:30
parent bb168a0f46
commit e033d8781c
3 changed files with 15 additions and 0 deletions

View File

@ -839,6 +839,7 @@ static enum power_supply_property smb5_usb_props[] = {
POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN,
POWER_SUPPLY_PROP_SCOPE,
POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT,
POWER_SUPPLY_PROP_POWER_NOW,
};
static int smb5_usb_get_prop(struct power_supply *psy,
@ -884,6 +885,13 @@ static int smb5_usb_get_prop(struct power_supply *psy,
val->intval = get_client_vote(chg->usb_icl_votable,
USB_PSY_VOTER);
break;
case POWER_SUPPLY_PROP_POWER_NOW:
/* Show power rating for QC3+ adapter. */
if (chg->real_charger_type == QTI_POWER_SUPPLY_TYPE_USB_HVDCP_3P5)
val->intval = chg->qc3p5_detected_mw;
else
rc = -ENODATA;
break;
default:
pr_err("get prop %d is not supported in usb\n", psp);
rc = -EINVAL;
@ -910,6 +918,9 @@ static int smb5_usb_set_prop(struct power_supply *psy,
case POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT:
rc = smblib_set_prop_sdp_current_max(chg, val->intval);
break;
case POWER_SUPPLY_PROP_POWER_NOW:
chg->qc3p5_detected_mw = val->intval;
break;
default:
pr_err("Set prop %d is not supported in usb psy\n",
psp);
@ -925,6 +936,7 @@ static int smb5_usb_prop_is_writeable(struct power_supply *psy,
{
switch (psp) {
case POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT:
case POWER_SUPPLY_PROP_POWER_NOW:
return 1;
default:
break;

View File

@ -1355,6 +1355,7 @@ static void smblib_uusb_removal(struct smb_charger *chg)
}
chg->qc3p5_detected = false;
chg->qc3p5_detected_mw = 0;
smblib_update_usb_type(chg);
}
@ -6319,6 +6320,7 @@ static void typec_src_removal(struct smb_charger *chg)
"Couldn't disable secondary charger rc=%d\n", rc);
chg->qc3p5_detected = false;
chg->qc3p5_detected_mw = 0;
typec_src_fault_condition_cfg(chg, false);
smblib_hvdcp_detect_try_enable(chg, false);
smblib_update_usb_type(chg);

View File

@ -593,6 +593,7 @@ struct smb_charger {
bool dpdm_enabled;
bool apsd_ext_timeout;
bool qc3p5_detected;
int qc3p5_detected_mw;
/* workaround flag */
int real_charger_type;