Skip to content

Commit b7a6261

Browse files
Xu Yanggregkh
authored andcommitted
usb: chipidea: add USB PHY event
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: Xu Yang <[email protected]> Acked-by: Peter Chen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 7713aaf commit b7a6261

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

drivers/usb/chipidea/ci.h

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,19 @@ static inline int ci_role_start(struct ci_hdrc *ci, enum ci_role role)
281281
return -ENXIO;
282282

283283
ret = ci->roles[role]->start(ci);
284-
if (!ret)
285-
ci->role = role;
284+
if (ret)
285+
return ret;
286+
287+
ci->role = role;
288+
289+
if (ci->usb_phy) {
290+
if (role == CI_ROLE_HOST)
291+
usb_phy_set_event(ci->usb_phy, USB_EVENT_ID);
292+
else
293+
/* in device mode but vbus is invalid*/
294+
usb_phy_set_event(ci->usb_phy, USB_EVENT_NONE);
295+
}
296+
286297
return ret;
287298
}
288299

@@ -296,6 +307,9 @@ static inline void ci_role_stop(struct ci_hdrc *ci)
296307
ci->role = CI_ROLE_END;
297308

298309
ci->roles[role]->stop(ci);
310+
311+
if (ci->usb_phy)
312+
usb_phy_set_event(ci->usb_phy, USB_EVENT_NONE);
299313
}
300314

301315
static inline enum usb_role ci_role_to_usb_role(struct ci_hdrc *ci)

drivers/usb/chipidea/udc.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1718,6 +1718,13 @@ static int ci_udc_vbus_session(struct usb_gadget *_gadget, int is_active)
17181718
ret = ci->platdata->notify_event(ci,
17191719
CI_HDRC_CONTROLLER_VBUS_EVENT);
17201720

1721+
if (ci->usb_phy) {
1722+
if (is_active)
1723+
usb_phy_set_event(ci->usb_phy, USB_EVENT_VBUS);
1724+
else
1725+
usb_phy_set_event(ci->usb_phy, USB_EVENT_NONE);
1726+
}
1727+
17211728
if (ci->driver)
17221729
ci_hdrc_gadget_connect(_gadget, is_active);
17231730

@@ -2034,6 +2041,9 @@ static irqreturn_t udc_irq(struct ci_hdrc *ci)
20342041
if (USBi_PCI & intr) {
20352042
ci->gadget.speed = hw_port_is_high_speed(ci) ?
20362043
USB_SPEED_HIGH : USB_SPEED_FULL;
2044+
if (ci->usb_phy)
2045+
usb_phy_set_event(ci->usb_phy,
2046+
USB_EVENT_ENUMERATED);
20372047
if (ci->suspended) {
20382048
if (ci->driver->resume) {
20392049
spin_unlock(&ci->lock);

0 commit comments

Comments
 (0)