Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: phy: mxs: enable weak 1p1 regulator for imx6ul during suspend

1p1 is off when the system enters suspend at i.MX6UL. It cause the PHY
get wrong USB DP/DM value, then unexpected wakeup may occur if USB wakeup
enabled. This will enable weak 1p1 during PHY suspend if vbus exist. So
USB DP/DM is correct when system suspend.

Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
Link: https://lore.kernel.org/r/20240726113207.3393247-5-xu.yang_2@nxp.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Xu Yang and committed by
Greg Kroah-Hartman
2919d888 c99b27ef

+28 -4
+28 -4
drivers/usb/phy/phy-mxs-usb.c
··· 71 71 #define BM_USBPHY_PLL_EN_USB_CLKS BIT(6) 72 72 73 73 /* Anatop Registers */ 74 + #define ANADIG_REG_1P1_SET 0x114 75 + #define ANADIG_REG_1P1_CLR 0x118 76 + 74 77 #define ANADIG_ANA_MISC0 0x150 75 78 #define ANADIG_ANA_MISC0_SET 0x154 76 79 #define ANADIG_ANA_MISC0_CLR 0x158 ··· 125 122 #define SIM_GPR1 0x30 126 123 127 124 #define USB_PHY_VLLS_WAKEUP_EN BIT(0) 125 + 126 + #define BM_ANADIG_REG_1P1_ENABLE_WEAK_LINREG BIT(18) 127 + #define BM_ANADIG_REG_1P1_TRACK_VDD_SOC_CAP BIT(19) 128 128 129 129 #define to_mxs_phy(p) container_of((p), struct mxs_phy, phy) 130 130 ··· 202 196 }; 203 197 204 198 static const struct mxs_phy_data imx6ul_phy_data = { 205 - .flags = MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS, 199 + .flags = MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS | 200 + MXS_PHY_HARDWARE_CONTROL_PHY2_CLK, 206 201 }; 207 202 208 203 static const struct mxs_phy_data imx7ulp_phy_data = { ··· 246 239 static inline bool is_imx7ulp_phy(struct mxs_phy *mxs_phy) 247 240 { 248 241 return mxs_phy->data == &imx7ulp_phy_data; 242 + } 243 + 244 + static inline bool is_imx6ul_phy(struct mxs_phy *mxs_phy) 245 + { 246 + return mxs_phy->data == &imx6ul_phy_data; 249 247 } 250 248 251 249 /* ··· 896 884 897 885 static void mxs_phy_enable_ldo_in_suspend(struct mxs_phy *mxs_phy, bool on) 898 886 { 899 - unsigned int reg = on ? ANADIG_ANA_MISC0_SET : ANADIG_ANA_MISC0_CLR; 887 + unsigned int reg; 888 + u32 value; 900 889 901 890 /* If the SoCs don't have anatop, quit */ 902 891 if (!mxs_phy->regmap_anatop) 903 892 return; 904 893 905 - if (is_imx6q_phy(mxs_phy)) 894 + if (is_imx6q_phy(mxs_phy)) { 895 + reg = on ? ANADIG_ANA_MISC0_SET : ANADIG_ANA_MISC0_CLR; 906 896 regmap_write(mxs_phy->regmap_anatop, reg, 907 897 BM_ANADIG_ANA_MISC0_STOP_MODE_CONFIG); 908 - else if (is_imx6sl_phy(mxs_phy)) 898 + } else if (is_imx6sl_phy(mxs_phy)) { 899 + reg = on ? ANADIG_ANA_MISC0_SET : ANADIG_ANA_MISC0_CLR; 909 900 regmap_write(mxs_phy->regmap_anatop, 910 901 reg, BM_ANADIG_ANA_MISC0_STOP_MODE_CONFIG_SL); 902 + } else if (is_imx6ul_phy(mxs_phy)) { 903 + reg = on ? ANADIG_REG_1P1_SET : ANADIG_REG_1P1_CLR; 904 + value = BM_ANADIG_REG_1P1_ENABLE_WEAK_LINREG | 905 + BM_ANADIG_REG_1P1_TRACK_VDD_SOC_CAP; 906 + if (mxs_phy_get_vbus_status(mxs_phy) && on) 907 + regmap_write(mxs_phy->regmap_anatop, reg, value); 908 + else if (!on) 909 + regmap_write(mxs_phy->regmap_anatop, reg, value); 910 + } 911 911 } 912 912 913 913 static int mxs_phy_system_suspend(struct device *dev)