xref: /openbmc/linux/drivers/phy/qualcomm/phy-qcom-qmp-pcie.c (revision 5cbeb75a36aa28353e51f5e6926e19449a4f3389)
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>
1711bf53a3SDmitry Baryshkov #include <linux/phy/pcie.h>
1894a407ccSDmitry Baryshkov #include <linux/phy/phy.h>
1994a407ccSDmitry Baryshkov #include <linux/platform_device.h>
2094a407ccSDmitry Baryshkov #include <linux/regulator/consumer.h>
2194a407ccSDmitry Baryshkov #include <linux/reset.h>
2294a407ccSDmitry Baryshkov #include <linux/slab.h>
2394a407ccSDmitry Baryshkov 
2494a407ccSDmitry Baryshkov #include <dt-bindings/phy/phy.h>
2594a407ccSDmitry Baryshkov 
2694a407ccSDmitry Baryshkov #include "phy-qcom-qmp.h"
2794a407ccSDmitry Baryshkov 
2894a407ccSDmitry Baryshkov /* QPHY_SW_RESET bit */
2994a407ccSDmitry Baryshkov #define SW_RESET				BIT(0)
3094a407ccSDmitry Baryshkov /* QPHY_POWER_DOWN_CONTROL */
3194a407ccSDmitry Baryshkov #define SW_PWRDN				BIT(0)
3294a407ccSDmitry Baryshkov #define REFCLK_DRV_DSBL				BIT(1)
3394a407ccSDmitry Baryshkov /* QPHY_START_CONTROL bits */
3494a407ccSDmitry Baryshkov #define SERDES_START				BIT(0)
3594a407ccSDmitry Baryshkov #define PCS_START				BIT(1)
3694a407ccSDmitry Baryshkov /* QPHY_PCS_STATUS bit */
3794a407ccSDmitry Baryshkov #define PHYSTATUS				BIT(6)
3894a407ccSDmitry Baryshkov #define PHYSTATUS_4_20				BIT(7)
3994a407ccSDmitry Baryshkov 
4094a407ccSDmitry Baryshkov #define PHY_INIT_COMPLETE_TIMEOUT		10000
4194a407ccSDmitry Baryshkov 
4294a407ccSDmitry Baryshkov struct qmp_phy_init_tbl {
4394a407ccSDmitry Baryshkov 	unsigned int offset;
4494a407ccSDmitry Baryshkov 	unsigned int val;
4594a407ccSDmitry Baryshkov 	/*
4694a407ccSDmitry Baryshkov 	 * mask of lanes for which this register is written
4794a407ccSDmitry Baryshkov 	 * for cases when second lane needs different values
4894a407ccSDmitry Baryshkov 	 */
4994a407ccSDmitry Baryshkov 	u8 lane_mask;
5094a407ccSDmitry Baryshkov };
5194a407ccSDmitry Baryshkov 
5294a407ccSDmitry Baryshkov #define QMP_PHY_INIT_CFG(o, v)		\
5394a407ccSDmitry Baryshkov 	{				\
5494a407ccSDmitry Baryshkov 		.offset = o,		\
5594a407ccSDmitry Baryshkov 		.val = v,		\
5694a407ccSDmitry Baryshkov 		.lane_mask = 0xff,	\
5794a407ccSDmitry Baryshkov 	}
5894a407ccSDmitry Baryshkov 
5994a407ccSDmitry Baryshkov #define QMP_PHY_INIT_CFG_LANE(o, v, l)	\
6094a407ccSDmitry Baryshkov 	{				\
6194a407ccSDmitry Baryshkov 		.offset = o,		\
6294a407ccSDmitry Baryshkov 		.val = v,		\
6394a407ccSDmitry Baryshkov 		.lane_mask = l,		\
6494a407ccSDmitry Baryshkov 	}
6594a407ccSDmitry Baryshkov 
6694a407ccSDmitry Baryshkov /* set of registers with offsets different per-PHY */
6794a407ccSDmitry Baryshkov enum qphy_reg_layout {
6894a407ccSDmitry Baryshkov 	/* PCS registers */
6994a407ccSDmitry Baryshkov 	QPHY_SW_RESET,
7094a407ccSDmitry Baryshkov 	QPHY_START_CTRL,
7194a407ccSDmitry Baryshkov 	QPHY_PCS_STATUS,
7294a407ccSDmitry Baryshkov 	QPHY_PCS_POWER_DOWN_CONTROL,
7394a407ccSDmitry Baryshkov 	/* Keep last to ensure regs_layout arrays are properly initialized */
7494a407ccSDmitry Baryshkov 	QPHY_LAYOUT_SIZE
7594a407ccSDmitry Baryshkov };
7694a407ccSDmitry Baryshkov 
7794a407ccSDmitry Baryshkov static const unsigned int ipq_pciephy_gen3_regs_layout[QPHY_LAYOUT_SIZE] = {
7894a407ccSDmitry Baryshkov 	[QPHY_SW_RESET]				= 0x00,
7994a407ccSDmitry Baryshkov 	[QPHY_START_CTRL]			= 0x44,
8094a407ccSDmitry Baryshkov 	[QPHY_PCS_STATUS]			= 0x14,
8194a407ccSDmitry Baryshkov 	[QPHY_PCS_POWER_DOWN_CONTROL]		= 0x40,
8294a407ccSDmitry Baryshkov };
8394a407ccSDmitry Baryshkov 
8494a407ccSDmitry Baryshkov static const unsigned int pciephy_regs_layout[QPHY_LAYOUT_SIZE] = {
8594a407ccSDmitry Baryshkov 	[QPHY_SW_RESET]			= 0x00,
8694a407ccSDmitry Baryshkov 	[QPHY_START_CTRL]		= 0x08,
8794a407ccSDmitry Baryshkov 	[QPHY_PCS_STATUS]		= 0x174,
886d5b1e20SJohan Hovold 	[QPHY_PCS_POWER_DOWN_CONTROL]	= 0x04,
8994a407ccSDmitry Baryshkov };
9094a407ccSDmitry Baryshkov 
9194a407ccSDmitry Baryshkov static const unsigned int sdm845_qmp_pciephy_regs_layout[QPHY_LAYOUT_SIZE] = {
9294a407ccSDmitry Baryshkov 	[QPHY_SW_RESET]			= 0x00,
9394a407ccSDmitry Baryshkov 	[QPHY_START_CTRL]		= 0x08,
9494a407ccSDmitry Baryshkov 	[QPHY_PCS_STATUS]		= 0x174,
956d5b1e20SJohan Hovold 	[QPHY_PCS_POWER_DOWN_CONTROL]	= 0x04,
9694a407ccSDmitry Baryshkov };
9794a407ccSDmitry Baryshkov 
9894a407ccSDmitry Baryshkov static const unsigned int sdm845_qhp_pciephy_regs_layout[QPHY_LAYOUT_SIZE] = {
9994a407ccSDmitry Baryshkov 	[QPHY_SW_RESET]			= 0x00,
10094a407ccSDmitry Baryshkov 	[QPHY_START_CTRL]		= 0x08,
10194a407ccSDmitry Baryshkov 	[QPHY_PCS_STATUS]		= 0x2ac,
1026d5b1e20SJohan Hovold 	[QPHY_PCS_POWER_DOWN_CONTROL]	= 0x04,
10394a407ccSDmitry Baryshkov };
10494a407ccSDmitry Baryshkov 
10594a407ccSDmitry Baryshkov static const unsigned int sm8250_pcie_regs_layout[QPHY_LAYOUT_SIZE] = {
10694a407ccSDmitry Baryshkov 	[QPHY_SW_RESET]			= 0x00,
10794a407ccSDmitry Baryshkov 	[QPHY_START_CTRL]		= 0x44,
10894a407ccSDmitry Baryshkov 	[QPHY_PCS_STATUS]		= 0x14,
10994a407ccSDmitry Baryshkov 	[QPHY_PCS_POWER_DOWN_CONTROL]	= 0x40,
11094a407ccSDmitry Baryshkov };
11194a407ccSDmitry Baryshkov 
11294a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl msm8998_pcie_serdes_tbl[] = {
11394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_BIAS_EN_CLKBUFLR_EN, 0x14),
11494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_SELECT, 0x30),
11594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_IVCO, 0x0f),
11694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CMN_CONFIG, 0x06),
11794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP_EN, 0x01),
11894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_RESETSM_CNTRL, 0x20),
11994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_MAP, 0x00),
12094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE2_MODE0, 0x01),
12194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE1_MODE0, 0xc9),
12294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_TIMER1, 0xff),
12394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_TIMER2, 0x3f),
12494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SVS_MODE_CLK_SEL, 0x01),
12594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CORE_CLK_EN, 0x00),
12694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CORECLK_DIV_MODE0, 0x0a),
12794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_EP_DIV, 0x19),
12894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_ENABLE1, 0x90),
12994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_DEC_START_MODE0, 0x82),
13094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START3_MODE0, 0x03),
13194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START2_MODE0, 0x55),
13294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START1_MODE0, 0x55),
13394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP3_MODE0, 0x00),
13494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP2_MODE0, 0x0d),
13594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP1_MODE0, 0x04),
13694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_HSCLK_SEL, 0x00),
13794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CP_CTRL_MODE0, 0x08),
13894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_RCTRL_MODE0, 0x16),
13994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_CCTRL_MODE0, 0x34),
14094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CMN_CONFIG, 0x06),
14194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_SELECT, 0x33),
14294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYS_CLK_CTRL, 0x02),
14394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYSCLK_BUF_ENABLE, 0x07),
14494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYSCLK_EN_SEL, 0x04),
14594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN1_MODE0, 0x00),
14694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN0_MODE0, 0x3f),
14794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_BG_TIMER, 0x09),
14894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_EN_CENTER, 0x01),
14994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_PER1, 0x40),
15094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_PER2, 0x01),
15194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_ADJ_PER1, 0x02),
15294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_ADJ_PER2, 0x00),
15394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_STEP_SIZE1, 0x7e),
15494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_STEP_SIZE2, 0x15),
15594a407ccSDmitry Baryshkov };
15694a407ccSDmitry Baryshkov 
15794a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl msm8998_pcie_tx_tbl[] = {
15894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_TX_RES_CODE_LANE_OFFSET_TX, 0x02),
15994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_TX_RCV_DETECT_LVL_2, 0x12),
16094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_TX_HIGHZ_DRVR_EN, 0x10),
16194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_TX_LANE_MODE_1, 0x06),
16294a407ccSDmitry Baryshkov };
16394a407ccSDmitry Baryshkov 
16494a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl msm8998_pcie_rx_tbl[] = {
16594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_CNTRL, 0x03),
16694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_ENABLES, 0x1c),
16794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_DEGLITCH_CNTRL, 0x14),
16894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL2, 0x0a),
16994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL3, 0x04),
17094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL4, 0x1a),
17194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x4b),
17294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SO_GAIN, 0x04),
17394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SO_GAIN_HALF, 0x04),
17494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1, 0x00),
17594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_OFFSET_ADAPTOR_CNTRL2, 0x80),
17694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_INTERFACE_MODE, 0x40),
17794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_PI_CONTROLS, 0x71),
17894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_FASTLOCK_COUNT_LOW, 0x40),
17994a407ccSDmitry Baryshkov };
18094a407ccSDmitry Baryshkov 
18194a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl msm8998_pcie_pcs_tbl[] = {
18294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V3_PCS_ENDPOINT_REFCLK_DRIVE, 0x04),
18394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V3_PCS_OSC_DTCT_ACTIONS, 0x00),
18494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V3_PCS_PWRUP_RESET_DLY_TIME_AUXCLK, 0x01),
18594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V3_PCS_L1SS_WAKEUP_DLY_TIME_AUXCLK_MSB, 0x00),
18694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V3_PCS_L1SS_WAKEUP_DLY_TIME_AUXCLK_LSB, 0x20),
18794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V3_PCS_LP_WAKEUP_DLY_TIME_AUXCLK_MSB, 0x00),
18894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V3_PCS_LP_WAKEUP_DLY_TIME_AUXCLK, 0x01),
18994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V3_PCS_PLL_LOCK_CHK_DLY_TIME, 0x73),
19094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V3_PCS_RX_SIGDET_LVL, 0x99),
19194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V3_PCS_SIGDET_CNTRL, 0x03),
19294a407ccSDmitry Baryshkov };
19394a407ccSDmitry Baryshkov 
19494a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl ipq6018_pcie_serdes_tbl[] = {
19594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_SSC_PER1, 0x7d),
19694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_SSC_PER2, 0x01),
19794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_SSC_STEP_SIZE1_MODE0, 0x0a),
19894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_SSC_STEP_SIZE2_MODE0, 0x05),
19994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_SSC_STEP_SIZE1_MODE1, 0x08),
20094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_SSC_STEP_SIZE2_MODE1, 0x04),
20194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_BIAS_EN_CLKBUFLR_EN, 0x18),
20294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_CLK_ENABLE1, 0x90),
20394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_SYS_CLK_CTRL, 0x02),
20494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_SYSCLK_BUF_ENABLE, 0x07),
20594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_PLL_IVCO, 0x0f),
20694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_LOCK_CMP1_MODE0, 0xd4),
20794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_LOCK_CMP2_MODE0, 0x14),
20894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_LOCK_CMP1_MODE1, 0xaa),
20994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_LOCK_CMP2_MODE1, 0x29),
21094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_BG_TRIM, 0x0f),
21194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_CP_CTRL_MODE0, 0x09),
21294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_CP_CTRL_MODE1, 0x09),
21394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_PLL_RCTRL_MODE0, 0x16),
21494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_PLL_RCTRL_MODE1, 0x16),
21594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_PLL_CCTRL_MODE0, 0x28),
21694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_PLL_CCTRL_MODE1, 0x28),
21794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_BIAS_EN_CTRL_BY_PSM, 0x01),
21894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_SYSCLK_EN_SEL, 0x08),
21994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_RESETSM_CNTRL, 0x20),
22094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_LOCK_CMP_EN, 0x42),
22194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_DEC_START_MODE0, 0x68),
22294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_DEC_START_MODE1, 0x53),
22394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_DIV_FRAC_START1_MODE0, 0xab),
22494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_DIV_FRAC_START2_MODE0, 0xaa),
22594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_DIV_FRAC_START3_MODE0, 0x02),
22694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_DIV_FRAC_START1_MODE1, 0x55),
22794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_DIV_FRAC_START2_MODE1, 0x55),
22894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_DIV_FRAC_START3_MODE1, 0x05),
22994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_INTEGLOOP_GAIN0_MODE0, 0xa0),
23094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_INTEGLOOP_GAIN0_MODE1, 0xa0),
23194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_VCO_TUNE1_MODE0, 0x24),
23294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_VCO_TUNE2_MODE0, 0x02),
23394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_VCO_TUNE1_MODE1, 0xb4),
23494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_VCO_TUNE2_MODE1, 0x03),
23594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_CLK_SELECT, 0x32),
23694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_HSCLK_SEL, 0x01),
23794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_CORE_CLK_EN, 0x00),
23894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_CMN_CONFIG, 0x06),
23994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_SVS_MODE_CLK_SEL, 0x05),
24094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_CORECLK_DIV_MODE1, 0x08),
24194a407ccSDmitry Baryshkov };
24294a407ccSDmitry Baryshkov 
24394a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl ipq6018_pcie_tx_tbl[] = {
244079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_TX_RES_CODE_LANE_OFFSET_TX, 0x02),
245079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_TX_LANE_MODE_1, 0x06),
246079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_TX_RCV_DETECT_LVL_2, 0x12),
24794a407ccSDmitry Baryshkov };
24894a407ccSDmitry Baryshkov 
24994a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl ipq6018_pcie_rx_tbl[] = {
250079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_FO_GAIN, 0x0c),
251079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SO_GAIN, 0x02),
252079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x7f),
253079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_PI_CONTROLS, 0x70),
254079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL2, 0x61),
255079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL3, 0x04),
256079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL4, 0x1e),
257079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_IDAC_TSETTLE_LOW, 0xc0),
258079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_IDAC_TSETTLE_HIGH, 0x00),
259079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1, 0x73),
260079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_OFFSET_ADAPTOR_CNTRL2, 0x80),
261079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_ENABLES, 0x1c),
262079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_CNTRL, 0x03),
263079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_DEGLITCH_CNTRL, 0x14),
264079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_LOW, 0xf0),
265079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH, 0x01),
266079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH2, 0x2f),
267079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH3, 0xd3),
268079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH4, 0x40),
269079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_LOW, 0x01),
270079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH, 0x02),
271079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH2, 0xc8),
272079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH3, 0x09),
273079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH4, 0xb1),
274079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_LOW, 0x00),
275079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH, 0x02),
276079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH2, 0xc8),
277079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH3, 0x09),
278079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH4, 0xb1),
279079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_DFE_EN_TIMER, 0x04),
28094a407ccSDmitry Baryshkov };
28194a407ccSDmitry Baryshkov 
28294a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl ipq6018_pcie_pcs_tbl[] = {
28360f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_FLL_CNTRL1, 0x01),
28460f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_REFGEN_REQ_CONFIG1, 0x0d),
28560f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_G12S1_TXDEEMPH_M3P5DB, 0x10),
28660f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_RX_SIGDET_LVL, 0xaa),
28760f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_P2U3_WAKEUP_DLY_TIME_AUXCLK_L, 0x01),
28860f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_RX_DCC_CAL_CONFIG, 0x01),
28960f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_EQ_CONFIG5, 0x01),
290af664324SDmitry Baryshkov };
291af664324SDmitry Baryshkov 
292af664324SDmitry Baryshkov static const struct qmp_phy_init_tbl ipq6018_pcie_pcs_misc_tbl[] = {
29360f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_POWER_STATE_CONFIG2, 0x0d),
29460f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_POWER_STATE_CONFIG4, 0x07),
29560f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_ENDPOINT_REFCLK_DRIVE, 0xc1),
29660f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_L1P1_WAKEUP_DLY_TIME_AUXCLK_L, 0x01),
29760f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_L1P2_WAKEUP_DLY_TIME_AUXCLK_L, 0x01),
29860f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_OSC_DTCT_ACTIONS, 0x00),
29960f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_EQ_CONFIG1, 0x11),
30060f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_PRESET_P10_PRE, 0x00),
30160f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_PRESET_P10_POST, 0x58),
30294a407ccSDmitry Baryshkov };
30394a407ccSDmitry Baryshkov 
30494a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl ipq8074_pcie_serdes_tbl[] = {
30594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_BIAS_EN_CLKBUFLR_EN, 0x18),
30694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_CLK_ENABLE1, 0x10),
30794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_BG_TRIM, 0xf),
30894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP_EN, 0x1),
30994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_MAP, 0x0),
31094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_TIMER1, 0xff),
31194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_TIMER2, 0x1f),
31294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_CMN_CONFIG, 0x6),
31394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_PLL_IVCO, 0xf),
31494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_HSCLK_SEL, 0x0),
31594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_SVS_MODE_CLK_SEL, 0x1),
31694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_CORE_CLK_EN, 0x20),
31794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_CORECLK_DIV, 0xa),
31894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_RESETSM_CNTRL, 0x20),
31994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_BG_TIMER, 0xa),
32094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_SYSCLK_EN_SEL, 0xa),
32194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_DEC_START_MODE0, 0x82),
32294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_DIV_FRAC_START3_MODE0, 0x3),
32394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_DIV_FRAC_START2_MODE0, 0x55),
32494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_DIV_FRAC_START1_MODE0, 0x55),
32594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP3_MODE0, 0x0),
32694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP2_MODE0, 0xD),
32794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP1_MODE0, 0xD04),
32894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_CLK_SELECT, 0x33),
32994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_SYS_CLK_CTRL, 0x2),
33094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_SYSCLK_BUF_ENABLE, 0x1f),
33194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_CP_CTRL_MODE0, 0xb),
33294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_PLL_RCTRL_MODE0, 0x16),
33394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_PLL_CCTRL_MODE0, 0x28),
33494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_INTEGLOOP_GAIN1_MODE0, 0x0),
33594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_INTEGLOOP_GAIN0_MODE0, 0x80),
33694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_BIAS_EN_CTRL_BY_PSM, 0x1),
33794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_SSC_EN_CENTER, 0x1),
33894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_SSC_PER1, 0x31),
33994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_SSC_PER2, 0x1),
34094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_SSC_ADJ_PER1, 0x2),
34194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_SSC_ADJ_PER2, 0x0),
34294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_SSC_STEP_SIZE1, 0x2f),
34394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_SSC_STEP_SIZE2, 0x19),
34494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_CLK_EP_DIV, 0x19),
34594a407ccSDmitry Baryshkov };
34694a407ccSDmitry Baryshkov 
34794a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl ipq8074_pcie_tx_tbl[] = {
34894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_TX_HIGHZ_TRANSCEIVEREN_BIAS_DRVR_EN, 0x45),
34994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_TX_LANE_MODE, 0x6),
35094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_TX_RES_CODE_LANE_OFFSET, 0x2),
35194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_TX_RCV_DETECT_LVL_2, 0x12),
352f7c5cedbSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_TX_TX_EMP_POST1_LVL, 0x36),
35394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_TX_SLEW_CNTL, 0x0a),
35494a407ccSDmitry Baryshkov };
35594a407ccSDmitry Baryshkov 
35694a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl ipq8074_pcie_rx_tbl[] = {
35794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_RX_SIGDET_ENABLES, 0x1c),
35894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_RX_SIGDET_DEGLITCH_CNTRL, 0x14),
35994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_RX_RX_EQU_ADAPTOR_CNTRL2, 0x1),
36094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_RX_RX_EQU_ADAPTOR_CNTRL3, 0x0),
36194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_RX_RX_EQU_ADAPTOR_CNTRL4, 0xdb),
36294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x4b),
36394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_RX_UCDR_SO_GAIN, 0x4),
36494a407ccSDmitry Baryshkov };
36594a407ccSDmitry Baryshkov 
36694a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl ipq8074_pcie_pcs_tbl[] = {
3676cad2983SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V2_PCS_ENDPOINT_REFCLK_DRIVE, 0x4),
3686cad2983SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V2_PCS_OSC_DTCT_ACTIONS, 0x0),
3696cad2983SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V2_PCS_PWRUP_RESET_DLY_TIME_AUXCLK, 0x40),
3706cad2983SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V2_PCS_L1SS_WAKEUP_DLY_TIME_AUXCLK_MSB, 0x0),
3716cad2983SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V2_PCS_L1SS_WAKEUP_DLY_TIME_AUXCLK_LSB, 0x40),
3726cad2983SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V2_PCS_PLL_LOCK_CHK_DLY_TIME_AUXCLK_LSB, 0x0),
3736cad2983SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V2_PCS_LP_WAKEUP_DLY_TIME_AUXCLK, 0x40),
374c1ab64aaSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V2_PCS_PLL_LOCK_CHK_DLY_TIME, 0x73),
3756cad2983SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V2_PCS_RX_SIGDET_LVL, 0x99),
3766cad2983SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V2_PCS_TXDEEMPH_M6DB_V0, 0x15),
3776cad2983SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V2_PCS_TXDEEMPH_M3P5DB_V0, 0xe),
37894a407ccSDmitry Baryshkov };
37994a407ccSDmitry Baryshkov 
380334fad18SRobert Marko static const struct qmp_phy_init_tbl ipq8074_pcie_gen3_serdes_tbl[] = {
381334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_BIAS_EN_CLKBUFLR_EN, 0x18),
382334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_BIAS_EN_CTRL_BY_PSM, 0x01),
383334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_CLK_SELECT, 0x31),
384334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_PLL_IVCO, 0x0f),
385334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_BG_TRIM, 0x0f),
386334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_CMN_CONFIG, 0x06),
387334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_LOCK_CMP_EN, 0x42),
388334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_RESETSM_CNTRL, 0x20),
389334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_SVS_MODE_CLK_SEL, 0x01),
390334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_VCO_TUNE_MAP, 0x04),
391334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_SVS_MODE_CLK_SEL, 0x05),
392334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_VCO_TUNE_TIMER1, 0xff),
393334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_VCO_TUNE_TIMER2, 0x3f),
394334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_CORE_CLK_EN, 0x30),
395334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_HSCLK_SEL, 0x21),
396334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_DEC_START_MODE0, 0x82),
397334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_DIV_FRAC_START3_MODE0, 0x03),
398334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_DIV_FRAC_START2_MODE0, 0x355),
399334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_DIV_FRAC_START1_MODE0, 0x35555),
400334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_LOCK_CMP2_MODE0, 0x1a),
401334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_LOCK_CMP1_MODE0, 0x1a0a),
402334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_CP_CTRL_MODE0, 0xb),
403334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_PLL_RCTRL_MODE0, 0x16),
404334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_PLL_CCTRL_MODE0, 0x28),
405334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_INTEGLOOP_GAIN1_MODE0, 0x0),
406334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_INTEGLOOP_GAIN0_MODE0, 0x40),
407334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_VCO_TUNE2_MODE0, 0x02),
408334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_VCO_TUNE1_MODE0, 0x24),
409334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_SVS_MODE_CLK_SEL, 0x05),
410334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_CORE_CLK_EN, 0x20),
411334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_CORECLK_DIV, 0xa),
412334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_CLK_SELECT, 0x32),
413334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_SYS_CLK_CTRL, 0x02),
414334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_SYSCLK_BUF_ENABLE, 0x07),
415334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_SYSCLK_EN_SEL, 0x08),
416334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_BG_TIMER, 0xa),
417334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_HSCLK_SEL, 0x1),
418334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_DEC_START_MODE1, 0x68),
419334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_DIV_FRAC_START3_MODE1, 0x2),
420334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_DIV_FRAC_START2_MODE1, 0x2aa),
421334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_DIV_FRAC_START1_MODE1, 0x2aaab),
422334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_CLK_ENABLE1, 0x90),
423334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_LOCK_CMP2_MODE1, 0x34),
424334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_LOCK_CMP1_MODE1, 0x3414),
425334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_CP_CTRL_MODE1, 0x0b),
426334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_PLL_RCTRL_MODE1, 0x16),
427334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_PLL_CCTRL_MODE1, 0x28),
428334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_INTEGLOOP_GAIN1_MODE1, 0x0),
429334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_INTEGLOOP_GAIN0_MODE1, 0x40),
430334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_VCO_TUNE2_MODE1, 0x03),
431334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_VCO_TUNE1_MODE1, 0xb4),
432334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_SVS_MODE_CLK_SEL, 0x05),
433334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_CORE_CLK_EN, 0x0),
434334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_CORECLK_DIV_MODE1, 0x08),
435334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_CLK_EP_DIV_MODE0, 0x19),
436334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_CLK_EP_DIV_MODE1, 0x28),
437334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_CLK_ENABLE1, 0x90),
438334fad18SRobert Marko };
439334fad18SRobert Marko 
440334fad18SRobert Marko static const struct qmp_phy_init_tbl ipq8074_pcie_gen3_tx_tbl[] = {
441079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_TX_RES_CODE_LANE_OFFSET_TX, 0x02),
442079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_TX_RCV_DETECT_LVL_2, 0x12),
443079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_TX_HIGHZ_DRVR_EN, 0x10),
444079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_TX_LANE_MODE_1, 0x06),
445334fad18SRobert Marko };
446334fad18SRobert Marko 
447334fad18SRobert Marko static const struct qmp_phy_init_tbl ipq8074_pcie_gen3_rx_tbl[] = {
448079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_CNTRL, 0x03),
449079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_ENABLES, 0x1c),
450079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_DEGLITCH_CNTRL, 0x14),
451079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL2, 0xe),
452079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL3, 0x4),
453079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL4, 0x1b),
454079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_DFE_EN_TIMER, 0x04),
455079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x7f),
456079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_PI_CONTROLS, 0x70),
457079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1, 0x73),
458079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_OFFSET_ADAPTOR_CNTRL2, 0x80),
459079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_LOW, 0x00),
460079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH, 0x02),
461079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH2, 0xc8),
462079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH3, 0x09),
463079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH4, 0xb1),
464079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_LOW, 0x01),
465079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH, 0x02),
466079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH2, 0xc8),
467079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH3, 0x09),
468079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH4, 0xb1),
469079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_LOW, 0xf0),
470079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH, 0x2),
471079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH2, 0x2f),
472079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH3, 0xd3),
473079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH4, 0x40),
474079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_IDAC_TSETTLE_HIGH, 0x00),
475079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_IDAC_TSETTLE_LOW, 0xc0),
476079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_FO_GAIN, 0x0c),
477079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SO_GAIN, 0x02),
478334fad18SRobert Marko };
479334fad18SRobert Marko 
480334fad18SRobert Marko static const struct qmp_phy_init_tbl ipq8074_pcie_gen3_pcs_tbl[] = {
48160f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_FLL_CNTRL2, 0x83),
48260f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_FLL_CNT_VAL_L, 0x9),
48360f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_FLL_CNT_VAL_H_TOL, 0x42),
48460f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_FLL_MAN_CODE, 0x40),
48560f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_FLL_CNTRL1, 0x01),
48660f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_P2U3_WAKEUP_DLY_TIME_AUXCLK_H, 0x0),
48760f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_P2U3_WAKEUP_DLY_TIME_AUXCLK_L, 0x1),
48860f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_OSC_DTCT_ACTIONS, 0x0),
48960f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_L1P1_WAKEUP_DLY_TIME_AUXCLK_H, 0x00),
49060f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_L1P1_WAKEUP_DLY_TIME_AUXCLK_L, 0x01),
49160f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_L1P2_WAKEUP_DLY_TIME_AUXCLK_H, 0x00),
49260f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_L1P2_WAKEUP_DLY_TIME_AUXCLK_L, 0x01),
49360f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_EQ_CONFIG1, 0x11),
49460f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_EQ_CONFIG2, 0xb),
49560f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_POWER_STATE_CONFIG4, 0x07),
49660f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_OSC_DTCT_CONFIG2, 0x52),
49760f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_OSC_DTCT_MODE2_CONFIG2, 0x50),
49860f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_OSC_DTCT_MODE2_CONFIG4, 0x1a),
49960f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_OSC_DTCT_MODE2_CONFIG5, 0x6),
50060f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_G12S1_TXDEEMPH_M3P5DB, 0x10),
50160f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_ENDPOINT_REFCLK_DRIVE, 0xc1),
50260f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_RX_DCC_CAL_CONFIG, 0x01),
50360f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_RX_SIGDET_LVL, 0xaa),
50460f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_REFGEN_REQ_CONFIG1, 0x0d),
505334fad18SRobert Marko };
506334fad18SRobert Marko 
50794a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sdm845_qmp_pcie_serdes_tbl[] = {
50894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_BIAS_EN_CLKBUFLR_EN, 0x14),
50994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_SELECT, 0x30),
51094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_IVCO, 0x007),
51194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CMN_CONFIG, 0x06),
51294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP_EN, 0x01),
51394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_RESETSM_CNTRL, 0x20),
51494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_MAP, 0x00),
51594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE2_MODE0, 0x01),
51694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE1_MODE0, 0xc9),
51794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_TIMER1, 0xff),
51894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_TIMER2, 0x3f),
51994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SVS_MODE_CLK_SEL, 0x01),
52094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CORE_CLK_EN, 0x00),
52194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CORECLK_DIV_MODE0, 0x0a),
52294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_EP_DIV, 0x19),
52394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_ENABLE1, 0x90),
52494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_DEC_START_MODE0, 0x82),
52594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START3_MODE0, 0x02),
52694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START2_MODE0, 0xea),
52794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START1_MODE0, 0xab),
52894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP3_MODE0, 0x00),
52994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP2_MODE0, 0x0d),
53094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP1_MODE0, 0x04),
53194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_HSCLK_SEL, 0x00),
53294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CP_CTRL_MODE0, 0x06),
53394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_RCTRL_MODE0, 0x16),
53494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_CCTRL_MODE0, 0x36),
53594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CMN_MODE, 0x01),
53694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_SELECT, 0x33),
53794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYS_CLK_CTRL, 0x02),
53894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYSCLK_BUF_ENABLE, 0x06),
53994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYSCLK_EN_SEL, 0x04),
54094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN1_MODE0, 0x00),
54194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN0_MODE0, 0x3f),
54294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_BG_TIMER, 0x09),
54394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_EN_CENTER, 0x01),
54494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_PER1, 0x40),
54594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_PER2, 0x01),
54694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_ADJ_PER1, 0x02),
54794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_ADJ_PER2, 0x00),
54894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_STEP_SIZE1, 0x7e),
54994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_STEP_SIZE2, 0x15),
55094a407ccSDmitry Baryshkov };
55194a407ccSDmitry Baryshkov 
55294a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sdm845_qmp_pcie_tx_tbl[] = {
55394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_TX_RES_CODE_LANE_OFFSET_TX, 0x02),
55494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_TX_RCV_DETECT_LVL_2, 0x12),
55594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_TX_HIGHZ_DRVR_EN, 0x10),
55694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_TX_LANE_MODE_1, 0x06),
55794a407ccSDmitry Baryshkov };
55894a407ccSDmitry Baryshkov 
55994a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sdm845_qmp_pcie_rx_tbl[] = {
56094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_CNTRL, 0x03),
56194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_ENABLES, 0x10),
56294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_DEGLITCH_CNTRL, 0x14),
56394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL2, 0x0e),
56494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL3, 0x04),
56594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL4, 0x1a),
56694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x4b),
56794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SO_GAIN, 0x04),
56894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SO_GAIN_HALF, 0x04),
56994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1, 0x71),
57094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_MODE_00, 0x59),
57194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_MODE_01, 0x59),
57294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_OFFSET_ADAPTOR_CNTRL2, 0x80),
57394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_INTERFACE_MODE, 0x40),
57494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_PI_CONTROLS, 0x71),
57594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_FASTLOCK_COUNT_LOW, 0x40),
57694a407ccSDmitry Baryshkov };
57794a407ccSDmitry Baryshkov 
57894a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sdm845_qmp_pcie_pcs_tbl[] = {
57994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V3_PCS_ENDPOINT_REFCLK_DRIVE, 0x04),
58094a407ccSDmitry Baryshkov 
58194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNTRL2, 0x83),
58294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNT_VAL_L, 0x09),
58394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNT_VAL_H_TOL, 0xa2),
58494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_MAN_CODE, 0x40),
58594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNTRL1, 0x02),
58694a407ccSDmitry Baryshkov 
58794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V3_PCS_OSC_DTCT_ACTIONS, 0x00),
58894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V3_PCS_PWRUP_RESET_DLY_TIME_AUXCLK, 0x01),
58994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V3_PCS_L1SS_WAKEUP_DLY_TIME_AUXCLK_MSB, 0x00),
59094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V3_PCS_L1SS_WAKEUP_DLY_TIME_AUXCLK_LSB, 0x20),
59194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V3_PCS_LP_WAKEUP_DLY_TIME_AUXCLK_MSB, 0x00),
59294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V3_PCS_LP_WAKEUP_DLY_TIME_AUXCLK, 0x01),
59394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V3_PCS_PLL_LOCK_CHK_DLY_TIME, 0x73),
59494a407ccSDmitry Baryshkov 
59594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V3_PCS_RX_SIGDET_LVL, 0xbb),
59694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V3_PCS_SIGDET_CNTRL, 0x03),
59794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V3_PCS_REFGEN_REQ_CONFIG1, 0x0d),
59894a407ccSDmitry Baryshkov 
59994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V3_PCS_POWER_STATE_CONFIG4, 0x00),
60094a407ccSDmitry Baryshkov };
60194a407ccSDmitry Baryshkov 
60294a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sdm845_qmp_pcie_pcs_misc_tbl[] = {
60394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V3_PCS_MISC_OSC_DTCT_CONFIG2, 0x52),
60494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V3_PCS_MISC_OSC_DTCT_MODE2_CONFIG2, 0x10),
60594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V3_PCS_MISC_OSC_DTCT_MODE2_CONFIG4, 0x1a),
60694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V3_PCS_MISC_OSC_DTCT_MODE2_CONFIG5, 0x06),
60794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V3_PCS_MISC_PCIE_INT_AUX_CLK_CONFIG1, 0x00),
60894a407ccSDmitry Baryshkov };
60994a407ccSDmitry Baryshkov 
61094a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sdm845_qhp_pcie_serdes_tbl[] = {
61194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_SYSCLK_EN_SEL, 0x27),
61294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_SSC_EN_CENTER, 0x01),
61394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_SSC_PER1, 0x31),
61494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_SSC_PER2, 0x01),
61594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_SSC_STEP_SIZE1, 0xde),
61694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_SSC_STEP_SIZE2, 0x07),
61794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_SSC_STEP_SIZE1_MODE1, 0x4c),
61894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_SSC_STEP_SIZE2_MODE1, 0x06),
61994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_BIAS_EN_CKBUFLR_EN, 0x18),
62094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_CLK_ENABLE1, 0xb0),
62194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_LOCK_CMP1_MODE0, 0x8c),
62294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_LOCK_CMP2_MODE0, 0x20),
62394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_LOCK_CMP1_MODE1, 0x14),
62494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_LOCK_CMP2_MODE1, 0x34),
62594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_CP_CTRL_MODE0, 0x06),
62694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_CP_CTRL_MODE1, 0x06),
62794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_PLL_RCTRL_MODE0, 0x16),
62894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_PLL_RCTRL_MODE1, 0x16),
62994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_PLL_CCTRL_MODE0, 0x36),
63094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_PLL_CCTRL_MODE1, 0x36),
63194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_RESTRIM_CTRL2, 0x05),
63294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_LOCK_CMP_EN, 0x42),
63394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_DEC_START_MODE0, 0x82),
63494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_DEC_START_MODE1, 0x68),
63594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_DIV_FRAC_START1_MODE0, 0x55),
63694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_DIV_FRAC_START2_MODE0, 0x55),
63794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_DIV_FRAC_START3_MODE0, 0x03),
63894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_DIV_FRAC_START1_MODE1, 0xab),
63994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_DIV_FRAC_START2_MODE1, 0xaa),
64094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_DIV_FRAC_START3_MODE1, 0x02),
64194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_INTEGLOOP_GAIN0_MODE0, 0x3f),
64294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_INTEGLOOP_GAIN0_MODE1, 0x3f),
64394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_VCO_TUNE_MAP, 0x10),
64494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_CLK_SELECT, 0x04),
64594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_HSCLK_SEL1, 0x30),
64694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_CORECLK_DIV, 0x04),
64794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_CORE_CLK_EN, 0x73),
64894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_CMN_CONFIG, 0x0c),
64994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_SVS_MODE_CLK_SEL, 0x15),
65094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_CORECLK_DIV_MODE1, 0x04),
65194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_CMN_MODE, 0x01),
65294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_VREGCLK_DIV1, 0x22),
65394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_VREGCLK_DIV2, 0x00),
65494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_BGV_TRIM, 0x20),
65594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_BG_CTRL, 0x07),
65694a407ccSDmitry Baryshkov };
65794a407ccSDmitry Baryshkov 
65894a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sdm845_qhp_pcie_tx_tbl[] = {
65994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_DRVR_CTRL0, 0x00),
66094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_DRVR_TAP_EN, 0x0d),
66194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_TX_BAND_MODE, 0x01),
66294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_LANE_MODE, 0x1a),
66394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_PARALLEL_RATE, 0x2f),
66494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_CML_CTRL_MODE0, 0x09),
66594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_CML_CTRL_MODE1, 0x09),
66694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_CML_CTRL_MODE2, 0x1b),
66794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_PREAMP_CTRL_MODE1, 0x01),
66894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_PREAMP_CTRL_MODE2, 0x07),
66994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_MIXER_CTRL_MODE0, 0x31),
67094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_MIXER_CTRL_MODE1, 0x31),
67194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_MIXER_CTRL_MODE2, 0x03),
67294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_CTLE_THRESH_DFE, 0x02),
67394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_CGA_THRESH_DFE, 0x00),
67494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RXENGINE_EN0, 0x12),
67594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_CTLE_TRAIN_TIME, 0x25),
67694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_CTLE_DFE_OVRLP_TIME, 0x00),
67794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_DFE_REFRESH_TIME, 0x05),
67894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_DFE_ENABLE_TIME, 0x01),
67994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_VGA_GAIN, 0x26),
68094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_DFE_GAIN, 0x12),
68194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_EQ_GAIN, 0x04),
68294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_OFFSET_GAIN, 0x04),
68394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_PRE_GAIN, 0x09),
68494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_EQ_INTVAL, 0x15),
68594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_EDAC_INITVAL, 0x28),
68694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RXEQ_INITB0, 0x7f),
68794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RXEQ_INITB1, 0x07),
68894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RCVRDONE_THRESH1, 0x04),
68994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RXEQ_CTRL, 0x70),
69094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_UCDR_FO_GAIN_MODE0, 0x8b),
69194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_UCDR_FO_GAIN_MODE1, 0x08),
69294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_UCDR_FO_GAIN_MODE2, 0x0a),
69394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_UCDR_SO_GAIN_MODE0, 0x03),
69494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_UCDR_SO_GAIN_MODE1, 0x04),
69594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_UCDR_SO_GAIN_MODE2, 0x04),
69694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_UCDR_SO_CONFIG, 0x0c),
69794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RX_BAND, 0x02),
69894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RX_RCVR_PATH1_MODE0, 0x5c),
69994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RX_RCVR_PATH1_MODE1, 0x3e),
70094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RX_RCVR_PATH1_MODE2, 0x3f),
70194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_SIGDET_ENABLES, 0x01),
70294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_SIGDET_CNTRL, 0xa0),
70394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_SIGDET_DEGLITCH_CNTRL, 0x08),
70494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_DCC_GAIN, 0x01),
70594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RX_EN_SIGNAL, 0xc3),
70694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_PSM_RX_EN_CAL, 0x00),
70794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RX_MISC_CNTRL0, 0xbc),
70894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_TS0_TIMER, 0x7f),
70994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_DLL_HIGHDATARATE, 0x15),
71094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_DRVR_CTRL1, 0x0c),
71194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_DRVR_CTRL2, 0x0f),
71294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RX_RESETCODE_OFFSET, 0x04),
71394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_VGA_INITVAL, 0x20),
71494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RSM_START, 0x01),
71594a407ccSDmitry Baryshkov };
71694a407ccSDmitry Baryshkov 
71794a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sdm845_qhp_pcie_rx_tbl[] = {
71894a407ccSDmitry Baryshkov };
71994a407ccSDmitry Baryshkov 
72094a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sdm845_qhp_pcie_pcs_tbl[] = {
72194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_PHY_POWER_STATE_CONFIG, 0x3f),
72294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_PHY_PCS_TX_RX_CONFIG, 0x50),
72394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_PHY_TXMGN_MAIN_V0_M3P5DB, 0x19),
72494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_PHY_TXMGN_POST_V0_M3P5DB, 0x07),
72594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_PHY_TXMGN_MAIN_V0_M6DB, 0x17),
72694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_PHY_TXMGN_POST_V0_M6DB, 0x09),
72794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_PHY_POWER_STATE_CONFIG5, 0x9f),
72894a407ccSDmitry Baryshkov };
72994a407ccSDmitry Baryshkov 
73094a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sc8180x_qmp_pcie_serdes_tbl[] = {
73194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_SYSCLK_EN_SEL, 0x08),
73294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_CLK_SELECT, 0x34),
73394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_CORECLK_DIV_MODE1, 0x08),
73494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_IVCO, 0x0f),
73594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP_EN, 0x42),
73694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE1_MODE0, 0x24),
73794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE2_MODE1, 0x03),
73894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE1_MODE1, 0xb4),
73994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE_MAP, 0x02),
74094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_HSCLK_SEL, 0x11),
74194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_DEC_START_MODE0, 0x82),
74294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START3_MODE0, 0x03),
74394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START2_MODE0, 0x55),
74494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START1_MODE0, 0x55),
74594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP2_MODE0, 0x1a),
74694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP1_MODE0, 0x0a),
74794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_DEC_START_MODE1, 0x68),
74894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START3_MODE1, 0x02),
74994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START2_MODE1, 0xaa),
75094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START1_MODE1, 0xab),
75194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP2_MODE1, 0x34),
75294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP1_MODE1, 0x14),
75394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_HSCLK_SEL, 0x01),
75494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_CP_CTRL_MODE0, 0x06),
75594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_RCTRL_MODE0, 0x16),
75694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_CCTRL_MODE0, 0x36),
75794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_CP_CTRL_MODE1, 0x06),
75894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_RCTRL_MODE1, 0x16),
75994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_CCTRL_MODE1, 0x36),
76094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE2_MODE0, 0x1e),
76194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE1_MODE0, 0xca),
76294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE2_MODE1, 0x18),
76394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE1_MODE1, 0xa2),
76494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_SYSCLK_BUF_ENABLE, 0x07),
76594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_EN_CENTER, 0x01),
76694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_PER1, 0x31),
76794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_PER2, 0x01),
76894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_STEP_SIZE1_MODE0, 0xde),
76994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_STEP_SIZE2_MODE0, 0x07),
77094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_STEP_SIZE1_MODE1, 0x4c),
77194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_STEP_SIZE2_MODE1, 0x06),
77294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_CLK_ENABLE1, 0x90),
77394a407ccSDmitry Baryshkov };
77494a407ccSDmitry Baryshkov 
77594a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sc8180x_qmp_pcie_tx_tbl[] = {
77694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_TX_RCV_DETECT_LVL_2, 0x12),
77794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_TX_LANE_MODE_1, 0x5),
77894a407ccSDmitry Baryshkov };
77994a407ccSDmitry Baryshkov 
78094a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sc8180x_qmp_pcie_rx_tbl[] = {
78194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_CNTRL, 0x03),
78294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_ENABLES, 0x1c),
78394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_DEGLITCH_CNTRL, 0x14),
78494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL1, 0x07),
78594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL2, 0x6e),
78694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL3, 0x6e),
78794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL4, 0x4a),
78894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_DFE_EN_TIMER, 0x04),
78994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x7f),
79094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_PI_CONTROLS, 0x70),
79194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1, 0x17),
79294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_VGA_CAL_CNTRL1, 0x54),
79394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_VGA_CAL_CNTRL2, 0x37),
79494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_LOW, 0xd4),
79594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH, 0x54),
79694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH2, 0xdb),
79794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH3, 0x39),
79894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH4, 0x31),
79994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_LOW, 0x24),
80094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH, 0xe4),
80194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH2, 0xec),
80294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH3, 0x39),
80394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH4, 0x36),
80494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_LOW, 0x7f),
80594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH, 0xff),
80694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH2, 0xff),
80794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH3, 0xdb),
80894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH4, 0x75),
80994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_IDAC_TSETTLE_HIGH, 0x00),
81094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_IDAC_TSETTLE_LOW, 0xc0),
81194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_AUX_DATA_TCOARSE_TFINE, 0xa0),
81294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RCLK_AUXDATA_SEL, 0xc0),
81394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_DCC_CTRL1, 0x0c),
81494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_GM_CAL, 0x05),
81594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_FO_GAIN, 0x0c),
81694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SO_GAIN, 0x03),
81794a407ccSDmitry Baryshkov };
81894a407ccSDmitry Baryshkov 
81994a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sc8180x_qmp_pcie_pcs_tbl[] = {
82094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_P2U3_WAKEUP_DLY_TIME_AUXCLK_L, 0x01),
82194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_RX_SIGDET_LVL, 0xaa),
82294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_RATE_SLEW_CNTRL1, 0x0b),
82394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_REFGEN_REQ_CONFIG1, 0x0d),
82494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_EQ_CONFIG5, 0x01),
82594a407ccSDmitry Baryshkov };
82694a407ccSDmitry Baryshkov 
82794a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sc8180x_qmp_pcie_pcs_misc_tbl[] = {
82894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_OSC_DTCT_ACTIONS, 0x00),
82994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_L1P1_WAKEUP_DLY_TIME_AUXCLK_L, 0x01),
83094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_L1P2_WAKEUP_DLY_TIME_AUXCLK_L, 0x01),
83194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_INT_AUX_CLK_CONFIG1, 0x00),
83294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_PRESET_P10_PRE, 0x00),
83394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_PRESET_P10_POST, 0x58),
83494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_ENDPOINT_REFCLK_DRIVE, 0xc1),
83594a407ccSDmitry Baryshkov };
83694a407ccSDmitry Baryshkov 
83794a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8250_qmp_pcie_serdes_tbl[] = {
83894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_SYSCLK_EN_SEL, 0x08),
83994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_CLK_SELECT, 0x34),
84094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_CORECLK_DIV_MODE1, 0x08),
84194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_IVCO, 0x0f),
84294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP_EN, 0x42),
84394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE1_MODE0, 0x24),
84494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE2_MODE1, 0x03),
84594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE1_MODE1, 0xb4),
84694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE_MAP, 0x02),
84794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_HSCLK_SEL, 0x11),
84894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_DEC_START_MODE0, 0x82),
84994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START3_MODE0, 0x03),
85094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START2_MODE0, 0x55),
85194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START1_MODE0, 0x55),
85294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP2_MODE0, 0x1a),
85394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP1_MODE0, 0x0a),
85494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_DEC_START_MODE1, 0x68),
85594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START3_MODE1, 0x02),
85694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START2_MODE1, 0xaa),
85794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START1_MODE1, 0xab),
85894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP2_MODE1, 0x34),
85994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP1_MODE1, 0x14),
86094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_HSCLK_SEL, 0x01),
86194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_CP_CTRL_MODE0, 0x06),
86294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_RCTRL_MODE0, 0x16),
86394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_CCTRL_MODE0, 0x36),
86494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_CP_CTRL_MODE1, 0x06),
86594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_RCTRL_MODE1, 0x16),
86694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_CCTRL_MODE1, 0x36),
86794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE2_MODE0, 0x1e),
86894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE1_MODE0, 0xca),
86994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE2_MODE1, 0x18),
87094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE1_MODE1, 0xa2),
87194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_EN_CENTER, 0x01),
87294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_PER1, 0x31),
87394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_PER2, 0x01),
87494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_STEP_SIZE1_MODE0, 0xde),
87594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_STEP_SIZE2_MODE0, 0x07),
87694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_STEP_SIZE1_MODE1, 0x4c),
87794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_STEP_SIZE2_MODE1, 0x06),
87894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_CLK_ENABLE1, 0x90),
87994a407ccSDmitry Baryshkov };
88094a407ccSDmitry Baryshkov 
88194a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8250_qmp_gen3x1_pcie_serdes_tbl[] = {
88294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_SYSCLK_BUF_ENABLE, 0x07),
88394a407ccSDmitry Baryshkov };
88494a407ccSDmitry Baryshkov 
88594a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8250_qmp_pcie_tx_tbl[] = {
88694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_TX_RCV_DETECT_LVL_2, 0x12),
88794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_TX_LANE_MODE_1, 0x35),
88894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_TX_RES_CODE_LANE_OFFSET_TX, 0x11),
88994a407ccSDmitry Baryshkov };
89094a407ccSDmitry Baryshkov 
89194a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8250_qmp_pcie_rx_tbl[] = {
89294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_FO_GAIN, 0x0c),
89394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SO_GAIN, 0x03),
89494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_GM_CAL, 0x1b),
89594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_IDAC_TSETTLE_HIGH, 0x00),
89694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_IDAC_TSETTLE_LOW, 0xc0),
89794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_AUX_DATA_TCOARSE_TFINE, 0x30),
89894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_VGA_CAL_CNTRL1, 0x04),
89994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_VGA_CAL_CNTRL2, 0x07),
90094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x7f),
90194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_PI_CONTROLS, 0x70),
90294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL2, 0x0e),
90394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL3, 0x4a),
90494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL4, 0x0f),
90594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_CNTRL, 0x03),
90694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_ENABLES, 0x1c),
90794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_DEGLITCH_CNTRL, 0x1e),
90894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1, 0x17),
90994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_LOW, 0xd4),
91094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH, 0x54),
91194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH2, 0xdb),
91294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH3, 0x3b),
91394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH4, 0x31),
91494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_LOW, 0x24),
91594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH2, 0xff),
91694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH3, 0x7f),
91794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_DCC_CTRL1, 0x0c),
91894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH, 0xe4),
91994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH2, 0xec),
92094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH3, 0x3b),
92194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH4, 0x36),
92294a407ccSDmitry Baryshkov };
92394a407ccSDmitry Baryshkov 
92494a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8250_qmp_gen3x1_pcie_rx_tbl[] = {
92594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RCLK_AUXDATA_SEL, 0x00),
92694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL1, 0x00),
92794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_DFE_EN_TIMER, 0x04),
92894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_LOW, 0x3f),
92994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH4, 0x14),
93094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_DFE_CTLE_POST_CAL_OFFSET, 0x30),
93194a407ccSDmitry Baryshkov };
93294a407ccSDmitry Baryshkov 
93394a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8250_qmp_pcie_pcs_tbl[] = {
93494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_P2U3_WAKEUP_DLY_TIME_AUXCLK_L, 0x01),
93594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_RX_SIGDET_LVL, 0x77),
93694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_RATE_SLEW_CNTRL1, 0x0b),
93794a407ccSDmitry Baryshkov };
93894a407ccSDmitry Baryshkov 
93994a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8250_qmp_gen3x1_pcie_pcs_tbl[] = {
94094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_REFGEN_REQ_CONFIG1, 0x0d),
94194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_EQ_CONFIG5, 0x12),
94294a407ccSDmitry Baryshkov };
94394a407ccSDmitry Baryshkov 
94494a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8250_qmp_pcie_pcs_misc_tbl[] = {
94594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_OSC_DTCT_ACTIONS, 0x00),
94694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_L1P1_WAKEUP_DLY_TIME_AUXCLK_L, 0x01),
94794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_L1P2_WAKEUP_DLY_TIME_AUXCLK_L, 0x01),
94894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_PRESET_P6_P7_PRE, 0x33),
94994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_PRESET_P10_PRE, 0x00),
95094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_PRESET_P10_POST, 0x58),
95194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_ENDPOINT_REFCLK_DRIVE, 0xc1),
95294a407ccSDmitry Baryshkov };
95394a407ccSDmitry Baryshkov 
95494a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8250_qmp_gen3x1_pcie_pcs_misc_tbl[] = {
95594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_INT_AUX_CLK_CONFIG1, 0x00),
95694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_EQ_CONFIG2, 0x0f),
95794a407ccSDmitry Baryshkov };
95894a407ccSDmitry Baryshkov 
95994a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8250_qmp_gen3x2_pcie_tx_tbl[] = {
96094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_TX_PI_QEC_CTRL, 0x20),
96194a407ccSDmitry Baryshkov };
96294a407ccSDmitry Baryshkov 
96394a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8250_qmp_gen3x2_pcie_rx_tbl[] = {
96494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL1, 0x04),
96594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_LOW, 0xbf),
96694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH4, 0x15),
96794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_DFE_CTLE_POST_CAL_OFFSET, 0x38),
96894a407ccSDmitry Baryshkov };
96994a407ccSDmitry Baryshkov 
97094a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8250_qmp_gen3x2_pcie_pcs_tbl[] = {
97194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_REFGEN_REQ_CONFIG1, 0x05),
97294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_EQ_CONFIG2, 0x0f),
97394a407ccSDmitry Baryshkov };
97494a407ccSDmitry Baryshkov 
97594a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8250_qmp_gen3x2_pcie_pcs_misc_tbl[] = {
97694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_POWER_STATE_CONFIG2, 0x0d),
97794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_POWER_STATE_CONFIG4, 0x07),
97894a407ccSDmitry Baryshkov };
97994a407ccSDmitry Baryshkov 
98094a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sdx55_qmp_pcie_serdes_tbl[] = {
98194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_BG_TIMER, 0x02),
98294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIAS_EN_CLKBUFLR_EN, 0x18),
98394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_SYS_CLK_CTRL, 0x07),
98494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_IVCO, 0x0f),
98594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_CP_CTRL_MODE0, 0x0a),
98694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_CP_CTRL_MODE1, 0x0a),
98794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_RCTRL_MODE0, 0x19),
98894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_RCTRL_MODE1, 0x19),
98994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_CCTRL_MODE0, 0x03),
99094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_CCTRL_MODE1, 0x03),
99194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_SYSCLK_EN_SEL, 0x00),
99294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP_EN, 0x46),
99394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP_CFG, 0x04),
99494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP1_MODE0, 0x7f),
99594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP2_MODE0, 0x02),
99694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP1_MODE1, 0xff),
99794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP2_MODE1, 0x04),
99894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_DEC_START_MODE0, 0x4b),
99994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_DEC_START_MODE1, 0x50),
100094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START3_MODE0, 0x00),
100194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_INTEGLOOP_GAIN0_MODE0, 0xfb),
100294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_INTEGLOOP_GAIN1_MODE0, 0x01),
100394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_INTEGLOOP_GAIN0_MODE1, 0xfb),
100494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_INTEGLOOP_GAIN1_MODE1, 0x01),
100594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE_MAP, 0x02),
100694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_HSCLK_SEL, 0x12),
100794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_HSCLK_HS_SWITCH_SEL, 0x00),
100894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_CORECLK_DIV_MODE0, 0x05),
100994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_CORECLK_DIV_MODE1, 0x04),
101094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_CMN_CONFIG, 0x04),
101194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_CMN_MISC1, 0x88),
10121195c1daSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_CMN_MISC2, 0x03),
101394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_CMN_MODE, 0x17),
101494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_DC_LEVEL_CTRL, 0x0b),
101594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE1_MODE0, 0x56),
101694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE2_MODE0, 0x1d),
101794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE1_MODE1, 0x4b),
101894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE2_MODE1, 0x1f),
101994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_HSCLK_SEL, 0x22),
102094a407ccSDmitry Baryshkov };
102194a407ccSDmitry Baryshkov 
102294a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sdx55_qmp_pcie_tx_tbl[] = {
102394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_20_TX_LANE_MODE_1, 0x05),
102494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_20_TX_LANE_MODE_2, 0xf6),
102594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_20_TX_LANE_MODE_3, 0x13),
102694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_20_TX_VMODE_CTRL1, 0x00),
102794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_20_TX_PI_QEC_CTRL, 0x00),
102894a407ccSDmitry Baryshkov };
102994a407ccSDmitry Baryshkov 
103094a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sdx55_qmp_pcie_rx_tbl[] = {
103194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_FO_GAIN_RATE2, 0x0c),
103294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_UCDR_PI_CONTROLS, 0x16),
103394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_AUX_DATA_TCOARSE_TFINE, 0x7f),
103494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_DFE_3, 0x55),
103594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_DFE_DAC_ENABLE1, 0x0c),
103694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_DFE_DAC_ENABLE2, 0x00),
103794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_VGA_CAL_CNTRL2, 0x08),
103894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1, 0x27),
103994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE_0_1_B1, 0x1a),
104094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE_0_1_B2, 0x5a),
104194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE_0_1_B3, 0x09),
104294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE_0_1_B4, 0x37),
104394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE2_B0, 0xbd),
104494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE2_B1, 0xf9),
104594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE2_B2, 0xbf),
104694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE2_B3, 0xce),
104794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE2_B4, 0x62),
104894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE3_B0, 0xbf),
104994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE3_B1, 0x7d),
105094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE3_B2, 0xbf),
105194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE3_B3, 0xcf),
105294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE3_B4, 0xd6),
105394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_PHPRE_CTRL, 0xa0),
105494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_DFE_CTLE_POST_CAL_OFFSET, 0x38),
105594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_MARG_COARSE_CTRL2, 0x12),
105694a407ccSDmitry Baryshkov };
105794a407ccSDmitry Baryshkov 
105894a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sdx55_qmp_pcie_pcs_tbl[] = {
105994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_20_PCS_RX_SIGDET_LVL, 0x77),
106094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_20_PCS_EQ_CONFIG2, 0x01),
106194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_20_PCS_EQ_CONFIG4, 0x16),
106294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_20_PCS_EQ_CONFIG5, 0x02),
106394a407ccSDmitry Baryshkov };
106494a407ccSDmitry Baryshkov 
106594a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sdx55_qmp_pcie_pcs_misc_tbl[] = {
106694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_20_PCS_PCIE_EQ_CONFIG1, 0x17),
106794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_20_PCS_PCIE_G3_RXEQEVAL_TIME, 0x13),
106894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_20_PCS_PCIE_G4_RXEQEVAL_TIME, 0x13),
106994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_20_PCS_PCIE_G4_EQ_CONFIG2, 0x01),
107094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_20_PCS_PCIE_G4_EQ_CONFIG5, 0x02),
107194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_20_PCS_LANE1_INSIG_SW_CTRL2, 0x00),
107294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_20_PCS_LANE1_INSIG_MX_CTRL2, 0x00),
107394a407ccSDmitry Baryshkov };
107494a407ccSDmitry Baryshkov 
107594a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8450_qmp_gen3x1_pcie_serdes_tbl[] = {
107694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_SYSCLK_EN_SEL, 0x08),
107794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_CLK_SELECT, 0x34),
107894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_CORECLK_DIV_MODE1, 0x08),
107994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_IVCO, 0x0f),
108094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP_EN, 0x42),
108194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_VCO_TUNE1_MODE0, 0x24),
108294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_VCO_TUNE2_MODE1, 0x03),
108394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_VCO_TUNE1_MODE1, 0xb4),
108494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_VCO_TUNE_MAP, 0x02),
108594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_BIN_VCOCAL_HSCLK_SEL, 0x11),
108694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_DEC_START_MODE0, 0x82),
108794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START3_MODE0, 0x03),
108894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START2_MODE0, 0x55),
108994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START1_MODE0, 0x55),
109094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP2_MODE0, 0x1a),
109194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP1_MODE0, 0x0a),
109294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_DEC_START_MODE1, 0x68),
109394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START3_MODE1, 0x02),
109494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START2_MODE1, 0xaa),
109594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START1_MODE1, 0xab),
109694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP2_MODE1, 0x34),
109794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP1_MODE1, 0x14),
109894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_HSCLK_SEL, 0x01),
109994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_CP_CTRL_MODE0, 0x06),
110094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_RCTRL_MODE0, 0x16),
110194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_CCTRL_MODE0, 0x36),
110294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_CP_CTRL_MODE1, 0x06),
110394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_RCTRL_MODE1, 0x16),
110494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_CCTRL_MODE1, 0x36),
110594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_BIN_VCOCAL_CMP_CODE2_MODE0, 0x1e),
110694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_BIN_VCOCAL_CMP_CODE1_MODE0, 0xca),
110794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_BIN_VCOCAL_CMP_CODE2_MODE1, 0x18),
110894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_BIN_VCOCAL_CMP_CODE1_MODE1, 0xa2),
110994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_SYSCLK_BUF_ENABLE, 0x07),
111094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_EN_CENTER, 0x01),
111194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_PER1, 0x31),
111294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_PER2, 0x01),
111394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_STEP_SIZE1_MODE0, 0xde),
111494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_STEP_SIZE2_MODE0, 0x07),
111594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_STEP_SIZE1_MODE1, 0x4c),
111694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_STEP_SIZE2_MODE1, 0x06),
111794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_CLK_ENABLE1, 0x90),
111894a407ccSDmitry Baryshkov };
111994a407ccSDmitry Baryshkov 
112094a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8450_qmp_gen3x1_pcie_tx_tbl[] = {
112194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_TX_PI_QEC_CTRL, 0x20),
112294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_TX_LANE_MODE_1, 0x75),
112394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_TX_LANE_MODE_4, 0x3f),
112494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_TX_RES_CODE_LANE_OFFSET_TX, 0x16),
112594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_TX_RES_CODE_LANE_OFFSET_RX, 0x04),
112694a407ccSDmitry Baryshkov };
112794a407ccSDmitry Baryshkov 
112894a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8450_qmp_gen3x1_pcie_rx_tbl[] = {
112994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_00_LOW, 0x7f),
113094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_00_HIGH, 0xff),
113194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_00_HIGH2, 0xbf),
113294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_00_HIGH3, 0x3f),
113394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_00_HIGH4, 0xd8),
113494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_01_LOW, 0xdc),
113594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_01_HIGH, 0xdc),
113694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_01_HIGH2, 0x5c),
113794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_01_HIGH3, 0x34),
113894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_01_HIGH4, 0xa6),
113994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_10_HIGH3, 0x34),
114094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_10_HIGH4, 0x38),
114194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_RX_VGA_CAL_CNTRL2, 0x07),
114294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_RX_GM_CAL, 0x00),
114394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_RX_UCDR_SB2_THRESH1, 0x08),
114494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_RX_UCDR_SB2_THRESH2, 0x08),
114594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_RX_UCDR_PI_CONTROLS, 0xf0),
114694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_RX_DFE_CTLE_POST_CAL_OFFSET, 0x38),
114794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_RX_TX_ADAPT_POST_THRESH, 0xf0),
114894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_EQU_ADAPTOR_CNTRL4, 0x07),
114994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_RX_UCDR_FO_GAIN, 0x09),
115094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_RX_UCDR_SO_GAIN, 0x05),
115194a407ccSDmitry Baryshkov };
115294a407ccSDmitry Baryshkov 
115394a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8450_qmp_gen3x1_pcie_pcs_tbl[] = {
115494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V5_PCS_RX_SIGDET_LVL, 0x77),
115594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V5_PCS_RATE_SLEW_CNTRL1, 0x0b),
115694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V5_PCS_REFGEN_REQ_CONFIG1, 0x05),
115794a407ccSDmitry Baryshkov };
115894a407ccSDmitry Baryshkov 
115994a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8450_qmp_gen3x1_pcie_pcs_misc_tbl[] = {
116094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V5_PCS_PCIE_OSC_DTCT_ACTIONS, 0x00),
116194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V5_PCS_PCIE_INT_AUX_CLK_CONFIG1, 0x00),
116294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V5_PCS_PCIE_EQ_CONFIG2, 0x0f),
116394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V5_PCS_PCIE_ENDPOINT_REFCLK_DRIVE, 0xc1),
116494a407ccSDmitry Baryshkov };
116594a407ccSDmitry Baryshkov 
116694a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8450_qmp_gen4x2_pcie_serdes_tbl[] = {
1167f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_BIAS_EN_CLKBUFLR_EN, 0x14),
1168f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_IVCO, 0x0f),
1169f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP_EN, 0x46),
1170f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP_CFG, 0x04),
1171f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_VCO_TUNE_MAP, 0x02),
1172f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_HSCLK_SEL, 0x12),
1173f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_HSCLK_HS_SWITCH_SEL, 0x00),
1174f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_CORECLK_DIV_MODE0, 0x0a),
1175f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_CORECLK_DIV_MODE1, 0x04),
1176f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_CMN_MISC1, 0x88),
1177f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_CMN_CONFIG, 0x06),
1178f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_CMN_MODE, 0x14),
1179f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_VCO_DC_LEVEL_CTRL, 0x0f),
1180f5682f13SDmitry Baryshkov };
1181f5682f13SDmitry Baryshkov 
1182f5682f13SDmitry Baryshkov static const struct qmp_phy_init_tbl sm8450_qmp_gen4x2_pcie_rc_serdes_tbl[] = {
118394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_PER1, 0x31),
118494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_PER2, 0x01),
118594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_STEP_SIZE1_MODE0, 0xde),
118694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_STEP_SIZE2_MODE0, 0x07),
118794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_STEP_SIZE1_MODE1, 0x97),
118894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_STEP_SIZE2_MODE1, 0x0c),
118994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_CLK_ENABLE1, 0x90),
119094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_CP_CTRL_MODE0, 0x06),
119194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_CP_CTRL_MODE1, 0x06),
119294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_RCTRL_MODE0, 0x16),
119394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_RCTRL_MODE1, 0x16),
119494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_CCTRL_MODE0, 0x36),
119594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_CCTRL_MODE1, 0x36),
119694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_SYSCLK_EN_SEL, 0x08),
119794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP1_MODE0, 0x0a),
119894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP2_MODE0, 0x1a),
119994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP1_MODE1, 0x14),
120094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP2_MODE1, 0x34),
120194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_DEC_START_MODE0, 0x82),
120294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_DEC_START_MODE1, 0xd0),
120394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START1_MODE0, 0x55),
120494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START2_MODE0, 0x55),
120594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START3_MODE0, 0x03),
120694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START1_MODE1, 0x55),
120794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START2_MODE1, 0x55),
120894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START3_MODE1, 0x05),
120994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_CLK_SELECT, 0x34),
121094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_CORE_CLK_EN, 0x20),
121194a407ccSDmitry Baryshkov };
121294a407ccSDmitry Baryshkov 
121394a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8450_qmp_gen4x2_pcie_tx_tbl[] = {
121494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_TX_LANE_MODE_1, 0x05),
121594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_TX_LANE_MODE_2, 0xf6),
121694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_TX_RES_CODE_LANE_OFFSET_TX, 0x1a),
121794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_TX_RES_CODE_LANE_OFFSET_RX, 0x0c),
121894a407ccSDmitry Baryshkov };
121994a407ccSDmitry Baryshkov 
122094a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8450_qmp_gen4x2_pcie_rx_tbl[] = {
122194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_UCDR_PI_CONTROLS, 0x16),
122294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_DFE_CTLE_POST_CAL_OFFSET, 0x38),
122394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE_0_1_B1, 0xcc),
122494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE_0_1_B2, 0x12),
122594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE_0_1_B3, 0xcc),
122694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE_0_1_B5, 0x4a),
122794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE_0_1_B6, 0x29),
122894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE2_B0, 0xc5),
122994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE2_B1, 0xad),
123094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE2_B2, 0xb6),
123194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE2_B3, 0xc0),
123294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE2_B4, 0x1f),
123394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE2_B5, 0xfb),
123494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE2_B6, 0x0f),
123594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE3_B0, 0xc7),
123694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE3_B1, 0xef),
123794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE3_B2, 0xbf),
123894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE3_B3, 0xa0),
123994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE3_B4, 0x81),
124094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE3_B5, 0xde),
124194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE3_B6, 0x7f),
124294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_PHPRE_CTRL, 0x20),
124394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_AUX_DATA_THRESH_BIN_RATE_0_1, 0x3f),
124494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_AUX_DATA_THRESH_BIN_RATE_2_3, 0x37),
124594a407ccSDmitry Baryshkov 
124694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_DFE_3, 0x05),
124794a407ccSDmitry Baryshkov 
124894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MARG_COARSE_THRESH1_RATE3, 0x1f),
124994a407ccSDmitry Baryshkov 
125094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MARG_COARSE_THRESH2_RATE3, 0x1f),
125194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MARG_COARSE_THRESH3_RATE3, 0x1f),
125294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MARG_COARSE_THRESH4_RATE3, 0x1f),
125394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MARG_COARSE_THRESH5_RATE3, 0x1f),
125494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MARG_COARSE_THRESH6_RATE3, 0x1f),
125594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MARG_COARSE_THRESH1_RATE210, 0x1f),
125694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MARG_COARSE_THRESH2_RATE210, 0x1f),
125794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MARG_COARSE_THRESH3_RATE210, 0x1f),
125894a407ccSDmitry Baryshkov 
125994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_UCDR_FO_GAIN_RATE2, 0x0c),
126094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_UCDR_FO_GAIN_RATE3, 0x0a),
126194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_VGA_CAL_MAN_VAL, 0x0a),
126294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_EQU_ADAPTOR_CNTRL4, 0x0b),
126394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_IDAC_SAOFFSET, 0x10),
126494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_DFE_DAC_ENABLE1, 0x00),
126594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_GM_CAL, 0x0f),
126694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_TX_ADAPT_POST_THRESH1, 0x00),
126794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_TX_ADAPT_POST_THRESH2, 0x1f),
126894a407ccSDmitry Baryshkov };
126994a407ccSDmitry Baryshkov 
127094a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8450_qmp_gen4x2_pcie_pcs_tbl[] = {
127194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V5_PCS_EQ_CONFIG2, 0x16),
127294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V5_PCS_EQ_CONFIG3, 0x22),
127394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V5_PCS_G3S2_PRE_GAIN, 0x2e),
127494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V5_PCS_RX_SIGDET_LVL, 0x99),
127594a407ccSDmitry Baryshkov };
127694a407ccSDmitry Baryshkov 
127794a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8450_qmp_gen4x2_pcie_pcs_misc_tbl[] = {
127894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V5_20_PCS_PCIE_G4_EQ_CONFIG5, 0x02),
127994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V5_20_PCS_PCIE_EQ_CONFIG1, 0x16),
128094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V5_20_PCS_PCIE_RX_MARGINING_CONFIG3, 0x28),
128194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V5_20_PCS_PCIE_G4_PRE_GAIN, 0x2e),
128294a407ccSDmitry Baryshkov };
128394a407ccSDmitry Baryshkov 
1284f5682f13SDmitry Baryshkov static const struct qmp_phy_init_tbl sm8450_qmp_gen4x2_pcie_rc_pcs_misc_tbl[] = {
1285f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V5_20_PCS_PCIE_ENDPOINT_REFCLK_DRIVE, 0xc1),
1286f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V5_20_PCS_PCIE_OSC_DTCT_ACTIONS, 0x00),
1287f5682f13SDmitry Baryshkov };
1288f5682f13SDmitry Baryshkov 
1289f5682f13SDmitry Baryshkov static const struct qmp_phy_init_tbl sm8450_qmp_gen4x2_pcie_ep_serdes_tbl[] = {
1290f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_BG_TIMER, 0x02),
1291f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_SYS_CLK_CTRL, 0x07),
1292f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_CP_CTRL_MODE0, 0x27),
1293f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_CP_CTRL_MODE1, 0x0a),
1294f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_RCTRL_MODE0, 0x17),
1295f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_RCTRL_MODE1, 0x19),
1296f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_CCTRL_MODE0, 0x00),
1297f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_CCTRL_MODE1, 0x03),
1298f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_SYSCLK_EN_SEL, 0x00),
1299f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP1_MODE0, 0xff),
1300f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP2_MODE0, 0x04),
1301f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP1_MODE1, 0xff),
1302f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP2_MODE1, 0x09),
1303f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_DEC_START_MODE0, 0x19),
1304f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_DEC_START_MODE1, 0x28),
1305f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_INTEGLOOP_GAIN0_MODE0, 0xfb),
1306f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_INTEGLOOP_GAIN1_MODE0, 0x01),
1307f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_INTEGLOOP_GAIN0_MODE1, 0xfb),
1308f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_INTEGLOOP_GAIN1_MODE1, 0x01),
1309f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_CORE_CLK_EN, 0x60),
1310f5682f13SDmitry Baryshkov };
1311f5682f13SDmitry Baryshkov 
1312f5682f13SDmitry Baryshkov static const struct qmp_phy_init_tbl sm8450_qmp_gen4x2_pcie_ep_pcs_misc_tbl[] = {
1313f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V5_20_PCS_PCIE_OSC_DTCT_MODE2_CONFIG5, 0x08),
1314f5682f13SDmitry Baryshkov };
1315f5682f13SDmitry Baryshkov 
13162566ad8eSDmitry Baryshkov struct qmp_phy_cfg_tables {
13172566ad8eSDmitry Baryshkov 	const struct qmp_phy_init_tbl *serdes;
13182566ad8eSDmitry Baryshkov 	int serdes_num;
13192566ad8eSDmitry Baryshkov 	const struct qmp_phy_init_tbl *tx;
13202566ad8eSDmitry Baryshkov 	int tx_num;
13212566ad8eSDmitry Baryshkov 	const struct qmp_phy_init_tbl *rx;
13222566ad8eSDmitry Baryshkov 	int rx_num;
13232566ad8eSDmitry Baryshkov 	const struct qmp_phy_init_tbl *pcs;
13242566ad8eSDmitry Baryshkov 	int pcs_num;
13252566ad8eSDmitry Baryshkov 	const struct qmp_phy_init_tbl *pcs_misc;
13262566ad8eSDmitry Baryshkov 	int pcs_misc_num;
13272566ad8eSDmitry Baryshkov };
13282566ad8eSDmitry Baryshkov 
132994a407ccSDmitry Baryshkov /* struct qmp_phy_cfg - per-PHY initialization config */
133094a407ccSDmitry Baryshkov struct qmp_phy_cfg {
1331f02543faSJohan Hovold 	int lanes;
133294a407ccSDmitry Baryshkov 
13332566ad8eSDmitry Baryshkov 	/* Main init sequence for PHY blocks - serdes, tx, rx, pcs */
13342566ad8eSDmitry Baryshkov 	const struct qmp_phy_cfg_tables tables;
13352566ad8eSDmitry Baryshkov 	/*
133611bf53a3SDmitry Baryshkov 	 * Additional init sequences for PHY blocks, providing additional
133711bf53a3SDmitry Baryshkov 	 * register programming. They are used for providing separate sequences
133811bf53a3SDmitry Baryshkov 	 * for the Root Complex and End Point use cases.
133911bf53a3SDmitry Baryshkov 	 *
134011bf53a3SDmitry Baryshkov 	 * If EP mode is not supported, both tables can be left unset.
13412566ad8eSDmitry Baryshkov 	 */
13422566ad8eSDmitry Baryshkov 	const struct qmp_phy_cfg_tables *tables_rc;
134311bf53a3SDmitry Baryshkov 	const struct qmp_phy_cfg_tables *tables_ep;
134494a407ccSDmitry Baryshkov 
134594a407ccSDmitry Baryshkov 	/* clock ids to be requested */
134694a407ccSDmitry Baryshkov 	const char * const *clk_list;
134794a407ccSDmitry Baryshkov 	int num_clks;
134894a407ccSDmitry Baryshkov 	/* resets to be requested */
134994a407ccSDmitry Baryshkov 	const char * const *reset_list;
135094a407ccSDmitry Baryshkov 	int num_resets;
135194a407ccSDmitry Baryshkov 	/* regulators to be requested */
135294a407ccSDmitry Baryshkov 	const char * const *vreg_list;
135394a407ccSDmitry Baryshkov 	int num_vregs;
135494a407ccSDmitry Baryshkov 
135594a407ccSDmitry Baryshkov 	/* array of registers with different offsets */
135694a407ccSDmitry Baryshkov 	const unsigned int *regs;
135794a407ccSDmitry Baryshkov 
135894a407ccSDmitry Baryshkov 	unsigned int start_ctrl;
135994a407ccSDmitry Baryshkov 	unsigned int pwrdn_ctrl;
136094a407ccSDmitry Baryshkov 	/* bit offset of PHYSTATUS in QPHY_PCS_STATUS register */
136194a407ccSDmitry Baryshkov 	unsigned int phy_status;
136294a407ccSDmitry Baryshkov 
136351bd3306SJohan Hovold 	bool skip_start_delay;
136494a407ccSDmitry Baryshkov 
13652ec9bc8dSRobert Marko 	/* QMP PHY pipe clock interface rate */
13662ec9bc8dSRobert Marko 	unsigned long pipe_clock_rate;
136794a407ccSDmitry Baryshkov };
136894a407ccSDmitry Baryshkov 
136994a407ccSDmitry Baryshkov /**
137094a407ccSDmitry Baryshkov  * struct qmp_phy - per-lane phy descriptor
137194a407ccSDmitry Baryshkov  *
137294a407ccSDmitry Baryshkov  * @phy: generic phy
137394a407ccSDmitry Baryshkov  * @cfg: phy specific configuration
137494a407ccSDmitry Baryshkov  * @serdes: iomapped memory space for phy's serdes (i.e. PLL)
137594a407ccSDmitry Baryshkov  * @tx: iomapped memory space for lane's tx
137694a407ccSDmitry Baryshkov  * @rx: iomapped memory space for lane's rx
137794a407ccSDmitry Baryshkov  * @pcs: iomapped memory space for lane's pcs
137894a407ccSDmitry Baryshkov  * @tx2: iomapped memory space for second lane's tx (in dual lane PHYs)
137994a407ccSDmitry Baryshkov  * @rx2: iomapped memory space for second lane's rx (in dual lane PHYs)
138094a407ccSDmitry Baryshkov  * @pcs_misc: iomapped memory space for lane's pcs_misc
138194a407ccSDmitry Baryshkov  * @pipe_clk: pipe clock
138294a407ccSDmitry Baryshkov  * @qmp: QMP phy to which this lane belongs
138311bf53a3SDmitry Baryshkov  * @mode: currently selected PHY mode
138494a407ccSDmitry Baryshkov  */
138594a407ccSDmitry Baryshkov struct qmp_phy {
138694a407ccSDmitry Baryshkov 	struct phy *phy;
138794a407ccSDmitry Baryshkov 	const struct qmp_phy_cfg *cfg;
138894a407ccSDmitry Baryshkov 	void __iomem *serdes;
138994a407ccSDmitry Baryshkov 	void __iomem *tx;
139094a407ccSDmitry Baryshkov 	void __iomem *rx;
139194a407ccSDmitry Baryshkov 	void __iomem *pcs;
139294a407ccSDmitry Baryshkov 	void __iomem *tx2;
139394a407ccSDmitry Baryshkov 	void __iomem *rx2;
139494a407ccSDmitry Baryshkov 	void __iomem *pcs_misc;
139594a407ccSDmitry Baryshkov 	struct clk *pipe_clk;
139694a407ccSDmitry Baryshkov 	struct qcom_qmp *qmp;
139711bf53a3SDmitry Baryshkov 	int mode;
139894a407ccSDmitry Baryshkov };
139994a407ccSDmitry Baryshkov 
140094a407ccSDmitry Baryshkov /**
140194a407ccSDmitry Baryshkov  * struct qcom_qmp - structure holding QMP phy block attributes
140294a407ccSDmitry Baryshkov  *
140394a407ccSDmitry Baryshkov  * @dev: device
140494a407ccSDmitry Baryshkov  *
140594a407ccSDmitry Baryshkov  * @clks: array of clocks required by phy
140694a407ccSDmitry Baryshkov  * @resets: array of resets required by phy
140794a407ccSDmitry Baryshkov  * @vregs: regulator supplies bulk data
140894a407ccSDmitry Baryshkov  *
140994a407ccSDmitry Baryshkov  * @phys: array of per-lane phy descriptors
141094a407ccSDmitry Baryshkov  */
141194a407ccSDmitry Baryshkov struct qcom_qmp {
141294a407ccSDmitry Baryshkov 	struct device *dev;
141394a407ccSDmitry Baryshkov 
141494a407ccSDmitry Baryshkov 	struct clk_bulk_data *clks;
1415189ac6b8SDmitry Baryshkov 	struct reset_control_bulk_data *resets;
141694a407ccSDmitry Baryshkov 	struct regulator_bulk_data *vregs;
141794a407ccSDmitry Baryshkov 
141894a407ccSDmitry Baryshkov 	struct qmp_phy **phys;
141994a407ccSDmitry Baryshkov };
142094a407ccSDmitry Baryshkov 
142194a407ccSDmitry Baryshkov static inline void qphy_setbits(void __iomem *base, u32 offset, u32 val)
142294a407ccSDmitry Baryshkov {
142394a407ccSDmitry Baryshkov 	u32 reg;
142494a407ccSDmitry Baryshkov 
142594a407ccSDmitry Baryshkov 	reg = readl(base + offset);
142694a407ccSDmitry Baryshkov 	reg |= val;
142794a407ccSDmitry Baryshkov 	writel(reg, base + offset);
142894a407ccSDmitry Baryshkov 
142994a407ccSDmitry Baryshkov 	/* ensure that above write is through */
143094a407ccSDmitry Baryshkov 	readl(base + offset);
143194a407ccSDmitry Baryshkov }
143294a407ccSDmitry Baryshkov 
143394a407ccSDmitry Baryshkov static inline void qphy_clrbits(void __iomem *base, u32 offset, u32 val)
143494a407ccSDmitry Baryshkov {
143594a407ccSDmitry Baryshkov 	u32 reg;
143694a407ccSDmitry Baryshkov 
143794a407ccSDmitry Baryshkov 	reg = readl(base + offset);
143894a407ccSDmitry Baryshkov 	reg &= ~val;
143994a407ccSDmitry Baryshkov 	writel(reg, base + offset);
144094a407ccSDmitry Baryshkov 
144194a407ccSDmitry Baryshkov 	/* ensure that above write is through */
144294a407ccSDmitry Baryshkov 	readl(base + offset);
144394a407ccSDmitry Baryshkov }
144494a407ccSDmitry Baryshkov 
144594a407ccSDmitry Baryshkov /* list of clocks required by phy */
14465b76f5ecSJohan Hovold static const char * const ipq8074_pciephy_clk_l[] = {
14475b76f5ecSJohan Hovold 	"aux", "cfg_ahb",
14485b76f5ecSJohan Hovold };
14495b76f5ecSJohan Hovold 
145094a407ccSDmitry Baryshkov static const char * const msm8996_phy_clk_l[] = {
145194a407ccSDmitry Baryshkov 	"aux", "cfg_ahb", "ref",
145294a407ccSDmitry Baryshkov };
145394a407ccSDmitry Baryshkov 
145494a407ccSDmitry Baryshkov 
145594a407ccSDmitry Baryshkov static const char * const sdm845_pciephy_clk_l[] = {
145694a407ccSDmitry Baryshkov 	"aux", "cfg_ahb", "ref", "refgen",
145794a407ccSDmitry Baryshkov };
145894a407ccSDmitry Baryshkov 
145994a407ccSDmitry Baryshkov /* list of regulators */
146094a407ccSDmitry Baryshkov static const char * const qmp_phy_vreg_l[] = {
146194a407ccSDmitry Baryshkov 	"vdda-phy", "vdda-pll",
146294a407ccSDmitry Baryshkov };
146394a407ccSDmitry Baryshkov 
146494a407ccSDmitry Baryshkov /* list of resets */
146594a407ccSDmitry Baryshkov static const char * const ipq8074_pciephy_reset_l[] = {
146694a407ccSDmitry Baryshkov 	"phy", "common",
146794a407ccSDmitry Baryshkov };
146894a407ccSDmitry Baryshkov 
1469b35a5311SDmitry Baryshkov static const char * const sdm845_pciephy_reset_l[] = {
1470b35a5311SDmitry Baryshkov 	"phy",
1471b35a5311SDmitry Baryshkov };
1472b35a5311SDmitry Baryshkov 
147394a407ccSDmitry Baryshkov static const struct qmp_phy_cfg ipq8074_pciephy_cfg = {
1474f02543faSJohan Hovold 	.lanes			= 1,
147594a407ccSDmitry Baryshkov 
14762566ad8eSDmitry Baryshkov 	.tables = {
14772566ad8eSDmitry Baryshkov 		.serdes		= ipq8074_pcie_serdes_tbl,
14782566ad8eSDmitry Baryshkov 		.serdes_num	= ARRAY_SIZE(ipq8074_pcie_serdes_tbl),
14792566ad8eSDmitry Baryshkov 		.tx		= ipq8074_pcie_tx_tbl,
14802566ad8eSDmitry Baryshkov 		.tx_num		= ARRAY_SIZE(ipq8074_pcie_tx_tbl),
14812566ad8eSDmitry Baryshkov 		.rx		= ipq8074_pcie_rx_tbl,
14822566ad8eSDmitry Baryshkov 		.rx_num		= ARRAY_SIZE(ipq8074_pcie_rx_tbl),
14832566ad8eSDmitry Baryshkov 		.pcs		= ipq8074_pcie_pcs_tbl,
14842566ad8eSDmitry Baryshkov 		.pcs_num	= ARRAY_SIZE(ipq8074_pcie_pcs_tbl),
14852566ad8eSDmitry Baryshkov 	},
148694a407ccSDmitry Baryshkov 	.clk_list		= ipq8074_pciephy_clk_l,
148794a407ccSDmitry Baryshkov 	.num_clks		= ARRAY_SIZE(ipq8074_pciephy_clk_l),
148894a407ccSDmitry Baryshkov 	.reset_list		= ipq8074_pciephy_reset_l,
148994a407ccSDmitry Baryshkov 	.num_resets		= ARRAY_SIZE(ipq8074_pciephy_reset_l),
149094a407ccSDmitry Baryshkov 	.vreg_list		= NULL,
149194a407ccSDmitry Baryshkov 	.num_vregs		= 0,
149294a407ccSDmitry Baryshkov 	.regs			= pciephy_regs_layout,
149394a407ccSDmitry Baryshkov 
149494a407ccSDmitry Baryshkov 	.start_ctrl		= SERDES_START | PCS_START,
149594a407ccSDmitry Baryshkov 	.pwrdn_ctrl		= SW_PWRDN | REFCLK_DRV_DSBL,
149694a407ccSDmitry Baryshkov 	.phy_status		= PHYSTATUS,
149794a407ccSDmitry Baryshkov };
149894a407ccSDmitry Baryshkov 
1499334fad18SRobert Marko static const struct qmp_phy_cfg ipq8074_pciephy_gen3_cfg = {
1500f02543faSJohan Hovold 	.lanes			= 1,
1501334fad18SRobert Marko 
15022566ad8eSDmitry Baryshkov 	.tables = {
15032566ad8eSDmitry Baryshkov 		.serdes		= ipq8074_pcie_gen3_serdes_tbl,
15042566ad8eSDmitry Baryshkov 		.serdes_num	= ARRAY_SIZE(ipq8074_pcie_gen3_serdes_tbl),
15052566ad8eSDmitry Baryshkov 		.tx		= ipq8074_pcie_gen3_tx_tbl,
15062566ad8eSDmitry Baryshkov 		.tx_num		= ARRAY_SIZE(ipq8074_pcie_gen3_tx_tbl),
15072566ad8eSDmitry Baryshkov 		.rx		= ipq8074_pcie_gen3_rx_tbl,
15082566ad8eSDmitry Baryshkov 		.rx_num		= ARRAY_SIZE(ipq8074_pcie_gen3_rx_tbl),
15092566ad8eSDmitry Baryshkov 		.pcs		= ipq8074_pcie_gen3_pcs_tbl,
15102566ad8eSDmitry Baryshkov 		.pcs_num	= ARRAY_SIZE(ipq8074_pcie_gen3_pcs_tbl),
15112566ad8eSDmitry Baryshkov 	},
1512334fad18SRobert Marko 	.clk_list		= ipq8074_pciephy_clk_l,
1513334fad18SRobert Marko 	.num_clks		= ARRAY_SIZE(ipq8074_pciephy_clk_l),
1514334fad18SRobert Marko 	.reset_list		= ipq8074_pciephy_reset_l,
1515334fad18SRobert Marko 	.num_resets		= ARRAY_SIZE(ipq8074_pciephy_reset_l),
1516334fad18SRobert Marko 	.vreg_list		= NULL,
1517334fad18SRobert Marko 	.num_vregs		= 0,
1518334fad18SRobert Marko 	.regs			= ipq_pciephy_gen3_regs_layout,
1519334fad18SRobert Marko 
1520334fad18SRobert Marko 	.start_ctrl		= SERDES_START | PCS_START,
1521334fad18SRobert Marko 	.pwrdn_ctrl		= SW_PWRDN | REFCLK_DRV_DSBL,
152294b7288eSJohan Hovold 	.phy_status		= PHYSTATUS,
1523334fad18SRobert Marko 
1524334fad18SRobert Marko 	.pipe_clock_rate	= 250000000,
1525334fad18SRobert Marko };
1526334fad18SRobert Marko 
152794a407ccSDmitry Baryshkov static const struct qmp_phy_cfg ipq6018_pciephy_cfg = {
1528f02543faSJohan Hovold 	.lanes			= 1,
152994a407ccSDmitry Baryshkov 
15302566ad8eSDmitry Baryshkov 	.tables = {
15312566ad8eSDmitry Baryshkov 		.serdes		= ipq6018_pcie_serdes_tbl,
15322566ad8eSDmitry Baryshkov 		.serdes_num	= ARRAY_SIZE(ipq6018_pcie_serdes_tbl),
15332566ad8eSDmitry Baryshkov 		.tx		= ipq6018_pcie_tx_tbl,
15342566ad8eSDmitry Baryshkov 		.tx_num		= ARRAY_SIZE(ipq6018_pcie_tx_tbl),
15352566ad8eSDmitry Baryshkov 		.rx		= ipq6018_pcie_rx_tbl,
15362566ad8eSDmitry Baryshkov 		.rx_num		= ARRAY_SIZE(ipq6018_pcie_rx_tbl),
15372566ad8eSDmitry Baryshkov 		.pcs		= ipq6018_pcie_pcs_tbl,
15382566ad8eSDmitry Baryshkov 		.pcs_num	= ARRAY_SIZE(ipq6018_pcie_pcs_tbl),
15392566ad8eSDmitry Baryshkov 		.pcs_misc	= ipq6018_pcie_pcs_misc_tbl,
15402566ad8eSDmitry Baryshkov 		.pcs_misc_num	= ARRAY_SIZE(ipq6018_pcie_pcs_misc_tbl),
15412566ad8eSDmitry Baryshkov 	},
154294a407ccSDmitry Baryshkov 	.clk_list		= ipq8074_pciephy_clk_l,
154394a407ccSDmitry Baryshkov 	.num_clks		= ARRAY_SIZE(ipq8074_pciephy_clk_l),
154494a407ccSDmitry Baryshkov 	.reset_list		= ipq8074_pciephy_reset_l,
154594a407ccSDmitry Baryshkov 	.num_resets		= ARRAY_SIZE(ipq8074_pciephy_reset_l),
154694a407ccSDmitry Baryshkov 	.vreg_list		= NULL,
154794a407ccSDmitry Baryshkov 	.num_vregs		= 0,
154894a407ccSDmitry Baryshkov 	.regs			= ipq_pciephy_gen3_regs_layout,
154994a407ccSDmitry Baryshkov 
155094a407ccSDmitry Baryshkov 	.start_ctrl		= SERDES_START | PCS_START,
155194a407ccSDmitry Baryshkov 	.pwrdn_ctrl		= SW_PWRDN | REFCLK_DRV_DSBL,
155230518b19SJohan Hovold 	.phy_status		= PHYSTATUS,
155394a407ccSDmitry Baryshkov };
155494a407ccSDmitry Baryshkov 
155594a407ccSDmitry Baryshkov static const struct qmp_phy_cfg sdm845_qmp_pciephy_cfg = {
1556f02543faSJohan Hovold 	.lanes			= 1,
155794a407ccSDmitry Baryshkov 
15582566ad8eSDmitry Baryshkov 	.tables = {
15592566ad8eSDmitry Baryshkov 		.serdes		= sdm845_qmp_pcie_serdes_tbl,
15602566ad8eSDmitry Baryshkov 		.serdes_num	= ARRAY_SIZE(sdm845_qmp_pcie_serdes_tbl),
15612566ad8eSDmitry Baryshkov 		.tx		= sdm845_qmp_pcie_tx_tbl,
15622566ad8eSDmitry Baryshkov 		.tx_num		= ARRAY_SIZE(sdm845_qmp_pcie_tx_tbl),
15632566ad8eSDmitry Baryshkov 		.rx		= sdm845_qmp_pcie_rx_tbl,
15642566ad8eSDmitry Baryshkov 		.rx_num		= ARRAY_SIZE(sdm845_qmp_pcie_rx_tbl),
15652566ad8eSDmitry Baryshkov 		.pcs		= sdm845_qmp_pcie_pcs_tbl,
15662566ad8eSDmitry Baryshkov 		.pcs_num	= ARRAY_SIZE(sdm845_qmp_pcie_pcs_tbl),
15672566ad8eSDmitry Baryshkov 		.pcs_misc	= sdm845_qmp_pcie_pcs_misc_tbl,
15682566ad8eSDmitry Baryshkov 		.pcs_misc_num	= ARRAY_SIZE(sdm845_qmp_pcie_pcs_misc_tbl),
15692566ad8eSDmitry Baryshkov 	},
157094a407ccSDmitry Baryshkov 	.clk_list		= sdm845_pciephy_clk_l,
157194a407ccSDmitry Baryshkov 	.num_clks		= ARRAY_SIZE(sdm845_pciephy_clk_l),
157294a407ccSDmitry Baryshkov 	.reset_list		= sdm845_pciephy_reset_l,
157394a407ccSDmitry Baryshkov 	.num_resets		= ARRAY_SIZE(sdm845_pciephy_reset_l),
157494a407ccSDmitry Baryshkov 	.vreg_list		= qmp_phy_vreg_l,
157594a407ccSDmitry Baryshkov 	.num_vregs		= ARRAY_SIZE(qmp_phy_vreg_l),
157694a407ccSDmitry Baryshkov 	.regs			= sdm845_qmp_pciephy_regs_layout,
157794a407ccSDmitry Baryshkov 
157894a407ccSDmitry Baryshkov 	.start_ctrl		= PCS_START | SERDES_START,
157994a407ccSDmitry Baryshkov 	.pwrdn_ctrl		= SW_PWRDN | REFCLK_DRV_DSBL,
158094a407ccSDmitry Baryshkov 	.phy_status		= PHYSTATUS,
158194a407ccSDmitry Baryshkov };
158294a407ccSDmitry Baryshkov 
158394a407ccSDmitry Baryshkov static const struct qmp_phy_cfg sdm845_qhp_pciephy_cfg = {
1584f02543faSJohan Hovold 	.lanes			= 1,
158594a407ccSDmitry Baryshkov 
15862566ad8eSDmitry Baryshkov 	.tables = {
15872566ad8eSDmitry Baryshkov 		.serdes		= sdm845_qhp_pcie_serdes_tbl,
15882566ad8eSDmitry Baryshkov 		.serdes_num	= ARRAY_SIZE(sdm845_qhp_pcie_serdes_tbl),
15892566ad8eSDmitry Baryshkov 		.tx		= sdm845_qhp_pcie_tx_tbl,
15902566ad8eSDmitry Baryshkov 		.tx_num		= ARRAY_SIZE(sdm845_qhp_pcie_tx_tbl),
15912566ad8eSDmitry Baryshkov 		.rx		= sdm845_qhp_pcie_rx_tbl,
15922566ad8eSDmitry Baryshkov 		.rx_num		= ARRAY_SIZE(sdm845_qhp_pcie_rx_tbl),
15932566ad8eSDmitry Baryshkov 		.pcs		= sdm845_qhp_pcie_pcs_tbl,
15942566ad8eSDmitry Baryshkov 		.pcs_num	= ARRAY_SIZE(sdm845_qhp_pcie_pcs_tbl),
15952566ad8eSDmitry Baryshkov 	},
159694a407ccSDmitry Baryshkov 	.clk_list		= sdm845_pciephy_clk_l,
159794a407ccSDmitry Baryshkov 	.num_clks		= ARRAY_SIZE(sdm845_pciephy_clk_l),
159894a407ccSDmitry Baryshkov 	.reset_list		= sdm845_pciephy_reset_l,
159994a407ccSDmitry Baryshkov 	.num_resets		= ARRAY_SIZE(sdm845_pciephy_reset_l),
160094a407ccSDmitry Baryshkov 	.vreg_list		= qmp_phy_vreg_l,
160194a407ccSDmitry Baryshkov 	.num_vregs		= ARRAY_SIZE(qmp_phy_vreg_l),
160294a407ccSDmitry Baryshkov 	.regs			= sdm845_qhp_pciephy_regs_layout,
160394a407ccSDmitry Baryshkov 
160494a407ccSDmitry Baryshkov 	.start_ctrl		= PCS_START | SERDES_START,
160594a407ccSDmitry Baryshkov 	.pwrdn_ctrl		= SW_PWRDN | REFCLK_DRV_DSBL,
160694a407ccSDmitry Baryshkov 	.phy_status		= PHYSTATUS,
160794a407ccSDmitry Baryshkov };
160894a407ccSDmitry Baryshkov 
160994a407ccSDmitry Baryshkov static const struct qmp_phy_cfg sm8250_qmp_gen3x1_pciephy_cfg = {
1610f02543faSJohan Hovold 	.lanes			= 1,
161194a407ccSDmitry Baryshkov 
16122566ad8eSDmitry Baryshkov 	.tables = {
16132566ad8eSDmitry Baryshkov 		.serdes		= sm8250_qmp_pcie_serdes_tbl,
16142566ad8eSDmitry Baryshkov 		.serdes_num	= ARRAY_SIZE(sm8250_qmp_pcie_serdes_tbl),
16152566ad8eSDmitry Baryshkov 		.tx		= sm8250_qmp_pcie_tx_tbl,
16162566ad8eSDmitry Baryshkov 		.tx_num		= ARRAY_SIZE(sm8250_qmp_pcie_tx_tbl),
16172566ad8eSDmitry Baryshkov 		.rx		= sm8250_qmp_pcie_rx_tbl,
16182566ad8eSDmitry Baryshkov 		.rx_num		= ARRAY_SIZE(sm8250_qmp_pcie_rx_tbl),
16192566ad8eSDmitry Baryshkov 		.pcs		= sm8250_qmp_pcie_pcs_tbl,
16202566ad8eSDmitry Baryshkov 		.pcs_num	= ARRAY_SIZE(sm8250_qmp_pcie_pcs_tbl),
16212566ad8eSDmitry Baryshkov 		.pcs_misc	= sm8250_qmp_pcie_pcs_misc_tbl,
16222566ad8eSDmitry Baryshkov 		.pcs_misc_num	= ARRAY_SIZE(sm8250_qmp_pcie_pcs_misc_tbl),
16232566ad8eSDmitry Baryshkov 	},
16242566ad8eSDmitry Baryshkov 	.tables_rc = &(const struct qmp_phy_cfg_tables) {
16252566ad8eSDmitry Baryshkov 		.serdes		= sm8250_qmp_gen3x1_pcie_serdes_tbl,
16262566ad8eSDmitry Baryshkov 		.serdes_num	= ARRAY_SIZE(sm8250_qmp_gen3x1_pcie_serdes_tbl),
16272566ad8eSDmitry Baryshkov 		.rx		= sm8250_qmp_gen3x1_pcie_rx_tbl,
16282566ad8eSDmitry Baryshkov 		.rx_num		= ARRAY_SIZE(sm8250_qmp_gen3x1_pcie_rx_tbl),
16292566ad8eSDmitry Baryshkov 		.pcs		= sm8250_qmp_gen3x1_pcie_pcs_tbl,
16302566ad8eSDmitry Baryshkov 		.pcs_num	= ARRAY_SIZE(sm8250_qmp_gen3x1_pcie_pcs_tbl),
16312566ad8eSDmitry Baryshkov 		.pcs_misc	= sm8250_qmp_gen3x1_pcie_pcs_misc_tbl,
16322566ad8eSDmitry Baryshkov 		.pcs_misc_num	= ARRAY_SIZE(sm8250_qmp_gen3x1_pcie_pcs_misc_tbl),
16332566ad8eSDmitry Baryshkov 	},
163494a407ccSDmitry Baryshkov 	.clk_list		= sdm845_pciephy_clk_l,
163594a407ccSDmitry Baryshkov 	.num_clks		= ARRAY_SIZE(sdm845_pciephy_clk_l),
163694a407ccSDmitry Baryshkov 	.reset_list		= sdm845_pciephy_reset_l,
163794a407ccSDmitry Baryshkov 	.num_resets		= ARRAY_SIZE(sdm845_pciephy_reset_l),
163894a407ccSDmitry Baryshkov 	.vreg_list		= qmp_phy_vreg_l,
163994a407ccSDmitry Baryshkov 	.num_vregs		= ARRAY_SIZE(qmp_phy_vreg_l),
164094a407ccSDmitry Baryshkov 	.regs			= sm8250_pcie_regs_layout,
164194a407ccSDmitry Baryshkov 
164294a407ccSDmitry Baryshkov 	.start_ctrl		= PCS_START | SERDES_START,
164394a407ccSDmitry Baryshkov 	.pwrdn_ctrl		= SW_PWRDN | REFCLK_DRV_DSBL,
164494a407ccSDmitry Baryshkov 	.phy_status		= PHYSTATUS,
164594a407ccSDmitry Baryshkov };
164694a407ccSDmitry Baryshkov 
164794a407ccSDmitry Baryshkov static const struct qmp_phy_cfg sm8250_qmp_gen3x2_pciephy_cfg = {
1648f02543faSJohan Hovold 	.lanes			= 2,
164994a407ccSDmitry Baryshkov 
16502566ad8eSDmitry Baryshkov 	.tables = {
16512566ad8eSDmitry Baryshkov 		.serdes		= sm8250_qmp_pcie_serdes_tbl,
16522566ad8eSDmitry Baryshkov 		.serdes_num	= ARRAY_SIZE(sm8250_qmp_pcie_serdes_tbl),
16532566ad8eSDmitry Baryshkov 		.tx		= sm8250_qmp_pcie_tx_tbl,
16542566ad8eSDmitry Baryshkov 		.tx_num		= ARRAY_SIZE(sm8250_qmp_pcie_tx_tbl),
16552566ad8eSDmitry Baryshkov 		.rx		= sm8250_qmp_pcie_rx_tbl,
16562566ad8eSDmitry Baryshkov 		.rx_num		= ARRAY_SIZE(sm8250_qmp_pcie_rx_tbl),
16572566ad8eSDmitry Baryshkov 		.pcs		= sm8250_qmp_pcie_pcs_tbl,
16582566ad8eSDmitry Baryshkov 		.pcs_num	= ARRAY_SIZE(sm8250_qmp_pcie_pcs_tbl),
16592566ad8eSDmitry Baryshkov 		.pcs_misc	= sm8250_qmp_pcie_pcs_misc_tbl,
16602566ad8eSDmitry Baryshkov 		.pcs_misc_num	= ARRAY_SIZE(sm8250_qmp_pcie_pcs_misc_tbl),
16612566ad8eSDmitry Baryshkov 	},
16622566ad8eSDmitry Baryshkov 	.tables_rc = &(const struct qmp_phy_cfg_tables) {
16632566ad8eSDmitry Baryshkov 		.tx		= sm8250_qmp_gen3x2_pcie_tx_tbl,
16642566ad8eSDmitry Baryshkov 		.tx_num		= ARRAY_SIZE(sm8250_qmp_gen3x2_pcie_tx_tbl),
16652566ad8eSDmitry Baryshkov 		.rx		= sm8250_qmp_gen3x2_pcie_rx_tbl,
16662566ad8eSDmitry Baryshkov 		.rx_num		= ARRAY_SIZE(sm8250_qmp_gen3x2_pcie_rx_tbl),
16672566ad8eSDmitry Baryshkov 		.pcs		= sm8250_qmp_gen3x2_pcie_pcs_tbl,
16682566ad8eSDmitry Baryshkov 		.pcs_num	= ARRAY_SIZE(sm8250_qmp_gen3x2_pcie_pcs_tbl),
16692566ad8eSDmitry Baryshkov 		.pcs_misc	= sm8250_qmp_gen3x2_pcie_pcs_misc_tbl,
16702566ad8eSDmitry Baryshkov 		.pcs_misc_num	= ARRAY_SIZE(sm8250_qmp_gen3x2_pcie_pcs_misc_tbl),
16712566ad8eSDmitry Baryshkov 	},
167294a407ccSDmitry Baryshkov 	.clk_list		= sdm845_pciephy_clk_l,
167394a407ccSDmitry Baryshkov 	.num_clks		= ARRAY_SIZE(sdm845_pciephy_clk_l),
167494a407ccSDmitry Baryshkov 	.reset_list		= sdm845_pciephy_reset_l,
167594a407ccSDmitry Baryshkov 	.num_resets		= ARRAY_SIZE(sdm845_pciephy_reset_l),
167694a407ccSDmitry Baryshkov 	.vreg_list		= qmp_phy_vreg_l,
167794a407ccSDmitry Baryshkov 	.num_vregs		= ARRAY_SIZE(qmp_phy_vreg_l),
167894a407ccSDmitry Baryshkov 	.regs			= sm8250_pcie_regs_layout,
167994a407ccSDmitry Baryshkov 
168094a407ccSDmitry Baryshkov 	.start_ctrl		= PCS_START | SERDES_START,
168194a407ccSDmitry Baryshkov 	.pwrdn_ctrl		= SW_PWRDN | REFCLK_DRV_DSBL,
168294a407ccSDmitry Baryshkov 	.phy_status		= PHYSTATUS,
168394a407ccSDmitry Baryshkov };
168494a407ccSDmitry Baryshkov 
168594a407ccSDmitry Baryshkov static const struct qmp_phy_cfg msm8998_pciephy_cfg = {
1686f02543faSJohan Hovold 	.lanes			= 1,
168794a407ccSDmitry Baryshkov 
16882566ad8eSDmitry Baryshkov 	.tables = {
16892566ad8eSDmitry Baryshkov 		.serdes		= msm8998_pcie_serdes_tbl,
16902566ad8eSDmitry Baryshkov 		.serdes_num	= ARRAY_SIZE(msm8998_pcie_serdes_tbl),
16912566ad8eSDmitry Baryshkov 		.tx		= msm8998_pcie_tx_tbl,
16922566ad8eSDmitry Baryshkov 		.tx_num		= ARRAY_SIZE(msm8998_pcie_tx_tbl),
16932566ad8eSDmitry Baryshkov 		.rx		= msm8998_pcie_rx_tbl,
16942566ad8eSDmitry Baryshkov 		.rx_num		= ARRAY_SIZE(msm8998_pcie_rx_tbl),
16952566ad8eSDmitry Baryshkov 		.pcs		= msm8998_pcie_pcs_tbl,
16962566ad8eSDmitry Baryshkov 		.pcs_num	= ARRAY_SIZE(msm8998_pcie_pcs_tbl),
16972566ad8eSDmitry Baryshkov 	},
169894a407ccSDmitry Baryshkov 	.clk_list		= msm8996_phy_clk_l,
169994a407ccSDmitry Baryshkov 	.num_clks		= ARRAY_SIZE(msm8996_phy_clk_l),
170094a407ccSDmitry Baryshkov 	.reset_list		= ipq8074_pciephy_reset_l,
170194a407ccSDmitry Baryshkov 	.num_resets		= ARRAY_SIZE(ipq8074_pciephy_reset_l),
170294a407ccSDmitry Baryshkov 	.vreg_list		= qmp_phy_vreg_l,
170394a407ccSDmitry Baryshkov 	.num_vregs		= ARRAY_SIZE(qmp_phy_vreg_l),
170494a407ccSDmitry Baryshkov 	.regs			= pciephy_regs_layout,
170594a407ccSDmitry Baryshkov 
170694a407ccSDmitry Baryshkov 	.start_ctrl             = SERDES_START | PCS_START,
170794a407ccSDmitry Baryshkov 	.pwrdn_ctrl		= SW_PWRDN | REFCLK_DRV_DSBL,
170894a407ccSDmitry Baryshkov 	.phy_status		= PHYSTATUS,
170951bd3306SJohan Hovold 
171051bd3306SJohan Hovold 	.skip_start_delay	= true,
171194a407ccSDmitry Baryshkov };
171294a407ccSDmitry Baryshkov 
171394a407ccSDmitry Baryshkov static const struct qmp_phy_cfg sc8180x_pciephy_cfg = {
1714f02543faSJohan Hovold 	.lanes			= 1,
171594a407ccSDmitry Baryshkov 
17162566ad8eSDmitry Baryshkov 	.tables = {
17172566ad8eSDmitry Baryshkov 		.serdes		= sc8180x_qmp_pcie_serdes_tbl,
17182566ad8eSDmitry Baryshkov 		.serdes_num	= ARRAY_SIZE(sc8180x_qmp_pcie_serdes_tbl),
17192566ad8eSDmitry Baryshkov 		.tx		= sc8180x_qmp_pcie_tx_tbl,
17202566ad8eSDmitry Baryshkov 		.tx_num		= ARRAY_SIZE(sc8180x_qmp_pcie_tx_tbl),
17212566ad8eSDmitry Baryshkov 		.rx		= sc8180x_qmp_pcie_rx_tbl,
17222566ad8eSDmitry Baryshkov 		.rx_num		= ARRAY_SIZE(sc8180x_qmp_pcie_rx_tbl),
17232566ad8eSDmitry Baryshkov 		.pcs		= sc8180x_qmp_pcie_pcs_tbl,
17242566ad8eSDmitry Baryshkov 		.pcs_num	= ARRAY_SIZE(sc8180x_qmp_pcie_pcs_tbl),
17252566ad8eSDmitry Baryshkov 		.pcs_misc	= sc8180x_qmp_pcie_pcs_misc_tbl,
17262566ad8eSDmitry Baryshkov 		.pcs_misc_num	= ARRAY_SIZE(sc8180x_qmp_pcie_pcs_misc_tbl),
17272566ad8eSDmitry Baryshkov 	},
172894a407ccSDmitry Baryshkov 	.clk_list		= sdm845_pciephy_clk_l,
172994a407ccSDmitry Baryshkov 	.num_clks		= ARRAY_SIZE(sdm845_pciephy_clk_l),
173094a407ccSDmitry Baryshkov 	.reset_list		= sdm845_pciephy_reset_l,
173194a407ccSDmitry Baryshkov 	.num_resets		= ARRAY_SIZE(sdm845_pciephy_reset_l),
173294a407ccSDmitry Baryshkov 	.vreg_list		= qmp_phy_vreg_l,
173394a407ccSDmitry Baryshkov 	.num_vregs		= ARRAY_SIZE(qmp_phy_vreg_l),
173494a407ccSDmitry Baryshkov 	.regs			= sm8250_pcie_regs_layout,
173594a407ccSDmitry Baryshkov 
173694a407ccSDmitry Baryshkov 	.start_ctrl		= PCS_START | SERDES_START,
173794a407ccSDmitry Baryshkov 	.pwrdn_ctrl		= SW_PWRDN | REFCLK_DRV_DSBL,
17384a9eac5aSJohan Hovold 	.phy_status		= PHYSTATUS,
173994a407ccSDmitry Baryshkov };
174094a407ccSDmitry Baryshkov 
174194a407ccSDmitry Baryshkov static const struct qmp_phy_cfg sdx55_qmp_pciephy_cfg = {
1742f02543faSJohan Hovold 	.lanes			= 2,
174394a407ccSDmitry Baryshkov 
17442566ad8eSDmitry Baryshkov 	.tables = {
17452566ad8eSDmitry Baryshkov 		.serdes		= sdx55_qmp_pcie_serdes_tbl,
17462566ad8eSDmitry Baryshkov 		.serdes_num	= ARRAY_SIZE(sdx55_qmp_pcie_serdes_tbl),
17472566ad8eSDmitry Baryshkov 		.tx		= sdx55_qmp_pcie_tx_tbl,
17482566ad8eSDmitry Baryshkov 		.tx_num		= ARRAY_SIZE(sdx55_qmp_pcie_tx_tbl),
17492566ad8eSDmitry Baryshkov 		.rx		= sdx55_qmp_pcie_rx_tbl,
17502566ad8eSDmitry Baryshkov 		.rx_num		= ARRAY_SIZE(sdx55_qmp_pcie_rx_tbl),
17512566ad8eSDmitry Baryshkov 		.pcs		= sdx55_qmp_pcie_pcs_tbl,
17522566ad8eSDmitry Baryshkov 		.pcs_num	= ARRAY_SIZE(sdx55_qmp_pcie_pcs_tbl),
17532566ad8eSDmitry Baryshkov 		.pcs_misc	= sdx55_qmp_pcie_pcs_misc_tbl,
17542566ad8eSDmitry Baryshkov 		.pcs_misc_num	= ARRAY_SIZE(sdx55_qmp_pcie_pcs_misc_tbl),
17552566ad8eSDmitry Baryshkov 	},
175694a407ccSDmitry Baryshkov 	.clk_list		= sdm845_pciephy_clk_l,
175794a407ccSDmitry Baryshkov 	.num_clks		= ARRAY_SIZE(sdm845_pciephy_clk_l),
175894a407ccSDmitry Baryshkov 	.reset_list		= sdm845_pciephy_reset_l,
175994a407ccSDmitry Baryshkov 	.num_resets		= ARRAY_SIZE(sdm845_pciephy_reset_l),
176094a407ccSDmitry Baryshkov 	.vreg_list		= qmp_phy_vreg_l,
176194a407ccSDmitry Baryshkov 	.num_vregs		= ARRAY_SIZE(qmp_phy_vreg_l),
176294a407ccSDmitry Baryshkov 	.regs			= sm8250_pcie_regs_layout,
176394a407ccSDmitry Baryshkov 
176494a407ccSDmitry Baryshkov 	.start_ctrl		= PCS_START | SERDES_START,
176594a407ccSDmitry Baryshkov 	.pwrdn_ctrl		= SW_PWRDN,
176694a407ccSDmitry Baryshkov 	.phy_status		= PHYSTATUS_4_20,
176794a407ccSDmitry Baryshkov };
176894a407ccSDmitry Baryshkov 
176994a407ccSDmitry Baryshkov static const struct qmp_phy_cfg sm8450_qmp_gen3x1_pciephy_cfg = {
1770f02543faSJohan Hovold 	.lanes			= 1,
177194a407ccSDmitry Baryshkov 
17722566ad8eSDmitry Baryshkov 	.tables = {
17732566ad8eSDmitry Baryshkov 		.serdes		= sm8450_qmp_gen3x1_pcie_serdes_tbl,
17742566ad8eSDmitry Baryshkov 		.serdes_num	= ARRAY_SIZE(sm8450_qmp_gen3x1_pcie_serdes_tbl),
17752566ad8eSDmitry Baryshkov 		.tx		= sm8450_qmp_gen3x1_pcie_tx_tbl,
17762566ad8eSDmitry Baryshkov 		.tx_num		= ARRAY_SIZE(sm8450_qmp_gen3x1_pcie_tx_tbl),
17772566ad8eSDmitry Baryshkov 		.rx		= sm8450_qmp_gen3x1_pcie_rx_tbl,
17782566ad8eSDmitry Baryshkov 		.rx_num		= ARRAY_SIZE(sm8450_qmp_gen3x1_pcie_rx_tbl),
17792566ad8eSDmitry Baryshkov 		.pcs		= sm8450_qmp_gen3x1_pcie_pcs_tbl,
17802566ad8eSDmitry Baryshkov 		.pcs_num	= ARRAY_SIZE(sm8450_qmp_gen3x1_pcie_pcs_tbl),
17812566ad8eSDmitry Baryshkov 		.pcs_misc	= sm8450_qmp_gen3x1_pcie_pcs_misc_tbl,
17822566ad8eSDmitry Baryshkov 		.pcs_misc_num	= ARRAY_SIZE(sm8450_qmp_gen3x1_pcie_pcs_misc_tbl),
17832566ad8eSDmitry Baryshkov 	},
178494a407ccSDmitry Baryshkov 	.clk_list		= sdm845_pciephy_clk_l,
178594a407ccSDmitry Baryshkov 	.num_clks		= ARRAY_SIZE(sdm845_pciephy_clk_l),
178694a407ccSDmitry Baryshkov 	.reset_list		= sdm845_pciephy_reset_l,
178794a407ccSDmitry Baryshkov 	.num_resets		= ARRAY_SIZE(sdm845_pciephy_reset_l),
178894a407ccSDmitry Baryshkov 	.vreg_list		= qmp_phy_vreg_l,
178994a407ccSDmitry Baryshkov 	.num_vregs		= ARRAY_SIZE(qmp_phy_vreg_l),
179094a407ccSDmitry Baryshkov 	.regs			= sm8250_pcie_regs_layout,
179194a407ccSDmitry Baryshkov 
179294a407ccSDmitry Baryshkov 	.start_ctrl             = SERDES_START | PCS_START,
179394a407ccSDmitry Baryshkov 	.pwrdn_ctrl		= SW_PWRDN | REFCLK_DRV_DSBL,
179494a407ccSDmitry Baryshkov 	.phy_status		= PHYSTATUS,
179594a407ccSDmitry Baryshkov };
179694a407ccSDmitry Baryshkov 
179794a407ccSDmitry Baryshkov static const struct qmp_phy_cfg sm8450_qmp_gen4x2_pciephy_cfg = {
1798f02543faSJohan Hovold 	.lanes			= 2,
179994a407ccSDmitry Baryshkov 
18002566ad8eSDmitry Baryshkov 	.tables = {
18012566ad8eSDmitry Baryshkov 		.serdes		= sm8450_qmp_gen4x2_pcie_serdes_tbl,
18022566ad8eSDmitry Baryshkov 		.serdes_num	= ARRAY_SIZE(sm8450_qmp_gen4x2_pcie_serdes_tbl),
18032566ad8eSDmitry Baryshkov 		.tx		= sm8450_qmp_gen4x2_pcie_tx_tbl,
18042566ad8eSDmitry Baryshkov 		.tx_num		= ARRAY_SIZE(sm8450_qmp_gen4x2_pcie_tx_tbl),
18052566ad8eSDmitry Baryshkov 		.rx		= sm8450_qmp_gen4x2_pcie_rx_tbl,
18062566ad8eSDmitry Baryshkov 		.rx_num		= ARRAY_SIZE(sm8450_qmp_gen4x2_pcie_rx_tbl),
18072566ad8eSDmitry Baryshkov 		.pcs		= sm8450_qmp_gen4x2_pcie_pcs_tbl,
18082566ad8eSDmitry Baryshkov 		.pcs_num	= ARRAY_SIZE(sm8450_qmp_gen4x2_pcie_pcs_tbl),
18092566ad8eSDmitry Baryshkov 		.pcs_misc	= sm8450_qmp_gen4x2_pcie_pcs_misc_tbl,
18102566ad8eSDmitry Baryshkov 		.pcs_misc_num	= ARRAY_SIZE(sm8450_qmp_gen4x2_pcie_pcs_misc_tbl),
18112566ad8eSDmitry Baryshkov 	},
1812f5682f13SDmitry Baryshkov 
1813f5682f13SDmitry Baryshkov 	.tables_rc = &(const struct qmp_phy_cfg_tables) {
1814f5682f13SDmitry Baryshkov 		.serdes		= sm8450_qmp_gen4x2_pcie_rc_serdes_tbl,
1815f5682f13SDmitry Baryshkov 		.serdes_num	= ARRAY_SIZE(sm8450_qmp_gen4x2_pcie_rc_serdes_tbl),
1816f5682f13SDmitry Baryshkov 		.pcs_misc	= sm8450_qmp_gen4x2_pcie_rc_pcs_misc_tbl,
1817f5682f13SDmitry Baryshkov 		.pcs_misc_num	= ARRAY_SIZE(sm8450_qmp_gen4x2_pcie_rc_pcs_misc_tbl),
1818f5682f13SDmitry Baryshkov 	},
1819f5682f13SDmitry Baryshkov 
1820f5682f13SDmitry Baryshkov 	.tables_ep = &(const struct qmp_phy_cfg_tables) {
1821f5682f13SDmitry Baryshkov 		.serdes		= sm8450_qmp_gen4x2_pcie_ep_serdes_tbl,
1822f5682f13SDmitry Baryshkov 		.serdes_num	= ARRAY_SIZE(sm8450_qmp_gen4x2_pcie_ep_serdes_tbl),
1823f5682f13SDmitry Baryshkov 		.pcs_misc	= sm8450_qmp_gen4x2_pcie_ep_pcs_misc_tbl,
1824f5682f13SDmitry Baryshkov 		.pcs_misc_num	= ARRAY_SIZE(sm8450_qmp_gen4x2_pcie_ep_pcs_misc_tbl),
1825f5682f13SDmitry Baryshkov 	},
1826f5682f13SDmitry Baryshkov 
182794a407ccSDmitry Baryshkov 	.clk_list		= sdm845_pciephy_clk_l,
182894a407ccSDmitry Baryshkov 	.num_clks		= ARRAY_SIZE(sdm845_pciephy_clk_l),
182994a407ccSDmitry Baryshkov 	.reset_list		= sdm845_pciephy_reset_l,
183094a407ccSDmitry Baryshkov 	.num_resets		= ARRAY_SIZE(sdm845_pciephy_reset_l),
183194a407ccSDmitry Baryshkov 	.vreg_list		= qmp_phy_vreg_l,
183294a407ccSDmitry Baryshkov 	.num_vregs		= ARRAY_SIZE(qmp_phy_vreg_l),
183394a407ccSDmitry Baryshkov 	.regs			= sm8250_pcie_regs_layout,
183494a407ccSDmitry Baryshkov 
183594a407ccSDmitry Baryshkov 	.start_ctrl             = SERDES_START | PCS_START,
183694a407ccSDmitry Baryshkov 	.pwrdn_ctrl		= SW_PWRDN | REFCLK_DRV_DSBL,
183794a407ccSDmitry Baryshkov 	.phy_status		= PHYSTATUS_4_20,
183894a407ccSDmitry Baryshkov };
183994a407ccSDmitry Baryshkov 
184027878615SJohan Hovold static void qmp_pcie_configure_lane(void __iomem *base,
184194a407ccSDmitry Baryshkov 					const struct qmp_phy_init_tbl tbl[],
184294a407ccSDmitry Baryshkov 					int num,
184394a407ccSDmitry Baryshkov 					u8 lane_mask)
184494a407ccSDmitry Baryshkov {
184594a407ccSDmitry Baryshkov 	int i;
184694a407ccSDmitry Baryshkov 	const struct qmp_phy_init_tbl *t = tbl;
184794a407ccSDmitry Baryshkov 
184894a407ccSDmitry Baryshkov 	if (!t)
184994a407ccSDmitry Baryshkov 		return;
185094a407ccSDmitry Baryshkov 
185194a407ccSDmitry Baryshkov 	for (i = 0; i < num; i++, t++) {
185294a407ccSDmitry Baryshkov 		if (!(t->lane_mask & lane_mask))
185394a407ccSDmitry Baryshkov 			continue;
185494a407ccSDmitry Baryshkov 
185594a407ccSDmitry Baryshkov 		writel(t->val, base + t->offset);
185694a407ccSDmitry Baryshkov 	}
185794a407ccSDmitry Baryshkov }
185894a407ccSDmitry Baryshkov 
185927878615SJohan Hovold static void qmp_pcie_configure(void __iomem *base,
186094a407ccSDmitry Baryshkov 					const struct qmp_phy_init_tbl tbl[],
186194a407ccSDmitry Baryshkov 					int num)
186294a407ccSDmitry Baryshkov {
1863f2175762SJohan Hovold 	qmp_pcie_configure_lane(base, tbl, num, 0xff);
186494a407ccSDmitry Baryshkov }
186594a407ccSDmitry Baryshkov 
18662566ad8eSDmitry Baryshkov static void qmp_pcie_serdes_init(struct qmp_phy *qphy, const struct qmp_phy_cfg_tables *tables)
186794a407ccSDmitry Baryshkov {
186894a407ccSDmitry Baryshkov 	void __iomem *serdes = qphy->serdes;
186994a407ccSDmitry Baryshkov 
18702566ad8eSDmitry Baryshkov 	if (!tables)
18712566ad8eSDmitry Baryshkov 		return;
187294a407ccSDmitry Baryshkov 
1873f2175762SJohan Hovold 	qmp_pcie_configure(serdes, tables->serdes, tables->serdes_num);
18742566ad8eSDmitry Baryshkov }
18752566ad8eSDmitry Baryshkov 
18762566ad8eSDmitry Baryshkov static void qmp_pcie_lanes_init(struct qmp_phy *qphy, const struct qmp_phy_cfg_tables *tables)
18772566ad8eSDmitry Baryshkov {
18782566ad8eSDmitry Baryshkov 	const struct qmp_phy_cfg *cfg = qphy->cfg;
18792566ad8eSDmitry Baryshkov 	void __iomem *tx = qphy->tx;
18802566ad8eSDmitry Baryshkov 	void __iomem *rx = qphy->rx;
18812566ad8eSDmitry Baryshkov 
18822566ad8eSDmitry Baryshkov 	if (!tables)
18832566ad8eSDmitry Baryshkov 		return;
18842566ad8eSDmitry Baryshkov 
1885f2175762SJohan Hovold 	qmp_pcie_configure_lane(tx, tables->tx, tables->tx_num, 1);
18862566ad8eSDmitry Baryshkov 
18872566ad8eSDmitry Baryshkov 	if (cfg->lanes >= 2)
1888f2175762SJohan Hovold 		qmp_pcie_configure_lane(qphy->tx2, tables->tx, tables->tx_num, 2);
18892566ad8eSDmitry Baryshkov 
1890f2175762SJohan Hovold 	qmp_pcie_configure_lane(rx, tables->rx, tables->rx_num, 1);
18912566ad8eSDmitry Baryshkov 	if (cfg->lanes >= 2)
1892f2175762SJohan Hovold 		qmp_pcie_configure_lane(qphy->rx2, tables->rx, tables->rx_num, 2);
18932566ad8eSDmitry Baryshkov }
18942566ad8eSDmitry Baryshkov 
18952566ad8eSDmitry Baryshkov static void qmp_pcie_pcs_init(struct qmp_phy *qphy, const struct qmp_phy_cfg_tables *tables)
18962566ad8eSDmitry Baryshkov {
18972566ad8eSDmitry Baryshkov 	void __iomem *pcs = qphy->pcs;
18982566ad8eSDmitry Baryshkov 	void __iomem *pcs_misc = qphy->pcs_misc;
18992566ad8eSDmitry Baryshkov 
19002566ad8eSDmitry Baryshkov 	if (!tables)
19012566ad8eSDmitry Baryshkov 		return;
19022566ad8eSDmitry Baryshkov 
1903f2175762SJohan Hovold 	qmp_pcie_configure(pcs, tables->pcs, tables->pcs_num);
1904f2175762SJohan Hovold 	qmp_pcie_configure(pcs_misc, tables->pcs_misc, tables->pcs_misc_num);
190594a407ccSDmitry Baryshkov }
190694a407ccSDmitry Baryshkov 
190791174e2cSJohan Hovold static int qmp_pcie_init(struct phy *phy)
190894a407ccSDmitry Baryshkov {
190991174e2cSJohan Hovold 	struct qmp_phy *qphy = phy_get_drvdata(phy);
191094a407ccSDmitry Baryshkov 	struct qcom_qmp *qmp = qphy->qmp;
191194a407ccSDmitry Baryshkov 	const struct qmp_phy_cfg *cfg = qphy->cfg;
1912189ac6b8SDmitry Baryshkov 	int ret;
191394a407ccSDmitry Baryshkov 
191494a407ccSDmitry Baryshkov 	ret = regulator_bulk_enable(cfg->num_vregs, qmp->vregs);
191594a407ccSDmitry Baryshkov 	if (ret) {
191694a407ccSDmitry Baryshkov 		dev_err(qmp->dev, "failed to enable regulators, err=%d\n", ret);
19171239fd71SDmitry Baryshkov 		return ret;
191894a407ccSDmitry Baryshkov 	}
191994a407ccSDmitry Baryshkov 
1920189ac6b8SDmitry Baryshkov 	ret = reset_control_bulk_assert(cfg->num_resets, qmp->resets);
192194a407ccSDmitry Baryshkov 	if (ret) {
1922189ac6b8SDmitry Baryshkov 		dev_err(qmp->dev, "reset assert failed\n");
192394a407ccSDmitry Baryshkov 		goto err_disable_regulators;
192494a407ccSDmitry Baryshkov 	}
192594a407ccSDmitry Baryshkov 
1926189ac6b8SDmitry Baryshkov 	ret = reset_control_bulk_deassert(cfg->num_resets, qmp->resets);
192794a407ccSDmitry Baryshkov 	if (ret) {
1928189ac6b8SDmitry Baryshkov 		dev_err(qmp->dev, "reset deassert failed\n");
1929189ac6b8SDmitry Baryshkov 		goto err_disable_regulators;
193094a407ccSDmitry Baryshkov 	}
193194a407ccSDmitry Baryshkov 
193294a407ccSDmitry Baryshkov 	ret = clk_bulk_prepare_enable(cfg->num_clks, qmp->clks);
193394a407ccSDmitry Baryshkov 	if (ret)
193494a407ccSDmitry Baryshkov 		goto err_assert_reset;
193594a407ccSDmitry Baryshkov 
193694a407ccSDmitry Baryshkov 	return 0;
193794a407ccSDmitry Baryshkov 
193894a407ccSDmitry Baryshkov err_assert_reset:
1939189ac6b8SDmitry Baryshkov 	reset_control_bulk_assert(cfg->num_resets, qmp->resets);
194094a407ccSDmitry Baryshkov err_disable_regulators:
194194a407ccSDmitry Baryshkov 	regulator_bulk_disable(cfg->num_vregs, qmp->vregs);
194294a407ccSDmitry Baryshkov 
194394a407ccSDmitry Baryshkov 	return ret;
194494a407ccSDmitry Baryshkov }
194594a407ccSDmitry Baryshkov 
194691174e2cSJohan Hovold static int qmp_pcie_exit(struct phy *phy)
194794a407ccSDmitry Baryshkov {
194891174e2cSJohan Hovold 	struct qmp_phy *qphy = phy_get_drvdata(phy);
194994a407ccSDmitry Baryshkov 	struct qcom_qmp *qmp = qphy->qmp;
195094a407ccSDmitry Baryshkov 	const struct qmp_phy_cfg *cfg = qphy->cfg;
195194a407ccSDmitry Baryshkov 
1952189ac6b8SDmitry Baryshkov 	reset_control_bulk_assert(cfg->num_resets, qmp->resets);
195394a407ccSDmitry Baryshkov 
195494a407ccSDmitry Baryshkov 	clk_bulk_disable_unprepare(cfg->num_clks, qmp->clks);
195594a407ccSDmitry Baryshkov 
195694a407ccSDmitry Baryshkov 	regulator_bulk_disable(cfg->num_vregs, qmp->vregs);
195794a407ccSDmitry Baryshkov 
195894a407ccSDmitry Baryshkov 	return 0;
195994a407ccSDmitry Baryshkov }
196094a407ccSDmitry Baryshkov 
196127878615SJohan Hovold static int qmp_pcie_power_on(struct phy *phy)
196294a407ccSDmitry Baryshkov {
196394a407ccSDmitry Baryshkov 	struct qmp_phy *qphy = phy_get_drvdata(phy);
196494a407ccSDmitry Baryshkov 	struct qcom_qmp *qmp = qphy->qmp;
196594a407ccSDmitry Baryshkov 	const struct qmp_phy_cfg *cfg = qphy->cfg;
196611bf53a3SDmitry Baryshkov 	const struct qmp_phy_cfg_tables *mode_tables;
196794a407ccSDmitry Baryshkov 	void __iomem *pcs = qphy->pcs;
196894a407ccSDmitry Baryshkov 	void __iomem *status;
19692577ba8cSJohan Hovold 	unsigned int mask, val;
197094a407ccSDmitry Baryshkov 	int ret;
197194a407ccSDmitry Baryshkov 
19725b68d95cSJohan Hovold 	qphy_setbits(pcs, cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL],
19735b68d95cSJohan Hovold 			cfg->pwrdn_ctrl);
19745b68d95cSJohan Hovold 
197511bf53a3SDmitry Baryshkov 	if (qphy->mode == PHY_MODE_PCIE_RC)
197611bf53a3SDmitry Baryshkov 		mode_tables = cfg->tables_rc;
197711bf53a3SDmitry Baryshkov 	else
197811bf53a3SDmitry Baryshkov 		mode_tables = cfg->tables_ep;
197911bf53a3SDmitry Baryshkov 
19802566ad8eSDmitry Baryshkov 	qmp_pcie_serdes_init(qphy, &cfg->tables);
198111bf53a3SDmitry Baryshkov 	qmp_pcie_serdes_init(qphy, mode_tables);
198294a407ccSDmitry Baryshkov 
198394a407ccSDmitry Baryshkov 	ret = clk_prepare_enable(qphy->pipe_clk);
198494a407ccSDmitry Baryshkov 	if (ret) {
198594a407ccSDmitry Baryshkov 		dev_err(qmp->dev, "pipe_clk enable failed err=%d\n", ret);
1986fd926994SDmitry Baryshkov 		return ret;
198794a407ccSDmitry Baryshkov 	}
198894a407ccSDmitry Baryshkov 
198994a407ccSDmitry Baryshkov 	/* Tx, Rx, and PCS configurations */
19902566ad8eSDmitry Baryshkov 	qmp_pcie_lanes_init(qphy, &cfg->tables);
199111bf53a3SDmitry Baryshkov 	qmp_pcie_lanes_init(qphy, mode_tables);
199294a407ccSDmitry Baryshkov 
19932566ad8eSDmitry Baryshkov 	qmp_pcie_pcs_init(qphy, &cfg->tables);
199411bf53a3SDmitry Baryshkov 	qmp_pcie_pcs_init(qphy, mode_tables);
199594a407ccSDmitry Baryshkov 
199694a407ccSDmitry Baryshkov 	/* Pull PHY out of reset state */
199794a407ccSDmitry Baryshkov 	qphy_clrbits(pcs, cfg->regs[QPHY_SW_RESET], SW_RESET);
1998fd926994SDmitry Baryshkov 
199994a407ccSDmitry Baryshkov 	/* start SerDes and Phy-Coding-Sublayer */
200094a407ccSDmitry Baryshkov 	qphy_setbits(pcs, cfg->regs[QPHY_START_CTRL], cfg->start_ctrl);
200194a407ccSDmitry Baryshkov 
200251bd3306SJohan Hovold 	if (!cfg->skip_start_delay)
200351bd3306SJohan Hovold 		usleep_range(1000, 1200);
200451bd3306SJohan Hovold 
200594a407ccSDmitry Baryshkov 	status = pcs + cfg->regs[QPHY_PCS_STATUS];
200694a407ccSDmitry Baryshkov 	mask = cfg->phy_status;
2007*5cbeb75aSJohan Hovold 	ret = readl_poll_timeout(status, val, !(val & mask), 200,
200894a407ccSDmitry Baryshkov 				 PHY_INIT_COMPLETE_TIMEOUT);
200994a407ccSDmitry Baryshkov 	if (ret) {
201094a407ccSDmitry Baryshkov 		dev_err(qmp->dev, "phy initialization timed-out\n");
201194a407ccSDmitry Baryshkov 		goto err_disable_pipe_clk;
201294a407ccSDmitry Baryshkov 	}
2013da07a06bSDmitry Baryshkov 
201494a407ccSDmitry Baryshkov 	return 0;
201594a407ccSDmitry Baryshkov 
201694a407ccSDmitry Baryshkov err_disable_pipe_clk:
201794a407ccSDmitry Baryshkov 	clk_disable_unprepare(qphy->pipe_clk);
201894a407ccSDmitry Baryshkov 
201994a407ccSDmitry Baryshkov 	return ret;
202094a407ccSDmitry Baryshkov }
202194a407ccSDmitry Baryshkov 
202227878615SJohan Hovold static int qmp_pcie_power_off(struct phy *phy)
202394a407ccSDmitry Baryshkov {
202494a407ccSDmitry Baryshkov 	struct qmp_phy *qphy = phy_get_drvdata(phy);
202594a407ccSDmitry Baryshkov 	const struct qmp_phy_cfg *cfg = qphy->cfg;
202694a407ccSDmitry Baryshkov 
202794a407ccSDmitry Baryshkov 	clk_disable_unprepare(qphy->pipe_clk);
202894a407ccSDmitry Baryshkov 
202994a407ccSDmitry Baryshkov 	/* PHY reset */
203094a407ccSDmitry Baryshkov 	qphy_setbits(qphy->pcs, cfg->regs[QPHY_SW_RESET], SW_RESET);
203194a407ccSDmitry Baryshkov 
203294a407ccSDmitry Baryshkov 	/* stop SerDes and Phy-Coding-Sublayer */
203394a407ccSDmitry Baryshkov 	qphy_clrbits(qphy->pcs, cfg->regs[QPHY_START_CTRL], cfg->start_ctrl);
203494a407ccSDmitry Baryshkov 
203594a407ccSDmitry Baryshkov 	/* Put PHY into POWER DOWN state: active low */
203694a407ccSDmitry Baryshkov 	qphy_clrbits(qphy->pcs, cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL],
203794a407ccSDmitry Baryshkov 			cfg->pwrdn_ctrl);
203894a407ccSDmitry Baryshkov 
203994a407ccSDmitry Baryshkov 	return 0;
204094a407ccSDmitry Baryshkov }
204194a407ccSDmitry Baryshkov 
204227878615SJohan Hovold static int qmp_pcie_enable(struct phy *phy)
204394a407ccSDmitry Baryshkov {
204494a407ccSDmitry Baryshkov 	int ret;
204594a407ccSDmitry Baryshkov 
204627878615SJohan Hovold 	ret = qmp_pcie_init(phy);
204794a407ccSDmitry Baryshkov 	if (ret)
204894a407ccSDmitry Baryshkov 		return ret;
204994a407ccSDmitry Baryshkov 
205027878615SJohan Hovold 	ret = qmp_pcie_power_on(phy);
205194a407ccSDmitry Baryshkov 	if (ret)
205227878615SJohan Hovold 		qmp_pcie_exit(phy);
205394a407ccSDmitry Baryshkov 
205494a407ccSDmitry Baryshkov 	return ret;
205594a407ccSDmitry Baryshkov }
205694a407ccSDmitry Baryshkov 
205727878615SJohan Hovold static int qmp_pcie_disable(struct phy *phy)
205894a407ccSDmitry Baryshkov {
205994a407ccSDmitry Baryshkov 	int ret;
206094a407ccSDmitry Baryshkov 
206127878615SJohan Hovold 	ret = qmp_pcie_power_off(phy);
206294a407ccSDmitry Baryshkov 	if (ret)
206394a407ccSDmitry Baryshkov 		return ret;
206427878615SJohan Hovold 
206527878615SJohan Hovold 	return qmp_pcie_exit(phy);
206694a407ccSDmitry Baryshkov }
206794a407ccSDmitry Baryshkov 
206811bf53a3SDmitry Baryshkov static int qmp_pcie_set_mode(struct phy *phy, enum phy_mode mode, int submode)
206911bf53a3SDmitry Baryshkov {
207011bf53a3SDmitry Baryshkov 	struct qmp_phy *qphy = phy_get_drvdata(phy);
207111bf53a3SDmitry Baryshkov 
207211bf53a3SDmitry Baryshkov 	switch (submode) {
207311bf53a3SDmitry Baryshkov 	case PHY_MODE_PCIE_RC:
207411bf53a3SDmitry Baryshkov 	case PHY_MODE_PCIE_EP:
207511bf53a3SDmitry Baryshkov 		qphy->mode = submode;
207611bf53a3SDmitry Baryshkov 		break;
207711bf53a3SDmitry Baryshkov 	default:
207811bf53a3SDmitry Baryshkov 		dev_err(&phy->dev, "Unsupported submode %d\n", submode);
207911bf53a3SDmitry Baryshkov 		return -EINVAL;
208011bf53a3SDmitry Baryshkov 	}
208111bf53a3SDmitry Baryshkov 
208211bf53a3SDmitry Baryshkov 	return 0;
208311bf53a3SDmitry Baryshkov }
208411bf53a3SDmitry Baryshkov 
208527878615SJohan Hovold static int qmp_pcie_vreg_init(struct device *dev, const struct qmp_phy_cfg *cfg)
208694a407ccSDmitry Baryshkov {
208794a407ccSDmitry Baryshkov 	struct qcom_qmp *qmp = dev_get_drvdata(dev);
208894a407ccSDmitry Baryshkov 	int num = cfg->num_vregs;
208994a407ccSDmitry Baryshkov 	int i;
209094a407ccSDmitry Baryshkov 
209194a407ccSDmitry Baryshkov 	qmp->vregs = devm_kcalloc(dev, num, sizeof(*qmp->vregs), GFP_KERNEL);
209294a407ccSDmitry Baryshkov 	if (!qmp->vregs)
209394a407ccSDmitry Baryshkov 		return -ENOMEM;
209494a407ccSDmitry Baryshkov 
209594a407ccSDmitry Baryshkov 	for (i = 0; i < num; i++)
209694a407ccSDmitry Baryshkov 		qmp->vregs[i].supply = cfg->vreg_list[i];
209794a407ccSDmitry Baryshkov 
209894a407ccSDmitry Baryshkov 	return devm_regulator_bulk_get(dev, num, qmp->vregs);
209994a407ccSDmitry Baryshkov }
210094a407ccSDmitry Baryshkov 
210127878615SJohan Hovold static int qmp_pcie_reset_init(struct device *dev, const struct qmp_phy_cfg *cfg)
210294a407ccSDmitry Baryshkov {
210394a407ccSDmitry Baryshkov 	struct qcom_qmp *qmp = dev_get_drvdata(dev);
210494a407ccSDmitry Baryshkov 	int i;
2105189ac6b8SDmitry Baryshkov 	int ret;
210694a407ccSDmitry Baryshkov 
210794a407ccSDmitry Baryshkov 	qmp->resets = devm_kcalloc(dev, cfg->num_resets,
210894a407ccSDmitry Baryshkov 				   sizeof(*qmp->resets), GFP_KERNEL);
210994a407ccSDmitry Baryshkov 	if (!qmp->resets)
211094a407ccSDmitry Baryshkov 		return -ENOMEM;
211194a407ccSDmitry Baryshkov 
2112189ac6b8SDmitry Baryshkov 	for (i = 0; i < cfg->num_resets; i++)
2113189ac6b8SDmitry Baryshkov 		qmp->resets[i].id = cfg->reset_list[i];
211494a407ccSDmitry Baryshkov 
2115189ac6b8SDmitry Baryshkov 	ret = devm_reset_control_bulk_get_exclusive(dev, cfg->num_resets, qmp->resets);
2116189ac6b8SDmitry Baryshkov 	if (ret)
2117189ac6b8SDmitry Baryshkov 		return dev_err_probe(dev, ret, "failed to get resets\n");
211894a407ccSDmitry Baryshkov 
211994a407ccSDmitry Baryshkov 	return 0;
212094a407ccSDmitry Baryshkov }
212194a407ccSDmitry Baryshkov 
212227878615SJohan Hovold static int qmp_pcie_clk_init(struct device *dev, const struct qmp_phy_cfg *cfg)
212394a407ccSDmitry Baryshkov {
212494a407ccSDmitry Baryshkov 	struct qcom_qmp *qmp = dev_get_drvdata(dev);
212594a407ccSDmitry Baryshkov 	int num = cfg->num_clks;
212694a407ccSDmitry Baryshkov 	int i;
212794a407ccSDmitry Baryshkov 
212894a407ccSDmitry Baryshkov 	qmp->clks = devm_kcalloc(dev, num, sizeof(*qmp->clks), GFP_KERNEL);
212994a407ccSDmitry Baryshkov 	if (!qmp->clks)
213094a407ccSDmitry Baryshkov 		return -ENOMEM;
213194a407ccSDmitry Baryshkov 
213294a407ccSDmitry Baryshkov 	for (i = 0; i < num; i++)
213394a407ccSDmitry Baryshkov 		qmp->clks[i].id = cfg->clk_list[i];
213494a407ccSDmitry Baryshkov 
213594a407ccSDmitry Baryshkov 	return devm_clk_bulk_get(dev, num, qmp->clks);
213694a407ccSDmitry Baryshkov }
213794a407ccSDmitry Baryshkov 
213894a407ccSDmitry Baryshkov static void phy_clk_release_provider(void *res)
213994a407ccSDmitry Baryshkov {
214094a407ccSDmitry Baryshkov 	of_clk_del_provider(res);
214194a407ccSDmitry Baryshkov }
214294a407ccSDmitry Baryshkov 
214394a407ccSDmitry Baryshkov /*
214494a407ccSDmitry Baryshkov  * Register a fixed rate pipe clock.
214594a407ccSDmitry Baryshkov  *
214694a407ccSDmitry Baryshkov  * The <s>_pipe_clksrc generated by PHY goes to the GCC that gate
214794a407ccSDmitry Baryshkov  * controls it. The <s>_pipe_clk coming out of the GCC is requested
214894a407ccSDmitry Baryshkov  * by the PHY driver for its operations.
214994a407ccSDmitry Baryshkov  * We register the <s>_pipe_clksrc here. The gcc driver takes care
215094a407ccSDmitry Baryshkov  * of assigning this <s>_pipe_clksrc as parent to <s>_pipe_clk.
215194a407ccSDmitry Baryshkov  * Below picture shows this relationship.
215294a407ccSDmitry Baryshkov  *
215394a407ccSDmitry Baryshkov  *         +---------------+
215494a407ccSDmitry Baryshkov  *         |   PHY block   |<<---------------------------------------+
215594a407ccSDmitry Baryshkov  *         |               |                                         |
215694a407ccSDmitry Baryshkov  *         |   +-------+   |                   +-----+               |
215794a407ccSDmitry Baryshkov  *   I/P---^-->|  PLL  |---^--->pipe_clksrc--->| GCC |--->pipe_clk---+
215894a407ccSDmitry Baryshkov  *    clk  |   +-------+   |                   +-----+
215994a407ccSDmitry Baryshkov  *         +---------------+
216094a407ccSDmitry Baryshkov  */
216194a407ccSDmitry Baryshkov static int phy_pipe_clk_register(struct qcom_qmp *qmp, struct device_node *np)
216294a407ccSDmitry Baryshkov {
216394a407ccSDmitry Baryshkov 	struct clk_fixed_rate *fixed;
216494a407ccSDmitry Baryshkov 	struct clk_init_data init = { };
216594a407ccSDmitry Baryshkov 	int ret;
216694a407ccSDmitry Baryshkov 
216794a407ccSDmitry Baryshkov 	ret = of_property_read_string(np, "clock-output-names", &init.name);
216894a407ccSDmitry Baryshkov 	if (ret) {
216994a407ccSDmitry Baryshkov 		dev_err(qmp->dev, "%pOFn: No clock-output-names\n", np);
217094a407ccSDmitry Baryshkov 		return ret;
217194a407ccSDmitry Baryshkov 	}
217294a407ccSDmitry Baryshkov 
217394a407ccSDmitry Baryshkov 	fixed = devm_kzalloc(qmp->dev, sizeof(*fixed), GFP_KERNEL);
217494a407ccSDmitry Baryshkov 	if (!fixed)
217594a407ccSDmitry Baryshkov 		return -ENOMEM;
217694a407ccSDmitry Baryshkov 
217794a407ccSDmitry Baryshkov 	init.ops = &clk_fixed_rate_ops;
217894a407ccSDmitry Baryshkov 
21792ec9bc8dSRobert Marko 	/*
21802ec9bc8dSRobert Marko 	 * Controllers using QMP PHY-s use 125MHz pipe clock interface
21812ec9bc8dSRobert Marko 	 * unless other frequency is specified in the PHY config.
21822ec9bc8dSRobert Marko 	 */
21832ec9bc8dSRobert Marko 	if (qmp->phys[0]->cfg->pipe_clock_rate)
21842ec9bc8dSRobert Marko 		fixed->fixed_rate = qmp->phys[0]->cfg->pipe_clock_rate;
21852ec9bc8dSRobert Marko 	else
218694a407ccSDmitry Baryshkov 		fixed->fixed_rate = 125000000;
21872ec9bc8dSRobert Marko 
218894a407ccSDmitry Baryshkov 	fixed->hw.init = &init;
218994a407ccSDmitry Baryshkov 
219094a407ccSDmitry Baryshkov 	ret = devm_clk_hw_register(qmp->dev, &fixed->hw);
219194a407ccSDmitry Baryshkov 	if (ret)
219294a407ccSDmitry Baryshkov 		return ret;
219394a407ccSDmitry Baryshkov 
219494a407ccSDmitry Baryshkov 	ret = of_clk_add_hw_provider(np, of_clk_hw_simple_get, &fixed->hw);
219594a407ccSDmitry Baryshkov 	if (ret)
219694a407ccSDmitry Baryshkov 		return ret;
219794a407ccSDmitry Baryshkov 
219894a407ccSDmitry Baryshkov 	/*
219994a407ccSDmitry Baryshkov 	 * Roll a devm action because the clock provider is the child node, but
220094a407ccSDmitry Baryshkov 	 * the child node is not actually a device.
220194a407ccSDmitry Baryshkov 	 */
220294a407ccSDmitry Baryshkov 	return devm_add_action_or_reset(qmp->dev, phy_clk_release_provider, np);
220394a407ccSDmitry Baryshkov }
220494a407ccSDmitry Baryshkov 
220527878615SJohan Hovold static const struct phy_ops qmp_pcie_ops = {
220627878615SJohan Hovold 	.power_on	= qmp_pcie_enable,
220727878615SJohan Hovold 	.power_off	= qmp_pcie_disable,
220811bf53a3SDmitry Baryshkov 	.set_mode	= qmp_pcie_set_mode,
220994a407ccSDmitry Baryshkov 	.owner		= THIS_MODULE,
221094a407ccSDmitry Baryshkov };
221194a407ccSDmitry Baryshkov 
221227878615SJohan Hovold static int qmp_pcie_create(struct device *dev, struct device_node *np, int id,
221394a407ccSDmitry Baryshkov 			void __iomem *serdes, const struct qmp_phy_cfg *cfg)
221494a407ccSDmitry Baryshkov {
221594a407ccSDmitry Baryshkov 	struct qcom_qmp *qmp = dev_get_drvdata(dev);
221694a407ccSDmitry Baryshkov 	struct phy *generic_phy;
221794a407ccSDmitry Baryshkov 	struct qmp_phy *qphy;
221894a407ccSDmitry Baryshkov 	int ret;
221994a407ccSDmitry Baryshkov 
222094a407ccSDmitry Baryshkov 	qphy = devm_kzalloc(dev, sizeof(*qphy), GFP_KERNEL);
222194a407ccSDmitry Baryshkov 	if (!qphy)
222294a407ccSDmitry Baryshkov 		return -ENOMEM;
222394a407ccSDmitry Baryshkov 
222411bf53a3SDmitry Baryshkov 	qphy->mode = PHY_MODE_PCIE_RC;
222511bf53a3SDmitry Baryshkov 
222694a407ccSDmitry Baryshkov 	qphy->cfg = cfg;
222794a407ccSDmitry Baryshkov 	qphy->serdes = serdes;
222894a407ccSDmitry Baryshkov 	/*
22298d3bf724SJohan Hovold 	 * Get memory resources for the PHY:
223094a407ccSDmitry Baryshkov 	 * Resources are indexed as: tx -> 0; rx -> 1; pcs -> 2.
223194a407ccSDmitry Baryshkov 	 * For dual lane PHYs: tx2 -> 3, rx2 -> 4, pcs_misc (optional) -> 5
223294a407ccSDmitry Baryshkov 	 * For single lane PHYs: pcs_misc (optional) -> 3.
223394a407ccSDmitry Baryshkov 	 */
22344be26f69SJohan Hovold 	qphy->tx = devm_of_iomap(dev, np, 0, NULL);
22354be26f69SJohan Hovold 	if (IS_ERR(qphy->tx))
22364be26f69SJohan Hovold 		return PTR_ERR(qphy->tx);
223794a407ccSDmitry Baryshkov 
22380a40891bSDmitry Baryshkov 	if (of_device_is_compatible(dev->of_node, "qcom,sdm845-qhp-pcie-phy"))
22390a40891bSDmitry Baryshkov 		qphy->rx = qphy->tx;
22400a40891bSDmitry Baryshkov 	else
22414be26f69SJohan Hovold 		qphy->rx = devm_of_iomap(dev, np, 1, NULL);
22424be26f69SJohan Hovold 	if (IS_ERR(qphy->rx))
22434be26f69SJohan Hovold 		return PTR_ERR(qphy->rx);
224494a407ccSDmitry Baryshkov 
22454be26f69SJohan Hovold 	qphy->pcs = devm_of_iomap(dev, np, 2, NULL);
22464be26f69SJohan Hovold 	if (IS_ERR(qphy->pcs))
22474be26f69SJohan Hovold 		return PTR_ERR(qphy->pcs);
224894a407ccSDmitry Baryshkov 
2249f02543faSJohan Hovold 	if (cfg->lanes >= 2) {
22504be26f69SJohan Hovold 		qphy->tx2 = devm_of_iomap(dev, np, 3, NULL);
225169c90cb5SJohan Hovold 		if (IS_ERR(qphy->tx2))
225269c90cb5SJohan Hovold 			return PTR_ERR(qphy->tx2);
225369c90cb5SJohan Hovold 
22544be26f69SJohan Hovold 		qphy->rx2 = devm_of_iomap(dev, np, 4, NULL);
225569c90cb5SJohan Hovold 		if (IS_ERR(qphy->rx2))
225669c90cb5SJohan Hovold 			return PTR_ERR(qphy->rx2);
225794a407ccSDmitry Baryshkov 
22584be26f69SJohan Hovold 		qphy->pcs_misc = devm_of_iomap(dev, np, 5, NULL);
225994a407ccSDmitry Baryshkov 	} else {
22604be26f69SJohan Hovold 		qphy->pcs_misc = devm_of_iomap(dev, np, 3, NULL);
226194a407ccSDmitry Baryshkov 	}
226294a407ccSDmitry Baryshkov 
22634be26f69SJohan Hovold 	if (IS_ERR(qphy->pcs_misc) &&
2264af664324SDmitry Baryshkov 	    of_device_is_compatible(dev->of_node, "qcom,ipq6018-qmp-pcie-phy"))
2265af664324SDmitry Baryshkov 		qphy->pcs_misc = qphy->pcs + 0x400;
2266af664324SDmitry Baryshkov 
22674be26f69SJohan Hovold 	if (IS_ERR(qphy->pcs_misc)) {
22682566ad8eSDmitry Baryshkov 		if (cfg->tables.pcs_misc ||
226911bf53a3SDmitry Baryshkov 		    (cfg->tables_rc && cfg->tables_rc->pcs_misc) ||
227011bf53a3SDmitry Baryshkov 		    (cfg->tables_ep && cfg->tables_ep->pcs_misc))
22714be26f69SJohan Hovold 			return PTR_ERR(qphy->pcs_misc);
2272ecd5507eSJohan Hovold 	}
227394a407ccSDmitry Baryshkov 
2274f8432544SJohan Hovold 	qphy->pipe_clk = devm_get_clk_from_child(dev, np, NULL);
227594a407ccSDmitry Baryshkov 	if (IS_ERR(qphy->pipe_clk)) {
22768f662cd9SJohan Hovold 		return dev_err_probe(dev, PTR_ERR(qphy->pipe_clk),
22778f662cd9SJohan Hovold 				     "failed to get lane%d pipe clock\n", id);
227894a407ccSDmitry Baryshkov 	}
227994a407ccSDmitry Baryshkov 
228027878615SJohan Hovold 	generic_phy = devm_phy_create(dev, np, &qmp_pcie_ops);
228194a407ccSDmitry Baryshkov 	if (IS_ERR(generic_phy)) {
228294a407ccSDmitry Baryshkov 		ret = PTR_ERR(generic_phy);
228394a407ccSDmitry Baryshkov 		dev_err(dev, "failed to create qphy %d\n", ret);
228494a407ccSDmitry Baryshkov 		return ret;
228594a407ccSDmitry Baryshkov 	}
228694a407ccSDmitry Baryshkov 
228794a407ccSDmitry Baryshkov 	qphy->phy = generic_phy;
228894a407ccSDmitry Baryshkov 	qphy->qmp = qmp;
228994a407ccSDmitry Baryshkov 	qmp->phys[id] = qphy;
229094a407ccSDmitry Baryshkov 	phy_set_drvdata(generic_phy, qphy);
229194a407ccSDmitry Baryshkov 
229294a407ccSDmitry Baryshkov 	return 0;
229394a407ccSDmitry Baryshkov }
229494a407ccSDmitry Baryshkov 
229527878615SJohan Hovold static const struct of_device_id qmp_pcie_of_match_table[] = {
229694a407ccSDmitry Baryshkov 	{
229794a407ccSDmitry Baryshkov 		.compatible = "qcom,msm8998-qmp-pcie-phy",
229894a407ccSDmitry Baryshkov 		.data = &msm8998_pciephy_cfg,
229994a407ccSDmitry Baryshkov 	}, {
230094a407ccSDmitry Baryshkov 		.compatible = "qcom,ipq8074-qmp-pcie-phy",
230194a407ccSDmitry Baryshkov 		.data = &ipq8074_pciephy_cfg,
230294a407ccSDmitry Baryshkov 	}, {
2303334fad18SRobert Marko 		.compatible = "qcom,ipq8074-qmp-gen3-pcie-phy",
2304334fad18SRobert Marko 		.data = &ipq8074_pciephy_gen3_cfg,
2305334fad18SRobert Marko 	}, {
230694a407ccSDmitry Baryshkov 		.compatible = "qcom,ipq6018-qmp-pcie-phy",
230794a407ccSDmitry Baryshkov 		.data = &ipq6018_pciephy_cfg,
230894a407ccSDmitry Baryshkov 	}, {
230994a407ccSDmitry Baryshkov 		.compatible = "qcom,sc8180x-qmp-pcie-phy",
231094a407ccSDmitry Baryshkov 		.data = &sc8180x_pciephy_cfg,
231194a407ccSDmitry Baryshkov 	}, {
231294a407ccSDmitry Baryshkov 		.compatible = "qcom,sdm845-qhp-pcie-phy",
231394a407ccSDmitry Baryshkov 		.data = &sdm845_qhp_pciephy_cfg,
231494a407ccSDmitry Baryshkov 	}, {
231594a407ccSDmitry Baryshkov 		.compatible = "qcom,sdm845-qmp-pcie-phy",
231694a407ccSDmitry Baryshkov 		.data = &sdm845_qmp_pciephy_cfg,
231794a407ccSDmitry Baryshkov 	}, {
231894a407ccSDmitry Baryshkov 		.compatible = "qcom,sm8250-qmp-gen3x1-pcie-phy",
231994a407ccSDmitry Baryshkov 		.data = &sm8250_qmp_gen3x1_pciephy_cfg,
232094a407ccSDmitry Baryshkov 	}, {
232194a407ccSDmitry Baryshkov 		.compatible = "qcom,sm8250-qmp-gen3x2-pcie-phy",
232294a407ccSDmitry Baryshkov 		.data = &sm8250_qmp_gen3x2_pciephy_cfg,
232394a407ccSDmitry Baryshkov 	}, {
232494a407ccSDmitry Baryshkov 		.compatible = "qcom,sm8250-qmp-modem-pcie-phy",
232594a407ccSDmitry Baryshkov 		.data = &sm8250_qmp_gen3x2_pciephy_cfg,
232694a407ccSDmitry Baryshkov 	}, {
232794a407ccSDmitry Baryshkov 		.compatible = "qcom,sdx55-qmp-pcie-phy",
232894a407ccSDmitry Baryshkov 		.data = &sdx55_qmp_pciephy_cfg,
232994a407ccSDmitry Baryshkov 	}, {
233094a407ccSDmitry Baryshkov 		.compatible = "qcom,sm8450-qmp-gen3x1-pcie-phy",
233194a407ccSDmitry Baryshkov 		.data = &sm8450_qmp_gen3x1_pciephy_cfg,
233294a407ccSDmitry Baryshkov 	}, {
233394a407ccSDmitry Baryshkov 		.compatible = "qcom,sm8450-qmp-gen4x2-pcie-phy",
233494a407ccSDmitry Baryshkov 		.data = &sm8450_qmp_gen4x2_pciephy_cfg,
233594a407ccSDmitry Baryshkov 	},
233694a407ccSDmitry Baryshkov 	{ },
233794a407ccSDmitry Baryshkov };
233827878615SJohan Hovold MODULE_DEVICE_TABLE(of, qmp_pcie_of_match_table);
233994a407ccSDmitry Baryshkov 
234027878615SJohan Hovold static int qmp_pcie_probe(struct platform_device *pdev)
234194a407ccSDmitry Baryshkov {
234294a407ccSDmitry Baryshkov 	struct qcom_qmp *qmp;
234394a407ccSDmitry Baryshkov 	struct device *dev = &pdev->dev;
234494a407ccSDmitry Baryshkov 	struct device_node *child;
234594a407ccSDmitry Baryshkov 	struct phy_provider *phy_provider;
234694a407ccSDmitry Baryshkov 	void __iomem *serdes;
234794a407ccSDmitry Baryshkov 	const struct qmp_phy_cfg *cfg = NULL;
23481239fd71SDmitry Baryshkov 	int num, id;
234994a407ccSDmitry Baryshkov 	int ret;
235094a407ccSDmitry Baryshkov 
235194a407ccSDmitry Baryshkov 	qmp = devm_kzalloc(dev, sizeof(*qmp), GFP_KERNEL);
235294a407ccSDmitry Baryshkov 	if (!qmp)
235394a407ccSDmitry Baryshkov 		return -ENOMEM;
235494a407ccSDmitry Baryshkov 
235594a407ccSDmitry Baryshkov 	qmp->dev = dev;
235694a407ccSDmitry Baryshkov 	dev_set_drvdata(dev, qmp);
235794a407ccSDmitry Baryshkov 
235894a407ccSDmitry Baryshkov 	cfg = of_device_get_match_data(dev);
2359b35a5311SDmitry Baryshkov 	if (!cfg)
236094a407ccSDmitry Baryshkov 		return -EINVAL;
236194a407ccSDmitry Baryshkov 
2362da07a06bSDmitry Baryshkov 	serdes = devm_platform_ioremap_resource(pdev, 0);
236394a407ccSDmitry Baryshkov 	if (IS_ERR(serdes))
236494a407ccSDmitry Baryshkov 		return PTR_ERR(serdes);
236594a407ccSDmitry Baryshkov 
236627878615SJohan Hovold 	ret = qmp_pcie_clk_init(dev, cfg);
236794a407ccSDmitry Baryshkov 	if (ret)
236894a407ccSDmitry Baryshkov 		return ret;
236994a407ccSDmitry Baryshkov 
237027878615SJohan Hovold 	ret = qmp_pcie_reset_init(dev, cfg);
237194a407ccSDmitry Baryshkov 	if (ret)
237294a407ccSDmitry Baryshkov 		return ret;
237394a407ccSDmitry Baryshkov 
237427878615SJohan Hovold 	ret = qmp_pcie_vreg_init(dev, cfg);
2375a548b6b4SYuan Can 	if (ret)
237628d74fc3SJohan Hovold 		return ret;
237794a407ccSDmitry Baryshkov 
237894a407ccSDmitry Baryshkov 	num = of_get_available_child_count(dev->of_node);
237994a407ccSDmitry Baryshkov 	/* do we have a rogue child node ? */
23801239fd71SDmitry Baryshkov 	if (num > 1)
238194a407ccSDmitry Baryshkov 		return -EINVAL;
238294a407ccSDmitry Baryshkov 
238394a407ccSDmitry Baryshkov 	qmp->phys = devm_kcalloc(dev, num, sizeof(*qmp->phys), GFP_KERNEL);
238494a407ccSDmitry Baryshkov 	if (!qmp->phys)
238594a407ccSDmitry Baryshkov 		return -ENOMEM;
238694a407ccSDmitry Baryshkov 
238794a407ccSDmitry Baryshkov 	id = 0;
238894a407ccSDmitry Baryshkov 	for_each_available_child_of_node(dev->of_node, child) {
238994a407ccSDmitry Baryshkov 		/* Create per-lane phy */
239027878615SJohan Hovold 		ret = qmp_pcie_create(dev, child, id, serdes, cfg);
239194a407ccSDmitry Baryshkov 		if (ret) {
239294a407ccSDmitry Baryshkov 			dev_err(dev, "failed to create lane%d phy, %d\n",
239394a407ccSDmitry Baryshkov 				id, ret);
239494a407ccSDmitry Baryshkov 			goto err_node_put;
239594a407ccSDmitry Baryshkov 		}
239694a407ccSDmitry Baryshkov 
239794a407ccSDmitry Baryshkov 		/*
239894a407ccSDmitry Baryshkov 		 * Register the pipe clock provided by phy.
239994a407ccSDmitry Baryshkov 		 * See function description to see details of this pipe clock.
240094a407ccSDmitry Baryshkov 		 */
240194a407ccSDmitry Baryshkov 		ret = phy_pipe_clk_register(qmp, child);
240294a407ccSDmitry Baryshkov 		if (ret) {
240394a407ccSDmitry Baryshkov 			dev_err(qmp->dev,
240494a407ccSDmitry Baryshkov 				"failed to register pipe clock source\n");
240594a407ccSDmitry Baryshkov 			goto err_node_put;
240694a407ccSDmitry Baryshkov 		}
2407da07a06bSDmitry Baryshkov 
240894a407ccSDmitry Baryshkov 		id++;
240994a407ccSDmitry Baryshkov 	}
241094a407ccSDmitry Baryshkov 
241194a407ccSDmitry Baryshkov 	phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
241294a407ccSDmitry Baryshkov 
241394a407ccSDmitry Baryshkov 	return PTR_ERR_OR_ZERO(phy_provider);
241494a407ccSDmitry Baryshkov 
241594a407ccSDmitry Baryshkov err_node_put:
241694a407ccSDmitry Baryshkov 	of_node_put(child);
241794a407ccSDmitry Baryshkov 	return ret;
241894a407ccSDmitry Baryshkov }
241994a407ccSDmitry Baryshkov 
242027878615SJohan Hovold static struct platform_driver qmp_pcie_driver = {
242127878615SJohan Hovold 	.probe		= qmp_pcie_probe,
242294a407ccSDmitry Baryshkov 	.driver = {
2423b35a5311SDmitry Baryshkov 		.name	= "qcom-qmp-pcie-phy",
242427878615SJohan Hovold 		.of_match_table = qmp_pcie_of_match_table,
242594a407ccSDmitry Baryshkov 	},
242694a407ccSDmitry Baryshkov };
242794a407ccSDmitry Baryshkov 
242827878615SJohan Hovold module_platform_driver(qmp_pcie_driver);
242994a407ccSDmitry Baryshkov 
243094a407ccSDmitry Baryshkov MODULE_AUTHOR("Vivek Gautam <vivek.gautam@codeaurora.org>");
2431b35a5311SDmitry Baryshkov MODULE_DESCRIPTION("Qualcomm QMP PCIe PHY driver");
243294a407ccSDmitry Baryshkov MODULE_LICENSE("GPL v2");
2433