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

Commit 00adcfcb authored by Jack Pham's avatar Jack Pham
Browse files

usb: pd: Keep PROP_PR_SWAP set during ERROR_RECOVERY



Since ErrorRecovery handling requires a spoof disconnect, the
charger driver needs to avoid immediately reapplying the
terminations. Re-use the PROP_PR_SWAP property which ignores
the disconnect. After the 25ms delay, policy engine will
explicitly reset back to DRP.

Also remove the transition to ErrorRecovery from PE_SNK_DISCOVERY
as it is removed in V1.3 of the PD 2.0 specification.

Change-Id: I41f1da293208b6813dfb540a123ee84ac35b4a68
Signed-off-by: default avatarJack Pham <jackp@codeaurora.org>
parent ed97270b
Loading
Loading
Loading
Loading
+4 −16
Original line number Diff line number Diff line
@@ -724,9 +724,6 @@ static void usbpd_set_state(struct usbpd *pd, enum usbpd_state next_state)
	switch (next_state) {
	case PE_ERROR_RECOVERY: /* perform hard disconnect/reconnect */
		pd->in_pr_swap = false;
		val.intval = 0;
		power_supply_set_property(pd->usb_psy,
				POWER_SUPPLY_PROP_PR_SWAP, &val);
		pd->current_pr = PR_NONE;
		set_power_role(pd, PR_NONE);
		pd->typec_mode = POWER_SUPPLY_TYPEC_NONE;
@@ -1577,10 +1574,6 @@ static void usbpd_sm(struct work_struct *w)
		memset(&pd->received_pdos, 0, sizeof(pd->received_pdos));
		rx_msg_cleanup(pd);

		val.intval = 0;
		power_supply_set_property(pd->usb_psy,
				POWER_SUPPLY_PROP_PR_SWAP, &val);

		power_supply_set_property(pd->usb_psy,
				POWER_SUPPLY_PROP_PD_IN_HARD_RESET, &val);

@@ -1611,6 +1604,10 @@ static void usbpd_sm(struct work_struct *w)
			usleep_range(ERROR_RECOVERY_TIME * USEC_PER_MSEC,
				(ERROR_RECOVERY_TIME + 5) * USEC_PER_MSEC);

		val.intval = 0;
		power_supply_set_property(pd->usb_psy,
				POWER_SUPPLY_PROP_PR_SWAP, &val);

		/* set due to dual_role class "mode" change */
		if (pd->forced_pr != POWER_SUPPLY_TYPEC_PR_NONE)
			val.intval = pd->forced_pr;
@@ -1938,15 +1935,6 @@ static void usbpd_sm(struct work_struct *w)
					POWER_SUPPLY_PROP_PD_ACTIVE, &val);
		} else if (pd->hard_reset_count < 3) {
			usbpd_set_state(pd, PE_SNK_HARD_RESET);
		} else if (pd->pd_connected) {
			usbpd_info(&pd->dev, "Sink hard reset count exceeded, forcing reconnect\n");

			val.intval = 0;
			power_supply_set_property(pd->usb_psy,
					POWER_SUPPLY_PROP_PD_IN_HARD_RESET,
					&val);

			usbpd_set_state(pd, PE_ERROR_RECOVERY);
		} else {
			usbpd_dbg(&pd->dev, "Sink hard reset count exceeded, disabling PD\n");