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

Commit 95c95088 authored by Abhijeet Dharmapurikar's avatar Abhijeet Dharmapurikar Committed by Harry Yang
Browse files

qpnp-smb2: don't stomp over D+/D- during hard reset



Currently when we are in hard reset, the driver requests to remove
the float of D+/D- when VBUS drops and once VBUS is back, it requests
to float D+/D- again. This behaviour ends up stomping over D+/D- lines
leading to noncompliance with PD spec.

Fix it by ensuring we only run the CC2 workaround while VBUS dips
in hard reset.

Change-Id: I2bb9364b890b3a227dd3ea3e0a34a415b600e21a
Signed-off-by: default avatarAbhijeet Dharmapurikar <adharmap@codeaurora.org>
parent eecf558c
Loading
Loading
Loading
Loading
+21 −4
Original line number Diff line number Diff line
@@ -3158,12 +3158,28 @@ static void smblib_micro_usb_plugin(struct smb_charger *chg, bool vbus_rising)
	}
}

static void smblib_typec_usb_plugin(struct smb_charger *chg, bool vbus_rising)
void smblib_usb_plugin_hard_reset_locked(struct smb_charger *chg)
{
	int rc;
	u8 stat;
	bool vbus_rising;

	rc = smblib_read(chg, USBIN_BASE + INT_RT_STS_OFFSET, &stat);
	if (rc < 0) {
		smblib_err(chg, "Couldn't read USB_INT_RT_STS rc=%d\n", rc);
		return;
	}

	vbus_rising = (bool)(stat & USBIN_PLUGIN_RT_STS_BIT);

	if (vbus_rising)
		smblib_cc2_sink_removal_exit(chg);
	else
		smblib_cc2_sink_removal_enter(chg);

	power_supply_changed(chg->usb_psy);
	smblib_dbg(chg, PR_INTERRUPT, "IRQ: usbin-plugin %s\n",
					vbus_rising ? "attached" : "detached");
}

#define PL_DELAY_MS			30000
@@ -3222,8 +3238,6 @@ void smblib_usb_plugin_locked(struct smb_charger *chg)

	if (chg->micro_usb_mode)
		smblib_micro_usb_plugin(chg, vbus_rising);
	else
		smblib_typec_usb_plugin(chg, vbus_rising);

	power_supply_changed(chg->usb_psy);
	smblib_dbg(chg, PR_INTERRUPT, "IRQ: usbin-plugin %s\n",
@@ -3236,6 +3250,9 @@ irqreturn_t smblib_handle_usb_plugin(int irq, void *data)
	struct smb_charger *chg = irq_data->parent_data;

	mutex_lock(&chg->lock);
	if (chg->pd_hard_reset)
		smblib_usb_plugin_hard_reset_locked(chg);
	else
		smblib_usb_plugin_locked(chg);
	mutex_unlock(&chg->lock);
	return IRQ_HANDLED;