usb: dwc3: Add support to select maximum speed via extcon notification

Use extcon notification to select the maximum speed for host as well
as for peripheral mode. Notification handler sets maximum speed based
on the extcon cable state flag. This provides an option to start host
or peripheral in high speed only mode and leave ss phy suspended.

Change-Id: Ic48c661e68a293822d30cbd491e0fe6e46d385c9
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
Signed-off-by: Jack Pham <jackp@codeaurora.org>
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 65fe33b..7aa0c7d 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -191,6 +191,9 @@
 		return ret;
 	}
 
+	if (dwc->maximum_speed == USB_SPEED_HIGH)
+		goto generic_phy_init;
+
 	ret = usb_phy_init(dwc->usb3_phy);
 	if (ret == -EBUSY) {
 		/*
@@ -203,6 +206,8 @@
 				__func__, ret);
 		return ret;
 	}
+
+generic_phy_init:
 	ret = phy_init(dwc->usb2_generic_phy);
 	if (ret < 0)
 		return ret;
@@ -226,7 +231,9 @@
 
 	/* Reset PHYs */
 	usb_phy_reset(dwc->usb2_phy);
-	usb_phy_reset(dwc->usb3_phy);
+
+	if (dwc->maximum_speed == USB_SPEED_SUPER)
+		usb_phy_reset(dwc->usb3_phy);
 
 	/* Initialize PHYs */
 	ret = dwc3_init_usb_phys(dwc);