xref: /linux/drivers/phy/cadence/phy-cadence-sierra.c (revision da08aab940092a050a4fb2857ed9479d2b0e03c4)
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
27078e9e92SSwapnil Jakhade #define NUM_PHY_TYPE		3
28078e9e92SSwapnil Jakhade 
2944d30d62SAlan Douglas /* PHY register offsets */
30380f5708SKishon Vijay Abraham I #define SIERRA_COMMON_CDB_OFFSET			0x0
31380f5708SKishon Vijay Abraham I #define SIERRA_MACRO_ID_REG				0x0
3228081b72SKishon Vijay Abraham I #define SIERRA_CMN_PLLLC_GEN_PREG			0x42
33871002d7SAnil Varughese #define SIERRA_CMN_PLLLC_MODE_PREG			0x48
34871002d7SAnil Varughese #define SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG		0x49
35871002d7SAnil Varughese #define SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG		0x4A
36871002d7SAnil Varughese #define SIERRA_CMN_PLLLC_LOCK_CNTSTART_PREG		0x4B
37871002d7SAnil Varughese #define SIERRA_CMN_PLLLC_BWCAL_MODE1_PREG		0x4F
38871002d7SAnil Varughese #define SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG		0x50
397a5ad9b4SSwapnil Jakhade #define SIERRA_CMN_PLLLC_DSMCORR_PREG			0x51
407a5ad9b4SSwapnil Jakhade #define SIERRA_CMN_PLLLC_SS_PREG			0x52
417a5ad9b4SSwapnil Jakhade #define SIERRA_CMN_PLLLC_SS_AMP_STEP_SIZE_PREG		0x53
427a5ad9b4SSwapnil Jakhade #define SIERRA_CMN_PLLLC_SSTWOPT_PREG			0x54
43871002d7SAnil Varughese #define SIERRA_CMN_PLLLC_SS_TIME_STEPSIZE_MODE_PREG	0x62
447a5ad9b4SSwapnil Jakhade #define SIERRA_CMN_PLLLC_LOCK_DELAY_CTRL_PREG		0x63
4528081b72SKishon Vijay Abraham I #define SIERRA_CMN_REFRCV_PREG				0x98
4628081b72SKishon Vijay Abraham I #define SIERRA_CMN_REFRCV1_PREG				0xB8
4728081b72SKishon Vijay Abraham I #define SIERRA_CMN_PLLLC1_GEN_PREG			0xC2
48380f5708SKishon Vijay Abraham I 
49380f5708SKishon Vijay Abraham I #define SIERRA_LANE_CDB_OFFSET(ln, block_offset, reg_offset)	\
50380f5708SKishon Vijay Abraham I 				((0x4000 << (block_offset)) + \
51380f5708SKishon Vijay Abraham I 				 (((ln) << 9) << (reg_offset)))
52aead5fd6SKishon Vijay Abraham I 
53aead5fd6SKishon Vijay Abraham I #define SIERRA_DET_STANDEC_A_PREG			0x000
54aead5fd6SKishon Vijay Abraham I #define SIERRA_DET_STANDEC_B_PREG			0x001
55aead5fd6SKishon Vijay Abraham I #define SIERRA_DET_STANDEC_C_PREG			0x002
56aead5fd6SKishon Vijay Abraham I #define SIERRA_DET_STANDEC_D_PREG			0x003
57aead5fd6SKishon Vijay Abraham I #define SIERRA_DET_STANDEC_E_PREG			0x004
58871002d7SAnil Varughese #define SIERRA_PSM_LANECAL_DLY_A1_RESETS_PREG		0x008
59871002d7SAnil Varughese #define SIERRA_PSM_A0IN_TMR_PREG			0x009
607a5ad9b4SSwapnil Jakhade #define SIERRA_PSM_A3IN_TMR_PREG			0x00C
61aead5fd6SKishon Vijay Abraham I #define SIERRA_PSM_DIAG_PREG				0x015
62aead5fd6SKishon Vijay Abraham I #define SIERRA_PSC_TX_A0_PREG				0x028
63aead5fd6SKishon Vijay Abraham I #define SIERRA_PSC_TX_A1_PREG				0x029
64aead5fd6SKishon Vijay Abraham I #define SIERRA_PSC_TX_A2_PREG				0x02A
65aead5fd6SKishon Vijay Abraham I #define SIERRA_PSC_TX_A3_PREG				0x02B
66aead5fd6SKishon Vijay Abraham I #define SIERRA_PSC_RX_A0_PREG				0x030
67aead5fd6SKishon Vijay Abraham I #define SIERRA_PSC_RX_A1_PREG				0x031
68aead5fd6SKishon Vijay Abraham I #define SIERRA_PSC_RX_A2_PREG				0x032
69aead5fd6SKishon Vijay Abraham I #define SIERRA_PSC_RX_A3_PREG				0x033
70aead5fd6SKishon Vijay Abraham I #define SIERRA_PLLCTRL_SUBRATE_PREG			0x03A
71aead5fd6SKishon Vijay Abraham I #define SIERRA_PLLCTRL_GEN_D_PREG			0x03E
72871002d7SAnil Varughese #define SIERRA_PLLCTRL_CPGAIN_MODE_PREG			0x03F
73adc4bd6fSKishon Vijay Abraham I #define SIERRA_PLLCTRL_STATUS_PREG			0x044
74871002d7SAnil Varughese #define SIERRA_CLKPATH_BIASTRIM_PREG			0x04B
75871002d7SAnil Varughese #define SIERRA_DFE_BIASTRIM_PREG			0x04C
76aead5fd6SKishon Vijay Abraham I #define SIERRA_DRVCTRL_ATTEN_PREG			0x06A
777a5ad9b4SSwapnil Jakhade #define SIERRA_DRVCTRL_BOOST_PREG			0x06F
78aead5fd6SKishon Vijay Abraham I #define SIERRA_CLKPATHCTRL_TMR_PREG			0x081
79871002d7SAnil Varughese #define SIERRA_RX_CREQ_FLTR_A_MODE3_PREG		0x085
80871002d7SAnil Varughese #define SIERRA_RX_CREQ_FLTR_A_MODE2_PREG		0x086
81aead5fd6SKishon Vijay Abraham I #define SIERRA_RX_CREQ_FLTR_A_MODE1_PREG		0x087
82aead5fd6SKishon Vijay Abraham I #define SIERRA_RX_CREQ_FLTR_A_MODE0_PREG		0x088
837a5ad9b4SSwapnil Jakhade #define SIERRA_CREQ_DCBIASATTEN_OVR_PREG		0x08C
84aead5fd6SKishon Vijay Abraham I #define SIERRA_CREQ_CCLKDET_MODE01_PREG			0x08E
857a5ad9b4SSwapnil Jakhade #define SIERRA_RX_CTLE_CAL_PREG				0x08F
86aead5fd6SKishon Vijay Abraham I #define SIERRA_RX_CTLE_MAINTENANCE_PREG			0x091
87aead5fd6SKishon Vijay Abraham I #define SIERRA_CREQ_FSMCLK_SEL_PREG			0x092
88871002d7SAnil Varughese #define SIERRA_CREQ_EQ_CTRL_PREG			0x093
89871002d7SAnil Varughese #define SIERRA_CREQ_SPARE_PREG				0x096
90871002d7SAnil Varughese #define SIERRA_CREQ_EQ_OPEN_EYE_THRESH_PREG		0x097
91aead5fd6SKishon Vijay Abraham I #define SIERRA_CTLELUT_CTRL_PREG			0x098
92aead5fd6SKishon Vijay Abraham I #define SIERRA_DFE_ECMP_RATESEL_PREG			0x0C0
93aead5fd6SKishon Vijay Abraham I #define SIERRA_DFE_SMP_RATESEL_PREG			0x0C1
94871002d7SAnil Varughese #define SIERRA_DEQ_PHALIGN_CTRL				0x0C4
95871002d7SAnil Varughese #define SIERRA_DEQ_CONCUR_CTRL1_PREG			0x0C8
96871002d7SAnil Varughese #define SIERRA_DEQ_CONCUR_CTRL2_PREG			0x0C9
97871002d7SAnil Varughese #define SIERRA_DEQ_EPIPWR_CTRL2_PREG			0x0CD
98871002d7SAnil Varughese #define SIERRA_DEQ_FAST_MAINT_CYCLES_PREG		0x0CE
99871002d7SAnil Varughese #define SIERRA_DEQ_ERRCMP_CTRL_PREG			0x0D0
100871002d7SAnil Varughese #define SIERRA_DEQ_OFFSET_CTRL_PREG			0x0D8
101871002d7SAnil Varughese #define SIERRA_DEQ_GAIN_CTRL_PREG			0x0E0
102aead5fd6SKishon Vijay Abraham I #define SIERRA_DEQ_VGATUNE_CTRL_PREG			0x0E1
103871002d7SAnil Varughese #define SIERRA_DEQ_GLUT0				0x0E8
104871002d7SAnil Varughese #define SIERRA_DEQ_GLUT1				0x0E9
105871002d7SAnil Varughese #define SIERRA_DEQ_GLUT2				0x0EA
106871002d7SAnil Varughese #define SIERRA_DEQ_GLUT3				0x0EB
107871002d7SAnil Varughese #define SIERRA_DEQ_GLUT4				0x0EC
108871002d7SAnil Varughese #define SIERRA_DEQ_GLUT5				0x0ED
109871002d7SAnil Varughese #define SIERRA_DEQ_GLUT6				0x0EE
110871002d7SAnil Varughese #define SIERRA_DEQ_GLUT7				0x0EF
111871002d7SAnil Varughese #define SIERRA_DEQ_GLUT8				0x0F0
112871002d7SAnil Varughese #define SIERRA_DEQ_GLUT9				0x0F1
113871002d7SAnil Varughese #define SIERRA_DEQ_GLUT10				0x0F2
114871002d7SAnil Varughese #define SIERRA_DEQ_GLUT11				0x0F3
115871002d7SAnil Varughese #define SIERRA_DEQ_GLUT12				0x0F4
116871002d7SAnil Varughese #define SIERRA_DEQ_GLUT13				0x0F5
117871002d7SAnil Varughese #define SIERRA_DEQ_GLUT14				0x0F6
118871002d7SAnil Varughese #define SIERRA_DEQ_GLUT15				0x0F7
119871002d7SAnil Varughese #define SIERRA_DEQ_GLUT16				0x0F8
120871002d7SAnil Varughese #define SIERRA_DEQ_ALUT0				0x108
121871002d7SAnil Varughese #define SIERRA_DEQ_ALUT1				0x109
122871002d7SAnil Varughese #define SIERRA_DEQ_ALUT2				0x10A
123871002d7SAnil Varughese #define SIERRA_DEQ_ALUT3				0x10B
124871002d7SAnil Varughese #define SIERRA_DEQ_ALUT4				0x10C
125871002d7SAnil Varughese #define SIERRA_DEQ_ALUT5				0x10D
126871002d7SAnil Varughese #define SIERRA_DEQ_ALUT6				0x10E
127871002d7SAnil Varughese #define SIERRA_DEQ_ALUT7				0x10F
128871002d7SAnil Varughese #define SIERRA_DEQ_ALUT8				0x110
129871002d7SAnil Varughese #define SIERRA_DEQ_ALUT9				0x111
130871002d7SAnil Varughese #define SIERRA_DEQ_ALUT10				0x112
131871002d7SAnil Varughese #define SIERRA_DEQ_ALUT11				0x113
132871002d7SAnil Varughese #define SIERRA_DEQ_ALUT12				0x114
133871002d7SAnil Varughese #define SIERRA_DEQ_ALUT13				0x115
134871002d7SAnil Varughese #define SIERRA_DEQ_DFETAP_CTRL_PREG			0x128
1357a5ad9b4SSwapnil Jakhade #define SIERRA_DEQ_DFETAP0				0x129
1367a5ad9b4SSwapnil Jakhade #define SIERRA_DEQ_DFETAP1				0x12B
1377a5ad9b4SSwapnil Jakhade #define SIERRA_DEQ_DFETAP2				0x12D
1387a5ad9b4SSwapnil Jakhade #define SIERRA_DEQ_DFETAP3				0x12F
1397a5ad9b4SSwapnil Jakhade #define SIERRA_DEQ_DFETAP4				0x131
140871002d7SAnil Varughese #define SIERRA_DFE_EN_1010_IGNORE_PREG			0x134
1417a5ad9b4SSwapnil Jakhade #define SIERRA_DEQ_PRECUR_PREG				0x138
1427a5ad9b4SSwapnil Jakhade #define SIERRA_DEQ_POSTCUR_PREG				0x140
1437a5ad9b4SSwapnil Jakhade #define SIERRA_DEQ_POSTCUR_DECR_PREG			0x142
144871002d7SAnil Varughese #define SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG		0x150
145871002d7SAnil Varughese #define SIERRA_DEQ_TAU_CTRL2_PREG			0x151
1467a5ad9b4SSwapnil Jakhade #define SIERRA_DEQ_TAU_CTRL3_PREG			0x152
1477a5ad9b4SSwapnil Jakhade #define SIERRA_DEQ_OPENEYE_CTRL_PREG			0x158
148871002d7SAnil Varughese #define SIERRA_DEQ_PICTRL_PREG				0x161
149871002d7SAnil Varughese #define SIERRA_CPICAL_TMRVAL_MODE1_PREG			0x170
150871002d7SAnil Varughese #define SIERRA_CPICAL_TMRVAL_MODE0_PREG			0x171
151871002d7SAnil Varughese #define SIERRA_CPICAL_PICNT_MODE1_PREG			0x174
152aead5fd6SKishon Vijay Abraham I #define SIERRA_CPI_OUTBUF_RATESEL_PREG			0x17C
1537a5ad9b4SSwapnil Jakhade #define SIERRA_CPI_TRIM_PREG				0x17F
154871002d7SAnil Varughese #define SIERRA_CPICAL_RES_STARTCODE_MODE23_PREG		0x183
1557a5ad9b4SSwapnil Jakhade #define SIERRA_EPI_CTRL_PREG				0x187
156871002d7SAnil Varughese #define SIERRA_LFPSDET_SUPPORT_PREG			0x188
157aead5fd6SKishon Vijay Abraham I #define SIERRA_LFPSFILT_NS_PREG				0x18A
158aead5fd6SKishon Vijay Abraham I #define SIERRA_LFPSFILT_RD_PREG				0x18B
159aead5fd6SKishon Vijay Abraham I #define SIERRA_LFPSFILT_MP_PREG				0x18C
160871002d7SAnil Varughese #define SIERRA_SIGDET_SUPPORT_PREG			0x190
161aead5fd6SKishon Vijay Abraham I #define SIERRA_SDFILT_H2L_A_PREG			0x191
162871002d7SAnil Varughese #define SIERRA_SDFILT_L2H_PREG				0x193
163871002d7SAnil Varughese #define SIERRA_RXBUFFER_CTLECTRL_PREG			0x19E
164871002d7SAnil Varughese #define SIERRA_RXBUFFER_RCDFECTRL_PREG			0x19F
165871002d7SAnil Varughese #define SIERRA_RXBUFFER_DFECTRL_PREG			0x1A0
166871002d7SAnil Varughese #define SIERRA_DEQ_TAU_CTRL1_FAST_MAINT_PREG		0x14F
167871002d7SAnil Varughese #define SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG		0x150
168380f5708SKishon Vijay Abraham I 
1698c95e172SSwapnil Jakhade /* PHY PCS common registers */
1708c95e172SSwapnil Jakhade #define SIERRA_PHY_PCS_COMMON_OFFSET(block_offset)	\
171380f5708SKishon Vijay Abraham I 				     (0xc000 << (block_offset))
172fa105172SSwapnil Jakhade #define SIERRA_PHY_PIPE_CMN_CTRL1			0x0
173380f5708SKishon Vijay Abraham I #define SIERRA_PHY_PLL_CFG				0xe
17444d30d62SAlan Douglas 
17536ce4163SSwapnil Jakhade /* PHY PCS lane registers */
17636ce4163SSwapnil Jakhade #define SIERRA_PHY_PCS_LANE_CDB_OFFSET(ln, block_offset, reg_offset)	\
17736ce4163SSwapnil Jakhade 				       ((0xD000 << (block_offset)) +	\
17836ce4163SSwapnil Jakhade 				       (((ln) << 8) << (reg_offset)))
17936ce4163SSwapnil Jakhade 
18036ce4163SSwapnil Jakhade #define SIERRA_PHY_ISO_LINK_CTRL			0xB
18136ce4163SSwapnil Jakhade 
182f1cc6c3fSSwapnil Jakhade /* PHY PMA common registers */
183f1cc6c3fSSwapnil Jakhade #define SIERRA_PHY_PMA_COMMON_OFFSET(block_offset)	\
184f1cc6c3fSSwapnil Jakhade 				     (0xE000 << (block_offset))
185f1cc6c3fSSwapnil Jakhade #define SIERRA_PHY_PMA_CMN_CTRL				0x000
186f1cc6c3fSSwapnil Jakhade 
18744d30d62SAlan Douglas #define SIERRA_MACRO_ID					0x00007364
188a43f72aeSKishon Vijay Abraham I #define SIERRA_MAX_LANES				16
189adc4bd6fSKishon Vijay Abraham I #define PLL_LOCK_TIME					100000
19044d30d62SAlan Douglas 
19128081b72SKishon Vijay Abraham I #define CDNS_SIERRA_OUTPUT_CLOCKS			2
19228081b72SKishon Vijay Abraham I #define CDNS_SIERRA_INPUT_CLOCKS			5
193a0c30cd7SKishon Vijay Abraham I enum cdns_sierra_clock_input {
194a0c30cd7SKishon Vijay Abraham I 	PHY_CLK,
195a0c30cd7SKishon Vijay Abraham I 	CMN_REFCLK_DIG_DIV,
196a0c30cd7SKishon Vijay Abraham I 	CMN_REFCLK1_DIG_DIV,
19728081b72SKishon Vijay Abraham I 	PLL0_REFCLK,
19828081b72SKishon Vijay Abraham I 	PLL1_REFCLK,
199a0c30cd7SKishon Vijay Abraham I };
200a0c30cd7SKishon Vijay Abraham I 
20128081b72SKishon Vijay Abraham I #define SIERRA_NUM_CMN_PLLC				2
20228081b72SKishon Vijay Abraham I #define SIERRA_NUM_CMN_PLLC_PARENTS			2
20328081b72SKishon Vijay Abraham I 
204380f5708SKishon Vijay Abraham I static const struct reg_field macro_id_type =
205380f5708SKishon Vijay Abraham I 				REG_FIELD(SIERRA_MACRO_ID_REG, 0, 15);
206380f5708SKishon Vijay Abraham I static const struct reg_field phy_pll_cfg_1 =
207380f5708SKishon Vijay Abraham I 				REG_FIELD(SIERRA_PHY_PLL_CFG, 1, 1);
208f1cc6c3fSSwapnil Jakhade static const struct reg_field pma_cmn_ready =
209f1cc6c3fSSwapnil Jakhade 				REG_FIELD(SIERRA_PHY_PMA_CMN_CTRL, 0, 0);
210adc4bd6fSKishon Vijay Abraham I static const struct reg_field pllctrl_lock =
211adc4bd6fSKishon Vijay Abraham I 				REG_FIELD(SIERRA_PLLCTRL_STATUS_PREG, 0, 0);
21236ce4163SSwapnil Jakhade static const struct reg_field phy_iso_link_ctrl_1 =
21336ce4163SSwapnil Jakhade 				REG_FIELD(SIERRA_PHY_ISO_LINK_CTRL, 1, 1);
214380f5708SKishon Vijay Abraham I 
21528081b72SKishon Vijay Abraham I static const char * const clk_names[] = {
21628081b72SKishon Vijay Abraham I 	[CDNS_SIERRA_PLL_CMNLC] = "pll_cmnlc",
21728081b72SKishon Vijay Abraham I 	[CDNS_SIERRA_PLL_CMNLC1] = "pll_cmnlc1",
21828081b72SKishon Vijay Abraham I };
21928081b72SKishon Vijay Abraham I 
22028081b72SKishon Vijay Abraham I enum cdns_sierra_cmn_plllc {
22128081b72SKishon Vijay Abraham I 	CMN_PLLLC,
22228081b72SKishon Vijay Abraham I 	CMN_PLLLC1,
22328081b72SKishon Vijay Abraham I };
22428081b72SKishon Vijay Abraham I 
22528081b72SKishon Vijay Abraham I struct cdns_sierra_pll_mux_reg_fields {
22628081b72SKishon Vijay Abraham I 	struct reg_field	pfdclk_sel_preg;
22728081b72SKishon Vijay Abraham I 	struct reg_field	plllc1en_field;
22828081b72SKishon Vijay Abraham I 	struct reg_field	termen_field;
22928081b72SKishon Vijay Abraham I };
23028081b72SKishon Vijay Abraham I 
23128081b72SKishon Vijay Abraham I static const struct cdns_sierra_pll_mux_reg_fields cmn_plllc_pfdclk1_sel_preg[] = {
23228081b72SKishon Vijay Abraham I 	[CMN_PLLLC] = {
23328081b72SKishon Vijay Abraham I 		.pfdclk_sel_preg = REG_FIELD(SIERRA_CMN_PLLLC_GEN_PREG, 1, 1),
23428081b72SKishon Vijay Abraham I 		.plllc1en_field = REG_FIELD(SIERRA_CMN_REFRCV1_PREG, 8, 8),
23528081b72SKishon Vijay Abraham I 		.termen_field = REG_FIELD(SIERRA_CMN_REFRCV1_PREG, 0, 0),
23628081b72SKishon Vijay Abraham I 	},
23728081b72SKishon Vijay Abraham I 	[CMN_PLLLC1] = {
23828081b72SKishon Vijay Abraham I 		.pfdclk_sel_preg = REG_FIELD(SIERRA_CMN_PLLLC1_GEN_PREG, 1, 1),
23928081b72SKishon Vijay Abraham I 		.plllc1en_field = REG_FIELD(SIERRA_CMN_REFRCV_PREG, 8, 8),
24028081b72SKishon Vijay Abraham I 		.termen_field = REG_FIELD(SIERRA_CMN_REFRCV_PREG, 0, 0),
24128081b72SKishon Vijay Abraham I 	},
24228081b72SKishon Vijay Abraham I };
24328081b72SKishon Vijay Abraham I 
24428081b72SKishon Vijay Abraham I struct cdns_sierra_pll_mux {
24528081b72SKishon Vijay Abraham I 	struct clk_hw		hw;
24628081b72SKishon Vijay Abraham I 	struct regmap_field	*pfdclk_sel_preg;
24728081b72SKishon Vijay Abraham I 	struct regmap_field	*plllc1en_field;
24828081b72SKishon Vijay Abraham I 	struct regmap_field	*termen_field;
24928081b72SKishon Vijay Abraham I 	struct clk_init_data	clk_data;
25028081b72SKishon Vijay Abraham I };
25128081b72SKishon Vijay Abraham I 
25228081b72SKishon Vijay Abraham I #define to_cdns_sierra_pll_mux(_hw)	\
25328081b72SKishon Vijay Abraham I 			container_of(_hw, struct cdns_sierra_pll_mux, hw)
25428081b72SKishon Vijay Abraham I 
25528081b72SKishon Vijay Abraham I static const int pll_mux_parent_index[][SIERRA_NUM_CMN_PLLC_PARENTS] = {
25628081b72SKishon Vijay Abraham I 	[CMN_PLLLC] = { PLL0_REFCLK, PLL1_REFCLK },
25728081b72SKishon Vijay Abraham I 	[CMN_PLLLC1] = { PLL1_REFCLK, PLL0_REFCLK },
25828081b72SKishon Vijay Abraham I };
25928081b72SKishon Vijay Abraham I 
260*da08aab9SSwapnil Jakhade static u32 cdns_sierra_pll_mux_table[][SIERRA_NUM_CMN_PLLC_PARENTS] = {
261*da08aab9SSwapnil Jakhade 	[CMN_PLLLC] = { 0, 1 },
262*da08aab9SSwapnil Jakhade 	[CMN_PLLLC1] = { 1, 0 },
263*da08aab9SSwapnil Jakhade };
26428081b72SKishon Vijay Abraham I 
265078e9e92SSwapnil Jakhade enum cdns_sierra_phy_type {
266078e9e92SSwapnil Jakhade 	TYPE_NONE,
267078e9e92SSwapnil Jakhade 	TYPE_PCIE,
268078e9e92SSwapnil Jakhade 	TYPE_USB
269078e9e92SSwapnil Jakhade };
270078e9e92SSwapnil Jakhade 
271078e9e92SSwapnil Jakhade enum cdns_sierra_ssc_mode {
272078e9e92SSwapnil Jakhade 	NO_SSC,
273078e9e92SSwapnil Jakhade 	EXTERNAL_SSC,
274078e9e92SSwapnil Jakhade 	INTERNAL_SSC
275078e9e92SSwapnil Jakhade };
276078e9e92SSwapnil Jakhade 
27744d30d62SAlan Douglas struct cdns_sierra_inst {
27844d30d62SAlan Douglas 	struct phy *phy;
279078e9e92SSwapnil Jakhade 	enum cdns_sierra_phy_type phy_type;
28044d30d62SAlan Douglas 	u32 num_lanes;
28144d30d62SAlan Douglas 	u32 mlane;
28244d30d62SAlan Douglas 	struct reset_control *lnk_rst;
2831e902b2aSSwapnil Jakhade 	enum cdns_sierra_ssc_mode ssc_mode;
28444d30d62SAlan Douglas };
28544d30d62SAlan Douglas 
28644d30d62SAlan Douglas struct cdns_reg_pairs {
28744d30d62SAlan Douglas 	u16 val;
28844d30d62SAlan Douglas 	u32 off;
28944d30d62SAlan Douglas };
29044d30d62SAlan Douglas 
291078e9e92SSwapnil Jakhade struct cdns_sierra_vals {
292078e9e92SSwapnil Jakhade 	const struct cdns_reg_pairs *reg_pairs;
293078e9e92SSwapnil Jakhade 	u32 num_regs;
294078e9e92SSwapnil Jakhade };
295078e9e92SSwapnil Jakhade 
29644d30d62SAlan Douglas struct cdns_sierra_data {
29744d30d62SAlan Douglas 	u32 id_value;
298380f5708SKishon Vijay Abraham I 	u8 block_offset_shift;
299380f5708SKishon Vijay Abraham I 	u8 reg_offset_shift;
300fa105172SSwapnil Jakhade 	struct cdns_sierra_vals *pcs_cmn_vals[NUM_PHY_TYPE][NUM_PHY_TYPE]
301fa105172SSwapnil Jakhade 					     [NUM_SSC_MODE];
302078e9e92SSwapnil Jakhade 	struct cdns_sierra_vals *pma_cmn_vals[NUM_PHY_TYPE][NUM_PHY_TYPE]
303078e9e92SSwapnil Jakhade 					     [NUM_SSC_MODE];
304078e9e92SSwapnil Jakhade 	struct cdns_sierra_vals *pma_ln_vals[NUM_PHY_TYPE][NUM_PHY_TYPE]
305078e9e92SSwapnil Jakhade 					    [NUM_SSC_MODE];
30644d30d62SAlan Douglas };
30744d30d62SAlan Douglas 
308380f5708SKishon Vijay Abraham I struct cdns_regmap_cdb_context {
30944d30d62SAlan Douglas 	struct device *dev;
31044d30d62SAlan Douglas 	void __iomem *base;
311380f5708SKishon Vijay Abraham I 	u8 reg_offset_shift;
312380f5708SKishon Vijay Abraham I };
313380f5708SKishon Vijay Abraham I 
314380f5708SKishon Vijay Abraham I struct cdns_sierra_phy {
315380f5708SKishon Vijay Abraham I 	struct device *dev;
316380f5708SKishon Vijay Abraham I 	struct regmap *regmap;
317c3c11d55SSwapnil Jakhade 	const struct cdns_sierra_data *init_data;
31844d30d62SAlan Douglas 	struct cdns_sierra_inst phys[SIERRA_MAX_LANES];
31944d30d62SAlan Douglas 	struct reset_control *phy_rst;
32044d30d62SAlan Douglas 	struct reset_control *apb_rst;
321380f5708SKishon Vijay Abraham I 	struct regmap *regmap_lane_cdb[SIERRA_MAX_LANES];
3228c95e172SSwapnil Jakhade 	struct regmap *regmap_phy_pcs_common_cdb;
32336ce4163SSwapnil Jakhade 	struct regmap *regmap_phy_pcs_lane_cdb[SIERRA_MAX_LANES];
324f1cc6c3fSSwapnil Jakhade 	struct regmap *regmap_phy_pma_common_cdb;
325380f5708SKishon Vijay Abraham I 	struct regmap *regmap_common_cdb;
326380f5708SKishon Vijay Abraham I 	struct regmap_field *macro_id_type;
327380f5708SKishon Vijay Abraham I 	struct regmap_field *phy_pll_cfg_1;
328f1cc6c3fSSwapnil Jakhade 	struct regmap_field *pma_cmn_ready;
329adc4bd6fSKishon Vijay Abraham I 	struct regmap_field *pllctrl_lock[SIERRA_MAX_LANES];
33036ce4163SSwapnil Jakhade 	struct regmap_field *phy_iso_link_ctrl_1[SIERRA_MAX_LANES];
33128081b72SKishon Vijay Abraham I 	struct regmap_field *cmn_refrcv_refclk_plllc1en_preg[SIERRA_NUM_CMN_PLLC];
33228081b72SKishon Vijay Abraham I 	struct regmap_field *cmn_refrcv_refclk_termen_preg[SIERRA_NUM_CMN_PLLC];
33328081b72SKishon Vijay Abraham I 	struct regmap_field *cmn_plllc_pfdclk1_sel_preg[SIERRA_NUM_CMN_PLLC];
334a0c30cd7SKishon Vijay Abraham I 	struct clk *input_clks[CDNS_SIERRA_INPUT_CLOCKS];
33544d30d62SAlan Douglas 	int nsubnodes;
336a43f72aeSKishon Vijay Abraham I 	u32 num_lanes;
33744d30d62SAlan Douglas 	bool autoconf;
33828081b72SKishon Vijay Abraham I 	struct clk_onecell_data clk_data;
33928081b72SKishon Vijay Abraham I 	struct clk *output_clks[CDNS_SIERRA_OUTPUT_CLOCKS];
34044d30d62SAlan Douglas };
34144d30d62SAlan Douglas 
342380f5708SKishon Vijay Abraham I static int cdns_regmap_write(void *context, unsigned int reg, unsigned int val)
343380f5708SKishon Vijay Abraham I {
344380f5708SKishon Vijay Abraham I 	struct cdns_regmap_cdb_context *ctx = context;
345380f5708SKishon Vijay Abraham I 	u32 offset = reg << ctx->reg_offset_shift;
346380f5708SKishon Vijay Abraham I 
347380f5708SKishon Vijay Abraham I 	writew(val, ctx->base + offset);
348380f5708SKishon Vijay Abraham I 
349380f5708SKishon Vijay Abraham I 	return 0;
350380f5708SKishon Vijay Abraham I }
351380f5708SKishon Vijay Abraham I 
352380f5708SKishon Vijay Abraham I static int cdns_regmap_read(void *context, unsigned int reg, unsigned int *val)
353380f5708SKishon Vijay Abraham I {
354380f5708SKishon Vijay Abraham I 	struct cdns_regmap_cdb_context *ctx = context;
355380f5708SKishon Vijay Abraham I 	u32 offset = reg << ctx->reg_offset_shift;
356380f5708SKishon Vijay Abraham I 
357380f5708SKishon Vijay Abraham I 	*val = readw(ctx->base + offset);
358380f5708SKishon Vijay Abraham I 	return 0;
359380f5708SKishon Vijay Abraham I }
360380f5708SKishon Vijay Abraham I 
361380f5708SKishon Vijay Abraham I #define SIERRA_LANE_CDB_REGMAP_CONF(n) \
362380f5708SKishon Vijay Abraham I { \
363380f5708SKishon Vijay Abraham I 	.name = "sierra_lane" n "_cdb", \
364380f5708SKishon Vijay Abraham I 	.reg_stride = 1, \
365380f5708SKishon Vijay Abraham I 	.fast_io = true, \
366380f5708SKishon Vijay Abraham I 	.reg_write = cdns_regmap_write, \
367380f5708SKishon Vijay Abraham I 	.reg_read = cdns_regmap_read, \
368380f5708SKishon Vijay Abraham I }
369380f5708SKishon Vijay Abraham I 
3703cfb0e8eSRikard Falkeborn static const struct regmap_config cdns_sierra_lane_cdb_config[] = {
371380f5708SKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("0"),
372380f5708SKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("1"),
373380f5708SKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("2"),
374380f5708SKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("3"),
375a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("4"),
376a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("5"),
377a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("6"),
378a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("7"),
379a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("8"),
380a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("9"),
381a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("10"),
382a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("11"),
383a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("12"),
384a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("13"),
385a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("14"),
386a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("15"),
387380f5708SKishon Vijay Abraham I };
388380f5708SKishon Vijay Abraham I 
3893cfb0e8eSRikard Falkeborn static const struct regmap_config cdns_sierra_common_cdb_config = {
390380f5708SKishon Vijay Abraham I 	.name = "sierra_common_cdb",
391380f5708SKishon Vijay Abraham I 	.reg_stride = 1,
392380f5708SKishon Vijay Abraham I 	.fast_io = true,
393380f5708SKishon Vijay Abraham I 	.reg_write = cdns_regmap_write,
394380f5708SKishon Vijay Abraham I 	.reg_read = cdns_regmap_read,
395380f5708SKishon Vijay Abraham I };
396380f5708SKishon Vijay Abraham I 
3978c95e172SSwapnil Jakhade static const struct regmap_config cdns_sierra_phy_pcs_cmn_cdb_config = {
3988c95e172SSwapnil Jakhade 	.name = "sierra_phy_pcs_cmn_cdb",
399380f5708SKishon Vijay Abraham I 	.reg_stride = 1,
400380f5708SKishon Vijay Abraham I 	.fast_io = true,
401380f5708SKishon Vijay Abraham I 	.reg_write = cdns_regmap_write,
402380f5708SKishon Vijay Abraham I 	.reg_read = cdns_regmap_read,
403380f5708SKishon Vijay Abraham I };
404380f5708SKishon Vijay Abraham I 
40536ce4163SSwapnil Jakhade #define SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF(n) \
40636ce4163SSwapnil Jakhade { \
40736ce4163SSwapnil Jakhade 	.name = "sierra_phy_pcs_lane" n "_cdb", \
40836ce4163SSwapnil Jakhade 	.reg_stride = 1, \
40936ce4163SSwapnil Jakhade 	.fast_io = true, \
41036ce4163SSwapnil Jakhade 	.reg_write = cdns_regmap_write, \
41136ce4163SSwapnil Jakhade 	.reg_read = cdns_regmap_read, \
41236ce4163SSwapnil Jakhade }
41336ce4163SSwapnil Jakhade 
41436ce4163SSwapnil Jakhade static const struct regmap_config cdns_sierra_phy_pcs_lane_cdb_config[] = {
41536ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("0"),
41636ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("1"),
41736ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("2"),
41836ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("3"),
41936ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("4"),
42036ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("5"),
42136ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("6"),
42236ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("7"),
42336ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("8"),
42436ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("9"),
42536ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("10"),
42636ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("11"),
42736ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("12"),
42836ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("13"),
42936ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("14"),
43036ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("15"),
43136ce4163SSwapnil Jakhade };
43236ce4163SSwapnil Jakhade 
433f1cc6c3fSSwapnil Jakhade static const struct regmap_config cdns_sierra_phy_pma_cmn_cdb_config = {
434f1cc6c3fSSwapnil Jakhade 	.name = "sierra_phy_pma_cmn_cdb",
435f1cc6c3fSSwapnil Jakhade 	.reg_stride = 1,
436f1cc6c3fSSwapnil Jakhade 	.fast_io = true,
437f1cc6c3fSSwapnil Jakhade 	.reg_write = cdns_regmap_write,
438f1cc6c3fSSwapnil Jakhade 	.reg_read = cdns_regmap_read,
439f1cc6c3fSSwapnil Jakhade };
440f1cc6c3fSSwapnil Jakhade 
441cedcc2e2SKishon Vijay Abraham I static int cdns_sierra_phy_init(struct phy *gphy)
44244d30d62SAlan Douglas {
44344d30d62SAlan Douglas 	struct cdns_sierra_inst *ins = phy_get_drvdata(gphy);
44444d30d62SAlan Douglas 	struct cdns_sierra_phy *phy = dev_get_drvdata(gphy->dev.parent);
445078e9e92SSwapnil Jakhade 	const struct cdns_sierra_data *init_data = phy->init_data;
446078e9e92SSwapnil Jakhade 	struct cdns_sierra_vals *pma_cmn_vals, *pma_ln_vals;
447078e9e92SSwapnil Jakhade 	enum cdns_sierra_phy_type phy_type = ins->phy_type;
4481e902b2aSSwapnil Jakhade 	enum cdns_sierra_ssc_mode ssc = ins->ssc_mode;
449078e9e92SSwapnil Jakhade 	const struct cdns_reg_pairs *reg_pairs;
450fa105172SSwapnil Jakhade 	struct cdns_sierra_vals *pcs_cmn_vals;
45180f96fb1SColin Ian King 	struct regmap *regmap;
452078e9e92SSwapnil Jakhade 	u32 num_regs;
45344d30d62SAlan Douglas 	int i, j;
45444d30d62SAlan Douglas 
455cedcc2e2SKishon Vijay Abraham I 	/* Initialise the PHY registers, unless auto configured */
456cedcc2e2SKishon Vijay Abraham I 	if (phy->autoconf)
457cedcc2e2SKishon Vijay Abraham I 		return 0;
458cedcc2e2SKishon Vijay Abraham I 
459a0c30cd7SKishon Vijay Abraham I 	clk_set_rate(phy->input_clks[CMN_REFCLK_DIG_DIV], 25000000);
460a0c30cd7SKishon Vijay Abraham I 	clk_set_rate(phy->input_clks[CMN_REFCLK1_DIG_DIV], 25000000);
461078e9e92SSwapnil Jakhade 
462fa105172SSwapnil Jakhade 	/* PHY PCS common registers configurations */
463fa105172SSwapnil Jakhade 	pcs_cmn_vals = init_data->pcs_cmn_vals[phy_type][TYPE_NONE][ssc];
464fa105172SSwapnil Jakhade 	if (pcs_cmn_vals) {
465fa105172SSwapnil Jakhade 		reg_pairs = pcs_cmn_vals->reg_pairs;
466fa105172SSwapnil Jakhade 		num_regs = pcs_cmn_vals->num_regs;
467fa105172SSwapnil Jakhade 		regmap = phy->regmap_phy_pcs_common_cdb;
468fa105172SSwapnil Jakhade 		for (i = 0; i < num_regs; i++)
469fa105172SSwapnil Jakhade 			regmap_write(regmap, reg_pairs[i].off, reg_pairs[i].val);
470fa105172SSwapnil Jakhade 	}
471fa105172SSwapnil Jakhade 
472078e9e92SSwapnil Jakhade 	/* PMA common registers configurations */
473078e9e92SSwapnil Jakhade 	pma_cmn_vals = init_data->pma_cmn_vals[phy_type][TYPE_NONE][ssc];
474078e9e92SSwapnil Jakhade 	if (pma_cmn_vals) {
475078e9e92SSwapnil Jakhade 		reg_pairs = pma_cmn_vals->reg_pairs;
476078e9e92SSwapnil Jakhade 		num_regs = pma_cmn_vals->num_regs;
477078e9e92SSwapnil Jakhade 		regmap = phy->regmap_common_cdb;
478078e9e92SSwapnil Jakhade 		for (i = 0; i < num_regs; i++)
479078e9e92SSwapnil Jakhade 			regmap_write(regmap, reg_pairs[i].off, reg_pairs[i].val);
48044d30d62SAlan Douglas 	}
481871002d7SAnil Varughese 
482078e9e92SSwapnil Jakhade 	/* PMA lane registers configurations */
483078e9e92SSwapnil Jakhade 	pma_ln_vals = init_data->pma_ln_vals[phy_type][TYPE_NONE][ssc];
484078e9e92SSwapnil Jakhade 	if (pma_ln_vals) {
485078e9e92SSwapnil Jakhade 		reg_pairs = pma_ln_vals->reg_pairs;
486078e9e92SSwapnil Jakhade 		num_regs = pma_ln_vals->num_regs;
487380f5708SKishon Vijay Abraham I 		for (i = 0; i < ins->num_lanes; i++) {
488380f5708SKishon Vijay Abraham I 			regmap = phy->regmap_lane_cdb[i + ins->mlane];
489078e9e92SSwapnil Jakhade 			for (j = 0; j < num_regs; j++)
490078e9e92SSwapnil Jakhade 				regmap_write(regmap, reg_pairs[j].off, reg_pairs[j].val);
491380f5708SKishon Vijay Abraham I 		}
492380f5708SKishon Vijay Abraham I 	}
493cedcc2e2SKishon Vijay Abraham I 
494cedcc2e2SKishon Vijay Abraham I 	return 0;
49544d30d62SAlan Douglas }
49644d30d62SAlan Douglas 
49744d30d62SAlan Douglas static int cdns_sierra_phy_on(struct phy *gphy)
49844d30d62SAlan Douglas {
499adc4bd6fSKishon Vijay Abraham I 	struct cdns_sierra_phy *sp = dev_get_drvdata(gphy->dev.parent);
50044d30d62SAlan Douglas 	struct cdns_sierra_inst *ins = phy_get_drvdata(gphy);
501adc4bd6fSKishon Vijay Abraham I 	struct device *dev = sp->dev;
502adc4bd6fSKishon Vijay Abraham I 	u32 val;
503adc4bd6fSKishon Vijay Abraham I 	int ret;
50444d30d62SAlan Douglas 
5055b4f5757SKishon Vijay Abraham I 	ret = reset_control_deassert(sp->phy_rst);
5065b4f5757SKishon Vijay Abraham I 	if (ret) {
5075b4f5757SKishon Vijay Abraham I 		dev_err(dev, "Failed to take the PHY out of reset\n");
5085b4f5757SKishon Vijay Abraham I 		return ret;
5095b4f5757SKishon Vijay Abraham I 	}
5105b4f5757SKishon Vijay Abraham I 
51144d30d62SAlan Douglas 	/* Take the PHY lane group out of reset */
512adc4bd6fSKishon Vijay Abraham I 	ret = reset_control_deassert(ins->lnk_rst);
513adc4bd6fSKishon Vijay Abraham I 	if (ret) {
514adc4bd6fSKishon Vijay Abraham I 		dev_err(dev, "Failed to take the PHY lane out of reset\n");
515adc4bd6fSKishon Vijay Abraham I 		return ret;
516adc4bd6fSKishon Vijay Abraham I 	}
517adc4bd6fSKishon Vijay Abraham I 
51836ce4163SSwapnil Jakhade 	if (ins->phy_type == TYPE_PCIE || ins->phy_type == TYPE_USB) {
51936ce4163SSwapnil Jakhade 		ret = regmap_field_read_poll_timeout(sp->phy_iso_link_ctrl_1[ins->mlane],
52036ce4163SSwapnil Jakhade 						     val, !val, 1000, PLL_LOCK_TIME);
52136ce4163SSwapnil Jakhade 		if (ret) {
52236ce4163SSwapnil Jakhade 			dev_err(dev, "Timeout waiting for PHY status ready\n");
52336ce4163SSwapnil Jakhade 			return ret;
52436ce4163SSwapnil Jakhade 		}
52536ce4163SSwapnil Jakhade 	}
52636ce4163SSwapnil Jakhade 
527f1cc6c3fSSwapnil Jakhade 	/*
528f1cc6c3fSSwapnil Jakhade 	 * Wait for cmn_ready assertion
529f1cc6c3fSSwapnil Jakhade 	 * PHY_PMA_CMN_CTRL[0] == 1
530f1cc6c3fSSwapnil Jakhade 	 */
531f1cc6c3fSSwapnil Jakhade 	ret = regmap_field_read_poll_timeout(sp->pma_cmn_ready, val, val,
532f1cc6c3fSSwapnil Jakhade 					     1000, PLL_LOCK_TIME);
533f1cc6c3fSSwapnil Jakhade 	if (ret) {
534f1cc6c3fSSwapnil Jakhade 		dev_err(dev, "Timeout waiting for CMN ready\n");
535f1cc6c3fSSwapnil Jakhade 		return ret;
536f1cc6c3fSSwapnil Jakhade 	}
537f1cc6c3fSSwapnil Jakhade 
538adc4bd6fSKishon Vijay Abraham I 	ret = regmap_field_read_poll_timeout(sp->pllctrl_lock[ins->mlane],
539adc4bd6fSKishon Vijay Abraham I 					     val, val, 1000, PLL_LOCK_TIME);
540adc4bd6fSKishon Vijay Abraham I 	if (ret < 0)
541adc4bd6fSKishon Vijay Abraham I 		dev_err(dev, "PLL lock of lane failed\n");
542adc4bd6fSKishon Vijay Abraham I 
543adc4bd6fSKishon Vijay Abraham I 	return ret;
54444d30d62SAlan Douglas }
54544d30d62SAlan Douglas 
54644d30d62SAlan Douglas static int cdns_sierra_phy_off(struct phy *gphy)
54744d30d62SAlan Douglas {
54844d30d62SAlan Douglas 	struct cdns_sierra_inst *ins = phy_get_drvdata(gphy);
54944d30d62SAlan Douglas 
55044d30d62SAlan Douglas 	return reset_control_assert(ins->lnk_rst);
55144d30d62SAlan Douglas }
55244d30d62SAlan Douglas 
5537904e15bSRoger Quadros static int cdns_sierra_phy_reset(struct phy *gphy)
5547904e15bSRoger Quadros {
5557904e15bSRoger Quadros 	struct cdns_sierra_phy *sp = dev_get_drvdata(gphy->dev.parent);
5567904e15bSRoger Quadros 
5577904e15bSRoger Quadros 	reset_control_assert(sp->phy_rst);
5587904e15bSRoger Quadros 	reset_control_deassert(sp->phy_rst);
5597904e15bSRoger Quadros 	return 0;
5607904e15bSRoger Quadros };
5617904e15bSRoger Quadros 
56244d30d62SAlan Douglas static const struct phy_ops ops = {
563cedcc2e2SKishon Vijay Abraham I 	.init		= cdns_sierra_phy_init,
56444d30d62SAlan Douglas 	.power_on	= cdns_sierra_phy_on,
56544d30d62SAlan Douglas 	.power_off	= cdns_sierra_phy_off,
5667904e15bSRoger Quadros 	.reset		= cdns_sierra_phy_reset,
56744d30d62SAlan Douglas 	.owner		= THIS_MODULE,
56844d30d62SAlan Douglas };
56944d30d62SAlan Douglas 
57028081b72SKishon Vijay Abraham I static u8 cdns_sierra_pll_mux_get_parent(struct clk_hw *hw)
57128081b72SKishon Vijay Abraham I {
57228081b72SKishon Vijay Abraham I 	struct cdns_sierra_pll_mux *mux = to_cdns_sierra_pll_mux(hw);
573*da08aab9SSwapnil Jakhade 	struct regmap_field *plllc1en_field = mux->plllc1en_field;
574*da08aab9SSwapnil Jakhade 	struct regmap_field *termen_field = mux->termen_field;
57528081b72SKishon Vijay Abraham I 	struct regmap_field *field = mux->pfdclk_sel_preg;
57628081b72SKishon Vijay Abraham I 	unsigned int val;
577*da08aab9SSwapnil Jakhade 	int index;
57828081b72SKishon Vijay Abraham I 
57928081b72SKishon Vijay Abraham I 	regmap_field_read(field, &val);
580*da08aab9SSwapnil Jakhade 
581*da08aab9SSwapnil Jakhade 	if (strstr(clk_hw_get_name(hw), clk_names[CDNS_SIERRA_PLL_CMNLC1])) {
582*da08aab9SSwapnil Jakhade 		index = clk_mux_val_to_index(hw, cdns_sierra_pll_mux_table[CMN_PLLLC1], 0, val);
583*da08aab9SSwapnil Jakhade 		if (index == 1) {
584*da08aab9SSwapnil Jakhade 			regmap_field_write(plllc1en_field, 1);
585*da08aab9SSwapnil Jakhade 			regmap_field_write(termen_field, 1);
586*da08aab9SSwapnil Jakhade 		}
587*da08aab9SSwapnil Jakhade 	} else {
588*da08aab9SSwapnil Jakhade 		index = clk_mux_val_to_index(hw, cdns_sierra_pll_mux_table[CMN_PLLLC], 0, val);
589*da08aab9SSwapnil Jakhade 	}
590*da08aab9SSwapnil Jakhade 
591*da08aab9SSwapnil Jakhade 	return index;
59228081b72SKishon Vijay Abraham I }
59328081b72SKishon Vijay Abraham I 
59428081b72SKishon Vijay Abraham I static int cdns_sierra_pll_mux_set_parent(struct clk_hw *hw, u8 index)
59528081b72SKishon Vijay Abraham I {
59628081b72SKishon Vijay Abraham I 	struct cdns_sierra_pll_mux *mux = to_cdns_sierra_pll_mux(hw);
59728081b72SKishon Vijay Abraham I 	struct regmap_field *plllc1en_field = mux->plllc1en_field;
59828081b72SKishon Vijay Abraham I 	struct regmap_field *termen_field = mux->termen_field;
59928081b72SKishon Vijay Abraham I 	struct regmap_field *field = mux->pfdclk_sel_preg;
60028081b72SKishon Vijay Abraham I 	int val, ret;
60128081b72SKishon Vijay Abraham I 
60228081b72SKishon Vijay Abraham I 	ret = regmap_field_write(plllc1en_field, 0);
60328081b72SKishon Vijay Abraham I 	ret |= regmap_field_write(termen_field, 0);
60428081b72SKishon Vijay Abraham I 	if (index == 1) {
60528081b72SKishon Vijay Abraham I 		ret |= regmap_field_write(plllc1en_field, 1);
60628081b72SKishon Vijay Abraham I 		ret |= regmap_field_write(termen_field, 1);
60728081b72SKishon Vijay Abraham I 	}
60828081b72SKishon Vijay Abraham I 
609*da08aab9SSwapnil Jakhade 	if (strstr(clk_hw_get_name(hw), clk_names[CDNS_SIERRA_PLL_CMNLC1]))
610*da08aab9SSwapnil Jakhade 		val = cdns_sierra_pll_mux_table[CMN_PLLLC1][index];
611*da08aab9SSwapnil Jakhade 	else
612*da08aab9SSwapnil Jakhade 		val = cdns_sierra_pll_mux_table[CMN_PLLLC][index];
613*da08aab9SSwapnil Jakhade 
61428081b72SKishon Vijay Abraham I 	ret |= regmap_field_write(field, val);
61528081b72SKishon Vijay Abraham I 
61628081b72SKishon Vijay Abraham I 	return ret;
61728081b72SKishon Vijay Abraham I }
61828081b72SKishon Vijay Abraham I 
61928081b72SKishon Vijay Abraham I static const struct clk_ops cdns_sierra_pll_mux_ops = {
62028081b72SKishon Vijay Abraham I 	.set_parent = cdns_sierra_pll_mux_set_parent,
62128081b72SKishon Vijay Abraham I 	.get_parent = cdns_sierra_pll_mux_get_parent,
62228081b72SKishon Vijay Abraham I };
62328081b72SKishon Vijay Abraham I 
62428081b72SKishon Vijay Abraham I static int cdns_sierra_pll_mux_register(struct cdns_sierra_phy *sp,
62528081b72SKishon Vijay Abraham I 					struct regmap_field *pfdclk1_sel_field,
62628081b72SKishon Vijay Abraham I 					struct regmap_field *plllc1en_field,
62728081b72SKishon Vijay Abraham I 					struct regmap_field *termen_field,
62828081b72SKishon Vijay Abraham I 					int clk_index)
62928081b72SKishon Vijay Abraham I {
63028081b72SKishon Vijay Abraham I 	struct cdns_sierra_pll_mux *mux;
63128081b72SKishon Vijay Abraham I 	struct device *dev = sp->dev;
63228081b72SKishon Vijay Abraham I 	struct clk_init_data *init;
63328081b72SKishon Vijay Abraham I 	const char **parent_names;
63428081b72SKishon Vijay Abraham I 	unsigned int num_parents;
63528081b72SKishon Vijay Abraham I 	char clk_name[100];
63628081b72SKishon Vijay Abraham I 	struct clk *clk;
63728081b72SKishon Vijay Abraham I 	int i;
63828081b72SKishon Vijay Abraham I 
63928081b72SKishon Vijay Abraham I 	mux = devm_kzalloc(dev, sizeof(*mux), GFP_KERNEL);
64028081b72SKishon Vijay Abraham I 	if (!mux)
64128081b72SKishon Vijay Abraham I 		return -ENOMEM;
64228081b72SKishon Vijay Abraham I 
64328081b72SKishon Vijay Abraham I 	num_parents = SIERRA_NUM_CMN_PLLC_PARENTS;
64428081b72SKishon Vijay Abraham I 	parent_names = devm_kzalloc(dev, (sizeof(char *) * num_parents), GFP_KERNEL);
64528081b72SKishon Vijay Abraham I 	if (!parent_names)
64628081b72SKishon Vijay Abraham I 		return -ENOMEM;
64728081b72SKishon Vijay Abraham I 
64828081b72SKishon Vijay Abraham I 	for (i = 0; i < num_parents; i++) {
64928081b72SKishon Vijay Abraham I 		clk = sp->input_clks[pll_mux_parent_index[clk_index][i]];
65028081b72SKishon Vijay Abraham I 		if (IS_ERR_OR_NULL(clk)) {
651*da08aab9SSwapnil Jakhade 			dev_err(dev, "No parent clock for PLL mux clocks\n");
652*da08aab9SSwapnil Jakhade 			return IS_ERR(clk) ? PTR_ERR(clk) : -ENOENT;
65328081b72SKishon Vijay Abraham I 		}
65428081b72SKishon Vijay Abraham I 		parent_names[i] = __clk_get_name(clk);
65528081b72SKishon Vijay Abraham I 	}
65628081b72SKishon Vijay Abraham I 
65728081b72SKishon Vijay Abraham I 	snprintf(clk_name, sizeof(clk_name), "%s_%s", dev_name(dev), clk_names[clk_index]);
65828081b72SKishon Vijay Abraham I 
65928081b72SKishon Vijay Abraham I 	init = &mux->clk_data;
66028081b72SKishon Vijay Abraham I 
66128081b72SKishon Vijay Abraham I 	init->ops = &cdns_sierra_pll_mux_ops;
66228081b72SKishon Vijay Abraham I 	init->flags = CLK_SET_RATE_NO_REPARENT;
66328081b72SKishon Vijay Abraham I 	init->parent_names = parent_names;
66428081b72SKishon Vijay Abraham I 	init->num_parents = num_parents;
66528081b72SKishon Vijay Abraham I 	init->name = clk_name;
66628081b72SKishon Vijay Abraham I 
66728081b72SKishon Vijay Abraham I 	mux->pfdclk_sel_preg = pfdclk1_sel_field;
66828081b72SKishon Vijay Abraham I 	mux->plllc1en_field = plllc1en_field;
66928081b72SKishon Vijay Abraham I 	mux->termen_field = termen_field;
67028081b72SKishon Vijay Abraham I 	mux->hw.init = init;
67128081b72SKishon Vijay Abraham I 
67228081b72SKishon Vijay Abraham I 	clk = devm_clk_register(dev, &mux->hw);
67328081b72SKishon Vijay Abraham I 	if (IS_ERR(clk))
67428081b72SKishon Vijay Abraham I 		return PTR_ERR(clk);
67528081b72SKishon Vijay Abraham I 
67628081b72SKishon Vijay Abraham I 	sp->output_clks[clk_index] = clk;
67728081b72SKishon Vijay Abraham I 
67828081b72SKishon Vijay Abraham I 	return 0;
67928081b72SKishon Vijay Abraham I }
68028081b72SKishon Vijay Abraham I 
68128081b72SKishon Vijay Abraham I static int cdns_sierra_phy_register_pll_mux(struct cdns_sierra_phy *sp)
68228081b72SKishon Vijay Abraham I {
68328081b72SKishon Vijay Abraham I 	struct regmap_field *pfdclk1_sel_field;
68428081b72SKishon Vijay Abraham I 	struct regmap_field *plllc1en_field;
68528081b72SKishon Vijay Abraham I 	struct regmap_field *termen_field;
68628081b72SKishon Vijay Abraham I 	struct device *dev = sp->dev;
68728081b72SKishon Vijay Abraham I 	int ret = 0, i, clk_index;
68828081b72SKishon Vijay Abraham I 
68928081b72SKishon Vijay Abraham I 	clk_index = CDNS_SIERRA_PLL_CMNLC;
69028081b72SKishon Vijay Abraham I 	for (i = 0; i < SIERRA_NUM_CMN_PLLC; i++, clk_index++) {
69128081b72SKishon Vijay Abraham I 		pfdclk1_sel_field = sp->cmn_plllc_pfdclk1_sel_preg[i];
69228081b72SKishon Vijay Abraham I 		plllc1en_field = sp->cmn_refrcv_refclk_plllc1en_preg[i];
69328081b72SKishon Vijay Abraham I 		termen_field = sp->cmn_refrcv_refclk_termen_preg[i];
69428081b72SKishon Vijay Abraham I 
69528081b72SKishon Vijay Abraham I 		ret = cdns_sierra_pll_mux_register(sp, pfdclk1_sel_field, plllc1en_field,
69628081b72SKishon Vijay Abraham I 						   termen_field, clk_index);
69728081b72SKishon Vijay Abraham I 		if (ret) {
69828081b72SKishon Vijay Abraham I 			dev_err(dev, "Fail to register cmn plllc mux\n");
69928081b72SKishon Vijay Abraham I 			return ret;
70028081b72SKishon Vijay Abraham I 		}
70128081b72SKishon Vijay Abraham I 	}
70228081b72SKishon Vijay Abraham I 
70328081b72SKishon Vijay Abraham I 	return 0;
70428081b72SKishon Vijay Abraham I }
70528081b72SKishon Vijay Abraham I 
70628081b72SKishon Vijay Abraham I static void cdns_sierra_clk_unregister(struct cdns_sierra_phy *sp)
70728081b72SKishon Vijay Abraham I {
70828081b72SKishon Vijay Abraham I 	struct device *dev = sp->dev;
70928081b72SKishon Vijay Abraham I 	struct device_node *node = dev->of_node;
71028081b72SKishon Vijay Abraham I 
71128081b72SKishon Vijay Abraham I 	of_clk_del_provider(node);
71228081b72SKishon Vijay Abraham I }
71328081b72SKishon Vijay Abraham I 
71428081b72SKishon Vijay Abraham I static int cdns_sierra_clk_register(struct cdns_sierra_phy *sp)
71528081b72SKishon Vijay Abraham I {
71628081b72SKishon Vijay Abraham I 	struct device *dev = sp->dev;
71728081b72SKishon Vijay Abraham I 	struct device_node *node = dev->of_node;
71828081b72SKishon Vijay Abraham I 	int ret;
71928081b72SKishon Vijay Abraham I 
72028081b72SKishon Vijay Abraham I 	ret = cdns_sierra_phy_register_pll_mux(sp);
72128081b72SKishon Vijay Abraham I 	if (ret) {
72228081b72SKishon Vijay Abraham I 		dev_err(dev, "Failed to pll mux clocks\n");
72328081b72SKishon Vijay Abraham I 		return ret;
72428081b72SKishon Vijay Abraham I 	}
72528081b72SKishon Vijay Abraham I 
72628081b72SKishon Vijay Abraham I 	sp->clk_data.clks = sp->output_clks;
72728081b72SKishon Vijay Abraham I 	sp->clk_data.clk_num = CDNS_SIERRA_OUTPUT_CLOCKS;
72828081b72SKishon Vijay Abraham I 	ret = of_clk_add_provider(node, of_clk_src_onecell_get, &sp->clk_data);
72928081b72SKishon Vijay Abraham I 	if (ret)
73028081b72SKishon Vijay Abraham I 		dev_err(dev, "Failed to add clock provider: %s\n", node->name);
73128081b72SKishon Vijay Abraham I 
73228081b72SKishon Vijay Abraham I 	return ret;
73328081b72SKishon Vijay Abraham I }
73428081b72SKishon Vijay Abraham I 
73544d30d62SAlan Douglas static int cdns_sierra_get_optional(struct cdns_sierra_inst *inst,
73644d30d62SAlan Douglas 				    struct device_node *child)
73744d30d62SAlan Douglas {
738078e9e92SSwapnil Jakhade 	u32 phy_type;
739078e9e92SSwapnil Jakhade 
74044d30d62SAlan Douglas 	if (of_property_read_u32(child, "reg", &inst->mlane))
74144d30d62SAlan Douglas 		return -EINVAL;
74244d30d62SAlan Douglas 
74344d30d62SAlan Douglas 	if (of_property_read_u32(child, "cdns,num-lanes", &inst->num_lanes))
74444d30d62SAlan Douglas 		return -EINVAL;
74544d30d62SAlan Douglas 
746078e9e92SSwapnil Jakhade 	if (of_property_read_u32(child, "cdns,phy-type", &phy_type))
74744d30d62SAlan Douglas 		return -EINVAL;
74844d30d62SAlan Douglas 
749078e9e92SSwapnil Jakhade 	switch (phy_type) {
750078e9e92SSwapnil Jakhade 	case PHY_TYPE_PCIE:
751078e9e92SSwapnil Jakhade 		inst->phy_type = TYPE_PCIE;
752078e9e92SSwapnil Jakhade 		break;
753078e9e92SSwapnil Jakhade 	case PHY_TYPE_USB3:
754078e9e92SSwapnil Jakhade 		inst->phy_type = TYPE_USB;
755078e9e92SSwapnil Jakhade 		break;
756078e9e92SSwapnil Jakhade 	default:
757078e9e92SSwapnil Jakhade 		return -EINVAL;
758078e9e92SSwapnil Jakhade 	}
759078e9e92SSwapnil Jakhade 
7601e902b2aSSwapnil Jakhade 	inst->ssc_mode = EXTERNAL_SSC;
7611e902b2aSSwapnil Jakhade 	of_property_read_u32(child, "cdns,ssc-mode", &inst->ssc_mode);
7621e902b2aSSwapnil Jakhade 
76344d30d62SAlan Douglas 	return 0;
76444d30d62SAlan Douglas }
76544d30d62SAlan Douglas 
766380f5708SKishon Vijay Abraham I static struct regmap *cdns_regmap_init(struct device *dev, void __iomem *base,
767380f5708SKishon Vijay Abraham I 				       u32 block_offset, u8 reg_offset_shift,
768380f5708SKishon Vijay Abraham I 				       const struct regmap_config *config)
769380f5708SKishon Vijay Abraham I {
770380f5708SKishon Vijay Abraham I 	struct cdns_regmap_cdb_context *ctx;
771380f5708SKishon Vijay Abraham I 
772380f5708SKishon Vijay Abraham I 	ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
773380f5708SKishon Vijay Abraham I 	if (!ctx)
774380f5708SKishon Vijay Abraham I 		return ERR_PTR(-ENOMEM);
775380f5708SKishon Vijay Abraham I 
776380f5708SKishon Vijay Abraham I 	ctx->dev = dev;
777380f5708SKishon Vijay Abraham I 	ctx->base = base + block_offset;
778380f5708SKishon Vijay Abraham I 	ctx->reg_offset_shift = reg_offset_shift;
779380f5708SKishon Vijay Abraham I 
780380f5708SKishon Vijay Abraham I 	return devm_regmap_init(dev, NULL, ctx, config);
781380f5708SKishon Vijay Abraham I }
782380f5708SKishon Vijay Abraham I 
783380f5708SKishon Vijay Abraham I static int cdns_regfield_init(struct cdns_sierra_phy *sp)
784380f5708SKishon Vijay Abraham I {
785380f5708SKishon Vijay Abraham I 	struct device *dev = sp->dev;
786380f5708SKishon Vijay Abraham I 	struct regmap_field *field;
78728081b72SKishon Vijay Abraham I 	struct reg_field reg_field;
788380f5708SKishon Vijay Abraham I 	struct regmap *regmap;
789adc4bd6fSKishon Vijay Abraham I 	int i;
790380f5708SKishon Vijay Abraham I 
791380f5708SKishon Vijay Abraham I 	regmap = sp->regmap_common_cdb;
792380f5708SKishon Vijay Abraham I 	field = devm_regmap_field_alloc(dev, regmap, macro_id_type);
793380f5708SKishon Vijay Abraham I 	if (IS_ERR(field)) {
794380f5708SKishon Vijay Abraham I 		dev_err(dev, "MACRO_ID_TYPE reg field init failed\n");
795380f5708SKishon Vijay Abraham I 		return PTR_ERR(field);
796380f5708SKishon Vijay Abraham I 	}
797380f5708SKishon Vijay Abraham I 	sp->macro_id_type = field;
798380f5708SKishon Vijay Abraham I 
79928081b72SKishon Vijay Abraham I 	for (i = 0; i < SIERRA_NUM_CMN_PLLC; i++) {
80028081b72SKishon Vijay Abraham I 		reg_field = cmn_plllc_pfdclk1_sel_preg[i].pfdclk_sel_preg;
80128081b72SKishon Vijay Abraham I 		field = devm_regmap_field_alloc(dev, regmap, reg_field);
80228081b72SKishon Vijay Abraham I 		if (IS_ERR(field)) {
80328081b72SKishon Vijay Abraham I 			dev_err(dev, "PLLLC%d_PFDCLK1_SEL failed\n", i);
80428081b72SKishon Vijay Abraham I 			return PTR_ERR(field);
80528081b72SKishon Vijay Abraham I 		}
80628081b72SKishon Vijay Abraham I 		sp->cmn_plllc_pfdclk1_sel_preg[i] = field;
80728081b72SKishon Vijay Abraham I 
80828081b72SKishon Vijay Abraham I 		reg_field = cmn_plllc_pfdclk1_sel_preg[i].plllc1en_field;
80928081b72SKishon Vijay Abraham I 		field = devm_regmap_field_alloc(dev, regmap, reg_field);
81028081b72SKishon Vijay Abraham I 		if (IS_ERR(field)) {
81128081b72SKishon Vijay Abraham I 			dev_err(dev, "REFRCV%d_REFCLK_PLLLC1EN failed\n", i);
81228081b72SKishon Vijay Abraham I 			return PTR_ERR(field);
81328081b72SKishon Vijay Abraham I 		}
81428081b72SKishon Vijay Abraham I 		sp->cmn_refrcv_refclk_plllc1en_preg[i] = field;
81528081b72SKishon Vijay Abraham I 
81628081b72SKishon Vijay Abraham I 		reg_field = cmn_plllc_pfdclk1_sel_preg[i].termen_field;
81728081b72SKishon Vijay Abraham I 		field = devm_regmap_field_alloc(dev, regmap, reg_field);
81828081b72SKishon Vijay Abraham I 		if (IS_ERR(field)) {
81928081b72SKishon Vijay Abraham I 			dev_err(dev, "REFRCV%d_REFCLK_TERMEN failed\n", i);
82028081b72SKishon Vijay Abraham I 			return PTR_ERR(field);
82128081b72SKishon Vijay Abraham I 		}
82228081b72SKishon Vijay Abraham I 		sp->cmn_refrcv_refclk_termen_preg[i] = field;
82328081b72SKishon Vijay Abraham I 	}
82428081b72SKishon Vijay Abraham I 
8258c95e172SSwapnil Jakhade 	regmap = sp->regmap_phy_pcs_common_cdb;
826380f5708SKishon Vijay Abraham I 	field = devm_regmap_field_alloc(dev, regmap, phy_pll_cfg_1);
827380f5708SKishon Vijay Abraham I 	if (IS_ERR(field)) {
828380f5708SKishon Vijay Abraham I 		dev_err(dev, "PHY_PLL_CFG_1 reg field init failed\n");
829380f5708SKishon Vijay Abraham I 		return PTR_ERR(field);
830380f5708SKishon Vijay Abraham I 	}
831380f5708SKishon Vijay Abraham I 	sp->phy_pll_cfg_1 = field;
832380f5708SKishon Vijay Abraham I 
833f1cc6c3fSSwapnil Jakhade 	regmap = sp->regmap_phy_pma_common_cdb;
834f1cc6c3fSSwapnil Jakhade 	field = devm_regmap_field_alloc(dev, regmap, pma_cmn_ready);
835f1cc6c3fSSwapnil Jakhade 	if (IS_ERR(field)) {
836f1cc6c3fSSwapnil Jakhade 		dev_err(dev, "PHY_PMA_CMN_CTRL reg field init failed\n");
837f1cc6c3fSSwapnil Jakhade 		return PTR_ERR(field);
838f1cc6c3fSSwapnil Jakhade 	}
839f1cc6c3fSSwapnil Jakhade 	sp->pma_cmn_ready = field;
840f1cc6c3fSSwapnil Jakhade 
841adc4bd6fSKishon Vijay Abraham I 	for (i = 0; i < SIERRA_MAX_LANES; i++) {
842adc4bd6fSKishon Vijay Abraham I 		regmap = sp->regmap_lane_cdb[i];
843adc4bd6fSKishon Vijay Abraham I 		field = devm_regmap_field_alloc(dev, regmap, pllctrl_lock);
844adc4bd6fSKishon Vijay Abraham I 		if (IS_ERR(field)) {
845adc4bd6fSKishon Vijay Abraham I 			dev_err(dev, "P%d_ENABLE reg field init failed\n", i);
846adc4bd6fSKishon Vijay Abraham I 			return PTR_ERR(field);
847adc4bd6fSKishon Vijay Abraham I 		}
848adc4bd6fSKishon Vijay Abraham I 		sp->pllctrl_lock[i] = field;
849adc4bd6fSKishon Vijay Abraham I 	}
850adc4bd6fSKishon Vijay Abraham I 
85136ce4163SSwapnil Jakhade 	for (i = 0; i < SIERRA_MAX_LANES; i++) {
85236ce4163SSwapnil Jakhade 		regmap = sp->regmap_phy_pcs_lane_cdb[i];
85336ce4163SSwapnil Jakhade 		field = devm_regmap_field_alloc(dev, regmap, phy_iso_link_ctrl_1);
85436ce4163SSwapnil Jakhade 		if (IS_ERR(field)) {
85536ce4163SSwapnil Jakhade 			dev_err(dev, "PHY_ISO_LINK_CTRL reg field init for lane %d failed\n", i);
85636ce4163SSwapnil Jakhade 			return PTR_ERR(field);
85736ce4163SSwapnil Jakhade 		}
85836ce4163SSwapnil Jakhade 		sp->phy_iso_link_ctrl_1[i] = field;
85936ce4163SSwapnil Jakhade 	}
86036ce4163SSwapnil Jakhade 
861380f5708SKishon Vijay Abraham I 	return 0;
862380f5708SKishon Vijay Abraham I }
863380f5708SKishon Vijay Abraham I 
864380f5708SKishon Vijay Abraham I static int cdns_regmap_init_blocks(struct cdns_sierra_phy *sp,
865380f5708SKishon Vijay Abraham I 				   void __iomem *base, u8 block_offset_shift,
866380f5708SKishon Vijay Abraham I 				   u8 reg_offset_shift)
867380f5708SKishon Vijay Abraham I {
868380f5708SKishon Vijay Abraham I 	struct device *dev = sp->dev;
869380f5708SKishon Vijay Abraham I 	struct regmap *regmap;
870380f5708SKishon Vijay Abraham I 	u32 block_offset;
871380f5708SKishon Vijay Abraham I 	int i;
872380f5708SKishon Vijay Abraham I 
873380f5708SKishon Vijay Abraham I 	for (i = 0; i < SIERRA_MAX_LANES; i++) {
874380f5708SKishon Vijay Abraham I 		block_offset = SIERRA_LANE_CDB_OFFSET(i, block_offset_shift,
875380f5708SKishon Vijay Abraham I 						      reg_offset_shift);
876380f5708SKishon Vijay Abraham I 		regmap = cdns_regmap_init(dev, base, block_offset,
877380f5708SKishon Vijay Abraham I 					  reg_offset_shift,
878380f5708SKishon Vijay Abraham I 					  &cdns_sierra_lane_cdb_config[i]);
879380f5708SKishon Vijay Abraham I 		if (IS_ERR(regmap)) {
880380f5708SKishon Vijay Abraham I 			dev_err(dev, "Failed to init lane CDB regmap\n");
881380f5708SKishon Vijay Abraham I 			return PTR_ERR(regmap);
882380f5708SKishon Vijay Abraham I 		}
883380f5708SKishon Vijay Abraham I 		sp->regmap_lane_cdb[i] = regmap;
884380f5708SKishon Vijay Abraham I 	}
885380f5708SKishon Vijay Abraham I 
886380f5708SKishon Vijay Abraham I 	regmap = cdns_regmap_init(dev, base, SIERRA_COMMON_CDB_OFFSET,
887380f5708SKishon Vijay Abraham I 				  reg_offset_shift,
888380f5708SKishon Vijay Abraham I 				  &cdns_sierra_common_cdb_config);
889380f5708SKishon Vijay Abraham I 	if (IS_ERR(regmap)) {
890380f5708SKishon Vijay Abraham I 		dev_err(dev, "Failed to init common CDB regmap\n");
891380f5708SKishon Vijay Abraham I 		return PTR_ERR(regmap);
892380f5708SKishon Vijay Abraham I 	}
893380f5708SKishon Vijay Abraham I 	sp->regmap_common_cdb = regmap;
894380f5708SKishon Vijay Abraham I 
8958c95e172SSwapnil Jakhade 	block_offset = SIERRA_PHY_PCS_COMMON_OFFSET(block_offset_shift);
896380f5708SKishon Vijay Abraham I 	regmap = cdns_regmap_init(dev, base, block_offset, reg_offset_shift,
8978c95e172SSwapnil Jakhade 				  &cdns_sierra_phy_pcs_cmn_cdb_config);
898380f5708SKishon Vijay Abraham I 	if (IS_ERR(regmap)) {
8998c95e172SSwapnil Jakhade 		dev_err(dev, "Failed to init PHY PCS common CDB regmap\n");
900380f5708SKishon Vijay Abraham I 		return PTR_ERR(regmap);
901380f5708SKishon Vijay Abraham I 	}
9028c95e172SSwapnil Jakhade 	sp->regmap_phy_pcs_common_cdb = regmap;
903380f5708SKishon Vijay Abraham I 
90436ce4163SSwapnil Jakhade 	for (i = 0; i < SIERRA_MAX_LANES; i++) {
90536ce4163SSwapnil Jakhade 		block_offset = SIERRA_PHY_PCS_LANE_CDB_OFFSET(i, block_offset_shift,
90636ce4163SSwapnil Jakhade 							      reg_offset_shift);
90736ce4163SSwapnil Jakhade 		regmap = cdns_regmap_init(dev, base, block_offset,
90836ce4163SSwapnil Jakhade 					  reg_offset_shift,
90936ce4163SSwapnil Jakhade 					  &cdns_sierra_phy_pcs_lane_cdb_config[i]);
91036ce4163SSwapnil Jakhade 		if (IS_ERR(regmap)) {
91136ce4163SSwapnil Jakhade 			dev_err(dev, "Failed to init PHY PCS lane CDB regmap\n");
91236ce4163SSwapnil Jakhade 			return PTR_ERR(regmap);
91336ce4163SSwapnil Jakhade 		}
91436ce4163SSwapnil Jakhade 		sp->regmap_phy_pcs_lane_cdb[i] = regmap;
91536ce4163SSwapnil Jakhade 	}
91636ce4163SSwapnil Jakhade 
917f1cc6c3fSSwapnil Jakhade 	block_offset = SIERRA_PHY_PMA_COMMON_OFFSET(block_offset_shift);
918f1cc6c3fSSwapnil Jakhade 	regmap = cdns_regmap_init(dev, base, block_offset, reg_offset_shift,
919f1cc6c3fSSwapnil Jakhade 				  &cdns_sierra_phy_pma_cmn_cdb_config);
920f1cc6c3fSSwapnil Jakhade 	if (IS_ERR(regmap)) {
921f1cc6c3fSSwapnil Jakhade 		dev_err(dev, "Failed to init PHY PMA common CDB regmap\n");
922f1cc6c3fSSwapnil Jakhade 		return PTR_ERR(regmap);
923f1cc6c3fSSwapnil Jakhade 	}
924f1cc6c3fSSwapnil Jakhade 	sp->regmap_phy_pma_common_cdb = regmap;
925f1cc6c3fSSwapnil Jakhade 
926380f5708SKishon Vijay Abraham I 	return 0;
927380f5708SKishon Vijay Abraham I }
928380f5708SKishon Vijay Abraham I 
9297e016cbcSKishon Vijay Abraham I static int cdns_sierra_phy_get_clocks(struct cdns_sierra_phy *sp,
9307e016cbcSKishon Vijay Abraham I 				      struct device *dev)
9317e016cbcSKishon Vijay Abraham I {
9327e016cbcSKishon Vijay Abraham I 	struct clk *clk;
9337e016cbcSKishon Vijay Abraham I 	int ret;
9347e016cbcSKishon Vijay Abraham I 
9357e016cbcSKishon Vijay Abraham I 	clk = devm_clk_get_optional(dev, "phy_clk");
9367e016cbcSKishon Vijay Abraham I 	if (IS_ERR(clk)) {
9377e016cbcSKishon Vijay Abraham I 		dev_err(dev, "failed to get clock phy_clk\n");
9387e016cbcSKishon Vijay Abraham I 		return PTR_ERR(clk);
9397e016cbcSKishon Vijay Abraham I 	}
940a0c30cd7SKishon Vijay Abraham I 	sp->input_clks[PHY_CLK] = clk;
9417e016cbcSKishon Vijay Abraham I 
9427e016cbcSKishon Vijay Abraham I 	clk = devm_clk_get_optional(dev, "cmn_refclk_dig_div");
9437e016cbcSKishon Vijay Abraham I 	if (IS_ERR(clk)) {
9447e016cbcSKishon Vijay Abraham I 		dev_err(dev, "cmn_refclk_dig_div clock not found\n");
9457e016cbcSKishon Vijay Abraham I 		ret = PTR_ERR(clk);
9467e016cbcSKishon Vijay Abraham I 		return ret;
9477e016cbcSKishon Vijay Abraham I 	}
948a0c30cd7SKishon Vijay Abraham I 	sp->input_clks[CMN_REFCLK_DIG_DIV] = clk;
9497e016cbcSKishon Vijay Abraham I 
9507e016cbcSKishon Vijay Abraham I 	clk = devm_clk_get_optional(dev, "cmn_refclk1_dig_div");
9517e016cbcSKishon Vijay Abraham I 	if (IS_ERR(clk)) {
9527e016cbcSKishon Vijay Abraham I 		dev_err(dev, "cmn_refclk1_dig_div clock not found\n");
9537e016cbcSKishon Vijay Abraham I 		ret = PTR_ERR(clk);
9547e016cbcSKishon Vijay Abraham I 		return ret;
9557e016cbcSKishon Vijay Abraham I 	}
956a0c30cd7SKishon Vijay Abraham I 	sp->input_clks[CMN_REFCLK1_DIG_DIV] = clk;
9577e016cbcSKishon Vijay Abraham I 
95828081b72SKishon Vijay Abraham I 	clk = devm_clk_get_optional(dev, "pll0_refclk");
95928081b72SKishon Vijay Abraham I 	if (IS_ERR(clk)) {
96028081b72SKishon Vijay Abraham I 		dev_err(dev, "pll0_refclk clock not found\n");
96128081b72SKishon Vijay Abraham I 		ret = PTR_ERR(clk);
96228081b72SKishon Vijay Abraham I 		return ret;
96328081b72SKishon Vijay Abraham I 	}
96428081b72SKishon Vijay Abraham I 	sp->input_clks[PLL0_REFCLK] = clk;
96528081b72SKishon Vijay Abraham I 
96628081b72SKishon Vijay Abraham I 	clk = devm_clk_get_optional(dev, "pll1_refclk");
96728081b72SKishon Vijay Abraham I 	if (IS_ERR(clk)) {
96828081b72SKishon Vijay Abraham I 		dev_err(dev, "pll1_refclk clock not found\n");
96928081b72SKishon Vijay Abraham I 		ret = PTR_ERR(clk);
97028081b72SKishon Vijay Abraham I 		return ret;
97128081b72SKishon Vijay Abraham I 	}
97228081b72SKishon Vijay Abraham I 	sp->input_clks[PLL1_REFCLK] = clk;
97328081b72SKishon Vijay Abraham I 
9747e016cbcSKishon Vijay Abraham I 	return 0;
9757e016cbcSKishon Vijay Abraham I }
9767e016cbcSKishon Vijay Abraham I 
9771436ec30SKishon Vijay Abraham I static int cdns_sierra_phy_enable_clocks(struct cdns_sierra_phy *sp)
9781436ec30SKishon Vijay Abraham I {
9791436ec30SKishon Vijay Abraham I 	int ret;
9801436ec30SKishon Vijay Abraham I 
9811436ec30SKishon Vijay Abraham I 	ret = clk_prepare_enable(sp->input_clks[PHY_CLK]);
9821436ec30SKishon Vijay Abraham I 	if (ret)
9831436ec30SKishon Vijay Abraham I 		return ret;
9841436ec30SKishon Vijay Abraham I 
9851436ec30SKishon Vijay Abraham I 	ret = clk_prepare_enable(sp->output_clks[CDNS_SIERRA_PLL_CMNLC]);
9861436ec30SKishon Vijay Abraham I 	if (ret)
9871436ec30SKishon Vijay Abraham I 		goto err_pll_cmnlc;
9881436ec30SKishon Vijay Abraham I 
9891436ec30SKishon Vijay Abraham I 	ret = clk_prepare_enable(sp->output_clks[CDNS_SIERRA_PLL_CMNLC1]);
9901436ec30SKishon Vijay Abraham I 	if (ret)
9911436ec30SKishon Vijay Abraham I 		goto err_pll_cmnlc1;
9921436ec30SKishon Vijay Abraham I 
9931436ec30SKishon Vijay Abraham I 	return 0;
9941436ec30SKishon Vijay Abraham I 
9951436ec30SKishon Vijay Abraham I err_pll_cmnlc1:
9961436ec30SKishon Vijay Abraham I 	clk_disable_unprepare(sp->output_clks[CDNS_SIERRA_PLL_CMNLC]);
9971436ec30SKishon Vijay Abraham I 
9981436ec30SKishon Vijay Abraham I err_pll_cmnlc:
9991436ec30SKishon Vijay Abraham I 	clk_disable_unprepare(sp->input_clks[PHY_CLK]);
10001436ec30SKishon Vijay Abraham I 
10011436ec30SKishon Vijay Abraham I 	return ret;
10021436ec30SKishon Vijay Abraham I }
10031436ec30SKishon Vijay Abraham I 
10041436ec30SKishon Vijay Abraham I static void cdns_sierra_phy_disable_clocks(struct cdns_sierra_phy *sp)
10051436ec30SKishon Vijay Abraham I {
10061436ec30SKishon Vijay Abraham I 	clk_disable_unprepare(sp->output_clks[CDNS_SIERRA_PLL_CMNLC1]);
10071436ec30SKishon Vijay Abraham I 	clk_disable_unprepare(sp->output_clks[CDNS_SIERRA_PLL_CMNLC]);
10081436ec30SKishon Vijay Abraham I 	clk_disable_unprepare(sp->input_clks[PHY_CLK]);
10091436ec30SKishon Vijay Abraham I }
10101436ec30SKishon Vijay Abraham I 
10111d5f40e0SKishon Vijay Abraham I static int cdns_sierra_phy_get_resets(struct cdns_sierra_phy *sp,
10121d5f40e0SKishon Vijay Abraham I 				      struct device *dev)
10131d5f40e0SKishon Vijay Abraham I {
10141d5f40e0SKishon Vijay Abraham I 	struct reset_control *rst;
10151d5f40e0SKishon Vijay Abraham I 
101615b0b82dSKishon Vijay Abraham I 	rst = devm_reset_control_get_exclusive(dev, "sierra_reset");
10171d5f40e0SKishon Vijay Abraham I 	if (IS_ERR(rst)) {
10181d5f40e0SKishon Vijay Abraham I 		dev_err(dev, "failed to get reset\n");
10191d5f40e0SKishon Vijay Abraham I 		return PTR_ERR(rst);
10201d5f40e0SKishon Vijay Abraham I 	}
10211d5f40e0SKishon Vijay Abraham I 	sp->phy_rst = rst;
10221d5f40e0SKishon Vijay Abraham I 
102315b0b82dSKishon Vijay Abraham I 	rst = devm_reset_control_get_optional_exclusive(dev, "sierra_apb");
10241d5f40e0SKishon Vijay Abraham I 	if (IS_ERR(rst)) {
10251d5f40e0SKishon Vijay Abraham I 		dev_err(dev, "failed to get apb reset\n");
10261d5f40e0SKishon Vijay Abraham I 		return PTR_ERR(rst);
10271d5f40e0SKishon Vijay Abraham I 	}
10281d5f40e0SKishon Vijay Abraham I 	sp->apb_rst = rst;
10291d5f40e0SKishon Vijay Abraham I 
10301d5f40e0SKishon Vijay Abraham I 	return 0;
10311d5f40e0SKishon Vijay Abraham I }
10321d5f40e0SKishon Vijay Abraham I 
103344d30d62SAlan Douglas static int cdns_sierra_phy_probe(struct platform_device *pdev)
103444d30d62SAlan Douglas {
103544d30d62SAlan Douglas 	struct cdns_sierra_phy *sp;
103644d30d62SAlan Douglas 	struct phy_provider *phy_provider;
103744d30d62SAlan Douglas 	struct device *dev = &pdev->dev;
1038c3c11d55SSwapnil Jakhade 	const struct cdns_sierra_data *data;
1039380f5708SKishon Vijay Abraham I 	unsigned int id_value;
104044d30d62SAlan Douglas 	int i, ret, node = 0;
1041380f5708SKishon Vijay Abraham I 	void __iomem *base;
104244d30d62SAlan Douglas 	struct device_node *dn = dev->of_node, *child;
104344d30d62SAlan Douglas 
104444d30d62SAlan Douglas 	if (of_get_child_count(dn) == 0)
104544d30d62SAlan Douglas 		return -ENODEV;
104644d30d62SAlan Douglas 
1047380f5708SKishon Vijay Abraham I 	/* Get init data for this PHY */
1048c3c11d55SSwapnil Jakhade 	data = of_device_get_match_data(dev);
1049c3c11d55SSwapnil Jakhade 	if (!data)
1050380f5708SKishon Vijay Abraham I 		return -EINVAL;
1051380f5708SKishon Vijay Abraham I 
105244d30d62SAlan Douglas 	sp = devm_kzalloc(dev, sizeof(*sp), GFP_KERNEL);
105344d30d62SAlan Douglas 	if (!sp)
105444d30d62SAlan Douglas 		return -ENOMEM;
105544d30d62SAlan Douglas 	dev_set_drvdata(dev, sp);
105644d30d62SAlan Douglas 	sp->dev = dev;
1057380f5708SKishon Vijay Abraham I 	sp->init_data = data;
105844d30d62SAlan Douglas 
1059fa629094SChunfeng Yun 	base = devm_platform_ioremap_resource(pdev, 0);
1060380f5708SKishon Vijay Abraham I 	if (IS_ERR(base)) {
106144d30d62SAlan Douglas 		dev_err(dev, "missing \"reg\"\n");
1062380f5708SKishon Vijay Abraham I 		return PTR_ERR(base);
106344d30d62SAlan Douglas 	}
106444d30d62SAlan Douglas 
1065380f5708SKishon Vijay Abraham I 	ret = cdns_regmap_init_blocks(sp, base, data->block_offset_shift,
1066380f5708SKishon Vijay Abraham I 				      data->reg_offset_shift);
1067380f5708SKishon Vijay Abraham I 	if (ret)
1068380f5708SKishon Vijay Abraham I 		return ret;
1069380f5708SKishon Vijay Abraham I 
1070380f5708SKishon Vijay Abraham I 	ret = cdns_regfield_init(sp);
1071380f5708SKishon Vijay Abraham I 	if (ret)
1072380f5708SKishon Vijay Abraham I 		return ret;
107344d30d62SAlan Douglas 
107444d30d62SAlan Douglas 	platform_set_drvdata(pdev, sp);
107544d30d62SAlan Douglas 
10767e016cbcSKishon Vijay Abraham I 	ret = cdns_sierra_phy_get_clocks(sp, dev);
10777e016cbcSKishon Vijay Abraham I 	if (ret)
10787e016cbcSKishon Vijay Abraham I 		return ret;
107944d30d62SAlan Douglas 
108028081b72SKishon Vijay Abraham I 	ret = cdns_sierra_clk_register(sp);
10811d5f40e0SKishon Vijay Abraham I 	if (ret)
10821d5f40e0SKishon Vijay Abraham I 		return ret;
108344d30d62SAlan Douglas 
108428081b72SKishon Vijay Abraham I 	ret = cdns_sierra_phy_get_resets(sp, dev);
108528081b72SKishon Vijay Abraham I 	if (ret)
108628081b72SKishon Vijay Abraham I 		goto unregister_clk;
108728081b72SKishon Vijay Abraham I 
10881436ec30SKishon Vijay Abraham I 	ret = cdns_sierra_phy_enable_clocks(sp);
108944d30d62SAlan Douglas 	if (ret)
109028081b72SKishon Vijay Abraham I 		goto unregister_clk;
109144d30d62SAlan Douglas 
109244d30d62SAlan Douglas 	/* Enable APB */
109344d30d62SAlan Douglas 	reset_control_deassert(sp->apb_rst);
109444d30d62SAlan Douglas 
109544d30d62SAlan Douglas 	/* Check that PHY is present */
1096380f5708SKishon Vijay Abraham I 	regmap_field_read(sp->macro_id_type, &id_value);
1097380f5708SKishon Vijay Abraham I 	if  (sp->init_data->id_value != id_value) {
109844d30d62SAlan Douglas 		ret = -EINVAL;
109944d30d62SAlan Douglas 		goto clk_disable;
110044d30d62SAlan Douglas 	}
110144d30d62SAlan Douglas 
110244d30d62SAlan Douglas 	sp->autoconf = of_property_read_bool(dn, "cdns,autoconf");
110344d30d62SAlan Douglas 
110444d30d62SAlan Douglas 	for_each_available_child_of_node(dn, child) {
110544d30d62SAlan Douglas 		struct phy *gphy;
110644d30d62SAlan Douglas 
110703ada5a3SKishon Vijay Abraham I 		if (!(of_node_name_eq(child, "phy") ||
110803ada5a3SKishon Vijay Abraham I 		      of_node_name_eq(child, "link")))
110903ada5a3SKishon Vijay Abraham I 			continue;
111003ada5a3SKishon Vijay Abraham I 
111144d30d62SAlan Douglas 		sp->phys[node].lnk_rst =
1112b872936fSKishon Vijay Abraham I 			of_reset_control_array_get_exclusive(child);
111344d30d62SAlan Douglas 
111444d30d62SAlan Douglas 		if (IS_ERR(sp->phys[node].lnk_rst)) {
111544d30d62SAlan Douglas 			dev_err(dev, "failed to get reset %s\n",
111644d30d62SAlan Douglas 				child->full_name);
111744d30d62SAlan Douglas 			ret = PTR_ERR(sp->phys[node].lnk_rst);
111844d30d62SAlan Douglas 			goto put_child2;
111944d30d62SAlan Douglas 		}
112044d30d62SAlan Douglas 
112144d30d62SAlan Douglas 		if (!sp->autoconf) {
112244d30d62SAlan Douglas 			ret = cdns_sierra_get_optional(&sp->phys[node], child);
112344d30d62SAlan Douglas 			if (ret) {
112444d30d62SAlan Douglas 				dev_err(dev, "missing property in node %s\n",
112544d30d62SAlan Douglas 					child->name);
112644d30d62SAlan Douglas 				goto put_child;
112744d30d62SAlan Douglas 			}
112844d30d62SAlan Douglas 		}
112944d30d62SAlan Douglas 
1130a43f72aeSKishon Vijay Abraham I 		sp->num_lanes += sp->phys[node].num_lanes;
1131a43f72aeSKishon Vijay Abraham I 
113244d30d62SAlan Douglas 		gphy = devm_phy_create(dev, child, &ops);
113344d30d62SAlan Douglas 
113444d30d62SAlan Douglas 		if (IS_ERR(gphy)) {
113544d30d62SAlan Douglas 			ret = PTR_ERR(gphy);
113644d30d62SAlan Douglas 			goto put_child;
113744d30d62SAlan Douglas 		}
113844d30d62SAlan Douglas 		sp->phys[node].phy = gphy;
113944d30d62SAlan Douglas 		phy_set_drvdata(gphy, &sp->phys[node]);
114044d30d62SAlan Douglas 
114144d30d62SAlan Douglas 		node++;
114244d30d62SAlan Douglas 	}
114344d30d62SAlan Douglas 	sp->nsubnodes = node;
114444d30d62SAlan Douglas 
1145a43f72aeSKishon Vijay Abraham I 	if (sp->num_lanes > SIERRA_MAX_LANES) {
11466411e386SWang Wensheng 		ret = -EINVAL;
1147a43f72aeSKishon Vijay Abraham I 		dev_err(dev, "Invalid lane configuration\n");
1148a43f72aeSKishon Vijay Abraham I 		goto put_child2;
1149a43f72aeSKishon Vijay Abraham I 	}
1150a43f72aeSKishon Vijay Abraham I 
115144d30d62SAlan Douglas 	/* If more than one subnode, configure the PHY as multilink */
115244d30d62SAlan Douglas 	if (!sp->autoconf && sp->nsubnodes > 1)
1153380f5708SKishon Vijay Abraham I 		regmap_field_write(sp->phy_pll_cfg_1, 0x1);
115444d30d62SAlan Douglas 
115544d30d62SAlan Douglas 	pm_runtime_enable(dev);
115644d30d62SAlan Douglas 	phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
115744d30d62SAlan Douglas 	return PTR_ERR_OR_ZERO(phy_provider);
115844d30d62SAlan Douglas 
115944d30d62SAlan Douglas put_child:
116044d30d62SAlan Douglas 	node++;
116144d30d62SAlan Douglas put_child2:
116244d30d62SAlan Douglas 	for (i = 0; i < node; i++)
116344d30d62SAlan Douglas 		reset_control_put(sp->phys[i].lnk_rst);
116444d30d62SAlan Douglas 	of_node_put(child);
116544d30d62SAlan Douglas clk_disable:
11661436ec30SKishon Vijay Abraham I 	cdns_sierra_phy_disable_clocks(sp);
116744d30d62SAlan Douglas 	reset_control_assert(sp->apb_rst);
116828081b72SKishon Vijay Abraham I unregister_clk:
116928081b72SKishon Vijay Abraham I 	cdns_sierra_clk_unregister(sp);
117044d30d62SAlan Douglas 	return ret;
117144d30d62SAlan Douglas }
117244d30d62SAlan Douglas 
117344d30d62SAlan Douglas static int cdns_sierra_phy_remove(struct platform_device *pdev)
117444d30d62SAlan Douglas {
1175748e3456SKishon Vijay Abraham I 	struct cdns_sierra_phy *phy = platform_get_drvdata(pdev);
117644d30d62SAlan Douglas 	int i;
117744d30d62SAlan Douglas 
117844d30d62SAlan Douglas 	reset_control_assert(phy->phy_rst);
117944d30d62SAlan Douglas 	reset_control_assert(phy->apb_rst);
118044d30d62SAlan Douglas 	pm_runtime_disable(&pdev->dev);
118144d30d62SAlan Douglas 
11821436ec30SKishon Vijay Abraham I 	cdns_sierra_phy_disable_clocks(phy);
118344d30d62SAlan Douglas 	/*
118444d30d62SAlan Douglas 	 * The device level resets will be put automatically.
118544d30d62SAlan Douglas 	 * Need to put the subnode resets here though.
118644d30d62SAlan Douglas 	 */
118744d30d62SAlan Douglas 	for (i = 0; i < phy->nsubnodes; i++) {
118844d30d62SAlan Douglas 		reset_control_assert(phy->phys[i].lnk_rst);
118944d30d62SAlan Douglas 		reset_control_put(phy->phys[i].lnk_rst);
119044d30d62SAlan Douglas 	}
119129c2d02aSKishon Vijay Abraham I 
119228081b72SKishon Vijay Abraham I 	cdns_sierra_clk_unregister(phy);
119329c2d02aSKishon Vijay Abraham I 
119444d30d62SAlan Douglas 	return 0;
119544d30d62SAlan Douglas }
119644d30d62SAlan Douglas 
1197fa105172SSwapnil Jakhade /* PCIE PHY PCS common configuration */
1198fa105172SSwapnil Jakhade static struct cdns_reg_pairs pcie_phy_pcs_cmn_regs[] = {
1199fa105172SSwapnil Jakhade 	{0x0430, SIERRA_PHY_PIPE_CMN_CTRL1}
1200fa105172SSwapnil Jakhade };
1201fa105172SSwapnil Jakhade 
1202fa105172SSwapnil Jakhade static struct cdns_sierra_vals pcie_phy_pcs_cmn_vals = {
1203fa105172SSwapnil Jakhade 	.reg_pairs = pcie_phy_pcs_cmn_regs,
1204fa105172SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(pcie_phy_pcs_cmn_regs),
1205fa105172SSwapnil Jakhade };
1206fa105172SSwapnil Jakhade 
12077a5ad9b4SSwapnil Jakhade /* refclk100MHz_32b_PCIe_cmn_pll_no_ssc */
12087a5ad9b4SSwapnil Jakhade static const struct cdns_reg_pairs cdns_pcie_cmn_regs_no_ssc[] = {
12097a5ad9b4SSwapnil Jakhade 	{0x2105, SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG},
12107a5ad9b4SSwapnil Jakhade 	{0x2105, SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG},
12117a5ad9b4SSwapnil Jakhade 	{0x8A06, SIERRA_CMN_PLLLC_BWCAL_MODE1_PREG},
12127a5ad9b4SSwapnil Jakhade 	{0x8A06, SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG}
12137a5ad9b4SSwapnil Jakhade };
12147a5ad9b4SSwapnil Jakhade 
12157a5ad9b4SSwapnil Jakhade /* refclk100MHz_32b_PCIe_ln_no_ssc */
12167a5ad9b4SSwapnil Jakhade static const struct cdns_reg_pairs cdns_pcie_ln_regs_no_ssc[] = {
12177a5ad9b4SSwapnil Jakhade 	{0xFC08, SIERRA_DET_STANDEC_A_PREG},
12187a5ad9b4SSwapnil Jakhade 	{0x001D, SIERRA_PSM_A3IN_TMR_PREG},
12197a5ad9b4SSwapnil Jakhade 	{0x1555, SIERRA_DFE_BIASTRIM_PREG},
12207a5ad9b4SSwapnil Jakhade 	{0x9703, SIERRA_DRVCTRL_BOOST_PREG},
12217a5ad9b4SSwapnil Jakhade 	{0x8055, SIERRA_RX_CREQ_FLTR_A_MODE3_PREG},
12227a5ad9b4SSwapnil Jakhade 	{0x80BB, SIERRA_RX_CREQ_FLTR_A_MODE2_PREG},
12237a5ad9b4SSwapnil Jakhade 	{0x8351, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG},
12247a5ad9b4SSwapnil Jakhade 	{0x8349, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
12257a5ad9b4SSwapnil Jakhade 	{0x0002, SIERRA_CREQ_DCBIASATTEN_OVR_PREG},
12267a5ad9b4SSwapnil Jakhade 	{0x9800, SIERRA_RX_CTLE_CAL_PREG},
12277a5ad9b4SSwapnil Jakhade 	{0x5624, SIERRA_DEQ_CONCUR_CTRL2_PREG},
12287a5ad9b4SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_EPIPWR_CTRL2_PREG},
12297a5ad9b4SSwapnil Jakhade 	{0x00FF, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG},
12307a5ad9b4SSwapnil Jakhade 	{0x4C4C, SIERRA_DEQ_ERRCMP_CTRL_PREG},
12317a5ad9b4SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_OFFSET_CTRL_PREG},
12327a5ad9b4SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_GAIN_CTRL_PREG},
12337a5ad9b4SSwapnil Jakhade 	{0x0041, SIERRA_DEQ_GLUT0},
12347a5ad9b4SSwapnil Jakhade 	{0x0082, SIERRA_DEQ_GLUT1},
12357a5ad9b4SSwapnil Jakhade 	{0x00C3, SIERRA_DEQ_GLUT2},
12367a5ad9b4SSwapnil Jakhade 	{0x0145, SIERRA_DEQ_GLUT3},
12377a5ad9b4SSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT4},
12387a5ad9b4SSwapnil Jakhade 	{0x09E7, SIERRA_DEQ_ALUT0},
12397a5ad9b4SSwapnil Jakhade 	{0x09A6, SIERRA_DEQ_ALUT1},
12407a5ad9b4SSwapnil Jakhade 	{0x0965, SIERRA_DEQ_ALUT2},
12417a5ad9b4SSwapnil Jakhade 	{0x08E3, SIERRA_DEQ_ALUT3},
12427a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP0},
12437a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP1},
12447a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP2},
12457a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP3},
12467a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP4},
12477a5ad9b4SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_PRECUR_PREG},
12487a5ad9b4SSwapnil Jakhade 	{0x0280, SIERRA_DEQ_POSTCUR_PREG},
12497a5ad9b4SSwapnil Jakhade 	{0x8F00, SIERRA_DEQ_POSTCUR_DECR_PREG},
12507a5ad9b4SSwapnil Jakhade 	{0x3C0F, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG},
12517a5ad9b4SSwapnil Jakhade 	{0x1C0C, SIERRA_DEQ_TAU_CTRL2_PREG},
12527a5ad9b4SSwapnil Jakhade 	{0x0100, SIERRA_DEQ_TAU_CTRL3_PREG},
12537a5ad9b4SSwapnil Jakhade 	{0x5E82, SIERRA_DEQ_OPENEYE_CTRL_PREG},
12547a5ad9b4SSwapnil Jakhade 	{0x002B, SIERRA_CPI_TRIM_PREG},
12557a5ad9b4SSwapnil Jakhade 	{0x0003, SIERRA_EPI_CTRL_PREG},
12567a5ad9b4SSwapnil Jakhade 	{0x803F, SIERRA_SDFILT_H2L_A_PREG},
12577a5ad9b4SSwapnil Jakhade 	{0x0004, SIERRA_RXBUFFER_CTLECTRL_PREG},
12587a5ad9b4SSwapnil Jakhade 	{0x2010, SIERRA_RXBUFFER_RCDFECTRL_PREG},
12597a5ad9b4SSwapnil Jakhade 	{0x4432, SIERRA_RXBUFFER_DFECTRL_PREG}
12607a5ad9b4SSwapnil Jakhade };
12617a5ad9b4SSwapnil Jakhade 
12627a5ad9b4SSwapnil Jakhade static struct cdns_sierra_vals pcie_100_no_ssc_cmn_vals = {
12637a5ad9b4SSwapnil Jakhade 	.reg_pairs = cdns_pcie_cmn_regs_no_ssc,
12647a5ad9b4SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(cdns_pcie_cmn_regs_no_ssc),
12657a5ad9b4SSwapnil Jakhade };
12667a5ad9b4SSwapnil Jakhade 
12677a5ad9b4SSwapnil Jakhade static struct cdns_sierra_vals pcie_100_no_ssc_ln_vals = {
12687a5ad9b4SSwapnil Jakhade 	.reg_pairs = cdns_pcie_ln_regs_no_ssc,
12697a5ad9b4SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(cdns_pcie_ln_regs_no_ssc),
12707a5ad9b4SSwapnil Jakhade };
12717a5ad9b4SSwapnil Jakhade 
12727a5ad9b4SSwapnil Jakhade /* refclk100MHz_32b_PCIe_cmn_pll_int_ssc */
12737a5ad9b4SSwapnil Jakhade static const struct cdns_reg_pairs cdns_pcie_cmn_regs_int_ssc[] = {
12747a5ad9b4SSwapnil Jakhade 	{0x000E, SIERRA_CMN_PLLLC_MODE_PREG},
12757a5ad9b4SSwapnil Jakhade 	{0x4006, SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG},
12767a5ad9b4SSwapnil Jakhade 	{0x4006, SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG},
12777a5ad9b4SSwapnil Jakhade 	{0x0000, SIERRA_CMN_PLLLC_BWCAL_MODE1_PREG},
12787a5ad9b4SSwapnil Jakhade 	{0x0000, SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG},
12797a5ad9b4SSwapnil Jakhade 	{0x0581, SIERRA_CMN_PLLLC_DSMCORR_PREG},
12807a5ad9b4SSwapnil Jakhade 	{0x7F80, SIERRA_CMN_PLLLC_SS_PREG},
12817a5ad9b4SSwapnil Jakhade 	{0x0041, SIERRA_CMN_PLLLC_SS_AMP_STEP_SIZE_PREG},
12827a5ad9b4SSwapnil Jakhade 	{0x0464, SIERRA_CMN_PLLLC_SSTWOPT_PREG},
12837a5ad9b4SSwapnil Jakhade 	{0x0D0D, SIERRA_CMN_PLLLC_SS_TIME_STEPSIZE_MODE_PREG},
12847a5ad9b4SSwapnil Jakhade 	{0x0060, SIERRA_CMN_PLLLC_LOCK_DELAY_CTRL_PREG}
12857a5ad9b4SSwapnil Jakhade };
12867a5ad9b4SSwapnil Jakhade 
12877a5ad9b4SSwapnil Jakhade /* refclk100MHz_32b_PCIe_ln_int_ssc */
12887a5ad9b4SSwapnil Jakhade static const struct cdns_reg_pairs cdns_pcie_ln_regs_int_ssc[] = {
12897a5ad9b4SSwapnil Jakhade 	{0xFC08, SIERRA_DET_STANDEC_A_PREG},
12907a5ad9b4SSwapnil Jakhade 	{0x001D, SIERRA_PSM_A3IN_TMR_PREG},
12917a5ad9b4SSwapnil Jakhade 	{0x1555, SIERRA_DFE_BIASTRIM_PREG},
12927a5ad9b4SSwapnil Jakhade 	{0x9703, SIERRA_DRVCTRL_BOOST_PREG},
12937a5ad9b4SSwapnil Jakhade 	{0x813E, SIERRA_CLKPATHCTRL_TMR_PREG},
12947a5ad9b4SSwapnil Jakhade 	{0x8047, SIERRA_RX_CREQ_FLTR_A_MODE3_PREG},
12957a5ad9b4SSwapnil Jakhade 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE2_PREG},
12967a5ad9b4SSwapnil Jakhade 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG},
12977a5ad9b4SSwapnil Jakhade 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
12987a5ad9b4SSwapnil Jakhade 	{0x0002, SIERRA_CREQ_DCBIASATTEN_OVR_PREG},
12997a5ad9b4SSwapnil Jakhade 	{0x9800, SIERRA_RX_CTLE_CAL_PREG},
13007a5ad9b4SSwapnil Jakhade 	{0x033C, SIERRA_RX_CTLE_MAINTENANCE_PREG},
13017a5ad9b4SSwapnil Jakhade 	{0x44CC, SIERRA_CREQ_EQ_OPEN_EYE_THRESH_PREG},
13027a5ad9b4SSwapnil Jakhade 	{0x5624, SIERRA_DEQ_CONCUR_CTRL2_PREG},
13037a5ad9b4SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_EPIPWR_CTRL2_PREG},
13047a5ad9b4SSwapnil Jakhade 	{0x00FF, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG},
13057a5ad9b4SSwapnil Jakhade 	{0x4C4C, SIERRA_DEQ_ERRCMP_CTRL_PREG},
13067a5ad9b4SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_OFFSET_CTRL_PREG},
13077a5ad9b4SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_GAIN_CTRL_PREG},
13087a5ad9b4SSwapnil Jakhade 	{0x0041, SIERRA_DEQ_GLUT0},
13097a5ad9b4SSwapnil Jakhade 	{0x0082, SIERRA_DEQ_GLUT1},
13107a5ad9b4SSwapnil Jakhade 	{0x00C3, SIERRA_DEQ_GLUT2},
13117a5ad9b4SSwapnil Jakhade 	{0x0145, SIERRA_DEQ_GLUT3},
13127a5ad9b4SSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT4},
13137a5ad9b4SSwapnil Jakhade 	{0x09E7, SIERRA_DEQ_ALUT0},
13147a5ad9b4SSwapnil Jakhade 	{0x09A6, SIERRA_DEQ_ALUT1},
13157a5ad9b4SSwapnil Jakhade 	{0x0965, SIERRA_DEQ_ALUT2},
13167a5ad9b4SSwapnil Jakhade 	{0x08E3, SIERRA_DEQ_ALUT3},
13177a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP0},
13187a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP1},
13197a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP2},
13207a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP3},
13217a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP4},
13227a5ad9b4SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_PRECUR_PREG},
13237a5ad9b4SSwapnil Jakhade 	{0x0280, SIERRA_DEQ_POSTCUR_PREG},
13247a5ad9b4SSwapnil Jakhade 	{0x8F00, SIERRA_DEQ_POSTCUR_DECR_PREG},
13257a5ad9b4SSwapnil Jakhade 	{0x3C0F, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG},
13267a5ad9b4SSwapnil Jakhade 	{0x1C0C, SIERRA_DEQ_TAU_CTRL2_PREG},
13277a5ad9b4SSwapnil Jakhade 	{0x0100, SIERRA_DEQ_TAU_CTRL3_PREG},
13287a5ad9b4SSwapnil Jakhade 	{0x5E82, SIERRA_DEQ_OPENEYE_CTRL_PREG},
13297a5ad9b4SSwapnil Jakhade 	{0x002B, SIERRA_CPI_TRIM_PREG},
13307a5ad9b4SSwapnil Jakhade 	{0x0003, SIERRA_EPI_CTRL_PREG},
13317a5ad9b4SSwapnil Jakhade 	{0x803F, SIERRA_SDFILT_H2L_A_PREG},
13327a5ad9b4SSwapnil Jakhade 	{0x0004, SIERRA_RXBUFFER_CTLECTRL_PREG},
13337a5ad9b4SSwapnil Jakhade 	{0x2010, SIERRA_RXBUFFER_RCDFECTRL_PREG},
13347a5ad9b4SSwapnil Jakhade 	{0x4432, SIERRA_RXBUFFER_DFECTRL_PREG}
13357a5ad9b4SSwapnil Jakhade };
13367a5ad9b4SSwapnil Jakhade 
13377a5ad9b4SSwapnil Jakhade static struct cdns_sierra_vals pcie_100_int_ssc_cmn_vals = {
13387a5ad9b4SSwapnil Jakhade 	.reg_pairs = cdns_pcie_cmn_regs_int_ssc,
13397a5ad9b4SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(cdns_pcie_cmn_regs_int_ssc),
13407a5ad9b4SSwapnil Jakhade };
13417a5ad9b4SSwapnil Jakhade 
13427a5ad9b4SSwapnil Jakhade static struct cdns_sierra_vals pcie_100_int_ssc_ln_vals = {
13437a5ad9b4SSwapnil Jakhade 	.reg_pairs = cdns_pcie_ln_regs_int_ssc,
13447a5ad9b4SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(cdns_pcie_ln_regs_int_ssc),
13457a5ad9b4SSwapnil Jakhade };
13467a5ad9b4SSwapnil Jakhade 
1347871002d7SAnil Varughese /* refclk100MHz_32b_PCIe_cmn_pll_ext_ssc */
13483cfb0e8eSRikard Falkeborn static const struct cdns_reg_pairs cdns_pcie_cmn_regs_ext_ssc[] = {
1349871002d7SAnil Varughese 	{0x2106, SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG},
1350871002d7SAnil Varughese 	{0x2106, SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG},
1351871002d7SAnil Varughese 	{0x8A06, SIERRA_CMN_PLLLC_BWCAL_MODE1_PREG},
1352871002d7SAnil Varughese 	{0x8A06, SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG},
1353871002d7SAnil Varughese 	{0x1B1B, SIERRA_CMN_PLLLC_SS_TIME_STEPSIZE_MODE_PREG}
1354871002d7SAnil Varughese };
1355871002d7SAnil Varughese 
1356871002d7SAnil Varughese /* refclk100MHz_32b_PCIe_ln_ext_ssc */
13573cfb0e8eSRikard Falkeborn static const struct cdns_reg_pairs cdns_pcie_ln_regs_ext_ssc[] = {
13587a5ad9b4SSwapnil Jakhade 	{0xFC08, SIERRA_DET_STANDEC_A_PREG},
13597a5ad9b4SSwapnil Jakhade 	{0x001D, SIERRA_PSM_A3IN_TMR_PREG},
13607a5ad9b4SSwapnil Jakhade 	{0x1555, SIERRA_DFE_BIASTRIM_PREG},
13617a5ad9b4SSwapnil Jakhade 	{0x9703, SIERRA_DRVCTRL_BOOST_PREG},
1362871002d7SAnil Varughese 	{0x813E, SIERRA_CLKPATHCTRL_TMR_PREG},
1363871002d7SAnil Varughese 	{0x8047, SIERRA_RX_CREQ_FLTR_A_MODE3_PREG},
1364871002d7SAnil Varughese 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE2_PREG},
1365871002d7SAnil Varughese 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG},
1366871002d7SAnil Varughese 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
13677a5ad9b4SSwapnil Jakhade 	{0x0002, SIERRA_CREQ_DCBIASATTEN_OVR_PREG},
13687a5ad9b4SSwapnil Jakhade 	{0x9800, SIERRA_RX_CTLE_CAL_PREG},
1369871002d7SAnil Varughese 	{0x033C, SIERRA_RX_CTLE_MAINTENANCE_PREG},
13707a5ad9b4SSwapnil Jakhade 	{0x44CC, SIERRA_CREQ_EQ_OPEN_EYE_THRESH_PREG},
13717a5ad9b4SSwapnil Jakhade 	{0x5624, SIERRA_DEQ_CONCUR_CTRL2_PREG},
13727a5ad9b4SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_EPIPWR_CTRL2_PREG},
13737a5ad9b4SSwapnil Jakhade 	{0x00FF, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG},
13747a5ad9b4SSwapnil Jakhade 	{0x4C4C, SIERRA_DEQ_ERRCMP_CTRL_PREG},
13757a5ad9b4SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_OFFSET_CTRL_PREG},
13767a5ad9b4SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_GAIN_CTRL_PREG},
13777a5ad9b4SSwapnil Jakhade 	{0x0041, SIERRA_DEQ_GLUT0},
13787a5ad9b4SSwapnil Jakhade 	{0x0082, SIERRA_DEQ_GLUT1},
13797a5ad9b4SSwapnil Jakhade 	{0x00C3, SIERRA_DEQ_GLUT2},
13807a5ad9b4SSwapnil Jakhade 	{0x0145, SIERRA_DEQ_GLUT3},
13817a5ad9b4SSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT4},
13827a5ad9b4SSwapnil Jakhade 	{0x09E7, SIERRA_DEQ_ALUT0},
13837a5ad9b4SSwapnil Jakhade 	{0x09A6, SIERRA_DEQ_ALUT1},
13847a5ad9b4SSwapnil Jakhade 	{0x0965, SIERRA_DEQ_ALUT2},
13857a5ad9b4SSwapnil Jakhade 	{0x08E3, SIERRA_DEQ_ALUT3},
13867a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP0},
13877a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP1},
13887a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP2},
13897a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP3},
13907a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP4},
13917a5ad9b4SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_PRECUR_PREG},
13927a5ad9b4SSwapnil Jakhade 	{0x0280, SIERRA_DEQ_POSTCUR_PREG},
13937a5ad9b4SSwapnil Jakhade 	{0x8F00, SIERRA_DEQ_POSTCUR_DECR_PREG},
13947a5ad9b4SSwapnil Jakhade 	{0x3C0F, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG},
13957a5ad9b4SSwapnil Jakhade 	{0x1C0C, SIERRA_DEQ_TAU_CTRL2_PREG},
13967a5ad9b4SSwapnil Jakhade 	{0x0100, SIERRA_DEQ_TAU_CTRL3_PREG},
13977a5ad9b4SSwapnil Jakhade 	{0x5E82, SIERRA_DEQ_OPENEYE_CTRL_PREG},
13987a5ad9b4SSwapnil Jakhade 	{0x002B, SIERRA_CPI_TRIM_PREG},
13997a5ad9b4SSwapnil Jakhade 	{0x0003, SIERRA_EPI_CTRL_PREG},
14007a5ad9b4SSwapnil Jakhade 	{0x803F, SIERRA_SDFILT_H2L_A_PREG},
14017a5ad9b4SSwapnil Jakhade 	{0x0004, SIERRA_RXBUFFER_CTLECTRL_PREG},
14027a5ad9b4SSwapnil Jakhade 	{0x2010, SIERRA_RXBUFFER_RCDFECTRL_PREG},
14037a5ad9b4SSwapnil Jakhade 	{0x4432, SIERRA_RXBUFFER_DFECTRL_PREG}
1404871002d7SAnil Varughese };
1405871002d7SAnil Varughese 
1406078e9e92SSwapnil Jakhade static struct cdns_sierra_vals pcie_100_ext_ssc_cmn_vals = {
1407078e9e92SSwapnil Jakhade 	.reg_pairs = cdns_pcie_cmn_regs_ext_ssc,
1408078e9e92SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(cdns_pcie_cmn_regs_ext_ssc),
1409078e9e92SSwapnil Jakhade };
1410078e9e92SSwapnil Jakhade 
1411078e9e92SSwapnil Jakhade static struct cdns_sierra_vals pcie_100_ext_ssc_ln_vals = {
1412078e9e92SSwapnil Jakhade 	.reg_pairs = cdns_pcie_ln_regs_ext_ssc,
1413078e9e92SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(cdns_pcie_ln_regs_ext_ssc),
1414078e9e92SSwapnil Jakhade };
1415078e9e92SSwapnil Jakhade 
1416871002d7SAnil Varughese /* refclk100MHz_20b_USB_cmn_pll_ext_ssc */
14173cfb0e8eSRikard Falkeborn static const struct cdns_reg_pairs cdns_usb_cmn_regs_ext_ssc[] = {
1418871002d7SAnil Varughese 	{0x2085, SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG},
1419871002d7SAnil Varughese 	{0x2085, SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG},
1420871002d7SAnil Varughese 	{0x0000, SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG},
1421871002d7SAnil Varughese 	{0x0000, SIERRA_CMN_PLLLC_SS_TIME_STEPSIZE_MODE_PREG}
1422871002d7SAnil Varughese };
1423871002d7SAnil Varughese 
1424871002d7SAnil Varughese /* refclk100MHz_20b_USB_ln_ext_ssc */
14253cfb0e8eSRikard Falkeborn static const struct cdns_reg_pairs cdns_usb_ln_regs_ext_ssc[] = {
1426aead5fd6SKishon Vijay Abraham I 	{0xFE0A, SIERRA_DET_STANDEC_A_PREG},
1427aead5fd6SKishon Vijay Abraham I 	{0x000F, SIERRA_DET_STANDEC_B_PREG},
14282bcf14caSSanket Parmar 	{0x55A5, SIERRA_DET_STANDEC_C_PREG},
1429871002d7SAnil Varughese 	{0x69ad, SIERRA_DET_STANDEC_D_PREG},
1430aead5fd6SKishon Vijay Abraham I 	{0x0241, SIERRA_DET_STANDEC_E_PREG},
14312bcf14caSSanket Parmar 	{0x0110, SIERRA_PSM_LANECAL_DLY_A1_RESETS_PREG},
1432871002d7SAnil Varughese 	{0x0014, SIERRA_PSM_A0IN_TMR_PREG},
1433aead5fd6SKishon Vijay Abraham I 	{0xCF00, SIERRA_PSM_DIAG_PREG},
1434aead5fd6SKishon Vijay Abraham I 	{0x001F, SIERRA_PSC_TX_A0_PREG},
1435aead5fd6SKishon Vijay Abraham I 	{0x0007, SIERRA_PSC_TX_A1_PREG},
1436aead5fd6SKishon Vijay Abraham I 	{0x0003, SIERRA_PSC_TX_A2_PREG},
1437aead5fd6SKishon Vijay Abraham I 	{0x0003, SIERRA_PSC_TX_A3_PREG},
1438aead5fd6SKishon Vijay Abraham I 	{0x0FFF, SIERRA_PSC_RX_A0_PREG},
14392bcf14caSSanket Parmar 	{0x0003, SIERRA_PSC_RX_A1_PREG},
1440aead5fd6SKishon Vijay Abraham I 	{0x0003, SIERRA_PSC_RX_A2_PREG},
1441aead5fd6SKishon Vijay Abraham I 	{0x0001, SIERRA_PSC_RX_A3_PREG},
1442aead5fd6SKishon Vijay Abraham I 	{0x0001, SIERRA_PLLCTRL_SUBRATE_PREG},
1443aead5fd6SKishon Vijay Abraham I 	{0x0406, SIERRA_PLLCTRL_GEN_D_PREG},
1444871002d7SAnil Varughese 	{0x5233, SIERRA_PLLCTRL_CPGAIN_MODE_PREG},
1445871002d7SAnil Varughese 	{0x00CA, SIERRA_CLKPATH_BIASTRIM_PREG},
1446871002d7SAnil Varughese 	{0x2512, SIERRA_DFE_BIASTRIM_PREG},
1447aead5fd6SKishon Vijay Abraham I 	{0x0000, SIERRA_DRVCTRL_ATTEN_PREG},
14482bcf14caSSanket Parmar 	{0x823E, SIERRA_CLKPATHCTRL_TMR_PREG},
14492bcf14caSSanket Parmar 	{0x078F, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG},
14502bcf14caSSanket Parmar 	{0x078F, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
1451aead5fd6SKishon Vijay Abraham I 	{0x7B3C, SIERRA_CREQ_CCLKDET_MODE01_PREG},
14522bcf14caSSanket Parmar 	{0x023C, SIERRA_RX_CTLE_MAINTENANCE_PREG},
1453aead5fd6SKishon Vijay Abraham I 	{0x3232, SIERRA_CREQ_FSMCLK_SEL_PREG},
1454871002d7SAnil Varughese 	{0x0000, SIERRA_CREQ_EQ_CTRL_PREG},
14552bcf14caSSanket Parmar 	{0x0000, SIERRA_CREQ_SPARE_PREG},
1456871002d7SAnil Varughese 	{0xCC44, SIERRA_CREQ_EQ_OPEN_EYE_THRESH_PREG},
14572bcf14caSSanket Parmar 	{0x8452, SIERRA_CTLELUT_CTRL_PREG},
14582bcf14caSSanket Parmar 	{0x4121, SIERRA_DFE_ECMP_RATESEL_PREG},
14592bcf14caSSanket Parmar 	{0x4121, SIERRA_DFE_SMP_RATESEL_PREG},
14602bcf14caSSanket Parmar 	{0x0003, SIERRA_DEQ_PHALIGN_CTRL},
1461871002d7SAnil Varughese 	{0x3200, SIERRA_DEQ_CONCUR_CTRL1_PREG},
1462871002d7SAnil Varughese 	{0x5064, SIERRA_DEQ_CONCUR_CTRL2_PREG},
1463871002d7SAnil Varughese 	{0x0030, SIERRA_DEQ_EPIPWR_CTRL2_PREG},
1464871002d7SAnil Varughese 	{0x0048, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG},
1465871002d7SAnil Varughese 	{0x5A5A, SIERRA_DEQ_ERRCMP_CTRL_PREG},
1466871002d7SAnil Varughese 	{0x02F5, SIERRA_DEQ_OFFSET_CTRL_PREG},
1467871002d7SAnil Varughese 	{0x02F5, SIERRA_DEQ_GAIN_CTRL_PREG},
14682bcf14caSSanket Parmar 	{0x9999, SIERRA_DEQ_VGATUNE_CTRL_PREG},
1469871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT0},
1470871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT1},
1471871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT2},
1472871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT3},
1473871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT4},
1474871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT5},
1475871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT6},
1476871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT7},
1477871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT8},
1478871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT9},
1479871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT10},
1480871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT11},
1481871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT12},
1482871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT13},
1483871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT14},
1484871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT15},
1485871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT16},
1486871002d7SAnil Varughese 	{0x0BAE, SIERRA_DEQ_ALUT0},
1487871002d7SAnil Varughese 	{0x0AEB, SIERRA_DEQ_ALUT1},
1488871002d7SAnil Varughese 	{0x0A28, SIERRA_DEQ_ALUT2},
1489871002d7SAnil Varughese 	{0x0965, SIERRA_DEQ_ALUT3},
1490871002d7SAnil Varughese 	{0x08A2, SIERRA_DEQ_ALUT4},
1491871002d7SAnil Varughese 	{0x07DF, SIERRA_DEQ_ALUT5},
1492871002d7SAnil Varughese 	{0x071C, SIERRA_DEQ_ALUT6},
1493871002d7SAnil Varughese 	{0x0659, SIERRA_DEQ_ALUT7},
1494871002d7SAnil Varughese 	{0x0596, SIERRA_DEQ_ALUT8},
1495871002d7SAnil Varughese 	{0x0514, SIERRA_DEQ_ALUT9},
1496871002d7SAnil Varughese 	{0x0492, SIERRA_DEQ_ALUT10},
1497871002d7SAnil Varughese 	{0x0410, SIERRA_DEQ_ALUT11},
1498871002d7SAnil Varughese 	{0x038E, SIERRA_DEQ_ALUT12},
1499871002d7SAnil Varughese 	{0x030C, SIERRA_DEQ_ALUT13},
1500871002d7SAnil Varughese 	{0x03F4, SIERRA_DEQ_DFETAP_CTRL_PREG},
1501871002d7SAnil Varughese 	{0x0001, SIERRA_DFE_EN_1010_IGNORE_PREG},
1502871002d7SAnil Varughese 	{0x3C01, SIERRA_DEQ_TAU_CTRL1_FAST_MAINT_PREG},
1503871002d7SAnil Varughese 	{0x3C40, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG},
1504871002d7SAnil Varughese 	{0x1C08, SIERRA_DEQ_TAU_CTRL2_PREG},
1505871002d7SAnil Varughese 	{0x0033, SIERRA_DEQ_PICTRL_PREG},
1506871002d7SAnil Varughese 	{0x0400, SIERRA_CPICAL_TMRVAL_MODE1_PREG},
1507871002d7SAnil Varughese 	{0x0330, SIERRA_CPICAL_TMRVAL_MODE0_PREG},
1508871002d7SAnil Varughese 	{0x01FF, SIERRA_CPICAL_PICNT_MODE1_PREG},
1509aead5fd6SKishon Vijay Abraham I 	{0x0009, SIERRA_CPI_OUTBUF_RATESEL_PREG},
1510871002d7SAnil Varughese 	{0x3232, SIERRA_CPICAL_RES_STARTCODE_MODE23_PREG},
1511871002d7SAnil Varughese 	{0x0005, SIERRA_LFPSDET_SUPPORT_PREG},
1512aead5fd6SKishon Vijay Abraham I 	{0x000F, SIERRA_LFPSFILT_NS_PREG},
1513aead5fd6SKishon Vijay Abraham I 	{0x0009, SIERRA_LFPSFILT_RD_PREG},
1514aead5fd6SKishon Vijay Abraham I 	{0x0001, SIERRA_LFPSFILT_MP_PREG},
15152bcf14caSSanket Parmar 	{0x6013, SIERRA_SIGDET_SUPPORT_PREG},
1516aead5fd6SKishon Vijay Abraham I 	{0x8013, SIERRA_SDFILT_H2L_A_PREG},
1517871002d7SAnil Varughese 	{0x8009, SIERRA_SDFILT_L2H_PREG},
1518871002d7SAnil Varughese 	{0x0024, SIERRA_RXBUFFER_CTLECTRL_PREG},
1519871002d7SAnil Varughese 	{0x0020, SIERRA_RXBUFFER_RCDFECTRL_PREG},
1520871002d7SAnil Varughese 	{0x4243, SIERRA_RXBUFFER_DFECTRL_PREG}
152144d30d62SAlan Douglas };
152244d30d62SAlan Douglas 
1523078e9e92SSwapnil Jakhade static struct cdns_sierra_vals usb_100_ext_ssc_cmn_vals = {
1524078e9e92SSwapnil Jakhade 	.reg_pairs = cdns_usb_cmn_regs_ext_ssc,
1525078e9e92SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(cdns_usb_cmn_regs_ext_ssc),
1526078e9e92SSwapnil Jakhade };
1527078e9e92SSwapnil Jakhade 
1528078e9e92SSwapnil Jakhade static struct cdns_sierra_vals usb_100_ext_ssc_ln_vals = {
1529078e9e92SSwapnil Jakhade 	.reg_pairs = cdns_usb_ln_regs_ext_ssc,
1530078e9e92SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(cdns_usb_ln_regs_ext_ssc),
1531078e9e92SSwapnil Jakhade };
1532078e9e92SSwapnil Jakhade 
153344d30d62SAlan Douglas static const struct cdns_sierra_data cdns_map_sierra = {
1534078e9e92SSwapnil Jakhade 	.id_value = SIERRA_MACRO_ID,
1535078e9e92SSwapnil Jakhade 	.block_offset_shift = 0x2,
1536078e9e92SSwapnil Jakhade 	.reg_offset_shift = 0x2,
1537fa105172SSwapnil Jakhade 	.pcs_cmn_vals = {
1538fa105172SSwapnil Jakhade 		[TYPE_PCIE] = {
1539fa105172SSwapnil Jakhade 			[TYPE_NONE] = {
15407a5ad9b4SSwapnil Jakhade 				[NO_SSC] = &pcie_phy_pcs_cmn_vals,
1541fa105172SSwapnil Jakhade 				[EXTERNAL_SSC] = &pcie_phy_pcs_cmn_vals,
15427a5ad9b4SSwapnil Jakhade 				[INTERNAL_SSC] = &pcie_phy_pcs_cmn_vals,
1543fa105172SSwapnil Jakhade 			},
1544fa105172SSwapnil Jakhade 		},
1545fa105172SSwapnil Jakhade 	},
1546078e9e92SSwapnil Jakhade 	.pma_cmn_vals = {
1547078e9e92SSwapnil Jakhade 		[TYPE_PCIE] = {
1548078e9e92SSwapnil Jakhade 			[TYPE_NONE] = {
15497a5ad9b4SSwapnil Jakhade 				[NO_SSC] = &pcie_100_no_ssc_cmn_vals,
1550078e9e92SSwapnil Jakhade 				[EXTERNAL_SSC] = &pcie_100_ext_ssc_cmn_vals,
15517a5ad9b4SSwapnil Jakhade 				[INTERNAL_SSC] = &pcie_100_int_ssc_cmn_vals,
1552078e9e92SSwapnil Jakhade 			},
1553078e9e92SSwapnil Jakhade 		},
1554078e9e92SSwapnil Jakhade 		[TYPE_USB] = {
1555078e9e92SSwapnil Jakhade 			[TYPE_NONE] = {
1556078e9e92SSwapnil Jakhade 				[EXTERNAL_SSC] = &usb_100_ext_ssc_cmn_vals,
1557078e9e92SSwapnil Jakhade 			},
1558078e9e92SSwapnil Jakhade 		},
1559078e9e92SSwapnil Jakhade 	},
1560078e9e92SSwapnil Jakhade 	.pma_ln_vals = {
1561078e9e92SSwapnil Jakhade 		[TYPE_PCIE] = {
1562078e9e92SSwapnil Jakhade 			[TYPE_NONE] = {
15637a5ad9b4SSwapnil Jakhade 				[NO_SSC] = &pcie_100_no_ssc_ln_vals,
1564078e9e92SSwapnil Jakhade 				[EXTERNAL_SSC] = &pcie_100_ext_ssc_ln_vals,
15657a5ad9b4SSwapnil Jakhade 				[INTERNAL_SSC] = &pcie_100_int_ssc_ln_vals,
1566078e9e92SSwapnil Jakhade 			},
1567078e9e92SSwapnil Jakhade 		},
1568078e9e92SSwapnil Jakhade 		[TYPE_USB] = {
1569078e9e92SSwapnil Jakhade 			[TYPE_NONE] = {
1570078e9e92SSwapnil Jakhade 				[EXTERNAL_SSC] = &usb_100_ext_ssc_ln_vals,
1571078e9e92SSwapnil Jakhade 			},
1572078e9e92SSwapnil Jakhade 		},
1573078e9e92SSwapnil Jakhade 	},
157444d30d62SAlan Douglas };
157544d30d62SAlan Douglas 
1576367da978SKishon Vijay Abraham I static const struct cdns_sierra_data cdns_ti_map_sierra = {
1577078e9e92SSwapnil Jakhade 	.id_value = SIERRA_MACRO_ID,
1578078e9e92SSwapnil Jakhade 	.block_offset_shift = 0x0,
1579078e9e92SSwapnil Jakhade 	.reg_offset_shift = 0x1,
1580fa105172SSwapnil Jakhade 	.pcs_cmn_vals = {
1581fa105172SSwapnil Jakhade 		[TYPE_PCIE] = {
1582fa105172SSwapnil Jakhade 			[TYPE_NONE] = {
15837a5ad9b4SSwapnil Jakhade 				[NO_SSC] = &pcie_phy_pcs_cmn_vals,
1584fa105172SSwapnil Jakhade 				[EXTERNAL_SSC] = &pcie_phy_pcs_cmn_vals,
15857a5ad9b4SSwapnil Jakhade 				[INTERNAL_SSC] = &pcie_phy_pcs_cmn_vals,
1586fa105172SSwapnil Jakhade 			},
1587fa105172SSwapnil Jakhade 		},
1588fa105172SSwapnil Jakhade 	},
1589078e9e92SSwapnil Jakhade 	.pma_cmn_vals = {
1590078e9e92SSwapnil Jakhade 		[TYPE_PCIE] = {
1591078e9e92SSwapnil Jakhade 			[TYPE_NONE] = {
15927a5ad9b4SSwapnil Jakhade 				[NO_SSC] = &pcie_100_no_ssc_cmn_vals,
1593078e9e92SSwapnil Jakhade 				[EXTERNAL_SSC] = &pcie_100_ext_ssc_cmn_vals,
15947a5ad9b4SSwapnil Jakhade 				[INTERNAL_SSC] = &pcie_100_int_ssc_cmn_vals,
1595078e9e92SSwapnil Jakhade 			},
1596078e9e92SSwapnil Jakhade 		},
1597078e9e92SSwapnil Jakhade 		[TYPE_USB] = {
1598078e9e92SSwapnil Jakhade 			[TYPE_NONE] = {
1599078e9e92SSwapnil Jakhade 				[EXTERNAL_SSC] = &usb_100_ext_ssc_cmn_vals,
1600078e9e92SSwapnil Jakhade 			},
1601078e9e92SSwapnil Jakhade 		},
1602078e9e92SSwapnil Jakhade 	},
1603078e9e92SSwapnil Jakhade 	.pma_ln_vals = {
1604078e9e92SSwapnil Jakhade 		[TYPE_PCIE] = {
1605078e9e92SSwapnil Jakhade 			[TYPE_NONE] = {
16067a5ad9b4SSwapnil Jakhade 				[NO_SSC] = &pcie_100_no_ssc_ln_vals,
1607078e9e92SSwapnil Jakhade 				[EXTERNAL_SSC] = &pcie_100_ext_ssc_ln_vals,
16087a5ad9b4SSwapnil Jakhade 				[INTERNAL_SSC] = &pcie_100_int_ssc_ln_vals,
1609078e9e92SSwapnil Jakhade 			},
1610078e9e92SSwapnil Jakhade 		},
1611078e9e92SSwapnil Jakhade 		[TYPE_USB] = {
1612078e9e92SSwapnil Jakhade 			[TYPE_NONE] = {
1613078e9e92SSwapnil Jakhade 				[EXTERNAL_SSC] = &usb_100_ext_ssc_ln_vals,
1614078e9e92SSwapnil Jakhade 			},
1615078e9e92SSwapnil Jakhade 		},
1616078e9e92SSwapnil Jakhade 	},
1617367da978SKishon Vijay Abraham I };
1618367da978SKishon Vijay Abraham I 
161944d30d62SAlan Douglas static const struct of_device_id cdns_sierra_id_table[] = {
162044d30d62SAlan Douglas 	{
162144d30d62SAlan Douglas 		.compatible = "cdns,sierra-phy-t0",
162244d30d62SAlan Douglas 		.data = &cdns_map_sierra,
162344d30d62SAlan Douglas 	},
1624367da978SKishon Vijay Abraham I 	{
1625367da978SKishon Vijay Abraham I 		.compatible = "ti,sierra-phy-t0",
1626367da978SKishon Vijay Abraham I 		.data = &cdns_ti_map_sierra,
1627367da978SKishon Vijay Abraham I 	},
162844d30d62SAlan Douglas 	{}
162944d30d62SAlan Douglas };
163044d30d62SAlan Douglas MODULE_DEVICE_TABLE(of, cdns_sierra_id_table);
163144d30d62SAlan Douglas 
163244d30d62SAlan Douglas static struct platform_driver cdns_sierra_driver = {
163344d30d62SAlan Douglas 	.probe		= cdns_sierra_phy_probe,
163444d30d62SAlan Douglas 	.remove		= cdns_sierra_phy_remove,
163544d30d62SAlan Douglas 	.driver		= {
163644d30d62SAlan Douglas 		.name	= "cdns-sierra-phy",
163744d30d62SAlan Douglas 		.of_match_table = cdns_sierra_id_table,
163844d30d62SAlan Douglas 	},
163944d30d62SAlan Douglas };
164044d30d62SAlan Douglas module_platform_driver(cdns_sierra_driver);
164144d30d62SAlan Douglas 
164244d30d62SAlan Douglas MODULE_ALIAS("platform:cdns_sierra");
164344d30d62SAlan Douglas MODULE_AUTHOR("Cadence Design Systems");
164444d30d62SAlan Douglas MODULE_DESCRIPTION("CDNS sierra phy driver");
164544d30d62SAlan Douglas MODULE_LICENSE("GPL v2");
1646