1 // SPDX-License-Identifier: GPL-2.0 2 /* 3 * Cadence Sierra PHY Driver 4 * 5 * Copyright (c) 2018 Cadence Design Systems 6 * Author: Alan Douglas <adouglas@cadence.com> 7 * 8 */ 9 #include <linux/clk.h> 10 #include <linux/clk-provider.h> 11 #include <linux/delay.h> 12 #include <linux/err.h> 13 #include <linux/io.h> 14 #include <linux/module.h> 15 #include <linux/phy/phy.h> 16 #include <linux/platform_device.h> 17 #include <linux/pm_runtime.h> 18 #include <linux/regmap.h> 19 #include <linux/reset.h> 20 #include <linux/slab.h> 21 #include <linux/of.h> 22 #include <linux/of_platform.h> 23 #include <dt-bindings/phy/phy.h> 24 #include <dt-bindings/phy/phy-cadence.h> 25 26 #define NUM_SSC_MODE 3 27 #define NUM_PHY_TYPE 4 28 29 /* PHY register offsets */ 30 #define SIERRA_COMMON_CDB_OFFSET 0x0 31 #define SIERRA_MACRO_ID_REG 0x0 32 #define SIERRA_CMN_PLLLC_GEN_PREG 0x42 33 #define SIERRA_CMN_PLLLC_MODE_PREG 0x48 34 #define SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG 0x49 35 #define SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG 0x4A 36 #define SIERRA_CMN_PLLLC_LOCK_CNTSTART_PREG 0x4B 37 #define SIERRA_CMN_PLLLC_CLK1_PREG 0x4D 38 #define SIERRA_CMN_PLLLC_BWCAL_MODE1_PREG 0x4F 39 #define SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG 0x50 40 #define SIERRA_CMN_PLLLC_DSMCORR_PREG 0x51 41 #define SIERRA_CMN_PLLLC_SS_PREG 0x52 42 #define SIERRA_CMN_PLLLC_SS_AMP_STEP_SIZE_PREG 0x53 43 #define SIERRA_CMN_PLLLC_SSTWOPT_PREG 0x54 44 #define SIERRA_CMN_PLLLC_SS_TIME_STEPSIZE_MODE_PREG 0x62 45 #define SIERRA_CMN_PLLLC_LOCK_DELAY_CTRL_PREG 0x63 46 #define SIERRA_CMN_REFRCV_PREG 0x98 47 #define SIERRA_CMN_REFRCV1_PREG 0xB8 48 #define SIERRA_CMN_PLLLC1_GEN_PREG 0xC2 49 #define SIERRA_CMN_PLLLC1_LF_COEFF_MODE0_PREG 0xCA 50 #define SIERRA_CMN_PLLLC1_BWCAL_MODE0_PREG 0xD0 51 #define SIERRA_CMN_PLLLC1_SS_TIME_STEPSIZE_MODE_PREG 0xE2 52 53 #define SIERRA_LANE_CDB_OFFSET(ln, block_offset, reg_offset) \ 54 ((0x4000 << (block_offset)) + \ 55 (((ln) << 9) << (reg_offset))) 56 57 #define SIERRA_DET_STANDEC_A_PREG 0x000 58 #define SIERRA_DET_STANDEC_B_PREG 0x001 59 #define SIERRA_DET_STANDEC_C_PREG 0x002 60 #define SIERRA_DET_STANDEC_D_PREG 0x003 61 #define SIERRA_DET_STANDEC_E_PREG 0x004 62 #define SIERRA_PSM_LANECAL_DLY_A1_RESETS_PREG 0x008 63 #define SIERRA_PSM_A0IN_TMR_PREG 0x009 64 #define SIERRA_PSM_A3IN_TMR_PREG 0x00C 65 #define SIERRA_PSM_DIAG_PREG 0x015 66 #define SIERRA_PSC_LN_A3_PREG 0x023 67 #define SIERRA_PSC_LN_A4_PREG 0x024 68 #define SIERRA_PSC_LN_IDLE_PREG 0x026 69 #define SIERRA_PSC_TX_A0_PREG 0x028 70 #define SIERRA_PSC_TX_A1_PREG 0x029 71 #define SIERRA_PSC_TX_A2_PREG 0x02A 72 #define SIERRA_PSC_TX_A3_PREG 0x02B 73 #define SIERRA_PSC_RX_A0_PREG 0x030 74 #define SIERRA_PSC_RX_A1_PREG 0x031 75 #define SIERRA_PSC_RX_A2_PREG 0x032 76 #define SIERRA_PSC_RX_A3_PREG 0x033 77 #define SIERRA_PLLCTRL_SUBRATE_PREG 0x03A 78 #define SIERRA_PLLCTRL_GEN_A_PREG 0x03B 79 #define SIERRA_PLLCTRL_GEN_D_PREG 0x03E 80 #define SIERRA_PLLCTRL_CPGAIN_MODE_PREG 0x03F 81 #define SIERRA_PLLCTRL_STATUS_PREG 0x044 82 #define SIERRA_CLKPATH_BIASTRIM_PREG 0x04B 83 #define SIERRA_DFE_BIASTRIM_PREG 0x04C 84 #define SIERRA_DRVCTRL_ATTEN_PREG 0x06A 85 #define SIERRA_DRVCTRL_BOOST_PREG 0x06F 86 #define SIERRA_CLKPATHCTRL_TMR_PREG 0x081 87 #define SIERRA_RX_CREQ_FLTR_A_MODE3_PREG 0x085 88 #define SIERRA_RX_CREQ_FLTR_A_MODE2_PREG 0x086 89 #define SIERRA_RX_CREQ_FLTR_A_MODE1_PREG 0x087 90 #define SIERRA_RX_CREQ_FLTR_A_MODE0_PREG 0x088 91 #define SIERRA_CREQ_DCBIASATTEN_OVR_PREG 0x08C 92 #define SIERRA_CREQ_CCLKDET_MODE01_PREG 0x08E 93 #define SIERRA_RX_CTLE_CAL_PREG 0x08F 94 #define SIERRA_RX_CTLE_MAINTENANCE_PREG 0x091 95 #define SIERRA_CREQ_FSMCLK_SEL_PREG 0x092 96 #define SIERRA_CREQ_EQ_CTRL_PREG 0x093 97 #define SIERRA_CREQ_SPARE_PREG 0x096 98 #define SIERRA_CREQ_EQ_OPEN_EYE_THRESH_PREG 0x097 99 #define SIERRA_CTLELUT_CTRL_PREG 0x098 100 #define SIERRA_DFE_ECMP_RATESEL_PREG 0x0C0 101 #define SIERRA_DFE_SMP_RATESEL_PREG 0x0C1 102 #define SIERRA_DEQ_PHALIGN_CTRL 0x0C4 103 #define SIERRA_DEQ_CONCUR_CTRL1_PREG 0x0C8 104 #define SIERRA_DEQ_CONCUR_CTRL2_PREG 0x0C9 105 #define SIERRA_DEQ_EPIPWR_CTRL2_PREG 0x0CD 106 #define SIERRA_DEQ_FAST_MAINT_CYCLES_PREG 0x0CE 107 #define SIERRA_DEQ_ERRCMP_CTRL_PREG 0x0D0 108 #define SIERRA_DEQ_OFFSET_CTRL_PREG 0x0D8 109 #define SIERRA_DEQ_GAIN_CTRL_PREG 0x0E0 110 #define SIERRA_DEQ_VGATUNE_CTRL_PREG 0x0E1 111 #define SIERRA_DEQ_GLUT0 0x0E8 112 #define SIERRA_DEQ_GLUT1 0x0E9 113 #define SIERRA_DEQ_GLUT2 0x0EA 114 #define SIERRA_DEQ_GLUT3 0x0EB 115 #define SIERRA_DEQ_GLUT4 0x0EC 116 #define SIERRA_DEQ_GLUT5 0x0ED 117 #define SIERRA_DEQ_GLUT6 0x0EE 118 #define SIERRA_DEQ_GLUT7 0x0EF 119 #define SIERRA_DEQ_GLUT8 0x0F0 120 #define SIERRA_DEQ_GLUT9 0x0F1 121 #define SIERRA_DEQ_GLUT10 0x0F2 122 #define SIERRA_DEQ_GLUT11 0x0F3 123 #define SIERRA_DEQ_GLUT12 0x0F4 124 #define SIERRA_DEQ_GLUT13 0x0F5 125 #define SIERRA_DEQ_GLUT14 0x0F6 126 #define SIERRA_DEQ_GLUT15 0x0F7 127 #define SIERRA_DEQ_GLUT16 0x0F8 128 #define SIERRA_DEQ_ALUT0 0x108 129 #define SIERRA_DEQ_ALUT1 0x109 130 #define SIERRA_DEQ_ALUT2 0x10A 131 #define SIERRA_DEQ_ALUT3 0x10B 132 #define SIERRA_DEQ_ALUT4 0x10C 133 #define SIERRA_DEQ_ALUT5 0x10D 134 #define SIERRA_DEQ_ALUT6 0x10E 135 #define SIERRA_DEQ_ALUT7 0x10F 136 #define SIERRA_DEQ_ALUT8 0x110 137 #define SIERRA_DEQ_ALUT9 0x111 138 #define SIERRA_DEQ_ALUT10 0x112 139 #define SIERRA_DEQ_ALUT11 0x113 140 #define SIERRA_DEQ_ALUT12 0x114 141 #define SIERRA_DEQ_ALUT13 0x115 142 #define SIERRA_DEQ_DFETAP_CTRL_PREG 0x128 143 #define SIERRA_DEQ_DFETAP0 0x129 144 #define SIERRA_DEQ_DFETAP1 0x12B 145 #define SIERRA_DEQ_DFETAP2 0x12D 146 #define SIERRA_DEQ_DFETAP3 0x12F 147 #define SIERRA_DEQ_DFETAP4 0x131 148 #define SIERRA_DFE_EN_1010_IGNORE_PREG 0x134 149 #define SIERRA_DEQ_PRECUR_PREG 0x138 150 #define SIERRA_DEQ_POSTCUR_PREG 0x140 151 #define SIERRA_DEQ_POSTCUR_DECR_PREG 0x142 152 #define SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG 0x150 153 #define SIERRA_DEQ_TAU_CTRL2_PREG 0x151 154 #define SIERRA_DEQ_TAU_CTRL3_PREG 0x152 155 #define SIERRA_DEQ_OPENEYE_CTRL_PREG 0x158 156 #define SIERRA_DEQ_PICTRL_PREG 0x161 157 #define SIERRA_CPICAL_TMRVAL_MODE1_PREG 0x170 158 #define SIERRA_CPICAL_TMRVAL_MODE0_PREG 0x171 159 #define SIERRA_CPICAL_PICNT_MODE1_PREG 0x174 160 #define SIERRA_CPI_OUTBUF_RATESEL_PREG 0x17C 161 #define SIERRA_CPI_RESBIAS_BIN_PREG 0x17E 162 #define SIERRA_CPI_TRIM_PREG 0x17F 163 #define SIERRA_CPICAL_RES_STARTCODE_MODE23_PREG 0x183 164 #define SIERRA_EPI_CTRL_PREG 0x187 165 #define SIERRA_LFPSDET_SUPPORT_PREG 0x188 166 #define SIERRA_LFPSFILT_NS_PREG 0x18A 167 #define SIERRA_LFPSFILT_RD_PREG 0x18B 168 #define SIERRA_LFPSFILT_MP_PREG 0x18C 169 #define SIERRA_SIGDET_SUPPORT_PREG 0x190 170 #define SIERRA_SDFILT_H2L_A_PREG 0x191 171 #define SIERRA_SDFILT_L2H_PREG 0x193 172 #define SIERRA_RXBUFFER_CTLECTRL_PREG 0x19E 173 #define SIERRA_RXBUFFER_RCDFECTRL_PREG 0x19F 174 #define SIERRA_RXBUFFER_DFECTRL_PREG 0x1A0 175 #define SIERRA_DEQ_TAU_CTRL1_FAST_MAINT_PREG 0x14F 176 #define SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG 0x150 177 178 /* PHY PCS common registers */ 179 #define SIERRA_PHY_PCS_COMMON_OFFSET(block_offset) \ 180 (0xc000 << (block_offset)) 181 #define SIERRA_PHY_PIPE_CMN_CTRL1 0x0 182 #define SIERRA_PHY_PLL_CFG 0xe 183 184 /* PHY PCS lane registers */ 185 #define SIERRA_PHY_PCS_LANE_CDB_OFFSET(ln, block_offset, reg_offset) \ 186 ((0xD000 << (block_offset)) + \ 187 (((ln) << 8) << (reg_offset))) 188 189 #define SIERRA_PHY_ISO_LINK_CTRL 0xB 190 191 /* PHY PMA common registers */ 192 #define SIERRA_PHY_PMA_COMMON_OFFSET(block_offset) \ 193 (0xE000 << (block_offset)) 194 #define SIERRA_PHY_PMA_CMN_CTRL 0x000 195 196 /* PHY PMA lane registers */ 197 #define SIERRA_PHY_PMA_LANE_CDB_OFFSET(ln, block_offset, reg_offset) \ 198 ((0xF000 << (block_offset)) + \ 199 (((ln) << 8) << (reg_offset))) 200 201 #define SIERRA_PHY_PMA_XCVR_CTRL 0x000 202 203 #define SIERRA_MACRO_ID 0x00007364 204 #define SIERRA_MAX_LANES 16 205 #define PLL_LOCK_TIME 100000 206 207 #define CDNS_SIERRA_OUTPUT_CLOCKS 3 208 #define CDNS_SIERRA_INPUT_CLOCKS 5 209 enum cdns_sierra_clock_input { 210 PHY_CLK, 211 CMN_REFCLK_DIG_DIV, 212 CMN_REFCLK1_DIG_DIV, 213 PLL0_REFCLK, 214 PLL1_REFCLK, 215 }; 216 217 #define SIERRA_NUM_CMN_PLLC 2 218 #define SIERRA_NUM_CMN_PLLC_PARENTS 2 219 220 static const struct reg_field macro_id_type = 221 REG_FIELD(SIERRA_MACRO_ID_REG, 0, 15); 222 static const struct reg_field phy_pll_cfg_1 = 223 REG_FIELD(SIERRA_PHY_PLL_CFG, 1, 1); 224 static const struct reg_field pma_cmn_ready = 225 REG_FIELD(SIERRA_PHY_PMA_CMN_CTRL, 0, 0); 226 static const struct reg_field pllctrl_lock = 227 REG_FIELD(SIERRA_PLLCTRL_STATUS_PREG, 0, 0); 228 static const struct reg_field phy_iso_link_ctrl_1 = 229 REG_FIELD(SIERRA_PHY_ISO_LINK_CTRL, 1, 1); 230 static const struct reg_field cmn_plllc_clk1outdiv_preg = 231 REG_FIELD(SIERRA_CMN_PLLLC_CLK1_PREG, 0, 6); 232 static const struct reg_field cmn_plllc_clk1_en_preg = 233 REG_FIELD(SIERRA_CMN_PLLLC_CLK1_PREG, 12, 12); 234 235 static const char * const clk_names[] = { 236 [CDNS_SIERRA_PLL_CMNLC] = "pll_cmnlc", 237 [CDNS_SIERRA_PLL_CMNLC1] = "pll_cmnlc1", 238 [CDNS_SIERRA_DERIVED_REFCLK] = "refclk_der", 239 }; 240 241 enum cdns_sierra_cmn_plllc { 242 CMN_PLLLC, 243 CMN_PLLLC1, 244 }; 245 246 struct cdns_sierra_pll_mux_reg_fields { 247 struct reg_field pfdclk_sel_preg; 248 struct reg_field plllc1en_field; 249 struct reg_field termen_field; 250 }; 251 252 static const struct cdns_sierra_pll_mux_reg_fields cmn_plllc_pfdclk1_sel_preg[] = { 253 [CMN_PLLLC] = { 254 .pfdclk_sel_preg = REG_FIELD(SIERRA_CMN_PLLLC_GEN_PREG, 1, 1), 255 .plllc1en_field = REG_FIELD(SIERRA_CMN_REFRCV1_PREG, 8, 8), 256 .termen_field = REG_FIELD(SIERRA_CMN_REFRCV1_PREG, 0, 0), 257 }, 258 [CMN_PLLLC1] = { 259 .pfdclk_sel_preg = REG_FIELD(SIERRA_CMN_PLLLC1_GEN_PREG, 1, 1), 260 .plllc1en_field = REG_FIELD(SIERRA_CMN_REFRCV_PREG, 8, 8), 261 .termen_field = REG_FIELD(SIERRA_CMN_REFRCV_PREG, 0, 0), 262 }, 263 }; 264 265 struct cdns_sierra_pll_mux { 266 struct clk_hw hw; 267 struct regmap_field *pfdclk_sel_preg; 268 struct regmap_field *plllc1en_field; 269 struct regmap_field *termen_field; 270 struct clk_init_data clk_data; 271 }; 272 273 #define to_cdns_sierra_pll_mux(_hw) \ 274 container_of(_hw, struct cdns_sierra_pll_mux, hw) 275 276 static const int pll_mux_parent_index[][SIERRA_NUM_CMN_PLLC_PARENTS] = { 277 [CMN_PLLLC] = { PLL0_REFCLK, PLL1_REFCLK }, 278 [CMN_PLLLC1] = { PLL1_REFCLK, PLL0_REFCLK }, 279 }; 280 281 static u32 cdns_sierra_pll_mux_table[][SIERRA_NUM_CMN_PLLC_PARENTS] = { 282 [CMN_PLLLC] = { 0, 1 }, 283 [CMN_PLLLC1] = { 1, 0 }, 284 }; 285 286 struct cdns_sierra_derived_refclk { 287 struct clk_hw hw; 288 struct regmap_field *cmn_plllc_clk1outdiv_preg; 289 struct regmap_field *cmn_plllc_clk1_en_preg; 290 struct clk_init_data clk_data; 291 }; 292 293 #define to_cdns_sierra_derived_refclk(_hw) \ 294 container_of(_hw, struct cdns_sierra_derived_refclk, hw) 295 296 enum cdns_sierra_phy_type { 297 TYPE_NONE, 298 TYPE_PCIE, 299 TYPE_USB, 300 TYPE_QSGMII 301 }; 302 303 enum cdns_sierra_ssc_mode { 304 NO_SSC, 305 EXTERNAL_SSC, 306 INTERNAL_SSC 307 }; 308 309 struct cdns_sierra_inst { 310 struct phy *phy; 311 enum cdns_sierra_phy_type phy_type; 312 u32 num_lanes; 313 u32 mlane; 314 struct reset_control *lnk_rst; 315 enum cdns_sierra_ssc_mode ssc_mode; 316 }; 317 318 struct cdns_reg_pairs { 319 u16 val; 320 u32 off; 321 }; 322 323 struct cdns_sierra_vals { 324 const struct cdns_reg_pairs *reg_pairs; 325 u32 num_regs; 326 }; 327 328 struct cdns_sierra_data { 329 u32 id_value; 330 u8 block_offset_shift; 331 u8 reg_offset_shift; 332 struct cdns_sierra_vals *pcs_cmn_vals[NUM_PHY_TYPE][NUM_PHY_TYPE] 333 [NUM_SSC_MODE]; 334 struct cdns_sierra_vals *phy_pma_ln_vals[NUM_PHY_TYPE][NUM_PHY_TYPE] 335 [NUM_SSC_MODE]; 336 struct cdns_sierra_vals *pma_cmn_vals[NUM_PHY_TYPE][NUM_PHY_TYPE] 337 [NUM_SSC_MODE]; 338 struct cdns_sierra_vals *pma_ln_vals[NUM_PHY_TYPE][NUM_PHY_TYPE] 339 [NUM_SSC_MODE]; 340 }; 341 342 struct cdns_regmap_cdb_context { 343 struct device *dev; 344 void __iomem *base; 345 u8 reg_offset_shift; 346 }; 347 348 struct cdns_sierra_phy { 349 struct device *dev; 350 struct regmap *regmap; 351 const struct cdns_sierra_data *init_data; 352 struct cdns_sierra_inst phys[SIERRA_MAX_LANES]; 353 struct reset_control *phy_rst; 354 struct reset_control *apb_rst; 355 struct regmap *regmap_lane_cdb[SIERRA_MAX_LANES]; 356 struct regmap *regmap_phy_pcs_common_cdb; 357 struct regmap *regmap_phy_pcs_lane_cdb[SIERRA_MAX_LANES]; 358 struct regmap *regmap_phy_pma_common_cdb; 359 struct regmap *regmap_phy_pma_lane_cdb[SIERRA_MAX_LANES]; 360 struct regmap *regmap_common_cdb; 361 struct regmap_field *macro_id_type; 362 struct regmap_field *phy_pll_cfg_1; 363 struct regmap_field *pma_cmn_ready; 364 struct regmap_field *pllctrl_lock[SIERRA_MAX_LANES]; 365 struct regmap_field *phy_iso_link_ctrl_1[SIERRA_MAX_LANES]; 366 struct regmap_field *cmn_refrcv_refclk_plllc1en_preg[SIERRA_NUM_CMN_PLLC]; 367 struct regmap_field *cmn_refrcv_refclk_termen_preg[SIERRA_NUM_CMN_PLLC]; 368 struct regmap_field *cmn_plllc_pfdclk1_sel_preg[SIERRA_NUM_CMN_PLLC]; 369 struct clk *input_clks[CDNS_SIERRA_INPUT_CLOCKS]; 370 int nsubnodes; 371 u32 num_lanes; 372 bool autoconf; 373 int already_configured; 374 struct clk_onecell_data clk_data; 375 struct clk *output_clks[CDNS_SIERRA_OUTPUT_CLOCKS]; 376 }; 377 378 static int cdns_regmap_write(void *context, unsigned int reg, unsigned int val) 379 { 380 struct cdns_regmap_cdb_context *ctx = context; 381 u32 offset = reg << ctx->reg_offset_shift; 382 383 writew(val, ctx->base + offset); 384 385 return 0; 386 } 387 388 static int cdns_regmap_read(void *context, unsigned int reg, unsigned int *val) 389 { 390 struct cdns_regmap_cdb_context *ctx = context; 391 u32 offset = reg << ctx->reg_offset_shift; 392 393 *val = readw(ctx->base + offset); 394 return 0; 395 } 396 397 #define SIERRA_LANE_CDB_REGMAP_CONF(n) \ 398 { \ 399 .name = "sierra_lane" n "_cdb", \ 400 .reg_stride = 1, \ 401 .fast_io = true, \ 402 .reg_write = cdns_regmap_write, \ 403 .reg_read = cdns_regmap_read, \ 404 } 405 406 static const struct regmap_config cdns_sierra_lane_cdb_config[] = { 407 SIERRA_LANE_CDB_REGMAP_CONF("0"), 408 SIERRA_LANE_CDB_REGMAP_CONF("1"), 409 SIERRA_LANE_CDB_REGMAP_CONF("2"), 410 SIERRA_LANE_CDB_REGMAP_CONF("3"), 411 SIERRA_LANE_CDB_REGMAP_CONF("4"), 412 SIERRA_LANE_CDB_REGMAP_CONF("5"), 413 SIERRA_LANE_CDB_REGMAP_CONF("6"), 414 SIERRA_LANE_CDB_REGMAP_CONF("7"), 415 SIERRA_LANE_CDB_REGMAP_CONF("8"), 416 SIERRA_LANE_CDB_REGMAP_CONF("9"), 417 SIERRA_LANE_CDB_REGMAP_CONF("10"), 418 SIERRA_LANE_CDB_REGMAP_CONF("11"), 419 SIERRA_LANE_CDB_REGMAP_CONF("12"), 420 SIERRA_LANE_CDB_REGMAP_CONF("13"), 421 SIERRA_LANE_CDB_REGMAP_CONF("14"), 422 SIERRA_LANE_CDB_REGMAP_CONF("15"), 423 }; 424 425 static const struct regmap_config cdns_sierra_common_cdb_config = { 426 .name = "sierra_common_cdb", 427 .reg_stride = 1, 428 .fast_io = true, 429 .reg_write = cdns_regmap_write, 430 .reg_read = cdns_regmap_read, 431 }; 432 433 static const struct regmap_config cdns_sierra_phy_pcs_cmn_cdb_config = { 434 .name = "sierra_phy_pcs_cmn_cdb", 435 .reg_stride = 1, 436 .fast_io = true, 437 .reg_write = cdns_regmap_write, 438 .reg_read = cdns_regmap_read, 439 }; 440 441 #define SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF(n) \ 442 { \ 443 .name = "sierra_phy_pcs_lane" n "_cdb", \ 444 .reg_stride = 1, \ 445 .fast_io = true, \ 446 .reg_write = cdns_regmap_write, \ 447 .reg_read = cdns_regmap_read, \ 448 } 449 450 static const struct regmap_config cdns_sierra_phy_pcs_lane_cdb_config[] = { 451 SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("0"), 452 SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("1"), 453 SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("2"), 454 SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("3"), 455 SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("4"), 456 SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("5"), 457 SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("6"), 458 SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("7"), 459 SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("8"), 460 SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("9"), 461 SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("10"), 462 SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("11"), 463 SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("12"), 464 SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("13"), 465 SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("14"), 466 SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("15"), 467 }; 468 469 static const struct regmap_config cdns_sierra_phy_pma_cmn_cdb_config = { 470 .name = "sierra_phy_pma_cmn_cdb", 471 .reg_stride = 1, 472 .fast_io = true, 473 .reg_write = cdns_regmap_write, 474 .reg_read = cdns_regmap_read, 475 }; 476 477 #define SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF(n) \ 478 { \ 479 .name = "sierra_phy_pma_lane" n "_cdb", \ 480 .reg_stride = 1, \ 481 .fast_io = true, \ 482 .reg_write = cdns_regmap_write, \ 483 .reg_read = cdns_regmap_read, \ 484 } 485 486 static const struct regmap_config cdns_sierra_phy_pma_lane_cdb_config[] = { 487 SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("0"), 488 SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("1"), 489 SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("2"), 490 SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("3"), 491 SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("4"), 492 SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("5"), 493 SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("6"), 494 SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("7"), 495 SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("8"), 496 SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("9"), 497 SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("10"), 498 SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("11"), 499 SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("12"), 500 SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("13"), 501 SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("14"), 502 SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("15"), 503 }; 504 505 static int cdns_sierra_phy_init(struct phy *gphy) 506 { 507 struct cdns_sierra_inst *ins = phy_get_drvdata(gphy); 508 struct cdns_sierra_phy *phy = dev_get_drvdata(gphy->dev.parent); 509 const struct cdns_sierra_data *init_data = phy->init_data; 510 struct cdns_sierra_vals *pma_cmn_vals, *pma_ln_vals; 511 enum cdns_sierra_phy_type phy_type = ins->phy_type; 512 enum cdns_sierra_ssc_mode ssc = ins->ssc_mode; 513 struct cdns_sierra_vals *phy_pma_ln_vals; 514 const struct cdns_reg_pairs *reg_pairs; 515 struct cdns_sierra_vals *pcs_cmn_vals; 516 struct regmap *regmap; 517 u32 num_regs; 518 int i, j; 519 520 /* Initialise the PHY registers, unless auto configured */ 521 if (phy->autoconf || phy->already_configured || phy->nsubnodes > 1) 522 return 0; 523 524 clk_set_rate(phy->input_clks[CMN_REFCLK_DIG_DIV], 25000000); 525 clk_set_rate(phy->input_clks[CMN_REFCLK1_DIG_DIV], 25000000); 526 527 /* PHY PCS common registers configurations */ 528 pcs_cmn_vals = init_data->pcs_cmn_vals[phy_type][TYPE_NONE][ssc]; 529 if (pcs_cmn_vals) { 530 reg_pairs = pcs_cmn_vals->reg_pairs; 531 num_regs = pcs_cmn_vals->num_regs; 532 regmap = phy->regmap_phy_pcs_common_cdb; 533 for (i = 0; i < num_regs; i++) 534 regmap_write(regmap, reg_pairs[i].off, reg_pairs[i].val); 535 } 536 537 /* PHY PMA lane registers configurations */ 538 phy_pma_ln_vals = init_data->phy_pma_ln_vals[phy_type][TYPE_NONE][ssc]; 539 if (phy_pma_ln_vals) { 540 reg_pairs = phy_pma_ln_vals->reg_pairs; 541 num_regs = phy_pma_ln_vals->num_regs; 542 for (i = 0; i < ins->num_lanes; i++) { 543 regmap = phy->regmap_phy_pma_lane_cdb[i + ins->mlane]; 544 for (j = 0; j < num_regs; j++) 545 regmap_write(regmap, reg_pairs[j].off, reg_pairs[j].val); 546 } 547 } 548 549 /* PMA common registers configurations */ 550 pma_cmn_vals = init_data->pma_cmn_vals[phy_type][TYPE_NONE][ssc]; 551 if (pma_cmn_vals) { 552 reg_pairs = pma_cmn_vals->reg_pairs; 553 num_regs = pma_cmn_vals->num_regs; 554 regmap = phy->regmap_common_cdb; 555 for (i = 0; i < num_regs; i++) 556 regmap_write(regmap, reg_pairs[i].off, reg_pairs[i].val); 557 } 558 559 /* PMA lane registers configurations */ 560 pma_ln_vals = init_data->pma_ln_vals[phy_type][TYPE_NONE][ssc]; 561 if (pma_ln_vals) { 562 reg_pairs = pma_ln_vals->reg_pairs; 563 num_regs = pma_ln_vals->num_regs; 564 for (i = 0; i < ins->num_lanes; i++) { 565 regmap = phy->regmap_lane_cdb[i + ins->mlane]; 566 for (j = 0; j < num_regs; j++) 567 regmap_write(regmap, reg_pairs[j].off, reg_pairs[j].val); 568 } 569 } 570 571 return 0; 572 } 573 574 static int cdns_sierra_phy_on(struct phy *gphy) 575 { 576 struct cdns_sierra_phy *sp = dev_get_drvdata(gphy->dev.parent); 577 struct cdns_sierra_inst *ins = phy_get_drvdata(gphy); 578 struct device *dev = sp->dev; 579 u32 val; 580 int ret; 581 582 if (sp->nsubnodes == 1) { 583 /* Take the PHY out of reset */ 584 ret = reset_control_deassert(sp->phy_rst); 585 if (ret) { 586 dev_err(dev, "Failed to take the PHY out of reset\n"); 587 return ret; 588 } 589 } 590 591 /* Take the PHY lane group out of reset */ 592 ret = reset_control_deassert(ins->lnk_rst); 593 if (ret) { 594 dev_err(dev, "Failed to take the PHY lane out of reset\n"); 595 return ret; 596 } 597 598 if (ins->phy_type == TYPE_PCIE || ins->phy_type == TYPE_USB) { 599 ret = regmap_field_read_poll_timeout(sp->phy_iso_link_ctrl_1[ins->mlane], 600 val, !val, 1000, PLL_LOCK_TIME); 601 if (ret) { 602 dev_err(dev, "Timeout waiting for PHY status ready\n"); 603 return ret; 604 } 605 } 606 607 /* 608 * Wait for cmn_ready assertion 609 * PHY_PMA_CMN_CTRL[0] == 1 610 */ 611 ret = regmap_field_read_poll_timeout(sp->pma_cmn_ready, val, val, 612 1000, PLL_LOCK_TIME); 613 if (ret) { 614 dev_err(dev, "Timeout waiting for CMN ready\n"); 615 return ret; 616 } 617 618 ret = regmap_field_read_poll_timeout(sp->pllctrl_lock[ins->mlane], 619 val, val, 1000, PLL_LOCK_TIME); 620 if (ret < 0) 621 dev_err(dev, "PLL lock of lane failed\n"); 622 623 return ret; 624 } 625 626 static int cdns_sierra_phy_off(struct phy *gphy) 627 { 628 struct cdns_sierra_inst *ins = phy_get_drvdata(gphy); 629 630 return reset_control_assert(ins->lnk_rst); 631 } 632 633 static int cdns_sierra_phy_reset(struct phy *gphy) 634 { 635 struct cdns_sierra_phy *sp = dev_get_drvdata(gphy->dev.parent); 636 637 reset_control_assert(sp->phy_rst); 638 reset_control_deassert(sp->phy_rst); 639 return 0; 640 }; 641 642 static const struct phy_ops ops = { 643 .init = cdns_sierra_phy_init, 644 .power_on = cdns_sierra_phy_on, 645 .power_off = cdns_sierra_phy_off, 646 .reset = cdns_sierra_phy_reset, 647 .owner = THIS_MODULE, 648 }; 649 650 static int cdns_sierra_noop_phy_on(struct phy *gphy) 651 { 652 usleep_range(5000, 10000); 653 654 return 0; 655 } 656 657 static const struct phy_ops noop_ops = { 658 .power_on = cdns_sierra_noop_phy_on, 659 .owner = THIS_MODULE, 660 }; 661 662 static u8 cdns_sierra_pll_mux_get_parent(struct clk_hw *hw) 663 { 664 struct cdns_sierra_pll_mux *mux = to_cdns_sierra_pll_mux(hw); 665 struct regmap_field *plllc1en_field = mux->plllc1en_field; 666 struct regmap_field *termen_field = mux->termen_field; 667 struct regmap_field *field = mux->pfdclk_sel_preg; 668 unsigned int val; 669 int index; 670 671 regmap_field_read(field, &val); 672 673 if (strstr(clk_hw_get_name(hw), clk_names[CDNS_SIERRA_PLL_CMNLC1])) { 674 index = clk_mux_val_to_index(hw, cdns_sierra_pll_mux_table[CMN_PLLLC1], 0, val); 675 if (index == 1) { 676 regmap_field_write(plllc1en_field, 1); 677 regmap_field_write(termen_field, 1); 678 } 679 } else { 680 index = clk_mux_val_to_index(hw, cdns_sierra_pll_mux_table[CMN_PLLLC], 0, val); 681 } 682 683 return index; 684 } 685 686 static int cdns_sierra_pll_mux_set_parent(struct clk_hw *hw, u8 index) 687 { 688 struct cdns_sierra_pll_mux *mux = to_cdns_sierra_pll_mux(hw); 689 struct regmap_field *plllc1en_field = mux->plllc1en_field; 690 struct regmap_field *termen_field = mux->termen_field; 691 struct regmap_field *field = mux->pfdclk_sel_preg; 692 int val, ret; 693 694 ret = regmap_field_write(plllc1en_field, 0); 695 ret |= regmap_field_write(termen_field, 0); 696 if (index == 1) { 697 ret |= regmap_field_write(plllc1en_field, 1); 698 ret |= regmap_field_write(termen_field, 1); 699 } 700 701 if (strstr(clk_hw_get_name(hw), clk_names[CDNS_SIERRA_PLL_CMNLC1])) 702 val = cdns_sierra_pll_mux_table[CMN_PLLLC1][index]; 703 else 704 val = cdns_sierra_pll_mux_table[CMN_PLLLC][index]; 705 706 ret |= regmap_field_write(field, val); 707 708 return ret; 709 } 710 711 static const struct clk_ops cdns_sierra_pll_mux_ops = { 712 .set_parent = cdns_sierra_pll_mux_set_parent, 713 .get_parent = cdns_sierra_pll_mux_get_parent, 714 }; 715 716 static int cdns_sierra_pll_mux_register(struct cdns_sierra_phy *sp, 717 struct regmap_field *pfdclk1_sel_field, 718 struct regmap_field *plllc1en_field, 719 struct regmap_field *termen_field, 720 int clk_index) 721 { 722 struct cdns_sierra_pll_mux *mux; 723 struct device *dev = sp->dev; 724 struct clk_init_data *init; 725 const char **parent_names; 726 unsigned int num_parents; 727 char clk_name[100]; 728 struct clk *clk; 729 int i; 730 731 mux = devm_kzalloc(dev, sizeof(*mux), GFP_KERNEL); 732 if (!mux) 733 return -ENOMEM; 734 735 num_parents = SIERRA_NUM_CMN_PLLC_PARENTS; 736 parent_names = devm_kzalloc(dev, (sizeof(char *) * num_parents), GFP_KERNEL); 737 if (!parent_names) 738 return -ENOMEM; 739 740 for (i = 0; i < num_parents; i++) { 741 clk = sp->input_clks[pll_mux_parent_index[clk_index][i]]; 742 if (IS_ERR_OR_NULL(clk)) { 743 dev_err(dev, "No parent clock for PLL mux clocks\n"); 744 return IS_ERR(clk) ? PTR_ERR(clk) : -ENOENT; 745 } 746 parent_names[i] = __clk_get_name(clk); 747 } 748 749 snprintf(clk_name, sizeof(clk_name), "%s_%s", dev_name(dev), clk_names[clk_index]); 750 751 init = &mux->clk_data; 752 753 init->ops = &cdns_sierra_pll_mux_ops; 754 init->flags = CLK_SET_RATE_NO_REPARENT; 755 init->parent_names = parent_names; 756 init->num_parents = num_parents; 757 init->name = clk_name; 758 759 mux->pfdclk_sel_preg = pfdclk1_sel_field; 760 mux->plllc1en_field = plllc1en_field; 761 mux->termen_field = termen_field; 762 mux->hw.init = init; 763 764 clk = devm_clk_register(dev, &mux->hw); 765 if (IS_ERR(clk)) 766 return PTR_ERR(clk); 767 768 sp->output_clks[clk_index] = clk; 769 770 return 0; 771 } 772 773 static int cdns_sierra_phy_register_pll_mux(struct cdns_sierra_phy *sp) 774 { 775 struct regmap_field *pfdclk1_sel_field; 776 struct regmap_field *plllc1en_field; 777 struct regmap_field *termen_field; 778 struct device *dev = sp->dev; 779 int ret = 0, i, clk_index; 780 781 clk_index = CDNS_SIERRA_PLL_CMNLC; 782 for (i = 0; i < SIERRA_NUM_CMN_PLLC; i++, clk_index++) { 783 pfdclk1_sel_field = sp->cmn_plllc_pfdclk1_sel_preg[i]; 784 plllc1en_field = sp->cmn_refrcv_refclk_plllc1en_preg[i]; 785 termen_field = sp->cmn_refrcv_refclk_termen_preg[i]; 786 787 ret = cdns_sierra_pll_mux_register(sp, pfdclk1_sel_field, plllc1en_field, 788 termen_field, clk_index); 789 if (ret) { 790 dev_err(dev, "Fail to register cmn plllc mux\n"); 791 return ret; 792 } 793 } 794 795 return 0; 796 } 797 798 static int cdns_sierra_derived_refclk_enable(struct clk_hw *hw) 799 { 800 struct cdns_sierra_derived_refclk *derived_refclk = to_cdns_sierra_derived_refclk(hw); 801 802 regmap_field_write(derived_refclk->cmn_plllc_clk1_en_preg, 0x1); 803 804 /* Programming to get 100Mhz clock output in ref_der_clk_out 5GHz VCO/50 = 100MHz */ 805 regmap_field_write(derived_refclk->cmn_plllc_clk1outdiv_preg, 0x2E); 806 807 return 0; 808 } 809 810 static void cdns_sierra_derived_refclk_disable(struct clk_hw *hw) 811 { 812 struct cdns_sierra_derived_refclk *derived_refclk = to_cdns_sierra_derived_refclk(hw); 813 814 regmap_field_write(derived_refclk->cmn_plllc_clk1_en_preg, 0); 815 } 816 817 static int cdns_sierra_derived_refclk_is_enabled(struct clk_hw *hw) 818 { 819 struct cdns_sierra_derived_refclk *derived_refclk = to_cdns_sierra_derived_refclk(hw); 820 int val; 821 822 regmap_field_read(derived_refclk->cmn_plllc_clk1_en_preg, &val); 823 824 return !!val; 825 } 826 827 static const struct clk_ops cdns_sierra_derived_refclk_ops = { 828 .enable = cdns_sierra_derived_refclk_enable, 829 .disable = cdns_sierra_derived_refclk_disable, 830 .is_enabled = cdns_sierra_derived_refclk_is_enabled, 831 }; 832 833 static int cdns_sierra_derived_refclk_register(struct cdns_sierra_phy *sp) 834 { 835 struct cdns_sierra_derived_refclk *derived_refclk; 836 struct device *dev = sp->dev; 837 struct regmap_field *field; 838 struct clk_init_data *init; 839 struct regmap *regmap; 840 char clk_name[100]; 841 struct clk *clk; 842 843 derived_refclk = devm_kzalloc(dev, sizeof(*derived_refclk), GFP_KERNEL); 844 if (!derived_refclk) 845 return -ENOMEM; 846 847 snprintf(clk_name, sizeof(clk_name), "%s_%s", dev_name(dev), 848 clk_names[CDNS_SIERRA_DERIVED_REFCLK]); 849 850 init = &derived_refclk->clk_data; 851 852 init->ops = &cdns_sierra_derived_refclk_ops; 853 init->flags = 0; 854 init->name = clk_name; 855 856 regmap = sp->regmap_common_cdb; 857 858 field = devm_regmap_field_alloc(dev, regmap, cmn_plllc_clk1outdiv_preg); 859 if (IS_ERR(field)) { 860 dev_err(dev, "cmn_plllc_clk1outdiv_preg reg field init failed\n"); 861 return PTR_ERR(field); 862 } 863 derived_refclk->cmn_plllc_clk1outdiv_preg = field; 864 865 field = devm_regmap_field_alloc(dev, regmap, cmn_plllc_clk1_en_preg); 866 if (IS_ERR(field)) { 867 dev_err(dev, "cmn_plllc_clk1_en_preg reg field init failed\n"); 868 return PTR_ERR(field); 869 } 870 derived_refclk->cmn_plllc_clk1_en_preg = field; 871 872 derived_refclk->hw.init = init; 873 874 clk = devm_clk_register(dev, &derived_refclk->hw); 875 if (IS_ERR(clk)) 876 return PTR_ERR(clk); 877 878 sp->output_clks[CDNS_SIERRA_DERIVED_REFCLK] = clk; 879 880 return 0; 881 } 882 883 static void cdns_sierra_clk_unregister(struct cdns_sierra_phy *sp) 884 { 885 struct device *dev = sp->dev; 886 struct device_node *node = dev->of_node; 887 888 of_clk_del_provider(node); 889 } 890 891 static int cdns_sierra_clk_register(struct cdns_sierra_phy *sp) 892 { 893 struct device *dev = sp->dev; 894 struct device_node *node = dev->of_node; 895 int ret; 896 897 ret = cdns_sierra_phy_register_pll_mux(sp); 898 if (ret) { 899 dev_err(dev, "Failed to pll mux clocks\n"); 900 return ret; 901 } 902 903 ret = cdns_sierra_derived_refclk_register(sp); 904 if (ret) { 905 dev_err(dev, "Failed to register derived refclk\n"); 906 return ret; 907 } 908 909 sp->clk_data.clks = sp->output_clks; 910 sp->clk_data.clk_num = CDNS_SIERRA_OUTPUT_CLOCKS; 911 ret = of_clk_add_provider(node, of_clk_src_onecell_get, &sp->clk_data); 912 if (ret) 913 dev_err(dev, "Failed to add clock provider: %s\n", node->name); 914 915 return ret; 916 } 917 918 static int cdns_sierra_get_optional(struct cdns_sierra_inst *inst, 919 struct device_node *child) 920 { 921 u32 phy_type; 922 923 if (of_property_read_u32(child, "reg", &inst->mlane)) 924 return -EINVAL; 925 926 if (of_property_read_u32(child, "cdns,num-lanes", &inst->num_lanes)) 927 return -EINVAL; 928 929 if (of_property_read_u32(child, "cdns,phy-type", &phy_type)) 930 return -EINVAL; 931 932 switch (phy_type) { 933 case PHY_TYPE_PCIE: 934 inst->phy_type = TYPE_PCIE; 935 break; 936 case PHY_TYPE_USB3: 937 inst->phy_type = TYPE_USB; 938 break; 939 case PHY_TYPE_QSGMII: 940 inst->phy_type = TYPE_QSGMII; 941 break; 942 default: 943 return -EINVAL; 944 } 945 946 inst->ssc_mode = EXTERNAL_SSC; 947 of_property_read_u32(child, "cdns,ssc-mode", &inst->ssc_mode); 948 949 return 0; 950 } 951 952 static struct regmap *cdns_regmap_init(struct device *dev, void __iomem *base, 953 u32 block_offset, u8 reg_offset_shift, 954 const struct regmap_config *config) 955 { 956 struct cdns_regmap_cdb_context *ctx; 957 958 ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL); 959 if (!ctx) 960 return ERR_PTR(-ENOMEM); 961 962 ctx->dev = dev; 963 ctx->base = base + block_offset; 964 ctx->reg_offset_shift = reg_offset_shift; 965 966 return devm_regmap_init(dev, NULL, ctx, config); 967 } 968 969 static int cdns_regfield_init(struct cdns_sierra_phy *sp) 970 { 971 struct device *dev = sp->dev; 972 struct regmap_field *field; 973 struct reg_field reg_field; 974 struct regmap *regmap; 975 int i; 976 977 regmap = sp->regmap_common_cdb; 978 field = devm_regmap_field_alloc(dev, regmap, macro_id_type); 979 if (IS_ERR(field)) { 980 dev_err(dev, "MACRO_ID_TYPE reg field init failed\n"); 981 return PTR_ERR(field); 982 } 983 sp->macro_id_type = field; 984 985 for (i = 0; i < SIERRA_NUM_CMN_PLLC; i++) { 986 reg_field = cmn_plllc_pfdclk1_sel_preg[i].pfdclk_sel_preg; 987 field = devm_regmap_field_alloc(dev, regmap, reg_field); 988 if (IS_ERR(field)) { 989 dev_err(dev, "PLLLC%d_PFDCLK1_SEL failed\n", i); 990 return PTR_ERR(field); 991 } 992 sp->cmn_plllc_pfdclk1_sel_preg[i] = field; 993 994 reg_field = cmn_plllc_pfdclk1_sel_preg[i].plllc1en_field; 995 field = devm_regmap_field_alloc(dev, regmap, reg_field); 996 if (IS_ERR(field)) { 997 dev_err(dev, "REFRCV%d_REFCLK_PLLLC1EN failed\n", i); 998 return PTR_ERR(field); 999 } 1000 sp->cmn_refrcv_refclk_plllc1en_preg[i] = field; 1001 1002 reg_field = cmn_plllc_pfdclk1_sel_preg[i].termen_field; 1003 field = devm_regmap_field_alloc(dev, regmap, reg_field); 1004 if (IS_ERR(field)) { 1005 dev_err(dev, "REFRCV%d_REFCLK_TERMEN failed\n", i); 1006 return PTR_ERR(field); 1007 } 1008 sp->cmn_refrcv_refclk_termen_preg[i] = field; 1009 } 1010 1011 regmap = sp->regmap_phy_pcs_common_cdb; 1012 field = devm_regmap_field_alloc(dev, regmap, phy_pll_cfg_1); 1013 if (IS_ERR(field)) { 1014 dev_err(dev, "PHY_PLL_CFG_1 reg field init failed\n"); 1015 return PTR_ERR(field); 1016 } 1017 sp->phy_pll_cfg_1 = field; 1018 1019 regmap = sp->regmap_phy_pma_common_cdb; 1020 field = devm_regmap_field_alloc(dev, regmap, pma_cmn_ready); 1021 if (IS_ERR(field)) { 1022 dev_err(dev, "PHY_PMA_CMN_CTRL reg field init failed\n"); 1023 return PTR_ERR(field); 1024 } 1025 sp->pma_cmn_ready = field; 1026 1027 for (i = 0; i < SIERRA_MAX_LANES; i++) { 1028 regmap = sp->regmap_lane_cdb[i]; 1029 field = devm_regmap_field_alloc(dev, regmap, pllctrl_lock); 1030 if (IS_ERR(field)) { 1031 dev_err(dev, "P%d_ENABLE reg field init failed\n", i); 1032 return PTR_ERR(field); 1033 } 1034 sp->pllctrl_lock[i] = field; 1035 } 1036 1037 for (i = 0; i < SIERRA_MAX_LANES; i++) { 1038 regmap = sp->regmap_phy_pcs_lane_cdb[i]; 1039 field = devm_regmap_field_alloc(dev, regmap, phy_iso_link_ctrl_1); 1040 if (IS_ERR(field)) { 1041 dev_err(dev, "PHY_ISO_LINK_CTRL reg field init for lane %d failed\n", i); 1042 return PTR_ERR(field); 1043 } 1044 sp->phy_iso_link_ctrl_1[i] = field; 1045 } 1046 1047 return 0; 1048 } 1049 1050 static int cdns_regmap_init_blocks(struct cdns_sierra_phy *sp, 1051 void __iomem *base, u8 block_offset_shift, 1052 u8 reg_offset_shift) 1053 { 1054 struct device *dev = sp->dev; 1055 struct regmap *regmap; 1056 u32 block_offset; 1057 int i; 1058 1059 for (i = 0; i < SIERRA_MAX_LANES; i++) { 1060 block_offset = SIERRA_LANE_CDB_OFFSET(i, block_offset_shift, 1061 reg_offset_shift); 1062 regmap = cdns_regmap_init(dev, base, block_offset, 1063 reg_offset_shift, 1064 &cdns_sierra_lane_cdb_config[i]); 1065 if (IS_ERR(regmap)) { 1066 dev_err(dev, "Failed to init lane CDB regmap\n"); 1067 return PTR_ERR(regmap); 1068 } 1069 sp->regmap_lane_cdb[i] = regmap; 1070 } 1071 1072 regmap = cdns_regmap_init(dev, base, SIERRA_COMMON_CDB_OFFSET, 1073 reg_offset_shift, 1074 &cdns_sierra_common_cdb_config); 1075 if (IS_ERR(regmap)) { 1076 dev_err(dev, "Failed to init common CDB regmap\n"); 1077 return PTR_ERR(regmap); 1078 } 1079 sp->regmap_common_cdb = regmap; 1080 1081 block_offset = SIERRA_PHY_PCS_COMMON_OFFSET(block_offset_shift); 1082 regmap = cdns_regmap_init(dev, base, block_offset, reg_offset_shift, 1083 &cdns_sierra_phy_pcs_cmn_cdb_config); 1084 if (IS_ERR(regmap)) { 1085 dev_err(dev, "Failed to init PHY PCS common CDB regmap\n"); 1086 return PTR_ERR(regmap); 1087 } 1088 sp->regmap_phy_pcs_common_cdb = regmap; 1089 1090 for (i = 0; i < SIERRA_MAX_LANES; i++) { 1091 block_offset = SIERRA_PHY_PCS_LANE_CDB_OFFSET(i, block_offset_shift, 1092 reg_offset_shift); 1093 regmap = cdns_regmap_init(dev, base, block_offset, 1094 reg_offset_shift, 1095 &cdns_sierra_phy_pcs_lane_cdb_config[i]); 1096 if (IS_ERR(regmap)) { 1097 dev_err(dev, "Failed to init PHY PCS lane CDB regmap\n"); 1098 return PTR_ERR(regmap); 1099 } 1100 sp->regmap_phy_pcs_lane_cdb[i] = regmap; 1101 } 1102 1103 block_offset = SIERRA_PHY_PMA_COMMON_OFFSET(block_offset_shift); 1104 regmap = cdns_regmap_init(dev, base, block_offset, reg_offset_shift, 1105 &cdns_sierra_phy_pma_cmn_cdb_config); 1106 if (IS_ERR(regmap)) { 1107 dev_err(dev, "Failed to init PHY PMA common CDB regmap\n"); 1108 return PTR_ERR(regmap); 1109 } 1110 sp->regmap_phy_pma_common_cdb = regmap; 1111 1112 for (i = 0; i < SIERRA_MAX_LANES; i++) { 1113 block_offset = SIERRA_PHY_PMA_LANE_CDB_OFFSET(i, block_offset_shift, 1114 reg_offset_shift); 1115 regmap = cdns_regmap_init(dev, base, block_offset, 1116 reg_offset_shift, 1117 &cdns_sierra_phy_pma_lane_cdb_config[i]); 1118 if (IS_ERR(regmap)) { 1119 dev_err(dev, "Failed to init PHY PMA lane CDB regmap\n"); 1120 return PTR_ERR(regmap); 1121 } 1122 sp->regmap_phy_pma_lane_cdb[i] = regmap; 1123 } 1124 1125 return 0; 1126 } 1127 1128 static int cdns_sierra_phy_get_clocks(struct cdns_sierra_phy *sp, 1129 struct device *dev) 1130 { 1131 struct clk *clk; 1132 int ret; 1133 1134 clk = devm_clk_get_optional(dev, "cmn_refclk_dig_div"); 1135 if (IS_ERR(clk)) { 1136 dev_err(dev, "cmn_refclk_dig_div clock not found\n"); 1137 ret = PTR_ERR(clk); 1138 return ret; 1139 } 1140 sp->input_clks[CMN_REFCLK_DIG_DIV] = clk; 1141 1142 clk = devm_clk_get_optional(dev, "cmn_refclk1_dig_div"); 1143 if (IS_ERR(clk)) { 1144 dev_err(dev, "cmn_refclk1_dig_div clock not found\n"); 1145 ret = PTR_ERR(clk); 1146 return ret; 1147 } 1148 sp->input_clks[CMN_REFCLK1_DIG_DIV] = clk; 1149 1150 clk = devm_clk_get_optional(dev, "pll0_refclk"); 1151 if (IS_ERR(clk)) { 1152 dev_err(dev, "pll0_refclk clock not found\n"); 1153 ret = PTR_ERR(clk); 1154 return ret; 1155 } 1156 sp->input_clks[PLL0_REFCLK] = clk; 1157 1158 clk = devm_clk_get_optional(dev, "pll1_refclk"); 1159 if (IS_ERR(clk)) { 1160 dev_err(dev, "pll1_refclk clock not found\n"); 1161 ret = PTR_ERR(clk); 1162 return ret; 1163 } 1164 sp->input_clks[PLL1_REFCLK] = clk; 1165 1166 return 0; 1167 } 1168 1169 static int cdns_sierra_phy_clk(struct cdns_sierra_phy *sp) 1170 { 1171 struct device *dev = sp->dev; 1172 struct clk *clk; 1173 int ret; 1174 1175 clk = devm_clk_get_optional(dev, "phy_clk"); 1176 if (IS_ERR(clk)) { 1177 dev_err(dev, "failed to get clock phy_clk\n"); 1178 return PTR_ERR(clk); 1179 } 1180 sp->input_clks[PHY_CLK] = clk; 1181 1182 ret = clk_prepare_enable(sp->input_clks[PHY_CLK]); 1183 if (ret) 1184 return ret; 1185 1186 return 0; 1187 } 1188 1189 static int cdns_sierra_phy_enable_clocks(struct cdns_sierra_phy *sp) 1190 { 1191 int ret; 1192 1193 ret = clk_prepare_enable(sp->output_clks[CDNS_SIERRA_PLL_CMNLC]); 1194 if (ret) 1195 return ret; 1196 1197 ret = clk_prepare_enable(sp->output_clks[CDNS_SIERRA_PLL_CMNLC1]); 1198 if (ret) 1199 goto err_pll_cmnlc1; 1200 1201 return 0; 1202 1203 err_pll_cmnlc1: 1204 clk_disable_unprepare(sp->output_clks[CDNS_SIERRA_PLL_CMNLC]); 1205 1206 return ret; 1207 } 1208 1209 static void cdns_sierra_phy_disable_clocks(struct cdns_sierra_phy *sp) 1210 { 1211 clk_disable_unprepare(sp->output_clks[CDNS_SIERRA_PLL_CMNLC1]); 1212 clk_disable_unprepare(sp->output_clks[CDNS_SIERRA_PLL_CMNLC]); 1213 if (!sp->already_configured) 1214 clk_disable_unprepare(sp->input_clks[PHY_CLK]); 1215 } 1216 1217 static int cdns_sierra_phy_get_resets(struct cdns_sierra_phy *sp, 1218 struct device *dev) 1219 { 1220 struct reset_control *rst; 1221 1222 rst = devm_reset_control_get_exclusive(dev, "sierra_reset"); 1223 if (IS_ERR(rst)) { 1224 dev_err(dev, "failed to get reset\n"); 1225 return PTR_ERR(rst); 1226 } 1227 sp->phy_rst = rst; 1228 1229 rst = devm_reset_control_get_optional_exclusive(dev, "sierra_apb"); 1230 if (IS_ERR(rst)) { 1231 dev_err(dev, "failed to get apb reset\n"); 1232 return PTR_ERR(rst); 1233 } 1234 sp->apb_rst = rst; 1235 1236 return 0; 1237 } 1238 1239 static int cdns_sierra_phy_configure_multilink(struct cdns_sierra_phy *sp) 1240 { 1241 const struct cdns_sierra_data *init_data = sp->init_data; 1242 struct cdns_sierra_vals *pma_cmn_vals, *pma_ln_vals; 1243 enum cdns_sierra_phy_type phy_t1, phy_t2; 1244 struct cdns_sierra_vals *phy_pma_ln_vals; 1245 const struct cdns_reg_pairs *reg_pairs; 1246 struct cdns_sierra_vals *pcs_cmn_vals; 1247 int i, j, node, mlane, num_lanes, ret; 1248 enum cdns_sierra_ssc_mode ssc; 1249 struct regmap *regmap; 1250 u32 num_regs; 1251 1252 /* Maximum 2 links (subnodes) are supported */ 1253 if (sp->nsubnodes != 2) 1254 return -EINVAL; 1255 1256 clk_set_rate(sp->input_clks[CMN_REFCLK_DIG_DIV], 25000000); 1257 clk_set_rate(sp->input_clks[CMN_REFCLK1_DIG_DIV], 25000000); 1258 1259 /* PHY configured to use both PLL LC and LC1 */ 1260 regmap_field_write(sp->phy_pll_cfg_1, 0x1); 1261 1262 phy_t1 = sp->phys[0].phy_type; 1263 phy_t2 = sp->phys[1].phy_type; 1264 1265 /* 1266 * PHY configuration for multi-link operation is done in two steps. 1267 * e.g. Consider a case for a 4 lane PHY with PCIe using 2 lanes and QSGMII other 2 lanes. 1268 * Sierra PHY has 2 PLLs, viz. PLLLC and PLLLC1. So in this case, PLLLC is used for PCIe 1269 * and PLLLC1 is used for QSGMII. PHY is configured in two steps as described below. 1270 * 1271 * [1] For first step, phy_t1 = TYPE_PCIE and phy_t2 = TYPE_QSGMII 1272 * So the register values are selected as [TYPE_PCIE][TYPE_QSGMII][ssc]. 1273 * This will configure PHY registers associated for PCIe (i.e. first protocol) 1274 * involving PLLLC registers and registers for first 2 lanes of PHY. 1275 * [2] In second step, the variables phy_t1 and phy_t2 are swapped. So now, 1276 * phy_t1 = TYPE_QSGMII and phy_t2 = TYPE_PCIE. And the register values are selected as 1277 * [TYPE_QSGMII][TYPE_PCIE][ssc]. 1278 * This will configure PHY registers associated for QSGMII (i.e. second protocol) 1279 * involving PLLLC1 registers and registers for other 2 lanes of PHY. 1280 * 1281 * This completes the PHY configuration for multilink operation. This approach enables 1282 * dividing the large number of PHY register configurations into protocol specific 1283 * smaller groups. 1284 */ 1285 for (node = 0; node < sp->nsubnodes; node++) { 1286 if (node == 1) { 1287 /* 1288 * If first link with phy_t1 is configured, then configure the PHY for 1289 * second link with phy_t2. Get the array values as [phy_t2][phy_t1][ssc]. 1290 */ 1291 swap(phy_t1, phy_t2); 1292 } 1293 1294 mlane = sp->phys[node].mlane; 1295 ssc = sp->phys[node].ssc_mode; 1296 num_lanes = sp->phys[node].num_lanes; 1297 1298 /* PHY PCS common registers configurations */ 1299 pcs_cmn_vals = init_data->pcs_cmn_vals[phy_t1][phy_t2][ssc]; 1300 if (pcs_cmn_vals) { 1301 reg_pairs = pcs_cmn_vals->reg_pairs; 1302 num_regs = pcs_cmn_vals->num_regs; 1303 regmap = sp->regmap_phy_pcs_common_cdb; 1304 for (i = 0; i < num_regs; i++) 1305 regmap_write(regmap, reg_pairs[i].off, reg_pairs[i].val); 1306 } 1307 1308 /* PHY PMA lane registers configurations */ 1309 phy_pma_ln_vals = init_data->phy_pma_ln_vals[phy_t1][phy_t2][ssc]; 1310 if (phy_pma_ln_vals) { 1311 reg_pairs = phy_pma_ln_vals->reg_pairs; 1312 num_regs = phy_pma_ln_vals->num_regs; 1313 for (i = 0; i < num_lanes; i++) { 1314 regmap = sp->regmap_phy_pma_lane_cdb[i + mlane]; 1315 for (j = 0; j < num_regs; j++) 1316 regmap_write(regmap, reg_pairs[j].off, reg_pairs[j].val); 1317 } 1318 } 1319 1320 /* PMA common registers configurations */ 1321 pma_cmn_vals = init_data->pma_cmn_vals[phy_t1][phy_t2][ssc]; 1322 if (pma_cmn_vals) { 1323 reg_pairs = pma_cmn_vals->reg_pairs; 1324 num_regs = pma_cmn_vals->num_regs; 1325 regmap = sp->regmap_common_cdb; 1326 for (i = 0; i < num_regs; i++) 1327 regmap_write(regmap, reg_pairs[i].off, reg_pairs[i].val); 1328 } 1329 1330 /* PMA lane registers configurations */ 1331 pma_ln_vals = init_data->pma_ln_vals[phy_t1][phy_t2][ssc]; 1332 if (pma_ln_vals) { 1333 reg_pairs = pma_ln_vals->reg_pairs; 1334 num_regs = pma_ln_vals->num_regs; 1335 for (i = 0; i < num_lanes; i++) { 1336 regmap = sp->regmap_lane_cdb[i + mlane]; 1337 for (j = 0; j < num_regs; j++) 1338 regmap_write(regmap, reg_pairs[j].off, reg_pairs[j].val); 1339 } 1340 } 1341 1342 if (phy_t1 == TYPE_QSGMII) 1343 reset_control_deassert(sp->phys[node].lnk_rst); 1344 } 1345 1346 /* Take the PHY out of reset */ 1347 ret = reset_control_deassert(sp->phy_rst); 1348 if (ret) 1349 return ret; 1350 1351 return 0; 1352 } 1353 1354 static int cdns_sierra_phy_probe(struct platform_device *pdev) 1355 { 1356 struct cdns_sierra_phy *sp; 1357 struct phy_provider *phy_provider; 1358 struct device *dev = &pdev->dev; 1359 const struct cdns_sierra_data *data; 1360 unsigned int id_value; 1361 int ret, node = 0; 1362 void __iomem *base; 1363 struct device_node *dn = dev->of_node, *child; 1364 1365 if (of_get_child_count(dn) == 0) 1366 return -ENODEV; 1367 1368 /* Get init data for this PHY */ 1369 data = of_device_get_match_data(dev); 1370 if (!data) 1371 return -EINVAL; 1372 1373 sp = devm_kzalloc(dev, sizeof(*sp), GFP_KERNEL); 1374 if (!sp) 1375 return -ENOMEM; 1376 dev_set_drvdata(dev, sp); 1377 sp->dev = dev; 1378 sp->init_data = data; 1379 1380 base = devm_platform_ioremap_resource(pdev, 0); 1381 if (IS_ERR(base)) { 1382 dev_err(dev, "missing \"reg\"\n"); 1383 return PTR_ERR(base); 1384 } 1385 1386 ret = cdns_regmap_init_blocks(sp, base, data->block_offset_shift, 1387 data->reg_offset_shift); 1388 if (ret) 1389 return ret; 1390 1391 ret = cdns_regfield_init(sp); 1392 if (ret) 1393 return ret; 1394 1395 platform_set_drvdata(pdev, sp); 1396 1397 ret = cdns_sierra_phy_get_clocks(sp, dev); 1398 if (ret) 1399 return ret; 1400 1401 ret = cdns_sierra_clk_register(sp); 1402 if (ret) 1403 return ret; 1404 1405 ret = cdns_sierra_phy_enable_clocks(sp); 1406 if (ret) 1407 goto unregister_clk; 1408 1409 regmap_field_read(sp->pma_cmn_ready, &sp->already_configured); 1410 1411 if (!sp->already_configured) { 1412 ret = cdns_sierra_phy_clk(sp); 1413 if (ret) 1414 goto clk_disable; 1415 1416 ret = cdns_sierra_phy_get_resets(sp, dev); 1417 if (ret) 1418 goto clk_disable; 1419 1420 /* Enable APB */ 1421 reset_control_deassert(sp->apb_rst); 1422 } 1423 1424 /* Check that PHY is present */ 1425 regmap_field_read(sp->macro_id_type, &id_value); 1426 if (sp->init_data->id_value != id_value) { 1427 ret = -EINVAL; 1428 goto ctrl_assert; 1429 } 1430 1431 sp->autoconf = of_property_read_bool(dn, "cdns,autoconf"); 1432 1433 for_each_available_child_of_node(dn, child) { 1434 struct phy *gphy; 1435 1436 if (!(of_node_name_eq(child, "phy") || 1437 of_node_name_eq(child, "link"))) 1438 continue; 1439 1440 sp->phys[node].lnk_rst = 1441 of_reset_control_array_get_exclusive(child); 1442 1443 if (IS_ERR(sp->phys[node].lnk_rst)) { 1444 dev_err(dev, "failed to get reset %s\n", 1445 child->full_name); 1446 ret = PTR_ERR(sp->phys[node].lnk_rst); 1447 of_node_put(child); 1448 goto put_control; 1449 } 1450 1451 if (!sp->autoconf) { 1452 ret = cdns_sierra_get_optional(&sp->phys[node], child); 1453 if (ret) { 1454 dev_err(dev, "missing property in node %s\n", 1455 child->name); 1456 of_node_put(child); 1457 reset_control_put(sp->phys[node].lnk_rst); 1458 goto put_control; 1459 } 1460 } 1461 1462 sp->num_lanes += sp->phys[node].num_lanes; 1463 1464 if (!sp->already_configured) 1465 gphy = devm_phy_create(dev, child, &ops); 1466 else 1467 gphy = devm_phy_create(dev, child, &noop_ops); 1468 if (IS_ERR(gphy)) { 1469 ret = PTR_ERR(gphy); 1470 of_node_put(child); 1471 reset_control_put(sp->phys[node].lnk_rst); 1472 goto put_control; 1473 } 1474 sp->phys[node].phy = gphy; 1475 phy_set_drvdata(gphy, &sp->phys[node]); 1476 1477 node++; 1478 } 1479 sp->nsubnodes = node; 1480 1481 if (sp->num_lanes > SIERRA_MAX_LANES) { 1482 ret = -EINVAL; 1483 dev_err(dev, "Invalid lane configuration\n"); 1484 goto put_control; 1485 } 1486 1487 /* If more than one subnode, configure the PHY as multilink */ 1488 if (!sp->already_configured && !sp->autoconf && sp->nsubnodes > 1) { 1489 ret = cdns_sierra_phy_configure_multilink(sp); 1490 if (ret) 1491 goto put_control; 1492 } 1493 1494 pm_runtime_enable(dev); 1495 phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); 1496 if (IS_ERR(phy_provider)) { 1497 ret = PTR_ERR(phy_provider); 1498 goto put_control; 1499 } 1500 1501 return 0; 1502 1503 put_control: 1504 while (--node >= 0) 1505 reset_control_put(sp->phys[node].lnk_rst); 1506 ctrl_assert: 1507 if (!sp->already_configured) 1508 reset_control_assert(sp->apb_rst); 1509 clk_disable: 1510 cdns_sierra_phy_disable_clocks(sp); 1511 unregister_clk: 1512 cdns_sierra_clk_unregister(sp); 1513 return ret; 1514 } 1515 1516 static int cdns_sierra_phy_remove(struct platform_device *pdev) 1517 { 1518 struct cdns_sierra_phy *phy = platform_get_drvdata(pdev); 1519 int i; 1520 1521 reset_control_assert(phy->phy_rst); 1522 reset_control_assert(phy->apb_rst); 1523 pm_runtime_disable(&pdev->dev); 1524 1525 cdns_sierra_phy_disable_clocks(phy); 1526 /* 1527 * The device level resets will be put automatically. 1528 * Need to put the subnode resets here though. 1529 */ 1530 for (i = 0; i < phy->nsubnodes; i++) { 1531 reset_control_assert(phy->phys[i].lnk_rst); 1532 reset_control_put(phy->phys[i].lnk_rst); 1533 } 1534 1535 cdns_sierra_clk_unregister(phy); 1536 1537 return 0; 1538 } 1539 1540 /* QSGMII PHY PMA lane configuration */ 1541 static struct cdns_reg_pairs qsgmii_phy_pma_ln_regs[] = { 1542 {0x9010, SIERRA_PHY_PMA_XCVR_CTRL} 1543 }; 1544 1545 static struct cdns_sierra_vals qsgmii_phy_pma_ln_vals = { 1546 .reg_pairs = qsgmii_phy_pma_ln_regs, 1547 .num_regs = ARRAY_SIZE(qsgmii_phy_pma_ln_regs), 1548 }; 1549 1550 /* QSGMII refclk 100MHz, 20b, opt1, No BW cal, no ssc, PLL LC1 */ 1551 static const struct cdns_reg_pairs qsgmii_100_no_ssc_plllc1_cmn_regs[] = { 1552 {0x2085, SIERRA_CMN_PLLLC1_LF_COEFF_MODE0_PREG}, 1553 {0x0000, SIERRA_CMN_PLLLC1_BWCAL_MODE0_PREG}, 1554 {0x0000, SIERRA_CMN_PLLLC1_SS_TIME_STEPSIZE_MODE_PREG} 1555 }; 1556 1557 static const struct cdns_reg_pairs qsgmii_100_no_ssc_plllc1_ln_regs[] = { 1558 {0xFC08, SIERRA_DET_STANDEC_A_PREG}, 1559 {0x0252, SIERRA_DET_STANDEC_E_PREG}, 1560 {0x0004, SIERRA_PSC_LN_IDLE_PREG}, 1561 {0x0FFE, SIERRA_PSC_RX_A0_PREG}, 1562 {0x0011, SIERRA_PLLCTRL_SUBRATE_PREG}, 1563 {0x0001, SIERRA_PLLCTRL_GEN_A_PREG}, 1564 {0x5233, SIERRA_PLLCTRL_CPGAIN_MODE_PREG}, 1565 {0x0000, SIERRA_DRVCTRL_ATTEN_PREG}, 1566 {0x0089, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG}, 1567 {0x3C3C, SIERRA_CREQ_CCLKDET_MODE01_PREG}, 1568 {0x3222, SIERRA_CREQ_FSMCLK_SEL_PREG}, 1569 {0x0000, SIERRA_CREQ_EQ_CTRL_PREG}, 1570 {0x8422, SIERRA_CTLELUT_CTRL_PREG}, 1571 {0x4111, SIERRA_DFE_ECMP_RATESEL_PREG}, 1572 {0x4111, SIERRA_DFE_SMP_RATESEL_PREG}, 1573 {0x0002, SIERRA_DEQ_PHALIGN_CTRL}, 1574 {0x9595, SIERRA_DEQ_VGATUNE_CTRL_PREG}, 1575 {0x0186, SIERRA_DEQ_GLUT0}, 1576 {0x0186, SIERRA_DEQ_GLUT1}, 1577 {0x0186, SIERRA_DEQ_GLUT2}, 1578 {0x0186, SIERRA_DEQ_GLUT3}, 1579 {0x0186, SIERRA_DEQ_GLUT4}, 1580 {0x0861, SIERRA_DEQ_ALUT0}, 1581 {0x07E0, SIERRA_DEQ_ALUT1}, 1582 {0x079E, SIERRA_DEQ_ALUT2}, 1583 {0x071D, SIERRA_DEQ_ALUT3}, 1584 {0x03F5, SIERRA_DEQ_DFETAP_CTRL_PREG}, 1585 {0x0C01, SIERRA_DEQ_TAU_CTRL1_FAST_MAINT_PREG}, 1586 {0x3C40, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG}, 1587 {0x1C04, SIERRA_DEQ_TAU_CTRL2_PREG}, 1588 {0x0033, SIERRA_DEQ_PICTRL_PREG}, 1589 {0x0660, SIERRA_CPICAL_TMRVAL_MODE0_PREG}, 1590 {0x00D5, SIERRA_CPI_OUTBUF_RATESEL_PREG}, 1591 {0x0B6D, SIERRA_CPI_RESBIAS_BIN_PREG}, 1592 {0x0102, SIERRA_RXBUFFER_CTLECTRL_PREG}, 1593 {0x0002, SIERRA_RXBUFFER_RCDFECTRL_PREG} 1594 }; 1595 1596 static struct cdns_sierra_vals qsgmii_100_no_ssc_plllc1_cmn_vals = { 1597 .reg_pairs = qsgmii_100_no_ssc_plllc1_cmn_regs, 1598 .num_regs = ARRAY_SIZE(qsgmii_100_no_ssc_plllc1_cmn_regs), 1599 }; 1600 1601 static struct cdns_sierra_vals qsgmii_100_no_ssc_plllc1_ln_vals = { 1602 .reg_pairs = qsgmii_100_no_ssc_plllc1_ln_regs, 1603 .num_regs = ARRAY_SIZE(qsgmii_100_no_ssc_plllc1_ln_regs), 1604 }; 1605 1606 /* PCIE PHY PCS common configuration */ 1607 static struct cdns_reg_pairs pcie_phy_pcs_cmn_regs[] = { 1608 {0x0430, SIERRA_PHY_PIPE_CMN_CTRL1} 1609 }; 1610 1611 static struct cdns_sierra_vals pcie_phy_pcs_cmn_vals = { 1612 .reg_pairs = pcie_phy_pcs_cmn_regs, 1613 .num_regs = ARRAY_SIZE(pcie_phy_pcs_cmn_regs), 1614 }; 1615 1616 /* refclk100MHz_32b_PCIe_cmn_pll_no_ssc, pcie_links_using_plllc, pipe_bw_3 */ 1617 static const struct cdns_reg_pairs pcie_100_no_ssc_plllc_cmn_regs[] = { 1618 {0x2105, SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG}, 1619 {0x2105, SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG}, 1620 {0x8A06, SIERRA_CMN_PLLLC_BWCAL_MODE1_PREG}, 1621 {0x8A06, SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG} 1622 }; 1623 1624 /* 1625 * refclk100MHz_32b_PCIe_ln_no_ssc, multilink, using_plllc, 1626 * cmn_pllcy_anaclk0_1Ghz, xcvr_pllclk_fullrt_500mhz 1627 */ 1628 static const struct cdns_reg_pairs ml_pcie_100_no_ssc_ln_regs[] = { 1629 {0xFC08, SIERRA_DET_STANDEC_A_PREG}, 1630 {0x001D, SIERRA_PSM_A3IN_TMR_PREG}, 1631 {0x0004, SIERRA_PSC_LN_A3_PREG}, 1632 {0x0004, SIERRA_PSC_LN_A4_PREG}, 1633 {0x0004, SIERRA_PSC_LN_IDLE_PREG}, 1634 {0x1555, SIERRA_DFE_BIASTRIM_PREG}, 1635 {0x9703, SIERRA_DRVCTRL_BOOST_PREG}, 1636 {0x8055, SIERRA_RX_CREQ_FLTR_A_MODE3_PREG}, 1637 {0x80BB, SIERRA_RX_CREQ_FLTR_A_MODE2_PREG}, 1638 {0x8351, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG}, 1639 {0x8349, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG}, 1640 {0x0002, SIERRA_CREQ_DCBIASATTEN_OVR_PREG}, 1641 {0x9800, SIERRA_RX_CTLE_CAL_PREG}, 1642 {0x5624, SIERRA_DEQ_CONCUR_CTRL2_PREG}, 1643 {0x000F, SIERRA_DEQ_EPIPWR_CTRL2_PREG}, 1644 {0x00FF, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG}, 1645 {0x4C4C, SIERRA_DEQ_ERRCMP_CTRL_PREG}, 1646 {0x02FA, SIERRA_DEQ_OFFSET_CTRL_PREG}, 1647 {0x02FA, SIERRA_DEQ_GAIN_CTRL_PREG}, 1648 {0x0041, SIERRA_DEQ_GLUT0}, 1649 {0x0082, SIERRA_DEQ_GLUT1}, 1650 {0x00C3, SIERRA_DEQ_GLUT2}, 1651 {0x0145, SIERRA_DEQ_GLUT3}, 1652 {0x0186, SIERRA_DEQ_GLUT4}, 1653 {0x09E7, SIERRA_DEQ_ALUT0}, 1654 {0x09A6, SIERRA_DEQ_ALUT1}, 1655 {0x0965, SIERRA_DEQ_ALUT2}, 1656 {0x08E3, SIERRA_DEQ_ALUT3}, 1657 {0x00FA, SIERRA_DEQ_DFETAP0}, 1658 {0x00FA, SIERRA_DEQ_DFETAP1}, 1659 {0x00FA, SIERRA_DEQ_DFETAP2}, 1660 {0x00FA, SIERRA_DEQ_DFETAP3}, 1661 {0x00FA, SIERRA_DEQ_DFETAP4}, 1662 {0x000F, SIERRA_DEQ_PRECUR_PREG}, 1663 {0x0280, SIERRA_DEQ_POSTCUR_PREG}, 1664 {0x8F00, SIERRA_DEQ_POSTCUR_DECR_PREG}, 1665 {0x3C0F, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG}, 1666 {0x1C0C, SIERRA_DEQ_TAU_CTRL2_PREG}, 1667 {0x0100, SIERRA_DEQ_TAU_CTRL3_PREG}, 1668 {0x5E82, SIERRA_DEQ_OPENEYE_CTRL_PREG}, 1669 {0x002B, SIERRA_CPI_TRIM_PREG}, 1670 {0x0003, SIERRA_EPI_CTRL_PREG}, 1671 {0x803F, SIERRA_SDFILT_H2L_A_PREG}, 1672 {0x0004, SIERRA_RXBUFFER_CTLECTRL_PREG}, 1673 {0x2010, SIERRA_RXBUFFER_RCDFECTRL_PREG}, 1674 {0x4432, SIERRA_RXBUFFER_DFECTRL_PREG} 1675 }; 1676 1677 static struct cdns_sierra_vals pcie_100_no_ssc_plllc_cmn_vals = { 1678 .reg_pairs = pcie_100_no_ssc_plllc_cmn_regs, 1679 .num_regs = ARRAY_SIZE(pcie_100_no_ssc_plllc_cmn_regs), 1680 }; 1681 1682 static struct cdns_sierra_vals ml_pcie_100_no_ssc_ln_vals = { 1683 .reg_pairs = ml_pcie_100_no_ssc_ln_regs, 1684 .num_regs = ARRAY_SIZE(ml_pcie_100_no_ssc_ln_regs), 1685 }; 1686 1687 /* refclk100MHz_32b_PCIe_cmn_pll_int_ssc, pcie_links_using_plllc, pipe_bw_3 */ 1688 static const struct cdns_reg_pairs pcie_100_int_ssc_plllc_cmn_regs[] = { 1689 {0x000E, SIERRA_CMN_PLLLC_MODE_PREG}, 1690 {0x4006, SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG}, 1691 {0x4006, SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG}, 1692 {0x0000, SIERRA_CMN_PLLLC_BWCAL_MODE1_PREG}, 1693 {0x0000, SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG}, 1694 {0x0581, SIERRA_CMN_PLLLC_DSMCORR_PREG}, 1695 {0x7F80, SIERRA_CMN_PLLLC_SS_PREG}, 1696 {0x0041, SIERRA_CMN_PLLLC_SS_AMP_STEP_SIZE_PREG}, 1697 {0x0464, SIERRA_CMN_PLLLC_SSTWOPT_PREG}, 1698 {0x0D0D, SIERRA_CMN_PLLLC_SS_TIME_STEPSIZE_MODE_PREG}, 1699 {0x0060, SIERRA_CMN_PLLLC_LOCK_DELAY_CTRL_PREG} 1700 }; 1701 1702 /* 1703 * refclk100MHz_32b_PCIe_ln_int_ssc, multilink, using_plllc, 1704 * cmn_pllcy_anaclk0_1Ghz, xcvr_pllclk_fullrt_500mhz 1705 */ 1706 static const struct cdns_reg_pairs ml_pcie_100_int_ssc_ln_regs[] = { 1707 {0xFC08, SIERRA_DET_STANDEC_A_PREG}, 1708 {0x001D, SIERRA_PSM_A3IN_TMR_PREG}, 1709 {0x0004, SIERRA_PSC_LN_A3_PREG}, 1710 {0x0004, SIERRA_PSC_LN_A4_PREG}, 1711 {0x0004, SIERRA_PSC_LN_IDLE_PREG}, 1712 {0x1555, SIERRA_DFE_BIASTRIM_PREG}, 1713 {0x9703, SIERRA_DRVCTRL_BOOST_PREG}, 1714 {0x813E, SIERRA_CLKPATHCTRL_TMR_PREG}, 1715 {0x8047, SIERRA_RX_CREQ_FLTR_A_MODE3_PREG}, 1716 {0x808F, SIERRA_RX_CREQ_FLTR_A_MODE2_PREG}, 1717 {0x808F, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG}, 1718 {0x808F, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG}, 1719 {0x0002, SIERRA_CREQ_DCBIASATTEN_OVR_PREG}, 1720 {0x9800, SIERRA_RX_CTLE_CAL_PREG}, 1721 {0x033C, SIERRA_RX_CTLE_MAINTENANCE_PREG}, 1722 {0x44CC, SIERRA_CREQ_EQ_OPEN_EYE_THRESH_PREG}, 1723 {0x5624, SIERRA_DEQ_CONCUR_CTRL2_PREG}, 1724 {0x000F, SIERRA_DEQ_EPIPWR_CTRL2_PREG}, 1725 {0x00FF, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG}, 1726 {0x4C4C, SIERRA_DEQ_ERRCMP_CTRL_PREG}, 1727 {0x02FA, SIERRA_DEQ_OFFSET_CTRL_PREG}, 1728 {0x02FA, SIERRA_DEQ_GAIN_CTRL_PREG}, 1729 {0x0041, SIERRA_DEQ_GLUT0}, 1730 {0x0082, SIERRA_DEQ_GLUT1}, 1731 {0x00C3, SIERRA_DEQ_GLUT2}, 1732 {0x0145, SIERRA_DEQ_GLUT3}, 1733 {0x0186, SIERRA_DEQ_GLUT4}, 1734 {0x09E7, SIERRA_DEQ_ALUT0}, 1735 {0x09A6, SIERRA_DEQ_ALUT1}, 1736 {0x0965, SIERRA_DEQ_ALUT2}, 1737 {0x08E3, SIERRA_DEQ_ALUT3}, 1738 {0x00FA, SIERRA_DEQ_DFETAP0}, 1739 {0x00FA, SIERRA_DEQ_DFETAP1}, 1740 {0x00FA, SIERRA_DEQ_DFETAP2}, 1741 {0x00FA, SIERRA_DEQ_DFETAP3}, 1742 {0x00FA, SIERRA_DEQ_DFETAP4}, 1743 {0x000F, SIERRA_DEQ_PRECUR_PREG}, 1744 {0x0280, SIERRA_DEQ_POSTCUR_PREG}, 1745 {0x8F00, SIERRA_DEQ_POSTCUR_DECR_PREG}, 1746 {0x3C0F, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG}, 1747 {0x1C0C, SIERRA_DEQ_TAU_CTRL2_PREG}, 1748 {0x0100, SIERRA_DEQ_TAU_CTRL3_PREG}, 1749 {0x5E82, SIERRA_DEQ_OPENEYE_CTRL_PREG}, 1750 {0x002B, SIERRA_CPI_TRIM_PREG}, 1751 {0x0003, SIERRA_EPI_CTRL_PREG}, 1752 {0x803F, SIERRA_SDFILT_H2L_A_PREG}, 1753 {0x0004, SIERRA_RXBUFFER_CTLECTRL_PREG}, 1754 {0x2010, SIERRA_RXBUFFER_RCDFECTRL_PREG}, 1755 {0x4432, SIERRA_RXBUFFER_DFECTRL_PREG} 1756 }; 1757 1758 static struct cdns_sierra_vals pcie_100_int_ssc_plllc_cmn_vals = { 1759 .reg_pairs = pcie_100_int_ssc_plllc_cmn_regs, 1760 .num_regs = ARRAY_SIZE(pcie_100_int_ssc_plllc_cmn_regs), 1761 }; 1762 1763 static struct cdns_sierra_vals ml_pcie_100_int_ssc_ln_vals = { 1764 .reg_pairs = ml_pcie_100_int_ssc_ln_regs, 1765 .num_regs = ARRAY_SIZE(ml_pcie_100_int_ssc_ln_regs), 1766 }; 1767 1768 /* refclk100MHz_32b_PCIe_cmn_pll_ext_ssc, pcie_links_using_plllc, pipe_bw_3 */ 1769 static const struct cdns_reg_pairs pcie_100_ext_ssc_plllc_cmn_regs[] = { 1770 {0x2106, SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG}, 1771 {0x2106, SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG}, 1772 {0x8A06, SIERRA_CMN_PLLLC_BWCAL_MODE1_PREG}, 1773 {0x8A06, SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG}, 1774 {0x1B1B, SIERRA_CMN_PLLLC_SS_TIME_STEPSIZE_MODE_PREG} 1775 }; 1776 1777 /* 1778 * refclk100MHz_32b_PCIe_ln_ext_ssc, multilink, using_plllc, 1779 * cmn_pllcy_anaclk0_1Ghz, xcvr_pllclk_fullrt_500mhz 1780 */ 1781 static const struct cdns_reg_pairs ml_pcie_100_ext_ssc_ln_regs[] = { 1782 {0xFC08, SIERRA_DET_STANDEC_A_PREG}, 1783 {0x001D, SIERRA_PSM_A3IN_TMR_PREG}, 1784 {0x0004, SIERRA_PSC_LN_A3_PREG}, 1785 {0x0004, SIERRA_PSC_LN_A4_PREG}, 1786 {0x0004, SIERRA_PSC_LN_IDLE_PREG}, 1787 {0x1555, SIERRA_DFE_BIASTRIM_PREG}, 1788 {0x9703, SIERRA_DRVCTRL_BOOST_PREG}, 1789 {0x813E, SIERRA_CLKPATHCTRL_TMR_PREG}, 1790 {0x8047, SIERRA_RX_CREQ_FLTR_A_MODE3_PREG}, 1791 {0x808F, SIERRA_RX_CREQ_FLTR_A_MODE2_PREG}, 1792 {0x808F, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG}, 1793 {0x808F, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG}, 1794 {0x0002, SIERRA_CREQ_DCBIASATTEN_OVR_PREG}, 1795 {0x9800, SIERRA_RX_CTLE_CAL_PREG}, 1796 {0x033C, SIERRA_RX_CTLE_MAINTENANCE_PREG}, 1797 {0x44CC, SIERRA_CREQ_EQ_OPEN_EYE_THRESH_PREG}, 1798 {0x5624, SIERRA_DEQ_CONCUR_CTRL2_PREG}, 1799 {0x000F, SIERRA_DEQ_EPIPWR_CTRL2_PREG}, 1800 {0x00FF, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG}, 1801 {0x4C4C, SIERRA_DEQ_ERRCMP_CTRL_PREG}, 1802 {0x02FA, SIERRA_DEQ_OFFSET_CTRL_PREG}, 1803 {0x02FA, SIERRA_DEQ_GAIN_CTRL_PREG}, 1804 {0x0041, SIERRA_DEQ_GLUT0}, 1805 {0x0082, SIERRA_DEQ_GLUT1}, 1806 {0x00C3, SIERRA_DEQ_GLUT2}, 1807 {0x0145, SIERRA_DEQ_GLUT3}, 1808 {0x0186, SIERRA_DEQ_GLUT4}, 1809 {0x09E7, SIERRA_DEQ_ALUT0}, 1810 {0x09A6, SIERRA_DEQ_ALUT1}, 1811 {0x0965, SIERRA_DEQ_ALUT2}, 1812 {0x08E3, SIERRA_DEQ_ALUT3}, 1813 {0x00FA, SIERRA_DEQ_DFETAP0}, 1814 {0x00FA, SIERRA_DEQ_DFETAP1}, 1815 {0x00FA, SIERRA_DEQ_DFETAP2}, 1816 {0x00FA, SIERRA_DEQ_DFETAP3}, 1817 {0x00FA, SIERRA_DEQ_DFETAP4}, 1818 {0x000F, SIERRA_DEQ_PRECUR_PREG}, 1819 {0x0280, SIERRA_DEQ_POSTCUR_PREG}, 1820 {0x8F00, SIERRA_DEQ_POSTCUR_DECR_PREG}, 1821 {0x3C0F, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG}, 1822 {0x1C0C, SIERRA_DEQ_TAU_CTRL2_PREG}, 1823 {0x0100, SIERRA_DEQ_TAU_CTRL3_PREG}, 1824 {0x5E82, SIERRA_DEQ_OPENEYE_CTRL_PREG}, 1825 {0x002B, SIERRA_CPI_TRIM_PREG}, 1826 {0x0003, SIERRA_EPI_CTRL_PREG}, 1827 {0x803F, SIERRA_SDFILT_H2L_A_PREG}, 1828 {0x0004, SIERRA_RXBUFFER_CTLECTRL_PREG}, 1829 {0x2010, SIERRA_RXBUFFER_RCDFECTRL_PREG}, 1830 {0x4432, SIERRA_RXBUFFER_DFECTRL_PREG} 1831 }; 1832 1833 static struct cdns_sierra_vals pcie_100_ext_ssc_plllc_cmn_vals = { 1834 .reg_pairs = pcie_100_ext_ssc_plllc_cmn_regs, 1835 .num_regs = ARRAY_SIZE(pcie_100_ext_ssc_plllc_cmn_regs), 1836 }; 1837 1838 static struct cdns_sierra_vals ml_pcie_100_ext_ssc_ln_vals = { 1839 .reg_pairs = ml_pcie_100_ext_ssc_ln_regs, 1840 .num_regs = ARRAY_SIZE(ml_pcie_100_ext_ssc_ln_regs), 1841 }; 1842 1843 /* refclk100MHz_32b_PCIe_cmn_pll_no_ssc */ 1844 static const struct cdns_reg_pairs cdns_pcie_cmn_regs_no_ssc[] = { 1845 {0x2105, SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG}, 1846 {0x2105, SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG}, 1847 {0x8A06, SIERRA_CMN_PLLLC_BWCAL_MODE1_PREG}, 1848 {0x8A06, SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG} 1849 }; 1850 1851 /* refclk100MHz_32b_PCIe_ln_no_ssc */ 1852 static const struct cdns_reg_pairs cdns_pcie_ln_regs_no_ssc[] = { 1853 {0xFC08, SIERRA_DET_STANDEC_A_PREG}, 1854 {0x001D, SIERRA_PSM_A3IN_TMR_PREG}, 1855 {0x1555, SIERRA_DFE_BIASTRIM_PREG}, 1856 {0x9703, SIERRA_DRVCTRL_BOOST_PREG}, 1857 {0x8055, SIERRA_RX_CREQ_FLTR_A_MODE3_PREG}, 1858 {0x80BB, SIERRA_RX_CREQ_FLTR_A_MODE2_PREG}, 1859 {0x8351, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG}, 1860 {0x8349, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG}, 1861 {0x0002, SIERRA_CREQ_DCBIASATTEN_OVR_PREG}, 1862 {0x9800, SIERRA_RX_CTLE_CAL_PREG}, 1863 {0x5624, SIERRA_DEQ_CONCUR_CTRL2_PREG}, 1864 {0x000F, SIERRA_DEQ_EPIPWR_CTRL2_PREG}, 1865 {0x00FF, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG}, 1866 {0x4C4C, SIERRA_DEQ_ERRCMP_CTRL_PREG}, 1867 {0x02FA, SIERRA_DEQ_OFFSET_CTRL_PREG}, 1868 {0x02FA, SIERRA_DEQ_GAIN_CTRL_PREG}, 1869 {0x0041, SIERRA_DEQ_GLUT0}, 1870 {0x0082, SIERRA_DEQ_GLUT1}, 1871 {0x00C3, SIERRA_DEQ_GLUT2}, 1872 {0x0145, SIERRA_DEQ_GLUT3}, 1873 {0x0186, SIERRA_DEQ_GLUT4}, 1874 {0x09E7, SIERRA_DEQ_ALUT0}, 1875 {0x09A6, SIERRA_DEQ_ALUT1}, 1876 {0x0965, SIERRA_DEQ_ALUT2}, 1877 {0x08E3, SIERRA_DEQ_ALUT3}, 1878 {0x00FA, SIERRA_DEQ_DFETAP0}, 1879 {0x00FA, SIERRA_DEQ_DFETAP1}, 1880 {0x00FA, SIERRA_DEQ_DFETAP2}, 1881 {0x00FA, SIERRA_DEQ_DFETAP3}, 1882 {0x00FA, SIERRA_DEQ_DFETAP4}, 1883 {0x000F, SIERRA_DEQ_PRECUR_PREG}, 1884 {0x0280, SIERRA_DEQ_POSTCUR_PREG}, 1885 {0x8F00, SIERRA_DEQ_POSTCUR_DECR_PREG}, 1886 {0x3C0F, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG}, 1887 {0x1C0C, SIERRA_DEQ_TAU_CTRL2_PREG}, 1888 {0x0100, SIERRA_DEQ_TAU_CTRL3_PREG}, 1889 {0x5E82, SIERRA_DEQ_OPENEYE_CTRL_PREG}, 1890 {0x002B, SIERRA_CPI_TRIM_PREG}, 1891 {0x0003, SIERRA_EPI_CTRL_PREG}, 1892 {0x803F, SIERRA_SDFILT_H2L_A_PREG}, 1893 {0x0004, SIERRA_RXBUFFER_CTLECTRL_PREG}, 1894 {0x2010, SIERRA_RXBUFFER_RCDFECTRL_PREG}, 1895 {0x4432, SIERRA_RXBUFFER_DFECTRL_PREG} 1896 }; 1897 1898 static struct cdns_sierra_vals pcie_100_no_ssc_cmn_vals = { 1899 .reg_pairs = cdns_pcie_cmn_regs_no_ssc, 1900 .num_regs = ARRAY_SIZE(cdns_pcie_cmn_regs_no_ssc), 1901 }; 1902 1903 static struct cdns_sierra_vals pcie_100_no_ssc_ln_vals = { 1904 .reg_pairs = cdns_pcie_ln_regs_no_ssc, 1905 .num_regs = ARRAY_SIZE(cdns_pcie_ln_regs_no_ssc), 1906 }; 1907 1908 /* refclk100MHz_32b_PCIe_cmn_pll_int_ssc */ 1909 static const struct cdns_reg_pairs cdns_pcie_cmn_regs_int_ssc[] = { 1910 {0x000E, SIERRA_CMN_PLLLC_MODE_PREG}, 1911 {0x4006, SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG}, 1912 {0x4006, SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG}, 1913 {0x0000, SIERRA_CMN_PLLLC_BWCAL_MODE1_PREG}, 1914 {0x0000, SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG}, 1915 {0x0581, SIERRA_CMN_PLLLC_DSMCORR_PREG}, 1916 {0x7F80, SIERRA_CMN_PLLLC_SS_PREG}, 1917 {0x0041, SIERRA_CMN_PLLLC_SS_AMP_STEP_SIZE_PREG}, 1918 {0x0464, SIERRA_CMN_PLLLC_SSTWOPT_PREG}, 1919 {0x0D0D, SIERRA_CMN_PLLLC_SS_TIME_STEPSIZE_MODE_PREG}, 1920 {0x0060, SIERRA_CMN_PLLLC_LOCK_DELAY_CTRL_PREG} 1921 }; 1922 1923 /* refclk100MHz_32b_PCIe_ln_int_ssc */ 1924 static const struct cdns_reg_pairs cdns_pcie_ln_regs_int_ssc[] = { 1925 {0xFC08, SIERRA_DET_STANDEC_A_PREG}, 1926 {0x001D, SIERRA_PSM_A3IN_TMR_PREG}, 1927 {0x1555, SIERRA_DFE_BIASTRIM_PREG}, 1928 {0x9703, SIERRA_DRVCTRL_BOOST_PREG}, 1929 {0x813E, SIERRA_CLKPATHCTRL_TMR_PREG}, 1930 {0x8047, SIERRA_RX_CREQ_FLTR_A_MODE3_PREG}, 1931 {0x808F, SIERRA_RX_CREQ_FLTR_A_MODE2_PREG}, 1932 {0x808F, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG}, 1933 {0x808F, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG}, 1934 {0x0002, SIERRA_CREQ_DCBIASATTEN_OVR_PREG}, 1935 {0x9800, SIERRA_RX_CTLE_CAL_PREG}, 1936 {0x033C, SIERRA_RX_CTLE_MAINTENANCE_PREG}, 1937 {0x44CC, SIERRA_CREQ_EQ_OPEN_EYE_THRESH_PREG}, 1938 {0x5624, SIERRA_DEQ_CONCUR_CTRL2_PREG}, 1939 {0x000F, SIERRA_DEQ_EPIPWR_CTRL2_PREG}, 1940 {0x00FF, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG}, 1941 {0x4C4C, SIERRA_DEQ_ERRCMP_CTRL_PREG}, 1942 {0x02FA, SIERRA_DEQ_OFFSET_CTRL_PREG}, 1943 {0x02FA, SIERRA_DEQ_GAIN_CTRL_PREG}, 1944 {0x0041, SIERRA_DEQ_GLUT0}, 1945 {0x0082, SIERRA_DEQ_GLUT1}, 1946 {0x00C3, SIERRA_DEQ_GLUT2}, 1947 {0x0145, SIERRA_DEQ_GLUT3}, 1948 {0x0186, SIERRA_DEQ_GLUT4}, 1949 {0x09E7, SIERRA_DEQ_ALUT0}, 1950 {0x09A6, SIERRA_DEQ_ALUT1}, 1951 {0x0965, SIERRA_DEQ_ALUT2}, 1952 {0x08E3, SIERRA_DEQ_ALUT3}, 1953 {0x00FA, SIERRA_DEQ_DFETAP0}, 1954 {0x00FA, SIERRA_DEQ_DFETAP1}, 1955 {0x00FA, SIERRA_DEQ_DFETAP2}, 1956 {0x00FA, SIERRA_DEQ_DFETAP3}, 1957 {0x00FA, SIERRA_DEQ_DFETAP4}, 1958 {0x000F, SIERRA_DEQ_PRECUR_PREG}, 1959 {0x0280, SIERRA_DEQ_POSTCUR_PREG}, 1960 {0x8F00, SIERRA_DEQ_POSTCUR_DECR_PREG}, 1961 {0x3C0F, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG}, 1962 {0x1C0C, SIERRA_DEQ_TAU_CTRL2_PREG}, 1963 {0x0100, SIERRA_DEQ_TAU_CTRL3_PREG}, 1964 {0x5E82, SIERRA_DEQ_OPENEYE_CTRL_PREG}, 1965 {0x002B, SIERRA_CPI_TRIM_PREG}, 1966 {0x0003, SIERRA_EPI_CTRL_PREG}, 1967 {0x803F, SIERRA_SDFILT_H2L_A_PREG}, 1968 {0x0004, SIERRA_RXBUFFER_CTLECTRL_PREG}, 1969 {0x2010, SIERRA_RXBUFFER_RCDFECTRL_PREG}, 1970 {0x4432, SIERRA_RXBUFFER_DFECTRL_PREG} 1971 }; 1972 1973 static struct cdns_sierra_vals pcie_100_int_ssc_cmn_vals = { 1974 .reg_pairs = cdns_pcie_cmn_regs_int_ssc, 1975 .num_regs = ARRAY_SIZE(cdns_pcie_cmn_regs_int_ssc), 1976 }; 1977 1978 static struct cdns_sierra_vals pcie_100_int_ssc_ln_vals = { 1979 .reg_pairs = cdns_pcie_ln_regs_int_ssc, 1980 .num_regs = ARRAY_SIZE(cdns_pcie_ln_regs_int_ssc), 1981 }; 1982 1983 /* refclk100MHz_32b_PCIe_cmn_pll_ext_ssc */ 1984 static const struct cdns_reg_pairs cdns_pcie_cmn_regs_ext_ssc[] = { 1985 {0x2106, SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG}, 1986 {0x2106, SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG}, 1987 {0x8A06, SIERRA_CMN_PLLLC_BWCAL_MODE1_PREG}, 1988 {0x8A06, SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG}, 1989 {0x1B1B, SIERRA_CMN_PLLLC_SS_TIME_STEPSIZE_MODE_PREG} 1990 }; 1991 1992 /* refclk100MHz_32b_PCIe_ln_ext_ssc */ 1993 static const struct cdns_reg_pairs cdns_pcie_ln_regs_ext_ssc[] = { 1994 {0xFC08, SIERRA_DET_STANDEC_A_PREG}, 1995 {0x001D, SIERRA_PSM_A3IN_TMR_PREG}, 1996 {0x1555, SIERRA_DFE_BIASTRIM_PREG}, 1997 {0x9703, SIERRA_DRVCTRL_BOOST_PREG}, 1998 {0x813E, SIERRA_CLKPATHCTRL_TMR_PREG}, 1999 {0x8047, SIERRA_RX_CREQ_FLTR_A_MODE3_PREG}, 2000 {0x808F, SIERRA_RX_CREQ_FLTR_A_MODE2_PREG}, 2001 {0x808F, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG}, 2002 {0x808F, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG}, 2003 {0x0002, SIERRA_CREQ_DCBIASATTEN_OVR_PREG}, 2004 {0x9800, SIERRA_RX_CTLE_CAL_PREG}, 2005 {0x033C, SIERRA_RX_CTLE_MAINTENANCE_PREG}, 2006 {0x44CC, SIERRA_CREQ_EQ_OPEN_EYE_THRESH_PREG}, 2007 {0x5624, SIERRA_DEQ_CONCUR_CTRL2_PREG}, 2008 {0x000F, SIERRA_DEQ_EPIPWR_CTRL2_PREG}, 2009 {0x00FF, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG}, 2010 {0x4C4C, SIERRA_DEQ_ERRCMP_CTRL_PREG}, 2011 {0x02FA, SIERRA_DEQ_OFFSET_CTRL_PREG}, 2012 {0x02FA, SIERRA_DEQ_GAIN_CTRL_PREG}, 2013 {0x0041, SIERRA_DEQ_GLUT0}, 2014 {0x0082, SIERRA_DEQ_GLUT1}, 2015 {0x00C3, SIERRA_DEQ_GLUT2}, 2016 {0x0145, SIERRA_DEQ_GLUT3}, 2017 {0x0186, SIERRA_DEQ_GLUT4}, 2018 {0x09E7, SIERRA_DEQ_ALUT0}, 2019 {0x09A6, SIERRA_DEQ_ALUT1}, 2020 {0x0965, SIERRA_DEQ_ALUT2}, 2021 {0x08E3, SIERRA_DEQ_ALUT3}, 2022 {0x00FA, SIERRA_DEQ_DFETAP0}, 2023 {0x00FA, SIERRA_DEQ_DFETAP1}, 2024 {0x00FA, SIERRA_DEQ_DFETAP2}, 2025 {0x00FA, SIERRA_DEQ_DFETAP3}, 2026 {0x00FA, SIERRA_DEQ_DFETAP4}, 2027 {0x000F, SIERRA_DEQ_PRECUR_PREG}, 2028 {0x0280, SIERRA_DEQ_POSTCUR_PREG}, 2029 {0x8F00, SIERRA_DEQ_POSTCUR_DECR_PREG}, 2030 {0x3C0F, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG}, 2031 {0x1C0C, SIERRA_DEQ_TAU_CTRL2_PREG}, 2032 {0x0100, SIERRA_DEQ_TAU_CTRL3_PREG}, 2033 {0x5E82, SIERRA_DEQ_OPENEYE_CTRL_PREG}, 2034 {0x002B, SIERRA_CPI_TRIM_PREG}, 2035 {0x0003, SIERRA_EPI_CTRL_PREG}, 2036 {0x803F, SIERRA_SDFILT_H2L_A_PREG}, 2037 {0x0004, SIERRA_RXBUFFER_CTLECTRL_PREG}, 2038 {0x2010, SIERRA_RXBUFFER_RCDFECTRL_PREG}, 2039 {0x4432, SIERRA_RXBUFFER_DFECTRL_PREG} 2040 }; 2041 2042 static struct cdns_sierra_vals pcie_100_ext_ssc_cmn_vals = { 2043 .reg_pairs = cdns_pcie_cmn_regs_ext_ssc, 2044 .num_regs = ARRAY_SIZE(cdns_pcie_cmn_regs_ext_ssc), 2045 }; 2046 2047 static struct cdns_sierra_vals pcie_100_ext_ssc_ln_vals = { 2048 .reg_pairs = cdns_pcie_ln_regs_ext_ssc, 2049 .num_regs = ARRAY_SIZE(cdns_pcie_ln_regs_ext_ssc), 2050 }; 2051 2052 /* refclk100MHz_20b_USB_cmn_pll_ext_ssc */ 2053 static const struct cdns_reg_pairs cdns_usb_cmn_regs_ext_ssc[] = { 2054 {0x2085, SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG}, 2055 {0x2085, SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG}, 2056 {0x0000, SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG}, 2057 {0x0000, SIERRA_CMN_PLLLC_SS_TIME_STEPSIZE_MODE_PREG} 2058 }; 2059 2060 /* refclk100MHz_20b_USB_ln_ext_ssc */ 2061 static const struct cdns_reg_pairs cdns_usb_ln_regs_ext_ssc[] = { 2062 {0xFE0A, SIERRA_DET_STANDEC_A_PREG}, 2063 {0x000F, SIERRA_DET_STANDEC_B_PREG}, 2064 {0x55A5, SIERRA_DET_STANDEC_C_PREG}, 2065 {0x69ad, SIERRA_DET_STANDEC_D_PREG}, 2066 {0x0241, SIERRA_DET_STANDEC_E_PREG}, 2067 {0x0110, SIERRA_PSM_LANECAL_DLY_A1_RESETS_PREG}, 2068 {0x0014, SIERRA_PSM_A0IN_TMR_PREG}, 2069 {0xCF00, SIERRA_PSM_DIAG_PREG}, 2070 {0x001F, SIERRA_PSC_TX_A0_PREG}, 2071 {0x0007, SIERRA_PSC_TX_A1_PREG}, 2072 {0x0003, SIERRA_PSC_TX_A2_PREG}, 2073 {0x0003, SIERRA_PSC_TX_A3_PREG}, 2074 {0x0FFF, SIERRA_PSC_RX_A0_PREG}, 2075 {0x0003, SIERRA_PSC_RX_A1_PREG}, 2076 {0x0003, SIERRA_PSC_RX_A2_PREG}, 2077 {0x0001, SIERRA_PSC_RX_A3_PREG}, 2078 {0x0001, SIERRA_PLLCTRL_SUBRATE_PREG}, 2079 {0x0406, SIERRA_PLLCTRL_GEN_D_PREG}, 2080 {0x5233, SIERRA_PLLCTRL_CPGAIN_MODE_PREG}, 2081 {0x00CA, SIERRA_CLKPATH_BIASTRIM_PREG}, 2082 {0x2512, SIERRA_DFE_BIASTRIM_PREG}, 2083 {0x0000, SIERRA_DRVCTRL_ATTEN_PREG}, 2084 {0x823E, SIERRA_CLKPATHCTRL_TMR_PREG}, 2085 {0x078F, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG}, 2086 {0x078F, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG}, 2087 {0x7B3C, SIERRA_CREQ_CCLKDET_MODE01_PREG}, 2088 {0x023C, SIERRA_RX_CTLE_MAINTENANCE_PREG}, 2089 {0x3232, SIERRA_CREQ_FSMCLK_SEL_PREG}, 2090 {0x0000, SIERRA_CREQ_EQ_CTRL_PREG}, 2091 {0x0000, SIERRA_CREQ_SPARE_PREG}, 2092 {0xCC44, SIERRA_CREQ_EQ_OPEN_EYE_THRESH_PREG}, 2093 {0x8452, SIERRA_CTLELUT_CTRL_PREG}, 2094 {0x4121, SIERRA_DFE_ECMP_RATESEL_PREG}, 2095 {0x4121, SIERRA_DFE_SMP_RATESEL_PREG}, 2096 {0x0003, SIERRA_DEQ_PHALIGN_CTRL}, 2097 {0x3200, SIERRA_DEQ_CONCUR_CTRL1_PREG}, 2098 {0x5064, SIERRA_DEQ_CONCUR_CTRL2_PREG}, 2099 {0x0030, SIERRA_DEQ_EPIPWR_CTRL2_PREG}, 2100 {0x0048, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG}, 2101 {0x5A5A, SIERRA_DEQ_ERRCMP_CTRL_PREG}, 2102 {0x02F5, SIERRA_DEQ_OFFSET_CTRL_PREG}, 2103 {0x02F5, SIERRA_DEQ_GAIN_CTRL_PREG}, 2104 {0x9999, SIERRA_DEQ_VGATUNE_CTRL_PREG}, 2105 {0x0014, SIERRA_DEQ_GLUT0}, 2106 {0x0014, SIERRA_DEQ_GLUT1}, 2107 {0x0014, SIERRA_DEQ_GLUT2}, 2108 {0x0014, SIERRA_DEQ_GLUT3}, 2109 {0x0014, SIERRA_DEQ_GLUT4}, 2110 {0x0014, SIERRA_DEQ_GLUT5}, 2111 {0x0014, SIERRA_DEQ_GLUT6}, 2112 {0x0014, SIERRA_DEQ_GLUT7}, 2113 {0x0014, SIERRA_DEQ_GLUT8}, 2114 {0x0014, SIERRA_DEQ_GLUT9}, 2115 {0x0014, SIERRA_DEQ_GLUT10}, 2116 {0x0014, SIERRA_DEQ_GLUT11}, 2117 {0x0014, SIERRA_DEQ_GLUT12}, 2118 {0x0014, SIERRA_DEQ_GLUT13}, 2119 {0x0014, SIERRA_DEQ_GLUT14}, 2120 {0x0014, SIERRA_DEQ_GLUT15}, 2121 {0x0014, SIERRA_DEQ_GLUT16}, 2122 {0x0BAE, SIERRA_DEQ_ALUT0}, 2123 {0x0AEB, SIERRA_DEQ_ALUT1}, 2124 {0x0A28, SIERRA_DEQ_ALUT2}, 2125 {0x0965, SIERRA_DEQ_ALUT3}, 2126 {0x08A2, SIERRA_DEQ_ALUT4}, 2127 {0x07DF, SIERRA_DEQ_ALUT5}, 2128 {0x071C, SIERRA_DEQ_ALUT6}, 2129 {0x0659, SIERRA_DEQ_ALUT7}, 2130 {0x0596, SIERRA_DEQ_ALUT8}, 2131 {0x0514, SIERRA_DEQ_ALUT9}, 2132 {0x0492, SIERRA_DEQ_ALUT10}, 2133 {0x0410, SIERRA_DEQ_ALUT11}, 2134 {0x038E, SIERRA_DEQ_ALUT12}, 2135 {0x030C, SIERRA_DEQ_ALUT13}, 2136 {0x03F4, SIERRA_DEQ_DFETAP_CTRL_PREG}, 2137 {0x0001, SIERRA_DFE_EN_1010_IGNORE_PREG}, 2138 {0x3C01, SIERRA_DEQ_TAU_CTRL1_FAST_MAINT_PREG}, 2139 {0x3C40, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG}, 2140 {0x1C08, SIERRA_DEQ_TAU_CTRL2_PREG}, 2141 {0x0033, SIERRA_DEQ_PICTRL_PREG}, 2142 {0x0400, SIERRA_CPICAL_TMRVAL_MODE1_PREG}, 2143 {0x0330, SIERRA_CPICAL_TMRVAL_MODE0_PREG}, 2144 {0x01FF, SIERRA_CPICAL_PICNT_MODE1_PREG}, 2145 {0x0009, SIERRA_CPI_OUTBUF_RATESEL_PREG}, 2146 {0x3232, SIERRA_CPICAL_RES_STARTCODE_MODE23_PREG}, 2147 {0x0005, SIERRA_LFPSDET_SUPPORT_PREG}, 2148 {0x000F, SIERRA_LFPSFILT_NS_PREG}, 2149 {0x0009, SIERRA_LFPSFILT_RD_PREG}, 2150 {0x0001, SIERRA_LFPSFILT_MP_PREG}, 2151 {0x6013, SIERRA_SIGDET_SUPPORT_PREG}, 2152 {0x8013, SIERRA_SDFILT_H2L_A_PREG}, 2153 {0x8009, SIERRA_SDFILT_L2H_PREG}, 2154 {0x0024, SIERRA_RXBUFFER_CTLECTRL_PREG}, 2155 {0x0020, SIERRA_RXBUFFER_RCDFECTRL_PREG}, 2156 {0x4243, SIERRA_RXBUFFER_DFECTRL_PREG} 2157 }; 2158 2159 static struct cdns_sierra_vals usb_100_ext_ssc_cmn_vals = { 2160 .reg_pairs = cdns_usb_cmn_regs_ext_ssc, 2161 .num_regs = ARRAY_SIZE(cdns_usb_cmn_regs_ext_ssc), 2162 }; 2163 2164 static struct cdns_sierra_vals usb_100_ext_ssc_ln_vals = { 2165 .reg_pairs = cdns_usb_ln_regs_ext_ssc, 2166 .num_regs = ARRAY_SIZE(cdns_usb_ln_regs_ext_ssc), 2167 }; 2168 2169 static const struct cdns_sierra_data cdns_map_sierra = { 2170 .id_value = SIERRA_MACRO_ID, 2171 .block_offset_shift = 0x2, 2172 .reg_offset_shift = 0x2, 2173 .pcs_cmn_vals = { 2174 [TYPE_PCIE] = { 2175 [TYPE_NONE] = { 2176 [NO_SSC] = &pcie_phy_pcs_cmn_vals, 2177 [EXTERNAL_SSC] = &pcie_phy_pcs_cmn_vals, 2178 [INTERNAL_SSC] = &pcie_phy_pcs_cmn_vals, 2179 }, 2180 [TYPE_QSGMII] = { 2181 [NO_SSC] = &pcie_phy_pcs_cmn_vals, 2182 [EXTERNAL_SSC] = &pcie_phy_pcs_cmn_vals, 2183 [INTERNAL_SSC] = &pcie_phy_pcs_cmn_vals, 2184 }, 2185 }, 2186 }, 2187 .pma_cmn_vals = { 2188 [TYPE_PCIE] = { 2189 [TYPE_NONE] = { 2190 [NO_SSC] = &pcie_100_no_ssc_cmn_vals, 2191 [EXTERNAL_SSC] = &pcie_100_ext_ssc_cmn_vals, 2192 [INTERNAL_SSC] = &pcie_100_int_ssc_cmn_vals, 2193 }, 2194 [TYPE_QSGMII] = { 2195 [NO_SSC] = &pcie_100_no_ssc_plllc_cmn_vals, 2196 [EXTERNAL_SSC] = &pcie_100_ext_ssc_plllc_cmn_vals, 2197 [INTERNAL_SSC] = &pcie_100_int_ssc_plllc_cmn_vals, 2198 }, 2199 }, 2200 [TYPE_USB] = { 2201 [TYPE_NONE] = { 2202 [EXTERNAL_SSC] = &usb_100_ext_ssc_cmn_vals, 2203 }, 2204 }, 2205 [TYPE_QSGMII] = { 2206 [TYPE_PCIE] = { 2207 [NO_SSC] = &qsgmii_100_no_ssc_plllc1_cmn_vals, 2208 [EXTERNAL_SSC] = &qsgmii_100_no_ssc_plllc1_cmn_vals, 2209 [INTERNAL_SSC] = &qsgmii_100_no_ssc_plllc1_cmn_vals, 2210 }, 2211 }, 2212 }, 2213 .pma_ln_vals = { 2214 [TYPE_PCIE] = { 2215 [TYPE_NONE] = { 2216 [NO_SSC] = &pcie_100_no_ssc_ln_vals, 2217 [EXTERNAL_SSC] = &pcie_100_ext_ssc_ln_vals, 2218 [INTERNAL_SSC] = &pcie_100_int_ssc_ln_vals, 2219 }, 2220 [TYPE_QSGMII] = { 2221 [NO_SSC] = &ml_pcie_100_no_ssc_ln_vals, 2222 [EXTERNAL_SSC] = &ml_pcie_100_ext_ssc_ln_vals, 2223 [INTERNAL_SSC] = &ml_pcie_100_int_ssc_ln_vals, 2224 }, 2225 }, 2226 [TYPE_USB] = { 2227 [TYPE_NONE] = { 2228 [EXTERNAL_SSC] = &usb_100_ext_ssc_ln_vals, 2229 }, 2230 }, 2231 [TYPE_QSGMII] = { 2232 [TYPE_PCIE] = { 2233 [NO_SSC] = &qsgmii_100_no_ssc_plllc1_ln_vals, 2234 [EXTERNAL_SSC] = &qsgmii_100_no_ssc_plllc1_ln_vals, 2235 [INTERNAL_SSC] = &qsgmii_100_no_ssc_plllc1_ln_vals, 2236 }, 2237 }, 2238 }, 2239 }; 2240 2241 static const struct cdns_sierra_data cdns_ti_map_sierra = { 2242 .id_value = SIERRA_MACRO_ID, 2243 .block_offset_shift = 0x0, 2244 .reg_offset_shift = 0x1, 2245 .pcs_cmn_vals = { 2246 [TYPE_PCIE] = { 2247 [TYPE_NONE] = { 2248 [NO_SSC] = &pcie_phy_pcs_cmn_vals, 2249 [EXTERNAL_SSC] = &pcie_phy_pcs_cmn_vals, 2250 [INTERNAL_SSC] = &pcie_phy_pcs_cmn_vals, 2251 }, 2252 [TYPE_QSGMII] = { 2253 [NO_SSC] = &pcie_phy_pcs_cmn_vals, 2254 [EXTERNAL_SSC] = &pcie_phy_pcs_cmn_vals, 2255 [INTERNAL_SSC] = &pcie_phy_pcs_cmn_vals, 2256 }, 2257 }, 2258 }, 2259 .phy_pma_ln_vals = { 2260 [TYPE_QSGMII] = { 2261 [TYPE_PCIE] = { 2262 [NO_SSC] = &qsgmii_phy_pma_ln_vals, 2263 [EXTERNAL_SSC] = &qsgmii_phy_pma_ln_vals, 2264 [INTERNAL_SSC] = &qsgmii_phy_pma_ln_vals, 2265 }, 2266 }, 2267 }, 2268 .pma_cmn_vals = { 2269 [TYPE_PCIE] = { 2270 [TYPE_NONE] = { 2271 [NO_SSC] = &pcie_100_no_ssc_cmn_vals, 2272 [EXTERNAL_SSC] = &pcie_100_ext_ssc_cmn_vals, 2273 [INTERNAL_SSC] = &pcie_100_int_ssc_cmn_vals, 2274 }, 2275 [TYPE_QSGMII] = { 2276 [NO_SSC] = &pcie_100_no_ssc_plllc_cmn_vals, 2277 [EXTERNAL_SSC] = &pcie_100_ext_ssc_plllc_cmn_vals, 2278 [INTERNAL_SSC] = &pcie_100_int_ssc_plllc_cmn_vals, 2279 }, 2280 }, 2281 [TYPE_USB] = { 2282 [TYPE_NONE] = { 2283 [EXTERNAL_SSC] = &usb_100_ext_ssc_cmn_vals, 2284 }, 2285 }, 2286 [TYPE_QSGMII] = { 2287 [TYPE_PCIE] = { 2288 [NO_SSC] = &qsgmii_100_no_ssc_plllc1_cmn_vals, 2289 [EXTERNAL_SSC] = &qsgmii_100_no_ssc_plllc1_cmn_vals, 2290 [INTERNAL_SSC] = &qsgmii_100_no_ssc_plllc1_cmn_vals, 2291 }, 2292 }, 2293 }, 2294 .pma_ln_vals = { 2295 [TYPE_PCIE] = { 2296 [TYPE_NONE] = { 2297 [NO_SSC] = &pcie_100_no_ssc_ln_vals, 2298 [EXTERNAL_SSC] = &pcie_100_ext_ssc_ln_vals, 2299 [INTERNAL_SSC] = &pcie_100_int_ssc_ln_vals, 2300 }, 2301 [TYPE_QSGMII] = { 2302 [NO_SSC] = &ml_pcie_100_no_ssc_ln_vals, 2303 [EXTERNAL_SSC] = &ml_pcie_100_ext_ssc_ln_vals, 2304 [INTERNAL_SSC] = &ml_pcie_100_int_ssc_ln_vals, 2305 }, 2306 }, 2307 [TYPE_USB] = { 2308 [TYPE_NONE] = { 2309 [EXTERNAL_SSC] = &usb_100_ext_ssc_ln_vals, 2310 }, 2311 }, 2312 [TYPE_QSGMII] = { 2313 [TYPE_PCIE] = { 2314 [NO_SSC] = &qsgmii_100_no_ssc_plllc1_ln_vals, 2315 [EXTERNAL_SSC] = &qsgmii_100_no_ssc_plllc1_ln_vals, 2316 [INTERNAL_SSC] = &qsgmii_100_no_ssc_plllc1_ln_vals, 2317 }, 2318 }, 2319 }, 2320 }; 2321 2322 static const struct of_device_id cdns_sierra_id_table[] = { 2323 { 2324 .compatible = "cdns,sierra-phy-t0", 2325 .data = &cdns_map_sierra, 2326 }, 2327 { 2328 .compatible = "ti,sierra-phy-t0", 2329 .data = &cdns_ti_map_sierra, 2330 }, 2331 {} 2332 }; 2333 MODULE_DEVICE_TABLE(of, cdns_sierra_id_table); 2334 2335 static struct platform_driver cdns_sierra_driver = { 2336 .probe = cdns_sierra_phy_probe, 2337 .remove = cdns_sierra_phy_remove, 2338 .driver = { 2339 .name = "cdns-sierra-phy", 2340 .of_match_table = cdns_sierra_id_table, 2341 }, 2342 }; 2343 module_platform_driver(cdns_sierra_driver); 2344 2345 MODULE_ALIAS("platform:cdns_sierra"); 2346 MODULE_AUTHOR("Cadence Design Systems"); 2347 MODULE_DESCRIPTION("CDNS sierra phy driver"); 2348 MODULE_LICENSE("GPL v2"); 2349