Merge "smb-lib: allow hvdcp if pd is disabled"
This commit is contained in:
commit
bc51bf2f0c
1 changed files with 25 additions and 9 deletions
|
@ -2695,17 +2695,13 @@ int smblib_set_prop_pd_voltage_max(struct smb_charger *chg,
|
|||
return rc;
|
||||
}
|
||||
|
||||
int smblib_set_prop_pd_active(struct smb_charger *chg,
|
||||
const union power_supply_propval *val)
|
||||
static int __smblib_set_prop_pd_active(struct smb_charger *chg, bool pd_active)
|
||||
{
|
||||
int rc;
|
||||
bool orientation, sink_attached, hvdcp;
|
||||
u8 stat;
|
||||
|
||||
if (!get_effective_result(chg->pd_allowed_votable))
|
||||
return -EINVAL;
|
||||
|
||||
chg->pd_active = val->intval;
|
||||
chg->pd_active = pd_active;
|
||||
if (chg->pd_active) {
|
||||
vote(chg->apsd_disable_votable, PD_VOTER, true, 0);
|
||||
vote(chg->pd_allowed_votable, PD_VOTER, true, 0);
|
||||
|
@ -2793,6 +2789,15 @@ int smblib_set_prop_pd_active(struct smb_charger *chg,
|
|||
return rc;
|
||||
}
|
||||
|
||||
int smblib_set_prop_pd_active(struct smb_charger *chg,
|
||||
const union power_supply_propval *val)
|
||||
{
|
||||
if (!get_effective_result(chg->pd_allowed_votable))
|
||||
return -EINVAL;
|
||||
|
||||
return __smblib_set_prop_pd_active(chg, val->intval);
|
||||
}
|
||||
|
||||
int smblib_set_prop_ship_mode(struct smb_charger *chg,
|
||||
const union power_supply_propval *val)
|
||||
{
|
||||
|
@ -3544,6 +3549,13 @@ static void smblib_handle_hvdcp_check_timeout(struct smb_charger *chg,
|
|||
/* enforce DCP ICL if specified */
|
||||
vote(chg->usb_icl_votable, DCP_VOTER,
|
||||
chg->dcp_icl_ua != -EINVAL, chg->dcp_icl_ua);
|
||||
|
||||
/*
|
||||
* if pd is not allowed, then set pd_active = false right here,
|
||||
* so that it starts the hvdcp engine
|
||||
*/
|
||||
if (!get_effective_result(chg->pd_allowed_votable))
|
||||
__smblib_set_prop_pd_active(chg, 0);
|
||||
}
|
||||
|
||||
smblib_dbg(chg, PR_INTERRUPT, "IRQ: smblib_handle_hvdcp_check_timeout %s\n",
|
||||
|
@ -4188,7 +4200,7 @@ irqreturn_t smblib_handle_usb_typec_change(int irq, void *data)
|
|||
|
||||
if (chg->cc2_detach_wa_active || chg->typec_en_dis_active ||
|
||||
chg->try_sink_active) {
|
||||
smblib_dbg(chg, PR_INTERRUPT, "Ignoring since %s active\n",
|
||||
smblib_dbg(chg, PR_MISC | PR_INTERRUPT, "Ignoring since %s active\n",
|
||||
chg->cc2_detach_wa_active ?
|
||||
"cc2_detach_wa" : "typec_en_dis");
|
||||
return IRQ_HANDLED;
|
||||
|
@ -4699,7 +4711,9 @@ static void smblib_legacy_detection_work(struct work_struct *work)
|
|||
smblib_err(chg, "Couldn't disable type-c rc=%d\n", rc);
|
||||
|
||||
/* wait for the adapter to turn off VBUS */
|
||||
msleep(500);
|
||||
msleep(1000);
|
||||
|
||||
smblib_dbg(chg, PR_MISC, "legacy workaround enabling typec\n");
|
||||
|
||||
rc = smblib_masked_write(chg,
|
||||
TYPE_C_INTRPT_ENB_SOFTWARE_CTRL_REG,
|
||||
|
@ -4708,7 +4722,7 @@ static void smblib_legacy_detection_work(struct work_struct *work)
|
|||
smblib_err(chg, "Couldn't enable type-c rc=%d\n", rc);
|
||||
|
||||
/* wait for type-c detection to complete */
|
||||
msleep(100);
|
||||
msleep(400);
|
||||
|
||||
rc = smblib_read(chg, TYPE_C_STATUS_5_REG, &stat);
|
||||
if (rc < 0) {
|
||||
|
@ -4720,6 +4734,8 @@ static void smblib_legacy_detection_work(struct work_struct *work)
|
|||
vote(chg->usb_icl_votable, LEGACY_UNKNOWN_VOTER, false, 0);
|
||||
legacy = stat & TYPEC_LEGACY_CABLE_STATUS_BIT;
|
||||
rp_high = chg->typec_mode == POWER_SUPPLY_TYPEC_SOURCE_HIGH;
|
||||
smblib_dbg(chg, PR_MISC, "legacy workaround done legacy = %d rp_high = %d\n",
|
||||
legacy, rp_high);
|
||||
if (!legacy || !rp_high)
|
||||
vote(chg->hvdcp_disable_votable_indirect, VBUS_CC_SHORT_VOTER,
|
||||
false, 0);
|
||||
|
|
Loading…
Add table
Reference in a new issue