xref: /linux/drivers/phy/cadence/phy-cadence-sierra.c (revision d5aaa0bc6de9c2649fa15def775a6710c052c966)
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
270cfa43abSSwapnil Jakhade #define NUM_PHY_TYPE		5
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
33a1d12987SMarcin Wierzbicki #define SIERRA_CMN_PLLLC_FBDIV_INT_MODE0_PREG		0x43
34a1d12987SMarcin Wierzbicki #define SIERRA_CMN_PLLLC_DCOCAL_CTRL_PREG		0x45
35a1d12987SMarcin Wierzbicki #define SIERRA_CMN_PLLLC_INIT_PREG			0x46
36a1d12987SMarcin Wierzbicki #define SIERRA_CMN_PLLLC_ITERTMR_PREG			0x47
37871002d7SAnil Varughese #define SIERRA_CMN_PLLLC_MODE_PREG			0x48
38871002d7SAnil Varughese #define SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG		0x49
39871002d7SAnil Varughese #define SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG		0x4A
40871002d7SAnil Varughese #define SIERRA_CMN_PLLLC_LOCK_CNTSTART_PREG		0x4B
41a1d12987SMarcin Wierzbicki #define SIERRA_CMN_PLLLC_LOCKSEARCH_PREG		0x4C
4209d976b3SSwapnil Jakhade #define SIERRA_CMN_PLLLC_CLK1_PREG			0x4D
43a1d12987SMarcin Wierzbicki #define SIERRA_CMN_PLLLC_CLK0_PREG			0x4E
44871002d7SAnil Varughese #define SIERRA_CMN_PLLLC_BWCAL_MODE1_PREG		0x4F
45871002d7SAnil Varughese #define SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG		0x50
467a5ad9b4SSwapnil Jakhade #define SIERRA_CMN_PLLLC_DSMCORR_PREG			0x51
477a5ad9b4SSwapnil Jakhade #define SIERRA_CMN_PLLLC_SS_PREG			0x52
487a5ad9b4SSwapnil Jakhade #define SIERRA_CMN_PLLLC_SS_AMP_STEP_SIZE_PREG		0x53
497a5ad9b4SSwapnil Jakhade #define SIERRA_CMN_PLLLC_SSTWOPT_PREG			0x54
50a1d12987SMarcin Wierzbicki #define SIERRA_CMN_PLLCSM_PLLEN_TMR_PREG		0x5D
51a1d12987SMarcin Wierzbicki #define SIERRA_CMN_PLLCSM_PLLPRE_TMR_PREG		0x5E
52871002d7SAnil Varughese #define SIERRA_CMN_PLLLC_SS_TIME_STEPSIZE_MODE_PREG	0x62
537a5ad9b4SSwapnil Jakhade #define SIERRA_CMN_PLLLC_LOCK_DELAY_CTRL_PREG		0x63
54a1d12987SMarcin Wierzbicki #define SIERRA_SDOSCCAL_CLK_CNT_PREG			0x6E
5528081b72SKishon Vijay Abraham I #define SIERRA_CMN_REFRCV_PREG				0x98
56a1d12987SMarcin Wierzbicki #define SIERRA_CMN_RESCAL_CTRLA_PREG			0xA0
5728081b72SKishon Vijay Abraham I #define SIERRA_CMN_REFRCV1_PREG				0xB8
5828081b72SKishon Vijay Abraham I #define SIERRA_CMN_PLLLC1_GEN_PREG			0xC2
590cfa43abSSwapnil Jakhade #define SIERRA_CMN_PLLLC1_FBDIV_INT_PREG		0xC3
60a1d12987SMarcin Wierzbicki #define SIERRA_CMN_PLLLC1_DCOCAL_CTRL_PREG		0xC5
618a1b82d7SSwapnil Jakhade #define SIERRA_CMN_PLLLC1_LF_COEFF_MODE0_PREG		0xCA
620cfa43abSSwapnil Jakhade #define SIERRA_CMN_PLLLC1_CLK0_PREG			0xCE
638a1b82d7SSwapnil Jakhade #define SIERRA_CMN_PLLLC1_BWCAL_MODE0_PREG		0xD0
648a1b82d7SSwapnil Jakhade #define SIERRA_CMN_PLLLC1_SS_TIME_STEPSIZE_MODE_PREG	0xE2
65380f5708SKishon Vijay Abraham I 
66380f5708SKishon Vijay Abraham I #define SIERRA_LANE_CDB_OFFSET(ln, block_offset, reg_offset)	\
67380f5708SKishon Vijay Abraham I 				((0x4000 << (block_offset)) + \
68380f5708SKishon Vijay Abraham I 				 (((ln) << 9) << (reg_offset)))
69aead5fd6SKishon Vijay Abraham I 
70aead5fd6SKishon Vijay Abraham I #define SIERRA_DET_STANDEC_A_PREG			0x000
71aead5fd6SKishon Vijay Abraham I #define SIERRA_DET_STANDEC_B_PREG			0x001
72aead5fd6SKishon Vijay Abraham I #define SIERRA_DET_STANDEC_C_PREG			0x002
73aead5fd6SKishon Vijay Abraham I #define SIERRA_DET_STANDEC_D_PREG			0x003
74aead5fd6SKishon Vijay Abraham I #define SIERRA_DET_STANDEC_E_PREG			0x004
75871002d7SAnil Varughese #define SIERRA_PSM_LANECAL_DLY_A1_RESETS_PREG		0x008
76871002d7SAnil Varughese #define SIERRA_PSM_A0IN_TMR_PREG			0x009
777a5ad9b4SSwapnil Jakhade #define SIERRA_PSM_A3IN_TMR_PREG			0x00C
78aead5fd6SKishon Vijay Abraham I #define SIERRA_PSM_DIAG_PREG				0x015
798a1b82d7SSwapnil Jakhade #define SIERRA_PSC_LN_A3_PREG				0x023
808a1b82d7SSwapnil Jakhade #define SIERRA_PSC_LN_A4_PREG				0x024
818a1b82d7SSwapnil Jakhade #define SIERRA_PSC_LN_IDLE_PREG				0x026
82aead5fd6SKishon Vijay Abraham I #define SIERRA_PSC_TX_A0_PREG				0x028
83aead5fd6SKishon Vijay Abraham I #define SIERRA_PSC_TX_A1_PREG				0x029
84aead5fd6SKishon Vijay Abraham I #define SIERRA_PSC_TX_A2_PREG				0x02A
85aead5fd6SKishon Vijay Abraham I #define SIERRA_PSC_TX_A3_PREG				0x02B
86aead5fd6SKishon Vijay Abraham I #define SIERRA_PSC_RX_A0_PREG				0x030
87aead5fd6SKishon Vijay Abraham I #define SIERRA_PSC_RX_A1_PREG				0x031
88aead5fd6SKishon Vijay Abraham I #define SIERRA_PSC_RX_A2_PREG				0x032
89aead5fd6SKishon Vijay Abraham I #define SIERRA_PSC_RX_A3_PREG				0x033
900cfa43abSSwapnil Jakhade #define SIERRA_PLLCTRL_FBDIV_MODE01_PREG		0x039
91aead5fd6SKishon Vijay Abraham I #define SIERRA_PLLCTRL_SUBRATE_PREG			0x03A
928a1b82d7SSwapnil Jakhade #define SIERRA_PLLCTRL_GEN_A_PREG			0x03B
93aead5fd6SKishon Vijay Abraham I #define SIERRA_PLLCTRL_GEN_D_PREG			0x03E
94871002d7SAnil Varughese #define SIERRA_PLLCTRL_CPGAIN_MODE_PREG			0x03F
95adc4bd6fSKishon Vijay Abraham I #define SIERRA_PLLCTRL_STATUS_PREG			0x044
96871002d7SAnil Varughese #define SIERRA_CLKPATH_BIASTRIM_PREG			0x04B
97871002d7SAnil Varughese #define SIERRA_DFE_BIASTRIM_PREG			0x04C
98aead5fd6SKishon Vijay Abraham I #define SIERRA_DRVCTRL_ATTEN_PREG			0x06A
997a5ad9b4SSwapnil Jakhade #define SIERRA_DRVCTRL_BOOST_PREG			0x06F
100a1d12987SMarcin Wierzbicki #define SIERRA_LANE_TX_RECEIVER_DETECT_PREG		0x071
101e72659b6SSwapnil Jakhade #define SIERRA_TX_RCVDET_OVRD_PREG			0x072
102aead5fd6SKishon Vijay Abraham I #define SIERRA_CLKPATHCTRL_TMR_PREG			0x081
103871002d7SAnil Varughese #define SIERRA_RX_CREQ_FLTR_A_MODE3_PREG		0x085
104871002d7SAnil Varughese #define SIERRA_RX_CREQ_FLTR_A_MODE2_PREG		0x086
105aead5fd6SKishon Vijay Abraham I #define SIERRA_RX_CREQ_FLTR_A_MODE1_PREG		0x087
106aead5fd6SKishon Vijay Abraham I #define SIERRA_RX_CREQ_FLTR_A_MODE0_PREG		0x088
1077a5ad9b4SSwapnil Jakhade #define SIERRA_CREQ_DCBIASATTEN_OVR_PREG		0x08C
108aead5fd6SKishon Vijay Abraham I #define SIERRA_CREQ_CCLKDET_MODE01_PREG			0x08E
1097a5ad9b4SSwapnil Jakhade #define SIERRA_RX_CTLE_CAL_PREG				0x08F
110aead5fd6SKishon Vijay Abraham I #define SIERRA_RX_CTLE_MAINTENANCE_PREG			0x091
111aead5fd6SKishon Vijay Abraham I #define SIERRA_CREQ_FSMCLK_SEL_PREG			0x092
112871002d7SAnil Varughese #define SIERRA_CREQ_EQ_CTRL_PREG			0x093
113871002d7SAnil Varughese #define SIERRA_CREQ_SPARE_PREG				0x096
114871002d7SAnil Varughese #define SIERRA_CREQ_EQ_OPEN_EYE_THRESH_PREG		0x097
115aead5fd6SKishon Vijay Abraham I #define SIERRA_CTLELUT_CTRL_PREG			0x098
116a1d12987SMarcin Wierzbicki #define SIERRA_DEQ_BLK_TAU_CTRL1_PREG			0x0AC
117a1d12987SMarcin Wierzbicki #define SIERRA_DEQ_BLK_TAU_CTRL4_PREG			0x0AF
118aead5fd6SKishon Vijay Abraham I #define SIERRA_DFE_ECMP_RATESEL_PREG			0x0C0
119aead5fd6SKishon Vijay Abraham I #define SIERRA_DFE_SMP_RATESEL_PREG			0x0C1
120871002d7SAnil Varughese #define SIERRA_DEQ_PHALIGN_CTRL				0x0C4
121871002d7SAnil Varughese #define SIERRA_DEQ_CONCUR_CTRL1_PREG			0x0C8
122871002d7SAnil Varughese #define SIERRA_DEQ_CONCUR_CTRL2_PREG			0x0C9
123871002d7SAnil Varughese #define SIERRA_DEQ_EPIPWR_CTRL2_PREG			0x0CD
124871002d7SAnil Varughese #define SIERRA_DEQ_FAST_MAINT_CYCLES_PREG		0x0CE
125871002d7SAnil Varughese #define SIERRA_DEQ_ERRCMP_CTRL_PREG			0x0D0
126871002d7SAnil Varughese #define SIERRA_DEQ_OFFSET_CTRL_PREG			0x0D8
127871002d7SAnil Varughese #define SIERRA_DEQ_GAIN_CTRL_PREG			0x0E0
128aead5fd6SKishon Vijay Abraham I #define SIERRA_DEQ_VGATUNE_CTRL_PREG			0x0E1
129871002d7SAnil Varughese #define SIERRA_DEQ_GLUT0				0x0E8
130871002d7SAnil Varughese #define SIERRA_DEQ_GLUT1				0x0E9
131871002d7SAnil Varughese #define SIERRA_DEQ_GLUT2				0x0EA
132871002d7SAnil Varughese #define SIERRA_DEQ_GLUT3				0x0EB
133871002d7SAnil Varughese #define SIERRA_DEQ_GLUT4				0x0EC
134871002d7SAnil Varughese #define SIERRA_DEQ_GLUT5				0x0ED
135871002d7SAnil Varughese #define SIERRA_DEQ_GLUT6				0x0EE
136871002d7SAnil Varughese #define SIERRA_DEQ_GLUT7				0x0EF
137871002d7SAnil Varughese #define SIERRA_DEQ_GLUT8				0x0F0
138871002d7SAnil Varughese #define SIERRA_DEQ_GLUT9				0x0F1
139871002d7SAnil Varughese #define SIERRA_DEQ_GLUT10				0x0F2
140871002d7SAnil Varughese #define SIERRA_DEQ_GLUT11				0x0F3
141871002d7SAnil Varughese #define SIERRA_DEQ_GLUT12				0x0F4
142871002d7SAnil Varughese #define SIERRA_DEQ_GLUT13				0x0F5
143871002d7SAnil Varughese #define SIERRA_DEQ_GLUT14				0x0F6
144871002d7SAnil Varughese #define SIERRA_DEQ_GLUT15				0x0F7
145871002d7SAnil Varughese #define SIERRA_DEQ_GLUT16				0x0F8
146a1d12987SMarcin Wierzbicki #define SIERRA_POSTPRECUR_EN_CEPH_CTRL_PREG		0x0F9
147a1d12987SMarcin Wierzbicki #define SIERRA_TAU_EN_CEPH2TO0_PREG			0x0FB
148a1d12987SMarcin Wierzbicki #define SIERRA_TAU_EN_CEPH5TO3_PREG			0x0FC
149871002d7SAnil Varughese #define SIERRA_DEQ_ALUT0				0x108
150871002d7SAnil Varughese #define SIERRA_DEQ_ALUT1				0x109
151871002d7SAnil Varughese #define SIERRA_DEQ_ALUT2				0x10A
152871002d7SAnil Varughese #define SIERRA_DEQ_ALUT3				0x10B
153871002d7SAnil Varughese #define SIERRA_DEQ_ALUT4				0x10C
154871002d7SAnil Varughese #define SIERRA_DEQ_ALUT5				0x10D
155871002d7SAnil Varughese #define SIERRA_DEQ_ALUT6				0x10E
156871002d7SAnil Varughese #define SIERRA_DEQ_ALUT7				0x10F
157871002d7SAnil Varughese #define SIERRA_DEQ_ALUT8				0x110
158871002d7SAnil Varughese #define SIERRA_DEQ_ALUT9				0x111
159871002d7SAnil Varughese #define SIERRA_DEQ_ALUT10				0x112
160871002d7SAnil Varughese #define SIERRA_DEQ_ALUT11				0x113
161871002d7SAnil Varughese #define SIERRA_DEQ_ALUT12				0x114
162871002d7SAnil Varughese #define SIERRA_DEQ_ALUT13				0x115
163a1d12987SMarcin Wierzbicki #define SIERRA_OEPH_EN_CTRL_PREG			0x124
164871002d7SAnil Varughese #define SIERRA_DEQ_DFETAP_CTRL_PREG			0x128
1657a5ad9b4SSwapnil Jakhade #define SIERRA_DEQ_DFETAP0				0x129
1667a5ad9b4SSwapnil Jakhade #define SIERRA_DEQ_DFETAP1				0x12B
1677a5ad9b4SSwapnil Jakhade #define SIERRA_DEQ_DFETAP2				0x12D
1687a5ad9b4SSwapnil Jakhade #define SIERRA_DEQ_DFETAP3				0x12F
1697a5ad9b4SSwapnil Jakhade #define SIERRA_DEQ_DFETAP4				0x131
170871002d7SAnil Varughese #define SIERRA_DFE_EN_1010_IGNORE_PREG			0x134
1717a5ad9b4SSwapnil Jakhade #define SIERRA_DEQ_PRECUR_PREG				0x138
1727a5ad9b4SSwapnil Jakhade #define SIERRA_DEQ_POSTCUR_PREG				0x140
1737a5ad9b4SSwapnil Jakhade #define SIERRA_DEQ_POSTCUR_DECR_PREG			0x142
174871002d7SAnil Varughese #define SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG		0x150
175871002d7SAnil Varughese #define SIERRA_DEQ_TAU_CTRL2_PREG			0x151
1767a5ad9b4SSwapnil Jakhade #define SIERRA_DEQ_TAU_CTRL3_PREG			0x152
177*2d0f973bSBartosz Wawrzyniak #define SIERRA_DEQ_TAU_EPIOFFSET_MODE_PREG		0x158
178a1d12987SMarcin Wierzbicki #define SIERRA_DEQ_CONCUR_EPIOFFSET_MODE_PREG		0x159
179*2d0f973bSBartosz Wawrzyniak #define SIERRA_DEQ_OPENEYE_CTRL_PREG			0x15C
180871002d7SAnil Varughese #define SIERRA_DEQ_PICTRL_PREG				0x161
181871002d7SAnil Varughese #define SIERRA_CPICAL_TMRVAL_MODE1_PREG			0x170
182871002d7SAnil Varughese #define SIERRA_CPICAL_TMRVAL_MODE0_PREG			0x171
183871002d7SAnil Varughese #define SIERRA_CPICAL_PICNT_MODE1_PREG			0x174
184aead5fd6SKishon Vijay Abraham I #define SIERRA_CPI_OUTBUF_RATESEL_PREG			0x17C
1858a1b82d7SSwapnil Jakhade #define SIERRA_CPI_RESBIAS_BIN_PREG			0x17E
1867a5ad9b4SSwapnil Jakhade #define SIERRA_CPI_TRIM_PREG				0x17F
187871002d7SAnil Varughese #define SIERRA_CPICAL_RES_STARTCODE_MODE23_PREG		0x183
188a1d12987SMarcin Wierzbicki #define SIERRA_CPICAL_RES_STARTCODE_MODE01_PREG		0x184
1897a5ad9b4SSwapnil Jakhade #define SIERRA_EPI_CTRL_PREG				0x187
190871002d7SAnil Varughese #define SIERRA_LFPSDET_SUPPORT_PREG			0x188
191aead5fd6SKishon Vijay Abraham I #define SIERRA_LFPSFILT_NS_PREG				0x18A
192aead5fd6SKishon Vijay Abraham I #define SIERRA_LFPSFILT_RD_PREG				0x18B
193aead5fd6SKishon Vijay Abraham I #define SIERRA_LFPSFILT_MP_PREG				0x18C
194871002d7SAnil Varughese #define SIERRA_SIGDET_SUPPORT_PREG			0x190
195aead5fd6SKishon Vijay Abraham I #define SIERRA_SDFILT_H2L_A_PREG			0x191
196871002d7SAnil Varughese #define SIERRA_SDFILT_L2H_PREG				0x193
197871002d7SAnil Varughese #define SIERRA_RXBUFFER_CTLECTRL_PREG			0x19E
198871002d7SAnil Varughese #define SIERRA_RXBUFFER_RCDFECTRL_PREG			0x19F
199871002d7SAnil Varughese #define SIERRA_RXBUFFER_DFECTRL_PREG			0x1A0
200a1d12987SMarcin Wierzbicki #define SIERRA_LN_SPARE_REG_PREG			0x1B0
201871002d7SAnil Varughese #define SIERRA_DEQ_TAU_CTRL1_FAST_MAINT_PREG		0x14F
202871002d7SAnil Varughese #define SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG		0x150
203380f5708SKishon Vijay Abraham I 
2048c95e172SSwapnil Jakhade /* PHY PCS common registers */
2058c95e172SSwapnil Jakhade #define SIERRA_PHY_PCS_COMMON_OFFSET(block_offset)	\
206380f5708SKishon Vijay Abraham I 				     (0xc000 << (block_offset))
207fa105172SSwapnil Jakhade #define SIERRA_PHY_PIPE_CMN_CTRL1			0x0
208380f5708SKishon Vijay Abraham I #define SIERRA_PHY_PLL_CFG				0xe
20944d30d62SAlan Douglas 
21036ce4163SSwapnil Jakhade /* PHY PCS lane registers */
21136ce4163SSwapnil Jakhade #define SIERRA_PHY_PCS_LANE_CDB_OFFSET(ln, block_offset, reg_offset)	\
21236ce4163SSwapnil Jakhade 				       ((0xD000 << (block_offset)) +	\
21336ce4163SSwapnil Jakhade 				       (((ln) << 8) << (reg_offset)))
21436ce4163SSwapnil Jakhade 
21536ce4163SSwapnil Jakhade #define SIERRA_PHY_ISO_LINK_CTRL			0xB
21636ce4163SSwapnil Jakhade 
217f1cc6c3fSSwapnil Jakhade /* PHY PMA common registers */
218f1cc6c3fSSwapnil Jakhade #define SIERRA_PHY_PMA_COMMON_OFFSET(block_offset)	\
219f1cc6c3fSSwapnil Jakhade 				     (0xE000 << (block_offset))
220f1cc6c3fSSwapnil Jakhade #define SIERRA_PHY_PMA_CMN_CTRL				0x000
221f1cc6c3fSSwapnil Jakhade 
2226b81f05aSSwapnil Jakhade /* PHY PMA lane registers */
2236b81f05aSSwapnil Jakhade #define SIERRA_PHY_PMA_LANE_CDB_OFFSET(ln, block_offset, reg_offset)	\
2246b81f05aSSwapnil Jakhade 				       ((0xF000 << (block_offset)) +	\
2256b81f05aSSwapnil Jakhade 				       (((ln) << 8) << (reg_offset)))
2266b81f05aSSwapnil Jakhade 
2276b81f05aSSwapnil Jakhade #define SIERRA_PHY_PMA_XCVR_CTRL			0x000
2286b81f05aSSwapnil Jakhade 
22944d30d62SAlan Douglas #define SIERRA_MACRO_ID					0x00007364
230a43f72aeSKishon Vijay Abraham I #define SIERRA_MAX_LANES				16
231adc4bd6fSKishon Vijay Abraham I #define PLL_LOCK_TIME					100000
23244d30d62SAlan Douglas 
23309d976b3SSwapnil Jakhade #define CDNS_SIERRA_OUTPUT_CLOCKS			3
234a59f6006SLars-Peter Clausen #define CDNS_SIERRA_INPUT_CLOCKS			3
235a0c30cd7SKishon Vijay Abraham I enum cdns_sierra_clock_input {
236a0c30cd7SKishon Vijay Abraham I 	PHY_CLK,
237a0c30cd7SKishon Vijay Abraham I 	CMN_REFCLK_DIG_DIV,
238a0c30cd7SKishon Vijay Abraham I 	CMN_REFCLK1_DIG_DIV,
239a0c30cd7SKishon Vijay Abraham I };
240a0c30cd7SKishon Vijay Abraham I 
24128081b72SKishon Vijay Abraham I #define SIERRA_NUM_CMN_PLLC				2
24228081b72SKishon Vijay Abraham I #define SIERRA_NUM_CMN_PLLC_PARENTS			2
24328081b72SKishon Vijay Abraham I 
244380f5708SKishon Vijay Abraham I static const struct reg_field macro_id_type =
245380f5708SKishon Vijay Abraham I 				REG_FIELD(SIERRA_MACRO_ID_REG, 0, 15);
246380f5708SKishon Vijay Abraham I static const struct reg_field phy_pll_cfg_1 =
247380f5708SKishon Vijay Abraham I 				REG_FIELD(SIERRA_PHY_PLL_CFG, 1, 1);
248f1cc6c3fSSwapnil Jakhade static const struct reg_field pma_cmn_ready =
249f1cc6c3fSSwapnil Jakhade 				REG_FIELD(SIERRA_PHY_PMA_CMN_CTRL, 0, 0);
250adc4bd6fSKishon Vijay Abraham I static const struct reg_field pllctrl_lock =
251adc4bd6fSKishon Vijay Abraham I 				REG_FIELD(SIERRA_PLLCTRL_STATUS_PREG, 0, 0);
25236ce4163SSwapnil Jakhade static const struct reg_field phy_iso_link_ctrl_1 =
25336ce4163SSwapnil Jakhade 				REG_FIELD(SIERRA_PHY_ISO_LINK_CTRL, 1, 1);
25409d976b3SSwapnil Jakhade static const struct reg_field cmn_plllc_clk1outdiv_preg =
25509d976b3SSwapnil Jakhade 				REG_FIELD(SIERRA_CMN_PLLLC_CLK1_PREG, 0, 6);
25609d976b3SSwapnil Jakhade static const struct reg_field cmn_plllc_clk1_en_preg =
25709d976b3SSwapnil Jakhade 				REG_FIELD(SIERRA_CMN_PLLLC_CLK1_PREG, 12, 12);
258380f5708SKishon Vijay Abraham I 
25928081b72SKishon Vijay Abraham I static const char * const clk_names[] = {
26028081b72SKishon Vijay Abraham I 	[CDNS_SIERRA_PLL_CMNLC] = "pll_cmnlc",
26128081b72SKishon Vijay Abraham I 	[CDNS_SIERRA_PLL_CMNLC1] = "pll_cmnlc1",
26209d976b3SSwapnil Jakhade 	[CDNS_SIERRA_DERIVED_REFCLK] = "refclk_der",
26328081b72SKishon Vijay Abraham I };
26428081b72SKishon Vijay Abraham I 
26528081b72SKishon Vijay Abraham I enum cdns_sierra_cmn_plllc {
26628081b72SKishon Vijay Abraham I 	CMN_PLLLC,
26728081b72SKishon Vijay Abraham I 	CMN_PLLLC1,
26828081b72SKishon Vijay Abraham I };
26928081b72SKishon Vijay Abraham I 
27028081b72SKishon Vijay Abraham I struct cdns_sierra_pll_mux_reg_fields {
27128081b72SKishon Vijay Abraham I 	struct reg_field	pfdclk_sel_preg;
27228081b72SKishon Vijay Abraham I 	struct reg_field	plllc1en_field;
27328081b72SKishon Vijay Abraham I 	struct reg_field	termen_field;
27428081b72SKishon Vijay Abraham I };
27528081b72SKishon Vijay Abraham I 
27628081b72SKishon Vijay Abraham I static const struct cdns_sierra_pll_mux_reg_fields cmn_plllc_pfdclk1_sel_preg[] = {
27728081b72SKishon Vijay Abraham I 	[CMN_PLLLC] = {
27828081b72SKishon Vijay Abraham I 		.pfdclk_sel_preg = REG_FIELD(SIERRA_CMN_PLLLC_GEN_PREG, 1, 1),
27928081b72SKishon Vijay Abraham I 		.plllc1en_field = REG_FIELD(SIERRA_CMN_REFRCV1_PREG, 8, 8),
28028081b72SKishon Vijay Abraham I 		.termen_field = REG_FIELD(SIERRA_CMN_REFRCV1_PREG, 0, 0),
28128081b72SKishon Vijay Abraham I 	},
28228081b72SKishon Vijay Abraham I 	[CMN_PLLLC1] = {
28328081b72SKishon Vijay Abraham I 		.pfdclk_sel_preg = REG_FIELD(SIERRA_CMN_PLLLC1_GEN_PREG, 1, 1),
28428081b72SKishon Vijay Abraham I 		.plllc1en_field = REG_FIELD(SIERRA_CMN_REFRCV_PREG, 8, 8),
28528081b72SKishon Vijay Abraham I 		.termen_field = REG_FIELD(SIERRA_CMN_REFRCV_PREG, 0, 0),
28628081b72SKishon Vijay Abraham I 	},
28728081b72SKishon Vijay Abraham I };
28828081b72SKishon Vijay Abraham I 
28928081b72SKishon Vijay Abraham I struct cdns_sierra_pll_mux {
29028081b72SKishon Vijay Abraham I 	struct clk_hw		hw;
29128081b72SKishon Vijay Abraham I 	struct regmap_field	*pfdclk_sel_preg;
29228081b72SKishon Vijay Abraham I 	struct regmap_field	*plllc1en_field;
29328081b72SKishon Vijay Abraham I 	struct regmap_field	*termen_field;
29428081b72SKishon Vijay Abraham I 	struct clk_init_data	clk_data;
29528081b72SKishon Vijay Abraham I };
29628081b72SKishon Vijay Abraham I 
29728081b72SKishon Vijay Abraham I #define to_cdns_sierra_pll_mux(_hw)	\
29828081b72SKishon Vijay Abraham I 			container_of(_hw, struct cdns_sierra_pll_mux, hw)
29928081b72SKishon Vijay Abraham I 
300a59f6006SLars-Peter Clausen #define PLL0_REFCLK_NAME "pll0_refclk"
301a59f6006SLars-Peter Clausen #define PLL1_REFCLK_NAME "pll1_refclk"
302a59f6006SLars-Peter Clausen 
303a59f6006SLars-Peter Clausen static const struct clk_parent_data pll_mux_parent_data[][SIERRA_NUM_CMN_PLLC_PARENTS] = {
304a59f6006SLars-Peter Clausen 	[CMN_PLLLC] = {
305a59f6006SLars-Peter Clausen 		{ .fw_name = PLL0_REFCLK_NAME },
306a59f6006SLars-Peter Clausen 		{ .fw_name = PLL1_REFCLK_NAME }
307a59f6006SLars-Peter Clausen 	},
308a59f6006SLars-Peter Clausen 	[CMN_PLLLC1] = {
309a59f6006SLars-Peter Clausen 		{ .fw_name = PLL1_REFCLK_NAME },
310a59f6006SLars-Peter Clausen 		{ .fw_name = PLL0_REFCLK_NAME }
311a59f6006SLars-Peter Clausen 	},
31228081b72SKishon Vijay Abraham I };
31328081b72SKishon Vijay Abraham I 
314f75999c5SChristophe JAILLET static const u32 cdns_sierra_pll_mux_table[][SIERRA_NUM_CMN_PLLC_PARENTS] = {
315da08aab9SSwapnil Jakhade 	[CMN_PLLLC] = { 0, 1 },
316da08aab9SSwapnil Jakhade 	[CMN_PLLLC1] = { 1, 0 },
317da08aab9SSwapnil Jakhade };
31828081b72SKishon Vijay Abraham I 
31909d976b3SSwapnil Jakhade struct cdns_sierra_derived_refclk {
32009d976b3SSwapnil Jakhade 	struct clk_hw           hw;
32109d976b3SSwapnil Jakhade 	struct regmap_field     *cmn_plllc_clk1outdiv_preg;
32209d976b3SSwapnil Jakhade 	struct regmap_field     *cmn_plllc_clk1_en_preg;
32309d976b3SSwapnil Jakhade 	struct clk_init_data	clk_data;
32409d976b3SSwapnil Jakhade };
32509d976b3SSwapnil Jakhade 
32609d976b3SSwapnil Jakhade #define to_cdns_sierra_derived_refclk(_hw)	\
32709d976b3SSwapnil Jakhade 			container_of(_hw, struct cdns_sierra_derived_refclk, hw)
32809d976b3SSwapnil Jakhade 
329078e9e92SSwapnil Jakhade enum cdns_sierra_phy_type {
330078e9e92SSwapnil Jakhade 	TYPE_NONE,
331078e9e92SSwapnil Jakhade 	TYPE_PCIE,
3328a1b82d7SSwapnil Jakhade 	TYPE_USB,
3330cfa43abSSwapnil Jakhade 	TYPE_SGMII,
3348a1b82d7SSwapnil Jakhade 	TYPE_QSGMII
335078e9e92SSwapnil Jakhade };
336078e9e92SSwapnil Jakhade 
337078e9e92SSwapnil Jakhade enum cdns_sierra_ssc_mode {
338078e9e92SSwapnil Jakhade 	NO_SSC,
339078e9e92SSwapnil Jakhade 	EXTERNAL_SSC,
340078e9e92SSwapnil Jakhade 	INTERNAL_SSC
341078e9e92SSwapnil Jakhade };
342078e9e92SSwapnil Jakhade 
34344d30d62SAlan Douglas struct cdns_sierra_inst {
34444d30d62SAlan Douglas 	struct phy *phy;
345078e9e92SSwapnil Jakhade 	enum cdns_sierra_phy_type phy_type;
34644d30d62SAlan Douglas 	u32 num_lanes;
34744d30d62SAlan Douglas 	u32 mlane;
34844d30d62SAlan Douglas 	struct reset_control *lnk_rst;
3491e902b2aSSwapnil Jakhade 	enum cdns_sierra_ssc_mode ssc_mode;
35044d30d62SAlan Douglas };
35144d30d62SAlan Douglas 
35244d30d62SAlan Douglas struct cdns_reg_pairs {
35344d30d62SAlan Douglas 	u16 val;
35444d30d62SAlan Douglas 	u32 off;
35544d30d62SAlan Douglas };
35644d30d62SAlan Douglas 
357078e9e92SSwapnil Jakhade struct cdns_sierra_vals {
358078e9e92SSwapnil Jakhade 	const struct cdns_reg_pairs *reg_pairs;
359078e9e92SSwapnil Jakhade 	u32 num_regs;
360078e9e92SSwapnil Jakhade };
361078e9e92SSwapnil Jakhade 
36244d30d62SAlan Douglas struct cdns_sierra_data {
36344d30d62SAlan Douglas 	u32 id_value;
364380f5708SKishon Vijay Abraham I 	u8 block_offset_shift;
365380f5708SKishon Vijay Abraham I 	u8 reg_offset_shift;
366da41bac5SChristophe JAILLET 	const struct cdns_sierra_vals *pcs_cmn_vals[NUM_PHY_TYPE][NUM_PHY_TYPE]
367fa105172SSwapnil Jakhade 						   [NUM_SSC_MODE];
368da41bac5SChristophe JAILLET 	const struct cdns_sierra_vals *phy_pma_ln_vals[NUM_PHY_TYPE][NUM_PHY_TYPE]
3696b81f05aSSwapnil Jakhade 						      [NUM_SSC_MODE];
370da41bac5SChristophe JAILLET 	const struct cdns_sierra_vals *pma_cmn_vals[NUM_PHY_TYPE][NUM_PHY_TYPE]
371078e9e92SSwapnil Jakhade 						   [NUM_SSC_MODE];
372da41bac5SChristophe JAILLET 	const struct cdns_sierra_vals *pma_ln_vals[NUM_PHY_TYPE][NUM_PHY_TYPE]
373078e9e92SSwapnil Jakhade 						  [NUM_SSC_MODE];
37444d30d62SAlan Douglas };
37544d30d62SAlan Douglas 
376380f5708SKishon Vijay Abraham I struct cdns_regmap_cdb_context {
37744d30d62SAlan Douglas 	struct device *dev;
37844d30d62SAlan Douglas 	void __iomem *base;
379380f5708SKishon Vijay Abraham I 	u8 reg_offset_shift;
380380f5708SKishon Vijay Abraham I };
381380f5708SKishon Vijay Abraham I 
382380f5708SKishon Vijay Abraham I struct cdns_sierra_phy {
383380f5708SKishon Vijay Abraham I 	struct device *dev;
384c3c11d55SSwapnil Jakhade 	const struct cdns_sierra_data *init_data;
38544d30d62SAlan Douglas 	struct cdns_sierra_inst phys[SIERRA_MAX_LANES];
38644d30d62SAlan Douglas 	struct reset_control *phy_rst;
38744d30d62SAlan Douglas 	struct reset_control *apb_rst;
388380f5708SKishon Vijay Abraham I 	struct regmap *regmap_lane_cdb[SIERRA_MAX_LANES];
3898c95e172SSwapnil Jakhade 	struct regmap *regmap_phy_pcs_common_cdb;
39036ce4163SSwapnil Jakhade 	struct regmap *regmap_phy_pcs_lane_cdb[SIERRA_MAX_LANES];
391f1cc6c3fSSwapnil Jakhade 	struct regmap *regmap_phy_pma_common_cdb;
3926b81f05aSSwapnil Jakhade 	struct regmap *regmap_phy_pma_lane_cdb[SIERRA_MAX_LANES];
393380f5708SKishon Vijay Abraham I 	struct regmap *regmap_common_cdb;
394380f5708SKishon Vijay Abraham I 	struct regmap_field *macro_id_type;
395380f5708SKishon Vijay Abraham I 	struct regmap_field *phy_pll_cfg_1;
396f1cc6c3fSSwapnil Jakhade 	struct regmap_field *pma_cmn_ready;
397adc4bd6fSKishon Vijay Abraham I 	struct regmap_field *pllctrl_lock[SIERRA_MAX_LANES];
39836ce4163SSwapnil Jakhade 	struct regmap_field *phy_iso_link_ctrl_1[SIERRA_MAX_LANES];
39928081b72SKishon Vijay Abraham I 	struct regmap_field *cmn_refrcv_refclk_plllc1en_preg[SIERRA_NUM_CMN_PLLC];
40028081b72SKishon Vijay Abraham I 	struct regmap_field *cmn_refrcv_refclk_termen_preg[SIERRA_NUM_CMN_PLLC];
40128081b72SKishon Vijay Abraham I 	struct regmap_field *cmn_plllc_pfdclk1_sel_preg[SIERRA_NUM_CMN_PLLC];
402a0c30cd7SKishon Vijay Abraham I 	struct clk *input_clks[CDNS_SIERRA_INPUT_CLOCKS];
40344d30d62SAlan Douglas 	int nsubnodes;
404a43f72aeSKishon Vijay Abraham I 	u32 num_lanes;
40544d30d62SAlan Douglas 	bool autoconf;
406d88ca22dSAswath Govindraju 	int already_configured;
4076ef7aa32SLars-Peter Clausen 	struct clk *pll_clks[SIERRA_NUM_CMN_PLLC];
4086ef7aa32SLars-Peter Clausen 	struct clk_hw_onecell_data clk_data;
40944d30d62SAlan Douglas };
41044d30d62SAlan Douglas 
cdns_regmap_write(void * context,unsigned int reg,unsigned int val)411380f5708SKishon Vijay Abraham I static int cdns_regmap_write(void *context, unsigned int reg, unsigned int val)
412380f5708SKishon Vijay Abraham I {
413380f5708SKishon Vijay Abraham I 	struct cdns_regmap_cdb_context *ctx = context;
414380f5708SKishon Vijay Abraham I 	u32 offset = reg << ctx->reg_offset_shift;
415380f5708SKishon Vijay Abraham I 
416380f5708SKishon Vijay Abraham I 	writew(val, ctx->base + offset);
417380f5708SKishon Vijay Abraham I 
418380f5708SKishon Vijay Abraham I 	return 0;
419380f5708SKishon Vijay Abraham I }
420380f5708SKishon Vijay Abraham I 
cdns_regmap_read(void * context,unsigned int reg,unsigned int * val)421380f5708SKishon Vijay Abraham I static int cdns_regmap_read(void *context, unsigned int reg, unsigned int *val)
422380f5708SKishon Vijay Abraham I {
423380f5708SKishon Vijay Abraham I 	struct cdns_regmap_cdb_context *ctx = context;
424380f5708SKishon Vijay Abraham I 	u32 offset = reg << ctx->reg_offset_shift;
425380f5708SKishon Vijay Abraham I 
426380f5708SKishon Vijay Abraham I 	*val = readw(ctx->base + offset);
427380f5708SKishon Vijay Abraham I 	return 0;
428380f5708SKishon Vijay Abraham I }
429380f5708SKishon Vijay Abraham I 
430380f5708SKishon Vijay Abraham I #define SIERRA_LANE_CDB_REGMAP_CONF(n) \
431380f5708SKishon Vijay Abraham I { \
432380f5708SKishon Vijay Abraham I 	.name = "sierra_lane" n "_cdb", \
433380f5708SKishon Vijay Abraham I 	.reg_stride = 1, \
434380f5708SKishon Vijay Abraham I 	.fast_io = true, \
435380f5708SKishon Vijay Abraham I 	.reg_write = cdns_regmap_write, \
436380f5708SKishon Vijay Abraham I 	.reg_read = cdns_regmap_read, \
437380f5708SKishon Vijay Abraham I }
438380f5708SKishon Vijay Abraham I 
4393cfb0e8eSRikard Falkeborn static const struct regmap_config cdns_sierra_lane_cdb_config[] = {
440380f5708SKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("0"),
441380f5708SKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("1"),
442380f5708SKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("2"),
443380f5708SKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("3"),
444a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("4"),
445a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("5"),
446a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("6"),
447a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("7"),
448a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("8"),
449a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("9"),
450a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("10"),
451a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("11"),
452a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("12"),
453a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("13"),
454a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("14"),
455a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("15"),
456380f5708SKishon Vijay Abraham I };
457380f5708SKishon Vijay Abraham I 
4583cfb0e8eSRikard Falkeborn static const struct regmap_config cdns_sierra_common_cdb_config = {
459380f5708SKishon Vijay Abraham I 	.name = "sierra_common_cdb",
460380f5708SKishon Vijay Abraham I 	.reg_stride = 1,
461380f5708SKishon Vijay Abraham I 	.fast_io = true,
462380f5708SKishon Vijay Abraham I 	.reg_write = cdns_regmap_write,
463380f5708SKishon Vijay Abraham I 	.reg_read = cdns_regmap_read,
464380f5708SKishon Vijay Abraham I };
465380f5708SKishon Vijay Abraham I 
4668c95e172SSwapnil Jakhade static const struct regmap_config cdns_sierra_phy_pcs_cmn_cdb_config = {
4678c95e172SSwapnil Jakhade 	.name = "sierra_phy_pcs_cmn_cdb",
468380f5708SKishon Vijay Abraham I 	.reg_stride = 1,
469380f5708SKishon Vijay Abraham I 	.fast_io = true,
470380f5708SKishon Vijay Abraham I 	.reg_write = cdns_regmap_write,
471380f5708SKishon Vijay Abraham I 	.reg_read = cdns_regmap_read,
472380f5708SKishon Vijay Abraham I };
473380f5708SKishon Vijay Abraham I 
47436ce4163SSwapnil Jakhade #define SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF(n) \
47536ce4163SSwapnil Jakhade { \
47636ce4163SSwapnil Jakhade 	.name = "sierra_phy_pcs_lane" n "_cdb", \
47736ce4163SSwapnil Jakhade 	.reg_stride = 1, \
47836ce4163SSwapnil Jakhade 	.fast_io = true, \
47936ce4163SSwapnil Jakhade 	.reg_write = cdns_regmap_write, \
48036ce4163SSwapnil Jakhade 	.reg_read = cdns_regmap_read, \
48136ce4163SSwapnil Jakhade }
48236ce4163SSwapnil Jakhade 
48336ce4163SSwapnil Jakhade static const struct regmap_config cdns_sierra_phy_pcs_lane_cdb_config[] = {
48436ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("0"),
48536ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("1"),
48636ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("2"),
48736ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("3"),
48836ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("4"),
48936ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("5"),
49036ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("6"),
49136ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("7"),
49236ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("8"),
49336ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("9"),
49436ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("10"),
49536ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("11"),
49636ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("12"),
49736ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("13"),
49836ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("14"),
49936ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("15"),
50036ce4163SSwapnil Jakhade };
50136ce4163SSwapnil Jakhade 
502f1cc6c3fSSwapnil Jakhade static const struct regmap_config cdns_sierra_phy_pma_cmn_cdb_config = {
503f1cc6c3fSSwapnil Jakhade 	.name = "sierra_phy_pma_cmn_cdb",
504f1cc6c3fSSwapnil Jakhade 	.reg_stride = 1,
505f1cc6c3fSSwapnil Jakhade 	.fast_io = true,
506f1cc6c3fSSwapnil Jakhade 	.reg_write = cdns_regmap_write,
507f1cc6c3fSSwapnil Jakhade 	.reg_read = cdns_regmap_read,
508f1cc6c3fSSwapnil Jakhade };
509f1cc6c3fSSwapnil Jakhade 
5106b81f05aSSwapnil Jakhade #define SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF(n) \
5116b81f05aSSwapnil Jakhade { \
5126b81f05aSSwapnil Jakhade 	.name = "sierra_phy_pma_lane" n "_cdb", \
5136b81f05aSSwapnil Jakhade 	.reg_stride = 1, \
5146b81f05aSSwapnil Jakhade 	.fast_io = true, \
5156b81f05aSSwapnil Jakhade 	.reg_write = cdns_regmap_write, \
5166b81f05aSSwapnil Jakhade 	.reg_read = cdns_regmap_read, \
5176b81f05aSSwapnil Jakhade }
5186b81f05aSSwapnil Jakhade 
5196b81f05aSSwapnil Jakhade static const struct regmap_config cdns_sierra_phy_pma_lane_cdb_config[] = {
5206b81f05aSSwapnil Jakhade 	SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("0"),
5216b81f05aSSwapnil Jakhade 	SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("1"),
5226b81f05aSSwapnil Jakhade 	SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("2"),
5236b81f05aSSwapnil Jakhade 	SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("3"),
5246b81f05aSSwapnil Jakhade 	SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("4"),
5256b81f05aSSwapnil Jakhade 	SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("5"),
5266b81f05aSSwapnil Jakhade 	SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("6"),
5276b81f05aSSwapnil Jakhade 	SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("7"),
5286b81f05aSSwapnil Jakhade 	SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("8"),
5296b81f05aSSwapnil Jakhade 	SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("9"),
5306b81f05aSSwapnil Jakhade 	SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("10"),
5316b81f05aSSwapnil Jakhade 	SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("11"),
5326b81f05aSSwapnil Jakhade 	SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("12"),
5336b81f05aSSwapnil Jakhade 	SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("13"),
5346b81f05aSSwapnil Jakhade 	SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("14"),
5356b81f05aSSwapnil Jakhade 	SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("15"),
5366b81f05aSSwapnil Jakhade };
5376b81f05aSSwapnil Jakhade 
cdns_sierra_phy_init(struct phy * gphy)538cedcc2e2SKishon Vijay Abraham I static int cdns_sierra_phy_init(struct phy *gphy)
53944d30d62SAlan Douglas {
54044d30d62SAlan Douglas 	struct cdns_sierra_inst *ins = phy_get_drvdata(gphy);
54144d30d62SAlan Douglas 	struct cdns_sierra_phy *phy = dev_get_drvdata(gphy->dev.parent);
542078e9e92SSwapnil Jakhade 	const struct cdns_sierra_data *init_data = phy->init_data;
543da41bac5SChristophe JAILLET 	const struct cdns_sierra_vals *pma_cmn_vals, *pma_ln_vals;
544078e9e92SSwapnil Jakhade 	enum cdns_sierra_phy_type phy_type = ins->phy_type;
545da41bac5SChristophe JAILLET 	const struct cdns_sierra_vals *phy_pma_ln_vals;
5461e902b2aSSwapnil Jakhade 	enum cdns_sierra_ssc_mode ssc = ins->ssc_mode;
547da41bac5SChristophe JAILLET 	const struct cdns_sierra_vals *pcs_cmn_vals;
548078e9e92SSwapnil Jakhade 	const struct cdns_reg_pairs *reg_pairs;
54980f96fb1SColin Ian King 	struct regmap *regmap;
550078e9e92SSwapnil Jakhade 	u32 num_regs;
55144d30d62SAlan Douglas 	int i, j;
55244d30d62SAlan Douglas 
553cedcc2e2SKishon Vijay Abraham I 	/* Initialise the PHY registers, unless auto configured */
554d88ca22dSAswath Govindraju 	if (phy->autoconf || phy->already_configured || phy->nsubnodes > 1)
555cedcc2e2SKishon Vijay Abraham I 		return 0;
556cedcc2e2SKishon Vijay Abraham I 
557a0c30cd7SKishon Vijay Abraham I 	clk_set_rate(phy->input_clks[CMN_REFCLK_DIG_DIV], 25000000);
558a0c30cd7SKishon Vijay Abraham I 	clk_set_rate(phy->input_clks[CMN_REFCLK1_DIG_DIV], 25000000);
559078e9e92SSwapnil Jakhade 
560fa105172SSwapnil Jakhade 	/* PHY PCS common registers configurations */
561fa105172SSwapnil Jakhade 	pcs_cmn_vals = init_data->pcs_cmn_vals[phy_type][TYPE_NONE][ssc];
562fa105172SSwapnil Jakhade 	if (pcs_cmn_vals) {
563fa105172SSwapnil Jakhade 		reg_pairs = pcs_cmn_vals->reg_pairs;
564fa105172SSwapnil Jakhade 		num_regs = pcs_cmn_vals->num_regs;
565fa105172SSwapnil Jakhade 		regmap = phy->regmap_phy_pcs_common_cdb;
566fa105172SSwapnil Jakhade 		for (i = 0; i < num_regs; i++)
567fa105172SSwapnil Jakhade 			regmap_write(regmap, reg_pairs[i].off, reg_pairs[i].val);
568fa105172SSwapnil Jakhade 	}
569fa105172SSwapnil Jakhade 
5706b81f05aSSwapnil Jakhade 	/* PHY PMA lane registers configurations */
5716b81f05aSSwapnil Jakhade 	phy_pma_ln_vals = init_data->phy_pma_ln_vals[phy_type][TYPE_NONE][ssc];
5726b81f05aSSwapnil Jakhade 	if (phy_pma_ln_vals) {
5736b81f05aSSwapnil Jakhade 		reg_pairs = phy_pma_ln_vals->reg_pairs;
5746b81f05aSSwapnil Jakhade 		num_regs = phy_pma_ln_vals->num_regs;
5756b81f05aSSwapnil Jakhade 		for (i = 0; i < ins->num_lanes; i++) {
5766b81f05aSSwapnil Jakhade 			regmap = phy->regmap_phy_pma_lane_cdb[i + ins->mlane];
5776b81f05aSSwapnil Jakhade 			for (j = 0; j < num_regs; j++)
5786b81f05aSSwapnil Jakhade 				regmap_write(regmap, reg_pairs[j].off, reg_pairs[j].val);
5796b81f05aSSwapnil Jakhade 		}
5806b81f05aSSwapnil Jakhade 	}
5816b81f05aSSwapnil Jakhade 
582078e9e92SSwapnil Jakhade 	/* PMA common registers configurations */
583078e9e92SSwapnil Jakhade 	pma_cmn_vals = init_data->pma_cmn_vals[phy_type][TYPE_NONE][ssc];
584078e9e92SSwapnil Jakhade 	if (pma_cmn_vals) {
585078e9e92SSwapnil Jakhade 		reg_pairs = pma_cmn_vals->reg_pairs;
586078e9e92SSwapnil Jakhade 		num_regs = pma_cmn_vals->num_regs;
587078e9e92SSwapnil Jakhade 		regmap = phy->regmap_common_cdb;
588078e9e92SSwapnil Jakhade 		for (i = 0; i < num_regs; i++)
589078e9e92SSwapnil Jakhade 			regmap_write(regmap, reg_pairs[i].off, reg_pairs[i].val);
59044d30d62SAlan Douglas 	}
591871002d7SAnil Varughese 
592078e9e92SSwapnil Jakhade 	/* PMA lane registers configurations */
593078e9e92SSwapnil Jakhade 	pma_ln_vals = init_data->pma_ln_vals[phy_type][TYPE_NONE][ssc];
594078e9e92SSwapnil Jakhade 	if (pma_ln_vals) {
595078e9e92SSwapnil Jakhade 		reg_pairs = pma_ln_vals->reg_pairs;
596078e9e92SSwapnil Jakhade 		num_regs = pma_ln_vals->num_regs;
597380f5708SKishon Vijay Abraham I 		for (i = 0; i < ins->num_lanes; i++) {
598380f5708SKishon Vijay Abraham I 			regmap = phy->regmap_lane_cdb[i + ins->mlane];
599078e9e92SSwapnil Jakhade 			for (j = 0; j < num_regs; j++)
600078e9e92SSwapnil Jakhade 				regmap_write(regmap, reg_pairs[j].off, reg_pairs[j].val);
601380f5708SKishon Vijay Abraham I 		}
602380f5708SKishon Vijay Abraham I 	}
603cedcc2e2SKishon Vijay Abraham I 
604cedcc2e2SKishon Vijay Abraham I 	return 0;
60544d30d62SAlan Douglas }
60644d30d62SAlan Douglas 
cdns_sierra_phy_on(struct phy * gphy)60744d30d62SAlan Douglas static int cdns_sierra_phy_on(struct phy *gphy)
60844d30d62SAlan Douglas {
609adc4bd6fSKishon Vijay Abraham I 	struct cdns_sierra_phy *sp = dev_get_drvdata(gphy->dev.parent);
61044d30d62SAlan Douglas 	struct cdns_sierra_inst *ins = phy_get_drvdata(gphy);
611adc4bd6fSKishon Vijay Abraham I 	struct device *dev = sp->dev;
612adc4bd6fSKishon Vijay Abraham I 	u32 val;
613adc4bd6fSKishon Vijay Abraham I 	int ret;
61444d30d62SAlan Douglas 
6156b81f05aSSwapnil Jakhade 	if (sp->nsubnodes == 1) {
6166b81f05aSSwapnil Jakhade 		/* Take the PHY out of reset */
6175b4f5757SKishon Vijay Abraham I 		ret = reset_control_deassert(sp->phy_rst);
6185b4f5757SKishon Vijay Abraham I 		if (ret) {
6195b4f5757SKishon Vijay Abraham I 			dev_err(dev, "Failed to take the PHY out of reset\n");
6205b4f5757SKishon Vijay Abraham I 			return ret;
6215b4f5757SKishon Vijay Abraham I 		}
6226b81f05aSSwapnil Jakhade 	}
6235b4f5757SKishon Vijay Abraham I 
62444d30d62SAlan Douglas 	/* Take the PHY lane group out of reset */
625adc4bd6fSKishon Vijay Abraham I 	ret = reset_control_deassert(ins->lnk_rst);
626adc4bd6fSKishon Vijay Abraham I 	if (ret) {
627adc4bd6fSKishon Vijay Abraham I 		dev_err(dev, "Failed to take the PHY lane out of reset\n");
628adc4bd6fSKishon Vijay Abraham I 		return ret;
629adc4bd6fSKishon Vijay Abraham I 	}
630adc4bd6fSKishon Vijay Abraham I 
63136ce4163SSwapnil Jakhade 	if (ins->phy_type == TYPE_PCIE || ins->phy_type == TYPE_USB) {
63236ce4163SSwapnil Jakhade 		ret = regmap_field_read_poll_timeout(sp->phy_iso_link_ctrl_1[ins->mlane],
63336ce4163SSwapnil Jakhade 						     val, !val, 1000, PLL_LOCK_TIME);
63436ce4163SSwapnil Jakhade 		if (ret) {
63536ce4163SSwapnil Jakhade 			dev_err(dev, "Timeout waiting for PHY status ready\n");
63636ce4163SSwapnil Jakhade 			return ret;
63736ce4163SSwapnil Jakhade 		}
63836ce4163SSwapnil Jakhade 	}
63936ce4163SSwapnil Jakhade 
640f1cc6c3fSSwapnil Jakhade 	/*
641f1cc6c3fSSwapnil Jakhade 	 * Wait for cmn_ready assertion
642f1cc6c3fSSwapnil Jakhade 	 * PHY_PMA_CMN_CTRL[0] == 1
643f1cc6c3fSSwapnil Jakhade 	 */
644f1cc6c3fSSwapnil Jakhade 	ret = regmap_field_read_poll_timeout(sp->pma_cmn_ready, val, val,
645f1cc6c3fSSwapnil Jakhade 					     1000, PLL_LOCK_TIME);
646f1cc6c3fSSwapnil Jakhade 	if (ret) {
647f1cc6c3fSSwapnil Jakhade 		dev_err(dev, "Timeout waiting for CMN ready\n");
648f1cc6c3fSSwapnil Jakhade 		return ret;
649f1cc6c3fSSwapnil Jakhade 	}
650f1cc6c3fSSwapnil Jakhade 
651adc4bd6fSKishon Vijay Abraham I 	ret = regmap_field_read_poll_timeout(sp->pllctrl_lock[ins->mlane],
652adc4bd6fSKishon Vijay Abraham I 					     val, val, 1000, PLL_LOCK_TIME);
653adc4bd6fSKishon Vijay Abraham I 	if (ret < 0)
654adc4bd6fSKishon Vijay Abraham I 		dev_err(dev, "PLL lock of lane failed\n");
655adc4bd6fSKishon Vijay Abraham I 
656adc4bd6fSKishon Vijay Abraham I 	return ret;
65744d30d62SAlan Douglas }
65844d30d62SAlan Douglas 
cdns_sierra_phy_off(struct phy * gphy)65944d30d62SAlan Douglas static int cdns_sierra_phy_off(struct phy *gphy)
66044d30d62SAlan Douglas {
66144d30d62SAlan Douglas 	struct cdns_sierra_inst *ins = phy_get_drvdata(gphy);
66244d30d62SAlan Douglas 
66344d30d62SAlan Douglas 	return reset_control_assert(ins->lnk_rst);
66444d30d62SAlan Douglas }
66544d30d62SAlan Douglas 
cdns_sierra_phy_reset(struct phy * gphy)6667904e15bSRoger Quadros static int cdns_sierra_phy_reset(struct phy *gphy)
6677904e15bSRoger Quadros {
6687904e15bSRoger Quadros 	struct cdns_sierra_phy *sp = dev_get_drvdata(gphy->dev.parent);
6697904e15bSRoger Quadros 
6707904e15bSRoger Quadros 	reset_control_assert(sp->phy_rst);
6717904e15bSRoger Quadros 	reset_control_deassert(sp->phy_rst);
6727904e15bSRoger Quadros 	return 0;
6737904e15bSRoger Quadros };
6747904e15bSRoger Quadros 
67544d30d62SAlan Douglas static const struct phy_ops ops = {
676cedcc2e2SKishon Vijay Abraham I 	.init		= cdns_sierra_phy_init,
67744d30d62SAlan Douglas 	.power_on	= cdns_sierra_phy_on,
67844d30d62SAlan Douglas 	.power_off	= cdns_sierra_phy_off,
6797904e15bSRoger Quadros 	.reset		= cdns_sierra_phy_reset,
68044d30d62SAlan Douglas 	.owner		= THIS_MODULE,
68144d30d62SAlan Douglas };
68244d30d62SAlan Douglas 
cdns_sierra_noop_phy_on(struct phy * gphy)683d88ca22dSAswath Govindraju static int cdns_sierra_noop_phy_on(struct phy *gphy)
684d88ca22dSAswath Govindraju {
685d88ca22dSAswath Govindraju 	usleep_range(5000, 10000);
686d88ca22dSAswath Govindraju 
687d88ca22dSAswath Govindraju 	return 0;
688d88ca22dSAswath Govindraju }
689d88ca22dSAswath Govindraju 
690d88ca22dSAswath Govindraju static const struct phy_ops noop_ops = {
691d88ca22dSAswath Govindraju 	.power_on	= cdns_sierra_noop_phy_on,
692d88ca22dSAswath Govindraju 	.owner		= THIS_MODULE,
693d88ca22dSAswath Govindraju };
694d88ca22dSAswath Govindraju 
cdns_sierra_pll_mux_get_parent(struct clk_hw * hw)69528081b72SKishon Vijay Abraham I static u8 cdns_sierra_pll_mux_get_parent(struct clk_hw *hw)
69628081b72SKishon Vijay Abraham I {
69728081b72SKishon Vijay Abraham I 	struct cdns_sierra_pll_mux *mux = to_cdns_sierra_pll_mux(hw);
698da08aab9SSwapnil Jakhade 	struct regmap_field *plllc1en_field = mux->plllc1en_field;
699da08aab9SSwapnil Jakhade 	struct regmap_field *termen_field = mux->termen_field;
70028081b72SKishon Vijay Abraham I 	struct regmap_field *field = mux->pfdclk_sel_preg;
70128081b72SKishon Vijay Abraham I 	unsigned int val;
702da08aab9SSwapnil Jakhade 	int index;
70328081b72SKishon Vijay Abraham I 
70428081b72SKishon Vijay Abraham I 	regmap_field_read(field, &val);
705da08aab9SSwapnil Jakhade 
706da08aab9SSwapnil Jakhade 	if (strstr(clk_hw_get_name(hw), clk_names[CDNS_SIERRA_PLL_CMNLC1])) {
707da08aab9SSwapnil Jakhade 		index = clk_mux_val_to_index(hw, cdns_sierra_pll_mux_table[CMN_PLLLC1], 0, val);
708da08aab9SSwapnil Jakhade 		if (index == 1) {
709da08aab9SSwapnil Jakhade 			regmap_field_write(plllc1en_field, 1);
710da08aab9SSwapnil Jakhade 			regmap_field_write(termen_field, 1);
711da08aab9SSwapnil Jakhade 		}
712da08aab9SSwapnil Jakhade 	} else {
713da08aab9SSwapnil Jakhade 		index = clk_mux_val_to_index(hw, cdns_sierra_pll_mux_table[CMN_PLLLC], 0, val);
714da08aab9SSwapnil Jakhade 	}
715da08aab9SSwapnil Jakhade 
716da08aab9SSwapnil Jakhade 	return index;
71728081b72SKishon Vijay Abraham I }
71828081b72SKishon Vijay Abraham I 
cdns_sierra_pll_mux_set_parent(struct clk_hw * hw,u8 index)71928081b72SKishon Vijay Abraham I static int cdns_sierra_pll_mux_set_parent(struct clk_hw *hw, u8 index)
72028081b72SKishon Vijay Abraham I {
72128081b72SKishon Vijay Abraham I 	struct cdns_sierra_pll_mux *mux = to_cdns_sierra_pll_mux(hw);
72228081b72SKishon Vijay Abraham I 	struct regmap_field *plllc1en_field = mux->plllc1en_field;
72328081b72SKishon Vijay Abraham I 	struct regmap_field *termen_field = mux->termen_field;
72428081b72SKishon Vijay Abraham I 	struct regmap_field *field = mux->pfdclk_sel_preg;
72528081b72SKishon Vijay Abraham I 	int val, ret;
72628081b72SKishon Vijay Abraham I 
72728081b72SKishon Vijay Abraham I 	ret = regmap_field_write(plllc1en_field, 0);
72828081b72SKishon Vijay Abraham I 	ret |= regmap_field_write(termen_field, 0);
72928081b72SKishon Vijay Abraham I 	if (index == 1) {
73028081b72SKishon Vijay Abraham I 		ret |= regmap_field_write(plllc1en_field, 1);
73128081b72SKishon Vijay Abraham I 		ret |= regmap_field_write(termen_field, 1);
73228081b72SKishon Vijay Abraham I 	}
73328081b72SKishon Vijay Abraham I 
734da08aab9SSwapnil Jakhade 	if (strstr(clk_hw_get_name(hw), clk_names[CDNS_SIERRA_PLL_CMNLC1]))
735da08aab9SSwapnil Jakhade 		val = cdns_sierra_pll_mux_table[CMN_PLLLC1][index];
736da08aab9SSwapnil Jakhade 	else
737da08aab9SSwapnil Jakhade 		val = cdns_sierra_pll_mux_table[CMN_PLLLC][index];
738da08aab9SSwapnil Jakhade 
73928081b72SKishon Vijay Abraham I 	ret |= regmap_field_write(field, val);
74028081b72SKishon Vijay Abraham I 
74128081b72SKishon Vijay Abraham I 	return ret;
74228081b72SKishon Vijay Abraham I }
74328081b72SKishon Vijay Abraham I 
74428081b72SKishon Vijay Abraham I static const struct clk_ops cdns_sierra_pll_mux_ops = {
7451ca48301SMaxime Ripard 	.determine_rate = __clk_mux_determine_rate,
74628081b72SKishon Vijay Abraham I 	.set_parent = cdns_sierra_pll_mux_set_parent,
74728081b72SKishon Vijay Abraham I 	.get_parent = cdns_sierra_pll_mux_get_parent,
74828081b72SKishon Vijay Abraham I };
74928081b72SKishon Vijay Abraham I 
cdns_sierra_pll_mux_register(struct cdns_sierra_phy * sp,struct regmap_field * pfdclk1_sel_field,struct regmap_field * plllc1en_field,struct regmap_field * termen_field,int clk_index)75028081b72SKishon Vijay Abraham I static int cdns_sierra_pll_mux_register(struct cdns_sierra_phy *sp,
75128081b72SKishon Vijay Abraham I 					struct regmap_field *pfdclk1_sel_field,
75228081b72SKishon Vijay Abraham I 					struct regmap_field *plllc1en_field,
75328081b72SKishon Vijay Abraham I 					struct regmap_field *termen_field,
75428081b72SKishon Vijay Abraham I 					int clk_index)
75528081b72SKishon Vijay Abraham I {
75628081b72SKishon Vijay Abraham I 	struct cdns_sierra_pll_mux *mux;
75728081b72SKishon Vijay Abraham I 	struct device *dev = sp->dev;
75828081b72SKishon Vijay Abraham I 	struct clk_init_data *init;
75928081b72SKishon Vijay Abraham I 	char clk_name[100];
7606ef7aa32SLars-Peter Clausen 	int ret;
76128081b72SKishon Vijay Abraham I 
76228081b72SKishon Vijay Abraham I 	mux = devm_kzalloc(dev, sizeof(*mux), GFP_KERNEL);
76328081b72SKishon Vijay Abraham I 	if (!mux)
76428081b72SKishon Vijay Abraham I 		return -ENOMEM;
76528081b72SKishon Vijay Abraham I 
76628081b72SKishon Vijay Abraham I 	snprintf(clk_name, sizeof(clk_name), "%s_%s", dev_name(dev), clk_names[clk_index]);
76728081b72SKishon Vijay Abraham I 
76828081b72SKishon Vijay Abraham I 	init = &mux->clk_data;
76928081b72SKishon Vijay Abraham I 
77028081b72SKishon Vijay Abraham I 	init->ops = &cdns_sierra_pll_mux_ops;
77128081b72SKishon Vijay Abraham I 	init->flags = CLK_SET_RATE_NO_REPARENT;
772a59f6006SLars-Peter Clausen 	init->parent_data = pll_mux_parent_data[clk_index];
773a59f6006SLars-Peter Clausen 	init->num_parents = SIERRA_NUM_CMN_PLLC_PARENTS;
77428081b72SKishon Vijay Abraham I 	init->name = clk_name;
77528081b72SKishon Vijay Abraham I 
77628081b72SKishon Vijay Abraham I 	mux->pfdclk_sel_preg = pfdclk1_sel_field;
77728081b72SKishon Vijay Abraham I 	mux->plllc1en_field = plllc1en_field;
77828081b72SKishon Vijay Abraham I 	mux->termen_field = termen_field;
77928081b72SKishon Vijay Abraham I 	mux->hw.init = init;
78028081b72SKishon Vijay Abraham I 
7816ef7aa32SLars-Peter Clausen 	ret = devm_clk_hw_register(dev, &mux->hw);
7826ef7aa32SLars-Peter Clausen 	if (ret)
7836ef7aa32SLars-Peter Clausen 		return ret;
78428081b72SKishon Vijay Abraham I 
7856ef7aa32SLars-Peter Clausen 	sp->clk_data.hws[clk_index] = &mux->hw;
7866ef7aa32SLars-Peter Clausen 
7876ef7aa32SLars-Peter Clausen 	sp->pll_clks[clk_index] = devm_clk_hw_get_clk(dev, &mux->hw,
7886ef7aa32SLars-Peter Clausen 						      clk_names[clk_index]);
78928081b72SKishon Vijay Abraham I 
79028081b72SKishon Vijay Abraham I 	return 0;
79128081b72SKishon Vijay Abraham I }
79228081b72SKishon Vijay Abraham I 
cdns_sierra_phy_register_pll_mux(struct cdns_sierra_phy * sp)79328081b72SKishon Vijay Abraham I static int cdns_sierra_phy_register_pll_mux(struct cdns_sierra_phy *sp)
79428081b72SKishon Vijay Abraham I {
79528081b72SKishon Vijay Abraham I 	struct regmap_field *pfdclk1_sel_field;
79628081b72SKishon Vijay Abraham I 	struct regmap_field *plllc1en_field;
79728081b72SKishon Vijay Abraham I 	struct regmap_field *termen_field;
79828081b72SKishon Vijay Abraham I 	struct device *dev = sp->dev;
79928081b72SKishon Vijay Abraham I 	int ret = 0, i, clk_index;
80028081b72SKishon Vijay Abraham I 
80128081b72SKishon Vijay Abraham I 	clk_index = CDNS_SIERRA_PLL_CMNLC;
80228081b72SKishon Vijay Abraham I 	for (i = 0; i < SIERRA_NUM_CMN_PLLC; i++, clk_index++) {
80328081b72SKishon Vijay Abraham I 		pfdclk1_sel_field = sp->cmn_plllc_pfdclk1_sel_preg[i];
80428081b72SKishon Vijay Abraham I 		plllc1en_field = sp->cmn_refrcv_refclk_plllc1en_preg[i];
80528081b72SKishon Vijay Abraham I 		termen_field = sp->cmn_refrcv_refclk_termen_preg[i];
80628081b72SKishon Vijay Abraham I 
80728081b72SKishon Vijay Abraham I 		ret = cdns_sierra_pll_mux_register(sp, pfdclk1_sel_field, plllc1en_field,
80828081b72SKishon Vijay Abraham I 						   termen_field, clk_index);
80928081b72SKishon Vijay Abraham I 		if (ret) {
81028081b72SKishon Vijay Abraham I 			dev_err(dev, "Fail to register cmn plllc mux\n");
81128081b72SKishon Vijay Abraham I 			return ret;
81228081b72SKishon Vijay Abraham I 		}
81328081b72SKishon Vijay Abraham I 	}
81428081b72SKishon Vijay Abraham I 
81528081b72SKishon Vijay Abraham I 	return 0;
81628081b72SKishon Vijay Abraham I }
81728081b72SKishon Vijay Abraham I 
cdns_sierra_derived_refclk_enable(struct clk_hw * hw)81809d976b3SSwapnil Jakhade static int cdns_sierra_derived_refclk_enable(struct clk_hw *hw)
81909d976b3SSwapnil Jakhade {
82009d976b3SSwapnil Jakhade 	struct cdns_sierra_derived_refclk *derived_refclk = to_cdns_sierra_derived_refclk(hw);
82109d976b3SSwapnil Jakhade 
82209d976b3SSwapnil Jakhade 	regmap_field_write(derived_refclk->cmn_plllc_clk1_en_preg, 0x1);
82309d976b3SSwapnil Jakhade 
82409d976b3SSwapnil Jakhade 	/* Programming to get 100Mhz clock output in ref_der_clk_out 5GHz VCO/50 = 100MHz */
82509d976b3SSwapnil Jakhade 	regmap_field_write(derived_refclk->cmn_plllc_clk1outdiv_preg, 0x2E);
82609d976b3SSwapnil Jakhade 
82709d976b3SSwapnil Jakhade 	return 0;
82809d976b3SSwapnil Jakhade }
82909d976b3SSwapnil Jakhade 
cdns_sierra_derived_refclk_disable(struct clk_hw * hw)83009d976b3SSwapnil Jakhade static void cdns_sierra_derived_refclk_disable(struct clk_hw *hw)
83109d976b3SSwapnil Jakhade {
83209d976b3SSwapnil Jakhade 	struct cdns_sierra_derived_refclk *derived_refclk = to_cdns_sierra_derived_refclk(hw);
83309d976b3SSwapnil Jakhade 
83409d976b3SSwapnil Jakhade 	regmap_field_write(derived_refclk->cmn_plllc_clk1_en_preg, 0);
83509d976b3SSwapnil Jakhade }
83609d976b3SSwapnil Jakhade 
cdns_sierra_derived_refclk_is_enabled(struct clk_hw * hw)83709d976b3SSwapnil Jakhade static int cdns_sierra_derived_refclk_is_enabled(struct clk_hw *hw)
83809d976b3SSwapnil Jakhade {
83909d976b3SSwapnil Jakhade 	struct cdns_sierra_derived_refclk *derived_refclk = to_cdns_sierra_derived_refclk(hw);
84009d976b3SSwapnil Jakhade 	int val;
84109d976b3SSwapnil Jakhade 
84209d976b3SSwapnil Jakhade 	regmap_field_read(derived_refclk->cmn_plllc_clk1_en_preg, &val);
84309d976b3SSwapnil Jakhade 
84409d976b3SSwapnil Jakhade 	return !!val;
84509d976b3SSwapnil Jakhade }
84609d976b3SSwapnil Jakhade 
84709d976b3SSwapnil Jakhade static const struct clk_ops cdns_sierra_derived_refclk_ops = {
84809d976b3SSwapnil Jakhade 	.enable = cdns_sierra_derived_refclk_enable,
84909d976b3SSwapnil Jakhade 	.disable = cdns_sierra_derived_refclk_disable,
85009d976b3SSwapnil Jakhade 	.is_enabled = cdns_sierra_derived_refclk_is_enabled,
85109d976b3SSwapnil Jakhade };
85209d976b3SSwapnil Jakhade 
cdns_sierra_derived_refclk_register(struct cdns_sierra_phy * sp)85309d976b3SSwapnil Jakhade static int cdns_sierra_derived_refclk_register(struct cdns_sierra_phy *sp)
85409d976b3SSwapnil Jakhade {
85509d976b3SSwapnil Jakhade 	struct cdns_sierra_derived_refclk *derived_refclk;
85609d976b3SSwapnil Jakhade 	struct device *dev = sp->dev;
85709d976b3SSwapnil Jakhade 	struct regmap_field *field;
85809d976b3SSwapnil Jakhade 	struct clk_init_data *init;
85909d976b3SSwapnil Jakhade 	struct regmap *regmap;
86009d976b3SSwapnil Jakhade 	char clk_name[100];
8616ef7aa32SLars-Peter Clausen 	int ret;
86209d976b3SSwapnil Jakhade 
86309d976b3SSwapnil Jakhade 	derived_refclk = devm_kzalloc(dev, sizeof(*derived_refclk), GFP_KERNEL);
86409d976b3SSwapnil Jakhade 	if (!derived_refclk)
86509d976b3SSwapnil Jakhade 		return -ENOMEM;
86609d976b3SSwapnil Jakhade 
86709d976b3SSwapnil Jakhade 	snprintf(clk_name, sizeof(clk_name), "%s_%s", dev_name(dev),
86809d976b3SSwapnil Jakhade 		 clk_names[CDNS_SIERRA_DERIVED_REFCLK]);
86909d976b3SSwapnil Jakhade 
87009d976b3SSwapnil Jakhade 	init = &derived_refclk->clk_data;
87109d976b3SSwapnil Jakhade 
87209d976b3SSwapnil Jakhade 	init->ops = &cdns_sierra_derived_refclk_ops;
87309d976b3SSwapnil Jakhade 	init->flags = 0;
87409d976b3SSwapnil Jakhade 	init->name = clk_name;
87509d976b3SSwapnil Jakhade 
87609d976b3SSwapnil Jakhade 	regmap = sp->regmap_common_cdb;
87709d976b3SSwapnil Jakhade 
87809d976b3SSwapnil Jakhade 	field = devm_regmap_field_alloc(dev, regmap, cmn_plllc_clk1outdiv_preg);
87909d976b3SSwapnil Jakhade 	if (IS_ERR(field)) {
88009d976b3SSwapnil Jakhade 		dev_err(dev, "cmn_plllc_clk1outdiv_preg reg field init failed\n");
88109d976b3SSwapnil Jakhade 		return PTR_ERR(field);
88209d976b3SSwapnil Jakhade 	}
88309d976b3SSwapnil Jakhade 	derived_refclk->cmn_plllc_clk1outdiv_preg = field;
88409d976b3SSwapnil Jakhade 
88509d976b3SSwapnil Jakhade 	field = devm_regmap_field_alloc(dev, regmap, cmn_plllc_clk1_en_preg);
88609d976b3SSwapnil Jakhade 	if (IS_ERR(field)) {
88709d976b3SSwapnil Jakhade 		dev_err(dev, "cmn_plllc_clk1_en_preg reg field init failed\n");
88809d976b3SSwapnil Jakhade 		return PTR_ERR(field);
88909d976b3SSwapnil Jakhade 	}
89009d976b3SSwapnil Jakhade 	derived_refclk->cmn_plllc_clk1_en_preg = field;
89109d976b3SSwapnil Jakhade 
89209d976b3SSwapnil Jakhade 	derived_refclk->hw.init = init;
89309d976b3SSwapnil Jakhade 
8946ef7aa32SLars-Peter Clausen 	ret = devm_clk_hw_register(dev, &derived_refclk->hw);
8956ef7aa32SLars-Peter Clausen 	if (ret)
8966ef7aa32SLars-Peter Clausen 		return ret;
89709d976b3SSwapnil Jakhade 
8986ef7aa32SLars-Peter Clausen 	sp->clk_data.hws[CDNS_SIERRA_DERIVED_REFCLK] = &derived_refclk->hw;
89909d976b3SSwapnil Jakhade 
90009d976b3SSwapnil Jakhade 	return 0;
90109d976b3SSwapnil Jakhade }
90209d976b3SSwapnil Jakhade 
cdns_sierra_clk_unregister(struct cdns_sierra_phy * sp)90328081b72SKishon Vijay Abraham I static void cdns_sierra_clk_unregister(struct cdns_sierra_phy *sp)
90428081b72SKishon Vijay Abraham I {
90528081b72SKishon Vijay Abraham I 	struct device *dev = sp->dev;
90628081b72SKishon Vijay Abraham I 	struct device_node *node = dev->of_node;
90728081b72SKishon Vijay Abraham I 
90828081b72SKishon Vijay Abraham I 	of_clk_del_provider(node);
90928081b72SKishon Vijay Abraham I }
91028081b72SKishon Vijay Abraham I 
cdns_sierra_clk_register(struct cdns_sierra_phy * sp)91128081b72SKishon Vijay Abraham I static int cdns_sierra_clk_register(struct cdns_sierra_phy *sp)
91228081b72SKishon Vijay Abraham I {
91328081b72SKishon Vijay Abraham I 	struct device *dev = sp->dev;
91428081b72SKishon Vijay Abraham I 	struct device_node *node = dev->of_node;
91528081b72SKishon Vijay Abraham I 	int ret;
91628081b72SKishon Vijay Abraham I 
91728081b72SKishon Vijay Abraham I 	ret = cdns_sierra_phy_register_pll_mux(sp);
91828081b72SKishon Vijay Abraham I 	if (ret) {
91928081b72SKishon Vijay Abraham I 		dev_err(dev, "Failed to pll mux clocks\n");
92028081b72SKishon Vijay Abraham I 		return ret;
92128081b72SKishon Vijay Abraham I 	}
92228081b72SKishon Vijay Abraham I 
92309d976b3SSwapnil Jakhade 	ret = cdns_sierra_derived_refclk_register(sp);
92409d976b3SSwapnil Jakhade 	if (ret) {
92509d976b3SSwapnil Jakhade 		dev_err(dev, "Failed to register derived refclk\n");
92609d976b3SSwapnil Jakhade 		return ret;
92709d976b3SSwapnil Jakhade 	}
92809d976b3SSwapnil Jakhade 
9296ef7aa32SLars-Peter Clausen 	sp->clk_data.num = CDNS_SIERRA_OUTPUT_CLOCKS;
9306ef7aa32SLars-Peter Clausen 	ret = of_clk_add_hw_provider(node, of_clk_hw_onecell_get,
9316ef7aa32SLars-Peter Clausen 				     &sp->clk_data);
93228081b72SKishon Vijay Abraham I 	if (ret)
93328081b72SKishon Vijay Abraham I 		dev_err(dev, "Failed to add clock provider: %s\n", node->name);
93428081b72SKishon Vijay Abraham I 
93528081b72SKishon Vijay Abraham I 	return ret;
93628081b72SKishon Vijay Abraham I }
93728081b72SKishon Vijay Abraham I 
cdns_sierra_get_optional(struct cdns_sierra_inst * inst,struct device_node * child)93844d30d62SAlan Douglas static int cdns_sierra_get_optional(struct cdns_sierra_inst *inst,
93944d30d62SAlan Douglas 				    struct device_node *child)
94044d30d62SAlan Douglas {
941078e9e92SSwapnil Jakhade 	u32 phy_type;
942078e9e92SSwapnil Jakhade 
94344d30d62SAlan Douglas 	if (of_property_read_u32(child, "reg", &inst->mlane))
94444d30d62SAlan Douglas 		return -EINVAL;
94544d30d62SAlan Douglas 
94644d30d62SAlan Douglas 	if (of_property_read_u32(child, "cdns,num-lanes", &inst->num_lanes))
94744d30d62SAlan Douglas 		return -EINVAL;
94844d30d62SAlan Douglas 
949078e9e92SSwapnil Jakhade 	if (of_property_read_u32(child, "cdns,phy-type", &phy_type))
95044d30d62SAlan Douglas 		return -EINVAL;
95144d30d62SAlan Douglas 
952078e9e92SSwapnil Jakhade 	switch (phy_type) {
953078e9e92SSwapnil Jakhade 	case PHY_TYPE_PCIE:
954078e9e92SSwapnil Jakhade 		inst->phy_type = TYPE_PCIE;
955078e9e92SSwapnil Jakhade 		break;
956078e9e92SSwapnil Jakhade 	case PHY_TYPE_USB3:
957078e9e92SSwapnil Jakhade 		inst->phy_type = TYPE_USB;
958078e9e92SSwapnil Jakhade 		break;
9590cfa43abSSwapnil Jakhade 	case PHY_TYPE_SGMII:
9600cfa43abSSwapnil Jakhade 		inst->phy_type = TYPE_SGMII;
9610cfa43abSSwapnil Jakhade 		break;
9628a1b82d7SSwapnil Jakhade 	case PHY_TYPE_QSGMII:
9638a1b82d7SSwapnil Jakhade 		inst->phy_type = TYPE_QSGMII;
9648a1b82d7SSwapnil Jakhade 		break;
965078e9e92SSwapnil Jakhade 	default:
966078e9e92SSwapnil Jakhade 		return -EINVAL;
967078e9e92SSwapnil Jakhade 	}
968078e9e92SSwapnil Jakhade 
9691e902b2aSSwapnil Jakhade 	inst->ssc_mode = EXTERNAL_SSC;
9701e902b2aSSwapnil Jakhade 	of_property_read_u32(child, "cdns,ssc-mode", &inst->ssc_mode);
9711e902b2aSSwapnil Jakhade 
97244d30d62SAlan Douglas 	return 0;
97344d30d62SAlan Douglas }
97444d30d62SAlan Douglas 
cdns_regmap_init(struct device * dev,void __iomem * base,u32 block_offset,u8 reg_offset_shift,const struct regmap_config * config)975380f5708SKishon Vijay Abraham I static struct regmap *cdns_regmap_init(struct device *dev, void __iomem *base,
976380f5708SKishon Vijay Abraham I 				       u32 block_offset, u8 reg_offset_shift,
977380f5708SKishon Vijay Abraham I 				       const struct regmap_config *config)
978380f5708SKishon Vijay Abraham I {
979380f5708SKishon Vijay Abraham I 	struct cdns_regmap_cdb_context *ctx;
980380f5708SKishon Vijay Abraham I 
981380f5708SKishon Vijay Abraham I 	ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
982380f5708SKishon Vijay Abraham I 	if (!ctx)
983380f5708SKishon Vijay Abraham I 		return ERR_PTR(-ENOMEM);
984380f5708SKishon Vijay Abraham I 
985380f5708SKishon Vijay Abraham I 	ctx->dev = dev;
986380f5708SKishon Vijay Abraham I 	ctx->base = base + block_offset;
987380f5708SKishon Vijay Abraham I 	ctx->reg_offset_shift = reg_offset_shift;
988380f5708SKishon Vijay Abraham I 
989380f5708SKishon Vijay Abraham I 	return devm_regmap_init(dev, NULL, ctx, config);
990380f5708SKishon Vijay Abraham I }
991380f5708SKishon Vijay Abraham I 
cdns_regfield_init(struct cdns_sierra_phy * sp)992380f5708SKishon Vijay Abraham I static int cdns_regfield_init(struct cdns_sierra_phy *sp)
993380f5708SKishon Vijay Abraham I {
994380f5708SKishon Vijay Abraham I 	struct device *dev = sp->dev;
995380f5708SKishon Vijay Abraham I 	struct regmap_field *field;
99628081b72SKishon Vijay Abraham I 	struct reg_field reg_field;
997380f5708SKishon Vijay Abraham I 	struct regmap *regmap;
998adc4bd6fSKishon Vijay Abraham I 	int i;
999380f5708SKishon Vijay Abraham I 
1000380f5708SKishon Vijay Abraham I 	regmap = sp->regmap_common_cdb;
1001380f5708SKishon Vijay Abraham I 	field = devm_regmap_field_alloc(dev, regmap, macro_id_type);
1002380f5708SKishon Vijay Abraham I 	if (IS_ERR(field)) {
1003380f5708SKishon Vijay Abraham I 		dev_err(dev, "MACRO_ID_TYPE reg field init failed\n");
1004380f5708SKishon Vijay Abraham I 		return PTR_ERR(field);
1005380f5708SKishon Vijay Abraham I 	}
1006380f5708SKishon Vijay Abraham I 	sp->macro_id_type = field;
1007380f5708SKishon Vijay Abraham I 
100828081b72SKishon Vijay Abraham I 	for (i = 0; i < SIERRA_NUM_CMN_PLLC; i++) {
100928081b72SKishon Vijay Abraham I 		reg_field = cmn_plllc_pfdclk1_sel_preg[i].pfdclk_sel_preg;
101028081b72SKishon Vijay Abraham I 		field = devm_regmap_field_alloc(dev, regmap, reg_field);
101128081b72SKishon Vijay Abraham I 		if (IS_ERR(field)) {
101228081b72SKishon Vijay Abraham I 			dev_err(dev, "PLLLC%d_PFDCLK1_SEL failed\n", i);
101328081b72SKishon Vijay Abraham I 			return PTR_ERR(field);
101428081b72SKishon Vijay Abraham I 		}
101528081b72SKishon Vijay Abraham I 		sp->cmn_plllc_pfdclk1_sel_preg[i] = field;
101628081b72SKishon Vijay Abraham I 
101728081b72SKishon Vijay Abraham I 		reg_field = cmn_plllc_pfdclk1_sel_preg[i].plllc1en_field;
101828081b72SKishon Vijay Abraham I 		field = devm_regmap_field_alloc(dev, regmap, reg_field);
101928081b72SKishon Vijay Abraham I 		if (IS_ERR(field)) {
102028081b72SKishon Vijay Abraham I 			dev_err(dev, "REFRCV%d_REFCLK_PLLLC1EN failed\n", i);
102128081b72SKishon Vijay Abraham I 			return PTR_ERR(field);
102228081b72SKishon Vijay Abraham I 		}
102328081b72SKishon Vijay Abraham I 		sp->cmn_refrcv_refclk_plllc1en_preg[i] = field;
102428081b72SKishon Vijay Abraham I 
102528081b72SKishon Vijay Abraham I 		reg_field = cmn_plllc_pfdclk1_sel_preg[i].termen_field;
102628081b72SKishon Vijay Abraham I 		field = devm_regmap_field_alloc(dev, regmap, reg_field);
102728081b72SKishon Vijay Abraham I 		if (IS_ERR(field)) {
102828081b72SKishon Vijay Abraham I 			dev_err(dev, "REFRCV%d_REFCLK_TERMEN failed\n", i);
102928081b72SKishon Vijay Abraham I 			return PTR_ERR(field);
103028081b72SKishon Vijay Abraham I 		}
103128081b72SKishon Vijay Abraham I 		sp->cmn_refrcv_refclk_termen_preg[i] = field;
103228081b72SKishon Vijay Abraham I 	}
103328081b72SKishon Vijay Abraham I 
10348c95e172SSwapnil Jakhade 	regmap = sp->regmap_phy_pcs_common_cdb;
1035380f5708SKishon Vijay Abraham I 	field = devm_regmap_field_alloc(dev, regmap, phy_pll_cfg_1);
1036380f5708SKishon Vijay Abraham I 	if (IS_ERR(field)) {
1037380f5708SKishon Vijay Abraham I 		dev_err(dev, "PHY_PLL_CFG_1 reg field init failed\n");
1038380f5708SKishon Vijay Abraham I 		return PTR_ERR(field);
1039380f5708SKishon Vijay Abraham I 	}
1040380f5708SKishon Vijay Abraham I 	sp->phy_pll_cfg_1 = field;
1041380f5708SKishon Vijay Abraham I 
1042f1cc6c3fSSwapnil Jakhade 	regmap = sp->regmap_phy_pma_common_cdb;
1043f1cc6c3fSSwapnil Jakhade 	field = devm_regmap_field_alloc(dev, regmap, pma_cmn_ready);
1044f1cc6c3fSSwapnil Jakhade 	if (IS_ERR(field)) {
1045f1cc6c3fSSwapnil Jakhade 		dev_err(dev, "PHY_PMA_CMN_CTRL reg field init failed\n");
1046f1cc6c3fSSwapnil Jakhade 		return PTR_ERR(field);
1047f1cc6c3fSSwapnil Jakhade 	}
1048f1cc6c3fSSwapnil Jakhade 	sp->pma_cmn_ready = field;
1049f1cc6c3fSSwapnil Jakhade 
1050adc4bd6fSKishon Vijay Abraham I 	for (i = 0; i < SIERRA_MAX_LANES; i++) {
1051adc4bd6fSKishon Vijay Abraham I 		regmap = sp->regmap_lane_cdb[i];
1052adc4bd6fSKishon Vijay Abraham I 		field = devm_regmap_field_alloc(dev, regmap, pllctrl_lock);
1053adc4bd6fSKishon Vijay Abraham I 		if (IS_ERR(field)) {
1054adc4bd6fSKishon Vijay Abraham I 			dev_err(dev, "P%d_ENABLE reg field init failed\n", i);
1055adc4bd6fSKishon Vijay Abraham I 			return PTR_ERR(field);
1056adc4bd6fSKishon Vijay Abraham I 		}
1057adc4bd6fSKishon Vijay Abraham I 		sp->pllctrl_lock[i] = field;
1058adc4bd6fSKishon Vijay Abraham I 	}
1059adc4bd6fSKishon Vijay Abraham I 
106036ce4163SSwapnil Jakhade 	for (i = 0; i < SIERRA_MAX_LANES; i++) {
106136ce4163SSwapnil Jakhade 		regmap = sp->regmap_phy_pcs_lane_cdb[i];
106236ce4163SSwapnil Jakhade 		field = devm_regmap_field_alloc(dev, regmap, phy_iso_link_ctrl_1);
106336ce4163SSwapnil Jakhade 		if (IS_ERR(field)) {
106436ce4163SSwapnil Jakhade 			dev_err(dev, "PHY_ISO_LINK_CTRL reg field init for lane %d failed\n", i);
106536ce4163SSwapnil Jakhade 			return PTR_ERR(field);
106636ce4163SSwapnil Jakhade 		}
106736ce4163SSwapnil Jakhade 		sp->phy_iso_link_ctrl_1[i] = field;
106836ce4163SSwapnil Jakhade 	}
106936ce4163SSwapnil Jakhade 
1070380f5708SKishon Vijay Abraham I 	return 0;
1071380f5708SKishon Vijay Abraham I }
1072380f5708SKishon Vijay Abraham I 
cdns_regmap_init_blocks(struct cdns_sierra_phy * sp,void __iomem * base,u8 block_offset_shift,u8 reg_offset_shift)1073380f5708SKishon Vijay Abraham I static int cdns_regmap_init_blocks(struct cdns_sierra_phy *sp,
1074380f5708SKishon Vijay Abraham I 				   void __iomem *base, u8 block_offset_shift,
1075380f5708SKishon Vijay Abraham I 				   u8 reg_offset_shift)
1076380f5708SKishon Vijay Abraham I {
1077380f5708SKishon Vijay Abraham I 	struct device *dev = sp->dev;
1078380f5708SKishon Vijay Abraham I 	struct regmap *regmap;
1079380f5708SKishon Vijay Abraham I 	u32 block_offset;
1080380f5708SKishon Vijay Abraham I 	int i;
1081380f5708SKishon Vijay Abraham I 
1082380f5708SKishon Vijay Abraham I 	for (i = 0; i < SIERRA_MAX_LANES; i++) {
1083380f5708SKishon Vijay Abraham I 		block_offset = SIERRA_LANE_CDB_OFFSET(i, block_offset_shift,
1084380f5708SKishon Vijay Abraham I 						      reg_offset_shift);
1085380f5708SKishon Vijay Abraham I 		regmap = cdns_regmap_init(dev, base, block_offset,
1086380f5708SKishon Vijay Abraham I 					  reg_offset_shift,
1087380f5708SKishon Vijay Abraham I 					  &cdns_sierra_lane_cdb_config[i]);
1088380f5708SKishon Vijay Abraham I 		if (IS_ERR(regmap)) {
1089380f5708SKishon Vijay Abraham I 			dev_err(dev, "Failed to init lane CDB regmap\n");
1090380f5708SKishon Vijay Abraham I 			return PTR_ERR(regmap);
1091380f5708SKishon Vijay Abraham I 		}
1092380f5708SKishon Vijay Abraham I 		sp->regmap_lane_cdb[i] = regmap;
1093380f5708SKishon Vijay Abraham I 	}
1094380f5708SKishon Vijay Abraham I 
1095380f5708SKishon Vijay Abraham I 	regmap = cdns_regmap_init(dev, base, SIERRA_COMMON_CDB_OFFSET,
1096380f5708SKishon Vijay Abraham I 				  reg_offset_shift,
1097380f5708SKishon Vijay Abraham I 				  &cdns_sierra_common_cdb_config);
1098380f5708SKishon Vijay Abraham I 	if (IS_ERR(regmap)) {
1099380f5708SKishon Vijay Abraham I 		dev_err(dev, "Failed to init common CDB regmap\n");
1100380f5708SKishon Vijay Abraham I 		return PTR_ERR(regmap);
1101380f5708SKishon Vijay Abraham I 	}
1102380f5708SKishon Vijay Abraham I 	sp->regmap_common_cdb = regmap;
1103380f5708SKishon Vijay Abraham I 
11048c95e172SSwapnil Jakhade 	block_offset = SIERRA_PHY_PCS_COMMON_OFFSET(block_offset_shift);
1105380f5708SKishon Vijay Abraham I 	regmap = cdns_regmap_init(dev, base, block_offset, reg_offset_shift,
11068c95e172SSwapnil Jakhade 				  &cdns_sierra_phy_pcs_cmn_cdb_config);
1107380f5708SKishon Vijay Abraham I 	if (IS_ERR(regmap)) {
11088c95e172SSwapnil Jakhade 		dev_err(dev, "Failed to init PHY PCS common CDB regmap\n");
1109380f5708SKishon Vijay Abraham I 		return PTR_ERR(regmap);
1110380f5708SKishon Vijay Abraham I 	}
11118c95e172SSwapnil Jakhade 	sp->regmap_phy_pcs_common_cdb = regmap;
1112380f5708SKishon Vijay Abraham I 
111336ce4163SSwapnil Jakhade 	for (i = 0; i < SIERRA_MAX_LANES; i++) {
111436ce4163SSwapnil Jakhade 		block_offset = SIERRA_PHY_PCS_LANE_CDB_OFFSET(i, block_offset_shift,
111536ce4163SSwapnil Jakhade 							      reg_offset_shift);
111636ce4163SSwapnil Jakhade 		regmap = cdns_regmap_init(dev, base, block_offset,
111736ce4163SSwapnil Jakhade 					  reg_offset_shift,
111836ce4163SSwapnil Jakhade 					  &cdns_sierra_phy_pcs_lane_cdb_config[i]);
111936ce4163SSwapnil Jakhade 		if (IS_ERR(regmap)) {
112036ce4163SSwapnil Jakhade 			dev_err(dev, "Failed to init PHY PCS lane CDB regmap\n");
112136ce4163SSwapnil Jakhade 			return PTR_ERR(regmap);
112236ce4163SSwapnil Jakhade 		}
112336ce4163SSwapnil Jakhade 		sp->regmap_phy_pcs_lane_cdb[i] = regmap;
112436ce4163SSwapnil Jakhade 	}
112536ce4163SSwapnil Jakhade 
1126f1cc6c3fSSwapnil Jakhade 	block_offset = SIERRA_PHY_PMA_COMMON_OFFSET(block_offset_shift);
1127f1cc6c3fSSwapnil Jakhade 	regmap = cdns_regmap_init(dev, base, block_offset, reg_offset_shift,
1128f1cc6c3fSSwapnil Jakhade 				  &cdns_sierra_phy_pma_cmn_cdb_config);
1129f1cc6c3fSSwapnil Jakhade 	if (IS_ERR(regmap)) {
1130f1cc6c3fSSwapnil Jakhade 		dev_err(dev, "Failed to init PHY PMA common CDB regmap\n");
1131f1cc6c3fSSwapnil Jakhade 		return PTR_ERR(regmap);
1132f1cc6c3fSSwapnil Jakhade 	}
1133f1cc6c3fSSwapnil Jakhade 	sp->regmap_phy_pma_common_cdb = regmap;
1134f1cc6c3fSSwapnil Jakhade 
11356b81f05aSSwapnil Jakhade 	for (i = 0; i < SIERRA_MAX_LANES; i++) {
11366b81f05aSSwapnil Jakhade 		block_offset = SIERRA_PHY_PMA_LANE_CDB_OFFSET(i, block_offset_shift,
11376b81f05aSSwapnil Jakhade 							      reg_offset_shift);
11386b81f05aSSwapnil Jakhade 		regmap = cdns_regmap_init(dev, base, block_offset,
11396b81f05aSSwapnil Jakhade 					  reg_offset_shift,
11406b81f05aSSwapnil Jakhade 					  &cdns_sierra_phy_pma_lane_cdb_config[i]);
11416b81f05aSSwapnil Jakhade 		if (IS_ERR(regmap)) {
11426b81f05aSSwapnil Jakhade 			dev_err(dev, "Failed to init PHY PMA lane CDB regmap\n");
11436b81f05aSSwapnil Jakhade 			return PTR_ERR(regmap);
11446b81f05aSSwapnil Jakhade 		}
11456b81f05aSSwapnil Jakhade 		sp->regmap_phy_pma_lane_cdb[i] = regmap;
11466b81f05aSSwapnil Jakhade 	}
11476b81f05aSSwapnil Jakhade 
1148380f5708SKishon Vijay Abraham I 	return 0;
1149380f5708SKishon Vijay Abraham I }
1150380f5708SKishon Vijay Abraham I 
cdns_sierra_phy_get_clocks(struct cdns_sierra_phy * sp,struct device * dev)11517e016cbcSKishon Vijay Abraham I static int cdns_sierra_phy_get_clocks(struct cdns_sierra_phy *sp,
11527e016cbcSKishon Vijay Abraham I 				      struct device *dev)
11537e016cbcSKishon Vijay Abraham I {
11547e016cbcSKishon Vijay Abraham I 	struct clk *clk;
11557e016cbcSKishon Vijay Abraham I 	int ret;
11567e016cbcSKishon Vijay Abraham I 
11577e016cbcSKishon Vijay Abraham I 	clk = devm_clk_get_optional(dev, "cmn_refclk_dig_div");
11587e016cbcSKishon Vijay Abraham I 	if (IS_ERR(clk)) {
11597e016cbcSKishon Vijay Abraham I 		dev_err(dev, "cmn_refclk_dig_div clock not found\n");
11607e016cbcSKishon Vijay Abraham I 		ret = PTR_ERR(clk);
11617e016cbcSKishon Vijay Abraham I 		return ret;
11627e016cbcSKishon Vijay Abraham I 	}
1163a0c30cd7SKishon Vijay Abraham I 	sp->input_clks[CMN_REFCLK_DIG_DIV] = clk;
11647e016cbcSKishon Vijay Abraham I 
11657e016cbcSKishon Vijay Abraham I 	clk = devm_clk_get_optional(dev, "cmn_refclk1_dig_div");
11667e016cbcSKishon Vijay Abraham I 	if (IS_ERR(clk)) {
11677e016cbcSKishon Vijay Abraham I 		dev_err(dev, "cmn_refclk1_dig_div clock not found\n");
11687e016cbcSKishon Vijay Abraham I 		ret = PTR_ERR(clk);
11697e016cbcSKishon Vijay Abraham I 		return ret;
11707e016cbcSKishon Vijay Abraham I 	}
1171a0c30cd7SKishon Vijay Abraham I 	sp->input_clks[CMN_REFCLK1_DIG_DIV] = clk;
11727e016cbcSKishon Vijay Abraham I 
11737e016cbcSKishon Vijay Abraham I 	return 0;
11747e016cbcSKishon Vijay Abraham I }
11757e016cbcSKishon Vijay Abraham I 
cdns_sierra_phy_clk(struct cdns_sierra_phy * sp)1176d88ca22dSAswath Govindraju static int cdns_sierra_phy_clk(struct cdns_sierra_phy *sp)
11771436ec30SKishon Vijay Abraham I {
1178d88ca22dSAswath Govindraju 	struct device *dev = sp->dev;
1179d88ca22dSAswath Govindraju 	struct clk *clk;
11801436ec30SKishon Vijay Abraham I 	int ret;
11811436ec30SKishon Vijay Abraham I 
1182d88ca22dSAswath Govindraju 	clk = devm_clk_get_optional(dev, "phy_clk");
1183d88ca22dSAswath Govindraju 	if (IS_ERR(clk)) {
1184d88ca22dSAswath Govindraju 		dev_err(dev, "failed to get clock phy_clk\n");
1185d88ca22dSAswath Govindraju 		return PTR_ERR(clk);
1186d88ca22dSAswath Govindraju 	}
1187d88ca22dSAswath Govindraju 	sp->input_clks[PHY_CLK] = clk;
1188d88ca22dSAswath Govindraju 
11891436ec30SKishon Vijay Abraham I 	ret = clk_prepare_enable(sp->input_clks[PHY_CLK]);
11901436ec30SKishon Vijay Abraham I 	if (ret)
11911436ec30SKishon Vijay Abraham I 		return ret;
11921436ec30SKishon Vijay Abraham I 
1193d88ca22dSAswath Govindraju 	return 0;
1194d88ca22dSAswath Govindraju }
1195d88ca22dSAswath Govindraju 
cdns_sierra_phy_enable_clocks(struct cdns_sierra_phy * sp)1196d88ca22dSAswath Govindraju static int cdns_sierra_phy_enable_clocks(struct cdns_sierra_phy *sp)
1197d88ca22dSAswath Govindraju {
1198d88ca22dSAswath Govindraju 	int ret;
1199d88ca22dSAswath Govindraju 
12006ef7aa32SLars-Peter Clausen 	ret = clk_prepare_enable(sp->pll_clks[CDNS_SIERRA_PLL_CMNLC]);
12011436ec30SKishon Vijay Abraham I 	if (ret)
1202d88ca22dSAswath Govindraju 		return ret;
12031436ec30SKishon Vijay Abraham I 
12046ef7aa32SLars-Peter Clausen 	ret = clk_prepare_enable(sp->pll_clks[CDNS_SIERRA_PLL_CMNLC1]);
12051436ec30SKishon Vijay Abraham I 	if (ret)
12061436ec30SKishon Vijay Abraham I 		goto err_pll_cmnlc1;
12071436ec30SKishon Vijay Abraham I 
12081436ec30SKishon Vijay Abraham I 	return 0;
12091436ec30SKishon Vijay Abraham I 
12101436ec30SKishon Vijay Abraham I err_pll_cmnlc1:
12116ef7aa32SLars-Peter Clausen 	clk_disable_unprepare(sp->pll_clks[CDNS_SIERRA_PLL_CMNLC]);
12121436ec30SKishon Vijay Abraham I 
12131436ec30SKishon Vijay Abraham I 	return ret;
12141436ec30SKishon Vijay Abraham I }
12151436ec30SKishon Vijay Abraham I 
cdns_sierra_phy_disable_clocks(struct cdns_sierra_phy * sp)12161436ec30SKishon Vijay Abraham I static void cdns_sierra_phy_disable_clocks(struct cdns_sierra_phy *sp)
12171436ec30SKishon Vijay Abraham I {
12186ef7aa32SLars-Peter Clausen 	clk_disable_unprepare(sp->pll_clks[CDNS_SIERRA_PLL_CMNLC1]);
12196ef7aa32SLars-Peter Clausen 	clk_disable_unprepare(sp->pll_clks[CDNS_SIERRA_PLL_CMNLC]);
1220d88ca22dSAswath Govindraju 	if (!sp->already_configured)
12211436ec30SKishon Vijay Abraham I 		clk_disable_unprepare(sp->input_clks[PHY_CLK]);
12221436ec30SKishon Vijay Abraham I }
12231436ec30SKishon Vijay Abraham I 
cdns_sierra_phy_get_resets(struct cdns_sierra_phy * sp,struct device * dev)12241d5f40e0SKishon Vijay Abraham I static int cdns_sierra_phy_get_resets(struct cdns_sierra_phy *sp,
12251d5f40e0SKishon Vijay Abraham I 				      struct device *dev)
12261d5f40e0SKishon Vijay Abraham I {
12271d5f40e0SKishon Vijay Abraham I 	struct reset_control *rst;
12281d5f40e0SKishon Vijay Abraham I 
122915b0b82dSKishon Vijay Abraham I 	rst = devm_reset_control_get_exclusive(dev, "sierra_reset");
12301d5f40e0SKishon Vijay Abraham I 	if (IS_ERR(rst)) {
12311d5f40e0SKishon Vijay Abraham I 		dev_err(dev, "failed to get reset\n");
12321d5f40e0SKishon Vijay Abraham I 		return PTR_ERR(rst);
12331d5f40e0SKishon Vijay Abraham I 	}
12341d5f40e0SKishon Vijay Abraham I 	sp->phy_rst = rst;
12351d5f40e0SKishon Vijay Abraham I 
123615b0b82dSKishon Vijay Abraham I 	rst = devm_reset_control_get_optional_exclusive(dev, "sierra_apb");
12371d5f40e0SKishon Vijay Abraham I 	if (IS_ERR(rst)) {
12381d5f40e0SKishon Vijay Abraham I 		dev_err(dev, "failed to get apb reset\n");
12391d5f40e0SKishon Vijay Abraham I 		return PTR_ERR(rst);
12401d5f40e0SKishon Vijay Abraham I 	}
12411d5f40e0SKishon Vijay Abraham I 	sp->apb_rst = rst;
12421d5f40e0SKishon Vijay Abraham I 
12431d5f40e0SKishon Vijay Abraham I 	return 0;
12441d5f40e0SKishon Vijay Abraham I }
12451d5f40e0SKishon Vijay Abraham I 
cdns_sierra_phy_configure_multilink(struct cdns_sierra_phy * sp)12466b81f05aSSwapnil Jakhade static int cdns_sierra_phy_configure_multilink(struct cdns_sierra_phy *sp)
12476b81f05aSSwapnil Jakhade {
1248da41bac5SChristophe JAILLET 	const struct cdns_sierra_vals *pma_cmn_vals, *pma_ln_vals;
12496b81f05aSSwapnil Jakhade 	const struct cdns_sierra_data *init_data = sp->init_data;
1250da41bac5SChristophe JAILLET 	const struct cdns_sierra_vals *phy_pma_ln_vals;
1251da41bac5SChristophe JAILLET 	const struct cdns_sierra_vals *pcs_cmn_vals;
12526b81f05aSSwapnil Jakhade 	enum cdns_sierra_phy_type phy_t1, phy_t2;
12536b81f05aSSwapnil Jakhade 	const struct cdns_reg_pairs *reg_pairs;
12546b81f05aSSwapnil Jakhade 	int i, j, node, mlane, num_lanes, ret;
12556b81f05aSSwapnil Jakhade 	enum cdns_sierra_ssc_mode ssc;
12566b81f05aSSwapnil Jakhade 	struct regmap *regmap;
12576b81f05aSSwapnil Jakhade 	u32 num_regs;
12586b81f05aSSwapnil Jakhade 
12596b81f05aSSwapnil Jakhade 	/* Maximum 2 links (subnodes) are supported */
12606b81f05aSSwapnil Jakhade 	if (sp->nsubnodes != 2)
12616b81f05aSSwapnil Jakhade 		return -EINVAL;
12626b81f05aSSwapnil Jakhade 
12636b81f05aSSwapnil Jakhade 	clk_set_rate(sp->input_clks[CMN_REFCLK_DIG_DIV], 25000000);
12646b81f05aSSwapnil Jakhade 	clk_set_rate(sp->input_clks[CMN_REFCLK1_DIG_DIV], 25000000);
12656b81f05aSSwapnil Jakhade 
12666b81f05aSSwapnil Jakhade 	/* PHY configured to use both PLL LC and LC1 */
12676b81f05aSSwapnil Jakhade 	regmap_field_write(sp->phy_pll_cfg_1, 0x1);
12686b81f05aSSwapnil Jakhade 
12696b81f05aSSwapnil Jakhade 	phy_t1 = sp->phys[0].phy_type;
12706b81f05aSSwapnil Jakhade 	phy_t2 = sp->phys[1].phy_type;
12716b81f05aSSwapnil Jakhade 
12726b81f05aSSwapnil Jakhade 	/*
12736b81f05aSSwapnil Jakhade 	 * PHY configuration for multi-link operation is done in two steps.
12746b81f05aSSwapnil Jakhade 	 * e.g. Consider a case for a 4 lane PHY with PCIe using 2 lanes and QSGMII other 2 lanes.
12756b81f05aSSwapnil Jakhade 	 * Sierra PHY has 2 PLLs, viz. PLLLC and PLLLC1. So in this case, PLLLC is used for PCIe
12766b81f05aSSwapnil Jakhade 	 * and PLLLC1 is used for QSGMII. PHY is configured in two steps as described below.
12776b81f05aSSwapnil Jakhade 	 *
12786b81f05aSSwapnil Jakhade 	 * [1] For first step, phy_t1 = TYPE_PCIE and phy_t2 = TYPE_QSGMII
12796b81f05aSSwapnil Jakhade 	 *     So the register values are selected as [TYPE_PCIE][TYPE_QSGMII][ssc].
12806b81f05aSSwapnil Jakhade 	 *     This will configure PHY registers associated for PCIe (i.e. first protocol)
12816b81f05aSSwapnil Jakhade 	 *     involving PLLLC registers and registers for first 2 lanes of PHY.
12826b81f05aSSwapnil Jakhade 	 * [2] In second step, the variables phy_t1 and phy_t2 are swapped. So now,
12836b81f05aSSwapnil Jakhade 	 *     phy_t1 = TYPE_QSGMII and phy_t2 = TYPE_PCIE. And the register values are selected as
12846b81f05aSSwapnil Jakhade 	 *     [TYPE_QSGMII][TYPE_PCIE][ssc].
12856b81f05aSSwapnil Jakhade 	 *     This will configure PHY registers associated for QSGMII (i.e. second protocol)
12866b81f05aSSwapnil Jakhade 	 *     involving PLLLC1 registers and registers for other 2 lanes of PHY.
12876b81f05aSSwapnil Jakhade 	 *
12886b81f05aSSwapnil Jakhade 	 * This completes the PHY configuration for multilink operation. This approach enables
12896b81f05aSSwapnil Jakhade 	 * dividing the large number of PHY register configurations into protocol specific
12906b81f05aSSwapnil Jakhade 	 * smaller groups.
12916b81f05aSSwapnil Jakhade 	 */
12926b81f05aSSwapnil Jakhade 	for (node = 0; node < sp->nsubnodes; node++) {
12936b81f05aSSwapnil Jakhade 		if (node == 1) {
12946b81f05aSSwapnil Jakhade 			/*
12956b81f05aSSwapnil Jakhade 			 * If first link with phy_t1 is configured, then configure the PHY for
12966b81f05aSSwapnil Jakhade 			 * second link with phy_t2. Get the array values as [phy_t2][phy_t1][ssc].
12976b81f05aSSwapnil Jakhade 			 */
12986b81f05aSSwapnil Jakhade 			swap(phy_t1, phy_t2);
12996b81f05aSSwapnil Jakhade 		}
13006b81f05aSSwapnil Jakhade 
13016b81f05aSSwapnil Jakhade 		mlane = sp->phys[node].mlane;
13026b81f05aSSwapnil Jakhade 		ssc = sp->phys[node].ssc_mode;
13036b81f05aSSwapnil Jakhade 		num_lanes = sp->phys[node].num_lanes;
13046b81f05aSSwapnil Jakhade 
13056b81f05aSSwapnil Jakhade 		/* PHY PCS common registers configurations */
13066b81f05aSSwapnil Jakhade 		pcs_cmn_vals = init_data->pcs_cmn_vals[phy_t1][phy_t2][ssc];
13076b81f05aSSwapnil Jakhade 		if (pcs_cmn_vals) {
13086b81f05aSSwapnil Jakhade 			reg_pairs = pcs_cmn_vals->reg_pairs;
13096b81f05aSSwapnil Jakhade 			num_regs = pcs_cmn_vals->num_regs;
13106b81f05aSSwapnil Jakhade 			regmap = sp->regmap_phy_pcs_common_cdb;
13116b81f05aSSwapnil Jakhade 			for (i = 0; i < num_regs; i++)
13126b81f05aSSwapnil Jakhade 				regmap_write(regmap, reg_pairs[i].off, reg_pairs[i].val);
13136b81f05aSSwapnil Jakhade 		}
13146b81f05aSSwapnil Jakhade 
13156b81f05aSSwapnil Jakhade 		/* PHY PMA lane registers configurations */
13166b81f05aSSwapnil Jakhade 		phy_pma_ln_vals = init_data->phy_pma_ln_vals[phy_t1][phy_t2][ssc];
13176b81f05aSSwapnil Jakhade 		if (phy_pma_ln_vals) {
13186b81f05aSSwapnil Jakhade 			reg_pairs = phy_pma_ln_vals->reg_pairs;
13196b81f05aSSwapnil Jakhade 			num_regs = phy_pma_ln_vals->num_regs;
13206b81f05aSSwapnil Jakhade 			for (i = 0; i < num_lanes; i++) {
13216b81f05aSSwapnil Jakhade 				regmap = sp->regmap_phy_pma_lane_cdb[i + mlane];
13226b81f05aSSwapnil Jakhade 				for (j = 0; j < num_regs; j++)
13236b81f05aSSwapnil Jakhade 					regmap_write(regmap, reg_pairs[j].off, reg_pairs[j].val);
13246b81f05aSSwapnil Jakhade 			}
13256b81f05aSSwapnil Jakhade 		}
13266b81f05aSSwapnil Jakhade 
13276b81f05aSSwapnil Jakhade 		/* PMA common registers configurations */
13286b81f05aSSwapnil Jakhade 		pma_cmn_vals = init_data->pma_cmn_vals[phy_t1][phy_t2][ssc];
13296b81f05aSSwapnil Jakhade 		if (pma_cmn_vals) {
13306b81f05aSSwapnil Jakhade 			reg_pairs = pma_cmn_vals->reg_pairs;
13316b81f05aSSwapnil Jakhade 			num_regs = pma_cmn_vals->num_regs;
13326b81f05aSSwapnil Jakhade 			regmap = sp->regmap_common_cdb;
13336b81f05aSSwapnil Jakhade 			for (i = 0; i < num_regs; i++)
13346b81f05aSSwapnil Jakhade 				regmap_write(regmap, reg_pairs[i].off, reg_pairs[i].val);
13356b81f05aSSwapnil Jakhade 		}
13366b81f05aSSwapnil Jakhade 
13376b81f05aSSwapnil Jakhade 		/* PMA lane registers configurations */
13386b81f05aSSwapnil Jakhade 		pma_ln_vals = init_data->pma_ln_vals[phy_t1][phy_t2][ssc];
13396b81f05aSSwapnil Jakhade 		if (pma_ln_vals) {
13406b81f05aSSwapnil Jakhade 			reg_pairs = pma_ln_vals->reg_pairs;
13416b81f05aSSwapnil Jakhade 			num_regs = pma_ln_vals->num_regs;
13426b81f05aSSwapnil Jakhade 			for (i = 0; i < num_lanes; i++) {
13436b81f05aSSwapnil Jakhade 				regmap = sp->regmap_lane_cdb[i + mlane];
13446b81f05aSSwapnil Jakhade 				for (j = 0; j < num_regs; j++)
13456b81f05aSSwapnil Jakhade 					regmap_write(regmap, reg_pairs[j].off, reg_pairs[j].val);
13466b81f05aSSwapnil Jakhade 			}
13476b81f05aSSwapnil Jakhade 		}
13488a1b82d7SSwapnil Jakhade 
13490cfa43abSSwapnil Jakhade 		if (phy_t1 == TYPE_SGMII || phy_t1 == TYPE_QSGMII)
13508a1b82d7SSwapnil Jakhade 			reset_control_deassert(sp->phys[node].lnk_rst);
13516b81f05aSSwapnil Jakhade 	}
13526b81f05aSSwapnil Jakhade 
13536b81f05aSSwapnil Jakhade 	/* Take the PHY out of reset */
13546b81f05aSSwapnil Jakhade 	ret = reset_control_deassert(sp->phy_rst);
13556b81f05aSSwapnil Jakhade 	if (ret)
13566b81f05aSSwapnil Jakhade 		return ret;
13576b81f05aSSwapnil Jakhade 
13586b81f05aSSwapnil Jakhade 	return 0;
13596b81f05aSSwapnil Jakhade }
13606b81f05aSSwapnil Jakhade 
cdns_sierra_phy_probe(struct platform_device * pdev)136144d30d62SAlan Douglas static int cdns_sierra_phy_probe(struct platform_device *pdev)
136244d30d62SAlan Douglas {
136344d30d62SAlan Douglas 	struct cdns_sierra_phy *sp;
136444d30d62SAlan Douglas 	struct phy_provider *phy_provider;
136544d30d62SAlan Douglas 	struct device *dev = &pdev->dev;
1366c3c11d55SSwapnil Jakhade 	const struct cdns_sierra_data *data;
1367380f5708SKishon Vijay Abraham I 	unsigned int id_value;
136829afbd76SDan Carpenter 	int ret, node = 0;
1369380f5708SKishon Vijay Abraham I 	void __iomem *base;
1370612f9fcbSKrzysztof Kozlowski 	struct device_node *dn = dev->of_node;
137144d30d62SAlan Douglas 
137244d30d62SAlan Douglas 	if (of_get_child_count(dn) == 0)
137344d30d62SAlan Douglas 		return -ENODEV;
137444d30d62SAlan Douglas 
1375380f5708SKishon Vijay Abraham I 	/* Get init data for this PHY */
1376c3c11d55SSwapnil Jakhade 	data = of_device_get_match_data(dev);
1377c3c11d55SSwapnil Jakhade 	if (!data)
1378380f5708SKishon Vijay Abraham I 		return -EINVAL;
1379380f5708SKishon Vijay Abraham I 
13806ef7aa32SLars-Peter Clausen 	sp = devm_kzalloc(dev, struct_size(sp, clk_data.hws,
13816ef7aa32SLars-Peter Clausen 					   CDNS_SIERRA_OUTPUT_CLOCKS),
13826ef7aa32SLars-Peter Clausen 			  GFP_KERNEL);
138344d30d62SAlan Douglas 	if (!sp)
138444d30d62SAlan Douglas 		return -ENOMEM;
138544d30d62SAlan Douglas 	dev_set_drvdata(dev, sp);
138644d30d62SAlan Douglas 	sp->dev = dev;
1387380f5708SKishon Vijay Abraham I 	sp->init_data = data;
138844d30d62SAlan Douglas 
1389fa629094SChunfeng Yun 	base = devm_platform_ioremap_resource(pdev, 0);
1390380f5708SKishon Vijay Abraham I 	if (IS_ERR(base)) {
139144d30d62SAlan Douglas 		dev_err(dev, "missing \"reg\"\n");
1392380f5708SKishon Vijay Abraham I 		return PTR_ERR(base);
139344d30d62SAlan Douglas 	}
139444d30d62SAlan Douglas 
1395380f5708SKishon Vijay Abraham I 	ret = cdns_regmap_init_blocks(sp, base, data->block_offset_shift,
1396380f5708SKishon Vijay Abraham I 				      data->reg_offset_shift);
1397380f5708SKishon Vijay Abraham I 	if (ret)
1398380f5708SKishon Vijay Abraham I 		return ret;
1399380f5708SKishon Vijay Abraham I 
1400380f5708SKishon Vijay Abraham I 	ret = cdns_regfield_init(sp);
1401380f5708SKishon Vijay Abraham I 	if (ret)
1402380f5708SKishon Vijay Abraham I 		return ret;
140344d30d62SAlan Douglas 
140444d30d62SAlan Douglas 	platform_set_drvdata(pdev, sp);
140544d30d62SAlan Douglas 
14067e016cbcSKishon Vijay Abraham I 	ret = cdns_sierra_phy_get_clocks(sp, dev);
14077e016cbcSKishon Vijay Abraham I 	if (ret)
14087e016cbcSKishon Vijay Abraham I 		return ret;
140944d30d62SAlan Douglas 
141028081b72SKishon Vijay Abraham I 	ret = cdns_sierra_clk_register(sp);
14111d5f40e0SKishon Vijay Abraham I 	if (ret)
14121d5f40e0SKishon Vijay Abraham I 		return ret;
141344d30d62SAlan Douglas 
14141436ec30SKishon Vijay Abraham I 	ret = cdns_sierra_phy_enable_clocks(sp);
141544d30d62SAlan Douglas 	if (ret)
141628081b72SKishon Vijay Abraham I 		goto unregister_clk;
141744d30d62SAlan Douglas 
1418d88ca22dSAswath Govindraju 	regmap_field_read(sp->pma_cmn_ready, &sp->already_configured);
1419d88ca22dSAswath Govindraju 
1420d88ca22dSAswath Govindraju 	if (!sp->already_configured) {
1421d88ca22dSAswath Govindraju 		ret = cdns_sierra_phy_clk(sp);
1422d88ca22dSAswath Govindraju 		if (ret)
1423d88ca22dSAswath Govindraju 			goto clk_disable;
1424d88ca22dSAswath Govindraju 
1425d88ca22dSAswath Govindraju 		ret = cdns_sierra_phy_get_resets(sp, dev);
1426d88ca22dSAswath Govindraju 		if (ret)
1427d88ca22dSAswath Govindraju 			goto clk_disable;
1428d88ca22dSAswath Govindraju 
142944d30d62SAlan Douglas 		/* Enable APB */
143044d30d62SAlan Douglas 		reset_control_deassert(sp->apb_rst);
1431d88ca22dSAswath Govindraju 	}
143244d30d62SAlan Douglas 
143344d30d62SAlan Douglas 	/* Check that PHY is present */
1434380f5708SKishon Vijay Abraham I 	regmap_field_read(sp->macro_id_type, &id_value);
1435380f5708SKishon Vijay Abraham I 	if  (sp->init_data->id_value != id_value) {
143644d30d62SAlan Douglas 		ret = -EINVAL;
1437d88ca22dSAswath Govindraju 		goto ctrl_assert;
143844d30d62SAlan Douglas 	}
143944d30d62SAlan Douglas 
144044d30d62SAlan Douglas 	sp->autoconf = of_property_read_bool(dn, "cdns,autoconf");
144144d30d62SAlan Douglas 
1442612f9fcbSKrzysztof Kozlowski 	for_each_available_child_of_node_scoped(dn, child) {
144344d30d62SAlan Douglas 		struct phy *gphy;
144444d30d62SAlan Douglas 
144503ada5a3SKishon Vijay Abraham I 		if (!(of_node_name_eq(child, "phy") ||
144603ada5a3SKishon Vijay Abraham I 		      of_node_name_eq(child, "link")))
144703ada5a3SKishon Vijay Abraham I 			continue;
144803ada5a3SKishon Vijay Abraham I 
144944d30d62SAlan Douglas 		sp->phys[node].lnk_rst =
1450b872936fSKishon Vijay Abraham I 			of_reset_control_array_get_exclusive(child);
145144d30d62SAlan Douglas 
145244d30d62SAlan Douglas 		if (IS_ERR(sp->phys[node].lnk_rst)) {
145344d30d62SAlan Douglas 			dev_err(dev, "failed to get reset %s\n",
145444d30d62SAlan Douglas 				child->full_name);
145544d30d62SAlan Douglas 			ret = PTR_ERR(sp->phys[node].lnk_rst);
145629afbd76SDan Carpenter 			goto put_control;
145744d30d62SAlan Douglas 		}
145844d30d62SAlan Douglas 
145944d30d62SAlan Douglas 		if (!sp->autoconf) {
146044d30d62SAlan Douglas 			ret = cdns_sierra_get_optional(&sp->phys[node], child);
146144d30d62SAlan Douglas 			if (ret) {
146244d30d62SAlan Douglas 				dev_err(dev, "missing property in node %s\n",
146344d30d62SAlan Douglas 					child->name);
146429afbd76SDan Carpenter 				reset_control_put(sp->phys[node].lnk_rst);
146529afbd76SDan Carpenter 				goto put_control;
146644d30d62SAlan Douglas 			}
146744d30d62SAlan Douglas 		}
146844d30d62SAlan Douglas 
1469a43f72aeSKishon Vijay Abraham I 		sp->num_lanes += sp->phys[node].num_lanes;
1470a43f72aeSKishon Vijay Abraham I 
1471d88ca22dSAswath Govindraju 		if (!sp->already_configured)
147244d30d62SAlan Douglas 			gphy = devm_phy_create(dev, child, &ops);
1473d88ca22dSAswath Govindraju 		else
1474d88ca22dSAswath Govindraju 			gphy = devm_phy_create(dev, child, &noop_ops);
147544d30d62SAlan Douglas 		if (IS_ERR(gphy)) {
147644d30d62SAlan Douglas 			ret = PTR_ERR(gphy);
147729afbd76SDan Carpenter 			reset_control_put(sp->phys[node].lnk_rst);
147829afbd76SDan Carpenter 			goto put_control;
147944d30d62SAlan Douglas 		}
148044d30d62SAlan Douglas 		sp->phys[node].phy = gphy;
148144d30d62SAlan Douglas 		phy_set_drvdata(gphy, &sp->phys[node]);
148244d30d62SAlan Douglas 
148344d30d62SAlan Douglas 		node++;
148444d30d62SAlan Douglas 	}
148544d30d62SAlan Douglas 	sp->nsubnodes = node;
148644d30d62SAlan Douglas 
1487a43f72aeSKishon Vijay Abraham I 	if (sp->num_lanes > SIERRA_MAX_LANES) {
14886411e386SWang Wensheng 		ret = -EINVAL;
1489a43f72aeSKishon Vijay Abraham I 		dev_err(dev, "Invalid lane configuration\n");
149029afbd76SDan Carpenter 		goto put_control;
1491a43f72aeSKishon Vijay Abraham I 	}
1492a43f72aeSKishon Vijay Abraham I 
149344d30d62SAlan Douglas 	/* If more than one subnode, configure the PHY as multilink */
1494d88ca22dSAswath Govindraju 	if (!sp->already_configured && !sp->autoconf && sp->nsubnodes > 1) {
14956b81f05aSSwapnil Jakhade 		ret = cdns_sierra_phy_configure_multilink(sp);
14966b81f05aSSwapnil Jakhade 		if (ret)
149729afbd76SDan Carpenter 			goto put_control;
14986b81f05aSSwapnil Jakhade 	}
149944d30d62SAlan Douglas 
150044d30d62SAlan Douglas 	pm_runtime_enable(dev);
150144d30d62SAlan Douglas 	phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
150229afbd76SDan Carpenter 	if (IS_ERR(phy_provider)) {
150329afbd76SDan Carpenter 		ret = PTR_ERR(phy_provider);
150429afbd76SDan Carpenter 		goto put_control;
150529afbd76SDan Carpenter 	}
150644d30d62SAlan Douglas 
150729afbd76SDan Carpenter 	return 0;
150829afbd76SDan Carpenter 
150929afbd76SDan Carpenter put_control:
151029afbd76SDan Carpenter 	while (--node >= 0)
151129afbd76SDan Carpenter 		reset_control_put(sp->phys[node].lnk_rst);
1512d88ca22dSAswath Govindraju ctrl_assert:
1513d88ca22dSAswath Govindraju 	if (!sp->already_configured)
1514d88ca22dSAswath Govindraju 		reset_control_assert(sp->apb_rst);
151544d30d62SAlan Douglas clk_disable:
15161436ec30SKishon Vijay Abraham I 	cdns_sierra_phy_disable_clocks(sp);
151728081b72SKishon Vijay Abraham I unregister_clk:
151828081b72SKishon Vijay Abraham I 	cdns_sierra_clk_unregister(sp);
151944d30d62SAlan Douglas 	return ret;
152044d30d62SAlan Douglas }
152144d30d62SAlan Douglas 
cdns_sierra_phy_remove(struct platform_device * pdev)1522e9ddb1adSUwe Kleine-König static void cdns_sierra_phy_remove(struct platform_device *pdev)
152344d30d62SAlan Douglas {
1524748e3456SKishon Vijay Abraham I 	struct cdns_sierra_phy *phy = platform_get_drvdata(pdev);
152544d30d62SAlan Douglas 	int i;
152644d30d62SAlan Douglas 
152744d30d62SAlan Douglas 	reset_control_assert(phy->phy_rst);
152844d30d62SAlan Douglas 	reset_control_assert(phy->apb_rst);
152944d30d62SAlan Douglas 	pm_runtime_disable(&pdev->dev);
153044d30d62SAlan Douglas 
15311436ec30SKishon Vijay Abraham I 	cdns_sierra_phy_disable_clocks(phy);
153244d30d62SAlan Douglas 	/*
153344d30d62SAlan Douglas 	 * The device level resets will be put automatically.
153444d30d62SAlan Douglas 	 * Need to put the subnode resets here though.
153544d30d62SAlan Douglas 	 */
153644d30d62SAlan Douglas 	for (i = 0; i < phy->nsubnodes; i++) {
153744d30d62SAlan Douglas 		reset_control_assert(phy->phys[i].lnk_rst);
153844d30d62SAlan Douglas 		reset_control_put(phy->phys[i].lnk_rst);
153944d30d62SAlan Douglas 	}
154029c2d02aSKishon Vijay Abraham I 
154128081b72SKishon Vijay Abraham I 	cdns_sierra_clk_unregister(phy);
154244d30d62SAlan Douglas }
154344d30d62SAlan Douglas 
15440cfa43abSSwapnil Jakhade /* SGMII PHY PMA lane configuration */
154529f33f0bSChristophe JAILLET static const struct cdns_reg_pairs sgmii_phy_pma_ln_regs[] = {
15460cfa43abSSwapnil Jakhade 	{0x9010, SIERRA_PHY_PMA_XCVR_CTRL}
15470cfa43abSSwapnil Jakhade };
15480cfa43abSSwapnil Jakhade 
1549da41bac5SChristophe JAILLET static const struct cdns_sierra_vals sgmii_phy_pma_ln_vals = {
15500cfa43abSSwapnil Jakhade 	.reg_pairs = sgmii_phy_pma_ln_regs,
15510cfa43abSSwapnil Jakhade 	.num_regs = ARRAY_SIZE(sgmii_phy_pma_ln_regs),
15520cfa43abSSwapnil Jakhade };
15530cfa43abSSwapnil Jakhade 
15540cfa43abSSwapnil Jakhade /* SGMII refclk 100MHz, no ssc, opt3 and GE1 links using PLL LC1 */
15550cfa43abSSwapnil Jakhade static const struct cdns_reg_pairs sgmii_100_no_ssc_plllc1_opt3_cmn_regs[] = {
15560cfa43abSSwapnil Jakhade 	{0x002D, SIERRA_CMN_PLLLC1_FBDIV_INT_PREG},
15570cfa43abSSwapnil Jakhade 	{0x2085, SIERRA_CMN_PLLLC1_LF_COEFF_MODE0_PREG},
15580cfa43abSSwapnil Jakhade 	{0x1005, SIERRA_CMN_PLLLC1_CLK0_PREG},
15590cfa43abSSwapnil Jakhade 	{0x0000, SIERRA_CMN_PLLLC1_BWCAL_MODE0_PREG},
15600cfa43abSSwapnil Jakhade 	{0x0800, SIERRA_CMN_PLLLC1_SS_TIME_STEPSIZE_MODE_PREG}
15610cfa43abSSwapnil Jakhade };
15620cfa43abSSwapnil Jakhade 
15630cfa43abSSwapnil Jakhade static const struct cdns_reg_pairs sgmii_100_no_ssc_plllc1_opt3_ln_regs[] = {
15640cfa43abSSwapnil Jakhade 	{0x688E, SIERRA_DET_STANDEC_D_PREG},
15650cfa43abSSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_IDLE_PREG},
15660cfa43abSSwapnil Jakhade 	{0x0FFE, SIERRA_PSC_RX_A0_PREG},
15670cfa43abSSwapnil Jakhade 	{0x0106, SIERRA_PLLCTRL_FBDIV_MODE01_PREG},
15680cfa43abSSwapnil Jakhade 	{0x0013, SIERRA_PLLCTRL_SUBRATE_PREG},
15690cfa43abSSwapnil Jakhade 	{0x0003, SIERRA_PLLCTRL_GEN_A_PREG},
15700cfa43abSSwapnil Jakhade 	{0x0106, SIERRA_PLLCTRL_GEN_D_PREG},
15710cfa43abSSwapnil Jakhade 	{0x5231, SIERRA_PLLCTRL_CPGAIN_MODE_PREG },
15720cfa43abSSwapnil Jakhade 	{0x0000, SIERRA_DRVCTRL_ATTEN_PREG},
15730cfa43abSSwapnil Jakhade 	{0x9702, SIERRA_DRVCTRL_BOOST_PREG},
15740cfa43abSSwapnil Jakhade 	{0x0051, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
15750cfa43abSSwapnil Jakhade 	{0x3C0E, SIERRA_CREQ_CCLKDET_MODE01_PREG},
15760cfa43abSSwapnil Jakhade 	{0x3220, SIERRA_CREQ_FSMCLK_SEL_PREG},
15770cfa43abSSwapnil Jakhade 	{0x0000, SIERRA_CREQ_EQ_CTRL_PREG},
15780cfa43abSSwapnil Jakhade 	{0x0002, SIERRA_DEQ_PHALIGN_CTRL},
15790cfa43abSSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT0},
15800cfa43abSSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT1},
15810cfa43abSSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT2},
15820cfa43abSSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT3},
15830cfa43abSSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT4},
15840cfa43abSSwapnil Jakhade 	{0x0861, SIERRA_DEQ_ALUT0},
15850cfa43abSSwapnil Jakhade 	{0x07E0, SIERRA_DEQ_ALUT1},
15860cfa43abSSwapnil Jakhade 	{0x079E, SIERRA_DEQ_ALUT2},
15870cfa43abSSwapnil Jakhade 	{0x071D, SIERRA_DEQ_ALUT3},
15880cfa43abSSwapnil Jakhade 	{0x03F5, SIERRA_DEQ_DFETAP_CTRL_PREG},
15890cfa43abSSwapnil Jakhade 	{0x0C01, SIERRA_DEQ_TAU_CTRL1_FAST_MAINT_PREG},
15900cfa43abSSwapnil Jakhade 	{0x3C40, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG},
15910cfa43abSSwapnil Jakhade 	{0x1C04, SIERRA_DEQ_TAU_CTRL2_PREG},
15920cfa43abSSwapnil Jakhade 	{0x0033, SIERRA_DEQ_PICTRL_PREG},
15930cfa43abSSwapnil Jakhade 	{0x0000, SIERRA_CPI_OUTBUF_RATESEL_PREG},
15940cfa43abSSwapnil Jakhade 	{0x0B6D, SIERRA_CPI_RESBIAS_BIN_PREG},
15950cfa43abSSwapnil Jakhade 	{0x0102, SIERRA_RXBUFFER_CTLECTRL_PREG},
15960cfa43abSSwapnil Jakhade 	{0x0002, SIERRA_RXBUFFER_RCDFECTRL_PREG}
15970cfa43abSSwapnil Jakhade };
15980cfa43abSSwapnil Jakhade 
1599da41bac5SChristophe JAILLET static const struct cdns_sierra_vals sgmii_100_no_ssc_plllc1_opt3_cmn_vals = {
16000cfa43abSSwapnil Jakhade 	.reg_pairs = sgmii_100_no_ssc_plllc1_opt3_cmn_regs,
16010cfa43abSSwapnil Jakhade 	.num_regs = ARRAY_SIZE(sgmii_100_no_ssc_plllc1_opt3_cmn_regs),
16020cfa43abSSwapnil Jakhade };
16030cfa43abSSwapnil Jakhade 
1604da41bac5SChristophe JAILLET static const struct cdns_sierra_vals sgmii_100_no_ssc_plllc1_opt3_ln_vals = {
16050cfa43abSSwapnil Jakhade 	.reg_pairs = sgmii_100_no_ssc_plllc1_opt3_ln_regs,
16060cfa43abSSwapnil Jakhade 	.num_regs = ARRAY_SIZE(sgmii_100_no_ssc_plllc1_opt3_ln_regs),
16070cfa43abSSwapnil Jakhade };
16080cfa43abSSwapnil Jakhade 
16098a1b82d7SSwapnil Jakhade /* QSGMII PHY PMA lane configuration */
161029f33f0bSChristophe JAILLET static const struct cdns_reg_pairs qsgmii_phy_pma_ln_regs[] = {
16118a1b82d7SSwapnil Jakhade 	{0x9010, SIERRA_PHY_PMA_XCVR_CTRL}
16128a1b82d7SSwapnil Jakhade };
16138a1b82d7SSwapnil Jakhade 
1614da41bac5SChristophe JAILLET static const struct cdns_sierra_vals qsgmii_phy_pma_ln_vals = {
16158a1b82d7SSwapnil Jakhade 	.reg_pairs = qsgmii_phy_pma_ln_regs,
16168a1b82d7SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(qsgmii_phy_pma_ln_regs),
16178a1b82d7SSwapnil Jakhade };
16188a1b82d7SSwapnil Jakhade 
16198a1b82d7SSwapnil Jakhade /* QSGMII refclk 100MHz, 20b, opt1, No BW cal, no ssc, PLL LC1 */
16208a1b82d7SSwapnil Jakhade static const struct cdns_reg_pairs qsgmii_100_no_ssc_plllc1_cmn_regs[] = {
16218a1b82d7SSwapnil Jakhade 	{0x2085, SIERRA_CMN_PLLLC1_LF_COEFF_MODE0_PREG},
16228a1b82d7SSwapnil Jakhade 	{0x0000, SIERRA_CMN_PLLLC1_BWCAL_MODE0_PREG},
16238a1b82d7SSwapnil Jakhade 	{0x0000, SIERRA_CMN_PLLLC1_SS_TIME_STEPSIZE_MODE_PREG}
16248a1b82d7SSwapnil Jakhade };
16258a1b82d7SSwapnil Jakhade 
16268a1b82d7SSwapnil Jakhade static const struct cdns_reg_pairs qsgmii_100_no_ssc_plllc1_ln_regs[] = {
16278a1b82d7SSwapnil Jakhade 	{0xFC08, SIERRA_DET_STANDEC_A_PREG},
16288a1b82d7SSwapnil Jakhade 	{0x0252, SIERRA_DET_STANDEC_E_PREG},
16298a1b82d7SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_IDLE_PREG},
16308a1b82d7SSwapnil Jakhade 	{0x0FFE, SIERRA_PSC_RX_A0_PREG},
16318a1b82d7SSwapnil Jakhade 	{0x0011, SIERRA_PLLCTRL_SUBRATE_PREG},
16328a1b82d7SSwapnil Jakhade 	{0x0001, SIERRA_PLLCTRL_GEN_A_PREG},
16338a1b82d7SSwapnil Jakhade 	{0x5233, SIERRA_PLLCTRL_CPGAIN_MODE_PREG},
16348a1b82d7SSwapnil Jakhade 	{0x0000, SIERRA_DRVCTRL_ATTEN_PREG},
16358a1b82d7SSwapnil Jakhade 	{0x0089, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
16368a1b82d7SSwapnil Jakhade 	{0x3C3C, SIERRA_CREQ_CCLKDET_MODE01_PREG},
16378a1b82d7SSwapnil Jakhade 	{0x3222, SIERRA_CREQ_FSMCLK_SEL_PREG},
16388a1b82d7SSwapnil Jakhade 	{0x0000, SIERRA_CREQ_EQ_CTRL_PREG},
16398a1b82d7SSwapnil Jakhade 	{0x8422, SIERRA_CTLELUT_CTRL_PREG},
16408a1b82d7SSwapnil Jakhade 	{0x4111, SIERRA_DFE_ECMP_RATESEL_PREG},
16418a1b82d7SSwapnil Jakhade 	{0x4111, SIERRA_DFE_SMP_RATESEL_PREG},
16428a1b82d7SSwapnil Jakhade 	{0x0002, SIERRA_DEQ_PHALIGN_CTRL},
16438a1b82d7SSwapnil Jakhade 	{0x9595, SIERRA_DEQ_VGATUNE_CTRL_PREG},
16448a1b82d7SSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT0},
16458a1b82d7SSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT1},
16468a1b82d7SSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT2},
16478a1b82d7SSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT3},
16488a1b82d7SSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT4},
16498a1b82d7SSwapnil Jakhade 	{0x0861, SIERRA_DEQ_ALUT0},
16508a1b82d7SSwapnil Jakhade 	{0x07E0, SIERRA_DEQ_ALUT1},
16518a1b82d7SSwapnil Jakhade 	{0x079E, SIERRA_DEQ_ALUT2},
16528a1b82d7SSwapnil Jakhade 	{0x071D, SIERRA_DEQ_ALUT3},
16538a1b82d7SSwapnil Jakhade 	{0x03F5, SIERRA_DEQ_DFETAP_CTRL_PREG},
16548a1b82d7SSwapnil Jakhade 	{0x0C01, SIERRA_DEQ_TAU_CTRL1_FAST_MAINT_PREG},
16558a1b82d7SSwapnil Jakhade 	{0x3C40, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG},
16568a1b82d7SSwapnil Jakhade 	{0x1C04, SIERRA_DEQ_TAU_CTRL2_PREG},
16578a1b82d7SSwapnil Jakhade 	{0x0033, SIERRA_DEQ_PICTRL_PREG},
16588a1b82d7SSwapnil Jakhade 	{0x0660, SIERRA_CPICAL_TMRVAL_MODE0_PREG},
16598a1b82d7SSwapnil Jakhade 	{0x00D5, SIERRA_CPI_OUTBUF_RATESEL_PREG},
16608a1b82d7SSwapnil Jakhade 	{0x0B6D, SIERRA_CPI_RESBIAS_BIN_PREG},
16618a1b82d7SSwapnil Jakhade 	{0x0102, SIERRA_RXBUFFER_CTLECTRL_PREG},
16628a1b82d7SSwapnil Jakhade 	{0x0002, SIERRA_RXBUFFER_RCDFECTRL_PREG}
16638a1b82d7SSwapnil Jakhade };
16648a1b82d7SSwapnil Jakhade 
1665da41bac5SChristophe JAILLET static const struct cdns_sierra_vals qsgmii_100_no_ssc_plllc1_cmn_vals = {
16668a1b82d7SSwapnil Jakhade 	.reg_pairs = qsgmii_100_no_ssc_plllc1_cmn_regs,
16678a1b82d7SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(qsgmii_100_no_ssc_plllc1_cmn_regs),
16688a1b82d7SSwapnil Jakhade };
16698a1b82d7SSwapnil Jakhade 
1670da41bac5SChristophe JAILLET static const struct cdns_sierra_vals qsgmii_100_no_ssc_plllc1_ln_vals = {
16718a1b82d7SSwapnil Jakhade 	.reg_pairs = qsgmii_100_no_ssc_plllc1_ln_regs,
16728a1b82d7SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(qsgmii_100_no_ssc_plllc1_ln_regs),
16738a1b82d7SSwapnil Jakhade };
16748a1b82d7SSwapnil Jakhade 
1675fa105172SSwapnil Jakhade /* PCIE PHY PCS common configuration */
167629f33f0bSChristophe JAILLET static const struct cdns_reg_pairs pcie_phy_pcs_cmn_regs[] = {
1677fa105172SSwapnil Jakhade 	{0x0430, SIERRA_PHY_PIPE_CMN_CTRL1}
1678fa105172SSwapnil Jakhade };
1679fa105172SSwapnil Jakhade 
1680da41bac5SChristophe JAILLET static const struct cdns_sierra_vals pcie_phy_pcs_cmn_vals = {
1681fa105172SSwapnil Jakhade 	.reg_pairs = pcie_phy_pcs_cmn_regs,
1682fa105172SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(pcie_phy_pcs_cmn_regs),
1683fa105172SSwapnil Jakhade };
1684fa105172SSwapnil Jakhade 
16858a1b82d7SSwapnil Jakhade /* refclk100MHz_32b_PCIe_cmn_pll_no_ssc, pcie_links_using_plllc, pipe_bw_3 */
16868a1b82d7SSwapnil Jakhade static const struct cdns_reg_pairs pcie_100_no_ssc_plllc_cmn_regs[] = {
16878a1b82d7SSwapnil Jakhade 	{0x2105, SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG},
16888a1b82d7SSwapnil Jakhade 	{0x2105, SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG},
16898a1b82d7SSwapnil Jakhade 	{0x8A06, SIERRA_CMN_PLLLC_BWCAL_MODE1_PREG},
16908a1b82d7SSwapnil Jakhade 	{0x8A06, SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG}
16918a1b82d7SSwapnil Jakhade };
16928a1b82d7SSwapnil Jakhade 
16938a1b82d7SSwapnil Jakhade /*
16948a1b82d7SSwapnil Jakhade  * refclk100MHz_32b_PCIe_ln_no_ssc, multilink, using_plllc,
16958a1b82d7SSwapnil Jakhade  * cmn_pllcy_anaclk0_1Ghz, xcvr_pllclk_fullrt_500mhz
16968a1b82d7SSwapnil Jakhade  */
16978a1b82d7SSwapnil Jakhade static const struct cdns_reg_pairs ml_pcie_100_no_ssc_ln_regs[] = {
16988a1b82d7SSwapnil Jakhade 	{0xFC08, SIERRA_DET_STANDEC_A_PREG},
16998a1b82d7SSwapnil Jakhade 	{0x001D, SIERRA_PSM_A3IN_TMR_PREG},
17008a1b82d7SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_A3_PREG},
17018a1b82d7SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_A4_PREG},
17028a1b82d7SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_IDLE_PREG},
17038a1b82d7SSwapnil Jakhade 	{0x1555, SIERRA_DFE_BIASTRIM_PREG},
17048a1b82d7SSwapnil Jakhade 	{0x9703, SIERRA_DRVCTRL_BOOST_PREG},
17058a1b82d7SSwapnil Jakhade 	{0x8055, SIERRA_RX_CREQ_FLTR_A_MODE3_PREG},
17068a1b82d7SSwapnil Jakhade 	{0x80BB, SIERRA_RX_CREQ_FLTR_A_MODE2_PREG},
17078a1b82d7SSwapnil Jakhade 	{0x8351, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG},
17088a1b82d7SSwapnil Jakhade 	{0x8349, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
17098a1b82d7SSwapnil Jakhade 	{0x0002, SIERRA_CREQ_DCBIASATTEN_OVR_PREG},
17108a1b82d7SSwapnil Jakhade 	{0x9800, SIERRA_RX_CTLE_CAL_PREG},
17118a1b82d7SSwapnil Jakhade 	{0x5624, SIERRA_DEQ_CONCUR_CTRL2_PREG},
17128a1b82d7SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_EPIPWR_CTRL2_PREG},
17138a1b82d7SSwapnil Jakhade 	{0x00FF, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG},
17148a1b82d7SSwapnil Jakhade 	{0x4C4C, SIERRA_DEQ_ERRCMP_CTRL_PREG},
17158a1b82d7SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_OFFSET_CTRL_PREG},
17168a1b82d7SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_GAIN_CTRL_PREG},
17178a1b82d7SSwapnil Jakhade 	{0x0041, SIERRA_DEQ_GLUT0},
17188a1b82d7SSwapnil Jakhade 	{0x0082, SIERRA_DEQ_GLUT1},
17198a1b82d7SSwapnil Jakhade 	{0x00C3, SIERRA_DEQ_GLUT2},
17208a1b82d7SSwapnil Jakhade 	{0x0145, SIERRA_DEQ_GLUT3},
17218a1b82d7SSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT4},
17228a1b82d7SSwapnil Jakhade 	{0x09E7, SIERRA_DEQ_ALUT0},
17238a1b82d7SSwapnil Jakhade 	{0x09A6, SIERRA_DEQ_ALUT1},
17248a1b82d7SSwapnil Jakhade 	{0x0965, SIERRA_DEQ_ALUT2},
17258a1b82d7SSwapnil Jakhade 	{0x08E3, SIERRA_DEQ_ALUT3},
17268a1b82d7SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP0},
17278a1b82d7SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP1},
17288a1b82d7SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP2},
17298a1b82d7SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP3},
17308a1b82d7SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP4},
17318a1b82d7SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_PRECUR_PREG},
17328a1b82d7SSwapnil Jakhade 	{0x0280, SIERRA_DEQ_POSTCUR_PREG},
17338a1b82d7SSwapnil Jakhade 	{0x8F00, SIERRA_DEQ_POSTCUR_DECR_PREG},
17348a1b82d7SSwapnil Jakhade 	{0x3C0F, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG},
17358a1b82d7SSwapnil Jakhade 	{0x1C0C, SIERRA_DEQ_TAU_CTRL2_PREG},
17368a1b82d7SSwapnil Jakhade 	{0x0100, SIERRA_DEQ_TAU_CTRL3_PREG},
1737*2d0f973bSBartosz Wawrzyniak 	{0x5E82, SIERRA_DEQ_TAU_EPIOFFSET_MODE_PREG},
17388a1b82d7SSwapnil Jakhade 	{0x002B, SIERRA_CPI_TRIM_PREG},
17398a1b82d7SSwapnil Jakhade 	{0x0003, SIERRA_EPI_CTRL_PREG},
17408a1b82d7SSwapnil Jakhade 	{0x803F, SIERRA_SDFILT_H2L_A_PREG},
17418a1b82d7SSwapnil Jakhade 	{0x0004, SIERRA_RXBUFFER_CTLECTRL_PREG},
17428a1b82d7SSwapnil Jakhade 	{0x2010, SIERRA_RXBUFFER_RCDFECTRL_PREG},
17438a1b82d7SSwapnil Jakhade 	{0x4432, SIERRA_RXBUFFER_DFECTRL_PREG}
17448a1b82d7SSwapnil Jakhade };
17458a1b82d7SSwapnil Jakhade 
1746da41bac5SChristophe JAILLET static const struct cdns_sierra_vals pcie_100_no_ssc_plllc_cmn_vals = {
17478a1b82d7SSwapnil Jakhade 	.reg_pairs = pcie_100_no_ssc_plllc_cmn_regs,
17488a1b82d7SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(pcie_100_no_ssc_plllc_cmn_regs),
17498a1b82d7SSwapnil Jakhade };
17508a1b82d7SSwapnil Jakhade 
1751da41bac5SChristophe JAILLET static const struct cdns_sierra_vals ml_pcie_100_no_ssc_ln_vals = {
17528a1b82d7SSwapnil Jakhade 	.reg_pairs = ml_pcie_100_no_ssc_ln_regs,
17538a1b82d7SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(ml_pcie_100_no_ssc_ln_regs),
17548a1b82d7SSwapnil Jakhade };
17558a1b82d7SSwapnil Jakhade 
1756e72659b6SSwapnil Jakhade /*
1757e72659b6SSwapnil Jakhade  * TI J721E:
1758e72659b6SSwapnil Jakhade  * refclk100MHz_32b_PCIe_ln_no_ssc, multilink, using_plllc,
1759e72659b6SSwapnil Jakhade  * cmn_pllcy_anaclk0_1Ghz, xcvr_pllclk_fullrt_500mhz
1760e72659b6SSwapnil Jakhade  */
1761e72659b6SSwapnil Jakhade static const struct cdns_reg_pairs ti_ml_pcie_100_no_ssc_ln_regs[] = {
1762e72659b6SSwapnil Jakhade 	{0xFC08, SIERRA_DET_STANDEC_A_PREG},
1763e72659b6SSwapnil Jakhade 	{0x001D, SIERRA_PSM_A3IN_TMR_PREG},
1764e72659b6SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_A3_PREG},
1765e72659b6SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_A4_PREG},
1766e72659b6SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_IDLE_PREG},
1767e72659b6SSwapnil Jakhade 	{0x1555, SIERRA_DFE_BIASTRIM_PREG},
1768e72659b6SSwapnil Jakhade 	{0x9703, SIERRA_DRVCTRL_BOOST_PREG},
1769e72659b6SSwapnil Jakhade 	{0x8055, SIERRA_RX_CREQ_FLTR_A_MODE3_PREG},
1770e72659b6SSwapnil Jakhade 	{0x80BB, SIERRA_RX_CREQ_FLTR_A_MODE2_PREG},
1771e72659b6SSwapnil Jakhade 	{0x8351, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG},
1772e72659b6SSwapnil Jakhade 	{0x8349, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
1773e72659b6SSwapnil Jakhade 	{0x0002, SIERRA_CREQ_DCBIASATTEN_OVR_PREG},
1774e72659b6SSwapnil Jakhade 	{0x9800, SIERRA_RX_CTLE_CAL_PREG},
1775e72659b6SSwapnil Jakhade 	{0x5624, SIERRA_DEQ_CONCUR_CTRL2_PREG},
1776e72659b6SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_EPIPWR_CTRL2_PREG},
1777e72659b6SSwapnil Jakhade 	{0x00FF, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG},
1778e72659b6SSwapnil Jakhade 	{0x4C4C, SIERRA_DEQ_ERRCMP_CTRL_PREG},
1779e72659b6SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_OFFSET_CTRL_PREG},
1780e72659b6SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_GAIN_CTRL_PREG},
1781e72659b6SSwapnil Jakhade 	{0x0041, SIERRA_DEQ_GLUT0},
1782e72659b6SSwapnil Jakhade 	{0x0082, SIERRA_DEQ_GLUT1},
1783e72659b6SSwapnil Jakhade 	{0x00C3, SIERRA_DEQ_GLUT2},
1784e72659b6SSwapnil Jakhade 	{0x0145, SIERRA_DEQ_GLUT3},
1785e72659b6SSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT4},
1786e72659b6SSwapnil Jakhade 	{0x09E7, SIERRA_DEQ_ALUT0},
1787e72659b6SSwapnil Jakhade 	{0x09A6, SIERRA_DEQ_ALUT1},
1788e72659b6SSwapnil Jakhade 	{0x0965, SIERRA_DEQ_ALUT2},
1789e72659b6SSwapnil Jakhade 	{0x08E3, SIERRA_DEQ_ALUT3},
1790e72659b6SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP0},
1791e72659b6SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP1},
1792e72659b6SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP2},
1793e72659b6SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP3},
1794e72659b6SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP4},
1795e72659b6SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_PRECUR_PREG},
1796e72659b6SSwapnil Jakhade 	{0x0280, SIERRA_DEQ_POSTCUR_PREG},
1797e72659b6SSwapnil Jakhade 	{0x8F00, SIERRA_DEQ_POSTCUR_DECR_PREG},
1798e72659b6SSwapnil Jakhade 	{0x3C0F, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG},
1799e72659b6SSwapnil Jakhade 	{0x1C0C, SIERRA_DEQ_TAU_CTRL2_PREG},
1800e72659b6SSwapnil Jakhade 	{0x0100, SIERRA_DEQ_TAU_CTRL3_PREG},
1801*2d0f973bSBartosz Wawrzyniak 	{0x5E82, SIERRA_DEQ_TAU_EPIOFFSET_MODE_PREG},
1802e72659b6SSwapnil Jakhade 	{0x002B, SIERRA_CPI_TRIM_PREG},
1803e72659b6SSwapnil Jakhade 	{0x0003, SIERRA_EPI_CTRL_PREG},
1804e72659b6SSwapnil Jakhade 	{0x803F, SIERRA_SDFILT_H2L_A_PREG},
1805e72659b6SSwapnil Jakhade 	{0x0004, SIERRA_RXBUFFER_CTLECTRL_PREG},
1806e72659b6SSwapnil Jakhade 	{0x2010, SIERRA_RXBUFFER_RCDFECTRL_PREG},
1807e72659b6SSwapnil Jakhade 	{0x4432, SIERRA_RXBUFFER_DFECTRL_PREG},
1808e72659b6SSwapnil Jakhade 	{0x0002, SIERRA_TX_RCVDET_OVRD_PREG}
1809e72659b6SSwapnil Jakhade };
1810e72659b6SSwapnil Jakhade 
1811da41bac5SChristophe JAILLET static const struct cdns_sierra_vals ti_ml_pcie_100_no_ssc_ln_vals = {
1812e72659b6SSwapnil Jakhade 	.reg_pairs = ti_ml_pcie_100_no_ssc_ln_regs,
1813e72659b6SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(ti_ml_pcie_100_no_ssc_ln_regs),
1814e72659b6SSwapnil Jakhade };
1815e72659b6SSwapnil Jakhade 
18168a1b82d7SSwapnil Jakhade /* refclk100MHz_32b_PCIe_cmn_pll_int_ssc, pcie_links_using_plllc, pipe_bw_3 */
18178a1b82d7SSwapnil Jakhade static const struct cdns_reg_pairs pcie_100_int_ssc_plllc_cmn_regs[] = {
18188a1b82d7SSwapnil Jakhade 	{0x000E, SIERRA_CMN_PLLLC_MODE_PREG},
18198a1b82d7SSwapnil Jakhade 	{0x4006, SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG},
18208a1b82d7SSwapnil Jakhade 	{0x4006, SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG},
18218a1b82d7SSwapnil Jakhade 	{0x0000, SIERRA_CMN_PLLLC_BWCAL_MODE1_PREG},
18228a1b82d7SSwapnil Jakhade 	{0x0000, SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG},
18238a1b82d7SSwapnil Jakhade 	{0x0581, SIERRA_CMN_PLLLC_DSMCORR_PREG},
18248a1b82d7SSwapnil Jakhade 	{0x7F80, SIERRA_CMN_PLLLC_SS_PREG},
18258a1b82d7SSwapnil Jakhade 	{0x0041, SIERRA_CMN_PLLLC_SS_AMP_STEP_SIZE_PREG},
18268a1b82d7SSwapnil Jakhade 	{0x0464, SIERRA_CMN_PLLLC_SSTWOPT_PREG},
18278a1b82d7SSwapnil Jakhade 	{0x0D0D, SIERRA_CMN_PLLLC_SS_TIME_STEPSIZE_MODE_PREG},
18288a1b82d7SSwapnil Jakhade 	{0x0060, SIERRA_CMN_PLLLC_LOCK_DELAY_CTRL_PREG}
18298a1b82d7SSwapnil Jakhade };
18308a1b82d7SSwapnil Jakhade 
18318a1b82d7SSwapnil Jakhade /*
18328a1b82d7SSwapnil Jakhade  * refclk100MHz_32b_PCIe_ln_int_ssc, multilink, using_plllc,
18338a1b82d7SSwapnil Jakhade  * cmn_pllcy_anaclk0_1Ghz, xcvr_pllclk_fullrt_500mhz
18348a1b82d7SSwapnil Jakhade  */
18358a1b82d7SSwapnil Jakhade static const struct cdns_reg_pairs ml_pcie_100_int_ssc_ln_regs[] = {
18368a1b82d7SSwapnil Jakhade 	{0xFC08, SIERRA_DET_STANDEC_A_PREG},
18378a1b82d7SSwapnil Jakhade 	{0x001D, SIERRA_PSM_A3IN_TMR_PREG},
18388a1b82d7SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_A3_PREG},
18398a1b82d7SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_A4_PREG},
18408a1b82d7SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_IDLE_PREG},
18418a1b82d7SSwapnil Jakhade 	{0x1555, SIERRA_DFE_BIASTRIM_PREG},
18428a1b82d7SSwapnil Jakhade 	{0x9703, SIERRA_DRVCTRL_BOOST_PREG},
18438a1b82d7SSwapnil Jakhade 	{0x813E, SIERRA_CLKPATHCTRL_TMR_PREG},
18448a1b82d7SSwapnil Jakhade 	{0x8047, SIERRA_RX_CREQ_FLTR_A_MODE3_PREG},
18458a1b82d7SSwapnil Jakhade 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE2_PREG},
18468a1b82d7SSwapnil Jakhade 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG},
18478a1b82d7SSwapnil Jakhade 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
18488a1b82d7SSwapnil Jakhade 	{0x0002, SIERRA_CREQ_DCBIASATTEN_OVR_PREG},
18498a1b82d7SSwapnil Jakhade 	{0x9800, SIERRA_RX_CTLE_CAL_PREG},
18508a1b82d7SSwapnil Jakhade 	{0x033C, SIERRA_RX_CTLE_MAINTENANCE_PREG},
18518a1b82d7SSwapnil Jakhade 	{0x44CC, SIERRA_CREQ_EQ_OPEN_EYE_THRESH_PREG},
18528a1b82d7SSwapnil Jakhade 	{0x5624, SIERRA_DEQ_CONCUR_CTRL2_PREG},
18538a1b82d7SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_EPIPWR_CTRL2_PREG},
18548a1b82d7SSwapnil Jakhade 	{0x00FF, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG},
18558a1b82d7SSwapnil Jakhade 	{0x4C4C, SIERRA_DEQ_ERRCMP_CTRL_PREG},
18568a1b82d7SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_OFFSET_CTRL_PREG},
18578a1b82d7SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_GAIN_CTRL_PREG},
18588a1b82d7SSwapnil Jakhade 	{0x0041, SIERRA_DEQ_GLUT0},
18598a1b82d7SSwapnil Jakhade 	{0x0082, SIERRA_DEQ_GLUT1},
18608a1b82d7SSwapnil Jakhade 	{0x00C3, SIERRA_DEQ_GLUT2},
18618a1b82d7SSwapnil Jakhade 	{0x0145, SIERRA_DEQ_GLUT3},
18628a1b82d7SSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT4},
18638a1b82d7SSwapnil Jakhade 	{0x09E7, SIERRA_DEQ_ALUT0},
18648a1b82d7SSwapnil Jakhade 	{0x09A6, SIERRA_DEQ_ALUT1},
18658a1b82d7SSwapnil Jakhade 	{0x0965, SIERRA_DEQ_ALUT2},
18668a1b82d7SSwapnil Jakhade 	{0x08E3, SIERRA_DEQ_ALUT3},
18678a1b82d7SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP0},
18688a1b82d7SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP1},
18698a1b82d7SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP2},
18708a1b82d7SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP3},
18718a1b82d7SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP4},
18728a1b82d7SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_PRECUR_PREG},
18738a1b82d7SSwapnil Jakhade 	{0x0280, SIERRA_DEQ_POSTCUR_PREG},
18748a1b82d7SSwapnil Jakhade 	{0x8F00, SIERRA_DEQ_POSTCUR_DECR_PREG},
18758a1b82d7SSwapnil Jakhade 	{0x3C0F, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG},
18768a1b82d7SSwapnil Jakhade 	{0x1C0C, SIERRA_DEQ_TAU_CTRL2_PREG},
18778a1b82d7SSwapnil Jakhade 	{0x0100, SIERRA_DEQ_TAU_CTRL3_PREG},
1878*2d0f973bSBartosz Wawrzyniak 	{0x5E82, SIERRA_DEQ_TAU_EPIOFFSET_MODE_PREG},
18798a1b82d7SSwapnil Jakhade 	{0x002B, SIERRA_CPI_TRIM_PREG},
18808a1b82d7SSwapnil Jakhade 	{0x0003, SIERRA_EPI_CTRL_PREG},
18818a1b82d7SSwapnil Jakhade 	{0x803F, SIERRA_SDFILT_H2L_A_PREG},
18828a1b82d7SSwapnil Jakhade 	{0x0004, SIERRA_RXBUFFER_CTLECTRL_PREG},
18838a1b82d7SSwapnil Jakhade 	{0x2010, SIERRA_RXBUFFER_RCDFECTRL_PREG},
18848a1b82d7SSwapnil Jakhade 	{0x4432, SIERRA_RXBUFFER_DFECTRL_PREG}
18858a1b82d7SSwapnil Jakhade };
18868a1b82d7SSwapnil Jakhade 
1887da41bac5SChristophe JAILLET static const struct cdns_sierra_vals pcie_100_int_ssc_plllc_cmn_vals = {
18888a1b82d7SSwapnil Jakhade 	.reg_pairs = pcie_100_int_ssc_plllc_cmn_regs,
18898a1b82d7SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(pcie_100_int_ssc_plllc_cmn_regs),
18908a1b82d7SSwapnil Jakhade };
18918a1b82d7SSwapnil Jakhade 
1892da41bac5SChristophe JAILLET static const struct cdns_sierra_vals ml_pcie_100_int_ssc_ln_vals = {
18938a1b82d7SSwapnil Jakhade 	.reg_pairs = ml_pcie_100_int_ssc_ln_regs,
18948a1b82d7SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(ml_pcie_100_int_ssc_ln_regs),
18958a1b82d7SSwapnil Jakhade };
18968a1b82d7SSwapnil Jakhade 
1897e72659b6SSwapnil Jakhade /*
1898e72659b6SSwapnil Jakhade  * TI J721E:
1899e72659b6SSwapnil Jakhade  * refclk100MHz_32b_PCIe_ln_int_ssc, multilink, using_plllc,
1900e72659b6SSwapnil Jakhade  * cmn_pllcy_anaclk0_1Ghz, xcvr_pllclk_fullrt_500mhz
1901e72659b6SSwapnil Jakhade  */
1902e72659b6SSwapnil Jakhade static const struct cdns_reg_pairs ti_ml_pcie_100_int_ssc_ln_regs[] = {
1903e72659b6SSwapnil Jakhade 	{0xFC08, SIERRA_DET_STANDEC_A_PREG},
1904e72659b6SSwapnil Jakhade 	{0x001D, SIERRA_PSM_A3IN_TMR_PREG},
1905e72659b6SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_A3_PREG},
1906e72659b6SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_A4_PREG},
1907e72659b6SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_IDLE_PREG},
1908e72659b6SSwapnil Jakhade 	{0x1555, SIERRA_DFE_BIASTRIM_PREG},
1909e72659b6SSwapnil Jakhade 	{0x9703, SIERRA_DRVCTRL_BOOST_PREG},
1910e72659b6SSwapnil Jakhade 	{0x813E, SIERRA_CLKPATHCTRL_TMR_PREG},
1911e72659b6SSwapnil Jakhade 	{0x8047, SIERRA_RX_CREQ_FLTR_A_MODE3_PREG},
1912e72659b6SSwapnil Jakhade 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE2_PREG},
1913e72659b6SSwapnil Jakhade 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG},
1914e72659b6SSwapnil Jakhade 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
1915e72659b6SSwapnil Jakhade 	{0x0002, SIERRA_CREQ_DCBIASATTEN_OVR_PREG},
1916e72659b6SSwapnil Jakhade 	{0x9800, SIERRA_RX_CTLE_CAL_PREG},
1917e72659b6SSwapnil Jakhade 	{0x033C, SIERRA_RX_CTLE_MAINTENANCE_PREG},
1918e72659b6SSwapnil Jakhade 	{0x44CC, SIERRA_CREQ_EQ_OPEN_EYE_THRESH_PREG},
1919e72659b6SSwapnil Jakhade 	{0x5624, SIERRA_DEQ_CONCUR_CTRL2_PREG},
1920e72659b6SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_EPIPWR_CTRL2_PREG},
1921e72659b6SSwapnil Jakhade 	{0x00FF, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG},
1922e72659b6SSwapnil Jakhade 	{0x4C4C, SIERRA_DEQ_ERRCMP_CTRL_PREG},
1923e72659b6SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_OFFSET_CTRL_PREG},
1924e72659b6SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_GAIN_CTRL_PREG},
1925e72659b6SSwapnil Jakhade 	{0x0041, SIERRA_DEQ_GLUT0},
1926e72659b6SSwapnil Jakhade 	{0x0082, SIERRA_DEQ_GLUT1},
1927e72659b6SSwapnil Jakhade 	{0x00C3, SIERRA_DEQ_GLUT2},
1928e72659b6SSwapnil Jakhade 	{0x0145, SIERRA_DEQ_GLUT3},
1929e72659b6SSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT4},
1930e72659b6SSwapnil Jakhade 	{0x09E7, SIERRA_DEQ_ALUT0},
1931e72659b6SSwapnil Jakhade 	{0x09A6, SIERRA_DEQ_ALUT1},
1932e72659b6SSwapnil Jakhade 	{0x0965, SIERRA_DEQ_ALUT2},
1933e72659b6SSwapnil Jakhade 	{0x08E3, SIERRA_DEQ_ALUT3},
1934e72659b6SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP0},
1935e72659b6SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP1},
1936e72659b6SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP2},
1937e72659b6SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP3},
1938e72659b6SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP4},
1939e72659b6SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_PRECUR_PREG},
1940e72659b6SSwapnil Jakhade 	{0x0280, SIERRA_DEQ_POSTCUR_PREG},
1941e72659b6SSwapnil Jakhade 	{0x8F00, SIERRA_DEQ_POSTCUR_DECR_PREG},
1942e72659b6SSwapnil Jakhade 	{0x3C0F, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG},
1943e72659b6SSwapnil Jakhade 	{0x1C0C, SIERRA_DEQ_TAU_CTRL2_PREG},
1944e72659b6SSwapnil Jakhade 	{0x0100, SIERRA_DEQ_TAU_CTRL3_PREG},
1945*2d0f973bSBartosz Wawrzyniak 	{0x5E82, SIERRA_DEQ_TAU_EPIOFFSET_MODE_PREG},
1946e72659b6SSwapnil Jakhade 	{0x002B, SIERRA_CPI_TRIM_PREG},
1947e72659b6SSwapnil Jakhade 	{0x0003, SIERRA_EPI_CTRL_PREG},
1948e72659b6SSwapnil Jakhade 	{0x803F, SIERRA_SDFILT_H2L_A_PREG},
1949e72659b6SSwapnil Jakhade 	{0x0004, SIERRA_RXBUFFER_CTLECTRL_PREG},
1950e72659b6SSwapnil Jakhade 	{0x2010, SIERRA_RXBUFFER_RCDFECTRL_PREG},
1951e72659b6SSwapnil Jakhade 	{0x4432, SIERRA_RXBUFFER_DFECTRL_PREG},
1952e72659b6SSwapnil Jakhade 	{0x0002, SIERRA_TX_RCVDET_OVRD_PREG}
1953e72659b6SSwapnil Jakhade };
1954e72659b6SSwapnil Jakhade 
1955da41bac5SChristophe JAILLET static const struct cdns_sierra_vals ti_ml_pcie_100_int_ssc_ln_vals = {
1956e72659b6SSwapnil Jakhade 	.reg_pairs = ti_ml_pcie_100_int_ssc_ln_regs,
1957e72659b6SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(ti_ml_pcie_100_int_ssc_ln_regs),
1958e72659b6SSwapnil Jakhade };
1959e72659b6SSwapnil Jakhade 
19608a1b82d7SSwapnil Jakhade /* refclk100MHz_32b_PCIe_cmn_pll_ext_ssc, pcie_links_using_plllc, pipe_bw_3 */
19618a1b82d7SSwapnil Jakhade static const struct cdns_reg_pairs pcie_100_ext_ssc_plllc_cmn_regs[] = {
19628a1b82d7SSwapnil Jakhade 	{0x2106, SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG},
19638a1b82d7SSwapnil Jakhade 	{0x2106, SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG},
19648a1b82d7SSwapnil Jakhade 	{0x8A06, SIERRA_CMN_PLLLC_BWCAL_MODE1_PREG},
19658a1b82d7SSwapnil Jakhade 	{0x8A06, SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG},
19668a1b82d7SSwapnil Jakhade 	{0x1B1B, SIERRA_CMN_PLLLC_SS_TIME_STEPSIZE_MODE_PREG}
19678a1b82d7SSwapnil Jakhade };
19688a1b82d7SSwapnil Jakhade 
19698a1b82d7SSwapnil Jakhade /*
19708a1b82d7SSwapnil Jakhade  * refclk100MHz_32b_PCIe_ln_ext_ssc, multilink, using_plllc,
19718a1b82d7SSwapnil Jakhade  * cmn_pllcy_anaclk0_1Ghz, xcvr_pllclk_fullrt_500mhz
19728a1b82d7SSwapnil Jakhade  */
19738a1b82d7SSwapnil Jakhade static const struct cdns_reg_pairs ml_pcie_100_ext_ssc_ln_regs[] = {
19748a1b82d7SSwapnil Jakhade 	{0xFC08, SIERRA_DET_STANDEC_A_PREG},
19758a1b82d7SSwapnil Jakhade 	{0x001D, SIERRA_PSM_A3IN_TMR_PREG},
19768a1b82d7SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_A3_PREG},
19778a1b82d7SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_A4_PREG},
19788a1b82d7SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_IDLE_PREG},
19798a1b82d7SSwapnil Jakhade 	{0x1555, SIERRA_DFE_BIASTRIM_PREG},
19808a1b82d7SSwapnil Jakhade 	{0x9703, SIERRA_DRVCTRL_BOOST_PREG},
19818a1b82d7SSwapnil Jakhade 	{0x813E, SIERRA_CLKPATHCTRL_TMR_PREG},
19828a1b82d7SSwapnil Jakhade 	{0x8047, SIERRA_RX_CREQ_FLTR_A_MODE3_PREG},
19838a1b82d7SSwapnil Jakhade 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE2_PREG},
19848a1b82d7SSwapnil Jakhade 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG},
19858a1b82d7SSwapnil Jakhade 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
19868a1b82d7SSwapnil Jakhade 	{0x0002, SIERRA_CREQ_DCBIASATTEN_OVR_PREG},
19878a1b82d7SSwapnil Jakhade 	{0x9800, SIERRA_RX_CTLE_CAL_PREG},
19888a1b82d7SSwapnil Jakhade 	{0x033C, SIERRA_RX_CTLE_MAINTENANCE_PREG},
19898a1b82d7SSwapnil Jakhade 	{0x44CC, SIERRA_CREQ_EQ_OPEN_EYE_THRESH_PREG},
19908a1b82d7SSwapnil Jakhade 	{0x5624, SIERRA_DEQ_CONCUR_CTRL2_PREG},
19918a1b82d7SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_EPIPWR_CTRL2_PREG},
19928a1b82d7SSwapnil Jakhade 	{0x00FF, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG},
19938a1b82d7SSwapnil Jakhade 	{0x4C4C, SIERRA_DEQ_ERRCMP_CTRL_PREG},
19948a1b82d7SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_OFFSET_CTRL_PREG},
19958a1b82d7SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_GAIN_CTRL_PREG},
19968a1b82d7SSwapnil Jakhade 	{0x0041, SIERRA_DEQ_GLUT0},
19978a1b82d7SSwapnil Jakhade 	{0x0082, SIERRA_DEQ_GLUT1},
19988a1b82d7SSwapnil Jakhade 	{0x00C3, SIERRA_DEQ_GLUT2},
19998a1b82d7SSwapnil Jakhade 	{0x0145, SIERRA_DEQ_GLUT3},
20008a1b82d7SSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT4},
20018a1b82d7SSwapnil Jakhade 	{0x09E7, SIERRA_DEQ_ALUT0},
20028a1b82d7SSwapnil Jakhade 	{0x09A6, SIERRA_DEQ_ALUT1},
20038a1b82d7SSwapnil Jakhade 	{0x0965, SIERRA_DEQ_ALUT2},
20048a1b82d7SSwapnil Jakhade 	{0x08E3, SIERRA_DEQ_ALUT3},
20058a1b82d7SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP0},
20068a1b82d7SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP1},
20078a1b82d7SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP2},
20088a1b82d7SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP3},
20098a1b82d7SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP4},
20108a1b82d7SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_PRECUR_PREG},
20118a1b82d7SSwapnil Jakhade 	{0x0280, SIERRA_DEQ_POSTCUR_PREG},
20128a1b82d7SSwapnil Jakhade 	{0x8F00, SIERRA_DEQ_POSTCUR_DECR_PREG},
20138a1b82d7SSwapnil Jakhade 	{0x3C0F, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG},
20148a1b82d7SSwapnil Jakhade 	{0x1C0C, SIERRA_DEQ_TAU_CTRL2_PREG},
20158a1b82d7SSwapnil Jakhade 	{0x0100, SIERRA_DEQ_TAU_CTRL3_PREG},
2016*2d0f973bSBartosz Wawrzyniak 	{0x5E82, SIERRA_DEQ_TAU_EPIOFFSET_MODE_PREG},
20178a1b82d7SSwapnil Jakhade 	{0x002B, SIERRA_CPI_TRIM_PREG},
20188a1b82d7SSwapnil Jakhade 	{0x0003, SIERRA_EPI_CTRL_PREG},
20198a1b82d7SSwapnil Jakhade 	{0x803F, SIERRA_SDFILT_H2L_A_PREG},
20208a1b82d7SSwapnil Jakhade 	{0x0004, SIERRA_RXBUFFER_CTLECTRL_PREG},
20218a1b82d7SSwapnil Jakhade 	{0x2010, SIERRA_RXBUFFER_RCDFECTRL_PREG},
20228a1b82d7SSwapnil Jakhade 	{0x4432, SIERRA_RXBUFFER_DFECTRL_PREG}
20238a1b82d7SSwapnil Jakhade };
20248a1b82d7SSwapnil Jakhade 
2025da41bac5SChristophe JAILLET static const struct cdns_sierra_vals pcie_100_ext_ssc_plllc_cmn_vals = {
20268a1b82d7SSwapnil Jakhade 	.reg_pairs = pcie_100_ext_ssc_plllc_cmn_regs,
20278a1b82d7SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(pcie_100_ext_ssc_plllc_cmn_regs),
20288a1b82d7SSwapnil Jakhade };
20298a1b82d7SSwapnil Jakhade 
2030da41bac5SChristophe JAILLET static const struct cdns_sierra_vals ml_pcie_100_ext_ssc_ln_vals = {
20318a1b82d7SSwapnil Jakhade 	.reg_pairs = ml_pcie_100_ext_ssc_ln_regs,
20328a1b82d7SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(ml_pcie_100_ext_ssc_ln_regs),
20338a1b82d7SSwapnil Jakhade };
20348a1b82d7SSwapnil Jakhade 
2035e72659b6SSwapnil Jakhade /*
2036e72659b6SSwapnil Jakhade  * TI J721E:
2037e72659b6SSwapnil Jakhade  * refclk100MHz_32b_PCIe_ln_ext_ssc, multilink, using_plllc,
2038e72659b6SSwapnil Jakhade  * cmn_pllcy_anaclk0_1Ghz, xcvr_pllclk_fullrt_500mhz
2039e72659b6SSwapnil Jakhade  */
2040e72659b6SSwapnil Jakhade static const struct cdns_reg_pairs ti_ml_pcie_100_ext_ssc_ln_regs[] = {
2041e72659b6SSwapnil Jakhade 	{0xFC08, SIERRA_DET_STANDEC_A_PREG},
2042e72659b6SSwapnil Jakhade 	{0x001D, SIERRA_PSM_A3IN_TMR_PREG},
2043e72659b6SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_A3_PREG},
2044e72659b6SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_A4_PREG},
2045e72659b6SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_IDLE_PREG},
2046e72659b6SSwapnil Jakhade 	{0x1555, SIERRA_DFE_BIASTRIM_PREG},
2047e72659b6SSwapnil Jakhade 	{0x9703, SIERRA_DRVCTRL_BOOST_PREG},
2048e72659b6SSwapnil Jakhade 	{0x813E, SIERRA_CLKPATHCTRL_TMR_PREG},
2049e72659b6SSwapnil Jakhade 	{0x8047, SIERRA_RX_CREQ_FLTR_A_MODE3_PREG},
2050e72659b6SSwapnil Jakhade 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE2_PREG},
2051e72659b6SSwapnil Jakhade 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG},
2052e72659b6SSwapnil Jakhade 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
2053e72659b6SSwapnil Jakhade 	{0x0002, SIERRA_CREQ_DCBIASATTEN_OVR_PREG},
2054e72659b6SSwapnil Jakhade 	{0x9800, SIERRA_RX_CTLE_CAL_PREG},
2055e72659b6SSwapnil Jakhade 	{0x033C, SIERRA_RX_CTLE_MAINTENANCE_PREG},
2056e72659b6SSwapnil Jakhade 	{0x44CC, SIERRA_CREQ_EQ_OPEN_EYE_THRESH_PREG},
2057e72659b6SSwapnil Jakhade 	{0x5624, SIERRA_DEQ_CONCUR_CTRL2_PREG},
2058e72659b6SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_EPIPWR_CTRL2_PREG},
2059e72659b6SSwapnil Jakhade 	{0x00FF, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG},
2060e72659b6SSwapnil Jakhade 	{0x4C4C, SIERRA_DEQ_ERRCMP_CTRL_PREG},
2061e72659b6SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_OFFSET_CTRL_PREG},
2062e72659b6SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_GAIN_CTRL_PREG},
2063e72659b6SSwapnil Jakhade 	{0x0041, SIERRA_DEQ_GLUT0},
2064e72659b6SSwapnil Jakhade 	{0x0082, SIERRA_DEQ_GLUT1},
2065e72659b6SSwapnil Jakhade 	{0x00C3, SIERRA_DEQ_GLUT2},
2066e72659b6SSwapnil Jakhade 	{0x0145, SIERRA_DEQ_GLUT3},
2067e72659b6SSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT4},
2068e72659b6SSwapnil Jakhade 	{0x09E7, SIERRA_DEQ_ALUT0},
2069e72659b6SSwapnil Jakhade 	{0x09A6, SIERRA_DEQ_ALUT1},
2070e72659b6SSwapnil Jakhade 	{0x0965, SIERRA_DEQ_ALUT2},
2071e72659b6SSwapnil Jakhade 	{0x08E3, SIERRA_DEQ_ALUT3},
2072e72659b6SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP0},
2073e72659b6SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP1},
2074e72659b6SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP2},
2075e72659b6SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP3},
2076e72659b6SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP4},
2077e72659b6SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_PRECUR_PREG},
2078e72659b6SSwapnil Jakhade 	{0x0280, SIERRA_DEQ_POSTCUR_PREG},
2079e72659b6SSwapnil Jakhade 	{0x8F00, SIERRA_DEQ_POSTCUR_DECR_PREG},
2080e72659b6SSwapnil Jakhade 	{0x3C0F, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG},
2081e72659b6SSwapnil Jakhade 	{0x1C0C, SIERRA_DEQ_TAU_CTRL2_PREG},
2082e72659b6SSwapnil Jakhade 	{0x0100, SIERRA_DEQ_TAU_CTRL3_PREG},
2083*2d0f973bSBartosz Wawrzyniak 	{0x5E82, SIERRA_DEQ_TAU_EPIOFFSET_MODE_PREG},
2084e72659b6SSwapnil Jakhade 	{0x002B, SIERRA_CPI_TRIM_PREG},
2085e72659b6SSwapnil Jakhade 	{0x0003, SIERRA_EPI_CTRL_PREG},
2086e72659b6SSwapnil Jakhade 	{0x803F, SIERRA_SDFILT_H2L_A_PREG},
2087e72659b6SSwapnil Jakhade 	{0x0004, SIERRA_RXBUFFER_CTLECTRL_PREG},
2088e72659b6SSwapnil Jakhade 	{0x2010, SIERRA_RXBUFFER_RCDFECTRL_PREG},
2089e72659b6SSwapnil Jakhade 	{0x4432, SIERRA_RXBUFFER_DFECTRL_PREG},
2090e72659b6SSwapnil Jakhade 	{0x0002, SIERRA_TX_RCVDET_OVRD_PREG}
2091e72659b6SSwapnil Jakhade };
2092e72659b6SSwapnil Jakhade 
2093da41bac5SChristophe JAILLET static const struct cdns_sierra_vals ti_ml_pcie_100_ext_ssc_ln_vals = {
2094e72659b6SSwapnil Jakhade 	.reg_pairs = ti_ml_pcie_100_ext_ssc_ln_regs,
2095e72659b6SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(ti_ml_pcie_100_ext_ssc_ln_regs),
2096e72659b6SSwapnil Jakhade };
2097e72659b6SSwapnil Jakhade 
20987a5ad9b4SSwapnil Jakhade /* refclk100MHz_32b_PCIe_cmn_pll_no_ssc */
20997a5ad9b4SSwapnil Jakhade static const struct cdns_reg_pairs cdns_pcie_cmn_regs_no_ssc[] = {
21007a5ad9b4SSwapnil Jakhade 	{0x2105, SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG},
21017a5ad9b4SSwapnil Jakhade 	{0x2105, SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG},
21027a5ad9b4SSwapnil Jakhade 	{0x8A06, SIERRA_CMN_PLLLC_BWCAL_MODE1_PREG},
21037a5ad9b4SSwapnil Jakhade 	{0x8A06, SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG}
21047a5ad9b4SSwapnil Jakhade };
21057a5ad9b4SSwapnil Jakhade 
21067a5ad9b4SSwapnil Jakhade /* refclk100MHz_32b_PCIe_ln_no_ssc */
21077a5ad9b4SSwapnil Jakhade static const struct cdns_reg_pairs cdns_pcie_ln_regs_no_ssc[] = {
21087a5ad9b4SSwapnil Jakhade 	{0xFC08, SIERRA_DET_STANDEC_A_PREG},
21097a5ad9b4SSwapnil Jakhade 	{0x001D, SIERRA_PSM_A3IN_TMR_PREG},
21107a5ad9b4SSwapnil Jakhade 	{0x1555, SIERRA_DFE_BIASTRIM_PREG},
21117a5ad9b4SSwapnil Jakhade 	{0x9703, SIERRA_DRVCTRL_BOOST_PREG},
21127a5ad9b4SSwapnil Jakhade 	{0x8055, SIERRA_RX_CREQ_FLTR_A_MODE3_PREG},
21137a5ad9b4SSwapnil Jakhade 	{0x80BB, SIERRA_RX_CREQ_FLTR_A_MODE2_PREG},
21147a5ad9b4SSwapnil Jakhade 	{0x8351, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG},
21157a5ad9b4SSwapnil Jakhade 	{0x8349, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
21167a5ad9b4SSwapnil Jakhade 	{0x0002, SIERRA_CREQ_DCBIASATTEN_OVR_PREG},
21177a5ad9b4SSwapnil Jakhade 	{0x9800, SIERRA_RX_CTLE_CAL_PREG},
21187a5ad9b4SSwapnil Jakhade 	{0x5624, SIERRA_DEQ_CONCUR_CTRL2_PREG},
21197a5ad9b4SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_EPIPWR_CTRL2_PREG},
21207a5ad9b4SSwapnil Jakhade 	{0x00FF, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG},
21217a5ad9b4SSwapnil Jakhade 	{0x4C4C, SIERRA_DEQ_ERRCMP_CTRL_PREG},
21227a5ad9b4SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_OFFSET_CTRL_PREG},
21237a5ad9b4SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_GAIN_CTRL_PREG},
21247a5ad9b4SSwapnil Jakhade 	{0x0041, SIERRA_DEQ_GLUT0},
21257a5ad9b4SSwapnil Jakhade 	{0x0082, SIERRA_DEQ_GLUT1},
21267a5ad9b4SSwapnil Jakhade 	{0x00C3, SIERRA_DEQ_GLUT2},
21277a5ad9b4SSwapnil Jakhade 	{0x0145, SIERRA_DEQ_GLUT3},
21287a5ad9b4SSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT4},
21297a5ad9b4SSwapnil Jakhade 	{0x09E7, SIERRA_DEQ_ALUT0},
21307a5ad9b4SSwapnil Jakhade 	{0x09A6, SIERRA_DEQ_ALUT1},
21317a5ad9b4SSwapnil Jakhade 	{0x0965, SIERRA_DEQ_ALUT2},
21327a5ad9b4SSwapnil Jakhade 	{0x08E3, SIERRA_DEQ_ALUT3},
21337a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP0},
21347a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP1},
21357a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP2},
21367a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP3},
21377a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP4},
21387a5ad9b4SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_PRECUR_PREG},
21397a5ad9b4SSwapnil Jakhade 	{0x0280, SIERRA_DEQ_POSTCUR_PREG},
21407a5ad9b4SSwapnil Jakhade 	{0x8F00, SIERRA_DEQ_POSTCUR_DECR_PREG},
21417a5ad9b4SSwapnil Jakhade 	{0x3C0F, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG},
21427a5ad9b4SSwapnil Jakhade 	{0x1C0C, SIERRA_DEQ_TAU_CTRL2_PREG},
21437a5ad9b4SSwapnil Jakhade 	{0x0100, SIERRA_DEQ_TAU_CTRL3_PREG},
2144*2d0f973bSBartosz Wawrzyniak 	{0x5E82, SIERRA_DEQ_TAU_EPIOFFSET_MODE_PREG},
21457a5ad9b4SSwapnil Jakhade 	{0x002B, SIERRA_CPI_TRIM_PREG},
21467a5ad9b4SSwapnil Jakhade 	{0x0003, SIERRA_EPI_CTRL_PREG},
21477a5ad9b4SSwapnil Jakhade 	{0x803F, SIERRA_SDFILT_H2L_A_PREG},
21487a5ad9b4SSwapnil Jakhade 	{0x0004, SIERRA_RXBUFFER_CTLECTRL_PREG},
21497a5ad9b4SSwapnil Jakhade 	{0x2010, SIERRA_RXBUFFER_RCDFECTRL_PREG},
21507a5ad9b4SSwapnil Jakhade 	{0x4432, SIERRA_RXBUFFER_DFECTRL_PREG}
21517a5ad9b4SSwapnil Jakhade };
21527a5ad9b4SSwapnil Jakhade 
2153da41bac5SChristophe JAILLET static const struct cdns_sierra_vals pcie_100_no_ssc_cmn_vals = {
21547a5ad9b4SSwapnil Jakhade 	.reg_pairs = cdns_pcie_cmn_regs_no_ssc,
21557a5ad9b4SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(cdns_pcie_cmn_regs_no_ssc),
21567a5ad9b4SSwapnil Jakhade };
21577a5ad9b4SSwapnil Jakhade 
2158da41bac5SChristophe JAILLET static const struct cdns_sierra_vals pcie_100_no_ssc_ln_vals = {
21597a5ad9b4SSwapnil Jakhade 	.reg_pairs = cdns_pcie_ln_regs_no_ssc,
21607a5ad9b4SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(cdns_pcie_ln_regs_no_ssc),
21617a5ad9b4SSwapnil Jakhade };
21627a5ad9b4SSwapnil Jakhade 
21637a5ad9b4SSwapnil Jakhade /* refclk100MHz_32b_PCIe_cmn_pll_int_ssc */
21647a5ad9b4SSwapnil Jakhade static const struct cdns_reg_pairs cdns_pcie_cmn_regs_int_ssc[] = {
21657a5ad9b4SSwapnil Jakhade 	{0x000E, SIERRA_CMN_PLLLC_MODE_PREG},
21667a5ad9b4SSwapnil Jakhade 	{0x4006, SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG},
21677a5ad9b4SSwapnil Jakhade 	{0x4006, SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG},
21687a5ad9b4SSwapnil Jakhade 	{0x0000, SIERRA_CMN_PLLLC_BWCAL_MODE1_PREG},
21697a5ad9b4SSwapnil Jakhade 	{0x0000, SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG},
21707a5ad9b4SSwapnil Jakhade 	{0x0581, SIERRA_CMN_PLLLC_DSMCORR_PREG},
21717a5ad9b4SSwapnil Jakhade 	{0x7F80, SIERRA_CMN_PLLLC_SS_PREG},
21727a5ad9b4SSwapnil Jakhade 	{0x0041, SIERRA_CMN_PLLLC_SS_AMP_STEP_SIZE_PREG},
21737a5ad9b4SSwapnil Jakhade 	{0x0464, SIERRA_CMN_PLLLC_SSTWOPT_PREG},
21747a5ad9b4SSwapnil Jakhade 	{0x0D0D, SIERRA_CMN_PLLLC_SS_TIME_STEPSIZE_MODE_PREG},
21757a5ad9b4SSwapnil Jakhade 	{0x0060, SIERRA_CMN_PLLLC_LOCK_DELAY_CTRL_PREG}
21767a5ad9b4SSwapnil Jakhade };
21777a5ad9b4SSwapnil Jakhade 
21787a5ad9b4SSwapnil Jakhade /* refclk100MHz_32b_PCIe_ln_int_ssc */
21797a5ad9b4SSwapnil Jakhade static const struct cdns_reg_pairs cdns_pcie_ln_regs_int_ssc[] = {
21807a5ad9b4SSwapnil Jakhade 	{0xFC08, SIERRA_DET_STANDEC_A_PREG},
21817a5ad9b4SSwapnil Jakhade 	{0x001D, SIERRA_PSM_A3IN_TMR_PREG},
21827a5ad9b4SSwapnil Jakhade 	{0x1555, SIERRA_DFE_BIASTRIM_PREG},
21837a5ad9b4SSwapnil Jakhade 	{0x9703, SIERRA_DRVCTRL_BOOST_PREG},
21847a5ad9b4SSwapnil Jakhade 	{0x813E, SIERRA_CLKPATHCTRL_TMR_PREG},
21857a5ad9b4SSwapnil Jakhade 	{0x8047, SIERRA_RX_CREQ_FLTR_A_MODE3_PREG},
21867a5ad9b4SSwapnil Jakhade 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE2_PREG},
21877a5ad9b4SSwapnil Jakhade 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG},
21887a5ad9b4SSwapnil Jakhade 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
21897a5ad9b4SSwapnil Jakhade 	{0x0002, SIERRA_CREQ_DCBIASATTEN_OVR_PREG},
21907a5ad9b4SSwapnil Jakhade 	{0x9800, SIERRA_RX_CTLE_CAL_PREG},
21917a5ad9b4SSwapnil Jakhade 	{0x033C, SIERRA_RX_CTLE_MAINTENANCE_PREG},
21927a5ad9b4SSwapnil Jakhade 	{0x44CC, SIERRA_CREQ_EQ_OPEN_EYE_THRESH_PREG},
21937a5ad9b4SSwapnil Jakhade 	{0x5624, SIERRA_DEQ_CONCUR_CTRL2_PREG},
21947a5ad9b4SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_EPIPWR_CTRL2_PREG},
21957a5ad9b4SSwapnil Jakhade 	{0x00FF, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG},
21967a5ad9b4SSwapnil Jakhade 	{0x4C4C, SIERRA_DEQ_ERRCMP_CTRL_PREG},
21977a5ad9b4SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_OFFSET_CTRL_PREG},
21987a5ad9b4SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_GAIN_CTRL_PREG},
21997a5ad9b4SSwapnil Jakhade 	{0x0041, SIERRA_DEQ_GLUT0},
22007a5ad9b4SSwapnil Jakhade 	{0x0082, SIERRA_DEQ_GLUT1},
22017a5ad9b4SSwapnil Jakhade 	{0x00C3, SIERRA_DEQ_GLUT2},
22027a5ad9b4SSwapnil Jakhade 	{0x0145, SIERRA_DEQ_GLUT3},
22037a5ad9b4SSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT4},
22047a5ad9b4SSwapnil Jakhade 	{0x09E7, SIERRA_DEQ_ALUT0},
22057a5ad9b4SSwapnil Jakhade 	{0x09A6, SIERRA_DEQ_ALUT1},
22067a5ad9b4SSwapnil Jakhade 	{0x0965, SIERRA_DEQ_ALUT2},
22077a5ad9b4SSwapnil Jakhade 	{0x08E3, SIERRA_DEQ_ALUT3},
22087a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP0},
22097a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP1},
22107a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP2},
22117a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP3},
22127a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP4},
22137a5ad9b4SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_PRECUR_PREG},
22147a5ad9b4SSwapnil Jakhade 	{0x0280, SIERRA_DEQ_POSTCUR_PREG},
22157a5ad9b4SSwapnil Jakhade 	{0x8F00, SIERRA_DEQ_POSTCUR_DECR_PREG},
22167a5ad9b4SSwapnil Jakhade 	{0x3C0F, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG},
22177a5ad9b4SSwapnil Jakhade 	{0x1C0C, SIERRA_DEQ_TAU_CTRL2_PREG},
22187a5ad9b4SSwapnil Jakhade 	{0x0100, SIERRA_DEQ_TAU_CTRL3_PREG},
2219*2d0f973bSBartosz Wawrzyniak 	{0x5E82, SIERRA_DEQ_TAU_EPIOFFSET_MODE_PREG},
22207a5ad9b4SSwapnil Jakhade 	{0x002B, SIERRA_CPI_TRIM_PREG},
22217a5ad9b4SSwapnil Jakhade 	{0x0003, SIERRA_EPI_CTRL_PREG},
22227a5ad9b4SSwapnil Jakhade 	{0x803F, SIERRA_SDFILT_H2L_A_PREG},
22237a5ad9b4SSwapnil Jakhade 	{0x0004, SIERRA_RXBUFFER_CTLECTRL_PREG},
22247a5ad9b4SSwapnil Jakhade 	{0x2010, SIERRA_RXBUFFER_RCDFECTRL_PREG},
22257a5ad9b4SSwapnil Jakhade 	{0x4432, SIERRA_RXBUFFER_DFECTRL_PREG}
22267a5ad9b4SSwapnil Jakhade };
22277a5ad9b4SSwapnil Jakhade 
2228da41bac5SChristophe JAILLET static const struct cdns_sierra_vals pcie_100_int_ssc_cmn_vals = {
22297a5ad9b4SSwapnil Jakhade 	.reg_pairs = cdns_pcie_cmn_regs_int_ssc,
22307a5ad9b4SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(cdns_pcie_cmn_regs_int_ssc),
22317a5ad9b4SSwapnil Jakhade };
22327a5ad9b4SSwapnil Jakhade 
2233da41bac5SChristophe JAILLET static const struct cdns_sierra_vals pcie_100_int_ssc_ln_vals = {
22347a5ad9b4SSwapnil Jakhade 	.reg_pairs = cdns_pcie_ln_regs_int_ssc,
22357a5ad9b4SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(cdns_pcie_ln_regs_int_ssc),
22367a5ad9b4SSwapnil Jakhade };
22377a5ad9b4SSwapnil Jakhade 
2238871002d7SAnil Varughese /* refclk100MHz_32b_PCIe_cmn_pll_ext_ssc */
22393cfb0e8eSRikard Falkeborn static const struct cdns_reg_pairs cdns_pcie_cmn_regs_ext_ssc[] = {
2240871002d7SAnil Varughese 	{0x2106, SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG},
2241871002d7SAnil Varughese 	{0x2106, SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG},
2242871002d7SAnil Varughese 	{0x8A06, SIERRA_CMN_PLLLC_BWCAL_MODE1_PREG},
2243871002d7SAnil Varughese 	{0x8A06, SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG},
2244871002d7SAnil Varughese 	{0x1B1B, SIERRA_CMN_PLLLC_SS_TIME_STEPSIZE_MODE_PREG}
2245871002d7SAnil Varughese };
2246871002d7SAnil Varughese 
2247871002d7SAnil Varughese /* refclk100MHz_32b_PCIe_ln_ext_ssc */
22483cfb0e8eSRikard Falkeborn static const struct cdns_reg_pairs cdns_pcie_ln_regs_ext_ssc[] = {
22497a5ad9b4SSwapnil Jakhade 	{0xFC08, SIERRA_DET_STANDEC_A_PREG},
22507a5ad9b4SSwapnil Jakhade 	{0x001D, SIERRA_PSM_A3IN_TMR_PREG},
22517a5ad9b4SSwapnil Jakhade 	{0x1555, SIERRA_DFE_BIASTRIM_PREG},
22527a5ad9b4SSwapnil Jakhade 	{0x9703, SIERRA_DRVCTRL_BOOST_PREG},
2253871002d7SAnil Varughese 	{0x813E, SIERRA_CLKPATHCTRL_TMR_PREG},
2254871002d7SAnil Varughese 	{0x8047, SIERRA_RX_CREQ_FLTR_A_MODE3_PREG},
2255871002d7SAnil Varughese 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE2_PREG},
2256871002d7SAnil Varughese 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG},
2257871002d7SAnil Varughese 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
22587a5ad9b4SSwapnil Jakhade 	{0x0002, SIERRA_CREQ_DCBIASATTEN_OVR_PREG},
22597a5ad9b4SSwapnil Jakhade 	{0x9800, SIERRA_RX_CTLE_CAL_PREG},
2260871002d7SAnil Varughese 	{0x033C, SIERRA_RX_CTLE_MAINTENANCE_PREG},
22617a5ad9b4SSwapnil Jakhade 	{0x44CC, SIERRA_CREQ_EQ_OPEN_EYE_THRESH_PREG},
22627a5ad9b4SSwapnil Jakhade 	{0x5624, SIERRA_DEQ_CONCUR_CTRL2_PREG},
22637a5ad9b4SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_EPIPWR_CTRL2_PREG},
22647a5ad9b4SSwapnil Jakhade 	{0x00FF, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG},
22657a5ad9b4SSwapnil Jakhade 	{0x4C4C, SIERRA_DEQ_ERRCMP_CTRL_PREG},
22667a5ad9b4SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_OFFSET_CTRL_PREG},
22677a5ad9b4SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_GAIN_CTRL_PREG},
22687a5ad9b4SSwapnil Jakhade 	{0x0041, SIERRA_DEQ_GLUT0},
22697a5ad9b4SSwapnil Jakhade 	{0x0082, SIERRA_DEQ_GLUT1},
22707a5ad9b4SSwapnil Jakhade 	{0x00C3, SIERRA_DEQ_GLUT2},
22717a5ad9b4SSwapnil Jakhade 	{0x0145, SIERRA_DEQ_GLUT3},
22727a5ad9b4SSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT4},
22737a5ad9b4SSwapnil Jakhade 	{0x09E7, SIERRA_DEQ_ALUT0},
22747a5ad9b4SSwapnil Jakhade 	{0x09A6, SIERRA_DEQ_ALUT1},
22757a5ad9b4SSwapnil Jakhade 	{0x0965, SIERRA_DEQ_ALUT2},
22767a5ad9b4SSwapnil Jakhade 	{0x08E3, SIERRA_DEQ_ALUT3},
22777a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP0},
22787a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP1},
22797a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP2},
22807a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP3},
22817a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP4},
22827a5ad9b4SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_PRECUR_PREG},
22837a5ad9b4SSwapnil Jakhade 	{0x0280, SIERRA_DEQ_POSTCUR_PREG},
22847a5ad9b4SSwapnil Jakhade 	{0x8F00, SIERRA_DEQ_POSTCUR_DECR_PREG},
22857a5ad9b4SSwapnil Jakhade 	{0x3C0F, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG},
22867a5ad9b4SSwapnil Jakhade 	{0x1C0C, SIERRA_DEQ_TAU_CTRL2_PREG},
22877a5ad9b4SSwapnil Jakhade 	{0x0100, SIERRA_DEQ_TAU_CTRL3_PREG},
2288*2d0f973bSBartosz Wawrzyniak 	{0x5E82, SIERRA_DEQ_TAU_EPIOFFSET_MODE_PREG},
22897a5ad9b4SSwapnil Jakhade 	{0x002B, SIERRA_CPI_TRIM_PREG},
22907a5ad9b4SSwapnil Jakhade 	{0x0003, SIERRA_EPI_CTRL_PREG},
22917a5ad9b4SSwapnil Jakhade 	{0x803F, SIERRA_SDFILT_H2L_A_PREG},
22927a5ad9b4SSwapnil Jakhade 	{0x0004, SIERRA_RXBUFFER_CTLECTRL_PREG},
22937a5ad9b4SSwapnil Jakhade 	{0x2010, SIERRA_RXBUFFER_RCDFECTRL_PREG},
22947a5ad9b4SSwapnil Jakhade 	{0x4432, SIERRA_RXBUFFER_DFECTRL_PREG}
2295871002d7SAnil Varughese };
2296871002d7SAnil Varughese 
2297da41bac5SChristophe JAILLET static const struct cdns_sierra_vals pcie_100_ext_ssc_cmn_vals = {
2298078e9e92SSwapnil Jakhade 	.reg_pairs = cdns_pcie_cmn_regs_ext_ssc,
2299078e9e92SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(cdns_pcie_cmn_regs_ext_ssc),
2300078e9e92SSwapnil Jakhade };
2301078e9e92SSwapnil Jakhade 
2302da41bac5SChristophe JAILLET static const struct cdns_sierra_vals pcie_100_ext_ssc_ln_vals = {
2303078e9e92SSwapnil Jakhade 	.reg_pairs = cdns_pcie_ln_regs_ext_ssc,
2304078e9e92SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(cdns_pcie_ln_regs_ext_ssc),
2305078e9e92SSwapnil Jakhade };
2306078e9e92SSwapnil Jakhade 
2307871002d7SAnil Varughese /* refclk100MHz_20b_USB_cmn_pll_ext_ssc */
23083cfb0e8eSRikard Falkeborn static const struct cdns_reg_pairs cdns_usb_cmn_regs_ext_ssc[] = {
2309871002d7SAnil Varughese 	{0x2085, SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG},
2310871002d7SAnil Varughese 	{0x2085, SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG},
2311871002d7SAnil Varughese 	{0x0000, SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG},
2312871002d7SAnil Varughese 	{0x0000, SIERRA_CMN_PLLLC_SS_TIME_STEPSIZE_MODE_PREG}
2313871002d7SAnil Varughese };
2314871002d7SAnil Varughese 
2315871002d7SAnil Varughese /* refclk100MHz_20b_USB_ln_ext_ssc */
23163cfb0e8eSRikard Falkeborn static const struct cdns_reg_pairs cdns_usb_ln_regs_ext_ssc[] = {
2317aead5fd6SKishon Vijay Abraham I 	{0xFE0A, SIERRA_DET_STANDEC_A_PREG},
2318aead5fd6SKishon Vijay Abraham I 	{0x000F, SIERRA_DET_STANDEC_B_PREG},
23192bcf14caSSanket Parmar 	{0x55A5, SIERRA_DET_STANDEC_C_PREG},
2320871002d7SAnil Varughese 	{0x69ad, SIERRA_DET_STANDEC_D_PREG},
2321aead5fd6SKishon Vijay Abraham I 	{0x0241, SIERRA_DET_STANDEC_E_PREG},
23222bcf14caSSanket Parmar 	{0x0110, SIERRA_PSM_LANECAL_DLY_A1_RESETS_PREG},
2323871002d7SAnil Varughese 	{0x0014, SIERRA_PSM_A0IN_TMR_PREG},
2324aead5fd6SKishon Vijay Abraham I 	{0xCF00, SIERRA_PSM_DIAG_PREG},
2325aead5fd6SKishon Vijay Abraham I 	{0x001F, SIERRA_PSC_TX_A0_PREG},
2326aead5fd6SKishon Vijay Abraham I 	{0x0007, SIERRA_PSC_TX_A1_PREG},
2327aead5fd6SKishon Vijay Abraham I 	{0x0003, SIERRA_PSC_TX_A2_PREG},
2328aead5fd6SKishon Vijay Abraham I 	{0x0003, SIERRA_PSC_TX_A3_PREG},
2329aead5fd6SKishon Vijay Abraham I 	{0x0FFF, SIERRA_PSC_RX_A0_PREG},
23302bcf14caSSanket Parmar 	{0x0003, SIERRA_PSC_RX_A1_PREG},
2331aead5fd6SKishon Vijay Abraham I 	{0x0003, SIERRA_PSC_RX_A2_PREG},
2332aead5fd6SKishon Vijay Abraham I 	{0x0001, SIERRA_PSC_RX_A3_PREG},
2333aead5fd6SKishon Vijay Abraham I 	{0x0001, SIERRA_PLLCTRL_SUBRATE_PREG},
2334aead5fd6SKishon Vijay Abraham I 	{0x0406, SIERRA_PLLCTRL_GEN_D_PREG},
2335871002d7SAnil Varughese 	{0x5233, SIERRA_PLLCTRL_CPGAIN_MODE_PREG},
2336871002d7SAnil Varughese 	{0x00CA, SIERRA_CLKPATH_BIASTRIM_PREG},
2337871002d7SAnil Varughese 	{0x2512, SIERRA_DFE_BIASTRIM_PREG},
2338aead5fd6SKishon Vijay Abraham I 	{0x0000, SIERRA_DRVCTRL_ATTEN_PREG},
23392bcf14caSSanket Parmar 	{0x823E, SIERRA_CLKPATHCTRL_TMR_PREG},
23402bcf14caSSanket Parmar 	{0x078F, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG},
23412bcf14caSSanket Parmar 	{0x078F, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
2342aead5fd6SKishon Vijay Abraham I 	{0x7B3C, SIERRA_CREQ_CCLKDET_MODE01_PREG},
23432bcf14caSSanket Parmar 	{0x023C, SIERRA_RX_CTLE_MAINTENANCE_PREG},
2344aead5fd6SKishon Vijay Abraham I 	{0x3232, SIERRA_CREQ_FSMCLK_SEL_PREG},
2345871002d7SAnil Varughese 	{0x0000, SIERRA_CREQ_EQ_CTRL_PREG},
23462bcf14caSSanket Parmar 	{0x0000, SIERRA_CREQ_SPARE_PREG},
2347871002d7SAnil Varughese 	{0xCC44, SIERRA_CREQ_EQ_OPEN_EYE_THRESH_PREG},
23482bcf14caSSanket Parmar 	{0x8452, SIERRA_CTLELUT_CTRL_PREG},
23492bcf14caSSanket Parmar 	{0x4121, SIERRA_DFE_ECMP_RATESEL_PREG},
23502bcf14caSSanket Parmar 	{0x4121, SIERRA_DFE_SMP_RATESEL_PREG},
23512bcf14caSSanket Parmar 	{0x0003, SIERRA_DEQ_PHALIGN_CTRL},
2352871002d7SAnil Varughese 	{0x3200, SIERRA_DEQ_CONCUR_CTRL1_PREG},
2353871002d7SAnil Varughese 	{0x5064, SIERRA_DEQ_CONCUR_CTRL2_PREG},
2354871002d7SAnil Varughese 	{0x0030, SIERRA_DEQ_EPIPWR_CTRL2_PREG},
2355871002d7SAnil Varughese 	{0x0048, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG},
2356871002d7SAnil Varughese 	{0x5A5A, SIERRA_DEQ_ERRCMP_CTRL_PREG},
2357871002d7SAnil Varughese 	{0x02F5, SIERRA_DEQ_OFFSET_CTRL_PREG},
2358871002d7SAnil Varughese 	{0x02F5, SIERRA_DEQ_GAIN_CTRL_PREG},
23592bcf14caSSanket Parmar 	{0x9999, SIERRA_DEQ_VGATUNE_CTRL_PREG},
2360871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT0},
2361871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT1},
2362871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT2},
2363871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT3},
2364871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT4},
2365871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT5},
2366871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT6},
2367871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT7},
2368871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT8},
2369871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT9},
2370871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT10},
2371871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT11},
2372871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT12},
2373871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT13},
2374871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT14},
2375871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT15},
2376871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT16},
2377871002d7SAnil Varughese 	{0x0BAE, SIERRA_DEQ_ALUT0},
2378871002d7SAnil Varughese 	{0x0AEB, SIERRA_DEQ_ALUT1},
2379871002d7SAnil Varughese 	{0x0A28, SIERRA_DEQ_ALUT2},
2380871002d7SAnil Varughese 	{0x0965, SIERRA_DEQ_ALUT3},
2381871002d7SAnil Varughese 	{0x08A2, SIERRA_DEQ_ALUT4},
2382871002d7SAnil Varughese 	{0x07DF, SIERRA_DEQ_ALUT5},
2383871002d7SAnil Varughese 	{0x071C, SIERRA_DEQ_ALUT6},
2384871002d7SAnil Varughese 	{0x0659, SIERRA_DEQ_ALUT7},
2385871002d7SAnil Varughese 	{0x0596, SIERRA_DEQ_ALUT8},
2386871002d7SAnil Varughese 	{0x0514, SIERRA_DEQ_ALUT9},
2387871002d7SAnil Varughese 	{0x0492, SIERRA_DEQ_ALUT10},
2388871002d7SAnil Varughese 	{0x0410, SIERRA_DEQ_ALUT11},
2389871002d7SAnil Varughese 	{0x038E, SIERRA_DEQ_ALUT12},
2390871002d7SAnil Varughese 	{0x030C, SIERRA_DEQ_ALUT13},
2391871002d7SAnil Varughese 	{0x03F4, SIERRA_DEQ_DFETAP_CTRL_PREG},
2392871002d7SAnil Varughese 	{0x0001, SIERRA_DFE_EN_1010_IGNORE_PREG},
2393871002d7SAnil Varughese 	{0x3C01, SIERRA_DEQ_TAU_CTRL1_FAST_MAINT_PREG},
2394871002d7SAnil Varughese 	{0x3C40, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG},
2395871002d7SAnil Varughese 	{0x1C08, SIERRA_DEQ_TAU_CTRL2_PREG},
2396871002d7SAnil Varughese 	{0x0033, SIERRA_DEQ_PICTRL_PREG},
2397871002d7SAnil Varughese 	{0x0400, SIERRA_CPICAL_TMRVAL_MODE1_PREG},
2398871002d7SAnil Varughese 	{0x0330, SIERRA_CPICAL_TMRVAL_MODE0_PREG},
2399871002d7SAnil Varughese 	{0x01FF, SIERRA_CPICAL_PICNT_MODE1_PREG},
2400aead5fd6SKishon Vijay Abraham I 	{0x0009, SIERRA_CPI_OUTBUF_RATESEL_PREG},
2401871002d7SAnil Varughese 	{0x3232, SIERRA_CPICAL_RES_STARTCODE_MODE23_PREG},
2402871002d7SAnil Varughese 	{0x0005, SIERRA_LFPSDET_SUPPORT_PREG},
2403aead5fd6SKishon Vijay Abraham I 	{0x000F, SIERRA_LFPSFILT_NS_PREG},
2404aead5fd6SKishon Vijay Abraham I 	{0x0009, SIERRA_LFPSFILT_RD_PREG},
2405aead5fd6SKishon Vijay Abraham I 	{0x0001, SIERRA_LFPSFILT_MP_PREG},
24062bcf14caSSanket Parmar 	{0x6013, SIERRA_SIGDET_SUPPORT_PREG},
2407aead5fd6SKishon Vijay Abraham I 	{0x8013, SIERRA_SDFILT_H2L_A_PREG},
2408871002d7SAnil Varughese 	{0x8009, SIERRA_SDFILT_L2H_PREG},
2409871002d7SAnil Varughese 	{0x0024, SIERRA_RXBUFFER_CTLECTRL_PREG},
2410871002d7SAnil Varughese 	{0x0020, SIERRA_RXBUFFER_RCDFECTRL_PREG},
2411871002d7SAnil Varughese 	{0x4243, SIERRA_RXBUFFER_DFECTRL_PREG}
241244d30d62SAlan Douglas };
241344d30d62SAlan Douglas 
2414da41bac5SChristophe JAILLET static const struct cdns_sierra_vals usb_100_ext_ssc_cmn_vals = {
2415078e9e92SSwapnil Jakhade 	.reg_pairs = cdns_usb_cmn_regs_ext_ssc,
2416078e9e92SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(cdns_usb_cmn_regs_ext_ssc),
2417078e9e92SSwapnil Jakhade };
2418078e9e92SSwapnil Jakhade 
2419da41bac5SChristophe JAILLET static const struct cdns_sierra_vals usb_100_ext_ssc_ln_vals = {
2420078e9e92SSwapnil Jakhade 	.reg_pairs = cdns_usb_ln_regs_ext_ssc,
2421078e9e92SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(cdns_usb_ln_regs_ext_ssc),
2422078e9e92SSwapnil Jakhade };
2423078e9e92SSwapnil Jakhade 
2424a1d12987SMarcin Wierzbicki /* SGMII PHY common configuration */
2425a1d12987SMarcin Wierzbicki static const struct cdns_reg_pairs sgmii_pma_cmn_vals[] = {
2426a1d12987SMarcin Wierzbicki 	{0x0180, SIERRA_SDOSCCAL_CLK_CNT_PREG},
2427a1d12987SMarcin Wierzbicki 	{0x6000, SIERRA_CMN_REFRCV_PREG},
2428a1d12987SMarcin Wierzbicki 	{0x0031, SIERRA_CMN_RESCAL_CTRLA_PREG},
2429a1d12987SMarcin Wierzbicki 	{0x001C, SIERRA_CMN_PLLLC_FBDIV_INT_MODE0_PREG},
2430a1d12987SMarcin Wierzbicki 	{0x2106, SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG},
2431a1d12987SMarcin Wierzbicki 	{0x0000, SIERRA_CMN_PLLLC_LOCKSEARCH_PREG},
2432a1d12987SMarcin Wierzbicki 	{0x8103, SIERRA_CMN_PLLLC_CLK0_PREG},
2433a1d12987SMarcin Wierzbicki 	{0x0000, SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG},
2434a1d12987SMarcin Wierzbicki 	{0x0027, SIERRA_CMN_PLLCSM_PLLEN_TMR_PREG},
2435a1d12987SMarcin Wierzbicki 	{0x0062, SIERRA_CMN_PLLCSM_PLLPRE_TMR_PREG},
2436a1d12987SMarcin Wierzbicki 	{0x0800, SIERRA_CMN_PLLLC_SS_TIME_STEPSIZE_MODE_PREG},
2437a1d12987SMarcin Wierzbicki 	{0x0000, SIERRA_CMN_PLLLC_INIT_PREG},
2438a1d12987SMarcin Wierzbicki 	{0x0000, SIERRA_CMN_PLLLC_ITERTMR_PREG},
2439a1d12987SMarcin Wierzbicki 	{0x0020, SIERRA_CMN_PLLLC_LOCK_CNTSTART_PREG},
2440a1d12987SMarcin Wierzbicki 	{0x0013, SIERRA_CMN_PLLLC_DCOCAL_CTRL_PREG},
2441a1d12987SMarcin Wierzbicki 	{0x0013, SIERRA_CMN_PLLLC1_DCOCAL_CTRL_PREG},
2442a1d12987SMarcin Wierzbicki };
2443a1d12987SMarcin Wierzbicki 
2444da41bac5SChristophe JAILLET static const struct cdns_sierra_vals sgmii_cmn_vals = {
2445a1d12987SMarcin Wierzbicki 	.reg_pairs = sgmii_pma_cmn_vals,
2446a1d12987SMarcin Wierzbicki 	.num_regs = ARRAY_SIZE(sgmii_pma_cmn_vals),
2447a1d12987SMarcin Wierzbicki };
2448a1d12987SMarcin Wierzbicki 
2449a1d12987SMarcin Wierzbicki /* SGMII PHY lane configuration */
2450a1d12987SMarcin Wierzbicki static const struct cdns_reg_pairs sgmii_ln_regs[] = {
2451a1d12987SMarcin Wierzbicki 	{0x691E, SIERRA_DET_STANDEC_D_PREG},
2452a1d12987SMarcin Wierzbicki 	{0x0FFE, SIERRA_PSC_RX_A0_PREG},
2453a1d12987SMarcin Wierzbicki 	{0x0104, SIERRA_PLLCTRL_FBDIV_MODE01_PREG},
2454a1d12987SMarcin Wierzbicki 	{0x0013, SIERRA_PLLCTRL_SUBRATE_PREG},
2455a1d12987SMarcin Wierzbicki 	{0x0106, SIERRA_PLLCTRL_GEN_D_PREG},
2456a1d12987SMarcin Wierzbicki 	{0x5234, SIERRA_PLLCTRL_CPGAIN_MODE_PREG},
2457a1d12987SMarcin Wierzbicki 	{0x0000, SIERRA_DRVCTRL_ATTEN_PREG},
2458a1d12987SMarcin Wierzbicki 	{0x00AB, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
2459a1d12987SMarcin Wierzbicki 	{0x3C0E, SIERRA_CREQ_CCLKDET_MODE01_PREG},
2460a1d12987SMarcin Wierzbicki 	{0x3220, SIERRA_CREQ_FSMCLK_SEL_PREG},
2461a1d12987SMarcin Wierzbicki 	{0x0000, SIERRA_CREQ_EQ_CTRL_PREG},
2462a1d12987SMarcin Wierzbicki 	{0x6320, SIERRA_DEQ_CONCUR_EPIOFFSET_MODE_PREG},
2463a1d12987SMarcin Wierzbicki 	{0x0000, SIERRA_CPI_OUTBUF_RATESEL_PREG},
2464a1d12987SMarcin Wierzbicki 	{0x15A2, SIERRA_LN_SPARE_REG_PREG},
2465a1d12987SMarcin Wierzbicki 	{0x7900, SIERRA_DEQ_BLK_TAU_CTRL1_PREG},
2466a1d12987SMarcin Wierzbicki 	{0x2202, SIERRA_DEQ_BLK_TAU_CTRL4_PREG},
2467a1d12987SMarcin Wierzbicki 	{0x2206, SIERRA_DEQ_TAU_CTRL2_PREG},
2468a1d12987SMarcin Wierzbicki 	{0x0005, SIERRA_LANE_TX_RECEIVER_DETECT_PREG},
2469a1d12987SMarcin Wierzbicki 	{0x8001, SIERRA_CREQ_SPARE_PREG},
2470a1d12987SMarcin Wierzbicki 	{0x0000, SIERRA_DEQ_CONCUR_CTRL1_PREG},
2471a1d12987SMarcin Wierzbicki 	{0xD004, SIERRA_DEQ_CONCUR_CTRL2_PREG},
2472a1d12987SMarcin Wierzbicki 	{0x0101, SIERRA_DEQ_GLUT9},
2473a1d12987SMarcin Wierzbicki 	{0x0101, SIERRA_DEQ_GLUT10},
2474a1d12987SMarcin Wierzbicki 	{0x0101, SIERRA_DEQ_GLUT11},
2475a1d12987SMarcin Wierzbicki 	{0x0101, SIERRA_DEQ_GLUT12},
2476a1d12987SMarcin Wierzbicki 	{0x0000, SIERRA_DEQ_GLUT13},
2477a1d12987SMarcin Wierzbicki 	{0x0000, SIERRA_DEQ_GLUT16},
2478a1d12987SMarcin Wierzbicki 	{0x0000, SIERRA_POSTPRECUR_EN_CEPH_CTRL_PREG},
2479a1d12987SMarcin Wierzbicki 	{0x0000, SIERRA_TAU_EN_CEPH2TO0_PREG},
2480a1d12987SMarcin Wierzbicki 	{0x0003, SIERRA_TAU_EN_CEPH5TO3_PREG},
2481a1d12987SMarcin Wierzbicki 	{0x0101, SIERRA_DEQ_ALUT8},
2482a1d12987SMarcin Wierzbicki 	{0x0101, SIERRA_DEQ_ALUT9},
2483a1d12987SMarcin Wierzbicki 	{0x0100, SIERRA_DEQ_ALUT10},
2484a1d12987SMarcin Wierzbicki 	{0x0000, SIERRA_OEPH_EN_CTRL_PREG},
2485a1d12987SMarcin Wierzbicki 	{0x5425, SIERRA_DEQ_OPENEYE_CTRL_PREG},
2486a1d12987SMarcin Wierzbicki 	{0x7458, SIERRA_CPICAL_RES_STARTCODE_MODE23_PREG},
2487a1d12987SMarcin Wierzbicki 	{0x321F, SIERRA_CPICAL_RES_STARTCODE_MODE01_PREG},
2488a1d12987SMarcin Wierzbicki };
2489a1d12987SMarcin Wierzbicki 
2490da41bac5SChristophe JAILLET static const struct cdns_sierra_vals sgmii_pma_ln_vals = {
2491a1d12987SMarcin Wierzbicki 	.reg_pairs = sgmii_ln_regs,
2492a1d12987SMarcin Wierzbicki 	.num_regs = ARRAY_SIZE(sgmii_ln_regs),
2493a1d12987SMarcin Wierzbicki };
2494a1d12987SMarcin Wierzbicki 
249544d30d62SAlan Douglas static const struct cdns_sierra_data cdns_map_sierra = {
2496078e9e92SSwapnil Jakhade 	.id_value = SIERRA_MACRO_ID,
2497078e9e92SSwapnil Jakhade 	.block_offset_shift = 0x2,
2498078e9e92SSwapnil Jakhade 	.reg_offset_shift = 0x2,
2499fa105172SSwapnil Jakhade 	.pcs_cmn_vals = {
2500fa105172SSwapnil Jakhade 		[TYPE_PCIE] = {
2501fa105172SSwapnil Jakhade 			[TYPE_NONE] = {
25027a5ad9b4SSwapnil Jakhade 				[NO_SSC] = &pcie_phy_pcs_cmn_vals,
2503fa105172SSwapnil Jakhade 				[EXTERNAL_SSC] = &pcie_phy_pcs_cmn_vals,
25047a5ad9b4SSwapnil Jakhade 				[INTERNAL_SSC] = &pcie_phy_pcs_cmn_vals,
2505fa105172SSwapnil Jakhade 			},
25060cfa43abSSwapnil Jakhade 			[TYPE_SGMII] = {
25070cfa43abSSwapnil Jakhade 				[NO_SSC] = &pcie_phy_pcs_cmn_vals,
25080cfa43abSSwapnil Jakhade 				[EXTERNAL_SSC] = &pcie_phy_pcs_cmn_vals,
25090cfa43abSSwapnil Jakhade 				[INTERNAL_SSC] = &pcie_phy_pcs_cmn_vals,
25100cfa43abSSwapnil Jakhade 			},
25118a1b82d7SSwapnil Jakhade 			[TYPE_QSGMII] = {
25128a1b82d7SSwapnil Jakhade 				[NO_SSC] = &pcie_phy_pcs_cmn_vals,
25138a1b82d7SSwapnil Jakhade 				[EXTERNAL_SSC] = &pcie_phy_pcs_cmn_vals,
25148a1b82d7SSwapnil Jakhade 				[INTERNAL_SSC] = &pcie_phy_pcs_cmn_vals,
25158a1b82d7SSwapnil Jakhade 			},
2516fa105172SSwapnil Jakhade 		},
2517fa105172SSwapnil Jakhade 	},
2518078e9e92SSwapnil Jakhade 	.pma_cmn_vals = {
2519078e9e92SSwapnil Jakhade 		[TYPE_PCIE] = {
2520078e9e92SSwapnil Jakhade 			[TYPE_NONE] = {
25217a5ad9b4SSwapnil Jakhade 				[NO_SSC] = &pcie_100_no_ssc_cmn_vals,
2522078e9e92SSwapnil Jakhade 				[EXTERNAL_SSC] = &pcie_100_ext_ssc_cmn_vals,
25237a5ad9b4SSwapnil Jakhade 				[INTERNAL_SSC] = &pcie_100_int_ssc_cmn_vals,
2524078e9e92SSwapnil Jakhade 			},
25250cfa43abSSwapnil Jakhade 			[TYPE_SGMII] = {
25260cfa43abSSwapnil Jakhade 				[NO_SSC] = &pcie_100_no_ssc_plllc_cmn_vals,
25270cfa43abSSwapnil Jakhade 				[EXTERNAL_SSC] = &pcie_100_ext_ssc_plllc_cmn_vals,
25280cfa43abSSwapnil Jakhade 				[INTERNAL_SSC] = &pcie_100_int_ssc_plllc_cmn_vals,
25290cfa43abSSwapnil Jakhade 			},
25308a1b82d7SSwapnil Jakhade 			[TYPE_QSGMII] = {
25318a1b82d7SSwapnil Jakhade 				[NO_SSC] = &pcie_100_no_ssc_plllc_cmn_vals,
25328a1b82d7SSwapnil Jakhade 				[EXTERNAL_SSC] = &pcie_100_ext_ssc_plllc_cmn_vals,
25338a1b82d7SSwapnil Jakhade 				[INTERNAL_SSC] = &pcie_100_int_ssc_plllc_cmn_vals,
25348a1b82d7SSwapnil Jakhade 			},
2535078e9e92SSwapnil Jakhade 		},
2536078e9e92SSwapnil Jakhade 		[TYPE_USB] = {
2537078e9e92SSwapnil Jakhade 			[TYPE_NONE] = {
2538078e9e92SSwapnil Jakhade 				[EXTERNAL_SSC] = &usb_100_ext_ssc_cmn_vals,
2539078e9e92SSwapnil Jakhade 			},
2540078e9e92SSwapnil Jakhade 		},
25410cfa43abSSwapnil Jakhade 		[TYPE_SGMII] = {
2542a1d12987SMarcin Wierzbicki 			[TYPE_NONE] = {
2543a1d12987SMarcin Wierzbicki 				[NO_SSC] = &sgmii_cmn_vals,
2544a1d12987SMarcin Wierzbicki 			},
25450cfa43abSSwapnil Jakhade 			[TYPE_PCIE] = {
25460cfa43abSSwapnil Jakhade 				[NO_SSC] = &sgmii_100_no_ssc_plllc1_opt3_cmn_vals,
25470cfa43abSSwapnil Jakhade 				[EXTERNAL_SSC] = &sgmii_100_no_ssc_plllc1_opt3_cmn_vals,
25480cfa43abSSwapnil Jakhade 				[INTERNAL_SSC] = &sgmii_100_no_ssc_plllc1_opt3_cmn_vals,
25490cfa43abSSwapnil Jakhade 			},
25500cfa43abSSwapnil Jakhade 		},
25518a1b82d7SSwapnil Jakhade 		[TYPE_QSGMII] = {
25528a1b82d7SSwapnil Jakhade 			[TYPE_PCIE] = {
25538a1b82d7SSwapnil Jakhade 				[NO_SSC] = &qsgmii_100_no_ssc_plllc1_cmn_vals,
25548a1b82d7SSwapnil Jakhade 				[EXTERNAL_SSC] = &qsgmii_100_no_ssc_plllc1_cmn_vals,
25558a1b82d7SSwapnil Jakhade 				[INTERNAL_SSC] = &qsgmii_100_no_ssc_plllc1_cmn_vals,
25568a1b82d7SSwapnil Jakhade 			},
25578a1b82d7SSwapnil Jakhade 		},
2558078e9e92SSwapnil Jakhade 	},
2559078e9e92SSwapnil Jakhade 	.pma_ln_vals = {
2560078e9e92SSwapnil Jakhade 		[TYPE_PCIE] = {
2561078e9e92SSwapnil Jakhade 			[TYPE_NONE] = {
25627a5ad9b4SSwapnil Jakhade 				[NO_SSC] = &pcie_100_no_ssc_ln_vals,
2563078e9e92SSwapnil Jakhade 				[EXTERNAL_SSC] = &pcie_100_ext_ssc_ln_vals,
25647a5ad9b4SSwapnil Jakhade 				[INTERNAL_SSC] = &pcie_100_int_ssc_ln_vals,
2565078e9e92SSwapnil Jakhade 			},
25660cfa43abSSwapnil Jakhade 			[TYPE_SGMII] = {
25670cfa43abSSwapnil Jakhade 				[NO_SSC] = &ml_pcie_100_no_ssc_ln_vals,
25680cfa43abSSwapnil Jakhade 				[EXTERNAL_SSC] = &ml_pcie_100_ext_ssc_ln_vals,
25690cfa43abSSwapnil Jakhade 				[INTERNAL_SSC] = &ml_pcie_100_int_ssc_ln_vals,
25700cfa43abSSwapnil Jakhade 			},
25718a1b82d7SSwapnil Jakhade 			[TYPE_QSGMII] = {
25728a1b82d7SSwapnil Jakhade 				[NO_SSC] = &ml_pcie_100_no_ssc_ln_vals,
25738a1b82d7SSwapnil Jakhade 				[EXTERNAL_SSC] = &ml_pcie_100_ext_ssc_ln_vals,
25748a1b82d7SSwapnil Jakhade 				[INTERNAL_SSC] = &ml_pcie_100_int_ssc_ln_vals,
25758a1b82d7SSwapnil Jakhade 			},
2576078e9e92SSwapnil Jakhade 		},
2577078e9e92SSwapnil Jakhade 		[TYPE_USB] = {
2578078e9e92SSwapnil Jakhade 			[TYPE_NONE] = {
2579078e9e92SSwapnil Jakhade 				[EXTERNAL_SSC] = &usb_100_ext_ssc_ln_vals,
2580078e9e92SSwapnil Jakhade 			},
2581078e9e92SSwapnil Jakhade 		},
25820cfa43abSSwapnil Jakhade 		[TYPE_SGMII] = {
2583a1d12987SMarcin Wierzbicki 			[TYPE_NONE] = {
2584a1d12987SMarcin Wierzbicki 				[NO_SSC] = &sgmii_pma_ln_vals,
2585a1d12987SMarcin Wierzbicki 			},
25860cfa43abSSwapnil Jakhade 			[TYPE_PCIE] = {
25870cfa43abSSwapnil Jakhade 				[NO_SSC] = &sgmii_100_no_ssc_plllc1_opt3_ln_vals,
25880cfa43abSSwapnil Jakhade 				[EXTERNAL_SSC] = &sgmii_100_no_ssc_plllc1_opt3_ln_vals,
25890cfa43abSSwapnil Jakhade 				[INTERNAL_SSC] = &sgmii_100_no_ssc_plllc1_opt3_ln_vals,
25900cfa43abSSwapnil Jakhade 			},
25910cfa43abSSwapnil Jakhade 		},
25928a1b82d7SSwapnil Jakhade 		[TYPE_QSGMII] = {
25938a1b82d7SSwapnil Jakhade 			[TYPE_PCIE] = {
25948a1b82d7SSwapnil Jakhade 				[NO_SSC] = &qsgmii_100_no_ssc_plllc1_ln_vals,
25958a1b82d7SSwapnil Jakhade 				[EXTERNAL_SSC] = &qsgmii_100_no_ssc_plllc1_ln_vals,
25968a1b82d7SSwapnil Jakhade 				[INTERNAL_SSC] = &qsgmii_100_no_ssc_plllc1_ln_vals,
25978a1b82d7SSwapnil Jakhade 			},
25988a1b82d7SSwapnil Jakhade 		},
2599078e9e92SSwapnil Jakhade 	},
260044d30d62SAlan Douglas };
260144d30d62SAlan Douglas 
2602367da978SKishon Vijay Abraham I static const struct cdns_sierra_data cdns_ti_map_sierra = {
2603078e9e92SSwapnil Jakhade 	.id_value = SIERRA_MACRO_ID,
2604078e9e92SSwapnil Jakhade 	.block_offset_shift = 0x0,
2605078e9e92SSwapnil Jakhade 	.reg_offset_shift = 0x1,
2606fa105172SSwapnil Jakhade 	.pcs_cmn_vals = {
2607fa105172SSwapnil Jakhade 		[TYPE_PCIE] = {
2608fa105172SSwapnil Jakhade 			[TYPE_NONE] = {
26097a5ad9b4SSwapnil Jakhade 				[NO_SSC] = &pcie_phy_pcs_cmn_vals,
2610fa105172SSwapnil Jakhade 				[EXTERNAL_SSC] = &pcie_phy_pcs_cmn_vals,
26117a5ad9b4SSwapnil Jakhade 				[INTERNAL_SSC] = &pcie_phy_pcs_cmn_vals,
2612fa105172SSwapnil Jakhade 			},
26130cfa43abSSwapnil Jakhade 			[TYPE_SGMII] = {
26140cfa43abSSwapnil Jakhade 				[NO_SSC] = &pcie_phy_pcs_cmn_vals,
26150cfa43abSSwapnil Jakhade 				[EXTERNAL_SSC] = &pcie_phy_pcs_cmn_vals,
26160cfa43abSSwapnil Jakhade 				[INTERNAL_SSC] = &pcie_phy_pcs_cmn_vals,
26170cfa43abSSwapnil Jakhade 			},
26188a1b82d7SSwapnil Jakhade 			[TYPE_QSGMII] = {
26198a1b82d7SSwapnil Jakhade 				[NO_SSC] = &pcie_phy_pcs_cmn_vals,
26208a1b82d7SSwapnil Jakhade 				[EXTERNAL_SSC] = &pcie_phy_pcs_cmn_vals,
26218a1b82d7SSwapnil Jakhade 				[INTERNAL_SSC] = &pcie_phy_pcs_cmn_vals,
26228a1b82d7SSwapnil Jakhade 			},
26238a1b82d7SSwapnil Jakhade 		},
26248a1b82d7SSwapnil Jakhade 	},
26258a1b82d7SSwapnil Jakhade 	.phy_pma_ln_vals = {
26260cfa43abSSwapnil Jakhade 		[TYPE_SGMII] = {
26270cfa43abSSwapnil Jakhade 			[TYPE_PCIE] = {
26280cfa43abSSwapnil Jakhade 				[NO_SSC] = &sgmii_phy_pma_ln_vals,
26290cfa43abSSwapnil Jakhade 				[EXTERNAL_SSC] = &sgmii_phy_pma_ln_vals,
26300cfa43abSSwapnil Jakhade 				[INTERNAL_SSC] = &sgmii_phy_pma_ln_vals,
26310cfa43abSSwapnil Jakhade 			},
26320cfa43abSSwapnil Jakhade 		},
26338a1b82d7SSwapnil Jakhade 		[TYPE_QSGMII] = {
26348a1b82d7SSwapnil Jakhade 			[TYPE_PCIE] = {
26358a1b82d7SSwapnil Jakhade 				[NO_SSC] = &qsgmii_phy_pma_ln_vals,
26368a1b82d7SSwapnil Jakhade 				[EXTERNAL_SSC] = &qsgmii_phy_pma_ln_vals,
26378a1b82d7SSwapnil Jakhade 				[INTERNAL_SSC] = &qsgmii_phy_pma_ln_vals,
26388a1b82d7SSwapnil Jakhade 			},
2639fa105172SSwapnil Jakhade 		},
2640fa105172SSwapnil Jakhade 	},
2641078e9e92SSwapnil Jakhade 	.pma_cmn_vals = {
2642078e9e92SSwapnil Jakhade 		[TYPE_PCIE] = {
2643078e9e92SSwapnil Jakhade 			[TYPE_NONE] = {
26447a5ad9b4SSwapnil Jakhade 				[NO_SSC] = &pcie_100_no_ssc_cmn_vals,
2645078e9e92SSwapnil Jakhade 				[EXTERNAL_SSC] = &pcie_100_ext_ssc_cmn_vals,
26467a5ad9b4SSwapnil Jakhade 				[INTERNAL_SSC] = &pcie_100_int_ssc_cmn_vals,
2647078e9e92SSwapnil Jakhade 			},
26480cfa43abSSwapnil Jakhade 			[TYPE_SGMII] = {
26490cfa43abSSwapnil Jakhade 				[NO_SSC] = &pcie_100_no_ssc_plllc_cmn_vals,
26500cfa43abSSwapnil Jakhade 				[EXTERNAL_SSC] = &pcie_100_ext_ssc_plllc_cmn_vals,
26510cfa43abSSwapnil Jakhade 				[INTERNAL_SSC] = &pcie_100_int_ssc_plllc_cmn_vals,
26520cfa43abSSwapnil Jakhade 			},
26538a1b82d7SSwapnil Jakhade 			[TYPE_QSGMII] = {
26548a1b82d7SSwapnil Jakhade 				[NO_SSC] = &pcie_100_no_ssc_plllc_cmn_vals,
26558a1b82d7SSwapnil Jakhade 				[EXTERNAL_SSC] = &pcie_100_ext_ssc_plllc_cmn_vals,
26568a1b82d7SSwapnil Jakhade 				[INTERNAL_SSC] = &pcie_100_int_ssc_plllc_cmn_vals,
26578a1b82d7SSwapnil Jakhade 			},
2658078e9e92SSwapnil Jakhade 		},
2659078e9e92SSwapnil Jakhade 		[TYPE_USB] = {
2660078e9e92SSwapnil Jakhade 			[TYPE_NONE] = {
2661078e9e92SSwapnil Jakhade 				[EXTERNAL_SSC] = &usb_100_ext_ssc_cmn_vals,
2662078e9e92SSwapnil Jakhade 			},
2663078e9e92SSwapnil Jakhade 		},
26640cfa43abSSwapnil Jakhade 		[TYPE_SGMII] = {
26650cfa43abSSwapnil Jakhade 			[TYPE_PCIE] = {
26660cfa43abSSwapnil Jakhade 				[NO_SSC] = &sgmii_100_no_ssc_plllc1_opt3_cmn_vals,
26670cfa43abSSwapnil Jakhade 				[EXTERNAL_SSC] = &sgmii_100_no_ssc_plllc1_opt3_cmn_vals,
26680cfa43abSSwapnil Jakhade 				[INTERNAL_SSC] = &sgmii_100_no_ssc_plllc1_opt3_cmn_vals,
26690cfa43abSSwapnil Jakhade 			},
26700cfa43abSSwapnil Jakhade 		},
26718a1b82d7SSwapnil Jakhade 		[TYPE_QSGMII] = {
26728a1b82d7SSwapnil Jakhade 			[TYPE_PCIE] = {
26738a1b82d7SSwapnil Jakhade 				[NO_SSC] = &qsgmii_100_no_ssc_plllc1_cmn_vals,
26748a1b82d7SSwapnil Jakhade 				[EXTERNAL_SSC] = &qsgmii_100_no_ssc_plllc1_cmn_vals,
26758a1b82d7SSwapnil Jakhade 				[INTERNAL_SSC] = &qsgmii_100_no_ssc_plllc1_cmn_vals,
26768a1b82d7SSwapnil Jakhade 			},
26778a1b82d7SSwapnil Jakhade 		},
2678078e9e92SSwapnil Jakhade 	},
2679078e9e92SSwapnil Jakhade 	.pma_ln_vals = {
2680078e9e92SSwapnil Jakhade 		[TYPE_PCIE] = {
2681078e9e92SSwapnil Jakhade 			[TYPE_NONE] = {
26827a5ad9b4SSwapnil Jakhade 				[NO_SSC] = &pcie_100_no_ssc_ln_vals,
2683078e9e92SSwapnil Jakhade 				[EXTERNAL_SSC] = &pcie_100_ext_ssc_ln_vals,
26847a5ad9b4SSwapnil Jakhade 				[INTERNAL_SSC] = &pcie_100_int_ssc_ln_vals,
2685078e9e92SSwapnil Jakhade 			},
26860cfa43abSSwapnil Jakhade 			[TYPE_SGMII] = {
26870cfa43abSSwapnil Jakhade 				[NO_SSC] = &ti_ml_pcie_100_no_ssc_ln_vals,
26880cfa43abSSwapnil Jakhade 				[EXTERNAL_SSC] = &ti_ml_pcie_100_ext_ssc_ln_vals,
26890cfa43abSSwapnil Jakhade 				[INTERNAL_SSC] = &ti_ml_pcie_100_int_ssc_ln_vals,
26900cfa43abSSwapnil Jakhade 			},
26918a1b82d7SSwapnil Jakhade 			[TYPE_QSGMII] = {
2692e72659b6SSwapnil Jakhade 				[NO_SSC] = &ti_ml_pcie_100_no_ssc_ln_vals,
2693e72659b6SSwapnil Jakhade 				[EXTERNAL_SSC] = &ti_ml_pcie_100_ext_ssc_ln_vals,
2694e72659b6SSwapnil Jakhade 				[INTERNAL_SSC] = &ti_ml_pcie_100_int_ssc_ln_vals,
26958a1b82d7SSwapnil Jakhade 			},
2696078e9e92SSwapnil Jakhade 		},
2697078e9e92SSwapnil Jakhade 		[TYPE_USB] = {
2698078e9e92SSwapnil Jakhade 			[TYPE_NONE] = {
2699078e9e92SSwapnil Jakhade 				[EXTERNAL_SSC] = &usb_100_ext_ssc_ln_vals,
2700078e9e92SSwapnil Jakhade 			},
2701078e9e92SSwapnil Jakhade 		},
27020cfa43abSSwapnil Jakhade 		[TYPE_SGMII] = {
27030cfa43abSSwapnil Jakhade 			[TYPE_PCIE] = {
27040cfa43abSSwapnil Jakhade 				[NO_SSC] = &sgmii_100_no_ssc_plllc1_opt3_ln_vals,
27050cfa43abSSwapnil Jakhade 				[EXTERNAL_SSC] = &sgmii_100_no_ssc_plllc1_opt3_ln_vals,
27060cfa43abSSwapnil Jakhade 				[INTERNAL_SSC] = &sgmii_100_no_ssc_plllc1_opt3_ln_vals,
27070cfa43abSSwapnil Jakhade 			},
27080cfa43abSSwapnil Jakhade 		},
27098a1b82d7SSwapnil Jakhade 		[TYPE_QSGMII] = {
27108a1b82d7SSwapnil Jakhade 			[TYPE_PCIE] = {
27118a1b82d7SSwapnil Jakhade 				[NO_SSC] = &qsgmii_100_no_ssc_plllc1_ln_vals,
27128a1b82d7SSwapnil Jakhade 				[EXTERNAL_SSC] = &qsgmii_100_no_ssc_plllc1_ln_vals,
27138a1b82d7SSwapnil Jakhade 				[INTERNAL_SSC] = &qsgmii_100_no_ssc_plllc1_ln_vals,
27148a1b82d7SSwapnil Jakhade 			},
27158a1b82d7SSwapnil Jakhade 		},
2716078e9e92SSwapnil Jakhade 	},
2717367da978SKishon Vijay Abraham I };
2718367da978SKishon Vijay Abraham I 
271944d30d62SAlan Douglas static const struct of_device_id cdns_sierra_id_table[] = {
272044d30d62SAlan Douglas 	{
272144d30d62SAlan Douglas 		.compatible = "cdns,sierra-phy-t0",
272244d30d62SAlan Douglas 		.data = &cdns_map_sierra,
272344d30d62SAlan Douglas 	},
2724367da978SKishon Vijay Abraham I 	{
2725367da978SKishon Vijay Abraham I 		.compatible = "ti,sierra-phy-t0",
2726367da978SKishon Vijay Abraham I 		.data = &cdns_ti_map_sierra,
2727367da978SKishon Vijay Abraham I 	},
272844d30d62SAlan Douglas 	{}
272944d30d62SAlan Douglas };
273044d30d62SAlan Douglas MODULE_DEVICE_TABLE(of, cdns_sierra_id_table);
273144d30d62SAlan Douglas 
273244d30d62SAlan Douglas static struct platform_driver cdns_sierra_driver = {
273344d30d62SAlan Douglas 	.probe		= cdns_sierra_phy_probe,
2734e9ddb1adSUwe Kleine-König 	.remove_new	= cdns_sierra_phy_remove,
273544d30d62SAlan Douglas 	.driver		= {
273644d30d62SAlan Douglas 		.name	= "cdns-sierra-phy",
273744d30d62SAlan Douglas 		.of_match_table = cdns_sierra_id_table,
273844d30d62SAlan Douglas 	},
273944d30d62SAlan Douglas };
274044d30d62SAlan Douglas module_platform_driver(cdns_sierra_driver);
274144d30d62SAlan Douglas 
274244d30d62SAlan Douglas MODULE_ALIAS("platform:cdns_sierra");
274344d30d62SAlan Douglas MODULE_AUTHOR("Cadence Design Systems");
274444d30d62SAlan Douglas MODULE_DESCRIPTION("CDNS sierra phy driver");
274544d30d62SAlan Douglas MODULE_LICENSE("GPL v2");
2746