]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
usb: phy: mxs: keep USBPHY2's clk always on
authorXu Yang <xu.yang_2@nxp.com>
Fri, 26 Jul 2024 11:32:03 +0000 (19:32 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 13 Aug 2024 08:32:08 +0000 (10:32 +0200)
IP require keep USBPHY2's clk always on, so USBPHY2 (PLL7) power can be
controlled by suspend signal. USB remote wakeup needs resume signal be
sent out as soon as possible to match USB requirements.

Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
Reviewed-by: Peter Chen <peter.chen@kernel.org>
Link: https://lore.kernel.org/r/20240726113207.3393247-2-xu.yang_2@nxp.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/phy/phy-mxs-usb.c

index d9d29f0b37de93aa90fa03d8c03033dc4109d361..e172af75f602db5d237ecdc709866e038270c01f 100644 (file)
 #define MXS_PHY_TX_D_CAL_MIN                   79
 #define MXS_PHY_TX_D_CAL_MAX                   119
 
+/*
+ * At imx6q/6sl/6sx, the PHY2's clock is controlled by hardware directly,
+ * eg, according to PHY's suspend status. In these PHYs, we only need to
+ * open the clock at the initialization and close it at its shutdown routine.
+ * These PHYs can send resume signal without software interfere if not
+ * gate clock.
+ */
+#define MXS_PHY_HARDWARE_CONTROL_PHY2_CLK      BIT(4)
+
 struct mxs_phy_data {
        unsigned int flags;
 };
@@ -161,12 +170,14 @@ static const struct mxs_phy_data imx23_phy_data = {
 static const struct mxs_phy_data imx6q_phy_data = {
        .flags = MXS_PHY_SENDING_SOF_TOO_FAST |
                MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS |
-               MXS_PHY_NEED_IP_FIX,
+               MXS_PHY_NEED_IP_FIX |
+               MXS_PHY_HARDWARE_CONTROL_PHY2_CLK,
 };
 
 static const struct mxs_phy_data imx6sl_phy_data = {
        .flags = MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS |
-               MXS_PHY_NEED_IP_FIX,
+               MXS_PHY_NEED_IP_FIX |
+               MXS_PHY_HARDWARE_CONTROL_PHY2_CLK,
 };
 
 static const struct mxs_phy_data vf610_phy_data = {
@@ -175,7 +186,8 @@ static const struct mxs_phy_data vf610_phy_data = {
 };
 
 static const struct mxs_phy_data imx6sx_phy_data = {
-       .flags = MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS,
+       .flags = MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS |
+               MXS_PHY_HARDWARE_CONTROL_PHY2_CLK,
 };
 
 static const struct mxs_phy_data imx6ul_phy_data = {
@@ -518,12 +530,19 @@ static int mxs_phy_suspend(struct usb_phy *x, int suspend)
                }
                writel(BM_USBPHY_CTRL_CLKGATE,
                       x->io_priv + HW_USBPHY_CTRL_SET);
-               clk_disable_unprepare(mxs_phy->clk);
+               if (!(mxs_phy->port_id == 1 &&
+                       (mxs_phy->data->flags &
+                               MXS_PHY_HARDWARE_CONTROL_PHY2_CLK)))
+                       clk_disable_unprepare(mxs_phy->clk);
        } else {
                mxs_phy_clock_switch_delay();
-               ret = clk_prepare_enable(mxs_phy->clk);
-               if (ret)
-                       return ret;
+               if (!(mxs_phy->port_id == 1 &&
+                       (mxs_phy->data->flags &
+                               MXS_PHY_HARDWARE_CONTROL_PHY2_CLK))) {
+                       ret = clk_prepare_enable(mxs_phy->clk);
+                       if (ret)
+                               return ret;
+               }
                writel(BM_USBPHY_CTRL_CLKGATE,
                       x->io_priv + HW_USBPHY_CTRL_CLR);
                writel(0, x->io_priv + HW_USBPHY_PWD);