Skip to contentSkip to conversation

usb: chipidea: msm: Use USB PHY API to control PHY state

PATCH RESEND In review Ivan T. Ivanov 2 participants 3 messages Aug 15, 2014 – Aug 25, 2014

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 usb: chipidea: msm: Use USB PHY API to control PHY state

From: "Ivan T. Ivanov" <[email protected]>

PHY drivers keep track of the current state of the hardware, so don't change PHY settings under it.

---
 drivers/usb/chipidea/ci_hdrc_msm.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/usb/chipidea/ci_hdrc_msm.c +2 -7
index d72b9d2..81de834 100644
@@ -20,13 +20,11 @@
 static void ci_hdrc_msm_notify_event(struct ci_hdrc *ci, unsigned event)
 {
 	struct device *dev = ci->gadget.dev.parent;
-	int val;
 
 	switch (event) {
 	case CI_HDRC_CONTROLLER_RESET_EVENT:
 		dev_dbg(dev, "CI_HDRC_CONTROLLER_RESET_EVENT received\n");
-		writel(0, USB_AHBBURST);
-		writel(0, USB_AHBMODE);
+		usb_phy_init(ci->transceiver);
 		break;
 	case CI_HDRC_CONTROLLER_STOPPED_EVENT:
 		dev_dbg(dev, "CI_HDRC_CONTROLLER_STOPPED_EVENT received\n");
@@ -34,10 +32,7 @@ static void ci_hdrc_msm_notify_event(struct ci_hdrc *ci, unsigned event)
 		 * Put the transceiver in non-driving mode. Otherwise host
 		 * may not detect soft-disconnection.
 		 */
-		val = usb_phy_io_read(ci->transceiver, ULPI_FUNC_CTRL);
-		val &= ~ULPI_FUNC_CTRL_OPMODE_MASK;
-		val |= ULPI_FUNC_CTRL_OPMODE_NONDRIVING;
-		usb_phy_io_write(ci->transceiver, val, ULPI_FUNC_CTRL);
+		usb_phy_notify_disconnect(ci->transceiver, USB_SPEED_UNKNOWN);
 		break;
 	default:
 		dev_dbg(dev, "unknown ci_hdrc event\n");
Signature · 1 line
1.8.3.2
Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Ivan T. Ivanov

From: "Ivan T. Ivanov" <[email protected]>

PHY drivers keep track of the current state of the hardware, so don't change PHY settings under it.

looks correct to me from a PHY API perspective, so:

However, it doesn't look like msm_phy_init() is equivalent to the lines removes. Care to comment ?

Quoted 38 lines
---
 drivers/usb/chipidea/ci_hdrc_msm.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/usb/chipidea/ci_hdrc_msm.c +2 -7
index d72b9d2..81de834 100644
@@ -20,13 +20,11 @@
 static void ci_hdrc_msm_notify_event(struct ci_hdrc *ci, unsigned event)
 {
 	struct device *dev = ci->gadget.dev.parent;
-	int val;
 
 	switch (event) {
 	case CI_HDRC_CONTROLLER_RESET_EVENT:
 		dev_dbg(dev, "CI_HDRC_CONTROLLER_RESET_EVENT received\n");
-		writel(0, USB_AHBBURST);
-		writel(0, USB_AHBMODE);
+		usb_phy_init(ci->transceiver);
 		break;
 	case CI_HDRC_CONTROLLER_STOPPED_EVENT:
 		dev_dbg(dev, "CI_HDRC_CONTROLLER_STOPPED_EVENT received\n");
@@ -34,10 +32,7 @@ static void ci_hdrc_msm_notify_event(struct ci_hdrc *ci, unsigned event)
 		 * Put the transceiver in non-driving mode. Otherwise host
 		 * may not detect soft-disconnection.
 		 */
-		val = usb_phy_io_read(ci->transceiver, ULPI_FUNC_CTRL);
-		val &= ~ULPI_FUNC_CTRL_OPMODE_MASK;
-		val |= ULPI_FUNC_CTRL_OPMODE_NONDRIVING;
-		usb_phy_io_write(ci->transceiver, val, ULPI_FUNC_CTRL);
+		usb_phy_notify_disconnect(ci->transceiver, USB_SPEED_UNKNOWN);
 		break;
 	default:
 		dev_dbg(dev, "unknown ci_hdrc event\n");
Signature · 1 line
1.8.3.2
Signature · 1 line
balbi
#2 lore raw
Quoted 12 lines · Felipe Balbi
Quoted 6 lines · Ivan T. Ivanov

From: "Ivan T. Ivanov" <[email protected]>

PHY drivers keep track of the current state of the hardware, so don't change PHY settings under it.

looks correct to me from a PHY API perspective, so:

Thanks.

Quoted 3 lines

However, it doesn't look like msm_phy_init() is equivalent to the lines removes. Care to comment ?

What I have to actually do is just add phy_init(). No need to remove controller reinitialization. Tested and is working. Will post 2 new patches shortly.

Regards,
Ivan

Quoted 39 lines
Quoted 38 lines
---
 drivers/usb/chipidea/ci_hdrc_msm.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/usb/chipidea/ci_hdrc_msm.c +2 -7
index d72b9d2..81de834 100644
@@ -20,13 +20,11 @@
 static void ci_hdrc_msm_notify_event(struct ci_hdrc *ci, unsigned event)
 {
 	struct device *dev = ci->gadget.dev.parent;
-	int val;
 
 	switch (event) {
 	case CI_HDRC_CONTROLLER_RESET_EVENT:
 		dev_dbg(dev, "CI_HDRC_CONTROLLER_RESET_EVENT received\n");
-		writel(0, USB_AHBBURST);
-		writel(0, USB_AHBMODE);
+		usb_phy_init(ci->transceiver);
 		break;
 	case CI_HDRC_CONTROLLER_STOPPED_EVENT:
 		dev_dbg(dev, "CI_HDRC_CONTROLLER_STOPPED_EVENT received\n");
@@ -34,10 +32,7 @@ static void ci_hdrc_msm_notify_event(struct ci_hdrc *ci, unsigned event)
 		 * Put the transceiver in non-driving mode. Otherwise host
 		 * may not detect soft-disconnection.
 		 */
-		val = usb_phy_io_read(ci->transceiver, ULPI_FUNC_CTRL);
-		val &= ~ULPI_FUNC_CTRL_OPMODE_MASK;
-		val |= ULPI_FUNC_CTRL_OPMODE_NONDRIVING;
-		usb_phy_io_write(ci->transceiver, val, ULPI_FUNC_CTRL);
+		usb_phy_notify_disconnect(ci->transceiver, USB_SPEED_UNKNOWN);
 		break;
 	default:
 		dev_dbg(dev, "unknown ci_hdrc event\n");
Signature · 1 line
1.8.3.2