[PATCH 3/3] MLK-14285-2 usb: chipidea: set mode for usb phy driver

From: Li Jun
Date: Tue Apr 11 2017 - 17:38:48 EST


After enters one specific role, notify usb phy driver.

Signed-off-by: Li Jun <jun.li@xxxxxxx>
(cherry picked from commit d3aa2a13f4e47bc7fae7f2eee1e86291d7513312)
---
drivers/usb/chipidea/ci.h | 21 ++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h
index 99440baa6458..9d7ba902246d 100644
--- a/drivers/usb/chipidea/ci.h
+++ b/drivers/usb/chipidea/ci.h
@@ -274,9 +274,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,
+ CUR_USB_MODE_HOST);
+ else
+ usb_phy_set_mode(ci->usb_phy,
+ CUR_USB_MODE_DEVICE);
+ }
+
+ return 0;
}

static inline void ci_role_stop(struct ci_hdrc *ci)
@@ -289,6 +301,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, CUR_USB_MODE_NONE);
}

static inline enum usb_role ci_role_to_usb_role(struct ci_hdrc *ci)


Francesco