xref: /linux/drivers/phy/cadence/phy-cadence-sierra.c (revision f75999c525a1d7d6c4425a6a225cabae40ab1721)
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
1777a5ad9b4SSwapnil Jakhade #define SIERRA_DEQ_OPENEYE_CTRL_PREG			0x158
178a1d12987SMarcin Wierzbicki #define SIERRA_DEQ_CONCUR_EPIOFFSET_MODE_PREG		0x159
179871002d7SAnil Varughese #define SIERRA_DEQ_PICTRL_PREG				0x161
180871002d7SAnil Varughese #define SIERRA_CPICAL_TMRVAL_MODE1_PREG			0x170
181871002d7SAnil Varughese #define SIERRA_CPICAL_TMRVAL_MODE0_PREG			0x171
182871002d7SAnil Varughese #define SIERRA_CPICAL_PICNT_MODE1_PREG			0x174
183aead5fd6SKishon Vijay Abraham I #define SIERRA_CPI_OUTBUF_RATESEL_PREG			0x17C
1848a1b82d7SSwapnil Jakhade #define SIERRA_CPI_RESBIAS_BIN_PREG			0x17E
1857a5ad9b4SSwapnil Jakhade #define SIERRA_CPI_TRIM_PREG				0x17F
186871002d7SAnil Varughese #define SIERRA_CPICAL_RES_STARTCODE_MODE23_PREG		0x183
187a1d12987SMarcin Wierzbicki #define SIERRA_CPICAL_RES_STARTCODE_MODE01_PREG		0x184
1887a5ad9b4SSwapnil Jakhade #define SIERRA_EPI_CTRL_PREG				0x187
189871002d7SAnil Varughese #define SIERRA_LFPSDET_SUPPORT_PREG			0x188
190aead5fd6SKishon Vijay Abraham I #define SIERRA_LFPSFILT_NS_PREG				0x18A
191aead5fd6SKishon Vijay Abraham I #define SIERRA_LFPSFILT_RD_PREG				0x18B
192aead5fd6SKishon Vijay Abraham I #define SIERRA_LFPSFILT_MP_PREG				0x18C
193871002d7SAnil Varughese #define SIERRA_SIGDET_SUPPORT_PREG			0x190
194aead5fd6SKishon Vijay Abraham I #define SIERRA_SDFILT_H2L_A_PREG			0x191
195871002d7SAnil Varughese #define SIERRA_SDFILT_L2H_PREG				0x193
196871002d7SAnil Varughese #define SIERRA_RXBUFFER_CTLECTRL_PREG			0x19E
197871002d7SAnil Varughese #define SIERRA_RXBUFFER_RCDFECTRL_PREG			0x19F
198871002d7SAnil Varughese #define SIERRA_RXBUFFER_DFECTRL_PREG			0x1A0
199a1d12987SMarcin Wierzbicki #define SIERRA_LN_SPARE_REG_PREG			0x1B0
200871002d7SAnil Varughese #define SIERRA_DEQ_TAU_CTRL1_FAST_MAINT_PREG		0x14F
201871002d7SAnil Varughese #define SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG		0x150
202380f5708SKishon Vijay Abraham I 
2038c95e172SSwapnil Jakhade /* PHY PCS common registers */
2048c95e172SSwapnil Jakhade #define SIERRA_PHY_PCS_COMMON_OFFSET(block_offset)	\
205380f5708SKishon Vijay Abraham I 				     (0xc000 << (block_offset))
206fa105172SSwapnil Jakhade #define SIERRA_PHY_PIPE_CMN_CTRL1			0x0
207380f5708SKishon Vijay Abraham I #define SIERRA_PHY_PLL_CFG				0xe
20844d30d62SAlan Douglas 
20936ce4163SSwapnil Jakhade /* PHY PCS lane registers */
21036ce4163SSwapnil Jakhade #define SIERRA_PHY_PCS_LANE_CDB_OFFSET(ln, block_offset, reg_offset)	\
21136ce4163SSwapnil Jakhade 				       ((0xD000 << (block_offset)) +	\
21236ce4163SSwapnil Jakhade 				       (((ln) << 8) << (reg_offset)))
21336ce4163SSwapnil Jakhade 
21436ce4163SSwapnil Jakhade #define SIERRA_PHY_ISO_LINK_CTRL			0xB
21536ce4163SSwapnil Jakhade 
216f1cc6c3fSSwapnil Jakhade /* PHY PMA common registers */
217f1cc6c3fSSwapnil Jakhade #define SIERRA_PHY_PMA_COMMON_OFFSET(block_offset)	\
218f1cc6c3fSSwapnil Jakhade 				     (0xE000 << (block_offset))
219f1cc6c3fSSwapnil Jakhade #define SIERRA_PHY_PMA_CMN_CTRL				0x000
220f1cc6c3fSSwapnil Jakhade 
2216b81f05aSSwapnil Jakhade /* PHY PMA lane registers */
2226b81f05aSSwapnil Jakhade #define SIERRA_PHY_PMA_LANE_CDB_OFFSET(ln, block_offset, reg_offset)	\
2236b81f05aSSwapnil Jakhade 				       ((0xF000 << (block_offset)) +	\
2246b81f05aSSwapnil Jakhade 				       (((ln) << 8) << (reg_offset)))
2256b81f05aSSwapnil Jakhade 
2266b81f05aSSwapnil Jakhade #define SIERRA_PHY_PMA_XCVR_CTRL			0x000
2276b81f05aSSwapnil Jakhade 
22844d30d62SAlan Douglas #define SIERRA_MACRO_ID					0x00007364
229a43f72aeSKishon Vijay Abraham I #define SIERRA_MAX_LANES				16
230adc4bd6fSKishon Vijay Abraham I #define PLL_LOCK_TIME					100000
23144d30d62SAlan Douglas 
23209d976b3SSwapnil Jakhade #define CDNS_SIERRA_OUTPUT_CLOCKS			3
233a59f6006SLars-Peter Clausen #define CDNS_SIERRA_INPUT_CLOCKS			3
234a0c30cd7SKishon Vijay Abraham I enum cdns_sierra_clock_input {
235a0c30cd7SKishon Vijay Abraham I 	PHY_CLK,
236a0c30cd7SKishon Vijay Abraham I 	CMN_REFCLK_DIG_DIV,
237a0c30cd7SKishon Vijay Abraham I 	CMN_REFCLK1_DIG_DIV,
238a0c30cd7SKishon Vijay Abraham I };
239a0c30cd7SKishon Vijay Abraham I 
24028081b72SKishon Vijay Abraham I #define SIERRA_NUM_CMN_PLLC				2
24128081b72SKishon Vijay Abraham I #define SIERRA_NUM_CMN_PLLC_PARENTS			2
24228081b72SKishon Vijay Abraham I 
243380f5708SKishon Vijay Abraham I static const struct reg_field macro_id_type =
244380f5708SKishon Vijay Abraham I 				REG_FIELD(SIERRA_MACRO_ID_REG, 0, 15);
245380f5708SKishon Vijay Abraham I static const struct reg_field phy_pll_cfg_1 =
246380f5708SKishon Vijay Abraham I 				REG_FIELD(SIERRA_PHY_PLL_CFG, 1, 1);
247f1cc6c3fSSwapnil Jakhade static const struct reg_field pma_cmn_ready =
248f1cc6c3fSSwapnil Jakhade 				REG_FIELD(SIERRA_PHY_PMA_CMN_CTRL, 0, 0);
249adc4bd6fSKishon Vijay Abraham I static const struct reg_field pllctrl_lock =
250adc4bd6fSKishon Vijay Abraham I 				REG_FIELD(SIERRA_PLLCTRL_STATUS_PREG, 0, 0);
25136ce4163SSwapnil Jakhade static const struct reg_field phy_iso_link_ctrl_1 =
25236ce4163SSwapnil Jakhade 				REG_FIELD(SIERRA_PHY_ISO_LINK_CTRL, 1, 1);
25309d976b3SSwapnil Jakhade static const struct reg_field cmn_plllc_clk1outdiv_preg =
25409d976b3SSwapnil Jakhade 				REG_FIELD(SIERRA_CMN_PLLLC_CLK1_PREG, 0, 6);
25509d976b3SSwapnil Jakhade static const struct reg_field cmn_plllc_clk1_en_preg =
25609d976b3SSwapnil Jakhade 				REG_FIELD(SIERRA_CMN_PLLLC_CLK1_PREG, 12, 12);
257380f5708SKishon Vijay Abraham I 
25828081b72SKishon Vijay Abraham I static const char * const clk_names[] = {
25928081b72SKishon Vijay Abraham I 	[CDNS_SIERRA_PLL_CMNLC] = "pll_cmnlc",
26028081b72SKishon Vijay Abraham I 	[CDNS_SIERRA_PLL_CMNLC1] = "pll_cmnlc1",
26109d976b3SSwapnil Jakhade 	[CDNS_SIERRA_DERIVED_REFCLK] = "refclk_der",
26228081b72SKishon Vijay Abraham I };
26328081b72SKishon Vijay Abraham I 
26428081b72SKishon Vijay Abraham I enum cdns_sierra_cmn_plllc {
26528081b72SKishon Vijay Abraham I 	CMN_PLLLC,
26628081b72SKishon Vijay Abraham I 	CMN_PLLLC1,
26728081b72SKishon Vijay Abraham I };
26828081b72SKishon Vijay Abraham I 
26928081b72SKishon Vijay Abraham I struct cdns_sierra_pll_mux_reg_fields {
27028081b72SKishon Vijay Abraham I 	struct reg_field	pfdclk_sel_preg;
27128081b72SKishon Vijay Abraham I 	struct reg_field	plllc1en_field;
27228081b72SKishon Vijay Abraham I 	struct reg_field	termen_field;
27328081b72SKishon Vijay Abraham I };
27428081b72SKishon Vijay Abraham I 
27528081b72SKishon Vijay Abraham I static const struct cdns_sierra_pll_mux_reg_fields cmn_plllc_pfdclk1_sel_preg[] = {
27628081b72SKishon Vijay Abraham I 	[CMN_PLLLC] = {
27728081b72SKishon Vijay Abraham I 		.pfdclk_sel_preg = REG_FIELD(SIERRA_CMN_PLLLC_GEN_PREG, 1, 1),
27828081b72SKishon Vijay Abraham I 		.plllc1en_field = REG_FIELD(SIERRA_CMN_REFRCV1_PREG, 8, 8),
27928081b72SKishon Vijay Abraham I 		.termen_field = REG_FIELD(SIERRA_CMN_REFRCV1_PREG, 0, 0),
28028081b72SKishon Vijay Abraham I 	},
28128081b72SKishon Vijay Abraham I 	[CMN_PLLLC1] = {
28228081b72SKishon Vijay Abraham I 		.pfdclk_sel_preg = REG_FIELD(SIERRA_CMN_PLLLC1_GEN_PREG, 1, 1),
28328081b72SKishon Vijay Abraham I 		.plllc1en_field = REG_FIELD(SIERRA_CMN_REFRCV_PREG, 8, 8),
28428081b72SKishon Vijay Abraham I 		.termen_field = REG_FIELD(SIERRA_CMN_REFRCV_PREG, 0, 0),
28528081b72SKishon Vijay Abraham I 	},
28628081b72SKishon Vijay Abraham I };
28728081b72SKishon Vijay Abraham I 
28828081b72SKishon Vijay Abraham I struct cdns_sierra_pll_mux {
28928081b72SKishon Vijay Abraham I 	struct clk_hw		hw;
29028081b72SKishon Vijay Abraham I 	struct regmap_field	*pfdclk_sel_preg;
29128081b72SKishon Vijay Abraham I 	struct regmap_field	*plllc1en_field;
29228081b72SKishon Vijay Abraham I 	struct regmap_field	*termen_field;
29328081b72SKishon Vijay Abraham I 	struct clk_init_data	clk_data;
29428081b72SKishon Vijay Abraham I };
29528081b72SKishon Vijay Abraham I 
29628081b72SKishon Vijay Abraham I #define to_cdns_sierra_pll_mux(_hw)	\
29728081b72SKishon Vijay Abraham I 			container_of(_hw, struct cdns_sierra_pll_mux, hw)
29828081b72SKishon Vijay Abraham I 
299a59f6006SLars-Peter Clausen #define PLL0_REFCLK_NAME "pll0_refclk"
300a59f6006SLars-Peter Clausen #define PLL1_REFCLK_NAME "pll1_refclk"
301a59f6006SLars-Peter Clausen 
302a59f6006SLars-Peter Clausen static const struct clk_parent_data pll_mux_parent_data[][SIERRA_NUM_CMN_PLLC_PARENTS] = {
303a59f6006SLars-Peter Clausen 	[CMN_PLLLC] = {
304a59f6006SLars-Peter Clausen 		{ .fw_name = PLL0_REFCLK_NAME },
305a59f6006SLars-Peter Clausen 		{ .fw_name = PLL1_REFCLK_NAME }
306a59f6006SLars-Peter Clausen 	},
307a59f6006SLars-Peter Clausen 	[CMN_PLLLC1] = {
308a59f6006SLars-Peter Clausen 		{ .fw_name = PLL1_REFCLK_NAME },
309a59f6006SLars-Peter Clausen 		{ .fw_name = PLL0_REFCLK_NAME }
310a59f6006SLars-Peter Clausen 	},
31128081b72SKishon Vijay Abraham I };
31228081b72SKishon Vijay Abraham I 
313*f75999c5SChristophe JAILLET static const u32 cdns_sierra_pll_mux_table[][SIERRA_NUM_CMN_PLLC_PARENTS] = {
314da08aab9SSwapnil Jakhade 	[CMN_PLLLC] = { 0, 1 },
315da08aab9SSwapnil Jakhade 	[CMN_PLLLC1] = { 1, 0 },
316da08aab9SSwapnil Jakhade };
31728081b72SKishon Vijay Abraham I 
31809d976b3SSwapnil Jakhade struct cdns_sierra_derived_refclk {
31909d976b3SSwapnil Jakhade 	struct clk_hw           hw;
32009d976b3SSwapnil Jakhade 	struct regmap_field     *cmn_plllc_clk1outdiv_preg;
32109d976b3SSwapnil Jakhade 	struct regmap_field     *cmn_plllc_clk1_en_preg;
32209d976b3SSwapnil Jakhade 	struct clk_init_data	clk_data;
32309d976b3SSwapnil Jakhade };
32409d976b3SSwapnil Jakhade 
32509d976b3SSwapnil Jakhade #define to_cdns_sierra_derived_refclk(_hw)	\
32609d976b3SSwapnil Jakhade 			container_of(_hw, struct cdns_sierra_derived_refclk, hw)
32709d976b3SSwapnil Jakhade 
328078e9e92SSwapnil Jakhade enum cdns_sierra_phy_type {
329078e9e92SSwapnil Jakhade 	TYPE_NONE,
330078e9e92SSwapnil Jakhade 	TYPE_PCIE,
3318a1b82d7SSwapnil Jakhade 	TYPE_USB,
3320cfa43abSSwapnil Jakhade 	TYPE_SGMII,
3338a1b82d7SSwapnil Jakhade 	TYPE_QSGMII
334078e9e92SSwapnil Jakhade };
335078e9e92SSwapnil Jakhade 
336078e9e92SSwapnil Jakhade enum cdns_sierra_ssc_mode {
337078e9e92SSwapnil Jakhade 	NO_SSC,
338078e9e92SSwapnil Jakhade 	EXTERNAL_SSC,
339078e9e92SSwapnil Jakhade 	INTERNAL_SSC
340078e9e92SSwapnil Jakhade };
341078e9e92SSwapnil Jakhade 
34244d30d62SAlan Douglas struct cdns_sierra_inst {
34344d30d62SAlan Douglas 	struct phy *phy;
344078e9e92SSwapnil Jakhade 	enum cdns_sierra_phy_type phy_type;
34544d30d62SAlan Douglas 	u32 num_lanes;
34644d30d62SAlan Douglas 	u32 mlane;
34744d30d62SAlan Douglas 	struct reset_control *lnk_rst;
3481e902b2aSSwapnil Jakhade 	enum cdns_sierra_ssc_mode ssc_mode;
34944d30d62SAlan Douglas };
35044d30d62SAlan Douglas 
35144d30d62SAlan Douglas struct cdns_reg_pairs {
35244d30d62SAlan Douglas 	u16 val;
35344d30d62SAlan Douglas 	u32 off;
35444d30d62SAlan Douglas };
35544d30d62SAlan Douglas 
356078e9e92SSwapnil Jakhade struct cdns_sierra_vals {
357078e9e92SSwapnil Jakhade 	const struct cdns_reg_pairs *reg_pairs;
358078e9e92SSwapnil Jakhade 	u32 num_regs;
359078e9e92SSwapnil Jakhade };
360078e9e92SSwapnil Jakhade 
36144d30d62SAlan Douglas struct cdns_sierra_data {
36244d30d62SAlan Douglas 	u32 id_value;
363380f5708SKishon Vijay Abraham I 	u8 block_offset_shift;
364380f5708SKishon Vijay Abraham I 	u8 reg_offset_shift;
365da41bac5SChristophe JAILLET 	const struct cdns_sierra_vals *pcs_cmn_vals[NUM_PHY_TYPE][NUM_PHY_TYPE]
366fa105172SSwapnil Jakhade 						   [NUM_SSC_MODE];
367da41bac5SChristophe JAILLET 	const struct cdns_sierra_vals *phy_pma_ln_vals[NUM_PHY_TYPE][NUM_PHY_TYPE]
3686b81f05aSSwapnil Jakhade 						      [NUM_SSC_MODE];
369da41bac5SChristophe JAILLET 	const struct cdns_sierra_vals *pma_cmn_vals[NUM_PHY_TYPE][NUM_PHY_TYPE]
370078e9e92SSwapnil Jakhade 						   [NUM_SSC_MODE];
371da41bac5SChristophe JAILLET 	const struct cdns_sierra_vals *pma_ln_vals[NUM_PHY_TYPE][NUM_PHY_TYPE]
372078e9e92SSwapnil Jakhade 						  [NUM_SSC_MODE];
37344d30d62SAlan Douglas };
37444d30d62SAlan Douglas 
375380f5708SKishon Vijay Abraham I struct cdns_regmap_cdb_context {
37644d30d62SAlan Douglas 	struct device *dev;
37744d30d62SAlan Douglas 	void __iomem *base;
378380f5708SKishon Vijay Abraham I 	u8 reg_offset_shift;
379380f5708SKishon Vijay Abraham I };
380380f5708SKishon Vijay Abraham I 
381380f5708SKishon Vijay Abraham I struct cdns_sierra_phy {
382380f5708SKishon Vijay Abraham I 	struct device *dev;
383c3c11d55SSwapnil Jakhade 	const struct cdns_sierra_data *init_data;
38444d30d62SAlan Douglas 	struct cdns_sierra_inst phys[SIERRA_MAX_LANES];
38544d30d62SAlan Douglas 	struct reset_control *phy_rst;
38644d30d62SAlan Douglas 	struct reset_control *apb_rst;
387380f5708SKishon Vijay Abraham I 	struct regmap *regmap_lane_cdb[SIERRA_MAX_LANES];
3888c95e172SSwapnil Jakhade 	struct regmap *regmap_phy_pcs_common_cdb;
38936ce4163SSwapnil Jakhade 	struct regmap *regmap_phy_pcs_lane_cdb[SIERRA_MAX_LANES];
390f1cc6c3fSSwapnil Jakhade 	struct regmap *regmap_phy_pma_common_cdb;
3916b81f05aSSwapnil Jakhade 	struct regmap *regmap_phy_pma_lane_cdb[SIERRA_MAX_LANES];
392380f5708SKishon Vijay Abraham I 	struct regmap *regmap_common_cdb;
393380f5708SKishon Vijay Abraham I 	struct regmap_field *macro_id_type;
394380f5708SKishon Vijay Abraham I 	struct regmap_field *phy_pll_cfg_1;
395f1cc6c3fSSwapnil Jakhade 	struct regmap_field *pma_cmn_ready;
396adc4bd6fSKishon Vijay Abraham I 	struct regmap_field *pllctrl_lock[SIERRA_MAX_LANES];
39736ce4163SSwapnil Jakhade 	struct regmap_field *phy_iso_link_ctrl_1[SIERRA_MAX_LANES];
39828081b72SKishon Vijay Abraham I 	struct regmap_field *cmn_refrcv_refclk_plllc1en_preg[SIERRA_NUM_CMN_PLLC];
39928081b72SKishon Vijay Abraham I 	struct regmap_field *cmn_refrcv_refclk_termen_preg[SIERRA_NUM_CMN_PLLC];
40028081b72SKishon Vijay Abraham I 	struct regmap_field *cmn_plllc_pfdclk1_sel_preg[SIERRA_NUM_CMN_PLLC];
401a0c30cd7SKishon Vijay Abraham I 	struct clk *input_clks[CDNS_SIERRA_INPUT_CLOCKS];
40244d30d62SAlan Douglas 	int nsubnodes;
403a43f72aeSKishon Vijay Abraham I 	u32 num_lanes;
40444d30d62SAlan Douglas 	bool autoconf;
405d88ca22dSAswath Govindraju 	int already_configured;
4066ef7aa32SLars-Peter Clausen 	struct clk *pll_clks[SIERRA_NUM_CMN_PLLC];
4076ef7aa32SLars-Peter Clausen 	struct clk_hw_onecell_data clk_data;
40844d30d62SAlan Douglas };
40944d30d62SAlan Douglas 
410380f5708SKishon Vijay Abraham I static int cdns_regmap_write(void *context, unsigned int reg, unsigned int val)
411380f5708SKishon Vijay Abraham I {
412380f5708SKishon Vijay Abraham I 	struct cdns_regmap_cdb_context *ctx = context;
413380f5708SKishon Vijay Abraham I 	u32 offset = reg << ctx->reg_offset_shift;
414380f5708SKishon Vijay Abraham I 
415380f5708SKishon Vijay Abraham I 	writew(val, ctx->base + offset);
416380f5708SKishon Vijay Abraham I 
417380f5708SKishon Vijay Abraham I 	return 0;
418380f5708SKishon Vijay Abraham I }
419380f5708SKishon Vijay Abraham I 
420380f5708SKishon Vijay Abraham I static int cdns_regmap_read(void *context, unsigned int reg, unsigned int *val)
421380f5708SKishon Vijay Abraham I {
422380f5708SKishon Vijay Abraham I 	struct cdns_regmap_cdb_context *ctx = context;
423380f5708SKishon Vijay Abraham I 	u32 offset = reg << ctx->reg_offset_shift;
424380f5708SKishon Vijay Abraham I 
425380f5708SKishon Vijay Abraham I 	*val = readw(ctx->base + offset);
426380f5708SKishon Vijay Abraham I 	return 0;
427380f5708SKishon Vijay Abraham I }
428380f5708SKishon Vijay Abraham I 
429380f5708SKishon Vijay Abraham I #define SIERRA_LANE_CDB_REGMAP_CONF(n) \
430380f5708SKishon Vijay Abraham I { \
431380f5708SKishon Vijay Abraham I 	.name = "sierra_lane" n "_cdb", \
432380f5708SKishon Vijay Abraham I 	.reg_stride = 1, \
433380f5708SKishon Vijay Abraham I 	.fast_io = true, \
434380f5708SKishon Vijay Abraham I 	.reg_write = cdns_regmap_write, \
435380f5708SKishon Vijay Abraham I 	.reg_read = cdns_regmap_read, \
436380f5708SKishon Vijay Abraham I }
437380f5708SKishon Vijay Abraham I 
4383cfb0e8eSRikard Falkeborn static const struct regmap_config cdns_sierra_lane_cdb_config[] = {
439380f5708SKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("0"),
440380f5708SKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("1"),
441380f5708SKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("2"),
442380f5708SKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("3"),
443a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("4"),
444a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("5"),
445a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("6"),
446a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("7"),
447a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("8"),
448a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("9"),
449a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("10"),
450a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("11"),
451a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("12"),
452a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("13"),
453a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("14"),
454a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("15"),
455380f5708SKishon Vijay Abraham I };
456380f5708SKishon Vijay Abraham I 
4573cfb0e8eSRikard Falkeborn static const struct regmap_config cdns_sierra_common_cdb_config = {
458380f5708SKishon Vijay Abraham I 	.name = "sierra_common_cdb",
459380f5708SKishon Vijay Abraham I 	.reg_stride = 1,
460380f5708SKishon Vijay Abraham I 	.fast_io = true,
461380f5708SKishon Vijay Abraham I 	.reg_write = cdns_regmap_write,
462380f5708SKishon Vijay Abraham I 	.reg_read = cdns_regmap_read,
463380f5708SKishon Vijay Abraham I };
464380f5708SKishon Vijay Abraham I 
4658c95e172SSwapnil Jakhade static const struct regmap_config cdns_sierra_phy_pcs_cmn_cdb_config = {
4668c95e172SSwapnil Jakhade 	.name = "sierra_phy_pcs_cmn_cdb",
467380f5708SKishon Vijay Abraham I 	.reg_stride = 1,
468380f5708SKishon Vijay Abraham I 	.fast_io = true,
469380f5708SKishon Vijay Abraham I 	.reg_write = cdns_regmap_write,
470380f5708SKishon Vijay Abraham I 	.reg_read = cdns_regmap_read,
471380f5708SKishon Vijay Abraham I };
472380f5708SKishon Vijay Abraham I 
47336ce4163SSwapnil Jakhade #define SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF(n) \
47436ce4163SSwapnil Jakhade { \
47536ce4163SSwapnil Jakhade 	.name = "sierra_phy_pcs_lane" n "_cdb", \
47636ce4163SSwapnil Jakhade 	.reg_stride = 1, \
47736ce4163SSwapnil Jakhade 	.fast_io = true, \
47836ce4163SSwapnil Jakhade 	.reg_write = cdns_regmap_write, \
47936ce4163SSwapnil Jakhade 	.reg_read = cdns_regmap_read, \
48036ce4163SSwapnil Jakhade }
48136ce4163SSwapnil Jakhade 
48236ce4163SSwapnil Jakhade static const struct regmap_config cdns_sierra_phy_pcs_lane_cdb_config[] = {
48336ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("0"),
48436ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("1"),
48536ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("2"),
48636ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("3"),
48736ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("4"),
48836ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("5"),
48936ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("6"),
49036ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("7"),
49136ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("8"),
49236ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("9"),
49336ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("10"),
49436ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("11"),
49536ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("12"),
49636ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("13"),
49736ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("14"),
49836ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("15"),
49936ce4163SSwapnil Jakhade };
50036ce4163SSwapnil Jakhade 
501f1cc6c3fSSwapnil Jakhade static const struct regmap_config cdns_sierra_phy_pma_cmn_cdb_config = {
502f1cc6c3fSSwapnil Jakhade 	.name = "sierra_phy_pma_cmn_cdb",
503f1cc6c3fSSwapnil Jakhade 	.reg_stride = 1,
504f1cc6c3fSSwapnil Jakhade 	.fast_io = true,
505f1cc6c3fSSwapnil Jakhade 	.reg_write = cdns_regmap_write,
506f1cc6c3fSSwapnil Jakhade 	.reg_read = cdns_regmap_read,
507f1cc6c3fSSwapnil Jakhade };
508f1cc6c3fSSwapnil Jakhade 
5096b81f05aSSwapnil Jakhade #define SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF(n) \
5106b81f05aSSwapnil Jakhade { \
5116b81f05aSSwapnil Jakhade 	.name = "sierra_phy_pma_lane" n "_cdb", \
5126b81f05aSSwapnil Jakhade 	.reg_stride = 1, \
5136b81f05aSSwapnil Jakhade 	.fast_io = true, \
5146b81f05aSSwapnil Jakhade 	.reg_write = cdns_regmap_write, \
5156b81f05aSSwapnil Jakhade 	.reg_read = cdns_regmap_read, \
5166b81f05aSSwapnil Jakhade }
5176b81f05aSSwapnil Jakhade 
5186b81f05aSSwapnil Jakhade static const struct regmap_config cdns_sierra_phy_pma_lane_cdb_config[] = {
5196b81f05aSSwapnil Jakhade 	SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("0"),
5206b81f05aSSwapnil Jakhade 	SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("1"),
5216b81f05aSSwapnil Jakhade 	SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("2"),
5226b81f05aSSwapnil Jakhade 	SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("3"),
5236b81f05aSSwapnil Jakhade 	SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("4"),
5246b81f05aSSwapnil Jakhade 	SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("5"),
5256b81f05aSSwapnil Jakhade 	SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("6"),
5266b81f05aSSwapnil Jakhade 	SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("7"),
5276b81f05aSSwapnil Jakhade 	SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("8"),
5286b81f05aSSwapnil Jakhade 	SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("9"),
5296b81f05aSSwapnil Jakhade 	SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("10"),
5306b81f05aSSwapnil Jakhade 	SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("11"),
5316b81f05aSSwapnil Jakhade 	SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("12"),
5326b81f05aSSwapnil Jakhade 	SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("13"),
5336b81f05aSSwapnil Jakhade 	SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("14"),
5346b81f05aSSwapnil Jakhade 	SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("15"),
5356b81f05aSSwapnil Jakhade };
5366b81f05aSSwapnil Jakhade 
537cedcc2e2SKishon Vijay Abraham I static int cdns_sierra_phy_init(struct phy *gphy)
53844d30d62SAlan Douglas {
53944d30d62SAlan Douglas 	struct cdns_sierra_inst *ins = phy_get_drvdata(gphy);
54044d30d62SAlan Douglas 	struct cdns_sierra_phy *phy = dev_get_drvdata(gphy->dev.parent);
541078e9e92SSwapnil Jakhade 	const struct cdns_sierra_data *init_data = phy->init_data;
542da41bac5SChristophe JAILLET 	const struct cdns_sierra_vals *pma_cmn_vals, *pma_ln_vals;
543078e9e92SSwapnil Jakhade 	enum cdns_sierra_phy_type phy_type = ins->phy_type;
544da41bac5SChristophe JAILLET 	const struct cdns_sierra_vals *phy_pma_ln_vals;
5451e902b2aSSwapnil Jakhade 	enum cdns_sierra_ssc_mode ssc = ins->ssc_mode;
546da41bac5SChristophe JAILLET 	const struct cdns_sierra_vals *pcs_cmn_vals;
547078e9e92SSwapnil Jakhade 	const struct cdns_reg_pairs *reg_pairs;
54880f96fb1SColin Ian King 	struct regmap *regmap;
549078e9e92SSwapnil Jakhade 	u32 num_regs;
55044d30d62SAlan Douglas 	int i, j;
55144d30d62SAlan Douglas 
552cedcc2e2SKishon Vijay Abraham I 	/* Initialise the PHY registers, unless auto configured */
553d88ca22dSAswath Govindraju 	if (phy->autoconf || phy->already_configured || phy->nsubnodes > 1)
554cedcc2e2SKishon Vijay Abraham I 		return 0;
555cedcc2e2SKishon Vijay Abraham I 
556a0c30cd7SKishon Vijay Abraham I 	clk_set_rate(phy->input_clks[CMN_REFCLK_DIG_DIV], 25000000);
557a0c30cd7SKishon Vijay Abraham I 	clk_set_rate(phy->input_clks[CMN_REFCLK1_DIG_DIV], 25000000);
558078e9e92SSwapnil Jakhade 
559fa105172SSwapnil Jakhade 	/* PHY PCS common registers configurations */
560fa105172SSwapnil Jakhade 	pcs_cmn_vals = init_data->pcs_cmn_vals[phy_type][TYPE_NONE][ssc];
561fa105172SSwapnil Jakhade 	if (pcs_cmn_vals) {
562fa105172SSwapnil Jakhade 		reg_pairs = pcs_cmn_vals->reg_pairs;
563fa105172SSwapnil Jakhade 		num_regs = pcs_cmn_vals->num_regs;
564fa105172SSwapnil Jakhade 		regmap = phy->regmap_phy_pcs_common_cdb;
565fa105172SSwapnil Jakhade 		for (i = 0; i < num_regs; i++)
566fa105172SSwapnil Jakhade 			regmap_write(regmap, reg_pairs[i].off, reg_pairs[i].val);
567fa105172SSwapnil Jakhade 	}
568fa105172SSwapnil Jakhade 
5696b81f05aSSwapnil Jakhade 	/* PHY PMA lane registers configurations */
5706b81f05aSSwapnil Jakhade 	phy_pma_ln_vals = init_data->phy_pma_ln_vals[phy_type][TYPE_NONE][ssc];
5716b81f05aSSwapnil Jakhade 	if (phy_pma_ln_vals) {
5726b81f05aSSwapnil Jakhade 		reg_pairs = phy_pma_ln_vals->reg_pairs;
5736b81f05aSSwapnil Jakhade 		num_regs = phy_pma_ln_vals->num_regs;
5746b81f05aSSwapnil Jakhade 		for (i = 0; i < ins->num_lanes; i++) {
5756b81f05aSSwapnil Jakhade 			regmap = phy->regmap_phy_pma_lane_cdb[i + ins->mlane];
5766b81f05aSSwapnil Jakhade 			for (j = 0; j < num_regs; j++)
5776b81f05aSSwapnil Jakhade 				regmap_write(regmap, reg_pairs[j].off, reg_pairs[j].val);
5786b81f05aSSwapnil Jakhade 		}
5796b81f05aSSwapnil Jakhade 	}
5806b81f05aSSwapnil Jakhade 
581078e9e92SSwapnil Jakhade 	/* PMA common registers configurations */
582078e9e92SSwapnil Jakhade 	pma_cmn_vals = init_data->pma_cmn_vals[phy_type][TYPE_NONE][ssc];
583078e9e92SSwapnil Jakhade 	if (pma_cmn_vals) {
584078e9e92SSwapnil Jakhade 		reg_pairs = pma_cmn_vals->reg_pairs;
585078e9e92SSwapnil Jakhade 		num_regs = pma_cmn_vals->num_regs;
586078e9e92SSwapnil Jakhade 		regmap = phy->regmap_common_cdb;
587078e9e92SSwapnil Jakhade 		for (i = 0; i < num_regs; i++)
588078e9e92SSwapnil Jakhade 			regmap_write(regmap, reg_pairs[i].off, reg_pairs[i].val);
58944d30d62SAlan Douglas 	}
590871002d7SAnil Varughese 
591078e9e92SSwapnil Jakhade 	/* PMA lane registers configurations */
592078e9e92SSwapnil Jakhade 	pma_ln_vals = init_data->pma_ln_vals[phy_type][TYPE_NONE][ssc];
593078e9e92SSwapnil Jakhade 	if (pma_ln_vals) {
594078e9e92SSwapnil Jakhade 		reg_pairs = pma_ln_vals->reg_pairs;
595078e9e92SSwapnil Jakhade 		num_regs = pma_ln_vals->num_regs;
596380f5708SKishon Vijay Abraham I 		for (i = 0; i < ins->num_lanes; i++) {
597380f5708SKishon Vijay Abraham I 			regmap = phy->regmap_lane_cdb[i + ins->mlane];
598078e9e92SSwapnil Jakhade 			for (j = 0; j < num_regs; j++)
599078e9e92SSwapnil Jakhade 				regmap_write(regmap, reg_pairs[j].off, reg_pairs[j].val);
600380f5708SKishon Vijay Abraham I 		}
601380f5708SKishon Vijay Abraham I 	}
602cedcc2e2SKishon Vijay Abraham I 
603cedcc2e2SKishon Vijay Abraham I 	return 0;
60444d30d62SAlan Douglas }
60544d30d62SAlan Douglas 
60644d30d62SAlan Douglas static int cdns_sierra_phy_on(struct phy *gphy)
60744d30d62SAlan Douglas {
608adc4bd6fSKishon Vijay Abraham I 	struct cdns_sierra_phy *sp = dev_get_drvdata(gphy->dev.parent);
60944d30d62SAlan Douglas 	struct cdns_sierra_inst *ins = phy_get_drvdata(gphy);
610adc4bd6fSKishon Vijay Abraham I 	struct device *dev = sp->dev;
611adc4bd6fSKishon Vijay Abraham I 	u32 val;
612adc4bd6fSKishon Vijay Abraham I 	int ret;
61344d30d62SAlan Douglas 
6146b81f05aSSwapnil Jakhade 	if (sp->nsubnodes == 1) {
6156b81f05aSSwapnil Jakhade 		/* Take the PHY out of reset */
6165b4f5757SKishon Vijay Abraham I 		ret = reset_control_deassert(sp->phy_rst);
6175b4f5757SKishon Vijay Abraham I 		if (ret) {
6185b4f5757SKishon Vijay Abraham I 			dev_err(dev, "Failed to take the PHY out of reset\n");
6195b4f5757SKishon Vijay Abraham I 			return ret;
6205b4f5757SKishon Vijay Abraham I 		}
6216b81f05aSSwapnil Jakhade 	}
6225b4f5757SKishon Vijay Abraham I 
62344d30d62SAlan Douglas 	/* Take the PHY lane group out of reset */
624adc4bd6fSKishon Vijay Abraham I 	ret = reset_control_deassert(ins->lnk_rst);
625adc4bd6fSKishon Vijay Abraham I 	if (ret) {
626adc4bd6fSKishon Vijay Abraham I 		dev_err(dev, "Failed to take the PHY lane out of reset\n");
627adc4bd6fSKishon Vijay Abraham I 		return ret;
628adc4bd6fSKishon Vijay Abraham I 	}
629adc4bd6fSKishon Vijay Abraham I 
63036ce4163SSwapnil Jakhade 	if (ins->phy_type == TYPE_PCIE || ins->phy_type == TYPE_USB) {
63136ce4163SSwapnil Jakhade 		ret = regmap_field_read_poll_timeout(sp->phy_iso_link_ctrl_1[ins->mlane],
63236ce4163SSwapnil Jakhade 						     val, !val, 1000, PLL_LOCK_TIME);
63336ce4163SSwapnil Jakhade 		if (ret) {
63436ce4163SSwapnil Jakhade 			dev_err(dev, "Timeout waiting for PHY status ready\n");
63536ce4163SSwapnil Jakhade 			return ret;
63636ce4163SSwapnil Jakhade 		}
63736ce4163SSwapnil Jakhade 	}
63836ce4163SSwapnil Jakhade 
639f1cc6c3fSSwapnil Jakhade 	/*
640f1cc6c3fSSwapnil Jakhade 	 * Wait for cmn_ready assertion
641f1cc6c3fSSwapnil Jakhade 	 * PHY_PMA_CMN_CTRL[0] == 1
642f1cc6c3fSSwapnil Jakhade 	 */
643f1cc6c3fSSwapnil Jakhade 	ret = regmap_field_read_poll_timeout(sp->pma_cmn_ready, val, val,
644f1cc6c3fSSwapnil Jakhade 					     1000, PLL_LOCK_TIME);
645f1cc6c3fSSwapnil Jakhade 	if (ret) {
646f1cc6c3fSSwapnil Jakhade 		dev_err(dev, "Timeout waiting for CMN ready\n");
647f1cc6c3fSSwapnil Jakhade 		return ret;
648f1cc6c3fSSwapnil Jakhade 	}
649f1cc6c3fSSwapnil Jakhade 
650adc4bd6fSKishon Vijay Abraham I 	ret = regmap_field_read_poll_timeout(sp->pllctrl_lock[ins->mlane],
651adc4bd6fSKishon Vijay Abraham I 					     val, val, 1000, PLL_LOCK_TIME);
652adc4bd6fSKishon Vijay Abraham I 	if (ret < 0)
653adc4bd6fSKishon Vijay Abraham I 		dev_err(dev, "PLL lock of lane failed\n");
654adc4bd6fSKishon Vijay Abraham I 
655adc4bd6fSKishon Vijay Abraham I 	return ret;
65644d30d62SAlan Douglas }
65744d30d62SAlan Douglas 
65844d30d62SAlan Douglas static int cdns_sierra_phy_off(struct phy *gphy)
65944d30d62SAlan Douglas {
66044d30d62SAlan Douglas 	struct cdns_sierra_inst *ins = phy_get_drvdata(gphy);
66144d30d62SAlan Douglas 
66244d30d62SAlan Douglas 	return reset_control_assert(ins->lnk_rst);
66344d30d62SAlan Douglas }
66444d30d62SAlan Douglas 
6657904e15bSRoger Quadros static int cdns_sierra_phy_reset(struct phy *gphy)
6667904e15bSRoger Quadros {
6677904e15bSRoger Quadros 	struct cdns_sierra_phy *sp = dev_get_drvdata(gphy->dev.parent);
6687904e15bSRoger Quadros 
6697904e15bSRoger Quadros 	reset_control_assert(sp->phy_rst);
6707904e15bSRoger Quadros 	reset_control_deassert(sp->phy_rst);
6717904e15bSRoger Quadros 	return 0;
6727904e15bSRoger Quadros };
6737904e15bSRoger Quadros 
67444d30d62SAlan Douglas static const struct phy_ops ops = {
675cedcc2e2SKishon Vijay Abraham I 	.init		= cdns_sierra_phy_init,
67644d30d62SAlan Douglas 	.power_on	= cdns_sierra_phy_on,
67744d30d62SAlan Douglas 	.power_off	= cdns_sierra_phy_off,
6787904e15bSRoger Quadros 	.reset		= cdns_sierra_phy_reset,
67944d30d62SAlan Douglas 	.owner		= THIS_MODULE,
68044d30d62SAlan Douglas };
68144d30d62SAlan Douglas 
682d88ca22dSAswath Govindraju static int cdns_sierra_noop_phy_on(struct phy *gphy)
683d88ca22dSAswath Govindraju {
684d88ca22dSAswath Govindraju 	usleep_range(5000, 10000);
685d88ca22dSAswath Govindraju 
686d88ca22dSAswath Govindraju 	return 0;
687d88ca22dSAswath Govindraju }
688d88ca22dSAswath Govindraju 
689d88ca22dSAswath Govindraju static const struct phy_ops noop_ops = {
690d88ca22dSAswath Govindraju 	.power_on	= cdns_sierra_noop_phy_on,
691d88ca22dSAswath Govindraju 	.owner		= THIS_MODULE,
692d88ca22dSAswath Govindraju };
693d88ca22dSAswath Govindraju 
69428081b72SKishon Vijay Abraham I static u8 cdns_sierra_pll_mux_get_parent(struct clk_hw *hw)
69528081b72SKishon Vijay Abraham I {
69628081b72SKishon Vijay Abraham I 	struct cdns_sierra_pll_mux *mux = to_cdns_sierra_pll_mux(hw);
697da08aab9SSwapnil Jakhade 	struct regmap_field *plllc1en_field = mux->plllc1en_field;
698da08aab9SSwapnil Jakhade 	struct regmap_field *termen_field = mux->termen_field;
69928081b72SKishon Vijay Abraham I 	struct regmap_field *field = mux->pfdclk_sel_preg;
70028081b72SKishon Vijay Abraham I 	unsigned int val;
701da08aab9SSwapnil Jakhade 	int index;
70228081b72SKishon Vijay Abraham I 
70328081b72SKishon Vijay Abraham I 	regmap_field_read(field, &val);
704da08aab9SSwapnil Jakhade 
705da08aab9SSwapnil Jakhade 	if (strstr(clk_hw_get_name(hw), clk_names[CDNS_SIERRA_PLL_CMNLC1])) {
706da08aab9SSwapnil Jakhade 		index = clk_mux_val_to_index(hw, cdns_sierra_pll_mux_table[CMN_PLLLC1], 0, val);
707da08aab9SSwapnil Jakhade 		if (index == 1) {
708da08aab9SSwapnil Jakhade 			regmap_field_write(plllc1en_field, 1);
709da08aab9SSwapnil Jakhade 			regmap_field_write(termen_field, 1);
710da08aab9SSwapnil Jakhade 		}
711da08aab9SSwapnil Jakhade 	} else {
712da08aab9SSwapnil Jakhade 		index = clk_mux_val_to_index(hw, cdns_sierra_pll_mux_table[CMN_PLLLC], 0, val);
713da08aab9SSwapnil Jakhade 	}
714da08aab9SSwapnil Jakhade 
715da08aab9SSwapnil Jakhade 	return index;
71628081b72SKishon Vijay Abraham I }
71728081b72SKishon Vijay Abraham I 
71828081b72SKishon Vijay Abraham I static int cdns_sierra_pll_mux_set_parent(struct clk_hw *hw, u8 index)
71928081b72SKishon Vijay Abraham I {
72028081b72SKishon Vijay Abraham I 	struct cdns_sierra_pll_mux *mux = to_cdns_sierra_pll_mux(hw);
72128081b72SKishon Vijay Abraham I 	struct regmap_field *plllc1en_field = mux->plllc1en_field;
72228081b72SKishon Vijay Abraham I 	struct regmap_field *termen_field = mux->termen_field;
72328081b72SKishon Vijay Abraham I 	struct regmap_field *field = mux->pfdclk_sel_preg;
72428081b72SKishon Vijay Abraham I 	int val, ret;
72528081b72SKishon Vijay Abraham I 
72628081b72SKishon Vijay Abraham I 	ret = regmap_field_write(plllc1en_field, 0);
72728081b72SKishon Vijay Abraham I 	ret |= regmap_field_write(termen_field, 0);
72828081b72SKishon Vijay Abraham I 	if (index == 1) {
72928081b72SKishon Vijay Abraham I 		ret |= regmap_field_write(plllc1en_field, 1);
73028081b72SKishon Vijay Abraham I 		ret |= regmap_field_write(termen_field, 1);
73128081b72SKishon Vijay Abraham I 	}
73228081b72SKishon Vijay Abraham I 
733da08aab9SSwapnil Jakhade 	if (strstr(clk_hw_get_name(hw), clk_names[CDNS_SIERRA_PLL_CMNLC1]))
734da08aab9SSwapnil Jakhade 		val = cdns_sierra_pll_mux_table[CMN_PLLLC1][index];
735da08aab9SSwapnil Jakhade 	else
736da08aab9SSwapnil Jakhade 		val = cdns_sierra_pll_mux_table[CMN_PLLLC][index];
737da08aab9SSwapnil Jakhade 
73828081b72SKishon Vijay Abraham I 	ret |= regmap_field_write(field, val);
73928081b72SKishon Vijay Abraham I 
74028081b72SKishon Vijay Abraham I 	return ret;
74128081b72SKishon Vijay Abraham I }
74228081b72SKishon Vijay Abraham I 
74328081b72SKishon Vijay Abraham I static const struct clk_ops cdns_sierra_pll_mux_ops = {
7441ca48301SMaxime Ripard 	.determine_rate = __clk_mux_determine_rate,
74528081b72SKishon Vijay Abraham I 	.set_parent = cdns_sierra_pll_mux_set_parent,
74628081b72SKishon Vijay Abraham I 	.get_parent = cdns_sierra_pll_mux_get_parent,
74728081b72SKishon Vijay Abraham I };
74828081b72SKishon Vijay Abraham I 
74928081b72SKishon Vijay Abraham I static int cdns_sierra_pll_mux_register(struct cdns_sierra_phy *sp,
75028081b72SKishon Vijay Abraham I 					struct regmap_field *pfdclk1_sel_field,
75128081b72SKishon Vijay Abraham I 					struct regmap_field *plllc1en_field,
75228081b72SKishon Vijay Abraham I 					struct regmap_field *termen_field,
75328081b72SKishon Vijay Abraham I 					int clk_index)
75428081b72SKishon Vijay Abraham I {
75528081b72SKishon Vijay Abraham I 	struct cdns_sierra_pll_mux *mux;
75628081b72SKishon Vijay Abraham I 	struct device *dev = sp->dev;
75728081b72SKishon Vijay Abraham I 	struct clk_init_data *init;
75828081b72SKishon Vijay Abraham I 	char clk_name[100];
7596ef7aa32SLars-Peter Clausen 	int ret;
76028081b72SKishon Vijay Abraham I 
76128081b72SKishon Vijay Abraham I 	mux = devm_kzalloc(dev, sizeof(*mux), GFP_KERNEL);
76228081b72SKishon Vijay Abraham I 	if (!mux)
76328081b72SKishon Vijay Abraham I 		return -ENOMEM;
76428081b72SKishon Vijay Abraham I 
76528081b72SKishon Vijay Abraham I 	snprintf(clk_name, sizeof(clk_name), "%s_%s", dev_name(dev), clk_names[clk_index]);
76628081b72SKishon Vijay Abraham I 
76728081b72SKishon Vijay Abraham I 	init = &mux->clk_data;
76828081b72SKishon Vijay Abraham I 
76928081b72SKishon Vijay Abraham I 	init->ops = &cdns_sierra_pll_mux_ops;
77028081b72SKishon Vijay Abraham I 	init->flags = CLK_SET_RATE_NO_REPARENT;
771a59f6006SLars-Peter Clausen 	init->parent_data = pll_mux_parent_data[clk_index];
772a59f6006SLars-Peter Clausen 	init->num_parents = SIERRA_NUM_CMN_PLLC_PARENTS;
77328081b72SKishon Vijay Abraham I 	init->name = clk_name;
77428081b72SKishon Vijay Abraham I 
77528081b72SKishon Vijay Abraham I 	mux->pfdclk_sel_preg = pfdclk1_sel_field;
77628081b72SKishon Vijay Abraham I 	mux->plllc1en_field = plllc1en_field;
77728081b72SKishon Vijay Abraham I 	mux->termen_field = termen_field;
77828081b72SKishon Vijay Abraham I 	mux->hw.init = init;
77928081b72SKishon Vijay Abraham I 
7806ef7aa32SLars-Peter Clausen 	ret = devm_clk_hw_register(dev, &mux->hw);
7816ef7aa32SLars-Peter Clausen 	if (ret)
7826ef7aa32SLars-Peter Clausen 		return ret;
78328081b72SKishon Vijay Abraham I 
7846ef7aa32SLars-Peter Clausen 	sp->clk_data.hws[clk_index] = &mux->hw;
7856ef7aa32SLars-Peter Clausen 
7866ef7aa32SLars-Peter Clausen 	sp->pll_clks[clk_index] = devm_clk_hw_get_clk(dev, &mux->hw,
7876ef7aa32SLars-Peter Clausen 						      clk_names[clk_index]);
78828081b72SKishon Vijay Abraham I 
78928081b72SKishon Vijay Abraham I 	return 0;
79028081b72SKishon Vijay Abraham I }
79128081b72SKishon Vijay Abraham I 
79228081b72SKishon Vijay Abraham I static int cdns_sierra_phy_register_pll_mux(struct cdns_sierra_phy *sp)
79328081b72SKishon Vijay Abraham I {
79428081b72SKishon Vijay Abraham I 	struct regmap_field *pfdclk1_sel_field;
79528081b72SKishon Vijay Abraham I 	struct regmap_field *plllc1en_field;
79628081b72SKishon Vijay Abraham I 	struct regmap_field *termen_field;
79728081b72SKishon Vijay Abraham I 	struct device *dev = sp->dev;
79828081b72SKishon Vijay Abraham I 	int ret = 0, i, clk_index;
79928081b72SKishon Vijay Abraham I 
80028081b72SKishon Vijay Abraham I 	clk_index = CDNS_SIERRA_PLL_CMNLC;
80128081b72SKishon Vijay Abraham I 	for (i = 0; i < SIERRA_NUM_CMN_PLLC; i++, clk_index++) {
80228081b72SKishon Vijay Abraham I 		pfdclk1_sel_field = sp->cmn_plllc_pfdclk1_sel_preg[i];
80328081b72SKishon Vijay Abraham I 		plllc1en_field = sp->cmn_refrcv_refclk_plllc1en_preg[i];
80428081b72SKishon Vijay Abraham I 		termen_field = sp->cmn_refrcv_refclk_termen_preg[i];
80528081b72SKishon Vijay Abraham I 
80628081b72SKishon Vijay Abraham I 		ret = cdns_sierra_pll_mux_register(sp, pfdclk1_sel_field, plllc1en_field,
80728081b72SKishon Vijay Abraham I 						   termen_field, clk_index);
80828081b72SKishon Vijay Abraham I 		if (ret) {
80928081b72SKishon Vijay Abraham I 			dev_err(dev, "Fail to register cmn plllc mux\n");
81028081b72SKishon Vijay Abraham I 			return ret;
81128081b72SKishon Vijay Abraham I 		}
81228081b72SKishon Vijay Abraham I 	}
81328081b72SKishon Vijay Abraham I 
81428081b72SKishon Vijay Abraham I 	return 0;
81528081b72SKishon Vijay Abraham I }
81628081b72SKishon Vijay Abraham I 
81709d976b3SSwapnil Jakhade static int cdns_sierra_derived_refclk_enable(struct clk_hw *hw)
81809d976b3SSwapnil Jakhade {
81909d976b3SSwapnil Jakhade 	struct cdns_sierra_derived_refclk *derived_refclk = to_cdns_sierra_derived_refclk(hw);
82009d976b3SSwapnil Jakhade 
82109d976b3SSwapnil Jakhade 	regmap_field_write(derived_refclk->cmn_plllc_clk1_en_preg, 0x1);
82209d976b3SSwapnil Jakhade 
82309d976b3SSwapnil Jakhade 	/* Programming to get 100Mhz clock output in ref_der_clk_out 5GHz VCO/50 = 100MHz */
82409d976b3SSwapnil Jakhade 	regmap_field_write(derived_refclk->cmn_plllc_clk1outdiv_preg, 0x2E);
82509d976b3SSwapnil Jakhade 
82609d976b3SSwapnil Jakhade 	return 0;
82709d976b3SSwapnil Jakhade }
82809d976b3SSwapnil Jakhade 
82909d976b3SSwapnil Jakhade static void cdns_sierra_derived_refclk_disable(struct clk_hw *hw)
83009d976b3SSwapnil Jakhade {
83109d976b3SSwapnil Jakhade 	struct cdns_sierra_derived_refclk *derived_refclk = to_cdns_sierra_derived_refclk(hw);
83209d976b3SSwapnil Jakhade 
83309d976b3SSwapnil Jakhade 	regmap_field_write(derived_refclk->cmn_plllc_clk1_en_preg, 0);
83409d976b3SSwapnil Jakhade }
83509d976b3SSwapnil Jakhade 
83609d976b3SSwapnil Jakhade static int cdns_sierra_derived_refclk_is_enabled(struct clk_hw *hw)
83709d976b3SSwapnil Jakhade {
83809d976b3SSwapnil Jakhade 	struct cdns_sierra_derived_refclk *derived_refclk = to_cdns_sierra_derived_refclk(hw);
83909d976b3SSwapnil Jakhade 	int val;
84009d976b3SSwapnil Jakhade 
84109d976b3SSwapnil Jakhade 	regmap_field_read(derived_refclk->cmn_plllc_clk1_en_preg, &val);
84209d976b3SSwapnil Jakhade 
84309d976b3SSwapnil Jakhade 	return !!val;
84409d976b3SSwapnil Jakhade }
84509d976b3SSwapnil Jakhade 
84609d976b3SSwapnil Jakhade static const struct clk_ops cdns_sierra_derived_refclk_ops = {
84709d976b3SSwapnil Jakhade 	.enable = cdns_sierra_derived_refclk_enable,
84809d976b3SSwapnil Jakhade 	.disable = cdns_sierra_derived_refclk_disable,
84909d976b3SSwapnil Jakhade 	.is_enabled = cdns_sierra_derived_refclk_is_enabled,
85009d976b3SSwapnil Jakhade };
85109d976b3SSwapnil Jakhade 
85209d976b3SSwapnil Jakhade static int cdns_sierra_derived_refclk_register(struct cdns_sierra_phy *sp)
85309d976b3SSwapnil Jakhade {
85409d976b3SSwapnil Jakhade 	struct cdns_sierra_derived_refclk *derived_refclk;
85509d976b3SSwapnil Jakhade 	struct device *dev = sp->dev;
85609d976b3SSwapnil Jakhade 	struct regmap_field *field;
85709d976b3SSwapnil Jakhade 	struct clk_init_data *init;
85809d976b3SSwapnil Jakhade 	struct regmap *regmap;
85909d976b3SSwapnil Jakhade 	char clk_name[100];
8606ef7aa32SLars-Peter Clausen 	int ret;
86109d976b3SSwapnil Jakhade 
86209d976b3SSwapnil Jakhade 	derived_refclk = devm_kzalloc(dev, sizeof(*derived_refclk), GFP_KERNEL);
86309d976b3SSwapnil Jakhade 	if (!derived_refclk)
86409d976b3SSwapnil Jakhade 		return -ENOMEM;
86509d976b3SSwapnil Jakhade 
86609d976b3SSwapnil Jakhade 	snprintf(clk_name, sizeof(clk_name), "%s_%s", dev_name(dev),
86709d976b3SSwapnil Jakhade 		 clk_names[CDNS_SIERRA_DERIVED_REFCLK]);
86809d976b3SSwapnil Jakhade 
86909d976b3SSwapnil Jakhade 	init = &derived_refclk->clk_data;
87009d976b3SSwapnil Jakhade 
87109d976b3SSwapnil Jakhade 	init->ops = &cdns_sierra_derived_refclk_ops;
87209d976b3SSwapnil Jakhade 	init->flags = 0;
87309d976b3SSwapnil Jakhade 	init->name = clk_name;
87409d976b3SSwapnil Jakhade 
87509d976b3SSwapnil Jakhade 	regmap = sp->regmap_common_cdb;
87609d976b3SSwapnil Jakhade 
87709d976b3SSwapnil Jakhade 	field = devm_regmap_field_alloc(dev, regmap, cmn_plllc_clk1outdiv_preg);
87809d976b3SSwapnil Jakhade 	if (IS_ERR(field)) {
87909d976b3SSwapnil Jakhade 		dev_err(dev, "cmn_plllc_clk1outdiv_preg reg field init failed\n");
88009d976b3SSwapnil Jakhade 		return PTR_ERR(field);
88109d976b3SSwapnil Jakhade 	}
88209d976b3SSwapnil Jakhade 	derived_refclk->cmn_plllc_clk1outdiv_preg = field;
88309d976b3SSwapnil Jakhade 
88409d976b3SSwapnil Jakhade 	field = devm_regmap_field_alloc(dev, regmap, cmn_plllc_clk1_en_preg);
88509d976b3SSwapnil Jakhade 	if (IS_ERR(field)) {
88609d976b3SSwapnil Jakhade 		dev_err(dev, "cmn_plllc_clk1_en_preg reg field init failed\n");
88709d976b3SSwapnil Jakhade 		return PTR_ERR(field);
88809d976b3SSwapnil Jakhade 	}
88909d976b3SSwapnil Jakhade 	derived_refclk->cmn_plllc_clk1_en_preg = field;
89009d976b3SSwapnil Jakhade 
89109d976b3SSwapnil Jakhade 	derived_refclk->hw.init = init;
89209d976b3SSwapnil Jakhade 
8936ef7aa32SLars-Peter Clausen 	ret = devm_clk_hw_register(dev, &derived_refclk->hw);
8946ef7aa32SLars-Peter Clausen 	if (ret)
8956ef7aa32SLars-Peter Clausen 		return ret;
89609d976b3SSwapnil Jakhade 
8976ef7aa32SLars-Peter Clausen 	sp->clk_data.hws[CDNS_SIERRA_DERIVED_REFCLK] = &derived_refclk->hw;
89809d976b3SSwapnil Jakhade 
89909d976b3SSwapnil Jakhade 	return 0;
90009d976b3SSwapnil Jakhade }
90109d976b3SSwapnil Jakhade 
90228081b72SKishon Vijay Abraham I static void cdns_sierra_clk_unregister(struct cdns_sierra_phy *sp)
90328081b72SKishon Vijay Abraham I {
90428081b72SKishon Vijay Abraham I 	struct device *dev = sp->dev;
90528081b72SKishon Vijay Abraham I 	struct device_node *node = dev->of_node;
90628081b72SKishon Vijay Abraham I 
90728081b72SKishon Vijay Abraham I 	of_clk_del_provider(node);
90828081b72SKishon Vijay Abraham I }
90928081b72SKishon Vijay Abraham I 
91028081b72SKishon Vijay Abraham I static int cdns_sierra_clk_register(struct cdns_sierra_phy *sp)
91128081b72SKishon Vijay Abraham I {
91228081b72SKishon Vijay Abraham I 	struct device *dev = sp->dev;
91328081b72SKishon Vijay Abraham I 	struct device_node *node = dev->of_node;
91428081b72SKishon Vijay Abraham I 	int ret;
91528081b72SKishon Vijay Abraham I 
91628081b72SKishon Vijay Abraham I 	ret = cdns_sierra_phy_register_pll_mux(sp);
91728081b72SKishon Vijay Abraham I 	if (ret) {
91828081b72SKishon Vijay Abraham I 		dev_err(dev, "Failed to pll mux clocks\n");
91928081b72SKishon Vijay Abraham I 		return ret;
92028081b72SKishon Vijay Abraham I 	}
92128081b72SKishon Vijay Abraham I 
92209d976b3SSwapnil Jakhade 	ret = cdns_sierra_derived_refclk_register(sp);
92309d976b3SSwapnil Jakhade 	if (ret) {
92409d976b3SSwapnil Jakhade 		dev_err(dev, "Failed to register derived refclk\n");
92509d976b3SSwapnil Jakhade 		return ret;
92609d976b3SSwapnil Jakhade 	}
92709d976b3SSwapnil Jakhade 
9286ef7aa32SLars-Peter Clausen 	sp->clk_data.num = CDNS_SIERRA_OUTPUT_CLOCKS;
9296ef7aa32SLars-Peter Clausen 	ret = of_clk_add_hw_provider(node, of_clk_hw_onecell_get,
9306ef7aa32SLars-Peter Clausen 				     &sp->clk_data);
93128081b72SKishon Vijay Abraham I 	if (ret)
93228081b72SKishon Vijay Abraham I 		dev_err(dev, "Failed to add clock provider: %s\n", node->name);
93328081b72SKishon Vijay Abraham I 
93428081b72SKishon Vijay Abraham I 	return ret;
93528081b72SKishon Vijay Abraham I }
93628081b72SKishon Vijay Abraham I 
93744d30d62SAlan Douglas static int cdns_sierra_get_optional(struct cdns_sierra_inst *inst,
93844d30d62SAlan Douglas 				    struct device_node *child)
93944d30d62SAlan Douglas {
940078e9e92SSwapnil Jakhade 	u32 phy_type;
941078e9e92SSwapnil Jakhade 
94244d30d62SAlan Douglas 	if (of_property_read_u32(child, "reg", &inst->mlane))
94344d30d62SAlan Douglas 		return -EINVAL;
94444d30d62SAlan Douglas 
94544d30d62SAlan Douglas 	if (of_property_read_u32(child, "cdns,num-lanes", &inst->num_lanes))
94644d30d62SAlan Douglas 		return -EINVAL;
94744d30d62SAlan Douglas 
948078e9e92SSwapnil Jakhade 	if (of_property_read_u32(child, "cdns,phy-type", &phy_type))
94944d30d62SAlan Douglas 		return -EINVAL;
95044d30d62SAlan Douglas 
951078e9e92SSwapnil Jakhade 	switch (phy_type) {
952078e9e92SSwapnil Jakhade 	case PHY_TYPE_PCIE:
953078e9e92SSwapnil Jakhade 		inst->phy_type = TYPE_PCIE;
954078e9e92SSwapnil Jakhade 		break;
955078e9e92SSwapnil Jakhade 	case PHY_TYPE_USB3:
956078e9e92SSwapnil Jakhade 		inst->phy_type = TYPE_USB;
957078e9e92SSwapnil Jakhade 		break;
9580cfa43abSSwapnil Jakhade 	case PHY_TYPE_SGMII:
9590cfa43abSSwapnil Jakhade 		inst->phy_type = TYPE_SGMII;
9600cfa43abSSwapnil Jakhade 		break;
9618a1b82d7SSwapnil Jakhade 	case PHY_TYPE_QSGMII:
9628a1b82d7SSwapnil Jakhade 		inst->phy_type = TYPE_QSGMII;
9638a1b82d7SSwapnil Jakhade 		break;
964078e9e92SSwapnil Jakhade 	default:
965078e9e92SSwapnil Jakhade 		return -EINVAL;
966078e9e92SSwapnil Jakhade 	}
967078e9e92SSwapnil Jakhade 
9681e902b2aSSwapnil Jakhade 	inst->ssc_mode = EXTERNAL_SSC;
9691e902b2aSSwapnil Jakhade 	of_property_read_u32(child, "cdns,ssc-mode", &inst->ssc_mode);
9701e902b2aSSwapnil Jakhade 
97144d30d62SAlan Douglas 	return 0;
97244d30d62SAlan Douglas }
97344d30d62SAlan Douglas 
974380f5708SKishon Vijay Abraham I static struct regmap *cdns_regmap_init(struct device *dev, void __iomem *base,
975380f5708SKishon Vijay Abraham I 				       u32 block_offset, u8 reg_offset_shift,
976380f5708SKishon Vijay Abraham I 				       const struct regmap_config *config)
977380f5708SKishon Vijay Abraham I {
978380f5708SKishon Vijay Abraham I 	struct cdns_regmap_cdb_context *ctx;
979380f5708SKishon Vijay Abraham I 
980380f5708SKishon Vijay Abraham I 	ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
981380f5708SKishon Vijay Abraham I 	if (!ctx)
982380f5708SKishon Vijay Abraham I 		return ERR_PTR(-ENOMEM);
983380f5708SKishon Vijay Abraham I 
984380f5708SKishon Vijay Abraham I 	ctx->dev = dev;
985380f5708SKishon Vijay Abraham I 	ctx->base = base + block_offset;
986380f5708SKishon Vijay Abraham I 	ctx->reg_offset_shift = reg_offset_shift;
987380f5708SKishon Vijay Abraham I 
988380f5708SKishon Vijay Abraham I 	return devm_regmap_init(dev, NULL, ctx, config);
989380f5708SKishon Vijay Abraham I }
990380f5708SKishon Vijay Abraham I 
991380f5708SKishon Vijay Abraham I static int cdns_regfield_init(struct cdns_sierra_phy *sp)
992380f5708SKishon Vijay Abraham I {
993380f5708SKishon Vijay Abraham I 	struct device *dev = sp->dev;
994380f5708SKishon Vijay Abraham I 	struct regmap_field *field;
99528081b72SKishon Vijay Abraham I 	struct reg_field reg_field;
996380f5708SKishon Vijay Abraham I 	struct regmap *regmap;
997adc4bd6fSKishon Vijay Abraham I 	int i;
998380f5708SKishon Vijay Abraham I 
999380f5708SKishon Vijay Abraham I 	regmap = sp->regmap_common_cdb;
1000380f5708SKishon Vijay Abraham I 	field = devm_regmap_field_alloc(dev, regmap, macro_id_type);
1001380f5708SKishon Vijay Abraham I 	if (IS_ERR(field)) {
1002380f5708SKishon Vijay Abraham I 		dev_err(dev, "MACRO_ID_TYPE reg field init failed\n");
1003380f5708SKishon Vijay Abraham I 		return PTR_ERR(field);
1004380f5708SKishon Vijay Abraham I 	}
1005380f5708SKishon Vijay Abraham I 	sp->macro_id_type = field;
1006380f5708SKishon Vijay Abraham I 
100728081b72SKishon Vijay Abraham I 	for (i = 0; i < SIERRA_NUM_CMN_PLLC; i++) {
100828081b72SKishon Vijay Abraham I 		reg_field = cmn_plllc_pfdclk1_sel_preg[i].pfdclk_sel_preg;
100928081b72SKishon Vijay Abraham I 		field = devm_regmap_field_alloc(dev, regmap, reg_field);
101028081b72SKishon Vijay Abraham I 		if (IS_ERR(field)) {
101128081b72SKishon Vijay Abraham I 			dev_err(dev, "PLLLC%d_PFDCLK1_SEL failed\n", i);
101228081b72SKishon Vijay Abraham I 			return PTR_ERR(field);
101328081b72SKishon Vijay Abraham I 		}
101428081b72SKishon Vijay Abraham I 		sp->cmn_plllc_pfdclk1_sel_preg[i] = field;
101528081b72SKishon Vijay Abraham I 
101628081b72SKishon Vijay Abraham I 		reg_field = cmn_plllc_pfdclk1_sel_preg[i].plllc1en_field;
101728081b72SKishon Vijay Abraham I 		field = devm_regmap_field_alloc(dev, regmap, reg_field);
101828081b72SKishon Vijay Abraham I 		if (IS_ERR(field)) {
101928081b72SKishon Vijay Abraham I 			dev_err(dev, "REFRCV%d_REFCLK_PLLLC1EN failed\n", i);
102028081b72SKishon Vijay Abraham I 			return PTR_ERR(field);
102128081b72SKishon Vijay Abraham I 		}
102228081b72SKishon Vijay Abraham I 		sp->cmn_refrcv_refclk_plllc1en_preg[i] = field;
102328081b72SKishon Vijay Abraham I 
102428081b72SKishon Vijay Abraham I 		reg_field = cmn_plllc_pfdclk1_sel_preg[i].termen_field;
102528081b72SKishon Vijay Abraham I 		field = devm_regmap_field_alloc(dev, regmap, reg_field);
102628081b72SKishon Vijay Abraham I 		if (IS_ERR(field)) {
102728081b72SKishon Vijay Abraham I 			dev_err(dev, "REFRCV%d_REFCLK_TERMEN failed\n", i);
102828081b72SKishon Vijay Abraham I 			return PTR_ERR(field);
102928081b72SKishon Vijay Abraham I 		}
103028081b72SKishon Vijay Abraham I 		sp->cmn_refrcv_refclk_termen_preg[i] = field;
103128081b72SKishon Vijay Abraham I 	}
103228081b72SKishon Vijay Abraham I 
10338c95e172SSwapnil Jakhade 	regmap = sp->regmap_phy_pcs_common_cdb;
1034380f5708SKishon Vijay Abraham I 	field = devm_regmap_field_alloc(dev, regmap, phy_pll_cfg_1);
1035380f5708SKishon Vijay Abraham I 	if (IS_ERR(field)) {
1036380f5708SKishon Vijay Abraham I 		dev_err(dev, "PHY_PLL_CFG_1 reg field init failed\n");
1037380f5708SKishon Vijay Abraham I 		return PTR_ERR(field);
1038380f5708SKishon Vijay Abraham I 	}
1039380f5708SKishon Vijay Abraham I 	sp->phy_pll_cfg_1 = field;
1040380f5708SKishon Vijay Abraham I 
1041f1cc6c3fSSwapnil Jakhade 	regmap = sp->regmap_phy_pma_common_cdb;
1042f1cc6c3fSSwapnil Jakhade 	field = devm_regmap_field_alloc(dev, regmap, pma_cmn_ready);
1043f1cc6c3fSSwapnil Jakhade 	if (IS_ERR(field)) {
1044f1cc6c3fSSwapnil Jakhade 		dev_err(dev, "PHY_PMA_CMN_CTRL reg field init failed\n");
1045f1cc6c3fSSwapnil Jakhade 		return PTR_ERR(field);
1046f1cc6c3fSSwapnil Jakhade 	}
1047f1cc6c3fSSwapnil Jakhade 	sp->pma_cmn_ready = field;
1048f1cc6c3fSSwapnil Jakhade 
1049adc4bd6fSKishon Vijay Abraham I 	for (i = 0; i < SIERRA_MAX_LANES; i++) {
1050adc4bd6fSKishon Vijay Abraham I 		regmap = sp->regmap_lane_cdb[i];
1051adc4bd6fSKishon Vijay Abraham I 		field = devm_regmap_field_alloc(dev, regmap, pllctrl_lock);
1052adc4bd6fSKishon Vijay Abraham I 		if (IS_ERR(field)) {
1053adc4bd6fSKishon Vijay Abraham I 			dev_err(dev, "P%d_ENABLE reg field init failed\n", i);
1054adc4bd6fSKishon Vijay Abraham I 			return PTR_ERR(field);
1055adc4bd6fSKishon Vijay Abraham I 		}
1056adc4bd6fSKishon Vijay Abraham I 		sp->pllctrl_lock[i] = field;
1057adc4bd6fSKishon Vijay Abraham I 	}
1058adc4bd6fSKishon Vijay Abraham I 
105936ce4163SSwapnil Jakhade 	for (i = 0; i < SIERRA_MAX_LANES; i++) {
106036ce4163SSwapnil Jakhade 		regmap = sp->regmap_phy_pcs_lane_cdb[i];
106136ce4163SSwapnil Jakhade 		field = devm_regmap_field_alloc(dev, regmap, phy_iso_link_ctrl_1);
106236ce4163SSwapnil Jakhade 		if (IS_ERR(field)) {
106336ce4163SSwapnil Jakhade 			dev_err(dev, "PHY_ISO_LINK_CTRL reg field init for lane %d failed\n", i);
106436ce4163SSwapnil Jakhade 			return PTR_ERR(field);
106536ce4163SSwapnil Jakhade 		}
106636ce4163SSwapnil Jakhade 		sp->phy_iso_link_ctrl_1[i] = field;
106736ce4163SSwapnil Jakhade 	}
106836ce4163SSwapnil Jakhade 
1069380f5708SKishon Vijay Abraham I 	return 0;
1070380f5708SKishon Vijay Abraham I }
1071380f5708SKishon Vijay Abraham I 
1072380f5708SKishon Vijay Abraham I static int cdns_regmap_init_blocks(struct cdns_sierra_phy *sp,
1073380f5708SKishon Vijay Abraham I 				   void __iomem *base, u8 block_offset_shift,
1074380f5708SKishon Vijay Abraham I 				   u8 reg_offset_shift)
1075380f5708SKishon Vijay Abraham I {
1076380f5708SKishon Vijay Abraham I 	struct device *dev = sp->dev;
1077380f5708SKishon Vijay Abraham I 	struct regmap *regmap;
1078380f5708SKishon Vijay Abraham I 	u32 block_offset;
1079380f5708SKishon Vijay Abraham I 	int i;
1080380f5708SKishon Vijay Abraham I 
1081380f5708SKishon Vijay Abraham I 	for (i = 0; i < SIERRA_MAX_LANES; i++) {
1082380f5708SKishon Vijay Abraham I 		block_offset = SIERRA_LANE_CDB_OFFSET(i, block_offset_shift,
1083380f5708SKishon Vijay Abraham I 						      reg_offset_shift);
1084380f5708SKishon Vijay Abraham I 		regmap = cdns_regmap_init(dev, base, block_offset,
1085380f5708SKishon Vijay Abraham I 					  reg_offset_shift,
1086380f5708SKishon Vijay Abraham I 					  &cdns_sierra_lane_cdb_config[i]);
1087380f5708SKishon Vijay Abraham I 		if (IS_ERR(regmap)) {
1088380f5708SKishon Vijay Abraham I 			dev_err(dev, "Failed to init lane CDB regmap\n");
1089380f5708SKishon Vijay Abraham I 			return PTR_ERR(regmap);
1090380f5708SKishon Vijay Abraham I 		}
1091380f5708SKishon Vijay Abraham I 		sp->regmap_lane_cdb[i] = regmap;
1092380f5708SKishon Vijay Abraham I 	}
1093380f5708SKishon Vijay Abraham I 
1094380f5708SKishon Vijay Abraham I 	regmap = cdns_regmap_init(dev, base, SIERRA_COMMON_CDB_OFFSET,
1095380f5708SKishon Vijay Abraham I 				  reg_offset_shift,
1096380f5708SKishon Vijay Abraham I 				  &cdns_sierra_common_cdb_config);
1097380f5708SKishon Vijay Abraham I 	if (IS_ERR(regmap)) {
1098380f5708SKishon Vijay Abraham I 		dev_err(dev, "Failed to init common CDB regmap\n");
1099380f5708SKishon Vijay Abraham I 		return PTR_ERR(regmap);
1100380f5708SKishon Vijay Abraham I 	}
1101380f5708SKishon Vijay Abraham I 	sp->regmap_common_cdb = regmap;
1102380f5708SKishon Vijay Abraham I 
11038c95e172SSwapnil Jakhade 	block_offset = SIERRA_PHY_PCS_COMMON_OFFSET(block_offset_shift);
1104380f5708SKishon Vijay Abraham I 	regmap = cdns_regmap_init(dev, base, block_offset, reg_offset_shift,
11058c95e172SSwapnil Jakhade 				  &cdns_sierra_phy_pcs_cmn_cdb_config);
1106380f5708SKishon Vijay Abraham I 	if (IS_ERR(regmap)) {
11078c95e172SSwapnil Jakhade 		dev_err(dev, "Failed to init PHY PCS common CDB regmap\n");
1108380f5708SKishon Vijay Abraham I 		return PTR_ERR(regmap);
1109380f5708SKishon Vijay Abraham I 	}
11108c95e172SSwapnil Jakhade 	sp->regmap_phy_pcs_common_cdb = regmap;
1111380f5708SKishon Vijay Abraham I 
111236ce4163SSwapnil Jakhade 	for (i = 0; i < SIERRA_MAX_LANES; i++) {
111336ce4163SSwapnil Jakhade 		block_offset = SIERRA_PHY_PCS_LANE_CDB_OFFSET(i, block_offset_shift,
111436ce4163SSwapnil Jakhade 							      reg_offset_shift);
111536ce4163SSwapnil Jakhade 		regmap = cdns_regmap_init(dev, base, block_offset,
111636ce4163SSwapnil Jakhade 					  reg_offset_shift,
111736ce4163SSwapnil Jakhade 					  &cdns_sierra_phy_pcs_lane_cdb_config[i]);
111836ce4163SSwapnil Jakhade 		if (IS_ERR(regmap)) {
111936ce4163SSwapnil Jakhade 			dev_err(dev, "Failed to init PHY PCS lane CDB regmap\n");
112036ce4163SSwapnil Jakhade 			return PTR_ERR(regmap);
112136ce4163SSwapnil Jakhade 		}
112236ce4163SSwapnil Jakhade 		sp->regmap_phy_pcs_lane_cdb[i] = regmap;
112336ce4163SSwapnil Jakhade 	}
112436ce4163SSwapnil Jakhade 
1125f1cc6c3fSSwapnil Jakhade 	block_offset = SIERRA_PHY_PMA_COMMON_OFFSET(block_offset_shift);
1126f1cc6c3fSSwapnil Jakhade 	regmap = cdns_regmap_init(dev, base, block_offset, reg_offset_shift,
1127f1cc6c3fSSwapnil Jakhade 				  &cdns_sierra_phy_pma_cmn_cdb_config);
1128f1cc6c3fSSwapnil Jakhade 	if (IS_ERR(regmap)) {
1129f1cc6c3fSSwapnil Jakhade 		dev_err(dev, "Failed to init PHY PMA common CDB regmap\n");
1130f1cc6c3fSSwapnil Jakhade 		return PTR_ERR(regmap);
1131f1cc6c3fSSwapnil Jakhade 	}
1132f1cc6c3fSSwapnil Jakhade 	sp->regmap_phy_pma_common_cdb = regmap;
1133f1cc6c3fSSwapnil Jakhade 
11346b81f05aSSwapnil Jakhade 	for (i = 0; i < SIERRA_MAX_LANES; i++) {
11356b81f05aSSwapnil Jakhade 		block_offset = SIERRA_PHY_PMA_LANE_CDB_OFFSET(i, block_offset_shift,
11366b81f05aSSwapnil Jakhade 							      reg_offset_shift);
11376b81f05aSSwapnil Jakhade 		regmap = cdns_regmap_init(dev, base, block_offset,
11386b81f05aSSwapnil Jakhade 					  reg_offset_shift,
11396b81f05aSSwapnil Jakhade 					  &cdns_sierra_phy_pma_lane_cdb_config[i]);
11406b81f05aSSwapnil Jakhade 		if (IS_ERR(regmap)) {
11416b81f05aSSwapnil Jakhade 			dev_err(dev, "Failed to init PHY PMA lane CDB regmap\n");
11426b81f05aSSwapnil Jakhade 			return PTR_ERR(regmap);
11436b81f05aSSwapnil Jakhade 		}
11446b81f05aSSwapnil Jakhade 		sp->regmap_phy_pma_lane_cdb[i] = regmap;
11456b81f05aSSwapnil Jakhade 	}
11466b81f05aSSwapnil Jakhade 
1147380f5708SKishon Vijay Abraham I 	return 0;
1148380f5708SKishon Vijay Abraham I }
1149380f5708SKishon Vijay Abraham I 
11507e016cbcSKishon Vijay Abraham I static int cdns_sierra_phy_get_clocks(struct cdns_sierra_phy *sp,
11517e016cbcSKishon Vijay Abraham I 				      struct device *dev)
11527e016cbcSKishon Vijay Abraham I {
11537e016cbcSKishon Vijay Abraham I 	struct clk *clk;
11547e016cbcSKishon Vijay Abraham I 	int ret;
11557e016cbcSKishon Vijay Abraham I 
11567e016cbcSKishon Vijay Abraham I 	clk = devm_clk_get_optional(dev, "cmn_refclk_dig_div");
11577e016cbcSKishon Vijay Abraham I 	if (IS_ERR(clk)) {
11587e016cbcSKishon Vijay Abraham I 		dev_err(dev, "cmn_refclk_dig_div clock not found\n");
11597e016cbcSKishon Vijay Abraham I 		ret = PTR_ERR(clk);
11607e016cbcSKishon Vijay Abraham I 		return ret;
11617e016cbcSKishon Vijay Abraham I 	}
1162a0c30cd7SKishon Vijay Abraham I 	sp->input_clks[CMN_REFCLK_DIG_DIV] = clk;
11637e016cbcSKishon Vijay Abraham I 
11647e016cbcSKishon Vijay Abraham I 	clk = devm_clk_get_optional(dev, "cmn_refclk1_dig_div");
11657e016cbcSKishon Vijay Abraham I 	if (IS_ERR(clk)) {
11667e016cbcSKishon Vijay Abraham I 		dev_err(dev, "cmn_refclk1_dig_div clock not found\n");
11677e016cbcSKishon Vijay Abraham I 		ret = PTR_ERR(clk);
11687e016cbcSKishon Vijay Abraham I 		return ret;
11697e016cbcSKishon Vijay Abraham I 	}
1170a0c30cd7SKishon Vijay Abraham I 	sp->input_clks[CMN_REFCLK1_DIG_DIV] = clk;
11717e016cbcSKishon Vijay Abraham I 
11727e016cbcSKishon Vijay Abraham I 	return 0;
11737e016cbcSKishon Vijay Abraham I }
11747e016cbcSKishon Vijay Abraham I 
1175d88ca22dSAswath Govindraju static int cdns_sierra_phy_clk(struct cdns_sierra_phy *sp)
11761436ec30SKishon Vijay Abraham I {
1177d88ca22dSAswath Govindraju 	struct device *dev = sp->dev;
1178d88ca22dSAswath Govindraju 	struct clk *clk;
11791436ec30SKishon Vijay Abraham I 	int ret;
11801436ec30SKishon Vijay Abraham I 
1181d88ca22dSAswath Govindraju 	clk = devm_clk_get_optional(dev, "phy_clk");
1182d88ca22dSAswath Govindraju 	if (IS_ERR(clk)) {
1183d88ca22dSAswath Govindraju 		dev_err(dev, "failed to get clock phy_clk\n");
1184d88ca22dSAswath Govindraju 		return PTR_ERR(clk);
1185d88ca22dSAswath Govindraju 	}
1186d88ca22dSAswath Govindraju 	sp->input_clks[PHY_CLK] = clk;
1187d88ca22dSAswath Govindraju 
11881436ec30SKishon Vijay Abraham I 	ret = clk_prepare_enable(sp->input_clks[PHY_CLK]);
11891436ec30SKishon Vijay Abraham I 	if (ret)
11901436ec30SKishon Vijay Abraham I 		return ret;
11911436ec30SKishon Vijay Abraham I 
1192d88ca22dSAswath Govindraju 	return 0;
1193d88ca22dSAswath Govindraju }
1194d88ca22dSAswath Govindraju 
1195d88ca22dSAswath Govindraju static int cdns_sierra_phy_enable_clocks(struct cdns_sierra_phy *sp)
1196d88ca22dSAswath Govindraju {
1197d88ca22dSAswath Govindraju 	int ret;
1198d88ca22dSAswath Govindraju 
11996ef7aa32SLars-Peter Clausen 	ret = clk_prepare_enable(sp->pll_clks[CDNS_SIERRA_PLL_CMNLC]);
12001436ec30SKishon Vijay Abraham I 	if (ret)
1201d88ca22dSAswath Govindraju 		return ret;
12021436ec30SKishon Vijay Abraham I 
12036ef7aa32SLars-Peter Clausen 	ret = clk_prepare_enable(sp->pll_clks[CDNS_SIERRA_PLL_CMNLC1]);
12041436ec30SKishon Vijay Abraham I 	if (ret)
12051436ec30SKishon Vijay Abraham I 		goto err_pll_cmnlc1;
12061436ec30SKishon Vijay Abraham I 
12071436ec30SKishon Vijay Abraham I 	return 0;
12081436ec30SKishon Vijay Abraham I 
12091436ec30SKishon Vijay Abraham I err_pll_cmnlc1:
12106ef7aa32SLars-Peter Clausen 	clk_disable_unprepare(sp->pll_clks[CDNS_SIERRA_PLL_CMNLC]);
12111436ec30SKishon Vijay Abraham I 
12121436ec30SKishon Vijay Abraham I 	return ret;
12131436ec30SKishon Vijay Abraham I }
12141436ec30SKishon Vijay Abraham I 
12151436ec30SKishon Vijay Abraham I static void cdns_sierra_phy_disable_clocks(struct cdns_sierra_phy *sp)
12161436ec30SKishon Vijay Abraham I {
12176ef7aa32SLars-Peter Clausen 	clk_disable_unprepare(sp->pll_clks[CDNS_SIERRA_PLL_CMNLC1]);
12186ef7aa32SLars-Peter Clausen 	clk_disable_unprepare(sp->pll_clks[CDNS_SIERRA_PLL_CMNLC]);
1219d88ca22dSAswath Govindraju 	if (!sp->already_configured)
12201436ec30SKishon Vijay Abraham I 		clk_disable_unprepare(sp->input_clks[PHY_CLK]);
12211436ec30SKishon Vijay Abraham I }
12221436ec30SKishon Vijay Abraham I 
12231d5f40e0SKishon Vijay Abraham I static int cdns_sierra_phy_get_resets(struct cdns_sierra_phy *sp,
12241d5f40e0SKishon Vijay Abraham I 				      struct device *dev)
12251d5f40e0SKishon Vijay Abraham I {
12261d5f40e0SKishon Vijay Abraham I 	struct reset_control *rst;
12271d5f40e0SKishon Vijay Abraham I 
122815b0b82dSKishon Vijay Abraham I 	rst = devm_reset_control_get_exclusive(dev, "sierra_reset");
12291d5f40e0SKishon Vijay Abraham I 	if (IS_ERR(rst)) {
12301d5f40e0SKishon Vijay Abraham I 		dev_err(dev, "failed to get reset\n");
12311d5f40e0SKishon Vijay Abraham I 		return PTR_ERR(rst);
12321d5f40e0SKishon Vijay Abraham I 	}
12331d5f40e0SKishon Vijay Abraham I 	sp->phy_rst = rst;
12341d5f40e0SKishon Vijay Abraham I 
123515b0b82dSKishon Vijay Abraham I 	rst = devm_reset_control_get_optional_exclusive(dev, "sierra_apb");
12361d5f40e0SKishon Vijay Abraham I 	if (IS_ERR(rst)) {
12371d5f40e0SKishon Vijay Abraham I 		dev_err(dev, "failed to get apb reset\n");
12381d5f40e0SKishon Vijay Abraham I 		return PTR_ERR(rst);
12391d5f40e0SKishon Vijay Abraham I 	}
12401d5f40e0SKishon Vijay Abraham I 	sp->apb_rst = rst;
12411d5f40e0SKishon Vijay Abraham I 
12421d5f40e0SKishon Vijay Abraham I 	return 0;
12431d5f40e0SKishon Vijay Abraham I }
12441d5f40e0SKishon Vijay Abraham I 
12456b81f05aSSwapnil Jakhade static int cdns_sierra_phy_configure_multilink(struct cdns_sierra_phy *sp)
12466b81f05aSSwapnil Jakhade {
1247da41bac5SChristophe JAILLET 	const struct cdns_sierra_vals *pma_cmn_vals, *pma_ln_vals;
12486b81f05aSSwapnil Jakhade 	const struct cdns_sierra_data *init_data = sp->init_data;
1249da41bac5SChristophe JAILLET 	const struct cdns_sierra_vals *phy_pma_ln_vals;
1250da41bac5SChristophe JAILLET 	const struct cdns_sierra_vals *pcs_cmn_vals;
12516b81f05aSSwapnil Jakhade 	enum cdns_sierra_phy_type phy_t1, phy_t2;
12526b81f05aSSwapnil Jakhade 	const struct cdns_reg_pairs *reg_pairs;
12536b81f05aSSwapnil Jakhade 	int i, j, node, mlane, num_lanes, ret;
12546b81f05aSSwapnil Jakhade 	enum cdns_sierra_ssc_mode ssc;
12556b81f05aSSwapnil Jakhade 	struct regmap *regmap;
12566b81f05aSSwapnil Jakhade 	u32 num_regs;
12576b81f05aSSwapnil Jakhade 
12586b81f05aSSwapnil Jakhade 	/* Maximum 2 links (subnodes) are supported */
12596b81f05aSSwapnil Jakhade 	if (sp->nsubnodes != 2)
12606b81f05aSSwapnil Jakhade 		return -EINVAL;
12616b81f05aSSwapnil Jakhade 
12626b81f05aSSwapnil Jakhade 	clk_set_rate(sp->input_clks[CMN_REFCLK_DIG_DIV], 25000000);
12636b81f05aSSwapnil Jakhade 	clk_set_rate(sp->input_clks[CMN_REFCLK1_DIG_DIV], 25000000);
12646b81f05aSSwapnil Jakhade 
12656b81f05aSSwapnil Jakhade 	/* PHY configured to use both PLL LC and LC1 */
12666b81f05aSSwapnil Jakhade 	regmap_field_write(sp->phy_pll_cfg_1, 0x1);
12676b81f05aSSwapnil Jakhade 
12686b81f05aSSwapnil Jakhade 	phy_t1 = sp->phys[0].phy_type;
12696b81f05aSSwapnil Jakhade 	phy_t2 = sp->phys[1].phy_type;
12706b81f05aSSwapnil Jakhade 
12716b81f05aSSwapnil Jakhade 	/*
12726b81f05aSSwapnil Jakhade 	 * PHY configuration for multi-link operation is done in two steps.
12736b81f05aSSwapnil Jakhade 	 * e.g. Consider a case for a 4 lane PHY with PCIe using 2 lanes and QSGMII other 2 lanes.
12746b81f05aSSwapnil Jakhade 	 * Sierra PHY has 2 PLLs, viz. PLLLC and PLLLC1. So in this case, PLLLC is used for PCIe
12756b81f05aSSwapnil Jakhade 	 * and PLLLC1 is used for QSGMII. PHY is configured in two steps as described below.
12766b81f05aSSwapnil Jakhade 	 *
12776b81f05aSSwapnil Jakhade 	 * [1] For first step, phy_t1 = TYPE_PCIE and phy_t2 = TYPE_QSGMII
12786b81f05aSSwapnil Jakhade 	 *     So the register values are selected as [TYPE_PCIE][TYPE_QSGMII][ssc].
12796b81f05aSSwapnil Jakhade 	 *     This will configure PHY registers associated for PCIe (i.e. first protocol)
12806b81f05aSSwapnil Jakhade 	 *     involving PLLLC registers and registers for first 2 lanes of PHY.
12816b81f05aSSwapnil Jakhade 	 * [2] In second step, the variables phy_t1 and phy_t2 are swapped. So now,
12826b81f05aSSwapnil Jakhade 	 *     phy_t1 = TYPE_QSGMII and phy_t2 = TYPE_PCIE. And the register values are selected as
12836b81f05aSSwapnil Jakhade 	 *     [TYPE_QSGMII][TYPE_PCIE][ssc].
12846b81f05aSSwapnil Jakhade 	 *     This will configure PHY registers associated for QSGMII (i.e. second protocol)
12856b81f05aSSwapnil Jakhade 	 *     involving PLLLC1 registers and registers for other 2 lanes of PHY.
12866b81f05aSSwapnil Jakhade 	 *
12876b81f05aSSwapnil Jakhade 	 * This completes the PHY configuration for multilink operation. This approach enables
12886b81f05aSSwapnil Jakhade 	 * dividing the large number of PHY register configurations into protocol specific
12896b81f05aSSwapnil Jakhade 	 * smaller groups.
12906b81f05aSSwapnil Jakhade 	 */
12916b81f05aSSwapnil Jakhade 	for (node = 0; node < sp->nsubnodes; node++) {
12926b81f05aSSwapnil Jakhade 		if (node == 1) {
12936b81f05aSSwapnil Jakhade 			/*
12946b81f05aSSwapnil Jakhade 			 * If first link with phy_t1 is configured, then configure the PHY for
12956b81f05aSSwapnil Jakhade 			 * second link with phy_t2. Get the array values as [phy_t2][phy_t1][ssc].
12966b81f05aSSwapnil Jakhade 			 */
12976b81f05aSSwapnil Jakhade 			swap(phy_t1, phy_t2);
12986b81f05aSSwapnil Jakhade 		}
12996b81f05aSSwapnil Jakhade 
13006b81f05aSSwapnil Jakhade 		mlane = sp->phys[node].mlane;
13016b81f05aSSwapnil Jakhade 		ssc = sp->phys[node].ssc_mode;
13026b81f05aSSwapnil Jakhade 		num_lanes = sp->phys[node].num_lanes;
13036b81f05aSSwapnil Jakhade 
13046b81f05aSSwapnil Jakhade 		/* PHY PCS common registers configurations */
13056b81f05aSSwapnil Jakhade 		pcs_cmn_vals = init_data->pcs_cmn_vals[phy_t1][phy_t2][ssc];
13066b81f05aSSwapnil Jakhade 		if (pcs_cmn_vals) {
13076b81f05aSSwapnil Jakhade 			reg_pairs = pcs_cmn_vals->reg_pairs;
13086b81f05aSSwapnil Jakhade 			num_regs = pcs_cmn_vals->num_regs;
13096b81f05aSSwapnil Jakhade 			regmap = sp->regmap_phy_pcs_common_cdb;
13106b81f05aSSwapnil Jakhade 			for (i = 0; i < num_regs; i++)
13116b81f05aSSwapnil Jakhade 				regmap_write(regmap, reg_pairs[i].off, reg_pairs[i].val);
13126b81f05aSSwapnil Jakhade 		}
13136b81f05aSSwapnil Jakhade 
13146b81f05aSSwapnil Jakhade 		/* PHY PMA lane registers configurations */
13156b81f05aSSwapnil Jakhade 		phy_pma_ln_vals = init_data->phy_pma_ln_vals[phy_t1][phy_t2][ssc];
13166b81f05aSSwapnil Jakhade 		if (phy_pma_ln_vals) {
13176b81f05aSSwapnil Jakhade 			reg_pairs = phy_pma_ln_vals->reg_pairs;
13186b81f05aSSwapnil Jakhade 			num_regs = phy_pma_ln_vals->num_regs;
13196b81f05aSSwapnil Jakhade 			for (i = 0; i < num_lanes; i++) {
13206b81f05aSSwapnil Jakhade 				regmap = sp->regmap_phy_pma_lane_cdb[i + mlane];
13216b81f05aSSwapnil Jakhade 				for (j = 0; j < num_regs; j++)
13226b81f05aSSwapnil Jakhade 					regmap_write(regmap, reg_pairs[j].off, reg_pairs[j].val);
13236b81f05aSSwapnil Jakhade 			}
13246b81f05aSSwapnil Jakhade 		}
13256b81f05aSSwapnil Jakhade 
13266b81f05aSSwapnil Jakhade 		/* PMA common registers configurations */
13276b81f05aSSwapnil Jakhade 		pma_cmn_vals = init_data->pma_cmn_vals[phy_t1][phy_t2][ssc];
13286b81f05aSSwapnil Jakhade 		if (pma_cmn_vals) {
13296b81f05aSSwapnil Jakhade 			reg_pairs = pma_cmn_vals->reg_pairs;
13306b81f05aSSwapnil Jakhade 			num_regs = pma_cmn_vals->num_regs;
13316b81f05aSSwapnil Jakhade 			regmap = sp->regmap_common_cdb;
13326b81f05aSSwapnil Jakhade 			for (i = 0; i < num_regs; i++)
13336b81f05aSSwapnil Jakhade 				regmap_write(regmap, reg_pairs[i].off, reg_pairs[i].val);
13346b81f05aSSwapnil Jakhade 		}
13356b81f05aSSwapnil Jakhade 
13366b81f05aSSwapnil Jakhade 		/* PMA lane registers configurations */
13376b81f05aSSwapnil Jakhade 		pma_ln_vals = init_data->pma_ln_vals[phy_t1][phy_t2][ssc];
13386b81f05aSSwapnil Jakhade 		if (pma_ln_vals) {
13396b81f05aSSwapnil Jakhade 			reg_pairs = pma_ln_vals->reg_pairs;
13406b81f05aSSwapnil Jakhade 			num_regs = pma_ln_vals->num_regs;
13416b81f05aSSwapnil Jakhade 			for (i = 0; i < num_lanes; i++) {
13426b81f05aSSwapnil Jakhade 				regmap = sp->regmap_lane_cdb[i + mlane];
13436b81f05aSSwapnil Jakhade 				for (j = 0; j < num_regs; j++)
13446b81f05aSSwapnil Jakhade 					regmap_write(regmap, reg_pairs[j].off, reg_pairs[j].val);
13456b81f05aSSwapnil Jakhade 			}
13466b81f05aSSwapnil Jakhade 		}
13478a1b82d7SSwapnil Jakhade 
13480cfa43abSSwapnil Jakhade 		if (phy_t1 == TYPE_SGMII || phy_t1 == TYPE_QSGMII)
13498a1b82d7SSwapnil Jakhade 			reset_control_deassert(sp->phys[node].lnk_rst);
13506b81f05aSSwapnil Jakhade 	}
13516b81f05aSSwapnil Jakhade 
13526b81f05aSSwapnil Jakhade 	/* Take the PHY out of reset */
13536b81f05aSSwapnil Jakhade 	ret = reset_control_deassert(sp->phy_rst);
13546b81f05aSSwapnil Jakhade 	if (ret)
13556b81f05aSSwapnil Jakhade 		return ret;
13566b81f05aSSwapnil Jakhade 
13576b81f05aSSwapnil Jakhade 	return 0;
13586b81f05aSSwapnil Jakhade }
13596b81f05aSSwapnil Jakhade 
136044d30d62SAlan Douglas static int cdns_sierra_phy_probe(struct platform_device *pdev)
136144d30d62SAlan Douglas {
136244d30d62SAlan Douglas 	struct cdns_sierra_phy *sp;
136344d30d62SAlan Douglas 	struct phy_provider *phy_provider;
136444d30d62SAlan Douglas 	struct device *dev = &pdev->dev;
1365c3c11d55SSwapnil Jakhade 	const struct cdns_sierra_data *data;
1366380f5708SKishon Vijay Abraham I 	unsigned int id_value;
136729afbd76SDan Carpenter 	int ret, node = 0;
1368380f5708SKishon Vijay Abraham I 	void __iomem *base;
136944d30d62SAlan Douglas 	struct device_node *dn = dev->of_node, *child;
137044d30d62SAlan Douglas 
137144d30d62SAlan Douglas 	if (of_get_child_count(dn) == 0)
137244d30d62SAlan Douglas 		return -ENODEV;
137344d30d62SAlan Douglas 
1374380f5708SKishon Vijay Abraham I 	/* Get init data for this PHY */
1375c3c11d55SSwapnil Jakhade 	data = of_device_get_match_data(dev);
1376c3c11d55SSwapnil Jakhade 	if (!data)
1377380f5708SKishon Vijay Abraham I 		return -EINVAL;
1378380f5708SKishon Vijay Abraham I 
13796ef7aa32SLars-Peter Clausen 	sp = devm_kzalloc(dev, struct_size(sp, clk_data.hws,
13806ef7aa32SLars-Peter Clausen 					   CDNS_SIERRA_OUTPUT_CLOCKS),
13816ef7aa32SLars-Peter Clausen 			  GFP_KERNEL);
138244d30d62SAlan Douglas 	if (!sp)
138344d30d62SAlan Douglas 		return -ENOMEM;
138444d30d62SAlan Douglas 	dev_set_drvdata(dev, sp);
138544d30d62SAlan Douglas 	sp->dev = dev;
1386380f5708SKishon Vijay Abraham I 	sp->init_data = data;
138744d30d62SAlan Douglas 
1388fa629094SChunfeng Yun 	base = devm_platform_ioremap_resource(pdev, 0);
1389380f5708SKishon Vijay Abraham I 	if (IS_ERR(base)) {
139044d30d62SAlan Douglas 		dev_err(dev, "missing \"reg\"\n");
1391380f5708SKishon Vijay Abraham I 		return PTR_ERR(base);
139244d30d62SAlan Douglas 	}
139344d30d62SAlan Douglas 
1394380f5708SKishon Vijay Abraham I 	ret = cdns_regmap_init_blocks(sp, base, data->block_offset_shift,
1395380f5708SKishon Vijay Abraham I 				      data->reg_offset_shift);
1396380f5708SKishon Vijay Abraham I 	if (ret)
1397380f5708SKishon Vijay Abraham I 		return ret;
1398380f5708SKishon Vijay Abraham I 
1399380f5708SKishon Vijay Abraham I 	ret = cdns_regfield_init(sp);
1400380f5708SKishon Vijay Abraham I 	if (ret)
1401380f5708SKishon Vijay Abraham I 		return ret;
140244d30d62SAlan Douglas 
140344d30d62SAlan Douglas 	platform_set_drvdata(pdev, sp);
140444d30d62SAlan Douglas 
14057e016cbcSKishon Vijay Abraham I 	ret = cdns_sierra_phy_get_clocks(sp, dev);
14067e016cbcSKishon Vijay Abraham I 	if (ret)
14077e016cbcSKishon Vijay Abraham I 		return ret;
140844d30d62SAlan Douglas 
140928081b72SKishon Vijay Abraham I 	ret = cdns_sierra_clk_register(sp);
14101d5f40e0SKishon Vijay Abraham I 	if (ret)
14111d5f40e0SKishon Vijay Abraham I 		return ret;
141244d30d62SAlan Douglas 
14131436ec30SKishon Vijay Abraham I 	ret = cdns_sierra_phy_enable_clocks(sp);
141444d30d62SAlan Douglas 	if (ret)
141528081b72SKishon Vijay Abraham I 		goto unregister_clk;
141644d30d62SAlan Douglas 
1417d88ca22dSAswath Govindraju 	regmap_field_read(sp->pma_cmn_ready, &sp->already_configured);
1418d88ca22dSAswath Govindraju 
1419d88ca22dSAswath Govindraju 	if (!sp->already_configured) {
1420d88ca22dSAswath Govindraju 		ret = cdns_sierra_phy_clk(sp);
1421d88ca22dSAswath Govindraju 		if (ret)
1422d88ca22dSAswath Govindraju 			goto clk_disable;
1423d88ca22dSAswath Govindraju 
1424d88ca22dSAswath Govindraju 		ret = cdns_sierra_phy_get_resets(sp, dev);
1425d88ca22dSAswath Govindraju 		if (ret)
1426d88ca22dSAswath Govindraju 			goto clk_disable;
1427d88ca22dSAswath Govindraju 
142844d30d62SAlan Douglas 		/* Enable APB */
142944d30d62SAlan Douglas 		reset_control_deassert(sp->apb_rst);
1430d88ca22dSAswath Govindraju 	}
143144d30d62SAlan Douglas 
143244d30d62SAlan Douglas 	/* Check that PHY is present */
1433380f5708SKishon Vijay Abraham I 	regmap_field_read(sp->macro_id_type, &id_value);
1434380f5708SKishon Vijay Abraham I 	if  (sp->init_data->id_value != id_value) {
143544d30d62SAlan Douglas 		ret = -EINVAL;
1436d88ca22dSAswath Govindraju 		goto ctrl_assert;
143744d30d62SAlan Douglas 	}
143844d30d62SAlan Douglas 
143944d30d62SAlan Douglas 	sp->autoconf = of_property_read_bool(dn, "cdns,autoconf");
144044d30d62SAlan Douglas 
144144d30d62SAlan Douglas 	for_each_available_child_of_node(dn, child) {
144244d30d62SAlan Douglas 		struct phy *gphy;
144344d30d62SAlan Douglas 
144403ada5a3SKishon Vijay Abraham I 		if (!(of_node_name_eq(child, "phy") ||
144503ada5a3SKishon Vijay Abraham I 		      of_node_name_eq(child, "link")))
144603ada5a3SKishon Vijay Abraham I 			continue;
144703ada5a3SKishon Vijay Abraham I 
144844d30d62SAlan Douglas 		sp->phys[node].lnk_rst =
1449b872936fSKishon Vijay Abraham I 			of_reset_control_array_get_exclusive(child);
145044d30d62SAlan Douglas 
145144d30d62SAlan Douglas 		if (IS_ERR(sp->phys[node].lnk_rst)) {
145244d30d62SAlan Douglas 			dev_err(dev, "failed to get reset %s\n",
145344d30d62SAlan Douglas 				child->full_name);
145444d30d62SAlan Douglas 			ret = PTR_ERR(sp->phys[node].lnk_rst);
145529afbd76SDan Carpenter 			of_node_put(child);
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 				of_node_put(child);
146529afbd76SDan Carpenter 				reset_control_put(sp->phys[node].lnk_rst);
146629afbd76SDan Carpenter 				goto put_control;
146744d30d62SAlan Douglas 			}
146844d30d62SAlan Douglas 		}
146944d30d62SAlan Douglas 
1470a43f72aeSKishon Vijay Abraham I 		sp->num_lanes += sp->phys[node].num_lanes;
1471a43f72aeSKishon Vijay Abraham I 
1472d88ca22dSAswath Govindraju 		if (!sp->already_configured)
147344d30d62SAlan Douglas 			gphy = devm_phy_create(dev, child, &ops);
1474d88ca22dSAswath Govindraju 		else
1475d88ca22dSAswath Govindraju 			gphy = devm_phy_create(dev, child, &noop_ops);
147644d30d62SAlan Douglas 		if (IS_ERR(gphy)) {
147744d30d62SAlan Douglas 			ret = PTR_ERR(gphy);
147829afbd76SDan Carpenter 			of_node_put(child);
147929afbd76SDan Carpenter 			reset_control_put(sp->phys[node].lnk_rst);
148029afbd76SDan Carpenter 			goto put_control;
148144d30d62SAlan Douglas 		}
148244d30d62SAlan Douglas 		sp->phys[node].phy = gphy;
148344d30d62SAlan Douglas 		phy_set_drvdata(gphy, &sp->phys[node]);
148444d30d62SAlan Douglas 
148544d30d62SAlan Douglas 		node++;
148644d30d62SAlan Douglas 	}
148744d30d62SAlan Douglas 	sp->nsubnodes = node;
148844d30d62SAlan Douglas 
1489a43f72aeSKishon Vijay Abraham I 	if (sp->num_lanes > SIERRA_MAX_LANES) {
14906411e386SWang Wensheng 		ret = -EINVAL;
1491a43f72aeSKishon Vijay Abraham I 		dev_err(dev, "Invalid lane configuration\n");
149229afbd76SDan Carpenter 		goto put_control;
1493a43f72aeSKishon Vijay Abraham I 	}
1494a43f72aeSKishon Vijay Abraham I 
149544d30d62SAlan Douglas 	/* If more than one subnode, configure the PHY as multilink */
1496d88ca22dSAswath Govindraju 	if (!sp->already_configured && !sp->autoconf && sp->nsubnodes > 1) {
14976b81f05aSSwapnil Jakhade 		ret = cdns_sierra_phy_configure_multilink(sp);
14986b81f05aSSwapnil Jakhade 		if (ret)
149929afbd76SDan Carpenter 			goto put_control;
15006b81f05aSSwapnil Jakhade 	}
150144d30d62SAlan Douglas 
150244d30d62SAlan Douglas 	pm_runtime_enable(dev);
150344d30d62SAlan Douglas 	phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
150429afbd76SDan Carpenter 	if (IS_ERR(phy_provider)) {
150529afbd76SDan Carpenter 		ret = PTR_ERR(phy_provider);
150629afbd76SDan Carpenter 		goto put_control;
150729afbd76SDan Carpenter 	}
150844d30d62SAlan Douglas 
150929afbd76SDan Carpenter 	return 0;
151029afbd76SDan Carpenter 
151129afbd76SDan Carpenter put_control:
151229afbd76SDan Carpenter 	while (--node >= 0)
151329afbd76SDan Carpenter 		reset_control_put(sp->phys[node].lnk_rst);
1514d88ca22dSAswath Govindraju ctrl_assert:
1515d88ca22dSAswath Govindraju 	if (!sp->already_configured)
1516d88ca22dSAswath Govindraju 		reset_control_assert(sp->apb_rst);
151744d30d62SAlan Douglas clk_disable:
15181436ec30SKishon Vijay Abraham I 	cdns_sierra_phy_disable_clocks(sp);
151928081b72SKishon Vijay Abraham I unregister_clk:
152028081b72SKishon Vijay Abraham I 	cdns_sierra_clk_unregister(sp);
152144d30d62SAlan Douglas 	return ret;
152244d30d62SAlan Douglas }
152344d30d62SAlan Douglas 
1524e9ddb1adSUwe Kleine-König static void cdns_sierra_phy_remove(struct platform_device *pdev)
152544d30d62SAlan Douglas {
1526748e3456SKishon Vijay Abraham I 	struct cdns_sierra_phy *phy = platform_get_drvdata(pdev);
152744d30d62SAlan Douglas 	int i;
152844d30d62SAlan Douglas 
152944d30d62SAlan Douglas 	reset_control_assert(phy->phy_rst);
153044d30d62SAlan Douglas 	reset_control_assert(phy->apb_rst);
153144d30d62SAlan Douglas 	pm_runtime_disable(&pdev->dev);
153244d30d62SAlan Douglas 
15331436ec30SKishon Vijay Abraham I 	cdns_sierra_phy_disable_clocks(phy);
153444d30d62SAlan Douglas 	/*
153544d30d62SAlan Douglas 	 * The device level resets will be put automatically.
153644d30d62SAlan Douglas 	 * Need to put the subnode resets here though.
153744d30d62SAlan Douglas 	 */
153844d30d62SAlan Douglas 	for (i = 0; i < phy->nsubnodes; i++) {
153944d30d62SAlan Douglas 		reset_control_assert(phy->phys[i].lnk_rst);
154044d30d62SAlan Douglas 		reset_control_put(phy->phys[i].lnk_rst);
154144d30d62SAlan Douglas 	}
154229c2d02aSKishon Vijay Abraham I 
154328081b72SKishon Vijay Abraham I 	cdns_sierra_clk_unregister(phy);
154444d30d62SAlan Douglas }
154544d30d62SAlan Douglas 
15460cfa43abSSwapnil Jakhade /* SGMII PHY PMA lane configuration */
154729f33f0bSChristophe JAILLET static const struct cdns_reg_pairs sgmii_phy_pma_ln_regs[] = {
15480cfa43abSSwapnil Jakhade 	{0x9010, SIERRA_PHY_PMA_XCVR_CTRL}
15490cfa43abSSwapnil Jakhade };
15500cfa43abSSwapnil Jakhade 
1551da41bac5SChristophe JAILLET static const struct cdns_sierra_vals sgmii_phy_pma_ln_vals = {
15520cfa43abSSwapnil Jakhade 	.reg_pairs = sgmii_phy_pma_ln_regs,
15530cfa43abSSwapnil Jakhade 	.num_regs = ARRAY_SIZE(sgmii_phy_pma_ln_regs),
15540cfa43abSSwapnil Jakhade };
15550cfa43abSSwapnil Jakhade 
15560cfa43abSSwapnil Jakhade /* SGMII refclk 100MHz, no ssc, opt3 and GE1 links using PLL LC1 */
15570cfa43abSSwapnil Jakhade static const struct cdns_reg_pairs sgmii_100_no_ssc_plllc1_opt3_cmn_regs[] = {
15580cfa43abSSwapnil Jakhade 	{0x002D, SIERRA_CMN_PLLLC1_FBDIV_INT_PREG},
15590cfa43abSSwapnil Jakhade 	{0x2085, SIERRA_CMN_PLLLC1_LF_COEFF_MODE0_PREG},
15600cfa43abSSwapnil Jakhade 	{0x1005, SIERRA_CMN_PLLLC1_CLK0_PREG},
15610cfa43abSSwapnil Jakhade 	{0x0000, SIERRA_CMN_PLLLC1_BWCAL_MODE0_PREG},
15620cfa43abSSwapnil Jakhade 	{0x0800, SIERRA_CMN_PLLLC1_SS_TIME_STEPSIZE_MODE_PREG}
15630cfa43abSSwapnil Jakhade };
15640cfa43abSSwapnil Jakhade 
15650cfa43abSSwapnil Jakhade static const struct cdns_reg_pairs sgmii_100_no_ssc_plllc1_opt3_ln_regs[] = {
15660cfa43abSSwapnil Jakhade 	{0x688E, SIERRA_DET_STANDEC_D_PREG},
15670cfa43abSSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_IDLE_PREG},
15680cfa43abSSwapnil Jakhade 	{0x0FFE, SIERRA_PSC_RX_A0_PREG},
15690cfa43abSSwapnil Jakhade 	{0x0106, SIERRA_PLLCTRL_FBDIV_MODE01_PREG},
15700cfa43abSSwapnil Jakhade 	{0x0013, SIERRA_PLLCTRL_SUBRATE_PREG},
15710cfa43abSSwapnil Jakhade 	{0x0003, SIERRA_PLLCTRL_GEN_A_PREG},
15720cfa43abSSwapnil Jakhade 	{0x0106, SIERRA_PLLCTRL_GEN_D_PREG},
15730cfa43abSSwapnil Jakhade 	{0x5231, SIERRA_PLLCTRL_CPGAIN_MODE_PREG },
15740cfa43abSSwapnil Jakhade 	{0x0000, SIERRA_DRVCTRL_ATTEN_PREG},
15750cfa43abSSwapnil Jakhade 	{0x9702, SIERRA_DRVCTRL_BOOST_PREG},
15760cfa43abSSwapnil Jakhade 	{0x0051, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
15770cfa43abSSwapnil Jakhade 	{0x3C0E, SIERRA_CREQ_CCLKDET_MODE01_PREG},
15780cfa43abSSwapnil Jakhade 	{0x3220, SIERRA_CREQ_FSMCLK_SEL_PREG},
15790cfa43abSSwapnil Jakhade 	{0x0000, SIERRA_CREQ_EQ_CTRL_PREG},
15800cfa43abSSwapnil Jakhade 	{0x0002, SIERRA_DEQ_PHALIGN_CTRL},
15810cfa43abSSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT0},
15820cfa43abSSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT1},
15830cfa43abSSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT2},
15840cfa43abSSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT3},
15850cfa43abSSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT4},
15860cfa43abSSwapnil Jakhade 	{0x0861, SIERRA_DEQ_ALUT0},
15870cfa43abSSwapnil Jakhade 	{0x07E0, SIERRA_DEQ_ALUT1},
15880cfa43abSSwapnil Jakhade 	{0x079E, SIERRA_DEQ_ALUT2},
15890cfa43abSSwapnil Jakhade 	{0x071D, SIERRA_DEQ_ALUT3},
15900cfa43abSSwapnil Jakhade 	{0x03F5, SIERRA_DEQ_DFETAP_CTRL_PREG},
15910cfa43abSSwapnil Jakhade 	{0x0C01, SIERRA_DEQ_TAU_CTRL1_FAST_MAINT_PREG},
15920cfa43abSSwapnil Jakhade 	{0x3C40, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG},
15930cfa43abSSwapnil Jakhade 	{0x1C04, SIERRA_DEQ_TAU_CTRL2_PREG},
15940cfa43abSSwapnil Jakhade 	{0x0033, SIERRA_DEQ_PICTRL_PREG},
15950cfa43abSSwapnil Jakhade 	{0x0000, SIERRA_CPI_OUTBUF_RATESEL_PREG},
15960cfa43abSSwapnil Jakhade 	{0x0B6D, SIERRA_CPI_RESBIAS_BIN_PREG},
15970cfa43abSSwapnil Jakhade 	{0x0102, SIERRA_RXBUFFER_CTLECTRL_PREG},
15980cfa43abSSwapnil Jakhade 	{0x0002, SIERRA_RXBUFFER_RCDFECTRL_PREG}
15990cfa43abSSwapnil Jakhade };
16000cfa43abSSwapnil Jakhade 
1601da41bac5SChristophe JAILLET static const struct cdns_sierra_vals sgmii_100_no_ssc_plllc1_opt3_cmn_vals = {
16020cfa43abSSwapnil Jakhade 	.reg_pairs = sgmii_100_no_ssc_plllc1_opt3_cmn_regs,
16030cfa43abSSwapnil Jakhade 	.num_regs = ARRAY_SIZE(sgmii_100_no_ssc_plllc1_opt3_cmn_regs),
16040cfa43abSSwapnil Jakhade };
16050cfa43abSSwapnil Jakhade 
1606da41bac5SChristophe JAILLET static const struct cdns_sierra_vals sgmii_100_no_ssc_plllc1_opt3_ln_vals = {
16070cfa43abSSwapnil Jakhade 	.reg_pairs = sgmii_100_no_ssc_plllc1_opt3_ln_regs,
16080cfa43abSSwapnil Jakhade 	.num_regs = ARRAY_SIZE(sgmii_100_no_ssc_plllc1_opt3_ln_regs),
16090cfa43abSSwapnil Jakhade };
16100cfa43abSSwapnil Jakhade 
16118a1b82d7SSwapnil Jakhade /* QSGMII PHY PMA lane configuration */
161229f33f0bSChristophe JAILLET static const struct cdns_reg_pairs qsgmii_phy_pma_ln_regs[] = {
16138a1b82d7SSwapnil Jakhade 	{0x9010, SIERRA_PHY_PMA_XCVR_CTRL}
16148a1b82d7SSwapnil Jakhade };
16158a1b82d7SSwapnil Jakhade 
1616da41bac5SChristophe JAILLET static const struct cdns_sierra_vals qsgmii_phy_pma_ln_vals = {
16178a1b82d7SSwapnil Jakhade 	.reg_pairs = qsgmii_phy_pma_ln_regs,
16188a1b82d7SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(qsgmii_phy_pma_ln_regs),
16198a1b82d7SSwapnil Jakhade };
16208a1b82d7SSwapnil Jakhade 
16218a1b82d7SSwapnil Jakhade /* QSGMII refclk 100MHz, 20b, opt1, No BW cal, no ssc, PLL LC1 */
16228a1b82d7SSwapnil Jakhade static const struct cdns_reg_pairs qsgmii_100_no_ssc_plllc1_cmn_regs[] = {
16238a1b82d7SSwapnil Jakhade 	{0x2085, SIERRA_CMN_PLLLC1_LF_COEFF_MODE0_PREG},
16248a1b82d7SSwapnil Jakhade 	{0x0000, SIERRA_CMN_PLLLC1_BWCAL_MODE0_PREG},
16258a1b82d7SSwapnil Jakhade 	{0x0000, SIERRA_CMN_PLLLC1_SS_TIME_STEPSIZE_MODE_PREG}
16268a1b82d7SSwapnil Jakhade };
16278a1b82d7SSwapnil Jakhade 
16288a1b82d7SSwapnil Jakhade static const struct cdns_reg_pairs qsgmii_100_no_ssc_plllc1_ln_regs[] = {
16298a1b82d7SSwapnil Jakhade 	{0xFC08, SIERRA_DET_STANDEC_A_PREG},
16308a1b82d7SSwapnil Jakhade 	{0x0252, SIERRA_DET_STANDEC_E_PREG},
16318a1b82d7SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_IDLE_PREG},
16328a1b82d7SSwapnil Jakhade 	{0x0FFE, SIERRA_PSC_RX_A0_PREG},
16338a1b82d7SSwapnil Jakhade 	{0x0011, SIERRA_PLLCTRL_SUBRATE_PREG},
16348a1b82d7SSwapnil Jakhade 	{0x0001, SIERRA_PLLCTRL_GEN_A_PREG},
16358a1b82d7SSwapnil Jakhade 	{0x5233, SIERRA_PLLCTRL_CPGAIN_MODE_PREG},
16368a1b82d7SSwapnil Jakhade 	{0x0000, SIERRA_DRVCTRL_ATTEN_PREG},
16378a1b82d7SSwapnil Jakhade 	{0x0089, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
16388a1b82d7SSwapnil Jakhade 	{0x3C3C, SIERRA_CREQ_CCLKDET_MODE01_PREG},
16398a1b82d7SSwapnil Jakhade 	{0x3222, SIERRA_CREQ_FSMCLK_SEL_PREG},
16408a1b82d7SSwapnil Jakhade 	{0x0000, SIERRA_CREQ_EQ_CTRL_PREG},
16418a1b82d7SSwapnil Jakhade 	{0x8422, SIERRA_CTLELUT_CTRL_PREG},
16428a1b82d7SSwapnil Jakhade 	{0x4111, SIERRA_DFE_ECMP_RATESEL_PREG},
16438a1b82d7SSwapnil Jakhade 	{0x4111, SIERRA_DFE_SMP_RATESEL_PREG},
16448a1b82d7SSwapnil Jakhade 	{0x0002, SIERRA_DEQ_PHALIGN_CTRL},
16458a1b82d7SSwapnil Jakhade 	{0x9595, SIERRA_DEQ_VGATUNE_CTRL_PREG},
16468a1b82d7SSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT0},
16478a1b82d7SSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT1},
16488a1b82d7SSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT2},
16498a1b82d7SSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT3},
16508a1b82d7SSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT4},
16518a1b82d7SSwapnil Jakhade 	{0x0861, SIERRA_DEQ_ALUT0},
16528a1b82d7SSwapnil Jakhade 	{0x07E0, SIERRA_DEQ_ALUT1},
16538a1b82d7SSwapnil Jakhade 	{0x079E, SIERRA_DEQ_ALUT2},
16548a1b82d7SSwapnil Jakhade 	{0x071D, SIERRA_DEQ_ALUT3},
16558a1b82d7SSwapnil Jakhade 	{0x03F5, SIERRA_DEQ_DFETAP_CTRL_PREG},
16568a1b82d7SSwapnil Jakhade 	{0x0C01, SIERRA_DEQ_TAU_CTRL1_FAST_MAINT_PREG},
16578a1b82d7SSwapnil Jakhade 	{0x3C40, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG},
16588a1b82d7SSwapnil Jakhade 	{0x1C04, SIERRA_DEQ_TAU_CTRL2_PREG},
16598a1b82d7SSwapnil Jakhade 	{0x0033, SIERRA_DEQ_PICTRL_PREG},
16608a1b82d7SSwapnil Jakhade 	{0x0660, SIERRA_CPICAL_TMRVAL_MODE0_PREG},
16618a1b82d7SSwapnil Jakhade 	{0x00D5, SIERRA_CPI_OUTBUF_RATESEL_PREG},
16628a1b82d7SSwapnil Jakhade 	{0x0B6D, SIERRA_CPI_RESBIAS_BIN_PREG},
16638a1b82d7SSwapnil Jakhade 	{0x0102, SIERRA_RXBUFFER_CTLECTRL_PREG},
16648a1b82d7SSwapnil Jakhade 	{0x0002, SIERRA_RXBUFFER_RCDFECTRL_PREG}
16658a1b82d7SSwapnil Jakhade };
16668a1b82d7SSwapnil Jakhade 
1667da41bac5SChristophe JAILLET static const struct cdns_sierra_vals qsgmii_100_no_ssc_plllc1_cmn_vals = {
16688a1b82d7SSwapnil Jakhade 	.reg_pairs = qsgmii_100_no_ssc_plllc1_cmn_regs,
16698a1b82d7SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(qsgmii_100_no_ssc_plllc1_cmn_regs),
16708a1b82d7SSwapnil Jakhade };
16718a1b82d7SSwapnil Jakhade 
1672da41bac5SChristophe JAILLET static const struct cdns_sierra_vals qsgmii_100_no_ssc_plllc1_ln_vals = {
16738a1b82d7SSwapnil Jakhade 	.reg_pairs = qsgmii_100_no_ssc_plllc1_ln_regs,
16748a1b82d7SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(qsgmii_100_no_ssc_plllc1_ln_regs),
16758a1b82d7SSwapnil Jakhade };
16768a1b82d7SSwapnil Jakhade 
1677fa105172SSwapnil Jakhade /* PCIE PHY PCS common configuration */
167829f33f0bSChristophe JAILLET static const struct cdns_reg_pairs pcie_phy_pcs_cmn_regs[] = {
1679fa105172SSwapnil Jakhade 	{0x0430, SIERRA_PHY_PIPE_CMN_CTRL1}
1680fa105172SSwapnil Jakhade };
1681fa105172SSwapnil Jakhade 
1682da41bac5SChristophe JAILLET static const struct cdns_sierra_vals pcie_phy_pcs_cmn_vals = {
1683fa105172SSwapnil Jakhade 	.reg_pairs = pcie_phy_pcs_cmn_regs,
1684fa105172SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(pcie_phy_pcs_cmn_regs),
1685fa105172SSwapnil Jakhade };
1686fa105172SSwapnil Jakhade 
16878a1b82d7SSwapnil Jakhade /* refclk100MHz_32b_PCIe_cmn_pll_no_ssc, pcie_links_using_plllc, pipe_bw_3 */
16888a1b82d7SSwapnil Jakhade static const struct cdns_reg_pairs pcie_100_no_ssc_plllc_cmn_regs[] = {
16898a1b82d7SSwapnil Jakhade 	{0x2105, SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG},
16908a1b82d7SSwapnil Jakhade 	{0x2105, SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG},
16918a1b82d7SSwapnil Jakhade 	{0x8A06, SIERRA_CMN_PLLLC_BWCAL_MODE1_PREG},
16928a1b82d7SSwapnil Jakhade 	{0x8A06, SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG}
16938a1b82d7SSwapnil Jakhade };
16948a1b82d7SSwapnil Jakhade 
16958a1b82d7SSwapnil Jakhade /*
16968a1b82d7SSwapnil Jakhade  * refclk100MHz_32b_PCIe_ln_no_ssc, multilink, using_plllc,
16978a1b82d7SSwapnil Jakhade  * cmn_pllcy_anaclk0_1Ghz, xcvr_pllclk_fullrt_500mhz
16988a1b82d7SSwapnil Jakhade  */
16998a1b82d7SSwapnil Jakhade static const struct cdns_reg_pairs ml_pcie_100_no_ssc_ln_regs[] = {
17008a1b82d7SSwapnil Jakhade 	{0xFC08, SIERRA_DET_STANDEC_A_PREG},
17018a1b82d7SSwapnil Jakhade 	{0x001D, SIERRA_PSM_A3IN_TMR_PREG},
17028a1b82d7SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_A3_PREG},
17038a1b82d7SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_A4_PREG},
17048a1b82d7SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_IDLE_PREG},
17058a1b82d7SSwapnil Jakhade 	{0x1555, SIERRA_DFE_BIASTRIM_PREG},
17068a1b82d7SSwapnil Jakhade 	{0x9703, SIERRA_DRVCTRL_BOOST_PREG},
17078a1b82d7SSwapnil Jakhade 	{0x8055, SIERRA_RX_CREQ_FLTR_A_MODE3_PREG},
17088a1b82d7SSwapnil Jakhade 	{0x80BB, SIERRA_RX_CREQ_FLTR_A_MODE2_PREG},
17098a1b82d7SSwapnil Jakhade 	{0x8351, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG},
17108a1b82d7SSwapnil Jakhade 	{0x8349, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
17118a1b82d7SSwapnil Jakhade 	{0x0002, SIERRA_CREQ_DCBIASATTEN_OVR_PREG},
17128a1b82d7SSwapnil Jakhade 	{0x9800, SIERRA_RX_CTLE_CAL_PREG},
17138a1b82d7SSwapnil Jakhade 	{0x5624, SIERRA_DEQ_CONCUR_CTRL2_PREG},
17148a1b82d7SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_EPIPWR_CTRL2_PREG},
17158a1b82d7SSwapnil Jakhade 	{0x00FF, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG},
17168a1b82d7SSwapnil Jakhade 	{0x4C4C, SIERRA_DEQ_ERRCMP_CTRL_PREG},
17178a1b82d7SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_OFFSET_CTRL_PREG},
17188a1b82d7SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_GAIN_CTRL_PREG},
17198a1b82d7SSwapnil Jakhade 	{0x0041, SIERRA_DEQ_GLUT0},
17208a1b82d7SSwapnil Jakhade 	{0x0082, SIERRA_DEQ_GLUT1},
17218a1b82d7SSwapnil Jakhade 	{0x00C3, SIERRA_DEQ_GLUT2},
17228a1b82d7SSwapnil Jakhade 	{0x0145, SIERRA_DEQ_GLUT3},
17238a1b82d7SSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT4},
17248a1b82d7SSwapnil Jakhade 	{0x09E7, SIERRA_DEQ_ALUT0},
17258a1b82d7SSwapnil Jakhade 	{0x09A6, SIERRA_DEQ_ALUT1},
17268a1b82d7SSwapnil Jakhade 	{0x0965, SIERRA_DEQ_ALUT2},
17278a1b82d7SSwapnil Jakhade 	{0x08E3, SIERRA_DEQ_ALUT3},
17288a1b82d7SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP0},
17298a1b82d7SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP1},
17308a1b82d7SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP2},
17318a1b82d7SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP3},
17328a1b82d7SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP4},
17338a1b82d7SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_PRECUR_PREG},
17348a1b82d7SSwapnil Jakhade 	{0x0280, SIERRA_DEQ_POSTCUR_PREG},
17358a1b82d7SSwapnil Jakhade 	{0x8F00, SIERRA_DEQ_POSTCUR_DECR_PREG},
17368a1b82d7SSwapnil Jakhade 	{0x3C0F, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG},
17378a1b82d7SSwapnil Jakhade 	{0x1C0C, SIERRA_DEQ_TAU_CTRL2_PREG},
17388a1b82d7SSwapnil Jakhade 	{0x0100, SIERRA_DEQ_TAU_CTRL3_PREG},
17398a1b82d7SSwapnil Jakhade 	{0x5E82, SIERRA_DEQ_OPENEYE_CTRL_PREG},
17408a1b82d7SSwapnil Jakhade 	{0x002B, SIERRA_CPI_TRIM_PREG},
17418a1b82d7SSwapnil Jakhade 	{0x0003, SIERRA_EPI_CTRL_PREG},
17428a1b82d7SSwapnil Jakhade 	{0x803F, SIERRA_SDFILT_H2L_A_PREG},
17438a1b82d7SSwapnil Jakhade 	{0x0004, SIERRA_RXBUFFER_CTLECTRL_PREG},
17448a1b82d7SSwapnil Jakhade 	{0x2010, SIERRA_RXBUFFER_RCDFECTRL_PREG},
17458a1b82d7SSwapnil Jakhade 	{0x4432, SIERRA_RXBUFFER_DFECTRL_PREG}
17468a1b82d7SSwapnil Jakhade };
17478a1b82d7SSwapnil Jakhade 
1748da41bac5SChristophe JAILLET static const struct cdns_sierra_vals pcie_100_no_ssc_plllc_cmn_vals = {
17498a1b82d7SSwapnil Jakhade 	.reg_pairs = pcie_100_no_ssc_plllc_cmn_regs,
17508a1b82d7SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(pcie_100_no_ssc_plllc_cmn_regs),
17518a1b82d7SSwapnil Jakhade };
17528a1b82d7SSwapnil Jakhade 
1753da41bac5SChristophe JAILLET static const struct cdns_sierra_vals ml_pcie_100_no_ssc_ln_vals = {
17548a1b82d7SSwapnil Jakhade 	.reg_pairs = ml_pcie_100_no_ssc_ln_regs,
17558a1b82d7SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(ml_pcie_100_no_ssc_ln_regs),
17568a1b82d7SSwapnil Jakhade };
17578a1b82d7SSwapnil Jakhade 
1758e72659b6SSwapnil Jakhade /*
1759e72659b6SSwapnil Jakhade  * TI J721E:
1760e72659b6SSwapnil Jakhade  * refclk100MHz_32b_PCIe_ln_no_ssc, multilink, using_plllc,
1761e72659b6SSwapnil Jakhade  * cmn_pllcy_anaclk0_1Ghz, xcvr_pllclk_fullrt_500mhz
1762e72659b6SSwapnil Jakhade  */
1763e72659b6SSwapnil Jakhade static const struct cdns_reg_pairs ti_ml_pcie_100_no_ssc_ln_regs[] = {
1764e72659b6SSwapnil Jakhade 	{0xFC08, SIERRA_DET_STANDEC_A_PREG},
1765e72659b6SSwapnil Jakhade 	{0x001D, SIERRA_PSM_A3IN_TMR_PREG},
1766e72659b6SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_A3_PREG},
1767e72659b6SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_A4_PREG},
1768e72659b6SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_IDLE_PREG},
1769e72659b6SSwapnil Jakhade 	{0x1555, SIERRA_DFE_BIASTRIM_PREG},
1770e72659b6SSwapnil Jakhade 	{0x9703, SIERRA_DRVCTRL_BOOST_PREG},
1771e72659b6SSwapnil Jakhade 	{0x8055, SIERRA_RX_CREQ_FLTR_A_MODE3_PREG},
1772e72659b6SSwapnil Jakhade 	{0x80BB, SIERRA_RX_CREQ_FLTR_A_MODE2_PREG},
1773e72659b6SSwapnil Jakhade 	{0x8351, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG},
1774e72659b6SSwapnil Jakhade 	{0x8349, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
1775e72659b6SSwapnil Jakhade 	{0x0002, SIERRA_CREQ_DCBIASATTEN_OVR_PREG},
1776e72659b6SSwapnil Jakhade 	{0x9800, SIERRA_RX_CTLE_CAL_PREG},
1777e72659b6SSwapnil Jakhade 	{0x5624, SIERRA_DEQ_CONCUR_CTRL2_PREG},
1778e72659b6SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_EPIPWR_CTRL2_PREG},
1779e72659b6SSwapnil Jakhade 	{0x00FF, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG},
1780e72659b6SSwapnil Jakhade 	{0x4C4C, SIERRA_DEQ_ERRCMP_CTRL_PREG},
1781e72659b6SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_OFFSET_CTRL_PREG},
1782e72659b6SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_GAIN_CTRL_PREG},
1783e72659b6SSwapnil Jakhade 	{0x0041, SIERRA_DEQ_GLUT0},
1784e72659b6SSwapnil Jakhade 	{0x0082, SIERRA_DEQ_GLUT1},
1785e72659b6SSwapnil Jakhade 	{0x00C3, SIERRA_DEQ_GLUT2},
1786e72659b6SSwapnil Jakhade 	{0x0145, SIERRA_DEQ_GLUT3},
1787e72659b6SSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT4},
1788e72659b6SSwapnil Jakhade 	{0x09E7, SIERRA_DEQ_ALUT0},
1789e72659b6SSwapnil Jakhade 	{0x09A6, SIERRA_DEQ_ALUT1},
1790e72659b6SSwapnil Jakhade 	{0x0965, SIERRA_DEQ_ALUT2},
1791e72659b6SSwapnil Jakhade 	{0x08E3, SIERRA_DEQ_ALUT3},
1792e72659b6SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP0},
1793e72659b6SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP1},
1794e72659b6SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP2},
1795e72659b6SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP3},
1796e72659b6SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP4},
1797e72659b6SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_PRECUR_PREG},
1798e72659b6SSwapnil Jakhade 	{0x0280, SIERRA_DEQ_POSTCUR_PREG},
1799e72659b6SSwapnil Jakhade 	{0x8F00, SIERRA_DEQ_POSTCUR_DECR_PREG},
1800e72659b6SSwapnil Jakhade 	{0x3C0F, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG},
1801e72659b6SSwapnil Jakhade 	{0x1C0C, SIERRA_DEQ_TAU_CTRL2_PREG},
1802e72659b6SSwapnil Jakhade 	{0x0100, SIERRA_DEQ_TAU_CTRL3_PREG},
1803e72659b6SSwapnil Jakhade 	{0x5E82, SIERRA_DEQ_OPENEYE_CTRL_PREG},
1804e72659b6SSwapnil Jakhade 	{0x002B, SIERRA_CPI_TRIM_PREG},
1805e72659b6SSwapnil Jakhade 	{0x0003, SIERRA_EPI_CTRL_PREG},
1806e72659b6SSwapnil Jakhade 	{0x803F, SIERRA_SDFILT_H2L_A_PREG},
1807e72659b6SSwapnil Jakhade 	{0x0004, SIERRA_RXBUFFER_CTLECTRL_PREG},
1808e72659b6SSwapnil Jakhade 	{0x2010, SIERRA_RXBUFFER_RCDFECTRL_PREG},
1809e72659b6SSwapnil Jakhade 	{0x4432, SIERRA_RXBUFFER_DFECTRL_PREG},
1810e72659b6SSwapnil Jakhade 	{0x0002, SIERRA_TX_RCVDET_OVRD_PREG}
1811e72659b6SSwapnil Jakhade };
1812e72659b6SSwapnil Jakhade 
1813da41bac5SChristophe JAILLET static const struct cdns_sierra_vals ti_ml_pcie_100_no_ssc_ln_vals = {
1814e72659b6SSwapnil Jakhade 	.reg_pairs = ti_ml_pcie_100_no_ssc_ln_regs,
1815e72659b6SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(ti_ml_pcie_100_no_ssc_ln_regs),
1816e72659b6SSwapnil Jakhade };
1817e72659b6SSwapnil Jakhade 
18188a1b82d7SSwapnil Jakhade /* refclk100MHz_32b_PCIe_cmn_pll_int_ssc, pcie_links_using_plllc, pipe_bw_3 */
18198a1b82d7SSwapnil Jakhade static const struct cdns_reg_pairs pcie_100_int_ssc_plllc_cmn_regs[] = {
18208a1b82d7SSwapnil Jakhade 	{0x000E, SIERRA_CMN_PLLLC_MODE_PREG},
18218a1b82d7SSwapnil Jakhade 	{0x4006, SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG},
18228a1b82d7SSwapnil Jakhade 	{0x4006, SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG},
18238a1b82d7SSwapnil Jakhade 	{0x0000, SIERRA_CMN_PLLLC_BWCAL_MODE1_PREG},
18248a1b82d7SSwapnil Jakhade 	{0x0000, SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG},
18258a1b82d7SSwapnil Jakhade 	{0x0581, SIERRA_CMN_PLLLC_DSMCORR_PREG},
18268a1b82d7SSwapnil Jakhade 	{0x7F80, SIERRA_CMN_PLLLC_SS_PREG},
18278a1b82d7SSwapnil Jakhade 	{0x0041, SIERRA_CMN_PLLLC_SS_AMP_STEP_SIZE_PREG},
18288a1b82d7SSwapnil Jakhade 	{0x0464, SIERRA_CMN_PLLLC_SSTWOPT_PREG},
18298a1b82d7SSwapnil Jakhade 	{0x0D0D, SIERRA_CMN_PLLLC_SS_TIME_STEPSIZE_MODE_PREG},
18308a1b82d7SSwapnil Jakhade 	{0x0060, SIERRA_CMN_PLLLC_LOCK_DELAY_CTRL_PREG}
18318a1b82d7SSwapnil Jakhade };
18328a1b82d7SSwapnil Jakhade 
18338a1b82d7SSwapnil Jakhade /*
18348a1b82d7SSwapnil Jakhade  * refclk100MHz_32b_PCIe_ln_int_ssc, multilink, using_plllc,
18358a1b82d7SSwapnil Jakhade  * cmn_pllcy_anaclk0_1Ghz, xcvr_pllclk_fullrt_500mhz
18368a1b82d7SSwapnil Jakhade  */
18378a1b82d7SSwapnil Jakhade static const struct cdns_reg_pairs ml_pcie_100_int_ssc_ln_regs[] = {
18388a1b82d7SSwapnil Jakhade 	{0xFC08, SIERRA_DET_STANDEC_A_PREG},
18398a1b82d7SSwapnil Jakhade 	{0x001D, SIERRA_PSM_A3IN_TMR_PREG},
18408a1b82d7SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_A3_PREG},
18418a1b82d7SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_A4_PREG},
18428a1b82d7SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_IDLE_PREG},
18438a1b82d7SSwapnil Jakhade 	{0x1555, SIERRA_DFE_BIASTRIM_PREG},
18448a1b82d7SSwapnil Jakhade 	{0x9703, SIERRA_DRVCTRL_BOOST_PREG},
18458a1b82d7SSwapnil Jakhade 	{0x813E, SIERRA_CLKPATHCTRL_TMR_PREG},
18468a1b82d7SSwapnil Jakhade 	{0x8047, SIERRA_RX_CREQ_FLTR_A_MODE3_PREG},
18478a1b82d7SSwapnil Jakhade 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE2_PREG},
18488a1b82d7SSwapnil Jakhade 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG},
18498a1b82d7SSwapnil Jakhade 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
18508a1b82d7SSwapnil Jakhade 	{0x0002, SIERRA_CREQ_DCBIASATTEN_OVR_PREG},
18518a1b82d7SSwapnil Jakhade 	{0x9800, SIERRA_RX_CTLE_CAL_PREG},
18528a1b82d7SSwapnil Jakhade 	{0x033C, SIERRA_RX_CTLE_MAINTENANCE_PREG},
18538a1b82d7SSwapnil Jakhade 	{0x44CC, SIERRA_CREQ_EQ_OPEN_EYE_THRESH_PREG},
18548a1b82d7SSwapnil Jakhade 	{0x5624, SIERRA_DEQ_CONCUR_CTRL2_PREG},
18558a1b82d7SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_EPIPWR_CTRL2_PREG},
18568a1b82d7SSwapnil Jakhade 	{0x00FF, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG},
18578a1b82d7SSwapnil Jakhade 	{0x4C4C, SIERRA_DEQ_ERRCMP_CTRL_PREG},
18588a1b82d7SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_OFFSET_CTRL_PREG},
18598a1b82d7SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_GAIN_CTRL_PREG},
18608a1b82d7SSwapnil Jakhade 	{0x0041, SIERRA_DEQ_GLUT0},
18618a1b82d7SSwapnil Jakhade 	{0x0082, SIERRA_DEQ_GLUT1},
18628a1b82d7SSwapnil Jakhade 	{0x00C3, SIERRA_DEQ_GLUT2},
18638a1b82d7SSwapnil Jakhade 	{0x0145, SIERRA_DEQ_GLUT3},
18648a1b82d7SSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT4},
18658a1b82d7SSwapnil Jakhade 	{0x09E7, SIERRA_DEQ_ALUT0},
18668a1b82d7SSwapnil Jakhade 	{0x09A6, SIERRA_DEQ_ALUT1},
18678a1b82d7SSwapnil Jakhade 	{0x0965, SIERRA_DEQ_ALUT2},
18688a1b82d7SSwapnil Jakhade 	{0x08E3, SIERRA_DEQ_ALUT3},
18698a1b82d7SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP0},
18708a1b82d7SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP1},
18718a1b82d7SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP2},
18728a1b82d7SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP3},
18738a1b82d7SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP4},
18748a1b82d7SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_PRECUR_PREG},
18758a1b82d7SSwapnil Jakhade 	{0x0280, SIERRA_DEQ_POSTCUR_PREG},
18768a1b82d7SSwapnil Jakhade 	{0x8F00, SIERRA_DEQ_POSTCUR_DECR_PREG},
18778a1b82d7SSwapnil Jakhade 	{0x3C0F, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG},
18788a1b82d7SSwapnil Jakhade 	{0x1C0C, SIERRA_DEQ_TAU_CTRL2_PREG},
18798a1b82d7SSwapnil Jakhade 	{0x0100, SIERRA_DEQ_TAU_CTRL3_PREG},
18808a1b82d7SSwapnil Jakhade 	{0x5E82, SIERRA_DEQ_OPENEYE_CTRL_PREG},
18818a1b82d7SSwapnil Jakhade 	{0x002B, SIERRA_CPI_TRIM_PREG},
18828a1b82d7SSwapnil Jakhade 	{0x0003, SIERRA_EPI_CTRL_PREG},
18838a1b82d7SSwapnil Jakhade 	{0x803F, SIERRA_SDFILT_H2L_A_PREG},
18848a1b82d7SSwapnil Jakhade 	{0x0004, SIERRA_RXBUFFER_CTLECTRL_PREG},
18858a1b82d7SSwapnil Jakhade 	{0x2010, SIERRA_RXBUFFER_RCDFECTRL_PREG},
18868a1b82d7SSwapnil Jakhade 	{0x4432, SIERRA_RXBUFFER_DFECTRL_PREG}
18878a1b82d7SSwapnil Jakhade };
18888a1b82d7SSwapnil Jakhade 
1889da41bac5SChristophe JAILLET static const struct cdns_sierra_vals pcie_100_int_ssc_plllc_cmn_vals = {
18908a1b82d7SSwapnil Jakhade 	.reg_pairs = pcie_100_int_ssc_plllc_cmn_regs,
18918a1b82d7SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(pcie_100_int_ssc_plllc_cmn_regs),
18928a1b82d7SSwapnil Jakhade };
18938a1b82d7SSwapnil Jakhade 
1894da41bac5SChristophe JAILLET static const struct cdns_sierra_vals ml_pcie_100_int_ssc_ln_vals = {
18958a1b82d7SSwapnil Jakhade 	.reg_pairs = ml_pcie_100_int_ssc_ln_regs,
18968a1b82d7SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(ml_pcie_100_int_ssc_ln_regs),
18978a1b82d7SSwapnil Jakhade };
18988a1b82d7SSwapnil Jakhade 
1899e72659b6SSwapnil Jakhade /*
1900e72659b6SSwapnil Jakhade  * TI J721E:
1901e72659b6SSwapnil Jakhade  * refclk100MHz_32b_PCIe_ln_int_ssc, multilink, using_plllc,
1902e72659b6SSwapnil Jakhade  * cmn_pllcy_anaclk0_1Ghz, xcvr_pllclk_fullrt_500mhz
1903e72659b6SSwapnil Jakhade  */
1904e72659b6SSwapnil Jakhade static const struct cdns_reg_pairs ti_ml_pcie_100_int_ssc_ln_regs[] = {
1905e72659b6SSwapnil Jakhade 	{0xFC08, SIERRA_DET_STANDEC_A_PREG},
1906e72659b6SSwapnil Jakhade 	{0x001D, SIERRA_PSM_A3IN_TMR_PREG},
1907e72659b6SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_A3_PREG},
1908e72659b6SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_A4_PREG},
1909e72659b6SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_IDLE_PREG},
1910e72659b6SSwapnil Jakhade 	{0x1555, SIERRA_DFE_BIASTRIM_PREG},
1911e72659b6SSwapnil Jakhade 	{0x9703, SIERRA_DRVCTRL_BOOST_PREG},
1912e72659b6SSwapnil Jakhade 	{0x813E, SIERRA_CLKPATHCTRL_TMR_PREG},
1913e72659b6SSwapnil Jakhade 	{0x8047, SIERRA_RX_CREQ_FLTR_A_MODE3_PREG},
1914e72659b6SSwapnil Jakhade 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE2_PREG},
1915e72659b6SSwapnil Jakhade 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG},
1916e72659b6SSwapnil Jakhade 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
1917e72659b6SSwapnil Jakhade 	{0x0002, SIERRA_CREQ_DCBIASATTEN_OVR_PREG},
1918e72659b6SSwapnil Jakhade 	{0x9800, SIERRA_RX_CTLE_CAL_PREG},
1919e72659b6SSwapnil Jakhade 	{0x033C, SIERRA_RX_CTLE_MAINTENANCE_PREG},
1920e72659b6SSwapnil Jakhade 	{0x44CC, SIERRA_CREQ_EQ_OPEN_EYE_THRESH_PREG},
1921e72659b6SSwapnil Jakhade 	{0x5624, SIERRA_DEQ_CONCUR_CTRL2_PREG},
1922e72659b6SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_EPIPWR_CTRL2_PREG},
1923e72659b6SSwapnil Jakhade 	{0x00FF, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG},
1924e72659b6SSwapnil Jakhade 	{0x4C4C, SIERRA_DEQ_ERRCMP_CTRL_PREG},
1925e72659b6SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_OFFSET_CTRL_PREG},
1926e72659b6SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_GAIN_CTRL_PREG},
1927e72659b6SSwapnil Jakhade 	{0x0041, SIERRA_DEQ_GLUT0},
1928e72659b6SSwapnil Jakhade 	{0x0082, SIERRA_DEQ_GLUT1},
1929e72659b6SSwapnil Jakhade 	{0x00C3, SIERRA_DEQ_GLUT2},
1930e72659b6SSwapnil Jakhade 	{0x0145, SIERRA_DEQ_GLUT3},
1931e72659b6SSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT4},
1932e72659b6SSwapnil Jakhade 	{0x09E7, SIERRA_DEQ_ALUT0},
1933e72659b6SSwapnil Jakhade 	{0x09A6, SIERRA_DEQ_ALUT1},
1934e72659b6SSwapnil Jakhade 	{0x0965, SIERRA_DEQ_ALUT2},
1935e72659b6SSwapnil Jakhade 	{0x08E3, SIERRA_DEQ_ALUT3},
1936e72659b6SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP0},
1937e72659b6SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP1},
1938e72659b6SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP2},
1939e72659b6SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP3},
1940e72659b6SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP4},
1941e72659b6SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_PRECUR_PREG},
1942e72659b6SSwapnil Jakhade 	{0x0280, SIERRA_DEQ_POSTCUR_PREG},
1943e72659b6SSwapnil Jakhade 	{0x8F00, SIERRA_DEQ_POSTCUR_DECR_PREG},
1944e72659b6SSwapnil Jakhade 	{0x3C0F, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG},
1945e72659b6SSwapnil Jakhade 	{0x1C0C, SIERRA_DEQ_TAU_CTRL2_PREG},
1946e72659b6SSwapnil Jakhade 	{0x0100, SIERRA_DEQ_TAU_CTRL3_PREG},
1947e72659b6SSwapnil Jakhade 	{0x5E82, SIERRA_DEQ_OPENEYE_CTRL_PREG},
1948e72659b6SSwapnil Jakhade 	{0x002B, SIERRA_CPI_TRIM_PREG},
1949e72659b6SSwapnil Jakhade 	{0x0003, SIERRA_EPI_CTRL_PREG},
1950e72659b6SSwapnil Jakhade 	{0x803F, SIERRA_SDFILT_H2L_A_PREG},
1951e72659b6SSwapnil Jakhade 	{0x0004, SIERRA_RXBUFFER_CTLECTRL_PREG},
1952e72659b6SSwapnil Jakhade 	{0x2010, SIERRA_RXBUFFER_RCDFECTRL_PREG},
1953e72659b6SSwapnil Jakhade 	{0x4432, SIERRA_RXBUFFER_DFECTRL_PREG},
1954e72659b6SSwapnil Jakhade 	{0x0002, SIERRA_TX_RCVDET_OVRD_PREG}
1955e72659b6SSwapnil Jakhade };
1956e72659b6SSwapnil Jakhade 
1957da41bac5SChristophe JAILLET static const struct cdns_sierra_vals ti_ml_pcie_100_int_ssc_ln_vals = {
1958e72659b6SSwapnil Jakhade 	.reg_pairs = ti_ml_pcie_100_int_ssc_ln_regs,
1959e72659b6SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(ti_ml_pcie_100_int_ssc_ln_regs),
1960e72659b6SSwapnil Jakhade };
1961e72659b6SSwapnil Jakhade 
19628a1b82d7SSwapnil Jakhade /* refclk100MHz_32b_PCIe_cmn_pll_ext_ssc, pcie_links_using_plllc, pipe_bw_3 */
19638a1b82d7SSwapnil Jakhade static const struct cdns_reg_pairs pcie_100_ext_ssc_plllc_cmn_regs[] = {
19648a1b82d7SSwapnil Jakhade 	{0x2106, SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG},
19658a1b82d7SSwapnil Jakhade 	{0x2106, SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG},
19668a1b82d7SSwapnil Jakhade 	{0x8A06, SIERRA_CMN_PLLLC_BWCAL_MODE1_PREG},
19678a1b82d7SSwapnil Jakhade 	{0x8A06, SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG},
19688a1b82d7SSwapnil Jakhade 	{0x1B1B, SIERRA_CMN_PLLLC_SS_TIME_STEPSIZE_MODE_PREG}
19698a1b82d7SSwapnil Jakhade };
19708a1b82d7SSwapnil Jakhade 
19718a1b82d7SSwapnil Jakhade /*
19728a1b82d7SSwapnil Jakhade  * refclk100MHz_32b_PCIe_ln_ext_ssc, multilink, using_plllc,
19738a1b82d7SSwapnil Jakhade  * cmn_pllcy_anaclk0_1Ghz, xcvr_pllclk_fullrt_500mhz
19748a1b82d7SSwapnil Jakhade  */
19758a1b82d7SSwapnil Jakhade static const struct cdns_reg_pairs ml_pcie_100_ext_ssc_ln_regs[] = {
19768a1b82d7SSwapnil Jakhade 	{0xFC08, SIERRA_DET_STANDEC_A_PREG},
19778a1b82d7SSwapnil Jakhade 	{0x001D, SIERRA_PSM_A3IN_TMR_PREG},
19788a1b82d7SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_A3_PREG},
19798a1b82d7SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_A4_PREG},
19808a1b82d7SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_IDLE_PREG},
19818a1b82d7SSwapnil Jakhade 	{0x1555, SIERRA_DFE_BIASTRIM_PREG},
19828a1b82d7SSwapnil Jakhade 	{0x9703, SIERRA_DRVCTRL_BOOST_PREG},
19838a1b82d7SSwapnil Jakhade 	{0x813E, SIERRA_CLKPATHCTRL_TMR_PREG},
19848a1b82d7SSwapnil Jakhade 	{0x8047, SIERRA_RX_CREQ_FLTR_A_MODE3_PREG},
19858a1b82d7SSwapnil Jakhade 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE2_PREG},
19868a1b82d7SSwapnil Jakhade 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG},
19878a1b82d7SSwapnil Jakhade 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
19888a1b82d7SSwapnil Jakhade 	{0x0002, SIERRA_CREQ_DCBIASATTEN_OVR_PREG},
19898a1b82d7SSwapnil Jakhade 	{0x9800, SIERRA_RX_CTLE_CAL_PREG},
19908a1b82d7SSwapnil Jakhade 	{0x033C, SIERRA_RX_CTLE_MAINTENANCE_PREG},
19918a1b82d7SSwapnil Jakhade 	{0x44CC, SIERRA_CREQ_EQ_OPEN_EYE_THRESH_PREG},
19928a1b82d7SSwapnil Jakhade 	{0x5624, SIERRA_DEQ_CONCUR_CTRL2_PREG},
19938a1b82d7SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_EPIPWR_CTRL2_PREG},
19948a1b82d7SSwapnil Jakhade 	{0x00FF, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG},
19958a1b82d7SSwapnil Jakhade 	{0x4C4C, SIERRA_DEQ_ERRCMP_CTRL_PREG},
19968a1b82d7SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_OFFSET_CTRL_PREG},
19978a1b82d7SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_GAIN_CTRL_PREG},
19988a1b82d7SSwapnil Jakhade 	{0x0041, SIERRA_DEQ_GLUT0},
19998a1b82d7SSwapnil Jakhade 	{0x0082, SIERRA_DEQ_GLUT1},
20008a1b82d7SSwapnil Jakhade 	{0x00C3, SIERRA_DEQ_GLUT2},
20018a1b82d7SSwapnil Jakhade 	{0x0145, SIERRA_DEQ_GLUT3},
20028a1b82d7SSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT4},
20038a1b82d7SSwapnil Jakhade 	{0x09E7, SIERRA_DEQ_ALUT0},
20048a1b82d7SSwapnil Jakhade 	{0x09A6, SIERRA_DEQ_ALUT1},
20058a1b82d7SSwapnil Jakhade 	{0x0965, SIERRA_DEQ_ALUT2},
20068a1b82d7SSwapnil Jakhade 	{0x08E3, SIERRA_DEQ_ALUT3},
20078a1b82d7SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP0},
20088a1b82d7SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP1},
20098a1b82d7SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP2},
20108a1b82d7SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP3},
20118a1b82d7SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP4},
20128a1b82d7SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_PRECUR_PREG},
20138a1b82d7SSwapnil Jakhade 	{0x0280, SIERRA_DEQ_POSTCUR_PREG},
20148a1b82d7SSwapnil Jakhade 	{0x8F00, SIERRA_DEQ_POSTCUR_DECR_PREG},
20158a1b82d7SSwapnil Jakhade 	{0x3C0F, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG},
20168a1b82d7SSwapnil Jakhade 	{0x1C0C, SIERRA_DEQ_TAU_CTRL2_PREG},
20178a1b82d7SSwapnil Jakhade 	{0x0100, SIERRA_DEQ_TAU_CTRL3_PREG},
20188a1b82d7SSwapnil Jakhade 	{0x5E82, SIERRA_DEQ_OPENEYE_CTRL_PREG},
20198a1b82d7SSwapnil Jakhade 	{0x002B, SIERRA_CPI_TRIM_PREG},
20208a1b82d7SSwapnil Jakhade 	{0x0003, SIERRA_EPI_CTRL_PREG},
20218a1b82d7SSwapnil Jakhade 	{0x803F, SIERRA_SDFILT_H2L_A_PREG},
20228a1b82d7SSwapnil Jakhade 	{0x0004, SIERRA_RXBUFFER_CTLECTRL_PREG},
20238a1b82d7SSwapnil Jakhade 	{0x2010, SIERRA_RXBUFFER_RCDFECTRL_PREG},
20248a1b82d7SSwapnil Jakhade 	{0x4432, SIERRA_RXBUFFER_DFECTRL_PREG}
20258a1b82d7SSwapnil Jakhade };
20268a1b82d7SSwapnil Jakhade 
2027da41bac5SChristophe JAILLET static const struct cdns_sierra_vals pcie_100_ext_ssc_plllc_cmn_vals = {
20288a1b82d7SSwapnil Jakhade 	.reg_pairs = pcie_100_ext_ssc_plllc_cmn_regs,
20298a1b82d7SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(pcie_100_ext_ssc_plllc_cmn_regs),
20308a1b82d7SSwapnil Jakhade };
20318a1b82d7SSwapnil Jakhade 
2032da41bac5SChristophe JAILLET static const struct cdns_sierra_vals ml_pcie_100_ext_ssc_ln_vals = {
20338a1b82d7SSwapnil Jakhade 	.reg_pairs = ml_pcie_100_ext_ssc_ln_regs,
20348a1b82d7SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(ml_pcie_100_ext_ssc_ln_regs),
20358a1b82d7SSwapnil Jakhade };
20368a1b82d7SSwapnil Jakhade 
2037e72659b6SSwapnil Jakhade /*
2038e72659b6SSwapnil Jakhade  * TI J721E:
2039e72659b6SSwapnil Jakhade  * refclk100MHz_32b_PCIe_ln_ext_ssc, multilink, using_plllc,
2040e72659b6SSwapnil Jakhade  * cmn_pllcy_anaclk0_1Ghz, xcvr_pllclk_fullrt_500mhz
2041e72659b6SSwapnil Jakhade  */
2042e72659b6SSwapnil Jakhade static const struct cdns_reg_pairs ti_ml_pcie_100_ext_ssc_ln_regs[] = {
2043e72659b6SSwapnil Jakhade 	{0xFC08, SIERRA_DET_STANDEC_A_PREG},
2044e72659b6SSwapnil Jakhade 	{0x001D, SIERRA_PSM_A3IN_TMR_PREG},
2045e72659b6SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_A3_PREG},
2046e72659b6SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_A4_PREG},
2047e72659b6SSwapnil Jakhade 	{0x0004, SIERRA_PSC_LN_IDLE_PREG},
2048e72659b6SSwapnil Jakhade 	{0x1555, SIERRA_DFE_BIASTRIM_PREG},
2049e72659b6SSwapnil Jakhade 	{0x9703, SIERRA_DRVCTRL_BOOST_PREG},
2050e72659b6SSwapnil Jakhade 	{0x813E, SIERRA_CLKPATHCTRL_TMR_PREG},
2051e72659b6SSwapnil Jakhade 	{0x8047, SIERRA_RX_CREQ_FLTR_A_MODE3_PREG},
2052e72659b6SSwapnil Jakhade 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE2_PREG},
2053e72659b6SSwapnil Jakhade 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG},
2054e72659b6SSwapnil Jakhade 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
2055e72659b6SSwapnil Jakhade 	{0x0002, SIERRA_CREQ_DCBIASATTEN_OVR_PREG},
2056e72659b6SSwapnil Jakhade 	{0x9800, SIERRA_RX_CTLE_CAL_PREG},
2057e72659b6SSwapnil Jakhade 	{0x033C, SIERRA_RX_CTLE_MAINTENANCE_PREG},
2058e72659b6SSwapnil Jakhade 	{0x44CC, SIERRA_CREQ_EQ_OPEN_EYE_THRESH_PREG},
2059e72659b6SSwapnil Jakhade 	{0x5624, SIERRA_DEQ_CONCUR_CTRL2_PREG},
2060e72659b6SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_EPIPWR_CTRL2_PREG},
2061e72659b6SSwapnil Jakhade 	{0x00FF, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG},
2062e72659b6SSwapnil Jakhade 	{0x4C4C, SIERRA_DEQ_ERRCMP_CTRL_PREG},
2063e72659b6SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_OFFSET_CTRL_PREG},
2064e72659b6SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_GAIN_CTRL_PREG},
2065e72659b6SSwapnil Jakhade 	{0x0041, SIERRA_DEQ_GLUT0},
2066e72659b6SSwapnil Jakhade 	{0x0082, SIERRA_DEQ_GLUT1},
2067e72659b6SSwapnil Jakhade 	{0x00C3, SIERRA_DEQ_GLUT2},
2068e72659b6SSwapnil Jakhade 	{0x0145, SIERRA_DEQ_GLUT3},
2069e72659b6SSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT4},
2070e72659b6SSwapnil Jakhade 	{0x09E7, SIERRA_DEQ_ALUT0},
2071e72659b6SSwapnil Jakhade 	{0x09A6, SIERRA_DEQ_ALUT1},
2072e72659b6SSwapnil Jakhade 	{0x0965, SIERRA_DEQ_ALUT2},
2073e72659b6SSwapnil Jakhade 	{0x08E3, SIERRA_DEQ_ALUT3},
2074e72659b6SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP0},
2075e72659b6SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP1},
2076e72659b6SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP2},
2077e72659b6SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP3},
2078e72659b6SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP4},
2079e72659b6SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_PRECUR_PREG},
2080e72659b6SSwapnil Jakhade 	{0x0280, SIERRA_DEQ_POSTCUR_PREG},
2081e72659b6SSwapnil Jakhade 	{0x8F00, SIERRA_DEQ_POSTCUR_DECR_PREG},
2082e72659b6SSwapnil Jakhade 	{0x3C0F, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG},
2083e72659b6SSwapnil Jakhade 	{0x1C0C, SIERRA_DEQ_TAU_CTRL2_PREG},
2084e72659b6SSwapnil Jakhade 	{0x0100, SIERRA_DEQ_TAU_CTRL3_PREG},
2085e72659b6SSwapnil Jakhade 	{0x5E82, SIERRA_DEQ_OPENEYE_CTRL_PREG},
2086e72659b6SSwapnil Jakhade 	{0x002B, SIERRA_CPI_TRIM_PREG},
2087e72659b6SSwapnil Jakhade 	{0x0003, SIERRA_EPI_CTRL_PREG},
2088e72659b6SSwapnil Jakhade 	{0x803F, SIERRA_SDFILT_H2L_A_PREG},
2089e72659b6SSwapnil Jakhade 	{0x0004, SIERRA_RXBUFFER_CTLECTRL_PREG},
2090e72659b6SSwapnil Jakhade 	{0x2010, SIERRA_RXBUFFER_RCDFECTRL_PREG},
2091e72659b6SSwapnil Jakhade 	{0x4432, SIERRA_RXBUFFER_DFECTRL_PREG},
2092e72659b6SSwapnil Jakhade 	{0x0002, SIERRA_TX_RCVDET_OVRD_PREG}
2093e72659b6SSwapnil Jakhade };
2094e72659b6SSwapnil Jakhade 
2095da41bac5SChristophe JAILLET static const struct cdns_sierra_vals ti_ml_pcie_100_ext_ssc_ln_vals = {
2096e72659b6SSwapnil Jakhade 	.reg_pairs = ti_ml_pcie_100_ext_ssc_ln_regs,
2097e72659b6SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(ti_ml_pcie_100_ext_ssc_ln_regs),
2098e72659b6SSwapnil Jakhade };
2099e72659b6SSwapnil Jakhade 
21007a5ad9b4SSwapnil Jakhade /* refclk100MHz_32b_PCIe_cmn_pll_no_ssc */
21017a5ad9b4SSwapnil Jakhade static const struct cdns_reg_pairs cdns_pcie_cmn_regs_no_ssc[] = {
21027a5ad9b4SSwapnil Jakhade 	{0x2105, SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG},
21037a5ad9b4SSwapnil Jakhade 	{0x2105, SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG},
21047a5ad9b4SSwapnil Jakhade 	{0x8A06, SIERRA_CMN_PLLLC_BWCAL_MODE1_PREG},
21057a5ad9b4SSwapnil Jakhade 	{0x8A06, SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG}
21067a5ad9b4SSwapnil Jakhade };
21077a5ad9b4SSwapnil Jakhade 
21087a5ad9b4SSwapnil Jakhade /* refclk100MHz_32b_PCIe_ln_no_ssc */
21097a5ad9b4SSwapnil Jakhade static const struct cdns_reg_pairs cdns_pcie_ln_regs_no_ssc[] = {
21107a5ad9b4SSwapnil Jakhade 	{0xFC08, SIERRA_DET_STANDEC_A_PREG},
21117a5ad9b4SSwapnil Jakhade 	{0x001D, SIERRA_PSM_A3IN_TMR_PREG},
21127a5ad9b4SSwapnil Jakhade 	{0x1555, SIERRA_DFE_BIASTRIM_PREG},
21137a5ad9b4SSwapnil Jakhade 	{0x9703, SIERRA_DRVCTRL_BOOST_PREG},
21147a5ad9b4SSwapnil Jakhade 	{0x8055, SIERRA_RX_CREQ_FLTR_A_MODE3_PREG},
21157a5ad9b4SSwapnil Jakhade 	{0x80BB, SIERRA_RX_CREQ_FLTR_A_MODE2_PREG},
21167a5ad9b4SSwapnil Jakhade 	{0x8351, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG},
21177a5ad9b4SSwapnil Jakhade 	{0x8349, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
21187a5ad9b4SSwapnil Jakhade 	{0x0002, SIERRA_CREQ_DCBIASATTEN_OVR_PREG},
21197a5ad9b4SSwapnil Jakhade 	{0x9800, SIERRA_RX_CTLE_CAL_PREG},
21207a5ad9b4SSwapnil Jakhade 	{0x5624, SIERRA_DEQ_CONCUR_CTRL2_PREG},
21217a5ad9b4SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_EPIPWR_CTRL2_PREG},
21227a5ad9b4SSwapnil Jakhade 	{0x00FF, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG},
21237a5ad9b4SSwapnil Jakhade 	{0x4C4C, SIERRA_DEQ_ERRCMP_CTRL_PREG},
21247a5ad9b4SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_OFFSET_CTRL_PREG},
21257a5ad9b4SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_GAIN_CTRL_PREG},
21267a5ad9b4SSwapnil Jakhade 	{0x0041, SIERRA_DEQ_GLUT0},
21277a5ad9b4SSwapnil Jakhade 	{0x0082, SIERRA_DEQ_GLUT1},
21287a5ad9b4SSwapnil Jakhade 	{0x00C3, SIERRA_DEQ_GLUT2},
21297a5ad9b4SSwapnil Jakhade 	{0x0145, SIERRA_DEQ_GLUT3},
21307a5ad9b4SSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT4},
21317a5ad9b4SSwapnil Jakhade 	{0x09E7, SIERRA_DEQ_ALUT0},
21327a5ad9b4SSwapnil Jakhade 	{0x09A6, SIERRA_DEQ_ALUT1},
21337a5ad9b4SSwapnil Jakhade 	{0x0965, SIERRA_DEQ_ALUT2},
21347a5ad9b4SSwapnil Jakhade 	{0x08E3, SIERRA_DEQ_ALUT3},
21357a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP0},
21367a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP1},
21377a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP2},
21387a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP3},
21397a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP4},
21407a5ad9b4SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_PRECUR_PREG},
21417a5ad9b4SSwapnil Jakhade 	{0x0280, SIERRA_DEQ_POSTCUR_PREG},
21427a5ad9b4SSwapnil Jakhade 	{0x8F00, SIERRA_DEQ_POSTCUR_DECR_PREG},
21437a5ad9b4SSwapnil Jakhade 	{0x3C0F, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG},
21447a5ad9b4SSwapnil Jakhade 	{0x1C0C, SIERRA_DEQ_TAU_CTRL2_PREG},
21457a5ad9b4SSwapnil Jakhade 	{0x0100, SIERRA_DEQ_TAU_CTRL3_PREG},
21467a5ad9b4SSwapnil Jakhade 	{0x5E82, SIERRA_DEQ_OPENEYE_CTRL_PREG},
21477a5ad9b4SSwapnil Jakhade 	{0x002B, SIERRA_CPI_TRIM_PREG},
21487a5ad9b4SSwapnil Jakhade 	{0x0003, SIERRA_EPI_CTRL_PREG},
21497a5ad9b4SSwapnil Jakhade 	{0x803F, SIERRA_SDFILT_H2L_A_PREG},
21507a5ad9b4SSwapnil Jakhade 	{0x0004, SIERRA_RXBUFFER_CTLECTRL_PREG},
21517a5ad9b4SSwapnil Jakhade 	{0x2010, SIERRA_RXBUFFER_RCDFECTRL_PREG},
21527a5ad9b4SSwapnil Jakhade 	{0x4432, SIERRA_RXBUFFER_DFECTRL_PREG}
21537a5ad9b4SSwapnil Jakhade };
21547a5ad9b4SSwapnil Jakhade 
2155da41bac5SChristophe JAILLET static const struct cdns_sierra_vals pcie_100_no_ssc_cmn_vals = {
21567a5ad9b4SSwapnil Jakhade 	.reg_pairs = cdns_pcie_cmn_regs_no_ssc,
21577a5ad9b4SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(cdns_pcie_cmn_regs_no_ssc),
21587a5ad9b4SSwapnil Jakhade };
21597a5ad9b4SSwapnil Jakhade 
2160da41bac5SChristophe JAILLET static const struct cdns_sierra_vals pcie_100_no_ssc_ln_vals = {
21617a5ad9b4SSwapnil Jakhade 	.reg_pairs = cdns_pcie_ln_regs_no_ssc,
21627a5ad9b4SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(cdns_pcie_ln_regs_no_ssc),
21637a5ad9b4SSwapnil Jakhade };
21647a5ad9b4SSwapnil Jakhade 
21657a5ad9b4SSwapnil Jakhade /* refclk100MHz_32b_PCIe_cmn_pll_int_ssc */
21667a5ad9b4SSwapnil Jakhade static const struct cdns_reg_pairs cdns_pcie_cmn_regs_int_ssc[] = {
21677a5ad9b4SSwapnil Jakhade 	{0x000E, SIERRA_CMN_PLLLC_MODE_PREG},
21687a5ad9b4SSwapnil Jakhade 	{0x4006, SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG},
21697a5ad9b4SSwapnil Jakhade 	{0x4006, SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG},
21707a5ad9b4SSwapnil Jakhade 	{0x0000, SIERRA_CMN_PLLLC_BWCAL_MODE1_PREG},
21717a5ad9b4SSwapnil Jakhade 	{0x0000, SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG},
21727a5ad9b4SSwapnil Jakhade 	{0x0581, SIERRA_CMN_PLLLC_DSMCORR_PREG},
21737a5ad9b4SSwapnil Jakhade 	{0x7F80, SIERRA_CMN_PLLLC_SS_PREG},
21747a5ad9b4SSwapnil Jakhade 	{0x0041, SIERRA_CMN_PLLLC_SS_AMP_STEP_SIZE_PREG},
21757a5ad9b4SSwapnil Jakhade 	{0x0464, SIERRA_CMN_PLLLC_SSTWOPT_PREG},
21767a5ad9b4SSwapnil Jakhade 	{0x0D0D, SIERRA_CMN_PLLLC_SS_TIME_STEPSIZE_MODE_PREG},
21777a5ad9b4SSwapnil Jakhade 	{0x0060, SIERRA_CMN_PLLLC_LOCK_DELAY_CTRL_PREG}
21787a5ad9b4SSwapnil Jakhade };
21797a5ad9b4SSwapnil Jakhade 
21807a5ad9b4SSwapnil Jakhade /* refclk100MHz_32b_PCIe_ln_int_ssc */
21817a5ad9b4SSwapnil Jakhade static const struct cdns_reg_pairs cdns_pcie_ln_regs_int_ssc[] = {
21827a5ad9b4SSwapnil Jakhade 	{0xFC08, SIERRA_DET_STANDEC_A_PREG},
21837a5ad9b4SSwapnil Jakhade 	{0x001D, SIERRA_PSM_A3IN_TMR_PREG},
21847a5ad9b4SSwapnil Jakhade 	{0x1555, SIERRA_DFE_BIASTRIM_PREG},
21857a5ad9b4SSwapnil Jakhade 	{0x9703, SIERRA_DRVCTRL_BOOST_PREG},
21867a5ad9b4SSwapnil Jakhade 	{0x813E, SIERRA_CLKPATHCTRL_TMR_PREG},
21877a5ad9b4SSwapnil Jakhade 	{0x8047, SIERRA_RX_CREQ_FLTR_A_MODE3_PREG},
21887a5ad9b4SSwapnil Jakhade 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE2_PREG},
21897a5ad9b4SSwapnil Jakhade 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG},
21907a5ad9b4SSwapnil Jakhade 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
21917a5ad9b4SSwapnil Jakhade 	{0x0002, SIERRA_CREQ_DCBIASATTEN_OVR_PREG},
21927a5ad9b4SSwapnil Jakhade 	{0x9800, SIERRA_RX_CTLE_CAL_PREG},
21937a5ad9b4SSwapnil Jakhade 	{0x033C, SIERRA_RX_CTLE_MAINTENANCE_PREG},
21947a5ad9b4SSwapnil Jakhade 	{0x44CC, SIERRA_CREQ_EQ_OPEN_EYE_THRESH_PREG},
21957a5ad9b4SSwapnil Jakhade 	{0x5624, SIERRA_DEQ_CONCUR_CTRL2_PREG},
21967a5ad9b4SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_EPIPWR_CTRL2_PREG},
21977a5ad9b4SSwapnil Jakhade 	{0x00FF, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG},
21987a5ad9b4SSwapnil Jakhade 	{0x4C4C, SIERRA_DEQ_ERRCMP_CTRL_PREG},
21997a5ad9b4SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_OFFSET_CTRL_PREG},
22007a5ad9b4SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_GAIN_CTRL_PREG},
22017a5ad9b4SSwapnil Jakhade 	{0x0041, SIERRA_DEQ_GLUT0},
22027a5ad9b4SSwapnil Jakhade 	{0x0082, SIERRA_DEQ_GLUT1},
22037a5ad9b4SSwapnil Jakhade 	{0x00C3, SIERRA_DEQ_GLUT2},
22047a5ad9b4SSwapnil Jakhade 	{0x0145, SIERRA_DEQ_GLUT3},
22057a5ad9b4SSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT4},
22067a5ad9b4SSwapnil Jakhade 	{0x09E7, SIERRA_DEQ_ALUT0},
22077a5ad9b4SSwapnil Jakhade 	{0x09A6, SIERRA_DEQ_ALUT1},
22087a5ad9b4SSwapnil Jakhade 	{0x0965, SIERRA_DEQ_ALUT2},
22097a5ad9b4SSwapnil Jakhade 	{0x08E3, SIERRA_DEQ_ALUT3},
22107a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP0},
22117a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP1},
22127a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP2},
22137a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP3},
22147a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP4},
22157a5ad9b4SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_PRECUR_PREG},
22167a5ad9b4SSwapnil Jakhade 	{0x0280, SIERRA_DEQ_POSTCUR_PREG},
22177a5ad9b4SSwapnil Jakhade 	{0x8F00, SIERRA_DEQ_POSTCUR_DECR_PREG},
22187a5ad9b4SSwapnil Jakhade 	{0x3C0F, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG},
22197a5ad9b4SSwapnil Jakhade 	{0x1C0C, SIERRA_DEQ_TAU_CTRL2_PREG},
22207a5ad9b4SSwapnil Jakhade 	{0x0100, SIERRA_DEQ_TAU_CTRL3_PREG},
22217a5ad9b4SSwapnil Jakhade 	{0x5E82, SIERRA_DEQ_OPENEYE_CTRL_PREG},
22227a5ad9b4SSwapnil Jakhade 	{0x002B, SIERRA_CPI_TRIM_PREG},
22237a5ad9b4SSwapnil Jakhade 	{0x0003, SIERRA_EPI_CTRL_PREG},
22247a5ad9b4SSwapnil Jakhade 	{0x803F, SIERRA_SDFILT_H2L_A_PREG},
22257a5ad9b4SSwapnil Jakhade 	{0x0004, SIERRA_RXBUFFER_CTLECTRL_PREG},
22267a5ad9b4SSwapnil Jakhade 	{0x2010, SIERRA_RXBUFFER_RCDFECTRL_PREG},
22277a5ad9b4SSwapnil Jakhade 	{0x4432, SIERRA_RXBUFFER_DFECTRL_PREG}
22287a5ad9b4SSwapnil Jakhade };
22297a5ad9b4SSwapnil Jakhade 
2230da41bac5SChristophe JAILLET static const struct cdns_sierra_vals pcie_100_int_ssc_cmn_vals = {
22317a5ad9b4SSwapnil Jakhade 	.reg_pairs = cdns_pcie_cmn_regs_int_ssc,
22327a5ad9b4SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(cdns_pcie_cmn_regs_int_ssc),
22337a5ad9b4SSwapnil Jakhade };
22347a5ad9b4SSwapnil Jakhade 
2235da41bac5SChristophe JAILLET static const struct cdns_sierra_vals pcie_100_int_ssc_ln_vals = {
22367a5ad9b4SSwapnil Jakhade 	.reg_pairs = cdns_pcie_ln_regs_int_ssc,
22377a5ad9b4SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(cdns_pcie_ln_regs_int_ssc),
22387a5ad9b4SSwapnil Jakhade };
22397a5ad9b4SSwapnil Jakhade 
2240871002d7SAnil Varughese /* refclk100MHz_32b_PCIe_cmn_pll_ext_ssc */
22413cfb0e8eSRikard Falkeborn static const struct cdns_reg_pairs cdns_pcie_cmn_regs_ext_ssc[] = {
2242871002d7SAnil Varughese 	{0x2106, SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG},
2243871002d7SAnil Varughese 	{0x2106, SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG},
2244871002d7SAnil Varughese 	{0x8A06, SIERRA_CMN_PLLLC_BWCAL_MODE1_PREG},
2245871002d7SAnil Varughese 	{0x8A06, SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG},
2246871002d7SAnil Varughese 	{0x1B1B, SIERRA_CMN_PLLLC_SS_TIME_STEPSIZE_MODE_PREG}
2247871002d7SAnil Varughese };
2248871002d7SAnil Varughese 
2249871002d7SAnil Varughese /* refclk100MHz_32b_PCIe_ln_ext_ssc */
22503cfb0e8eSRikard Falkeborn static const struct cdns_reg_pairs cdns_pcie_ln_regs_ext_ssc[] = {
22517a5ad9b4SSwapnil Jakhade 	{0xFC08, SIERRA_DET_STANDEC_A_PREG},
22527a5ad9b4SSwapnil Jakhade 	{0x001D, SIERRA_PSM_A3IN_TMR_PREG},
22537a5ad9b4SSwapnil Jakhade 	{0x1555, SIERRA_DFE_BIASTRIM_PREG},
22547a5ad9b4SSwapnil Jakhade 	{0x9703, SIERRA_DRVCTRL_BOOST_PREG},
2255871002d7SAnil Varughese 	{0x813E, SIERRA_CLKPATHCTRL_TMR_PREG},
2256871002d7SAnil Varughese 	{0x8047, SIERRA_RX_CREQ_FLTR_A_MODE3_PREG},
2257871002d7SAnil Varughese 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE2_PREG},
2258871002d7SAnil Varughese 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG},
2259871002d7SAnil Varughese 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
22607a5ad9b4SSwapnil Jakhade 	{0x0002, SIERRA_CREQ_DCBIASATTEN_OVR_PREG},
22617a5ad9b4SSwapnil Jakhade 	{0x9800, SIERRA_RX_CTLE_CAL_PREG},
2262871002d7SAnil Varughese 	{0x033C, SIERRA_RX_CTLE_MAINTENANCE_PREG},
22637a5ad9b4SSwapnil Jakhade 	{0x44CC, SIERRA_CREQ_EQ_OPEN_EYE_THRESH_PREG},
22647a5ad9b4SSwapnil Jakhade 	{0x5624, SIERRA_DEQ_CONCUR_CTRL2_PREG},
22657a5ad9b4SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_EPIPWR_CTRL2_PREG},
22667a5ad9b4SSwapnil Jakhade 	{0x00FF, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG},
22677a5ad9b4SSwapnil Jakhade 	{0x4C4C, SIERRA_DEQ_ERRCMP_CTRL_PREG},
22687a5ad9b4SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_OFFSET_CTRL_PREG},
22697a5ad9b4SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_GAIN_CTRL_PREG},
22707a5ad9b4SSwapnil Jakhade 	{0x0041, SIERRA_DEQ_GLUT0},
22717a5ad9b4SSwapnil Jakhade 	{0x0082, SIERRA_DEQ_GLUT1},
22727a5ad9b4SSwapnil Jakhade 	{0x00C3, SIERRA_DEQ_GLUT2},
22737a5ad9b4SSwapnil Jakhade 	{0x0145, SIERRA_DEQ_GLUT3},
22747a5ad9b4SSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT4},
22757a5ad9b4SSwapnil Jakhade 	{0x09E7, SIERRA_DEQ_ALUT0},
22767a5ad9b4SSwapnil Jakhade 	{0x09A6, SIERRA_DEQ_ALUT1},
22777a5ad9b4SSwapnil Jakhade 	{0x0965, SIERRA_DEQ_ALUT2},
22787a5ad9b4SSwapnil Jakhade 	{0x08E3, SIERRA_DEQ_ALUT3},
22797a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP0},
22807a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP1},
22817a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP2},
22827a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP3},
22837a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP4},
22847a5ad9b4SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_PRECUR_PREG},
22857a5ad9b4SSwapnil Jakhade 	{0x0280, SIERRA_DEQ_POSTCUR_PREG},
22867a5ad9b4SSwapnil Jakhade 	{0x8F00, SIERRA_DEQ_POSTCUR_DECR_PREG},
22877a5ad9b4SSwapnil Jakhade 	{0x3C0F, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG},
22887a5ad9b4SSwapnil Jakhade 	{0x1C0C, SIERRA_DEQ_TAU_CTRL2_PREG},
22897a5ad9b4SSwapnil Jakhade 	{0x0100, SIERRA_DEQ_TAU_CTRL3_PREG},
22907a5ad9b4SSwapnil Jakhade 	{0x5E82, SIERRA_DEQ_OPENEYE_CTRL_PREG},
22917a5ad9b4SSwapnil Jakhade 	{0x002B, SIERRA_CPI_TRIM_PREG},
22927a5ad9b4SSwapnil Jakhade 	{0x0003, SIERRA_EPI_CTRL_PREG},
22937a5ad9b4SSwapnil Jakhade 	{0x803F, SIERRA_SDFILT_H2L_A_PREG},
22947a5ad9b4SSwapnil Jakhade 	{0x0004, SIERRA_RXBUFFER_CTLECTRL_PREG},
22957a5ad9b4SSwapnil Jakhade 	{0x2010, SIERRA_RXBUFFER_RCDFECTRL_PREG},
22967a5ad9b4SSwapnil Jakhade 	{0x4432, SIERRA_RXBUFFER_DFECTRL_PREG}
2297871002d7SAnil Varughese };
2298871002d7SAnil Varughese 
2299da41bac5SChristophe JAILLET static const struct cdns_sierra_vals pcie_100_ext_ssc_cmn_vals = {
2300078e9e92SSwapnil Jakhade 	.reg_pairs = cdns_pcie_cmn_regs_ext_ssc,
2301078e9e92SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(cdns_pcie_cmn_regs_ext_ssc),
2302078e9e92SSwapnil Jakhade };
2303078e9e92SSwapnil Jakhade 
2304da41bac5SChristophe JAILLET static const struct cdns_sierra_vals pcie_100_ext_ssc_ln_vals = {
2305078e9e92SSwapnil Jakhade 	.reg_pairs = cdns_pcie_ln_regs_ext_ssc,
2306078e9e92SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(cdns_pcie_ln_regs_ext_ssc),
2307078e9e92SSwapnil Jakhade };
2308078e9e92SSwapnil Jakhade 
2309871002d7SAnil Varughese /* refclk100MHz_20b_USB_cmn_pll_ext_ssc */
23103cfb0e8eSRikard Falkeborn static const struct cdns_reg_pairs cdns_usb_cmn_regs_ext_ssc[] = {
2311871002d7SAnil Varughese 	{0x2085, SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG},
2312871002d7SAnil Varughese 	{0x2085, SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG},
2313871002d7SAnil Varughese 	{0x0000, SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG},
2314871002d7SAnil Varughese 	{0x0000, SIERRA_CMN_PLLLC_SS_TIME_STEPSIZE_MODE_PREG}
2315871002d7SAnil Varughese };
2316871002d7SAnil Varughese 
2317871002d7SAnil Varughese /* refclk100MHz_20b_USB_ln_ext_ssc */
23183cfb0e8eSRikard Falkeborn static const struct cdns_reg_pairs cdns_usb_ln_regs_ext_ssc[] = {
2319aead5fd6SKishon Vijay Abraham I 	{0xFE0A, SIERRA_DET_STANDEC_A_PREG},
2320aead5fd6SKishon Vijay Abraham I 	{0x000F, SIERRA_DET_STANDEC_B_PREG},
23212bcf14caSSanket Parmar 	{0x55A5, SIERRA_DET_STANDEC_C_PREG},
2322871002d7SAnil Varughese 	{0x69ad, SIERRA_DET_STANDEC_D_PREG},
2323aead5fd6SKishon Vijay Abraham I 	{0x0241, SIERRA_DET_STANDEC_E_PREG},
23242bcf14caSSanket Parmar 	{0x0110, SIERRA_PSM_LANECAL_DLY_A1_RESETS_PREG},
2325871002d7SAnil Varughese 	{0x0014, SIERRA_PSM_A0IN_TMR_PREG},
2326aead5fd6SKishon Vijay Abraham I 	{0xCF00, SIERRA_PSM_DIAG_PREG},
2327aead5fd6SKishon Vijay Abraham I 	{0x001F, SIERRA_PSC_TX_A0_PREG},
2328aead5fd6SKishon Vijay Abraham I 	{0x0007, SIERRA_PSC_TX_A1_PREG},
2329aead5fd6SKishon Vijay Abraham I 	{0x0003, SIERRA_PSC_TX_A2_PREG},
2330aead5fd6SKishon Vijay Abraham I 	{0x0003, SIERRA_PSC_TX_A3_PREG},
2331aead5fd6SKishon Vijay Abraham I 	{0x0FFF, SIERRA_PSC_RX_A0_PREG},
23322bcf14caSSanket Parmar 	{0x0003, SIERRA_PSC_RX_A1_PREG},
2333aead5fd6SKishon Vijay Abraham I 	{0x0003, SIERRA_PSC_RX_A2_PREG},
2334aead5fd6SKishon Vijay Abraham I 	{0x0001, SIERRA_PSC_RX_A3_PREG},
2335aead5fd6SKishon Vijay Abraham I 	{0x0001, SIERRA_PLLCTRL_SUBRATE_PREG},
2336aead5fd6SKishon Vijay Abraham I 	{0x0406, SIERRA_PLLCTRL_GEN_D_PREG},
2337871002d7SAnil Varughese 	{0x5233, SIERRA_PLLCTRL_CPGAIN_MODE_PREG},
2338871002d7SAnil Varughese 	{0x00CA, SIERRA_CLKPATH_BIASTRIM_PREG},
2339871002d7SAnil Varughese 	{0x2512, SIERRA_DFE_BIASTRIM_PREG},
2340aead5fd6SKishon Vijay Abraham I 	{0x0000, SIERRA_DRVCTRL_ATTEN_PREG},
23412bcf14caSSanket Parmar 	{0x823E, SIERRA_CLKPATHCTRL_TMR_PREG},
23422bcf14caSSanket Parmar 	{0x078F, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG},
23432bcf14caSSanket Parmar 	{0x078F, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
2344aead5fd6SKishon Vijay Abraham I 	{0x7B3C, SIERRA_CREQ_CCLKDET_MODE01_PREG},
23452bcf14caSSanket Parmar 	{0x023C, SIERRA_RX_CTLE_MAINTENANCE_PREG},
2346aead5fd6SKishon Vijay Abraham I 	{0x3232, SIERRA_CREQ_FSMCLK_SEL_PREG},
2347871002d7SAnil Varughese 	{0x0000, SIERRA_CREQ_EQ_CTRL_PREG},
23482bcf14caSSanket Parmar 	{0x0000, SIERRA_CREQ_SPARE_PREG},
2349871002d7SAnil Varughese 	{0xCC44, SIERRA_CREQ_EQ_OPEN_EYE_THRESH_PREG},
23502bcf14caSSanket Parmar 	{0x8452, SIERRA_CTLELUT_CTRL_PREG},
23512bcf14caSSanket Parmar 	{0x4121, SIERRA_DFE_ECMP_RATESEL_PREG},
23522bcf14caSSanket Parmar 	{0x4121, SIERRA_DFE_SMP_RATESEL_PREG},
23532bcf14caSSanket Parmar 	{0x0003, SIERRA_DEQ_PHALIGN_CTRL},
2354871002d7SAnil Varughese 	{0x3200, SIERRA_DEQ_CONCUR_CTRL1_PREG},
2355871002d7SAnil Varughese 	{0x5064, SIERRA_DEQ_CONCUR_CTRL2_PREG},
2356871002d7SAnil Varughese 	{0x0030, SIERRA_DEQ_EPIPWR_CTRL2_PREG},
2357871002d7SAnil Varughese 	{0x0048, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG},
2358871002d7SAnil Varughese 	{0x5A5A, SIERRA_DEQ_ERRCMP_CTRL_PREG},
2359871002d7SAnil Varughese 	{0x02F5, SIERRA_DEQ_OFFSET_CTRL_PREG},
2360871002d7SAnil Varughese 	{0x02F5, SIERRA_DEQ_GAIN_CTRL_PREG},
23612bcf14caSSanket Parmar 	{0x9999, SIERRA_DEQ_VGATUNE_CTRL_PREG},
2362871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT0},
2363871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT1},
2364871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT2},
2365871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT3},
2366871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT4},
2367871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT5},
2368871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT6},
2369871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT7},
2370871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT8},
2371871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT9},
2372871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT10},
2373871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT11},
2374871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT12},
2375871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT13},
2376871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT14},
2377871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT15},
2378871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT16},
2379871002d7SAnil Varughese 	{0x0BAE, SIERRA_DEQ_ALUT0},
2380871002d7SAnil Varughese 	{0x0AEB, SIERRA_DEQ_ALUT1},
2381871002d7SAnil Varughese 	{0x0A28, SIERRA_DEQ_ALUT2},
2382871002d7SAnil Varughese 	{0x0965, SIERRA_DEQ_ALUT3},
2383871002d7SAnil Varughese 	{0x08A2, SIERRA_DEQ_ALUT4},
2384871002d7SAnil Varughese 	{0x07DF, SIERRA_DEQ_ALUT5},
2385871002d7SAnil Varughese 	{0x071C, SIERRA_DEQ_ALUT6},
2386871002d7SAnil Varughese 	{0x0659, SIERRA_DEQ_ALUT7},
2387871002d7SAnil Varughese 	{0x0596, SIERRA_DEQ_ALUT8},
2388871002d7SAnil Varughese 	{0x0514, SIERRA_DEQ_ALUT9},
2389871002d7SAnil Varughese 	{0x0492, SIERRA_DEQ_ALUT10},
2390871002d7SAnil Varughese 	{0x0410, SIERRA_DEQ_ALUT11},
2391871002d7SAnil Varughese 	{0x038E, SIERRA_DEQ_ALUT12},
2392871002d7SAnil Varughese 	{0x030C, SIERRA_DEQ_ALUT13},
2393871002d7SAnil Varughese 	{0x03F4, SIERRA_DEQ_DFETAP_CTRL_PREG},
2394871002d7SAnil Varughese 	{0x0001, SIERRA_DFE_EN_1010_IGNORE_PREG},
2395871002d7SAnil Varughese 	{0x3C01, SIERRA_DEQ_TAU_CTRL1_FAST_MAINT_PREG},
2396871002d7SAnil Varughese 	{0x3C40, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG},
2397871002d7SAnil Varughese 	{0x1C08, SIERRA_DEQ_TAU_CTRL2_PREG},
2398871002d7SAnil Varughese 	{0x0033, SIERRA_DEQ_PICTRL_PREG},
2399871002d7SAnil Varughese 	{0x0400, SIERRA_CPICAL_TMRVAL_MODE1_PREG},
2400871002d7SAnil Varughese 	{0x0330, SIERRA_CPICAL_TMRVAL_MODE0_PREG},
2401871002d7SAnil Varughese 	{0x01FF, SIERRA_CPICAL_PICNT_MODE1_PREG},
2402aead5fd6SKishon Vijay Abraham I 	{0x0009, SIERRA_CPI_OUTBUF_RATESEL_PREG},
2403871002d7SAnil Varughese 	{0x3232, SIERRA_CPICAL_RES_STARTCODE_MODE23_PREG},
2404871002d7SAnil Varughese 	{0x0005, SIERRA_LFPSDET_SUPPORT_PREG},
2405aead5fd6SKishon Vijay Abraham I 	{0x000F, SIERRA_LFPSFILT_NS_PREG},
2406aead5fd6SKishon Vijay Abraham I 	{0x0009, SIERRA_LFPSFILT_RD_PREG},
2407aead5fd6SKishon Vijay Abraham I 	{0x0001, SIERRA_LFPSFILT_MP_PREG},
24082bcf14caSSanket Parmar 	{0x6013, SIERRA_SIGDET_SUPPORT_PREG},
2409aead5fd6SKishon Vijay Abraham I 	{0x8013, SIERRA_SDFILT_H2L_A_PREG},
2410871002d7SAnil Varughese 	{0x8009, SIERRA_SDFILT_L2H_PREG},
2411871002d7SAnil Varughese 	{0x0024, SIERRA_RXBUFFER_CTLECTRL_PREG},
2412871002d7SAnil Varughese 	{0x0020, SIERRA_RXBUFFER_RCDFECTRL_PREG},
2413871002d7SAnil Varughese 	{0x4243, SIERRA_RXBUFFER_DFECTRL_PREG}
241444d30d62SAlan Douglas };
241544d30d62SAlan Douglas 
2416da41bac5SChristophe JAILLET static const struct cdns_sierra_vals usb_100_ext_ssc_cmn_vals = {
2417078e9e92SSwapnil Jakhade 	.reg_pairs = cdns_usb_cmn_regs_ext_ssc,
2418078e9e92SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(cdns_usb_cmn_regs_ext_ssc),
2419078e9e92SSwapnil Jakhade };
2420078e9e92SSwapnil Jakhade 
2421da41bac5SChristophe JAILLET static const struct cdns_sierra_vals usb_100_ext_ssc_ln_vals = {
2422078e9e92SSwapnil Jakhade 	.reg_pairs = cdns_usb_ln_regs_ext_ssc,
2423078e9e92SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(cdns_usb_ln_regs_ext_ssc),
2424078e9e92SSwapnil Jakhade };
2425078e9e92SSwapnil Jakhade 
2426a1d12987SMarcin Wierzbicki /* SGMII PHY common configuration */
2427a1d12987SMarcin Wierzbicki static const struct cdns_reg_pairs sgmii_pma_cmn_vals[] = {
2428a1d12987SMarcin Wierzbicki 	{0x0180, SIERRA_SDOSCCAL_CLK_CNT_PREG},
2429a1d12987SMarcin Wierzbicki 	{0x6000, SIERRA_CMN_REFRCV_PREG},
2430a1d12987SMarcin Wierzbicki 	{0x0031, SIERRA_CMN_RESCAL_CTRLA_PREG},
2431a1d12987SMarcin Wierzbicki 	{0x001C, SIERRA_CMN_PLLLC_FBDIV_INT_MODE0_PREG},
2432a1d12987SMarcin Wierzbicki 	{0x2106, SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG},
2433a1d12987SMarcin Wierzbicki 	{0x0000, SIERRA_CMN_PLLLC_LOCKSEARCH_PREG},
2434a1d12987SMarcin Wierzbicki 	{0x8103, SIERRA_CMN_PLLLC_CLK0_PREG},
2435a1d12987SMarcin Wierzbicki 	{0x0000, SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG},
2436a1d12987SMarcin Wierzbicki 	{0x0027, SIERRA_CMN_PLLCSM_PLLEN_TMR_PREG},
2437a1d12987SMarcin Wierzbicki 	{0x0062, SIERRA_CMN_PLLCSM_PLLPRE_TMR_PREG},
2438a1d12987SMarcin Wierzbicki 	{0x0800, SIERRA_CMN_PLLLC_SS_TIME_STEPSIZE_MODE_PREG},
2439a1d12987SMarcin Wierzbicki 	{0x0000, SIERRA_CMN_PLLLC_INIT_PREG},
2440a1d12987SMarcin Wierzbicki 	{0x0000, SIERRA_CMN_PLLLC_ITERTMR_PREG},
2441a1d12987SMarcin Wierzbicki 	{0x0020, SIERRA_CMN_PLLLC_LOCK_CNTSTART_PREG},
2442a1d12987SMarcin Wierzbicki 	{0x0013, SIERRA_CMN_PLLLC_DCOCAL_CTRL_PREG},
2443a1d12987SMarcin Wierzbicki 	{0x0013, SIERRA_CMN_PLLLC1_DCOCAL_CTRL_PREG},
2444a1d12987SMarcin Wierzbicki };
2445a1d12987SMarcin Wierzbicki 
2446da41bac5SChristophe JAILLET static const struct cdns_sierra_vals sgmii_cmn_vals = {
2447a1d12987SMarcin Wierzbicki 	.reg_pairs = sgmii_pma_cmn_vals,
2448a1d12987SMarcin Wierzbicki 	.num_regs = ARRAY_SIZE(sgmii_pma_cmn_vals),
2449a1d12987SMarcin Wierzbicki };
2450a1d12987SMarcin Wierzbicki 
2451a1d12987SMarcin Wierzbicki /* SGMII PHY lane configuration */
2452a1d12987SMarcin Wierzbicki static const struct cdns_reg_pairs sgmii_ln_regs[] = {
2453a1d12987SMarcin Wierzbicki 	{0x691E, SIERRA_DET_STANDEC_D_PREG},
2454a1d12987SMarcin Wierzbicki 	{0x0FFE, SIERRA_PSC_RX_A0_PREG},
2455a1d12987SMarcin Wierzbicki 	{0x0104, SIERRA_PLLCTRL_FBDIV_MODE01_PREG},
2456a1d12987SMarcin Wierzbicki 	{0x0013, SIERRA_PLLCTRL_SUBRATE_PREG},
2457a1d12987SMarcin Wierzbicki 	{0x0106, SIERRA_PLLCTRL_GEN_D_PREG},
2458a1d12987SMarcin Wierzbicki 	{0x5234, SIERRA_PLLCTRL_CPGAIN_MODE_PREG},
2459a1d12987SMarcin Wierzbicki 	{0x0000, SIERRA_DRVCTRL_ATTEN_PREG},
2460a1d12987SMarcin Wierzbicki 	{0x00AB, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
2461a1d12987SMarcin Wierzbicki 	{0x3C0E, SIERRA_CREQ_CCLKDET_MODE01_PREG},
2462a1d12987SMarcin Wierzbicki 	{0x3220, SIERRA_CREQ_FSMCLK_SEL_PREG},
2463a1d12987SMarcin Wierzbicki 	{0x0000, SIERRA_CREQ_EQ_CTRL_PREG},
2464a1d12987SMarcin Wierzbicki 	{0x6320, SIERRA_DEQ_CONCUR_EPIOFFSET_MODE_PREG},
2465a1d12987SMarcin Wierzbicki 	{0x0000, SIERRA_CPI_OUTBUF_RATESEL_PREG},
2466a1d12987SMarcin Wierzbicki 	{0x15A2, SIERRA_LN_SPARE_REG_PREG},
2467a1d12987SMarcin Wierzbicki 	{0x7900, SIERRA_DEQ_BLK_TAU_CTRL1_PREG},
2468a1d12987SMarcin Wierzbicki 	{0x2202, SIERRA_DEQ_BLK_TAU_CTRL4_PREG},
2469a1d12987SMarcin Wierzbicki 	{0x2206, SIERRA_DEQ_TAU_CTRL2_PREG},
2470a1d12987SMarcin Wierzbicki 	{0x0005, SIERRA_LANE_TX_RECEIVER_DETECT_PREG},
2471a1d12987SMarcin Wierzbicki 	{0x8001, SIERRA_CREQ_SPARE_PREG},
2472a1d12987SMarcin Wierzbicki 	{0x0000, SIERRA_DEQ_CONCUR_CTRL1_PREG},
2473a1d12987SMarcin Wierzbicki 	{0xD004, SIERRA_DEQ_CONCUR_CTRL2_PREG},
2474a1d12987SMarcin Wierzbicki 	{0x0101, SIERRA_DEQ_GLUT9},
2475a1d12987SMarcin Wierzbicki 	{0x0101, SIERRA_DEQ_GLUT10},
2476a1d12987SMarcin Wierzbicki 	{0x0101, SIERRA_DEQ_GLUT11},
2477a1d12987SMarcin Wierzbicki 	{0x0101, SIERRA_DEQ_GLUT12},
2478a1d12987SMarcin Wierzbicki 	{0x0000, SIERRA_DEQ_GLUT13},
2479a1d12987SMarcin Wierzbicki 	{0x0000, SIERRA_DEQ_GLUT16},
2480a1d12987SMarcin Wierzbicki 	{0x0000, SIERRA_POSTPRECUR_EN_CEPH_CTRL_PREG},
2481a1d12987SMarcin Wierzbicki 	{0x0000, SIERRA_TAU_EN_CEPH2TO0_PREG},
2482a1d12987SMarcin Wierzbicki 	{0x0003, SIERRA_TAU_EN_CEPH5TO3_PREG},
2483a1d12987SMarcin Wierzbicki 	{0x0101, SIERRA_DEQ_ALUT8},
2484a1d12987SMarcin Wierzbicki 	{0x0101, SIERRA_DEQ_ALUT9},
2485a1d12987SMarcin Wierzbicki 	{0x0100, SIERRA_DEQ_ALUT10},
2486a1d12987SMarcin Wierzbicki 	{0x0000, SIERRA_OEPH_EN_CTRL_PREG},
2487a1d12987SMarcin Wierzbicki 	{0x5425, SIERRA_DEQ_OPENEYE_CTRL_PREG},
2488a1d12987SMarcin Wierzbicki 	{0x7458, SIERRA_CPICAL_RES_STARTCODE_MODE23_PREG},
2489a1d12987SMarcin Wierzbicki 	{0x321F, SIERRA_CPICAL_RES_STARTCODE_MODE01_PREG},
2490a1d12987SMarcin Wierzbicki };
2491a1d12987SMarcin Wierzbicki 
2492da41bac5SChristophe JAILLET static const struct cdns_sierra_vals sgmii_pma_ln_vals = {
2493a1d12987SMarcin Wierzbicki 	.reg_pairs = sgmii_ln_regs,
2494a1d12987SMarcin Wierzbicki 	.num_regs = ARRAY_SIZE(sgmii_ln_regs),
2495a1d12987SMarcin Wierzbicki };
2496a1d12987SMarcin Wierzbicki 
249744d30d62SAlan Douglas static const struct cdns_sierra_data cdns_map_sierra = {
2498078e9e92SSwapnil Jakhade 	.id_value = SIERRA_MACRO_ID,
2499078e9e92SSwapnil Jakhade 	.block_offset_shift = 0x2,
2500078e9e92SSwapnil Jakhade 	.reg_offset_shift = 0x2,
2501fa105172SSwapnil Jakhade 	.pcs_cmn_vals = {
2502fa105172SSwapnil Jakhade 		[TYPE_PCIE] = {
2503fa105172SSwapnil Jakhade 			[TYPE_NONE] = {
25047a5ad9b4SSwapnil Jakhade 				[NO_SSC] = &pcie_phy_pcs_cmn_vals,
2505fa105172SSwapnil Jakhade 				[EXTERNAL_SSC] = &pcie_phy_pcs_cmn_vals,
25067a5ad9b4SSwapnil Jakhade 				[INTERNAL_SSC] = &pcie_phy_pcs_cmn_vals,
2507fa105172SSwapnil Jakhade 			},
25080cfa43abSSwapnil Jakhade 			[TYPE_SGMII] = {
25090cfa43abSSwapnil Jakhade 				[NO_SSC] = &pcie_phy_pcs_cmn_vals,
25100cfa43abSSwapnil Jakhade 				[EXTERNAL_SSC] = &pcie_phy_pcs_cmn_vals,
25110cfa43abSSwapnil Jakhade 				[INTERNAL_SSC] = &pcie_phy_pcs_cmn_vals,
25120cfa43abSSwapnil Jakhade 			},
25138a1b82d7SSwapnil Jakhade 			[TYPE_QSGMII] = {
25148a1b82d7SSwapnil Jakhade 				[NO_SSC] = &pcie_phy_pcs_cmn_vals,
25158a1b82d7SSwapnil Jakhade 				[EXTERNAL_SSC] = &pcie_phy_pcs_cmn_vals,
25168a1b82d7SSwapnil Jakhade 				[INTERNAL_SSC] = &pcie_phy_pcs_cmn_vals,
25178a1b82d7SSwapnil Jakhade 			},
2518fa105172SSwapnil Jakhade 		},
2519fa105172SSwapnil Jakhade 	},
2520078e9e92SSwapnil Jakhade 	.pma_cmn_vals = {
2521078e9e92SSwapnil Jakhade 		[TYPE_PCIE] = {
2522078e9e92SSwapnil Jakhade 			[TYPE_NONE] = {
25237a5ad9b4SSwapnil Jakhade 				[NO_SSC] = &pcie_100_no_ssc_cmn_vals,
2524078e9e92SSwapnil Jakhade 				[EXTERNAL_SSC] = &pcie_100_ext_ssc_cmn_vals,
25257a5ad9b4SSwapnil Jakhade 				[INTERNAL_SSC] = &pcie_100_int_ssc_cmn_vals,
2526078e9e92SSwapnil Jakhade 			},
25270cfa43abSSwapnil Jakhade 			[TYPE_SGMII] = {
25280cfa43abSSwapnil Jakhade 				[NO_SSC] = &pcie_100_no_ssc_plllc_cmn_vals,
25290cfa43abSSwapnil Jakhade 				[EXTERNAL_SSC] = &pcie_100_ext_ssc_plllc_cmn_vals,
25300cfa43abSSwapnil Jakhade 				[INTERNAL_SSC] = &pcie_100_int_ssc_plllc_cmn_vals,
25310cfa43abSSwapnil Jakhade 			},
25328a1b82d7SSwapnil Jakhade 			[TYPE_QSGMII] = {
25338a1b82d7SSwapnil Jakhade 				[NO_SSC] = &pcie_100_no_ssc_plllc_cmn_vals,
25348a1b82d7SSwapnil Jakhade 				[EXTERNAL_SSC] = &pcie_100_ext_ssc_plllc_cmn_vals,
25358a1b82d7SSwapnil Jakhade 				[INTERNAL_SSC] = &pcie_100_int_ssc_plllc_cmn_vals,
25368a1b82d7SSwapnil Jakhade 			},
2537078e9e92SSwapnil Jakhade 		},
2538078e9e92SSwapnil Jakhade 		[TYPE_USB] = {
2539078e9e92SSwapnil Jakhade 			[TYPE_NONE] = {
2540078e9e92SSwapnil Jakhade 				[EXTERNAL_SSC] = &usb_100_ext_ssc_cmn_vals,
2541078e9e92SSwapnil Jakhade 			},
2542078e9e92SSwapnil Jakhade 		},
25430cfa43abSSwapnil Jakhade 		[TYPE_SGMII] = {
2544a1d12987SMarcin Wierzbicki 			[TYPE_NONE] = {
2545a1d12987SMarcin Wierzbicki 				[NO_SSC] = &sgmii_cmn_vals,
2546a1d12987SMarcin Wierzbicki 			},
25470cfa43abSSwapnil Jakhade 			[TYPE_PCIE] = {
25480cfa43abSSwapnil Jakhade 				[NO_SSC] = &sgmii_100_no_ssc_plllc1_opt3_cmn_vals,
25490cfa43abSSwapnil Jakhade 				[EXTERNAL_SSC] = &sgmii_100_no_ssc_plllc1_opt3_cmn_vals,
25500cfa43abSSwapnil Jakhade 				[INTERNAL_SSC] = &sgmii_100_no_ssc_plllc1_opt3_cmn_vals,
25510cfa43abSSwapnil Jakhade 			},
25520cfa43abSSwapnil Jakhade 		},
25538a1b82d7SSwapnil Jakhade 		[TYPE_QSGMII] = {
25548a1b82d7SSwapnil Jakhade 			[TYPE_PCIE] = {
25558a1b82d7SSwapnil Jakhade 				[NO_SSC] = &qsgmii_100_no_ssc_plllc1_cmn_vals,
25568a1b82d7SSwapnil Jakhade 				[EXTERNAL_SSC] = &qsgmii_100_no_ssc_plllc1_cmn_vals,
25578a1b82d7SSwapnil Jakhade 				[INTERNAL_SSC] = &qsgmii_100_no_ssc_plllc1_cmn_vals,
25588a1b82d7SSwapnil Jakhade 			},
25598a1b82d7SSwapnil Jakhade 		},
2560078e9e92SSwapnil Jakhade 	},
2561078e9e92SSwapnil Jakhade 	.pma_ln_vals = {
2562078e9e92SSwapnil Jakhade 		[TYPE_PCIE] = {
2563078e9e92SSwapnil Jakhade 			[TYPE_NONE] = {
25647a5ad9b4SSwapnil Jakhade 				[NO_SSC] = &pcie_100_no_ssc_ln_vals,
2565078e9e92SSwapnil Jakhade 				[EXTERNAL_SSC] = &pcie_100_ext_ssc_ln_vals,
25667a5ad9b4SSwapnil Jakhade 				[INTERNAL_SSC] = &pcie_100_int_ssc_ln_vals,
2567078e9e92SSwapnil Jakhade 			},
25680cfa43abSSwapnil Jakhade 			[TYPE_SGMII] = {
25690cfa43abSSwapnil Jakhade 				[NO_SSC] = &ml_pcie_100_no_ssc_ln_vals,
25700cfa43abSSwapnil Jakhade 				[EXTERNAL_SSC] = &ml_pcie_100_ext_ssc_ln_vals,
25710cfa43abSSwapnil Jakhade 				[INTERNAL_SSC] = &ml_pcie_100_int_ssc_ln_vals,
25720cfa43abSSwapnil Jakhade 			},
25738a1b82d7SSwapnil Jakhade 			[TYPE_QSGMII] = {
25748a1b82d7SSwapnil Jakhade 				[NO_SSC] = &ml_pcie_100_no_ssc_ln_vals,
25758a1b82d7SSwapnil Jakhade 				[EXTERNAL_SSC] = &ml_pcie_100_ext_ssc_ln_vals,
25768a1b82d7SSwapnil Jakhade 				[INTERNAL_SSC] = &ml_pcie_100_int_ssc_ln_vals,
25778a1b82d7SSwapnil Jakhade 			},
2578078e9e92SSwapnil Jakhade 		},
2579078e9e92SSwapnil Jakhade 		[TYPE_USB] = {
2580078e9e92SSwapnil Jakhade 			[TYPE_NONE] = {
2581078e9e92SSwapnil Jakhade 				[EXTERNAL_SSC] = &usb_100_ext_ssc_ln_vals,
2582078e9e92SSwapnil Jakhade 			},
2583078e9e92SSwapnil Jakhade 		},
25840cfa43abSSwapnil Jakhade 		[TYPE_SGMII] = {
2585a1d12987SMarcin Wierzbicki 			[TYPE_NONE] = {
2586a1d12987SMarcin Wierzbicki 				[NO_SSC] = &sgmii_pma_ln_vals,
2587a1d12987SMarcin Wierzbicki 			},
25880cfa43abSSwapnil Jakhade 			[TYPE_PCIE] = {
25890cfa43abSSwapnil Jakhade 				[NO_SSC] = &sgmii_100_no_ssc_plllc1_opt3_ln_vals,
25900cfa43abSSwapnil Jakhade 				[EXTERNAL_SSC] = &sgmii_100_no_ssc_plllc1_opt3_ln_vals,
25910cfa43abSSwapnil Jakhade 				[INTERNAL_SSC] = &sgmii_100_no_ssc_plllc1_opt3_ln_vals,
25920cfa43abSSwapnil Jakhade 			},
25930cfa43abSSwapnil Jakhade 		},
25948a1b82d7SSwapnil Jakhade 		[TYPE_QSGMII] = {
25958a1b82d7SSwapnil Jakhade 			[TYPE_PCIE] = {
25968a1b82d7SSwapnil Jakhade 				[NO_SSC] = &qsgmii_100_no_ssc_plllc1_ln_vals,
25978a1b82d7SSwapnil Jakhade 				[EXTERNAL_SSC] = &qsgmii_100_no_ssc_plllc1_ln_vals,
25988a1b82d7SSwapnil Jakhade 				[INTERNAL_SSC] = &qsgmii_100_no_ssc_plllc1_ln_vals,
25998a1b82d7SSwapnil Jakhade 			},
26008a1b82d7SSwapnil Jakhade 		},
2601078e9e92SSwapnil Jakhade 	},
260244d30d62SAlan Douglas };
260344d30d62SAlan Douglas 
2604367da978SKishon Vijay Abraham I static const struct cdns_sierra_data cdns_ti_map_sierra = {
2605078e9e92SSwapnil Jakhade 	.id_value = SIERRA_MACRO_ID,
2606078e9e92SSwapnil Jakhade 	.block_offset_shift = 0x0,
2607078e9e92SSwapnil Jakhade 	.reg_offset_shift = 0x1,
2608fa105172SSwapnil Jakhade 	.pcs_cmn_vals = {
2609fa105172SSwapnil Jakhade 		[TYPE_PCIE] = {
2610fa105172SSwapnil Jakhade 			[TYPE_NONE] = {
26117a5ad9b4SSwapnil Jakhade 				[NO_SSC] = &pcie_phy_pcs_cmn_vals,
2612fa105172SSwapnil Jakhade 				[EXTERNAL_SSC] = &pcie_phy_pcs_cmn_vals,
26137a5ad9b4SSwapnil Jakhade 				[INTERNAL_SSC] = &pcie_phy_pcs_cmn_vals,
2614fa105172SSwapnil Jakhade 			},
26150cfa43abSSwapnil Jakhade 			[TYPE_SGMII] = {
26160cfa43abSSwapnil Jakhade 				[NO_SSC] = &pcie_phy_pcs_cmn_vals,
26170cfa43abSSwapnil Jakhade 				[EXTERNAL_SSC] = &pcie_phy_pcs_cmn_vals,
26180cfa43abSSwapnil Jakhade 				[INTERNAL_SSC] = &pcie_phy_pcs_cmn_vals,
26190cfa43abSSwapnil Jakhade 			},
26208a1b82d7SSwapnil Jakhade 			[TYPE_QSGMII] = {
26218a1b82d7SSwapnil Jakhade 				[NO_SSC] = &pcie_phy_pcs_cmn_vals,
26228a1b82d7SSwapnil Jakhade 				[EXTERNAL_SSC] = &pcie_phy_pcs_cmn_vals,
26238a1b82d7SSwapnil Jakhade 				[INTERNAL_SSC] = &pcie_phy_pcs_cmn_vals,
26248a1b82d7SSwapnil Jakhade 			},
26258a1b82d7SSwapnil Jakhade 		},
26268a1b82d7SSwapnil Jakhade 	},
26278a1b82d7SSwapnil Jakhade 	.phy_pma_ln_vals = {
26280cfa43abSSwapnil Jakhade 		[TYPE_SGMII] = {
26290cfa43abSSwapnil Jakhade 			[TYPE_PCIE] = {
26300cfa43abSSwapnil Jakhade 				[NO_SSC] = &sgmii_phy_pma_ln_vals,
26310cfa43abSSwapnil Jakhade 				[EXTERNAL_SSC] = &sgmii_phy_pma_ln_vals,
26320cfa43abSSwapnil Jakhade 				[INTERNAL_SSC] = &sgmii_phy_pma_ln_vals,
26330cfa43abSSwapnil Jakhade 			},
26340cfa43abSSwapnil Jakhade 		},
26358a1b82d7SSwapnil Jakhade 		[TYPE_QSGMII] = {
26368a1b82d7SSwapnil Jakhade 			[TYPE_PCIE] = {
26378a1b82d7SSwapnil Jakhade 				[NO_SSC] = &qsgmii_phy_pma_ln_vals,
26388a1b82d7SSwapnil Jakhade 				[EXTERNAL_SSC] = &qsgmii_phy_pma_ln_vals,
26398a1b82d7SSwapnil Jakhade 				[INTERNAL_SSC] = &qsgmii_phy_pma_ln_vals,
26408a1b82d7SSwapnil Jakhade 			},
2641fa105172SSwapnil Jakhade 		},
2642fa105172SSwapnil Jakhade 	},
2643078e9e92SSwapnil Jakhade 	.pma_cmn_vals = {
2644078e9e92SSwapnil Jakhade 		[TYPE_PCIE] = {
2645078e9e92SSwapnil Jakhade 			[TYPE_NONE] = {
26467a5ad9b4SSwapnil Jakhade 				[NO_SSC] = &pcie_100_no_ssc_cmn_vals,
2647078e9e92SSwapnil Jakhade 				[EXTERNAL_SSC] = &pcie_100_ext_ssc_cmn_vals,
26487a5ad9b4SSwapnil Jakhade 				[INTERNAL_SSC] = &pcie_100_int_ssc_cmn_vals,
2649078e9e92SSwapnil Jakhade 			},
26500cfa43abSSwapnil Jakhade 			[TYPE_SGMII] = {
26510cfa43abSSwapnil Jakhade 				[NO_SSC] = &pcie_100_no_ssc_plllc_cmn_vals,
26520cfa43abSSwapnil Jakhade 				[EXTERNAL_SSC] = &pcie_100_ext_ssc_plllc_cmn_vals,
26530cfa43abSSwapnil Jakhade 				[INTERNAL_SSC] = &pcie_100_int_ssc_plllc_cmn_vals,
26540cfa43abSSwapnil Jakhade 			},
26558a1b82d7SSwapnil Jakhade 			[TYPE_QSGMII] = {
26568a1b82d7SSwapnil Jakhade 				[NO_SSC] = &pcie_100_no_ssc_plllc_cmn_vals,
26578a1b82d7SSwapnil Jakhade 				[EXTERNAL_SSC] = &pcie_100_ext_ssc_plllc_cmn_vals,
26588a1b82d7SSwapnil Jakhade 				[INTERNAL_SSC] = &pcie_100_int_ssc_plllc_cmn_vals,
26598a1b82d7SSwapnil Jakhade 			},
2660078e9e92SSwapnil Jakhade 		},
2661078e9e92SSwapnil Jakhade 		[TYPE_USB] = {
2662078e9e92SSwapnil Jakhade 			[TYPE_NONE] = {
2663078e9e92SSwapnil Jakhade 				[EXTERNAL_SSC] = &usb_100_ext_ssc_cmn_vals,
2664078e9e92SSwapnil Jakhade 			},
2665078e9e92SSwapnil Jakhade 		},
26660cfa43abSSwapnil Jakhade 		[TYPE_SGMII] = {
26670cfa43abSSwapnil Jakhade 			[TYPE_PCIE] = {
26680cfa43abSSwapnil Jakhade 				[NO_SSC] = &sgmii_100_no_ssc_plllc1_opt3_cmn_vals,
26690cfa43abSSwapnil Jakhade 				[EXTERNAL_SSC] = &sgmii_100_no_ssc_plllc1_opt3_cmn_vals,
26700cfa43abSSwapnil Jakhade 				[INTERNAL_SSC] = &sgmii_100_no_ssc_plllc1_opt3_cmn_vals,
26710cfa43abSSwapnil Jakhade 			},
26720cfa43abSSwapnil Jakhade 		},
26738a1b82d7SSwapnil Jakhade 		[TYPE_QSGMII] = {
26748a1b82d7SSwapnil Jakhade 			[TYPE_PCIE] = {
26758a1b82d7SSwapnil Jakhade 				[NO_SSC] = &qsgmii_100_no_ssc_plllc1_cmn_vals,
26768a1b82d7SSwapnil Jakhade 				[EXTERNAL_SSC] = &qsgmii_100_no_ssc_plllc1_cmn_vals,
26778a1b82d7SSwapnil Jakhade 				[INTERNAL_SSC] = &qsgmii_100_no_ssc_plllc1_cmn_vals,
26788a1b82d7SSwapnil Jakhade 			},
26798a1b82d7SSwapnil Jakhade 		},
2680078e9e92SSwapnil Jakhade 	},
2681078e9e92SSwapnil Jakhade 	.pma_ln_vals = {
2682078e9e92SSwapnil Jakhade 		[TYPE_PCIE] = {
2683078e9e92SSwapnil Jakhade 			[TYPE_NONE] = {
26847a5ad9b4SSwapnil Jakhade 				[NO_SSC] = &pcie_100_no_ssc_ln_vals,
2685078e9e92SSwapnil Jakhade 				[EXTERNAL_SSC] = &pcie_100_ext_ssc_ln_vals,
26867a5ad9b4SSwapnil Jakhade 				[INTERNAL_SSC] = &pcie_100_int_ssc_ln_vals,
2687078e9e92SSwapnil Jakhade 			},
26880cfa43abSSwapnil Jakhade 			[TYPE_SGMII] = {
26890cfa43abSSwapnil Jakhade 				[NO_SSC] = &ti_ml_pcie_100_no_ssc_ln_vals,
26900cfa43abSSwapnil Jakhade 				[EXTERNAL_SSC] = &ti_ml_pcie_100_ext_ssc_ln_vals,
26910cfa43abSSwapnil Jakhade 				[INTERNAL_SSC] = &ti_ml_pcie_100_int_ssc_ln_vals,
26920cfa43abSSwapnil Jakhade 			},
26938a1b82d7SSwapnil Jakhade 			[TYPE_QSGMII] = {
2694e72659b6SSwapnil Jakhade 				[NO_SSC] = &ti_ml_pcie_100_no_ssc_ln_vals,
2695e72659b6SSwapnil Jakhade 				[EXTERNAL_SSC] = &ti_ml_pcie_100_ext_ssc_ln_vals,
2696e72659b6SSwapnil Jakhade 				[INTERNAL_SSC] = &ti_ml_pcie_100_int_ssc_ln_vals,
26978a1b82d7SSwapnil Jakhade 			},
2698078e9e92SSwapnil Jakhade 		},
2699078e9e92SSwapnil Jakhade 		[TYPE_USB] = {
2700078e9e92SSwapnil Jakhade 			[TYPE_NONE] = {
2701078e9e92SSwapnil Jakhade 				[EXTERNAL_SSC] = &usb_100_ext_ssc_ln_vals,
2702078e9e92SSwapnil Jakhade 			},
2703078e9e92SSwapnil Jakhade 		},
27040cfa43abSSwapnil Jakhade 		[TYPE_SGMII] = {
27050cfa43abSSwapnil Jakhade 			[TYPE_PCIE] = {
27060cfa43abSSwapnil Jakhade 				[NO_SSC] = &sgmii_100_no_ssc_plllc1_opt3_ln_vals,
27070cfa43abSSwapnil Jakhade 				[EXTERNAL_SSC] = &sgmii_100_no_ssc_plllc1_opt3_ln_vals,
27080cfa43abSSwapnil Jakhade 				[INTERNAL_SSC] = &sgmii_100_no_ssc_plllc1_opt3_ln_vals,
27090cfa43abSSwapnil Jakhade 			},
27100cfa43abSSwapnil Jakhade 		},
27118a1b82d7SSwapnil Jakhade 		[TYPE_QSGMII] = {
27128a1b82d7SSwapnil Jakhade 			[TYPE_PCIE] = {
27138a1b82d7SSwapnil Jakhade 				[NO_SSC] = &qsgmii_100_no_ssc_plllc1_ln_vals,
27148a1b82d7SSwapnil Jakhade 				[EXTERNAL_SSC] = &qsgmii_100_no_ssc_plllc1_ln_vals,
27158a1b82d7SSwapnil Jakhade 				[INTERNAL_SSC] = &qsgmii_100_no_ssc_plllc1_ln_vals,
27168a1b82d7SSwapnil Jakhade 			},
27178a1b82d7SSwapnil Jakhade 		},
2718078e9e92SSwapnil Jakhade 	},
2719367da978SKishon Vijay Abraham I };
2720367da978SKishon Vijay Abraham I 
272144d30d62SAlan Douglas static const struct of_device_id cdns_sierra_id_table[] = {
272244d30d62SAlan Douglas 	{
272344d30d62SAlan Douglas 		.compatible = "cdns,sierra-phy-t0",
272444d30d62SAlan Douglas 		.data = &cdns_map_sierra,
272544d30d62SAlan Douglas 	},
2726367da978SKishon Vijay Abraham I 	{
2727367da978SKishon Vijay Abraham I 		.compatible = "ti,sierra-phy-t0",
2728367da978SKishon Vijay Abraham I 		.data = &cdns_ti_map_sierra,
2729367da978SKishon Vijay Abraham I 	},
273044d30d62SAlan Douglas 	{}
273144d30d62SAlan Douglas };
273244d30d62SAlan Douglas MODULE_DEVICE_TABLE(of, cdns_sierra_id_table);
273344d30d62SAlan Douglas 
273444d30d62SAlan Douglas static struct platform_driver cdns_sierra_driver = {
273544d30d62SAlan Douglas 	.probe		= cdns_sierra_phy_probe,
2736e9ddb1adSUwe Kleine-König 	.remove_new	= cdns_sierra_phy_remove,
273744d30d62SAlan Douglas 	.driver		= {
273844d30d62SAlan Douglas 		.name	= "cdns-sierra-phy",
273944d30d62SAlan Douglas 		.of_match_table = cdns_sierra_id_table,
274044d30d62SAlan Douglas 	},
274144d30d62SAlan Douglas };
274244d30d62SAlan Douglas module_platform_driver(cdns_sierra_driver);
274344d30d62SAlan Douglas 
274444d30d62SAlan Douglas MODULE_ALIAS("platform:cdns_sierra");
274544d30d62SAlan Douglas MODULE_AUTHOR("Cadence Design Systems");
274644d30d62SAlan Douglas MODULE_DESCRIPTION("CDNS sierra phy driver");
274744d30d62SAlan Douglas MODULE_LICENSE("GPL v2");
2748