xref: /linux/drivers/phy/cadence/phy-cadence-sierra.c (revision e9ddb1ad98130d542c9f0d5dbfa6c833420a03ab)
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
86e72659b6SSwapnil 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;
351c3c11d55SSwapnil Jakhade 	const struct cdns_sierra_data *init_data;
35244d30d62SAlan Douglas 	struct cdns_sierra_inst phys[SIERRA_MAX_LANES];
35344d30d62SAlan Douglas 	struct reset_control *phy_rst;
35444d30d62SAlan Douglas 	struct reset_control *apb_rst;
355380f5708SKishon Vijay Abraham I 	struct regmap *regmap_lane_cdb[SIERRA_MAX_LANES];
3568c95e172SSwapnil Jakhade 	struct regmap *regmap_phy_pcs_common_cdb;
35736ce4163SSwapnil Jakhade 	struct regmap *regmap_phy_pcs_lane_cdb[SIERRA_MAX_LANES];
358f1cc6c3fSSwapnil Jakhade 	struct regmap *regmap_phy_pma_common_cdb;
3596b81f05aSSwapnil Jakhade 	struct regmap *regmap_phy_pma_lane_cdb[SIERRA_MAX_LANES];
360380f5708SKishon Vijay Abraham I 	struct regmap *regmap_common_cdb;
361380f5708SKishon Vijay Abraham I 	struct regmap_field *macro_id_type;
362380f5708SKishon Vijay Abraham I 	struct regmap_field *phy_pll_cfg_1;
363f1cc6c3fSSwapnil Jakhade 	struct regmap_field *pma_cmn_ready;
364adc4bd6fSKishon Vijay Abraham I 	struct regmap_field *pllctrl_lock[SIERRA_MAX_LANES];
36536ce4163SSwapnil Jakhade 	struct regmap_field *phy_iso_link_ctrl_1[SIERRA_MAX_LANES];
36628081b72SKishon Vijay Abraham I 	struct regmap_field *cmn_refrcv_refclk_plllc1en_preg[SIERRA_NUM_CMN_PLLC];
36728081b72SKishon Vijay Abraham I 	struct regmap_field *cmn_refrcv_refclk_termen_preg[SIERRA_NUM_CMN_PLLC];
36828081b72SKishon Vijay Abraham I 	struct regmap_field *cmn_plllc_pfdclk1_sel_preg[SIERRA_NUM_CMN_PLLC];
369a0c30cd7SKishon Vijay Abraham I 	struct clk *input_clks[CDNS_SIERRA_INPUT_CLOCKS];
37044d30d62SAlan Douglas 	int nsubnodes;
371a43f72aeSKishon Vijay Abraham I 	u32 num_lanes;
37244d30d62SAlan Douglas 	bool autoconf;
373d88ca22dSAswath Govindraju 	int already_configured;
37428081b72SKishon Vijay Abraham I 	struct clk_onecell_data clk_data;
37528081b72SKishon Vijay Abraham I 	struct clk *output_clks[CDNS_SIERRA_OUTPUT_CLOCKS];
37644d30d62SAlan Douglas };
37744d30d62SAlan Douglas 
378380f5708SKishon Vijay Abraham I static int cdns_regmap_write(void *context, unsigned int reg, unsigned int val)
379380f5708SKishon Vijay Abraham I {
380380f5708SKishon Vijay Abraham I 	struct cdns_regmap_cdb_context *ctx = context;
381380f5708SKishon Vijay Abraham I 	u32 offset = reg << ctx->reg_offset_shift;
382380f5708SKishon Vijay Abraham I 
383380f5708SKishon Vijay Abraham I 	writew(val, ctx->base + offset);
384380f5708SKishon Vijay Abraham I 
385380f5708SKishon Vijay Abraham I 	return 0;
386380f5708SKishon Vijay Abraham I }
387380f5708SKishon Vijay Abraham I 
388380f5708SKishon Vijay Abraham I static int cdns_regmap_read(void *context, unsigned int reg, unsigned int *val)
389380f5708SKishon Vijay Abraham I {
390380f5708SKishon Vijay Abraham I 	struct cdns_regmap_cdb_context *ctx = context;
391380f5708SKishon Vijay Abraham I 	u32 offset = reg << ctx->reg_offset_shift;
392380f5708SKishon Vijay Abraham I 
393380f5708SKishon Vijay Abraham I 	*val = readw(ctx->base + offset);
394380f5708SKishon Vijay Abraham I 	return 0;
395380f5708SKishon Vijay Abraham I }
396380f5708SKishon Vijay Abraham I 
397380f5708SKishon Vijay Abraham I #define SIERRA_LANE_CDB_REGMAP_CONF(n) \
398380f5708SKishon Vijay Abraham I { \
399380f5708SKishon Vijay Abraham I 	.name = "sierra_lane" n "_cdb", \
400380f5708SKishon Vijay Abraham I 	.reg_stride = 1, \
401380f5708SKishon Vijay Abraham I 	.fast_io = true, \
402380f5708SKishon Vijay Abraham I 	.reg_write = cdns_regmap_write, \
403380f5708SKishon Vijay Abraham I 	.reg_read = cdns_regmap_read, \
404380f5708SKishon Vijay Abraham I }
405380f5708SKishon Vijay Abraham I 
4063cfb0e8eSRikard Falkeborn static const struct regmap_config cdns_sierra_lane_cdb_config[] = {
407380f5708SKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("0"),
408380f5708SKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("1"),
409380f5708SKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("2"),
410380f5708SKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("3"),
411a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("4"),
412a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("5"),
413a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("6"),
414a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("7"),
415a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("8"),
416a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("9"),
417a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("10"),
418a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("11"),
419a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("12"),
420a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("13"),
421a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("14"),
422a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("15"),
423380f5708SKishon Vijay Abraham I };
424380f5708SKishon Vijay Abraham I 
4253cfb0e8eSRikard Falkeborn static const struct regmap_config cdns_sierra_common_cdb_config = {
426380f5708SKishon Vijay Abraham I 	.name = "sierra_common_cdb",
427380f5708SKishon Vijay Abraham I 	.reg_stride = 1,
428380f5708SKishon Vijay Abraham I 	.fast_io = true,
429380f5708SKishon Vijay Abraham I 	.reg_write = cdns_regmap_write,
430380f5708SKishon Vijay Abraham I 	.reg_read = cdns_regmap_read,
431380f5708SKishon Vijay Abraham I };
432380f5708SKishon Vijay Abraham I 
4338c95e172SSwapnil Jakhade static const struct regmap_config cdns_sierra_phy_pcs_cmn_cdb_config = {
4348c95e172SSwapnil Jakhade 	.name = "sierra_phy_pcs_cmn_cdb",
435380f5708SKishon Vijay Abraham I 	.reg_stride = 1,
436380f5708SKishon Vijay Abraham I 	.fast_io = true,
437380f5708SKishon Vijay Abraham I 	.reg_write = cdns_regmap_write,
438380f5708SKishon Vijay Abraham I 	.reg_read = cdns_regmap_read,
439380f5708SKishon Vijay Abraham I };
440380f5708SKishon Vijay Abraham I 
44136ce4163SSwapnil Jakhade #define SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF(n) \
44236ce4163SSwapnil Jakhade { \
44336ce4163SSwapnil Jakhade 	.name = "sierra_phy_pcs_lane" n "_cdb", \
44436ce4163SSwapnil Jakhade 	.reg_stride = 1, \
44536ce4163SSwapnil Jakhade 	.fast_io = true, \
44636ce4163SSwapnil Jakhade 	.reg_write = cdns_regmap_write, \
44736ce4163SSwapnil Jakhade 	.reg_read = cdns_regmap_read, \
44836ce4163SSwapnil Jakhade }
44936ce4163SSwapnil Jakhade 
45036ce4163SSwapnil Jakhade static const struct regmap_config cdns_sierra_phy_pcs_lane_cdb_config[] = {
45136ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("0"),
45236ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("1"),
45336ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("2"),
45436ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("3"),
45536ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("4"),
45636ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("5"),
45736ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("6"),
45836ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("7"),
45936ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("8"),
46036ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("9"),
46136ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("10"),
46236ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("11"),
46336ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("12"),
46436ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("13"),
46536ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("14"),
46636ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("15"),
46736ce4163SSwapnil Jakhade };
46836ce4163SSwapnil Jakhade 
469f1cc6c3fSSwapnil Jakhade static const struct regmap_config cdns_sierra_phy_pma_cmn_cdb_config = {
470f1cc6c3fSSwapnil Jakhade 	.name = "sierra_phy_pma_cmn_cdb",
471f1cc6c3fSSwapnil Jakhade 	.reg_stride = 1,
472f1cc6c3fSSwapnil Jakhade 	.fast_io = true,
473f1cc6c3fSSwapnil Jakhade 	.reg_write = cdns_regmap_write,
474f1cc6c3fSSwapnil Jakhade 	.reg_read = cdns_regmap_read,
475f1cc6c3fSSwapnil Jakhade };
476f1cc6c3fSSwapnil Jakhade 
4776b81f05aSSwapnil Jakhade #define SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF(n) \
4786b81f05aSSwapnil Jakhade { \
4796b81f05aSSwapnil Jakhade 	.name = "sierra_phy_pma_lane" n "_cdb", \
4806b81f05aSSwapnil Jakhade 	.reg_stride = 1, \
4816b81f05aSSwapnil Jakhade 	.fast_io = true, \
4826b81f05aSSwapnil Jakhade 	.reg_write = cdns_regmap_write, \
4836b81f05aSSwapnil Jakhade 	.reg_read = cdns_regmap_read, \
4846b81f05aSSwapnil Jakhade }
4856b81f05aSSwapnil Jakhade 
4866b81f05aSSwapnil Jakhade static const struct regmap_config cdns_sierra_phy_pma_lane_cdb_config[] = {
4876b81f05aSSwapnil Jakhade 	SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("0"),
4886b81f05aSSwapnil Jakhade 	SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("1"),
4896b81f05aSSwapnil Jakhade 	SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("2"),
4906b81f05aSSwapnil Jakhade 	SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("3"),
4916b81f05aSSwapnil Jakhade 	SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("4"),
4926b81f05aSSwapnil Jakhade 	SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("5"),
4936b81f05aSSwapnil Jakhade 	SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("6"),
4946b81f05aSSwapnil Jakhade 	SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("7"),
4956b81f05aSSwapnil Jakhade 	SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("8"),
4966b81f05aSSwapnil Jakhade 	SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("9"),
4976b81f05aSSwapnil Jakhade 	SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("10"),
4986b81f05aSSwapnil Jakhade 	SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("11"),
4996b81f05aSSwapnil Jakhade 	SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("12"),
5006b81f05aSSwapnil Jakhade 	SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("13"),
5016b81f05aSSwapnil Jakhade 	SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("14"),
5026b81f05aSSwapnil Jakhade 	SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("15"),
5036b81f05aSSwapnil Jakhade };
5046b81f05aSSwapnil Jakhade 
505cedcc2e2SKishon Vijay Abraham I static int cdns_sierra_phy_init(struct phy *gphy)
50644d30d62SAlan Douglas {
50744d30d62SAlan Douglas 	struct cdns_sierra_inst *ins = phy_get_drvdata(gphy);
50844d30d62SAlan Douglas 	struct cdns_sierra_phy *phy = dev_get_drvdata(gphy->dev.parent);
509078e9e92SSwapnil Jakhade 	const struct cdns_sierra_data *init_data = phy->init_data;
510078e9e92SSwapnil Jakhade 	struct cdns_sierra_vals *pma_cmn_vals, *pma_ln_vals;
511078e9e92SSwapnil Jakhade 	enum cdns_sierra_phy_type phy_type = ins->phy_type;
5121e902b2aSSwapnil Jakhade 	enum cdns_sierra_ssc_mode ssc = ins->ssc_mode;
5136b81f05aSSwapnil Jakhade 	struct cdns_sierra_vals *phy_pma_ln_vals;
514078e9e92SSwapnil Jakhade 	const struct cdns_reg_pairs *reg_pairs;
515fa105172SSwapnil Jakhade 	struct cdns_sierra_vals *pcs_cmn_vals;
51680f96fb1SColin Ian King 	struct regmap *regmap;
517078e9e92SSwapnil Jakhade 	u32 num_regs;
51844d30d62SAlan Douglas 	int i, j;
51944d30d62SAlan Douglas 
520cedcc2e2SKishon Vijay Abraham I 	/* Initialise the PHY registers, unless auto configured */
521d88ca22dSAswath Govindraju 	if (phy->autoconf || phy->already_configured || phy->nsubnodes > 1)
522cedcc2e2SKishon Vijay Abraham I 		return 0;
523cedcc2e2SKishon Vijay Abraham I 
524a0c30cd7SKishon Vijay Abraham I 	clk_set_rate(phy->input_clks[CMN_REFCLK_DIG_DIV], 25000000);
525a0c30cd7SKishon Vijay Abraham I 	clk_set_rate(phy->input_clks[CMN_REFCLK1_DIG_DIV], 25000000);
526078e9e92SSwapnil Jakhade 
527fa105172SSwapnil Jakhade 	/* PHY PCS common registers configurations */
528fa105172SSwapnil Jakhade 	pcs_cmn_vals = init_data->pcs_cmn_vals[phy_type][TYPE_NONE][ssc];
529fa105172SSwapnil Jakhade 	if (pcs_cmn_vals) {
530fa105172SSwapnil Jakhade 		reg_pairs = pcs_cmn_vals->reg_pairs;
531fa105172SSwapnil Jakhade 		num_regs = pcs_cmn_vals->num_regs;
532fa105172SSwapnil Jakhade 		regmap = phy->regmap_phy_pcs_common_cdb;
533fa105172SSwapnil Jakhade 		for (i = 0; i < num_regs; i++)
534fa105172SSwapnil Jakhade 			regmap_write(regmap, reg_pairs[i].off, reg_pairs[i].val);
535fa105172SSwapnil Jakhade 	}
536fa105172SSwapnil Jakhade 
5376b81f05aSSwapnil Jakhade 	/* PHY PMA lane registers configurations */
5386b81f05aSSwapnil Jakhade 	phy_pma_ln_vals = init_data->phy_pma_ln_vals[phy_type][TYPE_NONE][ssc];
5396b81f05aSSwapnil Jakhade 	if (phy_pma_ln_vals) {
5406b81f05aSSwapnil Jakhade 		reg_pairs = phy_pma_ln_vals->reg_pairs;
5416b81f05aSSwapnil Jakhade 		num_regs = phy_pma_ln_vals->num_regs;
5426b81f05aSSwapnil Jakhade 		for (i = 0; i < ins->num_lanes; i++) {
5436b81f05aSSwapnil Jakhade 			regmap = phy->regmap_phy_pma_lane_cdb[i + ins->mlane];
5446b81f05aSSwapnil Jakhade 			for (j = 0; j < num_regs; j++)
5456b81f05aSSwapnil Jakhade 				regmap_write(regmap, reg_pairs[j].off, reg_pairs[j].val);
5466b81f05aSSwapnil Jakhade 		}
5476b81f05aSSwapnil Jakhade 	}
5486b81f05aSSwapnil Jakhade 
549078e9e92SSwapnil Jakhade 	/* PMA common registers configurations */
550078e9e92SSwapnil Jakhade 	pma_cmn_vals = init_data->pma_cmn_vals[phy_type][TYPE_NONE][ssc];
551078e9e92SSwapnil Jakhade 	if (pma_cmn_vals) {
552078e9e92SSwapnil Jakhade 		reg_pairs = pma_cmn_vals->reg_pairs;
553078e9e92SSwapnil Jakhade 		num_regs = pma_cmn_vals->num_regs;
554078e9e92SSwapnil Jakhade 		regmap = phy->regmap_common_cdb;
555078e9e92SSwapnil Jakhade 		for (i = 0; i < num_regs; i++)
556078e9e92SSwapnil Jakhade 			regmap_write(regmap, reg_pairs[i].off, reg_pairs[i].val);
55744d30d62SAlan Douglas 	}
558871002d7SAnil Varughese 
559078e9e92SSwapnil Jakhade 	/* PMA lane registers configurations */
560078e9e92SSwapnil Jakhade 	pma_ln_vals = init_data->pma_ln_vals[phy_type][TYPE_NONE][ssc];
561078e9e92SSwapnil Jakhade 	if (pma_ln_vals) {
562078e9e92SSwapnil Jakhade 		reg_pairs = pma_ln_vals->reg_pairs;
563078e9e92SSwapnil Jakhade 		num_regs = pma_ln_vals->num_regs;
564380f5708SKishon Vijay Abraham I 		for (i = 0; i < ins->num_lanes; i++) {
565380f5708SKishon Vijay Abraham I 			regmap = phy->regmap_lane_cdb[i + ins->mlane];
566078e9e92SSwapnil Jakhade 			for (j = 0; j < num_regs; j++)
567078e9e92SSwapnil Jakhade 				regmap_write(regmap, reg_pairs[j].off, reg_pairs[j].val);
568380f5708SKishon Vijay Abraham I 		}
569380f5708SKishon Vijay Abraham I 	}
570cedcc2e2SKishon Vijay Abraham I 
571cedcc2e2SKishon Vijay Abraham I 	return 0;
57244d30d62SAlan Douglas }
57344d30d62SAlan Douglas 
57444d30d62SAlan Douglas static int cdns_sierra_phy_on(struct phy *gphy)
57544d30d62SAlan Douglas {
576adc4bd6fSKishon Vijay Abraham I 	struct cdns_sierra_phy *sp = dev_get_drvdata(gphy->dev.parent);
57744d30d62SAlan Douglas 	struct cdns_sierra_inst *ins = phy_get_drvdata(gphy);
578adc4bd6fSKishon Vijay Abraham I 	struct device *dev = sp->dev;
579adc4bd6fSKishon Vijay Abraham I 	u32 val;
580adc4bd6fSKishon Vijay Abraham I 	int ret;
58144d30d62SAlan Douglas 
5826b81f05aSSwapnil Jakhade 	if (sp->nsubnodes == 1) {
5836b81f05aSSwapnil Jakhade 		/* Take the PHY out of reset */
5845b4f5757SKishon Vijay Abraham I 		ret = reset_control_deassert(sp->phy_rst);
5855b4f5757SKishon Vijay Abraham I 		if (ret) {
5865b4f5757SKishon Vijay Abraham I 			dev_err(dev, "Failed to take the PHY out of reset\n");
5875b4f5757SKishon Vijay Abraham I 			return ret;
5885b4f5757SKishon Vijay Abraham I 		}
5896b81f05aSSwapnil Jakhade 	}
5905b4f5757SKishon Vijay Abraham I 
59144d30d62SAlan Douglas 	/* Take the PHY lane group out of reset */
592adc4bd6fSKishon Vijay Abraham I 	ret = reset_control_deassert(ins->lnk_rst);
593adc4bd6fSKishon Vijay Abraham I 	if (ret) {
594adc4bd6fSKishon Vijay Abraham I 		dev_err(dev, "Failed to take the PHY lane out of reset\n");
595adc4bd6fSKishon Vijay Abraham I 		return ret;
596adc4bd6fSKishon Vijay Abraham I 	}
597adc4bd6fSKishon Vijay Abraham I 
59836ce4163SSwapnil Jakhade 	if (ins->phy_type == TYPE_PCIE || ins->phy_type == TYPE_USB) {
59936ce4163SSwapnil Jakhade 		ret = regmap_field_read_poll_timeout(sp->phy_iso_link_ctrl_1[ins->mlane],
60036ce4163SSwapnil Jakhade 						     val, !val, 1000, PLL_LOCK_TIME);
60136ce4163SSwapnil Jakhade 		if (ret) {
60236ce4163SSwapnil Jakhade 			dev_err(dev, "Timeout waiting for PHY status ready\n");
60336ce4163SSwapnil Jakhade 			return ret;
60436ce4163SSwapnil Jakhade 		}
60536ce4163SSwapnil Jakhade 	}
60636ce4163SSwapnil Jakhade 
607f1cc6c3fSSwapnil Jakhade 	/*
608f1cc6c3fSSwapnil Jakhade 	 * Wait for cmn_ready assertion
609f1cc6c3fSSwapnil Jakhade 	 * PHY_PMA_CMN_CTRL[0] == 1
610f1cc6c3fSSwapnil Jakhade 	 */
611f1cc6c3fSSwapnil Jakhade 	ret = regmap_field_read_poll_timeout(sp->pma_cmn_ready, val, val,
612f1cc6c3fSSwapnil Jakhade 					     1000, PLL_LOCK_TIME);
613f1cc6c3fSSwapnil Jakhade 	if (ret) {
614f1cc6c3fSSwapnil Jakhade 		dev_err(dev, "Timeout waiting for CMN ready\n");
615f1cc6c3fSSwapnil Jakhade 		return ret;
616f1cc6c3fSSwapnil Jakhade 	}
617f1cc6c3fSSwapnil Jakhade 
618adc4bd6fSKishon Vijay Abraham I 	ret = regmap_field_read_poll_timeout(sp->pllctrl_lock[ins->mlane],
619adc4bd6fSKishon Vijay Abraham I 					     val, val, 1000, PLL_LOCK_TIME);
620adc4bd6fSKishon Vijay Abraham I 	if (ret < 0)
621adc4bd6fSKishon Vijay Abraham I 		dev_err(dev, "PLL lock of lane failed\n");
622adc4bd6fSKishon Vijay Abraham I 
623adc4bd6fSKishon Vijay Abraham I 	return ret;
62444d30d62SAlan Douglas }
62544d30d62SAlan Douglas 
62644d30d62SAlan Douglas static int cdns_sierra_phy_off(struct phy *gphy)
62744d30d62SAlan Douglas {
62844d30d62SAlan Douglas 	struct cdns_sierra_inst *ins = phy_get_drvdata(gphy);
62944d30d62SAlan Douglas 
63044d30d62SAlan Douglas 	return reset_control_assert(ins->lnk_rst);
63144d30d62SAlan Douglas }
63244d30d62SAlan Douglas 
6337904e15bSRoger Quadros static int cdns_sierra_phy_reset(struct phy *gphy)
6347904e15bSRoger Quadros {
6357904e15bSRoger Quadros 	struct cdns_sierra_phy *sp = dev_get_drvdata(gphy->dev.parent);
6367904e15bSRoger Quadros 
6377904e15bSRoger Quadros 	reset_control_assert(sp->phy_rst);
6387904e15bSRoger Quadros 	reset_control_deassert(sp->phy_rst);
6397904e15bSRoger Quadros 	return 0;
6407904e15bSRoger Quadros };
6417904e15bSRoger Quadros 
64244d30d62SAlan Douglas static const struct phy_ops ops = {
643cedcc2e2SKishon Vijay Abraham I 	.init		= cdns_sierra_phy_init,
64444d30d62SAlan Douglas 	.power_on	= cdns_sierra_phy_on,
64544d30d62SAlan Douglas 	.power_off	= cdns_sierra_phy_off,
6467904e15bSRoger Quadros 	.reset		= cdns_sierra_phy_reset,
64744d30d62SAlan Douglas 	.owner		= THIS_MODULE,
64844d30d62SAlan Douglas };
64944d30d62SAlan Douglas 
650d88ca22dSAswath Govindraju static int cdns_sierra_noop_phy_on(struct phy *gphy)
651d88ca22dSAswath Govindraju {
652d88ca22dSAswath Govindraju 	usleep_range(5000, 10000);
653d88ca22dSAswath Govindraju 
654d88ca22dSAswath Govindraju 	return 0;
655d88ca22dSAswath Govindraju }
656d88ca22dSAswath Govindraju 
657d88ca22dSAswath Govindraju static const struct phy_ops noop_ops = {
658d88ca22dSAswath Govindraju 	.power_on	= cdns_sierra_noop_phy_on,
659d88ca22dSAswath Govindraju 	.owner		= THIS_MODULE,
660d88ca22dSAswath Govindraju };
661d88ca22dSAswath Govindraju 
66228081b72SKishon Vijay Abraham I static u8 cdns_sierra_pll_mux_get_parent(struct clk_hw *hw)
66328081b72SKishon Vijay Abraham I {
66428081b72SKishon Vijay Abraham I 	struct cdns_sierra_pll_mux *mux = to_cdns_sierra_pll_mux(hw);
665da08aab9SSwapnil Jakhade 	struct regmap_field *plllc1en_field = mux->plllc1en_field;
666da08aab9SSwapnil Jakhade 	struct regmap_field *termen_field = mux->termen_field;
66728081b72SKishon Vijay Abraham I 	struct regmap_field *field = mux->pfdclk_sel_preg;
66828081b72SKishon Vijay Abraham I 	unsigned int val;
669da08aab9SSwapnil Jakhade 	int index;
67028081b72SKishon Vijay Abraham I 
67128081b72SKishon Vijay Abraham I 	regmap_field_read(field, &val);
672da08aab9SSwapnil Jakhade 
673da08aab9SSwapnil Jakhade 	if (strstr(clk_hw_get_name(hw), clk_names[CDNS_SIERRA_PLL_CMNLC1])) {
674da08aab9SSwapnil Jakhade 		index = clk_mux_val_to_index(hw, cdns_sierra_pll_mux_table[CMN_PLLLC1], 0, val);
675da08aab9SSwapnil Jakhade 		if (index == 1) {
676da08aab9SSwapnil Jakhade 			regmap_field_write(plllc1en_field, 1);
677da08aab9SSwapnil Jakhade 			regmap_field_write(termen_field, 1);
678da08aab9SSwapnil Jakhade 		}
679da08aab9SSwapnil Jakhade 	} else {
680da08aab9SSwapnil Jakhade 		index = clk_mux_val_to_index(hw, cdns_sierra_pll_mux_table[CMN_PLLLC], 0, val);
681da08aab9SSwapnil Jakhade 	}
682da08aab9SSwapnil Jakhade 
683da08aab9SSwapnil Jakhade 	return index;
68428081b72SKishon Vijay Abraham I }
68528081b72SKishon Vijay Abraham I 
68628081b72SKishon Vijay Abraham I static int cdns_sierra_pll_mux_set_parent(struct clk_hw *hw, u8 index)
68728081b72SKishon Vijay Abraham I {
68828081b72SKishon Vijay Abraham I 	struct cdns_sierra_pll_mux *mux = to_cdns_sierra_pll_mux(hw);
68928081b72SKishon Vijay Abraham I 	struct regmap_field *plllc1en_field = mux->plllc1en_field;
69028081b72SKishon Vijay Abraham I 	struct regmap_field *termen_field = mux->termen_field;
69128081b72SKishon Vijay Abraham I 	struct regmap_field *field = mux->pfdclk_sel_preg;
69228081b72SKishon Vijay Abraham I 	int val, ret;
69328081b72SKishon Vijay Abraham I 
69428081b72SKishon Vijay Abraham I 	ret = regmap_field_write(plllc1en_field, 0);
69528081b72SKishon Vijay Abraham I 	ret |= regmap_field_write(termen_field, 0);
69628081b72SKishon Vijay Abraham I 	if (index == 1) {
69728081b72SKishon Vijay Abraham I 		ret |= regmap_field_write(plllc1en_field, 1);
69828081b72SKishon Vijay Abraham I 		ret |= regmap_field_write(termen_field, 1);
69928081b72SKishon Vijay Abraham I 	}
70028081b72SKishon Vijay Abraham I 
701da08aab9SSwapnil Jakhade 	if (strstr(clk_hw_get_name(hw), clk_names[CDNS_SIERRA_PLL_CMNLC1]))
702da08aab9SSwapnil Jakhade 		val = cdns_sierra_pll_mux_table[CMN_PLLLC1][index];
703da08aab9SSwapnil Jakhade 	else
704da08aab9SSwapnil Jakhade 		val = cdns_sierra_pll_mux_table[CMN_PLLLC][index];
705da08aab9SSwapnil Jakhade 
70628081b72SKishon Vijay Abraham I 	ret |= regmap_field_write(field, val);
70728081b72SKishon Vijay Abraham I 
70828081b72SKishon Vijay Abraham I 	return ret;
70928081b72SKishon Vijay Abraham I }
71028081b72SKishon Vijay Abraham I 
71128081b72SKishon Vijay Abraham I static const struct clk_ops cdns_sierra_pll_mux_ops = {
71228081b72SKishon Vijay Abraham I 	.set_parent = cdns_sierra_pll_mux_set_parent,
71328081b72SKishon Vijay Abraham I 	.get_parent = cdns_sierra_pll_mux_get_parent,
71428081b72SKishon Vijay Abraham I };
71528081b72SKishon Vijay Abraham I 
71628081b72SKishon Vijay Abraham I static int cdns_sierra_pll_mux_register(struct cdns_sierra_phy *sp,
71728081b72SKishon Vijay Abraham I 					struct regmap_field *pfdclk1_sel_field,
71828081b72SKishon Vijay Abraham I 					struct regmap_field *plllc1en_field,
71928081b72SKishon Vijay Abraham I 					struct regmap_field *termen_field,
72028081b72SKishon Vijay Abraham I 					int clk_index)
72128081b72SKishon Vijay Abraham I {
72228081b72SKishon Vijay Abraham I 	struct cdns_sierra_pll_mux *mux;
72328081b72SKishon Vijay Abraham I 	struct device *dev = sp->dev;
72428081b72SKishon Vijay Abraham I 	struct clk_init_data *init;
72528081b72SKishon Vijay Abraham I 	const char **parent_names;
72628081b72SKishon Vijay Abraham I 	unsigned int num_parents;
72728081b72SKishon Vijay Abraham I 	char clk_name[100];
72828081b72SKishon Vijay Abraham I 	struct clk *clk;
72928081b72SKishon Vijay Abraham I 	int i;
73028081b72SKishon Vijay Abraham I 
73128081b72SKishon Vijay Abraham I 	mux = devm_kzalloc(dev, sizeof(*mux), GFP_KERNEL);
73228081b72SKishon Vijay Abraham I 	if (!mux)
73328081b72SKishon Vijay Abraham I 		return -ENOMEM;
73428081b72SKishon Vijay Abraham I 
73528081b72SKishon Vijay Abraham I 	num_parents = SIERRA_NUM_CMN_PLLC_PARENTS;
73628081b72SKishon Vijay Abraham I 	parent_names = devm_kzalloc(dev, (sizeof(char *) * num_parents), GFP_KERNEL);
73728081b72SKishon Vijay Abraham I 	if (!parent_names)
73828081b72SKishon Vijay Abraham I 		return -ENOMEM;
73928081b72SKishon Vijay Abraham I 
74028081b72SKishon Vijay Abraham I 	for (i = 0; i < num_parents; i++) {
74128081b72SKishon Vijay Abraham I 		clk = sp->input_clks[pll_mux_parent_index[clk_index][i]];
74228081b72SKishon Vijay Abraham I 		if (IS_ERR_OR_NULL(clk)) {
743da08aab9SSwapnil Jakhade 			dev_err(dev, "No parent clock for PLL mux clocks\n");
744da08aab9SSwapnil Jakhade 			return IS_ERR(clk) ? PTR_ERR(clk) : -ENOENT;
74528081b72SKishon Vijay Abraham I 		}
74628081b72SKishon Vijay Abraham I 		parent_names[i] = __clk_get_name(clk);
74728081b72SKishon Vijay Abraham I 	}
74828081b72SKishon Vijay Abraham I 
74928081b72SKishon Vijay Abraham I 	snprintf(clk_name, sizeof(clk_name), "%s_%s", dev_name(dev), clk_names[clk_index]);
75028081b72SKishon Vijay Abraham I 
75128081b72SKishon Vijay Abraham I 	init = &mux->clk_data;
75228081b72SKishon Vijay Abraham I 
75328081b72SKishon Vijay Abraham I 	init->ops = &cdns_sierra_pll_mux_ops;
75428081b72SKishon Vijay Abraham I 	init->flags = CLK_SET_RATE_NO_REPARENT;
75528081b72SKishon Vijay Abraham I 	init->parent_names = parent_names;
75628081b72SKishon Vijay Abraham I 	init->num_parents = num_parents;
75728081b72SKishon Vijay Abraham I 	init->name = clk_name;
75828081b72SKishon Vijay Abraham I 
75928081b72SKishon Vijay Abraham I 	mux->pfdclk_sel_preg = pfdclk1_sel_field;
76028081b72SKishon Vijay Abraham I 	mux->plllc1en_field = plllc1en_field;
76128081b72SKishon Vijay Abraham I 	mux->termen_field = termen_field;
76228081b72SKishon Vijay Abraham I 	mux->hw.init = init;
76328081b72SKishon Vijay Abraham I 
76428081b72SKishon Vijay Abraham I 	clk = devm_clk_register(dev, &mux->hw);
76528081b72SKishon Vijay Abraham I 	if (IS_ERR(clk))
76628081b72SKishon Vijay Abraham I 		return PTR_ERR(clk);
76728081b72SKishon Vijay Abraham I 
76828081b72SKishon Vijay Abraham I 	sp->output_clks[clk_index] = clk;
76928081b72SKishon Vijay Abraham I 
77028081b72SKishon Vijay Abraham I 	return 0;
77128081b72SKishon Vijay Abraham I }
77228081b72SKishon Vijay Abraham I 
77328081b72SKishon Vijay Abraham I static int cdns_sierra_phy_register_pll_mux(struct cdns_sierra_phy *sp)
77428081b72SKishon Vijay Abraham I {
77528081b72SKishon Vijay Abraham I 	struct regmap_field *pfdclk1_sel_field;
77628081b72SKishon Vijay Abraham I 	struct regmap_field *plllc1en_field;
77728081b72SKishon Vijay Abraham I 	struct regmap_field *termen_field;
77828081b72SKishon Vijay Abraham I 	struct device *dev = sp->dev;
77928081b72SKishon Vijay Abraham I 	int ret = 0, i, clk_index;
78028081b72SKishon Vijay Abraham I 
78128081b72SKishon Vijay Abraham I 	clk_index = CDNS_SIERRA_PLL_CMNLC;
78228081b72SKishon Vijay Abraham I 	for (i = 0; i < SIERRA_NUM_CMN_PLLC; i++, clk_index++) {
78328081b72SKishon Vijay Abraham I 		pfdclk1_sel_field = sp->cmn_plllc_pfdclk1_sel_preg[i];
78428081b72SKishon Vijay Abraham I 		plllc1en_field = sp->cmn_refrcv_refclk_plllc1en_preg[i];
78528081b72SKishon Vijay Abraham I 		termen_field = sp->cmn_refrcv_refclk_termen_preg[i];
78628081b72SKishon Vijay Abraham I 
78728081b72SKishon Vijay Abraham I 		ret = cdns_sierra_pll_mux_register(sp, pfdclk1_sel_field, plllc1en_field,
78828081b72SKishon Vijay Abraham I 						   termen_field, clk_index);
78928081b72SKishon Vijay Abraham I 		if (ret) {
79028081b72SKishon Vijay Abraham I 			dev_err(dev, "Fail to register cmn plllc mux\n");
79128081b72SKishon Vijay Abraham I 			return ret;
79228081b72SKishon Vijay Abraham I 		}
79328081b72SKishon Vijay Abraham I 	}
79428081b72SKishon Vijay Abraham I 
79528081b72SKishon Vijay Abraham I 	return 0;
79628081b72SKishon Vijay Abraham I }
79728081b72SKishon Vijay Abraham I 
79809d976b3SSwapnil Jakhade static int cdns_sierra_derived_refclk_enable(struct clk_hw *hw)
79909d976b3SSwapnil Jakhade {
80009d976b3SSwapnil Jakhade 	struct cdns_sierra_derived_refclk *derived_refclk = to_cdns_sierra_derived_refclk(hw);
80109d976b3SSwapnil Jakhade 
80209d976b3SSwapnil Jakhade 	regmap_field_write(derived_refclk->cmn_plllc_clk1_en_preg, 0x1);
80309d976b3SSwapnil Jakhade 
80409d976b3SSwapnil Jakhade 	/* Programming to get 100Mhz clock output in ref_der_clk_out 5GHz VCO/50 = 100MHz */
80509d976b3SSwapnil Jakhade 	regmap_field_write(derived_refclk->cmn_plllc_clk1outdiv_preg, 0x2E);
80609d976b3SSwapnil Jakhade 
80709d976b3SSwapnil Jakhade 	return 0;
80809d976b3SSwapnil Jakhade }
80909d976b3SSwapnil Jakhade 
81009d976b3SSwapnil Jakhade static void cdns_sierra_derived_refclk_disable(struct clk_hw *hw)
81109d976b3SSwapnil Jakhade {
81209d976b3SSwapnil Jakhade 	struct cdns_sierra_derived_refclk *derived_refclk = to_cdns_sierra_derived_refclk(hw);
81309d976b3SSwapnil Jakhade 
81409d976b3SSwapnil Jakhade 	regmap_field_write(derived_refclk->cmn_plllc_clk1_en_preg, 0);
81509d976b3SSwapnil Jakhade }
81609d976b3SSwapnil Jakhade 
81709d976b3SSwapnil Jakhade static int cdns_sierra_derived_refclk_is_enabled(struct clk_hw *hw)
81809d976b3SSwapnil Jakhade {
81909d976b3SSwapnil Jakhade 	struct cdns_sierra_derived_refclk *derived_refclk = to_cdns_sierra_derived_refclk(hw);
82009d976b3SSwapnil Jakhade 	int val;
82109d976b3SSwapnil Jakhade 
82209d976b3SSwapnil Jakhade 	regmap_field_read(derived_refclk->cmn_plllc_clk1_en_preg, &val);
82309d976b3SSwapnil Jakhade 
82409d976b3SSwapnil Jakhade 	return !!val;
82509d976b3SSwapnil Jakhade }
82609d976b3SSwapnil Jakhade 
82709d976b3SSwapnil Jakhade static const struct clk_ops cdns_sierra_derived_refclk_ops = {
82809d976b3SSwapnil Jakhade 	.enable = cdns_sierra_derived_refclk_enable,
82909d976b3SSwapnil Jakhade 	.disable = cdns_sierra_derived_refclk_disable,
83009d976b3SSwapnil Jakhade 	.is_enabled = cdns_sierra_derived_refclk_is_enabled,
83109d976b3SSwapnil Jakhade };
83209d976b3SSwapnil Jakhade 
83309d976b3SSwapnil Jakhade static int cdns_sierra_derived_refclk_register(struct cdns_sierra_phy *sp)
83409d976b3SSwapnil Jakhade {
83509d976b3SSwapnil Jakhade 	struct cdns_sierra_derived_refclk *derived_refclk;
83609d976b3SSwapnil Jakhade 	struct device *dev = sp->dev;
83709d976b3SSwapnil Jakhade 	struct regmap_field *field;
83809d976b3SSwapnil Jakhade 	struct clk_init_data *init;
83909d976b3SSwapnil Jakhade 	struct regmap *regmap;
84009d976b3SSwapnil Jakhade 	char clk_name[100];
84109d976b3SSwapnil Jakhade 	struct clk *clk;
84209d976b3SSwapnil Jakhade 
84309d976b3SSwapnil Jakhade 	derived_refclk = devm_kzalloc(dev, sizeof(*derived_refclk), GFP_KERNEL);
84409d976b3SSwapnil Jakhade 	if (!derived_refclk)
84509d976b3SSwapnil Jakhade 		return -ENOMEM;
84609d976b3SSwapnil Jakhade 
84709d976b3SSwapnil Jakhade 	snprintf(clk_name, sizeof(clk_name), "%s_%s", dev_name(dev),
84809d976b3SSwapnil Jakhade 		 clk_names[CDNS_SIERRA_DERIVED_REFCLK]);
84909d976b3SSwapnil Jakhade 
85009d976b3SSwapnil Jakhade 	init = &derived_refclk->clk_data;
85109d976b3SSwapnil Jakhade 
85209d976b3SSwapnil Jakhade 	init->ops = &cdns_sierra_derived_refclk_ops;
85309d976b3SSwapnil Jakhade 	init->flags = 0;
85409d976b3SSwapnil Jakhade 	init->name = clk_name;
85509d976b3SSwapnil Jakhade 
85609d976b3SSwapnil Jakhade 	regmap = sp->regmap_common_cdb;
85709d976b3SSwapnil Jakhade 
85809d976b3SSwapnil Jakhade 	field = devm_regmap_field_alloc(dev, regmap, cmn_plllc_clk1outdiv_preg);
85909d976b3SSwapnil Jakhade 	if (IS_ERR(field)) {
86009d976b3SSwapnil Jakhade 		dev_err(dev, "cmn_plllc_clk1outdiv_preg reg field init failed\n");
86109d976b3SSwapnil Jakhade 		return PTR_ERR(field);
86209d976b3SSwapnil Jakhade 	}
86309d976b3SSwapnil Jakhade 	derived_refclk->cmn_plllc_clk1outdiv_preg = field;
86409d976b3SSwapnil Jakhade 
86509d976b3SSwapnil Jakhade 	field = devm_regmap_field_alloc(dev, regmap, cmn_plllc_clk1_en_preg);
86609d976b3SSwapnil Jakhade 	if (IS_ERR(field)) {
86709d976b3SSwapnil Jakhade 		dev_err(dev, "cmn_plllc_clk1_en_preg reg field init failed\n");
86809d976b3SSwapnil Jakhade 		return PTR_ERR(field);
86909d976b3SSwapnil Jakhade 	}
87009d976b3SSwapnil Jakhade 	derived_refclk->cmn_plllc_clk1_en_preg = field;
87109d976b3SSwapnil Jakhade 
87209d976b3SSwapnil Jakhade 	derived_refclk->hw.init = init;
87309d976b3SSwapnil Jakhade 
87409d976b3SSwapnil Jakhade 	clk = devm_clk_register(dev, &derived_refclk->hw);
87509d976b3SSwapnil Jakhade 	if (IS_ERR(clk))
87609d976b3SSwapnil Jakhade 		return PTR_ERR(clk);
87709d976b3SSwapnil Jakhade 
87809d976b3SSwapnil Jakhade 	sp->output_clks[CDNS_SIERRA_DERIVED_REFCLK] = clk;
87909d976b3SSwapnil Jakhade 
88009d976b3SSwapnil Jakhade 	return 0;
88109d976b3SSwapnil Jakhade }
88209d976b3SSwapnil Jakhade 
88328081b72SKishon Vijay Abraham I static void cdns_sierra_clk_unregister(struct cdns_sierra_phy *sp)
88428081b72SKishon Vijay Abraham I {
88528081b72SKishon Vijay Abraham I 	struct device *dev = sp->dev;
88628081b72SKishon Vijay Abraham I 	struct device_node *node = dev->of_node;
88728081b72SKishon Vijay Abraham I 
88828081b72SKishon Vijay Abraham I 	of_clk_del_provider(node);
88928081b72SKishon Vijay Abraham I }
89028081b72SKishon Vijay Abraham I 
89128081b72SKishon Vijay Abraham I static int cdns_sierra_clk_register(struct cdns_sierra_phy *sp)
89228081b72SKishon Vijay Abraham I {
89328081b72SKishon Vijay Abraham I 	struct device *dev = sp->dev;
89428081b72SKishon Vijay Abraham I 	struct device_node *node = dev->of_node;
89528081b72SKishon Vijay Abraham I 	int ret;
89628081b72SKishon Vijay Abraham I 
89728081b72SKishon Vijay Abraham I 	ret = cdns_sierra_phy_register_pll_mux(sp);
89828081b72SKishon Vijay Abraham I 	if (ret) {
89928081b72SKishon Vijay Abraham I 		dev_err(dev, "Failed to pll mux clocks\n");
90028081b72SKishon Vijay Abraham I 		return ret;
90128081b72SKishon Vijay Abraham I 	}
90228081b72SKishon Vijay Abraham I 
90309d976b3SSwapnil Jakhade 	ret = cdns_sierra_derived_refclk_register(sp);
90409d976b3SSwapnil Jakhade 	if (ret) {
90509d976b3SSwapnil Jakhade 		dev_err(dev, "Failed to register derived refclk\n");
90609d976b3SSwapnil Jakhade 		return ret;
90709d976b3SSwapnil Jakhade 	}
90809d976b3SSwapnil Jakhade 
90928081b72SKishon Vijay Abraham I 	sp->clk_data.clks = sp->output_clks;
91028081b72SKishon Vijay Abraham I 	sp->clk_data.clk_num = CDNS_SIERRA_OUTPUT_CLOCKS;
91128081b72SKishon Vijay Abraham I 	ret = of_clk_add_provider(node, of_clk_src_onecell_get, &sp->clk_data);
91228081b72SKishon Vijay Abraham I 	if (ret)
91328081b72SKishon Vijay Abraham I 		dev_err(dev, "Failed to add clock provider: %s\n", node->name);
91428081b72SKishon Vijay Abraham I 
91528081b72SKishon Vijay Abraham I 	return ret;
91628081b72SKishon Vijay Abraham I }
91728081b72SKishon Vijay Abraham I 
91844d30d62SAlan Douglas static int cdns_sierra_get_optional(struct cdns_sierra_inst *inst,
91944d30d62SAlan Douglas 				    struct device_node *child)
92044d30d62SAlan Douglas {
921078e9e92SSwapnil Jakhade 	u32 phy_type;
922078e9e92SSwapnil Jakhade 
92344d30d62SAlan Douglas 	if (of_property_read_u32(child, "reg", &inst->mlane))
92444d30d62SAlan Douglas 		return -EINVAL;
92544d30d62SAlan Douglas 
92644d30d62SAlan Douglas 	if (of_property_read_u32(child, "cdns,num-lanes", &inst->num_lanes))
92744d30d62SAlan Douglas 		return -EINVAL;
92844d30d62SAlan Douglas 
929078e9e92SSwapnil Jakhade 	if (of_property_read_u32(child, "cdns,phy-type", &phy_type))
93044d30d62SAlan Douglas 		return -EINVAL;
93144d30d62SAlan Douglas 
932078e9e92SSwapnil Jakhade 	switch (phy_type) {
933078e9e92SSwapnil Jakhade 	case PHY_TYPE_PCIE:
934078e9e92SSwapnil Jakhade 		inst->phy_type = TYPE_PCIE;
935078e9e92SSwapnil Jakhade 		break;
936078e9e92SSwapnil Jakhade 	case PHY_TYPE_USB3:
937078e9e92SSwapnil Jakhade 		inst->phy_type = TYPE_USB;
938078e9e92SSwapnil Jakhade 		break;
9398a1b82d7SSwapnil Jakhade 	case PHY_TYPE_QSGMII:
9408a1b82d7SSwapnil Jakhade 		inst->phy_type = TYPE_QSGMII;
9418a1b82d7SSwapnil Jakhade 		break;
942078e9e92SSwapnil Jakhade 	default:
943078e9e92SSwapnil Jakhade 		return -EINVAL;
944078e9e92SSwapnil Jakhade 	}
945078e9e92SSwapnil Jakhade 
9461e902b2aSSwapnil Jakhade 	inst->ssc_mode = EXTERNAL_SSC;
9471e902b2aSSwapnil Jakhade 	of_property_read_u32(child, "cdns,ssc-mode", &inst->ssc_mode);
9481e902b2aSSwapnil Jakhade 
94944d30d62SAlan Douglas 	return 0;
95044d30d62SAlan Douglas }
95144d30d62SAlan Douglas 
952380f5708SKishon Vijay Abraham I static struct regmap *cdns_regmap_init(struct device *dev, void __iomem *base,
953380f5708SKishon Vijay Abraham I 				       u32 block_offset, u8 reg_offset_shift,
954380f5708SKishon Vijay Abraham I 				       const struct regmap_config *config)
955380f5708SKishon Vijay Abraham I {
956380f5708SKishon Vijay Abraham I 	struct cdns_regmap_cdb_context *ctx;
957380f5708SKishon Vijay Abraham I 
958380f5708SKishon Vijay Abraham I 	ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
959380f5708SKishon Vijay Abraham I 	if (!ctx)
960380f5708SKishon Vijay Abraham I 		return ERR_PTR(-ENOMEM);
961380f5708SKishon Vijay Abraham I 
962380f5708SKishon Vijay Abraham I 	ctx->dev = dev;
963380f5708SKishon Vijay Abraham I 	ctx->base = base + block_offset;
964380f5708SKishon Vijay Abraham I 	ctx->reg_offset_shift = reg_offset_shift;
965380f5708SKishon Vijay Abraham I 
966380f5708SKishon Vijay Abraham I 	return devm_regmap_init(dev, NULL, ctx, config);
967380f5708SKishon Vijay Abraham I }
968380f5708SKishon Vijay Abraham I 
969380f5708SKishon Vijay Abraham I static int cdns_regfield_init(struct cdns_sierra_phy *sp)
970380f5708SKishon Vijay Abraham I {
971380f5708SKishon Vijay Abraham I 	struct device *dev = sp->dev;
972380f5708SKishon Vijay Abraham I 	struct regmap_field *field;
97328081b72SKishon Vijay Abraham I 	struct reg_field reg_field;
974380f5708SKishon Vijay Abraham I 	struct regmap *regmap;
975adc4bd6fSKishon Vijay Abraham I 	int i;
976380f5708SKishon Vijay Abraham I 
977380f5708SKishon Vijay Abraham I 	regmap = sp->regmap_common_cdb;
978380f5708SKishon Vijay Abraham I 	field = devm_regmap_field_alloc(dev, regmap, macro_id_type);
979380f5708SKishon Vijay Abraham I 	if (IS_ERR(field)) {
980380f5708SKishon Vijay Abraham I 		dev_err(dev, "MACRO_ID_TYPE reg field init failed\n");
981380f5708SKishon Vijay Abraham I 		return PTR_ERR(field);
982380f5708SKishon Vijay Abraham I 	}
983380f5708SKishon Vijay Abraham I 	sp->macro_id_type = field;
984380f5708SKishon Vijay Abraham I 
98528081b72SKishon Vijay Abraham I 	for (i = 0; i < SIERRA_NUM_CMN_PLLC; i++) {
98628081b72SKishon Vijay Abraham I 		reg_field = cmn_plllc_pfdclk1_sel_preg[i].pfdclk_sel_preg;
98728081b72SKishon Vijay Abraham I 		field = devm_regmap_field_alloc(dev, regmap, reg_field);
98828081b72SKishon Vijay Abraham I 		if (IS_ERR(field)) {
98928081b72SKishon Vijay Abraham I 			dev_err(dev, "PLLLC%d_PFDCLK1_SEL failed\n", i);
99028081b72SKishon Vijay Abraham I 			return PTR_ERR(field);
99128081b72SKishon Vijay Abraham I 		}
99228081b72SKishon Vijay Abraham I 		sp->cmn_plllc_pfdclk1_sel_preg[i] = field;
99328081b72SKishon Vijay Abraham I 
99428081b72SKishon Vijay Abraham I 		reg_field = cmn_plllc_pfdclk1_sel_preg[i].plllc1en_field;
99528081b72SKishon Vijay Abraham I 		field = devm_regmap_field_alloc(dev, regmap, reg_field);
99628081b72SKishon Vijay Abraham I 		if (IS_ERR(field)) {
99728081b72SKishon Vijay Abraham I 			dev_err(dev, "REFRCV%d_REFCLK_PLLLC1EN failed\n", i);
99828081b72SKishon Vijay Abraham I 			return PTR_ERR(field);
99928081b72SKishon Vijay Abraham I 		}
100028081b72SKishon Vijay Abraham I 		sp->cmn_refrcv_refclk_plllc1en_preg[i] = field;
100128081b72SKishon Vijay Abraham I 
100228081b72SKishon Vijay Abraham I 		reg_field = cmn_plllc_pfdclk1_sel_preg[i].termen_field;
100328081b72SKishon Vijay Abraham I 		field = devm_regmap_field_alloc(dev, regmap, reg_field);
100428081b72SKishon Vijay Abraham I 		if (IS_ERR(field)) {
100528081b72SKishon Vijay Abraham I 			dev_err(dev, "REFRCV%d_REFCLK_TERMEN failed\n", i);
100628081b72SKishon Vijay Abraham I 			return PTR_ERR(field);
100728081b72SKishon Vijay Abraham I 		}
100828081b72SKishon Vijay Abraham I 		sp->cmn_refrcv_refclk_termen_preg[i] = field;
100928081b72SKishon Vijay Abraham I 	}
101028081b72SKishon Vijay Abraham I 
10118c95e172SSwapnil Jakhade 	regmap = sp->regmap_phy_pcs_common_cdb;
1012380f5708SKishon Vijay Abraham I 	field = devm_regmap_field_alloc(dev, regmap, phy_pll_cfg_1);
1013380f5708SKishon Vijay Abraham I 	if (IS_ERR(field)) {
1014380f5708SKishon Vijay Abraham I 		dev_err(dev, "PHY_PLL_CFG_1 reg field init failed\n");
1015380f5708SKishon Vijay Abraham I 		return PTR_ERR(field);
1016380f5708SKishon Vijay Abraham I 	}
1017380f5708SKishon Vijay Abraham I 	sp->phy_pll_cfg_1 = field;
1018380f5708SKishon Vijay Abraham I 
1019f1cc6c3fSSwapnil Jakhade 	regmap = sp->regmap_phy_pma_common_cdb;
1020f1cc6c3fSSwapnil Jakhade 	field = devm_regmap_field_alloc(dev, regmap, pma_cmn_ready);
1021f1cc6c3fSSwapnil Jakhade 	if (IS_ERR(field)) {
1022f1cc6c3fSSwapnil Jakhade 		dev_err(dev, "PHY_PMA_CMN_CTRL reg field init failed\n");
1023f1cc6c3fSSwapnil Jakhade 		return PTR_ERR(field);
1024f1cc6c3fSSwapnil Jakhade 	}
1025f1cc6c3fSSwapnil Jakhade 	sp->pma_cmn_ready = field;
1026f1cc6c3fSSwapnil Jakhade 
1027adc4bd6fSKishon Vijay Abraham I 	for (i = 0; i < SIERRA_MAX_LANES; i++) {
1028adc4bd6fSKishon Vijay Abraham I 		regmap = sp->regmap_lane_cdb[i];
1029adc4bd6fSKishon Vijay Abraham I 		field = devm_regmap_field_alloc(dev, regmap, pllctrl_lock);
1030adc4bd6fSKishon Vijay Abraham I 		if (IS_ERR(field)) {
1031adc4bd6fSKishon Vijay Abraham I 			dev_err(dev, "P%d_ENABLE reg field init failed\n", i);
1032adc4bd6fSKishon Vijay Abraham I 			return PTR_ERR(field);
1033adc4bd6fSKishon Vijay Abraham I 		}
1034adc4bd6fSKishon Vijay Abraham I 		sp->pllctrl_lock[i] = field;
1035adc4bd6fSKishon Vijay Abraham I 	}
1036adc4bd6fSKishon Vijay Abraham I 
103736ce4163SSwapnil Jakhade 	for (i = 0; i < SIERRA_MAX_LANES; i++) {
103836ce4163SSwapnil Jakhade 		regmap = sp->regmap_phy_pcs_lane_cdb[i];
103936ce4163SSwapnil Jakhade 		field = devm_regmap_field_alloc(dev, regmap, phy_iso_link_ctrl_1);
104036ce4163SSwapnil Jakhade 		if (IS_ERR(field)) {
104136ce4163SSwapnil Jakhade 			dev_err(dev, "PHY_ISO_LINK_CTRL reg field init for lane %d failed\n", i);
104236ce4163SSwapnil Jakhade 			return PTR_ERR(field);
104336ce4163SSwapnil Jakhade 		}
104436ce4163SSwapnil Jakhade 		sp->phy_iso_link_ctrl_1[i] = field;
104536ce4163SSwapnil Jakhade 	}
104636ce4163SSwapnil Jakhade 
1047380f5708SKishon Vijay Abraham I 	return 0;
1048380f5708SKishon Vijay Abraham I }
1049380f5708SKishon Vijay Abraham I 
1050380f5708SKishon Vijay Abraham I static int cdns_regmap_init_blocks(struct cdns_sierra_phy *sp,
1051380f5708SKishon Vijay Abraham I 				   void __iomem *base, u8 block_offset_shift,
1052380f5708SKishon Vijay Abraham I 				   u8 reg_offset_shift)
1053380f5708SKishon Vijay Abraham I {
1054380f5708SKishon Vijay Abraham I 	struct device *dev = sp->dev;
1055380f5708SKishon Vijay Abraham I 	struct regmap *regmap;
1056380f5708SKishon Vijay Abraham I 	u32 block_offset;
1057380f5708SKishon Vijay Abraham I 	int i;
1058380f5708SKishon Vijay Abraham I 
1059380f5708SKishon Vijay Abraham I 	for (i = 0; i < SIERRA_MAX_LANES; i++) {
1060380f5708SKishon Vijay Abraham I 		block_offset = SIERRA_LANE_CDB_OFFSET(i, block_offset_shift,
1061380f5708SKishon Vijay Abraham I 						      reg_offset_shift);
1062380f5708SKishon Vijay Abraham I 		regmap = cdns_regmap_init(dev, base, block_offset,
1063380f5708SKishon Vijay Abraham I 					  reg_offset_shift,
1064380f5708SKishon Vijay Abraham I 					  &cdns_sierra_lane_cdb_config[i]);
1065380f5708SKishon Vijay Abraham I 		if (IS_ERR(regmap)) {
1066380f5708SKishon Vijay Abraham I 			dev_err(dev, "Failed to init lane CDB regmap\n");
1067380f5708SKishon Vijay Abraham I 			return PTR_ERR(regmap);
1068380f5708SKishon Vijay Abraham I 		}
1069380f5708SKishon Vijay Abraham I 		sp->regmap_lane_cdb[i] = regmap;
1070380f5708SKishon Vijay Abraham I 	}
1071380f5708SKishon Vijay Abraham I 
1072380f5708SKishon Vijay Abraham I 	regmap = cdns_regmap_init(dev, base, SIERRA_COMMON_CDB_OFFSET,
1073380f5708SKishon Vijay Abraham I 				  reg_offset_shift,
1074380f5708SKishon Vijay Abraham I 				  &cdns_sierra_common_cdb_config);
1075380f5708SKishon Vijay Abraham I 	if (IS_ERR(regmap)) {
1076380f5708SKishon Vijay Abraham I 		dev_err(dev, "Failed to init common CDB regmap\n");
1077380f5708SKishon Vijay Abraham I 		return PTR_ERR(regmap);
1078380f5708SKishon Vijay Abraham I 	}
1079380f5708SKishon Vijay Abraham I 	sp->regmap_common_cdb = regmap;
1080380f5708SKishon Vijay Abraham I 
10818c95e172SSwapnil Jakhade 	block_offset = SIERRA_PHY_PCS_COMMON_OFFSET(block_offset_shift);
1082380f5708SKishon Vijay Abraham I 	regmap = cdns_regmap_init(dev, base, block_offset, reg_offset_shift,
10838c95e172SSwapnil Jakhade 				  &cdns_sierra_phy_pcs_cmn_cdb_config);
1084380f5708SKishon Vijay Abraham I 	if (IS_ERR(regmap)) {
10858c95e172SSwapnil Jakhade 		dev_err(dev, "Failed to init PHY PCS common CDB regmap\n");
1086380f5708SKishon Vijay Abraham I 		return PTR_ERR(regmap);
1087380f5708SKishon Vijay Abraham I 	}
10888c95e172SSwapnil Jakhade 	sp->regmap_phy_pcs_common_cdb = regmap;
1089380f5708SKishon Vijay Abraham I 
109036ce4163SSwapnil Jakhade 	for (i = 0; i < SIERRA_MAX_LANES; i++) {
109136ce4163SSwapnil Jakhade 		block_offset = SIERRA_PHY_PCS_LANE_CDB_OFFSET(i, block_offset_shift,
109236ce4163SSwapnil Jakhade 							      reg_offset_shift);
109336ce4163SSwapnil Jakhade 		regmap = cdns_regmap_init(dev, base, block_offset,
109436ce4163SSwapnil Jakhade 					  reg_offset_shift,
109536ce4163SSwapnil Jakhade 					  &cdns_sierra_phy_pcs_lane_cdb_config[i]);
109636ce4163SSwapnil Jakhade 		if (IS_ERR(regmap)) {
109736ce4163SSwapnil Jakhade 			dev_err(dev, "Failed to init PHY PCS lane CDB regmap\n");
109836ce4163SSwapnil Jakhade 			return PTR_ERR(regmap);
109936ce4163SSwapnil Jakhade 		}
110036ce4163SSwapnil Jakhade 		sp->regmap_phy_pcs_lane_cdb[i] = regmap;
110136ce4163SSwapnil Jakhade 	}
110236ce4163SSwapnil Jakhade 
1103f1cc6c3fSSwapnil Jakhade 	block_offset = SIERRA_PHY_PMA_COMMON_OFFSET(block_offset_shift);
1104f1cc6c3fSSwapnil Jakhade 	regmap = cdns_regmap_init(dev, base, block_offset, reg_offset_shift,
1105f1cc6c3fSSwapnil Jakhade 				  &cdns_sierra_phy_pma_cmn_cdb_config);
1106f1cc6c3fSSwapnil Jakhade 	if (IS_ERR(regmap)) {
1107f1cc6c3fSSwapnil Jakhade 		dev_err(dev, "Failed to init PHY PMA common CDB regmap\n");
1108f1cc6c3fSSwapnil Jakhade 		return PTR_ERR(regmap);
1109f1cc6c3fSSwapnil Jakhade 	}
1110f1cc6c3fSSwapnil Jakhade 	sp->regmap_phy_pma_common_cdb = regmap;
1111f1cc6c3fSSwapnil Jakhade 
11126b81f05aSSwapnil Jakhade 	for (i = 0; i < SIERRA_MAX_LANES; i++) {
11136b81f05aSSwapnil Jakhade 		block_offset = SIERRA_PHY_PMA_LANE_CDB_OFFSET(i, block_offset_shift,
11146b81f05aSSwapnil Jakhade 							      reg_offset_shift);
11156b81f05aSSwapnil Jakhade 		regmap = cdns_regmap_init(dev, base, block_offset,
11166b81f05aSSwapnil Jakhade 					  reg_offset_shift,
11176b81f05aSSwapnil Jakhade 					  &cdns_sierra_phy_pma_lane_cdb_config[i]);
11186b81f05aSSwapnil Jakhade 		if (IS_ERR(regmap)) {
11196b81f05aSSwapnil Jakhade 			dev_err(dev, "Failed to init PHY PMA lane CDB regmap\n");
11206b81f05aSSwapnil Jakhade 			return PTR_ERR(regmap);
11216b81f05aSSwapnil Jakhade 		}
11226b81f05aSSwapnil Jakhade 		sp->regmap_phy_pma_lane_cdb[i] = regmap;
11236b81f05aSSwapnil Jakhade 	}
11246b81f05aSSwapnil Jakhade 
1125380f5708SKishon Vijay Abraham I 	return 0;
1126380f5708SKishon Vijay Abraham I }
1127380f5708SKishon Vijay Abraham I 
11287e016cbcSKishon Vijay Abraham I static int cdns_sierra_phy_get_clocks(struct cdns_sierra_phy *sp,
11297e016cbcSKishon Vijay Abraham I 				      struct device *dev)
11307e016cbcSKishon Vijay Abraham I {
11317e016cbcSKishon Vijay Abraham I 	struct clk *clk;
11327e016cbcSKishon Vijay Abraham I 	int ret;
11337e016cbcSKishon Vijay Abraham I 
11347e016cbcSKishon Vijay Abraham I 	clk = devm_clk_get_optional(dev, "cmn_refclk_dig_div");
11357e016cbcSKishon Vijay Abraham I 	if (IS_ERR(clk)) {
11367e016cbcSKishon Vijay Abraham I 		dev_err(dev, "cmn_refclk_dig_div clock not found\n");
11377e016cbcSKishon Vijay Abraham I 		ret = PTR_ERR(clk);
11387e016cbcSKishon Vijay Abraham I 		return ret;
11397e016cbcSKishon Vijay Abraham I 	}
1140a0c30cd7SKishon Vijay Abraham I 	sp->input_clks[CMN_REFCLK_DIG_DIV] = clk;
11417e016cbcSKishon Vijay Abraham I 
11427e016cbcSKishon Vijay Abraham I 	clk = devm_clk_get_optional(dev, "cmn_refclk1_dig_div");
11437e016cbcSKishon Vijay Abraham I 	if (IS_ERR(clk)) {
11447e016cbcSKishon Vijay Abraham I 		dev_err(dev, "cmn_refclk1_dig_div clock not found\n");
11457e016cbcSKishon Vijay Abraham I 		ret = PTR_ERR(clk);
11467e016cbcSKishon Vijay Abraham I 		return ret;
11477e016cbcSKishon Vijay Abraham I 	}
1148a0c30cd7SKishon Vijay Abraham I 	sp->input_clks[CMN_REFCLK1_DIG_DIV] = clk;
11497e016cbcSKishon Vijay Abraham I 
115028081b72SKishon Vijay Abraham I 	clk = devm_clk_get_optional(dev, "pll0_refclk");
115128081b72SKishon Vijay Abraham I 	if (IS_ERR(clk)) {
115228081b72SKishon Vijay Abraham I 		dev_err(dev, "pll0_refclk clock not found\n");
115328081b72SKishon Vijay Abraham I 		ret = PTR_ERR(clk);
115428081b72SKishon Vijay Abraham I 		return ret;
115528081b72SKishon Vijay Abraham I 	}
115628081b72SKishon Vijay Abraham I 	sp->input_clks[PLL0_REFCLK] = clk;
115728081b72SKishon Vijay Abraham I 
115828081b72SKishon Vijay Abraham I 	clk = devm_clk_get_optional(dev, "pll1_refclk");
115928081b72SKishon Vijay Abraham I 	if (IS_ERR(clk)) {
116028081b72SKishon Vijay Abraham I 		dev_err(dev, "pll1_refclk clock not found\n");
116128081b72SKishon Vijay Abraham I 		ret = PTR_ERR(clk);
116228081b72SKishon Vijay Abraham I 		return ret;
116328081b72SKishon Vijay Abraham I 	}
116428081b72SKishon Vijay Abraham I 	sp->input_clks[PLL1_REFCLK] = clk;
116528081b72SKishon Vijay Abraham I 
11667e016cbcSKishon Vijay Abraham I 	return 0;
11677e016cbcSKishon Vijay Abraham I }
11687e016cbcSKishon Vijay Abraham I 
1169d88ca22dSAswath Govindraju static int cdns_sierra_phy_clk(struct cdns_sierra_phy *sp)
11701436ec30SKishon Vijay Abraham I {
1171d88ca22dSAswath Govindraju 	struct device *dev = sp->dev;
1172d88ca22dSAswath Govindraju 	struct clk *clk;
11731436ec30SKishon Vijay Abraham I 	int ret;
11741436ec30SKishon Vijay Abraham I 
1175d88ca22dSAswath Govindraju 	clk = devm_clk_get_optional(dev, "phy_clk");
1176d88ca22dSAswath Govindraju 	if (IS_ERR(clk)) {
1177d88ca22dSAswath Govindraju 		dev_err(dev, "failed to get clock phy_clk\n");
1178d88ca22dSAswath Govindraju 		return PTR_ERR(clk);
1179d88ca22dSAswath Govindraju 	}
1180d88ca22dSAswath Govindraju 	sp->input_clks[PHY_CLK] = clk;
1181d88ca22dSAswath Govindraju 
11821436ec30SKishon Vijay Abraham I 	ret = clk_prepare_enable(sp->input_clks[PHY_CLK]);
11831436ec30SKishon Vijay Abraham I 	if (ret)
11841436ec30SKishon Vijay Abraham I 		return ret;
11851436ec30SKishon Vijay Abraham I 
1186d88ca22dSAswath Govindraju 	return 0;
1187d88ca22dSAswath Govindraju }
1188d88ca22dSAswath Govindraju 
1189d88ca22dSAswath Govindraju static int cdns_sierra_phy_enable_clocks(struct cdns_sierra_phy *sp)
1190d88ca22dSAswath Govindraju {
1191d88ca22dSAswath Govindraju 	int ret;
1192d88ca22dSAswath Govindraju 
11931436ec30SKishon Vijay Abraham I 	ret = clk_prepare_enable(sp->output_clks[CDNS_SIERRA_PLL_CMNLC]);
11941436ec30SKishon Vijay Abraham I 	if (ret)
1195d88ca22dSAswath Govindraju 		return ret;
11961436ec30SKishon Vijay Abraham I 
11971436ec30SKishon Vijay Abraham I 	ret = clk_prepare_enable(sp->output_clks[CDNS_SIERRA_PLL_CMNLC1]);
11981436ec30SKishon Vijay Abraham I 	if (ret)
11991436ec30SKishon Vijay Abraham I 		goto err_pll_cmnlc1;
12001436ec30SKishon Vijay Abraham I 
12011436ec30SKishon Vijay Abraham I 	return 0;
12021436ec30SKishon Vijay Abraham I 
12031436ec30SKishon Vijay Abraham I err_pll_cmnlc1:
12041436ec30SKishon Vijay Abraham I 	clk_disable_unprepare(sp->output_clks[CDNS_SIERRA_PLL_CMNLC]);
12051436ec30SKishon Vijay Abraham I 
12061436ec30SKishon Vijay Abraham I 	return ret;
12071436ec30SKishon Vijay Abraham I }
12081436ec30SKishon Vijay Abraham I 
12091436ec30SKishon Vijay Abraham I static void cdns_sierra_phy_disable_clocks(struct cdns_sierra_phy *sp)
12101436ec30SKishon Vijay Abraham I {
12111436ec30SKishon Vijay Abraham I 	clk_disable_unprepare(sp->output_clks[CDNS_SIERRA_PLL_CMNLC1]);
12121436ec30SKishon Vijay Abraham I 	clk_disable_unprepare(sp->output_clks[CDNS_SIERRA_PLL_CMNLC]);
1213d88ca22dSAswath Govindraju 	if (!sp->already_configured)
12141436ec30SKishon Vijay Abraham I 		clk_disable_unprepare(sp->input_clks[PHY_CLK]);
12151436ec30SKishon Vijay Abraham I }
12161436ec30SKishon Vijay Abraham I 
12171d5f40e0SKishon Vijay Abraham I static int cdns_sierra_phy_get_resets(struct cdns_sierra_phy *sp,
12181d5f40e0SKishon Vijay Abraham I 				      struct device *dev)
12191d5f40e0SKishon Vijay Abraham I {
12201d5f40e0SKishon Vijay Abraham I 	struct reset_control *rst;
12211d5f40e0SKishon Vijay Abraham I 
122215b0b82dSKishon Vijay Abraham I 	rst = devm_reset_control_get_exclusive(dev, "sierra_reset");
12231d5f40e0SKishon Vijay Abraham I 	if (IS_ERR(rst)) {
12241d5f40e0SKishon Vijay Abraham I 		dev_err(dev, "failed to get reset\n");
12251d5f40e0SKishon Vijay Abraham I 		return PTR_ERR(rst);
12261d5f40e0SKishon Vijay Abraham I 	}
12271d5f40e0SKishon Vijay Abraham I 	sp->phy_rst = rst;
12281d5f40e0SKishon Vijay Abraham I 
122915b0b82dSKishon Vijay Abraham I 	rst = devm_reset_control_get_optional_exclusive(dev, "sierra_apb");
12301d5f40e0SKishon Vijay Abraham I 	if (IS_ERR(rst)) {
12311d5f40e0SKishon Vijay Abraham I 		dev_err(dev, "failed to get apb reset\n");
12321d5f40e0SKishon Vijay Abraham I 		return PTR_ERR(rst);
12331d5f40e0SKishon Vijay Abraham I 	}
12341d5f40e0SKishon Vijay Abraham I 	sp->apb_rst = rst;
12351d5f40e0SKishon Vijay Abraham I 
12361d5f40e0SKishon Vijay Abraham I 	return 0;
12371d5f40e0SKishon Vijay Abraham I }
12381d5f40e0SKishon Vijay Abraham I 
12396b81f05aSSwapnil Jakhade static int cdns_sierra_phy_configure_multilink(struct cdns_sierra_phy *sp)
12406b81f05aSSwapnil Jakhade {
12416b81f05aSSwapnil Jakhade 	const struct cdns_sierra_data *init_data = sp->init_data;
12426b81f05aSSwapnil Jakhade 	struct cdns_sierra_vals *pma_cmn_vals, *pma_ln_vals;
12436b81f05aSSwapnil Jakhade 	enum cdns_sierra_phy_type phy_t1, phy_t2;
12446b81f05aSSwapnil Jakhade 	struct cdns_sierra_vals *phy_pma_ln_vals;
12456b81f05aSSwapnil Jakhade 	const struct cdns_reg_pairs *reg_pairs;
12466b81f05aSSwapnil Jakhade 	struct cdns_sierra_vals *pcs_cmn_vals;
12476b81f05aSSwapnil Jakhade 	int i, j, node, mlane, num_lanes, ret;
12486b81f05aSSwapnil Jakhade 	enum cdns_sierra_ssc_mode ssc;
12496b81f05aSSwapnil Jakhade 	struct regmap *regmap;
12506b81f05aSSwapnil Jakhade 	u32 num_regs;
12516b81f05aSSwapnil Jakhade 
12526b81f05aSSwapnil Jakhade 	/* Maximum 2 links (subnodes) are supported */
12536b81f05aSSwapnil Jakhade 	if (sp->nsubnodes != 2)
12546b81f05aSSwapnil Jakhade 		return -EINVAL;
12556b81f05aSSwapnil Jakhade 
12566b81f05aSSwapnil Jakhade 	clk_set_rate(sp->input_clks[CMN_REFCLK_DIG_DIV], 25000000);
12576b81f05aSSwapnil Jakhade 	clk_set_rate(sp->input_clks[CMN_REFCLK1_DIG_DIV], 25000000);
12586b81f05aSSwapnil Jakhade 
12596b81f05aSSwapnil Jakhade 	/* PHY configured to use both PLL LC and LC1 */
12606b81f05aSSwapnil Jakhade 	regmap_field_write(sp->phy_pll_cfg_1, 0x1);
12616b81f05aSSwapnil Jakhade 
12626b81f05aSSwapnil Jakhade 	phy_t1 = sp->phys[0].phy_type;
12636b81f05aSSwapnil Jakhade 	phy_t2 = sp->phys[1].phy_type;
12646b81f05aSSwapnil Jakhade 
12656b81f05aSSwapnil Jakhade 	/*
12666b81f05aSSwapnil Jakhade 	 * PHY configuration for multi-link operation is done in two steps.
12676b81f05aSSwapnil Jakhade 	 * e.g. Consider a case for a 4 lane PHY with PCIe using 2 lanes and QSGMII other 2 lanes.
12686b81f05aSSwapnil Jakhade 	 * Sierra PHY has 2 PLLs, viz. PLLLC and PLLLC1. So in this case, PLLLC is used for PCIe
12696b81f05aSSwapnil Jakhade 	 * and PLLLC1 is used for QSGMII. PHY is configured in two steps as described below.
12706b81f05aSSwapnil Jakhade 	 *
12716b81f05aSSwapnil Jakhade 	 * [1] For first step, phy_t1 = TYPE_PCIE and phy_t2 = TYPE_QSGMII
12726b81f05aSSwapnil Jakhade 	 *     So the register values are selected as [TYPE_PCIE][TYPE_QSGMII][ssc].
12736b81f05aSSwapnil Jakhade 	 *     This will configure PHY registers associated for PCIe (i.e. first protocol)
12746b81f05aSSwapnil Jakhade 	 *     involving PLLLC registers and registers for first 2 lanes of PHY.
12756b81f05aSSwapnil Jakhade 	 * [2] In second step, the variables phy_t1 and phy_t2 are swapped. So now,
12766b81f05aSSwapnil Jakhade 	 *     phy_t1 = TYPE_QSGMII and phy_t2 = TYPE_PCIE. And the register values are selected as
12776b81f05aSSwapnil Jakhade 	 *     [TYPE_QSGMII][TYPE_PCIE][ssc].
12786b81f05aSSwapnil Jakhade 	 *     This will configure PHY registers associated for QSGMII (i.e. second protocol)
12796b81f05aSSwapnil Jakhade 	 *     involving PLLLC1 registers and registers for other 2 lanes of PHY.
12806b81f05aSSwapnil Jakhade 	 *
12816b81f05aSSwapnil Jakhade 	 * This completes the PHY configuration for multilink operation. This approach enables
12826b81f05aSSwapnil Jakhade 	 * dividing the large number of PHY register configurations into protocol specific
12836b81f05aSSwapnil Jakhade 	 * smaller groups.
12846b81f05aSSwapnil Jakhade 	 */
12856b81f05aSSwapnil Jakhade 	for (node = 0; node < sp->nsubnodes; node++) {
12866b81f05aSSwapnil Jakhade 		if (node == 1) {
12876b81f05aSSwapnil Jakhade 			/*
12886b81f05aSSwapnil Jakhade 			 * If first link with phy_t1 is configured, then configure the PHY for
12896b81f05aSSwapnil Jakhade 			 * second link with phy_t2. Get the array values as [phy_t2][phy_t1][ssc].
12906b81f05aSSwapnil Jakhade 			 */
12916b81f05aSSwapnil Jakhade 			swap(phy_t1, phy_t2);
12926b81f05aSSwapnil Jakhade 		}
12936b81f05aSSwapnil Jakhade 
12946b81f05aSSwapnil Jakhade 		mlane = sp->phys[node].mlane;
12956b81f05aSSwapnil Jakhade 		ssc = sp->phys[node].ssc_mode;
12966b81f05aSSwapnil Jakhade 		num_lanes = sp->phys[node].num_lanes;
12976b81f05aSSwapnil Jakhade 
12986b81f05aSSwapnil Jakhade 		/* PHY PCS common registers configurations */
12996b81f05aSSwapnil Jakhade 		pcs_cmn_vals = init_data->pcs_cmn_vals[phy_t1][phy_t2][ssc];
13006b81f05aSSwapnil Jakhade 		if (pcs_cmn_vals) {
13016b81f05aSSwapnil Jakhade 			reg_pairs = pcs_cmn_vals->reg_pairs;
13026b81f05aSSwapnil Jakhade 			num_regs = pcs_cmn_vals->num_regs;
13036b81f05aSSwapnil Jakhade 			regmap = sp->regmap_phy_pcs_common_cdb;
13046b81f05aSSwapnil Jakhade 			for (i = 0; i < num_regs; i++)
13056b81f05aSSwapnil Jakhade 				regmap_write(regmap, reg_pairs[i].off, reg_pairs[i].val);
13066b81f05aSSwapnil Jakhade 		}
13076b81f05aSSwapnil Jakhade 
13086b81f05aSSwapnil Jakhade 		/* PHY PMA lane registers configurations */
13096b81f05aSSwapnil Jakhade 		phy_pma_ln_vals = init_data->phy_pma_ln_vals[phy_t1][phy_t2][ssc];
13106b81f05aSSwapnil Jakhade 		if (phy_pma_ln_vals) {
13116b81f05aSSwapnil Jakhade 			reg_pairs = phy_pma_ln_vals->reg_pairs;
13126b81f05aSSwapnil Jakhade 			num_regs = phy_pma_ln_vals->num_regs;
13136b81f05aSSwapnil Jakhade 			for (i = 0; i < num_lanes; i++) {
13146b81f05aSSwapnil Jakhade 				regmap = sp->regmap_phy_pma_lane_cdb[i + mlane];
13156b81f05aSSwapnil Jakhade 				for (j = 0; j < num_regs; j++)
13166b81f05aSSwapnil Jakhade 					regmap_write(regmap, reg_pairs[j].off, reg_pairs[j].val);
13176b81f05aSSwapnil Jakhade 			}
13186b81f05aSSwapnil Jakhade 		}
13196b81f05aSSwapnil Jakhade 
13206b81f05aSSwapnil Jakhade 		/* PMA common registers configurations */
13216b81f05aSSwapnil Jakhade 		pma_cmn_vals = init_data->pma_cmn_vals[phy_t1][phy_t2][ssc];
13226b81f05aSSwapnil Jakhade 		if (pma_cmn_vals) {
13236b81f05aSSwapnil Jakhade 			reg_pairs = pma_cmn_vals->reg_pairs;
13246b81f05aSSwapnil Jakhade 			num_regs = pma_cmn_vals->num_regs;
13256b81f05aSSwapnil Jakhade 			regmap = sp->regmap_common_cdb;
13266b81f05aSSwapnil Jakhade 			for (i = 0; i < num_regs; i++)
13276b81f05aSSwapnil Jakhade 				regmap_write(regmap, reg_pairs[i].off, reg_pairs[i].val);
13286b81f05aSSwapnil Jakhade 		}
13296b81f05aSSwapnil Jakhade 
13306b81f05aSSwapnil Jakhade 		/* PMA lane registers configurations */
13316b81f05aSSwapnil Jakhade 		pma_ln_vals = init_data->pma_ln_vals[phy_t1][phy_t2][ssc];
13326b81f05aSSwapnil Jakhade 		if (pma_ln_vals) {
13336b81f05aSSwapnil Jakhade 			reg_pairs = pma_ln_vals->reg_pairs;
13346b81f05aSSwapnil Jakhade 			num_regs = pma_ln_vals->num_regs;
13356b81f05aSSwapnil Jakhade 			for (i = 0; i < num_lanes; i++) {
13366b81f05aSSwapnil Jakhade 				regmap = sp->regmap_lane_cdb[i + mlane];
13376b81f05aSSwapnil Jakhade 				for (j = 0; j < num_regs; j++)
13386b81f05aSSwapnil Jakhade 					regmap_write(regmap, reg_pairs[j].off, reg_pairs[j].val);
13396b81f05aSSwapnil Jakhade 			}
13406b81f05aSSwapnil Jakhade 		}
13418a1b82d7SSwapnil Jakhade 
13428a1b82d7SSwapnil Jakhade 		if (phy_t1 == TYPE_QSGMII)
13438a1b82d7SSwapnil Jakhade 			reset_control_deassert(sp->phys[node].lnk_rst);
13446b81f05aSSwapnil Jakhade 	}
13456b81f05aSSwapnil Jakhade 
13466b81f05aSSwapnil Jakhade 	/* Take the PHY out of reset */
13476b81f05aSSwapnil Jakhade 	ret = reset_control_deassert(sp->phy_rst);
13486b81f05aSSwapnil Jakhade 	if (ret)
13496b81f05aSSwapnil Jakhade 		return ret;
13506b81f05aSSwapnil Jakhade 
13516b81f05aSSwapnil Jakhade 	return 0;
13526b81f05aSSwapnil Jakhade }
13536b81f05aSSwapnil Jakhade 
135444d30d62SAlan Douglas static int cdns_sierra_phy_probe(struct platform_device *pdev)
135544d30d62SAlan Douglas {
135644d30d62SAlan Douglas 	struct cdns_sierra_phy *sp;
135744d30d62SAlan Douglas 	struct phy_provider *phy_provider;
135844d30d62SAlan Douglas 	struct device *dev = &pdev->dev;
1359c3c11d55SSwapnil Jakhade 	const struct cdns_sierra_data *data;
1360380f5708SKishon Vijay Abraham I 	unsigned int id_value;
136129afbd76SDan Carpenter 	int ret, node = 0;
1362380f5708SKishon Vijay Abraham I 	void __iomem *base;
136344d30d62SAlan Douglas 	struct device_node *dn = dev->of_node, *child;
136444d30d62SAlan Douglas 
136544d30d62SAlan Douglas 	if (of_get_child_count(dn) == 0)
136644d30d62SAlan Douglas 		return -ENODEV;
136744d30d62SAlan Douglas 
1368380f5708SKishon Vijay Abraham I 	/* Get init data for this PHY */
1369c3c11d55SSwapnil Jakhade 	data = of_device_get_match_data(dev);
1370c3c11d55SSwapnil Jakhade 	if (!data)
1371380f5708SKishon Vijay Abraham I 		return -EINVAL;
1372380f5708SKishon Vijay Abraham I 
137344d30d62SAlan Douglas 	sp = devm_kzalloc(dev, sizeof(*sp), GFP_KERNEL);
137444d30d62SAlan Douglas 	if (!sp)
137544d30d62SAlan Douglas 		return -ENOMEM;
137644d30d62SAlan Douglas 	dev_set_drvdata(dev, sp);
137744d30d62SAlan Douglas 	sp->dev = dev;
1378380f5708SKishon Vijay Abraham I 	sp->init_data = data;
137944d30d62SAlan Douglas 
1380fa629094SChunfeng Yun 	base = devm_platform_ioremap_resource(pdev, 0);
1381380f5708SKishon Vijay Abraham I 	if (IS_ERR(base)) {
138244d30d62SAlan Douglas 		dev_err(dev, "missing \"reg\"\n");
1383380f5708SKishon Vijay Abraham I 		return PTR_ERR(base);
138444d30d62SAlan Douglas 	}
138544d30d62SAlan Douglas 
1386380f5708SKishon Vijay Abraham I 	ret = cdns_regmap_init_blocks(sp, base, data->block_offset_shift,
1387380f5708SKishon Vijay Abraham I 				      data->reg_offset_shift);
1388380f5708SKishon Vijay Abraham I 	if (ret)
1389380f5708SKishon Vijay Abraham I 		return ret;
1390380f5708SKishon Vijay Abraham I 
1391380f5708SKishon Vijay Abraham I 	ret = cdns_regfield_init(sp);
1392380f5708SKishon Vijay Abraham I 	if (ret)
1393380f5708SKishon Vijay Abraham I 		return ret;
139444d30d62SAlan Douglas 
139544d30d62SAlan Douglas 	platform_set_drvdata(pdev, sp);
139644d30d62SAlan Douglas 
13977e016cbcSKishon Vijay Abraham I 	ret = cdns_sierra_phy_get_clocks(sp, dev);
13987e016cbcSKishon Vijay Abraham I 	if (ret)
13997e016cbcSKishon Vijay Abraham I 		return ret;
140044d30d62SAlan Douglas 
140128081b72SKishon Vijay Abraham I 	ret = cdns_sierra_clk_register(sp);
14021d5f40e0SKishon Vijay Abraham I 	if (ret)
14031d5f40e0SKishon Vijay Abraham I 		return ret;
140444d30d62SAlan Douglas 
14051436ec30SKishon Vijay Abraham I 	ret = cdns_sierra_phy_enable_clocks(sp);
140644d30d62SAlan Douglas 	if (ret)
140728081b72SKishon Vijay Abraham I 		goto unregister_clk;
140844d30d62SAlan Douglas 
1409d88ca22dSAswath Govindraju 	regmap_field_read(sp->pma_cmn_ready, &sp->already_configured);
1410d88ca22dSAswath Govindraju 
1411d88ca22dSAswath Govindraju 	if (!sp->already_configured) {
1412d88ca22dSAswath Govindraju 		ret = cdns_sierra_phy_clk(sp);
1413d88ca22dSAswath Govindraju 		if (ret)
1414d88ca22dSAswath Govindraju 			goto clk_disable;
1415d88ca22dSAswath Govindraju 
1416d88ca22dSAswath Govindraju 		ret = cdns_sierra_phy_get_resets(sp, dev);
1417d88ca22dSAswath Govindraju 		if (ret)
1418d88ca22dSAswath Govindraju 			goto clk_disable;
1419d88ca22dSAswath Govindraju 
142044d30d62SAlan Douglas 		/* Enable APB */
142144d30d62SAlan Douglas 		reset_control_deassert(sp->apb_rst);
1422d88ca22dSAswath Govindraju 	}
142344d30d62SAlan Douglas 
142444d30d62SAlan Douglas 	/* Check that PHY is present */
1425380f5708SKishon Vijay Abraham I 	regmap_field_read(sp->macro_id_type, &id_value);
1426380f5708SKishon Vijay Abraham I 	if  (sp->init_data->id_value != id_value) {
142744d30d62SAlan Douglas 		ret = -EINVAL;
1428d88ca22dSAswath Govindraju 		goto ctrl_assert;
142944d30d62SAlan Douglas 	}
143044d30d62SAlan Douglas 
143144d30d62SAlan Douglas 	sp->autoconf = of_property_read_bool(dn, "cdns,autoconf");
143244d30d62SAlan Douglas 
143344d30d62SAlan Douglas 	for_each_available_child_of_node(dn, child) {
143444d30d62SAlan Douglas 		struct phy *gphy;
143544d30d62SAlan Douglas 
143603ada5a3SKishon Vijay Abraham I 		if (!(of_node_name_eq(child, "phy") ||
143703ada5a3SKishon Vijay Abraham I 		      of_node_name_eq(child, "link")))
143803ada5a3SKishon Vijay Abraham I 			continue;
143903ada5a3SKishon Vijay Abraham I 
144044d30d62SAlan Douglas 		sp->phys[node].lnk_rst =
1441b872936fSKishon Vijay Abraham I 			of_reset_control_array_get_exclusive(child);
144244d30d62SAlan Douglas 
144344d30d62SAlan Douglas 		if (IS_ERR(sp->phys[node].lnk_rst)) {
144444d30d62SAlan Douglas 			dev_err(dev, "failed to get reset %s\n",
144544d30d62SAlan Douglas 				child->full_name);
144644d30d62SAlan Douglas 			ret = PTR_ERR(sp->phys[node].lnk_rst);
144729afbd76SDan Carpenter 			of_node_put(child);
144829afbd76SDan Carpenter 			goto put_control;
144944d30d62SAlan Douglas 		}
145044d30d62SAlan Douglas 
145144d30d62SAlan Douglas 		if (!sp->autoconf) {
145244d30d62SAlan Douglas 			ret = cdns_sierra_get_optional(&sp->phys[node], child);
145344d30d62SAlan Douglas 			if (ret) {
145444d30d62SAlan Douglas 				dev_err(dev, "missing property in node %s\n",
145544d30d62SAlan Douglas 					child->name);
145629afbd76SDan Carpenter 				of_node_put(child);
145729afbd76SDan Carpenter 				reset_control_put(sp->phys[node].lnk_rst);
145829afbd76SDan Carpenter 				goto put_control;
145944d30d62SAlan Douglas 			}
146044d30d62SAlan Douglas 		}
146144d30d62SAlan Douglas 
1462a43f72aeSKishon Vijay Abraham I 		sp->num_lanes += sp->phys[node].num_lanes;
1463a43f72aeSKishon Vijay Abraham I 
1464d88ca22dSAswath Govindraju 		if (!sp->already_configured)
146544d30d62SAlan Douglas 			gphy = devm_phy_create(dev, child, &ops);
1466d88ca22dSAswath Govindraju 		else
1467d88ca22dSAswath Govindraju 			gphy = devm_phy_create(dev, child, &noop_ops);
146844d30d62SAlan Douglas 		if (IS_ERR(gphy)) {
146944d30d62SAlan Douglas 			ret = PTR_ERR(gphy);
147029afbd76SDan Carpenter 			of_node_put(child);
147129afbd76SDan Carpenter 			reset_control_put(sp->phys[node].lnk_rst);
147229afbd76SDan Carpenter 			goto put_control;
147344d30d62SAlan Douglas 		}
147444d30d62SAlan Douglas 		sp->phys[node].phy = gphy;
147544d30d62SAlan Douglas 		phy_set_drvdata(gphy, &sp->phys[node]);
147644d30d62SAlan Douglas 
147744d30d62SAlan Douglas 		node++;
147844d30d62SAlan Douglas 	}
147944d30d62SAlan Douglas 	sp->nsubnodes = node;
148044d30d62SAlan Douglas 
1481a43f72aeSKishon Vijay Abraham I 	if (sp->num_lanes > SIERRA_MAX_LANES) {
14826411e386SWang Wensheng 		ret = -EINVAL;
1483a43f72aeSKishon Vijay Abraham I 		dev_err(dev, "Invalid lane configuration\n");
148429afbd76SDan Carpenter 		goto put_control;
1485a43f72aeSKishon Vijay Abraham I 	}
1486a43f72aeSKishon Vijay Abraham I 
148744d30d62SAlan Douglas 	/* If more than one subnode, configure the PHY as multilink */
1488d88ca22dSAswath Govindraju 	if (!sp->already_configured && !sp->autoconf && sp->nsubnodes > 1) {
14896b81f05aSSwapnil Jakhade 		ret = cdns_sierra_phy_configure_multilink(sp);
14906b81f05aSSwapnil Jakhade 		if (ret)
149129afbd76SDan Carpenter 			goto put_control;
14926b81f05aSSwapnil Jakhade 	}
149344d30d62SAlan Douglas 
149444d30d62SAlan Douglas 	pm_runtime_enable(dev);
149544d30d62SAlan Douglas 	phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
149629afbd76SDan Carpenter 	if (IS_ERR(phy_provider)) {
149729afbd76SDan Carpenter 		ret = PTR_ERR(phy_provider);
149829afbd76SDan Carpenter 		goto put_control;
149929afbd76SDan Carpenter 	}
150044d30d62SAlan Douglas 
150129afbd76SDan Carpenter 	return 0;
150229afbd76SDan Carpenter 
150329afbd76SDan Carpenter put_control:
150429afbd76SDan Carpenter 	while (--node >= 0)
150529afbd76SDan Carpenter 		reset_control_put(sp->phys[node].lnk_rst);
1506d88ca22dSAswath Govindraju ctrl_assert:
1507d88ca22dSAswath Govindraju 	if (!sp->already_configured)
1508d88ca22dSAswath Govindraju 		reset_control_assert(sp->apb_rst);
150944d30d62SAlan Douglas clk_disable:
15101436ec30SKishon Vijay Abraham I 	cdns_sierra_phy_disable_clocks(sp);
151128081b72SKishon Vijay Abraham I unregister_clk:
151228081b72SKishon Vijay Abraham I 	cdns_sierra_clk_unregister(sp);
151344d30d62SAlan Douglas 	return ret;
151444d30d62SAlan Douglas }
151544d30d62SAlan Douglas 
1516*e9ddb1adSUwe Kleine-König static void cdns_sierra_phy_remove(struct platform_device *pdev)
151744d30d62SAlan Douglas {
1518748e3456SKishon Vijay Abraham I 	struct cdns_sierra_phy *phy = platform_get_drvdata(pdev);
151944d30d62SAlan Douglas 	int i;
152044d30d62SAlan Douglas 
152144d30d62SAlan Douglas 	reset_control_assert(phy->phy_rst);
152244d30d62SAlan Douglas 	reset_control_assert(phy->apb_rst);
152344d30d62SAlan Douglas 	pm_runtime_disable(&pdev->dev);
152444d30d62SAlan Douglas 
15251436ec30SKishon Vijay Abraham I 	cdns_sierra_phy_disable_clocks(phy);
152644d30d62SAlan Douglas 	/*
152744d30d62SAlan Douglas 	 * The device level resets will be put automatically.
152844d30d62SAlan Douglas 	 * Need to put the subnode resets here though.
152944d30d62SAlan Douglas 	 */
153044d30d62SAlan Douglas 	for (i = 0; i < phy->nsubnodes; i++) {
153144d30d62SAlan Douglas 		reset_control_assert(phy->phys[i].lnk_rst);
153244d30d62SAlan Douglas 		reset_control_put(phy->phys[i].lnk_rst);
153344d30d62SAlan Douglas 	}
153429c2d02aSKishon Vijay Abraham I 
153528081b72SKishon Vijay Abraham I 	cdns_sierra_clk_unregister(phy);
153644d30d62SAlan Douglas }
153744d30d62SAlan Douglas 
15388a1b82d7SSwapnil Jakhade /* QSGMII PHY PMA lane configuration */
15398a1b82d7SSwapnil Jakhade static struct cdns_reg_pairs qsgmii_phy_pma_ln_regs[] = {
15408a1b82d7SSwapnil Jakhade 	{0x9010, SIERRA_PHY_PMA_XCVR_CTRL}
15418a1b82d7SSwapnil Jakhade };
15428a1b82d7SSwapnil Jakhade 
15438a1b82d7SSwapnil Jakhade static struct cdns_sierra_vals qsgmii_phy_pma_ln_vals = {
15448a1b82d7SSwapnil Jakhade 	.reg_pairs = qsgmii_phy_pma_ln_regs,
15458a1b82d7SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(qsgmii_phy_pma_ln_regs),
15468a1b82d7SSwapnil Jakhade };
15478a1b82d7SSwapnil Jakhade 
15488a1b82d7SSwapnil Jakhade /* QSGMII refclk 100MHz, 20b, opt1, No BW cal, no ssc, PLL LC1 */
15498a1b82d7SSwapnil Jakhade static const struct cdns_reg_pairs qsgmii_100_no_ssc_plllc1_cmn_regs[] = {
15508a1b82d7SSwapnil Jakhade 	{0x2085, SIERRA_CMN_PLLLC1_LF_COEFF_MODE0_PREG},
15518a1b82d7SSwapnil Jakhade 	{0x0000, SIERRA_CMN_PLLLC1_BWCAL_MODE0_PREG},
15528a1b82d7SSwapnil Jakhade 	{0x0000, SIERRA_CMN_PLLLC1_SS_TIME_STEPSIZE_MODE_PREG}
15538a1b82d7SSwapnil Jakhade };
15548a1b82d7SSwapnil Jakhade 
15558a1b82d7SSwapnil Jakhade static const struct cdns_reg_pairs qsgmii_100_no_ssc_plllc1_ln_regs[] = {
15568a1b82d7SSwapnil Jakhade 	{0xFC08, SIERRA_DET_STANDEC_A_PREG},
15578a1b82d7SSwapnil Jakhade 	{0x0252, SIERRA_DET_STANDEC_E_PREG},
15588a1b82d7SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_IDLE_PREG},
15598a1b82d7SSwapnil Jakhade 	{0x0FFE, SIERRA_PSC_RX_A0_PREG},
15608a1b82d7SSwapnil Jakhade 	{0x0011, SIERRA_PLLCTRL_SUBRATE_PREG},
15618a1b82d7SSwapnil Jakhade 	{0x0001, SIERRA_PLLCTRL_GEN_A_PREG},
15628a1b82d7SSwapnil Jakhade 	{0x5233, SIERRA_PLLCTRL_CPGAIN_MODE_PREG},
15638a1b82d7SSwapnil Jakhade 	{0x0000, SIERRA_DRVCTRL_ATTEN_PREG},
15648a1b82d7SSwapnil Jakhade 	{0x0089, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
15658a1b82d7SSwapnil Jakhade 	{0x3C3C, SIERRA_CREQ_CCLKDET_MODE01_PREG},
15668a1b82d7SSwapnil Jakhade 	{0x3222, SIERRA_CREQ_FSMCLK_SEL_PREG},
15678a1b82d7SSwapnil Jakhade 	{0x0000, SIERRA_CREQ_EQ_CTRL_PREG},
15688a1b82d7SSwapnil Jakhade 	{0x8422, SIERRA_CTLELUT_CTRL_PREG},
15698a1b82d7SSwapnil Jakhade 	{0x4111, SIERRA_DFE_ECMP_RATESEL_PREG},
15708a1b82d7SSwapnil Jakhade 	{0x4111, SIERRA_DFE_SMP_RATESEL_PREG},
15718a1b82d7SSwapnil Jakhade 	{0x0002, SIERRA_DEQ_PHALIGN_CTRL},
15728a1b82d7SSwapnil Jakhade 	{0x9595, SIERRA_DEQ_VGATUNE_CTRL_PREG},
15738a1b82d7SSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT0},
15748a1b82d7SSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT1},
15758a1b82d7SSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT2},
15768a1b82d7SSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT3},
15778a1b82d7SSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT4},
15788a1b82d7SSwapnil Jakhade 	{0x0861, SIERRA_DEQ_ALUT0},
15798a1b82d7SSwapnil Jakhade 	{0x07E0, SIERRA_DEQ_ALUT1},
15808a1b82d7SSwapnil Jakhade 	{0x079E, SIERRA_DEQ_ALUT2},
15818a1b82d7SSwapnil Jakhade 	{0x071D, SIERRA_DEQ_ALUT3},
15828a1b82d7SSwapnil Jakhade 	{0x03F5, SIERRA_DEQ_DFETAP_CTRL_PREG},
15838a1b82d7SSwapnil Jakhade 	{0x0C01, SIERRA_DEQ_TAU_CTRL1_FAST_MAINT_PREG},
15848a1b82d7SSwapnil Jakhade 	{0x3C40, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG},
15858a1b82d7SSwapnil Jakhade 	{0x1C04, SIERRA_DEQ_TAU_CTRL2_PREG},
15868a1b82d7SSwapnil Jakhade 	{0x0033, SIERRA_DEQ_PICTRL_PREG},
15878a1b82d7SSwapnil Jakhade 	{0x0660, SIERRA_CPICAL_TMRVAL_MODE0_PREG},
15888a1b82d7SSwapnil Jakhade 	{0x00D5, SIERRA_CPI_OUTBUF_RATESEL_PREG},
15898a1b82d7SSwapnil Jakhade 	{0x0B6D, SIERRA_CPI_RESBIAS_BIN_PREG},
15908a1b82d7SSwapnil Jakhade 	{0x0102, SIERRA_RXBUFFER_CTLECTRL_PREG},
15918a1b82d7SSwapnil Jakhade 	{0x0002, SIERRA_RXBUFFER_RCDFECTRL_PREG}
15928a1b82d7SSwapnil Jakhade };
15938a1b82d7SSwapnil Jakhade 
15948a1b82d7SSwapnil Jakhade static struct cdns_sierra_vals qsgmii_100_no_ssc_plllc1_cmn_vals = {
15958a1b82d7SSwapnil Jakhade 	.reg_pairs = qsgmii_100_no_ssc_plllc1_cmn_regs,
15968a1b82d7SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(qsgmii_100_no_ssc_plllc1_cmn_regs),
15978a1b82d7SSwapnil Jakhade };
15988a1b82d7SSwapnil Jakhade 
15998a1b82d7SSwapnil Jakhade static struct cdns_sierra_vals qsgmii_100_no_ssc_plllc1_ln_vals = {
16008a1b82d7SSwapnil Jakhade 	.reg_pairs = qsgmii_100_no_ssc_plllc1_ln_regs,
16018a1b82d7SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(qsgmii_100_no_ssc_plllc1_ln_regs),
16028a1b82d7SSwapnil Jakhade };
16038a1b82d7SSwapnil Jakhade 
1604fa105172SSwapnil Jakhade /* PCIE PHY PCS common configuration */
1605fa105172SSwapnil Jakhade static struct cdns_reg_pairs pcie_phy_pcs_cmn_regs[] = {
1606fa105172SSwapnil Jakhade 	{0x0430, SIERRA_PHY_PIPE_CMN_CTRL1}
1607fa105172SSwapnil Jakhade };
1608fa105172SSwapnil Jakhade 
1609fa105172SSwapnil Jakhade static struct cdns_sierra_vals pcie_phy_pcs_cmn_vals = {
1610fa105172SSwapnil Jakhade 	.reg_pairs = pcie_phy_pcs_cmn_regs,
1611fa105172SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(pcie_phy_pcs_cmn_regs),
1612fa105172SSwapnil Jakhade };
1613fa105172SSwapnil Jakhade 
16148a1b82d7SSwapnil Jakhade /* refclk100MHz_32b_PCIe_cmn_pll_no_ssc, pcie_links_using_plllc, pipe_bw_3 */
16158a1b82d7SSwapnil Jakhade static const struct cdns_reg_pairs pcie_100_no_ssc_plllc_cmn_regs[] = {
16168a1b82d7SSwapnil Jakhade 	{0x2105, SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG},
16178a1b82d7SSwapnil Jakhade 	{0x2105, SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG},
16188a1b82d7SSwapnil Jakhade 	{0x8A06, SIERRA_CMN_PLLLC_BWCAL_MODE1_PREG},
16198a1b82d7SSwapnil Jakhade 	{0x8A06, SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG}
16208a1b82d7SSwapnil Jakhade };
16218a1b82d7SSwapnil Jakhade 
16228a1b82d7SSwapnil Jakhade /*
16238a1b82d7SSwapnil Jakhade  * refclk100MHz_32b_PCIe_ln_no_ssc, multilink, using_plllc,
16248a1b82d7SSwapnil Jakhade  * cmn_pllcy_anaclk0_1Ghz, xcvr_pllclk_fullrt_500mhz
16258a1b82d7SSwapnil Jakhade  */
16268a1b82d7SSwapnil Jakhade static const struct cdns_reg_pairs ml_pcie_100_no_ssc_ln_regs[] = {
16278a1b82d7SSwapnil Jakhade 	{0xFC08, SIERRA_DET_STANDEC_A_PREG},
16288a1b82d7SSwapnil Jakhade 	{0x001D, SIERRA_PSM_A3IN_TMR_PREG},
16298a1b82d7SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_A3_PREG},
16308a1b82d7SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_A4_PREG},
16318a1b82d7SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_IDLE_PREG},
16328a1b82d7SSwapnil Jakhade 	{0x1555, SIERRA_DFE_BIASTRIM_PREG},
16338a1b82d7SSwapnil Jakhade 	{0x9703, SIERRA_DRVCTRL_BOOST_PREG},
16348a1b82d7SSwapnil Jakhade 	{0x8055, SIERRA_RX_CREQ_FLTR_A_MODE3_PREG},
16358a1b82d7SSwapnil Jakhade 	{0x80BB, SIERRA_RX_CREQ_FLTR_A_MODE2_PREG},
16368a1b82d7SSwapnil Jakhade 	{0x8351, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG},
16378a1b82d7SSwapnil Jakhade 	{0x8349, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
16388a1b82d7SSwapnil Jakhade 	{0x0002, SIERRA_CREQ_DCBIASATTEN_OVR_PREG},
16398a1b82d7SSwapnil Jakhade 	{0x9800, SIERRA_RX_CTLE_CAL_PREG},
16408a1b82d7SSwapnil Jakhade 	{0x5624, SIERRA_DEQ_CONCUR_CTRL2_PREG},
16418a1b82d7SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_EPIPWR_CTRL2_PREG},
16428a1b82d7SSwapnil Jakhade 	{0x00FF, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG},
16438a1b82d7SSwapnil Jakhade 	{0x4C4C, SIERRA_DEQ_ERRCMP_CTRL_PREG},
16448a1b82d7SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_OFFSET_CTRL_PREG},
16458a1b82d7SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_GAIN_CTRL_PREG},
16468a1b82d7SSwapnil Jakhade 	{0x0041, SIERRA_DEQ_GLUT0},
16478a1b82d7SSwapnil Jakhade 	{0x0082, SIERRA_DEQ_GLUT1},
16488a1b82d7SSwapnil Jakhade 	{0x00C3, SIERRA_DEQ_GLUT2},
16498a1b82d7SSwapnil Jakhade 	{0x0145, SIERRA_DEQ_GLUT3},
16508a1b82d7SSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT4},
16518a1b82d7SSwapnil Jakhade 	{0x09E7, SIERRA_DEQ_ALUT0},
16528a1b82d7SSwapnil Jakhade 	{0x09A6, SIERRA_DEQ_ALUT1},
16538a1b82d7SSwapnil Jakhade 	{0x0965, SIERRA_DEQ_ALUT2},
16548a1b82d7SSwapnil Jakhade 	{0x08E3, SIERRA_DEQ_ALUT3},
16558a1b82d7SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP0},
16568a1b82d7SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP1},
16578a1b82d7SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP2},
16588a1b82d7SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP3},
16598a1b82d7SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP4},
16608a1b82d7SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_PRECUR_PREG},
16618a1b82d7SSwapnil Jakhade 	{0x0280, SIERRA_DEQ_POSTCUR_PREG},
16628a1b82d7SSwapnil Jakhade 	{0x8F00, SIERRA_DEQ_POSTCUR_DECR_PREG},
16638a1b82d7SSwapnil Jakhade 	{0x3C0F, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG},
16648a1b82d7SSwapnil Jakhade 	{0x1C0C, SIERRA_DEQ_TAU_CTRL2_PREG},
16658a1b82d7SSwapnil Jakhade 	{0x0100, SIERRA_DEQ_TAU_CTRL3_PREG},
16668a1b82d7SSwapnil Jakhade 	{0x5E82, SIERRA_DEQ_OPENEYE_CTRL_PREG},
16678a1b82d7SSwapnil Jakhade 	{0x002B, SIERRA_CPI_TRIM_PREG},
16688a1b82d7SSwapnil Jakhade 	{0x0003, SIERRA_EPI_CTRL_PREG},
16698a1b82d7SSwapnil Jakhade 	{0x803F, SIERRA_SDFILT_H2L_A_PREG},
16708a1b82d7SSwapnil Jakhade 	{0x0004, SIERRA_RXBUFFER_CTLECTRL_PREG},
16718a1b82d7SSwapnil Jakhade 	{0x2010, SIERRA_RXBUFFER_RCDFECTRL_PREG},
16728a1b82d7SSwapnil Jakhade 	{0x4432, SIERRA_RXBUFFER_DFECTRL_PREG}
16738a1b82d7SSwapnil Jakhade };
16748a1b82d7SSwapnil Jakhade 
16758a1b82d7SSwapnil Jakhade static struct cdns_sierra_vals pcie_100_no_ssc_plllc_cmn_vals = {
16768a1b82d7SSwapnil Jakhade 	.reg_pairs = pcie_100_no_ssc_plllc_cmn_regs,
16778a1b82d7SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(pcie_100_no_ssc_plllc_cmn_regs),
16788a1b82d7SSwapnil Jakhade };
16798a1b82d7SSwapnil Jakhade 
16808a1b82d7SSwapnil Jakhade static struct cdns_sierra_vals ml_pcie_100_no_ssc_ln_vals = {
16818a1b82d7SSwapnil Jakhade 	.reg_pairs = ml_pcie_100_no_ssc_ln_regs,
16828a1b82d7SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(ml_pcie_100_no_ssc_ln_regs),
16838a1b82d7SSwapnil Jakhade };
16848a1b82d7SSwapnil Jakhade 
1685e72659b6SSwapnil Jakhade /*
1686e72659b6SSwapnil Jakhade  * TI J721E:
1687e72659b6SSwapnil Jakhade  * refclk100MHz_32b_PCIe_ln_no_ssc, multilink, using_plllc,
1688e72659b6SSwapnil Jakhade  * cmn_pllcy_anaclk0_1Ghz, xcvr_pllclk_fullrt_500mhz
1689e72659b6SSwapnil Jakhade  */
1690e72659b6SSwapnil Jakhade static const struct cdns_reg_pairs ti_ml_pcie_100_no_ssc_ln_regs[] = {
1691e72659b6SSwapnil Jakhade 	{0xFC08, SIERRA_DET_STANDEC_A_PREG},
1692e72659b6SSwapnil Jakhade 	{0x001D, SIERRA_PSM_A3IN_TMR_PREG},
1693e72659b6SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_A3_PREG},
1694e72659b6SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_A4_PREG},
1695e72659b6SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_IDLE_PREG},
1696e72659b6SSwapnil Jakhade 	{0x1555, SIERRA_DFE_BIASTRIM_PREG},
1697e72659b6SSwapnil Jakhade 	{0x9703, SIERRA_DRVCTRL_BOOST_PREG},
1698e72659b6SSwapnil Jakhade 	{0x8055, SIERRA_RX_CREQ_FLTR_A_MODE3_PREG},
1699e72659b6SSwapnil Jakhade 	{0x80BB, SIERRA_RX_CREQ_FLTR_A_MODE2_PREG},
1700e72659b6SSwapnil Jakhade 	{0x8351, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG},
1701e72659b6SSwapnil Jakhade 	{0x8349, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
1702e72659b6SSwapnil Jakhade 	{0x0002, SIERRA_CREQ_DCBIASATTEN_OVR_PREG},
1703e72659b6SSwapnil Jakhade 	{0x9800, SIERRA_RX_CTLE_CAL_PREG},
1704e72659b6SSwapnil Jakhade 	{0x5624, SIERRA_DEQ_CONCUR_CTRL2_PREG},
1705e72659b6SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_EPIPWR_CTRL2_PREG},
1706e72659b6SSwapnil Jakhade 	{0x00FF, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG},
1707e72659b6SSwapnil Jakhade 	{0x4C4C, SIERRA_DEQ_ERRCMP_CTRL_PREG},
1708e72659b6SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_OFFSET_CTRL_PREG},
1709e72659b6SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_GAIN_CTRL_PREG},
1710e72659b6SSwapnil Jakhade 	{0x0041, SIERRA_DEQ_GLUT0},
1711e72659b6SSwapnil Jakhade 	{0x0082, SIERRA_DEQ_GLUT1},
1712e72659b6SSwapnil Jakhade 	{0x00C3, SIERRA_DEQ_GLUT2},
1713e72659b6SSwapnil Jakhade 	{0x0145, SIERRA_DEQ_GLUT3},
1714e72659b6SSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT4},
1715e72659b6SSwapnil Jakhade 	{0x09E7, SIERRA_DEQ_ALUT0},
1716e72659b6SSwapnil Jakhade 	{0x09A6, SIERRA_DEQ_ALUT1},
1717e72659b6SSwapnil Jakhade 	{0x0965, SIERRA_DEQ_ALUT2},
1718e72659b6SSwapnil Jakhade 	{0x08E3, SIERRA_DEQ_ALUT3},
1719e72659b6SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP0},
1720e72659b6SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP1},
1721e72659b6SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP2},
1722e72659b6SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP3},
1723e72659b6SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP4},
1724e72659b6SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_PRECUR_PREG},
1725e72659b6SSwapnil Jakhade 	{0x0280, SIERRA_DEQ_POSTCUR_PREG},
1726e72659b6SSwapnil Jakhade 	{0x8F00, SIERRA_DEQ_POSTCUR_DECR_PREG},
1727e72659b6SSwapnil Jakhade 	{0x3C0F, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG},
1728e72659b6SSwapnil Jakhade 	{0x1C0C, SIERRA_DEQ_TAU_CTRL2_PREG},
1729e72659b6SSwapnil Jakhade 	{0x0100, SIERRA_DEQ_TAU_CTRL3_PREG},
1730e72659b6SSwapnil Jakhade 	{0x5E82, SIERRA_DEQ_OPENEYE_CTRL_PREG},
1731e72659b6SSwapnil Jakhade 	{0x002B, SIERRA_CPI_TRIM_PREG},
1732e72659b6SSwapnil Jakhade 	{0x0003, SIERRA_EPI_CTRL_PREG},
1733e72659b6SSwapnil Jakhade 	{0x803F, SIERRA_SDFILT_H2L_A_PREG},
1734e72659b6SSwapnil Jakhade 	{0x0004, SIERRA_RXBUFFER_CTLECTRL_PREG},
1735e72659b6SSwapnil Jakhade 	{0x2010, SIERRA_RXBUFFER_RCDFECTRL_PREG},
1736e72659b6SSwapnil Jakhade 	{0x4432, SIERRA_RXBUFFER_DFECTRL_PREG},
1737e72659b6SSwapnil Jakhade 	{0x0002, SIERRA_TX_RCVDET_OVRD_PREG}
1738e72659b6SSwapnil Jakhade };
1739e72659b6SSwapnil Jakhade 
1740e72659b6SSwapnil Jakhade static struct cdns_sierra_vals ti_ml_pcie_100_no_ssc_ln_vals = {
1741e72659b6SSwapnil Jakhade 	.reg_pairs = ti_ml_pcie_100_no_ssc_ln_regs,
1742e72659b6SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(ti_ml_pcie_100_no_ssc_ln_regs),
1743e72659b6SSwapnil Jakhade };
1744e72659b6SSwapnil Jakhade 
17458a1b82d7SSwapnil Jakhade /* refclk100MHz_32b_PCIe_cmn_pll_int_ssc, pcie_links_using_plllc, pipe_bw_3 */
17468a1b82d7SSwapnil Jakhade static const struct cdns_reg_pairs pcie_100_int_ssc_plllc_cmn_regs[] = {
17478a1b82d7SSwapnil Jakhade 	{0x000E, SIERRA_CMN_PLLLC_MODE_PREG},
17488a1b82d7SSwapnil Jakhade 	{0x4006, SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG},
17498a1b82d7SSwapnil Jakhade 	{0x4006, SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG},
17508a1b82d7SSwapnil Jakhade 	{0x0000, SIERRA_CMN_PLLLC_BWCAL_MODE1_PREG},
17518a1b82d7SSwapnil Jakhade 	{0x0000, SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG},
17528a1b82d7SSwapnil Jakhade 	{0x0581, SIERRA_CMN_PLLLC_DSMCORR_PREG},
17538a1b82d7SSwapnil Jakhade 	{0x7F80, SIERRA_CMN_PLLLC_SS_PREG},
17548a1b82d7SSwapnil Jakhade 	{0x0041, SIERRA_CMN_PLLLC_SS_AMP_STEP_SIZE_PREG},
17558a1b82d7SSwapnil Jakhade 	{0x0464, SIERRA_CMN_PLLLC_SSTWOPT_PREG},
17568a1b82d7SSwapnil Jakhade 	{0x0D0D, SIERRA_CMN_PLLLC_SS_TIME_STEPSIZE_MODE_PREG},
17578a1b82d7SSwapnil Jakhade 	{0x0060, SIERRA_CMN_PLLLC_LOCK_DELAY_CTRL_PREG}
17588a1b82d7SSwapnil Jakhade };
17598a1b82d7SSwapnil Jakhade 
17608a1b82d7SSwapnil Jakhade /*
17618a1b82d7SSwapnil Jakhade  * refclk100MHz_32b_PCIe_ln_int_ssc, multilink, using_plllc,
17628a1b82d7SSwapnil Jakhade  * cmn_pllcy_anaclk0_1Ghz, xcvr_pllclk_fullrt_500mhz
17638a1b82d7SSwapnil Jakhade  */
17648a1b82d7SSwapnil Jakhade static const struct cdns_reg_pairs ml_pcie_100_int_ssc_ln_regs[] = {
17658a1b82d7SSwapnil Jakhade 	{0xFC08, SIERRA_DET_STANDEC_A_PREG},
17668a1b82d7SSwapnil Jakhade 	{0x001D, SIERRA_PSM_A3IN_TMR_PREG},
17678a1b82d7SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_A3_PREG},
17688a1b82d7SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_A4_PREG},
17698a1b82d7SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_IDLE_PREG},
17708a1b82d7SSwapnil Jakhade 	{0x1555, SIERRA_DFE_BIASTRIM_PREG},
17718a1b82d7SSwapnil Jakhade 	{0x9703, SIERRA_DRVCTRL_BOOST_PREG},
17728a1b82d7SSwapnil Jakhade 	{0x813E, SIERRA_CLKPATHCTRL_TMR_PREG},
17738a1b82d7SSwapnil Jakhade 	{0x8047, SIERRA_RX_CREQ_FLTR_A_MODE3_PREG},
17748a1b82d7SSwapnil Jakhade 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE2_PREG},
17758a1b82d7SSwapnil Jakhade 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG},
17768a1b82d7SSwapnil Jakhade 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
17778a1b82d7SSwapnil Jakhade 	{0x0002, SIERRA_CREQ_DCBIASATTEN_OVR_PREG},
17788a1b82d7SSwapnil Jakhade 	{0x9800, SIERRA_RX_CTLE_CAL_PREG},
17798a1b82d7SSwapnil Jakhade 	{0x033C, SIERRA_RX_CTLE_MAINTENANCE_PREG},
17808a1b82d7SSwapnil Jakhade 	{0x44CC, SIERRA_CREQ_EQ_OPEN_EYE_THRESH_PREG},
17818a1b82d7SSwapnil Jakhade 	{0x5624, SIERRA_DEQ_CONCUR_CTRL2_PREG},
17828a1b82d7SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_EPIPWR_CTRL2_PREG},
17838a1b82d7SSwapnil Jakhade 	{0x00FF, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG},
17848a1b82d7SSwapnil Jakhade 	{0x4C4C, SIERRA_DEQ_ERRCMP_CTRL_PREG},
17858a1b82d7SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_OFFSET_CTRL_PREG},
17868a1b82d7SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_GAIN_CTRL_PREG},
17878a1b82d7SSwapnil Jakhade 	{0x0041, SIERRA_DEQ_GLUT0},
17888a1b82d7SSwapnil Jakhade 	{0x0082, SIERRA_DEQ_GLUT1},
17898a1b82d7SSwapnil Jakhade 	{0x00C3, SIERRA_DEQ_GLUT2},
17908a1b82d7SSwapnil Jakhade 	{0x0145, SIERRA_DEQ_GLUT3},
17918a1b82d7SSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT4},
17928a1b82d7SSwapnil Jakhade 	{0x09E7, SIERRA_DEQ_ALUT0},
17938a1b82d7SSwapnil Jakhade 	{0x09A6, SIERRA_DEQ_ALUT1},
17948a1b82d7SSwapnil Jakhade 	{0x0965, SIERRA_DEQ_ALUT2},
17958a1b82d7SSwapnil Jakhade 	{0x08E3, SIERRA_DEQ_ALUT3},
17968a1b82d7SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP0},
17978a1b82d7SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP1},
17988a1b82d7SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP2},
17998a1b82d7SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP3},
18008a1b82d7SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP4},
18018a1b82d7SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_PRECUR_PREG},
18028a1b82d7SSwapnil Jakhade 	{0x0280, SIERRA_DEQ_POSTCUR_PREG},
18038a1b82d7SSwapnil Jakhade 	{0x8F00, SIERRA_DEQ_POSTCUR_DECR_PREG},
18048a1b82d7SSwapnil Jakhade 	{0x3C0F, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG},
18058a1b82d7SSwapnil Jakhade 	{0x1C0C, SIERRA_DEQ_TAU_CTRL2_PREG},
18068a1b82d7SSwapnil Jakhade 	{0x0100, SIERRA_DEQ_TAU_CTRL3_PREG},
18078a1b82d7SSwapnil Jakhade 	{0x5E82, SIERRA_DEQ_OPENEYE_CTRL_PREG},
18088a1b82d7SSwapnil Jakhade 	{0x002B, SIERRA_CPI_TRIM_PREG},
18098a1b82d7SSwapnil Jakhade 	{0x0003, SIERRA_EPI_CTRL_PREG},
18108a1b82d7SSwapnil Jakhade 	{0x803F, SIERRA_SDFILT_H2L_A_PREG},
18118a1b82d7SSwapnil Jakhade 	{0x0004, SIERRA_RXBUFFER_CTLECTRL_PREG},
18128a1b82d7SSwapnil Jakhade 	{0x2010, SIERRA_RXBUFFER_RCDFECTRL_PREG},
18138a1b82d7SSwapnil Jakhade 	{0x4432, SIERRA_RXBUFFER_DFECTRL_PREG}
18148a1b82d7SSwapnil Jakhade };
18158a1b82d7SSwapnil Jakhade 
18168a1b82d7SSwapnil Jakhade static struct cdns_sierra_vals pcie_100_int_ssc_plllc_cmn_vals = {
18178a1b82d7SSwapnil Jakhade 	.reg_pairs = pcie_100_int_ssc_plllc_cmn_regs,
18188a1b82d7SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(pcie_100_int_ssc_plllc_cmn_regs),
18198a1b82d7SSwapnil Jakhade };
18208a1b82d7SSwapnil Jakhade 
18218a1b82d7SSwapnil Jakhade static struct cdns_sierra_vals ml_pcie_100_int_ssc_ln_vals = {
18228a1b82d7SSwapnil Jakhade 	.reg_pairs = ml_pcie_100_int_ssc_ln_regs,
18238a1b82d7SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(ml_pcie_100_int_ssc_ln_regs),
18248a1b82d7SSwapnil Jakhade };
18258a1b82d7SSwapnil Jakhade 
1826e72659b6SSwapnil Jakhade /*
1827e72659b6SSwapnil Jakhade  * TI J721E:
1828e72659b6SSwapnil Jakhade  * refclk100MHz_32b_PCIe_ln_int_ssc, multilink, using_plllc,
1829e72659b6SSwapnil Jakhade  * cmn_pllcy_anaclk0_1Ghz, xcvr_pllclk_fullrt_500mhz
1830e72659b6SSwapnil Jakhade  */
1831e72659b6SSwapnil Jakhade static const struct cdns_reg_pairs ti_ml_pcie_100_int_ssc_ln_regs[] = {
1832e72659b6SSwapnil Jakhade 	{0xFC08, SIERRA_DET_STANDEC_A_PREG},
1833e72659b6SSwapnil Jakhade 	{0x001D, SIERRA_PSM_A3IN_TMR_PREG},
1834e72659b6SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_A3_PREG},
1835e72659b6SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_A4_PREG},
1836e72659b6SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_IDLE_PREG},
1837e72659b6SSwapnil Jakhade 	{0x1555, SIERRA_DFE_BIASTRIM_PREG},
1838e72659b6SSwapnil Jakhade 	{0x9703, SIERRA_DRVCTRL_BOOST_PREG},
1839e72659b6SSwapnil Jakhade 	{0x813E, SIERRA_CLKPATHCTRL_TMR_PREG},
1840e72659b6SSwapnil Jakhade 	{0x8047, SIERRA_RX_CREQ_FLTR_A_MODE3_PREG},
1841e72659b6SSwapnil Jakhade 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE2_PREG},
1842e72659b6SSwapnil Jakhade 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG},
1843e72659b6SSwapnil Jakhade 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
1844e72659b6SSwapnil Jakhade 	{0x0002, SIERRA_CREQ_DCBIASATTEN_OVR_PREG},
1845e72659b6SSwapnil Jakhade 	{0x9800, SIERRA_RX_CTLE_CAL_PREG},
1846e72659b6SSwapnil Jakhade 	{0x033C, SIERRA_RX_CTLE_MAINTENANCE_PREG},
1847e72659b6SSwapnil Jakhade 	{0x44CC, SIERRA_CREQ_EQ_OPEN_EYE_THRESH_PREG},
1848e72659b6SSwapnil Jakhade 	{0x5624, SIERRA_DEQ_CONCUR_CTRL2_PREG},
1849e72659b6SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_EPIPWR_CTRL2_PREG},
1850e72659b6SSwapnil Jakhade 	{0x00FF, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG},
1851e72659b6SSwapnil Jakhade 	{0x4C4C, SIERRA_DEQ_ERRCMP_CTRL_PREG},
1852e72659b6SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_OFFSET_CTRL_PREG},
1853e72659b6SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_GAIN_CTRL_PREG},
1854e72659b6SSwapnil Jakhade 	{0x0041, SIERRA_DEQ_GLUT0},
1855e72659b6SSwapnil Jakhade 	{0x0082, SIERRA_DEQ_GLUT1},
1856e72659b6SSwapnil Jakhade 	{0x00C3, SIERRA_DEQ_GLUT2},
1857e72659b6SSwapnil Jakhade 	{0x0145, SIERRA_DEQ_GLUT3},
1858e72659b6SSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT4},
1859e72659b6SSwapnil Jakhade 	{0x09E7, SIERRA_DEQ_ALUT0},
1860e72659b6SSwapnil Jakhade 	{0x09A6, SIERRA_DEQ_ALUT1},
1861e72659b6SSwapnil Jakhade 	{0x0965, SIERRA_DEQ_ALUT2},
1862e72659b6SSwapnil Jakhade 	{0x08E3, SIERRA_DEQ_ALUT3},
1863e72659b6SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP0},
1864e72659b6SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP1},
1865e72659b6SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP2},
1866e72659b6SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP3},
1867e72659b6SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP4},
1868e72659b6SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_PRECUR_PREG},
1869e72659b6SSwapnil Jakhade 	{0x0280, SIERRA_DEQ_POSTCUR_PREG},
1870e72659b6SSwapnil Jakhade 	{0x8F00, SIERRA_DEQ_POSTCUR_DECR_PREG},
1871e72659b6SSwapnil Jakhade 	{0x3C0F, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG},
1872e72659b6SSwapnil Jakhade 	{0x1C0C, SIERRA_DEQ_TAU_CTRL2_PREG},
1873e72659b6SSwapnil Jakhade 	{0x0100, SIERRA_DEQ_TAU_CTRL3_PREG},
1874e72659b6SSwapnil Jakhade 	{0x5E82, SIERRA_DEQ_OPENEYE_CTRL_PREG},
1875e72659b6SSwapnil Jakhade 	{0x002B, SIERRA_CPI_TRIM_PREG},
1876e72659b6SSwapnil Jakhade 	{0x0003, SIERRA_EPI_CTRL_PREG},
1877e72659b6SSwapnil Jakhade 	{0x803F, SIERRA_SDFILT_H2L_A_PREG},
1878e72659b6SSwapnil Jakhade 	{0x0004, SIERRA_RXBUFFER_CTLECTRL_PREG},
1879e72659b6SSwapnil Jakhade 	{0x2010, SIERRA_RXBUFFER_RCDFECTRL_PREG},
1880e72659b6SSwapnil Jakhade 	{0x4432, SIERRA_RXBUFFER_DFECTRL_PREG},
1881e72659b6SSwapnil Jakhade 	{0x0002, SIERRA_TX_RCVDET_OVRD_PREG}
1882e72659b6SSwapnil Jakhade };
1883e72659b6SSwapnil Jakhade 
1884e72659b6SSwapnil Jakhade static struct cdns_sierra_vals ti_ml_pcie_100_int_ssc_ln_vals = {
1885e72659b6SSwapnil Jakhade 	.reg_pairs = ti_ml_pcie_100_int_ssc_ln_regs,
1886e72659b6SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(ti_ml_pcie_100_int_ssc_ln_regs),
1887e72659b6SSwapnil Jakhade };
1888e72659b6SSwapnil Jakhade 
18898a1b82d7SSwapnil Jakhade /* refclk100MHz_32b_PCIe_cmn_pll_ext_ssc, pcie_links_using_plllc, pipe_bw_3 */
18908a1b82d7SSwapnil Jakhade static const struct cdns_reg_pairs pcie_100_ext_ssc_plllc_cmn_regs[] = {
18918a1b82d7SSwapnil Jakhade 	{0x2106, SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG},
18928a1b82d7SSwapnil Jakhade 	{0x2106, SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG},
18938a1b82d7SSwapnil Jakhade 	{0x8A06, SIERRA_CMN_PLLLC_BWCAL_MODE1_PREG},
18948a1b82d7SSwapnil Jakhade 	{0x8A06, SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG},
18958a1b82d7SSwapnil Jakhade 	{0x1B1B, SIERRA_CMN_PLLLC_SS_TIME_STEPSIZE_MODE_PREG}
18968a1b82d7SSwapnil Jakhade };
18978a1b82d7SSwapnil Jakhade 
18988a1b82d7SSwapnil Jakhade /*
18998a1b82d7SSwapnil Jakhade  * refclk100MHz_32b_PCIe_ln_ext_ssc, multilink, using_plllc,
19008a1b82d7SSwapnil Jakhade  * cmn_pllcy_anaclk0_1Ghz, xcvr_pllclk_fullrt_500mhz
19018a1b82d7SSwapnil Jakhade  */
19028a1b82d7SSwapnil Jakhade static const struct cdns_reg_pairs ml_pcie_100_ext_ssc_ln_regs[] = {
19038a1b82d7SSwapnil Jakhade 	{0xFC08, SIERRA_DET_STANDEC_A_PREG},
19048a1b82d7SSwapnil Jakhade 	{0x001D, SIERRA_PSM_A3IN_TMR_PREG},
19058a1b82d7SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_A3_PREG},
19068a1b82d7SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_A4_PREG},
19078a1b82d7SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_IDLE_PREG},
19088a1b82d7SSwapnil Jakhade 	{0x1555, SIERRA_DFE_BIASTRIM_PREG},
19098a1b82d7SSwapnil Jakhade 	{0x9703, SIERRA_DRVCTRL_BOOST_PREG},
19108a1b82d7SSwapnil Jakhade 	{0x813E, SIERRA_CLKPATHCTRL_TMR_PREG},
19118a1b82d7SSwapnil Jakhade 	{0x8047, SIERRA_RX_CREQ_FLTR_A_MODE3_PREG},
19128a1b82d7SSwapnil Jakhade 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE2_PREG},
19138a1b82d7SSwapnil Jakhade 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG},
19148a1b82d7SSwapnil Jakhade 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
19158a1b82d7SSwapnil Jakhade 	{0x0002, SIERRA_CREQ_DCBIASATTEN_OVR_PREG},
19168a1b82d7SSwapnil Jakhade 	{0x9800, SIERRA_RX_CTLE_CAL_PREG},
19178a1b82d7SSwapnil Jakhade 	{0x033C, SIERRA_RX_CTLE_MAINTENANCE_PREG},
19188a1b82d7SSwapnil Jakhade 	{0x44CC, SIERRA_CREQ_EQ_OPEN_EYE_THRESH_PREG},
19198a1b82d7SSwapnil Jakhade 	{0x5624, SIERRA_DEQ_CONCUR_CTRL2_PREG},
19208a1b82d7SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_EPIPWR_CTRL2_PREG},
19218a1b82d7SSwapnil Jakhade 	{0x00FF, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG},
19228a1b82d7SSwapnil Jakhade 	{0x4C4C, SIERRA_DEQ_ERRCMP_CTRL_PREG},
19238a1b82d7SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_OFFSET_CTRL_PREG},
19248a1b82d7SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_GAIN_CTRL_PREG},
19258a1b82d7SSwapnil Jakhade 	{0x0041, SIERRA_DEQ_GLUT0},
19268a1b82d7SSwapnil Jakhade 	{0x0082, SIERRA_DEQ_GLUT1},
19278a1b82d7SSwapnil Jakhade 	{0x00C3, SIERRA_DEQ_GLUT2},
19288a1b82d7SSwapnil Jakhade 	{0x0145, SIERRA_DEQ_GLUT3},
19298a1b82d7SSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT4},
19308a1b82d7SSwapnil Jakhade 	{0x09E7, SIERRA_DEQ_ALUT0},
19318a1b82d7SSwapnil Jakhade 	{0x09A6, SIERRA_DEQ_ALUT1},
19328a1b82d7SSwapnil Jakhade 	{0x0965, SIERRA_DEQ_ALUT2},
19338a1b82d7SSwapnil Jakhade 	{0x08E3, SIERRA_DEQ_ALUT3},
19348a1b82d7SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP0},
19358a1b82d7SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP1},
19368a1b82d7SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP2},
19378a1b82d7SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP3},
19388a1b82d7SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP4},
19398a1b82d7SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_PRECUR_PREG},
19408a1b82d7SSwapnil Jakhade 	{0x0280, SIERRA_DEQ_POSTCUR_PREG},
19418a1b82d7SSwapnil Jakhade 	{0x8F00, SIERRA_DEQ_POSTCUR_DECR_PREG},
19428a1b82d7SSwapnil Jakhade 	{0x3C0F, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG},
19438a1b82d7SSwapnil Jakhade 	{0x1C0C, SIERRA_DEQ_TAU_CTRL2_PREG},
19448a1b82d7SSwapnil Jakhade 	{0x0100, SIERRA_DEQ_TAU_CTRL3_PREG},
19458a1b82d7SSwapnil Jakhade 	{0x5E82, SIERRA_DEQ_OPENEYE_CTRL_PREG},
19468a1b82d7SSwapnil Jakhade 	{0x002B, SIERRA_CPI_TRIM_PREG},
19478a1b82d7SSwapnil Jakhade 	{0x0003, SIERRA_EPI_CTRL_PREG},
19488a1b82d7SSwapnil Jakhade 	{0x803F, SIERRA_SDFILT_H2L_A_PREG},
19498a1b82d7SSwapnil Jakhade 	{0x0004, SIERRA_RXBUFFER_CTLECTRL_PREG},
19508a1b82d7SSwapnil Jakhade 	{0x2010, SIERRA_RXBUFFER_RCDFECTRL_PREG},
19518a1b82d7SSwapnil Jakhade 	{0x4432, SIERRA_RXBUFFER_DFECTRL_PREG}
19528a1b82d7SSwapnil Jakhade };
19538a1b82d7SSwapnil Jakhade 
19548a1b82d7SSwapnil Jakhade static struct cdns_sierra_vals pcie_100_ext_ssc_plllc_cmn_vals = {
19558a1b82d7SSwapnil Jakhade 	.reg_pairs = pcie_100_ext_ssc_plllc_cmn_regs,
19568a1b82d7SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(pcie_100_ext_ssc_plllc_cmn_regs),
19578a1b82d7SSwapnil Jakhade };
19588a1b82d7SSwapnil Jakhade 
19598a1b82d7SSwapnil Jakhade static struct cdns_sierra_vals ml_pcie_100_ext_ssc_ln_vals = {
19608a1b82d7SSwapnil Jakhade 	.reg_pairs = ml_pcie_100_ext_ssc_ln_regs,
19618a1b82d7SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(ml_pcie_100_ext_ssc_ln_regs),
19628a1b82d7SSwapnil Jakhade };
19638a1b82d7SSwapnil Jakhade 
1964e72659b6SSwapnil Jakhade /*
1965e72659b6SSwapnil Jakhade  * TI J721E:
1966e72659b6SSwapnil Jakhade  * refclk100MHz_32b_PCIe_ln_ext_ssc, multilink, using_plllc,
1967e72659b6SSwapnil Jakhade  * cmn_pllcy_anaclk0_1Ghz, xcvr_pllclk_fullrt_500mhz
1968e72659b6SSwapnil Jakhade  */
1969e72659b6SSwapnil Jakhade static const struct cdns_reg_pairs ti_ml_pcie_100_ext_ssc_ln_regs[] = {
1970e72659b6SSwapnil Jakhade 	{0xFC08, SIERRA_DET_STANDEC_A_PREG},
1971e72659b6SSwapnil Jakhade 	{0x001D, SIERRA_PSM_A3IN_TMR_PREG},
1972e72659b6SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_A3_PREG},
1973e72659b6SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_A4_PREG},
1974e72659b6SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_IDLE_PREG},
1975e72659b6SSwapnil Jakhade 	{0x1555, SIERRA_DFE_BIASTRIM_PREG},
1976e72659b6SSwapnil Jakhade 	{0x9703, SIERRA_DRVCTRL_BOOST_PREG},
1977e72659b6SSwapnil Jakhade 	{0x813E, SIERRA_CLKPATHCTRL_TMR_PREG},
1978e72659b6SSwapnil Jakhade 	{0x8047, SIERRA_RX_CREQ_FLTR_A_MODE3_PREG},
1979e72659b6SSwapnil Jakhade 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE2_PREG},
1980e72659b6SSwapnil Jakhade 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG},
1981e72659b6SSwapnil Jakhade 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
1982e72659b6SSwapnil Jakhade 	{0x0002, SIERRA_CREQ_DCBIASATTEN_OVR_PREG},
1983e72659b6SSwapnil Jakhade 	{0x9800, SIERRA_RX_CTLE_CAL_PREG},
1984e72659b6SSwapnil Jakhade 	{0x033C, SIERRA_RX_CTLE_MAINTENANCE_PREG},
1985e72659b6SSwapnil Jakhade 	{0x44CC, SIERRA_CREQ_EQ_OPEN_EYE_THRESH_PREG},
1986e72659b6SSwapnil Jakhade 	{0x5624, SIERRA_DEQ_CONCUR_CTRL2_PREG},
1987e72659b6SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_EPIPWR_CTRL2_PREG},
1988e72659b6SSwapnil Jakhade 	{0x00FF, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG},
1989e72659b6SSwapnil Jakhade 	{0x4C4C, SIERRA_DEQ_ERRCMP_CTRL_PREG},
1990e72659b6SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_OFFSET_CTRL_PREG},
1991e72659b6SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_GAIN_CTRL_PREG},
1992e72659b6SSwapnil Jakhade 	{0x0041, SIERRA_DEQ_GLUT0},
1993e72659b6SSwapnil Jakhade 	{0x0082, SIERRA_DEQ_GLUT1},
1994e72659b6SSwapnil Jakhade 	{0x00C3, SIERRA_DEQ_GLUT2},
1995e72659b6SSwapnil Jakhade 	{0x0145, SIERRA_DEQ_GLUT3},
1996e72659b6SSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT4},
1997e72659b6SSwapnil Jakhade 	{0x09E7, SIERRA_DEQ_ALUT0},
1998e72659b6SSwapnil Jakhade 	{0x09A6, SIERRA_DEQ_ALUT1},
1999e72659b6SSwapnil Jakhade 	{0x0965, SIERRA_DEQ_ALUT2},
2000e72659b6SSwapnil Jakhade 	{0x08E3, SIERRA_DEQ_ALUT3},
2001e72659b6SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP0},
2002e72659b6SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP1},
2003e72659b6SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP2},
2004e72659b6SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP3},
2005e72659b6SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP4},
2006e72659b6SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_PRECUR_PREG},
2007e72659b6SSwapnil Jakhade 	{0x0280, SIERRA_DEQ_POSTCUR_PREG},
2008e72659b6SSwapnil Jakhade 	{0x8F00, SIERRA_DEQ_POSTCUR_DECR_PREG},
2009e72659b6SSwapnil Jakhade 	{0x3C0F, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG},
2010e72659b6SSwapnil Jakhade 	{0x1C0C, SIERRA_DEQ_TAU_CTRL2_PREG},
2011e72659b6SSwapnil Jakhade 	{0x0100, SIERRA_DEQ_TAU_CTRL3_PREG},
2012e72659b6SSwapnil Jakhade 	{0x5E82, SIERRA_DEQ_OPENEYE_CTRL_PREG},
2013e72659b6SSwapnil Jakhade 	{0x002B, SIERRA_CPI_TRIM_PREG},
2014e72659b6SSwapnil Jakhade 	{0x0003, SIERRA_EPI_CTRL_PREG},
2015e72659b6SSwapnil Jakhade 	{0x803F, SIERRA_SDFILT_H2L_A_PREG},
2016e72659b6SSwapnil Jakhade 	{0x0004, SIERRA_RXBUFFER_CTLECTRL_PREG},
2017e72659b6SSwapnil Jakhade 	{0x2010, SIERRA_RXBUFFER_RCDFECTRL_PREG},
2018e72659b6SSwapnil Jakhade 	{0x4432, SIERRA_RXBUFFER_DFECTRL_PREG},
2019e72659b6SSwapnil Jakhade 	{0x0002, SIERRA_TX_RCVDET_OVRD_PREG}
2020e72659b6SSwapnil Jakhade };
2021e72659b6SSwapnil Jakhade 
2022e72659b6SSwapnil Jakhade static struct cdns_sierra_vals ti_ml_pcie_100_ext_ssc_ln_vals = {
2023e72659b6SSwapnil Jakhade 	.reg_pairs = ti_ml_pcie_100_ext_ssc_ln_regs,
2024e72659b6SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(ti_ml_pcie_100_ext_ssc_ln_regs),
2025e72659b6SSwapnil Jakhade };
2026e72659b6SSwapnil Jakhade 
20277a5ad9b4SSwapnil Jakhade /* refclk100MHz_32b_PCIe_cmn_pll_no_ssc */
20287a5ad9b4SSwapnil Jakhade static const struct cdns_reg_pairs cdns_pcie_cmn_regs_no_ssc[] = {
20297a5ad9b4SSwapnil Jakhade 	{0x2105, SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG},
20307a5ad9b4SSwapnil Jakhade 	{0x2105, SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG},
20317a5ad9b4SSwapnil Jakhade 	{0x8A06, SIERRA_CMN_PLLLC_BWCAL_MODE1_PREG},
20327a5ad9b4SSwapnil Jakhade 	{0x8A06, SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG}
20337a5ad9b4SSwapnil Jakhade };
20347a5ad9b4SSwapnil Jakhade 
20357a5ad9b4SSwapnil Jakhade /* refclk100MHz_32b_PCIe_ln_no_ssc */
20367a5ad9b4SSwapnil Jakhade static const struct cdns_reg_pairs cdns_pcie_ln_regs_no_ssc[] = {
20377a5ad9b4SSwapnil Jakhade 	{0xFC08, SIERRA_DET_STANDEC_A_PREG},
20387a5ad9b4SSwapnil Jakhade 	{0x001D, SIERRA_PSM_A3IN_TMR_PREG},
20397a5ad9b4SSwapnil Jakhade 	{0x1555, SIERRA_DFE_BIASTRIM_PREG},
20407a5ad9b4SSwapnil Jakhade 	{0x9703, SIERRA_DRVCTRL_BOOST_PREG},
20417a5ad9b4SSwapnil Jakhade 	{0x8055, SIERRA_RX_CREQ_FLTR_A_MODE3_PREG},
20427a5ad9b4SSwapnil Jakhade 	{0x80BB, SIERRA_RX_CREQ_FLTR_A_MODE2_PREG},
20437a5ad9b4SSwapnil Jakhade 	{0x8351, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG},
20447a5ad9b4SSwapnil Jakhade 	{0x8349, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
20457a5ad9b4SSwapnil Jakhade 	{0x0002, SIERRA_CREQ_DCBIASATTEN_OVR_PREG},
20467a5ad9b4SSwapnil Jakhade 	{0x9800, SIERRA_RX_CTLE_CAL_PREG},
20477a5ad9b4SSwapnil Jakhade 	{0x5624, SIERRA_DEQ_CONCUR_CTRL2_PREG},
20487a5ad9b4SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_EPIPWR_CTRL2_PREG},
20497a5ad9b4SSwapnil Jakhade 	{0x00FF, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG},
20507a5ad9b4SSwapnil Jakhade 	{0x4C4C, SIERRA_DEQ_ERRCMP_CTRL_PREG},
20517a5ad9b4SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_OFFSET_CTRL_PREG},
20527a5ad9b4SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_GAIN_CTRL_PREG},
20537a5ad9b4SSwapnil Jakhade 	{0x0041, SIERRA_DEQ_GLUT0},
20547a5ad9b4SSwapnil Jakhade 	{0x0082, SIERRA_DEQ_GLUT1},
20557a5ad9b4SSwapnil Jakhade 	{0x00C3, SIERRA_DEQ_GLUT2},
20567a5ad9b4SSwapnil Jakhade 	{0x0145, SIERRA_DEQ_GLUT3},
20577a5ad9b4SSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT4},
20587a5ad9b4SSwapnil Jakhade 	{0x09E7, SIERRA_DEQ_ALUT0},
20597a5ad9b4SSwapnil Jakhade 	{0x09A6, SIERRA_DEQ_ALUT1},
20607a5ad9b4SSwapnil Jakhade 	{0x0965, SIERRA_DEQ_ALUT2},
20617a5ad9b4SSwapnil Jakhade 	{0x08E3, SIERRA_DEQ_ALUT3},
20627a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP0},
20637a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP1},
20647a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP2},
20657a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP3},
20667a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP4},
20677a5ad9b4SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_PRECUR_PREG},
20687a5ad9b4SSwapnil Jakhade 	{0x0280, SIERRA_DEQ_POSTCUR_PREG},
20697a5ad9b4SSwapnil Jakhade 	{0x8F00, SIERRA_DEQ_POSTCUR_DECR_PREG},
20707a5ad9b4SSwapnil Jakhade 	{0x3C0F, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG},
20717a5ad9b4SSwapnil Jakhade 	{0x1C0C, SIERRA_DEQ_TAU_CTRL2_PREG},
20727a5ad9b4SSwapnil Jakhade 	{0x0100, SIERRA_DEQ_TAU_CTRL3_PREG},
20737a5ad9b4SSwapnil Jakhade 	{0x5E82, SIERRA_DEQ_OPENEYE_CTRL_PREG},
20747a5ad9b4SSwapnil Jakhade 	{0x002B, SIERRA_CPI_TRIM_PREG},
20757a5ad9b4SSwapnil Jakhade 	{0x0003, SIERRA_EPI_CTRL_PREG},
20767a5ad9b4SSwapnil Jakhade 	{0x803F, SIERRA_SDFILT_H2L_A_PREG},
20777a5ad9b4SSwapnil Jakhade 	{0x0004, SIERRA_RXBUFFER_CTLECTRL_PREG},
20787a5ad9b4SSwapnil Jakhade 	{0x2010, SIERRA_RXBUFFER_RCDFECTRL_PREG},
20797a5ad9b4SSwapnil Jakhade 	{0x4432, SIERRA_RXBUFFER_DFECTRL_PREG}
20807a5ad9b4SSwapnil Jakhade };
20817a5ad9b4SSwapnil Jakhade 
20827a5ad9b4SSwapnil Jakhade static struct cdns_sierra_vals pcie_100_no_ssc_cmn_vals = {
20837a5ad9b4SSwapnil Jakhade 	.reg_pairs = cdns_pcie_cmn_regs_no_ssc,
20847a5ad9b4SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(cdns_pcie_cmn_regs_no_ssc),
20857a5ad9b4SSwapnil Jakhade };
20867a5ad9b4SSwapnil Jakhade 
20877a5ad9b4SSwapnil Jakhade static struct cdns_sierra_vals pcie_100_no_ssc_ln_vals = {
20887a5ad9b4SSwapnil Jakhade 	.reg_pairs = cdns_pcie_ln_regs_no_ssc,
20897a5ad9b4SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(cdns_pcie_ln_regs_no_ssc),
20907a5ad9b4SSwapnil Jakhade };
20917a5ad9b4SSwapnil Jakhade 
20927a5ad9b4SSwapnil Jakhade /* refclk100MHz_32b_PCIe_cmn_pll_int_ssc */
20937a5ad9b4SSwapnil Jakhade static const struct cdns_reg_pairs cdns_pcie_cmn_regs_int_ssc[] = {
20947a5ad9b4SSwapnil Jakhade 	{0x000E, SIERRA_CMN_PLLLC_MODE_PREG},
20957a5ad9b4SSwapnil Jakhade 	{0x4006, SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG},
20967a5ad9b4SSwapnil Jakhade 	{0x4006, SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG},
20977a5ad9b4SSwapnil Jakhade 	{0x0000, SIERRA_CMN_PLLLC_BWCAL_MODE1_PREG},
20987a5ad9b4SSwapnil Jakhade 	{0x0000, SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG},
20997a5ad9b4SSwapnil Jakhade 	{0x0581, SIERRA_CMN_PLLLC_DSMCORR_PREG},
21007a5ad9b4SSwapnil Jakhade 	{0x7F80, SIERRA_CMN_PLLLC_SS_PREG},
21017a5ad9b4SSwapnil Jakhade 	{0x0041, SIERRA_CMN_PLLLC_SS_AMP_STEP_SIZE_PREG},
21027a5ad9b4SSwapnil Jakhade 	{0x0464, SIERRA_CMN_PLLLC_SSTWOPT_PREG},
21037a5ad9b4SSwapnil Jakhade 	{0x0D0D, SIERRA_CMN_PLLLC_SS_TIME_STEPSIZE_MODE_PREG},
21047a5ad9b4SSwapnil Jakhade 	{0x0060, SIERRA_CMN_PLLLC_LOCK_DELAY_CTRL_PREG}
21057a5ad9b4SSwapnil Jakhade };
21067a5ad9b4SSwapnil Jakhade 
21077a5ad9b4SSwapnil Jakhade /* refclk100MHz_32b_PCIe_ln_int_ssc */
21087a5ad9b4SSwapnil Jakhade static const struct cdns_reg_pairs cdns_pcie_ln_regs_int_ssc[] = {
21097a5ad9b4SSwapnil Jakhade 	{0xFC08, SIERRA_DET_STANDEC_A_PREG},
21107a5ad9b4SSwapnil Jakhade 	{0x001D, SIERRA_PSM_A3IN_TMR_PREG},
21117a5ad9b4SSwapnil Jakhade 	{0x1555, SIERRA_DFE_BIASTRIM_PREG},
21127a5ad9b4SSwapnil Jakhade 	{0x9703, SIERRA_DRVCTRL_BOOST_PREG},
21137a5ad9b4SSwapnil Jakhade 	{0x813E, SIERRA_CLKPATHCTRL_TMR_PREG},
21147a5ad9b4SSwapnil Jakhade 	{0x8047, SIERRA_RX_CREQ_FLTR_A_MODE3_PREG},
21157a5ad9b4SSwapnil Jakhade 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE2_PREG},
21167a5ad9b4SSwapnil Jakhade 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG},
21177a5ad9b4SSwapnil Jakhade 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
21187a5ad9b4SSwapnil Jakhade 	{0x0002, SIERRA_CREQ_DCBIASATTEN_OVR_PREG},
21197a5ad9b4SSwapnil Jakhade 	{0x9800, SIERRA_RX_CTLE_CAL_PREG},
21207a5ad9b4SSwapnil Jakhade 	{0x033C, SIERRA_RX_CTLE_MAINTENANCE_PREG},
21217a5ad9b4SSwapnil Jakhade 	{0x44CC, SIERRA_CREQ_EQ_OPEN_EYE_THRESH_PREG},
21227a5ad9b4SSwapnil Jakhade 	{0x5624, SIERRA_DEQ_CONCUR_CTRL2_PREG},
21237a5ad9b4SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_EPIPWR_CTRL2_PREG},
21247a5ad9b4SSwapnil Jakhade 	{0x00FF, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG},
21257a5ad9b4SSwapnil Jakhade 	{0x4C4C, SIERRA_DEQ_ERRCMP_CTRL_PREG},
21267a5ad9b4SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_OFFSET_CTRL_PREG},
21277a5ad9b4SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_GAIN_CTRL_PREG},
21287a5ad9b4SSwapnil Jakhade 	{0x0041, SIERRA_DEQ_GLUT0},
21297a5ad9b4SSwapnil Jakhade 	{0x0082, SIERRA_DEQ_GLUT1},
21307a5ad9b4SSwapnil Jakhade 	{0x00C3, SIERRA_DEQ_GLUT2},
21317a5ad9b4SSwapnil Jakhade 	{0x0145, SIERRA_DEQ_GLUT3},
21327a5ad9b4SSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT4},
21337a5ad9b4SSwapnil Jakhade 	{0x09E7, SIERRA_DEQ_ALUT0},
21347a5ad9b4SSwapnil Jakhade 	{0x09A6, SIERRA_DEQ_ALUT1},
21357a5ad9b4SSwapnil Jakhade 	{0x0965, SIERRA_DEQ_ALUT2},
21367a5ad9b4SSwapnil Jakhade 	{0x08E3, SIERRA_DEQ_ALUT3},
21377a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP0},
21387a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP1},
21397a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP2},
21407a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP3},
21417a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP4},
21427a5ad9b4SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_PRECUR_PREG},
21437a5ad9b4SSwapnil Jakhade 	{0x0280, SIERRA_DEQ_POSTCUR_PREG},
21447a5ad9b4SSwapnil Jakhade 	{0x8F00, SIERRA_DEQ_POSTCUR_DECR_PREG},
21457a5ad9b4SSwapnil Jakhade 	{0x3C0F, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG},
21467a5ad9b4SSwapnil Jakhade 	{0x1C0C, SIERRA_DEQ_TAU_CTRL2_PREG},
21477a5ad9b4SSwapnil Jakhade 	{0x0100, SIERRA_DEQ_TAU_CTRL3_PREG},
21487a5ad9b4SSwapnil Jakhade 	{0x5E82, SIERRA_DEQ_OPENEYE_CTRL_PREG},
21497a5ad9b4SSwapnil Jakhade 	{0x002B, SIERRA_CPI_TRIM_PREG},
21507a5ad9b4SSwapnil Jakhade 	{0x0003, SIERRA_EPI_CTRL_PREG},
21517a5ad9b4SSwapnil Jakhade 	{0x803F, SIERRA_SDFILT_H2L_A_PREG},
21527a5ad9b4SSwapnil Jakhade 	{0x0004, SIERRA_RXBUFFER_CTLECTRL_PREG},
21537a5ad9b4SSwapnil Jakhade 	{0x2010, SIERRA_RXBUFFER_RCDFECTRL_PREG},
21547a5ad9b4SSwapnil Jakhade 	{0x4432, SIERRA_RXBUFFER_DFECTRL_PREG}
21557a5ad9b4SSwapnil Jakhade };
21567a5ad9b4SSwapnil Jakhade 
21577a5ad9b4SSwapnil Jakhade static struct cdns_sierra_vals pcie_100_int_ssc_cmn_vals = {
21587a5ad9b4SSwapnil Jakhade 	.reg_pairs = cdns_pcie_cmn_regs_int_ssc,
21597a5ad9b4SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(cdns_pcie_cmn_regs_int_ssc),
21607a5ad9b4SSwapnil Jakhade };
21617a5ad9b4SSwapnil Jakhade 
21627a5ad9b4SSwapnil Jakhade static struct cdns_sierra_vals pcie_100_int_ssc_ln_vals = {
21637a5ad9b4SSwapnil Jakhade 	.reg_pairs = cdns_pcie_ln_regs_int_ssc,
21647a5ad9b4SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(cdns_pcie_ln_regs_int_ssc),
21657a5ad9b4SSwapnil Jakhade };
21667a5ad9b4SSwapnil Jakhade 
2167871002d7SAnil Varughese /* refclk100MHz_32b_PCIe_cmn_pll_ext_ssc */
21683cfb0e8eSRikard Falkeborn static const struct cdns_reg_pairs cdns_pcie_cmn_regs_ext_ssc[] = {
2169871002d7SAnil Varughese 	{0x2106, SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG},
2170871002d7SAnil Varughese 	{0x2106, SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG},
2171871002d7SAnil Varughese 	{0x8A06, SIERRA_CMN_PLLLC_BWCAL_MODE1_PREG},
2172871002d7SAnil Varughese 	{0x8A06, SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG},
2173871002d7SAnil Varughese 	{0x1B1B, SIERRA_CMN_PLLLC_SS_TIME_STEPSIZE_MODE_PREG}
2174871002d7SAnil Varughese };
2175871002d7SAnil Varughese 
2176871002d7SAnil Varughese /* refclk100MHz_32b_PCIe_ln_ext_ssc */
21773cfb0e8eSRikard Falkeborn static const struct cdns_reg_pairs cdns_pcie_ln_regs_ext_ssc[] = {
21787a5ad9b4SSwapnil Jakhade 	{0xFC08, SIERRA_DET_STANDEC_A_PREG},
21797a5ad9b4SSwapnil Jakhade 	{0x001D, SIERRA_PSM_A3IN_TMR_PREG},
21807a5ad9b4SSwapnil Jakhade 	{0x1555, SIERRA_DFE_BIASTRIM_PREG},
21817a5ad9b4SSwapnil Jakhade 	{0x9703, SIERRA_DRVCTRL_BOOST_PREG},
2182871002d7SAnil Varughese 	{0x813E, SIERRA_CLKPATHCTRL_TMR_PREG},
2183871002d7SAnil Varughese 	{0x8047, SIERRA_RX_CREQ_FLTR_A_MODE3_PREG},
2184871002d7SAnil Varughese 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE2_PREG},
2185871002d7SAnil Varughese 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG},
2186871002d7SAnil Varughese 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
21877a5ad9b4SSwapnil Jakhade 	{0x0002, SIERRA_CREQ_DCBIASATTEN_OVR_PREG},
21887a5ad9b4SSwapnil Jakhade 	{0x9800, SIERRA_RX_CTLE_CAL_PREG},
2189871002d7SAnil Varughese 	{0x033C, SIERRA_RX_CTLE_MAINTENANCE_PREG},
21907a5ad9b4SSwapnil Jakhade 	{0x44CC, SIERRA_CREQ_EQ_OPEN_EYE_THRESH_PREG},
21917a5ad9b4SSwapnil Jakhade 	{0x5624, SIERRA_DEQ_CONCUR_CTRL2_PREG},
21927a5ad9b4SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_EPIPWR_CTRL2_PREG},
21937a5ad9b4SSwapnil Jakhade 	{0x00FF, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG},
21947a5ad9b4SSwapnil Jakhade 	{0x4C4C, SIERRA_DEQ_ERRCMP_CTRL_PREG},
21957a5ad9b4SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_OFFSET_CTRL_PREG},
21967a5ad9b4SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_GAIN_CTRL_PREG},
21977a5ad9b4SSwapnil Jakhade 	{0x0041, SIERRA_DEQ_GLUT0},
21987a5ad9b4SSwapnil Jakhade 	{0x0082, SIERRA_DEQ_GLUT1},
21997a5ad9b4SSwapnil Jakhade 	{0x00C3, SIERRA_DEQ_GLUT2},
22007a5ad9b4SSwapnil Jakhade 	{0x0145, SIERRA_DEQ_GLUT3},
22017a5ad9b4SSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT4},
22027a5ad9b4SSwapnil Jakhade 	{0x09E7, SIERRA_DEQ_ALUT0},
22037a5ad9b4SSwapnil Jakhade 	{0x09A6, SIERRA_DEQ_ALUT1},
22047a5ad9b4SSwapnil Jakhade 	{0x0965, SIERRA_DEQ_ALUT2},
22057a5ad9b4SSwapnil Jakhade 	{0x08E3, SIERRA_DEQ_ALUT3},
22067a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP0},
22077a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP1},
22087a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP2},
22097a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP3},
22107a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP4},
22117a5ad9b4SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_PRECUR_PREG},
22127a5ad9b4SSwapnil Jakhade 	{0x0280, SIERRA_DEQ_POSTCUR_PREG},
22137a5ad9b4SSwapnil Jakhade 	{0x8F00, SIERRA_DEQ_POSTCUR_DECR_PREG},
22147a5ad9b4SSwapnil Jakhade 	{0x3C0F, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG},
22157a5ad9b4SSwapnil Jakhade 	{0x1C0C, SIERRA_DEQ_TAU_CTRL2_PREG},
22167a5ad9b4SSwapnil Jakhade 	{0x0100, SIERRA_DEQ_TAU_CTRL3_PREG},
22177a5ad9b4SSwapnil Jakhade 	{0x5E82, SIERRA_DEQ_OPENEYE_CTRL_PREG},
22187a5ad9b4SSwapnil Jakhade 	{0x002B, SIERRA_CPI_TRIM_PREG},
22197a5ad9b4SSwapnil Jakhade 	{0x0003, SIERRA_EPI_CTRL_PREG},
22207a5ad9b4SSwapnil Jakhade 	{0x803F, SIERRA_SDFILT_H2L_A_PREG},
22217a5ad9b4SSwapnil Jakhade 	{0x0004, SIERRA_RXBUFFER_CTLECTRL_PREG},
22227a5ad9b4SSwapnil Jakhade 	{0x2010, SIERRA_RXBUFFER_RCDFECTRL_PREG},
22237a5ad9b4SSwapnil Jakhade 	{0x4432, SIERRA_RXBUFFER_DFECTRL_PREG}
2224871002d7SAnil Varughese };
2225871002d7SAnil Varughese 
2226078e9e92SSwapnil Jakhade static struct cdns_sierra_vals pcie_100_ext_ssc_cmn_vals = {
2227078e9e92SSwapnil Jakhade 	.reg_pairs = cdns_pcie_cmn_regs_ext_ssc,
2228078e9e92SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(cdns_pcie_cmn_regs_ext_ssc),
2229078e9e92SSwapnil Jakhade };
2230078e9e92SSwapnil Jakhade 
2231078e9e92SSwapnil Jakhade static struct cdns_sierra_vals pcie_100_ext_ssc_ln_vals = {
2232078e9e92SSwapnil Jakhade 	.reg_pairs = cdns_pcie_ln_regs_ext_ssc,
2233078e9e92SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(cdns_pcie_ln_regs_ext_ssc),
2234078e9e92SSwapnil Jakhade };
2235078e9e92SSwapnil Jakhade 
2236871002d7SAnil Varughese /* refclk100MHz_20b_USB_cmn_pll_ext_ssc */
22373cfb0e8eSRikard Falkeborn static const struct cdns_reg_pairs cdns_usb_cmn_regs_ext_ssc[] = {
2238871002d7SAnil Varughese 	{0x2085, SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG},
2239871002d7SAnil Varughese 	{0x2085, SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG},
2240871002d7SAnil Varughese 	{0x0000, SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG},
2241871002d7SAnil Varughese 	{0x0000, SIERRA_CMN_PLLLC_SS_TIME_STEPSIZE_MODE_PREG}
2242871002d7SAnil Varughese };
2243871002d7SAnil Varughese 
2244871002d7SAnil Varughese /* refclk100MHz_20b_USB_ln_ext_ssc */
22453cfb0e8eSRikard Falkeborn static const struct cdns_reg_pairs cdns_usb_ln_regs_ext_ssc[] = {
2246aead5fd6SKishon Vijay Abraham I 	{0xFE0A, SIERRA_DET_STANDEC_A_PREG},
2247aead5fd6SKishon Vijay Abraham I 	{0x000F, SIERRA_DET_STANDEC_B_PREG},
22482bcf14caSSanket Parmar 	{0x55A5, SIERRA_DET_STANDEC_C_PREG},
2249871002d7SAnil Varughese 	{0x69ad, SIERRA_DET_STANDEC_D_PREG},
2250aead5fd6SKishon Vijay Abraham I 	{0x0241, SIERRA_DET_STANDEC_E_PREG},
22512bcf14caSSanket Parmar 	{0x0110, SIERRA_PSM_LANECAL_DLY_A1_RESETS_PREG},
2252871002d7SAnil Varughese 	{0x0014, SIERRA_PSM_A0IN_TMR_PREG},
2253aead5fd6SKishon Vijay Abraham I 	{0xCF00, SIERRA_PSM_DIAG_PREG},
2254aead5fd6SKishon Vijay Abraham I 	{0x001F, SIERRA_PSC_TX_A0_PREG},
2255aead5fd6SKishon Vijay Abraham I 	{0x0007, SIERRA_PSC_TX_A1_PREG},
2256aead5fd6SKishon Vijay Abraham I 	{0x0003, SIERRA_PSC_TX_A2_PREG},
2257aead5fd6SKishon Vijay Abraham I 	{0x0003, SIERRA_PSC_TX_A3_PREG},
2258aead5fd6SKishon Vijay Abraham I 	{0x0FFF, SIERRA_PSC_RX_A0_PREG},
22592bcf14caSSanket Parmar 	{0x0003, SIERRA_PSC_RX_A1_PREG},
2260aead5fd6SKishon Vijay Abraham I 	{0x0003, SIERRA_PSC_RX_A2_PREG},
2261aead5fd6SKishon Vijay Abraham I 	{0x0001, SIERRA_PSC_RX_A3_PREG},
2262aead5fd6SKishon Vijay Abraham I 	{0x0001, SIERRA_PLLCTRL_SUBRATE_PREG},
2263aead5fd6SKishon Vijay Abraham I 	{0x0406, SIERRA_PLLCTRL_GEN_D_PREG},
2264871002d7SAnil Varughese 	{0x5233, SIERRA_PLLCTRL_CPGAIN_MODE_PREG},
2265871002d7SAnil Varughese 	{0x00CA, SIERRA_CLKPATH_BIASTRIM_PREG},
2266871002d7SAnil Varughese 	{0x2512, SIERRA_DFE_BIASTRIM_PREG},
2267aead5fd6SKishon Vijay Abraham I 	{0x0000, SIERRA_DRVCTRL_ATTEN_PREG},
22682bcf14caSSanket Parmar 	{0x823E, SIERRA_CLKPATHCTRL_TMR_PREG},
22692bcf14caSSanket Parmar 	{0x078F, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG},
22702bcf14caSSanket Parmar 	{0x078F, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
2271aead5fd6SKishon Vijay Abraham I 	{0x7B3C, SIERRA_CREQ_CCLKDET_MODE01_PREG},
22722bcf14caSSanket Parmar 	{0x023C, SIERRA_RX_CTLE_MAINTENANCE_PREG},
2273aead5fd6SKishon Vijay Abraham I 	{0x3232, SIERRA_CREQ_FSMCLK_SEL_PREG},
2274871002d7SAnil Varughese 	{0x0000, SIERRA_CREQ_EQ_CTRL_PREG},
22752bcf14caSSanket Parmar 	{0x0000, SIERRA_CREQ_SPARE_PREG},
2276871002d7SAnil Varughese 	{0xCC44, SIERRA_CREQ_EQ_OPEN_EYE_THRESH_PREG},
22772bcf14caSSanket Parmar 	{0x8452, SIERRA_CTLELUT_CTRL_PREG},
22782bcf14caSSanket Parmar 	{0x4121, SIERRA_DFE_ECMP_RATESEL_PREG},
22792bcf14caSSanket Parmar 	{0x4121, SIERRA_DFE_SMP_RATESEL_PREG},
22802bcf14caSSanket Parmar 	{0x0003, SIERRA_DEQ_PHALIGN_CTRL},
2281871002d7SAnil Varughese 	{0x3200, SIERRA_DEQ_CONCUR_CTRL1_PREG},
2282871002d7SAnil Varughese 	{0x5064, SIERRA_DEQ_CONCUR_CTRL2_PREG},
2283871002d7SAnil Varughese 	{0x0030, SIERRA_DEQ_EPIPWR_CTRL2_PREG},
2284871002d7SAnil Varughese 	{0x0048, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG},
2285871002d7SAnil Varughese 	{0x5A5A, SIERRA_DEQ_ERRCMP_CTRL_PREG},
2286871002d7SAnil Varughese 	{0x02F5, SIERRA_DEQ_OFFSET_CTRL_PREG},
2287871002d7SAnil Varughese 	{0x02F5, SIERRA_DEQ_GAIN_CTRL_PREG},
22882bcf14caSSanket Parmar 	{0x9999, SIERRA_DEQ_VGATUNE_CTRL_PREG},
2289871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT0},
2290871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT1},
2291871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT2},
2292871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT3},
2293871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT4},
2294871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT5},
2295871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT6},
2296871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT7},
2297871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT8},
2298871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT9},
2299871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT10},
2300871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT11},
2301871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT12},
2302871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT13},
2303871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT14},
2304871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT15},
2305871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT16},
2306871002d7SAnil Varughese 	{0x0BAE, SIERRA_DEQ_ALUT0},
2307871002d7SAnil Varughese 	{0x0AEB, SIERRA_DEQ_ALUT1},
2308871002d7SAnil Varughese 	{0x0A28, SIERRA_DEQ_ALUT2},
2309871002d7SAnil Varughese 	{0x0965, SIERRA_DEQ_ALUT3},
2310871002d7SAnil Varughese 	{0x08A2, SIERRA_DEQ_ALUT4},
2311871002d7SAnil Varughese 	{0x07DF, SIERRA_DEQ_ALUT5},
2312871002d7SAnil Varughese 	{0x071C, SIERRA_DEQ_ALUT6},
2313871002d7SAnil Varughese 	{0x0659, SIERRA_DEQ_ALUT7},
2314871002d7SAnil Varughese 	{0x0596, SIERRA_DEQ_ALUT8},
2315871002d7SAnil Varughese 	{0x0514, SIERRA_DEQ_ALUT9},
2316871002d7SAnil Varughese 	{0x0492, SIERRA_DEQ_ALUT10},
2317871002d7SAnil Varughese 	{0x0410, SIERRA_DEQ_ALUT11},
2318871002d7SAnil Varughese 	{0x038E, SIERRA_DEQ_ALUT12},
2319871002d7SAnil Varughese 	{0x030C, SIERRA_DEQ_ALUT13},
2320871002d7SAnil Varughese 	{0x03F4, SIERRA_DEQ_DFETAP_CTRL_PREG},
2321871002d7SAnil Varughese 	{0x0001, SIERRA_DFE_EN_1010_IGNORE_PREG},
2322871002d7SAnil Varughese 	{0x3C01, SIERRA_DEQ_TAU_CTRL1_FAST_MAINT_PREG},
2323871002d7SAnil Varughese 	{0x3C40, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG},
2324871002d7SAnil Varughese 	{0x1C08, SIERRA_DEQ_TAU_CTRL2_PREG},
2325871002d7SAnil Varughese 	{0x0033, SIERRA_DEQ_PICTRL_PREG},
2326871002d7SAnil Varughese 	{0x0400, SIERRA_CPICAL_TMRVAL_MODE1_PREG},
2327871002d7SAnil Varughese 	{0x0330, SIERRA_CPICAL_TMRVAL_MODE0_PREG},
2328871002d7SAnil Varughese 	{0x01FF, SIERRA_CPICAL_PICNT_MODE1_PREG},
2329aead5fd6SKishon Vijay Abraham I 	{0x0009, SIERRA_CPI_OUTBUF_RATESEL_PREG},
2330871002d7SAnil Varughese 	{0x3232, SIERRA_CPICAL_RES_STARTCODE_MODE23_PREG},
2331871002d7SAnil Varughese 	{0x0005, SIERRA_LFPSDET_SUPPORT_PREG},
2332aead5fd6SKishon Vijay Abraham I 	{0x000F, SIERRA_LFPSFILT_NS_PREG},
2333aead5fd6SKishon Vijay Abraham I 	{0x0009, SIERRA_LFPSFILT_RD_PREG},
2334aead5fd6SKishon Vijay Abraham I 	{0x0001, SIERRA_LFPSFILT_MP_PREG},
23352bcf14caSSanket Parmar 	{0x6013, SIERRA_SIGDET_SUPPORT_PREG},
2336aead5fd6SKishon Vijay Abraham I 	{0x8013, SIERRA_SDFILT_H2L_A_PREG},
2337871002d7SAnil Varughese 	{0x8009, SIERRA_SDFILT_L2H_PREG},
2338871002d7SAnil Varughese 	{0x0024, SIERRA_RXBUFFER_CTLECTRL_PREG},
2339871002d7SAnil Varughese 	{0x0020, SIERRA_RXBUFFER_RCDFECTRL_PREG},
2340871002d7SAnil Varughese 	{0x4243, SIERRA_RXBUFFER_DFECTRL_PREG}
234144d30d62SAlan Douglas };
234244d30d62SAlan Douglas 
2343078e9e92SSwapnil Jakhade static struct cdns_sierra_vals usb_100_ext_ssc_cmn_vals = {
2344078e9e92SSwapnil Jakhade 	.reg_pairs = cdns_usb_cmn_regs_ext_ssc,
2345078e9e92SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(cdns_usb_cmn_regs_ext_ssc),
2346078e9e92SSwapnil Jakhade };
2347078e9e92SSwapnil Jakhade 
2348078e9e92SSwapnil Jakhade static struct cdns_sierra_vals usb_100_ext_ssc_ln_vals = {
2349078e9e92SSwapnil Jakhade 	.reg_pairs = cdns_usb_ln_regs_ext_ssc,
2350078e9e92SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(cdns_usb_ln_regs_ext_ssc),
2351078e9e92SSwapnil Jakhade };
2352078e9e92SSwapnil Jakhade 
235344d30d62SAlan Douglas static const struct cdns_sierra_data cdns_map_sierra = {
2354078e9e92SSwapnil Jakhade 	.id_value = SIERRA_MACRO_ID,
2355078e9e92SSwapnil Jakhade 	.block_offset_shift = 0x2,
2356078e9e92SSwapnil Jakhade 	.reg_offset_shift = 0x2,
2357fa105172SSwapnil Jakhade 	.pcs_cmn_vals = {
2358fa105172SSwapnil Jakhade 		[TYPE_PCIE] = {
2359fa105172SSwapnil Jakhade 			[TYPE_NONE] = {
23607a5ad9b4SSwapnil Jakhade 				[NO_SSC] = &pcie_phy_pcs_cmn_vals,
2361fa105172SSwapnil Jakhade 				[EXTERNAL_SSC] = &pcie_phy_pcs_cmn_vals,
23627a5ad9b4SSwapnil Jakhade 				[INTERNAL_SSC] = &pcie_phy_pcs_cmn_vals,
2363fa105172SSwapnil Jakhade 			},
23648a1b82d7SSwapnil Jakhade 			[TYPE_QSGMII] = {
23658a1b82d7SSwapnil Jakhade 				[NO_SSC] = &pcie_phy_pcs_cmn_vals,
23668a1b82d7SSwapnil Jakhade 				[EXTERNAL_SSC] = &pcie_phy_pcs_cmn_vals,
23678a1b82d7SSwapnil Jakhade 				[INTERNAL_SSC] = &pcie_phy_pcs_cmn_vals,
23688a1b82d7SSwapnil Jakhade 			},
2369fa105172SSwapnil Jakhade 		},
2370fa105172SSwapnil Jakhade 	},
2371078e9e92SSwapnil Jakhade 	.pma_cmn_vals = {
2372078e9e92SSwapnil Jakhade 		[TYPE_PCIE] = {
2373078e9e92SSwapnil Jakhade 			[TYPE_NONE] = {
23747a5ad9b4SSwapnil Jakhade 				[NO_SSC] = &pcie_100_no_ssc_cmn_vals,
2375078e9e92SSwapnil Jakhade 				[EXTERNAL_SSC] = &pcie_100_ext_ssc_cmn_vals,
23767a5ad9b4SSwapnil Jakhade 				[INTERNAL_SSC] = &pcie_100_int_ssc_cmn_vals,
2377078e9e92SSwapnil Jakhade 			},
23788a1b82d7SSwapnil Jakhade 			[TYPE_QSGMII] = {
23798a1b82d7SSwapnil Jakhade 				[NO_SSC] = &pcie_100_no_ssc_plllc_cmn_vals,
23808a1b82d7SSwapnil Jakhade 				[EXTERNAL_SSC] = &pcie_100_ext_ssc_plllc_cmn_vals,
23818a1b82d7SSwapnil Jakhade 				[INTERNAL_SSC] = &pcie_100_int_ssc_plllc_cmn_vals,
23828a1b82d7SSwapnil Jakhade 			},
2383078e9e92SSwapnil Jakhade 		},
2384078e9e92SSwapnil Jakhade 		[TYPE_USB] = {
2385078e9e92SSwapnil Jakhade 			[TYPE_NONE] = {
2386078e9e92SSwapnil Jakhade 				[EXTERNAL_SSC] = &usb_100_ext_ssc_cmn_vals,
2387078e9e92SSwapnil Jakhade 			},
2388078e9e92SSwapnil Jakhade 		},
23898a1b82d7SSwapnil Jakhade 		[TYPE_QSGMII] = {
23908a1b82d7SSwapnil Jakhade 			[TYPE_PCIE] = {
23918a1b82d7SSwapnil Jakhade 				[NO_SSC] = &qsgmii_100_no_ssc_plllc1_cmn_vals,
23928a1b82d7SSwapnil Jakhade 				[EXTERNAL_SSC] = &qsgmii_100_no_ssc_plllc1_cmn_vals,
23938a1b82d7SSwapnil Jakhade 				[INTERNAL_SSC] = &qsgmii_100_no_ssc_plllc1_cmn_vals,
23948a1b82d7SSwapnil Jakhade 			},
23958a1b82d7SSwapnil Jakhade 		},
2396078e9e92SSwapnil Jakhade 	},
2397078e9e92SSwapnil Jakhade 	.pma_ln_vals = {
2398078e9e92SSwapnil Jakhade 		[TYPE_PCIE] = {
2399078e9e92SSwapnil Jakhade 			[TYPE_NONE] = {
24007a5ad9b4SSwapnil Jakhade 				[NO_SSC] = &pcie_100_no_ssc_ln_vals,
2401078e9e92SSwapnil Jakhade 				[EXTERNAL_SSC] = &pcie_100_ext_ssc_ln_vals,
24027a5ad9b4SSwapnil Jakhade 				[INTERNAL_SSC] = &pcie_100_int_ssc_ln_vals,
2403078e9e92SSwapnil Jakhade 			},
24048a1b82d7SSwapnil Jakhade 			[TYPE_QSGMII] = {
24058a1b82d7SSwapnil Jakhade 				[NO_SSC] = &ml_pcie_100_no_ssc_ln_vals,
24068a1b82d7SSwapnil Jakhade 				[EXTERNAL_SSC] = &ml_pcie_100_ext_ssc_ln_vals,
24078a1b82d7SSwapnil Jakhade 				[INTERNAL_SSC] = &ml_pcie_100_int_ssc_ln_vals,
24088a1b82d7SSwapnil Jakhade 			},
2409078e9e92SSwapnil Jakhade 		},
2410078e9e92SSwapnil Jakhade 		[TYPE_USB] = {
2411078e9e92SSwapnil Jakhade 			[TYPE_NONE] = {
2412078e9e92SSwapnil Jakhade 				[EXTERNAL_SSC] = &usb_100_ext_ssc_ln_vals,
2413078e9e92SSwapnil Jakhade 			},
2414078e9e92SSwapnil Jakhade 		},
24158a1b82d7SSwapnil Jakhade 		[TYPE_QSGMII] = {
24168a1b82d7SSwapnil Jakhade 			[TYPE_PCIE] = {
24178a1b82d7SSwapnil Jakhade 				[NO_SSC] = &qsgmii_100_no_ssc_plllc1_ln_vals,
24188a1b82d7SSwapnil Jakhade 				[EXTERNAL_SSC] = &qsgmii_100_no_ssc_plllc1_ln_vals,
24198a1b82d7SSwapnil Jakhade 				[INTERNAL_SSC] = &qsgmii_100_no_ssc_plllc1_ln_vals,
24208a1b82d7SSwapnil Jakhade 			},
24218a1b82d7SSwapnil Jakhade 		},
2422078e9e92SSwapnil Jakhade 	},
242344d30d62SAlan Douglas };
242444d30d62SAlan Douglas 
2425367da978SKishon Vijay Abraham I static const struct cdns_sierra_data cdns_ti_map_sierra = {
2426078e9e92SSwapnil Jakhade 	.id_value = SIERRA_MACRO_ID,
2427078e9e92SSwapnil Jakhade 	.block_offset_shift = 0x0,
2428078e9e92SSwapnil Jakhade 	.reg_offset_shift = 0x1,
2429fa105172SSwapnil Jakhade 	.pcs_cmn_vals = {
2430fa105172SSwapnil Jakhade 		[TYPE_PCIE] = {
2431fa105172SSwapnil Jakhade 			[TYPE_NONE] = {
24327a5ad9b4SSwapnil Jakhade 				[NO_SSC] = &pcie_phy_pcs_cmn_vals,
2433fa105172SSwapnil Jakhade 				[EXTERNAL_SSC] = &pcie_phy_pcs_cmn_vals,
24347a5ad9b4SSwapnil Jakhade 				[INTERNAL_SSC] = &pcie_phy_pcs_cmn_vals,
2435fa105172SSwapnil Jakhade 			},
24368a1b82d7SSwapnil Jakhade 			[TYPE_QSGMII] = {
24378a1b82d7SSwapnil Jakhade 				[NO_SSC] = &pcie_phy_pcs_cmn_vals,
24388a1b82d7SSwapnil Jakhade 				[EXTERNAL_SSC] = &pcie_phy_pcs_cmn_vals,
24398a1b82d7SSwapnil Jakhade 				[INTERNAL_SSC] = &pcie_phy_pcs_cmn_vals,
24408a1b82d7SSwapnil Jakhade 			},
24418a1b82d7SSwapnil Jakhade 		},
24428a1b82d7SSwapnil Jakhade 	},
24438a1b82d7SSwapnil Jakhade 	.phy_pma_ln_vals = {
24448a1b82d7SSwapnil Jakhade 		[TYPE_QSGMII] = {
24458a1b82d7SSwapnil Jakhade 			[TYPE_PCIE] = {
24468a1b82d7SSwapnil Jakhade 				[NO_SSC] = &qsgmii_phy_pma_ln_vals,
24478a1b82d7SSwapnil Jakhade 				[EXTERNAL_SSC] = &qsgmii_phy_pma_ln_vals,
24488a1b82d7SSwapnil Jakhade 				[INTERNAL_SSC] = &qsgmii_phy_pma_ln_vals,
24498a1b82d7SSwapnil Jakhade 			},
2450fa105172SSwapnil Jakhade 		},
2451fa105172SSwapnil Jakhade 	},
2452078e9e92SSwapnil Jakhade 	.pma_cmn_vals = {
2453078e9e92SSwapnil Jakhade 		[TYPE_PCIE] = {
2454078e9e92SSwapnil Jakhade 			[TYPE_NONE] = {
24557a5ad9b4SSwapnil Jakhade 				[NO_SSC] = &pcie_100_no_ssc_cmn_vals,
2456078e9e92SSwapnil Jakhade 				[EXTERNAL_SSC] = &pcie_100_ext_ssc_cmn_vals,
24577a5ad9b4SSwapnil Jakhade 				[INTERNAL_SSC] = &pcie_100_int_ssc_cmn_vals,
2458078e9e92SSwapnil Jakhade 			},
24598a1b82d7SSwapnil Jakhade 			[TYPE_QSGMII] = {
24608a1b82d7SSwapnil Jakhade 				[NO_SSC] = &pcie_100_no_ssc_plllc_cmn_vals,
24618a1b82d7SSwapnil Jakhade 				[EXTERNAL_SSC] = &pcie_100_ext_ssc_plllc_cmn_vals,
24628a1b82d7SSwapnil Jakhade 				[INTERNAL_SSC] = &pcie_100_int_ssc_plllc_cmn_vals,
24638a1b82d7SSwapnil Jakhade 			},
2464078e9e92SSwapnil Jakhade 		},
2465078e9e92SSwapnil Jakhade 		[TYPE_USB] = {
2466078e9e92SSwapnil Jakhade 			[TYPE_NONE] = {
2467078e9e92SSwapnil Jakhade 				[EXTERNAL_SSC] = &usb_100_ext_ssc_cmn_vals,
2468078e9e92SSwapnil Jakhade 			},
2469078e9e92SSwapnil Jakhade 		},
24708a1b82d7SSwapnil Jakhade 		[TYPE_QSGMII] = {
24718a1b82d7SSwapnil Jakhade 			[TYPE_PCIE] = {
24728a1b82d7SSwapnil Jakhade 				[NO_SSC] = &qsgmii_100_no_ssc_plllc1_cmn_vals,
24738a1b82d7SSwapnil Jakhade 				[EXTERNAL_SSC] = &qsgmii_100_no_ssc_plllc1_cmn_vals,
24748a1b82d7SSwapnil Jakhade 				[INTERNAL_SSC] = &qsgmii_100_no_ssc_plllc1_cmn_vals,
24758a1b82d7SSwapnil Jakhade 			},
24768a1b82d7SSwapnil Jakhade 		},
2477078e9e92SSwapnil Jakhade 	},
2478078e9e92SSwapnil Jakhade 	.pma_ln_vals = {
2479078e9e92SSwapnil Jakhade 		[TYPE_PCIE] = {
2480078e9e92SSwapnil Jakhade 			[TYPE_NONE] = {
24817a5ad9b4SSwapnil Jakhade 				[NO_SSC] = &pcie_100_no_ssc_ln_vals,
2482078e9e92SSwapnil Jakhade 				[EXTERNAL_SSC] = &pcie_100_ext_ssc_ln_vals,
24837a5ad9b4SSwapnil Jakhade 				[INTERNAL_SSC] = &pcie_100_int_ssc_ln_vals,
2484078e9e92SSwapnil Jakhade 			},
24858a1b82d7SSwapnil Jakhade 			[TYPE_QSGMII] = {
2486e72659b6SSwapnil Jakhade 				[NO_SSC] = &ti_ml_pcie_100_no_ssc_ln_vals,
2487e72659b6SSwapnil Jakhade 				[EXTERNAL_SSC] = &ti_ml_pcie_100_ext_ssc_ln_vals,
2488e72659b6SSwapnil Jakhade 				[INTERNAL_SSC] = &ti_ml_pcie_100_int_ssc_ln_vals,
24898a1b82d7SSwapnil Jakhade 			},
2490078e9e92SSwapnil Jakhade 		},
2491078e9e92SSwapnil Jakhade 		[TYPE_USB] = {
2492078e9e92SSwapnil Jakhade 			[TYPE_NONE] = {
2493078e9e92SSwapnil Jakhade 				[EXTERNAL_SSC] = &usb_100_ext_ssc_ln_vals,
2494078e9e92SSwapnil Jakhade 			},
2495078e9e92SSwapnil Jakhade 		},
24968a1b82d7SSwapnil Jakhade 		[TYPE_QSGMII] = {
24978a1b82d7SSwapnil Jakhade 			[TYPE_PCIE] = {
24988a1b82d7SSwapnil Jakhade 				[NO_SSC] = &qsgmii_100_no_ssc_plllc1_ln_vals,
24998a1b82d7SSwapnil Jakhade 				[EXTERNAL_SSC] = &qsgmii_100_no_ssc_plllc1_ln_vals,
25008a1b82d7SSwapnil Jakhade 				[INTERNAL_SSC] = &qsgmii_100_no_ssc_plllc1_ln_vals,
25018a1b82d7SSwapnil Jakhade 			},
25028a1b82d7SSwapnil Jakhade 		},
2503078e9e92SSwapnil Jakhade 	},
2504367da978SKishon Vijay Abraham I };
2505367da978SKishon Vijay Abraham I 
250644d30d62SAlan Douglas static const struct of_device_id cdns_sierra_id_table[] = {
250744d30d62SAlan Douglas 	{
250844d30d62SAlan Douglas 		.compatible = "cdns,sierra-phy-t0",
250944d30d62SAlan Douglas 		.data = &cdns_map_sierra,
251044d30d62SAlan Douglas 	},
2511367da978SKishon Vijay Abraham I 	{
2512367da978SKishon Vijay Abraham I 		.compatible = "ti,sierra-phy-t0",
2513367da978SKishon Vijay Abraham I 		.data = &cdns_ti_map_sierra,
2514367da978SKishon Vijay Abraham I 	},
251544d30d62SAlan Douglas 	{}
251644d30d62SAlan Douglas };
251744d30d62SAlan Douglas MODULE_DEVICE_TABLE(of, cdns_sierra_id_table);
251844d30d62SAlan Douglas 
251944d30d62SAlan Douglas static struct platform_driver cdns_sierra_driver = {
252044d30d62SAlan Douglas 	.probe		= cdns_sierra_phy_probe,
2521*e9ddb1adSUwe Kleine-König 	.remove_new	= cdns_sierra_phy_remove,
252244d30d62SAlan Douglas 	.driver		= {
252344d30d62SAlan Douglas 		.name	= "cdns-sierra-phy",
252444d30d62SAlan Douglas 		.of_match_table = cdns_sierra_id_table,
252544d30d62SAlan Douglas 	},
252644d30d62SAlan Douglas };
252744d30d62SAlan Douglas module_platform_driver(cdns_sierra_driver);
252844d30d62SAlan Douglas 
252944d30d62SAlan Douglas MODULE_ALIAS("platform:cdns_sierra");
253044d30d62SAlan Douglas MODULE_AUTHOR("Cadence Design Systems");
253144d30d62SAlan Douglas MODULE_DESCRIPTION("CDNS sierra phy driver");
253244d30d62SAlan Douglas MODULE_LICENSE("GPL v2");
2533