MLK-13308-1 usb: chipidea: udc: add USB PHY event
authorPeter Chen <peter.chen@nxp.com>
Tue, 18 Oct 2016 08:32:04 +0000 (16:32 +0800)
committerNitin Garg <nitin.garg@nxp.com>
Mon, 19 Mar 2018 19:52:27 +0000 (14:52 -0500)
Add USB PHY event for below situation:
- vbus connect
- vbus disconnect
- gadget driver is enumerated

USB PHY driver can get the last event after above situation
occurs.

Signed-off-by: Peter Chen <peter.chen@nxp.com>
drivers/usb/chipidea/udc.c

index 83c8aac..5b4f92c 100644 (file)
@@ -1587,6 +1587,13 @@ static int ci_udc_vbus_session(struct usb_gadget *_gadget, int is_active)
        /* Charger Detection */
        ci_usb_charger_connect(ci, is_active);
 
+       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 (gadget_ready)
                ci_hdrc_gadget_connect(_gadget, is_active);
 
@@ -1882,6 +1889,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 && ci->driver->resume) {
                                spin_unlock(&ci->lock);
                                ci->driver->resume(&ci->gadget);