power: smb5-lib: Report the CURRENT_MAX as 1A in CC-mode

Userspace uses the CURRENT_MAX power-supply property to
determine the strength of the charger. In CC-mode of operation
the main-charger's ICL is configured low and hence the
CURRENT_MAX reported is lower attributing it as a weak-charger.
Fix this by reporting a fixed value of 1A during CC-mode.

Change-Id: Id8745b54c3909d01df69376a823396ea4c94eeb1
Signed-off-by: Anirudh Ghayal <aghayal@codeaurora.org>
This commit is contained in:
Anirudh Ghayal 2020-06-30 15:14:17 +05:30 • committed by Gerrit - the friendly Code Review server
commit fa7a9cba6e
3 changed files with 22 additions and 1 deletions

View file

@ -860,7 +860,7 @@ static int smb5_usb_get_prop(struct power_supply *psy,
rc = smblib_get_prop_usb_current_now(chg, val);
break;
case POWER_SUPPLY_PROP_CURRENT_MAX:
rc = smblib_get_prop_input_current_settled(chg, val);
rc = smblib_get_prop_input_current_max(chg, val);
break;
case POWER_SUPPLY_PROP_TYPE:
val->intval = POWER_SUPPLY_TYPE_USB_PD;

View file

@ -1410,6 +1410,7 @@ static int smblib_get_pulse_cnt(struct smb_charger *chg, int *count)
#define USBIN_150MA 150000
#define USBIN_500MA 500000
#define USBIN_900MA 900000
#define USBIN_1000MA 1000000
static int set_sdp_current(struct smb_charger *chg, int icl_ua)
{
int rc;
@ -4044,6 +4045,24 @@ int smblib_get_prop_input_current_settled(struct smb_charger *chg,
return smblib_get_charge_param(chg, &chg->param.icl_stat, &val->intval);
}
int smblib_get_prop_input_current_max(struct smb_charger *chg,
union power_supply_propval *val)
{
int icl_ua = 0, rc;
rc = smblib_get_charge_param(chg, &chg->param.usb_icl, &icl_ua);
if (rc < 0)
return rc;
if (is_override_vote_enabled_locked(chg->usb_icl_votable) &&
icl_ua < USBIN_1000MA) {
val->intval = USBIN_1000MA;
return 0;
}
return smblib_get_charge_param(chg, &chg->param.icl_stat, &val->intval);
}
int smblib_get_prop_input_voltage_settled(struct smb_charger *chg,
int *val)
{

View file

@ -765,6 +765,8 @@ int smblib_get_die_health(struct smb_charger *chg,
int *val);
int smblib_get_prop_smb_health(struct smb_charger *chg);
int smblib_get_prop_connector_health(struct smb_charger *chg);
int smblib_get_prop_input_current_max(struct smb_charger *chg,
union power_supply_propval *val);
int smblib_set_prop_thermal_overheat(struct smb_charger *chg,
int therm_overheat);
int smblib_get_skin_temp_status(struct smb_charger *chg);