Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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 <xu.yang_2@nxp.com>
Acked-by: Peter Chen <peter.chen@kernel.org>
Link: https://lore.kernel.org/r/20230627110353.1879477-1-xu.yang_2@nxp.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Xu Yang and committed by
Greg Kroah-Hartman
b7a62611 7713aaf4

+26 -2
+16 -2
drivers/usb/chipidea/ci.h
··· 281 281 return -ENXIO; 282 282 283 283 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 + 286 297 return ret; 287 298 } 288 299 ··· 307 296 ci->role = CI_ROLE_END; 308 297 309 298 ci->roles[role]->stop(ci); 299 + 300 + if (ci->usb_phy) 301 + usb_phy_set_event(ci->usb_phy, USB_EVENT_NONE); 310 302 } 311 303 312 304 static inline enum usb_role ci_role_to_usb_role(struct ci_hdrc *ci)
+10
drivers/usb/chipidea/udc.c
··· 1718 1718 ret = ci->platdata->notify_event(ci, 1719 1719 CI_HDRC_CONTROLLER_VBUS_EVENT); 1720 1720 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 + 1721 1728 if (ci->driver) 1722 1729 ci_hdrc_gadget_connect(_gadget, is_active); 1723 1730 ··· 2041 2034 if (USBi_PCI & intr) { 2042 2035 ci->gadget.speed = hw_port_is_high_speed(ci) ? 2043 2036 USB_SPEED_HIGH : USB_SPEED_FULL; 2037 + if (ci->usb_phy) 2038 + usb_phy_set_event(ci->usb_phy, 2039 + USB_EVENT_ENUMERATED); 2044 2040 if (ci->suspended) { 2045 2041 if (ci->driver->resume) { 2046 2042 spin_unlock(&ci->lock);