usb: cdns3: drd: call PHY .set_mode accordingly
authorPeter Chen <peter.chen@nxp.com>
Tue, 1 Sep 2020 02:33:51 +0000 (10:33 +0800)
committerFelipe Balbi <balbi@kernel.org>
Fri, 2 Oct 2020 06:57:40 +0000 (09:57 +0300)
Some PHYs may need to enter related mode, and do some settings.

Signed-off-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Felipe Balbi <balbi@kernel.org>
drivers/usb/cdns3/drd.c

index fcd295f566b2dbf2ba7c8e135e0c3a5da7a636bf..38ccd29e4cdef1e0dda34fc13cb4bb774d9642ca 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/delay.h>
 #include <linux/iopoll.h>
 #include <linux/usb/otg.h>
+#include <linux/phy/phy.h>
 
 #include "gadget.h"
 #include "drd.h"
@@ -157,6 +158,7 @@ int cdns3_drd_host_on(struct cdns3 *cdns)
        if (ret)
                dev_err(cdns->dev, "timeout waiting for xhci_ready\n");
 
+       phy_set_mode(cdns->usb3_phy, PHY_MODE_USB_HOST);
        return ret;
 }
 
@@ -176,6 +178,7 @@ void cdns3_drd_host_off(struct cdns3 *cdns)
        readl_poll_timeout_atomic(&cdns->otg_regs->state, val,
                                  !(val & OTGSTATE_HOST_STATE_MASK),
                                  1, 2000000);
+       phy_set_mode(cdns->usb3_phy, PHY_MODE_INVALID);
 }
 
 /**
@@ -202,6 +205,7 @@ int cdns3_drd_gadget_on(struct cdns3 *cdns)
                return ret;
        }
 
+       phy_set_mode(cdns->usb3_phy, PHY_MODE_USB_DEVICE);
        return 0;
 }
 
@@ -225,6 +229,7 @@ void cdns3_drd_gadget_off(struct cdns3 *cdns)
        readl_poll_timeout_atomic(&cdns->otg_regs->state, val,
                                  !(val & OTGSTATE_DEV_STATE_MASK),
                                  1, 2000000);
+       phy_set_mode(cdns->usb3_phy, PHY_MODE_INVALID);
 }
 
 /**