qpnp-smb2: Support faking input current limited state

Support faking input current limited state. This is very helpful
in testing/debugging the software based vbus changing algorithms.

Change-Id: I7cf548c94397ee680c9d65343c49ec7b16873e88
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
This commit is contained in:
Abhijeet Dharmapurikar 2017-05-01 20:00:25 -07:00
parent 15a68a61bd
commit 9d0fdc3738
3 changed files with 20 additions and 0 deletions

View file

@ -1166,6 +1166,9 @@ static int smb2_batt_set_prop(struct power_supply *psy,
case POWER_SUPPLY_PROP_DP_DM:
rc = smblib_dp_dm(chg, val->intval);
break;
case POWER_SUPPLY_PROP_INPUT_CURRENT_LIMITED:
rc = smblib_set_prop_input_current_limited(chg, val);
break;
default:
rc = -EINVAL;
}
@ -1183,6 +1186,7 @@ static int smb2_batt_prop_is_writeable(struct power_supply *psy,
case POWER_SUPPLY_PROP_PARALLEL_DISABLE:
case POWER_SUPPLY_PROP_DP_DM:
case POWER_SUPPLY_PROP_RERUN_AICL:
case POWER_SUPPLY_PROP_INPUT_CURRENT_LIMITED:
return 1;
default:
break;

View file

@ -1707,6 +1707,11 @@ int smblib_get_prop_input_current_limited(struct smb_charger *chg,
u8 stat;
int rc;
if (chg->fake_input_current_limited >= 0) {
val->intval = chg->fake_input_current_limited;
return 0;
}
rc = smblib_read(chg, AICL_STATUS_REG, &stat);
if (rc < 0) {
smblib_err(chg, "Couldn't read AICL_STATUS rc=%d\n", rc);
@ -1898,6 +1903,13 @@ int smblib_set_prop_charge_qnovo_enable(struct smb_charger *chg,
return rc;
}
int smblib_set_prop_input_current_limited(struct smb_charger *chg,
const union power_supply_propval *val)
{
chg->fake_input_current_limited = val->intval;
return 0;
}
int smblib_rerun_aicl(struct smb_charger *chg)
{
int rc, settled_icl_ua;
@ -4471,6 +4483,7 @@ int smblib_init(struct smb_charger *chg)
INIT_DELAYED_WORK(&chg->pl_enable_work, smblib_pl_enable_work);
INIT_WORK(&chg->legacy_detection_work, smblib_legacy_detection_work);
chg->fake_capacity = -EINVAL;
chg->fake_input_current_limited = -EINVAL;
switch (chg->mode) {
case PARALLEL_MASTER:

View file

@ -318,6 +318,7 @@ struct smb_charger {
bool typec_present;
u8 typec_status[5];
bool typec_legacy_valid;
int fake_input_current_limited;
/* workaround flag */
u32 wa_flags;
@ -421,6 +422,8 @@ int smblib_set_prop_batt_capacity(struct smb_charger *chg,
const union power_supply_propval *val);
int smblib_set_prop_system_temp_level(struct smb_charger *chg,
const union power_supply_propval *val);
int smblib_set_prop_input_current_limited(struct smb_charger *chg,
const union power_supply_propval *val);
int smblib_get_prop_dc_present(struct smb_charger *chg,
union power_supply_propval *val);