xref: /linux/drivers/phy/cadence/phy-cadence-sierra.c (revision 7a5ad9b4b98cd95f02ec12c895e80bc521fbf9ec)
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
39*7a5ad9b4SSwapnil Jakhade #define SIERRA_CMN_PLLLC_DSMCORR_PREG			0x51
40*7a5ad9b4SSwapnil Jakhade #define SIERRA_CMN_PLLLC_SS_PREG			0x52
41*7a5ad9b4SSwapnil Jakhade #define SIERRA_CMN_PLLLC_SS_AMP_STEP_SIZE_PREG		0x53
42*7a5ad9b4SSwapnil Jakhade #define SIERRA_CMN_PLLLC_SSTWOPT_PREG			0x54
43871002d7SAnil Varughese #define SIERRA_CMN_PLLLC_SS_TIME_STEPSIZE_MODE_PREG	0x62
44*7a5ad9b4SSwapnil 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
60*7a5ad9b4SSwapnil 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
77*7a5ad9b4SSwapnil 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
83*7a5ad9b4SSwapnil Jakhade #define SIERRA_CREQ_DCBIASATTEN_OVR_PREG		0x08C
84aead5fd6SKishon Vijay Abraham I #define SIERRA_CREQ_CCLKDET_MODE01_PREG			0x08E
85*7a5ad9b4SSwapnil 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
135*7a5ad9b4SSwapnil Jakhade #define SIERRA_DEQ_DFETAP0				0x129
136*7a5ad9b4SSwapnil Jakhade #define SIERRA_DEQ_DFETAP1				0x12B
137*7a5ad9b4SSwapnil Jakhade #define SIERRA_DEQ_DFETAP2				0x12D
138*7a5ad9b4SSwapnil Jakhade #define SIERRA_DEQ_DFETAP3				0x12F
139*7a5ad9b4SSwapnil Jakhade #define SIERRA_DEQ_DFETAP4				0x131
140871002d7SAnil Varughese #define SIERRA_DFE_EN_1010_IGNORE_PREG			0x134
141*7a5ad9b4SSwapnil Jakhade #define SIERRA_DEQ_PRECUR_PREG				0x138
142*7a5ad9b4SSwapnil Jakhade #define SIERRA_DEQ_POSTCUR_PREG				0x140
143*7a5ad9b4SSwapnil 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
146*7a5ad9b4SSwapnil Jakhade #define SIERRA_DEQ_TAU_CTRL3_PREG			0x152
147*7a5ad9b4SSwapnil 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
153*7a5ad9b4SSwapnil Jakhade #define SIERRA_CPI_TRIM_PREG				0x17F
154871002d7SAnil Varughese #define SIERRA_CPICAL_RES_STARTCODE_MODE23_PREG		0x183
155*7a5ad9b4SSwapnil 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 
26028081b72SKishon Vijay Abraham I static u32 cdns_sierra_pll_mux_table[] = { 0, 1 };
26128081b72SKishon Vijay Abraham I 
262078e9e92SSwapnil Jakhade enum cdns_sierra_phy_type {
263078e9e92SSwapnil Jakhade 	TYPE_NONE,
264078e9e92SSwapnil Jakhade 	TYPE_PCIE,
265078e9e92SSwapnil Jakhade 	TYPE_USB
266078e9e92SSwapnil Jakhade };
267078e9e92SSwapnil Jakhade 
268078e9e92SSwapnil Jakhade enum cdns_sierra_ssc_mode {
269078e9e92SSwapnil Jakhade 	NO_SSC,
270078e9e92SSwapnil Jakhade 	EXTERNAL_SSC,
271078e9e92SSwapnil Jakhade 	INTERNAL_SSC
272078e9e92SSwapnil Jakhade };
273078e9e92SSwapnil Jakhade 
27444d30d62SAlan Douglas struct cdns_sierra_inst {
27544d30d62SAlan Douglas 	struct phy *phy;
276078e9e92SSwapnil Jakhade 	enum cdns_sierra_phy_type phy_type;
27744d30d62SAlan Douglas 	u32 num_lanes;
27844d30d62SAlan Douglas 	u32 mlane;
27944d30d62SAlan Douglas 	struct reset_control *lnk_rst;
2801e902b2aSSwapnil Jakhade 	enum cdns_sierra_ssc_mode ssc_mode;
28144d30d62SAlan Douglas };
28244d30d62SAlan Douglas 
28344d30d62SAlan Douglas struct cdns_reg_pairs {
28444d30d62SAlan Douglas 	u16 val;
28544d30d62SAlan Douglas 	u32 off;
28644d30d62SAlan Douglas };
28744d30d62SAlan Douglas 
288078e9e92SSwapnil Jakhade struct cdns_sierra_vals {
289078e9e92SSwapnil Jakhade 	const struct cdns_reg_pairs *reg_pairs;
290078e9e92SSwapnil Jakhade 	u32 num_regs;
291078e9e92SSwapnil Jakhade };
292078e9e92SSwapnil Jakhade 
29344d30d62SAlan Douglas struct cdns_sierra_data {
29444d30d62SAlan Douglas 	u32 id_value;
295380f5708SKishon Vijay Abraham I 	u8 block_offset_shift;
296380f5708SKishon Vijay Abraham I 	u8 reg_offset_shift;
297fa105172SSwapnil Jakhade 	struct cdns_sierra_vals *pcs_cmn_vals[NUM_PHY_TYPE][NUM_PHY_TYPE]
298fa105172SSwapnil Jakhade 					     [NUM_SSC_MODE];
299078e9e92SSwapnil Jakhade 	struct cdns_sierra_vals *pma_cmn_vals[NUM_PHY_TYPE][NUM_PHY_TYPE]
300078e9e92SSwapnil Jakhade 					     [NUM_SSC_MODE];
301078e9e92SSwapnil Jakhade 	struct cdns_sierra_vals *pma_ln_vals[NUM_PHY_TYPE][NUM_PHY_TYPE]
302078e9e92SSwapnil Jakhade 					    [NUM_SSC_MODE];
30344d30d62SAlan Douglas };
30444d30d62SAlan Douglas 
305380f5708SKishon Vijay Abraham I struct cdns_regmap_cdb_context {
30644d30d62SAlan Douglas 	struct device *dev;
30744d30d62SAlan Douglas 	void __iomem *base;
308380f5708SKishon Vijay Abraham I 	u8 reg_offset_shift;
309380f5708SKishon Vijay Abraham I };
310380f5708SKishon Vijay Abraham I 
311380f5708SKishon Vijay Abraham I struct cdns_sierra_phy {
312380f5708SKishon Vijay Abraham I 	struct device *dev;
313380f5708SKishon Vijay Abraham I 	struct regmap *regmap;
314c3c11d55SSwapnil Jakhade 	const struct cdns_sierra_data *init_data;
31544d30d62SAlan Douglas 	struct cdns_sierra_inst phys[SIERRA_MAX_LANES];
31644d30d62SAlan Douglas 	struct reset_control *phy_rst;
31744d30d62SAlan Douglas 	struct reset_control *apb_rst;
318380f5708SKishon Vijay Abraham I 	struct regmap *regmap_lane_cdb[SIERRA_MAX_LANES];
3198c95e172SSwapnil Jakhade 	struct regmap *regmap_phy_pcs_common_cdb;
32036ce4163SSwapnil Jakhade 	struct regmap *regmap_phy_pcs_lane_cdb[SIERRA_MAX_LANES];
321f1cc6c3fSSwapnil Jakhade 	struct regmap *regmap_phy_pma_common_cdb;
322380f5708SKishon Vijay Abraham I 	struct regmap *regmap_common_cdb;
323380f5708SKishon Vijay Abraham I 	struct regmap_field *macro_id_type;
324380f5708SKishon Vijay Abraham I 	struct regmap_field *phy_pll_cfg_1;
325f1cc6c3fSSwapnil Jakhade 	struct regmap_field *pma_cmn_ready;
326adc4bd6fSKishon Vijay Abraham I 	struct regmap_field *pllctrl_lock[SIERRA_MAX_LANES];
32736ce4163SSwapnil Jakhade 	struct regmap_field *phy_iso_link_ctrl_1[SIERRA_MAX_LANES];
32828081b72SKishon Vijay Abraham I 	struct regmap_field *cmn_refrcv_refclk_plllc1en_preg[SIERRA_NUM_CMN_PLLC];
32928081b72SKishon Vijay Abraham I 	struct regmap_field *cmn_refrcv_refclk_termen_preg[SIERRA_NUM_CMN_PLLC];
33028081b72SKishon Vijay Abraham I 	struct regmap_field *cmn_plllc_pfdclk1_sel_preg[SIERRA_NUM_CMN_PLLC];
331a0c30cd7SKishon Vijay Abraham I 	struct clk *input_clks[CDNS_SIERRA_INPUT_CLOCKS];
33244d30d62SAlan Douglas 	int nsubnodes;
333a43f72aeSKishon Vijay Abraham I 	u32 num_lanes;
33444d30d62SAlan Douglas 	bool autoconf;
33528081b72SKishon Vijay Abraham I 	struct clk_onecell_data clk_data;
33628081b72SKishon Vijay Abraham I 	struct clk *output_clks[CDNS_SIERRA_OUTPUT_CLOCKS];
33744d30d62SAlan Douglas };
33844d30d62SAlan Douglas 
339380f5708SKishon Vijay Abraham I static int cdns_regmap_write(void *context, unsigned int reg, unsigned int val)
340380f5708SKishon Vijay Abraham I {
341380f5708SKishon Vijay Abraham I 	struct cdns_regmap_cdb_context *ctx = context;
342380f5708SKishon Vijay Abraham I 	u32 offset = reg << ctx->reg_offset_shift;
343380f5708SKishon Vijay Abraham I 
344380f5708SKishon Vijay Abraham I 	writew(val, ctx->base + offset);
345380f5708SKishon Vijay Abraham I 
346380f5708SKishon Vijay Abraham I 	return 0;
347380f5708SKishon Vijay Abraham I }
348380f5708SKishon Vijay Abraham I 
349380f5708SKishon Vijay Abraham I static int cdns_regmap_read(void *context, unsigned int reg, unsigned int *val)
350380f5708SKishon Vijay Abraham I {
351380f5708SKishon Vijay Abraham I 	struct cdns_regmap_cdb_context *ctx = context;
352380f5708SKishon Vijay Abraham I 	u32 offset = reg << ctx->reg_offset_shift;
353380f5708SKishon Vijay Abraham I 
354380f5708SKishon Vijay Abraham I 	*val = readw(ctx->base + offset);
355380f5708SKishon Vijay Abraham I 	return 0;
356380f5708SKishon Vijay Abraham I }
357380f5708SKishon Vijay Abraham I 
358380f5708SKishon Vijay Abraham I #define SIERRA_LANE_CDB_REGMAP_CONF(n) \
359380f5708SKishon Vijay Abraham I { \
360380f5708SKishon Vijay Abraham I 	.name = "sierra_lane" n "_cdb", \
361380f5708SKishon Vijay Abraham I 	.reg_stride = 1, \
362380f5708SKishon Vijay Abraham I 	.fast_io = true, \
363380f5708SKishon Vijay Abraham I 	.reg_write = cdns_regmap_write, \
364380f5708SKishon Vijay Abraham I 	.reg_read = cdns_regmap_read, \
365380f5708SKishon Vijay Abraham I }
366380f5708SKishon Vijay Abraham I 
3673cfb0e8eSRikard Falkeborn static const struct regmap_config cdns_sierra_lane_cdb_config[] = {
368380f5708SKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("0"),
369380f5708SKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("1"),
370380f5708SKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("2"),
371380f5708SKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("3"),
372a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("4"),
373a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("5"),
374a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("6"),
375a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("7"),
376a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("8"),
377a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("9"),
378a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("10"),
379a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("11"),
380a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("12"),
381a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("13"),
382a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("14"),
383a43f72aeSKishon Vijay Abraham I 	SIERRA_LANE_CDB_REGMAP_CONF("15"),
384380f5708SKishon Vijay Abraham I };
385380f5708SKishon Vijay Abraham I 
3863cfb0e8eSRikard Falkeborn static const struct regmap_config cdns_sierra_common_cdb_config = {
387380f5708SKishon Vijay Abraham I 	.name = "sierra_common_cdb",
388380f5708SKishon Vijay Abraham I 	.reg_stride = 1,
389380f5708SKishon Vijay Abraham I 	.fast_io = true,
390380f5708SKishon Vijay Abraham I 	.reg_write = cdns_regmap_write,
391380f5708SKishon Vijay Abraham I 	.reg_read = cdns_regmap_read,
392380f5708SKishon Vijay Abraham I };
393380f5708SKishon Vijay Abraham I 
3948c95e172SSwapnil Jakhade static const struct regmap_config cdns_sierra_phy_pcs_cmn_cdb_config = {
3958c95e172SSwapnil Jakhade 	.name = "sierra_phy_pcs_cmn_cdb",
396380f5708SKishon Vijay Abraham I 	.reg_stride = 1,
397380f5708SKishon Vijay Abraham I 	.fast_io = true,
398380f5708SKishon Vijay Abraham I 	.reg_write = cdns_regmap_write,
399380f5708SKishon Vijay Abraham I 	.reg_read = cdns_regmap_read,
400380f5708SKishon Vijay Abraham I };
401380f5708SKishon Vijay Abraham I 
40236ce4163SSwapnil Jakhade #define SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF(n) \
40336ce4163SSwapnil Jakhade { \
40436ce4163SSwapnil Jakhade 	.name = "sierra_phy_pcs_lane" n "_cdb", \
40536ce4163SSwapnil Jakhade 	.reg_stride = 1, \
40636ce4163SSwapnil Jakhade 	.fast_io = true, \
40736ce4163SSwapnil Jakhade 	.reg_write = cdns_regmap_write, \
40836ce4163SSwapnil Jakhade 	.reg_read = cdns_regmap_read, \
40936ce4163SSwapnil Jakhade }
41036ce4163SSwapnil Jakhade 
41136ce4163SSwapnil Jakhade static const struct regmap_config cdns_sierra_phy_pcs_lane_cdb_config[] = {
41236ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("0"),
41336ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("1"),
41436ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("2"),
41536ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("3"),
41636ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("4"),
41736ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("5"),
41836ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("6"),
41936ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("7"),
42036ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("8"),
42136ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("9"),
42236ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("10"),
42336ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("11"),
42436ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("12"),
42536ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("13"),
42636ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("14"),
42736ce4163SSwapnil Jakhade 	SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("15"),
42836ce4163SSwapnil Jakhade };
42936ce4163SSwapnil Jakhade 
430f1cc6c3fSSwapnil Jakhade static const struct regmap_config cdns_sierra_phy_pma_cmn_cdb_config = {
431f1cc6c3fSSwapnil Jakhade 	.name = "sierra_phy_pma_cmn_cdb",
432f1cc6c3fSSwapnil Jakhade 	.reg_stride = 1,
433f1cc6c3fSSwapnil Jakhade 	.fast_io = true,
434f1cc6c3fSSwapnil Jakhade 	.reg_write = cdns_regmap_write,
435f1cc6c3fSSwapnil Jakhade 	.reg_read = cdns_regmap_read,
436f1cc6c3fSSwapnil Jakhade };
437f1cc6c3fSSwapnil Jakhade 
438cedcc2e2SKishon Vijay Abraham I static int cdns_sierra_phy_init(struct phy *gphy)
43944d30d62SAlan Douglas {
44044d30d62SAlan Douglas 	struct cdns_sierra_inst *ins = phy_get_drvdata(gphy);
44144d30d62SAlan Douglas 	struct cdns_sierra_phy *phy = dev_get_drvdata(gphy->dev.parent);
442078e9e92SSwapnil Jakhade 	const struct cdns_sierra_data *init_data = phy->init_data;
443078e9e92SSwapnil Jakhade 	struct cdns_sierra_vals *pma_cmn_vals, *pma_ln_vals;
444078e9e92SSwapnil Jakhade 	enum cdns_sierra_phy_type phy_type = ins->phy_type;
4451e902b2aSSwapnil Jakhade 	enum cdns_sierra_ssc_mode ssc = ins->ssc_mode;
446078e9e92SSwapnil Jakhade 	const struct cdns_reg_pairs *reg_pairs;
447fa105172SSwapnil Jakhade 	struct cdns_sierra_vals *pcs_cmn_vals;
44880f96fb1SColin Ian King 	struct regmap *regmap;
449078e9e92SSwapnil Jakhade 	u32 num_regs;
45044d30d62SAlan Douglas 	int i, j;
45144d30d62SAlan Douglas 
452cedcc2e2SKishon Vijay Abraham I 	/* Initialise the PHY registers, unless auto configured */
453cedcc2e2SKishon Vijay Abraham I 	if (phy->autoconf)
454cedcc2e2SKishon Vijay Abraham I 		return 0;
455cedcc2e2SKishon Vijay Abraham I 
456a0c30cd7SKishon Vijay Abraham I 	clk_set_rate(phy->input_clks[CMN_REFCLK_DIG_DIV], 25000000);
457a0c30cd7SKishon Vijay Abraham I 	clk_set_rate(phy->input_clks[CMN_REFCLK1_DIG_DIV], 25000000);
458078e9e92SSwapnil Jakhade 
459fa105172SSwapnil Jakhade 	/* PHY PCS common registers configurations */
460fa105172SSwapnil Jakhade 	pcs_cmn_vals = init_data->pcs_cmn_vals[phy_type][TYPE_NONE][ssc];
461fa105172SSwapnil Jakhade 	if (pcs_cmn_vals) {
462fa105172SSwapnil Jakhade 		reg_pairs = pcs_cmn_vals->reg_pairs;
463fa105172SSwapnil Jakhade 		num_regs = pcs_cmn_vals->num_regs;
464fa105172SSwapnil Jakhade 		regmap = phy->regmap_phy_pcs_common_cdb;
465fa105172SSwapnil Jakhade 		for (i = 0; i < num_regs; i++)
466fa105172SSwapnil Jakhade 			regmap_write(regmap, reg_pairs[i].off, reg_pairs[i].val);
467fa105172SSwapnil Jakhade 	}
468fa105172SSwapnil Jakhade 
469078e9e92SSwapnil Jakhade 	/* PMA common registers configurations */
470078e9e92SSwapnil Jakhade 	pma_cmn_vals = init_data->pma_cmn_vals[phy_type][TYPE_NONE][ssc];
471078e9e92SSwapnil Jakhade 	if (pma_cmn_vals) {
472078e9e92SSwapnil Jakhade 		reg_pairs = pma_cmn_vals->reg_pairs;
473078e9e92SSwapnil Jakhade 		num_regs = pma_cmn_vals->num_regs;
474078e9e92SSwapnil Jakhade 		regmap = phy->regmap_common_cdb;
475078e9e92SSwapnil Jakhade 		for (i = 0; i < num_regs; i++)
476078e9e92SSwapnil Jakhade 			regmap_write(regmap, reg_pairs[i].off, reg_pairs[i].val);
47744d30d62SAlan Douglas 	}
478871002d7SAnil Varughese 
479078e9e92SSwapnil Jakhade 	/* PMA lane registers configurations */
480078e9e92SSwapnil Jakhade 	pma_ln_vals = init_data->pma_ln_vals[phy_type][TYPE_NONE][ssc];
481078e9e92SSwapnil Jakhade 	if (pma_ln_vals) {
482078e9e92SSwapnil Jakhade 		reg_pairs = pma_ln_vals->reg_pairs;
483078e9e92SSwapnil Jakhade 		num_regs = pma_ln_vals->num_regs;
484380f5708SKishon Vijay Abraham I 		for (i = 0; i < ins->num_lanes; i++) {
485380f5708SKishon Vijay Abraham I 			regmap = phy->regmap_lane_cdb[i + ins->mlane];
486078e9e92SSwapnil Jakhade 			for (j = 0; j < num_regs; j++)
487078e9e92SSwapnil Jakhade 				regmap_write(regmap, reg_pairs[j].off, reg_pairs[j].val);
488380f5708SKishon Vijay Abraham I 		}
489380f5708SKishon Vijay Abraham I 	}
490cedcc2e2SKishon Vijay Abraham I 
491cedcc2e2SKishon Vijay Abraham I 	return 0;
49244d30d62SAlan Douglas }
49344d30d62SAlan Douglas 
49444d30d62SAlan Douglas static int cdns_sierra_phy_on(struct phy *gphy)
49544d30d62SAlan Douglas {
496adc4bd6fSKishon Vijay Abraham I 	struct cdns_sierra_phy *sp = dev_get_drvdata(gphy->dev.parent);
49744d30d62SAlan Douglas 	struct cdns_sierra_inst *ins = phy_get_drvdata(gphy);
498adc4bd6fSKishon Vijay Abraham I 	struct device *dev = sp->dev;
499adc4bd6fSKishon Vijay Abraham I 	u32 val;
500adc4bd6fSKishon Vijay Abraham I 	int ret;
50144d30d62SAlan Douglas 
5025b4f5757SKishon Vijay Abraham I 	ret = reset_control_deassert(sp->phy_rst);
5035b4f5757SKishon Vijay Abraham I 	if (ret) {
5045b4f5757SKishon Vijay Abraham I 		dev_err(dev, "Failed to take the PHY out of reset\n");
5055b4f5757SKishon Vijay Abraham I 		return ret;
5065b4f5757SKishon Vijay Abraham I 	}
5075b4f5757SKishon Vijay Abraham I 
50844d30d62SAlan Douglas 	/* Take the PHY lane group out of reset */
509adc4bd6fSKishon Vijay Abraham I 	ret = reset_control_deassert(ins->lnk_rst);
510adc4bd6fSKishon Vijay Abraham I 	if (ret) {
511adc4bd6fSKishon Vijay Abraham I 		dev_err(dev, "Failed to take the PHY lane out of reset\n");
512adc4bd6fSKishon Vijay Abraham I 		return ret;
513adc4bd6fSKishon Vijay Abraham I 	}
514adc4bd6fSKishon Vijay Abraham I 
51536ce4163SSwapnil Jakhade 	if (ins->phy_type == TYPE_PCIE || ins->phy_type == TYPE_USB) {
51636ce4163SSwapnil Jakhade 		ret = regmap_field_read_poll_timeout(sp->phy_iso_link_ctrl_1[ins->mlane],
51736ce4163SSwapnil Jakhade 						     val, !val, 1000, PLL_LOCK_TIME);
51836ce4163SSwapnil Jakhade 		if (ret) {
51936ce4163SSwapnil Jakhade 			dev_err(dev, "Timeout waiting for PHY status ready\n");
52036ce4163SSwapnil Jakhade 			return ret;
52136ce4163SSwapnil Jakhade 		}
52236ce4163SSwapnil Jakhade 	}
52336ce4163SSwapnil Jakhade 
524f1cc6c3fSSwapnil Jakhade 	/*
525f1cc6c3fSSwapnil Jakhade 	 * Wait for cmn_ready assertion
526f1cc6c3fSSwapnil Jakhade 	 * PHY_PMA_CMN_CTRL[0] == 1
527f1cc6c3fSSwapnil Jakhade 	 */
528f1cc6c3fSSwapnil Jakhade 	ret = regmap_field_read_poll_timeout(sp->pma_cmn_ready, val, val,
529f1cc6c3fSSwapnil Jakhade 					     1000, PLL_LOCK_TIME);
530f1cc6c3fSSwapnil Jakhade 	if (ret) {
531f1cc6c3fSSwapnil Jakhade 		dev_err(dev, "Timeout waiting for CMN ready\n");
532f1cc6c3fSSwapnil Jakhade 		return ret;
533f1cc6c3fSSwapnil Jakhade 	}
534f1cc6c3fSSwapnil Jakhade 
535adc4bd6fSKishon Vijay Abraham I 	ret = regmap_field_read_poll_timeout(sp->pllctrl_lock[ins->mlane],
536adc4bd6fSKishon Vijay Abraham I 					     val, val, 1000, PLL_LOCK_TIME);
537adc4bd6fSKishon Vijay Abraham I 	if (ret < 0)
538adc4bd6fSKishon Vijay Abraham I 		dev_err(dev, "PLL lock of lane failed\n");
539adc4bd6fSKishon Vijay Abraham I 
540adc4bd6fSKishon Vijay Abraham I 	return ret;
54144d30d62SAlan Douglas }
54244d30d62SAlan Douglas 
54344d30d62SAlan Douglas static int cdns_sierra_phy_off(struct phy *gphy)
54444d30d62SAlan Douglas {
54544d30d62SAlan Douglas 	struct cdns_sierra_inst *ins = phy_get_drvdata(gphy);
54644d30d62SAlan Douglas 
54744d30d62SAlan Douglas 	return reset_control_assert(ins->lnk_rst);
54844d30d62SAlan Douglas }
54944d30d62SAlan Douglas 
5507904e15bSRoger Quadros static int cdns_sierra_phy_reset(struct phy *gphy)
5517904e15bSRoger Quadros {
5527904e15bSRoger Quadros 	struct cdns_sierra_phy *sp = dev_get_drvdata(gphy->dev.parent);
5537904e15bSRoger Quadros 
5547904e15bSRoger Quadros 	reset_control_assert(sp->phy_rst);
5557904e15bSRoger Quadros 	reset_control_deassert(sp->phy_rst);
5567904e15bSRoger Quadros 	return 0;
5577904e15bSRoger Quadros };
5587904e15bSRoger Quadros 
55944d30d62SAlan Douglas static const struct phy_ops ops = {
560cedcc2e2SKishon Vijay Abraham I 	.init		= cdns_sierra_phy_init,
56144d30d62SAlan Douglas 	.power_on	= cdns_sierra_phy_on,
56244d30d62SAlan Douglas 	.power_off	= cdns_sierra_phy_off,
5637904e15bSRoger Quadros 	.reset		= cdns_sierra_phy_reset,
56444d30d62SAlan Douglas 	.owner		= THIS_MODULE,
56544d30d62SAlan Douglas };
56644d30d62SAlan Douglas 
56728081b72SKishon Vijay Abraham I static u8 cdns_sierra_pll_mux_get_parent(struct clk_hw *hw)
56828081b72SKishon Vijay Abraham I {
56928081b72SKishon Vijay Abraham I 	struct cdns_sierra_pll_mux *mux = to_cdns_sierra_pll_mux(hw);
57028081b72SKishon Vijay Abraham I 	struct regmap_field *field = mux->pfdclk_sel_preg;
57128081b72SKishon Vijay Abraham I 	unsigned int val;
57228081b72SKishon Vijay Abraham I 
57328081b72SKishon Vijay Abraham I 	regmap_field_read(field, &val);
57428081b72SKishon Vijay Abraham I 	return clk_mux_val_to_index(hw, cdns_sierra_pll_mux_table, 0, val);
57528081b72SKishon Vijay Abraham I }
57628081b72SKishon Vijay Abraham I 
57728081b72SKishon Vijay Abraham I static int cdns_sierra_pll_mux_set_parent(struct clk_hw *hw, u8 index)
57828081b72SKishon Vijay Abraham I {
57928081b72SKishon Vijay Abraham I 	struct cdns_sierra_pll_mux *mux = to_cdns_sierra_pll_mux(hw);
58028081b72SKishon Vijay Abraham I 	struct regmap_field *plllc1en_field = mux->plllc1en_field;
58128081b72SKishon Vijay Abraham I 	struct regmap_field *termen_field = mux->termen_field;
58228081b72SKishon Vijay Abraham I 	struct regmap_field *field = mux->pfdclk_sel_preg;
58328081b72SKishon Vijay Abraham I 	int val, ret;
58428081b72SKishon Vijay Abraham I 
58528081b72SKishon Vijay Abraham I 	ret = regmap_field_write(plllc1en_field, 0);
58628081b72SKishon Vijay Abraham I 	ret |= regmap_field_write(termen_field, 0);
58728081b72SKishon Vijay Abraham I 	if (index == 1) {
58828081b72SKishon Vijay Abraham I 		ret |= regmap_field_write(plllc1en_field, 1);
58928081b72SKishon Vijay Abraham I 		ret |= regmap_field_write(termen_field, 1);
59028081b72SKishon Vijay Abraham I 	}
59128081b72SKishon Vijay Abraham I 
59228081b72SKishon Vijay Abraham I 	val = cdns_sierra_pll_mux_table[index];
59328081b72SKishon Vijay Abraham I 	ret |= regmap_field_write(field, val);
59428081b72SKishon Vijay Abraham I 
59528081b72SKishon Vijay Abraham I 	return ret;
59628081b72SKishon Vijay Abraham I }
59728081b72SKishon Vijay Abraham I 
59828081b72SKishon Vijay Abraham I static const struct clk_ops cdns_sierra_pll_mux_ops = {
59928081b72SKishon Vijay Abraham I 	.set_parent = cdns_sierra_pll_mux_set_parent,
60028081b72SKishon Vijay Abraham I 	.get_parent = cdns_sierra_pll_mux_get_parent,
60128081b72SKishon Vijay Abraham I };
60228081b72SKishon Vijay Abraham I 
60328081b72SKishon Vijay Abraham I static int cdns_sierra_pll_mux_register(struct cdns_sierra_phy *sp,
60428081b72SKishon Vijay Abraham I 					struct regmap_field *pfdclk1_sel_field,
60528081b72SKishon Vijay Abraham I 					struct regmap_field *plllc1en_field,
60628081b72SKishon Vijay Abraham I 					struct regmap_field *termen_field,
60728081b72SKishon Vijay Abraham I 					int clk_index)
60828081b72SKishon Vijay Abraham I {
60928081b72SKishon Vijay Abraham I 	struct cdns_sierra_pll_mux *mux;
61028081b72SKishon Vijay Abraham I 	struct device *dev = sp->dev;
61128081b72SKishon Vijay Abraham I 	struct clk_init_data *init;
61228081b72SKishon Vijay Abraham I 	const char **parent_names;
61328081b72SKishon Vijay Abraham I 	unsigned int num_parents;
61428081b72SKishon Vijay Abraham I 	char clk_name[100];
61528081b72SKishon Vijay Abraham I 	struct clk *clk;
61628081b72SKishon Vijay Abraham I 	int i;
61728081b72SKishon Vijay Abraham I 
61828081b72SKishon Vijay Abraham I 	mux = devm_kzalloc(dev, sizeof(*mux), GFP_KERNEL);
61928081b72SKishon Vijay Abraham I 	if (!mux)
62028081b72SKishon Vijay Abraham I 		return -ENOMEM;
62128081b72SKishon Vijay Abraham I 
62228081b72SKishon Vijay Abraham I 	num_parents = SIERRA_NUM_CMN_PLLC_PARENTS;
62328081b72SKishon Vijay Abraham I 	parent_names = devm_kzalloc(dev, (sizeof(char *) * num_parents), GFP_KERNEL);
62428081b72SKishon Vijay Abraham I 	if (!parent_names)
62528081b72SKishon Vijay Abraham I 		return -ENOMEM;
62628081b72SKishon Vijay Abraham I 
62728081b72SKishon Vijay Abraham I 	for (i = 0; i < num_parents; i++) {
62828081b72SKishon Vijay Abraham I 		clk = sp->input_clks[pll_mux_parent_index[clk_index][i]];
62928081b72SKishon Vijay Abraham I 		if (IS_ERR_OR_NULL(clk)) {
63028081b72SKishon Vijay Abraham I 			dev_err(dev, "No parent clock for derived_refclk\n");
63128081b72SKishon Vijay Abraham I 			return PTR_ERR(clk);
63228081b72SKishon Vijay Abraham I 		}
63328081b72SKishon Vijay Abraham I 		parent_names[i] = __clk_get_name(clk);
63428081b72SKishon Vijay Abraham I 	}
63528081b72SKishon Vijay Abraham I 
63628081b72SKishon Vijay Abraham I 	snprintf(clk_name, sizeof(clk_name), "%s_%s", dev_name(dev), clk_names[clk_index]);
63728081b72SKishon Vijay Abraham I 
63828081b72SKishon Vijay Abraham I 	init = &mux->clk_data;
63928081b72SKishon Vijay Abraham I 
64028081b72SKishon Vijay Abraham I 	init->ops = &cdns_sierra_pll_mux_ops;
64128081b72SKishon Vijay Abraham I 	init->flags = CLK_SET_RATE_NO_REPARENT;
64228081b72SKishon Vijay Abraham I 	init->parent_names = parent_names;
64328081b72SKishon Vijay Abraham I 	init->num_parents = num_parents;
64428081b72SKishon Vijay Abraham I 	init->name = clk_name;
64528081b72SKishon Vijay Abraham I 
64628081b72SKishon Vijay Abraham I 	mux->pfdclk_sel_preg = pfdclk1_sel_field;
64728081b72SKishon Vijay Abraham I 	mux->plllc1en_field = plllc1en_field;
64828081b72SKishon Vijay Abraham I 	mux->termen_field = termen_field;
64928081b72SKishon Vijay Abraham I 	mux->hw.init = init;
65028081b72SKishon Vijay Abraham I 
65128081b72SKishon Vijay Abraham I 	clk = devm_clk_register(dev, &mux->hw);
65228081b72SKishon Vijay Abraham I 	if (IS_ERR(clk))
65328081b72SKishon Vijay Abraham I 		return PTR_ERR(clk);
65428081b72SKishon Vijay Abraham I 
65528081b72SKishon Vijay Abraham I 	sp->output_clks[clk_index] = clk;
65628081b72SKishon Vijay Abraham I 
65728081b72SKishon Vijay Abraham I 	return 0;
65828081b72SKishon Vijay Abraham I }
65928081b72SKishon Vijay Abraham I 
66028081b72SKishon Vijay Abraham I static int cdns_sierra_phy_register_pll_mux(struct cdns_sierra_phy *sp)
66128081b72SKishon Vijay Abraham I {
66228081b72SKishon Vijay Abraham I 	struct regmap_field *pfdclk1_sel_field;
66328081b72SKishon Vijay Abraham I 	struct regmap_field *plllc1en_field;
66428081b72SKishon Vijay Abraham I 	struct regmap_field *termen_field;
66528081b72SKishon Vijay Abraham I 	struct device *dev = sp->dev;
66628081b72SKishon Vijay Abraham I 	int ret = 0, i, clk_index;
66728081b72SKishon Vijay Abraham I 
66828081b72SKishon Vijay Abraham I 	clk_index = CDNS_SIERRA_PLL_CMNLC;
66928081b72SKishon Vijay Abraham I 	for (i = 0; i < SIERRA_NUM_CMN_PLLC; i++, clk_index++) {
67028081b72SKishon Vijay Abraham I 		pfdclk1_sel_field = sp->cmn_plllc_pfdclk1_sel_preg[i];
67128081b72SKishon Vijay Abraham I 		plllc1en_field = sp->cmn_refrcv_refclk_plllc1en_preg[i];
67228081b72SKishon Vijay Abraham I 		termen_field = sp->cmn_refrcv_refclk_termen_preg[i];
67328081b72SKishon Vijay Abraham I 
67428081b72SKishon Vijay Abraham I 		ret = cdns_sierra_pll_mux_register(sp, pfdclk1_sel_field, plllc1en_field,
67528081b72SKishon Vijay Abraham I 						   termen_field, clk_index);
67628081b72SKishon Vijay Abraham I 		if (ret) {
67728081b72SKishon Vijay Abraham I 			dev_err(dev, "Fail to register cmn plllc mux\n");
67828081b72SKishon Vijay Abraham I 			return ret;
67928081b72SKishon Vijay Abraham I 		}
68028081b72SKishon Vijay Abraham I 	}
68128081b72SKishon Vijay Abraham I 
68228081b72SKishon Vijay Abraham I 	return 0;
68328081b72SKishon Vijay Abraham I }
68428081b72SKishon Vijay Abraham I 
68528081b72SKishon Vijay Abraham I static void cdns_sierra_clk_unregister(struct cdns_sierra_phy *sp)
68628081b72SKishon Vijay Abraham I {
68728081b72SKishon Vijay Abraham I 	struct device *dev = sp->dev;
68828081b72SKishon Vijay Abraham I 	struct device_node *node = dev->of_node;
68928081b72SKishon Vijay Abraham I 
69028081b72SKishon Vijay Abraham I 	of_clk_del_provider(node);
69128081b72SKishon Vijay Abraham I }
69228081b72SKishon Vijay Abraham I 
69328081b72SKishon Vijay Abraham I static int cdns_sierra_clk_register(struct cdns_sierra_phy *sp)
69428081b72SKishon Vijay Abraham I {
69528081b72SKishon Vijay Abraham I 	struct device *dev = sp->dev;
69628081b72SKishon Vijay Abraham I 	struct device_node *node = dev->of_node;
69728081b72SKishon Vijay Abraham I 	int ret;
69828081b72SKishon Vijay Abraham I 
69928081b72SKishon Vijay Abraham I 	ret = cdns_sierra_phy_register_pll_mux(sp);
70028081b72SKishon Vijay Abraham I 	if (ret) {
70128081b72SKishon Vijay Abraham I 		dev_err(dev, "Failed to pll mux clocks\n");
70228081b72SKishon Vijay Abraham I 		return ret;
70328081b72SKishon Vijay Abraham I 	}
70428081b72SKishon Vijay Abraham I 
70528081b72SKishon Vijay Abraham I 	sp->clk_data.clks = sp->output_clks;
70628081b72SKishon Vijay Abraham I 	sp->clk_data.clk_num = CDNS_SIERRA_OUTPUT_CLOCKS;
70728081b72SKishon Vijay Abraham I 	ret = of_clk_add_provider(node, of_clk_src_onecell_get, &sp->clk_data);
70828081b72SKishon Vijay Abraham I 	if (ret)
70928081b72SKishon Vijay Abraham I 		dev_err(dev, "Failed to add clock provider: %s\n", node->name);
71028081b72SKishon Vijay Abraham I 
71128081b72SKishon Vijay Abraham I 	return ret;
71228081b72SKishon Vijay Abraham I }
71328081b72SKishon Vijay Abraham I 
71444d30d62SAlan Douglas static int cdns_sierra_get_optional(struct cdns_sierra_inst *inst,
71544d30d62SAlan Douglas 				    struct device_node *child)
71644d30d62SAlan Douglas {
717078e9e92SSwapnil Jakhade 	u32 phy_type;
718078e9e92SSwapnil Jakhade 
71944d30d62SAlan Douglas 	if (of_property_read_u32(child, "reg", &inst->mlane))
72044d30d62SAlan Douglas 		return -EINVAL;
72144d30d62SAlan Douglas 
72244d30d62SAlan Douglas 	if (of_property_read_u32(child, "cdns,num-lanes", &inst->num_lanes))
72344d30d62SAlan Douglas 		return -EINVAL;
72444d30d62SAlan Douglas 
725078e9e92SSwapnil Jakhade 	if (of_property_read_u32(child, "cdns,phy-type", &phy_type))
72644d30d62SAlan Douglas 		return -EINVAL;
72744d30d62SAlan Douglas 
728078e9e92SSwapnil Jakhade 	switch (phy_type) {
729078e9e92SSwapnil Jakhade 	case PHY_TYPE_PCIE:
730078e9e92SSwapnil Jakhade 		inst->phy_type = TYPE_PCIE;
731078e9e92SSwapnil Jakhade 		break;
732078e9e92SSwapnil Jakhade 	case PHY_TYPE_USB3:
733078e9e92SSwapnil Jakhade 		inst->phy_type = TYPE_USB;
734078e9e92SSwapnil Jakhade 		break;
735078e9e92SSwapnil Jakhade 	default:
736078e9e92SSwapnil Jakhade 		return -EINVAL;
737078e9e92SSwapnil Jakhade 	}
738078e9e92SSwapnil Jakhade 
7391e902b2aSSwapnil Jakhade 	inst->ssc_mode = EXTERNAL_SSC;
7401e902b2aSSwapnil Jakhade 	of_property_read_u32(child, "cdns,ssc-mode", &inst->ssc_mode);
7411e902b2aSSwapnil Jakhade 
74244d30d62SAlan Douglas 	return 0;
74344d30d62SAlan Douglas }
74444d30d62SAlan Douglas 
745380f5708SKishon Vijay Abraham I static struct regmap *cdns_regmap_init(struct device *dev, void __iomem *base,
746380f5708SKishon Vijay Abraham I 				       u32 block_offset, u8 reg_offset_shift,
747380f5708SKishon Vijay Abraham I 				       const struct regmap_config *config)
748380f5708SKishon Vijay Abraham I {
749380f5708SKishon Vijay Abraham I 	struct cdns_regmap_cdb_context *ctx;
750380f5708SKishon Vijay Abraham I 
751380f5708SKishon Vijay Abraham I 	ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
752380f5708SKishon Vijay Abraham I 	if (!ctx)
753380f5708SKishon Vijay Abraham I 		return ERR_PTR(-ENOMEM);
754380f5708SKishon Vijay Abraham I 
755380f5708SKishon Vijay Abraham I 	ctx->dev = dev;
756380f5708SKishon Vijay Abraham I 	ctx->base = base + block_offset;
757380f5708SKishon Vijay Abraham I 	ctx->reg_offset_shift = reg_offset_shift;
758380f5708SKishon Vijay Abraham I 
759380f5708SKishon Vijay Abraham I 	return devm_regmap_init(dev, NULL, ctx, config);
760380f5708SKishon Vijay Abraham I }
761380f5708SKishon Vijay Abraham I 
762380f5708SKishon Vijay Abraham I static int cdns_regfield_init(struct cdns_sierra_phy *sp)
763380f5708SKishon Vijay Abraham I {
764380f5708SKishon Vijay Abraham I 	struct device *dev = sp->dev;
765380f5708SKishon Vijay Abraham I 	struct regmap_field *field;
76628081b72SKishon Vijay Abraham I 	struct reg_field reg_field;
767380f5708SKishon Vijay Abraham I 	struct regmap *regmap;
768adc4bd6fSKishon Vijay Abraham I 	int i;
769380f5708SKishon Vijay Abraham I 
770380f5708SKishon Vijay Abraham I 	regmap = sp->regmap_common_cdb;
771380f5708SKishon Vijay Abraham I 	field = devm_regmap_field_alloc(dev, regmap, macro_id_type);
772380f5708SKishon Vijay Abraham I 	if (IS_ERR(field)) {
773380f5708SKishon Vijay Abraham I 		dev_err(dev, "MACRO_ID_TYPE reg field init failed\n");
774380f5708SKishon Vijay Abraham I 		return PTR_ERR(field);
775380f5708SKishon Vijay Abraham I 	}
776380f5708SKishon Vijay Abraham I 	sp->macro_id_type = field;
777380f5708SKishon Vijay Abraham I 
77828081b72SKishon Vijay Abraham I 	for (i = 0; i < SIERRA_NUM_CMN_PLLC; i++) {
77928081b72SKishon Vijay Abraham I 		reg_field = cmn_plllc_pfdclk1_sel_preg[i].pfdclk_sel_preg;
78028081b72SKishon Vijay Abraham I 		field = devm_regmap_field_alloc(dev, regmap, reg_field);
78128081b72SKishon Vijay Abraham I 		if (IS_ERR(field)) {
78228081b72SKishon Vijay Abraham I 			dev_err(dev, "PLLLC%d_PFDCLK1_SEL failed\n", i);
78328081b72SKishon Vijay Abraham I 			return PTR_ERR(field);
78428081b72SKishon Vijay Abraham I 		}
78528081b72SKishon Vijay Abraham I 		sp->cmn_plllc_pfdclk1_sel_preg[i] = field;
78628081b72SKishon Vijay Abraham I 
78728081b72SKishon Vijay Abraham I 		reg_field = cmn_plllc_pfdclk1_sel_preg[i].plllc1en_field;
78828081b72SKishon Vijay Abraham I 		field = devm_regmap_field_alloc(dev, regmap, reg_field);
78928081b72SKishon Vijay Abraham I 		if (IS_ERR(field)) {
79028081b72SKishon Vijay Abraham I 			dev_err(dev, "REFRCV%d_REFCLK_PLLLC1EN failed\n", i);
79128081b72SKishon Vijay Abraham I 			return PTR_ERR(field);
79228081b72SKishon Vijay Abraham I 		}
79328081b72SKishon Vijay Abraham I 		sp->cmn_refrcv_refclk_plllc1en_preg[i] = field;
79428081b72SKishon Vijay Abraham I 
79528081b72SKishon Vijay Abraham I 		reg_field = cmn_plllc_pfdclk1_sel_preg[i].termen_field;
79628081b72SKishon Vijay Abraham I 		field = devm_regmap_field_alloc(dev, regmap, reg_field);
79728081b72SKishon Vijay Abraham I 		if (IS_ERR(field)) {
79828081b72SKishon Vijay Abraham I 			dev_err(dev, "REFRCV%d_REFCLK_TERMEN failed\n", i);
79928081b72SKishon Vijay Abraham I 			return PTR_ERR(field);
80028081b72SKishon Vijay Abraham I 		}
80128081b72SKishon Vijay Abraham I 		sp->cmn_refrcv_refclk_termen_preg[i] = field;
80228081b72SKishon Vijay Abraham I 	}
80328081b72SKishon Vijay Abraham I 
8048c95e172SSwapnil Jakhade 	regmap = sp->regmap_phy_pcs_common_cdb;
805380f5708SKishon Vijay Abraham I 	field = devm_regmap_field_alloc(dev, regmap, phy_pll_cfg_1);
806380f5708SKishon Vijay Abraham I 	if (IS_ERR(field)) {
807380f5708SKishon Vijay Abraham I 		dev_err(dev, "PHY_PLL_CFG_1 reg field init failed\n");
808380f5708SKishon Vijay Abraham I 		return PTR_ERR(field);
809380f5708SKishon Vijay Abraham I 	}
810380f5708SKishon Vijay Abraham I 	sp->phy_pll_cfg_1 = field;
811380f5708SKishon Vijay Abraham I 
812f1cc6c3fSSwapnil Jakhade 	regmap = sp->regmap_phy_pma_common_cdb;
813f1cc6c3fSSwapnil Jakhade 	field = devm_regmap_field_alloc(dev, regmap, pma_cmn_ready);
814f1cc6c3fSSwapnil Jakhade 	if (IS_ERR(field)) {
815f1cc6c3fSSwapnil Jakhade 		dev_err(dev, "PHY_PMA_CMN_CTRL reg field init failed\n");
816f1cc6c3fSSwapnil Jakhade 		return PTR_ERR(field);
817f1cc6c3fSSwapnil Jakhade 	}
818f1cc6c3fSSwapnil Jakhade 	sp->pma_cmn_ready = field;
819f1cc6c3fSSwapnil Jakhade 
820adc4bd6fSKishon Vijay Abraham I 	for (i = 0; i < SIERRA_MAX_LANES; i++) {
821adc4bd6fSKishon Vijay Abraham I 		regmap = sp->regmap_lane_cdb[i];
822adc4bd6fSKishon Vijay Abraham I 		field = devm_regmap_field_alloc(dev, regmap, pllctrl_lock);
823adc4bd6fSKishon Vijay Abraham I 		if (IS_ERR(field)) {
824adc4bd6fSKishon Vijay Abraham I 			dev_err(dev, "P%d_ENABLE reg field init failed\n", i);
825adc4bd6fSKishon Vijay Abraham I 			return PTR_ERR(field);
826adc4bd6fSKishon Vijay Abraham I 		}
827adc4bd6fSKishon Vijay Abraham I 		sp->pllctrl_lock[i] = field;
828adc4bd6fSKishon Vijay Abraham I 	}
829adc4bd6fSKishon Vijay Abraham I 
83036ce4163SSwapnil Jakhade 	for (i = 0; i < SIERRA_MAX_LANES; i++) {
83136ce4163SSwapnil Jakhade 		regmap = sp->regmap_phy_pcs_lane_cdb[i];
83236ce4163SSwapnil Jakhade 		field = devm_regmap_field_alloc(dev, regmap, phy_iso_link_ctrl_1);
83336ce4163SSwapnil Jakhade 		if (IS_ERR(field)) {
83436ce4163SSwapnil Jakhade 			dev_err(dev, "PHY_ISO_LINK_CTRL reg field init for lane %d failed\n", i);
83536ce4163SSwapnil Jakhade 			return PTR_ERR(field);
83636ce4163SSwapnil Jakhade 		}
83736ce4163SSwapnil Jakhade 		sp->phy_iso_link_ctrl_1[i] = field;
83836ce4163SSwapnil Jakhade 	}
83936ce4163SSwapnil Jakhade 
840380f5708SKishon Vijay Abraham I 	return 0;
841380f5708SKishon Vijay Abraham I }
842380f5708SKishon Vijay Abraham I 
843380f5708SKishon Vijay Abraham I static int cdns_regmap_init_blocks(struct cdns_sierra_phy *sp,
844380f5708SKishon Vijay Abraham I 				   void __iomem *base, u8 block_offset_shift,
845380f5708SKishon Vijay Abraham I 				   u8 reg_offset_shift)
846380f5708SKishon Vijay Abraham I {
847380f5708SKishon Vijay Abraham I 	struct device *dev = sp->dev;
848380f5708SKishon Vijay Abraham I 	struct regmap *regmap;
849380f5708SKishon Vijay Abraham I 	u32 block_offset;
850380f5708SKishon Vijay Abraham I 	int i;
851380f5708SKishon Vijay Abraham I 
852380f5708SKishon Vijay Abraham I 	for (i = 0; i < SIERRA_MAX_LANES; i++) {
853380f5708SKishon Vijay Abraham I 		block_offset = SIERRA_LANE_CDB_OFFSET(i, block_offset_shift,
854380f5708SKishon Vijay Abraham I 						      reg_offset_shift);
855380f5708SKishon Vijay Abraham I 		regmap = cdns_regmap_init(dev, base, block_offset,
856380f5708SKishon Vijay Abraham I 					  reg_offset_shift,
857380f5708SKishon Vijay Abraham I 					  &cdns_sierra_lane_cdb_config[i]);
858380f5708SKishon Vijay Abraham I 		if (IS_ERR(regmap)) {
859380f5708SKishon Vijay Abraham I 			dev_err(dev, "Failed to init lane CDB regmap\n");
860380f5708SKishon Vijay Abraham I 			return PTR_ERR(regmap);
861380f5708SKishon Vijay Abraham I 		}
862380f5708SKishon Vijay Abraham I 		sp->regmap_lane_cdb[i] = regmap;
863380f5708SKishon Vijay Abraham I 	}
864380f5708SKishon Vijay Abraham I 
865380f5708SKishon Vijay Abraham I 	regmap = cdns_regmap_init(dev, base, SIERRA_COMMON_CDB_OFFSET,
866380f5708SKishon Vijay Abraham I 				  reg_offset_shift,
867380f5708SKishon Vijay Abraham I 				  &cdns_sierra_common_cdb_config);
868380f5708SKishon Vijay Abraham I 	if (IS_ERR(regmap)) {
869380f5708SKishon Vijay Abraham I 		dev_err(dev, "Failed to init common CDB regmap\n");
870380f5708SKishon Vijay Abraham I 		return PTR_ERR(regmap);
871380f5708SKishon Vijay Abraham I 	}
872380f5708SKishon Vijay Abraham I 	sp->regmap_common_cdb = regmap;
873380f5708SKishon Vijay Abraham I 
8748c95e172SSwapnil Jakhade 	block_offset = SIERRA_PHY_PCS_COMMON_OFFSET(block_offset_shift);
875380f5708SKishon Vijay Abraham I 	regmap = cdns_regmap_init(dev, base, block_offset, reg_offset_shift,
8768c95e172SSwapnil Jakhade 				  &cdns_sierra_phy_pcs_cmn_cdb_config);
877380f5708SKishon Vijay Abraham I 	if (IS_ERR(regmap)) {
8788c95e172SSwapnil Jakhade 		dev_err(dev, "Failed to init PHY PCS common CDB regmap\n");
879380f5708SKishon Vijay Abraham I 		return PTR_ERR(regmap);
880380f5708SKishon Vijay Abraham I 	}
8818c95e172SSwapnil Jakhade 	sp->regmap_phy_pcs_common_cdb = regmap;
882380f5708SKishon Vijay Abraham I 
88336ce4163SSwapnil Jakhade 	for (i = 0; i < SIERRA_MAX_LANES; i++) {
88436ce4163SSwapnil Jakhade 		block_offset = SIERRA_PHY_PCS_LANE_CDB_OFFSET(i, block_offset_shift,
88536ce4163SSwapnil Jakhade 							      reg_offset_shift);
88636ce4163SSwapnil Jakhade 		regmap = cdns_regmap_init(dev, base, block_offset,
88736ce4163SSwapnil Jakhade 					  reg_offset_shift,
88836ce4163SSwapnil Jakhade 					  &cdns_sierra_phy_pcs_lane_cdb_config[i]);
88936ce4163SSwapnil Jakhade 		if (IS_ERR(regmap)) {
89036ce4163SSwapnil Jakhade 			dev_err(dev, "Failed to init PHY PCS lane CDB regmap\n");
89136ce4163SSwapnil Jakhade 			return PTR_ERR(regmap);
89236ce4163SSwapnil Jakhade 		}
89336ce4163SSwapnil Jakhade 		sp->regmap_phy_pcs_lane_cdb[i] = regmap;
89436ce4163SSwapnil Jakhade 	}
89536ce4163SSwapnil Jakhade 
896f1cc6c3fSSwapnil Jakhade 	block_offset = SIERRA_PHY_PMA_COMMON_OFFSET(block_offset_shift);
897f1cc6c3fSSwapnil Jakhade 	regmap = cdns_regmap_init(dev, base, block_offset, reg_offset_shift,
898f1cc6c3fSSwapnil Jakhade 				  &cdns_sierra_phy_pma_cmn_cdb_config);
899f1cc6c3fSSwapnil Jakhade 	if (IS_ERR(regmap)) {
900f1cc6c3fSSwapnil Jakhade 		dev_err(dev, "Failed to init PHY PMA common CDB regmap\n");
901f1cc6c3fSSwapnil Jakhade 		return PTR_ERR(regmap);
902f1cc6c3fSSwapnil Jakhade 	}
903f1cc6c3fSSwapnil Jakhade 	sp->regmap_phy_pma_common_cdb = regmap;
904f1cc6c3fSSwapnil Jakhade 
905380f5708SKishon Vijay Abraham I 	return 0;
906380f5708SKishon Vijay Abraham I }
907380f5708SKishon Vijay Abraham I 
9087e016cbcSKishon Vijay Abraham I static int cdns_sierra_phy_get_clocks(struct cdns_sierra_phy *sp,
9097e016cbcSKishon Vijay Abraham I 				      struct device *dev)
9107e016cbcSKishon Vijay Abraham I {
9117e016cbcSKishon Vijay Abraham I 	struct clk *clk;
9127e016cbcSKishon Vijay Abraham I 	int ret;
9137e016cbcSKishon Vijay Abraham I 
9147e016cbcSKishon Vijay Abraham I 	clk = devm_clk_get_optional(dev, "phy_clk");
9157e016cbcSKishon Vijay Abraham I 	if (IS_ERR(clk)) {
9167e016cbcSKishon Vijay Abraham I 		dev_err(dev, "failed to get clock phy_clk\n");
9177e016cbcSKishon Vijay Abraham I 		return PTR_ERR(clk);
9187e016cbcSKishon Vijay Abraham I 	}
919a0c30cd7SKishon Vijay Abraham I 	sp->input_clks[PHY_CLK] = clk;
9207e016cbcSKishon Vijay Abraham I 
9217e016cbcSKishon Vijay Abraham I 	clk = devm_clk_get_optional(dev, "cmn_refclk_dig_div");
9227e016cbcSKishon Vijay Abraham I 	if (IS_ERR(clk)) {
9237e016cbcSKishon Vijay Abraham I 		dev_err(dev, "cmn_refclk_dig_div clock not found\n");
9247e016cbcSKishon Vijay Abraham I 		ret = PTR_ERR(clk);
9257e016cbcSKishon Vijay Abraham I 		return ret;
9267e016cbcSKishon Vijay Abraham I 	}
927a0c30cd7SKishon Vijay Abraham I 	sp->input_clks[CMN_REFCLK_DIG_DIV] = clk;
9287e016cbcSKishon Vijay Abraham I 
9297e016cbcSKishon Vijay Abraham I 	clk = devm_clk_get_optional(dev, "cmn_refclk1_dig_div");
9307e016cbcSKishon Vijay Abraham I 	if (IS_ERR(clk)) {
9317e016cbcSKishon Vijay Abraham I 		dev_err(dev, "cmn_refclk1_dig_div clock not found\n");
9327e016cbcSKishon Vijay Abraham I 		ret = PTR_ERR(clk);
9337e016cbcSKishon Vijay Abraham I 		return ret;
9347e016cbcSKishon Vijay Abraham I 	}
935a0c30cd7SKishon Vijay Abraham I 	sp->input_clks[CMN_REFCLK1_DIG_DIV] = clk;
9367e016cbcSKishon Vijay Abraham I 
93728081b72SKishon Vijay Abraham I 	clk = devm_clk_get_optional(dev, "pll0_refclk");
93828081b72SKishon Vijay Abraham I 	if (IS_ERR(clk)) {
93928081b72SKishon Vijay Abraham I 		dev_err(dev, "pll0_refclk clock not found\n");
94028081b72SKishon Vijay Abraham I 		ret = PTR_ERR(clk);
94128081b72SKishon Vijay Abraham I 		return ret;
94228081b72SKishon Vijay Abraham I 	}
94328081b72SKishon Vijay Abraham I 	sp->input_clks[PLL0_REFCLK] = clk;
94428081b72SKishon Vijay Abraham I 
94528081b72SKishon Vijay Abraham I 	clk = devm_clk_get_optional(dev, "pll1_refclk");
94628081b72SKishon Vijay Abraham I 	if (IS_ERR(clk)) {
94728081b72SKishon Vijay Abraham I 		dev_err(dev, "pll1_refclk clock not found\n");
94828081b72SKishon Vijay Abraham I 		ret = PTR_ERR(clk);
94928081b72SKishon Vijay Abraham I 		return ret;
95028081b72SKishon Vijay Abraham I 	}
95128081b72SKishon Vijay Abraham I 	sp->input_clks[PLL1_REFCLK] = clk;
95228081b72SKishon Vijay Abraham I 
9537e016cbcSKishon Vijay Abraham I 	return 0;
9547e016cbcSKishon Vijay Abraham I }
9557e016cbcSKishon Vijay Abraham I 
9561436ec30SKishon Vijay Abraham I static int cdns_sierra_phy_enable_clocks(struct cdns_sierra_phy *sp)
9571436ec30SKishon Vijay Abraham I {
9581436ec30SKishon Vijay Abraham I 	int ret;
9591436ec30SKishon Vijay Abraham I 
9601436ec30SKishon Vijay Abraham I 	ret = clk_prepare_enable(sp->input_clks[PHY_CLK]);
9611436ec30SKishon Vijay Abraham I 	if (ret)
9621436ec30SKishon Vijay Abraham I 		return ret;
9631436ec30SKishon Vijay Abraham I 
9641436ec30SKishon Vijay Abraham I 	ret = clk_prepare_enable(sp->output_clks[CDNS_SIERRA_PLL_CMNLC]);
9651436ec30SKishon Vijay Abraham I 	if (ret)
9661436ec30SKishon Vijay Abraham I 		goto err_pll_cmnlc;
9671436ec30SKishon Vijay Abraham I 
9681436ec30SKishon Vijay Abraham I 	ret = clk_prepare_enable(sp->output_clks[CDNS_SIERRA_PLL_CMNLC1]);
9691436ec30SKishon Vijay Abraham I 	if (ret)
9701436ec30SKishon Vijay Abraham I 		goto err_pll_cmnlc1;
9711436ec30SKishon Vijay Abraham I 
9721436ec30SKishon Vijay Abraham I 	return 0;
9731436ec30SKishon Vijay Abraham I 
9741436ec30SKishon Vijay Abraham I err_pll_cmnlc1:
9751436ec30SKishon Vijay Abraham I 	clk_disable_unprepare(sp->output_clks[CDNS_SIERRA_PLL_CMNLC]);
9761436ec30SKishon Vijay Abraham I 
9771436ec30SKishon Vijay Abraham I err_pll_cmnlc:
9781436ec30SKishon Vijay Abraham I 	clk_disable_unprepare(sp->input_clks[PHY_CLK]);
9791436ec30SKishon Vijay Abraham I 
9801436ec30SKishon Vijay Abraham I 	return ret;
9811436ec30SKishon Vijay Abraham I }
9821436ec30SKishon Vijay Abraham I 
9831436ec30SKishon Vijay Abraham I static void cdns_sierra_phy_disable_clocks(struct cdns_sierra_phy *sp)
9841436ec30SKishon Vijay Abraham I {
9851436ec30SKishon Vijay Abraham I 	clk_disable_unprepare(sp->output_clks[CDNS_SIERRA_PLL_CMNLC1]);
9861436ec30SKishon Vijay Abraham I 	clk_disable_unprepare(sp->output_clks[CDNS_SIERRA_PLL_CMNLC]);
9871436ec30SKishon Vijay Abraham I 	clk_disable_unprepare(sp->input_clks[PHY_CLK]);
9881436ec30SKishon Vijay Abraham I }
9891436ec30SKishon Vijay Abraham I 
9901d5f40e0SKishon Vijay Abraham I static int cdns_sierra_phy_get_resets(struct cdns_sierra_phy *sp,
9911d5f40e0SKishon Vijay Abraham I 				      struct device *dev)
9921d5f40e0SKishon Vijay Abraham I {
9931d5f40e0SKishon Vijay Abraham I 	struct reset_control *rst;
9941d5f40e0SKishon Vijay Abraham I 
99515b0b82dSKishon Vijay Abraham I 	rst = devm_reset_control_get_exclusive(dev, "sierra_reset");
9961d5f40e0SKishon Vijay Abraham I 	if (IS_ERR(rst)) {
9971d5f40e0SKishon Vijay Abraham I 		dev_err(dev, "failed to get reset\n");
9981d5f40e0SKishon Vijay Abraham I 		return PTR_ERR(rst);
9991d5f40e0SKishon Vijay Abraham I 	}
10001d5f40e0SKishon Vijay Abraham I 	sp->phy_rst = rst;
10011d5f40e0SKishon Vijay Abraham I 
100215b0b82dSKishon Vijay Abraham I 	rst = devm_reset_control_get_optional_exclusive(dev, "sierra_apb");
10031d5f40e0SKishon Vijay Abraham I 	if (IS_ERR(rst)) {
10041d5f40e0SKishon Vijay Abraham I 		dev_err(dev, "failed to get apb reset\n");
10051d5f40e0SKishon Vijay Abraham I 		return PTR_ERR(rst);
10061d5f40e0SKishon Vijay Abraham I 	}
10071d5f40e0SKishon Vijay Abraham I 	sp->apb_rst = rst;
10081d5f40e0SKishon Vijay Abraham I 
10091d5f40e0SKishon Vijay Abraham I 	return 0;
10101d5f40e0SKishon Vijay Abraham I }
10111d5f40e0SKishon Vijay Abraham I 
101244d30d62SAlan Douglas static int cdns_sierra_phy_probe(struct platform_device *pdev)
101344d30d62SAlan Douglas {
101444d30d62SAlan Douglas 	struct cdns_sierra_phy *sp;
101544d30d62SAlan Douglas 	struct phy_provider *phy_provider;
101644d30d62SAlan Douglas 	struct device *dev = &pdev->dev;
1017c3c11d55SSwapnil Jakhade 	const struct cdns_sierra_data *data;
1018380f5708SKishon Vijay Abraham I 	unsigned int id_value;
101944d30d62SAlan Douglas 	int i, ret, node = 0;
1020380f5708SKishon Vijay Abraham I 	void __iomem *base;
102144d30d62SAlan Douglas 	struct device_node *dn = dev->of_node, *child;
102244d30d62SAlan Douglas 
102344d30d62SAlan Douglas 	if (of_get_child_count(dn) == 0)
102444d30d62SAlan Douglas 		return -ENODEV;
102544d30d62SAlan Douglas 
1026380f5708SKishon Vijay Abraham I 	/* Get init data for this PHY */
1027c3c11d55SSwapnil Jakhade 	data = of_device_get_match_data(dev);
1028c3c11d55SSwapnil Jakhade 	if (!data)
1029380f5708SKishon Vijay Abraham I 		return -EINVAL;
1030380f5708SKishon Vijay Abraham I 
103144d30d62SAlan Douglas 	sp = devm_kzalloc(dev, sizeof(*sp), GFP_KERNEL);
103244d30d62SAlan Douglas 	if (!sp)
103344d30d62SAlan Douglas 		return -ENOMEM;
103444d30d62SAlan Douglas 	dev_set_drvdata(dev, sp);
103544d30d62SAlan Douglas 	sp->dev = dev;
1036380f5708SKishon Vijay Abraham I 	sp->init_data = data;
103744d30d62SAlan Douglas 
1038fa629094SChunfeng Yun 	base = devm_platform_ioremap_resource(pdev, 0);
1039380f5708SKishon Vijay Abraham I 	if (IS_ERR(base)) {
104044d30d62SAlan Douglas 		dev_err(dev, "missing \"reg\"\n");
1041380f5708SKishon Vijay Abraham I 		return PTR_ERR(base);
104244d30d62SAlan Douglas 	}
104344d30d62SAlan Douglas 
1044380f5708SKishon Vijay Abraham I 	ret = cdns_regmap_init_blocks(sp, base, data->block_offset_shift,
1045380f5708SKishon Vijay Abraham I 				      data->reg_offset_shift);
1046380f5708SKishon Vijay Abraham I 	if (ret)
1047380f5708SKishon Vijay Abraham I 		return ret;
1048380f5708SKishon Vijay Abraham I 
1049380f5708SKishon Vijay Abraham I 	ret = cdns_regfield_init(sp);
1050380f5708SKishon Vijay Abraham I 	if (ret)
1051380f5708SKishon Vijay Abraham I 		return ret;
105244d30d62SAlan Douglas 
105344d30d62SAlan Douglas 	platform_set_drvdata(pdev, sp);
105444d30d62SAlan Douglas 
10557e016cbcSKishon Vijay Abraham I 	ret = cdns_sierra_phy_get_clocks(sp, dev);
10567e016cbcSKishon Vijay Abraham I 	if (ret)
10577e016cbcSKishon Vijay Abraham I 		return ret;
105844d30d62SAlan Douglas 
105928081b72SKishon Vijay Abraham I 	ret = cdns_sierra_clk_register(sp);
10601d5f40e0SKishon Vijay Abraham I 	if (ret)
10611d5f40e0SKishon Vijay Abraham I 		return ret;
106244d30d62SAlan Douglas 
106328081b72SKishon Vijay Abraham I 	ret = cdns_sierra_phy_get_resets(sp, dev);
106428081b72SKishon Vijay Abraham I 	if (ret)
106528081b72SKishon Vijay Abraham I 		goto unregister_clk;
106628081b72SKishon Vijay Abraham I 
10671436ec30SKishon Vijay Abraham I 	ret = cdns_sierra_phy_enable_clocks(sp);
106844d30d62SAlan Douglas 	if (ret)
106928081b72SKishon Vijay Abraham I 		goto unregister_clk;
107044d30d62SAlan Douglas 
107144d30d62SAlan Douglas 	/* Enable APB */
107244d30d62SAlan Douglas 	reset_control_deassert(sp->apb_rst);
107344d30d62SAlan Douglas 
107444d30d62SAlan Douglas 	/* Check that PHY is present */
1075380f5708SKishon Vijay Abraham I 	regmap_field_read(sp->macro_id_type, &id_value);
1076380f5708SKishon Vijay Abraham I 	if  (sp->init_data->id_value != id_value) {
107744d30d62SAlan Douglas 		ret = -EINVAL;
107844d30d62SAlan Douglas 		goto clk_disable;
107944d30d62SAlan Douglas 	}
108044d30d62SAlan Douglas 
108144d30d62SAlan Douglas 	sp->autoconf = of_property_read_bool(dn, "cdns,autoconf");
108244d30d62SAlan Douglas 
108344d30d62SAlan Douglas 	for_each_available_child_of_node(dn, child) {
108444d30d62SAlan Douglas 		struct phy *gphy;
108544d30d62SAlan Douglas 
108603ada5a3SKishon Vijay Abraham I 		if (!(of_node_name_eq(child, "phy") ||
108703ada5a3SKishon Vijay Abraham I 		      of_node_name_eq(child, "link")))
108803ada5a3SKishon Vijay Abraham I 			continue;
108903ada5a3SKishon Vijay Abraham I 
109044d30d62SAlan Douglas 		sp->phys[node].lnk_rst =
1091b872936fSKishon Vijay Abraham I 			of_reset_control_array_get_exclusive(child);
109244d30d62SAlan Douglas 
109344d30d62SAlan Douglas 		if (IS_ERR(sp->phys[node].lnk_rst)) {
109444d30d62SAlan Douglas 			dev_err(dev, "failed to get reset %s\n",
109544d30d62SAlan Douglas 				child->full_name);
109644d30d62SAlan Douglas 			ret = PTR_ERR(sp->phys[node].lnk_rst);
109744d30d62SAlan Douglas 			goto put_child2;
109844d30d62SAlan Douglas 		}
109944d30d62SAlan Douglas 
110044d30d62SAlan Douglas 		if (!sp->autoconf) {
110144d30d62SAlan Douglas 			ret = cdns_sierra_get_optional(&sp->phys[node], child);
110244d30d62SAlan Douglas 			if (ret) {
110344d30d62SAlan Douglas 				dev_err(dev, "missing property in node %s\n",
110444d30d62SAlan Douglas 					child->name);
110544d30d62SAlan Douglas 				goto put_child;
110644d30d62SAlan Douglas 			}
110744d30d62SAlan Douglas 		}
110844d30d62SAlan Douglas 
1109a43f72aeSKishon Vijay Abraham I 		sp->num_lanes += sp->phys[node].num_lanes;
1110a43f72aeSKishon Vijay Abraham I 
111144d30d62SAlan Douglas 		gphy = devm_phy_create(dev, child, &ops);
111244d30d62SAlan Douglas 
111344d30d62SAlan Douglas 		if (IS_ERR(gphy)) {
111444d30d62SAlan Douglas 			ret = PTR_ERR(gphy);
111544d30d62SAlan Douglas 			goto put_child;
111644d30d62SAlan Douglas 		}
111744d30d62SAlan Douglas 		sp->phys[node].phy = gphy;
111844d30d62SAlan Douglas 		phy_set_drvdata(gphy, &sp->phys[node]);
111944d30d62SAlan Douglas 
112044d30d62SAlan Douglas 		node++;
112144d30d62SAlan Douglas 	}
112244d30d62SAlan Douglas 	sp->nsubnodes = node;
112344d30d62SAlan Douglas 
1124a43f72aeSKishon Vijay Abraham I 	if (sp->num_lanes > SIERRA_MAX_LANES) {
11256411e386SWang Wensheng 		ret = -EINVAL;
1126a43f72aeSKishon Vijay Abraham I 		dev_err(dev, "Invalid lane configuration\n");
1127a43f72aeSKishon Vijay Abraham I 		goto put_child2;
1128a43f72aeSKishon Vijay Abraham I 	}
1129a43f72aeSKishon Vijay Abraham I 
113044d30d62SAlan Douglas 	/* If more than one subnode, configure the PHY as multilink */
113144d30d62SAlan Douglas 	if (!sp->autoconf && sp->nsubnodes > 1)
1132380f5708SKishon Vijay Abraham I 		regmap_field_write(sp->phy_pll_cfg_1, 0x1);
113344d30d62SAlan Douglas 
113444d30d62SAlan Douglas 	pm_runtime_enable(dev);
113544d30d62SAlan Douglas 	phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
113644d30d62SAlan Douglas 	return PTR_ERR_OR_ZERO(phy_provider);
113744d30d62SAlan Douglas 
113844d30d62SAlan Douglas put_child:
113944d30d62SAlan Douglas 	node++;
114044d30d62SAlan Douglas put_child2:
114144d30d62SAlan Douglas 	for (i = 0; i < node; i++)
114244d30d62SAlan Douglas 		reset_control_put(sp->phys[i].lnk_rst);
114344d30d62SAlan Douglas 	of_node_put(child);
114444d30d62SAlan Douglas clk_disable:
11451436ec30SKishon Vijay Abraham I 	cdns_sierra_phy_disable_clocks(sp);
114644d30d62SAlan Douglas 	reset_control_assert(sp->apb_rst);
114728081b72SKishon Vijay Abraham I unregister_clk:
114828081b72SKishon Vijay Abraham I 	cdns_sierra_clk_unregister(sp);
114944d30d62SAlan Douglas 	return ret;
115044d30d62SAlan Douglas }
115144d30d62SAlan Douglas 
115244d30d62SAlan Douglas static int cdns_sierra_phy_remove(struct platform_device *pdev)
115344d30d62SAlan Douglas {
1154748e3456SKishon Vijay Abraham I 	struct cdns_sierra_phy *phy = platform_get_drvdata(pdev);
115544d30d62SAlan Douglas 	int i;
115644d30d62SAlan Douglas 
115744d30d62SAlan Douglas 	reset_control_assert(phy->phy_rst);
115844d30d62SAlan Douglas 	reset_control_assert(phy->apb_rst);
115944d30d62SAlan Douglas 	pm_runtime_disable(&pdev->dev);
116044d30d62SAlan Douglas 
11611436ec30SKishon Vijay Abraham I 	cdns_sierra_phy_disable_clocks(phy);
116244d30d62SAlan Douglas 	/*
116344d30d62SAlan Douglas 	 * The device level resets will be put automatically.
116444d30d62SAlan Douglas 	 * Need to put the subnode resets here though.
116544d30d62SAlan Douglas 	 */
116644d30d62SAlan Douglas 	for (i = 0; i < phy->nsubnodes; i++) {
116744d30d62SAlan Douglas 		reset_control_assert(phy->phys[i].lnk_rst);
116844d30d62SAlan Douglas 		reset_control_put(phy->phys[i].lnk_rst);
116944d30d62SAlan Douglas 	}
117029c2d02aSKishon Vijay Abraham I 
117128081b72SKishon Vijay Abraham I 	cdns_sierra_clk_unregister(phy);
117229c2d02aSKishon Vijay Abraham I 
117344d30d62SAlan Douglas 	return 0;
117444d30d62SAlan Douglas }
117544d30d62SAlan Douglas 
1176fa105172SSwapnil Jakhade /* PCIE PHY PCS common configuration */
1177fa105172SSwapnil Jakhade static struct cdns_reg_pairs pcie_phy_pcs_cmn_regs[] = {
1178fa105172SSwapnil Jakhade 	{0x0430, SIERRA_PHY_PIPE_CMN_CTRL1}
1179fa105172SSwapnil Jakhade };
1180fa105172SSwapnil Jakhade 
1181fa105172SSwapnil Jakhade static struct cdns_sierra_vals pcie_phy_pcs_cmn_vals = {
1182fa105172SSwapnil Jakhade 	.reg_pairs = pcie_phy_pcs_cmn_regs,
1183fa105172SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(pcie_phy_pcs_cmn_regs),
1184fa105172SSwapnil Jakhade };
1185fa105172SSwapnil Jakhade 
1186*7a5ad9b4SSwapnil Jakhade /* refclk100MHz_32b_PCIe_cmn_pll_no_ssc */
1187*7a5ad9b4SSwapnil Jakhade static const struct cdns_reg_pairs cdns_pcie_cmn_regs_no_ssc[] = {
1188*7a5ad9b4SSwapnil Jakhade 	{0x2105, SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG},
1189*7a5ad9b4SSwapnil Jakhade 	{0x2105, SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG},
1190*7a5ad9b4SSwapnil Jakhade 	{0x8A06, SIERRA_CMN_PLLLC_BWCAL_MODE1_PREG},
1191*7a5ad9b4SSwapnil Jakhade 	{0x8A06, SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG}
1192*7a5ad9b4SSwapnil Jakhade };
1193*7a5ad9b4SSwapnil Jakhade 
1194*7a5ad9b4SSwapnil Jakhade /* refclk100MHz_32b_PCIe_ln_no_ssc */
1195*7a5ad9b4SSwapnil Jakhade static const struct cdns_reg_pairs cdns_pcie_ln_regs_no_ssc[] = {
1196*7a5ad9b4SSwapnil Jakhade 	{0xFC08, SIERRA_DET_STANDEC_A_PREG},
1197*7a5ad9b4SSwapnil Jakhade 	{0x001D, SIERRA_PSM_A3IN_TMR_PREG},
1198*7a5ad9b4SSwapnil Jakhade 	{0x1555, SIERRA_DFE_BIASTRIM_PREG},
1199*7a5ad9b4SSwapnil Jakhade 	{0x9703, SIERRA_DRVCTRL_BOOST_PREG},
1200*7a5ad9b4SSwapnil Jakhade 	{0x8055, SIERRA_RX_CREQ_FLTR_A_MODE3_PREG},
1201*7a5ad9b4SSwapnil Jakhade 	{0x80BB, SIERRA_RX_CREQ_FLTR_A_MODE2_PREG},
1202*7a5ad9b4SSwapnil Jakhade 	{0x8351, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG},
1203*7a5ad9b4SSwapnil Jakhade 	{0x8349, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
1204*7a5ad9b4SSwapnil Jakhade 	{0x0002, SIERRA_CREQ_DCBIASATTEN_OVR_PREG},
1205*7a5ad9b4SSwapnil Jakhade 	{0x9800, SIERRA_RX_CTLE_CAL_PREG},
1206*7a5ad9b4SSwapnil Jakhade 	{0x5624, SIERRA_DEQ_CONCUR_CTRL2_PREG},
1207*7a5ad9b4SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_EPIPWR_CTRL2_PREG},
1208*7a5ad9b4SSwapnil Jakhade 	{0x00FF, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG},
1209*7a5ad9b4SSwapnil Jakhade 	{0x4C4C, SIERRA_DEQ_ERRCMP_CTRL_PREG},
1210*7a5ad9b4SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_OFFSET_CTRL_PREG},
1211*7a5ad9b4SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_GAIN_CTRL_PREG},
1212*7a5ad9b4SSwapnil Jakhade 	{0x0041, SIERRA_DEQ_GLUT0},
1213*7a5ad9b4SSwapnil Jakhade 	{0x0082, SIERRA_DEQ_GLUT1},
1214*7a5ad9b4SSwapnil Jakhade 	{0x00C3, SIERRA_DEQ_GLUT2},
1215*7a5ad9b4SSwapnil Jakhade 	{0x0145, SIERRA_DEQ_GLUT3},
1216*7a5ad9b4SSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT4},
1217*7a5ad9b4SSwapnil Jakhade 	{0x09E7, SIERRA_DEQ_ALUT0},
1218*7a5ad9b4SSwapnil Jakhade 	{0x09A6, SIERRA_DEQ_ALUT1},
1219*7a5ad9b4SSwapnil Jakhade 	{0x0965, SIERRA_DEQ_ALUT2},
1220*7a5ad9b4SSwapnil Jakhade 	{0x08E3, SIERRA_DEQ_ALUT3},
1221*7a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP0},
1222*7a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP1},
1223*7a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP2},
1224*7a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP3},
1225*7a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP4},
1226*7a5ad9b4SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_PRECUR_PREG},
1227*7a5ad9b4SSwapnil Jakhade 	{0x0280, SIERRA_DEQ_POSTCUR_PREG},
1228*7a5ad9b4SSwapnil Jakhade 	{0x8F00, SIERRA_DEQ_POSTCUR_DECR_PREG},
1229*7a5ad9b4SSwapnil Jakhade 	{0x3C0F, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG},
1230*7a5ad9b4SSwapnil Jakhade 	{0x1C0C, SIERRA_DEQ_TAU_CTRL2_PREG},
1231*7a5ad9b4SSwapnil Jakhade 	{0x0100, SIERRA_DEQ_TAU_CTRL3_PREG},
1232*7a5ad9b4SSwapnil Jakhade 	{0x5E82, SIERRA_DEQ_OPENEYE_CTRL_PREG},
1233*7a5ad9b4SSwapnil Jakhade 	{0x002B, SIERRA_CPI_TRIM_PREG},
1234*7a5ad9b4SSwapnil Jakhade 	{0x0003, SIERRA_EPI_CTRL_PREG},
1235*7a5ad9b4SSwapnil Jakhade 	{0x803F, SIERRA_SDFILT_H2L_A_PREG},
1236*7a5ad9b4SSwapnil Jakhade 	{0x0004, SIERRA_RXBUFFER_CTLECTRL_PREG},
1237*7a5ad9b4SSwapnil Jakhade 	{0x2010, SIERRA_RXBUFFER_RCDFECTRL_PREG},
1238*7a5ad9b4SSwapnil Jakhade 	{0x4432, SIERRA_RXBUFFER_DFECTRL_PREG}
1239*7a5ad9b4SSwapnil Jakhade };
1240*7a5ad9b4SSwapnil Jakhade 
1241*7a5ad9b4SSwapnil Jakhade static struct cdns_sierra_vals pcie_100_no_ssc_cmn_vals = {
1242*7a5ad9b4SSwapnil Jakhade 	.reg_pairs = cdns_pcie_cmn_regs_no_ssc,
1243*7a5ad9b4SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(cdns_pcie_cmn_regs_no_ssc),
1244*7a5ad9b4SSwapnil Jakhade };
1245*7a5ad9b4SSwapnil Jakhade 
1246*7a5ad9b4SSwapnil Jakhade static struct cdns_sierra_vals pcie_100_no_ssc_ln_vals = {
1247*7a5ad9b4SSwapnil Jakhade 	.reg_pairs = cdns_pcie_ln_regs_no_ssc,
1248*7a5ad9b4SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(cdns_pcie_ln_regs_no_ssc),
1249*7a5ad9b4SSwapnil Jakhade };
1250*7a5ad9b4SSwapnil Jakhade 
1251*7a5ad9b4SSwapnil Jakhade /* refclk100MHz_32b_PCIe_cmn_pll_int_ssc */
1252*7a5ad9b4SSwapnil Jakhade static const struct cdns_reg_pairs cdns_pcie_cmn_regs_int_ssc[] = {
1253*7a5ad9b4SSwapnil Jakhade 	{0x000E, SIERRA_CMN_PLLLC_MODE_PREG},
1254*7a5ad9b4SSwapnil Jakhade 	{0x4006, SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG},
1255*7a5ad9b4SSwapnil Jakhade 	{0x4006, SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG},
1256*7a5ad9b4SSwapnil Jakhade 	{0x0000, SIERRA_CMN_PLLLC_BWCAL_MODE1_PREG},
1257*7a5ad9b4SSwapnil Jakhade 	{0x0000, SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG},
1258*7a5ad9b4SSwapnil Jakhade 	{0x0581, SIERRA_CMN_PLLLC_DSMCORR_PREG},
1259*7a5ad9b4SSwapnil Jakhade 	{0x7F80, SIERRA_CMN_PLLLC_SS_PREG},
1260*7a5ad9b4SSwapnil Jakhade 	{0x0041, SIERRA_CMN_PLLLC_SS_AMP_STEP_SIZE_PREG},
1261*7a5ad9b4SSwapnil Jakhade 	{0x0464, SIERRA_CMN_PLLLC_SSTWOPT_PREG},
1262*7a5ad9b4SSwapnil Jakhade 	{0x0D0D, SIERRA_CMN_PLLLC_SS_TIME_STEPSIZE_MODE_PREG},
1263*7a5ad9b4SSwapnil Jakhade 	{0x0060, SIERRA_CMN_PLLLC_LOCK_DELAY_CTRL_PREG}
1264*7a5ad9b4SSwapnil Jakhade };
1265*7a5ad9b4SSwapnil Jakhade 
1266*7a5ad9b4SSwapnil Jakhade /* refclk100MHz_32b_PCIe_ln_int_ssc */
1267*7a5ad9b4SSwapnil Jakhade static const struct cdns_reg_pairs cdns_pcie_ln_regs_int_ssc[] = {
1268*7a5ad9b4SSwapnil Jakhade 	{0xFC08, SIERRA_DET_STANDEC_A_PREG},
1269*7a5ad9b4SSwapnil Jakhade 	{0x001D, SIERRA_PSM_A3IN_TMR_PREG},
1270*7a5ad9b4SSwapnil Jakhade 	{0x1555, SIERRA_DFE_BIASTRIM_PREG},
1271*7a5ad9b4SSwapnil Jakhade 	{0x9703, SIERRA_DRVCTRL_BOOST_PREG},
1272*7a5ad9b4SSwapnil Jakhade 	{0x813E, SIERRA_CLKPATHCTRL_TMR_PREG},
1273*7a5ad9b4SSwapnil Jakhade 	{0x8047, SIERRA_RX_CREQ_FLTR_A_MODE3_PREG},
1274*7a5ad9b4SSwapnil Jakhade 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE2_PREG},
1275*7a5ad9b4SSwapnil Jakhade 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG},
1276*7a5ad9b4SSwapnil Jakhade 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
1277*7a5ad9b4SSwapnil Jakhade 	{0x0002, SIERRA_CREQ_DCBIASATTEN_OVR_PREG},
1278*7a5ad9b4SSwapnil Jakhade 	{0x9800, SIERRA_RX_CTLE_CAL_PREG},
1279*7a5ad9b4SSwapnil Jakhade 	{0x033C, SIERRA_RX_CTLE_MAINTENANCE_PREG},
1280*7a5ad9b4SSwapnil Jakhade 	{0x44CC, SIERRA_CREQ_EQ_OPEN_EYE_THRESH_PREG},
1281*7a5ad9b4SSwapnil Jakhade 	{0x5624, SIERRA_DEQ_CONCUR_CTRL2_PREG},
1282*7a5ad9b4SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_EPIPWR_CTRL2_PREG},
1283*7a5ad9b4SSwapnil Jakhade 	{0x00FF, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG},
1284*7a5ad9b4SSwapnil Jakhade 	{0x4C4C, SIERRA_DEQ_ERRCMP_CTRL_PREG},
1285*7a5ad9b4SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_OFFSET_CTRL_PREG},
1286*7a5ad9b4SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_GAIN_CTRL_PREG},
1287*7a5ad9b4SSwapnil Jakhade 	{0x0041, SIERRA_DEQ_GLUT0},
1288*7a5ad9b4SSwapnil Jakhade 	{0x0082, SIERRA_DEQ_GLUT1},
1289*7a5ad9b4SSwapnil Jakhade 	{0x00C3, SIERRA_DEQ_GLUT2},
1290*7a5ad9b4SSwapnil Jakhade 	{0x0145, SIERRA_DEQ_GLUT3},
1291*7a5ad9b4SSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT4},
1292*7a5ad9b4SSwapnil Jakhade 	{0x09E7, SIERRA_DEQ_ALUT0},
1293*7a5ad9b4SSwapnil Jakhade 	{0x09A6, SIERRA_DEQ_ALUT1},
1294*7a5ad9b4SSwapnil Jakhade 	{0x0965, SIERRA_DEQ_ALUT2},
1295*7a5ad9b4SSwapnil Jakhade 	{0x08E3, SIERRA_DEQ_ALUT3},
1296*7a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP0},
1297*7a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP1},
1298*7a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP2},
1299*7a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP3},
1300*7a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP4},
1301*7a5ad9b4SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_PRECUR_PREG},
1302*7a5ad9b4SSwapnil Jakhade 	{0x0280, SIERRA_DEQ_POSTCUR_PREG},
1303*7a5ad9b4SSwapnil Jakhade 	{0x8F00, SIERRA_DEQ_POSTCUR_DECR_PREG},
1304*7a5ad9b4SSwapnil Jakhade 	{0x3C0F, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG},
1305*7a5ad9b4SSwapnil Jakhade 	{0x1C0C, SIERRA_DEQ_TAU_CTRL2_PREG},
1306*7a5ad9b4SSwapnil Jakhade 	{0x0100, SIERRA_DEQ_TAU_CTRL3_PREG},
1307*7a5ad9b4SSwapnil Jakhade 	{0x5E82, SIERRA_DEQ_OPENEYE_CTRL_PREG},
1308*7a5ad9b4SSwapnil Jakhade 	{0x002B, SIERRA_CPI_TRIM_PREG},
1309*7a5ad9b4SSwapnil Jakhade 	{0x0003, SIERRA_EPI_CTRL_PREG},
1310*7a5ad9b4SSwapnil Jakhade 	{0x803F, SIERRA_SDFILT_H2L_A_PREG},
1311*7a5ad9b4SSwapnil Jakhade 	{0x0004, SIERRA_RXBUFFER_CTLECTRL_PREG},
1312*7a5ad9b4SSwapnil Jakhade 	{0x2010, SIERRA_RXBUFFER_RCDFECTRL_PREG},
1313*7a5ad9b4SSwapnil Jakhade 	{0x4432, SIERRA_RXBUFFER_DFECTRL_PREG}
1314*7a5ad9b4SSwapnil Jakhade };
1315*7a5ad9b4SSwapnil Jakhade 
1316*7a5ad9b4SSwapnil Jakhade static struct cdns_sierra_vals pcie_100_int_ssc_cmn_vals = {
1317*7a5ad9b4SSwapnil Jakhade 	.reg_pairs = cdns_pcie_cmn_regs_int_ssc,
1318*7a5ad9b4SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(cdns_pcie_cmn_regs_int_ssc),
1319*7a5ad9b4SSwapnil Jakhade };
1320*7a5ad9b4SSwapnil Jakhade 
1321*7a5ad9b4SSwapnil Jakhade static struct cdns_sierra_vals pcie_100_int_ssc_ln_vals = {
1322*7a5ad9b4SSwapnil Jakhade 	.reg_pairs = cdns_pcie_ln_regs_int_ssc,
1323*7a5ad9b4SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(cdns_pcie_ln_regs_int_ssc),
1324*7a5ad9b4SSwapnil Jakhade };
1325*7a5ad9b4SSwapnil Jakhade 
1326871002d7SAnil Varughese /* refclk100MHz_32b_PCIe_cmn_pll_ext_ssc */
13273cfb0e8eSRikard Falkeborn static const struct cdns_reg_pairs cdns_pcie_cmn_regs_ext_ssc[] = {
1328871002d7SAnil Varughese 	{0x2106, SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG},
1329871002d7SAnil Varughese 	{0x2106, SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG},
1330871002d7SAnil Varughese 	{0x8A06, SIERRA_CMN_PLLLC_BWCAL_MODE1_PREG},
1331871002d7SAnil Varughese 	{0x8A06, SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG},
1332871002d7SAnil Varughese 	{0x1B1B, SIERRA_CMN_PLLLC_SS_TIME_STEPSIZE_MODE_PREG}
1333871002d7SAnil Varughese };
1334871002d7SAnil Varughese 
1335871002d7SAnil Varughese /* refclk100MHz_32b_PCIe_ln_ext_ssc */
13363cfb0e8eSRikard Falkeborn static const struct cdns_reg_pairs cdns_pcie_ln_regs_ext_ssc[] = {
1337*7a5ad9b4SSwapnil Jakhade 	{0xFC08, SIERRA_DET_STANDEC_A_PREG},
1338*7a5ad9b4SSwapnil Jakhade 	{0x001D, SIERRA_PSM_A3IN_TMR_PREG},
1339*7a5ad9b4SSwapnil Jakhade 	{0x1555, SIERRA_DFE_BIASTRIM_PREG},
1340*7a5ad9b4SSwapnil Jakhade 	{0x9703, SIERRA_DRVCTRL_BOOST_PREG},
1341871002d7SAnil Varughese 	{0x813E, SIERRA_CLKPATHCTRL_TMR_PREG},
1342871002d7SAnil Varughese 	{0x8047, SIERRA_RX_CREQ_FLTR_A_MODE3_PREG},
1343871002d7SAnil Varughese 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE2_PREG},
1344871002d7SAnil Varughese 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG},
1345871002d7SAnil Varughese 	{0x808F, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
1346*7a5ad9b4SSwapnil Jakhade 	{0x0002, SIERRA_CREQ_DCBIASATTEN_OVR_PREG},
1347*7a5ad9b4SSwapnil Jakhade 	{0x9800, SIERRA_RX_CTLE_CAL_PREG},
1348871002d7SAnil Varughese 	{0x033C, SIERRA_RX_CTLE_MAINTENANCE_PREG},
1349*7a5ad9b4SSwapnil Jakhade 	{0x44CC, SIERRA_CREQ_EQ_OPEN_EYE_THRESH_PREG},
1350*7a5ad9b4SSwapnil Jakhade 	{0x5624, SIERRA_DEQ_CONCUR_CTRL2_PREG},
1351*7a5ad9b4SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_EPIPWR_CTRL2_PREG},
1352*7a5ad9b4SSwapnil Jakhade 	{0x00FF, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG},
1353*7a5ad9b4SSwapnil Jakhade 	{0x4C4C, SIERRA_DEQ_ERRCMP_CTRL_PREG},
1354*7a5ad9b4SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_OFFSET_CTRL_PREG},
1355*7a5ad9b4SSwapnil Jakhade 	{0x02FA, SIERRA_DEQ_GAIN_CTRL_PREG},
1356*7a5ad9b4SSwapnil Jakhade 	{0x0041, SIERRA_DEQ_GLUT0},
1357*7a5ad9b4SSwapnil Jakhade 	{0x0082, SIERRA_DEQ_GLUT1},
1358*7a5ad9b4SSwapnil Jakhade 	{0x00C3, SIERRA_DEQ_GLUT2},
1359*7a5ad9b4SSwapnil Jakhade 	{0x0145, SIERRA_DEQ_GLUT3},
1360*7a5ad9b4SSwapnil Jakhade 	{0x0186, SIERRA_DEQ_GLUT4},
1361*7a5ad9b4SSwapnil Jakhade 	{0x09E7, SIERRA_DEQ_ALUT0},
1362*7a5ad9b4SSwapnil Jakhade 	{0x09A6, SIERRA_DEQ_ALUT1},
1363*7a5ad9b4SSwapnil Jakhade 	{0x0965, SIERRA_DEQ_ALUT2},
1364*7a5ad9b4SSwapnil Jakhade 	{0x08E3, SIERRA_DEQ_ALUT3},
1365*7a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP0},
1366*7a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP1},
1367*7a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP2},
1368*7a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP3},
1369*7a5ad9b4SSwapnil Jakhade 	{0x00FA, SIERRA_DEQ_DFETAP4},
1370*7a5ad9b4SSwapnil Jakhade 	{0x000F, SIERRA_DEQ_PRECUR_PREG},
1371*7a5ad9b4SSwapnil Jakhade 	{0x0280, SIERRA_DEQ_POSTCUR_PREG},
1372*7a5ad9b4SSwapnil Jakhade 	{0x8F00, SIERRA_DEQ_POSTCUR_DECR_PREG},
1373*7a5ad9b4SSwapnil Jakhade 	{0x3C0F, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG},
1374*7a5ad9b4SSwapnil Jakhade 	{0x1C0C, SIERRA_DEQ_TAU_CTRL2_PREG},
1375*7a5ad9b4SSwapnil Jakhade 	{0x0100, SIERRA_DEQ_TAU_CTRL3_PREG},
1376*7a5ad9b4SSwapnil Jakhade 	{0x5E82, SIERRA_DEQ_OPENEYE_CTRL_PREG},
1377*7a5ad9b4SSwapnil Jakhade 	{0x002B, SIERRA_CPI_TRIM_PREG},
1378*7a5ad9b4SSwapnil Jakhade 	{0x0003, SIERRA_EPI_CTRL_PREG},
1379*7a5ad9b4SSwapnil Jakhade 	{0x803F, SIERRA_SDFILT_H2L_A_PREG},
1380*7a5ad9b4SSwapnil Jakhade 	{0x0004, SIERRA_RXBUFFER_CTLECTRL_PREG},
1381*7a5ad9b4SSwapnil Jakhade 	{0x2010, SIERRA_RXBUFFER_RCDFECTRL_PREG},
1382*7a5ad9b4SSwapnil Jakhade 	{0x4432, SIERRA_RXBUFFER_DFECTRL_PREG}
1383871002d7SAnil Varughese };
1384871002d7SAnil Varughese 
1385078e9e92SSwapnil Jakhade static struct cdns_sierra_vals pcie_100_ext_ssc_cmn_vals = {
1386078e9e92SSwapnil Jakhade 	.reg_pairs = cdns_pcie_cmn_regs_ext_ssc,
1387078e9e92SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(cdns_pcie_cmn_regs_ext_ssc),
1388078e9e92SSwapnil Jakhade };
1389078e9e92SSwapnil Jakhade 
1390078e9e92SSwapnil Jakhade static struct cdns_sierra_vals pcie_100_ext_ssc_ln_vals = {
1391078e9e92SSwapnil Jakhade 	.reg_pairs = cdns_pcie_ln_regs_ext_ssc,
1392078e9e92SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(cdns_pcie_ln_regs_ext_ssc),
1393078e9e92SSwapnil Jakhade };
1394078e9e92SSwapnil Jakhade 
1395871002d7SAnil Varughese /* refclk100MHz_20b_USB_cmn_pll_ext_ssc */
13963cfb0e8eSRikard Falkeborn static const struct cdns_reg_pairs cdns_usb_cmn_regs_ext_ssc[] = {
1397871002d7SAnil Varughese 	{0x2085, SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG},
1398871002d7SAnil Varughese 	{0x2085, SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG},
1399871002d7SAnil Varughese 	{0x0000, SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG},
1400871002d7SAnil Varughese 	{0x0000, SIERRA_CMN_PLLLC_SS_TIME_STEPSIZE_MODE_PREG}
1401871002d7SAnil Varughese };
1402871002d7SAnil Varughese 
1403871002d7SAnil Varughese /* refclk100MHz_20b_USB_ln_ext_ssc */
14043cfb0e8eSRikard Falkeborn static const struct cdns_reg_pairs cdns_usb_ln_regs_ext_ssc[] = {
1405aead5fd6SKishon Vijay Abraham I 	{0xFE0A, SIERRA_DET_STANDEC_A_PREG},
1406aead5fd6SKishon Vijay Abraham I 	{0x000F, SIERRA_DET_STANDEC_B_PREG},
14072bcf14caSSanket Parmar 	{0x55A5, SIERRA_DET_STANDEC_C_PREG},
1408871002d7SAnil Varughese 	{0x69ad, SIERRA_DET_STANDEC_D_PREG},
1409aead5fd6SKishon Vijay Abraham I 	{0x0241, SIERRA_DET_STANDEC_E_PREG},
14102bcf14caSSanket Parmar 	{0x0110, SIERRA_PSM_LANECAL_DLY_A1_RESETS_PREG},
1411871002d7SAnil Varughese 	{0x0014, SIERRA_PSM_A0IN_TMR_PREG},
1412aead5fd6SKishon Vijay Abraham I 	{0xCF00, SIERRA_PSM_DIAG_PREG},
1413aead5fd6SKishon Vijay Abraham I 	{0x001F, SIERRA_PSC_TX_A0_PREG},
1414aead5fd6SKishon Vijay Abraham I 	{0x0007, SIERRA_PSC_TX_A1_PREG},
1415aead5fd6SKishon Vijay Abraham I 	{0x0003, SIERRA_PSC_TX_A2_PREG},
1416aead5fd6SKishon Vijay Abraham I 	{0x0003, SIERRA_PSC_TX_A3_PREG},
1417aead5fd6SKishon Vijay Abraham I 	{0x0FFF, SIERRA_PSC_RX_A0_PREG},
14182bcf14caSSanket Parmar 	{0x0003, SIERRA_PSC_RX_A1_PREG},
1419aead5fd6SKishon Vijay Abraham I 	{0x0003, SIERRA_PSC_RX_A2_PREG},
1420aead5fd6SKishon Vijay Abraham I 	{0x0001, SIERRA_PSC_RX_A3_PREG},
1421aead5fd6SKishon Vijay Abraham I 	{0x0001, SIERRA_PLLCTRL_SUBRATE_PREG},
1422aead5fd6SKishon Vijay Abraham I 	{0x0406, SIERRA_PLLCTRL_GEN_D_PREG},
1423871002d7SAnil Varughese 	{0x5233, SIERRA_PLLCTRL_CPGAIN_MODE_PREG},
1424871002d7SAnil Varughese 	{0x00CA, SIERRA_CLKPATH_BIASTRIM_PREG},
1425871002d7SAnil Varughese 	{0x2512, SIERRA_DFE_BIASTRIM_PREG},
1426aead5fd6SKishon Vijay Abraham I 	{0x0000, SIERRA_DRVCTRL_ATTEN_PREG},
14272bcf14caSSanket Parmar 	{0x823E, SIERRA_CLKPATHCTRL_TMR_PREG},
14282bcf14caSSanket Parmar 	{0x078F, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG},
14292bcf14caSSanket Parmar 	{0x078F, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
1430aead5fd6SKishon Vijay Abraham I 	{0x7B3C, SIERRA_CREQ_CCLKDET_MODE01_PREG},
14312bcf14caSSanket Parmar 	{0x023C, SIERRA_RX_CTLE_MAINTENANCE_PREG},
1432aead5fd6SKishon Vijay Abraham I 	{0x3232, SIERRA_CREQ_FSMCLK_SEL_PREG},
1433871002d7SAnil Varughese 	{0x0000, SIERRA_CREQ_EQ_CTRL_PREG},
14342bcf14caSSanket Parmar 	{0x0000, SIERRA_CREQ_SPARE_PREG},
1435871002d7SAnil Varughese 	{0xCC44, SIERRA_CREQ_EQ_OPEN_EYE_THRESH_PREG},
14362bcf14caSSanket Parmar 	{0x8452, SIERRA_CTLELUT_CTRL_PREG},
14372bcf14caSSanket Parmar 	{0x4121, SIERRA_DFE_ECMP_RATESEL_PREG},
14382bcf14caSSanket Parmar 	{0x4121, SIERRA_DFE_SMP_RATESEL_PREG},
14392bcf14caSSanket Parmar 	{0x0003, SIERRA_DEQ_PHALIGN_CTRL},
1440871002d7SAnil Varughese 	{0x3200, SIERRA_DEQ_CONCUR_CTRL1_PREG},
1441871002d7SAnil Varughese 	{0x5064, SIERRA_DEQ_CONCUR_CTRL2_PREG},
1442871002d7SAnil Varughese 	{0x0030, SIERRA_DEQ_EPIPWR_CTRL2_PREG},
1443871002d7SAnil Varughese 	{0x0048, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG},
1444871002d7SAnil Varughese 	{0x5A5A, SIERRA_DEQ_ERRCMP_CTRL_PREG},
1445871002d7SAnil Varughese 	{0x02F5, SIERRA_DEQ_OFFSET_CTRL_PREG},
1446871002d7SAnil Varughese 	{0x02F5, SIERRA_DEQ_GAIN_CTRL_PREG},
14472bcf14caSSanket Parmar 	{0x9999, SIERRA_DEQ_VGATUNE_CTRL_PREG},
1448871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT0},
1449871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT1},
1450871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT2},
1451871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT3},
1452871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT4},
1453871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT5},
1454871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT6},
1455871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT7},
1456871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT8},
1457871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT9},
1458871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT10},
1459871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT11},
1460871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT12},
1461871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT13},
1462871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT14},
1463871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT15},
1464871002d7SAnil Varughese 	{0x0014, SIERRA_DEQ_GLUT16},
1465871002d7SAnil Varughese 	{0x0BAE, SIERRA_DEQ_ALUT0},
1466871002d7SAnil Varughese 	{0x0AEB, SIERRA_DEQ_ALUT1},
1467871002d7SAnil Varughese 	{0x0A28, SIERRA_DEQ_ALUT2},
1468871002d7SAnil Varughese 	{0x0965, SIERRA_DEQ_ALUT3},
1469871002d7SAnil Varughese 	{0x08A2, SIERRA_DEQ_ALUT4},
1470871002d7SAnil Varughese 	{0x07DF, SIERRA_DEQ_ALUT5},
1471871002d7SAnil Varughese 	{0x071C, SIERRA_DEQ_ALUT6},
1472871002d7SAnil Varughese 	{0x0659, SIERRA_DEQ_ALUT7},
1473871002d7SAnil Varughese 	{0x0596, SIERRA_DEQ_ALUT8},
1474871002d7SAnil Varughese 	{0x0514, SIERRA_DEQ_ALUT9},
1475871002d7SAnil Varughese 	{0x0492, SIERRA_DEQ_ALUT10},
1476871002d7SAnil Varughese 	{0x0410, SIERRA_DEQ_ALUT11},
1477871002d7SAnil Varughese 	{0x038E, SIERRA_DEQ_ALUT12},
1478871002d7SAnil Varughese 	{0x030C, SIERRA_DEQ_ALUT13},
1479871002d7SAnil Varughese 	{0x03F4, SIERRA_DEQ_DFETAP_CTRL_PREG},
1480871002d7SAnil Varughese 	{0x0001, SIERRA_DFE_EN_1010_IGNORE_PREG},
1481871002d7SAnil Varughese 	{0x3C01, SIERRA_DEQ_TAU_CTRL1_FAST_MAINT_PREG},
1482871002d7SAnil Varughese 	{0x3C40, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG},
1483871002d7SAnil Varughese 	{0x1C08, SIERRA_DEQ_TAU_CTRL2_PREG},
1484871002d7SAnil Varughese 	{0x0033, SIERRA_DEQ_PICTRL_PREG},
1485871002d7SAnil Varughese 	{0x0400, SIERRA_CPICAL_TMRVAL_MODE1_PREG},
1486871002d7SAnil Varughese 	{0x0330, SIERRA_CPICAL_TMRVAL_MODE0_PREG},
1487871002d7SAnil Varughese 	{0x01FF, SIERRA_CPICAL_PICNT_MODE1_PREG},
1488aead5fd6SKishon Vijay Abraham I 	{0x0009, SIERRA_CPI_OUTBUF_RATESEL_PREG},
1489871002d7SAnil Varughese 	{0x3232, SIERRA_CPICAL_RES_STARTCODE_MODE23_PREG},
1490871002d7SAnil Varughese 	{0x0005, SIERRA_LFPSDET_SUPPORT_PREG},
1491aead5fd6SKishon Vijay Abraham I 	{0x000F, SIERRA_LFPSFILT_NS_PREG},
1492aead5fd6SKishon Vijay Abraham I 	{0x0009, SIERRA_LFPSFILT_RD_PREG},
1493aead5fd6SKishon Vijay Abraham I 	{0x0001, SIERRA_LFPSFILT_MP_PREG},
14942bcf14caSSanket Parmar 	{0x6013, SIERRA_SIGDET_SUPPORT_PREG},
1495aead5fd6SKishon Vijay Abraham I 	{0x8013, SIERRA_SDFILT_H2L_A_PREG},
1496871002d7SAnil Varughese 	{0x8009, SIERRA_SDFILT_L2H_PREG},
1497871002d7SAnil Varughese 	{0x0024, SIERRA_RXBUFFER_CTLECTRL_PREG},
1498871002d7SAnil Varughese 	{0x0020, SIERRA_RXBUFFER_RCDFECTRL_PREG},
1499871002d7SAnil Varughese 	{0x4243, SIERRA_RXBUFFER_DFECTRL_PREG}
150044d30d62SAlan Douglas };
150144d30d62SAlan Douglas 
1502078e9e92SSwapnil Jakhade static struct cdns_sierra_vals usb_100_ext_ssc_cmn_vals = {
1503078e9e92SSwapnil Jakhade 	.reg_pairs = cdns_usb_cmn_regs_ext_ssc,
1504078e9e92SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(cdns_usb_cmn_regs_ext_ssc),
1505078e9e92SSwapnil Jakhade };
1506078e9e92SSwapnil Jakhade 
1507078e9e92SSwapnil Jakhade static struct cdns_sierra_vals usb_100_ext_ssc_ln_vals = {
1508078e9e92SSwapnil Jakhade 	.reg_pairs = cdns_usb_ln_regs_ext_ssc,
1509078e9e92SSwapnil Jakhade 	.num_regs = ARRAY_SIZE(cdns_usb_ln_regs_ext_ssc),
1510078e9e92SSwapnil Jakhade };
1511078e9e92SSwapnil Jakhade 
151244d30d62SAlan Douglas static const struct cdns_sierra_data cdns_map_sierra = {
1513078e9e92SSwapnil Jakhade 	.id_value = SIERRA_MACRO_ID,
1514078e9e92SSwapnil Jakhade 	.block_offset_shift = 0x2,
1515078e9e92SSwapnil Jakhade 	.reg_offset_shift = 0x2,
1516fa105172SSwapnil Jakhade 	.pcs_cmn_vals = {
1517fa105172SSwapnil Jakhade 		[TYPE_PCIE] = {
1518fa105172SSwapnil Jakhade 			[TYPE_NONE] = {
1519*7a5ad9b4SSwapnil Jakhade 				[NO_SSC] = &pcie_phy_pcs_cmn_vals,
1520fa105172SSwapnil Jakhade 				[EXTERNAL_SSC] = &pcie_phy_pcs_cmn_vals,
1521*7a5ad9b4SSwapnil Jakhade 				[INTERNAL_SSC] = &pcie_phy_pcs_cmn_vals,
1522fa105172SSwapnil Jakhade 			},
1523fa105172SSwapnil Jakhade 		},
1524fa105172SSwapnil Jakhade 	},
1525078e9e92SSwapnil Jakhade 	.pma_cmn_vals = {
1526078e9e92SSwapnil Jakhade 		[TYPE_PCIE] = {
1527078e9e92SSwapnil Jakhade 			[TYPE_NONE] = {
1528*7a5ad9b4SSwapnil Jakhade 				[NO_SSC] = &pcie_100_no_ssc_cmn_vals,
1529078e9e92SSwapnil Jakhade 				[EXTERNAL_SSC] = &pcie_100_ext_ssc_cmn_vals,
1530*7a5ad9b4SSwapnil Jakhade 				[INTERNAL_SSC] = &pcie_100_int_ssc_cmn_vals,
1531078e9e92SSwapnil Jakhade 			},
1532078e9e92SSwapnil Jakhade 		},
1533078e9e92SSwapnil Jakhade 		[TYPE_USB] = {
1534078e9e92SSwapnil Jakhade 			[TYPE_NONE] = {
1535078e9e92SSwapnil Jakhade 				[EXTERNAL_SSC] = &usb_100_ext_ssc_cmn_vals,
1536078e9e92SSwapnil Jakhade 			},
1537078e9e92SSwapnil Jakhade 		},
1538078e9e92SSwapnil Jakhade 	},
1539078e9e92SSwapnil Jakhade 	.pma_ln_vals = {
1540078e9e92SSwapnil Jakhade 		[TYPE_PCIE] = {
1541078e9e92SSwapnil Jakhade 			[TYPE_NONE] = {
1542*7a5ad9b4SSwapnil Jakhade 				[NO_SSC] = &pcie_100_no_ssc_ln_vals,
1543078e9e92SSwapnil Jakhade 				[EXTERNAL_SSC] = &pcie_100_ext_ssc_ln_vals,
1544*7a5ad9b4SSwapnil Jakhade 				[INTERNAL_SSC] = &pcie_100_int_ssc_ln_vals,
1545078e9e92SSwapnil Jakhade 			},
1546078e9e92SSwapnil Jakhade 		},
1547078e9e92SSwapnil Jakhade 		[TYPE_USB] = {
1548078e9e92SSwapnil Jakhade 			[TYPE_NONE] = {
1549078e9e92SSwapnil Jakhade 				[EXTERNAL_SSC] = &usb_100_ext_ssc_ln_vals,
1550078e9e92SSwapnil Jakhade 			},
1551078e9e92SSwapnil Jakhade 		},
1552078e9e92SSwapnil Jakhade 	},
155344d30d62SAlan Douglas };
155444d30d62SAlan Douglas 
1555367da978SKishon Vijay Abraham I static const struct cdns_sierra_data cdns_ti_map_sierra = {
1556078e9e92SSwapnil Jakhade 	.id_value = SIERRA_MACRO_ID,
1557078e9e92SSwapnil Jakhade 	.block_offset_shift = 0x0,
1558078e9e92SSwapnil Jakhade 	.reg_offset_shift = 0x1,
1559fa105172SSwapnil Jakhade 	.pcs_cmn_vals = {
1560fa105172SSwapnil Jakhade 		[TYPE_PCIE] = {
1561fa105172SSwapnil Jakhade 			[TYPE_NONE] = {
1562*7a5ad9b4SSwapnil Jakhade 				[NO_SSC] = &pcie_phy_pcs_cmn_vals,
1563fa105172SSwapnil Jakhade 				[EXTERNAL_SSC] = &pcie_phy_pcs_cmn_vals,
1564*7a5ad9b4SSwapnil Jakhade 				[INTERNAL_SSC] = &pcie_phy_pcs_cmn_vals,
1565fa105172SSwapnil Jakhade 			},
1566fa105172SSwapnil Jakhade 		},
1567fa105172SSwapnil Jakhade 	},
1568078e9e92SSwapnil Jakhade 	.pma_cmn_vals = {
1569078e9e92SSwapnil Jakhade 		[TYPE_PCIE] = {
1570078e9e92SSwapnil Jakhade 			[TYPE_NONE] = {
1571*7a5ad9b4SSwapnil Jakhade 				[NO_SSC] = &pcie_100_no_ssc_cmn_vals,
1572078e9e92SSwapnil Jakhade 				[EXTERNAL_SSC] = &pcie_100_ext_ssc_cmn_vals,
1573*7a5ad9b4SSwapnil Jakhade 				[INTERNAL_SSC] = &pcie_100_int_ssc_cmn_vals,
1574078e9e92SSwapnil Jakhade 			},
1575078e9e92SSwapnil Jakhade 		},
1576078e9e92SSwapnil Jakhade 		[TYPE_USB] = {
1577078e9e92SSwapnil Jakhade 			[TYPE_NONE] = {
1578078e9e92SSwapnil Jakhade 				[EXTERNAL_SSC] = &usb_100_ext_ssc_cmn_vals,
1579078e9e92SSwapnil Jakhade 			},
1580078e9e92SSwapnil Jakhade 		},
1581078e9e92SSwapnil Jakhade 	},
1582078e9e92SSwapnil Jakhade 	.pma_ln_vals = {
1583078e9e92SSwapnil Jakhade 		[TYPE_PCIE] = {
1584078e9e92SSwapnil Jakhade 			[TYPE_NONE] = {
1585*7a5ad9b4SSwapnil Jakhade 				[NO_SSC] = &pcie_100_no_ssc_ln_vals,
1586078e9e92SSwapnil Jakhade 				[EXTERNAL_SSC] = &pcie_100_ext_ssc_ln_vals,
1587*7a5ad9b4SSwapnil Jakhade 				[INTERNAL_SSC] = &pcie_100_int_ssc_ln_vals,
1588078e9e92SSwapnil Jakhade 			},
1589078e9e92SSwapnil Jakhade 		},
1590078e9e92SSwapnil Jakhade 		[TYPE_USB] = {
1591078e9e92SSwapnil Jakhade 			[TYPE_NONE] = {
1592078e9e92SSwapnil Jakhade 				[EXTERNAL_SSC] = &usb_100_ext_ssc_ln_vals,
1593078e9e92SSwapnil Jakhade 			},
1594078e9e92SSwapnil Jakhade 		},
1595078e9e92SSwapnil Jakhade 	},
1596367da978SKishon Vijay Abraham I };
1597367da978SKishon Vijay Abraham I 
159844d30d62SAlan Douglas static const struct of_device_id cdns_sierra_id_table[] = {
159944d30d62SAlan Douglas 	{
160044d30d62SAlan Douglas 		.compatible = "cdns,sierra-phy-t0",
160144d30d62SAlan Douglas 		.data = &cdns_map_sierra,
160244d30d62SAlan Douglas 	},
1603367da978SKishon Vijay Abraham I 	{
1604367da978SKishon Vijay Abraham I 		.compatible = "ti,sierra-phy-t0",
1605367da978SKishon Vijay Abraham I 		.data = &cdns_ti_map_sierra,
1606367da978SKishon Vijay Abraham I 	},
160744d30d62SAlan Douglas 	{}
160844d30d62SAlan Douglas };
160944d30d62SAlan Douglas MODULE_DEVICE_TABLE(of, cdns_sierra_id_table);
161044d30d62SAlan Douglas 
161144d30d62SAlan Douglas static struct platform_driver cdns_sierra_driver = {
161244d30d62SAlan Douglas 	.probe		= cdns_sierra_phy_probe,
161344d30d62SAlan Douglas 	.remove		= cdns_sierra_phy_remove,
161444d30d62SAlan Douglas 	.driver		= {
161544d30d62SAlan Douglas 		.name	= "cdns-sierra-phy",
161644d30d62SAlan Douglas 		.of_match_table = cdns_sierra_id_table,
161744d30d62SAlan Douglas 	},
161844d30d62SAlan Douglas };
161944d30d62SAlan Douglas module_platform_driver(cdns_sierra_driver);
162044d30d62SAlan Douglas 
162144d30d62SAlan Douglas MODULE_ALIAS("platform:cdns_sierra");
162244d30d62SAlan Douglas MODULE_AUTHOR("Cadence Design Systems");
162344d30d62SAlan Douglas MODULE_DESCRIPTION("CDNS sierra phy driver");
162444d30d62SAlan Douglas MODULE_LICENSE("GPL v2");
1625