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

drivers: phy: sr-usb: do not use internal fsm for USB2 phy init

During different reboot cycles, USB PHY PLL may not always lock
during initialization and therefore can cause USB to be not usable.

Hence do not use internal FSM programming sequence for the USB
PHY initialization.

Fixes: 4dcddbb38b64 ("phy: sr-usb: Add Stingray USB PHY driver")
Signed-off-by: Bharat Gooty <bharat.gooty@broadcom.com>
Signed-off-by: Rayagonda Kokatanur <rayagonda.kokatanur@broadcom.com>
Link: https://lore.kernel.org/r/20200513173947.10919-1-rayagonda.kokatanur@broadcom.com
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>

authored by

Bharat Gooty and committed by
Kishon Vijay Abraham I
6f0577d1 42aed917

+2 -53
+2 -53
drivers/phy/broadcom/phy-bcm-sr-usb.c
··· 16 16 }; 17 17 18 18 enum bcm_usb_phy_reg { 19 - PLL_NDIV_FRAC, 20 - PLL_NDIV_INT, 21 19 PLL_CTRL, 22 20 PHY_CTRL, 23 21 PHY_PLL_CTRL, ··· 29 31 }; 30 32 31 33 static const u8 bcm_usb_combo_phy_hs[] = { 32 - [PLL_NDIV_FRAC] = 0x04, 33 - [PLL_NDIV_INT] = 0x08, 34 34 [PLL_CTRL] = 0x0c, 35 35 [PHY_CTRL] = 0x10, 36 36 }; 37 37 38 - #define HSPLL_NDIV_INT_VAL 0x13 39 - #define HSPLL_NDIV_FRAC_VAL 0x1005 40 - 41 38 static const u8 bcm_usb_hs_phy[] = { 42 - [PLL_NDIV_FRAC] = 0x0, 43 - [PLL_NDIV_INT] = 0x4, 44 39 [PLL_CTRL] = 0x8, 45 40 [PHY_CTRL] = 0xc, 46 41 }; ··· 43 52 SSPLL_SUSPEND_EN, 44 53 PLL_SEQ_START, 45 54 PLL_LOCK, 46 - PLL_PDIV, 47 55 }; 48 56 49 57 static const u8 u3pll_ctrl[] = { ··· 56 66 #define HSPLL_PDIV_VAL 0x1 57 67 58 68 static const u8 u2pll_ctrl[] = { 59 - [PLL_PDIV] = 1, 60 69 [PLL_RESETB] = 5, 61 70 [PLL_LOCK] = 6, 62 71 }; 63 72 64 73 enum bcm_usb_phy_ctrl_bits { 65 74 CORERDY, 66 - AFE_LDO_PWRDWNB, 67 - AFE_PLL_PWRDWNB, 68 - AFE_BG_PWRDWNB, 69 - PHY_ISO, 70 75 PHY_RESETB, 71 76 PHY_PCTL, 72 77 }; 73 78 74 79 #define PHY_PCTL_MASK 0xffff 75 - /* 76 - * 0x0806 of PCTL_VAL has below bits set 77 - * BIT-8 : refclk divider 1 78 - * BIT-3:2: device mode; mode is not effect 79 - * BIT-1: soft reset active low 80 - */ 81 - #define HSPHY_PCTL_VAL 0x0806 82 80 #define SSPHY_PCTL_VAL 0x0006 83 81 84 82 static const u8 u3phy_ctrl[] = { ··· 76 98 77 99 static const u8 u2phy_ctrl[] = { 78 100 [CORERDY] = 0, 79 - [AFE_LDO_PWRDWNB] = 1, 80 - [AFE_PLL_PWRDWNB] = 2, 81 - [AFE_BG_PWRDWNB] = 3, 82 - [PHY_ISO] = 4, 83 101 [PHY_RESETB] = 5, 84 102 [PHY_PCTL] = 6, 85 103 }; ··· 160 186 int ret = 0; 161 187 void __iomem *regs = phy_cfg->regs; 162 188 const u8 *offset; 163 - u32 rd_data; 164 189 165 190 offset = phy_cfg->offset; 166 191 167 - writel(HSPLL_NDIV_INT_VAL, regs + offset[PLL_NDIV_INT]); 168 - writel(HSPLL_NDIV_FRAC_VAL, regs + offset[PLL_NDIV_FRAC]); 169 - 170 - rd_data = readl(regs + offset[PLL_CTRL]); 171 - rd_data &= ~(HSPLL_PDIV_MASK << u2pll_ctrl[PLL_PDIV]); 172 - rd_data |= (HSPLL_PDIV_VAL << u2pll_ctrl[PLL_PDIV]); 173 - writel(rd_data, regs + offset[PLL_CTRL]); 174 - 175 - /* Set Core Ready high */ 176 - bcm_usb_reg32_setbits(regs + offset[PHY_CTRL], 177 - BIT(u2phy_ctrl[CORERDY])); 178 - 179 - /* Maximum timeout for Core Ready done */ 180 - msleep(30); 181 - 192 + bcm_usb_reg32_clrbits(regs + offset[PLL_CTRL], 193 + BIT(u2pll_ctrl[PLL_RESETB])); 182 194 bcm_usb_reg32_setbits(regs + offset[PLL_CTRL], 183 195 BIT(u2pll_ctrl[PLL_RESETB])); 184 - bcm_usb_reg32_setbits(regs + offset[PHY_CTRL], 185 - BIT(u2phy_ctrl[PHY_RESETB])); 186 - 187 - 188 - rd_data = readl(regs + offset[PHY_CTRL]); 189 - rd_data &= ~(PHY_PCTL_MASK << u2phy_ctrl[PHY_PCTL]); 190 - rd_data |= (HSPHY_PCTL_VAL << u2phy_ctrl[PHY_PCTL]); 191 - writel(rd_data, regs + offset[PHY_CTRL]); 192 - 193 - /* Maximum timeout for PLL reset done */ 194 - msleep(30); 195 196 196 197 ret = bcm_usb_pll_lock_check(regs + offset[PLL_CTRL], 197 198 BIT(u2pll_ctrl[PLL_LOCK]));