Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | /* |
| 3 | * Copyright (c) 2017, The Linux Foundation. All rights reserved. |
| 4 | */ |
| 5 | |
| 6 | #include <linux/clk.h> |
| 7 | #include <linux/clk-provider.h> |
| 8 | #include <linux/delay.h> |
| 9 | #include <linux/err.h> |
| 10 | #include <linux/io.h> |
| 11 | #include <linux/iopoll.h> |
| 12 | #include <linux/kernel.h> |
| 13 | #include <linux/module.h> |
| 14 | #include <linux/of.h> |
| 15 | #include <linux/of_device.h> |
| 16 | #include <linux/of_address.h> |
| 17 | #include <linux/phy/phy.h> |
| 18 | #include <linux/platform_device.h> |
| 19 | #include <linux/regulator/consumer.h> |
| 20 | #include <linux/reset.h> |
| 21 | #include <linux/slab.h> |
| 22 | |
| 23 | #include <dt-bindings/phy/phy.h> |
| 24 | |
| 25 | #include "phy-qcom-qmp.h" |
| 26 | |
| 27 | /* QPHY_SW_RESET bit */ |
| 28 | #define SW_RESET BIT(0) |
| 29 | /* QPHY_POWER_DOWN_CONTROL */ |
| 30 | #define SW_PWRDN BIT(0) |
| 31 | #define REFCLK_DRV_DSBL BIT(1) |
| 32 | /* QPHY_START_CONTROL bits */ |
| 33 | #define SERDES_START BIT(0) |
| 34 | #define PCS_START BIT(1) |
| 35 | #define PLL_READY_GATE_EN BIT(3) |
| 36 | /* QPHY_PCS_STATUS bit */ |
| 37 | #define PHYSTATUS BIT(6) |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 38 | /* QPHY_PCS_READY_STATUS & QPHY_COM_PCS_READY_STATUS bit */ |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 39 | #define PCS_READY BIT(0) |
| 40 | |
| 41 | /* QPHY_V3_DP_COM_RESET_OVRD_CTRL register bits */ |
| 42 | /* DP PHY soft reset */ |
| 43 | #define SW_DPPHY_RESET BIT(0) |
| 44 | /* mux to select DP PHY reset control, 0:HW control, 1: software reset */ |
| 45 | #define SW_DPPHY_RESET_MUX BIT(1) |
| 46 | /* USB3 PHY soft reset */ |
| 47 | #define SW_USB3PHY_RESET BIT(2) |
| 48 | /* mux to select USB3 PHY reset control, 0:HW control, 1: software reset */ |
| 49 | #define SW_USB3PHY_RESET_MUX BIT(3) |
| 50 | |
| 51 | /* QPHY_V3_DP_COM_PHY_MODE_CTRL register bits */ |
| 52 | #define USB3_MODE BIT(0) /* enables USB3 mode */ |
| 53 | #define DP_MODE BIT(1) /* enables DP mode */ |
| 54 | |
| 55 | /* QPHY_PCS_AUTONOMOUS_MODE_CTRL register bits */ |
| 56 | #define ARCVR_DTCT_EN BIT(0) |
| 57 | #define ALFPS_DTCT_EN BIT(1) |
| 58 | #define ARCVR_DTCT_EVENT_SEL BIT(4) |
| 59 | |
| 60 | /* QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR register bits */ |
| 61 | #define IRQ_CLEAR BIT(0) |
| 62 | |
| 63 | /* QPHY_PCS_LFPS_RXTERM_IRQ_STATUS register bits */ |
| 64 | #define RCVR_DETECT BIT(0) |
| 65 | |
| 66 | /* QPHY_V3_PCS_MISC_CLAMP_ENABLE register bits */ |
| 67 | #define CLAMP_EN BIT(0) /* enables i/o clamp_n */ |
| 68 | |
Olivier Deprez | 0e64123 | 2021-09-23 10:07:05 +0200 | [diff] [blame^] | 69 | #define PHY_INIT_COMPLETE_TIMEOUT 10000 |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 70 | #define POWER_DOWN_DELAY_US_MIN 10 |
| 71 | #define POWER_DOWN_DELAY_US_MAX 11 |
| 72 | |
| 73 | #define MAX_PROP_NAME 32 |
| 74 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 75 | /* Define the assumed distance between lanes for underspecified device trees. */ |
| 76 | #define QMP_PHY_LEGACY_LANE_STRIDE 0x400 |
| 77 | |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 78 | struct qmp_phy_init_tbl { |
| 79 | unsigned int offset; |
| 80 | unsigned int val; |
| 81 | /* |
| 82 | * register part of layout ? |
| 83 | * if yes, then offset gives index in the reg-layout |
| 84 | */ |
| 85 | int in_layout; |
| 86 | }; |
| 87 | |
| 88 | #define QMP_PHY_INIT_CFG(o, v) \ |
| 89 | { \ |
| 90 | .offset = o, \ |
| 91 | .val = v, \ |
| 92 | } |
| 93 | |
| 94 | #define QMP_PHY_INIT_CFG_L(o, v) \ |
| 95 | { \ |
| 96 | .offset = o, \ |
| 97 | .val = v, \ |
| 98 | .in_layout = 1, \ |
| 99 | } |
| 100 | |
| 101 | /* set of registers with offsets different per-PHY */ |
| 102 | enum qphy_reg_layout { |
| 103 | /* Common block control registers */ |
| 104 | QPHY_COM_SW_RESET, |
| 105 | QPHY_COM_POWER_DOWN_CONTROL, |
| 106 | QPHY_COM_START_CONTROL, |
| 107 | QPHY_COM_PCS_READY_STATUS, |
| 108 | /* PCS registers */ |
| 109 | QPHY_PLL_LOCK_CHK_DLY_TIME, |
| 110 | QPHY_FLL_CNTRL1, |
| 111 | QPHY_FLL_CNTRL2, |
| 112 | QPHY_FLL_CNT_VAL_L, |
| 113 | QPHY_FLL_CNT_VAL_H_TOL, |
| 114 | QPHY_FLL_MAN_CODE, |
| 115 | QPHY_SW_RESET, |
| 116 | QPHY_START_CTRL, |
| 117 | QPHY_PCS_READY_STATUS, |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 118 | QPHY_PCS_STATUS, |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 119 | QPHY_PCS_AUTONOMOUS_MODE_CTRL, |
| 120 | QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR, |
| 121 | QPHY_PCS_LFPS_RXTERM_IRQ_STATUS, |
| 122 | }; |
| 123 | |
| 124 | static const unsigned int pciephy_regs_layout[] = { |
| 125 | [QPHY_COM_SW_RESET] = 0x400, |
| 126 | [QPHY_COM_POWER_DOWN_CONTROL] = 0x404, |
| 127 | [QPHY_COM_START_CONTROL] = 0x408, |
| 128 | [QPHY_COM_PCS_READY_STATUS] = 0x448, |
| 129 | [QPHY_PLL_LOCK_CHK_DLY_TIME] = 0xa8, |
| 130 | [QPHY_FLL_CNTRL1] = 0xc4, |
| 131 | [QPHY_FLL_CNTRL2] = 0xc8, |
| 132 | [QPHY_FLL_CNT_VAL_L] = 0xcc, |
| 133 | [QPHY_FLL_CNT_VAL_H_TOL] = 0xd0, |
| 134 | [QPHY_FLL_MAN_CODE] = 0xd4, |
| 135 | [QPHY_SW_RESET] = 0x00, |
| 136 | [QPHY_START_CTRL] = 0x08, |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 137 | [QPHY_PCS_STATUS] = 0x174, |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 138 | }; |
| 139 | |
| 140 | static const unsigned int usb3phy_regs_layout[] = { |
| 141 | [QPHY_FLL_CNTRL1] = 0xc0, |
| 142 | [QPHY_FLL_CNTRL2] = 0xc4, |
| 143 | [QPHY_FLL_CNT_VAL_L] = 0xc8, |
| 144 | [QPHY_FLL_CNT_VAL_H_TOL] = 0xcc, |
| 145 | [QPHY_FLL_MAN_CODE] = 0xd0, |
| 146 | [QPHY_SW_RESET] = 0x00, |
| 147 | [QPHY_START_CTRL] = 0x08, |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 148 | [QPHY_PCS_STATUS] = 0x17c, |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 149 | [QPHY_PCS_AUTONOMOUS_MODE_CTRL] = 0x0d4, |
| 150 | [QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR] = 0x0d8, |
| 151 | [QPHY_PCS_LFPS_RXTERM_IRQ_STATUS] = 0x178, |
| 152 | }; |
| 153 | |
| 154 | static const unsigned int qmp_v3_usb3phy_regs_layout[] = { |
| 155 | [QPHY_SW_RESET] = 0x00, |
| 156 | [QPHY_START_CTRL] = 0x08, |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 157 | [QPHY_PCS_STATUS] = 0x174, |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 158 | [QPHY_PCS_AUTONOMOUS_MODE_CTRL] = 0x0d8, |
| 159 | [QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR] = 0x0dc, |
| 160 | [QPHY_PCS_LFPS_RXTERM_IRQ_STATUS] = 0x170, |
| 161 | }; |
| 162 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 163 | static const unsigned int sdm845_ufsphy_regs_layout[] = { |
| 164 | [QPHY_START_CTRL] = 0x00, |
| 165 | [QPHY_PCS_READY_STATUS] = 0x160, |
| 166 | }; |
| 167 | |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 168 | static const struct qmp_phy_init_tbl msm8996_pcie_serdes_tbl[] = { |
| 169 | QMP_PHY_INIT_CFG(QSERDES_COM_BIAS_EN_CLKBUFLR_EN, 0x1c), |
| 170 | QMP_PHY_INIT_CFG(QSERDES_COM_CLK_ENABLE1, 0x10), |
| 171 | QMP_PHY_INIT_CFG(QSERDES_COM_CLK_SELECT, 0x33), |
| 172 | QMP_PHY_INIT_CFG(QSERDES_COM_CMN_CONFIG, 0x06), |
| 173 | QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP_EN, 0x42), |
| 174 | QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_MAP, 0x00), |
| 175 | QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_TIMER1, 0xff), |
| 176 | QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_TIMER2, 0x1f), |
| 177 | QMP_PHY_INIT_CFG(QSERDES_COM_HSCLK_SEL, 0x01), |
| 178 | QMP_PHY_INIT_CFG(QSERDES_COM_SVS_MODE_CLK_SEL, 0x01), |
| 179 | QMP_PHY_INIT_CFG(QSERDES_COM_CORE_CLK_EN, 0x00), |
| 180 | QMP_PHY_INIT_CFG(QSERDES_COM_CORECLK_DIV, 0x0a), |
| 181 | QMP_PHY_INIT_CFG(QSERDES_COM_BG_TIMER, 0x09), |
| 182 | QMP_PHY_INIT_CFG(QSERDES_COM_DEC_START_MODE0, 0x82), |
| 183 | QMP_PHY_INIT_CFG(QSERDES_COM_DIV_FRAC_START3_MODE0, 0x03), |
| 184 | QMP_PHY_INIT_CFG(QSERDES_COM_DIV_FRAC_START2_MODE0, 0x55), |
| 185 | QMP_PHY_INIT_CFG(QSERDES_COM_DIV_FRAC_START1_MODE0, 0x55), |
| 186 | QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP3_MODE0, 0x00), |
| 187 | QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP2_MODE0, 0x1a), |
| 188 | QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP1_MODE0, 0x0a), |
| 189 | QMP_PHY_INIT_CFG(QSERDES_COM_CLK_SELECT, 0x33), |
| 190 | QMP_PHY_INIT_CFG(QSERDES_COM_SYS_CLK_CTRL, 0x02), |
| 191 | QMP_PHY_INIT_CFG(QSERDES_COM_SYSCLK_BUF_ENABLE, 0x1f), |
| 192 | QMP_PHY_INIT_CFG(QSERDES_COM_SYSCLK_EN_SEL, 0x04), |
| 193 | QMP_PHY_INIT_CFG(QSERDES_COM_CP_CTRL_MODE0, 0x0b), |
| 194 | QMP_PHY_INIT_CFG(QSERDES_COM_PLL_RCTRL_MODE0, 0x16), |
| 195 | QMP_PHY_INIT_CFG(QSERDES_COM_PLL_CCTRL_MODE0, 0x28), |
| 196 | QMP_PHY_INIT_CFG(QSERDES_COM_INTEGLOOP_GAIN1_MODE0, 0x00), |
| 197 | QMP_PHY_INIT_CFG(QSERDES_COM_INTEGLOOP_GAIN0_MODE0, 0x80), |
| 198 | QMP_PHY_INIT_CFG(QSERDES_COM_SSC_EN_CENTER, 0x01), |
| 199 | QMP_PHY_INIT_CFG(QSERDES_COM_SSC_PER1, 0x31), |
| 200 | QMP_PHY_INIT_CFG(QSERDES_COM_SSC_PER2, 0x01), |
| 201 | QMP_PHY_INIT_CFG(QSERDES_COM_SSC_ADJ_PER1, 0x02), |
| 202 | QMP_PHY_INIT_CFG(QSERDES_COM_SSC_ADJ_PER2, 0x00), |
| 203 | QMP_PHY_INIT_CFG(QSERDES_COM_SSC_STEP_SIZE1, 0x2f), |
| 204 | QMP_PHY_INIT_CFG(QSERDES_COM_SSC_STEP_SIZE2, 0x19), |
| 205 | QMP_PHY_INIT_CFG(QSERDES_COM_RESCODE_DIV_NUM, 0x15), |
| 206 | QMP_PHY_INIT_CFG(QSERDES_COM_BG_TRIM, 0x0f), |
| 207 | QMP_PHY_INIT_CFG(QSERDES_COM_PLL_IVCO, 0x0f), |
| 208 | QMP_PHY_INIT_CFG(QSERDES_COM_CLK_EP_DIV, 0x19), |
| 209 | QMP_PHY_INIT_CFG(QSERDES_COM_CLK_ENABLE1, 0x10), |
| 210 | QMP_PHY_INIT_CFG(QSERDES_COM_HSCLK_SEL, 0x00), |
| 211 | QMP_PHY_INIT_CFG(QSERDES_COM_RESCODE_DIV_NUM, 0x40), |
| 212 | }; |
| 213 | |
| 214 | static const struct qmp_phy_init_tbl msm8996_pcie_tx_tbl[] = { |
| 215 | QMP_PHY_INIT_CFG(QSERDES_TX_HIGHZ_TRANSCEIVEREN_BIAS_DRVR_EN, 0x45), |
| 216 | QMP_PHY_INIT_CFG(QSERDES_TX_LANE_MODE, 0x06), |
| 217 | }; |
| 218 | |
| 219 | static const struct qmp_phy_init_tbl msm8996_pcie_rx_tbl[] = { |
| 220 | QMP_PHY_INIT_CFG(QSERDES_RX_SIGDET_ENABLES, 0x1c), |
| 221 | QMP_PHY_INIT_CFG(QSERDES_RX_RX_EQU_ADAPTOR_CNTRL2, 0x01), |
| 222 | QMP_PHY_INIT_CFG(QSERDES_RX_RX_EQU_ADAPTOR_CNTRL3, 0x00), |
| 223 | QMP_PHY_INIT_CFG(QSERDES_RX_RX_EQU_ADAPTOR_CNTRL4, 0xdb), |
| 224 | QMP_PHY_INIT_CFG(QSERDES_RX_RX_BAND, 0x18), |
| 225 | QMP_PHY_INIT_CFG(QSERDES_RX_UCDR_SO_GAIN, 0x04), |
| 226 | QMP_PHY_INIT_CFG(QSERDES_RX_UCDR_SO_GAIN_HALF, 0x04), |
| 227 | QMP_PHY_INIT_CFG(QSERDES_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x4b), |
| 228 | QMP_PHY_INIT_CFG(QSERDES_RX_SIGDET_DEGLITCH_CNTRL, 0x14), |
| 229 | QMP_PHY_INIT_CFG(QSERDES_RX_SIGDET_LVL, 0x19), |
| 230 | }; |
| 231 | |
| 232 | static const struct qmp_phy_init_tbl msm8996_pcie_pcs_tbl[] = { |
| 233 | QMP_PHY_INIT_CFG(QPHY_RX_IDLE_DTCT_CNTRL, 0x4c), |
| 234 | QMP_PHY_INIT_CFG(QPHY_PWRUP_RESET_DLY_TIME_AUXCLK, 0x00), |
| 235 | QMP_PHY_INIT_CFG(QPHY_LP_WAKEUP_DLY_TIME_AUXCLK, 0x01), |
| 236 | |
| 237 | QMP_PHY_INIT_CFG_L(QPHY_PLL_LOCK_CHK_DLY_TIME, 0x05), |
| 238 | |
| 239 | QMP_PHY_INIT_CFG(QPHY_ENDPOINT_REFCLK_DRIVE, 0x05), |
| 240 | QMP_PHY_INIT_CFG(QPHY_POWER_DOWN_CONTROL, 0x02), |
| 241 | QMP_PHY_INIT_CFG(QPHY_POWER_STATE_CONFIG4, 0x00), |
| 242 | QMP_PHY_INIT_CFG(QPHY_POWER_STATE_CONFIG1, 0xa3), |
| 243 | QMP_PHY_INIT_CFG(QPHY_TXDEEMPH_M3P5DB_V0, 0x0e), |
| 244 | }; |
| 245 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 246 | static const struct qmp_phy_init_tbl msm8998_pcie_serdes_tbl[] = { |
| 247 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_BIAS_EN_CLKBUFLR_EN, 0x14), |
| 248 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_SELECT, 0x30), |
| 249 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_IVCO, 0x0f), |
| 250 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CMN_CONFIG, 0x06), |
| 251 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP_EN, 0x01), |
| 252 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_RESETSM_CNTRL, 0x20), |
| 253 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_MAP, 0x00), |
| 254 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE2_MODE0, 0x01), |
| 255 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE1_MODE0, 0xc9), |
| 256 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_TIMER1, 0xff), |
| 257 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_TIMER2, 0x3f), |
| 258 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SVS_MODE_CLK_SEL, 0x01), |
| 259 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CORE_CLK_EN, 0x00), |
| 260 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CORECLK_DIV_MODE0, 0x0a), |
| 261 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_EP_DIV, 0x19), |
| 262 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_ENABLE1, 0x90), |
| 263 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_DEC_START_MODE0, 0x82), |
| 264 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START3_MODE0, 0x03), |
| 265 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START2_MODE0, 0x55), |
| 266 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START1_MODE0, 0x55), |
| 267 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP3_MODE0, 0x00), |
| 268 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP2_MODE0, 0x0d), |
| 269 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP1_MODE0, 0x04), |
| 270 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_HSCLK_SEL, 0x00), |
| 271 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CP_CTRL_MODE0, 0x08), |
| 272 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_RCTRL_MODE0, 0x16), |
| 273 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_CCTRL_MODE0, 0x34), |
| 274 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CMN_CONFIG, 0x06), |
| 275 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_SELECT, 0x33), |
| 276 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYS_CLK_CTRL, 0x02), |
| 277 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYSCLK_BUF_ENABLE, 0x07), |
| 278 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYSCLK_EN_SEL, 0x04), |
| 279 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN1_MODE0, 0x00), |
| 280 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN0_MODE0, 0x3f), |
| 281 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_BG_TIMER, 0x09), |
| 282 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_EN_CENTER, 0x01), |
| 283 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_PER1, 0x40), |
| 284 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_PER2, 0x01), |
| 285 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_ADJ_PER1, 0x02), |
| 286 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_ADJ_PER2, 0x00), |
| 287 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_STEP_SIZE1, 0x7e), |
| 288 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_STEP_SIZE2, 0x15), |
| 289 | }; |
| 290 | |
| 291 | static const struct qmp_phy_init_tbl msm8998_pcie_tx_tbl[] = { |
| 292 | QMP_PHY_INIT_CFG(QSERDES_V3_TX_RES_CODE_LANE_OFFSET_TX, 0x02), |
| 293 | QMP_PHY_INIT_CFG(QSERDES_V3_TX_RCV_DETECT_LVL_2, 0x12), |
| 294 | QMP_PHY_INIT_CFG(QSERDES_V3_TX_HIGHZ_DRVR_EN, 0x10), |
| 295 | QMP_PHY_INIT_CFG(QSERDES_V3_TX_LANE_MODE_1, 0x06), |
| 296 | }; |
| 297 | |
| 298 | static const struct qmp_phy_init_tbl msm8998_pcie_rx_tbl[] = { |
| 299 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_CNTRL, 0x03), |
| 300 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_ENABLES, 0x1c), |
| 301 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_DEGLITCH_CNTRL, 0x14), |
| 302 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL2, 0x0a), |
| 303 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL3, 0x04), |
| 304 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL4, 0x1a), |
| 305 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x4b), |
| 306 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SO_GAIN, 0x04), |
| 307 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SO_GAIN_HALF, 0x04), |
| 308 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1, 0x00), |
| 309 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_OFFSET_ADAPTOR_CNTRL2, 0x80), |
| 310 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_INTERFACE_MODE, 0x40), |
| 311 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_PI_CONTROLS, 0x71), |
| 312 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_FASTLOCK_COUNT_LOW, 0x40), |
| 313 | }; |
| 314 | |
| 315 | static const struct qmp_phy_init_tbl msm8998_pcie_pcs_tbl[] = { |
| 316 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_ENDPOINT_REFCLK_DRIVE, 0x04), |
| 317 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_OSC_DTCT_ACTIONS, 0x00), |
| 318 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_PWRUP_RESET_DLY_TIME_AUXCLK, 0x01), |
| 319 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_L1SS_WAKEUP_DLY_TIME_AUXCLK_MSB, 0x00), |
| 320 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_L1SS_WAKEUP_DLY_TIME_AUXCLK_LSB, 0x20), |
| 321 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_LP_WAKEUP_DLY_TIME_AUXCLK_MSB, 0x00), |
| 322 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_LP_WAKEUP_DLY_TIME_AUXCLK, 0x01), |
| 323 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_PLL_LOCK_CHK_DLY_TIME, 0x73), |
| 324 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_RX_SIGDET_LVL, 0x99), |
| 325 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_SIGDET_CNTRL, 0x03), |
| 326 | }; |
| 327 | |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 328 | static const struct qmp_phy_init_tbl msm8996_usb3_serdes_tbl[] = { |
| 329 | QMP_PHY_INIT_CFG(QSERDES_COM_SYSCLK_EN_SEL, 0x14), |
| 330 | QMP_PHY_INIT_CFG(QSERDES_COM_BIAS_EN_CLKBUFLR_EN, 0x08), |
| 331 | QMP_PHY_INIT_CFG(QSERDES_COM_CLK_SELECT, 0x30), |
| 332 | QMP_PHY_INIT_CFG(QSERDES_COM_CMN_CONFIG, 0x06), |
| 333 | QMP_PHY_INIT_CFG(QSERDES_COM_SVS_MODE_CLK_SEL, 0x01), |
| 334 | QMP_PHY_INIT_CFG(QSERDES_COM_HSCLK_SEL, 0x00), |
| 335 | QMP_PHY_INIT_CFG(QSERDES_COM_BG_TRIM, 0x0f), |
| 336 | QMP_PHY_INIT_CFG(QSERDES_COM_PLL_IVCO, 0x0f), |
| 337 | QMP_PHY_INIT_CFG(QSERDES_COM_SYS_CLK_CTRL, 0x04), |
| 338 | /* PLL and Loop filter settings */ |
| 339 | QMP_PHY_INIT_CFG(QSERDES_COM_DEC_START_MODE0, 0x82), |
| 340 | QMP_PHY_INIT_CFG(QSERDES_COM_DIV_FRAC_START1_MODE0, 0x55), |
| 341 | QMP_PHY_INIT_CFG(QSERDES_COM_DIV_FRAC_START2_MODE0, 0x55), |
| 342 | QMP_PHY_INIT_CFG(QSERDES_COM_DIV_FRAC_START3_MODE0, 0x03), |
| 343 | QMP_PHY_INIT_CFG(QSERDES_COM_CP_CTRL_MODE0, 0x0b), |
| 344 | QMP_PHY_INIT_CFG(QSERDES_COM_PLL_RCTRL_MODE0, 0x16), |
| 345 | QMP_PHY_INIT_CFG(QSERDES_COM_PLL_CCTRL_MODE0, 0x28), |
| 346 | QMP_PHY_INIT_CFG(QSERDES_COM_INTEGLOOP_GAIN0_MODE0, 0x80), |
| 347 | QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_CTRL, 0x00), |
| 348 | QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP1_MODE0, 0x15), |
| 349 | QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP2_MODE0, 0x34), |
| 350 | QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP3_MODE0, 0x00), |
| 351 | QMP_PHY_INIT_CFG(QSERDES_COM_CORE_CLK_EN, 0x00), |
| 352 | QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP_CFG, 0x00), |
| 353 | QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_MAP, 0x00), |
| 354 | QMP_PHY_INIT_CFG(QSERDES_COM_BG_TIMER, 0x0a), |
| 355 | /* SSC settings */ |
| 356 | QMP_PHY_INIT_CFG(QSERDES_COM_SSC_EN_CENTER, 0x01), |
| 357 | QMP_PHY_INIT_CFG(QSERDES_COM_SSC_PER1, 0x31), |
| 358 | QMP_PHY_INIT_CFG(QSERDES_COM_SSC_PER2, 0x01), |
| 359 | QMP_PHY_INIT_CFG(QSERDES_COM_SSC_ADJ_PER1, 0x00), |
| 360 | QMP_PHY_INIT_CFG(QSERDES_COM_SSC_ADJ_PER2, 0x00), |
| 361 | QMP_PHY_INIT_CFG(QSERDES_COM_SSC_STEP_SIZE1, 0xde), |
| 362 | QMP_PHY_INIT_CFG(QSERDES_COM_SSC_STEP_SIZE2, 0x07), |
| 363 | }; |
| 364 | |
| 365 | static const struct qmp_phy_init_tbl msm8996_usb3_tx_tbl[] = { |
| 366 | QMP_PHY_INIT_CFG(QSERDES_TX_HIGHZ_TRANSCEIVEREN_BIAS_DRVR_EN, 0x45), |
| 367 | QMP_PHY_INIT_CFG(QSERDES_TX_RCV_DETECT_LVL_2, 0x12), |
| 368 | QMP_PHY_INIT_CFG(QSERDES_TX_LANE_MODE, 0x06), |
| 369 | }; |
| 370 | |
| 371 | static const struct qmp_phy_init_tbl msm8996_usb3_rx_tbl[] = { |
| 372 | QMP_PHY_INIT_CFG(QSERDES_RX_UCDR_FASTLOCK_FO_GAIN, 0x0b), |
| 373 | QMP_PHY_INIT_CFG(QSERDES_RX_UCDR_SO_GAIN, 0x04), |
| 374 | QMP_PHY_INIT_CFG(QSERDES_RX_RX_EQU_ADAPTOR_CNTRL2, 0x02), |
| 375 | QMP_PHY_INIT_CFG(QSERDES_RX_RX_EQU_ADAPTOR_CNTRL3, 0x4c), |
| 376 | QMP_PHY_INIT_CFG(QSERDES_RX_RX_EQU_ADAPTOR_CNTRL4, 0xbb), |
| 377 | QMP_PHY_INIT_CFG(QSERDES_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1, 0x77), |
| 378 | QMP_PHY_INIT_CFG(QSERDES_RX_RX_OFFSET_ADAPTOR_CNTRL2, 0x80), |
| 379 | QMP_PHY_INIT_CFG(QSERDES_RX_SIGDET_CNTRL, 0x03), |
| 380 | QMP_PHY_INIT_CFG(QSERDES_RX_SIGDET_LVL, 0x18), |
| 381 | QMP_PHY_INIT_CFG(QSERDES_RX_SIGDET_DEGLITCH_CNTRL, 0x16), |
| 382 | }; |
| 383 | |
| 384 | static const struct qmp_phy_init_tbl msm8996_usb3_pcs_tbl[] = { |
| 385 | /* FLL settings */ |
| 386 | QMP_PHY_INIT_CFG_L(QPHY_FLL_CNTRL2, 0x03), |
| 387 | QMP_PHY_INIT_CFG_L(QPHY_FLL_CNTRL1, 0x02), |
| 388 | QMP_PHY_INIT_CFG_L(QPHY_FLL_CNT_VAL_L, 0x09), |
| 389 | QMP_PHY_INIT_CFG_L(QPHY_FLL_CNT_VAL_H_TOL, 0x42), |
| 390 | QMP_PHY_INIT_CFG_L(QPHY_FLL_MAN_CODE, 0x85), |
| 391 | |
| 392 | /* Lock Det settings */ |
| 393 | QMP_PHY_INIT_CFG(QPHY_LOCK_DETECT_CONFIG1, 0xd1), |
| 394 | QMP_PHY_INIT_CFG(QPHY_LOCK_DETECT_CONFIG2, 0x1f), |
| 395 | QMP_PHY_INIT_CFG(QPHY_LOCK_DETECT_CONFIG3, 0x47), |
| 396 | QMP_PHY_INIT_CFG(QPHY_POWER_STATE_CONFIG2, 0x08), |
| 397 | }; |
| 398 | |
| 399 | static const struct qmp_phy_init_tbl ipq8074_pcie_serdes_tbl[] = { |
| 400 | QMP_PHY_INIT_CFG(QSERDES_COM_BIAS_EN_CLKBUFLR_EN, 0x18), |
| 401 | QMP_PHY_INIT_CFG(QSERDES_COM_CLK_ENABLE1, 0x10), |
| 402 | QMP_PHY_INIT_CFG(QSERDES_COM_BG_TRIM, 0xf), |
| 403 | QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP_EN, 0x1), |
| 404 | QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_MAP, 0x0), |
Olivier Deprez | 0e64123 | 2021-09-23 10:07:05 +0200 | [diff] [blame^] | 405 | QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_TIMER1, 0xff), |
| 406 | QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_TIMER2, 0x1f), |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 407 | QMP_PHY_INIT_CFG(QSERDES_COM_CMN_CONFIG, 0x6), |
| 408 | QMP_PHY_INIT_CFG(QSERDES_COM_PLL_IVCO, 0xf), |
| 409 | QMP_PHY_INIT_CFG(QSERDES_COM_HSCLK_SEL, 0x0), |
| 410 | QMP_PHY_INIT_CFG(QSERDES_COM_SVS_MODE_CLK_SEL, 0x1), |
| 411 | QMP_PHY_INIT_CFG(QSERDES_COM_CORE_CLK_EN, 0x20), |
| 412 | QMP_PHY_INIT_CFG(QSERDES_COM_CORECLK_DIV, 0xa), |
| 413 | QMP_PHY_INIT_CFG(QSERDES_COM_RESETSM_CNTRL, 0x20), |
| 414 | QMP_PHY_INIT_CFG(QSERDES_COM_BG_TIMER, 0xa), |
| 415 | QMP_PHY_INIT_CFG(QSERDES_COM_SYSCLK_EN_SEL, 0xa), |
| 416 | QMP_PHY_INIT_CFG(QSERDES_COM_DEC_START_MODE0, 0x82), |
| 417 | QMP_PHY_INIT_CFG(QSERDES_COM_DIV_FRAC_START3_MODE0, 0x3), |
| 418 | QMP_PHY_INIT_CFG(QSERDES_COM_DIV_FRAC_START2_MODE0, 0x55), |
| 419 | QMP_PHY_INIT_CFG(QSERDES_COM_DIV_FRAC_START1_MODE0, 0x55), |
| 420 | QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP3_MODE0, 0x0), |
| 421 | QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP2_MODE0, 0xD), |
| 422 | QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP1_MODE0, 0xD04), |
| 423 | QMP_PHY_INIT_CFG(QSERDES_COM_CLK_SELECT, 0x33), |
| 424 | QMP_PHY_INIT_CFG(QSERDES_COM_SYS_CLK_CTRL, 0x2), |
| 425 | QMP_PHY_INIT_CFG(QSERDES_COM_SYSCLK_BUF_ENABLE, 0x1f), |
| 426 | QMP_PHY_INIT_CFG(QSERDES_COM_CP_CTRL_MODE0, 0xb), |
| 427 | QMP_PHY_INIT_CFG(QSERDES_COM_PLL_RCTRL_MODE0, 0x16), |
| 428 | QMP_PHY_INIT_CFG(QSERDES_COM_PLL_CCTRL_MODE0, 0x28), |
| 429 | QMP_PHY_INIT_CFG(QSERDES_COM_INTEGLOOP_GAIN1_MODE0, 0x0), |
| 430 | QMP_PHY_INIT_CFG(QSERDES_COM_INTEGLOOP_GAIN0_MODE0, 0x80), |
| 431 | QMP_PHY_INIT_CFG(QSERDES_COM_BIAS_EN_CTRL_BY_PSM, 0x1), |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 432 | QMP_PHY_INIT_CFG(QSERDES_COM_SSC_EN_CENTER, 0x1), |
| 433 | QMP_PHY_INIT_CFG(QSERDES_COM_SSC_PER1, 0x31), |
| 434 | QMP_PHY_INIT_CFG(QSERDES_COM_SSC_PER2, 0x1), |
| 435 | QMP_PHY_INIT_CFG(QSERDES_COM_SSC_ADJ_PER1, 0x2), |
| 436 | QMP_PHY_INIT_CFG(QSERDES_COM_SSC_ADJ_PER2, 0x0), |
| 437 | QMP_PHY_INIT_CFG(QSERDES_COM_SSC_STEP_SIZE1, 0x2f), |
| 438 | QMP_PHY_INIT_CFG(QSERDES_COM_SSC_STEP_SIZE2, 0x19), |
| 439 | QMP_PHY_INIT_CFG(QSERDES_COM_CLK_EP_DIV, 0x19), |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 440 | }; |
| 441 | |
| 442 | static const struct qmp_phy_init_tbl ipq8074_pcie_tx_tbl[] = { |
| 443 | QMP_PHY_INIT_CFG(QSERDES_TX_HIGHZ_TRANSCEIVEREN_BIAS_DRVR_EN, 0x45), |
| 444 | QMP_PHY_INIT_CFG(QSERDES_TX_LANE_MODE, 0x6), |
| 445 | QMP_PHY_INIT_CFG(QSERDES_TX_RES_CODE_LANE_OFFSET, 0x2), |
| 446 | QMP_PHY_INIT_CFG(QSERDES_TX_RCV_DETECT_LVL_2, 0x12), |
Olivier Deprez | 0e64123 | 2021-09-23 10:07:05 +0200 | [diff] [blame^] | 447 | QMP_PHY_INIT_CFG(QSERDES_TX_EMP_POST1_LVL, 0x36), |
| 448 | QMP_PHY_INIT_CFG(QSERDES_TX_SLEW_CNTL, 0x0a), |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 449 | }; |
| 450 | |
| 451 | static const struct qmp_phy_init_tbl ipq8074_pcie_rx_tbl[] = { |
| 452 | QMP_PHY_INIT_CFG(QSERDES_RX_SIGDET_ENABLES, 0x1c), |
| 453 | QMP_PHY_INIT_CFG(QSERDES_RX_SIGDET_DEGLITCH_CNTRL, 0x14), |
| 454 | QMP_PHY_INIT_CFG(QSERDES_RX_RX_EQU_ADAPTOR_CNTRL2, 0x1), |
| 455 | QMP_PHY_INIT_CFG(QSERDES_RX_RX_EQU_ADAPTOR_CNTRL3, 0x0), |
| 456 | QMP_PHY_INIT_CFG(QSERDES_RX_RX_EQU_ADAPTOR_CNTRL4, 0xdb), |
| 457 | QMP_PHY_INIT_CFG(QSERDES_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x4b), |
| 458 | QMP_PHY_INIT_CFG(QSERDES_RX_UCDR_SO_GAIN, 0x4), |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 459 | }; |
| 460 | |
| 461 | static const struct qmp_phy_init_tbl ipq8074_pcie_pcs_tbl[] = { |
| 462 | QMP_PHY_INIT_CFG(QPHY_ENDPOINT_REFCLK_DRIVE, 0x4), |
| 463 | QMP_PHY_INIT_CFG(QPHY_OSC_DTCT_ACTIONS, 0x0), |
| 464 | QMP_PHY_INIT_CFG(QPHY_PWRUP_RESET_DLY_TIME_AUXCLK, 0x40), |
| 465 | QMP_PHY_INIT_CFG(QPHY_L1SS_WAKEUP_DLY_TIME_AUXCLK_MSB, 0x0), |
| 466 | QMP_PHY_INIT_CFG(QPHY_L1SS_WAKEUP_DLY_TIME_AUXCLK_LSB, 0x40), |
| 467 | QMP_PHY_INIT_CFG(QPHY_PLL_LOCK_CHK_DLY_TIME_AUXCLK_LSB, 0x0), |
| 468 | QMP_PHY_INIT_CFG(QPHY_LP_WAKEUP_DLY_TIME_AUXCLK, 0x40), |
| 469 | QMP_PHY_INIT_CFG_L(QPHY_PLL_LOCK_CHK_DLY_TIME, 0x73), |
| 470 | QMP_PHY_INIT_CFG(QPHY_RX_SIGDET_LVL, 0x99), |
| 471 | QMP_PHY_INIT_CFG(QPHY_TXDEEMPH_M6DB_V0, 0x15), |
| 472 | QMP_PHY_INIT_CFG(QPHY_TXDEEMPH_M3P5DB_V0, 0xe), |
| 473 | QMP_PHY_INIT_CFG_L(QPHY_SW_RESET, 0x0), |
| 474 | QMP_PHY_INIT_CFG_L(QPHY_START_CTRL, 0x3), |
| 475 | }; |
| 476 | |
| 477 | static const struct qmp_phy_init_tbl qmp_v3_usb3_serdes_tbl[] = { |
| 478 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_IVCO, 0x07), |
| 479 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYSCLK_EN_SEL, 0x14), |
| 480 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_BIAS_EN_CLKBUFLR_EN, 0x08), |
| 481 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_SELECT, 0x30), |
| 482 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYS_CLK_CTRL, 0x02), |
| 483 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_RESETSM_CNTRL2, 0x08), |
| 484 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CMN_CONFIG, 0x16), |
| 485 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SVS_MODE_CLK_SEL, 0x01), |
| 486 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_HSCLK_SEL, 0x80), |
| 487 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_DEC_START_MODE0, 0x82), |
| 488 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START1_MODE0, 0xab), |
| 489 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START2_MODE0, 0xea), |
| 490 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START3_MODE0, 0x02), |
| 491 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CP_CTRL_MODE0, 0x06), |
| 492 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_RCTRL_MODE0, 0x16), |
| 493 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_CCTRL_MODE0, 0x36), |
| 494 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN1_MODE0, 0x00), |
| 495 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN0_MODE0, 0x3f), |
| 496 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE2_MODE0, 0x01), |
| 497 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE1_MODE0, 0xc9), |
| 498 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CORECLK_DIV_MODE0, 0x0a), |
| 499 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP3_MODE0, 0x00), |
| 500 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP2_MODE0, 0x34), |
| 501 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP1_MODE0, 0x15), |
| 502 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP_EN, 0x04), |
| 503 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CORE_CLK_EN, 0x00), |
| 504 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP_CFG, 0x00), |
| 505 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_MAP, 0x00), |
| 506 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYSCLK_BUF_ENABLE, 0x0a), |
| 507 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_EN_CENTER, 0x01), |
| 508 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_PER1, 0x31), |
| 509 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_PER2, 0x01), |
| 510 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_ADJ_PER1, 0x00), |
| 511 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_ADJ_PER2, 0x00), |
| 512 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_STEP_SIZE1, 0x85), |
| 513 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_STEP_SIZE2, 0x07), |
| 514 | }; |
| 515 | |
| 516 | static const struct qmp_phy_init_tbl qmp_v3_usb3_tx_tbl[] = { |
| 517 | QMP_PHY_INIT_CFG(QSERDES_V3_TX_HIGHZ_DRVR_EN, 0x10), |
| 518 | QMP_PHY_INIT_CFG(QSERDES_V3_TX_RCV_DETECT_LVL_2, 0x12), |
| 519 | QMP_PHY_INIT_CFG(QSERDES_V3_TX_LANE_MODE_1, 0x16), |
| 520 | QMP_PHY_INIT_CFG(QSERDES_V3_TX_RES_CODE_LANE_OFFSET_RX, 0x09), |
| 521 | QMP_PHY_INIT_CFG(QSERDES_V3_TX_RES_CODE_LANE_OFFSET_TX, 0x06), |
| 522 | }; |
| 523 | |
| 524 | static const struct qmp_phy_init_tbl qmp_v3_usb3_rx_tbl[] = { |
| 525 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_FASTLOCK_FO_GAIN, 0x0b), |
| 526 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL2, 0x0f), |
| 527 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL3, 0x4e), |
| 528 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL4, 0x18), |
| 529 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1, 0x77), |
| 530 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_OFFSET_ADAPTOR_CNTRL2, 0x80), |
| 531 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_CNTRL, 0x03), |
| 532 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_DEGLITCH_CNTRL, 0x16), |
| 533 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x75), |
| 534 | }; |
| 535 | |
| 536 | static const struct qmp_phy_init_tbl qmp_v3_usb3_pcs_tbl[] = { |
| 537 | /* FLL settings */ |
| 538 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNTRL2, 0x83), |
| 539 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNT_VAL_L, 0x09), |
| 540 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNT_VAL_H_TOL, 0xa2), |
| 541 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_MAN_CODE, 0x40), |
| 542 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNTRL1, 0x02), |
| 543 | |
| 544 | /* Lock Det settings */ |
| 545 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_LOCK_DETECT_CONFIG1, 0xd1), |
| 546 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_LOCK_DETECT_CONFIG2, 0x1f), |
| 547 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_LOCK_DETECT_CONFIG3, 0x47), |
| 548 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_POWER_STATE_CONFIG2, 0x1b), |
| 549 | |
| 550 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_RX_SIGDET_LVL, 0xba), |
| 551 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_V0, 0x9f), |
| 552 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_V1, 0x9f), |
| 553 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_V2, 0xb7), |
| 554 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_V3, 0x4e), |
| 555 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_V4, 0x65), |
| 556 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_LS, 0x6b), |
| 557 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_V0, 0x15), |
| 558 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_V0, 0x0d), |
| 559 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_V1, 0x15), |
| 560 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_V1, 0x0d), |
| 561 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_V2, 0x15), |
| 562 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_V2, 0x0d), |
| 563 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_V3, 0x15), |
| 564 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_V3, 0x1d), |
| 565 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_V4, 0x15), |
| 566 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_V4, 0x0d), |
| 567 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_LS, 0x15), |
| 568 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_LS, 0x0d), |
| 569 | |
| 570 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_RATE_SLEW_CNTRL, 0x02), |
| 571 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_PWRUP_RESET_DLY_TIME_AUXCLK, 0x04), |
| 572 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TSYNC_RSYNC_TIME, 0x44), |
| 573 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_PWRUP_RESET_DLY_TIME_AUXCLK, 0x04), |
| 574 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_RCVR_DTCT_DLY_P1U2_L, 0xe7), |
| 575 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_RCVR_DTCT_DLY_P1U2_H, 0x03), |
| 576 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_RCVR_DTCT_DLY_U3_L, 0x40), |
| 577 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_RCVR_DTCT_DLY_U3_H, 0x00), |
| 578 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_RXEQTRAINING_WAIT_TIME, 0x75), |
| 579 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_LFPS_TX_ECSTART_EQTLOCK, 0x86), |
| 580 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_RXEQTRAINING_RUN_TIME, 0x13), |
| 581 | }; |
| 582 | |
| 583 | static const struct qmp_phy_init_tbl qmp_v3_usb3_uniphy_serdes_tbl[] = { |
| 584 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_IVCO, 0x07), |
| 585 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYSCLK_EN_SEL, 0x14), |
| 586 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_BIAS_EN_CLKBUFLR_EN, 0x04), |
| 587 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_SELECT, 0x30), |
| 588 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYS_CLK_CTRL, 0x02), |
| 589 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_RESETSM_CNTRL2, 0x08), |
| 590 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CMN_CONFIG, 0x06), |
| 591 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SVS_MODE_CLK_SEL, 0x01), |
| 592 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_HSCLK_SEL, 0x80), |
| 593 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_DEC_START_MODE0, 0x82), |
| 594 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START1_MODE0, 0xab), |
| 595 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START2_MODE0, 0xea), |
| 596 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START3_MODE0, 0x02), |
| 597 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CP_CTRL_MODE0, 0x06), |
| 598 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_RCTRL_MODE0, 0x16), |
| 599 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_CCTRL_MODE0, 0x36), |
| 600 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN1_MODE0, 0x00), |
| 601 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN0_MODE0, 0x3f), |
| 602 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE2_MODE0, 0x01), |
| 603 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE1_MODE0, 0xc9), |
| 604 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CORECLK_DIV_MODE0, 0x0a), |
| 605 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP3_MODE0, 0x00), |
| 606 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP2_MODE0, 0x34), |
| 607 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP1_MODE0, 0x15), |
| 608 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP_EN, 0x04), |
| 609 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CORE_CLK_EN, 0x00), |
| 610 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP_CFG, 0x00), |
| 611 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_MAP, 0x00), |
| 612 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYSCLK_BUF_ENABLE, 0x0a), |
| 613 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_EN_CENTER, 0x01), |
| 614 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_PER1, 0x31), |
| 615 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_PER2, 0x01), |
| 616 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_ADJ_PER1, 0x00), |
| 617 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_ADJ_PER2, 0x00), |
| 618 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_STEP_SIZE1, 0x85), |
| 619 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_STEP_SIZE2, 0x07), |
| 620 | }; |
| 621 | |
| 622 | static const struct qmp_phy_init_tbl qmp_v3_usb3_uniphy_tx_tbl[] = { |
| 623 | QMP_PHY_INIT_CFG(QSERDES_V3_TX_HIGHZ_DRVR_EN, 0x10), |
| 624 | QMP_PHY_INIT_CFG(QSERDES_V3_TX_RCV_DETECT_LVL_2, 0x12), |
| 625 | QMP_PHY_INIT_CFG(QSERDES_V3_TX_LANE_MODE_1, 0xc6), |
| 626 | QMP_PHY_INIT_CFG(QSERDES_V3_TX_RES_CODE_LANE_OFFSET_RX, 0x06), |
| 627 | QMP_PHY_INIT_CFG(QSERDES_V3_TX_RES_CODE_LANE_OFFSET_TX, 0x06), |
| 628 | }; |
| 629 | |
| 630 | static const struct qmp_phy_init_tbl qmp_v3_usb3_uniphy_rx_tbl[] = { |
| 631 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_VGA_CAL_CNTRL2, 0x0c), |
| 632 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_MODE_00, 0x50), |
| 633 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_FASTLOCK_FO_GAIN, 0x0b), |
| 634 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL2, 0x0e), |
| 635 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL3, 0x4e), |
| 636 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL4, 0x18), |
| 637 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1, 0x77), |
| 638 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_OFFSET_ADAPTOR_CNTRL2, 0x80), |
| 639 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_CNTRL, 0x03), |
| 640 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_DEGLITCH_CNTRL, 0x1c), |
| 641 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x75), |
| 642 | }; |
| 643 | |
| 644 | static const struct qmp_phy_init_tbl qmp_v3_usb3_uniphy_pcs_tbl[] = { |
| 645 | /* FLL settings */ |
| 646 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNTRL2, 0x83), |
| 647 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNT_VAL_L, 0x09), |
| 648 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNT_VAL_H_TOL, 0xa2), |
| 649 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_MAN_CODE, 0x40), |
| 650 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNTRL1, 0x02), |
| 651 | |
| 652 | /* Lock Det settings */ |
| 653 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_LOCK_DETECT_CONFIG1, 0xd1), |
| 654 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_LOCK_DETECT_CONFIG2, 0x1f), |
| 655 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_LOCK_DETECT_CONFIG3, 0x47), |
| 656 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_POWER_STATE_CONFIG2, 0x1b), |
| 657 | |
| 658 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_RX_SIGDET_LVL, 0xba), |
| 659 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_V0, 0x9f), |
| 660 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_V1, 0x9f), |
| 661 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_V2, 0xb5), |
| 662 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_V3, 0x4c), |
| 663 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_V4, 0x64), |
| 664 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_LS, 0x6a), |
| 665 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_V0, 0x15), |
| 666 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_V0, 0x0d), |
| 667 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_V1, 0x15), |
| 668 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_V1, 0x0d), |
| 669 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_V2, 0x15), |
| 670 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_V2, 0x0d), |
| 671 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_V3, 0x15), |
| 672 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_V3, 0x1d), |
| 673 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_V4, 0x15), |
| 674 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_V4, 0x0d), |
| 675 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_LS, 0x15), |
| 676 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_LS, 0x0d), |
| 677 | |
| 678 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_RATE_SLEW_CNTRL, 0x02), |
| 679 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_PWRUP_RESET_DLY_TIME_AUXCLK, 0x04), |
| 680 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TSYNC_RSYNC_TIME, 0x44), |
| 681 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_PWRUP_RESET_DLY_TIME_AUXCLK, 0x04), |
| 682 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_RCVR_DTCT_DLY_P1U2_L, 0xe7), |
| 683 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_RCVR_DTCT_DLY_P1U2_H, 0x03), |
| 684 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_RCVR_DTCT_DLY_U3_L, 0x40), |
| 685 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_RCVR_DTCT_DLY_U3_H, 0x00), |
| 686 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_RXEQTRAINING_WAIT_TIME, 0x75), |
| 687 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_LFPS_TX_ECSTART_EQTLOCK, 0x86), |
| 688 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_RXEQTRAINING_RUN_TIME, 0x13), |
| 689 | |
| 690 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_REFGEN_REQ_CONFIG1, 0x21), |
| 691 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_REFGEN_REQ_CONFIG2, 0x60), |
| 692 | }; |
| 693 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 694 | static const struct qmp_phy_init_tbl sdm845_ufsphy_serdes_tbl[] = { |
| 695 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYS_CLK_CTRL, 0x02), |
| 696 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_BIAS_EN_CLKBUFLR_EN, 0x04), |
| 697 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_BG_TIMER, 0x0a), |
| 698 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_IVCO, 0x07), |
| 699 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CMN_CONFIG, 0x06), |
| 700 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYSCLK_EN_SEL, 0xd5), |
| 701 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_RESETSM_CNTRL, 0x20), |
| 702 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_SELECT, 0x30), |
| 703 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_HSCLK_SEL, 0x00), |
| 704 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP_EN, 0x01), |
| 705 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_CTRL, 0x00), |
| 706 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CORE_CLK_EN, 0x00), |
| 707 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_MAP, 0x04), |
| 708 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SVS_MODE_CLK_SEL, 0x05), |
| 709 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_INITVAL1, 0xff), |
| 710 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_INITVAL2, 0x00), |
| 711 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_DEC_START_MODE0, 0x82), |
| 712 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CP_CTRL_MODE0, 0x06), |
| 713 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_RCTRL_MODE0, 0x16), |
| 714 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_CCTRL_MODE0, 0x36), |
| 715 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN0_MODE0, 0x3f), |
| 716 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN1_MODE0, 0x00), |
| 717 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE1_MODE0, 0xda), |
| 718 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE2_MODE0, 0x01), |
| 719 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP1_MODE0, 0xff), |
| 720 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP2_MODE0, 0x0c), |
| 721 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_DEC_START_MODE1, 0x98), |
| 722 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CP_CTRL_MODE1, 0x06), |
| 723 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_RCTRL_MODE1, 0x16), |
| 724 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_CCTRL_MODE1, 0x36), |
| 725 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN0_MODE1, 0x3f), |
| 726 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN1_MODE1, 0x00), |
| 727 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE1_MODE1, 0xc1), |
| 728 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE2_MODE1, 0x00), |
| 729 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP1_MODE1, 0x32), |
| 730 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP2_MODE1, 0x0f), |
| 731 | |
| 732 | /* Rate B */ |
| 733 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_MAP, 0x44), |
| 734 | }; |
| 735 | |
| 736 | static const struct qmp_phy_init_tbl sdm845_ufsphy_tx_tbl[] = { |
| 737 | QMP_PHY_INIT_CFG(QSERDES_V3_TX_LANE_MODE_1, 0x06), |
| 738 | QMP_PHY_INIT_CFG(QSERDES_V3_TX_RES_CODE_LANE_OFFSET_TX, 0x04), |
| 739 | QMP_PHY_INIT_CFG(QSERDES_V3_TX_RES_CODE_LANE_OFFSET_RX, 0x07), |
| 740 | }; |
| 741 | |
| 742 | static const struct qmp_phy_init_tbl sdm845_ufsphy_rx_tbl[] = { |
| 743 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_LVL, 0x24), |
| 744 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_CNTRL, 0x0f), |
| 745 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_DEGLITCH_CNTRL, 0x1e), |
| 746 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_INTERFACE_MODE, 0x40), |
| 747 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_FASTLOCK_FO_GAIN, 0x0b), |
| 748 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_TERM_BW, 0x5b), |
| 749 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL2, 0x06), |
| 750 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL3, 0x04), |
| 751 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL4, 0x1b), |
| 752 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SVS_SO_GAIN_HALF, 0x04), |
| 753 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SVS_SO_GAIN_QUARTER, 0x04), |
| 754 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SVS_SO_GAIN, 0x04), |
| 755 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x4b), |
| 756 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_PI_CONTROLS, 0x81), |
| 757 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_FASTLOCK_COUNT_LOW, 0x80), |
| 758 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_MODE_00, 0x59), |
| 759 | }; |
| 760 | |
| 761 | static const struct qmp_phy_init_tbl sdm845_ufsphy_pcs_tbl[] = { |
| 762 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_RX_SIGDET_CTRL2, 0x6e), |
| 763 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TX_LARGE_AMP_DRV_LVL, 0x0a), |
| 764 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TX_SMALL_AMP_DRV_LVL, 0x02), |
| 765 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_RX_SYM_RESYNC_CTRL, 0x03), |
| 766 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TX_MID_TERM_CTRL1, 0x43), |
| 767 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_RX_SIGDET_CTRL1, 0x0f), |
| 768 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_RX_MIN_HIBERN8_TIME, 0x9a), |
| 769 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_MULTI_LANE_CTRL1, 0x02), |
| 770 | }; |
| 771 | |
| 772 | static const struct qmp_phy_init_tbl msm8998_usb3_serdes_tbl[] = { |
| 773 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_SELECT, 0x30), |
| 774 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_BIAS_EN_CLKBUFLR_EN, 0x04), |
| 775 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYSCLK_EN_SEL, 0x14), |
| 776 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYS_CLK_CTRL, 0x06), |
| 777 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_RESETSM_CNTRL2, 0x08), |
| 778 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CMN_CONFIG, 0x06), |
| 779 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SVS_MODE_CLK_SEL, 0x01), |
| 780 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_HSCLK_SEL, 0x80), |
| 781 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_DEC_START_MODE0, 0x82), |
| 782 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START1_MODE0, 0xab), |
| 783 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START2_MODE0, 0xea), |
| 784 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START3_MODE0, 0x02), |
| 785 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CP_CTRL_MODE0, 0x06), |
| 786 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_RCTRL_MODE0, 0x16), |
| 787 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_CCTRL_MODE0, 0x36), |
| 788 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN1_MODE0, 0x00), |
| 789 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN0_MODE0, 0x3f), |
| 790 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE2_MODE0, 0x01), |
| 791 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE1_MODE0, 0xc9), |
| 792 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CORECLK_DIV_MODE0, 0x0a), |
| 793 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP3_MODE0, 0x00), |
| 794 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP2_MODE0, 0x34), |
| 795 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP1_MODE0, 0x15), |
| 796 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP_EN, 0x04), |
| 797 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CORE_CLK_EN, 0x00), |
| 798 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP_CFG, 0x00), |
| 799 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_MAP, 0x00), |
| 800 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_BG_TIMER, 0x0a), |
| 801 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_IVCO, 0x07), |
| 802 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_INITVAL, 0x80), |
| 803 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CMN_MODE, 0x01), |
| 804 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_EN_CENTER, 0x01), |
| 805 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_PER1, 0x31), |
| 806 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_PER2, 0x01), |
| 807 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_ADJ_PER1, 0x00), |
| 808 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_ADJ_PER2, 0x00), |
| 809 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_STEP_SIZE1, 0x85), |
| 810 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_STEP_SIZE2, 0x07), |
| 811 | }; |
| 812 | |
| 813 | static const struct qmp_phy_init_tbl msm8998_usb3_tx_tbl[] = { |
| 814 | QMP_PHY_INIT_CFG(QSERDES_V3_TX_HIGHZ_DRVR_EN, 0x10), |
| 815 | QMP_PHY_INIT_CFG(QSERDES_V3_TX_RCV_DETECT_LVL_2, 0x12), |
| 816 | QMP_PHY_INIT_CFG(QSERDES_V3_TX_LANE_MODE_1, 0x16), |
| 817 | QMP_PHY_INIT_CFG(QSERDES_V3_TX_RES_CODE_LANE_OFFSET_TX, 0x00), |
| 818 | }; |
| 819 | |
| 820 | static const struct qmp_phy_init_tbl msm8998_usb3_rx_tbl[] = { |
| 821 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_FASTLOCK_FO_GAIN, 0x0b), |
| 822 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL2, 0x0f), |
| 823 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL3, 0x4e), |
| 824 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL4, 0x18), |
| 825 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1, 0x07), |
| 826 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_OFFSET_ADAPTOR_CNTRL2, 0x80), |
| 827 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_CNTRL, 0x43), |
| 828 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_DEGLITCH_CNTRL, 0x1c), |
| 829 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x75), |
| 830 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_FASTLOCK_COUNT_LOW, 0x00), |
| 831 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_FASTLOCK_COUNT_HIGH, 0x00), |
| 832 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_PI_CONTROLS, 0x80), |
| 833 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_FO_GAIN, 0x0a), |
| 834 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SO_GAIN, 0x06), |
| 835 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_ENABLES, 0x00), |
| 836 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_VGA_CAL_CNTRL2, 0x03), |
| 837 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_MODE_00, 0x05), |
| 838 | }; |
| 839 | |
| 840 | static const struct qmp_phy_init_tbl msm8998_usb3_pcs_tbl[] = { |
| 841 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNTRL2, 0x83), |
| 842 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNT_VAL_L, 0x09), |
| 843 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNT_VAL_H_TOL, 0xa2), |
| 844 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_MAN_CODE, 0x40), |
| 845 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNTRL1, 0x02), |
| 846 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_LOCK_DETECT_CONFIG1, 0xd1), |
| 847 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_LOCK_DETECT_CONFIG2, 0x1f), |
| 848 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_LOCK_DETECT_CONFIG3, 0x47), |
| 849 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_POWER_STATE_CONFIG2, 0x1b), |
| 850 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_V0, 0x9f), |
| 851 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_V1, 0x9f), |
| 852 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_V2, 0xb7), |
| 853 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_V3, 0x4e), |
| 854 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_V4, 0x65), |
| 855 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_LS, 0x6b), |
| 856 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_V0, 0x15), |
| 857 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_V0, 0x0d), |
| 858 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TX_LARGE_AMP_DRV_LVL, 0x15), |
| 859 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_V1, 0x0d), |
| 860 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_V2, 0x15), |
| 861 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_V2, 0x0d), |
| 862 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_V3, 0x15), |
| 863 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_V3, 0x0d), |
| 864 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_V4, 0x15), |
| 865 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_V4, 0x0d), |
| 866 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_LS, 0x15), |
| 867 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_LS, 0x0d), |
| 868 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_RATE_SLEW_CNTRL, 0x02), |
| 869 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_PWRUP_RESET_DLY_TIME_AUXCLK, 0x04), |
| 870 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TSYNC_RSYNC_TIME, 0x44), |
| 871 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_RCVR_DTCT_DLY_P1U2_L, 0xe7), |
| 872 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_RCVR_DTCT_DLY_P1U2_H, 0x03), |
| 873 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_RCVR_DTCT_DLY_U3_L, 0x40), |
| 874 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_RCVR_DTCT_DLY_U3_H, 0x00), |
| 875 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_RX_SIGDET_LVL, 0x8a), |
| 876 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_RXEQTRAINING_WAIT_TIME, 0x75), |
| 877 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_LFPS_TX_ECSTART_EQTLOCK, 0x86), |
| 878 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_RXEQTRAINING_RUN_TIME, 0x13), |
| 879 | }; |
| 880 | |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 881 | |
| 882 | /* struct qmp_phy_cfg - per-PHY initialization config */ |
| 883 | struct qmp_phy_cfg { |
| 884 | /* phy-type - PCIE/UFS/USB */ |
| 885 | unsigned int type; |
| 886 | /* number of lanes provided by phy */ |
| 887 | int nlanes; |
| 888 | |
| 889 | /* Init sequence for PHY blocks - serdes, tx, rx, pcs */ |
| 890 | const struct qmp_phy_init_tbl *serdes_tbl; |
| 891 | int serdes_tbl_num; |
| 892 | const struct qmp_phy_init_tbl *tx_tbl; |
| 893 | int tx_tbl_num; |
| 894 | const struct qmp_phy_init_tbl *rx_tbl; |
| 895 | int rx_tbl_num; |
| 896 | const struct qmp_phy_init_tbl *pcs_tbl; |
| 897 | int pcs_tbl_num; |
| 898 | |
| 899 | /* clock ids to be requested */ |
| 900 | const char * const *clk_list; |
| 901 | int num_clks; |
| 902 | /* resets to be requested */ |
| 903 | const char * const *reset_list; |
| 904 | int num_resets; |
| 905 | /* regulators to be requested */ |
| 906 | const char * const *vreg_list; |
| 907 | int num_vregs; |
| 908 | |
| 909 | /* array of registers with different offsets */ |
| 910 | const unsigned int *regs; |
| 911 | |
| 912 | unsigned int start_ctrl; |
| 913 | unsigned int pwrdn_ctrl; |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 914 | unsigned int mask_com_pcs_ready; |
| 915 | |
| 916 | /* true, if PHY has a separate PHY_COM control block */ |
| 917 | bool has_phy_com_ctrl; |
| 918 | /* true, if PHY has a reset for individual lanes */ |
| 919 | bool has_lane_rst; |
| 920 | /* true, if PHY needs delay after POWER_DOWN */ |
| 921 | bool has_pwrdn_delay; |
| 922 | /* power_down delay in usec */ |
| 923 | int pwrdn_delay_min; |
| 924 | int pwrdn_delay_max; |
| 925 | |
| 926 | /* true, if PHY has a separate DP_COM control block */ |
| 927 | bool has_phy_dp_com_ctrl; |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 928 | /* true, if PHY has secondary tx/rx lanes to be configured */ |
| 929 | bool is_dual_lane_phy; |
| 930 | |
| 931 | /* true, if PCS block has no separate SW_RESET register */ |
| 932 | bool no_pcs_sw_reset; |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 933 | }; |
| 934 | |
| 935 | /** |
| 936 | * struct qmp_phy - per-lane phy descriptor |
| 937 | * |
| 938 | * @phy: generic phy |
| 939 | * @tx: iomapped memory space for lane's tx |
| 940 | * @rx: iomapped memory space for lane's rx |
| 941 | * @pcs: iomapped memory space for lane's pcs |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 942 | * @tx2: iomapped memory space for second lane's tx (in dual lane PHYs) |
| 943 | * @rx2: iomapped memory space for second lane's rx (in dual lane PHYs) |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 944 | * @pcs_misc: iomapped memory space for lane's pcs_misc |
| 945 | * @pipe_clk: pipe lock |
| 946 | * @index: lane index |
| 947 | * @qmp: QMP phy to which this lane belongs |
| 948 | * @lane_rst: lane's reset controller |
| 949 | */ |
| 950 | struct qmp_phy { |
| 951 | struct phy *phy; |
| 952 | void __iomem *tx; |
| 953 | void __iomem *rx; |
| 954 | void __iomem *pcs; |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 955 | void __iomem *tx2; |
| 956 | void __iomem *rx2; |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 957 | void __iomem *pcs_misc; |
| 958 | struct clk *pipe_clk; |
| 959 | unsigned int index; |
| 960 | struct qcom_qmp *qmp; |
| 961 | struct reset_control *lane_rst; |
| 962 | }; |
| 963 | |
| 964 | /** |
| 965 | * struct qcom_qmp - structure holding QMP phy block attributes |
| 966 | * |
| 967 | * @dev: device |
| 968 | * @serdes: iomapped memory space for phy's serdes |
| 969 | * @dp_com: iomapped memory space for phy's dp_com control block |
| 970 | * |
| 971 | * @clks: array of clocks required by phy |
| 972 | * @resets: array of resets required by phy |
| 973 | * @vregs: regulator supplies bulk data |
| 974 | * |
| 975 | * @cfg: phy specific configuration |
| 976 | * @phys: array of per-lane phy descriptors |
| 977 | * @phy_mutex: mutex lock for PHY common block initialization |
| 978 | * @init_count: phy common block initialization count |
| 979 | * @phy_initialized: indicate if PHY has been initialized |
| 980 | * @mode: current PHY mode |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 981 | * @ufs_reset: optional UFS PHY reset handle |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 982 | */ |
| 983 | struct qcom_qmp { |
| 984 | struct device *dev; |
| 985 | void __iomem *serdes; |
| 986 | void __iomem *dp_com; |
| 987 | |
| 988 | struct clk_bulk_data *clks; |
| 989 | struct reset_control **resets; |
| 990 | struct regulator_bulk_data *vregs; |
| 991 | |
| 992 | const struct qmp_phy_cfg *cfg; |
| 993 | struct qmp_phy **phys; |
| 994 | |
| 995 | struct mutex phy_mutex; |
| 996 | int init_count; |
| 997 | bool phy_initialized; |
| 998 | enum phy_mode mode; |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 999 | |
| 1000 | struct reset_control *ufs_reset; |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1001 | }; |
| 1002 | |
| 1003 | static inline void qphy_setbits(void __iomem *base, u32 offset, u32 val) |
| 1004 | { |
| 1005 | u32 reg; |
| 1006 | |
| 1007 | reg = readl(base + offset); |
| 1008 | reg |= val; |
| 1009 | writel(reg, base + offset); |
| 1010 | |
| 1011 | /* ensure that above write is through */ |
| 1012 | readl(base + offset); |
| 1013 | } |
| 1014 | |
| 1015 | static inline void qphy_clrbits(void __iomem *base, u32 offset, u32 val) |
| 1016 | { |
| 1017 | u32 reg; |
| 1018 | |
| 1019 | reg = readl(base + offset); |
| 1020 | reg &= ~val; |
| 1021 | writel(reg, base + offset); |
| 1022 | |
| 1023 | /* ensure that above write is through */ |
| 1024 | readl(base + offset); |
| 1025 | } |
| 1026 | |
| 1027 | /* list of clocks required by phy */ |
| 1028 | static const char * const msm8996_phy_clk_l[] = { |
| 1029 | "aux", "cfg_ahb", "ref", |
| 1030 | }; |
| 1031 | |
| 1032 | static const char * const qmp_v3_phy_clk_l[] = { |
| 1033 | "aux", "cfg_ahb", "ref", "com_aux", |
| 1034 | }; |
| 1035 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1036 | static const char * const sdm845_ufs_phy_clk_l[] = { |
| 1037 | "ref", "ref_aux", |
| 1038 | }; |
| 1039 | |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1040 | /* list of resets */ |
| 1041 | static const char * const msm8996_pciephy_reset_l[] = { |
| 1042 | "phy", "common", "cfg", |
| 1043 | }; |
| 1044 | |
| 1045 | static const char * const msm8996_usb3phy_reset_l[] = { |
| 1046 | "phy", "common", |
| 1047 | }; |
| 1048 | |
| 1049 | /* list of regulators */ |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1050 | static const char * const qmp_phy_vreg_l[] = { |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1051 | "vdda-phy", "vdda-pll", |
| 1052 | }; |
| 1053 | |
| 1054 | static const struct qmp_phy_cfg msm8996_pciephy_cfg = { |
| 1055 | .type = PHY_TYPE_PCIE, |
| 1056 | .nlanes = 3, |
| 1057 | |
| 1058 | .serdes_tbl = msm8996_pcie_serdes_tbl, |
| 1059 | .serdes_tbl_num = ARRAY_SIZE(msm8996_pcie_serdes_tbl), |
| 1060 | .tx_tbl = msm8996_pcie_tx_tbl, |
| 1061 | .tx_tbl_num = ARRAY_SIZE(msm8996_pcie_tx_tbl), |
| 1062 | .rx_tbl = msm8996_pcie_rx_tbl, |
| 1063 | .rx_tbl_num = ARRAY_SIZE(msm8996_pcie_rx_tbl), |
| 1064 | .pcs_tbl = msm8996_pcie_pcs_tbl, |
| 1065 | .pcs_tbl_num = ARRAY_SIZE(msm8996_pcie_pcs_tbl), |
| 1066 | .clk_list = msm8996_phy_clk_l, |
| 1067 | .num_clks = ARRAY_SIZE(msm8996_phy_clk_l), |
| 1068 | .reset_list = msm8996_pciephy_reset_l, |
| 1069 | .num_resets = ARRAY_SIZE(msm8996_pciephy_reset_l), |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1070 | .vreg_list = qmp_phy_vreg_l, |
| 1071 | .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1072 | .regs = pciephy_regs_layout, |
| 1073 | |
| 1074 | .start_ctrl = PCS_START | PLL_READY_GATE_EN, |
| 1075 | .pwrdn_ctrl = SW_PWRDN | REFCLK_DRV_DSBL, |
| 1076 | .mask_com_pcs_ready = PCS_READY, |
| 1077 | |
| 1078 | .has_phy_com_ctrl = true, |
| 1079 | .has_lane_rst = true, |
| 1080 | .has_pwrdn_delay = true, |
| 1081 | .pwrdn_delay_min = POWER_DOWN_DELAY_US_MIN, |
| 1082 | .pwrdn_delay_max = POWER_DOWN_DELAY_US_MAX, |
| 1083 | }; |
| 1084 | |
| 1085 | static const struct qmp_phy_cfg msm8996_usb3phy_cfg = { |
| 1086 | .type = PHY_TYPE_USB3, |
| 1087 | .nlanes = 1, |
| 1088 | |
| 1089 | .serdes_tbl = msm8996_usb3_serdes_tbl, |
| 1090 | .serdes_tbl_num = ARRAY_SIZE(msm8996_usb3_serdes_tbl), |
| 1091 | .tx_tbl = msm8996_usb3_tx_tbl, |
| 1092 | .tx_tbl_num = ARRAY_SIZE(msm8996_usb3_tx_tbl), |
| 1093 | .rx_tbl = msm8996_usb3_rx_tbl, |
| 1094 | .rx_tbl_num = ARRAY_SIZE(msm8996_usb3_rx_tbl), |
| 1095 | .pcs_tbl = msm8996_usb3_pcs_tbl, |
| 1096 | .pcs_tbl_num = ARRAY_SIZE(msm8996_usb3_pcs_tbl), |
| 1097 | .clk_list = msm8996_phy_clk_l, |
| 1098 | .num_clks = ARRAY_SIZE(msm8996_phy_clk_l), |
| 1099 | .reset_list = msm8996_usb3phy_reset_l, |
| 1100 | .num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l), |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1101 | .vreg_list = qmp_phy_vreg_l, |
| 1102 | .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1103 | .regs = usb3phy_regs_layout, |
| 1104 | |
| 1105 | .start_ctrl = SERDES_START | PCS_START, |
| 1106 | .pwrdn_ctrl = SW_PWRDN, |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1107 | }; |
| 1108 | |
Olivier Deprez | 0e64123 | 2021-09-23 10:07:05 +0200 | [diff] [blame^] | 1109 | static const char * const ipq8074_pciephy_clk_l[] = { |
| 1110 | "aux", "cfg_ahb", |
| 1111 | }; |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1112 | /* list of resets */ |
| 1113 | static const char * const ipq8074_pciephy_reset_l[] = { |
| 1114 | "phy", "common", |
| 1115 | }; |
| 1116 | |
| 1117 | static const struct qmp_phy_cfg ipq8074_pciephy_cfg = { |
| 1118 | .type = PHY_TYPE_PCIE, |
| 1119 | .nlanes = 1, |
| 1120 | |
| 1121 | .serdes_tbl = ipq8074_pcie_serdes_tbl, |
| 1122 | .serdes_tbl_num = ARRAY_SIZE(ipq8074_pcie_serdes_tbl), |
| 1123 | .tx_tbl = ipq8074_pcie_tx_tbl, |
| 1124 | .tx_tbl_num = ARRAY_SIZE(ipq8074_pcie_tx_tbl), |
| 1125 | .rx_tbl = ipq8074_pcie_rx_tbl, |
| 1126 | .rx_tbl_num = ARRAY_SIZE(ipq8074_pcie_rx_tbl), |
| 1127 | .pcs_tbl = ipq8074_pcie_pcs_tbl, |
| 1128 | .pcs_tbl_num = ARRAY_SIZE(ipq8074_pcie_pcs_tbl), |
Olivier Deprez | 0e64123 | 2021-09-23 10:07:05 +0200 | [diff] [blame^] | 1129 | .clk_list = ipq8074_pciephy_clk_l, |
| 1130 | .num_clks = ARRAY_SIZE(ipq8074_pciephy_clk_l), |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1131 | .reset_list = ipq8074_pciephy_reset_l, |
| 1132 | .num_resets = ARRAY_SIZE(ipq8074_pciephy_reset_l), |
| 1133 | .vreg_list = NULL, |
| 1134 | .num_vregs = 0, |
| 1135 | .regs = pciephy_regs_layout, |
| 1136 | |
| 1137 | .start_ctrl = SERDES_START | PCS_START, |
| 1138 | .pwrdn_ctrl = SW_PWRDN | REFCLK_DRV_DSBL, |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1139 | |
| 1140 | .has_phy_com_ctrl = false, |
| 1141 | .has_lane_rst = false, |
| 1142 | .has_pwrdn_delay = true, |
| 1143 | .pwrdn_delay_min = 995, /* us */ |
| 1144 | .pwrdn_delay_max = 1005, /* us */ |
| 1145 | }; |
| 1146 | |
| 1147 | static const struct qmp_phy_cfg qmp_v3_usb3phy_cfg = { |
| 1148 | .type = PHY_TYPE_USB3, |
| 1149 | .nlanes = 1, |
| 1150 | |
| 1151 | .serdes_tbl = qmp_v3_usb3_serdes_tbl, |
| 1152 | .serdes_tbl_num = ARRAY_SIZE(qmp_v3_usb3_serdes_tbl), |
| 1153 | .tx_tbl = qmp_v3_usb3_tx_tbl, |
| 1154 | .tx_tbl_num = ARRAY_SIZE(qmp_v3_usb3_tx_tbl), |
| 1155 | .rx_tbl = qmp_v3_usb3_rx_tbl, |
| 1156 | .rx_tbl_num = ARRAY_SIZE(qmp_v3_usb3_rx_tbl), |
| 1157 | .pcs_tbl = qmp_v3_usb3_pcs_tbl, |
| 1158 | .pcs_tbl_num = ARRAY_SIZE(qmp_v3_usb3_pcs_tbl), |
| 1159 | .clk_list = qmp_v3_phy_clk_l, |
| 1160 | .num_clks = ARRAY_SIZE(qmp_v3_phy_clk_l), |
| 1161 | .reset_list = msm8996_usb3phy_reset_l, |
| 1162 | .num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l), |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1163 | .vreg_list = qmp_phy_vreg_l, |
| 1164 | .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1165 | .regs = qmp_v3_usb3phy_regs_layout, |
| 1166 | |
| 1167 | .start_ctrl = SERDES_START | PCS_START, |
| 1168 | .pwrdn_ctrl = SW_PWRDN, |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1169 | |
| 1170 | .has_pwrdn_delay = true, |
| 1171 | .pwrdn_delay_min = POWER_DOWN_DELAY_US_MIN, |
| 1172 | .pwrdn_delay_max = POWER_DOWN_DELAY_US_MAX, |
| 1173 | |
| 1174 | .has_phy_dp_com_ctrl = true, |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1175 | .is_dual_lane_phy = true, |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1176 | }; |
| 1177 | |
| 1178 | static const struct qmp_phy_cfg qmp_v3_usb3_uniphy_cfg = { |
| 1179 | .type = PHY_TYPE_USB3, |
| 1180 | .nlanes = 1, |
| 1181 | |
| 1182 | .serdes_tbl = qmp_v3_usb3_uniphy_serdes_tbl, |
| 1183 | .serdes_tbl_num = ARRAY_SIZE(qmp_v3_usb3_uniphy_serdes_tbl), |
| 1184 | .tx_tbl = qmp_v3_usb3_uniphy_tx_tbl, |
| 1185 | .tx_tbl_num = ARRAY_SIZE(qmp_v3_usb3_uniphy_tx_tbl), |
| 1186 | .rx_tbl = qmp_v3_usb3_uniphy_rx_tbl, |
| 1187 | .rx_tbl_num = ARRAY_SIZE(qmp_v3_usb3_uniphy_rx_tbl), |
| 1188 | .pcs_tbl = qmp_v3_usb3_uniphy_pcs_tbl, |
| 1189 | .pcs_tbl_num = ARRAY_SIZE(qmp_v3_usb3_uniphy_pcs_tbl), |
| 1190 | .clk_list = qmp_v3_phy_clk_l, |
| 1191 | .num_clks = ARRAY_SIZE(qmp_v3_phy_clk_l), |
| 1192 | .reset_list = msm8996_usb3phy_reset_l, |
| 1193 | .num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l), |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1194 | .vreg_list = qmp_phy_vreg_l, |
| 1195 | .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1196 | .regs = qmp_v3_usb3phy_regs_layout, |
| 1197 | |
| 1198 | .start_ctrl = SERDES_START | PCS_START, |
| 1199 | .pwrdn_ctrl = SW_PWRDN, |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1200 | |
| 1201 | .has_pwrdn_delay = true, |
| 1202 | .pwrdn_delay_min = POWER_DOWN_DELAY_US_MIN, |
| 1203 | .pwrdn_delay_max = POWER_DOWN_DELAY_US_MAX, |
| 1204 | }; |
| 1205 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1206 | static const struct qmp_phy_cfg sdm845_ufsphy_cfg = { |
| 1207 | .type = PHY_TYPE_UFS, |
| 1208 | .nlanes = 2, |
| 1209 | |
| 1210 | .serdes_tbl = sdm845_ufsphy_serdes_tbl, |
| 1211 | .serdes_tbl_num = ARRAY_SIZE(sdm845_ufsphy_serdes_tbl), |
| 1212 | .tx_tbl = sdm845_ufsphy_tx_tbl, |
| 1213 | .tx_tbl_num = ARRAY_SIZE(sdm845_ufsphy_tx_tbl), |
| 1214 | .rx_tbl = sdm845_ufsphy_rx_tbl, |
| 1215 | .rx_tbl_num = ARRAY_SIZE(sdm845_ufsphy_rx_tbl), |
| 1216 | .pcs_tbl = sdm845_ufsphy_pcs_tbl, |
| 1217 | .pcs_tbl_num = ARRAY_SIZE(sdm845_ufsphy_pcs_tbl), |
| 1218 | .clk_list = sdm845_ufs_phy_clk_l, |
| 1219 | .num_clks = ARRAY_SIZE(sdm845_ufs_phy_clk_l), |
| 1220 | .vreg_list = qmp_phy_vreg_l, |
| 1221 | .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), |
| 1222 | .regs = sdm845_ufsphy_regs_layout, |
| 1223 | |
| 1224 | .start_ctrl = SERDES_START, |
| 1225 | .pwrdn_ctrl = SW_PWRDN, |
| 1226 | |
| 1227 | .is_dual_lane_phy = true, |
| 1228 | .no_pcs_sw_reset = true, |
| 1229 | }; |
| 1230 | |
| 1231 | static const struct qmp_phy_cfg msm8998_pciephy_cfg = { |
| 1232 | .type = PHY_TYPE_PCIE, |
| 1233 | .nlanes = 1, |
| 1234 | |
| 1235 | .serdes_tbl = msm8998_pcie_serdes_tbl, |
| 1236 | .serdes_tbl_num = ARRAY_SIZE(msm8998_pcie_serdes_tbl), |
| 1237 | .tx_tbl = msm8998_pcie_tx_tbl, |
| 1238 | .tx_tbl_num = ARRAY_SIZE(msm8998_pcie_tx_tbl), |
| 1239 | .rx_tbl = msm8998_pcie_rx_tbl, |
| 1240 | .rx_tbl_num = ARRAY_SIZE(msm8998_pcie_rx_tbl), |
| 1241 | .pcs_tbl = msm8998_pcie_pcs_tbl, |
| 1242 | .pcs_tbl_num = ARRAY_SIZE(msm8998_pcie_pcs_tbl), |
| 1243 | .clk_list = msm8996_phy_clk_l, |
| 1244 | .num_clks = ARRAY_SIZE(msm8996_phy_clk_l), |
| 1245 | .reset_list = ipq8074_pciephy_reset_l, |
| 1246 | .num_resets = ARRAY_SIZE(ipq8074_pciephy_reset_l), |
| 1247 | .vreg_list = qmp_phy_vreg_l, |
| 1248 | .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), |
| 1249 | .regs = pciephy_regs_layout, |
| 1250 | |
| 1251 | .start_ctrl = SERDES_START | PCS_START, |
| 1252 | .pwrdn_ctrl = SW_PWRDN | REFCLK_DRV_DSBL, |
| 1253 | }; |
| 1254 | |
| 1255 | static const struct qmp_phy_cfg msm8998_usb3phy_cfg = { |
| 1256 | .type = PHY_TYPE_USB3, |
| 1257 | .nlanes = 1, |
| 1258 | |
| 1259 | .serdes_tbl = msm8998_usb3_serdes_tbl, |
| 1260 | .serdes_tbl_num = ARRAY_SIZE(msm8998_usb3_serdes_tbl), |
| 1261 | .tx_tbl = msm8998_usb3_tx_tbl, |
| 1262 | .tx_tbl_num = ARRAY_SIZE(msm8998_usb3_tx_tbl), |
| 1263 | .rx_tbl = msm8998_usb3_rx_tbl, |
| 1264 | .rx_tbl_num = ARRAY_SIZE(msm8998_usb3_rx_tbl), |
| 1265 | .pcs_tbl = msm8998_usb3_pcs_tbl, |
| 1266 | .pcs_tbl_num = ARRAY_SIZE(msm8998_usb3_pcs_tbl), |
| 1267 | .clk_list = msm8996_phy_clk_l, |
| 1268 | .num_clks = ARRAY_SIZE(msm8996_phy_clk_l), |
| 1269 | .reset_list = msm8996_usb3phy_reset_l, |
| 1270 | .num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l), |
| 1271 | .vreg_list = qmp_phy_vreg_l, |
| 1272 | .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), |
| 1273 | .regs = qmp_v3_usb3phy_regs_layout, |
| 1274 | |
| 1275 | .start_ctrl = SERDES_START | PCS_START, |
| 1276 | .pwrdn_ctrl = SW_PWRDN, |
| 1277 | |
| 1278 | .is_dual_lane_phy = true, |
| 1279 | }; |
| 1280 | |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1281 | static void qcom_qmp_phy_configure(void __iomem *base, |
| 1282 | const unsigned int *regs, |
| 1283 | const struct qmp_phy_init_tbl tbl[], |
| 1284 | int num) |
| 1285 | { |
| 1286 | int i; |
| 1287 | const struct qmp_phy_init_tbl *t = tbl; |
| 1288 | |
| 1289 | if (!t) |
| 1290 | return; |
| 1291 | |
| 1292 | for (i = 0; i < num; i++, t++) { |
| 1293 | if (t->in_layout) |
| 1294 | writel(t->val, base + regs[t->offset]); |
| 1295 | else |
| 1296 | writel(t->val, base + t->offset); |
| 1297 | } |
| 1298 | } |
| 1299 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1300 | static int qcom_qmp_phy_com_init(struct qmp_phy *qphy) |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1301 | { |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1302 | struct qcom_qmp *qmp = qphy->qmp; |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1303 | const struct qmp_phy_cfg *cfg = qmp->cfg; |
| 1304 | void __iomem *serdes = qmp->serdes; |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1305 | void __iomem *pcs = qphy->pcs; |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1306 | void __iomem *dp_com = qmp->dp_com; |
| 1307 | int ret, i; |
| 1308 | |
| 1309 | mutex_lock(&qmp->phy_mutex); |
| 1310 | if (qmp->init_count++) { |
| 1311 | mutex_unlock(&qmp->phy_mutex); |
| 1312 | return 0; |
| 1313 | } |
| 1314 | |
| 1315 | /* turn on regulator supplies */ |
| 1316 | ret = regulator_bulk_enable(cfg->num_vregs, qmp->vregs); |
| 1317 | if (ret) { |
| 1318 | dev_err(qmp->dev, "failed to enable regulators, err=%d\n", ret); |
| 1319 | goto err_reg_enable; |
| 1320 | } |
| 1321 | |
| 1322 | for (i = 0; i < cfg->num_resets; i++) { |
| 1323 | ret = reset_control_assert(qmp->resets[i]); |
| 1324 | if (ret) { |
| 1325 | dev_err(qmp->dev, "%s reset assert failed\n", |
| 1326 | cfg->reset_list[i]); |
| 1327 | goto err_rst_assert; |
| 1328 | } |
| 1329 | } |
| 1330 | |
| 1331 | for (i = cfg->num_resets - 1; i >= 0; i--) { |
| 1332 | ret = reset_control_deassert(qmp->resets[i]); |
| 1333 | if (ret) { |
| 1334 | dev_err(qmp->dev, "%s reset deassert failed\n", |
| 1335 | qmp->cfg->reset_list[i]); |
| 1336 | goto err_rst; |
| 1337 | } |
| 1338 | } |
| 1339 | |
| 1340 | ret = clk_bulk_prepare_enable(cfg->num_clks, qmp->clks); |
| 1341 | if (ret) { |
| 1342 | dev_err(qmp->dev, "failed to enable clks, err=%d\n", ret); |
| 1343 | goto err_rst; |
| 1344 | } |
| 1345 | |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1346 | if (cfg->has_phy_dp_com_ctrl) { |
| 1347 | qphy_setbits(dp_com, QPHY_V3_DP_COM_POWER_DOWN_CTRL, |
| 1348 | SW_PWRDN); |
| 1349 | /* override hardware control for reset of qmp phy */ |
| 1350 | qphy_setbits(dp_com, QPHY_V3_DP_COM_RESET_OVRD_CTRL, |
| 1351 | SW_DPPHY_RESET_MUX | SW_DPPHY_RESET | |
| 1352 | SW_USB3PHY_RESET_MUX | SW_USB3PHY_RESET); |
| 1353 | |
| 1354 | qphy_setbits(dp_com, QPHY_V3_DP_COM_PHY_MODE_CTRL, |
| 1355 | USB3_MODE | DP_MODE); |
| 1356 | |
| 1357 | /* bring both QMP USB and QMP DP PHYs PCS block out of reset */ |
| 1358 | qphy_clrbits(dp_com, QPHY_V3_DP_COM_RESET_OVRD_CTRL, |
| 1359 | SW_DPPHY_RESET_MUX | SW_DPPHY_RESET | |
| 1360 | SW_USB3PHY_RESET_MUX | SW_USB3PHY_RESET); |
| 1361 | } |
| 1362 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1363 | if (cfg->has_phy_com_ctrl) |
| 1364 | qphy_setbits(serdes, cfg->regs[QPHY_COM_POWER_DOWN_CONTROL], |
| 1365 | SW_PWRDN); |
| 1366 | else |
| 1367 | qphy_setbits(pcs, QPHY_POWER_DOWN_CONTROL, cfg->pwrdn_ctrl); |
| 1368 | |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1369 | /* Serdes configuration */ |
| 1370 | qcom_qmp_phy_configure(serdes, cfg->regs, cfg->serdes_tbl, |
| 1371 | cfg->serdes_tbl_num); |
| 1372 | |
| 1373 | if (cfg->has_phy_com_ctrl) { |
| 1374 | void __iomem *status; |
| 1375 | unsigned int mask, val; |
| 1376 | |
| 1377 | qphy_clrbits(serdes, cfg->regs[QPHY_COM_SW_RESET], SW_RESET); |
| 1378 | qphy_setbits(serdes, cfg->regs[QPHY_COM_START_CONTROL], |
| 1379 | SERDES_START | PCS_START); |
| 1380 | |
| 1381 | status = serdes + cfg->regs[QPHY_COM_PCS_READY_STATUS]; |
| 1382 | mask = cfg->mask_com_pcs_ready; |
| 1383 | |
| 1384 | ret = readl_poll_timeout(status, val, (val & mask), 10, |
| 1385 | PHY_INIT_COMPLETE_TIMEOUT); |
| 1386 | if (ret) { |
| 1387 | dev_err(qmp->dev, |
| 1388 | "phy common block init timed-out\n"); |
| 1389 | goto err_com_init; |
| 1390 | } |
| 1391 | } |
| 1392 | |
| 1393 | mutex_unlock(&qmp->phy_mutex); |
| 1394 | |
| 1395 | return 0; |
| 1396 | |
| 1397 | err_com_init: |
| 1398 | clk_bulk_disable_unprepare(cfg->num_clks, qmp->clks); |
| 1399 | err_rst: |
| 1400 | while (++i < cfg->num_resets) |
| 1401 | reset_control_assert(qmp->resets[i]); |
| 1402 | err_rst_assert: |
| 1403 | regulator_bulk_disable(cfg->num_vregs, qmp->vregs); |
| 1404 | err_reg_enable: |
| 1405 | mutex_unlock(&qmp->phy_mutex); |
| 1406 | |
| 1407 | return ret; |
| 1408 | } |
| 1409 | |
| 1410 | static int qcom_qmp_phy_com_exit(struct qcom_qmp *qmp) |
| 1411 | { |
| 1412 | const struct qmp_phy_cfg *cfg = qmp->cfg; |
| 1413 | void __iomem *serdes = qmp->serdes; |
| 1414 | int i = cfg->num_resets; |
| 1415 | |
| 1416 | mutex_lock(&qmp->phy_mutex); |
| 1417 | if (--qmp->init_count) { |
| 1418 | mutex_unlock(&qmp->phy_mutex); |
| 1419 | return 0; |
| 1420 | } |
| 1421 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1422 | reset_control_assert(qmp->ufs_reset); |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1423 | if (cfg->has_phy_com_ctrl) { |
| 1424 | qphy_setbits(serdes, cfg->regs[QPHY_COM_START_CONTROL], |
| 1425 | SERDES_START | PCS_START); |
| 1426 | qphy_clrbits(serdes, cfg->regs[QPHY_COM_SW_RESET], |
| 1427 | SW_RESET); |
| 1428 | qphy_setbits(serdes, cfg->regs[QPHY_COM_POWER_DOWN_CONTROL], |
| 1429 | SW_PWRDN); |
| 1430 | } |
| 1431 | |
| 1432 | while (--i >= 0) |
| 1433 | reset_control_assert(qmp->resets[i]); |
| 1434 | |
| 1435 | clk_bulk_disable_unprepare(cfg->num_clks, qmp->clks); |
| 1436 | |
| 1437 | regulator_bulk_disable(cfg->num_vregs, qmp->vregs); |
| 1438 | |
| 1439 | mutex_unlock(&qmp->phy_mutex); |
| 1440 | |
| 1441 | return 0; |
| 1442 | } |
| 1443 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1444 | static int qcom_qmp_phy_enable(struct phy *phy) |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1445 | { |
| 1446 | struct qmp_phy *qphy = phy_get_drvdata(phy); |
| 1447 | struct qcom_qmp *qmp = qphy->qmp; |
| 1448 | const struct qmp_phy_cfg *cfg = qmp->cfg; |
| 1449 | void __iomem *tx = qphy->tx; |
| 1450 | void __iomem *rx = qphy->rx; |
| 1451 | void __iomem *pcs = qphy->pcs; |
| 1452 | void __iomem *dp_com = qmp->dp_com; |
| 1453 | void __iomem *status; |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1454 | unsigned int mask, val, ready; |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1455 | int ret; |
| 1456 | |
| 1457 | dev_vdbg(qmp->dev, "Initializing QMP phy\n"); |
| 1458 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1459 | if (cfg->no_pcs_sw_reset) { |
| 1460 | /* |
| 1461 | * Get UFS reset, which is delayed until now to avoid a |
| 1462 | * circular dependency where UFS needs its PHY, but the PHY |
| 1463 | * needs this UFS reset. |
| 1464 | */ |
| 1465 | if (!qmp->ufs_reset) { |
| 1466 | qmp->ufs_reset = |
| 1467 | devm_reset_control_get_exclusive(qmp->dev, |
| 1468 | "ufsphy"); |
| 1469 | |
| 1470 | if (IS_ERR(qmp->ufs_reset)) { |
| 1471 | ret = PTR_ERR(qmp->ufs_reset); |
| 1472 | dev_err(qmp->dev, |
| 1473 | "failed to get UFS reset: %d\n", |
| 1474 | ret); |
| 1475 | |
| 1476 | qmp->ufs_reset = NULL; |
| 1477 | return ret; |
| 1478 | } |
| 1479 | } |
| 1480 | |
| 1481 | ret = reset_control_assert(qmp->ufs_reset); |
| 1482 | if (ret) |
| 1483 | goto err_lane_rst; |
| 1484 | } |
| 1485 | |
| 1486 | ret = qcom_qmp_phy_com_init(qphy); |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1487 | if (ret) |
| 1488 | return ret; |
| 1489 | |
| 1490 | if (cfg->has_lane_rst) { |
| 1491 | ret = reset_control_deassert(qphy->lane_rst); |
| 1492 | if (ret) { |
| 1493 | dev_err(qmp->dev, "lane%d reset deassert failed\n", |
| 1494 | qphy->index); |
| 1495 | goto err_lane_rst; |
| 1496 | } |
| 1497 | } |
| 1498 | |
| 1499 | ret = clk_prepare_enable(qphy->pipe_clk); |
| 1500 | if (ret) { |
| 1501 | dev_err(qmp->dev, "pipe_clk enable failed err=%d\n", ret); |
| 1502 | goto err_clk_enable; |
| 1503 | } |
| 1504 | |
| 1505 | /* Tx, Rx, and PCS configurations */ |
| 1506 | qcom_qmp_phy_configure(tx, cfg->regs, cfg->tx_tbl, cfg->tx_tbl_num); |
| 1507 | /* Configuration for other LANE for USB-DP combo PHY */ |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1508 | if (cfg->is_dual_lane_phy) |
| 1509 | qcom_qmp_phy_configure(qphy->tx2, cfg->regs, |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1510 | cfg->tx_tbl, cfg->tx_tbl_num); |
| 1511 | |
| 1512 | qcom_qmp_phy_configure(rx, cfg->regs, cfg->rx_tbl, cfg->rx_tbl_num); |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1513 | if (cfg->is_dual_lane_phy) |
| 1514 | qcom_qmp_phy_configure(qphy->rx2, cfg->regs, |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1515 | cfg->rx_tbl, cfg->rx_tbl_num); |
| 1516 | |
| 1517 | qcom_qmp_phy_configure(pcs, cfg->regs, cfg->pcs_tbl, cfg->pcs_tbl_num); |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1518 | ret = reset_control_deassert(qmp->ufs_reset); |
| 1519 | if (ret) |
| 1520 | goto err_lane_rst; |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1521 | |
| 1522 | /* |
| 1523 | * Pull out PHY from POWER DOWN state. |
| 1524 | * This is active low enable signal to power-down PHY. |
| 1525 | */ |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1526 | if(cfg->type == PHY_TYPE_PCIE) |
| 1527 | qphy_setbits(pcs, QPHY_POWER_DOWN_CONTROL, cfg->pwrdn_ctrl); |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1528 | |
| 1529 | if (cfg->has_pwrdn_delay) |
| 1530 | usleep_range(cfg->pwrdn_delay_min, cfg->pwrdn_delay_max); |
| 1531 | |
| 1532 | /* Pull PHY out of reset state */ |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1533 | if (!cfg->no_pcs_sw_reset) |
| 1534 | qphy_clrbits(pcs, cfg->regs[QPHY_SW_RESET], SW_RESET); |
| 1535 | |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1536 | if (cfg->has_phy_dp_com_ctrl) |
| 1537 | qphy_clrbits(dp_com, QPHY_V3_DP_COM_SW_RESET, SW_RESET); |
| 1538 | |
| 1539 | /* start SerDes and Phy-Coding-Sublayer */ |
| 1540 | qphy_setbits(pcs, cfg->regs[QPHY_START_CTRL], cfg->start_ctrl); |
| 1541 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1542 | if (cfg->type == PHY_TYPE_UFS) { |
| 1543 | status = pcs + cfg->regs[QPHY_PCS_READY_STATUS]; |
| 1544 | mask = PCS_READY; |
| 1545 | ready = PCS_READY; |
| 1546 | } else { |
| 1547 | status = pcs + cfg->regs[QPHY_PCS_STATUS]; |
| 1548 | mask = PHYSTATUS; |
| 1549 | ready = 0; |
| 1550 | } |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1551 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1552 | ret = readl_poll_timeout(status, val, (val & mask) == ready, 10, |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1553 | PHY_INIT_COMPLETE_TIMEOUT); |
| 1554 | if (ret) { |
| 1555 | dev_err(qmp->dev, "phy initialization timed-out\n"); |
| 1556 | goto err_pcs_ready; |
| 1557 | } |
| 1558 | qmp->phy_initialized = true; |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1559 | return 0; |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1560 | |
| 1561 | err_pcs_ready: |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1562 | reset_control_assert(qmp->ufs_reset); |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1563 | clk_disable_unprepare(qphy->pipe_clk); |
| 1564 | err_clk_enable: |
| 1565 | if (cfg->has_lane_rst) |
| 1566 | reset_control_assert(qphy->lane_rst); |
| 1567 | err_lane_rst: |
| 1568 | qcom_qmp_phy_com_exit(qmp); |
| 1569 | |
| 1570 | return ret; |
| 1571 | } |
| 1572 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1573 | static int qcom_qmp_phy_disable(struct phy *phy) |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1574 | { |
| 1575 | struct qmp_phy *qphy = phy_get_drvdata(phy); |
| 1576 | struct qcom_qmp *qmp = qphy->qmp; |
| 1577 | const struct qmp_phy_cfg *cfg = qmp->cfg; |
| 1578 | |
| 1579 | clk_disable_unprepare(qphy->pipe_clk); |
| 1580 | |
| 1581 | /* PHY reset */ |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1582 | if (!cfg->no_pcs_sw_reset) |
| 1583 | qphy_setbits(qphy->pcs, cfg->regs[QPHY_SW_RESET], SW_RESET); |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1584 | |
| 1585 | /* stop SerDes and Phy-Coding-Sublayer */ |
| 1586 | qphy_clrbits(qphy->pcs, cfg->regs[QPHY_START_CTRL], cfg->start_ctrl); |
| 1587 | |
| 1588 | /* Put PHY into POWER DOWN state: active low */ |
| 1589 | qphy_clrbits(qphy->pcs, QPHY_POWER_DOWN_CONTROL, cfg->pwrdn_ctrl); |
| 1590 | |
| 1591 | if (cfg->has_lane_rst) |
| 1592 | reset_control_assert(qphy->lane_rst); |
| 1593 | |
| 1594 | qcom_qmp_phy_com_exit(qmp); |
| 1595 | |
| 1596 | qmp->phy_initialized = false; |
| 1597 | |
| 1598 | return 0; |
| 1599 | } |
| 1600 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1601 | static int qcom_qmp_phy_set_mode(struct phy *phy, |
| 1602 | enum phy_mode mode, int submode) |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1603 | { |
| 1604 | struct qmp_phy *qphy = phy_get_drvdata(phy); |
| 1605 | struct qcom_qmp *qmp = qphy->qmp; |
| 1606 | |
| 1607 | qmp->mode = mode; |
| 1608 | |
| 1609 | return 0; |
| 1610 | } |
| 1611 | |
| 1612 | static void qcom_qmp_phy_enable_autonomous_mode(struct qmp_phy *qphy) |
| 1613 | { |
| 1614 | struct qcom_qmp *qmp = qphy->qmp; |
| 1615 | const struct qmp_phy_cfg *cfg = qmp->cfg; |
| 1616 | void __iomem *pcs = qphy->pcs; |
| 1617 | void __iomem *pcs_misc = qphy->pcs_misc; |
| 1618 | u32 intr_mask; |
| 1619 | |
| 1620 | if (qmp->mode == PHY_MODE_USB_HOST_SS || |
| 1621 | qmp->mode == PHY_MODE_USB_DEVICE_SS) |
| 1622 | intr_mask = ARCVR_DTCT_EN | ALFPS_DTCT_EN; |
| 1623 | else |
| 1624 | intr_mask = ARCVR_DTCT_EN | ARCVR_DTCT_EVENT_SEL; |
| 1625 | |
| 1626 | /* Clear any pending interrupts status */ |
| 1627 | qphy_setbits(pcs, cfg->regs[QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR], IRQ_CLEAR); |
| 1628 | /* Writing 1 followed by 0 clears the interrupt */ |
| 1629 | qphy_clrbits(pcs, cfg->regs[QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR], IRQ_CLEAR); |
| 1630 | |
| 1631 | qphy_clrbits(pcs, cfg->regs[QPHY_PCS_AUTONOMOUS_MODE_CTRL], |
| 1632 | ARCVR_DTCT_EN | ALFPS_DTCT_EN | ARCVR_DTCT_EVENT_SEL); |
| 1633 | |
| 1634 | /* Enable required PHY autonomous mode interrupts */ |
| 1635 | qphy_setbits(pcs, cfg->regs[QPHY_PCS_AUTONOMOUS_MODE_CTRL], intr_mask); |
| 1636 | |
| 1637 | /* Enable i/o clamp_n for autonomous mode */ |
| 1638 | if (pcs_misc) |
| 1639 | qphy_clrbits(pcs_misc, QPHY_V3_PCS_MISC_CLAMP_ENABLE, CLAMP_EN); |
| 1640 | } |
| 1641 | |
| 1642 | static void qcom_qmp_phy_disable_autonomous_mode(struct qmp_phy *qphy) |
| 1643 | { |
| 1644 | struct qcom_qmp *qmp = qphy->qmp; |
| 1645 | const struct qmp_phy_cfg *cfg = qmp->cfg; |
| 1646 | void __iomem *pcs = qphy->pcs; |
| 1647 | void __iomem *pcs_misc = qphy->pcs_misc; |
| 1648 | |
| 1649 | /* Disable i/o clamp_n on resume for normal mode */ |
| 1650 | if (pcs_misc) |
| 1651 | qphy_setbits(pcs_misc, QPHY_V3_PCS_MISC_CLAMP_ENABLE, CLAMP_EN); |
| 1652 | |
| 1653 | qphy_clrbits(pcs, cfg->regs[QPHY_PCS_AUTONOMOUS_MODE_CTRL], |
| 1654 | ARCVR_DTCT_EN | ARCVR_DTCT_EVENT_SEL | ALFPS_DTCT_EN); |
| 1655 | |
| 1656 | qphy_setbits(pcs, cfg->regs[QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR], IRQ_CLEAR); |
| 1657 | /* Writing 1 followed by 0 clears the interrupt */ |
| 1658 | qphy_clrbits(pcs, cfg->regs[QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR], IRQ_CLEAR); |
| 1659 | } |
| 1660 | |
| 1661 | static int __maybe_unused qcom_qmp_phy_runtime_suspend(struct device *dev) |
| 1662 | { |
| 1663 | struct qcom_qmp *qmp = dev_get_drvdata(dev); |
| 1664 | struct qmp_phy *qphy = qmp->phys[0]; |
| 1665 | const struct qmp_phy_cfg *cfg = qmp->cfg; |
| 1666 | |
| 1667 | dev_vdbg(dev, "Suspending QMP phy, mode:%d\n", qmp->mode); |
| 1668 | |
| 1669 | /* Supported only for USB3 PHY */ |
| 1670 | if (cfg->type != PHY_TYPE_USB3) |
| 1671 | return 0; |
| 1672 | |
| 1673 | if (!qmp->phy_initialized) { |
| 1674 | dev_vdbg(dev, "PHY not initialized, bailing out\n"); |
| 1675 | return 0; |
| 1676 | } |
| 1677 | |
| 1678 | qcom_qmp_phy_enable_autonomous_mode(qphy); |
| 1679 | |
| 1680 | clk_disable_unprepare(qphy->pipe_clk); |
| 1681 | clk_bulk_disable_unprepare(cfg->num_clks, qmp->clks); |
| 1682 | |
| 1683 | return 0; |
| 1684 | } |
| 1685 | |
| 1686 | static int __maybe_unused qcom_qmp_phy_runtime_resume(struct device *dev) |
| 1687 | { |
| 1688 | struct qcom_qmp *qmp = dev_get_drvdata(dev); |
| 1689 | struct qmp_phy *qphy = qmp->phys[0]; |
| 1690 | const struct qmp_phy_cfg *cfg = qmp->cfg; |
| 1691 | int ret = 0; |
| 1692 | |
| 1693 | dev_vdbg(dev, "Resuming QMP phy, mode:%d\n", qmp->mode); |
| 1694 | |
| 1695 | /* Supported only for USB3 PHY */ |
| 1696 | if (cfg->type != PHY_TYPE_USB3) |
| 1697 | return 0; |
| 1698 | |
| 1699 | if (!qmp->phy_initialized) { |
| 1700 | dev_vdbg(dev, "PHY not initialized, bailing out\n"); |
| 1701 | return 0; |
| 1702 | } |
| 1703 | |
| 1704 | ret = clk_bulk_prepare_enable(cfg->num_clks, qmp->clks); |
| 1705 | if (ret) { |
| 1706 | dev_err(qmp->dev, "failed to enable clks, err=%d\n", ret); |
| 1707 | return ret; |
| 1708 | } |
| 1709 | |
| 1710 | ret = clk_prepare_enable(qphy->pipe_clk); |
| 1711 | if (ret) { |
| 1712 | dev_err(dev, "pipe_clk enable failed, err=%d\n", ret); |
| 1713 | clk_bulk_disable_unprepare(cfg->num_clks, qmp->clks); |
| 1714 | return ret; |
| 1715 | } |
| 1716 | |
| 1717 | qcom_qmp_phy_disable_autonomous_mode(qphy); |
| 1718 | |
| 1719 | return 0; |
| 1720 | } |
| 1721 | |
| 1722 | static int qcom_qmp_phy_vreg_init(struct device *dev) |
| 1723 | { |
| 1724 | struct qcom_qmp *qmp = dev_get_drvdata(dev); |
| 1725 | int num = qmp->cfg->num_vregs; |
| 1726 | int i; |
| 1727 | |
| 1728 | qmp->vregs = devm_kcalloc(dev, num, sizeof(*qmp->vregs), GFP_KERNEL); |
| 1729 | if (!qmp->vregs) |
| 1730 | return -ENOMEM; |
| 1731 | |
| 1732 | for (i = 0; i < num; i++) |
| 1733 | qmp->vregs[i].supply = qmp->cfg->vreg_list[i]; |
| 1734 | |
| 1735 | return devm_regulator_bulk_get(dev, num, qmp->vregs); |
| 1736 | } |
| 1737 | |
| 1738 | static int qcom_qmp_phy_reset_init(struct device *dev) |
| 1739 | { |
| 1740 | struct qcom_qmp *qmp = dev_get_drvdata(dev); |
| 1741 | int i; |
| 1742 | |
| 1743 | qmp->resets = devm_kcalloc(dev, qmp->cfg->num_resets, |
| 1744 | sizeof(*qmp->resets), GFP_KERNEL); |
| 1745 | if (!qmp->resets) |
| 1746 | return -ENOMEM; |
| 1747 | |
| 1748 | for (i = 0; i < qmp->cfg->num_resets; i++) { |
| 1749 | struct reset_control *rst; |
| 1750 | const char *name = qmp->cfg->reset_list[i]; |
| 1751 | |
| 1752 | rst = devm_reset_control_get(dev, name); |
| 1753 | if (IS_ERR(rst)) { |
| 1754 | dev_err(dev, "failed to get %s reset\n", name); |
| 1755 | return PTR_ERR(rst); |
| 1756 | } |
| 1757 | qmp->resets[i] = rst; |
| 1758 | } |
| 1759 | |
| 1760 | return 0; |
| 1761 | } |
| 1762 | |
| 1763 | static int qcom_qmp_phy_clk_init(struct device *dev) |
| 1764 | { |
| 1765 | struct qcom_qmp *qmp = dev_get_drvdata(dev); |
| 1766 | int num = qmp->cfg->num_clks; |
| 1767 | int i; |
| 1768 | |
| 1769 | qmp->clks = devm_kcalloc(dev, num, sizeof(*qmp->clks), GFP_KERNEL); |
| 1770 | if (!qmp->clks) |
| 1771 | return -ENOMEM; |
| 1772 | |
| 1773 | for (i = 0; i < num; i++) |
| 1774 | qmp->clks[i].id = qmp->cfg->clk_list[i]; |
| 1775 | |
| 1776 | return devm_clk_bulk_get(dev, num, qmp->clks); |
| 1777 | } |
| 1778 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1779 | static void phy_pipe_clk_release_provider(void *res) |
| 1780 | { |
| 1781 | of_clk_del_provider(res); |
| 1782 | } |
| 1783 | |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1784 | /* |
| 1785 | * Register a fixed rate pipe clock. |
| 1786 | * |
| 1787 | * The <s>_pipe_clksrc generated by PHY goes to the GCC that gate |
| 1788 | * controls it. The <s>_pipe_clk coming out of the GCC is requested |
| 1789 | * by the PHY driver for its operations. |
| 1790 | * We register the <s>_pipe_clksrc here. The gcc driver takes care |
| 1791 | * of assigning this <s>_pipe_clksrc as parent to <s>_pipe_clk. |
| 1792 | * Below picture shows this relationship. |
| 1793 | * |
| 1794 | * +---------------+ |
| 1795 | * | PHY block |<<---------------------------------------+ |
| 1796 | * | | | |
| 1797 | * | +-------+ | +-----+ | |
| 1798 | * I/P---^-->| PLL |---^--->pipe_clksrc--->| GCC |--->pipe_clk---+ |
| 1799 | * clk | +-------+ | +-----+ |
| 1800 | * +---------------+ |
| 1801 | */ |
| 1802 | static int phy_pipe_clk_register(struct qcom_qmp *qmp, struct device_node *np) |
| 1803 | { |
| 1804 | struct clk_fixed_rate *fixed; |
| 1805 | struct clk_init_data init = { }; |
| 1806 | int ret; |
| 1807 | |
| 1808 | if ((qmp->cfg->type != PHY_TYPE_USB3) && |
| 1809 | (qmp->cfg->type != PHY_TYPE_PCIE)) { |
| 1810 | /* not all phys register pipe clocks, so return success */ |
| 1811 | return 0; |
| 1812 | } |
| 1813 | |
| 1814 | ret = of_property_read_string(np, "clock-output-names", &init.name); |
| 1815 | if (ret) { |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1816 | dev_err(qmp->dev, "%pOFn: No clock-output-names\n", np); |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1817 | return ret; |
| 1818 | } |
| 1819 | |
| 1820 | fixed = devm_kzalloc(qmp->dev, sizeof(*fixed), GFP_KERNEL); |
| 1821 | if (!fixed) |
| 1822 | return -ENOMEM; |
| 1823 | |
| 1824 | init.ops = &clk_fixed_rate_ops; |
| 1825 | |
| 1826 | /* controllers using QMP phys use 125MHz pipe clock interface */ |
| 1827 | fixed->fixed_rate = 125000000; |
| 1828 | fixed->hw.init = &init; |
| 1829 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1830 | ret = devm_clk_hw_register(qmp->dev, &fixed->hw); |
| 1831 | if (ret) |
| 1832 | return ret; |
| 1833 | |
| 1834 | ret = of_clk_add_hw_provider(np, of_clk_hw_simple_get, &fixed->hw); |
| 1835 | if (ret) |
| 1836 | return ret; |
| 1837 | |
| 1838 | /* |
| 1839 | * Roll a devm action because the clock provider is the child node, but |
| 1840 | * the child node is not actually a device. |
| 1841 | */ |
| 1842 | ret = devm_add_action(qmp->dev, phy_pipe_clk_release_provider, np); |
| 1843 | if (ret) |
| 1844 | phy_pipe_clk_release_provider(np); |
| 1845 | |
| 1846 | return ret; |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1847 | } |
| 1848 | |
| 1849 | static const struct phy_ops qcom_qmp_phy_gen_ops = { |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1850 | .init = qcom_qmp_phy_enable, |
| 1851 | .exit = qcom_qmp_phy_disable, |
| 1852 | .set_mode = qcom_qmp_phy_set_mode, |
| 1853 | .owner = THIS_MODULE, |
| 1854 | }; |
| 1855 | |
| 1856 | static const struct phy_ops qcom_qmp_ufs_ops = { |
| 1857 | .power_on = qcom_qmp_phy_enable, |
| 1858 | .power_off = qcom_qmp_phy_disable, |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1859 | .set_mode = qcom_qmp_phy_set_mode, |
| 1860 | .owner = THIS_MODULE, |
| 1861 | }; |
| 1862 | |
| 1863 | static |
| 1864 | int qcom_qmp_phy_create(struct device *dev, struct device_node *np, int id) |
| 1865 | { |
| 1866 | struct qcom_qmp *qmp = dev_get_drvdata(dev); |
| 1867 | struct phy *generic_phy; |
| 1868 | struct qmp_phy *qphy; |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1869 | const struct phy_ops *ops = &qcom_qmp_phy_gen_ops; |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1870 | char prop_name[MAX_PROP_NAME]; |
| 1871 | int ret; |
| 1872 | |
| 1873 | qphy = devm_kzalloc(dev, sizeof(*qphy), GFP_KERNEL); |
| 1874 | if (!qphy) |
| 1875 | return -ENOMEM; |
| 1876 | |
| 1877 | /* |
| 1878 | * Get memory resources for each phy lane: |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1879 | * Resources are indexed as: tx -> 0; rx -> 1; pcs -> 2. |
| 1880 | * For dual lane PHYs: tx2 -> 3, rx2 -> 4, pcs_misc (optional) -> 5 |
| 1881 | * For single lane PHYs: pcs_misc (optional) -> 3. |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1882 | */ |
| 1883 | qphy->tx = of_iomap(np, 0); |
| 1884 | if (!qphy->tx) |
| 1885 | return -ENOMEM; |
| 1886 | |
| 1887 | qphy->rx = of_iomap(np, 1); |
| 1888 | if (!qphy->rx) |
| 1889 | return -ENOMEM; |
| 1890 | |
| 1891 | qphy->pcs = of_iomap(np, 2); |
| 1892 | if (!qphy->pcs) |
| 1893 | return -ENOMEM; |
| 1894 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1895 | /* |
| 1896 | * If this is a dual-lane PHY, then there should be registers for the |
| 1897 | * second lane. Some old device trees did not specify this, so fall |
| 1898 | * back to old legacy behavior of assuming they can be reached at an |
| 1899 | * offset from the first lane. |
| 1900 | */ |
| 1901 | if (qmp->cfg->is_dual_lane_phy) { |
| 1902 | qphy->tx2 = of_iomap(np, 3); |
| 1903 | qphy->rx2 = of_iomap(np, 4); |
| 1904 | if (!qphy->tx2 || !qphy->rx2) { |
| 1905 | dev_warn(dev, |
| 1906 | "Underspecified device tree, falling back to legacy register regions\n"); |
| 1907 | |
| 1908 | /* In the old version, pcs_misc is at index 3. */ |
| 1909 | qphy->pcs_misc = qphy->tx2; |
| 1910 | qphy->tx2 = qphy->tx + QMP_PHY_LEGACY_LANE_STRIDE; |
| 1911 | qphy->rx2 = qphy->rx + QMP_PHY_LEGACY_LANE_STRIDE; |
| 1912 | |
| 1913 | } else { |
| 1914 | qphy->pcs_misc = of_iomap(np, 5); |
| 1915 | } |
| 1916 | |
| 1917 | } else { |
| 1918 | qphy->pcs_misc = of_iomap(np, 3); |
| 1919 | } |
| 1920 | |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1921 | if (!qphy->pcs_misc) |
| 1922 | dev_vdbg(dev, "PHY pcs_misc-reg not used\n"); |
| 1923 | |
| 1924 | /* |
| 1925 | * Get PHY's Pipe clock, if any. USB3 and PCIe are PIPE3 |
| 1926 | * based phys, so they essentially have pipe clock. So, |
| 1927 | * we return error in case phy is USB3 or PIPE type. |
| 1928 | * Otherwise, we initialize pipe clock to NULL for |
| 1929 | * all phys that don't need this. |
| 1930 | */ |
| 1931 | snprintf(prop_name, sizeof(prop_name), "pipe%d", id); |
| 1932 | qphy->pipe_clk = of_clk_get_by_name(np, prop_name); |
| 1933 | if (IS_ERR(qphy->pipe_clk)) { |
| 1934 | if (qmp->cfg->type == PHY_TYPE_PCIE || |
| 1935 | qmp->cfg->type == PHY_TYPE_USB3) { |
| 1936 | ret = PTR_ERR(qphy->pipe_clk); |
| 1937 | if (ret != -EPROBE_DEFER) |
| 1938 | dev_err(dev, |
| 1939 | "failed to get lane%d pipe_clk, %d\n", |
| 1940 | id, ret); |
| 1941 | return ret; |
| 1942 | } |
| 1943 | qphy->pipe_clk = NULL; |
| 1944 | } |
| 1945 | |
| 1946 | /* Get lane reset, if any */ |
| 1947 | if (qmp->cfg->has_lane_rst) { |
| 1948 | snprintf(prop_name, sizeof(prop_name), "lane%d", id); |
| 1949 | qphy->lane_rst = of_reset_control_get(np, prop_name); |
| 1950 | if (IS_ERR(qphy->lane_rst)) { |
| 1951 | dev_err(dev, "failed to get lane%d reset\n", id); |
| 1952 | return PTR_ERR(qphy->lane_rst); |
| 1953 | } |
| 1954 | } |
| 1955 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1956 | if (qmp->cfg->type == PHY_TYPE_UFS) |
| 1957 | ops = &qcom_qmp_ufs_ops; |
| 1958 | |
| 1959 | generic_phy = devm_phy_create(dev, np, ops); |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1960 | if (IS_ERR(generic_phy)) { |
| 1961 | ret = PTR_ERR(generic_phy); |
| 1962 | dev_err(dev, "failed to create qphy %d\n", ret); |
| 1963 | return ret; |
| 1964 | } |
| 1965 | |
| 1966 | qphy->phy = generic_phy; |
| 1967 | qphy->index = id; |
| 1968 | qphy->qmp = qmp; |
| 1969 | qmp->phys[id] = qphy; |
| 1970 | phy_set_drvdata(generic_phy, qphy); |
| 1971 | |
| 1972 | return 0; |
| 1973 | } |
| 1974 | |
| 1975 | static const struct of_device_id qcom_qmp_phy_of_match_table[] = { |
| 1976 | { |
| 1977 | .compatible = "qcom,msm8996-qmp-pcie-phy", |
| 1978 | .data = &msm8996_pciephy_cfg, |
| 1979 | }, { |
| 1980 | .compatible = "qcom,msm8996-qmp-usb3-phy", |
| 1981 | .data = &msm8996_usb3phy_cfg, |
| 1982 | }, { |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1983 | .compatible = "qcom,msm8998-qmp-pcie-phy", |
| 1984 | .data = &msm8998_pciephy_cfg, |
| 1985 | }, { |
| 1986 | .compatible = "qcom,msm8998-qmp-ufs-phy", |
| 1987 | .data = &sdm845_ufsphy_cfg, |
| 1988 | }, { |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1989 | .compatible = "qcom,ipq8074-qmp-pcie-phy", |
| 1990 | .data = &ipq8074_pciephy_cfg, |
| 1991 | }, { |
| 1992 | .compatible = "qcom,sdm845-qmp-usb3-phy", |
| 1993 | .data = &qmp_v3_usb3phy_cfg, |
| 1994 | }, { |
| 1995 | .compatible = "qcom,sdm845-qmp-usb3-uni-phy", |
| 1996 | .data = &qmp_v3_usb3_uniphy_cfg, |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1997 | }, { |
| 1998 | .compatible = "qcom,sdm845-qmp-ufs-phy", |
| 1999 | .data = &sdm845_ufsphy_cfg, |
| 2000 | }, { |
| 2001 | .compatible = "qcom,msm8998-qmp-usb3-phy", |
| 2002 | .data = &msm8998_usb3phy_cfg, |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 2003 | }, |
| 2004 | { }, |
| 2005 | }; |
| 2006 | MODULE_DEVICE_TABLE(of, qcom_qmp_phy_of_match_table); |
| 2007 | |
| 2008 | static const struct dev_pm_ops qcom_qmp_phy_pm_ops = { |
| 2009 | SET_RUNTIME_PM_OPS(qcom_qmp_phy_runtime_suspend, |
| 2010 | qcom_qmp_phy_runtime_resume, NULL) |
| 2011 | }; |
| 2012 | |
| 2013 | static int qcom_qmp_phy_probe(struct platform_device *pdev) |
| 2014 | { |
| 2015 | struct qcom_qmp *qmp; |
| 2016 | struct device *dev = &pdev->dev; |
| 2017 | struct resource *res; |
| 2018 | struct device_node *child; |
| 2019 | struct phy_provider *phy_provider; |
| 2020 | void __iomem *base; |
| 2021 | int num, id; |
| 2022 | int ret; |
| 2023 | |
| 2024 | qmp = devm_kzalloc(dev, sizeof(*qmp), GFP_KERNEL); |
| 2025 | if (!qmp) |
| 2026 | return -ENOMEM; |
| 2027 | |
| 2028 | qmp->dev = dev; |
| 2029 | dev_set_drvdata(dev, qmp); |
| 2030 | |
| 2031 | /* Get the specific init parameters of QMP phy */ |
| 2032 | qmp->cfg = of_device_get_match_data(dev); |
| 2033 | if (!qmp->cfg) |
| 2034 | return -EINVAL; |
| 2035 | |
| 2036 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 2037 | base = devm_ioremap_resource(dev, res); |
| 2038 | if (IS_ERR(base)) |
| 2039 | return PTR_ERR(base); |
| 2040 | |
| 2041 | /* per PHY serdes; usually located at base address */ |
| 2042 | qmp->serdes = base; |
| 2043 | |
| 2044 | /* per PHY dp_com; if PHY has dp_com control block */ |
| 2045 | if (qmp->cfg->has_phy_dp_com_ctrl) { |
| 2046 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, |
| 2047 | "dp_com"); |
| 2048 | base = devm_ioremap_resource(dev, res); |
| 2049 | if (IS_ERR(base)) |
| 2050 | return PTR_ERR(base); |
| 2051 | |
| 2052 | qmp->dp_com = base; |
| 2053 | } |
| 2054 | |
| 2055 | mutex_init(&qmp->phy_mutex); |
| 2056 | |
| 2057 | ret = qcom_qmp_phy_clk_init(dev); |
| 2058 | if (ret) |
| 2059 | return ret; |
| 2060 | |
| 2061 | ret = qcom_qmp_phy_reset_init(dev); |
| 2062 | if (ret) |
| 2063 | return ret; |
| 2064 | |
| 2065 | ret = qcom_qmp_phy_vreg_init(dev); |
| 2066 | if (ret) { |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 2067 | if (ret != -EPROBE_DEFER) |
| 2068 | dev_err(dev, "failed to get regulator supplies: %d\n", |
| 2069 | ret); |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 2070 | return ret; |
| 2071 | } |
| 2072 | |
| 2073 | num = of_get_available_child_count(dev->of_node); |
| 2074 | /* do we have a rogue child node ? */ |
| 2075 | if (num > qmp->cfg->nlanes) |
| 2076 | return -EINVAL; |
| 2077 | |
| 2078 | qmp->phys = devm_kcalloc(dev, num, sizeof(*qmp->phys), GFP_KERNEL); |
| 2079 | if (!qmp->phys) |
| 2080 | return -ENOMEM; |
| 2081 | |
| 2082 | id = 0; |
| 2083 | pm_runtime_set_active(dev); |
| 2084 | pm_runtime_enable(dev); |
| 2085 | /* |
| 2086 | * Prevent runtime pm from being ON by default. Users can enable |
| 2087 | * it using power/control in sysfs. |
| 2088 | */ |
| 2089 | pm_runtime_forbid(dev); |
| 2090 | |
| 2091 | for_each_available_child_of_node(dev->of_node, child) { |
| 2092 | /* Create per-lane phy */ |
| 2093 | ret = qcom_qmp_phy_create(dev, child, id); |
| 2094 | if (ret) { |
| 2095 | dev_err(dev, "failed to create lane%d phy, %d\n", |
| 2096 | id, ret); |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 2097 | goto err_node_put; |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 2098 | } |
| 2099 | |
| 2100 | /* |
| 2101 | * Register the pipe clock provided by phy. |
| 2102 | * See function description to see details of this pipe clock. |
| 2103 | */ |
| 2104 | ret = phy_pipe_clk_register(qmp, child); |
| 2105 | if (ret) { |
| 2106 | dev_err(qmp->dev, |
| 2107 | "failed to register pipe clock source\n"); |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 2108 | goto err_node_put; |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 2109 | } |
| 2110 | id++; |
| 2111 | } |
| 2112 | |
| 2113 | phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); |
| 2114 | if (!IS_ERR(phy_provider)) |
| 2115 | dev_info(dev, "Registered Qcom-QMP phy\n"); |
| 2116 | else |
| 2117 | pm_runtime_disable(dev); |
| 2118 | |
| 2119 | return PTR_ERR_OR_ZERO(phy_provider); |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 2120 | |
| 2121 | err_node_put: |
| 2122 | pm_runtime_disable(dev); |
| 2123 | of_node_put(child); |
| 2124 | return ret; |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 2125 | } |
| 2126 | |
| 2127 | static struct platform_driver qcom_qmp_phy_driver = { |
| 2128 | .probe = qcom_qmp_phy_probe, |
| 2129 | .driver = { |
| 2130 | .name = "qcom-qmp-phy", |
| 2131 | .pm = &qcom_qmp_phy_pm_ops, |
| 2132 | .of_match_table = qcom_qmp_phy_of_match_table, |
| 2133 | }, |
| 2134 | }; |
| 2135 | |
| 2136 | module_platform_driver(qcom_qmp_phy_driver); |
| 2137 | |
| 2138 | MODULE_AUTHOR("Vivek Gautam <vivek.gautam@codeaurora.org>"); |
| 2139 | MODULE_DESCRIPTION("Qualcomm QMP PHY driver"); |
| 2140 | MODULE_LICENSE("GPL v2"); |