MLK-14285-2 usb: chipidea: set mode for usb phy driver
authorLi Jun <jun.li@nxp.com>
Tue, 11 Apr 2017 21:38:48 +0000 (05:38 +0800)
committerNitin Garg <nitin.garg@nxp.com>
Mon, 19 Mar 2018 20:21:55 +0000 (15:21 -0500)
After enters one specific role, notify usb phy driver.

Signed-off-by: Li Jun <jun.li@nxp.com>
(cherry picked from commit d3aa2a13f4e47bc7fae7f2eee1e86291d7513312)

drivers/usb/chipidea/ci.h

index 591536f..33c99e2 100644 (file)
@@ -289,9 +289,21 @@ static inline int ci_role_start(struct ci_hdrc *ci, enum ci_role role)
                return -ENXIO;
 
        ret = ci->roles[role]->start(ci);
-       if (!ret)
-               ci->role = role;
-       return ret;
+       if (ret)
+               return ret;
+
+       ci->role = role;
+
+       if (ci->usb_phy) {
+               if (role == CI_ROLE_HOST)
+                       usb_phy_set_mode(ci->usb_phy,
+                                       USB_MODE_HOST);
+               else
+                       usb_phy_set_mode(ci->usb_phy,
+                                       USB_MODE_DEVICE);
+       }
+
+       return 0;
 }
 
 static inline void ci_role_stop(struct ci_hdrc *ci)
@@ -304,6 +316,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_mode(ci->usb_phy, USB_MODE_NONE);
 }
 
 /**