Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ed8f4e5c authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "smb-lib: allow hvdcp if pd is disabled"

parents 4259de5b bb4d39d7
Loading
Loading
Loading
Loading
+25 −9
Original line number Original line Diff line number Diff line
@@ -2740,17 +2740,13 @@ int smblib_set_prop_pd_voltage_max(struct smb_charger *chg,
	return rc;
	return rc;
}
}


int smblib_set_prop_pd_active(struct smb_charger *chg,
static int __smblib_set_prop_pd_active(struct smb_charger *chg, bool pd_active)
			      const union power_supply_propval *val)
{
{
	int rc;
	int rc;
	bool orientation, sink_attached, hvdcp;
	bool orientation, sink_attached, hvdcp;
	u8 stat;
	u8 stat;


	if (!get_effective_result(chg->pd_allowed_votable))
	chg->pd_active = pd_active;
		return -EINVAL;

	chg->pd_active = val->intval;
	if (chg->pd_active) {
	if (chg->pd_active) {
		vote(chg->apsd_disable_votable, PD_VOTER, true, 0);
		vote(chg->apsd_disable_votable, PD_VOTER, true, 0);
		vote(chg->pd_allowed_votable, PD_VOTER, true, 0);
		vote(chg->pd_allowed_votable, PD_VOTER, true, 0);
@@ -2838,6 +2834,15 @@ int smblib_set_prop_pd_active(struct smb_charger *chg,
	return rc;
	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,
int smblib_set_prop_ship_mode(struct smb_charger *chg,
				const union power_supply_propval *val)
				const union power_supply_propval *val)
{
{
@@ -3598,6 +3603,13 @@ static void smblib_handle_hvdcp_check_timeout(struct smb_charger *chg,
			/* enforce DCP ICL if specified */
			/* enforce DCP ICL if specified */
			vote(chg->usb_icl_votable, DCP_VOTER,
			vote(chg->usb_icl_votable, DCP_VOTER,
				chg->dcp_icl_ua != -EINVAL, chg->dcp_icl_ua);
				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",
	smblib_dbg(chg, PR_INTERRUPT, "IRQ: smblib_handle_hvdcp_check_timeout %s\n",
@@ -4261,7 +4273,7 @@ irqreturn_t smblib_handle_usb_typec_change(int irq, void *data)


	if (chg->cc2_detach_wa_active || chg->typec_en_dis_active ||
	if (chg->cc2_detach_wa_active || chg->typec_en_dis_active ||
					 chg->try_sink_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 ?
			chg->cc2_detach_wa_active ?
			"cc2_detach_wa" : "typec_en_dis");
			"cc2_detach_wa" : "typec_en_dis");
		return IRQ_HANDLED;
		return IRQ_HANDLED;
@@ -4786,7 +4798,9 @@ static void smblib_legacy_detection_work(struct work_struct *work)
		smblib_err(chg, "Couldn't disable type-c rc=%d\n", rc);
		smblib_err(chg, "Couldn't disable type-c rc=%d\n", rc);


	/* wait for the adapter to turn off VBUS */
	/* 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,
	rc = smblib_masked_write(chg,
				TYPE_C_INTRPT_ENB_SOFTWARE_CTRL_REG,
				TYPE_C_INTRPT_ENB_SOFTWARE_CTRL_REG,
@@ -4795,7 +4809,7 @@ static void smblib_legacy_detection_work(struct work_struct *work)
		smblib_err(chg, "Couldn't enable type-c rc=%d\n", rc);
		smblib_err(chg, "Couldn't enable type-c rc=%d\n", rc);


	/* wait for type-c detection to complete */
	/* wait for type-c detection to complete */
	msleep(100);
	msleep(400);


	rc = smblib_read(chg, TYPE_C_STATUS_5_REG, &stat);
	rc = smblib_read(chg, TYPE_C_STATUS_5_REG, &stat);
	if (rc < 0) {
	if (rc < 0) {
@@ -4807,6 +4821,8 @@ static void smblib_legacy_detection_work(struct work_struct *work)
	vote(chg->usb_icl_votable, LEGACY_UNKNOWN_VOTER, false, 0);
	vote(chg->usb_icl_votable, LEGACY_UNKNOWN_VOTER, false, 0);
	legacy = stat & TYPEC_LEGACY_CABLE_STATUS_BIT;
	legacy = stat & TYPEC_LEGACY_CABLE_STATUS_BIT;
	rp_high = chg->typec_mode == POWER_SUPPLY_TYPEC_SOURCE_HIGH;
	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)
	if (!legacy || !rp_high)
		vote(chg->hvdcp_disable_votable_indirect, VBUS_CC_SHORT_VOTER,
		vote(chg->hvdcp_disable_votable_indirect, VBUS_CC_SHORT_VOTER,
								false, 0);
								false, 0);