xref: /linux/drivers/phy/cadence/phy-cadence-sierra.c (revision e72659b69f0650f8f0e7e1587e5f261d2a431697)
144d30d62SAlan Douglas // SPDX-License-Identifier: GPL-2.0
244d30d62SAlan Douglas /*
344d30d62SAlan Douglas  * Cadence Sierra PHY Driver
444d30d62SAlan Douglas  *
544d30d62SAlan Douglas  * Copyright (c) 2018 Cadence Design Systems
644d30d62SAlan Douglas  * Author: Alan Douglas <adouglas@cadence.com>
744d30d62SAlan Douglas  *
844d30d62SAlan Douglas  */
944d30d62SAlan Douglas #include <linux/clk.h>
1028081b72SKishon Vijay Abraham I #include <linux/clk-provider.h>
1144d30d62SAlan Douglas #include <linux/delay.h>
1244d30d62SAlan Douglas #include <linux/err.h>
1344d30d62SAlan Douglas #include <linux/io.h>
1444d30d62SAlan Douglas #include <linux/module.h>
1544d30d62SAlan Douglas #include <linux/phy/phy.h>
1644d30d62SAlan Douglas #include <linux/platform_device.h>
1744d30d62SAlan Douglas #include <linux/pm_runtime.h>
1844d30d62SAlan Douglas #include <linux/regmap.h>
1944d30d62SAlan Douglas #include <linux/reset.h>
2044d30d62SAlan Douglas #include <linux/slab.h>
2144d30d62SAlan Douglas #include <linux/of.h>
2244d30d62SAlan Douglas #include <linux/of_platform.h>
2344d30d62SAlan Douglas #include <dt-bindings/phy/phy.h>
2428081b72SKishon Vijay Abraham I #include <dt-bindings/phy/phy-cadence.h>
2544d30d62SAlan Douglas 
26078e9e92SSwapnil Jakhade #define NUM_SSC_MODE		3
276b81f05aSSwapnil Jakhade #define NUM_PHY_TYPE		4
28078e9e92SSwapnil Jakhade 
2944d30d62SAlan Douglas /* PHY register offsets */
30380f5708SKishon Vijay Abraham I #define SIERRA_COMMON_CDB_OFFSET			0x0
31380f5708SKishon Vijay Abraham I #define SIERRA_MACRO_ID_REG				0x0
3228081b72SKishon Vijay Abraham I #define SIERRA_CMN_PLLLC_GEN_PREG			0x42
33871002d7SAnil Varughese #define SIERRA_CMN_PLLLC_MODE_PREG			0x48
34871002d7SAnil Varughese #define SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG		0x49
35871002d7SAnil Varughese #define SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG		0x4A
36871002d7SAnil Varughese #define SIERRA_CMN_PLLLC_LOCK_CNTSTART_PREG		0x4B
3709d976b3SSwapnil Jakhade #define SIERRA_CMN_PLLLC_CLK1_PREG			0x4D
38871002d7SAnil Varughese #define SIERRA_CMN_PLLLC_BWCAL_MODE1_PREG		0x4F
39871002d7SAnil Varughese #define SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG		0x50
407a5ad9b4SSwapnil Jakhade #define SIERRA_CMN_PLLLC_DSMCORR_PREG			0x51
417a5ad9b4SSwapnil Jakhade #define SIERRA_CMN_PLLLC_SS_PREG			0x52
427a5ad9b4SSwapnil Jakhade #define SIERRA_CMN_PLLLC_SS_AMP_STEP_SIZE_PREG		0x53
437a5ad9b4SSwapnil Jakhade #define SIERRA_CMN_PLLLC_SSTWOPT_PREG			0x54
44871002d7SAnil Varughese #define SIERRA_CMN_PLLLC_SS_TIME_STEPSIZE_MODE_PREG	0x62
457a5ad9b4SSwapnil Jakhade #define SIERRA_CMN_PLLLC_LOCK_DELAY_CTRL_PREG		0x63
4628081b72SKishon Vijay Abraham I #define SIERRA_CMN_REFRCV_PREG				0x98
4728081b72SKishon Vijay Abraham I #define SIERRA_CMN_REFRCV1_PREG				0xB8
4828081b72SKishon Vijay Abraham I #define SIERRA_CMN_PLLLC1_GEN_PREG			0xC2
498a1b82d7SSwapnil Jakhade #define SIERRA_CMN_PLLLC1_LF_COEFF_MODE0_PREG		0xCA
508a1b82d7SSwapnil Jakhade #define SIERRA_CMN_PLLLC1_BWCAL_MODE0_PREG		0xD0
518a1b82d7SSwapnil Jakhade #define SIERRA_CMN_PLLLC1_SS_TIME_STEPSIZE_MODE_PREG	0xE2
52380f5708SKishon Vijay Abraham I 
53380f5708SKishon Vijay Abraham I #define SIERRA_LANE_CDB_OFFSET(ln, block_offset, reg_offset)	\
54380f5708SKishon Vijay Abraham I 				((0x4000 << (block_offset)) + \
55380f5708SKishon Vijay Abraham I 				 (((ln) << 9) << (reg_offset)))
56aead5fd6SKishon Vijay Abraham I 
57aead5fd6SKishon Vijay Abraham I #define SIERRA_DET_STANDEC_A_PREG			0x000
58aead5fd6SKishon Vijay Abraham I #define SIERRA_DET_STANDEC_B_PREG			0x001
59aead5fd6SKishon Vijay Abraham I #define SIERRA_DET_STANDEC_C_PREG			0x002
60aead5fd6SKishon Vijay Abraham I #define SIERRA_DET_STANDEC_D_PREG			0x003
61aead5fd6SKishon Vijay Abraham I #define SIERRA_DET_STANDEC_E_PREG			0x004
62871002d7SAnil Varughese #define SIERRA_PSM_LANECAL_DLY_A1_RESETS_PREG		0x008
63871002d7SAnil Varughese #define SIERRA_PSM_A0IN_TMR_PREG			0x009
647a5ad9b4SSwapnil Jakhade #define SIERRA_PSM_A3IN_TMR_PREG			0x00C
65aead5fd6SKishon Vijay Abraham I #define SIERRA_PSM_DIAG_PREG				0x015
668a1b82d7SSwapnil Jakhade #define SIERRA_PSC_LN_A3_PREG				0x023
678a1b82d7SSwapnil Jakhade #define SIERRA_PSC_LN_A4_PREG				0x024
688a1b82d7SSwapnil Jakhade #define SIERRA_PSC_LN_IDLE_PREG				0x026
69aead5fd6SKishon Vijay Abraham I #define SIERRA_PSC_TX_A0_PREG				0x028
70aead5fd6SKishon Vijay Abraham I #define SIERRA_PSC_TX_A1_PREG				0x029
71aead5fd6SKishon Vijay Abraham I #define SIERRA_PSC_TX_A2_PREG				0x02A
72aead5fd6SKishon Vijay Abraham I #define SIERRA_PSC_TX_A3_PREG				0x02B
73aead5fd6SKishon Vijay Abraham I #define SIERRA_PSC_RX_A0_PREG				0x030
74aead5fd6SKishon Vijay Abraham I #define SIERRA_PSC_RX_A1_PREG				0x031
75aead5fd6SKishon Vijay Abraham I #define SIERRA_PSC_RX_A2_PREG				0x032
76aead5fd6SKishon Vijay Abraham I #define SIERRA_PSC_RX_A3_PREG				0x033
77aead5fd6SKishon Vijay Abraham I #define SIERRA_PLLCTRL_SUBRATE_PREG			0x03A
788a1b82d7SSwapnil Jakhade #define SIERRA_PLLCTRL_GEN_A_PREG			0x03B
79aead5fd6SKishon Vijay Abraham I #define SIERRA_PLLCTRL_GEN_D_PREG			0x03E
80871002d7SAnil Varughese #define SIERRA_PLLCTRL_CPGAIN_MODE_PREG			0x03F
81adc4bd6fSKishon Vijay Abraham I #define SIERRA_PLLCTRL_STATUS_PREG			0x044
82871002d7SAnil Varughese #define SIERRA_CLKPATH_BIASTRIM_PREG			0x04B
83871002d7SAnil Varughese #define SIERRA_DFE_BIASTRIM_PREG			0x04C
84aead5fd6SKishon Vijay Abraham I #define SIERRA_DRVCTRL_ATTEN_PREG			0x06A
857a5ad9b4SSwapnil Jakhade #define SIERRA_DRVCTRL_BOOST_PREG			0x06F
86*e72659b6SSwapnil Jakhade #define SIERRA_TX_RCVDET_OVRD_PREG			0x072
87aead5fd6SKishon Vijay Abraham I #define SIERRA_CLKPATHCTRL_TMR_PREG			0x081
88871002d7SAnil Varughese #define SIERRA_RX_CREQ_FLTR_A_MODE3_PREG		0x085
89871002d7SAnil Varughese #define SIERRA_RX_CREQ_FLTR_A_MODE2_PREG		0x086
90aead5fd6SKishon Vijay Abraham I #define SIERRA_RX_CREQ_FLTR_A_MODE1_PREG		0x087
91aead5fd6SKishon Vijay Abraham I #define SIERRA_RX_CREQ_FLTR_A_MODE0_PREG		0x088
927a5ad9b4SSwapnil Jakhade #define SIERRA_CREQ_DCBIASATTEN_OVR_PREG		0x08C
93aead5fd6SKishon Vijay Abraham I #define SIERRA_CREQ_CCLKDET_MODE01_PREG			0x08E
947a5ad9b4SSwapnil Jakhade #define SIERRA_RX_CTLE_CAL_PREG				0x08F
95aead5fd6SKishon Vijay Abraham I #define SIERRA_RX_CTLE_MAINTENANCE_PREG			0x091
96aead5fd6SKishon Vijay Abraham I #define SIERRA_CREQ_FSMCLK_SEL_PREG			0x092
97871002d7SAnil Varughese #define SIERRA_CREQ_EQ_CTRL_PREG			0x093
98871002d7SAnil Varughese #define SIERRA_CREQ_SPARE_PREG				0x096
99871002d7SAnil Varughese #define SIERRA_CREQ_EQ_OPEN_EYE_THRESH_PREG		0x097
100aead5fd6SKishon Vijay Abraham I #define SIERRA_CTLELUT_CTRL_PREG			0x098
101aead5fd6SKishon Vijay Abraham I #define SIERRA_DFE_ECMP_RATESEL_PREG			0x0C0
102aead5fd6SKishon Vijay Abraham I #define SIERRA_DFE_SMP_RATESEL_PREG			0x0C1
103871002d7SAnil Varughese #define SIERRA_DEQ_PHALIGN_CTRL				0x0C4
104871002d7SAnil Varughese #define SIERRA_DEQ_CONCUR_CTRL1_PREG			0x0C8
105871002d7SAnil Varughese #define SIERRA_DEQ_CONCUR_CTRL2_PREG			0x0C9
106871002d7SAnil Varughese #define SIERRA_DEQ_EPIPWR_CTRL2_PREG			0x0CD
107871002d7SAnil Varughese #define SIERRA_DEQ_FAST_MAINT_CYCLES_PREG		0x0CE
108871002d7SAnil Varughese #define SIERRA_DEQ_ERRCMP_CTRL_PREG			0x0D0
109871002d7SAnil Varughese #define SIERRA_DEQ_OFFSET_CTRL_PREG			0x0D8
110871002d7SAnil Varughese #define SIERRA_DEQ_GAIN_CTRL_PREG			0x0E0
111aead5fd6SKishon Vijay Abraham I #define SIERRA_DEQ_VGATUNE_CTRL_PREG			0x0E1
112871002d7SAnil Varughese #define SIERRA_DEQ_GLUT0				0x0E8
113871002d7SAnil Varughese #define SIERRA_DEQ_GLUT1				0x0E9
114871002d7SAnil Varughese #define SIERRA_DEQ_GLUT2				0x0EA
115871002d7SAnil Varughese #define SIERRA_DEQ_GLUT3				0x0EB
116871002d7SAnil Varughese #define SIERRA_DEQ_GLUT4				0x0EC
117871002d7SAnil Varughese #define SIERRA_DEQ_GLUT5				0x0ED
118871002d7SAnil Varughese #define SIERRA_DEQ_GLUT6				0x0EE
119871002d7SAnil Varughese #define SIERRA_DEQ_GLUT7				0x0EF
120871002d7SAnil Varughese #define SIERRA_DEQ_GLUT8				0x0F0
121871002d7SAnil Varughese #define SIERRA_DEQ_GLUT9				0x0F1
122871002d7SAnil Varughese #define SIERRA_DEQ_GLUT10				0x0F2
123871002d7SAnil Varughese #define SIERRA_DEQ_GLUT11				0x0F3
124871002d7SAnil Varughese #define SIERRA_DEQ_GLUT12				0x0F4
125871002d7SAnil Varughese #define SIERRA_DEQ_GLUT13				0x0F5
126871002d7SAnil Varughese #define SIERRA_DEQ_GLUT14				0x0F6
127871002d7SAnil Varughese #define SIERRA_DEQ_GLUT15				0x0F7
128871002d7SAnil Varughese #define SIERRA_DEQ_GLUT16				0x0F8
129871002d7SAnil Varughese #define SIERRA_DEQ_ALUT0				0x108
130871002d7SAnil Varughese #define SIERRA_DEQ_ALUT1				0x109
131871002d7SAnil Varughese #define SIERRA_DEQ_ALUT2				0x10A
132871002d7SAnil Varughese #define SIERRA_DEQ_ALUT3				0x10B
133871002d7SAnil Varughese #define SIERRA_DEQ_ALUT4				0x10C
134871002d7SAnil Varughese #define SIERRA_DEQ_ALUT5				0x10D
135871002d7SAnil Varughese #define SIERRA_DEQ_ALUT6				0x10E
136871002d7SAnil Varughese #define SIERRA_DEQ_ALUT7				0x10F
137871002d7SAnil Varughese #define SIERRA_DEQ_ALUT8				0x110
138871002d7SAnil Varughese #define SIERRA_DEQ_ALUT9				0x111
139871002d7SAnil Varughese #define SIERRA_DEQ_ALUT10				0x112
140871002d7SAnil Varughese #define SIERRA_DEQ_ALUT11				0x113
141871002d7SAnil Varughese #define SIERRA_DEQ_ALUT12				0x114
142871002d7SAnil Varughese #define SIERRA_DEQ_ALUT13				0x115
143871002d7SAnil Varughese #define SIERRA_DEQ_DFETAP_CTRL_PREG			0x128
1447a5ad9b4SSwapnil Jakhade #define SIERRA_DEQ_DFETAP0				0x129
1457a5ad9b4SSwapnil Jakhade #define SIERRA_DEQ_DFETAP1				0x12B
1467a5ad9b4SSwapnil Jakhade #define SIERRA_DEQ_DFETAP2				0x12D
1477a5ad9b4SSwapnil Jakhade #define SIERRA_DEQ_DFETAP3				0x12F
1487a5ad9b4SSwapnil Jakhade #define SIERRA_DEQ_DFETAP4				0x131
149871002d7SAnil Varughese #define SIERRA_DFE_EN_1010_IGNORE_PREG			0x134
1507a5ad9b4SSwapnil Jakhade #define SIERRA_DEQ_PRECUR_PREG				0x138
1517a5ad9b4SSwapnil Jakhade #define SIERRA_DEQ_POSTCUR_PREG				0x140
1527a5ad9b4SSwapnil Jakhade #define SIERRA_DEQ_POSTCUR_DECR_PREG			0x142
153871002d7SAnil Varughese #define SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG		0x150
154871002d7SAnil Varughese #define SIERRA_DEQ_TAU_CTRL2_PREG			0x151
1557a5ad9b4SSwapnil Jakhade #define SIERRA_DEQ_TAU_CTRL3_PREG			0x152
1567a5ad9b4SSwapnil Jakhade #define SIERRA_DEQ_OPENEYE_CTRL_PREG			0x158
157871002d7SAnil Varughese #define SIERRA_DEQ_PICTRL_PREG				0x161
158871002d7SAnil Varughese #define SIERRA_CPICAL_TMRVAL_MODE1_PREG			0x170
159871002d7SAnil Varughese #define SIERRA_CPICAL_TMRVAL_MODE0_PREG			0x171
160871002d7SAnil Varughese #define SIERRA_CPICAL_PICNT_MODE1_PREG			0x174
161aead5fd6SKishon Vijay Abraham I #define SIERRA_CPI_OUTBUF_RATESEL_PREG			0x17C
1628a1b82d7SSwapnil Jakhade #define SIERRA_CPI_RESBIAS_BIN_PREG			0x17E
1637a5ad9b4SSwapnil Jakhade #define SIERRA_CPI_TRIM_PREG				0x17F
164871002d7SAnil Varughese #define SIERRA_CPICAL_RES_STARTCODE_MODE23_PREG		0x183
1657a5ad9b4SSwapnil Jakhade #define SIERRA_EPI_CTRL_PREG				0x187
166871002d7SAnil Varughese #define SIERRA_LFPSDET_SUPPORT_PREG			0x188
167aead5fd6SKishon Vijay Abraham I #define SIERRA_LFPSFILT_NS_PREG				0x18A
168aead5fd6SKishon Vijay Abraham I #define SIERRA_LFPSFILT_RD_PREG				0x18B
169aead5fd6SKishon Vijay Abraham I #define SIERRA_LFPSFILT_MP_PREG				0x18C
170871002d7SAnil Varughese #define SIERRA_SIGDET_SUPPORT_PREG			0x190
171aead5fd6SKishon Vijay Abraham I #define SIERRA_SDFILT_H2L_A_PREG			0x191
172871002d7SAnil Varughese #define SIERRA_SDFILT_L2H_PREG				0x193
173871002d7SAnil Varughese #define SIERRA_RXBUFFER_CTLECTRL_PREG			0x19E
174871002d7SAnil Varughese #define SIERRA_RXBUFFER_RCDFECTRL_PREG			0x19F
175871002d7SAnil Varughese #define SIERRA_RXBUFFER_DFECTRL_PREG			0x1A0
176871002d7SAnil Varughese #define SIERRA_DEQ_TAU_CTRL1_FAST_MAINT_PREG		0x14F
177871002d7SAnil Varughese #define SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG		0x150
178380f5708SKishon Vijay Abraham I 
1798c95e172SSwapnil Jakhade /* PHY PCS common registers */
1808c95e172SSwapnil Jakhade #define SIERRA_PHY_PCS_COMMON_OFFSET(block_offset)	\
181380f5708SKishon Vijay Abraham I 				     (0xc000 << (block_offset))
182fa105172SSwapnil Jakhade #define SIERRA_PHY_PIPE_CMN_CTRL1			0x0
183380f5708SKishon Vijay Abraham I #define SIERRA_PHY_PLL_CFG				0xe
18444d30d62SAlan Douglas 
18536ce4163SSwapnil Jakhade /* PHY PCS lane registers */
18636ce4163SSwapnil Jakhade #define SIERRA_PHY_PCS_LANE_CDB_OFFSET(ln, block_offset, reg_offset)	\
18736ce4163SSwapnil Jakhade 				       ((0xD000 << (block_offset)) +	\
18836ce4163SSwapnil Jakhade 				       (((ln) << 8) << (reg_offset)))
18936ce4163SSwapnil Jakhade 
19036ce4163SSwapnil Jakhade #define SIERRA_PHY_ISO_LINK_CTRL			0xB
19136ce4163SSwapnil Jakhade 
192f1cc6c3fSSwapnil Jakhade /* PHY PMA common registers */
193f1cc6c3fSSwapnil Jakhade #define SIERRA_PHY_PMA_COMMON_OFFSET(block_offset)	\
194f1cc6c3fSSwapnil Jakhade 				     (0xE000 << (block_offset))
195f1cc6c3fSSwapnil Jakhade #define SIERRA_PHY_PMA_CMN_CTRL				0x000
196f1cc6c3fSSwapnil Jakhade 
1976b81f05aSSwapnil Jakhade /* PHY PMA lane registers */
1986b81f05aSSwapnil Jakhade #define SIERRA_PHY_PMA_LANE_CDB_OFFSET(ln, block_offset, reg_offset)	\
1996b81f05aSSwapnil Jakhade 				       ((0xF000 << (block_offset)) +	\
2006b81f05aSSwapnil Jakhade 				       (((ln) << 8) << (reg_offset)))
2016b81f05aSSwapnil Jakhade 
2026b81f05aSSwapnil Jakhade #define SIERRA_PHY_PMA_XCVR_CTRL			0x000
2036b81f05aSSwapnil Jakhade 
20444d30d62SAlan Douglas #define SIERRA_MACRO_ID					0x00007364
205a43f72aeSKishon Vijay Abraham I #define SIERRA_MAX_LANES				16
206adc4bd6fSKishon Vijay Abraham I #define PLL_LOCK_TIME					100000
20744d30d62SAlan Douglas 
20809d976b3SSwapnil Jakhade #define CDNS_SIERRA_OUTPUT_CLOCKS			3
20928081b72SKishon Vijay Abraham I #define CDNS_SIERRA_INPUT_CLOCKS			5
210a0c30cd7SKishon Vijay Abraham I enum cdns_sierra_clock_input {
211a0c30cd7SKishon Vijay Abraham I 	PHY_CLK,
212a0c30cd7SKishon Vijay Abraham I 	CMN_REFCLK_DIG_DIV,
213a0c30cd7SKishon Vijay Abraham I 	CMN_REFCLK1_DIG_DIV,
21428081b72SKishon Vijay Abraham I 	PLL0_REFCLK,
21528081b72SKishon Vijay Abraham I 	PLL1_REFCLK,
216a0c30cd7SKishon Vijay Abraham I };
217a0c30cd7SKishon Vijay Abraham I 
21828081b72SKishon Vijay Abraham I #define SIERRA_NUM_CMN_PLLC				2
21928081b72SKishon Vijay Abraham I #define SIERRA_NUM_CMN_PLLC_PARENTS			2
22028081b72SKishon Vijay Abraham I 
221380f5708SKishon Vijay Abraham I static const struct reg_field macro_id_type =
222380f5708SKishon Vijay Abraham I 				REG_FIELD(SIERRA_MACRO_ID_REG, 0, 15);
223380f5708SKishon Vijay Abraham I static const struct reg_field phy_pll_cfg_1 =
224380f5708SKishon Vijay Abraham I 				REG_FIELD(SIERRA_PHY_PLL_CFG, 1, 1);
225f1cc6c3fSSwapnil Jakhade static const struct reg_field pma_cmn_ready =
226f1cc6c3fSSwapnil Jakhade 				REG_FIELD(SIERRA_PHY_PMA_CMN_CTRL, 0, 0);
227adc4bd6fSKishon Vijay Abraham I static const struct reg_field pllctrl_lock =
228adc4bd6fSKishon Vijay Abraham I 				REG_FIELD(SIERRA_PLLCTRL_STATUS_PREG, 0, 0);
22936ce4163SSwapnil Jakhade static const struct reg_field phy_iso_link_ctrl_1 =
23036ce4163SSwapnil Jakhade 				REG_FIELD(SIERRA_PHY_ISO_LINK_CTRL, 1, 1);
23109d976b3SSwapnil Jakhade static const struct reg_field cmn_plllc_clk1outdiv_preg =
23209d976b3SSwapnil Jakhade 				REG_FIELD(SIERRA_CMN_PLLLC_CLK1_PREG, 0, 6);
23309d976b3SSwapnil Jakhade static const struct reg_field cmn_plllc_clk1_en_preg =
23409d976b3SSwapnil Jakhade 				REG_FIELD(SIERRA_CMN_PLLLC_CLK1_PREG, 12, 12);
235380f5708SKishon Vijay Abraham I 
23628081b72SKishon Vijay Abraham I static const char * const clk_names[] = {
23728081b72SKishon Vijay Abraham I 	[CDNS_SIERRA_PLL_CMNLC] = "pll_cmnlc",
23828081b72SKishon Vijay Abraham I 	[CDNS_SIERRA_PLL_CMNLC1] = "pll_cmnlc1",
23909d976b3SSwapnil Jakhade 	[CDNS_SIERRA_DERIVED_REFCLK] = "refclk_der",
24028081b72SKishon Vijay Abraham I };
24128081b72SKishon Vijay Abraham I 
24228081b72SKishon Vijay Abraham I enum cdns_sierra_cmn_plllc {
24328081b72SKishon Vijay Abraham I 	CMN_PLLLC,
24428081b72SKishon Vijay Abraham I 	CMN_PLLLC1,
24528081b72SKishon Vijay Abraham I };
24628081b72SKishon Vijay Abraham I 
24728081b72SKishon Vijay Abraham I struct cdns_sierra_pll_mux_reg_fields {
24828081b72SKishon Vijay Abraham I 	struct reg_field	pfdclk_sel_preg;
24928081b72SKishon Vijay Abraham I 	struct reg_field	plllc1en_field;
25028081b72SKishon Vijay Abraham I 	struct reg_field	termen_field;
25128081b72SKishon Vijay Abraham I };
25228081b72SKishon Vijay Abraham I 
25328081b72SKishon Vijay Abraham I static const struct cdns_sierra_pll_mux_reg_fields cmn_plllc_pfdclk1_sel_preg[] = {
25428081b72SKishon Vijay Abraham I 	[CMN_PLLLC] = {
25528081b72SKishon Vijay Abraham I 		.pfdclk_sel_preg = REG_FIELD(SIERRA_CMN_PLLLC_GEN_PREG, 1, 1),
25628081b72SKishon Vijay Abraham I 		.plllc1en_field = REG_FIELD(SIERRA_CMN_REFRCV1_PREG, 8, 8),
25728081b72SKishon Vijay Abraham I 		.termen_field = REG_FIELD(SIERRA_CMN_REFRCV1_PREG, 0, 0),
25828081b72SKishon Vijay Abraham I 	},
25928081b72SKishon Vijay Abraham I 	[CMN_PLLLC1] = {
26028081b72SKishon Vijay Abraham I 		.pfdclk_sel_preg = REG_FIELD(SIERRA_CMN_PLLLC1_GEN_PREG, 1, 1),
26128081b72SKishon Vijay Abraham I 		.plllc1en_field = REG_FIELD(SIERRA_CMN_REFRCV_PREG, 8, 8),
26228081b72SKishon Vijay Abraham I 		.termen_field = REG_FIELD(SIERRA_CMN_REFRCV_PREG, 0, 0),
26328081b72SKishon Vijay Abraham I 	},
26428081b72SKishon Vijay Abraham I };
26528081b72SKishon Vijay Abraham I 
26628081b72SKishon Vijay Abraham I struct cdns_sierra_pll_mux {
26728081b72SKishon Vijay Abraham I 	struct clk_hw		hw;
26828081b72SKishon Vijay Abraham I 	struct regmap_field	*pfdclk_sel_preg;
26928081b72SKishon Vijay Abraham I 	struct regmap_field	*plllc1en_field;
27028081b72SKishon Vijay Abraham I 	struct regmap_field	*termen_field;
27128081b72SKishon Vijay Abraham I 	struct clk_init_data	clk_data;
27228081b72SKishon Vijay Abraham I };
27328081b72SKishon Vijay Abraham I 
27428081b72SKishon Vijay Abraham I #define to_cdns_sierra_pll_mux(_hw)	\
27528081b72SKishon Vijay Abraham I 			container_of(_hw, struct cdns_sierra_pll_mux, hw)
27628081b72SKishon Vijay Abraham I 
27728081b72SKishon Vijay Abraham I static const int pll_mux_parent_index[][SIERRA_NUM_CMN_PLLC_PARENTS] = {
27828081b72SKishon Vijay Abraham I 	[CMN_PLLLC] = { PLL0_REFCLK, PLL1_REFCLK },
27928081b72SKishon Vijay Abraham I 	[CMN_PLLLC1] = { PLL1_REFCLK, PLL0_REFCLK },
28028081b72SKishon Vijay Abraham I };
28128081b72SKishon Vijay Abraham I 
282da08aab9SSwapnil Jakhade static u32 cdns_sierra_pll_mux_table[][SIERRA_NUM_CMN_PLLC_PARENTS] = {
283da08aab9SSwapnil Jakhade 	[CMN_PLLLC] = { 0, 1 },
284da08aab9SSwapnil Jakhade 	[CMN_PLLLC1] = { 1, 0 },
285da08aab9SSwapnil Jakhade };
28628081b72SKishon Vijay Abraham I 
28709d976b3SSwapnil Jakhade struct cdns_sierra_derived_refclk {
28809d976b3SSwapnil Jakhade 	struct clk_hw           hw;
28909d976b3SSwapnil Jakhade 	struct regmap_field     *cmn_plllc_clk1outdiv_preg;
29009d976b3SSwapnil Jakhade 	struct regmap_field     *cmn_plllc_clk1_en_preg;
29109d976b3SSwapnil Jakhade 	struct clk_init_data	clk_data;
29209d976b3SSwapnil Jakhade };
29309d976b3SSwapnil Jakhade 
29409d976b3SSwapnil Jakhade #define to_cdns_sierra_derived_refclk(_hw)	\
29509d976b3SSwapnil Jakhade 			container_of(_hw, struct cdns_sierra_derived_refclk, hw)
29609d976b3SSwapnil Jakhade 
297078e9e92SSwapnil Jakhade enum cdns_sierra_phy_type {
298078e9e92SSwapnil Jakhade 	TYPE_NONE,
299078e9e92SSwapnil Jakhade 	TYPE_PCIE,
3008a1b82d7SSwapnil Jakhade 	TYPE_USB,
3018a1b82d7SSwapnil Jakhade 	TYPE_QSGMII
302078e9e92SSwapnil Jakhade };
303078e9e92SSwapnil Jakhade 
304078e9e92SSwapnil Jakhade enum cdns_sierra_ssc_mode {
305078e9e92SSwapnil Jakhade 	NO_SSC,
306078e9e92SSwapnil Jakhade 	EXTERNAL_SSC,
307078e9e92SSwapnil Jakhade 	INTERNAL_SSC
308078e9e92SSwapnil Jakhade };
309078e9e92SSwapnil Jakhade 
31044d30d62SAlan Douglas struct cdns_sierra_inst {
31144d30d62SAlan Douglas 	struct phy *phy;
312078e9e92SSwapnil Jakhade 	enum cdns_sierra_phy_type phy_type;
31344d30d62SAlan Douglas 	u32 num_lanes;
31444d30d62SAlan Douglas 	u32 mlane;
31544d30d62SAlan Douglas 	struct reset_control *lnk_rst;
3161e902b2aSSwapnil Jakhade 	enum cdns_sierra_ssc_mode ssc_mode;
31744d30d62SAlan Douglas };
31844d30d62SAlan Douglas 
31944d30d62SAlan Douglas struct cdns_reg_pairs {
32044d30d62SAlan Douglas 	u16 val;
32144d30d62SAlan Douglas 	u32 off;
32244d30d62SAlan Douglas };
32344d30d62SAlan Douglas 
324078e9e92SSwapnil Jakhade struct cdns_sierra_vals {
325078e9e92SSwapnil Jakhade 	const struct cdns_reg_pairs *reg_pairs;
326078e9e92SSwapnil Jakhade 	u32 num_regs;
327078e9e92SSwapnil Jakhade };
328078e9e92SSwapnil Jakhade 
32944d30d62SAlan Douglas struct cdns_sierra_data {
33044d30d62SAlan Douglas 	u32 id_value;
331380f5708SKishon Vijay Abraham I 	u8 block_offset_shift;
332380f5708SKishon Vijay Abraham I 	u8 reg_offset_shift;
333fa105172SSwapnil Jakhade 	struct cdns_sierra_vals *pcs_cmn_vals[NUM_PHY_TYPE][NUM_PHY_TYPE]
334fa105172SSwapnil Jakhade 					     [NUM_SSC_MODE];
3356b81f05aSSwapnil Jakhade 	struct cdns_sierra_vals *phy_pma_ln_vals[NUM_PHY_TYPE][NUM_PHY_TYPE]
3366b81f05aSSwapnil Jakhade 						[NUM_SSC_MODE];
337078e9e92SSwapnil Jakhade 	struct cdns_sierra_vals *pma_cmn_vals[NUM_PHY_TYPE][NUM_PHY_TYPE]
338078e9e92SSwapnil Jakhade 					     [NUM_SSC_MODE];
339078e9e92SSwapnil Jakhade 	struct cdns_sierra_vals *pma_ln_vals[NUM_PHY_TYPE][NUM_PHY_TYPE]
340078e9e92SSwapnil Jakhade 					    [NUM_SSC_MODE];
34144d30d62SAlan Douglas };
34244d30d62SAlan Douglas 
343380f5708SKishon Vijay Abraham I struct cdns_regmap_cdb_context {
34444d30d62SAlan Douglas 	struct device *dev;
34544d30d62SAlan Douglas 	void __iomem *base;
346380f5708SKishon Vijay Abraham I 	u8 reg_offset_shift;
347380f5708SKishon Vijay Abraham I };
348380f5708SKishon Vijay Abraham I 
349380f5708SKishon Vijay Abraham I struct cdns_sierra_phy {
350380f5708SKishon Vijay Abraham I 	struct device *dev;
351380f5708SKishon Vijay Abraham I 	struct regmap *regmap;
352c3c11d55SSwapnil Jakhade 	const struct cdns_sierra_data *init_data;
35344d30d62SAlan Douglas 	struct cdns_sierra_inst phys[SIERRA_MAX_LANES];
35444d30d62SAlan Douglas 	struct reset_control *phy_rst;
35544d30d62SAlan Douglas 	struct reset_control *apb_rst;
356380f5708SKishon Vijay Abraham I 	struct regmap *regmap_lane_cdb[SIERRA_MAX_LANES];
3578c95e172SSwapnil Jakhade 	struct regmap *regmap_phy_pcs_common_cdb;
35836ce4163SSwapnil Jakhade 	struct regmap *regmap_phy_pcs_lane_cdb[SIERRA_MAX_LANES];
359f1cc6c3fSSwapnil Jakhade 	struct regmap *regmap_phy_pma_common_cdb;
3606b81f05aSSwapnil Jakhade 	struct regmap *regmap_phy_pma_lane_cdb[SIERRA_MAX_LANES];
361380f5708SKishon Vijay Abraham I 	struct regmap *regmap_common_cdb;
362380f5708SKishon Vijay Abraham I 	struct regmap_field *macro_id_type;
363380f5708SKishon Vijay Abraham I 	struct regmap_field *phy_pll_cfg_1;
364f1cc6c3fSSwapnil Jakhade 	struct regmap_field *pma_cmn_ready;
365adc4bd6fSKishon Vijay Abraham I 	struct regmap_field *pllctrl_lock[SIERRA_MAX_LANES];
36636ce4163SSwapnil Jakhade 	struct regmap_field *phy_iso_link_ctrl_1[SIERRA_MAX_LANES];
36728081b72SKishon Vijay Abraham I 	struct regmap_field *cmn_refrcv_refclk_plllc1en_preg[SIERRA_NUM_CMN_PLLC];
36828081b72SKishon Vijay Abraham I 	struct regmap_field *cmn_refrcv_refclk_termen_preg[SIERRA_NUM_CMN_PLLC];
36928081b72SKishon Vijay Abraham I 	struct regmap_field *cmn_plllc_pfdclk1_sel_preg[SIERRA_NUM_CMN_PLLC];
370a0c30cd7SKishon Vijay Abraham I 	struct clk *input_clks[CDNS_SIERRA_INPUT_CLOCKS];
37144d30d62SAlan Douglas 	int nsubnodes;
372a43f72aeSKishon Vijay Abraham I 	u32 num_lanes;
37344d30d62SAlan Douglas 	bool autoconf;
374d88ca22dSAswath Govindraju 	int already_configured;
37528081b72SKishon Vijay Abraham I 	struct clk_onecell_data clk_data;
37628081b72SKishon Vijay Abraham I 	struct clk *output_clks[CDNS_SIERRA_OUTPUT_CLOCKS];
37744d30d62SAlan Douglas };
37844d30d62SAlan Douglas 
379380f5708SKishon Vijay Abraham I static int cdns_regmap_write(void *context, unsigned int reg, unsigned int val)
380380f5708SKishon Vijay Abraham I {
381380f5708SKishon Vijay Abraham I 	struct cdns_regmap_cdb_context *ctx = context;
382380f5708SKishon Vijay Abraham I 	u32 offset = reg << ctx->reg_offset_shift;
383380f5708SKishon Vijay Abraham I 
384380f5708SKishon Vijay Abraham I 	writew(val, ctx->base + offset);
385380f5708SKishon Vijay Abraham I 
386380f5708SKishon Vijay Abraham I 	return 0;
387380f5708SKishon Vijay Abraham I }
388380f5708SKishon Vijay Abraham I 
389380f5708SKishon Vijay Abraham I static int cdns_regmap_read(void *context, unsigned int reg, unsigned int *val)
390380f5708SKishon Vijay Abraham I {
391380f5708SKishon Vijay Abraham I 	struct cdns_regmap_cdb_context *ctx = context;
392380f5708SKishon Vijay Abraham I 	u32 offset = reg << ctx->reg_offset_shift;
393380f5708SKishon Vijay Abraham I 
394380f5708SKishon Vijay Abraham I 	*val = readw(ctx->base + offset);
395380f5708SKishon Vijay Abraham I 	return 0;
396380f5708SKishon Vijay Abraham I }
397380f5708SKishon Vijay Abraham I 
398380f5708SKishon Vijay Abraham I #define SIERRA_LANE_CDB_REGMAP_CONF(n) \
399380f5708SKishon Vijay Abraham I { \
400380f5708SKishon Vijay Abraham I 	.name = "sierra_lane" n "_cdb", \
401380f5708SKishon Vijay Abraham I 	.reg_stride = 1, \
402380f5708SKishon Vijay Abraham I 	.fast_io = true, \
403380f5708SKishon Vijay Abraham I 	.reg_write = cdns_regmap_write, \
404380f5708SKishon Vijay Abraham I 	.reg_read = cdns_regmap_read, \
405380f5708SKishon Vijay Abraham I }
406380f5708SKishon Vijay Abraham I 
4073cfb0e8eSRikard Falkeborn static const struct regmap_config cdns_sierra_lane_cdb_config[] = {
408380f5708SKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("0"),
409380f5708SKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("1"),
410380f5708SKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("2"),
411380f5708SKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("3"),
412a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("4"),
413a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("5"),
414a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("6"),
415a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("7"),
416a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("8"),
417a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("9"),
418a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("10"),
419a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("11"),
420a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("12"),
421a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("13"),
422a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("14"),
423a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("15"),
424380f5708SKishon Vijay Abraham I };
425380f5708SKishon Vijay Abraham I 
4263cfb0e8eSRikard Falkeborn static const struct regmap_config cdns_sierra_common_cdb_config = {
427380f5708SKishon Vijay Abraham I 	.name = "sierra_common_cdb",
428380f5708SKishon Vijay Abraham I 	.reg_stride = 1,
429380f5708SKishon Vijay Abraham I 	.fast_io = true,
430380f5708SKishon Vijay Abraham I 	.reg_write = cdns_regmap_write,
431380f5708SKishon Vijay Abraham I 	.reg_read = cdns_regmap_read,
432380f5708SKishon Vijay Abraham I };
433380f5708SKishon Vijay Abraham I 
4348c95e172SSwapnil Jakhade static const struct regmap_config cdns_sierra_phy_pcs_cmn_cdb_config = {
4358c95e172SSwapnil Jakhade 	.name = "sierra_phy_pcs_cmn_cdb",
436380f5708SKishon Vijay Abraham I 	.reg_stride = 1,
437380f5708SKishon Vijay Abraham I 	.fast_io = true,
438380f5708SKishon Vijay Abraham I 	.reg_write = cdns_regmap_write,
439380f5708SKishon Vijay Abraham I 	.reg_read = cdns_regmap_read,
440380f5708SKishon Vijay Abraham I };
441380f5708SKishon Vijay Abraham I 
44236ce4163SSwapnil Jakhade #define SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF(n) \
44336ce4163SSwapnil Jakhade { \
44436ce4163SSwapnil Jakhade 	.name = "sierra_phy_pcs_lane" n "_cdb", \
44536ce4163SSwapnil Jakhade 	.reg_stride = 1, \
44636ce4163SSwapnil Jakhade 	.fast_io = true, \
44736ce4163SSwapnil Jakhade 	.reg_write = cdns_regmap_write, \
44836ce4163SSwapnil Jakhade 	.reg_read = cdns_regmap_read, \
44936ce4163SSwapnil Jakhade }
45036ce4163SSwapnil Jakhade 
45136ce4163SSwapnil Jakhade static const struct regmap_config cdns_sierra_phy_pcs_lane_cdb_config[] = {
45236ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("0"),
45336ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("1"),
45436ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("2"),
45536ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("3"),
45636ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("4"),
45736ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("5"),
45836ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("6"),
45936ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("7"),
46036ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("8"),
46136ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("9"),
46236ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("10"),
46336ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("11"),
46436ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("12"),
46536ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("13"),
46636ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("14"),
46736ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("15"),
46836ce4163SSwapnil Jakhade };
46936ce4163SSwapnil Jakhade 
470f1cc6c3fSSwapnil Jakhade static const struct regmap_config cdns_sierra_phy_pma_cmn_cdb_config = {
471f1cc6c3fSSwapnil Jakhade 	.name = "sierra_phy_pma_cmn_cdb",
472f1cc6c3fSSwapnil Jakhade 	.reg_stride = 1,
473f1cc6c3fSSwapnil Jakhade 	.fast_io = true,
474f1cc6c3fSSwapnil Jakhade 	.reg_write = cdns_regmap_write,
475f1cc6c3fSSwapnil Jakhade 	.reg_read = cdns_regmap_read,
476f1cc6c3fSSwapnil Jakhade };
477f1cc6c3fSSwapnil Jakhade 
4786b81f05aSSwapnil Jakhade #define SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF(n) \
4796b81f05aSSwapnil Jakhade { \
4806b81f05aSSwapnil Jakhade 	.name = "sierra_phy_pma_lane" n "_cdb", \
4816b81f05aSSwapnil Jakhade 	.reg_stride = 1, \
4826b81f05aSSwapnil Jakhade 	.fast_io = true, \
4836b81f05aSSwapnil Jakhade 	.reg_write = cdns_regmap_write, \
4846b81f05aSSwapnil Jakhade 	.reg_read = cdns_regmap_read, \
4856b81f05aSSwapnil Jakhade }
4866b81f05aSSwapnil Jakhade 
4876b81f05aSSwapnil Jakhade static const struct regmap_config cdns_sierra_phy_pma_lane_cdb_config[] = {
4886b81f05aSSwapnil Jakhade 	SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("0"),
4896b81f05aSSwapnil Jakhade 	SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("1"),
4906b81f05aSSwapnil Jakhade 	SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("2"),
4916b81f05aSSwapnil Jakhade 	SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("3"),
4926b81f05aSSwapnil Jakhade 	SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("4"),
4936b81f05aSSwapnil Jakhade 	SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("5"),
4946b81f05aSSwapnil Jakhade 	SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("6"),
4956b81f05aSSwapnil Jakhade 	SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("7"),
4966b81f05aSSwapnil Jakhade 	SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("8"),
4976b81f05aSSwapnil Jakhade 	SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("9"),
4986b81f05aSSwapnil Jakhade 	SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("10"),
4996b81f05aSSwapnil Jakhade 	SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("11"),
5006b81f05aSSwapnil Jakhade 	SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("12"),
5016b81f05aSSwapnil Jakhade 	SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("13"),
5026b81f05aSSwapnil Jakhade 	SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("14"),
5036b81f05aSSwapnil Jakhade 	SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("15"),
5046b81f05aSSwapnil Jakhade };
5056b81f05aSSwapnil Jakhade 
506cedcc2e2SKishon Vijay Abraham I static int cdns_sierra_phy_init(struct phy *gphy)
50744d30d62SAlan Douglas {
50844d30d62SAlan Douglas 	struct cdns_sierra_inst *ins = phy_get_drvdata(gphy);
50944d30d62SAlan Douglas 	struct cdns_sierra_phy *phy = dev_get_drvdata(gphy->dev.parent);
510078e9e92SSwapnil Jakhade 	const struct cdns_sierra_data *init_data = phy->init_data;
511078e9e92SSwapnil Jakhade 	struct cdns_sierra_vals *pma_cmn_vals, *pma_ln_vals;
512078e9e92SSwapnil Jakhade 	enum cdns_sierra_phy_type phy_type = ins->phy_type;
5131e902b2aSSwapnil Jakhade 	enum cdns_sierra_ssc_mode ssc = ins->ssc_mode;
5146b81f05aSSwapnil Jakhade 	struct cdns_sierra_vals *phy_pma_ln_vals;
515078e9e92SSwapnil Jakhade 	const struct cdns_reg_pairs *reg_pairs;
516fa105172SSwapnil Jakhade 	struct cdns_sierra_vals *pcs_cmn_vals;
51780f96fb1SColin Ian King 	struct regmap *regmap;
518078e9e92SSwapnil Jakhade 	u32 num_regs;
51944d30d62SAlan Douglas 	int i, j;
52044d30d62SAlan Douglas 
521cedcc2e2SKishon Vijay Abraham I 	/* Initialise the PHY registers, unless auto configured */
522d88ca22dSAswath Govindraju 	if (phy->autoconf || phy->already_configured || phy->nsubnodes > 1)
523cedcc2e2SKishon Vijay Abraham I 		return 0;
524cedcc2e2SKishon Vijay Abraham I 
525a0c30cd7SKishon Vijay Abraham I 	clk_set_rate(phy->input_clks[CMN_REFCLK_DIG_DIV], 25000000);
526a0c30cd7SKishon Vijay Abraham I 	clk_set_rate(phy->input_clks[CMN_REFCLK1_DIG_DIV], 25000000);
527078e9e92SSwapnil Jakhade 
528fa105172SSwapnil Jakhade 	/* PHY PCS common registers configurations */
529fa105172SSwapnil Jakhade 	pcs_cmn_vals = init_data->pcs_cmn_vals[phy_type][TYPE_NONE][ssc];
530fa105172SSwapnil Jakhade 	if (pcs_cmn_vals) {
531fa105172SSwapnil Jakhade 		reg_pairs = pcs_cmn_vals->reg_pairs;
532fa105172SSwapnil Jakhade 		num_regs = pcs_cmn_vals->num_regs;
533fa105172SSwapnil Jakhade 		regmap = phy->regmap_phy_pcs_common_cdb;
534fa105172SSwapnil Jakhade 		for (i = 0; i < num_regs; i++)
535fa105172SSwapnil Jakhade 			regmap_write(regmap, reg_pairs[i].off, reg_pairs[i].val);
536fa105172SSwapnil Jakhade 	}
537fa105172SSwapnil Jakhade 
5386b81f05aSSwapnil Jakhade 	/* PHY PMA lane registers configurations */
5396b81f05aSSwapnil Jakhade 	phy_pma_ln_vals = init_data->phy_pma_ln_vals[phy_type][TYPE_NONE][ssc];
5406b81f05aSSwapnil Jakhade 	if (phy_pma_ln_vals) {
5416b81f05aSSwapnil Jakhade 		reg_pairs = phy_pma_ln_vals->reg_pairs;
5426b81f05aSSwapnil Jakhade 		num_regs = phy_pma_ln_vals->num_regs;
5436b81f05aSSwapnil Jakhade 		for (i = 0; i < ins->num_lanes; i++) {
5446b81f05aSSwapnil Jakhade 			regmap = phy->regmap_phy_pma_lane_cdb[i + ins->mlane];
5456b81f05aSSwapnil Jakhade 			for (j = 0; j < num_regs; j++)
5466b81f05aSSwapnil Jakhade 				regmap_write(regmap, reg_pairs[j].off, reg_pairs[j].val);
5476b81f05aSSwapnil Jakhade 		}
5486b81f05aSSwapnil Jakhade 	}
5496b81f05aSSwapnil Jakhade 
550078e9e92SSwapnil Jakhade 	/* PMA common registers configurations */
551078e9e92SSwapnil Jakhade 	pma_cmn_vals = init_data->pma_cmn_vals[phy_type][TYPE_NONE][ssc];
552078e9e92SSwapnil Jakhade 	if (pma_cmn_vals) {
553078e9e92SSwapnil Jakhade 		reg_pairs = pma_cmn_vals->reg_pairs;
554078e9e92SSwapnil Jakhade 		num_regs = pma_cmn_vals->num_regs;
555078e9e92SSwapnil Jakhade 		regmap = phy->regmap_common_cdb;
556078e9e92SSwapnil Jakhade 		for (i = 0; i < num_regs; i++)
557078e9e92SSwapnil Jakhade 			regmap_write(regmap, reg_pairs[i].off, reg_pairs[i].val);
55844d30d62SAlan Douglas 	}
559871002d7SAnil Varughese 
560078e9e92SSwapnil Jakhade 	/* PMA lane registers configurations */
561078e9e92SSwapnil Jakhade 	pma_ln_vals = init_data->pma_ln_vals[phy_type][TYPE_NONE][ssc];
562078e9e92SSwapnil Jakhade 	if (pma_ln_vals) {
563078e9e92SSwapnil Jakhade 		reg_pairs = pma_ln_vals->reg_pairs;
564078e9e92SSwapnil Jakhade 		num_regs = pma_ln_vals->num_regs;
565380f5708SKishon Vijay Abraham I 		for (i = 0; i < ins->num_lanes; i++) {
566380f5708SKishon Vijay Abraham I 			regmap = phy->regmap_lane_cdb[i + ins->mlane];
567078e9e92SSwapnil Jakhade 			for (j = 0; j < num_regs; j++)
568078e9e92SSwapnil Jakhade 				regmap_write(regmap, reg_pairs[j].off, reg_pairs[j].val);
569380f5708SKishon Vijay Abraham I 		}
570380f5708SKishon Vijay Abraham I 	}
571cedcc2e2SKishon Vijay Abraham I 
572cedcc2e2SKishon Vijay Abraham I 	return 0;
57344d30d62SAlan Douglas }
57444d30d62SAlan Douglas 
57544d30d62SAlan Douglas static int cdns_sierra_phy_on(struct phy *gphy)
57644d30d62SAlan Douglas {
577adc4bd6fSKishon Vijay Abraham I 	struct cdns_sierra_phy *sp = dev_get_drvdata(gphy->dev.parent);
57844d30d62SAlan Douglas 	struct cdns_sierra_inst *ins = phy_get_drvdata(gphy);
579adc4bd6fSKishon Vijay Abraham I 	struct device *dev = sp->dev;
580adc4bd6fSKishon Vijay Abraham I 	u32 val;
581adc4bd6fSKishon Vijay Abraham I 	int ret;
58244d30d62SAlan Douglas 
5836b81f05aSSwapnil Jakhade 	if (sp->nsubnodes == 1) {
5846b81f05aSSwapnil Jakhade 		/* Take the PHY out of reset */
5855b4f5757SKishon Vijay Abraham I 		ret = reset_control_deassert(sp->phy_rst);
5865b4f5757SKishon Vijay Abraham I 		if (ret) {
5875b4f5757SKishon Vijay Abraham I 			dev_err(dev, "Failed to take the PHY out of reset\n");
5885b4f5757SKishon Vijay Abraham I 			return ret;
5895b4f5757SKishon Vijay Abraham I 		}
5906b81f05aSSwapnil Jakhade 	}
5915b4f5757SKishon Vijay Abraham I 
59244d30d62SAlan Douglas 	/* Take the PHY lane group out of reset */
593adc4bd6fSKishon Vijay Abraham I 	ret = reset_control_deassert(ins->lnk_rst);
594adc4bd6fSKishon Vijay Abraham I 	if (ret) {
595adc4bd6fSKishon Vijay Abraham I 		dev_err(dev, "Failed to take the PHY lane out of reset\n");
596adc4bd6fSKishon Vijay Abraham I 		return ret;
597adc4bd6fSKishon Vijay Abraham I 	}
598adc4bd6fSKishon Vijay Abraham I 
59936ce4163SSwapnil Jakhade 	if (ins->phy_type == TYPE_PCIE || ins->phy_type == TYPE_USB) {
60036ce4163SSwapnil Jakhade 		ret = regmap_field_read_poll_timeout(sp->phy_iso_link_ctrl_1[ins->mlane],
60136ce4163SSwapnil Jakhade 						     val, !val, 1000, PLL_LOCK_TIME);
60236ce4163SSwapnil Jakhade 		if (ret) {
60336ce4163SSwapnil Jakhade 			dev_err(dev, "Timeout waiting for PHY status ready\n");
60436ce4163SSwapnil Jakhade 			return ret;
60536ce4163SSwapnil Jakhade 		}
60636ce4163SSwapnil Jakhade 	}
60736ce4163SSwapnil Jakhade 
608f1cc6c3fSSwapnil Jakhade 	/*
609f1cc6c3fSSwapnil Jakhade 	 * Wait for cmn_ready assertion
610f1cc6c3fSSwapnil Jakhade 	 * PHY_PMA_CMN_CTRL[0] == 1
611f1cc6c3fSSwapnil Jakhade 	 */
612f1cc6c3fSSwapnil Jakhade 	ret = regmap_field_read_poll_timeout(sp->pma_cmn_ready, val, val,
613f1cc6c3fSSwapnil Jakhade 					     1000, PLL_LOCK_TIME);
614f1cc6c3fSSwapnil Jakhade 	if (ret) {
615f1cc6c3fSSwapnil Jakhade 		dev_err(dev, "Timeout waiting for CMN ready\n");
616f1cc6c3fSSwapnil Jakhade 		return ret;
617f1cc6c3fSSwapnil Jakhade 	}
618f1cc6c3fSSwapnil Jakhade 
619adc4bd6fSKishon Vijay Abraham I 	ret = regmap_field_read_poll_timeout(sp->pllctrl_lock[ins->mlane],
620adc4bd6fSKishon Vijay Abraham I 					     val, val, 1000, PLL_LOCK_TIME);
621adc4bd6fSKishon Vijay Abraham I 	if (ret < 0)
622adc4bd6fSKishon Vijay Abraham I 		dev_err(dev, "PLL lock of lane failed\n");
623adc4bd6fSKishon Vijay Abraham I 
624adc4bd6fSKishon Vijay Abraham I 	return ret;
62544d30d62SAlan Douglas }
62644d30d62SAlan Douglas 
62744d30d62SAlan Douglas static int cdns_sierra_phy_off(struct phy *gphy)
62844d30d62SAlan Douglas {
62944d30d62SAlan Douglas 	struct cdns_sierra_inst *ins = phy_get_drvdata(gphy);
63044d30d62SAlan Douglas 
63144d30d62SAlan Douglas 	return reset_control_assert(ins->lnk_rst);
63244d30d62SAlan Douglas }
63344d30d62SAlan Douglas 
6347904e15bSRoger Quadros static int cdns_sierra_phy_reset(struct phy *gphy)
6357904e15bSRoger Quadros {
6367904e15bSRoger Quadros 	struct cdns_sierra_phy *sp = dev_get_drvdata(gphy->dev.parent);
6377904e15bSRoger Quadros 
6387904e15bSRoger Quadros 	reset_control_assert(sp->phy_rst);
6397904e15bSRoger Quadros 	reset_control_deassert(sp->phy_rst);
6407904e15bSRoger Quadros 	return 0;
6417904e15bSRoger Quadros };
6427904e15bSRoger Quadros 
64344d30d62SAlan Douglas static const struct phy_ops ops = {
644cedcc2e2SKishon Vijay Abraham I 	.init		= cdns_sierra_phy_init,
64544d30d62SAlan Douglas 	.power_on	= cdns_sierra_phy_on,
64644d30d62SAlan Douglas 	.power_off	= cdns_sierra_phy_off,
6477904e15bSRoger Quadros 	.reset		= cdns_sierra_phy_reset,
64844d30d62SAlan Douglas 	.owner		= THIS_MODULE,
64944d30d62SAlan Douglas };
65044d30d62SAlan Douglas 
651d88ca22dSAswath Govindraju static int cdns_sierra_noop_phy_on(struct phy *gphy)
652d88ca22dSAswath Govindraju {
653d88ca22dSAswath Govindraju 	usleep_range(5000, 10000);
654d88ca22dSAswath Govindraju 
655d88ca22dSAswath Govindraju 	return 0;
656d88ca22dSAswath Govindraju }
657d88ca22dSAswath Govindraju 
658d88ca22dSAswath Govindraju static const struct phy_ops noop_ops = {
659d88ca22dSAswath Govindraju 	.power_on	= cdns_sierra_noop_phy_on,
660d88ca22dSAswath Govindraju 	.owner		= THIS_MODULE,
661d88ca22dSAswath Govindraju };
662d88ca22dSAswath Govindraju 
66328081b72SKishon Vijay Abraham I static u8 cdns_sierra_pll_mux_get_parent(struct clk_hw *hw)
66428081b72SKishon Vijay Abraham I {
66528081b72SKishon Vijay Abraham I 	struct cdns_sierra_pll_mux *mux = to_cdns_sierra_pll_mux(hw);
666da08aab9SSwapnil Jakhade 	struct regmap_field *plllc1en_field = mux->plllc1en_field;
667da08aab9SSwapnil Jakhade 	struct regmap_field *termen_field = mux->termen_field;
66828081b72SKishon Vijay Abraham I 	struct regmap_field *field = mux->pfdclk_sel_preg;
66928081b72SKishon Vijay Abraham I 	unsigned int val;
670da08aab9SSwapnil Jakhade 	int index;
67128081b72SKishon Vijay Abraham I 
67228081b72SKishon Vijay Abraham I 	regmap_field_read(field, &val);
673da08aab9SSwapnil Jakhade 
674da08aab9SSwapnil Jakhade 	if (strstr(clk_hw_get_name(hw), clk_names[CDNS_SIERRA_PLL_CMNLC1])) {
675da08aab9SSwapnil Jakhade 		index = clk_mux_val_to_index(hw, cdns_sierra_pll_mux_table[CMN_PLLLC1], 0, val);
676da08aab9SSwapnil Jakhade 		if (index == 1) {
677da08aab9SSwapnil Jakhade 			regmap_field_write(plllc1en_field, 1);
678da08aab9SSwapnil Jakhade 			regmap_field_write(termen_field, 1);
679da08aab9SSwapnil Jakhade 		}
680da08aab9SSwapnil Jakhade 	} else {
681da08aab9SSwapnil Jakhade 		index = clk_mux_val_to_index(hw, cdns_sierra_pll_mux_table[CMN_PLLLC], 0, val);
682da08aab9SSwapnil Jakhade 	}
683da08aab9SSwapnil Jakhade 
684da08aab9SSwapnil Jakhade 	return index;
68528081b72SKishon Vijay Abraham I }
68628081b72SKishon Vijay Abraham I 
68728081b72SKishon Vijay Abraham I static int cdns_sierra_pll_mux_set_parent(struct clk_hw *hw, u8 index)
68828081b72SKishon Vijay Abraham I {
68928081b72SKishon Vijay Abraham I 	struct cdns_sierra_pll_mux *mux = to_cdns_sierra_pll_mux(hw);
69028081b72SKishon Vijay Abraham I 	struct regmap_field *plllc1en_field = mux->plllc1en_field;
69128081b72SKishon Vijay Abraham I 	struct regmap_field *termen_field = mux->termen_field;
69228081b72SKishon Vijay Abraham I 	struct regmap_field *field = mux->pfdclk_sel_preg;
69328081b72SKishon Vijay Abraham I 	int val, ret;
69428081b72SKishon Vijay Abraham I 
69528081b72SKishon Vijay Abraham I 	ret = regmap_field_write(plllc1en_field, 0);
69628081b72SKishon Vijay Abraham I 	ret |= regmap_field_write(termen_field, 0);
69728081b72SKishon Vijay Abraham I 	if (index == 1) {
69828081b72SKishon Vijay Abraham I 		ret |= regmap_field_write(plllc1en_field, 1);
69928081b72SKishon Vijay Abraham I 		ret |= regmap_field_write(termen_field, 1);
70028081b72SKishon Vijay Abraham I 	}
70128081b72SKishon Vijay Abraham I 
702da08aab9SSwapnil Jakhade 	if (strstr(clk_hw_get_name(hw), clk_names[CDNS_SIERRA_PLL_CMNLC1]))
703da08aab9SSwapnil Jakhade 		val = cdns_sierra_pll_mux_table[CMN_PLLLC1][index];
704da08aab9SSwapnil Jakhade 	else
705da08aab9SSwapnil Jakhade 		val = cdns_sierra_pll_mux_table[CMN_PLLLC][index];
706da08aab9SSwapnil Jakhade 
70728081b72SKishon Vijay Abraham I 	ret |= regmap_field_write(field, val);
70828081b72SKishon Vijay Abraham I 
70928081b72SKishon Vijay Abraham I 	return ret;
71028081b72SKishon Vijay Abraham I }
71128081b72SKishon Vijay Abraham I 
71228081b72SKishon Vijay Abraham I static const struct clk_ops cdns_sierra_pll_mux_ops = {
71328081b72SKishon Vijay Abraham I 	.set_parent = cdns_sierra_pll_mux_set_parent,
71428081b72SKishon Vijay Abraham I 	.get_parent = cdns_sierra_pll_mux_get_parent,
71528081b72SKishon Vijay Abraham I };
71628081b72SKishon Vijay Abraham I 
71728081b72SKishon Vijay Abraham I static int cdns_sierra_pll_mux_register(struct cdns_sierra_phy *sp,
71828081b72SKishon Vijay Abraham I 					struct regmap_field *pfdclk1_sel_field,
71928081b72SKishon Vijay Abraham I 					struct regmap_field *plllc1en_field,
72028081b72SKishon Vijay Abraham I 					struct regmap_field *termen_field,
72128081b72SKishon Vijay Abraham I 					int clk_index)
72228081b72SKishon Vijay Abraham I {
72328081b72SKishon Vijay Abraham I 	struct cdns_sierra_pll_mux *mux;
72428081b72SKishon Vijay Abraham I 	struct device *dev = sp->dev;
72528081b72SKishon Vijay Abraham I 	struct clk_init_data *init;
72628081b72SKishon Vijay Abraham I 	const char **parent_names;
72728081b72SKishon Vijay Abraham I 	unsigned int num_parents;
72828081b72SKishon Vijay Abraham I 	char clk_name[100];
72928081b72SKishon Vijay Abraham I 	struct clk *clk;
73028081b72SKishon Vijay Abraham I 	int i;
73128081b72SKishon Vijay Abraham I 
73228081b72SKishon Vijay Abraham I 	mux = devm_kzalloc(dev, sizeof(*mux), GFP_KERNEL);
73328081b72SKishon Vijay Abraham I 	if (!mux)
73428081b72SKishon Vijay Abraham I 		return -ENOMEM;
73528081b72SKishon Vijay Abraham I 
73628081b72SKishon Vijay Abraham I 	num_parents = SIERRA_NUM_CMN_PLLC_PARENTS;
73728081b72SKishon Vijay Abraham I 	parent_names = devm_kzalloc(dev, (sizeof(char *) * num_parents), GFP_KERNEL);
73828081b72SKishon Vijay Abraham I 	if (!parent_names)
73928081b72SKishon Vijay Abraham I 		return -ENOMEM;
74028081b72SKishon Vijay Abraham I 
74128081b72SKishon Vijay Abraham I 	for (i = 0; i < num_parents; i++) {
74228081b72SKishon Vijay Abraham I 		clk = sp->input_clks[pll_mux_parent_index[clk_index][i]];
74328081b72SKishon Vijay Abraham I 		if (IS_ERR_OR_NULL(clk)) {
744da08aab9SSwapnil Jakhade 			dev_err(dev, "No parent clock for PLL mux clocks\n");
745da08aab9SSwapnil Jakhade 			return IS_ERR(clk) ? PTR_ERR(clk) : -ENOENT;
74628081b72SKishon Vijay Abraham I 		}
74728081b72SKishon Vijay Abraham I 		parent_names[i] = __clk_get_name(clk);
74828081b72SKishon Vijay Abraham I 	}
74928081b72SKishon Vijay Abraham I 
75028081b72SKishon Vijay Abraham I 	snprintf(clk_name, sizeof(clk_name), "%s_%s", dev_name(dev), clk_names[clk_index]);
75128081b72SKishon Vijay Abraham I 
75228081b72SKishon Vijay Abraham I 	init = &mux->clk_data;
75328081b72SKishon Vijay Abraham I 
75428081b72SKishon Vijay Abraham I 	init->ops = &cdns_sierra_pll_mux_ops;
75528081b72SKishon Vijay Abraham I 	init->flags = CLK_SET_RATE_NO_REPARENT;
75628081b72SKishon Vijay Abraham I 	init->parent_names = parent_names;
75728081b72SKishon Vijay Abraham I 	init->num_parents = num_parents;
75828081b72SKishon Vijay Abraham I 	init->name = clk_name;
75928081b72SKishon Vijay Abraham I 
76028081b72SKishon Vijay Abraham I 	mux->pfdclk_sel_preg = pfdclk1_sel_field;
76128081b72SKishon Vijay Abraham I 	mux->plllc1en_field = plllc1en_field;
76228081b72SKishon Vijay Abraham I 	mux->termen_field = termen_field;
76328081b72SKishon Vijay Abraham I 	mux->hw.init = init;
76428081b72SKishon Vijay Abraham I 
76528081b72SKishon Vijay Abraham I 	clk = devm_clk_register(dev, &mux->hw);
76628081b72SKishon Vijay Abraham I 	if (IS_ERR(clk))
76728081b72SKishon Vijay Abraham I 		return PTR_ERR(clk);
76828081b72SKishon Vijay Abraham I 
76928081b72SKishon Vijay Abraham I 	sp->output_clks[clk_index] = clk;
77028081b72SKishon Vijay Abraham I 
77128081b72SKishon Vijay Abraham I 	return 0;
77228081b72SKishon Vijay Abraham I }
77328081b72SKishon Vijay Abraham I 
77428081b72SKishon Vijay Abraham I static int cdns_sierra_phy_register_pll_mux(struct cdns_sierra_phy *sp)
77528081b72SKishon Vijay Abraham I {
77628081b72SKishon Vijay Abraham I 	struct regmap_field *pfdclk1_sel_field;
77728081b72SKishon Vijay Abraham I 	struct regmap_field *plllc1en_field;
77828081b72SKishon Vijay Abraham I 	struct regmap_field *termen_field;
77928081b72SKishon Vijay Abraham I 	struct device *dev = sp->dev;
78028081b72SKishon Vijay Abraham I 	int ret = 0, i, clk_index;
78128081b72SKishon Vijay Abraham I 
78228081b72SKishon Vijay Abraham I 	clk_index = CDNS_SIERRA_PLL_CMNLC;
78328081b72SKishon Vijay Abraham I 	for (i = 0; i < SIERRA_NUM_CMN_PLLC; i++, clk_index++) {
78428081b72SKishon Vijay Abraham I 		pfdclk1_sel_field = sp->cmn_plllc_pfdclk1_sel_preg[i];
78528081b72SKishon Vijay Abraham I 		plllc1en_field = sp->cmn_refrcv_refclk_plllc1en_preg[i];
78628081b72SKishon Vijay Abraham I 		termen_field = sp->cmn_refrcv_refclk_termen_preg[i];
78728081b72SKishon Vijay Abraham I 
78828081b72SKishon Vijay Abraham I 		ret = cdns_sierra_pll_mux_register(sp, pfdclk1_sel_field, plllc1en_field,
78928081b72SKishon Vijay Abraham I 						   termen_field, clk_index);
79028081b72SKishon Vijay Abraham I 		if (ret) {
79128081b72SKishon Vijay Abraham I 			dev_err(dev, "Fail to register cmn plllc mux\n");
79228081b72SKishon Vijay Abraham I 			return ret;
79328081b72SKishon Vijay Abraham I 		}
79428081b72SKishon Vijay Abraham I 	}
79528081b72SKishon Vijay Abraham I 
79628081b72SKishon Vijay Abraham I 	return 0;
79728081b72SKishon Vijay Abraham I }
79828081b72SKishon Vijay Abraham I 
79909d976b3SSwapnil Jakhade static int cdns_sierra_derived_refclk_enable(struct clk_hw *hw)
80009d976b3SSwapnil Jakhade {
80109d976b3SSwapnil Jakhade 	struct cdns_sierra_derived_refclk *derived_refclk = to_cdns_sierra_derived_refclk(hw);
80209d976b3SSwapnil Jakhade 
80309d976b3SSwapnil Jakhade 	regmap_field_write(derived_refclk->cmn_plllc_clk1_en_preg, 0x1);
80409d976b3SSwapnil Jakhade 
80509d976b3SSwapnil Jakhade 	/* Programming to get 100Mhz clock output in ref_der_clk_out 5GHz VCO/50 = 100MHz */
80609d976b3SSwapnil Jakhade 	regmap_field_write(derived_refclk->cmn_plllc_clk1outdiv_preg, 0x2E);
80709d976b3SSwapnil Jakhade 
80809d976b3SSwapnil Jakhade 	return 0;
80909d976b3SSwapnil Jakhade }
81009d976b3SSwapnil Jakhade 
81109d976b3SSwapnil Jakhade static void cdns_sierra_derived_refclk_disable(struct clk_hw *hw)
81209d976b3SSwapnil Jakhade {
81309d976b3SSwapnil Jakhade 	struct cdns_sierra_derived_refclk *derived_refclk = to_cdns_sierra_derived_refclk(hw);
81409d976b3SSwapnil Jakhade 
81509d976b3SSwapnil Jakhade 	regmap_field_write(derived_refclk->cmn_plllc_clk1_en_preg, 0);
81609d976b3SSwapnil Jakhade }
81709d976b3SSwapnil Jakhade 
81809d976b3SSwapnil Jakhade static int cdns_sierra_derived_refclk_is_enabled(struct clk_hw *hw)
81909d976b3SSwapnil Jakhade {
82009d976b3SSwapnil Jakhade 	struct cdns_sierra_derived_refclk *derived_refclk = to_cdns_sierra_derived_refclk(hw);
82109d976b3SSwapnil Jakhade 	int val;
82209d976b3SSwapnil Jakhade 
82309d976b3SSwapnil Jakhade 	regmap_field_read(derived_refclk->cmn_plllc_clk1_en_preg, &val);
82409d976b3SSwapnil Jakhade 
82509d976b3SSwapnil Jakhade 	return !!val;
82609d976b3SSwapnil Jakhade }
82709d976b3SSwapnil Jakhade 
82809d976b3SSwapnil Jakhade static const struct clk_ops cdns_sierra_derived_refclk_ops = {
82909d976b3SSwapnil Jakhade 	.enable = cdns_sierra_derived_refclk_enable,
83009d976b3SSwapnil Jakhade 	.disable = cdns_sierra_derived_refclk_disable,
83109d976b3SSwapnil Jakhade 	.is_enabled = cdns_sierra_derived_refclk_is_enabled,
83209d976b3SSwapnil Jakhade };
83309d976b3SSwapnil Jakhade 
83409d976b3SSwapnil Jakhade static int cdns_sierra_derived_refclk_register(struct cdns_sierra_phy *sp)
83509d976b3SSwapnil Jakhade {
83609d976b3SSwapnil Jakhade 	struct cdns_sierra_derived_refclk *derived_refclk;
83709d976b3SSwapnil Jakhade 	struct device *dev = sp->dev;
83809d976b3SSwapnil Jakhade 	struct regmap_field *field;
83909d976b3SSwapnil Jakhade 	struct clk_init_data *init;
84009d976b3SSwapnil Jakhade 	struct regmap *regmap;
84109d976b3SSwapnil Jakhade 	char clk_name[100];
84209d976b3SSwapnil Jakhade 	struct clk *clk;
84309d976b3SSwapnil Jakhade 
84409d976b3SSwapnil Jakhade 	derived_refclk = devm_kzalloc(dev, sizeof(*derived_refclk), GFP_KERNEL);
84509d976b3SSwapnil Jakhade 	if (!derived_refclk)
84609d976b3SSwapnil Jakhade 		return -ENOMEM;
84709d976b3SSwapnil Jakhade 
84809d976b3SSwapnil Jakhade 	snprintf(clk_name, sizeof(clk_name), "%s_%s", dev_name(dev),
84909d976b3SSwapnil Jakhade 		 clk_names[CDNS_SIERRA_DERIVED_REFCLK]);
85009d976b3SSwapnil Jakhade 
85109d976b3SSwapnil Jakhade 	init = &derived_refclk->clk_data;
85209d976b3SSwapnil Jakhade 
85309d976b3SSwapnil Jakhade 	init->ops = &cdns_sierra_derived_refclk_ops;
85409d976b3SSwapnil Jakhade 	init->flags = 0;
85509d976b3SSwapnil Jakhade 	init->name = clk_name;
85609d976b3SSwapnil Jakhade 
85709d976b3SSwapnil Jakhade 	regmap = sp->regmap_common_cdb;
85809d976b3SSwapnil Jakhade 
85909d976b3SSwapnil Jakhade 	field = devm_regmap_field_alloc(dev, regmap, cmn_plllc_clk1outdiv_preg);
86009d976b3SSwapnil Jakhade 	if (IS_ERR(field)) {
86109d976b3SSwapnil Jakhade 		dev_err(dev, "cmn_plllc_clk1outdiv_preg reg field init failed\n");
86209d976b3SSwapnil Jakhade 		return PTR_ERR(field);
86309d976b3SSwapnil Jakhade 	}
86409d976b3SSwapnil Jakhade 	derived_refclk->cmn_plllc_clk1outdiv_preg = field;
86509d976b3SSwapnil Jakhade 
86609d976b3SSwapnil Jakhade 	field = devm_regmap_field_alloc(dev, regmap, cmn_plllc_clk1_en_preg);
86709d976b3SSwapnil Jakhade 	if (IS_ERR(field)) {
86809d976b3SSwapnil Jakhade 		dev_err(dev, "cmn_plllc_clk1_en_preg reg field init failed\n");
86909d976b3SSwapnil Jakhade 		return PTR_ERR(field);
87009d976b3SSwapnil Jakhade 	}
87109d976b3SSwapnil Jakhade 	derived_refclk->cmn_plllc_clk1_en_preg = field;
87209d976b3SSwapnil Jakhade 
87309d976b3SSwapnil Jakhade 	derived_refclk->hw.init = init;
87409d976b3SSwapnil Jakhade 
87509d976b3SSwapnil Jakhade 	clk = devm_clk_register(dev, &derived_refclk->hw);
87609d976b3SSwapnil Jakhade 	if (IS_ERR(clk))
87709d976b3SSwapnil Jakhade 		return PTR_ERR(clk);
87809d976b3SSwapnil Jakhade 
87909d976b3SSwapnil Jakhade 	sp->output_clks[CDNS_SIERRA_DERIVED_REFCLK] = clk;
88009d976b3SSwapnil Jakhade 
88109d976b3SSwapnil Jakhade 	return 0;
88209d976b3SSwapnil Jakhade }
88309d976b3SSwapnil Jakhade 
88428081b72SKishon Vijay Abraham I static void cdns_sierra_clk_unregister(struct cdns_sierra_phy *sp)
88528081b72SKishon Vijay Abraham I {
88628081b72SKishon Vijay Abraham I 	struct device *dev = sp->dev;
88728081b72SKishon Vijay Abraham I 	struct device_node *node = dev->of_node;
88828081b72SKishon Vijay Abraham I 
88928081b72SKishon Vijay Abraham I 	of_clk_del_provider(node);
89028081b72SKishon Vijay Abraham I }
89128081b72SKishon Vijay Abraham I 
89228081b72SKishon Vijay Abraham I static int cdns_sierra_clk_register(struct cdns_sierra_phy *sp)
89328081b72SKishon Vijay Abraham I {
89428081b72SKishon Vijay Abraham I 	struct device *dev = sp->dev;
89528081b72SKishon Vijay Abraham I 	struct device_node *node = dev->of_node;
89628081b72SKishon Vijay Abraham I 	int ret;
89728081b72SKishon Vijay Abraham I 
89828081b72SKishon Vijay Abraham I 	ret = cdns_sierra_phy_register_pll_mux(sp);
89928081b72SKishon Vijay Abraham I 	if (ret) {
90028081b72SKishon Vijay Abraham I 		dev_err(dev, "Failed to pll mux clocks\n");
90128081b72SKishon Vijay Abraham I 		return ret;
90228081b72SKishon Vijay Abraham I 	}
90328081b72SKishon Vijay Abraham I 
90409d976b3SSwapnil Jakhade 	ret = cdns_sierra_derived_refclk_register(sp);
90509d976b3SSwapnil Jakhade 	if (ret) {
90609d976b3SSwapnil Jakhade 		dev_err(dev, "Failed to register derived refclk\n");
90709d976b3SSwapnil Jakhade 		return ret;
90809d976b3SSwapnil Jakhade 	}
90909d976b3SSwapnil Jakhade 
91028081b72SKishon Vijay Abraham I 	sp->clk_data.clks = sp->output_clks;
91128081b72SKishon Vijay Abraham I 	sp->clk_data.clk_num = CDNS_SIERRA_OUTPUT_CLOCKS;
91228081b72SKishon Vijay Abraham I 	ret = of_clk_add_provider(node, of_clk_src_onecell_get, &sp->clk_data);
91328081b72SKishon Vijay Abraham I 	if (ret)
91428081b72SKishon Vijay Abraham I 		dev_err(dev, "Failed to add clock provider: %s\n", node->name);
91528081b72SKishon Vijay Abraham I 
91628081b72SKishon Vijay Abraham I 	return ret;
91728081b72SKishon Vijay Abraham I }
91828081b72SKishon Vijay Abraham I 
91944d30d62SAlan Douglas static int cdns_sierra_get_optional(struct cdns_sierra_inst *inst,
92044d30d62SAlan Douglas 				    struct device_node *child)
92144d30d62SAlan Douglas {
922078e9e92SSwapnil Jakhade 	u32 phy_type;
923078e9e92SSwapnil Jakhade 
92444d30d62SAlan Douglas 	if (of_property_read_u32(child, "reg", &inst->mlane))
92544d30d62SAlan Douglas 		return -EINVAL;
92644d30d62SAlan Douglas 
92744d30d62SAlan Douglas 	if (of_property_read_u32(child, "cdns,num-lanes", &inst->num_lanes))
92844d30d62SAlan Douglas 		return -EINVAL;
92944d30d62SAlan Douglas 
930078e9e92SSwapnil Jakhade 	if (of_property_read_u32(child, "cdns,phy-type", &phy_type))
93144d30d62SAlan Douglas 		return -EINVAL;
93244d30d62SAlan Douglas 
933078e9e92SSwapnil Jakhade 	switch (phy_type) {
934078e9e92SSwapnil Jakhade 	case PHY_TYPE_PCIE:
935078e9e92SSwapnil Jakhade 		inst->phy_type = TYPE_PCIE;
936078e9e92SSwapnil Jakhade 		break;
937078e9e92SSwapnil Jakhade 	case PHY_TYPE_USB3:
938078e9e92SSwapnil Jakhade 		inst->phy_type = TYPE_USB;
939078e9e92SSwapnil Jakhade 		break;
9408a1b82d7SSwapnil Jakhade 	case PHY_TYPE_QSGMII:
9418a1b82d7SSwapnil Jakhade 		inst->phy_type = TYPE_QSGMII;
9428a1b82d7SSwapnil Jakhade 		break;
943078e9e92SSwapnil Jakhade 	default:
944078e9e92SSwapnil Jakhade 		return -EINVAL;
945078e9e92SSwapnil Jakhade 	}
946078e9e92SSwapnil Jakhade 
9471e902b2aSSwapnil Jakhade 	inst->ssc_mode = EXTERNAL_SSC;
9481e902b2aSSwapnil Jakhade 	of_property_read_u32(child, "cdns,ssc-mode", &inst->ssc_mode);
9491e902b2aSSwapnil Jakhade 
95044d30d62SAlan Douglas 	return 0;
95144d30d62SAlan Douglas }
95244d30d62SAlan Douglas 
953380f5708SKishon Vijay Abraham I static struct regmap *cdns_regmap_init(struct device *dev, void __iomem *base,
954380f5708SKishon Vijay Abraham I 				       u32 block_offset, u8 reg_offset_shift,
955380f5708SKishon Vijay Abraham I 				       const struct regmap_config *config)
956380f5708SKishon Vijay Abraham I {
957380f5708SKishon Vijay Abraham I 	struct cdns_regmap_cdb_context *ctx;
958380f5708SKishon Vijay Abraham I 
959380f5708SKishon Vijay Abraham I 	ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
960380f5708SKishon Vijay Abraham I 	if (!ctx)
961380f5708SKishon Vijay Abraham I 		return ERR_PTR(-ENOMEM);
962380f5708SKishon Vijay Abraham I 
963380f5708SKishon Vijay Abraham I 	ctx->dev = dev;
964380f5708SKishon Vijay Abraham I 	ctx->base = base + block_offset;
965380f5708SKishon Vijay Abraham I 	ctx->reg_offset_shift = reg_offset_shift;
966380f5708SKishon Vijay Abraham I 
967380f5708SKishon Vijay Abraham I 	return devm_regmap_init(dev, NULL, ctx, config);
968380f5708SKishon Vijay Abraham I }
969380f5708SKishon Vijay Abraham I 
970380f5708SKishon Vijay Abraham I static int cdns_regfield_init(struct cdns_sierra_phy *sp)
971380f5708SKishon Vijay Abraham I {
972380f5708SKishon Vijay Abraham I 	struct device *dev = sp->dev;
973380f5708SKishon Vijay Abraham I 	struct regmap_field *field;
97428081b72SKishon Vijay Abraham I 	struct reg_field reg_field;
975380f5708SKishon Vijay Abraham I 	struct regmap *regmap;
976adc4bd6fSKishon Vijay Abraham I 	int i;
977380f5708SKishon Vijay Abraham I 
978380f5708SKishon Vijay Abraham I 	regmap = sp->regmap_common_cdb;
979380f5708SKishon Vijay Abraham I 	field = devm_regmap_field_alloc(dev, regmap, macro_id_type);
980380f5708SKishon Vijay Abraham I 	if (IS_ERR(field)) {
981380f5708SKishon Vijay Abraham I 		dev_err(dev, "MACRO_ID_TYPE reg field init failed\n");
982380f5708SKishon Vijay Abraham I 		return PTR_ERR(field);
983380f5708SKishon Vijay Abraham I 	}
984380f5708SKishon Vijay Abraham I 	sp->macro_id_type = field;
985380f5708SKishon Vijay Abraham I 
98628081b72SKishon Vijay Abraham I 	for (i = 0; i < SIERRA_NUM_CMN_PLLC; i++) {
98728081b72SKishon Vijay Abraham I 		reg_field = cmn_plllc_pfdclk1_sel_preg[i].pfdclk_sel_preg;
98828081b72SKishon Vijay Abraham I 		field = devm_regmap_field_alloc(dev, regmap, reg_field);
98928081b72SKishon Vijay Abraham I 		if (IS_ERR(field)) {
99028081b72SKishon Vijay Abraham I 			dev_err(dev, "PLLLC%d_PFDCLK1_SEL failed\n", i);
99128081b72SKishon Vijay Abraham I 			return PTR_ERR(field);
99228081b72SKishon Vijay Abraham I 		}
99328081b72SKishon Vijay Abraham I 		sp->cmn_plllc_pfdclk1_sel_preg[i] = field;
99428081b72SKishon Vijay Abraham I 
99528081b72SKishon Vijay Abraham I 		reg_field = cmn_plllc_pfdclk1_sel_preg[i].plllc1en_field;
99628081b72SKishon Vijay Abraham I 		field = devm_regmap_field_alloc(dev, regmap, reg_field);
99728081b72SKishon Vijay Abraham I 		if (IS_ERR(field)) {
99828081b72SKishon Vijay Abraham I 			dev_err(dev, "REFRCV%d_REFCLK_PLLLC1EN failed\n", i);
99928081b72SKishon Vijay Abraham I 			return PTR_ERR(field);
100028081b72SKishon Vijay Abraham I 		}
100128081b72SKishon Vijay Abraham I 		sp->cmn_refrcv_refclk_plllc1en_preg[i] = field;
100228081b72SKishon Vijay Abraham I 
100328081b72SKishon Vijay Abraham I 		reg_field = cmn_plllc_pfdclk1_sel_preg[i].termen_field;
100428081b72SKishon Vijay Abraham I 		field = devm_regmap_field_alloc(dev, regmap, reg_field);
100528081b72SKishon Vijay Abraham I 		if (IS_ERR(field)) {
100628081b72SKishon Vijay Abraham I 			dev_err(dev, "REFRCV%d_REFCLK_TERMEN failed\n", i);
100728081b72SKishon Vijay Abraham I 			return PTR_ERR(field);
100828081b72SKishon Vijay Abraham I 		}
100928081b72SKishon Vijay Abraham I 		sp->cmn_refrcv_refclk_termen_preg[i] = field;
101028081b72SKishon Vijay Abraham I 	}
101128081b72SKishon Vijay Abraham I 
10128c95e172SSwapnil Jakhade 	regmap = sp->regmap_phy_pcs_common_cdb;
1013380f5708SKishon Vijay Abraham I 	field = devm_regmap_field_alloc(dev, regmap, phy_pll_cfg_1);
1014380f5708SKishon Vijay Abraham I 	if (IS_ERR(field)) {
1015380f5708SKishon Vijay Abraham I 		dev_err(dev, "PHY_PLL_CFG_1 reg field init failed\n");
1016380f5708SKishon Vijay Abraham I 		return PTR_ERR(field);
1017380f5708SKishon Vijay Abraham I 	}
1018380f5708SKishon Vijay Abraham I 	sp->phy_pll_cfg_1 = field;
1019380f5708SKishon Vijay Abraham I 
1020f1cc6c3fSSwapnil Jakhade 	regmap = sp->regmap_phy_pma_common_cdb;
1021f1cc6c3fSSwapnil Jakhade 	field = devm_regmap_field_alloc(dev, regmap, pma_cmn_ready);
1022f1cc6c3fSSwapnil Jakhade 	if (IS_ERR(field)) {
1023f1cc6c3fSSwapnil Jakhade 		dev_err(dev, "PHY_PMA_CMN_CTRL reg field init failed\n");
1024f1cc6c3fSSwapnil Jakhade 		return PTR_ERR(field);
1025f1cc6c3fSSwapnil Jakhade 	}
1026f1cc6c3fSSwapnil Jakhade 	sp->pma_cmn_ready = field;
1027f1cc6c3fSSwapnil Jakhade 
1028adc4bd6fSKishon Vijay Abraham I 	for (i = 0; i < SIERRA_MAX_LANES; i++) {
1029adc4bd6fSKishon Vijay Abraham I 		regmap = sp->regmap_lane_cdb[i];
1030adc4bd6fSKishon Vijay Abraham I 		field = devm_regmap_field_alloc(dev, regmap, pllctrl_lock);
1031adc4bd6fSKishon Vijay Abraham I 		if (IS_ERR(field)) {
1032adc4bd6fSKishon Vijay Abraham I 			dev_err(dev, "P%d_ENABLE reg field init failed\n", i);
1033adc4bd6fSKishon Vijay Abraham I 			return PTR_ERR(field);
1034adc4bd6fSKishon Vijay Abraham I 		}
1035adc4bd6fSKishon Vijay Abraham I 		sp->pllctrl_lock[i] = field;
1036adc4bd6fSKishon Vijay Abraham I 	}
1037adc4bd6fSKishon Vijay Abraham I 
103836ce4163SSwapnil Jakhade 	for (i = 0; i < SIERRA_MAX_LANES; i++) {
103936ce4163SSwapnil Jakhade 		regmap = sp->regmap_phy_pcs_lane_cdb[i];
104036ce4163SSwapnil Jakhade 		field = devm_regmap_field_alloc(dev, regmap, phy_iso_link_ctrl_1);
104136ce4163SSwapnil Jakhade 		if (IS_ERR(field)) {
104236ce4163SSwapnil Jakhade 			dev_err(dev, "PHY_ISO_LINK_CTRL reg field init for lane %d failed\n", i);
104336ce4163SSwapnil Jakhade 			return PTR_ERR(field);
104436ce4163SSwapnil Jakhade 		}
104536ce4163SSwapnil Jakhade 		sp->phy_iso_link_ctrl_1[i] = field;
104636ce4163SSwapnil Jakhade 	}
104736ce4163SSwapnil Jakhade 
1048380f5708SKishon Vijay Abraham I 	return 0;
1049380f5708SKishon Vijay Abraham I }
1050380f5708SKishon Vijay Abraham I 
1051380f5708SKishon Vijay Abraham I static int cdns_regmap_init_blocks(struct cdns_sierra_phy *sp,
1052380f5708SKishon Vijay Abraham I 				   void __iomem *base, u8 block_offset_shift,
1053380f5708SKishon Vijay Abraham I 				   u8 reg_offset_shift)
1054380f5708SKishon Vijay Abraham I {
1055380f5708SKishon Vijay Abraham I 	struct device *dev = sp->dev;
1056380f5708SKishon Vijay Abraham I 	struct regmap *regmap;
1057380f5708SKishon Vijay Abraham I 	u32 block_offset;
1058380f5708SKishon Vijay Abraham I 	int i;
1059380f5708SKishon Vijay Abraham I 
1060380f5708SKishon Vijay Abraham I 	for (i = 0; i < SIERRA_MAX_LANES; i++) {
1061380f5708SKishon Vijay Abraham I 		block_offset = SIERRA_LANE_CDB_OFFSET(i, block_offset_shift,
1062380f5708SKishon Vijay Abraham I 						      reg_offset_shift);
1063380f5708SKishon Vijay Abraham I 		regmap = cdns_regmap_init(dev, base, block_offset,
1064380f5708SKishon Vijay Abraham I 					  reg_offset_shift,
1065380f5708SKishon Vijay Abraham I 					  &cdns_sierra_lane_cdb_config[i]);
1066380f5708SKishon Vijay Abraham I 		if (IS_ERR(regmap)) {
1067380f5708SKishon Vijay Abraham I 			dev_err(dev, "Failed to init lane CDB regmap\n");
1068380f5708SKishon Vijay Abraham I 			return PTR_ERR(regmap);
1069380f5708SKishon Vijay Abraham I 		}
1070380f5708SKishon Vijay Abraham I 		sp->regmap_lane_cdb[i] = regmap;
1071380f5708SKishon Vijay Abraham I 	}
1072380f5708SKishon Vijay Abraham I 
1073380f5708SKishon Vijay Abraham I 	regmap = cdns_regmap_init(dev, base, SIERRA_COMMON_CDB_OFFSET,
1074380f5708SKishon Vijay Abraham I 				  reg_offset_shift,
1075380f5708SKishon Vijay Abraham I 				  &cdns_sierra_common_cdb_config);
1076380f5708SKishon Vijay Abraham I 	if (IS_ERR(regmap)) {
1077380f5708SKishon Vijay Abraham I 		dev_err(dev, "Failed to init common CDB regmap\n");
1078380f5708SKishon Vijay Abraham I 		return PTR_ERR(regmap);
1079380f5708SKishon Vijay Abraham I 	}
1080380f5708SKishon Vijay Abraham I 	sp->regmap_common_cdb = regmap;
1081380f5708SKishon Vijay Abraham I 
10828c95e172SSwapnil Jakhade 	block_offset = SIERRA_PHY_PCS_COMMON_OFFSET(block_offset_shift);
1083380f5708SKishon Vijay Abraham I 	regmap = cdns_regmap_init(dev, base, block_offset, reg_offset_shift,
10848c95e172SSwapnil Jakhade 				  &cdns_sierra_phy_pcs_cmn_cdb_config);
1085380f5708SKishon Vijay Abraham I 	if (IS_ERR(regmap)) {
10868c95e172SSwapnil Jakhade 		dev_err(dev, "Failed to init PHY PCS common CDB regmap\n");
1087380f5708SKishon Vijay Abraham I 		return PTR_ERR(regmap);
1088380f5708SKishon Vijay Abraham I 	}
10898c95e172SSwapnil Jakhade 	sp->regmap_phy_pcs_common_cdb = regmap;
1090380f5708SKishon Vijay Abraham I 
109136ce4163SSwapnil Jakhade 	for (i = 0; i < SIERRA_MAX_LANES; i++) {
109236ce4163SSwapnil Jakhade 		block_offset = SIERRA_PHY_PCS_LANE_CDB_OFFSET(i, block_offset_shift,
109336ce4163SSwapnil Jakhade 							      reg_offset_shift);
109436ce4163SSwapnil Jakhade 		regmap = cdns_regmap_init(dev, base, block_offset,
109536ce4163SSwapnil Jakhade 					  reg_offset_shift,
109636ce4163SSwapnil Jakhade 					  &cdns_sierra_phy_pcs_lane_cdb_config[i]);
109736ce4163SSwapnil Jakhade 		if (IS_ERR(regmap)) {
109836ce4163SSwapnil Jakhade 			dev_err(dev, "Failed to init PHY PCS lane CDB regmap\n");
109936ce4163SSwapnil Jakhade 			return PTR_ERR(regmap);
110036ce4163SSwapnil Jakhade 		}
110136ce4163SSwapnil Jakhade 		sp->regmap_phy_pcs_lane_cdb[i] = regmap;
110236ce4163SSwapnil Jakhade 	}
110336ce4163SSwapnil Jakhade 
1104f1cc6c3fSSwapnil Jakhade 	block_offset = SIERRA_PHY_PMA_COMMON_OFFSET(block_offset_shift);
1105f1cc6c3fSSwapnil Jakhade 	regmap = cdns_regmap_init(dev, base, block_offset, reg_offset_shift,
1106f1cc6c3fSSwapnil Jakhade 				  &cdns_sierra_phy_pma_cmn_cdb_config);
1107f1cc6c3fSSwapnil Jakhade 	if (IS_ERR(regmap)) {
1108f1cc6c3fSSwapnil Jakhade 		dev_err(dev, "Failed to init PHY PMA common CDB regmap\n");
1109f1cc6c3fSSwapnil Jakhade 		return PTR_ERR(regmap);
1110f1cc6c3fSSwapnil Jakhade 	}
1111f1cc6c3fSSwapnil Jakhade 	sp->regmap_phy_pma_common_cdb = regmap;
1112f1cc6c3fSSwapnil Jakhade 
11136b81f05aSSwapnil Jakhade 	for (i = 0; i < SIERRA_MAX_LANES; i++) {
11146b81f05aSSwapnil Jakhade 		block_offset = SIERRA_PHY_PMA_LANE_CDB_OFFSET(i, block_offset_shift,
11156b81f05aSSwapnil Jakhade 							      reg_offset_shift);
11166b81f05aSSwapnil Jakhade 		regmap = cdns_regmap_init(dev, base, block_offset,
11176b81f05aSSwapnil Jakhade 					  reg_offset_shift,
11186b81f05aSSwapnil Jakhade 					  &cdns_sierra_phy_pma_lane_cdb_config[i]);
11196b81f05aSSwapnil Jakhade 		if (IS_ERR(regmap)) {
11206b81f05aSSwapnil Jakhade 			dev_err(dev, "Failed to init PHY PMA lane CDB regmap\n");
11216b81f05aSSwapnil Jakhade 			return PTR_ERR(regmap);
11226b81f05aSSwapnil Jakhade 		}
11236b81f05aSSwapnil Jakhade 		sp->regmap_phy_pma_lane_cdb[i] = regmap;
11246b81f05aSSwapnil Jakhade 	}
11256b81f05aSSwapnil Jakhade 
1126380f5708SKishon Vijay Abraham I 	return 0;
1127380f5708SKishon Vijay Abraham I }
1128380f5708SKishon Vijay Abraham I 
11297e016cbcSKishon Vijay Abraham I static int cdns_sierra_phy_get_clocks(struct cdns_sierra_phy *sp,
11307e016cbcSKishon Vijay Abraham I 				      struct device *dev)
11317e016cbcSKishon Vijay Abraham I {
11327e016cbcSKishon Vijay Abraham I 	struct clk *clk;
11337e016cbcSKishon Vijay Abraham I 	int ret;
11347e016cbcSKishon Vijay Abraham I 
11357e016cbcSKishon Vijay Abraham I 	clk = devm_clk_get_optional(dev, "cmn_refclk_dig_div");
11367e016cbcSKishon Vijay Abraham I 	if (IS_ERR(clk)) {
11377e016cbcSKishon Vijay Abraham I 		dev_err(dev, "cmn_refclk_dig_div clock not found\n");
11387e016cbcSKishon Vijay Abraham I 		ret = PTR_ERR(clk);
11397e016cbcSKishon Vijay Abraham I 		return ret;
11407e016cbcSKishon Vijay Abraham I 	}
1141a0c30cd7SKishon Vijay Abraham I 	sp->input_clks[CMN_REFCLK_DIG_DIV] = clk;
11427e016cbcSKishon Vijay Abraham I 
11437e016cbcSKishon Vijay Abraham I 	clk = devm_clk_get_optional(dev, "cmn_refclk1_dig_div");
11447e016cbcSKishon Vijay Abraham I 	if (IS_ERR(clk)) {
11457e016cbcSKishon Vijay Abraham I 		dev_err(dev, "cmn_refclk1_dig_div clock not found\n");
11467e016cbcSKishon Vijay Abraham I 		ret = PTR_ERR(clk);
11477e016cbcSKishon Vijay Abraham I 		return ret;
11487e016cbcSKishon Vijay Abraham I 	}
1149a0c30cd7SKishon Vijay Abraham I 	sp->input_clks[CMN_REFCLK1_DIG_DIV] = clk;
11507e016cbcSKishon Vijay Abraham I 
115128081b72SKishon Vijay Abraham I 	clk = devm_clk_get_optional(dev, "pll0_refclk");
115228081b72SKishon Vijay Abraham I 	if (IS_ERR(clk)) {
115328081b72SKishon Vijay Abraham I 		dev_err(dev, "pll0_refclk clock not found\n");
115428081b72SKishon Vijay Abraham I 		ret = PTR_ERR(clk);
115528081b72SKishon Vijay Abraham I 		return ret;
115628081b72SKishon Vijay Abraham I 	}
115728081b72SKishon Vijay Abraham I 	sp->input_clks[PLL0_REFCLK] = clk;
115828081b72SKishon Vijay Abraham I 
115928081b72SKishon Vijay Abraham I 	clk = devm_clk_get_optional(dev, "pll1_refclk");
116028081b72SKishon Vijay Abraham I 	if (IS_ERR(clk)) {
116128081b72SKishon Vijay Abraham I 		dev_err(dev, "pll1_refclk clock not found\n");
116228081b72SKishon Vijay Abraham I 		ret = PTR_ERR(clk);
116328081b72SKishon Vijay Abraham I 		return ret;
116428081b72SKishon Vijay Abraham I 	}
116528081b72SKishon Vijay Abraham I 	sp->input_clks[PLL1_REFCLK] = clk;
116628081b72SKishon Vijay Abraham I 
11677e016cbcSKishon Vijay Abraham I 	return 0;
11687e016cbcSKishon Vijay Abraham I }
11697e016cbcSKishon Vijay Abraham I 
1170d88ca22dSAswath Govindraju static int cdns_sierra_phy_clk(struct cdns_sierra_phy *sp)
11711436ec30SKishon Vijay Abraham I {
1172d88ca22dSAswath Govindraju 	struct device *dev = sp->dev;
1173d88ca22dSAswath Govindraju 	struct clk *clk;
11741436ec30SKishon Vijay Abraham I 	int ret;
11751436ec30SKishon Vijay Abraham I 
1176d88ca22dSAswath Govindraju 	clk = devm_clk_get_optional(dev, "phy_clk");
1177d88ca22dSAswath Govindraju 	if (IS_ERR(clk)) {
1178d88ca22dSAswath Govindraju 		dev_err(dev, "failed to get clock phy_clk\n");
1179d88ca22dSAswath Govindraju 		return PTR_ERR(clk);
1180d88ca22dSAswath Govindraju 	}
1181d88ca22dSAswath Govindraju 	sp->input_clks[PHY_CLK] = clk;
1182d88ca22dSAswath Govindraju 
11831436ec30SKishon Vijay Abraham I 	ret = clk_prepare_enable(sp->input_clks[PHY_CLK]);
11841436ec30SKishon Vijay Abraham I 	if (ret)
11851436ec30SKishon Vijay Abraham I 		return ret;
11861436ec30SKishon Vijay Abraham I 
1187d88ca22dSAswath Govindraju 	return 0;
1188d88ca22dSAswath Govindraju }
1189d88ca22dSAswath Govindraju 
1190d88ca22dSAswath Govindraju static int cdns_sierra_phy_enable_clocks(struct cdns_sierra_phy *sp)
1191d88ca22dSAswath Govindraju {
1192d88ca22dSAswath Govindraju 	int ret;
1193d88ca22dSAswath Govindraju 
11941436ec30SKishon Vijay Abraham I 	ret = clk_prepare_enable(sp->output_clks[CDNS_SIERRA_PLL_CMNLC]);
11951436ec30SKishon Vijay Abraham I 	if (ret)
1196d88ca22dSAswath Govindraju 		return ret;
11971436ec30SKishon Vijay Abraham I 
11981436ec30SKishon Vijay Abraham I 	ret = clk_prepare_enable(sp->output_clks[CDNS_SIERRA_PLL_CMNLC1]);
11991436ec30SKishon Vijay Abraham I 	if (ret)
12001436ec30SKishon Vijay Abraham I 		goto err_pll_cmnlc1;
12011436ec30SKishon Vijay Abraham I 
12021436ec30SKishon Vijay Abraham I 	return 0;
12031436ec30SKishon Vijay Abraham I 
12041436ec30SKishon Vijay Abraham I err_pll_cmnlc1:
12051436ec30SKishon Vijay Abraham I 	clk_disable_unprepare(sp->output_clks[CDNS_SIERRA_PLL_CMNLC]);
12061436ec30SKishon Vijay Abraham I 
12071436ec30SKishon Vijay Abraham I 	return ret;
12081436ec30SKishon Vijay Abraham I }
12091436ec30SKishon Vijay Abraham I 
12101436ec30SKishon Vijay Abraham I static void cdns_sierra_phy_disable_clocks(struct cdns_sierra_phy *sp)
12111436ec30SKishon Vijay Abraham I {
12121436ec30SKishon Vijay Abraham I 	clk_disable_unprepare(sp->output_clks[CDNS_SIERRA_PLL_CMNLC1]);
12131436ec30SKishon Vijay Abraham I 	clk_disable_unprepare(sp->output_clks[CDNS_SIERRA_PLL_CMNLC]);
1214d88ca22dSAswath Govindraju 	if (!sp->already_configured)
12151436ec30SKishon Vijay Abraham I 		clk_disable_unprepare(sp->input_clks[PHY_CLK]);
12161436ec30SKishon Vijay Abraham I }
12171436ec30SKishon Vijay Abraham I 
12181d5f40e0SKishon Vijay Abraham I static int cdns_sierra_phy_get_resets(struct cdns_sierra_phy *sp,
12191d5f40e0SKishon Vijay Abraham I 				      struct device *dev)
12201d5f40e0SKishon Vijay Abraham I {
12211d5f40e0SKishon Vijay Abraham I 	struct reset_control *rst;
12221d5f40e0SKishon Vijay Abraham I 
122315b0b82dSKishon Vijay Abraham I 	rst = devm_reset_control_get_exclusive(dev, "sierra_reset");
12241d5f40e0SKishon Vijay Abraham I 	if (IS_ERR(rst)) {
12251d5f40e0SKishon Vijay Abraham I 		dev_err(dev, "failed to get reset\n");
12261d5f40e0SKishon Vijay Abraham I 		return PTR_ERR(rst);
12271d5f40e0SKishon Vijay Abraham I 	}
12281d5f40e0SKishon Vijay Abraham I 	sp->phy_rst = rst;
12291d5f40e0SKishon Vijay Abraham I 
123015b0b82dSKishon Vijay Abraham I 	rst = devm_reset_control_get_optional_exclusive(dev, "sierra_apb");
12311d5f40e0SKishon Vijay Abraham I 	if (IS_ERR(rst)) {
12321d5f40e0SKishon Vijay Abraham I 		dev_err(dev, "failed to get apb reset\n");
12331d5f40e0SKishon Vijay Abraham I 		return PTR_ERR(rst);
12341d5f40e0SKishon Vijay Abraham I 	}
12351d5f40e0SKishon Vijay Abraham I 	sp->apb_rst = rst;
12361d5f40e0SKishon Vijay Abraham I 
12371d5f40e0SKishon Vijay Abraham I 	return 0;
12381d5f40e0SKishon Vijay Abraham I }
12391d5f40e0SKishon Vijay Abraham I 
12406b81f05aSSwapnil Jakhade static int cdns_sierra_phy_configure_multilink(struct cdns_sierra_phy *sp)
12416b81f05aSSwapnil Jakhade {
12426b81f05aSSwapnil Jakhade 	const struct cdns_sierra_data *init_data = sp->init_data;
12436b81f05aSSwapnil Jakhade 	struct cdns_sierra_vals *pma_cmn_vals, *pma_ln_vals;
12446b81f05aSSwapnil Jakhade 	enum cdns_sierra_phy_type phy_t1, phy_t2;
12456b81f05aSSwapnil Jakhade 	struct cdns_sierra_vals *phy_pma_ln_vals;
12466b81f05aSSwapnil Jakhade 	const struct cdns_reg_pairs *reg_pairs;
12476b81f05aSSwapnil Jakhade 	struct cdns_sierra_vals *pcs_cmn_vals;
12486b81f05aSSwapnil Jakhade 	int i, j, node, mlane, num_lanes, ret;
12496b81f05aSSwapnil Jakhade 	enum cdns_sierra_ssc_mode ssc;
12506b81f05aSSwapnil Jakhade 	struct regmap *regmap;
12516b81f05aSSwapnil Jakhade 	u32 num_regs;
12526b81f05aSSwapnil Jakhade 
12536b81f05aSSwapnil Jakhade 	/* Maximum 2 links (subnodes) are supported */
12546b81f05aSSwapnil Jakhade 	if (sp->nsubnodes != 2)
12556b81f05aSSwapnil Jakhade 		return -EINVAL;
12566b81f05aSSwapnil Jakhade 
12576b81f05aSSwapnil Jakhade 	clk_set_rate(sp->input_clks[CMN_REFCLK_DIG_DIV], 25000000);
12586b81f05aSSwapnil Jakhade 	clk_set_rate(sp->input_clks[CMN_REFCLK1_DIG_DIV], 25000000);
12596b81f05aSSwapnil Jakhade 
12606b81f05aSSwapnil Jakhade 	/* PHY configured to use both PLL LC and LC1 */
12616b81f05aSSwapnil Jakhade 	regmap_field_write(sp->phy_pll_cfg_1, 0x1);
12626b81f05aSSwapnil Jakhade 
12636b81f05aSSwapnil Jakhade 	phy_t1 = sp->phys[0].phy_type;
12646b81f05aSSwapnil Jakhade 	phy_t2 = sp->phys[1].phy_type;
12656b81f05aSSwapnil Jakhade 
12666b81f05aSSwapnil Jakhade 	/*
12676b81f05aSSwapnil Jakhade 	 * PHY configuration for multi-link operation is done in two steps.
12686b81f05aSSwapnil Jakhade 	 * e.g. Consider a case for a 4 lane PHY with PCIe using 2 lanes and QSGMII other 2 lanes.
12696b81f05aSSwapnil Jakhade 	 * Sierra PHY has 2 PLLs, viz. PLLLC and PLLLC1. So in this case, PLLLC is used for PCIe
12706b81f05aSSwapnil Jakhade 	 * and PLLLC1 is used for QSGMII. PHY is configured in two steps as described below.
12716b81f05aSSwapnil Jakhade 	 *
12726b81f05aSSwapnil Jakhade 	 * [1] For first step, phy_t1 = TYPE_PCIE and phy_t2 = TYPE_QSGMII
12736b81f05aSSwapnil Jakhade 	 *     So the register values are selected as [TYPE_PCIE][TYPE_QSGMII][ssc].
12746b81f05aSSwapnil Jakhade 	 *     This will configure PHY registers associated for PCIe (i.e. first protocol)
12756b81f05aSSwapnil Jakhade 	 *     involving PLLLC registers and registers for first 2 lanes of PHY.
12766b81f05aSSwapnil Jakhade 	 * [2] In second step, the variables phy_t1 and phy_t2 are swapped. So now,
12776b81f05aSSwapnil Jakhade 	 *     phy_t1 = TYPE_QSGMII and phy_t2 = TYPE_PCIE. And the register values are selected as
12786b81f05aSSwapnil Jakhade 	 *     [TYPE_QSGMII][TYPE_PCIE][ssc].
12796b81f05aSSwapnil Jakhade 	 *     This will configure PHY registers associated for QSGMII (i.e. second protocol)
12806b81f05aSSwapnil Jakhade 	 *     involving PLLLC1 registers and registers for other 2 lanes of PHY.
12816b81f05aSSwapnil Jakhade 	 *
12826b81f05aSSwapnil Jakhade 	 * This completes the PHY configuration for multilink operation. This approach enables
12836b81f05aSSwapnil Jakhade 	 * dividing the large number of PHY register configurations into protocol specific
12846b81f05aSSwapnil Jakhade 	 * smaller groups.
12856b81f05aSSwapnil Jakhade 	 */
12866b81f05aSSwapnil Jakhade 	for (node = 0; node < sp->nsubnodes; node++) {
12876b81f05aSSwapnil Jakhade 		if (node == 1) {
12886b81f05aSSwapnil Jakhade 			/*
12896b81f05aSSwapnil Jakhade 			 * If first link with phy_t1 is configured, then configure the PHY for
12906b81f05aSSwapnil Jakhade 			 * second link with phy_t2. Get the array values as [phy_t2][phy_t1][ssc].
12916b81f05aSSwapnil Jakhade 			 */
12926b81f05aSSwapnil Jakhade 			swap(phy_t1, phy_t2);
12936b81f05aSSwapnil Jakhade 		}
12946b81f05aSSwapnil Jakhade 
12956b81f05aSSwapnil Jakhade 		mlane = sp->phys[node].mlane;
12966b81f05aSSwapnil Jakhade 		ssc = sp->phys[node].ssc_mode;
12976b81f05aSSwapnil Jakhade 		num_lanes = sp->phys[node].num_lanes;
12986b81f05aSSwapnil Jakhade 
12996b81f05aSSwapnil Jakhade 		/* PHY PCS common registers configurations */
13006b81f05aSSwapnil Jakhade 		pcs_cmn_vals = init_data->pcs_cmn_vals[phy_t1][phy_t2][ssc];
13016b81f05aSSwapnil Jakhade 		if (pcs_cmn_vals) {
13026b81f05aSSwapnil Jakhade 			reg_pairs = pcs_cmn_vals->reg_pairs;
13036b81f05aSSwapnil Jakhade 			num_regs = pcs_cmn_vals->num_regs;
13046b81f05aSSwapnil Jakhade 			regmap = sp->regmap_phy_pcs_common_cdb;
13056b81f05aSSwapnil Jakhade 			for (i = 0; i < num_regs; i++)
13066b81f05aSSwapnil Jakhade 				regmap_write(regmap, reg_pairs[i].off, reg_pairs[i].val);
13076b81f05aSSwapnil Jakhade 		}
13086b81f05aSSwapnil Jakhade 
13096b81f05aSSwapnil Jakhade 		/* PHY PMA lane registers configurations */
13106b81f05aSSwapnil Jakhade 		phy_pma_ln_vals = init_data->phy_pma_ln_vals[phy_t1][phy_t2][ssc];
13116b81f05aSSwapnil Jakhade 		if (phy_pma_ln_vals) {
13126b81f05aSSwapnil Jakhade 			reg_pairs = phy_pma_ln_vals->reg_pairs;
13136b81f05aSSwapnil Jakhade 			num_regs = phy_pma_ln_vals->num_regs;
13146b81f05aSSwapnil Jakhade 			for (i = 0; i < num_lanes; i++) {
13156b81f05aSSwapnil Jakhade 				regmap = sp->regmap_phy_pma_lane_cdb[i + mlane];
13166b81f05aSSwapnil Jakhade 				for (j = 0; j < num_regs; j++)
13176b81f05aSSwapnil Jakhade 					regmap_write(regmap, reg_pairs[j].off, reg_pairs[j].val);
13186b81f05aSSwapnil Jakhade 			}
13196b81f05aSSwapnil Jakhade 		}
13206b81f05aSSwapnil Jakhade 
13216b81f05aSSwapnil Jakhade 		/* PMA common registers configurations */
13226b81f05aSSwapnil Jakhade 		pma_cmn_vals = init_data->pma_cmn_vals[phy_t1][phy_t2][ssc];
13236b81f05aSSwapnil Jakhade 		if (pma_cmn_vals) {
13246b81f05aSSwapnil Jakhade 			reg_pairs = pma_cmn_vals->reg_pairs;
13256b81f05aSSwapnil Jakhade 			num_regs = pma_cmn_vals->num_regs;
13266b81f05aSSwapnil Jakhade 			regmap = sp->regmap_common_cdb;
13276b81f05aSSwapnil Jakhade 			for (i = 0; i < num_regs; i++)
13286b81f05aSSwapnil Jakhade 				regmap_write(regmap, reg_pairs[i].off, reg_pairs[i].val);
13296b81f05aSSwapnil Jakhade 		}
13306b81f05aSSwapnil Jakhade 
13316b81f05aSSwapnil Jakhade 		/* PMA lane registers configurations */
13326b81f05aSSwapnil Jakhade 		pma_ln_vals = init_data->pma_ln_vals[phy_t1][phy_t2][ssc];
13336b81f05aSSwapnil Jakhade 		if (pma_ln_vals) {
13346b81f05aSSwapnil Jakhade 			reg_pairs = pma_ln_vals->reg_pairs;
13356b81f05aSSwapnil Jakhade 			num_regs = pma_ln_vals->num_regs;
13366b81f05aSSwapnil Jakhade 			for (i = 0; i < num_lanes; i++) {
13376b81f05aSSwapnil Jakhade 				regmap = sp->regmap_lane_cdb[i + mlane];
13386b81f05aSSwapnil Jakhade 				for (j = 0; j < num_regs; j++)
13396b81f05aSSwapnil Jakhade 					regmap_write(regmap, reg_pairs[j].off, reg_pairs[j].val);
13406b81f05aSSwapnil Jakhade 			}
13416b81f05aSSwapnil Jakhade 		}
13428a1b82d7SSwapnil Jakhade 
13438a1b82d7SSwapnil Jakhade 		if (phy_t1 == TYPE_QSGMII)
13448a1b82d7SSwapnil Jakhade 			reset_control_deassert(sp->phys[node].lnk_rst);
13456b81f05aSSwapnil Jakhade 	}
13466b81f05aSSwapnil Jakhade 
13476b81f05aSSwapnil Jakhade 	/* Take the PHY out of reset */
13486b81f05aSSwapnil Jakhade 	ret = reset_control_deassert(sp->phy_rst);
13496b81f05aSSwapnil Jakhade 	if (ret)
13506b81f05aSSwapnil Jakhade 		return ret;
13516b81f05aSSwapnil Jakhade 
13526b81f05aSSwapnil Jakhade 	return 0;
13536b81f05aSSwapnil Jakhade }
13546b81f05aSSwapnil Jakhade 
135544d30d62SAlan Douglas static int cdns_sierra_phy_probe(struct platform_device *pdev)
135644d30d62SAlan Douglas {
135744d30d62SAlan Douglas 	struct cdns_sierra_phy *sp;
135844d30d62SAlan Douglas 	struct phy_provider *phy_provider;
135944d30d62SAlan Douglas 	struct device *dev = &pdev->dev;
1360c3c11d55SSwapnil Jakhade 	const struct cdns_sierra_data *data;
1361380f5708SKishon Vijay Abraham I 	unsigned int id_value;
136229afbd76SDan Carpenter 	int ret, node = 0;
1363380f5708SKishon Vijay Abraham I 	void __iomem *base;
136444d30d62SAlan Douglas 	struct device_node *dn = dev->of_node, *child;
136544d30d62SAlan Douglas 
136644d30d62SAlan Douglas 	if (of_get_child_count(dn) == 0)
136744d30d62SAlan Douglas 		return -ENODEV;
136844d30d62SAlan Douglas 
1369380f5708SKishon Vijay Abraham I 	/* Get init data for this PHY */
1370c3c11d55SSwapnil Jakhade 	data = of_device_get_match_data(dev);
1371c3c11d55SSwapnil Jakhade 	if (!data)
1372380f5708SKishon Vijay Abraham I 		return -EINVAL;
1373380f5708SKishon Vijay Abraham I 
137444d30d62SAlan Douglas 	sp = devm_kzalloc(dev, sizeof(*sp), GFP_KERNEL);
137544d30d62SAlan Douglas 	if (!sp)
137644d30d62SAlan Douglas 		return -ENOMEM;
137744d30d62SAlan Douglas 	dev_set_drvdata(dev, sp);
137844d30d62SAlan Douglas 	sp->dev = dev;
1379380f5708SKishon Vijay Abraham I 	sp->init_data = data;
138044d30d62SAlan Douglas 
1381fa629094SChunfeng Yun 	base = devm_platform_ioremap_resource(pdev, 0);
1382380f5708SKishon Vijay Abraham I 	if (IS_ERR(base)) {
138344d30d62SAlan Douglas 		dev_err(dev, "missing \"reg\"\n");
1384380f5708SKishon Vijay Abraham I 		return PTR_ERR(base);
138544d30d62SAlan Douglas 	}
138644d30d62SAlan Douglas 
1387380f5708SKishon Vijay Abraham I 	ret = cdns_regmap_init_blocks(sp, base, data->block_offset_shift,
1388380f5708SKishon Vijay Abraham I 				      data->reg_offset_shift);
1389380f5708SKishon Vijay Abraham I 	if (ret)
1390380f5708SKishon Vijay Abraham I 		return ret;
1391380f5708SKishon Vijay Abraham I 
1392380f5708SKishon Vijay Abraham I 	ret = cdns_regfield_init(sp);
1393380f5708SKishon Vijay Abraham I 	if (ret)
1394380f5708SKishon Vijay Abraham I 		return ret;
139544d30d62SAlan Douglas 
139644d30d62SAlan Douglas 	platform_set_drvdata(pdev, sp);
139744d30d62SAlan Douglas 
13987e016cbcSKishon Vijay Abraham I 	ret = cdns_sierra_phy_get_clocks(sp, dev);
13997e016cbcSKishon Vijay Abraham I 	if (ret)
14007e016cbcSKishon Vijay Abraham I 		return ret;
140144d30d62SAlan Douglas 
140228081b72SKishon Vijay Abraham I 	ret = cdns_sierra_clk_register(sp);
14031d5f40e0SKishon Vijay Abraham I 	if (ret)
14041d5f40e0SKishon Vijay Abraham I 		return ret;
140544d30d62SAlan Douglas 
14061436ec30SKishon Vijay Abraham I 	ret = cdns_sierra_phy_enable_clocks(sp);
140744d30d62SAlan Douglas 	if (ret)
140828081b72SKishon Vijay Abraham I 		goto unregister_clk;
140944d30d62SAlan Douglas 
1410d88ca22dSAswath Govindraju 	regmap_field_read(sp->pma_cmn_ready, &sp->already_configured);
1411d88ca22dSAswath Govindraju 
1412d88ca22dSAswath Govindraju 	if (!sp->already_configured) {
1413d88ca22dSAswath Govindraju 		ret = cdns_sierra_phy_clk(sp);
1414d88ca22dSAswath Govindraju 		if (ret)
1415d88ca22dSAswath Govindraju 			goto clk_disable;
1416d88ca22dSAswath Govindraju 
1417d88ca22dSAswath Govindraju 		ret = cdns_sierra_phy_get_resets(sp, dev);
1418d88ca22dSAswath Govindraju 		if (ret)
1419d88ca22dSAswath Govindraju 			goto clk_disable;
1420d88ca22dSAswath Govindraju 
142144d30d62SAlan Douglas 		/* Enable APB */
142244d30d62SAlan Douglas 		reset_control_deassert(sp->apb_rst);
1423d88ca22dSAswath Govindraju 	}
142444d30d62SAlan Douglas 
142544d30d62SAlan Douglas 	/* Check that PHY is present */
1426380f5708SKishon Vijay Abraham I 	regmap_field_read(sp->macro_id_type, &id_value);
1427380f5708SKishon Vijay Abraham I 	if  (sp->init_data->id_value != id_value) {
142844d30d62SAlan Douglas 		ret = -EINVAL;
1429d88ca22dSAswath Govindraju 		goto ctrl_assert;
143044d30d62SAlan Douglas 	}
143144d30d62SAlan Douglas 
143244d30d62SAlan Douglas 	sp->autoconf = of_property_read_bool(dn, "cdns,autoconf");
143344d30d62SAlan Douglas 
143444d30d62SAlan Douglas 	for_each_available_child_of_node(dn, child) {
143544d30d62SAlan Douglas 		struct phy *gphy;
143644d30d62SAlan Douglas 
143703ada5a3SKishon Vijay Abraham I 		if (!(of_node_name_eq(child, "phy") ||
143803ada5a3SKishon Vijay Abraham I 		      of_node_name_eq(child, "link")))
143903ada5a3SKishon Vijay Abraham I 			continue;
144003ada5a3SKishon Vijay Abraham I 
144144d30d62SAlan Douglas 		sp->phys[node].lnk_rst =
1442b872936fSKishon Vijay Abraham I 			of_reset_control_array_get_exclusive(child);
144344d30d62SAlan Douglas 
144444d30d62SAlan Douglas 		if (IS_ERR(sp->phys[node].lnk_rst)) {
144544d30d62SAlan Douglas 			dev_err(dev, "failed to get reset %s\n",
144644d30d62SAlan Douglas 				child->full_name);
144744d30d62SAlan Douglas 			ret = PTR_ERR(sp->phys[node].lnk_rst);
144829afbd76SDan Carpenter 			of_node_put(child);
144929afbd76SDan Carpenter 			goto put_control;
145044d30d62SAlan Douglas 		}
145144d30d62SAlan Douglas 
145244d30d62SAlan Douglas 		if (!sp->autoconf) {
145344d30d62SAlan Douglas 			ret = cdns_sierra_get_optional(&sp->phys[node], child);
145444d30d62SAlan Douglas 			if (ret) {
145544d30d62SAlan Douglas 				dev_err(dev, "missing property in node %s\n",
145644d30d62SAlan Douglas 					child->name);
145729afbd76SDan Carpenter 				of_node_put(child);
145829afbd76SDan Carpenter 				reset_control_put(sp->phys[node].lnk_rst);
145929afbd76SDan Carpenter 				goto put_control;
146044d30d62SAlan Douglas 			}
146144d30d62SAlan Douglas 		}
146244d30d62SAlan Douglas 
1463a43f72aeSKishon Vijay Abraham I 		sp->num_lanes += sp->phys[node].num_lanes;
1464a43f72aeSKishon Vijay Abraham I 
1465d88ca22dSAswath Govindraju 		if (!sp->already_configured)
146644d30d62SAlan Douglas 			gphy = devm_phy_create(dev, child, &ops);
1467d88ca22dSAswath Govindraju 		else
1468d88ca22dSAswath Govindraju 			gphy = devm_phy_create(dev, child, &noop_ops);
146944d30d62SAlan Douglas 		if (IS_ERR(gphy)) {
147044d30d62SAlan Douglas 			ret = PTR_ERR(gphy);
147129afbd76SDan Carpenter 			of_node_put(child);
147229afbd76SDan Carpenter 			reset_control_put(sp->phys[node].lnk_rst);
147329afbd76SDan Carpenter 			goto put_control;
147444d30d62SAlan Douglas 		}
147544d30d62SAlan Douglas 		sp->phys[node].phy = gphy;
147644d30d62SAlan Douglas 		phy_set_drvdata(gphy, &sp->phys[node]);
147744d30d62SAlan Douglas 
147844d30d62SAlan Douglas 		node++;
147944d30d62SAlan Douglas 	}
148044d30d62SAlan Douglas 	sp->nsubnodes = node;
148144d30d62SAlan Douglas 
1482a43f72aeSKishon Vijay Abraham I 	if (sp->num_lanes > SIERRA_MAX_LANES) {
14836411e386SWang Wensheng 		ret = -EINVAL;
1484a43f72aeSKishon Vijay Abraham I 		dev_err(dev, "Invalid lane configuration\n");
148529afbd76SDan Carpenter 		goto put_control;
1486a43f72aeSKishon Vijay Abraham I 	}
1487a43f72aeSKishon Vijay Abraham I 
148844d30d62SAlan Douglas 	/* If more than one subnode, configure the PHY as multilink */
1489d88ca22dSAswath Govindraju 	if (!sp->already_configured && !sp->autoconf && sp->nsubnodes > 1) {
14906b81f05aSSwapnil Jakhade 		ret = cdns_sierra_phy_configure_multilink(sp);
14916b81f05aSSwapnil Jakhade 		if (ret)
149229afbd76SDan Carpenter 			goto put_control;
14936b81f05aSSwapnil Jakhade 	}
149444d30d62SAlan Douglas 
149544d30d62SAlan Douglas 	pm_runtime_enable(dev);
149644d30d62SAlan Douglas 	phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
149729afbd76SDan Carpenter 	if (IS_ERR(phy_provider)) {
149829afbd76SDan Carpenter 		ret = PTR_ERR(phy_provider);
149929afbd76SDan Carpenter 		goto put_control;
150029afbd76SDan Carpenter 	}
150144d30d62SAlan Douglas 
150229afbd76SDan Carpenter 	return 0;
150329afbd76SDan Carpenter 
150429afbd76SDan Carpenter put_control:
150529afbd76SDan Carpenter 	while (--node >= 0)
150629afbd76SDan Carpenter 		reset_control_put(sp->phys[node].lnk_rst);
1507d88ca22dSAswath Govindraju ctrl_assert:
1508d88ca22dSAswath Govindraju 	if (!sp->already_configured)
1509d88ca22dSAswath Govindraju 		reset_control_assert(sp->apb_rst);
151044d30d62SAlan Douglas clk_disable:
15111436ec30SKishon Vijay Abraham I 	cdns_sierra_phy_disable_clocks(sp);
151228081b72SKishon Vijay Abraham I unregister_clk:
151328081b72SKishon Vijay Abraham I 	cdns_sierra_clk_unregister(sp);
151444d30d62SAlan Douglas 	return ret;
151544d30d62SAlan Douglas }
151644d30d62SAlan Douglas 
151744d30d62SAlan Douglas static int cdns_sierra_phy_remove(struct platform_device *pdev)
151844d30d62SAlan Douglas {
1519748e3456SKishon Vijay Abraham I 	struct cdns_sierra_phy *phy = platform_get_drvdata(pdev);
152044d30d62SAlan Douglas 	int i;
152144d30d62SAlan Douglas 
152244d30d62SAlan Douglas 	reset_control_assert(phy->phy_rst);
152344d30d62SAlan Douglas 	reset_control_assert(phy->apb_rst);
152444d30d62SAlan Douglas 	pm_runtime_disable(&pdev->dev);
152544d30d62SAlan Douglas 
15261436ec30SKishon Vijay Abraham I 	cdns_sierra_phy_disable_clocks(phy);
152744d30d62SAlan Douglas 	/*
152844d30d62SAlan Douglas 	 * The device level resets will be put automatically.
152944d30d62SAlan Douglas 	 * Need to put the subnode resets here though.
153044d30d62SAlan Douglas 	 */
153144d30d62SAlan Douglas 	for (i = 0; i < phy->nsubnodes; i++) {
153244d30d62SAlan Douglas 		reset_control_assert(phy->phys[i].lnk_rst);
153344d30d62SAlan Douglas 		reset_control_put(phy->phys[i].lnk_rst);
153444d30d62SAlan Douglas 	}
153529c2d02aSKishon Vijay Abraham I 
153628081b72SKishon Vijay Abraham I 	cdns_sierra_clk_unregister(phy);
153729c2d02aSKishon Vijay Abraham I 
153844d30d62SAlan Douglas 	return 0;
153944d30d62SAlan Douglas }
154044d30d62SAlan Douglas 
15418a1b82d7SSwapnil Jakhade /* QSGMII PHY PMA lane configuration */
15428a1b82d7SSwapnil Jakhade static struct cdns_reg_pairs qsgmii_phy_pma_ln_regs[] = {
15438a1b82d7SSwapnil Jakhade 	{0x9010, SIERRA_PHY_PMA_XCVR_CTRL}
15448a1b82d7SSwapnil Jakhade };
15458a1b82d7SSwapnil Jakhade 
15468a1b82d7SSwapnil Jakhade static struct cdns_sierra_vals qsgmii_phy_pma_ln_vals = {
15478a1b82d7SSwapnil Jakhade 	.reg_pairs = qsgmii_phy_pma_ln_regs,
15488a1b82d7SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(qsgmii_phy_pma_ln_regs),
15498a1b82d7SSwapnil Jakhade };
15508a1b82d7SSwapnil Jakhade 
15518a1b82d7SSwapnil Jakhade /* QSGMII refclk 100MHz, 20b, opt1, No BW cal, no ssc, PLL LC1 */
15528a1b82d7SSwapnil Jakhade static const struct cdns_reg_pairs qsgmii_100_no_ssc_plllc1_cmn_regs[] = {
15538a1b82d7SSwapnil Jakhade 	{0x2085, SIERRA_CMN_PLLLC1_LF_COEFF_MODE0_PREG},
15548a1b82d7SSwapnil Jakhade 	{0x0000, SIERRA_CMN_PLLLC1_BWCAL_MODE0_PREG},
15558a1b82d7SSwapnil Jakhade 	{0x0000, SIERRA_CMN_PLLLC1_SS_TIME_STEPSIZE_MODE_PREG}
15568a1b82d7SSwapnil Jakhade };
15578a1b82d7SSwapnil Jakhade 
15588a1b82d7SSwapnil Jakhade static const struct cdns_reg_pairs qsgmii_100_no_ssc_plllc1_ln_regs[] = {
15598a1b82d7SSwapnil Jakhade 	{0xFC08, SIERRA_DET_STANDEC_A_PREG},
15608a1b82d7SSwapnil Jakhade 	{0x0252, SIERRA_DET_STANDEC_E_PREG},
15618a1b82d7SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_IDLE_PREG},
15628a1b82d7SSwapnil Jakhade 	{0x0FFE, SIERRA_PSC_RX_A0_PREG},
15638a1b82d7SSwapnil Jakhade 	{0x0011, SIERRA_PLLCTRL_SUBRATE_PREG},
15648a1b82d7SSwapnil Jakhade 	{0x0001, SIERRA_PLLCTRL_GEN_A_PREG},
15658a1b82d7SSwapnil Jakhade 	{0x5233, SIERRA_PLLCTRL_CPGAIN_MODE_PREG},
15668a1b82d7SSwapnil Jakhade 	{0x0000, SIERRA_DRVCTRL_ATTEN_PREG},
15678a1b82d7SSwapnil Jakhade 	{0x0089, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
15688a1b82d7SSwapnil Jakhade 	{0x3C3C, SIERRA_CREQ_CCLKDET_MODE01_PREG},
15698a1b82d7SSwapnil Jakhade 	{0x3222, SIERRA_CREQ_FSMCLK_SEL_PREG},
15708a1b82d7SSwapnil Jakhade 	{0x0000, SIERRA_CREQ_EQ_CTRL_PREG},
15718a1b82d7SSwapnil Jakhade 	{0x8422, SIERRA_CTLELUT_CTRL_PREG},
15728a1b82d7SSwapnil Jakhade 	{0x4111, SIERRA_DFE_ECMP_RATESEL_PREG},
15738a1b82d7SSwapnil Jakhade 	{0x4111, SIERRA_DFE_SMP_RATESEL_PREG},
15748a1b82d7SSwapnil Jakhade 	{0x0002, SIERRA_DEQ_PHALIGN_CTRL},
15758a1b82d7SSwapnil Jakhade 	{0x9595, SIERRA_DEQ_VGATUNE_CTRL_PREG},
15768a1b82d7SSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT0},
15778a1b82d7SSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT1},
15788a1b82d7SSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT2},
15798a1b82d7SSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT3},
15808a1b82d7SSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT4},
15818a1b82d7SSwapnil Jakhade 	{0x0861, SIERRA_DEQ_ALUT0},
15828a1b82d7SSwapnil Jakhade 	{0x07E0, SIERRA_DEQ_ALUT1},
15838a1b82d7SSwapnil Jakhade 	{0x079E, SIERRA_DEQ_ALUT2},
15848a1b82d7SSwapnil Jakhade 	{0x071D, SIERRA_DEQ_ALUT3},
15858a1b82d7SSwapnil Jakhade 	{0x03F5, SIERRA_DEQ_DFETAP_CTRL_PREG},
15868a1b82d7SSwapnil Jakhade 	{0x0C01, SIERRA_DEQ_TAU_CTRL1_FAST_MAINT_PREG},
15878a1b82d7SSwapnil Jakhade 	{0x3C40, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG},
15888a1b82d7SSwapnil Jakhade 	{0x1C04, SIERRA_DEQ_TAU_CTRL2_PREG},
15898a1b82d7SSwapnil Jakhade 	{0x0033, SIERRA_DEQ_PICTRL_PREG},
15908a1b82d7SSwapnil Jakhade 	{0x0660, SIERRA_CPICAL_TMRVAL_MODE0_PREG},
15918a1b82d7SSwapnil Jakhade 	{0x00D5, SIERRA_CPI_OUTBUF_RATESEL_PREG},
15928a1b82d7SSwapnil Jakhade 	{0x0B6D, SIERRA_CPI_RESBIAS_BIN_PREG},
15938a1b82d7SSwapnil Jakhade 	{0x0102, SIERRA_RXBUFFER_CTLECTRL_PREG},
15948a1b82d7SSwapnil Jakhade 	{0x0002, SIERRA_RXBUFFER_RCDFECTRL_PREG}
15958a1b82d7SSwapnil Jakhade };
15968a1b82d7SSwapnil Jakhade 
15978a1b82d7SSwapnil Jakhade static struct cdns_sierra_vals qsgmii_100_no_ssc_plllc1_cmn_vals = {
15988a1b82d7SSwapnil Jakhade 	.reg_pairs = qsgmii_100_no_ssc_plllc1_cmn_regs,
15998a1b82d7SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(qsgmii_100_no_ssc_plllc1_cmn_regs),
16008a1b82d7SSwapnil Jakhade };
16018a1b82d7SSwapnil Jakhade 
16028a1b82d7SSwapnil Jakhade static struct cdns_sierra_vals qsgmii_100_no_ssc_plllc1_ln_vals = {
16038a1b82d7SSwapnil Jakhade 	.reg_pairs = qsgmii_100_no_ssc_plllc1_ln_regs,
16048a1b82d7SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(qsgmii_100_no_ssc_plllc1_ln_regs),
16058a1b82d7SSwapnil Jakhade };
16068a1b82d7SSwapnil Jakhade 
1607fa105172SSwapnil Jakhade /* PCIE PHY PCS common configuration */
1608fa105172SSwapnil Jakhade static struct cdns_reg_pairs pcie_phy_pcs_cmn_regs[] = {
1609fa105172SSwapnil Jakhade 	{0x0430, SIERRA_PHY_PIPE_CMN_CTRL1}
1610fa105172SSwapnil Jakhade };
1611fa105172SSwapnil Jakhade 
1612fa105172SSwapnil Jakhade static struct cdns_sierra_vals pcie_phy_pcs_cmn_vals = {
1613fa105172SSwapnil Jakhade 	.reg_pairs = pcie_phy_pcs_cmn_regs,
1614fa105172SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(pcie_phy_pcs_cmn_regs),
1615fa105172SSwapnil Jakhade };
1616fa105172SSwapnil Jakhade 
16178a1b82d7SSwapnil Jakhade /* refclk100MHz_32b_PCIe_cmn_pll_no_ssc, pcie_links_using_plllc, pipe_bw_3 */
16188a1b82d7SSwapnil Jakhade static const struct cdns_reg_pairs pcie_100_no_ssc_plllc_cmn_regs[] = {
16198a1b82d7SSwapnil Jakhade 	{0x2105, SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG},
16208a1b82d7SSwapnil Jakhade 	{0x2105, SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG},
16218a1b82d7SSwapnil Jakhade 	{0x8A06, SIERRA_CMN_PLLLC_BWCAL_MODE1_PREG},
16228a1b82d7SSwapnil Jakhade 	{0x8A06, SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG}
16238a1b82d7SSwapnil Jakhade };
16248a1b82d7SSwapnil Jakhade 
16258a1b82d7SSwapnil Jakhade /*
16268a1b82d7SSwapnil Jakhade  * refclk100MHz_32b_PCIe_ln_no_ssc, multilink, using_plllc,
16278a1b82d7SSwapnil Jakhade  * cmn_pllcy_anaclk0_1Ghz, xcvr_pllclk_fullrt_500mhz
16288a1b82d7SSwapnil Jakhade  */
16298a1b82d7SSwapnil Jakhade static const struct cdns_reg_pairs ml_pcie_100_no_ssc_ln_regs[] = {
16308a1b82d7SSwapnil Jakhade 	{0xFC08, SIERRA_DET_STANDEC_A_PREG},
16318a1b82d7SSwapnil Jakhade 	{0x001D, SIERRA_PSM_A3IN_TMR_PREG},
16328a1b82d7SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_A3_PREG},
16338a1b82d7SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_A4_PREG},
16348a1b82d7SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_IDLE_PREG},
16358a1b82d7SSwapnil Jakhade 	{0x1555, SIERRA_DFE_BIASTRIM_PREG},
16368a1b82d7SSwapnil Jakhade 	{0x9703, SIERRA_DRVCTRL_BOOST_PREG},
16378a1b82d7SSwapnil Jakhade 	{0x8055, SIERRA_RX_CREQ_FLTR_A_MODE3_PREG},
16388a1b82d7SSwapnil Jakhade 	{0x80BB, SIERRA_RX_CREQ_FLTR_A_MODE2_PREG},
16398a1b82d7SSwapnil Jakhade 	{0x8351, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG},
16408a1b82d7SSwapnil Jakhade 	{0x8349, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
16418a1b82d7SSwapnil Jakhade 	{0x0002, SIERRA_CREQ_DCBIASATTEN_OVR_PREG},
16428a1b82d7SSwapnil Jakhade 	{0x9800, SIERRA_RX_CTLE_CAL_PREG},
16438a1b82d7SSwapnil Jakhade 	{0x5624, SIERRA_DEQ_CONCUR_CTRL2_PREG},
16448a1b82d7SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_EPIPWR_CTRL2_PREG},
16458a1b82d7SSwapnil Jakhade 	{0x00FF, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG},
16468a1b82d7SSwapnil Jakhade 	{0x4C4C, SIERRA_DEQ_ERRCMP_CTRL_PREG},
16478a1b82d7SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_OFFSET_CTRL_PREG},
16488a1b82d7SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_GAIN_CTRL_PREG},
16498a1b82d7SSwapnil Jakhade 	{0x0041, SIERRA_DEQ_GLUT0},
16508a1b82d7SSwapnil Jakhade 	{0x0082, SIERRA_DEQ_GLUT1},
16518a1b82d7SSwapnil Jakhade 	{0x00C3, SIERRA_DEQ_GLUT2},
16528a1b82d7SSwapnil Jakhade 	{0x0145, SIERRA_DEQ_GLUT3},
16538a1b82d7SSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT4},
16548a1b82d7SSwapnil Jakhade 	{0x09E7, SIERRA_DEQ_ALUT0},
16558a1b82d7SSwapnil Jakhade 	{0x09A6, SIERRA_DEQ_ALUT1},
16568a1b82d7SSwapnil Jakhade 	{0x0965, SIERRA_DEQ_ALUT2},
16578a1b82d7SSwapnil Jakhade 	{0x08E3, SIERRA_DEQ_ALUT3},
16588a1b82d7SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP0},
16598a1b82d7SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP1},
16608a1b82d7SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP2},
16618a1b82d7SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP3},
16628a1b82d7SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP4},
16638a1b82d7SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_PRECUR_PREG},
16648a1b82d7SSwapnil Jakhade 	{0x0280, SIERRA_DEQ_POSTCUR_PREG},
16658a1b82d7SSwapnil Jakhade 	{0x8F00, SIERRA_DEQ_POSTCUR_DECR_PREG},
16668a1b82d7SSwapnil Jakhade 	{0x3C0F, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG},
16678a1b82d7SSwapnil Jakhade 	{0x1C0C, SIERRA_DEQ_TAU_CTRL2_PREG},
16688a1b82d7SSwapnil Jakhade 	{0x0100, SIERRA_DEQ_TAU_CTRL3_PREG},
16698a1b82d7SSwapnil Jakhade 	{0x5E82, SIERRA_DEQ_OPENEYE_CTRL_PREG},
16708a1b82d7SSwapnil Jakhade 	{0x002B, SIERRA_CPI_TRIM_PREG},
16718a1b82d7SSwapnil Jakhade 	{0x0003, SIERRA_EPI_CTRL_PREG},
16728a1b82d7SSwapnil Jakhade 	{0x803F, SIERRA_SDFILT_H2L_A_PREG},
16738a1b82d7SSwapnil Jakhade 	{0x0004, SIERRA_RXBUFFER_CTLECTRL_PREG},
16748a1b82d7SSwapnil Jakhade 	{0x2010, SIERRA_RXBUFFER_RCDFECTRL_PREG},
16758a1b82d7SSwapnil Jakhade 	{0x4432, SIERRA_RXBUFFER_DFECTRL_PREG}
16768a1b82d7SSwapnil Jakhade };
16778a1b82d7SSwapnil Jakhade 
16788a1b82d7SSwapnil Jakhade static struct cdns_sierra_vals pcie_100_no_ssc_plllc_cmn_vals = {
16798a1b82d7SSwapnil Jakhade 	.reg_pairs = pcie_100_no_ssc_plllc_cmn_regs,
16808a1b82d7SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(pcie_100_no_ssc_plllc_cmn_regs),
16818a1b82d7SSwapnil Jakhade };
16828a1b82d7SSwapnil Jakhade 
16838a1b82d7SSwapnil Jakhade static struct cdns_sierra_vals ml_pcie_100_no_ssc_ln_vals = {
16848a1b82d7SSwapnil Jakhade 	.reg_pairs = ml_pcie_100_no_ssc_ln_regs,
16858a1b82d7SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(ml_pcie_100_no_ssc_ln_regs),
16868a1b82d7SSwapnil Jakhade };
16878a1b82d7SSwapnil Jakhade 
1688*e72659b6SSwapnil Jakhade /*
1689*e72659b6SSwapnil Jakhade  * TI J721E:
1690*e72659b6SSwapnil Jakhade  * refclk100MHz_32b_PCIe_ln_no_ssc, multilink, using_plllc,
1691*e72659b6SSwapnil Jakhade  * cmn_pllcy_anaclk0_1Ghz, xcvr_pllclk_fullrt_500mhz
1692*e72659b6SSwapnil Jakhade  */
1693*e72659b6SSwapnil Jakhade static const struct cdns_reg_pairs ti_ml_pcie_100_no_ssc_ln_regs[] = {
1694*e72659b6SSwapnil Jakhade 	{0xFC08, SIERRA_DET_STANDEC_A_PREG},
1695*e72659b6SSwapnil Jakhade 	{0x001D, SIERRA_PSM_A3IN_TMR_PREG},
1696*e72659b6SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_A3_PREG},
1697*e72659b6SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_A4_PREG},
1698*e72659b6SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_IDLE_PREG},
1699*e72659b6SSwapnil Jakhade 	{0x1555, SIERRA_DFE_BIASTRIM_PREG},
1700*e72659b6SSwapnil Jakhade 	{0x9703, SIERRA_DRVCTRL_BOOST_PREG},
1701*e72659b6SSwapnil Jakhade 	{0x8055, SIERRA_RX_CREQ_FLTR_A_MODE3_PREG},
1702*e72659b6SSwapnil Jakhade 	{0x80BB, SIERRA_RX_CREQ_FLTR_A_MODE2_PREG},
1703*e72659b6SSwapnil Jakhade 	{0x8351, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG},
1704*e72659b6SSwapnil Jakhade 	{0x8349, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
1705*e72659b6SSwapnil Jakhade 	{0x0002, SIERRA_CREQ_DCBIASATTEN_OVR_PREG},
1706*e72659b6SSwapnil Jakhade 	{0x9800, SIERRA_RX_CTLE_CAL_PREG},
1707*e72659b6SSwapnil Jakhade 	{0x5624, SIERRA_DEQ_CONCUR_CTRL2_PREG},
1708*e72659b6SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_EPIPWR_CTRL2_PREG},
1709*e72659b6SSwapnil Jakhade 	{0x00FF, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG},
1710*e72659b6SSwapnil Jakhade 	{0x4C4C, SIERRA_DEQ_ERRCMP_CTRL_PREG},
1711*e72659b6SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_OFFSET_CTRL_PREG},
1712*e72659b6SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_GAIN_CTRL_PREG},
1713*e72659b6SSwapnil Jakhade 	{0x0041, SIERRA_DEQ_GLUT0},
1714*e72659b6SSwapnil Jakhade 	{0x0082, SIERRA_DEQ_GLUT1},
1715*e72659b6SSwapnil Jakhade 	{0x00C3, SIERRA_DEQ_GLUT2},
1716*e72659b6SSwapnil Jakhade 	{0x0145, SIERRA_DEQ_GLUT3},
1717*e72659b6SSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT4},
1718*e72659b6SSwapnil Jakhade 	{0x09E7, SIERRA_DEQ_ALUT0},
1719*e72659b6SSwapnil Jakhade 	{0x09A6, SIERRA_DEQ_ALUT1},
1720*e72659b6SSwapnil Jakhade 	{0x0965, SIERRA_DEQ_ALUT2},
1721*e72659b6SSwapnil Jakhade 	{0x08E3, SIERRA_DEQ_ALUT3},
1722*e72659b6SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP0},
1723*e72659b6SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP1},
1724*e72659b6SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP2},
1725*e72659b6SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP3},
1726*e72659b6SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP4},
1727*e72659b6SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_PRECUR_PREG},
1728*e72659b6SSwapnil Jakhade 	{0x0280, SIERRA_DEQ_POSTCUR_PREG},
1729*e72659b6SSwapnil Jakhade 	{0x8F00, SIERRA_DEQ_POSTCUR_DECR_PREG},
1730*e72659b6SSwapnil Jakhade 	{0x3C0F, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG},
1731*e72659b6SSwapnil Jakhade 	{0x1C0C, SIERRA_DEQ_TAU_CTRL2_PREG},
1732*e72659b6SSwapnil Jakhade 	{0x0100, SIERRA_DEQ_TAU_CTRL3_PREG},
1733*e72659b6SSwapnil Jakhade 	{0x5E82, SIERRA_DEQ_OPENEYE_CTRL_PREG},
1734*e72659b6SSwapnil Jakhade 	{0x002B, SIERRA_CPI_TRIM_PREG},
1735*e72659b6SSwapnil Jakhade 	{0x0003, SIERRA_EPI_CTRL_PREG},
1736*e72659b6SSwapnil Jakhade 	{0x803F, SIERRA_SDFILT_H2L_A_PREG},
1737*e72659b6SSwapnil Jakhade 	{0x0004, SIERRA_RXBUFFER_CTLECTRL_PREG},
1738*e72659b6SSwapnil Jakhade 	{0x2010, SIERRA_RXBUFFER_RCDFECTRL_PREG},
1739*e72659b6SSwapnil Jakhade 	{0x4432, SIERRA_RXBUFFER_DFECTRL_PREG},
1740*e72659b6SSwapnil Jakhade 	{0x0002, SIERRA_TX_RCVDET_OVRD_PREG}
1741*e72659b6SSwapnil Jakhade };
1742*e72659b6SSwapnil Jakhade 
1743*e72659b6SSwapnil Jakhade static struct cdns_sierra_vals ti_ml_pcie_100_no_ssc_ln_vals = {
1744*e72659b6SSwapnil Jakhade 	.reg_pairs = ti_ml_pcie_100_no_ssc_ln_regs,
1745*e72659b6SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(ti_ml_pcie_100_no_ssc_ln_regs),
1746*e72659b6SSwapnil Jakhade };
1747*e72659b6SSwapnil Jakhade 
17488a1b82d7SSwapnil Jakhade /* refclk100MHz_32b_PCIe_cmn_pll_int_ssc, pcie_links_using_plllc, pipe_bw_3 */
17498a1b82d7SSwapnil Jakhade static const struct cdns_reg_pairs pcie_100_int_ssc_plllc_cmn_regs[] = {
17508a1b82d7SSwapnil Jakhade 	{0x000E, SIERRA_CMN_PLLLC_MODE_PREG},
17518a1b82d7SSwapnil Jakhade 	{0x4006, SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG},
17528a1b82d7SSwapnil Jakhade 	{0x4006, SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG},
17538a1b82d7SSwapnil Jakhade 	{0x0000, SIERRA_CMN_PLLLC_BWCAL_MODE1_PREG},
17548a1b82d7SSwapnil Jakhade 	{0x0000, SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG},
17558a1b82d7SSwapnil Jakhade 	{0x0581, SIERRA_CMN_PLLLC_DSMCORR_PREG},
17568a1b82d7SSwapnil Jakhade 	{0x7F80, SIERRA_CMN_PLLLC_SS_PREG},
17578a1b82d7SSwapnil Jakhade 	{0x0041, SIERRA_CMN_PLLLC_SS_AMP_STEP_SIZE_PREG},
17588a1b82d7SSwapnil Jakhade 	{0x0464, SIERRA_CMN_PLLLC_SSTWOPT_PREG},
17598a1b82d7SSwapnil Jakhade 	{0x0D0D, SIERRA_CMN_PLLLC_SS_TIME_STEPSIZE_MODE_PREG},
17608a1b82d7SSwapnil Jakhade 	{0x0060, SIERRA_CMN_PLLLC_LOCK_DELAY_CTRL_PREG}
17618a1b82d7SSwapnil Jakhade };
17628a1b82d7SSwapnil Jakhade 
17638a1b82d7SSwapnil Jakhade /*
17648a1b82d7SSwapnil Jakhade  * refclk100MHz_32b_PCIe_ln_int_ssc, multilink, using_plllc,
17658a1b82d7SSwapnil Jakhade  * cmn_pllcy_anaclk0_1Ghz, xcvr_pllclk_fullrt_500mhz
17668a1b82d7SSwapnil Jakhade  */
17678a1b82d7SSwapnil Jakhade static const struct cdns_reg_pairs ml_pcie_100_int_ssc_ln_regs[] = {
17688a1b82d7SSwapnil Jakhade 	{0xFC08, SIERRA_DET_STANDEC_A_PREG},
17698a1b82d7SSwapnil Jakhade 	{0x001D, SIERRA_PSM_A3IN_TMR_PREG},
17708a1b82d7SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_A3_PREG},
17718a1b82d7SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_A4_PREG},
17728a1b82d7SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_IDLE_PREG},
17738a1b82d7SSwapnil Jakhade 	{0x1555, SIERRA_DFE_BIASTRIM_PREG},
17748a1b82d7SSwapnil Jakhade 	{0x9703, SIERRA_DRVCTRL_BOOST_PREG},
17758a1b82d7SSwapnil Jakhade 	{0x813E, SIERRA_CLKPATHCTRL_TMR_PREG},
17768a1b82d7SSwapnil Jakhade 	{0x8047, SIERRA_RX_CREQ_FLTR_A_MODE3_PREG},
17778a1b82d7SSwapnil Jakhade 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE2_PREG},
17788a1b82d7SSwapnil Jakhade 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG},
17798a1b82d7SSwapnil Jakhade 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
17808a1b82d7SSwapnil Jakhade 	{0x0002, SIERRA_CREQ_DCBIASATTEN_OVR_PREG},
17818a1b82d7SSwapnil Jakhade 	{0x9800, SIERRA_RX_CTLE_CAL_PREG},
17828a1b82d7SSwapnil Jakhade 	{0x033C, SIERRA_RX_CTLE_MAINTENANCE_PREG},
17838a1b82d7SSwapnil Jakhade 	{0x44CC, SIERRA_CREQ_EQ_OPEN_EYE_THRESH_PREG},
17848a1b82d7SSwapnil Jakhade 	{0x5624, SIERRA_DEQ_CONCUR_CTRL2_PREG},
17858a1b82d7SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_EPIPWR_CTRL2_PREG},
17868a1b82d7SSwapnil Jakhade 	{0x00FF, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG},
17878a1b82d7SSwapnil Jakhade 	{0x4C4C, SIERRA_DEQ_ERRCMP_CTRL_PREG},
17888a1b82d7SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_OFFSET_CTRL_PREG},
17898a1b82d7SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_GAIN_CTRL_PREG},
17908a1b82d7SSwapnil Jakhade 	{0x0041, SIERRA_DEQ_GLUT0},
17918a1b82d7SSwapnil Jakhade 	{0x0082, SIERRA_DEQ_GLUT1},
17928a1b82d7SSwapnil Jakhade 	{0x00C3, SIERRA_DEQ_GLUT2},
17938a1b82d7SSwapnil Jakhade 	{0x0145, SIERRA_DEQ_GLUT3},
17948a1b82d7SSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT4},
17958a1b82d7SSwapnil Jakhade 	{0x09E7, SIERRA_DEQ_ALUT0},
17968a1b82d7SSwapnil Jakhade 	{0x09A6, SIERRA_DEQ_ALUT1},
17978a1b82d7SSwapnil Jakhade 	{0x0965, SIERRA_DEQ_ALUT2},
17988a1b82d7SSwapnil Jakhade 	{0x08E3, SIERRA_DEQ_ALUT3},
17998a1b82d7SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP0},
18008a1b82d7SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP1},
18018a1b82d7SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP2},
18028a1b82d7SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP3},
18038a1b82d7SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP4},
18048a1b82d7SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_PRECUR_PREG},
18058a1b82d7SSwapnil Jakhade 	{0x0280, SIERRA_DEQ_POSTCUR_PREG},
18068a1b82d7SSwapnil Jakhade 	{0x8F00, SIERRA_DEQ_POSTCUR_DECR_PREG},
18078a1b82d7SSwapnil Jakhade 	{0x3C0F, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG},
18088a1b82d7SSwapnil Jakhade 	{0x1C0C, SIERRA_DEQ_TAU_CTRL2_PREG},
18098a1b82d7SSwapnil Jakhade 	{0x0100, SIERRA_DEQ_TAU_CTRL3_PREG},
18108a1b82d7SSwapnil Jakhade 	{0x5E82, SIERRA_DEQ_OPENEYE_CTRL_PREG},
18118a1b82d7SSwapnil Jakhade 	{0x002B, SIERRA_CPI_TRIM_PREG},
18128a1b82d7SSwapnil Jakhade 	{0x0003, SIERRA_EPI_CTRL_PREG},
18138a1b82d7SSwapnil Jakhade 	{0x803F, SIERRA_SDFILT_H2L_A_PREG},
18148a1b82d7SSwapnil Jakhade 	{0x0004, SIERRA_RXBUFFER_CTLECTRL_PREG},
18158a1b82d7SSwapnil Jakhade 	{0x2010, SIERRA_RXBUFFER_RCDFECTRL_PREG},
18168a1b82d7SSwapnil Jakhade 	{0x4432, SIERRA_RXBUFFER_DFECTRL_PREG}
18178a1b82d7SSwapnil Jakhade };
18188a1b82d7SSwapnil Jakhade 
18198a1b82d7SSwapnil Jakhade static struct cdns_sierra_vals pcie_100_int_ssc_plllc_cmn_vals = {
18208a1b82d7SSwapnil Jakhade 	.reg_pairs = pcie_100_int_ssc_plllc_cmn_regs,
18218a1b82d7SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(pcie_100_int_ssc_plllc_cmn_regs),
18228a1b82d7SSwapnil Jakhade };
18238a1b82d7SSwapnil Jakhade 
18248a1b82d7SSwapnil Jakhade static struct cdns_sierra_vals ml_pcie_100_int_ssc_ln_vals = {
18258a1b82d7SSwapnil Jakhade 	.reg_pairs = ml_pcie_100_int_ssc_ln_regs,
18268a1b82d7SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(ml_pcie_100_int_ssc_ln_regs),
18278a1b82d7SSwapnil Jakhade };
18288a1b82d7SSwapnil Jakhade 
1829*e72659b6SSwapnil Jakhade /*
1830*e72659b6SSwapnil Jakhade  * TI J721E:
1831*e72659b6SSwapnil Jakhade  * refclk100MHz_32b_PCIe_ln_int_ssc, multilink, using_plllc,
1832*e72659b6SSwapnil Jakhade  * cmn_pllcy_anaclk0_1Ghz, xcvr_pllclk_fullrt_500mhz
1833*e72659b6SSwapnil Jakhade  */
1834*e72659b6SSwapnil Jakhade static const struct cdns_reg_pairs ti_ml_pcie_100_int_ssc_ln_regs[] = {
1835*e72659b6SSwapnil Jakhade 	{0xFC08, SIERRA_DET_STANDEC_A_PREG},
1836*e72659b6SSwapnil Jakhade 	{0x001D, SIERRA_PSM_A3IN_TMR_PREG},
1837*e72659b6SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_A3_PREG},
1838*e72659b6SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_A4_PREG},
1839*e72659b6SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_IDLE_PREG},
1840*e72659b6SSwapnil Jakhade 	{0x1555, SIERRA_DFE_BIASTRIM_PREG},
1841*e72659b6SSwapnil Jakhade 	{0x9703, SIERRA_DRVCTRL_BOOST_PREG},
1842*e72659b6SSwapnil Jakhade 	{0x813E, SIERRA_CLKPATHCTRL_TMR_PREG},
1843*e72659b6SSwapnil Jakhade 	{0x8047, SIERRA_RX_CREQ_FLTR_A_MODE3_PREG},
1844*e72659b6SSwapnil Jakhade 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE2_PREG},
1845*e72659b6SSwapnil Jakhade 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG},
1846*e72659b6SSwapnil Jakhade 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
1847*e72659b6SSwapnil Jakhade 	{0x0002, SIERRA_CREQ_DCBIASATTEN_OVR_PREG},
1848*e72659b6SSwapnil Jakhade 	{0x9800, SIERRA_RX_CTLE_CAL_PREG},
1849*e72659b6SSwapnil Jakhade 	{0x033C, SIERRA_RX_CTLE_MAINTENANCE_PREG},
1850*e72659b6SSwapnil Jakhade 	{0x44CC, SIERRA_CREQ_EQ_OPEN_EYE_THRESH_PREG},
1851*e72659b6SSwapnil Jakhade 	{0x5624, SIERRA_DEQ_CONCUR_CTRL2_PREG},
1852*e72659b6SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_EPIPWR_CTRL2_PREG},
1853*e72659b6SSwapnil Jakhade 	{0x00FF, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG},
1854*e72659b6SSwapnil Jakhade 	{0x4C4C, SIERRA_DEQ_ERRCMP_CTRL_PREG},
1855*e72659b6SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_OFFSET_CTRL_PREG},
1856*e72659b6SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_GAIN_CTRL_PREG},
1857*e72659b6SSwapnil Jakhade 	{0x0041, SIERRA_DEQ_GLUT0},
1858*e72659b6SSwapnil Jakhade 	{0x0082, SIERRA_DEQ_GLUT1},
1859*e72659b6SSwapnil Jakhade 	{0x00C3, SIERRA_DEQ_GLUT2},
1860*e72659b6SSwapnil Jakhade 	{0x0145, SIERRA_DEQ_GLUT3},
1861*e72659b6SSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT4},
1862*e72659b6SSwapnil Jakhade 	{0x09E7, SIERRA_DEQ_ALUT0},
1863*e72659b6SSwapnil Jakhade 	{0x09A6, SIERRA_DEQ_ALUT1},
1864*e72659b6SSwapnil Jakhade 	{0x0965, SIERRA_DEQ_ALUT2},
1865*e72659b6SSwapnil Jakhade 	{0x08E3, SIERRA_DEQ_ALUT3},
1866*e72659b6SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP0},
1867*e72659b6SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP1},
1868*e72659b6SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP2},
1869*e72659b6SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP3},
1870*e72659b6SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP4},
1871*e72659b6SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_PRECUR_PREG},
1872*e72659b6SSwapnil Jakhade 	{0x0280, SIERRA_DEQ_POSTCUR_PREG},
1873*e72659b6SSwapnil Jakhade 	{0x8F00, SIERRA_DEQ_POSTCUR_DECR_PREG},
1874*e72659b6SSwapnil Jakhade 	{0x3C0F, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG},
1875*e72659b6SSwapnil Jakhade 	{0x1C0C, SIERRA_DEQ_TAU_CTRL2_PREG},
1876*e72659b6SSwapnil Jakhade 	{0x0100, SIERRA_DEQ_TAU_CTRL3_PREG},
1877*e72659b6SSwapnil Jakhade 	{0x5E82, SIERRA_DEQ_OPENEYE_CTRL_PREG},
1878*e72659b6SSwapnil Jakhade 	{0x002B, SIERRA_CPI_TRIM_PREG},
1879*e72659b6SSwapnil Jakhade 	{0x0003, SIERRA_EPI_CTRL_PREG},
1880*e72659b6SSwapnil Jakhade 	{0x803F, SIERRA_SDFILT_H2L_A_PREG},
1881*e72659b6SSwapnil Jakhade 	{0x0004, SIERRA_RXBUFFER_CTLECTRL_PREG},
1882*e72659b6SSwapnil Jakhade 	{0x2010, SIERRA_RXBUFFER_RCDFECTRL_PREG},
1883*e72659b6SSwapnil Jakhade 	{0x4432, SIERRA_RXBUFFER_DFECTRL_PREG},
1884*e72659b6SSwapnil Jakhade 	{0x0002, SIERRA_TX_RCVDET_OVRD_PREG}
1885*e72659b6SSwapnil Jakhade };
1886*e72659b6SSwapnil Jakhade 
1887*e72659b6SSwapnil Jakhade static struct cdns_sierra_vals ti_ml_pcie_100_int_ssc_ln_vals = {
1888*e72659b6SSwapnil Jakhade 	.reg_pairs = ti_ml_pcie_100_int_ssc_ln_regs,
1889*e72659b6SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(ti_ml_pcie_100_int_ssc_ln_regs),
1890*e72659b6SSwapnil Jakhade };
1891*e72659b6SSwapnil Jakhade 
18928a1b82d7SSwapnil Jakhade /* refclk100MHz_32b_PCIe_cmn_pll_ext_ssc, pcie_links_using_plllc, pipe_bw_3 */
18938a1b82d7SSwapnil Jakhade static const struct cdns_reg_pairs pcie_100_ext_ssc_plllc_cmn_regs[] = {
18948a1b82d7SSwapnil Jakhade 	{0x2106, SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG},
18958a1b82d7SSwapnil Jakhade 	{0x2106, SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG},
18968a1b82d7SSwapnil Jakhade 	{0x8A06, SIERRA_CMN_PLLLC_BWCAL_MODE1_PREG},
18978a1b82d7SSwapnil Jakhade 	{0x8A06, SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG},
18988a1b82d7SSwapnil Jakhade 	{0x1B1B, SIERRA_CMN_PLLLC_SS_TIME_STEPSIZE_MODE_PREG}
18998a1b82d7SSwapnil Jakhade };
19008a1b82d7SSwapnil Jakhade 
19018a1b82d7SSwapnil Jakhade /*
19028a1b82d7SSwapnil Jakhade  * refclk100MHz_32b_PCIe_ln_ext_ssc, multilink, using_plllc,
19038a1b82d7SSwapnil Jakhade  * cmn_pllcy_anaclk0_1Ghz, xcvr_pllclk_fullrt_500mhz
19048a1b82d7SSwapnil Jakhade  */
19058a1b82d7SSwapnil Jakhade static const struct cdns_reg_pairs ml_pcie_100_ext_ssc_ln_regs[] = {
19068a1b82d7SSwapnil Jakhade 	{0xFC08, SIERRA_DET_STANDEC_A_PREG},
19078a1b82d7SSwapnil Jakhade 	{0x001D, SIERRA_PSM_A3IN_TMR_PREG},
19088a1b82d7SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_A3_PREG},
19098a1b82d7SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_A4_PREG},
19108a1b82d7SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_IDLE_PREG},
19118a1b82d7SSwapnil Jakhade 	{0x1555, SIERRA_DFE_BIASTRIM_PREG},
19128a1b82d7SSwapnil Jakhade 	{0x9703, SIERRA_DRVCTRL_BOOST_PREG},
19138a1b82d7SSwapnil Jakhade 	{0x813E, SIERRA_CLKPATHCTRL_TMR_PREG},
19148a1b82d7SSwapnil Jakhade 	{0x8047, SIERRA_RX_CREQ_FLTR_A_MODE3_PREG},
19158a1b82d7SSwapnil Jakhade 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE2_PREG},
19168a1b82d7SSwapnil Jakhade 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG},
19178a1b82d7SSwapnil Jakhade 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
19188a1b82d7SSwapnil Jakhade 	{0x0002, SIERRA_CREQ_DCBIASATTEN_OVR_PREG},
19198a1b82d7SSwapnil Jakhade 	{0x9800, SIERRA_RX_CTLE_CAL_PREG},
19208a1b82d7SSwapnil Jakhade 	{0x033C, SIERRA_RX_CTLE_MAINTENANCE_PREG},
19218a1b82d7SSwapnil Jakhade 	{0x44CC, SIERRA_CREQ_EQ_OPEN_EYE_THRESH_PREG},
19228a1b82d7SSwapnil Jakhade 	{0x5624, SIERRA_DEQ_CONCUR_CTRL2_PREG},
19238a1b82d7SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_EPIPWR_CTRL2_PREG},
19248a1b82d7SSwapnil Jakhade 	{0x00FF, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG},
19258a1b82d7SSwapnil Jakhade 	{0x4C4C, SIERRA_DEQ_ERRCMP_CTRL_PREG},
19268a1b82d7SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_OFFSET_CTRL_PREG},
19278a1b82d7SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_GAIN_CTRL_PREG},
19288a1b82d7SSwapnil Jakhade 	{0x0041, SIERRA_DEQ_GLUT0},
19298a1b82d7SSwapnil Jakhade 	{0x0082, SIERRA_DEQ_GLUT1},
19308a1b82d7SSwapnil Jakhade 	{0x00C3, SIERRA_DEQ_GLUT2},
19318a1b82d7SSwapnil Jakhade 	{0x0145, SIERRA_DEQ_GLUT3},
19328a1b82d7SSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT4},
19338a1b82d7SSwapnil Jakhade 	{0x09E7, SIERRA_DEQ_ALUT0},
19348a1b82d7SSwapnil Jakhade 	{0x09A6, SIERRA_DEQ_ALUT1},
19358a1b82d7SSwapnil Jakhade 	{0x0965, SIERRA_DEQ_ALUT2},
19368a1b82d7SSwapnil Jakhade 	{0x08E3, SIERRA_DEQ_ALUT3},
19378a1b82d7SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP0},
19388a1b82d7SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP1},
19398a1b82d7SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP2},
19408a1b82d7SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP3},
19418a1b82d7SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP4},
19428a1b82d7SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_PRECUR_PREG},
19438a1b82d7SSwapnil Jakhade 	{0x0280, SIERRA_DEQ_POSTCUR_PREG},
19448a1b82d7SSwapnil Jakhade 	{0x8F00, SIERRA_DEQ_POSTCUR_DECR_PREG},
19458a1b82d7SSwapnil Jakhade 	{0x3C0F, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG},
19468a1b82d7SSwapnil Jakhade 	{0x1C0C, SIERRA_DEQ_TAU_CTRL2_PREG},
19478a1b82d7SSwapnil Jakhade 	{0x0100, SIERRA_DEQ_TAU_CTRL3_PREG},
19488a1b82d7SSwapnil Jakhade 	{0x5E82, SIERRA_DEQ_OPENEYE_CTRL_PREG},
19498a1b82d7SSwapnil Jakhade 	{0x002B, SIERRA_CPI_TRIM_PREG},
19508a1b82d7SSwapnil Jakhade 	{0x0003, SIERRA_EPI_CTRL_PREG},
19518a1b82d7SSwapnil Jakhade 	{0x803F, SIERRA_SDFILT_H2L_A_PREG},
19528a1b82d7SSwapnil Jakhade 	{0x0004, SIERRA_RXBUFFER_CTLECTRL_PREG},
19538a1b82d7SSwapnil Jakhade 	{0x2010, SIERRA_RXBUFFER_RCDFECTRL_PREG},
19548a1b82d7SSwapnil Jakhade 	{0x4432, SIERRA_RXBUFFER_DFECTRL_PREG}
19558a1b82d7SSwapnil Jakhade };
19568a1b82d7SSwapnil Jakhade 
19578a1b82d7SSwapnil Jakhade static struct cdns_sierra_vals pcie_100_ext_ssc_plllc_cmn_vals = {
19588a1b82d7SSwapnil Jakhade 	.reg_pairs = pcie_100_ext_ssc_plllc_cmn_regs,
19598a1b82d7SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(pcie_100_ext_ssc_plllc_cmn_regs),
19608a1b82d7SSwapnil Jakhade };
19618a1b82d7SSwapnil Jakhade 
19628a1b82d7SSwapnil Jakhade static struct cdns_sierra_vals ml_pcie_100_ext_ssc_ln_vals = {
19638a1b82d7SSwapnil Jakhade 	.reg_pairs = ml_pcie_100_ext_ssc_ln_regs,
19648a1b82d7SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(ml_pcie_100_ext_ssc_ln_regs),
19658a1b82d7SSwapnil Jakhade };
19668a1b82d7SSwapnil Jakhade 
1967*e72659b6SSwapnil Jakhade /*
1968*e72659b6SSwapnil Jakhade  * TI J721E:
1969*e72659b6SSwapnil Jakhade  * refclk100MHz_32b_PCIe_ln_ext_ssc, multilink, using_plllc,
1970*e72659b6SSwapnil Jakhade  * cmn_pllcy_anaclk0_1Ghz, xcvr_pllclk_fullrt_500mhz
1971*e72659b6SSwapnil Jakhade  */
1972*e72659b6SSwapnil Jakhade static const struct cdns_reg_pairs ti_ml_pcie_100_ext_ssc_ln_regs[] = {
1973*e72659b6SSwapnil Jakhade 	{0xFC08, SIERRA_DET_STANDEC_A_PREG},
1974*e72659b6SSwapnil Jakhade 	{0x001D, SIERRA_PSM_A3IN_TMR_PREG},
1975*e72659b6SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_A3_PREG},
1976*e72659b6SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_A4_PREG},
1977*e72659b6SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_IDLE_PREG},
1978*e72659b6SSwapnil Jakhade 	{0x1555, SIERRA_DFE_BIASTRIM_PREG},
1979*e72659b6SSwapnil Jakhade 	{0x9703, SIERRA_DRVCTRL_BOOST_PREG},
1980*e72659b6SSwapnil Jakhade 	{0x813E, SIERRA_CLKPATHCTRL_TMR_PREG},
1981*e72659b6SSwapnil Jakhade 	{0x8047, SIERRA_RX_CREQ_FLTR_A_MODE3_PREG},
1982*e72659b6SSwapnil Jakhade 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE2_PREG},
1983*e72659b6SSwapnil Jakhade 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG},
1984*e72659b6SSwapnil Jakhade 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
1985*e72659b6SSwapnil Jakhade 	{0x0002, SIERRA_CREQ_DCBIASATTEN_OVR_PREG},
1986*e72659b6SSwapnil Jakhade 	{0x9800, SIERRA_RX_CTLE_CAL_PREG},
1987*e72659b6SSwapnil Jakhade 	{0x033C, SIERRA_RX_CTLE_MAINTENANCE_PREG},
1988*e72659b6SSwapnil Jakhade 	{0x44CC, SIERRA_CREQ_EQ_OPEN_EYE_THRESH_PREG},
1989*e72659b6SSwapnil Jakhade 	{0x5624, SIERRA_DEQ_CONCUR_CTRL2_PREG},
1990*e72659b6SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_EPIPWR_CTRL2_PREG},
1991*e72659b6SSwapnil Jakhade 	{0x00FF, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG},
1992*e72659b6SSwapnil Jakhade 	{0x4C4C, SIERRA_DEQ_ERRCMP_CTRL_PREG},
1993*e72659b6SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_OFFSET_CTRL_PREG},
1994*e72659b6SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_GAIN_CTRL_PREG},
1995*e72659b6SSwapnil Jakhade 	{0x0041, SIERRA_DEQ_GLUT0},
1996*e72659b6SSwapnil Jakhade 	{0x0082, SIERRA_DEQ_GLUT1},
1997*e72659b6SSwapnil Jakhade 	{0x00C3, SIERRA_DEQ_GLUT2},
1998*e72659b6SSwapnil Jakhade 	{0x0145, SIERRA_DEQ_GLUT3},
1999*e72659b6SSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT4},
2000*e72659b6SSwapnil Jakhade 	{0x09E7, SIERRA_DEQ_ALUT0},
2001*e72659b6SSwapnil Jakhade 	{0x09A6, SIERRA_DEQ_ALUT1},
2002*e72659b6SSwapnil Jakhade 	{0x0965, SIERRA_DEQ_ALUT2},
2003*e72659b6SSwapnil Jakhade 	{0x08E3, SIERRA_DEQ_ALUT3},
2004*e72659b6SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP0},
2005*e72659b6SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP1},
2006*e72659b6SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP2},
2007*e72659b6SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP3},
2008*e72659b6SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP4},
2009*e72659b6SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_PRECUR_PREG},
2010*e72659b6SSwapnil Jakhade 	{0x0280, SIERRA_DEQ_POSTCUR_PREG},
2011*e72659b6SSwapnil Jakhade 	{0x8F00, SIERRA_DEQ_POSTCUR_DECR_PREG},
2012*e72659b6SSwapnil Jakhade 	{0x3C0F, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG},
2013*e72659b6SSwapnil Jakhade 	{0x1C0C, SIERRA_DEQ_TAU_CTRL2_PREG},
2014*e72659b6SSwapnil Jakhade 	{0x0100, SIERRA_DEQ_TAU_CTRL3_PREG},
2015*e72659b6SSwapnil Jakhade 	{0x5E82, SIERRA_DEQ_OPENEYE_CTRL_PREG},
2016*e72659b6SSwapnil Jakhade 	{0x002B, SIERRA_CPI_TRIM_PREG},
2017*e72659b6SSwapnil Jakhade 	{0x0003, SIERRA_EPI_CTRL_PREG},
2018*e72659b6SSwapnil Jakhade 	{0x803F, SIERRA_SDFILT_H2L_A_PREG},
2019*e72659b6SSwapnil Jakhade 	{0x0004, SIERRA_RXBUFFER_CTLECTRL_PREG},
2020*e72659b6SSwapnil Jakhade 	{0x2010, SIERRA_RXBUFFER_RCDFECTRL_PREG},
2021*e72659b6SSwapnil Jakhade 	{0x4432, SIERRA_RXBUFFER_DFECTRL_PREG},
2022*e72659b6SSwapnil Jakhade 	{0x0002, SIERRA_TX_RCVDET_OVRD_PREG}
2023*e72659b6SSwapnil Jakhade };
2024*e72659b6SSwapnil Jakhade 
2025*e72659b6SSwapnil Jakhade static struct cdns_sierra_vals ti_ml_pcie_100_ext_ssc_ln_vals = {
2026*e72659b6SSwapnil Jakhade 	.reg_pairs = ti_ml_pcie_100_ext_ssc_ln_regs,
2027*e72659b6SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(ti_ml_pcie_100_ext_ssc_ln_regs),
2028*e72659b6SSwapnil Jakhade };
2029*e72659b6SSwapnil Jakhade 
20307a5ad9b4SSwapnil Jakhade /* refclk100MHz_32b_PCIe_cmn_pll_no_ssc */
20317a5ad9b4SSwapnil Jakhade static const struct cdns_reg_pairs cdns_pcie_cmn_regs_no_ssc[] = {
20327a5ad9b4SSwapnil Jakhade 	{0x2105, SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG},
20337a5ad9b4SSwapnil Jakhade 	{0x2105, SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG},
20347a5ad9b4SSwapnil Jakhade 	{0x8A06, SIERRA_CMN_PLLLC_BWCAL_MODE1_PREG},
20357a5ad9b4SSwapnil Jakhade 	{0x8A06, SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG}
20367a5ad9b4SSwapnil Jakhade };
20377a5ad9b4SSwapnil Jakhade 
20387a5ad9b4SSwapnil Jakhade /* refclk100MHz_32b_PCIe_ln_no_ssc */
20397a5ad9b4SSwapnil Jakhade static const struct cdns_reg_pairs cdns_pcie_ln_regs_no_ssc[] = {
20407a5ad9b4SSwapnil Jakhade 	{0xFC08, SIERRA_DET_STANDEC_A_PREG},
20417a5ad9b4SSwapnil Jakhade 	{0x001D, SIERRA_PSM_A3IN_TMR_PREG},
20427a5ad9b4SSwapnil Jakhade 	{0x1555, SIERRA_DFE_BIASTRIM_PREG},
20437a5ad9b4SSwapnil Jakhade 	{0x9703, SIERRA_DRVCTRL_BOOST_PREG},
20447a5ad9b4SSwapnil Jakhade 	{0x8055, SIERRA_RX_CREQ_FLTR_A_MODE3_PREG},
20457a5ad9b4SSwapnil Jakhade 	{0x80BB, SIERRA_RX_CREQ_FLTR_A_MODE2_PREG},
20467a5ad9b4SSwapnil Jakhade 	{0x8351, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG},
20477a5ad9b4SSwapnil Jakhade 	{0x8349, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
20487a5ad9b4SSwapnil Jakhade 	{0x0002, SIERRA_CREQ_DCBIASATTEN_OVR_PREG},
20497a5ad9b4SSwapnil Jakhade 	{0x9800, SIERRA_RX_CTLE_CAL_PREG},
20507a5ad9b4SSwapnil Jakhade 	{0x5624, SIERRA_DEQ_CONCUR_CTRL2_PREG},
20517a5ad9b4SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_EPIPWR_CTRL2_PREG},
20527a5ad9b4SSwapnil Jakhade 	{0x00FF, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG},
20537a5ad9b4SSwapnil Jakhade 	{0x4C4C, SIERRA_DEQ_ERRCMP_CTRL_PREG},
20547a5ad9b4SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_OFFSET_CTRL_PREG},
20557a5ad9b4SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_GAIN_CTRL_PREG},
20567a5ad9b4SSwapnil Jakhade 	{0x0041, SIERRA_DEQ_GLUT0},
20577a5ad9b4SSwapnil Jakhade 	{0x0082, SIERRA_DEQ_GLUT1},
20587a5ad9b4SSwapnil Jakhade 	{0x00C3, SIERRA_DEQ_GLUT2},
20597a5ad9b4SSwapnil Jakhade 	{0x0145, SIERRA_DEQ_GLUT3},
20607a5ad9b4SSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT4},
20617a5ad9b4SSwapnil Jakhade 	{0x09E7, SIERRA_DEQ_ALUT0},
20627a5ad9b4SSwapnil Jakhade 	{0x09A6, SIERRA_DEQ_ALUT1},
20637a5ad9b4SSwapnil Jakhade 	{0x0965, SIERRA_DEQ_ALUT2},
20647a5ad9b4SSwapnil Jakhade 	{0x08E3, SIERRA_DEQ_ALUT3},
20657a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP0},
20667a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP1},
20677a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP2},
20687a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP3},
20697a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP4},
20707a5ad9b4SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_PRECUR_PREG},
20717a5ad9b4SSwapnil Jakhade 	{0x0280, SIERRA_DEQ_POSTCUR_PREG},
20727a5ad9b4SSwapnil Jakhade 	{0x8F00, SIERRA_DEQ_POSTCUR_DECR_PREG},
20737a5ad9b4SSwapnil Jakhade 	{0x3C0F, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG},
20747a5ad9b4SSwapnil Jakhade 	{0x1C0C, SIERRA_DEQ_TAU_CTRL2_PREG},
20757a5ad9b4SSwapnil Jakhade 	{0x0100, SIERRA_DEQ_TAU_CTRL3_PREG},
20767a5ad9b4SSwapnil Jakhade 	{0x5E82, SIERRA_DEQ_OPENEYE_CTRL_PREG},
20777a5ad9b4SSwapnil Jakhade 	{0x002B, SIERRA_CPI_TRIM_PREG},
20787a5ad9b4SSwapnil Jakhade 	{0x0003, SIERRA_EPI_CTRL_PREG},
20797a5ad9b4SSwapnil Jakhade 	{0x803F, SIERRA_SDFILT_H2L_A_PREG},
20807a5ad9b4SSwapnil Jakhade 	{0x0004, SIERRA_RXBUFFER_CTLECTRL_PREG},
20817a5ad9b4SSwapnil Jakhade 	{0x2010, SIERRA_RXBUFFER_RCDFECTRL_PREG},
20827a5ad9b4SSwapnil Jakhade 	{0x4432, SIERRA_RXBUFFER_DFECTRL_PREG}
20837a5ad9b4SSwapnil Jakhade };
20847a5ad9b4SSwapnil Jakhade 
20857a5ad9b4SSwapnil Jakhade static struct cdns_sierra_vals pcie_100_no_ssc_cmn_vals = {
20867a5ad9b4SSwapnil Jakhade 	.reg_pairs = cdns_pcie_cmn_regs_no_ssc,
20877a5ad9b4SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(cdns_pcie_cmn_regs_no_ssc),
20887a5ad9b4SSwapnil Jakhade };
20897a5ad9b4SSwapnil Jakhade 
20907a5ad9b4SSwapnil Jakhade static struct cdns_sierra_vals pcie_100_no_ssc_ln_vals = {
20917a5ad9b4SSwapnil Jakhade 	.reg_pairs = cdns_pcie_ln_regs_no_ssc,
20927a5ad9b4SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(cdns_pcie_ln_regs_no_ssc),
20937a5ad9b4SSwapnil Jakhade };
20947a5ad9b4SSwapnil Jakhade 
20957a5ad9b4SSwapnil Jakhade /* refclk100MHz_32b_PCIe_cmn_pll_int_ssc */
20967a5ad9b4SSwapnil Jakhade static const struct cdns_reg_pairs cdns_pcie_cmn_regs_int_ssc[] = {
20977a5ad9b4SSwapnil Jakhade 	{0x000E, SIERRA_CMN_PLLLC_MODE_PREG},
20987a5ad9b4SSwapnil Jakhade 	{0x4006, SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG},
20997a5ad9b4SSwapnil Jakhade 	{0x4006, SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG},
21007a5ad9b4SSwapnil Jakhade 	{0x0000, SIERRA_CMN_PLLLC_BWCAL_MODE1_PREG},
21017a5ad9b4SSwapnil Jakhade 	{0x0000, SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG},
21027a5ad9b4SSwapnil Jakhade 	{0x0581, SIERRA_CMN_PLLLC_DSMCORR_PREG},
21037a5ad9b4SSwapnil Jakhade 	{0x7F80, SIERRA_CMN_PLLLC_SS_PREG},
21047a5ad9b4SSwapnil Jakhade 	{0x0041, SIERRA_CMN_PLLLC_SS_AMP_STEP_SIZE_PREG},
21057a5ad9b4SSwapnil Jakhade 	{0x0464, SIERRA_CMN_PLLLC_SSTWOPT_PREG},
21067a5ad9b4SSwapnil Jakhade 	{0x0D0D, SIERRA_CMN_PLLLC_SS_TIME_STEPSIZE_MODE_PREG},
21077a5ad9b4SSwapnil Jakhade 	{0x0060, SIERRA_CMN_PLLLC_LOCK_DELAY_CTRL_PREG}
21087a5ad9b4SSwapnil Jakhade };
21097a5ad9b4SSwapnil Jakhade 
21107a5ad9b4SSwapnil Jakhade /* refclk100MHz_32b_PCIe_ln_int_ssc */
21117a5ad9b4SSwapnil Jakhade static const struct cdns_reg_pairs cdns_pcie_ln_regs_int_ssc[] = {
21127a5ad9b4SSwapnil Jakhade 	{0xFC08, SIERRA_DET_STANDEC_A_PREG},
21137a5ad9b4SSwapnil Jakhade 	{0x001D, SIERRA_PSM_A3IN_TMR_PREG},
21147a5ad9b4SSwapnil Jakhade 	{0x1555, SIERRA_DFE_BIASTRIM_PREG},
21157a5ad9b4SSwapnil Jakhade 	{0x9703, SIERRA_DRVCTRL_BOOST_PREG},
21167a5ad9b4SSwapnil Jakhade 	{0x813E, SIERRA_CLKPATHCTRL_TMR_PREG},
21177a5ad9b4SSwapnil Jakhade 	{0x8047, SIERRA_RX_CREQ_FLTR_A_MODE3_PREG},
21187a5ad9b4SSwapnil Jakhade 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE2_PREG},
21197a5ad9b4SSwapnil Jakhade 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG},
21207a5ad9b4SSwapnil Jakhade 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
21217a5ad9b4SSwapnil Jakhade 	{0x0002, SIERRA_CREQ_DCBIASATTEN_OVR_PREG},
21227a5ad9b4SSwapnil Jakhade 	{0x9800, SIERRA_RX_CTLE_CAL_PREG},
21237a5ad9b4SSwapnil Jakhade 	{0x033C, SIERRA_RX_CTLE_MAINTENANCE_PREG},
21247a5ad9b4SSwapnil Jakhade 	{0x44CC, SIERRA_CREQ_EQ_OPEN_EYE_THRESH_PREG},
21257a5ad9b4SSwapnil Jakhade 	{0x5624, SIERRA_DEQ_CONCUR_CTRL2_PREG},
21267a5ad9b4SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_EPIPWR_CTRL2_PREG},
21277a5ad9b4SSwapnil Jakhade 	{0x00FF, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG},
21287a5ad9b4SSwapnil Jakhade 	{0x4C4C, SIERRA_DEQ_ERRCMP_CTRL_PREG},
21297a5ad9b4SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_OFFSET_CTRL_PREG},
21307a5ad9b4SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_GAIN_CTRL_PREG},
21317a5ad9b4SSwapnil Jakhade 	{0x0041, SIERRA_DEQ_GLUT0},
21327a5ad9b4SSwapnil Jakhade 	{0x0082, SIERRA_DEQ_GLUT1},
21337a5ad9b4SSwapnil Jakhade 	{0x00C3, SIERRA_DEQ_GLUT2},
21347a5ad9b4SSwapnil Jakhade 	{0x0145, SIERRA_DEQ_GLUT3},
21357a5ad9b4SSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT4},
21367a5ad9b4SSwapnil Jakhade 	{0x09E7, SIERRA_DEQ_ALUT0},
21377a5ad9b4SSwapnil Jakhade 	{0x09A6, SIERRA_DEQ_ALUT1},
21387a5ad9b4SSwapnil Jakhade 	{0x0965, SIERRA_DEQ_ALUT2},
21397a5ad9b4SSwapnil Jakhade 	{0x08E3, SIERRA_DEQ_ALUT3},
21407a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP0},
21417a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP1},
21427a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP2},
21437a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP3},
21447a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP4},
21457a5ad9b4SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_PRECUR_PREG},
21467a5ad9b4SSwapnil Jakhade 	{0x0280, SIERRA_DEQ_POSTCUR_PREG},
21477a5ad9b4SSwapnil Jakhade 	{0x8F00, SIERRA_DEQ_POSTCUR_DECR_PREG},
21487a5ad9b4SSwapnil Jakhade 	{0x3C0F, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG},
21497a5ad9b4SSwapnil Jakhade 	{0x1C0C, SIERRA_DEQ_TAU_CTRL2_PREG},
21507a5ad9b4SSwapnil Jakhade 	{0x0100, SIERRA_DEQ_TAU_CTRL3_PREG},
21517a5ad9b4SSwapnil Jakhade 	{0x5E82, SIERRA_DEQ_OPENEYE_CTRL_PREG},
21527a5ad9b4SSwapnil Jakhade 	{0x002B, SIERRA_CPI_TRIM_PREG},
21537a5ad9b4SSwapnil Jakhade 	{0x0003, SIERRA_EPI_CTRL_PREG},
21547a5ad9b4SSwapnil Jakhade 	{0x803F, SIERRA_SDFILT_H2L_A_PREG},
21557a5ad9b4SSwapnil Jakhade 	{0x0004, SIERRA_RXBUFFER_CTLECTRL_PREG},
21567a5ad9b4SSwapnil Jakhade 	{0x2010, SIERRA_RXBUFFER_RCDFECTRL_PREG},
21577a5ad9b4SSwapnil Jakhade 	{0x4432, SIERRA_RXBUFFER_DFECTRL_PREG}
21587a5ad9b4SSwapnil Jakhade };
21597a5ad9b4SSwapnil Jakhade 
21607a5ad9b4SSwapnil Jakhade static struct cdns_sierra_vals pcie_100_int_ssc_cmn_vals = {
21617a5ad9b4SSwapnil Jakhade 	.reg_pairs = cdns_pcie_cmn_regs_int_ssc,
21627a5ad9b4SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(cdns_pcie_cmn_regs_int_ssc),
21637a5ad9b4SSwapnil Jakhade };
21647a5ad9b4SSwapnil Jakhade 
21657a5ad9b4SSwapnil Jakhade static struct cdns_sierra_vals pcie_100_int_ssc_ln_vals = {
21667a5ad9b4SSwapnil Jakhade 	.reg_pairs = cdns_pcie_ln_regs_int_ssc,
21677a5ad9b4SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(cdns_pcie_ln_regs_int_ssc),
21687a5ad9b4SSwapnil Jakhade };
21697a5ad9b4SSwapnil Jakhade 
2170871002d7SAnil Varughese /* refclk100MHz_32b_PCIe_cmn_pll_ext_ssc */
21713cfb0e8eSRikard Falkeborn static const struct cdns_reg_pairs cdns_pcie_cmn_regs_ext_ssc[] = {
2172871002d7SAnil Varughese 	{0x2106, SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG},
2173871002d7SAnil Varughese 	{0x2106, SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG},
2174871002d7SAnil Varughese 	{0x8A06, SIERRA_CMN_PLLLC_BWCAL_MODE1_PREG},
2175871002d7SAnil Varughese 	{0x8A06, SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG},
2176871002d7SAnil Varughese 	{0x1B1B, SIERRA_CMN_PLLLC_SS_TIME_STEPSIZE_MODE_PREG}
2177871002d7SAnil Varughese };
2178871002d7SAnil Varughese 
2179871002d7SAnil Varughese /* refclk100MHz_32b_PCIe_ln_ext_ssc */
21803cfb0e8eSRikard Falkeborn static const struct cdns_reg_pairs cdns_pcie_ln_regs_ext_ssc[] = {
21817a5ad9b4SSwapnil Jakhade 	{0xFC08, SIERRA_DET_STANDEC_A_PREG},
21827a5ad9b4SSwapnil Jakhade 	{0x001D, SIERRA_PSM_A3IN_TMR_PREG},
21837a5ad9b4SSwapnil Jakhade 	{0x1555, SIERRA_DFE_BIASTRIM_PREG},
21847a5ad9b4SSwapnil Jakhade 	{0x9703, SIERRA_DRVCTRL_BOOST_PREG},
2185871002d7SAnil Varughese 	{0x813E, SIERRA_CLKPATHCTRL_TMR_PREG},
2186871002d7SAnil Varughese 	{0x8047, SIERRA_RX_CREQ_FLTR_A_MODE3_PREG},
2187871002d7SAnil Varughese 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE2_PREG},
2188871002d7SAnil Varughese 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG},
2189871002d7SAnil Varughese 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
21907a5ad9b4SSwapnil Jakhade 	{0x0002, SIERRA_CREQ_DCBIASATTEN_OVR_PREG},
21917a5ad9b4SSwapnil Jakhade 	{0x9800, SIERRA_RX_CTLE_CAL_PREG},
2192871002d7SAnil Varughese 	{0x033C, SIERRA_RX_CTLE_MAINTENANCE_PREG},
21937a5ad9b4SSwapnil Jakhade 	{0x44CC, SIERRA_CREQ_EQ_OPEN_EYE_THRESH_PREG},
21947a5ad9b4SSwapnil Jakhade 	{0x5624, SIERRA_DEQ_CONCUR_CTRL2_PREG},
21957a5ad9b4SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_EPIPWR_CTRL2_PREG},
21967a5ad9b4SSwapnil Jakhade 	{0x00FF, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG},
21977a5ad9b4SSwapnil Jakhade 	{0x4C4C, SIERRA_DEQ_ERRCMP_CTRL_PREG},
21987a5ad9b4SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_OFFSET_CTRL_PREG},
21997a5ad9b4SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_GAIN_CTRL_PREG},
22007a5ad9b4SSwapnil Jakhade 	{0x0041, SIERRA_DEQ_GLUT0},
22017a5ad9b4SSwapnil Jakhade 	{0x0082, SIERRA_DEQ_GLUT1},
22027a5ad9b4SSwapnil Jakhade 	{0x00C3, SIERRA_DEQ_GLUT2},
22037a5ad9b4SSwapnil Jakhade 	{0x0145, SIERRA_DEQ_GLUT3},
22047a5ad9b4SSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT4},
22057a5ad9b4SSwapnil Jakhade 	{0x09E7, SIERRA_DEQ_ALUT0},
22067a5ad9b4SSwapnil Jakhade 	{0x09A6, SIERRA_DEQ_ALUT1},
22077a5ad9b4SSwapnil Jakhade 	{0x0965, SIERRA_DEQ_ALUT2},
22087a5ad9b4SSwapnil Jakhade 	{0x08E3, SIERRA_DEQ_ALUT3},
22097a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP0},
22107a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP1},
22117a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP2},
22127a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP3},
22137a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP4},
22147a5ad9b4SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_PRECUR_PREG},
22157a5ad9b4SSwapnil Jakhade 	{0x0280, SIERRA_DEQ_POSTCUR_PREG},
22167a5ad9b4SSwapnil Jakhade 	{0x8F00, SIERRA_DEQ_POSTCUR_DECR_PREG},
22177a5ad9b4SSwapnil Jakhade 	{0x3C0F, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG},
22187a5ad9b4SSwapnil Jakhade 	{0x1C0C, SIERRA_DEQ_TAU_CTRL2_PREG},
22197a5ad9b4SSwapnil Jakhade 	{0x0100, SIERRA_DEQ_TAU_CTRL3_PREG},
22207a5ad9b4SSwapnil Jakhade 	{0x5E82, SIERRA_DEQ_OPENEYE_CTRL_PREG},
22217a5ad9b4SSwapnil Jakhade 	{0x002B, SIERRA_CPI_TRIM_PREG},
22227a5ad9b4SSwapnil Jakhade 	{0x0003, SIERRA_EPI_CTRL_PREG},
22237a5ad9b4SSwapnil Jakhade 	{0x803F, SIERRA_SDFILT_H2L_A_PREG},
22247a5ad9b4SSwapnil Jakhade 	{0x0004, SIERRA_RXBUFFER_CTLECTRL_PREG},
22257a5ad9b4SSwapnil Jakhade 	{0x2010, SIERRA_RXBUFFER_RCDFECTRL_PREG},
22267a5ad9b4SSwapnil Jakhade 	{0x4432, SIERRA_RXBUFFER_DFECTRL_PREG}
2227871002d7SAnil Varughese };
2228871002d7SAnil Varughese 
2229078e9e92SSwapnil Jakhade static struct cdns_sierra_vals pcie_100_ext_ssc_cmn_vals = {
2230078e9e92SSwapnil Jakhade 	.reg_pairs = cdns_pcie_cmn_regs_ext_ssc,
2231078e9e92SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(cdns_pcie_cmn_regs_ext_ssc),
2232078e9e92SSwapnil Jakhade };
2233078e9e92SSwapnil Jakhade 
2234078e9e92SSwapnil Jakhade static struct cdns_sierra_vals pcie_100_ext_ssc_ln_vals = {
2235078e9e92SSwapnil Jakhade 	.reg_pairs = cdns_pcie_ln_regs_ext_ssc,
2236078e9e92SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(cdns_pcie_ln_regs_ext_ssc),
2237078e9e92SSwapnil Jakhade };
2238078e9e92SSwapnil Jakhade 
2239871002d7SAnil Varughese /* refclk100MHz_20b_USB_cmn_pll_ext_ssc */
22403cfb0e8eSRikard Falkeborn static const struct cdns_reg_pairs cdns_usb_cmn_regs_ext_ssc[] = {
2241871002d7SAnil Varughese 	{0x2085, SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG},
2242871002d7SAnil Varughese 	{0x2085, SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG},
2243871002d7SAnil Varughese 	{0x0000, SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG},
2244871002d7SAnil Varughese 	{0x0000, SIERRA_CMN_PLLLC_SS_TIME_STEPSIZE_MODE_PREG}
2245871002d7SAnil Varughese };
2246871002d7SAnil Varughese 
2247871002d7SAnil Varughese /* refclk100MHz_20b_USB_ln_ext_ssc */
22483cfb0e8eSRikard Falkeborn static const struct cdns_reg_pairs cdns_usb_ln_regs_ext_ssc[] = {
2249aead5fd6SKishon Vijay Abraham I 	{0xFE0A, SIERRA_DET_STANDEC_A_PREG},
2250aead5fd6SKishon Vijay Abraham I 	{0x000F, SIERRA_DET_STANDEC_B_PREG},
22512bcf14caSSanket Parmar 	{0x55A5, SIERRA_DET_STANDEC_C_PREG},
2252871002d7SAnil Varughese 	{0x69ad, SIERRA_DET_STANDEC_D_PREG},
2253aead5fd6SKishon Vijay Abraham I 	{0x0241, SIERRA_DET_STANDEC_E_PREG},
22542bcf14caSSanket Parmar 	{0x0110, SIERRA_PSM_LANECAL_DLY_A1_RESETS_PREG},
2255871002d7SAnil Varughese 	{0x0014, SIERRA_PSM_A0IN_TMR_PREG},
2256aead5fd6SKishon Vijay Abraham I 	{0xCF00, SIERRA_PSM_DIAG_PREG},
2257aead5fd6SKishon Vijay Abraham I 	{0x001F, SIERRA_PSC_TX_A0_PREG},
2258aead5fd6SKishon Vijay Abraham I 	{0x0007, SIERRA_PSC_TX_A1_PREG},
2259aead5fd6SKishon Vijay Abraham I 	{0x0003, SIERRA_PSC_TX_A2_PREG},
2260aead5fd6SKishon Vijay Abraham I 	{0x0003, SIERRA_PSC_TX_A3_PREG},
2261aead5fd6SKishon Vijay Abraham I 	{0x0FFF, SIERRA_PSC_RX_A0_PREG},
22622bcf14caSSanket Parmar 	{0x0003, SIERRA_PSC_RX_A1_PREG},
2263aead5fd6SKishon Vijay Abraham I 	{0x0003, SIERRA_PSC_RX_A2_PREG},
2264aead5fd6SKishon Vijay Abraham I 	{0x0001, SIERRA_PSC_RX_A3_PREG},
2265aead5fd6SKishon Vijay Abraham I 	{0x0001, SIERRA_PLLCTRL_SUBRATE_PREG},
2266aead5fd6SKishon Vijay Abraham I 	{0x0406, SIERRA_PLLCTRL_GEN_D_PREG},
2267871002d7SAnil Varughese 	{0x5233, SIERRA_PLLCTRL_CPGAIN_MODE_PREG},
2268871002d7SAnil Varughese 	{0x00CA, SIERRA_CLKPATH_BIASTRIM_PREG},
2269871002d7SAnil Varughese 	{0x2512, SIERRA_DFE_BIASTRIM_PREG},
2270aead5fd6SKishon Vijay Abraham I 	{0x0000, SIERRA_DRVCTRL_ATTEN_PREG},
22712bcf14caSSanket Parmar 	{0x823E, SIERRA_CLKPATHCTRL_TMR_PREG},
22722bcf14caSSanket Parmar 	{0x078F, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG},
22732bcf14caSSanket Parmar 	{0x078F, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
2274aead5fd6SKishon Vijay Abraham I 	{0x7B3C, SIERRA_CREQ_CCLKDET_MODE01_PREG},
22752bcf14caSSanket Parmar 	{0x023C, SIERRA_RX_CTLE_MAINTENANCE_PREG},
2276aead5fd6SKishon Vijay Abraham I 	{0x3232, SIERRA_CREQ_FSMCLK_SEL_PREG},
2277871002d7SAnil Varughese 	{0x0000, SIERRA_CREQ_EQ_CTRL_PREG},
22782bcf14caSSanket Parmar 	{0x0000, SIERRA_CREQ_SPARE_PREG},
2279871002d7SAnil Varughese 	{0xCC44, SIERRA_CREQ_EQ_OPEN_EYE_THRESH_PREG},
22802bcf14caSSanket Parmar 	{0x8452, SIERRA_CTLELUT_CTRL_PREG},
22812bcf14caSSanket Parmar 	{0x4121, SIERRA_DFE_ECMP_RATESEL_PREG},
22822bcf14caSSanket Parmar 	{0x4121, SIERRA_DFE_SMP_RATESEL_PREG},
22832bcf14caSSanket Parmar 	{0x0003, SIERRA_DEQ_PHALIGN_CTRL},
2284871002d7SAnil Varughese 	{0x3200, SIERRA_DEQ_CONCUR_CTRL1_PREG},
2285871002d7SAnil Varughese 	{0x5064, SIERRA_DEQ_CONCUR_CTRL2_PREG},
2286871002d7SAnil Varughese 	{0x0030, SIERRA_DEQ_EPIPWR_CTRL2_PREG},
2287871002d7SAnil Varughese 	{0x0048, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG},
2288871002d7SAnil Varughese 	{0x5A5A, SIERRA_DEQ_ERRCMP_CTRL_PREG},
2289871002d7SAnil Varughese 	{0x02F5, SIERRA_DEQ_OFFSET_CTRL_PREG},
2290871002d7SAnil Varughese 	{0x02F5, SIERRA_DEQ_GAIN_CTRL_PREG},
22912bcf14caSSanket Parmar 	{0x9999, SIERRA_DEQ_VGATUNE_CTRL_PREG},
2292871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT0},
2293871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT1},
2294871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT2},
2295871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT3},
2296871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT4},
2297871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT5},
2298871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT6},
2299871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT7},
2300871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT8},
2301871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT9},
2302871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT10},
2303871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT11},
2304871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT12},
2305871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT13},
2306871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT14},
2307871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT15},
2308871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT16},
2309871002d7SAnil Varughese 	{0x0BAE, SIERRA_DEQ_ALUT0},
2310871002d7SAnil Varughese 	{0x0AEB, SIERRA_DEQ_ALUT1},
2311871002d7SAnil Varughese 	{0x0A28, SIERRA_DEQ_ALUT2},
2312871002d7SAnil Varughese 	{0x0965, SIERRA_DEQ_ALUT3},
2313871002d7SAnil Varughese 	{0x08A2, SIERRA_DEQ_ALUT4},
2314871002d7SAnil Varughese 	{0x07DF, SIERRA_DEQ_ALUT5},
2315871002d7SAnil Varughese 	{0x071C, SIERRA_DEQ_ALUT6},
2316871002d7SAnil Varughese 	{0x0659, SIERRA_DEQ_ALUT7},
2317871002d7SAnil Varughese 	{0x0596, SIERRA_DEQ_ALUT8},
2318871002d7SAnil Varughese 	{0x0514, SIERRA_DEQ_ALUT9},
2319871002d7SAnil Varughese 	{0x0492, SIERRA_DEQ_ALUT10},
2320871002d7SAnil Varughese 	{0x0410, SIERRA_DEQ_ALUT11},
2321871002d7SAnil Varughese 	{0x038E, SIERRA_DEQ_ALUT12},
2322871002d7SAnil Varughese 	{0x030C, SIERRA_DEQ_ALUT13},
2323871002d7SAnil Varughese 	{0x03F4, SIERRA_DEQ_DFETAP_CTRL_PREG},
2324871002d7SAnil Varughese 	{0x0001, SIERRA_DFE_EN_1010_IGNORE_PREG},
2325871002d7SAnil Varughese 	{0x3C01, SIERRA_DEQ_TAU_CTRL1_FAST_MAINT_PREG},
2326871002d7SAnil Varughese 	{0x3C40, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG},
2327871002d7SAnil Varughese 	{0x1C08, SIERRA_DEQ_TAU_CTRL2_PREG},
2328871002d7SAnil Varughese 	{0x0033, SIERRA_DEQ_PICTRL_PREG},
2329871002d7SAnil Varughese 	{0x0400, SIERRA_CPICAL_TMRVAL_MODE1_PREG},
2330871002d7SAnil Varughese 	{0x0330, SIERRA_CPICAL_TMRVAL_MODE0_PREG},
2331871002d7SAnil Varughese 	{0x01FF, SIERRA_CPICAL_PICNT_MODE1_PREG},
2332aead5fd6SKishon Vijay Abraham I 	{0x0009, SIERRA_CPI_OUTBUF_RATESEL_PREG},
2333871002d7SAnil Varughese 	{0x3232, SIERRA_CPICAL_RES_STARTCODE_MODE23_PREG},
2334871002d7SAnil Varughese 	{0x0005, SIERRA_LFPSDET_SUPPORT_PREG},
2335aead5fd6SKishon Vijay Abraham I 	{0x000F, SIERRA_LFPSFILT_NS_PREG},
2336aead5fd6SKishon Vijay Abraham I 	{0x0009, SIERRA_LFPSFILT_RD_PREG},
2337aead5fd6SKishon Vijay Abraham I 	{0x0001, SIERRA_LFPSFILT_MP_PREG},
23382bcf14caSSanket Parmar 	{0x6013, SIERRA_SIGDET_SUPPORT_PREG},
2339aead5fd6SKishon Vijay Abraham I 	{0x8013, SIERRA_SDFILT_H2L_A_PREG},
2340871002d7SAnil Varughese 	{0x8009, SIERRA_SDFILT_L2H_PREG},
2341871002d7SAnil Varughese 	{0x0024, SIERRA_RXBUFFER_CTLECTRL_PREG},
2342871002d7SAnil Varughese 	{0x0020, SIERRA_RXBUFFER_RCDFECTRL_PREG},
2343871002d7SAnil Varughese 	{0x4243, SIERRA_RXBUFFER_DFECTRL_PREG}
234444d30d62SAlan Douglas };
234544d30d62SAlan Douglas 
2346078e9e92SSwapnil Jakhade static struct cdns_sierra_vals usb_100_ext_ssc_cmn_vals = {
2347078e9e92SSwapnil Jakhade 	.reg_pairs = cdns_usb_cmn_regs_ext_ssc,
2348078e9e92SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(cdns_usb_cmn_regs_ext_ssc),
2349078e9e92SSwapnil Jakhade };
2350078e9e92SSwapnil Jakhade 
2351078e9e92SSwapnil Jakhade static struct cdns_sierra_vals usb_100_ext_ssc_ln_vals = {
2352078e9e92SSwapnil Jakhade 	.reg_pairs = cdns_usb_ln_regs_ext_ssc,
2353078e9e92SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(cdns_usb_ln_regs_ext_ssc),
2354078e9e92SSwapnil Jakhade };
2355078e9e92SSwapnil Jakhade 
235644d30d62SAlan Douglas static const struct cdns_sierra_data cdns_map_sierra = {
2357078e9e92SSwapnil Jakhade 	.id_value = SIERRA_MACRO_ID,
2358078e9e92SSwapnil Jakhade 	.block_offset_shift = 0x2,
2359078e9e92SSwapnil Jakhade 	.reg_offset_shift = 0x2,
2360fa105172SSwapnil Jakhade 	.pcs_cmn_vals = {
2361fa105172SSwapnil Jakhade 		[TYPE_PCIE] = {
2362fa105172SSwapnil Jakhade 			[TYPE_NONE] = {
23637a5ad9b4SSwapnil Jakhade 				[NO_SSC] = &pcie_phy_pcs_cmn_vals,
2364fa105172SSwapnil Jakhade 				[EXTERNAL_SSC] = &pcie_phy_pcs_cmn_vals,
23657a5ad9b4SSwapnil Jakhade 				[INTERNAL_SSC] = &pcie_phy_pcs_cmn_vals,
2366fa105172SSwapnil Jakhade 			},
23678a1b82d7SSwapnil Jakhade 			[TYPE_QSGMII] = {
23688a1b82d7SSwapnil Jakhade 				[NO_SSC] = &pcie_phy_pcs_cmn_vals,
23698a1b82d7SSwapnil Jakhade 				[EXTERNAL_SSC] = &pcie_phy_pcs_cmn_vals,
23708a1b82d7SSwapnil Jakhade 				[INTERNAL_SSC] = &pcie_phy_pcs_cmn_vals,
23718a1b82d7SSwapnil Jakhade 			},
2372fa105172SSwapnil Jakhade 		},
2373fa105172SSwapnil Jakhade 	},
2374078e9e92SSwapnil Jakhade 	.pma_cmn_vals = {
2375078e9e92SSwapnil Jakhade 		[TYPE_PCIE] = {
2376078e9e92SSwapnil Jakhade 			[TYPE_NONE] = {
23777a5ad9b4SSwapnil Jakhade 				[NO_SSC] = &pcie_100_no_ssc_cmn_vals,
2378078e9e92SSwapnil Jakhade 				[EXTERNAL_SSC] = &pcie_100_ext_ssc_cmn_vals,
23797a5ad9b4SSwapnil Jakhade 				[INTERNAL_SSC] = &pcie_100_int_ssc_cmn_vals,
2380078e9e92SSwapnil Jakhade 			},
23818a1b82d7SSwapnil Jakhade 			[TYPE_QSGMII] = {
23828a1b82d7SSwapnil Jakhade 				[NO_SSC] = &pcie_100_no_ssc_plllc_cmn_vals,
23838a1b82d7SSwapnil Jakhade 				[EXTERNAL_SSC] = &pcie_100_ext_ssc_plllc_cmn_vals,
23848a1b82d7SSwapnil Jakhade 				[INTERNAL_SSC] = &pcie_100_int_ssc_plllc_cmn_vals,
23858a1b82d7SSwapnil Jakhade 			},
2386078e9e92SSwapnil Jakhade 		},
2387078e9e92SSwapnil Jakhade 		[TYPE_USB] = {
2388078e9e92SSwapnil Jakhade 			[TYPE_NONE] = {
2389078e9e92SSwapnil Jakhade 				[EXTERNAL_SSC] = &usb_100_ext_ssc_cmn_vals,
2390078e9e92SSwapnil Jakhade 			},
2391078e9e92SSwapnil Jakhade 		},
23928a1b82d7SSwapnil Jakhade 		[TYPE_QSGMII] = {
23938a1b82d7SSwapnil Jakhade 			[TYPE_PCIE] = {
23948a1b82d7SSwapnil Jakhade 				[NO_SSC] = &qsgmii_100_no_ssc_plllc1_cmn_vals,
23958a1b82d7SSwapnil Jakhade 				[EXTERNAL_SSC] = &qsgmii_100_no_ssc_plllc1_cmn_vals,
23968a1b82d7SSwapnil Jakhade 				[INTERNAL_SSC] = &qsgmii_100_no_ssc_plllc1_cmn_vals,
23978a1b82d7SSwapnil Jakhade 			},
23988a1b82d7SSwapnil Jakhade 		},
2399078e9e92SSwapnil Jakhade 	},
2400078e9e92SSwapnil Jakhade 	.pma_ln_vals = {
2401078e9e92SSwapnil Jakhade 		[TYPE_PCIE] = {
2402078e9e92SSwapnil Jakhade 			[TYPE_NONE] = {
24037a5ad9b4SSwapnil Jakhade 				[NO_SSC] = &pcie_100_no_ssc_ln_vals,
2404078e9e92SSwapnil Jakhade 				[EXTERNAL_SSC] = &pcie_100_ext_ssc_ln_vals,
24057a5ad9b4SSwapnil Jakhade 				[INTERNAL_SSC] = &pcie_100_int_ssc_ln_vals,
2406078e9e92SSwapnil Jakhade 			},
24078a1b82d7SSwapnil Jakhade 			[TYPE_QSGMII] = {
24088a1b82d7SSwapnil Jakhade 				[NO_SSC] = &ml_pcie_100_no_ssc_ln_vals,
24098a1b82d7SSwapnil Jakhade 				[EXTERNAL_SSC] = &ml_pcie_100_ext_ssc_ln_vals,
24108a1b82d7SSwapnil Jakhade 				[INTERNAL_SSC] = &ml_pcie_100_int_ssc_ln_vals,
24118a1b82d7SSwapnil Jakhade 			},
2412078e9e92SSwapnil Jakhade 		},
2413078e9e92SSwapnil Jakhade 		[TYPE_USB] = {
2414078e9e92SSwapnil Jakhade 			[TYPE_NONE] = {
2415078e9e92SSwapnil Jakhade 				[EXTERNAL_SSC] = &usb_100_ext_ssc_ln_vals,
2416078e9e92SSwapnil Jakhade 			},
2417078e9e92SSwapnil Jakhade 		},
24188a1b82d7SSwapnil Jakhade 		[TYPE_QSGMII] = {
24198a1b82d7SSwapnil Jakhade 			[TYPE_PCIE] = {
24208a1b82d7SSwapnil Jakhade 				[NO_SSC] = &qsgmii_100_no_ssc_plllc1_ln_vals,
24218a1b82d7SSwapnil Jakhade 				[EXTERNAL_SSC] = &qsgmii_100_no_ssc_plllc1_ln_vals,
24228a1b82d7SSwapnil Jakhade 				[INTERNAL_SSC] = &qsgmii_100_no_ssc_plllc1_ln_vals,
24238a1b82d7SSwapnil Jakhade 			},
24248a1b82d7SSwapnil Jakhade 		},
2425078e9e92SSwapnil Jakhade 	},
242644d30d62SAlan Douglas };
242744d30d62SAlan Douglas 
2428367da978SKishon Vijay Abraham I static const struct cdns_sierra_data cdns_ti_map_sierra = {
2429078e9e92SSwapnil Jakhade 	.id_value = SIERRA_MACRO_ID,
2430078e9e92SSwapnil Jakhade 	.block_offset_shift = 0x0,
2431078e9e92SSwapnil Jakhade 	.reg_offset_shift = 0x1,
2432fa105172SSwapnil Jakhade 	.pcs_cmn_vals = {
2433fa105172SSwapnil Jakhade 		[TYPE_PCIE] = {
2434fa105172SSwapnil Jakhade 			[TYPE_NONE] = {
24357a5ad9b4SSwapnil Jakhade 				[NO_SSC] = &pcie_phy_pcs_cmn_vals,
2436fa105172SSwapnil Jakhade 				[EXTERNAL_SSC] = &pcie_phy_pcs_cmn_vals,
24377a5ad9b4SSwapnil Jakhade 				[INTERNAL_SSC] = &pcie_phy_pcs_cmn_vals,
2438fa105172SSwapnil Jakhade 			},
24398a1b82d7SSwapnil Jakhade 			[TYPE_QSGMII] = {
24408a1b82d7SSwapnil Jakhade 				[NO_SSC] = &pcie_phy_pcs_cmn_vals,
24418a1b82d7SSwapnil Jakhade 				[EXTERNAL_SSC] = &pcie_phy_pcs_cmn_vals,
24428a1b82d7SSwapnil Jakhade 				[INTERNAL_SSC] = &pcie_phy_pcs_cmn_vals,
24438a1b82d7SSwapnil Jakhade 			},
24448a1b82d7SSwapnil Jakhade 		},
24458a1b82d7SSwapnil Jakhade 	},
24468a1b82d7SSwapnil Jakhade 	.phy_pma_ln_vals = {
24478a1b82d7SSwapnil Jakhade 		[TYPE_QSGMII] = {
24488a1b82d7SSwapnil Jakhade 			[TYPE_PCIE] = {
24498a1b82d7SSwapnil Jakhade 				[NO_SSC] = &qsgmii_phy_pma_ln_vals,
24508a1b82d7SSwapnil Jakhade 				[EXTERNAL_SSC] = &qsgmii_phy_pma_ln_vals,
24518a1b82d7SSwapnil Jakhade 				[INTERNAL_SSC] = &qsgmii_phy_pma_ln_vals,
24528a1b82d7SSwapnil Jakhade 			},
2453fa105172SSwapnil Jakhade 		},
2454fa105172SSwapnil Jakhade 	},
2455078e9e92SSwapnil Jakhade 	.pma_cmn_vals = {
2456078e9e92SSwapnil Jakhade 		[TYPE_PCIE] = {
2457078e9e92SSwapnil Jakhade 			[TYPE_NONE] = {
24587a5ad9b4SSwapnil Jakhade 				[NO_SSC] = &pcie_100_no_ssc_cmn_vals,
2459078e9e92SSwapnil Jakhade 				[EXTERNAL_SSC] = &pcie_100_ext_ssc_cmn_vals,
24607a5ad9b4SSwapnil Jakhade 				[INTERNAL_SSC] = &pcie_100_int_ssc_cmn_vals,
2461078e9e92SSwapnil Jakhade 			},
24628a1b82d7SSwapnil Jakhade 			[TYPE_QSGMII] = {
24638a1b82d7SSwapnil Jakhade 				[NO_SSC] = &pcie_100_no_ssc_plllc_cmn_vals,
24648a1b82d7SSwapnil Jakhade 				[EXTERNAL_SSC] = &pcie_100_ext_ssc_plllc_cmn_vals,
24658a1b82d7SSwapnil Jakhade 				[INTERNAL_SSC] = &pcie_100_int_ssc_plllc_cmn_vals,
24668a1b82d7SSwapnil Jakhade 			},
2467078e9e92SSwapnil Jakhade 		},
2468078e9e92SSwapnil Jakhade 		[TYPE_USB] = {
2469078e9e92SSwapnil Jakhade 			[TYPE_NONE] = {
2470078e9e92SSwapnil Jakhade 				[EXTERNAL_SSC] = &usb_100_ext_ssc_cmn_vals,
2471078e9e92SSwapnil Jakhade 			},
2472078e9e92SSwapnil Jakhade 		},
24738a1b82d7SSwapnil Jakhade 		[TYPE_QSGMII] = {
24748a1b82d7SSwapnil Jakhade 			[TYPE_PCIE] = {
24758a1b82d7SSwapnil Jakhade 				[NO_SSC] = &qsgmii_100_no_ssc_plllc1_cmn_vals,
24768a1b82d7SSwapnil Jakhade 				[EXTERNAL_SSC] = &qsgmii_100_no_ssc_plllc1_cmn_vals,
24778a1b82d7SSwapnil Jakhade 				[INTERNAL_SSC] = &qsgmii_100_no_ssc_plllc1_cmn_vals,
24788a1b82d7SSwapnil Jakhade 			},
24798a1b82d7SSwapnil Jakhade 		},
2480078e9e92SSwapnil Jakhade 	},
2481078e9e92SSwapnil Jakhade 	.pma_ln_vals = {
2482078e9e92SSwapnil Jakhade 		[TYPE_PCIE] = {
2483078e9e92SSwapnil Jakhade 			[TYPE_NONE] = {
24847a5ad9b4SSwapnil Jakhade 				[NO_SSC] = &pcie_100_no_ssc_ln_vals,
2485078e9e92SSwapnil Jakhade 				[EXTERNAL_SSC] = &pcie_100_ext_ssc_ln_vals,
24867a5ad9b4SSwapnil Jakhade 				[INTERNAL_SSC] = &pcie_100_int_ssc_ln_vals,
2487078e9e92SSwapnil Jakhade 			},
24888a1b82d7SSwapnil Jakhade 			[TYPE_QSGMII] = {
2489*e72659b6SSwapnil Jakhade 				[NO_SSC] = &ti_ml_pcie_100_no_ssc_ln_vals,
2490*e72659b6SSwapnil Jakhade 				[EXTERNAL_SSC] = &ti_ml_pcie_100_ext_ssc_ln_vals,
2491*e72659b6SSwapnil Jakhade 				[INTERNAL_SSC] = &ti_ml_pcie_100_int_ssc_ln_vals,
24928a1b82d7SSwapnil Jakhade 			},
2493078e9e92SSwapnil Jakhade 		},
2494078e9e92SSwapnil Jakhade 		[TYPE_USB] = {
2495078e9e92SSwapnil Jakhade 			[TYPE_NONE] = {
2496078e9e92SSwapnil Jakhade 				[EXTERNAL_SSC] = &usb_100_ext_ssc_ln_vals,
2497078e9e92SSwapnil Jakhade 			},
2498078e9e92SSwapnil Jakhade 		},
24998a1b82d7SSwapnil Jakhade 		[TYPE_QSGMII] = {
25008a1b82d7SSwapnil Jakhade 			[TYPE_PCIE] = {
25018a1b82d7SSwapnil Jakhade 				[NO_SSC] = &qsgmii_100_no_ssc_plllc1_ln_vals,
25028a1b82d7SSwapnil Jakhade 				[EXTERNAL_SSC] = &qsgmii_100_no_ssc_plllc1_ln_vals,
25038a1b82d7SSwapnil Jakhade 				[INTERNAL_SSC] = &qsgmii_100_no_ssc_plllc1_ln_vals,
25048a1b82d7SSwapnil Jakhade 			},
25058a1b82d7SSwapnil Jakhade 		},
2506078e9e92SSwapnil Jakhade 	},
2507367da978SKishon Vijay Abraham I };
2508367da978SKishon Vijay Abraham I 
250944d30d62SAlan Douglas static const struct of_device_id cdns_sierra_id_table[] = {
251044d30d62SAlan Douglas 	{
251144d30d62SAlan Douglas 		.compatible = "cdns,sierra-phy-t0",
251244d30d62SAlan Douglas 		.data = &cdns_map_sierra,
251344d30d62SAlan Douglas 	},
2514367da978SKishon Vijay Abraham I 	{
2515367da978SKishon Vijay Abraham I 		.compatible = "ti,sierra-phy-t0",
2516367da978SKishon Vijay Abraham I 		.data = &cdns_ti_map_sierra,
2517367da978SKishon Vijay Abraham I 	},
251844d30d62SAlan Douglas 	{}
251944d30d62SAlan Douglas };
252044d30d62SAlan Douglas MODULE_DEVICE_TABLE(of, cdns_sierra_id_table);
252144d30d62SAlan Douglas 
252244d30d62SAlan Douglas static struct platform_driver cdns_sierra_driver = {
252344d30d62SAlan Douglas 	.probe		= cdns_sierra_phy_probe,
252444d30d62SAlan Douglas 	.remove		= cdns_sierra_phy_remove,
252544d30d62SAlan Douglas 	.driver		= {
252644d30d62SAlan Douglas 		.name	= "cdns-sierra-phy",
252744d30d62SAlan Douglas 		.of_match_table = cdns_sierra_id_table,
252844d30d62SAlan Douglas 	},
252944d30d62SAlan Douglas };
253044d30d62SAlan Douglas module_platform_driver(cdns_sierra_driver);
253144d30d62SAlan Douglas 
253244d30d62SAlan Douglas MODULE_ALIAS("platform:cdns_sierra");
253344d30d62SAlan Douglas MODULE_AUTHOR("Cadence Design Systems");
253444d30d62SAlan Douglas MODULE_DESCRIPTION("CDNS sierra phy driver");
253544d30d62SAlan Douglas MODULE_LICENSE("GPL v2");
2536