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

Commit 4eb4ad45 authored by Xu Yang's avatar Xu Yang Committed by Greg Kroah-Hartman
Browse files

usb: chipidea: add USB PHY event



[ Upstream commit b7a62611fab72e585c729a7fcf666aa9c4144214 ]

Add USB PHY event for below situation:
- usb role changed
- vbus connect
- vbus disconnect
- gadget driver is enumerated

USB PHY driver can get the last event after above situation occurs
and deal with different situations.

Signed-off-by: default avatarXu Yang <xu.yang_2@nxp.com>
Acked-by: default avatarPeter Chen <peter.chen@kernel.org>
Link: https://lore.kernel.org/r/20230627110353.1879477-1-xu.yang_2@nxp.com


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent f2b6a88c
Loading
Loading
Loading
Loading
+16 −2
Original line number Diff line number Diff line
@@ -277,8 +277,19 @@ static inline int ci_role_start(struct ci_hdrc *ci, enum ci_role role)
		return -ENXIO;

	ret = ci->roles[role]->start(ci);
	if (!ret)
	if (ret)
		return ret;

	ci->role = role;

	if (ci->usb_phy) {
		if (role == CI_ROLE_HOST)
			usb_phy_set_event(ci->usb_phy, USB_EVENT_ID);
		else
			/* in device mode but vbus is invalid*/
			usb_phy_set_event(ci->usb_phy, USB_EVENT_NONE);
	}

	return ret;
}

@@ -292,6 +303,9 @@ static inline void ci_role_stop(struct ci_hdrc *ci)
	ci->role = CI_ROLE_END;

	ci->roles[role]->stop(ci);

	if (ci->usb_phy)
		usb_phy_set_event(ci->usb_phy, USB_EVENT_NONE);
}

static inline enum usb_role ci_role_to_usb_role(struct ci_hdrc *ci)
+10 −0
Original line number Diff line number Diff line
@@ -1583,6 +1583,13 @@ static int ci_udc_vbus_session(struct usb_gadget *_gadget, int is_active)
		ret = ci->platdata->notify_event(ci,
				CI_HDRC_CONTROLLER_VBUS_EVENT);

	if (ci->usb_phy) {
		if (is_active)
			usb_phy_set_event(ci->usb_phy, USB_EVENT_VBUS);
		else
			usb_phy_set_event(ci->usb_phy, USB_EVENT_NONE);
	}

	if (ci->driver)
		ci_hdrc_gadget_connect(_gadget, is_active);

@@ -1898,6 +1905,9 @@ static irqreturn_t udc_irq(struct ci_hdrc *ci)
		if (USBi_PCI & intr) {
			ci->gadget.speed = hw_port_is_high_speed(ci) ?
				USB_SPEED_HIGH : USB_SPEED_FULL;
			if (ci->usb_phy)
				usb_phy_set_event(ci->usb_phy,
					USB_EVENT_ENUMERATED);
			if (ci->suspended) {
				if (ci->driver->resume) {
					spin_unlock(&ci->lock);