1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * Cadence Torrent SD0801 PHY driver.
4 *
5 * Copyright 2018 Cadence Design Systems, Inc.
6 *
7 */
8
9 #include <dt-bindings/phy/phy.h>
10 #include <dt-bindings/phy/phy-cadence.h>
11 #include <linux/clk.h>
12 #include <linux/clk-provider.h>
13 #include <linux/delay.h>
14 #include <linux/err.h>
15 #include <linux/io.h>
16 #include <linux/iopoll.h>
17 #include <linux/kernel.h>
18 #include <linux/module.h>
19 #include <linux/of.h>
20 #include <linux/phy/phy.h>
21 #include <linux/platform_device.h>
22 #include <linux/reset.h>
23 #include <linux/regmap.h>
24
25 #define REF_CLK_19_2MHZ 19200000
26 #define REF_CLK_25MHZ 25000000
27 #define REF_CLK_100MHZ 100000000
28 #define REF_CLK_156_25MHZ 156250000
29
30 #define MAX_NUM_LANES 4
31 #define DEFAULT_MAX_BIT_RATE 8100 /* in Mbps */
32
33 #define POLL_TIMEOUT_US 5000
34 #define PLL_LOCK_TIMEOUT 100000
35
36 #define DP_PLL0 BIT(0)
37 #define DP_PLL1 BIT(1)
38
39 #define TORRENT_COMMON_CDB_OFFSET 0x0
40
41 #define TORRENT_TX_LANE_CDB_OFFSET(ln, block_offset, reg_offset) \
42 ((0x4000 << (block_offset)) + \
43 (((ln) << 9) << (reg_offset)))
44
45 #define TORRENT_RX_LANE_CDB_OFFSET(ln, block_offset, reg_offset) \
46 ((0x8000 << (block_offset)) + \
47 (((ln) << 9) << (reg_offset)))
48
49 #define TORRENT_PHY_PCS_COMMON_OFFSET(block_offset) \
50 (0xC000 << (block_offset))
51
52 #define TORRENT_PHY_PCS_LANE_CDB_OFFSET(ln, block_offset, reg_offset) \
53 ((0xD000 << (block_offset)) + \
54 (((ln) << 8) << (reg_offset)))
55
56 #define TORRENT_PHY_PMA_COMMON_OFFSET(block_offset) \
57 (0xE000 << (block_offset))
58
59 #define TORRENT_DPTX_PHY_OFFSET 0x0
60
61 /*
62 * register offsets from DPTX PHY register block base (i.e MHDP
63 * register base + 0x30a00)
64 */
65 #define PHY_AUX_CTRL 0x04
66 #define PHY_RESET 0x20
67 #define PMA_TX_ELEC_IDLE_SHIFT 4
68 #define PHY_PMA_XCVR_PLLCLK_EN 0x24
69 #define PHY_PMA_XCVR_PLLCLK_EN_ACK 0x28
70 #define PHY_PMA_XCVR_POWER_STATE_REQ 0x2c
71 #define PHY_POWER_STATE_LN(ln) ((ln) * 8)
72 #define PMA_XCVR_POWER_STATE_REQ_LN_MASK 0x3FU
73 #define PHY_PMA_XCVR_POWER_STATE_ACK 0x30
74 #define PHY_PMA_CMN_READY 0x34
75
76 /*
77 * register offsets from SD0801 PHY register block base (i.e MHDP
78 * register base + 0x500000)
79 */
80 #define CMN_SSM_BANDGAP_TMR 0x0021U
81 #define CMN_SSM_BIAS_TMR 0x0022U
82 #define CMN_PLLSM0_PLLPRE_TMR 0x002AU
83 #define CMN_PLLSM0_PLLLOCK_TMR 0x002CU
84 #define CMN_PLLSM1_PLLPRE_TMR 0x0032U
85 #define CMN_PLLSM1_PLLLOCK_TMR 0x0034U
86 #define CMN_CDIAG_CDB_PWRI_OVRD 0x0041U
87 #define CMN_CDIAG_XCVRC_PWRI_OVRD 0x0047U
88 #define CMN_CDIAG_REFCLK_OVRD 0x004CU
89 #define CMN_CDIAG_REFCLK_DRV0_CTRL 0x0050U
90 #define CMN_BGCAL_INIT_TMR 0x0064U
91 #define CMN_BGCAL_ITER_TMR 0x0065U
92 #define CMN_IBCAL_INIT_TMR 0x0074U
93 #define CMN_PLL0_VCOCAL_TCTRL 0x0082U
94 #define CMN_PLL0_VCOCAL_INIT_TMR 0x0084U
95 #define CMN_PLL0_VCOCAL_ITER_TMR 0x0085U
96 #define CMN_PLL0_VCOCAL_REFTIM_START 0x0086U
97 #define CMN_PLL0_VCOCAL_PLLCNT_START 0x0088U
98 #define CMN_PLL0_INTDIV_M0 0x0090U
99 #define CMN_PLL0_FRACDIVL_M0 0x0091U
100 #define CMN_PLL0_FRACDIVH_M0 0x0092U
101 #define CMN_PLL0_HIGH_THR_M0 0x0093U
102 #define CMN_PLL0_DSM_DIAG_M0 0x0094U
103 #define CMN_PLL0_DSM_FBH_OVRD_M0 0x0095U
104 #define CMN_PLL0_DSM_FBL_OVRD_M0 0x0096U
105 #define CMN_PLL0_SS_CTRL1_M0 0x0098U
106 #define CMN_PLL0_SS_CTRL2_M0 0x0099U
107 #define CMN_PLL0_SS_CTRL3_M0 0x009AU
108 #define CMN_PLL0_SS_CTRL4_M0 0x009BU
109 #define CMN_PLL0_LOCK_REFCNT_START 0x009CU
110 #define CMN_PLL0_LOCK_PLLCNT_START 0x009EU
111 #define CMN_PLL0_LOCK_PLLCNT_THR 0x009FU
112 #define CMN_PLL0_INTDIV_M1 0x00A0U
113 #define CMN_PLL0_FRACDIVH_M1 0x00A2U
114 #define CMN_PLL0_HIGH_THR_M1 0x00A3U
115 #define CMN_PLL0_DSM_DIAG_M1 0x00A4U
116 #define CMN_PLL0_SS_CTRL1_M1 0x00A8U
117 #define CMN_PLL0_SS_CTRL2_M1 0x00A9U
118 #define CMN_PLL0_SS_CTRL3_M1 0x00AAU
119 #define CMN_PLL0_SS_CTRL4_M1 0x00ABU
120 #define CMN_PLL1_VCOCAL_TCTRL 0x00C2U
121 #define CMN_PLL1_VCOCAL_INIT_TMR 0x00C4U
122 #define CMN_PLL1_VCOCAL_ITER_TMR 0x00C5U
123 #define CMN_PLL1_VCOCAL_REFTIM_START 0x00C6U
124 #define CMN_PLL1_VCOCAL_PLLCNT_START 0x00C8U
125 #define CMN_PLL1_INTDIV_M0 0x00D0U
126 #define CMN_PLL1_FRACDIVL_M0 0x00D1U
127 #define CMN_PLL1_FRACDIVH_M0 0x00D2U
128 #define CMN_PLL1_HIGH_THR_M0 0x00D3U
129 #define CMN_PLL1_DSM_DIAG_M0 0x00D4U
130 #define CMN_PLL1_DSM_FBH_OVRD_M0 0x00D5U
131 #define CMN_PLL1_DSM_FBL_OVRD_M0 0x00D6U
132 #define CMN_PLL1_SS_CTRL1_M0 0x00D8U
133 #define CMN_PLL1_SS_CTRL2_M0 0x00D9U
134 #define CMN_PLL1_SS_CTRL3_M0 0x00DAU
135 #define CMN_PLL1_SS_CTRL4_M0 0x00DBU
136 #define CMN_PLL1_LOCK_REFCNT_START 0x00DCU
137 #define CMN_PLL1_LOCK_PLLCNT_START 0x00DEU
138 #define CMN_PLL1_LOCK_PLLCNT_THR 0x00DFU
139 #define CMN_TXPUCAL_TUNE 0x0103U
140 #define CMN_TXPUCAL_INIT_TMR 0x0104U
141 #define CMN_TXPUCAL_ITER_TMR 0x0105U
142 #define CMN_TXPDCAL_TUNE 0x010BU
143 #define CMN_TXPDCAL_INIT_TMR 0x010CU
144 #define CMN_TXPDCAL_ITER_TMR 0x010DU
145 #define CMN_RXCAL_INIT_TMR 0x0114U
146 #define CMN_RXCAL_ITER_TMR 0x0115U
147 #define CMN_SD_CAL_INIT_TMR 0x0124U
148 #define CMN_SD_CAL_ITER_TMR 0x0125U
149 #define CMN_SD_CAL_REFTIM_START 0x0126U
150 #define CMN_SD_CAL_PLLCNT_START 0x0128U
151 #define CMN_PDIAG_PLL0_CTRL_M0 0x01A0U
152 #define CMN_PDIAG_PLL0_CLK_SEL_M0 0x01A1U
153 #define CMN_PDIAG_PLL0_CP_PADJ_M0 0x01A4U
154 #define CMN_PDIAG_PLL0_CP_IADJ_M0 0x01A5U
155 #define CMN_PDIAG_PLL0_FILT_PADJ_M0 0x01A6U
156 #define CMN_PDIAG_PLL0_CTRL_M1 0x01B0U
157 #define CMN_PDIAG_PLL0_CLK_SEL_M1 0x01B1U
158 #define CMN_PDIAG_PLL0_CP_PADJ_M1 0x01B4U
159 #define CMN_PDIAG_PLL0_CP_IADJ_M1 0x01B5U
160 #define CMN_PDIAG_PLL0_FILT_PADJ_M1 0x01B6U
161 #define CMN_PDIAG_PLL1_CTRL_M0 0x01C0U
162 #define CMN_PDIAG_PLL1_CLK_SEL_M0 0x01C1U
163 #define CMN_PDIAG_PLL1_CP_PADJ_M0 0x01C4U
164 #define CMN_PDIAG_PLL1_CP_IADJ_M0 0x01C5U
165 #define CMN_PDIAG_PLL1_FILT_PADJ_M0 0x01C6U
166 #define CMN_DIAG_BIAS_OVRD1 0x01E1U
167
168 /* PMA TX Lane registers */
169 #define TX_TXCC_CTRL 0x0040U
170 #define TX_TXCC_CPOST_MULT_00 0x004CU
171 #define TX_TXCC_CPOST_MULT_01 0x004DU
172 #define TX_TXCC_MGNFS_MULT_000 0x0050U
173 #define TX_TXCC_MGNFS_MULT_100 0x0054U
174 #define DRV_DIAG_TX_DRV 0x00C6U
175 #define XCVR_DIAG_PLLDRC_CTRL 0x00E5U
176 #define XCVR_DIAG_HSCLK_SEL 0x00E6U
177 #define XCVR_DIAG_HSCLK_DIV 0x00E7U
178 #define XCVR_DIAG_RXCLK_CTRL 0x00E9U
179 #define XCVR_DIAG_BIDI_CTRL 0x00EAU
180 #define XCVR_DIAG_PSC_OVRD 0x00EBU
181 #define TX_PSC_A0 0x0100U
182 #define TX_PSC_A1 0x0101U
183 #define TX_PSC_A2 0x0102U
184 #define TX_PSC_A3 0x0103U
185 #define TX_RCVDET_ST_TMR 0x0123U
186 #define TX_DIAG_ACYA 0x01E7U
187 #define TX_DIAG_ACYA_HBDC_MASK 0x0001U
188
189 /* PMA RX Lane registers */
190 #define RX_PSC_A0 0x0000U
191 #define RX_PSC_A1 0x0001U
192 #define RX_PSC_A2 0x0002U
193 #define RX_PSC_A3 0x0003U
194 #define RX_PSC_CAL 0x0006U
195 #define RX_SDCAL0_INIT_TMR 0x0044U
196 #define RX_SDCAL0_ITER_TMR 0x0045U
197 #define RX_SDCAL1_INIT_TMR 0x004CU
198 #define RX_SDCAL1_ITER_TMR 0x004DU
199 #define RX_CDRLF_CNFG 0x0080U
200 #define RX_CDRLF_CNFG2 0x0081U
201 #define RX_CDRLF_CNFG3 0x0082U
202 #define RX_SIGDET_HL_FILT_TMR 0x0090U
203 #define RX_REE_GCSM1_CTRL 0x0108U
204 #define RX_REE_GCSM1_EQENM_PH1 0x0109U
205 #define RX_REE_GCSM1_EQENM_PH2 0x010AU
206 #define RX_REE_GCSM2_CTRL 0x0110U
207 #define RX_REE_PERGCSM_CTRL 0x0118U
208 #define RX_REE_PEAK_UTHR 0x0142U
209 #define RX_REE_PEAK_LTHR 0x0143U
210 #define RX_REE_ATTEN_THR 0x0149U
211 #define RX_REE_TAP1_CLIP 0x0171U
212 #define RX_REE_TAP2TON_CLIP 0x0172U
213 #define RX_REE_SMGM_CTRL1 0x0177U
214 #define RX_REE_SMGM_CTRL2 0x0178U
215 #define RX_DIAG_DFE_CTRL 0x01E0U
216 #define RX_DIAG_DFE_AMP_TUNE_2 0x01E2U
217 #define RX_DIAG_DFE_AMP_TUNE_3 0x01E3U
218 #define RX_DIAG_REE_DAC_CTRL 0x01E4U
219 #define RX_DIAG_NQST_CTRL 0x01E5U
220 #define RX_DIAG_SIGDET_TUNE 0x01E8U
221 #define RX_DIAG_PI_RATE 0x01F4U
222 #define RX_DIAG_PI_CAP 0x01F5U
223 #define RX_DIAG_ACYA 0x01FFU
224
225 /* PHY PCS common registers */
226 #define PHY_PIPE_CMN_CTRL1 0x0000U
227 #define PHY_PLL_CFG 0x000EU
228 #define PHY_PIPE_USB3_GEN2_PRE_CFG0 0x0020U
229 #define PHY_PIPE_USB3_GEN2_POST_CFG0 0x0022U
230 #define PHY_PIPE_USB3_GEN2_POST_CFG1 0x0023U
231
232 /* PHY PCS lane registers */
233 #define PHY_PCS_ISO_LINK_CTRL 0x000BU
234
235 /* PHY PMA common registers */
236 #define PHY_PMA_CMN_CTRL1 0x0000U
237 #define PHY_PMA_CMN_CTRL2 0x0001U
238 #define PHY_PMA_PLL_RAW_CTRL 0x0003U
239
240 #define CDNS_TORRENT_OUTPUT_CLOCKS 3
241
242 static const char * const clk_names[] = {
243 [CDNS_TORRENT_REFCLK_DRIVER] = "refclk-driver",
244 [CDNS_TORRENT_DERIVED_REFCLK] = "refclk-der",
245 [CDNS_TORRENT_RECEIVED_REFCLK] = "refclk-rec",
246 };
247
248 static const struct reg_field phy_pll_cfg =
249 REG_FIELD(PHY_PLL_CFG, 0, 1);
250
251 static const struct reg_field phy_pma_cmn_ctrl_1 =
252 REG_FIELD(PHY_PMA_CMN_CTRL1, 0, 0);
253
254 static const struct reg_field phy_pma_cmn_ctrl_2 =
255 REG_FIELD(PHY_PMA_CMN_CTRL2, 0, 7);
256
257 static const struct reg_field phy_pma_pll_raw_ctrl =
258 REG_FIELD(PHY_PMA_PLL_RAW_CTRL, 0, 1);
259
260 static const struct reg_field phy_reset_ctrl =
261 REG_FIELD(PHY_RESET, 8, 8);
262
263 static const struct reg_field phy_pcs_iso_link_ctrl_1 =
264 REG_FIELD(PHY_PCS_ISO_LINK_CTRL, 1, 1);
265
266 static const struct reg_field phy_pipe_cmn_ctrl1_0 = REG_FIELD(PHY_PIPE_CMN_CTRL1, 0, 0);
267
268 static const struct reg_field cmn_cdiag_refclk_ovrd_4 =
269 REG_FIELD(CMN_CDIAG_REFCLK_OVRD, 4, 4);
270
271 #define REFCLK_OUT_NUM_CMN_CONFIG 4
272
273 enum cdns_torrent_refclk_out_cmn {
274 CMN_CDIAG_REFCLK_DRV0_CTRL_1,
275 CMN_CDIAG_REFCLK_DRV0_CTRL_4,
276 CMN_CDIAG_REFCLK_DRV0_CTRL_5,
277 CMN_CDIAG_REFCLK_DRV0_CTRL_6,
278 };
279
280 static const struct reg_field refclk_out_cmn_cfg[] = {
281 [CMN_CDIAG_REFCLK_DRV0_CTRL_1] = REG_FIELD(CMN_CDIAG_REFCLK_DRV0_CTRL, 1, 1),
282 [CMN_CDIAG_REFCLK_DRV0_CTRL_4] = REG_FIELD(CMN_CDIAG_REFCLK_DRV0_CTRL, 4, 4),
283 [CMN_CDIAG_REFCLK_DRV0_CTRL_5] = REG_FIELD(CMN_CDIAG_REFCLK_DRV0_CTRL, 5, 5),
284 [CMN_CDIAG_REFCLK_DRV0_CTRL_6] = REG_FIELD(CMN_CDIAG_REFCLK_DRV0_CTRL, 6, 6),
285 };
286
287 static const int refclk_driver_parent_index[] = {
288 CDNS_TORRENT_DERIVED_REFCLK,
289 CDNS_TORRENT_RECEIVED_REFCLK
290 };
291
292 static const u32 cdns_torrent_refclk_driver_mux_table[] = { 1, 0 };
293
294 enum cdns_torrent_phy_type {
295 TYPE_NONE,
296 TYPE_DP,
297 TYPE_PCIE,
298 TYPE_SGMII,
299 TYPE_QSGMII,
300 TYPE_USB,
301 TYPE_USXGMII,
302 TYPE_PCIE_ML,
303 };
304
305 enum cdns_torrent_ref_clk {
306 CLK_19_2_MHZ,
307 CLK_25_MHZ,
308 CLK_100_MHZ,
309 CLK_156_25_MHZ,
310 CLK_ANY,
311 };
312
313 enum cdns_torrent_ssc_mode {
314 NO_SSC,
315 EXTERNAL_SSC,
316 INTERNAL_SSC,
317 ANY_SSC,
318 };
319
320 /* Unique key id for vals table entry
321 * REFCLK0_RATE | REFCLK1_RATE | LINK0_TYPE | LINK1_TYPE | SSC_TYPE
322 */
323 #define REFCLK0_SHIFT 12
324 #define REFCLK0_MASK GENMASK(14, 12)
325 #define REFCLK1_SHIFT 9
326 #define REFCLK1_MASK GENMASK(11, 9)
327 #define LINK0_SHIFT 6
328 #define LINK0_MASK GENMASK(8, 6)
329 #define LINK1_SHIFT 3
330 #define LINK1_MASK GENMASK(5, 3)
331 #define SSC_SHIFT 0
332 #define SSC_MASK GENMASK(2, 0)
333
334 #define CDNS_TORRENT_KEY(refclk0, refclk1, link0, link1, ssc) \
335 ((((refclk0) << REFCLK0_SHIFT) & REFCLK0_MASK) | \
336 (((refclk1) << REFCLK1_SHIFT) & REFCLK1_MASK) | \
337 (((link0) << LINK0_SHIFT) & LINK0_MASK) | \
338 (((link1) << LINK1_SHIFT) & LINK1_MASK) | \
339 (((ssc) << SSC_SHIFT) & SSC_MASK))
340
341 #define CDNS_TORRENT_KEY_ANYCLK(link0, link1) \
342 CDNS_TORRENT_KEY(CLK_ANY, CLK_ANY, \
343 (link0), (link1), ANY_SSC)
344
345 struct cdns_torrent_inst {
346 struct phy *phy;
347 u32 mlane;
348 enum cdns_torrent_phy_type phy_type;
349 u32 num_lanes;
350 struct reset_control *lnk_rst;
351 enum cdns_torrent_ssc_mode ssc_mode;
352 };
353
354 struct cdns_torrent_phy {
355 void __iomem *base; /* DPTX registers base */
356 void __iomem *sd_base; /* SD0801 registers base */
357 u32 max_bit_rate; /* Maximum link bit rate to use (in Mbps) */
358 u32 dp_pll;
359 u32 protocol_bitmask;
360 struct reset_control *phy_rst;
361 struct reset_control *apb_rst;
362 struct device *dev;
363 struct clk *clk;
364 struct clk *clk1;
365 enum cdns_torrent_ref_clk ref_clk_rate;
366 enum cdns_torrent_ref_clk ref_clk1_rate;
367 struct cdns_torrent_inst phys[MAX_NUM_LANES];
368 int nsubnodes;
369 int already_configured;
370 const struct cdns_torrent_data *init_data;
371 struct regmap *regmap_common_cdb;
372 struct regmap *regmap_phy_pcs_common_cdb;
373 struct regmap *regmap_phy_pma_common_cdb;
374 struct regmap *regmap_tx_lane_cdb[MAX_NUM_LANES];
375 struct regmap *regmap_rx_lane_cdb[MAX_NUM_LANES];
376 struct regmap *regmap_phy_pcs_lane_cdb[MAX_NUM_LANES];
377 struct regmap *regmap_dptx_phy_reg;
378 struct regmap_field *phy_pll_cfg;
379 struct regmap_field *phy_pipe_cmn_ctrl1_0;
380 struct regmap_field *cmn_cdiag_refclk_ovrd_4;
381 struct regmap_field *phy_pma_cmn_ctrl_1;
382 struct regmap_field *phy_pma_cmn_ctrl_2;
383 struct regmap_field *phy_pma_pll_raw_ctrl;
384 struct regmap_field *phy_reset_ctrl;
385 struct regmap_field *phy_pcs_iso_link_ctrl_1[MAX_NUM_LANES];
386 struct clk_hw_onecell_data *clk_hw_data;
387 };
388
389 enum phy_powerstate {
390 POWERSTATE_A0 = 0,
391 /* Powerstate A1 is unused */
392 POWERSTATE_A2 = 2,
393 POWERSTATE_A3 = 3,
394 };
395
396 struct cdns_torrent_refclk_driver {
397 struct clk_hw hw;
398 struct regmap_field *cmn_fields[REFCLK_OUT_NUM_CMN_CONFIG];
399 struct clk_init_data clk_data;
400 };
401
402 #define to_cdns_torrent_refclk_driver(_hw) \
403 container_of(_hw, struct cdns_torrent_refclk_driver, hw)
404
405 struct cdns_torrent_derived_refclk {
406 struct clk_hw hw;
407 struct regmap_field *phy_pipe_cmn_ctrl1_0;
408 struct regmap_field *cmn_cdiag_refclk_ovrd_4;
409 struct clk_init_data clk_data;
410 };
411
412 #define to_cdns_torrent_derived_refclk(_hw) \
413 container_of(_hw, struct cdns_torrent_derived_refclk, hw)
414
415 struct cdns_torrent_received_refclk {
416 struct clk_hw hw;
417 struct regmap_field *phy_pipe_cmn_ctrl1_0;
418 struct regmap_field *cmn_cdiag_refclk_ovrd_4;
419 struct clk_init_data clk_data;
420 };
421
422 #define to_cdns_torrent_received_refclk(_hw) \
423 container_of(_hw, struct cdns_torrent_received_refclk, hw)
424
425 struct cdns_reg_pairs {
426 u32 val;
427 u32 off;
428 };
429
430 struct cdns_torrent_vals {
431 const struct cdns_reg_pairs *reg_pairs;
432 u32 num_regs;
433 };
434
435 struct cdns_torrent_vals_entry {
436 u32 key;
437 const struct cdns_torrent_vals *vals;
438 };
439
440 struct cdns_torrent_vals_table {
441 const struct cdns_torrent_vals_entry *entries;
442 u32 num_entries;
443 };
444
445 struct cdns_torrent_data {
446 u8 block_offset_shift;
447 u8 reg_offset_shift;
448 struct cdns_torrent_vals_table link_cmn_vals_tbl;
449 struct cdns_torrent_vals_table xcvr_diag_vals_tbl;
450 struct cdns_torrent_vals_table pcs_cmn_vals_tbl;
451 struct cdns_torrent_vals_table phy_pma_cmn_vals_tbl;
452 struct cdns_torrent_vals_table cmn_vals_tbl;
453 struct cdns_torrent_vals_table tx_ln_vals_tbl;
454 struct cdns_torrent_vals_table rx_ln_vals_tbl;
455 };
456
457 struct cdns_regmap_cdb_context {
458 struct device *dev;
459 void __iomem *base;
460 u8 reg_offset_shift;
461 };
462
cdns_torrent_get_tbl_vals(const struct cdns_torrent_vals_table * tbl,enum cdns_torrent_ref_clk refclk0,enum cdns_torrent_ref_clk refclk1,enum cdns_torrent_phy_type link0,enum cdns_torrent_phy_type link1,enum cdns_torrent_ssc_mode ssc)463 static const struct cdns_torrent_vals *cdns_torrent_get_tbl_vals(const struct cdns_torrent_vals_table *tbl,
464 enum cdns_torrent_ref_clk refclk0,
465 enum cdns_torrent_ref_clk refclk1,
466 enum cdns_torrent_phy_type link0,
467 enum cdns_torrent_phy_type link1,
468 enum cdns_torrent_ssc_mode ssc)
469 {
470 int i;
471 u32 key = CDNS_TORRENT_KEY(refclk0, refclk1, link0, link1, ssc);
472
473 for (i = 0; i < tbl->num_entries; i++) {
474 if (tbl->entries[i].key == key)
475 return tbl->entries[i].vals;
476 }
477
478 return NULL;
479 }
480
cdns_regmap_write(void * context,unsigned int reg,unsigned int val)481 static int cdns_regmap_write(void *context, unsigned int reg, unsigned int val)
482 {
483 struct cdns_regmap_cdb_context *ctx = context;
484 u32 offset = reg << ctx->reg_offset_shift;
485
486 writew(val, ctx->base + offset);
487
488 return 0;
489 }
490
cdns_regmap_read(void * context,unsigned int reg,unsigned int * val)491 static int cdns_regmap_read(void *context, unsigned int reg, unsigned int *val)
492 {
493 struct cdns_regmap_cdb_context *ctx = context;
494 u32 offset = reg << ctx->reg_offset_shift;
495
496 *val = readw(ctx->base + offset);
497 return 0;
498 }
499
cdns_regmap_dptx_write(void * context,unsigned int reg,unsigned int val)500 static int cdns_regmap_dptx_write(void *context, unsigned int reg,
501 unsigned int val)
502 {
503 struct cdns_regmap_cdb_context *ctx = context;
504 u32 offset = reg;
505
506 writel(val, ctx->base + offset);
507
508 return 0;
509 }
510
cdns_regmap_dptx_read(void * context,unsigned int reg,unsigned int * val)511 static int cdns_regmap_dptx_read(void *context, unsigned int reg,
512 unsigned int *val)
513 {
514 struct cdns_regmap_cdb_context *ctx = context;
515 u32 offset = reg;
516
517 *val = readl(ctx->base + offset);
518 return 0;
519 }
520
521 #define TORRENT_TX_LANE_CDB_REGMAP_CONF(n) \
522 { \
523 .name = "torrent_tx_lane" n "_cdb", \
524 .reg_stride = 1, \
525 .fast_io = true, \
526 .reg_write = cdns_regmap_write, \
527 .reg_read = cdns_regmap_read, \
528 }
529
530 #define TORRENT_RX_LANE_CDB_REGMAP_CONF(n) \
531 { \
532 .name = "torrent_rx_lane" n "_cdb", \
533 .reg_stride = 1, \
534 .fast_io = true, \
535 .reg_write = cdns_regmap_write, \
536 .reg_read = cdns_regmap_read, \
537 }
538
539 static const struct regmap_config cdns_torrent_tx_lane_cdb_config[] = {
540 TORRENT_TX_LANE_CDB_REGMAP_CONF("0"),
541 TORRENT_TX_LANE_CDB_REGMAP_CONF("1"),
542 TORRENT_TX_LANE_CDB_REGMAP_CONF("2"),
543 TORRENT_TX_LANE_CDB_REGMAP_CONF("3"),
544 };
545
546 static const struct regmap_config cdns_torrent_rx_lane_cdb_config[] = {
547 TORRENT_RX_LANE_CDB_REGMAP_CONF("0"),
548 TORRENT_RX_LANE_CDB_REGMAP_CONF("1"),
549 TORRENT_RX_LANE_CDB_REGMAP_CONF("2"),
550 TORRENT_RX_LANE_CDB_REGMAP_CONF("3"),
551 };
552
553 static const struct regmap_config cdns_torrent_common_cdb_config = {
554 .name = "torrent_common_cdb",
555 .reg_stride = 1,
556 .fast_io = true,
557 .reg_write = cdns_regmap_write,
558 .reg_read = cdns_regmap_read,
559 };
560
561 #define TORRENT_PHY_PCS_LANE_CDB_REGMAP_CONF(n) \
562 { \
563 .name = "torrent_phy_pcs_lane" n "_cdb", \
564 .reg_stride = 1, \
565 .fast_io = true, \
566 .reg_write = cdns_regmap_write, \
567 .reg_read = cdns_regmap_read, \
568 }
569
570 static const struct regmap_config cdns_torrent_phy_pcs_lane_cdb_config[] = {
571 TORRENT_PHY_PCS_LANE_CDB_REGMAP_CONF("0"),
572 TORRENT_PHY_PCS_LANE_CDB_REGMAP_CONF("1"),
573 TORRENT_PHY_PCS_LANE_CDB_REGMAP_CONF("2"),
574 TORRENT_PHY_PCS_LANE_CDB_REGMAP_CONF("3"),
575 };
576
577 static const struct regmap_config cdns_torrent_phy_pcs_cmn_cdb_config = {
578 .name = "torrent_phy_pcs_cmn_cdb",
579 .reg_stride = 1,
580 .fast_io = true,
581 .reg_write = cdns_regmap_write,
582 .reg_read = cdns_regmap_read,
583 };
584
585 static const struct regmap_config cdns_torrent_phy_pma_cmn_cdb_config = {
586 .name = "torrent_phy_pma_cmn_cdb",
587 .reg_stride = 1,
588 .fast_io = true,
589 .reg_write = cdns_regmap_write,
590 .reg_read = cdns_regmap_read,
591 };
592
593 static const struct regmap_config cdns_torrent_dptx_phy_config = {
594 .name = "torrent_dptx_phy",
595 .reg_stride = 1,
596 .fast_io = true,
597 .reg_write = cdns_regmap_dptx_write,
598 .reg_read = cdns_regmap_dptx_read,
599 };
600
601 /* PHY mmr access functions */
602
cdns_torrent_phy_write(struct regmap * regmap,u32 offset,u32 val)603 static void cdns_torrent_phy_write(struct regmap *regmap, u32 offset, u32 val)
604 {
605 regmap_write(regmap, offset, val);
606 }
607
cdns_torrent_phy_read(struct regmap * regmap,u32 offset)608 static u32 cdns_torrent_phy_read(struct regmap *regmap, u32 offset)
609 {
610 unsigned int val;
611
612 regmap_read(regmap, offset, &val);
613 return val;
614 }
615
616 /* DPTX mmr access functions */
617
cdns_torrent_dp_write(struct regmap * regmap,u32 offset,u32 val)618 static void cdns_torrent_dp_write(struct regmap *regmap, u32 offset, u32 val)
619 {
620 regmap_write(regmap, offset, val);
621 }
622
cdns_torrent_dp_read(struct regmap * regmap,u32 offset)623 static u32 cdns_torrent_dp_read(struct regmap *regmap, u32 offset)
624 {
625 u32 val;
626
627 regmap_read(regmap, offset, &val);
628 return val;
629 }
630
631 /*
632 * Structure used to store values of PHY registers for voltage-related
633 * coefficients, for particular voltage swing and pre-emphasis level. Values
634 * are shared across all physical lanes.
635 */
636 struct coefficients {
637 /* Value of DRV_DIAG_TX_DRV register to use */
638 u16 diag_tx_drv;
639 /* Value of TX_TXCC_MGNFS_MULT_000 register to use */
640 u16 mgnfs_mult;
641 /* Value of TX_TXCC_CPOST_MULT_00 register to use */
642 u16 cpost_mult;
643 };
644
645 /*
646 * Array consists of values of voltage-related registers for sd0801 PHY. A value
647 * of 0xFFFF is a placeholder for invalid combination, and will never be used.
648 */
649 static const struct coefficients vltg_coeff[4][4] = {
650 /* voltage swing 0, pre-emphasis 0->3 */
651 { {.diag_tx_drv = 0x0003, .mgnfs_mult = 0x002A,
652 .cpost_mult = 0x0000},
653 {.diag_tx_drv = 0x0003, .mgnfs_mult = 0x001F,
654 .cpost_mult = 0x0014},
655 {.diag_tx_drv = 0x0003, .mgnfs_mult = 0x0012,
656 .cpost_mult = 0x0020},
657 {.diag_tx_drv = 0x0003, .mgnfs_mult = 0x0000,
658 .cpost_mult = 0x002A}
659 },
660
661 /* voltage swing 1, pre-emphasis 0->3 */
662 { {.diag_tx_drv = 0x0003, .mgnfs_mult = 0x001F,
663 .cpost_mult = 0x0000},
664 {.diag_tx_drv = 0x0003, .mgnfs_mult = 0x0013,
665 .cpost_mult = 0x0012},
666 {.diag_tx_drv = 0x0003, .mgnfs_mult = 0x0000,
667 .cpost_mult = 0x001F},
668 {.diag_tx_drv = 0xFFFF, .mgnfs_mult = 0xFFFF,
669 .cpost_mult = 0xFFFF}
670 },
671
672 /* voltage swing 2, pre-emphasis 0->3 */
673 { {.diag_tx_drv = 0x0003, .mgnfs_mult = 0x0013,
674 .cpost_mult = 0x0000},
675 {.diag_tx_drv = 0x0003, .mgnfs_mult = 0x0000,
676 .cpost_mult = 0x0013},
677 {.diag_tx_drv = 0xFFFF, .mgnfs_mult = 0xFFFF,
678 .cpost_mult = 0xFFFF},
679 {.diag_tx_drv = 0xFFFF, .mgnfs_mult = 0xFFFF,
680 .cpost_mult = 0xFFFF}
681 },
682
683 /* voltage swing 3, pre-emphasis 0->3 */
684 { {.diag_tx_drv = 0x0003, .mgnfs_mult = 0x0000,
685 .cpost_mult = 0x0000},
686 {.diag_tx_drv = 0xFFFF, .mgnfs_mult = 0xFFFF,
687 .cpost_mult = 0xFFFF},
688 {.diag_tx_drv = 0xFFFF, .mgnfs_mult = 0xFFFF,
689 .cpost_mult = 0xFFFF},
690 {.diag_tx_drv = 0xFFFF, .mgnfs_mult = 0xFFFF,
691 .cpost_mult = 0xFFFF}
692 }
693 };
694
cdns_torrent_get_phy_type(enum cdns_torrent_phy_type phy_type)695 static const char *cdns_torrent_get_phy_type(enum cdns_torrent_phy_type phy_type)
696 {
697 switch (phy_type) {
698 case TYPE_DP:
699 return "DisplayPort";
700 case TYPE_PCIE:
701 case TYPE_PCIE_ML:
702 return "PCIe";
703 case TYPE_SGMII:
704 return "SGMII";
705 case TYPE_QSGMII:
706 return "QSGMII";
707 case TYPE_USB:
708 return "USB";
709 case TYPE_USXGMII:
710 return "USXGMII";
711 default:
712 return "None";
713 }
714 }
715
716 /*
717 * Set registers responsible for enabling and configuring SSC, with second and
718 * third register values provided by parameters.
719 */
720 static
cdns_torrent_dp_enable_ssc_19_2mhz(struct cdns_torrent_phy * cdns_phy,u32 ctrl2_val,u32 ctrl3_val)721 void cdns_torrent_dp_enable_ssc_19_2mhz(struct cdns_torrent_phy *cdns_phy,
722 u32 ctrl2_val, u32 ctrl3_val)
723 {
724 struct regmap *regmap = cdns_phy->regmap_common_cdb;
725
726 cdns_torrent_phy_write(regmap, CMN_PLL0_SS_CTRL1_M0, 0x0001);
727 cdns_torrent_phy_write(regmap, CMN_PLL0_SS_CTRL1_M0, ctrl2_val);
728 cdns_torrent_phy_write(regmap, CMN_PLL0_SS_CTRL1_M0, ctrl3_val);
729 cdns_torrent_phy_write(regmap, CMN_PLL0_SS_CTRL4_M0, 0x0003);
730 cdns_torrent_phy_write(regmap, CMN_PLL1_SS_CTRL1_M0, 0x0001);
731 cdns_torrent_phy_write(regmap, CMN_PLL1_SS_CTRL1_M0, ctrl2_val);
732 cdns_torrent_phy_write(regmap, CMN_PLL1_SS_CTRL1_M0, ctrl3_val);
733 cdns_torrent_phy_write(regmap, CMN_PLL1_SS_CTRL4_M0, 0x0003);
734 }
735
736 static
cdns_torrent_dp_pma_cmn_vco_cfg_19_2mhz(struct cdns_torrent_phy * cdns_phy,u32 rate,bool ssc)737 void cdns_torrent_dp_pma_cmn_vco_cfg_19_2mhz(struct cdns_torrent_phy *cdns_phy,
738 u32 rate, bool ssc)
739 {
740 struct regmap *regmap = cdns_phy->regmap_common_cdb;
741
742 /* Assumes 19.2 MHz refclock */
743 switch (rate) {
744 /* Setting VCO for 10.8GHz */
745 case 2700:
746 case 5400:
747 cdns_torrent_phy_write(regmap, CMN_PLL0_INTDIV_M0, 0x0119);
748 cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVL_M0, 0x4000);
749 cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVH_M0, 0x0002);
750 cdns_torrent_phy_write(regmap, CMN_PLL0_HIGH_THR_M0, 0x00BC);
751 cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL0_CTRL_M0, 0x0012);
752 cdns_torrent_phy_write(regmap, CMN_PLL1_INTDIV_M0, 0x0119);
753 cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVL_M0, 0x4000);
754 cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVH_M0, 0x0002);
755 cdns_torrent_phy_write(regmap, CMN_PLL1_HIGH_THR_M0, 0x00BC);
756 cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL1_CTRL_M0, 0x0012);
757 if (ssc)
758 cdns_torrent_dp_enable_ssc_19_2mhz(cdns_phy, 0x033A, 0x006A);
759 break;
760 /* Setting VCO for 9.72GHz */
761 case 1620:
762 case 2430:
763 case 3240:
764 cdns_torrent_phy_write(regmap, CMN_PLL0_INTDIV_M0, 0x01FA);
765 cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVL_M0, 0x4000);
766 cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVH_M0, 0x0002);
767 cdns_torrent_phy_write(regmap, CMN_PLL0_HIGH_THR_M0, 0x0152);
768 cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL0_CTRL_M0, 0x0002);
769 cdns_torrent_phy_write(regmap, CMN_PLL1_INTDIV_M0, 0x01FA);
770 cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVL_M0, 0x4000);
771 cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVH_M0, 0x0002);
772 cdns_torrent_phy_write(regmap, CMN_PLL1_HIGH_THR_M0, 0x0152);
773 cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL1_CTRL_M0, 0x0002);
774 if (ssc)
775 cdns_torrent_dp_enable_ssc_19_2mhz(cdns_phy, 0x05DD, 0x0069);
776 break;
777 /* Setting VCO for 8.64GHz */
778 case 2160:
779 case 4320:
780 cdns_torrent_phy_write(regmap, CMN_PLL0_INTDIV_M0, 0x01C2);
781 cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVL_M0, 0x0000);
782 cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVH_M0, 0x0002);
783 cdns_torrent_phy_write(regmap, CMN_PLL0_HIGH_THR_M0, 0x012C);
784 cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL0_CTRL_M0, 0x0002);
785 cdns_torrent_phy_write(regmap, CMN_PLL1_INTDIV_M0, 0x01C2);
786 cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVL_M0, 0x0000);
787 cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVH_M0, 0x0002);
788 cdns_torrent_phy_write(regmap, CMN_PLL1_HIGH_THR_M0, 0x012C);
789 cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL1_CTRL_M0, 0x0002);
790 if (ssc)
791 cdns_torrent_dp_enable_ssc_19_2mhz(cdns_phy, 0x0536, 0x0069);
792 break;
793 /* Setting VCO for 8.1GHz */
794 case 8100:
795 cdns_torrent_phy_write(regmap, CMN_PLL0_INTDIV_M0, 0x01A5);
796 cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVL_M0, 0xE000);
797 cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVH_M0, 0x0002);
798 cdns_torrent_phy_write(regmap, CMN_PLL0_HIGH_THR_M0, 0x011A);
799 cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL0_CTRL_M0, 0x0002);
800 cdns_torrent_phy_write(regmap, CMN_PLL1_INTDIV_M0, 0x01A5);
801 cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVL_M0, 0xE000);
802 cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVH_M0, 0x0002);
803 cdns_torrent_phy_write(regmap, CMN_PLL1_HIGH_THR_M0, 0x011A);
804 cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL1_CTRL_M0, 0x0002);
805 if (ssc)
806 cdns_torrent_dp_enable_ssc_19_2mhz(cdns_phy, 0x04D7, 0x006A);
807 break;
808 }
809
810 if (ssc) {
811 cdns_torrent_phy_write(regmap, CMN_PLL0_VCOCAL_PLLCNT_START, 0x025E);
812 cdns_torrent_phy_write(regmap, CMN_PLL0_LOCK_PLLCNT_THR, 0x0005);
813 cdns_torrent_phy_write(regmap, CMN_PLL1_VCOCAL_PLLCNT_START, 0x025E);
814 cdns_torrent_phy_write(regmap, CMN_PLL1_LOCK_PLLCNT_THR, 0x0005);
815 } else {
816 cdns_torrent_phy_write(regmap, CMN_PLL0_VCOCAL_PLLCNT_START, 0x0260);
817 cdns_torrent_phy_write(regmap, CMN_PLL1_VCOCAL_PLLCNT_START, 0x0260);
818 /* Set reset register values to disable SSC */
819 cdns_torrent_phy_write(regmap, CMN_PLL0_SS_CTRL1_M0, 0x0002);
820 cdns_torrent_phy_write(regmap, CMN_PLL0_SS_CTRL2_M0, 0x0000);
821 cdns_torrent_phy_write(regmap, CMN_PLL0_SS_CTRL3_M0, 0x0000);
822 cdns_torrent_phy_write(regmap, CMN_PLL0_SS_CTRL4_M0, 0x0000);
823 cdns_torrent_phy_write(regmap, CMN_PLL0_LOCK_PLLCNT_THR, 0x0003);
824 cdns_torrent_phy_write(regmap, CMN_PLL1_SS_CTRL1_M0, 0x0002);
825 cdns_torrent_phy_write(regmap, CMN_PLL1_SS_CTRL2_M0, 0x0000);
826 cdns_torrent_phy_write(regmap, CMN_PLL1_SS_CTRL3_M0, 0x0000);
827 cdns_torrent_phy_write(regmap, CMN_PLL1_SS_CTRL4_M0, 0x0000);
828 cdns_torrent_phy_write(regmap, CMN_PLL1_LOCK_PLLCNT_THR, 0x0003);
829 }
830
831 cdns_torrent_phy_write(regmap, CMN_PLL0_LOCK_REFCNT_START, 0x0099);
832 cdns_torrent_phy_write(regmap, CMN_PLL0_LOCK_PLLCNT_START, 0x0099);
833 cdns_torrent_phy_write(regmap, CMN_PLL1_LOCK_REFCNT_START, 0x0099);
834 cdns_torrent_phy_write(regmap, CMN_PLL1_LOCK_PLLCNT_START, 0x0099);
835 }
836
837 /*
838 * Set registers responsible for enabling and configuring SSC, with second
839 * register value provided by a parameter.
840 */
cdns_torrent_dp_enable_ssc_25mhz(struct cdns_torrent_phy * cdns_phy,u32 ctrl2_val)841 static void cdns_torrent_dp_enable_ssc_25mhz(struct cdns_torrent_phy *cdns_phy,
842 u32 ctrl2_val)
843 {
844 struct regmap *regmap = cdns_phy->regmap_common_cdb;
845
846 cdns_torrent_phy_write(regmap, CMN_PLL0_SS_CTRL1_M0, 0x0001);
847 cdns_torrent_phy_write(regmap, CMN_PLL0_SS_CTRL1_M0, ctrl2_val);
848 cdns_torrent_phy_write(regmap, CMN_PLL0_SS_CTRL1_M0, 0x007F);
849 cdns_torrent_phy_write(regmap, CMN_PLL0_SS_CTRL4_M0, 0x0003);
850 cdns_torrent_phy_write(regmap, CMN_PLL1_SS_CTRL1_M0, 0x0001);
851 cdns_torrent_phy_write(regmap, CMN_PLL1_SS_CTRL1_M0, ctrl2_val);
852 cdns_torrent_phy_write(regmap, CMN_PLL1_SS_CTRL1_M0, 0x007F);
853 cdns_torrent_phy_write(regmap, CMN_PLL1_SS_CTRL4_M0, 0x0003);
854 }
855
856 static
cdns_torrent_dp_pma_cmn_vco_cfg_25mhz(struct cdns_torrent_phy * cdns_phy,u32 rate,bool ssc)857 void cdns_torrent_dp_pma_cmn_vco_cfg_25mhz(struct cdns_torrent_phy *cdns_phy,
858 u32 rate, bool ssc)
859 {
860 struct regmap *regmap = cdns_phy->regmap_common_cdb;
861
862 /* Assumes 25 MHz refclock */
863 switch (rate) {
864 /* Setting VCO for 10.8GHz */
865 case 2700:
866 case 5400:
867 cdns_torrent_phy_write(regmap, CMN_PLL0_INTDIV_M0, 0x01B0);
868 cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVL_M0, 0x0000);
869 cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVH_M0, 0x0002);
870 cdns_torrent_phy_write(regmap, CMN_PLL0_HIGH_THR_M0, 0x0120);
871 cdns_torrent_phy_write(regmap, CMN_PLL1_INTDIV_M0, 0x01B0);
872 cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVL_M0, 0x0000);
873 cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVH_M0, 0x0002);
874 cdns_torrent_phy_write(regmap, CMN_PLL1_HIGH_THR_M0, 0x0120);
875 if (ssc)
876 cdns_torrent_dp_enable_ssc_25mhz(cdns_phy, 0x0423);
877 break;
878 /* Setting VCO for 9.72GHz */
879 case 1620:
880 case 2430:
881 case 3240:
882 cdns_torrent_phy_write(regmap, CMN_PLL0_INTDIV_M0, 0x0184);
883 cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVL_M0, 0xCCCD);
884 cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVH_M0, 0x0002);
885 cdns_torrent_phy_write(regmap, CMN_PLL0_HIGH_THR_M0, 0x0104);
886 cdns_torrent_phy_write(regmap, CMN_PLL1_INTDIV_M0, 0x0184);
887 cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVL_M0, 0xCCCD);
888 cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVH_M0, 0x0002);
889 cdns_torrent_phy_write(regmap, CMN_PLL1_HIGH_THR_M0, 0x0104);
890 if (ssc)
891 cdns_torrent_dp_enable_ssc_25mhz(cdns_phy, 0x03B9);
892 break;
893 /* Setting VCO for 8.64GHz */
894 case 2160:
895 case 4320:
896 cdns_torrent_phy_write(regmap, CMN_PLL0_INTDIV_M0, 0x0159);
897 cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVL_M0, 0x999A);
898 cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVH_M0, 0x0002);
899 cdns_torrent_phy_write(regmap, CMN_PLL0_HIGH_THR_M0, 0x00E7);
900 cdns_torrent_phy_write(regmap, CMN_PLL1_INTDIV_M0, 0x0159);
901 cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVL_M0, 0x999A);
902 cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVH_M0, 0x0002);
903 cdns_torrent_phy_write(regmap, CMN_PLL1_HIGH_THR_M0, 0x00E7);
904 if (ssc)
905 cdns_torrent_dp_enable_ssc_25mhz(cdns_phy, 0x034F);
906 break;
907 /* Setting VCO for 8.1GHz */
908 case 8100:
909 cdns_torrent_phy_write(regmap, CMN_PLL0_INTDIV_M0, 0x0144);
910 cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVL_M0, 0x0000);
911 cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVH_M0, 0x0002);
912 cdns_torrent_phy_write(regmap, CMN_PLL0_HIGH_THR_M0, 0x00D8);
913 cdns_torrent_phy_write(regmap, CMN_PLL1_INTDIV_M0, 0x0144);
914 cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVL_M0, 0x0000);
915 cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVH_M0, 0x0002);
916 cdns_torrent_phy_write(regmap, CMN_PLL1_HIGH_THR_M0, 0x00D8);
917 if (ssc)
918 cdns_torrent_dp_enable_ssc_25mhz(cdns_phy, 0x031A);
919 break;
920 }
921
922 cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL0_CTRL_M0, 0x0002);
923 cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL1_CTRL_M0, 0x0002);
924
925 if (ssc) {
926 cdns_torrent_phy_write(regmap,
927 CMN_PLL0_VCOCAL_PLLCNT_START, 0x0315);
928 cdns_torrent_phy_write(regmap,
929 CMN_PLL0_LOCK_PLLCNT_THR, 0x0005);
930 cdns_torrent_phy_write(regmap,
931 CMN_PLL1_VCOCAL_PLLCNT_START, 0x0315);
932 cdns_torrent_phy_write(regmap,
933 CMN_PLL1_LOCK_PLLCNT_THR, 0x0005);
934 } else {
935 cdns_torrent_phy_write(regmap,
936 CMN_PLL0_VCOCAL_PLLCNT_START, 0x0317);
937 cdns_torrent_phy_write(regmap,
938 CMN_PLL1_VCOCAL_PLLCNT_START, 0x0317);
939 /* Set reset register values to disable SSC */
940 cdns_torrent_phy_write(regmap, CMN_PLL0_SS_CTRL1_M0, 0x0002);
941 cdns_torrent_phy_write(regmap, CMN_PLL0_SS_CTRL2_M0, 0x0000);
942 cdns_torrent_phy_write(regmap, CMN_PLL0_SS_CTRL3_M0, 0x0000);
943 cdns_torrent_phy_write(regmap, CMN_PLL0_SS_CTRL4_M0, 0x0000);
944 cdns_torrent_phy_write(regmap,
945 CMN_PLL0_LOCK_PLLCNT_THR, 0x0003);
946 cdns_torrent_phy_write(regmap, CMN_PLL1_SS_CTRL1_M0, 0x0002);
947 cdns_torrent_phy_write(regmap, CMN_PLL1_SS_CTRL2_M0, 0x0000);
948 cdns_torrent_phy_write(regmap, CMN_PLL1_SS_CTRL3_M0, 0x0000);
949 cdns_torrent_phy_write(regmap, CMN_PLL1_SS_CTRL4_M0, 0x0000);
950 cdns_torrent_phy_write(regmap,
951 CMN_PLL1_LOCK_PLLCNT_THR, 0x0003);
952 }
953
954 cdns_torrent_phy_write(regmap, CMN_PLL0_LOCK_REFCNT_START, 0x00C7);
955 cdns_torrent_phy_write(regmap, CMN_PLL0_LOCK_PLLCNT_START, 0x00C7);
956 cdns_torrent_phy_write(regmap, CMN_PLL1_LOCK_REFCNT_START, 0x00C7);
957 cdns_torrent_phy_write(regmap, CMN_PLL1_LOCK_PLLCNT_START, 0x00C7);
958 }
959
960 static
cdns_torrent_dp_pma_cmn_vco_cfg_100mhz(struct cdns_torrent_phy * cdns_phy,u32 rate,bool ssc)961 void cdns_torrent_dp_pma_cmn_vco_cfg_100mhz(struct cdns_torrent_phy *cdns_phy,
962 u32 rate, bool ssc)
963 {
964 struct regmap *regmap = cdns_phy->regmap_common_cdb;
965
966 /* Assumes 100 MHz refclock */
967 switch (rate) {
968 /* Setting VCO for 10.8GHz */
969 case 2700:
970 case 5400:
971 if (cdns_phy->dp_pll & DP_PLL0)
972 cdns_torrent_phy_write(regmap, CMN_PLL0_DSM_FBH_OVRD_M0, 0x0022);
973
974 if (cdns_phy->dp_pll & DP_PLL1) {
975 cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL1_CP_PADJ_M0, 0x0028);
976 cdns_torrent_phy_write(regmap, CMN_PLL1_DSM_FBH_OVRD_M0, 0x0022);
977 cdns_torrent_phy_write(regmap, CMN_PLL1_DSM_FBL_OVRD_M0, 0x000C);
978 }
979 break;
980 /* Setting VCO for 9.72GHz */
981 case 1620:
982 case 2430:
983 case 3240:
984 if (cdns_phy->dp_pll & DP_PLL0) {
985 cdns_torrent_phy_write(regmap, CMN_PLL0_DSM_DIAG_M0, 0x0004);
986 cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL0_CP_PADJ_M0, 0x0509);
987 cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL0_CP_IADJ_M0, 0x0F00);
988 cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL0_FILT_PADJ_M0, 0x0F08);
989 cdns_torrent_phy_write(regmap, CMN_PLL0_INTDIV_M0, 0x0061);
990 cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVL_M0, 0x3333);
991 cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVH_M0, 0x0002);
992 cdns_torrent_phy_write(regmap, CMN_PLL0_HIGH_THR_M0, 0x0042);
993 cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL0_CTRL_M0, 0x0002);
994 }
995 if (cdns_phy->dp_pll & DP_PLL1) {
996 cdns_torrent_phy_write(regmap, CMN_PLL1_DSM_DIAG_M0, 0x0004);
997 cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL1_CP_PADJ_M0, 0x0509);
998 cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL1_CP_IADJ_M0, 0x0F00);
999 cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL1_FILT_PADJ_M0, 0x0F08);
1000 cdns_torrent_phy_write(regmap, CMN_PLL1_INTDIV_M0, 0x0061);
1001 cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVL_M0, 0x3333);
1002 cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVH_M0, 0x0002);
1003 cdns_torrent_phy_write(regmap, CMN_PLL1_HIGH_THR_M0, 0x0042);
1004 cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL1_CTRL_M0, 0x0002);
1005 }
1006 break;
1007 /* Setting VCO for 8.64GHz */
1008 case 2160:
1009 case 4320:
1010 if (cdns_phy->dp_pll & DP_PLL0) {
1011 cdns_torrent_phy_write(regmap, CMN_PLL0_DSM_DIAG_M0, 0x0004);
1012 cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL0_CP_PADJ_M0, 0x0509);
1013 cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL0_CP_IADJ_M0, 0x0F00);
1014 cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL0_FILT_PADJ_M0, 0x0F08);
1015 cdns_torrent_phy_write(regmap, CMN_PLL0_INTDIV_M0, 0x0056);
1016 cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVL_M0, 0x6666);
1017 cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVH_M0, 0x0002);
1018 cdns_torrent_phy_write(regmap, CMN_PLL0_HIGH_THR_M0, 0x003A);
1019 cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL0_CTRL_M0, 0x0002);
1020 }
1021 if (cdns_phy->dp_pll & DP_PLL1) {
1022 cdns_torrent_phy_write(regmap, CMN_PLL1_DSM_DIAG_M0, 0x0004);
1023 cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL1_CP_PADJ_M0, 0x0509);
1024 cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL1_CP_IADJ_M0, 0x0F00);
1025 cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL1_FILT_PADJ_M0, 0x0F08);
1026 cdns_torrent_phy_write(regmap, CMN_PLL1_INTDIV_M0, 0x0056);
1027 cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVL_M0, 0x6666);
1028 cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVH_M0, 0x0002);
1029 cdns_torrent_phy_write(regmap, CMN_PLL1_HIGH_THR_M0, 0x003A);
1030 cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL1_CTRL_M0, 0x0002);
1031 }
1032 break;
1033 /* Setting VCO for 8.1GHz */
1034 case 8100:
1035 if (cdns_phy->dp_pll & DP_PLL0) {
1036 cdns_torrent_phy_write(regmap, CMN_PLL0_DSM_DIAG_M0, 0x0004);
1037 cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL0_CP_PADJ_M0, 0x0509);
1038 cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL0_CP_IADJ_M0, 0x0F00);
1039 cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL0_FILT_PADJ_M0, 0x0F08);
1040 cdns_torrent_phy_write(regmap, CMN_PLL0_INTDIV_M0, 0x0051);
1041 cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVH_M0, 0x0002);
1042 cdns_torrent_phy_write(regmap, CMN_PLL0_HIGH_THR_M0, 0x0036);
1043 cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL0_CTRL_M0, 0x0002);
1044 }
1045 if (cdns_phy->dp_pll & DP_PLL1) {
1046 cdns_torrent_phy_write(regmap, CMN_PLL1_DSM_DIAG_M0, 0x0004);
1047 cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL1_CP_PADJ_M0, 0x0509);
1048 cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL1_CP_IADJ_M0, 0x0F00);
1049 cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL1_FILT_PADJ_M0, 0x0F08);
1050 cdns_torrent_phy_write(regmap, CMN_PLL1_INTDIV_M0, 0x0051);
1051 cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVH_M0, 0x0002);
1052 cdns_torrent_phy_write(regmap, CMN_PLL1_HIGH_THR_M0, 0x0036);
1053 cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL1_CTRL_M0, 0x0002);
1054 }
1055 break;
1056 }
1057 }
1058
1059 /* Set PLL used for DP configuration */
cdns_torrent_dp_get_pll(struct cdns_torrent_phy * cdns_phy,enum cdns_torrent_phy_type phy_t2)1060 static int cdns_torrent_dp_get_pll(struct cdns_torrent_phy *cdns_phy,
1061 enum cdns_torrent_phy_type phy_t2)
1062 {
1063 switch (phy_t2) {
1064 case TYPE_PCIE:
1065 case TYPE_USB:
1066 cdns_phy->dp_pll = DP_PLL1;
1067 break;
1068 case TYPE_SGMII:
1069 case TYPE_QSGMII:
1070 cdns_phy->dp_pll = DP_PLL0;
1071 break;
1072 case TYPE_NONE:
1073 cdns_phy->dp_pll = DP_PLL0 | DP_PLL1;
1074 break;
1075 default:
1076 dev_err(cdns_phy->dev, "Unsupported PHY configuration\n");
1077 return -EINVAL;
1078 }
1079
1080 return 0;
1081 }
1082
1083 /*
1084 * Enable or disable PLL for selected lanes.
1085 */
cdns_torrent_dp_set_pll_en(struct cdns_torrent_phy * cdns_phy,struct cdns_torrent_inst * inst,struct phy_configure_opts_dp * dp,bool enable)1086 static int cdns_torrent_dp_set_pll_en(struct cdns_torrent_phy *cdns_phy,
1087 struct cdns_torrent_inst *inst,
1088 struct phy_configure_opts_dp *dp,
1089 bool enable)
1090 {
1091 struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg;
1092 u32 rd_val, pll_ack_val;
1093 int ret;
1094
1095 /*
1096 * Used to determine, which bits to check for or enable in
1097 * PHY_PMA_XCVR_PLLCLK_EN register.
1098 */
1099 u32 pll_bits;
1100 /* Used to enable or disable lanes. */
1101 u32 pll_val;
1102
1103 /* Select values of registers and mask, depending on enabled lane count. */
1104 pll_val = cdns_torrent_dp_read(regmap, PHY_PMA_XCVR_PLLCLK_EN);
1105
1106 if (enable) {
1107 pll_bits = ((1 << dp->lanes) - 1);
1108 pll_val |= pll_bits;
1109 pll_ack_val = pll_bits;
1110 } else {
1111 pll_bits = ((1 << inst->num_lanes) - 1);
1112 pll_val &= (~pll_bits);
1113 pll_ack_val = 0;
1114 }
1115
1116 cdns_torrent_dp_write(regmap, PHY_PMA_XCVR_PLLCLK_EN, pll_val);
1117
1118 /* Wait for acknowledgment from PHY. */
1119 ret = regmap_read_poll_timeout(regmap,
1120 PHY_PMA_XCVR_PLLCLK_EN_ACK,
1121 rd_val,
1122 (rd_val & pll_bits) == pll_ack_val,
1123 0, POLL_TIMEOUT_US);
1124 ndelay(100);
1125 return ret;
1126 }
1127
cdns_torrent_dp_set_power_state(struct cdns_torrent_phy * cdns_phy,struct cdns_torrent_inst * inst,u32 num_lanes,enum phy_powerstate powerstate)1128 static int cdns_torrent_dp_set_power_state(struct cdns_torrent_phy *cdns_phy,
1129 struct cdns_torrent_inst *inst,
1130 u32 num_lanes,
1131 enum phy_powerstate powerstate)
1132 {
1133 /* Register value for power state for a single byte. */
1134 u32 value_part, i;
1135 u32 value = 0;
1136 u32 mask = 0;
1137 u32 read_val;
1138 int ret;
1139 struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg;
1140
1141 switch (powerstate) {
1142 case (POWERSTATE_A0):
1143 value_part = 0x01U;
1144 break;
1145 case (POWERSTATE_A2):
1146 value_part = 0x04U;
1147 break;
1148 default:
1149 /* Powerstate A3 */
1150 value_part = 0x08U;
1151 break;
1152 }
1153
1154 /* Select values of registers and mask, depending on enabled lane count. */
1155
1156 for (i = 0; i < num_lanes; i++) {
1157 value |= (value_part << PHY_POWER_STATE_LN(i));
1158 mask |= (PMA_XCVR_POWER_STATE_REQ_LN_MASK << PHY_POWER_STATE_LN(i));
1159 }
1160
1161 /* Set power state A<n>. */
1162 cdns_torrent_dp_write(regmap, PHY_PMA_XCVR_POWER_STATE_REQ, value);
1163 /* Wait, until PHY acknowledges power state completion. */
1164 ret = regmap_read_poll_timeout(regmap, PHY_PMA_XCVR_POWER_STATE_ACK,
1165 read_val, (read_val & mask) == value, 0,
1166 POLL_TIMEOUT_US);
1167 if (ret)
1168 return ret;
1169
1170 cdns_torrent_dp_write(regmap, PHY_PMA_XCVR_POWER_STATE_REQ, 0x00000000);
1171 ndelay(100);
1172
1173 return ret;
1174 }
1175
cdns_torrent_dp_run(struct cdns_torrent_phy * cdns_phy,struct cdns_torrent_inst * inst,u32 num_lanes)1176 static int cdns_torrent_dp_run(struct cdns_torrent_phy *cdns_phy,
1177 struct cdns_torrent_inst *inst, u32 num_lanes)
1178 {
1179 unsigned int read_val;
1180 int ret;
1181 struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg;
1182
1183 /*
1184 * waiting for ACK of pma_xcvr_pllclk_en_ln_*, only for the
1185 * master lane
1186 */
1187 ret = regmap_read_poll_timeout(regmap, PHY_PMA_XCVR_PLLCLK_EN_ACK,
1188 read_val, read_val & 1,
1189 0, POLL_TIMEOUT_US);
1190 if (ret == -ETIMEDOUT) {
1191 dev_err(cdns_phy->dev,
1192 "timeout waiting for link PLL clock enable ack\n");
1193 return ret;
1194 }
1195
1196 ndelay(100);
1197
1198 ret = cdns_torrent_dp_set_power_state(cdns_phy, inst, num_lanes,
1199 POWERSTATE_A2);
1200 if (ret)
1201 return ret;
1202
1203 ret = cdns_torrent_dp_set_power_state(cdns_phy, inst, num_lanes,
1204 POWERSTATE_A0);
1205
1206 return ret;
1207 }
1208
cdns_torrent_dp_wait_pma_cmn_ready(struct cdns_torrent_phy * cdns_phy)1209 static int cdns_torrent_dp_wait_pma_cmn_ready(struct cdns_torrent_phy *cdns_phy)
1210 {
1211 unsigned int reg;
1212 int ret;
1213 struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg;
1214
1215 ret = regmap_read_poll_timeout(regmap, PHY_PMA_CMN_READY, reg,
1216 reg & 1, 0, POLL_TIMEOUT_US);
1217 if (ret == -ETIMEDOUT) {
1218 dev_err(cdns_phy->dev,
1219 "timeout waiting for PMA common ready\n");
1220 return -ETIMEDOUT;
1221 }
1222
1223 return 0;
1224 }
1225
cdns_torrent_dp_pma_cmn_rate(struct cdns_torrent_phy * cdns_phy,struct cdns_torrent_inst * inst,u32 rate,u32 num_lanes)1226 static void cdns_torrent_dp_pma_cmn_rate(struct cdns_torrent_phy *cdns_phy,
1227 struct cdns_torrent_inst *inst,
1228 u32 rate, u32 num_lanes)
1229 {
1230 unsigned int clk_sel_val = 0;
1231 unsigned int hsclk_div_val = 0;
1232 unsigned int i;
1233
1234 switch (rate) {
1235 case 1620:
1236 clk_sel_val = 0x0f01;
1237 hsclk_div_val = 2;
1238 break;
1239 case 2160:
1240 case 2430:
1241 case 2700:
1242 clk_sel_val = 0x0701;
1243 hsclk_div_val = 1;
1244 break;
1245 case 3240:
1246 clk_sel_val = 0x0b00;
1247 hsclk_div_val = 2;
1248 break;
1249 case 4320:
1250 case 5400:
1251 clk_sel_val = 0x0301;
1252 hsclk_div_val = 0;
1253 break;
1254 case 8100:
1255 clk_sel_val = 0x0200;
1256 hsclk_div_val = 0;
1257 break;
1258 }
1259
1260 if (cdns_phy->dp_pll & DP_PLL0)
1261 cdns_torrent_phy_write(cdns_phy->regmap_common_cdb,
1262 CMN_PDIAG_PLL0_CLK_SEL_M0, clk_sel_val);
1263
1264 if (cdns_phy->dp_pll & DP_PLL1)
1265 cdns_torrent_phy_write(cdns_phy->regmap_common_cdb,
1266 CMN_PDIAG_PLL1_CLK_SEL_M0, clk_sel_val);
1267
1268 /* PMA lane configuration to deal with multi-link operation */
1269 for (i = 0; i < num_lanes; i++)
1270 cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[inst->mlane + i],
1271 XCVR_DIAG_HSCLK_DIV, hsclk_div_val);
1272 }
1273
1274 /*
1275 * Perform register operations related to setting link rate, once powerstate is
1276 * set and PLL disable request was processed.
1277 */
cdns_torrent_dp_configure_rate(struct cdns_torrent_phy * cdns_phy,struct cdns_torrent_inst * inst,struct phy_configure_opts_dp * dp)1278 static int cdns_torrent_dp_configure_rate(struct cdns_torrent_phy *cdns_phy,
1279 struct cdns_torrent_inst *inst,
1280 struct phy_configure_opts_dp *dp)
1281 {
1282 u32 read_val, field_val;
1283 int ret;
1284
1285 /*
1286 * Disable the associated PLL (cmn_pll0_en or cmn_pll1_en) before
1287 * re-programming the new data rate.
1288 */
1289 ret = regmap_field_read(cdns_phy->phy_pma_pll_raw_ctrl, &field_val);
1290 if (ret)
1291 return ret;
1292 field_val &= ~(cdns_phy->dp_pll);
1293 regmap_field_write(cdns_phy->phy_pma_pll_raw_ctrl, field_val);
1294
1295 /*
1296 * Wait for PLL ready de-assertion.
1297 * For PLL0 - PHY_PMA_CMN_CTRL2[2] == 1
1298 * For PLL1 - PHY_PMA_CMN_CTRL2[3] == 1
1299 */
1300 if (cdns_phy->dp_pll & DP_PLL0) {
1301 ret = regmap_field_read_poll_timeout(cdns_phy->phy_pma_cmn_ctrl_2,
1302 read_val,
1303 ((read_val >> 2) & 0x01) != 0,
1304 0, POLL_TIMEOUT_US);
1305 if (ret)
1306 return ret;
1307 }
1308
1309 if ((cdns_phy->dp_pll & DP_PLL1) && cdns_phy->nsubnodes != 1) {
1310 ret = regmap_field_read_poll_timeout(cdns_phy->phy_pma_cmn_ctrl_2,
1311 read_val,
1312 ((read_val >> 3) & 0x01) != 0,
1313 0, POLL_TIMEOUT_US);
1314 if (ret)
1315 return ret;
1316 }
1317 ndelay(200);
1318
1319 /* DP Rate Change - VCO Output settings. */
1320 if (cdns_phy->ref_clk_rate == CLK_19_2_MHZ)
1321 /* PMA common configuration 19.2MHz */
1322 cdns_torrent_dp_pma_cmn_vco_cfg_19_2mhz(cdns_phy, dp->link_rate, dp->ssc);
1323 else if (cdns_phy->ref_clk_rate == CLK_25_MHZ)
1324 /* PMA common configuration 25MHz */
1325 cdns_torrent_dp_pma_cmn_vco_cfg_25mhz(cdns_phy, dp->link_rate, dp->ssc);
1326 else if (cdns_phy->ref_clk_rate == CLK_100_MHZ)
1327 /* PMA common configuration 100MHz */
1328 cdns_torrent_dp_pma_cmn_vco_cfg_100mhz(cdns_phy, dp->link_rate, dp->ssc);
1329
1330 cdns_torrent_dp_pma_cmn_rate(cdns_phy, inst, dp->link_rate, dp->lanes);
1331
1332 /* Enable the associated PLL (cmn_pll0_en or cmn_pll1_en) */
1333 ret = regmap_field_read(cdns_phy->phy_pma_pll_raw_ctrl, &field_val);
1334 if (ret)
1335 return ret;
1336 field_val |= cdns_phy->dp_pll;
1337 regmap_field_write(cdns_phy->phy_pma_pll_raw_ctrl, field_val);
1338
1339 /*
1340 * Wait for PLL ready assertion.
1341 * For PLL0 - PHY_PMA_CMN_CTRL2[0] == 1
1342 * For PLL1 - PHY_PMA_CMN_CTRL2[1] == 1
1343 */
1344 if (cdns_phy->dp_pll & DP_PLL0) {
1345 ret = regmap_field_read_poll_timeout(cdns_phy->phy_pma_cmn_ctrl_2,
1346 read_val,
1347 (read_val & 0x01) != 0,
1348 0, POLL_TIMEOUT_US);
1349 if (ret)
1350 return ret;
1351 }
1352
1353 if ((cdns_phy->dp_pll & DP_PLL1) && cdns_phy->nsubnodes != 1)
1354 ret = regmap_field_read_poll_timeout(cdns_phy->phy_pma_cmn_ctrl_2,
1355 read_val,
1356 ((read_val >> 1) & 0x01) != 0,
1357 0, POLL_TIMEOUT_US);
1358
1359 return ret;
1360 }
1361
1362 /*
1363 * Verify, that parameters to configure PHY with are correct.
1364 */
cdns_torrent_dp_verify_config(struct cdns_torrent_inst * inst,struct phy_configure_opts_dp * dp)1365 static int cdns_torrent_dp_verify_config(struct cdns_torrent_inst *inst,
1366 struct phy_configure_opts_dp *dp)
1367 {
1368 u8 i;
1369
1370 /* If changing link rate was required, verify it's supported. */
1371 if (dp->set_rate) {
1372 switch (dp->link_rate) {
1373 case 1620:
1374 case 2160:
1375 case 2430:
1376 case 2700:
1377 case 3240:
1378 case 4320:
1379 case 5400:
1380 case 8100:
1381 /* valid bit rate */
1382 break;
1383 default:
1384 return -EINVAL;
1385 }
1386 }
1387
1388 /* Verify lane count. */
1389 switch (dp->lanes) {
1390 case 1:
1391 case 2:
1392 case 4:
1393 /* valid lane count. */
1394 break;
1395 default:
1396 return -EINVAL;
1397 }
1398
1399 /* Check against actual number of PHY's lanes. */
1400 if (dp->lanes > inst->num_lanes)
1401 return -EINVAL;
1402
1403 /*
1404 * If changing voltages is required, check swing and pre-emphasis
1405 * levels, per-lane.
1406 */
1407 if (dp->set_voltages) {
1408 /* Lane count verified previously. */
1409 for (i = 0; i < dp->lanes; i++) {
1410 if (dp->voltage[i] > 3 || dp->pre[i] > 3)
1411 return -EINVAL;
1412
1413 /* Sum of voltage swing and pre-emphasis levels cannot
1414 * exceed 3.
1415 */
1416 if (dp->voltage[i] + dp->pre[i] > 3)
1417 return -EINVAL;
1418 }
1419 }
1420
1421 return 0;
1422 }
1423
1424 /* Set power state A0 and PLL clock enable to 0 on enabled lanes. */
cdns_torrent_dp_set_a0_pll(struct cdns_torrent_phy * cdns_phy,struct cdns_torrent_inst * inst,u32 num_lanes)1425 static void cdns_torrent_dp_set_a0_pll(struct cdns_torrent_phy *cdns_phy,
1426 struct cdns_torrent_inst *inst,
1427 u32 num_lanes)
1428 {
1429 struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg;
1430 u32 pwr_state = cdns_torrent_dp_read(regmap,
1431 PHY_PMA_XCVR_POWER_STATE_REQ);
1432 u32 pll_clk_en = cdns_torrent_dp_read(regmap,
1433 PHY_PMA_XCVR_PLLCLK_EN);
1434 u32 i;
1435
1436 for (i = 0; i < num_lanes; i++) {
1437 pwr_state &= ~(PMA_XCVR_POWER_STATE_REQ_LN_MASK
1438 << PHY_POWER_STATE_LN(inst->mlane + i));
1439
1440 pll_clk_en &= ~(0x01U << (inst->mlane + i));
1441 }
1442
1443 cdns_torrent_dp_write(regmap, PHY_PMA_XCVR_POWER_STATE_REQ, pwr_state);
1444 cdns_torrent_dp_write(regmap, PHY_PMA_XCVR_PLLCLK_EN, pll_clk_en);
1445 }
1446
1447 /* Configure lane count as required. */
cdns_torrent_dp_set_lanes(struct cdns_torrent_phy * cdns_phy,struct cdns_torrent_inst * inst,struct phy_configure_opts_dp * dp)1448 static int cdns_torrent_dp_set_lanes(struct cdns_torrent_phy *cdns_phy,
1449 struct cdns_torrent_inst *inst,
1450 struct phy_configure_opts_dp *dp)
1451 {
1452 u32 value, i;
1453 int ret;
1454 struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg;
1455 u8 lane_mask = (1 << dp->lanes) - 1;
1456 u8 pma_tx_elec_idle_mask = 0;
1457 u32 clane = inst->mlane;
1458
1459 lane_mask <<= clane;
1460
1461 value = cdns_torrent_dp_read(regmap, PHY_RESET);
1462 /* clear pma_tx_elec_idle_ln_* bits. */
1463 pma_tx_elec_idle_mask = ((1 << inst->num_lanes) - 1) << clane;
1464
1465 pma_tx_elec_idle_mask <<= PMA_TX_ELEC_IDLE_SHIFT;
1466
1467 value &= ~pma_tx_elec_idle_mask;
1468
1469 /* Assert pma_tx_elec_idle_ln_* for disabled lanes. */
1470 value |= ((~lane_mask) << PMA_TX_ELEC_IDLE_SHIFT) &
1471 pma_tx_elec_idle_mask;
1472
1473 cdns_torrent_dp_write(regmap, PHY_RESET, value);
1474
1475 /* reset the link by asserting master lane phy_l0*_reset_n low */
1476 cdns_torrent_dp_write(regmap, PHY_RESET,
1477 value & (~(1 << clane)));
1478
1479 /*
1480 * Assert lane reset on unused lanes and master lane so they remain in reset
1481 * and powered down when re-enabling the link
1482 */
1483 for (i = 0; i < inst->num_lanes; i++)
1484 value &= (~(1 << (clane + i)));
1485
1486 for (i = 1; i < inst->num_lanes; i++)
1487 value |= ((1 << (clane + i)) & lane_mask);
1488
1489 cdns_torrent_dp_write(regmap, PHY_RESET, value);
1490
1491 cdns_torrent_dp_set_a0_pll(cdns_phy, inst, dp->lanes);
1492
1493 /* release phy_l0*_reset_n based on used laneCount */
1494 for (i = 0; i < inst->num_lanes; i++)
1495 value &= (~(1 << (clane + i)));
1496
1497 for (i = 0; i < inst->num_lanes; i++)
1498 value |= ((1 << (clane + i)) & lane_mask);
1499
1500 cdns_torrent_dp_write(regmap, PHY_RESET, value);
1501
1502 /* Wait, until PHY gets ready after releasing PHY reset signal. */
1503 ret = cdns_torrent_dp_wait_pma_cmn_ready(cdns_phy);
1504 if (ret)
1505 return ret;
1506
1507 ndelay(100);
1508
1509 /* release pma_xcvr_pllclk_en_ln_*, only for the master lane */
1510 value = cdns_torrent_dp_read(regmap, PHY_PMA_XCVR_PLLCLK_EN);
1511 value |= (1 << clane);
1512 cdns_torrent_dp_write(regmap, PHY_PMA_XCVR_PLLCLK_EN, value);
1513
1514 ret = cdns_torrent_dp_run(cdns_phy, inst, dp->lanes);
1515
1516 return ret;
1517 }
1518
1519 /* Configure link rate as required. */
cdns_torrent_dp_set_rate(struct cdns_torrent_phy * cdns_phy,struct cdns_torrent_inst * inst,struct phy_configure_opts_dp * dp)1520 static int cdns_torrent_dp_set_rate(struct cdns_torrent_phy *cdns_phy,
1521 struct cdns_torrent_inst *inst,
1522 struct phy_configure_opts_dp *dp)
1523 {
1524 int ret;
1525
1526 ret = cdns_torrent_dp_set_power_state(cdns_phy, inst, dp->lanes,
1527 POWERSTATE_A3);
1528 if (ret)
1529 return ret;
1530 ret = cdns_torrent_dp_set_pll_en(cdns_phy, inst, dp, false);
1531 if (ret)
1532 return ret;
1533 ndelay(200);
1534
1535 ret = cdns_torrent_dp_configure_rate(cdns_phy, inst, dp);
1536 if (ret)
1537 return ret;
1538 ndelay(200);
1539
1540 ret = cdns_torrent_dp_set_pll_en(cdns_phy, inst, dp, true);
1541 if (ret)
1542 return ret;
1543 ret = cdns_torrent_dp_set_power_state(cdns_phy, inst, dp->lanes,
1544 POWERSTATE_A2);
1545 if (ret)
1546 return ret;
1547 ret = cdns_torrent_dp_set_power_state(cdns_phy, inst, dp->lanes,
1548 POWERSTATE_A0);
1549 if (ret)
1550 return ret;
1551 ndelay(900);
1552
1553 return ret;
1554 }
1555
1556 /* Configure voltage swing and pre-emphasis for all enabled lanes. */
cdns_torrent_dp_set_voltages(struct cdns_torrent_phy * cdns_phy,struct cdns_torrent_inst * inst,struct phy_configure_opts_dp * dp)1557 static void cdns_torrent_dp_set_voltages(struct cdns_torrent_phy *cdns_phy,
1558 struct cdns_torrent_inst *inst,
1559 struct phy_configure_opts_dp *dp)
1560 {
1561 u8 lane;
1562 u16 val;
1563
1564 for (lane = 0; lane < dp->lanes; lane++) {
1565 val = cdns_torrent_phy_read(cdns_phy->regmap_tx_lane_cdb[inst->mlane + lane],
1566 TX_DIAG_ACYA);
1567 /*
1568 * Write 1 to register bit TX_DIAG_ACYA[0] to freeze the
1569 * current state of the analog TX driver.
1570 */
1571 val |= TX_DIAG_ACYA_HBDC_MASK;
1572 cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[inst->mlane + lane],
1573 TX_DIAG_ACYA, val);
1574
1575 cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[inst->mlane + lane],
1576 TX_TXCC_CTRL, 0x08A4);
1577 val = vltg_coeff[dp->voltage[lane]][dp->pre[lane]].diag_tx_drv;
1578 cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[inst->mlane + lane],
1579 DRV_DIAG_TX_DRV, val);
1580 val = vltg_coeff[dp->voltage[lane]][dp->pre[lane]].mgnfs_mult;
1581 cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[inst->mlane + lane],
1582 TX_TXCC_MGNFS_MULT_000,
1583 val);
1584 val = vltg_coeff[dp->voltage[lane]][dp->pre[lane]].cpost_mult;
1585 cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[inst->mlane + lane],
1586 TX_TXCC_CPOST_MULT_00,
1587 val);
1588
1589 val = cdns_torrent_phy_read(cdns_phy->regmap_tx_lane_cdb[inst->mlane + lane],
1590 TX_DIAG_ACYA);
1591 /*
1592 * Write 0 to register bit TX_DIAG_ACYA[0] to allow the state of
1593 * analog TX driver to reflect the new programmed one.
1594 */
1595 val &= ~TX_DIAG_ACYA_HBDC_MASK;
1596 cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[inst->mlane + lane],
1597 TX_DIAG_ACYA, val);
1598 }
1599 };
1600
cdns_torrent_dp_configure(struct phy * phy,union phy_configure_opts * opts)1601 static int cdns_torrent_dp_configure(struct phy *phy,
1602 union phy_configure_opts *opts)
1603 {
1604 struct cdns_torrent_inst *inst = phy_get_drvdata(phy);
1605 struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(phy->dev.parent);
1606 int ret;
1607
1608 if (cdns_phy->already_configured)
1609 return 0;
1610
1611 ret = cdns_torrent_dp_verify_config(inst, &opts->dp);
1612 if (ret) {
1613 dev_err(&phy->dev, "invalid params for phy configure\n");
1614 return ret;
1615 }
1616
1617 if (opts->dp.set_lanes) {
1618 ret = cdns_torrent_dp_set_lanes(cdns_phy, inst, &opts->dp);
1619 if (ret) {
1620 dev_err(&phy->dev, "cdns_torrent_dp_set_lanes failed\n");
1621 return ret;
1622 }
1623 }
1624
1625 if (opts->dp.set_rate) {
1626 ret = cdns_torrent_dp_set_rate(cdns_phy, inst, &opts->dp);
1627 if (ret) {
1628 dev_err(&phy->dev, "cdns_torrent_dp_set_rate failed\n");
1629 return ret;
1630 }
1631 }
1632
1633 if (opts->dp.set_voltages)
1634 cdns_torrent_dp_set_voltages(cdns_phy, inst, &opts->dp);
1635
1636 return ret;
1637 }
1638
cdns_torrent_phy_on(struct phy * phy)1639 static int cdns_torrent_phy_on(struct phy *phy)
1640 {
1641 struct cdns_torrent_inst *inst = phy_get_drvdata(phy);
1642 struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(phy->dev.parent);
1643 u32 read_val;
1644 int ret;
1645
1646 if (cdns_phy->already_configured) {
1647 /* Give 5ms to 10ms delay for the PIPE clock to be stable */
1648 usleep_range(5000, 10000);
1649 return 0;
1650 }
1651
1652 if (cdns_phy->nsubnodes == 1) {
1653 /* Take the PHY lane group out of reset */
1654 reset_control_deassert(inst->lnk_rst);
1655
1656 /* Take the PHY out of reset */
1657 ret = reset_control_deassert(cdns_phy->phy_rst);
1658 if (ret)
1659 return ret;
1660 }
1661
1662 /*
1663 * Wait for cmn_ready assertion
1664 * PHY_PMA_CMN_CTRL1[0] == 1
1665 */
1666 ret = regmap_field_read_poll_timeout(cdns_phy->phy_pma_cmn_ctrl_1,
1667 read_val, read_val, 1000,
1668 PLL_LOCK_TIMEOUT);
1669 if (ret) {
1670 dev_err(cdns_phy->dev, "Timeout waiting for CMN ready\n");
1671 return ret;
1672 }
1673
1674 if (inst->phy_type == TYPE_PCIE || inst->phy_type == TYPE_USB) {
1675 ret = regmap_field_read_poll_timeout(cdns_phy->phy_pcs_iso_link_ctrl_1[inst->mlane],
1676 read_val, !read_val, 1000,
1677 PLL_LOCK_TIMEOUT);
1678 if (ret == -ETIMEDOUT) {
1679 dev_err(cdns_phy->dev, "Timeout waiting for PHY status ready\n");
1680 return ret;
1681 }
1682 }
1683
1684 return 0;
1685 }
1686
cdns_torrent_phy_off(struct phy * phy)1687 static int cdns_torrent_phy_off(struct phy *phy)
1688 {
1689 struct cdns_torrent_inst *inst = phy_get_drvdata(phy);
1690 struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(phy->dev.parent);
1691 int ret;
1692
1693 if (cdns_phy->nsubnodes != 1)
1694 return 0;
1695
1696 ret = reset_control_assert(cdns_phy->phy_rst);
1697 if (ret)
1698 return ret;
1699
1700 return reset_control_assert(inst->lnk_rst);
1701 }
1702
cdns_torrent_dp_common_init(struct cdns_torrent_phy * cdns_phy,struct cdns_torrent_inst * inst)1703 static void cdns_torrent_dp_common_init(struct cdns_torrent_phy *cdns_phy,
1704 struct cdns_torrent_inst *inst)
1705 {
1706 struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg;
1707 unsigned char lane_bits;
1708 u32 val;
1709
1710 cdns_torrent_dp_write(regmap, PHY_AUX_CTRL, 0x0003); /* enable AUX */
1711
1712 /*
1713 * Set lines power state to A0
1714 * Set lines pll clk enable to 0
1715 */
1716 cdns_torrent_dp_set_a0_pll(cdns_phy, inst, inst->num_lanes);
1717
1718 /*
1719 * release phy_l0*_reset_n and pma_tx_elec_idle_ln_* based on
1720 * used lanes
1721 */
1722 lane_bits = (1 << inst->num_lanes) - 1;
1723
1724 val = cdns_torrent_dp_read(regmap, PHY_RESET);
1725 val |= (0xF & lane_bits);
1726 val &= ~(lane_bits << 4);
1727 cdns_torrent_dp_write(regmap, PHY_RESET, val);
1728
1729 /* release pma_xcvr_pllclk_en_ln_*, only for the master lane */
1730 val = cdns_torrent_dp_read(regmap, PHY_PMA_XCVR_PLLCLK_EN);
1731 val |= 1;
1732 cdns_torrent_dp_write(regmap, PHY_PMA_XCVR_PLLCLK_EN, val);
1733
1734 /*
1735 * PHY PMA registers configuration functions
1736 * Initialize PHY with max supported link rate, without SSC.
1737 */
1738 if (cdns_phy->ref_clk_rate == CLK_19_2_MHZ)
1739 cdns_torrent_dp_pma_cmn_vco_cfg_19_2mhz(cdns_phy,
1740 cdns_phy->max_bit_rate,
1741 false);
1742 else if (cdns_phy->ref_clk_rate == CLK_25_MHZ)
1743 cdns_torrent_dp_pma_cmn_vco_cfg_25mhz(cdns_phy,
1744 cdns_phy->max_bit_rate,
1745 false);
1746 else if (cdns_phy->ref_clk_rate == CLK_100_MHZ)
1747 cdns_torrent_dp_pma_cmn_vco_cfg_100mhz(cdns_phy,
1748 cdns_phy->max_bit_rate,
1749 false);
1750
1751 cdns_torrent_dp_pma_cmn_rate(cdns_phy, inst, cdns_phy->max_bit_rate,
1752 inst->num_lanes);
1753
1754 /* take out of reset */
1755 regmap_field_write(cdns_phy->phy_reset_ctrl, 0x1);
1756 }
1757
cdns_torrent_dp_start(struct cdns_torrent_phy * cdns_phy,struct cdns_torrent_inst * inst,struct phy * phy)1758 static int cdns_torrent_dp_start(struct cdns_torrent_phy *cdns_phy,
1759 struct cdns_torrent_inst *inst,
1760 struct phy *phy)
1761 {
1762 int ret;
1763
1764 ret = cdns_torrent_phy_on(phy);
1765 if (ret)
1766 return ret;
1767
1768 ret = cdns_torrent_dp_wait_pma_cmn_ready(cdns_phy);
1769 if (ret)
1770 return ret;
1771
1772 ret = cdns_torrent_dp_run(cdns_phy, inst, inst->num_lanes);
1773
1774 return ret;
1775 }
1776
cdns_torrent_dp_init(struct phy * phy)1777 static int cdns_torrent_dp_init(struct phy *phy)
1778 {
1779 struct cdns_torrent_inst *inst = phy_get_drvdata(phy);
1780 struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(phy->dev.parent);
1781 int ret;
1782
1783 switch (cdns_phy->ref_clk_rate) {
1784 case CLK_19_2_MHZ:
1785 case CLK_25_MHZ:
1786 case CLK_100_MHZ:
1787 /* Valid Ref Clock Rate */
1788 break;
1789 default:
1790 dev_err(cdns_phy->dev, "Unsupported Ref Clock Rate\n");
1791 return -EINVAL;
1792 }
1793
1794 ret = cdns_torrent_dp_get_pll(cdns_phy, TYPE_NONE);
1795 if (ret)
1796 return ret;
1797
1798 cdns_torrent_dp_common_init(cdns_phy, inst);
1799
1800 return cdns_torrent_dp_start(cdns_phy, inst, phy);
1801 }
1802
cdns_torrent_dp_multilink_init(struct cdns_torrent_phy * cdns_phy,struct cdns_torrent_inst * inst,struct phy * phy)1803 static int cdns_torrent_dp_multilink_init(struct cdns_torrent_phy *cdns_phy,
1804 struct cdns_torrent_inst *inst,
1805 struct phy *phy)
1806 {
1807 if (cdns_phy->ref_clk_rate != CLK_100_MHZ) {
1808 dev_err(cdns_phy->dev, "Unsupported Ref Clock Rate\n");
1809 return -EINVAL;
1810 }
1811
1812 cdns_torrent_dp_common_init(cdns_phy, inst);
1813
1814 return cdns_torrent_dp_start(cdns_phy, inst, phy);
1815 }
1816
cdns_torrent_derived_refclk_enable(struct clk_hw * hw)1817 static int cdns_torrent_derived_refclk_enable(struct clk_hw *hw)
1818 {
1819 struct cdns_torrent_derived_refclk *derived_refclk = to_cdns_torrent_derived_refclk(hw);
1820
1821 regmap_field_write(derived_refclk->cmn_cdiag_refclk_ovrd_4, 1);
1822 regmap_field_write(derived_refclk->phy_pipe_cmn_ctrl1_0, 1);
1823
1824 return 0;
1825 }
1826
cdns_torrent_derived_refclk_disable(struct clk_hw * hw)1827 static void cdns_torrent_derived_refclk_disable(struct clk_hw *hw)
1828 {
1829 struct cdns_torrent_derived_refclk *derived_refclk = to_cdns_torrent_derived_refclk(hw);
1830
1831 regmap_field_write(derived_refclk->phy_pipe_cmn_ctrl1_0, 0);
1832 regmap_field_write(derived_refclk->cmn_cdiag_refclk_ovrd_4, 0);
1833 }
1834
cdns_torrent_derived_refclk_is_enabled(struct clk_hw * hw)1835 static int cdns_torrent_derived_refclk_is_enabled(struct clk_hw *hw)
1836 {
1837 struct cdns_torrent_derived_refclk *derived_refclk = to_cdns_torrent_derived_refclk(hw);
1838 int val;
1839
1840 regmap_field_read(derived_refclk->cmn_cdiag_refclk_ovrd_4, &val);
1841
1842 return !!val;
1843 }
1844
1845 static const struct clk_ops cdns_torrent_derived_refclk_ops = {
1846 .enable = cdns_torrent_derived_refclk_enable,
1847 .disable = cdns_torrent_derived_refclk_disable,
1848 .is_enabled = cdns_torrent_derived_refclk_is_enabled,
1849 };
1850
cdns_torrent_derived_refclk_register(struct cdns_torrent_phy * cdns_phy)1851 static int cdns_torrent_derived_refclk_register(struct cdns_torrent_phy *cdns_phy)
1852 {
1853 struct cdns_torrent_derived_refclk *derived_refclk;
1854 struct device *dev = cdns_phy->dev;
1855 struct clk_init_data *init;
1856 const char *parent_name;
1857 char clk_name[100];
1858 struct clk_hw *hw;
1859 struct clk *clk;
1860 int ret;
1861
1862 derived_refclk = devm_kzalloc(dev, sizeof(*derived_refclk), GFP_KERNEL);
1863 if (!derived_refclk)
1864 return -ENOMEM;
1865
1866 snprintf(clk_name, sizeof(clk_name), "%s_%s", dev_name(dev),
1867 clk_names[CDNS_TORRENT_DERIVED_REFCLK]);
1868
1869 clk = devm_clk_get_optional(dev, "phy_en_refclk");
1870 if (IS_ERR(clk)) {
1871 dev_err(dev, "No parent clock for derived_refclk\n");
1872 return PTR_ERR(clk);
1873 }
1874
1875 init = &derived_refclk->clk_data;
1876
1877 if (clk) {
1878 parent_name = __clk_get_name(clk);
1879 init->parent_names = &parent_name;
1880 init->num_parents = 1;
1881 }
1882 init->ops = &cdns_torrent_derived_refclk_ops;
1883 init->flags = 0;
1884 init->name = clk_name;
1885
1886 derived_refclk->phy_pipe_cmn_ctrl1_0 = cdns_phy->phy_pipe_cmn_ctrl1_0;
1887 derived_refclk->cmn_cdiag_refclk_ovrd_4 = cdns_phy->cmn_cdiag_refclk_ovrd_4;
1888
1889 derived_refclk->hw.init = init;
1890
1891 hw = &derived_refclk->hw;
1892 ret = devm_clk_hw_register(dev, hw);
1893 if (ret)
1894 return ret;
1895
1896 cdns_phy->clk_hw_data->hws[CDNS_TORRENT_DERIVED_REFCLK] = hw;
1897
1898 return 0;
1899 }
1900
cdns_torrent_received_refclk_enable(struct clk_hw * hw)1901 static int cdns_torrent_received_refclk_enable(struct clk_hw *hw)
1902 {
1903 struct cdns_torrent_received_refclk *received_refclk = to_cdns_torrent_received_refclk(hw);
1904
1905 regmap_field_write(received_refclk->phy_pipe_cmn_ctrl1_0, 1);
1906
1907 return 0;
1908 }
1909
cdns_torrent_received_refclk_disable(struct clk_hw * hw)1910 static void cdns_torrent_received_refclk_disable(struct clk_hw *hw)
1911 {
1912 struct cdns_torrent_received_refclk *received_refclk = to_cdns_torrent_received_refclk(hw);
1913
1914 regmap_field_write(received_refclk->phy_pipe_cmn_ctrl1_0, 0);
1915 }
1916
cdns_torrent_received_refclk_is_enabled(struct clk_hw * hw)1917 static int cdns_torrent_received_refclk_is_enabled(struct clk_hw *hw)
1918 {
1919 struct cdns_torrent_received_refclk *received_refclk = to_cdns_torrent_received_refclk(hw);
1920 int val, cmn_val;
1921
1922 regmap_field_read(received_refclk->phy_pipe_cmn_ctrl1_0, &val);
1923 regmap_field_read(received_refclk->cmn_cdiag_refclk_ovrd_4, &cmn_val);
1924
1925 return val && !cmn_val;
1926 }
1927
1928 static const struct clk_ops cdns_torrent_received_refclk_ops = {
1929 .enable = cdns_torrent_received_refclk_enable,
1930 .disable = cdns_torrent_received_refclk_disable,
1931 .is_enabled = cdns_torrent_received_refclk_is_enabled,
1932 };
1933
cdns_torrent_received_refclk_register(struct cdns_torrent_phy * cdns_phy)1934 static int cdns_torrent_received_refclk_register(struct cdns_torrent_phy *cdns_phy)
1935 {
1936 struct cdns_torrent_received_refclk *received_refclk;
1937 struct device *dev = cdns_phy->dev;
1938 struct clk_init_data *init;
1939 const char *parent_name;
1940 char clk_name[100];
1941 struct clk_hw *hw;
1942 struct clk *clk;
1943 int ret;
1944
1945 received_refclk = devm_kzalloc(dev, sizeof(*received_refclk), GFP_KERNEL);
1946 if (!received_refclk)
1947 return -ENOMEM;
1948
1949 snprintf(clk_name, sizeof(clk_name), "%s_%s", dev_name(dev),
1950 clk_names[CDNS_TORRENT_RECEIVED_REFCLK]);
1951
1952 clk = devm_clk_get_optional(dev, "phy_en_refclk");
1953 if (IS_ERR(clk)) {
1954 dev_err(dev, "No parent clock for received_refclk\n");
1955 return PTR_ERR(clk);
1956 }
1957
1958 init = &received_refclk->clk_data;
1959
1960 if (clk) {
1961 parent_name = __clk_get_name(clk);
1962 init->parent_names = &parent_name;
1963 init->num_parents = 1;
1964 }
1965 init->ops = &cdns_torrent_received_refclk_ops;
1966 init->flags = 0;
1967 init->name = clk_name;
1968
1969 received_refclk->phy_pipe_cmn_ctrl1_0 = cdns_phy->phy_pipe_cmn_ctrl1_0;
1970 received_refclk->cmn_cdiag_refclk_ovrd_4 = cdns_phy->cmn_cdiag_refclk_ovrd_4;
1971
1972 received_refclk->hw.init = init;
1973
1974 hw = &received_refclk->hw;
1975 ret = devm_clk_hw_register(dev, hw);
1976 if (ret)
1977 return ret;
1978
1979 cdns_phy->clk_hw_data->hws[CDNS_TORRENT_RECEIVED_REFCLK] = hw;
1980
1981 return 0;
1982 }
1983
cdns_torrent_refclk_driver_enable(struct clk_hw * hw)1984 static int cdns_torrent_refclk_driver_enable(struct clk_hw *hw)
1985 {
1986 struct cdns_torrent_refclk_driver *refclk_driver = to_cdns_torrent_refclk_driver(hw);
1987
1988 regmap_field_write(refclk_driver->cmn_fields[CMN_CDIAG_REFCLK_DRV0_CTRL_6], 0);
1989 regmap_field_write(refclk_driver->cmn_fields[CMN_CDIAG_REFCLK_DRV0_CTRL_5], 1);
1990 regmap_field_write(refclk_driver->cmn_fields[CMN_CDIAG_REFCLK_DRV0_CTRL_1], 0);
1991
1992 return 0;
1993 }
1994
cdns_torrent_refclk_driver_disable(struct clk_hw * hw)1995 static void cdns_torrent_refclk_driver_disable(struct clk_hw *hw)
1996 {
1997 struct cdns_torrent_refclk_driver *refclk_driver = to_cdns_torrent_refclk_driver(hw);
1998
1999 regmap_field_write(refclk_driver->cmn_fields[CMN_CDIAG_REFCLK_DRV0_CTRL_1], 1);
2000 }
2001
cdns_torrent_refclk_driver_is_enabled(struct clk_hw * hw)2002 static int cdns_torrent_refclk_driver_is_enabled(struct clk_hw *hw)
2003 {
2004 struct cdns_torrent_refclk_driver *refclk_driver = to_cdns_torrent_refclk_driver(hw);
2005 int val;
2006
2007 regmap_field_read(refclk_driver->cmn_fields[CMN_CDIAG_REFCLK_DRV0_CTRL_1], &val);
2008
2009 return !val;
2010 }
2011
cdns_torrent_refclk_driver_get_parent(struct clk_hw * hw)2012 static u8 cdns_torrent_refclk_driver_get_parent(struct clk_hw *hw)
2013 {
2014 struct cdns_torrent_refclk_driver *refclk_driver = to_cdns_torrent_refclk_driver(hw);
2015 unsigned int val;
2016
2017 regmap_field_read(refclk_driver->cmn_fields[CMN_CDIAG_REFCLK_DRV0_CTRL_4], &val);
2018 return clk_mux_val_to_index(hw, cdns_torrent_refclk_driver_mux_table, 0, val);
2019 }
2020
cdns_torrent_refclk_driver_set_parent(struct clk_hw * hw,u8 index)2021 static int cdns_torrent_refclk_driver_set_parent(struct clk_hw *hw, u8 index)
2022 {
2023 struct cdns_torrent_refclk_driver *refclk_driver = to_cdns_torrent_refclk_driver(hw);
2024 unsigned int val;
2025
2026 val = cdns_torrent_refclk_driver_mux_table[index];
2027 return regmap_field_write(refclk_driver->cmn_fields[CMN_CDIAG_REFCLK_DRV0_CTRL_4], val);
2028 }
2029
2030 static const struct clk_ops cdns_torrent_refclk_driver_ops = {
2031 .enable = cdns_torrent_refclk_driver_enable,
2032 .disable = cdns_torrent_refclk_driver_disable,
2033 .is_enabled = cdns_torrent_refclk_driver_is_enabled,
2034 .determine_rate = __clk_mux_determine_rate,
2035 .set_parent = cdns_torrent_refclk_driver_set_parent,
2036 .get_parent = cdns_torrent_refclk_driver_get_parent,
2037 };
2038
cdns_torrent_refclk_driver_register(struct cdns_torrent_phy * cdns_phy)2039 static int cdns_torrent_refclk_driver_register(struct cdns_torrent_phy *cdns_phy)
2040 {
2041 struct cdns_torrent_refclk_driver *refclk_driver;
2042 struct device *dev = cdns_phy->dev;
2043 struct regmap_field *field;
2044 struct clk_init_data *init;
2045 const char **parent_names;
2046 unsigned int num_parents;
2047 struct regmap *regmap;
2048 char clk_name[100];
2049 struct clk_hw *hw;
2050 int i, ret;
2051
2052 refclk_driver = devm_kzalloc(dev, sizeof(*refclk_driver), GFP_KERNEL);
2053 if (!refclk_driver)
2054 return -ENOMEM;
2055
2056 num_parents = ARRAY_SIZE(refclk_driver_parent_index);
2057 parent_names = devm_kzalloc(dev, (sizeof(char *) * num_parents), GFP_KERNEL);
2058 if (!parent_names)
2059 return -ENOMEM;
2060
2061 for (i = 0; i < num_parents; i++) {
2062 hw = cdns_phy->clk_hw_data->hws[refclk_driver_parent_index[i]];
2063 if (IS_ERR_OR_NULL(hw)) {
2064 dev_err(dev, "No parent clock for refclk driver clock\n");
2065 return IS_ERR(hw) ? PTR_ERR(hw) : -ENOENT;
2066 }
2067 parent_names[i] = clk_hw_get_name(hw);
2068 }
2069
2070 snprintf(clk_name, sizeof(clk_name), "%s_%s", dev_name(dev),
2071 clk_names[CDNS_TORRENT_REFCLK_DRIVER]);
2072
2073 init = &refclk_driver->clk_data;
2074
2075 init->ops = &cdns_torrent_refclk_driver_ops;
2076 init->flags = CLK_SET_RATE_NO_REPARENT;
2077 init->parent_names = parent_names;
2078 init->num_parents = num_parents;
2079 init->name = clk_name;
2080
2081 regmap = cdns_phy->regmap_common_cdb;
2082
2083 for (i = 0; i < REFCLK_OUT_NUM_CMN_CONFIG; i++) {
2084 field = devm_regmap_field_alloc(dev, regmap, refclk_out_cmn_cfg[i]);
2085 if (IS_ERR(field)) {
2086 dev_err(dev, "Refclk driver CMN reg field init failed\n");
2087 return PTR_ERR(field);
2088 }
2089 refclk_driver->cmn_fields[i] = field;
2090 }
2091
2092 /* Enable Derived reference clock as default */
2093 regmap_field_write(refclk_driver->cmn_fields[CMN_CDIAG_REFCLK_DRV0_CTRL_4], 1);
2094
2095 refclk_driver->hw.init = init;
2096
2097 hw = &refclk_driver->hw;
2098 ret = devm_clk_hw_register(dev, hw);
2099 if (ret)
2100 return ret;
2101
2102 cdns_phy->clk_hw_data->hws[CDNS_TORRENT_REFCLK_DRIVER] = hw;
2103
2104 return 0;
2105 }
2106
cdns_regmap_init(struct device * dev,void __iomem * base,u32 block_offset,u8 reg_offset_shift,const struct regmap_config * config)2107 static struct regmap *cdns_regmap_init(struct device *dev, void __iomem *base,
2108 u32 block_offset,
2109 u8 reg_offset_shift,
2110 const struct regmap_config *config)
2111 {
2112 struct cdns_regmap_cdb_context *ctx;
2113
2114 ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
2115 if (!ctx)
2116 return ERR_PTR(-ENOMEM);
2117
2118 ctx->dev = dev;
2119 ctx->base = base + block_offset;
2120 ctx->reg_offset_shift = reg_offset_shift;
2121
2122 return devm_regmap_init(dev, NULL, ctx, config);
2123 }
2124
cdns_torrent_dp_regfield_init(struct cdns_torrent_phy * cdns_phy)2125 static int cdns_torrent_dp_regfield_init(struct cdns_torrent_phy *cdns_phy)
2126 {
2127 struct device *dev = cdns_phy->dev;
2128 struct regmap_field *field;
2129 struct regmap *regmap;
2130
2131 regmap = cdns_phy->regmap_dptx_phy_reg;
2132 field = devm_regmap_field_alloc(dev, regmap, phy_reset_ctrl);
2133 if (IS_ERR(field)) {
2134 dev_err(dev, "PHY_RESET reg field init failed\n");
2135 return PTR_ERR(field);
2136 }
2137 cdns_phy->phy_reset_ctrl = field;
2138
2139 return 0;
2140 }
2141
cdns_torrent_regfield_init(struct cdns_torrent_phy * cdns_phy)2142 static int cdns_torrent_regfield_init(struct cdns_torrent_phy *cdns_phy)
2143 {
2144 struct device *dev = cdns_phy->dev;
2145 struct regmap_field *field;
2146 struct regmap *regmap;
2147 int i;
2148
2149 regmap = cdns_phy->regmap_phy_pcs_common_cdb;
2150 field = devm_regmap_field_alloc(dev, regmap, phy_pll_cfg);
2151 if (IS_ERR(field)) {
2152 dev_err(dev, "PHY_PLL_CFG reg field init failed\n");
2153 return PTR_ERR(field);
2154 }
2155 cdns_phy->phy_pll_cfg = field;
2156
2157 regmap = cdns_phy->regmap_phy_pcs_common_cdb;
2158 field = devm_regmap_field_alloc(dev, regmap, phy_pipe_cmn_ctrl1_0);
2159 if (IS_ERR(field)) {
2160 dev_err(dev, "phy_pipe_cmn_ctrl1_0 reg field init failed\n");
2161 return PTR_ERR(field);
2162 }
2163 cdns_phy->phy_pipe_cmn_ctrl1_0 = field;
2164
2165 regmap = cdns_phy->regmap_common_cdb;
2166 field = devm_regmap_field_alloc(dev, regmap, cmn_cdiag_refclk_ovrd_4);
2167 if (IS_ERR(field)) {
2168 dev_err(dev, "cmn_cdiag_refclk_ovrd_4 reg field init failed\n");
2169 return PTR_ERR(field);
2170 }
2171 cdns_phy->cmn_cdiag_refclk_ovrd_4 = field;
2172
2173 regmap = cdns_phy->regmap_phy_pma_common_cdb;
2174 field = devm_regmap_field_alloc(dev, regmap, phy_pma_cmn_ctrl_1);
2175 if (IS_ERR(field)) {
2176 dev_err(dev, "PHY_PMA_CMN_CTRL1 reg field init failed\n");
2177 return PTR_ERR(field);
2178 }
2179 cdns_phy->phy_pma_cmn_ctrl_1 = field;
2180
2181 regmap = cdns_phy->regmap_phy_pma_common_cdb;
2182 field = devm_regmap_field_alloc(dev, regmap, phy_pma_cmn_ctrl_2);
2183 if (IS_ERR(field)) {
2184 dev_err(dev, "PHY_PMA_CMN_CTRL2 reg field init failed\n");
2185 return PTR_ERR(field);
2186 }
2187 cdns_phy->phy_pma_cmn_ctrl_2 = field;
2188
2189 regmap = cdns_phy->regmap_phy_pma_common_cdb;
2190 field = devm_regmap_field_alloc(dev, regmap, phy_pma_pll_raw_ctrl);
2191 if (IS_ERR(field)) {
2192 dev_err(dev, "PHY_PMA_PLL_RAW_CTRL reg field init failed\n");
2193 return PTR_ERR(field);
2194 }
2195 cdns_phy->phy_pma_pll_raw_ctrl = field;
2196
2197 for (i = 0; i < MAX_NUM_LANES; i++) {
2198 regmap = cdns_phy->regmap_phy_pcs_lane_cdb[i];
2199 field = devm_regmap_field_alloc(dev, regmap, phy_pcs_iso_link_ctrl_1);
2200 if (IS_ERR(field)) {
2201 dev_err(dev, "PHY_PCS_ISO_LINK_CTRL reg field init for ln %d failed\n", i);
2202 return PTR_ERR(field);
2203 }
2204 cdns_phy->phy_pcs_iso_link_ctrl_1[i] = field;
2205 }
2206
2207 return 0;
2208 }
2209
cdns_torrent_dp_regmap_init(struct cdns_torrent_phy * cdns_phy)2210 static int cdns_torrent_dp_regmap_init(struct cdns_torrent_phy *cdns_phy)
2211 {
2212 void __iomem *base = cdns_phy->base;
2213 struct device *dev = cdns_phy->dev;
2214 struct regmap *regmap;
2215 u8 reg_offset_shift;
2216 u32 block_offset;
2217
2218 reg_offset_shift = cdns_phy->init_data->reg_offset_shift;
2219
2220 block_offset = TORRENT_DPTX_PHY_OFFSET;
2221 regmap = cdns_regmap_init(dev, base, block_offset,
2222 reg_offset_shift,
2223 &cdns_torrent_dptx_phy_config);
2224 if (IS_ERR(regmap)) {
2225 dev_err(dev, "Failed to init DPTX PHY regmap\n");
2226 return PTR_ERR(regmap);
2227 }
2228 cdns_phy->regmap_dptx_phy_reg = regmap;
2229
2230 return 0;
2231 }
2232
cdns_torrent_regmap_init(struct cdns_torrent_phy * cdns_phy)2233 static int cdns_torrent_regmap_init(struct cdns_torrent_phy *cdns_phy)
2234 {
2235 void __iomem *sd_base = cdns_phy->sd_base;
2236 u8 block_offset_shift, reg_offset_shift;
2237 struct device *dev = cdns_phy->dev;
2238 struct regmap *regmap;
2239 u32 block_offset;
2240 int i;
2241
2242 block_offset_shift = cdns_phy->init_data->block_offset_shift;
2243 reg_offset_shift = cdns_phy->init_data->reg_offset_shift;
2244
2245 for (i = 0; i < MAX_NUM_LANES; i++) {
2246 block_offset = TORRENT_TX_LANE_CDB_OFFSET(i, block_offset_shift,
2247 reg_offset_shift);
2248 regmap = cdns_regmap_init(dev, sd_base, block_offset,
2249 reg_offset_shift,
2250 &cdns_torrent_tx_lane_cdb_config[i]);
2251 if (IS_ERR(regmap)) {
2252 dev_err(dev, "Failed to init tx lane CDB regmap\n");
2253 return PTR_ERR(regmap);
2254 }
2255 cdns_phy->regmap_tx_lane_cdb[i] = regmap;
2256
2257 block_offset = TORRENT_RX_LANE_CDB_OFFSET(i, block_offset_shift,
2258 reg_offset_shift);
2259 regmap = cdns_regmap_init(dev, sd_base, block_offset,
2260 reg_offset_shift,
2261 &cdns_torrent_rx_lane_cdb_config[i]);
2262 if (IS_ERR(regmap)) {
2263 dev_err(dev, "Failed to init rx lane CDB regmap\n");
2264 return PTR_ERR(regmap);
2265 }
2266 cdns_phy->regmap_rx_lane_cdb[i] = regmap;
2267
2268 block_offset = TORRENT_PHY_PCS_LANE_CDB_OFFSET(i, block_offset_shift,
2269 reg_offset_shift);
2270 regmap = cdns_regmap_init(dev, sd_base, block_offset,
2271 reg_offset_shift,
2272 &cdns_torrent_phy_pcs_lane_cdb_config[i]);
2273 if (IS_ERR(regmap)) {
2274 dev_err(dev, "Failed to init PHY PCS lane CDB regmap\n");
2275 return PTR_ERR(regmap);
2276 }
2277 cdns_phy->regmap_phy_pcs_lane_cdb[i] = regmap;
2278 }
2279
2280 block_offset = TORRENT_COMMON_CDB_OFFSET;
2281 regmap = cdns_regmap_init(dev, sd_base, block_offset,
2282 reg_offset_shift,
2283 &cdns_torrent_common_cdb_config);
2284 if (IS_ERR(regmap)) {
2285 dev_err(dev, "Failed to init common CDB regmap\n");
2286 return PTR_ERR(regmap);
2287 }
2288 cdns_phy->regmap_common_cdb = regmap;
2289
2290 block_offset = TORRENT_PHY_PCS_COMMON_OFFSET(block_offset_shift);
2291 regmap = cdns_regmap_init(dev, sd_base, block_offset,
2292 reg_offset_shift,
2293 &cdns_torrent_phy_pcs_cmn_cdb_config);
2294 if (IS_ERR(regmap)) {
2295 dev_err(dev, "Failed to init PHY PCS common CDB regmap\n");
2296 return PTR_ERR(regmap);
2297 }
2298 cdns_phy->regmap_phy_pcs_common_cdb = regmap;
2299
2300 block_offset = TORRENT_PHY_PMA_COMMON_OFFSET(block_offset_shift);
2301 regmap = cdns_regmap_init(dev, sd_base, block_offset,
2302 reg_offset_shift,
2303 &cdns_torrent_phy_pma_cmn_cdb_config);
2304 if (IS_ERR(regmap)) {
2305 dev_err(dev, "Failed to init PHY PMA common CDB regmap\n");
2306 return PTR_ERR(regmap);
2307 }
2308 cdns_phy->regmap_phy_pma_common_cdb = regmap;
2309
2310 return 0;
2311 }
2312
cdns_torrent_phy_init(struct phy * phy)2313 static int cdns_torrent_phy_init(struct phy *phy)
2314 {
2315 struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(phy->dev.parent);
2316 const struct cdns_torrent_vals *cmn_vals, *tx_ln_vals, *rx_ln_vals;
2317 const struct cdns_torrent_data *init_data = cdns_phy->init_data;
2318 const struct cdns_torrent_vals *link_cmn_vals, *xcvr_diag_vals;
2319 enum cdns_torrent_ref_clk ref_clk = cdns_phy->ref_clk_rate;
2320 struct cdns_torrent_inst *inst = phy_get_drvdata(phy);
2321 enum cdns_torrent_phy_type phy_type = inst->phy_type;
2322 const struct cdns_torrent_vals *phy_pma_cmn_vals;
2323 enum cdns_torrent_ssc_mode ssc = inst->ssc_mode;
2324 const struct cdns_torrent_vals *pcs_cmn_vals;
2325 const struct cdns_reg_pairs *reg_pairs;
2326 struct regmap *regmap;
2327 u32 num_regs;
2328 int i, j;
2329
2330 if (cdns_phy->already_configured)
2331 return 0;
2332
2333 if (cdns_phy->nsubnodes > 1) {
2334 if (phy_type == TYPE_DP)
2335 return cdns_torrent_dp_multilink_init(cdns_phy, inst, phy);
2336 return 0;
2337 }
2338
2339 /**
2340 * Spread spectrum generation is not required or supported
2341 * for SGMII/QSGMII/USXGMII
2342 */
2343 if (phy_type == TYPE_SGMII || phy_type == TYPE_QSGMII || phy_type == TYPE_USXGMII)
2344 ssc = NO_SSC;
2345
2346 /* PHY configuration specific registers for single link */
2347 link_cmn_vals = cdns_torrent_get_tbl_vals(&init_data->link_cmn_vals_tbl,
2348 CLK_ANY, CLK_ANY,
2349 phy_type, TYPE_NONE,
2350 ANY_SSC);
2351 if (link_cmn_vals) {
2352 reg_pairs = link_cmn_vals->reg_pairs;
2353 num_regs = link_cmn_vals->num_regs;
2354 regmap = cdns_phy->regmap_common_cdb;
2355
2356 /**
2357 * First array value in link_cmn_vals must be of
2358 * PHY_PLL_CFG register
2359 */
2360 regmap_field_write(cdns_phy->phy_pll_cfg, reg_pairs[0].val);
2361
2362 for (i = 1; i < num_regs; i++)
2363 regmap_write(regmap, reg_pairs[i].off,
2364 reg_pairs[i].val);
2365 }
2366
2367 xcvr_diag_vals = cdns_torrent_get_tbl_vals(&init_data->xcvr_diag_vals_tbl,
2368 CLK_ANY, CLK_ANY,
2369 phy_type, TYPE_NONE,
2370 ANY_SSC);
2371 if (xcvr_diag_vals) {
2372 reg_pairs = xcvr_diag_vals->reg_pairs;
2373 num_regs = xcvr_diag_vals->num_regs;
2374 for (i = 0; i < inst->num_lanes; i++) {
2375 regmap = cdns_phy->regmap_tx_lane_cdb[i + inst->mlane];
2376 for (j = 0; j < num_regs; j++)
2377 regmap_write(regmap, reg_pairs[j].off,
2378 reg_pairs[j].val);
2379 }
2380 }
2381
2382 /* PHY PCS common registers configurations */
2383 pcs_cmn_vals = cdns_torrent_get_tbl_vals(&init_data->pcs_cmn_vals_tbl,
2384 CLK_ANY, CLK_ANY,
2385 phy_type, TYPE_NONE,
2386 ANY_SSC);
2387 if (pcs_cmn_vals) {
2388 reg_pairs = pcs_cmn_vals->reg_pairs;
2389 num_regs = pcs_cmn_vals->num_regs;
2390 regmap = cdns_phy->regmap_phy_pcs_common_cdb;
2391 for (i = 0; i < num_regs; i++)
2392 regmap_write(regmap, reg_pairs[i].off,
2393 reg_pairs[i].val);
2394 }
2395
2396 /* PHY PMA common registers configurations */
2397 phy_pma_cmn_vals = cdns_torrent_get_tbl_vals(&init_data->phy_pma_cmn_vals_tbl,
2398 CLK_ANY, CLK_ANY,
2399 phy_type, TYPE_NONE,
2400 ANY_SSC);
2401 if (phy_pma_cmn_vals) {
2402 reg_pairs = phy_pma_cmn_vals->reg_pairs;
2403 num_regs = phy_pma_cmn_vals->num_regs;
2404 regmap = cdns_phy->regmap_phy_pma_common_cdb;
2405 for (i = 0; i < num_regs; i++)
2406 regmap_write(regmap, reg_pairs[i].off,
2407 reg_pairs[i].val);
2408 }
2409
2410 /* PMA common registers configurations */
2411 cmn_vals = cdns_torrent_get_tbl_vals(&init_data->cmn_vals_tbl,
2412 ref_clk, ref_clk,
2413 phy_type, TYPE_NONE,
2414 ssc);
2415 if (cmn_vals) {
2416 reg_pairs = cmn_vals->reg_pairs;
2417 num_regs = cmn_vals->num_regs;
2418 regmap = cdns_phy->regmap_common_cdb;
2419 for (i = 0; i < num_regs; i++)
2420 regmap_write(regmap, reg_pairs[i].off,
2421 reg_pairs[i].val);
2422 }
2423
2424 /* PMA TX lane registers configurations */
2425 tx_ln_vals = cdns_torrent_get_tbl_vals(&init_data->tx_ln_vals_tbl,
2426 ref_clk, ref_clk,
2427 phy_type, TYPE_NONE,
2428 ssc);
2429 if (tx_ln_vals) {
2430 reg_pairs = tx_ln_vals->reg_pairs;
2431 num_regs = tx_ln_vals->num_regs;
2432 for (i = 0; i < inst->num_lanes; i++) {
2433 regmap = cdns_phy->regmap_tx_lane_cdb[i + inst->mlane];
2434 for (j = 0; j < num_regs; j++)
2435 regmap_write(regmap, reg_pairs[j].off,
2436 reg_pairs[j].val);
2437 }
2438 }
2439
2440 /* PMA RX lane registers configurations */
2441 rx_ln_vals = cdns_torrent_get_tbl_vals(&init_data->rx_ln_vals_tbl,
2442 ref_clk, ref_clk,
2443 phy_type, TYPE_NONE,
2444 ssc);
2445 if (rx_ln_vals) {
2446 reg_pairs = rx_ln_vals->reg_pairs;
2447 num_regs = rx_ln_vals->num_regs;
2448 for (i = 0; i < inst->num_lanes; i++) {
2449 regmap = cdns_phy->regmap_rx_lane_cdb[i + inst->mlane];
2450 for (j = 0; j < num_regs; j++)
2451 regmap_write(regmap, reg_pairs[j].off,
2452 reg_pairs[j].val);
2453 }
2454 }
2455
2456 if (phy_type == TYPE_DP)
2457 return cdns_torrent_dp_init(phy);
2458
2459 return 0;
2460 }
2461
2462 static const struct phy_ops cdns_torrent_phy_ops = {
2463 .init = cdns_torrent_phy_init,
2464 .configure = cdns_torrent_dp_configure,
2465 .power_on = cdns_torrent_phy_on,
2466 .power_off = cdns_torrent_phy_off,
2467 .owner = THIS_MODULE,
2468 };
2469
2470 static
cdns_torrent_phy_configure_multilink(struct cdns_torrent_phy * cdns_phy)2471 int cdns_torrent_phy_configure_multilink(struct cdns_torrent_phy *cdns_phy)
2472 {
2473 const struct cdns_torrent_vals *cmn_vals, *tx_ln_vals, *rx_ln_vals;
2474 const struct cdns_torrent_data *init_data = cdns_phy->init_data;
2475 const struct cdns_torrent_vals *link_cmn_vals, *xcvr_diag_vals;
2476 enum cdns_torrent_ref_clk ref_clk1 = cdns_phy->ref_clk1_rate;
2477 enum cdns_torrent_ref_clk ref_clk = cdns_phy->ref_clk_rate;
2478 const struct cdns_torrent_vals *phy_pma_cmn_vals;
2479 const struct cdns_torrent_vals *pcs_cmn_vals;
2480 enum cdns_torrent_phy_type phy_t1, phy_t2;
2481 const struct cdns_reg_pairs *reg_pairs;
2482 int i, j, node, mlane, num_lanes, ret;
2483 struct device *dev = cdns_phy->dev;
2484 enum cdns_torrent_ssc_mode ssc;
2485 struct regmap *regmap;
2486 u32 num_regs, num_protocols, protocol;
2487 u32 num_pcie_links = 0;
2488
2489 num_protocols = hweight32(cdns_phy->protocol_bitmask);
2490 /* Maximum 2 protocols are supported */
2491 if (num_protocols > 2) {
2492 dev_err(dev, "at most 2 protocols are supported\n");
2493 return -EINVAL;
2494 }
2495
2496
2497 /**
2498 * Get PHY types directly from subnodes if only 2 subnodes exist.
2499 * It is possible for phy_t1 to be the same as phy_t2 for special
2500 * configurations such as PCIe Multilink.
2501 */
2502 if (cdns_phy->nsubnodes == 2) {
2503 phy_t1 = cdns_phy->phys[0].phy_type;
2504 phy_t2 = cdns_phy->phys[1].phy_type;
2505 } else {
2506 /**
2507 * Both PHY types / protocols should be unique.
2508 * If they are the same, it should be expressed with either
2509 * a) Single-Link (1 Sub-node) - handled via PHY APIs
2510 * OR
2511 * b) Double-Link (2 Sub-nodes) - handled above
2512 */
2513 if (num_protocols != 2) {
2514 dev_err(dev, "incorrect representation of link\n");
2515 return -EINVAL;
2516 }
2517
2518 phy_t1 = fns(cdns_phy->protocol_bitmask, 0);
2519 phy_t2 = fns(cdns_phy->protocol_bitmask, 1);
2520
2521 /*
2522 * PCIe Multilink configuration can be supported along with a
2523 * non-PCIe protocol. The existing limitation associated with
2524 * the standalone PCIe Multilink configuration still remains,
2525 * implying that there can be only two links (subnodes) of the
2526 * PHY type PCIe which constitute the PCIe Multilink.
2527 *
2528 * Such configurations are handled by introducing a new protocol
2529 * namely TYPE_PCIE_ML. Both of the PCIe links which have the
2530 * protocol as TYPE_PCIE shall be treated as though the protocol
2531 * corresponding to them is TYPE_PCIE_ML only for the sake of
2532 * configuring the SERDES.
2533 *
2534 * PCIe Multilink configuration can be identified by checking if
2535 * there are exactly two links with phy_type set to TYPE_PCIE.
2536 * phy_t1 and phy_t2 are modified in such cases to support the
2537 * PCIe Multilink configuration with a non-PCIe protocol.
2538 */
2539 for (node = 0; node < cdns_phy->nsubnodes; node++) {
2540 if (cdns_phy->phys[node].phy_type == TYPE_PCIE)
2541 num_pcie_links++;
2542 }
2543
2544 if (num_pcie_links > 2) {
2545 dev_err(dev, "cannot support PCIe Multilink with %u PCIe links\n",
2546 num_pcie_links);
2547 return -EINVAL;
2548 } else if (num_pcie_links == 2) {
2549 phy_t1 = TYPE_PCIE_ML;
2550 for (node = 0; node < cdns_phy->nsubnodes; node++) {
2551 if (cdns_phy->phys[node].phy_type == TYPE_PCIE) {
2552 cdns_phy->phys[node].phy_type = TYPE_PCIE_ML;
2553 continue;
2554 }
2555 phy_t2 = cdns_phy->phys[node].phy_type;
2556 }
2557 }
2558 }
2559
2560 /**
2561 * Configure all links with the protocol phy_t1 first followed by
2562 * configuring all links with the protocol phy_t2.
2563 *
2564 * When phy_t1 = phy_t2, it is a single protocol and configuration
2565 * is performed with a single iteration of the protocol and multiple
2566 * iterations over the sub-nodes (links).
2567 *
2568 * When phy_t1 != phy_t2, there are two protocols and configuration
2569 * is performed by iterating over all sub-nodes matching the first
2570 * protocol and configuring them first, followed by iterating over
2571 * all sub-nodes matching the second protocol and configuring them
2572 * next.
2573 */
2574 for (protocol = 0; protocol < num_protocols; protocol++) {
2575 /**
2576 * For the case where num_protocols is 1,
2577 * phy_t1 = phy_t2 and the swap is unnecessary.
2578 *
2579 * Swapping phy_t1 and phy_t2 is only required when the
2580 * number of protocols is 2 and there are 2 or more links.
2581 */
2582 if (protocol == 1) {
2583 /**
2584 * If first protocol with phy_t1 is configured, then
2585 * configure the PHY for second protocol with phy_t2.
2586 * Get the array values as [phy_t2][phy_t1][ssc].
2587 */
2588 swap(phy_t1, phy_t2);
2589 swap(ref_clk, ref_clk1);
2590 }
2591
2592 for (node = 0; node < cdns_phy->nsubnodes; node++) {
2593 if (cdns_phy->phys[node].phy_type != phy_t1)
2594 continue;
2595
2596 mlane = cdns_phy->phys[node].mlane;
2597 ssc = cdns_phy->phys[node].ssc_mode;
2598 num_lanes = cdns_phy->phys[node].num_lanes;
2599
2600 /**
2601 * PHY configuration specific registers:
2602 * link_cmn_vals depend on combination of PHY types being
2603 * configured and are common for both PHY types, so array
2604 * values should be same for [phy_t1][phy_t2][ssc] and
2605 * [phy_t2][phy_t1][ssc].
2606 * xcvr_diag_vals also depend on combination of PHY types
2607 * being configured, but these can be different for particular
2608 * PHY type and are per lane.
2609 */
2610 link_cmn_vals = cdns_torrent_get_tbl_vals(&init_data->link_cmn_vals_tbl,
2611 CLK_ANY, CLK_ANY,
2612 phy_t1, phy_t2, ANY_SSC);
2613 if (link_cmn_vals) {
2614 reg_pairs = link_cmn_vals->reg_pairs;
2615 num_regs = link_cmn_vals->num_regs;
2616 regmap = cdns_phy->regmap_common_cdb;
2617
2618 /**
2619 * First array value in link_cmn_vals must be of
2620 * PHY_PLL_CFG register
2621 */
2622 regmap_field_write(cdns_phy->phy_pll_cfg,
2623 reg_pairs[0].val);
2624
2625 for (i = 1; i < num_regs; i++)
2626 regmap_write(regmap, reg_pairs[i].off,
2627 reg_pairs[i].val);
2628 }
2629
2630 xcvr_diag_vals = cdns_torrent_get_tbl_vals(&init_data->xcvr_diag_vals_tbl,
2631 CLK_ANY, CLK_ANY,
2632 phy_t1, phy_t2, ANY_SSC);
2633 if (xcvr_diag_vals) {
2634 reg_pairs = xcvr_diag_vals->reg_pairs;
2635 num_regs = xcvr_diag_vals->num_regs;
2636 for (i = 0; i < num_lanes; i++) {
2637 regmap = cdns_phy->regmap_tx_lane_cdb[i + mlane];
2638 for (j = 0; j < num_regs; j++)
2639 regmap_write(regmap, reg_pairs[j].off,
2640 reg_pairs[j].val);
2641 }
2642 }
2643
2644 /* PHY PCS common registers configurations */
2645 pcs_cmn_vals = cdns_torrent_get_tbl_vals(&init_data->pcs_cmn_vals_tbl,
2646 CLK_ANY, CLK_ANY,
2647 phy_t1, phy_t2, ANY_SSC);
2648 if (pcs_cmn_vals) {
2649 reg_pairs = pcs_cmn_vals->reg_pairs;
2650 num_regs = pcs_cmn_vals->num_regs;
2651 regmap = cdns_phy->regmap_phy_pcs_common_cdb;
2652 for (i = 0; i < num_regs; i++)
2653 regmap_write(regmap, reg_pairs[i].off,
2654 reg_pairs[i].val);
2655 }
2656
2657 /* PHY PMA common registers configurations */
2658 phy_pma_cmn_vals =
2659 cdns_torrent_get_tbl_vals(&init_data->phy_pma_cmn_vals_tbl,
2660 CLK_ANY, CLK_ANY, phy_t1, phy_t2,
2661 ANY_SSC);
2662 if (phy_pma_cmn_vals) {
2663 reg_pairs = phy_pma_cmn_vals->reg_pairs;
2664 num_regs = phy_pma_cmn_vals->num_regs;
2665 regmap = cdns_phy->regmap_phy_pma_common_cdb;
2666 for (i = 0; i < num_regs; i++)
2667 regmap_write(regmap, reg_pairs[i].off,
2668 reg_pairs[i].val);
2669 }
2670
2671 /* PMA common registers configurations */
2672 cmn_vals = cdns_torrent_get_tbl_vals(&init_data->cmn_vals_tbl,
2673 ref_clk, ref_clk1,
2674 phy_t1, phy_t2, ssc);
2675 if (cmn_vals) {
2676 reg_pairs = cmn_vals->reg_pairs;
2677 num_regs = cmn_vals->num_regs;
2678 regmap = cdns_phy->regmap_common_cdb;
2679 for (i = 0; i < num_regs; i++)
2680 regmap_write(regmap, reg_pairs[i].off,
2681 reg_pairs[i].val);
2682 }
2683
2684 /* PMA TX lane registers configurations */
2685 tx_ln_vals = cdns_torrent_get_tbl_vals(&init_data->tx_ln_vals_tbl,
2686 ref_clk, ref_clk1,
2687 phy_t1, phy_t2, ssc);
2688 if (tx_ln_vals) {
2689 reg_pairs = tx_ln_vals->reg_pairs;
2690 num_regs = tx_ln_vals->num_regs;
2691 for (i = 0; i < num_lanes; i++) {
2692 regmap = cdns_phy->regmap_tx_lane_cdb[i + mlane];
2693 for (j = 0; j < num_regs; j++)
2694 regmap_write(regmap, reg_pairs[j].off,
2695 reg_pairs[j].val);
2696 }
2697 }
2698
2699 /* PMA RX lane registers configurations */
2700 rx_ln_vals = cdns_torrent_get_tbl_vals(&init_data->rx_ln_vals_tbl,
2701 ref_clk, ref_clk1,
2702 phy_t1, phy_t2, ssc);
2703 if (rx_ln_vals) {
2704 reg_pairs = rx_ln_vals->reg_pairs;
2705 num_regs = rx_ln_vals->num_regs;
2706 for (i = 0; i < num_lanes; i++) {
2707 regmap = cdns_phy->regmap_rx_lane_cdb[i + mlane];
2708 for (j = 0; j < num_regs; j++)
2709 regmap_write(regmap, reg_pairs[j].off,
2710 reg_pairs[j].val);
2711 }
2712 }
2713
2714 if (phy_t1 == TYPE_DP) {
2715 ret = cdns_torrent_dp_get_pll(cdns_phy, phy_t2);
2716 if (ret)
2717 return ret;
2718 }
2719
2720 reset_control_deassert(cdns_phy->phys[node].lnk_rst);
2721 }
2722 }
2723
2724 /* Restore TYPE_PCIE_ML to TYPE_PCIE to be compatible with suspend-resume */
2725 for (node = 0; node < cdns_phy->nsubnodes; node++)
2726 if (cdns_phy->phys[node].phy_type == TYPE_PCIE_ML)
2727 cdns_phy->phys[node].phy_type = TYPE_PCIE;
2728
2729 /* Take the PHY out of reset */
2730 ret = reset_control_deassert(cdns_phy->phy_rst);
2731 if (ret)
2732 return ret;
2733
2734 return 0;
2735 }
2736
cdns_torrent_clk_cleanup(struct cdns_torrent_phy * cdns_phy)2737 static void cdns_torrent_clk_cleanup(struct cdns_torrent_phy *cdns_phy)
2738 {
2739 struct device *dev = cdns_phy->dev;
2740
2741 of_clk_del_provider(dev->of_node);
2742 }
2743
cdns_torrent_clk_register(struct cdns_torrent_phy * cdns_phy)2744 static int cdns_torrent_clk_register(struct cdns_torrent_phy *cdns_phy)
2745 {
2746 struct device *dev = cdns_phy->dev;
2747 struct device_node *node = dev->of_node;
2748 struct clk_hw_onecell_data *data;
2749 int ret;
2750
2751 data = devm_kzalloc(dev, struct_size(data, hws, CDNS_TORRENT_OUTPUT_CLOCKS), GFP_KERNEL);
2752 if (!data)
2753 return -ENOMEM;
2754
2755 data->num = CDNS_TORRENT_OUTPUT_CLOCKS;
2756 cdns_phy->clk_hw_data = data;
2757
2758 ret = cdns_torrent_derived_refclk_register(cdns_phy);
2759 if (ret) {
2760 dev_err(dev, "failed to register derived refclk\n");
2761 return ret;
2762 }
2763
2764 ret = cdns_torrent_received_refclk_register(cdns_phy);
2765 if (ret) {
2766 dev_err(dev, "failed to register received refclk\n");
2767 return ret;
2768 }
2769
2770 ret = cdns_torrent_refclk_driver_register(cdns_phy);
2771 if (ret) {
2772 dev_err(dev, "failed to register refclk driver\n");
2773 return ret;
2774 }
2775
2776 ret = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, data);
2777 if (ret) {
2778 dev_err(dev, "Failed to add clock provider: %s\n", node->name);
2779 return ret;
2780 }
2781
2782 return 0;
2783 }
2784
cdns_torrent_of_get_reset(struct cdns_torrent_phy * cdns_phy)2785 static int cdns_torrent_of_get_reset(struct cdns_torrent_phy *cdns_phy)
2786 {
2787 struct device *dev = cdns_phy->dev;
2788
2789 cdns_phy->phy_rst = devm_reset_control_get_exclusive_by_index(dev, 0);
2790 if (IS_ERR(cdns_phy->phy_rst)) {
2791 dev_err(dev, "%s: failed to get reset\n",
2792 dev->of_node->full_name);
2793 return PTR_ERR(cdns_phy->phy_rst);
2794 }
2795
2796 cdns_phy->apb_rst = devm_reset_control_get_optional_exclusive(dev, "torrent_apb");
2797 if (IS_ERR(cdns_phy->apb_rst)) {
2798 dev_err(dev, "%s: failed to get apb reset\n",
2799 dev->of_node->full_name);
2800 return PTR_ERR(cdns_phy->apb_rst);
2801 }
2802
2803 return 0;
2804 }
2805
cdns_torrent_of_get_clk(struct cdns_torrent_phy * cdns_phy)2806 static int cdns_torrent_of_get_clk(struct cdns_torrent_phy *cdns_phy)
2807 {
2808 /* refclk: Input reference clock for PLL0 */
2809 cdns_phy->clk = devm_clk_get(cdns_phy->dev, "refclk");
2810 if (IS_ERR(cdns_phy->clk))
2811 return dev_err_probe(cdns_phy->dev, PTR_ERR(cdns_phy->clk),
2812 "phy ref clock not found\n");
2813
2814 /* refclk1: Input reference clock for PLL1 */
2815 cdns_phy->clk1 = devm_clk_get_optional(cdns_phy->dev, "pll1_refclk");
2816 if (IS_ERR(cdns_phy->clk1))
2817 return dev_err_probe(cdns_phy->dev, PTR_ERR(cdns_phy->clk1),
2818 "phy PLL1 ref clock not found\n");
2819
2820 return 0;
2821 }
2822
cdns_torrent_clk(struct cdns_torrent_phy * cdns_phy)2823 static int cdns_torrent_clk(struct cdns_torrent_phy *cdns_phy)
2824 {
2825 unsigned long ref_clk1_rate;
2826 unsigned long ref_clk_rate;
2827 int ret;
2828
2829 ret = clk_prepare_enable(cdns_phy->clk);
2830 if (ret) {
2831 dev_err(cdns_phy->dev, "Failed to prepare ref clock: %d\n", ret);
2832 return ret;
2833 }
2834
2835 ref_clk_rate = clk_get_rate(cdns_phy->clk);
2836 if (!ref_clk_rate) {
2837 dev_err(cdns_phy->dev, "Failed to get ref clock rate\n");
2838 ret = -EINVAL;
2839 goto disable_clk;
2840 }
2841
2842 switch (ref_clk_rate) {
2843 case REF_CLK_19_2MHZ:
2844 cdns_phy->ref_clk_rate = CLK_19_2_MHZ;
2845 break;
2846 case REF_CLK_25MHZ:
2847 cdns_phy->ref_clk_rate = CLK_25_MHZ;
2848 break;
2849 case REF_CLK_100MHZ:
2850 cdns_phy->ref_clk_rate = CLK_100_MHZ;
2851 break;
2852 case REF_CLK_156_25MHZ:
2853 cdns_phy->ref_clk_rate = CLK_156_25_MHZ;
2854 break;
2855 default:
2856 dev_err(cdns_phy->dev, "Invalid ref clock rate\n");
2857 ret = -EINVAL;
2858 goto disable_clk;
2859 }
2860
2861 if (cdns_phy->clk1) {
2862 ret = clk_prepare_enable(cdns_phy->clk1);
2863 if (ret) {
2864 dev_err(cdns_phy->dev, "Failed to prepare PLL1 ref clock: %d\n", ret);
2865 goto disable_clk;
2866 }
2867
2868 ref_clk1_rate = clk_get_rate(cdns_phy->clk1);
2869 if (!ref_clk1_rate) {
2870 dev_err(cdns_phy->dev, "Failed to get PLL1 ref clock rate\n");
2871 ret = -EINVAL;
2872 goto disable_clk1;
2873 }
2874
2875 switch (ref_clk1_rate) {
2876 case REF_CLK_19_2MHZ:
2877 cdns_phy->ref_clk1_rate = CLK_19_2_MHZ;
2878 break;
2879 case REF_CLK_25MHZ:
2880 cdns_phy->ref_clk1_rate = CLK_25_MHZ;
2881 break;
2882 case REF_CLK_100MHZ:
2883 cdns_phy->ref_clk1_rate = CLK_100_MHZ;
2884 break;
2885 case REF_CLK_156_25MHZ:
2886 cdns_phy->ref_clk1_rate = CLK_156_25_MHZ;
2887 break;
2888 default:
2889 dev_err(cdns_phy->dev, "Invalid PLL1 ref clock rate\n");
2890 ret = -EINVAL;
2891 goto disable_clk1;
2892 }
2893 } else {
2894 cdns_phy->ref_clk1_rate = cdns_phy->ref_clk_rate;
2895 }
2896
2897 return 0;
2898
2899 disable_clk1:
2900 clk_disable_unprepare(cdns_phy->clk1);
2901 disable_clk:
2902 clk_disable_unprepare(cdns_phy->clk);
2903 return ret;
2904 }
2905
cdns_torrent_phy_probe(struct platform_device * pdev)2906 static int cdns_torrent_phy_probe(struct platform_device *pdev)
2907 {
2908 struct cdns_torrent_phy *cdns_phy;
2909 struct device *dev = &pdev->dev;
2910 struct phy_provider *phy_provider;
2911 const struct cdns_torrent_data *data;
2912 struct device_node *child;
2913 int ret, subnodes, node = 0, i;
2914 u32 total_num_lanes = 0;
2915 u8 init_dp_regmap = 0;
2916 u32 phy_type;
2917
2918 /* Get init data for this PHY */
2919 data = of_device_get_match_data(dev);
2920 if (!data)
2921 return -EINVAL;
2922
2923 cdns_phy = devm_kzalloc(dev, sizeof(*cdns_phy), GFP_KERNEL);
2924 if (!cdns_phy)
2925 return -ENOMEM;
2926
2927 dev_set_drvdata(dev, cdns_phy);
2928 cdns_phy->dev = dev;
2929 cdns_phy->init_data = data;
2930 cdns_phy->protocol_bitmask = 0;
2931
2932 cdns_phy->sd_base = devm_platform_ioremap_resource(pdev, 0);
2933 if (IS_ERR(cdns_phy->sd_base))
2934 return PTR_ERR(cdns_phy->sd_base);
2935
2936 subnodes = of_get_available_child_count(dev->of_node);
2937 if (subnodes == 0) {
2938 dev_err(dev, "No available link subnodes found\n");
2939 return -EINVAL;
2940 }
2941
2942 ret = cdns_torrent_regmap_init(cdns_phy);
2943 if (ret)
2944 return ret;
2945
2946 ret = cdns_torrent_regfield_init(cdns_phy);
2947 if (ret)
2948 return ret;
2949
2950 ret = cdns_torrent_clk_register(cdns_phy);
2951 if (ret)
2952 return ret;
2953
2954 ret = cdns_torrent_of_get_reset(cdns_phy);
2955 if (ret)
2956 goto clk_cleanup;
2957
2958 ret = cdns_torrent_of_get_clk(cdns_phy);
2959 if (ret)
2960 goto clk_cleanup;
2961
2962 regmap_field_read(cdns_phy->phy_pma_cmn_ctrl_1, &cdns_phy->already_configured);
2963
2964 if (!cdns_phy->already_configured) {
2965 ret = cdns_torrent_clk(cdns_phy);
2966 if (ret)
2967 goto clk_cleanup;
2968
2969 /* Enable APB */
2970 reset_control_deassert(cdns_phy->apb_rst);
2971 }
2972
2973 for_each_available_child_of_node(dev->of_node, child) {
2974 struct phy *gphy;
2975
2976 /* PHY subnode name must be 'phy'. */
2977 if (!(of_node_name_eq(child, "phy")))
2978 continue;
2979
2980 cdns_phy->phys[node].lnk_rst =
2981 of_reset_control_array_get_exclusive(child);
2982 if (IS_ERR(cdns_phy->phys[node].lnk_rst)) {
2983 dev_err(dev, "%s: failed to get reset\n",
2984 child->full_name);
2985 ret = PTR_ERR(cdns_phy->phys[node].lnk_rst);
2986 goto put_lnk_rst;
2987 }
2988
2989 if (of_property_read_u32(child, "reg",
2990 &cdns_phy->phys[node].mlane)) {
2991 dev_err(dev, "%s: No \"reg\"-property.\n",
2992 child->full_name);
2993 ret = -EINVAL;
2994 goto put_child;
2995 }
2996
2997 if (of_property_read_u32(child, "cdns,phy-type", &phy_type)) {
2998 dev_err(dev, "%s: No \"cdns,phy-type\"-property.\n",
2999 child->full_name);
3000 ret = -EINVAL;
3001 goto put_child;
3002 }
3003
3004 switch (phy_type) {
3005 case PHY_TYPE_PCIE:
3006 cdns_phy->phys[node].phy_type = TYPE_PCIE;
3007 break;
3008 case PHY_TYPE_DP:
3009 cdns_phy->phys[node].phy_type = TYPE_DP;
3010 break;
3011 case PHY_TYPE_SGMII:
3012 cdns_phy->phys[node].phy_type = TYPE_SGMII;
3013 break;
3014 case PHY_TYPE_QSGMII:
3015 cdns_phy->phys[node].phy_type = TYPE_QSGMII;
3016 break;
3017 case PHY_TYPE_USB3:
3018 cdns_phy->phys[node].phy_type = TYPE_USB;
3019 break;
3020 case PHY_TYPE_USXGMII:
3021 cdns_phy->phys[node].phy_type = TYPE_USXGMII;
3022 break;
3023 default:
3024 dev_err(dev, "Unsupported protocol\n");
3025 ret = -EINVAL;
3026 goto put_child;
3027 }
3028
3029 if (of_property_read_u32(child, "cdns,num-lanes",
3030 &cdns_phy->phys[node].num_lanes)) {
3031 dev_err(dev, "%s: No \"cdns,num-lanes\"-property.\n",
3032 child->full_name);
3033 ret = -EINVAL;
3034 goto put_child;
3035 }
3036
3037 total_num_lanes += cdns_phy->phys[node].num_lanes;
3038
3039 /* Get SSC mode */
3040 cdns_phy->phys[node].ssc_mode = NO_SSC;
3041 of_property_read_u32(child, "cdns,ssc-mode",
3042 &cdns_phy->phys[node].ssc_mode);
3043
3044 gphy = devm_phy_create(dev, child, &cdns_torrent_phy_ops);
3045 if (IS_ERR(gphy)) {
3046 ret = PTR_ERR(gphy);
3047 goto put_child;
3048 }
3049
3050 if (cdns_phy->phys[node].phy_type == TYPE_DP) {
3051 switch (cdns_phy->phys[node].num_lanes) {
3052 case 1:
3053 case 2:
3054 case 4:
3055 /* valid number of lanes */
3056 break;
3057 default:
3058 dev_err(dev, "unsupported number of lanes: %d\n",
3059 cdns_phy->phys[node].num_lanes);
3060 ret = -EINVAL;
3061 goto put_child;
3062 }
3063
3064 cdns_phy->max_bit_rate = DEFAULT_MAX_BIT_RATE;
3065 of_property_read_u32(child, "cdns,max-bit-rate",
3066 &cdns_phy->max_bit_rate);
3067
3068 switch (cdns_phy->max_bit_rate) {
3069 case 1620:
3070 case 2160:
3071 case 2430:
3072 case 2700:
3073 case 3240:
3074 case 4320:
3075 case 5400:
3076 case 8100:
3077 /* valid bit rate */
3078 break;
3079 default:
3080 dev_err(dev, "unsupported max bit rate: %dMbps\n",
3081 cdns_phy->max_bit_rate);
3082 ret = -EINVAL;
3083 goto put_child;
3084 }
3085
3086 /* DPTX registers */
3087 cdns_phy->base = devm_platform_ioremap_resource(pdev, 1);
3088 if (IS_ERR(cdns_phy->base)) {
3089 ret = PTR_ERR(cdns_phy->base);
3090 goto put_child;
3091 }
3092
3093 if (!init_dp_regmap) {
3094 ret = cdns_torrent_dp_regmap_init(cdns_phy);
3095 if (ret)
3096 goto put_child;
3097
3098 ret = cdns_torrent_dp_regfield_init(cdns_phy);
3099 if (ret)
3100 goto put_child;
3101
3102 init_dp_regmap++;
3103 }
3104
3105 dev_dbg(dev, "DP max bit rate %d.%03d Gbps\n",
3106 cdns_phy->max_bit_rate / 1000,
3107 cdns_phy->max_bit_rate % 1000);
3108
3109 gphy->attrs.bus_width = cdns_phy->phys[node].num_lanes;
3110 gphy->attrs.max_link_rate = cdns_phy->max_bit_rate;
3111 gphy->attrs.mode = PHY_MODE_DP;
3112 }
3113
3114 cdns_phy->phys[node].phy = gphy;
3115 cdns_phy->protocol_bitmask |= BIT(cdns_phy->phys[node].phy_type);
3116 phy_set_drvdata(gphy, &cdns_phy->phys[node]);
3117
3118 node++;
3119 }
3120 cdns_phy->nsubnodes = node;
3121
3122 if (total_num_lanes > MAX_NUM_LANES) {
3123 dev_err(dev, "Invalid lane configuration\n");
3124 ret = -EINVAL;
3125 goto put_lnk_rst;
3126 }
3127
3128 if (cdns_phy->nsubnodes > 1 && !cdns_phy->already_configured) {
3129 ret = cdns_torrent_phy_configure_multilink(cdns_phy);
3130 if (ret)
3131 goto put_lnk_rst;
3132 }
3133
3134 phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
3135 if (IS_ERR(phy_provider)) {
3136 ret = PTR_ERR(phy_provider);
3137 goto put_lnk_rst;
3138 }
3139
3140 if (cdns_phy->nsubnodes > 1)
3141 dev_dbg(dev, "Multi link configuration:\n");
3142 else
3143 dev_dbg(dev, "Single link configuration:\n");
3144
3145 for (i = 0; i < cdns_phy->nsubnodes; i++)
3146 dev_dbg(dev, "%s (%d lanes)",
3147 cdns_torrent_get_phy_type(cdns_phy->phys[i].phy_type),
3148 cdns_phy->phys[i].num_lanes);
3149
3150 return 0;
3151
3152 put_child:
3153 node++;
3154 put_lnk_rst:
3155 for (i = 0; i < node; i++)
3156 reset_control_put(cdns_phy->phys[i].lnk_rst);
3157 of_node_put(child);
3158 reset_control_assert(cdns_phy->apb_rst);
3159 clk_disable_unprepare(cdns_phy->clk1);
3160 clk_disable_unprepare(cdns_phy->clk);
3161 clk_cleanup:
3162 cdns_torrent_clk_cleanup(cdns_phy);
3163 return ret;
3164 }
3165
cdns_torrent_phy_remove(struct platform_device * pdev)3166 static void cdns_torrent_phy_remove(struct platform_device *pdev)
3167 {
3168 struct cdns_torrent_phy *cdns_phy = platform_get_drvdata(pdev);
3169 int i;
3170
3171 reset_control_assert(cdns_phy->phy_rst);
3172 reset_control_assert(cdns_phy->apb_rst);
3173 for (i = 0; i < cdns_phy->nsubnodes; i++) {
3174 reset_control_assert(cdns_phy->phys[i].lnk_rst);
3175 reset_control_put(cdns_phy->phys[i].lnk_rst);
3176 }
3177
3178 clk_disable_unprepare(cdns_phy->clk1);
3179 clk_disable_unprepare(cdns_phy->clk);
3180 cdns_torrent_clk_cleanup(cdns_phy);
3181 }
3182
3183 /* Multilink PCIe and USB Same SSC link configuration */
3184 static const struct cdns_reg_pairs ml_pcie_usb_link_cmn_regs[] = {
3185 {0x0002, PHY_PLL_CFG},
3186 {0x8600, CMN_PDIAG_PLL0_CLK_SEL_M0}
3187 };
3188
3189 static const struct cdns_reg_pairs ml_pcie_usb_xcvr_diag_ln_regs[] = {
3190 {0x0100, XCVR_DIAG_HSCLK_SEL},
3191 {0x0013, XCVR_DIAG_HSCLK_DIV},
3192 {0x0812, XCVR_DIAG_PLLDRC_CTRL}
3193 };
3194
3195 static const struct cdns_reg_pairs usb_ml_pcie_xcvr_diag_ln_regs[] = {
3196 {0x0041, XCVR_DIAG_PLLDRC_CTRL},
3197 };
3198
3199 static const struct cdns_torrent_vals ml_pcie_usb_link_cmn_vals = {
3200 .reg_pairs = ml_pcie_usb_link_cmn_regs,
3201 .num_regs = ARRAY_SIZE(ml_pcie_usb_link_cmn_regs),
3202 };
3203
3204 static const struct cdns_torrent_vals ml_pcie_usb_xcvr_diag_ln_vals = {
3205 .reg_pairs = ml_pcie_usb_xcvr_diag_ln_regs,
3206 .num_regs = ARRAY_SIZE(ml_pcie_usb_xcvr_diag_ln_regs),
3207 };
3208
3209 static const struct cdns_torrent_vals usb_ml_pcie_xcvr_diag_ln_vals = {
3210 .reg_pairs = usb_ml_pcie_xcvr_diag_ln_regs,
3211 .num_regs = ARRAY_SIZE(usb_ml_pcie_xcvr_diag_ln_regs),
3212 };
3213
3214 /* Multi link PCIe configuration */
3215 static const struct cdns_reg_pairs ml_pcie_link_cmn_regs[] = {
3216 {0x0002, PHY_PLL_CFG},
3217 {0x0601, CMN_PDIAG_PLL0_CLK_SEL_M0}
3218 };
3219
3220 static const struct cdns_reg_pairs ml_pcie_xcvr_diag_ln_regs[] = {
3221 {0x0100, XCVR_DIAG_HSCLK_SEL},
3222 {0x0001, XCVR_DIAG_HSCLK_DIV},
3223 {0x0812, XCVR_DIAG_PLLDRC_CTRL}
3224 };
3225
3226 static const struct cdns_torrent_vals ml_pcie_link_cmn_vals = {
3227 .reg_pairs = ml_pcie_link_cmn_regs,
3228 .num_regs = ARRAY_SIZE(ml_pcie_link_cmn_regs),
3229 };
3230
3231 static const struct cdns_torrent_vals ml_pcie_xcvr_diag_ln_vals = {
3232 .reg_pairs = ml_pcie_xcvr_diag_ln_regs,
3233 .num_regs = ARRAY_SIZE(ml_pcie_xcvr_diag_ln_regs),
3234 };
3235
3236 /* Multi link PCIe, 100 MHz Ref clk, no SSC */
3237 static const struct cdns_reg_pairs ml_pcie_100_no_ssc_cmn_regs[] = {
3238 {0x0003, CMN_PLL0_VCOCAL_TCTRL},
3239 {0x0003, CMN_PLL1_VCOCAL_TCTRL}
3240 };
3241
3242 static const struct cdns_reg_pairs ml_pcie_100_no_ssc_rx_ln_regs[] = {
3243 {0x0019, RX_REE_TAP1_CLIP},
3244 {0x0019, RX_REE_TAP2TON_CLIP},
3245 {0x0008, RX_REE_PEAK_UTHR},
3246 {0x018E, RX_CDRLF_CNFG},
3247 {0x2E33, RX_CDRLF_CNFG2},
3248 {0x0001, RX_DIAG_ACYA},
3249 {0x0C21, RX_DIAG_DFE_AMP_TUNE_2},
3250 {0x0002, RX_DIAG_DFE_AMP_TUNE_3},
3251 {0x0005, RX_DIAG_REE_DAC_CTRL}
3252 };
3253
3254 static const struct cdns_torrent_vals ml_pcie_100_no_ssc_cmn_vals = {
3255 .reg_pairs = ml_pcie_100_no_ssc_cmn_regs,
3256 .num_regs = ARRAY_SIZE(ml_pcie_100_no_ssc_cmn_regs),
3257 };
3258
3259 static const struct cdns_torrent_vals ml_pcie_100_no_ssc_rx_ln_vals = {
3260 .reg_pairs = ml_pcie_100_no_ssc_rx_ln_regs,
3261 .num_regs = ARRAY_SIZE(ml_pcie_100_no_ssc_rx_ln_regs),
3262 };
3263
3264 /* Multi link PCIe, 100 MHz Ref clk, internal SSC */
3265 static const struct cdns_reg_pairs ml_pcie_100_int_ssc_cmn_regs[] = {
3266 {0x0004, CMN_PLL0_DSM_DIAG_M0},
3267 {0x0004, CMN_PLL1_DSM_DIAG_M0},
3268 {0x0509, CMN_PDIAG_PLL0_CP_PADJ_M0},
3269 {0x0509, CMN_PDIAG_PLL1_CP_PADJ_M0},
3270 {0x0F00, CMN_PDIAG_PLL0_CP_IADJ_M0},
3271 {0x0F00, CMN_PDIAG_PLL1_CP_IADJ_M0},
3272 {0x0F08, CMN_PDIAG_PLL0_FILT_PADJ_M0},
3273 {0x0F08, CMN_PDIAG_PLL1_FILT_PADJ_M0},
3274 {0x0064, CMN_PLL0_INTDIV_M0},
3275 {0x0050, CMN_PLL1_INTDIV_M0},
3276 {0x0002, CMN_PLL0_FRACDIVH_M0},
3277 {0x0002, CMN_PLL1_FRACDIVH_M0},
3278 {0x0044, CMN_PLL0_HIGH_THR_M0},
3279 {0x0036, CMN_PLL1_HIGH_THR_M0},
3280 {0x0002, CMN_PDIAG_PLL0_CTRL_M0},
3281 {0x0002, CMN_PDIAG_PLL1_CTRL_M0},
3282 {0x0001, CMN_PLL0_SS_CTRL1_M0},
3283 {0x0001, CMN_PLL1_SS_CTRL1_M0},
3284 {0x011B, CMN_PLL0_SS_CTRL2_M0},
3285 {0x011B, CMN_PLL1_SS_CTRL2_M0},
3286 {0x006E, CMN_PLL0_SS_CTRL3_M0},
3287 {0x0058, CMN_PLL1_SS_CTRL3_M0},
3288 {0x000E, CMN_PLL0_SS_CTRL4_M0},
3289 {0x0012, CMN_PLL1_SS_CTRL4_M0},
3290 {0x0C5E, CMN_PLL0_VCOCAL_REFTIM_START},
3291 {0x0C5E, CMN_PLL1_VCOCAL_REFTIM_START},
3292 {0x0C56, CMN_PLL0_VCOCAL_PLLCNT_START},
3293 {0x0C56, CMN_PLL1_VCOCAL_PLLCNT_START},
3294 {0x0003, CMN_PLL0_VCOCAL_TCTRL},
3295 {0x0003, CMN_PLL1_VCOCAL_TCTRL},
3296 {0x00C7, CMN_PLL0_LOCK_REFCNT_START},
3297 {0x00C7, CMN_PLL1_LOCK_REFCNT_START},
3298 {0x00C7, CMN_PLL0_LOCK_PLLCNT_START},
3299 {0x00C7, CMN_PLL1_LOCK_PLLCNT_START},
3300 {0x0005, CMN_PLL0_LOCK_PLLCNT_THR},
3301 {0x0005, CMN_PLL1_LOCK_PLLCNT_THR}
3302 };
3303
3304 static const struct cdns_torrent_vals ml_pcie_100_int_ssc_cmn_vals = {
3305 .reg_pairs = ml_pcie_100_int_ssc_cmn_regs,
3306 .num_regs = ARRAY_SIZE(ml_pcie_100_int_ssc_cmn_regs),
3307 };
3308
3309 /* SGMII and QSGMII link configuration */
3310 static const struct cdns_reg_pairs sgmii_qsgmii_link_cmn_regs[] = {
3311 {0x0002, PHY_PLL_CFG}
3312 };
3313
3314 static const struct cdns_reg_pairs sgmii_qsgmii_xcvr_diag_ln_regs[] = {
3315 {0x0003, XCVR_DIAG_HSCLK_DIV},
3316 {0x0113, XCVR_DIAG_PLLDRC_CTRL}
3317 };
3318
3319 static const struct cdns_torrent_vals sgmii_qsgmii_link_cmn_vals = {
3320 .reg_pairs = sgmii_qsgmii_link_cmn_regs,
3321 .num_regs = ARRAY_SIZE(sgmii_qsgmii_link_cmn_regs),
3322 };
3323
3324 static const struct cdns_torrent_vals sgmii_qsgmii_xcvr_diag_ln_vals = {
3325 .reg_pairs = sgmii_qsgmii_xcvr_diag_ln_regs,
3326 .num_regs = ARRAY_SIZE(sgmii_qsgmii_xcvr_diag_ln_regs),
3327 };
3328
cdns_torrent_phy_suspend_noirq(struct device * dev)3329 static int cdns_torrent_phy_suspend_noirq(struct device *dev)
3330 {
3331 struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(dev);
3332 int i;
3333
3334 reset_control_assert(cdns_phy->phy_rst);
3335 reset_control_assert(cdns_phy->apb_rst);
3336 for (i = 0; i < cdns_phy->nsubnodes; i++)
3337 reset_control_assert(cdns_phy->phys[i].lnk_rst);
3338
3339 if (cdns_phy->already_configured)
3340 cdns_phy->already_configured = 0;
3341 else {
3342 clk_disable_unprepare(cdns_phy->clk1);
3343 clk_disable_unprepare(cdns_phy->clk);
3344 }
3345
3346 return 0;
3347 }
3348
cdns_torrent_phy_resume_noirq(struct device * dev)3349 static int cdns_torrent_phy_resume_noirq(struct device *dev)
3350 {
3351 struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(dev);
3352 int node = cdns_phy->nsubnodes;
3353 int ret, i;
3354
3355 ret = cdns_torrent_clk(cdns_phy);
3356 if (ret)
3357 return ret;
3358
3359 /* Enable APB */
3360 reset_control_deassert(cdns_phy->apb_rst);
3361
3362 if (cdns_phy->nsubnodes > 1) {
3363 ret = cdns_torrent_phy_configure_multilink(cdns_phy);
3364 if (ret)
3365 goto put_lnk_rst;
3366 }
3367
3368 return 0;
3369
3370 put_lnk_rst:
3371 for (i = 0; i < node; i++)
3372 reset_control_assert(cdns_phy->phys[i].lnk_rst);
3373 reset_control_assert(cdns_phy->apb_rst);
3374
3375 clk_disable_unprepare(cdns_phy->clk1);
3376 clk_disable_unprepare(cdns_phy->clk);
3377
3378 return ret;
3379 }
3380
3381 static DEFINE_NOIRQ_DEV_PM_OPS(cdns_torrent_phy_pm_ops,
3382 cdns_torrent_phy_suspend_noirq,
3383 cdns_torrent_phy_resume_noirq);
3384
3385 /* USB and DP link configuration */
3386 static const struct cdns_reg_pairs usb_dp_link_cmn_regs[] = {
3387 {0x0002, PHY_PLL_CFG},
3388 {0x8600, CMN_PDIAG_PLL0_CLK_SEL_M0}
3389 };
3390
3391 static const struct cdns_reg_pairs usb_dp_xcvr_diag_ln_regs[] = {
3392 {0x0000, XCVR_DIAG_HSCLK_SEL},
3393 {0x0001, XCVR_DIAG_HSCLK_DIV},
3394 {0x0041, XCVR_DIAG_PLLDRC_CTRL}
3395 };
3396
3397 static const struct cdns_reg_pairs dp_usb_xcvr_diag_ln_regs[] = {
3398 {0x0001, XCVR_DIAG_HSCLK_SEL},
3399 {0x0009, XCVR_DIAG_PLLDRC_CTRL}
3400 };
3401
3402 static const struct cdns_torrent_vals usb_dp_link_cmn_vals = {
3403 .reg_pairs = usb_dp_link_cmn_regs,
3404 .num_regs = ARRAY_SIZE(usb_dp_link_cmn_regs),
3405 };
3406
3407 static const struct cdns_torrent_vals usb_dp_xcvr_diag_ln_vals = {
3408 .reg_pairs = usb_dp_xcvr_diag_ln_regs,
3409 .num_regs = ARRAY_SIZE(usb_dp_xcvr_diag_ln_regs),
3410 };
3411
3412 static const struct cdns_torrent_vals dp_usb_xcvr_diag_ln_vals = {
3413 .reg_pairs = dp_usb_xcvr_diag_ln_regs,
3414 .num_regs = ARRAY_SIZE(dp_usb_xcvr_diag_ln_regs),
3415 };
3416
3417 /* USXGMII and SGMII/QSGMII link configuration */
3418 static const struct cdns_reg_pairs usxgmii_sgmii_link_cmn_regs[] = {
3419 {0x0002, PHY_PLL_CFG},
3420 {0x0400, CMN_PDIAG_PLL0_CLK_SEL_M0},
3421 {0x0601, CMN_PDIAG_PLL1_CLK_SEL_M0}
3422 };
3423
3424 static const struct cdns_reg_pairs usxgmii_sgmii_xcvr_diag_ln_regs[] = {
3425 {0x0000, XCVR_DIAG_HSCLK_SEL},
3426 {0x0001, XCVR_DIAG_HSCLK_DIV},
3427 {0x0001, XCVR_DIAG_PLLDRC_CTRL}
3428 };
3429
3430 static const struct cdns_reg_pairs sgmii_usxgmii_xcvr_diag_ln_regs[] = {
3431 {0x0111, XCVR_DIAG_HSCLK_SEL},
3432 {0x0103, XCVR_DIAG_HSCLK_DIV},
3433 {0x0A9B, XCVR_DIAG_PLLDRC_CTRL}
3434 };
3435
3436 static const struct cdns_torrent_vals usxgmii_sgmii_link_cmn_vals = {
3437 .reg_pairs = usxgmii_sgmii_link_cmn_regs,
3438 .num_regs = ARRAY_SIZE(usxgmii_sgmii_link_cmn_regs),
3439 };
3440
3441 static const struct cdns_torrent_vals usxgmii_sgmii_xcvr_diag_ln_vals = {
3442 .reg_pairs = usxgmii_sgmii_xcvr_diag_ln_regs,
3443 .num_regs = ARRAY_SIZE(usxgmii_sgmii_xcvr_diag_ln_regs),
3444 };
3445
3446 static const struct cdns_torrent_vals sgmii_usxgmii_xcvr_diag_ln_vals = {
3447 .reg_pairs = sgmii_usxgmii_xcvr_diag_ln_regs,
3448 .num_regs = ARRAY_SIZE(sgmii_usxgmii_xcvr_diag_ln_regs),
3449 };
3450
3451 /* Multilink USXGMII, using PLL0, 156.25 MHz Ref clk, no SSC */
3452 static const struct cdns_reg_pairs ml_usxgmii_pll0_156_25_no_ssc_cmn_regs[] = {
3453 {0x0014, CMN_PLL0_DSM_FBH_OVRD_M0},
3454 {0x0005, CMN_PLL0_DSM_FBL_OVRD_M0},
3455 {0x061B, CMN_PLL0_VCOCAL_INIT_TMR},
3456 {0x0019, CMN_PLL0_VCOCAL_ITER_TMR},
3457 {0x1354, CMN_PLL0_VCOCAL_REFTIM_START},
3458 {0x1354, CMN_PLL0_VCOCAL_PLLCNT_START},
3459 {0x0003, CMN_PLL0_VCOCAL_TCTRL},
3460 {0x0138, CMN_PLL0_LOCK_REFCNT_START},
3461 {0x0138, CMN_PLL0_LOCK_PLLCNT_START}
3462 };
3463
3464 static const struct cdns_torrent_vals ml_usxgmii_pll0_156_25_no_ssc_cmn_vals = {
3465 .reg_pairs = ml_usxgmii_pll0_156_25_no_ssc_cmn_regs,
3466 .num_regs = ARRAY_SIZE(ml_usxgmii_pll0_156_25_no_ssc_cmn_regs),
3467 };
3468
3469 /* Multilink SGMII/QSGMII, using PLL1, 100 MHz Ref clk, no SSC */
3470 static const struct cdns_reg_pairs ml_sgmii_pll1_100_no_ssc_cmn_regs[] = {
3471 {0x0028, CMN_PDIAG_PLL1_CP_PADJ_M0},
3472 {0x001E, CMN_PLL1_DSM_FBH_OVRD_M0},
3473 {0x000C, CMN_PLL1_DSM_FBL_OVRD_M0},
3474 {0x0003, CMN_PLL1_VCOCAL_TCTRL},
3475 {0x007F, CMN_TXPUCAL_TUNE},
3476 {0x007F, CMN_TXPDCAL_TUNE}
3477 };
3478
3479 static const struct cdns_torrent_vals ml_sgmii_pll1_100_no_ssc_cmn_vals = {
3480 .reg_pairs = ml_sgmii_pll1_100_no_ssc_cmn_regs,
3481 .num_regs = ARRAY_SIZE(ml_sgmii_pll1_100_no_ssc_cmn_regs),
3482 };
3483
3484 /* TI J7200, Multilink USXGMII, using PLL0, 156.25 MHz Ref clk, no SSC */
3485 static const struct cdns_reg_pairs j7200_ml_usxgmii_pll0_156_25_no_ssc_cmn_regs[] = {
3486 {0x0014, CMN_SSM_BIAS_TMR},
3487 {0x0028, CMN_PLLSM0_PLLPRE_TMR},
3488 {0x00A4, CMN_PLLSM0_PLLLOCK_TMR},
3489 {0x0062, CMN_BGCAL_INIT_TMR},
3490 {0x0062, CMN_BGCAL_ITER_TMR},
3491 {0x0014, CMN_IBCAL_INIT_TMR},
3492 {0x0018, CMN_TXPUCAL_INIT_TMR},
3493 {0x0005, CMN_TXPUCAL_ITER_TMR},
3494 {0x0018, CMN_TXPDCAL_INIT_TMR},
3495 {0x0005, CMN_TXPDCAL_ITER_TMR},
3496 {0x024A, CMN_RXCAL_INIT_TMR},
3497 {0x0005, CMN_RXCAL_ITER_TMR},
3498 {0x000B, CMN_SD_CAL_REFTIM_START},
3499 {0x0132, CMN_SD_CAL_PLLCNT_START},
3500 {0x0014, CMN_PLL0_DSM_FBH_OVRD_M0},
3501 {0x0005, CMN_PLL0_DSM_FBL_OVRD_M0},
3502 {0x061B, CMN_PLL0_VCOCAL_INIT_TMR},
3503 {0x0019, CMN_PLL0_VCOCAL_ITER_TMR},
3504 {0x1354, CMN_PLL0_VCOCAL_REFTIM_START},
3505 {0x1354, CMN_PLL0_VCOCAL_PLLCNT_START},
3506 {0x0003, CMN_PLL0_VCOCAL_TCTRL},
3507 {0x0138, CMN_PLL0_LOCK_REFCNT_START},
3508 {0x0138, CMN_PLL0_LOCK_PLLCNT_START}
3509 };
3510
3511 static const struct cdns_torrent_vals j7200_ml_usxgmii_pll0_156_25_no_ssc_cmn_vals = {
3512 .reg_pairs = j7200_ml_usxgmii_pll0_156_25_no_ssc_cmn_regs,
3513 .num_regs = ARRAY_SIZE(j7200_ml_usxgmii_pll0_156_25_no_ssc_cmn_regs),
3514 };
3515
3516 /* TI J7200, Multilink SGMII/QSGMII, using PLL1, 100 MHz Ref clk, no SSC */
3517 static const struct cdns_reg_pairs j7200_ml_sgmii_pll1_100_no_ssc_cmn_regs[] = {
3518 {0x0028, CMN_PLLSM1_PLLPRE_TMR},
3519 {0x00A4, CMN_PLLSM1_PLLLOCK_TMR},
3520 {0x0028, CMN_PDIAG_PLL1_CP_PADJ_M0},
3521 {0x001E, CMN_PLL1_DSM_FBH_OVRD_M0},
3522 {0x000C, CMN_PLL1_DSM_FBL_OVRD_M0},
3523 {0x0003, CMN_PLL1_VCOCAL_TCTRL},
3524 {0x007F, CMN_TXPUCAL_TUNE},
3525 {0x007F, CMN_TXPDCAL_TUNE}
3526 };
3527
3528 static const struct cdns_torrent_vals j7200_ml_sgmii_pll1_100_no_ssc_cmn_vals = {
3529 .reg_pairs = j7200_ml_sgmii_pll1_100_no_ssc_cmn_regs,
3530 .num_regs = ARRAY_SIZE(j7200_ml_sgmii_pll1_100_no_ssc_cmn_regs),
3531 };
3532
3533 /* PCIe and USXGMII link configuration */
3534 static const struct cdns_reg_pairs pcie_usxgmii_link_cmn_regs[] = {
3535 {0x0003, PHY_PLL_CFG},
3536 {0x0601, CMN_PDIAG_PLL0_CLK_SEL_M0},
3537 {0x0400, CMN_PDIAG_PLL0_CLK_SEL_M1},
3538 {0x0400, CMN_PDIAG_PLL1_CLK_SEL_M0}
3539 };
3540
3541 static const struct cdns_reg_pairs pcie_usxgmii_xcvr_diag_ln_regs[] = {
3542 {0x0000, XCVR_DIAG_HSCLK_SEL},
3543 {0x0001, XCVR_DIAG_HSCLK_DIV},
3544 {0x0012, XCVR_DIAG_PLLDRC_CTRL}
3545 };
3546
3547 static const struct cdns_reg_pairs usxgmii_pcie_xcvr_diag_ln_regs[] = {
3548 {0x0011, XCVR_DIAG_HSCLK_SEL},
3549 {0x0001, XCVR_DIAG_HSCLK_DIV},
3550 {0x0089, XCVR_DIAG_PLLDRC_CTRL}
3551 };
3552
3553 static const struct cdns_torrent_vals pcie_usxgmii_link_cmn_vals = {
3554 .reg_pairs = pcie_usxgmii_link_cmn_regs,
3555 .num_regs = ARRAY_SIZE(pcie_usxgmii_link_cmn_regs),
3556 };
3557
3558 static const struct cdns_torrent_vals pcie_usxgmii_xcvr_diag_ln_vals = {
3559 .reg_pairs = pcie_usxgmii_xcvr_diag_ln_regs,
3560 .num_regs = ARRAY_SIZE(pcie_usxgmii_xcvr_diag_ln_regs),
3561 };
3562
3563 static const struct cdns_torrent_vals usxgmii_pcie_xcvr_diag_ln_vals = {
3564 .reg_pairs = usxgmii_pcie_xcvr_diag_ln_regs,
3565 .num_regs = ARRAY_SIZE(usxgmii_pcie_xcvr_diag_ln_regs),
3566 };
3567
3568 /*
3569 * Multilink USXGMII, using PLL1, 156.25 MHz Ref clk, no SSC
3570 */
3571 static const struct cdns_reg_pairs ml_usxgmii_pll1_156_25_no_ssc_cmn_regs[] = {
3572 {0x0028, CMN_PDIAG_PLL1_CP_PADJ_M0},
3573 {0x0014, CMN_PLL1_DSM_FBH_OVRD_M0},
3574 {0x0005, CMN_PLL1_DSM_FBL_OVRD_M0},
3575 {0x061B, CMN_PLL1_VCOCAL_INIT_TMR},
3576 {0x0019, CMN_PLL1_VCOCAL_ITER_TMR},
3577 {0x1354, CMN_PLL1_VCOCAL_REFTIM_START},
3578 {0x1354, CMN_PLL1_VCOCAL_PLLCNT_START},
3579 {0x0003, CMN_PLL1_VCOCAL_TCTRL},
3580 {0x0138, CMN_PLL1_LOCK_REFCNT_START},
3581 {0x0138, CMN_PLL1_LOCK_PLLCNT_START},
3582 {0x007F, CMN_TXPUCAL_TUNE},
3583 {0x007F, CMN_TXPDCAL_TUNE}
3584 };
3585
3586 static const struct cdns_reg_pairs ml_usxgmii_156_25_no_ssc_tx_ln_regs[] = {
3587 {0x00F3, TX_PSC_A0},
3588 {0x04A2, TX_PSC_A2},
3589 {0x04A2, TX_PSC_A3 },
3590 {0x0000, TX_TXCC_CPOST_MULT_00},
3591 {0x0000, XCVR_DIAG_PSC_OVRD}
3592 };
3593
3594 static const struct cdns_reg_pairs ml_usxgmii_156_25_no_ssc_rx_ln_regs[] = {
3595 {0x091D, RX_PSC_A0},
3596 {0x0900, RX_PSC_A2},
3597 {0x0100, RX_PSC_A3},
3598 {0x0030, RX_REE_SMGM_CTRL1},
3599 {0x03C7, RX_REE_GCSM1_EQENM_PH1},
3600 {0x01C7, RX_REE_GCSM1_EQENM_PH2},
3601 {0x0000, RX_DIAG_DFE_CTRL},
3602 {0x0019, RX_REE_TAP1_CLIP},
3603 {0x0019, RX_REE_TAP2TON_CLIP},
3604 {0x00B9, RX_DIAG_NQST_CTRL},
3605 {0x0C21, RX_DIAG_DFE_AMP_TUNE_2},
3606 {0x0002, RX_DIAG_DFE_AMP_TUNE_3},
3607 {0x0033, RX_DIAG_PI_RATE},
3608 {0x0001, RX_DIAG_ACYA},
3609 {0x018C, RX_CDRLF_CNFG}
3610 };
3611
3612 static const struct cdns_torrent_vals ml_usxgmii_pll1_156_25_no_ssc_cmn_vals = {
3613 .reg_pairs = ml_usxgmii_pll1_156_25_no_ssc_cmn_regs,
3614 .num_regs = ARRAY_SIZE(ml_usxgmii_pll1_156_25_no_ssc_cmn_regs),
3615 };
3616
3617 static const struct cdns_torrent_vals ml_usxgmii_156_25_no_ssc_tx_ln_vals = {
3618 .reg_pairs = ml_usxgmii_156_25_no_ssc_tx_ln_regs,
3619 .num_regs = ARRAY_SIZE(ml_usxgmii_156_25_no_ssc_tx_ln_regs),
3620 };
3621
3622 static const struct cdns_torrent_vals ml_usxgmii_156_25_no_ssc_rx_ln_vals = {
3623 .reg_pairs = ml_usxgmii_156_25_no_ssc_rx_ln_regs,
3624 .num_regs = ARRAY_SIZE(ml_usxgmii_156_25_no_ssc_rx_ln_regs),
3625 };
3626
3627 /* TI USXGMII configuration: Enable cmn_refclk_rcv_out_en */
3628 static const struct cdns_reg_pairs ti_usxgmii_phy_pma_cmn_regs[] = {
3629 {0x0040, PHY_PMA_CMN_CTRL1},
3630 };
3631
3632 static const struct cdns_torrent_vals ti_usxgmii_phy_pma_cmn_vals = {
3633 .reg_pairs = ti_usxgmii_phy_pma_cmn_regs,
3634 .num_regs = ARRAY_SIZE(ti_usxgmii_phy_pma_cmn_regs),
3635 };
3636
3637 /* Single USXGMII link configuration */
3638 static const struct cdns_reg_pairs sl_usxgmii_link_cmn_regs[] = {
3639 {0x0000, PHY_PLL_CFG},
3640 {0x0400, CMN_PDIAG_PLL0_CLK_SEL_M0}
3641 };
3642
3643 static const struct cdns_reg_pairs sl_usxgmii_xcvr_diag_ln_regs[] = {
3644 {0x0000, XCVR_DIAG_HSCLK_SEL},
3645 {0x0001, XCVR_DIAG_HSCLK_DIV},
3646 {0x0001, XCVR_DIAG_PLLDRC_CTRL}
3647 };
3648
3649 static const struct cdns_torrent_vals sl_usxgmii_link_cmn_vals = {
3650 .reg_pairs = sl_usxgmii_link_cmn_regs,
3651 .num_regs = ARRAY_SIZE(sl_usxgmii_link_cmn_regs),
3652 };
3653
3654 static const struct cdns_torrent_vals sl_usxgmii_xcvr_diag_ln_vals = {
3655 .reg_pairs = sl_usxgmii_xcvr_diag_ln_regs,
3656 .num_regs = ARRAY_SIZE(sl_usxgmii_xcvr_diag_ln_regs),
3657 };
3658
3659 /* Single link USXGMII, 156.25 MHz Ref clk, no SSC */
3660 static const struct cdns_reg_pairs sl_usxgmii_156_25_no_ssc_cmn_regs[] = {
3661 {0x0014, CMN_SSM_BIAS_TMR},
3662 {0x0028, CMN_PLLSM0_PLLPRE_TMR},
3663 {0x00A4, CMN_PLLSM0_PLLLOCK_TMR},
3664 {0x0028, CMN_PLLSM1_PLLPRE_TMR},
3665 {0x00A4, CMN_PLLSM1_PLLLOCK_TMR},
3666 {0x0062, CMN_BGCAL_INIT_TMR},
3667 {0x0062, CMN_BGCAL_ITER_TMR},
3668 {0x0014, CMN_IBCAL_INIT_TMR},
3669 {0x0018, CMN_TXPUCAL_INIT_TMR},
3670 {0x0005, CMN_TXPUCAL_ITER_TMR},
3671 {0x0018, CMN_TXPDCAL_INIT_TMR},
3672 {0x0005, CMN_TXPDCAL_ITER_TMR},
3673 {0x024A, CMN_RXCAL_INIT_TMR},
3674 {0x0005, CMN_RXCAL_ITER_TMR},
3675 {0x000B, CMN_SD_CAL_REFTIM_START},
3676 {0x0132, CMN_SD_CAL_PLLCNT_START},
3677 {0x0028, CMN_PDIAG_PLL1_CP_PADJ_M0},
3678 {0x0014, CMN_PLL0_DSM_FBH_OVRD_M0},
3679 {0x0014, CMN_PLL1_DSM_FBH_OVRD_M0},
3680 {0x0005, CMN_PLL0_DSM_FBL_OVRD_M0},
3681 {0x0005, CMN_PLL1_DSM_FBL_OVRD_M0},
3682 {0x061B, CMN_PLL0_VCOCAL_INIT_TMR},
3683 {0x061B, CMN_PLL1_VCOCAL_INIT_TMR},
3684 {0x0019, CMN_PLL0_VCOCAL_ITER_TMR},
3685 {0x0019, CMN_PLL1_VCOCAL_ITER_TMR},
3686 {0x1354, CMN_PLL0_VCOCAL_REFTIM_START},
3687 {0x1354, CMN_PLL1_VCOCAL_REFTIM_START},
3688 {0x1354, CMN_PLL0_VCOCAL_PLLCNT_START},
3689 {0x1354, CMN_PLL1_VCOCAL_PLLCNT_START},
3690 {0x0003, CMN_PLL0_VCOCAL_TCTRL},
3691 {0x0003, CMN_PLL1_VCOCAL_TCTRL},
3692 {0x0138, CMN_PLL0_LOCK_REFCNT_START},
3693 {0x0138, CMN_PLL1_LOCK_REFCNT_START},
3694 {0x0138, CMN_PLL0_LOCK_PLLCNT_START},
3695 {0x0138, CMN_PLL1_LOCK_PLLCNT_START}
3696 };
3697
3698 static const struct cdns_reg_pairs usxgmii_156_25_no_ssc_tx_ln_regs[] = {
3699 {0x07A2, TX_RCVDET_ST_TMR},
3700 {0x00F3, TX_PSC_A0},
3701 {0x04A2, TX_PSC_A2},
3702 {0x04A2, TX_PSC_A3},
3703 {0x0000, TX_TXCC_CPOST_MULT_00},
3704 {0x0000, XCVR_DIAG_PSC_OVRD}
3705 };
3706
3707 static const struct cdns_reg_pairs usxgmii_156_25_no_ssc_rx_ln_regs[] = {
3708 {0x0014, RX_SDCAL0_INIT_TMR},
3709 {0x0062, RX_SDCAL0_ITER_TMR},
3710 {0x0014, RX_SDCAL1_INIT_TMR},
3711 {0x0062, RX_SDCAL1_ITER_TMR},
3712 {0x091D, RX_PSC_A0},
3713 {0x0900, RX_PSC_A2},
3714 {0x0100, RX_PSC_A3},
3715 {0x0030, RX_REE_SMGM_CTRL1},
3716 {0x03C7, RX_REE_GCSM1_EQENM_PH1},
3717 {0x01C7, RX_REE_GCSM1_EQENM_PH2},
3718 {0x0000, RX_DIAG_DFE_CTRL},
3719 {0x0019, RX_REE_TAP1_CLIP},
3720 {0x0019, RX_REE_TAP2TON_CLIP},
3721 {0x00B9, RX_DIAG_NQST_CTRL},
3722 {0x0C21, RX_DIAG_DFE_AMP_TUNE_2},
3723 {0x0002, RX_DIAG_DFE_AMP_TUNE_3},
3724 {0x0033, RX_DIAG_PI_RATE},
3725 {0x0001, RX_DIAG_ACYA},
3726 {0x018C, RX_CDRLF_CNFG}
3727 };
3728
3729 static const struct cdns_torrent_vals sl_usxgmii_156_25_no_ssc_cmn_vals = {
3730 .reg_pairs = sl_usxgmii_156_25_no_ssc_cmn_regs,
3731 .num_regs = ARRAY_SIZE(sl_usxgmii_156_25_no_ssc_cmn_regs),
3732 };
3733
3734 static const struct cdns_torrent_vals usxgmii_156_25_no_ssc_tx_ln_vals = {
3735 .reg_pairs = usxgmii_156_25_no_ssc_tx_ln_regs,
3736 .num_regs = ARRAY_SIZE(usxgmii_156_25_no_ssc_tx_ln_regs),
3737 };
3738
3739 static const struct cdns_torrent_vals usxgmii_156_25_no_ssc_rx_ln_vals = {
3740 .reg_pairs = usxgmii_156_25_no_ssc_rx_ln_regs,
3741 .num_regs = ARRAY_SIZE(usxgmii_156_25_no_ssc_rx_ln_regs),
3742 };
3743
3744 /* PCIe and DP link configuration */
3745 static const struct cdns_reg_pairs pcie_dp_link_cmn_regs[] = {
3746 {0x0003, PHY_PLL_CFG},
3747 {0x0601, CMN_PDIAG_PLL0_CLK_SEL_M0},
3748 {0x0400, CMN_PDIAG_PLL0_CLK_SEL_M1}
3749 };
3750
3751 static const struct cdns_reg_pairs pcie_dp_xcvr_diag_ln_regs[] = {
3752 {0x0000, XCVR_DIAG_HSCLK_SEL},
3753 {0x0001, XCVR_DIAG_HSCLK_DIV},
3754 {0x0012, XCVR_DIAG_PLLDRC_CTRL}
3755 };
3756
3757 static const struct cdns_reg_pairs dp_pcie_xcvr_diag_ln_regs[] = {
3758 {0x0001, XCVR_DIAG_HSCLK_SEL},
3759 {0x0009, XCVR_DIAG_PLLDRC_CTRL}
3760 };
3761
3762 static const struct cdns_torrent_vals pcie_dp_link_cmn_vals = {
3763 .reg_pairs = pcie_dp_link_cmn_regs,
3764 .num_regs = ARRAY_SIZE(pcie_dp_link_cmn_regs),
3765 };
3766
3767 static const struct cdns_torrent_vals pcie_dp_xcvr_diag_ln_vals = {
3768 .reg_pairs = pcie_dp_xcvr_diag_ln_regs,
3769 .num_regs = ARRAY_SIZE(pcie_dp_xcvr_diag_ln_regs),
3770 };
3771
3772 static const struct cdns_torrent_vals dp_pcie_xcvr_diag_ln_vals = {
3773 .reg_pairs = dp_pcie_xcvr_diag_ln_regs,
3774 .num_regs = ARRAY_SIZE(dp_pcie_xcvr_diag_ln_regs),
3775 };
3776
3777 /* DP Multilink, 100 MHz Ref clk, no SSC */
3778 static const struct cdns_reg_pairs dp_100_no_ssc_cmn_regs[] = {
3779 {0x007F, CMN_TXPUCAL_TUNE},
3780 {0x007F, CMN_TXPDCAL_TUNE}
3781 };
3782
3783 static const struct cdns_reg_pairs dp_100_no_ssc_tx_ln_regs[] = {
3784 {0x00FB, TX_PSC_A0},
3785 {0x04AA, TX_PSC_A2},
3786 {0x04AA, TX_PSC_A3},
3787 {0x000F, XCVR_DIAG_BIDI_CTRL}
3788 };
3789
3790 static const struct cdns_reg_pairs dp_100_no_ssc_rx_ln_regs[] = {
3791 {0x0000, RX_PSC_A0},
3792 {0x0000, RX_PSC_A2},
3793 {0x0000, RX_PSC_A3},
3794 {0x0000, RX_PSC_CAL},
3795 {0x0000, RX_REE_GCSM1_CTRL},
3796 {0x0000, RX_REE_GCSM2_CTRL},
3797 {0x0000, RX_REE_PERGCSM_CTRL}
3798 };
3799
3800 static const struct cdns_torrent_vals dp_100_no_ssc_cmn_vals = {
3801 .reg_pairs = dp_100_no_ssc_cmn_regs,
3802 .num_regs = ARRAY_SIZE(dp_100_no_ssc_cmn_regs),
3803 };
3804
3805 static const struct cdns_torrent_vals dp_100_no_ssc_tx_ln_vals = {
3806 .reg_pairs = dp_100_no_ssc_tx_ln_regs,
3807 .num_regs = ARRAY_SIZE(dp_100_no_ssc_tx_ln_regs),
3808 };
3809
3810 static const struct cdns_torrent_vals dp_100_no_ssc_rx_ln_vals = {
3811 .reg_pairs = dp_100_no_ssc_rx_ln_regs,
3812 .num_regs = ARRAY_SIZE(dp_100_no_ssc_rx_ln_regs),
3813 };
3814
3815 /* Single DisplayPort(DP) link configuration */
3816 static const struct cdns_reg_pairs sl_dp_link_cmn_regs[] = {
3817 {0x0000, PHY_PLL_CFG},
3818 };
3819
3820 static const struct cdns_reg_pairs sl_dp_xcvr_diag_ln_regs[] = {
3821 {0x0000, XCVR_DIAG_HSCLK_SEL},
3822 {0x0001, XCVR_DIAG_PLLDRC_CTRL}
3823 };
3824
3825 static const struct cdns_torrent_vals sl_dp_link_cmn_vals = {
3826 .reg_pairs = sl_dp_link_cmn_regs,
3827 .num_regs = ARRAY_SIZE(sl_dp_link_cmn_regs),
3828 };
3829
3830 static const struct cdns_torrent_vals sl_dp_xcvr_diag_ln_vals = {
3831 .reg_pairs = sl_dp_xcvr_diag_ln_regs,
3832 .num_regs = ARRAY_SIZE(sl_dp_xcvr_diag_ln_regs),
3833 };
3834
3835 /* Single DP, 19.2 MHz Ref clk, no SSC */
3836 static const struct cdns_reg_pairs sl_dp_19_2_no_ssc_cmn_regs[] = {
3837 {0x0014, CMN_SSM_BIAS_TMR},
3838 {0x0027, CMN_PLLSM0_PLLPRE_TMR},
3839 {0x00A1, CMN_PLLSM0_PLLLOCK_TMR},
3840 {0x0027, CMN_PLLSM1_PLLPRE_TMR},
3841 {0x00A1, CMN_PLLSM1_PLLLOCK_TMR},
3842 {0x0060, CMN_BGCAL_INIT_TMR},
3843 {0x0060, CMN_BGCAL_ITER_TMR},
3844 {0x0014, CMN_IBCAL_INIT_TMR},
3845 {0x0018, CMN_TXPUCAL_INIT_TMR},
3846 {0x0005, CMN_TXPUCAL_ITER_TMR},
3847 {0x0018, CMN_TXPDCAL_INIT_TMR},
3848 {0x0005, CMN_TXPDCAL_ITER_TMR},
3849 {0x0240, CMN_RXCAL_INIT_TMR},
3850 {0x0005, CMN_RXCAL_ITER_TMR},
3851 {0x0002, CMN_SD_CAL_INIT_TMR},
3852 {0x0002, CMN_SD_CAL_ITER_TMR},
3853 {0x000B, CMN_SD_CAL_REFTIM_START},
3854 {0x0137, CMN_SD_CAL_PLLCNT_START},
3855 {0x0509, CMN_PDIAG_PLL0_CP_PADJ_M0},
3856 {0x0F00, CMN_PDIAG_PLL0_CP_IADJ_M0},
3857 {0x0F08, CMN_PDIAG_PLL0_FILT_PADJ_M0},
3858 {0x0004, CMN_PLL0_DSM_DIAG_M0},
3859 {0x0509, CMN_PDIAG_PLL1_CP_PADJ_M0},
3860 {0x0F00, CMN_PDIAG_PLL1_CP_IADJ_M0},
3861 {0x0F08, CMN_PDIAG_PLL1_FILT_PADJ_M0},
3862 {0x0004, CMN_PLL1_DSM_DIAG_M0},
3863 {0x00C0, CMN_PLL0_VCOCAL_INIT_TMR},
3864 {0x0004, CMN_PLL0_VCOCAL_ITER_TMR},
3865 {0x00C0, CMN_PLL1_VCOCAL_INIT_TMR},
3866 {0x0004, CMN_PLL1_VCOCAL_ITER_TMR},
3867 {0x0260, CMN_PLL0_VCOCAL_REFTIM_START},
3868 {0x0003, CMN_PLL0_VCOCAL_TCTRL},
3869 {0x0260, CMN_PLL1_VCOCAL_REFTIM_START},
3870 {0x0003, CMN_PLL1_VCOCAL_TCTRL}
3871 };
3872
3873 static const struct cdns_reg_pairs sl_dp_19_2_no_ssc_tx_ln_regs[] = {
3874 {0x0780, TX_RCVDET_ST_TMR},
3875 {0x00FB, TX_PSC_A0},
3876 {0x04AA, TX_PSC_A2},
3877 {0x04AA, TX_PSC_A3},
3878 {0x000F, XCVR_DIAG_BIDI_CTRL}
3879 };
3880
3881 static const struct cdns_reg_pairs sl_dp_19_2_no_ssc_rx_ln_regs[] = {
3882 {0x0000, RX_PSC_A0},
3883 {0x0000, RX_PSC_A2},
3884 {0x0000, RX_PSC_A3},
3885 {0x0000, RX_PSC_CAL},
3886 {0x0000, RX_REE_GCSM1_CTRL},
3887 {0x0000, RX_REE_GCSM2_CTRL},
3888 {0x0000, RX_REE_PERGCSM_CTRL}
3889 };
3890
3891 static const struct cdns_torrent_vals sl_dp_19_2_no_ssc_cmn_vals = {
3892 .reg_pairs = sl_dp_19_2_no_ssc_cmn_regs,
3893 .num_regs = ARRAY_SIZE(sl_dp_19_2_no_ssc_cmn_regs),
3894 };
3895
3896 static const struct cdns_torrent_vals sl_dp_19_2_no_ssc_tx_ln_vals = {
3897 .reg_pairs = sl_dp_19_2_no_ssc_tx_ln_regs,
3898 .num_regs = ARRAY_SIZE(sl_dp_19_2_no_ssc_tx_ln_regs),
3899 };
3900
3901 static const struct cdns_torrent_vals sl_dp_19_2_no_ssc_rx_ln_vals = {
3902 .reg_pairs = sl_dp_19_2_no_ssc_rx_ln_regs,
3903 .num_regs = ARRAY_SIZE(sl_dp_19_2_no_ssc_rx_ln_regs),
3904 };
3905
3906 /* Single DP, 25 MHz Ref clk, no SSC */
3907 static const struct cdns_reg_pairs sl_dp_25_no_ssc_cmn_regs[] = {
3908 {0x0019, CMN_SSM_BIAS_TMR},
3909 {0x0032, CMN_PLLSM0_PLLPRE_TMR},
3910 {0x00D1, CMN_PLLSM0_PLLLOCK_TMR},
3911 {0x0032, CMN_PLLSM1_PLLPRE_TMR},
3912 {0x00D1, CMN_PLLSM1_PLLLOCK_TMR},
3913 {0x007D, CMN_BGCAL_INIT_TMR},
3914 {0x007D, CMN_BGCAL_ITER_TMR},
3915 {0x0019, CMN_IBCAL_INIT_TMR},
3916 {0x001E, CMN_TXPUCAL_INIT_TMR},
3917 {0x0006, CMN_TXPUCAL_ITER_TMR},
3918 {0x001E, CMN_TXPDCAL_INIT_TMR},
3919 {0x0006, CMN_TXPDCAL_ITER_TMR},
3920 {0x02EE, CMN_RXCAL_INIT_TMR},
3921 {0x0006, CMN_RXCAL_ITER_TMR},
3922 {0x0002, CMN_SD_CAL_INIT_TMR},
3923 {0x0002, CMN_SD_CAL_ITER_TMR},
3924 {0x000E, CMN_SD_CAL_REFTIM_START},
3925 {0x012B, CMN_SD_CAL_PLLCNT_START},
3926 {0x0509, CMN_PDIAG_PLL0_CP_PADJ_M0},
3927 {0x0F00, CMN_PDIAG_PLL0_CP_IADJ_M0},
3928 {0x0F08, CMN_PDIAG_PLL0_FILT_PADJ_M0},
3929 {0x0004, CMN_PLL0_DSM_DIAG_M0},
3930 {0x0509, CMN_PDIAG_PLL1_CP_PADJ_M0},
3931 {0x0F00, CMN_PDIAG_PLL1_CP_IADJ_M0},
3932 {0x0F08, CMN_PDIAG_PLL1_FILT_PADJ_M0},
3933 {0x0004, CMN_PLL1_DSM_DIAG_M0},
3934 {0x00FA, CMN_PLL0_VCOCAL_INIT_TMR},
3935 {0x0004, CMN_PLL0_VCOCAL_ITER_TMR},
3936 {0x00FA, CMN_PLL1_VCOCAL_INIT_TMR},
3937 {0x0004, CMN_PLL1_VCOCAL_ITER_TMR},
3938 {0x0317, CMN_PLL0_VCOCAL_REFTIM_START},
3939 {0x0003, CMN_PLL0_VCOCAL_TCTRL},
3940 {0x0317, CMN_PLL1_VCOCAL_REFTIM_START},
3941 {0x0003, CMN_PLL1_VCOCAL_TCTRL}
3942 };
3943
3944 static const struct cdns_reg_pairs sl_dp_25_no_ssc_tx_ln_regs[] = {
3945 {0x09C4, TX_RCVDET_ST_TMR},
3946 {0x00FB, TX_PSC_A0},
3947 {0x04AA, TX_PSC_A2},
3948 {0x04AA, TX_PSC_A3},
3949 {0x000F, XCVR_DIAG_BIDI_CTRL}
3950 };
3951
3952 static const struct cdns_reg_pairs sl_dp_25_no_ssc_rx_ln_regs[] = {
3953 {0x0000, RX_PSC_A0},
3954 {0x0000, RX_PSC_A2},
3955 {0x0000, RX_PSC_A3},
3956 {0x0000, RX_PSC_CAL},
3957 {0x0000, RX_REE_GCSM1_CTRL},
3958 {0x0000, RX_REE_GCSM2_CTRL},
3959 {0x0000, RX_REE_PERGCSM_CTRL}
3960 };
3961
3962 static const struct cdns_torrent_vals sl_dp_25_no_ssc_cmn_vals = {
3963 .reg_pairs = sl_dp_25_no_ssc_cmn_regs,
3964 .num_regs = ARRAY_SIZE(sl_dp_25_no_ssc_cmn_regs),
3965 };
3966
3967 static const struct cdns_torrent_vals sl_dp_25_no_ssc_tx_ln_vals = {
3968 .reg_pairs = sl_dp_25_no_ssc_tx_ln_regs,
3969 .num_regs = ARRAY_SIZE(sl_dp_25_no_ssc_tx_ln_regs),
3970 };
3971
3972 static const struct cdns_torrent_vals sl_dp_25_no_ssc_rx_ln_vals = {
3973 .reg_pairs = sl_dp_25_no_ssc_rx_ln_regs,
3974 .num_regs = ARRAY_SIZE(sl_dp_25_no_ssc_rx_ln_regs),
3975 };
3976
3977 /* Single DP, 100 MHz Ref clk, no SSC */
3978 static const struct cdns_reg_pairs sl_dp_100_no_ssc_cmn_regs[] = {
3979 {0x0003, CMN_PLL0_VCOCAL_TCTRL},
3980 {0x0003, CMN_PLL1_VCOCAL_TCTRL}
3981 };
3982
3983 static const struct cdns_reg_pairs sl_dp_100_no_ssc_tx_ln_regs[] = {
3984 {0x00FB, TX_PSC_A0},
3985 {0x04AA, TX_PSC_A2},
3986 {0x04AA, TX_PSC_A3},
3987 {0x000F, XCVR_DIAG_BIDI_CTRL}
3988 };
3989
3990 static const struct cdns_reg_pairs sl_dp_100_no_ssc_rx_ln_regs[] = {
3991 {0x0000, RX_PSC_A0},
3992 {0x0000, RX_PSC_A2},
3993 {0x0000, RX_PSC_A3},
3994 {0x0000, RX_PSC_CAL},
3995 {0x0000, RX_REE_GCSM1_CTRL},
3996 {0x0000, RX_REE_GCSM2_CTRL},
3997 {0x0000, RX_REE_PERGCSM_CTRL}
3998 };
3999
4000 static const struct cdns_torrent_vals sl_dp_100_no_ssc_cmn_vals = {
4001 .reg_pairs = sl_dp_100_no_ssc_cmn_regs,
4002 .num_regs = ARRAY_SIZE(sl_dp_100_no_ssc_cmn_regs),
4003 };
4004
4005 static const struct cdns_torrent_vals sl_dp_100_no_ssc_tx_ln_vals = {
4006 .reg_pairs = sl_dp_100_no_ssc_tx_ln_regs,
4007 .num_regs = ARRAY_SIZE(sl_dp_100_no_ssc_tx_ln_regs),
4008 };
4009
4010 static const struct cdns_torrent_vals sl_dp_100_no_ssc_rx_ln_vals = {
4011 .reg_pairs = sl_dp_100_no_ssc_rx_ln_regs,
4012 .num_regs = ARRAY_SIZE(sl_dp_100_no_ssc_rx_ln_regs),
4013 };
4014
4015 /* USB and SGMII/QSGMII link configuration */
4016 static const struct cdns_reg_pairs usb_sgmii_link_cmn_regs[] = {
4017 {0x0002, PHY_PLL_CFG},
4018 {0x8600, CMN_PDIAG_PLL0_CLK_SEL_M0},
4019 {0x0601, CMN_PDIAG_PLL1_CLK_SEL_M0}
4020 };
4021
4022 static const struct cdns_reg_pairs usb_sgmii_xcvr_diag_ln_regs[] = {
4023 {0x0000, XCVR_DIAG_HSCLK_SEL},
4024 {0x0001, XCVR_DIAG_HSCLK_DIV},
4025 {0x0041, XCVR_DIAG_PLLDRC_CTRL}
4026 };
4027
4028 static const struct cdns_reg_pairs sgmii_usb_xcvr_diag_ln_regs[] = {
4029 {0x0011, XCVR_DIAG_HSCLK_SEL},
4030 {0x0003, XCVR_DIAG_HSCLK_DIV},
4031 {0x009B, XCVR_DIAG_PLLDRC_CTRL}
4032 };
4033
4034 static const struct cdns_torrent_vals usb_sgmii_link_cmn_vals = {
4035 .reg_pairs = usb_sgmii_link_cmn_regs,
4036 .num_regs = ARRAY_SIZE(usb_sgmii_link_cmn_regs),
4037 };
4038
4039 static const struct cdns_torrent_vals usb_sgmii_xcvr_diag_ln_vals = {
4040 .reg_pairs = usb_sgmii_xcvr_diag_ln_regs,
4041 .num_regs = ARRAY_SIZE(usb_sgmii_xcvr_diag_ln_regs),
4042 };
4043
4044 static const struct cdns_torrent_vals sgmii_usb_xcvr_diag_ln_vals = {
4045 .reg_pairs = sgmii_usb_xcvr_diag_ln_regs,
4046 .num_regs = ARRAY_SIZE(sgmii_usb_xcvr_diag_ln_regs),
4047 };
4048
4049 /* PCIe and USB Unique SSC link configuration */
4050 static const struct cdns_reg_pairs pcie_usb_link_cmn_regs[] = {
4051 {0x0003, PHY_PLL_CFG},
4052 {0x0601, CMN_PDIAG_PLL0_CLK_SEL_M0},
4053 {0x0400, CMN_PDIAG_PLL0_CLK_SEL_M1},
4054 {0x8600, CMN_PDIAG_PLL1_CLK_SEL_M0}
4055 };
4056
4057 static const struct cdns_reg_pairs pcie_usb_xcvr_diag_ln_regs[] = {
4058 {0x0000, XCVR_DIAG_HSCLK_SEL},
4059 {0x0001, XCVR_DIAG_HSCLK_DIV},
4060 {0x0012, XCVR_DIAG_PLLDRC_CTRL}
4061 };
4062
4063 static const struct cdns_reg_pairs usb_pcie_xcvr_diag_ln_regs[] = {
4064 {0x0011, XCVR_DIAG_HSCLK_SEL},
4065 {0x0001, XCVR_DIAG_HSCLK_DIV},
4066 {0x00C9, XCVR_DIAG_PLLDRC_CTRL}
4067 };
4068
4069 static const struct cdns_torrent_vals pcie_usb_link_cmn_vals = {
4070 .reg_pairs = pcie_usb_link_cmn_regs,
4071 .num_regs = ARRAY_SIZE(pcie_usb_link_cmn_regs),
4072 };
4073
4074 static const struct cdns_torrent_vals pcie_usb_xcvr_diag_ln_vals = {
4075 .reg_pairs = pcie_usb_xcvr_diag_ln_regs,
4076 .num_regs = ARRAY_SIZE(pcie_usb_xcvr_diag_ln_regs),
4077 };
4078
4079 static const struct cdns_torrent_vals usb_pcie_xcvr_diag_ln_vals = {
4080 .reg_pairs = usb_pcie_xcvr_diag_ln_regs,
4081 .num_regs = ARRAY_SIZE(usb_pcie_xcvr_diag_ln_regs),
4082 };
4083
4084 /* USB 100 MHz Ref clk, internal SSC */
4085 static const struct cdns_reg_pairs usb_100_int_ssc_cmn_regs[] = {
4086 {0x0004, CMN_PLL0_DSM_DIAG_M0},
4087 {0x0004, CMN_PLL0_DSM_DIAG_M1},
4088 {0x0004, CMN_PLL1_DSM_DIAG_M0},
4089 {0x0509, CMN_PDIAG_PLL0_CP_PADJ_M0},
4090 {0x0509, CMN_PDIAG_PLL0_CP_PADJ_M1},
4091 {0x0509, CMN_PDIAG_PLL1_CP_PADJ_M0},
4092 {0x0F00, CMN_PDIAG_PLL0_CP_IADJ_M0},
4093 {0x0F00, CMN_PDIAG_PLL0_CP_IADJ_M1},
4094 {0x0F00, CMN_PDIAG_PLL1_CP_IADJ_M0},
4095 {0x0F08, CMN_PDIAG_PLL0_FILT_PADJ_M0},
4096 {0x0F08, CMN_PDIAG_PLL0_FILT_PADJ_M1},
4097 {0x0F08, CMN_PDIAG_PLL1_FILT_PADJ_M0},
4098 {0x0064, CMN_PLL0_INTDIV_M0},
4099 {0x0050, CMN_PLL0_INTDIV_M1},
4100 {0x0064, CMN_PLL1_INTDIV_M0},
4101 {0x0002, CMN_PLL0_FRACDIVH_M0},
4102 {0x0002, CMN_PLL0_FRACDIVH_M1},
4103 {0x0002, CMN_PLL1_FRACDIVH_M0},
4104 {0x0044, CMN_PLL0_HIGH_THR_M0},
4105 {0x0036, CMN_PLL0_HIGH_THR_M1},
4106 {0x0044, CMN_PLL1_HIGH_THR_M0},
4107 {0x0002, CMN_PDIAG_PLL0_CTRL_M0},
4108 {0x0002, CMN_PDIAG_PLL0_CTRL_M1},
4109 {0x0002, CMN_PDIAG_PLL1_CTRL_M0},
4110 {0x0001, CMN_PLL0_SS_CTRL1_M0},
4111 {0x0001, CMN_PLL0_SS_CTRL1_M1},
4112 {0x0001, CMN_PLL1_SS_CTRL1_M0},
4113 {0x011B, CMN_PLL0_SS_CTRL2_M0},
4114 {0x011B, CMN_PLL0_SS_CTRL2_M1},
4115 {0x011B, CMN_PLL1_SS_CTRL2_M0},
4116 {0x006E, CMN_PLL0_SS_CTRL3_M0},
4117 {0x0058, CMN_PLL0_SS_CTRL3_M1},
4118 {0x006E, CMN_PLL1_SS_CTRL3_M0},
4119 {0x000E, CMN_PLL0_SS_CTRL4_M0},
4120 {0x0012, CMN_PLL0_SS_CTRL4_M1},
4121 {0x000E, CMN_PLL1_SS_CTRL4_M0},
4122 {0x0C5E, CMN_PLL0_VCOCAL_REFTIM_START},
4123 {0x0C5E, CMN_PLL1_VCOCAL_REFTIM_START},
4124 {0x0C56, CMN_PLL0_VCOCAL_PLLCNT_START},
4125 {0x0C56, CMN_PLL1_VCOCAL_PLLCNT_START},
4126 {0x00C7, CMN_PLL0_LOCK_REFCNT_START},
4127 {0x00C7, CMN_PLL1_LOCK_REFCNT_START},
4128 {0x00C7, CMN_PLL0_LOCK_PLLCNT_START},
4129 {0x00C7, CMN_PLL1_LOCK_PLLCNT_START},
4130 {0x0005, CMN_PLL0_LOCK_PLLCNT_THR},
4131 {0x0005, CMN_PLL1_LOCK_PLLCNT_THR},
4132 {0x8200, CMN_CDIAG_CDB_PWRI_OVRD},
4133 {0x8200, CMN_CDIAG_XCVRC_PWRI_OVRD},
4134 {0x007F, CMN_TXPUCAL_TUNE},
4135 {0x007F, CMN_TXPDCAL_TUNE}
4136 };
4137
4138 static const struct cdns_torrent_vals usb_100_int_ssc_cmn_vals = {
4139 .reg_pairs = usb_100_int_ssc_cmn_regs,
4140 .num_regs = ARRAY_SIZE(usb_100_int_ssc_cmn_regs),
4141 };
4142
4143 /* Single USB link configuration */
4144 static const struct cdns_reg_pairs sl_usb_link_cmn_regs[] = {
4145 {0x0000, PHY_PLL_CFG},
4146 {0x8600, CMN_PDIAG_PLL0_CLK_SEL_M0}
4147 };
4148
4149 static const struct cdns_reg_pairs sl_usb_xcvr_diag_ln_regs[] = {
4150 {0x0000, XCVR_DIAG_HSCLK_SEL},
4151 {0x0001, XCVR_DIAG_HSCLK_DIV},
4152 {0x0041, XCVR_DIAG_PLLDRC_CTRL}
4153 };
4154
4155 static const struct cdns_torrent_vals sl_usb_link_cmn_vals = {
4156 .reg_pairs = sl_usb_link_cmn_regs,
4157 .num_regs = ARRAY_SIZE(sl_usb_link_cmn_regs),
4158 };
4159
4160 static const struct cdns_torrent_vals sl_usb_xcvr_diag_ln_vals = {
4161 .reg_pairs = sl_usb_xcvr_diag_ln_regs,
4162 .num_regs = ARRAY_SIZE(sl_usb_xcvr_diag_ln_regs),
4163 };
4164
4165 /* USB PHY PCS common configuration */
4166 static const struct cdns_reg_pairs usb_phy_pcs_cmn_regs[] = {
4167 {0x0A0A, PHY_PIPE_USB3_GEN2_PRE_CFG0},
4168 {0x1000, PHY_PIPE_USB3_GEN2_POST_CFG0},
4169 {0x0010, PHY_PIPE_USB3_GEN2_POST_CFG1}
4170 };
4171
4172 static const struct cdns_torrent_vals usb_phy_pcs_cmn_vals = {
4173 .reg_pairs = usb_phy_pcs_cmn_regs,
4174 .num_regs = ARRAY_SIZE(usb_phy_pcs_cmn_regs),
4175 };
4176
4177 /* USB 100 MHz Ref clk, no SSC */
4178 static const struct cdns_reg_pairs sl_usb_100_no_ssc_cmn_regs[] = {
4179 {0x0028, CMN_PDIAG_PLL1_CP_PADJ_M0},
4180 {0x001E, CMN_PLL1_DSM_FBH_OVRD_M0},
4181 {0x000C, CMN_PLL1_DSM_FBL_OVRD_M0},
4182 {0x0003, CMN_PLL0_VCOCAL_TCTRL},
4183 {0x0003, CMN_PLL1_VCOCAL_TCTRL},
4184 {0x8200, CMN_CDIAG_CDB_PWRI_OVRD},
4185 {0x8200, CMN_CDIAG_XCVRC_PWRI_OVRD}
4186 };
4187
4188 static const struct cdns_torrent_vals sl_usb_100_no_ssc_cmn_vals = {
4189 .reg_pairs = sl_usb_100_no_ssc_cmn_regs,
4190 .num_regs = ARRAY_SIZE(sl_usb_100_no_ssc_cmn_regs),
4191 };
4192
4193 static const struct cdns_reg_pairs usb_100_no_ssc_cmn_regs[] = {
4194 {0x8200, CMN_CDIAG_CDB_PWRI_OVRD},
4195 {0x8200, CMN_CDIAG_XCVRC_PWRI_OVRD},
4196 {0x007F, CMN_TXPUCAL_TUNE},
4197 {0x007F, CMN_TXPDCAL_TUNE}
4198 };
4199
4200 static const struct cdns_reg_pairs usb_100_no_ssc_tx_ln_regs[] = {
4201 {0x02FF, TX_PSC_A0},
4202 {0x06AF, TX_PSC_A1},
4203 {0x06AE, TX_PSC_A2},
4204 {0x06AE, TX_PSC_A3},
4205 {0x2A82, TX_TXCC_CTRL},
4206 {0x0014, TX_TXCC_CPOST_MULT_01},
4207 {0x0003, XCVR_DIAG_PSC_OVRD}
4208 };
4209
4210 static const struct cdns_reg_pairs usb_100_no_ssc_rx_ln_regs[] = {
4211 {0x0D1D, RX_PSC_A0},
4212 {0x0D1D, RX_PSC_A1},
4213 {0x0D00, RX_PSC_A2},
4214 {0x0500, RX_PSC_A3},
4215 {0x0013, RX_SIGDET_HL_FILT_TMR},
4216 {0x0000, RX_REE_GCSM1_CTRL},
4217 {0x0C02, RX_REE_ATTEN_THR},
4218 {0x0330, RX_REE_SMGM_CTRL1},
4219 {0x0300, RX_REE_SMGM_CTRL2},
4220 {0x0000, RX_REE_PEAK_UTHR},
4221 {0x01F5, RX_REE_PEAK_LTHR},
4222 {0x0019, RX_REE_TAP1_CLIP},
4223 {0x0019, RX_REE_TAP2TON_CLIP},
4224 {0x1004, RX_DIAG_SIGDET_TUNE},
4225 {0x00F9, RX_DIAG_NQST_CTRL},
4226 {0x0C01, RX_DIAG_DFE_AMP_TUNE_2},
4227 {0x0002, RX_DIAG_DFE_AMP_TUNE_3},
4228 {0x0000, RX_DIAG_PI_CAP},
4229 {0x0031, RX_DIAG_PI_RATE},
4230 {0x0001, RX_DIAG_ACYA},
4231 {0x018C, RX_CDRLF_CNFG},
4232 {0x0003, RX_CDRLF_CNFG3}
4233 };
4234
4235 static const struct cdns_torrent_vals usb_100_no_ssc_cmn_vals = {
4236 .reg_pairs = usb_100_no_ssc_cmn_regs,
4237 .num_regs = ARRAY_SIZE(usb_100_no_ssc_cmn_regs),
4238 };
4239
4240 static const struct cdns_torrent_vals usb_100_no_ssc_tx_ln_vals = {
4241 .reg_pairs = usb_100_no_ssc_tx_ln_regs,
4242 .num_regs = ARRAY_SIZE(usb_100_no_ssc_tx_ln_regs),
4243 };
4244
4245 static const struct cdns_torrent_vals usb_100_no_ssc_rx_ln_vals = {
4246 .reg_pairs = usb_100_no_ssc_rx_ln_regs,
4247 .num_regs = ARRAY_SIZE(usb_100_no_ssc_rx_ln_regs),
4248 };
4249
4250 /* Single link USB, 100 MHz Ref clk, internal SSC */
4251 static const struct cdns_reg_pairs sl_usb_100_int_ssc_cmn_regs[] = {
4252 {0x0004, CMN_PLL0_DSM_DIAG_M0},
4253 {0x0004, CMN_PLL1_DSM_DIAG_M0},
4254 {0x0509, CMN_PDIAG_PLL0_CP_PADJ_M0},
4255 {0x0509, CMN_PDIAG_PLL1_CP_PADJ_M0},
4256 {0x0F00, CMN_PDIAG_PLL0_CP_IADJ_M0},
4257 {0x0F00, CMN_PDIAG_PLL1_CP_IADJ_M0},
4258 {0x0F08, CMN_PDIAG_PLL0_FILT_PADJ_M0},
4259 {0x0F08, CMN_PDIAG_PLL1_FILT_PADJ_M0},
4260 {0x0064, CMN_PLL0_INTDIV_M0},
4261 {0x0064, CMN_PLL1_INTDIV_M0},
4262 {0x0002, CMN_PLL0_FRACDIVH_M0},
4263 {0x0002, CMN_PLL1_FRACDIVH_M0},
4264 {0x0044, CMN_PLL0_HIGH_THR_M0},
4265 {0x0044, CMN_PLL1_HIGH_THR_M0},
4266 {0x0002, CMN_PDIAG_PLL0_CTRL_M0},
4267 {0x0002, CMN_PDIAG_PLL1_CTRL_M0},
4268 {0x0001, CMN_PLL0_SS_CTRL1_M0},
4269 {0x0001, CMN_PLL1_SS_CTRL1_M0},
4270 {0x011B, CMN_PLL0_SS_CTRL2_M0},
4271 {0x011B, CMN_PLL1_SS_CTRL2_M0},
4272 {0x006E, CMN_PLL0_SS_CTRL3_M0},
4273 {0x006E, CMN_PLL1_SS_CTRL3_M0},
4274 {0x000E, CMN_PLL0_SS_CTRL4_M0},
4275 {0x000E, CMN_PLL1_SS_CTRL4_M0},
4276 {0x0C5E, CMN_PLL0_VCOCAL_REFTIM_START},
4277 {0x0C5E, CMN_PLL1_VCOCAL_REFTIM_START},
4278 {0x0C56, CMN_PLL0_VCOCAL_PLLCNT_START},
4279 {0x0C56, CMN_PLL1_VCOCAL_PLLCNT_START},
4280 {0x0003, CMN_PLL0_VCOCAL_TCTRL},
4281 {0x0003, CMN_PLL1_VCOCAL_TCTRL},
4282 {0x00C7, CMN_PLL0_LOCK_REFCNT_START},
4283 {0x00C7, CMN_PLL1_LOCK_REFCNT_START},
4284 {0x00C7, CMN_PLL0_LOCK_PLLCNT_START},
4285 {0x00C7, CMN_PLL1_LOCK_PLLCNT_START},
4286 {0x0005, CMN_PLL0_LOCK_PLLCNT_THR},
4287 {0x0005, CMN_PLL1_LOCK_PLLCNT_THR},
4288 {0x8200, CMN_CDIAG_CDB_PWRI_OVRD},
4289 {0x8200, CMN_CDIAG_XCVRC_PWRI_OVRD}
4290 };
4291
4292 static const struct cdns_torrent_vals sl_usb_100_int_ssc_cmn_vals = {
4293 .reg_pairs = sl_usb_100_int_ssc_cmn_regs,
4294 .num_regs = ARRAY_SIZE(sl_usb_100_int_ssc_cmn_regs),
4295 };
4296
4297 /* PCIe and SGMII/QSGMII Unique SSC link configuration */
4298 static const struct cdns_reg_pairs pcie_sgmii_link_cmn_regs[] = {
4299 {0x0003, PHY_PLL_CFG},
4300 {0x0601, CMN_PDIAG_PLL0_CLK_SEL_M0},
4301 {0x0400, CMN_PDIAG_PLL0_CLK_SEL_M1},
4302 {0x0601, CMN_PDIAG_PLL1_CLK_SEL_M0}
4303 };
4304
4305 static const struct cdns_reg_pairs pcie_sgmii_xcvr_diag_ln_regs[] = {
4306 {0x0000, XCVR_DIAG_HSCLK_SEL},
4307 {0x0001, XCVR_DIAG_HSCLK_DIV},
4308 {0x0012, XCVR_DIAG_PLLDRC_CTRL}
4309 };
4310
4311 static const struct cdns_reg_pairs sgmii_pcie_xcvr_diag_ln_regs[] = {
4312 {0x0011, XCVR_DIAG_HSCLK_SEL},
4313 {0x0003, XCVR_DIAG_HSCLK_DIV},
4314 {0x009B, XCVR_DIAG_PLLDRC_CTRL}
4315 };
4316
4317 static const struct cdns_torrent_vals pcie_sgmii_link_cmn_vals = {
4318 .reg_pairs = pcie_sgmii_link_cmn_regs,
4319 .num_regs = ARRAY_SIZE(pcie_sgmii_link_cmn_regs),
4320 };
4321
4322 static const struct cdns_torrent_vals pcie_sgmii_xcvr_diag_ln_vals = {
4323 .reg_pairs = pcie_sgmii_xcvr_diag_ln_regs,
4324 .num_regs = ARRAY_SIZE(pcie_sgmii_xcvr_diag_ln_regs),
4325 };
4326
4327 static const struct cdns_torrent_vals sgmii_pcie_xcvr_diag_ln_vals = {
4328 .reg_pairs = sgmii_pcie_xcvr_diag_ln_regs,
4329 .num_regs = ARRAY_SIZE(sgmii_pcie_xcvr_diag_ln_regs),
4330 };
4331
4332 /* SGMII 100 MHz Ref clk, no SSC */
4333 static const struct cdns_reg_pairs sl_sgmii_100_no_ssc_cmn_regs[] = {
4334 {0x0028, CMN_PDIAG_PLL1_CP_PADJ_M0},
4335 {0x001E, CMN_PLL1_DSM_FBH_OVRD_M0},
4336 {0x000C, CMN_PLL1_DSM_FBL_OVRD_M0},
4337 {0x0003, CMN_PLL0_VCOCAL_TCTRL},
4338 {0x0003, CMN_PLL1_VCOCAL_TCTRL}
4339 };
4340
4341 static const struct cdns_torrent_vals sl_sgmii_100_no_ssc_cmn_vals = {
4342 .reg_pairs = sl_sgmii_100_no_ssc_cmn_regs,
4343 .num_regs = ARRAY_SIZE(sl_sgmii_100_no_ssc_cmn_regs),
4344 };
4345
4346 static const struct cdns_reg_pairs sgmii_100_no_ssc_cmn_regs[] = {
4347 {0x007F, CMN_TXPUCAL_TUNE},
4348 {0x007F, CMN_TXPDCAL_TUNE}
4349 };
4350
4351 static const struct cdns_reg_pairs sgmii_100_no_ssc_tx_ln_regs[] = {
4352 {0x00F3, TX_PSC_A0},
4353 {0x04A2, TX_PSC_A2},
4354 {0x04A2, TX_PSC_A3},
4355 {0x0000, TX_TXCC_CPOST_MULT_00},
4356 {0x00B3, DRV_DIAG_TX_DRV},
4357 {0x0002, XCVR_DIAG_PSC_OVRD}
4358 };
4359
4360 static const struct cdns_reg_pairs ti_sgmii_100_no_ssc_tx_ln_regs[] = {
4361 {0x00F3, TX_PSC_A0},
4362 {0x04A2, TX_PSC_A2},
4363 {0x04A2, TX_PSC_A3},
4364 {0x0000, TX_TXCC_CPOST_MULT_00},
4365 {0x00B3, DRV_DIAG_TX_DRV},
4366 {0x0002, XCVR_DIAG_PSC_OVRD},
4367 {0x4000, XCVR_DIAG_RXCLK_CTRL}
4368 };
4369
4370 static const struct cdns_reg_pairs sgmii_100_no_ssc_rx_ln_regs[] = {
4371 {0x091D, RX_PSC_A0},
4372 {0x0900, RX_PSC_A2},
4373 {0x0100, RX_PSC_A3},
4374 {0x03C7, RX_REE_GCSM1_EQENM_PH1},
4375 {0x01C7, RX_REE_GCSM1_EQENM_PH2},
4376 {0x0000, RX_DIAG_DFE_CTRL},
4377 {0x0019, RX_REE_TAP1_CLIP},
4378 {0x0019, RX_REE_TAP2TON_CLIP},
4379 {0x0098, RX_DIAG_NQST_CTRL},
4380 {0x0C01, RX_DIAG_DFE_AMP_TUNE_2},
4381 {0x0000, RX_DIAG_DFE_AMP_TUNE_3},
4382 {0x0000, RX_DIAG_PI_CAP},
4383 {0x0010, RX_DIAG_PI_RATE},
4384 {0x0001, RX_DIAG_ACYA},
4385 {0x018C, RX_CDRLF_CNFG},
4386 };
4387
4388 static const struct cdns_torrent_vals sgmii_100_no_ssc_cmn_vals = {
4389 .reg_pairs = sgmii_100_no_ssc_cmn_regs,
4390 .num_regs = ARRAY_SIZE(sgmii_100_no_ssc_cmn_regs),
4391 };
4392
4393 static const struct cdns_torrent_vals sgmii_100_no_ssc_tx_ln_vals = {
4394 .reg_pairs = sgmii_100_no_ssc_tx_ln_regs,
4395 .num_regs = ARRAY_SIZE(sgmii_100_no_ssc_tx_ln_regs),
4396 };
4397
4398 static const struct cdns_torrent_vals ti_sgmii_100_no_ssc_tx_ln_vals = {
4399 .reg_pairs = ti_sgmii_100_no_ssc_tx_ln_regs,
4400 .num_regs = ARRAY_SIZE(ti_sgmii_100_no_ssc_tx_ln_regs),
4401 };
4402
4403 static const struct cdns_torrent_vals sgmii_100_no_ssc_rx_ln_vals = {
4404 .reg_pairs = sgmii_100_no_ssc_rx_ln_regs,
4405 .num_regs = ARRAY_SIZE(sgmii_100_no_ssc_rx_ln_regs),
4406 };
4407
4408 /* TI J7200, multilink SGMII */
4409 static const struct cdns_reg_pairs j7200_sgmii_100_no_ssc_tx_ln_regs[] = {
4410 {0x07A2, TX_RCVDET_ST_TMR},
4411 {0x00F3, TX_PSC_A0},
4412 {0x04A2, TX_PSC_A2},
4413 {0x04A2, TX_PSC_A3 },
4414 {0x0000, TX_TXCC_CPOST_MULT_00},
4415 {0x00B3, DRV_DIAG_TX_DRV},
4416 {0x0002, XCVR_DIAG_PSC_OVRD},
4417 {0x4000, XCVR_DIAG_RXCLK_CTRL}
4418 };
4419
4420 static const struct cdns_torrent_vals j7200_sgmii_100_no_ssc_tx_ln_vals = {
4421 .reg_pairs = j7200_sgmii_100_no_ssc_tx_ln_regs,
4422 .num_regs = ARRAY_SIZE(j7200_sgmii_100_no_ssc_tx_ln_regs),
4423 };
4424
4425 static const struct cdns_reg_pairs j7200_sgmii_100_no_ssc_rx_ln_regs[] = {
4426 {0x0014, RX_SDCAL0_INIT_TMR},
4427 {0x0062, RX_SDCAL0_ITER_TMR},
4428 {0x0014, RX_SDCAL1_INIT_TMR},
4429 {0x0062, RX_SDCAL1_ITER_TMR},
4430 {0x091D, RX_PSC_A0},
4431 {0x0900, RX_PSC_A2},
4432 {0x0100, RX_PSC_A3},
4433 {0x03C7, RX_REE_GCSM1_EQENM_PH1},
4434 {0x01C7, RX_REE_GCSM1_EQENM_PH2},
4435 {0x0000, RX_DIAG_DFE_CTRL},
4436 {0x0019, RX_REE_TAP1_CLIP},
4437 {0x0019, RX_REE_TAP2TON_CLIP},
4438 {0x0098, RX_DIAG_NQST_CTRL},
4439 {0x0C01, RX_DIAG_DFE_AMP_TUNE_2},
4440 {0x0000, RX_DIAG_DFE_AMP_TUNE_3},
4441 {0x0000, RX_DIAG_PI_CAP},
4442 {0x0010, RX_DIAG_PI_RATE},
4443 {0x0001, RX_DIAG_ACYA},
4444 {0x018C, RX_CDRLF_CNFG}
4445 };
4446
4447 static const struct cdns_torrent_vals j7200_sgmii_100_no_ssc_rx_ln_vals = {
4448 .reg_pairs = j7200_sgmii_100_no_ssc_rx_ln_regs,
4449 .num_regs = ARRAY_SIZE(j7200_sgmii_100_no_ssc_rx_ln_regs),
4450 };
4451
4452 /* SGMII 100 MHz Ref clk, internal SSC */
4453 static const struct cdns_reg_pairs sgmii_100_int_ssc_cmn_regs[] = {
4454 {0x0004, CMN_PLL0_DSM_DIAG_M0},
4455 {0x0004, CMN_PLL0_DSM_DIAG_M1},
4456 {0x0004, CMN_PLL1_DSM_DIAG_M0},
4457 {0x0509, CMN_PDIAG_PLL0_CP_PADJ_M0},
4458 {0x0509, CMN_PDIAG_PLL0_CP_PADJ_M1},
4459 {0x0509, CMN_PDIAG_PLL1_CP_PADJ_M0},
4460 {0x0F00, CMN_PDIAG_PLL0_CP_IADJ_M0},
4461 {0x0F00, CMN_PDIAG_PLL0_CP_IADJ_M1},
4462 {0x0F00, CMN_PDIAG_PLL1_CP_IADJ_M0},
4463 {0x0F08, CMN_PDIAG_PLL0_FILT_PADJ_M0},
4464 {0x0F08, CMN_PDIAG_PLL0_FILT_PADJ_M1},
4465 {0x0F08, CMN_PDIAG_PLL1_FILT_PADJ_M0},
4466 {0x0064, CMN_PLL0_INTDIV_M0},
4467 {0x0050, CMN_PLL0_INTDIV_M1},
4468 {0x0064, CMN_PLL1_INTDIV_M0},
4469 {0x0002, CMN_PLL0_FRACDIVH_M0},
4470 {0x0002, CMN_PLL0_FRACDIVH_M1},
4471 {0x0002, CMN_PLL1_FRACDIVH_M0},
4472 {0x0044, CMN_PLL0_HIGH_THR_M0},
4473 {0x0036, CMN_PLL0_HIGH_THR_M1},
4474 {0x0044, CMN_PLL1_HIGH_THR_M0},
4475 {0x0002, CMN_PDIAG_PLL0_CTRL_M0},
4476 {0x0002, CMN_PDIAG_PLL0_CTRL_M1},
4477 {0x0002, CMN_PDIAG_PLL1_CTRL_M0},
4478 {0x0001, CMN_PLL0_SS_CTRL1_M0},
4479 {0x0001, CMN_PLL0_SS_CTRL1_M1},
4480 {0x0001, CMN_PLL1_SS_CTRL1_M0},
4481 {0x011B, CMN_PLL0_SS_CTRL2_M0},
4482 {0x011B, CMN_PLL0_SS_CTRL2_M1},
4483 {0x011B, CMN_PLL1_SS_CTRL2_M0},
4484 {0x006E, CMN_PLL0_SS_CTRL3_M0},
4485 {0x0058, CMN_PLL0_SS_CTRL3_M1},
4486 {0x006E, CMN_PLL1_SS_CTRL3_M0},
4487 {0x000E, CMN_PLL0_SS_CTRL4_M0},
4488 {0x0012, CMN_PLL0_SS_CTRL4_M1},
4489 {0x000E, CMN_PLL1_SS_CTRL4_M0},
4490 {0x0C5E, CMN_PLL0_VCOCAL_REFTIM_START},
4491 {0x0C5E, CMN_PLL1_VCOCAL_REFTIM_START},
4492 {0x0C56, CMN_PLL0_VCOCAL_PLLCNT_START},
4493 {0x0C56, CMN_PLL1_VCOCAL_PLLCNT_START},
4494 {0x00C7, CMN_PLL0_LOCK_REFCNT_START},
4495 {0x00C7, CMN_PLL1_LOCK_REFCNT_START},
4496 {0x00C7, CMN_PLL0_LOCK_PLLCNT_START},
4497 {0x00C7, CMN_PLL1_LOCK_PLLCNT_START},
4498 {0x0005, CMN_PLL0_LOCK_PLLCNT_THR},
4499 {0x0005, CMN_PLL1_LOCK_PLLCNT_THR},
4500 {0x007F, CMN_TXPUCAL_TUNE},
4501 {0x007F, CMN_TXPDCAL_TUNE}
4502 };
4503
4504 static const struct cdns_torrent_vals sgmii_100_int_ssc_cmn_vals = {
4505 .reg_pairs = sgmii_100_int_ssc_cmn_regs,
4506 .num_regs = ARRAY_SIZE(sgmii_100_int_ssc_cmn_regs),
4507 };
4508
4509 /* QSGMII 100 MHz Ref clk, no SSC */
4510 static const struct cdns_reg_pairs sl_qsgmii_100_no_ssc_cmn_regs[] = {
4511 {0x0028, CMN_PDIAG_PLL1_CP_PADJ_M0},
4512 {0x001E, CMN_PLL1_DSM_FBH_OVRD_M0},
4513 {0x000C, CMN_PLL1_DSM_FBL_OVRD_M0},
4514 {0x0003, CMN_PLL0_VCOCAL_TCTRL},
4515 {0x0003, CMN_PLL1_VCOCAL_TCTRL}
4516 };
4517
4518 static const struct cdns_torrent_vals sl_qsgmii_100_no_ssc_cmn_vals = {
4519 .reg_pairs = sl_qsgmii_100_no_ssc_cmn_regs,
4520 .num_regs = ARRAY_SIZE(sl_qsgmii_100_no_ssc_cmn_regs),
4521 };
4522
4523 static const struct cdns_reg_pairs qsgmii_100_no_ssc_cmn_regs[] = {
4524 {0x007F, CMN_TXPUCAL_TUNE},
4525 {0x007F, CMN_TXPDCAL_TUNE}
4526 };
4527
4528 static const struct cdns_reg_pairs qsgmii_100_no_ssc_tx_ln_regs[] = {
4529 {0x00F3, TX_PSC_A0},
4530 {0x04A2, TX_PSC_A2},
4531 {0x04A2, TX_PSC_A3},
4532 {0x0000, TX_TXCC_CPOST_MULT_00},
4533 {0x0011, TX_TXCC_MGNFS_MULT_100},
4534 {0x0003, DRV_DIAG_TX_DRV},
4535 {0x0002, XCVR_DIAG_PSC_OVRD}
4536 };
4537
4538 static const struct cdns_reg_pairs ti_qsgmii_100_no_ssc_tx_ln_regs[] = {
4539 {0x00F3, TX_PSC_A0},
4540 {0x04A2, TX_PSC_A2},
4541 {0x04A2, TX_PSC_A3},
4542 {0x0000, TX_TXCC_CPOST_MULT_00},
4543 {0x0011, TX_TXCC_MGNFS_MULT_100},
4544 {0x0003, DRV_DIAG_TX_DRV},
4545 {0x0002, XCVR_DIAG_PSC_OVRD},
4546 {0x4000, XCVR_DIAG_RXCLK_CTRL}
4547 };
4548
4549 static const struct cdns_reg_pairs qsgmii_100_no_ssc_rx_ln_regs[] = {
4550 {0x091D, RX_PSC_A0},
4551 {0x0900, RX_PSC_A2},
4552 {0x0100, RX_PSC_A3},
4553 {0x03C7, RX_REE_GCSM1_EQENM_PH1},
4554 {0x01C7, RX_REE_GCSM1_EQENM_PH2},
4555 {0x0000, RX_DIAG_DFE_CTRL},
4556 {0x0019, RX_REE_TAP1_CLIP},
4557 {0x0019, RX_REE_TAP2TON_CLIP},
4558 {0x0098, RX_DIAG_NQST_CTRL},
4559 {0x0C01, RX_DIAG_DFE_AMP_TUNE_2},
4560 {0x0000, RX_DIAG_DFE_AMP_TUNE_3},
4561 {0x0000, RX_DIAG_PI_CAP},
4562 {0x0010, RX_DIAG_PI_RATE},
4563 {0x0001, RX_DIAG_ACYA},
4564 {0x018C, RX_CDRLF_CNFG},
4565 };
4566
4567 static const struct cdns_torrent_vals qsgmii_100_no_ssc_cmn_vals = {
4568 .reg_pairs = qsgmii_100_no_ssc_cmn_regs,
4569 .num_regs = ARRAY_SIZE(qsgmii_100_no_ssc_cmn_regs),
4570 };
4571
4572 static const struct cdns_torrent_vals qsgmii_100_no_ssc_tx_ln_vals = {
4573 .reg_pairs = qsgmii_100_no_ssc_tx_ln_regs,
4574 .num_regs = ARRAY_SIZE(qsgmii_100_no_ssc_tx_ln_regs),
4575 };
4576
4577 static const struct cdns_torrent_vals ti_qsgmii_100_no_ssc_tx_ln_vals = {
4578 .reg_pairs = ti_qsgmii_100_no_ssc_tx_ln_regs,
4579 .num_regs = ARRAY_SIZE(ti_qsgmii_100_no_ssc_tx_ln_regs),
4580 };
4581
4582 static const struct cdns_torrent_vals qsgmii_100_no_ssc_rx_ln_vals = {
4583 .reg_pairs = qsgmii_100_no_ssc_rx_ln_regs,
4584 .num_regs = ARRAY_SIZE(qsgmii_100_no_ssc_rx_ln_regs),
4585 };
4586
4587 /* TI J7200, multilink QSGMII */
4588 static const struct cdns_reg_pairs j7200_qsgmii_100_no_ssc_tx_ln_regs[] = {
4589 {0x07A2, TX_RCVDET_ST_TMR},
4590 {0x00F3, TX_PSC_A0},
4591 {0x04A2, TX_PSC_A2},
4592 {0x04A2, TX_PSC_A3 },
4593 {0x0000, TX_TXCC_CPOST_MULT_00},
4594 {0x0011, TX_TXCC_MGNFS_MULT_100},
4595 {0x0003, DRV_DIAG_TX_DRV},
4596 {0x0002, XCVR_DIAG_PSC_OVRD},
4597 {0x4000, XCVR_DIAG_RXCLK_CTRL}
4598 };
4599
4600 static const struct cdns_torrent_vals j7200_qsgmii_100_no_ssc_tx_ln_vals = {
4601 .reg_pairs = j7200_qsgmii_100_no_ssc_tx_ln_regs,
4602 .num_regs = ARRAY_SIZE(j7200_qsgmii_100_no_ssc_tx_ln_regs),
4603 };
4604
4605 static const struct cdns_reg_pairs j7200_qsgmii_100_no_ssc_rx_ln_regs[] = {
4606 {0x0014, RX_SDCAL0_INIT_TMR},
4607 {0x0062, RX_SDCAL0_ITER_TMR},
4608 {0x0014, RX_SDCAL1_INIT_TMR},
4609 {0x0062, RX_SDCAL1_ITER_TMR},
4610 {0x091D, RX_PSC_A0},
4611 {0x0900, RX_PSC_A2},
4612 {0x0100, RX_PSC_A3},
4613 {0x03C7, RX_REE_GCSM1_EQENM_PH1},
4614 {0x01C7, RX_REE_GCSM1_EQENM_PH2},
4615 {0x0000, RX_DIAG_DFE_CTRL},
4616 {0x0019, RX_REE_TAP1_CLIP},
4617 {0x0019, RX_REE_TAP2TON_CLIP},
4618 {0x0098, RX_DIAG_NQST_CTRL},
4619 {0x0C01, RX_DIAG_DFE_AMP_TUNE_2},
4620 {0x0000, RX_DIAG_DFE_AMP_TUNE_3},
4621 {0x0000, RX_DIAG_PI_CAP},
4622 {0x0010, RX_DIAG_PI_RATE},
4623 {0x0001, RX_DIAG_ACYA},
4624 {0x018C, RX_CDRLF_CNFG}
4625 };
4626
4627 static const struct cdns_torrent_vals j7200_qsgmii_100_no_ssc_rx_ln_vals = {
4628 .reg_pairs = j7200_qsgmii_100_no_ssc_rx_ln_regs,
4629 .num_regs = ARRAY_SIZE(j7200_qsgmii_100_no_ssc_rx_ln_regs),
4630 };
4631
4632 /* QSGMII 100 MHz Ref clk, internal SSC */
4633 static const struct cdns_reg_pairs qsgmii_100_int_ssc_cmn_regs[] = {
4634 {0x0004, CMN_PLL0_DSM_DIAG_M0},
4635 {0x0004, CMN_PLL0_DSM_DIAG_M1},
4636 {0x0004, CMN_PLL1_DSM_DIAG_M0},
4637 {0x0509, CMN_PDIAG_PLL0_CP_PADJ_M0},
4638 {0x0509, CMN_PDIAG_PLL0_CP_PADJ_M1},
4639 {0x0509, CMN_PDIAG_PLL1_CP_PADJ_M0},
4640 {0x0F00, CMN_PDIAG_PLL0_CP_IADJ_M0},
4641 {0x0F00, CMN_PDIAG_PLL0_CP_IADJ_M1},
4642 {0x0F00, CMN_PDIAG_PLL1_CP_IADJ_M0},
4643 {0x0F08, CMN_PDIAG_PLL0_FILT_PADJ_M0},
4644 {0x0F08, CMN_PDIAG_PLL0_FILT_PADJ_M1},
4645 {0x0F08, CMN_PDIAG_PLL1_FILT_PADJ_M0},
4646 {0x0064, CMN_PLL0_INTDIV_M0},
4647 {0x0050, CMN_PLL0_INTDIV_M1},
4648 {0x0064, CMN_PLL1_INTDIV_M0},
4649 {0x0002, CMN_PLL0_FRACDIVH_M0},
4650 {0x0002, CMN_PLL0_FRACDIVH_M1},
4651 {0x0002, CMN_PLL1_FRACDIVH_M0},
4652 {0x0044, CMN_PLL0_HIGH_THR_M0},
4653 {0x0036, CMN_PLL0_HIGH_THR_M1},
4654 {0x0044, CMN_PLL1_HIGH_THR_M0},
4655 {0x0002, CMN_PDIAG_PLL0_CTRL_M0},
4656 {0x0002, CMN_PDIAG_PLL0_CTRL_M1},
4657 {0x0002, CMN_PDIAG_PLL1_CTRL_M0},
4658 {0x0001, CMN_PLL0_SS_CTRL1_M0},
4659 {0x0001, CMN_PLL0_SS_CTRL1_M1},
4660 {0x0001, CMN_PLL1_SS_CTRL1_M0},
4661 {0x011B, CMN_PLL0_SS_CTRL2_M0},
4662 {0x011B, CMN_PLL0_SS_CTRL2_M1},
4663 {0x011B, CMN_PLL1_SS_CTRL2_M0},
4664 {0x006E, CMN_PLL0_SS_CTRL3_M0},
4665 {0x0058, CMN_PLL0_SS_CTRL3_M1},
4666 {0x006E, CMN_PLL1_SS_CTRL3_M0},
4667 {0x000E, CMN_PLL0_SS_CTRL4_M0},
4668 {0x0012, CMN_PLL0_SS_CTRL4_M1},
4669 {0x000E, CMN_PLL1_SS_CTRL4_M0},
4670 {0x0C5E, CMN_PLL0_VCOCAL_REFTIM_START},
4671 {0x0C5E, CMN_PLL1_VCOCAL_REFTIM_START},
4672 {0x0C56, CMN_PLL0_VCOCAL_PLLCNT_START},
4673 {0x0C56, CMN_PLL1_VCOCAL_PLLCNT_START},
4674 {0x00C7, CMN_PLL0_LOCK_REFCNT_START},
4675 {0x00C7, CMN_PLL1_LOCK_REFCNT_START},
4676 {0x00C7, CMN_PLL0_LOCK_PLLCNT_START},
4677 {0x00C7, CMN_PLL1_LOCK_PLLCNT_START},
4678 {0x0005, CMN_PLL0_LOCK_PLLCNT_THR},
4679 {0x0005, CMN_PLL1_LOCK_PLLCNT_THR},
4680 {0x007F, CMN_TXPUCAL_TUNE},
4681 {0x007F, CMN_TXPDCAL_TUNE}
4682 };
4683
4684 static const struct cdns_torrent_vals qsgmii_100_int_ssc_cmn_vals = {
4685 .reg_pairs = qsgmii_100_int_ssc_cmn_regs,
4686 .num_regs = ARRAY_SIZE(qsgmii_100_int_ssc_cmn_regs),
4687 };
4688
4689 /* Single SGMII/QSGMII link configuration */
4690 static const struct cdns_reg_pairs sl_sgmii_link_cmn_regs[] = {
4691 {0x0000, PHY_PLL_CFG},
4692 {0x0601, CMN_PDIAG_PLL0_CLK_SEL_M0}
4693 };
4694
4695 static const struct cdns_reg_pairs sl_sgmii_xcvr_diag_ln_regs[] = {
4696 {0x0000, XCVR_DIAG_HSCLK_SEL},
4697 {0x0003, XCVR_DIAG_HSCLK_DIV},
4698 {0x0013, XCVR_DIAG_PLLDRC_CTRL}
4699 };
4700
4701 static const struct cdns_torrent_vals sl_sgmii_link_cmn_vals = {
4702 .reg_pairs = sl_sgmii_link_cmn_regs,
4703 .num_regs = ARRAY_SIZE(sl_sgmii_link_cmn_regs),
4704 };
4705
4706 static const struct cdns_torrent_vals sl_sgmii_xcvr_diag_ln_vals = {
4707 .reg_pairs = sl_sgmii_xcvr_diag_ln_regs,
4708 .num_regs = ARRAY_SIZE(sl_sgmii_xcvr_diag_ln_regs),
4709 };
4710
4711 /* For PCIe (with some other protocol), 100 MHz Ref clk, internal SSC */
4712 static const struct cdns_reg_pairs pcie_100_int_ssc_cmn_regs[] = {
4713 {0x0004, CMN_PLL0_DSM_DIAG_M0},
4714 {0x0004, CMN_PLL0_DSM_DIAG_M1},
4715 {0x0004, CMN_PLL1_DSM_DIAG_M0},
4716 {0x0509, CMN_PDIAG_PLL0_CP_PADJ_M0},
4717 {0x0509, CMN_PDIAG_PLL0_CP_PADJ_M1},
4718 {0x0509, CMN_PDIAG_PLL1_CP_PADJ_M0},
4719 {0x0F00, CMN_PDIAG_PLL0_CP_IADJ_M0},
4720 {0x0F00, CMN_PDIAG_PLL0_CP_IADJ_M1},
4721 {0x0F00, CMN_PDIAG_PLL1_CP_IADJ_M0},
4722 {0x0F08, CMN_PDIAG_PLL0_FILT_PADJ_M0},
4723 {0x0F08, CMN_PDIAG_PLL0_FILT_PADJ_M1},
4724 {0x0F08, CMN_PDIAG_PLL1_FILT_PADJ_M0},
4725 {0x0064, CMN_PLL0_INTDIV_M0},
4726 {0x0050, CMN_PLL0_INTDIV_M1},
4727 {0x0064, CMN_PLL1_INTDIV_M0},
4728 {0x0002, CMN_PLL0_FRACDIVH_M0},
4729 {0x0002, CMN_PLL0_FRACDIVH_M1},
4730 {0x0002, CMN_PLL1_FRACDIVH_M0},
4731 {0x0044, CMN_PLL0_HIGH_THR_M0},
4732 {0x0036, CMN_PLL0_HIGH_THR_M1},
4733 {0x0044, CMN_PLL1_HIGH_THR_M0},
4734 {0x0002, CMN_PDIAG_PLL0_CTRL_M0},
4735 {0x0002, CMN_PDIAG_PLL0_CTRL_M1},
4736 {0x0002, CMN_PDIAG_PLL1_CTRL_M0},
4737 {0x0001, CMN_PLL0_SS_CTRL1_M0},
4738 {0x0001, CMN_PLL0_SS_CTRL1_M1},
4739 {0x0001, CMN_PLL1_SS_CTRL1_M0},
4740 {0x011B, CMN_PLL0_SS_CTRL2_M0},
4741 {0x011B, CMN_PLL0_SS_CTRL2_M1},
4742 {0x011B, CMN_PLL1_SS_CTRL2_M0},
4743 {0x006E, CMN_PLL0_SS_CTRL3_M0},
4744 {0x0058, CMN_PLL0_SS_CTRL3_M1},
4745 {0x006E, CMN_PLL1_SS_CTRL3_M0},
4746 {0x000E, CMN_PLL0_SS_CTRL4_M0},
4747 {0x0012, CMN_PLL0_SS_CTRL4_M1},
4748 {0x000E, CMN_PLL1_SS_CTRL4_M0},
4749 {0x0C5E, CMN_PLL0_VCOCAL_REFTIM_START},
4750 {0x0C5E, CMN_PLL1_VCOCAL_REFTIM_START},
4751 {0x0C56, CMN_PLL0_VCOCAL_PLLCNT_START},
4752 {0x0C56, CMN_PLL1_VCOCAL_PLLCNT_START},
4753 {0x00C7, CMN_PLL0_LOCK_REFCNT_START},
4754 {0x00C7, CMN_PLL1_LOCK_REFCNT_START},
4755 {0x00C7, CMN_PLL0_LOCK_PLLCNT_START},
4756 {0x00C7, CMN_PLL1_LOCK_PLLCNT_START},
4757 {0x0005, CMN_PLL0_LOCK_PLLCNT_THR},
4758 {0x0005, CMN_PLL1_LOCK_PLLCNT_THR}
4759 };
4760
4761 static const struct cdns_torrent_vals pcie_100_int_ssc_cmn_vals = {
4762 .reg_pairs = pcie_100_int_ssc_cmn_regs,
4763 .num_regs = ARRAY_SIZE(pcie_100_int_ssc_cmn_regs),
4764 };
4765
4766 /* Single link PCIe, 100 MHz Ref clk, internal SSC */
4767 static const struct cdns_reg_pairs sl_pcie_100_int_ssc_cmn_regs[] = {
4768 {0x0004, CMN_PLL0_DSM_DIAG_M0},
4769 {0x0004, CMN_PLL0_DSM_DIAG_M1},
4770 {0x0004, CMN_PLL1_DSM_DIAG_M0},
4771 {0x0509, CMN_PDIAG_PLL0_CP_PADJ_M0},
4772 {0x0509, CMN_PDIAG_PLL0_CP_PADJ_M1},
4773 {0x0509, CMN_PDIAG_PLL1_CP_PADJ_M0},
4774 {0x0F00, CMN_PDIAG_PLL0_CP_IADJ_M0},
4775 {0x0F00, CMN_PDIAG_PLL0_CP_IADJ_M1},
4776 {0x0F00, CMN_PDIAG_PLL1_CP_IADJ_M0},
4777 {0x0F08, CMN_PDIAG_PLL0_FILT_PADJ_M0},
4778 {0x0F08, CMN_PDIAG_PLL0_FILT_PADJ_M1},
4779 {0x0F08, CMN_PDIAG_PLL1_FILT_PADJ_M0},
4780 {0x0064, CMN_PLL0_INTDIV_M0},
4781 {0x0050, CMN_PLL0_INTDIV_M1},
4782 {0x0050, CMN_PLL1_INTDIV_M0},
4783 {0x0002, CMN_PLL0_FRACDIVH_M0},
4784 {0x0002, CMN_PLL0_FRACDIVH_M1},
4785 {0x0002, CMN_PLL1_FRACDIVH_M0},
4786 {0x0044, CMN_PLL0_HIGH_THR_M0},
4787 {0x0036, CMN_PLL0_HIGH_THR_M1},
4788 {0x0036, CMN_PLL1_HIGH_THR_M0},
4789 {0x0002, CMN_PDIAG_PLL0_CTRL_M0},
4790 {0x0002, CMN_PDIAG_PLL0_CTRL_M1},
4791 {0x0002, CMN_PDIAG_PLL1_CTRL_M0},
4792 {0x0001, CMN_PLL0_SS_CTRL1_M0},
4793 {0x0001, CMN_PLL0_SS_CTRL1_M1},
4794 {0x0001, CMN_PLL1_SS_CTRL1_M0},
4795 {0x011B, CMN_PLL0_SS_CTRL2_M0},
4796 {0x011B, CMN_PLL0_SS_CTRL2_M1},
4797 {0x011B, CMN_PLL1_SS_CTRL2_M0},
4798 {0x006E, CMN_PLL0_SS_CTRL3_M0},
4799 {0x0058, CMN_PLL0_SS_CTRL3_M1},
4800 {0x0058, CMN_PLL1_SS_CTRL3_M0},
4801 {0x000E, CMN_PLL0_SS_CTRL4_M0},
4802 {0x0012, CMN_PLL0_SS_CTRL4_M1},
4803 {0x0012, CMN_PLL1_SS_CTRL4_M0},
4804 {0x0C5E, CMN_PLL0_VCOCAL_REFTIM_START},
4805 {0x0C5E, CMN_PLL1_VCOCAL_REFTIM_START},
4806 {0x0C56, CMN_PLL0_VCOCAL_PLLCNT_START},
4807 {0x0C56, CMN_PLL1_VCOCAL_PLLCNT_START},
4808 {0x00C7, CMN_PLL0_LOCK_REFCNT_START},
4809 {0x00C7, CMN_PLL1_LOCK_REFCNT_START},
4810 {0x00C7, CMN_PLL0_LOCK_PLLCNT_START},
4811 {0x00C7, CMN_PLL1_LOCK_PLLCNT_START},
4812 {0x0005, CMN_PLL0_LOCK_PLLCNT_THR},
4813 {0x0005, CMN_PLL1_LOCK_PLLCNT_THR}
4814 };
4815
4816 static const struct cdns_torrent_vals sl_pcie_100_int_ssc_cmn_vals = {
4817 .reg_pairs = sl_pcie_100_int_ssc_cmn_regs,
4818 .num_regs = ARRAY_SIZE(sl_pcie_100_int_ssc_cmn_regs),
4819 };
4820
4821 /* PCIe, 100 MHz Ref clk, no SSC & external SSC */
4822 static const struct cdns_reg_pairs pcie_100_ext_no_ssc_cmn_regs[] = {
4823 {0x0028, CMN_PDIAG_PLL1_CP_PADJ_M0},
4824 {0x001E, CMN_PLL1_DSM_FBH_OVRD_M0},
4825 {0x000C, CMN_PLL1_DSM_FBL_OVRD_M0}
4826 };
4827
4828 static const struct cdns_reg_pairs pcie_100_ext_no_ssc_rx_ln_regs[] = {
4829 {0x0019, RX_REE_TAP1_CLIP},
4830 {0x0019, RX_REE_TAP2TON_CLIP},
4831 {0x0001, RX_DIAG_ACYA}
4832 };
4833
4834 static const struct cdns_torrent_vals pcie_100_no_ssc_cmn_vals = {
4835 .reg_pairs = pcie_100_ext_no_ssc_cmn_regs,
4836 .num_regs = ARRAY_SIZE(pcie_100_ext_no_ssc_cmn_regs),
4837 };
4838
4839 static const struct cdns_torrent_vals pcie_100_no_ssc_rx_ln_vals = {
4840 .reg_pairs = pcie_100_ext_no_ssc_rx_ln_regs,
4841 .num_regs = ARRAY_SIZE(pcie_100_ext_no_ssc_rx_ln_regs),
4842 };
4843
4844 static const struct cdns_torrent_vals_entry link_cmn_vals_entries[] = {
4845 {CDNS_TORRENT_KEY_ANYCLK(TYPE_DP, TYPE_NONE), &sl_dp_link_cmn_vals},
4846 {CDNS_TORRENT_KEY_ANYCLK(TYPE_DP, TYPE_PCIE), &pcie_dp_link_cmn_vals},
4847 {CDNS_TORRENT_KEY_ANYCLK(TYPE_DP, TYPE_USB), &usb_dp_link_cmn_vals},
4848
4849 {CDNS_TORRENT_KEY_ANYCLK(TYPE_PCIE, TYPE_NONE), NULL},
4850 {CDNS_TORRENT_KEY_ANYCLK(TYPE_PCIE, TYPE_PCIE), &ml_pcie_link_cmn_vals},
4851 {CDNS_TORRENT_KEY_ANYCLK(TYPE_PCIE, TYPE_SGMII), &pcie_sgmii_link_cmn_vals},
4852 {CDNS_TORRENT_KEY_ANYCLK(TYPE_PCIE, TYPE_QSGMII), &pcie_sgmii_link_cmn_vals},
4853 {CDNS_TORRENT_KEY_ANYCLK(TYPE_PCIE, TYPE_USB), &pcie_usb_link_cmn_vals},
4854 {CDNS_TORRENT_KEY_ANYCLK(TYPE_PCIE, TYPE_DP), &pcie_dp_link_cmn_vals},
4855 {CDNS_TORRENT_KEY_ANYCLK(TYPE_PCIE, TYPE_USXGMII), &pcie_usxgmii_link_cmn_vals},
4856
4857 {CDNS_TORRENT_KEY_ANYCLK(TYPE_PCIE_ML, TYPE_USB), &ml_pcie_usb_link_cmn_vals},
4858
4859 {CDNS_TORRENT_KEY_ANYCLK(TYPE_SGMII, TYPE_NONE), &sl_sgmii_link_cmn_vals},
4860 {CDNS_TORRENT_KEY_ANYCLK(TYPE_SGMII, TYPE_PCIE), &pcie_sgmii_link_cmn_vals},
4861 {CDNS_TORRENT_KEY_ANYCLK(TYPE_SGMII, TYPE_QSGMII), &sgmii_qsgmii_link_cmn_vals},
4862 {CDNS_TORRENT_KEY_ANYCLK(TYPE_SGMII, TYPE_USB), &usb_sgmii_link_cmn_vals},
4863 {CDNS_TORRENT_KEY_ANYCLK(TYPE_SGMII, TYPE_USXGMII), &usxgmii_sgmii_link_cmn_vals},
4864
4865 {CDNS_TORRENT_KEY_ANYCLK(TYPE_QSGMII, TYPE_NONE), &sl_sgmii_link_cmn_vals},
4866 {CDNS_TORRENT_KEY_ANYCLK(TYPE_QSGMII, TYPE_PCIE), &pcie_sgmii_link_cmn_vals},
4867 {CDNS_TORRENT_KEY_ANYCLK(TYPE_QSGMII, TYPE_SGMII), &sgmii_qsgmii_link_cmn_vals},
4868 {CDNS_TORRENT_KEY_ANYCLK(TYPE_QSGMII, TYPE_USB), &usb_sgmii_link_cmn_vals},
4869 {CDNS_TORRENT_KEY_ANYCLK(TYPE_QSGMII, TYPE_USXGMII), &usxgmii_sgmii_link_cmn_vals},
4870
4871 {CDNS_TORRENT_KEY_ANYCLK(TYPE_USB, TYPE_NONE), &sl_usb_link_cmn_vals},
4872 {CDNS_TORRENT_KEY_ANYCLK(TYPE_USB, TYPE_PCIE), &pcie_usb_link_cmn_vals},
4873 {CDNS_TORRENT_KEY_ANYCLK(TYPE_USB, TYPE_PCIE_ML), &ml_pcie_usb_link_cmn_vals},
4874 {CDNS_TORRENT_KEY_ANYCLK(TYPE_USB, TYPE_SGMII), &usb_sgmii_link_cmn_vals},
4875 {CDNS_TORRENT_KEY_ANYCLK(TYPE_USB, TYPE_QSGMII), &usb_sgmii_link_cmn_vals},
4876 {CDNS_TORRENT_KEY_ANYCLK(TYPE_USB, TYPE_DP), &usb_dp_link_cmn_vals},
4877
4878 {CDNS_TORRENT_KEY_ANYCLK(TYPE_USXGMII, TYPE_NONE), &sl_usxgmii_link_cmn_vals},
4879 {CDNS_TORRENT_KEY_ANYCLK(TYPE_USXGMII, TYPE_PCIE), &pcie_usxgmii_link_cmn_vals},
4880 {CDNS_TORRENT_KEY_ANYCLK(TYPE_USXGMII, TYPE_SGMII), &usxgmii_sgmii_link_cmn_vals},
4881 {CDNS_TORRENT_KEY_ANYCLK(TYPE_USXGMII, TYPE_QSGMII), &usxgmii_sgmii_link_cmn_vals},
4882 };
4883
4884 static const struct cdns_torrent_vals_entry xcvr_diag_vals_entries[] = {
4885 {CDNS_TORRENT_KEY_ANYCLK(TYPE_DP, TYPE_NONE), &sl_dp_xcvr_diag_ln_vals},
4886 {CDNS_TORRENT_KEY_ANYCLK(TYPE_DP, TYPE_PCIE), &dp_pcie_xcvr_diag_ln_vals},
4887 {CDNS_TORRENT_KEY_ANYCLK(TYPE_DP, TYPE_USB), &dp_usb_xcvr_diag_ln_vals},
4888
4889 {CDNS_TORRENT_KEY_ANYCLK(TYPE_PCIE, TYPE_NONE), NULL},
4890 {CDNS_TORRENT_KEY_ANYCLK(TYPE_PCIE, TYPE_PCIE), &ml_pcie_xcvr_diag_ln_vals},
4891 {CDNS_TORRENT_KEY_ANYCLK(TYPE_PCIE, TYPE_SGMII), &pcie_sgmii_xcvr_diag_ln_vals},
4892 {CDNS_TORRENT_KEY_ANYCLK(TYPE_PCIE, TYPE_QSGMII), &pcie_sgmii_xcvr_diag_ln_vals},
4893 {CDNS_TORRENT_KEY_ANYCLK(TYPE_PCIE, TYPE_USB), &pcie_usb_xcvr_diag_ln_vals},
4894 {CDNS_TORRENT_KEY_ANYCLK(TYPE_PCIE, TYPE_DP), &pcie_dp_xcvr_diag_ln_vals},
4895 {CDNS_TORRENT_KEY_ANYCLK(TYPE_PCIE, TYPE_USXGMII), &pcie_usxgmii_xcvr_diag_ln_vals},
4896
4897 {CDNS_TORRENT_KEY_ANYCLK(TYPE_PCIE_ML, TYPE_USB), &ml_pcie_usb_xcvr_diag_ln_vals},
4898
4899 {CDNS_TORRENT_KEY_ANYCLK(TYPE_SGMII, TYPE_NONE), &sl_sgmii_xcvr_diag_ln_vals},
4900 {CDNS_TORRENT_KEY_ANYCLK(TYPE_SGMII, TYPE_PCIE), &sgmii_pcie_xcvr_diag_ln_vals},
4901 {CDNS_TORRENT_KEY_ANYCLK(TYPE_SGMII, TYPE_QSGMII), &sgmii_qsgmii_xcvr_diag_ln_vals},
4902 {CDNS_TORRENT_KEY_ANYCLK(TYPE_SGMII, TYPE_USB), &sgmii_usb_xcvr_diag_ln_vals},
4903 {CDNS_TORRENT_KEY_ANYCLK(TYPE_SGMII, TYPE_USXGMII), &sgmii_usxgmii_xcvr_diag_ln_vals},
4904
4905 {CDNS_TORRENT_KEY_ANYCLK(TYPE_QSGMII, TYPE_NONE), &sl_sgmii_xcvr_diag_ln_vals},
4906 {CDNS_TORRENT_KEY_ANYCLK(TYPE_QSGMII, TYPE_PCIE), &sgmii_pcie_xcvr_diag_ln_vals},
4907 {CDNS_TORRENT_KEY_ANYCLK(TYPE_QSGMII, TYPE_SGMII), &sgmii_qsgmii_xcvr_diag_ln_vals},
4908 {CDNS_TORRENT_KEY_ANYCLK(TYPE_QSGMII, TYPE_USB), &sgmii_usb_xcvr_diag_ln_vals},
4909 {CDNS_TORRENT_KEY_ANYCLK(TYPE_QSGMII, TYPE_USXGMII), &sgmii_usxgmii_xcvr_diag_ln_vals},
4910
4911 {CDNS_TORRENT_KEY_ANYCLK(TYPE_USB, TYPE_NONE), &sl_usb_xcvr_diag_ln_vals},
4912 {CDNS_TORRENT_KEY_ANYCLK(TYPE_USB, TYPE_PCIE), &usb_pcie_xcvr_diag_ln_vals},
4913 {CDNS_TORRENT_KEY_ANYCLK(TYPE_USB, TYPE_PCIE_ML), &usb_ml_pcie_xcvr_diag_ln_vals},
4914 {CDNS_TORRENT_KEY_ANYCLK(TYPE_USB, TYPE_SGMII), &usb_sgmii_xcvr_diag_ln_vals},
4915 {CDNS_TORRENT_KEY_ANYCLK(TYPE_USB, TYPE_QSGMII), &usb_sgmii_xcvr_diag_ln_vals},
4916 {CDNS_TORRENT_KEY_ANYCLK(TYPE_USB, TYPE_DP), &usb_dp_xcvr_diag_ln_vals},
4917
4918 {CDNS_TORRENT_KEY_ANYCLK(TYPE_USXGMII, TYPE_NONE), &sl_usxgmii_xcvr_diag_ln_vals},
4919 {CDNS_TORRENT_KEY_ANYCLK(TYPE_USXGMII, TYPE_PCIE), &usxgmii_pcie_xcvr_diag_ln_vals},
4920 {CDNS_TORRENT_KEY_ANYCLK(TYPE_USXGMII, TYPE_SGMII), &usxgmii_sgmii_xcvr_diag_ln_vals},
4921 {CDNS_TORRENT_KEY_ANYCLK(TYPE_USXGMII, TYPE_QSGMII), &usxgmii_sgmii_xcvr_diag_ln_vals},
4922 };
4923
4924 static const struct cdns_torrent_vals_entry pcs_cmn_vals_entries[] = {
4925 {CDNS_TORRENT_KEY_ANYCLK(TYPE_USB, TYPE_NONE), &usb_phy_pcs_cmn_vals},
4926 {CDNS_TORRENT_KEY_ANYCLK(TYPE_USB, TYPE_PCIE), &usb_phy_pcs_cmn_vals},
4927 {CDNS_TORRENT_KEY_ANYCLK(TYPE_USB, TYPE_PCIE_ML), &usb_phy_pcs_cmn_vals},
4928 {CDNS_TORRENT_KEY_ANYCLK(TYPE_USB, TYPE_SGMII), &usb_phy_pcs_cmn_vals},
4929 {CDNS_TORRENT_KEY_ANYCLK(TYPE_USB, TYPE_QSGMII), &usb_phy_pcs_cmn_vals},
4930 {CDNS_TORRENT_KEY_ANYCLK(TYPE_USB, TYPE_DP), &usb_phy_pcs_cmn_vals},
4931 };
4932
4933 static const struct cdns_torrent_vals_entry cmn_vals_entries[] = {
4934 {CDNS_TORRENT_KEY(CLK_19_2_MHZ, CLK_19_2_MHZ, TYPE_DP, TYPE_NONE, NO_SSC), &sl_dp_19_2_no_ssc_cmn_vals},
4935 {CDNS_TORRENT_KEY(CLK_25_MHZ, CLK_25_MHZ, TYPE_DP, TYPE_NONE, NO_SSC), &sl_dp_25_no_ssc_cmn_vals},
4936
4937 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_DP, TYPE_NONE, NO_SSC), &sl_dp_100_no_ssc_cmn_vals},
4938 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_DP, TYPE_PCIE, NO_SSC), &dp_100_no_ssc_cmn_vals},
4939 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_DP, TYPE_USB, NO_SSC), &sl_dp_100_no_ssc_cmn_vals},
4940
4941 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_NONE, NO_SSC), NULL},
4942 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_NONE, EXTERNAL_SSC), NULL},
4943 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_NONE, INTERNAL_SSC), &sl_pcie_100_int_ssc_cmn_vals},
4944
4945 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_PCIE, NO_SSC), &ml_pcie_100_no_ssc_cmn_vals},
4946 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_PCIE, EXTERNAL_SSC), &ml_pcie_100_no_ssc_cmn_vals},
4947 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_PCIE, INTERNAL_SSC), &ml_pcie_100_int_ssc_cmn_vals},
4948
4949 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_SGMII, NO_SSC), &pcie_100_no_ssc_cmn_vals},
4950 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_SGMII, EXTERNAL_SSC), &pcie_100_no_ssc_cmn_vals},
4951 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_SGMII, INTERNAL_SSC), &pcie_100_int_ssc_cmn_vals},
4952
4953 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_QSGMII, NO_SSC), &pcie_100_no_ssc_cmn_vals},
4954 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_QSGMII, EXTERNAL_SSC), &pcie_100_no_ssc_cmn_vals},
4955 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_QSGMII, INTERNAL_SSC), &pcie_100_int_ssc_cmn_vals},
4956
4957 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_USB, NO_SSC), &pcie_100_no_ssc_cmn_vals},
4958 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_USB, EXTERNAL_SSC), &pcie_100_no_ssc_cmn_vals},
4959 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_USB, INTERNAL_SSC), &pcie_100_int_ssc_cmn_vals},
4960
4961 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_DP, NO_SSC), NULL},
4962
4963 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE_ML, TYPE_USB, NO_SSC), &ml_pcie_100_no_ssc_cmn_vals},
4964 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE_ML, TYPE_USB, EXTERNAL_SSC), &ml_pcie_100_no_ssc_cmn_vals},
4965 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE_ML, TYPE_USB, INTERNAL_SSC), &ml_pcie_100_int_ssc_cmn_vals},
4966
4967 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_NONE, NO_SSC), &sl_sgmii_100_no_ssc_cmn_vals},
4968
4969 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_PCIE, NO_SSC), &sgmii_100_no_ssc_cmn_vals},
4970 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_PCIE, EXTERNAL_SSC), &sgmii_100_no_ssc_cmn_vals},
4971 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_PCIE, INTERNAL_SSC), &sgmii_100_int_ssc_cmn_vals},
4972
4973 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_QSGMII, NO_SSC), &sl_sgmii_100_no_ssc_cmn_vals},
4974
4975 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_USB, NO_SSC), &sgmii_100_no_ssc_cmn_vals},
4976 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_USB, EXTERNAL_SSC), &sgmii_100_no_ssc_cmn_vals},
4977 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_USB, INTERNAL_SSC), &sgmii_100_no_ssc_cmn_vals},
4978
4979 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_NONE, NO_SSC), &sl_qsgmii_100_no_ssc_cmn_vals},
4980
4981 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_PCIE, NO_SSC), &qsgmii_100_no_ssc_cmn_vals},
4982 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_PCIE, EXTERNAL_SSC), &qsgmii_100_no_ssc_cmn_vals},
4983 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_PCIE, INTERNAL_SSC), &qsgmii_100_int_ssc_cmn_vals},
4984
4985 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_SGMII, NO_SSC), &sl_qsgmii_100_no_ssc_cmn_vals},
4986
4987 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_USB, NO_SSC), &qsgmii_100_no_ssc_cmn_vals},
4988 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_USB, EXTERNAL_SSC), &qsgmii_100_no_ssc_cmn_vals},
4989 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_USB, INTERNAL_SSC), &qsgmii_100_no_ssc_cmn_vals},
4990
4991 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_NONE, NO_SSC), &sl_usb_100_no_ssc_cmn_vals},
4992 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_NONE, EXTERNAL_SSC), &sl_usb_100_no_ssc_cmn_vals},
4993 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_NONE, INTERNAL_SSC), &sl_usb_100_int_ssc_cmn_vals},
4994
4995 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_PCIE, NO_SSC), &usb_100_no_ssc_cmn_vals},
4996 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_PCIE, EXTERNAL_SSC), &usb_100_no_ssc_cmn_vals},
4997 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_PCIE, INTERNAL_SSC), &usb_100_int_ssc_cmn_vals},
4998
4999 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_PCIE_ML, NO_SSC), &usb_100_no_ssc_cmn_vals},
5000 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_PCIE_ML, EXTERNAL_SSC), &usb_100_no_ssc_cmn_vals},
5001 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_PCIE_ML, INTERNAL_SSC), &usb_100_no_ssc_cmn_vals},
5002
5003 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_SGMII, NO_SSC), &sl_usb_100_no_ssc_cmn_vals},
5004 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_SGMII, EXTERNAL_SSC), &sl_usb_100_no_ssc_cmn_vals},
5005 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_SGMII, INTERNAL_SSC), &sl_usb_100_int_ssc_cmn_vals},
5006
5007 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_QSGMII, NO_SSC), &sl_usb_100_no_ssc_cmn_vals},
5008 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_QSGMII, EXTERNAL_SSC), &sl_usb_100_no_ssc_cmn_vals},
5009 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_QSGMII, INTERNAL_SSC), &sl_usb_100_int_ssc_cmn_vals},
5010
5011 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_DP, NO_SSC), &usb_100_no_ssc_cmn_vals},
5012
5013 {CDNS_TORRENT_KEY(CLK_156_25_MHZ, CLK_156_25_MHZ, TYPE_USXGMII, TYPE_NONE, NO_SSC), &sl_usxgmii_156_25_no_ssc_cmn_vals},
5014
5015 /* Dual refclk */
5016 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_156_25_MHZ, TYPE_PCIE, TYPE_USXGMII, NO_SSC), NULL},
5017
5018 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_156_25_MHZ, TYPE_SGMII, TYPE_USXGMII, NO_SSC), &ml_sgmii_pll1_100_no_ssc_cmn_vals},
5019
5020 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_156_25_MHZ, TYPE_QSGMII, TYPE_USXGMII, NO_SSC), &ml_sgmii_pll1_100_no_ssc_cmn_vals},
5021
5022 {CDNS_TORRENT_KEY(CLK_156_25_MHZ, CLK_100_MHZ, TYPE_USXGMII, TYPE_PCIE, NO_SSC), &ml_usxgmii_pll1_156_25_no_ssc_cmn_vals},
5023 {CDNS_TORRENT_KEY(CLK_156_25_MHZ, CLK_100_MHZ, TYPE_USXGMII, TYPE_SGMII, NO_SSC), &ml_usxgmii_pll0_156_25_no_ssc_cmn_vals},
5024 {CDNS_TORRENT_KEY(CLK_156_25_MHZ, CLK_100_MHZ, TYPE_USXGMII, TYPE_QSGMII, NO_SSC), &ml_usxgmii_pll0_156_25_no_ssc_cmn_vals},
5025 };
5026
5027 static const struct cdns_torrent_vals_entry cdns_tx_ln_vals_entries[] = {
5028 {CDNS_TORRENT_KEY(CLK_19_2_MHZ, CLK_19_2_MHZ, TYPE_DP, TYPE_NONE, NO_SSC), &sl_dp_19_2_no_ssc_tx_ln_vals},
5029 {CDNS_TORRENT_KEY(CLK_25_MHZ, CLK_25_MHZ, TYPE_DP, TYPE_NONE, NO_SSC), &sl_dp_25_no_ssc_tx_ln_vals},
5030
5031 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_DP, TYPE_NONE, NO_SSC), &sl_dp_100_no_ssc_tx_ln_vals},
5032 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_DP, TYPE_PCIE, NO_SSC), &dp_100_no_ssc_tx_ln_vals},
5033 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_DP, TYPE_USB, NO_SSC), &dp_100_no_ssc_tx_ln_vals},
5034
5035 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_NONE, NO_SSC), NULL},
5036 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_NONE, EXTERNAL_SSC), NULL},
5037 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_NONE, INTERNAL_SSC), NULL},
5038
5039 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_PCIE, NO_SSC), NULL},
5040 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_PCIE, EXTERNAL_SSC), NULL},
5041 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_PCIE, INTERNAL_SSC), NULL},
5042
5043 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_SGMII, NO_SSC), NULL},
5044 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_SGMII, EXTERNAL_SSC), NULL},
5045 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_SGMII, INTERNAL_SSC), NULL},
5046
5047 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_QSGMII, NO_SSC), NULL},
5048 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_QSGMII, EXTERNAL_SSC), NULL},
5049 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_QSGMII, INTERNAL_SSC), NULL},
5050
5051 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_USB, NO_SSC), NULL},
5052 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_USB, EXTERNAL_SSC), NULL},
5053 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_USB, INTERNAL_SSC), NULL},
5054
5055 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_DP, NO_SSC), NULL},
5056
5057 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE_ML, TYPE_USB, NO_SSC), NULL},
5058 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE_ML, TYPE_USB, EXTERNAL_SSC), NULL},
5059 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE_ML, TYPE_USB, INTERNAL_SSC), NULL},
5060
5061 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_NONE, NO_SSC), &sgmii_100_no_ssc_tx_ln_vals},
5062
5063 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_PCIE, NO_SSC), &sgmii_100_no_ssc_tx_ln_vals},
5064 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_PCIE, EXTERNAL_SSC), &sgmii_100_no_ssc_tx_ln_vals},
5065 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_PCIE, INTERNAL_SSC), &sgmii_100_no_ssc_tx_ln_vals},
5066
5067 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_QSGMII, NO_SSC), &sgmii_100_no_ssc_tx_ln_vals},
5068
5069 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_USB, NO_SSC), &sgmii_100_no_ssc_tx_ln_vals},
5070 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_USB, EXTERNAL_SSC), &sgmii_100_no_ssc_tx_ln_vals},
5071 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_USB, INTERNAL_SSC), &sgmii_100_no_ssc_tx_ln_vals},
5072
5073 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_NONE, NO_SSC), &qsgmii_100_no_ssc_tx_ln_vals},
5074
5075 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_PCIE, NO_SSC), &qsgmii_100_no_ssc_tx_ln_vals},
5076 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_PCIE, EXTERNAL_SSC), &qsgmii_100_no_ssc_tx_ln_vals},
5077 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_PCIE, INTERNAL_SSC), &qsgmii_100_no_ssc_tx_ln_vals},
5078
5079 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_SGMII, NO_SSC), &qsgmii_100_no_ssc_tx_ln_vals},
5080
5081 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_USB, NO_SSC), &qsgmii_100_no_ssc_tx_ln_vals},
5082 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_USB, EXTERNAL_SSC), &qsgmii_100_no_ssc_tx_ln_vals},
5083 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_USB, INTERNAL_SSC), &qsgmii_100_no_ssc_tx_ln_vals},
5084
5085 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_NONE, NO_SSC), &usb_100_no_ssc_tx_ln_vals},
5086 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_NONE, EXTERNAL_SSC), &usb_100_no_ssc_tx_ln_vals},
5087 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_NONE, INTERNAL_SSC), &usb_100_no_ssc_tx_ln_vals},
5088
5089 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_PCIE, NO_SSC), &usb_100_no_ssc_tx_ln_vals},
5090 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_PCIE, EXTERNAL_SSC), &usb_100_no_ssc_tx_ln_vals},
5091 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_PCIE, INTERNAL_SSC), &usb_100_no_ssc_tx_ln_vals},
5092
5093 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_PCIE_ML, NO_SSC), &usb_100_no_ssc_tx_ln_vals},
5094 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_PCIE_ML, EXTERNAL_SSC), &usb_100_no_ssc_tx_ln_vals},
5095 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_PCIE_ML, INTERNAL_SSC), &usb_100_no_ssc_tx_ln_vals},
5096
5097 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_SGMII, NO_SSC), &usb_100_no_ssc_tx_ln_vals},
5098 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_SGMII, EXTERNAL_SSC), &usb_100_no_ssc_tx_ln_vals},
5099 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_SGMII, INTERNAL_SSC), &usb_100_no_ssc_tx_ln_vals},
5100
5101 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_QSGMII, NO_SSC), &usb_100_no_ssc_tx_ln_vals},
5102 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_QSGMII, EXTERNAL_SSC), &usb_100_no_ssc_tx_ln_vals},
5103 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_QSGMII, INTERNAL_SSC), &usb_100_no_ssc_tx_ln_vals},
5104
5105 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_DP, NO_SSC), &usb_100_no_ssc_tx_ln_vals},
5106
5107 {CDNS_TORRENT_KEY(CLK_156_25_MHZ, CLK_156_25_MHZ, TYPE_USXGMII, TYPE_NONE, NO_SSC), &usxgmii_156_25_no_ssc_tx_ln_vals},
5108
5109 /* Dual refclk */
5110 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_156_25_MHZ, TYPE_PCIE, TYPE_USXGMII, NO_SSC), NULL},
5111
5112 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_156_25_MHZ, TYPE_SGMII, TYPE_USXGMII, NO_SSC), &sgmii_100_no_ssc_tx_ln_vals},
5113
5114 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_156_25_MHZ, TYPE_QSGMII, TYPE_USXGMII, NO_SSC), &qsgmii_100_no_ssc_tx_ln_vals},
5115
5116 {CDNS_TORRENT_KEY(CLK_156_25_MHZ, CLK_100_MHZ, TYPE_USXGMII, TYPE_PCIE, NO_SSC), &ml_usxgmii_156_25_no_ssc_tx_ln_vals},
5117 {CDNS_TORRENT_KEY(CLK_156_25_MHZ, CLK_100_MHZ, TYPE_USXGMII, TYPE_SGMII, NO_SSC), &ml_usxgmii_156_25_no_ssc_tx_ln_vals},
5118 {CDNS_TORRENT_KEY(CLK_156_25_MHZ, CLK_100_MHZ, TYPE_USXGMII, TYPE_QSGMII, NO_SSC), &ml_usxgmii_156_25_no_ssc_tx_ln_vals},
5119 };
5120
5121 static const struct cdns_torrent_vals_entry cdns_rx_ln_vals_entries[] = {
5122 {CDNS_TORRENT_KEY(CLK_19_2_MHZ, CLK_19_2_MHZ, TYPE_DP, TYPE_NONE, NO_SSC), &sl_dp_19_2_no_ssc_rx_ln_vals},
5123 {CDNS_TORRENT_KEY(CLK_25_MHZ, CLK_25_MHZ, TYPE_DP, TYPE_NONE, NO_SSC), &sl_dp_25_no_ssc_rx_ln_vals},
5124
5125 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_DP, TYPE_NONE, NO_SSC), &sl_dp_100_no_ssc_rx_ln_vals},
5126 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_DP, TYPE_PCIE, NO_SSC), &dp_100_no_ssc_rx_ln_vals},
5127 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_DP, TYPE_USB, NO_SSC), &dp_100_no_ssc_rx_ln_vals},
5128
5129 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_NONE, NO_SSC), &pcie_100_no_ssc_rx_ln_vals},
5130 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_NONE, EXTERNAL_SSC), &pcie_100_no_ssc_rx_ln_vals},
5131 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_NONE, INTERNAL_SSC), &pcie_100_no_ssc_rx_ln_vals},
5132
5133 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_PCIE, NO_SSC), &ml_pcie_100_no_ssc_rx_ln_vals},
5134 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_PCIE, EXTERNAL_SSC), &ml_pcie_100_no_ssc_rx_ln_vals},
5135 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_PCIE, INTERNAL_SSC), &ml_pcie_100_no_ssc_rx_ln_vals},
5136
5137 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_SGMII, NO_SSC), &pcie_100_no_ssc_rx_ln_vals},
5138 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_SGMII, EXTERNAL_SSC), &pcie_100_no_ssc_rx_ln_vals},
5139 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_SGMII, INTERNAL_SSC), &pcie_100_no_ssc_rx_ln_vals},
5140
5141 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_QSGMII, NO_SSC), &pcie_100_no_ssc_rx_ln_vals},
5142 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_QSGMII, EXTERNAL_SSC), &pcie_100_no_ssc_rx_ln_vals},
5143 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_QSGMII, INTERNAL_SSC), &pcie_100_no_ssc_rx_ln_vals},
5144
5145 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_USB, NO_SSC), &pcie_100_no_ssc_rx_ln_vals},
5146 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_USB, EXTERNAL_SSC), &pcie_100_no_ssc_rx_ln_vals},
5147 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_USB, INTERNAL_SSC), &pcie_100_no_ssc_rx_ln_vals},
5148
5149 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_DP, NO_SSC), &pcie_100_no_ssc_rx_ln_vals},
5150
5151 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE_ML, TYPE_USB, NO_SSC), &ml_pcie_100_no_ssc_rx_ln_vals},
5152 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE_ML, TYPE_USB, EXTERNAL_SSC), &ml_pcie_100_no_ssc_rx_ln_vals},
5153 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE_ML, TYPE_USB, INTERNAL_SSC), &ml_pcie_100_no_ssc_rx_ln_vals},
5154
5155 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_NONE, NO_SSC), &sgmii_100_no_ssc_rx_ln_vals},
5156
5157 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_PCIE, NO_SSC), &sgmii_100_no_ssc_rx_ln_vals},
5158 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_PCIE, EXTERNAL_SSC), &sgmii_100_no_ssc_rx_ln_vals},
5159 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_PCIE, INTERNAL_SSC), &sgmii_100_no_ssc_rx_ln_vals},
5160
5161 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_QSGMII, NO_SSC), &sgmii_100_no_ssc_rx_ln_vals},
5162
5163 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_USB, NO_SSC), &sgmii_100_no_ssc_rx_ln_vals},
5164 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_USB, EXTERNAL_SSC), &sgmii_100_no_ssc_rx_ln_vals},
5165 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_USB, INTERNAL_SSC), &sgmii_100_no_ssc_rx_ln_vals},
5166
5167 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_NONE, NO_SSC), &qsgmii_100_no_ssc_rx_ln_vals},
5168
5169 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_PCIE, NO_SSC), &qsgmii_100_no_ssc_rx_ln_vals},
5170 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_PCIE, EXTERNAL_SSC), &qsgmii_100_no_ssc_rx_ln_vals},
5171 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_PCIE, INTERNAL_SSC), &qsgmii_100_no_ssc_rx_ln_vals},
5172
5173 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_SGMII, NO_SSC), &qsgmii_100_no_ssc_rx_ln_vals},
5174
5175 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_USB, NO_SSC), &qsgmii_100_no_ssc_rx_ln_vals},
5176 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_USB, EXTERNAL_SSC), &qsgmii_100_no_ssc_rx_ln_vals},
5177 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_USB, INTERNAL_SSC), &qsgmii_100_no_ssc_rx_ln_vals},
5178
5179 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_NONE, NO_SSC), &usb_100_no_ssc_rx_ln_vals},
5180 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_NONE, EXTERNAL_SSC), &usb_100_no_ssc_rx_ln_vals},
5181 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_NONE, INTERNAL_SSC), &usb_100_no_ssc_rx_ln_vals},
5182
5183 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_PCIE, NO_SSC), &usb_100_no_ssc_rx_ln_vals},
5184 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_PCIE, EXTERNAL_SSC), &usb_100_no_ssc_rx_ln_vals},
5185 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_PCIE, INTERNAL_SSC), &usb_100_no_ssc_rx_ln_vals},
5186
5187 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_PCIE_ML, NO_SSC), &usb_100_no_ssc_rx_ln_vals},
5188 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_PCIE_ML, EXTERNAL_SSC), &usb_100_no_ssc_rx_ln_vals},
5189 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_PCIE_ML, INTERNAL_SSC), &usb_100_no_ssc_rx_ln_vals},
5190
5191 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_SGMII, NO_SSC), &usb_100_no_ssc_rx_ln_vals},
5192 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_SGMII, EXTERNAL_SSC), &usb_100_no_ssc_rx_ln_vals},
5193 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_SGMII, INTERNAL_SSC), &usb_100_no_ssc_rx_ln_vals},
5194
5195 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_QSGMII, NO_SSC), &usb_100_no_ssc_rx_ln_vals},
5196 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_QSGMII, EXTERNAL_SSC), &usb_100_no_ssc_rx_ln_vals},
5197 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_QSGMII, INTERNAL_SSC), &usb_100_no_ssc_rx_ln_vals},
5198
5199 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_DP, NO_SSC), &usb_100_no_ssc_rx_ln_vals},
5200
5201 {CDNS_TORRENT_KEY(CLK_156_25_MHZ, CLK_156_25_MHZ, TYPE_USXGMII, TYPE_NONE, NO_SSC), &usxgmii_156_25_no_ssc_rx_ln_vals},
5202
5203 /* Dual refclk */
5204 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_156_25_MHZ, TYPE_PCIE, TYPE_USXGMII, NO_SSC), &pcie_100_no_ssc_rx_ln_vals},
5205
5206 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_156_25_MHZ, TYPE_SGMII, TYPE_USXGMII, NO_SSC), &sgmii_100_no_ssc_rx_ln_vals},
5207
5208 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_156_25_MHZ, TYPE_QSGMII, TYPE_USXGMII, NO_SSC), &qsgmii_100_no_ssc_rx_ln_vals},
5209
5210 {CDNS_TORRENT_KEY(CLK_156_25_MHZ, CLK_100_MHZ, TYPE_USXGMII, TYPE_PCIE, NO_SSC), &ml_usxgmii_156_25_no_ssc_rx_ln_vals},
5211 {CDNS_TORRENT_KEY(CLK_156_25_MHZ, CLK_100_MHZ, TYPE_USXGMII, TYPE_SGMII, NO_SSC), &ml_usxgmii_156_25_no_ssc_rx_ln_vals},
5212 {CDNS_TORRENT_KEY(CLK_156_25_MHZ, CLK_100_MHZ, TYPE_USXGMII, TYPE_QSGMII, NO_SSC), &ml_usxgmii_156_25_no_ssc_rx_ln_vals},
5213 };
5214
5215 static const struct cdns_torrent_data cdns_map_torrent = {
5216 .block_offset_shift = 0x2,
5217 .reg_offset_shift = 0x2,
5218 .link_cmn_vals_tbl = {
5219 .entries = link_cmn_vals_entries,
5220 .num_entries = ARRAY_SIZE(link_cmn_vals_entries),
5221 },
5222 .xcvr_diag_vals_tbl = {
5223 .entries = xcvr_diag_vals_entries,
5224 .num_entries = ARRAY_SIZE(xcvr_diag_vals_entries),
5225 },
5226 .pcs_cmn_vals_tbl = {
5227 .entries = pcs_cmn_vals_entries,
5228 .num_entries = ARRAY_SIZE(pcs_cmn_vals_entries),
5229 },
5230 .cmn_vals_tbl = {
5231 .entries = cmn_vals_entries,
5232 .num_entries = ARRAY_SIZE(cmn_vals_entries),
5233 },
5234 .tx_ln_vals_tbl = {
5235 .entries = cdns_tx_ln_vals_entries,
5236 .num_entries = ARRAY_SIZE(cdns_tx_ln_vals_entries),
5237 },
5238 .rx_ln_vals_tbl = {
5239 .entries = cdns_rx_ln_vals_entries,
5240 .num_entries = ARRAY_SIZE(cdns_rx_ln_vals_entries),
5241 },
5242 };
5243
5244 static const struct cdns_torrent_vals_entry j721e_phy_pma_cmn_vals_entries[] = {
5245 {CDNS_TORRENT_KEY_ANYCLK(TYPE_USXGMII, TYPE_NONE), &ti_usxgmii_phy_pma_cmn_vals},
5246 {CDNS_TORRENT_KEY_ANYCLK(TYPE_USXGMII, TYPE_PCIE), &ti_usxgmii_phy_pma_cmn_vals},
5247 {CDNS_TORRENT_KEY_ANYCLK(TYPE_USXGMII, TYPE_SGMII), &ti_usxgmii_phy_pma_cmn_vals},
5248 {CDNS_TORRENT_KEY_ANYCLK(TYPE_USXGMII, TYPE_QSGMII), &ti_usxgmii_phy_pma_cmn_vals},
5249 };
5250
5251 static const struct cdns_torrent_vals_entry ti_tx_ln_vals_entries[] = {
5252 {CDNS_TORRENT_KEY(CLK_19_2_MHZ, CLK_19_2_MHZ, TYPE_DP, TYPE_NONE, NO_SSC), &sl_dp_19_2_no_ssc_tx_ln_vals},
5253 {CDNS_TORRENT_KEY(CLK_25_MHZ, CLK_25_MHZ, TYPE_DP, TYPE_NONE, NO_SSC), &sl_dp_25_no_ssc_tx_ln_vals},
5254
5255 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_DP, TYPE_NONE, NO_SSC), &sl_dp_100_no_ssc_tx_ln_vals},
5256 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_DP, TYPE_PCIE, NO_SSC), &dp_100_no_ssc_tx_ln_vals},
5257 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_DP, TYPE_USB, NO_SSC), &dp_100_no_ssc_tx_ln_vals},
5258
5259 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_NONE, NO_SSC), NULL},
5260 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_NONE, EXTERNAL_SSC), NULL},
5261 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_NONE, INTERNAL_SSC), NULL},
5262
5263 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_PCIE, NO_SSC), NULL},
5264 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_PCIE, EXTERNAL_SSC), NULL},
5265 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_PCIE, INTERNAL_SSC), NULL},
5266
5267 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_SGMII, NO_SSC), NULL},
5268 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_SGMII, EXTERNAL_SSC), NULL},
5269 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_SGMII, INTERNAL_SSC), NULL},
5270
5271 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_QSGMII, NO_SSC), NULL},
5272 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_QSGMII, EXTERNAL_SSC), NULL},
5273 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_QSGMII, INTERNAL_SSC), NULL},
5274
5275 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_USB, NO_SSC), NULL},
5276 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_USB, EXTERNAL_SSC), NULL},
5277 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_USB, INTERNAL_SSC), NULL},
5278
5279 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_DP, NO_SSC), NULL},
5280
5281 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE_ML, TYPE_USB, NO_SSC), NULL},
5282 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE_ML, TYPE_USB, EXTERNAL_SSC), NULL},
5283 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE_ML, TYPE_USB, INTERNAL_SSC), NULL},
5284
5285 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_NONE, NO_SSC), &ti_sgmii_100_no_ssc_tx_ln_vals},
5286
5287 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_PCIE, NO_SSC), &ti_sgmii_100_no_ssc_tx_ln_vals},
5288 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_PCIE, EXTERNAL_SSC), &ti_sgmii_100_no_ssc_tx_ln_vals},
5289 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_PCIE, INTERNAL_SSC), &ti_sgmii_100_no_ssc_tx_ln_vals},
5290
5291 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_QSGMII, NO_SSC), &ti_sgmii_100_no_ssc_tx_ln_vals},
5292
5293 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_USB, NO_SSC), &ti_sgmii_100_no_ssc_tx_ln_vals},
5294 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_USB, EXTERNAL_SSC), &ti_sgmii_100_no_ssc_tx_ln_vals},
5295 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_USB, INTERNAL_SSC), &ti_sgmii_100_no_ssc_tx_ln_vals},
5296
5297 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_NONE, NO_SSC), &ti_qsgmii_100_no_ssc_tx_ln_vals},
5298
5299 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_PCIE, NO_SSC), &ti_qsgmii_100_no_ssc_tx_ln_vals},
5300 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_PCIE, EXTERNAL_SSC), &ti_qsgmii_100_no_ssc_tx_ln_vals},
5301 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_PCIE, INTERNAL_SSC), &ti_qsgmii_100_no_ssc_tx_ln_vals},
5302
5303 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_SGMII, NO_SSC), &ti_qsgmii_100_no_ssc_tx_ln_vals},
5304
5305 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_USB, NO_SSC), &ti_qsgmii_100_no_ssc_tx_ln_vals},
5306 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_USB, EXTERNAL_SSC), &ti_qsgmii_100_no_ssc_tx_ln_vals},
5307 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_USB, INTERNAL_SSC), &ti_qsgmii_100_no_ssc_tx_ln_vals},
5308
5309 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_NONE, NO_SSC), &usb_100_no_ssc_tx_ln_vals},
5310 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_NONE, EXTERNAL_SSC), &usb_100_no_ssc_tx_ln_vals},
5311 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_NONE, INTERNAL_SSC), &usb_100_no_ssc_tx_ln_vals},
5312
5313 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_PCIE, NO_SSC), &usb_100_no_ssc_tx_ln_vals},
5314 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_PCIE, EXTERNAL_SSC), &usb_100_no_ssc_tx_ln_vals},
5315 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_PCIE, INTERNAL_SSC), &usb_100_no_ssc_tx_ln_vals},
5316
5317 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_PCIE_ML, NO_SSC), &usb_100_no_ssc_tx_ln_vals},
5318 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_PCIE_ML, EXTERNAL_SSC), &usb_100_no_ssc_tx_ln_vals},
5319 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_PCIE_ML, INTERNAL_SSC), &usb_100_no_ssc_tx_ln_vals},
5320
5321 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_SGMII, NO_SSC), &usb_100_no_ssc_tx_ln_vals},
5322 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_SGMII, EXTERNAL_SSC), &usb_100_no_ssc_tx_ln_vals},
5323 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_SGMII, INTERNAL_SSC), &usb_100_no_ssc_tx_ln_vals},
5324
5325 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_QSGMII, NO_SSC), &usb_100_no_ssc_tx_ln_vals},
5326 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_QSGMII, EXTERNAL_SSC), &usb_100_no_ssc_tx_ln_vals},
5327 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_QSGMII, INTERNAL_SSC), &usb_100_no_ssc_tx_ln_vals},
5328
5329 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_DP, NO_SSC), &usb_100_no_ssc_tx_ln_vals},
5330
5331 {CDNS_TORRENT_KEY(CLK_156_25_MHZ, CLK_156_25_MHZ, TYPE_USXGMII, TYPE_NONE, NO_SSC), &usxgmii_156_25_no_ssc_tx_ln_vals},
5332
5333 /* Dual refclk */
5334 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_156_25_MHZ, TYPE_PCIE, TYPE_USXGMII, NO_SSC), NULL},
5335
5336 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_156_25_MHZ, TYPE_SGMII, TYPE_USXGMII, NO_SSC), &ti_sgmii_100_no_ssc_tx_ln_vals},
5337
5338 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_156_25_MHZ, TYPE_QSGMII, TYPE_USXGMII, NO_SSC), &ti_qsgmii_100_no_ssc_tx_ln_vals},
5339
5340 {CDNS_TORRENT_KEY(CLK_156_25_MHZ, CLK_100_MHZ, TYPE_USXGMII, TYPE_PCIE, NO_SSC), &ml_usxgmii_156_25_no_ssc_tx_ln_vals},
5341 {CDNS_TORRENT_KEY(CLK_156_25_MHZ, CLK_100_MHZ, TYPE_USXGMII, TYPE_SGMII, NO_SSC), &ml_usxgmii_156_25_no_ssc_tx_ln_vals},
5342 {CDNS_TORRENT_KEY(CLK_156_25_MHZ, CLK_100_MHZ, TYPE_USXGMII, TYPE_QSGMII, NO_SSC), &ml_usxgmii_156_25_no_ssc_tx_ln_vals},
5343 };
5344
5345 static const struct cdns_torrent_data ti_j721e_map_torrent = {
5346 .block_offset_shift = 0x0,
5347 .reg_offset_shift = 0x1,
5348 .link_cmn_vals_tbl = {
5349 .entries = link_cmn_vals_entries,
5350 .num_entries = ARRAY_SIZE(link_cmn_vals_entries),
5351 },
5352 .xcvr_diag_vals_tbl = {
5353 .entries = xcvr_diag_vals_entries,
5354 .num_entries = ARRAY_SIZE(xcvr_diag_vals_entries),
5355 },
5356 .pcs_cmn_vals_tbl = {
5357 .entries = pcs_cmn_vals_entries,
5358 .num_entries = ARRAY_SIZE(pcs_cmn_vals_entries),
5359 },
5360 .phy_pma_cmn_vals_tbl = {
5361 .entries = j721e_phy_pma_cmn_vals_entries,
5362 .num_entries = ARRAY_SIZE(j721e_phy_pma_cmn_vals_entries),
5363 },
5364 .cmn_vals_tbl = {
5365 .entries = cmn_vals_entries,
5366 .num_entries = ARRAY_SIZE(cmn_vals_entries),
5367 },
5368 .tx_ln_vals_tbl = {
5369 .entries = ti_tx_ln_vals_entries,
5370 .num_entries = ARRAY_SIZE(ti_tx_ln_vals_entries),
5371 },
5372 .rx_ln_vals_tbl = {
5373 .entries = cdns_rx_ln_vals_entries,
5374 .num_entries = ARRAY_SIZE(cdns_rx_ln_vals_entries),
5375 },
5376 };
5377
5378 /* TI J7200 (Torrent SD0805) */
5379 static const struct cdns_torrent_vals_entry ti_j7200_cmn_vals_entries[] = {
5380 {CDNS_TORRENT_KEY(CLK_19_2_MHZ, CLK_19_2_MHZ, TYPE_DP, TYPE_NONE, NO_SSC), &sl_dp_19_2_no_ssc_cmn_vals},
5381 {CDNS_TORRENT_KEY(CLK_25_MHZ, CLK_25_MHZ, TYPE_DP, TYPE_NONE, NO_SSC), &sl_dp_25_no_ssc_cmn_vals},
5382
5383 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_DP, TYPE_NONE, NO_SSC), &sl_dp_100_no_ssc_cmn_vals},
5384 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_DP, TYPE_PCIE, NO_SSC), &dp_100_no_ssc_cmn_vals},
5385 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_DP, TYPE_USB, NO_SSC), &sl_dp_100_no_ssc_cmn_vals},
5386
5387 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_NONE, NO_SSC), NULL},
5388 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_NONE, EXTERNAL_SSC), NULL},
5389 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_NONE, INTERNAL_SSC), &sl_pcie_100_int_ssc_cmn_vals},
5390
5391 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_PCIE, NO_SSC), &ml_pcie_100_no_ssc_cmn_vals},
5392 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_PCIE, EXTERNAL_SSC), &ml_pcie_100_no_ssc_cmn_vals},
5393 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_PCIE, INTERNAL_SSC), &ml_pcie_100_int_ssc_cmn_vals},
5394
5395 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_SGMII, NO_SSC), &pcie_100_no_ssc_cmn_vals},
5396 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_SGMII, EXTERNAL_SSC), &pcie_100_no_ssc_cmn_vals},
5397 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_SGMII, INTERNAL_SSC), &pcie_100_int_ssc_cmn_vals},
5398
5399 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_QSGMII, NO_SSC), &pcie_100_no_ssc_cmn_vals},
5400 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_QSGMII, EXTERNAL_SSC), &pcie_100_no_ssc_cmn_vals},
5401 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_QSGMII, INTERNAL_SSC), &pcie_100_int_ssc_cmn_vals},
5402
5403 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_USB, NO_SSC), &pcie_100_no_ssc_cmn_vals},
5404 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_USB, EXTERNAL_SSC), &pcie_100_no_ssc_cmn_vals},
5405 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_USB, INTERNAL_SSC), &pcie_100_int_ssc_cmn_vals},
5406
5407 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_DP, NO_SSC), NULL},
5408
5409 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE_ML, TYPE_USB, NO_SSC), &ml_pcie_100_no_ssc_cmn_vals},
5410 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE_ML, TYPE_USB, EXTERNAL_SSC), &ml_pcie_100_no_ssc_cmn_vals},
5411 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE_ML, TYPE_USB, INTERNAL_SSC), &ml_pcie_100_int_ssc_cmn_vals},
5412
5413 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_NONE, NO_SSC), &sl_sgmii_100_no_ssc_cmn_vals},
5414
5415 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_PCIE, NO_SSC), &sgmii_100_no_ssc_cmn_vals},
5416 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_PCIE, EXTERNAL_SSC), &sgmii_100_no_ssc_cmn_vals},
5417 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_PCIE, INTERNAL_SSC), &sgmii_100_int_ssc_cmn_vals},
5418
5419 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_QSGMII, NO_SSC), &sl_sgmii_100_no_ssc_cmn_vals},
5420
5421 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_USB, NO_SSC), &sgmii_100_no_ssc_cmn_vals},
5422 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_USB, EXTERNAL_SSC), &sgmii_100_no_ssc_cmn_vals},
5423 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_USB, INTERNAL_SSC), &sgmii_100_no_ssc_cmn_vals},
5424
5425 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_NONE, NO_SSC), &sl_qsgmii_100_no_ssc_cmn_vals},
5426
5427 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_PCIE, NO_SSC), &qsgmii_100_no_ssc_cmn_vals},
5428 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_PCIE, EXTERNAL_SSC), &qsgmii_100_no_ssc_cmn_vals},
5429 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_PCIE, INTERNAL_SSC), &qsgmii_100_int_ssc_cmn_vals},
5430
5431 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_SGMII, NO_SSC), &sl_qsgmii_100_no_ssc_cmn_vals},
5432
5433 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_USB, NO_SSC), &qsgmii_100_no_ssc_cmn_vals},
5434 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_USB, EXTERNAL_SSC), &qsgmii_100_no_ssc_cmn_vals},
5435 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_USB, INTERNAL_SSC), &qsgmii_100_no_ssc_cmn_vals},
5436
5437 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_NONE, NO_SSC), &sl_usb_100_no_ssc_cmn_vals},
5438 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_NONE, EXTERNAL_SSC), &sl_usb_100_no_ssc_cmn_vals},
5439 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_NONE, INTERNAL_SSC), &sl_usb_100_int_ssc_cmn_vals},
5440
5441 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_PCIE, NO_SSC), &usb_100_no_ssc_cmn_vals},
5442 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_PCIE, EXTERNAL_SSC), &usb_100_no_ssc_cmn_vals},
5443 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_PCIE, INTERNAL_SSC), &usb_100_int_ssc_cmn_vals},
5444
5445 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_PCIE_ML, NO_SSC), &usb_100_no_ssc_cmn_vals},
5446 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_PCIE_ML, EXTERNAL_SSC), &usb_100_no_ssc_cmn_vals},
5447 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_PCIE_ML, INTERNAL_SSC), &usb_100_no_ssc_cmn_vals},
5448
5449 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_SGMII, NO_SSC), &sl_usb_100_no_ssc_cmn_vals},
5450 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_SGMII, EXTERNAL_SSC), &sl_usb_100_no_ssc_cmn_vals},
5451 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_SGMII, INTERNAL_SSC), &sl_usb_100_int_ssc_cmn_vals},
5452
5453 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_QSGMII, NO_SSC), &sl_usb_100_no_ssc_cmn_vals},
5454 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_QSGMII, EXTERNAL_SSC), &sl_usb_100_no_ssc_cmn_vals},
5455 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_QSGMII, INTERNAL_SSC), &sl_usb_100_int_ssc_cmn_vals},
5456
5457 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_DP, NO_SSC), &usb_100_no_ssc_cmn_vals},
5458
5459 {CDNS_TORRENT_KEY(CLK_156_25_MHZ, CLK_156_25_MHZ, TYPE_USXGMII, TYPE_NONE, NO_SSC), &sl_usxgmii_156_25_no_ssc_cmn_vals},
5460
5461 /* Dual refclk */
5462 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_156_25_MHZ, TYPE_PCIE, TYPE_USXGMII, NO_SSC), NULL},
5463
5464 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_156_25_MHZ, TYPE_SGMII, TYPE_USXGMII, NO_SSC), &j7200_ml_sgmii_pll1_100_no_ssc_cmn_vals},
5465
5466 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_156_25_MHZ, TYPE_QSGMII, TYPE_USXGMII, NO_SSC), &j7200_ml_sgmii_pll1_100_no_ssc_cmn_vals},
5467
5468 {CDNS_TORRENT_KEY(CLK_156_25_MHZ, CLK_100_MHZ, TYPE_USXGMII, TYPE_PCIE, NO_SSC), &ml_usxgmii_pll1_156_25_no_ssc_cmn_vals},
5469 {CDNS_TORRENT_KEY(CLK_156_25_MHZ, CLK_100_MHZ, TYPE_USXGMII, TYPE_SGMII, NO_SSC), &j7200_ml_usxgmii_pll0_156_25_no_ssc_cmn_vals},
5470 {CDNS_TORRENT_KEY(CLK_156_25_MHZ, CLK_100_MHZ, TYPE_USXGMII, TYPE_QSGMII, NO_SSC), &j7200_ml_usxgmii_pll0_156_25_no_ssc_cmn_vals},
5471 };
5472
5473 static const struct cdns_torrent_vals_entry ti_j7200_tx_ln_vals_entries[] = {
5474 {CDNS_TORRENT_KEY(CLK_19_2_MHZ, CLK_19_2_MHZ, TYPE_DP, TYPE_NONE, NO_SSC), &sl_dp_19_2_no_ssc_tx_ln_vals},
5475 {CDNS_TORRENT_KEY(CLK_25_MHZ, CLK_25_MHZ, TYPE_DP, TYPE_NONE, NO_SSC), &sl_dp_25_no_ssc_tx_ln_vals},
5476
5477 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_DP, TYPE_NONE, NO_SSC), &sl_dp_100_no_ssc_tx_ln_vals},
5478 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_DP, TYPE_PCIE, NO_SSC), &dp_100_no_ssc_tx_ln_vals},
5479 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_DP, TYPE_USB, NO_SSC), &dp_100_no_ssc_tx_ln_vals},
5480
5481 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_NONE, NO_SSC), NULL},
5482 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_NONE, EXTERNAL_SSC), NULL},
5483 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_NONE, INTERNAL_SSC), NULL},
5484
5485 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_PCIE, NO_SSC), NULL},
5486 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_PCIE, EXTERNAL_SSC), NULL},
5487 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_PCIE, INTERNAL_SSC), NULL},
5488
5489 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_SGMII, NO_SSC), NULL},
5490 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_SGMII, EXTERNAL_SSC), NULL},
5491 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_SGMII, INTERNAL_SSC), NULL},
5492
5493 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_QSGMII, NO_SSC), NULL},
5494 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_QSGMII, EXTERNAL_SSC), NULL},
5495 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_QSGMII, INTERNAL_SSC), NULL},
5496
5497 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_USB, NO_SSC), NULL},
5498 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_USB, EXTERNAL_SSC), NULL},
5499 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_USB, INTERNAL_SSC), NULL},
5500
5501 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_DP, NO_SSC), NULL},
5502
5503 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE_ML, TYPE_USB, NO_SSC), NULL},
5504 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE_ML, TYPE_USB, EXTERNAL_SSC), NULL},
5505 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE_ML, TYPE_USB, INTERNAL_SSC), NULL},
5506
5507 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_NONE, NO_SSC), &ti_sgmii_100_no_ssc_tx_ln_vals},
5508
5509 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_PCIE, NO_SSC), &ti_sgmii_100_no_ssc_tx_ln_vals},
5510 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_PCIE, EXTERNAL_SSC), &ti_sgmii_100_no_ssc_tx_ln_vals},
5511 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_PCIE, INTERNAL_SSC), &ti_sgmii_100_no_ssc_tx_ln_vals},
5512
5513 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_QSGMII, NO_SSC), &ti_sgmii_100_no_ssc_tx_ln_vals},
5514
5515 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_USB, NO_SSC), &ti_sgmii_100_no_ssc_tx_ln_vals},
5516 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_USB, EXTERNAL_SSC), &ti_sgmii_100_no_ssc_tx_ln_vals},
5517 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_USB, INTERNAL_SSC), &ti_sgmii_100_no_ssc_tx_ln_vals},
5518
5519 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_NONE, NO_SSC), &ti_qsgmii_100_no_ssc_tx_ln_vals},
5520
5521 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_PCIE, NO_SSC), &ti_qsgmii_100_no_ssc_tx_ln_vals},
5522 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_PCIE, EXTERNAL_SSC), &ti_qsgmii_100_no_ssc_tx_ln_vals},
5523 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_PCIE, INTERNAL_SSC), &ti_qsgmii_100_no_ssc_tx_ln_vals},
5524
5525 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_SGMII, NO_SSC), &ti_qsgmii_100_no_ssc_tx_ln_vals},
5526
5527 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_USB, NO_SSC), &ti_qsgmii_100_no_ssc_tx_ln_vals},
5528 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_USB, EXTERNAL_SSC), &ti_qsgmii_100_no_ssc_tx_ln_vals},
5529 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_USB, INTERNAL_SSC), &ti_qsgmii_100_no_ssc_tx_ln_vals},
5530
5531 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_NONE, NO_SSC), &usb_100_no_ssc_tx_ln_vals},
5532 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_NONE, EXTERNAL_SSC), &usb_100_no_ssc_tx_ln_vals},
5533 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_NONE, INTERNAL_SSC), &usb_100_no_ssc_tx_ln_vals},
5534
5535 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_PCIE, NO_SSC), &usb_100_no_ssc_tx_ln_vals},
5536 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_PCIE, EXTERNAL_SSC), &usb_100_no_ssc_tx_ln_vals},
5537 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_PCIE, INTERNAL_SSC), &usb_100_no_ssc_tx_ln_vals},
5538
5539 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_PCIE_ML, NO_SSC), &usb_100_no_ssc_tx_ln_vals},
5540 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_PCIE_ML, EXTERNAL_SSC), &usb_100_no_ssc_tx_ln_vals},
5541 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_PCIE_ML, INTERNAL_SSC), &usb_100_no_ssc_tx_ln_vals},
5542
5543 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_SGMII, NO_SSC), &usb_100_no_ssc_tx_ln_vals},
5544 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_SGMII, EXTERNAL_SSC), &usb_100_no_ssc_tx_ln_vals},
5545 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_SGMII, INTERNAL_SSC), &usb_100_no_ssc_tx_ln_vals},
5546
5547 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_QSGMII, NO_SSC), &usb_100_no_ssc_tx_ln_vals},
5548 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_QSGMII, EXTERNAL_SSC), &usb_100_no_ssc_tx_ln_vals},
5549 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_QSGMII, INTERNAL_SSC), &usb_100_no_ssc_tx_ln_vals},
5550
5551 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_DP, NO_SSC), &usb_100_no_ssc_tx_ln_vals},
5552
5553 {CDNS_TORRENT_KEY(CLK_156_25_MHZ, CLK_156_25_MHZ, TYPE_USXGMII, TYPE_NONE, NO_SSC), &usxgmii_156_25_no_ssc_tx_ln_vals},
5554
5555 /* Dual refclk */
5556 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_156_25_MHZ, TYPE_PCIE, TYPE_USXGMII, NO_SSC), NULL},
5557
5558 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_156_25_MHZ, TYPE_SGMII, TYPE_USXGMII, NO_SSC), &j7200_sgmii_100_no_ssc_tx_ln_vals},
5559
5560 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_156_25_MHZ, TYPE_QSGMII, TYPE_USXGMII, NO_SSC), &j7200_qsgmii_100_no_ssc_tx_ln_vals},
5561
5562 {CDNS_TORRENT_KEY(CLK_156_25_MHZ, CLK_100_MHZ, TYPE_USXGMII, TYPE_PCIE, NO_SSC), &ml_usxgmii_156_25_no_ssc_tx_ln_vals},
5563 {CDNS_TORRENT_KEY(CLK_156_25_MHZ, CLK_100_MHZ, TYPE_USXGMII, TYPE_SGMII, NO_SSC), &usxgmii_156_25_no_ssc_tx_ln_vals},
5564 {CDNS_TORRENT_KEY(CLK_156_25_MHZ, CLK_100_MHZ, TYPE_USXGMII, TYPE_QSGMII, NO_SSC), &usxgmii_156_25_no_ssc_tx_ln_vals},
5565 };
5566
5567 static const struct cdns_torrent_vals_entry ti_j7200_rx_ln_vals_entries[] = {
5568 {CDNS_TORRENT_KEY(CLK_19_2_MHZ, CLK_19_2_MHZ, TYPE_DP, TYPE_NONE, NO_SSC), &sl_dp_19_2_no_ssc_rx_ln_vals},
5569 {CDNS_TORRENT_KEY(CLK_25_MHZ, CLK_25_MHZ, TYPE_DP, TYPE_NONE, NO_SSC), &sl_dp_25_no_ssc_rx_ln_vals},
5570
5571 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_DP, TYPE_NONE, NO_SSC), &sl_dp_100_no_ssc_rx_ln_vals},
5572 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_DP, TYPE_PCIE, NO_SSC), &dp_100_no_ssc_rx_ln_vals},
5573 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_DP, TYPE_USB, NO_SSC), &dp_100_no_ssc_rx_ln_vals},
5574
5575 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_NONE, NO_SSC), &pcie_100_no_ssc_rx_ln_vals},
5576 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_NONE, EXTERNAL_SSC), &pcie_100_no_ssc_rx_ln_vals},
5577 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_NONE, INTERNAL_SSC), &pcie_100_no_ssc_rx_ln_vals},
5578
5579 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_PCIE, NO_SSC), &pcie_100_no_ssc_rx_ln_vals},
5580 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_PCIE, EXTERNAL_SSC), &pcie_100_no_ssc_rx_ln_vals},
5581 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_PCIE, INTERNAL_SSC), &pcie_100_no_ssc_rx_ln_vals},
5582
5583 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_SGMII, NO_SSC), &pcie_100_no_ssc_rx_ln_vals},
5584 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_SGMII, EXTERNAL_SSC), &pcie_100_no_ssc_rx_ln_vals},
5585 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_SGMII, INTERNAL_SSC), &pcie_100_no_ssc_rx_ln_vals},
5586
5587 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_QSGMII, NO_SSC), &pcie_100_no_ssc_rx_ln_vals},
5588 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_QSGMII, EXTERNAL_SSC), &pcie_100_no_ssc_rx_ln_vals},
5589 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_QSGMII, INTERNAL_SSC), &pcie_100_no_ssc_rx_ln_vals},
5590
5591 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_USB, NO_SSC), &pcie_100_no_ssc_rx_ln_vals},
5592 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_USB, EXTERNAL_SSC), &pcie_100_no_ssc_rx_ln_vals},
5593 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_USB, INTERNAL_SSC), &pcie_100_no_ssc_rx_ln_vals},
5594
5595 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_DP, NO_SSC), &pcie_100_no_ssc_rx_ln_vals},
5596
5597 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE_ML, TYPE_USB, NO_SSC), &pcie_100_no_ssc_rx_ln_vals},
5598 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE_ML, TYPE_USB, EXTERNAL_SSC), &pcie_100_no_ssc_rx_ln_vals},
5599 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE_ML, TYPE_USB, INTERNAL_SSC), &pcie_100_no_ssc_rx_ln_vals},
5600
5601 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_NONE, NO_SSC), &sgmii_100_no_ssc_rx_ln_vals},
5602
5603 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_PCIE, NO_SSC), &sgmii_100_no_ssc_rx_ln_vals},
5604 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_PCIE, EXTERNAL_SSC), &sgmii_100_no_ssc_rx_ln_vals},
5605 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_PCIE, INTERNAL_SSC), &sgmii_100_no_ssc_rx_ln_vals},
5606
5607 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_QSGMII, NO_SSC), &sgmii_100_no_ssc_rx_ln_vals},
5608
5609 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_USB, NO_SSC), &sgmii_100_no_ssc_rx_ln_vals},
5610 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_USB, EXTERNAL_SSC), &sgmii_100_no_ssc_rx_ln_vals},
5611 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_USB, INTERNAL_SSC), &sgmii_100_no_ssc_rx_ln_vals},
5612
5613 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_NONE, NO_SSC), &qsgmii_100_no_ssc_rx_ln_vals},
5614
5615 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_PCIE, NO_SSC), &qsgmii_100_no_ssc_rx_ln_vals},
5616 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_PCIE, EXTERNAL_SSC), &qsgmii_100_no_ssc_rx_ln_vals},
5617 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_PCIE, INTERNAL_SSC), &qsgmii_100_no_ssc_rx_ln_vals},
5618
5619 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_SGMII, NO_SSC), &qsgmii_100_no_ssc_rx_ln_vals},
5620
5621 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_USB, NO_SSC), &qsgmii_100_no_ssc_rx_ln_vals},
5622 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_USB, EXTERNAL_SSC), &qsgmii_100_no_ssc_rx_ln_vals},
5623 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_USB, INTERNAL_SSC), &qsgmii_100_no_ssc_rx_ln_vals},
5624
5625 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_NONE, NO_SSC), &usb_100_no_ssc_rx_ln_vals},
5626 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_NONE, EXTERNAL_SSC), &usb_100_no_ssc_rx_ln_vals},
5627 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_NONE, INTERNAL_SSC), &usb_100_no_ssc_rx_ln_vals},
5628
5629 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_PCIE, NO_SSC), &usb_100_no_ssc_rx_ln_vals},
5630 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_PCIE, EXTERNAL_SSC), &usb_100_no_ssc_rx_ln_vals},
5631 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_PCIE, INTERNAL_SSC), &usb_100_no_ssc_rx_ln_vals},
5632
5633 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_PCIE_ML, NO_SSC), &usb_100_no_ssc_rx_ln_vals},
5634 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_PCIE_ML, EXTERNAL_SSC), &usb_100_no_ssc_rx_ln_vals},
5635 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_PCIE_ML, INTERNAL_SSC), &usb_100_no_ssc_rx_ln_vals},
5636
5637 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_SGMII, NO_SSC), &usb_100_no_ssc_rx_ln_vals},
5638 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_SGMII, EXTERNAL_SSC), &usb_100_no_ssc_rx_ln_vals},
5639 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_SGMII, INTERNAL_SSC), &usb_100_no_ssc_rx_ln_vals},
5640
5641 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_QSGMII, NO_SSC), &usb_100_no_ssc_rx_ln_vals},
5642 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_QSGMII, EXTERNAL_SSC), &usb_100_no_ssc_rx_ln_vals},
5643 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_QSGMII, INTERNAL_SSC), &usb_100_no_ssc_rx_ln_vals},
5644
5645 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_DP, NO_SSC), &usb_100_no_ssc_rx_ln_vals},
5646
5647 {CDNS_TORRENT_KEY(CLK_156_25_MHZ, CLK_156_25_MHZ, TYPE_USXGMII, TYPE_NONE, NO_SSC), &usxgmii_156_25_no_ssc_rx_ln_vals},
5648
5649 /* Dual refclk */
5650 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_156_25_MHZ, TYPE_PCIE, TYPE_USXGMII, NO_SSC), &pcie_100_no_ssc_rx_ln_vals},
5651
5652 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_156_25_MHZ, TYPE_SGMII, TYPE_USXGMII, NO_SSC), &j7200_sgmii_100_no_ssc_rx_ln_vals},
5653
5654 {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_156_25_MHZ, TYPE_QSGMII, TYPE_USXGMII, NO_SSC), &j7200_qsgmii_100_no_ssc_rx_ln_vals},
5655
5656 {CDNS_TORRENT_KEY(CLK_156_25_MHZ, CLK_100_MHZ, TYPE_USXGMII, TYPE_PCIE, NO_SSC), &ml_usxgmii_156_25_no_ssc_rx_ln_vals},
5657 {CDNS_TORRENT_KEY(CLK_156_25_MHZ, CLK_100_MHZ, TYPE_USXGMII, TYPE_SGMII, NO_SSC), &usxgmii_156_25_no_ssc_rx_ln_vals},
5658 {CDNS_TORRENT_KEY(CLK_156_25_MHZ, CLK_100_MHZ, TYPE_USXGMII, TYPE_QSGMII, NO_SSC), &usxgmii_156_25_no_ssc_rx_ln_vals},
5659 };
5660
5661 static const struct cdns_torrent_data ti_j7200_map_torrent = {
5662 .block_offset_shift = 0x0,
5663 .reg_offset_shift = 0x1,
5664 .link_cmn_vals_tbl = {
5665 .entries = link_cmn_vals_entries,
5666 .num_entries = ARRAY_SIZE(link_cmn_vals_entries),
5667 },
5668 .xcvr_diag_vals_tbl = {
5669 .entries = xcvr_diag_vals_entries,
5670 .num_entries = ARRAY_SIZE(xcvr_diag_vals_entries),
5671 },
5672 .pcs_cmn_vals_tbl = {
5673 .entries = pcs_cmn_vals_entries,
5674 .num_entries = ARRAY_SIZE(pcs_cmn_vals_entries),
5675 },
5676 .phy_pma_cmn_vals_tbl = {
5677 .entries = j721e_phy_pma_cmn_vals_entries,
5678 .num_entries = ARRAY_SIZE(j721e_phy_pma_cmn_vals_entries),
5679 },
5680 .cmn_vals_tbl = {
5681 .entries = ti_j7200_cmn_vals_entries,
5682 .num_entries = ARRAY_SIZE(ti_j7200_cmn_vals_entries),
5683 },
5684 .tx_ln_vals_tbl = {
5685 .entries = ti_j7200_tx_ln_vals_entries,
5686 .num_entries = ARRAY_SIZE(ti_j7200_tx_ln_vals_entries),
5687 },
5688 .rx_ln_vals_tbl = {
5689 .entries = ti_j7200_rx_ln_vals_entries,
5690 .num_entries = ARRAY_SIZE(ti_j7200_rx_ln_vals_entries),
5691 },
5692 };
5693
5694 static const struct of_device_id cdns_torrent_phy_of_match[] = {
5695 {
5696 .compatible = "cdns,torrent-phy",
5697 .data = &cdns_map_torrent,
5698 },
5699 {
5700 .compatible = "ti,j721e-serdes-10g",
5701 .data = &ti_j721e_map_torrent,
5702 },
5703 {
5704 .compatible = "ti,j7200-serdes-10g",
5705 .data = &ti_j7200_map_torrent,
5706 },
5707 {}
5708 };
5709 MODULE_DEVICE_TABLE(of, cdns_torrent_phy_of_match);
5710
5711 static struct platform_driver cdns_torrent_phy_driver = {
5712 .probe = cdns_torrent_phy_probe,
5713 .remove = cdns_torrent_phy_remove,
5714 .driver = {
5715 .name = "cdns-torrent-phy",
5716 .of_match_table = cdns_torrent_phy_of_match,
5717 .pm = pm_sleep_ptr(&cdns_torrent_phy_pm_ops),
5718 }
5719 };
5720 module_platform_driver(cdns_torrent_phy_driver);
5721
5722 MODULE_AUTHOR("Cadence Design Systems, Inc.");
5723 MODULE_DESCRIPTION("Cadence Torrent PHY driver");
5724 MODULE_LICENSE("GPL v2");
5725