1*4882a593Smuzhiyun // SPDX-License-Identifier: GPL-2.0-only
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun * Cadence Torrent SD0801 PHY driver.
4*4882a593Smuzhiyun *
5*4882a593Smuzhiyun * Copyright 2018 Cadence Design Systems, Inc.
6*4882a593Smuzhiyun *
7*4882a593Smuzhiyun */
8*4882a593Smuzhiyun
9*4882a593Smuzhiyun #include <dt-bindings/phy/phy.h>
10*4882a593Smuzhiyun #include <linux/clk.h>
11*4882a593Smuzhiyun #include <linux/delay.h>
12*4882a593Smuzhiyun #include <linux/err.h>
13*4882a593Smuzhiyun #include <linux/io.h>
14*4882a593Smuzhiyun #include <linux/iopoll.h>
15*4882a593Smuzhiyun #include <linux/kernel.h>
16*4882a593Smuzhiyun #include <linux/module.h>
17*4882a593Smuzhiyun #include <linux/of.h>
18*4882a593Smuzhiyun #include <linux/of_address.h>
19*4882a593Smuzhiyun #include <linux/of_device.h>
20*4882a593Smuzhiyun #include <linux/phy/phy.h>
21*4882a593Smuzhiyun #include <linux/platform_device.h>
22*4882a593Smuzhiyun #include <linux/reset.h>
23*4882a593Smuzhiyun #include <linux/regmap.h>
24*4882a593Smuzhiyun
25*4882a593Smuzhiyun #define REF_CLK_19_2MHz 19200000
26*4882a593Smuzhiyun #define REF_CLK_25MHz 25000000
27*4882a593Smuzhiyun
28*4882a593Smuzhiyun #define MAX_NUM_LANES 4
29*4882a593Smuzhiyun #define DEFAULT_MAX_BIT_RATE 8100 /* in Mbps */
30*4882a593Smuzhiyun
31*4882a593Smuzhiyun #define NUM_SSC_MODE 3
32*4882a593Smuzhiyun #define NUM_PHY_TYPE 6
33*4882a593Smuzhiyun
34*4882a593Smuzhiyun #define POLL_TIMEOUT_US 5000
35*4882a593Smuzhiyun #define PLL_LOCK_TIMEOUT 100000
36*4882a593Smuzhiyun
37*4882a593Smuzhiyun #define TORRENT_COMMON_CDB_OFFSET 0x0
38*4882a593Smuzhiyun
39*4882a593Smuzhiyun #define TORRENT_TX_LANE_CDB_OFFSET(ln, block_offset, reg_offset) \
40*4882a593Smuzhiyun ((0x4000 << (block_offset)) + \
41*4882a593Smuzhiyun (((ln) << 9) << (reg_offset)))
42*4882a593Smuzhiyun
43*4882a593Smuzhiyun #define TORRENT_RX_LANE_CDB_OFFSET(ln, block_offset, reg_offset) \
44*4882a593Smuzhiyun ((0x8000 << (block_offset)) + \
45*4882a593Smuzhiyun (((ln) << 9) << (reg_offset)))
46*4882a593Smuzhiyun
47*4882a593Smuzhiyun #define TORRENT_PHY_PCS_COMMON_OFFSET(block_offset) \
48*4882a593Smuzhiyun (0xC000 << (block_offset))
49*4882a593Smuzhiyun
50*4882a593Smuzhiyun #define TORRENT_PHY_PMA_COMMON_OFFSET(block_offset) \
51*4882a593Smuzhiyun (0xE000 << (block_offset))
52*4882a593Smuzhiyun
53*4882a593Smuzhiyun #define TORRENT_DPTX_PHY_OFFSET 0x0
54*4882a593Smuzhiyun
55*4882a593Smuzhiyun /*
56*4882a593Smuzhiyun * register offsets from DPTX PHY register block base (i.e MHDP
57*4882a593Smuzhiyun * register base + 0x30a00)
58*4882a593Smuzhiyun */
59*4882a593Smuzhiyun #define PHY_AUX_CTRL 0x04
60*4882a593Smuzhiyun #define PHY_RESET 0x20
61*4882a593Smuzhiyun #define PMA_TX_ELEC_IDLE_MASK 0xF0U
62*4882a593Smuzhiyun #define PMA_TX_ELEC_IDLE_SHIFT 4
63*4882a593Smuzhiyun #define PHY_L00_RESET_N_MASK 0x01U
64*4882a593Smuzhiyun #define PHY_PMA_XCVR_PLLCLK_EN 0x24
65*4882a593Smuzhiyun #define PHY_PMA_XCVR_PLLCLK_EN_ACK 0x28
66*4882a593Smuzhiyun #define PHY_PMA_XCVR_POWER_STATE_REQ 0x2c
67*4882a593Smuzhiyun #define PHY_POWER_STATE_LN_0 0x0000
68*4882a593Smuzhiyun #define PHY_POWER_STATE_LN_1 0x0008
69*4882a593Smuzhiyun #define PHY_POWER_STATE_LN_2 0x0010
70*4882a593Smuzhiyun #define PHY_POWER_STATE_LN_3 0x0018
71*4882a593Smuzhiyun #define PMA_XCVR_POWER_STATE_REQ_LN_MASK 0x3FU
72*4882a593Smuzhiyun #define PHY_PMA_XCVR_POWER_STATE_ACK 0x30
73*4882a593Smuzhiyun #define PHY_PMA_CMN_READY 0x34
74*4882a593Smuzhiyun
75*4882a593Smuzhiyun /*
76*4882a593Smuzhiyun * register offsets from SD0801 PHY register block base (i.e MHDP
77*4882a593Smuzhiyun * register base + 0x500000)
78*4882a593Smuzhiyun */
79*4882a593Smuzhiyun #define CMN_SSM_BANDGAP_TMR 0x0021U
80*4882a593Smuzhiyun #define CMN_SSM_BIAS_TMR 0x0022U
81*4882a593Smuzhiyun #define CMN_PLLSM0_PLLPRE_TMR 0x002AU
82*4882a593Smuzhiyun #define CMN_PLLSM0_PLLLOCK_TMR 0x002CU
83*4882a593Smuzhiyun #define CMN_PLLSM1_PLLPRE_TMR 0x0032U
84*4882a593Smuzhiyun #define CMN_PLLSM1_PLLLOCK_TMR 0x0034U
85*4882a593Smuzhiyun #define CMN_CDIAG_CDB_PWRI_OVRD 0x0041U
86*4882a593Smuzhiyun #define CMN_CDIAG_XCVRC_PWRI_OVRD 0x0047U
87*4882a593Smuzhiyun #define CMN_BGCAL_INIT_TMR 0x0064U
88*4882a593Smuzhiyun #define CMN_BGCAL_ITER_TMR 0x0065U
89*4882a593Smuzhiyun #define CMN_IBCAL_INIT_TMR 0x0074U
90*4882a593Smuzhiyun #define CMN_PLL0_VCOCAL_TCTRL 0x0082U
91*4882a593Smuzhiyun #define CMN_PLL0_VCOCAL_INIT_TMR 0x0084U
92*4882a593Smuzhiyun #define CMN_PLL0_VCOCAL_ITER_TMR 0x0085U
93*4882a593Smuzhiyun #define CMN_PLL0_VCOCAL_REFTIM_START 0x0086U
94*4882a593Smuzhiyun #define CMN_PLL0_VCOCAL_PLLCNT_START 0x0088U
95*4882a593Smuzhiyun #define CMN_PLL0_INTDIV_M0 0x0090U
96*4882a593Smuzhiyun #define CMN_PLL0_FRACDIVL_M0 0x0091U
97*4882a593Smuzhiyun #define CMN_PLL0_FRACDIVH_M0 0x0092U
98*4882a593Smuzhiyun #define CMN_PLL0_HIGH_THR_M0 0x0093U
99*4882a593Smuzhiyun #define CMN_PLL0_DSM_DIAG_M0 0x0094U
100*4882a593Smuzhiyun #define CMN_PLL0_SS_CTRL1_M0 0x0098U
101*4882a593Smuzhiyun #define CMN_PLL0_SS_CTRL2_M0 0x0099U
102*4882a593Smuzhiyun #define CMN_PLL0_SS_CTRL3_M0 0x009AU
103*4882a593Smuzhiyun #define CMN_PLL0_SS_CTRL4_M0 0x009BU
104*4882a593Smuzhiyun #define CMN_PLL0_LOCK_REFCNT_START 0x009CU
105*4882a593Smuzhiyun #define CMN_PLL0_LOCK_PLLCNT_START 0x009EU
106*4882a593Smuzhiyun #define CMN_PLL0_LOCK_PLLCNT_THR 0x009FU
107*4882a593Smuzhiyun #define CMN_PLL0_INTDIV_M1 0x00A0U
108*4882a593Smuzhiyun #define CMN_PLL0_FRACDIVH_M1 0x00A2U
109*4882a593Smuzhiyun #define CMN_PLL0_HIGH_THR_M1 0x00A3U
110*4882a593Smuzhiyun #define CMN_PLL0_DSM_DIAG_M1 0x00A4U
111*4882a593Smuzhiyun #define CMN_PLL0_SS_CTRL1_M1 0x00A8U
112*4882a593Smuzhiyun #define CMN_PLL0_SS_CTRL2_M1 0x00A9U
113*4882a593Smuzhiyun #define CMN_PLL0_SS_CTRL3_M1 0x00AAU
114*4882a593Smuzhiyun #define CMN_PLL0_SS_CTRL4_M1 0x00ABU
115*4882a593Smuzhiyun #define CMN_PLL1_VCOCAL_TCTRL 0x00C2U
116*4882a593Smuzhiyun #define CMN_PLL1_VCOCAL_INIT_TMR 0x00C4U
117*4882a593Smuzhiyun #define CMN_PLL1_VCOCAL_ITER_TMR 0x00C5U
118*4882a593Smuzhiyun #define CMN_PLL1_VCOCAL_REFTIM_START 0x00C6U
119*4882a593Smuzhiyun #define CMN_PLL1_VCOCAL_PLLCNT_START 0x00C8U
120*4882a593Smuzhiyun #define CMN_PLL1_INTDIV_M0 0x00D0U
121*4882a593Smuzhiyun #define CMN_PLL1_FRACDIVL_M0 0x00D1U
122*4882a593Smuzhiyun #define CMN_PLL1_FRACDIVH_M0 0x00D2U
123*4882a593Smuzhiyun #define CMN_PLL1_HIGH_THR_M0 0x00D3U
124*4882a593Smuzhiyun #define CMN_PLL1_DSM_DIAG_M0 0x00D4U
125*4882a593Smuzhiyun #define CMN_PLL1_SS_CTRL1_M0 0x00D8U
126*4882a593Smuzhiyun #define CMN_PLL1_SS_CTRL2_M0 0x00D9U
127*4882a593Smuzhiyun #define CMN_PLL1_SS_CTRL3_M0 0x00DAU
128*4882a593Smuzhiyun #define CMN_PLL1_SS_CTRL4_M0 0x00DBU
129*4882a593Smuzhiyun #define CMN_PLL1_LOCK_REFCNT_START 0x00DCU
130*4882a593Smuzhiyun #define CMN_PLL1_LOCK_PLLCNT_START 0x00DEU
131*4882a593Smuzhiyun #define CMN_PLL1_LOCK_PLLCNT_THR 0x00DFU
132*4882a593Smuzhiyun #define CMN_TXPUCAL_TUNE 0x0103U
133*4882a593Smuzhiyun #define CMN_TXPUCAL_INIT_TMR 0x0104U
134*4882a593Smuzhiyun #define CMN_TXPUCAL_ITER_TMR 0x0105U
135*4882a593Smuzhiyun #define CMN_TXPDCAL_TUNE 0x010BU
136*4882a593Smuzhiyun #define CMN_TXPDCAL_INIT_TMR 0x010CU
137*4882a593Smuzhiyun #define CMN_TXPDCAL_ITER_TMR 0x010DU
138*4882a593Smuzhiyun #define CMN_RXCAL_INIT_TMR 0x0114U
139*4882a593Smuzhiyun #define CMN_RXCAL_ITER_TMR 0x0115U
140*4882a593Smuzhiyun #define CMN_SD_CAL_INIT_TMR 0x0124U
141*4882a593Smuzhiyun #define CMN_SD_CAL_ITER_TMR 0x0125U
142*4882a593Smuzhiyun #define CMN_SD_CAL_REFTIM_START 0x0126U
143*4882a593Smuzhiyun #define CMN_SD_CAL_PLLCNT_START 0x0128U
144*4882a593Smuzhiyun #define CMN_PDIAG_PLL0_CTRL_M0 0x01A0U
145*4882a593Smuzhiyun #define CMN_PDIAG_PLL0_CLK_SEL_M0 0x01A1U
146*4882a593Smuzhiyun #define CMN_PDIAG_PLL0_CP_PADJ_M0 0x01A4U
147*4882a593Smuzhiyun #define CMN_PDIAG_PLL0_CP_IADJ_M0 0x01A5U
148*4882a593Smuzhiyun #define CMN_PDIAG_PLL0_FILT_PADJ_M0 0x01A6U
149*4882a593Smuzhiyun #define CMN_PDIAG_PLL0_CTRL_M1 0x01B0U
150*4882a593Smuzhiyun #define CMN_PDIAG_PLL0_CLK_SEL_M1 0x01B1U
151*4882a593Smuzhiyun #define CMN_PDIAG_PLL0_CP_PADJ_M1 0x01B4U
152*4882a593Smuzhiyun #define CMN_PDIAG_PLL0_CP_IADJ_M1 0x01B5U
153*4882a593Smuzhiyun #define CMN_PDIAG_PLL0_FILT_PADJ_M1 0x01B6U
154*4882a593Smuzhiyun #define CMN_PDIAG_PLL1_CTRL_M0 0x01C0U
155*4882a593Smuzhiyun #define CMN_PDIAG_PLL1_CLK_SEL_M0 0x01C1U
156*4882a593Smuzhiyun #define CMN_PDIAG_PLL1_CP_PADJ_M0 0x01C4U
157*4882a593Smuzhiyun #define CMN_PDIAG_PLL1_CP_IADJ_M0 0x01C5U
158*4882a593Smuzhiyun #define CMN_PDIAG_PLL1_FILT_PADJ_M0 0x01C6U
159*4882a593Smuzhiyun #define CMN_DIAG_BIAS_OVRD1 0x01E1U
160*4882a593Smuzhiyun
161*4882a593Smuzhiyun /* PMA TX Lane registers */
162*4882a593Smuzhiyun #define TX_TXCC_CTRL 0x0040U
163*4882a593Smuzhiyun #define TX_TXCC_CPOST_MULT_00 0x004CU
164*4882a593Smuzhiyun #define TX_TXCC_CPOST_MULT_01 0x004DU
165*4882a593Smuzhiyun #define TX_TXCC_MGNFS_MULT_000 0x0050U
166*4882a593Smuzhiyun #define DRV_DIAG_TX_DRV 0x00C6U
167*4882a593Smuzhiyun #define XCVR_DIAG_PLLDRC_CTRL 0x00E5U
168*4882a593Smuzhiyun #define XCVR_DIAG_HSCLK_SEL 0x00E6U
169*4882a593Smuzhiyun #define XCVR_DIAG_HSCLK_DIV 0x00E7U
170*4882a593Smuzhiyun #define XCVR_DIAG_BIDI_CTRL 0x00EAU
171*4882a593Smuzhiyun #define XCVR_DIAG_PSC_OVRD 0x00EBU
172*4882a593Smuzhiyun #define TX_PSC_A0 0x0100U
173*4882a593Smuzhiyun #define TX_PSC_A1 0x0101U
174*4882a593Smuzhiyun #define TX_PSC_A2 0x0102U
175*4882a593Smuzhiyun #define TX_PSC_A3 0x0103U
176*4882a593Smuzhiyun #define TX_RCVDET_ST_TMR 0x0123U
177*4882a593Smuzhiyun #define TX_DIAG_ACYA 0x01E7U
178*4882a593Smuzhiyun #define TX_DIAG_ACYA_HBDC_MASK 0x0001U
179*4882a593Smuzhiyun
180*4882a593Smuzhiyun /* PMA RX Lane registers */
181*4882a593Smuzhiyun #define RX_PSC_A0 0x0000U
182*4882a593Smuzhiyun #define RX_PSC_A1 0x0001U
183*4882a593Smuzhiyun #define RX_PSC_A2 0x0002U
184*4882a593Smuzhiyun #define RX_PSC_A3 0x0003U
185*4882a593Smuzhiyun #define RX_PSC_CAL 0x0006U
186*4882a593Smuzhiyun #define RX_CDRLF_CNFG 0x0080U
187*4882a593Smuzhiyun #define RX_CDRLF_CNFG3 0x0082U
188*4882a593Smuzhiyun #define RX_SIGDET_HL_FILT_TMR 0x0090U
189*4882a593Smuzhiyun #define RX_REE_GCSM1_CTRL 0x0108U
190*4882a593Smuzhiyun #define RX_REE_GCSM1_EQENM_PH1 0x0109U
191*4882a593Smuzhiyun #define RX_REE_GCSM1_EQENM_PH2 0x010AU
192*4882a593Smuzhiyun #define RX_REE_GCSM2_CTRL 0x0110U
193*4882a593Smuzhiyun #define RX_REE_PERGCSM_CTRL 0x0118U
194*4882a593Smuzhiyun #define RX_REE_ATTEN_THR 0x0149U
195*4882a593Smuzhiyun #define RX_REE_TAP1_CLIP 0x0171U
196*4882a593Smuzhiyun #define RX_REE_TAP2TON_CLIP 0x0172U
197*4882a593Smuzhiyun #define RX_REE_SMGM_CTRL1 0x0177U
198*4882a593Smuzhiyun #define RX_REE_SMGM_CTRL2 0x0178U
199*4882a593Smuzhiyun #define RX_DIAG_DFE_CTRL 0x01E0U
200*4882a593Smuzhiyun #define RX_DIAG_DFE_AMP_TUNE_2 0x01E2U
201*4882a593Smuzhiyun #define RX_DIAG_DFE_AMP_TUNE_3 0x01E3U
202*4882a593Smuzhiyun #define RX_DIAG_NQST_CTRL 0x01E5U
203*4882a593Smuzhiyun #define RX_DIAG_SIGDET_TUNE 0x01E8U
204*4882a593Smuzhiyun #define RX_DIAG_PI_RATE 0x01F4U
205*4882a593Smuzhiyun #define RX_DIAG_PI_CAP 0x01F5U
206*4882a593Smuzhiyun #define RX_DIAG_ACYA 0x01FFU
207*4882a593Smuzhiyun
208*4882a593Smuzhiyun /* PHY PCS common registers */
209*4882a593Smuzhiyun #define PHY_PLL_CFG 0x000EU
210*4882a593Smuzhiyun #define PHY_PIPE_USB3_GEN2_PRE_CFG0 0x0020U
211*4882a593Smuzhiyun #define PHY_PIPE_USB3_GEN2_POST_CFG0 0x0022U
212*4882a593Smuzhiyun #define PHY_PIPE_USB3_GEN2_POST_CFG1 0x0023U
213*4882a593Smuzhiyun
214*4882a593Smuzhiyun /* PHY PMA common registers */
215*4882a593Smuzhiyun #define PHY_PMA_CMN_CTRL1 0x0000U
216*4882a593Smuzhiyun #define PHY_PMA_CMN_CTRL2 0x0001U
217*4882a593Smuzhiyun #define PHY_PMA_PLL_RAW_CTRL 0x0003U
218*4882a593Smuzhiyun
219*4882a593Smuzhiyun static const struct reg_field phy_pll_cfg =
220*4882a593Smuzhiyun REG_FIELD(PHY_PLL_CFG, 0, 1);
221*4882a593Smuzhiyun
222*4882a593Smuzhiyun static const struct reg_field phy_pma_cmn_ctrl_1 =
223*4882a593Smuzhiyun REG_FIELD(PHY_PMA_CMN_CTRL1, 0, 0);
224*4882a593Smuzhiyun
225*4882a593Smuzhiyun static const struct reg_field phy_pma_cmn_ctrl_2 =
226*4882a593Smuzhiyun REG_FIELD(PHY_PMA_CMN_CTRL2, 0, 7);
227*4882a593Smuzhiyun
228*4882a593Smuzhiyun static const struct reg_field phy_pma_pll_raw_ctrl =
229*4882a593Smuzhiyun REG_FIELD(PHY_PMA_PLL_RAW_CTRL, 0, 1);
230*4882a593Smuzhiyun
231*4882a593Smuzhiyun static const struct reg_field phy_reset_ctrl =
232*4882a593Smuzhiyun REG_FIELD(PHY_RESET, 8, 8);
233*4882a593Smuzhiyun
234*4882a593Smuzhiyun enum cdns_torrent_phy_type {
235*4882a593Smuzhiyun TYPE_NONE,
236*4882a593Smuzhiyun TYPE_DP,
237*4882a593Smuzhiyun TYPE_PCIE,
238*4882a593Smuzhiyun TYPE_SGMII,
239*4882a593Smuzhiyun TYPE_QSGMII,
240*4882a593Smuzhiyun TYPE_USB,
241*4882a593Smuzhiyun };
242*4882a593Smuzhiyun
243*4882a593Smuzhiyun enum cdns_torrent_ssc_mode {
244*4882a593Smuzhiyun NO_SSC,
245*4882a593Smuzhiyun EXTERNAL_SSC,
246*4882a593Smuzhiyun INTERNAL_SSC
247*4882a593Smuzhiyun };
248*4882a593Smuzhiyun
249*4882a593Smuzhiyun struct cdns_torrent_inst {
250*4882a593Smuzhiyun struct phy *phy;
251*4882a593Smuzhiyun u32 mlane;
252*4882a593Smuzhiyun enum cdns_torrent_phy_type phy_type;
253*4882a593Smuzhiyun u32 num_lanes;
254*4882a593Smuzhiyun struct reset_control *lnk_rst;
255*4882a593Smuzhiyun enum cdns_torrent_ssc_mode ssc_mode;
256*4882a593Smuzhiyun };
257*4882a593Smuzhiyun
258*4882a593Smuzhiyun struct cdns_torrent_phy {
259*4882a593Smuzhiyun void __iomem *base; /* DPTX registers base */
260*4882a593Smuzhiyun void __iomem *sd_base; /* SD0801 registers base */
261*4882a593Smuzhiyun u32 max_bit_rate; /* Maximum link bit rate to use (in Mbps) */
262*4882a593Smuzhiyun struct reset_control *phy_rst;
263*4882a593Smuzhiyun struct reset_control *apb_rst;
264*4882a593Smuzhiyun struct device *dev;
265*4882a593Smuzhiyun struct clk *clk;
266*4882a593Smuzhiyun unsigned long ref_clk_rate;
267*4882a593Smuzhiyun struct cdns_torrent_inst phys[MAX_NUM_LANES];
268*4882a593Smuzhiyun int nsubnodes;
269*4882a593Smuzhiyun const struct cdns_torrent_data *init_data;
270*4882a593Smuzhiyun struct regmap *regmap;
271*4882a593Smuzhiyun struct regmap *regmap_common_cdb;
272*4882a593Smuzhiyun struct regmap *regmap_phy_pcs_common_cdb;
273*4882a593Smuzhiyun struct regmap *regmap_phy_pma_common_cdb;
274*4882a593Smuzhiyun struct regmap *regmap_tx_lane_cdb[MAX_NUM_LANES];
275*4882a593Smuzhiyun struct regmap *regmap_rx_lane_cdb[MAX_NUM_LANES];
276*4882a593Smuzhiyun struct regmap *regmap_dptx_phy_reg;
277*4882a593Smuzhiyun struct regmap_field *phy_pll_cfg;
278*4882a593Smuzhiyun struct regmap_field *phy_pma_cmn_ctrl_1;
279*4882a593Smuzhiyun struct regmap_field *phy_pma_cmn_ctrl_2;
280*4882a593Smuzhiyun struct regmap_field *phy_pma_pll_raw_ctrl;
281*4882a593Smuzhiyun struct regmap_field *phy_reset_ctrl;
282*4882a593Smuzhiyun };
283*4882a593Smuzhiyun
284*4882a593Smuzhiyun enum phy_powerstate {
285*4882a593Smuzhiyun POWERSTATE_A0 = 0,
286*4882a593Smuzhiyun /* Powerstate A1 is unused */
287*4882a593Smuzhiyun POWERSTATE_A2 = 2,
288*4882a593Smuzhiyun POWERSTATE_A3 = 3,
289*4882a593Smuzhiyun };
290*4882a593Smuzhiyun
291*4882a593Smuzhiyun static int cdns_torrent_phy_init(struct phy *phy);
292*4882a593Smuzhiyun static int cdns_torrent_dp_init(struct phy *phy);
293*4882a593Smuzhiyun static int cdns_torrent_dp_run(struct cdns_torrent_phy *cdns_phy,
294*4882a593Smuzhiyun u32 num_lanes);
295*4882a593Smuzhiyun static
296*4882a593Smuzhiyun int cdns_torrent_dp_wait_pma_cmn_ready(struct cdns_torrent_phy *cdns_phy);
297*4882a593Smuzhiyun static void cdns_torrent_dp_pma_cfg(struct cdns_torrent_phy *cdns_phy,
298*4882a593Smuzhiyun struct cdns_torrent_inst *inst);
299*4882a593Smuzhiyun static
300*4882a593Smuzhiyun void cdns_torrent_dp_pma_cmn_cfg_19_2mhz(struct cdns_torrent_phy *cdns_phy);
301*4882a593Smuzhiyun static
302*4882a593Smuzhiyun void cdns_torrent_dp_pma_cmn_vco_cfg_19_2mhz(struct cdns_torrent_phy *cdns_phy,
303*4882a593Smuzhiyun u32 rate, bool ssc);
304*4882a593Smuzhiyun static
305*4882a593Smuzhiyun void cdns_torrent_dp_pma_cmn_cfg_25mhz(struct cdns_torrent_phy *cdns_phy);
306*4882a593Smuzhiyun static
307*4882a593Smuzhiyun void cdns_torrent_dp_pma_cmn_vco_cfg_25mhz(struct cdns_torrent_phy *cdns_phy,
308*4882a593Smuzhiyun u32 rate, bool ssc);
309*4882a593Smuzhiyun static void cdns_torrent_dp_pma_lane_cfg(struct cdns_torrent_phy *cdns_phy,
310*4882a593Smuzhiyun unsigned int lane);
311*4882a593Smuzhiyun static void cdns_torrent_dp_pma_cmn_rate(struct cdns_torrent_phy *cdns_phy,
312*4882a593Smuzhiyun u32 rate, u32 num_lanes);
313*4882a593Smuzhiyun static int cdns_torrent_dp_configure(struct phy *phy,
314*4882a593Smuzhiyun union phy_configure_opts *opts);
315*4882a593Smuzhiyun static int cdns_torrent_dp_set_power_state(struct cdns_torrent_phy *cdns_phy,
316*4882a593Smuzhiyun u32 num_lanes,
317*4882a593Smuzhiyun enum phy_powerstate powerstate);
318*4882a593Smuzhiyun static int cdns_torrent_phy_on(struct phy *phy);
319*4882a593Smuzhiyun static int cdns_torrent_phy_off(struct phy *phy);
320*4882a593Smuzhiyun
321*4882a593Smuzhiyun static const struct phy_ops cdns_torrent_phy_ops = {
322*4882a593Smuzhiyun .init = cdns_torrent_phy_init,
323*4882a593Smuzhiyun .configure = cdns_torrent_dp_configure,
324*4882a593Smuzhiyun .power_on = cdns_torrent_phy_on,
325*4882a593Smuzhiyun .power_off = cdns_torrent_phy_off,
326*4882a593Smuzhiyun .owner = THIS_MODULE,
327*4882a593Smuzhiyun };
328*4882a593Smuzhiyun
329*4882a593Smuzhiyun struct cdns_reg_pairs {
330*4882a593Smuzhiyun u32 val;
331*4882a593Smuzhiyun u32 off;
332*4882a593Smuzhiyun };
333*4882a593Smuzhiyun
334*4882a593Smuzhiyun struct cdns_torrent_vals {
335*4882a593Smuzhiyun struct cdns_reg_pairs *reg_pairs;
336*4882a593Smuzhiyun u32 num_regs;
337*4882a593Smuzhiyun };
338*4882a593Smuzhiyun
339*4882a593Smuzhiyun struct cdns_torrent_data {
340*4882a593Smuzhiyun u8 block_offset_shift;
341*4882a593Smuzhiyun u8 reg_offset_shift;
342*4882a593Smuzhiyun struct cdns_torrent_vals *link_cmn_vals[NUM_PHY_TYPE][NUM_PHY_TYPE]
343*4882a593Smuzhiyun [NUM_SSC_MODE];
344*4882a593Smuzhiyun struct cdns_torrent_vals *xcvr_diag_vals[NUM_PHY_TYPE][NUM_PHY_TYPE]
345*4882a593Smuzhiyun [NUM_SSC_MODE];
346*4882a593Smuzhiyun struct cdns_torrent_vals *pcs_cmn_vals[NUM_PHY_TYPE][NUM_PHY_TYPE]
347*4882a593Smuzhiyun [NUM_SSC_MODE];
348*4882a593Smuzhiyun struct cdns_torrent_vals *cmn_vals[NUM_PHY_TYPE][NUM_PHY_TYPE]
349*4882a593Smuzhiyun [NUM_SSC_MODE];
350*4882a593Smuzhiyun struct cdns_torrent_vals *tx_ln_vals[NUM_PHY_TYPE][NUM_PHY_TYPE]
351*4882a593Smuzhiyun [NUM_SSC_MODE];
352*4882a593Smuzhiyun struct cdns_torrent_vals *rx_ln_vals[NUM_PHY_TYPE][NUM_PHY_TYPE]
353*4882a593Smuzhiyun [NUM_SSC_MODE];
354*4882a593Smuzhiyun };
355*4882a593Smuzhiyun
356*4882a593Smuzhiyun struct cdns_regmap_cdb_context {
357*4882a593Smuzhiyun struct device *dev;
358*4882a593Smuzhiyun void __iomem *base;
359*4882a593Smuzhiyun u8 reg_offset_shift;
360*4882a593Smuzhiyun };
361*4882a593Smuzhiyun
cdns_regmap_write(void * context,unsigned int reg,unsigned int val)362*4882a593Smuzhiyun static int cdns_regmap_write(void *context, unsigned int reg, unsigned int val)
363*4882a593Smuzhiyun {
364*4882a593Smuzhiyun struct cdns_regmap_cdb_context *ctx = context;
365*4882a593Smuzhiyun u32 offset = reg << ctx->reg_offset_shift;
366*4882a593Smuzhiyun
367*4882a593Smuzhiyun writew(val, ctx->base + offset);
368*4882a593Smuzhiyun
369*4882a593Smuzhiyun return 0;
370*4882a593Smuzhiyun }
371*4882a593Smuzhiyun
cdns_regmap_read(void * context,unsigned int reg,unsigned int * val)372*4882a593Smuzhiyun static int cdns_regmap_read(void *context, unsigned int reg, unsigned int *val)
373*4882a593Smuzhiyun {
374*4882a593Smuzhiyun struct cdns_regmap_cdb_context *ctx = context;
375*4882a593Smuzhiyun u32 offset = reg << ctx->reg_offset_shift;
376*4882a593Smuzhiyun
377*4882a593Smuzhiyun *val = readw(ctx->base + offset);
378*4882a593Smuzhiyun return 0;
379*4882a593Smuzhiyun }
380*4882a593Smuzhiyun
cdns_regmap_dptx_write(void * context,unsigned int reg,unsigned int val)381*4882a593Smuzhiyun static int cdns_regmap_dptx_write(void *context, unsigned int reg,
382*4882a593Smuzhiyun unsigned int val)
383*4882a593Smuzhiyun {
384*4882a593Smuzhiyun struct cdns_regmap_cdb_context *ctx = context;
385*4882a593Smuzhiyun u32 offset = reg;
386*4882a593Smuzhiyun
387*4882a593Smuzhiyun writel(val, ctx->base + offset);
388*4882a593Smuzhiyun
389*4882a593Smuzhiyun return 0;
390*4882a593Smuzhiyun }
391*4882a593Smuzhiyun
cdns_regmap_dptx_read(void * context,unsigned int reg,unsigned int * val)392*4882a593Smuzhiyun static int cdns_regmap_dptx_read(void *context, unsigned int reg,
393*4882a593Smuzhiyun unsigned int *val)
394*4882a593Smuzhiyun {
395*4882a593Smuzhiyun struct cdns_regmap_cdb_context *ctx = context;
396*4882a593Smuzhiyun u32 offset = reg;
397*4882a593Smuzhiyun
398*4882a593Smuzhiyun *val = readl(ctx->base + offset);
399*4882a593Smuzhiyun return 0;
400*4882a593Smuzhiyun }
401*4882a593Smuzhiyun
402*4882a593Smuzhiyun #define TORRENT_TX_LANE_CDB_REGMAP_CONF(n) \
403*4882a593Smuzhiyun { \
404*4882a593Smuzhiyun .name = "torrent_tx_lane" n "_cdb", \
405*4882a593Smuzhiyun .reg_stride = 1, \
406*4882a593Smuzhiyun .fast_io = true, \
407*4882a593Smuzhiyun .reg_write = cdns_regmap_write, \
408*4882a593Smuzhiyun .reg_read = cdns_regmap_read, \
409*4882a593Smuzhiyun }
410*4882a593Smuzhiyun
411*4882a593Smuzhiyun #define TORRENT_RX_LANE_CDB_REGMAP_CONF(n) \
412*4882a593Smuzhiyun { \
413*4882a593Smuzhiyun .name = "torrent_rx_lane" n "_cdb", \
414*4882a593Smuzhiyun .reg_stride = 1, \
415*4882a593Smuzhiyun .fast_io = true, \
416*4882a593Smuzhiyun .reg_write = cdns_regmap_write, \
417*4882a593Smuzhiyun .reg_read = cdns_regmap_read, \
418*4882a593Smuzhiyun }
419*4882a593Smuzhiyun
420*4882a593Smuzhiyun static const struct regmap_config cdns_torrent_tx_lane_cdb_config[] = {
421*4882a593Smuzhiyun TORRENT_TX_LANE_CDB_REGMAP_CONF("0"),
422*4882a593Smuzhiyun TORRENT_TX_LANE_CDB_REGMAP_CONF("1"),
423*4882a593Smuzhiyun TORRENT_TX_LANE_CDB_REGMAP_CONF("2"),
424*4882a593Smuzhiyun TORRENT_TX_LANE_CDB_REGMAP_CONF("3"),
425*4882a593Smuzhiyun };
426*4882a593Smuzhiyun
427*4882a593Smuzhiyun static const struct regmap_config cdns_torrent_rx_lane_cdb_config[] = {
428*4882a593Smuzhiyun TORRENT_RX_LANE_CDB_REGMAP_CONF("0"),
429*4882a593Smuzhiyun TORRENT_RX_LANE_CDB_REGMAP_CONF("1"),
430*4882a593Smuzhiyun TORRENT_RX_LANE_CDB_REGMAP_CONF("2"),
431*4882a593Smuzhiyun TORRENT_RX_LANE_CDB_REGMAP_CONF("3"),
432*4882a593Smuzhiyun };
433*4882a593Smuzhiyun
434*4882a593Smuzhiyun static const struct regmap_config cdns_torrent_common_cdb_config = {
435*4882a593Smuzhiyun .name = "torrent_common_cdb",
436*4882a593Smuzhiyun .reg_stride = 1,
437*4882a593Smuzhiyun .fast_io = true,
438*4882a593Smuzhiyun .reg_write = cdns_regmap_write,
439*4882a593Smuzhiyun .reg_read = cdns_regmap_read,
440*4882a593Smuzhiyun };
441*4882a593Smuzhiyun
442*4882a593Smuzhiyun static const struct regmap_config cdns_torrent_phy_pcs_cmn_cdb_config = {
443*4882a593Smuzhiyun .name = "torrent_phy_pcs_cmn_cdb",
444*4882a593Smuzhiyun .reg_stride = 1,
445*4882a593Smuzhiyun .fast_io = true,
446*4882a593Smuzhiyun .reg_write = cdns_regmap_write,
447*4882a593Smuzhiyun .reg_read = cdns_regmap_read,
448*4882a593Smuzhiyun };
449*4882a593Smuzhiyun
450*4882a593Smuzhiyun static const struct regmap_config cdns_torrent_phy_pma_cmn_cdb_config = {
451*4882a593Smuzhiyun .name = "torrent_phy_pma_cmn_cdb",
452*4882a593Smuzhiyun .reg_stride = 1,
453*4882a593Smuzhiyun .fast_io = true,
454*4882a593Smuzhiyun .reg_write = cdns_regmap_write,
455*4882a593Smuzhiyun .reg_read = cdns_regmap_read,
456*4882a593Smuzhiyun };
457*4882a593Smuzhiyun
458*4882a593Smuzhiyun static const struct regmap_config cdns_torrent_dptx_phy_config = {
459*4882a593Smuzhiyun .name = "torrent_dptx_phy",
460*4882a593Smuzhiyun .reg_stride = 1,
461*4882a593Smuzhiyun .fast_io = true,
462*4882a593Smuzhiyun .reg_write = cdns_regmap_dptx_write,
463*4882a593Smuzhiyun .reg_read = cdns_regmap_dptx_read,
464*4882a593Smuzhiyun };
465*4882a593Smuzhiyun
466*4882a593Smuzhiyun /* PHY mmr access functions */
467*4882a593Smuzhiyun
cdns_torrent_phy_write(struct regmap * regmap,u32 offset,u32 val)468*4882a593Smuzhiyun static void cdns_torrent_phy_write(struct regmap *regmap, u32 offset, u32 val)
469*4882a593Smuzhiyun {
470*4882a593Smuzhiyun regmap_write(regmap, offset, val);
471*4882a593Smuzhiyun }
472*4882a593Smuzhiyun
cdns_torrent_phy_read(struct regmap * regmap,u32 offset)473*4882a593Smuzhiyun static u32 cdns_torrent_phy_read(struct regmap *regmap, u32 offset)
474*4882a593Smuzhiyun {
475*4882a593Smuzhiyun unsigned int val;
476*4882a593Smuzhiyun
477*4882a593Smuzhiyun regmap_read(regmap, offset, &val);
478*4882a593Smuzhiyun return val;
479*4882a593Smuzhiyun }
480*4882a593Smuzhiyun
481*4882a593Smuzhiyun /* DPTX mmr access functions */
482*4882a593Smuzhiyun
cdns_torrent_dp_write(struct regmap * regmap,u32 offset,u32 val)483*4882a593Smuzhiyun static void cdns_torrent_dp_write(struct regmap *regmap, u32 offset, u32 val)
484*4882a593Smuzhiyun {
485*4882a593Smuzhiyun regmap_write(regmap, offset, val);
486*4882a593Smuzhiyun }
487*4882a593Smuzhiyun
cdns_torrent_dp_read(struct regmap * regmap,u32 offset)488*4882a593Smuzhiyun static u32 cdns_torrent_dp_read(struct regmap *regmap, u32 offset)
489*4882a593Smuzhiyun {
490*4882a593Smuzhiyun u32 val;
491*4882a593Smuzhiyun
492*4882a593Smuzhiyun regmap_read(regmap, offset, &val);
493*4882a593Smuzhiyun return val;
494*4882a593Smuzhiyun }
495*4882a593Smuzhiyun
496*4882a593Smuzhiyun /*
497*4882a593Smuzhiyun * Structure used to store values of PHY registers for voltage-related
498*4882a593Smuzhiyun * coefficients, for particular voltage swing and pre-emphasis level. Values
499*4882a593Smuzhiyun * are shared across all physical lanes.
500*4882a593Smuzhiyun */
501*4882a593Smuzhiyun struct coefficients {
502*4882a593Smuzhiyun /* Value of DRV_DIAG_TX_DRV register to use */
503*4882a593Smuzhiyun u16 diag_tx_drv;
504*4882a593Smuzhiyun /* Value of TX_TXCC_MGNFS_MULT_000 register to use */
505*4882a593Smuzhiyun u16 mgnfs_mult;
506*4882a593Smuzhiyun /* Value of TX_TXCC_CPOST_MULT_00 register to use */
507*4882a593Smuzhiyun u16 cpost_mult;
508*4882a593Smuzhiyun };
509*4882a593Smuzhiyun
510*4882a593Smuzhiyun /*
511*4882a593Smuzhiyun * Array consists of values of voltage-related registers for sd0801 PHY. A value
512*4882a593Smuzhiyun * of 0xFFFF is a placeholder for invalid combination, and will never be used.
513*4882a593Smuzhiyun */
514*4882a593Smuzhiyun static const struct coefficients vltg_coeff[4][4] = {
515*4882a593Smuzhiyun /* voltage swing 0, pre-emphasis 0->3 */
516*4882a593Smuzhiyun { {.diag_tx_drv = 0x0003, .mgnfs_mult = 0x002A,
517*4882a593Smuzhiyun .cpost_mult = 0x0000},
518*4882a593Smuzhiyun {.diag_tx_drv = 0x0003, .mgnfs_mult = 0x001F,
519*4882a593Smuzhiyun .cpost_mult = 0x0014},
520*4882a593Smuzhiyun {.diag_tx_drv = 0x0003, .mgnfs_mult = 0x0012,
521*4882a593Smuzhiyun .cpost_mult = 0x0020},
522*4882a593Smuzhiyun {.diag_tx_drv = 0x0003, .mgnfs_mult = 0x0000,
523*4882a593Smuzhiyun .cpost_mult = 0x002A}
524*4882a593Smuzhiyun },
525*4882a593Smuzhiyun
526*4882a593Smuzhiyun /* voltage swing 1, pre-emphasis 0->3 */
527*4882a593Smuzhiyun { {.diag_tx_drv = 0x0003, .mgnfs_mult = 0x001F,
528*4882a593Smuzhiyun .cpost_mult = 0x0000},
529*4882a593Smuzhiyun {.diag_tx_drv = 0x0003, .mgnfs_mult = 0x0013,
530*4882a593Smuzhiyun .cpost_mult = 0x0012},
531*4882a593Smuzhiyun {.diag_tx_drv = 0x0003, .mgnfs_mult = 0x0000,
532*4882a593Smuzhiyun .cpost_mult = 0x001F},
533*4882a593Smuzhiyun {.diag_tx_drv = 0xFFFF, .mgnfs_mult = 0xFFFF,
534*4882a593Smuzhiyun .cpost_mult = 0xFFFF}
535*4882a593Smuzhiyun },
536*4882a593Smuzhiyun
537*4882a593Smuzhiyun /* voltage swing 2, pre-emphasis 0->3 */
538*4882a593Smuzhiyun { {.diag_tx_drv = 0x0003, .mgnfs_mult = 0x0013,
539*4882a593Smuzhiyun .cpost_mult = 0x0000},
540*4882a593Smuzhiyun {.diag_tx_drv = 0x0003, .mgnfs_mult = 0x0000,
541*4882a593Smuzhiyun .cpost_mult = 0x0013},
542*4882a593Smuzhiyun {.diag_tx_drv = 0xFFFF, .mgnfs_mult = 0xFFFF,
543*4882a593Smuzhiyun .cpost_mult = 0xFFFF},
544*4882a593Smuzhiyun {.diag_tx_drv = 0xFFFF, .mgnfs_mult = 0xFFFF,
545*4882a593Smuzhiyun .cpost_mult = 0xFFFF}
546*4882a593Smuzhiyun },
547*4882a593Smuzhiyun
548*4882a593Smuzhiyun /* voltage swing 3, pre-emphasis 0->3 */
549*4882a593Smuzhiyun { {.diag_tx_drv = 0x0003, .mgnfs_mult = 0x0000,
550*4882a593Smuzhiyun .cpost_mult = 0x0000},
551*4882a593Smuzhiyun {.diag_tx_drv = 0xFFFF, .mgnfs_mult = 0xFFFF,
552*4882a593Smuzhiyun .cpost_mult = 0xFFFF},
553*4882a593Smuzhiyun {.diag_tx_drv = 0xFFFF, .mgnfs_mult = 0xFFFF,
554*4882a593Smuzhiyun .cpost_mult = 0xFFFF},
555*4882a593Smuzhiyun {.diag_tx_drv = 0xFFFF, .mgnfs_mult = 0xFFFF,
556*4882a593Smuzhiyun .cpost_mult = 0xFFFF}
557*4882a593Smuzhiyun }
558*4882a593Smuzhiyun };
559*4882a593Smuzhiyun
560*4882a593Smuzhiyun /*
561*4882a593Smuzhiyun * Enable or disable PLL for selected lanes.
562*4882a593Smuzhiyun */
cdns_torrent_dp_set_pll_en(struct cdns_torrent_phy * cdns_phy,struct phy_configure_opts_dp * dp,bool enable)563*4882a593Smuzhiyun static int cdns_torrent_dp_set_pll_en(struct cdns_torrent_phy *cdns_phy,
564*4882a593Smuzhiyun struct phy_configure_opts_dp *dp,
565*4882a593Smuzhiyun bool enable)
566*4882a593Smuzhiyun {
567*4882a593Smuzhiyun u32 rd_val;
568*4882a593Smuzhiyun u32 ret;
569*4882a593Smuzhiyun struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg;
570*4882a593Smuzhiyun
571*4882a593Smuzhiyun /*
572*4882a593Smuzhiyun * Used to determine, which bits to check for or enable in
573*4882a593Smuzhiyun * PHY_PMA_XCVR_PLLCLK_EN register.
574*4882a593Smuzhiyun */
575*4882a593Smuzhiyun u32 pll_bits;
576*4882a593Smuzhiyun /* Used to enable or disable lanes. */
577*4882a593Smuzhiyun u32 pll_val;
578*4882a593Smuzhiyun
579*4882a593Smuzhiyun /* Select values of registers and mask, depending on enabled lane
580*4882a593Smuzhiyun * count.
581*4882a593Smuzhiyun */
582*4882a593Smuzhiyun switch (dp->lanes) {
583*4882a593Smuzhiyun /* lane 0 */
584*4882a593Smuzhiyun case (1):
585*4882a593Smuzhiyun pll_bits = 0x00000001;
586*4882a593Smuzhiyun break;
587*4882a593Smuzhiyun /* lanes 0-1 */
588*4882a593Smuzhiyun case (2):
589*4882a593Smuzhiyun pll_bits = 0x00000003;
590*4882a593Smuzhiyun break;
591*4882a593Smuzhiyun /* lanes 0-3, all */
592*4882a593Smuzhiyun default:
593*4882a593Smuzhiyun pll_bits = 0x0000000F;
594*4882a593Smuzhiyun break;
595*4882a593Smuzhiyun }
596*4882a593Smuzhiyun
597*4882a593Smuzhiyun if (enable)
598*4882a593Smuzhiyun pll_val = pll_bits;
599*4882a593Smuzhiyun else
600*4882a593Smuzhiyun pll_val = 0x00000000;
601*4882a593Smuzhiyun
602*4882a593Smuzhiyun cdns_torrent_dp_write(regmap, PHY_PMA_XCVR_PLLCLK_EN, pll_val);
603*4882a593Smuzhiyun
604*4882a593Smuzhiyun /* Wait for acknowledgment from PHY. */
605*4882a593Smuzhiyun ret = regmap_read_poll_timeout(regmap,
606*4882a593Smuzhiyun PHY_PMA_XCVR_PLLCLK_EN_ACK,
607*4882a593Smuzhiyun rd_val,
608*4882a593Smuzhiyun (rd_val & pll_bits) == pll_val,
609*4882a593Smuzhiyun 0, POLL_TIMEOUT_US);
610*4882a593Smuzhiyun ndelay(100);
611*4882a593Smuzhiyun return ret;
612*4882a593Smuzhiyun }
613*4882a593Smuzhiyun
614*4882a593Smuzhiyun /*
615*4882a593Smuzhiyun * Perform register operations related to setting link rate, once powerstate is
616*4882a593Smuzhiyun * set and PLL disable request was processed.
617*4882a593Smuzhiyun */
cdns_torrent_dp_configure_rate(struct cdns_torrent_phy * cdns_phy,struct phy_configure_opts_dp * dp)618*4882a593Smuzhiyun static int cdns_torrent_dp_configure_rate(struct cdns_torrent_phy *cdns_phy,
619*4882a593Smuzhiyun struct phy_configure_opts_dp *dp)
620*4882a593Smuzhiyun {
621*4882a593Smuzhiyun u32 ret;
622*4882a593Smuzhiyun u32 read_val;
623*4882a593Smuzhiyun
624*4882a593Smuzhiyun /* Disable the cmn_pll0_en before re-programming the new data rate. */
625*4882a593Smuzhiyun regmap_field_write(cdns_phy->phy_pma_pll_raw_ctrl, 0x0);
626*4882a593Smuzhiyun
627*4882a593Smuzhiyun /*
628*4882a593Smuzhiyun * Wait for PLL ready de-assertion.
629*4882a593Smuzhiyun * For PLL0 - PHY_PMA_CMN_CTRL2[2] == 1
630*4882a593Smuzhiyun */
631*4882a593Smuzhiyun ret = regmap_field_read_poll_timeout(cdns_phy->phy_pma_cmn_ctrl_2,
632*4882a593Smuzhiyun read_val,
633*4882a593Smuzhiyun ((read_val >> 2) & 0x01) != 0,
634*4882a593Smuzhiyun 0, POLL_TIMEOUT_US);
635*4882a593Smuzhiyun if (ret)
636*4882a593Smuzhiyun return ret;
637*4882a593Smuzhiyun ndelay(200);
638*4882a593Smuzhiyun
639*4882a593Smuzhiyun /* DP Rate Change - VCO Output settings. */
640*4882a593Smuzhiyun if (cdns_phy->ref_clk_rate == REF_CLK_19_2MHz) {
641*4882a593Smuzhiyun /* PMA common configuration 19.2MHz */
642*4882a593Smuzhiyun cdns_torrent_dp_pma_cmn_vco_cfg_19_2mhz(cdns_phy, dp->link_rate,
643*4882a593Smuzhiyun dp->ssc);
644*4882a593Smuzhiyun cdns_torrent_dp_pma_cmn_cfg_19_2mhz(cdns_phy);
645*4882a593Smuzhiyun } else if (cdns_phy->ref_clk_rate == REF_CLK_25MHz) {
646*4882a593Smuzhiyun /* PMA common configuration 25MHz */
647*4882a593Smuzhiyun cdns_torrent_dp_pma_cmn_vco_cfg_25mhz(cdns_phy, dp->link_rate,
648*4882a593Smuzhiyun dp->ssc);
649*4882a593Smuzhiyun cdns_torrent_dp_pma_cmn_cfg_25mhz(cdns_phy);
650*4882a593Smuzhiyun }
651*4882a593Smuzhiyun cdns_torrent_dp_pma_cmn_rate(cdns_phy, dp->link_rate, dp->lanes);
652*4882a593Smuzhiyun
653*4882a593Smuzhiyun /* Enable the cmn_pll0_en. */
654*4882a593Smuzhiyun regmap_field_write(cdns_phy->phy_pma_pll_raw_ctrl, 0x3);
655*4882a593Smuzhiyun
656*4882a593Smuzhiyun /*
657*4882a593Smuzhiyun * Wait for PLL ready assertion.
658*4882a593Smuzhiyun * For PLL0 - PHY_PMA_CMN_CTRL2[0] == 1
659*4882a593Smuzhiyun */
660*4882a593Smuzhiyun ret = regmap_field_read_poll_timeout(cdns_phy->phy_pma_cmn_ctrl_2,
661*4882a593Smuzhiyun read_val,
662*4882a593Smuzhiyun (read_val & 0x01) != 0,
663*4882a593Smuzhiyun 0, POLL_TIMEOUT_US);
664*4882a593Smuzhiyun return ret;
665*4882a593Smuzhiyun }
666*4882a593Smuzhiyun
667*4882a593Smuzhiyun /*
668*4882a593Smuzhiyun * Verify, that parameters to configure PHY with are correct.
669*4882a593Smuzhiyun */
cdns_torrent_dp_verify_config(struct cdns_torrent_inst * inst,struct phy_configure_opts_dp * dp)670*4882a593Smuzhiyun static int cdns_torrent_dp_verify_config(struct cdns_torrent_inst *inst,
671*4882a593Smuzhiyun struct phy_configure_opts_dp *dp)
672*4882a593Smuzhiyun {
673*4882a593Smuzhiyun u8 i;
674*4882a593Smuzhiyun
675*4882a593Smuzhiyun /* If changing link rate was required, verify it's supported. */
676*4882a593Smuzhiyun if (dp->set_rate) {
677*4882a593Smuzhiyun switch (dp->link_rate) {
678*4882a593Smuzhiyun case 1620:
679*4882a593Smuzhiyun case 2160:
680*4882a593Smuzhiyun case 2430:
681*4882a593Smuzhiyun case 2700:
682*4882a593Smuzhiyun case 3240:
683*4882a593Smuzhiyun case 4320:
684*4882a593Smuzhiyun case 5400:
685*4882a593Smuzhiyun case 8100:
686*4882a593Smuzhiyun /* valid bit rate */
687*4882a593Smuzhiyun break;
688*4882a593Smuzhiyun default:
689*4882a593Smuzhiyun return -EINVAL;
690*4882a593Smuzhiyun }
691*4882a593Smuzhiyun }
692*4882a593Smuzhiyun
693*4882a593Smuzhiyun /* Verify lane count. */
694*4882a593Smuzhiyun switch (dp->lanes) {
695*4882a593Smuzhiyun case 1:
696*4882a593Smuzhiyun case 2:
697*4882a593Smuzhiyun case 4:
698*4882a593Smuzhiyun /* valid lane count. */
699*4882a593Smuzhiyun break;
700*4882a593Smuzhiyun default:
701*4882a593Smuzhiyun return -EINVAL;
702*4882a593Smuzhiyun }
703*4882a593Smuzhiyun
704*4882a593Smuzhiyun /* Check against actual number of PHY's lanes. */
705*4882a593Smuzhiyun if (dp->lanes > inst->num_lanes)
706*4882a593Smuzhiyun return -EINVAL;
707*4882a593Smuzhiyun
708*4882a593Smuzhiyun /*
709*4882a593Smuzhiyun * If changing voltages is required, check swing and pre-emphasis
710*4882a593Smuzhiyun * levels, per-lane.
711*4882a593Smuzhiyun */
712*4882a593Smuzhiyun if (dp->set_voltages) {
713*4882a593Smuzhiyun /* Lane count verified previously. */
714*4882a593Smuzhiyun for (i = 0; i < dp->lanes; i++) {
715*4882a593Smuzhiyun if (dp->voltage[i] > 3 || dp->pre[i] > 3)
716*4882a593Smuzhiyun return -EINVAL;
717*4882a593Smuzhiyun
718*4882a593Smuzhiyun /* Sum of voltage swing and pre-emphasis levels cannot
719*4882a593Smuzhiyun * exceed 3.
720*4882a593Smuzhiyun */
721*4882a593Smuzhiyun if (dp->voltage[i] + dp->pre[i] > 3)
722*4882a593Smuzhiyun return -EINVAL;
723*4882a593Smuzhiyun }
724*4882a593Smuzhiyun }
725*4882a593Smuzhiyun
726*4882a593Smuzhiyun return 0;
727*4882a593Smuzhiyun }
728*4882a593Smuzhiyun
729*4882a593Smuzhiyun /* Set power state A0 and PLL clock enable to 0 on enabled lanes. */
cdns_torrent_dp_set_a0_pll(struct cdns_torrent_phy * cdns_phy,u32 num_lanes)730*4882a593Smuzhiyun static void cdns_torrent_dp_set_a0_pll(struct cdns_torrent_phy *cdns_phy,
731*4882a593Smuzhiyun u32 num_lanes)
732*4882a593Smuzhiyun {
733*4882a593Smuzhiyun struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg;
734*4882a593Smuzhiyun u32 pwr_state = cdns_torrent_dp_read(regmap,
735*4882a593Smuzhiyun PHY_PMA_XCVR_POWER_STATE_REQ);
736*4882a593Smuzhiyun u32 pll_clk_en = cdns_torrent_dp_read(regmap,
737*4882a593Smuzhiyun PHY_PMA_XCVR_PLLCLK_EN);
738*4882a593Smuzhiyun
739*4882a593Smuzhiyun /* Lane 0 is always enabled. */
740*4882a593Smuzhiyun pwr_state &= ~(PMA_XCVR_POWER_STATE_REQ_LN_MASK <<
741*4882a593Smuzhiyun PHY_POWER_STATE_LN_0);
742*4882a593Smuzhiyun pll_clk_en &= ~0x01U;
743*4882a593Smuzhiyun
744*4882a593Smuzhiyun if (num_lanes > 1) {
745*4882a593Smuzhiyun /* lane 1 */
746*4882a593Smuzhiyun pwr_state &= ~(PMA_XCVR_POWER_STATE_REQ_LN_MASK <<
747*4882a593Smuzhiyun PHY_POWER_STATE_LN_1);
748*4882a593Smuzhiyun pll_clk_en &= ~(0x01U << 1);
749*4882a593Smuzhiyun }
750*4882a593Smuzhiyun
751*4882a593Smuzhiyun if (num_lanes > 2) {
752*4882a593Smuzhiyun /* lanes 2 and 3 */
753*4882a593Smuzhiyun pwr_state &= ~(PMA_XCVR_POWER_STATE_REQ_LN_MASK <<
754*4882a593Smuzhiyun PHY_POWER_STATE_LN_2);
755*4882a593Smuzhiyun pwr_state &= ~(PMA_XCVR_POWER_STATE_REQ_LN_MASK <<
756*4882a593Smuzhiyun PHY_POWER_STATE_LN_3);
757*4882a593Smuzhiyun pll_clk_en &= ~(0x01U << 2);
758*4882a593Smuzhiyun pll_clk_en &= ~(0x01U << 3);
759*4882a593Smuzhiyun }
760*4882a593Smuzhiyun
761*4882a593Smuzhiyun cdns_torrent_dp_write(regmap, PHY_PMA_XCVR_POWER_STATE_REQ, pwr_state);
762*4882a593Smuzhiyun cdns_torrent_dp_write(regmap, PHY_PMA_XCVR_PLLCLK_EN, pll_clk_en);
763*4882a593Smuzhiyun }
764*4882a593Smuzhiyun
765*4882a593Smuzhiyun /* Configure lane count as required. */
cdns_torrent_dp_set_lanes(struct cdns_torrent_phy * cdns_phy,struct phy_configure_opts_dp * dp)766*4882a593Smuzhiyun static int cdns_torrent_dp_set_lanes(struct cdns_torrent_phy *cdns_phy,
767*4882a593Smuzhiyun struct phy_configure_opts_dp *dp)
768*4882a593Smuzhiyun {
769*4882a593Smuzhiyun u32 value;
770*4882a593Smuzhiyun u32 ret;
771*4882a593Smuzhiyun struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg;
772*4882a593Smuzhiyun u8 lane_mask = (1 << dp->lanes) - 1;
773*4882a593Smuzhiyun
774*4882a593Smuzhiyun value = cdns_torrent_dp_read(regmap, PHY_RESET);
775*4882a593Smuzhiyun /* clear pma_tx_elec_idle_ln_* bits. */
776*4882a593Smuzhiyun value &= ~PMA_TX_ELEC_IDLE_MASK;
777*4882a593Smuzhiyun /* Assert pma_tx_elec_idle_ln_* for disabled lanes. */
778*4882a593Smuzhiyun value |= ((~lane_mask) << PMA_TX_ELEC_IDLE_SHIFT) &
779*4882a593Smuzhiyun PMA_TX_ELEC_IDLE_MASK;
780*4882a593Smuzhiyun cdns_torrent_dp_write(regmap, PHY_RESET, value);
781*4882a593Smuzhiyun
782*4882a593Smuzhiyun /* reset the link by asserting phy_l00_reset_n low */
783*4882a593Smuzhiyun cdns_torrent_dp_write(regmap, PHY_RESET,
784*4882a593Smuzhiyun value & (~PHY_L00_RESET_N_MASK));
785*4882a593Smuzhiyun
786*4882a593Smuzhiyun /*
787*4882a593Smuzhiyun * Assert lane reset on unused lanes and lane 0 so they remain in reset
788*4882a593Smuzhiyun * and powered down when re-enabling the link
789*4882a593Smuzhiyun */
790*4882a593Smuzhiyun value = (value & 0x0000FFF0) | (0x0000000E & lane_mask);
791*4882a593Smuzhiyun cdns_torrent_dp_write(regmap, PHY_RESET, value);
792*4882a593Smuzhiyun
793*4882a593Smuzhiyun cdns_torrent_dp_set_a0_pll(cdns_phy, dp->lanes);
794*4882a593Smuzhiyun
795*4882a593Smuzhiyun /* release phy_l0*_reset_n based on used laneCount */
796*4882a593Smuzhiyun value = (value & 0x0000FFF0) | (0x0000000F & lane_mask);
797*4882a593Smuzhiyun cdns_torrent_dp_write(regmap, PHY_RESET, value);
798*4882a593Smuzhiyun
799*4882a593Smuzhiyun /* Wait, until PHY gets ready after releasing PHY reset signal. */
800*4882a593Smuzhiyun ret = cdns_torrent_dp_wait_pma_cmn_ready(cdns_phy);
801*4882a593Smuzhiyun if (ret)
802*4882a593Smuzhiyun return ret;
803*4882a593Smuzhiyun
804*4882a593Smuzhiyun ndelay(100);
805*4882a593Smuzhiyun
806*4882a593Smuzhiyun /* release pma_xcvr_pllclk_en_ln_*, only for the master lane */
807*4882a593Smuzhiyun cdns_torrent_dp_write(regmap, PHY_PMA_XCVR_PLLCLK_EN, 0x0001);
808*4882a593Smuzhiyun
809*4882a593Smuzhiyun ret = cdns_torrent_dp_run(cdns_phy, dp->lanes);
810*4882a593Smuzhiyun
811*4882a593Smuzhiyun return ret;
812*4882a593Smuzhiyun }
813*4882a593Smuzhiyun
814*4882a593Smuzhiyun /* Configure link rate as required. */
cdns_torrent_dp_set_rate(struct cdns_torrent_phy * cdns_phy,struct phy_configure_opts_dp * dp)815*4882a593Smuzhiyun static int cdns_torrent_dp_set_rate(struct cdns_torrent_phy *cdns_phy,
816*4882a593Smuzhiyun struct phy_configure_opts_dp *dp)
817*4882a593Smuzhiyun {
818*4882a593Smuzhiyun u32 ret;
819*4882a593Smuzhiyun
820*4882a593Smuzhiyun ret = cdns_torrent_dp_set_power_state(cdns_phy, dp->lanes,
821*4882a593Smuzhiyun POWERSTATE_A3);
822*4882a593Smuzhiyun if (ret)
823*4882a593Smuzhiyun return ret;
824*4882a593Smuzhiyun ret = cdns_torrent_dp_set_pll_en(cdns_phy, dp, false);
825*4882a593Smuzhiyun if (ret)
826*4882a593Smuzhiyun return ret;
827*4882a593Smuzhiyun ndelay(200);
828*4882a593Smuzhiyun
829*4882a593Smuzhiyun ret = cdns_torrent_dp_configure_rate(cdns_phy, dp);
830*4882a593Smuzhiyun if (ret)
831*4882a593Smuzhiyun return ret;
832*4882a593Smuzhiyun ndelay(200);
833*4882a593Smuzhiyun
834*4882a593Smuzhiyun ret = cdns_torrent_dp_set_pll_en(cdns_phy, dp, true);
835*4882a593Smuzhiyun if (ret)
836*4882a593Smuzhiyun return ret;
837*4882a593Smuzhiyun ret = cdns_torrent_dp_set_power_state(cdns_phy, dp->lanes,
838*4882a593Smuzhiyun POWERSTATE_A2);
839*4882a593Smuzhiyun if (ret)
840*4882a593Smuzhiyun return ret;
841*4882a593Smuzhiyun ret = cdns_torrent_dp_set_power_state(cdns_phy, dp->lanes,
842*4882a593Smuzhiyun POWERSTATE_A0);
843*4882a593Smuzhiyun if (ret)
844*4882a593Smuzhiyun return ret;
845*4882a593Smuzhiyun ndelay(900);
846*4882a593Smuzhiyun
847*4882a593Smuzhiyun return ret;
848*4882a593Smuzhiyun }
849*4882a593Smuzhiyun
850*4882a593Smuzhiyun /* Configure voltage swing and pre-emphasis for all enabled lanes. */
cdns_torrent_dp_set_voltages(struct cdns_torrent_phy * cdns_phy,struct phy_configure_opts_dp * dp)851*4882a593Smuzhiyun static void cdns_torrent_dp_set_voltages(struct cdns_torrent_phy *cdns_phy,
852*4882a593Smuzhiyun struct phy_configure_opts_dp *dp)
853*4882a593Smuzhiyun {
854*4882a593Smuzhiyun u8 lane;
855*4882a593Smuzhiyun u16 val;
856*4882a593Smuzhiyun
857*4882a593Smuzhiyun for (lane = 0; lane < dp->lanes; lane++) {
858*4882a593Smuzhiyun val = cdns_torrent_phy_read(cdns_phy->regmap_tx_lane_cdb[lane],
859*4882a593Smuzhiyun TX_DIAG_ACYA);
860*4882a593Smuzhiyun /*
861*4882a593Smuzhiyun * Write 1 to register bit TX_DIAG_ACYA[0] to freeze the
862*4882a593Smuzhiyun * current state of the analog TX driver.
863*4882a593Smuzhiyun */
864*4882a593Smuzhiyun val |= TX_DIAG_ACYA_HBDC_MASK;
865*4882a593Smuzhiyun cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[lane],
866*4882a593Smuzhiyun TX_DIAG_ACYA, val);
867*4882a593Smuzhiyun
868*4882a593Smuzhiyun cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[lane],
869*4882a593Smuzhiyun TX_TXCC_CTRL, 0x08A4);
870*4882a593Smuzhiyun val = vltg_coeff[dp->voltage[lane]][dp->pre[lane]].diag_tx_drv;
871*4882a593Smuzhiyun cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[lane],
872*4882a593Smuzhiyun DRV_DIAG_TX_DRV, val);
873*4882a593Smuzhiyun val = vltg_coeff[dp->voltage[lane]][dp->pre[lane]].mgnfs_mult;
874*4882a593Smuzhiyun cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[lane],
875*4882a593Smuzhiyun TX_TXCC_MGNFS_MULT_000,
876*4882a593Smuzhiyun val);
877*4882a593Smuzhiyun val = vltg_coeff[dp->voltage[lane]][dp->pre[lane]].cpost_mult;
878*4882a593Smuzhiyun cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[lane],
879*4882a593Smuzhiyun TX_TXCC_CPOST_MULT_00,
880*4882a593Smuzhiyun val);
881*4882a593Smuzhiyun
882*4882a593Smuzhiyun val = cdns_torrent_phy_read(cdns_phy->regmap_tx_lane_cdb[lane],
883*4882a593Smuzhiyun TX_DIAG_ACYA);
884*4882a593Smuzhiyun /*
885*4882a593Smuzhiyun * Write 0 to register bit TX_DIAG_ACYA[0] to allow the state of
886*4882a593Smuzhiyun * analog TX driver to reflect the new programmed one.
887*4882a593Smuzhiyun */
888*4882a593Smuzhiyun val &= ~TX_DIAG_ACYA_HBDC_MASK;
889*4882a593Smuzhiyun cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[lane],
890*4882a593Smuzhiyun TX_DIAG_ACYA, val);
891*4882a593Smuzhiyun }
892*4882a593Smuzhiyun };
893*4882a593Smuzhiyun
cdns_torrent_dp_configure(struct phy * phy,union phy_configure_opts * opts)894*4882a593Smuzhiyun static int cdns_torrent_dp_configure(struct phy *phy,
895*4882a593Smuzhiyun union phy_configure_opts *opts)
896*4882a593Smuzhiyun {
897*4882a593Smuzhiyun struct cdns_torrent_inst *inst = phy_get_drvdata(phy);
898*4882a593Smuzhiyun struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(phy->dev.parent);
899*4882a593Smuzhiyun int ret;
900*4882a593Smuzhiyun
901*4882a593Smuzhiyun ret = cdns_torrent_dp_verify_config(inst, &opts->dp);
902*4882a593Smuzhiyun if (ret) {
903*4882a593Smuzhiyun dev_err(&phy->dev, "invalid params for phy configure\n");
904*4882a593Smuzhiyun return ret;
905*4882a593Smuzhiyun }
906*4882a593Smuzhiyun
907*4882a593Smuzhiyun if (opts->dp.set_lanes) {
908*4882a593Smuzhiyun ret = cdns_torrent_dp_set_lanes(cdns_phy, &opts->dp);
909*4882a593Smuzhiyun if (ret) {
910*4882a593Smuzhiyun dev_err(&phy->dev, "cdns_torrent_dp_set_lanes failed\n");
911*4882a593Smuzhiyun return ret;
912*4882a593Smuzhiyun }
913*4882a593Smuzhiyun }
914*4882a593Smuzhiyun
915*4882a593Smuzhiyun if (opts->dp.set_rate) {
916*4882a593Smuzhiyun ret = cdns_torrent_dp_set_rate(cdns_phy, &opts->dp);
917*4882a593Smuzhiyun if (ret) {
918*4882a593Smuzhiyun dev_err(&phy->dev, "cdns_torrent_dp_set_rate failed\n");
919*4882a593Smuzhiyun return ret;
920*4882a593Smuzhiyun }
921*4882a593Smuzhiyun }
922*4882a593Smuzhiyun
923*4882a593Smuzhiyun if (opts->dp.set_voltages)
924*4882a593Smuzhiyun cdns_torrent_dp_set_voltages(cdns_phy, &opts->dp);
925*4882a593Smuzhiyun
926*4882a593Smuzhiyun return ret;
927*4882a593Smuzhiyun }
928*4882a593Smuzhiyun
cdns_torrent_dp_init(struct phy * phy)929*4882a593Smuzhiyun static int cdns_torrent_dp_init(struct phy *phy)
930*4882a593Smuzhiyun {
931*4882a593Smuzhiyun unsigned char lane_bits;
932*4882a593Smuzhiyun int ret;
933*4882a593Smuzhiyun struct cdns_torrent_inst *inst = phy_get_drvdata(phy);
934*4882a593Smuzhiyun struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(phy->dev.parent);
935*4882a593Smuzhiyun struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg;
936*4882a593Smuzhiyun
937*4882a593Smuzhiyun switch (cdns_phy->ref_clk_rate) {
938*4882a593Smuzhiyun case REF_CLK_19_2MHz:
939*4882a593Smuzhiyun case REF_CLK_25MHz:
940*4882a593Smuzhiyun /* Valid Ref Clock Rate */
941*4882a593Smuzhiyun break;
942*4882a593Smuzhiyun default:
943*4882a593Smuzhiyun dev_err(cdns_phy->dev, "Unsupported Ref Clock Rate\n");
944*4882a593Smuzhiyun return -EINVAL;
945*4882a593Smuzhiyun }
946*4882a593Smuzhiyun
947*4882a593Smuzhiyun cdns_torrent_dp_write(regmap, PHY_AUX_CTRL, 0x0003); /* enable AUX */
948*4882a593Smuzhiyun
949*4882a593Smuzhiyun /* PHY PMA registers configuration function */
950*4882a593Smuzhiyun cdns_torrent_dp_pma_cfg(cdns_phy, inst);
951*4882a593Smuzhiyun
952*4882a593Smuzhiyun /*
953*4882a593Smuzhiyun * Set lines power state to A0
954*4882a593Smuzhiyun * Set lines pll clk enable to 0
955*4882a593Smuzhiyun */
956*4882a593Smuzhiyun cdns_torrent_dp_set_a0_pll(cdns_phy, inst->num_lanes);
957*4882a593Smuzhiyun
958*4882a593Smuzhiyun /*
959*4882a593Smuzhiyun * release phy_l0*_reset_n and pma_tx_elec_idle_ln_* based on
960*4882a593Smuzhiyun * used lanes
961*4882a593Smuzhiyun */
962*4882a593Smuzhiyun lane_bits = (1 << inst->num_lanes) - 1;
963*4882a593Smuzhiyun cdns_torrent_dp_write(regmap, PHY_RESET,
964*4882a593Smuzhiyun ((0xF & ~lane_bits) << 4) | (0xF & lane_bits));
965*4882a593Smuzhiyun
966*4882a593Smuzhiyun /* release pma_xcvr_pllclk_en_ln_*, only for the master lane */
967*4882a593Smuzhiyun cdns_torrent_dp_write(regmap, PHY_PMA_XCVR_PLLCLK_EN, 0x0001);
968*4882a593Smuzhiyun
969*4882a593Smuzhiyun /* PHY PMA registers configuration functions */
970*4882a593Smuzhiyun /* Initialize PHY with max supported link rate, without SSC. */
971*4882a593Smuzhiyun if (cdns_phy->ref_clk_rate == REF_CLK_19_2MHz)
972*4882a593Smuzhiyun cdns_torrent_dp_pma_cmn_vco_cfg_19_2mhz(cdns_phy,
973*4882a593Smuzhiyun cdns_phy->max_bit_rate,
974*4882a593Smuzhiyun false);
975*4882a593Smuzhiyun else if (cdns_phy->ref_clk_rate == REF_CLK_25MHz)
976*4882a593Smuzhiyun cdns_torrent_dp_pma_cmn_vco_cfg_25mhz(cdns_phy,
977*4882a593Smuzhiyun cdns_phy->max_bit_rate,
978*4882a593Smuzhiyun false);
979*4882a593Smuzhiyun cdns_torrent_dp_pma_cmn_rate(cdns_phy, cdns_phy->max_bit_rate,
980*4882a593Smuzhiyun inst->num_lanes);
981*4882a593Smuzhiyun
982*4882a593Smuzhiyun /* take out of reset */
983*4882a593Smuzhiyun regmap_field_write(cdns_phy->phy_reset_ctrl, 0x1);
984*4882a593Smuzhiyun
985*4882a593Smuzhiyun cdns_torrent_phy_on(phy);
986*4882a593Smuzhiyun
987*4882a593Smuzhiyun ret = cdns_torrent_dp_wait_pma_cmn_ready(cdns_phy);
988*4882a593Smuzhiyun if (ret)
989*4882a593Smuzhiyun return ret;
990*4882a593Smuzhiyun
991*4882a593Smuzhiyun ret = cdns_torrent_dp_run(cdns_phy, inst->num_lanes);
992*4882a593Smuzhiyun
993*4882a593Smuzhiyun return ret;
994*4882a593Smuzhiyun }
995*4882a593Smuzhiyun
996*4882a593Smuzhiyun static
cdns_torrent_dp_wait_pma_cmn_ready(struct cdns_torrent_phy * cdns_phy)997*4882a593Smuzhiyun int cdns_torrent_dp_wait_pma_cmn_ready(struct cdns_torrent_phy *cdns_phy)
998*4882a593Smuzhiyun {
999*4882a593Smuzhiyun unsigned int reg;
1000*4882a593Smuzhiyun int ret;
1001*4882a593Smuzhiyun struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg;
1002*4882a593Smuzhiyun
1003*4882a593Smuzhiyun ret = regmap_read_poll_timeout(regmap, PHY_PMA_CMN_READY, reg,
1004*4882a593Smuzhiyun reg & 1, 0, POLL_TIMEOUT_US);
1005*4882a593Smuzhiyun if (ret == -ETIMEDOUT) {
1006*4882a593Smuzhiyun dev_err(cdns_phy->dev,
1007*4882a593Smuzhiyun "timeout waiting for PMA common ready\n");
1008*4882a593Smuzhiyun return -ETIMEDOUT;
1009*4882a593Smuzhiyun }
1010*4882a593Smuzhiyun
1011*4882a593Smuzhiyun return 0;
1012*4882a593Smuzhiyun }
1013*4882a593Smuzhiyun
cdns_torrent_dp_pma_cfg(struct cdns_torrent_phy * cdns_phy,struct cdns_torrent_inst * inst)1014*4882a593Smuzhiyun static void cdns_torrent_dp_pma_cfg(struct cdns_torrent_phy *cdns_phy,
1015*4882a593Smuzhiyun struct cdns_torrent_inst *inst)
1016*4882a593Smuzhiyun {
1017*4882a593Smuzhiyun unsigned int i;
1018*4882a593Smuzhiyun
1019*4882a593Smuzhiyun if (cdns_phy->ref_clk_rate == REF_CLK_19_2MHz)
1020*4882a593Smuzhiyun /* PMA common configuration 19.2MHz */
1021*4882a593Smuzhiyun cdns_torrent_dp_pma_cmn_cfg_19_2mhz(cdns_phy);
1022*4882a593Smuzhiyun else if (cdns_phy->ref_clk_rate == REF_CLK_25MHz)
1023*4882a593Smuzhiyun /* PMA common configuration 25MHz */
1024*4882a593Smuzhiyun cdns_torrent_dp_pma_cmn_cfg_25mhz(cdns_phy);
1025*4882a593Smuzhiyun
1026*4882a593Smuzhiyun /* PMA lane configuration to deal with multi-link operation */
1027*4882a593Smuzhiyun for (i = 0; i < inst->num_lanes; i++)
1028*4882a593Smuzhiyun cdns_torrent_dp_pma_lane_cfg(cdns_phy, i);
1029*4882a593Smuzhiyun }
1030*4882a593Smuzhiyun
1031*4882a593Smuzhiyun static
cdns_torrent_dp_pma_cmn_cfg_19_2mhz(struct cdns_torrent_phy * cdns_phy)1032*4882a593Smuzhiyun void cdns_torrent_dp_pma_cmn_cfg_19_2mhz(struct cdns_torrent_phy *cdns_phy)
1033*4882a593Smuzhiyun {
1034*4882a593Smuzhiyun struct regmap *regmap = cdns_phy->regmap_common_cdb;
1035*4882a593Smuzhiyun
1036*4882a593Smuzhiyun /* refclock registers - assumes 19.2 MHz refclock */
1037*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_SSM_BIAS_TMR, 0x0014);
1038*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLLSM0_PLLPRE_TMR, 0x0027);
1039*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLLSM0_PLLLOCK_TMR, 0x00A1);
1040*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLLSM1_PLLPRE_TMR, 0x0027);
1041*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLLSM1_PLLLOCK_TMR, 0x00A1);
1042*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_BGCAL_INIT_TMR, 0x0060);
1043*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_BGCAL_ITER_TMR, 0x0060);
1044*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_IBCAL_INIT_TMR, 0x0014);
1045*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_TXPUCAL_INIT_TMR, 0x0018);
1046*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_TXPUCAL_ITER_TMR, 0x0005);
1047*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_TXPDCAL_INIT_TMR, 0x0018);
1048*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_TXPDCAL_ITER_TMR, 0x0005);
1049*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_RXCAL_INIT_TMR, 0x0240);
1050*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_RXCAL_ITER_TMR, 0x0005);
1051*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_SD_CAL_INIT_TMR, 0x0002);
1052*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_SD_CAL_ITER_TMR, 0x0002);
1053*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_SD_CAL_REFTIM_START, 0x000B);
1054*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_SD_CAL_PLLCNT_START, 0x0137);
1055*4882a593Smuzhiyun
1056*4882a593Smuzhiyun /* PLL registers */
1057*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL0_CP_PADJ_M0, 0x0509);
1058*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL0_CP_IADJ_M0, 0x0F00);
1059*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL0_FILT_PADJ_M0, 0x0F08);
1060*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL0_DSM_DIAG_M0, 0x0004);
1061*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL1_CP_PADJ_M0, 0x0509);
1062*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL1_CP_IADJ_M0, 0x0F00);
1063*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL1_FILT_PADJ_M0, 0x0F08);
1064*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL1_DSM_DIAG_M0, 0x0004);
1065*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL0_VCOCAL_INIT_TMR, 0x00C0);
1066*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL0_VCOCAL_ITER_TMR, 0x0004);
1067*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL1_VCOCAL_INIT_TMR, 0x00C0);
1068*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL1_VCOCAL_ITER_TMR, 0x0004);
1069*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL0_VCOCAL_REFTIM_START, 0x0260);
1070*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL0_VCOCAL_TCTRL, 0x0003);
1071*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL1_VCOCAL_REFTIM_START, 0x0260);
1072*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL1_VCOCAL_TCTRL, 0x0003);
1073*4882a593Smuzhiyun }
1074*4882a593Smuzhiyun
1075*4882a593Smuzhiyun /*
1076*4882a593Smuzhiyun * Set registers responsible for enabling and configuring SSC, with second and
1077*4882a593Smuzhiyun * third register values provided by parameters.
1078*4882a593Smuzhiyun */
1079*4882a593Smuzhiyun static
cdns_torrent_dp_enable_ssc_19_2mhz(struct cdns_torrent_phy * cdns_phy,u32 ctrl2_val,u32 ctrl3_val)1080*4882a593Smuzhiyun void cdns_torrent_dp_enable_ssc_19_2mhz(struct cdns_torrent_phy *cdns_phy,
1081*4882a593Smuzhiyun u32 ctrl2_val, u32 ctrl3_val)
1082*4882a593Smuzhiyun {
1083*4882a593Smuzhiyun struct regmap *regmap = cdns_phy->regmap_common_cdb;
1084*4882a593Smuzhiyun
1085*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL0_SS_CTRL1_M0, 0x0001);
1086*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL0_SS_CTRL1_M0, ctrl2_val);
1087*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL0_SS_CTRL1_M0, ctrl3_val);
1088*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL0_SS_CTRL4_M0, 0x0003);
1089*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL1_SS_CTRL1_M0, 0x0001);
1090*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL1_SS_CTRL1_M0, ctrl2_val);
1091*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL1_SS_CTRL1_M0, ctrl3_val);
1092*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL1_SS_CTRL4_M0, 0x0003);
1093*4882a593Smuzhiyun }
1094*4882a593Smuzhiyun
1095*4882a593Smuzhiyun static
cdns_torrent_dp_pma_cmn_vco_cfg_19_2mhz(struct cdns_torrent_phy * cdns_phy,u32 rate,bool ssc)1096*4882a593Smuzhiyun void cdns_torrent_dp_pma_cmn_vco_cfg_19_2mhz(struct cdns_torrent_phy *cdns_phy,
1097*4882a593Smuzhiyun u32 rate, bool ssc)
1098*4882a593Smuzhiyun {
1099*4882a593Smuzhiyun struct regmap *regmap = cdns_phy->regmap_common_cdb;
1100*4882a593Smuzhiyun
1101*4882a593Smuzhiyun /* Assumes 19.2 MHz refclock */
1102*4882a593Smuzhiyun switch (rate) {
1103*4882a593Smuzhiyun /* Setting VCO for 10.8GHz */
1104*4882a593Smuzhiyun case 2700:
1105*4882a593Smuzhiyun case 5400:
1106*4882a593Smuzhiyun cdns_torrent_phy_write(regmap,
1107*4882a593Smuzhiyun CMN_PLL0_INTDIV_M0, 0x0119);
1108*4882a593Smuzhiyun cdns_torrent_phy_write(regmap,
1109*4882a593Smuzhiyun CMN_PLL0_FRACDIVL_M0, 0x4000);
1110*4882a593Smuzhiyun cdns_torrent_phy_write(regmap,
1111*4882a593Smuzhiyun CMN_PLL0_FRACDIVH_M0, 0x0002);
1112*4882a593Smuzhiyun cdns_torrent_phy_write(regmap,
1113*4882a593Smuzhiyun CMN_PLL0_HIGH_THR_M0, 0x00BC);
1114*4882a593Smuzhiyun cdns_torrent_phy_write(regmap,
1115*4882a593Smuzhiyun CMN_PDIAG_PLL0_CTRL_M0, 0x0012);
1116*4882a593Smuzhiyun cdns_torrent_phy_write(regmap,
1117*4882a593Smuzhiyun CMN_PLL1_INTDIV_M0, 0x0119);
1118*4882a593Smuzhiyun cdns_torrent_phy_write(regmap,
1119*4882a593Smuzhiyun CMN_PLL1_FRACDIVL_M0, 0x4000);
1120*4882a593Smuzhiyun cdns_torrent_phy_write(regmap,
1121*4882a593Smuzhiyun CMN_PLL1_FRACDIVH_M0, 0x0002);
1122*4882a593Smuzhiyun cdns_torrent_phy_write(regmap,
1123*4882a593Smuzhiyun CMN_PLL1_HIGH_THR_M0, 0x00BC);
1124*4882a593Smuzhiyun cdns_torrent_phy_write(regmap,
1125*4882a593Smuzhiyun CMN_PDIAG_PLL1_CTRL_M0, 0x0012);
1126*4882a593Smuzhiyun if (ssc)
1127*4882a593Smuzhiyun cdns_torrent_dp_enable_ssc_19_2mhz(cdns_phy, 0x033A,
1128*4882a593Smuzhiyun 0x006A);
1129*4882a593Smuzhiyun break;
1130*4882a593Smuzhiyun /* Setting VCO for 9.72GHz */
1131*4882a593Smuzhiyun case 1620:
1132*4882a593Smuzhiyun case 2430:
1133*4882a593Smuzhiyun case 3240:
1134*4882a593Smuzhiyun cdns_torrent_phy_write(regmap,
1135*4882a593Smuzhiyun CMN_PLL0_INTDIV_M0, 0x01FA);
1136*4882a593Smuzhiyun cdns_torrent_phy_write(regmap,
1137*4882a593Smuzhiyun CMN_PLL0_FRACDIVL_M0, 0x4000);
1138*4882a593Smuzhiyun cdns_torrent_phy_write(regmap,
1139*4882a593Smuzhiyun CMN_PLL0_FRACDIVH_M0, 0x0002);
1140*4882a593Smuzhiyun cdns_torrent_phy_write(regmap,
1141*4882a593Smuzhiyun CMN_PLL0_HIGH_THR_M0, 0x0152);
1142*4882a593Smuzhiyun cdns_torrent_phy_write(regmap,
1143*4882a593Smuzhiyun CMN_PDIAG_PLL0_CTRL_M0, 0x0002);
1144*4882a593Smuzhiyun cdns_torrent_phy_write(regmap,
1145*4882a593Smuzhiyun CMN_PLL1_INTDIV_M0, 0x01FA);
1146*4882a593Smuzhiyun cdns_torrent_phy_write(regmap,
1147*4882a593Smuzhiyun CMN_PLL1_FRACDIVL_M0, 0x4000);
1148*4882a593Smuzhiyun cdns_torrent_phy_write(regmap,
1149*4882a593Smuzhiyun CMN_PLL1_FRACDIVH_M0, 0x0002);
1150*4882a593Smuzhiyun cdns_torrent_phy_write(regmap,
1151*4882a593Smuzhiyun CMN_PLL1_HIGH_THR_M0, 0x0152);
1152*4882a593Smuzhiyun cdns_torrent_phy_write(regmap,
1153*4882a593Smuzhiyun CMN_PDIAG_PLL1_CTRL_M0, 0x0002);
1154*4882a593Smuzhiyun if (ssc)
1155*4882a593Smuzhiyun cdns_torrent_dp_enable_ssc_19_2mhz(cdns_phy, 0x05DD,
1156*4882a593Smuzhiyun 0x0069);
1157*4882a593Smuzhiyun break;
1158*4882a593Smuzhiyun /* Setting VCO for 8.64GHz */
1159*4882a593Smuzhiyun case 2160:
1160*4882a593Smuzhiyun case 4320:
1161*4882a593Smuzhiyun cdns_torrent_phy_write(regmap,
1162*4882a593Smuzhiyun CMN_PLL0_INTDIV_M0, 0x01C2);
1163*4882a593Smuzhiyun cdns_torrent_phy_write(regmap,
1164*4882a593Smuzhiyun CMN_PLL0_FRACDIVL_M0, 0x0000);
1165*4882a593Smuzhiyun cdns_torrent_phy_write(regmap,
1166*4882a593Smuzhiyun CMN_PLL0_FRACDIVH_M0, 0x0002);
1167*4882a593Smuzhiyun cdns_torrent_phy_write(regmap,
1168*4882a593Smuzhiyun CMN_PLL0_HIGH_THR_M0, 0x012C);
1169*4882a593Smuzhiyun cdns_torrent_phy_write(regmap,
1170*4882a593Smuzhiyun CMN_PDIAG_PLL0_CTRL_M0, 0x0002);
1171*4882a593Smuzhiyun cdns_torrent_phy_write(regmap,
1172*4882a593Smuzhiyun CMN_PLL1_INTDIV_M0, 0x01C2);
1173*4882a593Smuzhiyun cdns_torrent_phy_write(regmap,
1174*4882a593Smuzhiyun CMN_PLL1_FRACDIVL_M0, 0x0000);
1175*4882a593Smuzhiyun cdns_torrent_phy_write(regmap,
1176*4882a593Smuzhiyun CMN_PLL1_FRACDIVH_M0, 0x0002);
1177*4882a593Smuzhiyun cdns_torrent_phy_write(regmap,
1178*4882a593Smuzhiyun CMN_PLL1_HIGH_THR_M0, 0x012C);
1179*4882a593Smuzhiyun cdns_torrent_phy_write(regmap,
1180*4882a593Smuzhiyun CMN_PDIAG_PLL1_CTRL_M0, 0x0002);
1181*4882a593Smuzhiyun if (ssc)
1182*4882a593Smuzhiyun cdns_torrent_dp_enable_ssc_19_2mhz(cdns_phy, 0x0536,
1183*4882a593Smuzhiyun 0x0069);
1184*4882a593Smuzhiyun break;
1185*4882a593Smuzhiyun /* Setting VCO for 8.1GHz */
1186*4882a593Smuzhiyun case 8100:
1187*4882a593Smuzhiyun cdns_torrent_phy_write(regmap,
1188*4882a593Smuzhiyun CMN_PLL0_INTDIV_M0, 0x01A5);
1189*4882a593Smuzhiyun cdns_torrent_phy_write(regmap,
1190*4882a593Smuzhiyun CMN_PLL0_FRACDIVL_M0, 0xE000);
1191*4882a593Smuzhiyun cdns_torrent_phy_write(regmap,
1192*4882a593Smuzhiyun CMN_PLL0_FRACDIVH_M0, 0x0002);
1193*4882a593Smuzhiyun cdns_torrent_phy_write(regmap,
1194*4882a593Smuzhiyun CMN_PLL0_HIGH_THR_M0, 0x011A);
1195*4882a593Smuzhiyun cdns_torrent_phy_write(regmap,
1196*4882a593Smuzhiyun CMN_PDIAG_PLL0_CTRL_M0, 0x0002);
1197*4882a593Smuzhiyun cdns_torrent_phy_write(regmap,
1198*4882a593Smuzhiyun CMN_PLL1_INTDIV_M0, 0x01A5);
1199*4882a593Smuzhiyun cdns_torrent_phy_write(regmap,
1200*4882a593Smuzhiyun CMN_PLL1_FRACDIVL_M0, 0xE000);
1201*4882a593Smuzhiyun cdns_torrent_phy_write(regmap,
1202*4882a593Smuzhiyun CMN_PLL1_FRACDIVH_M0, 0x0002);
1203*4882a593Smuzhiyun cdns_torrent_phy_write(regmap,
1204*4882a593Smuzhiyun CMN_PLL1_HIGH_THR_M0, 0x011A);
1205*4882a593Smuzhiyun cdns_torrent_phy_write(regmap,
1206*4882a593Smuzhiyun CMN_PDIAG_PLL1_CTRL_M0, 0x0002);
1207*4882a593Smuzhiyun if (ssc)
1208*4882a593Smuzhiyun cdns_torrent_dp_enable_ssc_19_2mhz(cdns_phy, 0x04D7,
1209*4882a593Smuzhiyun 0x006A);
1210*4882a593Smuzhiyun break;
1211*4882a593Smuzhiyun }
1212*4882a593Smuzhiyun
1213*4882a593Smuzhiyun if (ssc) {
1214*4882a593Smuzhiyun cdns_torrent_phy_write(regmap,
1215*4882a593Smuzhiyun CMN_PLL0_VCOCAL_PLLCNT_START, 0x025E);
1216*4882a593Smuzhiyun cdns_torrent_phy_write(regmap,
1217*4882a593Smuzhiyun CMN_PLL0_LOCK_PLLCNT_THR, 0x0005);
1218*4882a593Smuzhiyun cdns_torrent_phy_write(regmap,
1219*4882a593Smuzhiyun CMN_PLL1_VCOCAL_PLLCNT_START, 0x025E);
1220*4882a593Smuzhiyun cdns_torrent_phy_write(regmap,
1221*4882a593Smuzhiyun CMN_PLL1_LOCK_PLLCNT_THR, 0x0005);
1222*4882a593Smuzhiyun } else {
1223*4882a593Smuzhiyun cdns_torrent_phy_write(regmap,
1224*4882a593Smuzhiyun CMN_PLL0_VCOCAL_PLLCNT_START, 0x0260);
1225*4882a593Smuzhiyun cdns_torrent_phy_write(regmap,
1226*4882a593Smuzhiyun CMN_PLL1_VCOCAL_PLLCNT_START, 0x0260);
1227*4882a593Smuzhiyun /* Set reset register values to disable SSC */
1228*4882a593Smuzhiyun cdns_torrent_phy_write(regmap,
1229*4882a593Smuzhiyun CMN_PLL0_SS_CTRL1_M0, 0x0002);
1230*4882a593Smuzhiyun cdns_torrent_phy_write(regmap,
1231*4882a593Smuzhiyun CMN_PLL0_SS_CTRL2_M0, 0x0000);
1232*4882a593Smuzhiyun cdns_torrent_phy_write(regmap,
1233*4882a593Smuzhiyun CMN_PLL0_SS_CTRL3_M0, 0x0000);
1234*4882a593Smuzhiyun cdns_torrent_phy_write(regmap,
1235*4882a593Smuzhiyun CMN_PLL0_SS_CTRL4_M0, 0x0000);
1236*4882a593Smuzhiyun cdns_torrent_phy_write(regmap,
1237*4882a593Smuzhiyun CMN_PLL0_LOCK_PLLCNT_THR, 0x0003);
1238*4882a593Smuzhiyun cdns_torrent_phy_write(regmap,
1239*4882a593Smuzhiyun CMN_PLL1_SS_CTRL1_M0, 0x0002);
1240*4882a593Smuzhiyun cdns_torrent_phy_write(regmap,
1241*4882a593Smuzhiyun CMN_PLL1_SS_CTRL2_M0, 0x0000);
1242*4882a593Smuzhiyun cdns_torrent_phy_write(regmap,
1243*4882a593Smuzhiyun CMN_PLL1_SS_CTRL3_M0, 0x0000);
1244*4882a593Smuzhiyun cdns_torrent_phy_write(regmap,
1245*4882a593Smuzhiyun CMN_PLL1_SS_CTRL4_M0, 0x0000);
1246*4882a593Smuzhiyun cdns_torrent_phy_write(regmap,
1247*4882a593Smuzhiyun CMN_PLL1_LOCK_PLLCNT_THR, 0x0003);
1248*4882a593Smuzhiyun }
1249*4882a593Smuzhiyun
1250*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL0_LOCK_REFCNT_START, 0x0099);
1251*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL0_LOCK_PLLCNT_START, 0x0099);
1252*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL1_LOCK_REFCNT_START, 0x0099);
1253*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL1_LOCK_PLLCNT_START, 0x0099);
1254*4882a593Smuzhiyun }
1255*4882a593Smuzhiyun
1256*4882a593Smuzhiyun static
cdns_torrent_dp_pma_cmn_cfg_25mhz(struct cdns_torrent_phy * cdns_phy)1257*4882a593Smuzhiyun void cdns_torrent_dp_pma_cmn_cfg_25mhz(struct cdns_torrent_phy *cdns_phy)
1258*4882a593Smuzhiyun {
1259*4882a593Smuzhiyun struct regmap *regmap = cdns_phy->regmap_common_cdb;
1260*4882a593Smuzhiyun
1261*4882a593Smuzhiyun /* refclock registers - assumes 25 MHz refclock */
1262*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_SSM_BIAS_TMR, 0x0019);
1263*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLLSM0_PLLPRE_TMR, 0x0032);
1264*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLLSM0_PLLLOCK_TMR, 0x00D1);
1265*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLLSM1_PLLPRE_TMR, 0x0032);
1266*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLLSM1_PLLLOCK_TMR, 0x00D1);
1267*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_BGCAL_INIT_TMR, 0x007D);
1268*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_BGCAL_ITER_TMR, 0x007D);
1269*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_IBCAL_INIT_TMR, 0x0019);
1270*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_TXPUCAL_INIT_TMR, 0x001E);
1271*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_TXPUCAL_ITER_TMR, 0x0006);
1272*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_TXPDCAL_INIT_TMR, 0x001E);
1273*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_TXPDCAL_ITER_TMR, 0x0006);
1274*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_RXCAL_INIT_TMR, 0x02EE);
1275*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_RXCAL_ITER_TMR, 0x0006);
1276*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_SD_CAL_INIT_TMR, 0x0002);
1277*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_SD_CAL_ITER_TMR, 0x0002);
1278*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_SD_CAL_REFTIM_START, 0x000E);
1279*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_SD_CAL_PLLCNT_START, 0x012B);
1280*4882a593Smuzhiyun
1281*4882a593Smuzhiyun /* PLL registers */
1282*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL0_CP_PADJ_M0, 0x0509);
1283*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL0_CP_IADJ_M0, 0x0F00);
1284*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL0_FILT_PADJ_M0, 0x0F08);
1285*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL0_DSM_DIAG_M0, 0x0004);
1286*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL1_CP_PADJ_M0, 0x0509);
1287*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL1_CP_IADJ_M0, 0x0F00);
1288*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL1_FILT_PADJ_M0, 0x0F08);
1289*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL1_DSM_DIAG_M0, 0x0004);
1290*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL0_VCOCAL_INIT_TMR, 0x00FA);
1291*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL0_VCOCAL_ITER_TMR, 0x0004);
1292*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL1_VCOCAL_INIT_TMR, 0x00FA);
1293*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL1_VCOCAL_ITER_TMR, 0x0004);
1294*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL0_VCOCAL_REFTIM_START, 0x0317);
1295*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL0_VCOCAL_TCTRL, 0x0003);
1296*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL1_VCOCAL_REFTIM_START, 0x0317);
1297*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL1_VCOCAL_TCTRL, 0x0003);
1298*4882a593Smuzhiyun }
1299*4882a593Smuzhiyun
1300*4882a593Smuzhiyun /*
1301*4882a593Smuzhiyun * Set registers responsible for enabling and configuring SSC, with second
1302*4882a593Smuzhiyun * register value provided by a parameter.
1303*4882a593Smuzhiyun */
cdns_torrent_dp_enable_ssc_25mhz(struct cdns_torrent_phy * cdns_phy,u32 ctrl2_val)1304*4882a593Smuzhiyun static void cdns_torrent_dp_enable_ssc_25mhz(struct cdns_torrent_phy *cdns_phy,
1305*4882a593Smuzhiyun u32 ctrl2_val)
1306*4882a593Smuzhiyun {
1307*4882a593Smuzhiyun struct regmap *regmap = cdns_phy->regmap_common_cdb;
1308*4882a593Smuzhiyun
1309*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL0_SS_CTRL1_M0, 0x0001);
1310*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL0_SS_CTRL1_M0, ctrl2_val);
1311*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL0_SS_CTRL1_M0, 0x007F);
1312*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL0_SS_CTRL4_M0, 0x0003);
1313*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL1_SS_CTRL1_M0, 0x0001);
1314*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL1_SS_CTRL1_M0, ctrl2_val);
1315*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL1_SS_CTRL1_M0, 0x007F);
1316*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL1_SS_CTRL4_M0, 0x0003);
1317*4882a593Smuzhiyun }
1318*4882a593Smuzhiyun
1319*4882a593Smuzhiyun static
cdns_torrent_dp_pma_cmn_vco_cfg_25mhz(struct cdns_torrent_phy * cdns_phy,u32 rate,bool ssc)1320*4882a593Smuzhiyun void cdns_torrent_dp_pma_cmn_vco_cfg_25mhz(struct cdns_torrent_phy *cdns_phy,
1321*4882a593Smuzhiyun u32 rate, bool ssc)
1322*4882a593Smuzhiyun {
1323*4882a593Smuzhiyun struct regmap *regmap = cdns_phy->regmap_common_cdb;
1324*4882a593Smuzhiyun
1325*4882a593Smuzhiyun /* Assumes 25 MHz refclock */
1326*4882a593Smuzhiyun switch (rate) {
1327*4882a593Smuzhiyun /* Setting VCO for 10.8GHz */
1328*4882a593Smuzhiyun case 2700:
1329*4882a593Smuzhiyun case 5400:
1330*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL0_INTDIV_M0, 0x01B0);
1331*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVL_M0, 0x0000);
1332*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVH_M0, 0x0002);
1333*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL0_HIGH_THR_M0, 0x0120);
1334*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL1_INTDIV_M0, 0x01B0);
1335*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVL_M0, 0x0000);
1336*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVH_M0, 0x0002);
1337*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL1_HIGH_THR_M0, 0x0120);
1338*4882a593Smuzhiyun if (ssc)
1339*4882a593Smuzhiyun cdns_torrent_dp_enable_ssc_25mhz(cdns_phy, 0x0423);
1340*4882a593Smuzhiyun break;
1341*4882a593Smuzhiyun /* Setting VCO for 9.72GHz */
1342*4882a593Smuzhiyun case 1620:
1343*4882a593Smuzhiyun case 2430:
1344*4882a593Smuzhiyun case 3240:
1345*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL0_INTDIV_M0, 0x0184);
1346*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVL_M0, 0xCCCD);
1347*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVH_M0, 0x0002);
1348*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL0_HIGH_THR_M0, 0x0104);
1349*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL1_INTDIV_M0, 0x0184);
1350*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVL_M0, 0xCCCD);
1351*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVH_M0, 0x0002);
1352*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL1_HIGH_THR_M0, 0x0104);
1353*4882a593Smuzhiyun if (ssc)
1354*4882a593Smuzhiyun cdns_torrent_dp_enable_ssc_25mhz(cdns_phy, 0x03B9);
1355*4882a593Smuzhiyun break;
1356*4882a593Smuzhiyun /* Setting VCO for 8.64GHz */
1357*4882a593Smuzhiyun case 2160:
1358*4882a593Smuzhiyun case 4320:
1359*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL0_INTDIV_M0, 0x0159);
1360*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVL_M0, 0x999A);
1361*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVH_M0, 0x0002);
1362*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL0_HIGH_THR_M0, 0x00E7);
1363*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL1_INTDIV_M0, 0x0159);
1364*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVL_M0, 0x999A);
1365*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVH_M0, 0x0002);
1366*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL1_HIGH_THR_M0, 0x00E7);
1367*4882a593Smuzhiyun if (ssc)
1368*4882a593Smuzhiyun cdns_torrent_dp_enable_ssc_25mhz(cdns_phy, 0x034F);
1369*4882a593Smuzhiyun break;
1370*4882a593Smuzhiyun /* Setting VCO for 8.1GHz */
1371*4882a593Smuzhiyun case 8100:
1372*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL0_INTDIV_M0, 0x0144);
1373*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVL_M0, 0x0000);
1374*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVH_M0, 0x0002);
1375*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL0_HIGH_THR_M0, 0x00D8);
1376*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL1_INTDIV_M0, 0x0144);
1377*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVL_M0, 0x0000);
1378*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVH_M0, 0x0002);
1379*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL1_HIGH_THR_M0, 0x00D8);
1380*4882a593Smuzhiyun if (ssc)
1381*4882a593Smuzhiyun cdns_torrent_dp_enable_ssc_25mhz(cdns_phy, 0x031A);
1382*4882a593Smuzhiyun break;
1383*4882a593Smuzhiyun }
1384*4882a593Smuzhiyun
1385*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL0_CTRL_M0, 0x0002);
1386*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL1_CTRL_M0, 0x0002);
1387*4882a593Smuzhiyun
1388*4882a593Smuzhiyun if (ssc) {
1389*4882a593Smuzhiyun cdns_torrent_phy_write(regmap,
1390*4882a593Smuzhiyun CMN_PLL0_VCOCAL_PLLCNT_START, 0x0315);
1391*4882a593Smuzhiyun cdns_torrent_phy_write(regmap,
1392*4882a593Smuzhiyun CMN_PLL0_LOCK_PLLCNT_THR, 0x0005);
1393*4882a593Smuzhiyun cdns_torrent_phy_write(regmap,
1394*4882a593Smuzhiyun CMN_PLL1_VCOCAL_PLLCNT_START, 0x0315);
1395*4882a593Smuzhiyun cdns_torrent_phy_write(regmap,
1396*4882a593Smuzhiyun CMN_PLL1_LOCK_PLLCNT_THR, 0x0005);
1397*4882a593Smuzhiyun } else {
1398*4882a593Smuzhiyun cdns_torrent_phy_write(regmap,
1399*4882a593Smuzhiyun CMN_PLL0_VCOCAL_PLLCNT_START, 0x0317);
1400*4882a593Smuzhiyun cdns_torrent_phy_write(regmap,
1401*4882a593Smuzhiyun CMN_PLL1_VCOCAL_PLLCNT_START, 0x0317);
1402*4882a593Smuzhiyun /* Set reset register values to disable SSC */
1403*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL0_SS_CTRL1_M0, 0x0002);
1404*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL0_SS_CTRL2_M0, 0x0000);
1405*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL0_SS_CTRL3_M0, 0x0000);
1406*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL0_SS_CTRL4_M0, 0x0000);
1407*4882a593Smuzhiyun cdns_torrent_phy_write(regmap,
1408*4882a593Smuzhiyun CMN_PLL0_LOCK_PLLCNT_THR, 0x0003);
1409*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL1_SS_CTRL1_M0, 0x0002);
1410*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL1_SS_CTRL2_M0, 0x0000);
1411*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL1_SS_CTRL3_M0, 0x0000);
1412*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL1_SS_CTRL4_M0, 0x0000);
1413*4882a593Smuzhiyun cdns_torrent_phy_write(regmap,
1414*4882a593Smuzhiyun CMN_PLL1_LOCK_PLLCNT_THR, 0x0003);
1415*4882a593Smuzhiyun }
1416*4882a593Smuzhiyun
1417*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL0_LOCK_REFCNT_START, 0x00C7);
1418*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL0_LOCK_PLLCNT_START, 0x00C7);
1419*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL1_LOCK_REFCNT_START, 0x00C7);
1420*4882a593Smuzhiyun cdns_torrent_phy_write(regmap, CMN_PLL1_LOCK_PLLCNT_START, 0x00C7);
1421*4882a593Smuzhiyun }
1422*4882a593Smuzhiyun
cdns_torrent_dp_pma_cmn_rate(struct cdns_torrent_phy * cdns_phy,u32 rate,u32 num_lanes)1423*4882a593Smuzhiyun static void cdns_torrent_dp_pma_cmn_rate(struct cdns_torrent_phy *cdns_phy,
1424*4882a593Smuzhiyun u32 rate, u32 num_lanes)
1425*4882a593Smuzhiyun {
1426*4882a593Smuzhiyun unsigned int clk_sel_val = 0;
1427*4882a593Smuzhiyun unsigned int hsclk_div_val = 0;
1428*4882a593Smuzhiyun unsigned int i;
1429*4882a593Smuzhiyun
1430*4882a593Smuzhiyun /* 16'h0000 for single DP link configuration */
1431*4882a593Smuzhiyun regmap_field_write(cdns_phy->phy_pll_cfg, 0x0);
1432*4882a593Smuzhiyun
1433*4882a593Smuzhiyun switch (rate) {
1434*4882a593Smuzhiyun case 1620:
1435*4882a593Smuzhiyun clk_sel_val = 0x0f01;
1436*4882a593Smuzhiyun hsclk_div_val = 2;
1437*4882a593Smuzhiyun break;
1438*4882a593Smuzhiyun case 2160:
1439*4882a593Smuzhiyun case 2430:
1440*4882a593Smuzhiyun case 2700:
1441*4882a593Smuzhiyun clk_sel_val = 0x0701;
1442*4882a593Smuzhiyun hsclk_div_val = 1;
1443*4882a593Smuzhiyun break;
1444*4882a593Smuzhiyun case 3240:
1445*4882a593Smuzhiyun clk_sel_val = 0x0b00;
1446*4882a593Smuzhiyun hsclk_div_val = 2;
1447*4882a593Smuzhiyun break;
1448*4882a593Smuzhiyun case 4320:
1449*4882a593Smuzhiyun case 5400:
1450*4882a593Smuzhiyun clk_sel_val = 0x0301;
1451*4882a593Smuzhiyun hsclk_div_val = 0;
1452*4882a593Smuzhiyun break;
1453*4882a593Smuzhiyun case 8100:
1454*4882a593Smuzhiyun clk_sel_val = 0x0200;
1455*4882a593Smuzhiyun hsclk_div_val = 0;
1456*4882a593Smuzhiyun break;
1457*4882a593Smuzhiyun }
1458*4882a593Smuzhiyun
1459*4882a593Smuzhiyun cdns_torrent_phy_write(cdns_phy->regmap_common_cdb,
1460*4882a593Smuzhiyun CMN_PDIAG_PLL0_CLK_SEL_M0, clk_sel_val);
1461*4882a593Smuzhiyun cdns_torrent_phy_write(cdns_phy->regmap_common_cdb,
1462*4882a593Smuzhiyun CMN_PDIAG_PLL1_CLK_SEL_M0, clk_sel_val);
1463*4882a593Smuzhiyun
1464*4882a593Smuzhiyun /* PMA lane configuration to deal with multi-link operation */
1465*4882a593Smuzhiyun for (i = 0; i < num_lanes; i++)
1466*4882a593Smuzhiyun cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[i],
1467*4882a593Smuzhiyun XCVR_DIAG_HSCLK_DIV, hsclk_div_val);
1468*4882a593Smuzhiyun }
1469*4882a593Smuzhiyun
cdns_torrent_dp_pma_lane_cfg(struct cdns_torrent_phy * cdns_phy,unsigned int lane)1470*4882a593Smuzhiyun static void cdns_torrent_dp_pma_lane_cfg(struct cdns_torrent_phy *cdns_phy,
1471*4882a593Smuzhiyun unsigned int lane)
1472*4882a593Smuzhiyun {
1473*4882a593Smuzhiyun /* Per lane, refclock-dependent receiver detection setting */
1474*4882a593Smuzhiyun if (cdns_phy->ref_clk_rate == REF_CLK_19_2MHz)
1475*4882a593Smuzhiyun cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[lane],
1476*4882a593Smuzhiyun TX_RCVDET_ST_TMR, 0x0780);
1477*4882a593Smuzhiyun else if (cdns_phy->ref_clk_rate == REF_CLK_25MHz)
1478*4882a593Smuzhiyun cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[lane],
1479*4882a593Smuzhiyun TX_RCVDET_ST_TMR, 0x09C4);
1480*4882a593Smuzhiyun
1481*4882a593Smuzhiyun /* Writing Tx/Rx Power State Controllers registers */
1482*4882a593Smuzhiyun cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[lane],
1483*4882a593Smuzhiyun TX_PSC_A0, 0x00FB);
1484*4882a593Smuzhiyun cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[lane],
1485*4882a593Smuzhiyun TX_PSC_A2, 0x04AA);
1486*4882a593Smuzhiyun cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[lane],
1487*4882a593Smuzhiyun TX_PSC_A3, 0x04AA);
1488*4882a593Smuzhiyun cdns_torrent_phy_write(cdns_phy->regmap_rx_lane_cdb[lane],
1489*4882a593Smuzhiyun RX_PSC_A0, 0x0000);
1490*4882a593Smuzhiyun cdns_torrent_phy_write(cdns_phy->regmap_rx_lane_cdb[lane],
1491*4882a593Smuzhiyun RX_PSC_A2, 0x0000);
1492*4882a593Smuzhiyun cdns_torrent_phy_write(cdns_phy->regmap_rx_lane_cdb[lane],
1493*4882a593Smuzhiyun RX_PSC_A3, 0x0000);
1494*4882a593Smuzhiyun
1495*4882a593Smuzhiyun cdns_torrent_phy_write(cdns_phy->regmap_rx_lane_cdb[lane],
1496*4882a593Smuzhiyun RX_PSC_CAL, 0x0000);
1497*4882a593Smuzhiyun
1498*4882a593Smuzhiyun cdns_torrent_phy_write(cdns_phy->regmap_rx_lane_cdb[lane],
1499*4882a593Smuzhiyun RX_REE_GCSM1_CTRL, 0x0000);
1500*4882a593Smuzhiyun cdns_torrent_phy_write(cdns_phy->regmap_rx_lane_cdb[lane],
1501*4882a593Smuzhiyun RX_REE_GCSM2_CTRL, 0x0000);
1502*4882a593Smuzhiyun cdns_torrent_phy_write(cdns_phy->regmap_rx_lane_cdb[lane],
1503*4882a593Smuzhiyun RX_REE_PERGCSM_CTRL, 0x0000);
1504*4882a593Smuzhiyun
1505*4882a593Smuzhiyun cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[lane],
1506*4882a593Smuzhiyun XCVR_DIAG_BIDI_CTRL, 0x000F);
1507*4882a593Smuzhiyun cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[lane],
1508*4882a593Smuzhiyun XCVR_DIAG_PLLDRC_CTRL, 0x0001);
1509*4882a593Smuzhiyun cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[lane],
1510*4882a593Smuzhiyun XCVR_DIAG_HSCLK_SEL, 0x0000);
1511*4882a593Smuzhiyun }
1512*4882a593Smuzhiyun
cdns_torrent_dp_set_power_state(struct cdns_torrent_phy * cdns_phy,u32 num_lanes,enum phy_powerstate powerstate)1513*4882a593Smuzhiyun static int cdns_torrent_dp_set_power_state(struct cdns_torrent_phy *cdns_phy,
1514*4882a593Smuzhiyun u32 num_lanes,
1515*4882a593Smuzhiyun enum phy_powerstate powerstate)
1516*4882a593Smuzhiyun {
1517*4882a593Smuzhiyun /* Register value for power state for a single byte. */
1518*4882a593Smuzhiyun u32 value_part;
1519*4882a593Smuzhiyun u32 value;
1520*4882a593Smuzhiyun u32 mask;
1521*4882a593Smuzhiyun u32 read_val;
1522*4882a593Smuzhiyun u32 ret;
1523*4882a593Smuzhiyun struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg;
1524*4882a593Smuzhiyun
1525*4882a593Smuzhiyun switch (powerstate) {
1526*4882a593Smuzhiyun case (POWERSTATE_A0):
1527*4882a593Smuzhiyun value_part = 0x01U;
1528*4882a593Smuzhiyun break;
1529*4882a593Smuzhiyun case (POWERSTATE_A2):
1530*4882a593Smuzhiyun value_part = 0x04U;
1531*4882a593Smuzhiyun break;
1532*4882a593Smuzhiyun default:
1533*4882a593Smuzhiyun /* Powerstate A3 */
1534*4882a593Smuzhiyun value_part = 0x08U;
1535*4882a593Smuzhiyun break;
1536*4882a593Smuzhiyun }
1537*4882a593Smuzhiyun
1538*4882a593Smuzhiyun /* Select values of registers and mask, depending on enabled
1539*4882a593Smuzhiyun * lane count.
1540*4882a593Smuzhiyun */
1541*4882a593Smuzhiyun switch (num_lanes) {
1542*4882a593Smuzhiyun /* lane 0 */
1543*4882a593Smuzhiyun case (1):
1544*4882a593Smuzhiyun value = value_part;
1545*4882a593Smuzhiyun mask = 0x0000003FU;
1546*4882a593Smuzhiyun break;
1547*4882a593Smuzhiyun /* lanes 0-1 */
1548*4882a593Smuzhiyun case (2):
1549*4882a593Smuzhiyun value = (value_part
1550*4882a593Smuzhiyun | (value_part << 8));
1551*4882a593Smuzhiyun mask = 0x00003F3FU;
1552*4882a593Smuzhiyun break;
1553*4882a593Smuzhiyun /* lanes 0-3, all */
1554*4882a593Smuzhiyun default:
1555*4882a593Smuzhiyun value = (value_part
1556*4882a593Smuzhiyun | (value_part << 8)
1557*4882a593Smuzhiyun | (value_part << 16)
1558*4882a593Smuzhiyun | (value_part << 24));
1559*4882a593Smuzhiyun mask = 0x3F3F3F3FU;
1560*4882a593Smuzhiyun break;
1561*4882a593Smuzhiyun }
1562*4882a593Smuzhiyun
1563*4882a593Smuzhiyun /* Set power state A<n>. */
1564*4882a593Smuzhiyun cdns_torrent_dp_write(regmap, PHY_PMA_XCVR_POWER_STATE_REQ, value);
1565*4882a593Smuzhiyun /* Wait, until PHY acknowledges power state completion. */
1566*4882a593Smuzhiyun ret = regmap_read_poll_timeout(regmap, PHY_PMA_XCVR_POWER_STATE_ACK,
1567*4882a593Smuzhiyun read_val, (read_val & mask) == value, 0,
1568*4882a593Smuzhiyun POLL_TIMEOUT_US);
1569*4882a593Smuzhiyun cdns_torrent_dp_write(regmap, PHY_PMA_XCVR_POWER_STATE_REQ, 0x00000000);
1570*4882a593Smuzhiyun ndelay(100);
1571*4882a593Smuzhiyun
1572*4882a593Smuzhiyun return ret;
1573*4882a593Smuzhiyun }
1574*4882a593Smuzhiyun
cdns_torrent_dp_run(struct cdns_torrent_phy * cdns_phy,u32 num_lanes)1575*4882a593Smuzhiyun static int cdns_torrent_dp_run(struct cdns_torrent_phy *cdns_phy, u32 num_lanes)
1576*4882a593Smuzhiyun {
1577*4882a593Smuzhiyun unsigned int read_val;
1578*4882a593Smuzhiyun int ret;
1579*4882a593Smuzhiyun struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg;
1580*4882a593Smuzhiyun
1581*4882a593Smuzhiyun /*
1582*4882a593Smuzhiyun * waiting for ACK of pma_xcvr_pllclk_en_ln_*, only for the
1583*4882a593Smuzhiyun * master lane
1584*4882a593Smuzhiyun */
1585*4882a593Smuzhiyun ret = regmap_read_poll_timeout(regmap, PHY_PMA_XCVR_PLLCLK_EN_ACK,
1586*4882a593Smuzhiyun read_val, read_val & 1,
1587*4882a593Smuzhiyun 0, POLL_TIMEOUT_US);
1588*4882a593Smuzhiyun if (ret == -ETIMEDOUT) {
1589*4882a593Smuzhiyun dev_err(cdns_phy->dev,
1590*4882a593Smuzhiyun "timeout waiting for link PLL clock enable ack\n");
1591*4882a593Smuzhiyun return ret;
1592*4882a593Smuzhiyun }
1593*4882a593Smuzhiyun
1594*4882a593Smuzhiyun ndelay(100);
1595*4882a593Smuzhiyun
1596*4882a593Smuzhiyun ret = cdns_torrent_dp_set_power_state(cdns_phy, num_lanes,
1597*4882a593Smuzhiyun POWERSTATE_A2);
1598*4882a593Smuzhiyun if (ret)
1599*4882a593Smuzhiyun return ret;
1600*4882a593Smuzhiyun
1601*4882a593Smuzhiyun ret = cdns_torrent_dp_set_power_state(cdns_phy, num_lanes,
1602*4882a593Smuzhiyun POWERSTATE_A0);
1603*4882a593Smuzhiyun
1604*4882a593Smuzhiyun return ret;
1605*4882a593Smuzhiyun }
1606*4882a593Smuzhiyun
cdns_torrent_phy_on(struct phy * phy)1607*4882a593Smuzhiyun static int cdns_torrent_phy_on(struct phy *phy)
1608*4882a593Smuzhiyun {
1609*4882a593Smuzhiyun struct cdns_torrent_inst *inst = phy_get_drvdata(phy);
1610*4882a593Smuzhiyun struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(phy->dev.parent);
1611*4882a593Smuzhiyun u32 read_val;
1612*4882a593Smuzhiyun int ret;
1613*4882a593Smuzhiyun
1614*4882a593Smuzhiyun if (cdns_phy->nsubnodes == 1) {
1615*4882a593Smuzhiyun /* Take the PHY lane group out of reset */
1616*4882a593Smuzhiyun reset_control_deassert(inst->lnk_rst);
1617*4882a593Smuzhiyun
1618*4882a593Smuzhiyun /* Take the PHY out of reset */
1619*4882a593Smuzhiyun ret = reset_control_deassert(cdns_phy->phy_rst);
1620*4882a593Smuzhiyun if (ret)
1621*4882a593Smuzhiyun return ret;
1622*4882a593Smuzhiyun }
1623*4882a593Smuzhiyun
1624*4882a593Smuzhiyun /*
1625*4882a593Smuzhiyun * Wait for cmn_ready assertion
1626*4882a593Smuzhiyun * PHY_PMA_CMN_CTRL1[0] == 1
1627*4882a593Smuzhiyun */
1628*4882a593Smuzhiyun ret = regmap_field_read_poll_timeout(cdns_phy->phy_pma_cmn_ctrl_1,
1629*4882a593Smuzhiyun read_val, read_val, 1000,
1630*4882a593Smuzhiyun PLL_LOCK_TIMEOUT);
1631*4882a593Smuzhiyun if (ret) {
1632*4882a593Smuzhiyun dev_err(cdns_phy->dev, "Timeout waiting for CMN ready\n");
1633*4882a593Smuzhiyun return ret;
1634*4882a593Smuzhiyun }
1635*4882a593Smuzhiyun
1636*4882a593Smuzhiyun mdelay(10);
1637*4882a593Smuzhiyun
1638*4882a593Smuzhiyun return 0;
1639*4882a593Smuzhiyun }
1640*4882a593Smuzhiyun
cdns_torrent_phy_off(struct phy * phy)1641*4882a593Smuzhiyun static int cdns_torrent_phy_off(struct phy *phy)
1642*4882a593Smuzhiyun {
1643*4882a593Smuzhiyun struct cdns_torrent_inst *inst = phy_get_drvdata(phy);
1644*4882a593Smuzhiyun struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(phy->dev.parent);
1645*4882a593Smuzhiyun int ret;
1646*4882a593Smuzhiyun
1647*4882a593Smuzhiyun if (cdns_phy->nsubnodes != 1)
1648*4882a593Smuzhiyun return 0;
1649*4882a593Smuzhiyun
1650*4882a593Smuzhiyun ret = reset_control_assert(cdns_phy->phy_rst);
1651*4882a593Smuzhiyun if (ret)
1652*4882a593Smuzhiyun return ret;
1653*4882a593Smuzhiyun
1654*4882a593Smuzhiyun return reset_control_assert(inst->lnk_rst);
1655*4882a593Smuzhiyun }
1656*4882a593Smuzhiyun
cdns_regmap_init(struct device * dev,void __iomem * base,u32 block_offset,u8 reg_offset_shift,const struct regmap_config * config)1657*4882a593Smuzhiyun static struct regmap *cdns_regmap_init(struct device *dev, void __iomem *base,
1658*4882a593Smuzhiyun u32 block_offset,
1659*4882a593Smuzhiyun u8 reg_offset_shift,
1660*4882a593Smuzhiyun const struct regmap_config *config)
1661*4882a593Smuzhiyun {
1662*4882a593Smuzhiyun struct cdns_regmap_cdb_context *ctx;
1663*4882a593Smuzhiyun
1664*4882a593Smuzhiyun ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
1665*4882a593Smuzhiyun if (!ctx)
1666*4882a593Smuzhiyun return ERR_PTR(-ENOMEM);
1667*4882a593Smuzhiyun
1668*4882a593Smuzhiyun ctx->dev = dev;
1669*4882a593Smuzhiyun ctx->base = base + block_offset;
1670*4882a593Smuzhiyun ctx->reg_offset_shift = reg_offset_shift;
1671*4882a593Smuzhiyun
1672*4882a593Smuzhiyun return devm_regmap_init(dev, NULL, ctx, config);
1673*4882a593Smuzhiyun }
1674*4882a593Smuzhiyun
cdns_torrent_dp_regfield_init(struct cdns_torrent_phy * cdns_phy)1675*4882a593Smuzhiyun static int cdns_torrent_dp_regfield_init(struct cdns_torrent_phy *cdns_phy)
1676*4882a593Smuzhiyun {
1677*4882a593Smuzhiyun struct device *dev = cdns_phy->dev;
1678*4882a593Smuzhiyun struct regmap_field *field;
1679*4882a593Smuzhiyun struct regmap *regmap;
1680*4882a593Smuzhiyun
1681*4882a593Smuzhiyun regmap = cdns_phy->regmap_dptx_phy_reg;
1682*4882a593Smuzhiyun field = devm_regmap_field_alloc(dev, regmap, phy_reset_ctrl);
1683*4882a593Smuzhiyun if (IS_ERR(field)) {
1684*4882a593Smuzhiyun dev_err(dev, "PHY_RESET reg field init failed\n");
1685*4882a593Smuzhiyun return PTR_ERR(field);
1686*4882a593Smuzhiyun }
1687*4882a593Smuzhiyun cdns_phy->phy_reset_ctrl = field;
1688*4882a593Smuzhiyun
1689*4882a593Smuzhiyun return 0;
1690*4882a593Smuzhiyun }
1691*4882a593Smuzhiyun
cdns_torrent_regfield_init(struct cdns_torrent_phy * cdns_phy)1692*4882a593Smuzhiyun static int cdns_torrent_regfield_init(struct cdns_torrent_phy *cdns_phy)
1693*4882a593Smuzhiyun {
1694*4882a593Smuzhiyun struct device *dev = cdns_phy->dev;
1695*4882a593Smuzhiyun struct regmap_field *field;
1696*4882a593Smuzhiyun struct regmap *regmap;
1697*4882a593Smuzhiyun
1698*4882a593Smuzhiyun regmap = cdns_phy->regmap_phy_pcs_common_cdb;
1699*4882a593Smuzhiyun field = devm_regmap_field_alloc(dev, regmap, phy_pll_cfg);
1700*4882a593Smuzhiyun if (IS_ERR(field)) {
1701*4882a593Smuzhiyun dev_err(dev, "PHY_PLL_CFG reg field init failed\n");
1702*4882a593Smuzhiyun return PTR_ERR(field);
1703*4882a593Smuzhiyun }
1704*4882a593Smuzhiyun cdns_phy->phy_pll_cfg = field;
1705*4882a593Smuzhiyun
1706*4882a593Smuzhiyun regmap = cdns_phy->regmap_phy_pma_common_cdb;
1707*4882a593Smuzhiyun field = devm_regmap_field_alloc(dev, regmap, phy_pma_cmn_ctrl_1);
1708*4882a593Smuzhiyun if (IS_ERR(field)) {
1709*4882a593Smuzhiyun dev_err(dev, "PHY_PMA_CMN_CTRL1 reg field init failed\n");
1710*4882a593Smuzhiyun return PTR_ERR(field);
1711*4882a593Smuzhiyun }
1712*4882a593Smuzhiyun cdns_phy->phy_pma_cmn_ctrl_1 = field;
1713*4882a593Smuzhiyun
1714*4882a593Smuzhiyun regmap = cdns_phy->regmap_phy_pma_common_cdb;
1715*4882a593Smuzhiyun field = devm_regmap_field_alloc(dev, regmap, phy_pma_cmn_ctrl_2);
1716*4882a593Smuzhiyun if (IS_ERR(field)) {
1717*4882a593Smuzhiyun dev_err(dev, "PHY_PMA_CMN_CTRL2 reg field init failed\n");
1718*4882a593Smuzhiyun return PTR_ERR(field);
1719*4882a593Smuzhiyun }
1720*4882a593Smuzhiyun cdns_phy->phy_pma_cmn_ctrl_2 = field;
1721*4882a593Smuzhiyun
1722*4882a593Smuzhiyun regmap = cdns_phy->regmap_phy_pma_common_cdb;
1723*4882a593Smuzhiyun field = devm_regmap_field_alloc(dev, regmap, phy_pma_pll_raw_ctrl);
1724*4882a593Smuzhiyun if (IS_ERR(field)) {
1725*4882a593Smuzhiyun dev_err(dev, "PHY_PMA_PLL_RAW_CTRL reg field init failed\n");
1726*4882a593Smuzhiyun return PTR_ERR(field);
1727*4882a593Smuzhiyun }
1728*4882a593Smuzhiyun cdns_phy->phy_pma_pll_raw_ctrl = field;
1729*4882a593Smuzhiyun
1730*4882a593Smuzhiyun return 0;
1731*4882a593Smuzhiyun }
1732*4882a593Smuzhiyun
cdns_torrent_dp_regmap_init(struct cdns_torrent_phy * cdns_phy)1733*4882a593Smuzhiyun static int cdns_torrent_dp_regmap_init(struct cdns_torrent_phy *cdns_phy)
1734*4882a593Smuzhiyun {
1735*4882a593Smuzhiyun void __iomem *base = cdns_phy->base;
1736*4882a593Smuzhiyun struct device *dev = cdns_phy->dev;
1737*4882a593Smuzhiyun struct regmap *regmap;
1738*4882a593Smuzhiyun u8 reg_offset_shift;
1739*4882a593Smuzhiyun u32 block_offset;
1740*4882a593Smuzhiyun
1741*4882a593Smuzhiyun reg_offset_shift = cdns_phy->init_data->reg_offset_shift;
1742*4882a593Smuzhiyun
1743*4882a593Smuzhiyun block_offset = TORRENT_DPTX_PHY_OFFSET;
1744*4882a593Smuzhiyun regmap = cdns_regmap_init(dev, base, block_offset,
1745*4882a593Smuzhiyun reg_offset_shift,
1746*4882a593Smuzhiyun &cdns_torrent_dptx_phy_config);
1747*4882a593Smuzhiyun if (IS_ERR(regmap)) {
1748*4882a593Smuzhiyun dev_err(dev, "Failed to init DPTX PHY regmap\n");
1749*4882a593Smuzhiyun return PTR_ERR(regmap);
1750*4882a593Smuzhiyun }
1751*4882a593Smuzhiyun cdns_phy->regmap_dptx_phy_reg = regmap;
1752*4882a593Smuzhiyun
1753*4882a593Smuzhiyun return 0;
1754*4882a593Smuzhiyun }
1755*4882a593Smuzhiyun
cdns_torrent_regmap_init(struct cdns_torrent_phy * cdns_phy)1756*4882a593Smuzhiyun static int cdns_torrent_regmap_init(struct cdns_torrent_phy *cdns_phy)
1757*4882a593Smuzhiyun {
1758*4882a593Smuzhiyun void __iomem *sd_base = cdns_phy->sd_base;
1759*4882a593Smuzhiyun u8 block_offset_shift, reg_offset_shift;
1760*4882a593Smuzhiyun struct device *dev = cdns_phy->dev;
1761*4882a593Smuzhiyun struct regmap *regmap;
1762*4882a593Smuzhiyun u32 block_offset;
1763*4882a593Smuzhiyun int i;
1764*4882a593Smuzhiyun
1765*4882a593Smuzhiyun block_offset_shift = cdns_phy->init_data->block_offset_shift;
1766*4882a593Smuzhiyun reg_offset_shift = cdns_phy->init_data->reg_offset_shift;
1767*4882a593Smuzhiyun
1768*4882a593Smuzhiyun for (i = 0; i < MAX_NUM_LANES; i++) {
1769*4882a593Smuzhiyun block_offset = TORRENT_TX_LANE_CDB_OFFSET(i, block_offset_shift,
1770*4882a593Smuzhiyun reg_offset_shift);
1771*4882a593Smuzhiyun regmap = cdns_regmap_init(dev, sd_base, block_offset,
1772*4882a593Smuzhiyun reg_offset_shift,
1773*4882a593Smuzhiyun &cdns_torrent_tx_lane_cdb_config[i]);
1774*4882a593Smuzhiyun if (IS_ERR(regmap)) {
1775*4882a593Smuzhiyun dev_err(dev, "Failed to init tx lane CDB regmap\n");
1776*4882a593Smuzhiyun return PTR_ERR(regmap);
1777*4882a593Smuzhiyun }
1778*4882a593Smuzhiyun cdns_phy->regmap_tx_lane_cdb[i] = regmap;
1779*4882a593Smuzhiyun
1780*4882a593Smuzhiyun block_offset = TORRENT_RX_LANE_CDB_OFFSET(i, block_offset_shift,
1781*4882a593Smuzhiyun reg_offset_shift);
1782*4882a593Smuzhiyun regmap = cdns_regmap_init(dev, sd_base, block_offset,
1783*4882a593Smuzhiyun reg_offset_shift,
1784*4882a593Smuzhiyun &cdns_torrent_rx_lane_cdb_config[i]);
1785*4882a593Smuzhiyun if (IS_ERR(regmap)) {
1786*4882a593Smuzhiyun dev_err(dev, "Failed to init rx lane CDB regmap\n");
1787*4882a593Smuzhiyun return PTR_ERR(regmap);
1788*4882a593Smuzhiyun }
1789*4882a593Smuzhiyun cdns_phy->regmap_rx_lane_cdb[i] = regmap;
1790*4882a593Smuzhiyun }
1791*4882a593Smuzhiyun
1792*4882a593Smuzhiyun block_offset = TORRENT_COMMON_CDB_OFFSET;
1793*4882a593Smuzhiyun regmap = cdns_regmap_init(dev, sd_base, block_offset,
1794*4882a593Smuzhiyun reg_offset_shift,
1795*4882a593Smuzhiyun &cdns_torrent_common_cdb_config);
1796*4882a593Smuzhiyun if (IS_ERR(regmap)) {
1797*4882a593Smuzhiyun dev_err(dev, "Failed to init common CDB regmap\n");
1798*4882a593Smuzhiyun return PTR_ERR(regmap);
1799*4882a593Smuzhiyun }
1800*4882a593Smuzhiyun cdns_phy->regmap_common_cdb = regmap;
1801*4882a593Smuzhiyun
1802*4882a593Smuzhiyun block_offset = TORRENT_PHY_PCS_COMMON_OFFSET(block_offset_shift);
1803*4882a593Smuzhiyun regmap = cdns_regmap_init(dev, sd_base, block_offset,
1804*4882a593Smuzhiyun reg_offset_shift,
1805*4882a593Smuzhiyun &cdns_torrent_phy_pcs_cmn_cdb_config);
1806*4882a593Smuzhiyun if (IS_ERR(regmap)) {
1807*4882a593Smuzhiyun dev_err(dev, "Failed to init PHY PCS common CDB regmap\n");
1808*4882a593Smuzhiyun return PTR_ERR(regmap);
1809*4882a593Smuzhiyun }
1810*4882a593Smuzhiyun cdns_phy->regmap_phy_pcs_common_cdb = regmap;
1811*4882a593Smuzhiyun
1812*4882a593Smuzhiyun block_offset = TORRENT_PHY_PMA_COMMON_OFFSET(block_offset_shift);
1813*4882a593Smuzhiyun regmap = cdns_regmap_init(dev, sd_base, block_offset,
1814*4882a593Smuzhiyun reg_offset_shift,
1815*4882a593Smuzhiyun &cdns_torrent_phy_pma_cmn_cdb_config);
1816*4882a593Smuzhiyun if (IS_ERR(regmap)) {
1817*4882a593Smuzhiyun dev_err(dev, "Failed to init PHY PMA common CDB regmap\n");
1818*4882a593Smuzhiyun return PTR_ERR(regmap);
1819*4882a593Smuzhiyun }
1820*4882a593Smuzhiyun cdns_phy->regmap_phy_pma_common_cdb = regmap;
1821*4882a593Smuzhiyun
1822*4882a593Smuzhiyun return 0;
1823*4882a593Smuzhiyun }
1824*4882a593Smuzhiyun
cdns_torrent_phy_init(struct phy * phy)1825*4882a593Smuzhiyun static int cdns_torrent_phy_init(struct phy *phy)
1826*4882a593Smuzhiyun {
1827*4882a593Smuzhiyun struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(phy->dev.parent);
1828*4882a593Smuzhiyun const struct cdns_torrent_data *init_data = cdns_phy->init_data;
1829*4882a593Smuzhiyun struct cdns_torrent_vals *cmn_vals, *tx_ln_vals, *rx_ln_vals;
1830*4882a593Smuzhiyun struct cdns_torrent_vals *link_cmn_vals, *xcvr_diag_vals;
1831*4882a593Smuzhiyun struct cdns_torrent_inst *inst = phy_get_drvdata(phy);
1832*4882a593Smuzhiyun enum cdns_torrent_phy_type phy_type = inst->phy_type;
1833*4882a593Smuzhiyun enum cdns_torrent_ssc_mode ssc = inst->ssc_mode;
1834*4882a593Smuzhiyun struct cdns_torrent_vals *pcs_cmn_vals;
1835*4882a593Smuzhiyun struct cdns_reg_pairs *reg_pairs;
1836*4882a593Smuzhiyun struct regmap *regmap;
1837*4882a593Smuzhiyun u32 num_regs;
1838*4882a593Smuzhiyun int i, j;
1839*4882a593Smuzhiyun
1840*4882a593Smuzhiyun if (cdns_phy->nsubnodes > 1)
1841*4882a593Smuzhiyun return 0;
1842*4882a593Smuzhiyun
1843*4882a593Smuzhiyun if (phy_type == TYPE_DP)
1844*4882a593Smuzhiyun return cdns_torrent_dp_init(phy);
1845*4882a593Smuzhiyun
1846*4882a593Smuzhiyun /**
1847*4882a593Smuzhiyun * Spread spectrum generation is not required or supported
1848*4882a593Smuzhiyun * for SGMII/QSGMII
1849*4882a593Smuzhiyun */
1850*4882a593Smuzhiyun if (phy_type == TYPE_SGMII || phy_type == TYPE_QSGMII)
1851*4882a593Smuzhiyun ssc = NO_SSC;
1852*4882a593Smuzhiyun
1853*4882a593Smuzhiyun /* PHY configuration specific registers for single link */
1854*4882a593Smuzhiyun link_cmn_vals = init_data->link_cmn_vals[phy_type][TYPE_NONE][ssc];
1855*4882a593Smuzhiyun if (link_cmn_vals) {
1856*4882a593Smuzhiyun reg_pairs = link_cmn_vals->reg_pairs;
1857*4882a593Smuzhiyun num_regs = link_cmn_vals->num_regs;
1858*4882a593Smuzhiyun regmap = cdns_phy->regmap_common_cdb;
1859*4882a593Smuzhiyun
1860*4882a593Smuzhiyun /**
1861*4882a593Smuzhiyun * First array value in link_cmn_vals must be of
1862*4882a593Smuzhiyun * PHY_PLL_CFG register
1863*4882a593Smuzhiyun */
1864*4882a593Smuzhiyun regmap_field_write(cdns_phy->phy_pll_cfg, reg_pairs[0].val);
1865*4882a593Smuzhiyun
1866*4882a593Smuzhiyun for (i = 1; i < num_regs; i++)
1867*4882a593Smuzhiyun regmap_write(regmap, reg_pairs[i].off,
1868*4882a593Smuzhiyun reg_pairs[i].val);
1869*4882a593Smuzhiyun }
1870*4882a593Smuzhiyun
1871*4882a593Smuzhiyun xcvr_diag_vals = init_data->xcvr_diag_vals[phy_type][TYPE_NONE][ssc];
1872*4882a593Smuzhiyun if (xcvr_diag_vals) {
1873*4882a593Smuzhiyun reg_pairs = xcvr_diag_vals->reg_pairs;
1874*4882a593Smuzhiyun num_regs = xcvr_diag_vals->num_regs;
1875*4882a593Smuzhiyun for (i = 0; i < inst->num_lanes; i++) {
1876*4882a593Smuzhiyun regmap = cdns_phy->regmap_tx_lane_cdb[i + inst->mlane];
1877*4882a593Smuzhiyun for (j = 0; j < num_regs; j++)
1878*4882a593Smuzhiyun regmap_write(regmap, reg_pairs[j].off,
1879*4882a593Smuzhiyun reg_pairs[j].val);
1880*4882a593Smuzhiyun }
1881*4882a593Smuzhiyun }
1882*4882a593Smuzhiyun
1883*4882a593Smuzhiyun /* PHY PCS common registers configurations */
1884*4882a593Smuzhiyun pcs_cmn_vals = init_data->pcs_cmn_vals[phy_type][TYPE_NONE][ssc];
1885*4882a593Smuzhiyun if (pcs_cmn_vals) {
1886*4882a593Smuzhiyun reg_pairs = pcs_cmn_vals->reg_pairs;
1887*4882a593Smuzhiyun num_regs = pcs_cmn_vals->num_regs;
1888*4882a593Smuzhiyun regmap = cdns_phy->regmap_phy_pcs_common_cdb;
1889*4882a593Smuzhiyun for (i = 0; i < num_regs; i++)
1890*4882a593Smuzhiyun regmap_write(regmap, reg_pairs[i].off,
1891*4882a593Smuzhiyun reg_pairs[i].val);
1892*4882a593Smuzhiyun }
1893*4882a593Smuzhiyun
1894*4882a593Smuzhiyun /* PMA common registers configurations */
1895*4882a593Smuzhiyun cmn_vals = init_data->cmn_vals[phy_type][TYPE_NONE][ssc];
1896*4882a593Smuzhiyun if (cmn_vals) {
1897*4882a593Smuzhiyun reg_pairs = cmn_vals->reg_pairs;
1898*4882a593Smuzhiyun num_regs = cmn_vals->num_regs;
1899*4882a593Smuzhiyun regmap = cdns_phy->regmap_common_cdb;
1900*4882a593Smuzhiyun for (i = 0; i < num_regs; i++)
1901*4882a593Smuzhiyun regmap_write(regmap, reg_pairs[i].off,
1902*4882a593Smuzhiyun reg_pairs[i].val);
1903*4882a593Smuzhiyun }
1904*4882a593Smuzhiyun
1905*4882a593Smuzhiyun /* PMA TX lane registers configurations */
1906*4882a593Smuzhiyun tx_ln_vals = init_data->tx_ln_vals[phy_type][TYPE_NONE][ssc];
1907*4882a593Smuzhiyun if (tx_ln_vals) {
1908*4882a593Smuzhiyun reg_pairs = tx_ln_vals->reg_pairs;
1909*4882a593Smuzhiyun num_regs = tx_ln_vals->num_regs;
1910*4882a593Smuzhiyun for (i = 0; i < inst->num_lanes; i++) {
1911*4882a593Smuzhiyun regmap = cdns_phy->regmap_tx_lane_cdb[i + inst->mlane];
1912*4882a593Smuzhiyun for (j = 0; j < num_regs; j++)
1913*4882a593Smuzhiyun regmap_write(regmap, reg_pairs[j].off,
1914*4882a593Smuzhiyun reg_pairs[j].val);
1915*4882a593Smuzhiyun }
1916*4882a593Smuzhiyun }
1917*4882a593Smuzhiyun
1918*4882a593Smuzhiyun /* PMA RX lane registers configurations */
1919*4882a593Smuzhiyun rx_ln_vals = init_data->rx_ln_vals[phy_type][TYPE_NONE][ssc];
1920*4882a593Smuzhiyun if (rx_ln_vals) {
1921*4882a593Smuzhiyun reg_pairs = rx_ln_vals->reg_pairs;
1922*4882a593Smuzhiyun num_regs = rx_ln_vals->num_regs;
1923*4882a593Smuzhiyun for (i = 0; i < inst->num_lanes; i++) {
1924*4882a593Smuzhiyun regmap = cdns_phy->regmap_rx_lane_cdb[i + inst->mlane];
1925*4882a593Smuzhiyun for (j = 0; j < num_regs; j++)
1926*4882a593Smuzhiyun regmap_write(regmap, reg_pairs[j].off,
1927*4882a593Smuzhiyun reg_pairs[j].val);
1928*4882a593Smuzhiyun }
1929*4882a593Smuzhiyun }
1930*4882a593Smuzhiyun
1931*4882a593Smuzhiyun return 0;
1932*4882a593Smuzhiyun }
1933*4882a593Smuzhiyun
1934*4882a593Smuzhiyun static
cdns_torrent_phy_configure_multilink(struct cdns_torrent_phy * cdns_phy)1935*4882a593Smuzhiyun int cdns_torrent_phy_configure_multilink(struct cdns_torrent_phy *cdns_phy)
1936*4882a593Smuzhiyun {
1937*4882a593Smuzhiyun const struct cdns_torrent_data *init_data = cdns_phy->init_data;
1938*4882a593Smuzhiyun struct cdns_torrent_vals *cmn_vals, *tx_ln_vals, *rx_ln_vals;
1939*4882a593Smuzhiyun struct cdns_torrent_vals *link_cmn_vals, *xcvr_diag_vals;
1940*4882a593Smuzhiyun enum cdns_torrent_phy_type phy_t1, phy_t2, tmp_phy_type;
1941*4882a593Smuzhiyun struct cdns_torrent_vals *pcs_cmn_vals;
1942*4882a593Smuzhiyun int i, j, node, mlane, num_lanes, ret;
1943*4882a593Smuzhiyun struct cdns_reg_pairs *reg_pairs;
1944*4882a593Smuzhiyun enum cdns_torrent_ssc_mode ssc;
1945*4882a593Smuzhiyun struct regmap *regmap;
1946*4882a593Smuzhiyun u32 num_regs;
1947*4882a593Smuzhiyun
1948*4882a593Smuzhiyun /* Maximum 2 links (subnodes) are supported */
1949*4882a593Smuzhiyun if (cdns_phy->nsubnodes != 2)
1950*4882a593Smuzhiyun return -EINVAL;
1951*4882a593Smuzhiyun
1952*4882a593Smuzhiyun phy_t1 = cdns_phy->phys[0].phy_type;
1953*4882a593Smuzhiyun phy_t2 = cdns_phy->phys[1].phy_type;
1954*4882a593Smuzhiyun
1955*4882a593Smuzhiyun /**
1956*4882a593Smuzhiyun * First configure the PHY for first link with phy_t1. Get the array
1957*4882a593Smuzhiyun * values as [phy_t1][phy_t2][ssc].
1958*4882a593Smuzhiyun */
1959*4882a593Smuzhiyun for (node = 0; node < cdns_phy->nsubnodes; node++) {
1960*4882a593Smuzhiyun if (node == 1) {
1961*4882a593Smuzhiyun /**
1962*4882a593Smuzhiyun * If first link with phy_t1 is configured, then
1963*4882a593Smuzhiyun * configure the PHY for second link with phy_t2.
1964*4882a593Smuzhiyun * Get the array values as [phy_t2][phy_t1][ssc].
1965*4882a593Smuzhiyun */
1966*4882a593Smuzhiyun tmp_phy_type = phy_t1;
1967*4882a593Smuzhiyun phy_t1 = phy_t2;
1968*4882a593Smuzhiyun phy_t2 = tmp_phy_type;
1969*4882a593Smuzhiyun }
1970*4882a593Smuzhiyun
1971*4882a593Smuzhiyun mlane = cdns_phy->phys[node].mlane;
1972*4882a593Smuzhiyun ssc = cdns_phy->phys[node].ssc_mode;
1973*4882a593Smuzhiyun num_lanes = cdns_phy->phys[node].num_lanes;
1974*4882a593Smuzhiyun
1975*4882a593Smuzhiyun /**
1976*4882a593Smuzhiyun * PHY configuration specific registers:
1977*4882a593Smuzhiyun * link_cmn_vals depend on combination of PHY types being
1978*4882a593Smuzhiyun * configured and are common for both PHY types, so array
1979*4882a593Smuzhiyun * values should be same for [phy_t1][phy_t2][ssc] and
1980*4882a593Smuzhiyun * [phy_t2][phy_t1][ssc].
1981*4882a593Smuzhiyun * xcvr_diag_vals also depend on combination of PHY types
1982*4882a593Smuzhiyun * being configured, but these can be different for particular
1983*4882a593Smuzhiyun * PHY type and are per lane.
1984*4882a593Smuzhiyun */
1985*4882a593Smuzhiyun link_cmn_vals = init_data->link_cmn_vals[phy_t1][phy_t2][ssc];
1986*4882a593Smuzhiyun if (link_cmn_vals) {
1987*4882a593Smuzhiyun reg_pairs = link_cmn_vals->reg_pairs;
1988*4882a593Smuzhiyun num_regs = link_cmn_vals->num_regs;
1989*4882a593Smuzhiyun regmap = cdns_phy->regmap_common_cdb;
1990*4882a593Smuzhiyun
1991*4882a593Smuzhiyun /**
1992*4882a593Smuzhiyun * First array value in link_cmn_vals must be of
1993*4882a593Smuzhiyun * PHY_PLL_CFG register
1994*4882a593Smuzhiyun */
1995*4882a593Smuzhiyun regmap_field_write(cdns_phy->phy_pll_cfg,
1996*4882a593Smuzhiyun reg_pairs[0].val);
1997*4882a593Smuzhiyun
1998*4882a593Smuzhiyun for (i = 1; i < num_regs; i++)
1999*4882a593Smuzhiyun regmap_write(regmap, reg_pairs[i].off,
2000*4882a593Smuzhiyun reg_pairs[i].val);
2001*4882a593Smuzhiyun }
2002*4882a593Smuzhiyun
2003*4882a593Smuzhiyun xcvr_diag_vals = init_data->xcvr_diag_vals[phy_t1][phy_t2][ssc];
2004*4882a593Smuzhiyun if (xcvr_diag_vals) {
2005*4882a593Smuzhiyun reg_pairs = xcvr_diag_vals->reg_pairs;
2006*4882a593Smuzhiyun num_regs = xcvr_diag_vals->num_regs;
2007*4882a593Smuzhiyun for (i = 0; i < num_lanes; i++) {
2008*4882a593Smuzhiyun regmap = cdns_phy->regmap_tx_lane_cdb[i + mlane];
2009*4882a593Smuzhiyun for (j = 0; j < num_regs; j++)
2010*4882a593Smuzhiyun regmap_write(regmap, reg_pairs[j].off,
2011*4882a593Smuzhiyun reg_pairs[j].val);
2012*4882a593Smuzhiyun }
2013*4882a593Smuzhiyun }
2014*4882a593Smuzhiyun
2015*4882a593Smuzhiyun /* PHY PCS common registers configurations */
2016*4882a593Smuzhiyun pcs_cmn_vals = init_data->pcs_cmn_vals[phy_t1][phy_t2][ssc];
2017*4882a593Smuzhiyun if (pcs_cmn_vals) {
2018*4882a593Smuzhiyun reg_pairs = pcs_cmn_vals->reg_pairs;
2019*4882a593Smuzhiyun num_regs = pcs_cmn_vals->num_regs;
2020*4882a593Smuzhiyun regmap = cdns_phy->regmap_phy_pcs_common_cdb;
2021*4882a593Smuzhiyun for (i = 0; i < num_regs; i++)
2022*4882a593Smuzhiyun regmap_write(regmap, reg_pairs[i].off,
2023*4882a593Smuzhiyun reg_pairs[i].val);
2024*4882a593Smuzhiyun }
2025*4882a593Smuzhiyun
2026*4882a593Smuzhiyun /* PMA common registers configurations */
2027*4882a593Smuzhiyun cmn_vals = init_data->cmn_vals[phy_t1][phy_t2][ssc];
2028*4882a593Smuzhiyun if (cmn_vals) {
2029*4882a593Smuzhiyun reg_pairs = cmn_vals->reg_pairs;
2030*4882a593Smuzhiyun num_regs = cmn_vals->num_regs;
2031*4882a593Smuzhiyun regmap = cdns_phy->regmap_common_cdb;
2032*4882a593Smuzhiyun for (i = 0; i < num_regs; i++)
2033*4882a593Smuzhiyun regmap_write(regmap, reg_pairs[i].off,
2034*4882a593Smuzhiyun reg_pairs[i].val);
2035*4882a593Smuzhiyun }
2036*4882a593Smuzhiyun
2037*4882a593Smuzhiyun /* PMA TX lane registers configurations */
2038*4882a593Smuzhiyun tx_ln_vals = init_data->tx_ln_vals[phy_t1][phy_t2][ssc];
2039*4882a593Smuzhiyun if (tx_ln_vals) {
2040*4882a593Smuzhiyun reg_pairs = tx_ln_vals->reg_pairs;
2041*4882a593Smuzhiyun num_regs = tx_ln_vals->num_regs;
2042*4882a593Smuzhiyun for (i = 0; i < num_lanes; i++) {
2043*4882a593Smuzhiyun regmap = cdns_phy->regmap_tx_lane_cdb[i + mlane];
2044*4882a593Smuzhiyun for (j = 0; j < num_regs; j++)
2045*4882a593Smuzhiyun regmap_write(regmap, reg_pairs[j].off,
2046*4882a593Smuzhiyun reg_pairs[j].val);
2047*4882a593Smuzhiyun }
2048*4882a593Smuzhiyun }
2049*4882a593Smuzhiyun
2050*4882a593Smuzhiyun /* PMA RX lane registers configurations */
2051*4882a593Smuzhiyun rx_ln_vals = init_data->rx_ln_vals[phy_t1][phy_t2][ssc];
2052*4882a593Smuzhiyun if (rx_ln_vals) {
2053*4882a593Smuzhiyun reg_pairs = rx_ln_vals->reg_pairs;
2054*4882a593Smuzhiyun num_regs = rx_ln_vals->num_regs;
2055*4882a593Smuzhiyun for (i = 0; i < num_lanes; i++) {
2056*4882a593Smuzhiyun regmap = cdns_phy->regmap_rx_lane_cdb[i + mlane];
2057*4882a593Smuzhiyun for (j = 0; j < num_regs; j++)
2058*4882a593Smuzhiyun regmap_write(regmap, reg_pairs[j].off,
2059*4882a593Smuzhiyun reg_pairs[j].val);
2060*4882a593Smuzhiyun }
2061*4882a593Smuzhiyun }
2062*4882a593Smuzhiyun
2063*4882a593Smuzhiyun reset_control_deassert(cdns_phy->phys[node].lnk_rst);
2064*4882a593Smuzhiyun }
2065*4882a593Smuzhiyun
2066*4882a593Smuzhiyun /* Take the PHY out of reset */
2067*4882a593Smuzhiyun ret = reset_control_deassert(cdns_phy->phy_rst);
2068*4882a593Smuzhiyun if (ret)
2069*4882a593Smuzhiyun return ret;
2070*4882a593Smuzhiyun
2071*4882a593Smuzhiyun return 0;
2072*4882a593Smuzhiyun }
2073*4882a593Smuzhiyun
cdns_torrent_phy_probe(struct platform_device * pdev)2074*4882a593Smuzhiyun static int cdns_torrent_phy_probe(struct platform_device *pdev)
2075*4882a593Smuzhiyun {
2076*4882a593Smuzhiyun struct cdns_torrent_phy *cdns_phy;
2077*4882a593Smuzhiyun struct device *dev = &pdev->dev;
2078*4882a593Smuzhiyun struct phy_provider *phy_provider;
2079*4882a593Smuzhiyun const struct cdns_torrent_data *data;
2080*4882a593Smuzhiyun struct device_node *child;
2081*4882a593Smuzhiyun int ret, subnodes, node = 0, i;
2082*4882a593Smuzhiyun u32 total_num_lanes = 0;
2083*4882a593Smuzhiyun u8 init_dp_regmap = 0;
2084*4882a593Smuzhiyun u32 phy_type;
2085*4882a593Smuzhiyun
2086*4882a593Smuzhiyun /* Get init data for this PHY */
2087*4882a593Smuzhiyun data = of_device_get_match_data(dev);
2088*4882a593Smuzhiyun if (!data)
2089*4882a593Smuzhiyun return -EINVAL;
2090*4882a593Smuzhiyun
2091*4882a593Smuzhiyun cdns_phy = devm_kzalloc(dev, sizeof(*cdns_phy), GFP_KERNEL);
2092*4882a593Smuzhiyun if (!cdns_phy)
2093*4882a593Smuzhiyun return -ENOMEM;
2094*4882a593Smuzhiyun
2095*4882a593Smuzhiyun dev_set_drvdata(dev, cdns_phy);
2096*4882a593Smuzhiyun cdns_phy->dev = dev;
2097*4882a593Smuzhiyun cdns_phy->init_data = data;
2098*4882a593Smuzhiyun
2099*4882a593Smuzhiyun cdns_phy->phy_rst = devm_reset_control_get_exclusive_by_index(dev, 0);
2100*4882a593Smuzhiyun if (IS_ERR(cdns_phy->phy_rst)) {
2101*4882a593Smuzhiyun dev_err(dev, "%s: failed to get reset\n",
2102*4882a593Smuzhiyun dev->of_node->full_name);
2103*4882a593Smuzhiyun return PTR_ERR(cdns_phy->phy_rst);
2104*4882a593Smuzhiyun }
2105*4882a593Smuzhiyun
2106*4882a593Smuzhiyun cdns_phy->apb_rst = devm_reset_control_get_optional(dev, "torrent_apb");
2107*4882a593Smuzhiyun if (IS_ERR(cdns_phy->apb_rst)) {
2108*4882a593Smuzhiyun dev_err(dev, "%s: failed to get apb reset\n",
2109*4882a593Smuzhiyun dev->of_node->full_name);
2110*4882a593Smuzhiyun return PTR_ERR(cdns_phy->apb_rst);
2111*4882a593Smuzhiyun }
2112*4882a593Smuzhiyun
2113*4882a593Smuzhiyun cdns_phy->clk = devm_clk_get(dev, "refclk");
2114*4882a593Smuzhiyun if (IS_ERR(cdns_phy->clk)) {
2115*4882a593Smuzhiyun dev_err(dev, "phy ref clock not found\n");
2116*4882a593Smuzhiyun return PTR_ERR(cdns_phy->clk);
2117*4882a593Smuzhiyun }
2118*4882a593Smuzhiyun
2119*4882a593Smuzhiyun cdns_phy->sd_base = devm_platform_ioremap_resource(pdev, 0);
2120*4882a593Smuzhiyun if (IS_ERR(cdns_phy->sd_base))
2121*4882a593Smuzhiyun return PTR_ERR(cdns_phy->sd_base);
2122*4882a593Smuzhiyun
2123*4882a593Smuzhiyun subnodes = of_get_available_child_count(dev->of_node);
2124*4882a593Smuzhiyun if (subnodes == 0) {
2125*4882a593Smuzhiyun dev_err(dev, "No available link subnodes found\n");
2126*4882a593Smuzhiyun return -EINVAL;
2127*4882a593Smuzhiyun }
2128*4882a593Smuzhiyun
2129*4882a593Smuzhiyun ret = cdns_torrent_regmap_init(cdns_phy);
2130*4882a593Smuzhiyun if (ret)
2131*4882a593Smuzhiyun return ret;
2132*4882a593Smuzhiyun
2133*4882a593Smuzhiyun ret = cdns_torrent_regfield_init(cdns_phy);
2134*4882a593Smuzhiyun if (ret)
2135*4882a593Smuzhiyun return ret;
2136*4882a593Smuzhiyun
2137*4882a593Smuzhiyun ret = clk_prepare_enable(cdns_phy->clk);
2138*4882a593Smuzhiyun if (ret) {
2139*4882a593Smuzhiyun dev_err(cdns_phy->dev, "Failed to prepare ref clock\n");
2140*4882a593Smuzhiyun return ret;
2141*4882a593Smuzhiyun }
2142*4882a593Smuzhiyun
2143*4882a593Smuzhiyun cdns_phy->ref_clk_rate = clk_get_rate(cdns_phy->clk);
2144*4882a593Smuzhiyun if (!(cdns_phy->ref_clk_rate)) {
2145*4882a593Smuzhiyun dev_err(cdns_phy->dev, "Failed to get ref clock rate\n");
2146*4882a593Smuzhiyun clk_disable_unprepare(cdns_phy->clk);
2147*4882a593Smuzhiyun return -EINVAL;
2148*4882a593Smuzhiyun }
2149*4882a593Smuzhiyun
2150*4882a593Smuzhiyun /* Enable APB */
2151*4882a593Smuzhiyun reset_control_deassert(cdns_phy->apb_rst);
2152*4882a593Smuzhiyun
2153*4882a593Smuzhiyun for_each_available_child_of_node(dev->of_node, child) {
2154*4882a593Smuzhiyun struct phy *gphy;
2155*4882a593Smuzhiyun
2156*4882a593Smuzhiyun /* PHY subnode name must be 'phy'. */
2157*4882a593Smuzhiyun if (!(of_node_name_eq(child, "phy")))
2158*4882a593Smuzhiyun continue;
2159*4882a593Smuzhiyun
2160*4882a593Smuzhiyun cdns_phy->phys[node].lnk_rst =
2161*4882a593Smuzhiyun of_reset_control_array_get_exclusive(child);
2162*4882a593Smuzhiyun if (IS_ERR(cdns_phy->phys[node].lnk_rst)) {
2163*4882a593Smuzhiyun dev_err(dev, "%s: failed to get reset\n",
2164*4882a593Smuzhiyun child->full_name);
2165*4882a593Smuzhiyun ret = PTR_ERR(cdns_phy->phys[node].lnk_rst);
2166*4882a593Smuzhiyun goto put_lnk_rst;
2167*4882a593Smuzhiyun }
2168*4882a593Smuzhiyun
2169*4882a593Smuzhiyun if (of_property_read_u32(child, "reg",
2170*4882a593Smuzhiyun &cdns_phy->phys[node].mlane)) {
2171*4882a593Smuzhiyun dev_err(dev, "%s: No \"reg\"-property.\n",
2172*4882a593Smuzhiyun child->full_name);
2173*4882a593Smuzhiyun ret = -EINVAL;
2174*4882a593Smuzhiyun goto put_child;
2175*4882a593Smuzhiyun }
2176*4882a593Smuzhiyun
2177*4882a593Smuzhiyun if (of_property_read_u32(child, "cdns,phy-type", &phy_type)) {
2178*4882a593Smuzhiyun dev_err(dev, "%s: No \"cdns,phy-type\"-property.\n",
2179*4882a593Smuzhiyun child->full_name);
2180*4882a593Smuzhiyun ret = -EINVAL;
2181*4882a593Smuzhiyun goto put_child;
2182*4882a593Smuzhiyun }
2183*4882a593Smuzhiyun
2184*4882a593Smuzhiyun switch (phy_type) {
2185*4882a593Smuzhiyun case PHY_TYPE_PCIE:
2186*4882a593Smuzhiyun cdns_phy->phys[node].phy_type = TYPE_PCIE;
2187*4882a593Smuzhiyun break;
2188*4882a593Smuzhiyun case PHY_TYPE_DP:
2189*4882a593Smuzhiyun cdns_phy->phys[node].phy_type = TYPE_DP;
2190*4882a593Smuzhiyun break;
2191*4882a593Smuzhiyun case PHY_TYPE_SGMII:
2192*4882a593Smuzhiyun cdns_phy->phys[node].phy_type = TYPE_SGMII;
2193*4882a593Smuzhiyun break;
2194*4882a593Smuzhiyun case PHY_TYPE_QSGMII:
2195*4882a593Smuzhiyun cdns_phy->phys[node].phy_type = TYPE_QSGMII;
2196*4882a593Smuzhiyun break;
2197*4882a593Smuzhiyun case PHY_TYPE_USB3:
2198*4882a593Smuzhiyun cdns_phy->phys[node].phy_type = TYPE_USB;
2199*4882a593Smuzhiyun break;
2200*4882a593Smuzhiyun default:
2201*4882a593Smuzhiyun dev_err(dev, "Unsupported protocol\n");
2202*4882a593Smuzhiyun ret = -EINVAL;
2203*4882a593Smuzhiyun goto put_child;
2204*4882a593Smuzhiyun }
2205*4882a593Smuzhiyun
2206*4882a593Smuzhiyun if (of_property_read_u32(child, "cdns,num-lanes",
2207*4882a593Smuzhiyun &cdns_phy->phys[node].num_lanes)) {
2208*4882a593Smuzhiyun dev_err(dev, "%s: No \"cdns,num-lanes\"-property.\n",
2209*4882a593Smuzhiyun child->full_name);
2210*4882a593Smuzhiyun ret = -EINVAL;
2211*4882a593Smuzhiyun goto put_child;
2212*4882a593Smuzhiyun }
2213*4882a593Smuzhiyun
2214*4882a593Smuzhiyun total_num_lanes += cdns_phy->phys[node].num_lanes;
2215*4882a593Smuzhiyun
2216*4882a593Smuzhiyun /* Get SSC mode */
2217*4882a593Smuzhiyun cdns_phy->phys[node].ssc_mode = NO_SSC;
2218*4882a593Smuzhiyun of_property_read_u32(child, "cdns,ssc-mode",
2219*4882a593Smuzhiyun &cdns_phy->phys[node].ssc_mode);
2220*4882a593Smuzhiyun
2221*4882a593Smuzhiyun gphy = devm_phy_create(dev, child, &cdns_torrent_phy_ops);
2222*4882a593Smuzhiyun if (IS_ERR(gphy)) {
2223*4882a593Smuzhiyun ret = PTR_ERR(gphy);
2224*4882a593Smuzhiyun goto put_child;
2225*4882a593Smuzhiyun }
2226*4882a593Smuzhiyun
2227*4882a593Smuzhiyun if (cdns_phy->phys[node].phy_type == TYPE_DP) {
2228*4882a593Smuzhiyun switch (cdns_phy->phys[node].num_lanes) {
2229*4882a593Smuzhiyun case 1:
2230*4882a593Smuzhiyun case 2:
2231*4882a593Smuzhiyun case 4:
2232*4882a593Smuzhiyun /* valid number of lanes */
2233*4882a593Smuzhiyun break;
2234*4882a593Smuzhiyun default:
2235*4882a593Smuzhiyun dev_err(dev, "unsupported number of lanes: %d\n",
2236*4882a593Smuzhiyun cdns_phy->phys[node].num_lanes);
2237*4882a593Smuzhiyun ret = -EINVAL;
2238*4882a593Smuzhiyun goto put_child;
2239*4882a593Smuzhiyun }
2240*4882a593Smuzhiyun
2241*4882a593Smuzhiyun cdns_phy->max_bit_rate = DEFAULT_MAX_BIT_RATE;
2242*4882a593Smuzhiyun of_property_read_u32(child, "cdns,max-bit-rate",
2243*4882a593Smuzhiyun &cdns_phy->max_bit_rate);
2244*4882a593Smuzhiyun
2245*4882a593Smuzhiyun switch (cdns_phy->max_bit_rate) {
2246*4882a593Smuzhiyun case 1620:
2247*4882a593Smuzhiyun case 2160:
2248*4882a593Smuzhiyun case 2430:
2249*4882a593Smuzhiyun case 2700:
2250*4882a593Smuzhiyun case 3240:
2251*4882a593Smuzhiyun case 4320:
2252*4882a593Smuzhiyun case 5400:
2253*4882a593Smuzhiyun case 8100:
2254*4882a593Smuzhiyun /* valid bit rate */
2255*4882a593Smuzhiyun break;
2256*4882a593Smuzhiyun default:
2257*4882a593Smuzhiyun dev_err(dev, "unsupported max bit rate: %dMbps\n",
2258*4882a593Smuzhiyun cdns_phy->max_bit_rate);
2259*4882a593Smuzhiyun ret = -EINVAL;
2260*4882a593Smuzhiyun goto put_child;
2261*4882a593Smuzhiyun }
2262*4882a593Smuzhiyun
2263*4882a593Smuzhiyun /* DPTX registers */
2264*4882a593Smuzhiyun cdns_phy->base = devm_platform_ioremap_resource(pdev, 1);
2265*4882a593Smuzhiyun if (IS_ERR(cdns_phy->base)) {
2266*4882a593Smuzhiyun ret = PTR_ERR(cdns_phy->base);
2267*4882a593Smuzhiyun goto put_child;
2268*4882a593Smuzhiyun }
2269*4882a593Smuzhiyun
2270*4882a593Smuzhiyun if (!init_dp_regmap) {
2271*4882a593Smuzhiyun ret = cdns_torrent_dp_regmap_init(cdns_phy);
2272*4882a593Smuzhiyun if (ret)
2273*4882a593Smuzhiyun goto put_child;
2274*4882a593Smuzhiyun
2275*4882a593Smuzhiyun ret = cdns_torrent_dp_regfield_init(cdns_phy);
2276*4882a593Smuzhiyun if (ret)
2277*4882a593Smuzhiyun goto put_child;
2278*4882a593Smuzhiyun
2279*4882a593Smuzhiyun init_dp_regmap++;
2280*4882a593Smuzhiyun }
2281*4882a593Smuzhiyun
2282*4882a593Smuzhiyun dev_info(dev, "%d lanes, max bit rate %d.%03d Gbps\n",
2283*4882a593Smuzhiyun cdns_phy->phys[node].num_lanes,
2284*4882a593Smuzhiyun cdns_phy->max_bit_rate / 1000,
2285*4882a593Smuzhiyun cdns_phy->max_bit_rate % 1000);
2286*4882a593Smuzhiyun
2287*4882a593Smuzhiyun gphy->attrs.bus_width = cdns_phy->phys[node].num_lanes;
2288*4882a593Smuzhiyun gphy->attrs.max_link_rate = cdns_phy->max_bit_rate;
2289*4882a593Smuzhiyun gphy->attrs.mode = PHY_MODE_DP;
2290*4882a593Smuzhiyun }
2291*4882a593Smuzhiyun
2292*4882a593Smuzhiyun cdns_phy->phys[node].phy = gphy;
2293*4882a593Smuzhiyun phy_set_drvdata(gphy, &cdns_phy->phys[node]);
2294*4882a593Smuzhiyun
2295*4882a593Smuzhiyun node++;
2296*4882a593Smuzhiyun }
2297*4882a593Smuzhiyun cdns_phy->nsubnodes = node;
2298*4882a593Smuzhiyun
2299*4882a593Smuzhiyun if (total_num_lanes > MAX_NUM_LANES) {
2300*4882a593Smuzhiyun dev_err(dev, "Invalid lane configuration\n");
2301*4882a593Smuzhiyun ret = -EINVAL;
2302*4882a593Smuzhiyun goto put_lnk_rst;
2303*4882a593Smuzhiyun }
2304*4882a593Smuzhiyun
2305*4882a593Smuzhiyun if (cdns_phy->nsubnodes > 1) {
2306*4882a593Smuzhiyun ret = cdns_torrent_phy_configure_multilink(cdns_phy);
2307*4882a593Smuzhiyun if (ret)
2308*4882a593Smuzhiyun goto put_lnk_rst;
2309*4882a593Smuzhiyun }
2310*4882a593Smuzhiyun
2311*4882a593Smuzhiyun phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
2312*4882a593Smuzhiyun if (IS_ERR(phy_provider)) {
2313*4882a593Smuzhiyun ret = PTR_ERR(phy_provider);
2314*4882a593Smuzhiyun goto put_lnk_rst;
2315*4882a593Smuzhiyun }
2316*4882a593Smuzhiyun
2317*4882a593Smuzhiyun return 0;
2318*4882a593Smuzhiyun
2319*4882a593Smuzhiyun put_child:
2320*4882a593Smuzhiyun node++;
2321*4882a593Smuzhiyun put_lnk_rst:
2322*4882a593Smuzhiyun for (i = 0; i < node; i++)
2323*4882a593Smuzhiyun reset_control_put(cdns_phy->phys[i].lnk_rst);
2324*4882a593Smuzhiyun of_node_put(child);
2325*4882a593Smuzhiyun reset_control_assert(cdns_phy->apb_rst);
2326*4882a593Smuzhiyun clk_disable_unprepare(cdns_phy->clk);
2327*4882a593Smuzhiyun return ret;
2328*4882a593Smuzhiyun }
2329*4882a593Smuzhiyun
cdns_torrent_phy_remove(struct platform_device * pdev)2330*4882a593Smuzhiyun static int cdns_torrent_phy_remove(struct platform_device *pdev)
2331*4882a593Smuzhiyun {
2332*4882a593Smuzhiyun struct cdns_torrent_phy *cdns_phy = platform_get_drvdata(pdev);
2333*4882a593Smuzhiyun int i;
2334*4882a593Smuzhiyun
2335*4882a593Smuzhiyun reset_control_assert(cdns_phy->phy_rst);
2336*4882a593Smuzhiyun reset_control_assert(cdns_phy->apb_rst);
2337*4882a593Smuzhiyun for (i = 0; i < cdns_phy->nsubnodes; i++) {
2338*4882a593Smuzhiyun reset_control_assert(cdns_phy->phys[i].lnk_rst);
2339*4882a593Smuzhiyun reset_control_put(cdns_phy->phys[i].lnk_rst);
2340*4882a593Smuzhiyun }
2341*4882a593Smuzhiyun
2342*4882a593Smuzhiyun clk_disable_unprepare(cdns_phy->clk);
2343*4882a593Smuzhiyun
2344*4882a593Smuzhiyun return 0;
2345*4882a593Smuzhiyun }
2346*4882a593Smuzhiyun
2347*4882a593Smuzhiyun /* USB and SGMII/QSGMII link configuration */
2348*4882a593Smuzhiyun static struct cdns_reg_pairs usb_sgmii_link_cmn_regs[] = {
2349*4882a593Smuzhiyun {0x0002, PHY_PLL_CFG},
2350*4882a593Smuzhiyun {0x8600, CMN_PDIAG_PLL0_CLK_SEL_M0},
2351*4882a593Smuzhiyun {0x0601, CMN_PDIAG_PLL1_CLK_SEL_M0}
2352*4882a593Smuzhiyun };
2353*4882a593Smuzhiyun
2354*4882a593Smuzhiyun static struct cdns_reg_pairs usb_sgmii_xcvr_diag_ln_regs[] = {
2355*4882a593Smuzhiyun {0x0000, XCVR_DIAG_HSCLK_SEL},
2356*4882a593Smuzhiyun {0x0001, XCVR_DIAG_HSCLK_DIV},
2357*4882a593Smuzhiyun {0x0041, XCVR_DIAG_PLLDRC_CTRL}
2358*4882a593Smuzhiyun };
2359*4882a593Smuzhiyun
2360*4882a593Smuzhiyun static struct cdns_reg_pairs sgmii_usb_xcvr_diag_ln_regs[] = {
2361*4882a593Smuzhiyun {0x0011, XCVR_DIAG_HSCLK_SEL},
2362*4882a593Smuzhiyun {0x0003, XCVR_DIAG_HSCLK_DIV},
2363*4882a593Smuzhiyun {0x009B, XCVR_DIAG_PLLDRC_CTRL}
2364*4882a593Smuzhiyun };
2365*4882a593Smuzhiyun
2366*4882a593Smuzhiyun static struct cdns_torrent_vals usb_sgmii_link_cmn_vals = {
2367*4882a593Smuzhiyun .reg_pairs = usb_sgmii_link_cmn_regs,
2368*4882a593Smuzhiyun .num_regs = ARRAY_SIZE(usb_sgmii_link_cmn_regs),
2369*4882a593Smuzhiyun };
2370*4882a593Smuzhiyun
2371*4882a593Smuzhiyun static struct cdns_torrent_vals usb_sgmii_xcvr_diag_ln_vals = {
2372*4882a593Smuzhiyun .reg_pairs = usb_sgmii_xcvr_diag_ln_regs,
2373*4882a593Smuzhiyun .num_regs = ARRAY_SIZE(usb_sgmii_xcvr_diag_ln_regs),
2374*4882a593Smuzhiyun };
2375*4882a593Smuzhiyun
2376*4882a593Smuzhiyun static struct cdns_torrent_vals sgmii_usb_xcvr_diag_ln_vals = {
2377*4882a593Smuzhiyun .reg_pairs = sgmii_usb_xcvr_diag_ln_regs,
2378*4882a593Smuzhiyun .num_regs = ARRAY_SIZE(sgmii_usb_xcvr_diag_ln_regs),
2379*4882a593Smuzhiyun };
2380*4882a593Smuzhiyun
2381*4882a593Smuzhiyun /* PCIe and USB Unique SSC link configuration */
2382*4882a593Smuzhiyun static struct cdns_reg_pairs pcie_usb_link_cmn_regs[] = {
2383*4882a593Smuzhiyun {0x0003, PHY_PLL_CFG},
2384*4882a593Smuzhiyun {0x0601, CMN_PDIAG_PLL0_CLK_SEL_M0},
2385*4882a593Smuzhiyun {0x0400, CMN_PDIAG_PLL0_CLK_SEL_M1},
2386*4882a593Smuzhiyun {0x8600, CMN_PDIAG_PLL1_CLK_SEL_M0}
2387*4882a593Smuzhiyun };
2388*4882a593Smuzhiyun
2389*4882a593Smuzhiyun static struct cdns_reg_pairs pcie_usb_xcvr_diag_ln_regs[] = {
2390*4882a593Smuzhiyun {0x0000, XCVR_DIAG_HSCLK_SEL},
2391*4882a593Smuzhiyun {0x0001, XCVR_DIAG_HSCLK_DIV},
2392*4882a593Smuzhiyun {0x0012, XCVR_DIAG_PLLDRC_CTRL}
2393*4882a593Smuzhiyun };
2394*4882a593Smuzhiyun
2395*4882a593Smuzhiyun static struct cdns_reg_pairs usb_pcie_xcvr_diag_ln_regs[] = {
2396*4882a593Smuzhiyun {0x0011, XCVR_DIAG_HSCLK_SEL},
2397*4882a593Smuzhiyun {0x0001, XCVR_DIAG_HSCLK_DIV},
2398*4882a593Smuzhiyun {0x00C9, XCVR_DIAG_PLLDRC_CTRL}
2399*4882a593Smuzhiyun };
2400*4882a593Smuzhiyun
2401*4882a593Smuzhiyun static struct cdns_torrent_vals pcie_usb_link_cmn_vals = {
2402*4882a593Smuzhiyun .reg_pairs = pcie_usb_link_cmn_regs,
2403*4882a593Smuzhiyun .num_regs = ARRAY_SIZE(pcie_usb_link_cmn_regs),
2404*4882a593Smuzhiyun };
2405*4882a593Smuzhiyun
2406*4882a593Smuzhiyun static struct cdns_torrent_vals pcie_usb_xcvr_diag_ln_vals = {
2407*4882a593Smuzhiyun .reg_pairs = pcie_usb_xcvr_diag_ln_regs,
2408*4882a593Smuzhiyun .num_regs = ARRAY_SIZE(pcie_usb_xcvr_diag_ln_regs),
2409*4882a593Smuzhiyun };
2410*4882a593Smuzhiyun
2411*4882a593Smuzhiyun static struct cdns_torrent_vals usb_pcie_xcvr_diag_ln_vals = {
2412*4882a593Smuzhiyun .reg_pairs = usb_pcie_xcvr_diag_ln_regs,
2413*4882a593Smuzhiyun .num_regs = ARRAY_SIZE(usb_pcie_xcvr_diag_ln_regs),
2414*4882a593Smuzhiyun };
2415*4882a593Smuzhiyun
2416*4882a593Smuzhiyun /* USB 100 MHz Ref clk, internal SSC */
2417*4882a593Smuzhiyun static struct cdns_reg_pairs usb_100_int_ssc_cmn_regs[] = {
2418*4882a593Smuzhiyun {0x0004, CMN_PLL0_DSM_DIAG_M0},
2419*4882a593Smuzhiyun {0x0004, CMN_PLL0_DSM_DIAG_M1},
2420*4882a593Smuzhiyun {0x0004, CMN_PLL1_DSM_DIAG_M0},
2421*4882a593Smuzhiyun {0x0509, CMN_PDIAG_PLL0_CP_PADJ_M0},
2422*4882a593Smuzhiyun {0x0509, CMN_PDIAG_PLL0_CP_PADJ_M1},
2423*4882a593Smuzhiyun {0x0509, CMN_PDIAG_PLL1_CP_PADJ_M0},
2424*4882a593Smuzhiyun {0x0F00, CMN_PDIAG_PLL0_CP_IADJ_M0},
2425*4882a593Smuzhiyun {0x0F00, CMN_PDIAG_PLL0_CP_IADJ_M1},
2426*4882a593Smuzhiyun {0x0F00, CMN_PDIAG_PLL1_CP_IADJ_M0},
2427*4882a593Smuzhiyun {0x0F08, CMN_PDIAG_PLL0_FILT_PADJ_M0},
2428*4882a593Smuzhiyun {0x0F08, CMN_PDIAG_PLL0_FILT_PADJ_M1},
2429*4882a593Smuzhiyun {0x0F08, CMN_PDIAG_PLL1_FILT_PADJ_M0},
2430*4882a593Smuzhiyun {0x0064, CMN_PLL0_INTDIV_M0},
2431*4882a593Smuzhiyun {0x0050, CMN_PLL0_INTDIV_M1},
2432*4882a593Smuzhiyun {0x0064, CMN_PLL1_INTDIV_M0},
2433*4882a593Smuzhiyun {0x0002, CMN_PLL0_FRACDIVH_M0},
2434*4882a593Smuzhiyun {0x0002, CMN_PLL0_FRACDIVH_M1},
2435*4882a593Smuzhiyun {0x0002, CMN_PLL1_FRACDIVH_M0},
2436*4882a593Smuzhiyun {0x0044, CMN_PLL0_HIGH_THR_M0},
2437*4882a593Smuzhiyun {0x0036, CMN_PLL0_HIGH_THR_M1},
2438*4882a593Smuzhiyun {0x0044, CMN_PLL1_HIGH_THR_M0},
2439*4882a593Smuzhiyun {0x0002, CMN_PDIAG_PLL0_CTRL_M0},
2440*4882a593Smuzhiyun {0x0002, CMN_PDIAG_PLL0_CTRL_M1},
2441*4882a593Smuzhiyun {0x0002, CMN_PDIAG_PLL1_CTRL_M0},
2442*4882a593Smuzhiyun {0x0001, CMN_PLL0_SS_CTRL1_M0},
2443*4882a593Smuzhiyun {0x0001, CMN_PLL0_SS_CTRL1_M1},
2444*4882a593Smuzhiyun {0x0001, CMN_PLL1_SS_CTRL1_M0},
2445*4882a593Smuzhiyun {0x011B, CMN_PLL0_SS_CTRL2_M0},
2446*4882a593Smuzhiyun {0x011B, CMN_PLL0_SS_CTRL2_M1},
2447*4882a593Smuzhiyun {0x011B, CMN_PLL1_SS_CTRL2_M0},
2448*4882a593Smuzhiyun {0x006E, CMN_PLL0_SS_CTRL3_M0},
2449*4882a593Smuzhiyun {0x0058, CMN_PLL0_SS_CTRL3_M1},
2450*4882a593Smuzhiyun {0x006E, CMN_PLL1_SS_CTRL3_M0},
2451*4882a593Smuzhiyun {0x000E, CMN_PLL0_SS_CTRL4_M0},
2452*4882a593Smuzhiyun {0x0012, CMN_PLL0_SS_CTRL4_M1},
2453*4882a593Smuzhiyun {0x000E, CMN_PLL1_SS_CTRL4_M0},
2454*4882a593Smuzhiyun {0x0C5E, CMN_PLL0_VCOCAL_REFTIM_START},
2455*4882a593Smuzhiyun {0x0C5E, CMN_PLL1_VCOCAL_REFTIM_START},
2456*4882a593Smuzhiyun {0x0C56, CMN_PLL0_VCOCAL_PLLCNT_START},
2457*4882a593Smuzhiyun {0x0C56, CMN_PLL1_VCOCAL_PLLCNT_START},
2458*4882a593Smuzhiyun {0x0003, CMN_PLL0_VCOCAL_TCTRL},
2459*4882a593Smuzhiyun {0x0003, CMN_PLL1_VCOCAL_TCTRL},
2460*4882a593Smuzhiyun {0x00C7, CMN_PLL0_LOCK_REFCNT_START},
2461*4882a593Smuzhiyun {0x00C7, CMN_PLL1_LOCK_REFCNT_START},
2462*4882a593Smuzhiyun {0x00C7, CMN_PLL0_LOCK_PLLCNT_START},
2463*4882a593Smuzhiyun {0x00C7, CMN_PLL1_LOCK_PLLCNT_START},
2464*4882a593Smuzhiyun {0x0005, CMN_PLL0_LOCK_PLLCNT_THR},
2465*4882a593Smuzhiyun {0x0005, CMN_PLL1_LOCK_PLLCNT_THR},
2466*4882a593Smuzhiyun {0x8200, CMN_CDIAG_CDB_PWRI_OVRD},
2467*4882a593Smuzhiyun {0x8200, CMN_CDIAG_XCVRC_PWRI_OVRD}
2468*4882a593Smuzhiyun };
2469*4882a593Smuzhiyun
2470*4882a593Smuzhiyun static struct cdns_torrent_vals usb_100_int_ssc_cmn_vals = {
2471*4882a593Smuzhiyun .reg_pairs = usb_100_int_ssc_cmn_regs,
2472*4882a593Smuzhiyun .num_regs = ARRAY_SIZE(usb_100_int_ssc_cmn_regs),
2473*4882a593Smuzhiyun };
2474*4882a593Smuzhiyun
2475*4882a593Smuzhiyun /* Single USB link configuration */
2476*4882a593Smuzhiyun static struct cdns_reg_pairs sl_usb_link_cmn_regs[] = {
2477*4882a593Smuzhiyun {0x0000, PHY_PLL_CFG},
2478*4882a593Smuzhiyun {0x8600, CMN_PDIAG_PLL0_CLK_SEL_M0}
2479*4882a593Smuzhiyun };
2480*4882a593Smuzhiyun
2481*4882a593Smuzhiyun static struct cdns_reg_pairs sl_usb_xcvr_diag_ln_regs[] = {
2482*4882a593Smuzhiyun {0x0000, XCVR_DIAG_HSCLK_SEL},
2483*4882a593Smuzhiyun {0x0001, XCVR_DIAG_HSCLK_DIV},
2484*4882a593Smuzhiyun {0x0041, XCVR_DIAG_PLLDRC_CTRL}
2485*4882a593Smuzhiyun };
2486*4882a593Smuzhiyun
2487*4882a593Smuzhiyun static struct cdns_torrent_vals sl_usb_link_cmn_vals = {
2488*4882a593Smuzhiyun .reg_pairs = sl_usb_link_cmn_regs,
2489*4882a593Smuzhiyun .num_regs = ARRAY_SIZE(sl_usb_link_cmn_regs),
2490*4882a593Smuzhiyun };
2491*4882a593Smuzhiyun
2492*4882a593Smuzhiyun static struct cdns_torrent_vals sl_usb_xcvr_diag_ln_vals = {
2493*4882a593Smuzhiyun .reg_pairs = sl_usb_xcvr_diag_ln_regs,
2494*4882a593Smuzhiyun .num_regs = ARRAY_SIZE(sl_usb_xcvr_diag_ln_regs),
2495*4882a593Smuzhiyun };
2496*4882a593Smuzhiyun
2497*4882a593Smuzhiyun /* USB PHY PCS common configuration */
2498*4882a593Smuzhiyun static struct cdns_reg_pairs usb_phy_pcs_cmn_regs[] = {
2499*4882a593Smuzhiyun {0x0A0A, PHY_PIPE_USB3_GEN2_PRE_CFG0},
2500*4882a593Smuzhiyun {0x1000, PHY_PIPE_USB3_GEN2_POST_CFG0},
2501*4882a593Smuzhiyun {0x0010, PHY_PIPE_USB3_GEN2_POST_CFG1}
2502*4882a593Smuzhiyun };
2503*4882a593Smuzhiyun
2504*4882a593Smuzhiyun static struct cdns_torrent_vals usb_phy_pcs_cmn_vals = {
2505*4882a593Smuzhiyun .reg_pairs = usb_phy_pcs_cmn_regs,
2506*4882a593Smuzhiyun .num_regs = ARRAY_SIZE(usb_phy_pcs_cmn_regs),
2507*4882a593Smuzhiyun };
2508*4882a593Smuzhiyun
2509*4882a593Smuzhiyun /* USB 100 MHz Ref clk, no SSC */
2510*4882a593Smuzhiyun static struct cdns_reg_pairs usb_100_no_ssc_cmn_regs[] = {
2511*4882a593Smuzhiyun {0x0003, CMN_PLL0_VCOCAL_TCTRL},
2512*4882a593Smuzhiyun {0x0003, CMN_PLL1_VCOCAL_TCTRL},
2513*4882a593Smuzhiyun {0x8200, CMN_CDIAG_CDB_PWRI_OVRD},
2514*4882a593Smuzhiyun {0x8200, CMN_CDIAG_XCVRC_PWRI_OVRD}
2515*4882a593Smuzhiyun };
2516*4882a593Smuzhiyun
2517*4882a593Smuzhiyun static struct cdns_reg_pairs usb_100_no_ssc_tx_ln_regs[] = {
2518*4882a593Smuzhiyun {0x02FF, TX_PSC_A0},
2519*4882a593Smuzhiyun {0x06AF, TX_PSC_A1},
2520*4882a593Smuzhiyun {0x06AE, TX_PSC_A2},
2521*4882a593Smuzhiyun {0x06AE, TX_PSC_A3},
2522*4882a593Smuzhiyun {0x2A82, TX_TXCC_CTRL},
2523*4882a593Smuzhiyun {0x0014, TX_TXCC_CPOST_MULT_01},
2524*4882a593Smuzhiyun {0x0003, XCVR_DIAG_PSC_OVRD}
2525*4882a593Smuzhiyun };
2526*4882a593Smuzhiyun
2527*4882a593Smuzhiyun static struct cdns_reg_pairs usb_100_no_ssc_rx_ln_regs[] = {
2528*4882a593Smuzhiyun {0x0D1D, RX_PSC_A0},
2529*4882a593Smuzhiyun {0x0D1D, RX_PSC_A1},
2530*4882a593Smuzhiyun {0x0D00, RX_PSC_A2},
2531*4882a593Smuzhiyun {0x0500, RX_PSC_A3},
2532*4882a593Smuzhiyun {0x0013, RX_SIGDET_HL_FILT_TMR},
2533*4882a593Smuzhiyun {0x0000, RX_REE_GCSM1_CTRL},
2534*4882a593Smuzhiyun {0x0C02, RX_REE_ATTEN_THR},
2535*4882a593Smuzhiyun {0x0330, RX_REE_SMGM_CTRL1},
2536*4882a593Smuzhiyun {0x0300, RX_REE_SMGM_CTRL2},
2537*4882a593Smuzhiyun {0x0019, RX_REE_TAP1_CLIP},
2538*4882a593Smuzhiyun {0x0019, RX_REE_TAP2TON_CLIP},
2539*4882a593Smuzhiyun {0x1004, RX_DIAG_SIGDET_TUNE},
2540*4882a593Smuzhiyun {0x00F9, RX_DIAG_NQST_CTRL},
2541*4882a593Smuzhiyun {0x0C01, RX_DIAG_DFE_AMP_TUNE_2},
2542*4882a593Smuzhiyun {0x0002, RX_DIAG_DFE_AMP_TUNE_3},
2543*4882a593Smuzhiyun {0x0000, RX_DIAG_PI_CAP},
2544*4882a593Smuzhiyun {0x0031, RX_DIAG_PI_RATE},
2545*4882a593Smuzhiyun {0x0001, RX_DIAG_ACYA},
2546*4882a593Smuzhiyun {0x018C, RX_CDRLF_CNFG},
2547*4882a593Smuzhiyun {0x0003, RX_CDRLF_CNFG3}
2548*4882a593Smuzhiyun };
2549*4882a593Smuzhiyun
2550*4882a593Smuzhiyun static struct cdns_torrent_vals usb_100_no_ssc_cmn_vals = {
2551*4882a593Smuzhiyun .reg_pairs = usb_100_no_ssc_cmn_regs,
2552*4882a593Smuzhiyun .num_regs = ARRAY_SIZE(usb_100_no_ssc_cmn_regs),
2553*4882a593Smuzhiyun };
2554*4882a593Smuzhiyun
2555*4882a593Smuzhiyun static struct cdns_torrent_vals usb_100_no_ssc_tx_ln_vals = {
2556*4882a593Smuzhiyun .reg_pairs = usb_100_no_ssc_tx_ln_regs,
2557*4882a593Smuzhiyun .num_regs = ARRAY_SIZE(usb_100_no_ssc_tx_ln_regs),
2558*4882a593Smuzhiyun };
2559*4882a593Smuzhiyun
2560*4882a593Smuzhiyun static struct cdns_torrent_vals usb_100_no_ssc_rx_ln_vals = {
2561*4882a593Smuzhiyun .reg_pairs = usb_100_no_ssc_rx_ln_regs,
2562*4882a593Smuzhiyun .num_regs = ARRAY_SIZE(usb_100_no_ssc_rx_ln_regs),
2563*4882a593Smuzhiyun };
2564*4882a593Smuzhiyun
2565*4882a593Smuzhiyun /* Single link USB, 100 MHz Ref clk, internal SSC */
2566*4882a593Smuzhiyun static struct cdns_reg_pairs sl_usb_100_int_ssc_cmn_regs[] = {
2567*4882a593Smuzhiyun {0x0004, CMN_PLL0_DSM_DIAG_M0},
2568*4882a593Smuzhiyun {0x0004, CMN_PLL1_DSM_DIAG_M0},
2569*4882a593Smuzhiyun {0x0509, CMN_PDIAG_PLL0_CP_PADJ_M0},
2570*4882a593Smuzhiyun {0x0509, CMN_PDIAG_PLL1_CP_PADJ_M0},
2571*4882a593Smuzhiyun {0x0F00, CMN_PDIAG_PLL0_CP_IADJ_M0},
2572*4882a593Smuzhiyun {0x0F00, CMN_PDIAG_PLL1_CP_IADJ_M0},
2573*4882a593Smuzhiyun {0x0F08, CMN_PDIAG_PLL0_FILT_PADJ_M0},
2574*4882a593Smuzhiyun {0x0F08, CMN_PDIAG_PLL1_FILT_PADJ_M0},
2575*4882a593Smuzhiyun {0x0064, CMN_PLL0_INTDIV_M0},
2576*4882a593Smuzhiyun {0x0064, CMN_PLL1_INTDIV_M0},
2577*4882a593Smuzhiyun {0x0002, CMN_PLL0_FRACDIVH_M0},
2578*4882a593Smuzhiyun {0x0002, CMN_PLL1_FRACDIVH_M0},
2579*4882a593Smuzhiyun {0x0044, CMN_PLL0_HIGH_THR_M0},
2580*4882a593Smuzhiyun {0x0044, CMN_PLL1_HIGH_THR_M0},
2581*4882a593Smuzhiyun {0x0002, CMN_PDIAG_PLL0_CTRL_M0},
2582*4882a593Smuzhiyun {0x0002, CMN_PDIAG_PLL1_CTRL_M0},
2583*4882a593Smuzhiyun {0x0001, CMN_PLL0_SS_CTRL1_M0},
2584*4882a593Smuzhiyun {0x0001, CMN_PLL1_SS_CTRL1_M0},
2585*4882a593Smuzhiyun {0x011B, CMN_PLL0_SS_CTRL2_M0},
2586*4882a593Smuzhiyun {0x011B, CMN_PLL1_SS_CTRL2_M0},
2587*4882a593Smuzhiyun {0x006E, CMN_PLL0_SS_CTRL3_M0},
2588*4882a593Smuzhiyun {0x006E, CMN_PLL1_SS_CTRL3_M0},
2589*4882a593Smuzhiyun {0x000E, CMN_PLL0_SS_CTRL4_M0},
2590*4882a593Smuzhiyun {0x000E, CMN_PLL1_SS_CTRL4_M0},
2591*4882a593Smuzhiyun {0x0C5E, CMN_PLL0_VCOCAL_REFTIM_START},
2592*4882a593Smuzhiyun {0x0C5E, CMN_PLL1_VCOCAL_REFTIM_START},
2593*4882a593Smuzhiyun {0x0C56, CMN_PLL0_VCOCAL_PLLCNT_START},
2594*4882a593Smuzhiyun {0x0C56, CMN_PLL1_VCOCAL_PLLCNT_START},
2595*4882a593Smuzhiyun {0x0003, CMN_PLL0_VCOCAL_TCTRL},
2596*4882a593Smuzhiyun {0x0003, CMN_PLL1_VCOCAL_TCTRL},
2597*4882a593Smuzhiyun {0x00C7, CMN_PLL0_LOCK_REFCNT_START},
2598*4882a593Smuzhiyun {0x00C7, CMN_PLL1_LOCK_REFCNT_START},
2599*4882a593Smuzhiyun {0x00C7, CMN_PLL0_LOCK_PLLCNT_START},
2600*4882a593Smuzhiyun {0x00C7, CMN_PLL1_LOCK_PLLCNT_START},
2601*4882a593Smuzhiyun {0x0005, CMN_PLL0_LOCK_PLLCNT_THR},
2602*4882a593Smuzhiyun {0x0005, CMN_PLL1_LOCK_PLLCNT_THR},
2603*4882a593Smuzhiyun {0x8200, CMN_CDIAG_CDB_PWRI_OVRD},
2604*4882a593Smuzhiyun {0x8200, CMN_CDIAG_XCVRC_PWRI_OVRD}
2605*4882a593Smuzhiyun };
2606*4882a593Smuzhiyun
2607*4882a593Smuzhiyun static struct cdns_torrent_vals sl_usb_100_int_ssc_cmn_vals = {
2608*4882a593Smuzhiyun .reg_pairs = sl_usb_100_int_ssc_cmn_regs,
2609*4882a593Smuzhiyun .num_regs = ARRAY_SIZE(sl_usb_100_int_ssc_cmn_regs),
2610*4882a593Smuzhiyun };
2611*4882a593Smuzhiyun
2612*4882a593Smuzhiyun /* PCIe and SGMII/QSGMII Unique SSC link configuration */
2613*4882a593Smuzhiyun static struct cdns_reg_pairs pcie_sgmii_link_cmn_regs[] = {
2614*4882a593Smuzhiyun {0x0003, PHY_PLL_CFG},
2615*4882a593Smuzhiyun {0x0601, CMN_PDIAG_PLL0_CLK_SEL_M0},
2616*4882a593Smuzhiyun {0x0400, CMN_PDIAG_PLL0_CLK_SEL_M1},
2617*4882a593Smuzhiyun {0x0601, CMN_PDIAG_PLL1_CLK_SEL_M0}
2618*4882a593Smuzhiyun };
2619*4882a593Smuzhiyun
2620*4882a593Smuzhiyun static struct cdns_reg_pairs pcie_sgmii_xcvr_diag_ln_regs[] = {
2621*4882a593Smuzhiyun {0x0000, XCVR_DIAG_HSCLK_SEL},
2622*4882a593Smuzhiyun {0x0001, XCVR_DIAG_HSCLK_DIV},
2623*4882a593Smuzhiyun {0x0012, XCVR_DIAG_PLLDRC_CTRL}
2624*4882a593Smuzhiyun };
2625*4882a593Smuzhiyun
2626*4882a593Smuzhiyun static struct cdns_reg_pairs sgmii_pcie_xcvr_diag_ln_regs[] = {
2627*4882a593Smuzhiyun {0x0011, XCVR_DIAG_HSCLK_SEL},
2628*4882a593Smuzhiyun {0x0003, XCVR_DIAG_HSCLK_DIV},
2629*4882a593Smuzhiyun {0x009B, XCVR_DIAG_PLLDRC_CTRL}
2630*4882a593Smuzhiyun };
2631*4882a593Smuzhiyun
2632*4882a593Smuzhiyun static struct cdns_torrent_vals pcie_sgmii_link_cmn_vals = {
2633*4882a593Smuzhiyun .reg_pairs = pcie_sgmii_link_cmn_regs,
2634*4882a593Smuzhiyun .num_regs = ARRAY_SIZE(pcie_sgmii_link_cmn_regs),
2635*4882a593Smuzhiyun };
2636*4882a593Smuzhiyun
2637*4882a593Smuzhiyun static struct cdns_torrent_vals pcie_sgmii_xcvr_diag_ln_vals = {
2638*4882a593Smuzhiyun .reg_pairs = pcie_sgmii_xcvr_diag_ln_regs,
2639*4882a593Smuzhiyun .num_regs = ARRAY_SIZE(pcie_sgmii_xcvr_diag_ln_regs),
2640*4882a593Smuzhiyun };
2641*4882a593Smuzhiyun
2642*4882a593Smuzhiyun static struct cdns_torrent_vals sgmii_pcie_xcvr_diag_ln_vals = {
2643*4882a593Smuzhiyun .reg_pairs = sgmii_pcie_xcvr_diag_ln_regs,
2644*4882a593Smuzhiyun .num_regs = ARRAY_SIZE(sgmii_pcie_xcvr_diag_ln_regs),
2645*4882a593Smuzhiyun };
2646*4882a593Smuzhiyun
2647*4882a593Smuzhiyun /* SGMII 100 MHz Ref clk, no SSC */
2648*4882a593Smuzhiyun static struct cdns_reg_pairs sgmii_100_no_ssc_cmn_regs[] = {
2649*4882a593Smuzhiyun {0x0003, CMN_PLL0_VCOCAL_TCTRL},
2650*4882a593Smuzhiyun {0x0003, CMN_PLL1_VCOCAL_TCTRL},
2651*4882a593Smuzhiyun {0x3700, CMN_DIAG_BIAS_OVRD1},
2652*4882a593Smuzhiyun {0x0008, CMN_TXPUCAL_TUNE},
2653*4882a593Smuzhiyun {0x0008, CMN_TXPDCAL_TUNE}
2654*4882a593Smuzhiyun };
2655*4882a593Smuzhiyun
2656*4882a593Smuzhiyun static struct cdns_reg_pairs sgmii_100_no_ssc_tx_ln_regs[] = {
2657*4882a593Smuzhiyun {0x00F3, TX_PSC_A0},
2658*4882a593Smuzhiyun {0x04A2, TX_PSC_A2},
2659*4882a593Smuzhiyun {0x04A2, TX_PSC_A3},
2660*4882a593Smuzhiyun {0x0000, TX_TXCC_CPOST_MULT_00},
2661*4882a593Smuzhiyun {0x00B3, DRV_DIAG_TX_DRV}
2662*4882a593Smuzhiyun };
2663*4882a593Smuzhiyun
2664*4882a593Smuzhiyun static struct cdns_reg_pairs sgmii_100_no_ssc_rx_ln_regs[] = {
2665*4882a593Smuzhiyun {0x091D, RX_PSC_A0},
2666*4882a593Smuzhiyun {0x0900, RX_PSC_A2},
2667*4882a593Smuzhiyun {0x0100, RX_PSC_A3},
2668*4882a593Smuzhiyun {0x03C7, RX_REE_GCSM1_EQENM_PH1},
2669*4882a593Smuzhiyun {0x01C7, RX_REE_GCSM1_EQENM_PH2},
2670*4882a593Smuzhiyun {0x0000, RX_DIAG_DFE_CTRL},
2671*4882a593Smuzhiyun {0x0019, RX_REE_TAP1_CLIP},
2672*4882a593Smuzhiyun {0x0019, RX_REE_TAP2TON_CLIP},
2673*4882a593Smuzhiyun {0x0098, RX_DIAG_NQST_CTRL},
2674*4882a593Smuzhiyun {0x0C01, RX_DIAG_DFE_AMP_TUNE_2},
2675*4882a593Smuzhiyun {0x0000, RX_DIAG_DFE_AMP_TUNE_3},
2676*4882a593Smuzhiyun {0x0000, RX_DIAG_PI_CAP},
2677*4882a593Smuzhiyun {0x0010, RX_DIAG_PI_RATE},
2678*4882a593Smuzhiyun {0x0001, RX_DIAG_ACYA},
2679*4882a593Smuzhiyun {0x018C, RX_CDRLF_CNFG},
2680*4882a593Smuzhiyun };
2681*4882a593Smuzhiyun
2682*4882a593Smuzhiyun static struct cdns_torrent_vals sgmii_100_no_ssc_cmn_vals = {
2683*4882a593Smuzhiyun .reg_pairs = sgmii_100_no_ssc_cmn_regs,
2684*4882a593Smuzhiyun .num_regs = ARRAY_SIZE(sgmii_100_no_ssc_cmn_regs),
2685*4882a593Smuzhiyun };
2686*4882a593Smuzhiyun
2687*4882a593Smuzhiyun static struct cdns_torrent_vals sgmii_100_no_ssc_tx_ln_vals = {
2688*4882a593Smuzhiyun .reg_pairs = sgmii_100_no_ssc_tx_ln_regs,
2689*4882a593Smuzhiyun .num_regs = ARRAY_SIZE(sgmii_100_no_ssc_tx_ln_regs),
2690*4882a593Smuzhiyun };
2691*4882a593Smuzhiyun
2692*4882a593Smuzhiyun static struct cdns_torrent_vals sgmii_100_no_ssc_rx_ln_vals = {
2693*4882a593Smuzhiyun .reg_pairs = sgmii_100_no_ssc_rx_ln_regs,
2694*4882a593Smuzhiyun .num_regs = ARRAY_SIZE(sgmii_100_no_ssc_rx_ln_regs),
2695*4882a593Smuzhiyun };
2696*4882a593Smuzhiyun
2697*4882a593Smuzhiyun /* SGMII 100 MHz Ref clk, internal SSC */
2698*4882a593Smuzhiyun static struct cdns_reg_pairs sgmii_100_int_ssc_cmn_regs[] = {
2699*4882a593Smuzhiyun {0x0004, CMN_PLL0_DSM_DIAG_M0},
2700*4882a593Smuzhiyun {0x0004, CMN_PLL0_DSM_DIAG_M1},
2701*4882a593Smuzhiyun {0x0004, CMN_PLL1_DSM_DIAG_M0},
2702*4882a593Smuzhiyun {0x0509, CMN_PDIAG_PLL0_CP_PADJ_M0},
2703*4882a593Smuzhiyun {0x0509, CMN_PDIAG_PLL0_CP_PADJ_M1},
2704*4882a593Smuzhiyun {0x0509, CMN_PDIAG_PLL1_CP_PADJ_M0},
2705*4882a593Smuzhiyun {0x0F00, CMN_PDIAG_PLL0_CP_IADJ_M0},
2706*4882a593Smuzhiyun {0x0F00, CMN_PDIAG_PLL0_CP_IADJ_M1},
2707*4882a593Smuzhiyun {0x0F00, CMN_PDIAG_PLL1_CP_IADJ_M0},
2708*4882a593Smuzhiyun {0x0F08, CMN_PDIAG_PLL0_FILT_PADJ_M0},
2709*4882a593Smuzhiyun {0x0F08, CMN_PDIAG_PLL0_FILT_PADJ_M1},
2710*4882a593Smuzhiyun {0x0F08, CMN_PDIAG_PLL1_FILT_PADJ_M0},
2711*4882a593Smuzhiyun {0x0064, CMN_PLL0_INTDIV_M0},
2712*4882a593Smuzhiyun {0x0050, CMN_PLL0_INTDIV_M1},
2713*4882a593Smuzhiyun {0x0064, CMN_PLL1_INTDIV_M0},
2714*4882a593Smuzhiyun {0x0002, CMN_PLL0_FRACDIVH_M0},
2715*4882a593Smuzhiyun {0x0002, CMN_PLL0_FRACDIVH_M1},
2716*4882a593Smuzhiyun {0x0002, CMN_PLL1_FRACDIVH_M0},
2717*4882a593Smuzhiyun {0x0044, CMN_PLL0_HIGH_THR_M0},
2718*4882a593Smuzhiyun {0x0036, CMN_PLL0_HIGH_THR_M1},
2719*4882a593Smuzhiyun {0x0044, CMN_PLL1_HIGH_THR_M0},
2720*4882a593Smuzhiyun {0x0002, CMN_PDIAG_PLL0_CTRL_M0},
2721*4882a593Smuzhiyun {0x0002, CMN_PDIAG_PLL0_CTRL_M1},
2722*4882a593Smuzhiyun {0x0002, CMN_PDIAG_PLL1_CTRL_M0},
2723*4882a593Smuzhiyun {0x0001, CMN_PLL0_SS_CTRL1_M0},
2724*4882a593Smuzhiyun {0x0001, CMN_PLL0_SS_CTRL1_M1},
2725*4882a593Smuzhiyun {0x0001, CMN_PLL1_SS_CTRL1_M0},
2726*4882a593Smuzhiyun {0x011B, CMN_PLL0_SS_CTRL2_M0},
2727*4882a593Smuzhiyun {0x011B, CMN_PLL0_SS_CTRL2_M1},
2728*4882a593Smuzhiyun {0x011B, CMN_PLL1_SS_CTRL2_M0},
2729*4882a593Smuzhiyun {0x006E, CMN_PLL0_SS_CTRL3_M0},
2730*4882a593Smuzhiyun {0x0058, CMN_PLL0_SS_CTRL3_M1},
2731*4882a593Smuzhiyun {0x006E, CMN_PLL1_SS_CTRL3_M0},
2732*4882a593Smuzhiyun {0x000E, CMN_PLL0_SS_CTRL4_M0},
2733*4882a593Smuzhiyun {0x0012, CMN_PLL0_SS_CTRL4_M1},
2734*4882a593Smuzhiyun {0x000E, CMN_PLL1_SS_CTRL4_M0},
2735*4882a593Smuzhiyun {0x0C5E, CMN_PLL0_VCOCAL_REFTIM_START},
2736*4882a593Smuzhiyun {0x0C5E, CMN_PLL1_VCOCAL_REFTIM_START},
2737*4882a593Smuzhiyun {0x0C56, CMN_PLL0_VCOCAL_PLLCNT_START},
2738*4882a593Smuzhiyun {0x0C56, CMN_PLL1_VCOCAL_PLLCNT_START},
2739*4882a593Smuzhiyun {0x0003, CMN_PLL0_VCOCAL_TCTRL},
2740*4882a593Smuzhiyun {0x0003, CMN_PLL1_VCOCAL_TCTRL},
2741*4882a593Smuzhiyun {0x00C7, CMN_PLL0_LOCK_REFCNT_START},
2742*4882a593Smuzhiyun {0x00C7, CMN_PLL1_LOCK_REFCNT_START},
2743*4882a593Smuzhiyun {0x00C7, CMN_PLL0_LOCK_PLLCNT_START},
2744*4882a593Smuzhiyun {0x00C7, CMN_PLL1_LOCK_PLLCNT_START},
2745*4882a593Smuzhiyun {0x0005, CMN_PLL0_LOCK_PLLCNT_THR},
2746*4882a593Smuzhiyun {0x0005, CMN_PLL1_LOCK_PLLCNT_THR},
2747*4882a593Smuzhiyun {0x3700, CMN_DIAG_BIAS_OVRD1},
2748*4882a593Smuzhiyun {0x0008, CMN_TXPUCAL_TUNE},
2749*4882a593Smuzhiyun {0x0008, CMN_TXPDCAL_TUNE}
2750*4882a593Smuzhiyun };
2751*4882a593Smuzhiyun
2752*4882a593Smuzhiyun static struct cdns_torrent_vals sgmii_100_int_ssc_cmn_vals = {
2753*4882a593Smuzhiyun .reg_pairs = sgmii_100_int_ssc_cmn_regs,
2754*4882a593Smuzhiyun .num_regs = ARRAY_SIZE(sgmii_100_int_ssc_cmn_regs),
2755*4882a593Smuzhiyun };
2756*4882a593Smuzhiyun
2757*4882a593Smuzhiyun /* QSGMII 100 MHz Ref clk, no SSC */
2758*4882a593Smuzhiyun static struct cdns_reg_pairs qsgmii_100_no_ssc_cmn_regs[] = {
2759*4882a593Smuzhiyun {0x0003, CMN_PLL0_VCOCAL_TCTRL},
2760*4882a593Smuzhiyun {0x0003, CMN_PLL1_VCOCAL_TCTRL}
2761*4882a593Smuzhiyun };
2762*4882a593Smuzhiyun
2763*4882a593Smuzhiyun static struct cdns_reg_pairs qsgmii_100_no_ssc_tx_ln_regs[] = {
2764*4882a593Smuzhiyun {0x00F3, TX_PSC_A0},
2765*4882a593Smuzhiyun {0x04A2, TX_PSC_A2},
2766*4882a593Smuzhiyun {0x04A2, TX_PSC_A3},
2767*4882a593Smuzhiyun {0x0000, TX_TXCC_CPOST_MULT_00},
2768*4882a593Smuzhiyun {0x0003, DRV_DIAG_TX_DRV}
2769*4882a593Smuzhiyun };
2770*4882a593Smuzhiyun
2771*4882a593Smuzhiyun static struct cdns_reg_pairs qsgmii_100_no_ssc_rx_ln_regs[] = {
2772*4882a593Smuzhiyun {0x091D, RX_PSC_A0},
2773*4882a593Smuzhiyun {0x0900, RX_PSC_A2},
2774*4882a593Smuzhiyun {0x0100, RX_PSC_A3},
2775*4882a593Smuzhiyun {0x03C7, RX_REE_GCSM1_EQENM_PH1},
2776*4882a593Smuzhiyun {0x01C7, RX_REE_GCSM1_EQENM_PH2},
2777*4882a593Smuzhiyun {0x0000, RX_DIAG_DFE_CTRL},
2778*4882a593Smuzhiyun {0x0019, RX_REE_TAP1_CLIP},
2779*4882a593Smuzhiyun {0x0019, RX_REE_TAP2TON_CLIP},
2780*4882a593Smuzhiyun {0x0098, RX_DIAG_NQST_CTRL},
2781*4882a593Smuzhiyun {0x0C01, RX_DIAG_DFE_AMP_TUNE_2},
2782*4882a593Smuzhiyun {0x0000, RX_DIAG_DFE_AMP_TUNE_3},
2783*4882a593Smuzhiyun {0x0000, RX_DIAG_PI_CAP},
2784*4882a593Smuzhiyun {0x0010, RX_DIAG_PI_RATE},
2785*4882a593Smuzhiyun {0x0001, RX_DIAG_ACYA},
2786*4882a593Smuzhiyun {0x018C, RX_CDRLF_CNFG},
2787*4882a593Smuzhiyun };
2788*4882a593Smuzhiyun
2789*4882a593Smuzhiyun static struct cdns_torrent_vals qsgmii_100_no_ssc_cmn_vals = {
2790*4882a593Smuzhiyun .reg_pairs = qsgmii_100_no_ssc_cmn_regs,
2791*4882a593Smuzhiyun .num_regs = ARRAY_SIZE(qsgmii_100_no_ssc_cmn_regs),
2792*4882a593Smuzhiyun };
2793*4882a593Smuzhiyun
2794*4882a593Smuzhiyun static struct cdns_torrent_vals qsgmii_100_no_ssc_tx_ln_vals = {
2795*4882a593Smuzhiyun .reg_pairs = qsgmii_100_no_ssc_tx_ln_regs,
2796*4882a593Smuzhiyun .num_regs = ARRAY_SIZE(qsgmii_100_no_ssc_tx_ln_regs),
2797*4882a593Smuzhiyun };
2798*4882a593Smuzhiyun
2799*4882a593Smuzhiyun static struct cdns_torrent_vals qsgmii_100_no_ssc_rx_ln_vals = {
2800*4882a593Smuzhiyun .reg_pairs = qsgmii_100_no_ssc_rx_ln_regs,
2801*4882a593Smuzhiyun .num_regs = ARRAY_SIZE(qsgmii_100_no_ssc_rx_ln_regs),
2802*4882a593Smuzhiyun };
2803*4882a593Smuzhiyun
2804*4882a593Smuzhiyun /* QSGMII 100 MHz Ref clk, internal SSC */
2805*4882a593Smuzhiyun static struct cdns_reg_pairs qsgmii_100_int_ssc_cmn_regs[] = {
2806*4882a593Smuzhiyun {0x0004, CMN_PLL0_DSM_DIAG_M0},
2807*4882a593Smuzhiyun {0x0004, CMN_PLL0_DSM_DIAG_M1},
2808*4882a593Smuzhiyun {0x0004, CMN_PLL1_DSM_DIAG_M0},
2809*4882a593Smuzhiyun {0x0509, CMN_PDIAG_PLL0_CP_PADJ_M0},
2810*4882a593Smuzhiyun {0x0509, CMN_PDIAG_PLL0_CP_PADJ_M1},
2811*4882a593Smuzhiyun {0x0509, CMN_PDIAG_PLL1_CP_PADJ_M0},
2812*4882a593Smuzhiyun {0x0F00, CMN_PDIAG_PLL0_CP_IADJ_M0},
2813*4882a593Smuzhiyun {0x0F00, CMN_PDIAG_PLL0_CP_IADJ_M1},
2814*4882a593Smuzhiyun {0x0F00, CMN_PDIAG_PLL1_CP_IADJ_M0},
2815*4882a593Smuzhiyun {0x0F08, CMN_PDIAG_PLL0_FILT_PADJ_M0},
2816*4882a593Smuzhiyun {0x0F08, CMN_PDIAG_PLL0_FILT_PADJ_M1},
2817*4882a593Smuzhiyun {0x0F08, CMN_PDIAG_PLL1_FILT_PADJ_M0},
2818*4882a593Smuzhiyun {0x0064, CMN_PLL0_INTDIV_M0},
2819*4882a593Smuzhiyun {0x0050, CMN_PLL0_INTDIV_M1},
2820*4882a593Smuzhiyun {0x0064, CMN_PLL1_INTDIV_M0},
2821*4882a593Smuzhiyun {0x0002, CMN_PLL0_FRACDIVH_M0},
2822*4882a593Smuzhiyun {0x0002, CMN_PLL0_FRACDIVH_M1},
2823*4882a593Smuzhiyun {0x0002, CMN_PLL1_FRACDIVH_M0},
2824*4882a593Smuzhiyun {0x0044, CMN_PLL0_HIGH_THR_M0},
2825*4882a593Smuzhiyun {0x0036, CMN_PLL0_HIGH_THR_M1},
2826*4882a593Smuzhiyun {0x0044, CMN_PLL1_HIGH_THR_M0},
2827*4882a593Smuzhiyun {0x0002, CMN_PDIAG_PLL0_CTRL_M0},
2828*4882a593Smuzhiyun {0x0002, CMN_PDIAG_PLL0_CTRL_M1},
2829*4882a593Smuzhiyun {0x0002, CMN_PDIAG_PLL1_CTRL_M0},
2830*4882a593Smuzhiyun {0x0001, CMN_PLL0_SS_CTRL1_M0},
2831*4882a593Smuzhiyun {0x0001, CMN_PLL0_SS_CTRL1_M1},
2832*4882a593Smuzhiyun {0x0001, CMN_PLL1_SS_CTRL1_M0},
2833*4882a593Smuzhiyun {0x011B, CMN_PLL0_SS_CTRL2_M0},
2834*4882a593Smuzhiyun {0x011B, CMN_PLL0_SS_CTRL2_M1},
2835*4882a593Smuzhiyun {0x011B, CMN_PLL1_SS_CTRL2_M0},
2836*4882a593Smuzhiyun {0x006E, CMN_PLL0_SS_CTRL3_M0},
2837*4882a593Smuzhiyun {0x0058, CMN_PLL0_SS_CTRL3_M1},
2838*4882a593Smuzhiyun {0x006E, CMN_PLL1_SS_CTRL3_M0},
2839*4882a593Smuzhiyun {0x000E, CMN_PLL0_SS_CTRL4_M0},
2840*4882a593Smuzhiyun {0x0012, CMN_PLL0_SS_CTRL4_M1},
2841*4882a593Smuzhiyun {0x000E, CMN_PLL1_SS_CTRL4_M0},
2842*4882a593Smuzhiyun {0x0C5E, CMN_PLL0_VCOCAL_REFTIM_START},
2843*4882a593Smuzhiyun {0x0C5E, CMN_PLL1_VCOCAL_REFTIM_START},
2844*4882a593Smuzhiyun {0x0C56, CMN_PLL0_VCOCAL_PLLCNT_START},
2845*4882a593Smuzhiyun {0x0C56, CMN_PLL1_VCOCAL_PLLCNT_START},
2846*4882a593Smuzhiyun {0x0003, CMN_PLL0_VCOCAL_TCTRL},
2847*4882a593Smuzhiyun {0x0003, CMN_PLL1_VCOCAL_TCTRL},
2848*4882a593Smuzhiyun {0x00C7, CMN_PLL0_LOCK_REFCNT_START},
2849*4882a593Smuzhiyun {0x00C7, CMN_PLL1_LOCK_REFCNT_START},
2850*4882a593Smuzhiyun {0x00C7, CMN_PLL0_LOCK_PLLCNT_START},
2851*4882a593Smuzhiyun {0x00C7, CMN_PLL1_LOCK_PLLCNT_START},
2852*4882a593Smuzhiyun {0x0005, CMN_PLL0_LOCK_PLLCNT_THR},
2853*4882a593Smuzhiyun {0x0005, CMN_PLL1_LOCK_PLLCNT_THR}
2854*4882a593Smuzhiyun };
2855*4882a593Smuzhiyun
2856*4882a593Smuzhiyun static struct cdns_torrent_vals qsgmii_100_int_ssc_cmn_vals = {
2857*4882a593Smuzhiyun .reg_pairs = qsgmii_100_int_ssc_cmn_regs,
2858*4882a593Smuzhiyun .num_regs = ARRAY_SIZE(qsgmii_100_int_ssc_cmn_regs),
2859*4882a593Smuzhiyun };
2860*4882a593Smuzhiyun
2861*4882a593Smuzhiyun /* Single SGMII/QSGMII link configuration */
2862*4882a593Smuzhiyun static struct cdns_reg_pairs sl_sgmii_link_cmn_regs[] = {
2863*4882a593Smuzhiyun {0x0000, PHY_PLL_CFG},
2864*4882a593Smuzhiyun {0x0601, CMN_PDIAG_PLL0_CLK_SEL_M0}
2865*4882a593Smuzhiyun };
2866*4882a593Smuzhiyun
2867*4882a593Smuzhiyun static struct cdns_reg_pairs sl_sgmii_xcvr_diag_ln_regs[] = {
2868*4882a593Smuzhiyun {0x0000, XCVR_DIAG_HSCLK_SEL},
2869*4882a593Smuzhiyun {0x0003, XCVR_DIAG_HSCLK_DIV},
2870*4882a593Smuzhiyun {0x0013, XCVR_DIAG_PLLDRC_CTRL}
2871*4882a593Smuzhiyun };
2872*4882a593Smuzhiyun
2873*4882a593Smuzhiyun static struct cdns_torrent_vals sl_sgmii_link_cmn_vals = {
2874*4882a593Smuzhiyun .reg_pairs = sl_sgmii_link_cmn_regs,
2875*4882a593Smuzhiyun .num_regs = ARRAY_SIZE(sl_sgmii_link_cmn_regs),
2876*4882a593Smuzhiyun };
2877*4882a593Smuzhiyun
2878*4882a593Smuzhiyun static struct cdns_torrent_vals sl_sgmii_xcvr_diag_ln_vals = {
2879*4882a593Smuzhiyun .reg_pairs = sl_sgmii_xcvr_diag_ln_regs,
2880*4882a593Smuzhiyun .num_regs = ARRAY_SIZE(sl_sgmii_xcvr_diag_ln_regs),
2881*4882a593Smuzhiyun };
2882*4882a593Smuzhiyun
2883*4882a593Smuzhiyun /* Multi link PCIe, 100 MHz Ref clk, internal SSC */
2884*4882a593Smuzhiyun static struct cdns_reg_pairs pcie_100_int_ssc_cmn_regs[] = {
2885*4882a593Smuzhiyun {0x0004, CMN_PLL0_DSM_DIAG_M0},
2886*4882a593Smuzhiyun {0x0004, CMN_PLL0_DSM_DIAG_M1},
2887*4882a593Smuzhiyun {0x0004, CMN_PLL1_DSM_DIAG_M0},
2888*4882a593Smuzhiyun {0x0509, CMN_PDIAG_PLL0_CP_PADJ_M0},
2889*4882a593Smuzhiyun {0x0509, CMN_PDIAG_PLL0_CP_PADJ_M1},
2890*4882a593Smuzhiyun {0x0509, CMN_PDIAG_PLL1_CP_PADJ_M0},
2891*4882a593Smuzhiyun {0x0F00, CMN_PDIAG_PLL0_CP_IADJ_M0},
2892*4882a593Smuzhiyun {0x0F00, CMN_PDIAG_PLL0_CP_IADJ_M1},
2893*4882a593Smuzhiyun {0x0F00, CMN_PDIAG_PLL1_CP_IADJ_M0},
2894*4882a593Smuzhiyun {0x0F08, CMN_PDIAG_PLL0_FILT_PADJ_M0},
2895*4882a593Smuzhiyun {0x0F08, CMN_PDIAG_PLL0_FILT_PADJ_M1},
2896*4882a593Smuzhiyun {0x0F08, CMN_PDIAG_PLL1_FILT_PADJ_M0},
2897*4882a593Smuzhiyun {0x0064, CMN_PLL0_INTDIV_M0},
2898*4882a593Smuzhiyun {0x0050, CMN_PLL0_INTDIV_M1},
2899*4882a593Smuzhiyun {0x0064, CMN_PLL1_INTDIV_M0},
2900*4882a593Smuzhiyun {0x0002, CMN_PLL0_FRACDIVH_M0},
2901*4882a593Smuzhiyun {0x0002, CMN_PLL0_FRACDIVH_M1},
2902*4882a593Smuzhiyun {0x0002, CMN_PLL1_FRACDIVH_M0},
2903*4882a593Smuzhiyun {0x0044, CMN_PLL0_HIGH_THR_M0},
2904*4882a593Smuzhiyun {0x0036, CMN_PLL0_HIGH_THR_M1},
2905*4882a593Smuzhiyun {0x0044, CMN_PLL1_HIGH_THR_M0},
2906*4882a593Smuzhiyun {0x0002, CMN_PDIAG_PLL0_CTRL_M0},
2907*4882a593Smuzhiyun {0x0002, CMN_PDIAG_PLL0_CTRL_M1},
2908*4882a593Smuzhiyun {0x0002, CMN_PDIAG_PLL1_CTRL_M0},
2909*4882a593Smuzhiyun {0x0001, CMN_PLL0_SS_CTRL1_M0},
2910*4882a593Smuzhiyun {0x0001, CMN_PLL0_SS_CTRL1_M1},
2911*4882a593Smuzhiyun {0x0001, CMN_PLL1_SS_CTRL1_M0},
2912*4882a593Smuzhiyun {0x011B, CMN_PLL0_SS_CTRL2_M0},
2913*4882a593Smuzhiyun {0x011B, CMN_PLL0_SS_CTRL2_M1},
2914*4882a593Smuzhiyun {0x011B, CMN_PLL1_SS_CTRL2_M0},
2915*4882a593Smuzhiyun {0x006E, CMN_PLL0_SS_CTRL3_M0},
2916*4882a593Smuzhiyun {0x0058, CMN_PLL0_SS_CTRL3_M1},
2917*4882a593Smuzhiyun {0x006E, CMN_PLL1_SS_CTRL3_M0},
2918*4882a593Smuzhiyun {0x000E, CMN_PLL0_SS_CTRL4_M0},
2919*4882a593Smuzhiyun {0x0012, CMN_PLL0_SS_CTRL4_M1},
2920*4882a593Smuzhiyun {0x000E, CMN_PLL1_SS_CTRL4_M0},
2921*4882a593Smuzhiyun {0x0C5E, CMN_PLL0_VCOCAL_REFTIM_START},
2922*4882a593Smuzhiyun {0x0C5E, CMN_PLL1_VCOCAL_REFTIM_START},
2923*4882a593Smuzhiyun {0x0C56, CMN_PLL0_VCOCAL_PLLCNT_START},
2924*4882a593Smuzhiyun {0x0C56, CMN_PLL1_VCOCAL_PLLCNT_START},
2925*4882a593Smuzhiyun {0x0003, CMN_PLL0_VCOCAL_TCTRL},
2926*4882a593Smuzhiyun {0x0003, CMN_PLL1_VCOCAL_TCTRL},
2927*4882a593Smuzhiyun {0x00C7, CMN_PLL0_LOCK_REFCNT_START},
2928*4882a593Smuzhiyun {0x00C7, CMN_PLL1_LOCK_REFCNT_START},
2929*4882a593Smuzhiyun {0x00C7, CMN_PLL0_LOCK_PLLCNT_START},
2930*4882a593Smuzhiyun {0x00C7, CMN_PLL1_LOCK_PLLCNT_START},
2931*4882a593Smuzhiyun {0x0005, CMN_PLL0_LOCK_PLLCNT_THR},
2932*4882a593Smuzhiyun {0x0005, CMN_PLL1_LOCK_PLLCNT_THR}
2933*4882a593Smuzhiyun };
2934*4882a593Smuzhiyun
2935*4882a593Smuzhiyun static struct cdns_torrent_vals pcie_100_int_ssc_cmn_vals = {
2936*4882a593Smuzhiyun .reg_pairs = pcie_100_int_ssc_cmn_regs,
2937*4882a593Smuzhiyun .num_regs = ARRAY_SIZE(pcie_100_int_ssc_cmn_regs),
2938*4882a593Smuzhiyun };
2939*4882a593Smuzhiyun
2940*4882a593Smuzhiyun /* Single link PCIe, 100 MHz Ref clk, internal SSC */
2941*4882a593Smuzhiyun static struct cdns_reg_pairs sl_pcie_100_int_ssc_cmn_regs[] = {
2942*4882a593Smuzhiyun {0x0004, CMN_PLL0_DSM_DIAG_M0},
2943*4882a593Smuzhiyun {0x0004, CMN_PLL0_DSM_DIAG_M1},
2944*4882a593Smuzhiyun {0x0004, CMN_PLL1_DSM_DIAG_M0},
2945*4882a593Smuzhiyun {0x0509, CMN_PDIAG_PLL0_CP_PADJ_M0},
2946*4882a593Smuzhiyun {0x0509, CMN_PDIAG_PLL0_CP_PADJ_M1},
2947*4882a593Smuzhiyun {0x0509, CMN_PDIAG_PLL1_CP_PADJ_M0},
2948*4882a593Smuzhiyun {0x0F00, CMN_PDIAG_PLL0_CP_IADJ_M0},
2949*4882a593Smuzhiyun {0x0F00, CMN_PDIAG_PLL0_CP_IADJ_M1},
2950*4882a593Smuzhiyun {0x0F00, CMN_PDIAG_PLL1_CP_IADJ_M0},
2951*4882a593Smuzhiyun {0x0F08, CMN_PDIAG_PLL0_FILT_PADJ_M0},
2952*4882a593Smuzhiyun {0x0F08, CMN_PDIAG_PLL0_FILT_PADJ_M1},
2953*4882a593Smuzhiyun {0x0F08, CMN_PDIAG_PLL1_FILT_PADJ_M0},
2954*4882a593Smuzhiyun {0x0064, CMN_PLL0_INTDIV_M0},
2955*4882a593Smuzhiyun {0x0050, CMN_PLL0_INTDIV_M1},
2956*4882a593Smuzhiyun {0x0050, CMN_PLL1_INTDIV_M0},
2957*4882a593Smuzhiyun {0x0002, CMN_PLL0_FRACDIVH_M0},
2958*4882a593Smuzhiyun {0x0002, CMN_PLL0_FRACDIVH_M1},
2959*4882a593Smuzhiyun {0x0002, CMN_PLL1_FRACDIVH_M0},
2960*4882a593Smuzhiyun {0x0044, CMN_PLL0_HIGH_THR_M0},
2961*4882a593Smuzhiyun {0x0036, CMN_PLL0_HIGH_THR_M1},
2962*4882a593Smuzhiyun {0x0036, CMN_PLL1_HIGH_THR_M0},
2963*4882a593Smuzhiyun {0x0002, CMN_PDIAG_PLL0_CTRL_M0},
2964*4882a593Smuzhiyun {0x0002, CMN_PDIAG_PLL0_CTRL_M1},
2965*4882a593Smuzhiyun {0x0002, CMN_PDIAG_PLL1_CTRL_M0},
2966*4882a593Smuzhiyun {0x0001, CMN_PLL0_SS_CTRL1_M0},
2967*4882a593Smuzhiyun {0x0001, CMN_PLL0_SS_CTRL1_M1},
2968*4882a593Smuzhiyun {0x0001, CMN_PLL1_SS_CTRL1_M0},
2969*4882a593Smuzhiyun {0x011B, CMN_PLL0_SS_CTRL2_M0},
2970*4882a593Smuzhiyun {0x011B, CMN_PLL0_SS_CTRL2_M1},
2971*4882a593Smuzhiyun {0x011B, CMN_PLL1_SS_CTRL2_M0},
2972*4882a593Smuzhiyun {0x006E, CMN_PLL0_SS_CTRL3_M0},
2973*4882a593Smuzhiyun {0x0058, CMN_PLL0_SS_CTRL3_M1},
2974*4882a593Smuzhiyun {0x0058, CMN_PLL1_SS_CTRL3_M0},
2975*4882a593Smuzhiyun {0x000E, CMN_PLL0_SS_CTRL4_M0},
2976*4882a593Smuzhiyun {0x0012, CMN_PLL0_SS_CTRL4_M1},
2977*4882a593Smuzhiyun {0x0012, CMN_PLL1_SS_CTRL4_M0},
2978*4882a593Smuzhiyun {0x0C5E, CMN_PLL0_VCOCAL_REFTIM_START},
2979*4882a593Smuzhiyun {0x0C5E, CMN_PLL1_VCOCAL_REFTIM_START},
2980*4882a593Smuzhiyun {0x0C56, CMN_PLL0_VCOCAL_PLLCNT_START},
2981*4882a593Smuzhiyun {0x0C56, CMN_PLL1_VCOCAL_PLLCNT_START},
2982*4882a593Smuzhiyun {0x0003, CMN_PLL0_VCOCAL_TCTRL},
2983*4882a593Smuzhiyun {0x0003, CMN_PLL1_VCOCAL_TCTRL},
2984*4882a593Smuzhiyun {0x00C7, CMN_PLL0_LOCK_REFCNT_START},
2985*4882a593Smuzhiyun {0x00C7, CMN_PLL1_LOCK_REFCNT_START},
2986*4882a593Smuzhiyun {0x00C7, CMN_PLL0_LOCK_PLLCNT_START},
2987*4882a593Smuzhiyun {0x00C7, CMN_PLL1_LOCK_PLLCNT_START},
2988*4882a593Smuzhiyun {0x0005, CMN_PLL0_LOCK_PLLCNT_THR},
2989*4882a593Smuzhiyun {0x0005, CMN_PLL1_LOCK_PLLCNT_THR}
2990*4882a593Smuzhiyun };
2991*4882a593Smuzhiyun
2992*4882a593Smuzhiyun static struct cdns_torrent_vals sl_pcie_100_int_ssc_cmn_vals = {
2993*4882a593Smuzhiyun .reg_pairs = sl_pcie_100_int_ssc_cmn_regs,
2994*4882a593Smuzhiyun .num_regs = ARRAY_SIZE(sl_pcie_100_int_ssc_cmn_regs),
2995*4882a593Smuzhiyun };
2996*4882a593Smuzhiyun
2997*4882a593Smuzhiyun /* PCIe, 100 MHz Ref clk, no SSC & external SSC */
2998*4882a593Smuzhiyun static struct cdns_reg_pairs pcie_100_ext_no_ssc_cmn_regs[] = {
2999*4882a593Smuzhiyun {0x0003, CMN_PLL0_VCOCAL_TCTRL},
3000*4882a593Smuzhiyun {0x0003, CMN_PLL1_VCOCAL_TCTRL}
3001*4882a593Smuzhiyun };
3002*4882a593Smuzhiyun
3003*4882a593Smuzhiyun static struct cdns_reg_pairs pcie_100_ext_no_ssc_rx_ln_regs[] = {
3004*4882a593Smuzhiyun {0x0019, RX_REE_TAP1_CLIP},
3005*4882a593Smuzhiyun {0x0019, RX_REE_TAP2TON_CLIP},
3006*4882a593Smuzhiyun {0x0001, RX_DIAG_ACYA}
3007*4882a593Smuzhiyun };
3008*4882a593Smuzhiyun
3009*4882a593Smuzhiyun static struct cdns_torrent_vals pcie_100_no_ssc_cmn_vals = {
3010*4882a593Smuzhiyun .reg_pairs = pcie_100_ext_no_ssc_cmn_regs,
3011*4882a593Smuzhiyun .num_regs = ARRAY_SIZE(pcie_100_ext_no_ssc_cmn_regs),
3012*4882a593Smuzhiyun };
3013*4882a593Smuzhiyun
3014*4882a593Smuzhiyun static struct cdns_torrent_vals pcie_100_no_ssc_rx_ln_vals = {
3015*4882a593Smuzhiyun .reg_pairs = pcie_100_ext_no_ssc_rx_ln_regs,
3016*4882a593Smuzhiyun .num_regs = ARRAY_SIZE(pcie_100_ext_no_ssc_rx_ln_regs),
3017*4882a593Smuzhiyun };
3018*4882a593Smuzhiyun
3019*4882a593Smuzhiyun static const struct cdns_torrent_data cdns_map_torrent = {
3020*4882a593Smuzhiyun .block_offset_shift = 0x2,
3021*4882a593Smuzhiyun .reg_offset_shift = 0x2,
3022*4882a593Smuzhiyun .link_cmn_vals = {
3023*4882a593Smuzhiyun [TYPE_PCIE] = {
3024*4882a593Smuzhiyun [TYPE_NONE] = {
3025*4882a593Smuzhiyun [NO_SSC] = NULL,
3026*4882a593Smuzhiyun [EXTERNAL_SSC] = NULL,
3027*4882a593Smuzhiyun [INTERNAL_SSC] = NULL,
3028*4882a593Smuzhiyun },
3029*4882a593Smuzhiyun [TYPE_SGMII] = {
3030*4882a593Smuzhiyun [NO_SSC] = &pcie_sgmii_link_cmn_vals,
3031*4882a593Smuzhiyun [EXTERNAL_SSC] = &pcie_sgmii_link_cmn_vals,
3032*4882a593Smuzhiyun [INTERNAL_SSC] = &pcie_sgmii_link_cmn_vals,
3033*4882a593Smuzhiyun },
3034*4882a593Smuzhiyun [TYPE_QSGMII] = {
3035*4882a593Smuzhiyun [NO_SSC] = &pcie_sgmii_link_cmn_vals,
3036*4882a593Smuzhiyun [EXTERNAL_SSC] = &pcie_sgmii_link_cmn_vals,
3037*4882a593Smuzhiyun [INTERNAL_SSC] = &pcie_sgmii_link_cmn_vals,
3038*4882a593Smuzhiyun },
3039*4882a593Smuzhiyun [TYPE_USB] = {
3040*4882a593Smuzhiyun [NO_SSC] = &pcie_usb_link_cmn_vals,
3041*4882a593Smuzhiyun [EXTERNAL_SSC] = &pcie_usb_link_cmn_vals,
3042*4882a593Smuzhiyun [INTERNAL_SSC] = &pcie_usb_link_cmn_vals,
3043*4882a593Smuzhiyun },
3044*4882a593Smuzhiyun },
3045*4882a593Smuzhiyun [TYPE_SGMII] = {
3046*4882a593Smuzhiyun [TYPE_NONE] = {
3047*4882a593Smuzhiyun [NO_SSC] = &sl_sgmii_link_cmn_vals,
3048*4882a593Smuzhiyun },
3049*4882a593Smuzhiyun [TYPE_PCIE] = {
3050*4882a593Smuzhiyun [NO_SSC] = &pcie_sgmii_link_cmn_vals,
3051*4882a593Smuzhiyun [EXTERNAL_SSC] = &pcie_sgmii_link_cmn_vals,
3052*4882a593Smuzhiyun [INTERNAL_SSC] = &pcie_sgmii_link_cmn_vals,
3053*4882a593Smuzhiyun },
3054*4882a593Smuzhiyun [TYPE_USB] = {
3055*4882a593Smuzhiyun [NO_SSC] = &usb_sgmii_link_cmn_vals,
3056*4882a593Smuzhiyun [EXTERNAL_SSC] = &usb_sgmii_link_cmn_vals,
3057*4882a593Smuzhiyun [INTERNAL_SSC] = &usb_sgmii_link_cmn_vals,
3058*4882a593Smuzhiyun },
3059*4882a593Smuzhiyun },
3060*4882a593Smuzhiyun [TYPE_QSGMII] = {
3061*4882a593Smuzhiyun [TYPE_NONE] = {
3062*4882a593Smuzhiyun [NO_SSC] = &sl_sgmii_link_cmn_vals,
3063*4882a593Smuzhiyun },
3064*4882a593Smuzhiyun [TYPE_PCIE] = {
3065*4882a593Smuzhiyun [NO_SSC] = &pcie_sgmii_link_cmn_vals,
3066*4882a593Smuzhiyun [EXTERNAL_SSC] = &pcie_sgmii_link_cmn_vals,
3067*4882a593Smuzhiyun [INTERNAL_SSC] = &pcie_sgmii_link_cmn_vals,
3068*4882a593Smuzhiyun },
3069*4882a593Smuzhiyun [TYPE_USB] = {
3070*4882a593Smuzhiyun [NO_SSC] = &usb_sgmii_link_cmn_vals,
3071*4882a593Smuzhiyun [EXTERNAL_SSC] = &usb_sgmii_link_cmn_vals,
3072*4882a593Smuzhiyun [INTERNAL_SSC] = &usb_sgmii_link_cmn_vals,
3073*4882a593Smuzhiyun },
3074*4882a593Smuzhiyun },
3075*4882a593Smuzhiyun [TYPE_USB] = {
3076*4882a593Smuzhiyun [TYPE_NONE] = {
3077*4882a593Smuzhiyun [NO_SSC] = &sl_usb_link_cmn_vals,
3078*4882a593Smuzhiyun [EXTERNAL_SSC] = &sl_usb_link_cmn_vals,
3079*4882a593Smuzhiyun [INTERNAL_SSC] = &sl_usb_link_cmn_vals,
3080*4882a593Smuzhiyun },
3081*4882a593Smuzhiyun [TYPE_PCIE] = {
3082*4882a593Smuzhiyun [NO_SSC] = &pcie_usb_link_cmn_vals,
3083*4882a593Smuzhiyun [EXTERNAL_SSC] = &pcie_usb_link_cmn_vals,
3084*4882a593Smuzhiyun [INTERNAL_SSC] = &pcie_usb_link_cmn_vals,
3085*4882a593Smuzhiyun },
3086*4882a593Smuzhiyun [TYPE_SGMII] = {
3087*4882a593Smuzhiyun [NO_SSC] = &usb_sgmii_link_cmn_vals,
3088*4882a593Smuzhiyun [EXTERNAL_SSC] = &usb_sgmii_link_cmn_vals,
3089*4882a593Smuzhiyun [INTERNAL_SSC] = &usb_sgmii_link_cmn_vals,
3090*4882a593Smuzhiyun },
3091*4882a593Smuzhiyun [TYPE_QSGMII] = {
3092*4882a593Smuzhiyun [NO_SSC] = &usb_sgmii_link_cmn_vals,
3093*4882a593Smuzhiyun [EXTERNAL_SSC] = &usb_sgmii_link_cmn_vals,
3094*4882a593Smuzhiyun [INTERNAL_SSC] = &usb_sgmii_link_cmn_vals,
3095*4882a593Smuzhiyun },
3096*4882a593Smuzhiyun },
3097*4882a593Smuzhiyun },
3098*4882a593Smuzhiyun .xcvr_diag_vals = {
3099*4882a593Smuzhiyun [TYPE_PCIE] = {
3100*4882a593Smuzhiyun [TYPE_NONE] = {
3101*4882a593Smuzhiyun [NO_SSC] = NULL,
3102*4882a593Smuzhiyun [EXTERNAL_SSC] = NULL,
3103*4882a593Smuzhiyun [INTERNAL_SSC] = NULL,
3104*4882a593Smuzhiyun },
3105*4882a593Smuzhiyun [TYPE_SGMII] = {
3106*4882a593Smuzhiyun [NO_SSC] = &pcie_sgmii_xcvr_diag_ln_vals,
3107*4882a593Smuzhiyun [EXTERNAL_SSC] = &pcie_sgmii_xcvr_diag_ln_vals,
3108*4882a593Smuzhiyun [INTERNAL_SSC] = &pcie_sgmii_xcvr_diag_ln_vals,
3109*4882a593Smuzhiyun },
3110*4882a593Smuzhiyun [TYPE_QSGMII] = {
3111*4882a593Smuzhiyun [NO_SSC] = &pcie_sgmii_xcvr_diag_ln_vals,
3112*4882a593Smuzhiyun [EXTERNAL_SSC] = &pcie_sgmii_xcvr_diag_ln_vals,
3113*4882a593Smuzhiyun [INTERNAL_SSC] = &pcie_sgmii_xcvr_diag_ln_vals,
3114*4882a593Smuzhiyun },
3115*4882a593Smuzhiyun [TYPE_USB] = {
3116*4882a593Smuzhiyun [NO_SSC] = &pcie_usb_xcvr_diag_ln_vals,
3117*4882a593Smuzhiyun [EXTERNAL_SSC] = &pcie_usb_xcvr_diag_ln_vals,
3118*4882a593Smuzhiyun [INTERNAL_SSC] = &pcie_usb_xcvr_diag_ln_vals,
3119*4882a593Smuzhiyun },
3120*4882a593Smuzhiyun },
3121*4882a593Smuzhiyun [TYPE_SGMII] = {
3122*4882a593Smuzhiyun [TYPE_NONE] = {
3123*4882a593Smuzhiyun [NO_SSC] = &sl_sgmii_xcvr_diag_ln_vals,
3124*4882a593Smuzhiyun },
3125*4882a593Smuzhiyun [TYPE_PCIE] = {
3126*4882a593Smuzhiyun [NO_SSC] = &sgmii_pcie_xcvr_diag_ln_vals,
3127*4882a593Smuzhiyun [EXTERNAL_SSC] = &sgmii_pcie_xcvr_diag_ln_vals,
3128*4882a593Smuzhiyun [INTERNAL_SSC] = &sgmii_pcie_xcvr_diag_ln_vals,
3129*4882a593Smuzhiyun },
3130*4882a593Smuzhiyun [TYPE_USB] = {
3131*4882a593Smuzhiyun [NO_SSC] = &sgmii_usb_xcvr_diag_ln_vals,
3132*4882a593Smuzhiyun [EXTERNAL_SSC] = &sgmii_usb_xcvr_diag_ln_vals,
3133*4882a593Smuzhiyun [INTERNAL_SSC] = &sgmii_usb_xcvr_diag_ln_vals,
3134*4882a593Smuzhiyun },
3135*4882a593Smuzhiyun },
3136*4882a593Smuzhiyun [TYPE_QSGMII] = {
3137*4882a593Smuzhiyun [TYPE_NONE] = {
3138*4882a593Smuzhiyun [NO_SSC] = &sl_sgmii_xcvr_diag_ln_vals,
3139*4882a593Smuzhiyun },
3140*4882a593Smuzhiyun [TYPE_PCIE] = {
3141*4882a593Smuzhiyun [NO_SSC] = &sgmii_pcie_xcvr_diag_ln_vals,
3142*4882a593Smuzhiyun [EXTERNAL_SSC] = &sgmii_pcie_xcvr_diag_ln_vals,
3143*4882a593Smuzhiyun [INTERNAL_SSC] = &sgmii_pcie_xcvr_diag_ln_vals,
3144*4882a593Smuzhiyun },
3145*4882a593Smuzhiyun [TYPE_USB] = {
3146*4882a593Smuzhiyun [NO_SSC] = &sgmii_usb_xcvr_diag_ln_vals,
3147*4882a593Smuzhiyun [EXTERNAL_SSC] = &sgmii_usb_xcvr_diag_ln_vals,
3148*4882a593Smuzhiyun [INTERNAL_SSC] = &sgmii_usb_xcvr_diag_ln_vals,
3149*4882a593Smuzhiyun },
3150*4882a593Smuzhiyun },
3151*4882a593Smuzhiyun [TYPE_USB] = {
3152*4882a593Smuzhiyun [TYPE_NONE] = {
3153*4882a593Smuzhiyun [NO_SSC] = &sl_usb_xcvr_diag_ln_vals,
3154*4882a593Smuzhiyun [EXTERNAL_SSC] = &sl_usb_xcvr_diag_ln_vals,
3155*4882a593Smuzhiyun [INTERNAL_SSC] = &sl_usb_xcvr_diag_ln_vals,
3156*4882a593Smuzhiyun },
3157*4882a593Smuzhiyun [TYPE_PCIE] = {
3158*4882a593Smuzhiyun [NO_SSC] = &usb_pcie_xcvr_diag_ln_vals,
3159*4882a593Smuzhiyun [EXTERNAL_SSC] = &usb_pcie_xcvr_diag_ln_vals,
3160*4882a593Smuzhiyun [INTERNAL_SSC] = &usb_pcie_xcvr_diag_ln_vals,
3161*4882a593Smuzhiyun },
3162*4882a593Smuzhiyun [TYPE_SGMII] = {
3163*4882a593Smuzhiyun [NO_SSC] = &usb_sgmii_xcvr_diag_ln_vals,
3164*4882a593Smuzhiyun [EXTERNAL_SSC] = &usb_sgmii_xcvr_diag_ln_vals,
3165*4882a593Smuzhiyun [INTERNAL_SSC] = &usb_sgmii_xcvr_diag_ln_vals,
3166*4882a593Smuzhiyun },
3167*4882a593Smuzhiyun [TYPE_QSGMII] = {
3168*4882a593Smuzhiyun [NO_SSC] = &usb_sgmii_xcvr_diag_ln_vals,
3169*4882a593Smuzhiyun [EXTERNAL_SSC] = &usb_sgmii_xcvr_diag_ln_vals,
3170*4882a593Smuzhiyun [INTERNAL_SSC] = &usb_sgmii_xcvr_diag_ln_vals,
3171*4882a593Smuzhiyun },
3172*4882a593Smuzhiyun },
3173*4882a593Smuzhiyun },
3174*4882a593Smuzhiyun .pcs_cmn_vals = {
3175*4882a593Smuzhiyun [TYPE_USB] = {
3176*4882a593Smuzhiyun [TYPE_NONE] = {
3177*4882a593Smuzhiyun [NO_SSC] = &usb_phy_pcs_cmn_vals,
3178*4882a593Smuzhiyun [EXTERNAL_SSC] = &usb_phy_pcs_cmn_vals,
3179*4882a593Smuzhiyun [INTERNAL_SSC] = &usb_phy_pcs_cmn_vals,
3180*4882a593Smuzhiyun },
3181*4882a593Smuzhiyun [TYPE_PCIE] = {
3182*4882a593Smuzhiyun [NO_SSC] = &usb_phy_pcs_cmn_vals,
3183*4882a593Smuzhiyun [EXTERNAL_SSC] = &usb_phy_pcs_cmn_vals,
3184*4882a593Smuzhiyun [INTERNAL_SSC] = &usb_phy_pcs_cmn_vals,
3185*4882a593Smuzhiyun },
3186*4882a593Smuzhiyun [TYPE_SGMII] = {
3187*4882a593Smuzhiyun [NO_SSC] = &usb_phy_pcs_cmn_vals,
3188*4882a593Smuzhiyun [EXTERNAL_SSC] = &usb_phy_pcs_cmn_vals,
3189*4882a593Smuzhiyun [INTERNAL_SSC] = &usb_phy_pcs_cmn_vals,
3190*4882a593Smuzhiyun },
3191*4882a593Smuzhiyun [TYPE_QSGMII] = {
3192*4882a593Smuzhiyun [NO_SSC] = &usb_phy_pcs_cmn_vals,
3193*4882a593Smuzhiyun [EXTERNAL_SSC] = &usb_phy_pcs_cmn_vals,
3194*4882a593Smuzhiyun [INTERNAL_SSC] = &usb_phy_pcs_cmn_vals,
3195*4882a593Smuzhiyun },
3196*4882a593Smuzhiyun },
3197*4882a593Smuzhiyun },
3198*4882a593Smuzhiyun .cmn_vals = {
3199*4882a593Smuzhiyun [TYPE_PCIE] = {
3200*4882a593Smuzhiyun [TYPE_NONE] = {
3201*4882a593Smuzhiyun [NO_SSC] = &pcie_100_no_ssc_cmn_vals,
3202*4882a593Smuzhiyun [EXTERNAL_SSC] = &pcie_100_no_ssc_cmn_vals,
3203*4882a593Smuzhiyun [INTERNAL_SSC] = &sl_pcie_100_int_ssc_cmn_vals,
3204*4882a593Smuzhiyun },
3205*4882a593Smuzhiyun [TYPE_SGMII] = {
3206*4882a593Smuzhiyun [NO_SSC] = &pcie_100_no_ssc_cmn_vals,
3207*4882a593Smuzhiyun [EXTERNAL_SSC] = &pcie_100_no_ssc_cmn_vals,
3208*4882a593Smuzhiyun [INTERNAL_SSC] = &pcie_100_int_ssc_cmn_vals,
3209*4882a593Smuzhiyun },
3210*4882a593Smuzhiyun [TYPE_QSGMII] = {
3211*4882a593Smuzhiyun [NO_SSC] = &pcie_100_no_ssc_cmn_vals,
3212*4882a593Smuzhiyun [EXTERNAL_SSC] = &pcie_100_no_ssc_cmn_vals,
3213*4882a593Smuzhiyun [INTERNAL_SSC] = &pcie_100_int_ssc_cmn_vals,
3214*4882a593Smuzhiyun },
3215*4882a593Smuzhiyun [TYPE_USB] = {
3216*4882a593Smuzhiyun [NO_SSC] = &pcie_100_no_ssc_cmn_vals,
3217*4882a593Smuzhiyun [EXTERNAL_SSC] = &pcie_100_no_ssc_cmn_vals,
3218*4882a593Smuzhiyun [INTERNAL_SSC] = &pcie_100_int_ssc_cmn_vals,
3219*4882a593Smuzhiyun },
3220*4882a593Smuzhiyun },
3221*4882a593Smuzhiyun [TYPE_SGMII] = {
3222*4882a593Smuzhiyun [TYPE_NONE] = {
3223*4882a593Smuzhiyun [NO_SSC] = &sgmii_100_no_ssc_cmn_vals,
3224*4882a593Smuzhiyun },
3225*4882a593Smuzhiyun [TYPE_PCIE] = {
3226*4882a593Smuzhiyun [NO_SSC] = &sgmii_100_no_ssc_cmn_vals,
3227*4882a593Smuzhiyun [EXTERNAL_SSC] = &sgmii_100_no_ssc_cmn_vals,
3228*4882a593Smuzhiyun [INTERNAL_SSC] = &sgmii_100_int_ssc_cmn_vals,
3229*4882a593Smuzhiyun },
3230*4882a593Smuzhiyun [TYPE_USB] = {
3231*4882a593Smuzhiyun [NO_SSC] = &sgmii_100_no_ssc_cmn_vals,
3232*4882a593Smuzhiyun [EXTERNAL_SSC] = &sgmii_100_no_ssc_cmn_vals,
3233*4882a593Smuzhiyun [INTERNAL_SSC] = &sgmii_100_no_ssc_cmn_vals,
3234*4882a593Smuzhiyun },
3235*4882a593Smuzhiyun },
3236*4882a593Smuzhiyun [TYPE_QSGMII] = {
3237*4882a593Smuzhiyun [TYPE_NONE] = {
3238*4882a593Smuzhiyun [NO_SSC] = &qsgmii_100_no_ssc_cmn_vals,
3239*4882a593Smuzhiyun },
3240*4882a593Smuzhiyun [TYPE_PCIE] = {
3241*4882a593Smuzhiyun [NO_SSC] = &qsgmii_100_no_ssc_cmn_vals,
3242*4882a593Smuzhiyun [EXTERNAL_SSC] = &qsgmii_100_no_ssc_cmn_vals,
3243*4882a593Smuzhiyun [INTERNAL_SSC] = &qsgmii_100_int_ssc_cmn_vals,
3244*4882a593Smuzhiyun },
3245*4882a593Smuzhiyun [TYPE_USB] = {
3246*4882a593Smuzhiyun [NO_SSC] = &qsgmii_100_no_ssc_cmn_vals,
3247*4882a593Smuzhiyun [EXTERNAL_SSC] = &qsgmii_100_no_ssc_cmn_vals,
3248*4882a593Smuzhiyun [INTERNAL_SSC] = &qsgmii_100_no_ssc_cmn_vals,
3249*4882a593Smuzhiyun },
3250*4882a593Smuzhiyun },
3251*4882a593Smuzhiyun [TYPE_USB] = {
3252*4882a593Smuzhiyun [TYPE_NONE] = {
3253*4882a593Smuzhiyun [NO_SSC] = &usb_100_no_ssc_cmn_vals,
3254*4882a593Smuzhiyun [EXTERNAL_SSC] = &usb_100_no_ssc_cmn_vals,
3255*4882a593Smuzhiyun [INTERNAL_SSC] = &sl_usb_100_int_ssc_cmn_vals,
3256*4882a593Smuzhiyun },
3257*4882a593Smuzhiyun [TYPE_PCIE] = {
3258*4882a593Smuzhiyun [NO_SSC] = &usb_100_no_ssc_cmn_vals,
3259*4882a593Smuzhiyun [EXTERNAL_SSC] = &usb_100_no_ssc_cmn_vals,
3260*4882a593Smuzhiyun [INTERNAL_SSC] = &usb_100_int_ssc_cmn_vals,
3261*4882a593Smuzhiyun },
3262*4882a593Smuzhiyun [TYPE_SGMII] = {
3263*4882a593Smuzhiyun [NO_SSC] = &usb_100_no_ssc_cmn_vals,
3264*4882a593Smuzhiyun [EXTERNAL_SSC] = &usb_100_no_ssc_cmn_vals,
3265*4882a593Smuzhiyun [INTERNAL_SSC] = &sl_usb_100_int_ssc_cmn_vals,
3266*4882a593Smuzhiyun },
3267*4882a593Smuzhiyun [TYPE_QSGMII] = {
3268*4882a593Smuzhiyun [NO_SSC] = &usb_100_no_ssc_cmn_vals,
3269*4882a593Smuzhiyun [EXTERNAL_SSC] = &usb_100_no_ssc_cmn_vals,
3270*4882a593Smuzhiyun [INTERNAL_SSC] = &sl_usb_100_int_ssc_cmn_vals,
3271*4882a593Smuzhiyun },
3272*4882a593Smuzhiyun },
3273*4882a593Smuzhiyun },
3274*4882a593Smuzhiyun .tx_ln_vals = {
3275*4882a593Smuzhiyun [TYPE_PCIE] = {
3276*4882a593Smuzhiyun [TYPE_NONE] = {
3277*4882a593Smuzhiyun [NO_SSC] = NULL,
3278*4882a593Smuzhiyun [EXTERNAL_SSC] = NULL,
3279*4882a593Smuzhiyun [INTERNAL_SSC] = NULL,
3280*4882a593Smuzhiyun },
3281*4882a593Smuzhiyun [TYPE_SGMII] = {
3282*4882a593Smuzhiyun [NO_SSC] = NULL,
3283*4882a593Smuzhiyun [EXTERNAL_SSC] = NULL,
3284*4882a593Smuzhiyun [INTERNAL_SSC] = NULL,
3285*4882a593Smuzhiyun },
3286*4882a593Smuzhiyun [TYPE_QSGMII] = {
3287*4882a593Smuzhiyun [NO_SSC] = NULL,
3288*4882a593Smuzhiyun [EXTERNAL_SSC] = NULL,
3289*4882a593Smuzhiyun [INTERNAL_SSC] = NULL,
3290*4882a593Smuzhiyun },
3291*4882a593Smuzhiyun [TYPE_USB] = {
3292*4882a593Smuzhiyun [NO_SSC] = NULL,
3293*4882a593Smuzhiyun [EXTERNAL_SSC] = NULL,
3294*4882a593Smuzhiyun [INTERNAL_SSC] = NULL,
3295*4882a593Smuzhiyun },
3296*4882a593Smuzhiyun },
3297*4882a593Smuzhiyun [TYPE_SGMII] = {
3298*4882a593Smuzhiyun [TYPE_NONE] = {
3299*4882a593Smuzhiyun [NO_SSC] = &sgmii_100_no_ssc_tx_ln_vals,
3300*4882a593Smuzhiyun },
3301*4882a593Smuzhiyun [TYPE_PCIE] = {
3302*4882a593Smuzhiyun [NO_SSC] = &sgmii_100_no_ssc_tx_ln_vals,
3303*4882a593Smuzhiyun [EXTERNAL_SSC] = &sgmii_100_no_ssc_tx_ln_vals,
3304*4882a593Smuzhiyun [INTERNAL_SSC] = &sgmii_100_no_ssc_tx_ln_vals,
3305*4882a593Smuzhiyun },
3306*4882a593Smuzhiyun [TYPE_USB] = {
3307*4882a593Smuzhiyun [NO_SSC] = &sgmii_100_no_ssc_tx_ln_vals,
3308*4882a593Smuzhiyun [EXTERNAL_SSC] = &sgmii_100_no_ssc_tx_ln_vals,
3309*4882a593Smuzhiyun [INTERNAL_SSC] = &sgmii_100_no_ssc_tx_ln_vals,
3310*4882a593Smuzhiyun },
3311*4882a593Smuzhiyun },
3312*4882a593Smuzhiyun [TYPE_QSGMII] = {
3313*4882a593Smuzhiyun [TYPE_NONE] = {
3314*4882a593Smuzhiyun [NO_SSC] = &qsgmii_100_no_ssc_tx_ln_vals,
3315*4882a593Smuzhiyun },
3316*4882a593Smuzhiyun [TYPE_PCIE] = {
3317*4882a593Smuzhiyun [NO_SSC] = &qsgmii_100_no_ssc_tx_ln_vals,
3318*4882a593Smuzhiyun [EXTERNAL_SSC] = &qsgmii_100_no_ssc_tx_ln_vals,
3319*4882a593Smuzhiyun [INTERNAL_SSC] = &qsgmii_100_no_ssc_tx_ln_vals,
3320*4882a593Smuzhiyun },
3321*4882a593Smuzhiyun [TYPE_USB] = {
3322*4882a593Smuzhiyun [NO_SSC] = &qsgmii_100_no_ssc_tx_ln_vals,
3323*4882a593Smuzhiyun [EXTERNAL_SSC] = &qsgmii_100_no_ssc_tx_ln_vals,
3324*4882a593Smuzhiyun [INTERNAL_SSC] = &qsgmii_100_no_ssc_tx_ln_vals,
3325*4882a593Smuzhiyun },
3326*4882a593Smuzhiyun },
3327*4882a593Smuzhiyun [TYPE_USB] = {
3328*4882a593Smuzhiyun [TYPE_NONE] = {
3329*4882a593Smuzhiyun [NO_SSC] = &usb_100_no_ssc_tx_ln_vals,
3330*4882a593Smuzhiyun [EXTERNAL_SSC] = &usb_100_no_ssc_tx_ln_vals,
3331*4882a593Smuzhiyun [INTERNAL_SSC] = &usb_100_no_ssc_tx_ln_vals,
3332*4882a593Smuzhiyun },
3333*4882a593Smuzhiyun [TYPE_PCIE] = {
3334*4882a593Smuzhiyun [NO_SSC] = &usb_100_no_ssc_tx_ln_vals,
3335*4882a593Smuzhiyun [EXTERNAL_SSC] = &usb_100_no_ssc_tx_ln_vals,
3336*4882a593Smuzhiyun [INTERNAL_SSC] = &usb_100_no_ssc_tx_ln_vals,
3337*4882a593Smuzhiyun },
3338*4882a593Smuzhiyun [TYPE_SGMII] = {
3339*4882a593Smuzhiyun [NO_SSC] = &usb_100_no_ssc_tx_ln_vals,
3340*4882a593Smuzhiyun [EXTERNAL_SSC] = &usb_100_no_ssc_tx_ln_vals,
3341*4882a593Smuzhiyun [INTERNAL_SSC] = &usb_100_no_ssc_tx_ln_vals,
3342*4882a593Smuzhiyun },
3343*4882a593Smuzhiyun [TYPE_QSGMII] = {
3344*4882a593Smuzhiyun [NO_SSC] = &usb_100_no_ssc_tx_ln_vals,
3345*4882a593Smuzhiyun [EXTERNAL_SSC] = &usb_100_no_ssc_tx_ln_vals,
3346*4882a593Smuzhiyun [INTERNAL_SSC] = &usb_100_no_ssc_tx_ln_vals,
3347*4882a593Smuzhiyun },
3348*4882a593Smuzhiyun },
3349*4882a593Smuzhiyun },
3350*4882a593Smuzhiyun .rx_ln_vals = {
3351*4882a593Smuzhiyun [TYPE_PCIE] = {
3352*4882a593Smuzhiyun [TYPE_NONE] = {
3353*4882a593Smuzhiyun [NO_SSC] = &pcie_100_no_ssc_rx_ln_vals,
3354*4882a593Smuzhiyun [EXTERNAL_SSC] = &pcie_100_no_ssc_rx_ln_vals,
3355*4882a593Smuzhiyun [INTERNAL_SSC] = &pcie_100_no_ssc_rx_ln_vals,
3356*4882a593Smuzhiyun },
3357*4882a593Smuzhiyun [TYPE_SGMII] = {
3358*4882a593Smuzhiyun [NO_SSC] = &pcie_100_no_ssc_rx_ln_vals,
3359*4882a593Smuzhiyun [EXTERNAL_SSC] = &pcie_100_no_ssc_rx_ln_vals,
3360*4882a593Smuzhiyun [INTERNAL_SSC] = &pcie_100_no_ssc_rx_ln_vals,
3361*4882a593Smuzhiyun },
3362*4882a593Smuzhiyun [TYPE_QSGMII] = {
3363*4882a593Smuzhiyun [NO_SSC] = &pcie_100_no_ssc_rx_ln_vals,
3364*4882a593Smuzhiyun [EXTERNAL_SSC] = &pcie_100_no_ssc_rx_ln_vals,
3365*4882a593Smuzhiyun [INTERNAL_SSC] = &pcie_100_no_ssc_rx_ln_vals,
3366*4882a593Smuzhiyun },
3367*4882a593Smuzhiyun [TYPE_USB] = {
3368*4882a593Smuzhiyun [NO_SSC] = &pcie_100_no_ssc_rx_ln_vals,
3369*4882a593Smuzhiyun [EXTERNAL_SSC] = &pcie_100_no_ssc_rx_ln_vals,
3370*4882a593Smuzhiyun [INTERNAL_SSC] = &pcie_100_no_ssc_rx_ln_vals,
3371*4882a593Smuzhiyun },
3372*4882a593Smuzhiyun },
3373*4882a593Smuzhiyun [TYPE_SGMII] = {
3374*4882a593Smuzhiyun [TYPE_NONE] = {
3375*4882a593Smuzhiyun [NO_SSC] = &sgmii_100_no_ssc_rx_ln_vals,
3376*4882a593Smuzhiyun },
3377*4882a593Smuzhiyun [TYPE_PCIE] = {
3378*4882a593Smuzhiyun [NO_SSC] = &sgmii_100_no_ssc_rx_ln_vals,
3379*4882a593Smuzhiyun [EXTERNAL_SSC] = &sgmii_100_no_ssc_rx_ln_vals,
3380*4882a593Smuzhiyun [INTERNAL_SSC] = &sgmii_100_no_ssc_rx_ln_vals,
3381*4882a593Smuzhiyun },
3382*4882a593Smuzhiyun [TYPE_USB] = {
3383*4882a593Smuzhiyun [NO_SSC] = &sgmii_100_no_ssc_rx_ln_vals,
3384*4882a593Smuzhiyun [EXTERNAL_SSC] = &sgmii_100_no_ssc_rx_ln_vals,
3385*4882a593Smuzhiyun [INTERNAL_SSC] = &sgmii_100_no_ssc_rx_ln_vals,
3386*4882a593Smuzhiyun },
3387*4882a593Smuzhiyun },
3388*4882a593Smuzhiyun [TYPE_QSGMII] = {
3389*4882a593Smuzhiyun [TYPE_NONE] = {
3390*4882a593Smuzhiyun [NO_SSC] = &qsgmii_100_no_ssc_rx_ln_vals,
3391*4882a593Smuzhiyun },
3392*4882a593Smuzhiyun [TYPE_PCIE] = {
3393*4882a593Smuzhiyun [NO_SSC] = &qsgmii_100_no_ssc_rx_ln_vals,
3394*4882a593Smuzhiyun [EXTERNAL_SSC] = &qsgmii_100_no_ssc_rx_ln_vals,
3395*4882a593Smuzhiyun [INTERNAL_SSC] = &qsgmii_100_no_ssc_rx_ln_vals,
3396*4882a593Smuzhiyun },
3397*4882a593Smuzhiyun [TYPE_USB] = {
3398*4882a593Smuzhiyun [NO_SSC] = &qsgmii_100_no_ssc_rx_ln_vals,
3399*4882a593Smuzhiyun [EXTERNAL_SSC] = &qsgmii_100_no_ssc_rx_ln_vals,
3400*4882a593Smuzhiyun [INTERNAL_SSC] = &qsgmii_100_no_ssc_rx_ln_vals,
3401*4882a593Smuzhiyun },
3402*4882a593Smuzhiyun },
3403*4882a593Smuzhiyun [TYPE_USB] = {
3404*4882a593Smuzhiyun [TYPE_NONE] = {
3405*4882a593Smuzhiyun [NO_SSC] = &usb_100_no_ssc_rx_ln_vals,
3406*4882a593Smuzhiyun [EXTERNAL_SSC] = &usb_100_no_ssc_rx_ln_vals,
3407*4882a593Smuzhiyun [INTERNAL_SSC] = &usb_100_no_ssc_rx_ln_vals,
3408*4882a593Smuzhiyun },
3409*4882a593Smuzhiyun [TYPE_PCIE] = {
3410*4882a593Smuzhiyun [NO_SSC] = &usb_100_no_ssc_rx_ln_vals,
3411*4882a593Smuzhiyun [EXTERNAL_SSC] = &usb_100_no_ssc_rx_ln_vals,
3412*4882a593Smuzhiyun [INTERNAL_SSC] = &usb_100_no_ssc_rx_ln_vals,
3413*4882a593Smuzhiyun },
3414*4882a593Smuzhiyun [TYPE_SGMII] = {
3415*4882a593Smuzhiyun [NO_SSC] = &usb_100_no_ssc_rx_ln_vals,
3416*4882a593Smuzhiyun [EXTERNAL_SSC] = &usb_100_no_ssc_rx_ln_vals,
3417*4882a593Smuzhiyun [INTERNAL_SSC] = &usb_100_no_ssc_rx_ln_vals,
3418*4882a593Smuzhiyun },
3419*4882a593Smuzhiyun [TYPE_QSGMII] = {
3420*4882a593Smuzhiyun [NO_SSC] = &usb_100_no_ssc_rx_ln_vals,
3421*4882a593Smuzhiyun [EXTERNAL_SSC] = &usb_100_no_ssc_rx_ln_vals,
3422*4882a593Smuzhiyun [INTERNAL_SSC] = &usb_100_no_ssc_rx_ln_vals,
3423*4882a593Smuzhiyun },
3424*4882a593Smuzhiyun },
3425*4882a593Smuzhiyun },
3426*4882a593Smuzhiyun };
3427*4882a593Smuzhiyun
3428*4882a593Smuzhiyun static const struct cdns_torrent_data ti_j721e_map_torrent = {
3429*4882a593Smuzhiyun .block_offset_shift = 0x0,
3430*4882a593Smuzhiyun .reg_offset_shift = 0x1,
3431*4882a593Smuzhiyun .link_cmn_vals = {
3432*4882a593Smuzhiyun [TYPE_PCIE] = {
3433*4882a593Smuzhiyun [TYPE_NONE] = {
3434*4882a593Smuzhiyun [NO_SSC] = NULL,
3435*4882a593Smuzhiyun [EXTERNAL_SSC] = NULL,
3436*4882a593Smuzhiyun [INTERNAL_SSC] = NULL,
3437*4882a593Smuzhiyun },
3438*4882a593Smuzhiyun [TYPE_SGMII] = {
3439*4882a593Smuzhiyun [NO_SSC] = &pcie_sgmii_link_cmn_vals,
3440*4882a593Smuzhiyun [EXTERNAL_SSC] = &pcie_sgmii_link_cmn_vals,
3441*4882a593Smuzhiyun [INTERNAL_SSC] = &pcie_sgmii_link_cmn_vals,
3442*4882a593Smuzhiyun },
3443*4882a593Smuzhiyun [TYPE_QSGMII] = {
3444*4882a593Smuzhiyun [NO_SSC] = &pcie_sgmii_link_cmn_vals,
3445*4882a593Smuzhiyun [EXTERNAL_SSC] = &pcie_sgmii_link_cmn_vals,
3446*4882a593Smuzhiyun [INTERNAL_SSC] = &pcie_sgmii_link_cmn_vals,
3447*4882a593Smuzhiyun },
3448*4882a593Smuzhiyun [TYPE_USB] = {
3449*4882a593Smuzhiyun [NO_SSC] = &pcie_usb_link_cmn_vals,
3450*4882a593Smuzhiyun [EXTERNAL_SSC] = &pcie_usb_link_cmn_vals,
3451*4882a593Smuzhiyun [INTERNAL_SSC] = &pcie_usb_link_cmn_vals,
3452*4882a593Smuzhiyun },
3453*4882a593Smuzhiyun },
3454*4882a593Smuzhiyun [TYPE_SGMII] = {
3455*4882a593Smuzhiyun [TYPE_NONE] = {
3456*4882a593Smuzhiyun [NO_SSC] = &sl_sgmii_link_cmn_vals,
3457*4882a593Smuzhiyun },
3458*4882a593Smuzhiyun [TYPE_PCIE] = {
3459*4882a593Smuzhiyun [NO_SSC] = &pcie_sgmii_link_cmn_vals,
3460*4882a593Smuzhiyun [EXTERNAL_SSC] = &pcie_sgmii_link_cmn_vals,
3461*4882a593Smuzhiyun [INTERNAL_SSC] = &pcie_sgmii_link_cmn_vals,
3462*4882a593Smuzhiyun },
3463*4882a593Smuzhiyun [TYPE_USB] = {
3464*4882a593Smuzhiyun [NO_SSC] = &usb_sgmii_link_cmn_vals,
3465*4882a593Smuzhiyun [EXTERNAL_SSC] = &usb_sgmii_link_cmn_vals,
3466*4882a593Smuzhiyun [INTERNAL_SSC] = &usb_sgmii_link_cmn_vals,
3467*4882a593Smuzhiyun },
3468*4882a593Smuzhiyun },
3469*4882a593Smuzhiyun [TYPE_QSGMII] = {
3470*4882a593Smuzhiyun [TYPE_NONE] = {
3471*4882a593Smuzhiyun [NO_SSC] = &sl_sgmii_link_cmn_vals,
3472*4882a593Smuzhiyun },
3473*4882a593Smuzhiyun [TYPE_PCIE] = {
3474*4882a593Smuzhiyun [NO_SSC] = &pcie_sgmii_link_cmn_vals,
3475*4882a593Smuzhiyun [EXTERNAL_SSC] = &pcie_sgmii_link_cmn_vals,
3476*4882a593Smuzhiyun [INTERNAL_SSC] = &pcie_sgmii_link_cmn_vals,
3477*4882a593Smuzhiyun },
3478*4882a593Smuzhiyun [TYPE_USB] = {
3479*4882a593Smuzhiyun [NO_SSC] = &usb_sgmii_link_cmn_vals,
3480*4882a593Smuzhiyun [EXTERNAL_SSC] = &usb_sgmii_link_cmn_vals,
3481*4882a593Smuzhiyun [INTERNAL_SSC] = &usb_sgmii_link_cmn_vals,
3482*4882a593Smuzhiyun },
3483*4882a593Smuzhiyun },
3484*4882a593Smuzhiyun [TYPE_USB] = {
3485*4882a593Smuzhiyun [TYPE_NONE] = {
3486*4882a593Smuzhiyun [NO_SSC] = &sl_usb_link_cmn_vals,
3487*4882a593Smuzhiyun [EXTERNAL_SSC] = &sl_usb_link_cmn_vals,
3488*4882a593Smuzhiyun [INTERNAL_SSC] = &sl_usb_link_cmn_vals,
3489*4882a593Smuzhiyun },
3490*4882a593Smuzhiyun [TYPE_PCIE] = {
3491*4882a593Smuzhiyun [NO_SSC] = &pcie_usb_link_cmn_vals,
3492*4882a593Smuzhiyun [EXTERNAL_SSC] = &pcie_usb_link_cmn_vals,
3493*4882a593Smuzhiyun [INTERNAL_SSC] = &pcie_usb_link_cmn_vals,
3494*4882a593Smuzhiyun },
3495*4882a593Smuzhiyun [TYPE_SGMII] = {
3496*4882a593Smuzhiyun [NO_SSC] = &usb_sgmii_link_cmn_vals,
3497*4882a593Smuzhiyun [EXTERNAL_SSC] = &usb_sgmii_link_cmn_vals,
3498*4882a593Smuzhiyun [INTERNAL_SSC] = &usb_sgmii_link_cmn_vals,
3499*4882a593Smuzhiyun },
3500*4882a593Smuzhiyun [TYPE_QSGMII] = {
3501*4882a593Smuzhiyun [NO_SSC] = &usb_sgmii_link_cmn_vals,
3502*4882a593Smuzhiyun [EXTERNAL_SSC] = &usb_sgmii_link_cmn_vals,
3503*4882a593Smuzhiyun [INTERNAL_SSC] = &usb_sgmii_link_cmn_vals,
3504*4882a593Smuzhiyun },
3505*4882a593Smuzhiyun },
3506*4882a593Smuzhiyun },
3507*4882a593Smuzhiyun .xcvr_diag_vals = {
3508*4882a593Smuzhiyun [TYPE_PCIE] = {
3509*4882a593Smuzhiyun [TYPE_NONE] = {
3510*4882a593Smuzhiyun [NO_SSC] = NULL,
3511*4882a593Smuzhiyun [EXTERNAL_SSC] = NULL,
3512*4882a593Smuzhiyun [INTERNAL_SSC] = NULL,
3513*4882a593Smuzhiyun },
3514*4882a593Smuzhiyun [TYPE_SGMII] = {
3515*4882a593Smuzhiyun [NO_SSC] = &pcie_sgmii_xcvr_diag_ln_vals,
3516*4882a593Smuzhiyun [EXTERNAL_SSC] = &pcie_sgmii_xcvr_diag_ln_vals,
3517*4882a593Smuzhiyun [INTERNAL_SSC] = &pcie_sgmii_xcvr_diag_ln_vals,
3518*4882a593Smuzhiyun },
3519*4882a593Smuzhiyun [TYPE_QSGMII] = {
3520*4882a593Smuzhiyun [NO_SSC] = &pcie_sgmii_xcvr_diag_ln_vals,
3521*4882a593Smuzhiyun [EXTERNAL_SSC] = &pcie_sgmii_xcvr_diag_ln_vals,
3522*4882a593Smuzhiyun [INTERNAL_SSC] = &pcie_sgmii_xcvr_diag_ln_vals,
3523*4882a593Smuzhiyun },
3524*4882a593Smuzhiyun [TYPE_USB] = {
3525*4882a593Smuzhiyun [NO_SSC] = &pcie_usb_xcvr_diag_ln_vals,
3526*4882a593Smuzhiyun [EXTERNAL_SSC] = &pcie_usb_xcvr_diag_ln_vals,
3527*4882a593Smuzhiyun [INTERNAL_SSC] = &pcie_usb_xcvr_diag_ln_vals,
3528*4882a593Smuzhiyun },
3529*4882a593Smuzhiyun },
3530*4882a593Smuzhiyun [TYPE_SGMII] = {
3531*4882a593Smuzhiyun [TYPE_NONE] = {
3532*4882a593Smuzhiyun [NO_SSC] = &sl_sgmii_xcvr_diag_ln_vals,
3533*4882a593Smuzhiyun },
3534*4882a593Smuzhiyun [TYPE_PCIE] = {
3535*4882a593Smuzhiyun [NO_SSC] = &sgmii_pcie_xcvr_diag_ln_vals,
3536*4882a593Smuzhiyun [EXTERNAL_SSC] = &sgmii_pcie_xcvr_diag_ln_vals,
3537*4882a593Smuzhiyun [INTERNAL_SSC] = &sgmii_pcie_xcvr_diag_ln_vals,
3538*4882a593Smuzhiyun },
3539*4882a593Smuzhiyun [TYPE_USB] = {
3540*4882a593Smuzhiyun [NO_SSC] = &sgmii_usb_xcvr_diag_ln_vals,
3541*4882a593Smuzhiyun [EXTERNAL_SSC] = &sgmii_usb_xcvr_diag_ln_vals,
3542*4882a593Smuzhiyun [INTERNAL_SSC] = &sgmii_usb_xcvr_diag_ln_vals,
3543*4882a593Smuzhiyun },
3544*4882a593Smuzhiyun },
3545*4882a593Smuzhiyun [TYPE_QSGMII] = {
3546*4882a593Smuzhiyun [TYPE_NONE] = {
3547*4882a593Smuzhiyun [NO_SSC] = &sl_sgmii_xcvr_diag_ln_vals,
3548*4882a593Smuzhiyun },
3549*4882a593Smuzhiyun [TYPE_PCIE] = {
3550*4882a593Smuzhiyun [NO_SSC] = &sgmii_pcie_xcvr_diag_ln_vals,
3551*4882a593Smuzhiyun [EXTERNAL_SSC] = &sgmii_pcie_xcvr_diag_ln_vals,
3552*4882a593Smuzhiyun [INTERNAL_SSC] = &sgmii_pcie_xcvr_diag_ln_vals,
3553*4882a593Smuzhiyun },
3554*4882a593Smuzhiyun [TYPE_USB] = {
3555*4882a593Smuzhiyun [NO_SSC] = &sgmii_usb_xcvr_diag_ln_vals,
3556*4882a593Smuzhiyun [EXTERNAL_SSC] = &sgmii_usb_xcvr_diag_ln_vals,
3557*4882a593Smuzhiyun [INTERNAL_SSC] = &sgmii_usb_xcvr_diag_ln_vals,
3558*4882a593Smuzhiyun },
3559*4882a593Smuzhiyun },
3560*4882a593Smuzhiyun [TYPE_USB] = {
3561*4882a593Smuzhiyun [TYPE_NONE] = {
3562*4882a593Smuzhiyun [NO_SSC] = &sl_usb_xcvr_diag_ln_vals,
3563*4882a593Smuzhiyun [EXTERNAL_SSC] = &sl_usb_xcvr_diag_ln_vals,
3564*4882a593Smuzhiyun [INTERNAL_SSC] = &sl_usb_xcvr_diag_ln_vals,
3565*4882a593Smuzhiyun },
3566*4882a593Smuzhiyun [TYPE_PCIE] = {
3567*4882a593Smuzhiyun [NO_SSC] = &usb_pcie_xcvr_diag_ln_vals,
3568*4882a593Smuzhiyun [EXTERNAL_SSC] = &usb_pcie_xcvr_diag_ln_vals,
3569*4882a593Smuzhiyun [INTERNAL_SSC] = &usb_pcie_xcvr_diag_ln_vals,
3570*4882a593Smuzhiyun },
3571*4882a593Smuzhiyun [TYPE_SGMII] = {
3572*4882a593Smuzhiyun [NO_SSC] = &usb_sgmii_xcvr_diag_ln_vals,
3573*4882a593Smuzhiyun [EXTERNAL_SSC] = &usb_sgmii_xcvr_diag_ln_vals,
3574*4882a593Smuzhiyun [INTERNAL_SSC] = &usb_sgmii_xcvr_diag_ln_vals,
3575*4882a593Smuzhiyun },
3576*4882a593Smuzhiyun [TYPE_QSGMII] = {
3577*4882a593Smuzhiyun [NO_SSC] = &usb_sgmii_xcvr_diag_ln_vals,
3578*4882a593Smuzhiyun [EXTERNAL_SSC] = &usb_sgmii_xcvr_diag_ln_vals,
3579*4882a593Smuzhiyun [INTERNAL_SSC] = &usb_sgmii_xcvr_diag_ln_vals,
3580*4882a593Smuzhiyun },
3581*4882a593Smuzhiyun },
3582*4882a593Smuzhiyun },
3583*4882a593Smuzhiyun .pcs_cmn_vals = {
3584*4882a593Smuzhiyun [TYPE_USB] = {
3585*4882a593Smuzhiyun [TYPE_NONE] = {
3586*4882a593Smuzhiyun [NO_SSC] = &usb_phy_pcs_cmn_vals,
3587*4882a593Smuzhiyun [EXTERNAL_SSC] = &usb_phy_pcs_cmn_vals,
3588*4882a593Smuzhiyun [INTERNAL_SSC] = &usb_phy_pcs_cmn_vals,
3589*4882a593Smuzhiyun },
3590*4882a593Smuzhiyun [TYPE_PCIE] = {
3591*4882a593Smuzhiyun [NO_SSC] = &usb_phy_pcs_cmn_vals,
3592*4882a593Smuzhiyun [EXTERNAL_SSC] = &usb_phy_pcs_cmn_vals,
3593*4882a593Smuzhiyun [INTERNAL_SSC] = &usb_phy_pcs_cmn_vals,
3594*4882a593Smuzhiyun },
3595*4882a593Smuzhiyun [TYPE_SGMII] = {
3596*4882a593Smuzhiyun [NO_SSC] = &usb_phy_pcs_cmn_vals,
3597*4882a593Smuzhiyun [EXTERNAL_SSC] = &usb_phy_pcs_cmn_vals,
3598*4882a593Smuzhiyun [INTERNAL_SSC] = &usb_phy_pcs_cmn_vals,
3599*4882a593Smuzhiyun },
3600*4882a593Smuzhiyun [TYPE_QSGMII] = {
3601*4882a593Smuzhiyun [NO_SSC] = &usb_phy_pcs_cmn_vals,
3602*4882a593Smuzhiyun [EXTERNAL_SSC] = &usb_phy_pcs_cmn_vals,
3603*4882a593Smuzhiyun [INTERNAL_SSC] = &usb_phy_pcs_cmn_vals,
3604*4882a593Smuzhiyun },
3605*4882a593Smuzhiyun },
3606*4882a593Smuzhiyun },
3607*4882a593Smuzhiyun .cmn_vals = {
3608*4882a593Smuzhiyun [TYPE_PCIE] = {
3609*4882a593Smuzhiyun [TYPE_NONE] = {
3610*4882a593Smuzhiyun [NO_SSC] = &pcie_100_no_ssc_cmn_vals,
3611*4882a593Smuzhiyun [EXTERNAL_SSC] = &pcie_100_no_ssc_cmn_vals,
3612*4882a593Smuzhiyun [INTERNAL_SSC] = &sl_pcie_100_int_ssc_cmn_vals,
3613*4882a593Smuzhiyun },
3614*4882a593Smuzhiyun [TYPE_SGMII] = {
3615*4882a593Smuzhiyun [NO_SSC] = &pcie_100_no_ssc_cmn_vals,
3616*4882a593Smuzhiyun [EXTERNAL_SSC] = &pcie_100_no_ssc_cmn_vals,
3617*4882a593Smuzhiyun [INTERNAL_SSC] = &pcie_100_int_ssc_cmn_vals,
3618*4882a593Smuzhiyun },
3619*4882a593Smuzhiyun [TYPE_QSGMII] = {
3620*4882a593Smuzhiyun [NO_SSC] = &pcie_100_no_ssc_cmn_vals,
3621*4882a593Smuzhiyun [EXTERNAL_SSC] = &pcie_100_no_ssc_cmn_vals,
3622*4882a593Smuzhiyun [INTERNAL_SSC] = &pcie_100_int_ssc_cmn_vals,
3623*4882a593Smuzhiyun },
3624*4882a593Smuzhiyun [TYPE_USB] = {
3625*4882a593Smuzhiyun [NO_SSC] = &pcie_100_no_ssc_cmn_vals,
3626*4882a593Smuzhiyun [EXTERNAL_SSC] = &pcie_100_no_ssc_cmn_vals,
3627*4882a593Smuzhiyun [INTERNAL_SSC] = &pcie_100_int_ssc_cmn_vals,
3628*4882a593Smuzhiyun },
3629*4882a593Smuzhiyun },
3630*4882a593Smuzhiyun [TYPE_SGMII] = {
3631*4882a593Smuzhiyun [TYPE_NONE] = {
3632*4882a593Smuzhiyun [NO_SSC] = &sgmii_100_no_ssc_cmn_vals,
3633*4882a593Smuzhiyun },
3634*4882a593Smuzhiyun [TYPE_PCIE] = {
3635*4882a593Smuzhiyun [NO_SSC] = &sgmii_100_no_ssc_cmn_vals,
3636*4882a593Smuzhiyun [EXTERNAL_SSC] = &sgmii_100_no_ssc_cmn_vals,
3637*4882a593Smuzhiyun [INTERNAL_SSC] = &sgmii_100_int_ssc_cmn_vals,
3638*4882a593Smuzhiyun },
3639*4882a593Smuzhiyun [TYPE_USB] = {
3640*4882a593Smuzhiyun [NO_SSC] = &sgmii_100_no_ssc_cmn_vals,
3641*4882a593Smuzhiyun [EXTERNAL_SSC] = &sgmii_100_no_ssc_cmn_vals,
3642*4882a593Smuzhiyun [INTERNAL_SSC] = &sgmii_100_no_ssc_cmn_vals,
3643*4882a593Smuzhiyun },
3644*4882a593Smuzhiyun },
3645*4882a593Smuzhiyun [TYPE_QSGMII] = {
3646*4882a593Smuzhiyun [TYPE_NONE] = {
3647*4882a593Smuzhiyun [NO_SSC] = &qsgmii_100_no_ssc_cmn_vals,
3648*4882a593Smuzhiyun },
3649*4882a593Smuzhiyun [TYPE_PCIE] = {
3650*4882a593Smuzhiyun [NO_SSC] = &qsgmii_100_no_ssc_cmn_vals,
3651*4882a593Smuzhiyun [EXTERNAL_SSC] = &qsgmii_100_no_ssc_cmn_vals,
3652*4882a593Smuzhiyun [INTERNAL_SSC] = &qsgmii_100_int_ssc_cmn_vals,
3653*4882a593Smuzhiyun },
3654*4882a593Smuzhiyun [TYPE_USB] = {
3655*4882a593Smuzhiyun [NO_SSC] = &qsgmii_100_no_ssc_cmn_vals,
3656*4882a593Smuzhiyun [EXTERNAL_SSC] = &qsgmii_100_no_ssc_cmn_vals,
3657*4882a593Smuzhiyun [INTERNAL_SSC] = &qsgmii_100_no_ssc_cmn_vals,
3658*4882a593Smuzhiyun },
3659*4882a593Smuzhiyun },
3660*4882a593Smuzhiyun [TYPE_USB] = {
3661*4882a593Smuzhiyun [TYPE_NONE] = {
3662*4882a593Smuzhiyun [NO_SSC] = &usb_100_no_ssc_cmn_vals,
3663*4882a593Smuzhiyun [EXTERNAL_SSC] = &usb_100_no_ssc_cmn_vals,
3664*4882a593Smuzhiyun [INTERNAL_SSC] = &sl_usb_100_int_ssc_cmn_vals,
3665*4882a593Smuzhiyun },
3666*4882a593Smuzhiyun [TYPE_PCIE] = {
3667*4882a593Smuzhiyun [NO_SSC] = &usb_100_no_ssc_cmn_vals,
3668*4882a593Smuzhiyun [EXTERNAL_SSC] = &usb_100_no_ssc_cmn_vals,
3669*4882a593Smuzhiyun [INTERNAL_SSC] = &usb_100_int_ssc_cmn_vals,
3670*4882a593Smuzhiyun },
3671*4882a593Smuzhiyun [TYPE_SGMII] = {
3672*4882a593Smuzhiyun [NO_SSC] = &usb_100_no_ssc_cmn_vals,
3673*4882a593Smuzhiyun [EXTERNAL_SSC] = &usb_100_no_ssc_cmn_vals,
3674*4882a593Smuzhiyun [INTERNAL_SSC] = &sl_usb_100_int_ssc_cmn_vals,
3675*4882a593Smuzhiyun },
3676*4882a593Smuzhiyun [TYPE_QSGMII] = {
3677*4882a593Smuzhiyun [NO_SSC] = &usb_100_no_ssc_cmn_vals,
3678*4882a593Smuzhiyun [EXTERNAL_SSC] = &usb_100_no_ssc_cmn_vals,
3679*4882a593Smuzhiyun [INTERNAL_SSC] = &sl_usb_100_int_ssc_cmn_vals,
3680*4882a593Smuzhiyun },
3681*4882a593Smuzhiyun },
3682*4882a593Smuzhiyun },
3683*4882a593Smuzhiyun .tx_ln_vals = {
3684*4882a593Smuzhiyun [TYPE_PCIE] = {
3685*4882a593Smuzhiyun [TYPE_NONE] = {
3686*4882a593Smuzhiyun [NO_SSC] = NULL,
3687*4882a593Smuzhiyun [EXTERNAL_SSC] = NULL,
3688*4882a593Smuzhiyun [INTERNAL_SSC] = NULL,
3689*4882a593Smuzhiyun },
3690*4882a593Smuzhiyun [TYPE_SGMII] = {
3691*4882a593Smuzhiyun [NO_SSC] = NULL,
3692*4882a593Smuzhiyun [EXTERNAL_SSC] = NULL,
3693*4882a593Smuzhiyun [INTERNAL_SSC] = NULL,
3694*4882a593Smuzhiyun },
3695*4882a593Smuzhiyun [TYPE_QSGMII] = {
3696*4882a593Smuzhiyun [NO_SSC] = NULL,
3697*4882a593Smuzhiyun [EXTERNAL_SSC] = NULL,
3698*4882a593Smuzhiyun [INTERNAL_SSC] = NULL,
3699*4882a593Smuzhiyun },
3700*4882a593Smuzhiyun [TYPE_USB] = {
3701*4882a593Smuzhiyun [NO_SSC] = NULL,
3702*4882a593Smuzhiyun [EXTERNAL_SSC] = NULL,
3703*4882a593Smuzhiyun [INTERNAL_SSC] = NULL,
3704*4882a593Smuzhiyun },
3705*4882a593Smuzhiyun },
3706*4882a593Smuzhiyun [TYPE_SGMII] = {
3707*4882a593Smuzhiyun [TYPE_NONE] = {
3708*4882a593Smuzhiyun [NO_SSC] = &sgmii_100_no_ssc_tx_ln_vals,
3709*4882a593Smuzhiyun },
3710*4882a593Smuzhiyun [TYPE_PCIE] = {
3711*4882a593Smuzhiyun [NO_SSC] = &sgmii_100_no_ssc_tx_ln_vals,
3712*4882a593Smuzhiyun [EXTERNAL_SSC] = &sgmii_100_no_ssc_tx_ln_vals,
3713*4882a593Smuzhiyun [INTERNAL_SSC] = &sgmii_100_no_ssc_tx_ln_vals,
3714*4882a593Smuzhiyun },
3715*4882a593Smuzhiyun [TYPE_USB] = {
3716*4882a593Smuzhiyun [NO_SSC] = &sgmii_100_no_ssc_tx_ln_vals,
3717*4882a593Smuzhiyun [EXTERNAL_SSC] = &sgmii_100_no_ssc_tx_ln_vals,
3718*4882a593Smuzhiyun [INTERNAL_SSC] = &sgmii_100_no_ssc_tx_ln_vals,
3719*4882a593Smuzhiyun },
3720*4882a593Smuzhiyun },
3721*4882a593Smuzhiyun [TYPE_QSGMII] = {
3722*4882a593Smuzhiyun [TYPE_NONE] = {
3723*4882a593Smuzhiyun [NO_SSC] = &qsgmii_100_no_ssc_tx_ln_vals,
3724*4882a593Smuzhiyun },
3725*4882a593Smuzhiyun [TYPE_PCIE] = {
3726*4882a593Smuzhiyun [NO_SSC] = &qsgmii_100_no_ssc_tx_ln_vals,
3727*4882a593Smuzhiyun [EXTERNAL_SSC] = &qsgmii_100_no_ssc_tx_ln_vals,
3728*4882a593Smuzhiyun [INTERNAL_SSC] = &qsgmii_100_no_ssc_tx_ln_vals,
3729*4882a593Smuzhiyun },
3730*4882a593Smuzhiyun [TYPE_USB] = {
3731*4882a593Smuzhiyun [NO_SSC] = &qsgmii_100_no_ssc_tx_ln_vals,
3732*4882a593Smuzhiyun [EXTERNAL_SSC] = &qsgmii_100_no_ssc_tx_ln_vals,
3733*4882a593Smuzhiyun [INTERNAL_SSC] = &qsgmii_100_no_ssc_tx_ln_vals,
3734*4882a593Smuzhiyun },
3735*4882a593Smuzhiyun },
3736*4882a593Smuzhiyun [TYPE_USB] = {
3737*4882a593Smuzhiyun [TYPE_NONE] = {
3738*4882a593Smuzhiyun [NO_SSC] = &usb_100_no_ssc_tx_ln_vals,
3739*4882a593Smuzhiyun [EXTERNAL_SSC] = &usb_100_no_ssc_tx_ln_vals,
3740*4882a593Smuzhiyun [INTERNAL_SSC] = &usb_100_no_ssc_tx_ln_vals,
3741*4882a593Smuzhiyun },
3742*4882a593Smuzhiyun [TYPE_PCIE] = {
3743*4882a593Smuzhiyun [NO_SSC] = &usb_100_no_ssc_tx_ln_vals,
3744*4882a593Smuzhiyun [EXTERNAL_SSC] = &usb_100_no_ssc_tx_ln_vals,
3745*4882a593Smuzhiyun [INTERNAL_SSC] = &usb_100_no_ssc_tx_ln_vals,
3746*4882a593Smuzhiyun },
3747*4882a593Smuzhiyun [TYPE_SGMII] = {
3748*4882a593Smuzhiyun [NO_SSC] = &usb_100_no_ssc_tx_ln_vals,
3749*4882a593Smuzhiyun [EXTERNAL_SSC] = &usb_100_no_ssc_tx_ln_vals,
3750*4882a593Smuzhiyun [INTERNAL_SSC] = &usb_100_no_ssc_tx_ln_vals,
3751*4882a593Smuzhiyun },
3752*4882a593Smuzhiyun [TYPE_QSGMII] = {
3753*4882a593Smuzhiyun [NO_SSC] = &usb_100_no_ssc_tx_ln_vals,
3754*4882a593Smuzhiyun [EXTERNAL_SSC] = &usb_100_no_ssc_tx_ln_vals,
3755*4882a593Smuzhiyun [INTERNAL_SSC] = &usb_100_no_ssc_tx_ln_vals,
3756*4882a593Smuzhiyun },
3757*4882a593Smuzhiyun },
3758*4882a593Smuzhiyun },
3759*4882a593Smuzhiyun .rx_ln_vals = {
3760*4882a593Smuzhiyun [TYPE_PCIE] = {
3761*4882a593Smuzhiyun [TYPE_NONE] = {
3762*4882a593Smuzhiyun [NO_SSC] = &pcie_100_no_ssc_rx_ln_vals,
3763*4882a593Smuzhiyun [EXTERNAL_SSC] = &pcie_100_no_ssc_rx_ln_vals,
3764*4882a593Smuzhiyun [INTERNAL_SSC] = &pcie_100_no_ssc_rx_ln_vals,
3765*4882a593Smuzhiyun },
3766*4882a593Smuzhiyun [TYPE_SGMII] = {
3767*4882a593Smuzhiyun [NO_SSC] = &pcie_100_no_ssc_rx_ln_vals,
3768*4882a593Smuzhiyun [EXTERNAL_SSC] = &pcie_100_no_ssc_rx_ln_vals,
3769*4882a593Smuzhiyun [INTERNAL_SSC] = &pcie_100_no_ssc_rx_ln_vals,
3770*4882a593Smuzhiyun },
3771*4882a593Smuzhiyun [TYPE_QSGMII] = {
3772*4882a593Smuzhiyun [NO_SSC] = &pcie_100_no_ssc_rx_ln_vals,
3773*4882a593Smuzhiyun [EXTERNAL_SSC] = &pcie_100_no_ssc_rx_ln_vals,
3774*4882a593Smuzhiyun [INTERNAL_SSC] = &pcie_100_no_ssc_rx_ln_vals,
3775*4882a593Smuzhiyun },
3776*4882a593Smuzhiyun [TYPE_USB] = {
3777*4882a593Smuzhiyun [NO_SSC] = &pcie_100_no_ssc_rx_ln_vals,
3778*4882a593Smuzhiyun [EXTERNAL_SSC] = &pcie_100_no_ssc_rx_ln_vals,
3779*4882a593Smuzhiyun [INTERNAL_SSC] = &pcie_100_no_ssc_rx_ln_vals,
3780*4882a593Smuzhiyun },
3781*4882a593Smuzhiyun },
3782*4882a593Smuzhiyun [TYPE_SGMII] = {
3783*4882a593Smuzhiyun [TYPE_NONE] = {
3784*4882a593Smuzhiyun [NO_SSC] = &sgmii_100_no_ssc_rx_ln_vals,
3785*4882a593Smuzhiyun },
3786*4882a593Smuzhiyun [TYPE_PCIE] = {
3787*4882a593Smuzhiyun [NO_SSC] = &sgmii_100_no_ssc_rx_ln_vals,
3788*4882a593Smuzhiyun [EXTERNAL_SSC] = &sgmii_100_no_ssc_rx_ln_vals,
3789*4882a593Smuzhiyun [INTERNAL_SSC] = &sgmii_100_no_ssc_rx_ln_vals,
3790*4882a593Smuzhiyun },
3791*4882a593Smuzhiyun [TYPE_USB] = {
3792*4882a593Smuzhiyun [NO_SSC] = &sgmii_100_no_ssc_rx_ln_vals,
3793*4882a593Smuzhiyun [EXTERNAL_SSC] = &sgmii_100_no_ssc_rx_ln_vals,
3794*4882a593Smuzhiyun [INTERNAL_SSC] = &sgmii_100_no_ssc_rx_ln_vals,
3795*4882a593Smuzhiyun },
3796*4882a593Smuzhiyun },
3797*4882a593Smuzhiyun [TYPE_QSGMII] = {
3798*4882a593Smuzhiyun [TYPE_NONE] = {
3799*4882a593Smuzhiyun [NO_SSC] = &qsgmii_100_no_ssc_rx_ln_vals,
3800*4882a593Smuzhiyun },
3801*4882a593Smuzhiyun [TYPE_PCIE] = {
3802*4882a593Smuzhiyun [NO_SSC] = &qsgmii_100_no_ssc_rx_ln_vals,
3803*4882a593Smuzhiyun [EXTERNAL_SSC] = &qsgmii_100_no_ssc_rx_ln_vals,
3804*4882a593Smuzhiyun [INTERNAL_SSC] = &qsgmii_100_no_ssc_rx_ln_vals,
3805*4882a593Smuzhiyun },
3806*4882a593Smuzhiyun [TYPE_USB] = {
3807*4882a593Smuzhiyun [NO_SSC] = &qsgmii_100_no_ssc_rx_ln_vals,
3808*4882a593Smuzhiyun [EXTERNAL_SSC] = &qsgmii_100_no_ssc_rx_ln_vals,
3809*4882a593Smuzhiyun [INTERNAL_SSC] = &qsgmii_100_no_ssc_rx_ln_vals,
3810*4882a593Smuzhiyun },
3811*4882a593Smuzhiyun },
3812*4882a593Smuzhiyun [TYPE_USB] = {
3813*4882a593Smuzhiyun [TYPE_NONE] = {
3814*4882a593Smuzhiyun [NO_SSC] = &usb_100_no_ssc_rx_ln_vals,
3815*4882a593Smuzhiyun [EXTERNAL_SSC] = &usb_100_no_ssc_rx_ln_vals,
3816*4882a593Smuzhiyun [INTERNAL_SSC] = &usb_100_no_ssc_rx_ln_vals,
3817*4882a593Smuzhiyun },
3818*4882a593Smuzhiyun [TYPE_PCIE] = {
3819*4882a593Smuzhiyun [NO_SSC] = &usb_100_no_ssc_rx_ln_vals,
3820*4882a593Smuzhiyun [EXTERNAL_SSC] = &usb_100_no_ssc_rx_ln_vals,
3821*4882a593Smuzhiyun [INTERNAL_SSC] = &usb_100_no_ssc_rx_ln_vals,
3822*4882a593Smuzhiyun },
3823*4882a593Smuzhiyun [TYPE_SGMII] = {
3824*4882a593Smuzhiyun [NO_SSC] = &usb_100_no_ssc_rx_ln_vals,
3825*4882a593Smuzhiyun [EXTERNAL_SSC] = &usb_100_no_ssc_rx_ln_vals,
3826*4882a593Smuzhiyun [INTERNAL_SSC] = &usb_100_no_ssc_rx_ln_vals,
3827*4882a593Smuzhiyun },
3828*4882a593Smuzhiyun [TYPE_QSGMII] = {
3829*4882a593Smuzhiyun [NO_SSC] = &usb_100_no_ssc_rx_ln_vals,
3830*4882a593Smuzhiyun [EXTERNAL_SSC] = &usb_100_no_ssc_rx_ln_vals,
3831*4882a593Smuzhiyun [INTERNAL_SSC] = &usb_100_no_ssc_rx_ln_vals,
3832*4882a593Smuzhiyun },
3833*4882a593Smuzhiyun },
3834*4882a593Smuzhiyun },
3835*4882a593Smuzhiyun };
3836*4882a593Smuzhiyun
3837*4882a593Smuzhiyun static const struct of_device_id cdns_torrent_phy_of_match[] = {
3838*4882a593Smuzhiyun {
3839*4882a593Smuzhiyun .compatible = "cdns,torrent-phy",
3840*4882a593Smuzhiyun .data = &cdns_map_torrent,
3841*4882a593Smuzhiyun },
3842*4882a593Smuzhiyun {
3843*4882a593Smuzhiyun .compatible = "ti,j721e-serdes-10g",
3844*4882a593Smuzhiyun .data = &ti_j721e_map_torrent,
3845*4882a593Smuzhiyun },
3846*4882a593Smuzhiyun {}
3847*4882a593Smuzhiyun };
3848*4882a593Smuzhiyun MODULE_DEVICE_TABLE(of, cdns_torrent_phy_of_match);
3849*4882a593Smuzhiyun
3850*4882a593Smuzhiyun static struct platform_driver cdns_torrent_phy_driver = {
3851*4882a593Smuzhiyun .probe = cdns_torrent_phy_probe,
3852*4882a593Smuzhiyun .remove = cdns_torrent_phy_remove,
3853*4882a593Smuzhiyun .driver = {
3854*4882a593Smuzhiyun .name = "cdns-torrent-phy",
3855*4882a593Smuzhiyun .of_match_table = cdns_torrent_phy_of_match,
3856*4882a593Smuzhiyun }
3857*4882a593Smuzhiyun };
3858*4882a593Smuzhiyun module_platform_driver(cdns_torrent_phy_driver);
3859*4882a593Smuzhiyun
3860*4882a593Smuzhiyun MODULE_AUTHOR("Cadence Design Systems, Inc.");
3861*4882a593Smuzhiyun MODULE_DESCRIPTION("Cadence Torrent PHY driver");
3862*4882a593Smuzhiyun MODULE_LICENSE("GPL v2");
3863