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/pcie.h> 18 #include <linux/phy/phy.h> 19 #include <linux/platform_device.h> 20 #include <linux/regulator/consumer.h> 21 #include <linux/reset.h> 22 #include <linux/slab.h> 23 24 #include <dt-bindings/phy/phy.h> 25 26 #include "phy-qcom-qmp.h" 27 28 /* QPHY_SW_RESET bit */ 29 #define SW_RESET BIT(0) 30 /* QPHY_POWER_DOWN_CONTROL */ 31 #define SW_PWRDN BIT(0) 32 #define REFCLK_DRV_DSBL BIT(1) 33 /* QPHY_START_CONTROL bits */ 34 #define SERDES_START BIT(0) 35 #define PCS_START BIT(1) 36 /* QPHY_PCS_STATUS bit */ 37 #define PHYSTATUS BIT(6) 38 #define PHYSTATUS_4_20 BIT(7) 39 40 #define PHY_INIT_COMPLETE_TIMEOUT 10000 41 42 struct qmp_phy_init_tbl { 43 unsigned int offset; 44 unsigned int val; 45 /* 46 * register part of layout ? 47 * if yes, then offset gives index in the reg-layout 48 */ 49 bool in_layout; 50 /* 51 * mask of lanes for which this register is written 52 * for cases when second lane needs different values 53 */ 54 u8 lane_mask; 55 }; 56 57 #define QMP_PHY_INIT_CFG(o, v) \ 58 { \ 59 .offset = o, \ 60 .val = v, \ 61 .lane_mask = 0xff, \ 62 } 63 64 #define QMP_PHY_INIT_CFG_L(o, v) \ 65 { \ 66 .offset = o, \ 67 .val = v, \ 68 .in_layout = true, \ 69 .lane_mask = 0xff, \ 70 } 71 72 #define QMP_PHY_INIT_CFG_LANE(o, v, l) \ 73 { \ 74 .offset = o, \ 75 .val = v, \ 76 .lane_mask = l, \ 77 } 78 79 /* set of registers with offsets different per-PHY */ 80 enum qphy_reg_layout { 81 /* Common block control registers */ 82 QPHY_COM_SW_RESET, 83 QPHY_COM_POWER_DOWN_CONTROL, 84 QPHY_COM_START_CONTROL, 85 QPHY_COM_PCS_READY_STATUS, 86 /* PCS registers */ 87 QPHY_SW_RESET, 88 QPHY_START_CTRL, 89 QPHY_PCS_STATUS, 90 QPHY_PCS_POWER_DOWN_CONTROL, 91 /* Keep last to ensure regs_layout arrays are properly initialized */ 92 QPHY_LAYOUT_SIZE 93 }; 94 95 static const unsigned int ipq_pciephy_gen3_regs_layout[QPHY_LAYOUT_SIZE] = { 96 [QPHY_SW_RESET] = 0x00, 97 [QPHY_START_CTRL] = 0x44, 98 [QPHY_PCS_STATUS] = 0x14, 99 [QPHY_PCS_POWER_DOWN_CONTROL] = 0x40, 100 }; 101 102 static const unsigned int pciephy_regs_layout[QPHY_LAYOUT_SIZE] = { 103 [QPHY_COM_SW_RESET] = 0x400, 104 [QPHY_COM_POWER_DOWN_CONTROL] = 0x404, 105 [QPHY_COM_START_CONTROL] = 0x408, 106 [QPHY_COM_PCS_READY_STATUS] = 0x448, 107 [QPHY_SW_RESET] = 0x00, 108 [QPHY_START_CTRL] = 0x08, 109 [QPHY_PCS_STATUS] = 0x174, 110 }; 111 112 static const unsigned int sdm845_qmp_pciephy_regs_layout[QPHY_LAYOUT_SIZE] = { 113 [QPHY_SW_RESET] = 0x00, 114 [QPHY_START_CTRL] = 0x08, 115 [QPHY_PCS_STATUS] = 0x174, 116 }; 117 118 static const unsigned int sdm845_qhp_pciephy_regs_layout[QPHY_LAYOUT_SIZE] = { 119 [QPHY_SW_RESET] = 0x00, 120 [QPHY_START_CTRL] = 0x08, 121 [QPHY_PCS_STATUS] = 0x2ac, 122 }; 123 124 static const unsigned int sm8250_pcie_regs_layout[QPHY_LAYOUT_SIZE] = { 125 [QPHY_SW_RESET] = 0x00, 126 [QPHY_START_CTRL] = 0x44, 127 [QPHY_PCS_STATUS] = 0x14, 128 [QPHY_PCS_POWER_DOWN_CONTROL] = 0x40, 129 }; 130 131 static const struct qmp_phy_init_tbl msm8998_pcie_serdes_tbl[] = { 132 QMP_PHY_INIT_CFG(QSERDES_V3_COM_BIAS_EN_CLKBUFLR_EN, 0x14), 133 QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_SELECT, 0x30), 134 QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_IVCO, 0x0f), 135 QMP_PHY_INIT_CFG(QSERDES_V3_COM_CMN_CONFIG, 0x06), 136 QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP_EN, 0x01), 137 QMP_PHY_INIT_CFG(QSERDES_V3_COM_RESETSM_CNTRL, 0x20), 138 QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_MAP, 0x00), 139 QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE2_MODE0, 0x01), 140 QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE1_MODE0, 0xc9), 141 QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_TIMER1, 0xff), 142 QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_TIMER2, 0x3f), 143 QMP_PHY_INIT_CFG(QSERDES_V3_COM_SVS_MODE_CLK_SEL, 0x01), 144 QMP_PHY_INIT_CFG(QSERDES_V3_COM_CORE_CLK_EN, 0x00), 145 QMP_PHY_INIT_CFG(QSERDES_V3_COM_CORECLK_DIV_MODE0, 0x0a), 146 QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_EP_DIV, 0x19), 147 QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_ENABLE1, 0x90), 148 QMP_PHY_INIT_CFG(QSERDES_V3_COM_DEC_START_MODE0, 0x82), 149 QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START3_MODE0, 0x03), 150 QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START2_MODE0, 0x55), 151 QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START1_MODE0, 0x55), 152 QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP3_MODE0, 0x00), 153 QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP2_MODE0, 0x0d), 154 QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP1_MODE0, 0x04), 155 QMP_PHY_INIT_CFG(QSERDES_V3_COM_HSCLK_SEL, 0x00), 156 QMP_PHY_INIT_CFG(QSERDES_V3_COM_CP_CTRL_MODE0, 0x08), 157 QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_RCTRL_MODE0, 0x16), 158 QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_CCTRL_MODE0, 0x34), 159 QMP_PHY_INIT_CFG(QSERDES_V3_COM_CMN_CONFIG, 0x06), 160 QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_SELECT, 0x33), 161 QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYS_CLK_CTRL, 0x02), 162 QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYSCLK_BUF_ENABLE, 0x07), 163 QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYSCLK_EN_SEL, 0x04), 164 QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN1_MODE0, 0x00), 165 QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN0_MODE0, 0x3f), 166 QMP_PHY_INIT_CFG(QSERDES_V3_COM_BG_TIMER, 0x09), 167 QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_EN_CENTER, 0x01), 168 QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_PER1, 0x40), 169 QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_PER2, 0x01), 170 QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_ADJ_PER1, 0x02), 171 QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_ADJ_PER2, 0x00), 172 QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_STEP_SIZE1, 0x7e), 173 QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_STEP_SIZE2, 0x15), 174 }; 175 176 static const struct qmp_phy_init_tbl msm8998_pcie_tx_tbl[] = { 177 QMP_PHY_INIT_CFG(QSERDES_V3_TX_RES_CODE_LANE_OFFSET_TX, 0x02), 178 QMP_PHY_INIT_CFG(QSERDES_V3_TX_RCV_DETECT_LVL_2, 0x12), 179 QMP_PHY_INIT_CFG(QSERDES_V3_TX_HIGHZ_DRVR_EN, 0x10), 180 QMP_PHY_INIT_CFG(QSERDES_V3_TX_LANE_MODE_1, 0x06), 181 }; 182 183 static const struct qmp_phy_init_tbl msm8998_pcie_rx_tbl[] = { 184 QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_CNTRL, 0x03), 185 QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_ENABLES, 0x1c), 186 QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_DEGLITCH_CNTRL, 0x14), 187 QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL2, 0x0a), 188 QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL3, 0x04), 189 QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL4, 0x1a), 190 QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x4b), 191 QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SO_GAIN, 0x04), 192 QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SO_GAIN_HALF, 0x04), 193 QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1, 0x00), 194 QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_OFFSET_ADAPTOR_CNTRL2, 0x80), 195 QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_INTERFACE_MODE, 0x40), 196 QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_PI_CONTROLS, 0x71), 197 QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_FASTLOCK_COUNT_LOW, 0x40), 198 }; 199 200 static const struct qmp_phy_init_tbl msm8998_pcie_pcs_tbl[] = { 201 QMP_PHY_INIT_CFG(QPHY_V3_PCS_ENDPOINT_REFCLK_DRIVE, 0x04), 202 QMP_PHY_INIT_CFG(QPHY_V3_PCS_OSC_DTCT_ACTIONS, 0x00), 203 QMP_PHY_INIT_CFG(QPHY_V3_PCS_PWRUP_RESET_DLY_TIME_AUXCLK, 0x01), 204 QMP_PHY_INIT_CFG(QPHY_V3_PCS_L1SS_WAKEUP_DLY_TIME_AUXCLK_MSB, 0x00), 205 QMP_PHY_INIT_CFG(QPHY_V3_PCS_L1SS_WAKEUP_DLY_TIME_AUXCLK_LSB, 0x20), 206 QMP_PHY_INIT_CFG(QPHY_V3_PCS_LP_WAKEUP_DLY_TIME_AUXCLK_MSB, 0x00), 207 QMP_PHY_INIT_CFG(QPHY_V3_PCS_LP_WAKEUP_DLY_TIME_AUXCLK, 0x01), 208 QMP_PHY_INIT_CFG(QPHY_V3_PCS_PLL_LOCK_CHK_DLY_TIME, 0x73), 209 QMP_PHY_INIT_CFG(QPHY_V3_PCS_RX_SIGDET_LVL, 0x99), 210 QMP_PHY_INIT_CFG(QPHY_V3_PCS_SIGDET_CNTRL, 0x03), 211 }; 212 213 static const struct qmp_phy_init_tbl ipq6018_pcie_serdes_tbl[] = { 214 QMP_PHY_INIT_CFG(QSERDES_PLL_SSC_PER1, 0x7d), 215 QMP_PHY_INIT_CFG(QSERDES_PLL_SSC_PER2, 0x01), 216 QMP_PHY_INIT_CFG(QSERDES_PLL_SSC_STEP_SIZE1_MODE0, 0x0a), 217 QMP_PHY_INIT_CFG(QSERDES_PLL_SSC_STEP_SIZE2_MODE0, 0x05), 218 QMP_PHY_INIT_CFG(QSERDES_PLL_SSC_STEP_SIZE1_MODE1, 0x08), 219 QMP_PHY_INIT_CFG(QSERDES_PLL_SSC_STEP_SIZE2_MODE1, 0x04), 220 QMP_PHY_INIT_CFG(QSERDES_PLL_BIAS_EN_CLKBUFLR_EN, 0x18), 221 QMP_PHY_INIT_CFG(QSERDES_PLL_CLK_ENABLE1, 0x90), 222 QMP_PHY_INIT_CFG(QSERDES_PLL_SYS_CLK_CTRL, 0x02), 223 QMP_PHY_INIT_CFG(QSERDES_PLL_SYSCLK_BUF_ENABLE, 0x07), 224 QMP_PHY_INIT_CFG(QSERDES_PLL_PLL_IVCO, 0x0f), 225 QMP_PHY_INIT_CFG(QSERDES_PLL_LOCK_CMP1_MODE0, 0xd4), 226 QMP_PHY_INIT_CFG(QSERDES_PLL_LOCK_CMP2_MODE0, 0x14), 227 QMP_PHY_INIT_CFG(QSERDES_PLL_LOCK_CMP1_MODE1, 0xaa), 228 QMP_PHY_INIT_CFG(QSERDES_PLL_LOCK_CMP2_MODE1, 0x29), 229 QMP_PHY_INIT_CFG(QSERDES_PLL_BG_TRIM, 0x0f), 230 QMP_PHY_INIT_CFG(QSERDES_PLL_CP_CTRL_MODE0, 0x09), 231 QMP_PHY_INIT_CFG(QSERDES_PLL_CP_CTRL_MODE1, 0x09), 232 QMP_PHY_INIT_CFG(QSERDES_PLL_PLL_RCTRL_MODE0, 0x16), 233 QMP_PHY_INIT_CFG(QSERDES_PLL_PLL_RCTRL_MODE1, 0x16), 234 QMP_PHY_INIT_CFG(QSERDES_PLL_PLL_CCTRL_MODE0, 0x28), 235 QMP_PHY_INIT_CFG(QSERDES_PLL_PLL_CCTRL_MODE1, 0x28), 236 QMP_PHY_INIT_CFG(QSERDES_PLL_BIAS_EN_CTRL_BY_PSM, 0x01), 237 QMP_PHY_INIT_CFG(QSERDES_PLL_SYSCLK_EN_SEL, 0x08), 238 QMP_PHY_INIT_CFG(QSERDES_PLL_RESETSM_CNTRL, 0x20), 239 QMP_PHY_INIT_CFG(QSERDES_PLL_LOCK_CMP_EN, 0x42), 240 QMP_PHY_INIT_CFG(QSERDES_PLL_DEC_START_MODE0, 0x68), 241 QMP_PHY_INIT_CFG(QSERDES_PLL_DEC_START_MODE1, 0x53), 242 QMP_PHY_INIT_CFG(QSERDES_PLL_DIV_FRAC_START1_MODE0, 0xab), 243 QMP_PHY_INIT_CFG(QSERDES_PLL_DIV_FRAC_START2_MODE0, 0xaa), 244 QMP_PHY_INIT_CFG(QSERDES_PLL_DIV_FRAC_START3_MODE0, 0x02), 245 QMP_PHY_INIT_CFG(QSERDES_PLL_DIV_FRAC_START1_MODE1, 0x55), 246 QMP_PHY_INIT_CFG(QSERDES_PLL_DIV_FRAC_START2_MODE1, 0x55), 247 QMP_PHY_INIT_CFG(QSERDES_PLL_DIV_FRAC_START3_MODE1, 0x05), 248 QMP_PHY_INIT_CFG(QSERDES_PLL_INTEGLOOP_GAIN0_MODE0, 0xa0), 249 QMP_PHY_INIT_CFG(QSERDES_PLL_INTEGLOOP_GAIN0_MODE1, 0xa0), 250 QMP_PHY_INIT_CFG(QSERDES_PLL_VCO_TUNE1_MODE0, 0x24), 251 QMP_PHY_INIT_CFG(QSERDES_PLL_VCO_TUNE2_MODE0, 0x02), 252 QMP_PHY_INIT_CFG(QSERDES_PLL_VCO_TUNE1_MODE1, 0xb4), 253 QMP_PHY_INIT_CFG(QSERDES_PLL_VCO_TUNE2_MODE1, 0x03), 254 QMP_PHY_INIT_CFG(QSERDES_PLL_CLK_SELECT, 0x32), 255 QMP_PHY_INIT_CFG(QSERDES_PLL_HSCLK_SEL, 0x01), 256 QMP_PHY_INIT_CFG(QSERDES_PLL_CORE_CLK_EN, 0x00), 257 QMP_PHY_INIT_CFG(QSERDES_PLL_CMN_CONFIG, 0x06), 258 QMP_PHY_INIT_CFG(QSERDES_PLL_SVS_MODE_CLK_SEL, 0x05), 259 QMP_PHY_INIT_CFG(QSERDES_PLL_CORECLK_DIV_MODE1, 0x08), 260 }; 261 262 static const struct qmp_phy_init_tbl ipq6018_pcie_tx_tbl[] = { 263 QMP_PHY_INIT_CFG(QSERDES_V4_TX_RES_CODE_LANE_OFFSET_TX, 0x02), 264 QMP_PHY_INIT_CFG(QSERDES_V4_TX_LANE_MODE_1, 0x06), 265 QMP_PHY_INIT_CFG(QSERDES_V4_TX_RCV_DETECT_LVL_2, 0x12), 266 }; 267 268 static const struct qmp_phy_init_tbl ipq6018_pcie_rx_tbl[] = { 269 QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_FO_GAIN, 0x0c), 270 QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SO_GAIN, 0x02), 271 QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x7f), 272 QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_PI_CONTROLS, 0x70), 273 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL2, 0x61), 274 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL3, 0x04), 275 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL4, 0x1e), 276 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_IDAC_TSETTLE_LOW, 0xc0), 277 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_IDAC_TSETTLE_HIGH, 0x00), 278 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1, 0x73), 279 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_OFFSET_ADAPTOR_CNTRL2, 0x80), 280 QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_ENABLES, 0x1c), 281 QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_CNTRL, 0x03), 282 QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_DEGLITCH_CNTRL, 0x14), 283 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_LOW, 0xf0), 284 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH, 0x01), 285 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH2, 0x2f), 286 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH3, 0xd3), 287 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH4, 0x40), 288 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_LOW, 0x01), 289 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH, 0x02), 290 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH2, 0xc8), 291 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH3, 0x09), 292 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH4, 0xb1), 293 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_LOW, 0x00), 294 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH, 0x02), 295 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH2, 0xc8), 296 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH3, 0x09), 297 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH4, 0xb1), 298 QMP_PHY_INIT_CFG(QSERDES_V4_RX_DFE_EN_TIMER, 0x04), 299 }; 300 301 static const struct qmp_phy_init_tbl ipq6018_pcie_pcs_tbl[] = { 302 QMP_PHY_INIT_CFG(QPHY_V4_PCS_FLL_CNTRL1, 0x01), 303 QMP_PHY_INIT_CFG(QPHY_V4_PCS_REFGEN_REQ_CONFIG1, 0x0d), 304 QMP_PHY_INIT_CFG(QPHY_V4_PCS_G12S1_TXDEEMPH_M3P5DB, 0x10), 305 QMP_PHY_INIT_CFG(QPHY_V4_PCS_RX_SIGDET_LVL, 0xaa), 306 QMP_PHY_INIT_CFG(QPHY_V4_PCS_P2U3_WAKEUP_DLY_TIME_AUXCLK_L, 0x01), 307 QMP_PHY_INIT_CFG(QPHY_V4_PCS_RX_DCC_CAL_CONFIG, 0x01), 308 QMP_PHY_INIT_CFG(QPHY_V4_PCS_EQ_CONFIG5, 0x01), 309 }; 310 311 static const struct qmp_phy_init_tbl ipq6018_pcie_pcs_misc_tbl[] = { 312 QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_POWER_STATE_CONFIG2, 0x0d), 313 QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_POWER_STATE_CONFIG4, 0x07), 314 QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_ENDPOINT_REFCLK_DRIVE, 0xc1), 315 QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_L1P1_WAKEUP_DLY_TIME_AUXCLK_L, 0x01), 316 QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_L1P2_WAKEUP_DLY_TIME_AUXCLK_L, 0x01), 317 QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_OSC_DTCT_ACTIONS, 0x00), 318 QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_EQ_CONFIG1, 0x11), 319 QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_PRESET_P10_PRE, 0x00), 320 QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_PRESET_P10_POST, 0x58), 321 }; 322 323 static const struct qmp_phy_init_tbl ipq8074_pcie_serdes_tbl[] = { 324 QMP_PHY_INIT_CFG(QSERDES_COM_BIAS_EN_CLKBUFLR_EN, 0x18), 325 QMP_PHY_INIT_CFG(QSERDES_COM_CLK_ENABLE1, 0x10), 326 QMP_PHY_INIT_CFG(QSERDES_COM_BG_TRIM, 0xf), 327 QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP_EN, 0x1), 328 QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_MAP, 0x0), 329 QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_TIMER1, 0xff), 330 QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_TIMER2, 0x1f), 331 QMP_PHY_INIT_CFG(QSERDES_COM_CMN_CONFIG, 0x6), 332 QMP_PHY_INIT_CFG(QSERDES_COM_PLL_IVCO, 0xf), 333 QMP_PHY_INIT_CFG(QSERDES_COM_HSCLK_SEL, 0x0), 334 QMP_PHY_INIT_CFG(QSERDES_COM_SVS_MODE_CLK_SEL, 0x1), 335 QMP_PHY_INIT_CFG(QSERDES_COM_CORE_CLK_EN, 0x20), 336 QMP_PHY_INIT_CFG(QSERDES_COM_CORECLK_DIV, 0xa), 337 QMP_PHY_INIT_CFG(QSERDES_COM_RESETSM_CNTRL, 0x20), 338 QMP_PHY_INIT_CFG(QSERDES_COM_BG_TIMER, 0xa), 339 QMP_PHY_INIT_CFG(QSERDES_COM_SYSCLK_EN_SEL, 0xa), 340 QMP_PHY_INIT_CFG(QSERDES_COM_DEC_START_MODE0, 0x82), 341 QMP_PHY_INIT_CFG(QSERDES_COM_DIV_FRAC_START3_MODE0, 0x3), 342 QMP_PHY_INIT_CFG(QSERDES_COM_DIV_FRAC_START2_MODE0, 0x55), 343 QMP_PHY_INIT_CFG(QSERDES_COM_DIV_FRAC_START1_MODE0, 0x55), 344 QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP3_MODE0, 0x0), 345 QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP2_MODE0, 0xD), 346 QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP1_MODE0, 0xD04), 347 QMP_PHY_INIT_CFG(QSERDES_COM_CLK_SELECT, 0x33), 348 QMP_PHY_INIT_CFG(QSERDES_COM_SYS_CLK_CTRL, 0x2), 349 QMP_PHY_INIT_CFG(QSERDES_COM_SYSCLK_BUF_ENABLE, 0x1f), 350 QMP_PHY_INIT_CFG(QSERDES_COM_CP_CTRL_MODE0, 0xb), 351 QMP_PHY_INIT_CFG(QSERDES_COM_PLL_RCTRL_MODE0, 0x16), 352 QMP_PHY_INIT_CFG(QSERDES_COM_PLL_CCTRL_MODE0, 0x28), 353 QMP_PHY_INIT_CFG(QSERDES_COM_INTEGLOOP_GAIN1_MODE0, 0x0), 354 QMP_PHY_INIT_CFG(QSERDES_COM_INTEGLOOP_GAIN0_MODE0, 0x80), 355 QMP_PHY_INIT_CFG(QSERDES_COM_BIAS_EN_CTRL_BY_PSM, 0x1), 356 QMP_PHY_INIT_CFG(QSERDES_COM_SSC_EN_CENTER, 0x1), 357 QMP_PHY_INIT_CFG(QSERDES_COM_SSC_PER1, 0x31), 358 QMP_PHY_INIT_CFG(QSERDES_COM_SSC_PER2, 0x1), 359 QMP_PHY_INIT_CFG(QSERDES_COM_SSC_ADJ_PER1, 0x2), 360 QMP_PHY_INIT_CFG(QSERDES_COM_SSC_ADJ_PER2, 0x0), 361 QMP_PHY_INIT_CFG(QSERDES_COM_SSC_STEP_SIZE1, 0x2f), 362 QMP_PHY_INIT_CFG(QSERDES_COM_SSC_STEP_SIZE2, 0x19), 363 QMP_PHY_INIT_CFG(QSERDES_COM_CLK_EP_DIV, 0x19), 364 }; 365 366 static const struct qmp_phy_init_tbl ipq8074_pcie_tx_tbl[] = { 367 QMP_PHY_INIT_CFG(QSERDES_TX_HIGHZ_TRANSCEIVEREN_BIAS_DRVR_EN, 0x45), 368 QMP_PHY_INIT_CFG(QSERDES_TX_LANE_MODE, 0x6), 369 QMP_PHY_INIT_CFG(QSERDES_TX_RES_CODE_LANE_OFFSET, 0x2), 370 QMP_PHY_INIT_CFG(QSERDES_TX_RCV_DETECT_LVL_2, 0x12), 371 QMP_PHY_INIT_CFG(QSERDES_TX_TX_EMP_POST1_LVL, 0x36), 372 QMP_PHY_INIT_CFG(QSERDES_TX_SLEW_CNTL, 0x0a), 373 }; 374 375 static const struct qmp_phy_init_tbl ipq8074_pcie_rx_tbl[] = { 376 QMP_PHY_INIT_CFG(QSERDES_RX_SIGDET_ENABLES, 0x1c), 377 QMP_PHY_INIT_CFG(QSERDES_RX_SIGDET_DEGLITCH_CNTRL, 0x14), 378 QMP_PHY_INIT_CFG(QSERDES_RX_RX_EQU_ADAPTOR_CNTRL2, 0x1), 379 QMP_PHY_INIT_CFG(QSERDES_RX_RX_EQU_ADAPTOR_CNTRL3, 0x0), 380 QMP_PHY_INIT_CFG(QSERDES_RX_RX_EQU_ADAPTOR_CNTRL4, 0xdb), 381 QMP_PHY_INIT_CFG(QSERDES_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x4b), 382 QMP_PHY_INIT_CFG(QSERDES_RX_UCDR_SO_GAIN, 0x4), 383 }; 384 385 static const struct qmp_phy_init_tbl ipq8074_pcie_pcs_tbl[] = { 386 QMP_PHY_INIT_CFG(QPHY_V2_PCS_ENDPOINT_REFCLK_DRIVE, 0x4), 387 QMP_PHY_INIT_CFG(QPHY_V2_PCS_OSC_DTCT_ACTIONS, 0x0), 388 QMP_PHY_INIT_CFG(QPHY_V2_PCS_PWRUP_RESET_DLY_TIME_AUXCLK, 0x40), 389 QMP_PHY_INIT_CFG(QPHY_V2_PCS_L1SS_WAKEUP_DLY_TIME_AUXCLK_MSB, 0x0), 390 QMP_PHY_INIT_CFG(QPHY_V2_PCS_L1SS_WAKEUP_DLY_TIME_AUXCLK_LSB, 0x40), 391 QMP_PHY_INIT_CFG(QPHY_V2_PCS_PLL_LOCK_CHK_DLY_TIME_AUXCLK_LSB, 0x0), 392 QMP_PHY_INIT_CFG(QPHY_V2_PCS_LP_WAKEUP_DLY_TIME_AUXCLK, 0x40), 393 QMP_PHY_INIT_CFG(QPHY_V2_PCS_PLL_LOCK_CHK_DLY_TIME, 0x73), 394 QMP_PHY_INIT_CFG(QPHY_V2_PCS_RX_SIGDET_LVL, 0x99), 395 QMP_PHY_INIT_CFG(QPHY_V2_PCS_TXDEEMPH_M6DB_V0, 0x15), 396 QMP_PHY_INIT_CFG(QPHY_V2_PCS_TXDEEMPH_M3P5DB_V0, 0xe), 397 QMP_PHY_INIT_CFG_L(QPHY_SW_RESET, 0x0), 398 QMP_PHY_INIT_CFG_L(QPHY_START_CTRL, 0x3), 399 }; 400 401 static const struct qmp_phy_init_tbl ipq8074_pcie_gen3_serdes_tbl[] = { 402 QMP_PHY_INIT_CFG(QSERDES_PLL_BIAS_EN_CLKBUFLR_EN, 0x18), 403 QMP_PHY_INIT_CFG(QSERDES_PLL_BIAS_EN_CTRL_BY_PSM, 0x01), 404 QMP_PHY_INIT_CFG(QSERDES_PLL_CLK_SELECT, 0x31), 405 QMP_PHY_INIT_CFG(QSERDES_PLL_PLL_IVCO, 0x0f), 406 QMP_PHY_INIT_CFG(QSERDES_PLL_BG_TRIM, 0x0f), 407 QMP_PHY_INIT_CFG(QSERDES_PLL_CMN_CONFIG, 0x06), 408 QMP_PHY_INIT_CFG(QSERDES_PLL_LOCK_CMP_EN, 0x42), 409 QMP_PHY_INIT_CFG(QSERDES_PLL_RESETSM_CNTRL, 0x20), 410 QMP_PHY_INIT_CFG(QSERDES_PLL_SVS_MODE_CLK_SEL, 0x01), 411 QMP_PHY_INIT_CFG(QSERDES_PLL_VCO_TUNE_MAP, 0x04), 412 QMP_PHY_INIT_CFG(QSERDES_PLL_SVS_MODE_CLK_SEL, 0x05), 413 QMP_PHY_INIT_CFG(QSERDES_PLL_VCO_TUNE_TIMER1, 0xff), 414 QMP_PHY_INIT_CFG(QSERDES_PLL_VCO_TUNE_TIMER2, 0x3f), 415 QMP_PHY_INIT_CFG(QSERDES_PLL_CORE_CLK_EN, 0x30), 416 QMP_PHY_INIT_CFG(QSERDES_PLL_HSCLK_SEL, 0x21), 417 QMP_PHY_INIT_CFG(QSERDES_PLL_DEC_START_MODE0, 0x82), 418 QMP_PHY_INIT_CFG(QSERDES_PLL_DIV_FRAC_START3_MODE0, 0x03), 419 QMP_PHY_INIT_CFG(QSERDES_PLL_DIV_FRAC_START2_MODE0, 0x355), 420 QMP_PHY_INIT_CFG(QSERDES_PLL_DIV_FRAC_START1_MODE0, 0x35555), 421 QMP_PHY_INIT_CFG(QSERDES_PLL_LOCK_CMP2_MODE0, 0x1a), 422 QMP_PHY_INIT_CFG(QSERDES_PLL_LOCK_CMP1_MODE0, 0x1a0a), 423 QMP_PHY_INIT_CFG(QSERDES_PLL_CP_CTRL_MODE0, 0xb), 424 QMP_PHY_INIT_CFG(QSERDES_PLL_PLL_RCTRL_MODE0, 0x16), 425 QMP_PHY_INIT_CFG(QSERDES_PLL_PLL_CCTRL_MODE0, 0x28), 426 QMP_PHY_INIT_CFG(QSERDES_PLL_INTEGLOOP_GAIN1_MODE0, 0x0), 427 QMP_PHY_INIT_CFG(QSERDES_PLL_INTEGLOOP_GAIN0_MODE0, 0x40), 428 QMP_PHY_INIT_CFG(QSERDES_PLL_VCO_TUNE2_MODE0, 0x02), 429 QMP_PHY_INIT_CFG(QSERDES_PLL_VCO_TUNE1_MODE0, 0x24), 430 QMP_PHY_INIT_CFG(QSERDES_PLL_SVS_MODE_CLK_SEL, 0x05), 431 QMP_PHY_INIT_CFG(QSERDES_PLL_CORE_CLK_EN, 0x20), 432 QMP_PHY_INIT_CFG(QSERDES_PLL_CORECLK_DIV, 0xa), 433 QMP_PHY_INIT_CFG(QSERDES_PLL_CLK_SELECT, 0x32), 434 QMP_PHY_INIT_CFG(QSERDES_PLL_SYS_CLK_CTRL, 0x02), 435 QMP_PHY_INIT_CFG(QSERDES_PLL_SYSCLK_BUF_ENABLE, 0x07), 436 QMP_PHY_INIT_CFG(QSERDES_PLL_SYSCLK_EN_SEL, 0x08), 437 QMP_PHY_INIT_CFG(QSERDES_PLL_BG_TIMER, 0xa), 438 QMP_PHY_INIT_CFG(QSERDES_PLL_HSCLK_SEL, 0x1), 439 QMP_PHY_INIT_CFG(QSERDES_PLL_DEC_START_MODE1, 0x68), 440 QMP_PHY_INIT_CFG(QSERDES_PLL_DIV_FRAC_START3_MODE1, 0x2), 441 QMP_PHY_INIT_CFG(QSERDES_PLL_DIV_FRAC_START2_MODE1, 0x2aa), 442 QMP_PHY_INIT_CFG(QSERDES_PLL_DIV_FRAC_START1_MODE1, 0x2aaab), 443 QMP_PHY_INIT_CFG(QSERDES_PLL_CLK_ENABLE1, 0x90), 444 QMP_PHY_INIT_CFG(QSERDES_PLL_LOCK_CMP2_MODE1, 0x34), 445 QMP_PHY_INIT_CFG(QSERDES_PLL_LOCK_CMP1_MODE1, 0x3414), 446 QMP_PHY_INIT_CFG(QSERDES_PLL_CP_CTRL_MODE1, 0x0b), 447 QMP_PHY_INIT_CFG(QSERDES_PLL_PLL_RCTRL_MODE1, 0x16), 448 QMP_PHY_INIT_CFG(QSERDES_PLL_PLL_CCTRL_MODE1, 0x28), 449 QMP_PHY_INIT_CFG(QSERDES_PLL_INTEGLOOP_GAIN1_MODE1, 0x0), 450 QMP_PHY_INIT_CFG(QSERDES_PLL_INTEGLOOP_GAIN0_MODE1, 0x40), 451 QMP_PHY_INIT_CFG(QSERDES_PLL_VCO_TUNE2_MODE1, 0x03), 452 QMP_PHY_INIT_CFG(QSERDES_PLL_VCO_TUNE1_MODE1, 0xb4), 453 QMP_PHY_INIT_CFG(QSERDES_PLL_SVS_MODE_CLK_SEL, 0x05), 454 QMP_PHY_INIT_CFG(QSERDES_PLL_CORE_CLK_EN, 0x0), 455 QMP_PHY_INIT_CFG(QSERDES_PLL_CORECLK_DIV_MODE1, 0x08), 456 QMP_PHY_INIT_CFG(QSERDES_PLL_CLK_EP_DIV_MODE0, 0x19), 457 QMP_PHY_INIT_CFG(QSERDES_PLL_CLK_EP_DIV_MODE1, 0x28), 458 QMP_PHY_INIT_CFG(QSERDES_PLL_CLK_ENABLE1, 0x90), 459 }; 460 461 static const struct qmp_phy_init_tbl ipq8074_pcie_gen3_tx_tbl[] = { 462 QMP_PHY_INIT_CFG(QSERDES_V4_TX_RES_CODE_LANE_OFFSET_TX, 0x02), 463 QMP_PHY_INIT_CFG(QSERDES_V4_TX_RCV_DETECT_LVL_2, 0x12), 464 QMP_PHY_INIT_CFG(QSERDES_V4_TX_HIGHZ_DRVR_EN, 0x10), 465 QMP_PHY_INIT_CFG(QSERDES_V4_TX_LANE_MODE_1, 0x06), 466 }; 467 468 static const struct qmp_phy_init_tbl ipq8074_pcie_gen3_rx_tbl[] = { 469 QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_CNTRL, 0x03), 470 QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_ENABLES, 0x1c), 471 QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_DEGLITCH_CNTRL, 0x14), 472 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL2, 0xe), 473 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL3, 0x4), 474 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL4, 0x1b), 475 QMP_PHY_INIT_CFG(QSERDES_V4_RX_DFE_EN_TIMER, 0x04), 476 QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x7f), 477 QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_PI_CONTROLS, 0x70), 478 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1, 0x73), 479 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_OFFSET_ADAPTOR_CNTRL2, 0x80), 480 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_LOW, 0x00), 481 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH, 0x02), 482 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH2, 0xc8), 483 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH3, 0x09), 484 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH4, 0xb1), 485 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_LOW, 0x01), 486 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH, 0x02), 487 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH2, 0xc8), 488 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH3, 0x09), 489 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH4, 0xb1), 490 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_LOW, 0xf0), 491 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH, 0x2), 492 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH2, 0x2f), 493 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH3, 0xd3), 494 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH4, 0x40), 495 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_IDAC_TSETTLE_HIGH, 0x00), 496 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_IDAC_TSETTLE_LOW, 0xc0), 497 QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_FO_GAIN, 0x0c), 498 QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SO_GAIN, 0x02), 499 }; 500 501 static const struct qmp_phy_init_tbl ipq8074_pcie_gen3_pcs_tbl[] = { 502 QMP_PHY_INIT_CFG(QPHY_V4_PCS_FLL_CNTRL2, 0x83), 503 QMP_PHY_INIT_CFG(QPHY_V4_PCS_FLL_CNT_VAL_L, 0x9), 504 QMP_PHY_INIT_CFG(QPHY_V4_PCS_FLL_CNT_VAL_H_TOL, 0x42), 505 QMP_PHY_INIT_CFG(QPHY_V4_PCS_FLL_MAN_CODE, 0x40), 506 QMP_PHY_INIT_CFG(QPHY_V4_PCS_FLL_CNTRL1, 0x01), 507 QMP_PHY_INIT_CFG(QPHY_V4_PCS_P2U3_WAKEUP_DLY_TIME_AUXCLK_H, 0x0), 508 QMP_PHY_INIT_CFG(QPHY_V4_PCS_P2U3_WAKEUP_DLY_TIME_AUXCLK_L, 0x1), 509 QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_OSC_DTCT_ACTIONS, 0x0), 510 QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_L1P1_WAKEUP_DLY_TIME_AUXCLK_H, 0x00), 511 QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_L1P1_WAKEUP_DLY_TIME_AUXCLK_L, 0x01), 512 QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_L1P2_WAKEUP_DLY_TIME_AUXCLK_H, 0x00), 513 QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_L1P2_WAKEUP_DLY_TIME_AUXCLK_L, 0x01), 514 QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_EQ_CONFIG1, 0x11), 515 QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_EQ_CONFIG2, 0xb), 516 QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_POWER_STATE_CONFIG4, 0x07), 517 QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_OSC_DTCT_CONFIG2, 0x52), 518 QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_OSC_DTCT_MODE2_CONFIG2, 0x50), 519 QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_OSC_DTCT_MODE2_CONFIG4, 0x1a), 520 QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_OSC_DTCT_MODE2_CONFIG5, 0x6), 521 QMP_PHY_INIT_CFG(QPHY_V4_PCS_G12S1_TXDEEMPH_M3P5DB, 0x10), 522 QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_ENDPOINT_REFCLK_DRIVE, 0xc1), 523 QMP_PHY_INIT_CFG(QPHY_V4_PCS_RX_DCC_CAL_CONFIG, 0x01), 524 QMP_PHY_INIT_CFG(QPHY_V4_PCS_RX_SIGDET_LVL, 0xaa), 525 QMP_PHY_INIT_CFG(QPHY_V4_PCS_REFGEN_REQ_CONFIG1, 0x0d), 526 }; 527 528 static const struct qmp_phy_init_tbl sdm845_qmp_pcie_serdes_tbl[] = { 529 QMP_PHY_INIT_CFG(QSERDES_V3_COM_BIAS_EN_CLKBUFLR_EN, 0x14), 530 QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_SELECT, 0x30), 531 QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_IVCO, 0x007), 532 QMP_PHY_INIT_CFG(QSERDES_V3_COM_CMN_CONFIG, 0x06), 533 QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP_EN, 0x01), 534 QMP_PHY_INIT_CFG(QSERDES_V3_COM_RESETSM_CNTRL, 0x20), 535 QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_MAP, 0x00), 536 QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE2_MODE0, 0x01), 537 QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE1_MODE0, 0xc9), 538 QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_TIMER1, 0xff), 539 QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_TIMER2, 0x3f), 540 QMP_PHY_INIT_CFG(QSERDES_V3_COM_SVS_MODE_CLK_SEL, 0x01), 541 QMP_PHY_INIT_CFG(QSERDES_V3_COM_CORE_CLK_EN, 0x00), 542 QMP_PHY_INIT_CFG(QSERDES_V3_COM_CORECLK_DIV_MODE0, 0x0a), 543 QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_EP_DIV, 0x19), 544 QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_ENABLE1, 0x90), 545 QMP_PHY_INIT_CFG(QSERDES_V3_COM_DEC_START_MODE0, 0x82), 546 QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START3_MODE0, 0x02), 547 QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START2_MODE0, 0xea), 548 QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START1_MODE0, 0xab), 549 QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP3_MODE0, 0x00), 550 QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP2_MODE0, 0x0d), 551 QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP1_MODE0, 0x04), 552 QMP_PHY_INIT_CFG(QSERDES_V3_COM_HSCLK_SEL, 0x00), 553 QMP_PHY_INIT_CFG(QSERDES_V3_COM_CP_CTRL_MODE0, 0x06), 554 QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_RCTRL_MODE0, 0x16), 555 QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_CCTRL_MODE0, 0x36), 556 QMP_PHY_INIT_CFG(QSERDES_V3_COM_CMN_MODE, 0x01), 557 QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_SELECT, 0x33), 558 QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYS_CLK_CTRL, 0x02), 559 QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYSCLK_BUF_ENABLE, 0x06), 560 QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYSCLK_EN_SEL, 0x04), 561 QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN1_MODE0, 0x00), 562 QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN0_MODE0, 0x3f), 563 QMP_PHY_INIT_CFG(QSERDES_V3_COM_BG_TIMER, 0x09), 564 QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_EN_CENTER, 0x01), 565 QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_PER1, 0x40), 566 QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_PER2, 0x01), 567 QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_ADJ_PER1, 0x02), 568 QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_ADJ_PER2, 0x00), 569 QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_STEP_SIZE1, 0x7e), 570 QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_STEP_SIZE2, 0x15), 571 }; 572 573 static const struct qmp_phy_init_tbl sdm845_qmp_pcie_tx_tbl[] = { 574 QMP_PHY_INIT_CFG(QSERDES_V3_TX_RES_CODE_LANE_OFFSET_TX, 0x02), 575 QMP_PHY_INIT_CFG(QSERDES_V3_TX_RCV_DETECT_LVL_2, 0x12), 576 QMP_PHY_INIT_CFG(QSERDES_V3_TX_HIGHZ_DRVR_EN, 0x10), 577 QMP_PHY_INIT_CFG(QSERDES_V3_TX_LANE_MODE_1, 0x06), 578 }; 579 580 static const struct qmp_phy_init_tbl sdm845_qmp_pcie_rx_tbl[] = { 581 QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_CNTRL, 0x03), 582 QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_ENABLES, 0x10), 583 QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_DEGLITCH_CNTRL, 0x14), 584 QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL2, 0x0e), 585 QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL3, 0x04), 586 QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL4, 0x1a), 587 QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x4b), 588 QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SO_GAIN, 0x04), 589 QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SO_GAIN_HALF, 0x04), 590 QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1, 0x71), 591 QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_MODE_00, 0x59), 592 QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_MODE_01, 0x59), 593 QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_OFFSET_ADAPTOR_CNTRL2, 0x80), 594 QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_INTERFACE_MODE, 0x40), 595 QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_PI_CONTROLS, 0x71), 596 QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_FASTLOCK_COUNT_LOW, 0x40), 597 }; 598 599 static const struct qmp_phy_init_tbl sdm845_qmp_pcie_pcs_tbl[] = { 600 QMP_PHY_INIT_CFG(QPHY_V3_PCS_ENDPOINT_REFCLK_DRIVE, 0x04), 601 602 QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNTRL2, 0x83), 603 QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNT_VAL_L, 0x09), 604 QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNT_VAL_H_TOL, 0xa2), 605 QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_MAN_CODE, 0x40), 606 QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNTRL1, 0x02), 607 608 QMP_PHY_INIT_CFG(QPHY_V3_PCS_OSC_DTCT_ACTIONS, 0x00), 609 QMP_PHY_INIT_CFG(QPHY_V3_PCS_PWRUP_RESET_DLY_TIME_AUXCLK, 0x01), 610 QMP_PHY_INIT_CFG(QPHY_V3_PCS_L1SS_WAKEUP_DLY_TIME_AUXCLK_MSB, 0x00), 611 QMP_PHY_INIT_CFG(QPHY_V3_PCS_L1SS_WAKEUP_DLY_TIME_AUXCLK_LSB, 0x20), 612 QMP_PHY_INIT_CFG(QPHY_V3_PCS_LP_WAKEUP_DLY_TIME_AUXCLK_MSB, 0x00), 613 QMP_PHY_INIT_CFG(QPHY_V3_PCS_LP_WAKEUP_DLY_TIME_AUXCLK, 0x01), 614 QMP_PHY_INIT_CFG(QPHY_V3_PCS_PLL_LOCK_CHK_DLY_TIME, 0x73), 615 616 QMP_PHY_INIT_CFG(QPHY_V3_PCS_RX_SIGDET_LVL, 0xbb), 617 QMP_PHY_INIT_CFG(QPHY_V3_PCS_SIGDET_CNTRL, 0x03), 618 QMP_PHY_INIT_CFG(QPHY_V3_PCS_REFGEN_REQ_CONFIG1, 0x0d), 619 620 QMP_PHY_INIT_CFG(QPHY_V3_PCS_POWER_STATE_CONFIG4, 0x00), 621 }; 622 623 static const struct qmp_phy_init_tbl sdm845_qmp_pcie_pcs_misc_tbl[] = { 624 QMP_PHY_INIT_CFG(QPHY_V3_PCS_MISC_OSC_DTCT_CONFIG2, 0x52), 625 QMP_PHY_INIT_CFG(QPHY_V3_PCS_MISC_OSC_DTCT_MODE2_CONFIG2, 0x10), 626 QMP_PHY_INIT_CFG(QPHY_V3_PCS_MISC_OSC_DTCT_MODE2_CONFIG4, 0x1a), 627 QMP_PHY_INIT_CFG(QPHY_V3_PCS_MISC_OSC_DTCT_MODE2_CONFIG5, 0x06), 628 QMP_PHY_INIT_CFG(QPHY_V3_PCS_MISC_PCIE_INT_AUX_CLK_CONFIG1, 0x00), 629 }; 630 631 static const struct qmp_phy_init_tbl sdm845_qhp_pcie_serdes_tbl[] = { 632 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_SYSCLK_EN_SEL, 0x27), 633 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_SSC_EN_CENTER, 0x01), 634 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_SSC_PER1, 0x31), 635 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_SSC_PER2, 0x01), 636 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_SSC_STEP_SIZE1, 0xde), 637 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_SSC_STEP_SIZE2, 0x07), 638 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_SSC_STEP_SIZE1_MODE1, 0x4c), 639 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_SSC_STEP_SIZE2_MODE1, 0x06), 640 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_BIAS_EN_CKBUFLR_EN, 0x18), 641 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_CLK_ENABLE1, 0xb0), 642 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_LOCK_CMP1_MODE0, 0x8c), 643 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_LOCK_CMP2_MODE0, 0x20), 644 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_LOCK_CMP1_MODE1, 0x14), 645 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_LOCK_CMP2_MODE1, 0x34), 646 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_CP_CTRL_MODE0, 0x06), 647 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_CP_CTRL_MODE1, 0x06), 648 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_PLL_RCTRL_MODE0, 0x16), 649 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_PLL_RCTRL_MODE1, 0x16), 650 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_PLL_CCTRL_MODE0, 0x36), 651 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_PLL_CCTRL_MODE1, 0x36), 652 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_RESTRIM_CTRL2, 0x05), 653 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_LOCK_CMP_EN, 0x42), 654 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_DEC_START_MODE0, 0x82), 655 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_DEC_START_MODE1, 0x68), 656 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_DIV_FRAC_START1_MODE0, 0x55), 657 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_DIV_FRAC_START2_MODE0, 0x55), 658 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_DIV_FRAC_START3_MODE0, 0x03), 659 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_DIV_FRAC_START1_MODE1, 0xab), 660 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_DIV_FRAC_START2_MODE1, 0xaa), 661 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_DIV_FRAC_START3_MODE1, 0x02), 662 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_INTEGLOOP_GAIN0_MODE0, 0x3f), 663 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_INTEGLOOP_GAIN0_MODE1, 0x3f), 664 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_VCO_TUNE_MAP, 0x10), 665 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_CLK_SELECT, 0x04), 666 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_HSCLK_SEL1, 0x30), 667 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_CORECLK_DIV, 0x04), 668 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_CORE_CLK_EN, 0x73), 669 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_CMN_CONFIG, 0x0c), 670 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_SVS_MODE_CLK_SEL, 0x15), 671 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_CORECLK_DIV_MODE1, 0x04), 672 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_CMN_MODE, 0x01), 673 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_VREGCLK_DIV1, 0x22), 674 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_VREGCLK_DIV2, 0x00), 675 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_BGV_TRIM, 0x20), 676 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_BG_CTRL, 0x07), 677 }; 678 679 static const struct qmp_phy_init_tbl sdm845_qhp_pcie_tx_tbl[] = { 680 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_DRVR_CTRL0, 0x00), 681 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_DRVR_TAP_EN, 0x0d), 682 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_TX_BAND_MODE, 0x01), 683 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_LANE_MODE, 0x1a), 684 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_PARALLEL_RATE, 0x2f), 685 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_CML_CTRL_MODE0, 0x09), 686 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_CML_CTRL_MODE1, 0x09), 687 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_CML_CTRL_MODE2, 0x1b), 688 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_PREAMP_CTRL_MODE1, 0x01), 689 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_PREAMP_CTRL_MODE2, 0x07), 690 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_MIXER_CTRL_MODE0, 0x31), 691 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_MIXER_CTRL_MODE1, 0x31), 692 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_MIXER_CTRL_MODE2, 0x03), 693 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_CTLE_THRESH_DFE, 0x02), 694 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_CGA_THRESH_DFE, 0x00), 695 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RXENGINE_EN0, 0x12), 696 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_CTLE_TRAIN_TIME, 0x25), 697 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_CTLE_DFE_OVRLP_TIME, 0x00), 698 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_DFE_REFRESH_TIME, 0x05), 699 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_DFE_ENABLE_TIME, 0x01), 700 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_VGA_GAIN, 0x26), 701 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_DFE_GAIN, 0x12), 702 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_EQ_GAIN, 0x04), 703 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_OFFSET_GAIN, 0x04), 704 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_PRE_GAIN, 0x09), 705 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_EQ_INTVAL, 0x15), 706 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_EDAC_INITVAL, 0x28), 707 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RXEQ_INITB0, 0x7f), 708 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RXEQ_INITB1, 0x07), 709 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RCVRDONE_THRESH1, 0x04), 710 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RXEQ_CTRL, 0x70), 711 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_UCDR_FO_GAIN_MODE0, 0x8b), 712 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_UCDR_FO_GAIN_MODE1, 0x08), 713 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_UCDR_FO_GAIN_MODE2, 0x0a), 714 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_UCDR_SO_GAIN_MODE0, 0x03), 715 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_UCDR_SO_GAIN_MODE1, 0x04), 716 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_UCDR_SO_GAIN_MODE2, 0x04), 717 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_UCDR_SO_CONFIG, 0x0c), 718 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RX_BAND, 0x02), 719 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RX_RCVR_PATH1_MODE0, 0x5c), 720 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RX_RCVR_PATH1_MODE1, 0x3e), 721 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RX_RCVR_PATH1_MODE2, 0x3f), 722 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_SIGDET_ENABLES, 0x01), 723 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_SIGDET_CNTRL, 0xa0), 724 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_SIGDET_DEGLITCH_CNTRL, 0x08), 725 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_DCC_GAIN, 0x01), 726 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RX_EN_SIGNAL, 0xc3), 727 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_PSM_RX_EN_CAL, 0x00), 728 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RX_MISC_CNTRL0, 0xbc), 729 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_TS0_TIMER, 0x7f), 730 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_DLL_HIGHDATARATE, 0x15), 731 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_DRVR_CTRL1, 0x0c), 732 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_DRVR_CTRL2, 0x0f), 733 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RX_RESETCODE_OFFSET, 0x04), 734 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_VGA_INITVAL, 0x20), 735 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RSM_START, 0x01), 736 }; 737 738 static const struct qmp_phy_init_tbl sdm845_qhp_pcie_rx_tbl[] = { 739 }; 740 741 static const struct qmp_phy_init_tbl sdm845_qhp_pcie_pcs_tbl[] = { 742 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_PHY_POWER_STATE_CONFIG, 0x3f), 743 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_PHY_PCS_TX_RX_CONFIG, 0x50), 744 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_PHY_TXMGN_MAIN_V0_M3P5DB, 0x19), 745 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_PHY_TXMGN_POST_V0_M3P5DB, 0x07), 746 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_PHY_TXMGN_MAIN_V0_M6DB, 0x17), 747 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_PHY_TXMGN_POST_V0_M6DB, 0x09), 748 QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_PHY_POWER_STATE_CONFIG5, 0x9f), 749 }; 750 751 static const struct qmp_phy_init_tbl sc8180x_qmp_pcie_serdes_tbl[] = { 752 QMP_PHY_INIT_CFG(QSERDES_V4_COM_SYSCLK_EN_SEL, 0x08), 753 QMP_PHY_INIT_CFG(QSERDES_V4_COM_CLK_SELECT, 0x34), 754 QMP_PHY_INIT_CFG(QSERDES_V4_COM_CORECLK_DIV_MODE1, 0x08), 755 QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_IVCO, 0x0f), 756 QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP_EN, 0x42), 757 QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE1_MODE0, 0x24), 758 QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE2_MODE1, 0x03), 759 QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE1_MODE1, 0xb4), 760 QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE_MAP, 0x02), 761 QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_HSCLK_SEL, 0x11), 762 QMP_PHY_INIT_CFG(QSERDES_V4_COM_DEC_START_MODE0, 0x82), 763 QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START3_MODE0, 0x03), 764 QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START2_MODE0, 0x55), 765 QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START1_MODE0, 0x55), 766 QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP2_MODE0, 0x1a), 767 QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP1_MODE0, 0x0a), 768 QMP_PHY_INIT_CFG(QSERDES_V4_COM_DEC_START_MODE1, 0x68), 769 QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START3_MODE1, 0x02), 770 QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START2_MODE1, 0xaa), 771 QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START1_MODE1, 0xab), 772 QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP2_MODE1, 0x34), 773 QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP1_MODE1, 0x14), 774 QMP_PHY_INIT_CFG(QSERDES_V4_COM_HSCLK_SEL, 0x01), 775 QMP_PHY_INIT_CFG(QSERDES_V4_COM_CP_CTRL_MODE0, 0x06), 776 QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_RCTRL_MODE0, 0x16), 777 QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_CCTRL_MODE0, 0x36), 778 QMP_PHY_INIT_CFG(QSERDES_V4_COM_CP_CTRL_MODE1, 0x06), 779 QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_RCTRL_MODE1, 0x16), 780 QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_CCTRL_MODE1, 0x36), 781 QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE2_MODE0, 0x1e), 782 QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE1_MODE0, 0xca), 783 QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE2_MODE1, 0x18), 784 QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE1_MODE1, 0xa2), 785 QMP_PHY_INIT_CFG(QSERDES_V4_COM_SYSCLK_BUF_ENABLE, 0x07), 786 QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_EN_CENTER, 0x01), 787 QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_PER1, 0x31), 788 QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_PER2, 0x01), 789 QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_STEP_SIZE1_MODE0, 0xde), 790 QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_STEP_SIZE2_MODE0, 0x07), 791 QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_STEP_SIZE1_MODE1, 0x4c), 792 QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_STEP_SIZE2_MODE1, 0x06), 793 QMP_PHY_INIT_CFG(QSERDES_V4_COM_CLK_ENABLE1, 0x90), 794 }; 795 796 static const struct qmp_phy_init_tbl sc8180x_qmp_pcie_tx_tbl[] = { 797 QMP_PHY_INIT_CFG(QSERDES_V4_TX_RCV_DETECT_LVL_2, 0x12), 798 QMP_PHY_INIT_CFG(QSERDES_V4_TX_LANE_MODE_1, 0x5), 799 }; 800 801 static const struct qmp_phy_init_tbl sc8180x_qmp_pcie_rx_tbl[] = { 802 QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_CNTRL, 0x03), 803 QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_ENABLES, 0x1c), 804 QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_DEGLITCH_CNTRL, 0x14), 805 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL1, 0x07), 806 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL2, 0x6e), 807 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL3, 0x6e), 808 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL4, 0x4a), 809 QMP_PHY_INIT_CFG(QSERDES_V4_RX_DFE_EN_TIMER, 0x04), 810 QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x7f), 811 QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_PI_CONTROLS, 0x70), 812 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1, 0x17), 813 QMP_PHY_INIT_CFG(QSERDES_V4_RX_VGA_CAL_CNTRL1, 0x54), 814 QMP_PHY_INIT_CFG(QSERDES_V4_RX_VGA_CAL_CNTRL2, 0x37), 815 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_LOW, 0xd4), 816 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH, 0x54), 817 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH2, 0xdb), 818 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH3, 0x39), 819 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH4, 0x31), 820 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_LOW, 0x24), 821 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH, 0xe4), 822 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH2, 0xec), 823 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH3, 0x39), 824 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH4, 0x36), 825 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_LOW, 0x7f), 826 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH, 0xff), 827 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH2, 0xff), 828 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH3, 0xdb), 829 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH4, 0x75), 830 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_IDAC_TSETTLE_HIGH, 0x00), 831 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_IDAC_TSETTLE_LOW, 0xc0), 832 QMP_PHY_INIT_CFG(QSERDES_V4_RX_AUX_DATA_TCOARSE_TFINE, 0xa0), 833 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RCLK_AUXDATA_SEL, 0xc0), 834 QMP_PHY_INIT_CFG(QSERDES_V4_RX_DCC_CTRL1, 0x0c), 835 QMP_PHY_INIT_CFG(QSERDES_V4_RX_GM_CAL, 0x05), 836 QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_FO_GAIN, 0x0c), 837 QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SO_GAIN, 0x03), 838 }; 839 840 static const struct qmp_phy_init_tbl sc8180x_qmp_pcie_pcs_tbl[] = { 841 QMP_PHY_INIT_CFG(QPHY_V4_PCS_P2U3_WAKEUP_DLY_TIME_AUXCLK_L, 0x01), 842 QMP_PHY_INIT_CFG(QPHY_V4_PCS_RX_SIGDET_LVL, 0xaa), 843 QMP_PHY_INIT_CFG(QPHY_V4_PCS_RATE_SLEW_CNTRL1, 0x0b), 844 QMP_PHY_INIT_CFG(QPHY_V4_PCS_REFGEN_REQ_CONFIG1, 0x0d), 845 QMP_PHY_INIT_CFG(QPHY_V4_PCS_EQ_CONFIG5, 0x01), 846 }; 847 848 static const struct qmp_phy_init_tbl sc8180x_qmp_pcie_pcs_misc_tbl[] = { 849 QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_OSC_DTCT_ACTIONS, 0x00), 850 QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_L1P1_WAKEUP_DLY_TIME_AUXCLK_L, 0x01), 851 QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_L1P2_WAKEUP_DLY_TIME_AUXCLK_L, 0x01), 852 QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_INT_AUX_CLK_CONFIG1, 0x00), 853 QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_PRESET_P10_PRE, 0x00), 854 QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_PRESET_P10_POST, 0x58), 855 QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_ENDPOINT_REFCLK_DRIVE, 0xc1), 856 }; 857 858 static const struct qmp_phy_init_tbl sm8250_qmp_pcie_serdes_tbl[] = { 859 QMP_PHY_INIT_CFG(QSERDES_V4_COM_SYSCLK_EN_SEL, 0x08), 860 QMP_PHY_INIT_CFG(QSERDES_V4_COM_CLK_SELECT, 0x34), 861 QMP_PHY_INIT_CFG(QSERDES_V4_COM_CORECLK_DIV_MODE1, 0x08), 862 QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_IVCO, 0x0f), 863 QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP_EN, 0x42), 864 QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE1_MODE0, 0x24), 865 QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE2_MODE1, 0x03), 866 QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE1_MODE1, 0xb4), 867 QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE_MAP, 0x02), 868 QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_HSCLK_SEL, 0x11), 869 QMP_PHY_INIT_CFG(QSERDES_V4_COM_DEC_START_MODE0, 0x82), 870 QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START3_MODE0, 0x03), 871 QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START2_MODE0, 0x55), 872 QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START1_MODE0, 0x55), 873 QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP2_MODE0, 0x1a), 874 QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP1_MODE0, 0x0a), 875 QMP_PHY_INIT_CFG(QSERDES_V4_COM_DEC_START_MODE1, 0x68), 876 QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START3_MODE1, 0x02), 877 QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START2_MODE1, 0xaa), 878 QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START1_MODE1, 0xab), 879 QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP2_MODE1, 0x34), 880 QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP1_MODE1, 0x14), 881 QMP_PHY_INIT_CFG(QSERDES_V4_COM_HSCLK_SEL, 0x01), 882 QMP_PHY_INIT_CFG(QSERDES_V4_COM_CP_CTRL_MODE0, 0x06), 883 QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_RCTRL_MODE0, 0x16), 884 QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_CCTRL_MODE0, 0x36), 885 QMP_PHY_INIT_CFG(QSERDES_V4_COM_CP_CTRL_MODE1, 0x06), 886 QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_RCTRL_MODE1, 0x16), 887 QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_CCTRL_MODE1, 0x36), 888 QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE2_MODE0, 0x1e), 889 QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE1_MODE0, 0xca), 890 QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE2_MODE1, 0x18), 891 QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE1_MODE1, 0xa2), 892 QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_EN_CENTER, 0x01), 893 QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_PER1, 0x31), 894 QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_PER2, 0x01), 895 QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_STEP_SIZE1_MODE0, 0xde), 896 QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_STEP_SIZE2_MODE0, 0x07), 897 QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_STEP_SIZE1_MODE1, 0x4c), 898 QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_STEP_SIZE2_MODE1, 0x06), 899 QMP_PHY_INIT_CFG(QSERDES_V4_COM_CLK_ENABLE1, 0x90), 900 }; 901 902 static const struct qmp_phy_init_tbl sm8250_qmp_gen3x1_pcie_serdes_tbl[] = { 903 QMP_PHY_INIT_CFG(QSERDES_V4_COM_SYSCLK_BUF_ENABLE, 0x07), 904 }; 905 906 static const struct qmp_phy_init_tbl sm8250_qmp_pcie_tx_tbl[] = { 907 QMP_PHY_INIT_CFG(QSERDES_V4_TX_RCV_DETECT_LVL_2, 0x12), 908 QMP_PHY_INIT_CFG(QSERDES_V4_TX_LANE_MODE_1, 0x35), 909 QMP_PHY_INIT_CFG(QSERDES_V4_TX_RES_CODE_LANE_OFFSET_TX, 0x11), 910 }; 911 912 static const struct qmp_phy_init_tbl sm8250_qmp_pcie_rx_tbl[] = { 913 QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_FO_GAIN, 0x0c), 914 QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SO_GAIN, 0x03), 915 QMP_PHY_INIT_CFG(QSERDES_V4_RX_GM_CAL, 0x1b), 916 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_IDAC_TSETTLE_HIGH, 0x00), 917 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_IDAC_TSETTLE_LOW, 0xc0), 918 QMP_PHY_INIT_CFG(QSERDES_V4_RX_AUX_DATA_TCOARSE_TFINE, 0x30), 919 QMP_PHY_INIT_CFG(QSERDES_V4_RX_VGA_CAL_CNTRL1, 0x04), 920 QMP_PHY_INIT_CFG(QSERDES_V4_RX_VGA_CAL_CNTRL2, 0x07), 921 QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x7f), 922 QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_PI_CONTROLS, 0x70), 923 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL2, 0x0e), 924 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL3, 0x4a), 925 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL4, 0x0f), 926 QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_CNTRL, 0x03), 927 QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_ENABLES, 0x1c), 928 QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_DEGLITCH_CNTRL, 0x1e), 929 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1, 0x17), 930 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_LOW, 0xd4), 931 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH, 0x54), 932 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH2, 0xdb), 933 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH3, 0x3b), 934 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH4, 0x31), 935 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_LOW, 0x24), 936 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH2, 0xff), 937 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH3, 0x7f), 938 QMP_PHY_INIT_CFG(QSERDES_V4_RX_DCC_CTRL1, 0x0c), 939 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH, 0xe4), 940 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH2, 0xec), 941 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH3, 0x3b), 942 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH4, 0x36), 943 }; 944 945 static const struct qmp_phy_init_tbl sm8250_qmp_gen3x1_pcie_rx_tbl[] = { 946 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RCLK_AUXDATA_SEL, 0x00), 947 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL1, 0x00), 948 QMP_PHY_INIT_CFG(QSERDES_V4_RX_DFE_EN_TIMER, 0x04), 949 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_LOW, 0x3f), 950 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH4, 0x14), 951 QMP_PHY_INIT_CFG(QSERDES_V4_RX_DFE_CTLE_POST_CAL_OFFSET, 0x30), 952 }; 953 954 static const struct qmp_phy_init_tbl sm8250_qmp_pcie_pcs_tbl[] = { 955 QMP_PHY_INIT_CFG(QPHY_V4_PCS_P2U3_WAKEUP_DLY_TIME_AUXCLK_L, 0x01), 956 QMP_PHY_INIT_CFG(QPHY_V4_PCS_RX_SIGDET_LVL, 0x77), 957 QMP_PHY_INIT_CFG(QPHY_V4_PCS_RATE_SLEW_CNTRL1, 0x0b), 958 }; 959 960 static const struct qmp_phy_init_tbl sm8250_qmp_gen3x1_pcie_pcs_tbl[] = { 961 QMP_PHY_INIT_CFG(QPHY_V4_PCS_REFGEN_REQ_CONFIG1, 0x0d), 962 QMP_PHY_INIT_CFG(QPHY_V4_PCS_EQ_CONFIG5, 0x12), 963 }; 964 965 static const struct qmp_phy_init_tbl sm8250_qmp_pcie_pcs_misc_tbl[] = { 966 QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_OSC_DTCT_ACTIONS, 0x00), 967 QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_L1P1_WAKEUP_DLY_TIME_AUXCLK_L, 0x01), 968 QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_L1P2_WAKEUP_DLY_TIME_AUXCLK_L, 0x01), 969 QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_PRESET_P6_P7_PRE, 0x33), 970 QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_PRESET_P10_PRE, 0x00), 971 QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_PRESET_P10_POST, 0x58), 972 QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_ENDPOINT_REFCLK_DRIVE, 0xc1), 973 }; 974 975 static const struct qmp_phy_init_tbl sm8250_qmp_gen3x1_pcie_pcs_misc_tbl[] = { 976 QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_INT_AUX_CLK_CONFIG1, 0x00), 977 QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_EQ_CONFIG2, 0x0f), 978 }; 979 980 static const struct qmp_phy_init_tbl sm8250_qmp_gen3x2_pcie_tx_tbl[] = { 981 QMP_PHY_INIT_CFG(QSERDES_V4_TX_PI_QEC_CTRL, 0x20), 982 }; 983 984 static const struct qmp_phy_init_tbl sm8250_qmp_gen3x2_pcie_rx_tbl[] = { 985 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL1, 0x04), 986 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_LOW, 0xbf), 987 QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH4, 0x15), 988 QMP_PHY_INIT_CFG(QSERDES_V4_RX_DFE_CTLE_POST_CAL_OFFSET, 0x38), 989 }; 990 991 static const struct qmp_phy_init_tbl sm8250_qmp_gen3x2_pcie_pcs_tbl[] = { 992 QMP_PHY_INIT_CFG(QPHY_V4_PCS_REFGEN_REQ_CONFIG1, 0x05), 993 QMP_PHY_INIT_CFG(QPHY_V4_PCS_EQ_CONFIG2, 0x0f), 994 }; 995 996 static const struct qmp_phy_init_tbl sm8250_qmp_gen3x2_pcie_pcs_misc_tbl[] = { 997 QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_POWER_STATE_CONFIG2, 0x0d), 998 QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_POWER_STATE_CONFIG4, 0x07), 999 }; 1000 1001 static const struct qmp_phy_init_tbl sdx55_qmp_pcie_serdes_tbl[] = { 1002 QMP_PHY_INIT_CFG(QSERDES_V4_COM_BG_TIMER, 0x02), 1003 QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIAS_EN_CLKBUFLR_EN, 0x18), 1004 QMP_PHY_INIT_CFG(QSERDES_V4_COM_SYS_CLK_CTRL, 0x07), 1005 QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_IVCO, 0x0f), 1006 QMP_PHY_INIT_CFG(QSERDES_V4_COM_CP_CTRL_MODE0, 0x0a), 1007 QMP_PHY_INIT_CFG(QSERDES_V4_COM_CP_CTRL_MODE1, 0x0a), 1008 QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_RCTRL_MODE0, 0x19), 1009 QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_RCTRL_MODE1, 0x19), 1010 QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_CCTRL_MODE0, 0x03), 1011 QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_CCTRL_MODE1, 0x03), 1012 QMP_PHY_INIT_CFG(QSERDES_V4_COM_SYSCLK_EN_SEL, 0x00), 1013 QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP_EN, 0x46), 1014 QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP_CFG, 0x04), 1015 QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP1_MODE0, 0x7f), 1016 QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP2_MODE0, 0x02), 1017 QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP1_MODE1, 0xff), 1018 QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP2_MODE1, 0x04), 1019 QMP_PHY_INIT_CFG(QSERDES_V4_COM_DEC_START_MODE0, 0x4b), 1020 QMP_PHY_INIT_CFG(QSERDES_V4_COM_DEC_START_MODE1, 0x50), 1021 QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START3_MODE0, 0x00), 1022 QMP_PHY_INIT_CFG(QSERDES_V4_COM_INTEGLOOP_GAIN0_MODE0, 0xfb), 1023 QMP_PHY_INIT_CFG(QSERDES_V4_COM_INTEGLOOP_GAIN1_MODE0, 0x01), 1024 QMP_PHY_INIT_CFG(QSERDES_V4_COM_INTEGLOOP_GAIN0_MODE1, 0xfb), 1025 QMP_PHY_INIT_CFG(QSERDES_V4_COM_INTEGLOOP_GAIN1_MODE1, 0x01), 1026 QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE_MAP, 0x02), 1027 QMP_PHY_INIT_CFG(QSERDES_V4_COM_HSCLK_SEL, 0x12), 1028 QMP_PHY_INIT_CFG(QSERDES_V4_COM_HSCLK_HS_SWITCH_SEL, 0x00), 1029 QMP_PHY_INIT_CFG(QSERDES_V4_COM_CORECLK_DIV_MODE0, 0x05), 1030 QMP_PHY_INIT_CFG(QSERDES_V4_COM_CORECLK_DIV_MODE1, 0x04), 1031 QMP_PHY_INIT_CFG(QSERDES_V4_COM_CMN_CONFIG, 0x04), 1032 QMP_PHY_INIT_CFG(QSERDES_V4_COM_CMN_MISC1, 0x88), 1033 QMP_PHY_INIT_CFG(QSERDES_V4_COM_CMN_MISC2, 0x03), 1034 QMP_PHY_INIT_CFG(QSERDES_V4_COM_CMN_MODE, 0x17), 1035 QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_DC_LEVEL_CTRL, 0x0b), 1036 QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE1_MODE0, 0x56), 1037 QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE2_MODE0, 0x1d), 1038 QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE1_MODE1, 0x4b), 1039 QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE2_MODE1, 0x1f), 1040 QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_HSCLK_SEL, 0x22), 1041 }; 1042 1043 static const struct qmp_phy_init_tbl sdx55_qmp_pcie_tx_tbl[] = { 1044 QMP_PHY_INIT_CFG(QSERDES_V4_20_TX_LANE_MODE_1, 0x05), 1045 QMP_PHY_INIT_CFG(QSERDES_V4_20_TX_LANE_MODE_2, 0xf6), 1046 QMP_PHY_INIT_CFG(QSERDES_V4_20_TX_LANE_MODE_3, 0x13), 1047 QMP_PHY_INIT_CFG(QSERDES_V4_20_TX_VMODE_CTRL1, 0x00), 1048 QMP_PHY_INIT_CFG(QSERDES_V4_20_TX_PI_QEC_CTRL, 0x00), 1049 }; 1050 1051 static const struct qmp_phy_init_tbl sdx55_qmp_pcie_rx_tbl[] = { 1052 QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_FO_GAIN_RATE2, 0x0c), 1053 QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_UCDR_PI_CONTROLS, 0x16), 1054 QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_AUX_DATA_TCOARSE_TFINE, 0x7f), 1055 QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_DFE_3, 0x55), 1056 QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_DFE_DAC_ENABLE1, 0x0c), 1057 QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_DFE_DAC_ENABLE2, 0x00), 1058 QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_VGA_CAL_CNTRL2, 0x08), 1059 QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1, 0x27), 1060 QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE_0_1_B1, 0x1a), 1061 QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE_0_1_B2, 0x5a), 1062 QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE_0_1_B3, 0x09), 1063 QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE_0_1_B4, 0x37), 1064 QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE2_B0, 0xbd), 1065 QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE2_B1, 0xf9), 1066 QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE2_B2, 0xbf), 1067 QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE2_B3, 0xce), 1068 QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE2_B4, 0x62), 1069 QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE3_B0, 0xbf), 1070 QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE3_B1, 0x7d), 1071 QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE3_B2, 0xbf), 1072 QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE3_B3, 0xcf), 1073 QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE3_B4, 0xd6), 1074 QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_PHPRE_CTRL, 0xa0), 1075 QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_DFE_CTLE_POST_CAL_OFFSET, 0x38), 1076 QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_MARG_COARSE_CTRL2, 0x12), 1077 }; 1078 1079 static const struct qmp_phy_init_tbl sdx55_qmp_pcie_pcs_tbl[] = { 1080 QMP_PHY_INIT_CFG(QPHY_V4_20_PCS_RX_SIGDET_LVL, 0x77), 1081 QMP_PHY_INIT_CFG(QPHY_V4_20_PCS_EQ_CONFIG2, 0x01), 1082 QMP_PHY_INIT_CFG(QPHY_V4_20_PCS_EQ_CONFIG4, 0x16), 1083 QMP_PHY_INIT_CFG(QPHY_V4_20_PCS_EQ_CONFIG5, 0x02), 1084 }; 1085 1086 static const struct qmp_phy_init_tbl sdx55_qmp_pcie_pcs_misc_tbl[] = { 1087 QMP_PHY_INIT_CFG(QPHY_V4_20_PCS_PCIE_EQ_CONFIG1, 0x17), 1088 QMP_PHY_INIT_CFG(QPHY_V4_20_PCS_PCIE_G3_RXEQEVAL_TIME, 0x13), 1089 QMP_PHY_INIT_CFG(QPHY_V4_20_PCS_PCIE_G4_RXEQEVAL_TIME, 0x13), 1090 QMP_PHY_INIT_CFG(QPHY_V4_20_PCS_PCIE_G4_EQ_CONFIG2, 0x01), 1091 QMP_PHY_INIT_CFG(QPHY_V4_20_PCS_PCIE_G4_EQ_CONFIG5, 0x02), 1092 QMP_PHY_INIT_CFG(QPHY_V4_20_PCS_LANE1_INSIG_SW_CTRL2, 0x00), 1093 QMP_PHY_INIT_CFG(QPHY_V4_20_PCS_LANE1_INSIG_MX_CTRL2, 0x00), 1094 }; 1095 1096 static const struct qmp_phy_init_tbl sm8450_qmp_gen3x1_pcie_serdes_tbl[] = { 1097 QMP_PHY_INIT_CFG(QSERDES_V5_COM_SYSCLK_EN_SEL, 0x08), 1098 QMP_PHY_INIT_CFG(QSERDES_V5_COM_CLK_SELECT, 0x34), 1099 QMP_PHY_INIT_CFG(QSERDES_V5_COM_CORECLK_DIV_MODE1, 0x08), 1100 QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_IVCO, 0x0f), 1101 QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP_EN, 0x42), 1102 QMP_PHY_INIT_CFG(QSERDES_V5_COM_VCO_TUNE1_MODE0, 0x24), 1103 QMP_PHY_INIT_CFG(QSERDES_V5_COM_VCO_TUNE2_MODE1, 0x03), 1104 QMP_PHY_INIT_CFG(QSERDES_V5_COM_VCO_TUNE1_MODE1, 0xb4), 1105 QMP_PHY_INIT_CFG(QSERDES_V5_COM_VCO_TUNE_MAP, 0x02), 1106 QMP_PHY_INIT_CFG(QSERDES_V5_COM_BIN_VCOCAL_HSCLK_SEL, 0x11), 1107 QMP_PHY_INIT_CFG(QSERDES_V5_COM_DEC_START_MODE0, 0x82), 1108 QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START3_MODE0, 0x03), 1109 QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START2_MODE0, 0x55), 1110 QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START1_MODE0, 0x55), 1111 QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP2_MODE0, 0x1a), 1112 QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP1_MODE0, 0x0a), 1113 QMP_PHY_INIT_CFG(QSERDES_V5_COM_DEC_START_MODE1, 0x68), 1114 QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START3_MODE1, 0x02), 1115 QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START2_MODE1, 0xaa), 1116 QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START1_MODE1, 0xab), 1117 QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP2_MODE1, 0x34), 1118 QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP1_MODE1, 0x14), 1119 QMP_PHY_INIT_CFG(QSERDES_V5_COM_HSCLK_SEL, 0x01), 1120 QMP_PHY_INIT_CFG(QSERDES_V5_COM_CP_CTRL_MODE0, 0x06), 1121 QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_RCTRL_MODE0, 0x16), 1122 QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_CCTRL_MODE0, 0x36), 1123 QMP_PHY_INIT_CFG(QSERDES_V5_COM_CP_CTRL_MODE1, 0x06), 1124 QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_RCTRL_MODE1, 0x16), 1125 QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_CCTRL_MODE1, 0x36), 1126 QMP_PHY_INIT_CFG(QSERDES_V5_COM_BIN_VCOCAL_CMP_CODE2_MODE0, 0x1e), 1127 QMP_PHY_INIT_CFG(QSERDES_V5_COM_BIN_VCOCAL_CMP_CODE1_MODE0, 0xca), 1128 QMP_PHY_INIT_CFG(QSERDES_V5_COM_BIN_VCOCAL_CMP_CODE2_MODE1, 0x18), 1129 QMP_PHY_INIT_CFG(QSERDES_V5_COM_BIN_VCOCAL_CMP_CODE1_MODE1, 0xa2), 1130 QMP_PHY_INIT_CFG(QSERDES_V5_COM_SYSCLK_BUF_ENABLE, 0x07), 1131 QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_EN_CENTER, 0x01), 1132 QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_PER1, 0x31), 1133 QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_PER2, 0x01), 1134 QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_STEP_SIZE1_MODE0, 0xde), 1135 QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_STEP_SIZE2_MODE0, 0x07), 1136 QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_STEP_SIZE1_MODE1, 0x4c), 1137 QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_STEP_SIZE2_MODE1, 0x06), 1138 QMP_PHY_INIT_CFG(QSERDES_V5_COM_CLK_ENABLE1, 0x90), 1139 }; 1140 1141 static const struct qmp_phy_init_tbl sm8450_qmp_gen3x1_pcie_tx_tbl[] = { 1142 QMP_PHY_INIT_CFG(QSERDES_V5_TX_PI_QEC_CTRL, 0x20), 1143 QMP_PHY_INIT_CFG(QSERDES_V5_TX_LANE_MODE_1, 0x75), 1144 QMP_PHY_INIT_CFG(QSERDES_V5_TX_LANE_MODE_4, 0x3f), 1145 QMP_PHY_INIT_CFG(QSERDES_V5_TX_RES_CODE_LANE_OFFSET_TX, 0x16), 1146 QMP_PHY_INIT_CFG(QSERDES_V5_TX_RES_CODE_LANE_OFFSET_RX, 0x04), 1147 }; 1148 1149 static const struct qmp_phy_init_tbl sm8450_qmp_gen3x1_pcie_rx_tbl[] = { 1150 QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_00_LOW, 0x7f), 1151 QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_00_HIGH, 0xff), 1152 QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_00_HIGH2, 0xbf), 1153 QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_00_HIGH3, 0x3f), 1154 QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_00_HIGH4, 0xd8), 1155 QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_01_LOW, 0xdc), 1156 QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_01_HIGH, 0xdc), 1157 QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_01_HIGH2, 0x5c), 1158 QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_01_HIGH3, 0x34), 1159 QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_01_HIGH4, 0xa6), 1160 QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_10_HIGH3, 0x34), 1161 QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_10_HIGH4, 0x38), 1162 QMP_PHY_INIT_CFG(QSERDES_V5_RX_VGA_CAL_CNTRL2, 0x07), 1163 QMP_PHY_INIT_CFG(QSERDES_V5_RX_GM_CAL, 0x00), 1164 QMP_PHY_INIT_CFG(QSERDES_V5_RX_UCDR_SB2_THRESH1, 0x08), 1165 QMP_PHY_INIT_CFG(QSERDES_V5_RX_UCDR_SB2_THRESH2, 0x08), 1166 QMP_PHY_INIT_CFG(QSERDES_V5_RX_UCDR_PI_CONTROLS, 0xf0), 1167 QMP_PHY_INIT_CFG(QSERDES_V5_RX_DFE_CTLE_POST_CAL_OFFSET, 0x38), 1168 QMP_PHY_INIT_CFG(QSERDES_V5_RX_TX_ADAPT_POST_THRESH, 0xf0), 1169 QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_EQU_ADAPTOR_CNTRL4, 0x07), 1170 QMP_PHY_INIT_CFG(QSERDES_V5_RX_UCDR_FO_GAIN, 0x09), 1171 QMP_PHY_INIT_CFG(QSERDES_V5_RX_UCDR_SO_GAIN, 0x05), 1172 }; 1173 1174 static const struct qmp_phy_init_tbl sm8450_qmp_gen3x1_pcie_pcs_tbl[] = { 1175 QMP_PHY_INIT_CFG(QPHY_V5_PCS_RX_SIGDET_LVL, 0x77), 1176 QMP_PHY_INIT_CFG(QPHY_V5_PCS_RATE_SLEW_CNTRL1, 0x0b), 1177 QMP_PHY_INIT_CFG(QPHY_V5_PCS_REFGEN_REQ_CONFIG1, 0x05), 1178 }; 1179 1180 static const struct qmp_phy_init_tbl sm8450_qmp_gen3x1_pcie_pcs_misc_tbl[] = { 1181 QMP_PHY_INIT_CFG(QPHY_V5_PCS_PCIE_OSC_DTCT_ACTIONS, 0x00), 1182 QMP_PHY_INIT_CFG(QPHY_V5_PCS_PCIE_INT_AUX_CLK_CONFIG1, 0x00), 1183 QMP_PHY_INIT_CFG(QPHY_V5_PCS_PCIE_EQ_CONFIG2, 0x0f), 1184 QMP_PHY_INIT_CFG(QPHY_V5_PCS_PCIE_ENDPOINT_REFCLK_DRIVE, 0xc1), 1185 }; 1186 1187 static const struct qmp_phy_init_tbl sm8450_qmp_gen4x2_pcie_serdes_tbl[] = { 1188 QMP_PHY_INIT_CFG(QSERDES_V5_COM_BIAS_EN_CLKBUFLR_EN, 0x14), 1189 QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_IVCO, 0x0f), 1190 QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP_EN, 0x46), 1191 QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP_CFG, 0x04), 1192 QMP_PHY_INIT_CFG(QSERDES_V5_COM_VCO_TUNE_MAP, 0x02), 1193 QMP_PHY_INIT_CFG(QSERDES_V5_COM_HSCLK_SEL, 0x12), 1194 QMP_PHY_INIT_CFG(QSERDES_V5_COM_HSCLK_HS_SWITCH_SEL, 0x00), 1195 QMP_PHY_INIT_CFG(QSERDES_V5_COM_CORECLK_DIV_MODE0, 0x0a), 1196 QMP_PHY_INIT_CFG(QSERDES_V5_COM_CORECLK_DIV_MODE1, 0x04), 1197 QMP_PHY_INIT_CFG(QSERDES_V5_COM_CMN_MISC1, 0x88), 1198 QMP_PHY_INIT_CFG(QSERDES_V5_COM_CMN_CONFIG, 0x06), 1199 QMP_PHY_INIT_CFG(QSERDES_V5_COM_CMN_MODE, 0x14), 1200 QMP_PHY_INIT_CFG(QSERDES_V5_COM_VCO_DC_LEVEL_CTRL, 0x0f), 1201 }; 1202 1203 static const struct qmp_phy_init_tbl sm8450_qmp_gen4x2_pcie_rc_serdes_tbl[] = { 1204 QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_PER1, 0x31), 1205 QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_PER2, 0x01), 1206 QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_STEP_SIZE1_MODE0, 0xde), 1207 QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_STEP_SIZE2_MODE0, 0x07), 1208 QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_STEP_SIZE1_MODE1, 0x97), 1209 QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_STEP_SIZE2_MODE1, 0x0c), 1210 QMP_PHY_INIT_CFG(QSERDES_V5_COM_CLK_ENABLE1, 0x90), 1211 QMP_PHY_INIT_CFG(QSERDES_V5_COM_CP_CTRL_MODE0, 0x06), 1212 QMP_PHY_INIT_CFG(QSERDES_V5_COM_CP_CTRL_MODE1, 0x06), 1213 QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_RCTRL_MODE0, 0x16), 1214 QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_RCTRL_MODE1, 0x16), 1215 QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_CCTRL_MODE0, 0x36), 1216 QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_CCTRL_MODE1, 0x36), 1217 QMP_PHY_INIT_CFG(QSERDES_V5_COM_SYSCLK_EN_SEL, 0x08), 1218 QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP1_MODE0, 0x0a), 1219 QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP2_MODE0, 0x1a), 1220 QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP1_MODE1, 0x14), 1221 QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP2_MODE1, 0x34), 1222 QMP_PHY_INIT_CFG(QSERDES_V5_COM_DEC_START_MODE0, 0x82), 1223 QMP_PHY_INIT_CFG(QSERDES_V5_COM_DEC_START_MODE1, 0xd0), 1224 QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START1_MODE0, 0x55), 1225 QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START2_MODE0, 0x55), 1226 QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START3_MODE0, 0x03), 1227 QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START1_MODE1, 0x55), 1228 QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START2_MODE1, 0x55), 1229 QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START3_MODE1, 0x05), 1230 QMP_PHY_INIT_CFG(QSERDES_V5_COM_CLK_SELECT, 0x34), 1231 QMP_PHY_INIT_CFG(QSERDES_V5_COM_CORE_CLK_EN, 0x20), 1232 }; 1233 1234 static const struct qmp_phy_init_tbl sm8450_qmp_gen4x2_pcie_tx_tbl[] = { 1235 QMP_PHY_INIT_CFG(QSERDES_V5_20_TX_LANE_MODE_1, 0x05), 1236 QMP_PHY_INIT_CFG(QSERDES_V5_20_TX_LANE_MODE_2, 0xf6), 1237 QMP_PHY_INIT_CFG(QSERDES_V5_20_TX_RES_CODE_LANE_OFFSET_TX, 0x1a), 1238 QMP_PHY_INIT_CFG(QSERDES_V5_20_TX_RES_CODE_LANE_OFFSET_RX, 0x0c), 1239 }; 1240 1241 static const struct qmp_phy_init_tbl sm8450_qmp_gen4x2_pcie_rx_tbl[] = { 1242 QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_UCDR_PI_CONTROLS, 0x16), 1243 QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_DFE_CTLE_POST_CAL_OFFSET, 0x38), 1244 QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE_0_1_B1, 0xcc), 1245 QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE_0_1_B2, 0x12), 1246 QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE_0_1_B3, 0xcc), 1247 QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE_0_1_B5, 0x4a), 1248 QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE_0_1_B6, 0x29), 1249 QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE2_B0, 0xc5), 1250 QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE2_B1, 0xad), 1251 QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE2_B2, 0xb6), 1252 QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE2_B3, 0xc0), 1253 QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE2_B4, 0x1f), 1254 QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE2_B5, 0xfb), 1255 QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE2_B6, 0x0f), 1256 QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE3_B0, 0xc7), 1257 QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE3_B1, 0xef), 1258 QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE3_B2, 0xbf), 1259 QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE3_B3, 0xa0), 1260 QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE3_B4, 0x81), 1261 QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE3_B5, 0xde), 1262 QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE3_B6, 0x7f), 1263 QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_PHPRE_CTRL, 0x20), 1264 QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_AUX_DATA_THRESH_BIN_RATE_0_1, 0x3f), 1265 QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_AUX_DATA_THRESH_BIN_RATE_2_3, 0x37), 1266 1267 QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_DFE_3, 0x05), 1268 1269 QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MARG_COARSE_THRESH1_RATE3, 0x1f), 1270 1271 QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MARG_COARSE_THRESH2_RATE3, 0x1f), 1272 QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MARG_COARSE_THRESH3_RATE3, 0x1f), 1273 QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MARG_COARSE_THRESH4_RATE3, 0x1f), 1274 QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MARG_COARSE_THRESH5_RATE3, 0x1f), 1275 QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MARG_COARSE_THRESH6_RATE3, 0x1f), 1276 QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MARG_COARSE_THRESH1_RATE210, 0x1f), 1277 QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MARG_COARSE_THRESH2_RATE210, 0x1f), 1278 QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MARG_COARSE_THRESH3_RATE210, 0x1f), 1279 1280 QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_UCDR_FO_GAIN_RATE2, 0x0c), 1281 QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_UCDR_FO_GAIN_RATE3, 0x0a), 1282 QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_VGA_CAL_MAN_VAL, 0x0a), 1283 QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_EQU_ADAPTOR_CNTRL4, 0x0b), 1284 QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_IDAC_SAOFFSET, 0x10), 1285 QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_DFE_DAC_ENABLE1, 0x00), 1286 QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_GM_CAL, 0x0f), 1287 QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_TX_ADAPT_POST_THRESH1, 0x00), 1288 QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_TX_ADAPT_POST_THRESH2, 0x1f), 1289 }; 1290 1291 static const struct qmp_phy_init_tbl sm8450_qmp_gen4x2_pcie_pcs_tbl[] = { 1292 QMP_PHY_INIT_CFG(QPHY_V5_PCS_EQ_CONFIG2, 0x16), 1293 QMP_PHY_INIT_CFG(QPHY_V5_PCS_EQ_CONFIG3, 0x22), 1294 QMP_PHY_INIT_CFG(QPHY_V5_PCS_G3S2_PRE_GAIN, 0x2e), 1295 QMP_PHY_INIT_CFG(QPHY_V5_PCS_RX_SIGDET_LVL, 0x99), 1296 }; 1297 1298 static const struct qmp_phy_init_tbl sm8450_qmp_gen4x2_pcie_pcs_misc_tbl[] = { 1299 QMP_PHY_INIT_CFG(QPHY_V5_20_PCS_PCIE_G4_EQ_CONFIG5, 0x02), 1300 QMP_PHY_INIT_CFG(QPHY_V5_20_PCS_PCIE_EQ_CONFIG1, 0x16), 1301 QMP_PHY_INIT_CFG(QPHY_V5_20_PCS_PCIE_RX_MARGINING_CONFIG3, 0x28), 1302 QMP_PHY_INIT_CFG(QPHY_V5_20_PCS_PCIE_G4_PRE_GAIN, 0x2e), 1303 }; 1304 1305 static const struct qmp_phy_init_tbl sm8450_qmp_gen4x2_pcie_rc_pcs_misc_tbl[] = { 1306 QMP_PHY_INIT_CFG(QPHY_V5_20_PCS_PCIE_ENDPOINT_REFCLK_DRIVE, 0xc1), 1307 QMP_PHY_INIT_CFG(QPHY_V5_20_PCS_PCIE_OSC_DTCT_ACTIONS, 0x00), 1308 }; 1309 1310 static const struct qmp_phy_init_tbl sm8450_qmp_gen4x2_pcie_ep_serdes_tbl[] = { 1311 QMP_PHY_INIT_CFG(QSERDES_V5_COM_BG_TIMER, 0x02), 1312 QMP_PHY_INIT_CFG(QSERDES_V5_COM_SYS_CLK_CTRL, 0x07), 1313 QMP_PHY_INIT_CFG(QSERDES_V5_COM_CP_CTRL_MODE0, 0x27), 1314 QMP_PHY_INIT_CFG(QSERDES_V5_COM_CP_CTRL_MODE1, 0x0a), 1315 QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_RCTRL_MODE0, 0x17), 1316 QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_RCTRL_MODE1, 0x19), 1317 QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_CCTRL_MODE0, 0x00), 1318 QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_CCTRL_MODE1, 0x03), 1319 QMP_PHY_INIT_CFG(QSERDES_V5_COM_SYSCLK_EN_SEL, 0x00), 1320 QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP1_MODE0, 0xff), 1321 QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP2_MODE0, 0x04), 1322 QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP1_MODE1, 0xff), 1323 QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP2_MODE1, 0x09), 1324 QMP_PHY_INIT_CFG(QSERDES_V5_COM_DEC_START_MODE0, 0x19), 1325 QMP_PHY_INIT_CFG(QSERDES_V5_COM_DEC_START_MODE1, 0x28), 1326 QMP_PHY_INIT_CFG(QSERDES_V5_COM_INTEGLOOP_GAIN0_MODE0, 0xfb), 1327 QMP_PHY_INIT_CFG(QSERDES_V5_COM_INTEGLOOP_GAIN1_MODE0, 0x01), 1328 QMP_PHY_INIT_CFG(QSERDES_V5_COM_INTEGLOOP_GAIN0_MODE1, 0xfb), 1329 QMP_PHY_INIT_CFG(QSERDES_V5_COM_INTEGLOOP_GAIN1_MODE1, 0x01), 1330 QMP_PHY_INIT_CFG(QSERDES_V5_COM_CORE_CLK_EN, 0x60), 1331 }; 1332 1333 static const struct qmp_phy_init_tbl sm8450_qmp_gen4x2_pcie_ep_pcs_misc_tbl[] = { 1334 QMP_PHY_INIT_CFG(QPHY_V5_20_PCS_PCIE_OSC_DTCT_MODE2_CONFIG5, 0x08), 1335 }; 1336 1337 struct qmp_phy_cfg_tables { 1338 const struct qmp_phy_init_tbl *serdes; 1339 int serdes_num; 1340 const struct qmp_phy_init_tbl *tx; 1341 int tx_num; 1342 const struct qmp_phy_init_tbl *rx; 1343 int rx_num; 1344 const struct qmp_phy_init_tbl *pcs; 1345 int pcs_num; 1346 const struct qmp_phy_init_tbl *pcs_misc; 1347 int pcs_misc_num; 1348 }; 1349 1350 /* struct qmp_phy_cfg - per-PHY initialization config */ 1351 struct qmp_phy_cfg { 1352 int lanes; 1353 1354 /* Main init sequence for PHY blocks - serdes, tx, rx, pcs */ 1355 const struct qmp_phy_cfg_tables tables; 1356 /* 1357 * Additional init sequences for PHY blocks, providing additional 1358 * register programming. They are used for providing separate sequences 1359 * for the Root Complex and End Point use cases. 1360 * 1361 * If EP mode is not supported, both tables can be left unset. 1362 */ 1363 const struct qmp_phy_cfg_tables *tables_rc; 1364 const struct qmp_phy_cfg_tables *tables_ep; 1365 1366 /* clock ids to be requested */ 1367 const char * const *clk_list; 1368 int num_clks; 1369 /* resets to be requested */ 1370 const char * const *reset_list; 1371 int num_resets; 1372 /* regulators to be requested */ 1373 const char * const *vreg_list; 1374 int num_vregs; 1375 1376 /* array of registers with different offsets */ 1377 const unsigned int *regs; 1378 1379 unsigned int start_ctrl; 1380 unsigned int pwrdn_ctrl; 1381 /* bit offset of PHYSTATUS in QPHY_PCS_STATUS register */ 1382 unsigned int phy_status; 1383 1384 /* true, if PHY needs delay after POWER_DOWN */ 1385 bool has_pwrdn_delay; 1386 /* power_down delay in usec */ 1387 int pwrdn_delay_min; 1388 int pwrdn_delay_max; 1389 1390 /* QMP PHY pipe clock interface rate */ 1391 unsigned long pipe_clock_rate; 1392 }; 1393 1394 /** 1395 * struct qmp_phy - per-lane phy descriptor 1396 * 1397 * @phy: generic phy 1398 * @cfg: phy specific configuration 1399 * @serdes: iomapped memory space for phy's serdes (i.e. PLL) 1400 * @tx: iomapped memory space for lane's tx 1401 * @rx: iomapped memory space for lane's rx 1402 * @pcs: iomapped memory space for lane's pcs 1403 * @tx2: iomapped memory space for second lane's tx (in dual lane PHYs) 1404 * @rx2: iomapped memory space for second lane's rx (in dual lane PHYs) 1405 * @pcs_misc: iomapped memory space for lane's pcs_misc 1406 * @pipe_clk: pipe clock 1407 * @qmp: QMP phy to which this lane belongs 1408 * @mode: currently selected PHY mode 1409 */ 1410 struct qmp_phy { 1411 struct phy *phy; 1412 const struct qmp_phy_cfg *cfg; 1413 void __iomem *serdes; 1414 void __iomem *tx; 1415 void __iomem *rx; 1416 void __iomem *pcs; 1417 void __iomem *tx2; 1418 void __iomem *rx2; 1419 void __iomem *pcs_misc; 1420 struct clk *pipe_clk; 1421 struct qcom_qmp *qmp; 1422 int mode; 1423 }; 1424 1425 /** 1426 * struct qcom_qmp - structure holding QMP phy block attributes 1427 * 1428 * @dev: device 1429 * 1430 * @clks: array of clocks required by phy 1431 * @resets: array of resets required by phy 1432 * @vregs: regulator supplies bulk data 1433 * 1434 * @phys: array of per-lane phy descriptors 1435 */ 1436 struct qcom_qmp { 1437 struct device *dev; 1438 1439 struct clk_bulk_data *clks; 1440 struct reset_control_bulk_data *resets; 1441 struct regulator_bulk_data *vregs; 1442 1443 struct qmp_phy **phys; 1444 }; 1445 1446 static inline void qphy_setbits(void __iomem *base, u32 offset, u32 val) 1447 { 1448 u32 reg; 1449 1450 reg = readl(base + offset); 1451 reg |= val; 1452 writel(reg, base + offset); 1453 1454 /* ensure that above write is through */ 1455 readl(base + offset); 1456 } 1457 1458 static inline void qphy_clrbits(void __iomem *base, u32 offset, u32 val) 1459 { 1460 u32 reg; 1461 1462 reg = readl(base + offset); 1463 reg &= ~val; 1464 writel(reg, base + offset); 1465 1466 /* ensure that above write is through */ 1467 readl(base + offset); 1468 } 1469 1470 /* list of clocks required by phy */ 1471 static const char * const msm8996_phy_clk_l[] = { 1472 "aux", "cfg_ahb", "ref", 1473 }; 1474 1475 1476 static const char * const sdm845_pciephy_clk_l[] = { 1477 "aux", "cfg_ahb", "ref", "refgen", 1478 }; 1479 1480 /* list of regulators */ 1481 static const char * const qmp_phy_vreg_l[] = { 1482 "vdda-phy", "vdda-pll", 1483 }; 1484 1485 static const char * const ipq8074_pciephy_clk_l[] = { 1486 "aux", "cfg_ahb", 1487 }; 1488 1489 /* list of resets */ 1490 static const char * const ipq8074_pciephy_reset_l[] = { 1491 "phy", "common", 1492 }; 1493 1494 static const char * const sdm845_pciephy_reset_l[] = { 1495 "phy", 1496 }; 1497 1498 static const struct qmp_phy_cfg ipq8074_pciephy_cfg = { 1499 .lanes = 1, 1500 1501 .tables = { 1502 .serdes = ipq8074_pcie_serdes_tbl, 1503 .serdes_num = ARRAY_SIZE(ipq8074_pcie_serdes_tbl), 1504 .tx = ipq8074_pcie_tx_tbl, 1505 .tx_num = ARRAY_SIZE(ipq8074_pcie_tx_tbl), 1506 .rx = ipq8074_pcie_rx_tbl, 1507 .rx_num = ARRAY_SIZE(ipq8074_pcie_rx_tbl), 1508 .pcs = ipq8074_pcie_pcs_tbl, 1509 .pcs_num = ARRAY_SIZE(ipq8074_pcie_pcs_tbl), 1510 }, 1511 .clk_list = ipq8074_pciephy_clk_l, 1512 .num_clks = ARRAY_SIZE(ipq8074_pciephy_clk_l), 1513 .reset_list = ipq8074_pciephy_reset_l, 1514 .num_resets = ARRAY_SIZE(ipq8074_pciephy_reset_l), 1515 .vreg_list = NULL, 1516 .num_vregs = 0, 1517 .regs = pciephy_regs_layout, 1518 1519 .start_ctrl = SERDES_START | PCS_START, 1520 .pwrdn_ctrl = SW_PWRDN | REFCLK_DRV_DSBL, 1521 .phy_status = PHYSTATUS, 1522 1523 .has_pwrdn_delay = true, 1524 .pwrdn_delay_min = 995, /* us */ 1525 .pwrdn_delay_max = 1005, /* us */ 1526 }; 1527 1528 static const struct qmp_phy_cfg ipq8074_pciephy_gen3_cfg = { 1529 .lanes = 1, 1530 1531 .tables = { 1532 .serdes = ipq8074_pcie_gen3_serdes_tbl, 1533 .serdes_num = ARRAY_SIZE(ipq8074_pcie_gen3_serdes_tbl), 1534 .tx = ipq8074_pcie_gen3_tx_tbl, 1535 .tx_num = ARRAY_SIZE(ipq8074_pcie_gen3_tx_tbl), 1536 .rx = ipq8074_pcie_gen3_rx_tbl, 1537 .rx_num = ARRAY_SIZE(ipq8074_pcie_gen3_rx_tbl), 1538 .pcs = ipq8074_pcie_gen3_pcs_tbl, 1539 .pcs_num = ARRAY_SIZE(ipq8074_pcie_gen3_pcs_tbl), 1540 }, 1541 .clk_list = ipq8074_pciephy_clk_l, 1542 .num_clks = ARRAY_SIZE(ipq8074_pciephy_clk_l), 1543 .reset_list = ipq8074_pciephy_reset_l, 1544 .num_resets = ARRAY_SIZE(ipq8074_pciephy_reset_l), 1545 .vreg_list = NULL, 1546 .num_vregs = 0, 1547 .regs = ipq_pciephy_gen3_regs_layout, 1548 1549 .start_ctrl = SERDES_START | PCS_START, 1550 .pwrdn_ctrl = SW_PWRDN | REFCLK_DRV_DSBL, 1551 1552 .has_pwrdn_delay = true, 1553 .pwrdn_delay_min = 995, /* us */ 1554 .pwrdn_delay_max = 1005, /* us */ 1555 1556 .pipe_clock_rate = 250000000, 1557 }; 1558 1559 static const struct qmp_phy_cfg ipq6018_pciephy_cfg = { 1560 .lanes = 1, 1561 1562 .tables = { 1563 .serdes = ipq6018_pcie_serdes_tbl, 1564 .serdes_num = ARRAY_SIZE(ipq6018_pcie_serdes_tbl), 1565 .tx = ipq6018_pcie_tx_tbl, 1566 .tx_num = ARRAY_SIZE(ipq6018_pcie_tx_tbl), 1567 .rx = ipq6018_pcie_rx_tbl, 1568 .rx_num = ARRAY_SIZE(ipq6018_pcie_rx_tbl), 1569 .pcs = ipq6018_pcie_pcs_tbl, 1570 .pcs_num = ARRAY_SIZE(ipq6018_pcie_pcs_tbl), 1571 .pcs_misc = ipq6018_pcie_pcs_misc_tbl, 1572 .pcs_misc_num = ARRAY_SIZE(ipq6018_pcie_pcs_misc_tbl), 1573 }, 1574 .clk_list = ipq8074_pciephy_clk_l, 1575 .num_clks = ARRAY_SIZE(ipq8074_pciephy_clk_l), 1576 .reset_list = ipq8074_pciephy_reset_l, 1577 .num_resets = ARRAY_SIZE(ipq8074_pciephy_reset_l), 1578 .vreg_list = NULL, 1579 .num_vregs = 0, 1580 .regs = ipq_pciephy_gen3_regs_layout, 1581 1582 .start_ctrl = SERDES_START | PCS_START, 1583 .pwrdn_ctrl = SW_PWRDN | REFCLK_DRV_DSBL, 1584 1585 .has_pwrdn_delay = true, 1586 .pwrdn_delay_min = 995, /* us */ 1587 .pwrdn_delay_max = 1005, /* us */ 1588 }; 1589 1590 static const struct qmp_phy_cfg sdm845_qmp_pciephy_cfg = { 1591 .lanes = 1, 1592 1593 .tables = { 1594 .serdes = sdm845_qmp_pcie_serdes_tbl, 1595 .serdes_num = ARRAY_SIZE(sdm845_qmp_pcie_serdes_tbl), 1596 .tx = sdm845_qmp_pcie_tx_tbl, 1597 .tx_num = ARRAY_SIZE(sdm845_qmp_pcie_tx_tbl), 1598 .rx = sdm845_qmp_pcie_rx_tbl, 1599 .rx_num = ARRAY_SIZE(sdm845_qmp_pcie_rx_tbl), 1600 .pcs = sdm845_qmp_pcie_pcs_tbl, 1601 .pcs_num = ARRAY_SIZE(sdm845_qmp_pcie_pcs_tbl), 1602 .pcs_misc = sdm845_qmp_pcie_pcs_misc_tbl, 1603 .pcs_misc_num = ARRAY_SIZE(sdm845_qmp_pcie_pcs_misc_tbl), 1604 }, 1605 .clk_list = sdm845_pciephy_clk_l, 1606 .num_clks = ARRAY_SIZE(sdm845_pciephy_clk_l), 1607 .reset_list = sdm845_pciephy_reset_l, 1608 .num_resets = ARRAY_SIZE(sdm845_pciephy_reset_l), 1609 .vreg_list = qmp_phy_vreg_l, 1610 .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), 1611 .regs = sdm845_qmp_pciephy_regs_layout, 1612 1613 .start_ctrl = PCS_START | SERDES_START, 1614 .pwrdn_ctrl = SW_PWRDN | REFCLK_DRV_DSBL, 1615 .phy_status = PHYSTATUS, 1616 1617 .has_pwrdn_delay = true, 1618 .pwrdn_delay_min = 995, /* us */ 1619 .pwrdn_delay_max = 1005, /* us */ 1620 }; 1621 1622 static const struct qmp_phy_cfg sdm845_qhp_pciephy_cfg = { 1623 .lanes = 1, 1624 1625 .tables = { 1626 .serdes = sdm845_qhp_pcie_serdes_tbl, 1627 .serdes_num = ARRAY_SIZE(sdm845_qhp_pcie_serdes_tbl), 1628 .tx = sdm845_qhp_pcie_tx_tbl, 1629 .tx_num = ARRAY_SIZE(sdm845_qhp_pcie_tx_tbl), 1630 .rx = sdm845_qhp_pcie_rx_tbl, 1631 .rx_num = ARRAY_SIZE(sdm845_qhp_pcie_rx_tbl), 1632 .pcs = sdm845_qhp_pcie_pcs_tbl, 1633 .pcs_num = ARRAY_SIZE(sdm845_qhp_pcie_pcs_tbl), 1634 }, 1635 .clk_list = sdm845_pciephy_clk_l, 1636 .num_clks = ARRAY_SIZE(sdm845_pciephy_clk_l), 1637 .reset_list = sdm845_pciephy_reset_l, 1638 .num_resets = ARRAY_SIZE(sdm845_pciephy_reset_l), 1639 .vreg_list = qmp_phy_vreg_l, 1640 .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), 1641 .regs = sdm845_qhp_pciephy_regs_layout, 1642 1643 .start_ctrl = PCS_START | SERDES_START, 1644 .pwrdn_ctrl = SW_PWRDN | REFCLK_DRV_DSBL, 1645 .phy_status = PHYSTATUS, 1646 1647 .has_pwrdn_delay = true, 1648 .pwrdn_delay_min = 995, /* us */ 1649 .pwrdn_delay_max = 1005, /* us */ 1650 }; 1651 1652 static const struct qmp_phy_cfg sm8250_qmp_gen3x1_pciephy_cfg = { 1653 .lanes = 1, 1654 1655 .tables = { 1656 .serdes = sm8250_qmp_pcie_serdes_tbl, 1657 .serdes_num = ARRAY_SIZE(sm8250_qmp_pcie_serdes_tbl), 1658 .tx = sm8250_qmp_pcie_tx_tbl, 1659 .tx_num = ARRAY_SIZE(sm8250_qmp_pcie_tx_tbl), 1660 .rx = sm8250_qmp_pcie_rx_tbl, 1661 .rx_num = ARRAY_SIZE(sm8250_qmp_pcie_rx_tbl), 1662 .pcs = sm8250_qmp_pcie_pcs_tbl, 1663 .pcs_num = ARRAY_SIZE(sm8250_qmp_pcie_pcs_tbl), 1664 .pcs_misc = sm8250_qmp_pcie_pcs_misc_tbl, 1665 .pcs_misc_num = ARRAY_SIZE(sm8250_qmp_pcie_pcs_misc_tbl), 1666 }, 1667 .tables_rc = &(const struct qmp_phy_cfg_tables) { 1668 .serdes = sm8250_qmp_gen3x1_pcie_serdes_tbl, 1669 .serdes_num = ARRAY_SIZE(sm8250_qmp_gen3x1_pcie_serdes_tbl), 1670 .rx = sm8250_qmp_gen3x1_pcie_rx_tbl, 1671 .rx_num = ARRAY_SIZE(sm8250_qmp_gen3x1_pcie_rx_tbl), 1672 .pcs = sm8250_qmp_gen3x1_pcie_pcs_tbl, 1673 .pcs_num = ARRAY_SIZE(sm8250_qmp_gen3x1_pcie_pcs_tbl), 1674 .pcs_misc = sm8250_qmp_gen3x1_pcie_pcs_misc_tbl, 1675 .pcs_misc_num = ARRAY_SIZE(sm8250_qmp_gen3x1_pcie_pcs_misc_tbl), 1676 }, 1677 .clk_list = sdm845_pciephy_clk_l, 1678 .num_clks = ARRAY_SIZE(sdm845_pciephy_clk_l), 1679 .reset_list = sdm845_pciephy_reset_l, 1680 .num_resets = ARRAY_SIZE(sdm845_pciephy_reset_l), 1681 .vreg_list = qmp_phy_vreg_l, 1682 .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), 1683 .regs = sm8250_pcie_regs_layout, 1684 1685 .start_ctrl = PCS_START | SERDES_START, 1686 .pwrdn_ctrl = SW_PWRDN | REFCLK_DRV_DSBL, 1687 .phy_status = PHYSTATUS, 1688 1689 .has_pwrdn_delay = true, 1690 .pwrdn_delay_min = 995, /* us */ 1691 .pwrdn_delay_max = 1005, /* us */ 1692 }; 1693 1694 static const struct qmp_phy_cfg sm8250_qmp_gen3x2_pciephy_cfg = { 1695 .lanes = 2, 1696 1697 .tables = { 1698 .serdes = sm8250_qmp_pcie_serdes_tbl, 1699 .serdes_num = ARRAY_SIZE(sm8250_qmp_pcie_serdes_tbl), 1700 .tx = sm8250_qmp_pcie_tx_tbl, 1701 .tx_num = ARRAY_SIZE(sm8250_qmp_pcie_tx_tbl), 1702 .rx = sm8250_qmp_pcie_rx_tbl, 1703 .rx_num = ARRAY_SIZE(sm8250_qmp_pcie_rx_tbl), 1704 .pcs = sm8250_qmp_pcie_pcs_tbl, 1705 .pcs_num = ARRAY_SIZE(sm8250_qmp_pcie_pcs_tbl), 1706 .pcs_misc = sm8250_qmp_pcie_pcs_misc_tbl, 1707 .pcs_misc_num = ARRAY_SIZE(sm8250_qmp_pcie_pcs_misc_tbl), 1708 }, 1709 .tables_rc = &(const struct qmp_phy_cfg_tables) { 1710 .tx = sm8250_qmp_gen3x2_pcie_tx_tbl, 1711 .tx_num = ARRAY_SIZE(sm8250_qmp_gen3x2_pcie_tx_tbl), 1712 .rx = sm8250_qmp_gen3x2_pcie_rx_tbl, 1713 .rx_num = ARRAY_SIZE(sm8250_qmp_gen3x2_pcie_rx_tbl), 1714 .pcs = sm8250_qmp_gen3x2_pcie_pcs_tbl, 1715 .pcs_num = ARRAY_SIZE(sm8250_qmp_gen3x2_pcie_pcs_tbl), 1716 .pcs_misc = sm8250_qmp_gen3x2_pcie_pcs_misc_tbl, 1717 .pcs_misc_num = ARRAY_SIZE(sm8250_qmp_gen3x2_pcie_pcs_misc_tbl), 1718 }, 1719 .clk_list = sdm845_pciephy_clk_l, 1720 .num_clks = ARRAY_SIZE(sdm845_pciephy_clk_l), 1721 .reset_list = sdm845_pciephy_reset_l, 1722 .num_resets = ARRAY_SIZE(sdm845_pciephy_reset_l), 1723 .vreg_list = qmp_phy_vreg_l, 1724 .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), 1725 .regs = sm8250_pcie_regs_layout, 1726 1727 .start_ctrl = PCS_START | SERDES_START, 1728 .pwrdn_ctrl = SW_PWRDN | REFCLK_DRV_DSBL, 1729 .phy_status = PHYSTATUS, 1730 1731 .has_pwrdn_delay = true, 1732 .pwrdn_delay_min = 995, /* us */ 1733 .pwrdn_delay_max = 1005, /* us */ 1734 }; 1735 1736 static const struct qmp_phy_cfg msm8998_pciephy_cfg = { 1737 .lanes = 1, 1738 1739 .tables = { 1740 .serdes = msm8998_pcie_serdes_tbl, 1741 .serdes_num = ARRAY_SIZE(msm8998_pcie_serdes_tbl), 1742 .tx = msm8998_pcie_tx_tbl, 1743 .tx_num = ARRAY_SIZE(msm8998_pcie_tx_tbl), 1744 .rx = msm8998_pcie_rx_tbl, 1745 .rx_num = ARRAY_SIZE(msm8998_pcie_rx_tbl), 1746 .pcs = msm8998_pcie_pcs_tbl, 1747 .pcs_num = ARRAY_SIZE(msm8998_pcie_pcs_tbl), 1748 }, 1749 .clk_list = msm8996_phy_clk_l, 1750 .num_clks = ARRAY_SIZE(msm8996_phy_clk_l), 1751 .reset_list = ipq8074_pciephy_reset_l, 1752 .num_resets = ARRAY_SIZE(ipq8074_pciephy_reset_l), 1753 .vreg_list = qmp_phy_vreg_l, 1754 .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), 1755 .regs = pciephy_regs_layout, 1756 1757 .start_ctrl = SERDES_START | PCS_START, 1758 .pwrdn_ctrl = SW_PWRDN | REFCLK_DRV_DSBL, 1759 .phy_status = PHYSTATUS, 1760 }; 1761 1762 static const struct qmp_phy_cfg sc8180x_pciephy_cfg = { 1763 .lanes = 1, 1764 1765 .tables = { 1766 .serdes = sc8180x_qmp_pcie_serdes_tbl, 1767 .serdes_num = ARRAY_SIZE(sc8180x_qmp_pcie_serdes_tbl), 1768 .tx = sc8180x_qmp_pcie_tx_tbl, 1769 .tx_num = ARRAY_SIZE(sc8180x_qmp_pcie_tx_tbl), 1770 .rx = sc8180x_qmp_pcie_rx_tbl, 1771 .rx_num = ARRAY_SIZE(sc8180x_qmp_pcie_rx_tbl), 1772 .pcs = sc8180x_qmp_pcie_pcs_tbl, 1773 .pcs_num = ARRAY_SIZE(sc8180x_qmp_pcie_pcs_tbl), 1774 .pcs_misc = sc8180x_qmp_pcie_pcs_misc_tbl, 1775 .pcs_misc_num = ARRAY_SIZE(sc8180x_qmp_pcie_pcs_misc_tbl), 1776 }, 1777 .clk_list = sdm845_pciephy_clk_l, 1778 .num_clks = ARRAY_SIZE(sdm845_pciephy_clk_l), 1779 .reset_list = sdm845_pciephy_reset_l, 1780 .num_resets = ARRAY_SIZE(sdm845_pciephy_reset_l), 1781 .vreg_list = qmp_phy_vreg_l, 1782 .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), 1783 .regs = sm8250_pcie_regs_layout, 1784 1785 .start_ctrl = PCS_START | SERDES_START, 1786 .pwrdn_ctrl = SW_PWRDN | REFCLK_DRV_DSBL, 1787 1788 .has_pwrdn_delay = true, 1789 .pwrdn_delay_min = 995, /* us */ 1790 .pwrdn_delay_max = 1005, /* us */ 1791 }; 1792 1793 static const struct qmp_phy_cfg sdx55_qmp_pciephy_cfg = { 1794 .lanes = 2, 1795 1796 .tables = { 1797 .serdes = sdx55_qmp_pcie_serdes_tbl, 1798 .serdes_num = ARRAY_SIZE(sdx55_qmp_pcie_serdes_tbl), 1799 .tx = sdx55_qmp_pcie_tx_tbl, 1800 .tx_num = ARRAY_SIZE(sdx55_qmp_pcie_tx_tbl), 1801 .rx = sdx55_qmp_pcie_rx_tbl, 1802 .rx_num = ARRAY_SIZE(sdx55_qmp_pcie_rx_tbl), 1803 .pcs = sdx55_qmp_pcie_pcs_tbl, 1804 .pcs_num = ARRAY_SIZE(sdx55_qmp_pcie_pcs_tbl), 1805 .pcs_misc = sdx55_qmp_pcie_pcs_misc_tbl, 1806 .pcs_misc_num = ARRAY_SIZE(sdx55_qmp_pcie_pcs_misc_tbl), 1807 }, 1808 .clk_list = sdm845_pciephy_clk_l, 1809 .num_clks = ARRAY_SIZE(sdm845_pciephy_clk_l), 1810 .reset_list = sdm845_pciephy_reset_l, 1811 .num_resets = ARRAY_SIZE(sdm845_pciephy_reset_l), 1812 .vreg_list = qmp_phy_vreg_l, 1813 .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), 1814 .regs = sm8250_pcie_regs_layout, 1815 1816 .start_ctrl = PCS_START | SERDES_START, 1817 .pwrdn_ctrl = SW_PWRDN, 1818 .phy_status = PHYSTATUS_4_20, 1819 1820 .has_pwrdn_delay = true, 1821 .pwrdn_delay_min = 995, /* us */ 1822 .pwrdn_delay_max = 1005, /* us */ 1823 }; 1824 1825 static const struct qmp_phy_cfg sm8450_qmp_gen3x1_pciephy_cfg = { 1826 .lanes = 1, 1827 1828 .tables = { 1829 .serdes = sm8450_qmp_gen3x1_pcie_serdes_tbl, 1830 .serdes_num = ARRAY_SIZE(sm8450_qmp_gen3x1_pcie_serdes_tbl), 1831 .tx = sm8450_qmp_gen3x1_pcie_tx_tbl, 1832 .tx_num = ARRAY_SIZE(sm8450_qmp_gen3x1_pcie_tx_tbl), 1833 .rx = sm8450_qmp_gen3x1_pcie_rx_tbl, 1834 .rx_num = ARRAY_SIZE(sm8450_qmp_gen3x1_pcie_rx_tbl), 1835 .pcs = sm8450_qmp_gen3x1_pcie_pcs_tbl, 1836 .pcs_num = ARRAY_SIZE(sm8450_qmp_gen3x1_pcie_pcs_tbl), 1837 .pcs_misc = sm8450_qmp_gen3x1_pcie_pcs_misc_tbl, 1838 .pcs_misc_num = ARRAY_SIZE(sm8450_qmp_gen3x1_pcie_pcs_misc_tbl), 1839 }, 1840 .clk_list = sdm845_pciephy_clk_l, 1841 .num_clks = ARRAY_SIZE(sdm845_pciephy_clk_l), 1842 .reset_list = sdm845_pciephy_reset_l, 1843 .num_resets = ARRAY_SIZE(sdm845_pciephy_reset_l), 1844 .vreg_list = qmp_phy_vreg_l, 1845 .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), 1846 .regs = sm8250_pcie_regs_layout, 1847 1848 .start_ctrl = SERDES_START | PCS_START, 1849 .pwrdn_ctrl = SW_PWRDN | REFCLK_DRV_DSBL, 1850 .phy_status = PHYSTATUS, 1851 1852 .has_pwrdn_delay = true, 1853 .pwrdn_delay_min = 995, /* us */ 1854 .pwrdn_delay_max = 1005, /* us */ 1855 }; 1856 1857 static const struct qmp_phy_cfg sm8450_qmp_gen4x2_pciephy_cfg = { 1858 .lanes = 2, 1859 1860 .tables = { 1861 .serdes = sm8450_qmp_gen4x2_pcie_serdes_tbl, 1862 .serdes_num = ARRAY_SIZE(sm8450_qmp_gen4x2_pcie_serdes_tbl), 1863 .tx = sm8450_qmp_gen4x2_pcie_tx_tbl, 1864 .tx_num = ARRAY_SIZE(sm8450_qmp_gen4x2_pcie_tx_tbl), 1865 .rx = sm8450_qmp_gen4x2_pcie_rx_tbl, 1866 .rx_num = ARRAY_SIZE(sm8450_qmp_gen4x2_pcie_rx_tbl), 1867 .pcs = sm8450_qmp_gen4x2_pcie_pcs_tbl, 1868 .pcs_num = ARRAY_SIZE(sm8450_qmp_gen4x2_pcie_pcs_tbl), 1869 .pcs_misc = sm8450_qmp_gen4x2_pcie_pcs_misc_tbl, 1870 .pcs_misc_num = ARRAY_SIZE(sm8450_qmp_gen4x2_pcie_pcs_misc_tbl), 1871 }, 1872 1873 .tables_rc = &(const struct qmp_phy_cfg_tables) { 1874 .serdes = sm8450_qmp_gen4x2_pcie_rc_serdes_tbl, 1875 .serdes_num = ARRAY_SIZE(sm8450_qmp_gen4x2_pcie_rc_serdes_tbl), 1876 .pcs_misc = sm8450_qmp_gen4x2_pcie_rc_pcs_misc_tbl, 1877 .pcs_misc_num = ARRAY_SIZE(sm8450_qmp_gen4x2_pcie_rc_pcs_misc_tbl), 1878 }, 1879 1880 .tables_ep = &(const struct qmp_phy_cfg_tables) { 1881 .serdes = sm8450_qmp_gen4x2_pcie_ep_serdes_tbl, 1882 .serdes_num = ARRAY_SIZE(sm8450_qmp_gen4x2_pcie_ep_serdes_tbl), 1883 .pcs_misc = sm8450_qmp_gen4x2_pcie_ep_pcs_misc_tbl, 1884 .pcs_misc_num = ARRAY_SIZE(sm8450_qmp_gen4x2_pcie_ep_pcs_misc_tbl), 1885 }, 1886 1887 .clk_list = sdm845_pciephy_clk_l, 1888 .num_clks = ARRAY_SIZE(sdm845_pciephy_clk_l), 1889 .reset_list = sdm845_pciephy_reset_l, 1890 .num_resets = ARRAY_SIZE(sdm845_pciephy_reset_l), 1891 .vreg_list = qmp_phy_vreg_l, 1892 .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), 1893 .regs = sm8250_pcie_regs_layout, 1894 1895 .start_ctrl = SERDES_START | PCS_START, 1896 .pwrdn_ctrl = SW_PWRDN | REFCLK_DRV_DSBL, 1897 .phy_status = PHYSTATUS_4_20, 1898 1899 .has_pwrdn_delay = true, 1900 .pwrdn_delay_min = 995, /* us */ 1901 .pwrdn_delay_max = 1005, /* us */ 1902 }; 1903 1904 static void qmp_pcie_configure_lane(void __iomem *base, 1905 const unsigned int *regs, 1906 const struct qmp_phy_init_tbl tbl[], 1907 int num, 1908 u8 lane_mask) 1909 { 1910 int i; 1911 const struct qmp_phy_init_tbl *t = tbl; 1912 1913 if (!t) 1914 return; 1915 1916 for (i = 0; i < num; i++, t++) { 1917 if (!(t->lane_mask & lane_mask)) 1918 continue; 1919 1920 if (t->in_layout) 1921 writel(t->val, base + regs[t->offset]); 1922 else 1923 writel(t->val, base + t->offset); 1924 } 1925 } 1926 1927 static void qmp_pcie_configure(void __iomem *base, 1928 const unsigned int *regs, 1929 const struct qmp_phy_init_tbl tbl[], 1930 int num) 1931 { 1932 qmp_pcie_configure_lane(base, regs, tbl, num, 0xff); 1933 } 1934 1935 static void qmp_pcie_serdes_init(struct qmp_phy *qphy, const struct qmp_phy_cfg_tables *tables) 1936 { 1937 const struct qmp_phy_cfg *cfg = qphy->cfg; 1938 void __iomem *serdes = qphy->serdes; 1939 1940 if (!tables) 1941 return; 1942 1943 qmp_pcie_configure(serdes, cfg->regs, tables->serdes, tables->serdes_num); 1944 } 1945 1946 static void qmp_pcie_lanes_init(struct qmp_phy *qphy, const struct qmp_phy_cfg_tables *tables) 1947 { 1948 const struct qmp_phy_cfg *cfg = qphy->cfg; 1949 void __iomem *tx = qphy->tx; 1950 void __iomem *rx = qphy->rx; 1951 1952 if (!tables) 1953 return; 1954 1955 qmp_pcie_configure_lane(tx, cfg->regs, tables->tx, tables->tx_num, 1); 1956 1957 if (cfg->lanes >= 2) 1958 qmp_pcie_configure_lane(qphy->tx2, cfg->regs, tables->tx, tables->tx_num, 2); 1959 1960 qmp_pcie_configure_lane(rx, cfg->regs, tables->rx, tables->rx_num, 1); 1961 if (cfg->lanes >= 2) 1962 qmp_pcie_configure_lane(qphy->rx2, cfg->regs, tables->rx, tables->rx_num, 2); 1963 } 1964 1965 static void qmp_pcie_pcs_init(struct qmp_phy *qphy, const struct qmp_phy_cfg_tables *tables) 1966 { 1967 const struct qmp_phy_cfg *cfg = qphy->cfg; 1968 void __iomem *pcs = qphy->pcs; 1969 void __iomem *pcs_misc = qphy->pcs_misc; 1970 1971 if (!tables) 1972 return; 1973 1974 qmp_pcie_configure(pcs, cfg->regs, 1975 tables->pcs, tables->pcs_num); 1976 qmp_pcie_configure(pcs_misc, cfg->regs, 1977 tables->pcs_misc, tables->pcs_misc_num); 1978 } 1979 1980 static int qmp_pcie_init(struct phy *phy) 1981 { 1982 struct qmp_phy *qphy = phy_get_drvdata(phy); 1983 struct qcom_qmp *qmp = qphy->qmp; 1984 const struct qmp_phy_cfg *cfg = qphy->cfg; 1985 void __iomem *pcs = qphy->pcs; 1986 int ret; 1987 1988 /* turn on regulator supplies */ 1989 ret = regulator_bulk_enable(cfg->num_vregs, qmp->vregs); 1990 if (ret) { 1991 dev_err(qmp->dev, "failed to enable regulators, err=%d\n", ret); 1992 return ret; 1993 } 1994 1995 ret = reset_control_bulk_assert(cfg->num_resets, qmp->resets); 1996 if (ret) { 1997 dev_err(qmp->dev, "reset assert failed\n"); 1998 goto err_disable_regulators; 1999 } 2000 2001 ret = reset_control_bulk_deassert(cfg->num_resets, qmp->resets); 2002 if (ret) { 2003 dev_err(qmp->dev, "reset deassert failed\n"); 2004 goto err_disable_regulators; 2005 } 2006 2007 ret = clk_bulk_prepare_enable(cfg->num_clks, qmp->clks); 2008 if (ret) 2009 goto err_assert_reset; 2010 2011 if (cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL]) 2012 qphy_setbits(pcs, 2013 cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL], 2014 cfg->pwrdn_ctrl); 2015 else 2016 qphy_setbits(pcs, QPHY_V2_PCS_POWER_DOWN_CONTROL, 2017 cfg->pwrdn_ctrl); 2018 2019 return 0; 2020 2021 err_assert_reset: 2022 reset_control_bulk_assert(cfg->num_resets, qmp->resets); 2023 err_disable_regulators: 2024 regulator_bulk_disable(cfg->num_vregs, qmp->vregs); 2025 2026 return ret; 2027 } 2028 2029 static int qmp_pcie_exit(struct phy *phy) 2030 { 2031 struct qmp_phy *qphy = phy_get_drvdata(phy); 2032 struct qcom_qmp *qmp = qphy->qmp; 2033 const struct qmp_phy_cfg *cfg = qphy->cfg; 2034 2035 reset_control_bulk_assert(cfg->num_resets, qmp->resets); 2036 2037 clk_bulk_disable_unprepare(cfg->num_clks, qmp->clks); 2038 2039 regulator_bulk_disable(cfg->num_vregs, qmp->vregs); 2040 2041 return 0; 2042 } 2043 2044 static int qmp_pcie_power_on(struct phy *phy) 2045 { 2046 struct qmp_phy *qphy = phy_get_drvdata(phy); 2047 struct qcom_qmp *qmp = qphy->qmp; 2048 const struct qmp_phy_cfg *cfg = qphy->cfg; 2049 const struct qmp_phy_cfg_tables *mode_tables; 2050 void __iomem *pcs = qphy->pcs; 2051 void __iomem *status; 2052 unsigned int mask, val, ready; 2053 int ret; 2054 2055 if (qphy->mode == PHY_MODE_PCIE_RC) 2056 mode_tables = cfg->tables_rc; 2057 else 2058 mode_tables = cfg->tables_ep; 2059 2060 qmp_pcie_serdes_init(qphy, &cfg->tables); 2061 qmp_pcie_serdes_init(qphy, mode_tables); 2062 2063 ret = clk_prepare_enable(qphy->pipe_clk); 2064 if (ret) { 2065 dev_err(qmp->dev, "pipe_clk enable failed err=%d\n", ret); 2066 return ret; 2067 } 2068 2069 /* Tx, Rx, and PCS configurations */ 2070 qmp_pcie_lanes_init(qphy, &cfg->tables); 2071 qmp_pcie_lanes_init(qphy, mode_tables); 2072 2073 qmp_pcie_pcs_init(qphy, &cfg->tables); 2074 qmp_pcie_pcs_init(qphy, mode_tables); 2075 2076 /* 2077 * Pull out PHY from POWER DOWN state. 2078 * This is active low enable signal to power-down PHY. 2079 */ 2080 qphy_setbits(pcs, QPHY_V2_PCS_POWER_DOWN_CONTROL, cfg->pwrdn_ctrl); 2081 2082 if (cfg->has_pwrdn_delay) 2083 usleep_range(cfg->pwrdn_delay_min, cfg->pwrdn_delay_max); 2084 2085 /* Pull PHY out of reset state */ 2086 qphy_clrbits(pcs, cfg->regs[QPHY_SW_RESET], SW_RESET); 2087 2088 /* start SerDes and Phy-Coding-Sublayer */ 2089 qphy_setbits(pcs, cfg->regs[QPHY_START_CTRL], cfg->start_ctrl); 2090 2091 status = pcs + cfg->regs[QPHY_PCS_STATUS]; 2092 mask = cfg->phy_status; 2093 ready = 0; 2094 2095 ret = readl_poll_timeout(status, val, (val & mask) == ready, 10, 2096 PHY_INIT_COMPLETE_TIMEOUT); 2097 if (ret) { 2098 dev_err(qmp->dev, "phy initialization timed-out\n"); 2099 goto err_disable_pipe_clk; 2100 } 2101 2102 return 0; 2103 2104 err_disable_pipe_clk: 2105 clk_disable_unprepare(qphy->pipe_clk); 2106 2107 return ret; 2108 } 2109 2110 static int qmp_pcie_power_off(struct phy *phy) 2111 { 2112 struct qmp_phy *qphy = phy_get_drvdata(phy); 2113 const struct qmp_phy_cfg *cfg = qphy->cfg; 2114 2115 clk_disable_unprepare(qphy->pipe_clk); 2116 2117 /* PHY reset */ 2118 qphy_setbits(qphy->pcs, cfg->regs[QPHY_SW_RESET], SW_RESET); 2119 2120 /* stop SerDes and Phy-Coding-Sublayer */ 2121 qphy_clrbits(qphy->pcs, cfg->regs[QPHY_START_CTRL], cfg->start_ctrl); 2122 2123 /* Put PHY into POWER DOWN state: active low */ 2124 if (cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL]) { 2125 qphy_clrbits(qphy->pcs, cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL], 2126 cfg->pwrdn_ctrl); 2127 } else { 2128 qphy_clrbits(qphy->pcs, QPHY_V2_PCS_POWER_DOWN_CONTROL, 2129 cfg->pwrdn_ctrl); 2130 } 2131 2132 return 0; 2133 } 2134 2135 static int qmp_pcie_enable(struct phy *phy) 2136 { 2137 int ret; 2138 2139 ret = qmp_pcie_init(phy); 2140 if (ret) 2141 return ret; 2142 2143 ret = qmp_pcie_power_on(phy); 2144 if (ret) 2145 qmp_pcie_exit(phy); 2146 2147 return ret; 2148 } 2149 2150 static int qmp_pcie_disable(struct phy *phy) 2151 { 2152 int ret; 2153 2154 ret = qmp_pcie_power_off(phy); 2155 if (ret) 2156 return ret; 2157 2158 return qmp_pcie_exit(phy); 2159 } 2160 2161 static int qmp_pcie_set_mode(struct phy *phy, enum phy_mode mode, int submode) 2162 { 2163 struct qmp_phy *qphy = phy_get_drvdata(phy); 2164 2165 switch (submode) { 2166 case PHY_MODE_PCIE_RC: 2167 case PHY_MODE_PCIE_EP: 2168 qphy->mode = submode; 2169 break; 2170 default: 2171 dev_err(&phy->dev, "Unsupported submode %d\n", submode); 2172 return -EINVAL; 2173 } 2174 2175 return 0; 2176 } 2177 2178 static int qmp_pcie_vreg_init(struct device *dev, const struct qmp_phy_cfg *cfg) 2179 { 2180 struct qcom_qmp *qmp = dev_get_drvdata(dev); 2181 int num = cfg->num_vregs; 2182 int i; 2183 2184 qmp->vregs = devm_kcalloc(dev, num, sizeof(*qmp->vregs), GFP_KERNEL); 2185 if (!qmp->vregs) 2186 return -ENOMEM; 2187 2188 for (i = 0; i < num; i++) 2189 qmp->vregs[i].supply = cfg->vreg_list[i]; 2190 2191 return devm_regulator_bulk_get(dev, num, qmp->vregs); 2192 } 2193 2194 static int qmp_pcie_reset_init(struct device *dev, const struct qmp_phy_cfg *cfg) 2195 { 2196 struct qcom_qmp *qmp = dev_get_drvdata(dev); 2197 int i; 2198 int ret; 2199 2200 qmp->resets = devm_kcalloc(dev, cfg->num_resets, 2201 sizeof(*qmp->resets), GFP_KERNEL); 2202 if (!qmp->resets) 2203 return -ENOMEM; 2204 2205 for (i = 0; i < cfg->num_resets; i++) 2206 qmp->resets[i].id = cfg->reset_list[i]; 2207 2208 ret = devm_reset_control_bulk_get_exclusive(dev, cfg->num_resets, qmp->resets); 2209 if (ret) 2210 return dev_err_probe(dev, ret, "failed to get resets\n"); 2211 2212 return 0; 2213 } 2214 2215 static int qmp_pcie_clk_init(struct device *dev, const struct qmp_phy_cfg *cfg) 2216 { 2217 struct qcom_qmp *qmp = dev_get_drvdata(dev); 2218 int num = cfg->num_clks; 2219 int i; 2220 2221 qmp->clks = devm_kcalloc(dev, num, sizeof(*qmp->clks), GFP_KERNEL); 2222 if (!qmp->clks) 2223 return -ENOMEM; 2224 2225 for (i = 0; i < num; i++) 2226 qmp->clks[i].id = cfg->clk_list[i]; 2227 2228 return devm_clk_bulk_get(dev, num, qmp->clks); 2229 } 2230 2231 static void phy_clk_release_provider(void *res) 2232 { 2233 of_clk_del_provider(res); 2234 } 2235 2236 /* 2237 * Register a fixed rate pipe clock. 2238 * 2239 * The <s>_pipe_clksrc generated by PHY goes to the GCC that gate 2240 * controls it. The <s>_pipe_clk coming out of the GCC is requested 2241 * by the PHY driver for its operations. 2242 * We register the <s>_pipe_clksrc here. The gcc driver takes care 2243 * of assigning this <s>_pipe_clksrc as parent to <s>_pipe_clk. 2244 * Below picture shows this relationship. 2245 * 2246 * +---------------+ 2247 * | PHY block |<<---------------------------------------+ 2248 * | | | 2249 * | +-------+ | +-----+ | 2250 * I/P---^-->| PLL |---^--->pipe_clksrc--->| GCC |--->pipe_clk---+ 2251 * clk | +-------+ | +-----+ 2252 * +---------------+ 2253 */ 2254 static int phy_pipe_clk_register(struct qcom_qmp *qmp, struct device_node *np) 2255 { 2256 struct clk_fixed_rate *fixed; 2257 struct clk_init_data init = { }; 2258 int ret; 2259 2260 ret = of_property_read_string(np, "clock-output-names", &init.name); 2261 if (ret) { 2262 dev_err(qmp->dev, "%pOFn: No clock-output-names\n", np); 2263 return ret; 2264 } 2265 2266 fixed = devm_kzalloc(qmp->dev, sizeof(*fixed), GFP_KERNEL); 2267 if (!fixed) 2268 return -ENOMEM; 2269 2270 init.ops = &clk_fixed_rate_ops; 2271 2272 /* 2273 * Controllers using QMP PHY-s use 125MHz pipe clock interface 2274 * unless other frequency is specified in the PHY config. 2275 */ 2276 if (qmp->phys[0]->cfg->pipe_clock_rate) 2277 fixed->fixed_rate = qmp->phys[0]->cfg->pipe_clock_rate; 2278 else 2279 fixed->fixed_rate = 125000000; 2280 2281 fixed->hw.init = &init; 2282 2283 ret = devm_clk_hw_register(qmp->dev, &fixed->hw); 2284 if (ret) 2285 return ret; 2286 2287 ret = of_clk_add_hw_provider(np, of_clk_hw_simple_get, &fixed->hw); 2288 if (ret) 2289 return ret; 2290 2291 /* 2292 * Roll a devm action because the clock provider is the child node, but 2293 * the child node is not actually a device. 2294 */ 2295 return devm_add_action_or_reset(qmp->dev, phy_clk_release_provider, np); 2296 } 2297 2298 static const struct phy_ops qmp_pcie_ops = { 2299 .power_on = qmp_pcie_enable, 2300 .power_off = qmp_pcie_disable, 2301 .set_mode = qmp_pcie_set_mode, 2302 .owner = THIS_MODULE, 2303 }; 2304 2305 static int qmp_pcie_create(struct device *dev, struct device_node *np, int id, 2306 void __iomem *serdes, const struct qmp_phy_cfg *cfg) 2307 { 2308 struct qcom_qmp *qmp = dev_get_drvdata(dev); 2309 struct phy *generic_phy; 2310 struct qmp_phy *qphy; 2311 int ret; 2312 2313 qphy = devm_kzalloc(dev, sizeof(*qphy), GFP_KERNEL); 2314 if (!qphy) 2315 return -ENOMEM; 2316 2317 qphy->mode = PHY_MODE_PCIE_RC; 2318 2319 qphy->cfg = cfg; 2320 qphy->serdes = serdes; 2321 /* 2322 * Get memory resources for the PHY: 2323 * Resources are indexed as: tx -> 0; rx -> 1; pcs -> 2. 2324 * For dual lane PHYs: tx2 -> 3, rx2 -> 4, pcs_misc (optional) -> 5 2325 * For single lane PHYs: pcs_misc (optional) -> 3. 2326 */ 2327 qphy->tx = devm_of_iomap(dev, np, 0, NULL); 2328 if (IS_ERR(qphy->tx)) 2329 return PTR_ERR(qphy->tx); 2330 2331 if (of_device_is_compatible(dev->of_node, "qcom,sdm845-qhp-pcie-phy")) 2332 qphy->rx = qphy->tx; 2333 else 2334 qphy->rx = devm_of_iomap(dev, np, 1, NULL); 2335 if (IS_ERR(qphy->rx)) 2336 return PTR_ERR(qphy->rx); 2337 2338 qphy->pcs = devm_of_iomap(dev, np, 2, NULL); 2339 if (IS_ERR(qphy->pcs)) 2340 return PTR_ERR(qphy->pcs); 2341 2342 if (cfg->lanes >= 2) { 2343 qphy->tx2 = devm_of_iomap(dev, np, 3, NULL); 2344 if (IS_ERR(qphy->tx2)) 2345 return PTR_ERR(qphy->tx2); 2346 2347 qphy->rx2 = devm_of_iomap(dev, np, 4, NULL); 2348 if (IS_ERR(qphy->rx2)) 2349 return PTR_ERR(qphy->rx2); 2350 2351 qphy->pcs_misc = devm_of_iomap(dev, np, 5, NULL); 2352 } else { 2353 qphy->pcs_misc = devm_of_iomap(dev, np, 3, NULL); 2354 } 2355 2356 if (IS_ERR(qphy->pcs_misc) && 2357 of_device_is_compatible(dev->of_node, "qcom,ipq6018-qmp-pcie-phy")) 2358 qphy->pcs_misc = qphy->pcs + 0x400; 2359 2360 if (IS_ERR(qphy->pcs_misc)) { 2361 if (cfg->tables.pcs_misc || 2362 (cfg->tables_rc && cfg->tables_rc->pcs_misc) || 2363 (cfg->tables_ep && cfg->tables_ep->pcs_misc)) 2364 return PTR_ERR(qphy->pcs_misc); 2365 } 2366 2367 qphy->pipe_clk = devm_get_clk_from_child(dev, np, NULL); 2368 if (IS_ERR(qphy->pipe_clk)) { 2369 return dev_err_probe(dev, PTR_ERR(qphy->pipe_clk), 2370 "failed to get lane%d pipe clock\n", id); 2371 } 2372 2373 generic_phy = devm_phy_create(dev, np, &qmp_pcie_ops); 2374 if (IS_ERR(generic_phy)) { 2375 ret = PTR_ERR(generic_phy); 2376 dev_err(dev, "failed to create qphy %d\n", ret); 2377 return ret; 2378 } 2379 2380 qphy->phy = generic_phy; 2381 qphy->qmp = qmp; 2382 qmp->phys[id] = qphy; 2383 phy_set_drvdata(generic_phy, qphy); 2384 2385 return 0; 2386 } 2387 2388 static const struct of_device_id qmp_pcie_of_match_table[] = { 2389 { 2390 .compatible = "qcom,msm8998-qmp-pcie-phy", 2391 .data = &msm8998_pciephy_cfg, 2392 }, { 2393 .compatible = "qcom,ipq8074-qmp-pcie-phy", 2394 .data = &ipq8074_pciephy_cfg, 2395 }, { 2396 .compatible = "qcom,ipq8074-qmp-gen3-pcie-phy", 2397 .data = &ipq8074_pciephy_gen3_cfg, 2398 }, { 2399 .compatible = "qcom,ipq6018-qmp-pcie-phy", 2400 .data = &ipq6018_pciephy_cfg, 2401 }, { 2402 .compatible = "qcom,sc8180x-qmp-pcie-phy", 2403 .data = &sc8180x_pciephy_cfg, 2404 }, { 2405 .compatible = "qcom,sdm845-qhp-pcie-phy", 2406 .data = &sdm845_qhp_pciephy_cfg, 2407 }, { 2408 .compatible = "qcom,sdm845-qmp-pcie-phy", 2409 .data = &sdm845_qmp_pciephy_cfg, 2410 }, { 2411 .compatible = "qcom,sm8250-qmp-gen3x1-pcie-phy", 2412 .data = &sm8250_qmp_gen3x1_pciephy_cfg, 2413 }, { 2414 .compatible = "qcom,sm8250-qmp-gen3x2-pcie-phy", 2415 .data = &sm8250_qmp_gen3x2_pciephy_cfg, 2416 }, { 2417 .compatible = "qcom,sm8250-qmp-modem-pcie-phy", 2418 .data = &sm8250_qmp_gen3x2_pciephy_cfg, 2419 }, { 2420 .compatible = "qcom,sdx55-qmp-pcie-phy", 2421 .data = &sdx55_qmp_pciephy_cfg, 2422 }, { 2423 .compatible = "qcom,sm8450-qmp-gen3x1-pcie-phy", 2424 .data = &sm8450_qmp_gen3x1_pciephy_cfg, 2425 }, { 2426 .compatible = "qcom,sm8450-qmp-gen4x2-pcie-phy", 2427 .data = &sm8450_qmp_gen4x2_pciephy_cfg, 2428 }, 2429 { }, 2430 }; 2431 MODULE_DEVICE_TABLE(of, qmp_pcie_of_match_table); 2432 2433 static int qmp_pcie_probe(struct platform_device *pdev) 2434 { 2435 struct qcom_qmp *qmp; 2436 struct device *dev = &pdev->dev; 2437 struct device_node *child; 2438 struct phy_provider *phy_provider; 2439 void __iomem *serdes; 2440 const struct qmp_phy_cfg *cfg = NULL; 2441 int num, id; 2442 int ret; 2443 2444 qmp = devm_kzalloc(dev, sizeof(*qmp), GFP_KERNEL); 2445 if (!qmp) 2446 return -ENOMEM; 2447 2448 qmp->dev = dev; 2449 dev_set_drvdata(dev, qmp); 2450 2451 /* Get the specific init parameters of QMP phy */ 2452 cfg = of_device_get_match_data(dev); 2453 if (!cfg) 2454 return -EINVAL; 2455 2456 /* per PHY serdes; usually located at base address */ 2457 serdes = devm_platform_ioremap_resource(pdev, 0); 2458 if (IS_ERR(serdes)) 2459 return PTR_ERR(serdes); 2460 2461 ret = qmp_pcie_clk_init(dev, cfg); 2462 if (ret) 2463 return ret; 2464 2465 ret = qmp_pcie_reset_init(dev, cfg); 2466 if (ret) 2467 return ret; 2468 2469 ret = qmp_pcie_vreg_init(dev, cfg); 2470 if (ret) 2471 return dev_err_probe(dev, ret, 2472 "failed to get regulator supplies\n"); 2473 2474 num = of_get_available_child_count(dev->of_node); 2475 /* do we have a rogue child node ? */ 2476 if (num > 1) 2477 return -EINVAL; 2478 2479 qmp->phys = devm_kcalloc(dev, num, sizeof(*qmp->phys), GFP_KERNEL); 2480 if (!qmp->phys) 2481 return -ENOMEM; 2482 2483 id = 0; 2484 for_each_available_child_of_node(dev->of_node, child) { 2485 /* Create per-lane phy */ 2486 ret = qmp_pcie_create(dev, child, id, serdes, cfg); 2487 if (ret) { 2488 dev_err(dev, "failed to create lane%d phy, %d\n", 2489 id, ret); 2490 goto err_node_put; 2491 } 2492 2493 /* 2494 * Register the pipe clock provided by phy. 2495 * See function description to see details of this pipe clock. 2496 */ 2497 ret = phy_pipe_clk_register(qmp, child); 2498 if (ret) { 2499 dev_err(qmp->dev, 2500 "failed to register pipe clock source\n"); 2501 goto err_node_put; 2502 } 2503 2504 id++; 2505 } 2506 2507 phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); 2508 2509 return PTR_ERR_OR_ZERO(phy_provider); 2510 2511 err_node_put: 2512 of_node_put(child); 2513 return ret; 2514 } 2515 2516 static struct platform_driver qmp_pcie_driver = { 2517 .probe = qmp_pcie_probe, 2518 .driver = { 2519 .name = "qcom-qmp-pcie-phy", 2520 .of_match_table = qmp_pcie_of_match_table, 2521 }, 2522 }; 2523 2524 module_platform_driver(qmp_pcie_driver); 2525 2526 MODULE_AUTHOR("Vivek Gautam <vivek.gautam@codeaurora.org>"); 2527 MODULE_DESCRIPTION("Qualcomm QMP PCIe PHY driver"); 2528 MODULE_LICENSE("GPL v2"); 2529