144d30d62SAlan Douglas // SPDX-License-Identifier: GPL-2.0 244d30d62SAlan Douglas /* 344d30d62SAlan Douglas * Cadence Sierra PHY Driver 444d30d62SAlan Douglas * 544d30d62SAlan Douglas * Copyright (c) 2018 Cadence Design Systems 644d30d62SAlan Douglas * Author: Alan Douglas <adouglas@cadence.com> 744d30d62SAlan Douglas * 844d30d62SAlan Douglas */ 944d30d62SAlan Douglas #include <linux/clk.h> 1028081b72SKishon Vijay Abraham I #include <linux/clk-provider.h> 1144d30d62SAlan Douglas #include <linux/delay.h> 1244d30d62SAlan Douglas #include <linux/err.h> 1344d30d62SAlan Douglas #include <linux/io.h> 1444d30d62SAlan Douglas #include <linux/module.h> 1544d30d62SAlan Douglas #include <linux/phy/phy.h> 1644d30d62SAlan Douglas #include <linux/platform_device.h> 1744d30d62SAlan Douglas #include <linux/pm_runtime.h> 1844d30d62SAlan Douglas #include <linux/regmap.h> 1944d30d62SAlan Douglas #include <linux/reset.h> 2044d30d62SAlan Douglas #include <linux/slab.h> 2144d30d62SAlan Douglas #include <linux/of.h> 2244d30d62SAlan Douglas #include <linux/of_platform.h> 2344d30d62SAlan Douglas #include <dt-bindings/phy/phy.h> 2428081b72SKishon Vijay Abraham I #include <dt-bindings/phy/phy-cadence.h> 2544d30d62SAlan Douglas 26078e9e92SSwapnil Jakhade #define NUM_SSC_MODE 3 276b81f05aSSwapnil Jakhade #define NUM_PHY_TYPE 4 28078e9e92SSwapnil Jakhade 2944d30d62SAlan Douglas /* PHY register offsets */ 30380f5708SKishon Vijay Abraham I #define SIERRA_COMMON_CDB_OFFSET 0x0 31380f5708SKishon Vijay Abraham I #define SIERRA_MACRO_ID_REG 0x0 3228081b72SKishon Vijay Abraham I #define SIERRA_CMN_PLLLC_GEN_PREG 0x42 33871002d7SAnil Varughese #define SIERRA_CMN_PLLLC_MODE_PREG 0x48 34871002d7SAnil Varughese #define SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG 0x49 35871002d7SAnil Varughese #define SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG 0x4A 36871002d7SAnil Varughese #define SIERRA_CMN_PLLLC_LOCK_CNTSTART_PREG 0x4B 37*09d976b3SSwapnil Jakhade #define SIERRA_CMN_PLLLC_CLK1_PREG 0x4D 38871002d7SAnil Varughese #define SIERRA_CMN_PLLLC_BWCAL_MODE1_PREG 0x4F 39871002d7SAnil Varughese #define SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG 0x50 407a5ad9b4SSwapnil Jakhade #define SIERRA_CMN_PLLLC_DSMCORR_PREG 0x51 417a5ad9b4SSwapnil Jakhade #define SIERRA_CMN_PLLLC_SS_PREG 0x52 427a5ad9b4SSwapnil Jakhade #define SIERRA_CMN_PLLLC_SS_AMP_STEP_SIZE_PREG 0x53 437a5ad9b4SSwapnil Jakhade #define SIERRA_CMN_PLLLC_SSTWOPT_PREG 0x54 44871002d7SAnil Varughese #define SIERRA_CMN_PLLLC_SS_TIME_STEPSIZE_MODE_PREG 0x62 457a5ad9b4SSwapnil Jakhade #define SIERRA_CMN_PLLLC_LOCK_DELAY_CTRL_PREG 0x63 4628081b72SKishon Vijay Abraham I #define SIERRA_CMN_REFRCV_PREG 0x98 4728081b72SKishon Vijay Abraham I #define SIERRA_CMN_REFRCV1_PREG 0xB8 4828081b72SKishon Vijay Abraham I #define SIERRA_CMN_PLLLC1_GEN_PREG 0xC2 498a1b82d7SSwapnil Jakhade #define SIERRA_CMN_PLLLC1_LF_COEFF_MODE0_PREG 0xCA 508a1b82d7SSwapnil Jakhade #define SIERRA_CMN_PLLLC1_BWCAL_MODE0_PREG 0xD0 518a1b82d7SSwapnil Jakhade #define SIERRA_CMN_PLLLC1_SS_TIME_STEPSIZE_MODE_PREG 0xE2 52380f5708SKishon Vijay Abraham I 53380f5708SKishon Vijay Abraham I #define SIERRA_LANE_CDB_OFFSET(ln, block_offset, reg_offset) \ 54380f5708SKishon Vijay Abraham I ((0x4000 << (block_offset)) + \ 55380f5708SKishon Vijay Abraham I (((ln) << 9) << (reg_offset))) 56aead5fd6SKishon Vijay Abraham I 57aead5fd6SKishon Vijay Abraham I #define SIERRA_DET_STANDEC_A_PREG 0x000 58aead5fd6SKishon Vijay Abraham I #define SIERRA_DET_STANDEC_B_PREG 0x001 59aead5fd6SKishon Vijay Abraham I #define SIERRA_DET_STANDEC_C_PREG 0x002 60aead5fd6SKishon Vijay Abraham I #define SIERRA_DET_STANDEC_D_PREG 0x003 61aead5fd6SKishon Vijay Abraham I #define SIERRA_DET_STANDEC_E_PREG 0x004 62871002d7SAnil Varughese #define SIERRA_PSM_LANECAL_DLY_A1_RESETS_PREG 0x008 63871002d7SAnil Varughese #define SIERRA_PSM_A0IN_TMR_PREG 0x009 647a5ad9b4SSwapnil Jakhade #define SIERRA_PSM_A3IN_TMR_PREG 0x00C 65aead5fd6SKishon Vijay Abraham I #define SIERRA_PSM_DIAG_PREG 0x015 668a1b82d7SSwapnil Jakhade #define SIERRA_PSC_LN_A3_PREG 0x023 678a1b82d7SSwapnil Jakhade #define SIERRA_PSC_LN_A4_PREG 0x024 688a1b82d7SSwapnil Jakhade #define SIERRA_PSC_LN_IDLE_PREG 0x026 69aead5fd6SKishon Vijay Abraham I #define SIERRA_PSC_TX_A0_PREG 0x028 70aead5fd6SKishon Vijay Abraham I #define SIERRA_PSC_TX_A1_PREG 0x029 71aead5fd6SKishon Vijay Abraham I #define SIERRA_PSC_TX_A2_PREG 0x02A 72aead5fd6SKishon Vijay Abraham I #define SIERRA_PSC_TX_A3_PREG 0x02B 73aead5fd6SKishon Vijay Abraham I #define SIERRA_PSC_RX_A0_PREG 0x030 74aead5fd6SKishon Vijay Abraham I #define SIERRA_PSC_RX_A1_PREG 0x031 75aead5fd6SKishon Vijay Abraham I #define SIERRA_PSC_RX_A2_PREG 0x032 76aead5fd6SKishon Vijay Abraham I #define SIERRA_PSC_RX_A3_PREG 0x033 77aead5fd6SKishon Vijay Abraham I #define SIERRA_PLLCTRL_SUBRATE_PREG 0x03A 788a1b82d7SSwapnil Jakhade #define SIERRA_PLLCTRL_GEN_A_PREG 0x03B 79aead5fd6SKishon Vijay Abraham I #define SIERRA_PLLCTRL_GEN_D_PREG 0x03E 80871002d7SAnil Varughese #define SIERRA_PLLCTRL_CPGAIN_MODE_PREG 0x03F 81adc4bd6fSKishon Vijay Abraham I #define SIERRA_PLLCTRL_STATUS_PREG 0x044 82871002d7SAnil Varughese #define SIERRA_CLKPATH_BIASTRIM_PREG 0x04B 83871002d7SAnil Varughese #define SIERRA_DFE_BIASTRIM_PREG 0x04C 84aead5fd6SKishon Vijay Abraham I #define SIERRA_DRVCTRL_ATTEN_PREG 0x06A 857a5ad9b4SSwapnil Jakhade #define SIERRA_DRVCTRL_BOOST_PREG 0x06F 86aead5fd6SKishon Vijay Abraham I #define SIERRA_CLKPATHCTRL_TMR_PREG 0x081 87871002d7SAnil Varughese #define SIERRA_RX_CREQ_FLTR_A_MODE3_PREG 0x085 88871002d7SAnil Varughese #define SIERRA_RX_CREQ_FLTR_A_MODE2_PREG 0x086 89aead5fd6SKishon Vijay Abraham I #define SIERRA_RX_CREQ_FLTR_A_MODE1_PREG 0x087 90aead5fd6SKishon Vijay Abraham I #define SIERRA_RX_CREQ_FLTR_A_MODE0_PREG 0x088 917a5ad9b4SSwapnil Jakhade #define SIERRA_CREQ_DCBIASATTEN_OVR_PREG 0x08C 92aead5fd6SKishon Vijay Abraham I #define SIERRA_CREQ_CCLKDET_MODE01_PREG 0x08E 937a5ad9b4SSwapnil Jakhade #define SIERRA_RX_CTLE_CAL_PREG 0x08F 94aead5fd6SKishon Vijay Abraham I #define SIERRA_RX_CTLE_MAINTENANCE_PREG 0x091 95aead5fd6SKishon Vijay Abraham I #define SIERRA_CREQ_FSMCLK_SEL_PREG 0x092 96871002d7SAnil Varughese #define SIERRA_CREQ_EQ_CTRL_PREG 0x093 97871002d7SAnil Varughese #define SIERRA_CREQ_SPARE_PREG 0x096 98871002d7SAnil Varughese #define SIERRA_CREQ_EQ_OPEN_EYE_THRESH_PREG 0x097 99aead5fd6SKishon Vijay Abraham I #define SIERRA_CTLELUT_CTRL_PREG 0x098 100aead5fd6SKishon Vijay Abraham I #define SIERRA_DFE_ECMP_RATESEL_PREG 0x0C0 101aead5fd6SKishon Vijay Abraham I #define SIERRA_DFE_SMP_RATESEL_PREG 0x0C1 102871002d7SAnil Varughese #define SIERRA_DEQ_PHALIGN_CTRL 0x0C4 103871002d7SAnil Varughese #define SIERRA_DEQ_CONCUR_CTRL1_PREG 0x0C8 104871002d7SAnil Varughese #define SIERRA_DEQ_CONCUR_CTRL2_PREG 0x0C9 105871002d7SAnil Varughese #define SIERRA_DEQ_EPIPWR_CTRL2_PREG 0x0CD 106871002d7SAnil Varughese #define SIERRA_DEQ_FAST_MAINT_CYCLES_PREG 0x0CE 107871002d7SAnil Varughese #define SIERRA_DEQ_ERRCMP_CTRL_PREG 0x0D0 108871002d7SAnil Varughese #define SIERRA_DEQ_OFFSET_CTRL_PREG 0x0D8 109871002d7SAnil Varughese #define SIERRA_DEQ_GAIN_CTRL_PREG 0x0E0 110aead5fd6SKishon Vijay Abraham I #define SIERRA_DEQ_VGATUNE_CTRL_PREG 0x0E1 111871002d7SAnil Varughese #define SIERRA_DEQ_GLUT0 0x0E8 112871002d7SAnil Varughese #define SIERRA_DEQ_GLUT1 0x0E9 113871002d7SAnil Varughese #define SIERRA_DEQ_GLUT2 0x0EA 114871002d7SAnil Varughese #define SIERRA_DEQ_GLUT3 0x0EB 115871002d7SAnil Varughese #define SIERRA_DEQ_GLUT4 0x0EC 116871002d7SAnil Varughese #define SIERRA_DEQ_GLUT5 0x0ED 117871002d7SAnil Varughese #define SIERRA_DEQ_GLUT6 0x0EE 118871002d7SAnil Varughese #define SIERRA_DEQ_GLUT7 0x0EF 119871002d7SAnil Varughese #define SIERRA_DEQ_GLUT8 0x0F0 120871002d7SAnil Varughese #define SIERRA_DEQ_GLUT9 0x0F1 121871002d7SAnil Varughese #define SIERRA_DEQ_GLUT10 0x0F2 122871002d7SAnil Varughese #define SIERRA_DEQ_GLUT11 0x0F3 123871002d7SAnil Varughese #define SIERRA_DEQ_GLUT12 0x0F4 124871002d7SAnil Varughese #define SIERRA_DEQ_GLUT13 0x0F5 125871002d7SAnil Varughese #define SIERRA_DEQ_GLUT14 0x0F6 126871002d7SAnil Varughese #define SIERRA_DEQ_GLUT15 0x0F7 127871002d7SAnil Varughese #define SIERRA_DEQ_GLUT16 0x0F8 128871002d7SAnil Varughese #define SIERRA_DEQ_ALUT0 0x108 129871002d7SAnil Varughese #define SIERRA_DEQ_ALUT1 0x109 130871002d7SAnil Varughese #define SIERRA_DEQ_ALUT2 0x10A 131871002d7SAnil Varughese #define SIERRA_DEQ_ALUT3 0x10B 132871002d7SAnil Varughese #define SIERRA_DEQ_ALUT4 0x10C 133871002d7SAnil Varughese #define SIERRA_DEQ_ALUT5 0x10D 134871002d7SAnil Varughese #define SIERRA_DEQ_ALUT6 0x10E 135871002d7SAnil Varughese #define SIERRA_DEQ_ALUT7 0x10F 136871002d7SAnil Varughese #define SIERRA_DEQ_ALUT8 0x110 137871002d7SAnil Varughese #define SIERRA_DEQ_ALUT9 0x111 138871002d7SAnil Varughese #define SIERRA_DEQ_ALUT10 0x112 139871002d7SAnil Varughese #define SIERRA_DEQ_ALUT11 0x113 140871002d7SAnil Varughese #define SIERRA_DEQ_ALUT12 0x114 141871002d7SAnil Varughese #define SIERRA_DEQ_ALUT13 0x115 142871002d7SAnil Varughese #define SIERRA_DEQ_DFETAP_CTRL_PREG 0x128 1437a5ad9b4SSwapnil Jakhade #define SIERRA_DEQ_DFETAP0 0x129 1447a5ad9b4SSwapnil Jakhade #define SIERRA_DEQ_DFETAP1 0x12B 1457a5ad9b4SSwapnil Jakhade #define SIERRA_DEQ_DFETAP2 0x12D 1467a5ad9b4SSwapnil Jakhade #define SIERRA_DEQ_DFETAP3 0x12F 1477a5ad9b4SSwapnil Jakhade #define SIERRA_DEQ_DFETAP4 0x131 148871002d7SAnil Varughese #define SIERRA_DFE_EN_1010_IGNORE_PREG 0x134 1497a5ad9b4SSwapnil Jakhade #define SIERRA_DEQ_PRECUR_PREG 0x138 1507a5ad9b4SSwapnil Jakhade #define SIERRA_DEQ_POSTCUR_PREG 0x140 1517a5ad9b4SSwapnil Jakhade #define SIERRA_DEQ_POSTCUR_DECR_PREG 0x142 152871002d7SAnil Varughese #define SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG 0x150 153871002d7SAnil Varughese #define SIERRA_DEQ_TAU_CTRL2_PREG 0x151 1547a5ad9b4SSwapnil Jakhade #define SIERRA_DEQ_TAU_CTRL3_PREG 0x152 1557a5ad9b4SSwapnil Jakhade #define SIERRA_DEQ_OPENEYE_CTRL_PREG 0x158 156871002d7SAnil Varughese #define SIERRA_DEQ_PICTRL_PREG 0x161 157871002d7SAnil Varughese #define SIERRA_CPICAL_TMRVAL_MODE1_PREG 0x170 158871002d7SAnil Varughese #define SIERRA_CPICAL_TMRVAL_MODE0_PREG 0x171 159871002d7SAnil Varughese #define SIERRA_CPICAL_PICNT_MODE1_PREG 0x174 160aead5fd6SKishon Vijay Abraham I #define SIERRA_CPI_OUTBUF_RATESEL_PREG 0x17C 1618a1b82d7SSwapnil Jakhade #define SIERRA_CPI_RESBIAS_BIN_PREG 0x17E 1627a5ad9b4SSwapnil Jakhade #define SIERRA_CPI_TRIM_PREG 0x17F 163871002d7SAnil Varughese #define SIERRA_CPICAL_RES_STARTCODE_MODE23_PREG 0x183 1647a5ad9b4SSwapnil Jakhade #define SIERRA_EPI_CTRL_PREG 0x187 165871002d7SAnil Varughese #define SIERRA_LFPSDET_SUPPORT_PREG 0x188 166aead5fd6SKishon Vijay Abraham I #define SIERRA_LFPSFILT_NS_PREG 0x18A 167aead5fd6SKishon Vijay Abraham I #define SIERRA_LFPSFILT_RD_PREG 0x18B 168aead5fd6SKishon Vijay Abraham I #define SIERRA_LFPSFILT_MP_PREG 0x18C 169871002d7SAnil Varughese #define SIERRA_SIGDET_SUPPORT_PREG 0x190 170aead5fd6SKishon Vijay Abraham I #define SIERRA_SDFILT_H2L_A_PREG 0x191 171871002d7SAnil Varughese #define SIERRA_SDFILT_L2H_PREG 0x193 172871002d7SAnil Varughese #define SIERRA_RXBUFFER_CTLECTRL_PREG 0x19E 173871002d7SAnil Varughese #define SIERRA_RXBUFFER_RCDFECTRL_PREG 0x19F 174871002d7SAnil Varughese #define SIERRA_RXBUFFER_DFECTRL_PREG 0x1A0 175871002d7SAnil Varughese #define SIERRA_DEQ_TAU_CTRL1_FAST_MAINT_PREG 0x14F 176871002d7SAnil Varughese #define SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG 0x150 177380f5708SKishon Vijay Abraham I 1788c95e172SSwapnil Jakhade /* PHY PCS common registers */ 1798c95e172SSwapnil Jakhade #define SIERRA_PHY_PCS_COMMON_OFFSET(block_offset) \ 180380f5708SKishon Vijay Abraham I (0xc000 << (block_offset)) 181fa105172SSwapnil Jakhade #define SIERRA_PHY_PIPE_CMN_CTRL1 0x0 182380f5708SKishon Vijay Abraham I #define SIERRA_PHY_PLL_CFG 0xe 18344d30d62SAlan Douglas 18436ce4163SSwapnil Jakhade /* PHY PCS lane registers */ 18536ce4163SSwapnil Jakhade #define SIERRA_PHY_PCS_LANE_CDB_OFFSET(ln, block_offset, reg_offset) \ 18636ce4163SSwapnil Jakhade ((0xD000 << (block_offset)) + \ 18736ce4163SSwapnil Jakhade (((ln) << 8) << (reg_offset))) 18836ce4163SSwapnil Jakhade 18936ce4163SSwapnil Jakhade #define SIERRA_PHY_ISO_LINK_CTRL 0xB 19036ce4163SSwapnil Jakhade 191f1cc6c3fSSwapnil Jakhade /* PHY PMA common registers */ 192f1cc6c3fSSwapnil Jakhade #define SIERRA_PHY_PMA_COMMON_OFFSET(block_offset) \ 193f1cc6c3fSSwapnil Jakhade (0xE000 << (block_offset)) 194f1cc6c3fSSwapnil Jakhade #define SIERRA_PHY_PMA_CMN_CTRL 0x000 195f1cc6c3fSSwapnil Jakhade 1966b81f05aSSwapnil Jakhade /* PHY PMA lane registers */ 1976b81f05aSSwapnil Jakhade #define SIERRA_PHY_PMA_LANE_CDB_OFFSET(ln, block_offset, reg_offset) \ 1986b81f05aSSwapnil Jakhade ((0xF000 << (block_offset)) + \ 1996b81f05aSSwapnil Jakhade (((ln) << 8) << (reg_offset))) 2006b81f05aSSwapnil Jakhade 2016b81f05aSSwapnil Jakhade #define SIERRA_PHY_PMA_XCVR_CTRL 0x000 2026b81f05aSSwapnil Jakhade 20344d30d62SAlan Douglas #define SIERRA_MACRO_ID 0x00007364 204a43f72aeSKishon Vijay Abraham I #define SIERRA_MAX_LANES 16 205adc4bd6fSKishon Vijay Abraham I #define PLL_LOCK_TIME 100000 20644d30d62SAlan Douglas 207*09d976b3SSwapnil Jakhade #define CDNS_SIERRA_OUTPUT_CLOCKS 3 20828081b72SKishon Vijay Abraham I #define CDNS_SIERRA_INPUT_CLOCKS 5 209a0c30cd7SKishon Vijay Abraham I enum cdns_sierra_clock_input { 210a0c30cd7SKishon Vijay Abraham I PHY_CLK, 211a0c30cd7SKishon Vijay Abraham I CMN_REFCLK_DIG_DIV, 212a0c30cd7SKishon Vijay Abraham I CMN_REFCLK1_DIG_DIV, 21328081b72SKishon Vijay Abraham I PLL0_REFCLK, 21428081b72SKishon Vijay Abraham I PLL1_REFCLK, 215a0c30cd7SKishon Vijay Abraham I }; 216a0c30cd7SKishon Vijay Abraham I 21728081b72SKishon Vijay Abraham I #define SIERRA_NUM_CMN_PLLC 2 21828081b72SKishon Vijay Abraham I #define SIERRA_NUM_CMN_PLLC_PARENTS 2 21928081b72SKishon Vijay Abraham I 220380f5708SKishon Vijay Abraham I static const struct reg_field macro_id_type = 221380f5708SKishon Vijay Abraham I REG_FIELD(SIERRA_MACRO_ID_REG, 0, 15); 222380f5708SKishon Vijay Abraham I static const struct reg_field phy_pll_cfg_1 = 223380f5708SKishon Vijay Abraham I REG_FIELD(SIERRA_PHY_PLL_CFG, 1, 1); 224f1cc6c3fSSwapnil Jakhade static const struct reg_field pma_cmn_ready = 225f1cc6c3fSSwapnil Jakhade REG_FIELD(SIERRA_PHY_PMA_CMN_CTRL, 0, 0); 226adc4bd6fSKishon Vijay Abraham I static const struct reg_field pllctrl_lock = 227adc4bd6fSKishon Vijay Abraham I REG_FIELD(SIERRA_PLLCTRL_STATUS_PREG, 0, 0); 22836ce4163SSwapnil Jakhade static const struct reg_field phy_iso_link_ctrl_1 = 22936ce4163SSwapnil Jakhade REG_FIELD(SIERRA_PHY_ISO_LINK_CTRL, 1, 1); 230*09d976b3SSwapnil Jakhade static const struct reg_field cmn_plllc_clk1outdiv_preg = 231*09d976b3SSwapnil Jakhade REG_FIELD(SIERRA_CMN_PLLLC_CLK1_PREG, 0, 6); 232*09d976b3SSwapnil Jakhade static const struct reg_field cmn_plllc_clk1_en_preg = 233*09d976b3SSwapnil Jakhade REG_FIELD(SIERRA_CMN_PLLLC_CLK1_PREG, 12, 12); 234380f5708SKishon Vijay Abraham I 23528081b72SKishon Vijay Abraham I static const char * const clk_names[] = { 23628081b72SKishon Vijay Abraham I [CDNS_SIERRA_PLL_CMNLC] = "pll_cmnlc", 23728081b72SKishon Vijay Abraham I [CDNS_SIERRA_PLL_CMNLC1] = "pll_cmnlc1", 238*09d976b3SSwapnil Jakhade [CDNS_SIERRA_DERIVED_REFCLK] = "refclk_der", 23928081b72SKishon Vijay Abraham I }; 24028081b72SKishon Vijay Abraham I 24128081b72SKishon Vijay Abraham I enum cdns_sierra_cmn_plllc { 24228081b72SKishon Vijay Abraham I CMN_PLLLC, 24328081b72SKishon Vijay Abraham I CMN_PLLLC1, 24428081b72SKishon Vijay Abraham I }; 24528081b72SKishon Vijay Abraham I 24628081b72SKishon Vijay Abraham I struct cdns_sierra_pll_mux_reg_fields { 24728081b72SKishon Vijay Abraham I struct reg_field pfdclk_sel_preg; 24828081b72SKishon Vijay Abraham I struct reg_field plllc1en_field; 24928081b72SKishon Vijay Abraham I struct reg_field termen_field; 25028081b72SKishon Vijay Abraham I }; 25128081b72SKishon Vijay Abraham I 25228081b72SKishon Vijay Abraham I static const struct cdns_sierra_pll_mux_reg_fields cmn_plllc_pfdclk1_sel_preg[] = { 25328081b72SKishon Vijay Abraham I [CMN_PLLLC] = { 25428081b72SKishon Vijay Abraham I .pfdclk_sel_preg = REG_FIELD(SIERRA_CMN_PLLLC_GEN_PREG, 1, 1), 25528081b72SKishon Vijay Abraham I .plllc1en_field = REG_FIELD(SIERRA_CMN_REFRCV1_PREG, 8, 8), 25628081b72SKishon Vijay Abraham I .termen_field = REG_FIELD(SIERRA_CMN_REFRCV1_PREG, 0, 0), 25728081b72SKishon Vijay Abraham I }, 25828081b72SKishon Vijay Abraham I [CMN_PLLLC1] = { 25928081b72SKishon Vijay Abraham I .pfdclk_sel_preg = REG_FIELD(SIERRA_CMN_PLLLC1_GEN_PREG, 1, 1), 26028081b72SKishon Vijay Abraham I .plllc1en_field = REG_FIELD(SIERRA_CMN_REFRCV_PREG, 8, 8), 26128081b72SKishon Vijay Abraham I .termen_field = REG_FIELD(SIERRA_CMN_REFRCV_PREG, 0, 0), 26228081b72SKishon Vijay Abraham I }, 26328081b72SKishon Vijay Abraham I }; 26428081b72SKishon Vijay Abraham I 26528081b72SKishon Vijay Abraham I struct cdns_sierra_pll_mux { 26628081b72SKishon Vijay Abraham I struct clk_hw hw; 26728081b72SKishon Vijay Abraham I struct regmap_field *pfdclk_sel_preg; 26828081b72SKishon Vijay Abraham I struct regmap_field *plllc1en_field; 26928081b72SKishon Vijay Abraham I struct regmap_field *termen_field; 27028081b72SKishon Vijay Abraham I struct clk_init_data clk_data; 27128081b72SKishon Vijay Abraham I }; 27228081b72SKishon Vijay Abraham I 27328081b72SKishon Vijay Abraham I #define to_cdns_sierra_pll_mux(_hw) \ 27428081b72SKishon Vijay Abraham I container_of(_hw, struct cdns_sierra_pll_mux, hw) 27528081b72SKishon Vijay Abraham I 27628081b72SKishon Vijay Abraham I static const int pll_mux_parent_index[][SIERRA_NUM_CMN_PLLC_PARENTS] = { 27728081b72SKishon Vijay Abraham I [CMN_PLLLC] = { PLL0_REFCLK, PLL1_REFCLK }, 27828081b72SKishon Vijay Abraham I [CMN_PLLLC1] = { PLL1_REFCLK, PLL0_REFCLK }, 27928081b72SKishon Vijay Abraham I }; 28028081b72SKishon Vijay Abraham I 281da08aab9SSwapnil Jakhade static u32 cdns_sierra_pll_mux_table[][SIERRA_NUM_CMN_PLLC_PARENTS] = { 282da08aab9SSwapnil Jakhade [CMN_PLLLC] = { 0, 1 }, 283da08aab9SSwapnil Jakhade [CMN_PLLLC1] = { 1, 0 }, 284da08aab9SSwapnil Jakhade }; 28528081b72SKishon Vijay Abraham I 286*09d976b3SSwapnil Jakhade struct cdns_sierra_derived_refclk { 287*09d976b3SSwapnil Jakhade struct clk_hw hw; 288*09d976b3SSwapnil Jakhade struct regmap_field *cmn_plllc_clk1outdiv_preg; 289*09d976b3SSwapnil Jakhade struct regmap_field *cmn_plllc_clk1_en_preg; 290*09d976b3SSwapnil Jakhade struct clk_init_data clk_data; 291*09d976b3SSwapnil Jakhade }; 292*09d976b3SSwapnil Jakhade 293*09d976b3SSwapnil Jakhade #define to_cdns_sierra_derived_refclk(_hw) \ 294*09d976b3SSwapnil Jakhade container_of(_hw, struct cdns_sierra_derived_refclk, hw) 295*09d976b3SSwapnil Jakhade 296078e9e92SSwapnil Jakhade enum cdns_sierra_phy_type { 297078e9e92SSwapnil Jakhade TYPE_NONE, 298078e9e92SSwapnil Jakhade TYPE_PCIE, 2998a1b82d7SSwapnil Jakhade TYPE_USB, 3008a1b82d7SSwapnil Jakhade TYPE_QSGMII 301078e9e92SSwapnil Jakhade }; 302078e9e92SSwapnil Jakhade 303078e9e92SSwapnil Jakhade enum cdns_sierra_ssc_mode { 304078e9e92SSwapnil Jakhade NO_SSC, 305078e9e92SSwapnil Jakhade EXTERNAL_SSC, 306078e9e92SSwapnil Jakhade INTERNAL_SSC 307078e9e92SSwapnil Jakhade }; 308078e9e92SSwapnil Jakhade 30944d30d62SAlan Douglas struct cdns_sierra_inst { 31044d30d62SAlan Douglas struct phy *phy; 311078e9e92SSwapnil Jakhade enum cdns_sierra_phy_type phy_type; 31244d30d62SAlan Douglas u32 num_lanes; 31344d30d62SAlan Douglas u32 mlane; 31444d30d62SAlan Douglas struct reset_control *lnk_rst; 3151e902b2aSSwapnil Jakhade enum cdns_sierra_ssc_mode ssc_mode; 31644d30d62SAlan Douglas }; 31744d30d62SAlan Douglas 31844d30d62SAlan Douglas struct cdns_reg_pairs { 31944d30d62SAlan Douglas u16 val; 32044d30d62SAlan Douglas u32 off; 32144d30d62SAlan Douglas }; 32244d30d62SAlan Douglas 323078e9e92SSwapnil Jakhade struct cdns_sierra_vals { 324078e9e92SSwapnil Jakhade const struct cdns_reg_pairs *reg_pairs; 325078e9e92SSwapnil Jakhade u32 num_regs; 326078e9e92SSwapnil Jakhade }; 327078e9e92SSwapnil Jakhade 32844d30d62SAlan Douglas struct cdns_sierra_data { 32944d30d62SAlan Douglas u32 id_value; 330380f5708SKishon Vijay Abraham I u8 block_offset_shift; 331380f5708SKishon Vijay Abraham I u8 reg_offset_shift; 332fa105172SSwapnil Jakhade struct cdns_sierra_vals *pcs_cmn_vals[NUM_PHY_TYPE][NUM_PHY_TYPE] 333fa105172SSwapnil Jakhade [NUM_SSC_MODE]; 3346b81f05aSSwapnil Jakhade struct cdns_sierra_vals *phy_pma_ln_vals[NUM_PHY_TYPE][NUM_PHY_TYPE] 3356b81f05aSSwapnil Jakhade [NUM_SSC_MODE]; 336078e9e92SSwapnil Jakhade struct cdns_sierra_vals *pma_cmn_vals[NUM_PHY_TYPE][NUM_PHY_TYPE] 337078e9e92SSwapnil Jakhade [NUM_SSC_MODE]; 338078e9e92SSwapnil Jakhade struct cdns_sierra_vals *pma_ln_vals[NUM_PHY_TYPE][NUM_PHY_TYPE] 339078e9e92SSwapnil Jakhade [NUM_SSC_MODE]; 34044d30d62SAlan Douglas }; 34144d30d62SAlan Douglas 342380f5708SKishon Vijay Abraham I struct cdns_regmap_cdb_context { 34344d30d62SAlan Douglas struct device *dev; 34444d30d62SAlan Douglas void __iomem *base; 345380f5708SKishon Vijay Abraham I u8 reg_offset_shift; 346380f5708SKishon Vijay Abraham I }; 347380f5708SKishon Vijay Abraham I 348380f5708SKishon Vijay Abraham I struct cdns_sierra_phy { 349380f5708SKishon Vijay Abraham I struct device *dev; 350380f5708SKishon Vijay Abraham I struct regmap *regmap; 351c3c11d55SSwapnil Jakhade const struct cdns_sierra_data *init_data; 35244d30d62SAlan Douglas struct cdns_sierra_inst phys[SIERRA_MAX_LANES]; 35344d30d62SAlan Douglas struct reset_control *phy_rst; 35444d30d62SAlan Douglas struct reset_control *apb_rst; 355380f5708SKishon Vijay Abraham I struct regmap *regmap_lane_cdb[SIERRA_MAX_LANES]; 3568c95e172SSwapnil Jakhade struct regmap *regmap_phy_pcs_common_cdb; 35736ce4163SSwapnil Jakhade struct regmap *regmap_phy_pcs_lane_cdb[SIERRA_MAX_LANES]; 358f1cc6c3fSSwapnil Jakhade struct regmap *regmap_phy_pma_common_cdb; 3596b81f05aSSwapnil Jakhade struct regmap *regmap_phy_pma_lane_cdb[SIERRA_MAX_LANES]; 360380f5708SKishon Vijay Abraham I struct regmap *regmap_common_cdb; 361380f5708SKishon Vijay Abraham I struct regmap_field *macro_id_type; 362380f5708SKishon Vijay Abraham I struct regmap_field *phy_pll_cfg_1; 363f1cc6c3fSSwapnil Jakhade struct regmap_field *pma_cmn_ready; 364adc4bd6fSKishon Vijay Abraham I struct regmap_field *pllctrl_lock[SIERRA_MAX_LANES]; 36536ce4163SSwapnil Jakhade struct regmap_field *phy_iso_link_ctrl_1[SIERRA_MAX_LANES]; 36628081b72SKishon Vijay Abraham I struct regmap_field *cmn_refrcv_refclk_plllc1en_preg[SIERRA_NUM_CMN_PLLC]; 36728081b72SKishon Vijay Abraham I struct regmap_field *cmn_refrcv_refclk_termen_preg[SIERRA_NUM_CMN_PLLC]; 36828081b72SKishon Vijay Abraham I struct regmap_field *cmn_plllc_pfdclk1_sel_preg[SIERRA_NUM_CMN_PLLC]; 369a0c30cd7SKishon Vijay Abraham I struct clk *input_clks[CDNS_SIERRA_INPUT_CLOCKS]; 37044d30d62SAlan Douglas int nsubnodes; 371a43f72aeSKishon Vijay Abraham I u32 num_lanes; 37244d30d62SAlan Douglas bool autoconf; 37328081b72SKishon Vijay Abraham I struct clk_onecell_data clk_data; 37428081b72SKishon Vijay Abraham I struct clk *output_clks[CDNS_SIERRA_OUTPUT_CLOCKS]; 37544d30d62SAlan Douglas }; 37644d30d62SAlan Douglas 377380f5708SKishon Vijay Abraham I static int cdns_regmap_write(void *context, unsigned int reg, unsigned int val) 378380f5708SKishon Vijay Abraham I { 379380f5708SKishon Vijay Abraham I struct cdns_regmap_cdb_context *ctx = context; 380380f5708SKishon Vijay Abraham I u32 offset = reg << ctx->reg_offset_shift; 381380f5708SKishon Vijay Abraham I 382380f5708SKishon Vijay Abraham I writew(val, ctx->base + offset); 383380f5708SKishon Vijay Abraham I 384380f5708SKishon Vijay Abraham I return 0; 385380f5708SKishon Vijay Abraham I } 386380f5708SKishon Vijay Abraham I 387380f5708SKishon Vijay Abraham I static int cdns_regmap_read(void *context, unsigned int reg, unsigned int *val) 388380f5708SKishon Vijay Abraham I { 389380f5708SKishon Vijay Abraham I struct cdns_regmap_cdb_context *ctx = context; 390380f5708SKishon Vijay Abraham I u32 offset = reg << ctx->reg_offset_shift; 391380f5708SKishon Vijay Abraham I 392380f5708SKishon Vijay Abraham I *val = readw(ctx->base + offset); 393380f5708SKishon Vijay Abraham I return 0; 394380f5708SKishon Vijay Abraham I } 395380f5708SKishon Vijay Abraham I 396380f5708SKishon Vijay Abraham I #define SIERRA_LANE_CDB_REGMAP_CONF(n) \ 397380f5708SKishon Vijay Abraham I { \ 398380f5708SKishon Vijay Abraham I .name = "sierra_lane" n "_cdb", \ 399380f5708SKishon Vijay Abraham I .reg_stride = 1, \ 400380f5708SKishon Vijay Abraham I .fast_io = true, \ 401380f5708SKishon Vijay Abraham I .reg_write = cdns_regmap_write, \ 402380f5708SKishon Vijay Abraham I .reg_read = cdns_regmap_read, \ 403380f5708SKishon Vijay Abraham I } 404380f5708SKishon Vijay Abraham I 4053cfb0e8eSRikard Falkeborn static const struct regmap_config cdns_sierra_lane_cdb_config[] = { 406380f5708SKishon Vijay Abraham I SIERRA_LANE_CDB_REGMAP_CONF("0"), 407380f5708SKishon Vijay Abraham I SIERRA_LANE_CDB_REGMAP_CONF("1"), 408380f5708SKishon Vijay Abraham I SIERRA_LANE_CDB_REGMAP_CONF("2"), 409380f5708SKishon Vijay Abraham I SIERRA_LANE_CDB_REGMAP_CONF("3"), 410a43f72aeSKishon Vijay Abraham I SIERRA_LANE_CDB_REGMAP_CONF("4"), 411a43f72aeSKishon Vijay Abraham I SIERRA_LANE_CDB_REGMAP_CONF("5"), 412a43f72aeSKishon Vijay Abraham I SIERRA_LANE_CDB_REGMAP_CONF("6"), 413a43f72aeSKishon Vijay Abraham I SIERRA_LANE_CDB_REGMAP_CONF("7"), 414a43f72aeSKishon Vijay Abraham I SIERRA_LANE_CDB_REGMAP_CONF("8"), 415a43f72aeSKishon Vijay Abraham I SIERRA_LANE_CDB_REGMAP_CONF("9"), 416a43f72aeSKishon Vijay Abraham I SIERRA_LANE_CDB_REGMAP_CONF("10"), 417a43f72aeSKishon Vijay Abraham I SIERRA_LANE_CDB_REGMAP_CONF("11"), 418a43f72aeSKishon Vijay Abraham I SIERRA_LANE_CDB_REGMAP_CONF("12"), 419a43f72aeSKishon Vijay Abraham I SIERRA_LANE_CDB_REGMAP_CONF("13"), 420a43f72aeSKishon Vijay Abraham I SIERRA_LANE_CDB_REGMAP_CONF("14"), 421a43f72aeSKishon Vijay Abraham I SIERRA_LANE_CDB_REGMAP_CONF("15"), 422380f5708SKishon Vijay Abraham I }; 423380f5708SKishon Vijay Abraham I 4243cfb0e8eSRikard Falkeborn static const struct regmap_config cdns_sierra_common_cdb_config = { 425380f5708SKishon Vijay Abraham I .name = "sierra_common_cdb", 426380f5708SKishon Vijay Abraham I .reg_stride = 1, 427380f5708SKishon Vijay Abraham I .fast_io = true, 428380f5708SKishon Vijay Abraham I .reg_write = cdns_regmap_write, 429380f5708SKishon Vijay Abraham I .reg_read = cdns_regmap_read, 430380f5708SKishon Vijay Abraham I }; 431380f5708SKishon Vijay Abraham I 4328c95e172SSwapnil Jakhade static const struct regmap_config cdns_sierra_phy_pcs_cmn_cdb_config = { 4338c95e172SSwapnil Jakhade .name = "sierra_phy_pcs_cmn_cdb", 434380f5708SKishon Vijay Abraham I .reg_stride = 1, 435380f5708SKishon Vijay Abraham I .fast_io = true, 436380f5708SKishon Vijay Abraham I .reg_write = cdns_regmap_write, 437380f5708SKishon Vijay Abraham I .reg_read = cdns_regmap_read, 438380f5708SKishon Vijay Abraham I }; 439380f5708SKishon Vijay Abraham I 44036ce4163SSwapnil Jakhade #define SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF(n) \ 44136ce4163SSwapnil Jakhade { \ 44236ce4163SSwapnil Jakhade .name = "sierra_phy_pcs_lane" n "_cdb", \ 44336ce4163SSwapnil Jakhade .reg_stride = 1, \ 44436ce4163SSwapnil Jakhade .fast_io = true, \ 44536ce4163SSwapnil Jakhade .reg_write = cdns_regmap_write, \ 44636ce4163SSwapnil Jakhade .reg_read = cdns_regmap_read, \ 44736ce4163SSwapnil Jakhade } 44836ce4163SSwapnil Jakhade 44936ce4163SSwapnil Jakhade static const struct regmap_config cdns_sierra_phy_pcs_lane_cdb_config[] = { 45036ce4163SSwapnil Jakhade SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("0"), 45136ce4163SSwapnil Jakhade SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("1"), 45236ce4163SSwapnil Jakhade SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("2"), 45336ce4163SSwapnil Jakhade SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("3"), 45436ce4163SSwapnil Jakhade SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("4"), 45536ce4163SSwapnil Jakhade SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("5"), 45636ce4163SSwapnil Jakhade SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("6"), 45736ce4163SSwapnil Jakhade SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("7"), 45836ce4163SSwapnil Jakhade SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("8"), 45936ce4163SSwapnil Jakhade SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("9"), 46036ce4163SSwapnil Jakhade SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("10"), 46136ce4163SSwapnil Jakhade SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("11"), 46236ce4163SSwapnil Jakhade SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("12"), 46336ce4163SSwapnil Jakhade SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("13"), 46436ce4163SSwapnil Jakhade SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("14"), 46536ce4163SSwapnil Jakhade SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("15"), 46636ce4163SSwapnil Jakhade }; 46736ce4163SSwapnil Jakhade 468f1cc6c3fSSwapnil Jakhade static const struct regmap_config cdns_sierra_phy_pma_cmn_cdb_config = { 469f1cc6c3fSSwapnil Jakhade .name = "sierra_phy_pma_cmn_cdb", 470f1cc6c3fSSwapnil Jakhade .reg_stride = 1, 471f1cc6c3fSSwapnil Jakhade .fast_io = true, 472f1cc6c3fSSwapnil Jakhade .reg_write = cdns_regmap_write, 473f1cc6c3fSSwapnil Jakhade .reg_read = cdns_regmap_read, 474f1cc6c3fSSwapnil Jakhade }; 475f1cc6c3fSSwapnil Jakhade 4766b81f05aSSwapnil Jakhade #define SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF(n) \ 4776b81f05aSSwapnil Jakhade { \ 4786b81f05aSSwapnil Jakhade .name = "sierra_phy_pma_lane" n "_cdb", \ 4796b81f05aSSwapnil Jakhade .reg_stride = 1, \ 4806b81f05aSSwapnil Jakhade .fast_io = true, \ 4816b81f05aSSwapnil Jakhade .reg_write = cdns_regmap_write, \ 4826b81f05aSSwapnil Jakhade .reg_read = cdns_regmap_read, \ 4836b81f05aSSwapnil Jakhade } 4846b81f05aSSwapnil Jakhade 4856b81f05aSSwapnil Jakhade static const struct regmap_config cdns_sierra_phy_pma_lane_cdb_config[] = { 4866b81f05aSSwapnil Jakhade SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("0"), 4876b81f05aSSwapnil Jakhade SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("1"), 4886b81f05aSSwapnil Jakhade SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("2"), 4896b81f05aSSwapnil Jakhade SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("3"), 4906b81f05aSSwapnil Jakhade SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("4"), 4916b81f05aSSwapnil Jakhade SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("5"), 4926b81f05aSSwapnil Jakhade SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("6"), 4936b81f05aSSwapnil Jakhade SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("7"), 4946b81f05aSSwapnil Jakhade SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("8"), 4956b81f05aSSwapnil Jakhade SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("9"), 4966b81f05aSSwapnil Jakhade SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("10"), 4976b81f05aSSwapnil Jakhade SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("11"), 4986b81f05aSSwapnil Jakhade SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("12"), 4996b81f05aSSwapnil Jakhade SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("13"), 5006b81f05aSSwapnil Jakhade SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("14"), 5016b81f05aSSwapnil Jakhade SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("15"), 5026b81f05aSSwapnil Jakhade }; 5036b81f05aSSwapnil Jakhade 504cedcc2e2SKishon Vijay Abraham I static int cdns_sierra_phy_init(struct phy *gphy) 50544d30d62SAlan Douglas { 50644d30d62SAlan Douglas struct cdns_sierra_inst *ins = phy_get_drvdata(gphy); 50744d30d62SAlan Douglas struct cdns_sierra_phy *phy = dev_get_drvdata(gphy->dev.parent); 508078e9e92SSwapnil Jakhade const struct cdns_sierra_data *init_data = phy->init_data; 509078e9e92SSwapnil Jakhade struct cdns_sierra_vals *pma_cmn_vals, *pma_ln_vals; 510078e9e92SSwapnil Jakhade enum cdns_sierra_phy_type phy_type = ins->phy_type; 5111e902b2aSSwapnil Jakhade enum cdns_sierra_ssc_mode ssc = ins->ssc_mode; 5126b81f05aSSwapnil Jakhade struct cdns_sierra_vals *phy_pma_ln_vals; 513078e9e92SSwapnil Jakhade const struct cdns_reg_pairs *reg_pairs; 514fa105172SSwapnil Jakhade struct cdns_sierra_vals *pcs_cmn_vals; 51580f96fb1SColin Ian King struct regmap *regmap; 516078e9e92SSwapnil Jakhade u32 num_regs; 51744d30d62SAlan Douglas int i, j; 51844d30d62SAlan Douglas 519cedcc2e2SKishon Vijay Abraham I /* Initialise the PHY registers, unless auto configured */ 5206b81f05aSSwapnil Jakhade if (phy->autoconf || phy->nsubnodes > 1) 521cedcc2e2SKishon Vijay Abraham I return 0; 522cedcc2e2SKishon Vijay Abraham I 523a0c30cd7SKishon Vijay Abraham I clk_set_rate(phy->input_clks[CMN_REFCLK_DIG_DIV], 25000000); 524a0c30cd7SKishon Vijay Abraham I clk_set_rate(phy->input_clks[CMN_REFCLK1_DIG_DIV], 25000000); 525078e9e92SSwapnil Jakhade 526fa105172SSwapnil Jakhade /* PHY PCS common registers configurations */ 527fa105172SSwapnil Jakhade pcs_cmn_vals = init_data->pcs_cmn_vals[phy_type][TYPE_NONE][ssc]; 528fa105172SSwapnil Jakhade if (pcs_cmn_vals) { 529fa105172SSwapnil Jakhade reg_pairs = pcs_cmn_vals->reg_pairs; 530fa105172SSwapnil Jakhade num_regs = pcs_cmn_vals->num_regs; 531fa105172SSwapnil Jakhade regmap = phy->regmap_phy_pcs_common_cdb; 532fa105172SSwapnil Jakhade for (i = 0; i < num_regs; i++) 533fa105172SSwapnil Jakhade regmap_write(regmap, reg_pairs[i].off, reg_pairs[i].val); 534fa105172SSwapnil Jakhade } 535fa105172SSwapnil Jakhade 5366b81f05aSSwapnil Jakhade /* PHY PMA lane registers configurations */ 5376b81f05aSSwapnil Jakhade phy_pma_ln_vals = init_data->phy_pma_ln_vals[phy_type][TYPE_NONE][ssc]; 5386b81f05aSSwapnil Jakhade if (phy_pma_ln_vals) { 5396b81f05aSSwapnil Jakhade reg_pairs = phy_pma_ln_vals->reg_pairs; 5406b81f05aSSwapnil Jakhade num_regs = phy_pma_ln_vals->num_regs; 5416b81f05aSSwapnil Jakhade for (i = 0; i < ins->num_lanes; i++) { 5426b81f05aSSwapnil Jakhade regmap = phy->regmap_phy_pma_lane_cdb[i + ins->mlane]; 5436b81f05aSSwapnil Jakhade for (j = 0; j < num_regs; j++) 5446b81f05aSSwapnil Jakhade regmap_write(regmap, reg_pairs[j].off, reg_pairs[j].val); 5456b81f05aSSwapnil Jakhade } 5466b81f05aSSwapnil Jakhade } 5476b81f05aSSwapnil Jakhade 548078e9e92SSwapnil Jakhade /* PMA common registers configurations */ 549078e9e92SSwapnil Jakhade pma_cmn_vals = init_data->pma_cmn_vals[phy_type][TYPE_NONE][ssc]; 550078e9e92SSwapnil Jakhade if (pma_cmn_vals) { 551078e9e92SSwapnil Jakhade reg_pairs = pma_cmn_vals->reg_pairs; 552078e9e92SSwapnil Jakhade num_regs = pma_cmn_vals->num_regs; 553078e9e92SSwapnil Jakhade regmap = phy->regmap_common_cdb; 554078e9e92SSwapnil Jakhade for (i = 0; i < num_regs; i++) 555078e9e92SSwapnil Jakhade regmap_write(regmap, reg_pairs[i].off, reg_pairs[i].val); 55644d30d62SAlan Douglas } 557871002d7SAnil Varughese 558078e9e92SSwapnil Jakhade /* PMA lane registers configurations */ 559078e9e92SSwapnil Jakhade pma_ln_vals = init_data->pma_ln_vals[phy_type][TYPE_NONE][ssc]; 560078e9e92SSwapnil Jakhade if (pma_ln_vals) { 561078e9e92SSwapnil Jakhade reg_pairs = pma_ln_vals->reg_pairs; 562078e9e92SSwapnil Jakhade num_regs = pma_ln_vals->num_regs; 563380f5708SKishon Vijay Abraham I for (i = 0; i < ins->num_lanes; i++) { 564380f5708SKishon Vijay Abraham I regmap = phy->regmap_lane_cdb[i + ins->mlane]; 565078e9e92SSwapnil Jakhade for (j = 0; j < num_regs; j++) 566078e9e92SSwapnil Jakhade regmap_write(regmap, reg_pairs[j].off, reg_pairs[j].val); 567380f5708SKishon Vijay Abraham I } 568380f5708SKishon Vijay Abraham I } 569cedcc2e2SKishon Vijay Abraham I 570cedcc2e2SKishon Vijay Abraham I return 0; 57144d30d62SAlan Douglas } 57244d30d62SAlan Douglas 57344d30d62SAlan Douglas static int cdns_sierra_phy_on(struct phy *gphy) 57444d30d62SAlan Douglas { 575adc4bd6fSKishon Vijay Abraham I struct cdns_sierra_phy *sp = dev_get_drvdata(gphy->dev.parent); 57644d30d62SAlan Douglas struct cdns_sierra_inst *ins = phy_get_drvdata(gphy); 577adc4bd6fSKishon Vijay Abraham I struct device *dev = sp->dev; 578adc4bd6fSKishon Vijay Abraham I u32 val; 579adc4bd6fSKishon Vijay Abraham I int ret; 58044d30d62SAlan Douglas 5816b81f05aSSwapnil Jakhade if (sp->nsubnodes == 1) { 5826b81f05aSSwapnil Jakhade /* Take the PHY out of reset */ 5835b4f5757SKishon Vijay Abraham I ret = reset_control_deassert(sp->phy_rst); 5845b4f5757SKishon Vijay Abraham I if (ret) { 5855b4f5757SKishon Vijay Abraham I dev_err(dev, "Failed to take the PHY out of reset\n"); 5865b4f5757SKishon Vijay Abraham I return ret; 5875b4f5757SKishon Vijay Abraham I } 5886b81f05aSSwapnil Jakhade } 5895b4f5757SKishon Vijay Abraham I 59044d30d62SAlan Douglas /* Take the PHY lane group out of reset */ 591adc4bd6fSKishon Vijay Abraham I ret = reset_control_deassert(ins->lnk_rst); 592adc4bd6fSKishon Vijay Abraham I if (ret) { 593adc4bd6fSKishon Vijay Abraham I dev_err(dev, "Failed to take the PHY lane out of reset\n"); 594adc4bd6fSKishon Vijay Abraham I return ret; 595adc4bd6fSKishon Vijay Abraham I } 596adc4bd6fSKishon Vijay Abraham I 59736ce4163SSwapnil Jakhade if (ins->phy_type == TYPE_PCIE || ins->phy_type == TYPE_USB) { 59836ce4163SSwapnil Jakhade ret = regmap_field_read_poll_timeout(sp->phy_iso_link_ctrl_1[ins->mlane], 59936ce4163SSwapnil Jakhade val, !val, 1000, PLL_LOCK_TIME); 60036ce4163SSwapnil Jakhade if (ret) { 60136ce4163SSwapnil Jakhade dev_err(dev, "Timeout waiting for PHY status ready\n"); 60236ce4163SSwapnil Jakhade return ret; 60336ce4163SSwapnil Jakhade } 60436ce4163SSwapnil Jakhade } 60536ce4163SSwapnil Jakhade 606f1cc6c3fSSwapnil Jakhade /* 607f1cc6c3fSSwapnil Jakhade * Wait for cmn_ready assertion 608f1cc6c3fSSwapnil Jakhade * PHY_PMA_CMN_CTRL[0] == 1 609f1cc6c3fSSwapnil Jakhade */ 610f1cc6c3fSSwapnil Jakhade ret = regmap_field_read_poll_timeout(sp->pma_cmn_ready, val, val, 611f1cc6c3fSSwapnil Jakhade 1000, PLL_LOCK_TIME); 612f1cc6c3fSSwapnil Jakhade if (ret) { 613f1cc6c3fSSwapnil Jakhade dev_err(dev, "Timeout waiting for CMN ready\n"); 614f1cc6c3fSSwapnil Jakhade return ret; 615f1cc6c3fSSwapnil Jakhade } 616f1cc6c3fSSwapnil Jakhade 617adc4bd6fSKishon Vijay Abraham I ret = regmap_field_read_poll_timeout(sp->pllctrl_lock[ins->mlane], 618adc4bd6fSKishon Vijay Abraham I val, val, 1000, PLL_LOCK_TIME); 619adc4bd6fSKishon Vijay Abraham I if (ret < 0) 620adc4bd6fSKishon Vijay Abraham I dev_err(dev, "PLL lock of lane failed\n"); 621adc4bd6fSKishon Vijay Abraham I 622adc4bd6fSKishon Vijay Abraham I return ret; 62344d30d62SAlan Douglas } 62444d30d62SAlan Douglas 62544d30d62SAlan Douglas static int cdns_sierra_phy_off(struct phy *gphy) 62644d30d62SAlan Douglas { 62744d30d62SAlan Douglas struct cdns_sierra_inst *ins = phy_get_drvdata(gphy); 62844d30d62SAlan Douglas 62944d30d62SAlan Douglas return reset_control_assert(ins->lnk_rst); 63044d30d62SAlan Douglas } 63144d30d62SAlan Douglas 6327904e15bSRoger Quadros static int cdns_sierra_phy_reset(struct phy *gphy) 6337904e15bSRoger Quadros { 6347904e15bSRoger Quadros struct cdns_sierra_phy *sp = dev_get_drvdata(gphy->dev.parent); 6357904e15bSRoger Quadros 6367904e15bSRoger Quadros reset_control_assert(sp->phy_rst); 6377904e15bSRoger Quadros reset_control_deassert(sp->phy_rst); 6387904e15bSRoger Quadros return 0; 6397904e15bSRoger Quadros }; 6407904e15bSRoger Quadros 64144d30d62SAlan Douglas static const struct phy_ops ops = { 642cedcc2e2SKishon Vijay Abraham I .init = cdns_sierra_phy_init, 64344d30d62SAlan Douglas .power_on = cdns_sierra_phy_on, 64444d30d62SAlan Douglas .power_off = cdns_sierra_phy_off, 6457904e15bSRoger Quadros .reset = cdns_sierra_phy_reset, 64644d30d62SAlan Douglas .owner = THIS_MODULE, 64744d30d62SAlan Douglas }; 64844d30d62SAlan Douglas 64928081b72SKishon Vijay Abraham I static u8 cdns_sierra_pll_mux_get_parent(struct clk_hw *hw) 65028081b72SKishon Vijay Abraham I { 65128081b72SKishon Vijay Abraham I struct cdns_sierra_pll_mux *mux = to_cdns_sierra_pll_mux(hw); 652da08aab9SSwapnil Jakhade struct regmap_field *plllc1en_field = mux->plllc1en_field; 653da08aab9SSwapnil Jakhade struct regmap_field *termen_field = mux->termen_field; 65428081b72SKishon Vijay Abraham I struct regmap_field *field = mux->pfdclk_sel_preg; 65528081b72SKishon Vijay Abraham I unsigned int val; 656da08aab9SSwapnil Jakhade int index; 65728081b72SKishon Vijay Abraham I 65828081b72SKishon Vijay Abraham I regmap_field_read(field, &val); 659da08aab9SSwapnil Jakhade 660da08aab9SSwapnil Jakhade if (strstr(clk_hw_get_name(hw), clk_names[CDNS_SIERRA_PLL_CMNLC1])) { 661da08aab9SSwapnil Jakhade index = clk_mux_val_to_index(hw, cdns_sierra_pll_mux_table[CMN_PLLLC1], 0, val); 662da08aab9SSwapnil Jakhade if (index == 1) { 663da08aab9SSwapnil Jakhade regmap_field_write(plllc1en_field, 1); 664da08aab9SSwapnil Jakhade regmap_field_write(termen_field, 1); 665da08aab9SSwapnil Jakhade } 666da08aab9SSwapnil Jakhade } else { 667da08aab9SSwapnil Jakhade index = clk_mux_val_to_index(hw, cdns_sierra_pll_mux_table[CMN_PLLLC], 0, val); 668da08aab9SSwapnil Jakhade } 669da08aab9SSwapnil Jakhade 670da08aab9SSwapnil Jakhade return index; 67128081b72SKishon Vijay Abraham I } 67228081b72SKishon Vijay Abraham I 67328081b72SKishon Vijay Abraham I static int cdns_sierra_pll_mux_set_parent(struct clk_hw *hw, u8 index) 67428081b72SKishon Vijay Abraham I { 67528081b72SKishon Vijay Abraham I struct cdns_sierra_pll_mux *mux = to_cdns_sierra_pll_mux(hw); 67628081b72SKishon Vijay Abraham I struct regmap_field *plllc1en_field = mux->plllc1en_field; 67728081b72SKishon Vijay Abraham I struct regmap_field *termen_field = mux->termen_field; 67828081b72SKishon Vijay Abraham I struct regmap_field *field = mux->pfdclk_sel_preg; 67928081b72SKishon Vijay Abraham I int val, ret; 68028081b72SKishon Vijay Abraham I 68128081b72SKishon Vijay Abraham I ret = regmap_field_write(plllc1en_field, 0); 68228081b72SKishon Vijay Abraham I ret |= regmap_field_write(termen_field, 0); 68328081b72SKishon Vijay Abraham I if (index == 1) { 68428081b72SKishon Vijay Abraham I ret |= regmap_field_write(plllc1en_field, 1); 68528081b72SKishon Vijay Abraham I ret |= regmap_field_write(termen_field, 1); 68628081b72SKishon Vijay Abraham I } 68728081b72SKishon Vijay Abraham I 688da08aab9SSwapnil Jakhade if (strstr(clk_hw_get_name(hw), clk_names[CDNS_SIERRA_PLL_CMNLC1])) 689da08aab9SSwapnil Jakhade val = cdns_sierra_pll_mux_table[CMN_PLLLC1][index]; 690da08aab9SSwapnil Jakhade else 691da08aab9SSwapnil Jakhade val = cdns_sierra_pll_mux_table[CMN_PLLLC][index]; 692da08aab9SSwapnil Jakhade 69328081b72SKishon Vijay Abraham I ret |= regmap_field_write(field, val); 69428081b72SKishon Vijay Abraham I 69528081b72SKishon Vijay Abraham I return ret; 69628081b72SKishon Vijay Abraham I } 69728081b72SKishon Vijay Abraham I 69828081b72SKishon Vijay Abraham I static const struct clk_ops cdns_sierra_pll_mux_ops = { 69928081b72SKishon Vijay Abraham I .set_parent = cdns_sierra_pll_mux_set_parent, 70028081b72SKishon Vijay Abraham I .get_parent = cdns_sierra_pll_mux_get_parent, 70128081b72SKishon Vijay Abraham I }; 70228081b72SKishon Vijay Abraham I 70328081b72SKishon Vijay Abraham I static int cdns_sierra_pll_mux_register(struct cdns_sierra_phy *sp, 70428081b72SKishon Vijay Abraham I struct regmap_field *pfdclk1_sel_field, 70528081b72SKishon Vijay Abraham I struct regmap_field *plllc1en_field, 70628081b72SKishon Vijay Abraham I struct regmap_field *termen_field, 70728081b72SKishon Vijay Abraham I int clk_index) 70828081b72SKishon Vijay Abraham I { 70928081b72SKishon Vijay Abraham I struct cdns_sierra_pll_mux *mux; 71028081b72SKishon Vijay Abraham I struct device *dev = sp->dev; 71128081b72SKishon Vijay Abraham I struct clk_init_data *init; 71228081b72SKishon Vijay Abraham I const char **parent_names; 71328081b72SKishon Vijay Abraham I unsigned int num_parents; 71428081b72SKishon Vijay Abraham I char clk_name[100]; 71528081b72SKishon Vijay Abraham I struct clk *clk; 71628081b72SKishon Vijay Abraham I int i; 71728081b72SKishon Vijay Abraham I 71828081b72SKishon Vijay Abraham I mux = devm_kzalloc(dev, sizeof(*mux), GFP_KERNEL); 71928081b72SKishon Vijay Abraham I if (!mux) 72028081b72SKishon Vijay Abraham I return -ENOMEM; 72128081b72SKishon Vijay Abraham I 72228081b72SKishon Vijay Abraham I num_parents = SIERRA_NUM_CMN_PLLC_PARENTS; 72328081b72SKishon Vijay Abraham I parent_names = devm_kzalloc(dev, (sizeof(char *) * num_parents), GFP_KERNEL); 72428081b72SKishon Vijay Abraham I if (!parent_names) 72528081b72SKishon Vijay Abraham I return -ENOMEM; 72628081b72SKishon Vijay Abraham I 72728081b72SKishon Vijay Abraham I for (i = 0; i < num_parents; i++) { 72828081b72SKishon Vijay Abraham I clk = sp->input_clks[pll_mux_parent_index[clk_index][i]]; 72928081b72SKishon Vijay Abraham I if (IS_ERR_OR_NULL(clk)) { 730da08aab9SSwapnil Jakhade dev_err(dev, "No parent clock for PLL mux clocks\n"); 731da08aab9SSwapnil Jakhade return IS_ERR(clk) ? PTR_ERR(clk) : -ENOENT; 73228081b72SKishon Vijay Abraham I } 73328081b72SKishon Vijay Abraham I parent_names[i] = __clk_get_name(clk); 73428081b72SKishon Vijay Abraham I } 73528081b72SKishon Vijay Abraham I 73628081b72SKishon Vijay Abraham I snprintf(clk_name, sizeof(clk_name), "%s_%s", dev_name(dev), clk_names[clk_index]); 73728081b72SKishon Vijay Abraham I 73828081b72SKishon Vijay Abraham I init = &mux->clk_data; 73928081b72SKishon Vijay Abraham I 74028081b72SKishon Vijay Abraham I init->ops = &cdns_sierra_pll_mux_ops; 74128081b72SKishon Vijay Abraham I init->flags = CLK_SET_RATE_NO_REPARENT; 74228081b72SKishon Vijay Abraham I init->parent_names = parent_names; 74328081b72SKishon Vijay Abraham I init->num_parents = num_parents; 74428081b72SKishon Vijay Abraham I init->name = clk_name; 74528081b72SKishon Vijay Abraham I 74628081b72SKishon Vijay Abraham I mux->pfdclk_sel_preg = pfdclk1_sel_field; 74728081b72SKishon Vijay Abraham I mux->plllc1en_field = plllc1en_field; 74828081b72SKishon Vijay Abraham I mux->termen_field = termen_field; 74928081b72SKishon Vijay Abraham I mux->hw.init = init; 75028081b72SKishon Vijay Abraham I 75128081b72SKishon Vijay Abraham I clk = devm_clk_register(dev, &mux->hw); 75228081b72SKishon Vijay Abraham I if (IS_ERR(clk)) 75328081b72SKishon Vijay Abraham I return PTR_ERR(clk); 75428081b72SKishon Vijay Abraham I 75528081b72SKishon Vijay Abraham I sp->output_clks[clk_index] = clk; 75628081b72SKishon Vijay Abraham I 75728081b72SKishon Vijay Abraham I return 0; 75828081b72SKishon Vijay Abraham I } 75928081b72SKishon Vijay Abraham I 76028081b72SKishon Vijay Abraham I static int cdns_sierra_phy_register_pll_mux(struct cdns_sierra_phy *sp) 76128081b72SKishon Vijay Abraham I { 76228081b72SKishon Vijay Abraham I struct regmap_field *pfdclk1_sel_field; 76328081b72SKishon Vijay Abraham I struct regmap_field *plllc1en_field; 76428081b72SKishon Vijay Abraham I struct regmap_field *termen_field; 76528081b72SKishon Vijay Abraham I struct device *dev = sp->dev; 76628081b72SKishon Vijay Abraham I int ret = 0, i, clk_index; 76728081b72SKishon Vijay Abraham I 76828081b72SKishon Vijay Abraham I clk_index = CDNS_SIERRA_PLL_CMNLC; 76928081b72SKishon Vijay Abraham I for (i = 0; i < SIERRA_NUM_CMN_PLLC; i++, clk_index++) { 77028081b72SKishon Vijay Abraham I pfdclk1_sel_field = sp->cmn_plllc_pfdclk1_sel_preg[i]; 77128081b72SKishon Vijay Abraham I plllc1en_field = sp->cmn_refrcv_refclk_plllc1en_preg[i]; 77228081b72SKishon Vijay Abraham I termen_field = sp->cmn_refrcv_refclk_termen_preg[i]; 77328081b72SKishon Vijay Abraham I 77428081b72SKishon Vijay Abraham I ret = cdns_sierra_pll_mux_register(sp, pfdclk1_sel_field, plllc1en_field, 77528081b72SKishon Vijay Abraham I termen_field, clk_index); 77628081b72SKishon Vijay Abraham I if (ret) { 77728081b72SKishon Vijay Abraham I dev_err(dev, "Fail to register cmn plllc mux\n"); 77828081b72SKishon Vijay Abraham I return ret; 77928081b72SKishon Vijay Abraham I } 78028081b72SKishon Vijay Abraham I } 78128081b72SKishon Vijay Abraham I 78228081b72SKishon Vijay Abraham I return 0; 78328081b72SKishon Vijay Abraham I } 78428081b72SKishon Vijay Abraham I 785*09d976b3SSwapnil Jakhade static int cdns_sierra_derived_refclk_enable(struct clk_hw *hw) 786*09d976b3SSwapnil Jakhade { 787*09d976b3SSwapnil Jakhade struct cdns_sierra_derived_refclk *derived_refclk = to_cdns_sierra_derived_refclk(hw); 788*09d976b3SSwapnil Jakhade 789*09d976b3SSwapnil Jakhade regmap_field_write(derived_refclk->cmn_plllc_clk1_en_preg, 0x1); 790*09d976b3SSwapnil Jakhade 791*09d976b3SSwapnil Jakhade /* Programming to get 100Mhz clock output in ref_der_clk_out 5GHz VCO/50 = 100MHz */ 792*09d976b3SSwapnil Jakhade regmap_field_write(derived_refclk->cmn_plllc_clk1outdiv_preg, 0x2E); 793*09d976b3SSwapnil Jakhade 794*09d976b3SSwapnil Jakhade return 0; 795*09d976b3SSwapnil Jakhade } 796*09d976b3SSwapnil Jakhade 797*09d976b3SSwapnil Jakhade static void cdns_sierra_derived_refclk_disable(struct clk_hw *hw) 798*09d976b3SSwapnil Jakhade { 799*09d976b3SSwapnil Jakhade struct cdns_sierra_derived_refclk *derived_refclk = to_cdns_sierra_derived_refclk(hw); 800*09d976b3SSwapnil Jakhade 801*09d976b3SSwapnil Jakhade regmap_field_write(derived_refclk->cmn_plllc_clk1_en_preg, 0); 802*09d976b3SSwapnil Jakhade } 803*09d976b3SSwapnil Jakhade 804*09d976b3SSwapnil Jakhade static int cdns_sierra_derived_refclk_is_enabled(struct clk_hw *hw) 805*09d976b3SSwapnil Jakhade { 806*09d976b3SSwapnil Jakhade struct cdns_sierra_derived_refclk *derived_refclk = to_cdns_sierra_derived_refclk(hw); 807*09d976b3SSwapnil Jakhade int val; 808*09d976b3SSwapnil Jakhade 809*09d976b3SSwapnil Jakhade regmap_field_read(derived_refclk->cmn_plllc_clk1_en_preg, &val); 810*09d976b3SSwapnil Jakhade 811*09d976b3SSwapnil Jakhade return !!val; 812*09d976b3SSwapnil Jakhade } 813*09d976b3SSwapnil Jakhade 814*09d976b3SSwapnil Jakhade static const struct clk_ops cdns_sierra_derived_refclk_ops = { 815*09d976b3SSwapnil Jakhade .enable = cdns_sierra_derived_refclk_enable, 816*09d976b3SSwapnil Jakhade .disable = cdns_sierra_derived_refclk_disable, 817*09d976b3SSwapnil Jakhade .is_enabled = cdns_sierra_derived_refclk_is_enabled, 818*09d976b3SSwapnil Jakhade }; 819*09d976b3SSwapnil Jakhade 820*09d976b3SSwapnil Jakhade static int cdns_sierra_derived_refclk_register(struct cdns_sierra_phy *sp) 821*09d976b3SSwapnil Jakhade { 822*09d976b3SSwapnil Jakhade struct cdns_sierra_derived_refclk *derived_refclk; 823*09d976b3SSwapnil Jakhade struct device *dev = sp->dev; 824*09d976b3SSwapnil Jakhade struct regmap_field *field; 825*09d976b3SSwapnil Jakhade struct clk_init_data *init; 826*09d976b3SSwapnil Jakhade struct regmap *regmap; 827*09d976b3SSwapnil Jakhade char clk_name[100]; 828*09d976b3SSwapnil Jakhade struct clk *clk; 829*09d976b3SSwapnil Jakhade 830*09d976b3SSwapnil Jakhade derived_refclk = devm_kzalloc(dev, sizeof(*derived_refclk), GFP_KERNEL); 831*09d976b3SSwapnil Jakhade if (!derived_refclk) 832*09d976b3SSwapnil Jakhade return -ENOMEM; 833*09d976b3SSwapnil Jakhade 834*09d976b3SSwapnil Jakhade snprintf(clk_name, sizeof(clk_name), "%s_%s", dev_name(dev), 835*09d976b3SSwapnil Jakhade clk_names[CDNS_SIERRA_DERIVED_REFCLK]); 836*09d976b3SSwapnil Jakhade 837*09d976b3SSwapnil Jakhade init = &derived_refclk->clk_data; 838*09d976b3SSwapnil Jakhade 839*09d976b3SSwapnil Jakhade init->ops = &cdns_sierra_derived_refclk_ops; 840*09d976b3SSwapnil Jakhade init->flags = 0; 841*09d976b3SSwapnil Jakhade init->name = clk_name; 842*09d976b3SSwapnil Jakhade 843*09d976b3SSwapnil Jakhade regmap = sp->regmap_common_cdb; 844*09d976b3SSwapnil Jakhade 845*09d976b3SSwapnil Jakhade field = devm_regmap_field_alloc(dev, regmap, cmn_plllc_clk1outdiv_preg); 846*09d976b3SSwapnil Jakhade if (IS_ERR(field)) { 847*09d976b3SSwapnil Jakhade dev_err(dev, "cmn_plllc_clk1outdiv_preg reg field init failed\n"); 848*09d976b3SSwapnil Jakhade return PTR_ERR(field); 849*09d976b3SSwapnil Jakhade } 850*09d976b3SSwapnil Jakhade derived_refclk->cmn_plllc_clk1outdiv_preg = field; 851*09d976b3SSwapnil Jakhade 852*09d976b3SSwapnil Jakhade field = devm_regmap_field_alloc(dev, regmap, cmn_plllc_clk1_en_preg); 853*09d976b3SSwapnil Jakhade if (IS_ERR(field)) { 854*09d976b3SSwapnil Jakhade dev_err(dev, "cmn_plllc_clk1_en_preg reg field init failed\n"); 855*09d976b3SSwapnil Jakhade return PTR_ERR(field); 856*09d976b3SSwapnil Jakhade } 857*09d976b3SSwapnil Jakhade derived_refclk->cmn_plllc_clk1_en_preg = field; 858*09d976b3SSwapnil Jakhade 859*09d976b3SSwapnil Jakhade derived_refclk->hw.init = init; 860*09d976b3SSwapnil Jakhade 861*09d976b3SSwapnil Jakhade clk = devm_clk_register(dev, &derived_refclk->hw); 862*09d976b3SSwapnil Jakhade if (IS_ERR(clk)) 863*09d976b3SSwapnil Jakhade return PTR_ERR(clk); 864*09d976b3SSwapnil Jakhade 865*09d976b3SSwapnil Jakhade sp->output_clks[CDNS_SIERRA_DERIVED_REFCLK] = clk; 866*09d976b3SSwapnil Jakhade 867*09d976b3SSwapnil Jakhade return 0; 868*09d976b3SSwapnil Jakhade } 869*09d976b3SSwapnil Jakhade 87028081b72SKishon Vijay Abraham I static void cdns_sierra_clk_unregister(struct cdns_sierra_phy *sp) 87128081b72SKishon Vijay Abraham I { 87228081b72SKishon Vijay Abraham I struct device *dev = sp->dev; 87328081b72SKishon Vijay Abraham I struct device_node *node = dev->of_node; 87428081b72SKishon Vijay Abraham I 87528081b72SKishon Vijay Abraham I of_clk_del_provider(node); 87628081b72SKishon Vijay Abraham I } 87728081b72SKishon Vijay Abraham I 87828081b72SKishon Vijay Abraham I static int cdns_sierra_clk_register(struct cdns_sierra_phy *sp) 87928081b72SKishon Vijay Abraham I { 88028081b72SKishon Vijay Abraham I struct device *dev = sp->dev; 88128081b72SKishon Vijay Abraham I struct device_node *node = dev->of_node; 88228081b72SKishon Vijay Abraham I int ret; 88328081b72SKishon Vijay Abraham I 88428081b72SKishon Vijay Abraham I ret = cdns_sierra_phy_register_pll_mux(sp); 88528081b72SKishon Vijay Abraham I if (ret) { 88628081b72SKishon Vijay Abraham I dev_err(dev, "Failed to pll mux clocks\n"); 88728081b72SKishon Vijay Abraham I return ret; 88828081b72SKishon Vijay Abraham I } 88928081b72SKishon Vijay Abraham I 890*09d976b3SSwapnil Jakhade ret = cdns_sierra_derived_refclk_register(sp); 891*09d976b3SSwapnil Jakhade if (ret) { 892*09d976b3SSwapnil Jakhade dev_err(dev, "Failed to register derived refclk\n"); 893*09d976b3SSwapnil Jakhade return ret; 894*09d976b3SSwapnil Jakhade } 895*09d976b3SSwapnil Jakhade 89628081b72SKishon Vijay Abraham I sp->clk_data.clks = sp->output_clks; 89728081b72SKishon Vijay Abraham I sp->clk_data.clk_num = CDNS_SIERRA_OUTPUT_CLOCKS; 89828081b72SKishon Vijay Abraham I ret = of_clk_add_provider(node, of_clk_src_onecell_get, &sp->clk_data); 89928081b72SKishon Vijay Abraham I if (ret) 90028081b72SKishon Vijay Abraham I dev_err(dev, "Failed to add clock provider: %s\n", node->name); 90128081b72SKishon Vijay Abraham I 90228081b72SKishon Vijay Abraham I return ret; 90328081b72SKishon Vijay Abraham I } 90428081b72SKishon Vijay Abraham I 90544d30d62SAlan Douglas static int cdns_sierra_get_optional(struct cdns_sierra_inst *inst, 90644d30d62SAlan Douglas struct device_node *child) 90744d30d62SAlan Douglas { 908078e9e92SSwapnil Jakhade u32 phy_type; 909078e9e92SSwapnil Jakhade 91044d30d62SAlan Douglas if (of_property_read_u32(child, "reg", &inst->mlane)) 91144d30d62SAlan Douglas return -EINVAL; 91244d30d62SAlan Douglas 91344d30d62SAlan Douglas if (of_property_read_u32(child, "cdns,num-lanes", &inst->num_lanes)) 91444d30d62SAlan Douglas return -EINVAL; 91544d30d62SAlan Douglas 916078e9e92SSwapnil Jakhade if (of_property_read_u32(child, "cdns,phy-type", &phy_type)) 91744d30d62SAlan Douglas return -EINVAL; 91844d30d62SAlan Douglas 919078e9e92SSwapnil Jakhade switch (phy_type) { 920078e9e92SSwapnil Jakhade case PHY_TYPE_PCIE: 921078e9e92SSwapnil Jakhade inst->phy_type = TYPE_PCIE; 922078e9e92SSwapnil Jakhade break; 923078e9e92SSwapnil Jakhade case PHY_TYPE_USB3: 924078e9e92SSwapnil Jakhade inst->phy_type = TYPE_USB; 925078e9e92SSwapnil Jakhade break; 9268a1b82d7SSwapnil Jakhade case PHY_TYPE_QSGMII: 9278a1b82d7SSwapnil Jakhade inst->phy_type = TYPE_QSGMII; 9288a1b82d7SSwapnil Jakhade break; 929078e9e92SSwapnil Jakhade default: 930078e9e92SSwapnil Jakhade return -EINVAL; 931078e9e92SSwapnil Jakhade } 932078e9e92SSwapnil Jakhade 9331e902b2aSSwapnil Jakhade inst->ssc_mode = EXTERNAL_SSC; 9341e902b2aSSwapnil Jakhade of_property_read_u32(child, "cdns,ssc-mode", &inst->ssc_mode); 9351e902b2aSSwapnil Jakhade 93644d30d62SAlan Douglas return 0; 93744d30d62SAlan Douglas } 93844d30d62SAlan Douglas 939380f5708SKishon Vijay Abraham I static struct regmap *cdns_regmap_init(struct device *dev, void __iomem *base, 940380f5708SKishon Vijay Abraham I u32 block_offset, u8 reg_offset_shift, 941380f5708SKishon Vijay Abraham I const struct regmap_config *config) 942380f5708SKishon Vijay Abraham I { 943380f5708SKishon Vijay Abraham I struct cdns_regmap_cdb_context *ctx; 944380f5708SKishon Vijay Abraham I 945380f5708SKishon Vijay Abraham I ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL); 946380f5708SKishon Vijay Abraham I if (!ctx) 947380f5708SKishon Vijay Abraham I return ERR_PTR(-ENOMEM); 948380f5708SKishon Vijay Abraham I 949380f5708SKishon Vijay Abraham I ctx->dev = dev; 950380f5708SKishon Vijay Abraham I ctx->base = base + block_offset; 951380f5708SKishon Vijay Abraham I ctx->reg_offset_shift = reg_offset_shift; 952380f5708SKishon Vijay Abraham I 953380f5708SKishon Vijay Abraham I return devm_regmap_init(dev, NULL, ctx, config); 954380f5708SKishon Vijay Abraham I } 955380f5708SKishon Vijay Abraham I 956380f5708SKishon Vijay Abraham I static int cdns_regfield_init(struct cdns_sierra_phy *sp) 957380f5708SKishon Vijay Abraham I { 958380f5708SKishon Vijay Abraham I struct device *dev = sp->dev; 959380f5708SKishon Vijay Abraham I struct regmap_field *field; 96028081b72SKishon Vijay Abraham I struct reg_field reg_field; 961380f5708SKishon Vijay Abraham I struct regmap *regmap; 962adc4bd6fSKishon Vijay Abraham I int i; 963380f5708SKishon Vijay Abraham I 964380f5708SKishon Vijay Abraham I regmap = sp->regmap_common_cdb; 965380f5708SKishon Vijay Abraham I field = devm_regmap_field_alloc(dev, regmap, macro_id_type); 966380f5708SKishon Vijay Abraham I if (IS_ERR(field)) { 967380f5708SKishon Vijay Abraham I dev_err(dev, "MACRO_ID_TYPE reg field init failed\n"); 968380f5708SKishon Vijay Abraham I return PTR_ERR(field); 969380f5708SKishon Vijay Abraham I } 970380f5708SKishon Vijay Abraham I sp->macro_id_type = field; 971380f5708SKishon Vijay Abraham I 97228081b72SKishon Vijay Abraham I for (i = 0; i < SIERRA_NUM_CMN_PLLC; i++) { 97328081b72SKishon Vijay Abraham I reg_field = cmn_plllc_pfdclk1_sel_preg[i].pfdclk_sel_preg; 97428081b72SKishon Vijay Abraham I field = devm_regmap_field_alloc(dev, regmap, reg_field); 97528081b72SKishon Vijay Abraham I if (IS_ERR(field)) { 97628081b72SKishon Vijay Abraham I dev_err(dev, "PLLLC%d_PFDCLK1_SEL failed\n", i); 97728081b72SKishon Vijay Abraham I return PTR_ERR(field); 97828081b72SKishon Vijay Abraham I } 97928081b72SKishon Vijay Abraham I sp->cmn_plllc_pfdclk1_sel_preg[i] = field; 98028081b72SKishon Vijay Abraham I 98128081b72SKishon Vijay Abraham I reg_field = cmn_plllc_pfdclk1_sel_preg[i].plllc1en_field; 98228081b72SKishon Vijay Abraham I field = devm_regmap_field_alloc(dev, regmap, reg_field); 98328081b72SKishon Vijay Abraham I if (IS_ERR(field)) { 98428081b72SKishon Vijay Abraham I dev_err(dev, "REFRCV%d_REFCLK_PLLLC1EN failed\n", i); 98528081b72SKishon Vijay Abraham I return PTR_ERR(field); 98628081b72SKishon Vijay Abraham I } 98728081b72SKishon Vijay Abraham I sp->cmn_refrcv_refclk_plllc1en_preg[i] = field; 98828081b72SKishon Vijay Abraham I 98928081b72SKishon Vijay Abraham I reg_field = cmn_plllc_pfdclk1_sel_preg[i].termen_field; 99028081b72SKishon Vijay Abraham I field = devm_regmap_field_alloc(dev, regmap, reg_field); 99128081b72SKishon Vijay Abraham I if (IS_ERR(field)) { 99228081b72SKishon Vijay Abraham I dev_err(dev, "REFRCV%d_REFCLK_TERMEN failed\n", i); 99328081b72SKishon Vijay Abraham I return PTR_ERR(field); 99428081b72SKishon Vijay Abraham I } 99528081b72SKishon Vijay Abraham I sp->cmn_refrcv_refclk_termen_preg[i] = field; 99628081b72SKishon Vijay Abraham I } 99728081b72SKishon Vijay Abraham I 9988c95e172SSwapnil Jakhade regmap = sp->regmap_phy_pcs_common_cdb; 999380f5708SKishon Vijay Abraham I field = devm_regmap_field_alloc(dev, regmap, phy_pll_cfg_1); 1000380f5708SKishon Vijay Abraham I if (IS_ERR(field)) { 1001380f5708SKishon Vijay Abraham I dev_err(dev, "PHY_PLL_CFG_1 reg field init failed\n"); 1002380f5708SKishon Vijay Abraham I return PTR_ERR(field); 1003380f5708SKishon Vijay Abraham I } 1004380f5708SKishon Vijay Abraham I sp->phy_pll_cfg_1 = field; 1005380f5708SKishon Vijay Abraham I 1006f1cc6c3fSSwapnil Jakhade regmap = sp->regmap_phy_pma_common_cdb; 1007f1cc6c3fSSwapnil Jakhade field = devm_regmap_field_alloc(dev, regmap, pma_cmn_ready); 1008f1cc6c3fSSwapnil Jakhade if (IS_ERR(field)) { 1009f1cc6c3fSSwapnil Jakhade dev_err(dev, "PHY_PMA_CMN_CTRL reg field init failed\n"); 1010f1cc6c3fSSwapnil Jakhade return PTR_ERR(field); 1011f1cc6c3fSSwapnil Jakhade } 1012f1cc6c3fSSwapnil Jakhade sp->pma_cmn_ready = field; 1013f1cc6c3fSSwapnil Jakhade 1014adc4bd6fSKishon Vijay Abraham I for (i = 0; i < SIERRA_MAX_LANES; i++) { 1015adc4bd6fSKishon Vijay Abraham I regmap = sp->regmap_lane_cdb[i]; 1016adc4bd6fSKishon Vijay Abraham I field = devm_regmap_field_alloc(dev, regmap, pllctrl_lock); 1017adc4bd6fSKishon Vijay Abraham I if (IS_ERR(field)) { 1018adc4bd6fSKishon Vijay Abraham I dev_err(dev, "P%d_ENABLE reg field init failed\n", i); 1019adc4bd6fSKishon Vijay Abraham I return PTR_ERR(field); 1020adc4bd6fSKishon Vijay Abraham I } 1021adc4bd6fSKishon Vijay Abraham I sp->pllctrl_lock[i] = field; 1022adc4bd6fSKishon Vijay Abraham I } 1023adc4bd6fSKishon Vijay Abraham I 102436ce4163SSwapnil Jakhade for (i = 0; i < SIERRA_MAX_LANES; i++) { 102536ce4163SSwapnil Jakhade regmap = sp->regmap_phy_pcs_lane_cdb[i]; 102636ce4163SSwapnil Jakhade field = devm_regmap_field_alloc(dev, regmap, phy_iso_link_ctrl_1); 102736ce4163SSwapnil Jakhade if (IS_ERR(field)) { 102836ce4163SSwapnil Jakhade dev_err(dev, "PHY_ISO_LINK_CTRL reg field init for lane %d failed\n", i); 102936ce4163SSwapnil Jakhade return PTR_ERR(field); 103036ce4163SSwapnil Jakhade } 103136ce4163SSwapnil Jakhade sp->phy_iso_link_ctrl_1[i] = field; 103236ce4163SSwapnil Jakhade } 103336ce4163SSwapnil Jakhade 1034380f5708SKishon Vijay Abraham I return 0; 1035380f5708SKishon Vijay Abraham I } 1036380f5708SKishon Vijay Abraham I 1037380f5708SKishon Vijay Abraham I static int cdns_regmap_init_blocks(struct cdns_sierra_phy *sp, 1038380f5708SKishon Vijay Abraham I void __iomem *base, u8 block_offset_shift, 1039380f5708SKishon Vijay Abraham I u8 reg_offset_shift) 1040380f5708SKishon Vijay Abraham I { 1041380f5708SKishon Vijay Abraham I struct device *dev = sp->dev; 1042380f5708SKishon Vijay Abraham I struct regmap *regmap; 1043380f5708SKishon Vijay Abraham I u32 block_offset; 1044380f5708SKishon Vijay Abraham I int i; 1045380f5708SKishon Vijay Abraham I 1046380f5708SKishon Vijay Abraham I for (i = 0; i < SIERRA_MAX_LANES; i++) { 1047380f5708SKishon Vijay Abraham I block_offset = SIERRA_LANE_CDB_OFFSET(i, block_offset_shift, 1048380f5708SKishon Vijay Abraham I reg_offset_shift); 1049380f5708SKishon Vijay Abraham I regmap = cdns_regmap_init(dev, base, block_offset, 1050380f5708SKishon Vijay Abraham I reg_offset_shift, 1051380f5708SKishon Vijay Abraham I &cdns_sierra_lane_cdb_config[i]); 1052380f5708SKishon Vijay Abraham I if (IS_ERR(regmap)) { 1053380f5708SKishon Vijay Abraham I dev_err(dev, "Failed to init lane CDB regmap\n"); 1054380f5708SKishon Vijay Abraham I return PTR_ERR(regmap); 1055380f5708SKishon Vijay Abraham I } 1056380f5708SKishon Vijay Abraham I sp->regmap_lane_cdb[i] = regmap; 1057380f5708SKishon Vijay Abraham I } 1058380f5708SKishon Vijay Abraham I 1059380f5708SKishon Vijay Abraham I regmap = cdns_regmap_init(dev, base, SIERRA_COMMON_CDB_OFFSET, 1060380f5708SKishon Vijay Abraham I reg_offset_shift, 1061380f5708SKishon Vijay Abraham I &cdns_sierra_common_cdb_config); 1062380f5708SKishon Vijay Abraham I if (IS_ERR(regmap)) { 1063380f5708SKishon Vijay Abraham I dev_err(dev, "Failed to init common CDB regmap\n"); 1064380f5708SKishon Vijay Abraham I return PTR_ERR(regmap); 1065380f5708SKishon Vijay Abraham I } 1066380f5708SKishon Vijay Abraham I sp->regmap_common_cdb = regmap; 1067380f5708SKishon Vijay Abraham I 10688c95e172SSwapnil Jakhade block_offset = SIERRA_PHY_PCS_COMMON_OFFSET(block_offset_shift); 1069380f5708SKishon Vijay Abraham I regmap = cdns_regmap_init(dev, base, block_offset, reg_offset_shift, 10708c95e172SSwapnil Jakhade &cdns_sierra_phy_pcs_cmn_cdb_config); 1071380f5708SKishon Vijay Abraham I if (IS_ERR(regmap)) { 10728c95e172SSwapnil Jakhade dev_err(dev, "Failed to init PHY PCS common CDB regmap\n"); 1073380f5708SKishon Vijay Abraham I return PTR_ERR(regmap); 1074380f5708SKishon Vijay Abraham I } 10758c95e172SSwapnil Jakhade sp->regmap_phy_pcs_common_cdb = regmap; 1076380f5708SKishon Vijay Abraham I 107736ce4163SSwapnil Jakhade for (i = 0; i < SIERRA_MAX_LANES; i++) { 107836ce4163SSwapnil Jakhade block_offset = SIERRA_PHY_PCS_LANE_CDB_OFFSET(i, block_offset_shift, 107936ce4163SSwapnil Jakhade reg_offset_shift); 108036ce4163SSwapnil Jakhade regmap = cdns_regmap_init(dev, base, block_offset, 108136ce4163SSwapnil Jakhade reg_offset_shift, 108236ce4163SSwapnil Jakhade &cdns_sierra_phy_pcs_lane_cdb_config[i]); 108336ce4163SSwapnil Jakhade if (IS_ERR(regmap)) { 108436ce4163SSwapnil Jakhade dev_err(dev, "Failed to init PHY PCS lane CDB regmap\n"); 108536ce4163SSwapnil Jakhade return PTR_ERR(regmap); 108636ce4163SSwapnil Jakhade } 108736ce4163SSwapnil Jakhade sp->regmap_phy_pcs_lane_cdb[i] = regmap; 108836ce4163SSwapnil Jakhade } 108936ce4163SSwapnil Jakhade 1090f1cc6c3fSSwapnil Jakhade block_offset = SIERRA_PHY_PMA_COMMON_OFFSET(block_offset_shift); 1091f1cc6c3fSSwapnil Jakhade regmap = cdns_regmap_init(dev, base, block_offset, reg_offset_shift, 1092f1cc6c3fSSwapnil Jakhade &cdns_sierra_phy_pma_cmn_cdb_config); 1093f1cc6c3fSSwapnil Jakhade if (IS_ERR(regmap)) { 1094f1cc6c3fSSwapnil Jakhade dev_err(dev, "Failed to init PHY PMA common CDB regmap\n"); 1095f1cc6c3fSSwapnil Jakhade return PTR_ERR(regmap); 1096f1cc6c3fSSwapnil Jakhade } 1097f1cc6c3fSSwapnil Jakhade sp->regmap_phy_pma_common_cdb = regmap; 1098f1cc6c3fSSwapnil Jakhade 10996b81f05aSSwapnil Jakhade for (i = 0; i < SIERRA_MAX_LANES; i++) { 11006b81f05aSSwapnil Jakhade block_offset = SIERRA_PHY_PMA_LANE_CDB_OFFSET(i, block_offset_shift, 11016b81f05aSSwapnil Jakhade reg_offset_shift); 11026b81f05aSSwapnil Jakhade regmap = cdns_regmap_init(dev, base, block_offset, 11036b81f05aSSwapnil Jakhade reg_offset_shift, 11046b81f05aSSwapnil Jakhade &cdns_sierra_phy_pma_lane_cdb_config[i]); 11056b81f05aSSwapnil Jakhade if (IS_ERR(regmap)) { 11066b81f05aSSwapnil Jakhade dev_err(dev, "Failed to init PHY PMA lane CDB regmap\n"); 11076b81f05aSSwapnil Jakhade return PTR_ERR(regmap); 11086b81f05aSSwapnil Jakhade } 11096b81f05aSSwapnil Jakhade sp->regmap_phy_pma_lane_cdb[i] = regmap; 11106b81f05aSSwapnil Jakhade } 11116b81f05aSSwapnil Jakhade 1112380f5708SKishon Vijay Abraham I return 0; 1113380f5708SKishon Vijay Abraham I } 1114380f5708SKishon Vijay Abraham I 11157e016cbcSKishon Vijay Abraham I static int cdns_sierra_phy_get_clocks(struct cdns_sierra_phy *sp, 11167e016cbcSKishon Vijay Abraham I struct device *dev) 11177e016cbcSKishon Vijay Abraham I { 11187e016cbcSKishon Vijay Abraham I struct clk *clk; 11197e016cbcSKishon Vijay Abraham I int ret; 11207e016cbcSKishon Vijay Abraham I 11217e016cbcSKishon Vijay Abraham I clk = devm_clk_get_optional(dev, "phy_clk"); 11227e016cbcSKishon Vijay Abraham I if (IS_ERR(clk)) { 11237e016cbcSKishon Vijay Abraham I dev_err(dev, "failed to get clock phy_clk\n"); 11247e016cbcSKishon Vijay Abraham I return PTR_ERR(clk); 11257e016cbcSKishon Vijay Abraham I } 1126a0c30cd7SKishon Vijay Abraham I sp->input_clks[PHY_CLK] = clk; 11277e016cbcSKishon Vijay Abraham I 11287e016cbcSKishon Vijay Abraham I clk = devm_clk_get_optional(dev, "cmn_refclk_dig_div"); 11297e016cbcSKishon Vijay Abraham I if (IS_ERR(clk)) { 11307e016cbcSKishon Vijay Abraham I dev_err(dev, "cmn_refclk_dig_div clock not found\n"); 11317e016cbcSKishon Vijay Abraham I ret = PTR_ERR(clk); 11327e016cbcSKishon Vijay Abraham I return ret; 11337e016cbcSKishon Vijay Abraham I } 1134a0c30cd7SKishon Vijay Abraham I sp->input_clks[CMN_REFCLK_DIG_DIV] = clk; 11357e016cbcSKishon Vijay Abraham I 11367e016cbcSKishon Vijay Abraham I clk = devm_clk_get_optional(dev, "cmn_refclk1_dig_div"); 11377e016cbcSKishon Vijay Abraham I if (IS_ERR(clk)) { 11387e016cbcSKishon Vijay Abraham I dev_err(dev, "cmn_refclk1_dig_div clock not found\n"); 11397e016cbcSKishon Vijay Abraham I ret = PTR_ERR(clk); 11407e016cbcSKishon Vijay Abraham I return ret; 11417e016cbcSKishon Vijay Abraham I } 1142a0c30cd7SKishon Vijay Abraham I sp->input_clks[CMN_REFCLK1_DIG_DIV] = clk; 11437e016cbcSKishon Vijay Abraham I 114428081b72SKishon Vijay Abraham I clk = devm_clk_get_optional(dev, "pll0_refclk"); 114528081b72SKishon Vijay Abraham I if (IS_ERR(clk)) { 114628081b72SKishon Vijay Abraham I dev_err(dev, "pll0_refclk clock not found\n"); 114728081b72SKishon Vijay Abraham I ret = PTR_ERR(clk); 114828081b72SKishon Vijay Abraham I return ret; 114928081b72SKishon Vijay Abraham I } 115028081b72SKishon Vijay Abraham I sp->input_clks[PLL0_REFCLK] = clk; 115128081b72SKishon Vijay Abraham I 115228081b72SKishon Vijay Abraham I clk = devm_clk_get_optional(dev, "pll1_refclk"); 115328081b72SKishon Vijay Abraham I if (IS_ERR(clk)) { 115428081b72SKishon Vijay Abraham I dev_err(dev, "pll1_refclk clock not found\n"); 115528081b72SKishon Vijay Abraham I ret = PTR_ERR(clk); 115628081b72SKishon Vijay Abraham I return ret; 115728081b72SKishon Vijay Abraham I } 115828081b72SKishon Vijay Abraham I sp->input_clks[PLL1_REFCLK] = clk; 115928081b72SKishon Vijay Abraham I 11607e016cbcSKishon Vijay Abraham I return 0; 11617e016cbcSKishon Vijay Abraham I } 11627e016cbcSKishon Vijay Abraham I 11631436ec30SKishon Vijay Abraham I static int cdns_sierra_phy_enable_clocks(struct cdns_sierra_phy *sp) 11641436ec30SKishon Vijay Abraham I { 11651436ec30SKishon Vijay Abraham I int ret; 11661436ec30SKishon Vijay Abraham I 11671436ec30SKishon Vijay Abraham I ret = clk_prepare_enable(sp->input_clks[PHY_CLK]); 11681436ec30SKishon Vijay Abraham I if (ret) 11691436ec30SKishon Vijay Abraham I return ret; 11701436ec30SKishon Vijay Abraham I 11711436ec30SKishon Vijay Abraham I ret = clk_prepare_enable(sp->output_clks[CDNS_SIERRA_PLL_CMNLC]); 11721436ec30SKishon Vijay Abraham I if (ret) 11731436ec30SKishon Vijay Abraham I goto err_pll_cmnlc; 11741436ec30SKishon Vijay Abraham I 11751436ec30SKishon Vijay Abraham I ret = clk_prepare_enable(sp->output_clks[CDNS_SIERRA_PLL_CMNLC1]); 11761436ec30SKishon Vijay Abraham I if (ret) 11771436ec30SKishon Vijay Abraham I goto err_pll_cmnlc1; 11781436ec30SKishon Vijay Abraham I 11791436ec30SKishon Vijay Abraham I return 0; 11801436ec30SKishon Vijay Abraham I 11811436ec30SKishon Vijay Abraham I err_pll_cmnlc1: 11821436ec30SKishon Vijay Abraham I clk_disable_unprepare(sp->output_clks[CDNS_SIERRA_PLL_CMNLC]); 11831436ec30SKishon Vijay Abraham I 11841436ec30SKishon Vijay Abraham I err_pll_cmnlc: 11851436ec30SKishon Vijay Abraham I clk_disable_unprepare(sp->input_clks[PHY_CLK]); 11861436ec30SKishon Vijay Abraham I 11871436ec30SKishon Vijay Abraham I return ret; 11881436ec30SKishon Vijay Abraham I } 11891436ec30SKishon Vijay Abraham I 11901436ec30SKishon Vijay Abraham I static void cdns_sierra_phy_disable_clocks(struct cdns_sierra_phy *sp) 11911436ec30SKishon Vijay Abraham I { 11921436ec30SKishon Vijay Abraham I clk_disable_unprepare(sp->output_clks[CDNS_SIERRA_PLL_CMNLC1]); 11931436ec30SKishon Vijay Abraham I clk_disable_unprepare(sp->output_clks[CDNS_SIERRA_PLL_CMNLC]); 11941436ec30SKishon Vijay Abraham I clk_disable_unprepare(sp->input_clks[PHY_CLK]); 11951436ec30SKishon Vijay Abraham I } 11961436ec30SKishon Vijay Abraham I 11971d5f40e0SKishon Vijay Abraham I static int cdns_sierra_phy_get_resets(struct cdns_sierra_phy *sp, 11981d5f40e0SKishon Vijay Abraham I struct device *dev) 11991d5f40e0SKishon Vijay Abraham I { 12001d5f40e0SKishon Vijay Abraham I struct reset_control *rst; 12011d5f40e0SKishon Vijay Abraham I 120215b0b82dSKishon Vijay Abraham I rst = devm_reset_control_get_exclusive(dev, "sierra_reset"); 12031d5f40e0SKishon Vijay Abraham I if (IS_ERR(rst)) { 12041d5f40e0SKishon Vijay Abraham I dev_err(dev, "failed to get reset\n"); 12051d5f40e0SKishon Vijay Abraham I return PTR_ERR(rst); 12061d5f40e0SKishon Vijay Abraham I } 12071d5f40e0SKishon Vijay Abraham I sp->phy_rst = rst; 12081d5f40e0SKishon Vijay Abraham I 120915b0b82dSKishon Vijay Abraham I rst = devm_reset_control_get_optional_exclusive(dev, "sierra_apb"); 12101d5f40e0SKishon Vijay Abraham I if (IS_ERR(rst)) { 12111d5f40e0SKishon Vijay Abraham I dev_err(dev, "failed to get apb reset\n"); 12121d5f40e0SKishon Vijay Abraham I return PTR_ERR(rst); 12131d5f40e0SKishon Vijay Abraham I } 12141d5f40e0SKishon Vijay Abraham I sp->apb_rst = rst; 12151d5f40e0SKishon Vijay Abraham I 12161d5f40e0SKishon Vijay Abraham I return 0; 12171d5f40e0SKishon Vijay Abraham I } 12181d5f40e0SKishon Vijay Abraham I 12196b81f05aSSwapnil Jakhade static int cdns_sierra_phy_configure_multilink(struct cdns_sierra_phy *sp) 12206b81f05aSSwapnil Jakhade { 12216b81f05aSSwapnil Jakhade const struct cdns_sierra_data *init_data = sp->init_data; 12226b81f05aSSwapnil Jakhade struct cdns_sierra_vals *pma_cmn_vals, *pma_ln_vals; 12236b81f05aSSwapnil Jakhade enum cdns_sierra_phy_type phy_t1, phy_t2; 12246b81f05aSSwapnil Jakhade struct cdns_sierra_vals *phy_pma_ln_vals; 12256b81f05aSSwapnil Jakhade const struct cdns_reg_pairs *reg_pairs; 12266b81f05aSSwapnil Jakhade struct cdns_sierra_vals *pcs_cmn_vals; 12276b81f05aSSwapnil Jakhade int i, j, node, mlane, num_lanes, ret; 12286b81f05aSSwapnil Jakhade enum cdns_sierra_ssc_mode ssc; 12296b81f05aSSwapnil Jakhade struct regmap *regmap; 12306b81f05aSSwapnil Jakhade u32 num_regs; 12316b81f05aSSwapnil Jakhade 12326b81f05aSSwapnil Jakhade /* Maximum 2 links (subnodes) are supported */ 12336b81f05aSSwapnil Jakhade if (sp->nsubnodes != 2) 12346b81f05aSSwapnil Jakhade return -EINVAL; 12356b81f05aSSwapnil Jakhade 12366b81f05aSSwapnil Jakhade clk_set_rate(sp->input_clks[CMN_REFCLK_DIG_DIV], 25000000); 12376b81f05aSSwapnil Jakhade clk_set_rate(sp->input_clks[CMN_REFCLK1_DIG_DIV], 25000000); 12386b81f05aSSwapnil Jakhade 12396b81f05aSSwapnil Jakhade /* PHY configured to use both PLL LC and LC1 */ 12406b81f05aSSwapnil Jakhade regmap_field_write(sp->phy_pll_cfg_1, 0x1); 12416b81f05aSSwapnil Jakhade 12426b81f05aSSwapnil Jakhade phy_t1 = sp->phys[0].phy_type; 12436b81f05aSSwapnil Jakhade phy_t2 = sp->phys[1].phy_type; 12446b81f05aSSwapnil Jakhade 12456b81f05aSSwapnil Jakhade /* 12466b81f05aSSwapnil Jakhade * PHY configuration for multi-link operation is done in two steps. 12476b81f05aSSwapnil Jakhade * e.g. Consider a case for a 4 lane PHY with PCIe using 2 lanes and QSGMII other 2 lanes. 12486b81f05aSSwapnil Jakhade * Sierra PHY has 2 PLLs, viz. PLLLC and PLLLC1. So in this case, PLLLC is used for PCIe 12496b81f05aSSwapnil Jakhade * and PLLLC1 is used for QSGMII. PHY is configured in two steps as described below. 12506b81f05aSSwapnil Jakhade * 12516b81f05aSSwapnil Jakhade * [1] For first step, phy_t1 = TYPE_PCIE and phy_t2 = TYPE_QSGMII 12526b81f05aSSwapnil Jakhade * So the register values are selected as [TYPE_PCIE][TYPE_QSGMII][ssc]. 12536b81f05aSSwapnil Jakhade * This will configure PHY registers associated for PCIe (i.e. first protocol) 12546b81f05aSSwapnil Jakhade * involving PLLLC registers and registers for first 2 lanes of PHY. 12556b81f05aSSwapnil Jakhade * [2] In second step, the variables phy_t1 and phy_t2 are swapped. So now, 12566b81f05aSSwapnil Jakhade * phy_t1 = TYPE_QSGMII and phy_t2 = TYPE_PCIE. And the register values are selected as 12576b81f05aSSwapnil Jakhade * [TYPE_QSGMII][TYPE_PCIE][ssc]. 12586b81f05aSSwapnil Jakhade * This will configure PHY registers associated for QSGMII (i.e. second protocol) 12596b81f05aSSwapnil Jakhade * involving PLLLC1 registers and registers for other 2 lanes of PHY. 12606b81f05aSSwapnil Jakhade * 12616b81f05aSSwapnil Jakhade * This completes the PHY configuration for multilink operation. This approach enables 12626b81f05aSSwapnil Jakhade * dividing the large number of PHY register configurations into protocol specific 12636b81f05aSSwapnil Jakhade * smaller groups. 12646b81f05aSSwapnil Jakhade */ 12656b81f05aSSwapnil Jakhade for (node = 0; node < sp->nsubnodes; node++) { 12666b81f05aSSwapnil Jakhade if (node == 1) { 12676b81f05aSSwapnil Jakhade /* 12686b81f05aSSwapnil Jakhade * If first link with phy_t1 is configured, then configure the PHY for 12696b81f05aSSwapnil Jakhade * second link with phy_t2. Get the array values as [phy_t2][phy_t1][ssc]. 12706b81f05aSSwapnil Jakhade */ 12716b81f05aSSwapnil Jakhade swap(phy_t1, phy_t2); 12726b81f05aSSwapnil Jakhade } 12736b81f05aSSwapnil Jakhade 12746b81f05aSSwapnil Jakhade mlane = sp->phys[node].mlane; 12756b81f05aSSwapnil Jakhade ssc = sp->phys[node].ssc_mode; 12766b81f05aSSwapnil Jakhade num_lanes = sp->phys[node].num_lanes; 12776b81f05aSSwapnil Jakhade 12786b81f05aSSwapnil Jakhade /* PHY PCS common registers configurations */ 12796b81f05aSSwapnil Jakhade pcs_cmn_vals = init_data->pcs_cmn_vals[phy_t1][phy_t2][ssc]; 12806b81f05aSSwapnil Jakhade if (pcs_cmn_vals) { 12816b81f05aSSwapnil Jakhade reg_pairs = pcs_cmn_vals->reg_pairs; 12826b81f05aSSwapnil Jakhade num_regs = pcs_cmn_vals->num_regs; 12836b81f05aSSwapnil Jakhade regmap = sp->regmap_phy_pcs_common_cdb; 12846b81f05aSSwapnil Jakhade for (i = 0; i < num_regs; i++) 12856b81f05aSSwapnil Jakhade regmap_write(regmap, reg_pairs[i].off, reg_pairs[i].val); 12866b81f05aSSwapnil Jakhade } 12876b81f05aSSwapnil Jakhade 12886b81f05aSSwapnil Jakhade /* PHY PMA lane registers configurations */ 12896b81f05aSSwapnil Jakhade phy_pma_ln_vals = init_data->phy_pma_ln_vals[phy_t1][phy_t2][ssc]; 12906b81f05aSSwapnil Jakhade if (phy_pma_ln_vals) { 12916b81f05aSSwapnil Jakhade reg_pairs = phy_pma_ln_vals->reg_pairs; 12926b81f05aSSwapnil Jakhade num_regs = phy_pma_ln_vals->num_regs; 12936b81f05aSSwapnil Jakhade for (i = 0; i < num_lanes; i++) { 12946b81f05aSSwapnil Jakhade regmap = sp->regmap_phy_pma_lane_cdb[i + mlane]; 12956b81f05aSSwapnil Jakhade for (j = 0; j < num_regs; j++) 12966b81f05aSSwapnil Jakhade regmap_write(regmap, reg_pairs[j].off, reg_pairs[j].val); 12976b81f05aSSwapnil Jakhade } 12986b81f05aSSwapnil Jakhade } 12996b81f05aSSwapnil Jakhade 13006b81f05aSSwapnil Jakhade /* PMA common registers configurations */ 13016b81f05aSSwapnil Jakhade pma_cmn_vals = init_data->pma_cmn_vals[phy_t1][phy_t2][ssc]; 13026b81f05aSSwapnil Jakhade if (pma_cmn_vals) { 13036b81f05aSSwapnil Jakhade reg_pairs = pma_cmn_vals->reg_pairs; 13046b81f05aSSwapnil Jakhade num_regs = pma_cmn_vals->num_regs; 13056b81f05aSSwapnil Jakhade regmap = sp->regmap_common_cdb; 13066b81f05aSSwapnil Jakhade for (i = 0; i < num_regs; i++) 13076b81f05aSSwapnil Jakhade regmap_write(regmap, reg_pairs[i].off, reg_pairs[i].val); 13086b81f05aSSwapnil Jakhade } 13096b81f05aSSwapnil Jakhade 13106b81f05aSSwapnil Jakhade /* PMA lane registers configurations */ 13116b81f05aSSwapnil Jakhade pma_ln_vals = init_data->pma_ln_vals[phy_t1][phy_t2][ssc]; 13126b81f05aSSwapnil Jakhade if (pma_ln_vals) { 13136b81f05aSSwapnil Jakhade reg_pairs = pma_ln_vals->reg_pairs; 13146b81f05aSSwapnil Jakhade num_regs = pma_ln_vals->num_regs; 13156b81f05aSSwapnil Jakhade for (i = 0; i < num_lanes; i++) { 13166b81f05aSSwapnil Jakhade regmap = sp->regmap_lane_cdb[i + mlane]; 13176b81f05aSSwapnil Jakhade for (j = 0; j < num_regs; j++) 13186b81f05aSSwapnil Jakhade regmap_write(regmap, reg_pairs[j].off, reg_pairs[j].val); 13196b81f05aSSwapnil Jakhade } 13206b81f05aSSwapnil Jakhade } 13218a1b82d7SSwapnil Jakhade 13228a1b82d7SSwapnil Jakhade if (phy_t1 == TYPE_QSGMII) 13238a1b82d7SSwapnil Jakhade reset_control_deassert(sp->phys[node].lnk_rst); 13246b81f05aSSwapnil Jakhade } 13256b81f05aSSwapnil Jakhade 13266b81f05aSSwapnil Jakhade /* Take the PHY out of reset */ 13276b81f05aSSwapnil Jakhade ret = reset_control_deassert(sp->phy_rst); 13286b81f05aSSwapnil Jakhade if (ret) 13296b81f05aSSwapnil Jakhade return ret; 13306b81f05aSSwapnil Jakhade 13316b81f05aSSwapnil Jakhade return 0; 13326b81f05aSSwapnil Jakhade } 13336b81f05aSSwapnil Jakhade 133444d30d62SAlan Douglas static int cdns_sierra_phy_probe(struct platform_device *pdev) 133544d30d62SAlan Douglas { 133644d30d62SAlan Douglas struct cdns_sierra_phy *sp; 133744d30d62SAlan Douglas struct phy_provider *phy_provider; 133844d30d62SAlan Douglas struct device *dev = &pdev->dev; 1339c3c11d55SSwapnil Jakhade const struct cdns_sierra_data *data; 1340380f5708SKishon Vijay Abraham I unsigned int id_value; 134144d30d62SAlan Douglas int i, ret, node = 0; 1342380f5708SKishon Vijay Abraham I void __iomem *base; 134344d30d62SAlan Douglas struct device_node *dn = dev->of_node, *child; 134444d30d62SAlan Douglas 134544d30d62SAlan Douglas if (of_get_child_count(dn) == 0) 134644d30d62SAlan Douglas return -ENODEV; 134744d30d62SAlan Douglas 1348380f5708SKishon Vijay Abraham I /* Get init data for this PHY */ 1349c3c11d55SSwapnil Jakhade data = of_device_get_match_data(dev); 1350c3c11d55SSwapnil Jakhade if (!data) 1351380f5708SKishon Vijay Abraham I return -EINVAL; 1352380f5708SKishon Vijay Abraham I 135344d30d62SAlan Douglas sp = devm_kzalloc(dev, sizeof(*sp), GFP_KERNEL); 135444d30d62SAlan Douglas if (!sp) 135544d30d62SAlan Douglas return -ENOMEM; 135644d30d62SAlan Douglas dev_set_drvdata(dev, sp); 135744d30d62SAlan Douglas sp->dev = dev; 1358380f5708SKishon Vijay Abraham I sp->init_data = data; 135944d30d62SAlan Douglas 1360fa629094SChunfeng Yun base = devm_platform_ioremap_resource(pdev, 0); 1361380f5708SKishon Vijay Abraham I if (IS_ERR(base)) { 136244d30d62SAlan Douglas dev_err(dev, "missing \"reg\"\n"); 1363380f5708SKishon Vijay Abraham I return PTR_ERR(base); 136444d30d62SAlan Douglas } 136544d30d62SAlan Douglas 1366380f5708SKishon Vijay Abraham I ret = cdns_regmap_init_blocks(sp, base, data->block_offset_shift, 1367380f5708SKishon Vijay Abraham I data->reg_offset_shift); 1368380f5708SKishon Vijay Abraham I if (ret) 1369380f5708SKishon Vijay Abraham I return ret; 1370380f5708SKishon Vijay Abraham I 1371380f5708SKishon Vijay Abraham I ret = cdns_regfield_init(sp); 1372380f5708SKishon Vijay Abraham I if (ret) 1373380f5708SKishon Vijay Abraham I return ret; 137444d30d62SAlan Douglas 137544d30d62SAlan Douglas platform_set_drvdata(pdev, sp); 137644d30d62SAlan Douglas 13777e016cbcSKishon Vijay Abraham I ret = cdns_sierra_phy_get_clocks(sp, dev); 13787e016cbcSKishon Vijay Abraham I if (ret) 13797e016cbcSKishon Vijay Abraham I return ret; 138044d30d62SAlan Douglas 138128081b72SKishon Vijay Abraham I ret = cdns_sierra_clk_register(sp); 13821d5f40e0SKishon Vijay Abraham I if (ret) 13831d5f40e0SKishon Vijay Abraham I return ret; 138444d30d62SAlan Douglas 138528081b72SKishon Vijay Abraham I ret = cdns_sierra_phy_get_resets(sp, dev); 138628081b72SKishon Vijay Abraham I if (ret) 138728081b72SKishon Vijay Abraham I goto unregister_clk; 138828081b72SKishon Vijay Abraham I 13891436ec30SKishon Vijay Abraham I ret = cdns_sierra_phy_enable_clocks(sp); 139044d30d62SAlan Douglas if (ret) 139128081b72SKishon Vijay Abraham I goto unregister_clk; 139244d30d62SAlan Douglas 139344d30d62SAlan Douglas /* Enable APB */ 139444d30d62SAlan Douglas reset_control_deassert(sp->apb_rst); 139544d30d62SAlan Douglas 139644d30d62SAlan Douglas /* Check that PHY is present */ 1397380f5708SKishon Vijay Abraham I regmap_field_read(sp->macro_id_type, &id_value); 1398380f5708SKishon Vijay Abraham I if (sp->init_data->id_value != id_value) { 139944d30d62SAlan Douglas ret = -EINVAL; 140044d30d62SAlan Douglas goto clk_disable; 140144d30d62SAlan Douglas } 140244d30d62SAlan Douglas 140344d30d62SAlan Douglas sp->autoconf = of_property_read_bool(dn, "cdns,autoconf"); 140444d30d62SAlan Douglas 140544d30d62SAlan Douglas for_each_available_child_of_node(dn, child) { 140644d30d62SAlan Douglas struct phy *gphy; 140744d30d62SAlan Douglas 140803ada5a3SKishon Vijay Abraham I if (!(of_node_name_eq(child, "phy") || 140903ada5a3SKishon Vijay Abraham I of_node_name_eq(child, "link"))) 141003ada5a3SKishon Vijay Abraham I continue; 141103ada5a3SKishon Vijay Abraham I 141244d30d62SAlan Douglas sp->phys[node].lnk_rst = 1413b872936fSKishon Vijay Abraham I of_reset_control_array_get_exclusive(child); 141444d30d62SAlan Douglas 141544d30d62SAlan Douglas if (IS_ERR(sp->phys[node].lnk_rst)) { 141644d30d62SAlan Douglas dev_err(dev, "failed to get reset %s\n", 141744d30d62SAlan Douglas child->full_name); 141844d30d62SAlan Douglas ret = PTR_ERR(sp->phys[node].lnk_rst); 141944d30d62SAlan Douglas goto put_child2; 142044d30d62SAlan Douglas } 142144d30d62SAlan Douglas 142244d30d62SAlan Douglas if (!sp->autoconf) { 142344d30d62SAlan Douglas ret = cdns_sierra_get_optional(&sp->phys[node], child); 142444d30d62SAlan Douglas if (ret) { 142544d30d62SAlan Douglas dev_err(dev, "missing property in node %s\n", 142644d30d62SAlan Douglas child->name); 142744d30d62SAlan Douglas goto put_child; 142844d30d62SAlan Douglas } 142944d30d62SAlan Douglas } 143044d30d62SAlan Douglas 1431a43f72aeSKishon Vijay Abraham I sp->num_lanes += sp->phys[node].num_lanes; 1432a43f72aeSKishon Vijay Abraham I 143344d30d62SAlan Douglas gphy = devm_phy_create(dev, child, &ops); 143444d30d62SAlan Douglas 143544d30d62SAlan Douglas if (IS_ERR(gphy)) { 143644d30d62SAlan Douglas ret = PTR_ERR(gphy); 143744d30d62SAlan Douglas goto put_child; 143844d30d62SAlan Douglas } 143944d30d62SAlan Douglas sp->phys[node].phy = gphy; 144044d30d62SAlan Douglas phy_set_drvdata(gphy, &sp->phys[node]); 144144d30d62SAlan Douglas 144244d30d62SAlan Douglas node++; 144344d30d62SAlan Douglas } 144444d30d62SAlan Douglas sp->nsubnodes = node; 144544d30d62SAlan Douglas 1446a43f72aeSKishon Vijay Abraham I if (sp->num_lanes > SIERRA_MAX_LANES) { 14476411e386SWang Wensheng ret = -EINVAL; 1448a43f72aeSKishon Vijay Abraham I dev_err(dev, "Invalid lane configuration\n"); 1449a43f72aeSKishon Vijay Abraham I goto put_child2; 1450a43f72aeSKishon Vijay Abraham I } 1451a43f72aeSKishon Vijay Abraham I 145244d30d62SAlan Douglas /* If more than one subnode, configure the PHY as multilink */ 14536b81f05aSSwapnil Jakhade if (!sp->autoconf && sp->nsubnodes > 1) { 14546b81f05aSSwapnil Jakhade ret = cdns_sierra_phy_configure_multilink(sp); 14556b81f05aSSwapnil Jakhade if (ret) 14566b81f05aSSwapnil Jakhade goto put_child2; 14576b81f05aSSwapnil Jakhade } 145844d30d62SAlan Douglas 145944d30d62SAlan Douglas pm_runtime_enable(dev); 146044d30d62SAlan Douglas phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); 146144d30d62SAlan Douglas return PTR_ERR_OR_ZERO(phy_provider); 146244d30d62SAlan Douglas 146344d30d62SAlan Douglas put_child: 146444d30d62SAlan Douglas node++; 146544d30d62SAlan Douglas put_child2: 146644d30d62SAlan Douglas for (i = 0; i < node; i++) 146744d30d62SAlan Douglas reset_control_put(sp->phys[i].lnk_rst); 146844d30d62SAlan Douglas of_node_put(child); 146944d30d62SAlan Douglas clk_disable: 14701436ec30SKishon Vijay Abraham I cdns_sierra_phy_disable_clocks(sp); 147144d30d62SAlan Douglas reset_control_assert(sp->apb_rst); 147228081b72SKishon Vijay Abraham I unregister_clk: 147328081b72SKishon Vijay Abraham I cdns_sierra_clk_unregister(sp); 147444d30d62SAlan Douglas return ret; 147544d30d62SAlan Douglas } 147644d30d62SAlan Douglas 147744d30d62SAlan Douglas static int cdns_sierra_phy_remove(struct platform_device *pdev) 147844d30d62SAlan Douglas { 1479748e3456SKishon Vijay Abraham I struct cdns_sierra_phy *phy = platform_get_drvdata(pdev); 148044d30d62SAlan Douglas int i; 148144d30d62SAlan Douglas 148244d30d62SAlan Douglas reset_control_assert(phy->phy_rst); 148344d30d62SAlan Douglas reset_control_assert(phy->apb_rst); 148444d30d62SAlan Douglas pm_runtime_disable(&pdev->dev); 148544d30d62SAlan Douglas 14861436ec30SKishon Vijay Abraham I cdns_sierra_phy_disable_clocks(phy); 148744d30d62SAlan Douglas /* 148844d30d62SAlan Douglas * The device level resets will be put automatically. 148944d30d62SAlan Douglas * Need to put the subnode resets here though. 149044d30d62SAlan Douglas */ 149144d30d62SAlan Douglas for (i = 0; i < phy->nsubnodes; i++) { 149244d30d62SAlan Douglas reset_control_assert(phy->phys[i].lnk_rst); 149344d30d62SAlan Douglas reset_control_put(phy->phys[i].lnk_rst); 149444d30d62SAlan Douglas } 149529c2d02aSKishon Vijay Abraham I 149628081b72SKishon Vijay Abraham I cdns_sierra_clk_unregister(phy); 149729c2d02aSKishon Vijay Abraham I 149844d30d62SAlan Douglas return 0; 149944d30d62SAlan Douglas } 150044d30d62SAlan Douglas 15018a1b82d7SSwapnil Jakhade /* QSGMII PHY PMA lane configuration */ 15028a1b82d7SSwapnil Jakhade static struct cdns_reg_pairs qsgmii_phy_pma_ln_regs[] = { 15038a1b82d7SSwapnil Jakhade {0x9010, SIERRA_PHY_PMA_XCVR_CTRL} 15048a1b82d7SSwapnil Jakhade }; 15058a1b82d7SSwapnil Jakhade 15068a1b82d7SSwapnil Jakhade static struct cdns_sierra_vals qsgmii_phy_pma_ln_vals = { 15078a1b82d7SSwapnil Jakhade .reg_pairs = qsgmii_phy_pma_ln_regs, 15088a1b82d7SSwapnil Jakhade .num_regs = ARRAY_SIZE(qsgmii_phy_pma_ln_regs), 15098a1b82d7SSwapnil Jakhade }; 15108a1b82d7SSwapnil Jakhade 15118a1b82d7SSwapnil Jakhade /* QSGMII refclk 100MHz, 20b, opt1, No BW cal, no ssc, PLL LC1 */ 15128a1b82d7SSwapnil Jakhade static const struct cdns_reg_pairs qsgmii_100_no_ssc_plllc1_cmn_regs[] = { 15138a1b82d7SSwapnil Jakhade {0x2085, SIERRA_CMN_PLLLC1_LF_COEFF_MODE0_PREG}, 15148a1b82d7SSwapnil Jakhade {0x0000, SIERRA_CMN_PLLLC1_BWCAL_MODE0_PREG}, 15158a1b82d7SSwapnil Jakhade {0x0000, SIERRA_CMN_PLLLC1_SS_TIME_STEPSIZE_MODE_PREG} 15168a1b82d7SSwapnil Jakhade }; 15178a1b82d7SSwapnil Jakhade 15188a1b82d7SSwapnil Jakhade static const struct cdns_reg_pairs qsgmii_100_no_ssc_plllc1_ln_regs[] = { 15198a1b82d7SSwapnil Jakhade {0xFC08, SIERRA_DET_STANDEC_A_PREG}, 15208a1b82d7SSwapnil Jakhade {0x0252, SIERRA_DET_STANDEC_E_PREG}, 15218a1b82d7SSwapnil Jakhade {0x0004, SIERRA_PSC_LN_IDLE_PREG}, 15228a1b82d7SSwapnil Jakhade {0x0FFE, SIERRA_PSC_RX_A0_PREG}, 15238a1b82d7SSwapnil Jakhade {0x0011, SIERRA_PLLCTRL_SUBRATE_PREG}, 15248a1b82d7SSwapnil Jakhade {0x0001, SIERRA_PLLCTRL_GEN_A_PREG}, 15258a1b82d7SSwapnil Jakhade {0x5233, SIERRA_PLLCTRL_CPGAIN_MODE_PREG}, 15268a1b82d7SSwapnil Jakhade {0x0000, SIERRA_DRVCTRL_ATTEN_PREG}, 15278a1b82d7SSwapnil Jakhade {0x0089, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG}, 15288a1b82d7SSwapnil Jakhade {0x3C3C, SIERRA_CREQ_CCLKDET_MODE01_PREG}, 15298a1b82d7SSwapnil Jakhade {0x3222, SIERRA_CREQ_FSMCLK_SEL_PREG}, 15308a1b82d7SSwapnil Jakhade {0x0000, SIERRA_CREQ_EQ_CTRL_PREG}, 15318a1b82d7SSwapnil Jakhade {0x8422, SIERRA_CTLELUT_CTRL_PREG}, 15328a1b82d7SSwapnil Jakhade {0x4111, SIERRA_DFE_ECMP_RATESEL_PREG}, 15338a1b82d7SSwapnil Jakhade {0x4111, SIERRA_DFE_SMP_RATESEL_PREG}, 15348a1b82d7SSwapnil Jakhade {0x0002, SIERRA_DEQ_PHALIGN_CTRL}, 15358a1b82d7SSwapnil Jakhade {0x9595, SIERRA_DEQ_VGATUNE_CTRL_PREG}, 15368a1b82d7SSwapnil Jakhade {0x0186, SIERRA_DEQ_GLUT0}, 15378a1b82d7SSwapnil Jakhade {0x0186, SIERRA_DEQ_GLUT1}, 15388a1b82d7SSwapnil Jakhade {0x0186, SIERRA_DEQ_GLUT2}, 15398a1b82d7SSwapnil Jakhade {0x0186, SIERRA_DEQ_GLUT3}, 15408a1b82d7SSwapnil Jakhade {0x0186, SIERRA_DEQ_GLUT4}, 15418a1b82d7SSwapnil Jakhade {0x0861, SIERRA_DEQ_ALUT0}, 15428a1b82d7SSwapnil Jakhade {0x07E0, SIERRA_DEQ_ALUT1}, 15438a1b82d7SSwapnil Jakhade {0x079E, SIERRA_DEQ_ALUT2}, 15448a1b82d7SSwapnil Jakhade {0x071D, SIERRA_DEQ_ALUT3}, 15458a1b82d7SSwapnil Jakhade {0x03F5, SIERRA_DEQ_DFETAP_CTRL_PREG}, 15468a1b82d7SSwapnil Jakhade {0x0C01, SIERRA_DEQ_TAU_CTRL1_FAST_MAINT_PREG}, 15478a1b82d7SSwapnil Jakhade {0x3C40, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG}, 15488a1b82d7SSwapnil Jakhade {0x1C04, SIERRA_DEQ_TAU_CTRL2_PREG}, 15498a1b82d7SSwapnil Jakhade {0x0033, SIERRA_DEQ_PICTRL_PREG}, 15508a1b82d7SSwapnil Jakhade {0x0660, SIERRA_CPICAL_TMRVAL_MODE0_PREG}, 15518a1b82d7SSwapnil Jakhade {0x00D5, SIERRA_CPI_OUTBUF_RATESEL_PREG}, 15528a1b82d7SSwapnil Jakhade {0x0B6D, SIERRA_CPI_RESBIAS_BIN_PREG}, 15538a1b82d7SSwapnil Jakhade {0x0102, SIERRA_RXBUFFER_CTLECTRL_PREG}, 15548a1b82d7SSwapnil Jakhade {0x0002, SIERRA_RXBUFFER_RCDFECTRL_PREG} 15558a1b82d7SSwapnil Jakhade }; 15568a1b82d7SSwapnil Jakhade 15578a1b82d7SSwapnil Jakhade static struct cdns_sierra_vals qsgmii_100_no_ssc_plllc1_cmn_vals = { 15588a1b82d7SSwapnil Jakhade .reg_pairs = qsgmii_100_no_ssc_plllc1_cmn_regs, 15598a1b82d7SSwapnil Jakhade .num_regs = ARRAY_SIZE(qsgmii_100_no_ssc_plllc1_cmn_regs), 15608a1b82d7SSwapnil Jakhade }; 15618a1b82d7SSwapnil Jakhade 15628a1b82d7SSwapnil Jakhade static struct cdns_sierra_vals qsgmii_100_no_ssc_plllc1_ln_vals = { 15638a1b82d7SSwapnil Jakhade .reg_pairs = qsgmii_100_no_ssc_plllc1_ln_regs, 15648a1b82d7SSwapnil Jakhade .num_regs = ARRAY_SIZE(qsgmii_100_no_ssc_plllc1_ln_regs), 15658a1b82d7SSwapnil Jakhade }; 15668a1b82d7SSwapnil Jakhade 1567fa105172SSwapnil Jakhade /* PCIE PHY PCS common configuration */ 1568fa105172SSwapnil Jakhade static struct cdns_reg_pairs pcie_phy_pcs_cmn_regs[] = { 1569fa105172SSwapnil Jakhade {0x0430, SIERRA_PHY_PIPE_CMN_CTRL1} 1570fa105172SSwapnil Jakhade }; 1571fa105172SSwapnil Jakhade 1572fa105172SSwapnil Jakhade static struct cdns_sierra_vals pcie_phy_pcs_cmn_vals = { 1573fa105172SSwapnil Jakhade .reg_pairs = pcie_phy_pcs_cmn_regs, 1574fa105172SSwapnil Jakhade .num_regs = ARRAY_SIZE(pcie_phy_pcs_cmn_regs), 1575fa105172SSwapnil Jakhade }; 1576fa105172SSwapnil Jakhade 15778a1b82d7SSwapnil Jakhade /* refclk100MHz_32b_PCIe_cmn_pll_no_ssc, pcie_links_using_plllc, pipe_bw_3 */ 15788a1b82d7SSwapnil Jakhade static const struct cdns_reg_pairs pcie_100_no_ssc_plllc_cmn_regs[] = { 15798a1b82d7SSwapnil Jakhade {0x2105, SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG}, 15808a1b82d7SSwapnil Jakhade {0x2105, SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG}, 15818a1b82d7SSwapnil Jakhade {0x8A06, SIERRA_CMN_PLLLC_BWCAL_MODE1_PREG}, 15828a1b82d7SSwapnil Jakhade {0x8A06, SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG} 15838a1b82d7SSwapnil Jakhade }; 15848a1b82d7SSwapnil Jakhade 15858a1b82d7SSwapnil Jakhade /* 15868a1b82d7SSwapnil Jakhade * refclk100MHz_32b_PCIe_ln_no_ssc, multilink, using_plllc, 15878a1b82d7SSwapnil Jakhade * cmn_pllcy_anaclk0_1Ghz, xcvr_pllclk_fullrt_500mhz 15888a1b82d7SSwapnil Jakhade */ 15898a1b82d7SSwapnil Jakhade static const struct cdns_reg_pairs ml_pcie_100_no_ssc_ln_regs[] = { 15908a1b82d7SSwapnil Jakhade {0xFC08, SIERRA_DET_STANDEC_A_PREG}, 15918a1b82d7SSwapnil Jakhade {0x001D, SIERRA_PSM_A3IN_TMR_PREG}, 15928a1b82d7SSwapnil Jakhade {0x0004, SIERRA_PSC_LN_A3_PREG}, 15938a1b82d7SSwapnil Jakhade {0x0004, SIERRA_PSC_LN_A4_PREG}, 15948a1b82d7SSwapnil Jakhade {0x0004, SIERRA_PSC_LN_IDLE_PREG}, 15958a1b82d7SSwapnil Jakhade {0x1555, SIERRA_DFE_BIASTRIM_PREG}, 15968a1b82d7SSwapnil Jakhade {0x9703, SIERRA_DRVCTRL_BOOST_PREG}, 15978a1b82d7SSwapnil Jakhade {0x8055, SIERRA_RX_CREQ_FLTR_A_MODE3_PREG}, 15988a1b82d7SSwapnil Jakhade {0x80BB, SIERRA_RX_CREQ_FLTR_A_MODE2_PREG}, 15998a1b82d7SSwapnil Jakhade {0x8351, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG}, 16008a1b82d7SSwapnil Jakhade {0x8349, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG}, 16018a1b82d7SSwapnil Jakhade {0x0002, SIERRA_CREQ_DCBIASATTEN_OVR_PREG}, 16028a1b82d7SSwapnil Jakhade {0x9800, SIERRA_RX_CTLE_CAL_PREG}, 16038a1b82d7SSwapnil Jakhade {0x5624, SIERRA_DEQ_CONCUR_CTRL2_PREG}, 16048a1b82d7SSwapnil Jakhade {0x000F, SIERRA_DEQ_EPIPWR_CTRL2_PREG}, 16058a1b82d7SSwapnil Jakhade {0x00FF, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG}, 16068a1b82d7SSwapnil Jakhade {0x4C4C, SIERRA_DEQ_ERRCMP_CTRL_PREG}, 16078a1b82d7SSwapnil Jakhade {0x02FA, SIERRA_DEQ_OFFSET_CTRL_PREG}, 16088a1b82d7SSwapnil Jakhade {0x02FA, SIERRA_DEQ_GAIN_CTRL_PREG}, 16098a1b82d7SSwapnil Jakhade {0x0041, SIERRA_DEQ_GLUT0}, 16108a1b82d7SSwapnil Jakhade {0x0082, SIERRA_DEQ_GLUT1}, 16118a1b82d7SSwapnil Jakhade {0x00C3, SIERRA_DEQ_GLUT2}, 16128a1b82d7SSwapnil Jakhade {0x0145, SIERRA_DEQ_GLUT3}, 16138a1b82d7SSwapnil Jakhade {0x0186, SIERRA_DEQ_GLUT4}, 16148a1b82d7SSwapnil Jakhade {0x09E7, SIERRA_DEQ_ALUT0}, 16158a1b82d7SSwapnil Jakhade {0x09A6, SIERRA_DEQ_ALUT1}, 16168a1b82d7SSwapnil Jakhade {0x0965, SIERRA_DEQ_ALUT2}, 16178a1b82d7SSwapnil Jakhade {0x08E3, SIERRA_DEQ_ALUT3}, 16188a1b82d7SSwapnil Jakhade {0x00FA, SIERRA_DEQ_DFETAP0}, 16198a1b82d7SSwapnil Jakhade {0x00FA, SIERRA_DEQ_DFETAP1}, 16208a1b82d7SSwapnil Jakhade {0x00FA, SIERRA_DEQ_DFETAP2}, 16218a1b82d7SSwapnil Jakhade {0x00FA, SIERRA_DEQ_DFETAP3}, 16228a1b82d7SSwapnil Jakhade {0x00FA, SIERRA_DEQ_DFETAP4}, 16238a1b82d7SSwapnil Jakhade {0x000F, SIERRA_DEQ_PRECUR_PREG}, 16248a1b82d7SSwapnil Jakhade {0x0280, SIERRA_DEQ_POSTCUR_PREG}, 16258a1b82d7SSwapnil Jakhade {0x8F00, SIERRA_DEQ_POSTCUR_DECR_PREG}, 16268a1b82d7SSwapnil Jakhade {0x3C0F, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG}, 16278a1b82d7SSwapnil Jakhade {0x1C0C, SIERRA_DEQ_TAU_CTRL2_PREG}, 16288a1b82d7SSwapnil Jakhade {0x0100, SIERRA_DEQ_TAU_CTRL3_PREG}, 16298a1b82d7SSwapnil Jakhade {0x5E82, SIERRA_DEQ_OPENEYE_CTRL_PREG}, 16308a1b82d7SSwapnil Jakhade {0x002B, SIERRA_CPI_TRIM_PREG}, 16318a1b82d7SSwapnil Jakhade {0x0003, SIERRA_EPI_CTRL_PREG}, 16328a1b82d7SSwapnil Jakhade {0x803F, SIERRA_SDFILT_H2L_A_PREG}, 16338a1b82d7SSwapnil Jakhade {0x0004, SIERRA_RXBUFFER_CTLECTRL_PREG}, 16348a1b82d7SSwapnil Jakhade {0x2010, SIERRA_RXBUFFER_RCDFECTRL_PREG}, 16358a1b82d7SSwapnil Jakhade {0x4432, SIERRA_RXBUFFER_DFECTRL_PREG} 16368a1b82d7SSwapnil Jakhade }; 16378a1b82d7SSwapnil Jakhade 16388a1b82d7SSwapnil Jakhade static struct cdns_sierra_vals pcie_100_no_ssc_plllc_cmn_vals = { 16398a1b82d7SSwapnil Jakhade .reg_pairs = pcie_100_no_ssc_plllc_cmn_regs, 16408a1b82d7SSwapnil Jakhade .num_regs = ARRAY_SIZE(pcie_100_no_ssc_plllc_cmn_regs), 16418a1b82d7SSwapnil Jakhade }; 16428a1b82d7SSwapnil Jakhade 16438a1b82d7SSwapnil Jakhade static struct cdns_sierra_vals ml_pcie_100_no_ssc_ln_vals = { 16448a1b82d7SSwapnil Jakhade .reg_pairs = ml_pcie_100_no_ssc_ln_regs, 16458a1b82d7SSwapnil Jakhade .num_regs = ARRAY_SIZE(ml_pcie_100_no_ssc_ln_regs), 16468a1b82d7SSwapnil Jakhade }; 16478a1b82d7SSwapnil Jakhade 16488a1b82d7SSwapnil Jakhade /* refclk100MHz_32b_PCIe_cmn_pll_int_ssc, pcie_links_using_plllc, pipe_bw_3 */ 16498a1b82d7SSwapnil Jakhade static const struct cdns_reg_pairs pcie_100_int_ssc_plllc_cmn_regs[] = { 16508a1b82d7SSwapnil Jakhade {0x000E, SIERRA_CMN_PLLLC_MODE_PREG}, 16518a1b82d7SSwapnil Jakhade {0x4006, SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG}, 16528a1b82d7SSwapnil Jakhade {0x4006, SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG}, 16538a1b82d7SSwapnil Jakhade {0x0000, SIERRA_CMN_PLLLC_BWCAL_MODE1_PREG}, 16548a1b82d7SSwapnil Jakhade {0x0000, SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG}, 16558a1b82d7SSwapnil Jakhade {0x0581, SIERRA_CMN_PLLLC_DSMCORR_PREG}, 16568a1b82d7SSwapnil Jakhade {0x7F80, SIERRA_CMN_PLLLC_SS_PREG}, 16578a1b82d7SSwapnil Jakhade {0x0041, SIERRA_CMN_PLLLC_SS_AMP_STEP_SIZE_PREG}, 16588a1b82d7SSwapnil Jakhade {0x0464, SIERRA_CMN_PLLLC_SSTWOPT_PREG}, 16598a1b82d7SSwapnil Jakhade {0x0D0D, SIERRA_CMN_PLLLC_SS_TIME_STEPSIZE_MODE_PREG}, 16608a1b82d7SSwapnil Jakhade {0x0060, SIERRA_CMN_PLLLC_LOCK_DELAY_CTRL_PREG} 16618a1b82d7SSwapnil Jakhade }; 16628a1b82d7SSwapnil Jakhade 16638a1b82d7SSwapnil Jakhade /* 16648a1b82d7SSwapnil Jakhade * refclk100MHz_32b_PCIe_ln_int_ssc, multilink, using_plllc, 16658a1b82d7SSwapnil Jakhade * cmn_pllcy_anaclk0_1Ghz, xcvr_pllclk_fullrt_500mhz 16668a1b82d7SSwapnil Jakhade */ 16678a1b82d7SSwapnil Jakhade static const struct cdns_reg_pairs ml_pcie_100_int_ssc_ln_regs[] = { 16688a1b82d7SSwapnil Jakhade {0xFC08, SIERRA_DET_STANDEC_A_PREG}, 16698a1b82d7SSwapnil Jakhade {0x001D, SIERRA_PSM_A3IN_TMR_PREG}, 16708a1b82d7SSwapnil Jakhade {0x0004, SIERRA_PSC_LN_A3_PREG}, 16718a1b82d7SSwapnil Jakhade {0x0004, SIERRA_PSC_LN_A4_PREG}, 16728a1b82d7SSwapnil Jakhade {0x0004, SIERRA_PSC_LN_IDLE_PREG}, 16738a1b82d7SSwapnil Jakhade {0x1555, SIERRA_DFE_BIASTRIM_PREG}, 16748a1b82d7SSwapnil Jakhade {0x9703, SIERRA_DRVCTRL_BOOST_PREG}, 16758a1b82d7SSwapnil Jakhade {0x813E, SIERRA_CLKPATHCTRL_TMR_PREG}, 16768a1b82d7SSwapnil Jakhade {0x8047, SIERRA_RX_CREQ_FLTR_A_MODE3_PREG}, 16778a1b82d7SSwapnil Jakhade {0x808F, SIERRA_RX_CREQ_FLTR_A_MODE2_PREG}, 16788a1b82d7SSwapnil Jakhade {0x808F, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG}, 16798a1b82d7SSwapnil Jakhade {0x808F, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG}, 16808a1b82d7SSwapnil Jakhade {0x0002, SIERRA_CREQ_DCBIASATTEN_OVR_PREG}, 16818a1b82d7SSwapnil Jakhade {0x9800, SIERRA_RX_CTLE_CAL_PREG}, 16828a1b82d7SSwapnil Jakhade {0x033C, SIERRA_RX_CTLE_MAINTENANCE_PREG}, 16838a1b82d7SSwapnil Jakhade {0x44CC, SIERRA_CREQ_EQ_OPEN_EYE_THRESH_PREG}, 16848a1b82d7SSwapnil Jakhade {0x5624, SIERRA_DEQ_CONCUR_CTRL2_PREG}, 16858a1b82d7SSwapnil Jakhade {0x000F, SIERRA_DEQ_EPIPWR_CTRL2_PREG}, 16868a1b82d7SSwapnil Jakhade {0x00FF, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG}, 16878a1b82d7SSwapnil Jakhade {0x4C4C, SIERRA_DEQ_ERRCMP_CTRL_PREG}, 16888a1b82d7SSwapnil Jakhade {0x02FA, SIERRA_DEQ_OFFSET_CTRL_PREG}, 16898a1b82d7SSwapnil Jakhade {0x02FA, SIERRA_DEQ_GAIN_CTRL_PREG}, 16908a1b82d7SSwapnil Jakhade {0x0041, SIERRA_DEQ_GLUT0}, 16918a1b82d7SSwapnil Jakhade {0x0082, SIERRA_DEQ_GLUT1}, 16928a1b82d7SSwapnil Jakhade {0x00C3, SIERRA_DEQ_GLUT2}, 16938a1b82d7SSwapnil Jakhade {0x0145, SIERRA_DEQ_GLUT3}, 16948a1b82d7SSwapnil Jakhade {0x0186, SIERRA_DEQ_GLUT4}, 16958a1b82d7SSwapnil Jakhade {0x09E7, SIERRA_DEQ_ALUT0}, 16968a1b82d7SSwapnil Jakhade {0x09A6, SIERRA_DEQ_ALUT1}, 16978a1b82d7SSwapnil Jakhade {0x0965, SIERRA_DEQ_ALUT2}, 16988a1b82d7SSwapnil Jakhade {0x08E3, SIERRA_DEQ_ALUT3}, 16998a1b82d7SSwapnil Jakhade {0x00FA, SIERRA_DEQ_DFETAP0}, 17008a1b82d7SSwapnil Jakhade {0x00FA, SIERRA_DEQ_DFETAP1}, 17018a1b82d7SSwapnil Jakhade {0x00FA, SIERRA_DEQ_DFETAP2}, 17028a1b82d7SSwapnil Jakhade {0x00FA, SIERRA_DEQ_DFETAP3}, 17038a1b82d7SSwapnil Jakhade {0x00FA, SIERRA_DEQ_DFETAP4}, 17048a1b82d7SSwapnil Jakhade {0x000F, SIERRA_DEQ_PRECUR_PREG}, 17058a1b82d7SSwapnil Jakhade {0x0280, SIERRA_DEQ_POSTCUR_PREG}, 17068a1b82d7SSwapnil Jakhade {0x8F00, SIERRA_DEQ_POSTCUR_DECR_PREG}, 17078a1b82d7SSwapnil Jakhade {0x3C0F, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG}, 17088a1b82d7SSwapnil Jakhade {0x1C0C, SIERRA_DEQ_TAU_CTRL2_PREG}, 17098a1b82d7SSwapnil Jakhade {0x0100, SIERRA_DEQ_TAU_CTRL3_PREG}, 17108a1b82d7SSwapnil Jakhade {0x5E82, SIERRA_DEQ_OPENEYE_CTRL_PREG}, 17118a1b82d7SSwapnil Jakhade {0x002B, SIERRA_CPI_TRIM_PREG}, 17128a1b82d7SSwapnil Jakhade {0x0003, SIERRA_EPI_CTRL_PREG}, 17138a1b82d7SSwapnil Jakhade {0x803F, SIERRA_SDFILT_H2L_A_PREG}, 17148a1b82d7SSwapnil Jakhade {0x0004, SIERRA_RXBUFFER_CTLECTRL_PREG}, 17158a1b82d7SSwapnil Jakhade {0x2010, SIERRA_RXBUFFER_RCDFECTRL_PREG}, 17168a1b82d7SSwapnil Jakhade {0x4432, SIERRA_RXBUFFER_DFECTRL_PREG} 17178a1b82d7SSwapnil Jakhade }; 17188a1b82d7SSwapnil Jakhade 17198a1b82d7SSwapnil Jakhade static struct cdns_sierra_vals pcie_100_int_ssc_plllc_cmn_vals = { 17208a1b82d7SSwapnil Jakhade .reg_pairs = pcie_100_int_ssc_plllc_cmn_regs, 17218a1b82d7SSwapnil Jakhade .num_regs = ARRAY_SIZE(pcie_100_int_ssc_plllc_cmn_regs), 17228a1b82d7SSwapnil Jakhade }; 17238a1b82d7SSwapnil Jakhade 17248a1b82d7SSwapnil Jakhade static struct cdns_sierra_vals ml_pcie_100_int_ssc_ln_vals = { 17258a1b82d7SSwapnil Jakhade .reg_pairs = ml_pcie_100_int_ssc_ln_regs, 17268a1b82d7SSwapnil Jakhade .num_regs = ARRAY_SIZE(ml_pcie_100_int_ssc_ln_regs), 17278a1b82d7SSwapnil Jakhade }; 17288a1b82d7SSwapnil Jakhade 17298a1b82d7SSwapnil Jakhade /* refclk100MHz_32b_PCIe_cmn_pll_ext_ssc, pcie_links_using_plllc, pipe_bw_3 */ 17308a1b82d7SSwapnil Jakhade static const struct cdns_reg_pairs pcie_100_ext_ssc_plllc_cmn_regs[] = { 17318a1b82d7SSwapnil Jakhade {0x2106, SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG}, 17328a1b82d7SSwapnil Jakhade {0x2106, SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG}, 17338a1b82d7SSwapnil Jakhade {0x8A06, SIERRA_CMN_PLLLC_BWCAL_MODE1_PREG}, 17348a1b82d7SSwapnil Jakhade {0x8A06, SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG}, 17358a1b82d7SSwapnil Jakhade {0x1B1B, SIERRA_CMN_PLLLC_SS_TIME_STEPSIZE_MODE_PREG} 17368a1b82d7SSwapnil Jakhade }; 17378a1b82d7SSwapnil Jakhade 17388a1b82d7SSwapnil Jakhade /* 17398a1b82d7SSwapnil Jakhade * refclk100MHz_32b_PCIe_ln_ext_ssc, multilink, using_plllc, 17408a1b82d7SSwapnil Jakhade * cmn_pllcy_anaclk0_1Ghz, xcvr_pllclk_fullrt_500mhz 17418a1b82d7SSwapnil Jakhade */ 17428a1b82d7SSwapnil Jakhade static const struct cdns_reg_pairs ml_pcie_100_ext_ssc_ln_regs[] = { 17438a1b82d7SSwapnil Jakhade {0xFC08, SIERRA_DET_STANDEC_A_PREG}, 17448a1b82d7SSwapnil Jakhade {0x001D, SIERRA_PSM_A3IN_TMR_PREG}, 17458a1b82d7SSwapnil Jakhade {0x0004, SIERRA_PSC_LN_A3_PREG}, 17468a1b82d7SSwapnil Jakhade {0x0004, SIERRA_PSC_LN_A4_PREG}, 17478a1b82d7SSwapnil Jakhade {0x0004, SIERRA_PSC_LN_IDLE_PREG}, 17488a1b82d7SSwapnil Jakhade {0x1555, SIERRA_DFE_BIASTRIM_PREG}, 17498a1b82d7SSwapnil Jakhade {0x9703, SIERRA_DRVCTRL_BOOST_PREG}, 17508a1b82d7SSwapnil Jakhade {0x813E, SIERRA_CLKPATHCTRL_TMR_PREG}, 17518a1b82d7SSwapnil Jakhade {0x8047, SIERRA_RX_CREQ_FLTR_A_MODE3_PREG}, 17528a1b82d7SSwapnil Jakhade {0x808F, SIERRA_RX_CREQ_FLTR_A_MODE2_PREG}, 17538a1b82d7SSwapnil Jakhade {0x808F, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG}, 17548a1b82d7SSwapnil Jakhade {0x808F, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG}, 17558a1b82d7SSwapnil Jakhade {0x0002, SIERRA_CREQ_DCBIASATTEN_OVR_PREG}, 17568a1b82d7SSwapnil Jakhade {0x9800, SIERRA_RX_CTLE_CAL_PREG}, 17578a1b82d7SSwapnil Jakhade {0x033C, SIERRA_RX_CTLE_MAINTENANCE_PREG}, 17588a1b82d7SSwapnil Jakhade {0x44CC, SIERRA_CREQ_EQ_OPEN_EYE_THRESH_PREG}, 17598a1b82d7SSwapnil Jakhade {0x5624, SIERRA_DEQ_CONCUR_CTRL2_PREG}, 17608a1b82d7SSwapnil Jakhade {0x000F, SIERRA_DEQ_EPIPWR_CTRL2_PREG}, 17618a1b82d7SSwapnil Jakhade {0x00FF, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG}, 17628a1b82d7SSwapnil Jakhade {0x4C4C, SIERRA_DEQ_ERRCMP_CTRL_PREG}, 17638a1b82d7SSwapnil Jakhade {0x02FA, SIERRA_DEQ_OFFSET_CTRL_PREG}, 17648a1b82d7SSwapnil Jakhade {0x02FA, SIERRA_DEQ_GAIN_CTRL_PREG}, 17658a1b82d7SSwapnil Jakhade {0x0041, SIERRA_DEQ_GLUT0}, 17668a1b82d7SSwapnil Jakhade {0x0082, SIERRA_DEQ_GLUT1}, 17678a1b82d7SSwapnil Jakhade {0x00C3, SIERRA_DEQ_GLUT2}, 17688a1b82d7SSwapnil Jakhade {0x0145, SIERRA_DEQ_GLUT3}, 17698a1b82d7SSwapnil Jakhade {0x0186, SIERRA_DEQ_GLUT4}, 17708a1b82d7SSwapnil Jakhade {0x09E7, SIERRA_DEQ_ALUT0}, 17718a1b82d7SSwapnil Jakhade {0x09A6, SIERRA_DEQ_ALUT1}, 17728a1b82d7SSwapnil Jakhade {0x0965, SIERRA_DEQ_ALUT2}, 17738a1b82d7SSwapnil Jakhade {0x08E3, SIERRA_DEQ_ALUT3}, 17748a1b82d7SSwapnil Jakhade {0x00FA, SIERRA_DEQ_DFETAP0}, 17758a1b82d7SSwapnil Jakhade {0x00FA, SIERRA_DEQ_DFETAP1}, 17768a1b82d7SSwapnil Jakhade {0x00FA, SIERRA_DEQ_DFETAP2}, 17778a1b82d7SSwapnil Jakhade {0x00FA, SIERRA_DEQ_DFETAP3}, 17788a1b82d7SSwapnil Jakhade {0x00FA, SIERRA_DEQ_DFETAP4}, 17798a1b82d7SSwapnil Jakhade {0x000F, SIERRA_DEQ_PRECUR_PREG}, 17808a1b82d7SSwapnil Jakhade {0x0280, SIERRA_DEQ_POSTCUR_PREG}, 17818a1b82d7SSwapnil Jakhade {0x8F00, SIERRA_DEQ_POSTCUR_DECR_PREG}, 17828a1b82d7SSwapnil Jakhade {0x3C0F, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG}, 17838a1b82d7SSwapnil Jakhade {0x1C0C, SIERRA_DEQ_TAU_CTRL2_PREG}, 17848a1b82d7SSwapnil Jakhade {0x0100, SIERRA_DEQ_TAU_CTRL3_PREG}, 17858a1b82d7SSwapnil Jakhade {0x5E82, SIERRA_DEQ_OPENEYE_CTRL_PREG}, 17868a1b82d7SSwapnil Jakhade {0x002B, SIERRA_CPI_TRIM_PREG}, 17878a1b82d7SSwapnil Jakhade {0x0003, SIERRA_EPI_CTRL_PREG}, 17888a1b82d7SSwapnil Jakhade {0x803F, SIERRA_SDFILT_H2L_A_PREG}, 17898a1b82d7SSwapnil Jakhade {0x0004, SIERRA_RXBUFFER_CTLECTRL_PREG}, 17908a1b82d7SSwapnil Jakhade {0x2010, SIERRA_RXBUFFER_RCDFECTRL_PREG}, 17918a1b82d7SSwapnil Jakhade {0x4432, SIERRA_RXBUFFER_DFECTRL_PREG} 17928a1b82d7SSwapnil Jakhade }; 17938a1b82d7SSwapnil Jakhade 17948a1b82d7SSwapnil Jakhade static struct cdns_sierra_vals pcie_100_ext_ssc_plllc_cmn_vals = { 17958a1b82d7SSwapnil Jakhade .reg_pairs = pcie_100_ext_ssc_plllc_cmn_regs, 17968a1b82d7SSwapnil Jakhade .num_regs = ARRAY_SIZE(pcie_100_ext_ssc_plllc_cmn_regs), 17978a1b82d7SSwapnil Jakhade }; 17988a1b82d7SSwapnil Jakhade 17998a1b82d7SSwapnil Jakhade static struct cdns_sierra_vals ml_pcie_100_ext_ssc_ln_vals = { 18008a1b82d7SSwapnil Jakhade .reg_pairs = ml_pcie_100_ext_ssc_ln_regs, 18018a1b82d7SSwapnil Jakhade .num_regs = ARRAY_SIZE(ml_pcie_100_ext_ssc_ln_regs), 18028a1b82d7SSwapnil Jakhade }; 18038a1b82d7SSwapnil Jakhade 18047a5ad9b4SSwapnil Jakhade /* refclk100MHz_32b_PCIe_cmn_pll_no_ssc */ 18057a5ad9b4SSwapnil Jakhade static const struct cdns_reg_pairs cdns_pcie_cmn_regs_no_ssc[] = { 18067a5ad9b4SSwapnil Jakhade {0x2105, SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG}, 18077a5ad9b4SSwapnil Jakhade {0x2105, SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG}, 18087a5ad9b4SSwapnil Jakhade {0x8A06, SIERRA_CMN_PLLLC_BWCAL_MODE1_PREG}, 18097a5ad9b4SSwapnil Jakhade {0x8A06, SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG} 18107a5ad9b4SSwapnil Jakhade }; 18117a5ad9b4SSwapnil Jakhade 18127a5ad9b4SSwapnil Jakhade /* refclk100MHz_32b_PCIe_ln_no_ssc */ 18137a5ad9b4SSwapnil Jakhade static const struct cdns_reg_pairs cdns_pcie_ln_regs_no_ssc[] = { 18147a5ad9b4SSwapnil Jakhade {0xFC08, SIERRA_DET_STANDEC_A_PREG}, 18157a5ad9b4SSwapnil Jakhade {0x001D, SIERRA_PSM_A3IN_TMR_PREG}, 18167a5ad9b4SSwapnil Jakhade {0x1555, SIERRA_DFE_BIASTRIM_PREG}, 18177a5ad9b4SSwapnil Jakhade {0x9703, SIERRA_DRVCTRL_BOOST_PREG}, 18187a5ad9b4SSwapnil Jakhade {0x8055, SIERRA_RX_CREQ_FLTR_A_MODE3_PREG}, 18197a5ad9b4SSwapnil Jakhade {0x80BB, SIERRA_RX_CREQ_FLTR_A_MODE2_PREG}, 18207a5ad9b4SSwapnil Jakhade {0x8351, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG}, 18217a5ad9b4SSwapnil Jakhade {0x8349, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG}, 18227a5ad9b4SSwapnil Jakhade {0x0002, SIERRA_CREQ_DCBIASATTEN_OVR_PREG}, 18237a5ad9b4SSwapnil Jakhade {0x9800, SIERRA_RX_CTLE_CAL_PREG}, 18247a5ad9b4SSwapnil Jakhade {0x5624, SIERRA_DEQ_CONCUR_CTRL2_PREG}, 18257a5ad9b4SSwapnil Jakhade {0x000F, SIERRA_DEQ_EPIPWR_CTRL2_PREG}, 18267a5ad9b4SSwapnil Jakhade {0x00FF, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG}, 18277a5ad9b4SSwapnil Jakhade {0x4C4C, SIERRA_DEQ_ERRCMP_CTRL_PREG}, 18287a5ad9b4SSwapnil Jakhade {0x02FA, SIERRA_DEQ_OFFSET_CTRL_PREG}, 18297a5ad9b4SSwapnil Jakhade {0x02FA, SIERRA_DEQ_GAIN_CTRL_PREG}, 18307a5ad9b4SSwapnil Jakhade {0x0041, SIERRA_DEQ_GLUT0}, 18317a5ad9b4SSwapnil Jakhade {0x0082, SIERRA_DEQ_GLUT1}, 18327a5ad9b4SSwapnil Jakhade {0x00C3, SIERRA_DEQ_GLUT2}, 18337a5ad9b4SSwapnil Jakhade {0x0145, SIERRA_DEQ_GLUT3}, 18347a5ad9b4SSwapnil Jakhade {0x0186, SIERRA_DEQ_GLUT4}, 18357a5ad9b4SSwapnil Jakhade {0x09E7, SIERRA_DEQ_ALUT0}, 18367a5ad9b4SSwapnil Jakhade {0x09A6, SIERRA_DEQ_ALUT1}, 18377a5ad9b4SSwapnil Jakhade {0x0965, SIERRA_DEQ_ALUT2}, 18387a5ad9b4SSwapnil Jakhade {0x08E3, SIERRA_DEQ_ALUT3}, 18397a5ad9b4SSwapnil Jakhade {0x00FA, SIERRA_DEQ_DFETAP0}, 18407a5ad9b4SSwapnil Jakhade {0x00FA, SIERRA_DEQ_DFETAP1}, 18417a5ad9b4SSwapnil Jakhade {0x00FA, SIERRA_DEQ_DFETAP2}, 18427a5ad9b4SSwapnil Jakhade {0x00FA, SIERRA_DEQ_DFETAP3}, 18437a5ad9b4SSwapnil Jakhade {0x00FA, SIERRA_DEQ_DFETAP4}, 18447a5ad9b4SSwapnil Jakhade {0x000F, SIERRA_DEQ_PRECUR_PREG}, 18457a5ad9b4SSwapnil Jakhade {0x0280, SIERRA_DEQ_POSTCUR_PREG}, 18467a5ad9b4SSwapnil Jakhade {0x8F00, SIERRA_DEQ_POSTCUR_DECR_PREG}, 18477a5ad9b4SSwapnil Jakhade {0x3C0F, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG}, 18487a5ad9b4SSwapnil Jakhade {0x1C0C, SIERRA_DEQ_TAU_CTRL2_PREG}, 18497a5ad9b4SSwapnil Jakhade {0x0100, SIERRA_DEQ_TAU_CTRL3_PREG}, 18507a5ad9b4SSwapnil Jakhade {0x5E82, SIERRA_DEQ_OPENEYE_CTRL_PREG}, 18517a5ad9b4SSwapnil Jakhade {0x002B, SIERRA_CPI_TRIM_PREG}, 18527a5ad9b4SSwapnil Jakhade {0x0003, SIERRA_EPI_CTRL_PREG}, 18537a5ad9b4SSwapnil Jakhade {0x803F, SIERRA_SDFILT_H2L_A_PREG}, 18547a5ad9b4SSwapnil Jakhade {0x0004, SIERRA_RXBUFFER_CTLECTRL_PREG}, 18557a5ad9b4SSwapnil Jakhade {0x2010, SIERRA_RXBUFFER_RCDFECTRL_PREG}, 18567a5ad9b4SSwapnil Jakhade {0x4432, SIERRA_RXBUFFER_DFECTRL_PREG} 18577a5ad9b4SSwapnil Jakhade }; 18587a5ad9b4SSwapnil Jakhade 18597a5ad9b4SSwapnil Jakhade static struct cdns_sierra_vals pcie_100_no_ssc_cmn_vals = { 18607a5ad9b4SSwapnil Jakhade .reg_pairs = cdns_pcie_cmn_regs_no_ssc, 18617a5ad9b4SSwapnil Jakhade .num_regs = ARRAY_SIZE(cdns_pcie_cmn_regs_no_ssc), 18627a5ad9b4SSwapnil Jakhade }; 18637a5ad9b4SSwapnil Jakhade 18647a5ad9b4SSwapnil Jakhade static struct cdns_sierra_vals pcie_100_no_ssc_ln_vals = { 18657a5ad9b4SSwapnil Jakhade .reg_pairs = cdns_pcie_ln_regs_no_ssc, 18667a5ad9b4SSwapnil Jakhade .num_regs = ARRAY_SIZE(cdns_pcie_ln_regs_no_ssc), 18677a5ad9b4SSwapnil Jakhade }; 18687a5ad9b4SSwapnil Jakhade 18697a5ad9b4SSwapnil Jakhade /* refclk100MHz_32b_PCIe_cmn_pll_int_ssc */ 18707a5ad9b4SSwapnil Jakhade static const struct cdns_reg_pairs cdns_pcie_cmn_regs_int_ssc[] = { 18717a5ad9b4SSwapnil Jakhade {0x000E, SIERRA_CMN_PLLLC_MODE_PREG}, 18727a5ad9b4SSwapnil Jakhade {0x4006, SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG}, 18737a5ad9b4SSwapnil Jakhade {0x4006, SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG}, 18747a5ad9b4SSwapnil Jakhade {0x0000, SIERRA_CMN_PLLLC_BWCAL_MODE1_PREG}, 18757a5ad9b4SSwapnil Jakhade {0x0000, SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG}, 18767a5ad9b4SSwapnil Jakhade {0x0581, SIERRA_CMN_PLLLC_DSMCORR_PREG}, 18777a5ad9b4SSwapnil Jakhade {0x7F80, SIERRA_CMN_PLLLC_SS_PREG}, 18787a5ad9b4SSwapnil Jakhade {0x0041, SIERRA_CMN_PLLLC_SS_AMP_STEP_SIZE_PREG}, 18797a5ad9b4SSwapnil Jakhade {0x0464, SIERRA_CMN_PLLLC_SSTWOPT_PREG}, 18807a5ad9b4SSwapnil Jakhade {0x0D0D, SIERRA_CMN_PLLLC_SS_TIME_STEPSIZE_MODE_PREG}, 18817a5ad9b4SSwapnil Jakhade {0x0060, SIERRA_CMN_PLLLC_LOCK_DELAY_CTRL_PREG} 18827a5ad9b4SSwapnil Jakhade }; 18837a5ad9b4SSwapnil Jakhade 18847a5ad9b4SSwapnil Jakhade /* refclk100MHz_32b_PCIe_ln_int_ssc */ 18857a5ad9b4SSwapnil Jakhade static const struct cdns_reg_pairs cdns_pcie_ln_regs_int_ssc[] = { 18867a5ad9b4SSwapnil Jakhade {0xFC08, SIERRA_DET_STANDEC_A_PREG}, 18877a5ad9b4SSwapnil Jakhade {0x001D, SIERRA_PSM_A3IN_TMR_PREG}, 18887a5ad9b4SSwapnil Jakhade {0x1555, SIERRA_DFE_BIASTRIM_PREG}, 18897a5ad9b4SSwapnil Jakhade {0x9703, SIERRA_DRVCTRL_BOOST_PREG}, 18907a5ad9b4SSwapnil Jakhade {0x813E, SIERRA_CLKPATHCTRL_TMR_PREG}, 18917a5ad9b4SSwapnil Jakhade {0x8047, SIERRA_RX_CREQ_FLTR_A_MODE3_PREG}, 18927a5ad9b4SSwapnil Jakhade {0x808F, SIERRA_RX_CREQ_FLTR_A_MODE2_PREG}, 18937a5ad9b4SSwapnil Jakhade {0x808F, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG}, 18947a5ad9b4SSwapnil Jakhade {0x808F, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG}, 18957a5ad9b4SSwapnil Jakhade {0x0002, SIERRA_CREQ_DCBIASATTEN_OVR_PREG}, 18967a5ad9b4SSwapnil Jakhade {0x9800, SIERRA_RX_CTLE_CAL_PREG}, 18977a5ad9b4SSwapnil Jakhade {0x033C, SIERRA_RX_CTLE_MAINTENANCE_PREG}, 18987a5ad9b4SSwapnil Jakhade {0x44CC, SIERRA_CREQ_EQ_OPEN_EYE_THRESH_PREG}, 18997a5ad9b4SSwapnil Jakhade {0x5624, SIERRA_DEQ_CONCUR_CTRL2_PREG}, 19007a5ad9b4SSwapnil Jakhade {0x000F, SIERRA_DEQ_EPIPWR_CTRL2_PREG}, 19017a5ad9b4SSwapnil Jakhade {0x00FF, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG}, 19027a5ad9b4SSwapnil Jakhade {0x4C4C, SIERRA_DEQ_ERRCMP_CTRL_PREG}, 19037a5ad9b4SSwapnil Jakhade {0x02FA, SIERRA_DEQ_OFFSET_CTRL_PREG}, 19047a5ad9b4SSwapnil Jakhade {0x02FA, SIERRA_DEQ_GAIN_CTRL_PREG}, 19057a5ad9b4SSwapnil Jakhade {0x0041, SIERRA_DEQ_GLUT0}, 19067a5ad9b4SSwapnil Jakhade {0x0082, SIERRA_DEQ_GLUT1}, 19077a5ad9b4SSwapnil Jakhade {0x00C3, SIERRA_DEQ_GLUT2}, 19087a5ad9b4SSwapnil Jakhade {0x0145, SIERRA_DEQ_GLUT3}, 19097a5ad9b4SSwapnil Jakhade {0x0186, SIERRA_DEQ_GLUT4}, 19107a5ad9b4SSwapnil Jakhade {0x09E7, SIERRA_DEQ_ALUT0}, 19117a5ad9b4SSwapnil Jakhade {0x09A6, SIERRA_DEQ_ALUT1}, 19127a5ad9b4SSwapnil Jakhade {0x0965, SIERRA_DEQ_ALUT2}, 19137a5ad9b4SSwapnil Jakhade {0x08E3, SIERRA_DEQ_ALUT3}, 19147a5ad9b4SSwapnil Jakhade {0x00FA, SIERRA_DEQ_DFETAP0}, 19157a5ad9b4SSwapnil Jakhade {0x00FA, SIERRA_DEQ_DFETAP1}, 19167a5ad9b4SSwapnil Jakhade {0x00FA, SIERRA_DEQ_DFETAP2}, 19177a5ad9b4SSwapnil Jakhade {0x00FA, SIERRA_DEQ_DFETAP3}, 19187a5ad9b4SSwapnil Jakhade {0x00FA, SIERRA_DEQ_DFETAP4}, 19197a5ad9b4SSwapnil Jakhade {0x000F, SIERRA_DEQ_PRECUR_PREG}, 19207a5ad9b4SSwapnil Jakhade {0x0280, SIERRA_DEQ_POSTCUR_PREG}, 19217a5ad9b4SSwapnil Jakhade {0x8F00, SIERRA_DEQ_POSTCUR_DECR_PREG}, 19227a5ad9b4SSwapnil Jakhade {0x3C0F, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG}, 19237a5ad9b4SSwapnil Jakhade {0x1C0C, SIERRA_DEQ_TAU_CTRL2_PREG}, 19247a5ad9b4SSwapnil Jakhade {0x0100, SIERRA_DEQ_TAU_CTRL3_PREG}, 19257a5ad9b4SSwapnil Jakhade {0x5E82, SIERRA_DEQ_OPENEYE_CTRL_PREG}, 19267a5ad9b4SSwapnil Jakhade {0x002B, SIERRA_CPI_TRIM_PREG}, 19277a5ad9b4SSwapnil Jakhade {0x0003, SIERRA_EPI_CTRL_PREG}, 19287a5ad9b4SSwapnil Jakhade {0x803F, SIERRA_SDFILT_H2L_A_PREG}, 19297a5ad9b4SSwapnil Jakhade {0x0004, SIERRA_RXBUFFER_CTLECTRL_PREG}, 19307a5ad9b4SSwapnil Jakhade {0x2010, SIERRA_RXBUFFER_RCDFECTRL_PREG}, 19317a5ad9b4SSwapnil Jakhade {0x4432, SIERRA_RXBUFFER_DFECTRL_PREG} 19327a5ad9b4SSwapnil Jakhade }; 19337a5ad9b4SSwapnil Jakhade 19347a5ad9b4SSwapnil Jakhade static struct cdns_sierra_vals pcie_100_int_ssc_cmn_vals = { 19357a5ad9b4SSwapnil Jakhade .reg_pairs = cdns_pcie_cmn_regs_int_ssc, 19367a5ad9b4SSwapnil Jakhade .num_regs = ARRAY_SIZE(cdns_pcie_cmn_regs_int_ssc), 19377a5ad9b4SSwapnil Jakhade }; 19387a5ad9b4SSwapnil Jakhade 19397a5ad9b4SSwapnil Jakhade static struct cdns_sierra_vals pcie_100_int_ssc_ln_vals = { 19407a5ad9b4SSwapnil Jakhade .reg_pairs = cdns_pcie_ln_regs_int_ssc, 19417a5ad9b4SSwapnil Jakhade .num_regs = ARRAY_SIZE(cdns_pcie_ln_regs_int_ssc), 19427a5ad9b4SSwapnil Jakhade }; 19437a5ad9b4SSwapnil Jakhade 1944871002d7SAnil Varughese /* refclk100MHz_32b_PCIe_cmn_pll_ext_ssc */ 19453cfb0e8eSRikard Falkeborn static const struct cdns_reg_pairs cdns_pcie_cmn_regs_ext_ssc[] = { 1946871002d7SAnil Varughese {0x2106, SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG}, 1947871002d7SAnil Varughese {0x2106, SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG}, 1948871002d7SAnil Varughese {0x8A06, SIERRA_CMN_PLLLC_BWCAL_MODE1_PREG}, 1949871002d7SAnil Varughese {0x8A06, SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG}, 1950871002d7SAnil Varughese {0x1B1B, SIERRA_CMN_PLLLC_SS_TIME_STEPSIZE_MODE_PREG} 1951871002d7SAnil Varughese }; 1952871002d7SAnil Varughese 1953871002d7SAnil Varughese /* refclk100MHz_32b_PCIe_ln_ext_ssc */ 19543cfb0e8eSRikard Falkeborn static const struct cdns_reg_pairs cdns_pcie_ln_regs_ext_ssc[] = { 19557a5ad9b4SSwapnil Jakhade {0xFC08, SIERRA_DET_STANDEC_A_PREG}, 19567a5ad9b4SSwapnil Jakhade {0x001D, SIERRA_PSM_A3IN_TMR_PREG}, 19577a5ad9b4SSwapnil Jakhade {0x1555, SIERRA_DFE_BIASTRIM_PREG}, 19587a5ad9b4SSwapnil Jakhade {0x9703, SIERRA_DRVCTRL_BOOST_PREG}, 1959871002d7SAnil Varughese {0x813E, SIERRA_CLKPATHCTRL_TMR_PREG}, 1960871002d7SAnil Varughese {0x8047, SIERRA_RX_CREQ_FLTR_A_MODE3_PREG}, 1961871002d7SAnil Varughese {0x808F, SIERRA_RX_CREQ_FLTR_A_MODE2_PREG}, 1962871002d7SAnil Varughese {0x808F, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG}, 1963871002d7SAnil Varughese {0x808F, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG}, 19647a5ad9b4SSwapnil Jakhade {0x0002, SIERRA_CREQ_DCBIASATTEN_OVR_PREG}, 19657a5ad9b4SSwapnil Jakhade {0x9800, SIERRA_RX_CTLE_CAL_PREG}, 1966871002d7SAnil Varughese {0x033C, SIERRA_RX_CTLE_MAINTENANCE_PREG}, 19677a5ad9b4SSwapnil Jakhade {0x44CC, SIERRA_CREQ_EQ_OPEN_EYE_THRESH_PREG}, 19687a5ad9b4SSwapnil Jakhade {0x5624, SIERRA_DEQ_CONCUR_CTRL2_PREG}, 19697a5ad9b4SSwapnil Jakhade {0x000F, SIERRA_DEQ_EPIPWR_CTRL2_PREG}, 19707a5ad9b4SSwapnil Jakhade {0x00FF, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG}, 19717a5ad9b4SSwapnil Jakhade {0x4C4C, SIERRA_DEQ_ERRCMP_CTRL_PREG}, 19727a5ad9b4SSwapnil Jakhade {0x02FA, SIERRA_DEQ_OFFSET_CTRL_PREG}, 19737a5ad9b4SSwapnil Jakhade {0x02FA, SIERRA_DEQ_GAIN_CTRL_PREG}, 19747a5ad9b4SSwapnil Jakhade {0x0041, SIERRA_DEQ_GLUT0}, 19757a5ad9b4SSwapnil Jakhade {0x0082, SIERRA_DEQ_GLUT1}, 19767a5ad9b4SSwapnil Jakhade {0x00C3, SIERRA_DEQ_GLUT2}, 19777a5ad9b4SSwapnil Jakhade {0x0145, SIERRA_DEQ_GLUT3}, 19787a5ad9b4SSwapnil Jakhade {0x0186, SIERRA_DEQ_GLUT4}, 19797a5ad9b4SSwapnil Jakhade {0x09E7, SIERRA_DEQ_ALUT0}, 19807a5ad9b4SSwapnil Jakhade {0x09A6, SIERRA_DEQ_ALUT1}, 19817a5ad9b4SSwapnil Jakhade {0x0965, SIERRA_DEQ_ALUT2}, 19827a5ad9b4SSwapnil Jakhade {0x08E3, SIERRA_DEQ_ALUT3}, 19837a5ad9b4SSwapnil Jakhade {0x00FA, SIERRA_DEQ_DFETAP0}, 19847a5ad9b4SSwapnil Jakhade {0x00FA, SIERRA_DEQ_DFETAP1}, 19857a5ad9b4SSwapnil Jakhade {0x00FA, SIERRA_DEQ_DFETAP2}, 19867a5ad9b4SSwapnil Jakhade {0x00FA, SIERRA_DEQ_DFETAP3}, 19877a5ad9b4SSwapnil Jakhade {0x00FA, SIERRA_DEQ_DFETAP4}, 19887a5ad9b4SSwapnil Jakhade {0x000F, SIERRA_DEQ_PRECUR_PREG}, 19897a5ad9b4SSwapnil Jakhade {0x0280, SIERRA_DEQ_POSTCUR_PREG}, 19907a5ad9b4SSwapnil Jakhade {0x8F00, SIERRA_DEQ_POSTCUR_DECR_PREG}, 19917a5ad9b4SSwapnil Jakhade {0x3C0F, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG}, 19927a5ad9b4SSwapnil Jakhade {0x1C0C, SIERRA_DEQ_TAU_CTRL2_PREG}, 19937a5ad9b4SSwapnil Jakhade {0x0100, SIERRA_DEQ_TAU_CTRL3_PREG}, 19947a5ad9b4SSwapnil Jakhade {0x5E82, SIERRA_DEQ_OPENEYE_CTRL_PREG}, 19957a5ad9b4SSwapnil Jakhade {0x002B, SIERRA_CPI_TRIM_PREG}, 19967a5ad9b4SSwapnil Jakhade {0x0003, SIERRA_EPI_CTRL_PREG}, 19977a5ad9b4SSwapnil Jakhade {0x803F, SIERRA_SDFILT_H2L_A_PREG}, 19987a5ad9b4SSwapnil Jakhade {0x0004, SIERRA_RXBUFFER_CTLECTRL_PREG}, 19997a5ad9b4SSwapnil Jakhade {0x2010, SIERRA_RXBUFFER_RCDFECTRL_PREG}, 20007a5ad9b4SSwapnil Jakhade {0x4432, SIERRA_RXBUFFER_DFECTRL_PREG} 2001871002d7SAnil Varughese }; 2002871002d7SAnil Varughese 2003078e9e92SSwapnil Jakhade static struct cdns_sierra_vals pcie_100_ext_ssc_cmn_vals = { 2004078e9e92SSwapnil Jakhade .reg_pairs = cdns_pcie_cmn_regs_ext_ssc, 2005078e9e92SSwapnil Jakhade .num_regs = ARRAY_SIZE(cdns_pcie_cmn_regs_ext_ssc), 2006078e9e92SSwapnil Jakhade }; 2007078e9e92SSwapnil Jakhade 2008078e9e92SSwapnil Jakhade static struct cdns_sierra_vals pcie_100_ext_ssc_ln_vals = { 2009078e9e92SSwapnil Jakhade .reg_pairs = cdns_pcie_ln_regs_ext_ssc, 2010078e9e92SSwapnil Jakhade .num_regs = ARRAY_SIZE(cdns_pcie_ln_regs_ext_ssc), 2011078e9e92SSwapnil Jakhade }; 2012078e9e92SSwapnil Jakhade 2013871002d7SAnil Varughese /* refclk100MHz_20b_USB_cmn_pll_ext_ssc */ 20143cfb0e8eSRikard Falkeborn static const struct cdns_reg_pairs cdns_usb_cmn_regs_ext_ssc[] = { 2015871002d7SAnil Varughese {0x2085, SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG}, 2016871002d7SAnil Varughese {0x2085, SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG}, 2017871002d7SAnil Varughese {0x0000, SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG}, 2018871002d7SAnil Varughese {0x0000, SIERRA_CMN_PLLLC_SS_TIME_STEPSIZE_MODE_PREG} 2019871002d7SAnil Varughese }; 2020871002d7SAnil Varughese 2021871002d7SAnil Varughese /* refclk100MHz_20b_USB_ln_ext_ssc */ 20223cfb0e8eSRikard Falkeborn static const struct cdns_reg_pairs cdns_usb_ln_regs_ext_ssc[] = { 2023aead5fd6SKishon Vijay Abraham I {0xFE0A, SIERRA_DET_STANDEC_A_PREG}, 2024aead5fd6SKishon Vijay Abraham I {0x000F, SIERRA_DET_STANDEC_B_PREG}, 20252bcf14caSSanket Parmar {0x55A5, SIERRA_DET_STANDEC_C_PREG}, 2026871002d7SAnil Varughese {0x69ad, SIERRA_DET_STANDEC_D_PREG}, 2027aead5fd6SKishon Vijay Abraham I {0x0241, SIERRA_DET_STANDEC_E_PREG}, 20282bcf14caSSanket Parmar {0x0110, SIERRA_PSM_LANECAL_DLY_A1_RESETS_PREG}, 2029871002d7SAnil Varughese {0x0014, SIERRA_PSM_A0IN_TMR_PREG}, 2030aead5fd6SKishon Vijay Abraham I {0xCF00, SIERRA_PSM_DIAG_PREG}, 2031aead5fd6SKishon Vijay Abraham I {0x001F, SIERRA_PSC_TX_A0_PREG}, 2032aead5fd6SKishon Vijay Abraham I {0x0007, SIERRA_PSC_TX_A1_PREG}, 2033aead5fd6SKishon Vijay Abraham I {0x0003, SIERRA_PSC_TX_A2_PREG}, 2034aead5fd6SKishon Vijay Abraham I {0x0003, SIERRA_PSC_TX_A3_PREG}, 2035aead5fd6SKishon Vijay Abraham I {0x0FFF, SIERRA_PSC_RX_A0_PREG}, 20362bcf14caSSanket Parmar {0x0003, SIERRA_PSC_RX_A1_PREG}, 2037aead5fd6SKishon Vijay Abraham I {0x0003, SIERRA_PSC_RX_A2_PREG}, 2038aead5fd6SKishon Vijay Abraham I {0x0001, SIERRA_PSC_RX_A3_PREG}, 2039aead5fd6SKishon Vijay Abraham I {0x0001, SIERRA_PLLCTRL_SUBRATE_PREG}, 2040aead5fd6SKishon Vijay Abraham I {0x0406, SIERRA_PLLCTRL_GEN_D_PREG}, 2041871002d7SAnil Varughese {0x5233, SIERRA_PLLCTRL_CPGAIN_MODE_PREG}, 2042871002d7SAnil Varughese {0x00CA, SIERRA_CLKPATH_BIASTRIM_PREG}, 2043871002d7SAnil Varughese {0x2512, SIERRA_DFE_BIASTRIM_PREG}, 2044aead5fd6SKishon Vijay Abraham I {0x0000, SIERRA_DRVCTRL_ATTEN_PREG}, 20452bcf14caSSanket Parmar {0x823E, SIERRA_CLKPATHCTRL_TMR_PREG}, 20462bcf14caSSanket Parmar {0x078F, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG}, 20472bcf14caSSanket Parmar {0x078F, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG}, 2048aead5fd6SKishon Vijay Abraham I {0x7B3C, SIERRA_CREQ_CCLKDET_MODE01_PREG}, 20492bcf14caSSanket Parmar {0x023C, SIERRA_RX_CTLE_MAINTENANCE_PREG}, 2050aead5fd6SKishon Vijay Abraham I {0x3232, SIERRA_CREQ_FSMCLK_SEL_PREG}, 2051871002d7SAnil Varughese {0x0000, SIERRA_CREQ_EQ_CTRL_PREG}, 20522bcf14caSSanket Parmar {0x0000, SIERRA_CREQ_SPARE_PREG}, 2053871002d7SAnil Varughese {0xCC44, SIERRA_CREQ_EQ_OPEN_EYE_THRESH_PREG}, 20542bcf14caSSanket Parmar {0x8452, SIERRA_CTLELUT_CTRL_PREG}, 20552bcf14caSSanket Parmar {0x4121, SIERRA_DFE_ECMP_RATESEL_PREG}, 20562bcf14caSSanket Parmar {0x4121, SIERRA_DFE_SMP_RATESEL_PREG}, 20572bcf14caSSanket Parmar {0x0003, SIERRA_DEQ_PHALIGN_CTRL}, 2058871002d7SAnil Varughese {0x3200, SIERRA_DEQ_CONCUR_CTRL1_PREG}, 2059871002d7SAnil Varughese {0x5064, SIERRA_DEQ_CONCUR_CTRL2_PREG}, 2060871002d7SAnil Varughese {0x0030, SIERRA_DEQ_EPIPWR_CTRL2_PREG}, 2061871002d7SAnil Varughese {0x0048, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG}, 2062871002d7SAnil Varughese {0x5A5A, SIERRA_DEQ_ERRCMP_CTRL_PREG}, 2063871002d7SAnil Varughese {0x02F5, SIERRA_DEQ_OFFSET_CTRL_PREG}, 2064871002d7SAnil Varughese {0x02F5, SIERRA_DEQ_GAIN_CTRL_PREG}, 20652bcf14caSSanket Parmar {0x9999, SIERRA_DEQ_VGATUNE_CTRL_PREG}, 2066871002d7SAnil Varughese {0x0014, SIERRA_DEQ_GLUT0}, 2067871002d7SAnil Varughese {0x0014, SIERRA_DEQ_GLUT1}, 2068871002d7SAnil Varughese {0x0014, SIERRA_DEQ_GLUT2}, 2069871002d7SAnil Varughese {0x0014, SIERRA_DEQ_GLUT3}, 2070871002d7SAnil Varughese {0x0014, SIERRA_DEQ_GLUT4}, 2071871002d7SAnil Varughese {0x0014, SIERRA_DEQ_GLUT5}, 2072871002d7SAnil Varughese {0x0014, SIERRA_DEQ_GLUT6}, 2073871002d7SAnil Varughese {0x0014, SIERRA_DEQ_GLUT7}, 2074871002d7SAnil Varughese {0x0014, SIERRA_DEQ_GLUT8}, 2075871002d7SAnil Varughese {0x0014, SIERRA_DEQ_GLUT9}, 2076871002d7SAnil Varughese {0x0014, SIERRA_DEQ_GLUT10}, 2077871002d7SAnil Varughese {0x0014, SIERRA_DEQ_GLUT11}, 2078871002d7SAnil Varughese {0x0014, SIERRA_DEQ_GLUT12}, 2079871002d7SAnil Varughese {0x0014, SIERRA_DEQ_GLUT13}, 2080871002d7SAnil Varughese {0x0014, SIERRA_DEQ_GLUT14}, 2081871002d7SAnil Varughese {0x0014, SIERRA_DEQ_GLUT15}, 2082871002d7SAnil Varughese {0x0014, SIERRA_DEQ_GLUT16}, 2083871002d7SAnil Varughese {0x0BAE, SIERRA_DEQ_ALUT0}, 2084871002d7SAnil Varughese {0x0AEB, SIERRA_DEQ_ALUT1}, 2085871002d7SAnil Varughese {0x0A28, SIERRA_DEQ_ALUT2}, 2086871002d7SAnil Varughese {0x0965, SIERRA_DEQ_ALUT3}, 2087871002d7SAnil Varughese {0x08A2, SIERRA_DEQ_ALUT4}, 2088871002d7SAnil Varughese {0x07DF, SIERRA_DEQ_ALUT5}, 2089871002d7SAnil Varughese {0x071C, SIERRA_DEQ_ALUT6}, 2090871002d7SAnil Varughese {0x0659, SIERRA_DEQ_ALUT7}, 2091871002d7SAnil Varughese {0x0596, SIERRA_DEQ_ALUT8}, 2092871002d7SAnil Varughese {0x0514, SIERRA_DEQ_ALUT9}, 2093871002d7SAnil Varughese {0x0492, SIERRA_DEQ_ALUT10}, 2094871002d7SAnil Varughese {0x0410, SIERRA_DEQ_ALUT11}, 2095871002d7SAnil Varughese {0x038E, SIERRA_DEQ_ALUT12}, 2096871002d7SAnil Varughese {0x030C, SIERRA_DEQ_ALUT13}, 2097871002d7SAnil Varughese {0x03F4, SIERRA_DEQ_DFETAP_CTRL_PREG}, 2098871002d7SAnil Varughese {0x0001, SIERRA_DFE_EN_1010_IGNORE_PREG}, 2099871002d7SAnil Varughese {0x3C01, SIERRA_DEQ_TAU_CTRL1_FAST_MAINT_PREG}, 2100871002d7SAnil Varughese {0x3C40, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG}, 2101871002d7SAnil Varughese {0x1C08, SIERRA_DEQ_TAU_CTRL2_PREG}, 2102871002d7SAnil Varughese {0x0033, SIERRA_DEQ_PICTRL_PREG}, 2103871002d7SAnil Varughese {0x0400, SIERRA_CPICAL_TMRVAL_MODE1_PREG}, 2104871002d7SAnil Varughese {0x0330, SIERRA_CPICAL_TMRVAL_MODE0_PREG}, 2105871002d7SAnil Varughese {0x01FF, SIERRA_CPICAL_PICNT_MODE1_PREG}, 2106aead5fd6SKishon Vijay Abraham I {0x0009, SIERRA_CPI_OUTBUF_RATESEL_PREG}, 2107871002d7SAnil Varughese {0x3232, SIERRA_CPICAL_RES_STARTCODE_MODE23_PREG}, 2108871002d7SAnil Varughese {0x0005, SIERRA_LFPSDET_SUPPORT_PREG}, 2109aead5fd6SKishon Vijay Abraham I {0x000F, SIERRA_LFPSFILT_NS_PREG}, 2110aead5fd6SKishon Vijay Abraham I {0x0009, SIERRA_LFPSFILT_RD_PREG}, 2111aead5fd6SKishon Vijay Abraham I {0x0001, SIERRA_LFPSFILT_MP_PREG}, 21122bcf14caSSanket Parmar {0x6013, SIERRA_SIGDET_SUPPORT_PREG}, 2113aead5fd6SKishon Vijay Abraham I {0x8013, SIERRA_SDFILT_H2L_A_PREG}, 2114871002d7SAnil Varughese {0x8009, SIERRA_SDFILT_L2H_PREG}, 2115871002d7SAnil Varughese {0x0024, SIERRA_RXBUFFER_CTLECTRL_PREG}, 2116871002d7SAnil Varughese {0x0020, SIERRA_RXBUFFER_RCDFECTRL_PREG}, 2117871002d7SAnil Varughese {0x4243, SIERRA_RXBUFFER_DFECTRL_PREG} 211844d30d62SAlan Douglas }; 211944d30d62SAlan Douglas 2120078e9e92SSwapnil Jakhade static struct cdns_sierra_vals usb_100_ext_ssc_cmn_vals = { 2121078e9e92SSwapnil Jakhade .reg_pairs = cdns_usb_cmn_regs_ext_ssc, 2122078e9e92SSwapnil Jakhade .num_regs = ARRAY_SIZE(cdns_usb_cmn_regs_ext_ssc), 2123078e9e92SSwapnil Jakhade }; 2124078e9e92SSwapnil Jakhade 2125078e9e92SSwapnil Jakhade static struct cdns_sierra_vals usb_100_ext_ssc_ln_vals = { 2126078e9e92SSwapnil Jakhade .reg_pairs = cdns_usb_ln_regs_ext_ssc, 2127078e9e92SSwapnil Jakhade .num_regs = ARRAY_SIZE(cdns_usb_ln_regs_ext_ssc), 2128078e9e92SSwapnil Jakhade }; 2129078e9e92SSwapnil Jakhade 213044d30d62SAlan Douglas static const struct cdns_sierra_data cdns_map_sierra = { 2131078e9e92SSwapnil Jakhade .id_value = SIERRA_MACRO_ID, 2132078e9e92SSwapnil Jakhade .block_offset_shift = 0x2, 2133078e9e92SSwapnil Jakhade .reg_offset_shift = 0x2, 2134fa105172SSwapnil Jakhade .pcs_cmn_vals = { 2135fa105172SSwapnil Jakhade [TYPE_PCIE] = { 2136fa105172SSwapnil Jakhade [TYPE_NONE] = { 21377a5ad9b4SSwapnil Jakhade [NO_SSC] = &pcie_phy_pcs_cmn_vals, 2138fa105172SSwapnil Jakhade [EXTERNAL_SSC] = &pcie_phy_pcs_cmn_vals, 21397a5ad9b4SSwapnil Jakhade [INTERNAL_SSC] = &pcie_phy_pcs_cmn_vals, 2140fa105172SSwapnil Jakhade }, 21418a1b82d7SSwapnil Jakhade [TYPE_QSGMII] = { 21428a1b82d7SSwapnil Jakhade [NO_SSC] = &pcie_phy_pcs_cmn_vals, 21438a1b82d7SSwapnil Jakhade [EXTERNAL_SSC] = &pcie_phy_pcs_cmn_vals, 21448a1b82d7SSwapnil Jakhade [INTERNAL_SSC] = &pcie_phy_pcs_cmn_vals, 21458a1b82d7SSwapnil Jakhade }, 2146fa105172SSwapnil Jakhade }, 2147fa105172SSwapnil Jakhade }, 2148078e9e92SSwapnil Jakhade .pma_cmn_vals = { 2149078e9e92SSwapnil Jakhade [TYPE_PCIE] = { 2150078e9e92SSwapnil Jakhade [TYPE_NONE] = { 21517a5ad9b4SSwapnil Jakhade [NO_SSC] = &pcie_100_no_ssc_cmn_vals, 2152078e9e92SSwapnil Jakhade [EXTERNAL_SSC] = &pcie_100_ext_ssc_cmn_vals, 21537a5ad9b4SSwapnil Jakhade [INTERNAL_SSC] = &pcie_100_int_ssc_cmn_vals, 2154078e9e92SSwapnil Jakhade }, 21558a1b82d7SSwapnil Jakhade [TYPE_QSGMII] = { 21568a1b82d7SSwapnil Jakhade [NO_SSC] = &pcie_100_no_ssc_plllc_cmn_vals, 21578a1b82d7SSwapnil Jakhade [EXTERNAL_SSC] = &pcie_100_ext_ssc_plllc_cmn_vals, 21588a1b82d7SSwapnil Jakhade [INTERNAL_SSC] = &pcie_100_int_ssc_plllc_cmn_vals, 21598a1b82d7SSwapnil Jakhade }, 2160078e9e92SSwapnil Jakhade }, 2161078e9e92SSwapnil Jakhade [TYPE_USB] = { 2162078e9e92SSwapnil Jakhade [TYPE_NONE] = { 2163078e9e92SSwapnil Jakhade [EXTERNAL_SSC] = &usb_100_ext_ssc_cmn_vals, 2164078e9e92SSwapnil Jakhade }, 2165078e9e92SSwapnil Jakhade }, 21668a1b82d7SSwapnil Jakhade [TYPE_QSGMII] = { 21678a1b82d7SSwapnil Jakhade [TYPE_PCIE] = { 21688a1b82d7SSwapnil Jakhade [NO_SSC] = &qsgmii_100_no_ssc_plllc1_cmn_vals, 21698a1b82d7SSwapnil Jakhade [EXTERNAL_SSC] = &qsgmii_100_no_ssc_plllc1_cmn_vals, 21708a1b82d7SSwapnil Jakhade [INTERNAL_SSC] = &qsgmii_100_no_ssc_plllc1_cmn_vals, 21718a1b82d7SSwapnil Jakhade }, 21728a1b82d7SSwapnil Jakhade }, 2173078e9e92SSwapnil Jakhade }, 2174078e9e92SSwapnil Jakhade .pma_ln_vals = { 2175078e9e92SSwapnil Jakhade [TYPE_PCIE] = { 2176078e9e92SSwapnil Jakhade [TYPE_NONE] = { 21777a5ad9b4SSwapnil Jakhade [NO_SSC] = &pcie_100_no_ssc_ln_vals, 2178078e9e92SSwapnil Jakhade [EXTERNAL_SSC] = &pcie_100_ext_ssc_ln_vals, 21797a5ad9b4SSwapnil Jakhade [INTERNAL_SSC] = &pcie_100_int_ssc_ln_vals, 2180078e9e92SSwapnil Jakhade }, 21818a1b82d7SSwapnil Jakhade [TYPE_QSGMII] = { 21828a1b82d7SSwapnil Jakhade [NO_SSC] = &ml_pcie_100_no_ssc_ln_vals, 21838a1b82d7SSwapnil Jakhade [EXTERNAL_SSC] = &ml_pcie_100_ext_ssc_ln_vals, 21848a1b82d7SSwapnil Jakhade [INTERNAL_SSC] = &ml_pcie_100_int_ssc_ln_vals, 21858a1b82d7SSwapnil Jakhade }, 2186078e9e92SSwapnil Jakhade }, 2187078e9e92SSwapnil Jakhade [TYPE_USB] = { 2188078e9e92SSwapnil Jakhade [TYPE_NONE] = { 2189078e9e92SSwapnil Jakhade [EXTERNAL_SSC] = &usb_100_ext_ssc_ln_vals, 2190078e9e92SSwapnil Jakhade }, 2191078e9e92SSwapnil Jakhade }, 21928a1b82d7SSwapnil Jakhade [TYPE_QSGMII] = { 21938a1b82d7SSwapnil Jakhade [TYPE_PCIE] = { 21948a1b82d7SSwapnil Jakhade [NO_SSC] = &qsgmii_100_no_ssc_plllc1_ln_vals, 21958a1b82d7SSwapnil Jakhade [EXTERNAL_SSC] = &qsgmii_100_no_ssc_plllc1_ln_vals, 21968a1b82d7SSwapnil Jakhade [INTERNAL_SSC] = &qsgmii_100_no_ssc_plllc1_ln_vals, 21978a1b82d7SSwapnil Jakhade }, 21988a1b82d7SSwapnil Jakhade }, 2199078e9e92SSwapnil Jakhade }, 220044d30d62SAlan Douglas }; 220144d30d62SAlan Douglas 2202367da978SKishon Vijay Abraham I static const struct cdns_sierra_data cdns_ti_map_sierra = { 2203078e9e92SSwapnil Jakhade .id_value = SIERRA_MACRO_ID, 2204078e9e92SSwapnil Jakhade .block_offset_shift = 0x0, 2205078e9e92SSwapnil Jakhade .reg_offset_shift = 0x1, 2206fa105172SSwapnil Jakhade .pcs_cmn_vals = { 2207fa105172SSwapnil Jakhade [TYPE_PCIE] = { 2208fa105172SSwapnil Jakhade [TYPE_NONE] = { 22097a5ad9b4SSwapnil Jakhade [NO_SSC] = &pcie_phy_pcs_cmn_vals, 2210fa105172SSwapnil Jakhade [EXTERNAL_SSC] = &pcie_phy_pcs_cmn_vals, 22117a5ad9b4SSwapnil Jakhade [INTERNAL_SSC] = &pcie_phy_pcs_cmn_vals, 2212fa105172SSwapnil Jakhade }, 22138a1b82d7SSwapnil Jakhade [TYPE_QSGMII] = { 22148a1b82d7SSwapnil Jakhade [NO_SSC] = &pcie_phy_pcs_cmn_vals, 22158a1b82d7SSwapnil Jakhade [EXTERNAL_SSC] = &pcie_phy_pcs_cmn_vals, 22168a1b82d7SSwapnil Jakhade [INTERNAL_SSC] = &pcie_phy_pcs_cmn_vals, 22178a1b82d7SSwapnil Jakhade }, 22188a1b82d7SSwapnil Jakhade }, 22198a1b82d7SSwapnil Jakhade }, 22208a1b82d7SSwapnil Jakhade .phy_pma_ln_vals = { 22218a1b82d7SSwapnil Jakhade [TYPE_QSGMII] = { 22228a1b82d7SSwapnil Jakhade [TYPE_PCIE] = { 22238a1b82d7SSwapnil Jakhade [NO_SSC] = &qsgmii_phy_pma_ln_vals, 22248a1b82d7SSwapnil Jakhade [EXTERNAL_SSC] = &qsgmii_phy_pma_ln_vals, 22258a1b82d7SSwapnil Jakhade [INTERNAL_SSC] = &qsgmii_phy_pma_ln_vals, 22268a1b82d7SSwapnil Jakhade }, 2227fa105172SSwapnil Jakhade }, 2228fa105172SSwapnil Jakhade }, 2229078e9e92SSwapnil Jakhade .pma_cmn_vals = { 2230078e9e92SSwapnil Jakhade [TYPE_PCIE] = { 2231078e9e92SSwapnil Jakhade [TYPE_NONE] = { 22327a5ad9b4SSwapnil Jakhade [NO_SSC] = &pcie_100_no_ssc_cmn_vals, 2233078e9e92SSwapnil Jakhade [EXTERNAL_SSC] = &pcie_100_ext_ssc_cmn_vals, 22347a5ad9b4SSwapnil Jakhade [INTERNAL_SSC] = &pcie_100_int_ssc_cmn_vals, 2235078e9e92SSwapnil Jakhade }, 22368a1b82d7SSwapnil Jakhade [TYPE_QSGMII] = { 22378a1b82d7SSwapnil Jakhade [NO_SSC] = &pcie_100_no_ssc_plllc_cmn_vals, 22388a1b82d7SSwapnil Jakhade [EXTERNAL_SSC] = &pcie_100_ext_ssc_plllc_cmn_vals, 22398a1b82d7SSwapnil Jakhade [INTERNAL_SSC] = &pcie_100_int_ssc_plllc_cmn_vals, 22408a1b82d7SSwapnil Jakhade }, 2241078e9e92SSwapnil Jakhade }, 2242078e9e92SSwapnil Jakhade [TYPE_USB] = { 2243078e9e92SSwapnil Jakhade [TYPE_NONE] = { 2244078e9e92SSwapnil Jakhade [EXTERNAL_SSC] = &usb_100_ext_ssc_cmn_vals, 2245078e9e92SSwapnil Jakhade }, 2246078e9e92SSwapnil Jakhade }, 22478a1b82d7SSwapnil Jakhade [TYPE_QSGMII] = { 22488a1b82d7SSwapnil Jakhade [TYPE_PCIE] = { 22498a1b82d7SSwapnil Jakhade [NO_SSC] = &qsgmii_100_no_ssc_plllc1_cmn_vals, 22508a1b82d7SSwapnil Jakhade [EXTERNAL_SSC] = &qsgmii_100_no_ssc_plllc1_cmn_vals, 22518a1b82d7SSwapnil Jakhade [INTERNAL_SSC] = &qsgmii_100_no_ssc_plllc1_cmn_vals, 22528a1b82d7SSwapnil Jakhade }, 22538a1b82d7SSwapnil Jakhade }, 2254078e9e92SSwapnil Jakhade }, 2255078e9e92SSwapnil Jakhade .pma_ln_vals = { 2256078e9e92SSwapnil Jakhade [TYPE_PCIE] = { 2257078e9e92SSwapnil Jakhade [TYPE_NONE] = { 22587a5ad9b4SSwapnil Jakhade [NO_SSC] = &pcie_100_no_ssc_ln_vals, 2259078e9e92SSwapnil Jakhade [EXTERNAL_SSC] = &pcie_100_ext_ssc_ln_vals, 22607a5ad9b4SSwapnil Jakhade [INTERNAL_SSC] = &pcie_100_int_ssc_ln_vals, 2261078e9e92SSwapnil Jakhade }, 22628a1b82d7SSwapnil Jakhade [TYPE_QSGMII] = { 22638a1b82d7SSwapnil Jakhade [NO_SSC] = &ml_pcie_100_no_ssc_ln_vals, 22648a1b82d7SSwapnil Jakhade [EXTERNAL_SSC] = &ml_pcie_100_ext_ssc_ln_vals, 22658a1b82d7SSwapnil Jakhade [INTERNAL_SSC] = &ml_pcie_100_int_ssc_ln_vals, 22668a1b82d7SSwapnil Jakhade }, 2267078e9e92SSwapnil Jakhade }, 2268078e9e92SSwapnil Jakhade [TYPE_USB] = { 2269078e9e92SSwapnil Jakhade [TYPE_NONE] = { 2270078e9e92SSwapnil Jakhade [EXTERNAL_SSC] = &usb_100_ext_ssc_ln_vals, 2271078e9e92SSwapnil Jakhade }, 2272078e9e92SSwapnil Jakhade }, 22738a1b82d7SSwapnil Jakhade [TYPE_QSGMII] = { 22748a1b82d7SSwapnil Jakhade [TYPE_PCIE] = { 22758a1b82d7SSwapnil Jakhade [NO_SSC] = &qsgmii_100_no_ssc_plllc1_ln_vals, 22768a1b82d7SSwapnil Jakhade [EXTERNAL_SSC] = &qsgmii_100_no_ssc_plllc1_ln_vals, 22778a1b82d7SSwapnil Jakhade [INTERNAL_SSC] = &qsgmii_100_no_ssc_plllc1_ln_vals, 22788a1b82d7SSwapnil Jakhade }, 22798a1b82d7SSwapnil Jakhade }, 2280078e9e92SSwapnil Jakhade }, 2281367da978SKishon Vijay Abraham I }; 2282367da978SKishon Vijay Abraham I 228344d30d62SAlan Douglas static const struct of_device_id cdns_sierra_id_table[] = { 228444d30d62SAlan Douglas { 228544d30d62SAlan Douglas .compatible = "cdns,sierra-phy-t0", 228644d30d62SAlan Douglas .data = &cdns_map_sierra, 228744d30d62SAlan Douglas }, 2288367da978SKishon Vijay Abraham I { 2289367da978SKishon Vijay Abraham I .compatible = "ti,sierra-phy-t0", 2290367da978SKishon Vijay Abraham I .data = &cdns_ti_map_sierra, 2291367da978SKishon Vijay Abraham I }, 229244d30d62SAlan Douglas {} 229344d30d62SAlan Douglas }; 229444d30d62SAlan Douglas MODULE_DEVICE_TABLE(of, cdns_sierra_id_table); 229544d30d62SAlan Douglas 229644d30d62SAlan Douglas static struct platform_driver cdns_sierra_driver = { 229744d30d62SAlan Douglas .probe = cdns_sierra_phy_probe, 229844d30d62SAlan Douglas .remove = cdns_sierra_phy_remove, 229944d30d62SAlan Douglas .driver = { 230044d30d62SAlan Douglas .name = "cdns-sierra-phy", 230144d30d62SAlan Douglas .of_match_table = cdns_sierra_id_table, 230244d30d62SAlan Douglas }, 230344d30d62SAlan Douglas }; 230444d30d62SAlan Douglas module_platform_driver(cdns_sierra_driver); 230544d30d62SAlan Douglas 230644d30d62SAlan Douglas MODULE_ALIAS("platform:cdns_sierra"); 230744d30d62SAlan Douglas MODULE_AUTHOR("Cadence Design Systems"); 230844d30d62SAlan Douglas MODULE_DESCRIPTION("CDNS sierra phy driver"); 230944d30d62SAlan Douglas MODULE_LICENSE("GPL v2"); 2310