xref: /openbmc/linux/drivers/phy/qualcomm/phy-qcom-qmp-pcie.c (revision 2fdedef3ea8e8a1a68a1da6eee1537074b308f63)
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 pwrdn_ctrl;
135994a407ccSDmitry Baryshkov 	/* bit offset of PHYSTATUS in QPHY_PCS_STATUS register */
136094a407ccSDmitry Baryshkov 	unsigned int phy_status;
136194a407ccSDmitry Baryshkov 
136251bd3306SJohan Hovold 	bool skip_start_delay;
136394a407ccSDmitry Baryshkov 
13642ec9bc8dSRobert Marko 	/* QMP PHY pipe clock interface rate */
13652ec9bc8dSRobert Marko 	unsigned long pipe_clock_rate;
136694a407ccSDmitry Baryshkov };
136794a407ccSDmitry Baryshkov 
1368*2fdedef3SJohan Hovold struct qmp_pcie {
136994a407ccSDmitry Baryshkov 	struct device *dev;
137094a407ccSDmitry Baryshkov 
1371*2fdedef3SJohan Hovold 	const struct qmp_phy_cfg *cfg;
1372*2fdedef3SJohan Hovold 
1373*2fdedef3SJohan Hovold 	void __iomem *serdes;
1374*2fdedef3SJohan Hovold 	void __iomem *pcs;
1375*2fdedef3SJohan Hovold 	void __iomem *pcs_misc;
1376*2fdedef3SJohan Hovold 	void __iomem *tx;
1377*2fdedef3SJohan Hovold 	void __iomem *rx;
1378*2fdedef3SJohan Hovold 	void __iomem *tx2;
1379*2fdedef3SJohan Hovold 	void __iomem *rx2;
1380*2fdedef3SJohan Hovold 
1381*2fdedef3SJohan Hovold 	struct clk *pipe_clk;
138294a407ccSDmitry Baryshkov 	struct clk_bulk_data *clks;
1383189ac6b8SDmitry Baryshkov 	struct reset_control_bulk_data *resets;
138494a407ccSDmitry Baryshkov 	struct regulator_bulk_data *vregs;
138594a407ccSDmitry Baryshkov 
1386*2fdedef3SJohan Hovold 	struct phy *phy;
1387*2fdedef3SJohan Hovold 	int mode;
138894a407ccSDmitry Baryshkov };
138994a407ccSDmitry Baryshkov 
139094a407ccSDmitry Baryshkov static inline void qphy_setbits(void __iomem *base, u32 offset, u32 val)
139194a407ccSDmitry Baryshkov {
139294a407ccSDmitry Baryshkov 	u32 reg;
139394a407ccSDmitry Baryshkov 
139494a407ccSDmitry Baryshkov 	reg = readl(base + offset);
139594a407ccSDmitry Baryshkov 	reg |= val;
139694a407ccSDmitry Baryshkov 	writel(reg, base + offset);
139794a407ccSDmitry Baryshkov 
139894a407ccSDmitry Baryshkov 	/* ensure that above write is through */
139994a407ccSDmitry Baryshkov 	readl(base + offset);
140094a407ccSDmitry Baryshkov }
140194a407ccSDmitry Baryshkov 
140294a407ccSDmitry Baryshkov static inline void qphy_clrbits(void __iomem *base, u32 offset, u32 val)
140394a407ccSDmitry Baryshkov {
140494a407ccSDmitry Baryshkov 	u32 reg;
140594a407ccSDmitry Baryshkov 
140694a407ccSDmitry Baryshkov 	reg = readl(base + offset);
140794a407ccSDmitry Baryshkov 	reg &= ~val;
140894a407ccSDmitry Baryshkov 	writel(reg, base + offset);
140994a407ccSDmitry Baryshkov 
141094a407ccSDmitry Baryshkov 	/* ensure that above write is through */
141194a407ccSDmitry Baryshkov 	readl(base + offset);
141294a407ccSDmitry Baryshkov }
141394a407ccSDmitry Baryshkov 
141494a407ccSDmitry Baryshkov /* list of clocks required by phy */
14155b76f5ecSJohan Hovold static const char * const ipq8074_pciephy_clk_l[] = {
14165b76f5ecSJohan Hovold 	"aux", "cfg_ahb",
14175b76f5ecSJohan Hovold };
14185b76f5ecSJohan Hovold 
141994a407ccSDmitry Baryshkov static const char * const msm8996_phy_clk_l[] = {
142094a407ccSDmitry Baryshkov 	"aux", "cfg_ahb", "ref",
142194a407ccSDmitry Baryshkov };
142294a407ccSDmitry Baryshkov 
142394a407ccSDmitry Baryshkov 
142494a407ccSDmitry Baryshkov static const char * const sdm845_pciephy_clk_l[] = {
142594a407ccSDmitry Baryshkov 	"aux", "cfg_ahb", "ref", "refgen",
142694a407ccSDmitry Baryshkov };
142794a407ccSDmitry Baryshkov 
142894a407ccSDmitry Baryshkov /* list of regulators */
142994a407ccSDmitry Baryshkov static const char * const qmp_phy_vreg_l[] = {
143094a407ccSDmitry Baryshkov 	"vdda-phy", "vdda-pll",
143194a407ccSDmitry Baryshkov };
143294a407ccSDmitry Baryshkov 
143394a407ccSDmitry Baryshkov /* list of resets */
143494a407ccSDmitry Baryshkov static const char * const ipq8074_pciephy_reset_l[] = {
143594a407ccSDmitry Baryshkov 	"phy", "common",
143694a407ccSDmitry Baryshkov };
143794a407ccSDmitry Baryshkov 
1438b35a5311SDmitry Baryshkov static const char * const sdm845_pciephy_reset_l[] = {
1439b35a5311SDmitry Baryshkov 	"phy",
1440b35a5311SDmitry Baryshkov };
1441b35a5311SDmitry Baryshkov 
144294a407ccSDmitry Baryshkov static const struct qmp_phy_cfg ipq8074_pciephy_cfg = {
1443f02543faSJohan Hovold 	.lanes			= 1,
144494a407ccSDmitry Baryshkov 
14452566ad8eSDmitry Baryshkov 	.tables = {
14462566ad8eSDmitry Baryshkov 		.serdes		= ipq8074_pcie_serdes_tbl,
14472566ad8eSDmitry Baryshkov 		.serdes_num	= ARRAY_SIZE(ipq8074_pcie_serdes_tbl),
14482566ad8eSDmitry Baryshkov 		.tx		= ipq8074_pcie_tx_tbl,
14492566ad8eSDmitry Baryshkov 		.tx_num		= ARRAY_SIZE(ipq8074_pcie_tx_tbl),
14502566ad8eSDmitry Baryshkov 		.rx		= ipq8074_pcie_rx_tbl,
14512566ad8eSDmitry Baryshkov 		.rx_num		= ARRAY_SIZE(ipq8074_pcie_rx_tbl),
14522566ad8eSDmitry Baryshkov 		.pcs		= ipq8074_pcie_pcs_tbl,
14532566ad8eSDmitry Baryshkov 		.pcs_num	= ARRAY_SIZE(ipq8074_pcie_pcs_tbl),
14542566ad8eSDmitry Baryshkov 	},
145594a407ccSDmitry Baryshkov 	.clk_list		= ipq8074_pciephy_clk_l,
145694a407ccSDmitry Baryshkov 	.num_clks		= ARRAY_SIZE(ipq8074_pciephy_clk_l),
145794a407ccSDmitry Baryshkov 	.reset_list		= ipq8074_pciephy_reset_l,
145894a407ccSDmitry Baryshkov 	.num_resets		= ARRAY_SIZE(ipq8074_pciephy_reset_l),
145994a407ccSDmitry Baryshkov 	.vreg_list		= NULL,
146094a407ccSDmitry Baryshkov 	.num_vregs		= 0,
146194a407ccSDmitry Baryshkov 	.regs			= pciephy_regs_layout,
146294a407ccSDmitry Baryshkov 
146394a407ccSDmitry Baryshkov 	.pwrdn_ctrl		= SW_PWRDN | REFCLK_DRV_DSBL,
146494a407ccSDmitry Baryshkov 	.phy_status		= PHYSTATUS,
146594a407ccSDmitry Baryshkov };
146694a407ccSDmitry Baryshkov 
1467334fad18SRobert Marko static const struct qmp_phy_cfg ipq8074_pciephy_gen3_cfg = {
1468f02543faSJohan Hovold 	.lanes			= 1,
1469334fad18SRobert Marko 
14702566ad8eSDmitry Baryshkov 	.tables = {
14712566ad8eSDmitry Baryshkov 		.serdes		= ipq8074_pcie_gen3_serdes_tbl,
14722566ad8eSDmitry Baryshkov 		.serdes_num	= ARRAY_SIZE(ipq8074_pcie_gen3_serdes_tbl),
14732566ad8eSDmitry Baryshkov 		.tx		= ipq8074_pcie_gen3_tx_tbl,
14742566ad8eSDmitry Baryshkov 		.tx_num		= ARRAY_SIZE(ipq8074_pcie_gen3_tx_tbl),
14752566ad8eSDmitry Baryshkov 		.rx		= ipq8074_pcie_gen3_rx_tbl,
14762566ad8eSDmitry Baryshkov 		.rx_num		= ARRAY_SIZE(ipq8074_pcie_gen3_rx_tbl),
14772566ad8eSDmitry Baryshkov 		.pcs		= ipq8074_pcie_gen3_pcs_tbl,
14782566ad8eSDmitry Baryshkov 		.pcs_num	= ARRAY_SIZE(ipq8074_pcie_gen3_pcs_tbl),
14792566ad8eSDmitry Baryshkov 	},
1480334fad18SRobert Marko 	.clk_list		= ipq8074_pciephy_clk_l,
1481334fad18SRobert Marko 	.num_clks		= ARRAY_SIZE(ipq8074_pciephy_clk_l),
1482334fad18SRobert Marko 	.reset_list		= ipq8074_pciephy_reset_l,
1483334fad18SRobert Marko 	.num_resets		= ARRAY_SIZE(ipq8074_pciephy_reset_l),
1484334fad18SRobert Marko 	.vreg_list		= NULL,
1485334fad18SRobert Marko 	.num_vregs		= 0,
1486334fad18SRobert Marko 	.regs			= ipq_pciephy_gen3_regs_layout,
1487334fad18SRobert Marko 
1488334fad18SRobert Marko 	.pwrdn_ctrl		= SW_PWRDN | REFCLK_DRV_DSBL,
148994b7288eSJohan Hovold 	.phy_status		= PHYSTATUS,
1490334fad18SRobert Marko 
1491334fad18SRobert Marko 	.pipe_clock_rate	= 250000000,
1492334fad18SRobert Marko };
1493334fad18SRobert Marko 
149494a407ccSDmitry Baryshkov static const struct qmp_phy_cfg ipq6018_pciephy_cfg = {
1495f02543faSJohan Hovold 	.lanes			= 1,
149694a407ccSDmitry Baryshkov 
14972566ad8eSDmitry Baryshkov 	.tables = {
14982566ad8eSDmitry Baryshkov 		.serdes		= ipq6018_pcie_serdes_tbl,
14992566ad8eSDmitry Baryshkov 		.serdes_num	= ARRAY_SIZE(ipq6018_pcie_serdes_tbl),
15002566ad8eSDmitry Baryshkov 		.tx		= ipq6018_pcie_tx_tbl,
15012566ad8eSDmitry Baryshkov 		.tx_num		= ARRAY_SIZE(ipq6018_pcie_tx_tbl),
15022566ad8eSDmitry Baryshkov 		.rx		= ipq6018_pcie_rx_tbl,
15032566ad8eSDmitry Baryshkov 		.rx_num		= ARRAY_SIZE(ipq6018_pcie_rx_tbl),
15042566ad8eSDmitry Baryshkov 		.pcs		= ipq6018_pcie_pcs_tbl,
15052566ad8eSDmitry Baryshkov 		.pcs_num	= ARRAY_SIZE(ipq6018_pcie_pcs_tbl),
15062566ad8eSDmitry Baryshkov 		.pcs_misc	= ipq6018_pcie_pcs_misc_tbl,
15072566ad8eSDmitry Baryshkov 		.pcs_misc_num	= ARRAY_SIZE(ipq6018_pcie_pcs_misc_tbl),
15082566ad8eSDmitry Baryshkov 	},
150994a407ccSDmitry Baryshkov 	.clk_list		= ipq8074_pciephy_clk_l,
151094a407ccSDmitry Baryshkov 	.num_clks		= ARRAY_SIZE(ipq8074_pciephy_clk_l),
151194a407ccSDmitry Baryshkov 	.reset_list		= ipq8074_pciephy_reset_l,
151294a407ccSDmitry Baryshkov 	.num_resets		= ARRAY_SIZE(ipq8074_pciephy_reset_l),
151394a407ccSDmitry Baryshkov 	.vreg_list		= NULL,
151494a407ccSDmitry Baryshkov 	.num_vregs		= 0,
151594a407ccSDmitry Baryshkov 	.regs			= ipq_pciephy_gen3_regs_layout,
151694a407ccSDmitry Baryshkov 
151794a407ccSDmitry Baryshkov 	.pwrdn_ctrl		= SW_PWRDN | REFCLK_DRV_DSBL,
151830518b19SJohan Hovold 	.phy_status		= PHYSTATUS,
151994a407ccSDmitry Baryshkov };
152094a407ccSDmitry Baryshkov 
152194a407ccSDmitry Baryshkov static const struct qmp_phy_cfg sdm845_qmp_pciephy_cfg = {
1522f02543faSJohan Hovold 	.lanes			= 1,
152394a407ccSDmitry Baryshkov 
15242566ad8eSDmitry Baryshkov 	.tables = {
15252566ad8eSDmitry Baryshkov 		.serdes		= sdm845_qmp_pcie_serdes_tbl,
15262566ad8eSDmitry Baryshkov 		.serdes_num	= ARRAY_SIZE(sdm845_qmp_pcie_serdes_tbl),
15272566ad8eSDmitry Baryshkov 		.tx		= sdm845_qmp_pcie_tx_tbl,
15282566ad8eSDmitry Baryshkov 		.tx_num		= ARRAY_SIZE(sdm845_qmp_pcie_tx_tbl),
15292566ad8eSDmitry Baryshkov 		.rx		= sdm845_qmp_pcie_rx_tbl,
15302566ad8eSDmitry Baryshkov 		.rx_num		= ARRAY_SIZE(sdm845_qmp_pcie_rx_tbl),
15312566ad8eSDmitry Baryshkov 		.pcs		= sdm845_qmp_pcie_pcs_tbl,
15322566ad8eSDmitry Baryshkov 		.pcs_num	= ARRAY_SIZE(sdm845_qmp_pcie_pcs_tbl),
15332566ad8eSDmitry Baryshkov 		.pcs_misc	= sdm845_qmp_pcie_pcs_misc_tbl,
15342566ad8eSDmitry Baryshkov 		.pcs_misc_num	= ARRAY_SIZE(sdm845_qmp_pcie_pcs_misc_tbl),
15352566ad8eSDmitry Baryshkov 	},
153694a407ccSDmitry Baryshkov 	.clk_list		= sdm845_pciephy_clk_l,
153794a407ccSDmitry Baryshkov 	.num_clks		= ARRAY_SIZE(sdm845_pciephy_clk_l),
153894a407ccSDmitry Baryshkov 	.reset_list		= sdm845_pciephy_reset_l,
153994a407ccSDmitry Baryshkov 	.num_resets		= ARRAY_SIZE(sdm845_pciephy_reset_l),
154094a407ccSDmitry Baryshkov 	.vreg_list		= qmp_phy_vreg_l,
154194a407ccSDmitry Baryshkov 	.num_vregs		= ARRAY_SIZE(qmp_phy_vreg_l),
154294a407ccSDmitry Baryshkov 	.regs			= sdm845_qmp_pciephy_regs_layout,
154394a407ccSDmitry Baryshkov 
154494a407ccSDmitry Baryshkov 	.pwrdn_ctrl		= SW_PWRDN | REFCLK_DRV_DSBL,
154594a407ccSDmitry Baryshkov 	.phy_status		= PHYSTATUS,
154694a407ccSDmitry Baryshkov };
154794a407ccSDmitry Baryshkov 
154894a407ccSDmitry Baryshkov static const struct qmp_phy_cfg sdm845_qhp_pciephy_cfg = {
1549f02543faSJohan Hovold 	.lanes			= 1,
155094a407ccSDmitry Baryshkov 
15512566ad8eSDmitry Baryshkov 	.tables = {
15522566ad8eSDmitry Baryshkov 		.serdes		= sdm845_qhp_pcie_serdes_tbl,
15532566ad8eSDmitry Baryshkov 		.serdes_num	= ARRAY_SIZE(sdm845_qhp_pcie_serdes_tbl),
15542566ad8eSDmitry Baryshkov 		.tx		= sdm845_qhp_pcie_tx_tbl,
15552566ad8eSDmitry Baryshkov 		.tx_num		= ARRAY_SIZE(sdm845_qhp_pcie_tx_tbl),
15562566ad8eSDmitry Baryshkov 		.rx		= sdm845_qhp_pcie_rx_tbl,
15572566ad8eSDmitry Baryshkov 		.rx_num		= ARRAY_SIZE(sdm845_qhp_pcie_rx_tbl),
15582566ad8eSDmitry Baryshkov 		.pcs		= sdm845_qhp_pcie_pcs_tbl,
15592566ad8eSDmitry Baryshkov 		.pcs_num	= ARRAY_SIZE(sdm845_qhp_pcie_pcs_tbl),
15602566ad8eSDmitry Baryshkov 	},
156194a407ccSDmitry Baryshkov 	.clk_list		= sdm845_pciephy_clk_l,
156294a407ccSDmitry Baryshkov 	.num_clks		= ARRAY_SIZE(sdm845_pciephy_clk_l),
156394a407ccSDmitry Baryshkov 	.reset_list		= sdm845_pciephy_reset_l,
156494a407ccSDmitry Baryshkov 	.num_resets		= ARRAY_SIZE(sdm845_pciephy_reset_l),
156594a407ccSDmitry Baryshkov 	.vreg_list		= qmp_phy_vreg_l,
156694a407ccSDmitry Baryshkov 	.num_vregs		= ARRAY_SIZE(qmp_phy_vreg_l),
156794a407ccSDmitry Baryshkov 	.regs			= sdm845_qhp_pciephy_regs_layout,
156894a407ccSDmitry Baryshkov 
156994a407ccSDmitry Baryshkov 	.pwrdn_ctrl		= SW_PWRDN | REFCLK_DRV_DSBL,
157094a407ccSDmitry Baryshkov 	.phy_status		= PHYSTATUS,
157194a407ccSDmitry Baryshkov };
157294a407ccSDmitry Baryshkov 
157394a407ccSDmitry Baryshkov static const struct qmp_phy_cfg sm8250_qmp_gen3x1_pciephy_cfg = {
1574f02543faSJohan Hovold 	.lanes			= 1,
157594a407ccSDmitry Baryshkov 
15762566ad8eSDmitry Baryshkov 	.tables = {
15772566ad8eSDmitry Baryshkov 		.serdes		= sm8250_qmp_pcie_serdes_tbl,
15782566ad8eSDmitry Baryshkov 		.serdes_num	= ARRAY_SIZE(sm8250_qmp_pcie_serdes_tbl),
15792566ad8eSDmitry Baryshkov 		.tx		= sm8250_qmp_pcie_tx_tbl,
15802566ad8eSDmitry Baryshkov 		.tx_num		= ARRAY_SIZE(sm8250_qmp_pcie_tx_tbl),
15812566ad8eSDmitry Baryshkov 		.rx		= sm8250_qmp_pcie_rx_tbl,
15822566ad8eSDmitry Baryshkov 		.rx_num		= ARRAY_SIZE(sm8250_qmp_pcie_rx_tbl),
15832566ad8eSDmitry Baryshkov 		.pcs		= sm8250_qmp_pcie_pcs_tbl,
15842566ad8eSDmitry Baryshkov 		.pcs_num	= ARRAY_SIZE(sm8250_qmp_pcie_pcs_tbl),
15852566ad8eSDmitry Baryshkov 		.pcs_misc	= sm8250_qmp_pcie_pcs_misc_tbl,
15862566ad8eSDmitry Baryshkov 		.pcs_misc_num	= ARRAY_SIZE(sm8250_qmp_pcie_pcs_misc_tbl),
15872566ad8eSDmitry Baryshkov 	},
15882566ad8eSDmitry Baryshkov 	.tables_rc = &(const struct qmp_phy_cfg_tables) {
15892566ad8eSDmitry Baryshkov 		.serdes		= sm8250_qmp_gen3x1_pcie_serdes_tbl,
15902566ad8eSDmitry Baryshkov 		.serdes_num	= ARRAY_SIZE(sm8250_qmp_gen3x1_pcie_serdes_tbl),
15912566ad8eSDmitry Baryshkov 		.rx		= sm8250_qmp_gen3x1_pcie_rx_tbl,
15922566ad8eSDmitry Baryshkov 		.rx_num		= ARRAY_SIZE(sm8250_qmp_gen3x1_pcie_rx_tbl),
15932566ad8eSDmitry Baryshkov 		.pcs		= sm8250_qmp_gen3x1_pcie_pcs_tbl,
15942566ad8eSDmitry Baryshkov 		.pcs_num	= ARRAY_SIZE(sm8250_qmp_gen3x1_pcie_pcs_tbl),
15952566ad8eSDmitry Baryshkov 		.pcs_misc	= sm8250_qmp_gen3x1_pcie_pcs_misc_tbl,
15962566ad8eSDmitry Baryshkov 		.pcs_misc_num	= ARRAY_SIZE(sm8250_qmp_gen3x1_pcie_pcs_misc_tbl),
15972566ad8eSDmitry Baryshkov 	},
159894a407ccSDmitry Baryshkov 	.clk_list		= sdm845_pciephy_clk_l,
159994a407ccSDmitry Baryshkov 	.num_clks		= ARRAY_SIZE(sdm845_pciephy_clk_l),
160094a407ccSDmitry Baryshkov 	.reset_list		= sdm845_pciephy_reset_l,
160194a407ccSDmitry Baryshkov 	.num_resets		= ARRAY_SIZE(sdm845_pciephy_reset_l),
160294a407ccSDmitry Baryshkov 	.vreg_list		= qmp_phy_vreg_l,
160394a407ccSDmitry Baryshkov 	.num_vregs		= ARRAY_SIZE(qmp_phy_vreg_l),
160494a407ccSDmitry Baryshkov 	.regs			= sm8250_pcie_regs_layout,
160594a407ccSDmitry Baryshkov 
160694a407ccSDmitry Baryshkov 	.pwrdn_ctrl		= SW_PWRDN | REFCLK_DRV_DSBL,
160794a407ccSDmitry Baryshkov 	.phy_status		= PHYSTATUS,
160894a407ccSDmitry Baryshkov };
160994a407ccSDmitry Baryshkov 
161094a407ccSDmitry Baryshkov static const struct qmp_phy_cfg sm8250_qmp_gen3x2_pciephy_cfg = {
1611f02543faSJohan Hovold 	.lanes			= 2,
161294a407ccSDmitry Baryshkov 
16132566ad8eSDmitry Baryshkov 	.tables = {
16142566ad8eSDmitry Baryshkov 		.serdes		= sm8250_qmp_pcie_serdes_tbl,
16152566ad8eSDmitry Baryshkov 		.serdes_num	= ARRAY_SIZE(sm8250_qmp_pcie_serdes_tbl),
16162566ad8eSDmitry Baryshkov 		.tx		= sm8250_qmp_pcie_tx_tbl,
16172566ad8eSDmitry Baryshkov 		.tx_num		= ARRAY_SIZE(sm8250_qmp_pcie_tx_tbl),
16182566ad8eSDmitry Baryshkov 		.rx		= sm8250_qmp_pcie_rx_tbl,
16192566ad8eSDmitry Baryshkov 		.rx_num		= ARRAY_SIZE(sm8250_qmp_pcie_rx_tbl),
16202566ad8eSDmitry Baryshkov 		.pcs		= sm8250_qmp_pcie_pcs_tbl,
16212566ad8eSDmitry Baryshkov 		.pcs_num	= ARRAY_SIZE(sm8250_qmp_pcie_pcs_tbl),
16222566ad8eSDmitry Baryshkov 		.pcs_misc	= sm8250_qmp_pcie_pcs_misc_tbl,
16232566ad8eSDmitry Baryshkov 		.pcs_misc_num	= ARRAY_SIZE(sm8250_qmp_pcie_pcs_misc_tbl),
16242566ad8eSDmitry Baryshkov 	},
16252566ad8eSDmitry Baryshkov 	.tables_rc = &(const struct qmp_phy_cfg_tables) {
16262566ad8eSDmitry Baryshkov 		.tx		= sm8250_qmp_gen3x2_pcie_tx_tbl,
16272566ad8eSDmitry Baryshkov 		.tx_num		= ARRAY_SIZE(sm8250_qmp_gen3x2_pcie_tx_tbl),
16282566ad8eSDmitry Baryshkov 		.rx		= sm8250_qmp_gen3x2_pcie_rx_tbl,
16292566ad8eSDmitry Baryshkov 		.rx_num		= ARRAY_SIZE(sm8250_qmp_gen3x2_pcie_rx_tbl),
16302566ad8eSDmitry Baryshkov 		.pcs		= sm8250_qmp_gen3x2_pcie_pcs_tbl,
16312566ad8eSDmitry Baryshkov 		.pcs_num	= ARRAY_SIZE(sm8250_qmp_gen3x2_pcie_pcs_tbl),
16322566ad8eSDmitry Baryshkov 		.pcs_misc	= sm8250_qmp_gen3x2_pcie_pcs_misc_tbl,
16332566ad8eSDmitry Baryshkov 		.pcs_misc_num	= ARRAY_SIZE(sm8250_qmp_gen3x2_pcie_pcs_misc_tbl),
16342566ad8eSDmitry Baryshkov 	},
163594a407ccSDmitry Baryshkov 	.clk_list		= sdm845_pciephy_clk_l,
163694a407ccSDmitry Baryshkov 	.num_clks		= ARRAY_SIZE(sdm845_pciephy_clk_l),
163794a407ccSDmitry Baryshkov 	.reset_list		= sdm845_pciephy_reset_l,
163894a407ccSDmitry Baryshkov 	.num_resets		= ARRAY_SIZE(sdm845_pciephy_reset_l),
163994a407ccSDmitry Baryshkov 	.vreg_list		= qmp_phy_vreg_l,
164094a407ccSDmitry Baryshkov 	.num_vregs		= ARRAY_SIZE(qmp_phy_vreg_l),
164194a407ccSDmitry Baryshkov 	.regs			= sm8250_pcie_regs_layout,
164294a407ccSDmitry Baryshkov 
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 msm8998_pciephy_cfg = {
1648f02543faSJohan Hovold 	.lanes			= 1,
164994a407ccSDmitry Baryshkov 
16502566ad8eSDmitry Baryshkov 	.tables = {
16512566ad8eSDmitry Baryshkov 		.serdes		= msm8998_pcie_serdes_tbl,
16522566ad8eSDmitry Baryshkov 		.serdes_num	= ARRAY_SIZE(msm8998_pcie_serdes_tbl),
16532566ad8eSDmitry Baryshkov 		.tx		= msm8998_pcie_tx_tbl,
16542566ad8eSDmitry Baryshkov 		.tx_num		= ARRAY_SIZE(msm8998_pcie_tx_tbl),
16552566ad8eSDmitry Baryshkov 		.rx		= msm8998_pcie_rx_tbl,
16562566ad8eSDmitry Baryshkov 		.rx_num		= ARRAY_SIZE(msm8998_pcie_rx_tbl),
16572566ad8eSDmitry Baryshkov 		.pcs		= msm8998_pcie_pcs_tbl,
16582566ad8eSDmitry Baryshkov 		.pcs_num	= ARRAY_SIZE(msm8998_pcie_pcs_tbl),
16592566ad8eSDmitry Baryshkov 	},
166094a407ccSDmitry Baryshkov 	.clk_list		= msm8996_phy_clk_l,
166194a407ccSDmitry Baryshkov 	.num_clks		= ARRAY_SIZE(msm8996_phy_clk_l),
166294a407ccSDmitry Baryshkov 	.reset_list		= ipq8074_pciephy_reset_l,
166394a407ccSDmitry Baryshkov 	.num_resets		= ARRAY_SIZE(ipq8074_pciephy_reset_l),
166494a407ccSDmitry Baryshkov 	.vreg_list		= qmp_phy_vreg_l,
166594a407ccSDmitry Baryshkov 	.num_vregs		= ARRAY_SIZE(qmp_phy_vreg_l),
166694a407ccSDmitry Baryshkov 	.regs			= pciephy_regs_layout,
166794a407ccSDmitry Baryshkov 
166894a407ccSDmitry Baryshkov 	.pwrdn_ctrl		= SW_PWRDN | REFCLK_DRV_DSBL,
166994a407ccSDmitry Baryshkov 	.phy_status		= PHYSTATUS,
167051bd3306SJohan Hovold 
167151bd3306SJohan Hovold 	.skip_start_delay	= true,
167294a407ccSDmitry Baryshkov };
167394a407ccSDmitry Baryshkov 
167494a407ccSDmitry Baryshkov static const struct qmp_phy_cfg sc8180x_pciephy_cfg = {
1675f02543faSJohan Hovold 	.lanes			= 1,
167694a407ccSDmitry Baryshkov 
16772566ad8eSDmitry Baryshkov 	.tables = {
16782566ad8eSDmitry Baryshkov 		.serdes		= sc8180x_qmp_pcie_serdes_tbl,
16792566ad8eSDmitry Baryshkov 		.serdes_num	= ARRAY_SIZE(sc8180x_qmp_pcie_serdes_tbl),
16802566ad8eSDmitry Baryshkov 		.tx		= sc8180x_qmp_pcie_tx_tbl,
16812566ad8eSDmitry Baryshkov 		.tx_num		= ARRAY_SIZE(sc8180x_qmp_pcie_tx_tbl),
16822566ad8eSDmitry Baryshkov 		.rx		= sc8180x_qmp_pcie_rx_tbl,
16832566ad8eSDmitry Baryshkov 		.rx_num		= ARRAY_SIZE(sc8180x_qmp_pcie_rx_tbl),
16842566ad8eSDmitry Baryshkov 		.pcs		= sc8180x_qmp_pcie_pcs_tbl,
16852566ad8eSDmitry Baryshkov 		.pcs_num	= ARRAY_SIZE(sc8180x_qmp_pcie_pcs_tbl),
16862566ad8eSDmitry Baryshkov 		.pcs_misc	= sc8180x_qmp_pcie_pcs_misc_tbl,
16872566ad8eSDmitry Baryshkov 		.pcs_misc_num	= ARRAY_SIZE(sc8180x_qmp_pcie_pcs_misc_tbl),
16882566ad8eSDmitry Baryshkov 	},
168994a407ccSDmitry Baryshkov 	.clk_list		= sdm845_pciephy_clk_l,
169094a407ccSDmitry Baryshkov 	.num_clks		= ARRAY_SIZE(sdm845_pciephy_clk_l),
169194a407ccSDmitry Baryshkov 	.reset_list		= sdm845_pciephy_reset_l,
169294a407ccSDmitry Baryshkov 	.num_resets		= ARRAY_SIZE(sdm845_pciephy_reset_l),
169394a407ccSDmitry Baryshkov 	.vreg_list		= qmp_phy_vreg_l,
169494a407ccSDmitry Baryshkov 	.num_vregs		= ARRAY_SIZE(qmp_phy_vreg_l),
169594a407ccSDmitry Baryshkov 	.regs			= sm8250_pcie_regs_layout,
169694a407ccSDmitry Baryshkov 
169794a407ccSDmitry Baryshkov 	.pwrdn_ctrl		= SW_PWRDN | REFCLK_DRV_DSBL,
16984a9eac5aSJohan Hovold 	.phy_status		= PHYSTATUS,
169994a407ccSDmitry Baryshkov };
170094a407ccSDmitry Baryshkov 
170194a407ccSDmitry Baryshkov static const struct qmp_phy_cfg sdx55_qmp_pciephy_cfg = {
1702f02543faSJohan Hovold 	.lanes			= 2,
170394a407ccSDmitry Baryshkov 
17042566ad8eSDmitry Baryshkov 	.tables = {
17052566ad8eSDmitry Baryshkov 		.serdes		= sdx55_qmp_pcie_serdes_tbl,
17062566ad8eSDmitry Baryshkov 		.serdes_num	= ARRAY_SIZE(sdx55_qmp_pcie_serdes_tbl),
17072566ad8eSDmitry Baryshkov 		.tx		= sdx55_qmp_pcie_tx_tbl,
17082566ad8eSDmitry Baryshkov 		.tx_num		= ARRAY_SIZE(sdx55_qmp_pcie_tx_tbl),
17092566ad8eSDmitry Baryshkov 		.rx		= sdx55_qmp_pcie_rx_tbl,
17102566ad8eSDmitry Baryshkov 		.rx_num		= ARRAY_SIZE(sdx55_qmp_pcie_rx_tbl),
17112566ad8eSDmitry Baryshkov 		.pcs		= sdx55_qmp_pcie_pcs_tbl,
17122566ad8eSDmitry Baryshkov 		.pcs_num	= ARRAY_SIZE(sdx55_qmp_pcie_pcs_tbl),
17132566ad8eSDmitry Baryshkov 		.pcs_misc	= sdx55_qmp_pcie_pcs_misc_tbl,
17142566ad8eSDmitry Baryshkov 		.pcs_misc_num	= ARRAY_SIZE(sdx55_qmp_pcie_pcs_misc_tbl),
17152566ad8eSDmitry Baryshkov 	},
171694a407ccSDmitry Baryshkov 	.clk_list		= sdm845_pciephy_clk_l,
171794a407ccSDmitry Baryshkov 	.num_clks		= ARRAY_SIZE(sdm845_pciephy_clk_l),
171894a407ccSDmitry Baryshkov 	.reset_list		= sdm845_pciephy_reset_l,
171994a407ccSDmitry Baryshkov 	.num_resets		= ARRAY_SIZE(sdm845_pciephy_reset_l),
172094a407ccSDmitry Baryshkov 	.vreg_list		= qmp_phy_vreg_l,
172194a407ccSDmitry Baryshkov 	.num_vregs		= ARRAY_SIZE(qmp_phy_vreg_l),
172294a407ccSDmitry Baryshkov 	.regs			= sm8250_pcie_regs_layout,
172394a407ccSDmitry Baryshkov 
172494a407ccSDmitry Baryshkov 	.pwrdn_ctrl		= SW_PWRDN,
172594a407ccSDmitry Baryshkov 	.phy_status		= PHYSTATUS_4_20,
172694a407ccSDmitry Baryshkov };
172794a407ccSDmitry Baryshkov 
172894a407ccSDmitry Baryshkov static const struct qmp_phy_cfg sm8450_qmp_gen3x1_pciephy_cfg = {
1729f02543faSJohan Hovold 	.lanes			= 1,
173094a407ccSDmitry Baryshkov 
17312566ad8eSDmitry Baryshkov 	.tables = {
17322566ad8eSDmitry Baryshkov 		.serdes		= sm8450_qmp_gen3x1_pcie_serdes_tbl,
17332566ad8eSDmitry Baryshkov 		.serdes_num	= ARRAY_SIZE(sm8450_qmp_gen3x1_pcie_serdes_tbl),
17342566ad8eSDmitry Baryshkov 		.tx		= sm8450_qmp_gen3x1_pcie_tx_tbl,
17352566ad8eSDmitry Baryshkov 		.tx_num		= ARRAY_SIZE(sm8450_qmp_gen3x1_pcie_tx_tbl),
17362566ad8eSDmitry Baryshkov 		.rx		= sm8450_qmp_gen3x1_pcie_rx_tbl,
17372566ad8eSDmitry Baryshkov 		.rx_num		= ARRAY_SIZE(sm8450_qmp_gen3x1_pcie_rx_tbl),
17382566ad8eSDmitry Baryshkov 		.pcs		= sm8450_qmp_gen3x1_pcie_pcs_tbl,
17392566ad8eSDmitry Baryshkov 		.pcs_num	= ARRAY_SIZE(sm8450_qmp_gen3x1_pcie_pcs_tbl),
17402566ad8eSDmitry Baryshkov 		.pcs_misc	= sm8450_qmp_gen3x1_pcie_pcs_misc_tbl,
17412566ad8eSDmitry Baryshkov 		.pcs_misc_num	= ARRAY_SIZE(sm8450_qmp_gen3x1_pcie_pcs_misc_tbl),
17422566ad8eSDmitry Baryshkov 	},
174394a407ccSDmitry Baryshkov 	.clk_list		= sdm845_pciephy_clk_l,
174494a407ccSDmitry Baryshkov 	.num_clks		= ARRAY_SIZE(sdm845_pciephy_clk_l),
174594a407ccSDmitry Baryshkov 	.reset_list		= sdm845_pciephy_reset_l,
174694a407ccSDmitry Baryshkov 	.num_resets		= ARRAY_SIZE(sdm845_pciephy_reset_l),
174794a407ccSDmitry Baryshkov 	.vreg_list		= qmp_phy_vreg_l,
174894a407ccSDmitry Baryshkov 	.num_vregs		= ARRAY_SIZE(qmp_phy_vreg_l),
174994a407ccSDmitry Baryshkov 	.regs			= sm8250_pcie_regs_layout,
175094a407ccSDmitry Baryshkov 
175194a407ccSDmitry Baryshkov 	.pwrdn_ctrl		= SW_PWRDN | REFCLK_DRV_DSBL,
175294a407ccSDmitry Baryshkov 	.phy_status		= PHYSTATUS,
175394a407ccSDmitry Baryshkov };
175494a407ccSDmitry Baryshkov 
175594a407ccSDmitry Baryshkov static const struct qmp_phy_cfg sm8450_qmp_gen4x2_pciephy_cfg = {
1756f02543faSJohan Hovold 	.lanes			= 2,
175794a407ccSDmitry Baryshkov 
17582566ad8eSDmitry Baryshkov 	.tables = {
17592566ad8eSDmitry Baryshkov 		.serdes		= sm8450_qmp_gen4x2_pcie_serdes_tbl,
17602566ad8eSDmitry Baryshkov 		.serdes_num	= ARRAY_SIZE(sm8450_qmp_gen4x2_pcie_serdes_tbl),
17612566ad8eSDmitry Baryshkov 		.tx		= sm8450_qmp_gen4x2_pcie_tx_tbl,
17622566ad8eSDmitry Baryshkov 		.tx_num		= ARRAY_SIZE(sm8450_qmp_gen4x2_pcie_tx_tbl),
17632566ad8eSDmitry Baryshkov 		.rx		= sm8450_qmp_gen4x2_pcie_rx_tbl,
17642566ad8eSDmitry Baryshkov 		.rx_num		= ARRAY_SIZE(sm8450_qmp_gen4x2_pcie_rx_tbl),
17652566ad8eSDmitry Baryshkov 		.pcs		= sm8450_qmp_gen4x2_pcie_pcs_tbl,
17662566ad8eSDmitry Baryshkov 		.pcs_num	= ARRAY_SIZE(sm8450_qmp_gen4x2_pcie_pcs_tbl),
17672566ad8eSDmitry Baryshkov 		.pcs_misc	= sm8450_qmp_gen4x2_pcie_pcs_misc_tbl,
17682566ad8eSDmitry Baryshkov 		.pcs_misc_num	= ARRAY_SIZE(sm8450_qmp_gen4x2_pcie_pcs_misc_tbl),
17692566ad8eSDmitry Baryshkov 	},
1770f5682f13SDmitry Baryshkov 
1771f5682f13SDmitry Baryshkov 	.tables_rc = &(const struct qmp_phy_cfg_tables) {
1772f5682f13SDmitry Baryshkov 		.serdes		= sm8450_qmp_gen4x2_pcie_rc_serdes_tbl,
1773f5682f13SDmitry Baryshkov 		.serdes_num	= ARRAY_SIZE(sm8450_qmp_gen4x2_pcie_rc_serdes_tbl),
1774f5682f13SDmitry Baryshkov 		.pcs_misc	= sm8450_qmp_gen4x2_pcie_rc_pcs_misc_tbl,
1775f5682f13SDmitry Baryshkov 		.pcs_misc_num	= ARRAY_SIZE(sm8450_qmp_gen4x2_pcie_rc_pcs_misc_tbl),
1776f5682f13SDmitry Baryshkov 	},
1777f5682f13SDmitry Baryshkov 
1778f5682f13SDmitry Baryshkov 	.tables_ep = &(const struct qmp_phy_cfg_tables) {
1779f5682f13SDmitry Baryshkov 		.serdes		= sm8450_qmp_gen4x2_pcie_ep_serdes_tbl,
1780f5682f13SDmitry Baryshkov 		.serdes_num	= ARRAY_SIZE(sm8450_qmp_gen4x2_pcie_ep_serdes_tbl),
1781f5682f13SDmitry Baryshkov 		.pcs_misc	= sm8450_qmp_gen4x2_pcie_ep_pcs_misc_tbl,
1782f5682f13SDmitry Baryshkov 		.pcs_misc_num	= ARRAY_SIZE(sm8450_qmp_gen4x2_pcie_ep_pcs_misc_tbl),
1783f5682f13SDmitry Baryshkov 	},
1784f5682f13SDmitry Baryshkov 
178594a407ccSDmitry Baryshkov 	.clk_list		= sdm845_pciephy_clk_l,
178694a407ccSDmitry Baryshkov 	.num_clks		= ARRAY_SIZE(sdm845_pciephy_clk_l),
178794a407ccSDmitry Baryshkov 	.reset_list		= sdm845_pciephy_reset_l,
178894a407ccSDmitry Baryshkov 	.num_resets		= ARRAY_SIZE(sdm845_pciephy_reset_l),
178994a407ccSDmitry Baryshkov 	.vreg_list		= qmp_phy_vreg_l,
179094a407ccSDmitry Baryshkov 	.num_vregs		= ARRAY_SIZE(qmp_phy_vreg_l),
179194a407ccSDmitry Baryshkov 	.regs			= sm8250_pcie_regs_layout,
179294a407ccSDmitry Baryshkov 
179394a407ccSDmitry Baryshkov 	.pwrdn_ctrl		= SW_PWRDN | REFCLK_DRV_DSBL,
179494a407ccSDmitry Baryshkov 	.phy_status		= PHYSTATUS_4_20,
179594a407ccSDmitry Baryshkov };
179694a407ccSDmitry Baryshkov 
179727878615SJohan Hovold static void qmp_pcie_configure_lane(void __iomem *base,
179894a407ccSDmitry Baryshkov 					const struct qmp_phy_init_tbl tbl[],
179994a407ccSDmitry Baryshkov 					int num,
180094a407ccSDmitry Baryshkov 					u8 lane_mask)
180194a407ccSDmitry Baryshkov {
180294a407ccSDmitry Baryshkov 	int i;
180394a407ccSDmitry Baryshkov 	const struct qmp_phy_init_tbl *t = tbl;
180494a407ccSDmitry Baryshkov 
180594a407ccSDmitry Baryshkov 	if (!t)
180694a407ccSDmitry Baryshkov 		return;
180794a407ccSDmitry Baryshkov 
180894a407ccSDmitry Baryshkov 	for (i = 0; i < num; i++, t++) {
180994a407ccSDmitry Baryshkov 		if (!(t->lane_mask & lane_mask))
181094a407ccSDmitry Baryshkov 			continue;
181194a407ccSDmitry Baryshkov 
181294a407ccSDmitry Baryshkov 		writel(t->val, base + t->offset);
181394a407ccSDmitry Baryshkov 	}
181494a407ccSDmitry Baryshkov }
181594a407ccSDmitry Baryshkov 
181627878615SJohan Hovold static void qmp_pcie_configure(void __iomem *base,
181794a407ccSDmitry Baryshkov 					const struct qmp_phy_init_tbl tbl[],
181894a407ccSDmitry Baryshkov 					int num)
181994a407ccSDmitry Baryshkov {
1820f2175762SJohan Hovold 	qmp_pcie_configure_lane(base, tbl, num, 0xff);
182194a407ccSDmitry Baryshkov }
182294a407ccSDmitry Baryshkov 
1823*2fdedef3SJohan Hovold static void qmp_pcie_serdes_init(struct qmp_pcie *qmp, const struct qmp_phy_cfg_tables *tables)
182494a407ccSDmitry Baryshkov {
1825*2fdedef3SJohan Hovold 	void __iomem *serdes = qmp->serdes;
182694a407ccSDmitry Baryshkov 
18272566ad8eSDmitry Baryshkov 	if (!tables)
18282566ad8eSDmitry Baryshkov 		return;
182994a407ccSDmitry Baryshkov 
1830f2175762SJohan Hovold 	qmp_pcie_configure(serdes, tables->serdes, tables->serdes_num);
18312566ad8eSDmitry Baryshkov }
18322566ad8eSDmitry Baryshkov 
1833*2fdedef3SJohan Hovold static void qmp_pcie_lanes_init(struct qmp_pcie *qmp, const struct qmp_phy_cfg_tables *tables)
18342566ad8eSDmitry Baryshkov {
1835*2fdedef3SJohan Hovold 	const struct qmp_phy_cfg *cfg = qmp->cfg;
1836*2fdedef3SJohan Hovold 	void __iomem *tx = qmp->tx;
1837*2fdedef3SJohan Hovold 	void __iomem *rx = qmp->rx;
18382566ad8eSDmitry Baryshkov 
18392566ad8eSDmitry Baryshkov 	if (!tables)
18402566ad8eSDmitry Baryshkov 		return;
18412566ad8eSDmitry Baryshkov 
1842f2175762SJohan Hovold 	qmp_pcie_configure_lane(tx, tables->tx, tables->tx_num, 1);
18432566ad8eSDmitry Baryshkov 
18442566ad8eSDmitry Baryshkov 	if (cfg->lanes >= 2)
1845*2fdedef3SJohan Hovold 		qmp_pcie_configure_lane(qmp->tx2, tables->tx, tables->tx_num, 2);
18462566ad8eSDmitry Baryshkov 
1847f2175762SJohan Hovold 	qmp_pcie_configure_lane(rx, tables->rx, tables->rx_num, 1);
18482566ad8eSDmitry Baryshkov 	if (cfg->lanes >= 2)
1849*2fdedef3SJohan Hovold 		qmp_pcie_configure_lane(qmp->rx2, tables->rx, tables->rx_num, 2);
18502566ad8eSDmitry Baryshkov }
18512566ad8eSDmitry Baryshkov 
1852*2fdedef3SJohan Hovold static void qmp_pcie_pcs_init(struct qmp_pcie *qmp, const struct qmp_phy_cfg_tables *tables)
18532566ad8eSDmitry Baryshkov {
1854*2fdedef3SJohan Hovold 	void __iomem *pcs = qmp->pcs;
1855*2fdedef3SJohan Hovold 	void __iomem *pcs_misc = qmp->pcs_misc;
18562566ad8eSDmitry Baryshkov 
18572566ad8eSDmitry Baryshkov 	if (!tables)
18582566ad8eSDmitry Baryshkov 		return;
18592566ad8eSDmitry Baryshkov 
1860f2175762SJohan Hovold 	qmp_pcie_configure(pcs, tables->pcs, tables->pcs_num);
1861f2175762SJohan Hovold 	qmp_pcie_configure(pcs_misc, tables->pcs_misc, tables->pcs_misc_num);
186294a407ccSDmitry Baryshkov }
186394a407ccSDmitry Baryshkov 
186491174e2cSJohan Hovold static int qmp_pcie_init(struct phy *phy)
186594a407ccSDmitry Baryshkov {
1866*2fdedef3SJohan Hovold 	struct qmp_pcie *qmp = phy_get_drvdata(phy);
1867*2fdedef3SJohan Hovold 	const struct qmp_phy_cfg *cfg = qmp->cfg;
1868189ac6b8SDmitry Baryshkov 	int ret;
186994a407ccSDmitry Baryshkov 
187094a407ccSDmitry Baryshkov 	ret = regulator_bulk_enable(cfg->num_vregs, qmp->vregs);
187194a407ccSDmitry Baryshkov 	if (ret) {
187294a407ccSDmitry Baryshkov 		dev_err(qmp->dev, "failed to enable regulators, err=%d\n", ret);
18731239fd71SDmitry Baryshkov 		return ret;
187494a407ccSDmitry Baryshkov 	}
187594a407ccSDmitry Baryshkov 
1876189ac6b8SDmitry Baryshkov 	ret = reset_control_bulk_assert(cfg->num_resets, qmp->resets);
187794a407ccSDmitry Baryshkov 	if (ret) {
1878189ac6b8SDmitry Baryshkov 		dev_err(qmp->dev, "reset assert failed\n");
187994a407ccSDmitry Baryshkov 		goto err_disable_regulators;
188094a407ccSDmitry Baryshkov 	}
188194a407ccSDmitry Baryshkov 
1882189ac6b8SDmitry Baryshkov 	ret = reset_control_bulk_deassert(cfg->num_resets, qmp->resets);
188394a407ccSDmitry Baryshkov 	if (ret) {
1884189ac6b8SDmitry Baryshkov 		dev_err(qmp->dev, "reset deassert failed\n");
1885189ac6b8SDmitry Baryshkov 		goto err_disable_regulators;
188694a407ccSDmitry Baryshkov 	}
188794a407ccSDmitry Baryshkov 
188894a407ccSDmitry Baryshkov 	ret = clk_bulk_prepare_enable(cfg->num_clks, qmp->clks);
188994a407ccSDmitry Baryshkov 	if (ret)
189094a407ccSDmitry Baryshkov 		goto err_assert_reset;
189194a407ccSDmitry Baryshkov 
189294a407ccSDmitry Baryshkov 	return 0;
189394a407ccSDmitry Baryshkov 
189494a407ccSDmitry Baryshkov err_assert_reset:
1895189ac6b8SDmitry Baryshkov 	reset_control_bulk_assert(cfg->num_resets, qmp->resets);
189694a407ccSDmitry Baryshkov err_disable_regulators:
189794a407ccSDmitry Baryshkov 	regulator_bulk_disable(cfg->num_vregs, qmp->vregs);
189894a407ccSDmitry Baryshkov 
189994a407ccSDmitry Baryshkov 	return ret;
190094a407ccSDmitry Baryshkov }
190194a407ccSDmitry Baryshkov 
190291174e2cSJohan Hovold static int qmp_pcie_exit(struct phy *phy)
190394a407ccSDmitry Baryshkov {
1904*2fdedef3SJohan Hovold 	struct qmp_pcie *qmp = phy_get_drvdata(phy);
1905*2fdedef3SJohan Hovold 	const struct qmp_phy_cfg *cfg = qmp->cfg;
190694a407ccSDmitry Baryshkov 
1907189ac6b8SDmitry Baryshkov 	reset_control_bulk_assert(cfg->num_resets, qmp->resets);
190894a407ccSDmitry Baryshkov 
190994a407ccSDmitry Baryshkov 	clk_bulk_disable_unprepare(cfg->num_clks, qmp->clks);
191094a407ccSDmitry Baryshkov 
191194a407ccSDmitry Baryshkov 	regulator_bulk_disable(cfg->num_vregs, qmp->vregs);
191294a407ccSDmitry Baryshkov 
191394a407ccSDmitry Baryshkov 	return 0;
191494a407ccSDmitry Baryshkov }
191594a407ccSDmitry Baryshkov 
191627878615SJohan Hovold static int qmp_pcie_power_on(struct phy *phy)
191794a407ccSDmitry Baryshkov {
1918*2fdedef3SJohan Hovold 	struct qmp_pcie *qmp = phy_get_drvdata(phy);
1919*2fdedef3SJohan Hovold 	const struct qmp_phy_cfg *cfg = qmp->cfg;
192011bf53a3SDmitry Baryshkov 	const struct qmp_phy_cfg_tables *mode_tables;
1921*2fdedef3SJohan Hovold 	void __iomem *pcs = qmp->pcs;
192294a407ccSDmitry Baryshkov 	void __iomem *status;
19232577ba8cSJohan Hovold 	unsigned int mask, val;
192494a407ccSDmitry Baryshkov 	int ret;
192594a407ccSDmitry Baryshkov 
19265b68d95cSJohan Hovold 	qphy_setbits(pcs, cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL],
19275b68d95cSJohan Hovold 			cfg->pwrdn_ctrl);
19285b68d95cSJohan Hovold 
1929*2fdedef3SJohan Hovold 	if (qmp->mode == PHY_MODE_PCIE_RC)
193011bf53a3SDmitry Baryshkov 		mode_tables = cfg->tables_rc;
193111bf53a3SDmitry Baryshkov 	else
193211bf53a3SDmitry Baryshkov 		mode_tables = cfg->tables_ep;
193311bf53a3SDmitry Baryshkov 
1934*2fdedef3SJohan Hovold 	qmp_pcie_serdes_init(qmp, &cfg->tables);
1935*2fdedef3SJohan Hovold 	qmp_pcie_serdes_init(qmp, mode_tables);
193694a407ccSDmitry Baryshkov 
1937*2fdedef3SJohan Hovold 	ret = clk_prepare_enable(qmp->pipe_clk);
193894a407ccSDmitry Baryshkov 	if (ret) {
193994a407ccSDmitry Baryshkov 		dev_err(qmp->dev, "pipe_clk enable failed err=%d\n", ret);
1940fd926994SDmitry Baryshkov 		return ret;
194194a407ccSDmitry Baryshkov 	}
194294a407ccSDmitry Baryshkov 
194394a407ccSDmitry Baryshkov 	/* Tx, Rx, and PCS configurations */
1944*2fdedef3SJohan Hovold 	qmp_pcie_lanes_init(qmp, &cfg->tables);
1945*2fdedef3SJohan Hovold 	qmp_pcie_lanes_init(qmp, mode_tables);
194694a407ccSDmitry Baryshkov 
1947*2fdedef3SJohan Hovold 	qmp_pcie_pcs_init(qmp, &cfg->tables);
1948*2fdedef3SJohan Hovold 	qmp_pcie_pcs_init(qmp, mode_tables);
194994a407ccSDmitry Baryshkov 
195094a407ccSDmitry Baryshkov 	/* Pull PHY out of reset state */
195194a407ccSDmitry Baryshkov 	qphy_clrbits(pcs, cfg->regs[QPHY_SW_RESET], SW_RESET);
1952fd926994SDmitry Baryshkov 
195394a407ccSDmitry Baryshkov 	/* start SerDes and Phy-Coding-Sublayer */
19545806b87dSJohan Hovold 	qphy_setbits(pcs, cfg->regs[QPHY_START_CTRL], SERDES_START | PCS_START);
195594a407ccSDmitry Baryshkov 
195651bd3306SJohan Hovold 	if (!cfg->skip_start_delay)
195751bd3306SJohan Hovold 		usleep_range(1000, 1200);
195851bd3306SJohan Hovold 
195994a407ccSDmitry Baryshkov 	status = pcs + cfg->regs[QPHY_PCS_STATUS];
196094a407ccSDmitry Baryshkov 	mask = cfg->phy_status;
19615cbeb75aSJohan Hovold 	ret = readl_poll_timeout(status, val, !(val & mask), 200,
196294a407ccSDmitry Baryshkov 				 PHY_INIT_COMPLETE_TIMEOUT);
196394a407ccSDmitry Baryshkov 	if (ret) {
196494a407ccSDmitry Baryshkov 		dev_err(qmp->dev, "phy initialization timed-out\n");
196594a407ccSDmitry Baryshkov 		goto err_disable_pipe_clk;
196694a407ccSDmitry Baryshkov 	}
1967da07a06bSDmitry Baryshkov 
196894a407ccSDmitry Baryshkov 	return 0;
196994a407ccSDmitry Baryshkov 
197094a407ccSDmitry Baryshkov err_disable_pipe_clk:
1971*2fdedef3SJohan Hovold 	clk_disable_unprepare(qmp->pipe_clk);
197294a407ccSDmitry Baryshkov 
197394a407ccSDmitry Baryshkov 	return ret;
197494a407ccSDmitry Baryshkov }
197594a407ccSDmitry Baryshkov 
197627878615SJohan Hovold static int qmp_pcie_power_off(struct phy *phy)
197794a407ccSDmitry Baryshkov {
1978*2fdedef3SJohan Hovold 	struct qmp_pcie *qmp = phy_get_drvdata(phy);
1979*2fdedef3SJohan Hovold 	const struct qmp_phy_cfg *cfg = qmp->cfg;
198094a407ccSDmitry Baryshkov 
1981*2fdedef3SJohan Hovold 	clk_disable_unprepare(qmp->pipe_clk);
198294a407ccSDmitry Baryshkov 
198394a407ccSDmitry Baryshkov 	/* PHY reset */
1984*2fdedef3SJohan Hovold 	qphy_setbits(qmp->pcs, cfg->regs[QPHY_SW_RESET], SW_RESET);
198594a407ccSDmitry Baryshkov 
198694a407ccSDmitry Baryshkov 	/* stop SerDes and Phy-Coding-Sublayer */
1987*2fdedef3SJohan Hovold 	qphy_clrbits(qmp->pcs, cfg->regs[QPHY_START_CTRL],
19885806b87dSJohan Hovold 			SERDES_START | PCS_START);
198994a407ccSDmitry Baryshkov 
199094a407ccSDmitry Baryshkov 	/* Put PHY into POWER DOWN state: active low */
1991*2fdedef3SJohan Hovold 	qphy_clrbits(qmp->pcs, cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL],
199294a407ccSDmitry Baryshkov 			cfg->pwrdn_ctrl);
199394a407ccSDmitry Baryshkov 
199494a407ccSDmitry Baryshkov 	return 0;
199594a407ccSDmitry Baryshkov }
199694a407ccSDmitry Baryshkov 
199727878615SJohan Hovold static int qmp_pcie_enable(struct phy *phy)
199894a407ccSDmitry Baryshkov {
199994a407ccSDmitry Baryshkov 	int ret;
200094a407ccSDmitry Baryshkov 
200127878615SJohan Hovold 	ret = qmp_pcie_init(phy);
200294a407ccSDmitry Baryshkov 	if (ret)
200394a407ccSDmitry Baryshkov 		return ret;
200494a407ccSDmitry Baryshkov 
200527878615SJohan Hovold 	ret = qmp_pcie_power_on(phy);
200694a407ccSDmitry Baryshkov 	if (ret)
200727878615SJohan Hovold 		qmp_pcie_exit(phy);
200894a407ccSDmitry Baryshkov 
200994a407ccSDmitry Baryshkov 	return ret;
201094a407ccSDmitry Baryshkov }
201194a407ccSDmitry Baryshkov 
201227878615SJohan Hovold static int qmp_pcie_disable(struct phy *phy)
201394a407ccSDmitry Baryshkov {
201494a407ccSDmitry Baryshkov 	int ret;
201594a407ccSDmitry Baryshkov 
201627878615SJohan Hovold 	ret = qmp_pcie_power_off(phy);
201794a407ccSDmitry Baryshkov 	if (ret)
201894a407ccSDmitry Baryshkov 		return ret;
201927878615SJohan Hovold 
202027878615SJohan Hovold 	return qmp_pcie_exit(phy);
202194a407ccSDmitry Baryshkov }
202294a407ccSDmitry Baryshkov 
202311bf53a3SDmitry Baryshkov static int qmp_pcie_set_mode(struct phy *phy, enum phy_mode mode, int submode)
202411bf53a3SDmitry Baryshkov {
2025*2fdedef3SJohan Hovold 	struct qmp_pcie *qmp = phy_get_drvdata(phy);
202611bf53a3SDmitry Baryshkov 
202711bf53a3SDmitry Baryshkov 	switch (submode) {
202811bf53a3SDmitry Baryshkov 	case PHY_MODE_PCIE_RC:
202911bf53a3SDmitry Baryshkov 	case PHY_MODE_PCIE_EP:
2030*2fdedef3SJohan Hovold 		qmp->mode = submode;
203111bf53a3SDmitry Baryshkov 		break;
203211bf53a3SDmitry Baryshkov 	default:
203311bf53a3SDmitry Baryshkov 		dev_err(&phy->dev, "Unsupported submode %d\n", submode);
203411bf53a3SDmitry Baryshkov 		return -EINVAL;
203511bf53a3SDmitry Baryshkov 	}
203611bf53a3SDmitry Baryshkov 
203711bf53a3SDmitry Baryshkov 	return 0;
203811bf53a3SDmitry Baryshkov }
203911bf53a3SDmitry Baryshkov 
204027878615SJohan Hovold static int qmp_pcie_vreg_init(struct device *dev, const struct qmp_phy_cfg *cfg)
204194a407ccSDmitry Baryshkov {
2042*2fdedef3SJohan Hovold 	struct qmp_pcie *qmp = dev_get_drvdata(dev);
204394a407ccSDmitry Baryshkov 	int num = cfg->num_vregs;
204494a407ccSDmitry Baryshkov 	int i;
204594a407ccSDmitry Baryshkov 
204694a407ccSDmitry Baryshkov 	qmp->vregs = devm_kcalloc(dev, num, sizeof(*qmp->vregs), GFP_KERNEL);
204794a407ccSDmitry Baryshkov 	if (!qmp->vregs)
204894a407ccSDmitry Baryshkov 		return -ENOMEM;
204994a407ccSDmitry Baryshkov 
205094a407ccSDmitry Baryshkov 	for (i = 0; i < num; i++)
205194a407ccSDmitry Baryshkov 		qmp->vregs[i].supply = cfg->vreg_list[i];
205294a407ccSDmitry Baryshkov 
205394a407ccSDmitry Baryshkov 	return devm_regulator_bulk_get(dev, num, qmp->vregs);
205494a407ccSDmitry Baryshkov }
205594a407ccSDmitry Baryshkov 
205627878615SJohan Hovold static int qmp_pcie_reset_init(struct device *dev, const struct qmp_phy_cfg *cfg)
205794a407ccSDmitry Baryshkov {
2058*2fdedef3SJohan Hovold 	struct qmp_pcie *qmp = dev_get_drvdata(dev);
205994a407ccSDmitry Baryshkov 	int i;
2060189ac6b8SDmitry Baryshkov 	int ret;
206194a407ccSDmitry Baryshkov 
206294a407ccSDmitry Baryshkov 	qmp->resets = devm_kcalloc(dev, cfg->num_resets,
206394a407ccSDmitry Baryshkov 				   sizeof(*qmp->resets), GFP_KERNEL);
206494a407ccSDmitry Baryshkov 	if (!qmp->resets)
206594a407ccSDmitry Baryshkov 		return -ENOMEM;
206694a407ccSDmitry Baryshkov 
2067189ac6b8SDmitry Baryshkov 	for (i = 0; i < cfg->num_resets; i++)
2068189ac6b8SDmitry Baryshkov 		qmp->resets[i].id = cfg->reset_list[i];
206994a407ccSDmitry Baryshkov 
2070189ac6b8SDmitry Baryshkov 	ret = devm_reset_control_bulk_get_exclusive(dev, cfg->num_resets, qmp->resets);
2071189ac6b8SDmitry Baryshkov 	if (ret)
2072189ac6b8SDmitry Baryshkov 		return dev_err_probe(dev, ret, "failed to get resets\n");
207394a407ccSDmitry Baryshkov 
207494a407ccSDmitry Baryshkov 	return 0;
207594a407ccSDmitry Baryshkov }
207694a407ccSDmitry Baryshkov 
207727878615SJohan Hovold static int qmp_pcie_clk_init(struct device *dev, const struct qmp_phy_cfg *cfg)
207894a407ccSDmitry Baryshkov {
2079*2fdedef3SJohan Hovold 	struct qmp_pcie *qmp = dev_get_drvdata(dev);
208094a407ccSDmitry Baryshkov 	int num = cfg->num_clks;
208194a407ccSDmitry Baryshkov 	int i;
208294a407ccSDmitry Baryshkov 
208394a407ccSDmitry Baryshkov 	qmp->clks = devm_kcalloc(dev, num, sizeof(*qmp->clks), GFP_KERNEL);
208494a407ccSDmitry Baryshkov 	if (!qmp->clks)
208594a407ccSDmitry Baryshkov 		return -ENOMEM;
208694a407ccSDmitry Baryshkov 
208794a407ccSDmitry Baryshkov 	for (i = 0; i < num; i++)
208894a407ccSDmitry Baryshkov 		qmp->clks[i].id = cfg->clk_list[i];
208994a407ccSDmitry Baryshkov 
209094a407ccSDmitry Baryshkov 	return devm_clk_bulk_get(dev, num, qmp->clks);
209194a407ccSDmitry Baryshkov }
209294a407ccSDmitry Baryshkov 
209394a407ccSDmitry Baryshkov static void phy_clk_release_provider(void *res)
209494a407ccSDmitry Baryshkov {
209594a407ccSDmitry Baryshkov 	of_clk_del_provider(res);
209694a407ccSDmitry Baryshkov }
209794a407ccSDmitry Baryshkov 
209894a407ccSDmitry Baryshkov /*
209994a407ccSDmitry Baryshkov  * Register a fixed rate pipe clock.
210094a407ccSDmitry Baryshkov  *
210194a407ccSDmitry Baryshkov  * The <s>_pipe_clksrc generated by PHY goes to the GCC that gate
210294a407ccSDmitry Baryshkov  * controls it. The <s>_pipe_clk coming out of the GCC is requested
210394a407ccSDmitry Baryshkov  * by the PHY driver for its operations.
210494a407ccSDmitry Baryshkov  * We register the <s>_pipe_clksrc here. The gcc driver takes care
210594a407ccSDmitry Baryshkov  * of assigning this <s>_pipe_clksrc as parent to <s>_pipe_clk.
210694a407ccSDmitry Baryshkov  * Below picture shows this relationship.
210794a407ccSDmitry Baryshkov  *
210894a407ccSDmitry Baryshkov  *         +---------------+
210994a407ccSDmitry Baryshkov  *         |   PHY block   |<<---------------------------------------+
211094a407ccSDmitry Baryshkov  *         |               |                                         |
211194a407ccSDmitry Baryshkov  *         |   +-------+   |                   +-----+               |
211294a407ccSDmitry Baryshkov  *   I/P---^-->|  PLL  |---^--->pipe_clksrc--->| GCC |--->pipe_clk---+
211394a407ccSDmitry Baryshkov  *    clk  |   +-------+   |                   +-----+
211494a407ccSDmitry Baryshkov  *         +---------------+
211594a407ccSDmitry Baryshkov  */
2116*2fdedef3SJohan Hovold static int phy_pipe_clk_register(struct qmp_pcie *qmp, struct device_node *np)
211794a407ccSDmitry Baryshkov {
211894a407ccSDmitry Baryshkov 	struct clk_fixed_rate *fixed;
211994a407ccSDmitry Baryshkov 	struct clk_init_data init = { };
212094a407ccSDmitry Baryshkov 	int ret;
212194a407ccSDmitry Baryshkov 
212294a407ccSDmitry Baryshkov 	ret = of_property_read_string(np, "clock-output-names", &init.name);
212394a407ccSDmitry Baryshkov 	if (ret) {
212494a407ccSDmitry Baryshkov 		dev_err(qmp->dev, "%pOFn: No clock-output-names\n", np);
212594a407ccSDmitry Baryshkov 		return ret;
212694a407ccSDmitry Baryshkov 	}
212794a407ccSDmitry Baryshkov 
212894a407ccSDmitry Baryshkov 	fixed = devm_kzalloc(qmp->dev, sizeof(*fixed), GFP_KERNEL);
212994a407ccSDmitry Baryshkov 	if (!fixed)
213094a407ccSDmitry Baryshkov 		return -ENOMEM;
213194a407ccSDmitry Baryshkov 
213294a407ccSDmitry Baryshkov 	init.ops = &clk_fixed_rate_ops;
213394a407ccSDmitry Baryshkov 
21342ec9bc8dSRobert Marko 	/*
21352ec9bc8dSRobert Marko 	 * Controllers using QMP PHY-s use 125MHz pipe clock interface
21362ec9bc8dSRobert Marko 	 * unless other frequency is specified in the PHY config.
21372ec9bc8dSRobert Marko 	 */
2138*2fdedef3SJohan Hovold 	if (qmp->cfg->pipe_clock_rate)
2139*2fdedef3SJohan Hovold 		fixed->fixed_rate = qmp->cfg->pipe_clock_rate;
21402ec9bc8dSRobert Marko 	else
214194a407ccSDmitry Baryshkov 		fixed->fixed_rate = 125000000;
21422ec9bc8dSRobert Marko 
214394a407ccSDmitry Baryshkov 	fixed->hw.init = &init;
214494a407ccSDmitry Baryshkov 
214594a407ccSDmitry Baryshkov 	ret = devm_clk_hw_register(qmp->dev, &fixed->hw);
214694a407ccSDmitry Baryshkov 	if (ret)
214794a407ccSDmitry Baryshkov 		return ret;
214894a407ccSDmitry Baryshkov 
214994a407ccSDmitry Baryshkov 	ret = of_clk_add_hw_provider(np, of_clk_hw_simple_get, &fixed->hw);
215094a407ccSDmitry Baryshkov 	if (ret)
215194a407ccSDmitry Baryshkov 		return ret;
215294a407ccSDmitry Baryshkov 
215394a407ccSDmitry Baryshkov 	/*
215494a407ccSDmitry Baryshkov 	 * Roll a devm action because the clock provider is the child node, but
215594a407ccSDmitry Baryshkov 	 * the child node is not actually a device.
215694a407ccSDmitry Baryshkov 	 */
215794a407ccSDmitry Baryshkov 	return devm_add_action_or_reset(qmp->dev, phy_clk_release_provider, np);
215894a407ccSDmitry Baryshkov }
215994a407ccSDmitry Baryshkov 
216027878615SJohan Hovold static const struct phy_ops qmp_pcie_ops = {
216127878615SJohan Hovold 	.power_on	= qmp_pcie_enable,
216227878615SJohan Hovold 	.power_off	= qmp_pcie_disable,
216311bf53a3SDmitry Baryshkov 	.set_mode	= qmp_pcie_set_mode,
216494a407ccSDmitry Baryshkov 	.owner		= THIS_MODULE,
216594a407ccSDmitry Baryshkov };
216694a407ccSDmitry Baryshkov 
2167*2fdedef3SJohan Hovold static int qmp_pcie_create(struct device *dev, struct device_node *np,
216894a407ccSDmitry Baryshkov 			void __iomem *serdes, const struct qmp_phy_cfg *cfg)
216994a407ccSDmitry Baryshkov {
2170*2fdedef3SJohan Hovold 	struct qmp_pcie *qmp = dev_get_drvdata(dev);
217194a407ccSDmitry Baryshkov 	struct phy *generic_phy;
217294a407ccSDmitry Baryshkov 	int ret;
217394a407ccSDmitry Baryshkov 
2174*2fdedef3SJohan Hovold 	qmp->mode = PHY_MODE_PCIE_RC;
217594a407ccSDmitry Baryshkov 
2176*2fdedef3SJohan Hovold 	qmp->cfg = cfg;
2177*2fdedef3SJohan Hovold 	qmp->serdes = serdes;
217811bf53a3SDmitry Baryshkov 
217994a407ccSDmitry Baryshkov 	/*
21808d3bf724SJohan Hovold 	 * Get memory resources for the PHY:
218194a407ccSDmitry Baryshkov 	 * Resources are indexed as: tx -> 0; rx -> 1; pcs -> 2.
218294a407ccSDmitry Baryshkov 	 * For dual lane PHYs: tx2 -> 3, rx2 -> 4, pcs_misc (optional) -> 5
218394a407ccSDmitry Baryshkov 	 * For single lane PHYs: pcs_misc (optional) -> 3.
218494a407ccSDmitry Baryshkov 	 */
2185*2fdedef3SJohan Hovold 	qmp->tx = devm_of_iomap(dev, np, 0, NULL);
2186*2fdedef3SJohan Hovold 	if (IS_ERR(qmp->tx))
2187*2fdedef3SJohan Hovold 		return PTR_ERR(qmp->tx);
218894a407ccSDmitry Baryshkov 
21890a40891bSDmitry Baryshkov 	if (of_device_is_compatible(dev->of_node, "qcom,sdm845-qhp-pcie-phy"))
2190*2fdedef3SJohan Hovold 		qmp->rx = qmp->tx;
21910a40891bSDmitry Baryshkov 	else
2192*2fdedef3SJohan Hovold 		qmp->rx = devm_of_iomap(dev, np, 1, NULL);
2193*2fdedef3SJohan Hovold 	if (IS_ERR(qmp->rx))
2194*2fdedef3SJohan Hovold 		return PTR_ERR(qmp->rx);
219594a407ccSDmitry Baryshkov 
2196*2fdedef3SJohan Hovold 	qmp->pcs = devm_of_iomap(dev, np, 2, NULL);
2197*2fdedef3SJohan Hovold 	if (IS_ERR(qmp->pcs))
2198*2fdedef3SJohan Hovold 		return PTR_ERR(qmp->pcs);
219994a407ccSDmitry Baryshkov 
2200f02543faSJohan Hovold 	if (cfg->lanes >= 2) {
2201*2fdedef3SJohan Hovold 		qmp->tx2 = devm_of_iomap(dev, np, 3, NULL);
2202*2fdedef3SJohan Hovold 		if (IS_ERR(qmp->tx2))
2203*2fdedef3SJohan Hovold 			return PTR_ERR(qmp->tx2);
220469c90cb5SJohan Hovold 
2205*2fdedef3SJohan Hovold 		qmp->rx2 = devm_of_iomap(dev, np, 4, NULL);
2206*2fdedef3SJohan Hovold 		if (IS_ERR(qmp->rx2))
2207*2fdedef3SJohan Hovold 			return PTR_ERR(qmp->rx2);
220894a407ccSDmitry Baryshkov 
2209*2fdedef3SJohan Hovold 		qmp->pcs_misc = devm_of_iomap(dev, np, 5, NULL);
221094a407ccSDmitry Baryshkov 	} else {
2211*2fdedef3SJohan Hovold 		qmp->pcs_misc = devm_of_iomap(dev, np, 3, NULL);
221294a407ccSDmitry Baryshkov 	}
221394a407ccSDmitry Baryshkov 
2214*2fdedef3SJohan Hovold 	if (IS_ERR(qmp->pcs_misc) &&
2215af664324SDmitry Baryshkov 	    of_device_is_compatible(dev->of_node, "qcom,ipq6018-qmp-pcie-phy"))
2216*2fdedef3SJohan Hovold 		qmp->pcs_misc = qmp->pcs + 0x400;
2217af664324SDmitry Baryshkov 
2218*2fdedef3SJohan Hovold 	if (IS_ERR(qmp->pcs_misc)) {
22192566ad8eSDmitry Baryshkov 		if (cfg->tables.pcs_misc ||
222011bf53a3SDmitry Baryshkov 		    (cfg->tables_rc && cfg->tables_rc->pcs_misc) ||
2221*2fdedef3SJohan Hovold 		    (cfg->tables_ep && cfg->tables_ep->pcs_misc)) {
2222*2fdedef3SJohan Hovold 			return PTR_ERR(qmp->pcs_misc);
2223*2fdedef3SJohan Hovold 		}
2224ecd5507eSJohan Hovold 	}
222594a407ccSDmitry Baryshkov 
2226*2fdedef3SJohan Hovold 	qmp->pipe_clk = devm_get_clk_from_child(dev, np, NULL);
2227*2fdedef3SJohan Hovold 	if (IS_ERR(qmp->pipe_clk)) {
2228*2fdedef3SJohan Hovold 		return dev_err_probe(dev, PTR_ERR(qmp->pipe_clk),
2229*2fdedef3SJohan Hovold 				     "failed to get pipe clock\n");
223094a407ccSDmitry Baryshkov 	}
223194a407ccSDmitry Baryshkov 
223227878615SJohan Hovold 	generic_phy = devm_phy_create(dev, np, &qmp_pcie_ops);
223394a407ccSDmitry Baryshkov 	if (IS_ERR(generic_phy)) {
223494a407ccSDmitry Baryshkov 		ret = PTR_ERR(generic_phy);
2235*2fdedef3SJohan Hovold 		dev_err(dev, "failed to create PHY: %d\n", ret);
223694a407ccSDmitry Baryshkov 		return ret;
223794a407ccSDmitry Baryshkov 	}
223894a407ccSDmitry Baryshkov 
2239*2fdedef3SJohan Hovold 	qmp->phy = generic_phy;
2240*2fdedef3SJohan Hovold 	phy_set_drvdata(generic_phy, qmp);
224194a407ccSDmitry Baryshkov 
224294a407ccSDmitry Baryshkov 	return 0;
224394a407ccSDmitry Baryshkov }
224494a407ccSDmitry Baryshkov 
224527878615SJohan Hovold static int qmp_pcie_probe(struct platform_device *pdev)
224694a407ccSDmitry Baryshkov {
224794a407ccSDmitry Baryshkov 	struct device *dev = &pdev->dev;
224894a407ccSDmitry Baryshkov 	struct device_node *child;
224994a407ccSDmitry Baryshkov 	struct phy_provider *phy_provider;
225094a407ccSDmitry Baryshkov 	void __iomem *serdes;
225194a407ccSDmitry Baryshkov 	const struct qmp_phy_cfg *cfg = NULL;
2252*2fdedef3SJohan Hovold 	struct qmp_pcie *qmp;
22531239fd71SDmitry Baryshkov 	int num, id;
225494a407ccSDmitry Baryshkov 	int ret;
225594a407ccSDmitry Baryshkov 
225694a407ccSDmitry Baryshkov 	qmp = devm_kzalloc(dev, sizeof(*qmp), GFP_KERNEL);
225794a407ccSDmitry Baryshkov 	if (!qmp)
225894a407ccSDmitry Baryshkov 		return -ENOMEM;
225994a407ccSDmitry Baryshkov 
226094a407ccSDmitry Baryshkov 	qmp->dev = dev;
226194a407ccSDmitry Baryshkov 	dev_set_drvdata(dev, qmp);
226294a407ccSDmitry Baryshkov 
226394a407ccSDmitry Baryshkov 	cfg = of_device_get_match_data(dev);
2264b35a5311SDmitry Baryshkov 	if (!cfg)
226594a407ccSDmitry Baryshkov 		return -EINVAL;
226694a407ccSDmitry Baryshkov 
226773ad6a9dSJohan Hovold 	WARN_ON_ONCE(!cfg->pwrdn_ctrl);
226873ad6a9dSJohan Hovold 	WARN_ON_ONCE(!cfg->phy_status);
226973ad6a9dSJohan Hovold 
2270da07a06bSDmitry Baryshkov 	serdes = devm_platform_ioremap_resource(pdev, 0);
227194a407ccSDmitry Baryshkov 	if (IS_ERR(serdes))
227294a407ccSDmitry Baryshkov 		return PTR_ERR(serdes);
227394a407ccSDmitry Baryshkov 
227427878615SJohan Hovold 	ret = qmp_pcie_clk_init(dev, cfg);
227594a407ccSDmitry Baryshkov 	if (ret)
227694a407ccSDmitry Baryshkov 		return ret;
227794a407ccSDmitry Baryshkov 
227827878615SJohan Hovold 	ret = qmp_pcie_reset_init(dev, cfg);
227994a407ccSDmitry Baryshkov 	if (ret)
228094a407ccSDmitry Baryshkov 		return ret;
228194a407ccSDmitry Baryshkov 
228227878615SJohan Hovold 	ret = qmp_pcie_vreg_init(dev, cfg);
2283a548b6b4SYuan Can 	if (ret)
228428d74fc3SJohan Hovold 		return ret;
228594a407ccSDmitry Baryshkov 
228694a407ccSDmitry Baryshkov 	num = of_get_available_child_count(dev->of_node);
228794a407ccSDmitry Baryshkov 	/* do we have a rogue child node ? */
22881239fd71SDmitry Baryshkov 	if (num > 1)
228994a407ccSDmitry Baryshkov 		return -EINVAL;
229094a407ccSDmitry Baryshkov 
229194a407ccSDmitry Baryshkov 	id = 0;
229294a407ccSDmitry Baryshkov 	for_each_available_child_of_node(dev->of_node, child) {
229394a407ccSDmitry Baryshkov 		/* Create per-lane phy */
2294*2fdedef3SJohan Hovold 		ret = qmp_pcie_create(dev, child, serdes, cfg);
229594a407ccSDmitry Baryshkov 		if (ret) {
229694a407ccSDmitry Baryshkov 			dev_err(dev, "failed to create lane%d phy, %d\n",
229794a407ccSDmitry Baryshkov 				id, ret);
229894a407ccSDmitry Baryshkov 			goto err_node_put;
229994a407ccSDmitry Baryshkov 		}
230094a407ccSDmitry Baryshkov 
230194a407ccSDmitry Baryshkov 		/*
230294a407ccSDmitry Baryshkov 		 * Register the pipe clock provided by phy.
230394a407ccSDmitry Baryshkov 		 * See function description to see details of this pipe clock.
230494a407ccSDmitry Baryshkov 		 */
230594a407ccSDmitry Baryshkov 		ret = phy_pipe_clk_register(qmp, child);
230694a407ccSDmitry Baryshkov 		if (ret) {
230794a407ccSDmitry Baryshkov 			dev_err(qmp->dev,
230894a407ccSDmitry Baryshkov 				"failed to register pipe clock source\n");
230994a407ccSDmitry Baryshkov 			goto err_node_put;
231094a407ccSDmitry Baryshkov 		}
2311da07a06bSDmitry Baryshkov 
231294a407ccSDmitry Baryshkov 		id++;
231394a407ccSDmitry Baryshkov 	}
231494a407ccSDmitry Baryshkov 
231594a407ccSDmitry Baryshkov 	phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
231694a407ccSDmitry Baryshkov 
231794a407ccSDmitry Baryshkov 	return PTR_ERR_OR_ZERO(phy_provider);
231894a407ccSDmitry Baryshkov 
231994a407ccSDmitry Baryshkov err_node_put:
232094a407ccSDmitry Baryshkov 	of_node_put(child);
232194a407ccSDmitry Baryshkov 	return ret;
232294a407ccSDmitry Baryshkov }
232394a407ccSDmitry Baryshkov 
2324cebc6ca7SJohan Hovold static const struct of_device_id qmp_pcie_of_match_table[] = {
2325cebc6ca7SJohan Hovold 	{
2326cebc6ca7SJohan Hovold 		.compatible = "qcom,ipq6018-qmp-pcie-phy",
2327cebc6ca7SJohan Hovold 		.data = &ipq6018_pciephy_cfg,
2328cebc6ca7SJohan Hovold 	}, {
2329cebc6ca7SJohan Hovold 		.compatible = "qcom,ipq8074-qmp-gen3-pcie-phy",
2330cebc6ca7SJohan Hovold 		.data = &ipq8074_pciephy_gen3_cfg,
2331cebc6ca7SJohan Hovold 	}, {
2332cebc6ca7SJohan Hovold 		.compatible = "qcom,ipq8074-qmp-pcie-phy",
2333cebc6ca7SJohan Hovold 		.data = &ipq8074_pciephy_cfg,
2334cebc6ca7SJohan Hovold 	}, {
2335cebc6ca7SJohan Hovold 		.compatible = "qcom,msm8998-qmp-pcie-phy",
2336cebc6ca7SJohan Hovold 		.data = &msm8998_pciephy_cfg,
2337cebc6ca7SJohan Hovold 	}, {
2338cebc6ca7SJohan Hovold 		.compatible = "qcom,sc8180x-qmp-pcie-phy",
2339cebc6ca7SJohan Hovold 		.data = &sc8180x_pciephy_cfg,
2340cebc6ca7SJohan Hovold 	}, {
2341cebc6ca7SJohan Hovold 		.compatible = "qcom,sdm845-qhp-pcie-phy",
2342cebc6ca7SJohan Hovold 		.data = &sdm845_qhp_pciephy_cfg,
2343cebc6ca7SJohan Hovold 	}, {
2344cebc6ca7SJohan Hovold 		.compatible = "qcom,sdm845-qmp-pcie-phy",
2345cebc6ca7SJohan Hovold 		.data = &sdm845_qmp_pciephy_cfg,
2346cebc6ca7SJohan Hovold 	}, {
2347cebc6ca7SJohan Hovold 		.compatible = "qcom,sdx55-qmp-pcie-phy",
2348cebc6ca7SJohan Hovold 		.data = &sdx55_qmp_pciephy_cfg,
2349cebc6ca7SJohan Hovold 	}, {
2350cebc6ca7SJohan Hovold 		.compatible = "qcom,sm8250-qmp-gen3x1-pcie-phy",
2351cebc6ca7SJohan Hovold 		.data = &sm8250_qmp_gen3x1_pciephy_cfg,
2352cebc6ca7SJohan Hovold 	}, {
2353cebc6ca7SJohan Hovold 		.compatible = "qcom,sm8250-qmp-gen3x2-pcie-phy",
2354cebc6ca7SJohan Hovold 		.data = &sm8250_qmp_gen3x2_pciephy_cfg,
2355cebc6ca7SJohan Hovold 	}, {
2356cebc6ca7SJohan Hovold 		.compatible = "qcom,sm8250-qmp-modem-pcie-phy",
2357cebc6ca7SJohan Hovold 		.data = &sm8250_qmp_gen3x2_pciephy_cfg,
2358cebc6ca7SJohan Hovold 	}, {
2359cebc6ca7SJohan Hovold 		.compatible = "qcom,sm8450-qmp-gen3x1-pcie-phy",
2360cebc6ca7SJohan Hovold 		.data = &sm8450_qmp_gen3x1_pciephy_cfg,
2361cebc6ca7SJohan Hovold 	}, {
2362cebc6ca7SJohan Hovold 		.compatible = "qcom,sm8450-qmp-gen4x2-pcie-phy",
2363cebc6ca7SJohan Hovold 		.data = &sm8450_qmp_gen4x2_pciephy_cfg,
2364cebc6ca7SJohan Hovold 	},
2365cebc6ca7SJohan Hovold 	{ },
2366cebc6ca7SJohan Hovold };
2367cebc6ca7SJohan Hovold MODULE_DEVICE_TABLE(of, qmp_pcie_of_match_table);
2368cebc6ca7SJohan Hovold 
236927878615SJohan Hovold static struct platform_driver qmp_pcie_driver = {
237027878615SJohan Hovold 	.probe		= qmp_pcie_probe,
237194a407ccSDmitry Baryshkov 	.driver = {
2372b35a5311SDmitry Baryshkov 		.name	= "qcom-qmp-pcie-phy",
237327878615SJohan Hovold 		.of_match_table = qmp_pcie_of_match_table,
237494a407ccSDmitry Baryshkov 	},
237594a407ccSDmitry Baryshkov };
237694a407ccSDmitry Baryshkov 
237727878615SJohan Hovold module_platform_driver(qmp_pcie_driver);
237894a407ccSDmitry Baryshkov 
237994a407ccSDmitry Baryshkov MODULE_AUTHOR("Vivek Gautam <vivek.gautam@codeaurora.org>");
2380b35a5311SDmitry Baryshkov MODULE_DESCRIPTION("Qualcomm QMP PCIe PHY driver");
238194a407ccSDmitry Baryshkov MODULE_LICENSE("GPL v2");
2382