Merge "qpnp-smb2: Fix QC_PULSE_COUNT reading logic"

This commit is contained in:
Linux Build Service Account 2017-06-19 16:41:59 -07:00 committed by Gerrit - the friendly Code Review server
commit a34722136d

View file

@ -737,7 +737,7 @@ int smblib_rerun_apsd_if_required(struct smb_charger *chg)
return 0;
}
static int smblib_get_pulse_cnt(struct smb_charger *chg, int *count)
static int smblib_get_hw_pulse_cnt(struct smb_charger *chg, int *count)
{
int rc;
u8 val[2];
@ -771,6 +771,24 @@ static int smblib_get_pulse_cnt(struct smb_charger *chg, int *count)
return 0;
}
static int smblib_get_pulse_cnt(struct smb_charger *chg, int *count)
{
int rc;
/* Use software based pulse count if HW INOV is disabled */
if (get_effective_result(chg->hvdcp_hw_inov_dis_votable) > 0) {
*count = chg->pulse_cnt;
return 0;
}
/* Use h/w pulse count if autonomous mode is enabled */
rc = smblib_get_hw_pulse_cnt(chg, count);
if (rc < 0)
smblib_err(chg, "failed to read h/w pulse count rc=%d\n", rc);
return rc;
}
#define USBIN_25MA 25000
#define USBIN_100MA 100000
#define USBIN_150MA 150000
@ -1127,7 +1145,7 @@ static int smblib_hvdcp_hw_inov_dis_vote_callback(struct votable *votable,
* the pulse count register get zeroed when autonomous mode is
* disabled. Track that in variables before disabling
*/
rc = smblib_get_pulse_cnt(chg, &chg->pulse_cnt);
rc = smblib_get_hw_pulse_cnt(chg, &chg->pulse_cnt);
if (rc < 0) {
pr_err("failed to read QC_PULSE_COUNT_STATUS_REG rc=%d\n",
rc);
@ -2303,7 +2321,6 @@ int smblib_get_prop_input_voltage_settled(struct smb_charger *chg,
{
const struct apsd_result *apsd_result = smblib_get_apsd_result(chg);
int rc, pulses;
u8 stat;
val->intval = MICRO_5V;
if (apsd_result == NULL) {
@ -2313,13 +2330,12 @@ int smblib_get_prop_input_voltage_settled(struct smb_charger *chg,
switch (apsd_result->pst) {
case POWER_SUPPLY_TYPE_USB_HVDCP_3:
rc = smblib_read(chg, QC_PULSE_COUNT_STATUS_REG, &stat);
rc = smblib_get_pulse_cnt(chg, &pulses);
if (rc < 0) {
smblib_err(chg,
"Couldn't read QC_PULSE_COUNT rc=%d\n", rc);
return 0;
}
pulses = (stat & QC_PULSE_COUNT_MASK);
val->intval = MICRO_5V + HVDCP3_STEP_UV * pulses;
break;
default:
@ -3296,13 +3312,12 @@ static void smblib_hvdcp_adaptive_voltage_change(struct smb_charger *chg)
}
if (chg->real_charger_type == POWER_SUPPLY_TYPE_USB_HVDCP_3) {
rc = smblib_read(chg, QC_PULSE_COUNT_STATUS_REG, &stat);
rc = smblib_get_pulse_cnt(chg, &pulses);
if (rc < 0) {
smblib_err(chg,
"Couldn't read QC_PULSE_COUNT rc=%d\n", rc);
return;
}
pulses = (stat & QC_PULSE_COUNT_MASK);
if (pulses < QC3_PULSES_FOR_6V)
smblib_set_opt_freq_buck(chg,