xref: /openbmc/linux/drivers/phy/qualcomm/phy-qcom-qmp-pcie.c (revision 5b68d95c3fc72b4a89b9c7549e1ef638a01a3e15)
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 	 * register part of layout ?
4794a407ccSDmitry Baryshkov 	 * if yes, then offset gives index in the reg-layout
4894a407ccSDmitry Baryshkov 	 */
4994a407ccSDmitry Baryshkov 	bool in_layout;
5094a407ccSDmitry Baryshkov 	/*
5194a407ccSDmitry Baryshkov 	 * mask of lanes for which this register is written
5294a407ccSDmitry Baryshkov 	 * for cases when second lane needs different values
5394a407ccSDmitry Baryshkov 	 */
5494a407ccSDmitry Baryshkov 	u8 lane_mask;
5594a407ccSDmitry Baryshkov };
5694a407ccSDmitry Baryshkov 
5794a407ccSDmitry Baryshkov #define QMP_PHY_INIT_CFG(o, v)		\
5894a407ccSDmitry Baryshkov 	{				\
5994a407ccSDmitry Baryshkov 		.offset = o,		\
6094a407ccSDmitry Baryshkov 		.val = v,		\
6194a407ccSDmitry Baryshkov 		.lane_mask = 0xff,	\
6294a407ccSDmitry Baryshkov 	}
6394a407ccSDmitry Baryshkov 
6494a407ccSDmitry Baryshkov #define QMP_PHY_INIT_CFG_L(o, v)	\
6594a407ccSDmitry Baryshkov 	{				\
6694a407ccSDmitry Baryshkov 		.offset = o,		\
6794a407ccSDmitry Baryshkov 		.val = v,		\
6894a407ccSDmitry Baryshkov 		.in_layout = true,	\
6994a407ccSDmitry Baryshkov 		.lane_mask = 0xff,	\
7094a407ccSDmitry Baryshkov 	}
7194a407ccSDmitry Baryshkov 
7294a407ccSDmitry Baryshkov #define QMP_PHY_INIT_CFG_LANE(o, v, l)	\
7394a407ccSDmitry Baryshkov 	{				\
7494a407ccSDmitry Baryshkov 		.offset = o,		\
7594a407ccSDmitry Baryshkov 		.val = v,		\
7694a407ccSDmitry Baryshkov 		.lane_mask = l,		\
7794a407ccSDmitry Baryshkov 	}
7894a407ccSDmitry Baryshkov 
7994a407ccSDmitry Baryshkov /* set of registers with offsets different per-PHY */
8094a407ccSDmitry Baryshkov enum qphy_reg_layout {
8194a407ccSDmitry Baryshkov 	/* PCS registers */
8294a407ccSDmitry Baryshkov 	QPHY_SW_RESET,
8394a407ccSDmitry Baryshkov 	QPHY_START_CTRL,
8494a407ccSDmitry Baryshkov 	QPHY_PCS_STATUS,
8594a407ccSDmitry Baryshkov 	QPHY_PCS_POWER_DOWN_CONTROL,
8694a407ccSDmitry Baryshkov 	/* Keep last to ensure regs_layout arrays are properly initialized */
8794a407ccSDmitry Baryshkov 	QPHY_LAYOUT_SIZE
8894a407ccSDmitry Baryshkov };
8994a407ccSDmitry Baryshkov 
9094a407ccSDmitry Baryshkov static const unsigned int ipq_pciephy_gen3_regs_layout[QPHY_LAYOUT_SIZE] = {
9194a407ccSDmitry Baryshkov 	[QPHY_SW_RESET]				= 0x00,
9294a407ccSDmitry Baryshkov 	[QPHY_START_CTRL]			= 0x44,
9394a407ccSDmitry Baryshkov 	[QPHY_PCS_STATUS]			= 0x14,
9494a407ccSDmitry Baryshkov 	[QPHY_PCS_POWER_DOWN_CONTROL]		= 0x40,
9594a407ccSDmitry Baryshkov };
9694a407ccSDmitry Baryshkov 
9794a407ccSDmitry Baryshkov static const unsigned int pciephy_regs_layout[QPHY_LAYOUT_SIZE] = {
9894a407ccSDmitry Baryshkov 	[QPHY_SW_RESET]			= 0x00,
9994a407ccSDmitry Baryshkov 	[QPHY_START_CTRL]		= 0x08,
10094a407ccSDmitry Baryshkov 	[QPHY_PCS_STATUS]		= 0x174,
1016d5b1e20SJohan Hovold 	[QPHY_PCS_POWER_DOWN_CONTROL]	= 0x04,
10294a407ccSDmitry Baryshkov };
10394a407ccSDmitry Baryshkov 
10494a407ccSDmitry Baryshkov static const unsigned int sdm845_qmp_pciephy_regs_layout[QPHY_LAYOUT_SIZE] = {
10594a407ccSDmitry Baryshkov 	[QPHY_SW_RESET]			= 0x00,
10694a407ccSDmitry Baryshkov 	[QPHY_START_CTRL]		= 0x08,
10794a407ccSDmitry Baryshkov 	[QPHY_PCS_STATUS]		= 0x174,
1086d5b1e20SJohan Hovold 	[QPHY_PCS_POWER_DOWN_CONTROL]	= 0x04,
10994a407ccSDmitry Baryshkov };
11094a407ccSDmitry Baryshkov 
11194a407ccSDmitry Baryshkov static const unsigned int sdm845_qhp_pciephy_regs_layout[QPHY_LAYOUT_SIZE] = {
11294a407ccSDmitry Baryshkov 	[QPHY_SW_RESET]			= 0x00,
11394a407ccSDmitry Baryshkov 	[QPHY_START_CTRL]		= 0x08,
11494a407ccSDmitry Baryshkov 	[QPHY_PCS_STATUS]		= 0x2ac,
1156d5b1e20SJohan Hovold 	[QPHY_PCS_POWER_DOWN_CONTROL]	= 0x04,
11694a407ccSDmitry Baryshkov };
11794a407ccSDmitry Baryshkov 
11894a407ccSDmitry Baryshkov static const unsigned int sm8250_pcie_regs_layout[QPHY_LAYOUT_SIZE] = {
11994a407ccSDmitry Baryshkov 	[QPHY_SW_RESET]			= 0x00,
12094a407ccSDmitry Baryshkov 	[QPHY_START_CTRL]		= 0x44,
12194a407ccSDmitry Baryshkov 	[QPHY_PCS_STATUS]		= 0x14,
12294a407ccSDmitry Baryshkov 	[QPHY_PCS_POWER_DOWN_CONTROL]	= 0x40,
12394a407ccSDmitry Baryshkov };
12494a407ccSDmitry Baryshkov 
12594a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl msm8998_pcie_serdes_tbl[] = {
12694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_BIAS_EN_CLKBUFLR_EN, 0x14),
12794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_SELECT, 0x30),
12894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_IVCO, 0x0f),
12994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CMN_CONFIG, 0x06),
13094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP_EN, 0x01),
13194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_RESETSM_CNTRL, 0x20),
13294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_MAP, 0x00),
13394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE2_MODE0, 0x01),
13494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE1_MODE0, 0xc9),
13594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_TIMER1, 0xff),
13694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_TIMER2, 0x3f),
13794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SVS_MODE_CLK_SEL, 0x01),
13894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CORE_CLK_EN, 0x00),
13994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CORECLK_DIV_MODE0, 0x0a),
14094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_EP_DIV, 0x19),
14194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_ENABLE1, 0x90),
14294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_DEC_START_MODE0, 0x82),
14394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START3_MODE0, 0x03),
14494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START2_MODE0, 0x55),
14594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START1_MODE0, 0x55),
14694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP3_MODE0, 0x00),
14794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP2_MODE0, 0x0d),
14894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP1_MODE0, 0x04),
14994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_HSCLK_SEL, 0x00),
15094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CP_CTRL_MODE0, 0x08),
15194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_RCTRL_MODE0, 0x16),
15294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_CCTRL_MODE0, 0x34),
15394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CMN_CONFIG, 0x06),
15494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_SELECT, 0x33),
15594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYS_CLK_CTRL, 0x02),
15694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYSCLK_BUF_ENABLE, 0x07),
15794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYSCLK_EN_SEL, 0x04),
15894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN1_MODE0, 0x00),
15994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN0_MODE0, 0x3f),
16094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_BG_TIMER, 0x09),
16194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_EN_CENTER, 0x01),
16294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_PER1, 0x40),
16394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_PER2, 0x01),
16494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_ADJ_PER1, 0x02),
16594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_ADJ_PER2, 0x00),
16694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_STEP_SIZE1, 0x7e),
16794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_STEP_SIZE2, 0x15),
16894a407ccSDmitry Baryshkov };
16994a407ccSDmitry Baryshkov 
17094a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl msm8998_pcie_tx_tbl[] = {
17194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_TX_RES_CODE_LANE_OFFSET_TX, 0x02),
17294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_TX_RCV_DETECT_LVL_2, 0x12),
17394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_TX_HIGHZ_DRVR_EN, 0x10),
17494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_TX_LANE_MODE_1, 0x06),
17594a407ccSDmitry Baryshkov };
17694a407ccSDmitry Baryshkov 
17794a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl msm8998_pcie_rx_tbl[] = {
17894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_CNTRL, 0x03),
17994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_ENABLES, 0x1c),
18094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_DEGLITCH_CNTRL, 0x14),
18194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL2, 0x0a),
18294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL3, 0x04),
18394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL4, 0x1a),
18494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x4b),
18594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SO_GAIN, 0x04),
18694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SO_GAIN_HALF, 0x04),
18794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1, 0x00),
18894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_OFFSET_ADAPTOR_CNTRL2, 0x80),
18994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_INTERFACE_MODE, 0x40),
19094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_PI_CONTROLS, 0x71),
19194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_FASTLOCK_COUNT_LOW, 0x40),
19294a407ccSDmitry Baryshkov };
19394a407ccSDmitry Baryshkov 
19494a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl msm8998_pcie_pcs_tbl[] = {
19594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V3_PCS_ENDPOINT_REFCLK_DRIVE, 0x04),
19694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V3_PCS_OSC_DTCT_ACTIONS, 0x00),
19794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V3_PCS_PWRUP_RESET_DLY_TIME_AUXCLK, 0x01),
19894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V3_PCS_L1SS_WAKEUP_DLY_TIME_AUXCLK_MSB, 0x00),
19994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V3_PCS_L1SS_WAKEUP_DLY_TIME_AUXCLK_LSB, 0x20),
20094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V3_PCS_LP_WAKEUP_DLY_TIME_AUXCLK_MSB, 0x00),
20194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V3_PCS_LP_WAKEUP_DLY_TIME_AUXCLK, 0x01),
20294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V3_PCS_PLL_LOCK_CHK_DLY_TIME, 0x73),
20394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V3_PCS_RX_SIGDET_LVL, 0x99),
20494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V3_PCS_SIGDET_CNTRL, 0x03),
20594a407ccSDmitry Baryshkov };
20694a407ccSDmitry Baryshkov 
20794a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl ipq6018_pcie_serdes_tbl[] = {
20894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_SSC_PER1, 0x7d),
20994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_SSC_PER2, 0x01),
21094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_SSC_STEP_SIZE1_MODE0, 0x0a),
21194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_SSC_STEP_SIZE2_MODE0, 0x05),
21294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_SSC_STEP_SIZE1_MODE1, 0x08),
21394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_SSC_STEP_SIZE2_MODE1, 0x04),
21494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_BIAS_EN_CLKBUFLR_EN, 0x18),
21594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_CLK_ENABLE1, 0x90),
21694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_SYS_CLK_CTRL, 0x02),
21794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_SYSCLK_BUF_ENABLE, 0x07),
21894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_PLL_IVCO, 0x0f),
21994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_LOCK_CMP1_MODE0, 0xd4),
22094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_LOCK_CMP2_MODE0, 0x14),
22194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_LOCK_CMP1_MODE1, 0xaa),
22294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_LOCK_CMP2_MODE1, 0x29),
22394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_BG_TRIM, 0x0f),
22494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_CP_CTRL_MODE0, 0x09),
22594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_CP_CTRL_MODE1, 0x09),
22694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_PLL_RCTRL_MODE0, 0x16),
22794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_PLL_RCTRL_MODE1, 0x16),
22894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_PLL_CCTRL_MODE0, 0x28),
22994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_PLL_CCTRL_MODE1, 0x28),
23094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_BIAS_EN_CTRL_BY_PSM, 0x01),
23194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_SYSCLK_EN_SEL, 0x08),
23294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_RESETSM_CNTRL, 0x20),
23394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_LOCK_CMP_EN, 0x42),
23494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_DEC_START_MODE0, 0x68),
23594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_DEC_START_MODE1, 0x53),
23694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_DIV_FRAC_START1_MODE0, 0xab),
23794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_DIV_FRAC_START2_MODE0, 0xaa),
23894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_DIV_FRAC_START3_MODE0, 0x02),
23994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_DIV_FRAC_START1_MODE1, 0x55),
24094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_DIV_FRAC_START2_MODE1, 0x55),
24194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_DIV_FRAC_START3_MODE1, 0x05),
24294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_INTEGLOOP_GAIN0_MODE0, 0xa0),
24394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_INTEGLOOP_GAIN0_MODE1, 0xa0),
24494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_VCO_TUNE1_MODE0, 0x24),
24594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_VCO_TUNE2_MODE0, 0x02),
24694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_VCO_TUNE1_MODE1, 0xb4),
24794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_VCO_TUNE2_MODE1, 0x03),
24894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_CLK_SELECT, 0x32),
24994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_HSCLK_SEL, 0x01),
25094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_CORE_CLK_EN, 0x00),
25194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_CMN_CONFIG, 0x06),
25294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_SVS_MODE_CLK_SEL, 0x05),
25394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_PLL_CORECLK_DIV_MODE1, 0x08),
25494a407ccSDmitry Baryshkov };
25594a407ccSDmitry Baryshkov 
25694a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl ipq6018_pcie_tx_tbl[] = {
257079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_TX_RES_CODE_LANE_OFFSET_TX, 0x02),
258079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_TX_LANE_MODE_1, 0x06),
259079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_TX_RCV_DETECT_LVL_2, 0x12),
26094a407ccSDmitry Baryshkov };
26194a407ccSDmitry Baryshkov 
26294a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl ipq6018_pcie_rx_tbl[] = {
263079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_FO_GAIN, 0x0c),
264079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SO_GAIN, 0x02),
265079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x7f),
266079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_PI_CONTROLS, 0x70),
267079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL2, 0x61),
268079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL3, 0x04),
269079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL4, 0x1e),
270079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_IDAC_TSETTLE_LOW, 0xc0),
271079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_IDAC_TSETTLE_HIGH, 0x00),
272079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1, 0x73),
273079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_OFFSET_ADAPTOR_CNTRL2, 0x80),
274079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_ENABLES, 0x1c),
275079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_CNTRL, 0x03),
276079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_DEGLITCH_CNTRL, 0x14),
277079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_LOW, 0xf0),
278079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH, 0x01),
279079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH2, 0x2f),
280079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH3, 0xd3),
281079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH4, 0x40),
282079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_LOW, 0x01),
283079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH, 0x02),
284079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH2, 0xc8),
285079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH3, 0x09),
286079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH4, 0xb1),
287079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_LOW, 0x00),
288079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH, 0x02),
289079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH2, 0xc8),
290079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH3, 0x09),
291079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH4, 0xb1),
292079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_DFE_EN_TIMER, 0x04),
29394a407ccSDmitry Baryshkov };
29494a407ccSDmitry Baryshkov 
29594a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl ipq6018_pcie_pcs_tbl[] = {
29660f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_FLL_CNTRL1, 0x01),
29760f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_REFGEN_REQ_CONFIG1, 0x0d),
29860f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_G12S1_TXDEEMPH_M3P5DB, 0x10),
29960f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_RX_SIGDET_LVL, 0xaa),
30060f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_P2U3_WAKEUP_DLY_TIME_AUXCLK_L, 0x01),
30160f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_RX_DCC_CAL_CONFIG, 0x01),
30260f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_EQ_CONFIG5, 0x01),
303af664324SDmitry Baryshkov };
304af664324SDmitry Baryshkov 
305af664324SDmitry Baryshkov static const struct qmp_phy_init_tbl ipq6018_pcie_pcs_misc_tbl[] = {
30660f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_POWER_STATE_CONFIG2, 0x0d),
30760f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_POWER_STATE_CONFIG4, 0x07),
30860f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_ENDPOINT_REFCLK_DRIVE, 0xc1),
30960f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_L1P1_WAKEUP_DLY_TIME_AUXCLK_L, 0x01),
31060f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_L1P2_WAKEUP_DLY_TIME_AUXCLK_L, 0x01),
31160f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_OSC_DTCT_ACTIONS, 0x00),
31260f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_EQ_CONFIG1, 0x11),
31360f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_PRESET_P10_PRE, 0x00),
31460f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_PRESET_P10_POST, 0x58),
31594a407ccSDmitry Baryshkov };
31694a407ccSDmitry Baryshkov 
31794a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl ipq8074_pcie_serdes_tbl[] = {
31894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_BIAS_EN_CLKBUFLR_EN, 0x18),
31994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_CLK_ENABLE1, 0x10),
32094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_BG_TRIM, 0xf),
32194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP_EN, 0x1),
32294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_MAP, 0x0),
32394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_TIMER1, 0xff),
32494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_TIMER2, 0x1f),
32594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_CMN_CONFIG, 0x6),
32694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_PLL_IVCO, 0xf),
32794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_HSCLK_SEL, 0x0),
32894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_SVS_MODE_CLK_SEL, 0x1),
32994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_CORE_CLK_EN, 0x20),
33094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_CORECLK_DIV, 0xa),
33194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_RESETSM_CNTRL, 0x20),
33294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_BG_TIMER, 0xa),
33394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_SYSCLK_EN_SEL, 0xa),
33494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_DEC_START_MODE0, 0x82),
33594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_DIV_FRAC_START3_MODE0, 0x3),
33694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_DIV_FRAC_START2_MODE0, 0x55),
33794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_DIV_FRAC_START1_MODE0, 0x55),
33894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP3_MODE0, 0x0),
33994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP2_MODE0, 0xD),
34094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP1_MODE0, 0xD04),
34194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_CLK_SELECT, 0x33),
34294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_SYS_CLK_CTRL, 0x2),
34394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_SYSCLK_BUF_ENABLE, 0x1f),
34494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_CP_CTRL_MODE0, 0xb),
34594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_PLL_RCTRL_MODE0, 0x16),
34694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_PLL_CCTRL_MODE0, 0x28),
34794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_INTEGLOOP_GAIN1_MODE0, 0x0),
34894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_INTEGLOOP_GAIN0_MODE0, 0x80),
34994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_BIAS_EN_CTRL_BY_PSM, 0x1),
35094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_SSC_EN_CENTER, 0x1),
35194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_SSC_PER1, 0x31),
35294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_SSC_PER2, 0x1),
35394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_SSC_ADJ_PER1, 0x2),
35494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_SSC_ADJ_PER2, 0x0),
35594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_SSC_STEP_SIZE1, 0x2f),
35694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_SSC_STEP_SIZE2, 0x19),
35794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_COM_CLK_EP_DIV, 0x19),
35894a407ccSDmitry Baryshkov };
35994a407ccSDmitry Baryshkov 
36094a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl ipq8074_pcie_tx_tbl[] = {
36194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_TX_HIGHZ_TRANSCEIVEREN_BIAS_DRVR_EN, 0x45),
36294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_TX_LANE_MODE, 0x6),
36394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_TX_RES_CODE_LANE_OFFSET, 0x2),
36494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_TX_RCV_DETECT_LVL_2, 0x12),
365f7c5cedbSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_TX_TX_EMP_POST1_LVL, 0x36),
36694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_TX_SLEW_CNTL, 0x0a),
36794a407ccSDmitry Baryshkov };
36894a407ccSDmitry Baryshkov 
36994a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl ipq8074_pcie_rx_tbl[] = {
37094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_RX_SIGDET_ENABLES, 0x1c),
37194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_RX_SIGDET_DEGLITCH_CNTRL, 0x14),
37294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_RX_RX_EQU_ADAPTOR_CNTRL2, 0x1),
37394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_RX_RX_EQU_ADAPTOR_CNTRL3, 0x0),
37494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_RX_RX_EQU_ADAPTOR_CNTRL4, 0xdb),
37594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x4b),
37694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_RX_UCDR_SO_GAIN, 0x4),
37794a407ccSDmitry Baryshkov };
37894a407ccSDmitry Baryshkov 
37994a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl ipq8074_pcie_pcs_tbl[] = {
3806cad2983SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V2_PCS_ENDPOINT_REFCLK_DRIVE, 0x4),
3816cad2983SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V2_PCS_OSC_DTCT_ACTIONS, 0x0),
3826cad2983SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V2_PCS_PWRUP_RESET_DLY_TIME_AUXCLK, 0x40),
3836cad2983SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V2_PCS_L1SS_WAKEUP_DLY_TIME_AUXCLK_MSB, 0x0),
3846cad2983SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V2_PCS_L1SS_WAKEUP_DLY_TIME_AUXCLK_LSB, 0x40),
3856cad2983SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V2_PCS_PLL_LOCK_CHK_DLY_TIME_AUXCLK_LSB, 0x0),
3866cad2983SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V2_PCS_LP_WAKEUP_DLY_TIME_AUXCLK, 0x40),
387c1ab64aaSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V2_PCS_PLL_LOCK_CHK_DLY_TIME, 0x73),
3886cad2983SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V2_PCS_RX_SIGDET_LVL, 0x99),
3896cad2983SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V2_PCS_TXDEEMPH_M6DB_V0, 0x15),
3906cad2983SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V2_PCS_TXDEEMPH_M3P5DB_V0, 0xe),
39194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG_L(QPHY_SW_RESET, 0x0),
39294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG_L(QPHY_START_CTRL, 0x3),
39394a407ccSDmitry Baryshkov };
39494a407ccSDmitry Baryshkov 
395334fad18SRobert Marko static const struct qmp_phy_init_tbl ipq8074_pcie_gen3_serdes_tbl[] = {
396334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_BIAS_EN_CLKBUFLR_EN, 0x18),
397334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_BIAS_EN_CTRL_BY_PSM, 0x01),
398334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_CLK_SELECT, 0x31),
399334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_PLL_IVCO, 0x0f),
400334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_BG_TRIM, 0x0f),
401334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_CMN_CONFIG, 0x06),
402334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_LOCK_CMP_EN, 0x42),
403334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_RESETSM_CNTRL, 0x20),
404334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_SVS_MODE_CLK_SEL, 0x01),
405334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_VCO_TUNE_MAP, 0x04),
406334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_SVS_MODE_CLK_SEL, 0x05),
407334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_VCO_TUNE_TIMER1, 0xff),
408334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_VCO_TUNE_TIMER2, 0x3f),
409334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_CORE_CLK_EN, 0x30),
410334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_HSCLK_SEL, 0x21),
411334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_DEC_START_MODE0, 0x82),
412334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_DIV_FRAC_START3_MODE0, 0x03),
413334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_DIV_FRAC_START2_MODE0, 0x355),
414334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_DIV_FRAC_START1_MODE0, 0x35555),
415334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_LOCK_CMP2_MODE0, 0x1a),
416334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_LOCK_CMP1_MODE0, 0x1a0a),
417334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_CP_CTRL_MODE0, 0xb),
418334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_PLL_RCTRL_MODE0, 0x16),
419334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_PLL_CCTRL_MODE0, 0x28),
420334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_INTEGLOOP_GAIN1_MODE0, 0x0),
421334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_INTEGLOOP_GAIN0_MODE0, 0x40),
422334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_VCO_TUNE2_MODE0, 0x02),
423334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_VCO_TUNE1_MODE0, 0x24),
424334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_SVS_MODE_CLK_SEL, 0x05),
425334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_CORE_CLK_EN, 0x20),
426334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_CORECLK_DIV, 0xa),
427334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_CLK_SELECT, 0x32),
428334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_SYS_CLK_CTRL, 0x02),
429334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_SYSCLK_BUF_ENABLE, 0x07),
430334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_SYSCLK_EN_SEL, 0x08),
431334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_BG_TIMER, 0xa),
432334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_HSCLK_SEL, 0x1),
433334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_DEC_START_MODE1, 0x68),
434334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_DIV_FRAC_START3_MODE1, 0x2),
435334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_DIV_FRAC_START2_MODE1, 0x2aa),
436334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_DIV_FRAC_START1_MODE1, 0x2aaab),
437334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_CLK_ENABLE1, 0x90),
438334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_LOCK_CMP2_MODE1, 0x34),
439334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_LOCK_CMP1_MODE1, 0x3414),
440334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_CP_CTRL_MODE1, 0x0b),
441334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_PLL_RCTRL_MODE1, 0x16),
442334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_PLL_CCTRL_MODE1, 0x28),
443334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_INTEGLOOP_GAIN1_MODE1, 0x0),
444334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_INTEGLOOP_GAIN0_MODE1, 0x40),
445334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_VCO_TUNE2_MODE1, 0x03),
446334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_VCO_TUNE1_MODE1, 0xb4),
447334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_SVS_MODE_CLK_SEL, 0x05),
448334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_CORE_CLK_EN, 0x0),
449334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_CORECLK_DIV_MODE1, 0x08),
450334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_CLK_EP_DIV_MODE0, 0x19),
451334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_CLK_EP_DIV_MODE1, 0x28),
452334fad18SRobert Marko 	QMP_PHY_INIT_CFG(QSERDES_PLL_CLK_ENABLE1, 0x90),
453334fad18SRobert Marko };
454334fad18SRobert Marko 
455334fad18SRobert Marko static const struct qmp_phy_init_tbl ipq8074_pcie_gen3_tx_tbl[] = {
456079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_TX_RES_CODE_LANE_OFFSET_TX, 0x02),
457079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_TX_RCV_DETECT_LVL_2, 0x12),
458079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_TX_HIGHZ_DRVR_EN, 0x10),
459079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_TX_LANE_MODE_1, 0x06),
460334fad18SRobert Marko };
461334fad18SRobert Marko 
462334fad18SRobert Marko static const struct qmp_phy_init_tbl ipq8074_pcie_gen3_rx_tbl[] = {
463079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_CNTRL, 0x03),
464079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_ENABLES, 0x1c),
465079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_DEGLITCH_CNTRL, 0x14),
466079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL2, 0xe),
467079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL3, 0x4),
468079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL4, 0x1b),
469079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_DFE_EN_TIMER, 0x04),
470079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x7f),
471079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_PI_CONTROLS, 0x70),
472079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1, 0x73),
473079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_OFFSET_ADAPTOR_CNTRL2, 0x80),
474079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_LOW, 0x00),
475079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH, 0x02),
476079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH2, 0xc8),
477079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH3, 0x09),
478079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH4, 0xb1),
479079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_LOW, 0x01),
480079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH, 0x02),
481079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH2, 0xc8),
482079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH3, 0x09),
483079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH4, 0xb1),
484079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_LOW, 0xf0),
485079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH, 0x2),
486079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH2, 0x2f),
487079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH3, 0xd3),
488079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH4, 0x40),
489079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_IDAC_TSETTLE_HIGH, 0x00),
490079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_IDAC_TSETTLE_LOW, 0xc0),
491079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_FO_GAIN, 0x0c),
492079328a9SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SO_GAIN, 0x02),
493334fad18SRobert Marko };
494334fad18SRobert Marko 
495334fad18SRobert Marko static const struct qmp_phy_init_tbl ipq8074_pcie_gen3_pcs_tbl[] = {
49660f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_FLL_CNTRL2, 0x83),
49760f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_FLL_CNT_VAL_L, 0x9),
49860f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_FLL_CNT_VAL_H_TOL, 0x42),
49960f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_FLL_MAN_CODE, 0x40),
50060f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_FLL_CNTRL1, 0x01),
50160f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_P2U3_WAKEUP_DLY_TIME_AUXCLK_H, 0x0),
50260f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_P2U3_WAKEUP_DLY_TIME_AUXCLK_L, 0x1),
50360f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_OSC_DTCT_ACTIONS, 0x0),
50460f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_L1P1_WAKEUP_DLY_TIME_AUXCLK_H, 0x00),
50560f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_L1P1_WAKEUP_DLY_TIME_AUXCLK_L, 0x01),
50660f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_L1P2_WAKEUP_DLY_TIME_AUXCLK_H, 0x00),
50760f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_L1P2_WAKEUP_DLY_TIME_AUXCLK_L, 0x01),
50860f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_EQ_CONFIG1, 0x11),
50960f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_EQ_CONFIG2, 0xb),
51060f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_POWER_STATE_CONFIG4, 0x07),
51160f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_OSC_DTCT_CONFIG2, 0x52),
51260f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_OSC_DTCT_MODE2_CONFIG2, 0x50),
51360f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_OSC_DTCT_MODE2_CONFIG4, 0x1a),
51460f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_OSC_DTCT_MODE2_CONFIG5, 0x6),
51560f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_G12S1_TXDEEMPH_M3P5DB, 0x10),
51660f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_ENDPOINT_REFCLK_DRIVE, 0xc1),
51760f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_RX_DCC_CAL_CONFIG, 0x01),
51860f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_RX_SIGDET_LVL, 0xaa),
51960f23414SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_REFGEN_REQ_CONFIG1, 0x0d),
520334fad18SRobert Marko };
521334fad18SRobert Marko 
52294a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sdm845_qmp_pcie_serdes_tbl[] = {
52394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_BIAS_EN_CLKBUFLR_EN, 0x14),
52494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_SELECT, 0x30),
52594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_IVCO, 0x007),
52694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CMN_CONFIG, 0x06),
52794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP_EN, 0x01),
52894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_RESETSM_CNTRL, 0x20),
52994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_MAP, 0x00),
53094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE2_MODE0, 0x01),
53194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE1_MODE0, 0xc9),
53294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_TIMER1, 0xff),
53394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_TIMER2, 0x3f),
53494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SVS_MODE_CLK_SEL, 0x01),
53594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CORE_CLK_EN, 0x00),
53694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CORECLK_DIV_MODE0, 0x0a),
53794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_EP_DIV, 0x19),
53894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_ENABLE1, 0x90),
53994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_DEC_START_MODE0, 0x82),
54094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START3_MODE0, 0x02),
54194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START2_MODE0, 0xea),
54294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START1_MODE0, 0xab),
54394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP3_MODE0, 0x00),
54494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP2_MODE0, 0x0d),
54594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP1_MODE0, 0x04),
54694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_HSCLK_SEL, 0x00),
54794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CP_CTRL_MODE0, 0x06),
54894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_RCTRL_MODE0, 0x16),
54994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_CCTRL_MODE0, 0x36),
55094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CMN_MODE, 0x01),
55194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_SELECT, 0x33),
55294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYS_CLK_CTRL, 0x02),
55394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYSCLK_BUF_ENABLE, 0x06),
55494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYSCLK_EN_SEL, 0x04),
55594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN1_MODE0, 0x00),
55694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN0_MODE0, 0x3f),
55794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_BG_TIMER, 0x09),
55894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_EN_CENTER, 0x01),
55994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_PER1, 0x40),
56094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_PER2, 0x01),
56194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_ADJ_PER1, 0x02),
56294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_ADJ_PER2, 0x00),
56394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_STEP_SIZE1, 0x7e),
56494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_STEP_SIZE2, 0x15),
56594a407ccSDmitry Baryshkov };
56694a407ccSDmitry Baryshkov 
56794a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sdm845_qmp_pcie_tx_tbl[] = {
56894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_TX_RES_CODE_LANE_OFFSET_TX, 0x02),
56994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_TX_RCV_DETECT_LVL_2, 0x12),
57094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_TX_HIGHZ_DRVR_EN, 0x10),
57194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_TX_LANE_MODE_1, 0x06),
57294a407ccSDmitry Baryshkov };
57394a407ccSDmitry Baryshkov 
57494a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sdm845_qmp_pcie_rx_tbl[] = {
57594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_CNTRL, 0x03),
57694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_ENABLES, 0x10),
57794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_DEGLITCH_CNTRL, 0x14),
57894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL2, 0x0e),
57994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL3, 0x04),
58094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL4, 0x1a),
58194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x4b),
58294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SO_GAIN, 0x04),
58394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SO_GAIN_HALF, 0x04),
58494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1, 0x71),
58594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_MODE_00, 0x59),
58694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_MODE_01, 0x59),
58794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_OFFSET_ADAPTOR_CNTRL2, 0x80),
58894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_INTERFACE_MODE, 0x40),
58994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_PI_CONTROLS, 0x71),
59094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_FASTLOCK_COUNT_LOW, 0x40),
59194a407ccSDmitry Baryshkov };
59294a407ccSDmitry Baryshkov 
59394a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sdm845_qmp_pcie_pcs_tbl[] = {
59494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V3_PCS_ENDPOINT_REFCLK_DRIVE, 0x04),
59594a407ccSDmitry Baryshkov 
59694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNTRL2, 0x83),
59794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNT_VAL_L, 0x09),
59894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNT_VAL_H_TOL, 0xa2),
59994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_MAN_CODE, 0x40),
60094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNTRL1, 0x02),
60194a407ccSDmitry Baryshkov 
60294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V3_PCS_OSC_DTCT_ACTIONS, 0x00),
60394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V3_PCS_PWRUP_RESET_DLY_TIME_AUXCLK, 0x01),
60494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V3_PCS_L1SS_WAKEUP_DLY_TIME_AUXCLK_MSB, 0x00),
60594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V3_PCS_L1SS_WAKEUP_DLY_TIME_AUXCLK_LSB, 0x20),
60694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V3_PCS_LP_WAKEUP_DLY_TIME_AUXCLK_MSB, 0x00),
60794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V3_PCS_LP_WAKEUP_DLY_TIME_AUXCLK, 0x01),
60894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V3_PCS_PLL_LOCK_CHK_DLY_TIME, 0x73),
60994a407ccSDmitry Baryshkov 
61094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V3_PCS_RX_SIGDET_LVL, 0xbb),
61194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V3_PCS_SIGDET_CNTRL, 0x03),
61294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V3_PCS_REFGEN_REQ_CONFIG1, 0x0d),
61394a407ccSDmitry Baryshkov 
61494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V3_PCS_POWER_STATE_CONFIG4, 0x00),
61594a407ccSDmitry Baryshkov };
61694a407ccSDmitry Baryshkov 
61794a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sdm845_qmp_pcie_pcs_misc_tbl[] = {
61894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V3_PCS_MISC_OSC_DTCT_CONFIG2, 0x52),
61994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V3_PCS_MISC_OSC_DTCT_MODE2_CONFIG2, 0x10),
62094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V3_PCS_MISC_OSC_DTCT_MODE2_CONFIG4, 0x1a),
62194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V3_PCS_MISC_OSC_DTCT_MODE2_CONFIG5, 0x06),
62294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V3_PCS_MISC_PCIE_INT_AUX_CLK_CONFIG1, 0x00),
62394a407ccSDmitry Baryshkov };
62494a407ccSDmitry Baryshkov 
62594a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sdm845_qhp_pcie_serdes_tbl[] = {
62694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_SYSCLK_EN_SEL, 0x27),
62794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_SSC_EN_CENTER, 0x01),
62894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_SSC_PER1, 0x31),
62994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_SSC_PER2, 0x01),
63094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_SSC_STEP_SIZE1, 0xde),
63194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_SSC_STEP_SIZE2, 0x07),
63294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_SSC_STEP_SIZE1_MODE1, 0x4c),
63394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_SSC_STEP_SIZE2_MODE1, 0x06),
63494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_BIAS_EN_CKBUFLR_EN, 0x18),
63594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_CLK_ENABLE1, 0xb0),
63694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_LOCK_CMP1_MODE0, 0x8c),
63794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_LOCK_CMP2_MODE0, 0x20),
63894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_LOCK_CMP1_MODE1, 0x14),
63994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_LOCK_CMP2_MODE1, 0x34),
64094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_CP_CTRL_MODE0, 0x06),
64194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_CP_CTRL_MODE1, 0x06),
64294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_PLL_RCTRL_MODE0, 0x16),
64394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_PLL_RCTRL_MODE1, 0x16),
64494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_PLL_CCTRL_MODE0, 0x36),
64594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_PLL_CCTRL_MODE1, 0x36),
64694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_RESTRIM_CTRL2, 0x05),
64794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_LOCK_CMP_EN, 0x42),
64894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_DEC_START_MODE0, 0x82),
64994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_DEC_START_MODE1, 0x68),
65094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_DIV_FRAC_START1_MODE0, 0x55),
65194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_DIV_FRAC_START2_MODE0, 0x55),
65294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_DIV_FRAC_START3_MODE0, 0x03),
65394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_DIV_FRAC_START1_MODE1, 0xab),
65494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_DIV_FRAC_START2_MODE1, 0xaa),
65594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_DIV_FRAC_START3_MODE1, 0x02),
65694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_INTEGLOOP_GAIN0_MODE0, 0x3f),
65794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_INTEGLOOP_GAIN0_MODE1, 0x3f),
65894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_VCO_TUNE_MAP, 0x10),
65994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_CLK_SELECT, 0x04),
66094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_HSCLK_SEL1, 0x30),
66194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_CORECLK_DIV, 0x04),
66294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_CORE_CLK_EN, 0x73),
66394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_CMN_CONFIG, 0x0c),
66494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_SVS_MODE_CLK_SEL, 0x15),
66594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_CORECLK_DIV_MODE1, 0x04),
66694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_CMN_MODE, 0x01),
66794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_VREGCLK_DIV1, 0x22),
66894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_VREGCLK_DIV2, 0x00),
66994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_BGV_TRIM, 0x20),
67094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_BG_CTRL, 0x07),
67194a407ccSDmitry Baryshkov };
67294a407ccSDmitry Baryshkov 
67394a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sdm845_qhp_pcie_tx_tbl[] = {
67494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_DRVR_CTRL0, 0x00),
67594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_DRVR_TAP_EN, 0x0d),
67694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_TX_BAND_MODE, 0x01),
67794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_LANE_MODE, 0x1a),
67894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_PARALLEL_RATE, 0x2f),
67994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_CML_CTRL_MODE0, 0x09),
68094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_CML_CTRL_MODE1, 0x09),
68194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_CML_CTRL_MODE2, 0x1b),
68294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_PREAMP_CTRL_MODE1, 0x01),
68394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_PREAMP_CTRL_MODE2, 0x07),
68494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_MIXER_CTRL_MODE0, 0x31),
68594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_MIXER_CTRL_MODE1, 0x31),
68694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_MIXER_CTRL_MODE2, 0x03),
68794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_CTLE_THRESH_DFE, 0x02),
68894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_CGA_THRESH_DFE, 0x00),
68994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RXENGINE_EN0, 0x12),
69094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_CTLE_TRAIN_TIME, 0x25),
69194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_CTLE_DFE_OVRLP_TIME, 0x00),
69294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_DFE_REFRESH_TIME, 0x05),
69394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_DFE_ENABLE_TIME, 0x01),
69494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_VGA_GAIN, 0x26),
69594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_DFE_GAIN, 0x12),
69694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_EQ_GAIN, 0x04),
69794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_OFFSET_GAIN, 0x04),
69894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_PRE_GAIN, 0x09),
69994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_EQ_INTVAL, 0x15),
70094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_EDAC_INITVAL, 0x28),
70194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RXEQ_INITB0, 0x7f),
70294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RXEQ_INITB1, 0x07),
70394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RCVRDONE_THRESH1, 0x04),
70494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RXEQ_CTRL, 0x70),
70594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_UCDR_FO_GAIN_MODE0, 0x8b),
70694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_UCDR_FO_GAIN_MODE1, 0x08),
70794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_UCDR_FO_GAIN_MODE2, 0x0a),
70894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_UCDR_SO_GAIN_MODE0, 0x03),
70994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_UCDR_SO_GAIN_MODE1, 0x04),
71094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_UCDR_SO_GAIN_MODE2, 0x04),
71194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_UCDR_SO_CONFIG, 0x0c),
71294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RX_BAND, 0x02),
71394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RX_RCVR_PATH1_MODE0, 0x5c),
71494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RX_RCVR_PATH1_MODE1, 0x3e),
71594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RX_RCVR_PATH1_MODE2, 0x3f),
71694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_SIGDET_ENABLES, 0x01),
71794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_SIGDET_CNTRL, 0xa0),
71894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_SIGDET_DEGLITCH_CNTRL, 0x08),
71994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_DCC_GAIN, 0x01),
72094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RX_EN_SIGNAL, 0xc3),
72194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_PSM_RX_EN_CAL, 0x00),
72294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RX_MISC_CNTRL0, 0xbc),
72394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_TS0_TIMER, 0x7f),
72494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_DLL_HIGHDATARATE, 0x15),
72594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_DRVR_CTRL1, 0x0c),
72694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_DRVR_CTRL2, 0x0f),
72794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RX_RESETCODE_OFFSET, 0x04),
72894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_VGA_INITVAL, 0x20),
72994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RSM_START, 0x01),
73094a407ccSDmitry Baryshkov };
73194a407ccSDmitry Baryshkov 
73294a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sdm845_qhp_pcie_rx_tbl[] = {
73394a407ccSDmitry Baryshkov };
73494a407ccSDmitry Baryshkov 
73594a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sdm845_qhp_pcie_pcs_tbl[] = {
73694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_PHY_POWER_STATE_CONFIG, 0x3f),
73794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_PHY_PCS_TX_RX_CONFIG, 0x50),
73894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_PHY_TXMGN_MAIN_V0_M3P5DB, 0x19),
73994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_PHY_TXMGN_POST_V0_M3P5DB, 0x07),
74094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_PHY_TXMGN_MAIN_V0_M6DB, 0x17),
74194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_PHY_TXMGN_POST_V0_M6DB, 0x09),
74294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_PHY_POWER_STATE_CONFIG5, 0x9f),
74394a407ccSDmitry Baryshkov };
74494a407ccSDmitry Baryshkov 
74594a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sc8180x_qmp_pcie_serdes_tbl[] = {
74694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_SYSCLK_EN_SEL, 0x08),
74794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_CLK_SELECT, 0x34),
74894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_CORECLK_DIV_MODE1, 0x08),
74994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_IVCO, 0x0f),
75094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP_EN, 0x42),
75194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE1_MODE0, 0x24),
75294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE2_MODE1, 0x03),
75394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE1_MODE1, 0xb4),
75494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE_MAP, 0x02),
75594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_HSCLK_SEL, 0x11),
75694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_DEC_START_MODE0, 0x82),
75794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START3_MODE0, 0x03),
75894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START2_MODE0, 0x55),
75994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START1_MODE0, 0x55),
76094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP2_MODE0, 0x1a),
76194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP1_MODE0, 0x0a),
76294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_DEC_START_MODE1, 0x68),
76394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START3_MODE1, 0x02),
76494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START2_MODE1, 0xaa),
76594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START1_MODE1, 0xab),
76694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP2_MODE1, 0x34),
76794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP1_MODE1, 0x14),
76894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_HSCLK_SEL, 0x01),
76994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_CP_CTRL_MODE0, 0x06),
77094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_RCTRL_MODE0, 0x16),
77194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_CCTRL_MODE0, 0x36),
77294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_CP_CTRL_MODE1, 0x06),
77394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_RCTRL_MODE1, 0x16),
77494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_CCTRL_MODE1, 0x36),
77594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE2_MODE0, 0x1e),
77694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE1_MODE0, 0xca),
77794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE2_MODE1, 0x18),
77894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE1_MODE1, 0xa2),
77994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_SYSCLK_BUF_ENABLE, 0x07),
78094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_EN_CENTER, 0x01),
78194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_PER1, 0x31),
78294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_PER2, 0x01),
78394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_STEP_SIZE1_MODE0, 0xde),
78494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_STEP_SIZE2_MODE0, 0x07),
78594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_STEP_SIZE1_MODE1, 0x4c),
78694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_STEP_SIZE2_MODE1, 0x06),
78794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_CLK_ENABLE1, 0x90),
78894a407ccSDmitry Baryshkov };
78994a407ccSDmitry Baryshkov 
79094a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sc8180x_qmp_pcie_tx_tbl[] = {
79194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_TX_RCV_DETECT_LVL_2, 0x12),
79294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_TX_LANE_MODE_1, 0x5),
79394a407ccSDmitry Baryshkov };
79494a407ccSDmitry Baryshkov 
79594a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sc8180x_qmp_pcie_rx_tbl[] = {
79694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_CNTRL, 0x03),
79794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_ENABLES, 0x1c),
79894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_DEGLITCH_CNTRL, 0x14),
79994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL1, 0x07),
80094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL2, 0x6e),
80194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL3, 0x6e),
80294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL4, 0x4a),
80394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_DFE_EN_TIMER, 0x04),
80494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x7f),
80594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_PI_CONTROLS, 0x70),
80694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1, 0x17),
80794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_VGA_CAL_CNTRL1, 0x54),
80894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_VGA_CAL_CNTRL2, 0x37),
80994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_LOW, 0xd4),
81094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH, 0x54),
81194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH2, 0xdb),
81294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH3, 0x39),
81394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH4, 0x31),
81494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_LOW, 0x24),
81594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH, 0xe4),
81694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH2, 0xec),
81794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH3, 0x39),
81894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH4, 0x36),
81994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_LOW, 0x7f),
82094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH, 0xff),
82194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH2, 0xff),
82294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH3, 0xdb),
82394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH4, 0x75),
82494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_IDAC_TSETTLE_HIGH, 0x00),
82594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_IDAC_TSETTLE_LOW, 0xc0),
82694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_AUX_DATA_TCOARSE_TFINE, 0xa0),
82794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RCLK_AUXDATA_SEL, 0xc0),
82894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_DCC_CTRL1, 0x0c),
82994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_GM_CAL, 0x05),
83094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_FO_GAIN, 0x0c),
83194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SO_GAIN, 0x03),
83294a407ccSDmitry Baryshkov };
83394a407ccSDmitry Baryshkov 
83494a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sc8180x_qmp_pcie_pcs_tbl[] = {
83594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_P2U3_WAKEUP_DLY_TIME_AUXCLK_L, 0x01),
83694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_RX_SIGDET_LVL, 0xaa),
83794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_RATE_SLEW_CNTRL1, 0x0b),
83894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_REFGEN_REQ_CONFIG1, 0x0d),
83994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_EQ_CONFIG5, 0x01),
84094a407ccSDmitry Baryshkov };
84194a407ccSDmitry Baryshkov 
84294a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sc8180x_qmp_pcie_pcs_misc_tbl[] = {
84394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_OSC_DTCT_ACTIONS, 0x00),
84494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_L1P1_WAKEUP_DLY_TIME_AUXCLK_L, 0x01),
84594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_L1P2_WAKEUP_DLY_TIME_AUXCLK_L, 0x01),
84694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_INT_AUX_CLK_CONFIG1, 0x00),
84794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_PRESET_P10_PRE, 0x00),
84894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_PRESET_P10_POST, 0x58),
84994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_ENDPOINT_REFCLK_DRIVE, 0xc1),
85094a407ccSDmitry Baryshkov };
85194a407ccSDmitry Baryshkov 
85294a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8250_qmp_pcie_serdes_tbl[] = {
85394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_SYSCLK_EN_SEL, 0x08),
85494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_CLK_SELECT, 0x34),
85594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_CORECLK_DIV_MODE1, 0x08),
85694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_IVCO, 0x0f),
85794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP_EN, 0x42),
85894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE1_MODE0, 0x24),
85994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE2_MODE1, 0x03),
86094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE1_MODE1, 0xb4),
86194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE_MAP, 0x02),
86294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_HSCLK_SEL, 0x11),
86394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_DEC_START_MODE0, 0x82),
86494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START3_MODE0, 0x03),
86594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START2_MODE0, 0x55),
86694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START1_MODE0, 0x55),
86794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP2_MODE0, 0x1a),
86894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP1_MODE0, 0x0a),
86994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_DEC_START_MODE1, 0x68),
87094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START3_MODE1, 0x02),
87194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START2_MODE1, 0xaa),
87294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START1_MODE1, 0xab),
87394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP2_MODE1, 0x34),
87494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP1_MODE1, 0x14),
87594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_HSCLK_SEL, 0x01),
87694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_CP_CTRL_MODE0, 0x06),
87794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_RCTRL_MODE0, 0x16),
87894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_CCTRL_MODE0, 0x36),
87994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_CP_CTRL_MODE1, 0x06),
88094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_RCTRL_MODE1, 0x16),
88194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_CCTRL_MODE1, 0x36),
88294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE2_MODE0, 0x1e),
88394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE1_MODE0, 0xca),
88494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE2_MODE1, 0x18),
88594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE1_MODE1, 0xa2),
88694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_EN_CENTER, 0x01),
88794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_PER1, 0x31),
88894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_PER2, 0x01),
88994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_STEP_SIZE1_MODE0, 0xde),
89094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_STEP_SIZE2_MODE0, 0x07),
89194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_STEP_SIZE1_MODE1, 0x4c),
89294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_STEP_SIZE2_MODE1, 0x06),
89394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_CLK_ENABLE1, 0x90),
89494a407ccSDmitry Baryshkov };
89594a407ccSDmitry Baryshkov 
89694a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8250_qmp_gen3x1_pcie_serdes_tbl[] = {
89794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_SYSCLK_BUF_ENABLE, 0x07),
89894a407ccSDmitry Baryshkov };
89994a407ccSDmitry Baryshkov 
90094a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8250_qmp_pcie_tx_tbl[] = {
90194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_TX_RCV_DETECT_LVL_2, 0x12),
90294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_TX_LANE_MODE_1, 0x35),
90394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_TX_RES_CODE_LANE_OFFSET_TX, 0x11),
90494a407ccSDmitry Baryshkov };
90594a407ccSDmitry Baryshkov 
90694a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8250_qmp_pcie_rx_tbl[] = {
90794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_FO_GAIN, 0x0c),
90894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SO_GAIN, 0x03),
90994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_GM_CAL, 0x1b),
91094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_IDAC_TSETTLE_HIGH, 0x00),
91194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_IDAC_TSETTLE_LOW, 0xc0),
91294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_AUX_DATA_TCOARSE_TFINE, 0x30),
91394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_VGA_CAL_CNTRL1, 0x04),
91494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_VGA_CAL_CNTRL2, 0x07),
91594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x7f),
91694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_PI_CONTROLS, 0x70),
91794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL2, 0x0e),
91894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL3, 0x4a),
91994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL4, 0x0f),
92094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_CNTRL, 0x03),
92194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_ENABLES, 0x1c),
92294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_DEGLITCH_CNTRL, 0x1e),
92394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1, 0x17),
92494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_LOW, 0xd4),
92594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH, 0x54),
92694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH2, 0xdb),
92794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH3, 0x3b),
92894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH4, 0x31),
92994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_LOW, 0x24),
93094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH2, 0xff),
93194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH3, 0x7f),
93294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_DCC_CTRL1, 0x0c),
93394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH, 0xe4),
93494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH2, 0xec),
93594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH3, 0x3b),
93694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH4, 0x36),
93794a407ccSDmitry Baryshkov };
93894a407ccSDmitry Baryshkov 
93994a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8250_qmp_gen3x1_pcie_rx_tbl[] = {
94094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RCLK_AUXDATA_SEL, 0x00),
94194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL1, 0x00),
94294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_DFE_EN_TIMER, 0x04),
94394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_LOW, 0x3f),
94494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH4, 0x14),
94594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_DFE_CTLE_POST_CAL_OFFSET, 0x30),
94694a407ccSDmitry Baryshkov };
94794a407ccSDmitry Baryshkov 
94894a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8250_qmp_pcie_pcs_tbl[] = {
94994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_P2U3_WAKEUP_DLY_TIME_AUXCLK_L, 0x01),
95094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_RX_SIGDET_LVL, 0x77),
95194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_RATE_SLEW_CNTRL1, 0x0b),
95294a407ccSDmitry Baryshkov };
95394a407ccSDmitry Baryshkov 
95494a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8250_qmp_gen3x1_pcie_pcs_tbl[] = {
95594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_REFGEN_REQ_CONFIG1, 0x0d),
95694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_EQ_CONFIG5, 0x12),
95794a407ccSDmitry Baryshkov };
95894a407ccSDmitry Baryshkov 
95994a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8250_qmp_pcie_pcs_misc_tbl[] = {
96094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_OSC_DTCT_ACTIONS, 0x00),
96194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_L1P1_WAKEUP_DLY_TIME_AUXCLK_L, 0x01),
96294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_L1P2_WAKEUP_DLY_TIME_AUXCLK_L, 0x01),
96394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_PRESET_P6_P7_PRE, 0x33),
96494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_PRESET_P10_PRE, 0x00),
96594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_PRESET_P10_POST, 0x58),
96694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_ENDPOINT_REFCLK_DRIVE, 0xc1),
96794a407ccSDmitry Baryshkov };
96894a407ccSDmitry Baryshkov 
96994a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8250_qmp_gen3x1_pcie_pcs_misc_tbl[] = {
97094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_INT_AUX_CLK_CONFIG1, 0x00),
97194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_EQ_CONFIG2, 0x0f),
97294a407ccSDmitry Baryshkov };
97394a407ccSDmitry Baryshkov 
97494a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8250_qmp_gen3x2_pcie_tx_tbl[] = {
97594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_TX_PI_QEC_CTRL, 0x20),
97694a407ccSDmitry Baryshkov };
97794a407ccSDmitry Baryshkov 
97894a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8250_qmp_gen3x2_pcie_rx_tbl[] = {
97994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL1, 0x04),
98094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_LOW, 0xbf),
98194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH4, 0x15),
98294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_RX_DFE_CTLE_POST_CAL_OFFSET, 0x38),
98394a407ccSDmitry Baryshkov };
98494a407ccSDmitry Baryshkov 
98594a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8250_qmp_gen3x2_pcie_pcs_tbl[] = {
98694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_REFGEN_REQ_CONFIG1, 0x05),
98794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_EQ_CONFIG2, 0x0f),
98894a407ccSDmitry Baryshkov };
98994a407ccSDmitry Baryshkov 
99094a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8250_qmp_gen3x2_pcie_pcs_misc_tbl[] = {
99194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_POWER_STATE_CONFIG2, 0x0d),
99294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_POWER_STATE_CONFIG4, 0x07),
99394a407ccSDmitry Baryshkov };
99494a407ccSDmitry Baryshkov 
99594a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sdx55_qmp_pcie_serdes_tbl[] = {
99694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_BG_TIMER, 0x02),
99794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIAS_EN_CLKBUFLR_EN, 0x18),
99894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_SYS_CLK_CTRL, 0x07),
99994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_IVCO, 0x0f),
100094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_CP_CTRL_MODE0, 0x0a),
100194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_CP_CTRL_MODE1, 0x0a),
100294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_RCTRL_MODE0, 0x19),
100394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_RCTRL_MODE1, 0x19),
100494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_CCTRL_MODE0, 0x03),
100594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_CCTRL_MODE1, 0x03),
100694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_SYSCLK_EN_SEL, 0x00),
100794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP_EN, 0x46),
100894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP_CFG, 0x04),
100994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP1_MODE0, 0x7f),
101094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP2_MODE0, 0x02),
101194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP1_MODE1, 0xff),
101294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP2_MODE1, 0x04),
101394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_DEC_START_MODE0, 0x4b),
101494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_DEC_START_MODE1, 0x50),
101594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START3_MODE0, 0x00),
101694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_INTEGLOOP_GAIN0_MODE0, 0xfb),
101794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_INTEGLOOP_GAIN1_MODE0, 0x01),
101894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_INTEGLOOP_GAIN0_MODE1, 0xfb),
101994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_INTEGLOOP_GAIN1_MODE1, 0x01),
102094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE_MAP, 0x02),
102194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_HSCLK_SEL, 0x12),
102294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_HSCLK_HS_SWITCH_SEL, 0x00),
102394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_CORECLK_DIV_MODE0, 0x05),
102494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_CORECLK_DIV_MODE1, 0x04),
102594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_CMN_CONFIG, 0x04),
102694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_CMN_MISC1, 0x88),
10271195c1daSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_CMN_MISC2, 0x03),
102894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_CMN_MODE, 0x17),
102994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_DC_LEVEL_CTRL, 0x0b),
103094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE1_MODE0, 0x56),
103194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE2_MODE0, 0x1d),
103294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE1_MODE1, 0x4b),
103394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE2_MODE1, 0x1f),
103494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_HSCLK_SEL, 0x22),
103594a407ccSDmitry Baryshkov };
103694a407ccSDmitry Baryshkov 
103794a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sdx55_qmp_pcie_tx_tbl[] = {
103894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_20_TX_LANE_MODE_1, 0x05),
103994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_20_TX_LANE_MODE_2, 0xf6),
104094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_20_TX_LANE_MODE_3, 0x13),
104194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_20_TX_VMODE_CTRL1, 0x00),
104294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_20_TX_PI_QEC_CTRL, 0x00),
104394a407ccSDmitry Baryshkov };
104494a407ccSDmitry Baryshkov 
104594a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sdx55_qmp_pcie_rx_tbl[] = {
104694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_FO_GAIN_RATE2, 0x0c),
104794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_UCDR_PI_CONTROLS, 0x16),
104894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_AUX_DATA_TCOARSE_TFINE, 0x7f),
104994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_DFE_3, 0x55),
105094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_DFE_DAC_ENABLE1, 0x0c),
105194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_DFE_DAC_ENABLE2, 0x00),
105294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_VGA_CAL_CNTRL2, 0x08),
105394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1, 0x27),
105494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE_0_1_B1, 0x1a),
105594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE_0_1_B2, 0x5a),
105694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE_0_1_B3, 0x09),
105794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE_0_1_B4, 0x37),
105894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE2_B0, 0xbd),
105994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE2_B1, 0xf9),
106094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE2_B2, 0xbf),
106194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE2_B3, 0xce),
106294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE2_B4, 0x62),
106394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE3_B0, 0xbf),
106494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE3_B1, 0x7d),
106594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE3_B2, 0xbf),
106694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE3_B3, 0xcf),
106794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_RX_MODE_RATE3_B4, 0xd6),
106894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_PHPRE_CTRL, 0xa0),
106994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_DFE_CTLE_POST_CAL_OFFSET, 0x38),
107094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V4_20_RX_MARG_COARSE_CTRL2, 0x12),
107194a407ccSDmitry Baryshkov };
107294a407ccSDmitry Baryshkov 
107394a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sdx55_qmp_pcie_pcs_tbl[] = {
107494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_20_PCS_RX_SIGDET_LVL, 0x77),
107594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_20_PCS_EQ_CONFIG2, 0x01),
107694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_20_PCS_EQ_CONFIG4, 0x16),
107794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_20_PCS_EQ_CONFIG5, 0x02),
107894a407ccSDmitry Baryshkov };
107994a407ccSDmitry Baryshkov 
108094a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sdx55_qmp_pcie_pcs_misc_tbl[] = {
108194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_20_PCS_PCIE_EQ_CONFIG1, 0x17),
108294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_20_PCS_PCIE_G3_RXEQEVAL_TIME, 0x13),
108394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_20_PCS_PCIE_G4_RXEQEVAL_TIME, 0x13),
108494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_20_PCS_PCIE_G4_EQ_CONFIG2, 0x01),
108594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_20_PCS_PCIE_G4_EQ_CONFIG5, 0x02),
108694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_20_PCS_LANE1_INSIG_SW_CTRL2, 0x00),
108794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V4_20_PCS_LANE1_INSIG_MX_CTRL2, 0x00),
108894a407ccSDmitry Baryshkov };
108994a407ccSDmitry Baryshkov 
109094a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8450_qmp_gen3x1_pcie_serdes_tbl[] = {
109194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_SYSCLK_EN_SEL, 0x08),
109294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_CLK_SELECT, 0x34),
109394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_CORECLK_DIV_MODE1, 0x08),
109494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_IVCO, 0x0f),
109594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP_EN, 0x42),
109694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_VCO_TUNE1_MODE0, 0x24),
109794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_VCO_TUNE2_MODE1, 0x03),
109894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_VCO_TUNE1_MODE1, 0xb4),
109994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_VCO_TUNE_MAP, 0x02),
110094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_BIN_VCOCAL_HSCLK_SEL, 0x11),
110194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_DEC_START_MODE0, 0x82),
110294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START3_MODE0, 0x03),
110394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START2_MODE0, 0x55),
110494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START1_MODE0, 0x55),
110594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP2_MODE0, 0x1a),
110694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP1_MODE0, 0x0a),
110794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_DEC_START_MODE1, 0x68),
110894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START3_MODE1, 0x02),
110994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START2_MODE1, 0xaa),
111094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START1_MODE1, 0xab),
111194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP2_MODE1, 0x34),
111294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP1_MODE1, 0x14),
111394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_HSCLK_SEL, 0x01),
111494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_CP_CTRL_MODE0, 0x06),
111594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_RCTRL_MODE0, 0x16),
111694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_CCTRL_MODE0, 0x36),
111794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_CP_CTRL_MODE1, 0x06),
111894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_RCTRL_MODE1, 0x16),
111994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_CCTRL_MODE1, 0x36),
112094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_BIN_VCOCAL_CMP_CODE2_MODE0, 0x1e),
112194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_BIN_VCOCAL_CMP_CODE1_MODE0, 0xca),
112294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_BIN_VCOCAL_CMP_CODE2_MODE1, 0x18),
112394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_BIN_VCOCAL_CMP_CODE1_MODE1, 0xa2),
112494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_SYSCLK_BUF_ENABLE, 0x07),
112594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_EN_CENTER, 0x01),
112694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_PER1, 0x31),
112794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_PER2, 0x01),
112894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_STEP_SIZE1_MODE0, 0xde),
112994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_STEP_SIZE2_MODE0, 0x07),
113094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_STEP_SIZE1_MODE1, 0x4c),
113194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_STEP_SIZE2_MODE1, 0x06),
113294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_CLK_ENABLE1, 0x90),
113394a407ccSDmitry Baryshkov };
113494a407ccSDmitry Baryshkov 
113594a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8450_qmp_gen3x1_pcie_tx_tbl[] = {
113694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_TX_PI_QEC_CTRL, 0x20),
113794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_TX_LANE_MODE_1, 0x75),
113894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_TX_LANE_MODE_4, 0x3f),
113994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_TX_RES_CODE_LANE_OFFSET_TX, 0x16),
114094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_TX_RES_CODE_LANE_OFFSET_RX, 0x04),
114194a407ccSDmitry Baryshkov };
114294a407ccSDmitry Baryshkov 
114394a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8450_qmp_gen3x1_pcie_rx_tbl[] = {
114494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_00_LOW, 0x7f),
114594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_00_HIGH, 0xff),
114694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_00_HIGH2, 0xbf),
114794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_00_HIGH3, 0x3f),
114894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_00_HIGH4, 0xd8),
114994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_01_LOW, 0xdc),
115094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_01_HIGH, 0xdc),
115194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_01_HIGH2, 0x5c),
115294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_01_HIGH3, 0x34),
115394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_01_HIGH4, 0xa6),
115494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_10_HIGH3, 0x34),
115594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_10_HIGH4, 0x38),
115694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_RX_VGA_CAL_CNTRL2, 0x07),
115794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_RX_GM_CAL, 0x00),
115894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_RX_UCDR_SB2_THRESH1, 0x08),
115994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_RX_UCDR_SB2_THRESH2, 0x08),
116094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_RX_UCDR_PI_CONTROLS, 0xf0),
116194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_RX_DFE_CTLE_POST_CAL_OFFSET, 0x38),
116294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_RX_TX_ADAPT_POST_THRESH, 0xf0),
116394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_EQU_ADAPTOR_CNTRL4, 0x07),
116494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_RX_UCDR_FO_GAIN, 0x09),
116594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_RX_UCDR_SO_GAIN, 0x05),
116694a407ccSDmitry Baryshkov };
116794a407ccSDmitry Baryshkov 
116894a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8450_qmp_gen3x1_pcie_pcs_tbl[] = {
116994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V5_PCS_RX_SIGDET_LVL, 0x77),
117094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V5_PCS_RATE_SLEW_CNTRL1, 0x0b),
117194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V5_PCS_REFGEN_REQ_CONFIG1, 0x05),
117294a407ccSDmitry Baryshkov };
117394a407ccSDmitry Baryshkov 
117494a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8450_qmp_gen3x1_pcie_pcs_misc_tbl[] = {
117594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V5_PCS_PCIE_OSC_DTCT_ACTIONS, 0x00),
117694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V5_PCS_PCIE_INT_AUX_CLK_CONFIG1, 0x00),
117794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V5_PCS_PCIE_EQ_CONFIG2, 0x0f),
117894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V5_PCS_PCIE_ENDPOINT_REFCLK_DRIVE, 0xc1),
117994a407ccSDmitry Baryshkov };
118094a407ccSDmitry Baryshkov 
118194a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8450_qmp_gen4x2_pcie_serdes_tbl[] = {
1182f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_BIAS_EN_CLKBUFLR_EN, 0x14),
1183f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_IVCO, 0x0f),
1184f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP_EN, 0x46),
1185f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP_CFG, 0x04),
1186f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_VCO_TUNE_MAP, 0x02),
1187f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_HSCLK_SEL, 0x12),
1188f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_HSCLK_HS_SWITCH_SEL, 0x00),
1189f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_CORECLK_DIV_MODE0, 0x0a),
1190f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_CORECLK_DIV_MODE1, 0x04),
1191f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_CMN_MISC1, 0x88),
1192f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_CMN_CONFIG, 0x06),
1193f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_CMN_MODE, 0x14),
1194f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_VCO_DC_LEVEL_CTRL, 0x0f),
1195f5682f13SDmitry Baryshkov };
1196f5682f13SDmitry Baryshkov 
1197f5682f13SDmitry Baryshkov static const struct qmp_phy_init_tbl sm8450_qmp_gen4x2_pcie_rc_serdes_tbl[] = {
119894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_PER1, 0x31),
119994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_PER2, 0x01),
120094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_STEP_SIZE1_MODE0, 0xde),
120194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_STEP_SIZE2_MODE0, 0x07),
120294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_STEP_SIZE1_MODE1, 0x97),
120394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_STEP_SIZE2_MODE1, 0x0c),
120494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_CLK_ENABLE1, 0x90),
120594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_CP_CTRL_MODE0, 0x06),
120694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_CP_CTRL_MODE1, 0x06),
120794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_RCTRL_MODE0, 0x16),
120894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_RCTRL_MODE1, 0x16),
120994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_CCTRL_MODE0, 0x36),
121094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_CCTRL_MODE1, 0x36),
121194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_SYSCLK_EN_SEL, 0x08),
121294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP1_MODE0, 0x0a),
121394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP2_MODE0, 0x1a),
121494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP1_MODE1, 0x14),
121594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP2_MODE1, 0x34),
121694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_DEC_START_MODE0, 0x82),
121794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_DEC_START_MODE1, 0xd0),
121894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START1_MODE0, 0x55),
121994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START2_MODE0, 0x55),
122094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START3_MODE0, 0x03),
122194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START1_MODE1, 0x55),
122294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START2_MODE1, 0x55),
122394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START3_MODE1, 0x05),
122494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_CLK_SELECT, 0x34),
122594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_CORE_CLK_EN, 0x20),
122694a407ccSDmitry Baryshkov };
122794a407ccSDmitry Baryshkov 
122894a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8450_qmp_gen4x2_pcie_tx_tbl[] = {
122994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_TX_LANE_MODE_1, 0x05),
123094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_TX_LANE_MODE_2, 0xf6),
123194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_TX_RES_CODE_LANE_OFFSET_TX, 0x1a),
123294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_TX_RES_CODE_LANE_OFFSET_RX, 0x0c),
123394a407ccSDmitry Baryshkov };
123494a407ccSDmitry Baryshkov 
123594a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8450_qmp_gen4x2_pcie_rx_tbl[] = {
123694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_UCDR_PI_CONTROLS, 0x16),
123794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_DFE_CTLE_POST_CAL_OFFSET, 0x38),
123894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE_0_1_B1, 0xcc),
123994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE_0_1_B2, 0x12),
124094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE_0_1_B3, 0xcc),
124194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE_0_1_B5, 0x4a),
124294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE_0_1_B6, 0x29),
124394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE2_B0, 0xc5),
124494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE2_B1, 0xad),
124594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE2_B2, 0xb6),
124694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE2_B3, 0xc0),
124794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE2_B4, 0x1f),
124894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE2_B5, 0xfb),
124994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE2_B6, 0x0f),
125094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE3_B0, 0xc7),
125194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE3_B1, 0xef),
125294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE3_B2, 0xbf),
125394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE3_B3, 0xa0),
125494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE3_B4, 0x81),
125594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE3_B5, 0xde),
125694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MODE_RATE3_B6, 0x7f),
125794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_PHPRE_CTRL, 0x20),
125894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_AUX_DATA_THRESH_BIN_RATE_0_1, 0x3f),
125994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_AUX_DATA_THRESH_BIN_RATE_2_3, 0x37),
126094a407ccSDmitry Baryshkov 
126194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_DFE_3, 0x05),
126294a407ccSDmitry Baryshkov 
126394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MARG_COARSE_THRESH1_RATE3, 0x1f),
126494a407ccSDmitry Baryshkov 
126594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MARG_COARSE_THRESH2_RATE3, 0x1f),
126694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MARG_COARSE_THRESH3_RATE3, 0x1f),
126794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MARG_COARSE_THRESH4_RATE3, 0x1f),
126894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MARG_COARSE_THRESH5_RATE3, 0x1f),
126994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MARG_COARSE_THRESH6_RATE3, 0x1f),
127094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MARG_COARSE_THRESH1_RATE210, 0x1f),
127194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MARG_COARSE_THRESH2_RATE210, 0x1f),
127294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_MARG_COARSE_THRESH3_RATE210, 0x1f),
127394a407ccSDmitry Baryshkov 
127494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_UCDR_FO_GAIN_RATE2, 0x0c),
127594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_UCDR_FO_GAIN_RATE3, 0x0a),
127694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_VGA_CAL_MAN_VAL, 0x0a),
127794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_EQU_ADAPTOR_CNTRL4, 0x0b),
127894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_RX_IDAC_SAOFFSET, 0x10),
127994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_DFE_DAC_ENABLE1, 0x00),
128094a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_GM_CAL, 0x0f),
128194a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_TX_ADAPT_POST_THRESH1, 0x00),
128294a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_20_RX_TX_ADAPT_POST_THRESH2, 0x1f),
128394a407ccSDmitry Baryshkov };
128494a407ccSDmitry Baryshkov 
128594a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8450_qmp_gen4x2_pcie_pcs_tbl[] = {
128694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V5_PCS_EQ_CONFIG2, 0x16),
128794a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V5_PCS_EQ_CONFIG3, 0x22),
128894a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V5_PCS_G3S2_PRE_GAIN, 0x2e),
128994a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V5_PCS_RX_SIGDET_LVL, 0x99),
129094a407ccSDmitry Baryshkov };
129194a407ccSDmitry Baryshkov 
129294a407ccSDmitry Baryshkov static const struct qmp_phy_init_tbl sm8450_qmp_gen4x2_pcie_pcs_misc_tbl[] = {
129394a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V5_20_PCS_PCIE_G4_EQ_CONFIG5, 0x02),
129494a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V5_20_PCS_PCIE_EQ_CONFIG1, 0x16),
129594a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V5_20_PCS_PCIE_RX_MARGINING_CONFIG3, 0x28),
129694a407ccSDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V5_20_PCS_PCIE_G4_PRE_GAIN, 0x2e),
129794a407ccSDmitry Baryshkov };
129894a407ccSDmitry Baryshkov 
1299f5682f13SDmitry Baryshkov static const struct qmp_phy_init_tbl sm8450_qmp_gen4x2_pcie_rc_pcs_misc_tbl[] = {
1300f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V5_20_PCS_PCIE_ENDPOINT_REFCLK_DRIVE, 0xc1),
1301f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V5_20_PCS_PCIE_OSC_DTCT_ACTIONS, 0x00),
1302f5682f13SDmitry Baryshkov };
1303f5682f13SDmitry Baryshkov 
1304f5682f13SDmitry Baryshkov static const struct qmp_phy_init_tbl sm8450_qmp_gen4x2_pcie_ep_serdes_tbl[] = {
1305f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_BG_TIMER, 0x02),
1306f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_SYS_CLK_CTRL, 0x07),
1307f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_CP_CTRL_MODE0, 0x27),
1308f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_CP_CTRL_MODE1, 0x0a),
1309f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_RCTRL_MODE0, 0x17),
1310f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_RCTRL_MODE1, 0x19),
1311f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_CCTRL_MODE0, 0x00),
1312f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_CCTRL_MODE1, 0x03),
1313f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_SYSCLK_EN_SEL, 0x00),
1314f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP1_MODE0, 0xff),
1315f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP2_MODE0, 0x04),
1316f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP1_MODE1, 0xff),
1317f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP2_MODE1, 0x09),
1318f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_DEC_START_MODE0, 0x19),
1319f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_DEC_START_MODE1, 0x28),
1320f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_INTEGLOOP_GAIN0_MODE0, 0xfb),
1321f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_INTEGLOOP_GAIN1_MODE0, 0x01),
1322f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_INTEGLOOP_GAIN0_MODE1, 0xfb),
1323f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_INTEGLOOP_GAIN1_MODE1, 0x01),
1324f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QSERDES_V5_COM_CORE_CLK_EN, 0x60),
1325f5682f13SDmitry Baryshkov };
1326f5682f13SDmitry Baryshkov 
1327f5682f13SDmitry Baryshkov static const struct qmp_phy_init_tbl sm8450_qmp_gen4x2_pcie_ep_pcs_misc_tbl[] = {
1328f5682f13SDmitry Baryshkov 	QMP_PHY_INIT_CFG(QPHY_V5_20_PCS_PCIE_OSC_DTCT_MODE2_CONFIG5, 0x08),
1329f5682f13SDmitry Baryshkov };
1330f5682f13SDmitry Baryshkov 
13312566ad8eSDmitry Baryshkov struct qmp_phy_cfg_tables {
13322566ad8eSDmitry Baryshkov 	const struct qmp_phy_init_tbl *serdes;
13332566ad8eSDmitry Baryshkov 	int serdes_num;
13342566ad8eSDmitry Baryshkov 	const struct qmp_phy_init_tbl *tx;
13352566ad8eSDmitry Baryshkov 	int tx_num;
13362566ad8eSDmitry Baryshkov 	const struct qmp_phy_init_tbl *rx;
13372566ad8eSDmitry Baryshkov 	int rx_num;
13382566ad8eSDmitry Baryshkov 	const struct qmp_phy_init_tbl *pcs;
13392566ad8eSDmitry Baryshkov 	int pcs_num;
13402566ad8eSDmitry Baryshkov 	const struct qmp_phy_init_tbl *pcs_misc;
13412566ad8eSDmitry Baryshkov 	int pcs_misc_num;
13422566ad8eSDmitry Baryshkov };
13432566ad8eSDmitry Baryshkov 
134494a407ccSDmitry Baryshkov /* struct qmp_phy_cfg - per-PHY initialization config */
134594a407ccSDmitry Baryshkov struct qmp_phy_cfg {
1346f02543faSJohan Hovold 	int lanes;
134794a407ccSDmitry Baryshkov 
13482566ad8eSDmitry Baryshkov 	/* Main init sequence for PHY blocks - serdes, tx, rx, pcs */
13492566ad8eSDmitry Baryshkov 	const struct qmp_phy_cfg_tables tables;
13502566ad8eSDmitry Baryshkov 	/*
135111bf53a3SDmitry Baryshkov 	 * Additional init sequences for PHY blocks, providing additional
135211bf53a3SDmitry Baryshkov 	 * register programming. They are used for providing separate sequences
135311bf53a3SDmitry Baryshkov 	 * for the Root Complex and End Point use cases.
135411bf53a3SDmitry Baryshkov 	 *
135511bf53a3SDmitry Baryshkov 	 * If EP mode is not supported, both tables can be left unset.
13562566ad8eSDmitry Baryshkov 	 */
13572566ad8eSDmitry Baryshkov 	const struct qmp_phy_cfg_tables *tables_rc;
135811bf53a3SDmitry Baryshkov 	const struct qmp_phy_cfg_tables *tables_ep;
135994a407ccSDmitry Baryshkov 
136094a407ccSDmitry Baryshkov 	/* clock ids to be requested */
136194a407ccSDmitry Baryshkov 	const char * const *clk_list;
136294a407ccSDmitry Baryshkov 	int num_clks;
136394a407ccSDmitry Baryshkov 	/* resets to be requested */
136494a407ccSDmitry Baryshkov 	const char * const *reset_list;
136594a407ccSDmitry Baryshkov 	int num_resets;
136694a407ccSDmitry Baryshkov 	/* regulators to be requested */
136794a407ccSDmitry Baryshkov 	const char * const *vreg_list;
136894a407ccSDmitry Baryshkov 	int num_vregs;
136994a407ccSDmitry Baryshkov 
137094a407ccSDmitry Baryshkov 	/* array of registers with different offsets */
137194a407ccSDmitry Baryshkov 	const unsigned int *regs;
137294a407ccSDmitry Baryshkov 
137394a407ccSDmitry Baryshkov 	unsigned int start_ctrl;
137494a407ccSDmitry Baryshkov 	unsigned int pwrdn_ctrl;
137594a407ccSDmitry Baryshkov 	/* bit offset of PHYSTATUS in QPHY_PCS_STATUS register */
137694a407ccSDmitry Baryshkov 	unsigned int phy_status;
137794a407ccSDmitry Baryshkov 
137894a407ccSDmitry Baryshkov 	/* true, if PHY needs delay after POWER_DOWN */
137994a407ccSDmitry Baryshkov 	bool has_pwrdn_delay;
138094a407ccSDmitry Baryshkov 	/* power_down delay in usec */
138194a407ccSDmitry Baryshkov 	int pwrdn_delay_min;
138294a407ccSDmitry Baryshkov 	int pwrdn_delay_max;
138394a407ccSDmitry Baryshkov 
13842ec9bc8dSRobert Marko 	/* QMP PHY pipe clock interface rate */
13852ec9bc8dSRobert Marko 	unsigned long pipe_clock_rate;
138694a407ccSDmitry Baryshkov };
138794a407ccSDmitry Baryshkov 
138894a407ccSDmitry Baryshkov /**
138994a407ccSDmitry Baryshkov  * struct qmp_phy - per-lane phy descriptor
139094a407ccSDmitry Baryshkov  *
139194a407ccSDmitry Baryshkov  * @phy: generic phy
139294a407ccSDmitry Baryshkov  * @cfg: phy specific configuration
139394a407ccSDmitry Baryshkov  * @serdes: iomapped memory space for phy's serdes (i.e. PLL)
139494a407ccSDmitry Baryshkov  * @tx: iomapped memory space for lane's tx
139594a407ccSDmitry Baryshkov  * @rx: iomapped memory space for lane's rx
139694a407ccSDmitry Baryshkov  * @pcs: iomapped memory space for lane's pcs
139794a407ccSDmitry Baryshkov  * @tx2: iomapped memory space for second lane's tx (in dual lane PHYs)
139894a407ccSDmitry Baryshkov  * @rx2: iomapped memory space for second lane's rx (in dual lane PHYs)
139994a407ccSDmitry Baryshkov  * @pcs_misc: iomapped memory space for lane's pcs_misc
140094a407ccSDmitry Baryshkov  * @pipe_clk: pipe clock
140194a407ccSDmitry Baryshkov  * @qmp: QMP phy to which this lane belongs
140211bf53a3SDmitry Baryshkov  * @mode: currently selected PHY mode
140394a407ccSDmitry Baryshkov  */
140494a407ccSDmitry Baryshkov struct qmp_phy {
140594a407ccSDmitry Baryshkov 	struct phy *phy;
140694a407ccSDmitry Baryshkov 	const struct qmp_phy_cfg *cfg;
140794a407ccSDmitry Baryshkov 	void __iomem *serdes;
140894a407ccSDmitry Baryshkov 	void __iomem *tx;
140994a407ccSDmitry Baryshkov 	void __iomem *rx;
141094a407ccSDmitry Baryshkov 	void __iomem *pcs;
141194a407ccSDmitry Baryshkov 	void __iomem *tx2;
141294a407ccSDmitry Baryshkov 	void __iomem *rx2;
141394a407ccSDmitry Baryshkov 	void __iomem *pcs_misc;
141494a407ccSDmitry Baryshkov 	struct clk *pipe_clk;
141594a407ccSDmitry Baryshkov 	struct qcom_qmp *qmp;
141611bf53a3SDmitry Baryshkov 	int mode;
141794a407ccSDmitry Baryshkov };
141894a407ccSDmitry Baryshkov 
141994a407ccSDmitry Baryshkov /**
142094a407ccSDmitry Baryshkov  * struct qcom_qmp - structure holding QMP phy block attributes
142194a407ccSDmitry Baryshkov  *
142294a407ccSDmitry Baryshkov  * @dev: device
142394a407ccSDmitry Baryshkov  *
142494a407ccSDmitry Baryshkov  * @clks: array of clocks required by phy
142594a407ccSDmitry Baryshkov  * @resets: array of resets required by phy
142694a407ccSDmitry Baryshkov  * @vregs: regulator supplies bulk data
142794a407ccSDmitry Baryshkov  *
142894a407ccSDmitry Baryshkov  * @phys: array of per-lane phy descriptors
142994a407ccSDmitry Baryshkov  */
143094a407ccSDmitry Baryshkov struct qcom_qmp {
143194a407ccSDmitry Baryshkov 	struct device *dev;
143294a407ccSDmitry Baryshkov 
143394a407ccSDmitry Baryshkov 	struct clk_bulk_data *clks;
1434189ac6b8SDmitry Baryshkov 	struct reset_control_bulk_data *resets;
143594a407ccSDmitry Baryshkov 	struct regulator_bulk_data *vregs;
143694a407ccSDmitry Baryshkov 
143794a407ccSDmitry Baryshkov 	struct qmp_phy **phys;
143894a407ccSDmitry Baryshkov };
143994a407ccSDmitry Baryshkov 
144094a407ccSDmitry Baryshkov static inline void qphy_setbits(void __iomem *base, u32 offset, u32 val)
144194a407ccSDmitry Baryshkov {
144294a407ccSDmitry Baryshkov 	u32 reg;
144394a407ccSDmitry Baryshkov 
144494a407ccSDmitry Baryshkov 	reg = readl(base + offset);
144594a407ccSDmitry Baryshkov 	reg |= val;
144694a407ccSDmitry Baryshkov 	writel(reg, base + offset);
144794a407ccSDmitry Baryshkov 
144894a407ccSDmitry Baryshkov 	/* ensure that above write is through */
144994a407ccSDmitry Baryshkov 	readl(base + offset);
145094a407ccSDmitry Baryshkov }
145194a407ccSDmitry Baryshkov 
145294a407ccSDmitry Baryshkov static inline void qphy_clrbits(void __iomem *base, u32 offset, u32 val)
145394a407ccSDmitry Baryshkov {
145494a407ccSDmitry Baryshkov 	u32 reg;
145594a407ccSDmitry Baryshkov 
145694a407ccSDmitry Baryshkov 	reg = readl(base + offset);
145794a407ccSDmitry Baryshkov 	reg &= ~val;
145894a407ccSDmitry Baryshkov 	writel(reg, base + offset);
145994a407ccSDmitry Baryshkov 
146094a407ccSDmitry Baryshkov 	/* ensure that above write is through */
146194a407ccSDmitry Baryshkov 	readl(base + offset);
146294a407ccSDmitry Baryshkov }
146394a407ccSDmitry Baryshkov 
146494a407ccSDmitry Baryshkov /* list of clocks required by phy */
146594a407ccSDmitry Baryshkov static const char * const msm8996_phy_clk_l[] = {
146694a407ccSDmitry Baryshkov 	"aux", "cfg_ahb", "ref",
146794a407ccSDmitry Baryshkov };
146894a407ccSDmitry Baryshkov 
146994a407ccSDmitry Baryshkov 
147094a407ccSDmitry Baryshkov static const char * const sdm845_pciephy_clk_l[] = {
147194a407ccSDmitry Baryshkov 	"aux", "cfg_ahb", "ref", "refgen",
147294a407ccSDmitry Baryshkov };
147394a407ccSDmitry Baryshkov 
147494a407ccSDmitry Baryshkov /* list of regulators */
147594a407ccSDmitry Baryshkov static const char * const qmp_phy_vreg_l[] = {
147694a407ccSDmitry Baryshkov 	"vdda-phy", "vdda-pll",
147794a407ccSDmitry Baryshkov };
147894a407ccSDmitry Baryshkov 
147994a407ccSDmitry Baryshkov static const char * const ipq8074_pciephy_clk_l[] = {
148094a407ccSDmitry Baryshkov 	"aux", "cfg_ahb",
148194a407ccSDmitry Baryshkov };
1482b35a5311SDmitry Baryshkov 
148394a407ccSDmitry Baryshkov /* list of resets */
148494a407ccSDmitry Baryshkov static const char * const ipq8074_pciephy_reset_l[] = {
148594a407ccSDmitry Baryshkov 	"phy", "common",
148694a407ccSDmitry Baryshkov };
148794a407ccSDmitry Baryshkov 
1488b35a5311SDmitry Baryshkov static const char * const sdm845_pciephy_reset_l[] = {
1489b35a5311SDmitry Baryshkov 	"phy",
1490b35a5311SDmitry Baryshkov };
1491b35a5311SDmitry Baryshkov 
149294a407ccSDmitry Baryshkov static const struct qmp_phy_cfg ipq8074_pciephy_cfg = {
1493f02543faSJohan Hovold 	.lanes			= 1,
149494a407ccSDmitry Baryshkov 
14952566ad8eSDmitry Baryshkov 	.tables = {
14962566ad8eSDmitry Baryshkov 		.serdes		= ipq8074_pcie_serdes_tbl,
14972566ad8eSDmitry Baryshkov 		.serdes_num	= ARRAY_SIZE(ipq8074_pcie_serdes_tbl),
14982566ad8eSDmitry Baryshkov 		.tx		= ipq8074_pcie_tx_tbl,
14992566ad8eSDmitry Baryshkov 		.tx_num		= ARRAY_SIZE(ipq8074_pcie_tx_tbl),
15002566ad8eSDmitry Baryshkov 		.rx		= ipq8074_pcie_rx_tbl,
15012566ad8eSDmitry Baryshkov 		.rx_num		= ARRAY_SIZE(ipq8074_pcie_rx_tbl),
15022566ad8eSDmitry Baryshkov 		.pcs		= ipq8074_pcie_pcs_tbl,
15032566ad8eSDmitry Baryshkov 		.pcs_num	= ARRAY_SIZE(ipq8074_pcie_pcs_tbl),
15042566ad8eSDmitry Baryshkov 	},
150594a407ccSDmitry Baryshkov 	.clk_list		= ipq8074_pciephy_clk_l,
150694a407ccSDmitry Baryshkov 	.num_clks		= ARRAY_SIZE(ipq8074_pciephy_clk_l),
150794a407ccSDmitry Baryshkov 	.reset_list		= ipq8074_pciephy_reset_l,
150894a407ccSDmitry Baryshkov 	.num_resets		= ARRAY_SIZE(ipq8074_pciephy_reset_l),
150994a407ccSDmitry Baryshkov 	.vreg_list		= NULL,
151094a407ccSDmitry Baryshkov 	.num_vregs		= 0,
151194a407ccSDmitry Baryshkov 	.regs			= pciephy_regs_layout,
151294a407ccSDmitry Baryshkov 
151394a407ccSDmitry Baryshkov 	.start_ctrl		= SERDES_START | PCS_START,
151494a407ccSDmitry Baryshkov 	.pwrdn_ctrl		= SW_PWRDN | REFCLK_DRV_DSBL,
151594a407ccSDmitry Baryshkov 	.phy_status		= PHYSTATUS,
151694a407ccSDmitry Baryshkov 
151794a407ccSDmitry Baryshkov 	.has_pwrdn_delay	= true,
151894a407ccSDmitry Baryshkov 	.pwrdn_delay_min	= 995,		/* us */
151994a407ccSDmitry Baryshkov 	.pwrdn_delay_max	= 1005,		/* us */
152094a407ccSDmitry Baryshkov };
152194a407ccSDmitry Baryshkov 
1522334fad18SRobert Marko static const struct qmp_phy_cfg ipq8074_pciephy_gen3_cfg = {
1523f02543faSJohan Hovold 	.lanes			= 1,
1524334fad18SRobert Marko 
15252566ad8eSDmitry Baryshkov 	.tables = {
15262566ad8eSDmitry Baryshkov 		.serdes		= ipq8074_pcie_gen3_serdes_tbl,
15272566ad8eSDmitry Baryshkov 		.serdes_num	= ARRAY_SIZE(ipq8074_pcie_gen3_serdes_tbl),
15282566ad8eSDmitry Baryshkov 		.tx		= ipq8074_pcie_gen3_tx_tbl,
15292566ad8eSDmitry Baryshkov 		.tx_num		= ARRAY_SIZE(ipq8074_pcie_gen3_tx_tbl),
15302566ad8eSDmitry Baryshkov 		.rx		= ipq8074_pcie_gen3_rx_tbl,
15312566ad8eSDmitry Baryshkov 		.rx_num		= ARRAY_SIZE(ipq8074_pcie_gen3_rx_tbl),
15322566ad8eSDmitry Baryshkov 		.pcs		= ipq8074_pcie_gen3_pcs_tbl,
15332566ad8eSDmitry Baryshkov 		.pcs_num	= ARRAY_SIZE(ipq8074_pcie_gen3_pcs_tbl),
15342566ad8eSDmitry Baryshkov 	},
1535334fad18SRobert Marko 	.clk_list		= ipq8074_pciephy_clk_l,
1536334fad18SRobert Marko 	.num_clks		= ARRAY_SIZE(ipq8074_pciephy_clk_l),
1537334fad18SRobert Marko 	.reset_list		= ipq8074_pciephy_reset_l,
1538334fad18SRobert Marko 	.num_resets		= ARRAY_SIZE(ipq8074_pciephy_reset_l),
1539334fad18SRobert Marko 	.vreg_list		= NULL,
1540334fad18SRobert Marko 	.num_vregs		= 0,
1541334fad18SRobert Marko 	.regs			= ipq_pciephy_gen3_regs_layout,
1542334fad18SRobert Marko 
1543334fad18SRobert Marko 	.start_ctrl		= SERDES_START | PCS_START,
1544334fad18SRobert Marko 	.pwrdn_ctrl		= SW_PWRDN | REFCLK_DRV_DSBL,
1545334fad18SRobert Marko 
1546334fad18SRobert Marko 	.has_pwrdn_delay	= true,
1547334fad18SRobert Marko 	.pwrdn_delay_min	= 995,		/* us */
1548334fad18SRobert Marko 	.pwrdn_delay_max	= 1005,		/* us */
1549334fad18SRobert Marko 
1550334fad18SRobert Marko 	.pipe_clock_rate	= 250000000,
1551334fad18SRobert Marko };
1552334fad18SRobert Marko 
155394a407ccSDmitry Baryshkov static const struct qmp_phy_cfg ipq6018_pciephy_cfg = {
1554f02543faSJohan Hovold 	.lanes			= 1,
155594a407ccSDmitry Baryshkov 
15562566ad8eSDmitry Baryshkov 	.tables = {
15572566ad8eSDmitry Baryshkov 		.serdes		= ipq6018_pcie_serdes_tbl,
15582566ad8eSDmitry Baryshkov 		.serdes_num	= ARRAY_SIZE(ipq6018_pcie_serdes_tbl),
15592566ad8eSDmitry Baryshkov 		.tx		= ipq6018_pcie_tx_tbl,
15602566ad8eSDmitry Baryshkov 		.tx_num		= ARRAY_SIZE(ipq6018_pcie_tx_tbl),
15612566ad8eSDmitry Baryshkov 		.rx		= ipq6018_pcie_rx_tbl,
15622566ad8eSDmitry Baryshkov 		.rx_num		= ARRAY_SIZE(ipq6018_pcie_rx_tbl),
15632566ad8eSDmitry Baryshkov 		.pcs		= ipq6018_pcie_pcs_tbl,
15642566ad8eSDmitry Baryshkov 		.pcs_num	= ARRAY_SIZE(ipq6018_pcie_pcs_tbl),
15652566ad8eSDmitry Baryshkov 		.pcs_misc	= ipq6018_pcie_pcs_misc_tbl,
15662566ad8eSDmitry Baryshkov 		.pcs_misc_num	= ARRAY_SIZE(ipq6018_pcie_pcs_misc_tbl),
15672566ad8eSDmitry Baryshkov 	},
156894a407ccSDmitry Baryshkov 	.clk_list		= ipq8074_pciephy_clk_l,
156994a407ccSDmitry Baryshkov 	.num_clks		= ARRAY_SIZE(ipq8074_pciephy_clk_l),
157094a407ccSDmitry Baryshkov 	.reset_list		= ipq8074_pciephy_reset_l,
157194a407ccSDmitry Baryshkov 	.num_resets		= ARRAY_SIZE(ipq8074_pciephy_reset_l),
157294a407ccSDmitry Baryshkov 	.vreg_list		= NULL,
157394a407ccSDmitry Baryshkov 	.num_vregs		= 0,
157494a407ccSDmitry Baryshkov 	.regs			= ipq_pciephy_gen3_regs_layout,
157594a407ccSDmitry Baryshkov 
157694a407ccSDmitry Baryshkov 	.start_ctrl		= SERDES_START | PCS_START,
157794a407ccSDmitry Baryshkov 	.pwrdn_ctrl		= SW_PWRDN | REFCLK_DRV_DSBL,
157894a407ccSDmitry Baryshkov 
157994a407ccSDmitry Baryshkov 	.has_pwrdn_delay	= true,
158094a407ccSDmitry Baryshkov 	.pwrdn_delay_min	= 995,		/* us */
158194a407ccSDmitry Baryshkov 	.pwrdn_delay_max	= 1005,		/* us */
158294a407ccSDmitry Baryshkov };
158394a407ccSDmitry Baryshkov 
158494a407ccSDmitry Baryshkov static const struct qmp_phy_cfg sdm845_qmp_pciephy_cfg = {
1585f02543faSJohan Hovold 	.lanes			= 1,
158694a407ccSDmitry Baryshkov 
15872566ad8eSDmitry Baryshkov 	.tables = {
15882566ad8eSDmitry Baryshkov 		.serdes		= sdm845_qmp_pcie_serdes_tbl,
15892566ad8eSDmitry Baryshkov 		.serdes_num	= ARRAY_SIZE(sdm845_qmp_pcie_serdes_tbl),
15902566ad8eSDmitry Baryshkov 		.tx		= sdm845_qmp_pcie_tx_tbl,
15912566ad8eSDmitry Baryshkov 		.tx_num		= ARRAY_SIZE(sdm845_qmp_pcie_tx_tbl),
15922566ad8eSDmitry Baryshkov 		.rx		= sdm845_qmp_pcie_rx_tbl,
15932566ad8eSDmitry Baryshkov 		.rx_num		= ARRAY_SIZE(sdm845_qmp_pcie_rx_tbl),
15942566ad8eSDmitry Baryshkov 		.pcs		= sdm845_qmp_pcie_pcs_tbl,
15952566ad8eSDmitry Baryshkov 		.pcs_num	= ARRAY_SIZE(sdm845_qmp_pcie_pcs_tbl),
15962566ad8eSDmitry Baryshkov 		.pcs_misc	= sdm845_qmp_pcie_pcs_misc_tbl,
15972566ad8eSDmitry Baryshkov 		.pcs_misc_num	= ARRAY_SIZE(sdm845_qmp_pcie_pcs_misc_tbl),
15982566ad8eSDmitry Baryshkov 	},
159994a407ccSDmitry Baryshkov 	.clk_list		= sdm845_pciephy_clk_l,
160094a407ccSDmitry Baryshkov 	.num_clks		= ARRAY_SIZE(sdm845_pciephy_clk_l),
160194a407ccSDmitry Baryshkov 	.reset_list		= sdm845_pciephy_reset_l,
160294a407ccSDmitry Baryshkov 	.num_resets		= ARRAY_SIZE(sdm845_pciephy_reset_l),
160394a407ccSDmitry Baryshkov 	.vreg_list		= qmp_phy_vreg_l,
160494a407ccSDmitry Baryshkov 	.num_vregs		= ARRAY_SIZE(qmp_phy_vreg_l),
160594a407ccSDmitry Baryshkov 	.regs			= sdm845_qmp_pciephy_regs_layout,
160694a407ccSDmitry Baryshkov 
160794a407ccSDmitry Baryshkov 	.start_ctrl		= PCS_START | SERDES_START,
160894a407ccSDmitry Baryshkov 	.pwrdn_ctrl		= SW_PWRDN | REFCLK_DRV_DSBL,
160994a407ccSDmitry Baryshkov 	.phy_status		= PHYSTATUS,
161094a407ccSDmitry Baryshkov 
161194a407ccSDmitry Baryshkov 	.has_pwrdn_delay	= true,
161294a407ccSDmitry Baryshkov 	.pwrdn_delay_min	= 995,		/* us */
161394a407ccSDmitry Baryshkov 	.pwrdn_delay_max	= 1005,		/* us */
161494a407ccSDmitry Baryshkov };
161594a407ccSDmitry Baryshkov 
161694a407ccSDmitry Baryshkov static const struct qmp_phy_cfg sdm845_qhp_pciephy_cfg = {
1617f02543faSJohan Hovold 	.lanes			= 1,
161894a407ccSDmitry Baryshkov 
16192566ad8eSDmitry Baryshkov 	.tables = {
16202566ad8eSDmitry Baryshkov 		.serdes		= sdm845_qhp_pcie_serdes_tbl,
16212566ad8eSDmitry Baryshkov 		.serdes_num	= ARRAY_SIZE(sdm845_qhp_pcie_serdes_tbl),
16222566ad8eSDmitry Baryshkov 		.tx		= sdm845_qhp_pcie_tx_tbl,
16232566ad8eSDmitry Baryshkov 		.tx_num		= ARRAY_SIZE(sdm845_qhp_pcie_tx_tbl),
16242566ad8eSDmitry Baryshkov 		.rx		= sdm845_qhp_pcie_rx_tbl,
16252566ad8eSDmitry Baryshkov 		.rx_num		= ARRAY_SIZE(sdm845_qhp_pcie_rx_tbl),
16262566ad8eSDmitry Baryshkov 		.pcs		= sdm845_qhp_pcie_pcs_tbl,
16272566ad8eSDmitry Baryshkov 		.pcs_num	= ARRAY_SIZE(sdm845_qhp_pcie_pcs_tbl),
16282566ad8eSDmitry Baryshkov 	},
162994a407ccSDmitry Baryshkov 	.clk_list		= sdm845_pciephy_clk_l,
163094a407ccSDmitry Baryshkov 	.num_clks		= ARRAY_SIZE(sdm845_pciephy_clk_l),
163194a407ccSDmitry Baryshkov 	.reset_list		= sdm845_pciephy_reset_l,
163294a407ccSDmitry Baryshkov 	.num_resets		= ARRAY_SIZE(sdm845_pciephy_reset_l),
163394a407ccSDmitry Baryshkov 	.vreg_list		= qmp_phy_vreg_l,
163494a407ccSDmitry Baryshkov 	.num_vregs		= ARRAY_SIZE(qmp_phy_vreg_l),
163594a407ccSDmitry Baryshkov 	.regs			= sdm845_qhp_pciephy_regs_layout,
163694a407ccSDmitry Baryshkov 
163794a407ccSDmitry Baryshkov 	.start_ctrl		= PCS_START | SERDES_START,
163894a407ccSDmitry Baryshkov 	.pwrdn_ctrl		= SW_PWRDN | REFCLK_DRV_DSBL,
163994a407ccSDmitry Baryshkov 	.phy_status		= PHYSTATUS,
164094a407ccSDmitry Baryshkov 
164194a407ccSDmitry Baryshkov 	.has_pwrdn_delay	= true,
164294a407ccSDmitry Baryshkov 	.pwrdn_delay_min	= 995,		/* us */
164394a407ccSDmitry Baryshkov 	.pwrdn_delay_max	= 1005,		/* us */
164494a407ccSDmitry Baryshkov };
164594a407ccSDmitry Baryshkov 
164694a407ccSDmitry Baryshkov static const struct qmp_phy_cfg sm8250_qmp_gen3x1_pciephy_cfg = {
1647f02543faSJohan Hovold 	.lanes			= 1,
164894a407ccSDmitry Baryshkov 
16492566ad8eSDmitry Baryshkov 	.tables = {
16502566ad8eSDmitry Baryshkov 		.serdes		= sm8250_qmp_pcie_serdes_tbl,
16512566ad8eSDmitry Baryshkov 		.serdes_num	= ARRAY_SIZE(sm8250_qmp_pcie_serdes_tbl),
16522566ad8eSDmitry Baryshkov 		.tx		= sm8250_qmp_pcie_tx_tbl,
16532566ad8eSDmitry Baryshkov 		.tx_num		= ARRAY_SIZE(sm8250_qmp_pcie_tx_tbl),
16542566ad8eSDmitry Baryshkov 		.rx		= sm8250_qmp_pcie_rx_tbl,
16552566ad8eSDmitry Baryshkov 		.rx_num		= ARRAY_SIZE(sm8250_qmp_pcie_rx_tbl),
16562566ad8eSDmitry Baryshkov 		.pcs		= sm8250_qmp_pcie_pcs_tbl,
16572566ad8eSDmitry Baryshkov 		.pcs_num	= ARRAY_SIZE(sm8250_qmp_pcie_pcs_tbl),
16582566ad8eSDmitry Baryshkov 		.pcs_misc	= sm8250_qmp_pcie_pcs_misc_tbl,
16592566ad8eSDmitry Baryshkov 		.pcs_misc_num	= ARRAY_SIZE(sm8250_qmp_pcie_pcs_misc_tbl),
16602566ad8eSDmitry Baryshkov 	},
16612566ad8eSDmitry Baryshkov 	.tables_rc = &(const struct qmp_phy_cfg_tables) {
16622566ad8eSDmitry Baryshkov 		.serdes		= sm8250_qmp_gen3x1_pcie_serdes_tbl,
16632566ad8eSDmitry Baryshkov 		.serdes_num	= ARRAY_SIZE(sm8250_qmp_gen3x1_pcie_serdes_tbl),
16642566ad8eSDmitry Baryshkov 		.rx		= sm8250_qmp_gen3x1_pcie_rx_tbl,
16652566ad8eSDmitry Baryshkov 		.rx_num		= ARRAY_SIZE(sm8250_qmp_gen3x1_pcie_rx_tbl),
16662566ad8eSDmitry Baryshkov 		.pcs		= sm8250_qmp_gen3x1_pcie_pcs_tbl,
16672566ad8eSDmitry Baryshkov 		.pcs_num	= ARRAY_SIZE(sm8250_qmp_gen3x1_pcie_pcs_tbl),
16682566ad8eSDmitry Baryshkov 		.pcs_misc	= sm8250_qmp_gen3x1_pcie_pcs_misc_tbl,
16692566ad8eSDmitry Baryshkov 		.pcs_misc_num	= ARRAY_SIZE(sm8250_qmp_gen3x1_pcie_pcs_misc_tbl),
16702566ad8eSDmitry Baryshkov 	},
167194a407ccSDmitry Baryshkov 	.clk_list		= sdm845_pciephy_clk_l,
167294a407ccSDmitry Baryshkov 	.num_clks		= ARRAY_SIZE(sdm845_pciephy_clk_l),
167394a407ccSDmitry Baryshkov 	.reset_list		= sdm845_pciephy_reset_l,
167494a407ccSDmitry Baryshkov 	.num_resets		= ARRAY_SIZE(sdm845_pciephy_reset_l),
167594a407ccSDmitry Baryshkov 	.vreg_list		= qmp_phy_vreg_l,
167694a407ccSDmitry Baryshkov 	.num_vregs		= ARRAY_SIZE(qmp_phy_vreg_l),
167794a407ccSDmitry Baryshkov 	.regs			= sm8250_pcie_regs_layout,
167894a407ccSDmitry Baryshkov 
167994a407ccSDmitry Baryshkov 	.start_ctrl		= PCS_START | SERDES_START,
168094a407ccSDmitry Baryshkov 	.pwrdn_ctrl		= SW_PWRDN | REFCLK_DRV_DSBL,
168194a407ccSDmitry Baryshkov 	.phy_status		= PHYSTATUS,
168294a407ccSDmitry Baryshkov 
168394a407ccSDmitry Baryshkov 	.has_pwrdn_delay	= true,
168494a407ccSDmitry Baryshkov 	.pwrdn_delay_min	= 995,		/* us */
168594a407ccSDmitry Baryshkov 	.pwrdn_delay_max	= 1005,		/* us */
168694a407ccSDmitry Baryshkov };
168794a407ccSDmitry Baryshkov 
168894a407ccSDmitry Baryshkov static const struct qmp_phy_cfg sm8250_qmp_gen3x2_pciephy_cfg = {
1689f02543faSJohan Hovold 	.lanes			= 2,
169094a407ccSDmitry Baryshkov 
16912566ad8eSDmitry Baryshkov 	.tables = {
16922566ad8eSDmitry Baryshkov 		.serdes		= sm8250_qmp_pcie_serdes_tbl,
16932566ad8eSDmitry Baryshkov 		.serdes_num	= ARRAY_SIZE(sm8250_qmp_pcie_serdes_tbl),
16942566ad8eSDmitry Baryshkov 		.tx		= sm8250_qmp_pcie_tx_tbl,
16952566ad8eSDmitry Baryshkov 		.tx_num		= ARRAY_SIZE(sm8250_qmp_pcie_tx_tbl),
16962566ad8eSDmitry Baryshkov 		.rx		= sm8250_qmp_pcie_rx_tbl,
16972566ad8eSDmitry Baryshkov 		.rx_num		= ARRAY_SIZE(sm8250_qmp_pcie_rx_tbl),
16982566ad8eSDmitry Baryshkov 		.pcs		= sm8250_qmp_pcie_pcs_tbl,
16992566ad8eSDmitry Baryshkov 		.pcs_num	= ARRAY_SIZE(sm8250_qmp_pcie_pcs_tbl),
17002566ad8eSDmitry Baryshkov 		.pcs_misc	= sm8250_qmp_pcie_pcs_misc_tbl,
17012566ad8eSDmitry Baryshkov 		.pcs_misc_num	= ARRAY_SIZE(sm8250_qmp_pcie_pcs_misc_tbl),
17022566ad8eSDmitry Baryshkov 	},
17032566ad8eSDmitry Baryshkov 	.tables_rc = &(const struct qmp_phy_cfg_tables) {
17042566ad8eSDmitry Baryshkov 		.tx		= sm8250_qmp_gen3x2_pcie_tx_tbl,
17052566ad8eSDmitry Baryshkov 		.tx_num		= ARRAY_SIZE(sm8250_qmp_gen3x2_pcie_tx_tbl),
17062566ad8eSDmitry Baryshkov 		.rx		= sm8250_qmp_gen3x2_pcie_rx_tbl,
17072566ad8eSDmitry Baryshkov 		.rx_num		= ARRAY_SIZE(sm8250_qmp_gen3x2_pcie_rx_tbl),
17082566ad8eSDmitry Baryshkov 		.pcs		= sm8250_qmp_gen3x2_pcie_pcs_tbl,
17092566ad8eSDmitry Baryshkov 		.pcs_num	= ARRAY_SIZE(sm8250_qmp_gen3x2_pcie_pcs_tbl),
17102566ad8eSDmitry Baryshkov 		.pcs_misc	= sm8250_qmp_gen3x2_pcie_pcs_misc_tbl,
17112566ad8eSDmitry Baryshkov 		.pcs_misc_num	= ARRAY_SIZE(sm8250_qmp_gen3x2_pcie_pcs_misc_tbl),
17122566ad8eSDmitry Baryshkov 	},
171394a407ccSDmitry Baryshkov 	.clk_list		= sdm845_pciephy_clk_l,
171494a407ccSDmitry Baryshkov 	.num_clks		= ARRAY_SIZE(sdm845_pciephy_clk_l),
171594a407ccSDmitry Baryshkov 	.reset_list		= sdm845_pciephy_reset_l,
171694a407ccSDmitry Baryshkov 	.num_resets		= ARRAY_SIZE(sdm845_pciephy_reset_l),
171794a407ccSDmitry Baryshkov 	.vreg_list		= qmp_phy_vreg_l,
171894a407ccSDmitry Baryshkov 	.num_vregs		= ARRAY_SIZE(qmp_phy_vreg_l),
171994a407ccSDmitry Baryshkov 	.regs			= sm8250_pcie_regs_layout,
172094a407ccSDmitry Baryshkov 
172194a407ccSDmitry Baryshkov 	.start_ctrl		= PCS_START | SERDES_START,
172294a407ccSDmitry Baryshkov 	.pwrdn_ctrl		= SW_PWRDN | REFCLK_DRV_DSBL,
172394a407ccSDmitry Baryshkov 	.phy_status		= PHYSTATUS,
172494a407ccSDmitry Baryshkov 
172594a407ccSDmitry Baryshkov 	.has_pwrdn_delay	= true,
172694a407ccSDmitry Baryshkov 	.pwrdn_delay_min	= 995,		/* us */
172794a407ccSDmitry Baryshkov 	.pwrdn_delay_max	= 1005,		/* us */
172894a407ccSDmitry Baryshkov };
172994a407ccSDmitry Baryshkov 
173094a407ccSDmitry Baryshkov static const struct qmp_phy_cfg msm8998_pciephy_cfg = {
1731f02543faSJohan Hovold 	.lanes			= 1,
173294a407ccSDmitry Baryshkov 
17332566ad8eSDmitry Baryshkov 	.tables = {
17342566ad8eSDmitry Baryshkov 		.serdes		= msm8998_pcie_serdes_tbl,
17352566ad8eSDmitry Baryshkov 		.serdes_num	= ARRAY_SIZE(msm8998_pcie_serdes_tbl),
17362566ad8eSDmitry Baryshkov 		.tx		= msm8998_pcie_tx_tbl,
17372566ad8eSDmitry Baryshkov 		.tx_num		= ARRAY_SIZE(msm8998_pcie_tx_tbl),
17382566ad8eSDmitry Baryshkov 		.rx		= msm8998_pcie_rx_tbl,
17392566ad8eSDmitry Baryshkov 		.rx_num		= ARRAY_SIZE(msm8998_pcie_rx_tbl),
17402566ad8eSDmitry Baryshkov 		.pcs		= msm8998_pcie_pcs_tbl,
17412566ad8eSDmitry Baryshkov 		.pcs_num	= ARRAY_SIZE(msm8998_pcie_pcs_tbl),
17422566ad8eSDmitry Baryshkov 	},
174394a407ccSDmitry Baryshkov 	.clk_list		= msm8996_phy_clk_l,
174494a407ccSDmitry Baryshkov 	.num_clks		= ARRAY_SIZE(msm8996_phy_clk_l),
174594a407ccSDmitry Baryshkov 	.reset_list		= ipq8074_pciephy_reset_l,
174694a407ccSDmitry Baryshkov 	.num_resets		= ARRAY_SIZE(ipq8074_pciephy_reset_l),
174794a407ccSDmitry Baryshkov 	.vreg_list		= qmp_phy_vreg_l,
174894a407ccSDmitry Baryshkov 	.num_vregs		= ARRAY_SIZE(qmp_phy_vreg_l),
174994a407ccSDmitry Baryshkov 	.regs			= pciephy_regs_layout,
175094a407ccSDmitry Baryshkov 
175194a407ccSDmitry Baryshkov 	.start_ctrl             = SERDES_START | PCS_START,
175294a407ccSDmitry Baryshkov 	.pwrdn_ctrl		= SW_PWRDN | REFCLK_DRV_DSBL,
175394a407ccSDmitry Baryshkov 	.phy_status		= PHYSTATUS,
175494a407ccSDmitry Baryshkov };
175594a407ccSDmitry Baryshkov 
175694a407ccSDmitry Baryshkov static const struct qmp_phy_cfg sc8180x_pciephy_cfg = {
1757f02543faSJohan Hovold 	.lanes			= 1,
175894a407ccSDmitry Baryshkov 
17592566ad8eSDmitry Baryshkov 	.tables = {
17602566ad8eSDmitry Baryshkov 		.serdes		= sc8180x_qmp_pcie_serdes_tbl,
17612566ad8eSDmitry Baryshkov 		.serdes_num	= ARRAY_SIZE(sc8180x_qmp_pcie_serdes_tbl),
17622566ad8eSDmitry Baryshkov 		.tx		= sc8180x_qmp_pcie_tx_tbl,
17632566ad8eSDmitry Baryshkov 		.tx_num		= ARRAY_SIZE(sc8180x_qmp_pcie_tx_tbl),
17642566ad8eSDmitry Baryshkov 		.rx		= sc8180x_qmp_pcie_rx_tbl,
17652566ad8eSDmitry Baryshkov 		.rx_num		= ARRAY_SIZE(sc8180x_qmp_pcie_rx_tbl),
17662566ad8eSDmitry Baryshkov 		.pcs		= sc8180x_qmp_pcie_pcs_tbl,
17672566ad8eSDmitry Baryshkov 		.pcs_num	= ARRAY_SIZE(sc8180x_qmp_pcie_pcs_tbl),
17682566ad8eSDmitry Baryshkov 		.pcs_misc	= sc8180x_qmp_pcie_pcs_misc_tbl,
17692566ad8eSDmitry Baryshkov 		.pcs_misc_num	= ARRAY_SIZE(sc8180x_qmp_pcie_pcs_misc_tbl),
17702566ad8eSDmitry Baryshkov 	},
177194a407ccSDmitry Baryshkov 	.clk_list		= sdm845_pciephy_clk_l,
177294a407ccSDmitry Baryshkov 	.num_clks		= ARRAY_SIZE(sdm845_pciephy_clk_l),
177394a407ccSDmitry Baryshkov 	.reset_list		= sdm845_pciephy_reset_l,
177494a407ccSDmitry Baryshkov 	.num_resets		= ARRAY_SIZE(sdm845_pciephy_reset_l),
177594a407ccSDmitry Baryshkov 	.vreg_list		= qmp_phy_vreg_l,
177694a407ccSDmitry Baryshkov 	.num_vregs		= ARRAY_SIZE(qmp_phy_vreg_l),
177794a407ccSDmitry Baryshkov 	.regs			= sm8250_pcie_regs_layout,
177894a407ccSDmitry Baryshkov 
177994a407ccSDmitry Baryshkov 	.start_ctrl		= PCS_START | SERDES_START,
178094a407ccSDmitry Baryshkov 	.pwrdn_ctrl		= SW_PWRDN | REFCLK_DRV_DSBL,
178194a407ccSDmitry Baryshkov 
178294a407ccSDmitry Baryshkov 	.has_pwrdn_delay	= true,
178394a407ccSDmitry Baryshkov 	.pwrdn_delay_min	= 995,		/* us */
178494a407ccSDmitry Baryshkov 	.pwrdn_delay_max	= 1005,		/* us */
178594a407ccSDmitry Baryshkov };
178694a407ccSDmitry Baryshkov 
178794a407ccSDmitry Baryshkov static const struct qmp_phy_cfg sdx55_qmp_pciephy_cfg = {
1788f02543faSJohan Hovold 	.lanes			= 2,
178994a407ccSDmitry Baryshkov 
17902566ad8eSDmitry Baryshkov 	.tables = {
17912566ad8eSDmitry Baryshkov 		.serdes		= sdx55_qmp_pcie_serdes_tbl,
17922566ad8eSDmitry Baryshkov 		.serdes_num	= ARRAY_SIZE(sdx55_qmp_pcie_serdes_tbl),
17932566ad8eSDmitry Baryshkov 		.tx		= sdx55_qmp_pcie_tx_tbl,
17942566ad8eSDmitry Baryshkov 		.tx_num		= ARRAY_SIZE(sdx55_qmp_pcie_tx_tbl),
17952566ad8eSDmitry Baryshkov 		.rx		= sdx55_qmp_pcie_rx_tbl,
17962566ad8eSDmitry Baryshkov 		.rx_num		= ARRAY_SIZE(sdx55_qmp_pcie_rx_tbl),
17972566ad8eSDmitry Baryshkov 		.pcs		= sdx55_qmp_pcie_pcs_tbl,
17982566ad8eSDmitry Baryshkov 		.pcs_num	= ARRAY_SIZE(sdx55_qmp_pcie_pcs_tbl),
17992566ad8eSDmitry Baryshkov 		.pcs_misc	= sdx55_qmp_pcie_pcs_misc_tbl,
18002566ad8eSDmitry Baryshkov 		.pcs_misc_num	= ARRAY_SIZE(sdx55_qmp_pcie_pcs_misc_tbl),
18012566ad8eSDmitry Baryshkov 	},
180294a407ccSDmitry Baryshkov 	.clk_list		= sdm845_pciephy_clk_l,
180394a407ccSDmitry Baryshkov 	.num_clks		= ARRAY_SIZE(sdm845_pciephy_clk_l),
180494a407ccSDmitry Baryshkov 	.reset_list		= sdm845_pciephy_reset_l,
180594a407ccSDmitry Baryshkov 	.num_resets		= ARRAY_SIZE(sdm845_pciephy_reset_l),
180694a407ccSDmitry Baryshkov 	.vreg_list		= qmp_phy_vreg_l,
180794a407ccSDmitry Baryshkov 	.num_vregs		= ARRAY_SIZE(qmp_phy_vreg_l),
180894a407ccSDmitry Baryshkov 	.regs			= sm8250_pcie_regs_layout,
180994a407ccSDmitry Baryshkov 
181094a407ccSDmitry Baryshkov 	.start_ctrl		= PCS_START | SERDES_START,
181194a407ccSDmitry Baryshkov 	.pwrdn_ctrl		= SW_PWRDN,
181294a407ccSDmitry Baryshkov 	.phy_status		= PHYSTATUS_4_20,
181394a407ccSDmitry Baryshkov 
181494a407ccSDmitry Baryshkov 	.has_pwrdn_delay	= true,
181594a407ccSDmitry Baryshkov 	.pwrdn_delay_min	= 995,		/* us */
181694a407ccSDmitry Baryshkov 	.pwrdn_delay_max	= 1005,		/* us */
181794a407ccSDmitry Baryshkov };
181894a407ccSDmitry Baryshkov 
181994a407ccSDmitry Baryshkov static const struct qmp_phy_cfg sm8450_qmp_gen3x1_pciephy_cfg = {
1820f02543faSJohan Hovold 	.lanes			= 1,
182194a407ccSDmitry Baryshkov 
18222566ad8eSDmitry Baryshkov 	.tables = {
18232566ad8eSDmitry Baryshkov 		.serdes		= sm8450_qmp_gen3x1_pcie_serdes_tbl,
18242566ad8eSDmitry Baryshkov 		.serdes_num	= ARRAY_SIZE(sm8450_qmp_gen3x1_pcie_serdes_tbl),
18252566ad8eSDmitry Baryshkov 		.tx		= sm8450_qmp_gen3x1_pcie_tx_tbl,
18262566ad8eSDmitry Baryshkov 		.tx_num		= ARRAY_SIZE(sm8450_qmp_gen3x1_pcie_tx_tbl),
18272566ad8eSDmitry Baryshkov 		.rx		= sm8450_qmp_gen3x1_pcie_rx_tbl,
18282566ad8eSDmitry Baryshkov 		.rx_num		= ARRAY_SIZE(sm8450_qmp_gen3x1_pcie_rx_tbl),
18292566ad8eSDmitry Baryshkov 		.pcs		= sm8450_qmp_gen3x1_pcie_pcs_tbl,
18302566ad8eSDmitry Baryshkov 		.pcs_num	= ARRAY_SIZE(sm8450_qmp_gen3x1_pcie_pcs_tbl),
18312566ad8eSDmitry Baryshkov 		.pcs_misc	= sm8450_qmp_gen3x1_pcie_pcs_misc_tbl,
18322566ad8eSDmitry Baryshkov 		.pcs_misc_num	= ARRAY_SIZE(sm8450_qmp_gen3x1_pcie_pcs_misc_tbl),
18332566ad8eSDmitry Baryshkov 	},
183494a407ccSDmitry Baryshkov 	.clk_list		= sdm845_pciephy_clk_l,
183594a407ccSDmitry Baryshkov 	.num_clks		= ARRAY_SIZE(sdm845_pciephy_clk_l),
183694a407ccSDmitry Baryshkov 	.reset_list		= sdm845_pciephy_reset_l,
183794a407ccSDmitry Baryshkov 	.num_resets		= ARRAY_SIZE(sdm845_pciephy_reset_l),
183894a407ccSDmitry Baryshkov 	.vreg_list		= qmp_phy_vreg_l,
183994a407ccSDmitry Baryshkov 	.num_vregs		= ARRAY_SIZE(qmp_phy_vreg_l),
184094a407ccSDmitry Baryshkov 	.regs			= sm8250_pcie_regs_layout,
184194a407ccSDmitry Baryshkov 
184294a407ccSDmitry Baryshkov 	.start_ctrl             = SERDES_START | PCS_START,
184394a407ccSDmitry Baryshkov 	.pwrdn_ctrl		= SW_PWRDN | REFCLK_DRV_DSBL,
184494a407ccSDmitry Baryshkov 	.phy_status		= PHYSTATUS,
184594a407ccSDmitry Baryshkov 
184694a407ccSDmitry Baryshkov 	.has_pwrdn_delay	= true,
184794a407ccSDmitry Baryshkov 	.pwrdn_delay_min	= 995,		/* us */
184894a407ccSDmitry Baryshkov 	.pwrdn_delay_max	= 1005,		/* us */
184994a407ccSDmitry Baryshkov };
185094a407ccSDmitry Baryshkov 
185194a407ccSDmitry Baryshkov static const struct qmp_phy_cfg sm8450_qmp_gen4x2_pciephy_cfg = {
1852f02543faSJohan Hovold 	.lanes			= 2,
185394a407ccSDmitry Baryshkov 
18542566ad8eSDmitry Baryshkov 	.tables = {
18552566ad8eSDmitry Baryshkov 		.serdes		= sm8450_qmp_gen4x2_pcie_serdes_tbl,
18562566ad8eSDmitry Baryshkov 		.serdes_num	= ARRAY_SIZE(sm8450_qmp_gen4x2_pcie_serdes_tbl),
18572566ad8eSDmitry Baryshkov 		.tx		= sm8450_qmp_gen4x2_pcie_tx_tbl,
18582566ad8eSDmitry Baryshkov 		.tx_num		= ARRAY_SIZE(sm8450_qmp_gen4x2_pcie_tx_tbl),
18592566ad8eSDmitry Baryshkov 		.rx		= sm8450_qmp_gen4x2_pcie_rx_tbl,
18602566ad8eSDmitry Baryshkov 		.rx_num		= ARRAY_SIZE(sm8450_qmp_gen4x2_pcie_rx_tbl),
18612566ad8eSDmitry Baryshkov 		.pcs		= sm8450_qmp_gen4x2_pcie_pcs_tbl,
18622566ad8eSDmitry Baryshkov 		.pcs_num	= ARRAY_SIZE(sm8450_qmp_gen4x2_pcie_pcs_tbl),
18632566ad8eSDmitry Baryshkov 		.pcs_misc	= sm8450_qmp_gen4x2_pcie_pcs_misc_tbl,
18642566ad8eSDmitry Baryshkov 		.pcs_misc_num	= ARRAY_SIZE(sm8450_qmp_gen4x2_pcie_pcs_misc_tbl),
18652566ad8eSDmitry Baryshkov 	},
1866f5682f13SDmitry Baryshkov 
1867f5682f13SDmitry Baryshkov 	.tables_rc = &(const struct qmp_phy_cfg_tables) {
1868f5682f13SDmitry Baryshkov 		.serdes		= sm8450_qmp_gen4x2_pcie_rc_serdes_tbl,
1869f5682f13SDmitry Baryshkov 		.serdes_num	= ARRAY_SIZE(sm8450_qmp_gen4x2_pcie_rc_serdes_tbl),
1870f5682f13SDmitry Baryshkov 		.pcs_misc	= sm8450_qmp_gen4x2_pcie_rc_pcs_misc_tbl,
1871f5682f13SDmitry Baryshkov 		.pcs_misc_num	= ARRAY_SIZE(sm8450_qmp_gen4x2_pcie_rc_pcs_misc_tbl),
1872f5682f13SDmitry Baryshkov 	},
1873f5682f13SDmitry Baryshkov 
1874f5682f13SDmitry Baryshkov 	.tables_ep = &(const struct qmp_phy_cfg_tables) {
1875f5682f13SDmitry Baryshkov 		.serdes		= sm8450_qmp_gen4x2_pcie_ep_serdes_tbl,
1876f5682f13SDmitry Baryshkov 		.serdes_num	= ARRAY_SIZE(sm8450_qmp_gen4x2_pcie_ep_serdes_tbl),
1877f5682f13SDmitry Baryshkov 		.pcs_misc	= sm8450_qmp_gen4x2_pcie_ep_pcs_misc_tbl,
1878f5682f13SDmitry Baryshkov 		.pcs_misc_num	= ARRAY_SIZE(sm8450_qmp_gen4x2_pcie_ep_pcs_misc_tbl),
1879f5682f13SDmitry Baryshkov 	},
1880f5682f13SDmitry Baryshkov 
188194a407ccSDmitry Baryshkov 	.clk_list		= sdm845_pciephy_clk_l,
188294a407ccSDmitry Baryshkov 	.num_clks		= ARRAY_SIZE(sdm845_pciephy_clk_l),
188394a407ccSDmitry Baryshkov 	.reset_list		= sdm845_pciephy_reset_l,
188494a407ccSDmitry Baryshkov 	.num_resets		= ARRAY_SIZE(sdm845_pciephy_reset_l),
188594a407ccSDmitry Baryshkov 	.vreg_list		= qmp_phy_vreg_l,
188694a407ccSDmitry Baryshkov 	.num_vregs		= ARRAY_SIZE(qmp_phy_vreg_l),
188794a407ccSDmitry Baryshkov 	.regs			= sm8250_pcie_regs_layout,
188894a407ccSDmitry Baryshkov 
188994a407ccSDmitry Baryshkov 	.start_ctrl             = SERDES_START | PCS_START,
189094a407ccSDmitry Baryshkov 	.pwrdn_ctrl		= SW_PWRDN | REFCLK_DRV_DSBL,
189194a407ccSDmitry Baryshkov 	.phy_status		= PHYSTATUS_4_20,
189294a407ccSDmitry Baryshkov 
189394a407ccSDmitry Baryshkov 	.has_pwrdn_delay	= true,
189494a407ccSDmitry Baryshkov 	.pwrdn_delay_min	= 995,		/* us */
189594a407ccSDmitry Baryshkov 	.pwrdn_delay_max	= 1005,		/* us */
189694a407ccSDmitry Baryshkov };
189794a407ccSDmitry Baryshkov 
189827878615SJohan Hovold static void qmp_pcie_configure_lane(void __iomem *base,
189994a407ccSDmitry Baryshkov 					const unsigned int *regs,
190094a407ccSDmitry Baryshkov 					const struct qmp_phy_init_tbl tbl[],
190194a407ccSDmitry Baryshkov 					int num,
190294a407ccSDmitry Baryshkov 					u8 lane_mask)
190394a407ccSDmitry Baryshkov {
190494a407ccSDmitry Baryshkov 	int i;
190594a407ccSDmitry Baryshkov 	const struct qmp_phy_init_tbl *t = tbl;
190694a407ccSDmitry Baryshkov 
190794a407ccSDmitry Baryshkov 	if (!t)
190894a407ccSDmitry Baryshkov 		return;
190994a407ccSDmitry Baryshkov 
191094a407ccSDmitry Baryshkov 	for (i = 0; i < num; i++, t++) {
191194a407ccSDmitry Baryshkov 		if (!(t->lane_mask & lane_mask))
191294a407ccSDmitry Baryshkov 			continue;
191394a407ccSDmitry Baryshkov 
191494a407ccSDmitry Baryshkov 		if (t->in_layout)
191594a407ccSDmitry Baryshkov 			writel(t->val, base + regs[t->offset]);
191694a407ccSDmitry Baryshkov 		else
191794a407ccSDmitry Baryshkov 			writel(t->val, base + t->offset);
191894a407ccSDmitry Baryshkov 	}
191994a407ccSDmitry Baryshkov }
192094a407ccSDmitry Baryshkov 
192127878615SJohan Hovold static void qmp_pcie_configure(void __iomem *base,
192294a407ccSDmitry Baryshkov 					const unsigned int *regs,
192394a407ccSDmitry Baryshkov 					const struct qmp_phy_init_tbl tbl[],
192494a407ccSDmitry Baryshkov 					int num)
192594a407ccSDmitry Baryshkov {
192627878615SJohan Hovold 	qmp_pcie_configure_lane(base, regs, tbl, num, 0xff);
192794a407ccSDmitry Baryshkov }
192894a407ccSDmitry Baryshkov 
19292566ad8eSDmitry Baryshkov static void qmp_pcie_serdes_init(struct qmp_phy *qphy, const struct qmp_phy_cfg_tables *tables)
193094a407ccSDmitry Baryshkov {
193194a407ccSDmitry Baryshkov 	const struct qmp_phy_cfg *cfg = qphy->cfg;
193294a407ccSDmitry Baryshkov 	void __iomem *serdes = qphy->serdes;
193394a407ccSDmitry Baryshkov 
19342566ad8eSDmitry Baryshkov 	if (!tables)
19352566ad8eSDmitry Baryshkov 		return;
193694a407ccSDmitry Baryshkov 
19372566ad8eSDmitry Baryshkov 	qmp_pcie_configure(serdes, cfg->regs, tables->serdes, tables->serdes_num);
19382566ad8eSDmitry Baryshkov }
19392566ad8eSDmitry Baryshkov 
19402566ad8eSDmitry Baryshkov static void qmp_pcie_lanes_init(struct qmp_phy *qphy, const struct qmp_phy_cfg_tables *tables)
19412566ad8eSDmitry Baryshkov {
19422566ad8eSDmitry Baryshkov 	const struct qmp_phy_cfg *cfg = qphy->cfg;
19432566ad8eSDmitry Baryshkov 	void __iomem *tx = qphy->tx;
19442566ad8eSDmitry Baryshkov 	void __iomem *rx = qphy->rx;
19452566ad8eSDmitry Baryshkov 
19462566ad8eSDmitry Baryshkov 	if (!tables)
19472566ad8eSDmitry Baryshkov 		return;
19482566ad8eSDmitry Baryshkov 
19492566ad8eSDmitry Baryshkov 	qmp_pcie_configure_lane(tx, cfg->regs, tables->tx, tables->tx_num, 1);
19502566ad8eSDmitry Baryshkov 
19512566ad8eSDmitry Baryshkov 	if (cfg->lanes >= 2)
19522566ad8eSDmitry Baryshkov 		qmp_pcie_configure_lane(qphy->tx2, cfg->regs, tables->tx, tables->tx_num, 2);
19532566ad8eSDmitry Baryshkov 
19542566ad8eSDmitry Baryshkov 	qmp_pcie_configure_lane(rx, cfg->regs, tables->rx, tables->rx_num, 1);
19552566ad8eSDmitry Baryshkov 	if (cfg->lanes >= 2)
19562566ad8eSDmitry Baryshkov 		qmp_pcie_configure_lane(qphy->rx2, cfg->regs, tables->rx, tables->rx_num, 2);
19572566ad8eSDmitry Baryshkov }
19582566ad8eSDmitry Baryshkov 
19592566ad8eSDmitry Baryshkov static void qmp_pcie_pcs_init(struct qmp_phy *qphy, const struct qmp_phy_cfg_tables *tables)
19602566ad8eSDmitry Baryshkov {
19612566ad8eSDmitry Baryshkov 	const struct qmp_phy_cfg *cfg = qphy->cfg;
19622566ad8eSDmitry Baryshkov 	void __iomem *pcs = qphy->pcs;
19632566ad8eSDmitry Baryshkov 	void __iomem *pcs_misc = qphy->pcs_misc;
19642566ad8eSDmitry Baryshkov 
19652566ad8eSDmitry Baryshkov 	if (!tables)
19662566ad8eSDmitry Baryshkov 		return;
19672566ad8eSDmitry Baryshkov 
19682566ad8eSDmitry Baryshkov 	qmp_pcie_configure(pcs, cfg->regs,
19692566ad8eSDmitry Baryshkov 			   tables->pcs, tables->pcs_num);
19702566ad8eSDmitry Baryshkov 	qmp_pcie_configure(pcs_misc, cfg->regs,
19712566ad8eSDmitry Baryshkov 			   tables->pcs_misc, tables->pcs_misc_num);
197294a407ccSDmitry Baryshkov }
197394a407ccSDmitry Baryshkov 
197491174e2cSJohan Hovold static int qmp_pcie_init(struct phy *phy)
197594a407ccSDmitry Baryshkov {
197691174e2cSJohan Hovold 	struct qmp_phy *qphy = phy_get_drvdata(phy);
197794a407ccSDmitry Baryshkov 	struct qcom_qmp *qmp = qphy->qmp;
197894a407ccSDmitry Baryshkov 	const struct qmp_phy_cfg *cfg = qphy->cfg;
1979189ac6b8SDmitry Baryshkov 	int ret;
198094a407ccSDmitry Baryshkov 
198194a407ccSDmitry Baryshkov 	/* turn on regulator supplies */
198294a407ccSDmitry Baryshkov 	ret = regulator_bulk_enable(cfg->num_vregs, qmp->vregs);
198394a407ccSDmitry Baryshkov 	if (ret) {
198494a407ccSDmitry Baryshkov 		dev_err(qmp->dev, "failed to enable regulators, err=%d\n", ret);
19851239fd71SDmitry Baryshkov 		return ret;
198694a407ccSDmitry Baryshkov 	}
198794a407ccSDmitry Baryshkov 
1988189ac6b8SDmitry Baryshkov 	ret = reset_control_bulk_assert(cfg->num_resets, qmp->resets);
198994a407ccSDmitry Baryshkov 	if (ret) {
1990189ac6b8SDmitry Baryshkov 		dev_err(qmp->dev, "reset assert failed\n");
199194a407ccSDmitry Baryshkov 		goto err_disable_regulators;
199294a407ccSDmitry Baryshkov 	}
199394a407ccSDmitry Baryshkov 
1994189ac6b8SDmitry Baryshkov 	ret = reset_control_bulk_deassert(cfg->num_resets, qmp->resets);
199594a407ccSDmitry Baryshkov 	if (ret) {
1996189ac6b8SDmitry Baryshkov 		dev_err(qmp->dev, "reset deassert failed\n");
1997189ac6b8SDmitry Baryshkov 		goto err_disable_regulators;
199894a407ccSDmitry Baryshkov 	}
199994a407ccSDmitry Baryshkov 
200094a407ccSDmitry Baryshkov 	ret = clk_bulk_prepare_enable(cfg->num_clks, qmp->clks);
200194a407ccSDmitry Baryshkov 	if (ret)
200294a407ccSDmitry Baryshkov 		goto err_assert_reset;
200394a407ccSDmitry Baryshkov 
200494a407ccSDmitry Baryshkov 	return 0;
200594a407ccSDmitry Baryshkov 
200694a407ccSDmitry Baryshkov err_assert_reset:
2007189ac6b8SDmitry Baryshkov 	reset_control_bulk_assert(cfg->num_resets, qmp->resets);
200894a407ccSDmitry Baryshkov err_disable_regulators:
200994a407ccSDmitry Baryshkov 	regulator_bulk_disable(cfg->num_vregs, qmp->vregs);
201094a407ccSDmitry Baryshkov 
201194a407ccSDmitry Baryshkov 	return ret;
201294a407ccSDmitry Baryshkov }
201394a407ccSDmitry Baryshkov 
201491174e2cSJohan Hovold static int qmp_pcie_exit(struct phy *phy)
201594a407ccSDmitry Baryshkov {
201691174e2cSJohan Hovold 	struct qmp_phy *qphy = phy_get_drvdata(phy);
201794a407ccSDmitry Baryshkov 	struct qcom_qmp *qmp = qphy->qmp;
201894a407ccSDmitry Baryshkov 	const struct qmp_phy_cfg *cfg = qphy->cfg;
201994a407ccSDmitry Baryshkov 
2020189ac6b8SDmitry Baryshkov 	reset_control_bulk_assert(cfg->num_resets, qmp->resets);
202194a407ccSDmitry Baryshkov 
202294a407ccSDmitry Baryshkov 	clk_bulk_disable_unprepare(cfg->num_clks, qmp->clks);
202394a407ccSDmitry Baryshkov 
202494a407ccSDmitry Baryshkov 	regulator_bulk_disable(cfg->num_vregs, qmp->vregs);
202594a407ccSDmitry Baryshkov 
202694a407ccSDmitry Baryshkov 	return 0;
202794a407ccSDmitry Baryshkov }
202894a407ccSDmitry Baryshkov 
202927878615SJohan Hovold static int qmp_pcie_power_on(struct phy *phy)
203094a407ccSDmitry Baryshkov {
203194a407ccSDmitry Baryshkov 	struct qmp_phy *qphy = phy_get_drvdata(phy);
203294a407ccSDmitry Baryshkov 	struct qcom_qmp *qmp = qphy->qmp;
203394a407ccSDmitry Baryshkov 	const struct qmp_phy_cfg *cfg = qphy->cfg;
203411bf53a3SDmitry Baryshkov 	const struct qmp_phy_cfg_tables *mode_tables;
203594a407ccSDmitry Baryshkov 	void __iomem *pcs = qphy->pcs;
203694a407ccSDmitry Baryshkov 	void __iomem *status;
203794a407ccSDmitry Baryshkov 	unsigned int mask, val, ready;
203894a407ccSDmitry Baryshkov 	int ret;
203994a407ccSDmitry Baryshkov 
2040*5b68d95cSJohan Hovold 	qphy_setbits(pcs, cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL],
2041*5b68d95cSJohan Hovold 			cfg->pwrdn_ctrl);
2042*5b68d95cSJohan Hovold 
204311bf53a3SDmitry Baryshkov 	if (qphy->mode == PHY_MODE_PCIE_RC)
204411bf53a3SDmitry Baryshkov 		mode_tables = cfg->tables_rc;
204511bf53a3SDmitry Baryshkov 	else
204611bf53a3SDmitry Baryshkov 		mode_tables = cfg->tables_ep;
204711bf53a3SDmitry Baryshkov 
20482566ad8eSDmitry Baryshkov 	qmp_pcie_serdes_init(qphy, &cfg->tables);
204911bf53a3SDmitry Baryshkov 	qmp_pcie_serdes_init(qphy, mode_tables);
205094a407ccSDmitry Baryshkov 
205194a407ccSDmitry Baryshkov 	ret = clk_prepare_enable(qphy->pipe_clk);
205294a407ccSDmitry Baryshkov 	if (ret) {
205394a407ccSDmitry Baryshkov 		dev_err(qmp->dev, "pipe_clk enable failed err=%d\n", ret);
2054fd926994SDmitry Baryshkov 		return ret;
205594a407ccSDmitry Baryshkov 	}
205694a407ccSDmitry Baryshkov 
205794a407ccSDmitry Baryshkov 	/* Tx, Rx, and PCS configurations */
20582566ad8eSDmitry Baryshkov 	qmp_pcie_lanes_init(qphy, &cfg->tables);
205911bf53a3SDmitry Baryshkov 	qmp_pcie_lanes_init(qphy, mode_tables);
206094a407ccSDmitry Baryshkov 
20612566ad8eSDmitry Baryshkov 	qmp_pcie_pcs_init(qphy, &cfg->tables);
206211bf53a3SDmitry Baryshkov 	qmp_pcie_pcs_init(qphy, mode_tables);
206394a407ccSDmitry Baryshkov 
206494a407ccSDmitry Baryshkov 	/*
206594a407ccSDmitry Baryshkov 	 * Pull out PHY from POWER DOWN state.
206694a407ccSDmitry Baryshkov 	 * This is active low enable signal to power-down PHY.
206794a407ccSDmitry Baryshkov 	 */
20686cad2983SDmitry Baryshkov 	qphy_setbits(pcs, QPHY_V2_PCS_POWER_DOWN_CONTROL, cfg->pwrdn_ctrl);
206994a407ccSDmitry Baryshkov 
207094a407ccSDmitry Baryshkov 	if (cfg->has_pwrdn_delay)
207194a407ccSDmitry Baryshkov 		usleep_range(cfg->pwrdn_delay_min, cfg->pwrdn_delay_max);
207294a407ccSDmitry Baryshkov 
207394a407ccSDmitry Baryshkov 	/* Pull PHY out of reset state */
207494a407ccSDmitry Baryshkov 	qphy_clrbits(pcs, cfg->regs[QPHY_SW_RESET], SW_RESET);
2075fd926994SDmitry Baryshkov 
207694a407ccSDmitry Baryshkov 	/* start SerDes and Phy-Coding-Sublayer */
207794a407ccSDmitry Baryshkov 	qphy_setbits(pcs, cfg->regs[QPHY_START_CTRL], cfg->start_ctrl);
207894a407ccSDmitry Baryshkov 
207994a407ccSDmitry Baryshkov 	status = pcs + cfg->regs[QPHY_PCS_STATUS];
208094a407ccSDmitry Baryshkov 	mask = cfg->phy_status;
208194a407ccSDmitry Baryshkov 	ready = 0;
208294a407ccSDmitry Baryshkov 
208394a407ccSDmitry Baryshkov 	ret = readl_poll_timeout(status, val, (val & mask) == ready, 10,
208494a407ccSDmitry Baryshkov 				 PHY_INIT_COMPLETE_TIMEOUT);
208594a407ccSDmitry Baryshkov 	if (ret) {
208694a407ccSDmitry Baryshkov 		dev_err(qmp->dev, "phy initialization timed-out\n");
208794a407ccSDmitry Baryshkov 		goto err_disable_pipe_clk;
208894a407ccSDmitry Baryshkov 	}
2089da07a06bSDmitry Baryshkov 
209094a407ccSDmitry Baryshkov 	return 0;
209194a407ccSDmitry Baryshkov 
209294a407ccSDmitry Baryshkov err_disable_pipe_clk:
209394a407ccSDmitry Baryshkov 	clk_disable_unprepare(qphy->pipe_clk);
209494a407ccSDmitry Baryshkov 
209594a407ccSDmitry Baryshkov 	return ret;
209694a407ccSDmitry Baryshkov }
209794a407ccSDmitry Baryshkov 
209827878615SJohan Hovold static int qmp_pcie_power_off(struct phy *phy)
209994a407ccSDmitry Baryshkov {
210094a407ccSDmitry Baryshkov 	struct qmp_phy *qphy = phy_get_drvdata(phy);
210194a407ccSDmitry Baryshkov 	const struct qmp_phy_cfg *cfg = qphy->cfg;
210294a407ccSDmitry Baryshkov 
210394a407ccSDmitry Baryshkov 	clk_disable_unprepare(qphy->pipe_clk);
210494a407ccSDmitry Baryshkov 
210594a407ccSDmitry Baryshkov 	/* PHY reset */
210694a407ccSDmitry Baryshkov 	qphy_setbits(qphy->pcs, cfg->regs[QPHY_SW_RESET], SW_RESET);
210794a407ccSDmitry Baryshkov 
210894a407ccSDmitry Baryshkov 	/* stop SerDes and Phy-Coding-Sublayer */
210994a407ccSDmitry Baryshkov 	qphy_clrbits(qphy->pcs, cfg->regs[QPHY_START_CTRL], cfg->start_ctrl);
211094a407ccSDmitry Baryshkov 
211194a407ccSDmitry Baryshkov 	/* Put PHY into POWER DOWN state: active low */
211294a407ccSDmitry Baryshkov 	qphy_clrbits(qphy->pcs, cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL],
211394a407ccSDmitry Baryshkov 			cfg->pwrdn_ctrl);
211494a407ccSDmitry Baryshkov 
211594a407ccSDmitry Baryshkov 	return 0;
211694a407ccSDmitry Baryshkov }
211794a407ccSDmitry Baryshkov 
211827878615SJohan Hovold static int qmp_pcie_enable(struct phy *phy)
211994a407ccSDmitry Baryshkov {
212094a407ccSDmitry Baryshkov 	int ret;
212194a407ccSDmitry Baryshkov 
212227878615SJohan Hovold 	ret = qmp_pcie_init(phy);
212394a407ccSDmitry Baryshkov 	if (ret)
212494a407ccSDmitry Baryshkov 		return ret;
212594a407ccSDmitry Baryshkov 
212627878615SJohan Hovold 	ret = qmp_pcie_power_on(phy);
212794a407ccSDmitry Baryshkov 	if (ret)
212827878615SJohan Hovold 		qmp_pcie_exit(phy);
212994a407ccSDmitry Baryshkov 
213094a407ccSDmitry Baryshkov 	return ret;
213194a407ccSDmitry Baryshkov }
213294a407ccSDmitry Baryshkov 
213327878615SJohan Hovold static int qmp_pcie_disable(struct phy *phy)
213494a407ccSDmitry Baryshkov {
213594a407ccSDmitry Baryshkov 	int ret;
213694a407ccSDmitry Baryshkov 
213727878615SJohan Hovold 	ret = qmp_pcie_power_off(phy);
213894a407ccSDmitry Baryshkov 	if (ret)
213994a407ccSDmitry Baryshkov 		return ret;
214027878615SJohan Hovold 
214127878615SJohan Hovold 	return qmp_pcie_exit(phy);
214294a407ccSDmitry Baryshkov }
214394a407ccSDmitry Baryshkov 
214411bf53a3SDmitry Baryshkov static int qmp_pcie_set_mode(struct phy *phy, enum phy_mode mode, int submode)
214511bf53a3SDmitry Baryshkov {
214611bf53a3SDmitry Baryshkov 	struct qmp_phy *qphy = phy_get_drvdata(phy);
214711bf53a3SDmitry Baryshkov 
214811bf53a3SDmitry Baryshkov 	switch (submode) {
214911bf53a3SDmitry Baryshkov 	case PHY_MODE_PCIE_RC:
215011bf53a3SDmitry Baryshkov 	case PHY_MODE_PCIE_EP:
215111bf53a3SDmitry Baryshkov 		qphy->mode = submode;
215211bf53a3SDmitry Baryshkov 		break;
215311bf53a3SDmitry Baryshkov 	default:
215411bf53a3SDmitry Baryshkov 		dev_err(&phy->dev, "Unsupported submode %d\n", submode);
215511bf53a3SDmitry Baryshkov 		return -EINVAL;
215611bf53a3SDmitry Baryshkov 	}
215711bf53a3SDmitry Baryshkov 
215811bf53a3SDmitry Baryshkov 	return 0;
215911bf53a3SDmitry Baryshkov }
216011bf53a3SDmitry Baryshkov 
216127878615SJohan Hovold static int qmp_pcie_vreg_init(struct device *dev, const struct qmp_phy_cfg *cfg)
216294a407ccSDmitry Baryshkov {
216394a407ccSDmitry Baryshkov 	struct qcom_qmp *qmp = dev_get_drvdata(dev);
216494a407ccSDmitry Baryshkov 	int num = cfg->num_vregs;
216594a407ccSDmitry Baryshkov 	int i;
216694a407ccSDmitry Baryshkov 
216794a407ccSDmitry Baryshkov 	qmp->vregs = devm_kcalloc(dev, num, sizeof(*qmp->vregs), GFP_KERNEL);
216894a407ccSDmitry Baryshkov 	if (!qmp->vregs)
216994a407ccSDmitry Baryshkov 		return -ENOMEM;
217094a407ccSDmitry Baryshkov 
217194a407ccSDmitry Baryshkov 	for (i = 0; i < num; i++)
217294a407ccSDmitry Baryshkov 		qmp->vregs[i].supply = cfg->vreg_list[i];
217394a407ccSDmitry Baryshkov 
217494a407ccSDmitry Baryshkov 	return devm_regulator_bulk_get(dev, num, qmp->vregs);
217594a407ccSDmitry Baryshkov }
217694a407ccSDmitry Baryshkov 
217727878615SJohan Hovold static int qmp_pcie_reset_init(struct device *dev, const struct qmp_phy_cfg *cfg)
217894a407ccSDmitry Baryshkov {
217994a407ccSDmitry Baryshkov 	struct qcom_qmp *qmp = dev_get_drvdata(dev);
218094a407ccSDmitry Baryshkov 	int i;
2181189ac6b8SDmitry Baryshkov 	int ret;
218294a407ccSDmitry Baryshkov 
218394a407ccSDmitry Baryshkov 	qmp->resets = devm_kcalloc(dev, cfg->num_resets,
218494a407ccSDmitry Baryshkov 				   sizeof(*qmp->resets), GFP_KERNEL);
218594a407ccSDmitry Baryshkov 	if (!qmp->resets)
218694a407ccSDmitry Baryshkov 		return -ENOMEM;
218794a407ccSDmitry Baryshkov 
2188189ac6b8SDmitry Baryshkov 	for (i = 0; i < cfg->num_resets; i++)
2189189ac6b8SDmitry Baryshkov 		qmp->resets[i].id = cfg->reset_list[i];
219094a407ccSDmitry Baryshkov 
2191189ac6b8SDmitry Baryshkov 	ret = devm_reset_control_bulk_get_exclusive(dev, cfg->num_resets, qmp->resets);
2192189ac6b8SDmitry Baryshkov 	if (ret)
2193189ac6b8SDmitry Baryshkov 		return dev_err_probe(dev, ret, "failed to get resets\n");
219494a407ccSDmitry Baryshkov 
219594a407ccSDmitry Baryshkov 	return 0;
219694a407ccSDmitry Baryshkov }
219794a407ccSDmitry Baryshkov 
219827878615SJohan Hovold static int qmp_pcie_clk_init(struct device *dev, const struct qmp_phy_cfg *cfg)
219994a407ccSDmitry Baryshkov {
220094a407ccSDmitry Baryshkov 	struct qcom_qmp *qmp = dev_get_drvdata(dev);
220194a407ccSDmitry Baryshkov 	int num = cfg->num_clks;
220294a407ccSDmitry Baryshkov 	int i;
220394a407ccSDmitry Baryshkov 
220494a407ccSDmitry Baryshkov 	qmp->clks = devm_kcalloc(dev, num, sizeof(*qmp->clks), GFP_KERNEL);
220594a407ccSDmitry Baryshkov 	if (!qmp->clks)
220694a407ccSDmitry Baryshkov 		return -ENOMEM;
220794a407ccSDmitry Baryshkov 
220894a407ccSDmitry Baryshkov 	for (i = 0; i < num; i++)
220994a407ccSDmitry Baryshkov 		qmp->clks[i].id = cfg->clk_list[i];
221094a407ccSDmitry Baryshkov 
221194a407ccSDmitry Baryshkov 	return devm_clk_bulk_get(dev, num, qmp->clks);
221294a407ccSDmitry Baryshkov }
221394a407ccSDmitry Baryshkov 
221494a407ccSDmitry Baryshkov static void phy_clk_release_provider(void *res)
221594a407ccSDmitry Baryshkov {
221694a407ccSDmitry Baryshkov 	of_clk_del_provider(res);
221794a407ccSDmitry Baryshkov }
221894a407ccSDmitry Baryshkov 
221994a407ccSDmitry Baryshkov /*
222094a407ccSDmitry Baryshkov  * Register a fixed rate pipe clock.
222194a407ccSDmitry Baryshkov  *
222294a407ccSDmitry Baryshkov  * The <s>_pipe_clksrc generated by PHY goes to the GCC that gate
222394a407ccSDmitry Baryshkov  * controls it. The <s>_pipe_clk coming out of the GCC is requested
222494a407ccSDmitry Baryshkov  * by the PHY driver for its operations.
222594a407ccSDmitry Baryshkov  * We register the <s>_pipe_clksrc here. The gcc driver takes care
222694a407ccSDmitry Baryshkov  * of assigning this <s>_pipe_clksrc as parent to <s>_pipe_clk.
222794a407ccSDmitry Baryshkov  * Below picture shows this relationship.
222894a407ccSDmitry Baryshkov  *
222994a407ccSDmitry Baryshkov  *         +---------------+
223094a407ccSDmitry Baryshkov  *         |   PHY block   |<<---------------------------------------+
223194a407ccSDmitry Baryshkov  *         |               |                                         |
223294a407ccSDmitry Baryshkov  *         |   +-------+   |                   +-----+               |
223394a407ccSDmitry Baryshkov  *   I/P---^-->|  PLL  |---^--->pipe_clksrc--->| GCC |--->pipe_clk---+
223494a407ccSDmitry Baryshkov  *    clk  |   +-------+   |                   +-----+
223594a407ccSDmitry Baryshkov  *         +---------------+
223694a407ccSDmitry Baryshkov  */
223794a407ccSDmitry Baryshkov static int phy_pipe_clk_register(struct qcom_qmp *qmp, struct device_node *np)
223894a407ccSDmitry Baryshkov {
223994a407ccSDmitry Baryshkov 	struct clk_fixed_rate *fixed;
224094a407ccSDmitry Baryshkov 	struct clk_init_data init = { };
224194a407ccSDmitry Baryshkov 	int ret;
224294a407ccSDmitry Baryshkov 
224394a407ccSDmitry Baryshkov 	ret = of_property_read_string(np, "clock-output-names", &init.name);
224494a407ccSDmitry Baryshkov 	if (ret) {
224594a407ccSDmitry Baryshkov 		dev_err(qmp->dev, "%pOFn: No clock-output-names\n", np);
224694a407ccSDmitry Baryshkov 		return ret;
224794a407ccSDmitry Baryshkov 	}
224894a407ccSDmitry Baryshkov 
224994a407ccSDmitry Baryshkov 	fixed = devm_kzalloc(qmp->dev, sizeof(*fixed), GFP_KERNEL);
225094a407ccSDmitry Baryshkov 	if (!fixed)
225194a407ccSDmitry Baryshkov 		return -ENOMEM;
225294a407ccSDmitry Baryshkov 
225394a407ccSDmitry Baryshkov 	init.ops = &clk_fixed_rate_ops;
225494a407ccSDmitry Baryshkov 
22552ec9bc8dSRobert Marko 	/*
22562ec9bc8dSRobert Marko 	 * Controllers using QMP PHY-s use 125MHz pipe clock interface
22572ec9bc8dSRobert Marko 	 * unless other frequency is specified in the PHY config.
22582ec9bc8dSRobert Marko 	 */
22592ec9bc8dSRobert Marko 	if (qmp->phys[0]->cfg->pipe_clock_rate)
22602ec9bc8dSRobert Marko 		fixed->fixed_rate = qmp->phys[0]->cfg->pipe_clock_rate;
22612ec9bc8dSRobert Marko 	else
226294a407ccSDmitry Baryshkov 		fixed->fixed_rate = 125000000;
22632ec9bc8dSRobert Marko 
226494a407ccSDmitry Baryshkov 	fixed->hw.init = &init;
226594a407ccSDmitry Baryshkov 
226694a407ccSDmitry Baryshkov 	ret = devm_clk_hw_register(qmp->dev, &fixed->hw);
226794a407ccSDmitry Baryshkov 	if (ret)
226894a407ccSDmitry Baryshkov 		return ret;
226994a407ccSDmitry Baryshkov 
227094a407ccSDmitry Baryshkov 	ret = of_clk_add_hw_provider(np, of_clk_hw_simple_get, &fixed->hw);
227194a407ccSDmitry Baryshkov 	if (ret)
227294a407ccSDmitry Baryshkov 		return ret;
227394a407ccSDmitry Baryshkov 
227494a407ccSDmitry Baryshkov 	/*
227594a407ccSDmitry Baryshkov 	 * Roll a devm action because the clock provider is the child node, but
227694a407ccSDmitry Baryshkov 	 * the child node is not actually a device.
227794a407ccSDmitry Baryshkov 	 */
227894a407ccSDmitry Baryshkov 	return devm_add_action_or_reset(qmp->dev, phy_clk_release_provider, np);
227994a407ccSDmitry Baryshkov }
228094a407ccSDmitry Baryshkov 
228127878615SJohan Hovold static const struct phy_ops qmp_pcie_ops = {
228227878615SJohan Hovold 	.power_on	= qmp_pcie_enable,
228327878615SJohan Hovold 	.power_off	= qmp_pcie_disable,
228411bf53a3SDmitry Baryshkov 	.set_mode	= qmp_pcie_set_mode,
228594a407ccSDmitry Baryshkov 	.owner		= THIS_MODULE,
228694a407ccSDmitry Baryshkov };
228794a407ccSDmitry Baryshkov 
228827878615SJohan Hovold static int qmp_pcie_create(struct device *dev, struct device_node *np, int id,
228994a407ccSDmitry Baryshkov 			void __iomem *serdes, const struct qmp_phy_cfg *cfg)
229094a407ccSDmitry Baryshkov {
229194a407ccSDmitry Baryshkov 	struct qcom_qmp *qmp = dev_get_drvdata(dev);
229294a407ccSDmitry Baryshkov 	struct phy *generic_phy;
229394a407ccSDmitry Baryshkov 	struct qmp_phy *qphy;
229494a407ccSDmitry Baryshkov 	int ret;
229594a407ccSDmitry Baryshkov 
229694a407ccSDmitry Baryshkov 	qphy = devm_kzalloc(dev, sizeof(*qphy), GFP_KERNEL);
229794a407ccSDmitry Baryshkov 	if (!qphy)
229894a407ccSDmitry Baryshkov 		return -ENOMEM;
229994a407ccSDmitry Baryshkov 
230011bf53a3SDmitry Baryshkov 	qphy->mode = PHY_MODE_PCIE_RC;
230111bf53a3SDmitry Baryshkov 
230294a407ccSDmitry Baryshkov 	qphy->cfg = cfg;
230394a407ccSDmitry Baryshkov 	qphy->serdes = serdes;
230494a407ccSDmitry Baryshkov 	/*
23058d3bf724SJohan Hovold 	 * Get memory resources for the PHY:
230694a407ccSDmitry Baryshkov 	 * Resources are indexed as: tx -> 0; rx -> 1; pcs -> 2.
230794a407ccSDmitry Baryshkov 	 * For dual lane PHYs: tx2 -> 3, rx2 -> 4, pcs_misc (optional) -> 5
230894a407ccSDmitry Baryshkov 	 * For single lane PHYs: pcs_misc (optional) -> 3.
230994a407ccSDmitry Baryshkov 	 */
23104be26f69SJohan Hovold 	qphy->tx = devm_of_iomap(dev, np, 0, NULL);
23114be26f69SJohan Hovold 	if (IS_ERR(qphy->tx))
23124be26f69SJohan Hovold 		return PTR_ERR(qphy->tx);
231394a407ccSDmitry Baryshkov 
23140a40891bSDmitry Baryshkov 	if (of_device_is_compatible(dev->of_node, "qcom,sdm845-qhp-pcie-phy"))
23150a40891bSDmitry Baryshkov 		qphy->rx = qphy->tx;
23160a40891bSDmitry Baryshkov 	else
23174be26f69SJohan Hovold 		qphy->rx = devm_of_iomap(dev, np, 1, NULL);
23184be26f69SJohan Hovold 	if (IS_ERR(qphy->rx))
23194be26f69SJohan Hovold 		return PTR_ERR(qphy->rx);
232094a407ccSDmitry Baryshkov 
23214be26f69SJohan Hovold 	qphy->pcs = devm_of_iomap(dev, np, 2, NULL);
23224be26f69SJohan Hovold 	if (IS_ERR(qphy->pcs))
23234be26f69SJohan Hovold 		return PTR_ERR(qphy->pcs);
232494a407ccSDmitry Baryshkov 
2325f02543faSJohan Hovold 	if (cfg->lanes >= 2) {
23264be26f69SJohan Hovold 		qphy->tx2 = devm_of_iomap(dev, np, 3, NULL);
232769c90cb5SJohan Hovold 		if (IS_ERR(qphy->tx2))
232869c90cb5SJohan Hovold 			return PTR_ERR(qphy->tx2);
232969c90cb5SJohan Hovold 
23304be26f69SJohan Hovold 		qphy->rx2 = devm_of_iomap(dev, np, 4, NULL);
233169c90cb5SJohan Hovold 		if (IS_ERR(qphy->rx2))
233269c90cb5SJohan Hovold 			return PTR_ERR(qphy->rx2);
233394a407ccSDmitry Baryshkov 
23344be26f69SJohan Hovold 		qphy->pcs_misc = devm_of_iomap(dev, np, 5, NULL);
233594a407ccSDmitry Baryshkov 	} else {
23364be26f69SJohan Hovold 		qphy->pcs_misc = devm_of_iomap(dev, np, 3, NULL);
233794a407ccSDmitry Baryshkov 	}
233894a407ccSDmitry Baryshkov 
23394be26f69SJohan Hovold 	if (IS_ERR(qphy->pcs_misc) &&
2340af664324SDmitry Baryshkov 	    of_device_is_compatible(dev->of_node, "qcom,ipq6018-qmp-pcie-phy"))
2341af664324SDmitry Baryshkov 		qphy->pcs_misc = qphy->pcs + 0x400;
2342af664324SDmitry Baryshkov 
23434be26f69SJohan Hovold 	if (IS_ERR(qphy->pcs_misc)) {
23442566ad8eSDmitry Baryshkov 		if (cfg->tables.pcs_misc ||
234511bf53a3SDmitry Baryshkov 		    (cfg->tables_rc && cfg->tables_rc->pcs_misc) ||
234611bf53a3SDmitry Baryshkov 		    (cfg->tables_ep && cfg->tables_ep->pcs_misc))
23474be26f69SJohan Hovold 			return PTR_ERR(qphy->pcs_misc);
2348ecd5507eSJohan Hovold 	}
234994a407ccSDmitry Baryshkov 
2350f8432544SJohan Hovold 	qphy->pipe_clk = devm_get_clk_from_child(dev, np, NULL);
235194a407ccSDmitry Baryshkov 	if (IS_ERR(qphy->pipe_clk)) {
23528f662cd9SJohan Hovold 		return dev_err_probe(dev, PTR_ERR(qphy->pipe_clk),
23538f662cd9SJohan Hovold 				     "failed to get lane%d pipe clock\n", id);
235494a407ccSDmitry Baryshkov 	}
235594a407ccSDmitry Baryshkov 
235627878615SJohan Hovold 	generic_phy = devm_phy_create(dev, np, &qmp_pcie_ops);
235794a407ccSDmitry Baryshkov 	if (IS_ERR(generic_phy)) {
235894a407ccSDmitry Baryshkov 		ret = PTR_ERR(generic_phy);
235994a407ccSDmitry Baryshkov 		dev_err(dev, "failed to create qphy %d\n", ret);
236094a407ccSDmitry Baryshkov 		return ret;
236194a407ccSDmitry Baryshkov 	}
236294a407ccSDmitry Baryshkov 
236394a407ccSDmitry Baryshkov 	qphy->phy = generic_phy;
236494a407ccSDmitry Baryshkov 	qphy->qmp = qmp;
236594a407ccSDmitry Baryshkov 	qmp->phys[id] = qphy;
236694a407ccSDmitry Baryshkov 	phy_set_drvdata(generic_phy, qphy);
236794a407ccSDmitry Baryshkov 
236894a407ccSDmitry Baryshkov 	return 0;
236994a407ccSDmitry Baryshkov }
237094a407ccSDmitry Baryshkov 
237127878615SJohan Hovold static const struct of_device_id qmp_pcie_of_match_table[] = {
237294a407ccSDmitry Baryshkov 	{
237394a407ccSDmitry Baryshkov 		.compatible = "qcom,msm8998-qmp-pcie-phy",
237494a407ccSDmitry Baryshkov 		.data = &msm8998_pciephy_cfg,
237594a407ccSDmitry Baryshkov 	}, {
237694a407ccSDmitry Baryshkov 		.compatible = "qcom,ipq8074-qmp-pcie-phy",
237794a407ccSDmitry Baryshkov 		.data = &ipq8074_pciephy_cfg,
237894a407ccSDmitry Baryshkov 	}, {
2379334fad18SRobert Marko 		.compatible = "qcom,ipq8074-qmp-gen3-pcie-phy",
2380334fad18SRobert Marko 		.data = &ipq8074_pciephy_gen3_cfg,
2381334fad18SRobert Marko 	}, {
238294a407ccSDmitry Baryshkov 		.compatible = "qcom,ipq6018-qmp-pcie-phy",
238394a407ccSDmitry Baryshkov 		.data = &ipq6018_pciephy_cfg,
238494a407ccSDmitry Baryshkov 	}, {
238594a407ccSDmitry Baryshkov 		.compatible = "qcom,sc8180x-qmp-pcie-phy",
238694a407ccSDmitry Baryshkov 		.data = &sc8180x_pciephy_cfg,
238794a407ccSDmitry Baryshkov 	}, {
238894a407ccSDmitry Baryshkov 		.compatible = "qcom,sdm845-qhp-pcie-phy",
238994a407ccSDmitry Baryshkov 		.data = &sdm845_qhp_pciephy_cfg,
239094a407ccSDmitry Baryshkov 	}, {
239194a407ccSDmitry Baryshkov 		.compatible = "qcom,sdm845-qmp-pcie-phy",
239294a407ccSDmitry Baryshkov 		.data = &sdm845_qmp_pciephy_cfg,
239394a407ccSDmitry Baryshkov 	}, {
239494a407ccSDmitry Baryshkov 		.compatible = "qcom,sm8250-qmp-gen3x1-pcie-phy",
239594a407ccSDmitry Baryshkov 		.data = &sm8250_qmp_gen3x1_pciephy_cfg,
239694a407ccSDmitry Baryshkov 	}, {
239794a407ccSDmitry Baryshkov 		.compatible = "qcom,sm8250-qmp-gen3x2-pcie-phy",
239894a407ccSDmitry Baryshkov 		.data = &sm8250_qmp_gen3x2_pciephy_cfg,
239994a407ccSDmitry Baryshkov 	}, {
240094a407ccSDmitry Baryshkov 		.compatible = "qcom,sm8250-qmp-modem-pcie-phy",
240194a407ccSDmitry Baryshkov 		.data = &sm8250_qmp_gen3x2_pciephy_cfg,
240294a407ccSDmitry Baryshkov 	}, {
240394a407ccSDmitry Baryshkov 		.compatible = "qcom,sdx55-qmp-pcie-phy",
240494a407ccSDmitry Baryshkov 		.data = &sdx55_qmp_pciephy_cfg,
240594a407ccSDmitry Baryshkov 	}, {
240694a407ccSDmitry Baryshkov 		.compatible = "qcom,sm8450-qmp-gen3x1-pcie-phy",
240794a407ccSDmitry Baryshkov 		.data = &sm8450_qmp_gen3x1_pciephy_cfg,
240894a407ccSDmitry Baryshkov 	}, {
240994a407ccSDmitry Baryshkov 		.compatible = "qcom,sm8450-qmp-gen4x2-pcie-phy",
241094a407ccSDmitry Baryshkov 		.data = &sm8450_qmp_gen4x2_pciephy_cfg,
241194a407ccSDmitry Baryshkov 	},
241294a407ccSDmitry Baryshkov 	{ },
241394a407ccSDmitry Baryshkov };
241427878615SJohan Hovold MODULE_DEVICE_TABLE(of, qmp_pcie_of_match_table);
241594a407ccSDmitry Baryshkov 
241627878615SJohan Hovold static int qmp_pcie_probe(struct platform_device *pdev)
241794a407ccSDmitry Baryshkov {
241894a407ccSDmitry Baryshkov 	struct qcom_qmp *qmp;
241994a407ccSDmitry Baryshkov 	struct device *dev = &pdev->dev;
242094a407ccSDmitry Baryshkov 	struct device_node *child;
242194a407ccSDmitry Baryshkov 	struct phy_provider *phy_provider;
242294a407ccSDmitry Baryshkov 	void __iomem *serdes;
242394a407ccSDmitry Baryshkov 	const struct qmp_phy_cfg *cfg = NULL;
24241239fd71SDmitry Baryshkov 	int num, id;
242594a407ccSDmitry Baryshkov 	int ret;
242694a407ccSDmitry Baryshkov 
242794a407ccSDmitry Baryshkov 	qmp = devm_kzalloc(dev, sizeof(*qmp), GFP_KERNEL);
242894a407ccSDmitry Baryshkov 	if (!qmp)
242994a407ccSDmitry Baryshkov 		return -ENOMEM;
243094a407ccSDmitry Baryshkov 
243194a407ccSDmitry Baryshkov 	qmp->dev = dev;
243294a407ccSDmitry Baryshkov 	dev_set_drvdata(dev, qmp);
243394a407ccSDmitry Baryshkov 
243494a407ccSDmitry Baryshkov 	/* Get the specific init parameters of QMP phy */
243594a407ccSDmitry Baryshkov 	cfg = of_device_get_match_data(dev);
2436b35a5311SDmitry Baryshkov 	if (!cfg)
243794a407ccSDmitry Baryshkov 		return -EINVAL;
243894a407ccSDmitry Baryshkov 
243994a407ccSDmitry Baryshkov 	/* per PHY serdes; usually located at base address */
2440da07a06bSDmitry Baryshkov 	serdes = devm_platform_ioremap_resource(pdev, 0);
244194a407ccSDmitry Baryshkov 	if (IS_ERR(serdes))
244294a407ccSDmitry Baryshkov 		return PTR_ERR(serdes);
244394a407ccSDmitry Baryshkov 
244427878615SJohan Hovold 	ret = qmp_pcie_clk_init(dev, cfg);
244594a407ccSDmitry Baryshkov 	if (ret)
244694a407ccSDmitry Baryshkov 		return ret;
244794a407ccSDmitry Baryshkov 
244827878615SJohan Hovold 	ret = qmp_pcie_reset_init(dev, cfg);
244994a407ccSDmitry Baryshkov 	if (ret)
245094a407ccSDmitry Baryshkov 		return ret;
245194a407ccSDmitry Baryshkov 
245227878615SJohan Hovold 	ret = qmp_pcie_vreg_init(dev, cfg);
2453a548b6b4SYuan Can 	if (ret)
2454a548b6b4SYuan Can 		return dev_err_probe(dev, ret,
2455a548b6b4SYuan Can 				     "failed to get regulator supplies\n");
245694a407ccSDmitry Baryshkov 
245794a407ccSDmitry Baryshkov 	num = of_get_available_child_count(dev->of_node);
245894a407ccSDmitry Baryshkov 	/* do we have a rogue child node ? */
24591239fd71SDmitry Baryshkov 	if (num > 1)
246094a407ccSDmitry Baryshkov 		return -EINVAL;
246194a407ccSDmitry Baryshkov 
246294a407ccSDmitry Baryshkov 	qmp->phys = devm_kcalloc(dev, num, sizeof(*qmp->phys), GFP_KERNEL);
246394a407ccSDmitry Baryshkov 	if (!qmp->phys)
246494a407ccSDmitry Baryshkov 		return -ENOMEM;
246594a407ccSDmitry Baryshkov 
246694a407ccSDmitry Baryshkov 	id = 0;
246794a407ccSDmitry Baryshkov 	for_each_available_child_of_node(dev->of_node, child) {
246894a407ccSDmitry Baryshkov 		/* Create per-lane phy */
246927878615SJohan Hovold 		ret = qmp_pcie_create(dev, child, id, serdes, cfg);
247094a407ccSDmitry Baryshkov 		if (ret) {
247194a407ccSDmitry Baryshkov 			dev_err(dev, "failed to create lane%d phy, %d\n",
247294a407ccSDmitry Baryshkov 				id, ret);
247394a407ccSDmitry Baryshkov 			goto err_node_put;
247494a407ccSDmitry Baryshkov 		}
247594a407ccSDmitry Baryshkov 
247694a407ccSDmitry Baryshkov 		/*
247794a407ccSDmitry Baryshkov 		 * Register the pipe clock provided by phy.
247894a407ccSDmitry Baryshkov 		 * See function description to see details of this pipe clock.
247994a407ccSDmitry Baryshkov 		 */
248094a407ccSDmitry Baryshkov 		ret = phy_pipe_clk_register(qmp, child);
248194a407ccSDmitry Baryshkov 		if (ret) {
248294a407ccSDmitry Baryshkov 			dev_err(qmp->dev,
248394a407ccSDmitry Baryshkov 				"failed to register pipe clock source\n");
248494a407ccSDmitry Baryshkov 			goto err_node_put;
248594a407ccSDmitry Baryshkov 		}
2486da07a06bSDmitry Baryshkov 
248794a407ccSDmitry Baryshkov 		id++;
248894a407ccSDmitry Baryshkov 	}
248994a407ccSDmitry Baryshkov 
249094a407ccSDmitry Baryshkov 	phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
249194a407ccSDmitry Baryshkov 
249294a407ccSDmitry Baryshkov 	return PTR_ERR_OR_ZERO(phy_provider);
249394a407ccSDmitry Baryshkov 
249494a407ccSDmitry Baryshkov err_node_put:
249594a407ccSDmitry Baryshkov 	of_node_put(child);
249694a407ccSDmitry Baryshkov 	return ret;
249794a407ccSDmitry Baryshkov }
249894a407ccSDmitry Baryshkov 
249927878615SJohan Hovold static struct platform_driver qmp_pcie_driver = {
250027878615SJohan Hovold 	.probe		= qmp_pcie_probe,
250194a407ccSDmitry Baryshkov 	.driver = {
2502b35a5311SDmitry Baryshkov 		.name	= "qcom-qmp-pcie-phy",
250327878615SJohan Hovold 		.of_match_table = qmp_pcie_of_match_table,
250494a407ccSDmitry Baryshkov 	},
250594a407ccSDmitry Baryshkov };
250694a407ccSDmitry Baryshkov 
250727878615SJohan Hovold module_platform_driver(qmp_pcie_driver);
250894a407ccSDmitry Baryshkov 
250994a407ccSDmitry Baryshkov MODULE_AUTHOR("Vivek Gautam <vivek.gautam@codeaurora.org>");
2510b35a5311SDmitry Baryshkov MODULE_DESCRIPTION("Qualcomm QMP PCIe PHY driver");
251194a407ccSDmitry Baryshkov MODULE_LICENSE("GPL v2");
2512