1c589e701SYuti Amonkar // SPDX-License-Identifier: GPL-2.0-only
2c589e701SYuti Amonkar /*
392e9ccc6SSwapnil Jakhade * Cadence Torrent SD0801 PHY driver.
4c589e701SYuti Amonkar *
5c589e701SYuti Amonkar * Copyright 2018 Cadence Design Systems, Inc.
6c589e701SYuti Amonkar *
7c589e701SYuti Amonkar */
8c589e701SYuti Amonkar
9afa4ba05SSwapnil Jakhade #include <dt-bindings/phy/phy.h>
10fd7abc3cSKishon Vijay Abraham I #include <dt-bindings/phy/phy-cadence.h>
11e4b496a3SSwapnil Jakhade #include <linux/clk.h>
122cca0228SKishon Vijay Abraham I #include <linux/clk-provider.h>
13c589e701SYuti Amonkar #include <linux/delay.h>
14c589e701SYuti Amonkar #include <linux/err.h>
15c589e701SYuti Amonkar #include <linux/io.h>
16c589e701SYuti Amonkar #include <linux/iopoll.h>
17c589e701SYuti Amonkar #include <linux/kernel.h>
18c589e701SYuti Amonkar #include <linux/module.h>
19c589e701SYuti Amonkar #include <linux/of.h>
20c589e701SYuti Amonkar #include <linux/phy/phy.h>
21c589e701SYuti Amonkar #include <linux/platform_device.h>
22afa4ba05SSwapnil Jakhade #include <linux/reset.h>
2369d114acSSwapnil Jakhade #include <linux/regmap.h>
24c589e701SYuti Amonkar
25e956d4fcSSwapnil Jakhade #define REF_CLK_19_2MHZ 19200000
26e956d4fcSSwapnil Jakhade #define REF_CLK_25MHZ 25000000
273b401625SSwapnil Jakhade #define REF_CLK_100MHZ 100000000
2816e0f0eaSSwapnil Jakhade #define REF_CLK_156_25MHZ 156250000
29e4b496a3SSwapnil Jakhade
30c589e701SYuti Amonkar #define MAX_NUM_LANES 4
31c589e701SYuti Amonkar #define DEFAULT_MAX_BIT_RATE 8100 /* in Mbps */
32c589e701SYuti Amonkar
3321c79146SSwapnil Jakhade #define POLL_TIMEOUT_US 5000
348e4c95b9SSwapnil Jakhade #define PLL_LOCK_TIMEOUT 100000
3569d114acSSwapnil Jakhade
361b0524fcSSwapnil Jakhade #define DP_PLL0 BIT(0)
371b0524fcSSwapnil Jakhade #define DP_PLL1 BIT(1)
381b0524fcSSwapnil Jakhade
3969d114acSSwapnil Jakhade #define TORRENT_COMMON_CDB_OFFSET 0x0
4069d114acSSwapnil Jakhade
4169d114acSSwapnil Jakhade #define TORRENT_TX_LANE_CDB_OFFSET(ln, block_offset, reg_offset) \
4269d114acSSwapnil Jakhade ((0x4000 << (block_offset)) + \
4369d114acSSwapnil Jakhade (((ln) << 9) << (reg_offset)))
4469d114acSSwapnil Jakhade
4569d114acSSwapnil Jakhade #define TORRENT_RX_LANE_CDB_OFFSET(ln, block_offset, reg_offset) \
4669d114acSSwapnil Jakhade ((0x8000 << (block_offset)) + \
4769d114acSSwapnil Jakhade (((ln) << 9) << (reg_offset)))
4869d114acSSwapnil Jakhade
4969d114acSSwapnil Jakhade #define TORRENT_PHY_PCS_COMMON_OFFSET(block_offset) \
5069d114acSSwapnil Jakhade (0xC000 << (block_offset))
5169d114acSSwapnil Jakhade
5248ac6085SSwapnil Jakhade #define TORRENT_PHY_PCS_LANE_CDB_OFFSET(ln, block_offset, reg_offset) \
5348ac6085SSwapnil Jakhade ((0xD000 << (block_offset)) + \
5448ac6085SSwapnil Jakhade (((ln) << 8) << (reg_offset)))
5548ac6085SSwapnil Jakhade
5669d114acSSwapnil Jakhade #define TORRENT_PHY_PMA_COMMON_OFFSET(block_offset) \
5769d114acSSwapnil Jakhade (0xE000 << (block_offset))
58c589e701SYuti Amonkar
59cba472ecSSwapnil Jakhade #define TORRENT_DPTX_PHY_OFFSET 0x0
60cba472ecSSwapnil Jakhade
61c589e701SYuti Amonkar /*
62c589e701SYuti Amonkar * register offsets from DPTX PHY register block base (i.e MHDP
63c589e701SYuti Amonkar * register base + 0x30a00)
64c589e701SYuti Amonkar */
65c589e701SYuti Amonkar #define PHY_AUX_CTRL 0x04
66c589e701SYuti Amonkar #define PHY_RESET 0x20
67572d6592SSwapnil Jakhade #define PMA_TX_ELEC_IDLE_SHIFT 4
68c589e701SYuti Amonkar #define PHY_PMA_XCVR_PLLCLK_EN 0x24
69c589e701SYuti Amonkar #define PHY_PMA_XCVR_PLLCLK_EN_ACK 0x28
70c589e701SYuti Amonkar #define PHY_PMA_XCVR_POWER_STATE_REQ 0x2c
71c756cc16SSwapnil Jakhade #define PHY_POWER_STATE_LN(ln) ((ln) * 8)
7221c79146SSwapnil Jakhade #define PMA_XCVR_POWER_STATE_REQ_LN_MASK 0x3FU
73c589e701SYuti Amonkar #define PHY_PMA_XCVR_POWER_STATE_ACK 0x30
74c589e701SYuti Amonkar #define PHY_PMA_CMN_READY 0x34
75c589e701SYuti Amonkar
76c589e701SYuti Amonkar /*
77c589e701SYuti Amonkar * register offsets from SD0801 PHY register block base (i.e MHDP
78c589e701SYuti Amonkar * register base + 0x500000)
79c589e701SYuti Amonkar */
8069d114acSSwapnil Jakhade #define CMN_SSM_BANDGAP_TMR 0x0021U
8169d114acSSwapnil Jakhade #define CMN_SSM_BIAS_TMR 0x0022U
8269d114acSSwapnil Jakhade #define CMN_PLLSM0_PLLPRE_TMR 0x002AU
8369d114acSSwapnil Jakhade #define CMN_PLLSM0_PLLLOCK_TMR 0x002CU
8469d114acSSwapnil Jakhade #define CMN_PLLSM1_PLLPRE_TMR 0x0032U
8569d114acSSwapnil Jakhade #define CMN_PLLSM1_PLLLOCK_TMR 0x0034U
869855d84bSSwapnil Jakhade #define CMN_CDIAG_CDB_PWRI_OVRD 0x0041U
879855d84bSSwapnil Jakhade #define CMN_CDIAG_XCVRC_PWRI_OVRD 0x0047U
882cca0228SKishon Vijay Abraham I #define CMN_CDIAG_REFCLK_OVRD 0x004CU
892cca0228SKishon Vijay Abraham I #define CMN_CDIAG_REFCLK_DRV0_CTRL 0x0050U
9069d114acSSwapnil Jakhade #define CMN_BGCAL_INIT_TMR 0x0064U
9169d114acSSwapnil Jakhade #define CMN_BGCAL_ITER_TMR 0x0065U
9269d114acSSwapnil Jakhade #define CMN_IBCAL_INIT_TMR 0x0074U
9369d114acSSwapnil Jakhade #define CMN_PLL0_VCOCAL_TCTRL 0x0082U
9469d114acSSwapnil Jakhade #define CMN_PLL0_VCOCAL_INIT_TMR 0x0084U
9569d114acSSwapnil Jakhade #define CMN_PLL0_VCOCAL_ITER_TMR 0x0085U
9669d114acSSwapnil Jakhade #define CMN_PLL0_VCOCAL_REFTIM_START 0x0086U
9769d114acSSwapnil Jakhade #define CMN_PLL0_VCOCAL_PLLCNT_START 0x0088U
9869d114acSSwapnil Jakhade #define CMN_PLL0_INTDIV_M0 0x0090U
9969d114acSSwapnil Jakhade #define CMN_PLL0_FRACDIVL_M0 0x0091U
10069d114acSSwapnil Jakhade #define CMN_PLL0_FRACDIVH_M0 0x0092U
10169d114acSSwapnil Jakhade #define CMN_PLL0_HIGH_THR_M0 0x0093U
10269d114acSSwapnil Jakhade #define CMN_PLL0_DSM_DIAG_M0 0x0094U
1031cc45515SSwapnil Jakhade #define CMN_PLL0_DSM_FBH_OVRD_M0 0x0095U
10416e0f0eaSSwapnil Jakhade #define CMN_PLL0_DSM_FBL_OVRD_M0 0x0096U
10569d114acSSwapnil Jakhade #define CMN_PLL0_SS_CTRL1_M0 0x0098U
10669d114acSSwapnil Jakhade #define CMN_PLL0_SS_CTRL2_M0 0x0099U
10769d114acSSwapnil Jakhade #define CMN_PLL0_SS_CTRL3_M0 0x009AU
10869d114acSSwapnil Jakhade #define CMN_PLL0_SS_CTRL4_M0 0x009BU
10969d114acSSwapnil Jakhade #define CMN_PLL0_LOCK_REFCNT_START 0x009CU
11069d114acSSwapnil Jakhade #define CMN_PLL0_LOCK_PLLCNT_START 0x009EU
11169d114acSSwapnil Jakhade #define CMN_PLL0_LOCK_PLLCNT_THR 0x009FU
112b54b47bdSSwapnil Jakhade #define CMN_PLL0_INTDIV_M1 0x00A0U
113b54b47bdSSwapnil Jakhade #define CMN_PLL0_FRACDIVH_M1 0x00A2U
114b54b47bdSSwapnil Jakhade #define CMN_PLL0_HIGH_THR_M1 0x00A3U
115b54b47bdSSwapnil Jakhade #define CMN_PLL0_DSM_DIAG_M1 0x00A4U
116b54b47bdSSwapnil Jakhade #define CMN_PLL0_SS_CTRL1_M1 0x00A8U
117b54b47bdSSwapnil Jakhade #define CMN_PLL0_SS_CTRL2_M1 0x00A9U
118b54b47bdSSwapnil Jakhade #define CMN_PLL0_SS_CTRL3_M1 0x00AAU
119b54b47bdSSwapnil Jakhade #define CMN_PLL0_SS_CTRL4_M1 0x00ABU
12069d114acSSwapnil Jakhade #define CMN_PLL1_VCOCAL_TCTRL 0x00C2U
12169d114acSSwapnil Jakhade #define CMN_PLL1_VCOCAL_INIT_TMR 0x00C4U
12269d114acSSwapnil Jakhade #define CMN_PLL1_VCOCAL_ITER_TMR 0x00C5U
12369d114acSSwapnil Jakhade #define CMN_PLL1_VCOCAL_REFTIM_START 0x00C6U
12469d114acSSwapnil Jakhade #define CMN_PLL1_VCOCAL_PLLCNT_START 0x00C8U
12569d114acSSwapnil Jakhade #define CMN_PLL1_INTDIV_M0 0x00D0U
12669d114acSSwapnil Jakhade #define CMN_PLL1_FRACDIVL_M0 0x00D1U
12769d114acSSwapnil Jakhade #define CMN_PLL1_FRACDIVH_M0 0x00D2U
12869d114acSSwapnil Jakhade #define CMN_PLL1_HIGH_THR_M0 0x00D3U
12969d114acSSwapnil Jakhade #define CMN_PLL1_DSM_DIAG_M0 0x00D4U
130e25c9dbcSSwapnil Jakhade #define CMN_PLL1_DSM_FBH_OVRD_M0 0x00D5U
131e25c9dbcSSwapnil Jakhade #define CMN_PLL1_DSM_FBL_OVRD_M0 0x00D6U
13269d114acSSwapnil Jakhade #define CMN_PLL1_SS_CTRL1_M0 0x00D8U
13369d114acSSwapnil Jakhade #define CMN_PLL1_SS_CTRL2_M0 0x00D9U
13469d114acSSwapnil Jakhade #define CMN_PLL1_SS_CTRL3_M0 0x00DAU
13569d114acSSwapnil Jakhade #define CMN_PLL1_SS_CTRL4_M0 0x00DBU
13669d114acSSwapnil Jakhade #define CMN_PLL1_LOCK_REFCNT_START 0x00DCU
13769d114acSSwapnil Jakhade #define CMN_PLL1_LOCK_PLLCNT_START 0x00DEU
13869d114acSSwapnil Jakhade #define CMN_PLL1_LOCK_PLLCNT_THR 0x00DFU
1396bcf3cb3SSwapnil Jakhade #define CMN_TXPUCAL_TUNE 0x0103U
14069d114acSSwapnil Jakhade #define CMN_TXPUCAL_INIT_TMR 0x0104U
14169d114acSSwapnil Jakhade #define CMN_TXPUCAL_ITER_TMR 0x0105U
1426bcf3cb3SSwapnil Jakhade #define CMN_TXPDCAL_TUNE 0x010BU
14369d114acSSwapnil Jakhade #define CMN_TXPDCAL_INIT_TMR 0x010CU
14469d114acSSwapnil Jakhade #define CMN_TXPDCAL_ITER_TMR 0x010DU
14569d114acSSwapnil Jakhade #define CMN_RXCAL_INIT_TMR 0x0114U
14669d114acSSwapnil Jakhade #define CMN_RXCAL_ITER_TMR 0x0115U
14769d114acSSwapnil Jakhade #define CMN_SD_CAL_INIT_TMR 0x0124U
14869d114acSSwapnil Jakhade #define CMN_SD_CAL_ITER_TMR 0x0125U
14969d114acSSwapnil Jakhade #define CMN_SD_CAL_REFTIM_START 0x0126U
15069d114acSSwapnil Jakhade #define CMN_SD_CAL_PLLCNT_START 0x0128U
15169d114acSSwapnil Jakhade #define CMN_PDIAG_PLL0_CTRL_M0 0x01A0U
15269d114acSSwapnil Jakhade #define CMN_PDIAG_PLL0_CLK_SEL_M0 0x01A1U
15369d114acSSwapnil Jakhade #define CMN_PDIAG_PLL0_CP_PADJ_M0 0x01A4U
15469d114acSSwapnil Jakhade #define CMN_PDIAG_PLL0_CP_IADJ_M0 0x01A5U
15569d114acSSwapnil Jakhade #define CMN_PDIAG_PLL0_FILT_PADJ_M0 0x01A6U
156b54b47bdSSwapnil Jakhade #define CMN_PDIAG_PLL0_CTRL_M1 0x01B0U
1576bcf3cb3SSwapnil Jakhade #define CMN_PDIAG_PLL0_CLK_SEL_M1 0x01B1U
15869d114acSSwapnil Jakhade #define CMN_PDIAG_PLL0_CP_PADJ_M1 0x01B4U
15969d114acSSwapnil Jakhade #define CMN_PDIAG_PLL0_CP_IADJ_M1 0x01B5U
160b54b47bdSSwapnil Jakhade #define CMN_PDIAG_PLL0_FILT_PADJ_M1 0x01B6U
16169d114acSSwapnil Jakhade #define CMN_PDIAG_PLL1_CTRL_M0 0x01C0U
16269d114acSSwapnil Jakhade #define CMN_PDIAG_PLL1_CLK_SEL_M0 0x01C1U
16369d114acSSwapnil Jakhade #define CMN_PDIAG_PLL1_CP_PADJ_M0 0x01C4U
16469d114acSSwapnil Jakhade #define CMN_PDIAG_PLL1_CP_IADJ_M0 0x01C5U
16569d114acSSwapnil Jakhade #define CMN_PDIAG_PLL1_FILT_PADJ_M0 0x01C6U
1666bcf3cb3SSwapnil Jakhade #define CMN_DIAG_BIAS_OVRD1 0x01E1U
167e4b496a3SSwapnil Jakhade
16869d114acSSwapnil Jakhade /* PMA TX Lane registers */
16969d114acSSwapnil Jakhade #define TX_TXCC_CTRL 0x0040U
17069d114acSSwapnil Jakhade #define TX_TXCC_CPOST_MULT_00 0x004CU
1719855d84bSSwapnil Jakhade #define TX_TXCC_CPOST_MULT_01 0x004DU
17269d114acSSwapnil Jakhade #define TX_TXCC_MGNFS_MULT_000 0x0050U
173e25c9dbcSSwapnil Jakhade #define TX_TXCC_MGNFS_MULT_100 0x0054U
17469d114acSSwapnil Jakhade #define DRV_DIAG_TX_DRV 0x00C6U
17569d114acSSwapnil Jakhade #define XCVR_DIAG_PLLDRC_CTRL 0x00E5U
17669d114acSSwapnil Jakhade #define XCVR_DIAG_HSCLK_SEL 0x00E6U
17769d114acSSwapnil Jakhade #define XCVR_DIAG_HSCLK_DIV 0x00E7U
17870901a7dSKishon Vijay Abraham I #define XCVR_DIAG_RXCLK_CTRL 0x00E9U
17969d114acSSwapnil Jakhade #define XCVR_DIAG_BIDI_CTRL 0x00EAU
1809855d84bSSwapnil Jakhade #define XCVR_DIAG_PSC_OVRD 0x00EBU
18169d114acSSwapnil Jakhade #define TX_PSC_A0 0x0100U
1829855d84bSSwapnil Jakhade #define TX_PSC_A1 0x0101U
18369d114acSSwapnil Jakhade #define TX_PSC_A2 0x0102U
18469d114acSSwapnil Jakhade #define TX_PSC_A3 0x0103U
18569d114acSSwapnil Jakhade #define TX_RCVDET_ST_TMR 0x0123U
18669d114acSSwapnil Jakhade #define TX_DIAG_ACYA 0x01E7U
187572d6592SSwapnil Jakhade #define TX_DIAG_ACYA_HBDC_MASK 0x0001U
188e4b496a3SSwapnil Jakhade
18969d114acSSwapnil Jakhade /* PMA RX Lane registers */
19069d114acSSwapnil Jakhade #define RX_PSC_A0 0x0000U
1919855d84bSSwapnil Jakhade #define RX_PSC_A1 0x0001U
19269d114acSSwapnil Jakhade #define RX_PSC_A2 0x0002U
19369d114acSSwapnil Jakhade #define RX_PSC_A3 0x0003U
19469d114acSSwapnil Jakhade #define RX_PSC_CAL 0x0006U
19516e0f0eaSSwapnil Jakhade #define RX_SDCAL0_INIT_TMR 0x0044U
19616e0f0eaSSwapnil Jakhade #define RX_SDCAL0_ITER_TMR 0x0045U
19716e0f0eaSSwapnil Jakhade #define RX_SDCAL1_INIT_TMR 0x004CU
19816e0f0eaSSwapnil Jakhade #define RX_SDCAL1_ITER_TMR 0x004DU
1996bcf3cb3SSwapnil Jakhade #define RX_CDRLF_CNFG 0x0080U
2009855d84bSSwapnil Jakhade #define RX_CDRLF_CNFG3 0x0082U
2019855d84bSSwapnil Jakhade #define RX_SIGDET_HL_FILT_TMR 0x0090U
20269d114acSSwapnil Jakhade #define RX_REE_GCSM1_CTRL 0x0108U
2036bcf3cb3SSwapnil Jakhade #define RX_REE_GCSM1_EQENM_PH1 0x0109U
2046bcf3cb3SSwapnil Jakhade #define RX_REE_GCSM1_EQENM_PH2 0x010AU
20569d114acSSwapnil Jakhade #define RX_REE_GCSM2_CTRL 0x0110U
20669d114acSSwapnil Jakhade #define RX_REE_PERGCSM_CTRL 0x0118U
2079855d84bSSwapnil Jakhade #define RX_REE_ATTEN_THR 0x0149U
208b54b47bdSSwapnil Jakhade #define RX_REE_TAP1_CLIP 0x0171U
209b54b47bdSSwapnil Jakhade #define RX_REE_TAP2TON_CLIP 0x0172U
2109855d84bSSwapnil Jakhade #define RX_REE_SMGM_CTRL1 0x0177U
2119855d84bSSwapnil Jakhade #define RX_REE_SMGM_CTRL2 0x0178U
2126bcf3cb3SSwapnil Jakhade #define RX_DIAG_DFE_CTRL 0x01E0U
2136bcf3cb3SSwapnil Jakhade #define RX_DIAG_DFE_AMP_TUNE_2 0x01E2U
2146bcf3cb3SSwapnil Jakhade #define RX_DIAG_DFE_AMP_TUNE_3 0x01E3U
2156bcf3cb3SSwapnil Jakhade #define RX_DIAG_NQST_CTRL 0x01E5U
2169855d84bSSwapnil Jakhade #define RX_DIAG_SIGDET_TUNE 0x01E8U
2176bcf3cb3SSwapnil Jakhade #define RX_DIAG_PI_RATE 0x01F4U
2186bcf3cb3SSwapnil Jakhade #define RX_DIAG_PI_CAP 0x01F5U
219b54b47bdSSwapnil Jakhade #define RX_DIAG_ACYA 0x01FFU
220c589e701SYuti Amonkar
22169d114acSSwapnil Jakhade /* PHY PCS common registers */
2222cca0228SKishon Vijay Abraham I #define PHY_PIPE_CMN_CTRL1 0x0000U
22369d114acSSwapnil Jakhade #define PHY_PLL_CFG 0x000EU
2249855d84bSSwapnil Jakhade #define PHY_PIPE_USB3_GEN2_PRE_CFG0 0x0020U
2259855d84bSSwapnil Jakhade #define PHY_PIPE_USB3_GEN2_POST_CFG0 0x0022U
2269855d84bSSwapnil Jakhade #define PHY_PIPE_USB3_GEN2_POST_CFG1 0x0023U
22769d114acSSwapnil Jakhade
22848ac6085SSwapnil Jakhade /* PHY PCS lane registers */
22948ac6085SSwapnil Jakhade #define PHY_PCS_ISO_LINK_CTRL 0x000BU
23048ac6085SSwapnil Jakhade
23169d114acSSwapnil Jakhade /* PHY PMA common registers */
2328e4c95b9SSwapnil Jakhade #define PHY_PMA_CMN_CTRL1 0x0000U
23369d114acSSwapnil Jakhade #define PHY_PMA_CMN_CTRL2 0x0001U
23469d114acSSwapnil Jakhade #define PHY_PMA_PLL_RAW_CTRL 0x0003U
23569d114acSSwapnil Jakhade
236785a4e68SSwapnil Jakhade #define CDNS_TORRENT_OUTPUT_CLOCKS 3
237aef096dbSSwapnil Jakhade
2382cca0228SKishon Vijay Abraham I static const char * const clk_names[] = {
2392cca0228SKishon Vijay Abraham I [CDNS_TORRENT_REFCLK_DRIVER] = "refclk-driver",
240235bde4fSSwapnil Jakhade [CDNS_TORRENT_DERIVED_REFCLK] = "refclk-der",
241785a4e68SSwapnil Jakhade [CDNS_TORRENT_RECEIVED_REFCLK] = "refclk-rec",
2422cca0228SKishon Vijay Abraham I };
2432cca0228SKishon Vijay Abraham I
24469d114acSSwapnil Jakhade static const struct reg_field phy_pll_cfg =
24569d114acSSwapnil Jakhade REG_FIELD(PHY_PLL_CFG, 0, 1);
24669d114acSSwapnil Jakhade
2478e4c95b9SSwapnil Jakhade static const struct reg_field phy_pma_cmn_ctrl_1 =
2488e4c95b9SSwapnil Jakhade REG_FIELD(PHY_PMA_CMN_CTRL1, 0, 0);
2498e4c95b9SSwapnil Jakhade
25069d114acSSwapnil Jakhade static const struct reg_field phy_pma_cmn_ctrl_2 =
25169d114acSSwapnil Jakhade REG_FIELD(PHY_PMA_CMN_CTRL2, 0, 7);
25269d114acSSwapnil Jakhade
25369d114acSSwapnil Jakhade static const struct reg_field phy_pma_pll_raw_ctrl =
25469d114acSSwapnil Jakhade REG_FIELD(PHY_PMA_PLL_RAW_CTRL, 0, 1);
25569d114acSSwapnil Jakhade
256cba472ecSSwapnil Jakhade static const struct reg_field phy_reset_ctrl =
257cba472ecSSwapnil Jakhade REG_FIELD(PHY_RESET, 8, 8);
258cba472ecSSwapnil Jakhade
25948ac6085SSwapnil Jakhade static const struct reg_field phy_pcs_iso_link_ctrl_1 =
26048ac6085SSwapnil Jakhade REG_FIELD(PHY_PCS_ISO_LINK_CTRL, 1, 1);
26148ac6085SSwapnil Jakhade
2622cca0228SKishon Vijay Abraham I static const struct reg_field phy_pipe_cmn_ctrl1_0 = REG_FIELD(PHY_PIPE_CMN_CTRL1, 0, 0);
2632cca0228SKishon Vijay Abraham I
264235bde4fSSwapnil Jakhade static const struct reg_field cmn_cdiag_refclk_ovrd_4 =
265235bde4fSSwapnil Jakhade REG_FIELD(CMN_CDIAG_REFCLK_OVRD, 4, 4);
266235bde4fSSwapnil Jakhade
267235bde4fSSwapnil Jakhade #define REFCLK_OUT_NUM_CMN_CONFIG 4
2682cca0228SKishon Vijay Abraham I
2692cca0228SKishon Vijay Abraham I enum cdns_torrent_refclk_out_cmn {
2702cca0228SKishon Vijay Abraham I CMN_CDIAG_REFCLK_DRV0_CTRL_1,
2712cca0228SKishon Vijay Abraham I CMN_CDIAG_REFCLK_DRV0_CTRL_4,
2722cca0228SKishon Vijay Abraham I CMN_CDIAG_REFCLK_DRV0_CTRL_5,
2732cca0228SKishon Vijay Abraham I CMN_CDIAG_REFCLK_DRV0_CTRL_6,
2742cca0228SKishon Vijay Abraham I };
2752cca0228SKishon Vijay Abraham I
2762cca0228SKishon Vijay Abraham I static const struct reg_field refclk_out_cmn_cfg[] = {
2772cca0228SKishon Vijay Abraham I [CMN_CDIAG_REFCLK_DRV0_CTRL_1] = REG_FIELD(CMN_CDIAG_REFCLK_DRV0_CTRL, 1, 1),
2782cca0228SKishon Vijay Abraham I [CMN_CDIAG_REFCLK_DRV0_CTRL_4] = REG_FIELD(CMN_CDIAG_REFCLK_DRV0_CTRL, 4, 4),
2792cca0228SKishon Vijay Abraham I [CMN_CDIAG_REFCLK_DRV0_CTRL_5] = REG_FIELD(CMN_CDIAG_REFCLK_DRV0_CTRL, 5, 5),
2802cca0228SKishon Vijay Abraham I [CMN_CDIAG_REFCLK_DRV0_CTRL_6] = REG_FIELD(CMN_CDIAG_REFCLK_DRV0_CTRL, 6, 6),
2812cca0228SKishon Vijay Abraham I };
2822cca0228SKishon Vijay Abraham I
283785a4e68SSwapnil Jakhade static const int refclk_driver_parent_index[] = {
284785a4e68SSwapnil Jakhade CDNS_TORRENT_DERIVED_REFCLK,
285785a4e68SSwapnil Jakhade CDNS_TORRENT_RECEIVED_REFCLK
286785a4e68SSwapnil Jakhade };
287785a4e68SSwapnil Jakhade
288785a4e68SSwapnil Jakhade static u32 cdns_torrent_refclk_driver_mux_table[] = { 1, 0 };
289785a4e68SSwapnil Jakhade
290b54b47bdSSwapnil Jakhade enum cdns_torrent_phy_type {
2916bcf3cb3SSwapnil Jakhade TYPE_NONE,
292b54b47bdSSwapnil Jakhade TYPE_DP,
2936bcf3cb3SSwapnil Jakhade TYPE_PCIE,
2946bcf3cb3SSwapnil Jakhade TYPE_SGMII,
2956bcf3cb3SSwapnil Jakhade TYPE_QSGMII,
2969855d84bSSwapnil Jakhade TYPE_USB,
29716e0f0eaSSwapnil Jakhade TYPE_USXGMII,
298b54b47bdSSwapnil Jakhade };
299b54b47bdSSwapnil Jakhade
3003b401625SSwapnil Jakhade enum cdns_torrent_ref_clk {
3013b401625SSwapnil Jakhade CLK_19_2_MHZ,
3023b401625SSwapnil Jakhade CLK_25_MHZ,
30316e0f0eaSSwapnil Jakhade CLK_100_MHZ,
304ebd05f90SRoger Quadros CLK_156_25_MHZ,
305ebd05f90SRoger Quadros CLK_ANY,
3063b401625SSwapnil Jakhade };
3073b401625SSwapnil Jakhade
308b54b47bdSSwapnil Jakhade enum cdns_torrent_ssc_mode {
309b54b47bdSSwapnil Jakhade NO_SSC,
310b54b47bdSSwapnil Jakhade EXTERNAL_SSC,
311ebd05f90SRoger Quadros INTERNAL_SSC,
312ebd05f90SRoger Quadros ANY_SSC,
313b54b47bdSSwapnil Jakhade };
314b54b47bdSSwapnil Jakhade
315ebd05f90SRoger Quadros /* Unique key id for vals table entry
316ebd05f90SRoger Quadros * REFCLK0_RATE | REFCLK1_RATE | LINK0_TYPE | LINK1_TYPE | SSC_TYPE
317ebd05f90SRoger Quadros */
318ebd05f90SRoger Quadros #define REFCLK0_SHIFT 12
319ebd05f90SRoger Quadros #define REFCLK0_MASK GENMASK(14, 12)
320ebd05f90SRoger Quadros #define REFCLK1_SHIFT 9
321ebd05f90SRoger Quadros #define REFCLK1_MASK GENMASK(11, 9)
322ebd05f90SRoger Quadros #define LINK0_SHIFT 6
323ebd05f90SRoger Quadros #define LINK0_MASK GENMASK(8, 6)
324ebd05f90SRoger Quadros #define LINK1_SHIFT 3
325ebd05f90SRoger Quadros #define LINK1_MASK GENMASK(5, 3)
326ebd05f90SRoger Quadros #define SSC_SHIFT 0
327ebd05f90SRoger Quadros #define SSC_MASK GENMASK(2, 0)
328ebd05f90SRoger Quadros
329ebd05f90SRoger Quadros #define CDNS_TORRENT_KEY(refclk0, refclk1, link0, link1, ssc) \
330ebd05f90SRoger Quadros ((((refclk0) << REFCLK0_SHIFT) & REFCLK0_MASK) | \
331ebd05f90SRoger Quadros (((refclk1) << REFCLK1_SHIFT) & REFCLK1_MASK) | \
332ebd05f90SRoger Quadros (((link0) << LINK0_SHIFT) & LINK0_MASK) | \
333ebd05f90SRoger Quadros (((link1) << LINK1_SHIFT) & LINK1_MASK) | \
334ebd05f90SRoger Quadros (((ssc) << SSC_SHIFT) & SSC_MASK))
335ebd05f90SRoger Quadros
336ebd05f90SRoger Quadros #define CDNS_TORRENT_KEY_ANYCLK(link0, link1) \
337ebd05f90SRoger Quadros CDNS_TORRENT_KEY(CLK_ANY, CLK_ANY, \
338ebd05f90SRoger Quadros (link0), (link1), ANY_SSC)
339ebd05f90SRoger Quadros
340afa4ba05SSwapnil Jakhade struct cdns_torrent_inst {
341afa4ba05SSwapnil Jakhade struct phy *phy;
342afa4ba05SSwapnil Jakhade u32 mlane;
343b54b47bdSSwapnil Jakhade enum cdns_torrent_phy_type phy_type;
344afa4ba05SSwapnil Jakhade u32 num_lanes;
345afa4ba05SSwapnil Jakhade struct reset_control *lnk_rst;
346b54b47bdSSwapnil Jakhade enum cdns_torrent_ssc_mode ssc_mode;
347afa4ba05SSwapnil Jakhade };
348afa4ba05SSwapnil Jakhade
34992e9ccc6SSwapnil Jakhade struct cdns_torrent_phy {
350c589e701SYuti Amonkar void __iomem *base; /* DPTX registers base */
351c589e701SYuti Amonkar void __iomem *sd_base; /* SD0801 registers base */
352c589e701SYuti Amonkar u32 max_bit_rate; /* Maximum link bit rate to use (in Mbps) */
3531b0524fcSSwapnil Jakhade u32 dp_pll;
354afa4ba05SSwapnil Jakhade struct reset_control *phy_rst;
35515c6a048SSwapnil Jakhade struct reset_control *apb_rst;
356c589e701SYuti Amonkar struct device *dev;
357e4b496a3SSwapnil Jakhade struct clk *clk;
3583b401625SSwapnil Jakhade enum cdns_torrent_ref_clk ref_clk_rate;
359afa4ba05SSwapnil Jakhade struct cdns_torrent_inst phys[MAX_NUM_LANES];
360afa4ba05SSwapnil Jakhade int nsubnodes;
36129d1fd2fSSwapnil Jakhade const struct cdns_torrent_data *init_data;
36269d114acSSwapnil Jakhade struct regmap *regmap_common_cdb;
36369d114acSSwapnil Jakhade struct regmap *regmap_phy_pcs_common_cdb;
36469d114acSSwapnil Jakhade struct regmap *regmap_phy_pma_common_cdb;
36569d114acSSwapnil Jakhade struct regmap *regmap_tx_lane_cdb[MAX_NUM_LANES];
36669d114acSSwapnil Jakhade struct regmap *regmap_rx_lane_cdb[MAX_NUM_LANES];
36748ac6085SSwapnil Jakhade struct regmap *regmap_phy_pcs_lane_cdb[MAX_NUM_LANES];
368cba472ecSSwapnil Jakhade struct regmap *regmap_dptx_phy_reg;
36969d114acSSwapnil Jakhade struct regmap_field *phy_pll_cfg;
370235bde4fSSwapnil Jakhade struct regmap_field *phy_pipe_cmn_ctrl1_0;
371235bde4fSSwapnil Jakhade struct regmap_field *cmn_cdiag_refclk_ovrd_4;
3728e4c95b9SSwapnil Jakhade struct regmap_field *phy_pma_cmn_ctrl_1;
37369d114acSSwapnil Jakhade struct regmap_field *phy_pma_cmn_ctrl_2;
37469d114acSSwapnil Jakhade struct regmap_field *phy_pma_pll_raw_ctrl;
375cba472ecSSwapnil Jakhade struct regmap_field *phy_reset_ctrl;
37648ac6085SSwapnil Jakhade struct regmap_field *phy_pcs_iso_link_ctrl_1[MAX_NUM_LANES];
377aef096dbSSwapnil Jakhade struct clk_hw_onecell_data *clk_hw_data;
378c589e701SYuti Amonkar };
379c589e701SYuti Amonkar
38021c79146SSwapnil Jakhade enum phy_powerstate {
38121c79146SSwapnil Jakhade POWERSTATE_A0 = 0,
38221c79146SSwapnil Jakhade /* Powerstate A1 is unused */
38321c79146SSwapnil Jakhade POWERSTATE_A2 = 2,
38421c79146SSwapnil Jakhade POWERSTATE_A3 = 3,
38521c79146SSwapnil Jakhade };
38621c79146SSwapnil Jakhade
387235bde4fSSwapnil Jakhade struct cdns_torrent_refclk_driver {
388235bde4fSSwapnil Jakhade struct clk_hw hw;
389235bde4fSSwapnil Jakhade struct regmap_field *cmn_fields[REFCLK_OUT_NUM_CMN_CONFIG];
390235bde4fSSwapnil Jakhade struct clk_init_data clk_data;
391235bde4fSSwapnil Jakhade };
392235bde4fSSwapnil Jakhade
393235bde4fSSwapnil Jakhade #define to_cdns_torrent_refclk_driver(_hw) \
394235bde4fSSwapnil Jakhade container_of(_hw, struct cdns_torrent_refclk_driver, hw)
395235bde4fSSwapnil Jakhade
3962cca0228SKishon Vijay Abraham I struct cdns_torrent_derived_refclk {
3972cca0228SKishon Vijay Abraham I struct clk_hw hw;
3982cca0228SKishon Vijay Abraham I struct regmap_field *phy_pipe_cmn_ctrl1_0;
399235bde4fSSwapnil Jakhade struct regmap_field *cmn_cdiag_refclk_ovrd_4;
4002cca0228SKishon Vijay Abraham I struct clk_init_data clk_data;
4012cca0228SKishon Vijay Abraham I };
4022cca0228SKishon Vijay Abraham I
4032cca0228SKishon Vijay Abraham I #define to_cdns_torrent_derived_refclk(_hw) \
4042cca0228SKishon Vijay Abraham I container_of(_hw, struct cdns_torrent_derived_refclk, hw)
4052cca0228SKishon Vijay Abraham I
406785a4e68SSwapnil Jakhade struct cdns_torrent_received_refclk {
407785a4e68SSwapnil Jakhade struct clk_hw hw;
408785a4e68SSwapnil Jakhade struct regmap_field *phy_pipe_cmn_ctrl1_0;
409785a4e68SSwapnil Jakhade struct regmap_field *cmn_cdiag_refclk_ovrd_4;
410785a4e68SSwapnil Jakhade struct clk_init_data clk_data;
411785a4e68SSwapnil Jakhade };
412785a4e68SSwapnil Jakhade
413785a4e68SSwapnil Jakhade #define to_cdns_torrent_received_refclk(_hw) \
414785a4e68SSwapnil Jakhade container_of(_hw, struct cdns_torrent_received_refclk, hw)
415785a4e68SSwapnil Jakhade
416b54b47bdSSwapnil Jakhade struct cdns_reg_pairs {
417b54b47bdSSwapnil Jakhade u32 val;
418b54b47bdSSwapnil Jakhade u32 off;
419b54b47bdSSwapnil Jakhade };
420b54b47bdSSwapnil Jakhade
421b54b47bdSSwapnil Jakhade struct cdns_torrent_vals {
422b54b47bdSSwapnil Jakhade struct cdns_reg_pairs *reg_pairs;
423b54b47bdSSwapnil Jakhade u32 num_regs;
424b54b47bdSSwapnil Jakhade };
425b54b47bdSSwapnil Jakhade
426ebd05f90SRoger Quadros struct cdns_torrent_vals_entry {
427ebd05f90SRoger Quadros u32 key;
428ebd05f90SRoger Quadros struct cdns_torrent_vals *vals;
429ebd05f90SRoger Quadros };
430ebd05f90SRoger Quadros
431ebd05f90SRoger Quadros struct cdns_torrent_vals_table {
432ebd05f90SRoger Quadros struct cdns_torrent_vals_entry *entries;
433ebd05f90SRoger Quadros u32 num_entries;
434ebd05f90SRoger Quadros };
435ebd05f90SRoger Quadros
43669d114acSSwapnil Jakhade struct cdns_torrent_data {
43769d114acSSwapnil Jakhade u8 block_offset_shift;
43869d114acSSwapnil Jakhade u8 reg_offset_shift;
439ebd05f90SRoger Quadros struct cdns_torrent_vals_table link_cmn_vals_tbl;
440ebd05f90SRoger Quadros struct cdns_torrent_vals_table xcvr_diag_vals_tbl;
441ebd05f90SRoger Quadros struct cdns_torrent_vals_table pcs_cmn_vals_tbl;
442ebd05f90SRoger Quadros struct cdns_torrent_vals_table phy_pma_cmn_vals_tbl;
443ebd05f90SRoger Quadros struct cdns_torrent_vals_table cmn_vals_tbl;
444ebd05f90SRoger Quadros struct cdns_torrent_vals_table tx_ln_vals_tbl;
445ebd05f90SRoger Quadros struct cdns_torrent_vals_table rx_ln_vals_tbl;
44669d114acSSwapnil Jakhade };
44769d114acSSwapnil Jakhade
44869d114acSSwapnil Jakhade struct cdns_regmap_cdb_context {
44969d114acSSwapnil Jakhade struct device *dev;
45069d114acSSwapnil Jakhade void __iomem *base;
45169d114acSSwapnil Jakhade u8 reg_offset_shift;
45269d114acSSwapnil Jakhade };
45369d114acSSwapnil Jakhade
cdns_torrent_get_tbl_vals(const struct cdns_torrent_vals_table * tbl,enum cdns_torrent_ref_clk refclk0,enum cdns_torrent_ref_clk refclk1,enum cdns_torrent_phy_type link0,enum cdns_torrent_phy_type link1,enum cdns_torrent_ssc_mode ssc)454ebd05f90SRoger Quadros static struct cdns_torrent_vals *cdns_torrent_get_tbl_vals(const struct cdns_torrent_vals_table *tbl,
455ebd05f90SRoger Quadros enum cdns_torrent_ref_clk refclk0,
456ebd05f90SRoger Quadros enum cdns_torrent_ref_clk refclk1,
457ebd05f90SRoger Quadros enum cdns_torrent_phy_type link0,
458ebd05f90SRoger Quadros enum cdns_torrent_phy_type link1,
459ebd05f90SRoger Quadros enum cdns_torrent_ssc_mode ssc)
460ebd05f90SRoger Quadros {
461ebd05f90SRoger Quadros int i;
462ebd05f90SRoger Quadros u32 key = CDNS_TORRENT_KEY(refclk0, refclk1, link0, link1, ssc);
463ebd05f90SRoger Quadros
464ebd05f90SRoger Quadros for (i = 0; i < tbl->num_entries; i++) {
465ebd05f90SRoger Quadros if (tbl->entries[i].key == key)
466ebd05f90SRoger Quadros return tbl->entries[i].vals;
467ebd05f90SRoger Quadros }
468ebd05f90SRoger Quadros
469ebd05f90SRoger Quadros return NULL;
470ebd05f90SRoger Quadros }
471ebd05f90SRoger Quadros
cdns_regmap_write(void * context,unsigned int reg,unsigned int val)47269d114acSSwapnil Jakhade static int cdns_regmap_write(void *context, unsigned int reg, unsigned int val)
47369d114acSSwapnil Jakhade {
47469d114acSSwapnil Jakhade struct cdns_regmap_cdb_context *ctx = context;
47569d114acSSwapnil Jakhade u32 offset = reg << ctx->reg_offset_shift;
47669d114acSSwapnil Jakhade
47769d114acSSwapnil Jakhade writew(val, ctx->base + offset);
47869d114acSSwapnil Jakhade
47969d114acSSwapnil Jakhade return 0;
48069d114acSSwapnil Jakhade }
48169d114acSSwapnil Jakhade
cdns_regmap_read(void * context,unsigned int reg,unsigned int * val)48269d114acSSwapnil Jakhade static int cdns_regmap_read(void *context, unsigned int reg, unsigned int *val)
48369d114acSSwapnil Jakhade {
48469d114acSSwapnil Jakhade struct cdns_regmap_cdb_context *ctx = context;
48569d114acSSwapnil Jakhade u32 offset = reg << ctx->reg_offset_shift;
48669d114acSSwapnil Jakhade
48769d114acSSwapnil Jakhade *val = readw(ctx->base + offset);
48869d114acSSwapnil Jakhade return 0;
48969d114acSSwapnil Jakhade }
49069d114acSSwapnil Jakhade
cdns_regmap_dptx_write(void * context,unsigned int reg,unsigned int val)491cba472ecSSwapnil Jakhade static int cdns_regmap_dptx_write(void *context, unsigned int reg,
492cba472ecSSwapnil Jakhade unsigned int val)
493cba472ecSSwapnil Jakhade {
494cba472ecSSwapnil Jakhade struct cdns_regmap_cdb_context *ctx = context;
495cba472ecSSwapnil Jakhade u32 offset = reg;
496cba472ecSSwapnil Jakhade
497cba472ecSSwapnil Jakhade writel(val, ctx->base + offset);
498cba472ecSSwapnil Jakhade
499cba472ecSSwapnil Jakhade return 0;
500cba472ecSSwapnil Jakhade }
501cba472ecSSwapnil Jakhade
cdns_regmap_dptx_read(void * context,unsigned int reg,unsigned int * val)502cba472ecSSwapnil Jakhade static int cdns_regmap_dptx_read(void *context, unsigned int reg,
503cba472ecSSwapnil Jakhade unsigned int *val)
504cba472ecSSwapnil Jakhade {
505cba472ecSSwapnil Jakhade struct cdns_regmap_cdb_context *ctx = context;
506cba472ecSSwapnil Jakhade u32 offset = reg;
507cba472ecSSwapnil Jakhade
508cba472ecSSwapnil Jakhade *val = readl(ctx->base + offset);
509cba472ecSSwapnil Jakhade return 0;
510cba472ecSSwapnil Jakhade }
511cba472ecSSwapnil Jakhade
51269d114acSSwapnil Jakhade #define TORRENT_TX_LANE_CDB_REGMAP_CONF(n) \
51369d114acSSwapnil Jakhade { \
51469d114acSSwapnil Jakhade .name = "torrent_tx_lane" n "_cdb", \
51569d114acSSwapnil Jakhade .reg_stride = 1, \
51669d114acSSwapnil Jakhade .fast_io = true, \
51769d114acSSwapnil Jakhade .reg_write = cdns_regmap_write, \
51869d114acSSwapnil Jakhade .reg_read = cdns_regmap_read, \
51969d114acSSwapnil Jakhade }
52069d114acSSwapnil Jakhade
52169d114acSSwapnil Jakhade #define TORRENT_RX_LANE_CDB_REGMAP_CONF(n) \
52269d114acSSwapnil Jakhade { \
52369d114acSSwapnil Jakhade .name = "torrent_rx_lane" n "_cdb", \
52469d114acSSwapnil Jakhade .reg_stride = 1, \
52569d114acSSwapnil Jakhade .fast_io = true, \
52669d114acSSwapnil Jakhade .reg_write = cdns_regmap_write, \
52769d114acSSwapnil Jakhade .reg_read = cdns_regmap_read, \
52869d114acSSwapnil Jakhade }
52969d114acSSwapnil Jakhade
53057d39c76SRikard Falkeborn static const struct regmap_config cdns_torrent_tx_lane_cdb_config[] = {
53169d114acSSwapnil Jakhade TORRENT_TX_LANE_CDB_REGMAP_CONF("0"),
53269d114acSSwapnil Jakhade TORRENT_TX_LANE_CDB_REGMAP_CONF("1"),
53369d114acSSwapnil Jakhade TORRENT_TX_LANE_CDB_REGMAP_CONF("2"),
53469d114acSSwapnil Jakhade TORRENT_TX_LANE_CDB_REGMAP_CONF("3"),
53569d114acSSwapnil Jakhade };
53669d114acSSwapnil Jakhade
53757d39c76SRikard Falkeborn static const struct regmap_config cdns_torrent_rx_lane_cdb_config[] = {
53869d114acSSwapnil Jakhade TORRENT_RX_LANE_CDB_REGMAP_CONF("0"),
53969d114acSSwapnil Jakhade TORRENT_RX_LANE_CDB_REGMAP_CONF("1"),
54069d114acSSwapnil Jakhade TORRENT_RX_LANE_CDB_REGMAP_CONF("2"),
54169d114acSSwapnil Jakhade TORRENT_RX_LANE_CDB_REGMAP_CONF("3"),
54269d114acSSwapnil Jakhade };
54369d114acSSwapnil Jakhade
54457d39c76SRikard Falkeborn static const struct regmap_config cdns_torrent_common_cdb_config = {
54569d114acSSwapnil Jakhade .name = "torrent_common_cdb",
54669d114acSSwapnil Jakhade .reg_stride = 1,
54769d114acSSwapnil Jakhade .fast_io = true,
54869d114acSSwapnil Jakhade .reg_write = cdns_regmap_write,
54969d114acSSwapnil Jakhade .reg_read = cdns_regmap_read,
55069d114acSSwapnil Jakhade };
55169d114acSSwapnil Jakhade
55248ac6085SSwapnil Jakhade #define TORRENT_PHY_PCS_LANE_CDB_REGMAP_CONF(n) \
55348ac6085SSwapnil Jakhade { \
55448ac6085SSwapnil Jakhade .name = "torrent_phy_pcs_lane" n "_cdb", \
55548ac6085SSwapnil Jakhade .reg_stride = 1, \
55648ac6085SSwapnil Jakhade .fast_io = true, \
55748ac6085SSwapnil Jakhade .reg_write = cdns_regmap_write, \
55848ac6085SSwapnil Jakhade .reg_read = cdns_regmap_read, \
55948ac6085SSwapnil Jakhade }
56048ac6085SSwapnil Jakhade
56148ac6085SSwapnil Jakhade static const struct regmap_config cdns_torrent_phy_pcs_lane_cdb_config[] = {
56248ac6085SSwapnil Jakhade TORRENT_PHY_PCS_LANE_CDB_REGMAP_CONF("0"),
56348ac6085SSwapnil Jakhade TORRENT_PHY_PCS_LANE_CDB_REGMAP_CONF("1"),
56448ac6085SSwapnil Jakhade TORRENT_PHY_PCS_LANE_CDB_REGMAP_CONF("2"),
56548ac6085SSwapnil Jakhade TORRENT_PHY_PCS_LANE_CDB_REGMAP_CONF("3"),
56648ac6085SSwapnil Jakhade };
56748ac6085SSwapnil Jakhade
56857d39c76SRikard Falkeborn static const struct regmap_config cdns_torrent_phy_pcs_cmn_cdb_config = {
56969d114acSSwapnil Jakhade .name = "torrent_phy_pcs_cmn_cdb",
57069d114acSSwapnil Jakhade .reg_stride = 1,
57169d114acSSwapnil Jakhade .fast_io = true,
57269d114acSSwapnil Jakhade .reg_write = cdns_regmap_write,
57369d114acSSwapnil Jakhade .reg_read = cdns_regmap_read,
57469d114acSSwapnil Jakhade };
57569d114acSSwapnil Jakhade
57657d39c76SRikard Falkeborn static const struct regmap_config cdns_torrent_phy_pma_cmn_cdb_config = {
57769d114acSSwapnil Jakhade .name = "torrent_phy_pma_cmn_cdb",
57869d114acSSwapnil Jakhade .reg_stride = 1,
57969d114acSSwapnil Jakhade .fast_io = true,
58069d114acSSwapnil Jakhade .reg_write = cdns_regmap_write,
58169d114acSSwapnil Jakhade .reg_read = cdns_regmap_read,
58269d114acSSwapnil Jakhade };
58369d114acSSwapnil Jakhade
58457d39c76SRikard Falkeborn static const struct regmap_config cdns_torrent_dptx_phy_config = {
585cba472ecSSwapnil Jakhade .name = "torrent_dptx_phy",
586cba472ecSSwapnil Jakhade .reg_stride = 1,
587cba472ecSSwapnil Jakhade .fast_io = true,
588cba472ecSSwapnil Jakhade .reg_write = cdns_regmap_dptx_write,
589cba472ecSSwapnil Jakhade .reg_read = cdns_regmap_dptx_read,
590cba472ecSSwapnil Jakhade };
591cba472ecSSwapnil Jakhade
592ccb1b89dSSwapnil Jakhade /* PHY mmr access functions */
593ccb1b89dSSwapnil Jakhade
cdns_torrent_phy_write(struct regmap * regmap,u32 offset,u32 val)59469d114acSSwapnil Jakhade static void cdns_torrent_phy_write(struct regmap *regmap, u32 offset, u32 val)
595ccb1b89dSSwapnil Jakhade {
59669d114acSSwapnil Jakhade regmap_write(regmap, offset, val);
597ccb1b89dSSwapnil Jakhade }
598ccb1b89dSSwapnil Jakhade
cdns_torrent_phy_read(struct regmap * regmap,u32 offset)59969d114acSSwapnil Jakhade static u32 cdns_torrent_phy_read(struct regmap *regmap, u32 offset)
600572d6592SSwapnil Jakhade {
60169d114acSSwapnil Jakhade unsigned int val;
602572d6592SSwapnil Jakhade
60369d114acSSwapnil Jakhade regmap_read(regmap, offset, &val);
60469d114acSSwapnil Jakhade return val;
60569d114acSSwapnil Jakhade }
606572d6592SSwapnil Jakhade
607f61b3aedSSwapnil Jakhade /* DPTX mmr access functions */
608f61b3aedSSwapnil Jakhade
cdns_torrent_dp_write(struct regmap * regmap,u32 offset,u32 val)609cba472ecSSwapnil Jakhade static void cdns_torrent_dp_write(struct regmap *regmap, u32 offset, u32 val)
610f61b3aedSSwapnil Jakhade {
611cba472ecSSwapnil Jakhade regmap_write(regmap, offset, val);
612f61b3aedSSwapnil Jakhade }
613f61b3aedSSwapnil Jakhade
cdns_torrent_dp_read(struct regmap * regmap,u32 offset)614cba472ecSSwapnil Jakhade static u32 cdns_torrent_dp_read(struct regmap *regmap, u32 offset)
615f61b3aedSSwapnil Jakhade {
616cba472ecSSwapnil Jakhade u32 val;
617f61b3aedSSwapnil Jakhade
618cba472ecSSwapnil Jakhade regmap_read(regmap, offset, &val);
619cba472ecSSwapnil Jakhade return val;
620cba472ecSSwapnil Jakhade }
621f61b3aedSSwapnil Jakhade
622572d6592SSwapnil Jakhade /*
623572d6592SSwapnil Jakhade * Structure used to store values of PHY registers for voltage-related
624572d6592SSwapnil Jakhade * coefficients, for particular voltage swing and pre-emphasis level. Values
625572d6592SSwapnil Jakhade * are shared across all physical lanes.
626572d6592SSwapnil Jakhade */
627572d6592SSwapnil Jakhade struct coefficients {
628572d6592SSwapnil Jakhade /* Value of DRV_DIAG_TX_DRV register to use */
629572d6592SSwapnil Jakhade u16 diag_tx_drv;
630572d6592SSwapnil Jakhade /* Value of TX_TXCC_MGNFS_MULT_000 register to use */
631572d6592SSwapnil Jakhade u16 mgnfs_mult;
632572d6592SSwapnil Jakhade /* Value of TX_TXCC_CPOST_MULT_00 register to use */
633572d6592SSwapnil Jakhade u16 cpost_mult;
634572d6592SSwapnil Jakhade };
635572d6592SSwapnil Jakhade
636572d6592SSwapnil Jakhade /*
637572d6592SSwapnil Jakhade * Array consists of values of voltage-related registers for sd0801 PHY. A value
638572d6592SSwapnil Jakhade * of 0xFFFF is a placeholder for invalid combination, and will never be used.
639572d6592SSwapnil Jakhade */
640572d6592SSwapnil Jakhade static const struct coefficients vltg_coeff[4][4] = {
641572d6592SSwapnil Jakhade /* voltage swing 0, pre-emphasis 0->3 */
642572d6592SSwapnil Jakhade { {.diag_tx_drv = 0x0003, .mgnfs_mult = 0x002A,
643572d6592SSwapnil Jakhade .cpost_mult = 0x0000},
644572d6592SSwapnil Jakhade {.diag_tx_drv = 0x0003, .mgnfs_mult = 0x001F,
645572d6592SSwapnil Jakhade .cpost_mult = 0x0014},
646572d6592SSwapnil Jakhade {.diag_tx_drv = 0x0003, .mgnfs_mult = 0x0012,
647572d6592SSwapnil Jakhade .cpost_mult = 0x0020},
648572d6592SSwapnil Jakhade {.diag_tx_drv = 0x0003, .mgnfs_mult = 0x0000,
649572d6592SSwapnil Jakhade .cpost_mult = 0x002A}
650572d6592SSwapnil Jakhade },
651572d6592SSwapnil Jakhade
652572d6592SSwapnil Jakhade /* voltage swing 1, pre-emphasis 0->3 */
653572d6592SSwapnil Jakhade { {.diag_tx_drv = 0x0003, .mgnfs_mult = 0x001F,
654572d6592SSwapnil Jakhade .cpost_mult = 0x0000},
655572d6592SSwapnil Jakhade {.diag_tx_drv = 0x0003, .mgnfs_mult = 0x0013,
656572d6592SSwapnil Jakhade .cpost_mult = 0x0012},
657572d6592SSwapnil Jakhade {.diag_tx_drv = 0x0003, .mgnfs_mult = 0x0000,
658572d6592SSwapnil Jakhade .cpost_mult = 0x001F},
659572d6592SSwapnil Jakhade {.diag_tx_drv = 0xFFFF, .mgnfs_mult = 0xFFFF,
660572d6592SSwapnil Jakhade .cpost_mult = 0xFFFF}
661572d6592SSwapnil Jakhade },
662572d6592SSwapnil Jakhade
663572d6592SSwapnil Jakhade /* voltage swing 2, pre-emphasis 0->3 */
664572d6592SSwapnil Jakhade { {.diag_tx_drv = 0x0003, .mgnfs_mult = 0x0013,
665572d6592SSwapnil Jakhade .cpost_mult = 0x0000},
666572d6592SSwapnil Jakhade {.diag_tx_drv = 0x0003, .mgnfs_mult = 0x0000,
667572d6592SSwapnil Jakhade .cpost_mult = 0x0013},
668572d6592SSwapnil Jakhade {.diag_tx_drv = 0xFFFF, .mgnfs_mult = 0xFFFF,
669572d6592SSwapnil Jakhade .cpost_mult = 0xFFFF},
670572d6592SSwapnil Jakhade {.diag_tx_drv = 0xFFFF, .mgnfs_mult = 0xFFFF,
671572d6592SSwapnil Jakhade .cpost_mult = 0xFFFF}
672572d6592SSwapnil Jakhade },
673572d6592SSwapnil Jakhade
674572d6592SSwapnil Jakhade /* voltage swing 3, pre-emphasis 0->3 */
675572d6592SSwapnil Jakhade { {.diag_tx_drv = 0x0003, .mgnfs_mult = 0x0000,
676572d6592SSwapnil Jakhade .cpost_mult = 0x0000},
677572d6592SSwapnil Jakhade {.diag_tx_drv = 0xFFFF, .mgnfs_mult = 0xFFFF,
678572d6592SSwapnil Jakhade .cpost_mult = 0xFFFF},
679572d6592SSwapnil Jakhade {.diag_tx_drv = 0xFFFF, .mgnfs_mult = 0xFFFF,
680572d6592SSwapnil Jakhade .cpost_mult = 0xFFFF},
681572d6592SSwapnil Jakhade {.diag_tx_drv = 0xFFFF, .mgnfs_mult = 0xFFFF,
682572d6592SSwapnil Jakhade .cpost_mult = 0xFFFF}
683572d6592SSwapnil Jakhade }
684572d6592SSwapnil Jakhade };
685572d6592SSwapnil Jakhade
cdns_torrent_get_phy_type(enum cdns_torrent_phy_type phy_type)68684f55df8SSwapnil Jakhade static const char *cdns_torrent_get_phy_type(enum cdns_torrent_phy_type phy_type)
68784f55df8SSwapnil Jakhade {
68884f55df8SSwapnil Jakhade switch (phy_type) {
68984f55df8SSwapnil Jakhade case TYPE_DP:
69084f55df8SSwapnil Jakhade return "DisplayPort";
69184f55df8SSwapnil Jakhade case TYPE_PCIE:
69284f55df8SSwapnil Jakhade return "PCIe";
69384f55df8SSwapnil Jakhade case TYPE_SGMII:
69484f55df8SSwapnil Jakhade return "SGMII";
69584f55df8SSwapnil Jakhade case TYPE_QSGMII:
69684f55df8SSwapnil Jakhade return "QSGMII";
69784f55df8SSwapnil Jakhade case TYPE_USB:
69884f55df8SSwapnil Jakhade return "USB";
69916e0f0eaSSwapnil Jakhade case TYPE_USXGMII:
70016e0f0eaSSwapnil Jakhade return "USXGMII";
70184f55df8SSwapnil Jakhade default:
70284f55df8SSwapnil Jakhade return "None";
70384f55df8SSwapnil Jakhade }
70484f55df8SSwapnil Jakhade }
70584f55df8SSwapnil Jakhade
706e4b496a3SSwapnil Jakhade /*
707e4b496a3SSwapnil Jakhade * Set registers responsible for enabling and configuring SSC, with second and
708e4b496a3SSwapnil Jakhade * third register values provided by parameters.
709e4b496a3SSwapnil Jakhade */
710e4b496a3SSwapnil Jakhade static
cdns_torrent_dp_enable_ssc_19_2mhz(struct cdns_torrent_phy * cdns_phy,u32 ctrl2_val,u32 ctrl3_val)711e4b496a3SSwapnil Jakhade void cdns_torrent_dp_enable_ssc_19_2mhz(struct cdns_torrent_phy *cdns_phy,
712e4b496a3SSwapnil Jakhade u32 ctrl2_val, u32 ctrl3_val)
713e4b496a3SSwapnil Jakhade {
71469d114acSSwapnil Jakhade struct regmap *regmap = cdns_phy->regmap_common_cdb;
71569d114acSSwapnil Jakhade
71669d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_SS_CTRL1_M0, 0x0001);
71769d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_SS_CTRL1_M0, ctrl2_val);
71869d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_SS_CTRL1_M0, ctrl3_val);
71969d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_SS_CTRL4_M0, 0x0003);
72069d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_SS_CTRL1_M0, 0x0001);
72169d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_SS_CTRL1_M0, ctrl2_val);
72269d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_SS_CTRL1_M0, ctrl3_val);
72369d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_SS_CTRL4_M0, 0x0003);
724e4b496a3SSwapnil Jakhade }
725e4b496a3SSwapnil Jakhade
726e4b496a3SSwapnil Jakhade static
cdns_torrent_dp_pma_cmn_vco_cfg_19_2mhz(struct cdns_torrent_phy * cdns_phy,u32 rate,bool ssc)727e4b496a3SSwapnil Jakhade void cdns_torrent_dp_pma_cmn_vco_cfg_19_2mhz(struct cdns_torrent_phy *cdns_phy,
728e4b496a3SSwapnil Jakhade u32 rate, bool ssc)
729e4b496a3SSwapnil Jakhade {
73069d114acSSwapnil Jakhade struct regmap *regmap = cdns_phy->regmap_common_cdb;
73169d114acSSwapnil Jakhade
732e4b496a3SSwapnil Jakhade /* Assumes 19.2 MHz refclock */
733e4b496a3SSwapnil Jakhade switch (rate) {
734e4b496a3SSwapnil Jakhade /* Setting VCO for 10.8GHz */
735e4b496a3SSwapnil Jakhade case 2700:
736e4b496a3SSwapnil Jakhade case 5400:
737da055e55SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_INTDIV_M0, 0x0119);
738da055e55SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVL_M0, 0x4000);
739da055e55SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVH_M0, 0x0002);
740da055e55SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_HIGH_THR_M0, 0x00BC);
741da055e55SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL0_CTRL_M0, 0x0012);
742da055e55SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_INTDIV_M0, 0x0119);
743da055e55SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVL_M0, 0x4000);
744da055e55SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVH_M0, 0x0002);
745da055e55SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_HIGH_THR_M0, 0x00BC);
746da055e55SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL1_CTRL_M0, 0x0012);
747e4b496a3SSwapnil Jakhade if (ssc)
748da055e55SSwapnil Jakhade cdns_torrent_dp_enable_ssc_19_2mhz(cdns_phy, 0x033A, 0x006A);
749e4b496a3SSwapnil Jakhade break;
750e4b496a3SSwapnil Jakhade /* Setting VCO for 9.72GHz */
751e4b496a3SSwapnil Jakhade case 1620:
752e4b496a3SSwapnil Jakhade case 2430:
753e4b496a3SSwapnil Jakhade case 3240:
754da055e55SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_INTDIV_M0, 0x01FA);
755da055e55SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVL_M0, 0x4000);
756da055e55SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVH_M0, 0x0002);
757da055e55SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_HIGH_THR_M0, 0x0152);
758da055e55SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL0_CTRL_M0, 0x0002);
759da055e55SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_INTDIV_M0, 0x01FA);
760da055e55SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVL_M0, 0x4000);
761da055e55SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVH_M0, 0x0002);
762da055e55SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_HIGH_THR_M0, 0x0152);
763da055e55SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL1_CTRL_M0, 0x0002);
764e4b496a3SSwapnil Jakhade if (ssc)
765da055e55SSwapnil Jakhade cdns_torrent_dp_enable_ssc_19_2mhz(cdns_phy, 0x05DD, 0x0069);
766e4b496a3SSwapnil Jakhade break;
767e4b496a3SSwapnil Jakhade /* Setting VCO for 8.64GHz */
768e4b496a3SSwapnil Jakhade case 2160:
769e4b496a3SSwapnil Jakhade case 4320:
770da055e55SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_INTDIV_M0, 0x01C2);
771da055e55SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVL_M0, 0x0000);
772da055e55SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVH_M0, 0x0002);
773da055e55SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_HIGH_THR_M0, 0x012C);
774da055e55SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL0_CTRL_M0, 0x0002);
775da055e55SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_INTDIV_M0, 0x01C2);
776da055e55SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVL_M0, 0x0000);
777da055e55SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVH_M0, 0x0002);
778da055e55SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_HIGH_THR_M0, 0x012C);
779da055e55SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL1_CTRL_M0, 0x0002);
780e4b496a3SSwapnil Jakhade if (ssc)
781da055e55SSwapnil Jakhade cdns_torrent_dp_enable_ssc_19_2mhz(cdns_phy, 0x0536, 0x0069);
782e4b496a3SSwapnil Jakhade break;
783e4b496a3SSwapnil Jakhade /* Setting VCO for 8.1GHz */
784e4b496a3SSwapnil Jakhade case 8100:
785da055e55SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_INTDIV_M0, 0x01A5);
786da055e55SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVL_M0, 0xE000);
787da055e55SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVH_M0, 0x0002);
788da055e55SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_HIGH_THR_M0, 0x011A);
789da055e55SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL0_CTRL_M0, 0x0002);
790da055e55SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_INTDIV_M0, 0x01A5);
791da055e55SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVL_M0, 0xE000);
792da055e55SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVH_M0, 0x0002);
793da055e55SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_HIGH_THR_M0, 0x011A);
794da055e55SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL1_CTRL_M0, 0x0002);
795e4b496a3SSwapnil Jakhade if (ssc)
796da055e55SSwapnil Jakhade cdns_torrent_dp_enable_ssc_19_2mhz(cdns_phy, 0x04D7, 0x006A);
797e4b496a3SSwapnil Jakhade break;
798e4b496a3SSwapnil Jakhade }
799e4b496a3SSwapnil Jakhade
800e4b496a3SSwapnil Jakhade if (ssc) {
801da055e55SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_VCOCAL_PLLCNT_START, 0x025E);
802da055e55SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_LOCK_PLLCNT_THR, 0x0005);
803da055e55SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_VCOCAL_PLLCNT_START, 0x025E);
804da055e55SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_LOCK_PLLCNT_THR, 0x0005);
805e4b496a3SSwapnil Jakhade } else {
806da055e55SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_VCOCAL_PLLCNT_START, 0x0260);
807da055e55SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_VCOCAL_PLLCNT_START, 0x0260);
808e4b496a3SSwapnil Jakhade /* Set reset register values to disable SSC */
809da055e55SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_SS_CTRL1_M0, 0x0002);
810da055e55SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_SS_CTRL2_M0, 0x0000);
811da055e55SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_SS_CTRL3_M0, 0x0000);
812da055e55SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_SS_CTRL4_M0, 0x0000);
813da055e55SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_LOCK_PLLCNT_THR, 0x0003);
814da055e55SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_SS_CTRL1_M0, 0x0002);
815da055e55SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_SS_CTRL2_M0, 0x0000);
816da055e55SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_SS_CTRL3_M0, 0x0000);
817da055e55SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_SS_CTRL4_M0, 0x0000);
818da055e55SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_LOCK_PLLCNT_THR, 0x0003);
819e4b496a3SSwapnil Jakhade }
820e4b496a3SSwapnil Jakhade
82169d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_LOCK_REFCNT_START, 0x0099);
82269d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_LOCK_PLLCNT_START, 0x0099);
82369d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_LOCK_REFCNT_START, 0x0099);
82469d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_LOCK_PLLCNT_START, 0x0099);
825e4b496a3SSwapnil Jakhade }
826e4b496a3SSwapnil Jakhade
827e4b496a3SSwapnil Jakhade /*
828e4b496a3SSwapnil Jakhade * Set registers responsible for enabling and configuring SSC, with second
829e4b496a3SSwapnil Jakhade * register value provided by a parameter.
830e4b496a3SSwapnil Jakhade */
cdns_torrent_dp_enable_ssc_25mhz(struct cdns_torrent_phy * cdns_phy,u32 ctrl2_val)831e4b496a3SSwapnil Jakhade static void cdns_torrent_dp_enable_ssc_25mhz(struct cdns_torrent_phy *cdns_phy,
832e4b496a3SSwapnil Jakhade u32 ctrl2_val)
833e4b496a3SSwapnil Jakhade {
83469d114acSSwapnil Jakhade struct regmap *regmap = cdns_phy->regmap_common_cdb;
83569d114acSSwapnil Jakhade
83669d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_SS_CTRL1_M0, 0x0001);
83769d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_SS_CTRL1_M0, ctrl2_val);
83869d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_SS_CTRL1_M0, 0x007F);
83969d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_SS_CTRL4_M0, 0x0003);
84069d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_SS_CTRL1_M0, 0x0001);
84169d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_SS_CTRL1_M0, ctrl2_val);
84269d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_SS_CTRL1_M0, 0x007F);
84369d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_SS_CTRL4_M0, 0x0003);
844c589e701SYuti Amonkar }
845c589e701SYuti Amonkar
84692e9ccc6SSwapnil Jakhade static
cdns_torrent_dp_pma_cmn_vco_cfg_25mhz(struct cdns_torrent_phy * cdns_phy,u32 rate,bool ssc)847e4b496a3SSwapnil Jakhade void cdns_torrent_dp_pma_cmn_vco_cfg_25mhz(struct cdns_torrent_phy *cdns_phy,
848e4b496a3SSwapnil Jakhade u32 rate, bool ssc)
849c589e701SYuti Amonkar {
85069d114acSSwapnil Jakhade struct regmap *regmap = cdns_phy->regmap_common_cdb;
85169d114acSSwapnil Jakhade
852c589e701SYuti Amonkar /* Assumes 25 MHz refclock */
853e4b496a3SSwapnil Jakhade switch (rate) {
854c589e701SYuti Amonkar /* Setting VCO for 10.8GHz */
855c589e701SYuti Amonkar case 2700:
856c589e701SYuti Amonkar case 5400:
85769d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_INTDIV_M0, 0x01B0);
85869d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVL_M0, 0x0000);
85969d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVH_M0, 0x0002);
86069d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_HIGH_THR_M0, 0x0120);
86169d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_INTDIV_M0, 0x01B0);
86269d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVL_M0, 0x0000);
86369d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVH_M0, 0x0002);
86469d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_HIGH_THR_M0, 0x0120);
865e4b496a3SSwapnil Jakhade if (ssc)
866e4b496a3SSwapnil Jakhade cdns_torrent_dp_enable_ssc_25mhz(cdns_phy, 0x0423);
867c589e701SYuti Amonkar break;
868c589e701SYuti Amonkar /* Setting VCO for 9.72GHz */
869e4b496a3SSwapnil Jakhade case 1620:
870c589e701SYuti Amonkar case 2430:
871c589e701SYuti Amonkar case 3240:
87269d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_INTDIV_M0, 0x0184);
87369d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVL_M0, 0xCCCD);
87469d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVH_M0, 0x0002);
87569d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_HIGH_THR_M0, 0x0104);
87669d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_INTDIV_M0, 0x0184);
87769d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVL_M0, 0xCCCD);
87869d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVH_M0, 0x0002);
87969d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_HIGH_THR_M0, 0x0104);
880e4b496a3SSwapnil Jakhade if (ssc)
881e4b496a3SSwapnil Jakhade cdns_torrent_dp_enable_ssc_25mhz(cdns_phy, 0x03B9);
882c589e701SYuti Amonkar break;
883c589e701SYuti Amonkar /* Setting VCO for 8.64GHz */
884c589e701SYuti Amonkar case 2160:
885c589e701SYuti Amonkar case 4320:
88669d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_INTDIV_M0, 0x0159);
88769d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVL_M0, 0x999A);
88869d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVH_M0, 0x0002);
88969d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_HIGH_THR_M0, 0x00E7);
89069d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_INTDIV_M0, 0x0159);
89169d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVL_M0, 0x999A);
89269d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVH_M0, 0x0002);
89369d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_HIGH_THR_M0, 0x00E7);
894e4b496a3SSwapnil Jakhade if (ssc)
895e4b496a3SSwapnil Jakhade cdns_torrent_dp_enable_ssc_25mhz(cdns_phy, 0x034F);
896c589e701SYuti Amonkar break;
897c589e701SYuti Amonkar /* Setting VCO for 8.1GHz */
898c589e701SYuti Amonkar case 8100:
89969d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_INTDIV_M0, 0x0144);
90069d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVL_M0, 0x0000);
90169d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVH_M0, 0x0002);
90269d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_HIGH_THR_M0, 0x00D8);
90369d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_INTDIV_M0, 0x0144);
90469d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVL_M0, 0x0000);
90569d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVH_M0, 0x0002);
90669d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_HIGH_THR_M0, 0x00D8);
907e4b496a3SSwapnil Jakhade if (ssc)
908e4b496a3SSwapnil Jakhade cdns_torrent_dp_enable_ssc_25mhz(cdns_phy, 0x031A);
909c589e701SYuti Amonkar break;
910c589e701SYuti Amonkar }
911c589e701SYuti Amonkar
91269d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL0_CTRL_M0, 0x0002);
91369d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL1_CTRL_M0, 0x0002);
914e4b496a3SSwapnil Jakhade
915e4b496a3SSwapnil Jakhade if (ssc) {
91669d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap,
917e4b496a3SSwapnil Jakhade CMN_PLL0_VCOCAL_PLLCNT_START, 0x0315);
91869d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap,
919e4b496a3SSwapnil Jakhade CMN_PLL0_LOCK_PLLCNT_THR, 0x0005);
92069d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap,
921e4b496a3SSwapnil Jakhade CMN_PLL1_VCOCAL_PLLCNT_START, 0x0315);
92269d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap,
923e4b496a3SSwapnil Jakhade CMN_PLL1_LOCK_PLLCNT_THR, 0x0005);
924e4b496a3SSwapnil Jakhade } else {
92569d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap,
926e4b496a3SSwapnil Jakhade CMN_PLL0_VCOCAL_PLLCNT_START, 0x0317);
92769d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap,
928e4b496a3SSwapnil Jakhade CMN_PLL1_VCOCAL_PLLCNT_START, 0x0317);
929e4b496a3SSwapnil Jakhade /* Set reset register values to disable SSC */
93069d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_SS_CTRL1_M0, 0x0002);
93169d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_SS_CTRL2_M0, 0x0000);
93269d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_SS_CTRL3_M0, 0x0000);
93369d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_SS_CTRL4_M0, 0x0000);
93469d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap,
935e4b496a3SSwapnil Jakhade CMN_PLL0_LOCK_PLLCNT_THR, 0x0003);
93669d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_SS_CTRL1_M0, 0x0002);
93769d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_SS_CTRL2_M0, 0x0000);
93869d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_SS_CTRL3_M0, 0x0000);
93969d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_SS_CTRL4_M0, 0x0000);
94069d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap,
941e4b496a3SSwapnil Jakhade CMN_PLL1_LOCK_PLLCNT_THR, 0x0003);
942c589e701SYuti Amonkar }
943c589e701SYuti Amonkar
94469d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_LOCK_REFCNT_START, 0x00C7);
94569d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_LOCK_PLLCNT_START, 0x00C7);
94669d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_LOCK_REFCNT_START, 0x00C7);
94769d114acSSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_LOCK_PLLCNT_START, 0x00C7);
948e4b496a3SSwapnil Jakhade }
949e4b496a3SSwapnil Jakhade
9501cc45515SSwapnil Jakhade static
cdns_torrent_dp_pma_cmn_vco_cfg_100mhz(struct cdns_torrent_phy * cdns_phy,u32 rate,bool ssc)9511cc45515SSwapnil Jakhade void cdns_torrent_dp_pma_cmn_vco_cfg_100mhz(struct cdns_torrent_phy *cdns_phy,
9521cc45515SSwapnil Jakhade u32 rate, bool ssc)
9531cc45515SSwapnil Jakhade {
9541cc45515SSwapnil Jakhade struct regmap *regmap = cdns_phy->regmap_common_cdb;
9551cc45515SSwapnil Jakhade
9561cc45515SSwapnil Jakhade /* Assumes 100 MHz refclock */
9571cc45515SSwapnil Jakhade switch (rate) {
9581cc45515SSwapnil Jakhade /* Setting VCO for 10.8GHz */
9591cc45515SSwapnil Jakhade case 2700:
9601cc45515SSwapnil Jakhade case 5400:
961ede775a8SSwapnil Jakhade if (cdns_phy->dp_pll & DP_PLL0)
9621cc45515SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_DSM_FBH_OVRD_M0, 0x0022);
963ede775a8SSwapnil Jakhade
964ede775a8SSwapnil Jakhade if (cdns_phy->dp_pll & DP_PLL1) {
965ede775a8SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL1_CP_PADJ_M0, 0x0028);
9661cc45515SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_DSM_FBH_OVRD_M0, 0x0022);
9671cc45515SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_DSM_FBL_OVRD_M0, 0x000C);
968ede775a8SSwapnil Jakhade }
9691cc45515SSwapnil Jakhade break;
9701cc45515SSwapnil Jakhade /* Setting VCO for 9.72GHz */
9711cc45515SSwapnil Jakhade case 1620:
9721cc45515SSwapnil Jakhade case 2430:
9731cc45515SSwapnil Jakhade case 3240:
974ede775a8SSwapnil Jakhade if (cdns_phy->dp_pll & DP_PLL0) {
9751cc45515SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_DSM_DIAG_M0, 0x0004);
9761cc45515SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL0_CP_PADJ_M0, 0x0509);
9771cc45515SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL0_CP_IADJ_M0, 0x0F00);
9781cc45515SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL0_FILT_PADJ_M0, 0x0F08);
9791cc45515SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_INTDIV_M0, 0x0061);
9801cc45515SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVL_M0, 0x3333);
9811cc45515SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVH_M0, 0x0002);
9821cc45515SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_HIGH_THR_M0, 0x0042);
9831cc45515SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL0_CTRL_M0, 0x0002);
984ede775a8SSwapnil Jakhade }
985ede775a8SSwapnil Jakhade if (cdns_phy->dp_pll & DP_PLL1) {
986ede775a8SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_DSM_DIAG_M0, 0x0004);
987ede775a8SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL1_CP_PADJ_M0, 0x0509);
988ede775a8SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL1_CP_IADJ_M0, 0x0F00);
989ede775a8SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL1_FILT_PADJ_M0, 0x0F08);
990ede775a8SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_INTDIV_M0, 0x0061);
991ede775a8SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVL_M0, 0x3333);
992ede775a8SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVH_M0, 0x0002);
993ede775a8SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_HIGH_THR_M0, 0x0042);
9941cc45515SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL1_CTRL_M0, 0x0002);
995ede775a8SSwapnil Jakhade }
9961cc45515SSwapnil Jakhade break;
9971cc45515SSwapnil Jakhade /* Setting VCO for 8.64GHz */
9981cc45515SSwapnil Jakhade case 2160:
9991cc45515SSwapnil Jakhade case 4320:
1000ede775a8SSwapnil Jakhade if (cdns_phy->dp_pll & DP_PLL0) {
10011cc45515SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_DSM_DIAG_M0, 0x0004);
10021cc45515SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL0_CP_PADJ_M0, 0x0509);
10031cc45515SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL0_CP_IADJ_M0, 0x0F00);
10041cc45515SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL0_FILT_PADJ_M0, 0x0F08);
10051cc45515SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_INTDIV_M0, 0x0056);
10061cc45515SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVL_M0, 0x6666);
10071cc45515SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVH_M0, 0x0002);
10081cc45515SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_HIGH_THR_M0, 0x003A);
10091cc45515SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL0_CTRL_M0, 0x0002);
1010ede775a8SSwapnil Jakhade }
1011ede775a8SSwapnil Jakhade if (cdns_phy->dp_pll & DP_PLL1) {
1012ede775a8SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_DSM_DIAG_M0, 0x0004);
1013ede775a8SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL1_CP_PADJ_M0, 0x0509);
1014ede775a8SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL1_CP_IADJ_M0, 0x0F00);
1015ede775a8SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL1_FILT_PADJ_M0, 0x0F08);
1016ede775a8SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_INTDIV_M0, 0x0056);
1017ede775a8SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVL_M0, 0x6666);
1018ede775a8SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVH_M0, 0x0002);
1019ede775a8SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_HIGH_THR_M0, 0x003A);
10201cc45515SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL1_CTRL_M0, 0x0002);
1021ede775a8SSwapnil Jakhade }
10221cc45515SSwapnil Jakhade break;
10231cc45515SSwapnil Jakhade /* Setting VCO for 8.1GHz */
10241cc45515SSwapnil Jakhade case 8100:
1025ede775a8SSwapnil Jakhade if (cdns_phy->dp_pll & DP_PLL0) {
10261cc45515SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_DSM_DIAG_M0, 0x0004);
10271cc45515SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL0_CP_PADJ_M0, 0x0509);
10281cc45515SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL0_CP_IADJ_M0, 0x0F00);
10291cc45515SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL0_FILT_PADJ_M0, 0x0F08);
10301cc45515SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_INTDIV_M0, 0x0051);
10311cc45515SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVH_M0, 0x0002);
10321cc45515SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL0_HIGH_THR_M0, 0x0036);
10331cc45515SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL0_CTRL_M0, 0x0002);
1034ede775a8SSwapnil Jakhade }
1035ede775a8SSwapnil Jakhade if (cdns_phy->dp_pll & DP_PLL1) {
1036ede775a8SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_DSM_DIAG_M0, 0x0004);
1037ede775a8SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL1_CP_PADJ_M0, 0x0509);
1038ede775a8SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL1_CP_IADJ_M0, 0x0F00);
1039ede775a8SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL1_FILT_PADJ_M0, 0x0F08);
1040ede775a8SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_INTDIV_M0, 0x0051);
1041ede775a8SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVH_M0, 0x0002);
1042ede775a8SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PLL1_HIGH_THR_M0, 0x0036);
10431cc45515SSwapnil Jakhade cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL1_CTRL_M0, 0x0002);
1044ede775a8SSwapnil Jakhade }
10451cc45515SSwapnil Jakhade break;
10461cc45515SSwapnil Jakhade }
10471cc45515SSwapnil Jakhade }
10481cc45515SSwapnil Jakhade
10491b0524fcSSwapnil Jakhade /* Set PLL used for DP configuration */
cdns_torrent_dp_get_pll(struct cdns_torrent_phy * cdns_phy,enum cdns_torrent_phy_type phy_t2)10501b0524fcSSwapnil Jakhade static int cdns_torrent_dp_get_pll(struct cdns_torrent_phy *cdns_phy,
10511b0524fcSSwapnil Jakhade enum cdns_torrent_phy_type phy_t2)
10521b0524fcSSwapnil Jakhade {
10531b0524fcSSwapnil Jakhade switch (phy_t2) {
10541b0524fcSSwapnil Jakhade case TYPE_PCIE:
10551b0524fcSSwapnil Jakhade case TYPE_USB:
10561b0524fcSSwapnil Jakhade cdns_phy->dp_pll = DP_PLL1;
10571b0524fcSSwapnil Jakhade break;
10581b0524fcSSwapnil Jakhade case TYPE_SGMII:
10591b0524fcSSwapnil Jakhade case TYPE_QSGMII:
10601b0524fcSSwapnil Jakhade cdns_phy->dp_pll = DP_PLL0;
10611b0524fcSSwapnil Jakhade break;
10621b0524fcSSwapnil Jakhade case TYPE_NONE:
10631b0524fcSSwapnil Jakhade cdns_phy->dp_pll = DP_PLL0 | DP_PLL1;
10641b0524fcSSwapnil Jakhade break;
10651b0524fcSSwapnil Jakhade default:
10661b0524fcSSwapnil Jakhade dev_err(cdns_phy->dev, "Unsupported PHY configuration\n");
10671b0524fcSSwapnil Jakhade return -EINVAL;
10681b0524fcSSwapnil Jakhade }
10691b0524fcSSwapnil Jakhade
10701b0524fcSSwapnil Jakhade return 0;
10711b0524fcSSwapnil Jakhade }
10721b0524fcSSwapnil Jakhade
10735b16a790SSwapnil Jakhade /*
10745b16a790SSwapnil Jakhade * Enable or disable PLL for selected lanes.
10755b16a790SSwapnil Jakhade */
cdns_torrent_dp_set_pll_en(struct cdns_torrent_phy * cdns_phy,struct cdns_torrent_inst * inst,struct phy_configure_opts_dp * dp,bool enable)10765b16a790SSwapnil Jakhade static int cdns_torrent_dp_set_pll_en(struct cdns_torrent_phy *cdns_phy,
1077c756cc16SSwapnil Jakhade struct cdns_torrent_inst *inst,
10785b16a790SSwapnil Jakhade struct phy_configure_opts_dp *dp,
10795b16a790SSwapnil Jakhade bool enable)
10805b16a790SSwapnil Jakhade {
10815b16a790SSwapnil Jakhade struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg;
1082c756cc16SSwapnil Jakhade u32 rd_val, pll_ack_val;
1083c756cc16SSwapnil Jakhade int ret;
10845b16a790SSwapnil Jakhade
10855b16a790SSwapnil Jakhade /*
10865b16a790SSwapnil Jakhade * Used to determine, which bits to check for or enable in
10875b16a790SSwapnil Jakhade * PHY_PMA_XCVR_PLLCLK_EN register.
10885b16a790SSwapnil Jakhade */
10895b16a790SSwapnil Jakhade u32 pll_bits;
10905b16a790SSwapnil Jakhade /* Used to enable or disable lanes. */
10915b16a790SSwapnil Jakhade u32 pll_val;
10925b16a790SSwapnil Jakhade
1093c756cc16SSwapnil Jakhade /* Select values of registers and mask, depending on enabled lane count. */
1094c756cc16SSwapnil Jakhade pll_val = cdns_torrent_dp_read(regmap, PHY_PMA_XCVR_PLLCLK_EN);
10955b16a790SSwapnil Jakhade
1096c756cc16SSwapnil Jakhade if (enable) {
1097c756cc16SSwapnil Jakhade pll_bits = ((1 << dp->lanes) - 1);
1098c756cc16SSwapnil Jakhade pll_val |= pll_bits;
1099c756cc16SSwapnil Jakhade pll_ack_val = pll_bits;
1100c756cc16SSwapnil Jakhade } else {
1101c756cc16SSwapnil Jakhade pll_bits = ((1 << inst->num_lanes) - 1);
1102c756cc16SSwapnil Jakhade pll_val &= (~pll_bits);
1103c756cc16SSwapnil Jakhade pll_ack_val = 0;
1104c756cc16SSwapnil Jakhade }
11055b16a790SSwapnil Jakhade
11065b16a790SSwapnil Jakhade cdns_torrent_dp_write(regmap, PHY_PMA_XCVR_PLLCLK_EN, pll_val);
11075b16a790SSwapnil Jakhade
11085b16a790SSwapnil Jakhade /* Wait for acknowledgment from PHY. */
11095b16a790SSwapnil Jakhade ret = regmap_read_poll_timeout(regmap,
11105b16a790SSwapnil Jakhade PHY_PMA_XCVR_PLLCLK_EN_ACK,
11115b16a790SSwapnil Jakhade rd_val,
1112c756cc16SSwapnil Jakhade (rd_val & pll_bits) == pll_ack_val,
11135b16a790SSwapnil Jakhade 0, POLL_TIMEOUT_US);
11145b16a790SSwapnil Jakhade ndelay(100);
11155b16a790SSwapnil Jakhade return ret;
11165b16a790SSwapnil Jakhade }
11175b16a790SSwapnil Jakhade
cdns_torrent_dp_set_power_state(struct cdns_torrent_phy * cdns_phy,struct cdns_torrent_inst * inst,u32 num_lanes,enum phy_powerstate powerstate)111821c79146SSwapnil Jakhade static int cdns_torrent_dp_set_power_state(struct cdns_torrent_phy *cdns_phy,
1119c756cc16SSwapnil Jakhade struct cdns_torrent_inst *inst,
112021c79146SSwapnil Jakhade u32 num_lanes,
112121c79146SSwapnil Jakhade enum phy_powerstate powerstate)
112221c79146SSwapnil Jakhade {
112321c79146SSwapnil Jakhade /* Register value for power state for a single byte. */
1124c756cc16SSwapnil Jakhade u32 value_part, i;
1125c756cc16SSwapnil Jakhade u32 value = 0;
1126c756cc16SSwapnil Jakhade u32 mask = 0;
112721c79146SSwapnil Jakhade u32 read_val;
1128c756cc16SSwapnil Jakhade int ret;
1129cba472ecSSwapnil Jakhade struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg;
113021c79146SSwapnil Jakhade
113121c79146SSwapnil Jakhade switch (powerstate) {
113221c79146SSwapnil Jakhade case (POWERSTATE_A0):
113321c79146SSwapnil Jakhade value_part = 0x01U;
113421c79146SSwapnil Jakhade break;
113521c79146SSwapnil Jakhade case (POWERSTATE_A2):
113621c79146SSwapnil Jakhade value_part = 0x04U;
113721c79146SSwapnil Jakhade break;
113821c79146SSwapnil Jakhade default:
113921c79146SSwapnil Jakhade /* Powerstate A3 */
114021c79146SSwapnil Jakhade value_part = 0x08U;
114121c79146SSwapnil Jakhade break;
114221c79146SSwapnil Jakhade }
114321c79146SSwapnil Jakhade
1144c756cc16SSwapnil Jakhade /* Select values of registers and mask, depending on enabled lane count. */
1145c756cc16SSwapnil Jakhade
1146c756cc16SSwapnil Jakhade for (i = 0; i < num_lanes; i++) {
1147c756cc16SSwapnil Jakhade value |= (value_part << PHY_POWER_STATE_LN(i));
1148c756cc16SSwapnil Jakhade mask |= (PMA_XCVR_POWER_STATE_REQ_LN_MASK << PHY_POWER_STATE_LN(i));
114921c79146SSwapnil Jakhade }
115021c79146SSwapnil Jakhade
115121c79146SSwapnil Jakhade /* Set power state A<n>. */
1152cba472ecSSwapnil Jakhade cdns_torrent_dp_write(regmap, PHY_PMA_XCVR_POWER_STATE_REQ, value);
115321c79146SSwapnil Jakhade /* Wait, until PHY acknowledges power state completion. */
1154cba472ecSSwapnil Jakhade ret = regmap_read_poll_timeout(regmap, PHY_PMA_XCVR_POWER_STATE_ACK,
1155cba472ecSSwapnil Jakhade read_val, (read_val & mask) == value, 0,
115621c79146SSwapnil Jakhade POLL_TIMEOUT_US);
1157*1cffbf30SMa Ke if (ret)
1158*1cffbf30SMa Ke return ret;
1159*1cffbf30SMa Ke
1160cba472ecSSwapnil Jakhade cdns_torrent_dp_write(regmap, PHY_PMA_XCVR_POWER_STATE_REQ, 0x00000000);
116121c79146SSwapnil Jakhade ndelay(100);
116221c79146SSwapnil Jakhade
116321c79146SSwapnil Jakhade return ret;
116421c79146SSwapnil Jakhade }
116521c79146SSwapnil Jakhade
cdns_torrent_dp_run(struct cdns_torrent_phy * cdns_phy,struct cdns_torrent_inst * inst,u32 num_lanes)1166c756cc16SSwapnil Jakhade static int cdns_torrent_dp_run(struct cdns_torrent_phy *cdns_phy,
1167c756cc16SSwapnil Jakhade struct cdns_torrent_inst *inst, u32 num_lanes)
1168c589e701SYuti Amonkar {
1169c589e701SYuti Amonkar unsigned int read_val;
1170c589e701SYuti Amonkar int ret;
1171cba472ecSSwapnil Jakhade struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg;
1172c589e701SYuti Amonkar
1173c589e701SYuti Amonkar /*
1174c589e701SYuti Amonkar * waiting for ACK of pma_xcvr_pllclk_en_ln_*, only for the
1175c589e701SYuti Amonkar * master lane
1176c589e701SYuti Amonkar */
1177cba472ecSSwapnil Jakhade ret = regmap_read_poll_timeout(regmap, PHY_PMA_XCVR_PLLCLK_EN_ACK,
1178cba472ecSSwapnil Jakhade read_val, read_val & 1,
1179cba472ecSSwapnil Jakhade 0, POLL_TIMEOUT_US);
118021c79146SSwapnil Jakhade if (ret == -ETIMEDOUT) {
1181c589e701SYuti Amonkar dev_err(cdns_phy->dev,
1182c589e701SYuti Amonkar "timeout waiting for link PLL clock enable ack\n");
118321c79146SSwapnil Jakhade return ret;
1184c589e701SYuti Amonkar }
1185c589e701SYuti Amonkar
1186c589e701SYuti Amonkar ndelay(100);
1187c589e701SYuti Amonkar
1188c756cc16SSwapnil Jakhade ret = cdns_torrent_dp_set_power_state(cdns_phy, inst, num_lanes,
118921c79146SSwapnil Jakhade POWERSTATE_A2);
119021c79146SSwapnil Jakhade if (ret)
119121c79146SSwapnil Jakhade return ret;
1192c589e701SYuti Amonkar
1193c756cc16SSwapnil Jakhade ret = cdns_torrent_dp_set_power_state(cdns_phy, inst, num_lanes,
119421c79146SSwapnil Jakhade POWERSTATE_A0);
1195c589e701SYuti Amonkar
119621c79146SSwapnil Jakhade return ret;
1197c589e701SYuti Amonkar }
1198c589e701SYuti Amonkar
cdns_torrent_dp_wait_pma_cmn_ready(struct cdns_torrent_phy * cdns_phy)11995b16a790SSwapnil Jakhade static int cdns_torrent_dp_wait_pma_cmn_ready(struct cdns_torrent_phy *cdns_phy)
12005b16a790SSwapnil Jakhade {
12015b16a790SSwapnil Jakhade unsigned int reg;
12025b16a790SSwapnil Jakhade int ret;
12035b16a790SSwapnil Jakhade struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg;
12045b16a790SSwapnil Jakhade
12055b16a790SSwapnil Jakhade ret = regmap_read_poll_timeout(regmap, PHY_PMA_CMN_READY, reg,
12065b16a790SSwapnil Jakhade reg & 1, 0, POLL_TIMEOUT_US);
12075b16a790SSwapnil Jakhade if (ret == -ETIMEDOUT) {
12085b16a790SSwapnil Jakhade dev_err(cdns_phy->dev,
12095b16a790SSwapnil Jakhade "timeout waiting for PMA common ready\n");
12105b16a790SSwapnil Jakhade return -ETIMEDOUT;
12115b16a790SSwapnil Jakhade }
12125b16a790SSwapnil Jakhade
12135b16a790SSwapnil Jakhade return 0;
12145b16a790SSwapnil Jakhade }
12155b16a790SSwapnil Jakhade
cdns_torrent_dp_pma_cmn_rate(struct cdns_torrent_phy * cdns_phy,struct cdns_torrent_inst * inst,u32 rate,u32 num_lanes)12165b16a790SSwapnil Jakhade static void cdns_torrent_dp_pma_cmn_rate(struct cdns_torrent_phy *cdns_phy,
1217c756cc16SSwapnil Jakhade struct cdns_torrent_inst *inst,
12185b16a790SSwapnil Jakhade u32 rate, u32 num_lanes)
12195b16a790SSwapnil Jakhade {
12205b16a790SSwapnil Jakhade unsigned int clk_sel_val = 0;
12215b16a790SSwapnil Jakhade unsigned int hsclk_div_val = 0;
12225b16a790SSwapnil Jakhade unsigned int i;
12235b16a790SSwapnil Jakhade
12245b16a790SSwapnil Jakhade switch (rate) {
12255b16a790SSwapnil Jakhade case 1620:
12265b16a790SSwapnil Jakhade clk_sel_val = 0x0f01;
12275b16a790SSwapnil Jakhade hsclk_div_val = 2;
12285b16a790SSwapnil Jakhade break;
12295b16a790SSwapnil Jakhade case 2160:
12305b16a790SSwapnil Jakhade case 2430:
12315b16a790SSwapnil Jakhade case 2700:
12325b16a790SSwapnil Jakhade clk_sel_val = 0x0701;
12335b16a790SSwapnil Jakhade hsclk_div_val = 1;
12345b16a790SSwapnil Jakhade break;
12355b16a790SSwapnil Jakhade case 3240:
12365b16a790SSwapnil Jakhade clk_sel_val = 0x0b00;
12375b16a790SSwapnil Jakhade hsclk_div_val = 2;
12385b16a790SSwapnil Jakhade break;
12395b16a790SSwapnil Jakhade case 4320:
12405b16a790SSwapnil Jakhade case 5400:
12415b16a790SSwapnil Jakhade clk_sel_val = 0x0301;
12425b16a790SSwapnil Jakhade hsclk_div_val = 0;
12435b16a790SSwapnil Jakhade break;
12445b16a790SSwapnil Jakhade case 8100:
12455b16a790SSwapnil Jakhade clk_sel_val = 0x0200;
12465b16a790SSwapnil Jakhade hsclk_div_val = 0;
12475b16a790SSwapnil Jakhade break;
12485b16a790SSwapnil Jakhade }
12495b16a790SSwapnil Jakhade
1250c756cc16SSwapnil Jakhade if (cdns_phy->dp_pll & DP_PLL0)
12515b16a790SSwapnil Jakhade cdns_torrent_phy_write(cdns_phy->regmap_common_cdb,
12525b16a790SSwapnil Jakhade CMN_PDIAG_PLL0_CLK_SEL_M0, clk_sel_val);
1253c756cc16SSwapnil Jakhade
1254c756cc16SSwapnil Jakhade if (cdns_phy->dp_pll & DP_PLL1)
12555b16a790SSwapnil Jakhade cdns_torrent_phy_write(cdns_phy->regmap_common_cdb,
12565b16a790SSwapnil Jakhade CMN_PDIAG_PLL1_CLK_SEL_M0, clk_sel_val);
12575b16a790SSwapnil Jakhade
12585b16a790SSwapnil Jakhade /* PMA lane configuration to deal with multi-link operation */
12595b16a790SSwapnil Jakhade for (i = 0; i < num_lanes; i++)
1260c756cc16SSwapnil Jakhade cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[inst->mlane + i],
12615b16a790SSwapnil Jakhade XCVR_DIAG_HSCLK_DIV, hsclk_div_val);
12625b16a790SSwapnil Jakhade }
12635b16a790SSwapnil Jakhade
12645b16a790SSwapnil Jakhade /*
12655b16a790SSwapnil Jakhade * Perform register operations related to setting link rate, once powerstate is
12665b16a790SSwapnil Jakhade * set and PLL disable request was processed.
12675b16a790SSwapnil Jakhade */
cdns_torrent_dp_configure_rate(struct cdns_torrent_phy * cdns_phy,struct cdns_torrent_inst * inst,struct phy_configure_opts_dp * dp)12685b16a790SSwapnil Jakhade static int cdns_torrent_dp_configure_rate(struct cdns_torrent_phy *cdns_phy,
1269c756cc16SSwapnil Jakhade struct cdns_torrent_inst *inst,
12705b16a790SSwapnil Jakhade struct phy_configure_opts_dp *dp)
12715b16a790SSwapnil Jakhade {
1272c756cc16SSwapnil Jakhade u32 read_val, field_val;
1273c756cc16SSwapnil Jakhade int ret;
12745b16a790SSwapnil Jakhade
1275c756cc16SSwapnil Jakhade /*
1276c756cc16SSwapnil Jakhade * Disable the associated PLL (cmn_pll0_en or cmn_pll1_en) before
1277c756cc16SSwapnil Jakhade * re-programming the new data rate.
1278c756cc16SSwapnil Jakhade */
1279c756cc16SSwapnil Jakhade ret = regmap_field_read(cdns_phy->phy_pma_pll_raw_ctrl, &field_val);
1280c756cc16SSwapnil Jakhade if (ret)
1281c756cc16SSwapnil Jakhade return ret;
1282c756cc16SSwapnil Jakhade field_val &= ~(cdns_phy->dp_pll);
1283c756cc16SSwapnil Jakhade regmap_field_write(cdns_phy->phy_pma_pll_raw_ctrl, field_val);
12845b16a790SSwapnil Jakhade
12855b16a790SSwapnil Jakhade /*
12865b16a790SSwapnil Jakhade * Wait for PLL ready de-assertion.
12875b16a790SSwapnil Jakhade * For PLL0 - PHY_PMA_CMN_CTRL2[2] == 1
1288c756cc16SSwapnil Jakhade * For PLL1 - PHY_PMA_CMN_CTRL2[3] == 1
12895b16a790SSwapnil Jakhade */
1290c756cc16SSwapnil Jakhade if (cdns_phy->dp_pll & DP_PLL0) {
12915b16a790SSwapnil Jakhade ret = regmap_field_read_poll_timeout(cdns_phy->phy_pma_cmn_ctrl_2,
12925b16a790SSwapnil Jakhade read_val,
12935b16a790SSwapnil Jakhade ((read_val >> 2) & 0x01) != 0,
12945b16a790SSwapnil Jakhade 0, POLL_TIMEOUT_US);
12955b16a790SSwapnil Jakhade if (ret)
12965b16a790SSwapnil Jakhade return ret;
1297c756cc16SSwapnil Jakhade }
1298c756cc16SSwapnil Jakhade
1299c756cc16SSwapnil Jakhade if ((cdns_phy->dp_pll & DP_PLL1) && cdns_phy->nsubnodes != 1) {
1300c756cc16SSwapnil Jakhade ret = regmap_field_read_poll_timeout(cdns_phy->phy_pma_cmn_ctrl_2,
1301c756cc16SSwapnil Jakhade read_val,
1302c756cc16SSwapnil Jakhade ((read_val >> 3) & 0x01) != 0,
1303c756cc16SSwapnil Jakhade 0, POLL_TIMEOUT_US);
1304c756cc16SSwapnil Jakhade if (ret)
1305c756cc16SSwapnil Jakhade return ret;
1306c756cc16SSwapnil Jakhade }
13075b16a790SSwapnil Jakhade ndelay(200);
13085b16a790SSwapnil Jakhade
13095b16a790SSwapnil Jakhade /* DP Rate Change - VCO Output settings. */
1310da055e55SSwapnil Jakhade if (cdns_phy->ref_clk_rate == CLK_19_2_MHZ)
13115b16a790SSwapnil Jakhade /* PMA common configuration 19.2MHz */
1312da055e55SSwapnil Jakhade cdns_torrent_dp_pma_cmn_vco_cfg_19_2mhz(cdns_phy, dp->link_rate, dp->ssc);
1313da055e55SSwapnil Jakhade else if (cdns_phy->ref_clk_rate == CLK_25_MHZ)
13145b16a790SSwapnil Jakhade /* PMA common configuration 25MHz */
1315da055e55SSwapnil Jakhade cdns_torrent_dp_pma_cmn_vco_cfg_25mhz(cdns_phy, dp->link_rate, dp->ssc);
13161cc45515SSwapnil Jakhade else if (cdns_phy->ref_clk_rate == CLK_100_MHZ)
13171cc45515SSwapnil Jakhade /* PMA common configuration 100MHz */
13181cc45515SSwapnil Jakhade cdns_torrent_dp_pma_cmn_vco_cfg_100mhz(cdns_phy, dp->link_rate, dp->ssc);
13191cc45515SSwapnil Jakhade
1320c756cc16SSwapnil Jakhade cdns_torrent_dp_pma_cmn_rate(cdns_phy, inst, dp->link_rate, dp->lanes);
13215b16a790SSwapnil Jakhade
1322c756cc16SSwapnil Jakhade /* Enable the associated PLL (cmn_pll0_en or cmn_pll1_en) */
1323c756cc16SSwapnil Jakhade ret = regmap_field_read(cdns_phy->phy_pma_pll_raw_ctrl, &field_val);
1324c756cc16SSwapnil Jakhade if (ret)
1325c756cc16SSwapnil Jakhade return ret;
1326c756cc16SSwapnil Jakhade field_val |= cdns_phy->dp_pll;
1327c756cc16SSwapnil Jakhade regmap_field_write(cdns_phy->phy_pma_pll_raw_ctrl, field_val);
13285b16a790SSwapnil Jakhade
13295b16a790SSwapnil Jakhade /*
13305b16a790SSwapnil Jakhade * Wait for PLL ready assertion.
13315b16a790SSwapnil Jakhade * For PLL0 - PHY_PMA_CMN_CTRL2[0] == 1
1332c756cc16SSwapnil Jakhade * For PLL1 - PHY_PMA_CMN_CTRL2[1] == 1
13335b16a790SSwapnil Jakhade */
1334c756cc16SSwapnil Jakhade if (cdns_phy->dp_pll & DP_PLL0) {
13355b16a790SSwapnil Jakhade ret = regmap_field_read_poll_timeout(cdns_phy->phy_pma_cmn_ctrl_2,
13365b16a790SSwapnil Jakhade read_val,
13375b16a790SSwapnil Jakhade (read_val & 0x01) != 0,
13385b16a790SSwapnil Jakhade 0, POLL_TIMEOUT_US);
1339c756cc16SSwapnil Jakhade if (ret)
1340c756cc16SSwapnil Jakhade return ret;
1341c756cc16SSwapnil Jakhade }
1342c756cc16SSwapnil Jakhade
1343c756cc16SSwapnil Jakhade if ((cdns_phy->dp_pll & DP_PLL1) && cdns_phy->nsubnodes != 1)
1344c756cc16SSwapnil Jakhade ret = regmap_field_read_poll_timeout(cdns_phy->phy_pma_cmn_ctrl_2,
1345c756cc16SSwapnil Jakhade read_val,
1346c756cc16SSwapnil Jakhade ((read_val >> 1) & 0x01) != 0,
1347c756cc16SSwapnil Jakhade 0, POLL_TIMEOUT_US);
1348c756cc16SSwapnil Jakhade
13495b16a790SSwapnil Jakhade return ret;
13505b16a790SSwapnil Jakhade }
13515b16a790SSwapnil Jakhade
13525b16a790SSwapnil Jakhade /*
13535b16a790SSwapnil Jakhade * Verify, that parameters to configure PHY with are correct.
13545b16a790SSwapnil Jakhade */
cdns_torrent_dp_verify_config(struct cdns_torrent_inst * inst,struct phy_configure_opts_dp * dp)13555b16a790SSwapnil Jakhade static int cdns_torrent_dp_verify_config(struct cdns_torrent_inst *inst,
13565b16a790SSwapnil Jakhade struct phy_configure_opts_dp *dp)
13575b16a790SSwapnil Jakhade {
13585b16a790SSwapnil Jakhade u8 i;
13595b16a790SSwapnil Jakhade
13605b16a790SSwapnil Jakhade /* If changing link rate was required, verify it's supported. */
13615b16a790SSwapnil Jakhade if (dp->set_rate) {
13625b16a790SSwapnil Jakhade switch (dp->link_rate) {
13635b16a790SSwapnil Jakhade case 1620:
13645b16a790SSwapnil Jakhade case 2160:
13655b16a790SSwapnil Jakhade case 2430:
13665b16a790SSwapnil Jakhade case 2700:
13675b16a790SSwapnil Jakhade case 3240:
13685b16a790SSwapnil Jakhade case 4320:
13695b16a790SSwapnil Jakhade case 5400:
13705b16a790SSwapnil Jakhade case 8100:
13715b16a790SSwapnil Jakhade /* valid bit rate */
13725b16a790SSwapnil Jakhade break;
13735b16a790SSwapnil Jakhade default:
13745b16a790SSwapnil Jakhade return -EINVAL;
13755b16a790SSwapnil Jakhade }
13765b16a790SSwapnil Jakhade }
13775b16a790SSwapnil Jakhade
13785b16a790SSwapnil Jakhade /* Verify lane count. */
13795b16a790SSwapnil Jakhade switch (dp->lanes) {
13805b16a790SSwapnil Jakhade case 1:
13815b16a790SSwapnil Jakhade case 2:
13825b16a790SSwapnil Jakhade case 4:
13835b16a790SSwapnil Jakhade /* valid lane count. */
13845b16a790SSwapnil Jakhade break;
13855b16a790SSwapnil Jakhade default:
13865b16a790SSwapnil Jakhade return -EINVAL;
13875b16a790SSwapnil Jakhade }
13885b16a790SSwapnil Jakhade
13895b16a790SSwapnil Jakhade /* Check against actual number of PHY's lanes. */
13905b16a790SSwapnil Jakhade if (dp->lanes > inst->num_lanes)
13915b16a790SSwapnil Jakhade return -EINVAL;
13925b16a790SSwapnil Jakhade
13935b16a790SSwapnil Jakhade /*
13945b16a790SSwapnil Jakhade * If changing voltages is required, check swing and pre-emphasis
13955b16a790SSwapnil Jakhade * levels, per-lane.
13965b16a790SSwapnil Jakhade */
13975b16a790SSwapnil Jakhade if (dp->set_voltages) {
13985b16a790SSwapnil Jakhade /* Lane count verified previously. */
13995b16a790SSwapnil Jakhade for (i = 0; i < dp->lanes; i++) {
14005b16a790SSwapnil Jakhade if (dp->voltage[i] > 3 || dp->pre[i] > 3)
14015b16a790SSwapnil Jakhade return -EINVAL;
14025b16a790SSwapnil Jakhade
14035b16a790SSwapnil Jakhade /* Sum of voltage swing and pre-emphasis levels cannot
14045b16a790SSwapnil Jakhade * exceed 3.
14055b16a790SSwapnil Jakhade */
14065b16a790SSwapnil Jakhade if (dp->voltage[i] + dp->pre[i] > 3)
14075b16a790SSwapnil Jakhade return -EINVAL;
14085b16a790SSwapnil Jakhade }
14095b16a790SSwapnil Jakhade }
14105b16a790SSwapnil Jakhade
14115b16a790SSwapnil Jakhade return 0;
14125b16a790SSwapnil Jakhade }
14135b16a790SSwapnil Jakhade
14145b16a790SSwapnil Jakhade /* 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,struct cdns_torrent_inst * inst,u32 num_lanes)14155b16a790SSwapnil Jakhade static void cdns_torrent_dp_set_a0_pll(struct cdns_torrent_phy *cdns_phy,
1416c756cc16SSwapnil Jakhade struct cdns_torrent_inst *inst,
14175b16a790SSwapnil Jakhade u32 num_lanes)
14185b16a790SSwapnil Jakhade {
14195b16a790SSwapnil Jakhade struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg;
14205b16a790SSwapnil Jakhade u32 pwr_state = cdns_torrent_dp_read(regmap,
14215b16a790SSwapnil Jakhade PHY_PMA_XCVR_POWER_STATE_REQ);
14225b16a790SSwapnil Jakhade u32 pll_clk_en = cdns_torrent_dp_read(regmap,
14235b16a790SSwapnil Jakhade PHY_PMA_XCVR_PLLCLK_EN);
1424c756cc16SSwapnil Jakhade u32 i;
14255b16a790SSwapnil Jakhade
1426c756cc16SSwapnil Jakhade for (i = 0; i < num_lanes; i++) {
1427c756cc16SSwapnil Jakhade pwr_state &= ~(PMA_XCVR_POWER_STATE_REQ_LN_MASK
1428c756cc16SSwapnil Jakhade << PHY_POWER_STATE_LN(inst->mlane + i));
14295b16a790SSwapnil Jakhade
1430c756cc16SSwapnil Jakhade pll_clk_en &= ~(0x01U << (inst->mlane + i));
14315b16a790SSwapnil Jakhade }
14325b16a790SSwapnil Jakhade
14335b16a790SSwapnil Jakhade cdns_torrent_dp_write(regmap, PHY_PMA_XCVR_POWER_STATE_REQ, pwr_state);
14345b16a790SSwapnil Jakhade cdns_torrent_dp_write(regmap, PHY_PMA_XCVR_PLLCLK_EN, pll_clk_en);
14355b16a790SSwapnil Jakhade }
14365b16a790SSwapnil Jakhade
14375b16a790SSwapnil Jakhade /* Configure lane count as required. */
cdns_torrent_dp_set_lanes(struct cdns_torrent_phy * cdns_phy,struct cdns_torrent_inst * inst,struct phy_configure_opts_dp * dp)14385b16a790SSwapnil Jakhade static int cdns_torrent_dp_set_lanes(struct cdns_torrent_phy *cdns_phy,
1439c756cc16SSwapnil Jakhade struct cdns_torrent_inst *inst,
14405b16a790SSwapnil Jakhade struct phy_configure_opts_dp *dp)
14415b16a790SSwapnil Jakhade {
1442c756cc16SSwapnil Jakhade u32 value, i;
1443c756cc16SSwapnil Jakhade int ret;
14445b16a790SSwapnil Jakhade struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg;
14455b16a790SSwapnil Jakhade u8 lane_mask = (1 << dp->lanes) - 1;
1446c756cc16SSwapnil Jakhade u8 pma_tx_elec_idle_mask = 0;
1447c756cc16SSwapnil Jakhade u32 clane = inst->mlane;
1448c756cc16SSwapnil Jakhade
1449c756cc16SSwapnil Jakhade lane_mask <<= clane;
14505b16a790SSwapnil Jakhade
14515b16a790SSwapnil Jakhade value = cdns_torrent_dp_read(regmap, PHY_RESET);
14525b16a790SSwapnil Jakhade /* clear pma_tx_elec_idle_ln_* bits. */
1453c756cc16SSwapnil Jakhade pma_tx_elec_idle_mask = ((1 << inst->num_lanes) - 1) << clane;
1454c756cc16SSwapnil Jakhade
1455c756cc16SSwapnil Jakhade pma_tx_elec_idle_mask <<= PMA_TX_ELEC_IDLE_SHIFT;
1456c756cc16SSwapnil Jakhade
1457c756cc16SSwapnil Jakhade value &= ~pma_tx_elec_idle_mask;
1458c756cc16SSwapnil Jakhade
14595b16a790SSwapnil Jakhade /* Assert pma_tx_elec_idle_ln_* for disabled lanes. */
14605b16a790SSwapnil Jakhade value |= ((~lane_mask) << PMA_TX_ELEC_IDLE_SHIFT) &
1461c756cc16SSwapnil Jakhade pma_tx_elec_idle_mask;
1462c756cc16SSwapnil Jakhade
14635b16a790SSwapnil Jakhade cdns_torrent_dp_write(regmap, PHY_RESET, value);
14645b16a790SSwapnil Jakhade
1465c756cc16SSwapnil Jakhade /* reset the link by asserting master lane phy_l0*_reset_n low */
14665b16a790SSwapnil Jakhade cdns_torrent_dp_write(regmap, PHY_RESET,
1467c756cc16SSwapnil Jakhade value & (~(1 << clane)));
14685b16a790SSwapnil Jakhade
14695b16a790SSwapnil Jakhade /*
1470c756cc16SSwapnil Jakhade * Assert lane reset on unused lanes and master lane so they remain in reset
14715b16a790SSwapnil Jakhade * and powered down when re-enabling the link
14725b16a790SSwapnil Jakhade */
1473c756cc16SSwapnil Jakhade for (i = 0; i < inst->num_lanes; i++)
1474c756cc16SSwapnil Jakhade value &= (~(1 << (clane + i)));
1475c756cc16SSwapnil Jakhade
1476c756cc16SSwapnil Jakhade for (i = 1; i < inst->num_lanes; i++)
1477c756cc16SSwapnil Jakhade value |= ((1 << (clane + i)) & lane_mask);
1478c756cc16SSwapnil Jakhade
14795b16a790SSwapnil Jakhade cdns_torrent_dp_write(regmap, PHY_RESET, value);
14805b16a790SSwapnil Jakhade
1481c756cc16SSwapnil Jakhade cdns_torrent_dp_set_a0_pll(cdns_phy, inst, dp->lanes);
14825b16a790SSwapnil Jakhade
14835b16a790SSwapnil Jakhade /* release phy_l0*_reset_n based on used laneCount */
1484c756cc16SSwapnil Jakhade for (i = 0; i < inst->num_lanes; i++)
1485c756cc16SSwapnil Jakhade value &= (~(1 << (clane + i)));
1486c756cc16SSwapnil Jakhade
1487c756cc16SSwapnil Jakhade for (i = 0; i < inst->num_lanes; i++)
1488c756cc16SSwapnil Jakhade value |= ((1 << (clane + i)) & lane_mask);
1489c756cc16SSwapnil Jakhade
14905b16a790SSwapnil Jakhade cdns_torrent_dp_write(regmap, PHY_RESET, value);
14915b16a790SSwapnil Jakhade
14925b16a790SSwapnil Jakhade /* Wait, until PHY gets ready after releasing PHY reset signal. */
14935b16a790SSwapnil Jakhade ret = cdns_torrent_dp_wait_pma_cmn_ready(cdns_phy);
14945b16a790SSwapnil Jakhade if (ret)
14955b16a790SSwapnil Jakhade return ret;
14965b16a790SSwapnil Jakhade
14975b16a790SSwapnil Jakhade ndelay(100);
14985b16a790SSwapnil Jakhade
14995b16a790SSwapnil Jakhade /* release pma_xcvr_pllclk_en_ln_*, only for the master lane */
1500c756cc16SSwapnil Jakhade value = cdns_torrent_dp_read(regmap, PHY_PMA_XCVR_PLLCLK_EN);
1501c756cc16SSwapnil Jakhade value |= (1 << clane);
1502c756cc16SSwapnil Jakhade cdns_torrent_dp_write(regmap, PHY_PMA_XCVR_PLLCLK_EN, value);
15035b16a790SSwapnil Jakhade
1504c756cc16SSwapnil Jakhade ret = cdns_torrent_dp_run(cdns_phy, inst, dp->lanes);
15055b16a790SSwapnil Jakhade
15065b16a790SSwapnil Jakhade return ret;
15075b16a790SSwapnil Jakhade }
15085b16a790SSwapnil Jakhade
15095b16a790SSwapnil Jakhade /* Configure link rate as required. */
cdns_torrent_dp_set_rate(struct cdns_torrent_phy * cdns_phy,struct cdns_torrent_inst * inst,struct phy_configure_opts_dp * dp)15105b16a790SSwapnil Jakhade static int cdns_torrent_dp_set_rate(struct cdns_torrent_phy *cdns_phy,
1511c756cc16SSwapnil Jakhade struct cdns_torrent_inst *inst,
15125b16a790SSwapnil Jakhade struct phy_configure_opts_dp *dp)
15135b16a790SSwapnil Jakhade {
1514c756cc16SSwapnil Jakhade int ret;
15155b16a790SSwapnil Jakhade
1516c756cc16SSwapnil Jakhade ret = cdns_torrent_dp_set_power_state(cdns_phy, inst, dp->lanes,
15175b16a790SSwapnil Jakhade POWERSTATE_A3);
15185b16a790SSwapnil Jakhade if (ret)
15195b16a790SSwapnil Jakhade return ret;
1520c756cc16SSwapnil Jakhade ret = cdns_torrent_dp_set_pll_en(cdns_phy, inst, dp, false);
15215b16a790SSwapnil Jakhade if (ret)
15225b16a790SSwapnil Jakhade return ret;
15235b16a790SSwapnil Jakhade ndelay(200);
15245b16a790SSwapnil Jakhade
1525c756cc16SSwapnil Jakhade ret = cdns_torrent_dp_configure_rate(cdns_phy, inst, dp);
15265b16a790SSwapnil Jakhade if (ret)
15275b16a790SSwapnil Jakhade return ret;
15285b16a790SSwapnil Jakhade ndelay(200);
15295b16a790SSwapnil Jakhade
1530c756cc16SSwapnil Jakhade ret = cdns_torrent_dp_set_pll_en(cdns_phy, inst, dp, true);
15315b16a790SSwapnil Jakhade if (ret)
15325b16a790SSwapnil Jakhade return ret;
1533c756cc16SSwapnil Jakhade ret = cdns_torrent_dp_set_power_state(cdns_phy, inst, dp->lanes,
15345b16a790SSwapnil Jakhade POWERSTATE_A2);
15355b16a790SSwapnil Jakhade if (ret)
15365b16a790SSwapnil Jakhade return ret;
1537c756cc16SSwapnil Jakhade ret = cdns_torrent_dp_set_power_state(cdns_phy, inst, dp->lanes,
15385b16a790SSwapnil Jakhade POWERSTATE_A0);
15395b16a790SSwapnil Jakhade if (ret)
15405b16a790SSwapnil Jakhade return ret;
15415b16a790SSwapnil Jakhade ndelay(900);
15425b16a790SSwapnil Jakhade
15435b16a790SSwapnil Jakhade return ret;
15445b16a790SSwapnil Jakhade }
15455b16a790SSwapnil Jakhade
15465b16a790SSwapnil Jakhade /* Configure voltage swing and pre-emphasis for all enabled lanes. */
cdns_torrent_dp_set_voltages(struct cdns_torrent_phy * cdns_phy,struct cdns_torrent_inst * inst,struct phy_configure_opts_dp * dp)15475b16a790SSwapnil Jakhade static void cdns_torrent_dp_set_voltages(struct cdns_torrent_phy *cdns_phy,
1548c756cc16SSwapnil Jakhade struct cdns_torrent_inst *inst,
15495b16a790SSwapnil Jakhade struct phy_configure_opts_dp *dp)
15505b16a790SSwapnil Jakhade {
15515b16a790SSwapnil Jakhade u8 lane;
15525b16a790SSwapnil Jakhade u16 val;
15535b16a790SSwapnil Jakhade
15545b16a790SSwapnil Jakhade for (lane = 0; lane < dp->lanes; lane++) {
1555c756cc16SSwapnil Jakhade val = cdns_torrent_phy_read(cdns_phy->regmap_tx_lane_cdb[inst->mlane + lane],
15565b16a790SSwapnil Jakhade TX_DIAG_ACYA);
15575b16a790SSwapnil Jakhade /*
15585b16a790SSwapnil Jakhade * Write 1 to register bit TX_DIAG_ACYA[0] to freeze the
15595b16a790SSwapnil Jakhade * current state of the analog TX driver.
15605b16a790SSwapnil Jakhade */
15615b16a790SSwapnil Jakhade val |= TX_DIAG_ACYA_HBDC_MASK;
1562c756cc16SSwapnil Jakhade cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[inst->mlane + lane],
15635b16a790SSwapnil Jakhade TX_DIAG_ACYA, val);
15645b16a790SSwapnil Jakhade
1565c756cc16SSwapnil Jakhade cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[inst->mlane + lane],
15665b16a790SSwapnil Jakhade TX_TXCC_CTRL, 0x08A4);
15675b16a790SSwapnil Jakhade val = vltg_coeff[dp->voltage[lane]][dp->pre[lane]].diag_tx_drv;
1568c756cc16SSwapnil Jakhade cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[inst->mlane + lane],
15695b16a790SSwapnil Jakhade DRV_DIAG_TX_DRV, val);
15705b16a790SSwapnil Jakhade val = vltg_coeff[dp->voltage[lane]][dp->pre[lane]].mgnfs_mult;
1571c756cc16SSwapnil Jakhade cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[inst->mlane + lane],
15725b16a790SSwapnil Jakhade TX_TXCC_MGNFS_MULT_000,
15735b16a790SSwapnil Jakhade val);
15745b16a790SSwapnil Jakhade val = vltg_coeff[dp->voltage[lane]][dp->pre[lane]].cpost_mult;
1575c756cc16SSwapnil Jakhade cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[inst->mlane + lane],
15765b16a790SSwapnil Jakhade TX_TXCC_CPOST_MULT_00,
15775b16a790SSwapnil Jakhade val);
15785b16a790SSwapnil Jakhade
1579c756cc16SSwapnil Jakhade val = cdns_torrent_phy_read(cdns_phy->regmap_tx_lane_cdb[inst->mlane + lane],
15805b16a790SSwapnil Jakhade TX_DIAG_ACYA);
15815b16a790SSwapnil Jakhade /*
15825b16a790SSwapnil Jakhade * Write 0 to register bit TX_DIAG_ACYA[0] to allow the state of
15835b16a790SSwapnil Jakhade * analog TX driver to reflect the new programmed one.
15845b16a790SSwapnil Jakhade */
15855b16a790SSwapnil Jakhade val &= ~TX_DIAG_ACYA_HBDC_MASK;
1586c756cc16SSwapnil Jakhade cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[inst->mlane + lane],
15875b16a790SSwapnil Jakhade TX_DIAG_ACYA, val);
15885b16a790SSwapnil Jakhade }
15895b16a790SSwapnil Jakhade };
15905b16a790SSwapnil Jakhade
cdns_torrent_dp_configure(struct phy * phy,union phy_configure_opts * opts)15915b16a790SSwapnil Jakhade static int cdns_torrent_dp_configure(struct phy *phy,
15925b16a790SSwapnil Jakhade union phy_configure_opts *opts)
15935b16a790SSwapnil Jakhade {
15945b16a790SSwapnil Jakhade struct cdns_torrent_inst *inst = phy_get_drvdata(phy);
15955b16a790SSwapnil Jakhade struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(phy->dev.parent);
15965b16a790SSwapnil Jakhade int ret;
15975b16a790SSwapnil Jakhade
15985b16a790SSwapnil Jakhade ret = cdns_torrent_dp_verify_config(inst, &opts->dp);
15995b16a790SSwapnil Jakhade if (ret) {
16005b16a790SSwapnil Jakhade dev_err(&phy->dev, "invalid params for phy configure\n");
16015b16a790SSwapnil Jakhade return ret;
16025b16a790SSwapnil Jakhade }
16035b16a790SSwapnil Jakhade
16045b16a790SSwapnil Jakhade if (opts->dp.set_lanes) {
1605c756cc16SSwapnil Jakhade ret = cdns_torrent_dp_set_lanes(cdns_phy, inst, &opts->dp);
16065b16a790SSwapnil Jakhade if (ret) {
16075b16a790SSwapnil Jakhade dev_err(&phy->dev, "cdns_torrent_dp_set_lanes failed\n");
16085b16a790SSwapnil Jakhade return ret;
16095b16a790SSwapnil Jakhade }
16105b16a790SSwapnil Jakhade }
16115b16a790SSwapnil Jakhade
16125b16a790SSwapnil Jakhade if (opts->dp.set_rate) {
1613c756cc16SSwapnil Jakhade ret = cdns_torrent_dp_set_rate(cdns_phy, inst, &opts->dp);
16145b16a790SSwapnil Jakhade if (ret) {
16155b16a790SSwapnil Jakhade dev_err(&phy->dev, "cdns_torrent_dp_set_rate failed\n");
16165b16a790SSwapnil Jakhade return ret;
16175b16a790SSwapnil Jakhade }
16185b16a790SSwapnil Jakhade }
16195b16a790SSwapnil Jakhade
16205b16a790SSwapnil Jakhade if (opts->dp.set_voltages)
1621c756cc16SSwapnil Jakhade cdns_torrent_dp_set_voltages(cdns_phy, inst, &opts->dp);
16225b16a790SSwapnil Jakhade
16235b16a790SSwapnil Jakhade return ret;
16245b16a790SSwapnil Jakhade }
16255b16a790SSwapnil Jakhade
cdns_torrent_phy_on(struct phy * phy)16265b16a790SSwapnil Jakhade static int cdns_torrent_phy_on(struct phy *phy)
16275b16a790SSwapnil Jakhade {
16285b16a790SSwapnil Jakhade struct cdns_torrent_inst *inst = phy_get_drvdata(phy);
16295b16a790SSwapnil Jakhade struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(phy->dev.parent);
16305b16a790SSwapnil Jakhade u32 read_val;
16315b16a790SSwapnil Jakhade int ret;
16325b16a790SSwapnil Jakhade
16335b16a790SSwapnil Jakhade if (cdns_phy->nsubnodes == 1) {
16345b16a790SSwapnil Jakhade /* Take the PHY lane group out of reset */
16355b16a790SSwapnil Jakhade reset_control_deassert(inst->lnk_rst);
16365b16a790SSwapnil Jakhade
16375b16a790SSwapnil Jakhade /* Take the PHY out of reset */
16385b16a790SSwapnil Jakhade ret = reset_control_deassert(cdns_phy->phy_rst);
16395b16a790SSwapnil Jakhade if (ret)
16405b16a790SSwapnil Jakhade return ret;
16415b16a790SSwapnil Jakhade }
16425b16a790SSwapnil Jakhade
16435b16a790SSwapnil Jakhade /*
16445b16a790SSwapnil Jakhade * Wait for cmn_ready assertion
16455b16a790SSwapnil Jakhade * PHY_PMA_CMN_CTRL1[0] == 1
16465b16a790SSwapnil Jakhade */
16475b16a790SSwapnil Jakhade ret = regmap_field_read_poll_timeout(cdns_phy->phy_pma_cmn_ctrl_1,
16485b16a790SSwapnil Jakhade read_val, read_val, 1000,
16495b16a790SSwapnil Jakhade PLL_LOCK_TIMEOUT);
16505b16a790SSwapnil Jakhade if (ret) {
16515b16a790SSwapnil Jakhade dev_err(cdns_phy->dev, "Timeout waiting for CMN ready\n");
16525b16a790SSwapnil Jakhade return ret;
16535b16a790SSwapnil Jakhade }
16545b16a790SSwapnil Jakhade
165548ac6085SSwapnil Jakhade if (inst->phy_type == TYPE_PCIE || inst->phy_type == TYPE_USB) {
165648ac6085SSwapnil Jakhade ret = regmap_field_read_poll_timeout(cdns_phy->phy_pcs_iso_link_ctrl_1[inst->mlane],
165748ac6085SSwapnil Jakhade read_val, !read_val, 1000,
165848ac6085SSwapnil Jakhade PLL_LOCK_TIMEOUT);
165948ac6085SSwapnil Jakhade if (ret == -ETIMEDOUT) {
166048ac6085SSwapnil Jakhade dev_err(cdns_phy->dev, "Timeout waiting for PHY status ready\n");
166148ac6085SSwapnil Jakhade return ret;
166248ac6085SSwapnil Jakhade }
166348ac6085SSwapnil Jakhade }
16645b16a790SSwapnil Jakhade
16655b16a790SSwapnil Jakhade return 0;
16665b16a790SSwapnil Jakhade }
16675b16a790SSwapnil Jakhade
cdns_torrent_phy_off(struct phy * phy)16685b16a790SSwapnil Jakhade static int cdns_torrent_phy_off(struct phy *phy)
16695b16a790SSwapnil Jakhade {
16705b16a790SSwapnil Jakhade struct cdns_torrent_inst *inst = phy_get_drvdata(phy);
16715b16a790SSwapnil Jakhade struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(phy->dev.parent);
16725b16a790SSwapnil Jakhade int ret;
16735b16a790SSwapnil Jakhade
16745b16a790SSwapnil Jakhade if (cdns_phy->nsubnodes != 1)
16755b16a790SSwapnil Jakhade return 0;
16765b16a790SSwapnil Jakhade
16775b16a790SSwapnil Jakhade ret = reset_control_assert(cdns_phy->phy_rst);
16785b16a790SSwapnil Jakhade if (ret)
16795b16a790SSwapnil Jakhade return ret;
16805b16a790SSwapnil Jakhade
16815b16a790SSwapnil Jakhade return reset_control_assert(inst->lnk_rst);
16825b16a790SSwapnil Jakhade }
16835b16a790SSwapnil Jakhade
cdns_torrent_dp_common_init(struct cdns_torrent_phy * cdns_phy,struct cdns_torrent_inst * inst)16848f3ced2fSSwapnil Jakhade static void cdns_torrent_dp_common_init(struct cdns_torrent_phy *cdns_phy,
16858f3ced2fSSwapnil Jakhade struct cdns_torrent_inst *inst)
16865b16a790SSwapnil Jakhade {
16875b16a790SSwapnil Jakhade struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg;
16888f3ced2fSSwapnil Jakhade unsigned char lane_bits;
1689c756cc16SSwapnil Jakhade u32 val;
16905b16a790SSwapnil Jakhade
16915b16a790SSwapnil Jakhade cdns_torrent_dp_write(regmap, PHY_AUX_CTRL, 0x0003); /* enable AUX */
16925b16a790SSwapnil Jakhade
16935b16a790SSwapnil Jakhade /*
16945b16a790SSwapnil Jakhade * Set lines power state to A0
16955b16a790SSwapnil Jakhade * Set lines pll clk enable to 0
16965b16a790SSwapnil Jakhade */
1697c756cc16SSwapnil Jakhade cdns_torrent_dp_set_a0_pll(cdns_phy, inst, inst->num_lanes);
16985b16a790SSwapnil Jakhade
16995b16a790SSwapnil Jakhade /*
17005b16a790SSwapnil Jakhade * release phy_l0*_reset_n and pma_tx_elec_idle_ln_* based on
17015b16a790SSwapnil Jakhade * used lanes
17025b16a790SSwapnil Jakhade */
17035b16a790SSwapnil Jakhade lane_bits = (1 << inst->num_lanes) - 1;
1704c756cc16SSwapnil Jakhade
1705c756cc16SSwapnil Jakhade val = cdns_torrent_dp_read(regmap, PHY_RESET);
1706c756cc16SSwapnil Jakhade val |= (0xF & lane_bits);
1707c756cc16SSwapnil Jakhade val &= ~(lane_bits << 4);
1708c756cc16SSwapnil Jakhade cdns_torrent_dp_write(regmap, PHY_RESET, val);
17095b16a790SSwapnil Jakhade
17105b16a790SSwapnil Jakhade /* release pma_xcvr_pllclk_en_ln_*, only for the master lane */
1711c756cc16SSwapnil Jakhade val = cdns_torrent_dp_read(regmap, PHY_PMA_XCVR_PLLCLK_EN);
1712c756cc16SSwapnil Jakhade val |= 1;
1713c756cc16SSwapnil Jakhade cdns_torrent_dp_write(regmap, PHY_PMA_XCVR_PLLCLK_EN, val);
17145b16a790SSwapnil Jakhade
17158f3ced2fSSwapnil Jakhade /*
17168f3ced2fSSwapnil Jakhade * PHY PMA registers configuration functions
17178f3ced2fSSwapnil Jakhade * Initialize PHY with max supported link rate, without SSC.
17188f3ced2fSSwapnil Jakhade */
17193b401625SSwapnil Jakhade if (cdns_phy->ref_clk_rate == CLK_19_2_MHZ)
17205b16a790SSwapnil Jakhade cdns_torrent_dp_pma_cmn_vco_cfg_19_2mhz(cdns_phy,
17215b16a790SSwapnil Jakhade cdns_phy->max_bit_rate,
17225b16a790SSwapnil Jakhade false);
17233b401625SSwapnil Jakhade else if (cdns_phy->ref_clk_rate == CLK_25_MHZ)
17245b16a790SSwapnil Jakhade cdns_torrent_dp_pma_cmn_vco_cfg_25mhz(cdns_phy,
17255b16a790SSwapnil Jakhade cdns_phy->max_bit_rate,
17265b16a790SSwapnil Jakhade false);
17271cc45515SSwapnil Jakhade else if (cdns_phy->ref_clk_rate == CLK_100_MHZ)
17281cc45515SSwapnil Jakhade cdns_torrent_dp_pma_cmn_vco_cfg_100mhz(cdns_phy,
17291cc45515SSwapnil Jakhade cdns_phy->max_bit_rate,
17301cc45515SSwapnil Jakhade false);
17311cc45515SSwapnil Jakhade
1732c756cc16SSwapnil Jakhade cdns_torrent_dp_pma_cmn_rate(cdns_phy, inst, cdns_phy->max_bit_rate,
17335b16a790SSwapnil Jakhade inst->num_lanes);
17345b16a790SSwapnil Jakhade
17355b16a790SSwapnil Jakhade /* take out of reset */
17365b16a790SSwapnil Jakhade regmap_field_write(cdns_phy->phy_reset_ctrl, 0x1);
17378f3ced2fSSwapnil Jakhade }
17388f3ced2fSSwapnil Jakhade
cdns_torrent_dp_start(struct cdns_torrent_phy * cdns_phy,struct cdns_torrent_inst * inst,struct phy * phy)17398f3ced2fSSwapnil Jakhade static int cdns_torrent_dp_start(struct cdns_torrent_phy *cdns_phy,
17408f3ced2fSSwapnil Jakhade struct cdns_torrent_inst *inst,
17418f3ced2fSSwapnil Jakhade struct phy *phy)
17428f3ced2fSSwapnil Jakhade {
17438f3ced2fSSwapnil Jakhade int ret;
17445b16a790SSwapnil Jakhade
1745c756cc16SSwapnil Jakhade ret = cdns_torrent_phy_on(phy);
1746c756cc16SSwapnil Jakhade if (ret)
1747c756cc16SSwapnil Jakhade return ret;
17485b16a790SSwapnil Jakhade
17495b16a790SSwapnil Jakhade ret = cdns_torrent_dp_wait_pma_cmn_ready(cdns_phy);
17505b16a790SSwapnil Jakhade if (ret)
17515b16a790SSwapnil Jakhade return ret;
17525b16a790SSwapnil Jakhade
1753c756cc16SSwapnil Jakhade ret = cdns_torrent_dp_run(cdns_phy, inst, inst->num_lanes);
17545b16a790SSwapnil Jakhade
17555b16a790SSwapnil Jakhade return ret;
17565b16a790SSwapnil Jakhade }
17575b16a790SSwapnil Jakhade
cdns_torrent_dp_init(struct phy * phy)17588f3ced2fSSwapnil Jakhade static int cdns_torrent_dp_init(struct phy *phy)
17598f3ced2fSSwapnil Jakhade {
17608f3ced2fSSwapnil Jakhade struct cdns_torrent_inst *inst = phy_get_drvdata(phy);
17618f3ced2fSSwapnil Jakhade struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(phy->dev.parent);
17621b0524fcSSwapnil Jakhade int ret;
17638f3ced2fSSwapnil Jakhade
17648f3ced2fSSwapnil Jakhade switch (cdns_phy->ref_clk_rate) {
17658f3ced2fSSwapnil Jakhade case CLK_19_2_MHZ:
17668f3ced2fSSwapnil Jakhade case CLK_25_MHZ:
17678f3ced2fSSwapnil Jakhade case CLK_100_MHZ:
17688f3ced2fSSwapnil Jakhade /* Valid Ref Clock Rate */
17698f3ced2fSSwapnil Jakhade break;
17708f3ced2fSSwapnil Jakhade default:
17718f3ced2fSSwapnil Jakhade dev_err(cdns_phy->dev, "Unsupported Ref Clock Rate\n");
17728f3ced2fSSwapnil Jakhade return -EINVAL;
17738f3ced2fSSwapnil Jakhade }
17748f3ced2fSSwapnil Jakhade
17751b0524fcSSwapnil Jakhade ret = cdns_torrent_dp_get_pll(cdns_phy, TYPE_NONE);
17761b0524fcSSwapnil Jakhade if (ret)
17771b0524fcSSwapnil Jakhade return ret;
17781b0524fcSSwapnil Jakhade
17798f3ced2fSSwapnil Jakhade cdns_torrent_dp_common_init(cdns_phy, inst);
17808f3ced2fSSwapnil Jakhade
17818f3ced2fSSwapnil Jakhade return cdns_torrent_dp_start(cdns_phy, inst, phy);
17828f3ced2fSSwapnil Jakhade }
17838f3ced2fSSwapnil Jakhade
cdns_torrent_dp_multilink_init(struct cdns_torrent_phy * cdns_phy,struct cdns_torrent_inst * inst,struct phy * phy)1784ede775a8SSwapnil Jakhade static int cdns_torrent_dp_multilink_init(struct cdns_torrent_phy *cdns_phy,
1785ede775a8SSwapnil Jakhade struct cdns_torrent_inst *inst,
1786ede775a8SSwapnil Jakhade struct phy *phy)
1787ede775a8SSwapnil Jakhade {
1788ede775a8SSwapnil Jakhade if (cdns_phy->ref_clk_rate != CLK_100_MHZ) {
1789ede775a8SSwapnil Jakhade dev_err(cdns_phy->dev, "Unsupported Ref Clock Rate\n");
1790ede775a8SSwapnil Jakhade return -EINVAL;
1791ede775a8SSwapnil Jakhade }
1792ede775a8SSwapnil Jakhade
17932cca0228SKishon Vijay Abraham I cdns_torrent_dp_common_init(cdns_phy, inst);
17942cca0228SKishon Vijay Abraham I
17952cca0228SKishon Vijay Abraham I return cdns_torrent_dp_start(cdns_phy, inst, phy);
17962cca0228SKishon Vijay Abraham I }
17972cca0228SKishon Vijay Abraham I
cdns_torrent_derived_refclk_enable(struct clk_hw * hw)17982cca0228SKishon Vijay Abraham I static int cdns_torrent_derived_refclk_enable(struct clk_hw *hw)
17992cca0228SKishon Vijay Abraham I {
18002cca0228SKishon Vijay Abraham I struct cdns_torrent_derived_refclk *derived_refclk = to_cdns_torrent_derived_refclk(hw);
18012cca0228SKishon Vijay Abraham I
1802235bde4fSSwapnil Jakhade regmap_field_write(derived_refclk->cmn_cdiag_refclk_ovrd_4, 1);
18032cca0228SKishon Vijay Abraham I regmap_field_write(derived_refclk->phy_pipe_cmn_ctrl1_0, 1);
18042cca0228SKishon Vijay Abraham I
18052cca0228SKishon Vijay Abraham I return 0;
18062cca0228SKishon Vijay Abraham I }
18072cca0228SKishon Vijay Abraham I
cdns_torrent_derived_refclk_disable(struct clk_hw * hw)18082cca0228SKishon Vijay Abraham I static void cdns_torrent_derived_refclk_disable(struct clk_hw *hw)
18092cca0228SKishon Vijay Abraham I {
18102cca0228SKishon Vijay Abraham I struct cdns_torrent_derived_refclk *derived_refclk = to_cdns_torrent_derived_refclk(hw);
18112cca0228SKishon Vijay Abraham I
18122cca0228SKishon Vijay Abraham I regmap_field_write(derived_refclk->phy_pipe_cmn_ctrl1_0, 0);
1813235bde4fSSwapnil Jakhade regmap_field_write(derived_refclk->cmn_cdiag_refclk_ovrd_4, 0);
18142cca0228SKishon Vijay Abraham I }
18152cca0228SKishon Vijay Abraham I
cdns_torrent_derived_refclk_is_enabled(struct clk_hw * hw)18162cca0228SKishon Vijay Abraham I static int cdns_torrent_derived_refclk_is_enabled(struct clk_hw *hw)
18172cca0228SKishon Vijay Abraham I {
18182cca0228SKishon Vijay Abraham I struct cdns_torrent_derived_refclk *derived_refclk = to_cdns_torrent_derived_refclk(hw);
18192cca0228SKishon Vijay Abraham I int val;
18202cca0228SKishon Vijay Abraham I
1821235bde4fSSwapnil Jakhade regmap_field_read(derived_refclk->cmn_cdiag_refclk_ovrd_4, &val);
18222cca0228SKishon Vijay Abraham I
18232cca0228SKishon Vijay Abraham I return !!val;
18242cca0228SKishon Vijay Abraham I }
18252cca0228SKishon Vijay Abraham I
18262cca0228SKishon Vijay Abraham I static const struct clk_ops cdns_torrent_derived_refclk_ops = {
18272cca0228SKishon Vijay Abraham I .enable = cdns_torrent_derived_refclk_enable,
18282cca0228SKishon Vijay Abraham I .disable = cdns_torrent_derived_refclk_disable,
18292cca0228SKishon Vijay Abraham I .is_enabled = cdns_torrent_derived_refclk_is_enabled,
18302cca0228SKishon Vijay Abraham I };
18312cca0228SKishon Vijay Abraham I
cdns_torrent_derived_refclk_register(struct cdns_torrent_phy * cdns_phy)18322cca0228SKishon Vijay Abraham I static int cdns_torrent_derived_refclk_register(struct cdns_torrent_phy *cdns_phy)
18332cca0228SKishon Vijay Abraham I {
18342cca0228SKishon Vijay Abraham I struct cdns_torrent_derived_refclk *derived_refclk;
18352cca0228SKishon Vijay Abraham I struct device *dev = cdns_phy->dev;
18362cca0228SKishon Vijay Abraham I struct clk_init_data *init;
18372cca0228SKishon Vijay Abraham I const char *parent_name;
18382cca0228SKishon Vijay Abraham I char clk_name[100];
1839aef096dbSSwapnil Jakhade struct clk_hw *hw;
18402cca0228SKishon Vijay Abraham I struct clk *clk;
1841235bde4fSSwapnil Jakhade int ret;
18422cca0228SKishon Vijay Abraham I
18432cca0228SKishon Vijay Abraham I derived_refclk = devm_kzalloc(dev, sizeof(*derived_refclk), GFP_KERNEL);
18442cca0228SKishon Vijay Abraham I if (!derived_refclk)
18452cca0228SKishon Vijay Abraham I return -ENOMEM;
18462cca0228SKishon Vijay Abraham I
18472cca0228SKishon Vijay Abraham I snprintf(clk_name, sizeof(clk_name), "%s_%s", dev_name(dev),
1848235bde4fSSwapnil Jakhade clk_names[CDNS_TORRENT_DERIVED_REFCLK]);
18492cca0228SKishon Vijay Abraham I
18502cca0228SKishon Vijay Abraham I clk = devm_clk_get_optional(dev, "phy_en_refclk");
18512cca0228SKishon Vijay Abraham I if (IS_ERR(clk)) {
18522cca0228SKishon Vijay Abraham I dev_err(dev, "No parent clock for derived_refclk\n");
18532cca0228SKishon Vijay Abraham I return PTR_ERR(clk);
18542cca0228SKishon Vijay Abraham I }
18552cca0228SKishon Vijay Abraham I
18562cca0228SKishon Vijay Abraham I init = &derived_refclk->clk_data;
18572cca0228SKishon Vijay Abraham I
18582cca0228SKishon Vijay Abraham I if (clk) {
18592cca0228SKishon Vijay Abraham I parent_name = __clk_get_name(clk);
18602cca0228SKishon Vijay Abraham I init->parent_names = &parent_name;
18612cca0228SKishon Vijay Abraham I init->num_parents = 1;
18622cca0228SKishon Vijay Abraham I }
18632cca0228SKishon Vijay Abraham I init->ops = &cdns_torrent_derived_refclk_ops;
18642cca0228SKishon Vijay Abraham I init->flags = 0;
18652cca0228SKishon Vijay Abraham I init->name = clk_name;
18662cca0228SKishon Vijay Abraham I
1867235bde4fSSwapnil Jakhade derived_refclk->phy_pipe_cmn_ctrl1_0 = cdns_phy->phy_pipe_cmn_ctrl1_0;
1868235bde4fSSwapnil Jakhade derived_refclk->cmn_cdiag_refclk_ovrd_4 = cdns_phy->cmn_cdiag_refclk_ovrd_4;
18692cca0228SKishon Vijay Abraham I
18702cca0228SKishon Vijay Abraham I derived_refclk->hw.init = init;
18712cca0228SKishon Vijay Abraham I
1872aef096dbSSwapnil Jakhade hw = &derived_refclk->hw;
1873aef096dbSSwapnil Jakhade ret = devm_clk_hw_register(dev, hw);
1874aef096dbSSwapnil Jakhade if (ret)
1875aef096dbSSwapnil Jakhade return ret;
18762cca0228SKishon Vijay Abraham I
1877235bde4fSSwapnil Jakhade cdns_phy->clk_hw_data->hws[CDNS_TORRENT_DERIVED_REFCLK] = hw;
1878235bde4fSSwapnil Jakhade
1879235bde4fSSwapnil Jakhade return 0;
1880235bde4fSSwapnil Jakhade }
1881235bde4fSSwapnil Jakhade
cdns_torrent_received_refclk_enable(struct clk_hw * hw)1882785a4e68SSwapnil Jakhade static int cdns_torrent_received_refclk_enable(struct clk_hw *hw)
1883785a4e68SSwapnil Jakhade {
1884785a4e68SSwapnil Jakhade struct cdns_torrent_received_refclk *received_refclk = to_cdns_torrent_received_refclk(hw);
1885785a4e68SSwapnil Jakhade
1886785a4e68SSwapnil Jakhade regmap_field_write(received_refclk->phy_pipe_cmn_ctrl1_0, 1);
1887785a4e68SSwapnil Jakhade
1888785a4e68SSwapnil Jakhade return 0;
1889785a4e68SSwapnil Jakhade }
1890785a4e68SSwapnil Jakhade
cdns_torrent_received_refclk_disable(struct clk_hw * hw)1891785a4e68SSwapnil Jakhade static void cdns_torrent_received_refclk_disable(struct clk_hw *hw)
1892785a4e68SSwapnil Jakhade {
1893785a4e68SSwapnil Jakhade struct cdns_torrent_received_refclk *received_refclk = to_cdns_torrent_received_refclk(hw);
1894785a4e68SSwapnil Jakhade
1895785a4e68SSwapnil Jakhade regmap_field_write(received_refclk->phy_pipe_cmn_ctrl1_0, 0);
1896785a4e68SSwapnil Jakhade }
1897785a4e68SSwapnil Jakhade
cdns_torrent_received_refclk_is_enabled(struct clk_hw * hw)1898785a4e68SSwapnil Jakhade static int cdns_torrent_received_refclk_is_enabled(struct clk_hw *hw)
1899785a4e68SSwapnil Jakhade {
1900785a4e68SSwapnil Jakhade struct cdns_torrent_received_refclk *received_refclk = to_cdns_torrent_received_refclk(hw);
1901785a4e68SSwapnil Jakhade int val, cmn_val;
1902785a4e68SSwapnil Jakhade
1903785a4e68SSwapnil Jakhade regmap_field_read(received_refclk->phy_pipe_cmn_ctrl1_0, &val);
1904785a4e68SSwapnil Jakhade regmap_field_read(received_refclk->cmn_cdiag_refclk_ovrd_4, &cmn_val);
1905785a4e68SSwapnil Jakhade
1906785a4e68SSwapnil Jakhade return val && !cmn_val;
1907785a4e68SSwapnil Jakhade }
1908785a4e68SSwapnil Jakhade
1909785a4e68SSwapnil Jakhade static const struct clk_ops cdns_torrent_received_refclk_ops = {
1910785a4e68SSwapnil Jakhade .enable = cdns_torrent_received_refclk_enable,
1911785a4e68SSwapnil Jakhade .disable = cdns_torrent_received_refclk_disable,
1912785a4e68SSwapnil Jakhade .is_enabled = cdns_torrent_received_refclk_is_enabled,
1913785a4e68SSwapnil Jakhade };
1914785a4e68SSwapnil Jakhade
cdns_torrent_received_refclk_register(struct cdns_torrent_phy * cdns_phy)1915785a4e68SSwapnil Jakhade static int cdns_torrent_received_refclk_register(struct cdns_torrent_phy *cdns_phy)
1916785a4e68SSwapnil Jakhade {
1917785a4e68SSwapnil Jakhade struct cdns_torrent_received_refclk *received_refclk;
1918785a4e68SSwapnil Jakhade struct device *dev = cdns_phy->dev;
1919785a4e68SSwapnil Jakhade struct clk_init_data *init;
1920785a4e68SSwapnil Jakhade const char *parent_name;
1921785a4e68SSwapnil Jakhade char clk_name[100];
1922785a4e68SSwapnil Jakhade struct clk_hw *hw;
1923785a4e68SSwapnil Jakhade struct clk *clk;
1924785a4e68SSwapnil Jakhade int ret;
1925785a4e68SSwapnil Jakhade
1926785a4e68SSwapnil Jakhade received_refclk = devm_kzalloc(dev, sizeof(*received_refclk), GFP_KERNEL);
1927785a4e68SSwapnil Jakhade if (!received_refclk)
1928785a4e68SSwapnil Jakhade return -ENOMEM;
1929785a4e68SSwapnil Jakhade
1930785a4e68SSwapnil Jakhade snprintf(clk_name, sizeof(clk_name), "%s_%s", dev_name(dev),
1931785a4e68SSwapnil Jakhade clk_names[CDNS_TORRENT_RECEIVED_REFCLK]);
1932785a4e68SSwapnil Jakhade
1933785a4e68SSwapnil Jakhade clk = devm_clk_get_optional(dev, "phy_en_refclk");
1934785a4e68SSwapnil Jakhade if (IS_ERR(clk)) {
1935785a4e68SSwapnil Jakhade dev_err(dev, "No parent clock for received_refclk\n");
1936785a4e68SSwapnil Jakhade return PTR_ERR(clk);
1937785a4e68SSwapnil Jakhade }
1938785a4e68SSwapnil Jakhade
1939785a4e68SSwapnil Jakhade init = &received_refclk->clk_data;
1940785a4e68SSwapnil Jakhade
1941785a4e68SSwapnil Jakhade if (clk) {
1942785a4e68SSwapnil Jakhade parent_name = __clk_get_name(clk);
1943785a4e68SSwapnil Jakhade init->parent_names = &parent_name;
1944785a4e68SSwapnil Jakhade init->num_parents = 1;
1945785a4e68SSwapnil Jakhade }
1946785a4e68SSwapnil Jakhade init->ops = &cdns_torrent_received_refclk_ops;
1947785a4e68SSwapnil Jakhade init->flags = 0;
1948785a4e68SSwapnil Jakhade init->name = clk_name;
1949785a4e68SSwapnil Jakhade
1950785a4e68SSwapnil Jakhade received_refclk->phy_pipe_cmn_ctrl1_0 = cdns_phy->phy_pipe_cmn_ctrl1_0;
1951785a4e68SSwapnil Jakhade received_refclk->cmn_cdiag_refclk_ovrd_4 = cdns_phy->cmn_cdiag_refclk_ovrd_4;
1952785a4e68SSwapnil Jakhade
1953785a4e68SSwapnil Jakhade received_refclk->hw.init = init;
1954785a4e68SSwapnil Jakhade
1955785a4e68SSwapnil Jakhade hw = &received_refclk->hw;
1956785a4e68SSwapnil Jakhade ret = devm_clk_hw_register(dev, hw);
1957785a4e68SSwapnil Jakhade if (ret)
1958785a4e68SSwapnil Jakhade return ret;
1959785a4e68SSwapnil Jakhade
1960785a4e68SSwapnil Jakhade cdns_phy->clk_hw_data->hws[CDNS_TORRENT_RECEIVED_REFCLK] = hw;
1961785a4e68SSwapnil Jakhade
1962785a4e68SSwapnil Jakhade return 0;
1963785a4e68SSwapnil Jakhade }
1964785a4e68SSwapnil Jakhade
cdns_torrent_refclk_driver_enable(struct clk_hw * hw)1965235bde4fSSwapnil Jakhade static int cdns_torrent_refclk_driver_enable(struct clk_hw *hw)
1966235bde4fSSwapnil Jakhade {
1967235bde4fSSwapnil Jakhade struct cdns_torrent_refclk_driver *refclk_driver = to_cdns_torrent_refclk_driver(hw);
1968235bde4fSSwapnil Jakhade
1969235bde4fSSwapnil Jakhade regmap_field_write(refclk_driver->cmn_fields[CMN_CDIAG_REFCLK_DRV0_CTRL_6], 0);
1970235bde4fSSwapnil Jakhade regmap_field_write(refclk_driver->cmn_fields[CMN_CDIAG_REFCLK_DRV0_CTRL_5], 1);
1971235bde4fSSwapnil Jakhade regmap_field_write(refclk_driver->cmn_fields[CMN_CDIAG_REFCLK_DRV0_CTRL_1], 0);
1972235bde4fSSwapnil Jakhade
1973235bde4fSSwapnil Jakhade return 0;
1974235bde4fSSwapnil Jakhade }
1975235bde4fSSwapnil Jakhade
cdns_torrent_refclk_driver_disable(struct clk_hw * hw)1976235bde4fSSwapnil Jakhade static void cdns_torrent_refclk_driver_disable(struct clk_hw *hw)
1977235bde4fSSwapnil Jakhade {
1978235bde4fSSwapnil Jakhade struct cdns_torrent_refclk_driver *refclk_driver = to_cdns_torrent_refclk_driver(hw);
1979235bde4fSSwapnil Jakhade
1980235bde4fSSwapnil Jakhade regmap_field_write(refclk_driver->cmn_fields[CMN_CDIAG_REFCLK_DRV0_CTRL_1], 1);
1981235bde4fSSwapnil Jakhade }
1982235bde4fSSwapnil Jakhade
cdns_torrent_refclk_driver_is_enabled(struct clk_hw * hw)1983235bde4fSSwapnil Jakhade static int cdns_torrent_refclk_driver_is_enabled(struct clk_hw *hw)
1984235bde4fSSwapnil Jakhade {
1985235bde4fSSwapnil Jakhade struct cdns_torrent_refclk_driver *refclk_driver = to_cdns_torrent_refclk_driver(hw);
1986235bde4fSSwapnil Jakhade int val;
1987235bde4fSSwapnil Jakhade
1988235bde4fSSwapnil Jakhade regmap_field_read(refclk_driver->cmn_fields[CMN_CDIAG_REFCLK_DRV0_CTRL_1], &val);
1989235bde4fSSwapnil Jakhade
1990235bde4fSSwapnil Jakhade return !val;
1991235bde4fSSwapnil Jakhade }
1992235bde4fSSwapnil Jakhade
cdns_torrent_refclk_driver_get_parent(struct clk_hw * hw)1993785a4e68SSwapnil Jakhade static u8 cdns_torrent_refclk_driver_get_parent(struct clk_hw *hw)
1994785a4e68SSwapnil Jakhade {
1995785a4e68SSwapnil Jakhade struct cdns_torrent_refclk_driver *refclk_driver = to_cdns_torrent_refclk_driver(hw);
1996785a4e68SSwapnil Jakhade unsigned int val;
1997785a4e68SSwapnil Jakhade
1998785a4e68SSwapnil Jakhade regmap_field_read(refclk_driver->cmn_fields[CMN_CDIAG_REFCLK_DRV0_CTRL_4], &val);
1999785a4e68SSwapnil Jakhade return clk_mux_val_to_index(hw, cdns_torrent_refclk_driver_mux_table, 0, val);
2000785a4e68SSwapnil Jakhade }
2001785a4e68SSwapnil Jakhade
cdns_torrent_refclk_driver_set_parent(struct clk_hw * hw,u8 index)2002785a4e68SSwapnil Jakhade static int cdns_torrent_refclk_driver_set_parent(struct clk_hw *hw, u8 index)
2003785a4e68SSwapnil Jakhade {
2004785a4e68SSwapnil Jakhade struct cdns_torrent_refclk_driver *refclk_driver = to_cdns_torrent_refclk_driver(hw);
2005785a4e68SSwapnil Jakhade unsigned int val;
2006785a4e68SSwapnil Jakhade
2007785a4e68SSwapnil Jakhade val = cdns_torrent_refclk_driver_mux_table[index];
2008785a4e68SSwapnil Jakhade return regmap_field_write(refclk_driver->cmn_fields[CMN_CDIAG_REFCLK_DRV0_CTRL_4], val);
2009785a4e68SSwapnil Jakhade }
2010785a4e68SSwapnil Jakhade
2011235bde4fSSwapnil Jakhade static const struct clk_ops cdns_torrent_refclk_driver_ops = {
2012235bde4fSSwapnil Jakhade .enable = cdns_torrent_refclk_driver_enable,
2013235bde4fSSwapnil Jakhade .disable = cdns_torrent_refclk_driver_disable,
2014235bde4fSSwapnil Jakhade .is_enabled = cdns_torrent_refclk_driver_is_enabled,
20157aee650eSMaxime Ripard .determine_rate = __clk_mux_determine_rate,
2016785a4e68SSwapnil Jakhade .set_parent = cdns_torrent_refclk_driver_set_parent,
2017785a4e68SSwapnil Jakhade .get_parent = cdns_torrent_refclk_driver_get_parent,
2018235bde4fSSwapnil Jakhade };
2019235bde4fSSwapnil Jakhade
cdns_torrent_refclk_driver_register(struct cdns_torrent_phy * cdns_phy)2020235bde4fSSwapnil Jakhade static int cdns_torrent_refclk_driver_register(struct cdns_torrent_phy *cdns_phy)
2021235bde4fSSwapnil Jakhade {
2022235bde4fSSwapnil Jakhade struct cdns_torrent_refclk_driver *refclk_driver;
2023235bde4fSSwapnil Jakhade struct device *dev = cdns_phy->dev;
2024235bde4fSSwapnil Jakhade struct regmap_field *field;
2025235bde4fSSwapnil Jakhade struct clk_init_data *init;
2026785a4e68SSwapnil Jakhade const char **parent_names;
2027785a4e68SSwapnil Jakhade unsigned int num_parents;
2028235bde4fSSwapnil Jakhade struct regmap *regmap;
2029235bde4fSSwapnil Jakhade char clk_name[100];
2030235bde4fSSwapnil Jakhade struct clk_hw *hw;
2031235bde4fSSwapnil Jakhade int i, ret;
2032235bde4fSSwapnil Jakhade
2033235bde4fSSwapnil Jakhade refclk_driver = devm_kzalloc(dev, sizeof(*refclk_driver), GFP_KERNEL);
2034235bde4fSSwapnil Jakhade if (!refclk_driver)
2035235bde4fSSwapnil Jakhade return -ENOMEM;
2036235bde4fSSwapnil Jakhade
2037785a4e68SSwapnil Jakhade num_parents = ARRAY_SIZE(refclk_driver_parent_index);
2038785a4e68SSwapnil Jakhade parent_names = devm_kzalloc(dev, (sizeof(char *) * num_parents), GFP_KERNEL);
2039785a4e68SSwapnil Jakhade if (!parent_names)
2040785a4e68SSwapnil Jakhade return -ENOMEM;
2041785a4e68SSwapnil Jakhade
2042785a4e68SSwapnil Jakhade for (i = 0; i < num_parents; i++) {
2043785a4e68SSwapnil Jakhade hw = cdns_phy->clk_hw_data->hws[refclk_driver_parent_index[i]];
2044235bde4fSSwapnil Jakhade if (IS_ERR_OR_NULL(hw)) {
2045235bde4fSSwapnil Jakhade dev_err(dev, "No parent clock for refclk driver clock\n");
2046235bde4fSSwapnil Jakhade return IS_ERR(hw) ? PTR_ERR(hw) : -ENOENT;
2047235bde4fSSwapnil Jakhade }
2048785a4e68SSwapnil Jakhade parent_names[i] = clk_hw_get_name(hw);
2049785a4e68SSwapnil Jakhade }
2050235bde4fSSwapnil Jakhade
2051235bde4fSSwapnil Jakhade snprintf(clk_name, sizeof(clk_name), "%s_%s", dev_name(dev),
2052235bde4fSSwapnil Jakhade clk_names[CDNS_TORRENT_REFCLK_DRIVER]);
2053235bde4fSSwapnil Jakhade
2054235bde4fSSwapnil Jakhade init = &refclk_driver->clk_data;
2055235bde4fSSwapnil Jakhade
2056235bde4fSSwapnil Jakhade init->ops = &cdns_torrent_refclk_driver_ops;
2057785a4e68SSwapnil Jakhade init->flags = CLK_SET_RATE_NO_REPARENT;
2058785a4e68SSwapnil Jakhade init->parent_names = parent_names;
2059785a4e68SSwapnil Jakhade init->num_parents = num_parents;
2060235bde4fSSwapnil Jakhade init->name = clk_name;
2061235bde4fSSwapnil Jakhade
2062235bde4fSSwapnil Jakhade regmap = cdns_phy->regmap_common_cdb;
2063235bde4fSSwapnil Jakhade
2064235bde4fSSwapnil Jakhade for (i = 0; i < REFCLK_OUT_NUM_CMN_CONFIG; i++) {
2065235bde4fSSwapnil Jakhade field = devm_regmap_field_alloc(dev, regmap, refclk_out_cmn_cfg[i]);
2066235bde4fSSwapnil Jakhade if (IS_ERR(field)) {
2067235bde4fSSwapnil Jakhade dev_err(dev, "Refclk driver CMN reg field init failed\n");
2068235bde4fSSwapnil Jakhade return PTR_ERR(field);
2069235bde4fSSwapnil Jakhade }
2070235bde4fSSwapnil Jakhade refclk_driver->cmn_fields[i] = field;
2071235bde4fSSwapnil Jakhade }
2072235bde4fSSwapnil Jakhade
2073785a4e68SSwapnil Jakhade /* Enable Derived reference clock as default */
2074785a4e68SSwapnil Jakhade regmap_field_write(refclk_driver->cmn_fields[CMN_CDIAG_REFCLK_DRV0_CTRL_4], 1);
2075785a4e68SSwapnil Jakhade
2076235bde4fSSwapnil Jakhade refclk_driver->hw.init = init;
2077235bde4fSSwapnil Jakhade
2078235bde4fSSwapnil Jakhade hw = &refclk_driver->hw;
2079235bde4fSSwapnil Jakhade ret = devm_clk_hw_register(dev, hw);
2080235bde4fSSwapnil Jakhade if (ret)
2081235bde4fSSwapnil Jakhade return ret;
2082235bde4fSSwapnil Jakhade
2083aef096dbSSwapnil Jakhade cdns_phy->clk_hw_data->hws[CDNS_TORRENT_REFCLK_DRIVER] = hw;
20842cca0228SKishon Vijay Abraham I
20852cca0228SKishon Vijay Abraham I return 0;
20862cca0228SKishon Vijay Abraham I }
20872cca0228SKishon Vijay Abraham I
cdns_regmap_init(struct device * dev,void __iomem * base,u32 block_offset,u8 reg_offset_shift,const struct regmap_config * config)208869d114acSSwapnil Jakhade static struct regmap *cdns_regmap_init(struct device *dev, void __iomem *base,
208969d114acSSwapnil Jakhade u32 block_offset,
209069d114acSSwapnil Jakhade u8 reg_offset_shift,
209169d114acSSwapnil Jakhade const struct regmap_config *config)
209269d114acSSwapnil Jakhade {
209369d114acSSwapnil Jakhade struct cdns_regmap_cdb_context *ctx;
209469d114acSSwapnil Jakhade
209569d114acSSwapnil Jakhade ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
209669d114acSSwapnil Jakhade if (!ctx)
209769d114acSSwapnil Jakhade return ERR_PTR(-ENOMEM);
209869d114acSSwapnil Jakhade
209969d114acSSwapnil Jakhade ctx->dev = dev;
210069d114acSSwapnil Jakhade ctx->base = base + block_offset;
210169d114acSSwapnil Jakhade ctx->reg_offset_shift = reg_offset_shift;
210269d114acSSwapnil Jakhade
210369d114acSSwapnil Jakhade return devm_regmap_init(dev, NULL, ctx, config);
210469d114acSSwapnil Jakhade }
210569d114acSSwapnil Jakhade
cdns_torrent_dp_regfield_init(struct cdns_torrent_phy * cdns_phy)21062e70c849SSwapnil Jakhade static int cdns_torrent_dp_regfield_init(struct cdns_torrent_phy *cdns_phy)
21072e70c849SSwapnil Jakhade {
21082e70c849SSwapnil Jakhade struct device *dev = cdns_phy->dev;
21092e70c849SSwapnil Jakhade struct regmap_field *field;
21102e70c849SSwapnil Jakhade struct regmap *regmap;
21112e70c849SSwapnil Jakhade
21122e70c849SSwapnil Jakhade regmap = cdns_phy->regmap_dptx_phy_reg;
21132e70c849SSwapnil Jakhade field = devm_regmap_field_alloc(dev, regmap, phy_reset_ctrl);
21142e70c849SSwapnil Jakhade if (IS_ERR(field)) {
21152e70c849SSwapnil Jakhade dev_err(dev, "PHY_RESET reg field init failed\n");
21162e70c849SSwapnil Jakhade return PTR_ERR(field);
21172e70c849SSwapnil Jakhade }
21182e70c849SSwapnil Jakhade cdns_phy->phy_reset_ctrl = field;
21192e70c849SSwapnil Jakhade
21202e70c849SSwapnil Jakhade return 0;
21212e70c849SSwapnil Jakhade }
21222e70c849SSwapnil Jakhade
cdns_torrent_regfield_init(struct cdns_torrent_phy * cdns_phy)21232e70c849SSwapnil Jakhade static int cdns_torrent_regfield_init(struct cdns_torrent_phy *cdns_phy)
212469d114acSSwapnil Jakhade {
212569d114acSSwapnil Jakhade struct device *dev = cdns_phy->dev;
212669d114acSSwapnil Jakhade struct regmap_field *field;
212769d114acSSwapnil Jakhade struct regmap *regmap;
212848ac6085SSwapnil Jakhade int i;
212969d114acSSwapnil Jakhade
213069d114acSSwapnil Jakhade regmap = cdns_phy->regmap_phy_pcs_common_cdb;
213169d114acSSwapnil Jakhade field = devm_regmap_field_alloc(dev, regmap, phy_pll_cfg);
213269d114acSSwapnil Jakhade if (IS_ERR(field)) {
213369d114acSSwapnil Jakhade dev_err(dev, "PHY_PLL_CFG reg field init failed\n");
213469d114acSSwapnil Jakhade return PTR_ERR(field);
213569d114acSSwapnil Jakhade }
213669d114acSSwapnil Jakhade cdns_phy->phy_pll_cfg = field;
213769d114acSSwapnil Jakhade
2138235bde4fSSwapnil Jakhade regmap = cdns_phy->regmap_phy_pcs_common_cdb;
2139235bde4fSSwapnil Jakhade field = devm_regmap_field_alloc(dev, regmap, phy_pipe_cmn_ctrl1_0);
2140235bde4fSSwapnil Jakhade if (IS_ERR(field)) {
2141235bde4fSSwapnil Jakhade dev_err(dev, "phy_pipe_cmn_ctrl1_0 reg field init failed\n");
2142235bde4fSSwapnil Jakhade return PTR_ERR(field);
2143235bde4fSSwapnil Jakhade }
2144235bde4fSSwapnil Jakhade cdns_phy->phy_pipe_cmn_ctrl1_0 = field;
2145235bde4fSSwapnil Jakhade
2146235bde4fSSwapnil Jakhade regmap = cdns_phy->regmap_common_cdb;
2147235bde4fSSwapnil Jakhade field = devm_regmap_field_alloc(dev, regmap, cmn_cdiag_refclk_ovrd_4);
2148235bde4fSSwapnil Jakhade if (IS_ERR(field)) {
2149235bde4fSSwapnil Jakhade dev_err(dev, "cmn_cdiag_refclk_ovrd_4 reg field init failed\n");
2150235bde4fSSwapnil Jakhade return PTR_ERR(field);
2151235bde4fSSwapnil Jakhade }
2152235bde4fSSwapnil Jakhade cdns_phy->cmn_cdiag_refclk_ovrd_4 = field;
2153235bde4fSSwapnil Jakhade
215469d114acSSwapnil Jakhade regmap = cdns_phy->regmap_phy_pma_common_cdb;
21558e4c95b9SSwapnil Jakhade field = devm_regmap_field_alloc(dev, regmap, phy_pma_cmn_ctrl_1);
21568e4c95b9SSwapnil Jakhade if (IS_ERR(field)) {
21578e4c95b9SSwapnil Jakhade dev_err(dev, "PHY_PMA_CMN_CTRL1 reg field init failed\n");
21588e4c95b9SSwapnil Jakhade return PTR_ERR(field);
21598e4c95b9SSwapnil Jakhade }
21608e4c95b9SSwapnil Jakhade cdns_phy->phy_pma_cmn_ctrl_1 = field;
21618e4c95b9SSwapnil Jakhade
21628e4c95b9SSwapnil Jakhade regmap = cdns_phy->regmap_phy_pma_common_cdb;
216369d114acSSwapnil Jakhade field = devm_regmap_field_alloc(dev, regmap, phy_pma_cmn_ctrl_2);
216469d114acSSwapnil Jakhade if (IS_ERR(field)) {
216569d114acSSwapnil Jakhade dev_err(dev, "PHY_PMA_CMN_CTRL2 reg field init failed\n");
216669d114acSSwapnil Jakhade return PTR_ERR(field);
216769d114acSSwapnil Jakhade }
216869d114acSSwapnil Jakhade cdns_phy->phy_pma_cmn_ctrl_2 = field;
216969d114acSSwapnil Jakhade
217069d114acSSwapnil Jakhade regmap = cdns_phy->regmap_phy_pma_common_cdb;
217169d114acSSwapnil Jakhade field = devm_regmap_field_alloc(dev, regmap, phy_pma_pll_raw_ctrl);
217269d114acSSwapnil Jakhade if (IS_ERR(field)) {
217369d114acSSwapnil Jakhade dev_err(dev, "PHY_PMA_PLL_RAW_CTRL reg field init failed\n");
217469d114acSSwapnil Jakhade return PTR_ERR(field);
217569d114acSSwapnil Jakhade }
217669d114acSSwapnil Jakhade cdns_phy->phy_pma_pll_raw_ctrl = field;
217769d114acSSwapnil Jakhade
217848ac6085SSwapnil Jakhade for (i = 0; i < MAX_NUM_LANES; i++) {
217948ac6085SSwapnil Jakhade regmap = cdns_phy->regmap_phy_pcs_lane_cdb[i];
218048ac6085SSwapnil Jakhade field = devm_regmap_field_alloc(dev, regmap, phy_pcs_iso_link_ctrl_1);
218148ac6085SSwapnil Jakhade if (IS_ERR(field)) {
218248ac6085SSwapnil Jakhade dev_err(dev, "PHY_PCS_ISO_LINK_CTRL reg field init for ln %d failed\n", i);
218348ac6085SSwapnil Jakhade return PTR_ERR(field);
218448ac6085SSwapnil Jakhade }
218548ac6085SSwapnil Jakhade cdns_phy->phy_pcs_iso_link_ctrl_1[i] = field;
218648ac6085SSwapnil Jakhade }
218748ac6085SSwapnil Jakhade
21882e70c849SSwapnil Jakhade return 0;
2189cba472ecSSwapnil Jakhade }
21902e70c849SSwapnil Jakhade
cdns_torrent_dp_regmap_init(struct cdns_torrent_phy * cdns_phy)21912e70c849SSwapnil Jakhade static int cdns_torrent_dp_regmap_init(struct cdns_torrent_phy *cdns_phy)
21922e70c849SSwapnil Jakhade {
21932e70c849SSwapnil Jakhade void __iomem *base = cdns_phy->base;
21942e70c849SSwapnil Jakhade struct device *dev = cdns_phy->dev;
21952e70c849SSwapnil Jakhade struct regmap *regmap;
21962e70c849SSwapnil Jakhade u8 reg_offset_shift;
21972e70c849SSwapnil Jakhade u32 block_offset;
21982e70c849SSwapnil Jakhade
21992e70c849SSwapnil Jakhade reg_offset_shift = cdns_phy->init_data->reg_offset_shift;
22002e70c849SSwapnil Jakhade
22012e70c849SSwapnil Jakhade block_offset = TORRENT_DPTX_PHY_OFFSET;
22022e70c849SSwapnil Jakhade regmap = cdns_regmap_init(dev, base, block_offset,
22032e70c849SSwapnil Jakhade reg_offset_shift,
22042e70c849SSwapnil Jakhade &cdns_torrent_dptx_phy_config);
22052e70c849SSwapnil Jakhade if (IS_ERR(regmap)) {
22062e70c849SSwapnil Jakhade dev_err(dev, "Failed to init DPTX PHY regmap\n");
22072e70c849SSwapnil Jakhade return PTR_ERR(regmap);
22082e70c849SSwapnil Jakhade }
22092e70c849SSwapnil Jakhade cdns_phy->regmap_dptx_phy_reg = regmap;
2210cba472ecSSwapnil Jakhade
221169d114acSSwapnil Jakhade return 0;
221269d114acSSwapnil Jakhade }
221369d114acSSwapnil Jakhade
cdns_torrent_regmap_init(struct cdns_torrent_phy * cdns_phy)22142e70c849SSwapnil Jakhade static int cdns_torrent_regmap_init(struct cdns_torrent_phy *cdns_phy)
221569d114acSSwapnil Jakhade {
22162e70c849SSwapnil Jakhade void __iomem *sd_base = cdns_phy->sd_base;
22172e70c849SSwapnil Jakhade u8 block_offset_shift, reg_offset_shift;
221869d114acSSwapnil Jakhade struct device *dev = cdns_phy->dev;
221969d114acSSwapnil Jakhade struct regmap *regmap;
222069d114acSSwapnil Jakhade u32 block_offset;
222169d114acSSwapnil Jakhade int i;
222269d114acSSwapnil Jakhade
22232e70c849SSwapnil Jakhade block_offset_shift = cdns_phy->init_data->block_offset_shift;
22242e70c849SSwapnil Jakhade reg_offset_shift = cdns_phy->init_data->reg_offset_shift;
22252e70c849SSwapnil Jakhade
222669d114acSSwapnil Jakhade for (i = 0; i < MAX_NUM_LANES; i++) {
222769d114acSSwapnil Jakhade block_offset = TORRENT_TX_LANE_CDB_OFFSET(i, block_offset_shift,
222869d114acSSwapnil Jakhade reg_offset_shift);
222969d114acSSwapnil Jakhade regmap = cdns_regmap_init(dev, sd_base, block_offset,
223069d114acSSwapnil Jakhade reg_offset_shift,
223169d114acSSwapnil Jakhade &cdns_torrent_tx_lane_cdb_config[i]);
223269d114acSSwapnil Jakhade if (IS_ERR(regmap)) {
223369d114acSSwapnil Jakhade dev_err(dev, "Failed to init tx lane CDB regmap\n");
223469d114acSSwapnil Jakhade return PTR_ERR(regmap);
223569d114acSSwapnil Jakhade }
223669d114acSSwapnil Jakhade cdns_phy->regmap_tx_lane_cdb[i] = regmap;
223769d114acSSwapnil Jakhade
223869d114acSSwapnil Jakhade block_offset = TORRENT_RX_LANE_CDB_OFFSET(i, block_offset_shift,
223969d114acSSwapnil Jakhade reg_offset_shift);
224069d114acSSwapnil Jakhade regmap = cdns_regmap_init(dev, sd_base, block_offset,
224169d114acSSwapnil Jakhade reg_offset_shift,
224269d114acSSwapnil Jakhade &cdns_torrent_rx_lane_cdb_config[i]);
224369d114acSSwapnil Jakhade if (IS_ERR(regmap)) {
224469d114acSSwapnil Jakhade dev_err(dev, "Failed to init rx lane CDB regmap\n");
224569d114acSSwapnil Jakhade return PTR_ERR(regmap);
224669d114acSSwapnil Jakhade }
224769d114acSSwapnil Jakhade cdns_phy->regmap_rx_lane_cdb[i] = regmap;
224848ac6085SSwapnil Jakhade
224948ac6085SSwapnil Jakhade block_offset = TORRENT_PHY_PCS_LANE_CDB_OFFSET(i, block_offset_shift,
225048ac6085SSwapnil Jakhade reg_offset_shift);
225148ac6085SSwapnil Jakhade regmap = cdns_regmap_init(dev, sd_base, block_offset,
225248ac6085SSwapnil Jakhade reg_offset_shift,
225348ac6085SSwapnil Jakhade &cdns_torrent_phy_pcs_lane_cdb_config[i]);
225448ac6085SSwapnil Jakhade if (IS_ERR(regmap)) {
225548ac6085SSwapnil Jakhade dev_err(dev, "Failed to init PHY PCS lane CDB regmap\n");
225648ac6085SSwapnil Jakhade return PTR_ERR(regmap);
225748ac6085SSwapnil Jakhade }
225848ac6085SSwapnil Jakhade cdns_phy->regmap_phy_pcs_lane_cdb[i] = regmap;
225969d114acSSwapnil Jakhade }
226069d114acSSwapnil Jakhade
226169d114acSSwapnil Jakhade block_offset = TORRENT_COMMON_CDB_OFFSET;
226269d114acSSwapnil Jakhade regmap = cdns_regmap_init(dev, sd_base, block_offset,
226369d114acSSwapnil Jakhade reg_offset_shift,
226469d114acSSwapnil Jakhade &cdns_torrent_common_cdb_config);
226569d114acSSwapnil Jakhade if (IS_ERR(regmap)) {
226669d114acSSwapnil Jakhade dev_err(dev, "Failed to init common CDB regmap\n");
226769d114acSSwapnil Jakhade return PTR_ERR(regmap);
226869d114acSSwapnil Jakhade }
226969d114acSSwapnil Jakhade cdns_phy->regmap_common_cdb = regmap;
227069d114acSSwapnil Jakhade
227169d114acSSwapnil Jakhade block_offset = TORRENT_PHY_PCS_COMMON_OFFSET(block_offset_shift);
227269d114acSSwapnil Jakhade regmap = cdns_regmap_init(dev, sd_base, block_offset,
227369d114acSSwapnil Jakhade reg_offset_shift,
227469d114acSSwapnil Jakhade &cdns_torrent_phy_pcs_cmn_cdb_config);
227569d114acSSwapnil Jakhade if (IS_ERR(regmap)) {
227669d114acSSwapnil Jakhade dev_err(dev, "Failed to init PHY PCS common CDB regmap\n");
227769d114acSSwapnil Jakhade return PTR_ERR(regmap);
227869d114acSSwapnil Jakhade }
227969d114acSSwapnil Jakhade cdns_phy->regmap_phy_pcs_common_cdb = regmap;
228069d114acSSwapnil Jakhade
228169d114acSSwapnil Jakhade block_offset = TORRENT_PHY_PMA_COMMON_OFFSET(block_offset_shift);
228269d114acSSwapnil Jakhade regmap = cdns_regmap_init(dev, sd_base, block_offset,
228369d114acSSwapnil Jakhade reg_offset_shift,
228469d114acSSwapnil Jakhade &cdns_torrent_phy_pma_cmn_cdb_config);
228569d114acSSwapnil Jakhade if (IS_ERR(regmap)) {
228669d114acSSwapnil Jakhade dev_err(dev, "Failed to init PHY PMA common CDB regmap\n");
228769d114acSSwapnil Jakhade return PTR_ERR(regmap);
228869d114acSSwapnil Jakhade }
228969d114acSSwapnil Jakhade cdns_phy->regmap_phy_pma_common_cdb = regmap;
229069d114acSSwapnil Jakhade
229169d114acSSwapnil Jakhade return 0;
229269d114acSSwapnil Jakhade }
229369d114acSSwapnil Jakhade
cdns_torrent_phy_init(struct phy * phy)2294b54b47bdSSwapnil Jakhade static int cdns_torrent_phy_init(struct phy *phy)
2295b54b47bdSSwapnil Jakhade {
2296b54b47bdSSwapnil Jakhade struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(phy->dev.parent);
22976bcf3cb3SSwapnil Jakhade const struct cdns_torrent_data *init_data = cdns_phy->init_data;
2298b54b47bdSSwapnil Jakhade struct cdns_torrent_vals *cmn_vals, *tx_ln_vals, *rx_ln_vals;
22996a2338a5SSwapnil Jakhade enum cdns_torrent_ref_clk ref_clk = cdns_phy->ref_clk_rate;
2300cd9aa947SSwapnil Jakhade struct cdns_torrent_vals *link_cmn_vals, *xcvr_diag_vals;
2301b54b47bdSSwapnil Jakhade struct cdns_torrent_inst *inst = phy_get_drvdata(phy);
2302b54b47bdSSwapnil Jakhade enum cdns_torrent_phy_type phy_type = inst->phy_type;
2303b54b47bdSSwapnil Jakhade enum cdns_torrent_ssc_mode ssc = inst->ssc_mode;
230416e0f0eaSSwapnil Jakhade struct cdns_torrent_vals *phy_pma_cmn_vals;
23059855d84bSSwapnil Jakhade struct cdns_torrent_vals *pcs_cmn_vals;
2306b54b47bdSSwapnil Jakhade struct cdns_reg_pairs *reg_pairs;
2307b54b47bdSSwapnil Jakhade struct regmap *regmap;
2308b54b47bdSSwapnil Jakhade u32 num_regs;
230907084c95SSwapnil Jakhade int i, j;
2310b54b47bdSSwapnil Jakhade
2311ede775a8SSwapnil Jakhade if (cdns_phy->nsubnodes > 1) {
2312ede775a8SSwapnil Jakhade if (phy_type == TYPE_DP)
2313ede775a8SSwapnil Jakhade return cdns_torrent_dp_multilink_init(cdns_phy, inst, phy);
23146bcf3cb3SSwapnil Jakhade return 0;
2315ede775a8SSwapnil Jakhade }
23166bcf3cb3SSwapnil Jakhade
23179f33b76aSSwapnil Jakhade /**
23189f33b76aSSwapnil Jakhade * Spread spectrum generation is not required or supported
231916e0f0eaSSwapnil Jakhade * for SGMII/QSGMII/USXGMII
23209f33b76aSSwapnil Jakhade */
232116e0f0eaSSwapnil Jakhade if (phy_type == TYPE_SGMII || phy_type == TYPE_QSGMII || phy_type == TYPE_USXGMII)
23229f33b76aSSwapnil Jakhade ssc = NO_SSC;
23239f33b76aSSwapnil Jakhade
2324cd9aa947SSwapnil Jakhade /* PHY configuration specific registers for single link */
2325ebd05f90SRoger Quadros link_cmn_vals = cdns_torrent_get_tbl_vals(&init_data->link_cmn_vals_tbl,
2326ebd05f90SRoger Quadros CLK_ANY, CLK_ANY,
2327ebd05f90SRoger Quadros phy_type, TYPE_NONE,
2328ebd05f90SRoger Quadros ANY_SSC);
2329cd9aa947SSwapnil Jakhade if (link_cmn_vals) {
2330cd9aa947SSwapnil Jakhade reg_pairs = link_cmn_vals->reg_pairs;
2331cd9aa947SSwapnil Jakhade num_regs = link_cmn_vals->num_regs;
2332cd9aa947SSwapnil Jakhade regmap = cdns_phy->regmap_common_cdb;
2333d66a6366SSwapnil Jakhade
2334d66a6366SSwapnil Jakhade /**
2335d66a6366SSwapnil Jakhade * First array value in link_cmn_vals must be of
2336d66a6366SSwapnil Jakhade * PHY_PLL_CFG register
2337d66a6366SSwapnil Jakhade */
2338d66a6366SSwapnil Jakhade regmap_field_write(cdns_phy->phy_pll_cfg, reg_pairs[0].val);
2339d66a6366SSwapnil Jakhade
2340d66a6366SSwapnil Jakhade for (i = 1; i < num_regs; i++)
2341cd9aa947SSwapnil Jakhade regmap_write(regmap, reg_pairs[i].off,
2342cd9aa947SSwapnil Jakhade reg_pairs[i].val);
2343cd9aa947SSwapnil Jakhade }
2344cd9aa947SSwapnil Jakhade
2345ebd05f90SRoger Quadros xcvr_diag_vals = cdns_torrent_get_tbl_vals(&init_data->xcvr_diag_vals_tbl,
2346ebd05f90SRoger Quadros CLK_ANY, CLK_ANY,
2347ebd05f90SRoger Quadros phy_type, TYPE_NONE,
2348ebd05f90SRoger Quadros ANY_SSC);
2349cd9aa947SSwapnil Jakhade if (xcvr_diag_vals) {
2350cd9aa947SSwapnil Jakhade reg_pairs = xcvr_diag_vals->reg_pairs;
2351cd9aa947SSwapnil Jakhade num_regs = xcvr_diag_vals->num_regs;
2352cd9aa947SSwapnil Jakhade for (i = 0; i < inst->num_lanes; i++) {
2353cd9aa947SSwapnil Jakhade regmap = cdns_phy->regmap_tx_lane_cdb[i + inst->mlane];
2354cd9aa947SSwapnil Jakhade for (j = 0; j < num_regs; j++)
2355cd9aa947SSwapnil Jakhade regmap_write(regmap, reg_pairs[j].off,
2356cd9aa947SSwapnil Jakhade reg_pairs[j].val);
2357cd9aa947SSwapnil Jakhade }
2358cd9aa947SSwapnil Jakhade }
2359cd9aa947SSwapnil Jakhade
23609855d84bSSwapnil Jakhade /* PHY PCS common registers configurations */
2361ebd05f90SRoger Quadros pcs_cmn_vals = cdns_torrent_get_tbl_vals(&init_data->pcs_cmn_vals_tbl,
2362ebd05f90SRoger Quadros CLK_ANY, CLK_ANY,
2363ebd05f90SRoger Quadros phy_type, TYPE_NONE,
2364ebd05f90SRoger Quadros ANY_SSC);
23659855d84bSSwapnil Jakhade if (pcs_cmn_vals) {
23669855d84bSSwapnil Jakhade reg_pairs = pcs_cmn_vals->reg_pairs;
23679855d84bSSwapnil Jakhade num_regs = pcs_cmn_vals->num_regs;
23689855d84bSSwapnil Jakhade regmap = cdns_phy->regmap_phy_pcs_common_cdb;
23699855d84bSSwapnil Jakhade for (i = 0; i < num_regs; i++)
23709855d84bSSwapnil Jakhade regmap_write(regmap, reg_pairs[i].off,
23719855d84bSSwapnil Jakhade reg_pairs[i].val);
23729855d84bSSwapnil Jakhade }
23739855d84bSSwapnil Jakhade
237416e0f0eaSSwapnil Jakhade /* PHY PMA common registers configurations */
2375ebd05f90SRoger Quadros phy_pma_cmn_vals = cdns_torrent_get_tbl_vals(&init_data->phy_pma_cmn_vals_tbl,
2376ebd05f90SRoger Quadros CLK_ANY, CLK_ANY,
2377ebd05f90SRoger Quadros phy_type, TYPE_NONE,
2378ebd05f90SRoger Quadros ANY_SSC);
237916e0f0eaSSwapnil Jakhade if (phy_pma_cmn_vals) {
238016e0f0eaSSwapnil Jakhade reg_pairs = phy_pma_cmn_vals->reg_pairs;
238116e0f0eaSSwapnil Jakhade num_regs = phy_pma_cmn_vals->num_regs;
238216e0f0eaSSwapnil Jakhade regmap = cdns_phy->regmap_phy_pma_common_cdb;
238316e0f0eaSSwapnil Jakhade for (i = 0; i < num_regs; i++)
238416e0f0eaSSwapnil Jakhade regmap_write(regmap, reg_pairs[i].off,
238516e0f0eaSSwapnil Jakhade reg_pairs[i].val);
238616e0f0eaSSwapnil Jakhade }
238716e0f0eaSSwapnil Jakhade
2388b54b47bdSSwapnil Jakhade /* PMA common registers configurations */
2389ebd05f90SRoger Quadros cmn_vals = cdns_torrent_get_tbl_vals(&init_data->cmn_vals_tbl,
2390ebd05f90SRoger Quadros ref_clk, ref_clk,
2391ebd05f90SRoger Quadros phy_type, TYPE_NONE,
2392ebd05f90SRoger Quadros ssc);
2393b54b47bdSSwapnil Jakhade if (cmn_vals) {
2394b54b47bdSSwapnil Jakhade reg_pairs = cmn_vals->reg_pairs;
2395b54b47bdSSwapnil Jakhade num_regs = cmn_vals->num_regs;
2396b54b47bdSSwapnil Jakhade regmap = cdns_phy->regmap_common_cdb;
2397b54b47bdSSwapnil Jakhade for (i = 0; i < num_regs; i++)
2398b54b47bdSSwapnil Jakhade regmap_write(regmap, reg_pairs[i].off,
2399b54b47bdSSwapnil Jakhade reg_pairs[i].val);
2400b54b47bdSSwapnil Jakhade }
2401b54b47bdSSwapnil Jakhade
2402b54b47bdSSwapnil Jakhade /* PMA TX lane registers configurations */
2403ebd05f90SRoger Quadros tx_ln_vals = cdns_torrent_get_tbl_vals(&init_data->tx_ln_vals_tbl,
2404ebd05f90SRoger Quadros ref_clk, ref_clk,
2405ebd05f90SRoger Quadros phy_type, TYPE_NONE,
2406ebd05f90SRoger Quadros ssc);
2407b54b47bdSSwapnil Jakhade if (tx_ln_vals) {
2408b54b47bdSSwapnil Jakhade reg_pairs = tx_ln_vals->reg_pairs;
2409b54b47bdSSwapnil Jakhade num_regs = tx_ln_vals->num_regs;
2410b54b47bdSSwapnil Jakhade for (i = 0; i < inst->num_lanes; i++) {
2411b54b47bdSSwapnil Jakhade regmap = cdns_phy->regmap_tx_lane_cdb[i + inst->mlane];
2412b54b47bdSSwapnil Jakhade for (j = 0; j < num_regs; j++)
2413b54b47bdSSwapnil Jakhade regmap_write(regmap, reg_pairs[j].off,
2414b54b47bdSSwapnil Jakhade reg_pairs[j].val);
2415b54b47bdSSwapnil Jakhade }
2416b54b47bdSSwapnil Jakhade }
2417b54b47bdSSwapnil Jakhade
2418b54b47bdSSwapnil Jakhade /* PMA RX lane registers configurations */
2419ebd05f90SRoger Quadros rx_ln_vals = cdns_torrent_get_tbl_vals(&init_data->rx_ln_vals_tbl,
2420ebd05f90SRoger Quadros ref_clk, ref_clk,
2421ebd05f90SRoger Quadros phy_type, TYPE_NONE,
2422ebd05f90SRoger Quadros ssc);
2423b54b47bdSSwapnil Jakhade if (rx_ln_vals) {
2424b54b47bdSSwapnil Jakhade reg_pairs = rx_ln_vals->reg_pairs;
2425b54b47bdSSwapnil Jakhade num_regs = rx_ln_vals->num_regs;
2426b54b47bdSSwapnil Jakhade for (i = 0; i < inst->num_lanes; i++) {
2427b54b47bdSSwapnil Jakhade regmap = cdns_phy->regmap_rx_lane_cdb[i + inst->mlane];
2428b54b47bdSSwapnil Jakhade for (j = 0; j < num_regs; j++)
2429b54b47bdSSwapnil Jakhade regmap_write(regmap, reg_pairs[j].off,
2430b54b47bdSSwapnil Jakhade reg_pairs[j].val);
2431b54b47bdSSwapnil Jakhade }
2432b54b47bdSSwapnil Jakhade }
2433b54b47bdSSwapnil Jakhade
2434da055e55SSwapnil Jakhade if (phy_type == TYPE_DP)
2435da055e55SSwapnil Jakhade return cdns_torrent_dp_init(phy);
2436da055e55SSwapnil Jakhade
2437b54b47bdSSwapnil Jakhade return 0;
2438b54b47bdSSwapnil Jakhade }
2439b54b47bdSSwapnil Jakhade
24405b16a790SSwapnil Jakhade static const struct phy_ops cdns_torrent_phy_ops = {
24415b16a790SSwapnil Jakhade .init = cdns_torrent_phy_init,
24425b16a790SSwapnil Jakhade .configure = cdns_torrent_dp_configure,
24435b16a790SSwapnil Jakhade .power_on = cdns_torrent_phy_on,
24445b16a790SSwapnil Jakhade .power_off = cdns_torrent_phy_off,
24455b16a790SSwapnil Jakhade .owner = THIS_MODULE,
24465b16a790SSwapnil Jakhade };
24475b16a790SSwapnil Jakhade
cdns_torrent_noop_phy_on(struct phy * phy)24485b16a790SSwapnil Jakhade static int cdns_torrent_noop_phy_on(struct phy *phy)
24495b16a790SSwapnil Jakhade {
24505b16a790SSwapnil Jakhade /* Give 5ms to 10ms delay for the PIPE clock to be stable */
24515b16a790SSwapnil Jakhade usleep_range(5000, 10000);
24525b16a790SSwapnil Jakhade
24535b16a790SSwapnil Jakhade return 0;
24545b16a790SSwapnil Jakhade }
24555b16a790SSwapnil Jakhade
24565b16a790SSwapnil Jakhade static const struct phy_ops noop_ops = {
24575b16a790SSwapnil Jakhade .power_on = cdns_torrent_noop_phy_on,
24585b16a790SSwapnil Jakhade .owner = THIS_MODULE,
24595b16a790SSwapnil Jakhade };
24605b16a790SSwapnil Jakhade
24616bcf3cb3SSwapnil Jakhade static
cdns_torrent_phy_configure_multilink(struct cdns_torrent_phy * cdns_phy)24626bcf3cb3SSwapnil Jakhade int cdns_torrent_phy_configure_multilink(struct cdns_torrent_phy *cdns_phy)
24636bcf3cb3SSwapnil Jakhade {
24646bcf3cb3SSwapnil Jakhade const struct cdns_torrent_data *init_data = cdns_phy->init_data;
24656bcf3cb3SSwapnil Jakhade struct cdns_torrent_vals *cmn_vals, *tx_ln_vals, *rx_ln_vals;
24666a2338a5SSwapnil Jakhade enum cdns_torrent_ref_clk ref_clk = cdns_phy->ref_clk_rate;
24676bcf3cb3SSwapnil Jakhade struct cdns_torrent_vals *link_cmn_vals, *xcvr_diag_vals;
2468a4634629SYang Guang enum cdns_torrent_phy_type phy_t1, phy_t2;
24694acea473SSwapnil Jakhade struct cdns_torrent_vals *pcs_cmn_vals;
2470f0f1fa04SSwapnil Jakhade int i, j, node, mlane, num_lanes, ret;
24716bcf3cb3SSwapnil Jakhade struct cdns_reg_pairs *reg_pairs;
24726bcf3cb3SSwapnil Jakhade enum cdns_torrent_ssc_mode ssc;
24736bcf3cb3SSwapnil Jakhade struct regmap *regmap;
24746bcf3cb3SSwapnil Jakhade u32 num_regs;
24756bcf3cb3SSwapnil Jakhade
24766bcf3cb3SSwapnil Jakhade /* Maximum 2 links (subnodes) are supported */
24776bcf3cb3SSwapnil Jakhade if (cdns_phy->nsubnodes != 2)
24786bcf3cb3SSwapnil Jakhade return -EINVAL;
24796bcf3cb3SSwapnil Jakhade
24806bcf3cb3SSwapnil Jakhade phy_t1 = cdns_phy->phys[0].phy_type;
24816bcf3cb3SSwapnil Jakhade phy_t2 = cdns_phy->phys[1].phy_type;
24826bcf3cb3SSwapnil Jakhade
24836bcf3cb3SSwapnil Jakhade /**
24846bcf3cb3SSwapnil Jakhade * First configure the PHY for first link with phy_t1. Get the array
24856bcf3cb3SSwapnil Jakhade * values as [phy_t1][phy_t2][ssc].
24866bcf3cb3SSwapnil Jakhade */
24876bcf3cb3SSwapnil Jakhade for (node = 0; node < cdns_phy->nsubnodes; node++) {
24886bcf3cb3SSwapnil Jakhade if (node == 1) {
24896bcf3cb3SSwapnil Jakhade /**
24906bcf3cb3SSwapnil Jakhade * If first link with phy_t1 is configured, then
24916bcf3cb3SSwapnil Jakhade * configure the PHY for second link with phy_t2.
24926bcf3cb3SSwapnil Jakhade * Get the array values as [phy_t2][phy_t1][ssc].
24936bcf3cb3SSwapnil Jakhade */
2494a4634629SYang Guang swap(phy_t1, phy_t2);
24956bcf3cb3SSwapnil Jakhade }
24966bcf3cb3SSwapnil Jakhade
24976bcf3cb3SSwapnil Jakhade mlane = cdns_phy->phys[node].mlane;
24986bcf3cb3SSwapnil Jakhade ssc = cdns_phy->phys[node].ssc_mode;
24996bcf3cb3SSwapnil Jakhade num_lanes = cdns_phy->phys[node].num_lanes;
25006bcf3cb3SSwapnil Jakhade
25016bcf3cb3SSwapnil Jakhade /**
25026bcf3cb3SSwapnil Jakhade * PHY configuration specific registers:
25036bcf3cb3SSwapnil Jakhade * link_cmn_vals depend on combination of PHY types being
25046bcf3cb3SSwapnil Jakhade * configured and are common for both PHY types, so array
25056bcf3cb3SSwapnil Jakhade * values should be same for [phy_t1][phy_t2][ssc] and
25066bcf3cb3SSwapnil Jakhade * [phy_t2][phy_t1][ssc].
25076bcf3cb3SSwapnil Jakhade * xcvr_diag_vals also depend on combination of PHY types
25086bcf3cb3SSwapnil Jakhade * being configured, but these can be different for particular
25096bcf3cb3SSwapnil Jakhade * PHY type and are per lane.
25106bcf3cb3SSwapnil Jakhade */
2511ebd05f90SRoger Quadros link_cmn_vals = cdns_torrent_get_tbl_vals(&init_data->link_cmn_vals_tbl,
2512ebd05f90SRoger Quadros CLK_ANY, CLK_ANY,
2513ebd05f90SRoger Quadros phy_t1, phy_t2, ANY_SSC);
25146bcf3cb3SSwapnil Jakhade if (link_cmn_vals) {
25156bcf3cb3SSwapnil Jakhade reg_pairs = link_cmn_vals->reg_pairs;
25166bcf3cb3SSwapnil Jakhade num_regs = link_cmn_vals->num_regs;
25176bcf3cb3SSwapnil Jakhade regmap = cdns_phy->regmap_common_cdb;
2518d66a6366SSwapnil Jakhade
2519d66a6366SSwapnil Jakhade /**
2520d66a6366SSwapnil Jakhade * First array value in link_cmn_vals must be of
2521d66a6366SSwapnil Jakhade * PHY_PLL_CFG register
2522d66a6366SSwapnil Jakhade */
2523d66a6366SSwapnil Jakhade regmap_field_write(cdns_phy->phy_pll_cfg,
2524d66a6366SSwapnil Jakhade reg_pairs[0].val);
2525d66a6366SSwapnil Jakhade
2526d66a6366SSwapnil Jakhade for (i = 1; i < num_regs; i++)
25276bcf3cb3SSwapnil Jakhade regmap_write(regmap, reg_pairs[i].off,
25286bcf3cb3SSwapnil Jakhade reg_pairs[i].val);
25296bcf3cb3SSwapnil Jakhade }
25306bcf3cb3SSwapnil Jakhade
2531ebd05f90SRoger Quadros xcvr_diag_vals = cdns_torrent_get_tbl_vals(&init_data->xcvr_diag_vals_tbl,
2532ebd05f90SRoger Quadros CLK_ANY, CLK_ANY,
2533ebd05f90SRoger Quadros phy_t1, phy_t2, ANY_SSC);
25346bcf3cb3SSwapnil Jakhade if (xcvr_diag_vals) {
25356bcf3cb3SSwapnil Jakhade reg_pairs = xcvr_diag_vals->reg_pairs;
25366bcf3cb3SSwapnil Jakhade num_regs = xcvr_diag_vals->num_regs;
25376bcf3cb3SSwapnil Jakhade for (i = 0; i < num_lanes; i++) {
25386bcf3cb3SSwapnil Jakhade regmap = cdns_phy->regmap_tx_lane_cdb[i + mlane];
25396bcf3cb3SSwapnil Jakhade for (j = 0; j < num_regs; j++)
25406bcf3cb3SSwapnil Jakhade regmap_write(regmap, reg_pairs[j].off,
25416bcf3cb3SSwapnil Jakhade reg_pairs[j].val);
25426bcf3cb3SSwapnil Jakhade }
25436bcf3cb3SSwapnil Jakhade }
25446bcf3cb3SSwapnil Jakhade
25454acea473SSwapnil Jakhade /* PHY PCS common registers configurations */
2546ebd05f90SRoger Quadros pcs_cmn_vals = cdns_torrent_get_tbl_vals(&init_data->pcs_cmn_vals_tbl,
2547ebd05f90SRoger Quadros CLK_ANY, CLK_ANY,
2548ebd05f90SRoger Quadros phy_t1, phy_t2, ANY_SSC);
25494acea473SSwapnil Jakhade if (pcs_cmn_vals) {
25504acea473SSwapnil Jakhade reg_pairs = pcs_cmn_vals->reg_pairs;
25514acea473SSwapnil Jakhade num_regs = pcs_cmn_vals->num_regs;
25524acea473SSwapnil Jakhade regmap = cdns_phy->regmap_phy_pcs_common_cdb;
25534acea473SSwapnil Jakhade for (i = 0; i < num_regs; i++)
25544acea473SSwapnil Jakhade regmap_write(regmap, reg_pairs[i].off,
25554acea473SSwapnil Jakhade reg_pairs[i].val);
25564acea473SSwapnil Jakhade }
25574acea473SSwapnil Jakhade
25586bcf3cb3SSwapnil Jakhade /* PMA common registers configurations */
2559ebd05f90SRoger Quadros cmn_vals = cdns_torrent_get_tbl_vals(&init_data->cmn_vals_tbl,
2560ebd05f90SRoger Quadros ref_clk, ref_clk,
2561ebd05f90SRoger Quadros phy_t1, phy_t2, ssc);
25626bcf3cb3SSwapnil Jakhade if (cmn_vals) {
25636bcf3cb3SSwapnil Jakhade reg_pairs = cmn_vals->reg_pairs;
25646bcf3cb3SSwapnil Jakhade num_regs = cmn_vals->num_regs;
25656bcf3cb3SSwapnil Jakhade regmap = cdns_phy->regmap_common_cdb;
25666bcf3cb3SSwapnil Jakhade for (i = 0; i < num_regs; i++)
25676bcf3cb3SSwapnil Jakhade regmap_write(regmap, reg_pairs[i].off,
25686bcf3cb3SSwapnil Jakhade reg_pairs[i].val);
25696bcf3cb3SSwapnil Jakhade }
25706bcf3cb3SSwapnil Jakhade
25716bcf3cb3SSwapnil Jakhade /* PMA TX lane registers configurations */
2572ebd05f90SRoger Quadros tx_ln_vals = cdns_torrent_get_tbl_vals(&init_data->tx_ln_vals_tbl,
2573ebd05f90SRoger Quadros ref_clk, ref_clk,
2574ebd05f90SRoger Quadros phy_t1, phy_t2, ssc);
25756bcf3cb3SSwapnil Jakhade if (tx_ln_vals) {
25766bcf3cb3SSwapnil Jakhade reg_pairs = tx_ln_vals->reg_pairs;
25776bcf3cb3SSwapnil Jakhade num_regs = tx_ln_vals->num_regs;
25786bcf3cb3SSwapnil Jakhade for (i = 0; i < num_lanes; i++) {
25796bcf3cb3SSwapnil Jakhade regmap = cdns_phy->regmap_tx_lane_cdb[i + mlane];
25806bcf3cb3SSwapnil Jakhade for (j = 0; j < num_regs; j++)
25816bcf3cb3SSwapnil Jakhade regmap_write(regmap, reg_pairs[j].off,
25826bcf3cb3SSwapnil Jakhade reg_pairs[j].val);
25836bcf3cb3SSwapnil Jakhade }
25846bcf3cb3SSwapnil Jakhade }
25856bcf3cb3SSwapnil Jakhade
25866bcf3cb3SSwapnil Jakhade /* PMA RX lane registers configurations */
2587ebd05f90SRoger Quadros rx_ln_vals = cdns_torrent_get_tbl_vals(&init_data->rx_ln_vals_tbl,
2588ebd05f90SRoger Quadros ref_clk, ref_clk,
2589ebd05f90SRoger Quadros phy_t1, phy_t2, ssc);
25906bcf3cb3SSwapnil Jakhade if (rx_ln_vals) {
25916bcf3cb3SSwapnil Jakhade reg_pairs = rx_ln_vals->reg_pairs;
25926bcf3cb3SSwapnil Jakhade num_regs = rx_ln_vals->num_regs;
25936bcf3cb3SSwapnil Jakhade for (i = 0; i < num_lanes; i++) {
25946bcf3cb3SSwapnil Jakhade regmap = cdns_phy->regmap_rx_lane_cdb[i + mlane];
25956bcf3cb3SSwapnil Jakhade for (j = 0; j < num_regs; j++)
25966bcf3cb3SSwapnil Jakhade regmap_write(regmap, reg_pairs[j].off,
25976bcf3cb3SSwapnil Jakhade reg_pairs[j].val);
25986bcf3cb3SSwapnil Jakhade }
25996bcf3cb3SSwapnil Jakhade }
2600f0f1fa04SSwapnil Jakhade
2601ede775a8SSwapnil Jakhade if (phy_t1 == TYPE_DP) {
2602ede775a8SSwapnil Jakhade ret = cdns_torrent_dp_get_pll(cdns_phy, phy_t2);
2603ede775a8SSwapnil Jakhade if (ret)
2604ede775a8SSwapnil Jakhade return ret;
2605ede775a8SSwapnil Jakhade }
2606ede775a8SSwapnil Jakhade
2607f0f1fa04SSwapnil Jakhade reset_control_deassert(cdns_phy->phys[node].lnk_rst);
26086bcf3cb3SSwapnil Jakhade }
26096bcf3cb3SSwapnil Jakhade
2610f0f1fa04SSwapnil Jakhade /* Take the PHY out of reset */
2611f0f1fa04SSwapnil Jakhade ret = reset_control_deassert(cdns_phy->phy_rst);
2612f0f1fa04SSwapnil Jakhade if (ret)
2613f0f1fa04SSwapnil Jakhade return ret;
2614f0f1fa04SSwapnil Jakhade
26156bcf3cb3SSwapnil Jakhade return 0;
26166bcf3cb3SSwapnil Jakhade }
26176bcf3cb3SSwapnil Jakhade
cdns_torrent_clk_cleanup(struct cdns_torrent_phy * cdns_phy)26182cca0228SKishon Vijay Abraham I static void cdns_torrent_clk_cleanup(struct cdns_torrent_phy *cdns_phy)
26192cca0228SKishon Vijay Abraham I {
26202cca0228SKishon Vijay Abraham I struct device *dev = cdns_phy->dev;
26212cca0228SKishon Vijay Abraham I
26222cca0228SKishon Vijay Abraham I of_clk_del_provider(dev->of_node);
26232cca0228SKishon Vijay Abraham I }
26242cca0228SKishon Vijay Abraham I
cdns_torrent_clk_register(struct cdns_torrent_phy * cdns_phy)26252cca0228SKishon Vijay Abraham I static int cdns_torrent_clk_register(struct cdns_torrent_phy *cdns_phy)
26262cca0228SKishon Vijay Abraham I {
26272cca0228SKishon Vijay Abraham I struct device *dev = cdns_phy->dev;
26282cca0228SKishon Vijay Abraham I struct device_node *node = dev->of_node;
2629aef096dbSSwapnil Jakhade struct clk_hw_onecell_data *data;
26302cca0228SKishon Vijay Abraham I int ret;
26312cca0228SKishon Vijay Abraham I
2632aef096dbSSwapnil Jakhade data = devm_kzalloc(dev, struct_size(data, hws, CDNS_TORRENT_OUTPUT_CLOCKS), GFP_KERNEL);
2633aef096dbSSwapnil Jakhade if (!data)
2634aef096dbSSwapnil Jakhade return -ENOMEM;
2635aef096dbSSwapnil Jakhade
2636aef096dbSSwapnil Jakhade data->num = CDNS_TORRENT_OUTPUT_CLOCKS;
2637aef096dbSSwapnil Jakhade cdns_phy->clk_hw_data = data;
2638aef096dbSSwapnil Jakhade
26392cca0228SKishon Vijay Abraham I ret = cdns_torrent_derived_refclk_register(cdns_phy);
26402cca0228SKishon Vijay Abraham I if (ret) {
26412cca0228SKishon Vijay Abraham I dev_err(dev, "failed to register derived refclk\n");
26422cca0228SKishon Vijay Abraham I return ret;
26432cca0228SKishon Vijay Abraham I }
26442cca0228SKishon Vijay Abraham I
2645785a4e68SSwapnil Jakhade ret = cdns_torrent_received_refclk_register(cdns_phy);
2646785a4e68SSwapnil Jakhade if (ret) {
2647785a4e68SSwapnil Jakhade dev_err(dev, "failed to register received refclk\n");
2648785a4e68SSwapnil Jakhade return ret;
2649785a4e68SSwapnil Jakhade }
2650785a4e68SSwapnil Jakhade
2651235bde4fSSwapnil Jakhade ret = cdns_torrent_refclk_driver_register(cdns_phy);
2652235bde4fSSwapnil Jakhade if (ret) {
2653235bde4fSSwapnil Jakhade dev_err(dev, "failed to register refclk driver\n");
2654235bde4fSSwapnil Jakhade return ret;
2655235bde4fSSwapnil Jakhade }
2656235bde4fSSwapnil Jakhade
2657aef096dbSSwapnil Jakhade ret = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, data);
26582cca0228SKishon Vijay Abraham I if (ret) {
26592cca0228SKishon Vijay Abraham I dev_err(dev, "Failed to add clock provider: %s\n", node->name);
26602cca0228SKishon Vijay Abraham I return ret;
26612cca0228SKishon Vijay Abraham I }
26622cca0228SKishon Vijay Abraham I
26632cca0228SKishon Vijay Abraham I return 0;
26642cca0228SKishon Vijay Abraham I }
26652cca0228SKishon Vijay Abraham I
cdns_torrent_reset(struct cdns_torrent_phy * cdns_phy)2666d44b4bf4SKishon Vijay Abraham I static int cdns_torrent_reset(struct cdns_torrent_phy *cdns_phy)
2667d44b4bf4SKishon Vijay Abraham I {
2668d44b4bf4SKishon Vijay Abraham I struct device *dev = cdns_phy->dev;
2669d44b4bf4SKishon Vijay Abraham I
2670d44b4bf4SKishon Vijay Abraham I cdns_phy->phy_rst = devm_reset_control_get_exclusive_by_index(dev, 0);
2671d44b4bf4SKishon Vijay Abraham I if (IS_ERR(cdns_phy->phy_rst)) {
2672d44b4bf4SKishon Vijay Abraham I dev_err(dev, "%s: failed to get reset\n",
2673d44b4bf4SKishon Vijay Abraham I dev->of_node->full_name);
2674d44b4bf4SKishon Vijay Abraham I return PTR_ERR(cdns_phy->phy_rst);
2675d44b4bf4SKishon Vijay Abraham I }
2676d44b4bf4SKishon Vijay Abraham I
2677e0611d6dSKishon Vijay Abraham I cdns_phy->apb_rst = devm_reset_control_get_optional_exclusive(dev, "torrent_apb");
2678d44b4bf4SKishon Vijay Abraham I if (IS_ERR(cdns_phy->apb_rst)) {
2679d44b4bf4SKishon Vijay Abraham I dev_err(dev, "%s: failed to get apb reset\n",
2680d44b4bf4SKishon Vijay Abraham I dev->of_node->full_name);
2681d44b4bf4SKishon Vijay Abraham I return PTR_ERR(cdns_phy->apb_rst);
2682d44b4bf4SKishon Vijay Abraham I }
2683d44b4bf4SKishon Vijay Abraham I
2684d44b4bf4SKishon Vijay Abraham I return 0;
2685d44b4bf4SKishon Vijay Abraham I }
2686d44b4bf4SKishon Vijay Abraham I
cdns_torrent_clk(struct cdns_torrent_phy * cdns_phy)2687d44b4bf4SKishon Vijay Abraham I static int cdns_torrent_clk(struct cdns_torrent_phy *cdns_phy)
2688d44b4bf4SKishon Vijay Abraham I {
2689d44b4bf4SKishon Vijay Abraham I struct device *dev = cdns_phy->dev;
26903b401625SSwapnil Jakhade unsigned long ref_clk_rate;
2691d44b4bf4SKishon Vijay Abraham I int ret;
2692d44b4bf4SKishon Vijay Abraham I
2693d44b4bf4SKishon Vijay Abraham I cdns_phy->clk = devm_clk_get(dev, "refclk");
2694d44b4bf4SKishon Vijay Abraham I if (IS_ERR(cdns_phy->clk)) {
2695d44b4bf4SKishon Vijay Abraham I dev_err(dev, "phy ref clock not found\n");
2696d44b4bf4SKishon Vijay Abraham I return PTR_ERR(cdns_phy->clk);
2697d44b4bf4SKishon Vijay Abraham I }
2698d44b4bf4SKishon Vijay Abraham I
2699d44b4bf4SKishon Vijay Abraham I ret = clk_prepare_enable(cdns_phy->clk);
2700d44b4bf4SKishon Vijay Abraham I if (ret) {
2701d44b4bf4SKishon Vijay Abraham I dev_err(cdns_phy->dev, "Failed to prepare ref clock\n");
2702d44b4bf4SKishon Vijay Abraham I return ret;
2703d44b4bf4SKishon Vijay Abraham I }
2704d44b4bf4SKishon Vijay Abraham I
27053b401625SSwapnil Jakhade ref_clk_rate = clk_get_rate(cdns_phy->clk);
27063b401625SSwapnil Jakhade if (!ref_clk_rate) {
2707d44b4bf4SKishon Vijay Abraham I dev_err(cdns_phy->dev, "Failed to get ref clock rate\n");
2708d44b4bf4SKishon Vijay Abraham I clk_disable_unprepare(cdns_phy->clk);
2709d44b4bf4SKishon Vijay Abraham I return -EINVAL;
2710d44b4bf4SKishon Vijay Abraham I }
2711d44b4bf4SKishon Vijay Abraham I
27123b401625SSwapnil Jakhade switch (ref_clk_rate) {
27133b401625SSwapnil Jakhade case REF_CLK_19_2MHZ:
27143b401625SSwapnil Jakhade cdns_phy->ref_clk_rate = CLK_19_2_MHZ;
27153b401625SSwapnil Jakhade break;
27163b401625SSwapnil Jakhade case REF_CLK_25MHZ:
27173b401625SSwapnil Jakhade cdns_phy->ref_clk_rate = CLK_25_MHZ;
27183b401625SSwapnil Jakhade break;
27193b401625SSwapnil Jakhade case REF_CLK_100MHZ:
27203b401625SSwapnil Jakhade cdns_phy->ref_clk_rate = CLK_100_MHZ;
27213b401625SSwapnil Jakhade break;
272216e0f0eaSSwapnil Jakhade case REF_CLK_156_25MHZ:
272316e0f0eaSSwapnil Jakhade cdns_phy->ref_clk_rate = CLK_156_25_MHZ;
272416e0f0eaSSwapnil Jakhade break;
27253b401625SSwapnil Jakhade default:
27263b401625SSwapnil Jakhade dev_err(cdns_phy->dev, "Invalid Ref Clock Rate\n");
27273b401625SSwapnil Jakhade clk_disable_unprepare(cdns_phy->clk);
27283b401625SSwapnil Jakhade return -EINVAL;
27293b401625SSwapnil Jakhade }
27303b401625SSwapnil Jakhade
2731d44b4bf4SKishon Vijay Abraham I return 0;
2732d44b4bf4SKishon Vijay Abraham I }
2733d44b4bf4SKishon Vijay Abraham I
cdns_torrent_phy_probe(struct platform_device * pdev)273492e9ccc6SSwapnil Jakhade static int cdns_torrent_phy_probe(struct platform_device *pdev)
2735c589e701SYuti Amonkar {
273692e9ccc6SSwapnil Jakhade struct cdns_torrent_phy *cdns_phy;
2737c589e701SYuti Amonkar struct device *dev = &pdev->dev;
2738c589e701SYuti Amonkar struct phy_provider *phy_provider;
273929d1fd2fSSwapnil Jakhade const struct cdns_torrent_data *data;
2740afa4ba05SSwapnil Jakhade struct device_node *child;
2741afa4ba05SSwapnil Jakhade int ret, subnodes, node = 0, i;
2742d09945eaSSwapnil Jakhade u32 total_num_lanes = 0;
2743b69d39f6SKishon Vijay Abraham I int already_configured;
27442e70c849SSwapnil Jakhade u8 init_dp_regmap = 0;
2745b54b47bdSSwapnil Jakhade u32 phy_type;
274669d114acSSwapnil Jakhade
274769d114acSSwapnil Jakhade /* Get init data for this PHY */
274829d1fd2fSSwapnil Jakhade data = of_device_get_match_data(dev);
274929d1fd2fSSwapnil Jakhade if (!data)
275069d114acSSwapnil Jakhade return -EINVAL;
275169d114acSSwapnil Jakhade
2752c589e701SYuti Amonkar cdns_phy = devm_kzalloc(dev, sizeof(*cdns_phy), GFP_KERNEL);
2753c589e701SYuti Amonkar if (!cdns_phy)
2754c589e701SYuti Amonkar return -ENOMEM;
2755c589e701SYuti Amonkar
2756afa4ba05SSwapnil Jakhade dev_set_drvdata(dev, cdns_phy);
2757afa4ba05SSwapnil Jakhade cdns_phy->dev = dev;
275829d1fd2fSSwapnil Jakhade cdns_phy->init_data = data;
2759c589e701SYuti Amonkar
276046d205afSSwapnil Jakhade cdns_phy->sd_base = devm_platform_ioremap_resource(pdev, 0);
276169d114acSSwapnil Jakhade if (IS_ERR(cdns_phy->sd_base))
276269d114acSSwapnil Jakhade return PTR_ERR(cdns_phy->sd_base);
276369d114acSSwapnil Jakhade
2764afa4ba05SSwapnil Jakhade subnodes = of_get_available_child_count(dev->of_node);
2765afa4ba05SSwapnil Jakhade if (subnodes == 0) {
2766afa4ba05SSwapnil Jakhade dev_err(dev, "No available link subnodes found\n");
2767afa4ba05SSwapnil Jakhade return -EINVAL;
2768afa4ba05SSwapnil Jakhade }
2769c589e701SYuti Amonkar
27702e70c849SSwapnil Jakhade ret = cdns_torrent_regmap_init(cdns_phy);
27712e70c849SSwapnil Jakhade if (ret)
27722e70c849SSwapnil Jakhade return ret;
27732e70c849SSwapnil Jakhade
27742e70c849SSwapnil Jakhade ret = cdns_torrent_regfield_init(cdns_phy);
27752e70c849SSwapnil Jakhade if (ret)
27762e70c849SSwapnil Jakhade return ret;
27772e70c849SSwapnil Jakhade
27782cca0228SKishon Vijay Abraham I ret = cdns_torrent_clk_register(cdns_phy);
27792cca0228SKishon Vijay Abraham I if (ret)
27802cca0228SKishon Vijay Abraham I return ret;
27812cca0228SKishon Vijay Abraham I
2782b69d39f6SKishon Vijay Abraham I regmap_field_read(cdns_phy->phy_pma_cmn_ctrl_1, &already_configured);
2783b69d39f6SKishon Vijay Abraham I
2784b69d39f6SKishon Vijay Abraham I if (!already_configured) {
2785d44b4bf4SKishon Vijay Abraham I ret = cdns_torrent_reset(cdns_phy);
2786d44b4bf4SKishon Vijay Abraham I if (ret)
27872cca0228SKishon Vijay Abraham I goto clk_cleanup;
278807084c95SSwapnil Jakhade
2789d44b4bf4SKishon Vijay Abraham I ret = cdns_torrent_clk(cdns_phy);
2790d44b4bf4SKishon Vijay Abraham I if (ret)
2791d44b4bf4SKishon Vijay Abraham I goto clk_cleanup;
279207084c95SSwapnil Jakhade
279315c6a048SSwapnil Jakhade /* Enable APB */
279415c6a048SSwapnil Jakhade reset_control_deassert(cdns_phy->apb_rst);
2795b69d39f6SKishon Vijay Abraham I }
279615c6a048SSwapnil Jakhade
2797afa4ba05SSwapnil Jakhade for_each_available_child_of_node(dev->of_node, child) {
2798afa4ba05SSwapnil Jakhade struct phy *gphy;
2799c589e701SYuti Amonkar
28006bcf3cb3SSwapnil Jakhade /* PHY subnode name must be 'phy'. */
28016bcf3cb3SSwapnil Jakhade if (!(of_node_name_eq(child, "phy")))
28026bcf3cb3SSwapnil Jakhade continue;
28036bcf3cb3SSwapnil Jakhade
2804afa4ba05SSwapnil Jakhade cdns_phy->phys[node].lnk_rst =
2805afa4ba05SSwapnil Jakhade of_reset_control_array_get_exclusive(child);
2806afa4ba05SSwapnil Jakhade if (IS_ERR(cdns_phy->phys[node].lnk_rst)) {
2807afa4ba05SSwapnil Jakhade dev_err(dev, "%s: failed to get reset\n",
2808afa4ba05SSwapnil Jakhade child->full_name);
2809afa4ba05SSwapnil Jakhade ret = PTR_ERR(cdns_phy->phys[node].lnk_rst);
2810afa4ba05SSwapnil Jakhade goto put_lnk_rst;
2811afa4ba05SSwapnil Jakhade }
2812c589e701SYuti Amonkar
2813afa4ba05SSwapnil Jakhade if (of_property_read_u32(child, "reg",
2814afa4ba05SSwapnil Jakhade &cdns_phy->phys[node].mlane)) {
2815afa4ba05SSwapnil Jakhade dev_err(dev, "%s: No \"reg\"-property.\n",
2816afa4ba05SSwapnil Jakhade child->full_name);
2817afa4ba05SSwapnil Jakhade ret = -EINVAL;
2818afa4ba05SSwapnil Jakhade goto put_child;
2819afa4ba05SSwapnil Jakhade }
2820afa4ba05SSwapnil Jakhade
2821b54b47bdSSwapnil Jakhade if (of_property_read_u32(child, "cdns,phy-type", &phy_type)) {
2822afa4ba05SSwapnil Jakhade dev_err(dev, "%s: No \"cdns,phy-type\"-property.\n",
2823afa4ba05SSwapnil Jakhade child->full_name);
2824afa4ba05SSwapnil Jakhade ret = -EINVAL;
2825afa4ba05SSwapnil Jakhade goto put_child;
2826afa4ba05SSwapnil Jakhade }
2827afa4ba05SSwapnil Jakhade
2828b54b47bdSSwapnil Jakhade switch (phy_type) {
2829b54b47bdSSwapnil Jakhade case PHY_TYPE_PCIE:
2830b54b47bdSSwapnil Jakhade cdns_phy->phys[node].phy_type = TYPE_PCIE;
2831b54b47bdSSwapnil Jakhade break;
2832b54b47bdSSwapnil Jakhade case PHY_TYPE_DP:
2833b54b47bdSSwapnil Jakhade cdns_phy->phys[node].phy_type = TYPE_DP;
2834b54b47bdSSwapnil Jakhade break;
28356bcf3cb3SSwapnil Jakhade case PHY_TYPE_SGMII:
28366bcf3cb3SSwapnil Jakhade cdns_phy->phys[node].phy_type = TYPE_SGMII;
28376bcf3cb3SSwapnil Jakhade break;
28386bcf3cb3SSwapnil Jakhade case PHY_TYPE_QSGMII:
28396bcf3cb3SSwapnil Jakhade cdns_phy->phys[node].phy_type = TYPE_QSGMII;
28406bcf3cb3SSwapnil Jakhade break;
28419855d84bSSwapnil Jakhade case PHY_TYPE_USB3:
28429855d84bSSwapnil Jakhade cdns_phy->phys[node].phy_type = TYPE_USB;
28439855d84bSSwapnil Jakhade break;
284416e0f0eaSSwapnil Jakhade case PHY_TYPE_USXGMII:
284516e0f0eaSSwapnil Jakhade cdns_phy->phys[node].phy_type = TYPE_USXGMII;
284616e0f0eaSSwapnil Jakhade break;
2847b54b47bdSSwapnil Jakhade default:
2848b54b47bdSSwapnil Jakhade dev_err(dev, "Unsupported protocol\n");
2849b54b47bdSSwapnil Jakhade ret = -EINVAL;
2850b54b47bdSSwapnil Jakhade goto put_child;
2851b54b47bdSSwapnil Jakhade }
2852b54b47bdSSwapnil Jakhade
2853d09945eaSSwapnil Jakhade if (of_property_read_u32(child, "cdns,num-lanes",
2854d09945eaSSwapnil Jakhade &cdns_phy->phys[node].num_lanes)) {
2855d09945eaSSwapnil Jakhade dev_err(dev, "%s: No \"cdns,num-lanes\"-property.\n",
2856d09945eaSSwapnil Jakhade child->full_name);
2857d09945eaSSwapnil Jakhade ret = -EINVAL;
2858d09945eaSSwapnil Jakhade goto put_child;
2859d09945eaSSwapnil Jakhade }
2860d09945eaSSwapnil Jakhade
2861d09945eaSSwapnil Jakhade total_num_lanes += cdns_phy->phys[node].num_lanes;
2862afa4ba05SSwapnil Jakhade
2863b54b47bdSSwapnil Jakhade /* Get SSC mode */
2864b54b47bdSSwapnil Jakhade cdns_phy->phys[node].ssc_mode = NO_SSC;
2865b54b47bdSSwapnil Jakhade of_property_read_u32(child, "cdns,ssc-mode",
2866b54b47bdSSwapnil Jakhade &cdns_phy->phys[node].ssc_mode);
2867b54b47bdSSwapnil Jakhade
2868b69d39f6SKishon Vijay Abraham I if (!already_configured)
2869b54b47bdSSwapnil Jakhade gphy = devm_phy_create(dev, child, &cdns_torrent_phy_ops);
2870b69d39f6SKishon Vijay Abraham I else
2871b69d39f6SKishon Vijay Abraham I gphy = devm_phy_create(dev, child, &noop_ops);
2872b54b47bdSSwapnil Jakhade if (IS_ERR(gphy)) {
2873b54b47bdSSwapnil Jakhade ret = PTR_ERR(gphy);
2874b54b47bdSSwapnil Jakhade goto put_child;
2875b54b47bdSSwapnil Jakhade }
2876b54b47bdSSwapnil Jakhade
2877b54b47bdSSwapnil Jakhade if (cdns_phy->phys[node].phy_type == TYPE_DP) {
2878afa4ba05SSwapnil Jakhade switch (cdns_phy->phys[node].num_lanes) {
2879c589e701SYuti Amonkar case 1:
2880c589e701SYuti Amonkar case 2:
2881c589e701SYuti Amonkar case 4:
2882c589e701SYuti Amonkar /* valid number of lanes */
2883c589e701SYuti Amonkar break;
2884c589e701SYuti Amonkar default:
2885c589e701SYuti Amonkar dev_err(dev, "unsupported number of lanes: %d\n",
2886afa4ba05SSwapnil Jakhade cdns_phy->phys[node].num_lanes);
2887afa4ba05SSwapnil Jakhade ret = -EINVAL;
2888afa4ba05SSwapnil Jakhade goto put_child;
2889c589e701SYuti Amonkar }
2890c589e701SYuti Amonkar
2891c589e701SYuti Amonkar cdns_phy->max_bit_rate = DEFAULT_MAX_BIT_RATE;
2892afa4ba05SSwapnil Jakhade of_property_read_u32(child, "cdns,max-bit-rate",
2893afa4ba05SSwapnil Jakhade &cdns_phy->max_bit_rate);
2894c589e701SYuti Amonkar
2895c589e701SYuti Amonkar switch (cdns_phy->max_bit_rate) {
2896e4b496a3SSwapnil Jakhade case 1620:
2897c589e701SYuti Amonkar case 2160:
2898c589e701SYuti Amonkar case 2430:
2899c589e701SYuti Amonkar case 2700:
2900c589e701SYuti Amonkar case 3240:
2901c589e701SYuti Amonkar case 4320:
2902c589e701SYuti Amonkar case 5400:
2903c589e701SYuti Amonkar case 8100:
2904c589e701SYuti Amonkar /* valid bit rate */
2905c589e701SYuti Amonkar break;
2906c589e701SYuti Amonkar default:
2907c589e701SYuti Amonkar dev_err(dev, "unsupported max bit rate: %dMbps\n",
2908c589e701SYuti Amonkar cdns_phy->max_bit_rate);
2909afa4ba05SSwapnil Jakhade ret = -EINVAL;
2910afa4ba05SSwapnil Jakhade goto put_child;
2911c589e701SYuti Amonkar }
2912c589e701SYuti Amonkar
2913afa4ba05SSwapnil Jakhade /* DPTX registers */
291446d205afSSwapnil Jakhade cdns_phy->base = devm_platform_ioremap_resource(pdev, 1);
2915afa4ba05SSwapnil Jakhade if (IS_ERR(cdns_phy->base)) {
2916afa4ba05SSwapnil Jakhade ret = PTR_ERR(cdns_phy->base);
2917afa4ba05SSwapnil Jakhade goto put_child;
2918e4b496a3SSwapnil Jakhade }
2919e4b496a3SSwapnil Jakhade
29202e70c849SSwapnil Jakhade if (!init_dp_regmap) {
29212e70c849SSwapnil Jakhade ret = cdns_torrent_dp_regmap_init(cdns_phy);
29222e70c849SSwapnil Jakhade if (ret)
29232e70c849SSwapnil Jakhade goto put_child;
29242e70c849SSwapnil Jakhade
29252e70c849SSwapnil Jakhade ret = cdns_torrent_dp_regfield_init(cdns_phy);
29262e70c849SSwapnil Jakhade if (ret)
29272e70c849SSwapnil Jakhade goto put_child;
29282e70c849SSwapnil Jakhade
29292e70c849SSwapnil Jakhade init_dp_regmap++;
29302e70c849SSwapnil Jakhade }
29312e70c849SSwapnil Jakhade
293284f55df8SSwapnil Jakhade dev_dbg(dev, "DP max bit rate %d.%03d Gbps\n",
2933afa4ba05SSwapnil Jakhade cdns_phy->max_bit_rate / 1000,
2934afa4ba05SSwapnil Jakhade cdns_phy->max_bit_rate % 1000);
29350ffcc378SSwapnil Jakhade
29360ffcc378SSwapnil Jakhade gphy->attrs.bus_width = cdns_phy->phys[node].num_lanes;
29370ffcc378SSwapnil Jakhade gphy->attrs.max_link_rate = cdns_phy->max_bit_rate;
29380ffcc378SSwapnil Jakhade gphy->attrs.mode = PHY_MODE_DP;
2939afa4ba05SSwapnil Jakhade }
2940b54b47bdSSwapnil Jakhade
2941afa4ba05SSwapnil Jakhade cdns_phy->phys[node].phy = gphy;
2942afa4ba05SSwapnil Jakhade phy_set_drvdata(gphy, &cdns_phy->phys[node]);
2943afa4ba05SSwapnil Jakhade
2944afa4ba05SSwapnil Jakhade node++;
2945afa4ba05SSwapnil Jakhade }
2946afa4ba05SSwapnil Jakhade cdns_phy->nsubnodes = node;
2947c589e701SYuti Amonkar
2948d09945eaSSwapnil Jakhade if (total_num_lanes > MAX_NUM_LANES) {
2949d09945eaSSwapnil Jakhade dev_err(dev, "Invalid lane configuration\n");
2950266df28fSDan Carpenter ret = -EINVAL;
2951d09945eaSSwapnil Jakhade goto put_lnk_rst;
2952d09945eaSSwapnil Jakhade }
2953d09945eaSSwapnil Jakhade
2954b69d39f6SKishon Vijay Abraham I if (cdns_phy->nsubnodes > 1 && !already_configured) {
29556bcf3cb3SSwapnil Jakhade ret = cdns_torrent_phy_configure_multilink(cdns_phy);
29566bcf3cb3SSwapnil Jakhade if (ret)
29576bcf3cb3SSwapnil Jakhade goto put_lnk_rst;
29586bcf3cb3SSwapnil Jakhade }
29596bcf3cb3SSwapnil Jakhade
2960c589e701SYuti Amonkar phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
2961afa4ba05SSwapnil Jakhade if (IS_ERR(phy_provider)) {
2962afa4ba05SSwapnil Jakhade ret = PTR_ERR(phy_provider);
2963afa4ba05SSwapnil Jakhade goto put_lnk_rst;
2964afa4ba05SSwapnil Jakhade }
2965c589e701SYuti Amonkar
296684f55df8SSwapnil Jakhade if (cdns_phy->nsubnodes > 1)
296784f55df8SSwapnil Jakhade dev_dbg(dev, "Multi-link: %s (%d lanes) & %s (%d lanes)",
296884f55df8SSwapnil Jakhade cdns_torrent_get_phy_type(cdns_phy->phys[0].phy_type),
296984f55df8SSwapnil Jakhade cdns_phy->phys[0].num_lanes,
297084f55df8SSwapnil Jakhade cdns_torrent_get_phy_type(cdns_phy->phys[1].phy_type),
297184f55df8SSwapnil Jakhade cdns_phy->phys[1].num_lanes);
297284f55df8SSwapnil Jakhade else
297384f55df8SSwapnil Jakhade dev_dbg(dev, "Single link: %s (%d lanes)",
297484f55df8SSwapnil Jakhade cdns_torrent_get_phy_type(cdns_phy->phys[0].phy_type),
297584f55df8SSwapnil Jakhade cdns_phy->phys[0].num_lanes);
297684f55df8SSwapnil Jakhade
2977afa4ba05SSwapnil Jakhade return 0;
2978c589e701SYuti Amonkar
2979afa4ba05SSwapnil Jakhade put_child:
2980afa4ba05SSwapnil Jakhade node++;
2981afa4ba05SSwapnil Jakhade put_lnk_rst:
2982afa4ba05SSwapnil Jakhade for (i = 0; i < node; i++)
2983afa4ba05SSwapnil Jakhade reset_control_put(cdns_phy->phys[i].lnk_rst);
2984afa4ba05SSwapnil Jakhade of_node_put(child);
298515c6a048SSwapnil Jakhade reset_control_assert(cdns_phy->apb_rst);
298607084c95SSwapnil Jakhade clk_disable_unprepare(cdns_phy->clk);
29872cca0228SKishon Vijay Abraham I clk_cleanup:
29882cca0228SKishon Vijay Abraham I cdns_torrent_clk_cleanup(cdns_phy);
2989afa4ba05SSwapnil Jakhade return ret;
2990afa4ba05SSwapnil Jakhade }
2991afa4ba05SSwapnil Jakhade
cdns_torrent_phy_remove(struct platform_device * pdev)2992e758fbbcSUwe Kleine-König static void cdns_torrent_phy_remove(struct platform_device *pdev)
2993afa4ba05SSwapnil Jakhade {
2994afa4ba05SSwapnil Jakhade struct cdns_torrent_phy *cdns_phy = platform_get_drvdata(pdev);
2995afa4ba05SSwapnil Jakhade int i;
2996afa4ba05SSwapnil Jakhade
2997afa4ba05SSwapnil Jakhade reset_control_assert(cdns_phy->phy_rst);
299815c6a048SSwapnil Jakhade reset_control_assert(cdns_phy->apb_rst);
2999afa4ba05SSwapnil Jakhade for (i = 0; i < cdns_phy->nsubnodes; i++) {
3000afa4ba05SSwapnil Jakhade reset_control_assert(cdns_phy->phys[i].lnk_rst);
3001afa4ba05SSwapnil Jakhade reset_control_put(cdns_phy->phys[i].lnk_rst);
3002afa4ba05SSwapnil Jakhade }
3003afa4ba05SSwapnil Jakhade
300407084c95SSwapnil Jakhade clk_disable_unprepare(cdns_phy->clk);
30052cca0228SKishon Vijay Abraham I cdns_torrent_clk_cleanup(cdns_phy);
3006c589e701SYuti Amonkar }
3007c589e701SYuti Amonkar
300872a5ce33SSwapnil Jakhade /* USB and DP link configuration */
300972a5ce33SSwapnil Jakhade static struct cdns_reg_pairs usb_dp_link_cmn_regs[] = {
301072a5ce33SSwapnil Jakhade {0x0002, PHY_PLL_CFG},
301172a5ce33SSwapnil Jakhade {0x8600, CMN_PDIAG_PLL0_CLK_SEL_M0}
301272a5ce33SSwapnil Jakhade };
301372a5ce33SSwapnil Jakhade
301472a5ce33SSwapnil Jakhade static struct cdns_reg_pairs usb_dp_xcvr_diag_ln_regs[] = {
301572a5ce33SSwapnil Jakhade {0x0000, XCVR_DIAG_HSCLK_SEL},
301672a5ce33SSwapnil Jakhade {0x0001, XCVR_DIAG_HSCLK_DIV},
301772a5ce33SSwapnil Jakhade {0x0041, XCVR_DIAG_PLLDRC_CTRL}
301872a5ce33SSwapnil Jakhade };
301972a5ce33SSwapnil Jakhade
302072a5ce33SSwapnil Jakhade static struct cdns_reg_pairs dp_usb_xcvr_diag_ln_regs[] = {
302172a5ce33SSwapnil Jakhade {0x0001, XCVR_DIAG_HSCLK_SEL},
302272a5ce33SSwapnil Jakhade {0x0009, XCVR_DIAG_PLLDRC_CTRL}
302372a5ce33SSwapnil Jakhade };
302472a5ce33SSwapnil Jakhade
302572a5ce33SSwapnil Jakhade static struct cdns_torrent_vals usb_dp_link_cmn_vals = {
302672a5ce33SSwapnil Jakhade .reg_pairs = usb_dp_link_cmn_regs,
302772a5ce33SSwapnil Jakhade .num_regs = ARRAY_SIZE(usb_dp_link_cmn_regs),
302872a5ce33SSwapnil Jakhade };
302972a5ce33SSwapnil Jakhade
303072a5ce33SSwapnil Jakhade static struct cdns_torrent_vals usb_dp_xcvr_diag_ln_vals = {
303172a5ce33SSwapnil Jakhade .reg_pairs = usb_dp_xcvr_diag_ln_regs,
303272a5ce33SSwapnil Jakhade .num_regs = ARRAY_SIZE(usb_dp_xcvr_diag_ln_regs),
303372a5ce33SSwapnil Jakhade };
303472a5ce33SSwapnil Jakhade
303572a5ce33SSwapnil Jakhade static struct cdns_torrent_vals dp_usb_xcvr_diag_ln_vals = {
303672a5ce33SSwapnil Jakhade .reg_pairs = dp_usb_xcvr_diag_ln_regs,
303772a5ce33SSwapnil Jakhade .num_regs = ARRAY_SIZE(dp_usb_xcvr_diag_ln_regs),
303872a5ce33SSwapnil Jakhade };
303972a5ce33SSwapnil Jakhade
304016e0f0eaSSwapnil Jakhade /* TI USXGMII configuration: Enable cmn_refclk_rcv_out_en */
304116e0f0eaSSwapnil Jakhade static struct cdns_reg_pairs ti_usxgmii_phy_pma_cmn_regs[] = {
304216e0f0eaSSwapnil Jakhade {0x0040, PHY_PMA_CMN_CTRL1},
304316e0f0eaSSwapnil Jakhade };
304416e0f0eaSSwapnil Jakhade
304516e0f0eaSSwapnil Jakhade static struct cdns_torrent_vals ti_usxgmii_phy_pma_cmn_vals = {
304616e0f0eaSSwapnil Jakhade .reg_pairs = ti_usxgmii_phy_pma_cmn_regs,
304716e0f0eaSSwapnil Jakhade .num_regs = ARRAY_SIZE(ti_usxgmii_phy_pma_cmn_regs),
304816e0f0eaSSwapnil Jakhade };
304916e0f0eaSSwapnil Jakhade
305016e0f0eaSSwapnil Jakhade /* Single USXGMII link configuration */
305116e0f0eaSSwapnil Jakhade static struct cdns_reg_pairs sl_usxgmii_link_cmn_regs[] = {
305216e0f0eaSSwapnil Jakhade {0x0000, PHY_PLL_CFG},
305316e0f0eaSSwapnil Jakhade {0x0400, CMN_PDIAG_PLL0_CLK_SEL_M0}
305416e0f0eaSSwapnil Jakhade };
305516e0f0eaSSwapnil Jakhade
305616e0f0eaSSwapnil Jakhade static struct cdns_reg_pairs sl_usxgmii_xcvr_diag_ln_regs[] = {
305716e0f0eaSSwapnil Jakhade {0x0000, XCVR_DIAG_HSCLK_SEL},
305816e0f0eaSSwapnil Jakhade {0x0001, XCVR_DIAG_HSCLK_DIV},
305916e0f0eaSSwapnil Jakhade {0x0001, XCVR_DIAG_PLLDRC_CTRL}
306016e0f0eaSSwapnil Jakhade };
306116e0f0eaSSwapnil Jakhade
306216e0f0eaSSwapnil Jakhade static struct cdns_torrent_vals sl_usxgmii_link_cmn_vals = {
306316e0f0eaSSwapnil Jakhade .reg_pairs = sl_usxgmii_link_cmn_regs,
306416e0f0eaSSwapnil Jakhade .num_regs = ARRAY_SIZE(sl_usxgmii_link_cmn_regs),
306516e0f0eaSSwapnil Jakhade };
306616e0f0eaSSwapnil Jakhade
306716e0f0eaSSwapnil Jakhade static struct cdns_torrent_vals sl_usxgmii_xcvr_diag_ln_vals = {
306816e0f0eaSSwapnil Jakhade .reg_pairs = sl_usxgmii_xcvr_diag_ln_regs,
306916e0f0eaSSwapnil Jakhade .num_regs = ARRAY_SIZE(sl_usxgmii_xcvr_diag_ln_regs),
307016e0f0eaSSwapnil Jakhade };
307116e0f0eaSSwapnil Jakhade
307216e0f0eaSSwapnil Jakhade /* Single link USXGMII, 156.25 MHz Ref clk, no SSC */
307316e0f0eaSSwapnil Jakhade static struct cdns_reg_pairs sl_usxgmii_156_25_no_ssc_cmn_regs[] = {
307416e0f0eaSSwapnil Jakhade {0x0014, CMN_SSM_BIAS_TMR},
307516e0f0eaSSwapnil Jakhade {0x0028, CMN_PLLSM0_PLLPRE_TMR},
307616e0f0eaSSwapnil Jakhade {0x00A4, CMN_PLLSM0_PLLLOCK_TMR},
307716e0f0eaSSwapnil Jakhade {0x0028, CMN_PLLSM1_PLLPRE_TMR},
307816e0f0eaSSwapnil Jakhade {0x00A4, CMN_PLLSM1_PLLLOCK_TMR},
307916e0f0eaSSwapnil Jakhade {0x0062, CMN_BGCAL_INIT_TMR},
308016e0f0eaSSwapnil Jakhade {0x0062, CMN_BGCAL_ITER_TMR},
308116e0f0eaSSwapnil Jakhade {0x0014, CMN_IBCAL_INIT_TMR},
308216e0f0eaSSwapnil Jakhade {0x0018, CMN_TXPUCAL_INIT_TMR},
308316e0f0eaSSwapnil Jakhade {0x0005, CMN_TXPUCAL_ITER_TMR},
308416e0f0eaSSwapnil Jakhade {0x0018, CMN_TXPDCAL_INIT_TMR},
308516e0f0eaSSwapnil Jakhade {0x0005, CMN_TXPDCAL_ITER_TMR},
308616e0f0eaSSwapnil Jakhade {0x024A, CMN_RXCAL_INIT_TMR},
308716e0f0eaSSwapnil Jakhade {0x0005, CMN_RXCAL_ITER_TMR},
308816e0f0eaSSwapnil Jakhade {0x000B, CMN_SD_CAL_REFTIM_START},
308916e0f0eaSSwapnil Jakhade {0x0132, CMN_SD_CAL_PLLCNT_START},
309016e0f0eaSSwapnil Jakhade {0x0028, CMN_PDIAG_PLL1_CP_PADJ_M0},
309116e0f0eaSSwapnil Jakhade {0x0014, CMN_PLL0_DSM_FBH_OVRD_M0},
309216e0f0eaSSwapnil Jakhade {0x0014, CMN_PLL1_DSM_FBH_OVRD_M0},
309316e0f0eaSSwapnil Jakhade {0x0005, CMN_PLL0_DSM_FBL_OVRD_M0},
309416e0f0eaSSwapnil Jakhade {0x0005, CMN_PLL1_DSM_FBL_OVRD_M0},
309516e0f0eaSSwapnil Jakhade {0x061B, CMN_PLL0_VCOCAL_INIT_TMR},
309616e0f0eaSSwapnil Jakhade {0x061B, CMN_PLL1_VCOCAL_INIT_TMR},
309716e0f0eaSSwapnil Jakhade {0x0019, CMN_PLL0_VCOCAL_ITER_TMR},
309816e0f0eaSSwapnil Jakhade {0x0019, CMN_PLL1_VCOCAL_ITER_TMR},
309916e0f0eaSSwapnil Jakhade {0x1354, CMN_PLL0_VCOCAL_REFTIM_START},
310016e0f0eaSSwapnil Jakhade {0x1354, CMN_PLL1_VCOCAL_REFTIM_START},
310116e0f0eaSSwapnil Jakhade {0x1354, CMN_PLL0_VCOCAL_PLLCNT_START},
310216e0f0eaSSwapnil Jakhade {0x1354, CMN_PLL1_VCOCAL_PLLCNT_START},
310316e0f0eaSSwapnil Jakhade {0x0003, CMN_PLL0_VCOCAL_TCTRL},
310416e0f0eaSSwapnil Jakhade {0x0003, CMN_PLL1_VCOCAL_TCTRL},
310516e0f0eaSSwapnil Jakhade {0x0138, CMN_PLL0_LOCK_REFCNT_START},
310616e0f0eaSSwapnil Jakhade {0x0138, CMN_PLL1_LOCK_REFCNT_START},
310716e0f0eaSSwapnil Jakhade {0x0138, CMN_PLL0_LOCK_PLLCNT_START},
310816e0f0eaSSwapnil Jakhade {0x0138, CMN_PLL1_LOCK_PLLCNT_START}
310916e0f0eaSSwapnil Jakhade };
311016e0f0eaSSwapnil Jakhade
311116e0f0eaSSwapnil Jakhade static struct cdns_reg_pairs usxgmii_156_25_no_ssc_tx_ln_regs[] = {
311216e0f0eaSSwapnil Jakhade {0x07A2, TX_RCVDET_ST_TMR},
311316e0f0eaSSwapnil Jakhade {0x00F3, TX_PSC_A0},
311416e0f0eaSSwapnil Jakhade {0x04A2, TX_PSC_A2},
311516e0f0eaSSwapnil Jakhade {0x04A2, TX_PSC_A3},
311616e0f0eaSSwapnil Jakhade {0x0000, TX_TXCC_CPOST_MULT_00},
311716e0f0eaSSwapnil Jakhade {0x0000, XCVR_DIAG_PSC_OVRD}
311816e0f0eaSSwapnil Jakhade };
311916e0f0eaSSwapnil Jakhade
312016e0f0eaSSwapnil Jakhade static struct cdns_reg_pairs usxgmii_156_25_no_ssc_rx_ln_regs[] = {
312116e0f0eaSSwapnil Jakhade {0x0014, RX_SDCAL0_INIT_TMR},
312216e0f0eaSSwapnil Jakhade {0x0062, RX_SDCAL0_ITER_TMR},
312316e0f0eaSSwapnil Jakhade {0x0014, RX_SDCAL1_INIT_TMR},
312416e0f0eaSSwapnil Jakhade {0x0062, RX_SDCAL1_ITER_TMR},
312516e0f0eaSSwapnil Jakhade {0x091D, RX_PSC_A0},
312616e0f0eaSSwapnil Jakhade {0x0900, RX_PSC_A2},
312716e0f0eaSSwapnil Jakhade {0x0100, RX_PSC_A3},
312816e0f0eaSSwapnil Jakhade {0x0030, RX_REE_SMGM_CTRL1},
312916e0f0eaSSwapnil Jakhade {0x03C7, RX_REE_GCSM1_EQENM_PH1},
313016e0f0eaSSwapnil Jakhade {0x01C7, RX_REE_GCSM1_EQENM_PH2},
313116e0f0eaSSwapnil Jakhade {0x0000, RX_DIAG_DFE_CTRL},
313216e0f0eaSSwapnil Jakhade {0x0019, RX_REE_TAP1_CLIP},
313316e0f0eaSSwapnil Jakhade {0x0019, RX_REE_TAP2TON_CLIP},
313416e0f0eaSSwapnil Jakhade {0x00B9, RX_DIAG_NQST_CTRL},
313516e0f0eaSSwapnil Jakhade {0x0C21, RX_DIAG_DFE_AMP_TUNE_2},
313616e0f0eaSSwapnil Jakhade {0x0002, RX_DIAG_DFE_AMP_TUNE_3},
313716e0f0eaSSwapnil Jakhade {0x0033, RX_DIAG_PI_RATE},
313816e0f0eaSSwapnil Jakhade {0x0001, RX_DIAG_ACYA},
313916e0f0eaSSwapnil Jakhade {0x018C, RX_CDRLF_CNFG}
314016e0f0eaSSwapnil Jakhade };
314116e0f0eaSSwapnil Jakhade
314216e0f0eaSSwapnil Jakhade static struct cdns_torrent_vals sl_usxgmii_156_25_no_ssc_cmn_vals = {
314316e0f0eaSSwapnil Jakhade .reg_pairs = sl_usxgmii_156_25_no_ssc_cmn_regs,
314416e0f0eaSSwapnil Jakhade .num_regs = ARRAY_SIZE(sl_usxgmii_156_25_no_ssc_cmn_regs),
314516e0f0eaSSwapnil Jakhade };
314616e0f0eaSSwapnil Jakhade
314716e0f0eaSSwapnil Jakhade static struct cdns_torrent_vals usxgmii_156_25_no_ssc_tx_ln_vals = {
314816e0f0eaSSwapnil Jakhade .reg_pairs = usxgmii_156_25_no_ssc_tx_ln_regs,
314916e0f0eaSSwapnil Jakhade .num_regs = ARRAY_SIZE(usxgmii_156_25_no_ssc_tx_ln_regs),
315016e0f0eaSSwapnil Jakhade };
315116e0f0eaSSwapnil Jakhade
315216e0f0eaSSwapnil Jakhade static struct cdns_torrent_vals usxgmii_156_25_no_ssc_rx_ln_vals = {
315316e0f0eaSSwapnil Jakhade .reg_pairs = usxgmii_156_25_no_ssc_rx_ln_regs,
315416e0f0eaSSwapnil Jakhade .num_regs = ARRAY_SIZE(usxgmii_156_25_no_ssc_rx_ln_regs),
315516e0f0eaSSwapnil Jakhade };
315616e0f0eaSSwapnil Jakhade
3157ede775a8SSwapnil Jakhade /* PCIe and DP link configuration */
3158ede775a8SSwapnil Jakhade static struct cdns_reg_pairs pcie_dp_link_cmn_regs[] = {
3159ede775a8SSwapnil Jakhade {0x0003, PHY_PLL_CFG},
3160ede775a8SSwapnil Jakhade {0x0601, CMN_PDIAG_PLL0_CLK_SEL_M0},
3161ede775a8SSwapnil Jakhade {0x0400, CMN_PDIAG_PLL0_CLK_SEL_M1}
3162ede775a8SSwapnil Jakhade };
3163ede775a8SSwapnil Jakhade
3164ede775a8SSwapnil Jakhade static struct cdns_reg_pairs pcie_dp_xcvr_diag_ln_regs[] = {
3165ede775a8SSwapnil Jakhade {0x0000, XCVR_DIAG_HSCLK_SEL},
3166ede775a8SSwapnil Jakhade {0x0001, XCVR_DIAG_HSCLK_DIV},
3167ede775a8SSwapnil Jakhade {0x0012, XCVR_DIAG_PLLDRC_CTRL}
3168ede775a8SSwapnil Jakhade };
3169ede775a8SSwapnil Jakhade
3170ede775a8SSwapnil Jakhade static struct cdns_reg_pairs dp_pcie_xcvr_diag_ln_regs[] = {
3171ede775a8SSwapnil Jakhade {0x0001, XCVR_DIAG_HSCLK_SEL},
3172ede775a8SSwapnil Jakhade {0x0009, XCVR_DIAG_PLLDRC_CTRL}
3173ede775a8SSwapnil Jakhade };
3174ede775a8SSwapnil Jakhade
3175ede775a8SSwapnil Jakhade static struct cdns_torrent_vals pcie_dp_link_cmn_vals = {
3176ede775a8SSwapnil Jakhade .reg_pairs = pcie_dp_link_cmn_regs,
3177ede775a8SSwapnil Jakhade .num_regs = ARRAY_SIZE(pcie_dp_link_cmn_regs),
3178ede775a8SSwapnil Jakhade };
3179ede775a8SSwapnil Jakhade
3180ede775a8SSwapnil Jakhade static struct cdns_torrent_vals pcie_dp_xcvr_diag_ln_vals = {
3181ede775a8SSwapnil Jakhade .reg_pairs = pcie_dp_xcvr_diag_ln_regs,
3182ede775a8SSwapnil Jakhade .num_regs = ARRAY_SIZE(pcie_dp_xcvr_diag_ln_regs),
3183ede775a8SSwapnil Jakhade };
3184ede775a8SSwapnil Jakhade
3185ede775a8SSwapnil Jakhade static struct cdns_torrent_vals dp_pcie_xcvr_diag_ln_vals = {
3186ede775a8SSwapnil Jakhade .reg_pairs = dp_pcie_xcvr_diag_ln_regs,
3187ede775a8SSwapnil Jakhade .num_regs = ARRAY_SIZE(dp_pcie_xcvr_diag_ln_regs),
3188ede775a8SSwapnil Jakhade };
3189ede775a8SSwapnil Jakhade
3190ede775a8SSwapnil Jakhade /* DP Multilink, 100 MHz Ref clk, no SSC */
3191ede775a8SSwapnil Jakhade static struct cdns_reg_pairs dp_100_no_ssc_cmn_regs[] = {
3192ede775a8SSwapnil Jakhade {0x007F, CMN_TXPUCAL_TUNE},
3193ede775a8SSwapnil Jakhade {0x007F, CMN_TXPDCAL_TUNE}
3194ede775a8SSwapnil Jakhade };
3195ede775a8SSwapnil Jakhade
3196ede775a8SSwapnil Jakhade static struct cdns_reg_pairs dp_100_no_ssc_tx_ln_regs[] = {
3197ede775a8SSwapnil Jakhade {0x00FB, TX_PSC_A0},
3198ede775a8SSwapnil Jakhade {0x04AA, TX_PSC_A2},
3199ede775a8SSwapnil Jakhade {0x04AA, TX_PSC_A3},
3200ede775a8SSwapnil Jakhade {0x000F, XCVR_DIAG_BIDI_CTRL}
3201ede775a8SSwapnil Jakhade };
3202ede775a8SSwapnil Jakhade
3203ede775a8SSwapnil Jakhade static struct cdns_reg_pairs dp_100_no_ssc_rx_ln_regs[] = {
3204ede775a8SSwapnil Jakhade {0x0000, RX_PSC_A0},
3205ede775a8SSwapnil Jakhade {0x0000, RX_PSC_A2},
3206ede775a8SSwapnil Jakhade {0x0000, RX_PSC_A3},
3207ede775a8SSwapnil Jakhade {0x0000, RX_PSC_CAL},
3208ede775a8SSwapnil Jakhade {0x0000, RX_REE_GCSM1_CTRL},
3209ede775a8SSwapnil Jakhade {0x0000, RX_REE_GCSM2_CTRL},
3210ede775a8SSwapnil Jakhade {0x0000, RX_REE_PERGCSM_CTRL}
3211ede775a8SSwapnil Jakhade };
3212ede775a8SSwapnil Jakhade
3213ede775a8SSwapnil Jakhade static struct cdns_torrent_vals dp_100_no_ssc_cmn_vals = {
3214ede775a8SSwapnil Jakhade .reg_pairs = dp_100_no_ssc_cmn_regs,
3215ede775a8SSwapnil Jakhade .num_regs = ARRAY_SIZE(dp_100_no_ssc_cmn_regs),
3216ede775a8SSwapnil Jakhade };
3217ede775a8SSwapnil Jakhade
3218ede775a8SSwapnil Jakhade static struct cdns_torrent_vals dp_100_no_ssc_tx_ln_vals = {
3219ede775a8SSwapnil Jakhade .reg_pairs = dp_100_no_ssc_tx_ln_regs,
3220ede775a8SSwapnil Jakhade .num_regs = ARRAY_SIZE(dp_100_no_ssc_tx_ln_regs),
3221ede775a8SSwapnil Jakhade };
3222ede775a8SSwapnil Jakhade
3223ede775a8SSwapnil Jakhade static struct cdns_torrent_vals dp_100_no_ssc_rx_ln_vals = {
3224ede775a8SSwapnil Jakhade .reg_pairs = dp_100_no_ssc_rx_ln_regs,
3225ede775a8SSwapnil Jakhade .num_regs = ARRAY_SIZE(dp_100_no_ssc_rx_ln_regs),
3226ede775a8SSwapnil Jakhade };
3227ede775a8SSwapnil Jakhade
3228da055e55SSwapnil Jakhade /* Single DisplayPort(DP) link configuration */
3229da055e55SSwapnil Jakhade static struct cdns_reg_pairs sl_dp_link_cmn_regs[] = {
3230da055e55SSwapnil Jakhade {0x0000, PHY_PLL_CFG},
3231da055e55SSwapnil Jakhade };
3232da055e55SSwapnil Jakhade
3233da055e55SSwapnil Jakhade static struct cdns_reg_pairs sl_dp_xcvr_diag_ln_regs[] = {
3234da055e55SSwapnil Jakhade {0x0000, XCVR_DIAG_HSCLK_SEL},
3235da055e55SSwapnil Jakhade {0x0001, XCVR_DIAG_PLLDRC_CTRL}
3236da055e55SSwapnil Jakhade };
3237da055e55SSwapnil Jakhade
3238da055e55SSwapnil Jakhade static struct cdns_torrent_vals sl_dp_link_cmn_vals = {
3239da055e55SSwapnil Jakhade .reg_pairs = sl_dp_link_cmn_regs,
3240da055e55SSwapnil Jakhade .num_regs = ARRAY_SIZE(sl_dp_link_cmn_regs),
3241da055e55SSwapnil Jakhade };
3242da055e55SSwapnil Jakhade
3243da055e55SSwapnil Jakhade static struct cdns_torrent_vals sl_dp_xcvr_diag_ln_vals = {
3244da055e55SSwapnil Jakhade .reg_pairs = sl_dp_xcvr_diag_ln_regs,
3245da055e55SSwapnil Jakhade .num_regs = ARRAY_SIZE(sl_dp_xcvr_diag_ln_regs),
3246da055e55SSwapnil Jakhade };
3247da055e55SSwapnil Jakhade
3248da055e55SSwapnil Jakhade /* Single DP, 19.2 MHz Ref clk, no SSC */
3249da055e55SSwapnil Jakhade static struct cdns_reg_pairs sl_dp_19_2_no_ssc_cmn_regs[] = {
3250da055e55SSwapnil Jakhade {0x0014, CMN_SSM_BIAS_TMR},
3251da055e55SSwapnil Jakhade {0x0027, CMN_PLLSM0_PLLPRE_TMR},
3252da055e55SSwapnil Jakhade {0x00A1, CMN_PLLSM0_PLLLOCK_TMR},
3253da055e55SSwapnil Jakhade {0x0027, CMN_PLLSM1_PLLPRE_TMR},
3254da055e55SSwapnil Jakhade {0x00A1, CMN_PLLSM1_PLLLOCK_TMR},
3255da055e55SSwapnil Jakhade {0x0060, CMN_BGCAL_INIT_TMR},
3256da055e55SSwapnil Jakhade {0x0060, CMN_BGCAL_ITER_TMR},
3257da055e55SSwapnil Jakhade {0x0014, CMN_IBCAL_INIT_TMR},
3258da055e55SSwapnil Jakhade {0x0018, CMN_TXPUCAL_INIT_TMR},
3259da055e55SSwapnil Jakhade {0x0005, CMN_TXPUCAL_ITER_TMR},
3260da055e55SSwapnil Jakhade {0x0018, CMN_TXPDCAL_INIT_TMR},
3261da055e55SSwapnil Jakhade {0x0005, CMN_TXPDCAL_ITER_TMR},
3262da055e55SSwapnil Jakhade {0x0240, CMN_RXCAL_INIT_TMR},
3263da055e55SSwapnil Jakhade {0x0005, CMN_RXCAL_ITER_TMR},
3264da055e55SSwapnil Jakhade {0x0002, CMN_SD_CAL_INIT_TMR},
3265da055e55SSwapnil Jakhade {0x0002, CMN_SD_CAL_ITER_TMR},
3266da055e55SSwapnil Jakhade {0x000B, CMN_SD_CAL_REFTIM_START},
3267da055e55SSwapnil Jakhade {0x0137, CMN_SD_CAL_PLLCNT_START},
3268da055e55SSwapnil Jakhade {0x0509, CMN_PDIAG_PLL0_CP_PADJ_M0},
3269da055e55SSwapnil Jakhade {0x0F00, CMN_PDIAG_PLL0_CP_IADJ_M0},
3270da055e55SSwapnil Jakhade {0x0F08, CMN_PDIAG_PLL0_FILT_PADJ_M0},
3271da055e55SSwapnil Jakhade {0x0004, CMN_PLL0_DSM_DIAG_M0},
3272da055e55SSwapnil Jakhade {0x0509, CMN_PDIAG_PLL1_CP_PADJ_M0},
3273da055e55SSwapnil Jakhade {0x0F00, CMN_PDIAG_PLL1_CP_IADJ_M0},
3274da055e55SSwapnil Jakhade {0x0F08, CMN_PDIAG_PLL1_FILT_PADJ_M0},
3275da055e55SSwapnil Jakhade {0x0004, CMN_PLL1_DSM_DIAG_M0},
3276da055e55SSwapnil Jakhade {0x00C0, CMN_PLL0_VCOCAL_INIT_TMR},
3277da055e55SSwapnil Jakhade {0x0004, CMN_PLL0_VCOCAL_ITER_TMR},
3278da055e55SSwapnil Jakhade {0x00C0, CMN_PLL1_VCOCAL_INIT_TMR},
3279da055e55SSwapnil Jakhade {0x0004, CMN_PLL1_VCOCAL_ITER_TMR},
3280da055e55SSwapnil Jakhade {0x0260, CMN_PLL0_VCOCAL_REFTIM_START},
3281da055e55SSwapnil Jakhade {0x0003, CMN_PLL0_VCOCAL_TCTRL},
3282da055e55SSwapnil Jakhade {0x0260, CMN_PLL1_VCOCAL_REFTIM_START},
3283da055e55SSwapnil Jakhade {0x0003, CMN_PLL1_VCOCAL_TCTRL}
3284da055e55SSwapnil Jakhade };
3285da055e55SSwapnil Jakhade
3286da055e55SSwapnil Jakhade static struct cdns_reg_pairs sl_dp_19_2_no_ssc_tx_ln_regs[] = {
3287da055e55SSwapnil Jakhade {0x0780, TX_RCVDET_ST_TMR},
3288da055e55SSwapnil Jakhade {0x00FB, TX_PSC_A0},
3289da055e55SSwapnil Jakhade {0x04AA, TX_PSC_A2},
3290da055e55SSwapnil Jakhade {0x04AA, TX_PSC_A3},
3291da055e55SSwapnil Jakhade {0x000F, XCVR_DIAG_BIDI_CTRL}
3292da055e55SSwapnil Jakhade };
3293da055e55SSwapnil Jakhade
3294da055e55SSwapnil Jakhade static struct cdns_reg_pairs sl_dp_19_2_no_ssc_rx_ln_regs[] = {
3295da055e55SSwapnil Jakhade {0x0000, RX_PSC_A0},
3296da055e55SSwapnil Jakhade {0x0000, RX_PSC_A2},
3297da055e55SSwapnil Jakhade {0x0000, RX_PSC_A3},
3298da055e55SSwapnil Jakhade {0x0000, RX_PSC_CAL},
3299da055e55SSwapnil Jakhade {0x0000, RX_REE_GCSM1_CTRL},
3300da055e55SSwapnil Jakhade {0x0000, RX_REE_GCSM2_CTRL},
3301da055e55SSwapnil Jakhade {0x0000, RX_REE_PERGCSM_CTRL}
3302da055e55SSwapnil Jakhade };
3303da055e55SSwapnil Jakhade
3304da055e55SSwapnil Jakhade static struct cdns_torrent_vals sl_dp_19_2_no_ssc_cmn_vals = {
3305da055e55SSwapnil Jakhade .reg_pairs = sl_dp_19_2_no_ssc_cmn_regs,
3306da055e55SSwapnil Jakhade .num_regs = ARRAY_SIZE(sl_dp_19_2_no_ssc_cmn_regs),
3307da055e55SSwapnil Jakhade };
3308da055e55SSwapnil Jakhade
3309da055e55SSwapnil Jakhade static struct cdns_torrent_vals sl_dp_19_2_no_ssc_tx_ln_vals = {
3310da055e55SSwapnil Jakhade .reg_pairs = sl_dp_19_2_no_ssc_tx_ln_regs,
3311da055e55SSwapnil Jakhade .num_regs = ARRAY_SIZE(sl_dp_19_2_no_ssc_tx_ln_regs),
3312da055e55SSwapnil Jakhade };
3313da055e55SSwapnil Jakhade
3314da055e55SSwapnil Jakhade static struct cdns_torrent_vals sl_dp_19_2_no_ssc_rx_ln_vals = {
3315da055e55SSwapnil Jakhade .reg_pairs = sl_dp_19_2_no_ssc_rx_ln_regs,
3316da055e55SSwapnil Jakhade .num_regs = ARRAY_SIZE(sl_dp_19_2_no_ssc_rx_ln_regs),
3317da055e55SSwapnil Jakhade };
3318da055e55SSwapnil Jakhade
3319da055e55SSwapnil Jakhade /* Single DP, 25 MHz Ref clk, no SSC */
3320da055e55SSwapnil Jakhade static struct cdns_reg_pairs sl_dp_25_no_ssc_cmn_regs[] = {
3321da055e55SSwapnil Jakhade {0x0019, CMN_SSM_BIAS_TMR},
3322da055e55SSwapnil Jakhade {0x0032, CMN_PLLSM0_PLLPRE_TMR},
3323da055e55SSwapnil Jakhade {0x00D1, CMN_PLLSM0_PLLLOCK_TMR},
3324da055e55SSwapnil Jakhade {0x0032, CMN_PLLSM1_PLLPRE_TMR},
3325da055e55SSwapnil Jakhade {0x00D1, CMN_PLLSM1_PLLLOCK_TMR},
3326da055e55SSwapnil Jakhade {0x007D, CMN_BGCAL_INIT_TMR},
3327da055e55SSwapnil Jakhade {0x007D, CMN_BGCAL_ITER_TMR},
3328da055e55SSwapnil Jakhade {0x0019, CMN_IBCAL_INIT_TMR},
3329da055e55SSwapnil Jakhade {0x001E, CMN_TXPUCAL_INIT_TMR},
3330da055e55SSwapnil Jakhade {0x0006, CMN_TXPUCAL_ITER_TMR},
3331da055e55SSwapnil Jakhade {0x001E, CMN_TXPDCAL_INIT_TMR},
3332da055e55SSwapnil Jakhade {0x0006, CMN_TXPDCAL_ITER_TMR},
3333da055e55SSwapnil Jakhade {0x02EE, CMN_RXCAL_INIT_TMR},
3334da055e55SSwapnil Jakhade {0x0006, CMN_RXCAL_ITER_TMR},
3335da055e55SSwapnil Jakhade {0x0002, CMN_SD_CAL_INIT_TMR},
3336da055e55SSwapnil Jakhade {0x0002, CMN_SD_CAL_ITER_TMR},
3337da055e55SSwapnil Jakhade {0x000E, CMN_SD_CAL_REFTIM_START},
3338da055e55SSwapnil Jakhade {0x012B, CMN_SD_CAL_PLLCNT_START},
3339da055e55SSwapnil Jakhade {0x0509, CMN_PDIAG_PLL0_CP_PADJ_M0},
3340da055e55SSwapnil Jakhade {0x0F00, CMN_PDIAG_PLL0_CP_IADJ_M0},
3341da055e55SSwapnil Jakhade {0x0F08, CMN_PDIAG_PLL0_FILT_PADJ_M0},
3342da055e55SSwapnil Jakhade {0x0004, CMN_PLL0_DSM_DIAG_M0},
3343da055e55SSwapnil Jakhade {0x0509, CMN_PDIAG_PLL1_CP_PADJ_M0},
3344da055e55SSwapnil Jakhade {0x0F00, CMN_PDIAG_PLL1_CP_IADJ_M0},
3345da055e55SSwapnil Jakhade {0x0F08, CMN_PDIAG_PLL1_FILT_PADJ_M0},
3346da055e55SSwapnil Jakhade {0x0004, CMN_PLL1_DSM_DIAG_M0},
3347da055e55SSwapnil Jakhade {0x00FA, CMN_PLL0_VCOCAL_INIT_TMR},
3348da055e55SSwapnil Jakhade {0x0004, CMN_PLL0_VCOCAL_ITER_TMR},
3349da055e55SSwapnil Jakhade {0x00FA, CMN_PLL1_VCOCAL_INIT_TMR},
3350da055e55SSwapnil Jakhade {0x0004, CMN_PLL1_VCOCAL_ITER_TMR},
3351da055e55SSwapnil Jakhade {0x0317, CMN_PLL0_VCOCAL_REFTIM_START},
3352da055e55SSwapnil Jakhade {0x0003, CMN_PLL0_VCOCAL_TCTRL},
3353da055e55SSwapnil Jakhade {0x0317, CMN_PLL1_VCOCAL_REFTIM_START},
3354da055e55SSwapnil Jakhade {0x0003, CMN_PLL1_VCOCAL_TCTRL}
3355da055e55SSwapnil Jakhade };
3356da055e55SSwapnil Jakhade
3357da055e55SSwapnil Jakhade static struct cdns_reg_pairs sl_dp_25_no_ssc_tx_ln_regs[] = {
3358da055e55SSwapnil Jakhade {0x09C4, TX_RCVDET_ST_TMR},
3359da055e55SSwapnil Jakhade {0x00FB, TX_PSC_A0},
3360da055e55SSwapnil Jakhade {0x04AA, TX_PSC_A2},
3361da055e55SSwapnil Jakhade {0x04AA, TX_PSC_A3},
3362da055e55SSwapnil Jakhade {0x000F, XCVR_DIAG_BIDI_CTRL}
3363da055e55SSwapnil Jakhade };
3364da055e55SSwapnil Jakhade
3365da055e55SSwapnil Jakhade static struct cdns_reg_pairs sl_dp_25_no_ssc_rx_ln_regs[] = {
3366da055e55SSwapnil Jakhade {0x0000, RX_PSC_A0},
3367da055e55SSwapnil Jakhade {0x0000, RX_PSC_A2},
3368da055e55SSwapnil Jakhade {0x0000, RX_PSC_A3},
3369da055e55SSwapnil Jakhade {0x0000, RX_PSC_CAL},
3370da055e55SSwapnil Jakhade {0x0000, RX_REE_GCSM1_CTRL},
3371da055e55SSwapnil Jakhade {0x0000, RX_REE_GCSM2_CTRL},
3372da055e55SSwapnil Jakhade {0x0000, RX_REE_PERGCSM_CTRL}
3373da055e55SSwapnil Jakhade };
3374da055e55SSwapnil Jakhade
3375da055e55SSwapnil Jakhade static struct cdns_torrent_vals sl_dp_25_no_ssc_cmn_vals = {
3376da055e55SSwapnil Jakhade .reg_pairs = sl_dp_25_no_ssc_cmn_regs,
3377da055e55SSwapnil Jakhade .num_regs = ARRAY_SIZE(sl_dp_25_no_ssc_cmn_regs),
3378da055e55SSwapnil Jakhade };
3379da055e55SSwapnil Jakhade
3380da055e55SSwapnil Jakhade static struct cdns_torrent_vals sl_dp_25_no_ssc_tx_ln_vals = {
3381da055e55SSwapnil Jakhade .reg_pairs = sl_dp_25_no_ssc_tx_ln_regs,
3382da055e55SSwapnil Jakhade .num_regs = ARRAY_SIZE(sl_dp_25_no_ssc_tx_ln_regs),
3383da055e55SSwapnil Jakhade };
3384da055e55SSwapnil Jakhade
3385da055e55SSwapnil Jakhade static struct cdns_torrent_vals sl_dp_25_no_ssc_rx_ln_vals = {
3386da055e55SSwapnil Jakhade .reg_pairs = sl_dp_25_no_ssc_rx_ln_regs,
3387da055e55SSwapnil Jakhade .num_regs = ARRAY_SIZE(sl_dp_25_no_ssc_rx_ln_regs),
3388da055e55SSwapnil Jakhade };
3389da055e55SSwapnil Jakhade
33901cc45515SSwapnil Jakhade /* Single DP, 100 MHz Ref clk, no SSC */
33911cc45515SSwapnil Jakhade static struct cdns_reg_pairs sl_dp_100_no_ssc_cmn_regs[] = {
33921cc45515SSwapnil Jakhade {0x0003, CMN_PLL0_VCOCAL_TCTRL},
33931cc45515SSwapnil Jakhade {0x0003, CMN_PLL1_VCOCAL_TCTRL}
33941cc45515SSwapnil Jakhade };
33951cc45515SSwapnil Jakhade
33961cc45515SSwapnil Jakhade static struct cdns_reg_pairs sl_dp_100_no_ssc_tx_ln_regs[] = {
33971cc45515SSwapnil Jakhade {0x00FB, TX_PSC_A0},
33981cc45515SSwapnil Jakhade {0x04AA, TX_PSC_A2},
33991cc45515SSwapnil Jakhade {0x04AA, TX_PSC_A3},
34001cc45515SSwapnil Jakhade {0x000F, XCVR_DIAG_BIDI_CTRL}
34011cc45515SSwapnil Jakhade };
34021cc45515SSwapnil Jakhade
34031cc45515SSwapnil Jakhade static struct cdns_reg_pairs sl_dp_100_no_ssc_rx_ln_regs[] = {
34041cc45515SSwapnil Jakhade {0x0000, RX_PSC_A0},
34051cc45515SSwapnil Jakhade {0x0000, RX_PSC_A2},
34061cc45515SSwapnil Jakhade {0x0000, RX_PSC_A3},
34071cc45515SSwapnil Jakhade {0x0000, RX_PSC_CAL},
34081cc45515SSwapnil Jakhade {0x0000, RX_REE_GCSM1_CTRL},
34091cc45515SSwapnil Jakhade {0x0000, RX_REE_GCSM2_CTRL},
34101cc45515SSwapnil Jakhade {0x0000, RX_REE_PERGCSM_CTRL}
34111cc45515SSwapnil Jakhade };
34121cc45515SSwapnil Jakhade
34131cc45515SSwapnil Jakhade static struct cdns_torrent_vals sl_dp_100_no_ssc_cmn_vals = {
34141cc45515SSwapnil Jakhade .reg_pairs = sl_dp_100_no_ssc_cmn_regs,
34151cc45515SSwapnil Jakhade .num_regs = ARRAY_SIZE(sl_dp_100_no_ssc_cmn_regs),
34161cc45515SSwapnil Jakhade };
34171cc45515SSwapnil Jakhade
34181cc45515SSwapnil Jakhade static struct cdns_torrent_vals sl_dp_100_no_ssc_tx_ln_vals = {
34191cc45515SSwapnil Jakhade .reg_pairs = sl_dp_100_no_ssc_tx_ln_regs,
34201cc45515SSwapnil Jakhade .num_regs = ARRAY_SIZE(sl_dp_100_no_ssc_tx_ln_regs),
34211cc45515SSwapnil Jakhade };
34221cc45515SSwapnil Jakhade
34231cc45515SSwapnil Jakhade static struct cdns_torrent_vals sl_dp_100_no_ssc_rx_ln_vals = {
34241cc45515SSwapnil Jakhade .reg_pairs = sl_dp_100_no_ssc_rx_ln_regs,
34251cc45515SSwapnil Jakhade .num_regs = ARRAY_SIZE(sl_dp_100_no_ssc_rx_ln_regs),
34261cc45515SSwapnil Jakhade };
34271cc45515SSwapnil Jakhade
34286fd428f7SSwapnil Jakhade /* USB and SGMII/QSGMII link configuration */
34296fd428f7SSwapnil Jakhade static struct cdns_reg_pairs usb_sgmii_link_cmn_regs[] = {
34306fd428f7SSwapnil Jakhade {0x0002, PHY_PLL_CFG},
34316fd428f7SSwapnil Jakhade {0x8600, CMN_PDIAG_PLL0_CLK_SEL_M0},
34326fd428f7SSwapnil Jakhade {0x0601, CMN_PDIAG_PLL1_CLK_SEL_M0}
34336fd428f7SSwapnil Jakhade };
34346fd428f7SSwapnil Jakhade
34356fd428f7SSwapnil Jakhade static struct cdns_reg_pairs usb_sgmii_xcvr_diag_ln_regs[] = {
34366fd428f7SSwapnil Jakhade {0x0000, XCVR_DIAG_HSCLK_SEL},
34376fd428f7SSwapnil Jakhade {0x0001, XCVR_DIAG_HSCLK_DIV},
34386fd428f7SSwapnil Jakhade {0x0041, XCVR_DIAG_PLLDRC_CTRL}
34396fd428f7SSwapnil Jakhade };
34406fd428f7SSwapnil Jakhade
34416fd428f7SSwapnil Jakhade static struct cdns_reg_pairs sgmii_usb_xcvr_diag_ln_regs[] = {
34426fd428f7SSwapnil Jakhade {0x0011, XCVR_DIAG_HSCLK_SEL},
34436fd428f7SSwapnil Jakhade {0x0003, XCVR_DIAG_HSCLK_DIV},
34446fd428f7SSwapnil Jakhade {0x009B, XCVR_DIAG_PLLDRC_CTRL}
34456fd428f7SSwapnil Jakhade };
34466fd428f7SSwapnil Jakhade
34476fd428f7SSwapnil Jakhade static struct cdns_torrent_vals usb_sgmii_link_cmn_vals = {
34486fd428f7SSwapnil Jakhade .reg_pairs = usb_sgmii_link_cmn_regs,
34496fd428f7SSwapnil Jakhade .num_regs = ARRAY_SIZE(usb_sgmii_link_cmn_regs),
34506fd428f7SSwapnil Jakhade };
34516fd428f7SSwapnil Jakhade
34526fd428f7SSwapnil Jakhade static struct cdns_torrent_vals usb_sgmii_xcvr_diag_ln_vals = {
34536fd428f7SSwapnil Jakhade .reg_pairs = usb_sgmii_xcvr_diag_ln_regs,
34546fd428f7SSwapnil Jakhade .num_regs = ARRAY_SIZE(usb_sgmii_xcvr_diag_ln_regs),
34556fd428f7SSwapnil Jakhade };
34566fd428f7SSwapnil Jakhade
34576fd428f7SSwapnil Jakhade static struct cdns_torrent_vals sgmii_usb_xcvr_diag_ln_vals = {
34586fd428f7SSwapnil Jakhade .reg_pairs = sgmii_usb_xcvr_diag_ln_regs,
34596fd428f7SSwapnil Jakhade .num_regs = ARRAY_SIZE(sgmii_usb_xcvr_diag_ln_regs),
34606fd428f7SSwapnil Jakhade };
34616fd428f7SSwapnil Jakhade
34624acea473SSwapnil Jakhade /* PCIe and USB Unique SSC link configuration */
34634acea473SSwapnil Jakhade static struct cdns_reg_pairs pcie_usb_link_cmn_regs[] = {
34644acea473SSwapnil Jakhade {0x0003, PHY_PLL_CFG},
34654acea473SSwapnil Jakhade {0x0601, CMN_PDIAG_PLL0_CLK_SEL_M0},
34664acea473SSwapnil Jakhade {0x0400, CMN_PDIAG_PLL0_CLK_SEL_M1},
34674acea473SSwapnil Jakhade {0x8600, CMN_PDIAG_PLL1_CLK_SEL_M0}
34684acea473SSwapnil Jakhade };
34694acea473SSwapnil Jakhade
34704acea473SSwapnil Jakhade static struct cdns_reg_pairs pcie_usb_xcvr_diag_ln_regs[] = {
34714acea473SSwapnil Jakhade {0x0000, XCVR_DIAG_HSCLK_SEL},
34724acea473SSwapnil Jakhade {0x0001, XCVR_DIAG_HSCLK_DIV},
34734acea473SSwapnil Jakhade {0x0012, XCVR_DIAG_PLLDRC_CTRL}
34744acea473SSwapnil Jakhade };
34754acea473SSwapnil Jakhade
34764acea473SSwapnil Jakhade static struct cdns_reg_pairs usb_pcie_xcvr_diag_ln_regs[] = {
34774acea473SSwapnil Jakhade {0x0011, XCVR_DIAG_HSCLK_SEL},
34784acea473SSwapnil Jakhade {0x0001, XCVR_DIAG_HSCLK_DIV},
34794acea473SSwapnil Jakhade {0x00C9, XCVR_DIAG_PLLDRC_CTRL}
34804acea473SSwapnil Jakhade };
34814acea473SSwapnil Jakhade
34824acea473SSwapnil Jakhade static struct cdns_torrent_vals pcie_usb_link_cmn_vals = {
34834acea473SSwapnil Jakhade .reg_pairs = pcie_usb_link_cmn_regs,
34844acea473SSwapnil Jakhade .num_regs = ARRAY_SIZE(pcie_usb_link_cmn_regs),
34854acea473SSwapnil Jakhade };
34864acea473SSwapnil Jakhade
34874acea473SSwapnil Jakhade static struct cdns_torrent_vals pcie_usb_xcvr_diag_ln_vals = {
34884acea473SSwapnil Jakhade .reg_pairs = pcie_usb_xcvr_diag_ln_regs,
34894acea473SSwapnil Jakhade .num_regs = ARRAY_SIZE(pcie_usb_xcvr_diag_ln_regs),
34904acea473SSwapnil Jakhade };
34914acea473SSwapnil Jakhade
34924acea473SSwapnil Jakhade static struct cdns_torrent_vals usb_pcie_xcvr_diag_ln_vals = {
34934acea473SSwapnil Jakhade .reg_pairs = usb_pcie_xcvr_diag_ln_regs,
34944acea473SSwapnil Jakhade .num_regs = ARRAY_SIZE(usb_pcie_xcvr_diag_ln_regs),
34954acea473SSwapnil Jakhade };
34964acea473SSwapnil Jakhade
34974acea473SSwapnil Jakhade /* USB 100 MHz Ref clk, internal SSC */
34984acea473SSwapnil Jakhade static struct cdns_reg_pairs usb_100_int_ssc_cmn_regs[] = {
34994acea473SSwapnil Jakhade {0x0004, CMN_PLL0_DSM_DIAG_M0},
35004acea473SSwapnil Jakhade {0x0004, CMN_PLL0_DSM_DIAG_M1},
35014acea473SSwapnil Jakhade {0x0004, CMN_PLL1_DSM_DIAG_M0},
35024acea473SSwapnil Jakhade {0x0509, CMN_PDIAG_PLL0_CP_PADJ_M0},
35034acea473SSwapnil Jakhade {0x0509, CMN_PDIAG_PLL0_CP_PADJ_M1},
35044acea473SSwapnil Jakhade {0x0509, CMN_PDIAG_PLL1_CP_PADJ_M0},
35054acea473SSwapnil Jakhade {0x0F00, CMN_PDIAG_PLL0_CP_IADJ_M0},
35064acea473SSwapnil Jakhade {0x0F00, CMN_PDIAG_PLL0_CP_IADJ_M1},
35074acea473SSwapnil Jakhade {0x0F00, CMN_PDIAG_PLL1_CP_IADJ_M0},
35084acea473SSwapnil Jakhade {0x0F08, CMN_PDIAG_PLL0_FILT_PADJ_M0},
35094acea473SSwapnil Jakhade {0x0F08, CMN_PDIAG_PLL0_FILT_PADJ_M1},
35104acea473SSwapnil Jakhade {0x0F08, CMN_PDIAG_PLL1_FILT_PADJ_M0},
35114acea473SSwapnil Jakhade {0x0064, CMN_PLL0_INTDIV_M0},
35124acea473SSwapnil Jakhade {0x0050, CMN_PLL0_INTDIV_M1},
35134acea473SSwapnil Jakhade {0x0064, CMN_PLL1_INTDIV_M0},
35144acea473SSwapnil Jakhade {0x0002, CMN_PLL0_FRACDIVH_M0},
35154acea473SSwapnil Jakhade {0x0002, CMN_PLL0_FRACDIVH_M1},
35164acea473SSwapnil Jakhade {0x0002, CMN_PLL1_FRACDIVH_M0},
35174acea473SSwapnil Jakhade {0x0044, CMN_PLL0_HIGH_THR_M0},
35184acea473SSwapnil Jakhade {0x0036, CMN_PLL0_HIGH_THR_M1},
35194acea473SSwapnil Jakhade {0x0044, CMN_PLL1_HIGH_THR_M0},
35204acea473SSwapnil Jakhade {0x0002, CMN_PDIAG_PLL0_CTRL_M0},
35214acea473SSwapnil Jakhade {0x0002, CMN_PDIAG_PLL0_CTRL_M1},
35224acea473SSwapnil Jakhade {0x0002, CMN_PDIAG_PLL1_CTRL_M0},
35234acea473SSwapnil Jakhade {0x0001, CMN_PLL0_SS_CTRL1_M0},
35244acea473SSwapnil Jakhade {0x0001, CMN_PLL0_SS_CTRL1_M1},
35254acea473SSwapnil Jakhade {0x0001, CMN_PLL1_SS_CTRL1_M0},
35264acea473SSwapnil Jakhade {0x011B, CMN_PLL0_SS_CTRL2_M0},
35274acea473SSwapnil Jakhade {0x011B, CMN_PLL0_SS_CTRL2_M1},
35284acea473SSwapnil Jakhade {0x011B, CMN_PLL1_SS_CTRL2_M0},
35294acea473SSwapnil Jakhade {0x006E, CMN_PLL0_SS_CTRL3_M0},
35304acea473SSwapnil Jakhade {0x0058, CMN_PLL0_SS_CTRL3_M1},
35314acea473SSwapnil Jakhade {0x006E, CMN_PLL1_SS_CTRL3_M0},
35324acea473SSwapnil Jakhade {0x000E, CMN_PLL0_SS_CTRL4_M0},
35334acea473SSwapnil Jakhade {0x0012, CMN_PLL0_SS_CTRL4_M1},
35344acea473SSwapnil Jakhade {0x000E, CMN_PLL1_SS_CTRL4_M0},
35354acea473SSwapnil Jakhade {0x0C5E, CMN_PLL0_VCOCAL_REFTIM_START},
35364acea473SSwapnil Jakhade {0x0C5E, CMN_PLL1_VCOCAL_REFTIM_START},
35374acea473SSwapnil Jakhade {0x0C56, CMN_PLL0_VCOCAL_PLLCNT_START},
35384acea473SSwapnil Jakhade {0x0C56, CMN_PLL1_VCOCAL_PLLCNT_START},
35394acea473SSwapnil Jakhade {0x00C7, CMN_PLL0_LOCK_REFCNT_START},
35404acea473SSwapnil Jakhade {0x00C7, CMN_PLL1_LOCK_REFCNT_START},
35414acea473SSwapnil Jakhade {0x00C7, CMN_PLL0_LOCK_PLLCNT_START},
35424acea473SSwapnil Jakhade {0x00C7, CMN_PLL1_LOCK_PLLCNT_START},
35434acea473SSwapnil Jakhade {0x0005, CMN_PLL0_LOCK_PLLCNT_THR},
35444acea473SSwapnil Jakhade {0x0005, CMN_PLL1_LOCK_PLLCNT_THR},
35454acea473SSwapnil Jakhade {0x8200, CMN_CDIAG_CDB_PWRI_OVRD},
3546ed9e07f8SSwapnil Jakhade {0x8200, CMN_CDIAG_XCVRC_PWRI_OVRD},
3547ed9e07f8SSwapnil Jakhade {0x007F, CMN_TXPUCAL_TUNE},
3548ed9e07f8SSwapnil Jakhade {0x007F, CMN_TXPDCAL_TUNE}
35494acea473SSwapnil Jakhade };
35504acea473SSwapnil Jakhade
35514acea473SSwapnil Jakhade static struct cdns_torrent_vals usb_100_int_ssc_cmn_vals = {
35524acea473SSwapnil Jakhade .reg_pairs = usb_100_int_ssc_cmn_regs,
35534acea473SSwapnil Jakhade .num_regs = ARRAY_SIZE(usb_100_int_ssc_cmn_regs),
35544acea473SSwapnil Jakhade };
35554acea473SSwapnil Jakhade
35569855d84bSSwapnil Jakhade /* Single USB link configuration */
35579855d84bSSwapnil Jakhade static struct cdns_reg_pairs sl_usb_link_cmn_regs[] = {
35589855d84bSSwapnil Jakhade {0x0000, PHY_PLL_CFG},
35599855d84bSSwapnil Jakhade {0x8600, CMN_PDIAG_PLL0_CLK_SEL_M0}
35609855d84bSSwapnil Jakhade };
35619855d84bSSwapnil Jakhade
35629855d84bSSwapnil Jakhade static struct cdns_reg_pairs sl_usb_xcvr_diag_ln_regs[] = {
35639855d84bSSwapnil Jakhade {0x0000, XCVR_DIAG_HSCLK_SEL},
35649855d84bSSwapnil Jakhade {0x0001, XCVR_DIAG_HSCLK_DIV},
35659855d84bSSwapnil Jakhade {0x0041, XCVR_DIAG_PLLDRC_CTRL}
35669855d84bSSwapnil Jakhade };
35679855d84bSSwapnil Jakhade
35689855d84bSSwapnil Jakhade static struct cdns_torrent_vals sl_usb_link_cmn_vals = {
35699855d84bSSwapnil Jakhade .reg_pairs = sl_usb_link_cmn_regs,
35709855d84bSSwapnil Jakhade .num_regs = ARRAY_SIZE(sl_usb_link_cmn_regs),
35719855d84bSSwapnil Jakhade };
35729855d84bSSwapnil Jakhade
35739855d84bSSwapnil Jakhade static struct cdns_torrent_vals sl_usb_xcvr_diag_ln_vals = {
35749855d84bSSwapnil Jakhade .reg_pairs = sl_usb_xcvr_diag_ln_regs,
35759855d84bSSwapnil Jakhade .num_regs = ARRAY_SIZE(sl_usb_xcvr_diag_ln_regs),
35769855d84bSSwapnil Jakhade };
35779855d84bSSwapnil Jakhade
35789855d84bSSwapnil Jakhade /* USB PHY PCS common configuration */
35799855d84bSSwapnil Jakhade static struct cdns_reg_pairs usb_phy_pcs_cmn_regs[] = {
35809855d84bSSwapnil Jakhade {0x0A0A, PHY_PIPE_USB3_GEN2_PRE_CFG0},
35819855d84bSSwapnil Jakhade {0x1000, PHY_PIPE_USB3_GEN2_POST_CFG0},
35829855d84bSSwapnil Jakhade {0x0010, PHY_PIPE_USB3_GEN2_POST_CFG1}
35839855d84bSSwapnil Jakhade };
35849855d84bSSwapnil Jakhade
35859855d84bSSwapnil Jakhade static struct cdns_torrent_vals usb_phy_pcs_cmn_vals = {
35869855d84bSSwapnil Jakhade .reg_pairs = usb_phy_pcs_cmn_regs,
35879855d84bSSwapnil Jakhade .num_regs = ARRAY_SIZE(usb_phy_pcs_cmn_regs),
35889855d84bSSwapnil Jakhade };
35899855d84bSSwapnil Jakhade
35909855d84bSSwapnil Jakhade /* USB 100 MHz Ref clk, no SSC */
3591ed9e07f8SSwapnil Jakhade static struct cdns_reg_pairs sl_usb_100_no_ssc_cmn_regs[] = {
3592ed9e07f8SSwapnil Jakhade {0x0028, CMN_PDIAG_PLL1_CP_PADJ_M0},
3593ed9e07f8SSwapnil Jakhade {0x001E, CMN_PLL1_DSM_FBH_OVRD_M0},
3594ed9e07f8SSwapnil Jakhade {0x000C, CMN_PLL1_DSM_FBL_OVRD_M0},
35959855d84bSSwapnil Jakhade {0x0003, CMN_PLL0_VCOCAL_TCTRL},
35969855d84bSSwapnil Jakhade {0x0003, CMN_PLL1_VCOCAL_TCTRL},
35979855d84bSSwapnil Jakhade {0x8200, CMN_CDIAG_CDB_PWRI_OVRD},
35989855d84bSSwapnil Jakhade {0x8200, CMN_CDIAG_XCVRC_PWRI_OVRD}
35999855d84bSSwapnil Jakhade };
36009855d84bSSwapnil Jakhade
3601ed9e07f8SSwapnil Jakhade static struct cdns_torrent_vals sl_usb_100_no_ssc_cmn_vals = {
3602ed9e07f8SSwapnil Jakhade .reg_pairs = sl_usb_100_no_ssc_cmn_regs,
3603ed9e07f8SSwapnil Jakhade .num_regs = ARRAY_SIZE(sl_usb_100_no_ssc_cmn_regs),
3604ed9e07f8SSwapnil Jakhade };
3605ed9e07f8SSwapnil Jakhade
3606ed9e07f8SSwapnil Jakhade static struct cdns_reg_pairs usb_100_no_ssc_cmn_regs[] = {
3607ed9e07f8SSwapnil Jakhade {0x8200, CMN_CDIAG_CDB_PWRI_OVRD},
3608ed9e07f8SSwapnil Jakhade {0x8200, CMN_CDIAG_XCVRC_PWRI_OVRD},
3609ed9e07f8SSwapnil Jakhade {0x007F, CMN_TXPUCAL_TUNE},
3610ed9e07f8SSwapnil Jakhade {0x007F, CMN_TXPDCAL_TUNE}
3611ed9e07f8SSwapnil Jakhade };
3612ed9e07f8SSwapnil Jakhade
36139855d84bSSwapnil Jakhade static struct cdns_reg_pairs usb_100_no_ssc_tx_ln_regs[] = {
36149855d84bSSwapnil Jakhade {0x02FF, TX_PSC_A0},
36159855d84bSSwapnil Jakhade {0x06AF, TX_PSC_A1},
36169855d84bSSwapnil Jakhade {0x06AE, TX_PSC_A2},
36179855d84bSSwapnil Jakhade {0x06AE, TX_PSC_A3},
36189855d84bSSwapnil Jakhade {0x2A82, TX_TXCC_CTRL},
36199855d84bSSwapnil Jakhade {0x0014, TX_TXCC_CPOST_MULT_01},
36209855d84bSSwapnil Jakhade {0x0003, XCVR_DIAG_PSC_OVRD}
36219855d84bSSwapnil Jakhade };
36229855d84bSSwapnil Jakhade
36239855d84bSSwapnil Jakhade static struct cdns_reg_pairs usb_100_no_ssc_rx_ln_regs[] = {
36249855d84bSSwapnil Jakhade {0x0D1D, RX_PSC_A0},
36259855d84bSSwapnil Jakhade {0x0D1D, RX_PSC_A1},
36269855d84bSSwapnil Jakhade {0x0D00, RX_PSC_A2},
36279855d84bSSwapnil Jakhade {0x0500, RX_PSC_A3},
36289855d84bSSwapnil Jakhade {0x0013, RX_SIGDET_HL_FILT_TMR},
36299855d84bSSwapnil Jakhade {0x0000, RX_REE_GCSM1_CTRL},
36309855d84bSSwapnil Jakhade {0x0C02, RX_REE_ATTEN_THR},
36319855d84bSSwapnil Jakhade {0x0330, RX_REE_SMGM_CTRL1},
36329855d84bSSwapnil Jakhade {0x0300, RX_REE_SMGM_CTRL2},
36339855d84bSSwapnil Jakhade {0x0019, RX_REE_TAP1_CLIP},
36349855d84bSSwapnil Jakhade {0x0019, RX_REE_TAP2TON_CLIP},
36359855d84bSSwapnil Jakhade {0x1004, RX_DIAG_SIGDET_TUNE},
36369855d84bSSwapnil Jakhade {0x00F9, RX_DIAG_NQST_CTRL},
36379855d84bSSwapnil Jakhade {0x0C01, RX_DIAG_DFE_AMP_TUNE_2},
36389855d84bSSwapnil Jakhade {0x0002, RX_DIAG_DFE_AMP_TUNE_3},
36399855d84bSSwapnil Jakhade {0x0000, RX_DIAG_PI_CAP},
36409855d84bSSwapnil Jakhade {0x0031, RX_DIAG_PI_RATE},
36419855d84bSSwapnil Jakhade {0x0001, RX_DIAG_ACYA},
36429855d84bSSwapnil Jakhade {0x018C, RX_CDRLF_CNFG},
36439855d84bSSwapnil Jakhade {0x0003, RX_CDRLF_CNFG3}
36449855d84bSSwapnil Jakhade };
36459855d84bSSwapnil Jakhade
36469855d84bSSwapnil Jakhade static struct cdns_torrent_vals usb_100_no_ssc_cmn_vals = {
36479855d84bSSwapnil Jakhade .reg_pairs = usb_100_no_ssc_cmn_regs,
36489855d84bSSwapnil Jakhade .num_regs = ARRAY_SIZE(usb_100_no_ssc_cmn_regs),
36499855d84bSSwapnil Jakhade };
36509855d84bSSwapnil Jakhade
36519855d84bSSwapnil Jakhade static struct cdns_torrent_vals usb_100_no_ssc_tx_ln_vals = {
36529855d84bSSwapnil Jakhade .reg_pairs = usb_100_no_ssc_tx_ln_regs,
36539855d84bSSwapnil Jakhade .num_regs = ARRAY_SIZE(usb_100_no_ssc_tx_ln_regs),
36549855d84bSSwapnil Jakhade };
36559855d84bSSwapnil Jakhade
36569855d84bSSwapnil Jakhade static struct cdns_torrent_vals usb_100_no_ssc_rx_ln_vals = {
36579855d84bSSwapnil Jakhade .reg_pairs = usb_100_no_ssc_rx_ln_regs,
36589855d84bSSwapnil Jakhade .num_regs = ARRAY_SIZE(usb_100_no_ssc_rx_ln_regs),
36599855d84bSSwapnil Jakhade };
36609855d84bSSwapnil Jakhade
36619855d84bSSwapnil Jakhade /* Single link USB, 100 MHz Ref clk, internal SSC */
36629855d84bSSwapnil Jakhade static struct cdns_reg_pairs sl_usb_100_int_ssc_cmn_regs[] = {
36639855d84bSSwapnil Jakhade {0x0004, CMN_PLL0_DSM_DIAG_M0},
36649855d84bSSwapnil Jakhade {0x0004, CMN_PLL1_DSM_DIAG_M0},
36659855d84bSSwapnil Jakhade {0x0509, CMN_PDIAG_PLL0_CP_PADJ_M0},
36669855d84bSSwapnil Jakhade {0x0509, CMN_PDIAG_PLL1_CP_PADJ_M0},
36679855d84bSSwapnil Jakhade {0x0F00, CMN_PDIAG_PLL0_CP_IADJ_M0},
36689855d84bSSwapnil Jakhade {0x0F00, CMN_PDIAG_PLL1_CP_IADJ_M0},
36699855d84bSSwapnil Jakhade {0x0F08, CMN_PDIAG_PLL0_FILT_PADJ_M0},
36709855d84bSSwapnil Jakhade {0x0F08, CMN_PDIAG_PLL1_FILT_PADJ_M0},
36719855d84bSSwapnil Jakhade {0x0064, CMN_PLL0_INTDIV_M0},
36729855d84bSSwapnil Jakhade {0x0064, CMN_PLL1_INTDIV_M0},
36739855d84bSSwapnil Jakhade {0x0002, CMN_PLL0_FRACDIVH_M0},
36749855d84bSSwapnil Jakhade {0x0002, CMN_PLL1_FRACDIVH_M0},
36759855d84bSSwapnil Jakhade {0x0044, CMN_PLL0_HIGH_THR_M0},
36769855d84bSSwapnil Jakhade {0x0044, CMN_PLL1_HIGH_THR_M0},
36779855d84bSSwapnil Jakhade {0x0002, CMN_PDIAG_PLL0_CTRL_M0},
36789855d84bSSwapnil Jakhade {0x0002, CMN_PDIAG_PLL1_CTRL_M0},
36799855d84bSSwapnil Jakhade {0x0001, CMN_PLL0_SS_CTRL1_M0},
36809855d84bSSwapnil Jakhade {0x0001, CMN_PLL1_SS_CTRL1_M0},
36819855d84bSSwapnil Jakhade {0x011B, CMN_PLL0_SS_CTRL2_M0},
36829855d84bSSwapnil Jakhade {0x011B, CMN_PLL1_SS_CTRL2_M0},
36839855d84bSSwapnil Jakhade {0x006E, CMN_PLL0_SS_CTRL3_M0},
36849855d84bSSwapnil Jakhade {0x006E, CMN_PLL1_SS_CTRL3_M0},
36859855d84bSSwapnil Jakhade {0x000E, CMN_PLL0_SS_CTRL4_M0},
36869855d84bSSwapnil Jakhade {0x000E, CMN_PLL1_SS_CTRL4_M0},
36879855d84bSSwapnil Jakhade {0x0C5E, CMN_PLL0_VCOCAL_REFTIM_START},
36889855d84bSSwapnil Jakhade {0x0C5E, CMN_PLL1_VCOCAL_REFTIM_START},
36899855d84bSSwapnil Jakhade {0x0C56, CMN_PLL0_VCOCAL_PLLCNT_START},
36909855d84bSSwapnil Jakhade {0x0C56, CMN_PLL1_VCOCAL_PLLCNT_START},
36919855d84bSSwapnil Jakhade {0x0003, CMN_PLL0_VCOCAL_TCTRL},
36929855d84bSSwapnil Jakhade {0x0003, CMN_PLL1_VCOCAL_TCTRL},
36939855d84bSSwapnil Jakhade {0x00C7, CMN_PLL0_LOCK_REFCNT_START},
36949855d84bSSwapnil Jakhade {0x00C7, CMN_PLL1_LOCK_REFCNT_START},
36959855d84bSSwapnil Jakhade {0x00C7, CMN_PLL0_LOCK_PLLCNT_START},
36969855d84bSSwapnil Jakhade {0x00C7, CMN_PLL1_LOCK_PLLCNT_START},
36979855d84bSSwapnil Jakhade {0x0005, CMN_PLL0_LOCK_PLLCNT_THR},
36989855d84bSSwapnil Jakhade {0x0005, CMN_PLL1_LOCK_PLLCNT_THR},
36999855d84bSSwapnil Jakhade {0x8200, CMN_CDIAG_CDB_PWRI_OVRD},
37009855d84bSSwapnil Jakhade {0x8200, CMN_CDIAG_XCVRC_PWRI_OVRD}
37019855d84bSSwapnil Jakhade };
37029855d84bSSwapnil Jakhade
37039855d84bSSwapnil Jakhade static struct cdns_torrent_vals sl_usb_100_int_ssc_cmn_vals = {
37049855d84bSSwapnil Jakhade .reg_pairs = sl_usb_100_int_ssc_cmn_regs,
37059855d84bSSwapnil Jakhade .num_regs = ARRAY_SIZE(sl_usb_100_int_ssc_cmn_regs),
37069855d84bSSwapnil Jakhade };
37079855d84bSSwapnil Jakhade
37086bcf3cb3SSwapnil Jakhade /* PCIe and SGMII/QSGMII Unique SSC link configuration */
37096bcf3cb3SSwapnil Jakhade static struct cdns_reg_pairs pcie_sgmii_link_cmn_regs[] = {
3710d66a6366SSwapnil Jakhade {0x0003, PHY_PLL_CFG},
37116bcf3cb3SSwapnil Jakhade {0x0601, CMN_PDIAG_PLL0_CLK_SEL_M0},
37126bcf3cb3SSwapnil Jakhade {0x0400, CMN_PDIAG_PLL0_CLK_SEL_M1},
37136bcf3cb3SSwapnil Jakhade {0x0601, CMN_PDIAG_PLL1_CLK_SEL_M0}
37146bcf3cb3SSwapnil Jakhade };
37156bcf3cb3SSwapnil Jakhade
37166bcf3cb3SSwapnil Jakhade static struct cdns_reg_pairs pcie_sgmii_xcvr_diag_ln_regs[] = {
37176bcf3cb3SSwapnil Jakhade {0x0000, XCVR_DIAG_HSCLK_SEL},
37186bcf3cb3SSwapnil Jakhade {0x0001, XCVR_DIAG_HSCLK_DIV},
37196bcf3cb3SSwapnil Jakhade {0x0012, XCVR_DIAG_PLLDRC_CTRL}
37206bcf3cb3SSwapnil Jakhade };
37216bcf3cb3SSwapnil Jakhade
37226bcf3cb3SSwapnil Jakhade static struct cdns_reg_pairs sgmii_pcie_xcvr_diag_ln_regs[] = {
37236bcf3cb3SSwapnil Jakhade {0x0011, XCVR_DIAG_HSCLK_SEL},
37246bcf3cb3SSwapnil Jakhade {0x0003, XCVR_DIAG_HSCLK_DIV},
37256bcf3cb3SSwapnil Jakhade {0x009B, XCVR_DIAG_PLLDRC_CTRL}
37266bcf3cb3SSwapnil Jakhade };
37276bcf3cb3SSwapnil Jakhade
37286bcf3cb3SSwapnil Jakhade static struct cdns_torrent_vals pcie_sgmii_link_cmn_vals = {
37296bcf3cb3SSwapnil Jakhade .reg_pairs = pcie_sgmii_link_cmn_regs,
37306bcf3cb3SSwapnil Jakhade .num_regs = ARRAY_SIZE(pcie_sgmii_link_cmn_regs),
37316bcf3cb3SSwapnil Jakhade };
37326bcf3cb3SSwapnil Jakhade
37336bcf3cb3SSwapnil Jakhade static struct cdns_torrent_vals pcie_sgmii_xcvr_diag_ln_vals = {
37346bcf3cb3SSwapnil Jakhade .reg_pairs = pcie_sgmii_xcvr_diag_ln_regs,
37356bcf3cb3SSwapnil Jakhade .num_regs = ARRAY_SIZE(pcie_sgmii_xcvr_diag_ln_regs),
37366bcf3cb3SSwapnil Jakhade };
37376bcf3cb3SSwapnil Jakhade
37386bcf3cb3SSwapnil Jakhade static struct cdns_torrent_vals sgmii_pcie_xcvr_diag_ln_vals = {
37396bcf3cb3SSwapnil Jakhade .reg_pairs = sgmii_pcie_xcvr_diag_ln_regs,
37406bcf3cb3SSwapnil Jakhade .num_regs = ARRAY_SIZE(sgmii_pcie_xcvr_diag_ln_regs),
37416bcf3cb3SSwapnil Jakhade };
37426bcf3cb3SSwapnil Jakhade
37436bcf3cb3SSwapnil Jakhade /* SGMII 100 MHz Ref clk, no SSC */
3744e25c9dbcSSwapnil Jakhade static struct cdns_reg_pairs sl_sgmii_100_no_ssc_cmn_regs[] = {
3745e25c9dbcSSwapnil Jakhade {0x0028, CMN_PDIAG_PLL1_CP_PADJ_M0},
3746e25c9dbcSSwapnil Jakhade {0x001E, CMN_PLL1_DSM_FBH_OVRD_M0},
3747e25c9dbcSSwapnil Jakhade {0x000C, CMN_PLL1_DSM_FBL_OVRD_M0},
37486bcf3cb3SSwapnil Jakhade {0x0003, CMN_PLL0_VCOCAL_TCTRL},
3749e25c9dbcSSwapnil Jakhade {0x0003, CMN_PLL1_VCOCAL_TCTRL}
3750e25c9dbcSSwapnil Jakhade };
3751e25c9dbcSSwapnil Jakhade
3752e25c9dbcSSwapnil Jakhade static struct cdns_torrent_vals sl_sgmii_100_no_ssc_cmn_vals = {
3753e25c9dbcSSwapnil Jakhade .reg_pairs = sl_sgmii_100_no_ssc_cmn_regs,
3754e25c9dbcSSwapnil Jakhade .num_regs = ARRAY_SIZE(sl_sgmii_100_no_ssc_cmn_regs),
3755e25c9dbcSSwapnil Jakhade };
3756e25c9dbcSSwapnil Jakhade
3757e25c9dbcSSwapnil Jakhade static struct cdns_reg_pairs sgmii_100_no_ssc_cmn_regs[] = {
3758e25c9dbcSSwapnil Jakhade {0x007F, CMN_TXPUCAL_TUNE},
3759e25c9dbcSSwapnil Jakhade {0x007F, CMN_TXPDCAL_TUNE}
37606bcf3cb3SSwapnil Jakhade };
37616bcf3cb3SSwapnil Jakhade
37626bcf3cb3SSwapnil Jakhade static struct cdns_reg_pairs sgmii_100_no_ssc_tx_ln_regs[] = {
37636bcf3cb3SSwapnil Jakhade {0x00F3, TX_PSC_A0},
37646bcf3cb3SSwapnil Jakhade {0x04A2, TX_PSC_A2},
37656bcf3cb3SSwapnil Jakhade {0x04A2, TX_PSC_A3},
37666bcf3cb3SSwapnil Jakhade {0x0000, TX_TXCC_CPOST_MULT_00},
37676bcf3cb3SSwapnil Jakhade {0x00B3, DRV_DIAG_TX_DRV}
37686bcf3cb3SSwapnil Jakhade };
37696bcf3cb3SSwapnil Jakhade
377070901a7dSKishon Vijay Abraham I static struct cdns_reg_pairs ti_sgmii_100_no_ssc_tx_ln_regs[] = {
377170901a7dSKishon Vijay Abraham I {0x00F3, TX_PSC_A0},
377270901a7dSKishon Vijay Abraham I {0x04A2, TX_PSC_A2},
377370901a7dSKishon Vijay Abraham I {0x04A2, TX_PSC_A3},
377470901a7dSKishon Vijay Abraham I {0x0000, TX_TXCC_CPOST_MULT_00},
377570901a7dSKishon Vijay Abraham I {0x00B3, DRV_DIAG_TX_DRV},
377670901a7dSKishon Vijay Abraham I {0x4000, XCVR_DIAG_RXCLK_CTRL},
377770901a7dSKishon Vijay Abraham I };
377870901a7dSKishon Vijay Abraham I
37796bcf3cb3SSwapnil Jakhade static struct cdns_reg_pairs sgmii_100_no_ssc_rx_ln_regs[] = {
37806bcf3cb3SSwapnil Jakhade {0x091D, RX_PSC_A0},
37816bcf3cb3SSwapnil Jakhade {0x0900, RX_PSC_A2},
37826bcf3cb3SSwapnil Jakhade {0x0100, RX_PSC_A3},
37836bcf3cb3SSwapnil Jakhade {0x03C7, RX_REE_GCSM1_EQENM_PH1},
37846bcf3cb3SSwapnil Jakhade {0x01C7, RX_REE_GCSM1_EQENM_PH2},
37856bcf3cb3SSwapnil Jakhade {0x0000, RX_DIAG_DFE_CTRL},
37866bcf3cb3SSwapnil Jakhade {0x0019, RX_REE_TAP1_CLIP},
37876bcf3cb3SSwapnil Jakhade {0x0019, RX_REE_TAP2TON_CLIP},
37886bcf3cb3SSwapnil Jakhade {0x0098, RX_DIAG_NQST_CTRL},
37896bcf3cb3SSwapnil Jakhade {0x0C01, RX_DIAG_DFE_AMP_TUNE_2},
37906bcf3cb3SSwapnil Jakhade {0x0000, RX_DIAG_DFE_AMP_TUNE_3},
37916bcf3cb3SSwapnil Jakhade {0x0000, RX_DIAG_PI_CAP},
37926bcf3cb3SSwapnil Jakhade {0x0010, RX_DIAG_PI_RATE},
37936bcf3cb3SSwapnil Jakhade {0x0001, RX_DIAG_ACYA},
37946bcf3cb3SSwapnil Jakhade {0x018C, RX_CDRLF_CNFG},
37956bcf3cb3SSwapnil Jakhade };
37966bcf3cb3SSwapnil Jakhade
37976bcf3cb3SSwapnil Jakhade static struct cdns_torrent_vals sgmii_100_no_ssc_cmn_vals = {
37986bcf3cb3SSwapnil Jakhade .reg_pairs = sgmii_100_no_ssc_cmn_regs,
37996bcf3cb3SSwapnil Jakhade .num_regs = ARRAY_SIZE(sgmii_100_no_ssc_cmn_regs),
38006bcf3cb3SSwapnil Jakhade };
38016bcf3cb3SSwapnil Jakhade
38026bcf3cb3SSwapnil Jakhade static struct cdns_torrent_vals sgmii_100_no_ssc_tx_ln_vals = {
38036bcf3cb3SSwapnil Jakhade .reg_pairs = sgmii_100_no_ssc_tx_ln_regs,
38046bcf3cb3SSwapnil Jakhade .num_regs = ARRAY_SIZE(sgmii_100_no_ssc_tx_ln_regs),
38056bcf3cb3SSwapnil Jakhade };
38066bcf3cb3SSwapnil Jakhade
380770901a7dSKishon Vijay Abraham I static struct cdns_torrent_vals ti_sgmii_100_no_ssc_tx_ln_vals = {
380870901a7dSKishon Vijay Abraham I .reg_pairs = ti_sgmii_100_no_ssc_tx_ln_regs,
380970901a7dSKishon Vijay Abraham I .num_regs = ARRAY_SIZE(ti_sgmii_100_no_ssc_tx_ln_regs),
381070901a7dSKishon Vijay Abraham I };
381170901a7dSKishon Vijay Abraham I
38126bcf3cb3SSwapnil Jakhade static struct cdns_torrent_vals sgmii_100_no_ssc_rx_ln_vals = {
38136bcf3cb3SSwapnil Jakhade .reg_pairs = sgmii_100_no_ssc_rx_ln_regs,
38146bcf3cb3SSwapnil Jakhade .num_regs = ARRAY_SIZE(sgmii_100_no_ssc_rx_ln_regs),
38156bcf3cb3SSwapnil Jakhade };
38166bcf3cb3SSwapnil Jakhade
38176bcf3cb3SSwapnil Jakhade /* SGMII 100 MHz Ref clk, internal SSC */
38186bcf3cb3SSwapnil Jakhade static struct cdns_reg_pairs sgmii_100_int_ssc_cmn_regs[] = {
38196bcf3cb3SSwapnil Jakhade {0x0004, CMN_PLL0_DSM_DIAG_M0},
38206bcf3cb3SSwapnil Jakhade {0x0004, CMN_PLL0_DSM_DIAG_M1},
38216bcf3cb3SSwapnil Jakhade {0x0004, CMN_PLL1_DSM_DIAG_M0},
38226bcf3cb3SSwapnil Jakhade {0x0509, CMN_PDIAG_PLL0_CP_PADJ_M0},
38236bcf3cb3SSwapnil Jakhade {0x0509, CMN_PDIAG_PLL0_CP_PADJ_M1},
38246bcf3cb3SSwapnil Jakhade {0x0509, CMN_PDIAG_PLL1_CP_PADJ_M0},
38256bcf3cb3SSwapnil Jakhade {0x0F00, CMN_PDIAG_PLL0_CP_IADJ_M0},
38266bcf3cb3SSwapnil Jakhade {0x0F00, CMN_PDIAG_PLL0_CP_IADJ_M1},
38276bcf3cb3SSwapnil Jakhade {0x0F00, CMN_PDIAG_PLL1_CP_IADJ_M0},
38286bcf3cb3SSwapnil Jakhade {0x0F08, CMN_PDIAG_PLL0_FILT_PADJ_M0},
38296bcf3cb3SSwapnil Jakhade {0x0F08, CMN_PDIAG_PLL0_FILT_PADJ_M1},
38306bcf3cb3SSwapnil Jakhade {0x0F08, CMN_PDIAG_PLL1_FILT_PADJ_M0},
38316bcf3cb3SSwapnil Jakhade {0x0064, CMN_PLL0_INTDIV_M0},
38326bcf3cb3SSwapnil Jakhade {0x0050, CMN_PLL0_INTDIV_M1},
38336bcf3cb3SSwapnil Jakhade {0x0064, CMN_PLL1_INTDIV_M0},
38346bcf3cb3SSwapnil Jakhade {0x0002, CMN_PLL0_FRACDIVH_M0},
38356bcf3cb3SSwapnil Jakhade {0x0002, CMN_PLL0_FRACDIVH_M1},
38366bcf3cb3SSwapnil Jakhade {0x0002, CMN_PLL1_FRACDIVH_M0},
38376bcf3cb3SSwapnil Jakhade {0x0044, CMN_PLL0_HIGH_THR_M0},
38386bcf3cb3SSwapnil Jakhade {0x0036, CMN_PLL0_HIGH_THR_M1},
38396bcf3cb3SSwapnil Jakhade {0x0044, CMN_PLL1_HIGH_THR_M0},
38406bcf3cb3SSwapnil Jakhade {0x0002, CMN_PDIAG_PLL0_CTRL_M0},
38416bcf3cb3SSwapnil Jakhade {0x0002, CMN_PDIAG_PLL0_CTRL_M1},
38426bcf3cb3SSwapnil Jakhade {0x0002, CMN_PDIAG_PLL1_CTRL_M0},
38436bcf3cb3SSwapnil Jakhade {0x0001, CMN_PLL0_SS_CTRL1_M0},
38446bcf3cb3SSwapnil Jakhade {0x0001, CMN_PLL0_SS_CTRL1_M1},
38456bcf3cb3SSwapnil Jakhade {0x0001, CMN_PLL1_SS_CTRL1_M0},
38466bcf3cb3SSwapnil Jakhade {0x011B, CMN_PLL0_SS_CTRL2_M0},
38476bcf3cb3SSwapnil Jakhade {0x011B, CMN_PLL0_SS_CTRL2_M1},
38486bcf3cb3SSwapnil Jakhade {0x011B, CMN_PLL1_SS_CTRL2_M0},
38496bcf3cb3SSwapnil Jakhade {0x006E, CMN_PLL0_SS_CTRL3_M0},
38506bcf3cb3SSwapnil Jakhade {0x0058, CMN_PLL0_SS_CTRL3_M1},
38516bcf3cb3SSwapnil Jakhade {0x006E, CMN_PLL1_SS_CTRL3_M0},
38526bcf3cb3SSwapnil Jakhade {0x000E, CMN_PLL0_SS_CTRL4_M0},
38536bcf3cb3SSwapnil Jakhade {0x0012, CMN_PLL0_SS_CTRL4_M1},
38546bcf3cb3SSwapnil Jakhade {0x000E, CMN_PLL1_SS_CTRL4_M0},
38556bcf3cb3SSwapnil Jakhade {0x0C5E, CMN_PLL0_VCOCAL_REFTIM_START},
38566bcf3cb3SSwapnil Jakhade {0x0C5E, CMN_PLL1_VCOCAL_REFTIM_START},
38576bcf3cb3SSwapnil Jakhade {0x0C56, CMN_PLL0_VCOCAL_PLLCNT_START},
38586bcf3cb3SSwapnil Jakhade {0x0C56, CMN_PLL1_VCOCAL_PLLCNT_START},
38596bcf3cb3SSwapnil Jakhade {0x00C7, CMN_PLL0_LOCK_REFCNT_START},
38606bcf3cb3SSwapnil Jakhade {0x00C7, CMN_PLL1_LOCK_REFCNT_START},
38616bcf3cb3SSwapnil Jakhade {0x00C7, CMN_PLL0_LOCK_PLLCNT_START},
38626bcf3cb3SSwapnil Jakhade {0x00C7, CMN_PLL1_LOCK_PLLCNT_START},
38636bcf3cb3SSwapnil Jakhade {0x0005, CMN_PLL0_LOCK_PLLCNT_THR},
38646bcf3cb3SSwapnil Jakhade {0x0005, CMN_PLL1_LOCK_PLLCNT_THR},
3865e25c9dbcSSwapnil Jakhade {0x007F, CMN_TXPUCAL_TUNE},
3866e25c9dbcSSwapnil Jakhade {0x007F, CMN_TXPDCAL_TUNE}
38676bcf3cb3SSwapnil Jakhade };
38686bcf3cb3SSwapnil Jakhade
38696bcf3cb3SSwapnil Jakhade static struct cdns_torrent_vals sgmii_100_int_ssc_cmn_vals = {
38706bcf3cb3SSwapnil Jakhade .reg_pairs = sgmii_100_int_ssc_cmn_regs,
38716bcf3cb3SSwapnil Jakhade .num_regs = ARRAY_SIZE(sgmii_100_int_ssc_cmn_regs),
38726bcf3cb3SSwapnil Jakhade };
38736bcf3cb3SSwapnil Jakhade
38746bcf3cb3SSwapnil Jakhade /* QSGMII 100 MHz Ref clk, no SSC */
3875e25c9dbcSSwapnil Jakhade static struct cdns_reg_pairs sl_qsgmii_100_no_ssc_cmn_regs[] = {
3876e25c9dbcSSwapnil Jakhade {0x0028, CMN_PDIAG_PLL1_CP_PADJ_M0},
3877e25c9dbcSSwapnil Jakhade {0x001E, CMN_PLL1_DSM_FBH_OVRD_M0},
3878e25c9dbcSSwapnil Jakhade {0x000C, CMN_PLL1_DSM_FBL_OVRD_M0},
38796bcf3cb3SSwapnil Jakhade {0x0003, CMN_PLL0_VCOCAL_TCTRL},
38806bcf3cb3SSwapnil Jakhade {0x0003, CMN_PLL1_VCOCAL_TCTRL}
38816bcf3cb3SSwapnil Jakhade };
38826bcf3cb3SSwapnil Jakhade
3883e25c9dbcSSwapnil Jakhade static struct cdns_torrent_vals sl_qsgmii_100_no_ssc_cmn_vals = {
3884e25c9dbcSSwapnil Jakhade .reg_pairs = sl_qsgmii_100_no_ssc_cmn_regs,
3885e25c9dbcSSwapnil Jakhade .num_regs = ARRAY_SIZE(sl_qsgmii_100_no_ssc_cmn_regs),
3886e25c9dbcSSwapnil Jakhade };
3887e25c9dbcSSwapnil Jakhade
3888e25c9dbcSSwapnil Jakhade static struct cdns_reg_pairs qsgmii_100_no_ssc_cmn_regs[] = {
3889e25c9dbcSSwapnil Jakhade {0x007F, CMN_TXPUCAL_TUNE},
3890e25c9dbcSSwapnil Jakhade {0x007F, CMN_TXPDCAL_TUNE}
3891e25c9dbcSSwapnil Jakhade };
3892e25c9dbcSSwapnil Jakhade
38936bcf3cb3SSwapnil Jakhade static struct cdns_reg_pairs qsgmii_100_no_ssc_tx_ln_regs[] = {
38946bcf3cb3SSwapnil Jakhade {0x00F3, TX_PSC_A0},
38956bcf3cb3SSwapnil Jakhade {0x04A2, TX_PSC_A2},
38966bcf3cb3SSwapnil Jakhade {0x04A2, TX_PSC_A3},
38976bcf3cb3SSwapnil Jakhade {0x0000, TX_TXCC_CPOST_MULT_00},
3898e25c9dbcSSwapnil Jakhade {0x0011, TX_TXCC_MGNFS_MULT_100},
38996bcf3cb3SSwapnil Jakhade {0x0003, DRV_DIAG_TX_DRV}
39006bcf3cb3SSwapnil Jakhade };
39016bcf3cb3SSwapnil Jakhade
390270901a7dSKishon Vijay Abraham I static struct cdns_reg_pairs ti_qsgmii_100_no_ssc_tx_ln_regs[] = {
390370901a7dSKishon Vijay Abraham I {0x00F3, TX_PSC_A0},
390470901a7dSKishon Vijay Abraham I {0x04A2, TX_PSC_A2},
390570901a7dSKishon Vijay Abraham I {0x04A2, TX_PSC_A3},
390670901a7dSKishon Vijay Abraham I {0x0000, TX_TXCC_CPOST_MULT_00},
390770901a7dSKishon Vijay Abraham I {0x0011, TX_TXCC_MGNFS_MULT_100},
390870901a7dSKishon Vijay Abraham I {0x0003, DRV_DIAG_TX_DRV},
390970901a7dSKishon Vijay Abraham I {0x4000, XCVR_DIAG_RXCLK_CTRL},
391070901a7dSKishon Vijay Abraham I };
391170901a7dSKishon Vijay Abraham I
39126bcf3cb3SSwapnil Jakhade static struct cdns_reg_pairs qsgmii_100_no_ssc_rx_ln_regs[] = {
39136bcf3cb3SSwapnil Jakhade {0x091D, RX_PSC_A0},
39146bcf3cb3SSwapnil Jakhade {0x0900, RX_PSC_A2},
39156bcf3cb3SSwapnil Jakhade {0x0100, RX_PSC_A3},
39166bcf3cb3SSwapnil Jakhade {0x03C7, RX_REE_GCSM1_EQENM_PH1},
39176bcf3cb3SSwapnil Jakhade {0x01C7, RX_REE_GCSM1_EQENM_PH2},
39186bcf3cb3SSwapnil Jakhade {0x0000, RX_DIAG_DFE_CTRL},
39196bcf3cb3SSwapnil Jakhade {0x0019, RX_REE_TAP1_CLIP},
39206bcf3cb3SSwapnil Jakhade {0x0019, RX_REE_TAP2TON_CLIP},
39216bcf3cb3SSwapnil Jakhade {0x0098, RX_DIAG_NQST_CTRL},
39226bcf3cb3SSwapnil Jakhade {0x0C01, RX_DIAG_DFE_AMP_TUNE_2},
39236bcf3cb3SSwapnil Jakhade {0x0000, RX_DIAG_DFE_AMP_TUNE_3},
39246bcf3cb3SSwapnil Jakhade {0x0000, RX_DIAG_PI_CAP},
39256bcf3cb3SSwapnil Jakhade {0x0010, RX_DIAG_PI_RATE},
39266bcf3cb3SSwapnil Jakhade {0x0001, RX_DIAG_ACYA},
39276bcf3cb3SSwapnil Jakhade {0x018C, RX_CDRLF_CNFG},
39286bcf3cb3SSwapnil Jakhade };
39296bcf3cb3SSwapnil Jakhade
39306bcf3cb3SSwapnil Jakhade static struct cdns_torrent_vals qsgmii_100_no_ssc_cmn_vals = {
39316bcf3cb3SSwapnil Jakhade .reg_pairs = qsgmii_100_no_ssc_cmn_regs,
39326bcf3cb3SSwapnil Jakhade .num_regs = ARRAY_SIZE(qsgmii_100_no_ssc_cmn_regs),
39336bcf3cb3SSwapnil Jakhade };
39346bcf3cb3SSwapnil Jakhade
39356bcf3cb3SSwapnil Jakhade static struct cdns_torrent_vals qsgmii_100_no_ssc_tx_ln_vals = {
39366bcf3cb3SSwapnil Jakhade .reg_pairs = qsgmii_100_no_ssc_tx_ln_regs,
39376bcf3cb3SSwapnil Jakhade .num_regs = ARRAY_SIZE(qsgmii_100_no_ssc_tx_ln_regs),
39386bcf3cb3SSwapnil Jakhade };
39396bcf3cb3SSwapnil Jakhade
394070901a7dSKishon Vijay Abraham I static struct cdns_torrent_vals ti_qsgmii_100_no_ssc_tx_ln_vals = {
394170901a7dSKishon Vijay Abraham I .reg_pairs = ti_qsgmii_100_no_ssc_tx_ln_regs,
394270901a7dSKishon Vijay Abraham I .num_regs = ARRAY_SIZE(ti_qsgmii_100_no_ssc_tx_ln_regs),
394370901a7dSKishon Vijay Abraham I };
394470901a7dSKishon Vijay Abraham I
39456bcf3cb3SSwapnil Jakhade static struct cdns_torrent_vals qsgmii_100_no_ssc_rx_ln_vals = {
39466bcf3cb3SSwapnil Jakhade .reg_pairs = qsgmii_100_no_ssc_rx_ln_regs,
39476bcf3cb3SSwapnil Jakhade .num_regs = ARRAY_SIZE(qsgmii_100_no_ssc_rx_ln_regs),
39486bcf3cb3SSwapnil Jakhade };
39496bcf3cb3SSwapnil Jakhade
39506bcf3cb3SSwapnil Jakhade /* QSGMII 100 MHz Ref clk, internal SSC */
39516bcf3cb3SSwapnil Jakhade static struct cdns_reg_pairs qsgmii_100_int_ssc_cmn_regs[] = {
39526bcf3cb3SSwapnil Jakhade {0x0004, CMN_PLL0_DSM_DIAG_M0},
39536bcf3cb3SSwapnil Jakhade {0x0004, CMN_PLL0_DSM_DIAG_M1},
39546bcf3cb3SSwapnil Jakhade {0x0004, CMN_PLL1_DSM_DIAG_M0},
39556bcf3cb3SSwapnil Jakhade {0x0509, CMN_PDIAG_PLL0_CP_PADJ_M0},
39566bcf3cb3SSwapnil Jakhade {0x0509, CMN_PDIAG_PLL0_CP_PADJ_M1},
39576bcf3cb3SSwapnil Jakhade {0x0509, CMN_PDIAG_PLL1_CP_PADJ_M0},
39586bcf3cb3SSwapnil Jakhade {0x0F00, CMN_PDIAG_PLL0_CP_IADJ_M0},
39596bcf3cb3SSwapnil Jakhade {0x0F00, CMN_PDIAG_PLL0_CP_IADJ_M1},
39606bcf3cb3SSwapnil Jakhade {0x0F00, CMN_PDIAG_PLL1_CP_IADJ_M0},
39616bcf3cb3SSwapnil Jakhade {0x0F08, CMN_PDIAG_PLL0_FILT_PADJ_M0},
39626bcf3cb3SSwapnil Jakhade {0x0F08, CMN_PDIAG_PLL0_FILT_PADJ_M1},
39636bcf3cb3SSwapnil Jakhade {0x0F08, CMN_PDIAG_PLL1_FILT_PADJ_M0},
39646bcf3cb3SSwapnil Jakhade {0x0064, CMN_PLL0_INTDIV_M0},
39656bcf3cb3SSwapnil Jakhade {0x0050, CMN_PLL0_INTDIV_M1},
39666bcf3cb3SSwapnil Jakhade {0x0064, CMN_PLL1_INTDIV_M0},
39676bcf3cb3SSwapnil Jakhade {0x0002, CMN_PLL0_FRACDIVH_M0},
39686bcf3cb3SSwapnil Jakhade {0x0002, CMN_PLL0_FRACDIVH_M1},
39696bcf3cb3SSwapnil Jakhade {0x0002, CMN_PLL1_FRACDIVH_M0},
39706bcf3cb3SSwapnil Jakhade {0x0044, CMN_PLL0_HIGH_THR_M0},
39716bcf3cb3SSwapnil Jakhade {0x0036, CMN_PLL0_HIGH_THR_M1},
39726bcf3cb3SSwapnil Jakhade {0x0044, CMN_PLL1_HIGH_THR_M0},
39736bcf3cb3SSwapnil Jakhade {0x0002, CMN_PDIAG_PLL0_CTRL_M0},
39746bcf3cb3SSwapnil Jakhade {0x0002, CMN_PDIAG_PLL0_CTRL_M1},
39756bcf3cb3SSwapnil Jakhade {0x0002, CMN_PDIAG_PLL1_CTRL_M0},
39766bcf3cb3SSwapnil Jakhade {0x0001, CMN_PLL0_SS_CTRL1_M0},
39776bcf3cb3SSwapnil Jakhade {0x0001, CMN_PLL0_SS_CTRL1_M1},
39786bcf3cb3SSwapnil Jakhade {0x0001, CMN_PLL1_SS_CTRL1_M0},
39796bcf3cb3SSwapnil Jakhade {0x011B, CMN_PLL0_SS_CTRL2_M0},
39806bcf3cb3SSwapnil Jakhade {0x011B, CMN_PLL0_SS_CTRL2_M1},
39816bcf3cb3SSwapnil Jakhade {0x011B, CMN_PLL1_SS_CTRL2_M0},
39826bcf3cb3SSwapnil Jakhade {0x006E, CMN_PLL0_SS_CTRL3_M0},
39836bcf3cb3SSwapnil Jakhade {0x0058, CMN_PLL0_SS_CTRL3_M1},
39846bcf3cb3SSwapnil Jakhade {0x006E, CMN_PLL1_SS_CTRL3_M0},
39856bcf3cb3SSwapnil Jakhade {0x000E, CMN_PLL0_SS_CTRL4_M0},
39866bcf3cb3SSwapnil Jakhade {0x0012, CMN_PLL0_SS_CTRL4_M1},
39876bcf3cb3SSwapnil Jakhade {0x000E, CMN_PLL1_SS_CTRL4_M0},
39886bcf3cb3SSwapnil Jakhade {0x0C5E, CMN_PLL0_VCOCAL_REFTIM_START},
39896bcf3cb3SSwapnil Jakhade {0x0C5E, CMN_PLL1_VCOCAL_REFTIM_START},
39906bcf3cb3SSwapnil Jakhade {0x0C56, CMN_PLL0_VCOCAL_PLLCNT_START},
39916bcf3cb3SSwapnil Jakhade {0x0C56, CMN_PLL1_VCOCAL_PLLCNT_START},
39926bcf3cb3SSwapnil Jakhade {0x00C7, CMN_PLL0_LOCK_REFCNT_START},
39936bcf3cb3SSwapnil Jakhade {0x00C7, CMN_PLL1_LOCK_REFCNT_START},
39946bcf3cb3SSwapnil Jakhade {0x00C7, CMN_PLL0_LOCK_PLLCNT_START},
39956bcf3cb3SSwapnil Jakhade {0x00C7, CMN_PLL1_LOCK_PLLCNT_START},
39966bcf3cb3SSwapnil Jakhade {0x0005, CMN_PLL0_LOCK_PLLCNT_THR},
3997e25c9dbcSSwapnil Jakhade {0x0005, CMN_PLL1_LOCK_PLLCNT_THR},
3998e25c9dbcSSwapnil Jakhade {0x007F, CMN_TXPUCAL_TUNE},
3999e25c9dbcSSwapnil Jakhade {0x007F, CMN_TXPDCAL_TUNE}
40006bcf3cb3SSwapnil Jakhade };
40016bcf3cb3SSwapnil Jakhade
40026bcf3cb3SSwapnil Jakhade static struct cdns_torrent_vals qsgmii_100_int_ssc_cmn_vals = {
40036bcf3cb3SSwapnil Jakhade .reg_pairs = qsgmii_100_int_ssc_cmn_regs,
40046bcf3cb3SSwapnil Jakhade .num_regs = ARRAY_SIZE(qsgmii_100_int_ssc_cmn_regs),
40056bcf3cb3SSwapnil Jakhade };
40066bcf3cb3SSwapnil Jakhade
40079f33b76aSSwapnil Jakhade /* Single SGMII/QSGMII link configuration */
40089f33b76aSSwapnil Jakhade static struct cdns_reg_pairs sl_sgmii_link_cmn_regs[] = {
40099f33b76aSSwapnil Jakhade {0x0000, PHY_PLL_CFG},
40109f33b76aSSwapnil Jakhade {0x0601, CMN_PDIAG_PLL0_CLK_SEL_M0}
40119f33b76aSSwapnil Jakhade };
40129f33b76aSSwapnil Jakhade
40139f33b76aSSwapnil Jakhade static struct cdns_reg_pairs sl_sgmii_xcvr_diag_ln_regs[] = {
40149f33b76aSSwapnil Jakhade {0x0000, XCVR_DIAG_HSCLK_SEL},
40159f33b76aSSwapnil Jakhade {0x0003, XCVR_DIAG_HSCLK_DIV},
40169f33b76aSSwapnil Jakhade {0x0013, XCVR_DIAG_PLLDRC_CTRL}
40179f33b76aSSwapnil Jakhade };
40189f33b76aSSwapnil Jakhade
40199f33b76aSSwapnil Jakhade static struct cdns_torrent_vals sl_sgmii_link_cmn_vals = {
40209f33b76aSSwapnil Jakhade .reg_pairs = sl_sgmii_link_cmn_regs,
40219f33b76aSSwapnil Jakhade .num_regs = ARRAY_SIZE(sl_sgmii_link_cmn_regs),
40229f33b76aSSwapnil Jakhade };
40239f33b76aSSwapnil Jakhade
40249f33b76aSSwapnil Jakhade static struct cdns_torrent_vals sl_sgmii_xcvr_diag_ln_vals = {
40259f33b76aSSwapnil Jakhade .reg_pairs = sl_sgmii_xcvr_diag_ln_regs,
40269f33b76aSSwapnil Jakhade .num_regs = ARRAY_SIZE(sl_sgmii_xcvr_diag_ln_regs),
40279f33b76aSSwapnil Jakhade };
40289f33b76aSSwapnil Jakhade
40296bcf3cb3SSwapnil Jakhade /* Multi link PCIe, 100 MHz Ref clk, internal SSC */
40306bcf3cb3SSwapnil Jakhade static struct cdns_reg_pairs pcie_100_int_ssc_cmn_regs[] = {
40316bcf3cb3SSwapnil Jakhade {0x0004, CMN_PLL0_DSM_DIAG_M0},
40326bcf3cb3SSwapnil Jakhade {0x0004, CMN_PLL0_DSM_DIAG_M1},
40336bcf3cb3SSwapnil Jakhade {0x0004, CMN_PLL1_DSM_DIAG_M0},
40346bcf3cb3SSwapnil Jakhade {0x0509, CMN_PDIAG_PLL0_CP_PADJ_M0},
40356bcf3cb3SSwapnil Jakhade {0x0509, CMN_PDIAG_PLL0_CP_PADJ_M1},
40366bcf3cb3SSwapnil Jakhade {0x0509, CMN_PDIAG_PLL1_CP_PADJ_M0},
40376bcf3cb3SSwapnil Jakhade {0x0F00, CMN_PDIAG_PLL0_CP_IADJ_M0},
40386bcf3cb3SSwapnil Jakhade {0x0F00, CMN_PDIAG_PLL0_CP_IADJ_M1},
40396bcf3cb3SSwapnil Jakhade {0x0F00, CMN_PDIAG_PLL1_CP_IADJ_M0},
40406bcf3cb3SSwapnil Jakhade {0x0F08, CMN_PDIAG_PLL0_FILT_PADJ_M0},
40416bcf3cb3SSwapnil Jakhade {0x0F08, CMN_PDIAG_PLL0_FILT_PADJ_M1},
40426bcf3cb3SSwapnil Jakhade {0x0F08, CMN_PDIAG_PLL1_FILT_PADJ_M0},
40436bcf3cb3SSwapnil Jakhade {0x0064, CMN_PLL0_INTDIV_M0},
40446bcf3cb3SSwapnil Jakhade {0x0050, CMN_PLL0_INTDIV_M1},
40456bcf3cb3SSwapnil Jakhade {0x0064, CMN_PLL1_INTDIV_M0},
40466bcf3cb3SSwapnil Jakhade {0x0002, CMN_PLL0_FRACDIVH_M0},
40476bcf3cb3SSwapnil Jakhade {0x0002, CMN_PLL0_FRACDIVH_M1},
40486bcf3cb3SSwapnil Jakhade {0x0002, CMN_PLL1_FRACDIVH_M0},
40496bcf3cb3SSwapnil Jakhade {0x0044, CMN_PLL0_HIGH_THR_M0},
40506bcf3cb3SSwapnil Jakhade {0x0036, CMN_PLL0_HIGH_THR_M1},
40516bcf3cb3SSwapnil Jakhade {0x0044, CMN_PLL1_HIGH_THR_M0},
40526bcf3cb3SSwapnil Jakhade {0x0002, CMN_PDIAG_PLL0_CTRL_M0},
40536bcf3cb3SSwapnil Jakhade {0x0002, CMN_PDIAG_PLL0_CTRL_M1},
40546bcf3cb3SSwapnil Jakhade {0x0002, CMN_PDIAG_PLL1_CTRL_M0},
40556bcf3cb3SSwapnil Jakhade {0x0001, CMN_PLL0_SS_CTRL1_M0},
40566bcf3cb3SSwapnil Jakhade {0x0001, CMN_PLL0_SS_CTRL1_M1},
40576bcf3cb3SSwapnil Jakhade {0x0001, CMN_PLL1_SS_CTRL1_M0},
40586bcf3cb3SSwapnil Jakhade {0x011B, CMN_PLL0_SS_CTRL2_M0},
40596bcf3cb3SSwapnil Jakhade {0x011B, CMN_PLL0_SS_CTRL2_M1},
40606bcf3cb3SSwapnil Jakhade {0x011B, CMN_PLL1_SS_CTRL2_M0},
40616bcf3cb3SSwapnil Jakhade {0x006E, CMN_PLL0_SS_CTRL3_M0},
40626bcf3cb3SSwapnil Jakhade {0x0058, CMN_PLL0_SS_CTRL3_M1},
40636bcf3cb3SSwapnil Jakhade {0x006E, CMN_PLL1_SS_CTRL3_M0},
40646bcf3cb3SSwapnil Jakhade {0x000E, CMN_PLL0_SS_CTRL4_M0},
40656bcf3cb3SSwapnil Jakhade {0x0012, CMN_PLL0_SS_CTRL4_M1},
40666bcf3cb3SSwapnil Jakhade {0x000E, CMN_PLL1_SS_CTRL4_M0},
40676bcf3cb3SSwapnil Jakhade {0x0C5E, CMN_PLL0_VCOCAL_REFTIM_START},
40686bcf3cb3SSwapnil Jakhade {0x0C5E, CMN_PLL1_VCOCAL_REFTIM_START},
40696bcf3cb3SSwapnil Jakhade {0x0C56, CMN_PLL0_VCOCAL_PLLCNT_START},
40706bcf3cb3SSwapnil Jakhade {0x0C56, CMN_PLL1_VCOCAL_PLLCNT_START},
40716bcf3cb3SSwapnil Jakhade {0x00C7, CMN_PLL0_LOCK_REFCNT_START},
40726bcf3cb3SSwapnil Jakhade {0x00C7, CMN_PLL1_LOCK_REFCNT_START},
40736bcf3cb3SSwapnil Jakhade {0x00C7, CMN_PLL0_LOCK_PLLCNT_START},
40746bcf3cb3SSwapnil Jakhade {0x00C7, CMN_PLL1_LOCK_PLLCNT_START},
40756bcf3cb3SSwapnil Jakhade {0x0005, CMN_PLL0_LOCK_PLLCNT_THR},
40766bcf3cb3SSwapnil Jakhade {0x0005, CMN_PLL1_LOCK_PLLCNT_THR}
40776bcf3cb3SSwapnil Jakhade };
40786bcf3cb3SSwapnil Jakhade
40796bcf3cb3SSwapnil Jakhade static struct cdns_torrent_vals pcie_100_int_ssc_cmn_vals = {
40806bcf3cb3SSwapnil Jakhade .reg_pairs = pcie_100_int_ssc_cmn_regs,
40816bcf3cb3SSwapnil Jakhade .num_regs = ARRAY_SIZE(pcie_100_int_ssc_cmn_regs),
40826bcf3cb3SSwapnil Jakhade };
40836bcf3cb3SSwapnil Jakhade
4084b54b47bdSSwapnil Jakhade /* Single link PCIe, 100 MHz Ref clk, internal SSC */
4085b54b47bdSSwapnil Jakhade static struct cdns_reg_pairs sl_pcie_100_int_ssc_cmn_regs[] = {
4086b54b47bdSSwapnil Jakhade {0x0004, CMN_PLL0_DSM_DIAG_M0},
4087b54b47bdSSwapnil Jakhade {0x0004, CMN_PLL0_DSM_DIAG_M1},
4088b54b47bdSSwapnil Jakhade {0x0004, CMN_PLL1_DSM_DIAG_M0},
4089b54b47bdSSwapnil Jakhade {0x0509, CMN_PDIAG_PLL0_CP_PADJ_M0},
4090b54b47bdSSwapnil Jakhade {0x0509, CMN_PDIAG_PLL0_CP_PADJ_M1},
4091b54b47bdSSwapnil Jakhade {0x0509, CMN_PDIAG_PLL1_CP_PADJ_M0},
4092b54b47bdSSwapnil Jakhade {0x0F00, CMN_PDIAG_PLL0_CP_IADJ_M0},
4093b54b47bdSSwapnil Jakhade {0x0F00, CMN_PDIAG_PLL0_CP_IADJ_M1},
4094b54b47bdSSwapnil Jakhade {0x0F00, CMN_PDIAG_PLL1_CP_IADJ_M0},
4095b54b47bdSSwapnil Jakhade {0x0F08, CMN_PDIAG_PLL0_FILT_PADJ_M0},
4096b54b47bdSSwapnil Jakhade {0x0F08, CMN_PDIAG_PLL0_FILT_PADJ_M1},
4097b54b47bdSSwapnil Jakhade {0x0F08, CMN_PDIAG_PLL1_FILT_PADJ_M0},
4098b54b47bdSSwapnil Jakhade {0x0064, CMN_PLL0_INTDIV_M0},
4099b54b47bdSSwapnil Jakhade {0x0050, CMN_PLL0_INTDIV_M1},
4100b54b47bdSSwapnil Jakhade {0x0050, CMN_PLL1_INTDIV_M0},
4101b54b47bdSSwapnil Jakhade {0x0002, CMN_PLL0_FRACDIVH_M0},
4102b54b47bdSSwapnil Jakhade {0x0002, CMN_PLL0_FRACDIVH_M1},
4103b54b47bdSSwapnil Jakhade {0x0002, CMN_PLL1_FRACDIVH_M0},
4104b54b47bdSSwapnil Jakhade {0x0044, CMN_PLL0_HIGH_THR_M0},
4105b54b47bdSSwapnil Jakhade {0x0036, CMN_PLL0_HIGH_THR_M1},
4106b54b47bdSSwapnil Jakhade {0x0036, CMN_PLL1_HIGH_THR_M0},
4107b54b47bdSSwapnil Jakhade {0x0002, CMN_PDIAG_PLL0_CTRL_M0},
4108b54b47bdSSwapnil Jakhade {0x0002, CMN_PDIAG_PLL0_CTRL_M1},
4109b54b47bdSSwapnil Jakhade {0x0002, CMN_PDIAG_PLL1_CTRL_M0},
4110b54b47bdSSwapnil Jakhade {0x0001, CMN_PLL0_SS_CTRL1_M0},
4111b54b47bdSSwapnil Jakhade {0x0001, CMN_PLL0_SS_CTRL1_M1},
4112b54b47bdSSwapnil Jakhade {0x0001, CMN_PLL1_SS_CTRL1_M0},
4113b54b47bdSSwapnil Jakhade {0x011B, CMN_PLL0_SS_CTRL2_M0},
4114b54b47bdSSwapnil Jakhade {0x011B, CMN_PLL0_SS_CTRL2_M1},
4115b54b47bdSSwapnil Jakhade {0x011B, CMN_PLL1_SS_CTRL2_M0},
4116b54b47bdSSwapnil Jakhade {0x006E, CMN_PLL0_SS_CTRL3_M0},
4117b54b47bdSSwapnil Jakhade {0x0058, CMN_PLL0_SS_CTRL3_M1},
4118b54b47bdSSwapnil Jakhade {0x0058, CMN_PLL1_SS_CTRL3_M0},
4119b54b47bdSSwapnil Jakhade {0x000E, CMN_PLL0_SS_CTRL4_M0},
4120b54b47bdSSwapnil Jakhade {0x0012, CMN_PLL0_SS_CTRL4_M1},
4121b54b47bdSSwapnil Jakhade {0x0012, CMN_PLL1_SS_CTRL4_M0},
4122b54b47bdSSwapnil Jakhade {0x0C5E, CMN_PLL0_VCOCAL_REFTIM_START},
4123b54b47bdSSwapnil Jakhade {0x0C5E, CMN_PLL1_VCOCAL_REFTIM_START},
4124b54b47bdSSwapnil Jakhade {0x0C56, CMN_PLL0_VCOCAL_PLLCNT_START},
4125b54b47bdSSwapnil Jakhade {0x0C56, CMN_PLL1_VCOCAL_PLLCNT_START},
4126b54b47bdSSwapnil Jakhade {0x00C7, CMN_PLL0_LOCK_REFCNT_START},
4127b54b47bdSSwapnil Jakhade {0x00C7, CMN_PLL1_LOCK_REFCNT_START},
4128b54b47bdSSwapnil Jakhade {0x00C7, CMN_PLL0_LOCK_PLLCNT_START},
4129b54b47bdSSwapnil Jakhade {0x00C7, CMN_PLL1_LOCK_PLLCNT_START},
4130b54b47bdSSwapnil Jakhade {0x0005, CMN_PLL0_LOCK_PLLCNT_THR},
4131b54b47bdSSwapnil Jakhade {0x0005, CMN_PLL1_LOCK_PLLCNT_THR}
4132b54b47bdSSwapnil Jakhade };
4133b54b47bdSSwapnil Jakhade
4134b54b47bdSSwapnil Jakhade static struct cdns_torrent_vals sl_pcie_100_int_ssc_cmn_vals = {
4135b54b47bdSSwapnil Jakhade .reg_pairs = sl_pcie_100_int_ssc_cmn_regs,
4136b54b47bdSSwapnil Jakhade .num_regs = ARRAY_SIZE(sl_pcie_100_int_ssc_cmn_regs),
4137b54b47bdSSwapnil Jakhade };
4138b54b47bdSSwapnil Jakhade
4139b54b47bdSSwapnil Jakhade /* PCIe, 100 MHz Ref clk, no SSC & external SSC */
4140b54b47bdSSwapnil Jakhade static struct cdns_reg_pairs pcie_100_ext_no_ssc_cmn_regs[] = {
4141e25c9dbcSSwapnil Jakhade {0x0028, CMN_PDIAG_PLL1_CP_PADJ_M0},
4142e25c9dbcSSwapnil Jakhade {0x001E, CMN_PLL1_DSM_FBH_OVRD_M0},
4143e25c9dbcSSwapnil Jakhade {0x000C, CMN_PLL1_DSM_FBL_OVRD_M0}
4144b54b47bdSSwapnil Jakhade };
4145b54b47bdSSwapnil Jakhade
4146b54b47bdSSwapnil Jakhade static struct cdns_reg_pairs pcie_100_ext_no_ssc_rx_ln_regs[] = {
4147b54b47bdSSwapnil Jakhade {0x0019, RX_REE_TAP1_CLIP},
4148b54b47bdSSwapnil Jakhade {0x0019, RX_REE_TAP2TON_CLIP},
4149b54b47bdSSwapnil Jakhade {0x0001, RX_DIAG_ACYA}
4150b54b47bdSSwapnil Jakhade };
4151b54b47bdSSwapnil Jakhade
4152b54b47bdSSwapnil Jakhade static struct cdns_torrent_vals pcie_100_no_ssc_cmn_vals = {
4153b54b47bdSSwapnil Jakhade .reg_pairs = pcie_100_ext_no_ssc_cmn_regs,
4154b54b47bdSSwapnil Jakhade .num_regs = ARRAY_SIZE(pcie_100_ext_no_ssc_cmn_regs),
4155b54b47bdSSwapnil Jakhade };
4156b54b47bdSSwapnil Jakhade
4157b54b47bdSSwapnil Jakhade static struct cdns_torrent_vals pcie_100_no_ssc_rx_ln_vals = {
4158b54b47bdSSwapnil Jakhade .reg_pairs = pcie_100_ext_no_ssc_rx_ln_regs,
4159b54b47bdSSwapnil Jakhade .num_regs = ARRAY_SIZE(pcie_100_ext_no_ssc_rx_ln_regs),
4160b54b47bdSSwapnil Jakhade };
4161b54b47bdSSwapnil Jakhade
4162ebd05f90SRoger Quadros static struct cdns_torrent_vals_entry link_cmn_vals_entries[] = {
4163ebd05f90SRoger Quadros {CDNS_TORRENT_KEY_ANYCLK(TYPE_DP, TYPE_NONE), &sl_dp_link_cmn_vals},
4164ebd05f90SRoger Quadros {CDNS_TORRENT_KEY_ANYCLK(TYPE_DP, TYPE_PCIE), &pcie_dp_link_cmn_vals},
4165ebd05f90SRoger Quadros {CDNS_TORRENT_KEY_ANYCLK(TYPE_DP, TYPE_USB), &usb_dp_link_cmn_vals},
4166ebd05f90SRoger Quadros
4167ebd05f90SRoger Quadros {CDNS_TORRENT_KEY_ANYCLK(TYPE_PCIE, TYPE_NONE), NULL},
4168ebd05f90SRoger Quadros {CDNS_TORRENT_KEY_ANYCLK(TYPE_PCIE, TYPE_SGMII), &pcie_sgmii_link_cmn_vals},
4169ebd05f90SRoger Quadros {CDNS_TORRENT_KEY_ANYCLK(TYPE_PCIE, TYPE_QSGMII), &pcie_sgmii_link_cmn_vals},
4170ebd05f90SRoger Quadros {CDNS_TORRENT_KEY_ANYCLK(TYPE_PCIE, TYPE_USB), &pcie_usb_link_cmn_vals},
4171ebd05f90SRoger Quadros {CDNS_TORRENT_KEY_ANYCLK(TYPE_PCIE, TYPE_DP), &pcie_dp_link_cmn_vals},
4172ebd05f90SRoger Quadros
4173ebd05f90SRoger Quadros {CDNS_TORRENT_KEY_ANYCLK(TYPE_SGMII, TYPE_NONE), &sl_sgmii_link_cmn_vals},
4174ebd05f90SRoger Quadros {CDNS_TORRENT_KEY_ANYCLK(TYPE_SGMII, TYPE_PCIE), &pcie_sgmii_link_cmn_vals},
4175ebd05f90SRoger Quadros {CDNS_TORRENT_KEY_ANYCLK(TYPE_SGMII, TYPE_USB), &usb_sgmii_link_cmn_vals},
4176ebd05f90SRoger Quadros
4177ebd05f90SRoger Quadros {CDNS_TORRENT_KEY_ANYCLK(TYPE_QSGMII, TYPE_NONE), &sl_sgmii_link_cmn_vals},
4178ebd05f90SRoger Quadros {CDNS_TORRENT_KEY_ANYCLK(TYPE_QSGMII, TYPE_PCIE), &pcie_sgmii_link_cmn_vals},
4179ebd05f90SRoger Quadros {CDNS_TORRENT_KEY_ANYCLK(TYPE_QSGMII, TYPE_USB), &usb_sgmii_link_cmn_vals},
4180ebd05f90SRoger Quadros
4181ebd05f90SRoger Quadros {CDNS_TORRENT_KEY_ANYCLK(TYPE_USB, TYPE_NONE), &sl_usb_link_cmn_vals},
4182ebd05f90SRoger Quadros {CDNS_TORRENT_KEY_ANYCLK(TYPE_USB, TYPE_PCIE), &pcie_usb_link_cmn_vals},
4183ebd05f90SRoger Quadros {CDNS_TORRENT_KEY_ANYCLK(TYPE_USB, TYPE_SGMII), &usb_sgmii_link_cmn_vals},
4184ebd05f90SRoger Quadros {CDNS_TORRENT_KEY_ANYCLK(TYPE_USB, TYPE_QSGMII), &usb_sgmii_link_cmn_vals},
4185ebd05f90SRoger Quadros {CDNS_TORRENT_KEY_ANYCLK(TYPE_USB, TYPE_DP), &usb_dp_link_cmn_vals},
4186ebd05f90SRoger Quadros
4187ebd05f90SRoger Quadros {CDNS_TORRENT_KEY_ANYCLK(TYPE_USXGMII, TYPE_NONE), &sl_usxgmii_link_cmn_vals},
4188ebd05f90SRoger Quadros };
4189ebd05f90SRoger Quadros
4190ebd05f90SRoger Quadros static struct cdns_torrent_vals_entry xcvr_diag_vals_entries[] = {
4191ebd05f90SRoger Quadros {CDNS_TORRENT_KEY_ANYCLK(TYPE_DP, TYPE_NONE), &sl_dp_xcvr_diag_ln_vals},
4192ebd05f90SRoger Quadros {CDNS_TORRENT_KEY_ANYCLK(TYPE_DP, TYPE_PCIE), &dp_pcie_xcvr_diag_ln_vals},
4193ebd05f90SRoger Quadros {CDNS_TORRENT_KEY_ANYCLK(TYPE_DP, TYPE_USB), &dp_usb_xcvr_diag_ln_vals},
4194ebd05f90SRoger Quadros
4195ebd05f90SRoger Quadros {CDNS_TORRENT_KEY_ANYCLK(TYPE_PCIE, TYPE_NONE), NULL},
4196ebd05f90SRoger Quadros {CDNS_TORRENT_KEY_ANYCLK(TYPE_PCIE, TYPE_SGMII), &pcie_sgmii_xcvr_diag_ln_vals},
4197ebd05f90SRoger Quadros {CDNS_TORRENT_KEY_ANYCLK(TYPE_PCIE, TYPE_QSGMII), &pcie_sgmii_xcvr_diag_ln_vals},
4198ebd05f90SRoger Quadros {CDNS_TORRENT_KEY_ANYCLK(TYPE_PCIE, TYPE_USB), &pcie_usb_xcvr_diag_ln_vals},
4199ebd05f90SRoger Quadros {CDNS_TORRENT_KEY_ANYCLK(TYPE_PCIE, TYPE_DP), &pcie_dp_xcvr_diag_ln_vals},
4200ebd05f90SRoger Quadros
4201ebd05f90SRoger Quadros {CDNS_TORRENT_KEY_ANYCLK(TYPE_SGMII, TYPE_NONE), &sl_sgmii_xcvr_diag_ln_vals},
4202ebd05f90SRoger Quadros {CDNS_TORRENT_KEY_ANYCLK(TYPE_SGMII, TYPE_PCIE), &sgmii_pcie_xcvr_diag_ln_vals},
4203ebd05f90SRoger Quadros {CDNS_TORRENT_KEY_ANYCLK(TYPE_SGMII, TYPE_USB), &sgmii_usb_xcvr_diag_ln_vals},
4204ebd05f90SRoger Quadros
4205ebd05f90SRoger Quadros {CDNS_TORRENT_KEY_ANYCLK(TYPE_QSGMII, TYPE_NONE), &sl_sgmii_xcvr_diag_ln_vals},
4206ebd05f90SRoger Quadros {CDNS_TORRENT_KEY_ANYCLK(TYPE_QSGMII, TYPE_PCIE), &sgmii_pcie_xcvr_diag_ln_vals},
4207ebd05f90SRoger Quadros {CDNS_TORRENT_KEY_ANYCLK(TYPE_QSGMII, TYPE_USB), &sgmii_usb_xcvr_diag_ln_vals},
4208ebd05f90SRoger Quadros
4209ebd05f90SRoger Quadros {CDNS_TORRENT_KEY_ANYCLK(TYPE_USB, TYPE_NONE), &sl_usb_xcvr_diag_ln_vals},
4210ebd05f90SRoger Quadros {CDNS_TORRENT_KEY_ANYCLK(TYPE_USB, TYPE_PCIE), &usb_pcie_xcvr_diag_ln_vals},
4211ebd05f90SRoger Quadros {CDNS_TORRENT_KEY_ANYCLK(TYPE_USB, TYPE_SGMII), &usb_sgmii_xcvr_diag_ln_vals},
4212ebd05f90SRoger Quadros {CDNS_TORRENT_KEY_ANYCLK(TYPE_USB, TYPE_QSGMII), &usb_sgmii_xcvr_diag_ln_vals},
4213ebd05f90SRoger Quadros {CDNS_TORRENT_KEY_ANYCLK(TYPE_USB, TYPE_DP), &usb_dp_xcvr_diag_ln_vals},
4214ebd05f90SRoger Quadros
4215ebd05f90SRoger Quadros {CDNS_TORRENT_KEY_ANYCLK(TYPE_USXGMII, TYPE_NONE), &sl_usxgmii_xcvr_diag_ln_vals},
4216ebd05f90SRoger Quadros };
4217ebd05f90SRoger Quadros
4218ebd05f90SRoger Quadros static struct cdns_torrent_vals_entry pcs_cmn_vals_entries[] = {
4219ebd05f90SRoger Quadros {CDNS_TORRENT_KEY_ANYCLK(TYPE_USB, TYPE_NONE), &usb_phy_pcs_cmn_vals},
4220ebd05f90SRoger Quadros {CDNS_TORRENT_KEY_ANYCLK(TYPE_USB, TYPE_PCIE), &usb_phy_pcs_cmn_vals},
4221ebd05f90SRoger Quadros {CDNS_TORRENT_KEY_ANYCLK(TYPE_USB, TYPE_SGMII), &usb_phy_pcs_cmn_vals},
4222ebd05f90SRoger Quadros {CDNS_TORRENT_KEY_ANYCLK(TYPE_USB, TYPE_QSGMII), &usb_phy_pcs_cmn_vals},
4223ebd05f90SRoger Quadros {CDNS_TORRENT_KEY_ANYCLK(TYPE_USB, TYPE_DP), &usb_phy_pcs_cmn_vals},
4224ebd05f90SRoger Quadros };
4225ebd05f90SRoger Quadros
4226ebd05f90SRoger Quadros static struct cdns_torrent_vals_entry cmn_vals_entries[] = {
4227ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_19_2_MHZ, CLK_19_2_MHZ, TYPE_DP, TYPE_NONE, NO_SSC), &sl_dp_19_2_no_ssc_cmn_vals},
4228ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_25_MHZ, CLK_25_MHZ, TYPE_DP, TYPE_NONE, NO_SSC), &sl_dp_25_no_ssc_cmn_vals},
4229ebd05f90SRoger Quadros
4230ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_DP, TYPE_NONE, NO_SSC), &sl_dp_100_no_ssc_cmn_vals},
4231ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_DP, TYPE_PCIE, NO_SSC), &dp_100_no_ssc_cmn_vals},
4232ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_DP, TYPE_USB, NO_SSC), &sl_dp_100_no_ssc_cmn_vals},
4233ebd05f90SRoger Quadros
4234ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_NONE, NO_SSC), NULL},
4235ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_NONE, EXTERNAL_SSC), NULL},
4236ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_NONE, INTERNAL_SSC), &sl_pcie_100_int_ssc_cmn_vals},
4237ebd05f90SRoger Quadros
4238ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_SGMII, NO_SSC), &pcie_100_no_ssc_cmn_vals},
4239ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_SGMII, EXTERNAL_SSC), &pcie_100_no_ssc_cmn_vals},
4240ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_SGMII, INTERNAL_SSC), &pcie_100_int_ssc_cmn_vals},
4241ebd05f90SRoger Quadros
4242ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_QSGMII, NO_SSC), &pcie_100_no_ssc_cmn_vals},
4243ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_QSGMII, EXTERNAL_SSC), &pcie_100_no_ssc_cmn_vals},
4244ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_QSGMII, INTERNAL_SSC), &pcie_100_int_ssc_cmn_vals},
4245ebd05f90SRoger Quadros
4246ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_USB, NO_SSC), &pcie_100_no_ssc_cmn_vals},
4247ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_USB, EXTERNAL_SSC), &pcie_100_no_ssc_cmn_vals},
4248ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_USB, INTERNAL_SSC), &pcie_100_int_ssc_cmn_vals},
4249ebd05f90SRoger Quadros
4250ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_DP, NO_SSC), NULL},
4251ebd05f90SRoger Quadros
4252ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_NONE, NO_SSC), &sl_sgmii_100_no_ssc_cmn_vals},
4253ebd05f90SRoger Quadros
4254ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_PCIE, NO_SSC), &sgmii_100_no_ssc_cmn_vals},
4255ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_PCIE, EXTERNAL_SSC), &sgmii_100_no_ssc_cmn_vals},
4256ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_PCIE, INTERNAL_SSC), &sgmii_100_int_ssc_cmn_vals},
4257ebd05f90SRoger Quadros
4258ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_USB, NO_SSC), &sgmii_100_no_ssc_cmn_vals},
4259ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_USB, EXTERNAL_SSC), &sgmii_100_no_ssc_cmn_vals},
4260ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_USB, INTERNAL_SSC), &sgmii_100_no_ssc_cmn_vals},
4261ebd05f90SRoger Quadros
4262ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_NONE, NO_SSC), &sl_qsgmii_100_no_ssc_cmn_vals},
4263ebd05f90SRoger Quadros
4264ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_PCIE, NO_SSC), &qsgmii_100_no_ssc_cmn_vals},
4265ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_PCIE, EXTERNAL_SSC), &qsgmii_100_no_ssc_cmn_vals},
4266ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_PCIE, INTERNAL_SSC), &qsgmii_100_int_ssc_cmn_vals},
4267ebd05f90SRoger Quadros
4268ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_USB, NO_SSC), &qsgmii_100_no_ssc_cmn_vals},
4269ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_USB, EXTERNAL_SSC), &qsgmii_100_no_ssc_cmn_vals},
4270ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_USB, INTERNAL_SSC), &qsgmii_100_no_ssc_cmn_vals},
4271ebd05f90SRoger Quadros
4272ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_NONE, NO_SSC), &sl_usb_100_no_ssc_cmn_vals},
4273ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_NONE, EXTERNAL_SSC), &sl_usb_100_no_ssc_cmn_vals},
4274ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_NONE, INTERNAL_SSC), &sl_usb_100_int_ssc_cmn_vals},
4275ebd05f90SRoger Quadros
4276ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_PCIE, NO_SSC), &usb_100_no_ssc_cmn_vals},
4277ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_PCIE, EXTERNAL_SSC), &usb_100_no_ssc_cmn_vals},
4278ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_PCIE, INTERNAL_SSC), &usb_100_int_ssc_cmn_vals},
4279ebd05f90SRoger Quadros
4280ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_SGMII, NO_SSC), &sl_usb_100_no_ssc_cmn_vals},
4281ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_SGMII, EXTERNAL_SSC), &sl_usb_100_no_ssc_cmn_vals},
4282ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_SGMII, INTERNAL_SSC), &sl_usb_100_int_ssc_cmn_vals},
4283ebd05f90SRoger Quadros
4284ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_QSGMII, NO_SSC), &sl_usb_100_no_ssc_cmn_vals},
4285ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_QSGMII, EXTERNAL_SSC), &sl_usb_100_no_ssc_cmn_vals},
4286ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_QSGMII, INTERNAL_SSC), &sl_usb_100_int_ssc_cmn_vals},
4287ebd05f90SRoger Quadros
4288ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_DP, NO_SSC), &usb_100_no_ssc_cmn_vals},
4289ebd05f90SRoger Quadros
4290ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_156_25_MHZ, CLK_156_25_MHZ, TYPE_USXGMII, TYPE_NONE, NO_SSC), &sl_usxgmii_156_25_no_ssc_cmn_vals},
4291ebd05f90SRoger Quadros };
4292ebd05f90SRoger Quadros
4293ebd05f90SRoger Quadros static struct cdns_torrent_vals_entry cdns_tx_ln_vals_entries[] = {
4294ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_19_2_MHZ, CLK_19_2_MHZ, TYPE_DP, TYPE_NONE, NO_SSC), &sl_dp_19_2_no_ssc_tx_ln_vals},
4295ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_25_MHZ, CLK_25_MHZ, TYPE_DP, TYPE_NONE, NO_SSC), &sl_dp_25_no_ssc_tx_ln_vals},
4296ebd05f90SRoger Quadros
4297ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_DP, TYPE_NONE, NO_SSC), &sl_dp_100_no_ssc_tx_ln_vals},
4298ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_DP, TYPE_PCIE, NO_SSC), &dp_100_no_ssc_tx_ln_vals},
4299ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_DP, TYPE_USB, NO_SSC), &dp_100_no_ssc_tx_ln_vals},
4300ebd05f90SRoger Quadros
4301ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_NONE, NO_SSC), NULL},
4302ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_NONE, EXTERNAL_SSC), NULL},
4303ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_NONE, INTERNAL_SSC), NULL},
4304ebd05f90SRoger Quadros
4305ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_SGMII, NO_SSC), NULL},
4306ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_SGMII, EXTERNAL_SSC), NULL},
4307ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_SGMII, INTERNAL_SSC), NULL},
4308ebd05f90SRoger Quadros
4309ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_QSGMII, NO_SSC), NULL},
4310ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_QSGMII, EXTERNAL_SSC), NULL},
4311ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_QSGMII, INTERNAL_SSC), NULL},
4312ebd05f90SRoger Quadros
4313ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_USB, NO_SSC), NULL},
4314ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_USB, EXTERNAL_SSC), NULL},
4315ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_USB, INTERNAL_SSC), NULL},
4316ebd05f90SRoger Quadros
4317ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_DP, NO_SSC), NULL},
4318ebd05f90SRoger Quadros
4319ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_NONE, NO_SSC), &sgmii_100_no_ssc_tx_ln_vals},
4320ebd05f90SRoger Quadros
4321ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_PCIE, NO_SSC), &sgmii_100_no_ssc_tx_ln_vals},
4322ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_PCIE, EXTERNAL_SSC), &sgmii_100_no_ssc_tx_ln_vals},
4323ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_PCIE, INTERNAL_SSC), &sgmii_100_no_ssc_tx_ln_vals},
4324ebd05f90SRoger Quadros
4325ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_USB, NO_SSC), &sgmii_100_no_ssc_tx_ln_vals},
4326ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_USB, EXTERNAL_SSC), &sgmii_100_no_ssc_tx_ln_vals},
4327ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_USB, INTERNAL_SSC), &sgmii_100_no_ssc_tx_ln_vals},
4328ebd05f90SRoger Quadros
4329ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_NONE, NO_SSC), &qsgmii_100_no_ssc_tx_ln_vals},
4330ebd05f90SRoger Quadros
4331ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_PCIE, NO_SSC), &qsgmii_100_no_ssc_tx_ln_vals},
4332ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_PCIE, EXTERNAL_SSC), &qsgmii_100_no_ssc_tx_ln_vals},
4333ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_PCIE, INTERNAL_SSC), &qsgmii_100_no_ssc_tx_ln_vals},
4334ebd05f90SRoger Quadros
4335ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_USB, NO_SSC), &qsgmii_100_no_ssc_tx_ln_vals},
4336ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_USB, EXTERNAL_SSC), &qsgmii_100_no_ssc_tx_ln_vals},
4337ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_USB, INTERNAL_SSC), &qsgmii_100_no_ssc_tx_ln_vals},
4338ebd05f90SRoger Quadros
4339ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_NONE, NO_SSC), &usb_100_no_ssc_tx_ln_vals},
4340ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_NONE, EXTERNAL_SSC), &usb_100_no_ssc_tx_ln_vals},
4341ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_NONE, INTERNAL_SSC), &usb_100_no_ssc_tx_ln_vals},
4342ebd05f90SRoger Quadros
4343ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_PCIE, NO_SSC), &usb_100_no_ssc_tx_ln_vals},
4344ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_PCIE, EXTERNAL_SSC), &usb_100_no_ssc_tx_ln_vals},
4345ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_PCIE, INTERNAL_SSC), &usb_100_no_ssc_tx_ln_vals},
4346ebd05f90SRoger Quadros
4347ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_SGMII, NO_SSC), &usb_100_no_ssc_tx_ln_vals},
4348ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_SGMII, EXTERNAL_SSC), &usb_100_no_ssc_tx_ln_vals},
4349ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_SGMII, INTERNAL_SSC), &usb_100_no_ssc_tx_ln_vals},
4350ebd05f90SRoger Quadros
4351ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_QSGMII, NO_SSC), &usb_100_no_ssc_tx_ln_vals},
4352ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_QSGMII, EXTERNAL_SSC), &usb_100_no_ssc_tx_ln_vals},
4353ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_QSGMII, INTERNAL_SSC), &usb_100_no_ssc_tx_ln_vals},
4354ebd05f90SRoger Quadros
4355ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_DP, NO_SSC), &usb_100_no_ssc_tx_ln_vals},
4356ebd05f90SRoger Quadros
4357ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_156_25_MHZ, CLK_156_25_MHZ, TYPE_USXGMII, TYPE_NONE, NO_SSC), &usxgmii_156_25_no_ssc_tx_ln_vals},
4358ebd05f90SRoger Quadros };
4359ebd05f90SRoger Quadros
4360ebd05f90SRoger Quadros static struct cdns_torrent_vals_entry cdns_rx_ln_vals_entries[] = {
4361ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_19_2_MHZ, CLK_19_2_MHZ, TYPE_DP, TYPE_NONE, NO_SSC), &sl_dp_19_2_no_ssc_rx_ln_vals},
4362ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_25_MHZ, CLK_25_MHZ, TYPE_DP, TYPE_NONE, NO_SSC), &sl_dp_25_no_ssc_rx_ln_vals},
4363ebd05f90SRoger Quadros
4364ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_DP, TYPE_NONE, NO_SSC), &sl_dp_100_no_ssc_rx_ln_vals},
4365ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_DP, TYPE_PCIE, NO_SSC), &dp_100_no_ssc_rx_ln_vals},
4366ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_DP, TYPE_USB, NO_SSC), &dp_100_no_ssc_rx_ln_vals},
4367ebd05f90SRoger Quadros
4368ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_NONE, NO_SSC), &pcie_100_no_ssc_rx_ln_vals},
4369ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_NONE, EXTERNAL_SSC), &pcie_100_no_ssc_rx_ln_vals},
4370ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_NONE, INTERNAL_SSC), &pcie_100_no_ssc_rx_ln_vals},
4371ebd05f90SRoger Quadros
4372ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_SGMII, NO_SSC), &pcie_100_no_ssc_rx_ln_vals},
4373ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_SGMII, EXTERNAL_SSC), &pcie_100_no_ssc_rx_ln_vals},
4374ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_SGMII, INTERNAL_SSC), &pcie_100_no_ssc_rx_ln_vals},
4375ebd05f90SRoger Quadros
4376ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_QSGMII, NO_SSC), &pcie_100_no_ssc_rx_ln_vals},
4377ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_QSGMII, EXTERNAL_SSC), &pcie_100_no_ssc_rx_ln_vals},
4378ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_QSGMII, INTERNAL_SSC), &pcie_100_no_ssc_rx_ln_vals},
4379ebd05f90SRoger Quadros
4380ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_USB, NO_SSC), &pcie_100_no_ssc_rx_ln_vals},
4381ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_USB, EXTERNAL_SSC), &pcie_100_no_ssc_rx_ln_vals},
4382ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_USB, INTERNAL_SSC), &pcie_100_no_ssc_rx_ln_vals},
4383ebd05f90SRoger Quadros
4384ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_DP, NO_SSC), &pcie_100_no_ssc_rx_ln_vals},
4385ebd05f90SRoger Quadros
4386ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_NONE, NO_SSC), &sgmii_100_no_ssc_rx_ln_vals},
4387ebd05f90SRoger Quadros
4388ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_PCIE, NO_SSC), &sgmii_100_no_ssc_rx_ln_vals},
4389ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_PCIE, EXTERNAL_SSC), &sgmii_100_no_ssc_rx_ln_vals},
4390ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_PCIE, INTERNAL_SSC), &sgmii_100_no_ssc_rx_ln_vals},
4391ebd05f90SRoger Quadros
4392ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_USB, NO_SSC), &sgmii_100_no_ssc_rx_ln_vals},
4393ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_USB, EXTERNAL_SSC), &sgmii_100_no_ssc_rx_ln_vals},
4394ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_USB, INTERNAL_SSC), &sgmii_100_no_ssc_rx_ln_vals},
4395ebd05f90SRoger Quadros
4396ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_NONE, NO_SSC), &qsgmii_100_no_ssc_rx_ln_vals},
4397ebd05f90SRoger Quadros
4398ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_PCIE, NO_SSC), &qsgmii_100_no_ssc_rx_ln_vals},
4399ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_PCIE, EXTERNAL_SSC), &qsgmii_100_no_ssc_rx_ln_vals},
4400ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_PCIE, INTERNAL_SSC), &qsgmii_100_no_ssc_rx_ln_vals},
4401ebd05f90SRoger Quadros
4402ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_USB, NO_SSC), &qsgmii_100_no_ssc_rx_ln_vals},
4403ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_USB, EXTERNAL_SSC), &qsgmii_100_no_ssc_rx_ln_vals},
4404ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_USB, INTERNAL_SSC), &qsgmii_100_no_ssc_rx_ln_vals},
4405ebd05f90SRoger Quadros
4406ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_NONE, NO_SSC), &usb_100_no_ssc_rx_ln_vals},
4407ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_NONE, EXTERNAL_SSC), &usb_100_no_ssc_rx_ln_vals},
4408ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_NONE, INTERNAL_SSC), &usb_100_no_ssc_rx_ln_vals},
4409ebd05f90SRoger Quadros
4410ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_PCIE, NO_SSC), &usb_100_no_ssc_rx_ln_vals},
4411ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_PCIE, EXTERNAL_SSC), &usb_100_no_ssc_rx_ln_vals},
4412ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_PCIE, INTERNAL_SSC), &usb_100_no_ssc_rx_ln_vals},
4413ebd05f90SRoger Quadros
4414ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_SGMII, NO_SSC), &usb_100_no_ssc_rx_ln_vals},
4415ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_SGMII, EXTERNAL_SSC), &usb_100_no_ssc_rx_ln_vals},
4416ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_SGMII, INTERNAL_SSC), &usb_100_no_ssc_rx_ln_vals},
4417ebd05f90SRoger Quadros
4418ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_QSGMII, NO_SSC), &usb_100_no_ssc_rx_ln_vals},
4419ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_QSGMII, EXTERNAL_SSC), &usb_100_no_ssc_rx_ln_vals},
4420ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_QSGMII, INTERNAL_SSC), &usb_100_no_ssc_rx_ln_vals},
4421ebd05f90SRoger Quadros
4422ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_DP, NO_SSC), &usb_100_no_ssc_rx_ln_vals},
4423ebd05f90SRoger Quadros
4424ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_156_25_MHZ, CLK_156_25_MHZ, TYPE_USXGMII, TYPE_NONE, NO_SSC), &usxgmii_156_25_no_ssc_rx_ln_vals},
4425ebd05f90SRoger Quadros };
4426ebd05f90SRoger Quadros
442769d114acSSwapnil Jakhade static const struct cdns_torrent_data cdns_map_torrent = {
442869d114acSSwapnil Jakhade .block_offset_shift = 0x2,
442969d114acSSwapnil Jakhade .reg_offset_shift = 0x2,
4430ebd05f90SRoger Quadros .link_cmn_vals_tbl = {
4431ebd05f90SRoger Quadros .entries = link_cmn_vals_entries,
4432ebd05f90SRoger Quadros .num_entries = ARRAY_SIZE(link_cmn_vals_entries),
4433da055e55SSwapnil Jakhade },
4434ebd05f90SRoger Quadros .xcvr_diag_vals_tbl = {
4435ebd05f90SRoger Quadros .entries = xcvr_diag_vals_entries,
4436ebd05f90SRoger Quadros .num_entries = ARRAY_SIZE(xcvr_diag_vals_entries),
4437ede775a8SSwapnil Jakhade },
4438ebd05f90SRoger Quadros .pcs_cmn_vals_tbl = {
4439ebd05f90SRoger Quadros .entries = pcs_cmn_vals_entries,
4440ebd05f90SRoger Quadros .num_entries = ARRAY_SIZE(pcs_cmn_vals_entries),
444172a5ce33SSwapnil Jakhade },
4442ebd05f90SRoger Quadros .cmn_vals_tbl = {
4443ebd05f90SRoger Quadros .entries = cmn_vals_entries,
4444ebd05f90SRoger Quadros .num_entries = ARRAY_SIZE(cmn_vals_entries),
4445da055e55SSwapnil Jakhade },
4446ebd05f90SRoger Quadros .tx_ln_vals_tbl = {
4447ebd05f90SRoger Quadros .entries = cdns_tx_ln_vals_entries,
4448ebd05f90SRoger Quadros .num_entries = ARRAY_SIZE(cdns_tx_ln_vals_entries),
4449cd9aa947SSwapnil Jakhade },
4450ebd05f90SRoger Quadros .rx_ln_vals_tbl = {
4451ebd05f90SRoger Quadros .entries = cdns_rx_ln_vals_entries,
4452ebd05f90SRoger Quadros .num_entries = ARRAY_SIZE(cdns_rx_ln_vals_entries),
44536bcf3cb3SSwapnil Jakhade },
4454ebd05f90SRoger Quadros };
4455ebd05f90SRoger Quadros
4456ebd05f90SRoger Quadros static struct cdns_torrent_vals_entry j721e_phy_pma_cmn_vals_entries[] = {
4457ebd05f90SRoger Quadros {CDNS_TORRENT_KEY_ANYCLK(TYPE_USXGMII, TYPE_NONE), &ti_usxgmii_phy_pma_cmn_vals},
4458ebd05f90SRoger Quadros };
4459ebd05f90SRoger Quadros
4460ebd05f90SRoger Quadros static struct cdns_torrent_vals_entry ti_tx_ln_vals_entries[] = {
4461ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_19_2_MHZ, CLK_19_2_MHZ, TYPE_DP, TYPE_NONE, NO_SSC), &sl_dp_19_2_no_ssc_tx_ln_vals},
4462ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_25_MHZ, CLK_25_MHZ, TYPE_DP, TYPE_NONE, NO_SSC), &sl_dp_25_no_ssc_tx_ln_vals},
4463ebd05f90SRoger Quadros
4464ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_DP, TYPE_NONE, NO_SSC), &sl_dp_100_no_ssc_tx_ln_vals},
4465ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_DP, TYPE_PCIE, NO_SSC), &dp_100_no_ssc_tx_ln_vals},
4466ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_DP, TYPE_USB, NO_SSC), &dp_100_no_ssc_tx_ln_vals},
4467ebd05f90SRoger Quadros
4468ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_NONE, NO_SSC), NULL},
4469ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_NONE, EXTERNAL_SSC), NULL},
4470ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_NONE, INTERNAL_SSC), NULL},
4471ebd05f90SRoger Quadros
4472ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_SGMII, NO_SSC), NULL},
4473ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_SGMII, EXTERNAL_SSC), NULL},
4474ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_SGMII, INTERNAL_SSC), NULL},
4475ebd05f90SRoger Quadros
4476ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_QSGMII, NO_SSC), NULL},
4477ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_QSGMII, EXTERNAL_SSC), NULL},
4478ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_QSGMII, INTERNAL_SSC), NULL},
4479ebd05f90SRoger Quadros
4480ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_USB, NO_SSC), NULL},
4481ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_USB, EXTERNAL_SSC), NULL},
4482ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_USB, INTERNAL_SSC), NULL},
4483ebd05f90SRoger Quadros
4484ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_PCIE, TYPE_DP, NO_SSC), NULL},
4485ebd05f90SRoger Quadros
4486ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_NONE, NO_SSC), &ti_sgmii_100_no_ssc_tx_ln_vals},
4487ebd05f90SRoger Quadros
4488ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_PCIE, NO_SSC), &ti_sgmii_100_no_ssc_tx_ln_vals},
4489ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_PCIE, EXTERNAL_SSC), &ti_sgmii_100_no_ssc_tx_ln_vals},
4490ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_PCIE, INTERNAL_SSC), &ti_sgmii_100_no_ssc_tx_ln_vals},
4491ebd05f90SRoger Quadros
4492ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_USB, NO_SSC), &ti_sgmii_100_no_ssc_tx_ln_vals},
4493ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_USB, EXTERNAL_SSC), &ti_sgmii_100_no_ssc_tx_ln_vals},
4494ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_SGMII, TYPE_USB, INTERNAL_SSC), &ti_sgmii_100_no_ssc_tx_ln_vals},
4495ebd05f90SRoger Quadros
4496ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_NONE, NO_SSC), &ti_qsgmii_100_no_ssc_tx_ln_vals},
4497ebd05f90SRoger Quadros
4498ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_PCIE, NO_SSC), &ti_qsgmii_100_no_ssc_tx_ln_vals},
4499ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_PCIE, EXTERNAL_SSC), &ti_qsgmii_100_no_ssc_tx_ln_vals},
4500ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_PCIE, INTERNAL_SSC), &ti_qsgmii_100_no_ssc_tx_ln_vals},
4501ebd05f90SRoger Quadros
4502ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_USB, NO_SSC), &ti_qsgmii_100_no_ssc_tx_ln_vals},
4503ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_USB, EXTERNAL_SSC), &ti_qsgmii_100_no_ssc_tx_ln_vals},
4504ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_QSGMII, TYPE_USB, INTERNAL_SSC), &ti_qsgmii_100_no_ssc_tx_ln_vals},
4505ebd05f90SRoger Quadros
4506ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_NONE, NO_SSC), &usb_100_no_ssc_tx_ln_vals},
4507ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_NONE, EXTERNAL_SSC), &usb_100_no_ssc_tx_ln_vals},
4508ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_NONE, INTERNAL_SSC), &usb_100_no_ssc_tx_ln_vals},
4509ebd05f90SRoger Quadros
4510ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_PCIE, NO_SSC), &usb_100_no_ssc_tx_ln_vals},
4511ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_PCIE, EXTERNAL_SSC), &usb_100_no_ssc_tx_ln_vals},
4512ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_PCIE, INTERNAL_SSC), &usb_100_no_ssc_tx_ln_vals},
4513ebd05f90SRoger Quadros
4514ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_SGMII, NO_SSC), &usb_100_no_ssc_tx_ln_vals},
4515ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_SGMII, EXTERNAL_SSC), &usb_100_no_ssc_tx_ln_vals},
4516ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_SGMII, INTERNAL_SSC), &usb_100_no_ssc_tx_ln_vals},
4517ebd05f90SRoger Quadros
4518ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_QSGMII, NO_SSC), &usb_100_no_ssc_tx_ln_vals},
4519ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_QSGMII, EXTERNAL_SSC), &usb_100_no_ssc_tx_ln_vals},
4520ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_QSGMII, INTERNAL_SSC), &usb_100_no_ssc_tx_ln_vals},
4521ebd05f90SRoger Quadros
4522ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_100_MHZ, CLK_100_MHZ, TYPE_USB, TYPE_DP, NO_SSC), &usb_100_no_ssc_tx_ln_vals},
4523ebd05f90SRoger Quadros
4524ebd05f90SRoger Quadros {CDNS_TORRENT_KEY(CLK_156_25_MHZ, CLK_156_25_MHZ, TYPE_USXGMII, TYPE_NONE, NO_SSC), &usxgmii_156_25_no_ssc_tx_ln_vals},
452569d114acSSwapnil Jakhade };
452669d114acSSwapnil Jakhade
4527597bf3f1SSwapnil Jakhade static const struct cdns_torrent_data ti_j721e_map_torrent = {
4528597bf3f1SSwapnil Jakhade .block_offset_shift = 0x0,
4529597bf3f1SSwapnil Jakhade .reg_offset_shift = 0x1,
4530ebd05f90SRoger Quadros .link_cmn_vals_tbl = {
4531ebd05f90SRoger Quadros .entries = link_cmn_vals_entries,
4532ebd05f90SRoger Quadros .num_entries = ARRAY_SIZE(link_cmn_vals_entries),
4533da055e55SSwapnil Jakhade },
4534ebd05f90SRoger Quadros .xcvr_diag_vals_tbl = {
4535ebd05f90SRoger Quadros .entries = xcvr_diag_vals_entries,
4536ebd05f90SRoger Quadros .num_entries = ARRAY_SIZE(xcvr_diag_vals_entries),
4537ede775a8SSwapnil Jakhade },
4538ebd05f90SRoger Quadros .pcs_cmn_vals_tbl = {
4539ebd05f90SRoger Quadros .entries = pcs_cmn_vals_entries,
4540ebd05f90SRoger Quadros .num_entries = ARRAY_SIZE(pcs_cmn_vals_entries),
454172a5ce33SSwapnil Jakhade },
4542ebd05f90SRoger Quadros .phy_pma_cmn_vals_tbl = {
4543ebd05f90SRoger Quadros .entries = j721e_phy_pma_cmn_vals_entries,
4544ebd05f90SRoger Quadros .num_entries = ARRAY_SIZE(j721e_phy_pma_cmn_vals_entries),
4545da055e55SSwapnil Jakhade },
4546ebd05f90SRoger Quadros .cmn_vals_tbl = {
4547ebd05f90SRoger Quadros .entries = cmn_vals_entries,
4548ebd05f90SRoger Quadros .num_entries = ARRAY_SIZE(cmn_vals_entries),
4549cd9aa947SSwapnil Jakhade },
4550ebd05f90SRoger Quadros .tx_ln_vals_tbl = {
4551ebd05f90SRoger Quadros .entries = ti_tx_ln_vals_entries,
4552ebd05f90SRoger Quadros .num_entries = ARRAY_SIZE(ti_tx_ln_vals_entries),
45536bcf3cb3SSwapnil Jakhade },
4554ebd05f90SRoger Quadros .rx_ln_vals_tbl = {
4555ebd05f90SRoger Quadros .entries = cdns_rx_ln_vals_entries,
4556ebd05f90SRoger Quadros .num_entries = ARRAY_SIZE(cdns_rx_ln_vals_entries),
45576a2338a5SSwapnil Jakhade },
4558597bf3f1SSwapnil Jakhade };
4559597bf3f1SSwapnil Jakhade
456092e9ccc6SSwapnil Jakhade static const struct of_device_id cdns_torrent_phy_of_match[] = {
4561c589e701SYuti Amonkar {
456269d114acSSwapnil Jakhade .compatible = "cdns,torrent-phy",
456369d114acSSwapnil Jakhade .data = &cdns_map_torrent,
4564c589e701SYuti Amonkar },
4565597bf3f1SSwapnil Jakhade {
4566597bf3f1SSwapnil Jakhade .compatible = "ti,j721e-serdes-10g",
4567597bf3f1SSwapnil Jakhade .data = &ti_j721e_map_torrent,
4568597bf3f1SSwapnil Jakhade },
4569c589e701SYuti Amonkar {}
4570c589e701SYuti Amonkar };
457192e9ccc6SSwapnil Jakhade MODULE_DEVICE_TABLE(of, cdns_torrent_phy_of_match);
4572c589e701SYuti Amonkar
457392e9ccc6SSwapnil Jakhade static struct platform_driver cdns_torrent_phy_driver = {
457492e9ccc6SSwapnil Jakhade .probe = cdns_torrent_phy_probe,
4575e758fbbcSUwe Kleine-König .remove_new = cdns_torrent_phy_remove,
4576c589e701SYuti Amonkar .driver = {
457792e9ccc6SSwapnil Jakhade .name = "cdns-torrent-phy",
457892e9ccc6SSwapnil Jakhade .of_match_table = cdns_torrent_phy_of_match,
4579c589e701SYuti Amonkar }
4580c589e701SYuti Amonkar };
458192e9ccc6SSwapnil Jakhade module_platform_driver(cdns_torrent_phy_driver);
4582c589e701SYuti Amonkar
4583c589e701SYuti Amonkar MODULE_AUTHOR("Cadence Design Systems, Inc.");
458492e9ccc6SSwapnil Jakhade MODULE_DESCRIPTION("Cadence Torrent PHY driver");
4585c589e701SYuti Amonkar MODULE_LICENSE("GPL v2");
4586