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_PLL_LOCK_CHK_DLY_TIME, 12594a407ccSDmitry Baryshkov QPHY_FLL_CNTRL1, 12694a407ccSDmitry Baryshkov QPHY_FLL_CNTRL2, 12794a407ccSDmitry Baryshkov QPHY_FLL_CNT_VAL_L, 12894a407ccSDmitry Baryshkov QPHY_FLL_CNT_VAL_H_TOL, 12994a407ccSDmitry Baryshkov QPHY_FLL_MAN_CODE, 13094a407ccSDmitry Baryshkov QPHY_SW_RESET, 13194a407ccSDmitry Baryshkov QPHY_START_CTRL, 13294a407ccSDmitry Baryshkov QPHY_PCS_READY_STATUS, 13394a407ccSDmitry Baryshkov QPHY_PCS_STATUS, 13494a407ccSDmitry Baryshkov QPHY_PCS_AUTONOMOUS_MODE_CTRL, 13594a407ccSDmitry Baryshkov QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR, 13694a407ccSDmitry Baryshkov QPHY_PCS_LFPS_RXTERM_IRQ_STATUS, 13794a407ccSDmitry Baryshkov QPHY_PCS_POWER_DOWN_CONTROL, 13894a407ccSDmitry Baryshkov /* PCS_MISC registers */ 13994a407ccSDmitry Baryshkov QPHY_PCS_MISC_TYPEC_CTRL, 14094a407ccSDmitry Baryshkov /* Keep last to ensure regs_layout arrays are properly initialized */ 14194a407ccSDmitry Baryshkov QPHY_LAYOUT_SIZE 14294a407ccSDmitry Baryshkov }; 14394a407ccSDmitry Baryshkov 14494a407ccSDmitry Baryshkov static const unsigned int ipq_pciephy_gen3_regs_layout[QPHY_LAYOUT_SIZE] = { 14594a407ccSDmitry Baryshkov [QPHY_SW_RESET] = 0x00, 14694a407ccSDmitry Baryshkov [QPHY_START_CTRL] = 0x44, 14794a407ccSDmitry Baryshkov [QPHY_PCS_STATUS] = 0x14, 14894a407ccSDmitry Baryshkov [QPHY_PCS_POWER_DOWN_CONTROL] = 0x40, 14994a407ccSDmitry Baryshkov }; 15094a407ccSDmitry Baryshkov 15194a407ccSDmitry Baryshkov static const unsigned int pciephy_regs_layout[QPHY_LAYOUT_SIZE] = { 15294a407ccSDmitry Baryshkov [QPHY_COM_SW_RESET] = 0x400, 15394a407ccSDmitry Baryshkov [QPHY_COM_POWER_DOWN_CONTROL] = 0x404, 15494a407ccSDmitry Baryshkov [QPHY_COM_START_CONTROL] = 0x408, 15594a407ccSDmitry Baryshkov [QPHY_COM_PCS_READY_STATUS] = 0x448, 15694a407ccSDmitry Baryshkov [QPHY_PLL_LOCK_CHK_DLY_TIME] = 0xa8, 15794a407ccSDmitry Baryshkov [QPHY_FLL_CNTRL1] = 0xc4, 15894a407ccSDmitry Baryshkov [QPHY_FLL_CNTRL2] = 0xc8, 15994a407ccSDmitry Baryshkov [QPHY_FLL_CNT_VAL_L] = 0xcc, 16094a407ccSDmitry Baryshkov [QPHY_FLL_CNT_VAL_H_TOL] = 0xd0, 16194a407ccSDmitry Baryshkov [QPHY_FLL_MAN_CODE] = 0xd4, 16294a407ccSDmitry Baryshkov [QPHY_SW_RESET] = 0x00, 16394a407ccSDmitry Baryshkov [QPHY_START_CTRL] = 0x08, 16494a407ccSDmitry Baryshkov [QPHY_PCS_STATUS] = 0x174, 16594a407ccSDmitry Baryshkov }; 16694a407ccSDmitry Baryshkov 16794a407ccSDmitry Baryshkov static const unsigned int sdm845_qmp_pciephy_regs_layout[QPHY_LAYOUT_SIZE] = { 16894a407ccSDmitry Baryshkov [QPHY_SW_RESET] = 0x00, 16994a407ccSDmitry Baryshkov [QPHY_START_CTRL] = 0x08, 17094a407ccSDmitry Baryshkov [QPHY_PCS_STATUS] = 0x174, 17194a407ccSDmitry Baryshkov }; 17294a407ccSDmitry Baryshkov 17394a407ccSDmitry Baryshkov static const unsigned int sdm845_qhp_pciephy_regs_layout[QPHY_LAYOUT_SIZE] = { 17494a407ccSDmitry Baryshkov [QPHY_SW_RESET] = 0x00, 17594a407ccSDmitry Baryshkov [QPHY_START_CTRL] = 0x08, 17694a407ccSDmitry Baryshkov [QPHY_PCS_STATUS] = 0x2ac, 17794a407ccSDmitry Baryshkov }; 17894a407ccSDmitry Baryshkov 17994a407ccSDmitry Baryshkov static const unsigned int sm8250_pcie_regs_layout[QPHY_LAYOUT_SIZE] = { 18094a407ccSDmitry Baryshkov [QPHY_SW_RESET] = 0x00, 18194a407ccSDmitry Baryshkov [QPHY_START_CTRL] = 0x44, 18294a407ccSDmitry Baryshkov [QPHY_PCS_STATUS] = 0x14, 18394a407ccSDmitry Baryshkov [QPHY_PCS_POWER_DOWN_CONTROL] = 0x40, 18494a407ccSDmitry Baryshkov }; 18594a407ccSDmitry Baryshkov 18694a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl msm8998_pcie_serdes_tbl[] = { 18794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_BIAS_EN_CLKBUFLR_EN, 0x14), 18894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_SELECT, 0x30), 18994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_IVCO, 0x0f), 19094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_CMN_CONFIG, 0x06), 19194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP_EN, 0x01), 19294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_RESETSM_CNTRL, 0x20), 19394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_MAP, 0x00), 19494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE2_MODE0, 0x01), 19594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE1_MODE0, 0xc9), 19694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_TIMER1, 0xff), 19794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_TIMER2, 0x3f), 19894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_SVS_MODE_CLK_SEL, 0x01), 19994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_CORE_CLK_EN, 0x00), 20094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_CORECLK_DIV_MODE0, 0x0a), 20194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_EP_DIV, 0x19), 20294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_ENABLE1, 0x90), 20394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_DEC_START_MODE0, 0x82), 20494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START3_MODE0, 0x03), 20594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START2_MODE0, 0x55), 20694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START1_MODE0, 0x55), 20794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP3_MODE0, 0x00), 20894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP2_MODE0, 0x0d), 20994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP1_MODE0, 0x04), 21094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_HSCLK_SEL, 0x00), 21194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_CP_CTRL_MODE0, 0x08), 21294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_RCTRL_MODE0, 0x16), 21394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_CCTRL_MODE0, 0x34), 21494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_CMN_CONFIG, 0x06), 21594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_SELECT, 0x33), 21694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYS_CLK_CTRL, 0x02), 21794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYSCLK_BUF_ENABLE, 0x07), 21894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYSCLK_EN_SEL, 0x04), 21994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN1_MODE0, 0x00), 22094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN0_MODE0, 0x3f), 22194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_BG_TIMER, 0x09), 22294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_EN_CENTER, 0x01), 22394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_PER1, 0x40), 22494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_PER2, 0x01), 22594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_ADJ_PER1, 0x02), 22694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_ADJ_PER2, 0x00), 22794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_STEP_SIZE1, 0x7e), 22894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_STEP_SIZE2, 0x15), 22994a407ccSDmitry Baryshkov }; 23094a407ccSDmitry Baryshkov 23194a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl msm8998_pcie_tx_tbl[] = { 23294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_TX_RES_CODE_LANE_OFFSET_TX, 0x02), 23394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_TX_RCV_DETECT_LVL_2, 0x12), 23494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_TX_HIGHZ_DRVR_EN, 0x10), 23594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_TX_LANE_MODE_1, 0x06), 23694a407ccSDmitry Baryshkov }; 23794a407ccSDmitry Baryshkov 23894a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl msm8998_pcie_rx_tbl[] = { 23994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_CNTRL, 0x03), 24094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_ENABLES, 0x1c), 24194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_DEGLITCH_CNTRL, 0x14), 24294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL2, 0x0a), 24394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL3, 0x04), 24494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL4, 0x1a), 24594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x4b), 24694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SO_GAIN, 0x04), 24794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SO_GAIN_HALF, 0x04), 24894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1, 0x00), 24994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_OFFSET_ADAPTOR_CNTRL2, 0x80), 25094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_INTERFACE_MODE, 0x40), 25194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_PI_CONTROLS, 0x71), 25294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_FASTLOCK_COUNT_LOW, 0x40), 25394a407ccSDmitry Baryshkov }; 25494a407ccSDmitry Baryshkov 25594a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl msm8998_pcie_pcs_tbl[] = { 25694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V3_PCS_ENDPOINT_REFCLK_DRIVE, 0x04), 25794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V3_PCS_OSC_DTCT_ACTIONS, 0x00), 25894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V3_PCS_PWRUP_RESET_DLY_TIME_AUXCLK, 0x01), 25994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V3_PCS_L1SS_WAKEUP_DLY_TIME_AUXCLK_MSB, 0x00), 26094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V3_PCS_L1SS_WAKEUP_DLY_TIME_AUXCLK_LSB, 0x20), 26194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V3_PCS_LP_WAKEUP_DLY_TIME_AUXCLK_MSB, 0x00), 26294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V3_PCS_LP_WAKEUP_DLY_TIME_AUXCLK, 0x01), 26394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V3_PCS_PLL_LOCK_CHK_DLY_TIME, 0x73), 26494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V3_PCS_RX_SIGDET_LVL, 0x99), 26594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V3_PCS_SIGDET_CNTRL, 0x03), 26694a407ccSDmitry Baryshkov }; 26794a407ccSDmitry Baryshkov 26894a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl ipq6018_pcie_serdes_tbl[] = { 26994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_SSC_PER1, 0x7d), 27094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_SSC_PER2, 0x01), 27194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_SSC_STEP_SIZE1_MODE0, 0x0a), 27294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_SSC_STEP_SIZE2_MODE0, 0x05), 27394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_SSC_STEP_SIZE1_MODE1, 0x08), 27494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_SSC_STEP_SIZE2_MODE1, 0x04), 27594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_BIAS_EN_CLKBUFLR_EN, 0x18), 27694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_CLK_ENABLE1, 0x90), 27794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_SYS_CLK_CTRL, 0x02), 27894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_SYSCLK_BUF_ENABLE, 0x07), 27994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_PLL_IVCO, 0x0f), 28094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_LOCK_CMP1_MODE0, 0xd4), 28194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_LOCK_CMP2_MODE0, 0x14), 28294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_LOCK_CMP1_MODE1, 0xaa), 28394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_LOCK_CMP2_MODE1, 0x29), 28494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_BG_TRIM, 0x0f), 28594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_CP_CTRL_MODE0, 0x09), 28694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_CP_CTRL_MODE1, 0x09), 28794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_PLL_RCTRL_MODE0, 0x16), 28894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_PLL_RCTRL_MODE1, 0x16), 28994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_PLL_CCTRL_MODE0, 0x28), 29094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_PLL_CCTRL_MODE1, 0x28), 29194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_BIAS_EN_CTRL_BY_PSM, 0x01), 29294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_SYSCLK_EN_SEL, 0x08), 29394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_RESETSM_CNTRL, 0x20), 29494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_LOCK_CMP_EN, 0x42), 29594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_DEC_START_MODE0, 0x68), 29694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_DEC_START_MODE1, 0x53), 29794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_DIV_FRAC_START1_MODE0, 0xab), 29894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_DIV_FRAC_START2_MODE0, 0xaa), 29994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_DIV_FRAC_START3_MODE0, 0x02), 30094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_DIV_FRAC_START1_MODE1, 0x55), 30194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_DIV_FRAC_START2_MODE1, 0x55), 30294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_DIV_FRAC_START3_MODE1, 0x05), 30394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_INTEGLOOP_GAIN0_MODE0, 0xa0), 30494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_INTEGLOOP_GAIN0_MODE1, 0xa0), 30594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_VCO_TUNE1_MODE0, 0x24), 30694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_VCO_TUNE2_MODE0, 0x02), 30794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_VCO_TUNE1_MODE1, 0xb4), 30894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_VCO_TUNE2_MODE1, 0x03), 30994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_CLK_SELECT, 0x32), 31094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_HSCLK_SEL, 0x01), 31194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_CORE_CLK_EN, 0x00), 31294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_CMN_CONFIG, 0x06), 31394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_SVS_MODE_CLK_SEL, 0x05), 31494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_PLL_CORECLK_DIV_MODE1, 0x08), 31594a407ccSDmitry Baryshkov }; 31694a407ccSDmitry Baryshkov 31794a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl ipq6018_pcie_tx_tbl[] = { 31894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_TX0_RES_CODE_LANE_OFFSET_TX, 0x02), 31994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_TX0_LANE_MODE_1, 0x06), 32094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_TX0_RCV_DETECT_LVL_2, 0x12), 32194a407ccSDmitry Baryshkov }; 32294a407ccSDmitry Baryshkov 32394a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl ipq6018_pcie_rx_tbl[] = { 32494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_RX0_UCDR_FO_GAIN, 0x0c), 32594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_RX0_UCDR_SO_GAIN, 0x02), 32694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_RX0_UCDR_SO_SATURATION_AND_ENABLE, 0x7f), 32794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_RX0_UCDR_PI_CONTROLS, 0x70), 32894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_RX0_RX_EQU_ADAPTOR_CNTRL2, 0x61), 32994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_RX0_RX_EQU_ADAPTOR_CNTRL3, 0x04), 33094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_RX0_RX_EQU_ADAPTOR_CNTRL4, 0x1e), 33194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_RX0_RX_IDAC_TSETTLE_LOW, 0xc0), 33294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_RX0_RX_IDAC_TSETTLE_HIGH, 0x00), 33394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_RX0_RX_EQ_OFFSET_ADAPTOR_CNTRL1, 0x73), 33494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_RX0_RX_OFFSET_ADAPTOR_CNTRL2, 0x80), 33594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_RX0_SIGDET_ENABLES, 0x1c), 33694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_RX0_SIGDET_CNTRL, 0x03), 33794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_RX0_SIGDET_DEGLITCH_CNTRL, 0x14), 33894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_RX0_RX_MODE_00_LOW, 0xf0), 33994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_RX0_RX_MODE_00_HIGH, 0x01), 34094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_RX0_RX_MODE_00_HIGH2, 0x2f), 34194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_RX0_RX_MODE_00_HIGH3, 0xd3), 34294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_RX0_RX_MODE_00_HIGH4, 0x40), 34394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_RX0_RX_MODE_01_LOW, 0x01), 34494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_RX0_RX_MODE_01_HIGH, 0x02), 34594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_RX0_RX_MODE_01_HIGH2, 0xc8), 34694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_RX0_RX_MODE_01_HIGH3, 0x09), 34794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_RX0_RX_MODE_01_HIGH4, 0xb1), 34894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_RX0_RX_MODE_10_LOW, 0x00), 34994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_RX0_RX_MODE_10_HIGH, 0x02), 35094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_RX0_RX_MODE_10_HIGH2, 0xc8), 35194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_RX0_RX_MODE_10_HIGH3, 0x09), 35294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_RX0_RX_MODE_10_HIGH4, 0xb1), 35394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_RX0_DFE_EN_TIMER, 0x04), 35494a407ccSDmitry Baryshkov }; 35594a407ccSDmitry Baryshkov 35694a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl ipq6018_pcie_pcs_tbl[] = { 35794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCS_COM_FLL_CNTRL1, 0x01), 35894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCS_COM_REFGEN_REQ_CONFIG1, 0x0d), 35994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCS_COM_G12S1_TXDEEMPH_M3P5DB, 0x10), 36094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCS_COM_RX_SIGDET_LVL, 0xaa), 36194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCS_COM_P2U3_WAKEUP_DLY_TIME_AUXCLK_L, 0x01), 36294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCS_COM_RX_DCC_CAL_CONFIG, 0x01), 36394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCS_COM_EQ_CONFIG5, 0x01), 364*af664324SDmitry Baryshkov }; 365*af664324SDmitry Baryshkov 366*af664324SDmitry Baryshkov static const struct qmp_phy_init_tbl ipq6018_pcie_pcs_misc_tbl[] = { 36794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCS_PCIE_POWER_STATE_CONFIG2, 0x0d), 36894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCS_PCIE_POWER_STATE_CONFIG4, 0x07), 36994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCS_PCIE_ENDPOINT_REFCLK_DRIVE, 0xc1), 37094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCS_PCIE_L1P1_WAKEUP_DLY_TIME_AUXCLK_L, 0x01), 37194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCS_PCIE_L1P2_WAKEUP_DLY_TIME_AUXCLK_L, 0x01), 37294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCS_PCIE_OSC_DTCT_ACTIONS, 0x00), 37394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCS_PCIE_EQ_CONFIG1, 0x11), 37494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCS_PCIE_PRESET_P10_PRE, 0x00), 37594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCS_PCIE_PRESET_P10_POST, 0x58), 37694a407ccSDmitry Baryshkov }; 37794a407ccSDmitry Baryshkov 37894a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl ipq8074_pcie_serdes_tbl[] = { 37994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_BIAS_EN_CLKBUFLR_EN, 0x18), 38094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_CLK_ENABLE1, 0x10), 38194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_BG_TRIM, 0xf), 38294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP_EN, 0x1), 38394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_MAP, 0x0), 38494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_TIMER1, 0xff), 38594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_TIMER2, 0x1f), 38694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_CMN_CONFIG, 0x6), 38794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_PLL_IVCO, 0xf), 38894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_HSCLK_SEL, 0x0), 38994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_SVS_MODE_CLK_SEL, 0x1), 39094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_CORE_CLK_EN, 0x20), 39194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_CORECLK_DIV, 0xa), 39294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_RESETSM_CNTRL, 0x20), 39394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_BG_TIMER, 0xa), 39494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_SYSCLK_EN_SEL, 0xa), 39594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_DEC_START_MODE0, 0x82), 39694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_DIV_FRAC_START3_MODE0, 0x3), 39794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_DIV_FRAC_START2_MODE0, 0x55), 39894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_DIV_FRAC_START1_MODE0, 0x55), 39994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP3_MODE0, 0x0), 40094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP2_MODE0, 0xD), 40194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP1_MODE0, 0xD04), 40294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_CLK_SELECT, 0x33), 40394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_SYS_CLK_CTRL, 0x2), 40494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_SYSCLK_BUF_ENABLE, 0x1f), 40594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_CP_CTRL_MODE0, 0xb), 40694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_PLL_RCTRL_MODE0, 0x16), 40794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_PLL_CCTRL_MODE0, 0x28), 40894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_INTEGLOOP_GAIN1_MODE0, 0x0), 40994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_INTEGLOOP_GAIN0_MODE0, 0x80), 41094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_BIAS_EN_CTRL_BY_PSM, 0x1), 41194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_SSC_EN_CENTER, 0x1), 41294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_SSC_PER1, 0x31), 41394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_SSC_PER2, 0x1), 41494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_SSC_ADJ_PER1, 0x2), 41594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_SSC_ADJ_PER2, 0x0), 41694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_SSC_STEP_SIZE1, 0x2f), 41794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_SSC_STEP_SIZE2, 0x19), 41894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_COM_CLK_EP_DIV, 0x19), 41994a407ccSDmitry Baryshkov }; 42094a407ccSDmitry Baryshkov 42194a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl ipq8074_pcie_tx_tbl[] = { 42294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_TX_HIGHZ_TRANSCEIVEREN_BIAS_DRVR_EN, 0x45), 42394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_TX_LANE_MODE, 0x6), 42494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_TX_RES_CODE_LANE_OFFSET, 0x2), 42594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_TX_RCV_DETECT_LVL_2, 0x12), 42694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_TX_EMP_POST1_LVL, 0x36), 42794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_TX_SLEW_CNTL, 0x0a), 42894a407ccSDmitry Baryshkov }; 42994a407ccSDmitry Baryshkov 43094a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl ipq8074_pcie_rx_tbl[] = { 43194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_RX_SIGDET_ENABLES, 0x1c), 43294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_RX_SIGDET_DEGLITCH_CNTRL, 0x14), 43394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_RX_RX_EQU_ADAPTOR_CNTRL2, 0x1), 43494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_RX_RX_EQU_ADAPTOR_CNTRL3, 0x0), 43594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_RX_RX_EQU_ADAPTOR_CNTRL4, 0xdb), 43694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x4b), 43794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_RX_UCDR_SO_GAIN, 0x4), 43894a407ccSDmitry Baryshkov }; 43994a407ccSDmitry Baryshkov 44094a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl ipq8074_pcie_pcs_tbl[] = { 44194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_ENDPOINT_REFCLK_DRIVE, 0x4), 44294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_OSC_DTCT_ACTIONS, 0x0), 44394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_PWRUP_RESET_DLY_TIME_AUXCLK, 0x40), 44494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_L1SS_WAKEUP_DLY_TIME_AUXCLK_MSB, 0x0), 44594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_L1SS_WAKEUP_DLY_TIME_AUXCLK_LSB, 0x40), 44694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_PLL_LOCK_CHK_DLY_TIME_AUXCLK_LSB, 0x0), 44794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_LP_WAKEUP_DLY_TIME_AUXCLK, 0x40), 44894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG_L(QPHY_PLL_LOCK_CHK_DLY_TIME, 0x73), 44994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_RX_SIGDET_LVL, 0x99), 45094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_TXDEEMPH_M6DB_V0, 0x15), 45194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_TXDEEMPH_M3P5DB_V0, 0xe), 45294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG_L(QPHY_SW_RESET, 0x0), 45394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG_L(QPHY_START_CTRL, 0x3), 45494a407ccSDmitry Baryshkov }; 45594a407ccSDmitry Baryshkov 456334fad18SRobert Marko static const struct qmp_phy_init_tbl ipq8074_pcie_gen3_serdes_tbl[] = { 457334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_BIAS_EN_CLKBUFLR_EN, 0x18), 458334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_BIAS_EN_CTRL_BY_PSM, 0x01), 459334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_CLK_SELECT, 0x31), 460334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_PLL_IVCO, 0x0f), 461334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_BG_TRIM, 0x0f), 462334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_CMN_CONFIG, 0x06), 463334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_LOCK_CMP_EN, 0x42), 464334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_RESETSM_CNTRL, 0x20), 465334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_SVS_MODE_CLK_SEL, 0x01), 466334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_VCO_TUNE_MAP, 0x04), 467334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_SVS_MODE_CLK_SEL, 0x05), 468334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_VCO_TUNE_TIMER1, 0xff), 469334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_VCO_TUNE_TIMER2, 0x3f), 470334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_CORE_CLK_EN, 0x30), 471334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_HSCLK_SEL, 0x21), 472334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_DEC_START_MODE0, 0x82), 473334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_DIV_FRAC_START3_MODE0, 0x03), 474334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_DIV_FRAC_START2_MODE0, 0x355), 475334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_DIV_FRAC_START1_MODE0, 0x35555), 476334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_LOCK_CMP2_MODE0, 0x1a), 477334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_LOCK_CMP1_MODE0, 0x1a0a), 478334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_CP_CTRL_MODE0, 0xb), 479334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_PLL_RCTRL_MODE0, 0x16), 480334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_PLL_CCTRL_MODE0, 0x28), 481334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_INTEGLOOP_GAIN1_MODE0, 0x0), 482334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_INTEGLOOP_GAIN0_MODE0, 0x40), 483334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_VCO_TUNE2_MODE0, 0x02), 484334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_VCO_TUNE1_MODE0, 0x24), 485334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_SVS_MODE_CLK_SEL, 0x05), 486334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_CORE_CLK_EN, 0x20), 487334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_CORECLK_DIV, 0xa), 488334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_CLK_SELECT, 0x32), 489334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_SYS_CLK_CTRL, 0x02), 490334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_SYSCLK_BUF_ENABLE, 0x07), 491334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_SYSCLK_EN_SEL, 0x08), 492334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_BG_TIMER, 0xa), 493334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_HSCLK_SEL, 0x1), 494334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_DEC_START_MODE1, 0x68), 495334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_DIV_FRAC_START3_MODE1, 0x2), 496334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_DIV_FRAC_START2_MODE1, 0x2aa), 497334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_DIV_FRAC_START1_MODE1, 0x2aaab), 498334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_CLK_ENABLE1, 0x90), 499334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_LOCK_CMP2_MODE1, 0x34), 500334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_LOCK_CMP1_MODE1, 0x3414), 501334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_CP_CTRL_MODE1, 0x0b), 502334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_PLL_RCTRL_MODE1, 0x16), 503334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_PLL_CCTRL_MODE1, 0x28), 504334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_INTEGLOOP_GAIN1_MODE1, 0x0), 505334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_INTEGLOOP_GAIN0_MODE1, 0x40), 506334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_VCO_TUNE2_MODE1, 0x03), 507334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_VCO_TUNE1_MODE1, 0xb4), 508334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_SVS_MODE_CLK_SEL, 0x05), 509334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_CORE_CLK_EN, 0x0), 510334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_CORECLK_DIV_MODE1, 0x08), 511334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_CLK_EP_DIV_MODE0, 0x19), 512334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_CLK_EP_DIV_MODE1, 0x28), 513334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_PLL_CLK_ENABLE1, 0x90), 514334fad18SRobert Marko }; 515334fad18SRobert Marko 516334fad18SRobert Marko static const struct qmp_phy_init_tbl ipq8074_pcie_gen3_tx_tbl[] = { 517334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_TX0_RES_CODE_LANE_OFFSET_TX, 0x02), 518334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_TX0_RCV_DETECT_LVL_2, 0x12), 519334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_TX0_HIGHZ_DRVR_EN, 0x10), 520334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_TX0_LANE_MODE_1, 0x06), 521334fad18SRobert Marko }; 522334fad18SRobert Marko 523334fad18SRobert Marko static const struct qmp_phy_init_tbl ipq8074_pcie_gen3_rx_tbl[] = { 524334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_RX0_SIGDET_CNTRL, 0x03), 525334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_RX0_SIGDET_ENABLES, 0x1c), 526334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_RX0_SIGDET_DEGLITCH_CNTRL, 0x14), 527334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_RX0_RX_EQU_ADAPTOR_CNTRL2, 0xe), 528334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_RX0_RX_EQU_ADAPTOR_CNTRL3, 0x4), 529334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_RX0_RX_EQU_ADAPTOR_CNTRL4, 0x1b), 530334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_RX0_DFE_EN_TIMER, 0x04), 531334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_RX0_UCDR_SO_SATURATION_AND_ENABLE, 0x7f), 532334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_RX0_UCDR_PI_CONTROLS, 0x70), 533334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_RX0_RX_EQ_OFFSET_ADAPTOR_CNTRL1, 0x73), 534334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_RX0_RX_OFFSET_ADAPTOR_CNTRL2, 0x80), 535334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_RX0_RX_MODE_10_LOW, 0x00), 536334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_RX0_RX_MODE_10_HIGH, 0x02), 537334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_RX0_RX_MODE_10_HIGH2, 0xc8), 538334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_RX0_RX_MODE_10_HIGH3, 0x09), 539334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_RX0_RX_MODE_10_HIGH4, 0xb1), 540334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_RX0_RX_MODE_01_LOW, 0x01), 541334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_RX0_RX_MODE_01_HIGH, 0x02), 542334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_RX0_RX_MODE_01_HIGH2, 0xc8), 543334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_RX0_RX_MODE_01_HIGH3, 0x09), 544334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_RX0_RX_MODE_01_HIGH4, 0xb1), 545334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_RX0_RX_MODE_00_LOW, 0xf0), 546334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_RX0_RX_MODE_00_HIGH, 0x2), 547334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_RX0_RX_MODE_00_HIGH2, 0x2f), 548334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_RX0_RX_MODE_00_HIGH3, 0xd3), 549334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_RX0_RX_MODE_00_HIGH4, 0x40), 550334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_RX0_RX_IDAC_TSETTLE_HIGH, 0x00), 551334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_RX0_RX_IDAC_TSETTLE_LOW, 0xc0), 552334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_RX0_UCDR_FO_GAIN, 0x0c), 553334fad18SRobert Marko QMP_PHY_INIT_CFG(QSERDES_RX0_UCDR_SO_GAIN, 0x02), 554334fad18SRobert Marko }; 555334fad18SRobert Marko 556334fad18SRobert Marko static const struct qmp_phy_init_tbl ipq8074_pcie_gen3_pcs_tbl[] = { 557334fad18SRobert Marko QMP_PHY_INIT_CFG(PCS_COM_FLL_CNTRL2, 0x83), 558334fad18SRobert Marko QMP_PHY_INIT_CFG(PCS_COM_FLL_CNT_VAL_L, 0x9), 559334fad18SRobert Marko QMP_PHY_INIT_CFG(PCS_COM_FLL_CNT_VAL_H_TOL, 0x42), 560334fad18SRobert Marko QMP_PHY_INIT_CFG(PCS_COM_FLL_MAN_CODE, 0x40), 561334fad18SRobert Marko QMP_PHY_INIT_CFG(PCS_COM_FLL_CNTRL1, 0x01), 562334fad18SRobert Marko QMP_PHY_INIT_CFG(PCS_COM_P2U3_WAKEUP_DLY_TIME_AUXCLK_H, 0x0), 563334fad18SRobert Marko QMP_PHY_INIT_CFG(PCS_COM_P2U3_WAKEUP_DLY_TIME_AUXCLK_L, 0x1), 564334fad18SRobert Marko QMP_PHY_INIT_CFG(PCS_PCIE_OSC_DTCT_ACTIONS, 0x0), 565334fad18SRobert Marko QMP_PHY_INIT_CFG(PCS_PCIE_L1P1_WAKEUP_DLY_TIME_AUXCLK_H, 0x00), 566334fad18SRobert Marko QMP_PHY_INIT_CFG(PCS_PCIE_L1P1_WAKEUP_DLY_TIME_AUXCLK_L, 0x01), 567334fad18SRobert Marko QMP_PHY_INIT_CFG(PCS_PCIE_L1P2_WAKEUP_DLY_TIME_AUXCLK_H, 0x00), 568334fad18SRobert Marko QMP_PHY_INIT_CFG(PCS_PCIE_L1P2_WAKEUP_DLY_TIME_AUXCLK_L, 0x01), 569334fad18SRobert Marko QMP_PHY_INIT_CFG(PCS_PCIE_EQ_CONFIG1, 0x11), 570334fad18SRobert Marko QMP_PHY_INIT_CFG(PCS_PCIE_EQ_CONFIG2, 0xb), 571334fad18SRobert Marko QMP_PHY_INIT_CFG(PCS_PCIE_POWER_STATE_CONFIG4, 0x07), 572334fad18SRobert Marko QMP_PHY_INIT_CFG(PCS_PCIE_OSC_DTCT_CONFIG2, 0x52), 573334fad18SRobert Marko QMP_PHY_INIT_CFG(PCS_PCIE_OSC_DTCT_MODE2_CONFIG2, 0x50), 574334fad18SRobert Marko QMP_PHY_INIT_CFG(PCS_PCIE_OSC_DTCT_MODE2_CONFIG4, 0x1a), 575334fad18SRobert Marko QMP_PHY_INIT_CFG(PCS_PCIE_OSC_DTCT_MODE2_CONFIG5, 0x6), 576334fad18SRobert Marko QMP_PHY_INIT_CFG(PCS_COM_G12S1_TXDEEMPH_M3P5DB, 0x10), 577334fad18SRobert Marko QMP_PHY_INIT_CFG(PCS_PCIE_ENDPOINT_REFCLK_DRIVE, 0xc1), 578334fad18SRobert Marko QMP_PHY_INIT_CFG(PCS_COM_RX_DCC_CAL_CONFIG, 0x01), 579334fad18SRobert Marko QMP_PHY_INIT_CFG(PCS_COM_RX_SIGDET_LVL, 0xaa), 580334fad18SRobert Marko QMP_PHY_INIT_CFG(PCS_COM_REFGEN_REQ_CONFIG1, 0x0d), 581334fad18SRobert Marko }; 582334fad18SRobert Marko 58394a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sdm845_qmp_pcie_serdes_tbl[] = { 58494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_BIAS_EN_CLKBUFLR_EN, 0x14), 58594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_SELECT, 0x30), 58694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_IVCO, 0x007), 58794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_CMN_CONFIG, 0x06), 58894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP_EN, 0x01), 58994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_RESETSM_CNTRL, 0x20), 59094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_MAP, 0x00), 59194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE2_MODE0, 0x01), 59294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE1_MODE0, 0xc9), 59394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_TIMER1, 0xff), 59494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_TIMER2, 0x3f), 59594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_SVS_MODE_CLK_SEL, 0x01), 59694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_CORE_CLK_EN, 0x00), 59794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_CORECLK_DIV_MODE0, 0x0a), 59894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_EP_DIV, 0x19), 59994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_ENABLE1, 0x90), 60094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_DEC_START_MODE0, 0x82), 60194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START3_MODE0, 0x02), 60294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START2_MODE0, 0xea), 60394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START1_MODE0, 0xab), 60494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP3_MODE0, 0x00), 60594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP2_MODE0, 0x0d), 60694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP1_MODE0, 0x04), 60794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_HSCLK_SEL, 0x00), 60894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_CP_CTRL_MODE0, 0x06), 60994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_RCTRL_MODE0, 0x16), 61094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_CCTRL_MODE0, 0x36), 61194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_CMN_MODE, 0x01), 61294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_SELECT, 0x33), 61394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYS_CLK_CTRL, 0x02), 61494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYSCLK_BUF_ENABLE, 0x06), 61594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYSCLK_EN_SEL, 0x04), 61694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN1_MODE0, 0x00), 61794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN0_MODE0, 0x3f), 61894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_BG_TIMER, 0x09), 61994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_EN_CENTER, 0x01), 62094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_PER1, 0x40), 62194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_PER2, 0x01), 62294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_ADJ_PER1, 0x02), 62394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_ADJ_PER2, 0x00), 62494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_STEP_SIZE1, 0x7e), 62594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_STEP_SIZE2, 0x15), 62694a407ccSDmitry Baryshkov }; 62794a407ccSDmitry Baryshkov 62894a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sdm845_qmp_pcie_tx_tbl[] = { 62994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_TX_RES_CODE_LANE_OFFSET_TX, 0x02), 63094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_TX_RCV_DETECT_LVL_2, 0x12), 63194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_TX_HIGHZ_DRVR_EN, 0x10), 63294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_TX_LANE_MODE_1, 0x06), 63394a407ccSDmitry Baryshkov }; 63494a407ccSDmitry Baryshkov 63594a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sdm845_qmp_pcie_rx_tbl[] = { 63694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_CNTRL, 0x03), 63794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_ENABLES, 0x10), 63894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_DEGLITCH_CNTRL, 0x14), 63994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL2, 0x0e), 64094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL3, 0x04), 64194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL4, 0x1a), 64294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x4b), 64394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SO_GAIN, 0x04), 64494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SO_GAIN_HALF, 0x04), 64594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1, 0x71), 64694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_MODE_00, 0x59), 64794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_MODE_01, 0x59), 64894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_OFFSET_ADAPTOR_CNTRL2, 0x80), 64994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_INTERFACE_MODE, 0x40), 65094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_PI_CONTROLS, 0x71), 65194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_FASTLOCK_COUNT_LOW, 0x40), 65294a407ccSDmitry Baryshkov }; 65394a407ccSDmitry Baryshkov 65494a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sdm845_qmp_pcie_pcs_tbl[] = { 65594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V3_PCS_ENDPOINT_REFCLK_DRIVE, 0x04), 65694a407ccSDmitry Baryshkov 65794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNTRL2, 0x83), 65894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNT_VAL_L, 0x09), 65994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNT_VAL_H_TOL, 0xa2), 66094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_MAN_CODE, 0x40), 66194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNTRL1, 0x02), 66294a407ccSDmitry Baryshkov 66394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V3_PCS_OSC_DTCT_ACTIONS, 0x00), 66494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V3_PCS_PWRUP_RESET_DLY_TIME_AUXCLK, 0x01), 66594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V3_PCS_L1SS_WAKEUP_DLY_TIME_AUXCLK_MSB, 0x00), 66694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V3_PCS_L1SS_WAKEUP_DLY_TIME_AUXCLK_LSB, 0x20), 66794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V3_PCS_LP_WAKEUP_DLY_TIME_AUXCLK_MSB, 0x00), 66894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V3_PCS_LP_WAKEUP_DLY_TIME_AUXCLK, 0x01), 66994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V3_PCS_PLL_LOCK_CHK_DLY_TIME, 0x73), 67094a407ccSDmitry Baryshkov 67194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V3_PCS_RX_SIGDET_LVL, 0xbb), 67294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V3_PCS_SIGDET_CNTRL, 0x03), 67394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V3_PCS_REFGEN_REQ_CONFIG1, 0x0d), 67494a407ccSDmitry Baryshkov 67594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V3_PCS_POWER_STATE_CONFIG4, 0x00), 67694a407ccSDmitry Baryshkov }; 67794a407ccSDmitry Baryshkov 67894a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sdm845_qmp_pcie_pcs_misc_tbl[] = { 67994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V3_PCS_MISC_OSC_DTCT_CONFIG2, 0x52), 68094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V3_PCS_MISC_OSC_DTCT_MODE2_CONFIG2, 0x10), 68194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V3_PCS_MISC_OSC_DTCT_MODE2_CONFIG4, 0x1a), 68294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V3_PCS_MISC_OSC_DTCT_MODE2_CONFIG5, 0x06), 68394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V3_PCS_MISC_PCIE_INT_AUX_CLK_CONFIG1, 0x00), 68494a407ccSDmitry Baryshkov }; 68594a407ccSDmitry Baryshkov 68694a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sdm845_qhp_pcie_serdes_tbl[] = { 68794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_SYSCLK_EN_SEL, 0x27), 68894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_SSC_EN_CENTER, 0x01), 68994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_SSC_PER1, 0x31), 69094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_SSC_PER2, 0x01), 69194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_SSC_STEP_SIZE1, 0xde), 69294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_SSC_STEP_SIZE2, 0x07), 69394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_SSC_STEP_SIZE1_MODE1, 0x4c), 69494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_SSC_STEP_SIZE2_MODE1, 0x06), 69594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_BIAS_EN_CKBUFLR_EN, 0x18), 69694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_CLK_ENABLE1, 0xb0), 69794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_LOCK_CMP1_MODE0, 0x8c), 69894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_LOCK_CMP2_MODE0, 0x20), 69994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_LOCK_CMP1_MODE1, 0x14), 70094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_LOCK_CMP2_MODE1, 0x34), 70194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_CP_CTRL_MODE0, 0x06), 70294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_CP_CTRL_MODE1, 0x06), 70394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_PLL_RCTRL_MODE0, 0x16), 70494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_PLL_RCTRL_MODE1, 0x16), 70594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_PLL_CCTRL_MODE0, 0x36), 70694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_PLL_CCTRL_MODE1, 0x36), 70794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_RESTRIM_CTRL2, 0x05), 70894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_LOCK_CMP_EN, 0x42), 70994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_DEC_START_MODE0, 0x82), 71094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_DEC_START_MODE1, 0x68), 71194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_DIV_FRAC_START1_MODE0, 0x55), 71294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_DIV_FRAC_START2_MODE0, 0x55), 71394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_DIV_FRAC_START3_MODE0, 0x03), 71494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_DIV_FRAC_START1_MODE1, 0xab), 71594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_DIV_FRAC_START2_MODE1, 0xaa), 71694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_DIV_FRAC_START3_MODE1, 0x02), 71794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_INTEGLOOP_GAIN0_MODE0, 0x3f), 71894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_INTEGLOOP_GAIN0_MODE1, 0x3f), 71994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_VCO_TUNE_MAP, 0x10), 72094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_CLK_SELECT, 0x04), 72194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_HSCLK_SEL1, 0x30), 72294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_CORECLK_DIV, 0x04), 72394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_CORE_CLK_EN, 0x73), 72494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_CMN_CONFIG, 0x0c), 72594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_SVS_MODE_CLK_SEL, 0x15), 72694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_CORECLK_DIV_MODE1, 0x04), 72794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_CMN_MODE, 0x01), 72894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_VREGCLK_DIV1, 0x22), 72994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_VREGCLK_DIV2, 0x00), 73094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_BGV_TRIM, 0x20), 73194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_BG_CTRL, 0x07), 73294a407ccSDmitry Baryshkov }; 73394a407ccSDmitry Baryshkov 73494a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sdm845_qhp_pcie_tx_tbl[] = { 73594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_DRVR_CTRL0, 0x00), 73694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_DRVR_TAP_EN, 0x0d), 73794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_TX_BAND_MODE, 0x01), 73894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_LANE_MODE, 0x1a), 73994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_PARALLEL_RATE, 0x2f), 74094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_CML_CTRL_MODE0, 0x09), 74194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_CML_CTRL_MODE1, 0x09), 74294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_CML_CTRL_MODE2, 0x1b), 74394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_PREAMP_CTRL_MODE1, 0x01), 74494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_PREAMP_CTRL_MODE2, 0x07), 74594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_MIXER_CTRL_MODE0, 0x31), 74694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_MIXER_CTRL_MODE1, 0x31), 74794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_MIXER_CTRL_MODE2, 0x03), 74894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_CTLE_THRESH_DFE, 0x02), 74994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_CGA_THRESH_DFE, 0x00), 75094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RXENGINE_EN0, 0x12), 75194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_CTLE_TRAIN_TIME, 0x25), 75294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_CTLE_DFE_OVRLP_TIME, 0x00), 75394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_DFE_REFRESH_TIME, 0x05), 75494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_DFE_ENABLE_TIME, 0x01), 75594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_VGA_GAIN, 0x26), 75694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_DFE_GAIN, 0x12), 75794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_EQ_GAIN, 0x04), 75894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_OFFSET_GAIN, 0x04), 75994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_PRE_GAIN, 0x09), 76094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_EQ_INTVAL, 0x15), 76194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_EDAC_INITVAL, 0x28), 76294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RXEQ_INITB0, 0x7f), 76394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RXEQ_INITB1, 0x07), 76494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RCVRDONE_THRESH1, 0x04), 76594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RXEQ_CTRL, 0x70), 76694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_UCDR_FO_GAIN_MODE0, 0x8b), 76794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_UCDR_FO_GAIN_MODE1, 0x08), 76894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_UCDR_FO_GAIN_MODE2, 0x0a), 76994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_UCDR_SO_GAIN_MODE0, 0x03), 77094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_UCDR_SO_GAIN_MODE1, 0x04), 77194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_UCDR_SO_GAIN_MODE2, 0x04), 77294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_UCDR_SO_CONFIG, 0x0c), 77394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RX_BAND, 0x02), 77494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RX_RCVR_PATH1_MODE0, 0x5c), 77594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RX_RCVR_PATH1_MODE1, 0x3e), 77694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RX_RCVR_PATH1_MODE2, 0x3f), 77794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_SIGDET_ENABLES, 0x01), 77894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_SIGDET_CNTRL, 0xa0), 77994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_SIGDET_DEGLITCH_CNTRL, 0x08), 78094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_DCC_GAIN, 0x01), 78194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RX_EN_SIGNAL, 0xc3), 78294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_PSM_RX_EN_CAL, 0x00), 78394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RX_MISC_CNTRL0, 0xbc), 78494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_TS0_TIMER, 0x7f), 78594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_DLL_HIGHDATARATE, 0x15), 78694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_DRVR_CTRL1, 0x0c), 78794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_DRVR_CTRL2, 0x0f), 78894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RX_RESETCODE_OFFSET, 0x04), 78994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_VGA_INITVAL, 0x20), 79094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RSM_START, 0x01), 79194a407ccSDmitry Baryshkov }; 79294a407ccSDmitry Baryshkov 79394a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sdm845_qhp_pcie_rx_tbl[] = { 79494a407ccSDmitry Baryshkov }; 79594a407ccSDmitry Baryshkov 79694a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sdm845_qhp_pcie_pcs_tbl[] = { 79794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_PHY_POWER_STATE_CONFIG, 0x3f), 79894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_PHY_PCS_TX_RX_CONFIG, 0x50), 79994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_PHY_TXMGN_MAIN_V0_M3P5DB, 0x19), 80094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_PHY_TXMGN_POST_V0_M3P5DB, 0x07), 80194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_PHY_TXMGN_MAIN_V0_M6DB, 0x17), 80294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_PHY_TXMGN_POST_V0_M6DB, 0x09), 80394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_PHY_POWER_STATE_CONFIG5, 0x9f), 80494a407ccSDmitry Baryshkov }; 80594a407ccSDmitry Baryshkov 80694a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sc8180x_qmp_pcie_serdes_tbl[] = { 80794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_SYSCLK_EN_SEL, 0x08), 80894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_CLK_SELECT, 0x34), 80994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_CORECLK_DIV_MODE1, 0x08), 81094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_IVCO, 0x0f), 81194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP_EN, 0x42), 81294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE1_MODE0, 0x24), 81394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE2_MODE1, 0x03), 81494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE1_MODE1, 0xb4), 81594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE_MAP, 0x02), 81694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_HSCLK_SEL, 0x11), 81794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_DEC_START_MODE0, 0x82), 81894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START3_MODE0, 0x03), 81994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START2_MODE0, 0x55), 82094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START1_MODE0, 0x55), 82194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP2_MODE0, 0x1a), 82294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP1_MODE0, 0x0a), 82394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_DEC_START_MODE1, 0x68), 82494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START3_MODE1, 0x02), 82594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START2_MODE1, 0xaa), 82694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START1_MODE1, 0xab), 82794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP2_MODE1, 0x34), 82894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP1_MODE1, 0x14), 82994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_HSCLK_SEL, 0x01), 83094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_CP_CTRL_MODE0, 0x06), 83194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_RCTRL_MODE0, 0x16), 83294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_CCTRL_MODE0, 0x36), 83394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_CP_CTRL_MODE1, 0x06), 83494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_RCTRL_MODE1, 0x16), 83594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_CCTRL_MODE1, 0x36), 83694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE2_MODE0, 0x1e), 83794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE1_MODE0, 0xca), 83894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE2_MODE1, 0x18), 83994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE1_MODE1, 0xa2), 84094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_SYSCLK_BUF_ENABLE, 0x07), 84194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_EN_CENTER, 0x01), 84294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_PER1, 0x31), 84394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_PER2, 0x01), 84494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_STEP_SIZE1_MODE0, 0xde), 84594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_STEP_SIZE2_MODE0, 0x07), 84694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_STEP_SIZE1_MODE1, 0x4c), 84794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_STEP_SIZE2_MODE1, 0x06), 84894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_CLK_ENABLE1, 0x90), 84994a407ccSDmitry Baryshkov }; 85094a407ccSDmitry Baryshkov 85194a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sc8180x_qmp_pcie_tx_tbl[] = { 85294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_TX_RCV_DETECT_LVL_2, 0x12), 85394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_TX_LANE_MODE_1, 0x5), 85494a407ccSDmitry Baryshkov }; 85594a407ccSDmitry Baryshkov 85694a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sc8180x_qmp_pcie_rx_tbl[] = { 85794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_CNTRL, 0x03), 85894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_ENABLES, 0x1c), 85994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_DEGLITCH_CNTRL, 0x14), 86094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL1, 0x07), 86194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL2, 0x6e), 86294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL3, 0x6e), 86394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL4, 0x4a), 86494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_DFE_EN_TIMER, 0x04), 86594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x7f), 86694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_PI_CONTROLS, 0x70), 86794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1, 0x17), 86894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_VGA_CAL_CNTRL1, 0x54), 86994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_VGA_CAL_CNTRL2, 0x37), 87094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_LOW, 0xd4), 87194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH, 0x54), 87294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH2, 0xdb), 87394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH3, 0x39), 87494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH4, 0x31), 87594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_LOW, 0x24), 87694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH, 0xe4), 87794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH2, 0xec), 87894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH3, 0x39), 87994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH4, 0x36), 88094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_LOW, 0x7f), 88194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH, 0xff), 88294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH2, 0xff), 88394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH3, 0xdb), 88494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH4, 0x75), 88594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_IDAC_TSETTLE_HIGH, 0x00), 88694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_IDAC_TSETTLE_LOW, 0xc0), 88794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_AUX_DATA_TCOARSE_TFINE, 0xa0), 88894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RCLK_AUXDATA_SEL, 0xc0), 88994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_DCC_CTRL1, 0x0c), 89094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_GM_CAL, 0x05), 89194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_FO_GAIN, 0x0c), 89294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SO_GAIN, 0x03), 89394a407ccSDmitry Baryshkov }; 89494a407ccSDmitry Baryshkov 89594a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sc8180x_qmp_pcie_pcs_tbl[] = { 89694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_P2U3_WAKEUP_DLY_TIME_AUXCLK_L, 0x01), 89794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_RX_SIGDET_LVL, 0xaa), 89894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_RATE_SLEW_CNTRL1, 0x0b), 89994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_REFGEN_REQ_CONFIG1, 0x0d), 90094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_EQ_CONFIG5, 0x01), 90194a407ccSDmitry Baryshkov }; 90294a407ccSDmitry Baryshkov 90394a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sc8180x_qmp_pcie_pcs_misc_tbl[] = { 90494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_OSC_DTCT_ACTIONS, 0x00), 90594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_L1P1_WAKEUP_DLY_TIME_AUXCLK_L, 0x01), 90694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_L1P2_WAKEUP_DLY_TIME_AUXCLK_L, 0x01), 90794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_INT_AUX_CLK_CONFIG1, 0x00), 90894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_PRESET_P10_PRE, 0x00), 90994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_PRESET_P10_POST, 0x58), 91094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_ENDPOINT_REFCLK_DRIVE, 0xc1), 91194a407ccSDmitry Baryshkov }; 91294a407ccSDmitry Baryshkov 91394a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8250_qmp_pcie_serdes_tbl[] = { 91494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_SYSCLK_EN_SEL, 0x08), 91594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_CLK_SELECT, 0x34), 91694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_CORECLK_DIV_MODE1, 0x08), 91794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_IVCO, 0x0f), 91894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP_EN, 0x42), 91994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE1_MODE0, 0x24), 92094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE2_MODE1, 0x03), 92194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE1_MODE1, 0xb4), 92294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE_MAP, 0x02), 92394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_HSCLK_SEL, 0x11), 92494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_DEC_START_MODE0, 0x82), 92594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START3_MODE0, 0x03), 92694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START2_MODE0, 0x55), 92794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START1_MODE0, 0x55), 92894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP2_MODE0, 0x1a), 92994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP1_MODE0, 0x0a), 93094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_DEC_START_MODE1, 0x68), 93194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START3_MODE1, 0x02), 93294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START2_MODE1, 0xaa), 93394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START1_MODE1, 0xab), 93494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP2_MODE1, 0x34), 93594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP1_MODE1, 0x14), 93694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_HSCLK_SEL, 0x01), 93794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_CP_CTRL_MODE0, 0x06), 93894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_RCTRL_MODE0, 0x16), 93994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_CCTRL_MODE0, 0x36), 94094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_CP_CTRL_MODE1, 0x06), 94194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_RCTRL_MODE1, 0x16), 94294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_CCTRL_MODE1, 0x36), 94394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE2_MODE0, 0x1e), 94494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE1_MODE0, 0xca), 94594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE2_MODE1, 0x18), 94694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE1_MODE1, 0xa2), 94794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_EN_CENTER, 0x01), 94894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_PER1, 0x31), 94994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_PER2, 0x01), 95094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_STEP_SIZE1_MODE0, 0xde), 95194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_STEP_SIZE2_MODE0, 0x07), 95294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_STEP_SIZE1_MODE1, 0x4c), 95394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_STEP_SIZE2_MODE1, 0x06), 95494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_CLK_ENABLE1, 0x90), 95594a407ccSDmitry Baryshkov }; 95694a407ccSDmitry Baryshkov 95794a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8250_qmp_gen3x1_pcie_serdes_tbl[] = { 95894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_SYSCLK_BUF_ENABLE, 0x07), 95994a407ccSDmitry Baryshkov }; 96094a407ccSDmitry Baryshkov 96194a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8250_qmp_pcie_tx_tbl[] = { 96294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_TX_RCV_DETECT_LVL_2, 0x12), 96394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_TX_LANE_MODE_1, 0x35), 96494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_TX_RES_CODE_LANE_OFFSET_TX, 0x11), 96594a407ccSDmitry Baryshkov }; 96694a407ccSDmitry Baryshkov 96794a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8250_qmp_pcie_rx_tbl[] = { 96894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_FO_GAIN, 0x0c), 96994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SO_GAIN, 0x03), 97094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_GM_CAL, 0x1b), 97194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_IDAC_TSETTLE_HIGH, 0x00), 97294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_IDAC_TSETTLE_LOW, 0xc0), 97394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_AUX_DATA_TCOARSE_TFINE, 0x30), 97494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_VGA_CAL_CNTRL1, 0x04), 97594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_VGA_CAL_CNTRL2, 0x07), 97694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x7f), 97794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_PI_CONTROLS, 0x70), 97894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL2, 0x0e), 97994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL3, 0x4a), 98094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL4, 0x0f), 98194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_CNTRL, 0x03), 98294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_ENABLES, 0x1c), 98394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_DEGLITCH_CNTRL, 0x1e), 98494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1, 0x17), 98594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_LOW, 0xd4), 98694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH, 0x54), 98794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH2, 0xdb), 98894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH3, 0x3b), 98994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH4, 0x31), 99094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_LOW, 0x24), 99194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH2, 0xff), 99294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH3, 0x7f), 99394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_DCC_CTRL1, 0x0c), 99494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH, 0xe4), 99594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH2, 0xec), 99694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH3, 0x3b), 99794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH4, 0x36), 99894a407ccSDmitry Baryshkov }; 99994a407ccSDmitry Baryshkov 100094a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8250_qmp_gen3x1_pcie_rx_tbl[] = { 100194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RCLK_AUXDATA_SEL, 0x00), 100294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL1, 0x00), 100394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_DFE_EN_TIMER, 0x04), 100494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_LOW, 0x3f), 100594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH4, 0x14), 100694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_DFE_CTLE_POST_CAL_OFFSET, 0x30), 100794a407ccSDmitry Baryshkov }; 100894a407ccSDmitry Baryshkov 100994a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8250_qmp_pcie_pcs_tbl[] = { 101094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_P2U3_WAKEUP_DLY_TIME_AUXCLK_L, 0x01), 101194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_RX_SIGDET_LVL, 0x77), 101294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_RATE_SLEW_CNTRL1, 0x0b), 101394a407ccSDmitry Baryshkov }; 101494a407ccSDmitry Baryshkov 101594a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8250_qmp_gen3x1_pcie_pcs_tbl[] = { 101694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_REFGEN_REQ_CONFIG1, 0x0d), 101794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_EQ_CONFIG5, 0x12), 101894a407ccSDmitry Baryshkov }; 101994a407ccSDmitry Baryshkov 102094a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8250_qmp_pcie_pcs_misc_tbl[] = { 102194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_OSC_DTCT_ACTIONS, 0x00), 102294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_L1P1_WAKEUP_DLY_TIME_AUXCLK_L, 0x01), 102394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_L1P2_WAKEUP_DLY_TIME_AUXCLK_L, 0x01), 102494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_PRESET_P6_P7_PRE, 0x33), 102594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_PRESET_P10_PRE, 0x00), 102694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_PRESET_P10_POST, 0x58), 102794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_ENDPOINT_REFCLK_DRIVE, 0xc1), 102894a407ccSDmitry Baryshkov }; 102994a407ccSDmitry Baryshkov 103094a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8250_qmp_gen3x1_pcie_pcs_misc_tbl[] = { 103194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_INT_AUX_CLK_CONFIG1, 0x00), 103294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_EQ_CONFIG2, 0x0f), 103394a407ccSDmitry Baryshkov }; 103494a407ccSDmitry Baryshkov 103594a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8250_qmp_gen3x2_pcie_tx_tbl[] = { 103694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_TX_PI_QEC_CTRL, 0x20), 103794a407ccSDmitry Baryshkov }; 103894a407ccSDmitry Baryshkov 103994a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8250_qmp_gen3x2_pcie_rx_tbl[] = { 104094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL1, 0x04), 104194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_LOW, 0xbf), 104294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH4, 0x15), 104394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_RX_DFE_CTLE_POST_CAL_OFFSET, 0x38), 104494a407ccSDmitry Baryshkov }; 104594a407ccSDmitry Baryshkov 104694a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8250_qmp_gen3x2_pcie_pcs_tbl[] = { 104794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_REFGEN_REQ_CONFIG1, 0x05), 104894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_EQ_CONFIG2, 0x0f), 104994a407ccSDmitry Baryshkov }; 105094a407ccSDmitry Baryshkov 105194a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8250_qmp_gen3x2_pcie_pcs_misc_tbl[] = { 105294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_POWER_STATE_CONFIG2, 0x0d), 105394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_POWER_STATE_CONFIG4, 0x07), 105494a407ccSDmitry Baryshkov }; 105594a407ccSDmitry Baryshkov 105694a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sdx55_qmp_pcie_serdes_tbl[] = { 105794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_BG_TIMER, 0x02), 105894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIAS_EN_CLKBUFLR_EN, 0x18), 105994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_SYS_CLK_CTRL, 0x07), 106094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_IVCO, 0x0f), 106194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_CP_CTRL_MODE0, 0x0a), 106294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_CP_CTRL_MODE1, 0x0a), 106394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_RCTRL_MODE0, 0x19), 106494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_RCTRL_MODE1, 0x19), 106594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_CCTRL_MODE0, 0x03), 106694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_CCTRL_MODE1, 0x03), 106794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_SYSCLK_EN_SEL, 0x00), 106894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP_EN, 0x46), 106994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP_CFG, 0x04), 107094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP1_MODE0, 0x7f), 107194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP2_MODE0, 0x02), 107294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP1_MODE1, 0xff), 107394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP2_MODE1, 0x04), 107494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_DEC_START_MODE0, 0x4b), 107594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_DEC_START_MODE1, 0x50), 107694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START3_MODE0, 0x00), 107794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_INTEGLOOP_GAIN0_MODE0, 0xfb), 107894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_INTEGLOOP_GAIN1_MODE0, 0x01), 107994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_INTEGLOOP_GAIN0_MODE1, 0xfb), 108094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_INTEGLOOP_GAIN1_MODE1, 0x01), 108194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE_MAP, 0x02), 108294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_HSCLK_SEL, 0x12), 108394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_HSCLK_HS_SWITCH_SEL, 0x00), 108494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_CORECLK_DIV_MODE0, 0x05), 108594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_CORECLK_DIV_MODE1, 0x04), 108694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_CMN_CONFIG, 0x04), 108794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_CMN_MISC1, 0x88), 108894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_INTERNAL_DIG_CORECLK_DIV, 0x03), 108994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_CMN_MODE, 0x17), 109094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_DC_LEVEL_CTRL, 0x0b), 109194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE1_MODE0, 0x56), 109294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE2_MODE0, 0x1d), 109394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE1_MODE1, 0x4b), 109494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE2_MODE1, 0x1f), 109594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_HSCLK_SEL, 0x22), 109694a407ccSDmitry Baryshkov }; 109794a407ccSDmitry Baryshkov 109894a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sdx55_qmp_pcie_tx_tbl[] = { 109994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_20_TX_LANE_MODE_1, 0x05), 110094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_20_TX_LANE_MODE_2, 0xf6), 110194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_20_TX_LANE_MODE_3, 0x13), 110294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_20_TX_VMODE_CTRL1, 0x00), 110394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_20_TX_PI_QEC_CTRL, 0x00), 110494a407ccSDmitry Baryshkov }; 110594a407ccSDmitry Baryshkov 110694a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sdx55_qmp_pcie_rx_tbl[] = { 110794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_FO_GAIN_RATE2, 0x0c), 110894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_UCDR_PI_CONTROLS, 0x16), 110994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_AUX_DATA_TCOARSE_TFINE, 0x7f), 111094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_DFE_3, 0x55), 111194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_DFE_DAC_ENABLE1, 0x0c), 111294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_DFE_DAC_ENABLE2, 0x00), 111394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_VGA_CAL_CNTRL2, 0x08), 111494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1, 0x27), 111594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE_0_1_B1, 0x1a), 111694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE_0_1_B2, 0x5a), 111794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE_0_1_B3, 0x09), 111894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE_0_1_B4, 0x37), 111994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE2_B0, 0xbd), 112094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE2_B1, 0xf9), 112194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE2_B2, 0xbf), 112294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE2_B3, 0xce), 112394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE2_B4, 0x62), 112494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE3_B0, 0xbf), 112594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE3_B1, 0x7d), 112694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE3_B2, 0xbf), 112794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE3_B3, 0xcf), 112894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE3_B4, 0xd6), 112994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_PHPRE_CTRL, 0xa0), 113094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_DFE_CTLE_POST_CAL_OFFSET, 0x38), 113194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_MARG_COARSE_CTRL2, 0x12), 113294a407ccSDmitry Baryshkov }; 113394a407ccSDmitry Baryshkov 113494a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sdx55_qmp_pcie_pcs_tbl[] = { 113594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_20_PCS_RX_SIGDET_LVL, 0x77), 113694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_20_PCS_EQ_CONFIG2, 0x01), 113794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_20_PCS_EQ_CONFIG4, 0x16), 113894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_20_PCS_EQ_CONFIG5, 0x02), 113994a407ccSDmitry Baryshkov }; 114094a407ccSDmitry Baryshkov 114194a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sdx55_qmp_pcie_pcs_misc_tbl[] = { 114294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_20_PCS_PCIE_EQ_CONFIG1, 0x17), 114394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_20_PCS_PCIE_G3_RXEQEVAL_TIME, 0x13), 114494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_20_PCS_PCIE_G4_RXEQEVAL_TIME, 0x13), 114594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_20_PCS_PCIE_G4_EQ_CONFIG2, 0x01), 114694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_20_PCS_PCIE_G4_EQ_CONFIG5, 0x02), 114794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_20_PCS_LANE1_INSIG_SW_CTRL2, 0x00), 114894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V4_20_PCS_LANE1_INSIG_MX_CTRL2, 0x00), 114994a407ccSDmitry Baryshkov }; 115094a407ccSDmitry Baryshkov 115194a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8450_qmp_gen3x1_pcie_serdes_tbl[] = { 115294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_SYSCLK_EN_SEL, 0x08), 115394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_CLK_SELECT, 0x34), 115494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_CORECLK_DIV_MODE1, 0x08), 115594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_IVCO, 0x0f), 115694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP_EN, 0x42), 115794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_VCO_TUNE1_MODE0, 0x24), 115894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_VCO_TUNE2_MODE1, 0x03), 115994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_VCO_TUNE1_MODE1, 0xb4), 116094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_VCO_TUNE_MAP, 0x02), 116194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_BIN_VCOCAL_HSCLK_SEL, 0x11), 116294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_DEC_START_MODE0, 0x82), 116394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START3_MODE0, 0x03), 116494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START2_MODE0, 0x55), 116594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START1_MODE0, 0x55), 116694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP2_MODE0, 0x1a), 116794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP1_MODE0, 0x0a), 116894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_DEC_START_MODE1, 0x68), 116994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START3_MODE1, 0x02), 117094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START2_MODE1, 0xaa), 117194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START1_MODE1, 0xab), 117294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP2_MODE1, 0x34), 117394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP1_MODE1, 0x14), 117494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_HSCLK_SEL, 0x01), 117594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_CP_CTRL_MODE0, 0x06), 117694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_RCTRL_MODE0, 0x16), 117794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_CCTRL_MODE0, 0x36), 117894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_CP_CTRL_MODE1, 0x06), 117994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_RCTRL_MODE1, 0x16), 118094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_CCTRL_MODE1, 0x36), 118194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_BIN_VCOCAL_CMP_CODE2_MODE0, 0x1e), 118294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_BIN_VCOCAL_CMP_CODE1_MODE0, 0xca), 118394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_BIN_VCOCAL_CMP_CODE2_MODE1, 0x18), 118494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_BIN_VCOCAL_CMP_CODE1_MODE1, 0xa2), 118594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_SYSCLK_BUF_ENABLE, 0x07), 118694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_EN_CENTER, 0x01), 118794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_PER1, 0x31), 118894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_PER2, 0x01), 118994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_STEP_SIZE1_MODE0, 0xde), 119094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_STEP_SIZE2_MODE0, 0x07), 119194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_STEP_SIZE1_MODE1, 0x4c), 119294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_STEP_SIZE2_MODE1, 0x06), 119394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_CLK_ENABLE1, 0x90), 119494a407ccSDmitry Baryshkov }; 119594a407ccSDmitry Baryshkov 119694a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8450_qmp_gen3x1_pcie_tx_tbl[] = { 119794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_TX_PI_QEC_CTRL, 0x20), 119894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_TX_LANE_MODE_1, 0x75), 119994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_TX_LANE_MODE_4, 0x3f), 120094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_TX_RES_CODE_LANE_OFFSET_TX, 0x16), 120194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_TX_RES_CODE_LANE_OFFSET_RX, 0x04), 120294a407ccSDmitry Baryshkov }; 120394a407ccSDmitry Baryshkov 120494a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8450_qmp_gen3x1_pcie_rx_tbl[] = { 120594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_00_LOW, 0x7f), 120694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_00_HIGH, 0xff), 120794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_00_HIGH2, 0xbf), 120894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_00_HIGH3, 0x3f), 120994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_00_HIGH4, 0xd8), 121094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_01_LOW, 0xdc), 121194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_01_HIGH, 0xdc), 121294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_01_HIGH2, 0x5c), 121394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_01_HIGH3, 0x34), 121494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_01_HIGH4, 0xa6), 121594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_10_HIGH3, 0x34), 121694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_10_HIGH4, 0x38), 121794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_RX_VGA_CAL_CNTRL2, 0x07), 121894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_RX_GM_CAL, 0x00), 121994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_RX_UCDR_SB2_THRESH1, 0x08), 122094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_RX_UCDR_SB2_THRESH2, 0x08), 122194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_RX_UCDR_PI_CONTROLS, 0xf0), 122294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_RX_DFE_CTLE_POST_CAL_OFFSET, 0x38), 122394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_RX_TX_ADAPT_POST_THRESH, 0xf0), 122494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_EQU_ADAPTOR_CNTRL4, 0x07), 122594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_RX_UCDR_FO_GAIN, 0x09), 122694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_RX_UCDR_SO_GAIN, 0x05), 122794a407ccSDmitry Baryshkov }; 122894a407ccSDmitry Baryshkov 122994a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8450_qmp_gen3x1_pcie_pcs_tbl[] = { 123094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V5_PCS_RX_SIGDET_LVL, 0x77), 123194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V5_PCS_RATE_SLEW_CNTRL1, 0x0b), 123294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V5_PCS_REFGEN_REQ_CONFIG1, 0x05), 123394a407ccSDmitry Baryshkov }; 123494a407ccSDmitry Baryshkov 123594a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8450_qmp_gen3x1_pcie_pcs_misc_tbl[] = { 123694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V5_PCS_PCIE_OSC_DTCT_ACTIONS, 0x00), 123794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V5_PCS_PCIE_INT_AUX_CLK_CONFIG1, 0x00), 123894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V5_PCS_PCIE_EQ_CONFIG2, 0x0f), 123994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V5_PCS_PCIE_ENDPOINT_REFCLK_DRIVE, 0xc1), 124094a407ccSDmitry Baryshkov }; 124194a407ccSDmitry Baryshkov 124294a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8450_qmp_gen4x2_pcie_serdes_tbl[] = { 124394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_PER1, 0x31), 124494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_PER2, 0x01), 124594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_STEP_SIZE1_MODE0, 0xde), 124694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_STEP_SIZE2_MODE0, 0x07), 124794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_STEP_SIZE1_MODE1, 0x97), 124894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_STEP_SIZE2_MODE1, 0x0c), 124994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_BIAS_EN_CLKBUFLR_EN, 0x14), 125094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_CLK_ENABLE1, 0x90), 125194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_IVCO, 0x0f), 125294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_CP_CTRL_MODE0, 0x06), 125394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_CP_CTRL_MODE1, 0x06), 125494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_RCTRL_MODE0, 0x16), 125594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_RCTRL_MODE1, 0x16), 125694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_CCTRL_MODE0, 0x36), 125794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_CCTRL_MODE1, 0x36), 125894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_SYSCLK_EN_SEL, 0x08), 125994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP_EN, 0x46), 126094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP_CFG, 0x04), 126194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP1_MODE0, 0x0a), 126294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP2_MODE0, 0x1a), 126394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP1_MODE1, 0x14), 126494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP2_MODE1, 0x34), 126594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_DEC_START_MODE0, 0x82), 126694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_DEC_START_MODE1, 0xd0), 126794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START1_MODE0, 0x55), 126894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START2_MODE0, 0x55), 126994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START3_MODE0, 0x03), 127094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START1_MODE1, 0x55), 127194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START2_MODE1, 0x55), 127294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START3_MODE1, 0x05), 127394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_VCO_TUNE_MAP, 0x02), 127494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_CLK_SELECT, 0x34), 127594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_HSCLK_SEL, 0x12), 127694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_HSCLK_HS_SWITCH_SEL, 0x00), 127794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_CORECLK_DIV_MODE0, 0x0a), 127894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_CORECLK_DIV_MODE1, 0x04), 127994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_CMN_MISC1, 0x88), 128094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_CORE_CLK_EN, 0x20), 128194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_CMN_CONFIG, 0x06), 128294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_CMN_MODE, 0x14), 128394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_COM_VCO_DC_LEVEL_CTRL, 0x0f), 128494a407ccSDmitry Baryshkov }; 128594a407ccSDmitry Baryshkov 128694a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8450_qmp_gen4x2_pcie_tx_tbl[] = { 128794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_TX_LANE_MODE_1, 0x05), 128894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_TX_LANE_MODE_2, 0xf6), 128994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_TX_RES_CODE_LANE_OFFSET_TX, 0x1a), 129094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_TX_RES_CODE_LANE_OFFSET_RX, 0x0c), 129194a407ccSDmitry Baryshkov }; 129294a407ccSDmitry Baryshkov 129394a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8450_qmp_gen4x2_pcie_rx_tbl[] = { 129494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_UCDR_PI_CONTROLS, 0x16), 129594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_DFE_CTLE_POST_CAL_OFFSET, 0x38), 129694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE_0_1_B1, 0xcc), 129794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE_0_1_B2, 0x12), 129894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE_0_1_B3, 0xcc), 129994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE_0_1_B5, 0x4a), 130094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE_0_1_B6, 0x29), 130194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE2_B0, 0xc5), 130294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE2_B1, 0xad), 130394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE2_B2, 0xb6), 130494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE2_B3, 0xc0), 130594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE2_B4, 0x1f), 130694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE2_B5, 0xfb), 130794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE2_B6, 0x0f), 130894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE3_B0, 0xc7), 130994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE3_B1, 0xef), 131094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE3_B2, 0xbf), 131194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE3_B3, 0xa0), 131294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE3_B4, 0x81), 131394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE3_B5, 0xde), 131494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE3_B6, 0x7f), 131594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_PHPRE_CTRL, 0x20), 131694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_AUX_DATA_THRESH_BIN_RATE_0_1, 0x3f), 131794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_AUX_DATA_THRESH_BIN_RATE_2_3, 0x37), 131894a407ccSDmitry Baryshkov 131994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_DFE_3, 0x05), 132094a407ccSDmitry Baryshkov 132194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MARG_COARSE_THRESH1_RATE3, 0x1f), 132294a407ccSDmitry Baryshkov 132394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MARG_COARSE_THRESH2_RATE3, 0x1f), 132494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MARG_COARSE_THRESH3_RATE3, 0x1f), 132594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MARG_COARSE_THRESH4_RATE3, 0x1f), 132694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MARG_COARSE_THRESH5_RATE3, 0x1f), 132794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MARG_COARSE_THRESH6_RATE3, 0x1f), 132894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MARG_COARSE_THRESH1_RATE210, 0x1f), 132994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MARG_COARSE_THRESH2_RATE210, 0x1f), 133094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MARG_COARSE_THRESH3_RATE210, 0x1f), 133194a407ccSDmitry Baryshkov 133294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_UCDR_FO_GAIN_RATE2, 0x0c), 133394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_UCDR_FO_GAIN_RATE3, 0x0a), 133494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_VGA_CAL_MAN_VAL, 0x0a), 133594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_EQU_ADAPTOR_CNTRL4, 0x0b), 133694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_IDAC_SAOFFSET, 0x10), 133794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_DFE_DAC_ENABLE1, 0x00), 133894a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_GM_CAL, 0x0f), 133994a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_TX_ADAPT_POST_THRESH1, 0x00), 134094a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_TX_ADAPT_POST_THRESH2, 0x1f), 134194a407ccSDmitry Baryshkov }; 134294a407ccSDmitry Baryshkov 134394a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8450_qmp_gen4x2_pcie_pcs_tbl[] = { 134494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V5_PCS_EQ_CONFIG2, 0x16), 134594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V5_PCS_EQ_CONFIG3, 0x22), 134694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V5_PCS_G3S2_PRE_GAIN, 0x2e), 134794a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V5_PCS_RX_SIGDET_LVL, 0x99), 134894a407ccSDmitry Baryshkov }; 134994a407ccSDmitry Baryshkov 135094a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8450_qmp_gen4x2_pcie_pcs_misc_tbl[] = { 135194a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V5_20_PCS_PCIE_ENDPOINT_REFCLK_DRIVE, 0xc1), 135294a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V5_20_PCS_PCIE_OSC_DTCT_ACTIONS, 0x00), 135394a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V5_20_PCS_PCIE_G4_EQ_CONFIG5, 0x02), 135494a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V5_20_PCS_PCIE_EQ_CONFIG1, 0x16), 135594a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V5_20_PCS_PCIE_RX_MARGINING_CONFIG3, 0x28), 135694a407ccSDmitry Baryshkov QMP_PHY_INIT_CFG(QPHY_V5_20_PCS_PCIE_G4_PRE_GAIN, 0x2e), 135794a407ccSDmitry Baryshkov }; 135894a407ccSDmitry Baryshkov 135994a407ccSDmitry Baryshkov struct qmp_phy; 136094a407ccSDmitry Baryshkov 136194a407ccSDmitry Baryshkov /* struct qmp_phy_cfg - per-PHY initialization config */ 136294a407ccSDmitry Baryshkov struct qmp_phy_cfg { 136394a407ccSDmitry Baryshkov /* phy-type - PCIE/UFS/USB */ 136494a407ccSDmitry Baryshkov unsigned int type; 136594a407ccSDmitry Baryshkov /* number of lanes provided by phy */ 136694a407ccSDmitry Baryshkov int nlanes; 136794a407ccSDmitry Baryshkov 136894a407ccSDmitry Baryshkov /* Init sequence for PHY blocks - serdes, tx, rx, pcs */ 136994a407ccSDmitry Baryshkov const struct qmp_phy_init_tbl *serdes_tbl; 137094a407ccSDmitry Baryshkov int serdes_tbl_num; 137194a407ccSDmitry Baryshkov const struct qmp_phy_init_tbl *serdes_tbl_sec; 137294a407ccSDmitry Baryshkov int serdes_tbl_num_sec; 137394a407ccSDmitry Baryshkov const struct qmp_phy_init_tbl *tx_tbl; 137494a407ccSDmitry Baryshkov int tx_tbl_num; 137594a407ccSDmitry Baryshkov const struct qmp_phy_init_tbl *tx_tbl_sec; 137694a407ccSDmitry Baryshkov int tx_tbl_num_sec; 137794a407ccSDmitry Baryshkov const struct qmp_phy_init_tbl *rx_tbl; 137894a407ccSDmitry Baryshkov int rx_tbl_num; 137994a407ccSDmitry Baryshkov const struct qmp_phy_init_tbl *rx_tbl_sec; 138094a407ccSDmitry Baryshkov int rx_tbl_num_sec; 138194a407ccSDmitry Baryshkov const struct qmp_phy_init_tbl *pcs_tbl; 138294a407ccSDmitry Baryshkov int pcs_tbl_num; 138394a407ccSDmitry Baryshkov const struct qmp_phy_init_tbl *pcs_tbl_sec; 138494a407ccSDmitry Baryshkov int pcs_tbl_num_sec; 138594a407ccSDmitry Baryshkov const struct qmp_phy_init_tbl *pcs_misc_tbl; 138694a407ccSDmitry Baryshkov int pcs_misc_tbl_num; 138794a407ccSDmitry Baryshkov const struct qmp_phy_init_tbl *pcs_misc_tbl_sec; 138894a407ccSDmitry Baryshkov int pcs_misc_tbl_num_sec; 138994a407ccSDmitry Baryshkov 139094a407ccSDmitry Baryshkov /* clock ids to be requested */ 139194a407ccSDmitry Baryshkov const char * const *clk_list; 139294a407ccSDmitry Baryshkov int num_clks; 139394a407ccSDmitry Baryshkov /* resets to be requested */ 139494a407ccSDmitry Baryshkov const char * const *reset_list; 139594a407ccSDmitry Baryshkov int num_resets; 139694a407ccSDmitry Baryshkov /* regulators to be requested */ 139794a407ccSDmitry Baryshkov const char * const *vreg_list; 139894a407ccSDmitry Baryshkov int num_vregs; 139994a407ccSDmitry Baryshkov 140094a407ccSDmitry Baryshkov /* array of registers with different offsets */ 140194a407ccSDmitry Baryshkov const unsigned int *regs; 140294a407ccSDmitry Baryshkov 140394a407ccSDmitry Baryshkov unsigned int start_ctrl; 140494a407ccSDmitry Baryshkov unsigned int pwrdn_ctrl; 140594a407ccSDmitry Baryshkov unsigned int mask_com_pcs_ready; 140694a407ccSDmitry Baryshkov /* bit offset of PHYSTATUS in QPHY_PCS_STATUS register */ 140794a407ccSDmitry Baryshkov unsigned int phy_status; 140894a407ccSDmitry Baryshkov 140994a407ccSDmitry Baryshkov /* true, if PHY needs delay after POWER_DOWN */ 141094a407ccSDmitry Baryshkov bool has_pwrdn_delay; 141194a407ccSDmitry Baryshkov /* power_down delay in usec */ 141294a407ccSDmitry Baryshkov int pwrdn_delay_min; 141394a407ccSDmitry Baryshkov int pwrdn_delay_max; 141494a407ccSDmitry Baryshkov 141594a407ccSDmitry Baryshkov /* true, if PHY has secondary tx/rx lanes to be configured */ 141694a407ccSDmitry Baryshkov bool is_dual_lane_phy; 14172ec9bc8dSRobert Marko 14182ec9bc8dSRobert Marko /* QMP PHY pipe clock interface rate */ 14192ec9bc8dSRobert Marko unsigned long pipe_clock_rate; 142094a407ccSDmitry Baryshkov }; 142194a407ccSDmitry Baryshkov 142294a407ccSDmitry Baryshkov /** 142394a407ccSDmitry Baryshkov * struct qmp_phy - per-lane phy descriptor 142494a407ccSDmitry Baryshkov * 142594a407ccSDmitry Baryshkov * @phy: generic phy 142694a407ccSDmitry Baryshkov * @cfg: phy specific configuration 142794a407ccSDmitry Baryshkov * @serdes: iomapped memory space for phy's serdes (i.e. PLL) 142894a407ccSDmitry Baryshkov * @tx: iomapped memory space for lane's tx 142994a407ccSDmitry Baryshkov * @rx: iomapped memory space for lane's rx 143094a407ccSDmitry Baryshkov * @pcs: iomapped memory space for lane's pcs 143194a407ccSDmitry Baryshkov * @tx2: iomapped memory space for second lane's tx (in dual lane PHYs) 143294a407ccSDmitry Baryshkov * @rx2: iomapped memory space for second lane's rx (in dual lane PHYs) 143394a407ccSDmitry Baryshkov * @pcs_misc: iomapped memory space for lane's pcs_misc 143494a407ccSDmitry Baryshkov * @pipe_clk: pipe clock 143594a407ccSDmitry Baryshkov * @index: lane index 143694a407ccSDmitry Baryshkov * @qmp: QMP phy to which this lane belongs 143794a407ccSDmitry Baryshkov * @mode: current PHY mode 143894a407ccSDmitry Baryshkov */ 143994a407ccSDmitry Baryshkov struct qmp_phy { 144094a407ccSDmitry Baryshkov struct phy *phy; 144194a407ccSDmitry Baryshkov const struct qmp_phy_cfg *cfg; 144294a407ccSDmitry Baryshkov void __iomem *serdes; 144394a407ccSDmitry Baryshkov void __iomem *tx; 144494a407ccSDmitry Baryshkov void __iomem *rx; 144594a407ccSDmitry Baryshkov void __iomem *pcs; 144694a407ccSDmitry Baryshkov void __iomem *tx2; 144794a407ccSDmitry Baryshkov void __iomem *rx2; 144894a407ccSDmitry Baryshkov void __iomem *pcs_misc; 144994a407ccSDmitry Baryshkov struct clk *pipe_clk; 145094a407ccSDmitry Baryshkov unsigned int index; 145194a407ccSDmitry Baryshkov struct qcom_qmp *qmp; 145294a407ccSDmitry Baryshkov enum phy_mode mode; 145394a407ccSDmitry Baryshkov }; 145494a407ccSDmitry Baryshkov 145594a407ccSDmitry Baryshkov /** 145694a407ccSDmitry Baryshkov * struct qcom_qmp - structure holding QMP phy block attributes 145794a407ccSDmitry Baryshkov * 145894a407ccSDmitry Baryshkov * @dev: device 145994a407ccSDmitry Baryshkov * 146094a407ccSDmitry Baryshkov * @clks: array of clocks required by phy 146194a407ccSDmitry Baryshkov * @resets: array of resets required by phy 146294a407ccSDmitry Baryshkov * @vregs: regulator supplies bulk data 146394a407ccSDmitry Baryshkov * 146494a407ccSDmitry Baryshkov * @phys: array of per-lane phy descriptors 146594a407ccSDmitry Baryshkov */ 146694a407ccSDmitry Baryshkov struct qcom_qmp { 146794a407ccSDmitry Baryshkov struct device *dev; 146894a407ccSDmitry Baryshkov 146994a407ccSDmitry Baryshkov struct clk_bulk_data *clks; 1470189ac6b8SDmitry Baryshkov struct reset_control_bulk_data *resets; 147194a407ccSDmitry Baryshkov struct regulator_bulk_data *vregs; 147294a407ccSDmitry Baryshkov 147394a407ccSDmitry Baryshkov struct qmp_phy **phys; 147494a407ccSDmitry Baryshkov }; 147594a407ccSDmitry Baryshkov 147694a407ccSDmitry Baryshkov static inline void qphy_setbits(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 static inline void qphy_clrbits(void __iomem *base, u32 offset, u32 val) 148994a407ccSDmitry Baryshkov { 149094a407ccSDmitry Baryshkov u32 reg; 149194a407ccSDmitry Baryshkov 149294a407ccSDmitry Baryshkov reg = readl(base + offset); 149394a407ccSDmitry Baryshkov reg &= ~val; 149494a407ccSDmitry Baryshkov writel(reg, base + offset); 149594a407ccSDmitry Baryshkov 149694a407ccSDmitry Baryshkov /* ensure that above write is through */ 149794a407ccSDmitry Baryshkov readl(base + offset); 149894a407ccSDmitry Baryshkov } 149994a407ccSDmitry Baryshkov 150094a407ccSDmitry Baryshkov /* list of clocks required by phy */ 150194a407ccSDmitry Baryshkov static const char * const msm8996_phy_clk_l[] = { 150294a407ccSDmitry Baryshkov "aux", "cfg_ahb", "ref", 150394a407ccSDmitry Baryshkov }; 150494a407ccSDmitry Baryshkov 150594a407ccSDmitry Baryshkov 150694a407ccSDmitry Baryshkov static const char * const sdm845_pciephy_clk_l[] = { 150794a407ccSDmitry Baryshkov "aux", "cfg_ahb", "ref", "refgen", 150894a407ccSDmitry Baryshkov }; 150994a407ccSDmitry Baryshkov 151094a407ccSDmitry Baryshkov /* list of regulators */ 151194a407ccSDmitry Baryshkov static const char * const qmp_phy_vreg_l[] = { 151294a407ccSDmitry Baryshkov "vdda-phy", "vdda-pll", 151394a407ccSDmitry Baryshkov }; 151494a407ccSDmitry Baryshkov 151594a407ccSDmitry Baryshkov static const char * const ipq8074_pciephy_clk_l[] = { 151694a407ccSDmitry Baryshkov "aux", "cfg_ahb", 151794a407ccSDmitry Baryshkov }; 1518b35a5311SDmitry Baryshkov 151994a407ccSDmitry Baryshkov /* list of resets */ 152094a407ccSDmitry Baryshkov static const char * const ipq8074_pciephy_reset_l[] = { 152194a407ccSDmitry Baryshkov "phy", "common", 152294a407ccSDmitry Baryshkov }; 152394a407ccSDmitry Baryshkov 1524b35a5311SDmitry Baryshkov static const char * const sdm845_pciephy_reset_l[] = { 1525b35a5311SDmitry Baryshkov "phy", 1526b35a5311SDmitry Baryshkov }; 1527b35a5311SDmitry Baryshkov 152894a407ccSDmitry Baryshkov static const struct qmp_phy_cfg ipq8074_pciephy_cfg = { 152994a407ccSDmitry Baryshkov .type = PHY_TYPE_PCIE, 153094a407ccSDmitry Baryshkov .nlanes = 1, 153194a407ccSDmitry Baryshkov 153294a407ccSDmitry Baryshkov .serdes_tbl = ipq8074_pcie_serdes_tbl, 153394a407ccSDmitry Baryshkov .serdes_tbl_num = ARRAY_SIZE(ipq8074_pcie_serdes_tbl), 153494a407ccSDmitry Baryshkov .tx_tbl = ipq8074_pcie_tx_tbl, 153594a407ccSDmitry Baryshkov .tx_tbl_num = ARRAY_SIZE(ipq8074_pcie_tx_tbl), 153694a407ccSDmitry Baryshkov .rx_tbl = ipq8074_pcie_rx_tbl, 153794a407ccSDmitry Baryshkov .rx_tbl_num = ARRAY_SIZE(ipq8074_pcie_rx_tbl), 153894a407ccSDmitry Baryshkov .pcs_tbl = ipq8074_pcie_pcs_tbl, 153994a407ccSDmitry Baryshkov .pcs_tbl_num = ARRAY_SIZE(ipq8074_pcie_pcs_tbl), 154094a407ccSDmitry Baryshkov .clk_list = ipq8074_pciephy_clk_l, 154194a407ccSDmitry Baryshkov .num_clks = ARRAY_SIZE(ipq8074_pciephy_clk_l), 154294a407ccSDmitry Baryshkov .reset_list = ipq8074_pciephy_reset_l, 154394a407ccSDmitry Baryshkov .num_resets = ARRAY_SIZE(ipq8074_pciephy_reset_l), 154494a407ccSDmitry Baryshkov .vreg_list = NULL, 154594a407ccSDmitry Baryshkov .num_vregs = 0, 154694a407ccSDmitry Baryshkov .regs = pciephy_regs_layout, 154794a407ccSDmitry Baryshkov 154894a407ccSDmitry Baryshkov .start_ctrl = SERDES_START | PCS_START, 154994a407ccSDmitry Baryshkov .pwrdn_ctrl = SW_PWRDN | REFCLK_DRV_DSBL, 155094a407ccSDmitry Baryshkov .phy_status = PHYSTATUS, 155194a407ccSDmitry Baryshkov 155294a407ccSDmitry Baryshkov .has_pwrdn_delay = true, 155394a407ccSDmitry Baryshkov .pwrdn_delay_min = 995, /* us */ 155494a407ccSDmitry Baryshkov .pwrdn_delay_max = 1005, /* us */ 155594a407ccSDmitry Baryshkov }; 155694a407ccSDmitry Baryshkov 1557334fad18SRobert Marko static const struct qmp_phy_cfg ipq8074_pciephy_gen3_cfg = { 1558334fad18SRobert Marko .type = PHY_TYPE_PCIE, 1559334fad18SRobert Marko .nlanes = 1, 1560334fad18SRobert Marko 1561334fad18SRobert Marko .serdes_tbl = ipq8074_pcie_gen3_serdes_tbl, 1562334fad18SRobert Marko .serdes_tbl_num = ARRAY_SIZE(ipq8074_pcie_gen3_serdes_tbl), 1563334fad18SRobert Marko .tx_tbl = ipq8074_pcie_gen3_tx_tbl, 1564334fad18SRobert Marko .tx_tbl_num = ARRAY_SIZE(ipq8074_pcie_gen3_tx_tbl), 1565334fad18SRobert Marko .rx_tbl = ipq8074_pcie_gen3_rx_tbl, 1566334fad18SRobert Marko .rx_tbl_num = ARRAY_SIZE(ipq8074_pcie_gen3_rx_tbl), 1567334fad18SRobert Marko .pcs_tbl = ipq8074_pcie_gen3_pcs_tbl, 1568334fad18SRobert Marko .pcs_tbl_num = ARRAY_SIZE(ipq8074_pcie_gen3_pcs_tbl), 1569334fad18SRobert Marko .clk_list = ipq8074_pciephy_clk_l, 1570334fad18SRobert Marko .num_clks = ARRAY_SIZE(ipq8074_pciephy_clk_l), 1571334fad18SRobert Marko .reset_list = ipq8074_pciephy_reset_l, 1572334fad18SRobert Marko .num_resets = ARRAY_SIZE(ipq8074_pciephy_reset_l), 1573334fad18SRobert Marko .vreg_list = NULL, 1574334fad18SRobert Marko .num_vregs = 0, 1575334fad18SRobert Marko .regs = ipq_pciephy_gen3_regs_layout, 1576334fad18SRobert Marko 1577334fad18SRobert Marko .start_ctrl = SERDES_START | PCS_START, 1578334fad18SRobert Marko .pwrdn_ctrl = SW_PWRDN | REFCLK_DRV_DSBL, 1579334fad18SRobert Marko 1580334fad18SRobert Marko .has_pwrdn_delay = true, 1581334fad18SRobert Marko .pwrdn_delay_min = 995, /* us */ 1582334fad18SRobert Marko .pwrdn_delay_max = 1005, /* us */ 1583334fad18SRobert Marko 1584334fad18SRobert Marko .pipe_clock_rate = 250000000, 1585334fad18SRobert Marko }; 1586334fad18SRobert Marko 158794a407ccSDmitry Baryshkov static const struct qmp_phy_cfg ipq6018_pciephy_cfg = { 158894a407ccSDmitry Baryshkov .type = PHY_TYPE_PCIE, 158994a407ccSDmitry Baryshkov .nlanes = 1, 159094a407ccSDmitry Baryshkov 159194a407ccSDmitry Baryshkov .serdes_tbl = ipq6018_pcie_serdes_tbl, 159294a407ccSDmitry Baryshkov .serdes_tbl_num = ARRAY_SIZE(ipq6018_pcie_serdes_tbl), 159394a407ccSDmitry Baryshkov .tx_tbl = ipq6018_pcie_tx_tbl, 159494a407ccSDmitry Baryshkov .tx_tbl_num = ARRAY_SIZE(ipq6018_pcie_tx_tbl), 159594a407ccSDmitry Baryshkov .rx_tbl = ipq6018_pcie_rx_tbl, 159694a407ccSDmitry Baryshkov .rx_tbl_num = ARRAY_SIZE(ipq6018_pcie_rx_tbl), 159794a407ccSDmitry Baryshkov .pcs_tbl = ipq6018_pcie_pcs_tbl, 159894a407ccSDmitry Baryshkov .pcs_tbl_num = ARRAY_SIZE(ipq6018_pcie_pcs_tbl), 1599*af664324SDmitry Baryshkov .pcs_misc_tbl = ipq6018_pcie_pcs_misc_tbl, 1600*af664324SDmitry Baryshkov .pcs_misc_tbl_num = ARRAY_SIZE(ipq6018_pcie_pcs_misc_tbl), 160194a407ccSDmitry Baryshkov .clk_list = ipq8074_pciephy_clk_l, 160294a407ccSDmitry Baryshkov .num_clks = ARRAY_SIZE(ipq8074_pciephy_clk_l), 160394a407ccSDmitry Baryshkov .reset_list = ipq8074_pciephy_reset_l, 160494a407ccSDmitry Baryshkov .num_resets = ARRAY_SIZE(ipq8074_pciephy_reset_l), 160594a407ccSDmitry Baryshkov .vreg_list = NULL, 160694a407ccSDmitry Baryshkov .num_vregs = 0, 160794a407ccSDmitry Baryshkov .regs = ipq_pciephy_gen3_regs_layout, 160894a407ccSDmitry Baryshkov 160994a407ccSDmitry Baryshkov .start_ctrl = SERDES_START | PCS_START, 161094a407ccSDmitry Baryshkov .pwrdn_ctrl = SW_PWRDN | REFCLK_DRV_DSBL, 161194a407ccSDmitry Baryshkov 161294a407ccSDmitry Baryshkov .has_pwrdn_delay = true, 161394a407ccSDmitry Baryshkov .pwrdn_delay_min = 995, /* us */ 161494a407ccSDmitry Baryshkov .pwrdn_delay_max = 1005, /* us */ 161594a407ccSDmitry Baryshkov }; 161694a407ccSDmitry Baryshkov 161794a407ccSDmitry Baryshkov static const struct qmp_phy_cfg sdm845_qmp_pciephy_cfg = { 161894a407ccSDmitry Baryshkov .type = PHY_TYPE_PCIE, 161994a407ccSDmitry Baryshkov .nlanes = 1, 162094a407ccSDmitry Baryshkov 162194a407ccSDmitry Baryshkov .serdes_tbl = sdm845_qmp_pcie_serdes_tbl, 162294a407ccSDmitry Baryshkov .serdes_tbl_num = ARRAY_SIZE(sdm845_qmp_pcie_serdes_tbl), 162394a407ccSDmitry Baryshkov .tx_tbl = sdm845_qmp_pcie_tx_tbl, 162494a407ccSDmitry Baryshkov .tx_tbl_num = ARRAY_SIZE(sdm845_qmp_pcie_tx_tbl), 162594a407ccSDmitry Baryshkov .rx_tbl = sdm845_qmp_pcie_rx_tbl, 162694a407ccSDmitry Baryshkov .rx_tbl_num = ARRAY_SIZE(sdm845_qmp_pcie_rx_tbl), 162794a407ccSDmitry Baryshkov .pcs_tbl = sdm845_qmp_pcie_pcs_tbl, 162894a407ccSDmitry Baryshkov .pcs_tbl_num = ARRAY_SIZE(sdm845_qmp_pcie_pcs_tbl), 162994a407ccSDmitry Baryshkov .pcs_misc_tbl = sdm845_qmp_pcie_pcs_misc_tbl, 163094a407ccSDmitry Baryshkov .pcs_misc_tbl_num = ARRAY_SIZE(sdm845_qmp_pcie_pcs_misc_tbl), 163194a407ccSDmitry Baryshkov .clk_list = sdm845_pciephy_clk_l, 163294a407ccSDmitry Baryshkov .num_clks = ARRAY_SIZE(sdm845_pciephy_clk_l), 163394a407ccSDmitry Baryshkov .reset_list = sdm845_pciephy_reset_l, 163494a407ccSDmitry Baryshkov .num_resets = ARRAY_SIZE(sdm845_pciephy_reset_l), 163594a407ccSDmitry Baryshkov .vreg_list = qmp_phy_vreg_l, 163694a407ccSDmitry Baryshkov .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), 163794a407ccSDmitry Baryshkov .regs = sdm845_qmp_pciephy_regs_layout, 163894a407ccSDmitry Baryshkov 163994a407ccSDmitry Baryshkov .start_ctrl = PCS_START | SERDES_START, 164094a407ccSDmitry Baryshkov .pwrdn_ctrl = SW_PWRDN | REFCLK_DRV_DSBL, 164194a407ccSDmitry Baryshkov .phy_status = PHYSTATUS, 164294a407ccSDmitry Baryshkov 164394a407ccSDmitry Baryshkov .has_pwrdn_delay = true, 164494a407ccSDmitry Baryshkov .pwrdn_delay_min = 995, /* us */ 164594a407ccSDmitry Baryshkov .pwrdn_delay_max = 1005, /* us */ 164694a407ccSDmitry Baryshkov }; 164794a407ccSDmitry Baryshkov 164894a407ccSDmitry Baryshkov static const struct qmp_phy_cfg sdm845_qhp_pciephy_cfg = { 164994a407ccSDmitry Baryshkov .type = PHY_TYPE_PCIE, 165094a407ccSDmitry Baryshkov .nlanes = 1, 165194a407ccSDmitry Baryshkov 165294a407ccSDmitry Baryshkov .serdes_tbl = sdm845_qhp_pcie_serdes_tbl, 165394a407ccSDmitry Baryshkov .serdes_tbl_num = ARRAY_SIZE(sdm845_qhp_pcie_serdes_tbl), 165494a407ccSDmitry Baryshkov .tx_tbl = sdm845_qhp_pcie_tx_tbl, 165594a407ccSDmitry Baryshkov .tx_tbl_num = ARRAY_SIZE(sdm845_qhp_pcie_tx_tbl), 165694a407ccSDmitry Baryshkov .rx_tbl = sdm845_qhp_pcie_rx_tbl, 165794a407ccSDmitry Baryshkov .rx_tbl_num = ARRAY_SIZE(sdm845_qhp_pcie_rx_tbl), 165894a407ccSDmitry Baryshkov .pcs_tbl = sdm845_qhp_pcie_pcs_tbl, 165994a407ccSDmitry Baryshkov .pcs_tbl_num = ARRAY_SIZE(sdm845_qhp_pcie_pcs_tbl), 166094a407ccSDmitry Baryshkov .clk_list = sdm845_pciephy_clk_l, 166194a407ccSDmitry Baryshkov .num_clks = ARRAY_SIZE(sdm845_pciephy_clk_l), 166294a407ccSDmitry Baryshkov .reset_list = sdm845_pciephy_reset_l, 166394a407ccSDmitry Baryshkov .num_resets = ARRAY_SIZE(sdm845_pciephy_reset_l), 166494a407ccSDmitry Baryshkov .vreg_list = qmp_phy_vreg_l, 166594a407ccSDmitry Baryshkov .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), 166694a407ccSDmitry Baryshkov .regs = sdm845_qhp_pciephy_regs_layout, 166794a407ccSDmitry Baryshkov 166894a407ccSDmitry Baryshkov .start_ctrl = PCS_START | SERDES_START, 166994a407ccSDmitry Baryshkov .pwrdn_ctrl = SW_PWRDN | REFCLK_DRV_DSBL, 167094a407ccSDmitry Baryshkov .phy_status = PHYSTATUS, 167194a407ccSDmitry Baryshkov 167294a407ccSDmitry Baryshkov .has_pwrdn_delay = true, 167394a407ccSDmitry Baryshkov .pwrdn_delay_min = 995, /* us */ 167494a407ccSDmitry Baryshkov .pwrdn_delay_max = 1005, /* us */ 167594a407ccSDmitry Baryshkov }; 167694a407ccSDmitry Baryshkov 167794a407ccSDmitry Baryshkov static const struct qmp_phy_cfg sm8250_qmp_gen3x1_pciephy_cfg = { 167894a407ccSDmitry Baryshkov .type = PHY_TYPE_PCIE, 167994a407ccSDmitry Baryshkov .nlanes = 1, 168094a407ccSDmitry Baryshkov 168194a407ccSDmitry Baryshkov .serdes_tbl = sm8250_qmp_pcie_serdes_tbl, 168294a407ccSDmitry Baryshkov .serdes_tbl_num = ARRAY_SIZE(sm8250_qmp_pcie_serdes_tbl), 168394a407ccSDmitry Baryshkov .serdes_tbl_sec = sm8250_qmp_gen3x1_pcie_serdes_tbl, 168494a407ccSDmitry Baryshkov .serdes_tbl_num_sec = ARRAY_SIZE(sm8250_qmp_gen3x1_pcie_serdes_tbl), 168594a407ccSDmitry Baryshkov .tx_tbl = sm8250_qmp_pcie_tx_tbl, 168694a407ccSDmitry Baryshkov .tx_tbl_num = ARRAY_SIZE(sm8250_qmp_pcie_tx_tbl), 168794a407ccSDmitry Baryshkov .rx_tbl = sm8250_qmp_pcie_rx_tbl, 168894a407ccSDmitry Baryshkov .rx_tbl_num = ARRAY_SIZE(sm8250_qmp_pcie_rx_tbl), 168994a407ccSDmitry Baryshkov .rx_tbl_sec = sm8250_qmp_gen3x1_pcie_rx_tbl, 169094a407ccSDmitry Baryshkov .rx_tbl_num_sec = ARRAY_SIZE(sm8250_qmp_gen3x1_pcie_rx_tbl), 169194a407ccSDmitry Baryshkov .pcs_tbl = sm8250_qmp_pcie_pcs_tbl, 169294a407ccSDmitry Baryshkov .pcs_tbl_num = ARRAY_SIZE(sm8250_qmp_pcie_pcs_tbl), 169394a407ccSDmitry Baryshkov .pcs_tbl_sec = sm8250_qmp_gen3x1_pcie_pcs_tbl, 169494a407ccSDmitry Baryshkov .pcs_tbl_num_sec = ARRAY_SIZE(sm8250_qmp_gen3x1_pcie_pcs_tbl), 169594a407ccSDmitry Baryshkov .pcs_misc_tbl = sm8250_qmp_pcie_pcs_misc_tbl, 169694a407ccSDmitry Baryshkov .pcs_misc_tbl_num = ARRAY_SIZE(sm8250_qmp_pcie_pcs_misc_tbl), 169794a407ccSDmitry Baryshkov .pcs_misc_tbl_sec = sm8250_qmp_gen3x1_pcie_pcs_misc_tbl, 169894a407ccSDmitry Baryshkov .pcs_misc_tbl_num_sec = ARRAY_SIZE(sm8250_qmp_gen3x1_pcie_pcs_misc_tbl), 169994a407ccSDmitry Baryshkov .clk_list = sdm845_pciephy_clk_l, 170094a407ccSDmitry Baryshkov .num_clks = ARRAY_SIZE(sdm845_pciephy_clk_l), 170194a407ccSDmitry Baryshkov .reset_list = sdm845_pciephy_reset_l, 170294a407ccSDmitry Baryshkov .num_resets = ARRAY_SIZE(sdm845_pciephy_reset_l), 170394a407ccSDmitry Baryshkov .vreg_list = qmp_phy_vreg_l, 170494a407ccSDmitry Baryshkov .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), 170594a407ccSDmitry Baryshkov .regs = sm8250_pcie_regs_layout, 170694a407ccSDmitry Baryshkov 170794a407ccSDmitry Baryshkov .start_ctrl = PCS_START | SERDES_START, 170894a407ccSDmitry Baryshkov .pwrdn_ctrl = SW_PWRDN | REFCLK_DRV_DSBL, 170994a407ccSDmitry Baryshkov .phy_status = PHYSTATUS, 171094a407ccSDmitry Baryshkov 171194a407ccSDmitry Baryshkov .has_pwrdn_delay = true, 171294a407ccSDmitry Baryshkov .pwrdn_delay_min = 995, /* us */ 171394a407ccSDmitry Baryshkov .pwrdn_delay_max = 1005, /* us */ 171494a407ccSDmitry Baryshkov }; 171594a407ccSDmitry Baryshkov 171694a407ccSDmitry Baryshkov static const struct qmp_phy_cfg sm8250_qmp_gen3x2_pciephy_cfg = { 171794a407ccSDmitry Baryshkov .type = PHY_TYPE_PCIE, 171894a407ccSDmitry Baryshkov .nlanes = 2, 171994a407ccSDmitry Baryshkov 172094a407ccSDmitry Baryshkov .serdes_tbl = sm8250_qmp_pcie_serdes_tbl, 172194a407ccSDmitry Baryshkov .serdes_tbl_num = ARRAY_SIZE(sm8250_qmp_pcie_serdes_tbl), 172294a407ccSDmitry Baryshkov .tx_tbl = sm8250_qmp_pcie_tx_tbl, 172394a407ccSDmitry Baryshkov .tx_tbl_num = ARRAY_SIZE(sm8250_qmp_pcie_tx_tbl), 172494a407ccSDmitry Baryshkov .tx_tbl_sec = sm8250_qmp_gen3x2_pcie_tx_tbl, 172594a407ccSDmitry Baryshkov .tx_tbl_num_sec = ARRAY_SIZE(sm8250_qmp_gen3x2_pcie_tx_tbl), 172694a407ccSDmitry Baryshkov .rx_tbl = sm8250_qmp_pcie_rx_tbl, 172794a407ccSDmitry Baryshkov .rx_tbl_num = ARRAY_SIZE(sm8250_qmp_pcie_rx_tbl), 172894a407ccSDmitry Baryshkov .rx_tbl_sec = sm8250_qmp_gen3x2_pcie_rx_tbl, 172994a407ccSDmitry Baryshkov .rx_tbl_num_sec = ARRAY_SIZE(sm8250_qmp_gen3x2_pcie_rx_tbl), 173094a407ccSDmitry Baryshkov .pcs_tbl = sm8250_qmp_pcie_pcs_tbl, 173194a407ccSDmitry Baryshkov .pcs_tbl_num = ARRAY_SIZE(sm8250_qmp_pcie_pcs_tbl), 173294a407ccSDmitry Baryshkov .pcs_tbl_sec = sm8250_qmp_gen3x2_pcie_pcs_tbl, 173394a407ccSDmitry Baryshkov .pcs_tbl_num_sec = ARRAY_SIZE(sm8250_qmp_gen3x2_pcie_pcs_tbl), 173494a407ccSDmitry Baryshkov .pcs_misc_tbl = sm8250_qmp_pcie_pcs_misc_tbl, 173594a407ccSDmitry Baryshkov .pcs_misc_tbl_num = ARRAY_SIZE(sm8250_qmp_pcie_pcs_misc_tbl), 173694a407ccSDmitry Baryshkov .pcs_misc_tbl_sec = sm8250_qmp_gen3x2_pcie_pcs_misc_tbl, 173794a407ccSDmitry Baryshkov .pcs_misc_tbl_num_sec = ARRAY_SIZE(sm8250_qmp_gen3x2_pcie_pcs_misc_tbl), 173894a407ccSDmitry Baryshkov .clk_list = sdm845_pciephy_clk_l, 173994a407ccSDmitry Baryshkov .num_clks = ARRAY_SIZE(sdm845_pciephy_clk_l), 174094a407ccSDmitry Baryshkov .reset_list = sdm845_pciephy_reset_l, 174194a407ccSDmitry Baryshkov .num_resets = ARRAY_SIZE(sdm845_pciephy_reset_l), 174294a407ccSDmitry Baryshkov .vreg_list = qmp_phy_vreg_l, 174394a407ccSDmitry Baryshkov .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), 174494a407ccSDmitry Baryshkov .regs = sm8250_pcie_regs_layout, 174594a407ccSDmitry Baryshkov 174694a407ccSDmitry Baryshkov .start_ctrl = PCS_START | SERDES_START, 174794a407ccSDmitry Baryshkov .pwrdn_ctrl = SW_PWRDN | REFCLK_DRV_DSBL, 174894a407ccSDmitry Baryshkov .phy_status = PHYSTATUS, 174994a407ccSDmitry Baryshkov 175094a407ccSDmitry Baryshkov .is_dual_lane_phy = true, 175194a407ccSDmitry Baryshkov .has_pwrdn_delay = true, 175294a407ccSDmitry Baryshkov .pwrdn_delay_min = 995, /* us */ 175394a407ccSDmitry Baryshkov .pwrdn_delay_max = 1005, /* us */ 175494a407ccSDmitry Baryshkov }; 175594a407ccSDmitry Baryshkov 175694a407ccSDmitry Baryshkov static const struct qmp_phy_cfg msm8998_pciephy_cfg = { 175794a407ccSDmitry Baryshkov .type = PHY_TYPE_PCIE, 175894a407ccSDmitry Baryshkov .nlanes = 1, 175994a407ccSDmitry Baryshkov 176094a407ccSDmitry Baryshkov .serdes_tbl = msm8998_pcie_serdes_tbl, 176194a407ccSDmitry Baryshkov .serdes_tbl_num = ARRAY_SIZE(msm8998_pcie_serdes_tbl), 176294a407ccSDmitry Baryshkov .tx_tbl = msm8998_pcie_tx_tbl, 176394a407ccSDmitry Baryshkov .tx_tbl_num = ARRAY_SIZE(msm8998_pcie_tx_tbl), 176494a407ccSDmitry Baryshkov .rx_tbl = msm8998_pcie_rx_tbl, 176594a407ccSDmitry Baryshkov .rx_tbl_num = ARRAY_SIZE(msm8998_pcie_rx_tbl), 176694a407ccSDmitry Baryshkov .pcs_tbl = msm8998_pcie_pcs_tbl, 176794a407ccSDmitry Baryshkov .pcs_tbl_num = ARRAY_SIZE(msm8998_pcie_pcs_tbl), 176894a407ccSDmitry Baryshkov .clk_list = msm8996_phy_clk_l, 176994a407ccSDmitry Baryshkov .num_clks = ARRAY_SIZE(msm8996_phy_clk_l), 177094a407ccSDmitry Baryshkov .reset_list = ipq8074_pciephy_reset_l, 177194a407ccSDmitry Baryshkov .num_resets = ARRAY_SIZE(ipq8074_pciephy_reset_l), 177294a407ccSDmitry Baryshkov .vreg_list = qmp_phy_vreg_l, 177394a407ccSDmitry Baryshkov .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), 177494a407ccSDmitry Baryshkov .regs = pciephy_regs_layout, 177594a407ccSDmitry Baryshkov 177694a407ccSDmitry Baryshkov .start_ctrl = SERDES_START | PCS_START, 177794a407ccSDmitry Baryshkov .pwrdn_ctrl = SW_PWRDN | REFCLK_DRV_DSBL, 177894a407ccSDmitry Baryshkov .phy_status = PHYSTATUS, 177994a407ccSDmitry Baryshkov }; 178094a407ccSDmitry Baryshkov 178194a407ccSDmitry Baryshkov static const struct qmp_phy_cfg sc8180x_pciephy_cfg = { 178294a407ccSDmitry Baryshkov .type = PHY_TYPE_PCIE, 178394a407ccSDmitry Baryshkov .nlanes = 1, 178494a407ccSDmitry Baryshkov 178594a407ccSDmitry Baryshkov .serdes_tbl = sc8180x_qmp_pcie_serdes_tbl, 178694a407ccSDmitry Baryshkov .serdes_tbl_num = ARRAY_SIZE(sc8180x_qmp_pcie_serdes_tbl), 178794a407ccSDmitry Baryshkov .tx_tbl = sc8180x_qmp_pcie_tx_tbl, 178894a407ccSDmitry Baryshkov .tx_tbl_num = ARRAY_SIZE(sc8180x_qmp_pcie_tx_tbl), 178994a407ccSDmitry Baryshkov .rx_tbl = sc8180x_qmp_pcie_rx_tbl, 179094a407ccSDmitry Baryshkov .rx_tbl_num = ARRAY_SIZE(sc8180x_qmp_pcie_rx_tbl), 179194a407ccSDmitry Baryshkov .pcs_tbl = sc8180x_qmp_pcie_pcs_tbl, 179294a407ccSDmitry Baryshkov .pcs_tbl_num = ARRAY_SIZE(sc8180x_qmp_pcie_pcs_tbl), 179394a407ccSDmitry Baryshkov .pcs_misc_tbl = sc8180x_qmp_pcie_pcs_misc_tbl, 179494a407ccSDmitry Baryshkov .pcs_misc_tbl_num = ARRAY_SIZE(sc8180x_qmp_pcie_pcs_misc_tbl), 179594a407ccSDmitry Baryshkov .clk_list = sdm845_pciephy_clk_l, 179694a407ccSDmitry Baryshkov .num_clks = ARRAY_SIZE(sdm845_pciephy_clk_l), 179794a407ccSDmitry Baryshkov .reset_list = sdm845_pciephy_reset_l, 179894a407ccSDmitry Baryshkov .num_resets = ARRAY_SIZE(sdm845_pciephy_reset_l), 179994a407ccSDmitry Baryshkov .vreg_list = qmp_phy_vreg_l, 180094a407ccSDmitry Baryshkov .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), 180194a407ccSDmitry Baryshkov .regs = sm8250_pcie_regs_layout, 180294a407ccSDmitry Baryshkov 180394a407ccSDmitry Baryshkov .start_ctrl = PCS_START | SERDES_START, 180494a407ccSDmitry Baryshkov .pwrdn_ctrl = SW_PWRDN | REFCLK_DRV_DSBL, 180594a407ccSDmitry Baryshkov 180694a407ccSDmitry Baryshkov .has_pwrdn_delay = true, 180794a407ccSDmitry Baryshkov .pwrdn_delay_min = 995, /* us */ 180894a407ccSDmitry Baryshkov .pwrdn_delay_max = 1005, /* us */ 180994a407ccSDmitry Baryshkov }; 181094a407ccSDmitry Baryshkov 181194a407ccSDmitry Baryshkov static const struct qmp_phy_cfg sdx55_qmp_pciephy_cfg = { 181294a407ccSDmitry Baryshkov .type = PHY_TYPE_PCIE, 181394a407ccSDmitry Baryshkov .nlanes = 2, 181494a407ccSDmitry Baryshkov 181594a407ccSDmitry Baryshkov .serdes_tbl = sdx55_qmp_pcie_serdes_tbl, 181694a407ccSDmitry Baryshkov .serdes_tbl_num = ARRAY_SIZE(sdx55_qmp_pcie_serdes_tbl), 181794a407ccSDmitry Baryshkov .tx_tbl = sdx55_qmp_pcie_tx_tbl, 181894a407ccSDmitry Baryshkov .tx_tbl_num = ARRAY_SIZE(sdx55_qmp_pcie_tx_tbl), 181994a407ccSDmitry Baryshkov .rx_tbl = sdx55_qmp_pcie_rx_tbl, 182094a407ccSDmitry Baryshkov .rx_tbl_num = ARRAY_SIZE(sdx55_qmp_pcie_rx_tbl), 182194a407ccSDmitry Baryshkov .pcs_tbl = sdx55_qmp_pcie_pcs_tbl, 182294a407ccSDmitry Baryshkov .pcs_tbl_num = ARRAY_SIZE(sdx55_qmp_pcie_pcs_tbl), 182394a407ccSDmitry Baryshkov .pcs_misc_tbl = sdx55_qmp_pcie_pcs_misc_tbl, 182494a407ccSDmitry Baryshkov .pcs_misc_tbl_num = ARRAY_SIZE(sdx55_qmp_pcie_pcs_misc_tbl), 182594a407ccSDmitry Baryshkov .clk_list = sdm845_pciephy_clk_l, 182694a407ccSDmitry Baryshkov .num_clks = ARRAY_SIZE(sdm845_pciephy_clk_l), 182794a407ccSDmitry Baryshkov .reset_list = sdm845_pciephy_reset_l, 182894a407ccSDmitry Baryshkov .num_resets = ARRAY_SIZE(sdm845_pciephy_reset_l), 182994a407ccSDmitry Baryshkov .vreg_list = qmp_phy_vreg_l, 183094a407ccSDmitry Baryshkov .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), 183194a407ccSDmitry Baryshkov .regs = sm8250_pcie_regs_layout, 183294a407ccSDmitry Baryshkov 183394a407ccSDmitry Baryshkov .start_ctrl = PCS_START | SERDES_START, 183494a407ccSDmitry Baryshkov .pwrdn_ctrl = SW_PWRDN, 183594a407ccSDmitry Baryshkov .phy_status = PHYSTATUS_4_20, 183694a407ccSDmitry Baryshkov 183794a407ccSDmitry Baryshkov .is_dual_lane_phy = true, 183894a407ccSDmitry Baryshkov .has_pwrdn_delay = true, 183994a407ccSDmitry Baryshkov .pwrdn_delay_min = 995, /* us */ 184094a407ccSDmitry Baryshkov .pwrdn_delay_max = 1005, /* us */ 184194a407ccSDmitry Baryshkov }; 184294a407ccSDmitry Baryshkov 184394a407ccSDmitry Baryshkov static const struct qmp_phy_cfg sm8450_qmp_gen3x1_pciephy_cfg = { 184494a407ccSDmitry Baryshkov .type = PHY_TYPE_PCIE, 184594a407ccSDmitry Baryshkov .nlanes = 1, 184694a407ccSDmitry Baryshkov 184794a407ccSDmitry Baryshkov .serdes_tbl = sm8450_qmp_gen3x1_pcie_serdes_tbl, 184894a407ccSDmitry Baryshkov .serdes_tbl_num = ARRAY_SIZE(sm8450_qmp_gen3x1_pcie_serdes_tbl), 184994a407ccSDmitry Baryshkov .tx_tbl = sm8450_qmp_gen3x1_pcie_tx_tbl, 185094a407ccSDmitry Baryshkov .tx_tbl_num = ARRAY_SIZE(sm8450_qmp_gen3x1_pcie_tx_tbl), 185194a407ccSDmitry Baryshkov .rx_tbl = sm8450_qmp_gen3x1_pcie_rx_tbl, 185294a407ccSDmitry Baryshkov .rx_tbl_num = ARRAY_SIZE(sm8450_qmp_gen3x1_pcie_rx_tbl), 185394a407ccSDmitry Baryshkov .pcs_tbl = sm8450_qmp_gen3x1_pcie_pcs_tbl, 185494a407ccSDmitry Baryshkov .pcs_tbl_num = ARRAY_SIZE(sm8450_qmp_gen3x1_pcie_pcs_tbl), 185594a407ccSDmitry Baryshkov .pcs_misc_tbl = sm8450_qmp_gen3x1_pcie_pcs_misc_tbl, 185694a407ccSDmitry Baryshkov .pcs_misc_tbl_num = ARRAY_SIZE(sm8450_qmp_gen3x1_pcie_pcs_misc_tbl), 185794a407ccSDmitry Baryshkov .clk_list = sdm845_pciephy_clk_l, 185894a407ccSDmitry Baryshkov .num_clks = ARRAY_SIZE(sdm845_pciephy_clk_l), 185994a407ccSDmitry Baryshkov .reset_list = sdm845_pciephy_reset_l, 186094a407ccSDmitry Baryshkov .num_resets = ARRAY_SIZE(sdm845_pciephy_reset_l), 186194a407ccSDmitry Baryshkov .vreg_list = qmp_phy_vreg_l, 186294a407ccSDmitry Baryshkov .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), 186394a407ccSDmitry Baryshkov .regs = sm8250_pcie_regs_layout, 186494a407ccSDmitry Baryshkov 186594a407ccSDmitry Baryshkov .start_ctrl = SERDES_START | PCS_START, 186694a407ccSDmitry Baryshkov .pwrdn_ctrl = SW_PWRDN | REFCLK_DRV_DSBL, 186794a407ccSDmitry Baryshkov .phy_status = PHYSTATUS, 186894a407ccSDmitry Baryshkov 186994a407ccSDmitry Baryshkov .has_pwrdn_delay = true, 187094a407ccSDmitry Baryshkov .pwrdn_delay_min = 995, /* us */ 187194a407ccSDmitry Baryshkov .pwrdn_delay_max = 1005, /* us */ 187294a407ccSDmitry Baryshkov }; 187394a407ccSDmitry Baryshkov 187494a407ccSDmitry Baryshkov static const struct qmp_phy_cfg sm8450_qmp_gen4x2_pciephy_cfg = { 187594a407ccSDmitry Baryshkov .type = PHY_TYPE_PCIE, 187694a407ccSDmitry Baryshkov .nlanes = 2, 187794a407ccSDmitry Baryshkov 187894a407ccSDmitry Baryshkov .serdes_tbl = sm8450_qmp_gen4x2_pcie_serdes_tbl, 187994a407ccSDmitry Baryshkov .serdes_tbl_num = ARRAY_SIZE(sm8450_qmp_gen4x2_pcie_serdes_tbl), 188094a407ccSDmitry Baryshkov .tx_tbl = sm8450_qmp_gen4x2_pcie_tx_tbl, 188194a407ccSDmitry Baryshkov .tx_tbl_num = ARRAY_SIZE(sm8450_qmp_gen4x2_pcie_tx_tbl), 188294a407ccSDmitry Baryshkov .rx_tbl = sm8450_qmp_gen4x2_pcie_rx_tbl, 188394a407ccSDmitry Baryshkov .rx_tbl_num = ARRAY_SIZE(sm8450_qmp_gen4x2_pcie_rx_tbl), 188494a407ccSDmitry Baryshkov .pcs_tbl = sm8450_qmp_gen4x2_pcie_pcs_tbl, 188594a407ccSDmitry Baryshkov .pcs_tbl_num = ARRAY_SIZE(sm8450_qmp_gen4x2_pcie_pcs_tbl), 188694a407ccSDmitry Baryshkov .pcs_misc_tbl = sm8450_qmp_gen4x2_pcie_pcs_misc_tbl, 188794a407ccSDmitry Baryshkov .pcs_misc_tbl_num = ARRAY_SIZE(sm8450_qmp_gen4x2_pcie_pcs_misc_tbl), 188894a407ccSDmitry Baryshkov .clk_list = sdm845_pciephy_clk_l, 188994a407ccSDmitry Baryshkov .num_clks = ARRAY_SIZE(sdm845_pciephy_clk_l), 189094a407ccSDmitry Baryshkov .reset_list = sdm845_pciephy_reset_l, 189194a407ccSDmitry Baryshkov .num_resets = ARRAY_SIZE(sdm845_pciephy_reset_l), 189294a407ccSDmitry Baryshkov .vreg_list = qmp_phy_vreg_l, 189394a407ccSDmitry Baryshkov .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), 189494a407ccSDmitry Baryshkov .regs = sm8250_pcie_regs_layout, 189594a407ccSDmitry Baryshkov 189694a407ccSDmitry Baryshkov .start_ctrl = SERDES_START | PCS_START, 189794a407ccSDmitry Baryshkov .pwrdn_ctrl = SW_PWRDN | REFCLK_DRV_DSBL, 189894a407ccSDmitry Baryshkov .phy_status = PHYSTATUS_4_20, 189994a407ccSDmitry Baryshkov 190094a407ccSDmitry Baryshkov .is_dual_lane_phy = true, 190194a407ccSDmitry Baryshkov .has_pwrdn_delay = true, 190294a407ccSDmitry Baryshkov .pwrdn_delay_min = 995, /* us */ 190394a407ccSDmitry Baryshkov .pwrdn_delay_max = 1005, /* us */ 190494a407ccSDmitry Baryshkov }; 190594a407ccSDmitry Baryshkov 19065dbc7d86SDmitry Baryshkov static void qcom_qmp_phy_pcie_configure_lane(void __iomem *base, 190794a407ccSDmitry Baryshkov const unsigned int *regs, 190894a407ccSDmitry Baryshkov const struct qmp_phy_init_tbl tbl[], 190994a407ccSDmitry Baryshkov int num, 191094a407ccSDmitry Baryshkov u8 lane_mask) 191194a407ccSDmitry Baryshkov { 191294a407ccSDmitry Baryshkov int i; 191394a407ccSDmitry Baryshkov const struct qmp_phy_init_tbl *t = tbl; 191494a407ccSDmitry Baryshkov 191594a407ccSDmitry Baryshkov if (!t) 191694a407ccSDmitry Baryshkov return; 191794a407ccSDmitry Baryshkov 191894a407ccSDmitry Baryshkov for (i = 0; i < num; i++, t++) { 191994a407ccSDmitry Baryshkov if (!(t->lane_mask & lane_mask)) 192094a407ccSDmitry Baryshkov continue; 192194a407ccSDmitry Baryshkov 192294a407ccSDmitry Baryshkov if (t->in_layout) 192394a407ccSDmitry Baryshkov writel(t->val, base + regs[t->offset]); 192494a407ccSDmitry Baryshkov else 192594a407ccSDmitry Baryshkov writel(t->val, base + t->offset); 192694a407ccSDmitry Baryshkov } 192794a407ccSDmitry Baryshkov } 192894a407ccSDmitry Baryshkov 19295dbc7d86SDmitry Baryshkov static void qcom_qmp_phy_pcie_configure(void __iomem *base, 193094a407ccSDmitry Baryshkov const unsigned int *regs, 193194a407ccSDmitry Baryshkov const struct qmp_phy_init_tbl tbl[], 193294a407ccSDmitry Baryshkov int num) 193394a407ccSDmitry Baryshkov { 19345dbc7d86SDmitry Baryshkov qcom_qmp_phy_pcie_configure_lane(base, regs, tbl, num, 0xff); 193594a407ccSDmitry Baryshkov } 193694a407ccSDmitry Baryshkov 19375dbc7d86SDmitry Baryshkov static int qcom_qmp_phy_pcie_serdes_init(struct qmp_phy *qphy) 193894a407ccSDmitry Baryshkov { 193994a407ccSDmitry Baryshkov const struct qmp_phy_cfg *cfg = qphy->cfg; 194094a407ccSDmitry Baryshkov void __iomem *serdes = qphy->serdes; 194194a407ccSDmitry Baryshkov const struct qmp_phy_init_tbl *serdes_tbl = cfg->serdes_tbl; 194294a407ccSDmitry Baryshkov int serdes_tbl_num = cfg->serdes_tbl_num; 194394a407ccSDmitry Baryshkov 19445dbc7d86SDmitry Baryshkov qcom_qmp_phy_pcie_configure(serdes, cfg->regs, serdes_tbl, serdes_tbl_num); 194594a407ccSDmitry Baryshkov if (cfg->serdes_tbl_sec) 19465dbc7d86SDmitry Baryshkov qcom_qmp_phy_pcie_configure(serdes, cfg->regs, cfg->serdes_tbl_sec, 194794a407ccSDmitry Baryshkov cfg->serdes_tbl_num_sec); 194894a407ccSDmitry Baryshkov 194994a407ccSDmitry Baryshkov return 0; 195094a407ccSDmitry Baryshkov } 195194a407ccSDmitry Baryshkov 19525dbc7d86SDmitry Baryshkov static int qcom_qmp_phy_pcie_com_init(struct qmp_phy *qphy) 195394a407ccSDmitry Baryshkov { 195494a407ccSDmitry Baryshkov struct qcom_qmp *qmp = qphy->qmp; 195594a407ccSDmitry Baryshkov const struct qmp_phy_cfg *cfg = qphy->cfg; 195694a407ccSDmitry Baryshkov void __iomem *pcs = qphy->pcs; 1957189ac6b8SDmitry Baryshkov int ret; 195894a407ccSDmitry Baryshkov 195994a407ccSDmitry Baryshkov /* turn on regulator supplies */ 196094a407ccSDmitry Baryshkov ret = regulator_bulk_enable(cfg->num_vregs, qmp->vregs); 196194a407ccSDmitry Baryshkov if (ret) { 196294a407ccSDmitry Baryshkov dev_err(qmp->dev, "failed to enable regulators, err=%d\n", ret); 19631239fd71SDmitry Baryshkov return ret; 196494a407ccSDmitry Baryshkov } 196594a407ccSDmitry Baryshkov 1966189ac6b8SDmitry Baryshkov ret = reset_control_bulk_assert(cfg->num_resets, qmp->resets); 196794a407ccSDmitry Baryshkov if (ret) { 1968189ac6b8SDmitry Baryshkov dev_err(qmp->dev, "reset assert failed\n"); 196994a407ccSDmitry Baryshkov goto err_disable_regulators; 197094a407ccSDmitry Baryshkov } 197194a407ccSDmitry Baryshkov 1972189ac6b8SDmitry Baryshkov ret = reset_control_bulk_deassert(cfg->num_resets, qmp->resets); 197394a407ccSDmitry Baryshkov if (ret) { 1974189ac6b8SDmitry Baryshkov dev_err(qmp->dev, "reset deassert failed\n"); 1975189ac6b8SDmitry Baryshkov goto err_disable_regulators; 197694a407ccSDmitry Baryshkov } 197794a407ccSDmitry Baryshkov 197894a407ccSDmitry Baryshkov ret = clk_bulk_prepare_enable(cfg->num_clks, qmp->clks); 197994a407ccSDmitry Baryshkov if (ret) 198094a407ccSDmitry Baryshkov goto err_assert_reset; 198194a407ccSDmitry Baryshkov 198294a407ccSDmitry Baryshkov if (cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL]) 198394a407ccSDmitry Baryshkov qphy_setbits(pcs, 198494a407ccSDmitry Baryshkov cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL], 198594a407ccSDmitry Baryshkov cfg->pwrdn_ctrl); 198694a407ccSDmitry Baryshkov else 198794a407ccSDmitry Baryshkov qphy_setbits(pcs, QPHY_POWER_DOWN_CONTROL, 198894a407ccSDmitry Baryshkov cfg->pwrdn_ctrl); 198994a407ccSDmitry Baryshkov 199094a407ccSDmitry Baryshkov return 0; 199194a407ccSDmitry Baryshkov 199294a407ccSDmitry Baryshkov err_assert_reset: 1993189ac6b8SDmitry Baryshkov reset_control_bulk_assert(cfg->num_resets, qmp->resets); 199494a407ccSDmitry Baryshkov err_disable_regulators: 199594a407ccSDmitry Baryshkov regulator_bulk_disable(cfg->num_vregs, qmp->vregs); 199694a407ccSDmitry Baryshkov 199794a407ccSDmitry Baryshkov return ret; 199894a407ccSDmitry Baryshkov } 199994a407ccSDmitry Baryshkov 20005dbc7d86SDmitry Baryshkov static int qcom_qmp_phy_pcie_com_exit(struct qmp_phy *qphy) 200194a407ccSDmitry Baryshkov { 200294a407ccSDmitry Baryshkov struct qcom_qmp *qmp = qphy->qmp; 200394a407ccSDmitry Baryshkov const struct qmp_phy_cfg *cfg = qphy->cfg; 200494a407ccSDmitry Baryshkov 2005189ac6b8SDmitry Baryshkov reset_control_bulk_assert(cfg->num_resets, qmp->resets); 200694a407ccSDmitry Baryshkov 200794a407ccSDmitry Baryshkov clk_bulk_disable_unprepare(cfg->num_clks, qmp->clks); 200894a407ccSDmitry Baryshkov 200994a407ccSDmitry Baryshkov regulator_bulk_disable(cfg->num_vregs, qmp->vregs); 201094a407ccSDmitry Baryshkov 201194a407ccSDmitry Baryshkov return 0; 201294a407ccSDmitry Baryshkov } 201394a407ccSDmitry Baryshkov 20145dbc7d86SDmitry Baryshkov static int qcom_qmp_phy_pcie_init(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 int ret; 201994a407ccSDmitry Baryshkov dev_vdbg(qmp->dev, "Initializing QMP phy\n"); 202094a407ccSDmitry Baryshkov 20215dbc7d86SDmitry Baryshkov ret = qcom_qmp_phy_pcie_com_init(qphy); 202294a407ccSDmitry Baryshkov if (ret) 202394a407ccSDmitry Baryshkov return ret; 202494a407ccSDmitry Baryshkov 202594a407ccSDmitry Baryshkov return 0; 202694a407ccSDmitry Baryshkov } 202794a407ccSDmitry Baryshkov 20285dbc7d86SDmitry Baryshkov static int qcom_qmp_phy_pcie_power_on(struct phy *phy) 202994a407ccSDmitry Baryshkov { 203094a407ccSDmitry Baryshkov struct qmp_phy *qphy = phy_get_drvdata(phy); 203194a407ccSDmitry Baryshkov struct qcom_qmp *qmp = qphy->qmp; 203294a407ccSDmitry Baryshkov const struct qmp_phy_cfg *cfg = qphy->cfg; 203394a407ccSDmitry Baryshkov void __iomem *tx = qphy->tx; 203494a407ccSDmitry Baryshkov void __iomem *rx = qphy->rx; 203594a407ccSDmitry Baryshkov void __iomem *pcs = qphy->pcs; 203694a407ccSDmitry Baryshkov void __iomem *pcs_misc = qphy->pcs_misc; 203794a407ccSDmitry Baryshkov void __iomem *status; 203894a407ccSDmitry Baryshkov unsigned int mask, val, ready; 203994a407ccSDmitry Baryshkov int ret; 204094a407ccSDmitry Baryshkov 20415dbc7d86SDmitry Baryshkov qcom_qmp_phy_pcie_serdes_init(qphy); 204294a407ccSDmitry Baryshkov 204394a407ccSDmitry Baryshkov ret = clk_prepare_enable(qphy->pipe_clk); 204494a407ccSDmitry Baryshkov if (ret) { 204594a407ccSDmitry Baryshkov dev_err(qmp->dev, "pipe_clk enable failed err=%d\n", ret); 2046fd926994SDmitry Baryshkov return ret; 204794a407ccSDmitry Baryshkov } 204894a407ccSDmitry Baryshkov 204994a407ccSDmitry Baryshkov /* Tx, Rx, and PCS configurations */ 20505dbc7d86SDmitry Baryshkov qcom_qmp_phy_pcie_configure_lane(tx, cfg->regs, 205194a407ccSDmitry Baryshkov cfg->tx_tbl, cfg->tx_tbl_num, 1); 205294a407ccSDmitry Baryshkov if (cfg->tx_tbl_sec) 20535dbc7d86SDmitry Baryshkov qcom_qmp_phy_pcie_configure_lane(tx, cfg->regs, cfg->tx_tbl_sec, 205494a407ccSDmitry Baryshkov cfg->tx_tbl_num_sec, 1); 205594a407ccSDmitry Baryshkov 205694a407ccSDmitry Baryshkov /* Configuration for other LANE for USB-DP combo PHY */ 205794a407ccSDmitry Baryshkov if (cfg->is_dual_lane_phy) { 20585dbc7d86SDmitry Baryshkov qcom_qmp_phy_pcie_configure_lane(qphy->tx2, cfg->regs, 205994a407ccSDmitry Baryshkov cfg->tx_tbl, cfg->tx_tbl_num, 2); 206094a407ccSDmitry Baryshkov if (cfg->tx_tbl_sec) 20615dbc7d86SDmitry Baryshkov qcom_qmp_phy_pcie_configure_lane(qphy->tx2, cfg->regs, 206294a407ccSDmitry Baryshkov cfg->tx_tbl_sec, 206394a407ccSDmitry Baryshkov cfg->tx_tbl_num_sec, 2); 206494a407ccSDmitry Baryshkov } 206594a407ccSDmitry Baryshkov 20665dbc7d86SDmitry Baryshkov qcom_qmp_phy_pcie_configure_lane(rx, cfg->regs, 206794a407ccSDmitry Baryshkov cfg->rx_tbl, cfg->rx_tbl_num, 1); 206894a407ccSDmitry Baryshkov if (cfg->rx_tbl_sec) 20695dbc7d86SDmitry Baryshkov qcom_qmp_phy_pcie_configure_lane(rx, cfg->regs, 207094a407ccSDmitry Baryshkov cfg->rx_tbl_sec, cfg->rx_tbl_num_sec, 1); 207194a407ccSDmitry Baryshkov 207294a407ccSDmitry Baryshkov if (cfg->is_dual_lane_phy) { 20735dbc7d86SDmitry Baryshkov qcom_qmp_phy_pcie_configure_lane(qphy->rx2, cfg->regs, 207494a407ccSDmitry Baryshkov cfg->rx_tbl, cfg->rx_tbl_num, 2); 207594a407ccSDmitry Baryshkov if (cfg->rx_tbl_sec) 20765dbc7d86SDmitry Baryshkov qcom_qmp_phy_pcie_configure_lane(qphy->rx2, cfg->regs, 207794a407ccSDmitry Baryshkov cfg->rx_tbl_sec, 207894a407ccSDmitry Baryshkov cfg->rx_tbl_num_sec, 2); 207994a407ccSDmitry Baryshkov } 208094a407ccSDmitry Baryshkov 20815dbc7d86SDmitry Baryshkov qcom_qmp_phy_pcie_configure(pcs, cfg->regs, cfg->pcs_tbl, cfg->pcs_tbl_num); 208294a407ccSDmitry Baryshkov if (cfg->pcs_tbl_sec) 20835dbc7d86SDmitry Baryshkov qcom_qmp_phy_pcie_configure(pcs, cfg->regs, cfg->pcs_tbl_sec, 208494a407ccSDmitry Baryshkov cfg->pcs_tbl_num_sec); 208594a407ccSDmitry Baryshkov 20865dbc7d86SDmitry Baryshkov qcom_qmp_phy_pcie_configure(pcs_misc, cfg->regs, cfg->pcs_misc_tbl, 208794a407ccSDmitry Baryshkov cfg->pcs_misc_tbl_num); 208894a407ccSDmitry Baryshkov if (cfg->pcs_misc_tbl_sec) 20895dbc7d86SDmitry Baryshkov qcom_qmp_phy_pcie_configure(pcs_misc, cfg->regs, cfg->pcs_misc_tbl_sec, 209094a407ccSDmitry Baryshkov cfg->pcs_misc_tbl_num_sec); 209194a407ccSDmitry Baryshkov 209294a407ccSDmitry Baryshkov /* 209394a407ccSDmitry Baryshkov * Pull out PHY from POWER DOWN state. 209494a407ccSDmitry Baryshkov * This is active low enable signal to power-down PHY. 209594a407ccSDmitry Baryshkov */ 209694a407ccSDmitry Baryshkov qphy_setbits(pcs, QPHY_POWER_DOWN_CONTROL, cfg->pwrdn_ctrl); 209794a407ccSDmitry Baryshkov 209894a407ccSDmitry Baryshkov if (cfg->has_pwrdn_delay) 209994a407ccSDmitry Baryshkov usleep_range(cfg->pwrdn_delay_min, cfg->pwrdn_delay_max); 210094a407ccSDmitry Baryshkov 210194a407ccSDmitry Baryshkov /* Pull PHY out of reset state */ 210294a407ccSDmitry Baryshkov qphy_clrbits(pcs, cfg->regs[QPHY_SW_RESET], SW_RESET); 2103fd926994SDmitry Baryshkov 210494a407ccSDmitry Baryshkov /* start SerDes and Phy-Coding-Sublayer */ 210594a407ccSDmitry Baryshkov qphy_setbits(pcs, cfg->regs[QPHY_START_CTRL], cfg->start_ctrl); 210694a407ccSDmitry Baryshkov 210794a407ccSDmitry Baryshkov status = pcs + cfg->regs[QPHY_PCS_STATUS]; 210894a407ccSDmitry Baryshkov mask = cfg->phy_status; 210994a407ccSDmitry Baryshkov ready = 0; 211094a407ccSDmitry Baryshkov 211194a407ccSDmitry Baryshkov ret = readl_poll_timeout(status, val, (val & mask) == ready, 10, 211294a407ccSDmitry Baryshkov PHY_INIT_COMPLETE_TIMEOUT); 211394a407ccSDmitry Baryshkov if (ret) { 211494a407ccSDmitry Baryshkov dev_err(qmp->dev, "phy initialization timed-out\n"); 211594a407ccSDmitry Baryshkov goto err_disable_pipe_clk; 211694a407ccSDmitry Baryshkov } 2117da07a06bSDmitry Baryshkov 211894a407ccSDmitry Baryshkov return 0; 211994a407ccSDmitry Baryshkov 212094a407ccSDmitry Baryshkov err_disable_pipe_clk: 212194a407ccSDmitry Baryshkov clk_disable_unprepare(qphy->pipe_clk); 212294a407ccSDmitry Baryshkov 212394a407ccSDmitry Baryshkov return ret; 212494a407ccSDmitry Baryshkov } 212594a407ccSDmitry Baryshkov 21265dbc7d86SDmitry Baryshkov static int qcom_qmp_phy_pcie_power_off(struct phy *phy) 212794a407ccSDmitry Baryshkov { 212894a407ccSDmitry Baryshkov struct qmp_phy *qphy = phy_get_drvdata(phy); 212994a407ccSDmitry Baryshkov const struct qmp_phy_cfg *cfg = qphy->cfg; 213094a407ccSDmitry Baryshkov 213194a407ccSDmitry Baryshkov clk_disable_unprepare(qphy->pipe_clk); 213294a407ccSDmitry Baryshkov 213394a407ccSDmitry Baryshkov /* PHY reset */ 213494a407ccSDmitry Baryshkov qphy_setbits(qphy->pcs, cfg->regs[QPHY_SW_RESET], SW_RESET); 213594a407ccSDmitry Baryshkov 213694a407ccSDmitry Baryshkov /* stop SerDes and Phy-Coding-Sublayer */ 213794a407ccSDmitry Baryshkov qphy_clrbits(qphy->pcs, cfg->regs[QPHY_START_CTRL], cfg->start_ctrl); 213894a407ccSDmitry Baryshkov 213994a407ccSDmitry Baryshkov /* Put PHY into POWER DOWN state: active low */ 214094a407ccSDmitry Baryshkov if (cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL]) { 214194a407ccSDmitry Baryshkov qphy_clrbits(qphy->pcs, cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL], 214294a407ccSDmitry Baryshkov cfg->pwrdn_ctrl); 214394a407ccSDmitry Baryshkov } else { 214494a407ccSDmitry Baryshkov qphy_clrbits(qphy->pcs, QPHY_POWER_DOWN_CONTROL, 214594a407ccSDmitry Baryshkov cfg->pwrdn_ctrl); 214694a407ccSDmitry Baryshkov } 214794a407ccSDmitry Baryshkov 214894a407ccSDmitry Baryshkov return 0; 214994a407ccSDmitry Baryshkov } 215094a407ccSDmitry Baryshkov 21515dbc7d86SDmitry Baryshkov static int qcom_qmp_phy_pcie_exit(struct phy *phy) 215294a407ccSDmitry Baryshkov { 215394a407ccSDmitry Baryshkov struct qmp_phy *qphy = phy_get_drvdata(phy); 215494a407ccSDmitry Baryshkov 21555dbc7d86SDmitry Baryshkov qcom_qmp_phy_pcie_com_exit(qphy); 215694a407ccSDmitry Baryshkov 215794a407ccSDmitry Baryshkov return 0; 215894a407ccSDmitry Baryshkov } 215994a407ccSDmitry Baryshkov 21605dbc7d86SDmitry Baryshkov static int qcom_qmp_phy_pcie_enable(struct phy *phy) 216194a407ccSDmitry Baryshkov { 216294a407ccSDmitry Baryshkov int ret; 216394a407ccSDmitry Baryshkov 21645dbc7d86SDmitry Baryshkov ret = qcom_qmp_phy_pcie_init(phy); 216594a407ccSDmitry Baryshkov if (ret) 216694a407ccSDmitry Baryshkov return ret; 216794a407ccSDmitry Baryshkov 21685dbc7d86SDmitry Baryshkov ret = qcom_qmp_phy_pcie_power_on(phy); 216994a407ccSDmitry Baryshkov if (ret) 21705dbc7d86SDmitry Baryshkov qcom_qmp_phy_pcie_exit(phy); 217194a407ccSDmitry Baryshkov 217294a407ccSDmitry Baryshkov return ret; 217394a407ccSDmitry Baryshkov } 217494a407ccSDmitry Baryshkov 21755dbc7d86SDmitry Baryshkov static int qcom_qmp_phy_pcie_disable(struct phy *phy) 217694a407ccSDmitry Baryshkov { 217794a407ccSDmitry Baryshkov int ret; 217894a407ccSDmitry Baryshkov 21795dbc7d86SDmitry Baryshkov ret = qcom_qmp_phy_pcie_power_off(phy); 218094a407ccSDmitry Baryshkov if (ret) 218194a407ccSDmitry Baryshkov return ret; 21825dbc7d86SDmitry Baryshkov return qcom_qmp_phy_pcie_exit(phy); 218394a407ccSDmitry Baryshkov } 218494a407ccSDmitry Baryshkov 21855dbc7d86SDmitry Baryshkov static int qcom_qmp_phy_pcie_set_mode(struct phy *phy, 218694a407ccSDmitry Baryshkov enum phy_mode mode, int submode) 218794a407ccSDmitry Baryshkov { 218894a407ccSDmitry Baryshkov struct qmp_phy *qphy = phy_get_drvdata(phy); 218994a407ccSDmitry Baryshkov 219094a407ccSDmitry Baryshkov qphy->mode = mode; 219194a407ccSDmitry Baryshkov 219294a407ccSDmitry Baryshkov return 0; 219394a407ccSDmitry Baryshkov } 219494a407ccSDmitry Baryshkov 21955dbc7d86SDmitry Baryshkov static int qcom_qmp_phy_pcie_vreg_init(struct device *dev, const struct qmp_phy_cfg *cfg) 219694a407ccSDmitry Baryshkov { 219794a407ccSDmitry Baryshkov struct qcom_qmp *qmp = dev_get_drvdata(dev); 219894a407ccSDmitry Baryshkov int num = cfg->num_vregs; 219994a407ccSDmitry Baryshkov int i; 220094a407ccSDmitry Baryshkov 220194a407ccSDmitry Baryshkov qmp->vregs = devm_kcalloc(dev, num, sizeof(*qmp->vregs), GFP_KERNEL); 220294a407ccSDmitry Baryshkov if (!qmp->vregs) 220394a407ccSDmitry Baryshkov return -ENOMEM; 220494a407ccSDmitry Baryshkov 220594a407ccSDmitry Baryshkov for (i = 0; i < num; i++) 220694a407ccSDmitry Baryshkov qmp->vregs[i].supply = cfg->vreg_list[i]; 220794a407ccSDmitry Baryshkov 220894a407ccSDmitry Baryshkov return devm_regulator_bulk_get(dev, num, qmp->vregs); 220994a407ccSDmitry Baryshkov } 221094a407ccSDmitry Baryshkov 22115dbc7d86SDmitry Baryshkov static int qcom_qmp_phy_pcie_reset_init(struct device *dev, const struct qmp_phy_cfg *cfg) 221294a407ccSDmitry Baryshkov { 221394a407ccSDmitry Baryshkov struct qcom_qmp *qmp = dev_get_drvdata(dev); 221494a407ccSDmitry Baryshkov int i; 2215189ac6b8SDmitry Baryshkov int ret; 221694a407ccSDmitry Baryshkov 221794a407ccSDmitry Baryshkov qmp->resets = devm_kcalloc(dev, cfg->num_resets, 221894a407ccSDmitry Baryshkov sizeof(*qmp->resets), GFP_KERNEL); 221994a407ccSDmitry Baryshkov if (!qmp->resets) 222094a407ccSDmitry Baryshkov return -ENOMEM; 222194a407ccSDmitry Baryshkov 2222189ac6b8SDmitry Baryshkov for (i = 0; i < cfg->num_resets; i++) 2223189ac6b8SDmitry Baryshkov qmp->resets[i].id = cfg->reset_list[i]; 222494a407ccSDmitry Baryshkov 2225189ac6b8SDmitry Baryshkov ret = devm_reset_control_bulk_get_exclusive(dev, cfg->num_resets, qmp->resets); 2226189ac6b8SDmitry Baryshkov if (ret) 2227189ac6b8SDmitry Baryshkov return dev_err_probe(dev, ret, "failed to get resets\n"); 222894a407ccSDmitry Baryshkov 222994a407ccSDmitry Baryshkov return 0; 223094a407ccSDmitry Baryshkov } 223194a407ccSDmitry Baryshkov 22325dbc7d86SDmitry Baryshkov static int qcom_qmp_phy_pcie_clk_init(struct device *dev, const struct qmp_phy_cfg *cfg) 223394a407ccSDmitry Baryshkov { 223494a407ccSDmitry Baryshkov struct qcom_qmp *qmp = dev_get_drvdata(dev); 223594a407ccSDmitry Baryshkov int num = cfg->num_clks; 223694a407ccSDmitry Baryshkov int i; 223794a407ccSDmitry Baryshkov 223894a407ccSDmitry Baryshkov qmp->clks = devm_kcalloc(dev, num, sizeof(*qmp->clks), GFP_KERNEL); 223994a407ccSDmitry Baryshkov if (!qmp->clks) 224094a407ccSDmitry Baryshkov return -ENOMEM; 224194a407ccSDmitry Baryshkov 224294a407ccSDmitry Baryshkov for (i = 0; i < num; i++) 224394a407ccSDmitry Baryshkov qmp->clks[i].id = cfg->clk_list[i]; 224494a407ccSDmitry Baryshkov 224594a407ccSDmitry Baryshkov return devm_clk_bulk_get(dev, num, qmp->clks); 224694a407ccSDmitry Baryshkov } 224794a407ccSDmitry Baryshkov 224894a407ccSDmitry Baryshkov static void phy_clk_release_provider(void *res) 224994a407ccSDmitry Baryshkov { 225094a407ccSDmitry Baryshkov of_clk_del_provider(res); 225194a407ccSDmitry Baryshkov } 225294a407ccSDmitry Baryshkov 225394a407ccSDmitry Baryshkov /* 225494a407ccSDmitry Baryshkov * Register a fixed rate pipe clock. 225594a407ccSDmitry Baryshkov * 225694a407ccSDmitry Baryshkov * The <s>_pipe_clksrc generated by PHY goes to the GCC that gate 225794a407ccSDmitry Baryshkov * controls it. The <s>_pipe_clk coming out of the GCC is requested 225894a407ccSDmitry Baryshkov * by the PHY driver for its operations. 225994a407ccSDmitry Baryshkov * We register the <s>_pipe_clksrc here. The gcc driver takes care 226094a407ccSDmitry Baryshkov * of assigning this <s>_pipe_clksrc as parent to <s>_pipe_clk. 226194a407ccSDmitry Baryshkov * Below picture shows this relationship. 226294a407ccSDmitry Baryshkov * 226394a407ccSDmitry Baryshkov * +---------------+ 226494a407ccSDmitry Baryshkov * | PHY block |<<---------------------------------------+ 226594a407ccSDmitry Baryshkov * | | | 226694a407ccSDmitry Baryshkov * | +-------+ | +-----+ | 226794a407ccSDmitry Baryshkov * I/P---^-->| PLL |---^--->pipe_clksrc--->| GCC |--->pipe_clk---+ 226894a407ccSDmitry Baryshkov * clk | +-------+ | +-----+ 226994a407ccSDmitry Baryshkov * +---------------+ 227094a407ccSDmitry Baryshkov */ 227194a407ccSDmitry Baryshkov static int phy_pipe_clk_register(struct qcom_qmp *qmp, struct device_node *np) 227294a407ccSDmitry Baryshkov { 227394a407ccSDmitry Baryshkov struct clk_fixed_rate *fixed; 227494a407ccSDmitry Baryshkov struct clk_init_data init = { }; 227594a407ccSDmitry Baryshkov int ret; 227694a407ccSDmitry Baryshkov 227794a407ccSDmitry Baryshkov ret = of_property_read_string(np, "clock-output-names", &init.name); 227894a407ccSDmitry Baryshkov if (ret) { 227994a407ccSDmitry Baryshkov dev_err(qmp->dev, "%pOFn: No clock-output-names\n", np); 228094a407ccSDmitry Baryshkov return ret; 228194a407ccSDmitry Baryshkov } 228294a407ccSDmitry Baryshkov 228394a407ccSDmitry Baryshkov fixed = devm_kzalloc(qmp->dev, sizeof(*fixed), GFP_KERNEL); 228494a407ccSDmitry Baryshkov if (!fixed) 228594a407ccSDmitry Baryshkov return -ENOMEM; 228694a407ccSDmitry Baryshkov 228794a407ccSDmitry Baryshkov init.ops = &clk_fixed_rate_ops; 228894a407ccSDmitry Baryshkov 22892ec9bc8dSRobert Marko /* 22902ec9bc8dSRobert Marko * Controllers using QMP PHY-s use 125MHz pipe clock interface 22912ec9bc8dSRobert Marko * unless other frequency is specified in the PHY config. 22922ec9bc8dSRobert Marko */ 22932ec9bc8dSRobert Marko if (qmp->phys[0]->cfg->pipe_clock_rate) 22942ec9bc8dSRobert Marko fixed->fixed_rate = qmp->phys[0]->cfg->pipe_clock_rate; 22952ec9bc8dSRobert Marko else 229694a407ccSDmitry Baryshkov fixed->fixed_rate = 125000000; 22972ec9bc8dSRobert Marko 229894a407ccSDmitry Baryshkov fixed->hw.init = &init; 229994a407ccSDmitry Baryshkov 230094a407ccSDmitry Baryshkov ret = devm_clk_hw_register(qmp->dev, &fixed->hw); 230194a407ccSDmitry Baryshkov if (ret) 230294a407ccSDmitry Baryshkov return ret; 230394a407ccSDmitry Baryshkov 230494a407ccSDmitry Baryshkov ret = of_clk_add_hw_provider(np, of_clk_hw_simple_get, &fixed->hw); 230594a407ccSDmitry Baryshkov if (ret) 230694a407ccSDmitry Baryshkov return ret; 230794a407ccSDmitry Baryshkov 230894a407ccSDmitry Baryshkov /* 230994a407ccSDmitry Baryshkov * Roll a devm action because the clock provider is the child node, but 231094a407ccSDmitry Baryshkov * the child node is not actually a device. 231194a407ccSDmitry Baryshkov */ 231294a407ccSDmitry Baryshkov return devm_add_action_or_reset(qmp->dev, phy_clk_release_provider, np); 231394a407ccSDmitry Baryshkov } 231494a407ccSDmitry Baryshkov 2315da07a06bSDmitry Baryshkov static const struct phy_ops qcom_qmp_phy_pcie_ops = { 23165bef2838SDmitry Baryshkov .power_on = qcom_qmp_phy_pcie_enable, 23175bef2838SDmitry Baryshkov .power_off = qcom_qmp_phy_pcie_disable, 23185dbc7d86SDmitry Baryshkov .set_mode = qcom_qmp_phy_pcie_set_mode, 231994a407ccSDmitry Baryshkov .owner = THIS_MODULE, 232094a407ccSDmitry Baryshkov }; 232194a407ccSDmitry Baryshkov 232294a407ccSDmitry Baryshkov static 23235dbc7d86SDmitry Baryshkov int qcom_qmp_phy_pcie_create(struct device *dev, struct device_node *np, int id, 232494a407ccSDmitry Baryshkov void __iomem *serdes, const struct qmp_phy_cfg *cfg) 232594a407ccSDmitry Baryshkov { 232694a407ccSDmitry Baryshkov struct qcom_qmp *qmp = dev_get_drvdata(dev); 232794a407ccSDmitry Baryshkov struct phy *generic_phy; 232894a407ccSDmitry Baryshkov struct qmp_phy *qphy; 232994a407ccSDmitry Baryshkov char prop_name[MAX_PROP_NAME]; 233094a407ccSDmitry Baryshkov int ret; 233194a407ccSDmitry Baryshkov 233294a407ccSDmitry Baryshkov qphy = devm_kzalloc(dev, sizeof(*qphy), GFP_KERNEL); 233394a407ccSDmitry Baryshkov if (!qphy) 233494a407ccSDmitry Baryshkov return -ENOMEM; 233594a407ccSDmitry Baryshkov 233694a407ccSDmitry Baryshkov qphy->cfg = cfg; 233794a407ccSDmitry Baryshkov qphy->serdes = serdes; 233894a407ccSDmitry Baryshkov /* 233994a407ccSDmitry Baryshkov * Get memory resources for each phy lane: 234094a407ccSDmitry Baryshkov * Resources are indexed as: tx -> 0; rx -> 1; pcs -> 2. 234194a407ccSDmitry Baryshkov * For dual lane PHYs: tx2 -> 3, rx2 -> 4, pcs_misc (optional) -> 5 234294a407ccSDmitry Baryshkov * For single lane PHYs: pcs_misc (optional) -> 3. 234394a407ccSDmitry Baryshkov */ 234494a407ccSDmitry Baryshkov qphy->tx = of_iomap(np, 0); 234594a407ccSDmitry Baryshkov if (!qphy->tx) 234694a407ccSDmitry Baryshkov return -ENOMEM; 234794a407ccSDmitry Baryshkov 234894a407ccSDmitry Baryshkov qphy->rx = of_iomap(np, 1); 234994a407ccSDmitry Baryshkov if (!qphy->rx) 235094a407ccSDmitry Baryshkov return -ENOMEM; 235194a407ccSDmitry Baryshkov 235294a407ccSDmitry Baryshkov qphy->pcs = of_iomap(np, 2); 235394a407ccSDmitry Baryshkov if (!qphy->pcs) 235494a407ccSDmitry Baryshkov return -ENOMEM; 235594a407ccSDmitry Baryshkov 235694a407ccSDmitry Baryshkov /* 235794a407ccSDmitry Baryshkov * If this is a dual-lane PHY, then there should be registers for the 235894a407ccSDmitry Baryshkov * second lane. Some old device trees did not specify this, so fall 235994a407ccSDmitry Baryshkov * back to old legacy behavior of assuming they can be reached at an 236094a407ccSDmitry Baryshkov * offset from the first lane. 236194a407ccSDmitry Baryshkov */ 236294a407ccSDmitry Baryshkov if (cfg->is_dual_lane_phy) { 236394a407ccSDmitry Baryshkov qphy->tx2 = of_iomap(np, 3); 236494a407ccSDmitry Baryshkov qphy->rx2 = of_iomap(np, 4); 236594a407ccSDmitry Baryshkov if (!qphy->tx2 || !qphy->rx2) { 236694a407ccSDmitry Baryshkov dev_warn(dev, 236794a407ccSDmitry Baryshkov "Underspecified device tree, falling back to legacy register regions\n"); 236894a407ccSDmitry Baryshkov 236994a407ccSDmitry Baryshkov /* In the old version, pcs_misc is at index 3. */ 237094a407ccSDmitry Baryshkov qphy->pcs_misc = qphy->tx2; 237194a407ccSDmitry Baryshkov qphy->tx2 = qphy->tx + QMP_PHY_LEGACY_LANE_STRIDE; 237294a407ccSDmitry Baryshkov qphy->rx2 = qphy->rx + QMP_PHY_LEGACY_LANE_STRIDE; 237394a407ccSDmitry Baryshkov 237494a407ccSDmitry Baryshkov } else { 237594a407ccSDmitry Baryshkov qphy->pcs_misc = of_iomap(np, 5); 237694a407ccSDmitry Baryshkov } 237794a407ccSDmitry Baryshkov 237894a407ccSDmitry Baryshkov } else { 237994a407ccSDmitry Baryshkov qphy->pcs_misc = of_iomap(np, 3); 238094a407ccSDmitry Baryshkov } 238194a407ccSDmitry Baryshkov 2382*af664324SDmitry Baryshkov if (!qphy->pcs_misc && 2383*af664324SDmitry Baryshkov of_device_is_compatible(dev->of_node, "qcom,ipq6018-qmp-pcie-phy")) 2384*af664324SDmitry Baryshkov qphy->pcs_misc = qphy->pcs + 0x400; 2385*af664324SDmitry Baryshkov 238694a407ccSDmitry Baryshkov if (!qphy->pcs_misc) 238794a407ccSDmitry Baryshkov dev_vdbg(dev, "PHY pcs_misc-reg not used\n"); 238894a407ccSDmitry Baryshkov 238994a407ccSDmitry Baryshkov snprintf(prop_name, sizeof(prop_name), "pipe%d", id); 239094a407ccSDmitry Baryshkov qphy->pipe_clk = devm_get_clk_from_child(dev, np, prop_name); 239194a407ccSDmitry Baryshkov if (IS_ERR(qphy->pipe_clk)) { 23928f662cd9SJohan Hovold return dev_err_probe(dev, PTR_ERR(qphy->pipe_clk), 23938f662cd9SJohan Hovold "failed to get lane%d pipe clock\n", id); 239494a407ccSDmitry Baryshkov } 239594a407ccSDmitry Baryshkov 2396da07a06bSDmitry Baryshkov generic_phy = devm_phy_create(dev, np, &qcom_qmp_phy_pcie_ops); 239794a407ccSDmitry Baryshkov if (IS_ERR(generic_phy)) { 239894a407ccSDmitry Baryshkov ret = PTR_ERR(generic_phy); 239994a407ccSDmitry Baryshkov dev_err(dev, "failed to create qphy %d\n", ret); 240094a407ccSDmitry Baryshkov return ret; 240194a407ccSDmitry Baryshkov } 240294a407ccSDmitry Baryshkov 240394a407ccSDmitry Baryshkov qphy->phy = generic_phy; 240494a407ccSDmitry Baryshkov qphy->index = id; 240594a407ccSDmitry Baryshkov qphy->qmp = qmp; 240694a407ccSDmitry Baryshkov qmp->phys[id] = qphy; 240794a407ccSDmitry Baryshkov phy_set_drvdata(generic_phy, qphy); 240894a407ccSDmitry Baryshkov 240994a407ccSDmitry Baryshkov return 0; 241094a407ccSDmitry Baryshkov } 241194a407ccSDmitry Baryshkov 24125dbc7d86SDmitry Baryshkov static const struct of_device_id qcom_qmp_phy_pcie_of_match_table[] = { 241394a407ccSDmitry Baryshkov { 241494a407ccSDmitry Baryshkov .compatible = "qcom,msm8998-qmp-pcie-phy", 241594a407ccSDmitry Baryshkov .data = &msm8998_pciephy_cfg, 241694a407ccSDmitry Baryshkov }, { 241794a407ccSDmitry Baryshkov .compatible = "qcom,ipq8074-qmp-pcie-phy", 241894a407ccSDmitry Baryshkov .data = &ipq8074_pciephy_cfg, 241994a407ccSDmitry Baryshkov }, { 2420334fad18SRobert Marko .compatible = "qcom,ipq8074-qmp-gen3-pcie-phy", 2421334fad18SRobert Marko .data = &ipq8074_pciephy_gen3_cfg, 2422334fad18SRobert Marko }, { 242394a407ccSDmitry Baryshkov .compatible = "qcom,ipq6018-qmp-pcie-phy", 242494a407ccSDmitry Baryshkov .data = &ipq6018_pciephy_cfg, 242594a407ccSDmitry Baryshkov }, { 242694a407ccSDmitry Baryshkov .compatible = "qcom,sc8180x-qmp-pcie-phy", 242794a407ccSDmitry Baryshkov .data = &sc8180x_pciephy_cfg, 242894a407ccSDmitry Baryshkov }, { 242994a407ccSDmitry Baryshkov .compatible = "qcom,sdm845-qhp-pcie-phy", 243094a407ccSDmitry Baryshkov .data = &sdm845_qhp_pciephy_cfg, 243194a407ccSDmitry Baryshkov }, { 243294a407ccSDmitry Baryshkov .compatible = "qcom,sdm845-qmp-pcie-phy", 243394a407ccSDmitry Baryshkov .data = &sdm845_qmp_pciephy_cfg, 243494a407ccSDmitry Baryshkov }, { 243594a407ccSDmitry Baryshkov .compatible = "qcom,sm8250-qmp-gen3x1-pcie-phy", 243694a407ccSDmitry Baryshkov .data = &sm8250_qmp_gen3x1_pciephy_cfg, 243794a407ccSDmitry Baryshkov }, { 243894a407ccSDmitry Baryshkov .compatible = "qcom,sm8250-qmp-gen3x2-pcie-phy", 243994a407ccSDmitry Baryshkov .data = &sm8250_qmp_gen3x2_pciephy_cfg, 244094a407ccSDmitry Baryshkov }, { 244194a407ccSDmitry Baryshkov .compatible = "qcom,sm8250-qmp-modem-pcie-phy", 244294a407ccSDmitry Baryshkov .data = &sm8250_qmp_gen3x2_pciephy_cfg, 244394a407ccSDmitry Baryshkov }, { 244494a407ccSDmitry Baryshkov .compatible = "qcom,sdx55-qmp-pcie-phy", 244594a407ccSDmitry Baryshkov .data = &sdx55_qmp_pciephy_cfg, 244694a407ccSDmitry Baryshkov }, { 244794a407ccSDmitry Baryshkov .compatible = "qcom,sm8450-qmp-gen3x1-pcie-phy", 244894a407ccSDmitry Baryshkov .data = &sm8450_qmp_gen3x1_pciephy_cfg, 244994a407ccSDmitry Baryshkov }, { 245094a407ccSDmitry Baryshkov .compatible = "qcom,sm8450-qmp-gen4x2-pcie-phy", 245194a407ccSDmitry Baryshkov .data = &sm8450_qmp_gen4x2_pciephy_cfg, 245294a407ccSDmitry Baryshkov }, 245394a407ccSDmitry Baryshkov { }, 245494a407ccSDmitry Baryshkov }; 24555dbc7d86SDmitry Baryshkov MODULE_DEVICE_TABLE(of, qcom_qmp_phy_pcie_of_match_table); 245694a407ccSDmitry Baryshkov 24575dbc7d86SDmitry Baryshkov static int qcom_qmp_phy_pcie_probe(struct platform_device *pdev) 245894a407ccSDmitry Baryshkov { 245994a407ccSDmitry Baryshkov struct qcom_qmp *qmp; 246094a407ccSDmitry Baryshkov struct device *dev = &pdev->dev; 246194a407ccSDmitry Baryshkov struct device_node *child; 246294a407ccSDmitry Baryshkov struct phy_provider *phy_provider; 246394a407ccSDmitry Baryshkov void __iomem *serdes; 246494a407ccSDmitry Baryshkov const struct qmp_phy_cfg *cfg = NULL; 24651239fd71SDmitry Baryshkov int num, id; 246694a407ccSDmitry Baryshkov int ret; 246794a407ccSDmitry Baryshkov 246894a407ccSDmitry Baryshkov qmp = devm_kzalloc(dev, sizeof(*qmp), GFP_KERNEL); 246994a407ccSDmitry Baryshkov if (!qmp) 247094a407ccSDmitry Baryshkov return -ENOMEM; 247194a407ccSDmitry Baryshkov 247294a407ccSDmitry Baryshkov qmp->dev = dev; 247394a407ccSDmitry Baryshkov dev_set_drvdata(dev, qmp); 247494a407ccSDmitry Baryshkov 247594a407ccSDmitry Baryshkov /* Get the specific init parameters of QMP phy */ 247694a407ccSDmitry Baryshkov cfg = of_device_get_match_data(dev); 2477b35a5311SDmitry Baryshkov if (!cfg) 247894a407ccSDmitry Baryshkov return -EINVAL; 247994a407ccSDmitry Baryshkov 248094a407ccSDmitry Baryshkov /* per PHY serdes; usually located at base address */ 2481da07a06bSDmitry Baryshkov serdes = devm_platform_ioremap_resource(pdev, 0); 248294a407ccSDmitry Baryshkov if (IS_ERR(serdes)) 248394a407ccSDmitry Baryshkov return PTR_ERR(serdes); 248494a407ccSDmitry Baryshkov 24855dbc7d86SDmitry Baryshkov ret = qcom_qmp_phy_pcie_clk_init(dev, cfg); 248694a407ccSDmitry Baryshkov if (ret) 248794a407ccSDmitry Baryshkov return ret; 248894a407ccSDmitry Baryshkov 24895dbc7d86SDmitry Baryshkov ret = qcom_qmp_phy_pcie_reset_init(dev, cfg); 249094a407ccSDmitry Baryshkov if (ret) 249194a407ccSDmitry Baryshkov return ret; 249294a407ccSDmitry Baryshkov 24935dbc7d86SDmitry Baryshkov ret = qcom_qmp_phy_pcie_vreg_init(dev, cfg); 249494a407ccSDmitry Baryshkov if (ret) { 249594a407ccSDmitry Baryshkov if (ret != -EPROBE_DEFER) 249694a407ccSDmitry Baryshkov dev_err(dev, "failed to get regulator supplies: %d\n", 249794a407ccSDmitry Baryshkov ret); 249894a407ccSDmitry Baryshkov return ret; 249994a407ccSDmitry Baryshkov } 250094a407ccSDmitry Baryshkov 250194a407ccSDmitry Baryshkov num = of_get_available_child_count(dev->of_node); 250294a407ccSDmitry Baryshkov /* do we have a rogue child node ? */ 25031239fd71SDmitry Baryshkov if (num > 1) 250494a407ccSDmitry Baryshkov return -EINVAL; 250594a407ccSDmitry Baryshkov 250694a407ccSDmitry Baryshkov qmp->phys = devm_kcalloc(dev, num, sizeof(*qmp->phys), GFP_KERNEL); 250794a407ccSDmitry Baryshkov if (!qmp->phys) 250894a407ccSDmitry Baryshkov return -ENOMEM; 250994a407ccSDmitry Baryshkov 251094a407ccSDmitry Baryshkov pm_runtime_set_active(dev); 251194a407ccSDmitry Baryshkov pm_runtime_enable(dev); 251294a407ccSDmitry Baryshkov /* 251394a407ccSDmitry Baryshkov * Prevent runtime pm from being ON by default. Users can enable 251494a407ccSDmitry Baryshkov * it using power/control in sysfs. 251594a407ccSDmitry Baryshkov */ 251694a407ccSDmitry Baryshkov pm_runtime_forbid(dev); 251794a407ccSDmitry Baryshkov 251894a407ccSDmitry Baryshkov id = 0; 251994a407ccSDmitry Baryshkov for_each_available_child_of_node(dev->of_node, child) { 252094a407ccSDmitry Baryshkov /* Create per-lane phy */ 25215dbc7d86SDmitry Baryshkov ret = qcom_qmp_phy_pcie_create(dev, child, id, serdes, cfg); 252294a407ccSDmitry Baryshkov if (ret) { 252394a407ccSDmitry Baryshkov dev_err(dev, "failed to create lane%d phy, %d\n", 252494a407ccSDmitry Baryshkov id, ret); 252594a407ccSDmitry Baryshkov goto err_node_put; 252694a407ccSDmitry Baryshkov } 252794a407ccSDmitry Baryshkov 252894a407ccSDmitry Baryshkov /* 252994a407ccSDmitry Baryshkov * Register the pipe clock provided by phy. 253094a407ccSDmitry Baryshkov * See function description to see details of this pipe clock. 253194a407ccSDmitry Baryshkov */ 253294a407ccSDmitry Baryshkov ret = phy_pipe_clk_register(qmp, child); 253394a407ccSDmitry Baryshkov if (ret) { 253494a407ccSDmitry Baryshkov dev_err(qmp->dev, 253594a407ccSDmitry Baryshkov "failed to register pipe clock source\n"); 253694a407ccSDmitry Baryshkov goto err_node_put; 253794a407ccSDmitry Baryshkov } 2538da07a06bSDmitry Baryshkov 253994a407ccSDmitry Baryshkov id++; 254094a407ccSDmitry Baryshkov } 254194a407ccSDmitry Baryshkov 254294a407ccSDmitry Baryshkov phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); 254394a407ccSDmitry Baryshkov if (!IS_ERR(phy_provider)) 254494a407ccSDmitry Baryshkov dev_info(dev, "Registered Qcom-QMP phy\n"); 254594a407ccSDmitry Baryshkov else 254694a407ccSDmitry Baryshkov pm_runtime_disable(dev); 254794a407ccSDmitry Baryshkov 254894a407ccSDmitry Baryshkov return PTR_ERR_OR_ZERO(phy_provider); 254994a407ccSDmitry Baryshkov 255094a407ccSDmitry Baryshkov err_node_put: 255194a407ccSDmitry Baryshkov pm_runtime_disable(dev); 255294a407ccSDmitry Baryshkov of_node_put(child); 255394a407ccSDmitry Baryshkov return ret; 255494a407ccSDmitry Baryshkov } 255594a407ccSDmitry Baryshkov 25565dbc7d86SDmitry Baryshkov static struct platform_driver qcom_qmp_phy_pcie_driver = { 25575dbc7d86SDmitry Baryshkov .probe = qcom_qmp_phy_pcie_probe, 255894a407ccSDmitry Baryshkov .driver = { 2559b35a5311SDmitry Baryshkov .name = "qcom-qmp-pcie-phy", 25605dbc7d86SDmitry Baryshkov .of_match_table = qcom_qmp_phy_pcie_of_match_table, 256194a407ccSDmitry Baryshkov }, 256294a407ccSDmitry Baryshkov }; 256394a407ccSDmitry Baryshkov 25645dbc7d86SDmitry Baryshkov module_platform_driver(qcom_qmp_phy_pcie_driver); 256594a407ccSDmitry Baryshkov 256694a407ccSDmitry Baryshkov MODULE_AUTHOR("Vivek Gautam <vivek.gautam@codeaurora.org>"); 2567b35a5311SDmitry Baryshkov MODULE_DESCRIPTION("Qualcomm QMP PCIe PHY driver"); 256894a407ccSDmitry Baryshkov MODULE_LICENSE("GPL v2"); 2569