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