194a407ccSDmitry Baryshkov // SPDX-License-Identifier: GPL-2.0 294a407ccSDmitry Baryshkov /* 394a407ccSDmitry Baryshkov * Copyright (c) 2017, The Linux Foundation. All rights reserved. 494a407ccSDmitry Baryshkov */ 594a407ccSDmitry Baryshkov 694a407ccSDmitry Baryshkov #include <linux/clk.h> 794a407ccSDmitry Baryshkov #include <linux/clk-provider.h> 894a407ccSDmitry Baryshkov #include <linux/delay.h> 994a407ccSDmitry Baryshkov #include <linux/err.h> 1094a407ccSDmitry Baryshkov #include <linux/io.h> 1194a407ccSDmitry Baryshkov #include <linux/iopoll.h> 1294a407ccSDmitry Baryshkov #include <linux/kernel.h> 1394a407ccSDmitry Baryshkov #include <linux/module.h> 1494a407ccSDmitry Baryshkov #include <linux/of.h> 1594a407ccSDmitry Baryshkov #include <linux/of_device.h> 1694a407ccSDmitry Baryshkov #include <linux/of_address.h> 1794a407ccSDmitry Baryshkov #include <linux/phy/phy.h> 1894a407ccSDmitry Baryshkov #include <linux/platform_device.h> 1994a407ccSDmitry Baryshkov #include <linux/regulator/consumer.h> 2094a407ccSDmitry Baryshkov #include <linux/reset.h> 2194a407ccSDmitry Baryshkov #include <linux/slab.h> 2294a407ccSDmitry Baryshkov 2394a407ccSDmitry Baryshkov #include <dt-bindings/phy/phy.h> 2494a407ccSDmitry Baryshkov 2594a407ccSDmitry Baryshkov #include "phy-qcom-qmp.h" 2694a407ccSDmitry Baryshkov 2794a407ccSDmitry Baryshkov /* QPHY_SW_RESET bit */ 2894a407ccSDmitry Baryshkov #define SW_RESET BIT(0) 2994a407ccSDmitry Baryshkov /* QPHY_POWER_DOWN_CONTROL */ 3094a407ccSDmitry Baryshkov #define SW_PWRDN BIT(0) 3194a407ccSDmitry Baryshkov #define REFCLK_DRV_DSBL BIT(1) 3294a407ccSDmitry Baryshkov /* QPHY_START_CONTROL bits */ 3394a407ccSDmitry Baryshkov #define SERDES_START BIT(0) 3494a407ccSDmitry Baryshkov #define PCS_START BIT(1) 3594a407ccSDmitry Baryshkov #define PLL_READY_GATE_EN BIT(3) 3694a407ccSDmitry Baryshkov /* QPHY_PCS_STATUS bit */ 3794a407ccSDmitry Baryshkov #define PHYSTATUS BIT(6) 3894a407ccSDmitry Baryshkov #define PHYSTATUS_4_20 BIT(7) 3994a407ccSDmitry Baryshkov /* QPHY_PCS_READY_STATUS & QPHY_COM_PCS_READY_STATUS bit */ 4094a407ccSDmitry Baryshkov #define PCS_READY BIT(0) 4194a407ccSDmitry Baryshkov 4294a407ccSDmitry Baryshkov /* QPHY_V3_DP_COM_RESET_OVRD_CTRL register bits */ 4394a407ccSDmitry Baryshkov /* DP PHY soft reset */ 4494a407ccSDmitry Baryshkov #define SW_DPPHY_RESET BIT(0) 4594a407ccSDmitry Baryshkov /* mux to select DP PHY reset control, 0:HW control, 1: software reset */ 4694a407ccSDmitry Baryshkov #define SW_DPPHY_RESET_MUX BIT(1) 4794a407ccSDmitry Baryshkov /* USB3 PHY soft reset */ 4894a407ccSDmitry Baryshkov #define SW_USB3PHY_RESET BIT(2) 4994a407ccSDmitry Baryshkov /* mux to select USB3 PHY reset control, 0:HW control, 1: software reset */ 5094a407ccSDmitry Baryshkov #define SW_USB3PHY_RESET_MUX BIT(3) 5194a407ccSDmitry Baryshkov 5294a407ccSDmitry Baryshkov /* QPHY_V3_DP_COM_PHY_MODE_CTRL register bits */ 5394a407ccSDmitry Baryshkov #define USB3_MODE BIT(0) /* enables USB3 mode */ 5494a407ccSDmitry Baryshkov #define DP_MODE BIT(1) /* enables DP mode */ 5594a407ccSDmitry Baryshkov 5694a407ccSDmitry Baryshkov /* QPHY_PCS_AUTONOMOUS_MODE_CTRL register bits */ 5794a407ccSDmitry Baryshkov #define ARCVR_DTCT_EN BIT(0) 5894a407ccSDmitry Baryshkov #define ALFPS_DTCT_EN BIT(1) 5994a407ccSDmitry Baryshkov #define ARCVR_DTCT_EVENT_SEL BIT(4) 6094a407ccSDmitry Baryshkov 6194a407ccSDmitry Baryshkov /* QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR register bits */ 6294a407ccSDmitry Baryshkov #define IRQ_CLEAR BIT(0) 6394a407ccSDmitry Baryshkov 6494a407ccSDmitry Baryshkov /* QPHY_PCS_LFPS_RXTERM_IRQ_STATUS register bits */ 6594a407ccSDmitry Baryshkov #define RCVR_DETECT BIT(0) 6694a407ccSDmitry Baryshkov 6794a407ccSDmitry Baryshkov /* QPHY_V3_PCS_MISC_CLAMP_ENABLE register bits */ 6894a407ccSDmitry Baryshkov #define CLAMP_EN BIT(0) /* enables i/o clamp_n */ 6994a407ccSDmitry Baryshkov 7094a407ccSDmitry Baryshkov #define PHY_INIT_COMPLETE_TIMEOUT 10000 7194a407ccSDmitry Baryshkov #define POWER_DOWN_DELAY_US_MIN 10 7294a407ccSDmitry Baryshkov #define POWER_DOWN_DELAY_US_MAX 11 7394a407ccSDmitry Baryshkov 7494a407ccSDmitry Baryshkov #define MAX_PROP_NAME 32 7594a407ccSDmitry Baryshkov 7694a407ccSDmitry Baryshkov /* Define the assumed distance between lanes for underspecified device trees. */ 7794a407ccSDmitry Baryshkov #define QMP_PHY_LEGACY_LANE_STRIDE 0x400 7894a407ccSDmitry Baryshkov 7994a407ccSDmitry Baryshkov struct qmp_phy_init_tbl { 8094a407ccSDmitry Baryshkov unsigned int offset; 8194a407ccSDmitry Baryshkov unsigned int val; 8294a407ccSDmitry Baryshkov /* 8394a407ccSDmitry Baryshkov * register part of layout ? 8494a407ccSDmitry Baryshkov * if yes, then offset gives index in the reg-layout 8594a407ccSDmitry Baryshkov */ 8694a407ccSDmitry Baryshkov bool in_layout; 8794a407ccSDmitry Baryshkov /* 8894a407ccSDmitry Baryshkov * mask of lanes for which this register is written 8994a407ccSDmitry Baryshkov * for cases when second lane needs different values 9094a407ccSDmitry Baryshkov */ 9194a407ccSDmitry Baryshkov u8 lane_mask; 9294a407ccSDmitry Baryshkov }; 9394a407ccSDmitry Baryshkov 9494a407ccSDmitry Baryshkov #define QMP_PHY_INIT_CFG(o, v) \ 9594a407ccSDmitry Baryshkov { \ 9694a407ccSDmitry Baryshkov .offset = o, \ 9794a407ccSDmitry Baryshkov .val = v, \ 9894a407ccSDmitry Baryshkov .lane_mask = 0xff, \ 9994a407ccSDmitry Baryshkov } 10094a407ccSDmitry Baryshkov 10194a407ccSDmitry Baryshkov #define QMP_PHY_INIT_CFG_L(o, v) \ 10294a407ccSDmitry Baryshkov { \ 10394a407ccSDmitry Baryshkov .offset = o, \ 10494a407ccSDmitry Baryshkov .val = v, \ 10594a407ccSDmitry Baryshkov .in_layout = true, \ 10694a407ccSDmitry Baryshkov .lane_mask = 0xff, \ 10794a407ccSDmitry Baryshkov } 10894a407ccSDmitry Baryshkov 10994a407ccSDmitry Baryshkov #define QMP_PHY_INIT_CFG_LANE(o, v, l) \ 11094a407ccSDmitry Baryshkov { \ 11194a407ccSDmitry Baryshkov .offset = o, \ 11294a407ccSDmitry Baryshkov .val = v, \ 11394a407ccSDmitry Baryshkov .lane_mask = l, \ 11494a407ccSDmitry Baryshkov } 11594a407ccSDmitry Baryshkov 11694a407ccSDmitry Baryshkov /* set of registers with offsets different per-PHY */ 11794a407ccSDmitry Baryshkov enum qphy_reg_layout { 11894a407ccSDmitry Baryshkov /* Common block control registers */ 11994a407ccSDmitry Baryshkov QPHY_COM_SW_RESET, 12094a407ccSDmitry Baryshkov QPHY_COM_POWER_DOWN_CONTROL, 12194a407ccSDmitry Baryshkov QPHY_COM_START_CONTROL, 12294a407ccSDmitry Baryshkov QPHY_COM_PCS_READY_STATUS, 12394a407ccSDmitry Baryshkov /* PCS registers */ 12494a407ccSDmitry Baryshkov QPHY_SW_RESET, 12594a407ccSDmitry Baryshkov QPHY_START_CTRL, 12694a407ccSDmitry Baryshkov QPHY_PCS_READY_STATUS, 12794a407ccSDmitry Baryshkov QPHY_PCS_STATUS, 12894a407ccSDmitry Baryshkov QPHY_PCS_AUTONOMOUS_MODE_CTRL, 12994a407ccSDmitry Baryshkov QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR, 13094a407ccSDmitry Baryshkov QPHY_PCS_LFPS_RXTERM_IRQ_STATUS, 13194a407ccSDmitry Baryshkov QPHY_PCS_POWER_DOWN_CONTROL, 13294a407ccSDmitry Baryshkov /* PCS_MISC registers */ 13394a407ccSDmitry Baryshkov QPHY_PCS_MISC_TYPEC_CTRL, 13494a407ccSDmitry Baryshkov /* Keep last to ensure regs_layout arrays are properly initialized */ 13594a407ccSDmitry Baryshkov QPHY_LAYOUT_SIZE 13694a407ccSDmitry Baryshkov }; 13794a407ccSDmitry Baryshkov 13894a407ccSDmitry Baryshkov static const unsigned int ipq_pciephy_gen3_regs_layout[QPHY_LAYOUT_SIZE] = { 13994a407ccSDmitry Baryshkov [QPHY_SW_RESET] = 0x00, 14094a407ccSDmitry Baryshkov [QPHY_START_CTRL] = 0x44, 14194a407ccSDmitry Baryshkov [QPHY_PCS_STATUS] = 0x14, 14294a407ccSDmitry Baryshkov [QPHY_PCS_POWER_DOWN_CONTROL] = 0x40, 14394a407ccSDmitry Baryshkov }; 14494a407ccSDmitry Baryshkov 14594a407ccSDmitry Baryshkov static const unsigned int pciephy_regs_layout[QPHY_LAYOUT_SIZE] = { 14694a407ccSDmitry Baryshkov [QPHY_COM_SW_RESET] = 0x400, 14794a407ccSDmitry Baryshkov [QPHY_COM_POWER_DOWN_CONTROL] = 0x404, 14894a407ccSDmitry Baryshkov [QPHY_COM_START_CONTROL] = 0x408, 14994a407ccSDmitry Baryshkov [QPHY_COM_PCS_READY_STATUS] = 0x448, 15094a407ccSDmitry Baryshkov [QPHY_SW_RESET] = 0x00, 15194a407ccSDmitry Baryshkov [QPHY_START_CTRL] = 0x08, 15294a407ccSDmitry Baryshkov [QPHY_PCS_STATUS] = 0x174, 15394a407ccSDmitry Baryshkov }; 15494a407ccSDmitry Baryshkov 15594a407ccSDmitry Baryshkov static const unsigned int sdm845_qmp_pciephy_regs_layout[QPHY_LAYOUT_SIZE] = { 15694a407ccSDmitry Baryshkov [QPHY_SW_RESET] = 0x00, 15794a407ccSDmitry Baryshkov [QPHY_START_CTRL] = 0x08, 15894a407ccSDmitry Baryshkov [QPHY_PCS_STATUS] = 0x174, 15994a407ccSDmitry Baryshkov }; 16094a407ccSDmitry Baryshkov 16194a407ccSDmitry Baryshkov static const unsigned int sdm845_qhp_pciephy_regs_layout[QPHY_LAYOUT_SIZE] = { 16294a407ccSDmitry Baryshkov [QPHY_SW_RESET] = 0x00, 16394a407ccSDmitry Baryshkov [QPHY_START_CTRL] = 0x08, 16494a407ccSDmitry Baryshkov [QPHY_PCS_STATUS] = 0x2ac, 16594a407ccSDmitry Baryshkov }; 16694a407ccSDmitry Baryshkov 16794a407ccSDmitry Baryshkov static const unsigned int sm8250_pcie_regs_layout[QPHY_LAYOUT_SIZE] = { 16894a407ccSDmitry Baryshkov [QPHY_SW_RESET] = 0x00, 16994a407ccSDmitry Baryshkov [QPHY_START_CTRL] = 0x44, 17094a407ccSDmitry Baryshkov [QPHY_PCS_STATUS] = 0x14, 17194a407ccSDmitry Baryshkov [QPHY_PCS_POWER_DOWN_CONTROL] = 0x40, 17294a407ccSDmitry Baryshkov }; 17394a407ccSDmitry Baryshkov 17494a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl msm8998_pcie_serdes_tbl[] = { 17594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_BIAS_EN_CLKBUFLR_EN, 0x14), 17694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_SELECT, 0x30), 17794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_IVCO, 0x0f), 17894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_CMN_CONFIG, 0x06), 17994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP_EN, 0x01), 18094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_RESETSM_CNTRL, 0x20), 18194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_MAP, 0x00), 18294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE2_MODE0, 0x01), 18394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE1_MODE0, 0xc9), 18494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_TIMER1, 0xff), 18594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_TIMER2, 0x3f), 18694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_SVS_MODE_CLK_SEL, 0x01), 18794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_CORE_CLK_EN, 0x00), 18894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_CORECLK_DIV_MODE0, 0x0a), 18994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_EP_DIV, 0x19), 19094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_ENABLE1, 0x90), 19194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_DEC_START_MODE0, 0x82), 19294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START3_MODE0, 0x03), 19394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START2_MODE0, 0x55), 19494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START1_MODE0, 0x55), 19594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP3_MODE0, 0x00), 19694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP2_MODE0, 0x0d), 19794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP1_MODE0, 0x04), 19894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_HSCLK_SEL, 0x00), 19994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_CP_CTRL_MODE0, 0x08), 20094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_RCTRL_MODE0, 0x16), 20194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_CCTRL_MODE0, 0x34), 20294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_CMN_CONFIG, 0x06), 20394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_SELECT, 0x33), 20494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYS_CLK_CTRL, 0x02), 20594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYSCLK_BUF_ENABLE, 0x07), 20694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYSCLK_EN_SEL, 0x04), 20794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN1_MODE0, 0x00), 20894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN0_MODE0, 0x3f), 20994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_BG_TIMER, 0x09), 21094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_EN_CENTER, 0x01), 21194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_PER1, 0x40), 21294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_PER2, 0x01), 21394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_ADJ_PER1, 0x02), 21494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_ADJ_PER2, 0x00), 21594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_STEP_SIZE1, 0x7e), 21694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_STEP_SIZE2, 0x15), 21794a407ccSDmitry Baryshkov }; 21894a407ccSDmitry Baryshkov 21994a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl msm8998_pcie_tx_tbl[] = { 22094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_TX_RES_CODE_LANE_OFFSET_TX, 0x02), 22194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_TX_RCV_DETECT_LVL_2, 0x12), 22294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_TX_HIGHZ_DRVR_EN, 0x10), 22394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_TX_LANE_MODE_1, 0x06), 22494a407ccSDmitry Baryshkov }; 22594a407ccSDmitry Baryshkov 22694a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl msm8998_pcie_rx_tbl[] = { 22794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_CNTRL, 0x03), 22894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_ENABLES, 0x1c), 22994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_DEGLITCH_CNTRL, 0x14), 23094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL2, 0x0a), 23194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL3, 0x04), 23294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL4, 0x1a), 23394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x4b), 23494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SO_GAIN, 0x04), 23594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SO_GAIN_HALF, 0x04), 23694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1, 0x00), 23794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_OFFSET_ADAPTOR_CNTRL2, 0x80), 23894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_INTERFACE_MODE, 0x40), 23994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_PI_CONTROLS, 0x71), 24094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_FASTLOCK_COUNT_LOW, 0x40), 24194a407ccSDmitry Baryshkov }; 24294a407ccSDmitry Baryshkov 24394a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl msm8998_pcie_pcs_tbl[] = { 24494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V3_PCS_ENDPOINT_REFCLK_DRIVE, 0x04), 24594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V3_PCS_OSC_DTCT_ACTIONS, 0x00), 24694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V3_PCS_PWRUP_RESET_DLY_TIME_AUXCLK, 0x01), 24794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V3_PCS_L1SS_WAKEUP_DLY_TIME_AUXCLK_MSB, 0x00), 24894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V3_PCS_L1SS_WAKEUP_DLY_TIME_AUXCLK_LSB, 0x20), 24994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V3_PCS_LP_WAKEUP_DLY_TIME_AUXCLK_MSB, 0x00), 25094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V3_PCS_LP_WAKEUP_DLY_TIME_AUXCLK, 0x01), 25194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V3_PCS_PLL_LOCK_CHK_DLY_TIME, 0x73), 25294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V3_PCS_RX_SIGDET_LVL, 0x99), 25394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V3_PCS_SIGDET_CNTRL, 0x03), 25494a407ccSDmitry Baryshkov }; 25594a407ccSDmitry Baryshkov 25694a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl ipq6018_pcie_serdes_tbl[] = { 25794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_SSC_PER1, 0x7d), 25894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_SSC_PER2, 0x01), 25994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_SSC_STEP_SIZE1_MODE0, 0x0a), 26094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_SSC_STEP_SIZE2_MODE0, 0x05), 26194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_SSC_STEP_SIZE1_MODE1, 0x08), 26294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_SSC_STEP_SIZE2_MODE1, 0x04), 26394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_BIAS_EN_CLKBUFLR_EN, 0x18), 26494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_CLK_ENABLE1, 0x90), 26594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_SYS_CLK_CTRL, 0x02), 26694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_SYSCLK_BUF_ENABLE, 0x07), 26794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_PLL_IVCO, 0x0f), 26894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_LOCK_CMP1_MODE0, 0xd4), 26994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_LOCK_CMP2_MODE0, 0x14), 27094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_LOCK_CMP1_MODE1, 0xaa), 27194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_LOCK_CMP2_MODE1, 0x29), 27294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_BG_TRIM, 0x0f), 27394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_CP_CTRL_MODE0, 0x09), 27494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_CP_CTRL_MODE1, 0x09), 27594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_PLL_RCTRL_MODE0, 0x16), 27694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_PLL_RCTRL_MODE1, 0x16), 27794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_PLL_CCTRL_MODE0, 0x28), 27894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_PLL_CCTRL_MODE1, 0x28), 27994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_BIAS_EN_CTRL_BY_PSM, 0x01), 28094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_SYSCLK_EN_SEL, 0x08), 28194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_RESETSM_CNTRL, 0x20), 28294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_LOCK_CMP_EN, 0x42), 28394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_DEC_START_MODE0, 0x68), 28494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_DEC_START_MODE1, 0x53), 28594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_DIV_FRAC_START1_MODE0, 0xab), 28694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_DIV_FRAC_START2_MODE0, 0xaa), 28794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_DIV_FRAC_START3_MODE0, 0x02), 28894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_DIV_FRAC_START1_MODE1, 0x55), 28994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_DIV_FRAC_START2_MODE1, 0x55), 29094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_DIV_FRAC_START3_MODE1, 0x05), 29194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_INTEGLOOP_GAIN0_MODE0, 0xa0), 29294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_INTEGLOOP_GAIN0_MODE1, 0xa0), 29394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_VCO_TUNE1_MODE0, 0x24), 29494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_VCO_TUNE2_MODE0, 0x02), 29594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_VCO_TUNE1_MODE1, 0xb4), 29694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_VCO_TUNE2_MODE1, 0x03), 29794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_CLK_SELECT, 0x32), 29894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_HSCLK_SEL, 0x01), 29994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_CORE_CLK_EN, 0x00), 30094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_CMN_CONFIG, 0x06), 30194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_SVS_MODE_CLK_SEL, 0x05), 30294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_CORECLK_DIV_MODE1, 0x08), 30394a407ccSDmitry Baryshkov }; 30494a407ccSDmitry Baryshkov 30594a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl ipq6018_pcie_tx_tbl[] = { 306079328a9SDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_TX_RES_CODE_LANE_OFFSET_TX, 0x02), 307079328a9SDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_TX_LANE_MODE_1, 0x06), 308079328a9SDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_TX_RCV_DETECT_LVL_2, 0x12), 30994a407ccSDmitry Baryshkov }; 31094a407ccSDmitry Baryshkov 31194a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl ipq6018_pcie_rx_tbl[] = { 312079328a9SDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_FO_GAIN, 0x0c), 313079328a9SDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SO_GAIN, 0x02), 314079328a9SDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x7f), 315079328a9SDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_PI_CONTROLS, 0x70), 316079328a9SDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL2, 0x61), 317079328a9SDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL3, 0x04), 318079328a9SDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL4, 0x1e), 319079328a9SDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_IDAC_TSETTLE_LOW, 0xc0), 320079328a9SDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_IDAC_TSETTLE_HIGH, 0x00), 321079328a9SDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1, 0x73), 322079328a9SDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_OFFSET_ADAPTOR_CNTRL2, 0x80), 323079328a9SDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_ENABLES, 0x1c), 324079328a9SDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_CNTRL, 0x03), 325079328a9SDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_DEGLITCH_CNTRL, 0x14), 326079328a9SDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_LOW, 0xf0), 327079328a9SDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH, 0x01), 328079328a9SDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH2, 0x2f), 329079328a9SDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH3, 0xd3), 330079328a9SDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH4, 0x40), 331079328a9SDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_LOW, 0x01), 332079328a9SDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH, 0x02), 333079328a9SDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH2, 0xc8), 334079328a9SDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH3, 0x09), 335079328a9SDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH4, 0xb1), 336079328a9SDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_LOW, 0x00), 337079328a9SDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH, 0x02), 338079328a9SDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH2, 0xc8), 339079328a9SDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH3, 0x09), 340079328a9SDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH4, 0xb1), 341079328a9SDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_DFE_EN_TIMER, 0x04), 34294a407ccSDmitry Baryshkov }; 34394a407ccSDmitry Baryshkov 34494a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl ipq6018_pcie_pcs_tbl[] = { 34560f23414SDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_FLL_CNTRL1, 0x01), 34660f23414SDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_REFGEN_REQ_CONFIG1, 0x0d), 34760f23414SDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_G12S1_TXDEEMPH_M3P5DB, 0x10), 34860f23414SDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_RX_SIGDET_LVL, 0xaa), 34960f23414SDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_P2U3_WAKEUP_DLY_TIME_AUXCLK_L, 0x01), 35060f23414SDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_RX_DCC_CAL_CONFIG, 0x01), 35160f23414SDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_EQ_CONFIG5, 0x01), 352af664324SDmitry Baryshkov }; 353af664324SDmitry Baryshkov 354af664324SDmitry Baryshkov static const struct qmp_phy_init_tbl ipq6018_pcie_pcs_misc_tbl[] = { 35560f23414SDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_POWER_STATE_CONFIG2, 0x0d), 35660f23414SDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_POWER_STATE_CONFIG4, 0x07), 35760f23414SDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_ENDPOINT_REFCLK_DRIVE, 0xc1), 35860f23414SDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_L1P1_WAKEUP_DLY_TIME_AUXCLK_L, 0x01), 35960f23414SDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_L1P2_WAKEUP_DLY_TIME_AUXCLK_L, 0x01), 36060f23414SDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_OSC_DTCT_ACTIONS, 0x00), 36160f23414SDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_EQ_CONFIG1, 0x11), 36260f23414SDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_PRESET_P10_PRE, 0x00), 36360f23414SDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_PRESET_P10_POST, 0x58), 36494a407ccSDmitry Baryshkov }; 36594a407ccSDmitry Baryshkov 36694a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl ipq8074_pcie_serdes_tbl[] = { 36794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_BIAS_EN_CLKBUFLR_EN, 0x18), 36894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_CLK_ENABLE1, 0x10), 36994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_BG_TRIM, 0xf), 37094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP_EN, 0x1), 37194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_MAP, 0x0), 37294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_TIMER1, 0xff), 37394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_TIMER2, 0x1f), 37494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_CMN_CONFIG, 0x6), 37594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_PLL_IVCO, 0xf), 37694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_HSCLK_SEL, 0x0), 37794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_SVS_MODE_CLK_SEL, 0x1), 37894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_CORE_CLK_EN, 0x20), 37994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_CORECLK_DIV, 0xa), 38094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_RESETSM_CNTRL, 0x20), 38194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_BG_TIMER, 0xa), 38294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_SYSCLK_EN_SEL, 0xa), 38394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_DEC_START_MODE0, 0x82), 38494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_DIV_FRAC_START3_MODE0, 0x3), 38594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_DIV_FRAC_START2_MODE0, 0x55), 38694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_DIV_FRAC_START1_MODE0, 0x55), 38794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP3_MODE0, 0x0), 38894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP2_MODE0, 0xD), 38994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP1_MODE0, 0xD04), 39094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_CLK_SELECT, 0x33), 39194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_SYS_CLK_CTRL, 0x2), 39294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_SYSCLK_BUF_ENABLE, 0x1f), 39394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_CP_CTRL_MODE0, 0xb), 39494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_PLL_RCTRL_MODE0, 0x16), 39594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_PLL_CCTRL_MODE0, 0x28), 39694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_INTEGLOOP_GAIN1_MODE0, 0x0), 39794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_INTEGLOOP_GAIN0_MODE0, 0x80), 39894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_BIAS_EN_CTRL_BY_PSM, 0x1), 39994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_SSC_EN_CENTER, 0x1), 40094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_SSC_PER1, 0x31), 40194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_SSC_PER2, 0x1), 40294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_SSC_ADJ_PER1, 0x2), 40394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_SSC_ADJ_PER2, 0x0), 40494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_SSC_STEP_SIZE1, 0x2f), 40594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_SSC_STEP_SIZE2, 0x19), 40694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_CLK_EP_DIV, 0x19), 40794a407ccSDmitry Baryshkov }; 40894a407ccSDmitry Baryshkov 40994a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl ipq8074_pcie_tx_tbl[] = { 41094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_TX_HIGHZ_TRANSCEIVEREN_BIAS_DRVR_EN, 0x45), 41194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_TX_LANE_MODE, 0x6), 41294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_TX_RES_CODE_LANE_OFFSET, 0x2), 41394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_TX_RCV_DETECT_LVL_2, 0x12), 414f7c5cedbSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_TX_TX_EMP_POST1_LVL, 0x36), 41594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_TX_SLEW_CNTL, 0x0a), 41694a407ccSDmitry Baryshkov }; 41794a407ccSDmitry Baryshkov 41894a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl ipq8074_pcie_rx_tbl[] = { 41994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_RX_SIGDET_ENABLES, 0x1c), 42094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_RX_SIGDET_DEGLITCH_CNTRL, 0x14), 42194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_RX_RX_EQU_ADAPTOR_CNTRL2, 0x1), 42294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_RX_RX_EQU_ADAPTOR_CNTRL3, 0x0), 42394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_RX_RX_EQU_ADAPTOR_CNTRL4, 0xdb), 42494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x4b), 42594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_RX_UCDR_SO_GAIN, 0x4), 42694a407ccSDmitry Baryshkov }; 42794a407ccSDmitry Baryshkov 42894a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl ipq8074_pcie_pcs_tbl[] = { 4296cad2983SDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V2_PCS_ENDPOINT_REFCLK_DRIVE, 0x4), 4306cad2983SDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V2_PCS_OSC_DTCT_ACTIONS, 0x0), 4316cad2983SDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V2_PCS_PWRUP_RESET_DLY_TIME_AUXCLK, 0x40), 4326cad2983SDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V2_PCS_L1SS_WAKEUP_DLY_TIME_AUXCLK_MSB, 0x0), 4336cad2983SDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V2_PCS_L1SS_WAKEUP_DLY_TIME_AUXCLK_LSB, 0x40), 4346cad2983SDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V2_PCS_PLL_LOCK_CHK_DLY_TIME_AUXCLK_LSB, 0x0), 4356cad2983SDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V2_PCS_LP_WAKEUP_DLY_TIME_AUXCLK, 0x40), 436c1ab64aaSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V2_PCS_PLL_LOCK_CHK_DLY_TIME, 0x73), 4376cad2983SDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V2_PCS_RX_SIGDET_LVL, 0x99), 4386cad2983SDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V2_PCS_TXDEEMPH_M6DB_V0, 0x15), 4396cad2983SDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V2_PCS_TXDEEMPH_M3P5DB_V0, 0xe), 44094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG_L(QPHY_SW_RESET, 0x0), 44194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG_L(QPHY_START_CTRL, 0x3), 44294a407ccSDmitry Baryshkov }; 44394a407ccSDmitry Baryshkov 444334fad18SRobert Marko static const struct qmp_phy_init_tbl ipq8074_pcie_gen3_serdes_tbl[] = { 445334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_BIAS_EN_CLKBUFLR_EN, 0x18), 446334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_BIAS_EN_CTRL_BY_PSM, 0x01), 447334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_CLK_SELECT, 0x31), 448334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_PLL_IVCO, 0x0f), 449334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_BG_TRIM, 0x0f), 450334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_CMN_CONFIG, 0x06), 451334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_LOCK_CMP_EN, 0x42), 452334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_RESETSM_CNTRL, 0x20), 453334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_SVS_MODE_CLK_SEL, 0x01), 454334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_VCO_TUNE_MAP, 0x04), 455334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_SVS_MODE_CLK_SEL, 0x05), 456334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_VCO_TUNE_TIMER1, 0xff), 457334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_VCO_TUNE_TIMER2, 0x3f), 458334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_CORE_CLK_EN, 0x30), 459334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_HSCLK_SEL, 0x21), 460334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_DEC_START_MODE0, 0x82), 461334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_DIV_FRAC_START3_MODE0, 0x03), 462334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_DIV_FRAC_START2_MODE0, 0x355), 463334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_DIV_FRAC_START1_MODE0, 0x35555), 464334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_LOCK_CMP2_MODE0, 0x1a), 465334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_LOCK_CMP1_MODE0, 0x1a0a), 466334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_CP_CTRL_MODE0, 0xb), 467334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_PLL_RCTRL_MODE0, 0x16), 468334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_PLL_CCTRL_MODE0, 0x28), 469334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_INTEGLOOP_GAIN1_MODE0, 0x0), 470334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_INTEGLOOP_GAIN0_MODE0, 0x40), 471334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_VCO_TUNE2_MODE0, 0x02), 472334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_VCO_TUNE1_MODE0, 0x24), 473334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_SVS_MODE_CLK_SEL, 0x05), 474334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_CORE_CLK_EN, 0x20), 475334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_CORECLK_DIV, 0xa), 476334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_CLK_SELECT, 0x32), 477334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_SYS_CLK_CTRL, 0x02), 478334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_SYSCLK_BUF_ENABLE, 0x07), 479334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_SYSCLK_EN_SEL, 0x08), 480334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_BG_TIMER, 0xa), 481334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_HSCLK_SEL, 0x1), 482334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_DEC_START_MODE1, 0x68), 483334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_DIV_FRAC_START3_MODE1, 0x2), 484334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_DIV_FRAC_START2_MODE1, 0x2aa), 485334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_DIV_FRAC_START1_MODE1, 0x2aaab), 486334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_CLK_ENABLE1, 0x90), 487334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_LOCK_CMP2_MODE1, 0x34), 488334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_LOCK_CMP1_MODE1, 0x3414), 489334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_CP_CTRL_MODE1, 0x0b), 490334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_PLL_RCTRL_MODE1, 0x16), 491334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_PLL_CCTRL_MODE1, 0x28), 492334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_INTEGLOOP_GAIN1_MODE1, 0x0), 493334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_INTEGLOOP_GAIN0_MODE1, 0x40), 494334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_VCO_TUNE2_MODE1, 0x03), 495334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_VCO_TUNE1_MODE1, 0xb4), 496334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_SVS_MODE_CLK_SEL, 0x05), 497334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_CORE_CLK_EN, 0x0), 498334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_CORECLK_DIV_MODE1, 0x08), 499334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_CLK_EP_DIV_MODE0, 0x19), 500334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_CLK_EP_DIV_MODE1, 0x28), 501334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_CLK_ENABLE1, 0x90), 502334fad18SRobert Marko }; 503334fad18SRobert Marko 504334fad18SRobert Marko static const struct qmp_phy_init_tbl ipq8074_pcie_gen3_tx_tbl[] = { 505079328a9SDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_TX_RES_CODE_LANE_OFFSET_TX, 0x02), 506079328a9SDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_TX_RCV_DETECT_LVL_2, 0x12), 507079328a9SDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_TX_HIGHZ_DRVR_EN, 0x10), 508079328a9SDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_TX_LANE_MODE_1, 0x06), 509334fad18SRobert Marko }; 510334fad18SRobert Marko 511334fad18SRobert Marko static const struct qmp_phy_init_tbl ipq8074_pcie_gen3_rx_tbl[] = { 512079328a9SDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_CNTRL, 0x03), 513079328a9SDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_ENABLES, 0x1c), 514079328a9SDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_DEGLITCH_CNTRL, 0x14), 515079328a9SDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL2, 0xe), 516079328a9SDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL3, 0x4), 517079328a9SDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL4, 0x1b), 518079328a9SDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_DFE_EN_TIMER, 0x04), 519079328a9SDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x7f), 520079328a9SDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_PI_CONTROLS, 0x70), 521079328a9SDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1, 0x73), 522079328a9SDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_OFFSET_ADAPTOR_CNTRL2, 0x80), 523079328a9SDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_LOW, 0x00), 524079328a9SDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH, 0x02), 525079328a9SDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH2, 0xc8), 526079328a9SDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH3, 0x09), 527079328a9SDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH4, 0xb1), 528079328a9SDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_LOW, 0x01), 529079328a9SDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH, 0x02), 530079328a9SDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH2, 0xc8), 531079328a9SDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH3, 0x09), 532079328a9SDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH4, 0xb1), 533079328a9SDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_LOW, 0xf0), 534079328a9SDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH, 0x2), 535079328a9SDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH2, 0x2f), 536079328a9SDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH3, 0xd3), 537079328a9SDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH4, 0x40), 538079328a9SDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_IDAC_TSETTLE_HIGH, 0x00), 539079328a9SDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_IDAC_TSETTLE_LOW, 0xc0), 540079328a9SDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_FO_GAIN, 0x0c), 541079328a9SDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SO_GAIN, 0x02), 542334fad18SRobert Marko }; 543334fad18SRobert Marko 544334fad18SRobert Marko static const struct qmp_phy_init_tbl ipq8074_pcie_gen3_pcs_tbl[] = { 54560f23414SDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_FLL_CNTRL2, 0x83), 54660f23414SDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_FLL_CNT_VAL_L, 0x9), 54760f23414SDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_FLL_CNT_VAL_H_TOL, 0x42), 54860f23414SDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_FLL_MAN_CODE, 0x40), 54960f23414SDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_FLL_CNTRL1, 0x01), 55060f23414SDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_P2U3_WAKEUP_DLY_TIME_AUXCLK_H, 0x0), 55160f23414SDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_P2U3_WAKEUP_DLY_TIME_AUXCLK_L, 0x1), 55260f23414SDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_OSC_DTCT_ACTIONS, 0x0), 55360f23414SDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_L1P1_WAKEUP_DLY_TIME_AUXCLK_H, 0x00), 55460f23414SDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_L1P1_WAKEUP_DLY_TIME_AUXCLK_L, 0x01), 55560f23414SDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_L1P2_WAKEUP_DLY_TIME_AUXCLK_H, 0x00), 55660f23414SDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_L1P2_WAKEUP_DLY_TIME_AUXCLK_L, 0x01), 55760f23414SDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_EQ_CONFIG1, 0x11), 55860f23414SDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_EQ_CONFIG2, 0xb), 55960f23414SDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_POWER_STATE_CONFIG4, 0x07), 56060f23414SDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_OSC_DTCT_CONFIG2, 0x52), 56160f23414SDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_OSC_DTCT_MODE2_CONFIG2, 0x50), 56260f23414SDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_OSC_DTCT_MODE2_CONFIG4, 0x1a), 56360f23414SDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_OSC_DTCT_MODE2_CONFIG5, 0x6), 56460f23414SDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_G12S1_TXDEEMPH_M3P5DB, 0x10), 56560f23414SDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_ENDPOINT_REFCLK_DRIVE, 0xc1), 56660f23414SDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_RX_DCC_CAL_CONFIG, 0x01), 56760f23414SDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_RX_SIGDET_LVL, 0xaa), 56860f23414SDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_REFGEN_REQ_CONFIG1, 0x0d), 569334fad18SRobert Marko }; 570334fad18SRobert Marko 57194a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sdm845_qmp_pcie_serdes_tbl[] = { 57294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_BIAS_EN_CLKBUFLR_EN, 0x14), 57394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_SELECT, 0x30), 57494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_IVCO, 0x007), 57594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_CMN_CONFIG, 0x06), 57694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP_EN, 0x01), 57794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_RESETSM_CNTRL, 0x20), 57894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_MAP, 0x00), 57994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE2_MODE0, 0x01), 58094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE1_MODE0, 0xc9), 58194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_TIMER1, 0xff), 58294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_TIMER2, 0x3f), 58394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_SVS_MODE_CLK_SEL, 0x01), 58494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_CORE_CLK_EN, 0x00), 58594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_CORECLK_DIV_MODE0, 0x0a), 58694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_EP_DIV, 0x19), 58794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_ENABLE1, 0x90), 58894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_DEC_START_MODE0, 0x82), 58994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START3_MODE0, 0x02), 59094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START2_MODE0, 0xea), 59194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START1_MODE0, 0xab), 59294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP3_MODE0, 0x00), 59394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP2_MODE0, 0x0d), 59494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP1_MODE0, 0x04), 59594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_HSCLK_SEL, 0x00), 59694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_CP_CTRL_MODE0, 0x06), 59794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_RCTRL_MODE0, 0x16), 59894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_CCTRL_MODE0, 0x36), 59994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_CMN_MODE, 0x01), 60094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_SELECT, 0x33), 60194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYS_CLK_CTRL, 0x02), 60294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYSCLK_BUF_ENABLE, 0x06), 60394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYSCLK_EN_SEL, 0x04), 60494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN1_MODE0, 0x00), 60594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN0_MODE0, 0x3f), 60694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_BG_TIMER, 0x09), 60794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_EN_CENTER, 0x01), 60894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_PER1, 0x40), 60994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_PER2, 0x01), 61094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_ADJ_PER1, 0x02), 61194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_ADJ_PER2, 0x00), 61294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_STEP_SIZE1, 0x7e), 61394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_STEP_SIZE2, 0x15), 61494a407ccSDmitry Baryshkov }; 61594a407ccSDmitry Baryshkov 61694a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sdm845_qmp_pcie_tx_tbl[] = { 61794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_TX_RES_CODE_LANE_OFFSET_TX, 0x02), 61894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_TX_RCV_DETECT_LVL_2, 0x12), 61994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_TX_HIGHZ_DRVR_EN, 0x10), 62094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_TX_LANE_MODE_1, 0x06), 62194a407ccSDmitry Baryshkov }; 62294a407ccSDmitry Baryshkov 62394a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sdm845_qmp_pcie_rx_tbl[] = { 62494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_CNTRL, 0x03), 62594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_ENABLES, 0x10), 62694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_DEGLITCH_CNTRL, 0x14), 62794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL2, 0x0e), 62894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL3, 0x04), 62994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL4, 0x1a), 63094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x4b), 63194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SO_GAIN, 0x04), 63294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SO_GAIN_HALF, 0x04), 63394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1, 0x71), 63494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_MODE_00, 0x59), 63594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_MODE_01, 0x59), 63694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_OFFSET_ADAPTOR_CNTRL2, 0x80), 63794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_INTERFACE_MODE, 0x40), 63894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_PI_CONTROLS, 0x71), 63994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_FASTLOCK_COUNT_LOW, 0x40), 64094a407ccSDmitry Baryshkov }; 64194a407ccSDmitry Baryshkov 64294a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sdm845_qmp_pcie_pcs_tbl[] = { 64394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V3_PCS_ENDPOINT_REFCLK_DRIVE, 0x04), 64494a407ccSDmitry Baryshkov 64594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNTRL2, 0x83), 64694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNT_VAL_L, 0x09), 64794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNT_VAL_H_TOL, 0xa2), 64894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_MAN_CODE, 0x40), 64994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNTRL1, 0x02), 65094a407ccSDmitry Baryshkov 65194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V3_PCS_OSC_DTCT_ACTIONS, 0x00), 65294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V3_PCS_PWRUP_RESET_DLY_TIME_AUXCLK, 0x01), 65394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V3_PCS_L1SS_WAKEUP_DLY_TIME_AUXCLK_MSB, 0x00), 65494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V3_PCS_L1SS_WAKEUP_DLY_TIME_AUXCLK_LSB, 0x20), 65594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V3_PCS_LP_WAKEUP_DLY_TIME_AUXCLK_MSB, 0x00), 65694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V3_PCS_LP_WAKEUP_DLY_TIME_AUXCLK, 0x01), 65794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V3_PCS_PLL_LOCK_CHK_DLY_TIME, 0x73), 65894a407ccSDmitry Baryshkov 65994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V3_PCS_RX_SIGDET_LVL, 0xbb), 66094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V3_PCS_SIGDET_CNTRL, 0x03), 66194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V3_PCS_REFGEN_REQ_CONFIG1, 0x0d), 66294a407ccSDmitry Baryshkov 66394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V3_PCS_POWER_STATE_CONFIG4, 0x00), 66494a407ccSDmitry Baryshkov }; 66594a407ccSDmitry Baryshkov 66694a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sdm845_qmp_pcie_pcs_misc_tbl[] = { 66794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V3_PCS_MISC_OSC_DTCT_CONFIG2, 0x52), 66894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V3_PCS_MISC_OSC_DTCT_MODE2_CONFIG2, 0x10), 66994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V3_PCS_MISC_OSC_DTCT_MODE2_CONFIG4, 0x1a), 67094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V3_PCS_MISC_OSC_DTCT_MODE2_CONFIG5, 0x06), 67194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V3_PCS_MISC_PCIE_INT_AUX_CLK_CONFIG1, 0x00), 67294a407ccSDmitry Baryshkov }; 67394a407ccSDmitry Baryshkov 67494a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sdm845_qhp_pcie_serdes_tbl[] = { 67594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_SYSCLK_EN_SEL, 0x27), 67694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_SSC_EN_CENTER, 0x01), 67794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_SSC_PER1, 0x31), 67894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_SSC_PER2, 0x01), 67994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_SSC_STEP_SIZE1, 0xde), 68094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_SSC_STEP_SIZE2, 0x07), 68194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_SSC_STEP_SIZE1_MODE1, 0x4c), 68294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_SSC_STEP_SIZE2_MODE1, 0x06), 68394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_BIAS_EN_CKBUFLR_EN, 0x18), 68494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_CLK_ENABLE1, 0xb0), 68594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_LOCK_CMP1_MODE0, 0x8c), 68694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_LOCK_CMP2_MODE0, 0x20), 68794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_LOCK_CMP1_MODE1, 0x14), 68894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_LOCK_CMP2_MODE1, 0x34), 68994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_CP_CTRL_MODE0, 0x06), 69094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_CP_CTRL_MODE1, 0x06), 69194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_PLL_RCTRL_MODE0, 0x16), 69294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_PLL_RCTRL_MODE1, 0x16), 69394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_PLL_CCTRL_MODE0, 0x36), 69494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_PLL_CCTRL_MODE1, 0x36), 69594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_RESTRIM_CTRL2, 0x05), 69694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_LOCK_CMP_EN, 0x42), 69794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_DEC_START_MODE0, 0x82), 69894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_DEC_START_MODE1, 0x68), 69994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_DIV_FRAC_START1_MODE0, 0x55), 70094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_DIV_FRAC_START2_MODE0, 0x55), 70194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_DIV_FRAC_START3_MODE0, 0x03), 70294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_DIV_FRAC_START1_MODE1, 0xab), 70394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_DIV_FRAC_START2_MODE1, 0xaa), 70494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_DIV_FRAC_START3_MODE1, 0x02), 70594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_INTEGLOOP_GAIN0_MODE0, 0x3f), 70694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_INTEGLOOP_GAIN0_MODE1, 0x3f), 70794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_VCO_TUNE_MAP, 0x10), 70894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_CLK_SELECT, 0x04), 70994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_HSCLK_SEL1, 0x30), 71094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_CORECLK_DIV, 0x04), 71194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_CORE_CLK_EN, 0x73), 71294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_CMN_CONFIG, 0x0c), 71394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_SVS_MODE_CLK_SEL, 0x15), 71494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_CORECLK_DIV_MODE1, 0x04), 71594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_CMN_MODE, 0x01), 71694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_VREGCLK_DIV1, 0x22), 71794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_VREGCLK_DIV2, 0x00), 71894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_BGV_TRIM, 0x20), 71994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_BG_CTRL, 0x07), 72094a407ccSDmitry Baryshkov }; 72194a407ccSDmitry Baryshkov 72294a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sdm845_qhp_pcie_tx_tbl[] = { 72394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_DRVR_CTRL0, 0x00), 72494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_DRVR_TAP_EN, 0x0d), 72594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_TX_BAND_MODE, 0x01), 72694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_LANE_MODE, 0x1a), 72794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_PARALLEL_RATE, 0x2f), 72894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_CML_CTRL_MODE0, 0x09), 72994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_CML_CTRL_MODE1, 0x09), 73094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_CML_CTRL_MODE2, 0x1b), 73194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_PREAMP_CTRL_MODE1, 0x01), 73294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_PREAMP_CTRL_MODE2, 0x07), 73394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_MIXER_CTRL_MODE0, 0x31), 73494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_MIXER_CTRL_MODE1, 0x31), 73594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_MIXER_CTRL_MODE2, 0x03), 73694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_CTLE_THRESH_DFE, 0x02), 73794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_CGA_THRESH_DFE, 0x00), 73894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RXENGINE_EN0, 0x12), 73994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_CTLE_TRAIN_TIME, 0x25), 74094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_CTLE_DFE_OVRLP_TIME, 0x00), 74194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_DFE_REFRESH_TIME, 0x05), 74294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_DFE_ENABLE_TIME, 0x01), 74394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_VGA_GAIN, 0x26), 74494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_DFE_GAIN, 0x12), 74594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_EQ_GAIN, 0x04), 74694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_OFFSET_GAIN, 0x04), 74794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_PRE_GAIN, 0x09), 74894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_EQ_INTVAL, 0x15), 74994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_EDAC_INITVAL, 0x28), 75094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RXEQ_INITB0, 0x7f), 75194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RXEQ_INITB1, 0x07), 75294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RCVRDONE_THRESH1, 0x04), 75394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RXEQ_CTRL, 0x70), 75494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_UCDR_FO_GAIN_MODE0, 0x8b), 75594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_UCDR_FO_GAIN_MODE1, 0x08), 75694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_UCDR_FO_GAIN_MODE2, 0x0a), 75794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_UCDR_SO_GAIN_MODE0, 0x03), 75894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_UCDR_SO_GAIN_MODE1, 0x04), 75994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_UCDR_SO_GAIN_MODE2, 0x04), 76094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_UCDR_SO_CONFIG, 0x0c), 76194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RX_BAND, 0x02), 76294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RX_RCVR_PATH1_MODE0, 0x5c), 76394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RX_RCVR_PATH1_MODE1, 0x3e), 76494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RX_RCVR_PATH1_MODE2, 0x3f), 76594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_SIGDET_ENABLES, 0x01), 76694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_SIGDET_CNTRL, 0xa0), 76794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_SIGDET_DEGLITCH_CNTRL, 0x08), 76894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_DCC_GAIN, 0x01), 76994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RX_EN_SIGNAL, 0xc3), 77094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_PSM_RX_EN_CAL, 0x00), 77194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RX_MISC_CNTRL0, 0xbc), 77294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_TS0_TIMER, 0x7f), 77394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_DLL_HIGHDATARATE, 0x15), 77494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_DRVR_CTRL1, 0x0c), 77594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_DRVR_CTRL2, 0x0f), 77694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RX_RESETCODE_OFFSET, 0x04), 77794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_VGA_INITVAL, 0x20), 77894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RSM_START, 0x01), 77994a407ccSDmitry Baryshkov }; 78094a407ccSDmitry Baryshkov 78194a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sdm845_qhp_pcie_rx_tbl[] = { 78294a407ccSDmitry Baryshkov }; 78394a407ccSDmitry Baryshkov 78494a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sdm845_qhp_pcie_pcs_tbl[] = { 78594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_PHY_POWER_STATE_CONFIG, 0x3f), 78694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_PHY_PCS_TX_RX_CONFIG, 0x50), 78794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_PHY_TXMGN_MAIN_V0_M3P5DB, 0x19), 78894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_PHY_TXMGN_POST_V0_M3P5DB, 0x07), 78994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_PHY_TXMGN_MAIN_V0_M6DB, 0x17), 79094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_PHY_TXMGN_POST_V0_M6DB, 0x09), 79194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_PHY_POWER_STATE_CONFIG5, 0x9f), 79294a407ccSDmitry Baryshkov }; 79394a407ccSDmitry Baryshkov 79494a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sc8180x_qmp_pcie_serdes_tbl[] = { 79594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_SYSCLK_EN_SEL, 0x08), 79694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_CLK_SELECT, 0x34), 79794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_CORECLK_DIV_MODE1, 0x08), 79894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_IVCO, 0x0f), 79994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP_EN, 0x42), 80094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE1_MODE0, 0x24), 80194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE2_MODE1, 0x03), 80294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE1_MODE1, 0xb4), 80394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE_MAP, 0x02), 80494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_HSCLK_SEL, 0x11), 80594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_DEC_START_MODE0, 0x82), 80694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START3_MODE0, 0x03), 80794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START2_MODE0, 0x55), 80894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START1_MODE0, 0x55), 80994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP2_MODE0, 0x1a), 81094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP1_MODE0, 0x0a), 81194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_DEC_START_MODE1, 0x68), 81294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START3_MODE1, 0x02), 81394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START2_MODE1, 0xaa), 81494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START1_MODE1, 0xab), 81594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP2_MODE1, 0x34), 81694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP1_MODE1, 0x14), 81794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_HSCLK_SEL, 0x01), 81894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_CP_CTRL_MODE0, 0x06), 81994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_RCTRL_MODE0, 0x16), 82094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_CCTRL_MODE0, 0x36), 82194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_CP_CTRL_MODE1, 0x06), 82294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_RCTRL_MODE1, 0x16), 82394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_CCTRL_MODE1, 0x36), 82494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE2_MODE0, 0x1e), 82594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE1_MODE0, 0xca), 82694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE2_MODE1, 0x18), 82794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE1_MODE1, 0xa2), 82894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_SYSCLK_BUF_ENABLE, 0x07), 82994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_EN_CENTER, 0x01), 83094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_PER1, 0x31), 83194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_PER2, 0x01), 83294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_STEP_SIZE1_MODE0, 0xde), 83394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_STEP_SIZE2_MODE0, 0x07), 83494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_STEP_SIZE1_MODE1, 0x4c), 83594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_STEP_SIZE2_MODE1, 0x06), 83694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_CLK_ENABLE1, 0x90), 83794a407ccSDmitry Baryshkov }; 83894a407ccSDmitry Baryshkov 83994a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sc8180x_qmp_pcie_tx_tbl[] = { 84094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_TX_RCV_DETECT_LVL_2, 0x12), 84194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_TX_LANE_MODE_1, 0x5), 84294a407ccSDmitry Baryshkov }; 84394a407ccSDmitry Baryshkov 84494a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sc8180x_qmp_pcie_rx_tbl[] = { 84594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_CNTRL, 0x03), 84694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_ENABLES, 0x1c), 84794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_DEGLITCH_CNTRL, 0x14), 84894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL1, 0x07), 84994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL2, 0x6e), 85094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL3, 0x6e), 85194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL4, 0x4a), 85294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_DFE_EN_TIMER, 0x04), 85394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x7f), 85494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_PI_CONTROLS, 0x70), 85594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1, 0x17), 85694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_VGA_CAL_CNTRL1, 0x54), 85794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_VGA_CAL_CNTRL2, 0x37), 85894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_LOW, 0xd4), 85994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH, 0x54), 86094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH2, 0xdb), 86194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH3, 0x39), 86294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH4, 0x31), 86394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_LOW, 0x24), 86494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH, 0xe4), 86594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH2, 0xec), 86694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH3, 0x39), 86794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH4, 0x36), 86894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_LOW, 0x7f), 86994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH, 0xff), 87094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH2, 0xff), 87194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH3, 0xdb), 87294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH4, 0x75), 87394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_IDAC_TSETTLE_HIGH, 0x00), 87494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_IDAC_TSETTLE_LOW, 0xc0), 87594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_AUX_DATA_TCOARSE_TFINE, 0xa0), 87694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RCLK_AUXDATA_SEL, 0xc0), 87794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_DCC_CTRL1, 0x0c), 87894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_GM_CAL, 0x05), 87994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_FO_GAIN, 0x0c), 88094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SO_GAIN, 0x03), 88194a407ccSDmitry Baryshkov }; 88294a407ccSDmitry Baryshkov 88394a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sc8180x_qmp_pcie_pcs_tbl[] = { 88494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_P2U3_WAKEUP_DLY_TIME_AUXCLK_L, 0x01), 88594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_RX_SIGDET_LVL, 0xaa), 88694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_RATE_SLEW_CNTRL1, 0x0b), 88794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_REFGEN_REQ_CONFIG1, 0x0d), 88894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_EQ_CONFIG5, 0x01), 88994a407ccSDmitry Baryshkov }; 89094a407ccSDmitry Baryshkov 89194a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sc8180x_qmp_pcie_pcs_misc_tbl[] = { 89294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_OSC_DTCT_ACTIONS, 0x00), 89394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_L1P1_WAKEUP_DLY_TIME_AUXCLK_L, 0x01), 89494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_L1P2_WAKEUP_DLY_TIME_AUXCLK_L, 0x01), 89594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_INT_AUX_CLK_CONFIG1, 0x00), 89694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_PRESET_P10_PRE, 0x00), 89794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_PRESET_P10_POST, 0x58), 89894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_ENDPOINT_REFCLK_DRIVE, 0xc1), 89994a407ccSDmitry Baryshkov }; 90094a407ccSDmitry Baryshkov 90194a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8250_qmp_pcie_serdes_tbl[] = { 90294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_SYSCLK_EN_SEL, 0x08), 90394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_CLK_SELECT, 0x34), 90494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_CORECLK_DIV_MODE1, 0x08), 90594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_IVCO, 0x0f), 90694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP_EN, 0x42), 90794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE1_MODE0, 0x24), 90894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE2_MODE1, 0x03), 90994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE1_MODE1, 0xb4), 91094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE_MAP, 0x02), 91194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_HSCLK_SEL, 0x11), 91294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_DEC_START_MODE0, 0x82), 91394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START3_MODE0, 0x03), 91494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START2_MODE0, 0x55), 91594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START1_MODE0, 0x55), 91694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP2_MODE0, 0x1a), 91794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP1_MODE0, 0x0a), 91894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_DEC_START_MODE1, 0x68), 91994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START3_MODE1, 0x02), 92094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START2_MODE1, 0xaa), 92194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START1_MODE1, 0xab), 92294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP2_MODE1, 0x34), 92394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP1_MODE1, 0x14), 92494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_HSCLK_SEL, 0x01), 92594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_CP_CTRL_MODE0, 0x06), 92694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_RCTRL_MODE0, 0x16), 92794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_CCTRL_MODE0, 0x36), 92894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_CP_CTRL_MODE1, 0x06), 92994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_RCTRL_MODE1, 0x16), 93094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_CCTRL_MODE1, 0x36), 93194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE2_MODE0, 0x1e), 93294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE1_MODE0, 0xca), 93394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE2_MODE1, 0x18), 93494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE1_MODE1, 0xa2), 93594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_EN_CENTER, 0x01), 93694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_PER1, 0x31), 93794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_PER2, 0x01), 93894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_STEP_SIZE1_MODE0, 0xde), 93994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_STEP_SIZE2_MODE0, 0x07), 94094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_STEP_SIZE1_MODE1, 0x4c), 94194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_STEP_SIZE2_MODE1, 0x06), 94294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_CLK_ENABLE1, 0x90), 94394a407ccSDmitry Baryshkov }; 94494a407ccSDmitry Baryshkov 94594a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8250_qmp_gen3x1_pcie_serdes_tbl[] = { 94694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_SYSCLK_BUF_ENABLE, 0x07), 94794a407ccSDmitry Baryshkov }; 94894a407ccSDmitry Baryshkov 94994a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8250_qmp_pcie_tx_tbl[] = { 95094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_TX_RCV_DETECT_LVL_2, 0x12), 95194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_TX_LANE_MODE_1, 0x35), 95294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_TX_RES_CODE_LANE_OFFSET_TX, 0x11), 95394a407ccSDmitry Baryshkov }; 95494a407ccSDmitry Baryshkov 95594a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8250_qmp_pcie_rx_tbl[] = { 95694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_FO_GAIN, 0x0c), 95794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SO_GAIN, 0x03), 95894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_GM_CAL, 0x1b), 95994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_IDAC_TSETTLE_HIGH, 0x00), 96094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_IDAC_TSETTLE_LOW, 0xc0), 96194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_AUX_DATA_TCOARSE_TFINE, 0x30), 96294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_VGA_CAL_CNTRL1, 0x04), 96394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_VGA_CAL_CNTRL2, 0x07), 96494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x7f), 96594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_PI_CONTROLS, 0x70), 96694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL2, 0x0e), 96794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL3, 0x4a), 96894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL4, 0x0f), 96994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_CNTRL, 0x03), 97094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_ENABLES, 0x1c), 97194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_DEGLITCH_CNTRL, 0x1e), 97294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1, 0x17), 97394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_LOW, 0xd4), 97494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH, 0x54), 97594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH2, 0xdb), 97694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH3, 0x3b), 97794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH4, 0x31), 97894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_LOW, 0x24), 97994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH2, 0xff), 98094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH3, 0x7f), 98194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_DCC_CTRL1, 0x0c), 98294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH, 0xe4), 98394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH2, 0xec), 98494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH3, 0x3b), 98594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH4, 0x36), 98694a407ccSDmitry Baryshkov }; 98794a407ccSDmitry Baryshkov 98894a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8250_qmp_gen3x1_pcie_rx_tbl[] = { 98994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RCLK_AUXDATA_SEL, 0x00), 99094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL1, 0x00), 99194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_DFE_EN_TIMER, 0x04), 99294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_LOW, 0x3f), 99394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH4, 0x14), 99494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_DFE_CTLE_POST_CAL_OFFSET, 0x30), 99594a407ccSDmitry Baryshkov }; 99694a407ccSDmitry Baryshkov 99794a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8250_qmp_pcie_pcs_tbl[] = { 99894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_P2U3_WAKEUP_DLY_TIME_AUXCLK_L, 0x01), 99994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_RX_SIGDET_LVL, 0x77), 100094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_RATE_SLEW_CNTRL1, 0x0b), 100194a407ccSDmitry Baryshkov }; 100294a407ccSDmitry Baryshkov 100394a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8250_qmp_gen3x1_pcie_pcs_tbl[] = { 100494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_REFGEN_REQ_CONFIG1, 0x0d), 100594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_EQ_CONFIG5, 0x12), 100694a407ccSDmitry Baryshkov }; 100794a407ccSDmitry Baryshkov 100894a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8250_qmp_pcie_pcs_misc_tbl[] = { 100994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_OSC_DTCT_ACTIONS, 0x00), 101094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_L1P1_WAKEUP_DLY_TIME_AUXCLK_L, 0x01), 101194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_L1P2_WAKEUP_DLY_TIME_AUXCLK_L, 0x01), 101294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_PRESET_P6_P7_PRE, 0x33), 101394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_PRESET_P10_PRE, 0x00), 101494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_PRESET_P10_POST, 0x58), 101594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_ENDPOINT_REFCLK_DRIVE, 0xc1), 101694a407ccSDmitry Baryshkov }; 101794a407ccSDmitry Baryshkov 101894a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8250_qmp_gen3x1_pcie_pcs_misc_tbl[] = { 101994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_INT_AUX_CLK_CONFIG1, 0x00), 102094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_EQ_CONFIG2, 0x0f), 102194a407ccSDmitry Baryshkov }; 102294a407ccSDmitry Baryshkov 102394a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8250_qmp_gen3x2_pcie_tx_tbl[] = { 102494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_TX_PI_QEC_CTRL, 0x20), 102594a407ccSDmitry Baryshkov }; 102694a407ccSDmitry Baryshkov 102794a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8250_qmp_gen3x2_pcie_rx_tbl[] = { 102894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL1, 0x04), 102994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_LOW, 0xbf), 103094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH4, 0x15), 103194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_DFE_CTLE_POST_CAL_OFFSET, 0x38), 103294a407ccSDmitry Baryshkov }; 103394a407ccSDmitry Baryshkov 103494a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8250_qmp_gen3x2_pcie_pcs_tbl[] = { 103594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_REFGEN_REQ_CONFIG1, 0x05), 103694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_EQ_CONFIG2, 0x0f), 103794a407ccSDmitry Baryshkov }; 103894a407ccSDmitry Baryshkov 103994a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8250_qmp_gen3x2_pcie_pcs_misc_tbl[] = { 104094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_POWER_STATE_CONFIG2, 0x0d), 104194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_POWER_STATE_CONFIG4, 0x07), 104294a407ccSDmitry Baryshkov }; 104394a407ccSDmitry Baryshkov 104494a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sdx55_qmp_pcie_serdes_tbl[] = { 104594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_BG_TIMER, 0x02), 104694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIAS_EN_CLKBUFLR_EN, 0x18), 104794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_SYS_CLK_CTRL, 0x07), 104894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_IVCO, 0x0f), 104994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_CP_CTRL_MODE0, 0x0a), 105094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_CP_CTRL_MODE1, 0x0a), 105194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_RCTRL_MODE0, 0x19), 105294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_RCTRL_MODE1, 0x19), 105394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_CCTRL_MODE0, 0x03), 105494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_CCTRL_MODE1, 0x03), 105594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_SYSCLK_EN_SEL, 0x00), 105694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP_EN, 0x46), 105794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP_CFG, 0x04), 105894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP1_MODE0, 0x7f), 105994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP2_MODE0, 0x02), 106094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP1_MODE1, 0xff), 106194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP2_MODE1, 0x04), 106294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_DEC_START_MODE0, 0x4b), 106394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_DEC_START_MODE1, 0x50), 106494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START3_MODE0, 0x00), 106594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_INTEGLOOP_GAIN0_MODE0, 0xfb), 106694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_INTEGLOOP_GAIN1_MODE0, 0x01), 106794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_INTEGLOOP_GAIN0_MODE1, 0xfb), 106894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_INTEGLOOP_GAIN1_MODE1, 0x01), 106994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE_MAP, 0x02), 107094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_HSCLK_SEL, 0x12), 107194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_HSCLK_HS_SWITCH_SEL, 0x00), 107294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_CORECLK_DIV_MODE0, 0x05), 107394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_CORECLK_DIV_MODE1, 0x04), 107494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_CMN_CONFIG, 0x04), 107594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_CMN_MISC1, 0x88), 10761195c1daSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_CMN_MISC2, 0x03), 107794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_CMN_MODE, 0x17), 107894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_DC_LEVEL_CTRL, 0x0b), 107994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE1_MODE0, 0x56), 108094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE2_MODE0, 0x1d), 108194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE1_MODE1, 0x4b), 108294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE2_MODE1, 0x1f), 108394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_HSCLK_SEL, 0x22), 108494a407ccSDmitry Baryshkov }; 108594a407ccSDmitry Baryshkov 108694a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sdx55_qmp_pcie_tx_tbl[] = { 108794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_20_TX_LANE_MODE_1, 0x05), 108894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_20_TX_LANE_MODE_2, 0xf6), 108994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_20_TX_LANE_MODE_3, 0x13), 109094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_20_TX_VMODE_CTRL1, 0x00), 109194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_20_TX_PI_QEC_CTRL, 0x00), 109294a407ccSDmitry Baryshkov }; 109394a407ccSDmitry Baryshkov 109494a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sdx55_qmp_pcie_rx_tbl[] = { 109594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_FO_GAIN_RATE2, 0x0c), 109694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_UCDR_PI_CONTROLS, 0x16), 109794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_AUX_DATA_TCOARSE_TFINE, 0x7f), 109894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_DFE_3, 0x55), 109994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_DFE_DAC_ENABLE1, 0x0c), 110094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_DFE_DAC_ENABLE2, 0x00), 110194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_VGA_CAL_CNTRL2, 0x08), 110294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1, 0x27), 110394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE_0_1_B1, 0x1a), 110494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE_0_1_B2, 0x5a), 110594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE_0_1_B3, 0x09), 110694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE_0_1_B4, 0x37), 110794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE2_B0, 0xbd), 110894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE2_B1, 0xf9), 110994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE2_B2, 0xbf), 111094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE2_B3, 0xce), 111194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE2_B4, 0x62), 111294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE3_B0, 0xbf), 111394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE3_B1, 0x7d), 111494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE3_B2, 0xbf), 111594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE3_B3, 0xcf), 111694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE3_B4, 0xd6), 111794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_PHPRE_CTRL, 0xa0), 111894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_DFE_CTLE_POST_CAL_OFFSET, 0x38), 111994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_MARG_COARSE_CTRL2, 0x12), 112094a407ccSDmitry Baryshkov }; 112194a407ccSDmitry Baryshkov 112294a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sdx55_qmp_pcie_pcs_tbl[] = { 112394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_20_PCS_RX_SIGDET_LVL, 0x77), 112494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_20_PCS_EQ_CONFIG2, 0x01), 112594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_20_PCS_EQ_CONFIG4, 0x16), 112694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_20_PCS_EQ_CONFIG5, 0x02), 112794a407ccSDmitry Baryshkov }; 112894a407ccSDmitry Baryshkov 112994a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sdx55_qmp_pcie_pcs_misc_tbl[] = { 113094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_20_PCS_PCIE_EQ_CONFIG1, 0x17), 113194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_20_PCS_PCIE_G3_RXEQEVAL_TIME, 0x13), 113294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_20_PCS_PCIE_G4_RXEQEVAL_TIME, 0x13), 113394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_20_PCS_PCIE_G4_EQ_CONFIG2, 0x01), 113494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_20_PCS_PCIE_G4_EQ_CONFIG5, 0x02), 113594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_20_PCS_LANE1_INSIG_SW_CTRL2, 0x00), 113694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_20_PCS_LANE1_INSIG_MX_CTRL2, 0x00), 113794a407ccSDmitry Baryshkov }; 113894a407ccSDmitry Baryshkov 113994a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8450_qmp_gen3x1_pcie_serdes_tbl[] = { 114094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_SYSCLK_EN_SEL, 0x08), 114194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_CLK_SELECT, 0x34), 114294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_CORECLK_DIV_MODE1, 0x08), 114394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_IVCO, 0x0f), 114494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP_EN, 0x42), 114594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_VCO_TUNE1_MODE0, 0x24), 114694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_VCO_TUNE2_MODE1, 0x03), 114794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_VCO_TUNE1_MODE1, 0xb4), 114894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_VCO_TUNE_MAP, 0x02), 114994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_BIN_VCOCAL_HSCLK_SEL, 0x11), 115094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_DEC_START_MODE0, 0x82), 115194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START3_MODE0, 0x03), 115294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START2_MODE0, 0x55), 115394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START1_MODE0, 0x55), 115494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP2_MODE0, 0x1a), 115594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP1_MODE0, 0x0a), 115694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_DEC_START_MODE1, 0x68), 115794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START3_MODE1, 0x02), 115894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START2_MODE1, 0xaa), 115994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START1_MODE1, 0xab), 116094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP2_MODE1, 0x34), 116194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP1_MODE1, 0x14), 116294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_HSCLK_SEL, 0x01), 116394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_CP_CTRL_MODE0, 0x06), 116494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_RCTRL_MODE0, 0x16), 116594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_CCTRL_MODE0, 0x36), 116694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_CP_CTRL_MODE1, 0x06), 116794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_RCTRL_MODE1, 0x16), 116894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_CCTRL_MODE1, 0x36), 116994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_BIN_VCOCAL_CMP_CODE2_MODE0, 0x1e), 117094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_BIN_VCOCAL_CMP_CODE1_MODE0, 0xca), 117194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_BIN_VCOCAL_CMP_CODE2_MODE1, 0x18), 117294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_BIN_VCOCAL_CMP_CODE1_MODE1, 0xa2), 117394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_SYSCLK_BUF_ENABLE, 0x07), 117494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_EN_CENTER, 0x01), 117594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_PER1, 0x31), 117694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_PER2, 0x01), 117794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_STEP_SIZE1_MODE0, 0xde), 117894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_STEP_SIZE2_MODE0, 0x07), 117994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_STEP_SIZE1_MODE1, 0x4c), 118094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_STEP_SIZE2_MODE1, 0x06), 118194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_CLK_ENABLE1, 0x90), 118294a407ccSDmitry Baryshkov }; 118394a407ccSDmitry Baryshkov 118494a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8450_qmp_gen3x1_pcie_tx_tbl[] = { 118594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_TX_PI_QEC_CTRL, 0x20), 118694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_TX_LANE_MODE_1, 0x75), 118794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_TX_LANE_MODE_4, 0x3f), 118894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_TX_RES_CODE_LANE_OFFSET_TX, 0x16), 118994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_TX_RES_CODE_LANE_OFFSET_RX, 0x04), 119094a407ccSDmitry Baryshkov }; 119194a407ccSDmitry Baryshkov 119294a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8450_qmp_gen3x1_pcie_rx_tbl[] = { 119394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_00_LOW, 0x7f), 119494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_00_HIGH, 0xff), 119594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_00_HIGH2, 0xbf), 119694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_00_HIGH3, 0x3f), 119794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_00_HIGH4, 0xd8), 119894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_01_LOW, 0xdc), 119994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_01_HIGH, 0xdc), 120094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_01_HIGH2, 0x5c), 120194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_01_HIGH3, 0x34), 120294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_01_HIGH4, 0xa6), 120394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_10_HIGH3, 0x34), 120494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_10_HIGH4, 0x38), 120594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_RX_VGA_CAL_CNTRL2, 0x07), 120694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_RX_GM_CAL, 0x00), 120794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_RX_UCDR_SB2_THRESH1, 0x08), 120894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_RX_UCDR_SB2_THRESH2, 0x08), 120994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_RX_UCDR_PI_CONTROLS, 0xf0), 121094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_RX_DFE_CTLE_POST_CAL_OFFSET, 0x38), 121194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_RX_TX_ADAPT_POST_THRESH, 0xf0), 121294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_EQU_ADAPTOR_CNTRL4, 0x07), 121394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_RX_UCDR_FO_GAIN, 0x09), 121494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_RX_UCDR_SO_GAIN, 0x05), 121594a407ccSDmitry Baryshkov }; 121694a407ccSDmitry Baryshkov 121794a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8450_qmp_gen3x1_pcie_pcs_tbl[] = { 121894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V5_PCS_RX_SIGDET_LVL, 0x77), 121994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V5_PCS_RATE_SLEW_CNTRL1, 0x0b), 122094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V5_PCS_REFGEN_REQ_CONFIG1, 0x05), 122194a407ccSDmitry Baryshkov }; 122294a407ccSDmitry Baryshkov 122394a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8450_qmp_gen3x1_pcie_pcs_misc_tbl[] = { 122494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V5_PCS_PCIE_OSC_DTCT_ACTIONS, 0x00), 122594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V5_PCS_PCIE_INT_AUX_CLK_CONFIG1, 0x00), 122694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V5_PCS_PCIE_EQ_CONFIG2, 0x0f), 122794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V5_PCS_PCIE_ENDPOINT_REFCLK_DRIVE, 0xc1), 122894a407ccSDmitry Baryshkov }; 122994a407ccSDmitry Baryshkov 123094a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8450_qmp_gen4x2_pcie_serdes_tbl[] = { 123194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_PER1, 0x31), 123294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_PER2, 0x01), 123394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_STEP_SIZE1_MODE0, 0xde), 123494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_STEP_SIZE2_MODE0, 0x07), 123594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_STEP_SIZE1_MODE1, 0x97), 123694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_STEP_SIZE2_MODE1, 0x0c), 123794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_BIAS_EN_CLKBUFLR_EN, 0x14), 123894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_CLK_ENABLE1, 0x90), 123994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_IVCO, 0x0f), 124094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_CP_CTRL_MODE0, 0x06), 124194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_CP_CTRL_MODE1, 0x06), 124294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_RCTRL_MODE0, 0x16), 124394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_RCTRL_MODE1, 0x16), 124494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_CCTRL_MODE0, 0x36), 124594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_CCTRL_MODE1, 0x36), 124694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_SYSCLK_EN_SEL, 0x08), 124794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP_EN, 0x46), 124894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP_CFG, 0x04), 124994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP1_MODE0, 0x0a), 125094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP2_MODE0, 0x1a), 125194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP1_MODE1, 0x14), 125294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP2_MODE1, 0x34), 125394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_DEC_START_MODE0, 0x82), 125494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_DEC_START_MODE1, 0xd0), 125594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START1_MODE0, 0x55), 125694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START2_MODE0, 0x55), 125794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START3_MODE0, 0x03), 125894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START1_MODE1, 0x55), 125994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START2_MODE1, 0x55), 126094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START3_MODE1, 0x05), 126194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_VCO_TUNE_MAP, 0x02), 126294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_CLK_SELECT, 0x34), 126394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_HSCLK_SEL, 0x12), 126494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_HSCLK_HS_SWITCH_SEL, 0x00), 126594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_CORECLK_DIV_MODE0, 0x0a), 126694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_CORECLK_DIV_MODE1, 0x04), 126794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_CMN_MISC1, 0x88), 126894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_CORE_CLK_EN, 0x20), 126994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_CMN_CONFIG, 0x06), 127094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_CMN_MODE, 0x14), 127194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_VCO_DC_LEVEL_CTRL, 0x0f), 127294a407ccSDmitry Baryshkov }; 127394a407ccSDmitry Baryshkov 127494a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8450_qmp_gen4x2_pcie_tx_tbl[] = { 127594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_TX_LANE_MODE_1, 0x05), 127694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_TX_LANE_MODE_2, 0xf6), 127794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_TX_RES_CODE_LANE_OFFSET_TX, 0x1a), 127894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_TX_RES_CODE_LANE_OFFSET_RX, 0x0c), 127994a407ccSDmitry Baryshkov }; 128094a407ccSDmitry Baryshkov 128194a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8450_qmp_gen4x2_pcie_rx_tbl[] = { 128294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_UCDR_PI_CONTROLS, 0x16), 128394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_DFE_CTLE_POST_CAL_OFFSET, 0x38), 128494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE_0_1_B1, 0xcc), 128594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE_0_1_B2, 0x12), 128694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE_0_1_B3, 0xcc), 128794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE_0_1_B5, 0x4a), 128894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE_0_1_B6, 0x29), 128994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE2_B0, 0xc5), 129094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE2_B1, 0xad), 129194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE2_B2, 0xb6), 129294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE2_B3, 0xc0), 129394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE2_B4, 0x1f), 129494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE2_B5, 0xfb), 129594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE2_B6, 0x0f), 129694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE3_B0, 0xc7), 129794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE3_B1, 0xef), 129894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE3_B2, 0xbf), 129994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE3_B3, 0xa0), 130094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE3_B4, 0x81), 130194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE3_B5, 0xde), 130294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE3_B6, 0x7f), 130394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_PHPRE_CTRL, 0x20), 130494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_AUX_DATA_THRESH_BIN_RATE_0_1, 0x3f), 130594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_AUX_DATA_THRESH_BIN_RATE_2_3, 0x37), 130694a407ccSDmitry Baryshkov 130794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_DFE_3, 0x05), 130894a407ccSDmitry Baryshkov 130994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MARG_COARSE_THRESH1_RATE3, 0x1f), 131094a407ccSDmitry Baryshkov 131194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MARG_COARSE_THRESH2_RATE3, 0x1f), 131294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MARG_COARSE_THRESH3_RATE3, 0x1f), 131394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MARG_COARSE_THRESH4_RATE3, 0x1f), 131494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MARG_COARSE_THRESH5_RATE3, 0x1f), 131594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MARG_COARSE_THRESH6_RATE3, 0x1f), 131694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MARG_COARSE_THRESH1_RATE210, 0x1f), 131794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MARG_COARSE_THRESH2_RATE210, 0x1f), 131894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MARG_COARSE_THRESH3_RATE210, 0x1f), 131994a407ccSDmitry Baryshkov 132094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_UCDR_FO_GAIN_RATE2, 0x0c), 132194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_UCDR_FO_GAIN_RATE3, 0x0a), 132294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_VGA_CAL_MAN_VAL, 0x0a), 132394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_EQU_ADAPTOR_CNTRL4, 0x0b), 132494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_IDAC_SAOFFSET, 0x10), 132594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_DFE_DAC_ENABLE1, 0x00), 132694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_GM_CAL, 0x0f), 132794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_TX_ADAPT_POST_THRESH1, 0x00), 132894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_TX_ADAPT_POST_THRESH2, 0x1f), 132994a407ccSDmitry Baryshkov }; 133094a407ccSDmitry Baryshkov 133194a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8450_qmp_gen4x2_pcie_pcs_tbl[] = { 133294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V5_PCS_EQ_CONFIG2, 0x16), 133394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V5_PCS_EQ_CONFIG3, 0x22), 133494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V5_PCS_G3S2_PRE_GAIN, 0x2e), 133594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V5_PCS_RX_SIGDET_LVL, 0x99), 133694a407ccSDmitry Baryshkov }; 133794a407ccSDmitry Baryshkov 133894a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8450_qmp_gen4x2_pcie_pcs_misc_tbl[] = { 133994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V5_20_PCS_PCIE_ENDPOINT_REFCLK_DRIVE, 0xc1), 134094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V5_20_PCS_PCIE_OSC_DTCT_ACTIONS, 0x00), 134194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V5_20_PCS_PCIE_G4_EQ_CONFIG5, 0x02), 134294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V5_20_PCS_PCIE_EQ_CONFIG1, 0x16), 134394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V5_20_PCS_PCIE_RX_MARGINING_CONFIG3, 0x28), 134494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V5_20_PCS_PCIE_G4_PRE_GAIN, 0x2e), 134594a407ccSDmitry Baryshkov }; 134694a407ccSDmitry Baryshkov 134794a407ccSDmitry Baryshkov struct qmp_phy; 134894a407ccSDmitry Baryshkov 134994a407ccSDmitry Baryshkov /* struct qmp_phy_cfg - per-PHY initialization config */ 135094a407ccSDmitry Baryshkov struct qmp_phy_cfg { 135194a407ccSDmitry Baryshkov /* phy-type - PCIE/UFS/USB */ 135294a407ccSDmitry Baryshkov unsigned int type; 135394a407ccSDmitry Baryshkov /* number of lanes provided by phy */ 135494a407ccSDmitry Baryshkov int nlanes; 135594a407ccSDmitry Baryshkov 135694a407ccSDmitry Baryshkov /* Init sequence for PHY blocks - serdes, tx, rx, pcs */ 135794a407ccSDmitry Baryshkov const struct qmp_phy_init_tbl *serdes_tbl; 135894a407ccSDmitry Baryshkov int serdes_tbl_num; 135994a407ccSDmitry Baryshkov const struct qmp_phy_init_tbl *serdes_tbl_sec; 136094a407ccSDmitry Baryshkov int serdes_tbl_num_sec; 136194a407ccSDmitry Baryshkov const struct qmp_phy_init_tbl *tx_tbl; 136294a407ccSDmitry Baryshkov int tx_tbl_num; 136394a407ccSDmitry Baryshkov const struct qmp_phy_init_tbl *tx_tbl_sec; 136494a407ccSDmitry Baryshkov int tx_tbl_num_sec; 136594a407ccSDmitry Baryshkov const struct qmp_phy_init_tbl *rx_tbl; 136694a407ccSDmitry Baryshkov int rx_tbl_num; 136794a407ccSDmitry Baryshkov const struct qmp_phy_init_tbl *rx_tbl_sec; 136894a407ccSDmitry Baryshkov int rx_tbl_num_sec; 136994a407ccSDmitry Baryshkov const struct qmp_phy_init_tbl *pcs_tbl; 137094a407ccSDmitry Baryshkov int pcs_tbl_num; 137194a407ccSDmitry Baryshkov const struct qmp_phy_init_tbl *pcs_tbl_sec; 137294a407ccSDmitry Baryshkov int pcs_tbl_num_sec; 137394a407ccSDmitry Baryshkov const struct qmp_phy_init_tbl *pcs_misc_tbl; 137494a407ccSDmitry Baryshkov int pcs_misc_tbl_num; 137594a407ccSDmitry Baryshkov const struct qmp_phy_init_tbl *pcs_misc_tbl_sec; 137694a407ccSDmitry Baryshkov int pcs_misc_tbl_num_sec; 137794a407ccSDmitry Baryshkov 137894a407ccSDmitry Baryshkov /* clock ids to be requested */ 137994a407ccSDmitry Baryshkov const char * const *clk_list; 138094a407ccSDmitry Baryshkov int num_clks; 138194a407ccSDmitry Baryshkov /* resets to be requested */ 138294a407ccSDmitry Baryshkov const char * const *reset_list; 138394a407ccSDmitry Baryshkov int num_resets; 138494a407ccSDmitry Baryshkov /* regulators to be requested */ 138594a407ccSDmitry Baryshkov const char * const *vreg_list; 138694a407ccSDmitry Baryshkov int num_vregs; 138794a407ccSDmitry Baryshkov 138894a407ccSDmitry Baryshkov /* array of registers with different offsets */ 138994a407ccSDmitry Baryshkov const unsigned int *regs; 139094a407ccSDmitry Baryshkov 139194a407ccSDmitry Baryshkov unsigned int start_ctrl; 139294a407ccSDmitry Baryshkov unsigned int pwrdn_ctrl; 139394a407ccSDmitry Baryshkov unsigned int mask_com_pcs_ready; 139494a407ccSDmitry Baryshkov /* bit offset of PHYSTATUS in QPHY_PCS_STATUS register */ 139594a407ccSDmitry Baryshkov unsigned int phy_status; 139694a407ccSDmitry Baryshkov 139794a407ccSDmitry Baryshkov /* true, if PHY needs delay after POWER_DOWN */ 139894a407ccSDmitry Baryshkov bool has_pwrdn_delay; 139994a407ccSDmitry Baryshkov /* power_down delay in usec */ 140094a407ccSDmitry Baryshkov int pwrdn_delay_min; 140194a407ccSDmitry Baryshkov int pwrdn_delay_max; 140294a407ccSDmitry Baryshkov 140394a407ccSDmitry Baryshkov /* true, if PHY has secondary tx/rx lanes to be configured */ 140494a407ccSDmitry Baryshkov bool is_dual_lane_phy; 14052ec9bc8dSRobert Marko 14062ec9bc8dSRobert Marko /* QMP PHY pipe clock interface rate */ 14072ec9bc8dSRobert Marko unsigned long pipe_clock_rate; 140894a407ccSDmitry Baryshkov }; 140994a407ccSDmitry Baryshkov 141094a407ccSDmitry Baryshkov /** 141194a407ccSDmitry Baryshkov * struct qmp_phy - per-lane phy descriptor 141294a407ccSDmitry Baryshkov * 141394a407ccSDmitry Baryshkov * @phy: generic phy 141494a407ccSDmitry Baryshkov * @cfg: phy specific configuration 141594a407ccSDmitry Baryshkov * @serdes: iomapped memory space for phy's serdes (i.e. PLL) 141694a407ccSDmitry Baryshkov * @tx: iomapped memory space for lane's tx 141794a407ccSDmitry Baryshkov * @rx: iomapped memory space for lane's rx 141894a407ccSDmitry Baryshkov * @pcs: iomapped memory space for lane's pcs 141994a407ccSDmitry Baryshkov * @tx2: iomapped memory space for second lane's tx (in dual lane PHYs) 142094a407ccSDmitry Baryshkov * @rx2: iomapped memory space for second lane's rx (in dual lane PHYs) 142194a407ccSDmitry Baryshkov * @pcs_misc: iomapped memory space for lane's pcs_misc 142294a407ccSDmitry Baryshkov * @pipe_clk: pipe clock 142394a407ccSDmitry Baryshkov * @index: lane index 142494a407ccSDmitry Baryshkov * @qmp: QMP phy to which this lane belongs 142594a407ccSDmitry Baryshkov * @mode: current PHY mode 142694a407ccSDmitry Baryshkov */ 142794a407ccSDmitry Baryshkov struct qmp_phy { 142894a407ccSDmitry Baryshkov struct phy *phy; 142994a407ccSDmitry Baryshkov const struct qmp_phy_cfg *cfg; 143094a407ccSDmitry Baryshkov void __iomem *serdes; 143194a407ccSDmitry Baryshkov void __iomem *tx; 143294a407ccSDmitry Baryshkov void __iomem *rx; 143394a407ccSDmitry Baryshkov void __iomem *pcs; 143494a407ccSDmitry Baryshkov void __iomem *tx2; 143594a407ccSDmitry Baryshkov void __iomem *rx2; 143694a407ccSDmitry Baryshkov void __iomem *pcs_misc; 143794a407ccSDmitry Baryshkov struct clk *pipe_clk; 143894a407ccSDmitry Baryshkov unsigned int index; 143994a407ccSDmitry Baryshkov struct qcom_qmp *qmp; 144094a407ccSDmitry Baryshkov enum phy_mode mode; 144194a407ccSDmitry Baryshkov }; 144294a407ccSDmitry Baryshkov 144394a407ccSDmitry Baryshkov /** 144494a407ccSDmitry Baryshkov * struct qcom_qmp - structure holding QMP phy block attributes 144594a407ccSDmitry Baryshkov * 144694a407ccSDmitry Baryshkov * @dev: device 144794a407ccSDmitry Baryshkov * 144894a407ccSDmitry Baryshkov * @clks: array of clocks required by phy 144994a407ccSDmitry Baryshkov * @resets: array of resets required by phy 145094a407ccSDmitry Baryshkov * @vregs: regulator supplies bulk data 145194a407ccSDmitry Baryshkov * 145294a407ccSDmitry Baryshkov * @phys: array of per-lane phy descriptors 145394a407ccSDmitry Baryshkov */ 145494a407ccSDmitry Baryshkov struct qcom_qmp { 145594a407ccSDmitry Baryshkov struct device *dev; 145694a407ccSDmitry Baryshkov 145794a407ccSDmitry Baryshkov struct clk_bulk_data *clks; 1458189ac6b8SDmitry Baryshkov struct reset_control_bulk_data *resets; 145994a407ccSDmitry Baryshkov struct regulator_bulk_data *vregs; 146094a407ccSDmitry Baryshkov 146194a407ccSDmitry Baryshkov struct qmp_phy **phys; 146294a407ccSDmitry Baryshkov }; 146394a407ccSDmitry Baryshkov 146494a407ccSDmitry Baryshkov static inline void qphy_setbits(void __iomem *base, u32 offset, u32 val) 146594a407ccSDmitry Baryshkov { 146694a407ccSDmitry Baryshkov u32 reg; 146794a407ccSDmitry Baryshkov 146894a407ccSDmitry Baryshkov reg = readl(base + offset); 146994a407ccSDmitry Baryshkov reg |= val; 147094a407ccSDmitry Baryshkov writel(reg, base + offset); 147194a407ccSDmitry Baryshkov 147294a407ccSDmitry Baryshkov /* ensure that above write is through */ 147394a407ccSDmitry Baryshkov readl(base + offset); 147494a407ccSDmitry Baryshkov } 147594a407ccSDmitry Baryshkov 147694a407ccSDmitry Baryshkov static inline void qphy_clrbits(void __iomem *base, u32 offset, u32 val) 147794a407ccSDmitry Baryshkov { 147894a407ccSDmitry Baryshkov u32 reg; 147994a407ccSDmitry Baryshkov 148094a407ccSDmitry Baryshkov reg = readl(base + offset); 148194a407ccSDmitry Baryshkov reg &= ~val; 148294a407ccSDmitry Baryshkov writel(reg, base + offset); 148394a407ccSDmitry Baryshkov 148494a407ccSDmitry Baryshkov /* ensure that above write is through */ 148594a407ccSDmitry Baryshkov readl(base + offset); 148694a407ccSDmitry Baryshkov } 148794a407ccSDmitry Baryshkov 148894a407ccSDmitry Baryshkov /* list of clocks required by phy */ 148994a407ccSDmitry Baryshkov static const char * const msm8996_phy_clk_l[] = { 149094a407ccSDmitry Baryshkov "aux", "cfg_ahb", "ref", 149194a407ccSDmitry Baryshkov }; 149294a407ccSDmitry Baryshkov 149394a407ccSDmitry Baryshkov 149494a407ccSDmitry Baryshkov static const char * const sdm845_pciephy_clk_l[] = { 149594a407ccSDmitry Baryshkov "aux", "cfg_ahb", "ref", "refgen", 149694a407ccSDmitry Baryshkov }; 149794a407ccSDmitry Baryshkov 149894a407ccSDmitry Baryshkov /* list of regulators */ 149994a407ccSDmitry Baryshkov static const char * const qmp_phy_vreg_l[] = { 150094a407ccSDmitry Baryshkov "vdda-phy", "vdda-pll", 150194a407ccSDmitry Baryshkov }; 150294a407ccSDmitry Baryshkov 150394a407ccSDmitry Baryshkov static const char * const ipq8074_pciephy_clk_l[] = { 150494a407ccSDmitry Baryshkov "aux", "cfg_ahb", 150594a407ccSDmitry Baryshkov }; 1506b35a5311SDmitry Baryshkov 150794a407ccSDmitry Baryshkov /* list of resets */ 150894a407ccSDmitry Baryshkov static const char * const ipq8074_pciephy_reset_l[] = { 150994a407ccSDmitry Baryshkov "phy", "common", 151094a407ccSDmitry Baryshkov }; 151194a407ccSDmitry Baryshkov 1512b35a5311SDmitry Baryshkov static const char * const sdm845_pciephy_reset_l[] = { 1513b35a5311SDmitry Baryshkov "phy", 1514b35a5311SDmitry Baryshkov }; 1515b35a5311SDmitry Baryshkov 151694a407ccSDmitry Baryshkov static const struct qmp_phy_cfg ipq8074_pciephy_cfg = { 151794a407ccSDmitry Baryshkov .type = PHY_TYPE_PCIE, 151894a407ccSDmitry Baryshkov .nlanes = 1, 151994a407ccSDmitry Baryshkov 152094a407ccSDmitry Baryshkov .serdes_tbl = ipq8074_pcie_serdes_tbl, 152194a407ccSDmitry Baryshkov .serdes_tbl_num = ARRAY_SIZE(ipq8074_pcie_serdes_tbl), 152294a407ccSDmitry Baryshkov .tx_tbl = ipq8074_pcie_tx_tbl, 152394a407ccSDmitry Baryshkov .tx_tbl_num = ARRAY_SIZE(ipq8074_pcie_tx_tbl), 152494a407ccSDmitry Baryshkov .rx_tbl = ipq8074_pcie_rx_tbl, 152594a407ccSDmitry Baryshkov .rx_tbl_num = ARRAY_SIZE(ipq8074_pcie_rx_tbl), 152694a407ccSDmitry Baryshkov .pcs_tbl = ipq8074_pcie_pcs_tbl, 152794a407ccSDmitry Baryshkov .pcs_tbl_num = ARRAY_SIZE(ipq8074_pcie_pcs_tbl), 152894a407ccSDmitry Baryshkov .clk_list = ipq8074_pciephy_clk_l, 152994a407ccSDmitry Baryshkov .num_clks = ARRAY_SIZE(ipq8074_pciephy_clk_l), 153094a407ccSDmitry Baryshkov .reset_list = ipq8074_pciephy_reset_l, 153194a407ccSDmitry Baryshkov .num_resets = ARRAY_SIZE(ipq8074_pciephy_reset_l), 153294a407ccSDmitry Baryshkov .vreg_list = NULL, 153394a407ccSDmitry Baryshkov .num_vregs = 0, 153494a407ccSDmitry Baryshkov .regs = pciephy_regs_layout, 153594a407ccSDmitry Baryshkov 153694a407ccSDmitry Baryshkov .start_ctrl = SERDES_START | PCS_START, 153794a407ccSDmitry Baryshkov .pwrdn_ctrl = SW_PWRDN | REFCLK_DRV_DSBL, 153894a407ccSDmitry Baryshkov .phy_status = PHYSTATUS, 153994a407ccSDmitry Baryshkov 154094a407ccSDmitry Baryshkov .has_pwrdn_delay = true, 154194a407ccSDmitry Baryshkov .pwrdn_delay_min = 995, /* us */ 154294a407ccSDmitry Baryshkov .pwrdn_delay_max = 1005, /* us */ 154394a407ccSDmitry Baryshkov }; 154494a407ccSDmitry Baryshkov 1545334fad18SRobert Marko static const struct qmp_phy_cfg ipq8074_pciephy_gen3_cfg = { 1546334fad18SRobert Marko .type = PHY_TYPE_PCIE, 1547334fad18SRobert Marko .nlanes = 1, 1548334fad18SRobert Marko 1549334fad18SRobert Marko .serdes_tbl = ipq8074_pcie_gen3_serdes_tbl, 1550334fad18SRobert Marko .serdes_tbl_num = ARRAY_SIZE(ipq8074_pcie_gen3_serdes_tbl), 1551334fad18SRobert Marko .tx_tbl = ipq8074_pcie_gen3_tx_tbl, 1552334fad18SRobert Marko .tx_tbl_num = ARRAY_SIZE(ipq8074_pcie_gen3_tx_tbl), 1553334fad18SRobert Marko .rx_tbl = ipq8074_pcie_gen3_rx_tbl, 1554334fad18SRobert Marko .rx_tbl_num = ARRAY_SIZE(ipq8074_pcie_gen3_rx_tbl), 1555334fad18SRobert Marko .pcs_tbl = ipq8074_pcie_gen3_pcs_tbl, 1556334fad18SRobert Marko .pcs_tbl_num = ARRAY_SIZE(ipq8074_pcie_gen3_pcs_tbl), 1557334fad18SRobert Marko .clk_list = ipq8074_pciephy_clk_l, 1558334fad18SRobert Marko .num_clks = ARRAY_SIZE(ipq8074_pciephy_clk_l), 1559334fad18SRobert Marko .reset_list = ipq8074_pciephy_reset_l, 1560334fad18SRobert Marko .num_resets = ARRAY_SIZE(ipq8074_pciephy_reset_l), 1561334fad18SRobert Marko .vreg_list = NULL, 1562334fad18SRobert Marko .num_vregs = 0, 1563334fad18SRobert Marko .regs = ipq_pciephy_gen3_regs_layout, 1564334fad18SRobert Marko 1565334fad18SRobert Marko .start_ctrl = SERDES_START | PCS_START, 1566334fad18SRobert Marko .pwrdn_ctrl = SW_PWRDN | REFCLK_DRV_DSBL, 1567334fad18SRobert Marko 1568334fad18SRobert Marko .has_pwrdn_delay = true, 1569334fad18SRobert Marko .pwrdn_delay_min = 995, /* us */ 1570334fad18SRobert Marko .pwrdn_delay_max = 1005, /* us */ 1571334fad18SRobert Marko 1572334fad18SRobert Marko .pipe_clock_rate = 250000000, 1573334fad18SRobert Marko }; 1574334fad18SRobert Marko 157594a407ccSDmitry Baryshkov static const struct qmp_phy_cfg ipq6018_pciephy_cfg = { 157694a407ccSDmitry Baryshkov .type = PHY_TYPE_PCIE, 157794a407ccSDmitry Baryshkov .nlanes = 1, 157894a407ccSDmitry Baryshkov 157994a407ccSDmitry Baryshkov .serdes_tbl = ipq6018_pcie_serdes_tbl, 158094a407ccSDmitry Baryshkov .serdes_tbl_num = ARRAY_SIZE(ipq6018_pcie_serdes_tbl), 158194a407ccSDmitry Baryshkov .tx_tbl = ipq6018_pcie_tx_tbl, 158294a407ccSDmitry Baryshkov .tx_tbl_num = ARRAY_SIZE(ipq6018_pcie_tx_tbl), 158394a407ccSDmitry Baryshkov .rx_tbl = ipq6018_pcie_rx_tbl, 158494a407ccSDmitry Baryshkov .rx_tbl_num = ARRAY_SIZE(ipq6018_pcie_rx_tbl), 158594a407ccSDmitry Baryshkov .pcs_tbl = ipq6018_pcie_pcs_tbl, 158694a407ccSDmitry Baryshkov .pcs_tbl_num = ARRAY_SIZE(ipq6018_pcie_pcs_tbl), 1587af664324SDmitry Baryshkov .pcs_misc_tbl = ipq6018_pcie_pcs_misc_tbl, 1588af664324SDmitry Baryshkov .pcs_misc_tbl_num = ARRAY_SIZE(ipq6018_pcie_pcs_misc_tbl), 158994a407ccSDmitry Baryshkov .clk_list = ipq8074_pciephy_clk_l, 159094a407ccSDmitry Baryshkov .num_clks = ARRAY_SIZE(ipq8074_pciephy_clk_l), 159194a407ccSDmitry Baryshkov .reset_list = ipq8074_pciephy_reset_l, 159294a407ccSDmitry Baryshkov .num_resets = ARRAY_SIZE(ipq8074_pciephy_reset_l), 159394a407ccSDmitry Baryshkov .vreg_list = NULL, 159494a407ccSDmitry Baryshkov .num_vregs = 0, 159594a407ccSDmitry Baryshkov .regs = ipq_pciephy_gen3_regs_layout, 159694a407ccSDmitry Baryshkov 159794a407ccSDmitry Baryshkov .start_ctrl = SERDES_START | PCS_START, 159894a407ccSDmitry Baryshkov .pwrdn_ctrl = SW_PWRDN | REFCLK_DRV_DSBL, 159994a407ccSDmitry Baryshkov 160094a407ccSDmitry Baryshkov .has_pwrdn_delay = true, 160194a407ccSDmitry Baryshkov .pwrdn_delay_min = 995, /* us */ 160294a407ccSDmitry Baryshkov .pwrdn_delay_max = 1005, /* us */ 160394a407ccSDmitry Baryshkov }; 160494a407ccSDmitry Baryshkov 160594a407ccSDmitry Baryshkov static const struct qmp_phy_cfg sdm845_qmp_pciephy_cfg = { 160694a407ccSDmitry Baryshkov .type = PHY_TYPE_PCIE, 160794a407ccSDmitry Baryshkov .nlanes = 1, 160894a407ccSDmitry Baryshkov 160994a407ccSDmitry Baryshkov .serdes_tbl = sdm845_qmp_pcie_serdes_tbl, 161094a407ccSDmitry Baryshkov .serdes_tbl_num = ARRAY_SIZE(sdm845_qmp_pcie_serdes_tbl), 161194a407ccSDmitry Baryshkov .tx_tbl = sdm845_qmp_pcie_tx_tbl, 161294a407ccSDmitry Baryshkov .tx_tbl_num = ARRAY_SIZE(sdm845_qmp_pcie_tx_tbl), 161394a407ccSDmitry Baryshkov .rx_tbl = sdm845_qmp_pcie_rx_tbl, 161494a407ccSDmitry Baryshkov .rx_tbl_num = ARRAY_SIZE(sdm845_qmp_pcie_rx_tbl), 161594a407ccSDmitry Baryshkov .pcs_tbl = sdm845_qmp_pcie_pcs_tbl, 161694a407ccSDmitry Baryshkov .pcs_tbl_num = ARRAY_SIZE(sdm845_qmp_pcie_pcs_tbl), 161794a407ccSDmitry Baryshkov .pcs_misc_tbl = sdm845_qmp_pcie_pcs_misc_tbl, 161894a407ccSDmitry Baryshkov .pcs_misc_tbl_num = ARRAY_SIZE(sdm845_qmp_pcie_pcs_misc_tbl), 161994a407ccSDmitry Baryshkov .clk_list = sdm845_pciephy_clk_l, 162094a407ccSDmitry Baryshkov .num_clks = ARRAY_SIZE(sdm845_pciephy_clk_l), 162194a407ccSDmitry Baryshkov .reset_list = sdm845_pciephy_reset_l, 162294a407ccSDmitry Baryshkov .num_resets = ARRAY_SIZE(sdm845_pciephy_reset_l), 162394a407ccSDmitry Baryshkov .vreg_list = qmp_phy_vreg_l, 162494a407ccSDmitry Baryshkov .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), 162594a407ccSDmitry Baryshkov .regs = sdm845_qmp_pciephy_regs_layout, 162694a407ccSDmitry Baryshkov 162794a407ccSDmitry Baryshkov .start_ctrl = PCS_START | SERDES_START, 162894a407ccSDmitry Baryshkov .pwrdn_ctrl = SW_PWRDN | REFCLK_DRV_DSBL, 162994a407ccSDmitry Baryshkov .phy_status = PHYSTATUS, 163094a407ccSDmitry Baryshkov 163194a407ccSDmitry Baryshkov .has_pwrdn_delay = true, 163294a407ccSDmitry Baryshkov .pwrdn_delay_min = 995, /* us */ 163394a407ccSDmitry Baryshkov .pwrdn_delay_max = 1005, /* us */ 163494a407ccSDmitry Baryshkov }; 163594a407ccSDmitry Baryshkov 163694a407ccSDmitry Baryshkov static const struct qmp_phy_cfg sdm845_qhp_pciephy_cfg = { 163794a407ccSDmitry Baryshkov .type = PHY_TYPE_PCIE, 163894a407ccSDmitry Baryshkov .nlanes = 1, 163994a407ccSDmitry Baryshkov 164094a407ccSDmitry Baryshkov .serdes_tbl = sdm845_qhp_pcie_serdes_tbl, 164194a407ccSDmitry Baryshkov .serdes_tbl_num = ARRAY_SIZE(sdm845_qhp_pcie_serdes_tbl), 164294a407ccSDmitry Baryshkov .tx_tbl = sdm845_qhp_pcie_tx_tbl, 164394a407ccSDmitry Baryshkov .tx_tbl_num = ARRAY_SIZE(sdm845_qhp_pcie_tx_tbl), 164494a407ccSDmitry Baryshkov .rx_tbl = sdm845_qhp_pcie_rx_tbl, 164594a407ccSDmitry Baryshkov .rx_tbl_num = ARRAY_SIZE(sdm845_qhp_pcie_rx_tbl), 164694a407ccSDmitry Baryshkov .pcs_tbl = sdm845_qhp_pcie_pcs_tbl, 164794a407ccSDmitry Baryshkov .pcs_tbl_num = ARRAY_SIZE(sdm845_qhp_pcie_pcs_tbl), 164894a407ccSDmitry Baryshkov .clk_list = sdm845_pciephy_clk_l, 164994a407ccSDmitry Baryshkov .num_clks = ARRAY_SIZE(sdm845_pciephy_clk_l), 165094a407ccSDmitry Baryshkov .reset_list = sdm845_pciephy_reset_l, 165194a407ccSDmitry Baryshkov .num_resets = ARRAY_SIZE(sdm845_pciephy_reset_l), 165294a407ccSDmitry Baryshkov .vreg_list = qmp_phy_vreg_l, 165394a407ccSDmitry Baryshkov .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), 165494a407ccSDmitry Baryshkov .regs = sdm845_qhp_pciephy_regs_layout, 165594a407ccSDmitry Baryshkov 165694a407ccSDmitry Baryshkov .start_ctrl = PCS_START | SERDES_START, 165794a407ccSDmitry Baryshkov .pwrdn_ctrl = SW_PWRDN | REFCLK_DRV_DSBL, 165894a407ccSDmitry Baryshkov .phy_status = PHYSTATUS, 165994a407ccSDmitry Baryshkov 166094a407ccSDmitry Baryshkov .has_pwrdn_delay = true, 166194a407ccSDmitry Baryshkov .pwrdn_delay_min = 995, /* us */ 166294a407ccSDmitry Baryshkov .pwrdn_delay_max = 1005, /* us */ 166394a407ccSDmitry Baryshkov }; 166494a407ccSDmitry Baryshkov 166594a407ccSDmitry Baryshkov static const struct qmp_phy_cfg sm8250_qmp_gen3x1_pciephy_cfg = { 166694a407ccSDmitry Baryshkov .type = PHY_TYPE_PCIE, 166794a407ccSDmitry Baryshkov .nlanes = 1, 166894a407ccSDmitry Baryshkov 166994a407ccSDmitry Baryshkov .serdes_tbl = sm8250_qmp_pcie_serdes_tbl, 167094a407ccSDmitry Baryshkov .serdes_tbl_num = ARRAY_SIZE(sm8250_qmp_pcie_serdes_tbl), 167194a407ccSDmitry Baryshkov .serdes_tbl_sec = sm8250_qmp_gen3x1_pcie_serdes_tbl, 167294a407ccSDmitry Baryshkov .serdes_tbl_num_sec = ARRAY_SIZE(sm8250_qmp_gen3x1_pcie_serdes_tbl), 167394a407ccSDmitry Baryshkov .tx_tbl = sm8250_qmp_pcie_tx_tbl, 167494a407ccSDmitry Baryshkov .tx_tbl_num = ARRAY_SIZE(sm8250_qmp_pcie_tx_tbl), 167594a407ccSDmitry Baryshkov .rx_tbl = sm8250_qmp_pcie_rx_tbl, 167694a407ccSDmitry Baryshkov .rx_tbl_num = ARRAY_SIZE(sm8250_qmp_pcie_rx_tbl), 167794a407ccSDmitry Baryshkov .rx_tbl_sec = sm8250_qmp_gen3x1_pcie_rx_tbl, 167894a407ccSDmitry Baryshkov .rx_tbl_num_sec = ARRAY_SIZE(sm8250_qmp_gen3x1_pcie_rx_tbl), 167994a407ccSDmitry Baryshkov .pcs_tbl = sm8250_qmp_pcie_pcs_tbl, 168094a407ccSDmitry Baryshkov .pcs_tbl_num = ARRAY_SIZE(sm8250_qmp_pcie_pcs_tbl), 168194a407ccSDmitry Baryshkov .pcs_tbl_sec = sm8250_qmp_gen3x1_pcie_pcs_tbl, 168294a407ccSDmitry Baryshkov .pcs_tbl_num_sec = ARRAY_SIZE(sm8250_qmp_gen3x1_pcie_pcs_tbl), 168394a407ccSDmitry Baryshkov .pcs_misc_tbl = sm8250_qmp_pcie_pcs_misc_tbl, 168494a407ccSDmitry Baryshkov .pcs_misc_tbl_num = ARRAY_SIZE(sm8250_qmp_pcie_pcs_misc_tbl), 168594a407ccSDmitry Baryshkov .pcs_misc_tbl_sec = sm8250_qmp_gen3x1_pcie_pcs_misc_tbl, 168694a407ccSDmitry Baryshkov .pcs_misc_tbl_num_sec = ARRAY_SIZE(sm8250_qmp_gen3x1_pcie_pcs_misc_tbl), 168794a407ccSDmitry Baryshkov .clk_list = sdm845_pciephy_clk_l, 168894a407ccSDmitry Baryshkov .num_clks = ARRAY_SIZE(sdm845_pciephy_clk_l), 168994a407ccSDmitry Baryshkov .reset_list = sdm845_pciephy_reset_l, 169094a407ccSDmitry Baryshkov .num_resets = ARRAY_SIZE(sdm845_pciephy_reset_l), 169194a407ccSDmitry Baryshkov .vreg_list = qmp_phy_vreg_l, 169294a407ccSDmitry Baryshkov .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), 169394a407ccSDmitry Baryshkov .regs = sm8250_pcie_regs_layout, 169494a407ccSDmitry Baryshkov 169594a407ccSDmitry Baryshkov .start_ctrl = PCS_START | SERDES_START, 169694a407ccSDmitry Baryshkov .pwrdn_ctrl = SW_PWRDN | REFCLK_DRV_DSBL, 169794a407ccSDmitry Baryshkov .phy_status = PHYSTATUS, 169894a407ccSDmitry Baryshkov 169994a407ccSDmitry Baryshkov .has_pwrdn_delay = true, 170094a407ccSDmitry Baryshkov .pwrdn_delay_min = 995, /* us */ 170194a407ccSDmitry Baryshkov .pwrdn_delay_max = 1005, /* us */ 170294a407ccSDmitry Baryshkov }; 170394a407ccSDmitry Baryshkov 170494a407ccSDmitry Baryshkov static const struct qmp_phy_cfg sm8250_qmp_gen3x2_pciephy_cfg = { 170594a407ccSDmitry Baryshkov .type = PHY_TYPE_PCIE, 170694a407ccSDmitry Baryshkov .nlanes = 2, 170794a407ccSDmitry Baryshkov 170894a407ccSDmitry Baryshkov .serdes_tbl = sm8250_qmp_pcie_serdes_tbl, 170994a407ccSDmitry Baryshkov .serdes_tbl_num = ARRAY_SIZE(sm8250_qmp_pcie_serdes_tbl), 171094a407ccSDmitry Baryshkov .tx_tbl = sm8250_qmp_pcie_tx_tbl, 171194a407ccSDmitry Baryshkov .tx_tbl_num = ARRAY_SIZE(sm8250_qmp_pcie_tx_tbl), 171294a407ccSDmitry Baryshkov .tx_tbl_sec = sm8250_qmp_gen3x2_pcie_tx_tbl, 171394a407ccSDmitry Baryshkov .tx_tbl_num_sec = ARRAY_SIZE(sm8250_qmp_gen3x2_pcie_tx_tbl), 171494a407ccSDmitry Baryshkov .rx_tbl = sm8250_qmp_pcie_rx_tbl, 171594a407ccSDmitry Baryshkov .rx_tbl_num = ARRAY_SIZE(sm8250_qmp_pcie_rx_tbl), 171694a407ccSDmitry Baryshkov .rx_tbl_sec = sm8250_qmp_gen3x2_pcie_rx_tbl, 171794a407ccSDmitry Baryshkov .rx_tbl_num_sec = ARRAY_SIZE(sm8250_qmp_gen3x2_pcie_rx_tbl), 171894a407ccSDmitry Baryshkov .pcs_tbl = sm8250_qmp_pcie_pcs_tbl, 171994a407ccSDmitry Baryshkov .pcs_tbl_num = ARRAY_SIZE(sm8250_qmp_pcie_pcs_tbl), 172094a407ccSDmitry Baryshkov .pcs_tbl_sec = sm8250_qmp_gen3x2_pcie_pcs_tbl, 172194a407ccSDmitry Baryshkov .pcs_tbl_num_sec = ARRAY_SIZE(sm8250_qmp_gen3x2_pcie_pcs_tbl), 172294a407ccSDmitry Baryshkov .pcs_misc_tbl = sm8250_qmp_pcie_pcs_misc_tbl, 172394a407ccSDmitry Baryshkov .pcs_misc_tbl_num = ARRAY_SIZE(sm8250_qmp_pcie_pcs_misc_tbl), 172494a407ccSDmitry Baryshkov .pcs_misc_tbl_sec = sm8250_qmp_gen3x2_pcie_pcs_misc_tbl, 172594a407ccSDmitry Baryshkov .pcs_misc_tbl_num_sec = ARRAY_SIZE(sm8250_qmp_gen3x2_pcie_pcs_misc_tbl), 172694a407ccSDmitry Baryshkov .clk_list = sdm845_pciephy_clk_l, 172794a407ccSDmitry Baryshkov .num_clks = ARRAY_SIZE(sdm845_pciephy_clk_l), 172894a407ccSDmitry Baryshkov .reset_list = sdm845_pciephy_reset_l, 172994a407ccSDmitry Baryshkov .num_resets = ARRAY_SIZE(sdm845_pciephy_reset_l), 173094a407ccSDmitry Baryshkov .vreg_list = qmp_phy_vreg_l, 173194a407ccSDmitry Baryshkov .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), 173294a407ccSDmitry Baryshkov .regs = sm8250_pcie_regs_layout, 173394a407ccSDmitry Baryshkov 173494a407ccSDmitry Baryshkov .start_ctrl = PCS_START | SERDES_START, 173594a407ccSDmitry Baryshkov .pwrdn_ctrl = SW_PWRDN | REFCLK_DRV_DSBL, 173694a407ccSDmitry Baryshkov .phy_status = PHYSTATUS, 173794a407ccSDmitry Baryshkov 173894a407ccSDmitry Baryshkov .is_dual_lane_phy = true, 173994a407ccSDmitry Baryshkov .has_pwrdn_delay = true, 174094a407ccSDmitry Baryshkov .pwrdn_delay_min = 995, /* us */ 174194a407ccSDmitry Baryshkov .pwrdn_delay_max = 1005, /* us */ 174294a407ccSDmitry Baryshkov }; 174394a407ccSDmitry Baryshkov 174494a407ccSDmitry Baryshkov static const struct qmp_phy_cfg msm8998_pciephy_cfg = { 174594a407ccSDmitry Baryshkov .type = PHY_TYPE_PCIE, 174694a407ccSDmitry Baryshkov .nlanes = 1, 174794a407ccSDmitry Baryshkov 174894a407ccSDmitry Baryshkov .serdes_tbl = msm8998_pcie_serdes_tbl, 174994a407ccSDmitry Baryshkov .serdes_tbl_num = ARRAY_SIZE(msm8998_pcie_serdes_tbl), 175094a407ccSDmitry Baryshkov .tx_tbl = msm8998_pcie_tx_tbl, 175194a407ccSDmitry Baryshkov .tx_tbl_num = ARRAY_SIZE(msm8998_pcie_tx_tbl), 175294a407ccSDmitry Baryshkov .rx_tbl = msm8998_pcie_rx_tbl, 175394a407ccSDmitry Baryshkov .rx_tbl_num = ARRAY_SIZE(msm8998_pcie_rx_tbl), 175494a407ccSDmitry Baryshkov .pcs_tbl = msm8998_pcie_pcs_tbl, 175594a407ccSDmitry Baryshkov .pcs_tbl_num = ARRAY_SIZE(msm8998_pcie_pcs_tbl), 175694a407ccSDmitry Baryshkov .clk_list = msm8996_phy_clk_l, 175794a407ccSDmitry Baryshkov .num_clks = ARRAY_SIZE(msm8996_phy_clk_l), 175894a407ccSDmitry Baryshkov .reset_list = ipq8074_pciephy_reset_l, 175994a407ccSDmitry Baryshkov .num_resets = ARRAY_SIZE(ipq8074_pciephy_reset_l), 176094a407ccSDmitry Baryshkov .vreg_list = qmp_phy_vreg_l, 176194a407ccSDmitry Baryshkov .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), 176294a407ccSDmitry Baryshkov .regs = pciephy_regs_layout, 176394a407ccSDmitry Baryshkov 176494a407ccSDmitry Baryshkov .start_ctrl = SERDES_START | PCS_START, 176594a407ccSDmitry Baryshkov .pwrdn_ctrl = SW_PWRDN | REFCLK_DRV_DSBL, 176694a407ccSDmitry Baryshkov .phy_status = PHYSTATUS, 176794a407ccSDmitry Baryshkov }; 176894a407ccSDmitry Baryshkov 176994a407ccSDmitry Baryshkov static const struct qmp_phy_cfg sc8180x_pciephy_cfg = { 177094a407ccSDmitry Baryshkov .type = PHY_TYPE_PCIE, 177194a407ccSDmitry Baryshkov .nlanes = 1, 177294a407ccSDmitry Baryshkov 177394a407ccSDmitry Baryshkov .serdes_tbl = sc8180x_qmp_pcie_serdes_tbl, 177494a407ccSDmitry Baryshkov .serdes_tbl_num = ARRAY_SIZE(sc8180x_qmp_pcie_serdes_tbl), 177594a407ccSDmitry Baryshkov .tx_tbl = sc8180x_qmp_pcie_tx_tbl, 177694a407ccSDmitry Baryshkov .tx_tbl_num = ARRAY_SIZE(sc8180x_qmp_pcie_tx_tbl), 177794a407ccSDmitry Baryshkov .rx_tbl = sc8180x_qmp_pcie_rx_tbl, 177894a407ccSDmitry Baryshkov .rx_tbl_num = ARRAY_SIZE(sc8180x_qmp_pcie_rx_tbl), 177994a407ccSDmitry Baryshkov .pcs_tbl = sc8180x_qmp_pcie_pcs_tbl, 178094a407ccSDmitry Baryshkov .pcs_tbl_num = ARRAY_SIZE(sc8180x_qmp_pcie_pcs_tbl), 178194a407ccSDmitry Baryshkov .pcs_misc_tbl = sc8180x_qmp_pcie_pcs_misc_tbl, 178294a407ccSDmitry Baryshkov .pcs_misc_tbl_num = ARRAY_SIZE(sc8180x_qmp_pcie_pcs_misc_tbl), 178394a407ccSDmitry Baryshkov .clk_list = sdm845_pciephy_clk_l, 178494a407ccSDmitry Baryshkov .num_clks = ARRAY_SIZE(sdm845_pciephy_clk_l), 178594a407ccSDmitry Baryshkov .reset_list = sdm845_pciephy_reset_l, 178694a407ccSDmitry Baryshkov .num_resets = ARRAY_SIZE(sdm845_pciephy_reset_l), 178794a407ccSDmitry Baryshkov .vreg_list = qmp_phy_vreg_l, 178894a407ccSDmitry Baryshkov .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), 178994a407ccSDmitry Baryshkov .regs = sm8250_pcie_regs_layout, 179094a407ccSDmitry Baryshkov 179194a407ccSDmitry Baryshkov .start_ctrl = PCS_START | SERDES_START, 179294a407ccSDmitry Baryshkov .pwrdn_ctrl = SW_PWRDN | REFCLK_DRV_DSBL, 179394a407ccSDmitry Baryshkov 179494a407ccSDmitry Baryshkov .has_pwrdn_delay = true, 179594a407ccSDmitry Baryshkov .pwrdn_delay_min = 995, /* us */ 179694a407ccSDmitry Baryshkov .pwrdn_delay_max = 1005, /* us */ 179794a407ccSDmitry Baryshkov }; 179894a407ccSDmitry Baryshkov 179994a407ccSDmitry Baryshkov static const struct qmp_phy_cfg sdx55_qmp_pciephy_cfg = { 180094a407ccSDmitry Baryshkov .type = PHY_TYPE_PCIE, 180194a407ccSDmitry Baryshkov .nlanes = 2, 180294a407ccSDmitry Baryshkov 180394a407ccSDmitry Baryshkov .serdes_tbl = sdx55_qmp_pcie_serdes_tbl, 180494a407ccSDmitry Baryshkov .serdes_tbl_num = ARRAY_SIZE(sdx55_qmp_pcie_serdes_tbl), 180594a407ccSDmitry Baryshkov .tx_tbl = sdx55_qmp_pcie_tx_tbl, 180694a407ccSDmitry Baryshkov .tx_tbl_num = ARRAY_SIZE(sdx55_qmp_pcie_tx_tbl), 180794a407ccSDmitry Baryshkov .rx_tbl = sdx55_qmp_pcie_rx_tbl, 180894a407ccSDmitry Baryshkov .rx_tbl_num = ARRAY_SIZE(sdx55_qmp_pcie_rx_tbl), 180994a407ccSDmitry Baryshkov .pcs_tbl = sdx55_qmp_pcie_pcs_tbl, 181094a407ccSDmitry Baryshkov .pcs_tbl_num = ARRAY_SIZE(sdx55_qmp_pcie_pcs_tbl), 181194a407ccSDmitry Baryshkov .pcs_misc_tbl = sdx55_qmp_pcie_pcs_misc_tbl, 181294a407ccSDmitry Baryshkov .pcs_misc_tbl_num = ARRAY_SIZE(sdx55_qmp_pcie_pcs_misc_tbl), 181394a407ccSDmitry Baryshkov .clk_list = sdm845_pciephy_clk_l, 181494a407ccSDmitry Baryshkov .num_clks = ARRAY_SIZE(sdm845_pciephy_clk_l), 181594a407ccSDmitry Baryshkov .reset_list = sdm845_pciephy_reset_l, 181694a407ccSDmitry Baryshkov .num_resets = ARRAY_SIZE(sdm845_pciephy_reset_l), 181794a407ccSDmitry Baryshkov .vreg_list = qmp_phy_vreg_l, 181894a407ccSDmitry Baryshkov .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), 181994a407ccSDmitry Baryshkov .regs = sm8250_pcie_regs_layout, 182094a407ccSDmitry Baryshkov 182194a407ccSDmitry Baryshkov .start_ctrl = PCS_START | SERDES_START, 182294a407ccSDmitry Baryshkov .pwrdn_ctrl = SW_PWRDN, 182394a407ccSDmitry Baryshkov .phy_status = PHYSTATUS_4_20, 182494a407ccSDmitry Baryshkov 182594a407ccSDmitry Baryshkov .is_dual_lane_phy = true, 182694a407ccSDmitry Baryshkov .has_pwrdn_delay = true, 182794a407ccSDmitry Baryshkov .pwrdn_delay_min = 995, /* us */ 182894a407ccSDmitry Baryshkov .pwrdn_delay_max = 1005, /* us */ 182994a407ccSDmitry Baryshkov }; 183094a407ccSDmitry Baryshkov 183194a407ccSDmitry Baryshkov static const struct qmp_phy_cfg sm8450_qmp_gen3x1_pciephy_cfg = { 183294a407ccSDmitry Baryshkov .type = PHY_TYPE_PCIE, 183394a407ccSDmitry Baryshkov .nlanes = 1, 183494a407ccSDmitry Baryshkov 183594a407ccSDmitry Baryshkov .serdes_tbl = sm8450_qmp_gen3x1_pcie_serdes_tbl, 183694a407ccSDmitry Baryshkov .serdes_tbl_num = ARRAY_SIZE(sm8450_qmp_gen3x1_pcie_serdes_tbl), 183794a407ccSDmitry Baryshkov .tx_tbl = sm8450_qmp_gen3x1_pcie_tx_tbl, 183894a407ccSDmitry Baryshkov .tx_tbl_num = ARRAY_SIZE(sm8450_qmp_gen3x1_pcie_tx_tbl), 183994a407ccSDmitry Baryshkov .rx_tbl = sm8450_qmp_gen3x1_pcie_rx_tbl, 184094a407ccSDmitry Baryshkov .rx_tbl_num = ARRAY_SIZE(sm8450_qmp_gen3x1_pcie_rx_tbl), 184194a407ccSDmitry Baryshkov .pcs_tbl = sm8450_qmp_gen3x1_pcie_pcs_tbl, 184294a407ccSDmitry Baryshkov .pcs_tbl_num = ARRAY_SIZE(sm8450_qmp_gen3x1_pcie_pcs_tbl), 184394a407ccSDmitry Baryshkov .pcs_misc_tbl = sm8450_qmp_gen3x1_pcie_pcs_misc_tbl, 184494a407ccSDmitry Baryshkov .pcs_misc_tbl_num = ARRAY_SIZE(sm8450_qmp_gen3x1_pcie_pcs_misc_tbl), 184594a407ccSDmitry Baryshkov .clk_list = sdm845_pciephy_clk_l, 184694a407ccSDmitry Baryshkov .num_clks = ARRAY_SIZE(sdm845_pciephy_clk_l), 184794a407ccSDmitry Baryshkov .reset_list = sdm845_pciephy_reset_l, 184894a407ccSDmitry Baryshkov .num_resets = ARRAY_SIZE(sdm845_pciephy_reset_l), 184994a407ccSDmitry Baryshkov .vreg_list = qmp_phy_vreg_l, 185094a407ccSDmitry Baryshkov .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), 185194a407ccSDmitry Baryshkov .regs = sm8250_pcie_regs_layout, 185294a407ccSDmitry Baryshkov 185394a407ccSDmitry Baryshkov .start_ctrl = SERDES_START | PCS_START, 185494a407ccSDmitry Baryshkov .pwrdn_ctrl = SW_PWRDN | REFCLK_DRV_DSBL, 185594a407ccSDmitry Baryshkov .phy_status = PHYSTATUS, 185694a407ccSDmitry Baryshkov 185794a407ccSDmitry Baryshkov .has_pwrdn_delay = true, 185894a407ccSDmitry Baryshkov .pwrdn_delay_min = 995, /* us */ 185994a407ccSDmitry Baryshkov .pwrdn_delay_max = 1005, /* us */ 186094a407ccSDmitry Baryshkov }; 186194a407ccSDmitry Baryshkov 186294a407ccSDmitry Baryshkov static const struct qmp_phy_cfg sm8450_qmp_gen4x2_pciephy_cfg = { 186394a407ccSDmitry Baryshkov .type = PHY_TYPE_PCIE, 186494a407ccSDmitry Baryshkov .nlanes = 2, 186594a407ccSDmitry Baryshkov 186694a407ccSDmitry Baryshkov .serdes_tbl = sm8450_qmp_gen4x2_pcie_serdes_tbl, 186794a407ccSDmitry Baryshkov .serdes_tbl_num = ARRAY_SIZE(sm8450_qmp_gen4x2_pcie_serdes_tbl), 186894a407ccSDmitry Baryshkov .tx_tbl = sm8450_qmp_gen4x2_pcie_tx_tbl, 186994a407ccSDmitry Baryshkov .tx_tbl_num = ARRAY_SIZE(sm8450_qmp_gen4x2_pcie_tx_tbl), 187094a407ccSDmitry Baryshkov .rx_tbl = sm8450_qmp_gen4x2_pcie_rx_tbl, 187194a407ccSDmitry Baryshkov .rx_tbl_num = ARRAY_SIZE(sm8450_qmp_gen4x2_pcie_rx_tbl), 187294a407ccSDmitry Baryshkov .pcs_tbl = sm8450_qmp_gen4x2_pcie_pcs_tbl, 187394a407ccSDmitry Baryshkov .pcs_tbl_num = ARRAY_SIZE(sm8450_qmp_gen4x2_pcie_pcs_tbl), 187494a407ccSDmitry Baryshkov .pcs_misc_tbl = sm8450_qmp_gen4x2_pcie_pcs_misc_tbl, 187594a407ccSDmitry Baryshkov .pcs_misc_tbl_num = ARRAY_SIZE(sm8450_qmp_gen4x2_pcie_pcs_misc_tbl), 187694a407ccSDmitry Baryshkov .clk_list = sdm845_pciephy_clk_l, 187794a407ccSDmitry Baryshkov .num_clks = ARRAY_SIZE(sdm845_pciephy_clk_l), 187894a407ccSDmitry Baryshkov .reset_list = sdm845_pciephy_reset_l, 187994a407ccSDmitry Baryshkov .num_resets = ARRAY_SIZE(sdm845_pciephy_reset_l), 188094a407ccSDmitry Baryshkov .vreg_list = qmp_phy_vreg_l, 188194a407ccSDmitry Baryshkov .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), 188294a407ccSDmitry Baryshkov .regs = sm8250_pcie_regs_layout, 188394a407ccSDmitry Baryshkov 188494a407ccSDmitry Baryshkov .start_ctrl = SERDES_START | PCS_START, 188594a407ccSDmitry Baryshkov .pwrdn_ctrl = SW_PWRDN | REFCLK_DRV_DSBL, 188694a407ccSDmitry Baryshkov .phy_status = PHYSTATUS_4_20, 188794a407ccSDmitry Baryshkov 188894a407ccSDmitry Baryshkov .is_dual_lane_phy = true, 188994a407ccSDmitry Baryshkov .has_pwrdn_delay = true, 189094a407ccSDmitry Baryshkov .pwrdn_delay_min = 995, /* us */ 189194a407ccSDmitry Baryshkov .pwrdn_delay_max = 1005, /* us */ 189294a407ccSDmitry Baryshkov }; 189394a407ccSDmitry Baryshkov 1894*27878615SJohan Hovold static void qmp_pcie_configure_lane(void __iomem *base, 189594a407ccSDmitry Baryshkov const unsigned int *regs, 189694a407ccSDmitry Baryshkov const struct qmp_phy_init_tbl tbl[], 189794a407ccSDmitry Baryshkov int num, 189894a407ccSDmitry Baryshkov u8 lane_mask) 189994a407ccSDmitry Baryshkov { 190094a407ccSDmitry Baryshkov int i; 190194a407ccSDmitry Baryshkov const struct qmp_phy_init_tbl *t = tbl; 190294a407ccSDmitry Baryshkov 190394a407ccSDmitry Baryshkov if (!t) 190494a407ccSDmitry Baryshkov return; 190594a407ccSDmitry Baryshkov 190694a407ccSDmitry Baryshkov for (i = 0; i < num; i++, t++) { 190794a407ccSDmitry Baryshkov if (!(t->lane_mask & lane_mask)) 190894a407ccSDmitry Baryshkov continue; 190994a407ccSDmitry Baryshkov 191094a407ccSDmitry Baryshkov if (t->in_layout) 191194a407ccSDmitry Baryshkov writel(t->val, base + regs[t->offset]); 191294a407ccSDmitry Baryshkov else 191394a407ccSDmitry Baryshkov writel(t->val, base + t->offset); 191494a407ccSDmitry Baryshkov } 191594a407ccSDmitry Baryshkov } 191694a407ccSDmitry Baryshkov 1917*27878615SJohan Hovold static void qmp_pcie_configure(void __iomem *base, 191894a407ccSDmitry Baryshkov const unsigned int *regs, 191994a407ccSDmitry Baryshkov const struct qmp_phy_init_tbl tbl[], 192094a407ccSDmitry Baryshkov int num) 192194a407ccSDmitry Baryshkov { 1922*27878615SJohan Hovold qmp_pcie_configure_lane(base, regs, tbl, num, 0xff); 192394a407ccSDmitry Baryshkov } 192494a407ccSDmitry Baryshkov 1925*27878615SJohan Hovold static int qmp_pcie_serdes_init(struct qmp_phy *qphy) 192694a407ccSDmitry Baryshkov { 192794a407ccSDmitry Baryshkov const struct qmp_phy_cfg *cfg = qphy->cfg; 192894a407ccSDmitry Baryshkov void __iomem *serdes = qphy->serdes; 192994a407ccSDmitry Baryshkov const struct qmp_phy_init_tbl *serdes_tbl = cfg->serdes_tbl; 193094a407ccSDmitry Baryshkov int serdes_tbl_num = cfg->serdes_tbl_num; 193194a407ccSDmitry Baryshkov 1932*27878615SJohan Hovold qmp_pcie_configure(serdes, cfg->regs, serdes_tbl, serdes_tbl_num); 1933*27878615SJohan Hovold qmp_pcie_configure(serdes, cfg->regs, cfg->serdes_tbl_sec, cfg->serdes_tbl_num_sec); 193494a407ccSDmitry Baryshkov 193594a407ccSDmitry Baryshkov return 0; 193694a407ccSDmitry Baryshkov } 193794a407ccSDmitry Baryshkov 1938*27878615SJohan Hovold static int qmp_pcie_com_init(struct qmp_phy *qphy) 193994a407ccSDmitry Baryshkov { 194094a407ccSDmitry Baryshkov struct qcom_qmp *qmp = qphy->qmp; 194194a407ccSDmitry Baryshkov const struct qmp_phy_cfg *cfg = qphy->cfg; 194294a407ccSDmitry Baryshkov void __iomem *pcs = qphy->pcs; 1943189ac6b8SDmitry Baryshkov int ret; 194494a407ccSDmitry Baryshkov 194594a407ccSDmitry Baryshkov /* turn on regulator supplies */ 194694a407ccSDmitry Baryshkov ret = regulator_bulk_enable(cfg->num_vregs, qmp->vregs); 194794a407ccSDmitry Baryshkov if (ret) { 194894a407ccSDmitry Baryshkov dev_err(qmp->dev, "failed to enable regulators, err=%d\n", ret); 19491239fd71SDmitry Baryshkov return ret; 195094a407ccSDmitry Baryshkov } 195194a407ccSDmitry Baryshkov 1952189ac6b8SDmitry Baryshkov ret = reset_control_bulk_assert(cfg->num_resets, qmp->resets); 195394a407ccSDmitry Baryshkov if (ret) { 1954189ac6b8SDmitry Baryshkov dev_err(qmp->dev, "reset assert failed\n"); 195594a407ccSDmitry Baryshkov goto err_disable_regulators; 195694a407ccSDmitry Baryshkov } 195794a407ccSDmitry Baryshkov 1958189ac6b8SDmitry Baryshkov ret = reset_control_bulk_deassert(cfg->num_resets, qmp->resets); 195994a407ccSDmitry Baryshkov if (ret) { 1960189ac6b8SDmitry Baryshkov dev_err(qmp->dev, "reset deassert failed\n"); 1961189ac6b8SDmitry Baryshkov goto err_disable_regulators; 196294a407ccSDmitry Baryshkov } 196394a407ccSDmitry Baryshkov 196494a407ccSDmitry Baryshkov ret = clk_bulk_prepare_enable(cfg->num_clks, qmp->clks); 196594a407ccSDmitry Baryshkov if (ret) 196694a407ccSDmitry Baryshkov goto err_assert_reset; 196794a407ccSDmitry Baryshkov 196894a407ccSDmitry Baryshkov if (cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL]) 196994a407ccSDmitry Baryshkov qphy_setbits(pcs, 197094a407ccSDmitry Baryshkov cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL], 197194a407ccSDmitry Baryshkov cfg->pwrdn_ctrl); 197294a407ccSDmitry Baryshkov else 19736cad2983SDmitry Baryshkov qphy_setbits(pcs, QPHY_V2_PCS_POWER_DOWN_CONTROL, 197494a407ccSDmitry Baryshkov cfg->pwrdn_ctrl); 197594a407ccSDmitry Baryshkov 197694a407ccSDmitry Baryshkov return 0; 197794a407ccSDmitry Baryshkov 197894a407ccSDmitry Baryshkov err_assert_reset: 1979189ac6b8SDmitry Baryshkov reset_control_bulk_assert(cfg->num_resets, qmp->resets); 198094a407ccSDmitry Baryshkov err_disable_regulators: 198194a407ccSDmitry Baryshkov regulator_bulk_disable(cfg->num_vregs, qmp->vregs); 198294a407ccSDmitry Baryshkov 198394a407ccSDmitry Baryshkov return ret; 198494a407ccSDmitry Baryshkov } 198594a407ccSDmitry Baryshkov 1986*27878615SJohan Hovold static int qmp_pcie_com_exit(struct qmp_phy *qphy) 198794a407ccSDmitry Baryshkov { 198894a407ccSDmitry Baryshkov struct qcom_qmp *qmp = qphy->qmp; 198994a407ccSDmitry Baryshkov const struct qmp_phy_cfg *cfg = qphy->cfg; 199094a407ccSDmitry Baryshkov 1991189ac6b8SDmitry Baryshkov reset_control_bulk_assert(cfg->num_resets, qmp->resets); 199294a407ccSDmitry Baryshkov 199394a407ccSDmitry Baryshkov clk_bulk_disable_unprepare(cfg->num_clks, qmp->clks); 199494a407ccSDmitry Baryshkov 199594a407ccSDmitry Baryshkov regulator_bulk_disable(cfg->num_vregs, qmp->vregs); 199694a407ccSDmitry Baryshkov 199794a407ccSDmitry Baryshkov return 0; 199894a407ccSDmitry Baryshkov } 199994a407ccSDmitry Baryshkov 2000*27878615SJohan Hovold static int qmp_pcie_init(struct phy *phy) 200194a407ccSDmitry Baryshkov { 200294a407ccSDmitry Baryshkov struct qmp_phy *qphy = phy_get_drvdata(phy); 200394a407ccSDmitry Baryshkov struct qcom_qmp *qmp = qphy->qmp; 200494a407ccSDmitry Baryshkov int ret; 200594a407ccSDmitry Baryshkov dev_vdbg(qmp->dev, "Initializing QMP phy\n"); 200694a407ccSDmitry Baryshkov 2007*27878615SJohan Hovold ret = qmp_pcie_com_init(qphy); 200894a407ccSDmitry Baryshkov if (ret) 200994a407ccSDmitry Baryshkov return ret; 201094a407ccSDmitry Baryshkov 201194a407ccSDmitry Baryshkov return 0; 201294a407ccSDmitry Baryshkov } 201394a407ccSDmitry Baryshkov 2014*27878615SJohan Hovold static int qmp_pcie_power_on(struct phy *phy) 201594a407ccSDmitry Baryshkov { 201694a407ccSDmitry Baryshkov struct qmp_phy *qphy = phy_get_drvdata(phy); 201794a407ccSDmitry Baryshkov struct qcom_qmp *qmp = qphy->qmp; 201894a407ccSDmitry Baryshkov const struct qmp_phy_cfg *cfg = qphy->cfg; 201994a407ccSDmitry Baryshkov void __iomem *tx = qphy->tx; 202094a407ccSDmitry Baryshkov void __iomem *rx = qphy->rx; 202194a407ccSDmitry Baryshkov void __iomem *pcs = qphy->pcs; 202294a407ccSDmitry Baryshkov void __iomem *pcs_misc = qphy->pcs_misc; 202394a407ccSDmitry Baryshkov void __iomem *status; 202494a407ccSDmitry Baryshkov unsigned int mask, val, ready; 202594a407ccSDmitry Baryshkov int ret; 202694a407ccSDmitry Baryshkov 2027*27878615SJohan Hovold qmp_pcie_serdes_init(qphy); 202894a407ccSDmitry Baryshkov 202994a407ccSDmitry Baryshkov ret = clk_prepare_enable(qphy->pipe_clk); 203094a407ccSDmitry Baryshkov if (ret) { 203194a407ccSDmitry Baryshkov dev_err(qmp->dev, "pipe_clk enable failed err=%d\n", ret); 2032fd926994SDmitry Baryshkov return ret; 203394a407ccSDmitry Baryshkov } 203494a407ccSDmitry Baryshkov 203594a407ccSDmitry Baryshkov /* Tx, Rx, and PCS configurations */ 2036*27878615SJohan Hovold qmp_pcie_configure_lane(tx, cfg->regs, cfg->tx_tbl, cfg->tx_tbl_num, 1); 2037*27878615SJohan Hovold qmp_pcie_configure_lane(tx, cfg->regs, cfg->tx_tbl_sec, cfg->tx_tbl_num_sec, 1); 203894a407ccSDmitry Baryshkov 203994a407ccSDmitry Baryshkov /* Configuration for other LANE for USB-DP combo PHY */ 204094a407ccSDmitry Baryshkov if (cfg->is_dual_lane_phy) { 2041*27878615SJohan Hovold qmp_pcie_configure_lane(qphy->tx2, cfg->regs, cfg->tx_tbl, 2042*27878615SJohan Hovold cfg->tx_tbl_num, 2); 2043*27878615SJohan Hovold qmp_pcie_configure_lane(qphy->tx2, cfg->regs, cfg->tx_tbl_sec, 204494a407ccSDmitry Baryshkov cfg->tx_tbl_num_sec, 2); 204594a407ccSDmitry Baryshkov } 204694a407ccSDmitry Baryshkov 2047*27878615SJohan Hovold qmp_pcie_configure_lane(rx, cfg->regs, cfg->rx_tbl, cfg->rx_tbl_num, 1); 2048*27878615SJohan Hovold qmp_pcie_configure_lane(rx, cfg->regs, cfg->rx_tbl_sec, cfg->rx_tbl_num_sec, 1); 204994a407ccSDmitry Baryshkov 205094a407ccSDmitry Baryshkov if (cfg->is_dual_lane_phy) { 2051*27878615SJohan Hovold qmp_pcie_configure_lane(qphy->rx2, cfg->regs, cfg->rx_tbl, 2052*27878615SJohan Hovold cfg->rx_tbl_num, 2); 2053*27878615SJohan Hovold qmp_pcie_configure_lane(qphy->rx2, cfg->regs, cfg->rx_tbl_sec, 205494a407ccSDmitry Baryshkov cfg->rx_tbl_num_sec, 2); 205594a407ccSDmitry Baryshkov } 205694a407ccSDmitry Baryshkov 2057*27878615SJohan Hovold qmp_pcie_configure(pcs, cfg->regs, cfg->pcs_tbl, cfg->pcs_tbl_num); 2058*27878615SJohan Hovold qmp_pcie_configure(pcs, cfg->regs, cfg->pcs_tbl_sec, cfg->pcs_tbl_num_sec); 205994a407ccSDmitry Baryshkov 2060*27878615SJohan Hovold qmp_pcie_configure(pcs_misc, cfg->regs, cfg->pcs_misc_tbl, cfg->pcs_misc_tbl_num); 2061*27878615SJohan Hovold qmp_pcie_configure(pcs_misc, cfg->regs, cfg->pcs_misc_tbl_sec, cfg->pcs_misc_tbl_num_sec); 206294a407ccSDmitry Baryshkov 206394a407ccSDmitry Baryshkov /* 206494a407ccSDmitry Baryshkov * Pull out PHY from POWER DOWN state. 206594a407ccSDmitry Baryshkov * This is active low enable signal to power-down PHY. 206694a407ccSDmitry Baryshkov */ 20676cad2983SDmitry Baryshkov qphy_setbits(pcs, QPHY_V2_PCS_POWER_DOWN_CONTROL, cfg->pwrdn_ctrl); 206894a407ccSDmitry Baryshkov 206994a407ccSDmitry Baryshkov if (cfg->has_pwrdn_delay) 207094a407ccSDmitry Baryshkov usleep_range(cfg->pwrdn_delay_min, cfg->pwrdn_delay_max); 207194a407ccSDmitry Baryshkov 207294a407ccSDmitry Baryshkov /* Pull PHY out of reset state */ 207394a407ccSDmitry Baryshkov qphy_clrbits(pcs, cfg->regs[QPHY_SW_RESET], SW_RESET); 2074fd926994SDmitry Baryshkov 207594a407ccSDmitry Baryshkov /* start SerDes and Phy-Coding-Sublayer */ 207694a407ccSDmitry Baryshkov qphy_setbits(pcs, cfg->regs[QPHY_START_CTRL], cfg->start_ctrl); 207794a407ccSDmitry Baryshkov 207894a407ccSDmitry Baryshkov status = pcs + cfg->regs[QPHY_PCS_STATUS]; 207994a407ccSDmitry Baryshkov mask = cfg->phy_status; 208094a407ccSDmitry Baryshkov ready = 0; 208194a407ccSDmitry Baryshkov 208294a407ccSDmitry Baryshkov ret = readl_poll_timeout(status, val, (val & mask) == ready, 10, 208394a407ccSDmitry Baryshkov PHY_INIT_COMPLETE_TIMEOUT); 208494a407ccSDmitry Baryshkov if (ret) { 208594a407ccSDmitry Baryshkov dev_err(qmp->dev, "phy initialization timed-out\n"); 208694a407ccSDmitry Baryshkov goto err_disable_pipe_clk; 208794a407ccSDmitry Baryshkov } 2088da07a06bSDmitry Baryshkov 208994a407ccSDmitry Baryshkov return 0; 209094a407ccSDmitry Baryshkov 209194a407ccSDmitry Baryshkov err_disable_pipe_clk: 209294a407ccSDmitry Baryshkov clk_disable_unprepare(qphy->pipe_clk); 209394a407ccSDmitry Baryshkov 209494a407ccSDmitry Baryshkov return ret; 209594a407ccSDmitry Baryshkov } 209694a407ccSDmitry Baryshkov 2097*27878615SJohan Hovold static int qmp_pcie_power_off(struct phy *phy) 209894a407ccSDmitry Baryshkov { 209994a407ccSDmitry Baryshkov struct qmp_phy *qphy = phy_get_drvdata(phy); 210094a407ccSDmitry Baryshkov const struct qmp_phy_cfg *cfg = qphy->cfg; 210194a407ccSDmitry Baryshkov 210294a407ccSDmitry Baryshkov clk_disable_unprepare(qphy->pipe_clk); 210394a407ccSDmitry Baryshkov 210494a407ccSDmitry Baryshkov /* PHY reset */ 210594a407ccSDmitry Baryshkov qphy_setbits(qphy->pcs, cfg->regs[QPHY_SW_RESET], SW_RESET); 210694a407ccSDmitry Baryshkov 210794a407ccSDmitry Baryshkov /* stop SerDes and Phy-Coding-Sublayer */ 210894a407ccSDmitry Baryshkov qphy_clrbits(qphy->pcs, cfg->regs[QPHY_START_CTRL], cfg->start_ctrl); 210994a407ccSDmitry Baryshkov 211094a407ccSDmitry Baryshkov /* Put PHY into POWER DOWN state: active low */ 211194a407ccSDmitry Baryshkov if (cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL]) { 211294a407ccSDmitry Baryshkov qphy_clrbits(qphy->pcs, cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL], 211394a407ccSDmitry Baryshkov cfg->pwrdn_ctrl); 211494a407ccSDmitry Baryshkov } else { 21156cad2983SDmitry Baryshkov qphy_clrbits(qphy->pcs, QPHY_V2_PCS_POWER_DOWN_CONTROL, 211694a407ccSDmitry Baryshkov cfg->pwrdn_ctrl); 211794a407ccSDmitry Baryshkov } 211894a407ccSDmitry Baryshkov 211994a407ccSDmitry Baryshkov return 0; 212094a407ccSDmitry Baryshkov } 212194a407ccSDmitry Baryshkov 2122*27878615SJohan Hovold static int qmp_pcie_exit(struct phy *phy) 212394a407ccSDmitry Baryshkov { 212494a407ccSDmitry Baryshkov struct qmp_phy *qphy = phy_get_drvdata(phy); 212594a407ccSDmitry Baryshkov 2126*27878615SJohan Hovold qmp_pcie_com_exit(qphy); 212794a407ccSDmitry Baryshkov 212894a407ccSDmitry Baryshkov return 0; 212994a407ccSDmitry Baryshkov } 213094a407ccSDmitry Baryshkov 2131*27878615SJohan Hovold static int qmp_pcie_enable(struct phy *phy) 213294a407ccSDmitry Baryshkov { 213394a407ccSDmitry Baryshkov int ret; 213494a407ccSDmitry Baryshkov 2135*27878615SJohan Hovold ret = qmp_pcie_init(phy); 213694a407ccSDmitry Baryshkov if (ret) 213794a407ccSDmitry Baryshkov return ret; 213894a407ccSDmitry Baryshkov 2139*27878615SJohan Hovold ret = qmp_pcie_power_on(phy); 214094a407ccSDmitry Baryshkov if (ret) 2141*27878615SJohan Hovold qmp_pcie_exit(phy); 214294a407ccSDmitry Baryshkov 214394a407ccSDmitry Baryshkov return ret; 214494a407ccSDmitry Baryshkov } 214594a407ccSDmitry Baryshkov 2146*27878615SJohan Hovold static int qmp_pcie_disable(struct phy *phy) 214794a407ccSDmitry Baryshkov { 214894a407ccSDmitry Baryshkov int ret; 214994a407ccSDmitry Baryshkov 2150*27878615SJohan Hovold ret = qmp_pcie_power_off(phy); 215194a407ccSDmitry Baryshkov if (ret) 215294a407ccSDmitry Baryshkov return ret; 2153*27878615SJohan Hovold 2154*27878615SJohan Hovold return qmp_pcie_exit(phy); 215594a407ccSDmitry Baryshkov } 215694a407ccSDmitry Baryshkov 2157*27878615SJohan Hovold static int qmp_pcie_set_mode(struct phy *phy, enum phy_mode mode, int submode) 215894a407ccSDmitry Baryshkov { 215994a407ccSDmitry Baryshkov struct qmp_phy *qphy = phy_get_drvdata(phy); 216094a407ccSDmitry Baryshkov 216194a407ccSDmitry Baryshkov qphy->mode = mode; 216294a407ccSDmitry Baryshkov 216394a407ccSDmitry Baryshkov return 0; 216494a407ccSDmitry Baryshkov } 216594a407ccSDmitry Baryshkov 2166*27878615SJohan Hovold static int qmp_pcie_vreg_init(struct device *dev, const struct qmp_phy_cfg *cfg) 216794a407ccSDmitry Baryshkov { 216894a407ccSDmitry Baryshkov struct qcom_qmp *qmp = dev_get_drvdata(dev); 216994a407ccSDmitry Baryshkov int num = cfg->num_vregs; 217094a407ccSDmitry Baryshkov int i; 217194a407ccSDmitry Baryshkov 217294a407ccSDmitry Baryshkov qmp->vregs = devm_kcalloc(dev, num, sizeof(*qmp->vregs), GFP_KERNEL); 217394a407ccSDmitry Baryshkov if (!qmp->vregs) 217494a407ccSDmitry Baryshkov return -ENOMEM; 217594a407ccSDmitry Baryshkov 217694a407ccSDmitry Baryshkov for (i = 0; i < num; i++) 217794a407ccSDmitry Baryshkov qmp->vregs[i].supply = cfg->vreg_list[i]; 217894a407ccSDmitry Baryshkov 217994a407ccSDmitry Baryshkov return devm_regulator_bulk_get(dev, num, qmp->vregs); 218094a407ccSDmitry Baryshkov } 218194a407ccSDmitry Baryshkov 2182*27878615SJohan Hovold static int qmp_pcie_reset_init(struct device *dev, const struct qmp_phy_cfg *cfg) 218394a407ccSDmitry Baryshkov { 218494a407ccSDmitry Baryshkov struct qcom_qmp *qmp = dev_get_drvdata(dev); 218594a407ccSDmitry Baryshkov int i; 2186189ac6b8SDmitry Baryshkov int ret; 218794a407ccSDmitry Baryshkov 218894a407ccSDmitry Baryshkov qmp->resets = devm_kcalloc(dev, cfg->num_resets, 218994a407ccSDmitry Baryshkov sizeof(*qmp->resets), GFP_KERNEL); 219094a407ccSDmitry Baryshkov if (!qmp->resets) 219194a407ccSDmitry Baryshkov return -ENOMEM; 219294a407ccSDmitry Baryshkov 2193189ac6b8SDmitry Baryshkov for (i = 0; i < cfg->num_resets; i++) 2194189ac6b8SDmitry Baryshkov qmp->resets[i].id = cfg->reset_list[i]; 219594a407ccSDmitry Baryshkov 2196189ac6b8SDmitry Baryshkov ret = devm_reset_control_bulk_get_exclusive(dev, cfg->num_resets, qmp->resets); 2197189ac6b8SDmitry Baryshkov if (ret) 2198189ac6b8SDmitry Baryshkov return dev_err_probe(dev, ret, "failed to get resets\n"); 219994a407ccSDmitry Baryshkov 220094a407ccSDmitry Baryshkov return 0; 220194a407ccSDmitry Baryshkov } 220294a407ccSDmitry Baryshkov 2203*27878615SJohan Hovold static int qmp_pcie_clk_init(struct device *dev, const struct qmp_phy_cfg *cfg) 220494a407ccSDmitry Baryshkov { 220594a407ccSDmitry Baryshkov struct qcom_qmp *qmp = dev_get_drvdata(dev); 220694a407ccSDmitry Baryshkov int num = cfg->num_clks; 220794a407ccSDmitry Baryshkov int i; 220894a407ccSDmitry Baryshkov 220994a407ccSDmitry Baryshkov qmp->clks = devm_kcalloc(dev, num, sizeof(*qmp->clks), GFP_KERNEL); 221094a407ccSDmitry Baryshkov if (!qmp->clks) 221194a407ccSDmitry Baryshkov return -ENOMEM; 221294a407ccSDmitry Baryshkov 221394a407ccSDmitry Baryshkov for (i = 0; i < num; i++) 221494a407ccSDmitry Baryshkov qmp->clks[i].id = cfg->clk_list[i]; 221594a407ccSDmitry Baryshkov 221694a407ccSDmitry Baryshkov return devm_clk_bulk_get(dev, num, qmp->clks); 221794a407ccSDmitry Baryshkov } 221894a407ccSDmitry Baryshkov 221994a407ccSDmitry Baryshkov static void phy_clk_release_provider(void *res) 222094a407ccSDmitry Baryshkov { 222194a407ccSDmitry Baryshkov of_clk_del_provider(res); 222294a407ccSDmitry Baryshkov } 222394a407ccSDmitry Baryshkov 222494a407ccSDmitry Baryshkov /* 222594a407ccSDmitry Baryshkov * Register a fixed rate pipe clock. 222694a407ccSDmitry Baryshkov * 222794a407ccSDmitry Baryshkov * The <s>_pipe_clksrc generated by PHY goes to the GCC that gate 222894a407ccSDmitry Baryshkov * controls it. The <s>_pipe_clk coming out of the GCC is requested 222994a407ccSDmitry Baryshkov * by the PHY driver for its operations. 223094a407ccSDmitry Baryshkov * We register the <s>_pipe_clksrc here. The gcc driver takes care 223194a407ccSDmitry Baryshkov * of assigning this <s>_pipe_clksrc as parent to <s>_pipe_clk. 223294a407ccSDmitry Baryshkov * Below picture shows this relationship. 223394a407ccSDmitry Baryshkov * 223494a407ccSDmitry Baryshkov * +---------------+ 223594a407ccSDmitry Baryshkov * | PHY block |<<---------------------------------------+ 223694a407ccSDmitry Baryshkov * | | | 223794a407ccSDmitry Baryshkov * | +-------+ | +-----+ | 223894a407ccSDmitry Baryshkov * I/P---^-->| PLL |---^--->pipe_clksrc--->| GCC |--->pipe_clk---+ 223994a407ccSDmitry Baryshkov * clk | +-------+ | +-----+ 224094a407ccSDmitry Baryshkov * +---------------+ 224194a407ccSDmitry Baryshkov */ 224294a407ccSDmitry Baryshkov static int phy_pipe_clk_register(struct qcom_qmp *qmp, struct device_node *np) 224394a407ccSDmitry Baryshkov { 224494a407ccSDmitry Baryshkov struct clk_fixed_rate *fixed; 224594a407ccSDmitry Baryshkov struct clk_init_data init = { }; 224694a407ccSDmitry Baryshkov int ret; 224794a407ccSDmitry Baryshkov 224894a407ccSDmitry Baryshkov ret = of_property_read_string(np, "clock-output-names", &init.name); 224994a407ccSDmitry Baryshkov if (ret) { 225094a407ccSDmitry Baryshkov dev_err(qmp->dev, "%pOFn: No clock-output-names\n", np); 225194a407ccSDmitry Baryshkov return ret; 225294a407ccSDmitry Baryshkov } 225394a407ccSDmitry Baryshkov 225494a407ccSDmitry Baryshkov fixed = devm_kzalloc(qmp->dev, sizeof(*fixed), GFP_KERNEL); 225594a407ccSDmitry Baryshkov if (!fixed) 225694a407ccSDmitry Baryshkov return -ENOMEM; 225794a407ccSDmitry Baryshkov 225894a407ccSDmitry Baryshkov init.ops = &clk_fixed_rate_ops; 225994a407ccSDmitry Baryshkov 22602ec9bc8dSRobert Marko /* 22612ec9bc8dSRobert Marko * Controllers using QMP PHY-s use 125MHz pipe clock interface 22622ec9bc8dSRobert Marko * unless other frequency is specified in the PHY config. 22632ec9bc8dSRobert Marko */ 22642ec9bc8dSRobert Marko if (qmp->phys[0]->cfg->pipe_clock_rate) 22652ec9bc8dSRobert Marko fixed->fixed_rate = qmp->phys[0]->cfg->pipe_clock_rate; 22662ec9bc8dSRobert Marko else 226794a407ccSDmitry Baryshkov fixed->fixed_rate = 125000000; 22682ec9bc8dSRobert Marko 226994a407ccSDmitry Baryshkov fixed->hw.init = &init; 227094a407ccSDmitry Baryshkov 227194a407ccSDmitry Baryshkov ret = devm_clk_hw_register(qmp->dev, &fixed->hw); 227294a407ccSDmitry Baryshkov if (ret) 227394a407ccSDmitry Baryshkov return ret; 227494a407ccSDmitry Baryshkov 227594a407ccSDmitry Baryshkov ret = of_clk_add_hw_provider(np, of_clk_hw_simple_get, &fixed->hw); 227694a407ccSDmitry Baryshkov if (ret) 227794a407ccSDmitry Baryshkov return ret; 227894a407ccSDmitry Baryshkov 227994a407ccSDmitry Baryshkov /* 228094a407ccSDmitry Baryshkov * Roll a devm action because the clock provider is the child node, but 228194a407ccSDmitry Baryshkov * the child node is not actually a device. 228294a407ccSDmitry Baryshkov */ 228394a407ccSDmitry Baryshkov return devm_add_action_or_reset(qmp->dev, phy_clk_release_provider, np); 228494a407ccSDmitry Baryshkov } 228594a407ccSDmitry Baryshkov 2286*27878615SJohan Hovold static const struct phy_ops qmp_pcie_ops = { 2287*27878615SJohan Hovold .power_on = qmp_pcie_enable, 2288*27878615SJohan Hovold .power_off = qmp_pcie_disable, 2289*27878615SJohan Hovold .set_mode = qmp_pcie_set_mode, 229094a407ccSDmitry Baryshkov .owner = THIS_MODULE, 229194a407ccSDmitry Baryshkov }; 229294a407ccSDmitry Baryshkov 2293*27878615SJohan Hovold static int qmp_pcie_create(struct device *dev, struct device_node *np, int id, 229494a407ccSDmitry Baryshkov void __iomem *serdes, const struct qmp_phy_cfg *cfg) 229594a407ccSDmitry Baryshkov { 229694a407ccSDmitry Baryshkov struct qcom_qmp *qmp = dev_get_drvdata(dev); 229794a407ccSDmitry Baryshkov struct phy *generic_phy; 229894a407ccSDmitry Baryshkov struct qmp_phy *qphy; 229994a407ccSDmitry Baryshkov int ret; 230094a407ccSDmitry Baryshkov 230194a407ccSDmitry Baryshkov qphy = devm_kzalloc(dev, sizeof(*qphy), GFP_KERNEL); 230294a407ccSDmitry Baryshkov if (!qphy) 230394a407ccSDmitry Baryshkov return -ENOMEM; 230494a407ccSDmitry Baryshkov 230594a407ccSDmitry Baryshkov qphy->cfg = cfg; 230694a407ccSDmitry Baryshkov qphy->serdes = serdes; 230794a407ccSDmitry Baryshkov /* 230894a407ccSDmitry Baryshkov * Get memory resources for each phy lane: 230994a407ccSDmitry Baryshkov * Resources are indexed as: tx -> 0; rx -> 1; pcs -> 2. 231094a407ccSDmitry Baryshkov * For dual lane PHYs: tx2 -> 3, rx2 -> 4, pcs_misc (optional) -> 5 231194a407ccSDmitry Baryshkov * For single lane PHYs: pcs_misc (optional) -> 3. 231294a407ccSDmitry Baryshkov */ 231394a407ccSDmitry Baryshkov qphy->tx = of_iomap(np, 0); 231494a407ccSDmitry Baryshkov if (!qphy->tx) 231594a407ccSDmitry Baryshkov return -ENOMEM; 231694a407ccSDmitry Baryshkov 231794a407ccSDmitry Baryshkov qphy->rx = of_iomap(np, 1); 231894a407ccSDmitry Baryshkov if (!qphy->rx) 231994a407ccSDmitry Baryshkov return -ENOMEM; 232094a407ccSDmitry Baryshkov 232194a407ccSDmitry Baryshkov qphy->pcs = of_iomap(np, 2); 232294a407ccSDmitry Baryshkov if (!qphy->pcs) 232394a407ccSDmitry Baryshkov return -ENOMEM; 232494a407ccSDmitry Baryshkov 232594a407ccSDmitry Baryshkov /* 232694a407ccSDmitry Baryshkov * If this is a dual-lane PHY, then there should be registers for the 232794a407ccSDmitry Baryshkov * second lane. Some old device trees did not specify this, so fall 232894a407ccSDmitry Baryshkov * back to old legacy behavior of assuming they can be reached at an 232994a407ccSDmitry Baryshkov * offset from the first lane. 233094a407ccSDmitry Baryshkov */ 233194a407ccSDmitry Baryshkov if (cfg->is_dual_lane_phy) { 233294a407ccSDmitry Baryshkov qphy->tx2 = of_iomap(np, 3); 233394a407ccSDmitry Baryshkov qphy->rx2 = of_iomap(np, 4); 233494a407ccSDmitry Baryshkov if (!qphy->tx2 || !qphy->rx2) { 233594a407ccSDmitry Baryshkov dev_warn(dev, 233694a407ccSDmitry Baryshkov "Underspecified device tree, falling back to legacy register regions\n"); 233794a407ccSDmitry Baryshkov 233894a407ccSDmitry Baryshkov /* In the old version, pcs_misc is at index 3. */ 233994a407ccSDmitry Baryshkov qphy->pcs_misc = qphy->tx2; 234094a407ccSDmitry Baryshkov qphy->tx2 = qphy->tx + QMP_PHY_LEGACY_LANE_STRIDE; 234194a407ccSDmitry Baryshkov qphy->rx2 = qphy->rx + QMP_PHY_LEGACY_LANE_STRIDE; 234294a407ccSDmitry Baryshkov 234394a407ccSDmitry Baryshkov } else { 234494a407ccSDmitry Baryshkov qphy->pcs_misc = of_iomap(np, 5); 234594a407ccSDmitry Baryshkov } 234694a407ccSDmitry Baryshkov 234794a407ccSDmitry Baryshkov } else { 234894a407ccSDmitry Baryshkov qphy->pcs_misc = of_iomap(np, 3); 234994a407ccSDmitry Baryshkov } 235094a407ccSDmitry Baryshkov 2351af664324SDmitry Baryshkov if (!qphy->pcs_misc && 2352af664324SDmitry Baryshkov of_device_is_compatible(dev->of_node, "qcom,ipq6018-qmp-pcie-phy")) 2353af664324SDmitry Baryshkov qphy->pcs_misc = qphy->pcs + 0x400; 2354af664324SDmitry Baryshkov 235594a407ccSDmitry Baryshkov if (!qphy->pcs_misc) 235694a407ccSDmitry Baryshkov dev_vdbg(dev, "PHY pcs_misc-reg not used\n"); 235794a407ccSDmitry Baryshkov 2358f8432544SJohan Hovold qphy->pipe_clk = devm_get_clk_from_child(dev, np, NULL); 235994a407ccSDmitry Baryshkov if (IS_ERR(qphy->pipe_clk)) { 23608f662cd9SJohan Hovold return dev_err_probe(dev, PTR_ERR(qphy->pipe_clk), 23618f662cd9SJohan Hovold "failed to get lane%d pipe clock\n", id); 236294a407ccSDmitry Baryshkov } 236394a407ccSDmitry Baryshkov 2364*27878615SJohan Hovold generic_phy = devm_phy_create(dev, np, &qmp_pcie_ops); 236594a407ccSDmitry Baryshkov if (IS_ERR(generic_phy)) { 236694a407ccSDmitry Baryshkov ret = PTR_ERR(generic_phy); 236794a407ccSDmitry Baryshkov dev_err(dev, "failed to create qphy %d\n", ret); 236894a407ccSDmitry Baryshkov return ret; 236994a407ccSDmitry Baryshkov } 237094a407ccSDmitry Baryshkov 237194a407ccSDmitry Baryshkov qphy->phy = generic_phy; 237294a407ccSDmitry Baryshkov qphy->index = id; 237394a407ccSDmitry Baryshkov qphy->qmp = qmp; 237494a407ccSDmitry Baryshkov qmp->phys[id] = qphy; 237594a407ccSDmitry Baryshkov phy_set_drvdata(generic_phy, qphy); 237694a407ccSDmitry Baryshkov 237794a407ccSDmitry Baryshkov return 0; 237894a407ccSDmitry Baryshkov } 237994a407ccSDmitry Baryshkov 2380*27878615SJohan Hovold static const struct of_device_id qmp_pcie_of_match_table[] = { 238194a407ccSDmitry Baryshkov { 238294a407ccSDmitry Baryshkov .compatible = "qcom,msm8998-qmp-pcie-phy", 238394a407ccSDmitry Baryshkov .data = &msm8998_pciephy_cfg, 238494a407ccSDmitry Baryshkov }, { 238594a407ccSDmitry Baryshkov .compatible = "qcom,ipq8074-qmp-pcie-phy", 238694a407ccSDmitry Baryshkov .data = &ipq8074_pciephy_cfg, 238794a407ccSDmitry Baryshkov }, { 2388334fad18SRobert Marko .compatible = "qcom,ipq8074-qmp-gen3-pcie-phy", 2389334fad18SRobert Marko .data = &ipq8074_pciephy_gen3_cfg, 2390334fad18SRobert Marko }, { 239194a407ccSDmitry Baryshkov .compatible = "qcom,ipq6018-qmp-pcie-phy", 239294a407ccSDmitry Baryshkov .data = &ipq6018_pciephy_cfg, 239394a407ccSDmitry Baryshkov }, { 239494a407ccSDmitry Baryshkov .compatible = "qcom,sc8180x-qmp-pcie-phy", 239594a407ccSDmitry Baryshkov .data = &sc8180x_pciephy_cfg, 239694a407ccSDmitry Baryshkov }, { 239794a407ccSDmitry Baryshkov .compatible = "qcom,sdm845-qhp-pcie-phy", 239894a407ccSDmitry Baryshkov .data = &sdm845_qhp_pciephy_cfg, 239994a407ccSDmitry Baryshkov }, { 240094a407ccSDmitry Baryshkov .compatible = "qcom,sdm845-qmp-pcie-phy", 240194a407ccSDmitry Baryshkov .data = &sdm845_qmp_pciephy_cfg, 240294a407ccSDmitry Baryshkov }, { 240394a407ccSDmitry Baryshkov .compatible = "qcom,sm8250-qmp-gen3x1-pcie-phy", 240494a407ccSDmitry Baryshkov .data = &sm8250_qmp_gen3x1_pciephy_cfg, 240594a407ccSDmitry Baryshkov }, { 240694a407ccSDmitry Baryshkov .compatible = "qcom,sm8250-qmp-gen3x2-pcie-phy", 240794a407ccSDmitry Baryshkov .data = &sm8250_qmp_gen3x2_pciephy_cfg, 240894a407ccSDmitry Baryshkov }, { 240994a407ccSDmitry Baryshkov .compatible = "qcom,sm8250-qmp-modem-pcie-phy", 241094a407ccSDmitry Baryshkov .data = &sm8250_qmp_gen3x2_pciephy_cfg, 241194a407ccSDmitry Baryshkov }, { 241294a407ccSDmitry Baryshkov .compatible = "qcom,sdx55-qmp-pcie-phy", 241394a407ccSDmitry Baryshkov .data = &sdx55_qmp_pciephy_cfg, 241494a407ccSDmitry Baryshkov }, { 241594a407ccSDmitry Baryshkov .compatible = "qcom,sm8450-qmp-gen3x1-pcie-phy", 241694a407ccSDmitry Baryshkov .data = &sm8450_qmp_gen3x1_pciephy_cfg, 241794a407ccSDmitry Baryshkov }, { 241894a407ccSDmitry Baryshkov .compatible = "qcom,sm8450-qmp-gen4x2-pcie-phy", 241994a407ccSDmitry Baryshkov .data = &sm8450_qmp_gen4x2_pciephy_cfg, 242094a407ccSDmitry Baryshkov }, 242194a407ccSDmitry Baryshkov { }, 242294a407ccSDmitry Baryshkov }; 2423*27878615SJohan Hovold MODULE_DEVICE_TABLE(of, qmp_pcie_of_match_table); 242494a407ccSDmitry Baryshkov 2425*27878615SJohan Hovold static int qmp_pcie_probe(struct platform_device *pdev) 242694a407ccSDmitry Baryshkov { 242794a407ccSDmitry Baryshkov struct qcom_qmp *qmp; 242894a407ccSDmitry Baryshkov struct device *dev = &pdev->dev; 242994a407ccSDmitry Baryshkov struct device_node *child; 243094a407ccSDmitry Baryshkov struct phy_provider *phy_provider; 243194a407ccSDmitry Baryshkov void __iomem *serdes; 243294a407ccSDmitry Baryshkov const struct qmp_phy_cfg *cfg = NULL; 24331239fd71SDmitry Baryshkov int num, id; 243494a407ccSDmitry Baryshkov int ret; 243594a407ccSDmitry Baryshkov 243694a407ccSDmitry Baryshkov qmp = devm_kzalloc(dev, sizeof(*qmp), GFP_KERNEL); 243794a407ccSDmitry Baryshkov if (!qmp) 243894a407ccSDmitry Baryshkov return -ENOMEM; 243994a407ccSDmitry Baryshkov 244094a407ccSDmitry Baryshkov qmp->dev = dev; 244194a407ccSDmitry Baryshkov dev_set_drvdata(dev, qmp); 244294a407ccSDmitry Baryshkov 244394a407ccSDmitry Baryshkov /* Get the specific init parameters of QMP phy */ 244494a407ccSDmitry Baryshkov cfg = of_device_get_match_data(dev); 2445b35a5311SDmitry Baryshkov if (!cfg) 244694a407ccSDmitry Baryshkov return -EINVAL; 244794a407ccSDmitry Baryshkov 244894a407ccSDmitry Baryshkov /* per PHY serdes; usually located at base address */ 2449da07a06bSDmitry Baryshkov serdes = devm_platform_ioremap_resource(pdev, 0); 245094a407ccSDmitry Baryshkov if (IS_ERR(serdes)) 245194a407ccSDmitry Baryshkov return PTR_ERR(serdes); 245294a407ccSDmitry Baryshkov 2453*27878615SJohan Hovold ret = qmp_pcie_clk_init(dev, cfg); 245494a407ccSDmitry Baryshkov if (ret) 245594a407ccSDmitry Baryshkov return ret; 245694a407ccSDmitry Baryshkov 2457*27878615SJohan Hovold ret = qmp_pcie_reset_init(dev, cfg); 245894a407ccSDmitry Baryshkov if (ret) 245994a407ccSDmitry Baryshkov return ret; 246094a407ccSDmitry Baryshkov 2461*27878615SJohan Hovold ret = qmp_pcie_vreg_init(dev, cfg); 246294a407ccSDmitry Baryshkov if (ret) { 246394a407ccSDmitry Baryshkov if (ret != -EPROBE_DEFER) 246494a407ccSDmitry Baryshkov dev_err(dev, "failed to get regulator supplies: %d\n", 246594a407ccSDmitry Baryshkov ret); 246694a407ccSDmitry Baryshkov return ret; 246794a407ccSDmitry Baryshkov } 246894a407ccSDmitry Baryshkov 246994a407ccSDmitry Baryshkov num = of_get_available_child_count(dev->of_node); 247094a407ccSDmitry Baryshkov /* do we have a rogue child node ? */ 24711239fd71SDmitry Baryshkov if (num > 1) 247294a407ccSDmitry Baryshkov return -EINVAL; 247394a407ccSDmitry Baryshkov 247494a407ccSDmitry Baryshkov qmp->phys = devm_kcalloc(dev, num, sizeof(*qmp->phys), GFP_KERNEL); 247594a407ccSDmitry Baryshkov if (!qmp->phys) 247694a407ccSDmitry Baryshkov return -ENOMEM; 247794a407ccSDmitry Baryshkov 247894a407ccSDmitry Baryshkov pm_runtime_set_active(dev); 247994a407ccSDmitry Baryshkov pm_runtime_enable(dev); 248094a407ccSDmitry Baryshkov /* 248194a407ccSDmitry Baryshkov * Prevent runtime pm from being ON by default. Users can enable 248294a407ccSDmitry Baryshkov * it using power/control in sysfs. 248394a407ccSDmitry Baryshkov */ 248494a407ccSDmitry Baryshkov pm_runtime_forbid(dev); 248594a407ccSDmitry Baryshkov 248694a407ccSDmitry Baryshkov id = 0; 248794a407ccSDmitry Baryshkov for_each_available_child_of_node(dev->of_node, child) { 248894a407ccSDmitry Baryshkov /* Create per-lane phy */ 2489*27878615SJohan Hovold ret = qmp_pcie_create(dev, child, id, serdes, cfg); 249094a407ccSDmitry Baryshkov if (ret) { 249194a407ccSDmitry Baryshkov dev_err(dev, "failed to create lane%d phy, %d\n", 249294a407ccSDmitry Baryshkov id, ret); 249394a407ccSDmitry Baryshkov goto err_node_put; 249494a407ccSDmitry Baryshkov } 249594a407ccSDmitry Baryshkov 249694a407ccSDmitry Baryshkov /* 249794a407ccSDmitry Baryshkov * Register the pipe clock provided by phy. 249894a407ccSDmitry Baryshkov * See function description to see details of this pipe clock. 249994a407ccSDmitry Baryshkov */ 250094a407ccSDmitry Baryshkov ret = phy_pipe_clk_register(qmp, child); 250194a407ccSDmitry Baryshkov if (ret) { 250294a407ccSDmitry Baryshkov dev_err(qmp->dev, 250394a407ccSDmitry Baryshkov "failed to register pipe clock source\n"); 250494a407ccSDmitry Baryshkov goto err_node_put; 250594a407ccSDmitry Baryshkov } 2506da07a06bSDmitry Baryshkov 250794a407ccSDmitry Baryshkov id++; 250894a407ccSDmitry Baryshkov } 250994a407ccSDmitry Baryshkov 251094a407ccSDmitry Baryshkov phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); 251194a407ccSDmitry Baryshkov if (!IS_ERR(phy_provider)) 251294a407ccSDmitry Baryshkov dev_info(dev, "Registered Qcom-QMP phy\n"); 251394a407ccSDmitry Baryshkov else 251494a407ccSDmitry Baryshkov pm_runtime_disable(dev); 251594a407ccSDmitry Baryshkov 251694a407ccSDmitry Baryshkov return PTR_ERR_OR_ZERO(phy_provider); 251794a407ccSDmitry Baryshkov 251894a407ccSDmitry Baryshkov err_node_put: 251994a407ccSDmitry Baryshkov pm_runtime_disable(dev); 252094a407ccSDmitry Baryshkov of_node_put(child); 252194a407ccSDmitry Baryshkov return ret; 252294a407ccSDmitry Baryshkov } 252394a407ccSDmitry Baryshkov 2524*27878615SJohan Hovold static struct platform_driver qmp_pcie_driver = { 2525*27878615SJohan Hovold .probe = qmp_pcie_probe, 252694a407ccSDmitry Baryshkov .driver = { 2527b35a5311SDmitry Baryshkov .name = "qcom-qmp-pcie-phy", 2528*27878615SJohan Hovold .of_match_table = qmp_pcie_of_match_table, 252994a407ccSDmitry Baryshkov }, 253094a407ccSDmitry Baryshkov }; 253194a407ccSDmitry Baryshkov 2532*27878615SJohan Hovold module_platform_driver(qmp_pcie_driver); 253394a407ccSDmitry Baryshkov 253494a407ccSDmitry Baryshkov MODULE_AUTHOR("Vivek Gautam <vivek.gautam@codeaurora.org>"); 2535b35a5311SDmitry Baryshkov MODULE_DESCRIPTION("Qualcomm QMP PCIe PHY driver"); 253694a407ccSDmitry Baryshkov MODULE_LICENSE("GPL v2"); 2537