18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright (c) 2017, The Linux Foundation. All rights reserved.
48c2ecf20Sopenharmony_ci */
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ci#include <linux/clk.h>
78c2ecf20Sopenharmony_ci#include <linux/clk-provider.h>
88c2ecf20Sopenharmony_ci#include <linux/delay.h>
98c2ecf20Sopenharmony_ci#include <linux/err.h>
108c2ecf20Sopenharmony_ci#include <linux/io.h>
118c2ecf20Sopenharmony_ci#include <linux/iopoll.h>
128c2ecf20Sopenharmony_ci#include <linux/kernel.h>
138c2ecf20Sopenharmony_ci#include <linux/module.h>
148c2ecf20Sopenharmony_ci#include <linux/of.h>
158c2ecf20Sopenharmony_ci#include <linux/of_device.h>
168c2ecf20Sopenharmony_ci#include <linux/of_address.h>
178c2ecf20Sopenharmony_ci#include <linux/phy/phy.h>
188c2ecf20Sopenharmony_ci#include <linux/platform_device.h>
198c2ecf20Sopenharmony_ci#include <linux/regulator/consumer.h>
208c2ecf20Sopenharmony_ci#include <linux/reset.h>
218c2ecf20Sopenharmony_ci#include <linux/slab.h>
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci#include <dt-bindings/phy/phy.h>
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_ci#include "phy-qcom-qmp.h"
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci/* QPHY_SW_RESET bit */
288c2ecf20Sopenharmony_ci#define SW_RESET				BIT(0)
298c2ecf20Sopenharmony_ci/* QPHY_POWER_DOWN_CONTROL */
308c2ecf20Sopenharmony_ci#define SW_PWRDN				BIT(0)
318c2ecf20Sopenharmony_ci#define REFCLK_DRV_DSBL				BIT(1)
328c2ecf20Sopenharmony_ci/* QPHY_START_CONTROL bits */
338c2ecf20Sopenharmony_ci#define SERDES_START				BIT(0)
348c2ecf20Sopenharmony_ci#define PCS_START				BIT(1)
358c2ecf20Sopenharmony_ci#define PLL_READY_GATE_EN			BIT(3)
368c2ecf20Sopenharmony_ci/* QPHY_PCS_STATUS bit */
378c2ecf20Sopenharmony_ci#define PHYSTATUS				BIT(6)
388c2ecf20Sopenharmony_ci/* QPHY_PCS_READY_STATUS & QPHY_COM_PCS_READY_STATUS bit */
398c2ecf20Sopenharmony_ci#define PCS_READY				BIT(0)
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ci/* QPHY_V3_DP_COM_RESET_OVRD_CTRL register bits */
428c2ecf20Sopenharmony_ci/* DP PHY soft reset */
438c2ecf20Sopenharmony_ci#define SW_DPPHY_RESET				BIT(0)
448c2ecf20Sopenharmony_ci/* mux to select DP PHY reset control, 0:HW control, 1: software reset */
458c2ecf20Sopenharmony_ci#define SW_DPPHY_RESET_MUX			BIT(1)
468c2ecf20Sopenharmony_ci/* USB3 PHY soft reset */
478c2ecf20Sopenharmony_ci#define SW_USB3PHY_RESET			BIT(2)
488c2ecf20Sopenharmony_ci/* mux to select USB3 PHY reset control, 0:HW control, 1: software reset */
498c2ecf20Sopenharmony_ci#define SW_USB3PHY_RESET_MUX			BIT(3)
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_ci/* QPHY_V3_DP_COM_PHY_MODE_CTRL register bits */
528c2ecf20Sopenharmony_ci#define USB3_MODE				BIT(0) /* enables USB3 mode */
538c2ecf20Sopenharmony_ci#define DP_MODE					BIT(1) /* enables DP mode */
548c2ecf20Sopenharmony_ci
558c2ecf20Sopenharmony_ci/* QPHY_PCS_AUTONOMOUS_MODE_CTRL register bits */
568c2ecf20Sopenharmony_ci#define ARCVR_DTCT_EN				BIT(0)
578c2ecf20Sopenharmony_ci#define ALFPS_DTCT_EN				BIT(1)
588c2ecf20Sopenharmony_ci#define ARCVR_DTCT_EVENT_SEL			BIT(4)
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_ci/* QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR register bits */
618c2ecf20Sopenharmony_ci#define IRQ_CLEAR				BIT(0)
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_ci/* QPHY_PCS_LFPS_RXTERM_IRQ_STATUS register bits */
648c2ecf20Sopenharmony_ci#define RCVR_DETECT				BIT(0)
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_ci/* QPHY_V3_PCS_MISC_CLAMP_ENABLE register bits */
678c2ecf20Sopenharmony_ci#define CLAMP_EN				BIT(0) /* enables i/o clamp_n */
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_ci#define PHY_INIT_COMPLETE_TIMEOUT		10000
708c2ecf20Sopenharmony_ci#define POWER_DOWN_DELAY_US_MIN			10
718c2ecf20Sopenharmony_ci#define POWER_DOWN_DELAY_US_MAX			11
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_ci#define MAX_PROP_NAME				32
748c2ecf20Sopenharmony_ci
758c2ecf20Sopenharmony_ci/* Define the assumed distance between lanes for underspecified device trees. */
768c2ecf20Sopenharmony_ci#define QMP_PHY_LEGACY_LANE_STRIDE		0x400
778c2ecf20Sopenharmony_ci
788c2ecf20Sopenharmony_cistruct qmp_phy_init_tbl {
798c2ecf20Sopenharmony_ci	unsigned int offset;
808c2ecf20Sopenharmony_ci	unsigned int val;
818c2ecf20Sopenharmony_ci	/*
828c2ecf20Sopenharmony_ci	 * register part of layout ?
838c2ecf20Sopenharmony_ci	 * if yes, then offset gives index in the reg-layout
848c2ecf20Sopenharmony_ci	 */
858c2ecf20Sopenharmony_ci	bool in_layout;
868c2ecf20Sopenharmony_ci	/*
878c2ecf20Sopenharmony_ci	 * mask of lanes for which this register is written
888c2ecf20Sopenharmony_ci	 * for cases when second lane needs different values
898c2ecf20Sopenharmony_ci	 */
908c2ecf20Sopenharmony_ci	u8 lane_mask;
918c2ecf20Sopenharmony_ci};
928c2ecf20Sopenharmony_ci
938c2ecf20Sopenharmony_ci#define QMP_PHY_INIT_CFG(o, v)		\
948c2ecf20Sopenharmony_ci	{				\
958c2ecf20Sopenharmony_ci		.offset = o,		\
968c2ecf20Sopenharmony_ci		.val = v,		\
978c2ecf20Sopenharmony_ci		.lane_mask = 0xff,	\
988c2ecf20Sopenharmony_ci	}
998c2ecf20Sopenharmony_ci
1008c2ecf20Sopenharmony_ci#define QMP_PHY_INIT_CFG_L(o, v)	\
1018c2ecf20Sopenharmony_ci	{				\
1028c2ecf20Sopenharmony_ci		.offset = o,		\
1038c2ecf20Sopenharmony_ci		.val = v,		\
1048c2ecf20Sopenharmony_ci		.in_layout = true,	\
1058c2ecf20Sopenharmony_ci		.lane_mask = 0xff,	\
1068c2ecf20Sopenharmony_ci	}
1078c2ecf20Sopenharmony_ci
1088c2ecf20Sopenharmony_ci#define QMP_PHY_INIT_CFG_LANE(o, v, l)	\
1098c2ecf20Sopenharmony_ci	{				\
1108c2ecf20Sopenharmony_ci		.offset = o,		\
1118c2ecf20Sopenharmony_ci		.val = v,		\
1128c2ecf20Sopenharmony_ci		.lane_mask = l,		\
1138c2ecf20Sopenharmony_ci	}
1148c2ecf20Sopenharmony_ci
1158c2ecf20Sopenharmony_ci/* set of registers with offsets different per-PHY */
1168c2ecf20Sopenharmony_cienum qphy_reg_layout {
1178c2ecf20Sopenharmony_ci	/* Common block control registers */
1188c2ecf20Sopenharmony_ci	QPHY_COM_SW_RESET,
1198c2ecf20Sopenharmony_ci	QPHY_COM_POWER_DOWN_CONTROL,
1208c2ecf20Sopenharmony_ci	QPHY_COM_START_CONTROL,
1218c2ecf20Sopenharmony_ci	QPHY_COM_PCS_READY_STATUS,
1228c2ecf20Sopenharmony_ci	/* PCS registers */
1238c2ecf20Sopenharmony_ci	QPHY_PLL_LOCK_CHK_DLY_TIME,
1248c2ecf20Sopenharmony_ci	QPHY_FLL_CNTRL1,
1258c2ecf20Sopenharmony_ci	QPHY_FLL_CNTRL2,
1268c2ecf20Sopenharmony_ci	QPHY_FLL_CNT_VAL_L,
1278c2ecf20Sopenharmony_ci	QPHY_FLL_CNT_VAL_H_TOL,
1288c2ecf20Sopenharmony_ci	QPHY_FLL_MAN_CODE,
1298c2ecf20Sopenharmony_ci	QPHY_SW_RESET,
1308c2ecf20Sopenharmony_ci	QPHY_START_CTRL,
1318c2ecf20Sopenharmony_ci	QPHY_PCS_READY_STATUS,
1328c2ecf20Sopenharmony_ci	QPHY_PCS_STATUS,
1338c2ecf20Sopenharmony_ci	QPHY_PCS_AUTONOMOUS_MODE_CTRL,
1348c2ecf20Sopenharmony_ci	QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR,
1358c2ecf20Sopenharmony_ci	QPHY_PCS_LFPS_RXTERM_IRQ_STATUS,
1368c2ecf20Sopenharmony_ci	QPHY_PCS_POWER_DOWN_CONTROL,
1378c2ecf20Sopenharmony_ci	/* Keep last to ensure regs_layout arrays are properly initialized */
1388c2ecf20Sopenharmony_ci	QPHY_LAYOUT_SIZE
1398c2ecf20Sopenharmony_ci};
1408c2ecf20Sopenharmony_ci
1418c2ecf20Sopenharmony_cistatic const unsigned int msm8996_ufsphy_regs_layout[QPHY_LAYOUT_SIZE] = {
1428c2ecf20Sopenharmony_ci	[QPHY_START_CTRL]		= 0x00,
1438c2ecf20Sopenharmony_ci	[QPHY_PCS_READY_STATUS]		= 0x168,
1448c2ecf20Sopenharmony_ci};
1458c2ecf20Sopenharmony_ci
1468c2ecf20Sopenharmony_cistatic const unsigned int pciephy_regs_layout[QPHY_LAYOUT_SIZE] = {
1478c2ecf20Sopenharmony_ci	[QPHY_COM_SW_RESET]		= 0x400,
1488c2ecf20Sopenharmony_ci	[QPHY_COM_POWER_DOWN_CONTROL]	= 0x404,
1498c2ecf20Sopenharmony_ci	[QPHY_COM_START_CONTROL]	= 0x408,
1508c2ecf20Sopenharmony_ci	[QPHY_COM_PCS_READY_STATUS]	= 0x448,
1518c2ecf20Sopenharmony_ci	[QPHY_PLL_LOCK_CHK_DLY_TIME]	= 0xa8,
1528c2ecf20Sopenharmony_ci	[QPHY_FLL_CNTRL1]		= 0xc4,
1538c2ecf20Sopenharmony_ci	[QPHY_FLL_CNTRL2]		= 0xc8,
1548c2ecf20Sopenharmony_ci	[QPHY_FLL_CNT_VAL_L]		= 0xcc,
1558c2ecf20Sopenharmony_ci	[QPHY_FLL_CNT_VAL_H_TOL]	= 0xd0,
1568c2ecf20Sopenharmony_ci	[QPHY_FLL_MAN_CODE]		= 0xd4,
1578c2ecf20Sopenharmony_ci	[QPHY_SW_RESET]			= 0x00,
1588c2ecf20Sopenharmony_ci	[QPHY_START_CTRL]		= 0x08,
1598c2ecf20Sopenharmony_ci	[QPHY_PCS_STATUS]		= 0x174,
1608c2ecf20Sopenharmony_ci};
1618c2ecf20Sopenharmony_ci
1628c2ecf20Sopenharmony_cistatic const unsigned int usb3phy_regs_layout[QPHY_LAYOUT_SIZE] = {
1638c2ecf20Sopenharmony_ci	[QPHY_FLL_CNTRL1]		= 0xc0,
1648c2ecf20Sopenharmony_ci	[QPHY_FLL_CNTRL2]		= 0xc4,
1658c2ecf20Sopenharmony_ci	[QPHY_FLL_CNT_VAL_L]		= 0xc8,
1668c2ecf20Sopenharmony_ci	[QPHY_FLL_CNT_VAL_H_TOL]	= 0xcc,
1678c2ecf20Sopenharmony_ci	[QPHY_FLL_MAN_CODE]		= 0xd0,
1688c2ecf20Sopenharmony_ci	[QPHY_SW_RESET]			= 0x00,
1698c2ecf20Sopenharmony_ci	[QPHY_START_CTRL]		= 0x08,
1708c2ecf20Sopenharmony_ci	[QPHY_PCS_STATUS]		= 0x17c,
1718c2ecf20Sopenharmony_ci	[QPHY_PCS_AUTONOMOUS_MODE_CTRL]	= 0x0d4,
1728c2ecf20Sopenharmony_ci	[QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR]  = 0x0d8,
1738c2ecf20Sopenharmony_ci	[QPHY_PCS_LFPS_RXTERM_IRQ_STATUS] = 0x178,
1748c2ecf20Sopenharmony_ci};
1758c2ecf20Sopenharmony_ci
1768c2ecf20Sopenharmony_cistatic const unsigned int qmp_v3_usb3phy_regs_layout[QPHY_LAYOUT_SIZE] = {
1778c2ecf20Sopenharmony_ci	[QPHY_SW_RESET]			= 0x00,
1788c2ecf20Sopenharmony_ci	[QPHY_START_CTRL]		= 0x08,
1798c2ecf20Sopenharmony_ci	[QPHY_PCS_STATUS]		= 0x174,
1808c2ecf20Sopenharmony_ci	[QPHY_PCS_AUTONOMOUS_MODE_CTRL]	= 0x0d8,
1818c2ecf20Sopenharmony_ci	[QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR]  = 0x0dc,
1828c2ecf20Sopenharmony_ci	[QPHY_PCS_LFPS_RXTERM_IRQ_STATUS] = 0x170,
1838c2ecf20Sopenharmony_ci};
1848c2ecf20Sopenharmony_ci
1858c2ecf20Sopenharmony_cistatic const unsigned int sdm845_qmp_pciephy_regs_layout[QPHY_LAYOUT_SIZE] = {
1868c2ecf20Sopenharmony_ci	[QPHY_SW_RESET]			= 0x00,
1878c2ecf20Sopenharmony_ci	[QPHY_START_CTRL]		= 0x08,
1888c2ecf20Sopenharmony_ci	[QPHY_PCS_STATUS]		= 0x174,
1898c2ecf20Sopenharmony_ci};
1908c2ecf20Sopenharmony_ci
1918c2ecf20Sopenharmony_cistatic const unsigned int sdm845_qhp_pciephy_regs_layout[QPHY_LAYOUT_SIZE] = {
1928c2ecf20Sopenharmony_ci	[QPHY_SW_RESET]			= 0x00,
1938c2ecf20Sopenharmony_ci	[QPHY_START_CTRL]		= 0x08,
1948c2ecf20Sopenharmony_ci	[QPHY_PCS_STATUS]		= 0x2ac,
1958c2ecf20Sopenharmony_ci};
1968c2ecf20Sopenharmony_ci
1978c2ecf20Sopenharmony_cistatic const unsigned int qmp_v4_usb3phy_regs_layout[QPHY_LAYOUT_SIZE] = {
1988c2ecf20Sopenharmony_ci	[QPHY_SW_RESET]			= 0x00,
1998c2ecf20Sopenharmony_ci	[QPHY_START_CTRL]		= 0x44,
2008c2ecf20Sopenharmony_ci	[QPHY_PCS_STATUS]		= 0x14,
2018c2ecf20Sopenharmony_ci	[QPHY_PCS_POWER_DOWN_CONTROL]	= 0x40,
2028c2ecf20Sopenharmony_ci	[QPHY_PCS_AUTONOMOUS_MODE_CTRL]	= 0x308,
2038c2ecf20Sopenharmony_ci	[QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR] = 0x314,
2048c2ecf20Sopenharmony_ci};
2058c2ecf20Sopenharmony_ci
2068c2ecf20Sopenharmony_cistatic const unsigned int qmp_v4_usb3_uniphy_regs_layout[QPHY_LAYOUT_SIZE] = {
2078c2ecf20Sopenharmony_ci	[QPHY_SW_RESET]			= 0x00,
2088c2ecf20Sopenharmony_ci	[QPHY_START_CTRL]		= 0x44,
2098c2ecf20Sopenharmony_ci	[QPHY_PCS_STATUS]		= 0x14,
2108c2ecf20Sopenharmony_ci	[QPHY_PCS_POWER_DOWN_CONTROL]	= 0x40,
2118c2ecf20Sopenharmony_ci	[QPHY_PCS_AUTONOMOUS_MODE_CTRL]	= 0x608,
2128c2ecf20Sopenharmony_ci	[QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR]  = 0x614,
2138c2ecf20Sopenharmony_ci};
2148c2ecf20Sopenharmony_ci
2158c2ecf20Sopenharmony_cistatic const unsigned int sdm845_ufsphy_regs_layout[QPHY_LAYOUT_SIZE] = {
2168c2ecf20Sopenharmony_ci	[QPHY_START_CTRL]		= 0x00,
2178c2ecf20Sopenharmony_ci	[QPHY_PCS_READY_STATUS]		= 0x160,
2188c2ecf20Sopenharmony_ci};
2198c2ecf20Sopenharmony_ci
2208c2ecf20Sopenharmony_cistatic const unsigned int sm8150_ufsphy_regs_layout[QPHY_LAYOUT_SIZE] = {
2218c2ecf20Sopenharmony_ci	[QPHY_START_CTRL]		= QPHY_V4_PCS_UFS_PHY_START,
2228c2ecf20Sopenharmony_ci	[QPHY_PCS_READY_STATUS]		= QPHY_V4_PCS_UFS_READY_STATUS,
2238c2ecf20Sopenharmony_ci	[QPHY_SW_RESET]			= QPHY_V4_PCS_UFS_SW_RESET,
2248c2ecf20Sopenharmony_ci};
2258c2ecf20Sopenharmony_ci
2268c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl ipq8074_usb3_serdes_tbl[] = {
2278c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_SYSCLK_EN_SEL, 0x1a),
2288c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_BIAS_EN_CLKBUFLR_EN, 0x08),
2298c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_CLK_SELECT, 0x30),
2308c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_BG_TRIM, 0x0f),
2318c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_RX_UCDR_FASTLOCK_FO_GAIN, 0x0b),
2328c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_SVS_MODE_CLK_SEL, 0x01),
2338c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_HSCLK_SEL, 0x00),
2348c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_CMN_CONFIG, 0x06),
2358c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_PLL_IVCO, 0x0f),
2368c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_SYS_CLK_CTRL, 0x06),
2378c2ecf20Sopenharmony_ci	/* PLL and Loop filter settings */
2388c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_DEC_START_MODE0, 0x82),
2398c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_DIV_FRAC_START1_MODE0, 0x55),
2408c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_DIV_FRAC_START2_MODE0, 0x55),
2418c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_DIV_FRAC_START3_MODE0, 0x03),
2428c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_CP_CTRL_MODE0, 0x0b),
2438c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_PLL_RCTRL_MODE0, 0x16),
2448c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_PLL_CCTRL_MODE0, 0x28),
2458c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_INTEGLOOP_GAIN0_MODE0, 0x80),
2468c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP1_MODE0, 0x15),
2478c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP2_MODE0, 0x34),
2488c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP3_MODE0, 0x00),
2498c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_CORE_CLK_EN, 0x00),
2508c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP_CFG, 0x00),
2518c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_MAP, 0x00),
2528c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_BG_TIMER, 0x0a),
2538c2ecf20Sopenharmony_ci	/* SSC settings */
2548c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_SSC_EN_CENTER, 0x01),
2558c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_SSC_PER1, 0x31),
2568c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_SSC_PER2, 0x01),
2578c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_SSC_ADJ_PER1, 0x00),
2588c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_SSC_ADJ_PER2, 0x00),
2598c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_SSC_STEP_SIZE1, 0xde),
2608c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_SSC_STEP_SIZE2, 0x07),
2618c2ecf20Sopenharmony_ci};
2628c2ecf20Sopenharmony_ci
2638c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl ipq8074_usb3_rx_tbl[] = {
2648c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_RX_UCDR_SO_GAIN, 0x06),
2658c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_RX_RX_EQU_ADAPTOR_CNTRL2, 0x02),
2668c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_RX_RX_EQU_ADAPTOR_CNTRL3, 0x4c),
2678c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_RX_RX_EQU_ADAPTOR_CNTRL4, 0xb8),
2688c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1, 0x77),
2698c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_RX_RX_OFFSET_ADAPTOR_CNTRL2, 0x80),
2708c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_RX_SIGDET_CNTRL, 0x03),
2718c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_RX_SIGDET_DEGLITCH_CNTRL, 0x16),
2728c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_RX_SIGDET_ENABLES, 0x0),
2738c2ecf20Sopenharmony_ci};
2748c2ecf20Sopenharmony_ci
2758c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl ipq8074_usb3_pcs_tbl[] = {
2768c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_V0, 0x15),
2778c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_V0, 0x0e),
2788c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNTRL2, 0x83),
2798c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNTRL1, 0x02),
2808c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNT_VAL_L, 0x09),
2818c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNT_VAL_H_TOL, 0xa2),
2828c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_MAN_CODE, 0x85),
2838c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_LOCK_DETECT_CONFIG1, 0xd1),
2848c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_LOCK_DETECT_CONFIG2, 0x1f),
2858c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_LOCK_DETECT_CONFIG3, 0x47),
2868c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_POWER_STATE_CONFIG2, 0x1b),
2878c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_RXEQTRAINING_WAIT_TIME, 0x75),
2888c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_RXEQTRAINING_RUN_TIME, 0x13),
2898c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_LFPS_TX_ECSTART_EQTLOCK, 0x86),
2908c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_PWRUP_RESET_DLY_TIME_AUXCLK, 0x04),
2918c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_TSYNC_RSYNC_TIME, 0x44),
2928c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_RCVR_DTCT_DLY_P1U2_L, 0xe7),
2938c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_RCVR_DTCT_DLY_P1U2_H, 0x03),
2948c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_RCVR_DTCT_DLY_U3_L, 0x40),
2958c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_RCVR_DTCT_DLY_U3_H, 0x00),
2968c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_RX_SIGDET_LVL, 0x88),
2978c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_V0, 0x17),
2988c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_V0, 0x0f),
2998c2ecf20Sopenharmony_ci};
3008c2ecf20Sopenharmony_ci
3018c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl msm8996_pcie_serdes_tbl[] = {
3028c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_BIAS_EN_CLKBUFLR_EN, 0x1c),
3038c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_CLK_ENABLE1, 0x10),
3048c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_CLK_SELECT, 0x33),
3058c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_CMN_CONFIG, 0x06),
3068c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP_EN, 0x42),
3078c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_MAP, 0x00),
3088c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_TIMER1, 0xff),
3098c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_TIMER2, 0x1f),
3108c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_HSCLK_SEL, 0x01),
3118c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_SVS_MODE_CLK_SEL, 0x01),
3128c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_CORE_CLK_EN, 0x00),
3138c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_CORECLK_DIV, 0x0a),
3148c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_BG_TIMER, 0x09),
3158c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_DEC_START_MODE0, 0x82),
3168c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_DIV_FRAC_START3_MODE0, 0x03),
3178c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_DIV_FRAC_START2_MODE0, 0x55),
3188c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_DIV_FRAC_START1_MODE0, 0x55),
3198c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP3_MODE0, 0x00),
3208c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP2_MODE0, 0x1a),
3218c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP1_MODE0, 0x0a),
3228c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_CLK_SELECT, 0x33),
3238c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_SYS_CLK_CTRL, 0x02),
3248c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_SYSCLK_BUF_ENABLE, 0x1f),
3258c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_SYSCLK_EN_SEL, 0x04),
3268c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_CP_CTRL_MODE0, 0x0b),
3278c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_PLL_RCTRL_MODE0, 0x16),
3288c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_PLL_CCTRL_MODE0, 0x28),
3298c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_INTEGLOOP_GAIN1_MODE0, 0x00),
3308c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_INTEGLOOP_GAIN0_MODE0, 0x80),
3318c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_SSC_EN_CENTER, 0x01),
3328c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_SSC_PER1, 0x31),
3338c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_SSC_PER2, 0x01),
3348c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_SSC_ADJ_PER1, 0x02),
3358c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_SSC_ADJ_PER2, 0x00),
3368c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_SSC_STEP_SIZE1, 0x2f),
3378c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_SSC_STEP_SIZE2, 0x19),
3388c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_RESCODE_DIV_NUM, 0x15),
3398c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_BG_TRIM, 0x0f),
3408c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_PLL_IVCO, 0x0f),
3418c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_CLK_EP_DIV, 0x19),
3428c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_CLK_ENABLE1, 0x10),
3438c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_HSCLK_SEL, 0x00),
3448c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_RESCODE_DIV_NUM, 0x40),
3458c2ecf20Sopenharmony_ci};
3468c2ecf20Sopenharmony_ci
3478c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl msm8996_pcie_tx_tbl[] = {
3488c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_TX_HIGHZ_TRANSCEIVEREN_BIAS_DRVR_EN, 0x45),
3498c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_TX_LANE_MODE, 0x06),
3508c2ecf20Sopenharmony_ci};
3518c2ecf20Sopenharmony_ci
3528c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl msm8996_pcie_rx_tbl[] = {
3538c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_RX_SIGDET_ENABLES, 0x1c),
3548c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_RX_RX_EQU_ADAPTOR_CNTRL2, 0x01),
3558c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_RX_RX_EQU_ADAPTOR_CNTRL3, 0x00),
3568c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_RX_RX_EQU_ADAPTOR_CNTRL4, 0xdb),
3578c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_RX_RX_BAND, 0x18),
3588c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_RX_UCDR_SO_GAIN, 0x04),
3598c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_RX_UCDR_SO_GAIN_HALF, 0x04),
3608c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x4b),
3618c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_RX_SIGDET_DEGLITCH_CNTRL, 0x14),
3628c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_RX_SIGDET_LVL, 0x19),
3638c2ecf20Sopenharmony_ci};
3648c2ecf20Sopenharmony_ci
3658c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl msm8996_pcie_pcs_tbl[] = {
3668c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_RX_IDLE_DTCT_CNTRL, 0x4c),
3678c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_PWRUP_RESET_DLY_TIME_AUXCLK, 0x00),
3688c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_LP_WAKEUP_DLY_TIME_AUXCLK, 0x01),
3698c2ecf20Sopenharmony_ci
3708c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG_L(QPHY_PLL_LOCK_CHK_DLY_TIME, 0x05),
3718c2ecf20Sopenharmony_ci
3728c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_ENDPOINT_REFCLK_DRIVE, 0x05),
3738c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_POWER_DOWN_CONTROL, 0x02),
3748c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_POWER_STATE_CONFIG4, 0x00),
3758c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_POWER_STATE_CONFIG1, 0xa3),
3768c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_TXDEEMPH_M3P5DB_V0, 0x0e),
3778c2ecf20Sopenharmony_ci};
3788c2ecf20Sopenharmony_ci
3798c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl msm8998_pcie_serdes_tbl[] = {
3808c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_BIAS_EN_CLKBUFLR_EN, 0x14),
3818c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_SELECT, 0x30),
3828c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_IVCO, 0x0f),
3838c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CMN_CONFIG, 0x06),
3848c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP_EN, 0x01),
3858c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_RESETSM_CNTRL, 0x20),
3868c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_MAP, 0x00),
3878c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE2_MODE0, 0x01),
3888c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE1_MODE0, 0xc9),
3898c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_TIMER1, 0xff),
3908c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_TIMER2, 0x3f),
3918c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SVS_MODE_CLK_SEL, 0x01),
3928c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CORE_CLK_EN, 0x00),
3938c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CORECLK_DIV_MODE0, 0x0a),
3948c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_EP_DIV, 0x19),
3958c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_ENABLE1, 0x90),
3968c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_DEC_START_MODE0, 0x82),
3978c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START3_MODE0, 0x03),
3988c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START2_MODE0, 0x55),
3998c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START1_MODE0, 0x55),
4008c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP3_MODE0, 0x00),
4018c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP2_MODE0, 0x0d),
4028c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP1_MODE0, 0x04),
4038c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_HSCLK_SEL, 0x00),
4048c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CP_CTRL_MODE0, 0x08),
4058c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_RCTRL_MODE0, 0x16),
4068c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_CCTRL_MODE0, 0x34),
4078c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CMN_CONFIG, 0x06),
4088c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_SELECT, 0x33),
4098c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYS_CLK_CTRL, 0x02),
4108c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYSCLK_BUF_ENABLE, 0x07),
4118c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYSCLK_EN_SEL, 0x04),
4128c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN1_MODE0, 0x00),
4138c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN0_MODE0, 0x3f),
4148c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_BG_TIMER, 0x09),
4158c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_EN_CENTER, 0x01),
4168c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_PER1, 0x40),
4178c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_PER2, 0x01),
4188c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_ADJ_PER1, 0x02),
4198c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_ADJ_PER2, 0x00),
4208c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_STEP_SIZE1, 0x7e),
4218c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_STEP_SIZE2, 0x15),
4228c2ecf20Sopenharmony_ci};
4238c2ecf20Sopenharmony_ci
4248c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl msm8998_pcie_tx_tbl[] = {
4258c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_TX_RES_CODE_LANE_OFFSET_TX, 0x02),
4268c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_TX_RCV_DETECT_LVL_2, 0x12),
4278c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_TX_HIGHZ_DRVR_EN, 0x10),
4288c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_TX_LANE_MODE_1, 0x06),
4298c2ecf20Sopenharmony_ci};
4308c2ecf20Sopenharmony_ci
4318c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl msm8998_pcie_rx_tbl[] = {
4328c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_CNTRL, 0x03),
4338c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_ENABLES, 0x1c),
4348c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_DEGLITCH_CNTRL, 0x14),
4358c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL2, 0x0a),
4368c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL3, 0x04),
4378c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL4, 0x1a),
4388c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x4b),
4398c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SO_GAIN, 0x04),
4408c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SO_GAIN_HALF, 0x04),
4418c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1, 0x00),
4428c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_OFFSET_ADAPTOR_CNTRL2, 0x80),
4438c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_INTERFACE_MODE, 0x40),
4448c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_PI_CONTROLS, 0x71),
4458c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_FASTLOCK_COUNT_LOW, 0x40),
4468c2ecf20Sopenharmony_ci};
4478c2ecf20Sopenharmony_ci
4488c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl msm8998_pcie_pcs_tbl[] = {
4498c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_ENDPOINT_REFCLK_DRIVE, 0x04),
4508c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_OSC_DTCT_ACTIONS, 0x00),
4518c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_PWRUP_RESET_DLY_TIME_AUXCLK, 0x01),
4528c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_L1SS_WAKEUP_DLY_TIME_AUXCLK_MSB, 0x00),
4538c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_L1SS_WAKEUP_DLY_TIME_AUXCLK_LSB, 0x20),
4548c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_LP_WAKEUP_DLY_TIME_AUXCLK_MSB, 0x00),
4558c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_LP_WAKEUP_DLY_TIME_AUXCLK, 0x01),
4568c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_PLL_LOCK_CHK_DLY_TIME, 0x73),
4578c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_RX_SIGDET_LVL, 0x99),
4588c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_SIGDET_CNTRL, 0x03),
4598c2ecf20Sopenharmony_ci};
4608c2ecf20Sopenharmony_ci
4618c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl msm8996_ufs_serdes_tbl[] = {
4628c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_POWER_DOWN_CONTROL, 0x01),
4638c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_CMN_CONFIG, 0x0e),
4648c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_SYSCLK_EN_SEL, 0xd7),
4658c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_CLK_SELECT, 0x30),
4668c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_SYS_CLK_CTRL, 0x06),
4678c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_BIAS_EN_CLKBUFLR_EN, 0x08),
4688c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_BG_TIMER, 0x0a),
4698c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_HSCLK_SEL, 0x05),
4708c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_CORECLK_DIV, 0x0a),
4718c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_CORECLK_DIV_MODE1, 0x0a),
4728c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP_EN, 0x01),
4738c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_CTRL, 0x10),
4748c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_RESETSM_CNTRL, 0x20),
4758c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_CORE_CLK_EN, 0x00),
4768c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP_CFG, 0x00),
4778c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_TIMER1, 0xff),
4788c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_TIMER2, 0x3f),
4798c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_MAP, 0x54),
4808c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_SVS_MODE_CLK_SEL, 0x05),
4818c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_DEC_START_MODE0, 0x82),
4828c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_DIV_FRAC_START1_MODE0, 0x00),
4838c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_DIV_FRAC_START2_MODE0, 0x00),
4848c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_DIV_FRAC_START3_MODE0, 0x00),
4858c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_CP_CTRL_MODE0, 0x0b),
4868c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_PLL_RCTRL_MODE0, 0x16),
4878c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_PLL_CCTRL_MODE0, 0x28),
4888c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_INTEGLOOP_GAIN0_MODE0, 0x80),
4898c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_INTEGLOOP_GAIN1_MODE0, 0x00),
4908c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE1_MODE0, 0x28),
4918c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE2_MODE0, 0x02),
4928c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP1_MODE0, 0xff),
4938c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP2_MODE0, 0x0c),
4948c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP3_MODE0, 0x00),
4958c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_DEC_START_MODE1, 0x98),
4968c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_DIV_FRAC_START1_MODE1, 0x00),
4978c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_DIV_FRAC_START2_MODE1, 0x00),
4988c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_DIV_FRAC_START3_MODE1, 0x00),
4998c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_CP_CTRL_MODE1, 0x0b),
5008c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_PLL_RCTRL_MODE1, 0x16),
5018c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_PLL_CCTRL_MODE1, 0x28),
5028c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_INTEGLOOP_GAIN0_MODE1, 0x80),
5038c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_INTEGLOOP_GAIN1_MODE1, 0x00),
5048c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE1_MODE1, 0xd6),
5058c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE2_MODE1, 0x00),
5068c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP1_MODE1, 0x32),
5078c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP2_MODE1, 0x0f),
5088c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP3_MODE1, 0x00),
5098c2ecf20Sopenharmony_ci};
5108c2ecf20Sopenharmony_ci
5118c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl msm8996_ufs_tx_tbl[] = {
5128c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_TX_HIGHZ_TRANSCEIVEREN_BIAS_DRVR_EN, 0x45),
5138c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_TX_LANE_MODE, 0x02),
5148c2ecf20Sopenharmony_ci};
5158c2ecf20Sopenharmony_ci
5168c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl msm8996_ufs_rx_tbl[] = {
5178c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_RX_SIGDET_LVL, 0x24),
5188c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_RX_SIGDET_CNTRL, 0x02),
5198c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_RX_RX_INTERFACE_MODE, 0x00),
5208c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_RX_SIGDET_DEGLITCH_CNTRL, 0x18),
5218c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_RX_UCDR_FASTLOCK_FO_GAIN, 0x0B),
5228c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_RX_RX_TERM_BW, 0x5b),
5238c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_RX_RX_EQ_GAIN1_LSB, 0xff),
5248c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_RX_RX_EQ_GAIN1_MSB, 0x3f),
5258c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_RX_RX_EQ_GAIN2_LSB, 0xff),
5268c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_RX_RX_EQ_GAIN2_MSB, 0x0f),
5278c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_RX_RX_EQU_ADAPTOR_CNTRL2, 0x0E),
5288c2ecf20Sopenharmony_ci};
5298c2ecf20Sopenharmony_ci
5308c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl msm8996_usb3_serdes_tbl[] = {
5318c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_SYSCLK_EN_SEL, 0x14),
5328c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_BIAS_EN_CLKBUFLR_EN, 0x08),
5338c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_CLK_SELECT, 0x30),
5348c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_CMN_CONFIG, 0x06),
5358c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_SVS_MODE_CLK_SEL, 0x01),
5368c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_HSCLK_SEL, 0x00),
5378c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_BG_TRIM, 0x0f),
5388c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_PLL_IVCO, 0x0f),
5398c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_SYS_CLK_CTRL, 0x04),
5408c2ecf20Sopenharmony_ci	/* PLL and Loop filter settings */
5418c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_DEC_START_MODE0, 0x82),
5428c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_DIV_FRAC_START1_MODE0, 0x55),
5438c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_DIV_FRAC_START2_MODE0, 0x55),
5448c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_DIV_FRAC_START3_MODE0, 0x03),
5458c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_CP_CTRL_MODE0, 0x0b),
5468c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_PLL_RCTRL_MODE0, 0x16),
5478c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_PLL_CCTRL_MODE0, 0x28),
5488c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_INTEGLOOP_GAIN0_MODE0, 0x80),
5498c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_CTRL, 0x00),
5508c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP1_MODE0, 0x15),
5518c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP2_MODE0, 0x34),
5528c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP3_MODE0, 0x00),
5538c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_CORE_CLK_EN, 0x00),
5548c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP_CFG, 0x00),
5558c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_MAP, 0x00),
5568c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_BG_TIMER, 0x0a),
5578c2ecf20Sopenharmony_ci	/* SSC settings */
5588c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_SSC_EN_CENTER, 0x01),
5598c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_SSC_PER1, 0x31),
5608c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_SSC_PER2, 0x01),
5618c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_SSC_ADJ_PER1, 0x00),
5628c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_SSC_ADJ_PER2, 0x00),
5638c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_SSC_STEP_SIZE1, 0xde),
5648c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_SSC_STEP_SIZE2, 0x07),
5658c2ecf20Sopenharmony_ci};
5668c2ecf20Sopenharmony_ci
5678c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl msm8996_usb3_tx_tbl[] = {
5688c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_TX_HIGHZ_TRANSCEIVEREN_BIAS_DRVR_EN, 0x45),
5698c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_TX_RCV_DETECT_LVL_2, 0x12),
5708c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_TX_LANE_MODE, 0x06),
5718c2ecf20Sopenharmony_ci};
5728c2ecf20Sopenharmony_ci
5738c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl msm8996_usb3_rx_tbl[] = {
5748c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_RX_UCDR_FASTLOCK_FO_GAIN, 0x0b),
5758c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_RX_UCDR_SO_GAIN, 0x04),
5768c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_RX_RX_EQU_ADAPTOR_CNTRL2, 0x02),
5778c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_RX_RX_EQU_ADAPTOR_CNTRL3, 0x4c),
5788c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_RX_RX_EQU_ADAPTOR_CNTRL4, 0xbb),
5798c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1, 0x77),
5808c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_RX_RX_OFFSET_ADAPTOR_CNTRL2, 0x80),
5818c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_RX_SIGDET_CNTRL, 0x03),
5828c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_RX_SIGDET_LVL, 0x18),
5838c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_RX_SIGDET_DEGLITCH_CNTRL, 0x16),
5848c2ecf20Sopenharmony_ci};
5858c2ecf20Sopenharmony_ci
5868c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl msm8996_usb3_pcs_tbl[] = {
5878c2ecf20Sopenharmony_ci	/* FLL settings */
5888c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG_L(QPHY_FLL_CNTRL2, 0x03),
5898c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG_L(QPHY_FLL_CNTRL1, 0x02),
5908c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG_L(QPHY_FLL_CNT_VAL_L, 0x09),
5918c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG_L(QPHY_FLL_CNT_VAL_H_TOL, 0x42),
5928c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG_L(QPHY_FLL_MAN_CODE, 0x85),
5938c2ecf20Sopenharmony_ci
5948c2ecf20Sopenharmony_ci	/* Lock Det settings */
5958c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_LOCK_DETECT_CONFIG1, 0xd1),
5968c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_LOCK_DETECT_CONFIG2, 0x1f),
5978c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_LOCK_DETECT_CONFIG3, 0x47),
5988c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_POWER_STATE_CONFIG2, 0x08),
5998c2ecf20Sopenharmony_ci};
6008c2ecf20Sopenharmony_ci
6018c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl ipq8074_pcie_serdes_tbl[] = {
6028c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_BIAS_EN_CLKBUFLR_EN, 0x18),
6038c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_CLK_ENABLE1, 0x10),
6048c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_BG_TRIM, 0xf),
6058c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP_EN, 0x1),
6068c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_MAP, 0x0),
6078c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_TIMER1, 0xff),
6088c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_TIMER2, 0x1f),
6098c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_CMN_CONFIG, 0x6),
6108c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_PLL_IVCO, 0xf),
6118c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_HSCLK_SEL, 0x0),
6128c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_SVS_MODE_CLK_SEL, 0x1),
6138c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_CORE_CLK_EN, 0x20),
6148c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_CORECLK_DIV, 0xa),
6158c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_RESETSM_CNTRL, 0x20),
6168c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_BG_TIMER, 0xa),
6178c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_SYSCLK_EN_SEL, 0xa),
6188c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_DEC_START_MODE0, 0x82),
6198c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_DIV_FRAC_START3_MODE0, 0x3),
6208c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_DIV_FRAC_START2_MODE0, 0x55),
6218c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_DIV_FRAC_START1_MODE0, 0x55),
6228c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP3_MODE0, 0x0),
6238c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP2_MODE0, 0xD),
6248c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP1_MODE0, 0xD04),
6258c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_CLK_SELECT, 0x33),
6268c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_SYS_CLK_CTRL, 0x2),
6278c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_SYSCLK_BUF_ENABLE, 0x1f),
6288c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_CP_CTRL_MODE0, 0xb),
6298c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_PLL_RCTRL_MODE0, 0x16),
6308c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_PLL_CCTRL_MODE0, 0x28),
6318c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_INTEGLOOP_GAIN1_MODE0, 0x0),
6328c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_INTEGLOOP_GAIN0_MODE0, 0x80),
6338c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_BIAS_EN_CTRL_BY_PSM, 0x1),
6348c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_SSC_EN_CENTER, 0x1),
6358c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_SSC_PER1, 0x31),
6368c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_SSC_PER2, 0x1),
6378c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_SSC_ADJ_PER1, 0x2),
6388c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_SSC_ADJ_PER2, 0x0),
6398c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_SSC_STEP_SIZE1, 0x2f),
6408c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_SSC_STEP_SIZE2, 0x19),
6418c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_COM_CLK_EP_DIV, 0x19),
6428c2ecf20Sopenharmony_ci};
6438c2ecf20Sopenharmony_ci
6448c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl ipq8074_pcie_tx_tbl[] = {
6458c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_TX_HIGHZ_TRANSCEIVEREN_BIAS_DRVR_EN, 0x45),
6468c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_TX_LANE_MODE, 0x6),
6478c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_TX_RES_CODE_LANE_OFFSET, 0x2),
6488c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_TX_RCV_DETECT_LVL_2, 0x12),
6498c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_TX_EMP_POST1_LVL, 0x36),
6508c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_TX_SLEW_CNTL, 0x0a),
6518c2ecf20Sopenharmony_ci};
6528c2ecf20Sopenharmony_ci
6538c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl ipq8074_pcie_rx_tbl[] = {
6548c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_RX_SIGDET_ENABLES, 0x1c),
6558c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_RX_SIGDET_DEGLITCH_CNTRL, 0x14),
6568c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_RX_RX_EQU_ADAPTOR_CNTRL2, 0x1),
6578c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_RX_RX_EQU_ADAPTOR_CNTRL3, 0x0),
6588c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_RX_RX_EQU_ADAPTOR_CNTRL4, 0xdb),
6598c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x4b),
6608c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_RX_UCDR_SO_GAIN, 0x4),
6618c2ecf20Sopenharmony_ci};
6628c2ecf20Sopenharmony_ci
6638c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl ipq8074_pcie_pcs_tbl[] = {
6648c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_ENDPOINT_REFCLK_DRIVE, 0x4),
6658c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_OSC_DTCT_ACTIONS, 0x0),
6668c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_PWRUP_RESET_DLY_TIME_AUXCLK, 0x40),
6678c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_L1SS_WAKEUP_DLY_TIME_AUXCLK_MSB, 0x0),
6688c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_L1SS_WAKEUP_DLY_TIME_AUXCLK_LSB, 0x40),
6698c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_PLL_LOCK_CHK_DLY_TIME_AUXCLK_LSB, 0x0),
6708c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_LP_WAKEUP_DLY_TIME_AUXCLK, 0x40),
6718c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG_L(QPHY_PLL_LOCK_CHK_DLY_TIME, 0x73),
6728c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_RX_SIGDET_LVL, 0x99),
6738c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_TXDEEMPH_M6DB_V0, 0x15),
6748c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_TXDEEMPH_M3P5DB_V0, 0xe),
6758c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG_L(QPHY_SW_RESET, 0x0),
6768c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG_L(QPHY_START_CTRL, 0x3),
6778c2ecf20Sopenharmony_ci};
6788c2ecf20Sopenharmony_ci
6798c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl sdm845_qmp_pcie_serdes_tbl[] = {
6808c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_BIAS_EN_CLKBUFLR_EN, 0x14),
6818c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_SELECT, 0x30),
6828c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_IVCO, 0x007),
6838c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CMN_CONFIG, 0x06),
6848c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP_EN, 0x01),
6858c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_RESETSM_CNTRL, 0x20),
6868c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_MAP, 0x00),
6878c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE2_MODE0, 0x01),
6888c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE1_MODE0, 0xc9),
6898c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_TIMER1, 0xff),
6908c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_TIMER2, 0x3f),
6918c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SVS_MODE_CLK_SEL, 0x01),
6928c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CORE_CLK_EN, 0x00),
6938c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CORECLK_DIV_MODE0, 0x0a),
6948c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_EP_DIV, 0x19),
6958c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_ENABLE1, 0x90),
6968c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_DEC_START_MODE0, 0x82),
6978c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START3_MODE0, 0x02),
6988c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START2_MODE0, 0xea),
6998c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START1_MODE0, 0xab),
7008c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP3_MODE0, 0x00),
7018c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP2_MODE0, 0x0d),
7028c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP1_MODE0, 0x04),
7038c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_HSCLK_SEL, 0x00),
7048c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CP_CTRL_MODE0, 0x06),
7058c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_RCTRL_MODE0, 0x16),
7068c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_CCTRL_MODE0, 0x36),
7078c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CMN_MODE, 0x01),
7088c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_SELECT, 0x33),
7098c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYS_CLK_CTRL, 0x02),
7108c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYSCLK_BUF_ENABLE, 0x06),
7118c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYSCLK_EN_SEL, 0x04),
7128c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN1_MODE0, 0x00),
7138c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN0_MODE0, 0x3f),
7148c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_BG_TIMER, 0x09),
7158c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_EN_CENTER, 0x01),
7168c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_PER1, 0x40),
7178c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_PER2, 0x01),
7188c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_ADJ_PER1, 0x02),
7198c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_ADJ_PER2, 0x00),
7208c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_STEP_SIZE1, 0x7e),
7218c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_STEP_SIZE2, 0x15),
7228c2ecf20Sopenharmony_ci};
7238c2ecf20Sopenharmony_ci
7248c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl sdm845_qmp_pcie_tx_tbl[] = {
7258c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_TX_RES_CODE_LANE_OFFSET_TX, 0x02),
7268c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_TX_RCV_DETECT_LVL_2, 0x12),
7278c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_TX_HIGHZ_DRVR_EN, 0x10),
7288c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_TX_LANE_MODE_1, 0x06),
7298c2ecf20Sopenharmony_ci};
7308c2ecf20Sopenharmony_ci
7318c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl sdm845_qmp_pcie_rx_tbl[] = {
7328c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_CNTRL, 0x03),
7338c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_ENABLES, 0x10),
7348c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_DEGLITCH_CNTRL, 0x14),
7358c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL2, 0x0e),
7368c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL3, 0x04),
7378c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL4, 0x1a),
7388c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x4b),
7398c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SO_GAIN, 0x04),
7408c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SO_GAIN_HALF, 0x04),
7418c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1, 0x71),
7428c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_MODE_00, 0x59),
7438c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_MODE_01, 0x59),
7448c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_OFFSET_ADAPTOR_CNTRL2, 0x80),
7458c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_INTERFACE_MODE, 0x40),
7468c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_PI_CONTROLS, 0x71),
7478c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_FASTLOCK_COUNT_LOW, 0x40),
7488c2ecf20Sopenharmony_ci};
7498c2ecf20Sopenharmony_ci
7508c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl sdm845_qmp_pcie_pcs_tbl[] = {
7518c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_ENDPOINT_REFCLK_DRIVE, 0x04),
7528c2ecf20Sopenharmony_ci
7538c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNTRL2, 0x83),
7548c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNT_VAL_L, 0x09),
7558c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNT_VAL_H_TOL, 0xa2),
7568c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_MAN_CODE, 0x40),
7578c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNTRL1, 0x02),
7588c2ecf20Sopenharmony_ci
7598c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_OSC_DTCT_ACTIONS, 0x00),
7608c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_PWRUP_RESET_DLY_TIME_AUXCLK, 0x01),
7618c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_L1SS_WAKEUP_DLY_TIME_AUXCLK_MSB, 0x00),
7628c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_L1SS_WAKEUP_DLY_TIME_AUXCLK_LSB, 0x20),
7638c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_LP_WAKEUP_DLY_TIME_AUXCLK_MSB, 0x00),
7648c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_LP_WAKEUP_DLY_TIME_AUXCLK, 0x01),
7658c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_PLL_LOCK_CHK_DLY_TIME, 0x73),
7668c2ecf20Sopenharmony_ci
7678c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_RX_SIGDET_LVL, 0xbb),
7688c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_SIGDET_CNTRL, 0x03),
7698c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_REFGEN_REQ_CONFIG1, 0x0d),
7708c2ecf20Sopenharmony_ci
7718c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_POWER_STATE_CONFIG4, 0x00),
7728c2ecf20Sopenharmony_ci};
7738c2ecf20Sopenharmony_ci
7748c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl sdm845_qmp_pcie_pcs_misc_tbl[] = {
7758c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_MISC_OSC_DTCT_CONFIG2, 0x52),
7768c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_MISC_OSC_DTCT_MODE2_CONFIG2, 0x10),
7778c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_MISC_OSC_DTCT_MODE2_CONFIG4, 0x1a),
7788c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_MISC_OSC_DTCT_MODE2_CONFIG5, 0x06),
7798c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_MISC_PCIE_INT_AUX_CLK_CONFIG1, 0x00),
7808c2ecf20Sopenharmony_ci};
7818c2ecf20Sopenharmony_ci
7828c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl sdm845_qhp_pcie_serdes_tbl[] = {
7838c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_SYSCLK_EN_SEL, 0x27),
7848c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_SSC_EN_CENTER, 0x01),
7858c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_SSC_PER1, 0x31),
7868c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_SSC_PER2, 0x01),
7878c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_SSC_STEP_SIZE1, 0xde),
7888c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_SSC_STEP_SIZE2, 0x07),
7898c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_SSC_STEP_SIZE1_MODE1, 0x4c),
7908c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_SSC_STEP_SIZE2_MODE1, 0x06),
7918c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_BIAS_EN_CKBUFLR_EN, 0x18),
7928c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_CLK_ENABLE1, 0xb0),
7938c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_LOCK_CMP1_MODE0, 0x8c),
7948c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_LOCK_CMP2_MODE0, 0x20),
7958c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_LOCK_CMP1_MODE1, 0x14),
7968c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_LOCK_CMP2_MODE1, 0x34),
7978c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_CP_CTRL_MODE0, 0x06),
7988c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_CP_CTRL_MODE1, 0x06),
7998c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_PLL_RCTRL_MODE0, 0x16),
8008c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_PLL_RCTRL_MODE1, 0x16),
8018c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_PLL_CCTRL_MODE0, 0x36),
8028c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_PLL_CCTRL_MODE1, 0x36),
8038c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_RESTRIM_CTRL2, 0x05),
8048c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_LOCK_CMP_EN, 0x42),
8058c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_DEC_START_MODE0, 0x82),
8068c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_DEC_START_MODE1, 0x68),
8078c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_DIV_FRAC_START1_MODE0, 0x55),
8088c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_DIV_FRAC_START2_MODE0, 0x55),
8098c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_DIV_FRAC_START3_MODE0, 0x03),
8108c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_DIV_FRAC_START1_MODE1, 0xab),
8118c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_DIV_FRAC_START2_MODE1, 0xaa),
8128c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_DIV_FRAC_START3_MODE1, 0x02),
8138c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_INTEGLOOP_GAIN0_MODE0, 0x3f),
8148c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_INTEGLOOP_GAIN0_MODE1, 0x3f),
8158c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_VCO_TUNE_MAP, 0x10),
8168c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_CLK_SELECT, 0x04),
8178c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_HSCLK_SEL1, 0x30),
8188c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_CORECLK_DIV, 0x04),
8198c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_CORE_CLK_EN, 0x73),
8208c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_CMN_CONFIG, 0x0c),
8218c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_SVS_MODE_CLK_SEL, 0x15),
8228c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_CORECLK_DIV_MODE1, 0x04),
8238c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_CMN_MODE, 0x01),
8248c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_VREGCLK_DIV1, 0x22),
8258c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_VREGCLK_DIV2, 0x00),
8268c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_BGV_TRIM, 0x20),
8278c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_BG_CTRL, 0x07),
8288c2ecf20Sopenharmony_ci};
8298c2ecf20Sopenharmony_ci
8308c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl sdm845_qhp_pcie_tx_tbl[] = {
8318c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_DRVR_CTRL0, 0x00),
8328c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_DRVR_TAP_EN, 0x0d),
8338c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_TX_BAND_MODE, 0x01),
8348c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_LANE_MODE, 0x1a),
8358c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_PARALLEL_RATE, 0x2f),
8368c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_CML_CTRL_MODE0, 0x09),
8378c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_CML_CTRL_MODE1, 0x09),
8388c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_CML_CTRL_MODE2, 0x1b),
8398c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_PREAMP_CTRL_MODE1, 0x01),
8408c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_PREAMP_CTRL_MODE2, 0x07),
8418c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_MIXER_CTRL_MODE0, 0x31),
8428c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_MIXER_CTRL_MODE1, 0x31),
8438c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_MIXER_CTRL_MODE2, 0x03),
8448c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_CTLE_THRESH_DFE, 0x02),
8458c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_CGA_THRESH_DFE, 0x00),
8468c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RXENGINE_EN0, 0x12),
8478c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_CTLE_TRAIN_TIME, 0x25),
8488c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_CTLE_DFE_OVRLP_TIME, 0x00),
8498c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_DFE_REFRESH_TIME, 0x05),
8508c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_DFE_ENABLE_TIME, 0x01),
8518c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_VGA_GAIN, 0x26),
8528c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_DFE_GAIN, 0x12),
8538c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_EQ_GAIN, 0x04),
8548c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_OFFSET_GAIN, 0x04),
8558c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_PRE_GAIN, 0x09),
8568c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_EQ_INTVAL, 0x15),
8578c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_EDAC_INITVAL, 0x28),
8588c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RXEQ_INITB0, 0x7f),
8598c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RXEQ_INITB1, 0x07),
8608c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RCVRDONE_THRESH1, 0x04),
8618c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RXEQ_CTRL, 0x70),
8628c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_UCDR_FO_GAIN_MODE0, 0x8b),
8638c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_UCDR_FO_GAIN_MODE1, 0x08),
8648c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_UCDR_FO_GAIN_MODE2, 0x0a),
8658c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_UCDR_SO_GAIN_MODE0, 0x03),
8668c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_UCDR_SO_GAIN_MODE1, 0x04),
8678c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_UCDR_SO_GAIN_MODE2, 0x04),
8688c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_UCDR_SO_CONFIG, 0x0c),
8698c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RX_BAND, 0x02),
8708c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RX_RCVR_PATH1_MODE0, 0x5c),
8718c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RX_RCVR_PATH1_MODE1, 0x3e),
8728c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RX_RCVR_PATH1_MODE2, 0x3f),
8738c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_SIGDET_ENABLES, 0x01),
8748c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_SIGDET_CNTRL, 0xa0),
8758c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_SIGDET_DEGLITCH_CNTRL, 0x08),
8768c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_DCC_GAIN, 0x01),
8778c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RX_EN_SIGNAL, 0xc3),
8788c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_PSM_RX_EN_CAL, 0x00),
8798c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RX_MISC_CNTRL0, 0xbc),
8808c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_TS0_TIMER, 0x7f),
8818c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_DLL_HIGHDATARATE, 0x15),
8828c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_DRVR_CTRL1, 0x0c),
8838c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_DRVR_CTRL2, 0x0f),
8848c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RX_RESETCODE_OFFSET, 0x04),
8858c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_VGA_INITVAL, 0x20),
8868c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RSM_START, 0x01),
8878c2ecf20Sopenharmony_ci};
8888c2ecf20Sopenharmony_ci
8898c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl sdm845_qhp_pcie_rx_tbl[] = {
8908c2ecf20Sopenharmony_ci};
8918c2ecf20Sopenharmony_ci
8928c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl sdm845_qhp_pcie_pcs_tbl[] = {
8938c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_PHY_POWER_STATE_CONFIG, 0x3f),
8948c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_PHY_PCS_TX_RX_CONFIG, 0x50),
8958c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_PHY_TXMGN_MAIN_V0_M3P5DB, 0x19),
8968c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_PHY_TXMGN_POST_V0_M3P5DB, 0x07),
8978c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_PHY_TXMGN_MAIN_V0_M6DB, 0x17),
8988c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_PHY_TXMGN_POST_V0_M6DB, 0x09),
8998c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_PHY_POWER_STATE_CONFIG5, 0x9f),
9008c2ecf20Sopenharmony_ci};
9018c2ecf20Sopenharmony_ci
9028c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl qmp_v3_usb3_serdes_tbl[] = {
9038c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_IVCO, 0x07),
9048c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYSCLK_EN_SEL, 0x14),
9058c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_BIAS_EN_CLKBUFLR_EN, 0x08),
9068c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_SELECT, 0x30),
9078c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYS_CLK_CTRL, 0x02),
9088c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_RESETSM_CNTRL2, 0x08),
9098c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CMN_CONFIG, 0x16),
9108c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SVS_MODE_CLK_SEL, 0x01),
9118c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_HSCLK_SEL, 0x80),
9128c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_DEC_START_MODE0, 0x82),
9138c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START1_MODE0, 0xab),
9148c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START2_MODE0, 0xea),
9158c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START3_MODE0, 0x02),
9168c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CP_CTRL_MODE0, 0x06),
9178c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_RCTRL_MODE0, 0x16),
9188c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_CCTRL_MODE0, 0x36),
9198c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN1_MODE0, 0x00),
9208c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN0_MODE0, 0x3f),
9218c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE2_MODE0, 0x01),
9228c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE1_MODE0, 0xc9),
9238c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CORECLK_DIV_MODE0, 0x0a),
9248c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP3_MODE0, 0x00),
9258c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP2_MODE0, 0x34),
9268c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP1_MODE0, 0x15),
9278c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP_EN, 0x04),
9288c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CORE_CLK_EN, 0x00),
9298c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP_CFG, 0x00),
9308c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_MAP, 0x00),
9318c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYSCLK_BUF_ENABLE, 0x0a),
9328c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_EN_CENTER, 0x01),
9338c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_PER1, 0x31),
9348c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_PER2, 0x01),
9358c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_ADJ_PER1, 0x00),
9368c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_ADJ_PER2, 0x00),
9378c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_STEP_SIZE1, 0x85),
9388c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_STEP_SIZE2, 0x07),
9398c2ecf20Sopenharmony_ci};
9408c2ecf20Sopenharmony_ci
9418c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl qmp_v3_usb3_tx_tbl[] = {
9428c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_TX_HIGHZ_DRVR_EN, 0x10),
9438c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_TX_RCV_DETECT_LVL_2, 0x12),
9448c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_TX_LANE_MODE_1, 0x16),
9458c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_TX_RES_CODE_LANE_OFFSET_RX, 0x09),
9468c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_TX_RES_CODE_LANE_OFFSET_TX, 0x06),
9478c2ecf20Sopenharmony_ci};
9488c2ecf20Sopenharmony_ci
9498c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl qmp_v3_dp_serdes_tbl[] = {
9508c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SVS_MODE_CLK_SEL, 0x01),
9518c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYSCLK_EN_SEL, 0x37),
9528c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYS_CLK_CTRL, 0x02),
9538c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_ENABLE1, 0x0e),
9548c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYSCLK_BUF_ENABLE, 0x06),
9558c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_SELECT, 0x30),
9568c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CMN_CONFIG, 0x02),
9578c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START1_MODE0, 0x00),
9588c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN0_MODE0, 0x3f),
9598c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN1_MODE0, 0x00),
9608c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_MAP, 0x00),
9618c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP3_MODE0, 0x00),
9628c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_BG_TIMER, 0x0a),
9638c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CORECLK_DIV_MODE0, 0x0a),
9648c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_CTRL, 0x00),
9658c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_BIAS_EN_CLKBUFLR_EN, 0x3f),
9668c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CORE_CLK_EN, 0x1f),
9678c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_IVCO, 0x07),
9688c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_CCTRL_MODE0, 0x36),
9698c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_RCTRL_MODE0, 0x16),
9708c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CP_CTRL_MODE0, 0x06),
9718c2ecf20Sopenharmony_ci};
9728c2ecf20Sopenharmony_ci
9738c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl qmp_v3_dp_serdes_tbl_rbr[] = {
9748c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_HSCLK_SEL, 0x0c),
9758c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_DEC_START_MODE0, 0x69),
9768c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START2_MODE0, 0x80),
9778c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START3_MODE0, 0x07),
9788c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP1_MODE0, 0x6f),
9798c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP2_MODE0, 0x08),
9808c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP_EN, 0x00),
9818c2ecf20Sopenharmony_ci};
9828c2ecf20Sopenharmony_ci
9838c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl qmp_v3_dp_serdes_tbl_hbr[] = {
9848c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_HSCLK_SEL, 0x04),
9858c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_DEC_START_MODE0, 0x69),
9868c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START2_MODE0, 0x80),
9878c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START3_MODE0, 0x07),
9888c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP1_MODE0, 0x0f),
9898c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP2_MODE0, 0x0e),
9908c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP_EN, 0x00),
9918c2ecf20Sopenharmony_ci};
9928c2ecf20Sopenharmony_ci
9938c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl qmp_v3_dp_serdes_tbl_hbr2[] = {
9948c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_HSCLK_SEL, 0x00),
9958c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_DEC_START_MODE0, 0x8c),
9968c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START2_MODE0, 0x00),
9978c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START3_MODE0, 0x0a),
9988c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP1_MODE0, 0x1f),
9998c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP2_MODE0, 0x1c),
10008c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP_EN, 0x00),
10018c2ecf20Sopenharmony_ci};
10028c2ecf20Sopenharmony_ci
10038c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl qmp_v3_dp_serdes_tbl_hbr3[] = {
10048c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_HSCLK_SEL, 0x03),
10058c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_DEC_START_MODE0, 0x69),
10068c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START2_MODE0, 0x80),
10078c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START3_MODE0, 0x07),
10088c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP1_MODE0, 0x2f),
10098c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP2_MODE0, 0x2a),
10108c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP_EN, 0x08),
10118c2ecf20Sopenharmony_ci};
10128c2ecf20Sopenharmony_ci
10138c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl qmp_v3_dp_tx_tbl[] = {
10148c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_TX_TRANSCEIVER_BIAS_EN, 0x1a),
10158c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_TX_VMODE_CTRL1, 0x40),
10168c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_TX_PRE_STALL_LDO_BOOST_EN, 0x30),
10178c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_TX_INTERFACE_SELECT, 0x3d),
10188c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_TX_CLKBUF_ENABLE, 0x0f),
10198c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_TX_RESET_TSYNC_EN, 0x03),
10208c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_TX_TRAN_DRVR_EMP_EN, 0x03),
10218c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_TX_PARRATE_REC_DETECT_IDLE_EN, 0x00),
10228c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_TX_TX_INTERFACE_MODE, 0x00),
10238c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_TX_TX_BAND, 0x4),
10248c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_TX_TX_POL_INV, 0x0a),
10258c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_TX_TX_DRV_LVL, 0x38),
10268c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_TX_TX_EMP_POST1_LVL, 0x20),
10278c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_TX_RES_CODE_LANE_OFFSET_TX, 0x06),
10288c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_TX_RES_CODE_LANE_OFFSET_RX, 0x07),
10298c2ecf20Sopenharmony_ci};
10308c2ecf20Sopenharmony_ci
10318c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl qmp_v3_usb3_rx_tbl[] = {
10328c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_FASTLOCK_FO_GAIN, 0x0b),
10338c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL2, 0x0f),
10348c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL3, 0x4e),
10358c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL4, 0x18),
10368c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1, 0x77),
10378c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_OFFSET_ADAPTOR_CNTRL2, 0x80),
10388c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_CNTRL, 0x03),
10398c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_DEGLITCH_CNTRL, 0x16),
10408c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x75),
10418c2ecf20Sopenharmony_ci};
10428c2ecf20Sopenharmony_ci
10438c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl qmp_v3_usb3_pcs_tbl[] = {
10448c2ecf20Sopenharmony_ci	/* FLL settings */
10458c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNTRL2, 0x83),
10468c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNT_VAL_L, 0x09),
10478c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNT_VAL_H_TOL, 0xa2),
10488c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_MAN_CODE, 0x40),
10498c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNTRL1, 0x02),
10508c2ecf20Sopenharmony_ci
10518c2ecf20Sopenharmony_ci	/* Lock Det settings */
10528c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_LOCK_DETECT_CONFIG1, 0xd1),
10538c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_LOCK_DETECT_CONFIG2, 0x1f),
10548c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_LOCK_DETECT_CONFIG3, 0x47),
10558c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_POWER_STATE_CONFIG2, 0x1b),
10568c2ecf20Sopenharmony_ci
10578c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_RX_SIGDET_LVL, 0xba),
10588c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_V0, 0x9f),
10598c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_V1, 0x9f),
10608c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_V2, 0xb7),
10618c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_V3, 0x4e),
10628c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_V4, 0x65),
10638c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_LS, 0x6b),
10648c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_V0, 0x15),
10658c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_V0, 0x0d),
10668c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_V1, 0x15),
10678c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_V1, 0x0d),
10688c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_V2, 0x15),
10698c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_V2, 0x0d),
10708c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_V3, 0x15),
10718c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_V3, 0x1d),
10728c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_V4, 0x15),
10738c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_V4, 0x0d),
10748c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_LS, 0x15),
10758c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_LS, 0x0d),
10768c2ecf20Sopenharmony_ci
10778c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_RATE_SLEW_CNTRL, 0x02),
10788c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_PWRUP_RESET_DLY_TIME_AUXCLK, 0x04),
10798c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_TSYNC_RSYNC_TIME, 0x44),
10808c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_PWRUP_RESET_DLY_TIME_AUXCLK, 0x04),
10818c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_RCVR_DTCT_DLY_P1U2_L, 0xe7),
10828c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_RCVR_DTCT_DLY_P1U2_H, 0x03),
10838c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_RCVR_DTCT_DLY_U3_L, 0x40),
10848c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_RCVR_DTCT_DLY_U3_H, 0x00),
10858c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_RXEQTRAINING_WAIT_TIME, 0x75),
10868c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_LFPS_TX_ECSTART_EQTLOCK, 0x86),
10878c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_RXEQTRAINING_RUN_TIME, 0x13),
10888c2ecf20Sopenharmony_ci};
10898c2ecf20Sopenharmony_ci
10908c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl qmp_v3_usb3_uniphy_serdes_tbl[] = {
10918c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_IVCO, 0x07),
10928c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYSCLK_EN_SEL, 0x14),
10938c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_BIAS_EN_CLKBUFLR_EN, 0x04),
10948c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_SELECT, 0x30),
10958c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYS_CLK_CTRL, 0x02),
10968c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_RESETSM_CNTRL2, 0x08),
10978c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CMN_CONFIG, 0x06),
10988c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SVS_MODE_CLK_SEL, 0x01),
10998c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_HSCLK_SEL, 0x80),
11008c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_DEC_START_MODE0, 0x82),
11018c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START1_MODE0, 0xab),
11028c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START2_MODE0, 0xea),
11038c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START3_MODE0, 0x02),
11048c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CP_CTRL_MODE0, 0x06),
11058c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_RCTRL_MODE0, 0x16),
11068c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_CCTRL_MODE0, 0x36),
11078c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN1_MODE0, 0x00),
11088c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN0_MODE0, 0x3f),
11098c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE2_MODE0, 0x01),
11108c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE1_MODE0, 0xc9),
11118c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CORECLK_DIV_MODE0, 0x0a),
11128c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP3_MODE0, 0x00),
11138c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP2_MODE0, 0x34),
11148c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP1_MODE0, 0x15),
11158c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP_EN, 0x04),
11168c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CORE_CLK_EN, 0x00),
11178c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP_CFG, 0x00),
11188c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_MAP, 0x00),
11198c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYSCLK_BUF_ENABLE, 0x0a),
11208c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_EN_CENTER, 0x01),
11218c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_PER1, 0x31),
11228c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_PER2, 0x01),
11238c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_ADJ_PER1, 0x00),
11248c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_ADJ_PER2, 0x00),
11258c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_STEP_SIZE1, 0x85),
11268c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_STEP_SIZE2, 0x07),
11278c2ecf20Sopenharmony_ci};
11288c2ecf20Sopenharmony_ci
11298c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl qmp_v3_usb3_uniphy_tx_tbl[] = {
11308c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_TX_HIGHZ_DRVR_EN, 0x10),
11318c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_TX_RCV_DETECT_LVL_2, 0x12),
11328c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_TX_LANE_MODE_1, 0xc6),
11338c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_TX_RES_CODE_LANE_OFFSET_RX, 0x06),
11348c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_TX_RES_CODE_LANE_OFFSET_TX, 0x06),
11358c2ecf20Sopenharmony_ci};
11368c2ecf20Sopenharmony_ci
11378c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl qmp_v3_usb3_uniphy_rx_tbl[] = {
11388c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_VGA_CAL_CNTRL2, 0x0c),
11398c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_MODE_00, 0x50),
11408c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_FASTLOCK_FO_GAIN, 0x0b),
11418c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL2, 0x0e),
11428c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL3, 0x4e),
11438c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL4, 0x18),
11448c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1, 0x77),
11458c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_OFFSET_ADAPTOR_CNTRL2, 0x80),
11468c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_CNTRL, 0x03),
11478c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_DEGLITCH_CNTRL, 0x1c),
11488c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x75),
11498c2ecf20Sopenharmony_ci};
11508c2ecf20Sopenharmony_ci
11518c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl qmp_v3_usb3_uniphy_pcs_tbl[] = {
11528c2ecf20Sopenharmony_ci	/* FLL settings */
11538c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNTRL2, 0x83),
11548c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNT_VAL_L, 0x09),
11558c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNT_VAL_H_TOL, 0xa2),
11568c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_MAN_CODE, 0x40),
11578c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNTRL1, 0x02),
11588c2ecf20Sopenharmony_ci
11598c2ecf20Sopenharmony_ci	/* Lock Det settings */
11608c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_LOCK_DETECT_CONFIG1, 0xd1),
11618c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_LOCK_DETECT_CONFIG2, 0x1f),
11628c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_LOCK_DETECT_CONFIG3, 0x47),
11638c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_POWER_STATE_CONFIG2, 0x1b),
11648c2ecf20Sopenharmony_ci
11658c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_RX_SIGDET_LVL, 0xba),
11668c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_V0, 0x9f),
11678c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_V1, 0x9f),
11688c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_V2, 0xb5),
11698c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_V3, 0x4c),
11708c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_V4, 0x64),
11718c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_LS, 0x6a),
11728c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_V0, 0x15),
11738c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_V0, 0x0d),
11748c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_V1, 0x15),
11758c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_V1, 0x0d),
11768c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_V2, 0x15),
11778c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_V2, 0x0d),
11788c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_V3, 0x15),
11798c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_V3, 0x1d),
11808c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_V4, 0x15),
11818c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_V4, 0x0d),
11828c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_LS, 0x15),
11838c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_LS, 0x0d),
11848c2ecf20Sopenharmony_ci
11858c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_RATE_SLEW_CNTRL, 0x02),
11868c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_PWRUP_RESET_DLY_TIME_AUXCLK, 0x04),
11878c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_TSYNC_RSYNC_TIME, 0x44),
11888c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_PWRUP_RESET_DLY_TIME_AUXCLK, 0x04),
11898c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_RCVR_DTCT_DLY_P1U2_L, 0xe7),
11908c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_RCVR_DTCT_DLY_P1U2_H, 0x03),
11918c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_RCVR_DTCT_DLY_U3_L, 0x40),
11928c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_RCVR_DTCT_DLY_U3_H, 0x00),
11938c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_RXEQTRAINING_WAIT_TIME, 0x75),
11948c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_LFPS_TX_ECSTART_EQTLOCK, 0x86),
11958c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_RXEQTRAINING_RUN_TIME, 0x13),
11968c2ecf20Sopenharmony_ci
11978c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_REFGEN_REQ_CONFIG1, 0x21),
11988c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_REFGEN_REQ_CONFIG2, 0x60),
11998c2ecf20Sopenharmony_ci};
12008c2ecf20Sopenharmony_ci
12018c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl sdm845_ufsphy_serdes_tbl[] = {
12028c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYS_CLK_CTRL, 0x02),
12038c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_BIAS_EN_CLKBUFLR_EN, 0x04),
12048c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_BG_TIMER, 0x0a),
12058c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_IVCO, 0x07),
12068c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CMN_CONFIG, 0x06),
12078c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYSCLK_EN_SEL, 0xd5),
12088c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_RESETSM_CNTRL, 0x20),
12098c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_SELECT, 0x30),
12108c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_HSCLK_SEL, 0x00),
12118c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP_EN, 0x01),
12128c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_CTRL, 0x00),
12138c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CORE_CLK_EN, 0x00),
12148c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_MAP, 0x04),
12158c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SVS_MODE_CLK_SEL, 0x05),
12168c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_INITVAL1, 0xff),
12178c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_INITVAL2, 0x00),
12188c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_DEC_START_MODE0, 0x82),
12198c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CP_CTRL_MODE0, 0x06),
12208c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_RCTRL_MODE0, 0x16),
12218c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_CCTRL_MODE0, 0x36),
12228c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN0_MODE0, 0x3f),
12238c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN1_MODE0, 0x00),
12248c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE1_MODE0, 0xda),
12258c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE2_MODE0, 0x01),
12268c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP1_MODE0, 0xff),
12278c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP2_MODE0, 0x0c),
12288c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_DEC_START_MODE1, 0x98),
12298c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CP_CTRL_MODE1, 0x06),
12308c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_RCTRL_MODE1, 0x16),
12318c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_CCTRL_MODE1, 0x36),
12328c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN0_MODE1, 0x3f),
12338c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN1_MODE1, 0x00),
12348c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE1_MODE1, 0xc1),
12358c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE2_MODE1, 0x00),
12368c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP1_MODE1, 0x32),
12378c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP2_MODE1, 0x0f),
12388c2ecf20Sopenharmony_ci
12398c2ecf20Sopenharmony_ci	/* Rate B */
12408c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_MAP, 0x44),
12418c2ecf20Sopenharmony_ci};
12428c2ecf20Sopenharmony_ci
12438c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl sdm845_ufsphy_tx_tbl[] = {
12448c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_TX_LANE_MODE_1, 0x06),
12458c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_TX_RES_CODE_LANE_OFFSET_TX, 0x04),
12468c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_TX_RES_CODE_LANE_OFFSET_RX, 0x07),
12478c2ecf20Sopenharmony_ci};
12488c2ecf20Sopenharmony_ci
12498c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl sdm845_ufsphy_rx_tbl[] = {
12508c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_LVL, 0x24),
12518c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_CNTRL, 0x0f),
12528c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_DEGLITCH_CNTRL, 0x1e),
12538c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_INTERFACE_MODE, 0x40),
12548c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_FASTLOCK_FO_GAIN, 0x0b),
12558c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_TERM_BW, 0x5b),
12568c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL2, 0x06),
12578c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL3, 0x04),
12588c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL4, 0x1b),
12598c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SVS_SO_GAIN_HALF, 0x04),
12608c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SVS_SO_GAIN_QUARTER, 0x04),
12618c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SVS_SO_GAIN, 0x04),
12628c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x4b),
12638c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_PI_CONTROLS, 0x81),
12648c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_FASTLOCK_COUNT_LOW, 0x80),
12658c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_MODE_00, 0x59),
12668c2ecf20Sopenharmony_ci};
12678c2ecf20Sopenharmony_ci
12688c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl sdm845_ufsphy_pcs_tbl[] = {
12698c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_RX_SIGDET_CTRL2, 0x6e),
12708c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_TX_LARGE_AMP_DRV_LVL, 0x0a),
12718c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_TX_SMALL_AMP_DRV_LVL, 0x02),
12728c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_RX_SYM_RESYNC_CTRL, 0x03),
12738c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_TX_MID_TERM_CTRL1, 0x43),
12748c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_RX_SIGDET_CTRL1, 0x0f),
12758c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_RX_MIN_HIBERN8_TIME, 0x9a),
12768c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_MULTI_LANE_CTRL1, 0x02),
12778c2ecf20Sopenharmony_ci};
12788c2ecf20Sopenharmony_ci
12798c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl msm8998_usb3_serdes_tbl[] = {
12808c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_SELECT, 0x30),
12818c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_BIAS_EN_CLKBUFLR_EN, 0x04),
12828c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYSCLK_EN_SEL, 0x14),
12838c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYS_CLK_CTRL, 0x06),
12848c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_RESETSM_CNTRL2, 0x08),
12858c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CMN_CONFIG, 0x06),
12868c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SVS_MODE_CLK_SEL, 0x01),
12878c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_HSCLK_SEL, 0x80),
12888c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_DEC_START_MODE0, 0x82),
12898c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START1_MODE0, 0xab),
12908c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START2_MODE0, 0xea),
12918c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START3_MODE0, 0x02),
12928c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CP_CTRL_MODE0, 0x06),
12938c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_RCTRL_MODE0, 0x16),
12948c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_CCTRL_MODE0, 0x36),
12958c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN1_MODE0, 0x00),
12968c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN0_MODE0, 0x3f),
12978c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE2_MODE0, 0x01),
12988c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE1_MODE0, 0xc9),
12998c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CORECLK_DIV_MODE0, 0x0a),
13008c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP3_MODE0, 0x00),
13018c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP2_MODE0, 0x34),
13028c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP1_MODE0, 0x15),
13038c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP_EN, 0x04),
13048c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CORE_CLK_EN, 0x00),
13058c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP_CFG, 0x00),
13068c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_MAP, 0x00),
13078c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_BG_TIMER, 0x0a),
13088c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_IVCO, 0x07),
13098c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_INITVAL, 0x80),
13108c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_CMN_MODE, 0x01),
13118c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_EN_CENTER, 0x01),
13128c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_PER1, 0x31),
13138c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_PER2, 0x01),
13148c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_ADJ_PER1, 0x00),
13158c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_ADJ_PER2, 0x00),
13168c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_STEP_SIZE1, 0x85),
13178c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_STEP_SIZE2, 0x07),
13188c2ecf20Sopenharmony_ci};
13198c2ecf20Sopenharmony_ci
13208c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl msm8998_usb3_tx_tbl[] = {
13218c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_TX_HIGHZ_DRVR_EN, 0x10),
13228c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_TX_RCV_DETECT_LVL_2, 0x12),
13238c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_TX_LANE_MODE_1, 0x16),
13248c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_TX_RES_CODE_LANE_OFFSET_TX, 0x00),
13258c2ecf20Sopenharmony_ci};
13268c2ecf20Sopenharmony_ci
13278c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl msm8998_usb3_rx_tbl[] = {
13288c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_FASTLOCK_FO_GAIN, 0x0b),
13298c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL2, 0x0f),
13308c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL3, 0x4e),
13318c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL4, 0x18),
13328c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1, 0x07),
13338c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_OFFSET_ADAPTOR_CNTRL2, 0x80),
13348c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_CNTRL, 0x43),
13358c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_DEGLITCH_CNTRL, 0x1c),
13368c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x75),
13378c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_FASTLOCK_COUNT_LOW, 0x00),
13388c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_FASTLOCK_COUNT_HIGH, 0x00),
13398c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_PI_CONTROLS, 0x80),
13408c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_FO_GAIN, 0x0a),
13418c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SO_GAIN, 0x06),
13428c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_ENABLES, 0x00),
13438c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_VGA_CAL_CNTRL2, 0x03),
13448c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_MODE_00, 0x05),
13458c2ecf20Sopenharmony_ci};
13468c2ecf20Sopenharmony_ci
13478c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl msm8998_usb3_pcs_tbl[] = {
13488c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNTRL2, 0x83),
13498c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNT_VAL_L, 0x09),
13508c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNT_VAL_H_TOL, 0xa2),
13518c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_MAN_CODE, 0x40),
13528c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNTRL1, 0x02),
13538c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_LOCK_DETECT_CONFIG1, 0xd1),
13548c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_LOCK_DETECT_CONFIG2, 0x1f),
13558c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_LOCK_DETECT_CONFIG3, 0x47),
13568c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_POWER_STATE_CONFIG2, 0x1b),
13578c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_V0, 0x9f),
13588c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_V1, 0x9f),
13598c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_V2, 0xb7),
13608c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_V3, 0x4e),
13618c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_V4, 0x65),
13628c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_LS, 0x6b),
13638c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_V0, 0x15),
13648c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_V0, 0x0d),
13658c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_TX_LARGE_AMP_DRV_LVL, 0x15),
13668c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_V1, 0x0d),
13678c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_V2, 0x15),
13688c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_V2, 0x0d),
13698c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_V3, 0x15),
13708c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_V3, 0x0d),
13718c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_V4, 0x15),
13728c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_V4, 0x0d),
13738c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_LS, 0x15),
13748c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_LS, 0x0d),
13758c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_RATE_SLEW_CNTRL, 0x02),
13768c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_PWRUP_RESET_DLY_TIME_AUXCLK, 0x04),
13778c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_TSYNC_RSYNC_TIME, 0x44),
13788c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_RCVR_DTCT_DLY_P1U2_L, 0xe7),
13798c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_RCVR_DTCT_DLY_P1U2_H, 0x03),
13808c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_RCVR_DTCT_DLY_U3_L, 0x40),
13818c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_RCVR_DTCT_DLY_U3_H, 0x00),
13828c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_RX_SIGDET_LVL, 0x8a),
13838c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_RXEQTRAINING_WAIT_TIME, 0x75),
13848c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_LFPS_TX_ECSTART_EQTLOCK, 0x86),
13858c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V3_PCS_RXEQTRAINING_RUN_TIME, 0x13),
13868c2ecf20Sopenharmony_ci};
13878c2ecf20Sopenharmony_ci
13888c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl sm8150_ufsphy_serdes_tbl[] = {
13898c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_SYSCLK_EN_SEL, 0xd9),
13908c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_HSCLK_SEL, 0x11),
13918c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_HSCLK_HS_SWITCH_SEL, 0x00),
13928c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP_EN, 0x01),
13938c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE_MAP, 0x02),
13948c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_IVCO, 0x0f),
13958c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE_INITVAL2, 0x00),
13968c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_HSCLK_SEL, 0x11),
13978c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_DEC_START_MODE0, 0x82),
13988c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_CP_CTRL_MODE0, 0x06),
13998c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_RCTRL_MODE0, 0x16),
14008c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_CCTRL_MODE0, 0x36),
14018c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP1_MODE0, 0xff),
14028c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP2_MODE0, 0x0c),
14038c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE1_MODE0, 0xac),
14048c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE2_MODE0, 0x1e),
14058c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_DEC_START_MODE1, 0x98),
14068c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_CP_CTRL_MODE1, 0x06),
14078c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_RCTRL_MODE1, 0x16),
14088c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_CCTRL_MODE1, 0x36),
14098c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP1_MODE1, 0x32),
14108c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP2_MODE1, 0x0f),
14118c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE1_MODE1, 0xdd),
14128c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE2_MODE1, 0x23),
14138c2ecf20Sopenharmony_ci
14148c2ecf20Sopenharmony_ci	/* Rate B */
14158c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE_MAP, 0x06),
14168c2ecf20Sopenharmony_ci};
14178c2ecf20Sopenharmony_ci
14188c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl sm8150_ufsphy_tx_tbl[] = {
14198c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_TX_PWM_GEAR_1_DIVIDER_BAND0_1, 0x06),
14208c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_TX_PWM_GEAR_2_DIVIDER_BAND0_1, 0x03),
14218c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_TX_PWM_GEAR_3_DIVIDER_BAND0_1, 0x01),
14228c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_TX_PWM_GEAR_4_DIVIDER_BAND0_1, 0x00),
14238c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_TX_LANE_MODE_1, 0x05),
14248c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_TX_TRAN_DRVR_EMP_EN, 0x0c),
14258c2ecf20Sopenharmony_ci};
14268c2ecf20Sopenharmony_ci
14278c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl sm8150_ufsphy_rx_tbl[] = {
14288c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_LVL, 0x24),
14298c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_CNTRL, 0x0f),
14308c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_DEGLITCH_CNTRL, 0x1e),
14318c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_BAND, 0x18),
14328c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_FASTLOCK_FO_GAIN, 0x0a),
14338c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x4b),
14348c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_PI_CONTROLS, 0xf1),
14358c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_FASTLOCK_COUNT_LOW, 0x80),
14368c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_PI_CTRL2, 0x80),
14378c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_FO_GAIN, 0x0c),
14388c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SO_GAIN, 0x04),
14398c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_TERM_BW, 0x1b),
14408c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL2, 0x06),
14418c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL3, 0x04),
14428c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL4, 0x1d),
14438c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_OFFSET_ADAPTOR_CNTRL2, 0x00),
14448c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_IDAC_MEASURE_TIME, 0x10),
14458c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_IDAC_TSETTLE_LOW, 0xc0),
14468c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_IDAC_TSETTLE_HIGH, 0x00),
14478c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_LOW, 0x36),
14488c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH, 0x36),
14498c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH2, 0xf6),
14508c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH3, 0x3b),
14518c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH4, 0x3d),
14528c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_LOW, 0xe0),
14538c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH, 0xc8),
14548c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH2, 0xc8),
14558c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH3, 0x3b),
14568c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH4, 0xb1),
14578c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_LOW, 0xe0),
14588c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH, 0xc8),
14598c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH2, 0xc8),
14608c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH3, 0x3b),
14618c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH4, 0xb1),
14628c2ecf20Sopenharmony_ci
14638c2ecf20Sopenharmony_ci};
14648c2ecf20Sopenharmony_ci
14658c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl sm8150_ufsphy_pcs_tbl[] = {
14668c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V4_PCS_UFS_RX_SIGDET_CTRL2, 0x6d),
14678c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V4_PCS_UFS_TX_LARGE_AMP_DRV_LVL, 0x0a),
14688c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V4_PCS_UFS_TX_SMALL_AMP_DRV_LVL, 0x02),
14698c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V4_PCS_UFS_TX_MID_TERM_CTRL1, 0x43),
14708c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V4_PCS_UFS_DEBUG_BUS_CLKSEL, 0x1f),
14718c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V4_PCS_UFS_RX_MIN_HIBERN8_TIME, 0xff),
14728c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V4_PCS_UFS_MULTI_LANE_CTRL1, 0x02),
14738c2ecf20Sopenharmony_ci};
14748c2ecf20Sopenharmony_ci
14758c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl sm8150_usb3_serdes_tbl[] = {
14768c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_EN_CENTER, 0x01),
14778c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_PER1, 0x31),
14788c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_PER2, 0x01),
14798c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_STEP_SIZE1_MODE0, 0xde),
14808c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_STEP_SIZE2_MODE0, 0x07),
14818c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_STEP_SIZE1_MODE1, 0xde),
14828c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_STEP_SIZE2_MODE1, 0x07),
14838c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_SYSCLK_BUF_ENABLE, 0x0a),
14848c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_CMN_IPTRIM, 0x20),
14858c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_CP_CTRL_MODE0, 0x06),
14868c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_CP_CTRL_MODE1, 0x06),
14878c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_RCTRL_MODE0, 0x16),
14888c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_RCTRL_MODE1, 0x16),
14898c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_CCTRL_MODE0, 0x36),
14908c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_CCTRL_MODE1, 0x36),
14918c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_SYSCLK_EN_SEL, 0x1a),
14928c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP_EN, 0x04),
14938c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP1_MODE0, 0x14),
14948c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP2_MODE0, 0x34),
14958c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP1_MODE1, 0x34),
14968c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP2_MODE1, 0x82),
14978c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_DEC_START_MODE0, 0x82),
14988c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_DEC_START_MODE1, 0x82),
14998c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START1_MODE0, 0xab),
15008c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START2_MODE0, 0xea),
15018c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START3_MODE0, 0x02),
15028c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE_MAP, 0x02),
15038c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START1_MODE1, 0xab),
15048c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START2_MODE1, 0xea),
15058c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START3_MODE1, 0x02),
15068c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE1_MODE0, 0x24),
15078c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE1_MODE1, 0x24),
15088c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE2_MODE1, 0x02),
15098c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_HSCLK_SEL, 0x01),
15108c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_CORECLK_DIV_MODE1, 0x08),
15118c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE1_MODE0, 0xca),
15128c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE2_MODE0, 0x1e),
15138c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE1_MODE1, 0xca),
15148c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE2_MODE1, 0x1e),
15158c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_HSCLK_SEL, 0x11),
15168c2ecf20Sopenharmony_ci};
15178c2ecf20Sopenharmony_ci
15188c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl sm8150_usb3_tx_tbl[] = {
15198c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_TX_RES_CODE_LANE_TX, 0x00),
15208c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_TX_RES_CODE_LANE_RX, 0x00),
15218c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_TX_LANE_MODE_1, 0xd5),
15228c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_TX_RCV_DETECT_LVL_2, 0x12),
15238c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_TX_PI_QEC_CTRL, 0x20),
15248c2ecf20Sopenharmony_ci};
15258c2ecf20Sopenharmony_ci
15268c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl sm8150_usb3_rx_tbl[] = {
15278c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SO_GAIN, 0x05),
15288c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_FASTLOCK_FO_GAIN, 0x2f),
15298c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x7f),
15308c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_FASTLOCK_COUNT_LOW, 0xff),
15318c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_FASTLOCK_COUNT_HIGH, 0x0f),
15328c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_PI_CONTROLS, 0x99),
15338c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SB2_THRESH1, 0x04),
15348c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SB2_THRESH2, 0x08),
15358c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SB2_GAIN1, 0x05),
15368c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SB2_GAIN2, 0x05),
15378c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_VGA_CAL_CNTRL1, 0x54),
15388c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_VGA_CAL_CNTRL2, 0x0e),
15398c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL2, 0x0f),
15408c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL3, 0x4a),
15418c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL4, 0x0a),
15428c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_IDAC_TSETTLE_LOW, 0xc0),
15438c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_IDAC_TSETTLE_HIGH, 0x00),
15448c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1, 0x77),
15458c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_CNTRL, 0x04),
15468c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_DEGLITCH_CNTRL, 0x0e),
15478c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_LOW, 0xbf),
15488c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH, 0xbf),
15498c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH2, 0x3f),
15508c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH3, 0x7f),
15518c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH4, 0x94),
15528c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_LOW, 0xdc),
15538c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH, 0xdc),
15548c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH2, 0x5c),
15558c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH3, 0x0b),
15568c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH4, 0xb3),
15578c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_DFE_EN_TIMER, 0x04),
15588c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_DFE_CTLE_POST_CAL_OFFSET, 0x38),
15598c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_AUX_DATA_TCOARSE_TFINE, 0xa0),
15608c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_DCC_CTRL1, 0x0c),
15618c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_GM_CAL, 0x1f),
15628c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_VTH_CODE, 0x10),
15638c2ecf20Sopenharmony_ci};
15648c2ecf20Sopenharmony_ci
15658c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl sm8150_usb3_pcs_tbl[] = {
15668c2ecf20Sopenharmony_ci	/* Lock Det settings */
15678c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V4_PCS_LOCK_DETECT_CONFIG1, 0xd0),
15688c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V4_PCS_LOCK_DETECT_CONFIG2, 0x07),
15698c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V4_PCS_LOCK_DETECT_CONFIG6, 0x13),
15708c2ecf20Sopenharmony_ci
15718c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V4_PCS_REFGEN_REQ_CONFIG1, 0x21),
15728c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V4_PCS_RX_SIGDET_LVL, 0xaa),
15738c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V4_PCS_CDR_RESET_TIME, 0x0a),
15748c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V4_PCS_ALIGN_DETECT_CONFIG1, 0x88),
15758c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V4_PCS_ALIGN_DETECT_CONFIG2, 0x13),
15768c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCS_TX_RX_CONFIG, 0x0c),
15778c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V4_PCS_EQ_CONFIG1, 0x4b),
15788c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V4_PCS_EQ_CONFIG5, 0x10),
15798c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V4_PCS_USB3_LFPS_DET_HIGH_COUNT_VAL, 0xf8),
15808c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V4_PCS_USB3_RXEQTRAINING_DFE_TIME_S2, 0x07),
15818c2ecf20Sopenharmony_ci};
15828c2ecf20Sopenharmony_ci
15838c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl sm8150_usb3_uniphy_serdes_tbl[] = {
15848c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_SYSCLK_EN_SEL, 0x1a),
15858c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_HSCLK_SEL, 0x11),
15868c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_HSCLK_SEL, 0x01),
15878c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_DEC_START_MODE0, 0x82),
15888c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START1_MODE0, 0xab),
15898c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START2_MODE0, 0xea),
15908c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START3_MODE0, 0x02),
15918c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE1_MODE0, 0xca),
15928c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE2_MODE0, 0x1e),
15938c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_CP_CTRL_MODE0, 0x06),
15948c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_RCTRL_MODE0, 0x16),
15958c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_CCTRL_MODE0, 0x36),
15968c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE1_MODE0, 0x24),
15978c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP2_MODE0, 0x34),
15988c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP1_MODE0, 0x14),
15998c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP_EN, 0x04),
16008c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_SYSCLK_BUF_ENABLE, 0x0a),
16018c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE2_MODE1, 0x02),
16028c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE1_MODE1, 0x24),
16038c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_CORECLK_DIV_MODE1, 0x08),
16048c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_DEC_START_MODE1, 0x82),
16058c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START1_MODE1, 0xab),
16068c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START2_MODE1, 0xea),
16078c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START3_MODE1, 0x02),
16088c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP2_MODE1, 0x82),
16098c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP1_MODE1, 0x34),
16108c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_CP_CTRL_MODE1, 0x06),
16118c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_RCTRL_MODE1, 0x16),
16128c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_CCTRL_MODE1, 0x36),
16138c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE1_MODE1, 0xca),
16148c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE2_MODE1, 0x1e),
16158c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_CMN_IPTRIM, 0x20),
16168c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_EN_CENTER, 0x01),
16178c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_PER1, 0x31),
16188c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_PER2, 0x01),
16198c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_STEP_SIZE1_MODE1, 0xde),
16208c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_STEP_SIZE2_MODE1, 0x07),
16218c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_STEP_SIZE1_MODE0, 0xde),
16228c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_STEP_SIZE2_MODE0, 0x07),
16238c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE_MAP, 0x02),
16248c2ecf20Sopenharmony_ci};
16258c2ecf20Sopenharmony_ci
16268c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl sm8150_usb3_uniphy_tx_tbl[] = {
16278c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_TX_RCV_DETECT_LVL_2, 0x12),
16288c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_TX_LANE_MODE_1, 0x95),
16298c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_TX_PI_QEC_CTRL, 0x40),
16308c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_TX_RES_CODE_LANE_OFFSET_TX, 0x05),
16318c2ecf20Sopenharmony_ci};
16328c2ecf20Sopenharmony_ci
16338c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl sm8150_usb3_uniphy_rx_tbl[] = {
16348c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH4, 0xb8),
16358c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH3, 0x7f),
16368c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH2, 0x37),
16378c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH, 0x2f),
16388c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_LOW, 0xef),
16398c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH4, 0xb3),
16408c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH3, 0x0b),
16418c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH2, 0x5c),
16428c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH, 0xdc),
16438c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_LOW, 0xdc),
16448c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_PI_CONTROLS, 0x99),
16458c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SB2_THRESH1, 0x04),
16468c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SB2_THRESH2, 0x08),
16478c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SB2_GAIN1, 0x05),
16488c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SB2_GAIN2, 0x05),
16498c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_FASTLOCK_FO_GAIN, 0x2f),
16508c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_FASTLOCK_COUNT_LOW, 0xff),
16518c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_FASTLOCK_COUNT_HIGH, 0x0f),
16528c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x7f),
16538c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_FO_GAIN, 0x08),
16548c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_VGA_CAL_CNTRL1, 0x54),
16558c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_VGA_CAL_CNTRL2, 0x0c),
16568c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_GM_CAL, 0x1f),
16578c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL2, 0x0f),
16588c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL3, 0x4a),
16598c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL4, 0x0a),
16608c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_DFE_EN_TIMER, 0x04),
16618c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1, 0x47),
16628c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_OFFSET_ADAPTOR_CNTRL2, 0x80),
16638c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_CNTRL, 0x04),
16648c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_DEGLITCH_CNTRL, 0x0e),
16658c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_IDAC_TSETTLE_HIGH, 0x00),
16668c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_IDAC_TSETTLE_LOW, 0xc0),
16678c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_DFE_CTLE_POST_CAL_OFFSET, 0x20),
16688c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SO_GAIN, 0x04),
16698c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_DCC_CTRL1, 0x0c),
16708c2ecf20Sopenharmony_ci};
16718c2ecf20Sopenharmony_ci
16728c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl sm8150_usb3_uniphy_pcs_tbl[] = {
16738c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V4_PCS_LOCK_DETECT_CONFIG1, 0xd0),
16748c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V4_PCS_LOCK_DETECT_CONFIG2, 0x07),
16758c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V4_PCS_LOCK_DETECT_CONFIG3, 0x20),
16768c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V4_PCS_LOCK_DETECT_CONFIG6, 0x13),
16778c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V4_PCS_RCVR_DTCT_DLY_P1U2_L, 0xe7),
16788c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V4_PCS_RCVR_DTCT_DLY_P1U2_H, 0x03),
16798c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V4_PCS_RX_SIGDET_LVL, 0xaa),
16808c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V4_PCS_USB3_UNI_RXEQTRAINING_DFE_TIME_S2, 0x07),
16818c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V4_PCS_USB3_UNI_LFPS_DET_HIGH_COUNT_VAL, 0xf8),
16828c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V4_PCS_CDR_RESET_TIME, 0x0f),
16838c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V4_PCS_ALIGN_DETECT_CONFIG1, 0x88),
16848c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V4_PCS_ALIGN_DETECT_CONFIG2, 0x13),
16858c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V4_PCS_EQ_CONFIG1, 0x4b),
16868c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V4_PCS_EQ_CONFIG5, 0x10),
16878c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V4_PCS_REFGEN_REQ_CONFIG1, 0x21),
16888c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCS_TX_RX_CONFIG, 0x0c),
16898c2ecf20Sopenharmony_ci};
16908c2ecf20Sopenharmony_ci
16918c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl sm8250_usb3_tx_tbl[] = {
16928c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_TX_RES_CODE_LANE_TX, 0x60),
16938c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_TX_RES_CODE_LANE_RX, 0x60),
16948c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_TX_RES_CODE_LANE_OFFSET_TX, 0x11),
16958c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_TX_RES_CODE_LANE_OFFSET_RX, 0x02),
16968c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_TX_LANE_MODE_1, 0xd5),
16978c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_TX_RCV_DETECT_LVL_2, 0x12),
16988c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG_LANE(QSERDES_V4_TX_PI_QEC_CTRL, 0x40, 1),
16998c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG_LANE(QSERDES_V4_TX_PI_QEC_CTRL, 0x54, 2),
17008c2ecf20Sopenharmony_ci};
17018c2ecf20Sopenharmony_ci
17028c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl sm8250_usb3_rx_tbl[] = {
17038c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SO_GAIN, 0x06),
17048c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_FASTLOCK_FO_GAIN, 0x2f),
17058c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x7f),
17068c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_FASTLOCK_COUNT_LOW, 0xff),
17078c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_FASTLOCK_COUNT_HIGH, 0x0f),
17088c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_PI_CONTROLS, 0x99),
17098c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SB2_THRESH1, 0x04),
17108c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SB2_THRESH2, 0x08),
17118c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SB2_GAIN1, 0x05),
17128c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SB2_GAIN2, 0x05),
17138c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_VGA_CAL_CNTRL1, 0x54),
17148c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_VGA_CAL_CNTRL2, 0x0c),
17158c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL2, 0x0f),
17168c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL3, 0x4a),
17178c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL4, 0x0a),
17188c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_IDAC_TSETTLE_LOW, 0xc0),
17198c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_IDAC_TSETTLE_HIGH, 0x00),
17208c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1, 0x77),
17218c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_CNTRL, 0x04),
17228c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_DEGLITCH_CNTRL, 0x0e),
17238c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG_LANE(QSERDES_V4_RX_RX_MODE_00_LOW, 0xff, 1),
17248c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG_LANE(QSERDES_V4_RX_RX_MODE_00_LOW, 0x7f, 2),
17258c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG_LANE(QSERDES_V4_RX_RX_MODE_00_HIGH, 0x7f, 1),
17268c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG_LANE(QSERDES_V4_RX_RX_MODE_00_HIGH, 0xff, 2),
17278c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH2, 0x7f),
17288c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH3, 0x7f),
17298c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH4, 0x97),
17308c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_LOW, 0xdc),
17318c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH, 0xdc),
17328c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH2, 0x5c),
17338c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH3, 0x7b),
17348c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH4, 0xb4),
17358c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_DFE_EN_TIMER, 0x04),
17368c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_DFE_CTLE_POST_CAL_OFFSET, 0x38),
17378c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_AUX_DATA_TCOARSE_TFINE, 0xa0),
17388c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_DCC_CTRL1, 0x0c),
17398c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_GM_CAL, 0x1f),
17408c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_VTH_CODE, 0x10),
17418c2ecf20Sopenharmony_ci};
17428c2ecf20Sopenharmony_ci
17438c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl sm8250_usb3_pcs_tbl[] = {
17448c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V4_PCS_LOCK_DETECT_CONFIG1, 0xd0),
17458c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V4_PCS_LOCK_DETECT_CONFIG2, 0x07),
17468c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V4_PCS_LOCK_DETECT_CONFIG3, 0x20),
17478c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V4_PCS_LOCK_DETECT_CONFIG6, 0x13),
17488c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V4_PCS_REFGEN_REQ_CONFIG1, 0x21),
17498c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V4_PCS_RX_SIGDET_LVL, 0xa9),
17508c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V4_PCS_CDR_RESET_TIME, 0x0a),
17518c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V4_PCS_ALIGN_DETECT_CONFIG1, 0x88),
17528c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V4_PCS_ALIGN_DETECT_CONFIG2, 0x13),
17538c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCS_TX_RX_CONFIG, 0x0c),
17548c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V4_PCS_EQ_CONFIG1, 0x4b),
17558c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V4_PCS_EQ_CONFIG5, 0x10),
17568c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V4_PCS_USB3_LFPS_DET_HIGH_COUNT_VAL, 0xf8),
17578c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V4_PCS_USB3_RXEQTRAINING_DFE_TIME_S2, 0x07),
17588c2ecf20Sopenharmony_ci};
17598c2ecf20Sopenharmony_ci
17608c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl sm8250_usb3_uniphy_tx_tbl[] = {
17618c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_TX_RCV_DETECT_LVL_2, 0x12),
17628c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_TX_LANE_MODE_1, 0xd5),
17638c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_TX_LANE_MODE_2, 0x82),
17648c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_TX_PI_QEC_CTRL, 0x40),
17658c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_TX_RES_CODE_LANE_OFFSET_TX, 0x11),
17668c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_TX_RES_CODE_LANE_OFFSET_RX, 0x02),
17678c2ecf20Sopenharmony_ci};
17688c2ecf20Sopenharmony_ci
17698c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl sm8250_usb3_uniphy_rx_tbl[] = {
17708c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH4, 0xb8),
17718c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH3, 0xff),
17728c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH2, 0xbf),
17738c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH, 0x7f),
17748c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_LOW, 0x7f),
17758c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH4, 0xb4),
17768c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH3, 0x7b),
17778c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH2, 0x5c),
17788c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH, 0xdc),
17798c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_LOW, 0xdc),
17808c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_PI_CONTROLS, 0x99),
17818c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SB2_THRESH1, 0x04),
17828c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SB2_THRESH2, 0x08),
17838c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SB2_GAIN1, 0x05),
17848c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SB2_GAIN2, 0x05),
17858c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_FASTLOCK_FO_GAIN, 0x2f),
17868c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_FASTLOCK_COUNT_LOW, 0xff),
17878c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_FASTLOCK_COUNT_HIGH, 0x0f),
17888c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x7f),
17898c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_FO_GAIN, 0x0a),
17908c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_VGA_CAL_CNTRL1, 0x54),
17918c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_VGA_CAL_CNTRL2, 0x0c),
17928c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL2, 0x0f),
17938c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL3, 0x4a),
17948c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL4, 0x0a),
17958c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_DFE_EN_TIMER, 0x04),
17968c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1, 0x47),
17978c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_OFFSET_ADAPTOR_CNTRL2, 0x80),
17988c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_CNTRL, 0x04),
17998c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_DEGLITCH_CNTRL, 0x0e),
18008c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_IDAC_TSETTLE_HIGH, 0x00),
18018c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_IDAC_TSETTLE_LOW, 0xc0),
18028c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_DFE_CTLE_POST_CAL_OFFSET, 0x38),
18038c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SO_GAIN, 0x06),
18048c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_DCC_CTRL1, 0x0c),
18058c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QSERDES_V4_RX_GM_CAL, 0x1f),
18068c2ecf20Sopenharmony_ci};
18078c2ecf20Sopenharmony_ci
18088c2ecf20Sopenharmony_cistatic const struct qmp_phy_init_tbl sm8250_usb3_uniphy_pcs_tbl[] = {
18098c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V4_PCS_LOCK_DETECT_CONFIG1, 0xd0),
18108c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V4_PCS_LOCK_DETECT_CONFIG2, 0x07),
18118c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V4_PCS_LOCK_DETECT_CONFIG3, 0x20),
18128c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V4_PCS_LOCK_DETECT_CONFIG6, 0x13),
18138c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V4_PCS_RCVR_DTCT_DLY_P1U2_L, 0xe7),
18148c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V4_PCS_RCVR_DTCT_DLY_P1U2_H, 0x03),
18158c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V4_PCS_RX_SIGDET_LVL, 0xa9),
18168c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCS_TX_RX_CONFIG, 0x0c),
18178c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V4_PCS_USB3_UNI_RXEQTRAINING_DFE_TIME_S2, 0x07),
18188c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V4_PCS_USB3_UNI_LFPS_DET_HIGH_COUNT_VAL, 0xf8),
18198c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V4_PCS_CDR_RESET_TIME, 0x0a),
18208c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V4_PCS_ALIGN_DETECT_CONFIG1, 0x88),
18218c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V4_PCS_ALIGN_DETECT_CONFIG2, 0x13),
18228c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V4_PCS_EQ_CONFIG1, 0x4b),
18238c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V4_PCS_EQ_CONFIG5, 0x10),
18248c2ecf20Sopenharmony_ci	QMP_PHY_INIT_CFG(QPHY_V4_PCS_REFGEN_REQ_CONFIG1, 0x21),
18258c2ecf20Sopenharmony_ci};
18268c2ecf20Sopenharmony_ci
18278c2ecf20Sopenharmony_ci/* struct qmp_phy_cfg - per-PHY initialization config */
18288c2ecf20Sopenharmony_cistruct qmp_phy_cfg {
18298c2ecf20Sopenharmony_ci	/* phy-type - PCIE/UFS/USB */
18308c2ecf20Sopenharmony_ci	unsigned int type;
18318c2ecf20Sopenharmony_ci	/* number of lanes provided by phy */
18328c2ecf20Sopenharmony_ci	int nlanes;
18338c2ecf20Sopenharmony_ci
18348c2ecf20Sopenharmony_ci	/* Init sequence for PHY blocks - serdes, tx, rx, pcs */
18358c2ecf20Sopenharmony_ci	const struct qmp_phy_init_tbl *serdes_tbl;
18368c2ecf20Sopenharmony_ci	int serdes_tbl_num;
18378c2ecf20Sopenharmony_ci	const struct qmp_phy_init_tbl *tx_tbl;
18388c2ecf20Sopenharmony_ci	int tx_tbl_num;
18398c2ecf20Sopenharmony_ci	const struct qmp_phy_init_tbl *rx_tbl;
18408c2ecf20Sopenharmony_ci	int rx_tbl_num;
18418c2ecf20Sopenharmony_ci	const struct qmp_phy_init_tbl *pcs_tbl;
18428c2ecf20Sopenharmony_ci	int pcs_tbl_num;
18438c2ecf20Sopenharmony_ci	const struct qmp_phy_init_tbl *pcs_misc_tbl;
18448c2ecf20Sopenharmony_ci	int pcs_misc_tbl_num;
18458c2ecf20Sopenharmony_ci
18468c2ecf20Sopenharmony_ci	/* Init sequence for DP PHY block link rates */
18478c2ecf20Sopenharmony_ci	const struct qmp_phy_init_tbl *serdes_tbl_rbr;
18488c2ecf20Sopenharmony_ci	int serdes_tbl_rbr_num;
18498c2ecf20Sopenharmony_ci	const struct qmp_phy_init_tbl *serdes_tbl_hbr;
18508c2ecf20Sopenharmony_ci	int serdes_tbl_hbr_num;
18518c2ecf20Sopenharmony_ci	const struct qmp_phy_init_tbl *serdes_tbl_hbr2;
18528c2ecf20Sopenharmony_ci	int serdes_tbl_hbr2_num;
18538c2ecf20Sopenharmony_ci	const struct qmp_phy_init_tbl *serdes_tbl_hbr3;
18548c2ecf20Sopenharmony_ci	int serdes_tbl_hbr3_num;
18558c2ecf20Sopenharmony_ci
18568c2ecf20Sopenharmony_ci	/* clock ids to be requested */
18578c2ecf20Sopenharmony_ci	const char * const *clk_list;
18588c2ecf20Sopenharmony_ci	int num_clks;
18598c2ecf20Sopenharmony_ci	/* resets to be requested */
18608c2ecf20Sopenharmony_ci	const char * const *reset_list;
18618c2ecf20Sopenharmony_ci	int num_resets;
18628c2ecf20Sopenharmony_ci	/* regulators to be requested */
18638c2ecf20Sopenharmony_ci	const char * const *vreg_list;
18648c2ecf20Sopenharmony_ci	int num_vregs;
18658c2ecf20Sopenharmony_ci
18668c2ecf20Sopenharmony_ci	/* array of registers with different offsets */
18678c2ecf20Sopenharmony_ci	const unsigned int *regs;
18688c2ecf20Sopenharmony_ci
18698c2ecf20Sopenharmony_ci	unsigned int start_ctrl;
18708c2ecf20Sopenharmony_ci	unsigned int pwrdn_ctrl;
18718c2ecf20Sopenharmony_ci	unsigned int mask_com_pcs_ready;
18728c2ecf20Sopenharmony_ci
18738c2ecf20Sopenharmony_ci	/* true, if PHY has a separate PHY_COM control block */
18748c2ecf20Sopenharmony_ci	bool has_phy_com_ctrl;
18758c2ecf20Sopenharmony_ci	/* true, if PHY has a reset for individual lanes */
18768c2ecf20Sopenharmony_ci	bool has_lane_rst;
18778c2ecf20Sopenharmony_ci	/* true, if PHY needs delay after POWER_DOWN */
18788c2ecf20Sopenharmony_ci	bool has_pwrdn_delay;
18798c2ecf20Sopenharmony_ci	/* power_down delay in usec */
18808c2ecf20Sopenharmony_ci	int pwrdn_delay_min;
18818c2ecf20Sopenharmony_ci	int pwrdn_delay_max;
18828c2ecf20Sopenharmony_ci
18838c2ecf20Sopenharmony_ci	/* true, if PHY has a separate DP_COM control block */
18848c2ecf20Sopenharmony_ci	bool has_phy_dp_com_ctrl;
18858c2ecf20Sopenharmony_ci	/* true, if PHY has secondary tx/rx lanes to be configured */
18868c2ecf20Sopenharmony_ci	bool is_dual_lane_phy;
18878c2ecf20Sopenharmony_ci
18888c2ecf20Sopenharmony_ci	/* true, if PCS block has no separate SW_RESET register */
18898c2ecf20Sopenharmony_ci	bool no_pcs_sw_reset;
18908c2ecf20Sopenharmony_ci};
18918c2ecf20Sopenharmony_ci
18928c2ecf20Sopenharmony_cistruct qmp_phy_combo_cfg {
18938c2ecf20Sopenharmony_ci	const struct qmp_phy_cfg *usb_cfg;
18948c2ecf20Sopenharmony_ci	const struct qmp_phy_cfg *dp_cfg;
18958c2ecf20Sopenharmony_ci};
18968c2ecf20Sopenharmony_ci
18978c2ecf20Sopenharmony_ci/**
18988c2ecf20Sopenharmony_ci * struct qmp_phy - per-lane phy descriptor
18998c2ecf20Sopenharmony_ci *
19008c2ecf20Sopenharmony_ci * @phy: generic phy
19018c2ecf20Sopenharmony_ci * @cfg: phy specific configuration
19028c2ecf20Sopenharmony_ci * @serdes: iomapped memory space for phy's serdes (i.e. PLL)
19038c2ecf20Sopenharmony_ci * @tx: iomapped memory space for lane's tx
19048c2ecf20Sopenharmony_ci * @rx: iomapped memory space for lane's rx
19058c2ecf20Sopenharmony_ci * @pcs: iomapped memory space for lane's pcs
19068c2ecf20Sopenharmony_ci * @tx2: iomapped memory space for second lane's tx (in dual lane PHYs)
19078c2ecf20Sopenharmony_ci * @rx2: iomapped memory space for second lane's rx (in dual lane PHYs)
19088c2ecf20Sopenharmony_ci * @pcs_misc: iomapped memory space for lane's pcs_misc
19098c2ecf20Sopenharmony_ci * @pipe_clk: pipe lock
19108c2ecf20Sopenharmony_ci * @index: lane index
19118c2ecf20Sopenharmony_ci * @qmp: QMP phy to which this lane belongs
19128c2ecf20Sopenharmony_ci * @lane_rst: lane's reset controller
19138c2ecf20Sopenharmony_ci * @mode: current PHY mode
19148c2ecf20Sopenharmony_ci */
19158c2ecf20Sopenharmony_cistruct qmp_phy {
19168c2ecf20Sopenharmony_ci	struct phy *phy;
19178c2ecf20Sopenharmony_ci	const struct qmp_phy_cfg *cfg;
19188c2ecf20Sopenharmony_ci	void __iomem *serdes;
19198c2ecf20Sopenharmony_ci	void __iomem *tx;
19208c2ecf20Sopenharmony_ci	void __iomem *rx;
19218c2ecf20Sopenharmony_ci	void __iomem *pcs;
19228c2ecf20Sopenharmony_ci	void __iomem *tx2;
19238c2ecf20Sopenharmony_ci	void __iomem *rx2;
19248c2ecf20Sopenharmony_ci	void __iomem *pcs_misc;
19258c2ecf20Sopenharmony_ci	struct clk *pipe_clk;
19268c2ecf20Sopenharmony_ci	unsigned int index;
19278c2ecf20Sopenharmony_ci	struct qcom_qmp *qmp;
19288c2ecf20Sopenharmony_ci	struct reset_control *lane_rst;
19298c2ecf20Sopenharmony_ci	enum phy_mode mode;
19308c2ecf20Sopenharmony_ci	unsigned int dp_aux_cfg;
19318c2ecf20Sopenharmony_ci	struct phy_configure_opts_dp dp_opts;
19328c2ecf20Sopenharmony_ci	struct qmp_phy_dp_clks *dp_clks;
19338c2ecf20Sopenharmony_ci};
19348c2ecf20Sopenharmony_ci
19358c2ecf20Sopenharmony_cistruct qmp_phy_dp_clks {
19368c2ecf20Sopenharmony_ci	struct qmp_phy *qphy;
19378c2ecf20Sopenharmony_ci	struct clk_hw dp_link_hw;
19388c2ecf20Sopenharmony_ci	struct clk_hw dp_pixel_hw;
19398c2ecf20Sopenharmony_ci};
19408c2ecf20Sopenharmony_ci
19418c2ecf20Sopenharmony_ci/**
19428c2ecf20Sopenharmony_ci * struct qcom_qmp - structure holding QMP phy block attributes
19438c2ecf20Sopenharmony_ci *
19448c2ecf20Sopenharmony_ci * @dev: device
19458c2ecf20Sopenharmony_ci * @dp_com: iomapped memory space for phy's dp_com control block
19468c2ecf20Sopenharmony_ci *
19478c2ecf20Sopenharmony_ci * @clks: array of clocks required by phy
19488c2ecf20Sopenharmony_ci * @resets: array of resets required by phy
19498c2ecf20Sopenharmony_ci * @vregs: regulator supplies bulk data
19508c2ecf20Sopenharmony_ci *
19518c2ecf20Sopenharmony_ci * @phys: array of per-lane phy descriptors
19528c2ecf20Sopenharmony_ci * @phy_mutex: mutex lock for PHY common block initialization
19538c2ecf20Sopenharmony_ci * @init_count: phy common block initialization count
19548c2ecf20Sopenharmony_ci * @ufs_reset: optional UFS PHY reset handle
19558c2ecf20Sopenharmony_ci */
19568c2ecf20Sopenharmony_cistruct qcom_qmp {
19578c2ecf20Sopenharmony_ci	struct device *dev;
19588c2ecf20Sopenharmony_ci	void __iomem *dp_com;
19598c2ecf20Sopenharmony_ci
19608c2ecf20Sopenharmony_ci	struct clk_bulk_data *clks;
19618c2ecf20Sopenharmony_ci	struct reset_control **resets;
19628c2ecf20Sopenharmony_ci	struct regulator_bulk_data *vregs;
19638c2ecf20Sopenharmony_ci
19648c2ecf20Sopenharmony_ci	struct qmp_phy **phys;
19658c2ecf20Sopenharmony_ci
19668c2ecf20Sopenharmony_ci	struct mutex phy_mutex;
19678c2ecf20Sopenharmony_ci	int init_count;
19688c2ecf20Sopenharmony_ci
19698c2ecf20Sopenharmony_ci	struct reset_control *ufs_reset;
19708c2ecf20Sopenharmony_ci};
19718c2ecf20Sopenharmony_ci
19728c2ecf20Sopenharmony_cistatic inline void qphy_setbits(void __iomem *base, u32 offset, u32 val)
19738c2ecf20Sopenharmony_ci{
19748c2ecf20Sopenharmony_ci	u32 reg;
19758c2ecf20Sopenharmony_ci
19768c2ecf20Sopenharmony_ci	reg = readl(base + offset);
19778c2ecf20Sopenharmony_ci	reg |= val;
19788c2ecf20Sopenharmony_ci	writel(reg, base + offset);
19798c2ecf20Sopenharmony_ci
19808c2ecf20Sopenharmony_ci	/* ensure that above write is through */
19818c2ecf20Sopenharmony_ci	readl(base + offset);
19828c2ecf20Sopenharmony_ci}
19838c2ecf20Sopenharmony_ci
19848c2ecf20Sopenharmony_cistatic inline void qphy_clrbits(void __iomem *base, u32 offset, u32 val)
19858c2ecf20Sopenharmony_ci{
19868c2ecf20Sopenharmony_ci	u32 reg;
19878c2ecf20Sopenharmony_ci
19888c2ecf20Sopenharmony_ci	reg = readl(base + offset);
19898c2ecf20Sopenharmony_ci	reg &= ~val;
19908c2ecf20Sopenharmony_ci	writel(reg, base + offset);
19918c2ecf20Sopenharmony_ci
19928c2ecf20Sopenharmony_ci	/* ensure that above write is through */
19938c2ecf20Sopenharmony_ci	readl(base + offset);
19948c2ecf20Sopenharmony_ci}
19958c2ecf20Sopenharmony_ci
19968c2ecf20Sopenharmony_ci/* list of clocks required by phy */
19978c2ecf20Sopenharmony_cistatic const char * const msm8996_phy_clk_l[] = {
19988c2ecf20Sopenharmony_ci	"aux", "cfg_ahb", "ref",
19998c2ecf20Sopenharmony_ci};
20008c2ecf20Sopenharmony_ci
20018c2ecf20Sopenharmony_cistatic const char * const msm8996_ufs_phy_clk_l[] = {
20028c2ecf20Sopenharmony_ci	"ref",
20038c2ecf20Sopenharmony_ci};
20048c2ecf20Sopenharmony_ci
20058c2ecf20Sopenharmony_cistatic const char * const qmp_v3_phy_clk_l[] = {
20068c2ecf20Sopenharmony_ci	"aux", "cfg_ahb", "ref", "com_aux",
20078c2ecf20Sopenharmony_ci};
20088c2ecf20Sopenharmony_ci
20098c2ecf20Sopenharmony_cistatic const char * const sdm845_pciephy_clk_l[] = {
20108c2ecf20Sopenharmony_ci	"aux", "cfg_ahb", "ref", "refgen",
20118c2ecf20Sopenharmony_ci};
20128c2ecf20Sopenharmony_ci
20138c2ecf20Sopenharmony_cistatic const char * const qmp_v4_phy_clk_l[] = {
20148c2ecf20Sopenharmony_ci	"aux", "ref_clk_src", "ref", "com_aux",
20158c2ecf20Sopenharmony_ci};
20168c2ecf20Sopenharmony_ci
20178c2ecf20Sopenharmony_ci/* the primary usb3 phy on sm8250 doesn't have a ref clock */
20188c2ecf20Sopenharmony_cistatic const char * const qmp_v4_sm8250_usbphy_clk_l[] = {
20198c2ecf20Sopenharmony_ci	"aux", "ref_clk_src", "com_aux"
20208c2ecf20Sopenharmony_ci};
20218c2ecf20Sopenharmony_ci
20228c2ecf20Sopenharmony_cistatic const char * const sdm845_ufs_phy_clk_l[] = {
20238c2ecf20Sopenharmony_ci	"ref", "ref_aux",
20248c2ecf20Sopenharmony_ci};
20258c2ecf20Sopenharmony_ci
20268c2ecf20Sopenharmony_ci/* list of resets */
20278c2ecf20Sopenharmony_cistatic const char * const msm8996_pciephy_reset_l[] = {
20288c2ecf20Sopenharmony_ci	"phy", "common", "cfg",
20298c2ecf20Sopenharmony_ci};
20308c2ecf20Sopenharmony_ci
20318c2ecf20Sopenharmony_cistatic const char * const msm8996_usb3phy_reset_l[] = {
20328c2ecf20Sopenharmony_ci	"phy", "common",
20338c2ecf20Sopenharmony_ci};
20348c2ecf20Sopenharmony_ci
20358c2ecf20Sopenharmony_cistatic const char * const sc7180_usb3phy_reset_l[] = {
20368c2ecf20Sopenharmony_ci	"phy",
20378c2ecf20Sopenharmony_ci};
20388c2ecf20Sopenharmony_ci
20398c2ecf20Sopenharmony_cistatic const char * const sdm845_pciephy_reset_l[] = {
20408c2ecf20Sopenharmony_ci	"phy",
20418c2ecf20Sopenharmony_ci};
20428c2ecf20Sopenharmony_ci
20438c2ecf20Sopenharmony_ci/* list of regulators */
20448c2ecf20Sopenharmony_cistatic const char * const qmp_phy_vreg_l[] = {
20458c2ecf20Sopenharmony_ci	"vdda-phy", "vdda-pll",
20468c2ecf20Sopenharmony_ci};
20478c2ecf20Sopenharmony_ci
20488c2ecf20Sopenharmony_cistatic const struct qmp_phy_cfg ipq8074_usb3phy_cfg = {
20498c2ecf20Sopenharmony_ci	.type			= PHY_TYPE_USB3,
20508c2ecf20Sopenharmony_ci	.nlanes			= 1,
20518c2ecf20Sopenharmony_ci
20528c2ecf20Sopenharmony_ci	.serdes_tbl		= ipq8074_usb3_serdes_tbl,
20538c2ecf20Sopenharmony_ci	.serdes_tbl_num		= ARRAY_SIZE(ipq8074_usb3_serdes_tbl),
20548c2ecf20Sopenharmony_ci	.tx_tbl			= msm8996_usb3_tx_tbl,
20558c2ecf20Sopenharmony_ci	.tx_tbl_num		= ARRAY_SIZE(msm8996_usb3_tx_tbl),
20568c2ecf20Sopenharmony_ci	.rx_tbl			= ipq8074_usb3_rx_tbl,
20578c2ecf20Sopenharmony_ci	.rx_tbl_num		= ARRAY_SIZE(ipq8074_usb3_rx_tbl),
20588c2ecf20Sopenharmony_ci	.pcs_tbl		= ipq8074_usb3_pcs_tbl,
20598c2ecf20Sopenharmony_ci	.pcs_tbl_num		= ARRAY_SIZE(ipq8074_usb3_pcs_tbl),
20608c2ecf20Sopenharmony_ci	.clk_list		= msm8996_phy_clk_l,
20618c2ecf20Sopenharmony_ci	.num_clks		= ARRAY_SIZE(msm8996_phy_clk_l),
20628c2ecf20Sopenharmony_ci	.reset_list		= msm8996_usb3phy_reset_l,
20638c2ecf20Sopenharmony_ci	.num_resets		= ARRAY_SIZE(msm8996_usb3phy_reset_l),
20648c2ecf20Sopenharmony_ci	.vreg_list		= qmp_phy_vreg_l,
20658c2ecf20Sopenharmony_ci	.num_vregs		= ARRAY_SIZE(qmp_phy_vreg_l),
20668c2ecf20Sopenharmony_ci	.regs			= usb3phy_regs_layout,
20678c2ecf20Sopenharmony_ci
20688c2ecf20Sopenharmony_ci	.start_ctrl		= SERDES_START | PCS_START,
20698c2ecf20Sopenharmony_ci	.pwrdn_ctrl		= SW_PWRDN,
20708c2ecf20Sopenharmony_ci};
20718c2ecf20Sopenharmony_ci
20728c2ecf20Sopenharmony_cistatic const struct qmp_phy_cfg msm8996_pciephy_cfg = {
20738c2ecf20Sopenharmony_ci	.type			= PHY_TYPE_PCIE,
20748c2ecf20Sopenharmony_ci	.nlanes			= 3,
20758c2ecf20Sopenharmony_ci
20768c2ecf20Sopenharmony_ci	.serdes_tbl		= msm8996_pcie_serdes_tbl,
20778c2ecf20Sopenharmony_ci	.serdes_tbl_num		= ARRAY_SIZE(msm8996_pcie_serdes_tbl),
20788c2ecf20Sopenharmony_ci	.tx_tbl			= msm8996_pcie_tx_tbl,
20798c2ecf20Sopenharmony_ci	.tx_tbl_num		= ARRAY_SIZE(msm8996_pcie_tx_tbl),
20808c2ecf20Sopenharmony_ci	.rx_tbl			= msm8996_pcie_rx_tbl,
20818c2ecf20Sopenharmony_ci	.rx_tbl_num		= ARRAY_SIZE(msm8996_pcie_rx_tbl),
20828c2ecf20Sopenharmony_ci	.pcs_tbl		= msm8996_pcie_pcs_tbl,
20838c2ecf20Sopenharmony_ci	.pcs_tbl_num		= ARRAY_SIZE(msm8996_pcie_pcs_tbl),
20848c2ecf20Sopenharmony_ci	.clk_list		= msm8996_phy_clk_l,
20858c2ecf20Sopenharmony_ci	.num_clks		= ARRAY_SIZE(msm8996_phy_clk_l),
20868c2ecf20Sopenharmony_ci	.reset_list		= msm8996_pciephy_reset_l,
20878c2ecf20Sopenharmony_ci	.num_resets		= ARRAY_SIZE(msm8996_pciephy_reset_l),
20888c2ecf20Sopenharmony_ci	.vreg_list		= qmp_phy_vreg_l,
20898c2ecf20Sopenharmony_ci	.num_vregs		= ARRAY_SIZE(qmp_phy_vreg_l),
20908c2ecf20Sopenharmony_ci	.regs			= pciephy_regs_layout,
20918c2ecf20Sopenharmony_ci
20928c2ecf20Sopenharmony_ci	.start_ctrl		= PCS_START | PLL_READY_GATE_EN,
20938c2ecf20Sopenharmony_ci	.pwrdn_ctrl		= SW_PWRDN | REFCLK_DRV_DSBL,
20948c2ecf20Sopenharmony_ci	.mask_com_pcs_ready	= PCS_READY,
20958c2ecf20Sopenharmony_ci
20968c2ecf20Sopenharmony_ci	.has_phy_com_ctrl	= true,
20978c2ecf20Sopenharmony_ci	.has_lane_rst		= true,
20988c2ecf20Sopenharmony_ci	.has_pwrdn_delay	= true,
20998c2ecf20Sopenharmony_ci	.pwrdn_delay_min	= POWER_DOWN_DELAY_US_MIN,
21008c2ecf20Sopenharmony_ci	.pwrdn_delay_max	= POWER_DOWN_DELAY_US_MAX,
21018c2ecf20Sopenharmony_ci};
21028c2ecf20Sopenharmony_ci
21038c2ecf20Sopenharmony_cistatic const struct qmp_phy_cfg msm8996_ufs_cfg = {
21048c2ecf20Sopenharmony_ci	.type			= PHY_TYPE_UFS,
21058c2ecf20Sopenharmony_ci	.nlanes			= 1,
21068c2ecf20Sopenharmony_ci
21078c2ecf20Sopenharmony_ci	.serdes_tbl		= msm8996_ufs_serdes_tbl,
21088c2ecf20Sopenharmony_ci	.serdes_tbl_num		= ARRAY_SIZE(msm8996_ufs_serdes_tbl),
21098c2ecf20Sopenharmony_ci	.tx_tbl			= msm8996_ufs_tx_tbl,
21108c2ecf20Sopenharmony_ci	.tx_tbl_num		= ARRAY_SIZE(msm8996_ufs_tx_tbl),
21118c2ecf20Sopenharmony_ci	.rx_tbl			= msm8996_ufs_rx_tbl,
21128c2ecf20Sopenharmony_ci	.rx_tbl_num		= ARRAY_SIZE(msm8996_ufs_rx_tbl),
21138c2ecf20Sopenharmony_ci
21148c2ecf20Sopenharmony_ci	.clk_list		= msm8996_ufs_phy_clk_l,
21158c2ecf20Sopenharmony_ci	.num_clks		= ARRAY_SIZE(msm8996_ufs_phy_clk_l),
21168c2ecf20Sopenharmony_ci
21178c2ecf20Sopenharmony_ci	.vreg_list		= qmp_phy_vreg_l,
21188c2ecf20Sopenharmony_ci	.num_vregs		= ARRAY_SIZE(qmp_phy_vreg_l),
21198c2ecf20Sopenharmony_ci
21208c2ecf20Sopenharmony_ci	.regs			= msm8996_ufsphy_regs_layout,
21218c2ecf20Sopenharmony_ci
21228c2ecf20Sopenharmony_ci	.start_ctrl		= SERDES_START,
21238c2ecf20Sopenharmony_ci	.pwrdn_ctrl		= SW_PWRDN,
21248c2ecf20Sopenharmony_ci
21258c2ecf20Sopenharmony_ci	.no_pcs_sw_reset	= true,
21268c2ecf20Sopenharmony_ci};
21278c2ecf20Sopenharmony_ci
21288c2ecf20Sopenharmony_cistatic const struct qmp_phy_cfg msm8996_usb3phy_cfg = {
21298c2ecf20Sopenharmony_ci	.type			= PHY_TYPE_USB3,
21308c2ecf20Sopenharmony_ci	.nlanes			= 1,
21318c2ecf20Sopenharmony_ci
21328c2ecf20Sopenharmony_ci	.serdes_tbl		= msm8996_usb3_serdes_tbl,
21338c2ecf20Sopenharmony_ci	.serdes_tbl_num		= ARRAY_SIZE(msm8996_usb3_serdes_tbl),
21348c2ecf20Sopenharmony_ci	.tx_tbl			= msm8996_usb3_tx_tbl,
21358c2ecf20Sopenharmony_ci	.tx_tbl_num		= ARRAY_SIZE(msm8996_usb3_tx_tbl),
21368c2ecf20Sopenharmony_ci	.rx_tbl			= msm8996_usb3_rx_tbl,
21378c2ecf20Sopenharmony_ci	.rx_tbl_num		= ARRAY_SIZE(msm8996_usb3_rx_tbl),
21388c2ecf20Sopenharmony_ci	.pcs_tbl		= msm8996_usb3_pcs_tbl,
21398c2ecf20Sopenharmony_ci	.pcs_tbl_num		= ARRAY_SIZE(msm8996_usb3_pcs_tbl),
21408c2ecf20Sopenharmony_ci	.clk_list		= msm8996_phy_clk_l,
21418c2ecf20Sopenharmony_ci	.num_clks		= ARRAY_SIZE(msm8996_phy_clk_l),
21428c2ecf20Sopenharmony_ci	.reset_list		= msm8996_usb3phy_reset_l,
21438c2ecf20Sopenharmony_ci	.num_resets		= ARRAY_SIZE(msm8996_usb3phy_reset_l),
21448c2ecf20Sopenharmony_ci	.vreg_list		= qmp_phy_vreg_l,
21458c2ecf20Sopenharmony_ci	.num_vregs		= ARRAY_SIZE(qmp_phy_vreg_l),
21468c2ecf20Sopenharmony_ci	.regs			= usb3phy_regs_layout,
21478c2ecf20Sopenharmony_ci
21488c2ecf20Sopenharmony_ci	.start_ctrl		= SERDES_START | PCS_START,
21498c2ecf20Sopenharmony_ci	.pwrdn_ctrl		= SW_PWRDN,
21508c2ecf20Sopenharmony_ci};
21518c2ecf20Sopenharmony_ci
21528c2ecf20Sopenharmony_cistatic const char * const ipq8074_pciephy_clk_l[] = {
21538c2ecf20Sopenharmony_ci	"aux", "cfg_ahb",
21548c2ecf20Sopenharmony_ci};
21558c2ecf20Sopenharmony_ci/* list of resets */
21568c2ecf20Sopenharmony_cistatic const char * const ipq8074_pciephy_reset_l[] = {
21578c2ecf20Sopenharmony_ci	"phy", "common",
21588c2ecf20Sopenharmony_ci};
21598c2ecf20Sopenharmony_ci
21608c2ecf20Sopenharmony_cistatic const struct qmp_phy_cfg ipq8074_pciephy_cfg = {
21618c2ecf20Sopenharmony_ci	.type			= PHY_TYPE_PCIE,
21628c2ecf20Sopenharmony_ci	.nlanes			= 1,
21638c2ecf20Sopenharmony_ci
21648c2ecf20Sopenharmony_ci	.serdes_tbl		= ipq8074_pcie_serdes_tbl,
21658c2ecf20Sopenharmony_ci	.serdes_tbl_num		= ARRAY_SIZE(ipq8074_pcie_serdes_tbl),
21668c2ecf20Sopenharmony_ci	.tx_tbl			= ipq8074_pcie_tx_tbl,
21678c2ecf20Sopenharmony_ci	.tx_tbl_num		= ARRAY_SIZE(ipq8074_pcie_tx_tbl),
21688c2ecf20Sopenharmony_ci	.rx_tbl			= ipq8074_pcie_rx_tbl,
21698c2ecf20Sopenharmony_ci	.rx_tbl_num		= ARRAY_SIZE(ipq8074_pcie_rx_tbl),
21708c2ecf20Sopenharmony_ci	.pcs_tbl		= ipq8074_pcie_pcs_tbl,
21718c2ecf20Sopenharmony_ci	.pcs_tbl_num		= ARRAY_SIZE(ipq8074_pcie_pcs_tbl),
21728c2ecf20Sopenharmony_ci	.clk_list		= ipq8074_pciephy_clk_l,
21738c2ecf20Sopenharmony_ci	.num_clks		= ARRAY_SIZE(ipq8074_pciephy_clk_l),
21748c2ecf20Sopenharmony_ci	.reset_list		= ipq8074_pciephy_reset_l,
21758c2ecf20Sopenharmony_ci	.num_resets		= ARRAY_SIZE(ipq8074_pciephy_reset_l),
21768c2ecf20Sopenharmony_ci	.vreg_list		= NULL,
21778c2ecf20Sopenharmony_ci	.num_vregs		= 0,
21788c2ecf20Sopenharmony_ci	.regs			= pciephy_regs_layout,
21798c2ecf20Sopenharmony_ci
21808c2ecf20Sopenharmony_ci	.start_ctrl		= SERDES_START | PCS_START,
21818c2ecf20Sopenharmony_ci	.pwrdn_ctrl		= SW_PWRDN | REFCLK_DRV_DSBL,
21828c2ecf20Sopenharmony_ci
21838c2ecf20Sopenharmony_ci	.has_phy_com_ctrl	= false,
21848c2ecf20Sopenharmony_ci	.has_lane_rst		= false,
21858c2ecf20Sopenharmony_ci	.has_pwrdn_delay	= true,
21868c2ecf20Sopenharmony_ci	.pwrdn_delay_min	= 995,		/* us */
21878c2ecf20Sopenharmony_ci	.pwrdn_delay_max	= 1005,		/* us */
21888c2ecf20Sopenharmony_ci};
21898c2ecf20Sopenharmony_ci
21908c2ecf20Sopenharmony_cistatic const struct qmp_phy_cfg sdm845_qmp_pciephy_cfg = {
21918c2ecf20Sopenharmony_ci	.type = PHY_TYPE_PCIE,
21928c2ecf20Sopenharmony_ci	.nlanes = 1,
21938c2ecf20Sopenharmony_ci
21948c2ecf20Sopenharmony_ci	.serdes_tbl		= sdm845_qmp_pcie_serdes_tbl,
21958c2ecf20Sopenharmony_ci	.serdes_tbl_num		= ARRAY_SIZE(sdm845_qmp_pcie_serdes_tbl),
21968c2ecf20Sopenharmony_ci	.tx_tbl			= sdm845_qmp_pcie_tx_tbl,
21978c2ecf20Sopenharmony_ci	.tx_tbl_num		= ARRAY_SIZE(sdm845_qmp_pcie_tx_tbl),
21988c2ecf20Sopenharmony_ci	.rx_tbl			= sdm845_qmp_pcie_rx_tbl,
21998c2ecf20Sopenharmony_ci	.rx_tbl_num		= ARRAY_SIZE(sdm845_qmp_pcie_rx_tbl),
22008c2ecf20Sopenharmony_ci	.pcs_tbl		= sdm845_qmp_pcie_pcs_tbl,
22018c2ecf20Sopenharmony_ci	.pcs_tbl_num		= ARRAY_SIZE(sdm845_qmp_pcie_pcs_tbl),
22028c2ecf20Sopenharmony_ci	.pcs_misc_tbl		= sdm845_qmp_pcie_pcs_misc_tbl,
22038c2ecf20Sopenharmony_ci	.pcs_misc_tbl_num	= ARRAY_SIZE(sdm845_qmp_pcie_pcs_misc_tbl),
22048c2ecf20Sopenharmony_ci	.clk_list		= sdm845_pciephy_clk_l,
22058c2ecf20Sopenharmony_ci	.num_clks		= ARRAY_SIZE(sdm845_pciephy_clk_l),
22068c2ecf20Sopenharmony_ci	.reset_list		= sdm845_pciephy_reset_l,
22078c2ecf20Sopenharmony_ci	.num_resets		= ARRAY_SIZE(sdm845_pciephy_reset_l),
22088c2ecf20Sopenharmony_ci	.vreg_list		= qmp_phy_vreg_l,
22098c2ecf20Sopenharmony_ci	.num_vregs		= ARRAY_SIZE(qmp_phy_vreg_l),
22108c2ecf20Sopenharmony_ci	.regs			= sdm845_qmp_pciephy_regs_layout,
22118c2ecf20Sopenharmony_ci
22128c2ecf20Sopenharmony_ci	.start_ctrl		= PCS_START | SERDES_START,
22138c2ecf20Sopenharmony_ci	.pwrdn_ctrl		= SW_PWRDN | REFCLK_DRV_DSBL,
22148c2ecf20Sopenharmony_ci
22158c2ecf20Sopenharmony_ci	.has_pwrdn_delay	= true,
22168c2ecf20Sopenharmony_ci	.pwrdn_delay_min	= 995,		/* us */
22178c2ecf20Sopenharmony_ci	.pwrdn_delay_max	= 1005,		/* us */
22188c2ecf20Sopenharmony_ci};
22198c2ecf20Sopenharmony_ci
22208c2ecf20Sopenharmony_cistatic const struct qmp_phy_cfg sdm845_qhp_pciephy_cfg = {
22218c2ecf20Sopenharmony_ci	.type = PHY_TYPE_PCIE,
22228c2ecf20Sopenharmony_ci	.nlanes = 1,
22238c2ecf20Sopenharmony_ci
22248c2ecf20Sopenharmony_ci	.serdes_tbl		= sdm845_qhp_pcie_serdes_tbl,
22258c2ecf20Sopenharmony_ci	.serdes_tbl_num		= ARRAY_SIZE(sdm845_qhp_pcie_serdes_tbl),
22268c2ecf20Sopenharmony_ci	.tx_tbl			= sdm845_qhp_pcie_tx_tbl,
22278c2ecf20Sopenharmony_ci	.tx_tbl_num		= ARRAY_SIZE(sdm845_qhp_pcie_tx_tbl),
22288c2ecf20Sopenharmony_ci	.rx_tbl			= sdm845_qhp_pcie_rx_tbl,
22298c2ecf20Sopenharmony_ci	.rx_tbl_num		= ARRAY_SIZE(sdm845_qhp_pcie_rx_tbl),
22308c2ecf20Sopenharmony_ci	.pcs_tbl		= sdm845_qhp_pcie_pcs_tbl,
22318c2ecf20Sopenharmony_ci	.pcs_tbl_num		= ARRAY_SIZE(sdm845_qhp_pcie_pcs_tbl),
22328c2ecf20Sopenharmony_ci	.clk_list		= sdm845_pciephy_clk_l,
22338c2ecf20Sopenharmony_ci	.num_clks		= ARRAY_SIZE(sdm845_pciephy_clk_l),
22348c2ecf20Sopenharmony_ci	.reset_list		= sdm845_pciephy_reset_l,
22358c2ecf20Sopenharmony_ci	.num_resets		= ARRAY_SIZE(sdm845_pciephy_reset_l),
22368c2ecf20Sopenharmony_ci	.vreg_list		= qmp_phy_vreg_l,
22378c2ecf20Sopenharmony_ci	.num_vregs		= ARRAY_SIZE(qmp_phy_vreg_l),
22388c2ecf20Sopenharmony_ci	.regs			= sdm845_qhp_pciephy_regs_layout,
22398c2ecf20Sopenharmony_ci
22408c2ecf20Sopenharmony_ci	.start_ctrl		= PCS_START | SERDES_START,
22418c2ecf20Sopenharmony_ci	.pwrdn_ctrl		= SW_PWRDN | REFCLK_DRV_DSBL,
22428c2ecf20Sopenharmony_ci
22438c2ecf20Sopenharmony_ci	.has_pwrdn_delay	= true,
22448c2ecf20Sopenharmony_ci	.pwrdn_delay_min	= 995,		/* us */
22458c2ecf20Sopenharmony_ci	.pwrdn_delay_max	= 1005,		/* us */
22468c2ecf20Sopenharmony_ci};
22478c2ecf20Sopenharmony_ci
22488c2ecf20Sopenharmony_cistatic const struct qmp_phy_cfg qmp_v3_usb3phy_cfg = {
22498c2ecf20Sopenharmony_ci	.type			= PHY_TYPE_USB3,
22508c2ecf20Sopenharmony_ci	.nlanes			= 1,
22518c2ecf20Sopenharmony_ci
22528c2ecf20Sopenharmony_ci	.serdes_tbl		= qmp_v3_usb3_serdes_tbl,
22538c2ecf20Sopenharmony_ci	.serdes_tbl_num		= ARRAY_SIZE(qmp_v3_usb3_serdes_tbl),
22548c2ecf20Sopenharmony_ci	.tx_tbl			= qmp_v3_usb3_tx_tbl,
22558c2ecf20Sopenharmony_ci	.tx_tbl_num		= ARRAY_SIZE(qmp_v3_usb3_tx_tbl),
22568c2ecf20Sopenharmony_ci	.rx_tbl			= qmp_v3_usb3_rx_tbl,
22578c2ecf20Sopenharmony_ci	.rx_tbl_num		= ARRAY_SIZE(qmp_v3_usb3_rx_tbl),
22588c2ecf20Sopenharmony_ci	.pcs_tbl		= qmp_v3_usb3_pcs_tbl,
22598c2ecf20Sopenharmony_ci	.pcs_tbl_num		= ARRAY_SIZE(qmp_v3_usb3_pcs_tbl),
22608c2ecf20Sopenharmony_ci	.clk_list		= qmp_v3_phy_clk_l,
22618c2ecf20Sopenharmony_ci	.num_clks		= ARRAY_SIZE(qmp_v3_phy_clk_l),
22628c2ecf20Sopenharmony_ci	.reset_list		= msm8996_usb3phy_reset_l,
22638c2ecf20Sopenharmony_ci	.num_resets		= ARRAY_SIZE(msm8996_usb3phy_reset_l),
22648c2ecf20Sopenharmony_ci	.vreg_list		= qmp_phy_vreg_l,
22658c2ecf20Sopenharmony_ci	.num_vregs		= ARRAY_SIZE(qmp_phy_vreg_l),
22668c2ecf20Sopenharmony_ci	.regs			= qmp_v3_usb3phy_regs_layout,
22678c2ecf20Sopenharmony_ci
22688c2ecf20Sopenharmony_ci	.start_ctrl		= SERDES_START | PCS_START,
22698c2ecf20Sopenharmony_ci	.pwrdn_ctrl		= SW_PWRDN,
22708c2ecf20Sopenharmony_ci
22718c2ecf20Sopenharmony_ci	.has_pwrdn_delay	= true,
22728c2ecf20Sopenharmony_ci	.pwrdn_delay_min	= POWER_DOWN_DELAY_US_MIN,
22738c2ecf20Sopenharmony_ci	.pwrdn_delay_max	= POWER_DOWN_DELAY_US_MAX,
22748c2ecf20Sopenharmony_ci
22758c2ecf20Sopenharmony_ci	.has_phy_dp_com_ctrl	= true,
22768c2ecf20Sopenharmony_ci	.is_dual_lane_phy	= true,
22778c2ecf20Sopenharmony_ci};
22788c2ecf20Sopenharmony_ci
22798c2ecf20Sopenharmony_cistatic const struct qmp_phy_cfg sc7180_usb3phy_cfg = {
22808c2ecf20Sopenharmony_ci	.type			= PHY_TYPE_USB3,
22818c2ecf20Sopenharmony_ci	.nlanes			= 1,
22828c2ecf20Sopenharmony_ci
22838c2ecf20Sopenharmony_ci	.serdes_tbl		= qmp_v3_usb3_serdes_tbl,
22848c2ecf20Sopenharmony_ci	.serdes_tbl_num		= ARRAY_SIZE(qmp_v3_usb3_serdes_tbl),
22858c2ecf20Sopenharmony_ci	.tx_tbl			= qmp_v3_usb3_tx_tbl,
22868c2ecf20Sopenharmony_ci	.tx_tbl_num		= ARRAY_SIZE(qmp_v3_usb3_tx_tbl),
22878c2ecf20Sopenharmony_ci	.rx_tbl			= qmp_v3_usb3_rx_tbl,
22888c2ecf20Sopenharmony_ci	.rx_tbl_num		= ARRAY_SIZE(qmp_v3_usb3_rx_tbl),
22898c2ecf20Sopenharmony_ci	.pcs_tbl		= qmp_v3_usb3_pcs_tbl,
22908c2ecf20Sopenharmony_ci	.pcs_tbl_num		= ARRAY_SIZE(qmp_v3_usb3_pcs_tbl),
22918c2ecf20Sopenharmony_ci	.clk_list		= qmp_v3_phy_clk_l,
22928c2ecf20Sopenharmony_ci	.num_clks		= ARRAY_SIZE(qmp_v3_phy_clk_l),
22938c2ecf20Sopenharmony_ci	.reset_list		= sc7180_usb3phy_reset_l,
22948c2ecf20Sopenharmony_ci	.num_resets		= ARRAY_SIZE(sc7180_usb3phy_reset_l),
22958c2ecf20Sopenharmony_ci	.vreg_list		= qmp_phy_vreg_l,
22968c2ecf20Sopenharmony_ci	.num_vregs		= ARRAY_SIZE(qmp_phy_vreg_l),
22978c2ecf20Sopenharmony_ci	.regs			= qmp_v3_usb3phy_regs_layout,
22988c2ecf20Sopenharmony_ci
22998c2ecf20Sopenharmony_ci	.start_ctrl		= SERDES_START | PCS_START,
23008c2ecf20Sopenharmony_ci	.pwrdn_ctrl		= SW_PWRDN,
23018c2ecf20Sopenharmony_ci
23028c2ecf20Sopenharmony_ci	.has_pwrdn_delay	= true,
23038c2ecf20Sopenharmony_ci	.pwrdn_delay_min	= POWER_DOWN_DELAY_US_MIN,
23048c2ecf20Sopenharmony_ci	.pwrdn_delay_max	= POWER_DOWN_DELAY_US_MAX,
23058c2ecf20Sopenharmony_ci
23068c2ecf20Sopenharmony_ci	.has_phy_dp_com_ctrl	= true,
23078c2ecf20Sopenharmony_ci	.is_dual_lane_phy	= true,
23088c2ecf20Sopenharmony_ci};
23098c2ecf20Sopenharmony_ci
23108c2ecf20Sopenharmony_cistatic const struct qmp_phy_cfg sc7180_dpphy_cfg = {
23118c2ecf20Sopenharmony_ci	.type			= PHY_TYPE_DP,
23128c2ecf20Sopenharmony_ci	.nlanes			= 1,
23138c2ecf20Sopenharmony_ci
23148c2ecf20Sopenharmony_ci	.serdes_tbl		= qmp_v3_dp_serdes_tbl,
23158c2ecf20Sopenharmony_ci	.serdes_tbl_num		= ARRAY_SIZE(qmp_v3_dp_serdes_tbl),
23168c2ecf20Sopenharmony_ci	.tx_tbl			= qmp_v3_dp_tx_tbl,
23178c2ecf20Sopenharmony_ci	.tx_tbl_num		= ARRAY_SIZE(qmp_v3_dp_tx_tbl),
23188c2ecf20Sopenharmony_ci
23198c2ecf20Sopenharmony_ci	.serdes_tbl_rbr		= qmp_v3_dp_serdes_tbl_rbr,
23208c2ecf20Sopenharmony_ci	.serdes_tbl_rbr_num	= ARRAY_SIZE(qmp_v3_dp_serdes_tbl_rbr),
23218c2ecf20Sopenharmony_ci	.serdes_tbl_hbr		= qmp_v3_dp_serdes_tbl_hbr,
23228c2ecf20Sopenharmony_ci	.serdes_tbl_hbr_num	= ARRAY_SIZE(qmp_v3_dp_serdes_tbl_hbr),
23238c2ecf20Sopenharmony_ci	.serdes_tbl_hbr2	= qmp_v3_dp_serdes_tbl_hbr2,
23248c2ecf20Sopenharmony_ci	.serdes_tbl_hbr2_num	= ARRAY_SIZE(qmp_v3_dp_serdes_tbl_hbr2),
23258c2ecf20Sopenharmony_ci	.serdes_tbl_hbr3	= qmp_v3_dp_serdes_tbl_hbr3,
23268c2ecf20Sopenharmony_ci	.serdes_tbl_hbr3_num	= ARRAY_SIZE(qmp_v3_dp_serdes_tbl_hbr3),
23278c2ecf20Sopenharmony_ci
23288c2ecf20Sopenharmony_ci	.clk_list		= qmp_v3_phy_clk_l,
23298c2ecf20Sopenharmony_ci	.num_clks		= ARRAY_SIZE(qmp_v3_phy_clk_l),
23308c2ecf20Sopenharmony_ci	.reset_list		= sc7180_usb3phy_reset_l,
23318c2ecf20Sopenharmony_ci	.num_resets		= ARRAY_SIZE(sc7180_usb3phy_reset_l),
23328c2ecf20Sopenharmony_ci	.vreg_list		= qmp_phy_vreg_l,
23338c2ecf20Sopenharmony_ci	.num_vregs		= ARRAY_SIZE(qmp_phy_vreg_l),
23348c2ecf20Sopenharmony_ci	.regs			= qmp_v3_usb3phy_regs_layout,
23358c2ecf20Sopenharmony_ci
23368c2ecf20Sopenharmony_ci	.has_phy_dp_com_ctrl	= true,
23378c2ecf20Sopenharmony_ci	.is_dual_lane_phy	= true,
23388c2ecf20Sopenharmony_ci};
23398c2ecf20Sopenharmony_ci
23408c2ecf20Sopenharmony_cistatic const struct qmp_phy_combo_cfg sc7180_usb3dpphy_cfg = {
23418c2ecf20Sopenharmony_ci	.usb_cfg		= &sc7180_usb3phy_cfg,
23428c2ecf20Sopenharmony_ci	.dp_cfg			= &sc7180_dpphy_cfg,
23438c2ecf20Sopenharmony_ci};
23448c2ecf20Sopenharmony_ci
23458c2ecf20Sopenharmony_cistatic const struct qmp_phy_cfg qmp_v3_usb3_uniphy_cfg = {
23468c2ecf20Sopenharmony_ci	.type			= PHY_TYPE_USB3,
23478c2ecf20Sopenharmony_ci	.nlanes			= 1,
23488c2ecf20Sopenharmony_ci
23498c2ecf20Sopenharmony_ci	.serdes_tbl		= qmp_v3_usb3_uniphy_serdes_tbl,
23508c2ecf20Sopenharmony_ci	.serdes_tbl_num		= ARRAY_SIZE(qmp_v3_usb3_uniphy_serdes_tbl),
23518c2ecf20Sopenharmony_ci	.tx_tbl			= qmp_v3_usb3_uniphy_tx_tbl,
23528c2ecf20Sopenharmony_ci	.tx_tbl_num		= ARRAY_SIZE(qmp_v3_usb3_uniphy_tx_tbl),
23538c2ecf20Sopenharmony_ci	.rx_tbl			= qmp_v3_usb3_uniphy_rx_tbl,
23548c2ecf20Sopenharmony_ci	.rx_tbl_num		= ARRAY_SIZE(qmp_v3_usb3_uniphy_rx_tbl),
23558c2ecf20Sopenharmony_ci	.pcs_tbl		= qmp_v3_usb3_uniphy_pcs_tbl,
23568c2ecf20Sopenharmony_ci	.pcs_tbl_num		= ARRAY_SIZE(qmp_v3_usb3_uniphy_pcs_tbl),
23578c2ecf20Sopenharmony_ci	.clk_list		= qmp_v3_phy_clk_l,
23588c2ecf20Sopenharmony_ci	.num_clks		= ARRAY_SIZE(qmp_v3_phy_clk_l),
23598c2ecf20Sopenharmony_ci	.reset_list		= msm8996_usb3phy_reset_l,
23608c2ecf20Sopenharmony_ci	.num_resets		= ARRAY_SIZE(msm8996_usb3phy_reset_l),
23618c2ecf20Sopenharmony_ci	.vreg_list		= qmp_phy_vreg_l,
23628c2ecf20Sopenharmony_ci	.num_vregs		= ARRAY_SIZE(qmp_phy_vreg_l),
23638c2ecf20Sopenharmony_ci	.regs			= qmp_v3_usb3phy_regs_layout,
23648c2ecf20Sopenharmony_ci
23658c2ecf20Sopenharmony_ci	.start_ctrl		= SERDES_START | PCS_START,
23668c2ecf20Sopenharmony_ci	.pwrdn_ctrl		= SW_PWRDN,
23678c2ecf20Sopenharmony_ci
23688c2ecf20Sopenharmony_ci	.has_pwrdn_delay	= true,
23698c2ecf20Sopenharmony_ci	.pwrdn_delay_min	= POWER_DOWN_DELAY_US_MIN,
23708c2ecf20Sopenharmony_ci	.pwrdn_delay_max	= POWER_DOWN_DELAY_US_MAX,
23718c2ecf20Sopenharmony_ci};
23728c2ecf20Sopenharmony_ci
23738c2ecf20Sopenharmony_cistatic const struct qmp_phy_cfg sdm845_ufsphy_cfg = {
23748c2ecf20Sopenharmony_ci	.type			= PHY_TYPE_UFS,
23758c2ecf20Sopenharmony_ci	.nlanes			= 2,
23768c2ecf20Sopenharmony_ci
23778c2ecf20Sopenharmony_ci	.serdes_tbl		= sdm845_ufsphy_serdes_tbl,
23788c2ecf20Sopenharmony_ci	.serdes_tbl_num		= ARRAY_SIZE(sdm845_ufsphy_serdes_tbl),
23798c2ecf20Sopenharmony_ci	.tx_tbl			= sdm845_ufsphy_tx_tbl,
23808c2ecf20Sopenharmony_ci	.tx_tbl_num		= ARRAY_SIZE(sdm845_ufsphy_tx_tbl),
23818c2ecf20Sopenharmony_ci	.rx_tbl			= sdm845_ufsphy_rx_tbl,
23828c2ecf20Sopenharmony_ci	.rx_tbl_num		= ARRAY_SIZE(sdm845_ufsphy_rx_tbl),
23838c2ecf20Sopenharmony_ci	.pcs_tbl		= sdm845_ufsphy_pcs_tbl,
23848c2ecf20Sopenharmony_ci	.pcs_tbl_num		= ARRAY_SIZE(sdm845_ufsphy_pcs_tbl),
23858c2ecf20Sopenharmony_ci	.clk_list		= sdm845_ufs_phy_clk_l,
23868c2ecf20Sopenharmony_ci	.num_clks		= ARRAY_SIZE(sdm845_ufs_phy_clk_l),
23878c2ecf20Sopenharmony_ci	.vreg_list		= qmp_phy_vreg_l,
23888c2ecf20Sopenharmony_ci	.num_vregs		= ARRAY_SIZE(qmp_phy_vreg_l),
23898c2ecf20Sopenharmony_ci	.regs			= sdm845_ufsphy_regs_layout,
23908c2ecf20Sopenharmony_ci
23918c2ecf20Sopenharmony_ci	.start_ctrl		= SERDES_START,
23928c2ecf20Sopenharmony_ci	.pwrdn_ctrl		= SW_PWRDN,
23938c2ecf20Sopenharmony_ci
23948c2ecf20Sopenharmony_ci	.is_dual_lane_phy	= true,
23958c2ecf20Sopenharmony_ci	.no_pcs_sw_reset	= true,
23968c2ecf20Sopenharmony_ci};
23978c2ecf20Sopenharmony_ci
23988c2ecf20Sopenharmony_cistatic const struct qmp_phy_cfg msm8998_pciephy_cfg = {
23998c2ecf20Sopenharmony_ci	.type			= PHY_TYPE_PCIE,
24008c2ecf20Sopenharmony_ci	.nlanes			= 1,
24018c2ecf20Sopenharmony_ci
24028c2ecf20Sopenharmony_ci	.serdes_tbl		= msm8998_pcie_serdes_tbl,
24038c2ecf20Sopenharmony_ci	.serdes_tbl_num		= ARRAY_SIZE(msm8998_pcie_serdes_tbl),
24048c2ecf20Sopenharmony_ci	.tx_tbl			= msm8998_pcie_tx_tbl,
24058c2ecf20Sopenharmony_ci	.tx_tbl_num		= ARRAY_SIZE(msm8998_pcie_tx_tbl),
24068c2ecf20Sopenharmony_ci	.rx_tbl			= msm8998_pcie_rx_tbl,
24078c2ecf20Sopenharmony_ci	.rx_tbl_num		= ARRAY_SIZE(msm8998_pcie_rx_tbl),
24088c2ecf20Sopenharmony_ci	.pcs_tbl		= msm8998_pcie_pcs_tbl,
24098c2ecf20Sopenharmony_ci	.pcs_tbl_num		= ARRAY_SIZE(msm8998_pcie_pcs_tbl),
24108c2ecf20Sopenharmony_ci	.clk_list		= msm8996_phy_clk_l,
24118c2ecf20Sopenharmony_ci	.num_clks		= ARRAY_SIZE(msm8996_phy_clk_l),
24128c2ecf20Sopenharmony_ci	.reset_list		= ipq8074_pciephy_reset_l,
24138c2ecf20Sopenharmony_ci	.num_resets		= ARRAY_SIZE(ipq8074_pciephy_reset_l),
24148c2ecf20Sopenharmony_ci	.vreg_list		= qmp_phy_vreg_l,
24158c2ecf20Sopenharmony_ci	.num_vregs		= ARRAY_SIZE(qmp_phy_vreg_l),
24168c2ecf20Sopenharmony_ci	.regs			= pciephy_regs_layout,
24178c2ecf20Sopenharmony_ci
24188c2ecf20Sopenharmony_ci	.start_ctrl             = SERDES_START | PCS_START,
24198c2ecf20Sopenharmony_ci	.pwrdn_ctrl		= SW_PWRDN | REFCLK_DRV_DSBL,
24208c2ecf20Sopenharmony_ci};
24218c2ecf20Sopenharmony_ci
24228c2ecf20Sopenharmony_cistatic const struct qmp_phy_cfg msm8998_usb3phy_cfg = {
24238c2ecf20Sopenharmony_ci	.type                   = PHY_TYPE_USB3,
24248c2ecf20Sopenharmony_ci	.nlanes                 = 1,
24258c2ecf20Sopenharmony_ci
24268c2ecf20Sopenharmony_ci	.serdes_tbl             = msm8998_usb3_serdes_tbl,
24278c2ecf20Sopenharmony_ci	.serdes_tbl_num         = ARRAY_SIZE(msm8998_usb3_serdes_tbl),
24288c2ecf20Sopenharmony_ci	.tx_tbl                 = msm8998_usb3_tx_tbl,
24298c2ecf20Sopenharmony_ci	.tx_tbl_num             = ARRAY_SIZE(msm8998_usb3_tx_tbl),
24308c2ecf20Sopenharmony_ci	.rx_tbl                 = msm8998_usb3_rx_tbl,
24318c2ecf20Sopenharmony_ci	.rx_tbl_num             = ARRAY_SIZE(msm8998_usb3_rx_tbl),
24328c2ecf20Sopenharmony_ci	.pcs_tbl                = msm8998_usb3_pcs_tbl,
24338c2ecf20Sopenharmony_ci	.pcs_tbl_num            = ARRAY_SIZE(msm8998_usb3_pcs_tbl),
24348c2ecf20Sopenharmony_ci	.clk_list               = msm8996_phy_clk_l,
24358c2ecf20Sopenharmony_ci	.num_clks               = ARRAY_SIZE(msm8996_phy_clk_l),
24368c2ecf20Sopenharmony_ci	.reset_list             = msm8996_usb3phy_reset_l,
24378c2ecf20Sopenharmony_ci	.num_resets             = ARRAY_SIZE(msm8996_usb3phy_reset_l),
24388c2ecf20Sopenharmony_ci	.vreg_list              = qmp_phy_vreg_l,
24398c2ecf20Sopenharmony_ci	.num_vregs              = ARRAY_SIZE(qmp_phy_vreg_l),
24408c2ecf20Sopenharmony_ci	.regs                   = qmp_v3_usb3phy_regs_layout,
24418c2ecf20Sopenharmony_ci
24428c2ecf20Sopenharmony_ci	.start_ctrl             = SERDES_START | PCS_START,
24438c2ecf20Sopenharmony_ci	.pwrdn_ctrl             = SW_PWRDN,
24448c2ecf20Sopenharmony_ci
24458c2ecf20Sopenharmony_ci	.is_dual_lane_phy       = true,
24468c2ecf20Sopenharmony_ci};
24478c2ecf20Sopenharmony_ci
24488c2ecf20Sopenharmony_cistatic const struct qmp_phy_cfg sm8150_ufsphy_cfg = {
24498c2ecf20Sopenharmony_ci	.type			= PHY_TYPE_UFS,
24508c2ecf20Sopenharmony_ci	.nlanes			= 2,
24518c2ecf20Sopenharmony_ci
24528c2ecf20Sopenharmony_ci	.serdes_tbl		= sm8150_ufsphy_serdes_tbl,
24538c2ecf20Sopenharmony_ci	.serdes_tbl_num		= ARRAY_SIZE(sm8150_ufsphy_serdes_tbl),
24548c2ecf20Sopenharmony_ci	.tx_tbl			= sm8150_ufsphy_tx_tbl,
24558c2ecf20Sopenharmony_ci	.tx_tbl_num		= ARRAY_SIZE(sm8150_ufsphy_tx_tbl),
24568c2ecf20Sopenharmony_ci	.rx_tbl			= sm8150_ufsphy_rx_tbl,
24578c2ecf20Sopenharmony_ci	.rx_tbl_num		= ARRAY_SIZE(sm8150_ufsphy_rx_tbl),
24588c2ecf20Sopenharmony_ci	.pcs_tbl		= sm8150_ufsphy_pcs_tbl,
24598c2ecf20Sopenharmony_ci	.pcs_tbl_num		= ARRAY_SIZE(sm8150_ufsphy_pcs_tbl),
24608c2ecf20Sopenharmony_ci	.clk_list		= sdm845_ufs_phy_clk_l,
24618c2ecf20Sopenharmony_ci	.num_clks		= ARRAY_SIZE(sdm845_ufs_phy_clk_l),
24628c2ecf20Sopenharmony_ci	.vreg_list		= qmp_phy_vreg_l,
24638c2ecf20Sopenharmony_ci	.num_vregs		= ARRAY_SIZE(qmp_phy_vreg_l),
24648c2ecf20Sopenharmony_ci	.regs			= sm8150_ufsphy_regs_layout,
24658c2ecf20Sopenharmony_ci
24668c2ecf20Sopenharmony_ci	.start_ctrl		= SERDES_START,
24678c2ecf20Sopenharmony_ci	.pwrdn_ctrl		= SW_PWRDN,
24688c2ecf20Sopenharmony_ci
24698c2ecf20Sopenharmony_ci	.is_dual_lane_phy	= true,
24708c2ecf20Sopenharmony_ci};
24718c2ecf20Sopenharmony_ci
24728c2ecf20Sopenharmony_cistatic const struct qmp_phy_cfg sm8150_usb3phy_cfg = {
24738c2ecf20Sopenharmony_ci	.type			= PHY_TYPE_USB3,
24748c2ecf20Sopenharmony_ci	.nlanes			= 1,
24758c2ecf20Sopenharmony_ci
24768c2ecf20Sopenharmony_ci	.serdes_tbl		= sm8150_usb3_serdes_tbl,
24778c2ecf20Sopenharmony_ci	.serdes_tbl_num		= ARRAY_SIZE(sm8150_usb3_serdes_tbl),
24788c2ecf20Sopenharmony_ci	.tx_tbl			= sm8150_usb3_tx_tbl,
24798c2ecf20Sopenharmony_ci	.tx_tbl_num		= ARRAY_SIZE(sm8150_usb3_tx_tbl),
24808c2ecf20Sopenharmony_ci	.rx_tbl			= sm8150_usb3_rx_tbl,
24818c2ecf20Sopenharmony_ci	.rx_tbl_num		= ARRAY_SIZE(sm8150_usb3_rx_tbl),
24828c2ecf20Sopenharmony_ci	.pcs_tbl		= sm8150_usb3_pcs_tbl,
24838c2ecf20Sopenharmony_ci	.pcs_tbl_num		= ARRAY_SIZE(sm8150_usb3_pcs_tbl),
24848c2ecf20Sopenharmony_ci	.clk_list		= qmp_v4_phy_clk_l,
24858c2ecf20Sopenharmony_ci	.num_clks		= ARRAY_SIZE(qmp_v4_phy_clk_l),
24868c2ecf20Sopenharmony_ci	.reset_list		= msm8996_usb3phy_reset_l,
24878c2ecf20Sopenharmony_ci	.num_resets		= ARRAY_SIZE(msm8996_usb3phy_reset_l),
24888c2ecf20Sopenharmony_ci	.vreg_list		= qmp_phy_vreg_l,
24898c2ecf20Sopenharmony_ci	.num_vregs		= ARRAY_SIZE(qmp_phy_vreg_l),
24908c2ecf20Sopenharmony_ci	.regs			= qmp_v4_usb3phy_regs_layout,
24918c2ecf20Sopenharmony_ci
24928c2ecf20Sopenharmony_ci	.start_ctrl		= SERDES_START | PCS_START,
24938c2ecf20Sopenharmony_ci	.pwrdn_ctrl		= SW_PWRDN,
24948c2ecf20Sopenharmony_ci
24958c2ecf20Sopenharmony_ci	.has_pwrdn_delay	= true,
24968c2ecf20Sopenharmony_ci	.pwrdn_delay_min	= POWER_DOWN_DELAY_US_MIN,
24978c2ecf20Sopenharmony_ci	.pwrdn_delay_max	= POWER_DOWN_DELAY_US_MAX,
24988c2ecf20Sopenharmony_ci
24998c2ecf20Sopenharmony_ci	.has_phy_dp_com_ctrl	= true,
25008c2ecf20Sopenharmony_ci	.is_dual_lane_phy	= true,
25018c2ecf20Sopenharmony_ci};
25028c2ecf20Sopenharmony_ci
25038c2ecf20Sopenharmony_cistatic const struct qmp_phy_cfg sm8150_usb3_uniphy_cfg = {
25048c2ecf20Sopenharmony_ci	.type			= PHY_TYPE_USB3,
25058c2ecf20Sopenharmony_ci	.nlanes			= 1,
25068c2ecf20Sopenharmony_ci
25078c2ecf20Sopenharmony_ci	.serdes_tbl		= sm8150_usb3_uniphy_serdes_tbl,
25088c2ecf20Sopenharmony_ci	.serdes_tbl_num		= ARRAY_SIZE(sm8150_usb3_uniphy_serdes_tbl),
25098c2ecf20Sopenharmony_ci	.tx_tbl			= sm8150_usb3_uniphy_tx_tbl,
25108c2ecf20Sopenharmony_ci	.tx_tbl_num		= ARRAY_SIZE(sm8150_usb3_uniphy_tx_tbl),
25118c2ecf20Sopenharmony_ci	.rx_tbl			= sm8150_usb3_uniphy_rx_tbl,
25128c2ecf20Sopenharmony_ci	.rx_tbl_num		= ARRAY_SIZE(sm8150_usb3_uniphy_rx_tbl),
25138c2ecf20Sopenharmony_ci	.pcs_tbl		= sm8150_usb3_uniphy_pcs_tbl,
25148c2ecf20Sopenharmony_ci	.pcs_tbl_num		= ARRAY_SIZE(sm8150_usb3_uniphy_pcs_tbl),
25158c2ecf20Sopenharmony_ci	.clk_list		= qmp_v4_phy_clk_l,
25168c2ecf20Sopenharmony_ci	.num_clks		= ARRAY_SIZE(qmp_v4_phy_clk_l),
25178c2ecf20Sopenharmony_ci	.reset_list		= msm8996_usb3phy_reset_l,
25188c2ecf20Sopenharmony_ci	.num_resets		= ARRAY_SIZE(msm8996_usb3phy_reset_l),
25198c2ecf20Sopenharmony_ci	.vreg_list		= qmp_phy_vreg_l,
25208c2ecf20Sopenharmony_ci	.num_vregs		= ARRAY_SIZE(qmp_phy_vreg_l),
25218c2ecf20Sopenharmony_ci	.regs			= qmp_v4_usb3_uniphy_regs_layout,
25228c2ecf20Sopenharmony_ci
25238c2ecf20Sopenharmony_ci	.start_ctrl		= SERDES_START | PCS_START,
25248c2ecf20Sopenharmony_ci	.pwrdn_ctrl		= SW_PWRDN,
25258c2ecf20Sopenharmony_ci
25268c2ecf20Sopenharmony_ci	.has_pwrdn_delay	= true,
25278c2ecf20Sopenharmony_ci	.pwrdn_delay_min	= POWER_DOWN_DELAY_US_MIN,
25288c2ecf20Sopenharmony_ci	.pwrdn_delay_max	= POWER_DOWN_DELAY_US_MAX,
25298c2ecf20Sopenharmony_ci};
25308c2ecf20Sopenharmony_ci
25318c2ecf20Sopenharmony_cistatic const struct qmp_phy_cfg sm8250_usb3phy_cfg = {
25328c2ecf20Sopenharmony_ci	.type			= PHY_TYPE_USB3,
25338c2ecf20Sopenharmony_ci	.nlanes			= 1,
25348c2ecf20Sopenharmony_ci
25358c2ecf20Sopenharmony_ci	.serdes_tbl		= sm8150_usb3_serdes_tbl,
25368c2ecf20Sopenharmony_ci	.serdes_tbl_num		= ARRAY_SIZE(sm8150_usb3_serdes_tbl),
25378c2ecf20Sopenharmony_ci	.tx_tbl			= sm8250_usb3_tx_tbl,
25388c2ecf20Sopenharmony_ci	.tx_tbl_num		= ARRAY_SIZE(sm8250_usb3_tx_tbl),
25398c2ecf20Sopenharmony_ci	.rx_tbl			= sm8250_usb3_rx_tbl,
25408c2ecf20Sopenharmony_ci	.rx_tbl_num		= ARRAY_SIZE(sm8250_usb3_rx_tbl),
25418c2ecf20Sopenharmony_ci	.pcs_tbl		= sm8250_usb3_pcs_tbl,
25428c2ecf20Sopenharmony_ci	.pcs_tbl_num		= ARRAY_SIZE(sm8250_usb3_pcs_tbl),
25438c2ecf20Sopenharmony_ci	.clk_list		= qmp_v4_sm8250_usbphy_clk_l,
25448c2ecf20Sopenharmony_ci	.num_clks		= ARRAY_SIZE(qmp_v4_sm8250_usbphy_clk_l),
25458c2ecf20Sopenharmony_ci	.reset_list		= msm8996_usb3phy_reset_l,
25468c2ecf20Sopenharmony_ci	.num_resets		= ARRAY_SIZE(msm8996_usb3phy_reset_l),
25478c2ecf20Sopenharmony_ci	.vreg_list		= qmp_phy_vreg_l,
25488c2ecf20Sopenharmony_ci	.num_vregs		= ARRAY_SIZE(qmp_phy_vreg_l),
25498c2ecf20Sopenharmony_ci	.regs			= qmp_v4_usb3phy_regs_layout,
25508c2ecf20Sopenharmony_ci
25518c2ecf20Sopenharmony_ci	.start_ctrl		= SERDES_START | PCS_START,
25528c2ecf20Sopenharmony_ci	.pwrdn_ctrl		= SW_PWRDN,
25538c2ecf20Sopenharmony_ci
25548c2ecf20Sopenharmony_ci	.has_pwrdn_delay	= true,
25558c2ecf20Sopenharmony_ci	.pwrdn_delay_min	= POWER_DOWN_DELAY_US_MIN,
25568c2ecf20Sopenharmony_ci	.pwrdn_delay_max	= POWER_DOWN_DELAY_US_MAX,
25578c2ecf20Sopenharmony_ci
25588c2ecf20Sopenharmony_ci	.has_phy_dp_com_ctrl	= true,
25598c2ecf20Sopenharmony_ci	.is_dual_lane_phy	= true,
25608c2ecf20Sopenharmony_ci};
25618c2ecf20Sopenharmony_ci
25628c2ecf20Sopenharmony_cistatic const struct qmp_phy_cfg sm8250_usb3_uniphy_cfg = {
25638c2ecf20Sopenharmony_ci	.type			= PHY_TYPE_USB3,
25648c2ecf20Sopenharmony_ci	.nlanes			= 1,
25658c2ecf20Sopenharmony_ci
25668c2ecf20Sopenharmony_ci	.serdes_tbl		= sm8150_usb3_uniphy_serdes_tbl,
25678c2ecf20Sopenharmony_ci	.serdes_tbl_num		= ARRAY_SIZE(sm8150_usb3_uniphy_serdes_tbl),
25688c2ecf20Sopenharmony_ci	.tx_tbl			= sm8250_usb3_uniphy_tx_tbl,
25698c2ecf20Sopenharmony_ci	.tx_tbl_num		= ARRAY_SIZE(sm8250_usb3_uniphy_tx_tbl),
25708c2ecf20Sopenharmony_ci	.rx_tbl			= sm8250_usb3_uniphy_rx_tbl,
25718c2ecf20Sopenharmony_ci	.rx_tbl_num		= ARRAY_SIZE(sm8250_usb3_uniphy_rx_tbl),
25728c2ecf20Sopenharmony_ci	.pcs_tbl		= sm8250_usb3_uniphy_pcs_tbl,
25738c2ecf20Sopenharmony_ci	.pcs_tbl_num		= ARRAY_SIZE(sm8250_usb3_uniphy_pcs_tbl),
25748c2ecf20Sopenharmony_ci	.clk_list		= qmp_v4_phy_clk_l,
25758c2ecf20Sopenharmony_ci	.num_clks		= ARRAY_SIZE(qmp_v4_phy_clk_l),
25768c2ecf20Sopenharmony_ci	.reset_list		= msm8996_usb3phy_reset_l,
25778c2ecf20Sopenharmony_ci	.num_resets		= ARRAY_SIZE(msm8996_usb3phy_reset_l),
25788c2ecf20Sopenharmony_ci	.vreg_list		= qmp_phy_vreg_l,
25798c2ecf20Sopenharmony_ci	.num_vregs		= ARRAY_SIZE(qmp_phy_vreg_l),
25808c2ecf20Sopenharmony_ci	.regs			= qmp_v4_usb3_uniphy_regs_layout,
25818c2ecf20Sopenharmony_ci
25828c2ecf20Sopenharmony_ci	.start_ctrl		= SERDES_START | PCS_START,
25838c2ecf20Sopenharmony_ci	.pwrdn_ctrl		= SW_PWRDN,
25848c2ecf20Sopenharmony_ci
25858c2ecf20Sopenharmony_ci	.has_pwrdn_delay	= true,
25868c2ecf20Sopenharmony_ci	.pwrdn_delay_min	= POWER_DOWN_DELAY_US_MIN,
25878c2ecf20Sopenharmony_ci	.pwrdn_delay_max	= POWER_DOWN_DELAY_US_MAX,
25888c2ecf20Sopenharmony_ci};
25898c2ecf20Sopenharmony_ci
25908c2ecf20Sopenharmony_cistatic void qcom_qmp_phy_configure_lane(void __iomem *base,
25918c2ecf20Sopenharmony_ci					const unsigned int *regs,
25928c2ecf20Sopenharmony_ci					const struct qmp_phy_init_tbl tbl[],
25938c2ecf20Sopenharmony_ci					int num,
25948c2ecf20Sopenharmony_ci					u8 lane_mask)
25958c2ecf20Sopenharmony_ci{
25968c2ecf20Sopenharmony_ci	int i;
25978c2ecf20Sopenharmony_ci	const struct qmp_phy_init_tbl *t = tbl;
25988c2ecf20Sopenharmony_ci
25998c2ecf20Sopenharmony_ci	if (!t)
26008c2ecf20Sopenharmony_ci		return;
26018c2ecf20Sopenharmony_ci
26028c2ecf20Sopenharmony_ci	for (i = 0; i < num; i++, t++) {
26038c2ecf20Sopenharmony_ci		if (!(t->lane_mask & lane_mask))
26048c2ecf20Sopenharmony_ci			continue;
26058c2ecf20Sopenharmony_ci
26068c2ecf20Sopenharmony_ci		if (t->in_layout)
26078c2ecf20Sopenharmony_ci			writel(t->val, base + regs[t->offset]);
26088c2ecf20Sopenharmony_ci		else
26098c2ecf20Sopenharmony_ci			writel(t->val, base + t->offset);
26108c2ecf20Sopenharmony_ci	}
26118c2ecf20Sopenharmony_ci}
26128c2ecf20Sopenharmony_ci
26138c2ecf20Sopenharmony_cistatic void qcom_qmp_phy_configure(void __iomem *base,
26148c2ecf20Sopenharmony_ci				   const unsigned int *regs,
26158c2ecf20Sopenharmony_ci				   const struct qmp_phy_init_tbl tbl[],
26168c2ecf20Sopenharmony_ci				   int num)
26178c2ecf20Sopenharmony_ci{
26188c2ecf20Sopenharmony_ci	qcom_qmp_phy_configure_lane(base, regs, tbl, num, 0xff);
26198c2ecf20Sopenharmony_ci}
26208c2ecf20Sopenharmony_ci
26218c2ecf20Sopenharmony_cistatic int qcom_qmp_phy_serdes_init(struct qmp_phy *qphy)
26228c2ecf20Sopenharmony_ci{
26238c2ecf20Sopenharmony_ci	struct qcom_qmp *qmp = qphy->qmp;
26248c2ecf20Sopenharmony_ci	const struct qmp_phy_cfg *cfg = qphy->cfg;
26258c2ecf20Sopenharmony_ci	void __iomem *serdes = qphy->serdes;
26268c2ecf20Sopenharmony_ci	const struct phy_configure_opts_dp *dp_opts = &qphy->dp_opts;
26278c2ecf20Sopenharmony_ci	const struct qmp_phy_init_tbl *serdes_tbl = cfg->serdes_tbl;
26288c2ecf20Sopenharmony_ci	int serdes_tbl_num = cfg->serdes_tbl_num;
26298c2ecf20Sopenharmony_ci	int ret;
26308c2ecf20Sopenharmony_ci
26318c2ecf20Sopenharmony_ci	qcom_qmp_phy_configure(serdes, cfg->regs, serdes_tbl, serdes_tbl_num);
26328c2ecf20Sopenharmony_ci
26338c2ecf20Sopenharmony_ci	if (cfg->type == PHY_TYPE_DP) {
26348c2ecf20Sopenharmony_ci		switch (dp_opts->link_rate) {
26358c2ecf20Sopenharmony_ci		case 1620:
26368c2ecf20Sopenharmony_ci			qcom_qmp_phy_configure(serdes, cfg->regs,
26378c2ecf20Sopenharmony_ci					       cfg->serdes_tbl_rbr,
26388c2ecf20Sopenharmony_ci					       cfg->serdes_tbl_rbr_num);
26398c2ecf20Sopenharmony_ci			break;
26408c2ecf20Sopenharmony_ci		case 2700:
26418c2ecf20Sopenharmony_ci			qcom_qmp_phy_configure(serdes, cfg->regs,
26428c2ecf20Sopenharmony_ci					       cfg->serdes_tbl_hbr,
26438c2ecf20Sopenharmony_ci					       cfg->serdes_tbl_hbr_num);
26448c2ecf20Sopenharmony_ci			break;
26458c2ecf20Sopenharmony_ci		case 5400:
26468c2ecf20Sopenharmony_ci			qcom_qmp_phy_configure(serdes, cfg->regs,
26478c2ecf20Sopenharmony_ci					       cfg->serdes_tbl_hbr2,
26488c2ecf20Sopenharmony_ci					       cfg->serdes_tbl_hbr2_num);
26498c2ecf20Sopenharmony_ci			break;
26508c2ecf20Sopenharmony_ci		case 8100:
26518c2ecf20Sopenharmony_ci			qcom_qmp_phy_configure(serdes, cfg->regs,
26528c2ecf20Sopenharmony_ci					       cfg->serdes_tbl_hbr3,
26538c2ecf20Sopenharmony_ci					       cfg->serdes_tbl_hbr3_num);
26548c2ecf20Sopenharmony_ci			break;
26558c2ecf20Sopenharmony_ci		default:
26568c2ecf20Sopenharmony_ci			/* Other link rates aren't supported */
26578c2ecf20Sopenharmony_ci			return -EINVAL;
26588c2ecf20Sopenharmony_ci		}
26598c2ecf20Sopenharmony_ci	}
26608c2ecf20Sopenharmony_ci
26618c2ecf20Sopenharmony_ci
26628c2ecf20Sopenharmony_ci	if (cfg->has_phy_com_ctrl) {
26638c2ecf20Sopenharmony_ci		void __iomem *status;
26648c2ecf20Sopenharmony_ci		unsigned int mask, val;
26658c2ecf20Sopenharmony_ci
26668c2ecf20Sopenharmony_ci		qphy_clrbits(serdes, cfg->regs[QPHY_COM_SW_RESET], SW_RESET);
26678c2ecf20Sopenharmony_ci		qphy_setbits(serdes, cfg->regs[QPHY_COM_START_CONTROL],
26688c2ecf20Sopenharmony_ci			     SERDES_START | PCS_START);
26698c2ecf20Sopenharmony_ci
26708c2ecf20Sopenharmony_ci		status = serdes + cfg->regs[QPHY_COM_PCS_READY_STATUS];
26718c2ecf20Sopenharmony_ci		mask = cfg->mask_com_pcs_ready;
26728c2ecf20Sopenharmony_ci
26738c2ecf20Sopenharmony_ci		ret = readl_poll_timeout(status, val, (val & mask), 10,
26748c2ecf20Sopenharmony_ci					 PHY_INIT_COMPLETE_TIMEOUT);
26758c2ecf20Sopenharmony_ci		if (ret) {
26768c2ecf20Sopenharmony_ci			dev_err(qmp->dev,
26778c2ecf20Sopenharmony_ci				"phy common block init timed-out\n");
26788c2ecf20Sopenharmony_ci			return ret;
26798c2ecf20Sopenharmony_ci		}
26808c2ecf20Sopenharmony_ci	}
26818c2ecf20Sopenharmony_ci
26828c2ecf20Sopenharmony_ci	return 0;
26838c2ecf20Sopenharmony_ci}
26848c2ecf20Sopenharmony_ci
26858c2ecf20Sopenharmony_cistatic void qcom_qmp_phy_dp_aux_init(struct qmp_phy *qphy)
26868c2ecf20Sopenharmony_ci{
26878c2ecf20Sopenharmony_ci	writel(DP_PHY_PD_CTL_PWRDN | DP_PHY_PD_CTL_AUX_PWRDN |
26888c2ecf20Sopenharmony_ci	       DP_PHY_PD_CTL_PLL_PWRDN | DP_PHY_PD_CTL_DP_CLAMP_EN,
26898c2ecf20Sopenharmony_ci	       qphy->pcs + QSERDES_V3_DP_PHY_PD_CTL);
26908c2ecf20Sopenharmony_ci
26918c2ecf20Sopenharmony_ci	/* Turn on BIAS current for PHY/PLL */
26928c2ecf20Sopenharmony_ci	writel(QSERDES_V3_COM_BIAS_EN | QSERDES_V3_COM_BIAS_EN_MUX |
26938c2ecf20Sopenharmony_ci	       QSERDES_V3_COM_CLKBUF_L_EN | QSERDES_V3_COM_EN_SYSCLK_TX_SEL,
26948c2ecf20Sopenharmony_ci	       qphy->serdes + QSERDES_V3_COM_BIAS_EN_CLKBUFLR_EN);
26958c2ecf20Sopenharmony_ci
26968c2ecf20Sopenharmony_ci	writel(DP_PHY_PD_CTL_PSR_PWRDN, qphy->pcs + QSERDES_V3_DP_PHY_PD_CTL);
26978c2ecf20Sopenharmony_ci
26988c2ecf20Sopenharmony_ci	writel(DP_PHY_PD_CTL_PWRDN | DP_PHY_PD_CTL_AUX_PWRDN |
26998c2ecf20Sopenharmony_ci	       DP_PHY_PD_CTL_LANE_0_1_PWRDN |
27008c2ecf20Sopenharmony_ci	       DP_PHY_PD_CTL_LANE_2_3_PWRDN | DP_PHY_PD_CTL_PLL_PWRDN |
27018c2ecf20Sopenharmony_ci	       DP_PHY_PD_CTL_DP_CLAMP_EN,
27028c2ecf20Sopenharmony_ci	       qphy->pcs + QSERDES_V3_DP_PHY_PD_CTL);
27038c2ecf20Sopenharmony_ci
27048c2ecf20Sopenharmony_ci	writel(QSERDES_V3_COM_BIAS_EN |
27058c2ecf20Sopenharmony_ci	       QSERDES_V3_COM_BIAS_EN_MUX | QSERDES_V3_COM_CLKBUF_R_EN |
27068c2ecf20Sopenharmony_ci	       QSERDES_V3_COM_CLKBUF_L_EN | QSERDES_V3_COM_EN_SYSCLK_TX_SEL |
27078c2ecf20Sopenharmony_ci	       QSERDES_V3_COM_CLKBUF_RX_DRIVE_L,
27088c2ecf20Sopenharmony_ci	       qphy->serdes + QSERDES_V3_COM_BIAS_EN_CLKBUFLR_EN);
27098c2ecf20Sopenharmony_ci
27108c2ecf20Sopenharmony_ci	writel(0x00, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG0);
27118c2ecf20Sopenharmony_ci	writel(0x13, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG1);
27128c2ecf20Sopenharmony_ci	writel(0x24, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG2);
27138c2ecf20Sopenharmony_ci	writel(0x00, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG3);
27148c2ecf20Sopenharmony_ci	writel(0x0a, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG4);
27158c2ecf20Sopenharmony_ci	writel(0x26, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG5);
27168c2ecf20Sopenharmony_ci	writel(0x0a, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG6);
27178c2ecf20Sopenharmony_ci	writel(0x03, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG7);
27188c2ecf20Sopenharmony_ci	writel(0xbb, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG8);
27198c2ecf20Sopenharmony_ci	writel(0x03, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG9);
27208c2ecf20Sopenharmony_ci	qphy->dp_aux_cfg = 0;
27218c2ecf20Sopenharmony_ci
27228c2ecf20Sopenharmony_ci	writel(PHY_AUX_STOP_ERR_MASK | PHY_AUX_DEC_ERR_MASK |
27238c2ecf20Sopenharmony_ci	       PHY_AUX_SYNC_ERR_MASK | PHY_AUX_ALIGN_ERR_MASK |
27248c2ecf20Sopenharmony_ci	       PHY_AUX_REQ_ERR_MASK,
27258c2ecf20Sopenharmony_ci	       qphy->pcs + QSERDES_V3_DP_PHY_AUX_INTERRUPT_MASK);
27268c2ecf20Sopenharmony_ci}
27278c2ecf20Sopenharmony_ci
27288c2ecf20Sopenharmony_cistatic const u8 qmp_dp_v3_pre_emphasis_hbr_rbr[4][4] = {
27298c2ecf20Sopenharmony_ci	{ 0x00, 0x0c, 0x14, 0x19 },
27308c2ecf20Sopenharmony_ci	{ 0x00, 0x0b, 0x12, 0xff },
27318c2ecf20Sopenharmony_ci	{ 0x00, 0x0b, 0xff, 0xff },
27328c2ecf20Sopenharmony_ci	{ 0x04, 0xff, 0xff, 0xff }
27338c2ecf20Sopenharmony_ci};
27348c2ecf20Sopenharmony_ci
27358c2ecf20Sopenharmony_cistatic const u8 qmp_dp_v3_voltage_swing_hbr_rbr[4][4] = {
27368c2ecf20Sopenharmony_ci	{ 0x08, 0x0f, 0x16, 0x1f },
27378c2ecf20Sopenharmony_ci	{ 0x11, 0x1e, 0x1f, 0xff },
27388c2ecf20Sopenharmony_ci	{ 0x19, 0x1f, 0xff, 0xff },
27398c2ecf20Sopenharmony_ci	{ 0x1f, 0xff, 0xff, 0xff }
27408c2ecf20Sopenharmony_ci};
27418c2ecf20Sopenharmony_ci
27428c2ecf20Sopenharmony_cistatic void qcom_qmp_phy_configure_dp_tx(struct qmp_phy *qphy)
27438c2ecf20Sopenharmony_ci{
27448c2ecf20Sopenharmony_ci	const struct phy_configure_opts_dp *dp_opts = &qphy->dp_opts;
27458c2ecf20Sopenharmony_ci	unsigned int v_level = 0, p_level = 0;
27468c2ecf20Sopenharmony_ci	u32 bias_en, drvr_en;
27478c2ecf20Sopenharmony_ci	u8 voltage_swing_cfg, pre_emphasis_cfg;
27488c2ecf20Sopenharmony_ci	int i;
27498c2ecf20Sopenharmony_ci
27508c2ecf20Sopenharmony_ci	for (i = 0; i < dp_opts->lanes; i++) {
27518c2ecf20Sopenharmony_ci		v_level = max(v_level, dp_opts->voltage[i]);
27528c2ecf20Sopenharmony_ci		p_level = max(p_level, dp_opts->pre[i]);
27538c2ecf20Sopenharmony_ci	}
27548c2ecf20Sopenharmony_ci
27558c2ecf20Sopenharmony_ci	if (dp_opts->lanes == 1) {
27568c2ecf20Sopenharmony_ci		bias_en = 0x3e;
27578c2ecf20Sopenharmony_ci		drvr_en = 0x13;
27588c2ecf20Sopenharmony_ci	} else {
27598c2ecf20Sopenharmony_ci		bias_en = 0x3f;
27608c2ecf20Sopenharmony_ci		drvr_en = 0x10;
27618c2ecf20Sopenharmony_ci	}
27628c2ecf20Sopenharmony_ci
27638c2ecf20Sopenharmony_ci	voltage_swing_cfg = qmp_dp_v3_voltage_swing_hbr_rbr[v_level][p_level];
27648c2ecf20Sopenharmony_ci	pre_emphasis_cfg = qmp_dp_v3_pre_emphasis_hbr_rbr[v_level][p_level];
27658c2ecf20Sopenharmony_ci
27668c2ecf20Sopenharmony_ci	/* TODO: Move check to config check */
27678c2ecf20Sopenharmony_ci	if (voltage_swing_cfg == 0xFF && pre_emphasis_cfg == 0xFF)
27688c2ecf20Sopenharmony_ci		return;
27698c2ecf20Sopenharmony_ci
27708c2ecf20Sopenharmony_ci	/* Enable MUX to use Cursor values from these registers */
27718c2ecf20Sopenharmony_ci	voltage_swing_cfg |= DP_PHY_TXn_TX_DRV_LVL_MUX_EN;
27728c2ecf20Sopenharmony_ci	pre_emphasis_cfg |= DP_PHY_TXn_TX_EMP_POST1_LVL_MUX_EN;
27738c2ecf20Sopenharmony_ci
27748c2ecf20Sopenharmony_ci	writel(voltage_swing_cfg, qphy->tx + QSERDES_V3_TX_TX_DRV_LVL);
27758c2ecf20Sopenharmony_ci	writel(pre_emphasis_cfg, qphy->tx + QSERDES_V3_TX_TX_EMP_POST1_LVL);
27768c2ecf20Sopenharmony_ci	writel(voltage_swing_cfg, qphy->tx2 + QSERDES_V3_TX_TX_DRV_LVL);
27778c2ecf20Sopenharmony_ci	writel(pre_emphasis_cfg, qphy->tx2 + QSERDES_V3_TX_TX_EMP_POST1_LVL);
27788c2ecf20Sopenharmony_ci
27798c2ecf20Sopenharmony_ci	writel(drvr_en, qphy->tx + QSERDES_V3_TX_HIGHZ_DRVR_EN);
27808c2ecf20Sopenharmony_ci	writel(bias_en, qphy->tx + QSERDES_V3_TX_TRANSCEIVER_BIAS_EN);
27818c2ecf20Sopenharmony_ci	writel(drvr_en, qphy->tx2 + QSERDES_V3_TX_HIGHZ_DRVR_EN);
27828c2ecf20Sopenharmony_ci	writel(bias_en, qphy->tx2 + QSERDES_V3_TX_TRANSCEIVER_BIAS_EN);
27838c2ecf20Sopenharmony_ci}
27848c2ecf20Sopenharmony_ci
27858c2ecf20Sopenharmony_cistatic int qcom_qmp_dp_phy_configure(struct phy *phy, union phy_configure_opts *opts)
27868c2ecf20Sopenharmony_ci{
27878c2ecf20Sopenharmony_ci	const struct phy_configure_opts_dp *dp_opts = &opts->dp;
27888c2ecf20Sopenharmony_ci	struct qmp_phy *qphy = phy_get_drvdata(phy);
27898c2ecf20Sopenharmony_ci
27908c2ecf20Sopenharmony_ci	memcpy(&qphy->dp_opts, dp_opts, sizeof(*dp_opts));
27918c2ecf20Sopenharmony_ci	if (qphy->dp_opts.set_voltages) {
27928c2ecf20Sopenharmony_ci		qcom_qmp_phy_configure_dp_tx(qphy);
27938c2ecf20Sopenharmony_ci		qphy->dp_opts.set_voltages = 0;
27948c2ecf20Sopenharmony_ci	}
27958c2ecf20Sopenharmony_ci
27968c2ecf20Sopenharmony_ci	return 0;
27978c2ecf20Sopenharmony_ci}
27988c2ecf20Sopenharmony_ci
27998c2ecf20Sopenharmony_cistatic int qcom_qmp_phy_configure_dp_phy(struct qmp_phy *qphy)
28008c2ecf20Sopenharmony_ci{
28018c2ecf20Sopenharmony_ci	const struct qmp_phy_dp_clks *dp_clks = qphy->dp_clks;
28028c2ecf20Sopenharmony_ci	const struct phy_configure_opts_dp *dp_opts = &qphy->dp_opts;
28038c2ecf20Sopenharmony_ci	u32 val, phy_vco_div, status;
28048c2ecf20Sopenharmony_ci	unsigned long pixel_freq;
28058c2ecf20Sopenharmony_ci
28068c2ecf20Sopenharmony_ci	val = DP_PHY_PD_CTL_PWRDN | DP_PHY_PD_CTL_AUX_PWRDN |
28078c2ecf20Sopenharmony_ci	      DP_PHY_PD_CTL_PLL_PWRDN | DP_PHY_PD_CTL_DP_CLAMP_EN;
28088c2ecf20Sopenharmony_ci
28098c2ecf20Sopenharmony_ci	/*
28108c2ecf20Sopenharmony_ci	 * TODO: Assume orientation is CC1 for now and two lanes, need to
28118c2ecf20Sopenharmony_ci	 * use type-c connector to understand orientation and lanes.
28128c2ecf20Sopenharmony_ci	 *
28138c2ecf20Sopenharmony_ci	 * Otherwise val changes to be like below if this code understood
28148c2ecf20Sopenharmony_ci	 * the orientation of the type-c cable.
28158c2ecf20Sopenharmony_ci	 *
28168c2ecf20Sopenharmony_ci	 * if (lane_cnt == 4 || orientation == ORIENTATION_CC2)
28178c2ecf20Sopenharmony_ci	 *	val |= DP_PHY_PD_CTL_LANE_0_1_PWRDN;
28188c2ecf20Sopenharmony_ci	 * if (lane_cnt == 4 || orientation == ORIENTATION_CC1)
28198c2ecf20Sopenharmony_ci	 *	val |= DP_PHY_PD_CTL_LANE_2_3_PWRDN;
28208c2ecf20Sopenharmony_ci	 * if (orientation == ORIENTATION_CC2)
28218c2ecf20Sopenharmony_ci	 *	writel(0x4c, qphy->pcs + QSERDES_V3_DP_PHY_MODE);
28228c2ecf20Sopenharmony_ci	 */
28238c2ecf20Sopenharmony_ci	val |= DP_PHY_PD_CTL_LANE_2_3_PWRDN;
28248c2ecf20Sopenharmony_ci	writel(val, qphy->pcs + QSERDES_V3_DP_PHY_PD_CTL);
28258c2ecf20Sopenharmony_ci
28268c2ecf20Sopenharmony_ci	writel(0x5c, qphy->pcs + QSERDES_V3_DP_PHY_MODE);
28278c2ecf20Sopenharmony_ci	writel(0x05, qphy->pcs + QSERDES_V3_DP_PHY_TX0_TX1_LANE_CTL);
28288c2ecf20Sopenharmony_ci	writel(0x05, qphy->pcs + QSERDES_V3_DP_PHY_TX2_TX3_LANE_CTL);
28298c2ecf20Sopenharmony_ci
28308c2ecf20Sopenharmony_ci	switch (dp_opts->link_rate) {
28318c2ecf20Sopenharmony_ci	case 1620:
28328c2ecf20Sopenharmony_ci		phy_vco_div = 0x1;
28338c2ecf20Sopenharmony_ci		pixel_freq = 1620000000UL / 2;
28348c2ecf20Sopenharmony_ci		break;
28358c2ecf20Sopenharmony_ci	case 2700:
28368c2ecf20Sopenharmony_ci		phy_vco_div = 0x1;
28378c2ecf20Sopenharmony_ci		pixel_freq = 2700000000UL / 2;
28388c2ecf20Sopenharmony_ci		break;
28398c2ecf20Sopenharmony_ci	case 5400:
28408c2ecf20Sopenharmony_ci		phy_vco_div = 0x2;
28418c2ecf20Sopenharmony_ci		pixel_freq = 5400000000UL / 4;
28428c2ecf20Sopenharmony_ci		break;
28438c2ecf20Sopenharmony_ci	case 8100:
28448c2ecf20Sopenharmony_ci		phy_vco_div = 0x0;
28458c2ecf20Sopenharmony_ci		pixel_freq = 8100000000UL / 6;
28468c2ecf20Sopenharmony_ci		break;
28478c2ecf20Sopenharmony_ci	default:
28488c2ecf20Sopenharmony_ci		/* Other link rates aren't supported */
28498c2ecf20Sopenharmony_ci		return -EINVAL;
28508c2ecf20Sopenharmony_ci	}
28518c2ecf20Sopenharmony_ci	writel(phy_vco_div, qphy->pcs + QSERDES_V3_DP_PHY_VCO_DIV);
28528c2ecf20Sopenharmony_ci
28538c2ecf20Sopenharmony_ci	clk_set_rate(dp_clks->dp_link_hw.clk, dp_opts->link_rate * 100000);
28548c2ecf20Sopenharmony_ci	clk_set_rate(dp_clks->dp_pixel_hw.clk, pixel_freq);
28558c2ecf20Sopenharmony_ci
28568c2ecf20Sopenharmony_ci	writel(0x04, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG2);
28578c2ecf20Sopenharmony_ci	writel(0x01, qphy->pcs + QSERDES_V3_DP_PHY_CFG);
28588c2ecf20Sopenharmony_ci	writel(0x05, qphy->pcs + QSERDES_V3_DP_PHY_CFG);
28598c2ecf20Sopenharmony_ci	writel(0x01, qphy->pcs + QSERDES_V3_DP_PHY_CFG);
28608c2ecf20Sopenharmony_ci	writel(0x09, qphy->pcs + QSERDES_V3_DP_PHY_CFG);
28618c2ecf20Sopenharmony_ci
28628c2ecf20Sopenharmony_ci	writel(0x20, qphy->serdes + QSERDES_V3_COM_RESETSM_CNTRL);
28638c2ecf20Sopenharmony_ci
28648c2ecf20Sopenharmony_ci	if (readl_poll_timeout(qphy->serdes + QSERDES_V3_COM_C_READY_STATUS,
28658c2ecf20Sopenharmony_ci			status,
28668c2ecf20Sopenharmony_ci			((status & BIT(0)) > 0),
28678c2ecf20Sopenharmony_ci			500,
28688c2ecf20Sopenharmony_ci			10000))
28698c2ecf20Sopenharmony_ci		return -ETIMEDOUT;
28708c2ecf20Sopenharmony_ci
28718c2ecf20Sopenharmony_ci	writel(0x19, qphy->pcs + QSERDES_V3_DP_PHY_CFG);
28728c2ecf20Sopenharmony_ci
28738c2ecf20Sopenharmony_ci	if (readl_poll_timeout(qphy->pcs + QSERDES_V3_DP_PHY_STATUS,
28748c2ecf20Sopenharmony_ci			status,
28758c2ecf20Sopenharmony_ci			((status & BIT(1)) > 0),
28768c2ecf20Sopenharmony_ci			500,
28778c2ecf20Sopenharmony_ci			10000))
28788c2ecf20Sopenharmony_ci		return -ETIMEDOUT;
28798c2ecf20Sopenharmony_ci
28808c2ecf20Sopenharmony_ci	writel(0x18, qphy->pcs + QSERDES_V3_DP_PHY_CFG);
28818c2ecf20Sopenharmony_ci	udelay(2000);
28828c2ecf20Sopenharmony_ci	writel(0x19, qphy->pcs + QSERDES_V3_DP_PHY_CFG);
28838c2ecf20Sopenharmony_ci
28848c2ecf20Sopenharmony_ci	return readl_poll_timeout(qphy->pcs + QSERDES_V3_DP_PHY_STATUS,
28858c2ecf20Sopenharmony_ci			status,
28868c2ecf20Sopenharmony_ci			((status & BIT(1)) > 0),
28878c2ecf20Sopenharmony_ci			500,
28888c2ecf20Sopenharmony_ci			10000);
28898c2ecf20Sopenharmony_ci}
28908c2ecf20Sopenharmony_ci
28918c2ecf20Sopenharmony_ci/*
28928c2ecf20Sopenharmony_ci * We need to calibrate the aux setting here as many times
28938c2ecf20Sopenharmony_ci * as the caller tries
28948c2ecf20Sopenharmony_ci */
28958c2ecf20Sopenharmony_cistatic int qcom_qmp_dp_phy_calibrate(struct phy *phy)
28968c2ecf20Sopenharmony_ci{
28978c2ecf20Sopenharmony_ci	struct qmp_phy *qphy = phy_get_drvdata(phy);
28988c2ecf20Sopenharmony_ci	const u8 cfg1_settings[] = { 0x13, 0x23, 0x1d };
28998c2ecf20Sopenharmony_ci	u8 val;
29008c2ecf20Sopenharmony_ci
29018c2ecf20Sopenharmony_ci	qphy->dp_aux_cfg++;
29028c2ecf20Sopenharmony_ci	qphy->dp_aux_cfg %= ARRAY_SIZE(cfg1_settings);
29038c2ecf20Sopenharmony_ci	val = cfg1_settings[qphy->dp_aux_cfg];
29048c2ecf20Sopenharmony_ci
29058c2ecf20Sopenharmony_ci	writel(val, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG1);
29068c2ecf20Sopenharmony_ci
29078c2ecf20Sopenharmony_ci	return 0;
29088c2ecf20Sopenharmony_ci}
29098c2ecf20Sopenharmony_ci
29108c2ecf20Sopenharmony_cistatic int qcom_qmp_phy_com_init(struct qmp_phy *qphy)
29118c2ecf20Sopenharmony_ci{
29128c2ecf20Sopenharmony_ci	struct qcom_qmp *qmp = qphy->qmp;
29138c2ecf20Sopenharmony_ci	const struct qmp_phy_cfg *cfg = qphy->cfg;
29148c2ecf20Sopenharmony_ci	void __iomem *serdes = qphy->serdes;
29158c2ecf20Sopenharmony_ci	void __iomem *pcs = qphy->pcs;
29168c2ecf20Sopenharmony_ci	void __iomem *dp_com = qmp->dp_com;
29178c2ecf20Sopenharmony_ci	int ret, i;
29188c2ecf20Sopenharmony_ci
29198c2ecf20Sopenharmony_ci	mutex_lock(&qmp->phy_mutex);
29208c2ecf20Sopenharmony_ci	if (qmp->init_count++) {
29218c2ecf20Sopenharmony_ci		mutex_unlock(&qmp->phy_mutex);
29228c2ecf20Sopenharmony_ci		return 0;
29238c2ecf20Sopenharmony_ci	}
29248c2ecf20Sopenharmony_ci
29258c2ecf20Sopenharmony_ci	/* turn on regulator supplies */
29268c2ecf20Sopenharmony_ci	ret = regulator_bulk_enable(cfg->num_vregs, qmp->vregs);
29278c2ecf20Sopenharmony_ci	if (ret) {
29288c2ecf20Sopenharmony_ci		dev_err(qmp->dev, "failed to enable regulators, err=%d\n", ret);
29298c2ecf20Sopenharmony_ci		goto err_reg_enable;
29308c2ecf20Sopenharmony_ci	}
29318c2ecf20Sopenharmony_ci
29328c2ecf20Sopenharmony_ci	for (i = 0; i < cfg->num_resets; i++) {
29338c2ecf20Sopenharmony_ci		ret = reset_control_assert(qmp->resets[i]);
29348c2ecf20Sopenharmony_ci		if (ret) {
29358c2ecf20Sopenharmony_ci			dev_err(qmp->dev, "%s reset assert failed\n",
29368c2ecf20Sopenharmony_ci				cfg->reset_list[i]);
29378c2ecf20Sopenharmony_ci			goto err_rst_assert;
29388c2ecf20Sopenharmony_ci		}
29398c2ecf20Sopenharmony_ci	}
29408c2ecf20Sopenharmony_ci
29418c2ecf20Sopenharmony_ci	for (i = cfg->num_resets - 1; i >= 0; i--) {
29428c2ecf20Sopenharmony_ci		ret = reset_control_deassert(qmp->resets[i]);
29438c2ecf20Sopenharmony_ci		if (ret) {
29448c2ecf20Sopenharmony_ci			dev_err(qmp->dev, "%s reset deassert failed\n",
29458c2ecf20Sopenharmony_ci				qphy->cfg->reset_list[i]);
29468c2ecf20Sopenharmony_ci			goto err_rst;
29478c2ecf20Sopenharmony_ci		}
29488c2ecf20Sopenharmony_ci	}
29498c2ecf20Sopenharmony_ci
29508c2ecf20Sopenharmony_ci	ret = clk_bulk_prepare_enable(cfg->num_clks, qmp->clks);
29518c2ecf20Sopenharmony_ci	if (ret) {
29528c2ecf20Sopenharmony_ci		dev_err(qmp->dev, "failed to enable clks, err=%d\n", ret);
29538c2ecf20Sopenharmony_ci		goto err_rst;
29548c2ecf20Sopenharmony_ci	}
29558c2ecf20Sopenharmony_ci
29568c2ecf20Sopenharmony_ci	if (cfg->has_phy_dp_com_ctrl) {
29578c2ecf20Sopenharmony_ci		qphy_setbits(dp_com, QPHY_V3_DP_COM_POWER_DOWN_CTRL,
29588c2ecf20Sopenharmony_ci			     SW_PWRDN);
29598c2ecf20Sopenharmony_ci		/* override hardware control for reset of qmp phy */
29608c2ecf20Sopenharmony_ci		qphy_setbits(dp_com, QPHY_V3_DP_COM_RESET_OVRD_CTRL,
29618c2ecf20Sopenharmony_ci			     SW_DPPHY_RESET_MUX | SW_DPPHY_RESET |
29628c2ecf20Sopenharmony_ci			     SW_USB3PHY_RESET_MUX | SW_USB3PHY_RESET);
29638c2ecf20Sopenharmony_ci
29648c2ecf20Sopenharmony_ci		/* Default type-c orientation, i.e CC1 */
29658c2ecf20Sopenharmony_ci		qphy_setbits(dp_com, QPHY_V3_DP_COM_TYPEC_CTRL, 0x02);
29668c2ecf20Sopenharmony_ci
29678c2ecf20Sopenharmony_ci		qphy_setbits(dp_com, QPHY_V3_DP_COM_PHY_MODE_CTRL,
29688c2ecf20Sopenharmony_ci			     USB3_MODE | DP_MODE);
29698c2ecf20Sopenharmony_ci
29708c2ecf20Sopenharmony_ci		/* bring both QMP USB and QMP DP PHYs PCS block out of reset */
29718c2ecf20Sopenharmony_ci		qphy_clrbits(dp_com, QPHY_V3_DP_COM_RESET_OVRD_CTRL,
29728c2ecf20Sopenharmony_ci			     SW_DPPHY_RESET_MUX | SW_DPPHY_RESET |
29738c2ecf20Sopenharmony_ci			     SW_USB3PHY_RESET_MUX | SW_USB3PHY_RESET);
29748c2ecf20Sopenharmony_ci
29758c2ecf20Sopenharmony_ci		qphy_clrbits(dp_com, QPHY_V3_DP_COM_SWI_CTRL, 0x03);
29768c2ecf20Sopenharmony_ci		qphy_clrbits(dp_com, QPHY_V3_DP_COM_SW_RESET, SW_RESET);
29778c2ecf20Sopenharmony_ci	}
29788c2ecf20Sopenharmony_ci
29798c2ecf20Sopenharmony_ci	if (cfg->has_phy_com_ctrl) {
29808c2ecf20Sopenharmony_ci		qphy_setbits(serdes, cfg->regs[QPHY_COM_POWER_DOWN_CONTROL],
29818c2ecf20Sopenharmony_ci			     SW_PWRDN);
29828c2ecf20Sopenharmony_ci	} else {
29838c2ecf20Sopenharmony_ci		if (cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL])
29848c2ecf20Sopenharmony_ci			qphy_setbits(pcs,
29858c2ecf20Sopenharmony_ci					cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL],
29868c2ecf20Sopenharmony_ci					cfg->pwrdn_ctrl);
29878c2ecf20Sopenharmony_ci		else
29888c2ecf20Sopenharmony_ci			qphy_setbits(pcs, QPHY_POWER_DOWN_CONTROL,
29898c2ecf20Sopenharmony_ci					cfg->pwrdn_ctrl);
29908c2ecf20Sopenharmony_ci	}
29918c2ecf20Sopenharmony_ci
29928c2ecf20Sopenharmony_ci	mutex_unlock(&qmp->phy_mutex);
29938c2ecf20Sopenharmony_ci
29948c2ecf20Sopenharmony_ci	return 0;
29958c2ecf20Sopenharmony_ci
29968c2ecf20Sopenharmony_cierr_rst:
29978c2ecf20Sopenharmony_ci	while (++i < cfg->num_resets)
29988c2ecf20Sopenharmony_ci		reset_control_assert(qmp->resets[i]);
29998c2ecf20Sopenharmony_cierr_rst_assert:
30008c2ecf20Sopenharmony_ci	regulator_bulk_disable(cfg->num_vregs, qmp->vregs);
30018c2ecf20Sopenharmony_cierr_reg_enable:
30028c2ecf20Sopenharmony_ci	mutex_unlock(&qmp->phy_mutex);
30038c2ecf20Sopenharmony_ci
30048c2ecf20Sopenharmony_ci	return ret;
30058c2ecf20Sopenharmony_ci}
30068c2ecf20Sopenharmony_ci
30078c2ecf20Sopenharmony_cistatic int qcom_qmp_phy_com_exit(struct qmp_phy *qphy)
30088c2ecf20Sopenharmony_ci{
30098c2ecf20Sopenharmony_ci	struct qcom_qmp *qmp = qphy->qmp;
30108c2ecf20Sopenharmony_ci	const struct qmp_phy_cfg *cfg = qphy->cfg;
30118c2ecf20Sopenharmony_ci	void __iomem *serdes = qphy->serdes;
30128c2ecf20Sopenharmony_ci	int i = cfg->num_resets;
30138c2ecf20Sopenharmony_ci
30148c2ecf20Sopenharmony_ci	mutex_lock(&qmp->phy_mutex);
30158c2ecf20Sopenharmony_ci	if (--qmp->init_count) {
30168c2ecf20Sopenharmony_ci		mutex_unlock(&qmp->phy_mutex);
30178c2ecf20Sopenharmony_ci		return 0;
30188c2ecf20Sopenharmony_ci	}
30198c2ecf20Sopenharmony_ci
30208c2ecf20Sopenharmony_ci	reset_control_assert(qmp->ufs_reset);
30218c2ecf20Sopenharmony_ci	if (cfg->has_phy_com_ctrl) {
30228c2ecf20Sopenharmony_ci		qphy_setbits(serdes, cfg->regs[QPHY_COM_START_CONTROL],
30238c2ecf20Sopenharmony_ci			     SERDES_START | PCS_START);
30248c2ecf20Sopenharmony_ci		qphy_clrbits(serdes, cfg->regs[QPHY_COM_SW_RESET],
30258c2ecf20Sopenharmony_ci			     SW_RESET);
30268c2ecf20Sopenharmony_ci		qphy_setbits(serdes, cfg->regs[QPHY_COM_POWER_DOWN_CONTROL],
30278c2ecf20Sopenharmony_ci			     SW_PWRDN);
30288c2ecf20Sopenharmony_ci	}
30298c2ecf20Sopenharmony_ci
30308c2ecf20Sopenharmony_ci	while (--i >= 0)
30318c2ecf20Sopenharmony_ci		reset_control_assert(qmp->resets[i]);
30328c2ecf20Sopenharmony_ci
30338c2ecf20Sopenharmony_ci	clk_bulk_disable_unprepare(cfg->num_clks, qmp->clks);
30348c2ecf20Sopenharmony_ci
30358c2ecf20Sopenharmony_ci	regulator_bulk_disable(cfg->num_vregs, qmp->vregs);
30368c2ecf20Sopenharmony_ci
30378c2ecf20Sopenharmony_ci	mutex_unlock(&qmp->phy_mutex);
30388c2ecf20Sopenharmony_ci
30398c2ecf20Sopenharmony_ci	return 0;
30408c2ecf20Sopenharmony_ci}
30418c2ecf20Sopenharmony_ci
30428c2ecf20Sopenharmony_cistatic int qcom_qmp_phy_init(struct phy *phy)
30438c2ecf20Sopenharmony_ci{
30448c2ecf20Sopenharmony_ci	struct qmp_phy *qphy = phy_get_drvdata(phy);
30458c2ecf20Sopenharmony_ci	struct qcom_qmp *qmp = qphy->qmp;
30468c2ecf20Sopenharmony_ci	const struct qmp_phy_cfg *cfg = qphy->cfg;
30478c2ecf20Sopenharmony_ci	int ret;
30488c2ecf20Sopenharmony_ci	dev_vdbg(qmp->dev, "Initializing QMP phy\n");
30498c2ecf20Sopenharmony_ci
30508c2ecf20Sopenharmony_ci	if (cfg->no_pcs_sw_reset) {
30518c2ecf20Sopenharmony_ci		/*
30528c2ecf20Sopenharmony_ci		 * Get UFS reset, which is delayed until now to avoid a
30538c2ecf20Sopenharmony_ci		 * circular dependency where UFS needs its PHY, but the PHY
30548c2ecf20Sopenharmony_ci		 * needs this UFS reset.
30558c2ecf20Sopenharmony_ci		 */
30568c2ecf20Sopenharmony_ci		if (!qmp->ufs_reset) {
30578c2ecf20Sopenharmony_ci			qmp->ufs_reset =
30588c2ecf20Sopenharmony_ci				devm_reset_control_get_exclusive(qmp->dev,
30598c2ecf20Sopenharmony_ci								 "ufsphy");
30608c2ecf20Sopenharmony_ci
30618c2ecf20Sopenharmony_ci			if (IS_ERR(qmp->ufs_reset)) {
30628c2ecf20Sopenharmony_ci				ret = PTR_ERR(qmp->ufs_reset);
30638c2ecf20Sopenharmony_ci				dev_err(qmp->dev,
30648c2ecf20Sopenharmony_ci					"failed to get UFS reset: %d\n",
30658c2ecf20Sopenharmony_ci					ret);
30668c2ecf20Sopenharmony_ci
30678c2ecf20Sopenharmony_ci				qmp->ufs_reset = NULL;
30688c2ecf20Sopenharmony_ci				return ret;
30698c2ecf20Sopenharmony_ci			}
30708c2ecf20Sopenharmony_ci		}
30718c2ecf20Sopenharmony_ci
30728c2ecf20Sopenharmony_ci		ret = reset_control_assert(qmp->ufs_reset);
30738c2ecf20Sopenharmony_ci		if (ret)
30748c2ecf20Sopenharmony_ci			return ret;
30758c2ecf20Sopenharmony_ci	}
30768c2ecf20Sopenharmony_ci
30778c2ecf20Sopenharmony_ci	ret = qcom_qmp_phy_com_init(qphy);
30788c2ecf20Sopenharmony_ci	if (ret)
30798c2ecf20Sopenharmony_ci		return ret;
30808c2ecf20Sopenharmony_ci
30818c2ecf20Sopenharmony_ci	if (cfg->type == PHY_TYPE_DP)
30828c2ecf20Sopenharmony_ci		qcom_qmp_phy_dp_aux_init(qphy);
30838c2ecf20Sopenharmony_ci
30848c2ecf20Sopenharmony_ci	return 0;
30858c2ecf20Sopenharmony_ci}
30868c2ecf20Sopenharmony_ci
30878c2ecf20Sopenharmony_cistatic int qcom_qmp_phy_power_on(struct phy *phy)
30888c2ecf20Sopenharmony_ci{
30898c2ecf20Sopenharmony_ci	struct qmp_phy *qphy = phy_get_drvdata(phy);
30908c2ecf20Sopenharmony_ci	struct qcom_qmp *qmp = qphy->qmp;
30918c2ecf20Sopenharmony_ci	const struct qmp_phy_cfg *cfg = qphy->cfg;
30928c2ecf20Sopenharmony_ci	void __iomem *tx = qphy->tx;
30938c2ecf20Sopenharmony_ci	void __iomem *rx = qphy->rx;
30948c2ecf20Sopenharmony_ci	void __iomem *pcs = qphy->pcs;
30958c2ecf20Sopenharmony_ci	void __iomem *pcs_misc = qphy->pcs_misc;
30968c2ecf20Sopenharmony_ci	void __iomem *status;
30978c2ecf20Sopenharmony_ci	unsigned int mask, val, ready;
30988c2ecf20Sopenharmony_ci	int ret;
30998c2ecf20Sopenharmony_ci
31008c2ecf20Sopenharmony_ci	qcom_qmp_phy_serdes_init(qphy);
31018c2ecf20Sopenharmony_ci
31028c2ecf20Sopenharmony_ci	if (cfg->has_lane_rst) {
31038c2ecf20Sopenharmony_ci		ret = reset_control_deassert(qphy->lane_rst);
31048c2ecf20Sopenharmony_ci		if (ret) {
31058c2ecf20Sopenharmony_ci			dev_err(qmp->dev, "lane%d reset deassert failed\n",
31068c2ecf20Sopenharmony_ci				qphy->index);
31078c2ecf20Sopenharmony_ci			goto err_lane_rst;
31088c2ecf20Sopenharmony_ci		}
31098c2ecf20Sopenharmony_ci	}
31108c2ecf20Sopenharmony_ci
31118c2ecf20Sopenharmony_ci	ret = clk_prepare_enable(qphy->pipe_clk);
31128c2ecf20Sopenharmony_ci	if (ret) {
31138c2ecf20Sopenharmony_ci		dev_err(qmp->dev, "pipe_clk enable failed err=%d\n", ret);
31148c2ecf20Sopenharmony_ci		goto err_clk_enable;
31158c2ecf20Sopenharmony_ci	}
31168c2ecf20Sopenharmony_ci
31178c2ecf20Sopenharmony_ci	/* Tx, Rx, and PCS configurations */
31188c2ecf20Sopenharmony_ci	qcom_qmp_phy_configure_lane(tx, cfg->regs,
31198c2ecf20Sopenharmony_ci				    cfg->tx_tbl, cfg->tx_tbl_num, 1);
31208c2ecf20Sopenharmony_ci	/* Configuration for other LANE for USB-DP combo PHY */
31218c2ecf20Sopenharmony_ci	if (cfg->is_dual_lane_phy)
31228c2ecf20Sopenharmony_ci		qcom_qmp_phy_configure_lane(qphy->tx2, cfg->regs,
31238c2ecf20Sopenharmony_ci					    cfg->tx_tbl, cfg->tx_tbl_num, 2);
31248c2ecf20Sopenharmony_ci
31258c2ecf20Sopenharmony_ci	/* Configure special DP tx tunings */
31268c2ecf20Sopenharmony_ci	if (cfg->type == PHY_TYPE_DP)
31278c2ecf20Sopenharmony_ci		qcom_qmp_phy_configure_dp_tx(qphy);
31288c2ecf20Sopenharmony_ci
31298c2ecf20Sopenharmony_ci	qcom_qmp_phy_configure_lane(rx, cfg->regs,
31308c2ecf20Sopenharmony_ci				    cfg->rx_tbl, cfg->rx_tbl_num, 1);
31318c2ecf20Sopenharmony_ci
31328c2ecf20Sopenharmony_ci	if (cfg->is_dual_lane_phy)
31338c2ecf20Sopenharmony_ci		qcom_qmp_phy_configure_lane(qphy->rx2, cfg->regs,
31348c2ecf20Sopenharmony_ci					    cfg->rx_tbl, cfg->rx_tbl_num, 2);
31358c2ecf20Sopenharmony_ci
31368c2ecf20Sopenharmony_ci	/* Configure link rate, swing, etc. */
31378c2ecf20Sopenharmony_ci	if (cfg->type == PHY_TYPE_DP)
31388c2ecf20Sopenharmony_ci		qcom_qmp_phy_configure_dp_phy(qphy);
31398c2ecf20Sopenharmony_ci	else
31408c2ecf20Sopenharmony_ci		qcom_qmp_phy_configure(pcs, cfg->regs, cfg->pcs_tbl, cfg->pcs_tbl_num);
31418c2ecf20Sopenharmony_ci
31428c2ecf20Sopenharmony_ci	ret = reset_control_deassert(qmp->ufs_reset);
31438c2ecf20Sopenharmony_ci	if (ret)
31448c2ecf20Sopenharmony_ci		goto err_pcs_ready;
31458c2ecf20Sopenharmony_ci
31468c2ecf20Sopenharmony_ci	qcom_qmp_phy_configure(pcs_misc, cfg->regs, cfg->pcs_misc_tbl,
31478c2ecf20Sopenharmony_ci			       cfg->pcs_misc_tbl_num);
31488c2ecf20Sopenharmony_ci
31498c2ecf20Sopenharmony_ci	/*
31508c2ecf20Sopenharmony_ci	 * Pull out PHY from POWER DOWN state.
31518c2ecf20Sopenharmony_ci	 * This is active low enable signal to power-down PHY.
31528c2ecf20Sopenharmony_ci	 */
31538c2ecf20Sopenharmony_ci	if(cfg->type == PHY_TYPE_PCIE)
31548c2ecf20Sopenharmony_ci		qphy_setbits(pcs, QPHY_POWER_DOWN_CONTROL, cfg->pwrdn_ctrl);
31558c2ecf20Sopenharmony_ci
31568c2ecf20Sopenharmony_ci	if (cfg->has_pwrdn_delay)
31578c2ecf20Sopenharmony_ci		usleep_range(cfg->pwrdn_delay_min, cfg->pwrdn_delay_max);
31588c2ecf20Sopenharmony_ci
31598c2ecf20Sopenharmony_ci	if (cfg->type != PHY_TYPE_DP) {
31608c2ecf20Sopenharmony_ci		/* Pull PHY out of reset state */
31618c2ecf20Sopenharmony_ci		if (!cfg->no_pcs_sw_reset)
31628c2ecf20Sopenharmony_ci			qphy_clrbits(pcs, cfg->regs[QPHY_SW_RESET], SW_RESET);
31638c2ecf20Sopenharmony_ci		/* start SerDes and Phy-Coding-Sublayer */
31648c2ecf20Sopenharmony_ci		qphy_setbits(pcs, cfg->regs[QPHY_START_CTRL], cfg->start_ctrl);
31658c2ecf20Sopenharmony_ci
31668c2ecf20Sopenharmony_ci		if (cfg->type == PHY_TYPE_UFS) {
31678c2ecf20Sopenharmony_ci			status = pcs + cfg->regs[QPHY_PCS_READY_STATUS];
31688c2ecf20Sopenharmony_ci			mask = PCS_READY;
31698c2ecf20Sopenharmony_ci			ready = PCS_READY;
31708c2ecf20Sopenharmony_ci		} else {
31718c2ecf20Sopenharmony_ci			status = pcs + cfg->regs[QPHY_PCS_STATUS];
31728c2ecf20Sopenharmony_ci			mask = PHYSTATUS;
31738c2ecf20Sopenharmony_ci			ready = 0;
31748c2ecf20Sopenharmony_ci		}
31758c2ecf20Sopenharmony_ci
31768c2ecf20Sopenharmony_ci		ret = readl_poll_timeout(status, val, (val & mask) == ready, 10,
31778c2ecf20Sopenharmony_ci					 PHY_INIT_COMPLETE_TIMEOUT);
31788c2ecf20Sopenharmony_ci		if (ret) {
31798c2ecf20Sopenharmony_ci			dev_err(qmp->dev, "phy initialization timed-out\n");
31808c2ecf20Sopenharmony_ci			goto err_pcs_ready;
31818c2ecf20Sopenharmony_ci		}
31828c2ecf20Sopenharmony_ci	}
31838c2ecf20Sopenharmony_ci	return 0;
31848c2ecf20Sopenharmony_ci
31858c2ecf20Sopenharmony_cierr_pcs_ready:
31868c2ecf20Sopenharmony_ci	clk_disable_unprepare(qphy->pipe_clk);
31878c2ecf20Sopenharmony_cierr_clk_enable:
31888c2ecf20Sopenharmony_ci	if (cfg->has_lane_rst)
31898c2ecf20Sopenharmony_ci		reset_control_assert(qphy->lane_rst);
31908c2ecf20Sopenharmony_cierr_lane_rst:
31918c2ecf20Sopenharmony_ci	return ret;
31928c2ecf20Sopenharmony_ci}
31938c2ecf20Sopenharmony_ci
31948c2ecf20Sopenharmony_cistatic int qcom_qmp_phy_power_off(struct phy *phy)
31958c2ecf20Sopenharmony_ci{
31968c2ecf20Sopenharmony_ci	struct qmp_phy *qphy = phy_get_drvdata(phy);
31978c2ecf20Sopenharmony_ci	const struct qmp_phy_cfg *cfg = qphy->cfg;
31988c2ecf20Sopenharmony_ci
31998c2ecf20Sopenharmony_ci	clk_disable_unprepare(qphy->pipe_clk);
32008c2ecf20Sopenharmony_ci
32018c2ecf20Sopenharmony_ci	if (cfg->type == PHY_TYPE_DP) {
32028c2ecf20Sopenharmony_ci		/* Assert DP PHY power down */
32038c2ecf20Sopenharmony_ci		writel(DP_PHY_PD_CTL_PSR_PWRDN, qphy->pcs + QSERDES_V3_DP_PHY_PD_CTL);
32048c2ecf20Sopenharmony_ci	} else {
32058c2ecf20Sopenharmony_ci		/* PHY reset */
32068c2ecf20Sopenharmony_ci		if (!cfg->no_pcs_sw_reset)
32078c2ecf20Sopenharmony_ci			qphy_setbits(qphy->pcs, cfg->regs[QPHY_SW_RESET], SW_RESET);
32088c2ecf20Sopenharmony_ci
32098c2ecf20Sopenharmony_ci		/* stop SerDes and Phy-Coding-Sublayer */
32108c2ecf20Sopenharmony_ci		qphy_clrbits(qphy->pcs, cfg->regs[QPHY_START_CTRL], cfg->start_ctrl);
32118c2ecf20Sopenharmony_ci
32128c2ecf20Sopenharmony_ci		/* Put PHY into POWER DOWN state: active low */
32138c2ecf20Sopenharmony_ci		if (cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL]) {
32148c2ecf20Sopenharmony_ci			qphy_clrbits(qphy->pcs, cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL],
32158c2ecf20Sopenharmony_ci				     cfg->pwrdn_ctrl);
32168c2ecf20Sopenharmony_ci		} else {
32178c2ecf20Sopenharmony_ci			qphy_clrbits(qphy->pcs, QPHY_POWER_DOWN_CONTROL,
32188c2ecf20Sopenharmony_ci					cfg->pwrdn_ctrl);
32198c2ecf20Sopenharmony_ci		}
32208c2ecf20Sopenharmony_ci	}
32218c2ecf20Sopenharmony_ci
32228c2ecf20Sopenharmony_ci	return 0;
32238c2ecf20Sopenharmony_ci}
32248c2ecf20Sopenharmony_ci
32258c2ecf20Sopenharmony_cistatic int qcom_qmp_phy_exit(struct phy *phy)
32268c2ecf20Sopenharmony_ci{
32278c2ecf20Sopenharmony_ci	struct qmp_phy *qphy = phy_get_drvdata(phy);
32288c2ecf20Sopenharmony_ci	const struct qmp_phy_cfg *cfg = qphy->cfg;
32298c2ecf20Sopenharmony_ci
32308c2ecf20Sopenharmony_ci	if (cfg->has_lane_rst)
32318c2ecf20Sopenharmony_ci		reset_control_assert(qphy->lane_rst);
32328c2ecf20Sopenharmony_ci
32338c2ecf20Sopenharmony_ci	qcom_qmp_phy_com_exit(qphy);
32348c2ecf20Sopenharmony_ci
32358c2ecf20Sopenharmony_ci	return 0;
32368c2ecf20Sopenharmony_ci}
32378c2ecf20Sopenharmony_ci
32388c2ecf20Sopenharmony_cistatic int qcom_qmp_phy_enable(struct phy *phy)
32398c2ecf20Sopenharmony_ci{
32408c2ecf20Sopenharmony_ci	int ret;
32418c2ecf20Sopenharmony_ci
32428c2ecf20Sopenharmony_ci	ret = qcom_qmp_phy_init(phy);
32438c2ecf20Sopenharmony_ci	if (ret)
32448c2ecf20Sopenharmony_ci		return ret;
32458c2ecf20Sopenharmony_ci
32468c2ecf20Sopenharmony_ci	ret = qcom_qmp_phy_power_on(phy);
32478c2ecf20Sopenharmony_ci	if (ret)
32488c2ecf20Sopenharmony_ci		qcom_qmp_phy_exit(phy);
32498c2ecf20Sopenharmony_ci
32508c2ecf20Sopenharmony_ci	return ret;
32518c2ecf20Sopenharmony_ci}
32528c2ecf20Sopenharmony_ci
32538c2ecf20Sopenharmony_cistatic int qcom_qmp_phy_disable(struct phy *phy)
32548c2ecf20Sopenharmony_ci{
32558c2ecf20Sopenharmony_ci	int ret;
32568c2ecf20Sopenharmony_ci
32578c2ecf20Sopenharmony_ci	ret = qcom_qmp_phy_power_off(phy);
32588c2ecf20Sopenharmony_ci	if (ret)
32598c2ecf20Sopenharmony_ci		return ret;
32608c2ecf20Sopenharmony_ci	return qcom_qmp_phy_exit(phy);
32618c2ecf20Sopenharmony_ci}
32628c2ecf20Sopenharmony_ci
32638c2ecf20Sopenharmony_cistatic int qcom_qmp_phy_set_mode(struct phy *phy,
32648c2ecf20Sopenharmony_ci				 enum phy_mode mode, int submode)
32658c2ecf20Sopenharmony_ci{
32668c2ecf20Sopenharmony_ci	struct qmp_phy *qphy = phy_get_drvdata(phy);
32678c2ecf20Sopenharmony_ci
32688c2ecf20Sopenharmony_ci	qphy->mode = mode;
32698c2ecf20Sopenharmony_ci
32708c2ecf20Sopenharmony_ci	return 0;
32718c2ecf20Sopenharmony_ci}
32728c2ecf20Sopenharmony_ci
32738c2ecf20Sopenharmony_cistatic void qcom_qmp_phy_enable_autonomous_mode(struct qmp_phy *qphy)
32748c2ecf20Sopenharmony_ci{
32758c2ecf20Sopenharmony_ci	const struct qmp_phy_cfg *cfg = qphy->cfg;
32768c2ecf20Sopenharmony_ci	void __iomem *pcs = qphy->pcs;
32778c2ecf20Sopenharmony_ci	void __iomem *pcs_misc = qphy->pcs_misc;
32788c2ecf20Sopenharmony_ci	u32 intr_mask;
32798c2ecf20Sopenharmony_ci
32808c2ecf20Sopenharmony_ci	if (qphy->mode == PHY_MODE_USB_HOST_SS ||
32818c2ecf20Sopenharmony_ci	    qphy->mode == PHY_MODE_USB_DEVICE_SS)
32828c2ecf20Sopenharmony_ci		intr_mask = ARCVR_DTCT_EN | ALFPS_DTCT_EN;
32838c2ecf20Sopenharmony_ci	else
32848c2ecf20Sopenharmony_ci		intr_mask = ARCVR_DTCT_EN | ARCVR_DTCT_EVENT_SEL;
32858c2ecf20Sopenharmony_ci
32868c2ecf20Sopenharmony_ci	/* Clear any pending interrupts status */
32878c2ecf20Sopenharmony_ci	qphy_setbits(pcs, cfg->regs[QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR], IRQ_CLEAR);
32888c2ecf20Sopenharmony_ci	/* Writing 1 followed by 0 clears the interrupt */
32898c2ecf20Sopenharmony_ci	qphy_clrbits(pcs, cfg->regs[QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR], IRQ_CLEAR);
32908c2ecf20Sopenharmony_ci
32918c2ecf20Sopenharmony_ci	qphy_clrbits(pcs, cfg->regs[QPHY_PCS_AUTONOMOUS_MODE_CTRL],
32928c2ecf20Sopenharmony_ci		     ARCVR_DTCT_EN | ALFPS_DTCT_EN | ARCVR_DTCT_EVENT_SEL);
32938c2ecf20Sopenharmony_ci
32948c2ecf20Sopenharmony_ci	/* Enable required PHY autonomous mode interrupts */
32958c2ecf20Sopenharmony_ci	qphy_setbits(pcs, cfg->regs[QPHY_PCS_AUTONOMOUS_MODE_CTRL], intr_mask);
32968c2ecf20Sopenharmony_ci
32978c2ecf20Sopenharmony_ci	/* Enable i/o clamp_n for autonomous mode */
32988c2ecf20Sopenharmony_ci	if (pcs_misc)
32998c2ecf20Sopenharmony_ci		qphy_clrbits(pcs_misc, QPHY_V3_PCS_MISC_CLAMP_ENABLE, CLAMP_EN);
33008c2ecf20Sopenharmony_ci}
33018c2ecf20Sopenharmony_ci
33028c2ecf20Sopenharmony_cistatic void qcom_qmp_phy_disable_autonomous_mode(struct qmp_phy *qphy)
33038c2ecf20Sopenharmony_ci{
33048c2ecf20Sopenharmony_ci	const struct qmp_phy_cfg *cfg = qphy->cfg;
33058c2ecf20Sopenharmony_ci	void __iomem *pcs = qphy->pcs;
33068c2ecf20Sopenharmony_ci	void __iomem *pcs_misc = qphy->pcs_misc;
33078c2ecf20Sopenharmony_ci
33088c2ecf20Sopenharmony_ci	/* Disable i/o clamp_n on resume for normal mode */
33098c2ecf20Sopenharmony_ci	if (pcs_misc)
33108c2ecf20Sopenharmony_ci		qphy_setbits(pcs_misc, QPHY_V3_PCS_MISC_CLAMP_ENABLE, CLAMP_EN);
33118c2ecf20Sopenharmony_ci
33128c2ecf20Sopenharmony_ci	qphy_clrbits(pcs, cfg->regs[QPHY_PCS_AUTONOMOUS_MODE_CTRL],
33138c2ecf20Sopenharmony_ci		     ARCVR_DTCT_EN | ARCVR_DTCT_EVENT_SEL | ALFPS_DTCT_EN);
33148c2ecf20Sopenharmony_ci
33158c2ecf20Sopenharmony_ci	qphy_setbits(pcs, cfg->regs[QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR], IRQ_CLEAR);
33168c2ecf20Sopenharmony_ci	/* Writing 1 followed by 0 clears the interrupt */
33178c2ecf20Sopenharmony_ci	qphy_clrbits(pcs, cfg->regs[QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR], IRQ_CLEAR);
33188c2ecf20Sopenharmony_ci}
33198c2ecf20Sopenharmony_ci
33208c2ecf20Sopenharmony_cistatic int __maybe_unused qcom_qmp_phy_runtime_suspend(struct device *dev)
33218c2ecf20Sopenharmony_ci{
33228c2ecf20Sopenharmony_ci	struct qcom_qmp *qmp = dev_get_drvdata(dev);
33238c2ecf20Sopenharmony_ci	struct qmp_phy *qphy = qmp->phys[0];
33248c2ecf20Sopenharmony_ci	const struct qmp_phy_cfg *cfg = qphy->cfg;
33258c2ecf20Sopenharmony_ci
33268c2ecf20Sopenharmony_ci	dev_vdbg(dev, "Suspending QMP phy, mode:%d\n", qphy->mode);
33278c2ecf20Sopenharmony_ci
33288c2ecf20Sopenharmony_ci	/* Supported only for USB3 PHY and luckily USB3 is the first phy */
33298c2ecf20Sopenharmony_ci	if (cfg->type != PHY_TYPE_USB3)
33308c2ecf20Sopenharmony_ci		return 0;
33318c2ecf20Sopenharmony_ci
33328c2ecf20Sopenharmony_ci	if (!qmp->init_count) {
33338c2ecf20Sopenharmony_ci		dev_vdbg(dev, "PHY not initialized, bailing out\n");
33348c2ecf20Sopenharmony_ci		return 0;
33358c2ecf20Sopenharmony_ci	}
33368c2ecf20Sopenharmony_ci
33378c2ecf20Sopenharmony_ci	qcom_qmp_phy_enable_autonomous_mode(qphy);
33388c2ecf20Sopenharmony_ci
33398c2ecf20Sopenharmony_ci	clk_disable_unprepare(qphy->pipe_clk);
33408c2ecf20Sopenharmony_ci	clk_bulk_disable_unprepare(cfg->num_clks, qmp->clks);
33418c2ecf20Sopenharmony_ci
33428c2ecf20Sopenharmony_ci	return 0;
33438c2ecf20Sopenharmony_ci}
33448c2ecf20Sopenharmony_ci
33458c2ecf20Sopenharmony_cistatic int __maybe_unused qcom_qmp_phy_runtime_resume(struct device *dev)
33468c2ecf20Sopenharmony_ci{
33478c2ecf20Sopenharmony_ci	struct qcom_qmp *qmp = dev_get_drvdata(dev);
33488c2ecf20Sopenharmony_ci	struct qmp_phy *qphy = qmp->phys[0];
33498c2ecf20Sopenharmony_ci	const struct qmp_phy_cfg *cfg = qphy->cfg;
33508c2ecf20Sopenharmony_ci	int ret = 0;
33518c2ecf20Sopenharmony_ci
33528c2ecf20Sopenharmony_ci	dev_vdbg(dev, "Resuming QMP phy, mode:%d\n", qphy->mode);
33538c2ecf20Sopenharmony_ci
33548c2ecf20Sopenharmony_ci	/* Supported only for USB3 PHY and luckily USB3 is the first phy */
33558c2ecf20Sopenharmony_ci	if (cfg->type != PHY_TYPE_USB3)
33568c2ecf20Sopenharmony_ci		return 0;
33578c2ecf20Sopenharmony_ci
33588c2ecf20Sopenharmony_ci	if (!qmp->init_count) {
33598c2ecf20Sopenharmony_ci		dev_vdbg(dev, "PHY not initialized, bailing out\n");
33608c2ecf20Sopenharmony_ci		return 0;
33618c2ecf20Sopenharmony_ci	}
33628c2ecf20Sopenharmony_ci
33638c2ecf20Sopenharmony_ci	ret = clk_bulk_prepare_enable(cfg->num_clks, qmp->clks);
33648c2ecf20Sopenharmony_ci	if (ret) {
33658c2ecf20Sopenharmony_ci		dev_err(qmp->dev, "failed to enable clks, err=%d\n", ret);
33668c2ecf20Sopenharmony_ci		return ret;
33678c2ecf20Sopenharmony_ci	}
33688c2ecf20Sopenharmony_ci
33698c2ecf20Sopenharmony_ci	ret = clk_prepare_enable(qphy->pipe_clk);
33708c2ecf20Sopenharmony_ci	if (ret) {
33718c2ecf20Sopenharmony_ci		dev_err(dev, "pipe_clk enable failed, err=%d\n", ret);
33728c2ecf20Sopenharmony_ci		clk_bulk_disable_unprepare(cfg->num_clks, qmp->clks);
33738c2ecf20Sopenharmony_ci		return ret;
33748c2ecf20Sopenharmony_ci	}
33758c2ecf20Sopenharmony_ci
33768c2ecf20Sopenharmony_ci	qcom_qmp_phy_disable_autonomous_mode(qphy);
33778c2ecf20Sopenharmony_ci
33788c2ecf20Sopenharmony_ci	return 0;
33798c2ecf20Sopenharmony_ci}
33808c2ecf20Sopenharmony_ci
33818c2ecf20Sopenharmony_cistatic int qcom_qmp_phy_vreg_init(struct device *dev, const struct qmp_phy_cfg *cfg)
33828c2ecf20Sopenharmony_ci{
33838c2ecf20Sopenharmony_ci	struct qcom_qmp *qmp = dev_get_drvdata(dev);
33848c2ecf20Sopenharmony_ci	int num = cfg->num_vregs;
33858c2ecf20Sopenharmony_ci	int i;
33868c2ecf20Sopenharmony_ci
33878c2ecf20Sopenharmony_ci	qmp->vregs = devm_kcalloc(dev, num, sizeof(*qmp->vregs), GFP_KERNEL);
33888c2ecf20Sopenharmony_ci	if (!qmp->vregs)
33898c2ecf20Sopenharmony_ci		return -ENOMEM;
33908c2ecf20Sopenharmony_ci
33918c2ecf20Sopenharmony_ci	for (i = 0; i < num; i++)
33928c2ecf20Sopenharmony_ci		qmp->vregs[i].supply = cfg->vreg_list[i];
33938c2ecf20Sopenharmony_ci
33948c2ecf20Sopenharmony_ci	return devm_regulator_bulk_get(dev, num, qmp->vregs);
33958c2ecf20Sopenharmony_ci}
33968c2ecf20Sopenharmony_ci
33978c2ecf20Sopenharmony_cistatic int qcom_qmp_phy_reset_init(struct device *dev, const struct qmp_phy_cfg *cfg)
33988c2ecf20Sopenharmony_ci{
33998c2ecf20Sopenharmony_ci	struct qcom_qmp *qmp = dev_get_drvdata(dev);
34008c2ecf20Sopenharmony_ci	int i;
34018c2ecf20Sopenharmony_ci
34028c2ecf20Sopenharmony_ci	qmp->resets = devm_kcalloc(dev, cfg->num_resets,
34038c2ecf20Sopenharmony_ci				   sizeof(*qmp->resets), GFP_KERNEL);
34048c2ecf20Sopenharmony_ci	if (!qmp->resets)
34058c2ecf20Sopenharmony_ci		return -ENOMEM;
34068c2ecf20Sopenharmony_ci
34078c2ecf20Sopenharmony_ci	for (i = 0; i < cfg->num_resets; i++) {
34088c2ecf20Sopenharmony_ci		struct reset_control *rst;
34098c2ecf20Sopenharmony_ci		const char *name = cfg->reset_list[i];
34108c2ecf20Sopenharmony_ci
34118c2ecf20Sopenharmony_ci		rst = devm_reset_control_get(dev, name);
34128c2ecf20Sopenharmony_ci		if (IS_ERR(rst)) {
34138c2ecf20Sopenharmony_ci			dev_err(dev, "failed to get %s reset\n", name);
34148c2ecf20Sopenharmony_ci			return PTR_ERR(rst);
34158c2ecf20Sopenharmony_ci		}
34168c2ecf20Sopenharmony_ci		qmp->resets[i] = rst;
34178c2ecf20Sopenharmony_ci	}
34188c2ecf20Sopenharmony_ci
34198c2ecf20Sopenharmony_ci	return 0;
34208c2ecf20Sopenharmony_ci}
34218c2ecf20Sopenharmony_ci
34228c2ecf20Sopenharmony_cistatic int qcom_qmp_phy_clk_init(struct device *dev, const struct qmp_phy_cfg *cfg)
34238c2ecf20Sopenharmony_ci{
34248c2ecf20Sopenharmony_ci	struct qcom_qmp *qmp = dev_get_drvdata(dev);
34258c2ecf20Sopenharmony_ci	int num = cfg->num_clks;
34268c2ecf20Sopenharmony_ci	int i;
34278c2ecf20Sopenharmony_ci
34288c2ecf20Sopenharmony_ci	qmp->clks = devm_kcalloc(dev, num, sizeof(*qmp->clks), GFP_KERNEL);
34298c2ecf20Sopenharmony_ci	if (!qmp->clks)
34308c2ecf20Sopenharmony_ci		return -ENOMEM;
34318c2ecf20Sopenharmony_ci
34328c2ecf20Sopenharmony_ci	for (i = 0; i < num; i++)
34338c2ecf20Sopenharmony_ci		qmp->clks[i].id = cfg->clk_list[i];
34348c2ecf20Sopenharmony_ci
34358c2ecf20Sopenharmony_ci	return devm_clk_bulk_get(dev, num, qmp->clks);
34368c2ecf20Sopenharmony_ci}
34378c2ecf20Sopenharmony_ci
34388c2ecf20Sopenharmony_cistatic void phy_clk_release_provider(void *res)
34398c2ecf20Sopenharmony_ci{
34408c2ecf20Sopenharmony_ci	of_clk_del_provider(res);
34418c2ecf20Sopenharmony_ci}
34428c2ecf20Sopenharmony_ci
34438c2ecf20Sopenharmony_ci/*
34448c2ecf20Sopenharmony_ci * Register a fixed rate pipe clock.
34458c2ecf20Sopenharmony_ci *
34468c2ecf20Sopenharmony_ci * The <s>_pipe_clksrc generated by PHY goes to the GCC that gate
34478c2ecf20Sopenharmony_ci * controls it. The <s>_pipe_clk coming out of the GCC is requested
34488c2ecf20Sopenharmony_ci * by the PHY driver for its operations.
34498c2ecf20Sopenharmony_ci * We register the <s>_pipe_clksrc here. The gcc driver takes care
34508c2ecf20Sopenharmony_ci * of assigning this <s>_pipe_clksrc as parent to <s>_pipe_clk.
34518c2ecf20Sopenharmony_ci * Below picture shows this relationship.
34528c2ecf20Sopenharmony_ci *
34538c2ecf20Sopenharmony_ci *         +---------------+
34548c2ecf20Sopenharmony_ci *         |   PHY block   |<<---------------------------------------+
34558c2ecf20Sopenharmony_ci *         |               |                                         |
34568c2ecf20Sopenharmony_ci *         |   +-------+   |                   +-----+               |
34578c2ecf20Sopenharmony_ci *   I/P---^-->|  PLL  |---^--->pipe_clksrc--->| GCC |--->pipe_clk---+
34588c2ecf20Sopenharmony_ci *    clk  |   +-------+   |                   +-----+
34598c2ecf20Sopenharmony_ci *         +---------------+
34608c2ecf20Sopenharmony_ci */
34618c2ecf20Sopenharmony_cistatic int phy_pipe_clk_register(struct qcom_qmp *qmp, struct device_node *np)
34628c2ecf20Sopenharmony_ci{
34638c2ecf20Sopenharmony_ci	struct clk_fixed_rate *fixed;
34648c2ecf20Sopenharmony_ci	struct clk_init_data init = { };
34658c2ecf20Sopenharmony_ci	int ret;
34668c2ecf20Sopenharmony_ci
34678c2ecf20Sopenharmony_ci	ret = of_property_read_string(np, "clock-output-names", &init.name);
34688c2ecf20Sopenharmony_ci	if (ret) {
34698c2ecf20Sopenharmony_ci		dev_err(qmp->dev, "%pOFn: No clock-output-names\n", np);
34708c2ecf20Sopenharmony_ci		return ret;
34718c2ecf20Sopenharmony_ci	}
34728c2ecf20Sopenharmony_ci
34738c2ecf20Sopenharmony_ci	fixed = devm_kzalloc(qmp->dev, sizeof(*fixed), GFP_KERNEL);
34748c2ecf20Sopenharmony_ci	if (!fixed)
34758c2ecf20Sopenharmony_ci		return -ENOMEM;
34768c2ecf20Sopenharmony_ci
34778c2ecf20Sopenharmony_ci	init.ops = &clk_fixed_rate_ops;
34788c2ecf20Sopenharmony_ci
34798c2ecf20Sopenharmony_ci	/* controllers using QMP phys use 125MHz pipe clock interface */
34808c2ecf20Sopenharmony_ci	fixed->fixed_rate = 125000000;
34818c2ecf20Sopenharmony_ci	fixed->hw.init = &init;
34828c2ecf20Sopenharmony_ci
34838c2ecf20Sopenharmony_ci	ret = devm_clk_hw_register(qmp->dev, &fixed->hw);
34848c2ecf20Sopenharmony_ci	if (ret)
34858c2ecf20Sopenharmony_ci		return ret;
34868c2ecf20Sopenharmony_ci
34878c2ecf20Sopenharmony_ci	ret = of_clk_add_hw_provider(np, of_clk_hw_simple_get, &fixed->hw);
34888c2ecf20Sopenharmony_ci	if (ret)
34898c2ecf20Sopenharmony_ci		return ret;
34908c2ecf20Sopenharmony_ci
34918c2ecf20Sopenharmony_ci	/*
34928c2ecf20Sopenharmony_ci	 * Roll a devm action because the clock provider is the child node, but
34938c2ecf20Sopenharmony_ci	 * the child node is not actually a device.
34948c2ecf20Sopenharmony_ci	 */
34958c2ecf20Sopenharmony_ci	ret = devm_add_action(qmp->dev, phy_clk_release_provider, np);
34968c2ecf20Sopenharmony_ci	if (ret)
34978c2ecf20Sopenharmony_ci		phy_clk_release_provider(np);
34988c2ecf20Sopenharmony_ci
34998c2ecf20Sopenharmony_ci	return ret;
35008c2ecf20Sopenharmony_ci}
35018c2ecf20Sopenharmony_ci
35028c2ecf20Sopenharmony_ci/*
35038c2ecf20Sopenharmony_ci * Display Port PLL driver block diagram for branch clocks
35048c2ecf20Sopenharmony_ci *
35058c2ecf20Sopenharmony_ci *              +------------------------------+
35068c2ecf20Sopenharmony_ci *              |         DP_VCO_CLK           |
35078c2ecf20Sopenharmony_ci *              |                              |
35088c2ecf20Sopenharmony_ci *              |    +-------------------+     |
35098c2ecf20Sopenharmony_ci *              |    |   (DP PLL/VCO)    |     |
35108c2ecf20Sopenharmony_ci *              |    +---------+---------+     |
35118c2ecf20Sopenharmony_ci *              |              v               |
35128c2ecf20Sopenharmony_ci *              |   +----------+-----------+   |
35138c2ecf20Sopenharmony_ci *              |   | hsclk_divsel_clk_src |   |
35148c2ecf20Sopenharmony_ci *              |   +----------+-----------+   |
35158c2ecf20Sopenharmony_ci *              +------------------------------+
35168c2ecf20Sopenharmony_ci *                              |
35178c2ecf20Sopenharmony_ci *          +---------<---------v------------>----------+
35188c2ecf20Sopenharmony_ci *          |                                           |
35198c2ecf20Sopenharmony_ci * +--------v----------------+                          |
35208c2ecf20Sopenharmony_ci * |    dp_phy_pll_link_clk  |                          |
35218c2ecf20Sopenharmony_ci * |     link_clk            |                          |
35228c2ecf20Sopenharmony_ci * +--------+----------------+                          |
35238c2ecf20Sopenharmony_ci *          |                                           |
35248c2ecf20Sopenharmony_ci *          |                                           |
35258c2ecf20Sopenharmony_ci *          v                                           v
35268c2ecf20Sopenharmony_ci * Input to DISPCC block                                |
35278c2ecf20Sopenharmony_ci * for link clk, crypto clk                             |
35288c2ecf20Sopenharmony_ci * and interface clock                                  |
35298c2ecf20Sopenharmony_ci *                                                      |
35308c2ecf20Sopenharmony_ci *                                                      |
35318c2ecf20Sopenharmony_ci *      +--------<------------+-----------------+---<---+
35328c2ecf20Sopenharmony_ci *      |                     |                 |
35338c2ecf20Sopenharmony_ci * +----v---------+  +--------v-----+  +--------v------+
35348c2ecf20Sopenharmony_ci * | vco_divided  |  | vco_divided  |  | vco_divided   |
35358c2ecf20Sopenharmony_ci * |    _clk_src  |  |    _clk_src  |  |    _clk_src   |
35368c2ecf20Sopenharmony_ci * |              |  |              |  |               |
35378c2ecf20Sopenharmony_ci * |divsel_six    |  |  divsel_two  |  |  divsel_four  |
35388c2ecf20Sopenharmony_ci * +-------+------+  +-----+--------+  +--------+------+
35398c2ecf20Sopenharmony_ci *         |                 |                  |
35408c2ecf20Sopenharmony_ci *         v---->----------v-------------<------v
35418c2ecf20Sopenharmony_ci *                         |
35428c2ecf20Sopenharmony_ci *              +----------+-----------------+
35438c2ecf20Sopenharmony_ci *              |   dp_phy_pll_vco_div_clk   |
35448c2ecf20Sopenharmony_ci *              +---------+------------------+
35458c2ecf20Sopenharmony_ci *                        |
35468c2ecf20Sopenharmony_ci *                        v
35478c2ecf20Sopenharmony_ci *              Input to DISPCC block
35488c2ecf20Sopenharmony_ci *              for DP pixel clock
35498c2ecf20Sopenharmony_ci *
35508c2ecf20Sopenharmony_ci */
35518c2ecf20Sopenharmony_cistatic int qcom_qmp_dp_pixel_clk_determine_rate(struct clk_hw *hw,
35528c2ecf20Sopenharmony_ci						struct clk_rate_request *req)
35538c2ecf20Sopenharmony_ci{
35548c2ecf20Sopenharmony_ci	switch (req->rate) {
35558c2ecf20Sopenharmony_ci	case 1620000000UL / 2:
35568c2ecf20Sopenharmony_ci	case 2700000000UL / 2:
35578c2ecf20Sopenharmony_ci	/* 5.4 and 8.1 GHz are same link rate as 2.7GHz, i.e. div 4 and div 6 */
35588c2ecf20Sopenharmony_ci		return 0;
35598c2ecf20Sopenharmony_ci	default:
35608c2ecf20Sopenharmony_ci		return -EINVAL;
35618c2ecf20Sopenharmony_ci	}
35628c2ecf20Sopenharmony_ci}
35638c2ecf20Sopenharmony_ci
35648c2ecf20Sopenharmony_cistatic unsigned long
35658c2ecf20Sopenharmony_ciqcom_qmp_dp_pixel_clk_recalc_rate(struct clk_hw *hw, unsigned long parent_rate)
35668c2ecf20Sopenharmony_ci{
35678c2ecf20Sopenharmony_ci	const struct qmp_phy_dp_clks *dp_clks;
35688c2ecf20Sopenharmony_ci	const struct qmp_phy *qphy;
35698c2ecf20Sopenharmony_ci	const struct phy_configure_opts_dp *dp_opts;
35708c2ecf20Sopenharmony_ci
35718c2ecf20Sopenharmony_ci	dp_clks = container_of(hw, struct qmp_phy_dp_clks, dp_pixel_hw);
35728c2ecf20Sopenharmony_ci	qphy = dp_clks->qphy;
35738c2ecf20Sopenharmony_ci	dp_opts = &qphy->dp_opts;
35748c2ecf20Sopenharmony_ci
35758c2ecf20Sopenharmony_ci	switch (dp_opts->link_rate) {
35768c2ecf20Sopenharmony_ci	case 1620:
35778c2ecf20Sopenharmony_ci		return 1620000000UL / 2;
35788c2ecf20Sopenharmony_ci	case 2700:
35798c2ecf20Sopenharmony_ci		return 2700000000UL / 2;
35808c2ecf20Sopenharmony_ci	case 5400:
35818c2ecf20Sopenharmony_ci		return 5400000000UL / 4;
35828c2ecf20Sopenharmony_ci	case 8100:
35838c2ecf20Sopenharmony_ci		return 8100000000UL / 6;
35848c2ecf20Sopenharmony_ci	default:
35858c2ecf20Sopenharmony_ci		return 0;
35868c2ecf20Sopenharmony_ci	}
35878c2ecf20Sopenharmony_ci}
35888c2ecf20Sopenharmony_ci
35898c2ecf20Sopenharmony_cistatic const struct clk_ops qcom_qmp_dp_pixel_clk_ops = {
35908c2ecf20Sopenharmony_ci	.determine_rate = qcom_qmp_dp_pixel_clk_determine_rate,
35918c2ecf20Sopenharmony_ci	.recalc_rate = qcom_qmp_dp_pixel_clk_recalc_rate,
35928c2ecf20Sopenharmony_ci};
35938c2ecf20Sopenharmony_ci
35948c2ecf20Sopenharmony_cistatic int qcom_qmp_dp_link_clk_determine_rate(struct clk_hw *hw,
35958c2ecf20Sopenharmony_ci					       struct clk_rate_request *req)
35968c2ecf20Sopenharmony_ci{
35978c2ecf20Sopenharmony_ci	switch (req->rate) {
35988c2ecf20Sopenharmony_ci	case 162000000:
35998c2ecf20Sopenharmony_ci	case 270000000:
36008c2ecf20Sopenharmony_ci	case 540000000:
36018c2ecf20Sopenharmony_ci	case 810000000:
36028c2ecf20Sopenharmony_ci		return 0;
36038c2ecf20Sopenharmony_ci	default:
36048c2ecf20Sopenharmony_ci		return -EINVAL;
36058c2ecf20Sopenharmony_ci	}
36068c2ecf20Sopenharmony_ci}
36078c2ecf20Sopenharmony_ci
36088c2ecf20Sopenharmony_cistatic unsigned long
36098c2ecf20Sopenharmony_ciqcom_qmp_dp_link_clk_recalc_rate(struct clk_hw *hw, unsigned long parent_rate)
36108c2ecf20Sopenharmony_ci{
36118c2ecf20Sopenharmony_ci	const struct qmp_phy_dp_clks *dp_clks;
36128c2ecf20Sopenharmony_ci	const struct qmp_phy *qphy;
36138c2ecf20Sopenharmony_ci	const struct phy_configure_opts_dp *dp_opts;
36148c2ecf20Sopenharmony_ci
36158c2ecf20Sopenharmony_ci	dp_clks = container_of(hw, struct qmp_phy_dp_clks, dp_link_hw);
36168c2ecf20Sopenharmony_ci	qphy = dp_clks->qphy;
36178c2ecf20Sopenharmony_ci	dp_opts = &qphy->dp_opts;
36188c2ecf20Sopenharmony_ci
36198c2ecf20Sopenharmony_ci	switch (dp_opts->link_rate) {
36208c2ecf20Sopenharmony_ci	case 1620:
36218c2ecf20Sopenharmony_ci	case 2700:
36228c2ecf20Sopenharmony_ci	case 5400:
36238c2ecf20Sopenharmony_ci	case 8100:
36248c2ecf20Sopenharmony_ci		return dp_opts->link_rate * 100000;
36258c2ecf20Sopenharmony_ci	default:
36268c2ecf20Sopenharmony_ci		return 0;
36278c2ecf20Sopenharmony_ci	}
36288c2ecf20Sopenharmony_ci}
36298c2ecf20Sopenharmony_ci
36308c2ecf20Sopenharmony_cistatic const struct clk_ops qcom_qmp_dp_link_clk_ops = {
36318c2ecf20Sopenharmony_ci	.determine_rate = qcom_qmp_dp_link_clk_determine_rate,
36328c2ecf20Sopenharmony_ci	.recalc_rate = qcom_qmp_dp_link_clk_recalc_rate,
36338c2ecf20Sopenharmony_ci};
36348c2ecf20Sopenharmony_ci
36358c2ecf20Sopenharmony_cistatic struct clk_hw *
36368c2ecf20Sopenharmony_ciqcom_qmp_dp_clks_hw_get(struct of_phandle_args *clkspec, void *data)
36378c2ecf20Sopenharmony_ci{
36388c2ecf20Sopenharmony_ci	struct qmp_phy_dp_clks *dp_clks = data;
36398c2ecf20Sopenharmony_ci	unsigned int idx = clkspec->args[0];
36408c2ecf20Sopenharmony_ci
36418c2ecf20Sopenharmony_ci	if (idx >= 2) {
36428c2ecf20Sopenharmony_ci		pr_err("%s: invalid index %u\n", __func__, idx);
36438c2ecf20Sopenharmony_ci		return ERR_PTR(-EINVAL);
36448c2ecf20Sopenharmony_ci	}
36458c2ecf20Sopenharmony_ci
36468c2ecf20Sopenharmony_ci	if (idx == 0)
36478c2ecf20Sopenharmony_ci		return &dp_clks->dp_link_hw;
36488c2ecf20Sopenharmony_ci
36498c2ecf20Sopenharmony_ci	return &dp_clks->dp_pixel_hw;
36508c2ecf20Sopenharmony_ci}
36518c2ecf20Sopenharmony_ci
36528c2ecf20Sopenharmony_cistatic int phy_dp_clks_register(struct qcom_qmp *qmp, struct qmp_phy *qphy,
36538c2ecf20Sopenharmony_ci				struct device_node *np)
36548c2ecf20Sopenharmony_ci{
36558c2ecf20Sopenharmony_ci	struct clk_init_data init = { };
36568c2ecf20Sopenharmony_ci	struct qmp_phy_dp_clks *dp_clks;
36578c2ecf20Sopenharmony_ci	int ret;
36588c2ecf20Sopenharmony_ci
36598c2ecf20Sopenharmony_ci	dp_clks = devm_kzalloc(qmp->dev, sizeof(*dp_clks), GFP_KERNEL);
36608c2ecf20Sopenharmony_ci	if (!dp_clks)
36618c2ecf20Sopenharmony_ci		return -ENOMEM;
36628c2ecf20Sopenharmony_ci
36638c2ecf20Sopenharmony_ci	dp_clks->qphy = qphy;
36648c2ecf20Sopenharmony_ci	qphy->dp_clks = dp_clks;
36658c2ecf20Sopenharmony_ci
36668c2ecf20Sopenharmony_ci	init.ops = &qcom_qmp_dp_link_clk_ops;
36678c2ecf20Sopenharmony_ci	init.name = "qmp_dp_phy_pll_link_clk";
36688c2ecf20Sopenharmony_ci	dp_clks->dp_link_hw.init = &init;
36698c2ecf20Sopenharmony_ci	ret = devm_clk_hw_register(qmp->dev, &dp_clks->dp_link_hw);
36708c2ecf20Sopenharmony_ci	if (ret)
36718c2ecf20Sopenharmony_ci		return ret;
36728c2ecf20Sopenharmony_ci
36738c2ecf20Sopenharmony_ci	init.ops = &qcom_qmp_dp_pixel_clk_ops;
36748c2ecf20Sopenharmony_ci	init.name = "qmp_dp_phy_pll_vco_div_clk";
36758c2ecf20Sopenharmony_ci	dp_clks->dp_pixel_hw.init = &init;
36768c2ecf20Sopenharmony_ci	ret = devm_clk_hw_register(qmp->dev, &dp_clks->dp_pixel_hw);
36778c2ecf20Sopenharmony_ci	if (ret)
36788c2ecf20Sopenharmony_ci		return ret;
36798c2ecf20Sopenharmony_ci
36808c2ecf20Sopenharmony_ci	ret = of_clk_add_hw_provider(np, qcom_qmp_dp_clks_hw_get, dp_clks);
36818c2ecf20Sopenharmony_ci	if (ret)
36828c2ecf20Sopenharmony_ci		return ret;
36838c2ecf20Sopenharmony_ci
36848c2ecf20Sopenharmony_ci	/*
36858c2ecf20Sopenharmony_ci	 * Roll a devm action because the clock provider is the child node, but
36868c2ecf20Sopenharmony_ci	 * the child node is not actually a device.
36878c2ecf20Sopenharmony_ci	 */
36888c2ecf20Sopenharmony_ci	ret = devm_add_action(qmp->dev, phy_clk_release_provider, np);
36898c2ecf20Sopenharmony_ci	if (ret)
36908c2ecf20Sopenharmony_ci		phy_clk_release_provider(np);
36918c2ecf20Sopenharmony_ci
36928c2ecf20Sopenharmony_ci	return ret;
36938c2ecf20Sopenharmony_ci}
36948c2ecf20Sopenharmony_ci
36958c2ecf20Sopenharmony_cistatic const struct phy_ops qcom_qmp_phy_gen_ops = {
36968c2ecf20Sopenharmony_ci	.init		= qcom_qmp_phy_enable,
36978c2ecf20Sopenharmony_ci	.exit		= qcom_qmp_phy_disable,
36988c2ecf20Sopenharmony_ci	.set_mode	= qcom_qmp_phy_set_mode,
36998c2ecf20Sopenharmony_ci	.owner		= THIS_MODULE,
37008c2ecf20Sopenharmony_ci};
37018c2ecf20Sopenharmony_ci
37028c2ecf20Sopenharmony_cistatic const struct phy_ops qcom_qmp_phy_dp_ops = {
37038c2ecf20Sopenharmony_ci	.init		= qcom_qmp_phy_init,
37048c2ecf20Sopenharmony_ci	.configure	= qcom_qmp_dp_phy_configure,
37058c2ecf20Sopenharmony_ci	.power_on	= qcom_qmp_phy_power_on,
37068c2ecf20Sopenharmony_ci	.calibrate	= qcom_qmp_dp_phy_calibrate,
37078c2ecf20Sopenharmony_ci	.power_off	= qcom_qmp_phy_power_off,
37088c2ecf20Sopenharmony_ci	.exit		= qcom_qmp_phy_exit,
37098c2ecf20Sopenharmony_ci	.set_mode	= qcom_qmp_phy_set_mode,
37108c2ecf20Sopenharmony_ci	.owner		= THIS_MODULE,
37118c2ecf20Sopenharmony_ci};
37128c2ecf20Sopenharmony_ci
37138c2ecf20Sopenharmony_cistatic const struct phy_ops qcom_qmp_pcie_ufs_ops = {
37148c2ecf20Sopenharmony_ci	.power_on	= qcom_qmp_phy_enable,
37158c2ecf20Sopenharmony_ci	.power_off	= qcom_qmp_phy_disable,
37168c2ecf20Sopenharmony_ci	.set_mode	= qcom_qmp_phy_set_mode,
37178c2ecf20Sopenharmony_ci	.owner		= THIS_MODULE,
37188c2ecf20Sopenharmony_ci};
37198c2ecf20Sopenharmony_ci
37208c2ecf20Sopenharmony_cistatic void qcom_qmp_reset_control_put(void *data)
37218c2ecf20Sopenharmony_ci{
37228c2ecf20Sopenharmony_ci	reset_control_put(data);
37238c2ecf20Sopenharmony_ci}
37248c2ecf20Sopenharmony_ci
37258c2ecf20Sopenharmony_cistatic
37268c2ecf20Sopenharmony_ciint qcom_qmp_phy_create(struct device *dev, struct device_node *np, int id,
37278c2ecf20Sopenharmony_ci			void __iomem *serdes, const struct qmp_phy_cfg *cfg)
37288c2ecf20Sopenharmony_ci{
37298c2ecf20Sopenharmony_ci	struct qcom_qmp *qmp = dev_get_drvdata(dev);
37308c2ecf20Sopenharmony_ci	struct phy *generic_phy;
37318c2ecf20Sopenharmony_ci	struct qmp_phy *qphy;
37328c2ecf20Sopenharmony_ci	const struct phy_ops *ops;
37338c2ecf20Sopenharmony_ci	char prop_name[MAX_PROP_NAME];
37348c2ecf20Sopenharmony_ci	int ret;
37358c2ecf20Sopenharmony_ci
37368c2ecf20Sopenharmony_ci	qphy = devm_kzalloc(dev, sizeof(*qphy), GFP_KERNEL);
37378c2ecf20Sopenharmony_ci	if (!qphy)
37388c2ecf20Sopenharmony_ci		return -ENOMEM;
37398c2ecf20Sopenharmony_ci
37408c2ecf20Sopenharmony_ci	qphy->cfg = cfg;
37418c2ecf20Sopenharmony_ci	qphy->serdes = serdes;
37428c2ecf20Sopenharmony_ci	/*
37438c2ecf20Sopenharmony_ci	 * Get memory resources for each phy lane:
37448c2ecf20Sopenharmony_ci	 * Resources are indexed as: tx -> 0; rx -> 1; pcs -> 2.
37458c2ecf20Sopenharmony_ci	 * For dual lane PHYs: tx2 -> 3, rx2 -> 4, pcs_misc (optional) -> 5
37468c2ecf20Sopenharmony_ci	 * For single lane PHYs: pcs_misc (optional) -> 3.
37478c2ecf20Sopenharmony_ci	 */
37488c2ecf20Sopenharmony_ci	qphy->tx = of_iomap(np, 0);
37498c2ecf20Sopenharmony_ci	if (!qphy->tx)
37508c2ecf20Sopenharmony_ci		return -ENOMEM;
37518c2ecf20Sopenharmony_ci
37528c2ecf20Sopenharmony_ci	qphy->rx = of_iomap(np, 1);
37538c2ecf20Sopenharmony_ci	if (!qphy->rx)
37548c2ecf20Sopenharmony_ci		return -ENOMEM;
37558c2ecf20Sopenharmony_ci
37568c2ecf20Sopenharmony_ci	qphy->pcs = of_iomap(np, 2);
37578c2ecf20Sopenharmony_ci	if (!qphy->pcs)
37588c2ecf20Sopenharmony_ci		return -ENOMEM;
37598c2ecf20Sopenharmony_ci
37608c2ecf20Sopenharmony_ci	/*
37618c2ecf20Sopenharmony_ci	 * If this is a dual-lane PHY, then there should be registers for the
37628c2ecf20Sopenharmony_ci	 * second lane. Some old device trees did not specify this, so fall
37638c2ecf20Sopenharmony_ci	 * back to old legacy behavior of assuming they can be reached at an
37648c2ecf20Sopenharmony_ci	 * offset from the first lane.
37658c2ecf20Sopenharmony_ci	 */
37668c2ecf20Sopenharmony_ci	if (cfg->is_dual_lane_phy) {
37678c2ecf20Sopenharmony_ci		qphy->tx2 = of_iomap(np, 3);
37688c2ecf20Sopenharmony_ci		qphy->rx2 = of_iomap(np, 4);
37698c2ecf20Sopenharmony_ci		if (!qphy->tx2 || !qphy->rx2) {
37708c2ecf20Sopenharmony_ci			dev_warn(dev,
37718c2ecf20Sopenharmony_ci				 "Underspecified device tree, falling back to legacy register regions\n");
37728c2ecf20Sopenharmony_ci
37738c2ecf20Sopenharmony_ci			/* In the old version, pcs_misc is at index 3. */
37748c2ecf20Sopenharmony_ci			qphy->pcs_misc = qphy->tx2;
37758c2ecf20Sopenharmony_ci			qphy->tx2 = qphy->tx + QMP_PHY_LEGACY_LANE_STRIDE;
37768c2ecf20Sopenharmony_ci			qphy->rx2 = qphy->rx + QMP_PHY_LEGACY_LANE_STRIDE;
37778c2ecf20Sopenharmony_ci
37788c2ecf20Sopenharmony_ci		} else {
37798c2ecf20Sopenharmony_ci			qphy->pcs_misc = of_iomap(np, 5);
37808c2ecf20Sopenharmony_ci		}
37818c2ecf20Sopenharmony_ci
37828c2ecf20Sopenharmony_ci	} else {
37838c2ecf20Sopenharmony_ci		qphy->pcs_misc = of_iomap(np, 3);
37848c2ecf20Sopenharmony_ci	}
37858c2ecf20Sopenharmony_ci
37868c2ecf20Sopenharmony_ci	if (!qphy->pcs_misc)
37878c2ecf20Sopenharmony_ci		dev_vdbg(dev, "PHY pcs_misc-reg not used\n");
37888c2ecf20Sopenharmony_ci
37898c2ecf20Sopenharmony_ci	/*
37908c2ecf20Sopenharmony_ci	 * Get PHY's Pipe clock, if any. USB3 and PCIe are PIPE3
37918c2ecf20Sopenharmony_ci	 * based phys, so they essentially have pipe clock. So,
37928c2ecf20Sopenharmony_ci	 * we return error in case phy is USB3 or PIPE type.
37938c2ecf20Sopenharmony_ci	 * Otherwise, we initialize pipe clock to NULL for
37948c2ecf20Sopenharmony_ci	 * all phys that don't need this.
37958c2ecf20Sopenharmony_ci	 */
37968c2ecf20Sopenharmony_ci	snprintf(prop_name, sizeof(prop_name), "pipe%d", id);
37978c2ecf20Sopenharmony_ci	qphy->pipe_clk = devm_get_clk_from_child(dev, np, prop_name);
37988c2ecf20Sopenharmony_ci	if (IS_ERR(qphy->pipe_clk)) {
37998c2ecf20Sopenharmony_ci		if (cfg->type == PHY_TYPE_PCIE ||
38008c2ecf20Sopenharmony_ci		    cfg->type == PHY_TYPE_USB3) {
38018c2ecf20Sopenharmony_ci			ret = PTR_ERR(qphy->pipe_clk);
38028c2ecf20Sopenharmony_ci			if (ret != -EPROBE_DEFER)
38038c2ecf20Sopenharmony_ci				dev_err(dev,
38048c2ecf20Sopenharmony_ci					"failed to get lane%d pipe_clk, %d\n",
38058c2ecf20Sopenharmony_ci					id, ret);
38068c2ecf20Sopenharmony_ci			return ret;
38078c2ecf20Sopenharmony_ci		}
38088c2ecf20Sopenharmony_ci		qphy->pipe_clk = NULL;
38098c2ecf20Sopenharmony_ci	}
38108c2ecf20Sopenharmony_ci
38118c2ecf20Sopenharmony_ci	/* Get lane reset, if any */
38128c2ecf20Sopenharmony_ci	if (cfg->has_lane_rst) {
38138c2ecf20Sopenharmony_ci		snprintf(prop_name, sizeof(prop_name), "lane%d", id);
38148c2ecf20Sopenharmony_ci		qphy->lane_rst = of_reset_control_get(np, prop_name);
38158c2ecf20Sopenharmony_ci		if (IS_ERR(qphy->lane_rst)) {
38168c2ecf20Sopenharmony_ci			dev_err(dev, "failed to get lane%d reset\n", id);
38178c2ecf20Sopenharmony_ci			return PTR_ERR(qphy->lane_rst);
38188c2ecf20Sopenharmony_ci		}
38198c2ecf20Sopenharmony_ci		ret = devm_add_action_or_reset(dev, qcom_qmp_reset_control_put,
38208c2ecf20Sopenharmony_ci					       qphy->lane_rst);
38218c2ecf20Sopenharmony_ci		if (ret)
38228c2ecf20Sopenharmony_ci			return ret;
38238c2ecf20Sopenharmony_ci	}
38248c2ecf20Sopenharmony_ci
38258c2ecf20Sopenharmony_ci	if (cfg->type == PHY_TYPE_UFS || cfg->type == PHY_TYPE_PCIE)
38268c2ecf20Sopenharmony_ci		ops = &qcom_qmp_pcie_ufs_ops;
38278c2ecf20Sopenharmony_ci	else if (cfg->type == PHY_TYPE_DP)
38288c2ecf20Sopenharmony_ci		ops = &qcom_qmp_phy_dp_ops;
38298c2ecf20Sopenharmony_ci	else
38308c2ecf20Sopenharmony_ci		ops = &qcom_qmp_phy_gen_ops;
38318c2ecf20Sopenharmony_ci
38328c2ecf20Sopenharmony_ci	generic_phy = devm_phy_create(dev, np, ops);
38338c2ecf20Sopenharmony_ci	if (IS_ERR(generic_phy)) {
38348c2ecf20Sopenharmony_ci		ret = PTR_ERR(generic_phy);
38358c2ecf20Sopenharmony_ci		dev_err(dev, "failed to create qphy %d\n", ret);
38368c2ecf20Sopenharmony_ci		return ret;
38378c2ecf20Sopenharmony_ci	}
38388c2ecf20Sopenharmony_ci
38398c2ecf20Sopenharmony_ci	qphy->phy = generic_phy;
38408c2ecf20Sopenharmony_ci	qphy->index = id;
38418c2ecf20Sopenharmony_ci	qphy->qmp = qmp;
38428c2ecf20Sopenharmony_ci	qmp->phys[id] = qphy;
38438c2ecf20Sopenharmony_ci	phy_set_drvdata(generic_phy, qphy);
38448c2ecf20Sopenharmony_ci
38458c2ecf20Sopenharmony_ci	return 0;
38468c2ecf20Sopenharmony_ci}
38478c2ecf20Sopenharmony_ci
38488c2ecf20Sopenharmony_cistatic const struct of_device_id qcom_qmp_phy_of_match_table[] = {
38498c2ecf20Sopenharmony_ci	{
38508c2ecf20Sopenharmony_ci		.compatible = "qcom,ipq8074-qmp-usb3-phy",
38518c2ecf20Sopenharmony_ci		.data = &ipq8074_usb3phy_cfg,
38528c2ecf20Sopenharmony_ci	}, {
38538c2ecf20Sopenharmony_ci		.compatible = "qcom,msm8996-qmp-pcie-phy",
38548c2ecf20Sopenharmony_ci		.data = &msm8996_pciephy_cfg,
38558c2ecf20Sopenharmony_ci	}, {
38568c2ecf20Sopenharmony_ci		.compatible = "qcom,msm8996-qmp-ufs-phy",
38578c2ecf20Sopenharmony_ci		.data = &msm8996_ufs_cfg,
38588c2ecf20Sopenharmony_ci	}, {
38598c2ecf20Sopenharmony_ci		.compatible = "qcom,msm8996-qmp-usb3-phy",
38608c2ecf20Sopenharmony_ci		.data = &msm8996_usb3phy_cfg,
38618c2ecf20Sopenharmony_ci	}, {
38628c2ecf20Sopenharmony_ci		.compatible = "qcom,msm8998-qmp-pcie-phy",
38638c2ecf20Sopenharmony_ci		.data = &msm8998_pciephy_cfg,
38648c2ecf20Sopenharmony_ci	}, {
38658c2ecf20Sopenharmony_ci		.compatible = "qcom,msm8998-qmp-ufs-phy",
38668c2ecf20Sopenharmony_ci		.data = &sdm845_ufsphy_cfg,
38678c2ecf20Sopenharmony_ci	}, {
38688c2ecf20Sopenharmony_ci		.compatible = "qcom,ipq8074-qmp-pcie-phy",
38698c2ecf20Sopenharmony_ci		.data = &ipq8074_pciephy_cfg,
38708c2ecf20Sopenharmony_ci	}, {
38718c2ecf20Sopenharmony_ci		.compatible = "qcom,sc7180-qmp-usb3-phy",
38728c2ecf20Sopenharmony_ci		.data = &sc7180_usb3phy_cfg,
38738c2ecf20Sopenharmony_ci	}, {
38748c2ecf20Sopenharmony_ci		.compatible = "qcom,sc7180-qmp-usb3-dp-phy",
38758c2ecf20Sopenharmony_ci		/* It's a combo phy */
38768c2ecf20Sopenharmony_ci	}, {
38778c2ecf20Sopenharmony_ci		.compatible = "qcom,sdm845-qhp-pcie-phy",
38788c2ecf20Sopenharmony_ci		.data = &sdm845_qhp_pciephy_cfg,
38798c2ecf20Sopenharmony_ci	}, {
38808c2ecf20Sopenharmony_ci		.compatible = "qcom,sdm845-qmp-pcie-phy",
38818c2ecf20Sopenharmony_ci		.data = &sdm845_qmp_pciephy_cfg,
38828c2ecf20Sopenharmony_ci	}, {
38838c2ecf20Sopenharmony_ci		.compatible = "qcom,sdm845-qmp-usb3-phy",
38848c2ecf20Sopenharmony_ci		.data = &qmp_v3_usb3phy_cfg,
38858c2ecf20Sopenharmony_ci	}, {
38868c2ecf20Sopenharmony_ci		.compatible = "qcom,sdm845-qmp-usb3-uni-phy",
38878c2ecf20Sopenharmony_ci		.data = &qmp_v3_usb3_uniphy_cfg,
38888c2ecf20Sopenharmony_ci	}, {
38898c2ecf20Sopenharmony_ci		.compatible = "qcom,sdm845-qmp-ufs-phy",
38908c2ecf20Sopenharmony_ci		.data = &sdm845_ufsphy_cfg,
38918c2ecf20Sopenharmony_ci	}, {
38928c2ecf20Sopenharmony_ci		.compatible = "qcom,msm8998-qmp-usb3-phy",
38938c2ecf20Sopenharmony_ci		.data = &msm8998_usb3phy_cfg,
38948c2ecf20Sopenharmony_ci	}, {
38958c2ecf20Sopenharmony_ci		.compatible = "qcom,sm8150-qmp-ufs-phy",
38968c2ecf20Sopenharmony_ci		.data = &sm8150_ufsphy_cfg,
38978c2ecf20Sopenharmony_ci	}, {
38988c2ecf20Sopenharmony_ci		.compatible = "qcom,sm8250-qmp-ufs-phy",
38998c2ecf20Sopenharmony_ci		.data = &sm8150_ufsphy_cfg,
39008c2ecf20Sopenharmony_ci	}, {
39018c2ecf20Sopenharmony_ci		.compatible = "qcom,sm8150-qmp-usb3-phy",
39028c2ecf20Sopenharmony_ci		.data = &sm8150_usb3phy_cfg,
39038c2ecf20Sopenharmony_ci	}, {
39048c2ecf20Sopenharmony_ci		.compatible = "qcom,sm8150-qmp-usb3-uni-phy",
39058c2ecf20Sopenharmony_ci		.data = &sm8150_usb3_uniphy_cfg,
39068c2ecf20Sopenharmony_ci	}, {
39078c2ecf20Sopenharmony_ci		.compatible = "qcom,sm8250-qmp-usb3-phy",
39088c2ecf20Sopenharmony_ci		.data = &sm8250_usb3phy_cfg,
39098c2ecf20Sopenharmony_ci	}, {
39108c2ecf20Sopenharmony_ci		.compatible = "qcom,sm8250-qmp-usb3-uni-phy",
39118c2ecf20Sopenharmony_ci		.data = &sm8250_usb3_uniphy_cfg,
39128c2ecf20Sopenharmony_ci	},
39138c2ecf20Sopenharmony_ci	{ },
39148c2ecf20Sopenharmony_ci};
39158c2ecf20Sopenharmony_ciMODULE_DEVICE_TABLE(of, qcom_qmp_phy_of_match_table);
39168c2ecf20Sopenharmony_ci
39178c2ecf20Sopenharmony_cistatic const struct of_device_id qcom_qmp_combo_phy_of_match_table[] = {
39188c2ecf20Sopenharmony_ci	{
39198c2ecf20Sopenharmony_ci		.compatible = "qcom,sc7180-qmp-usb3-dp-phy",
39208c2ecf20Sopenharmony_ci		.data = &sc7180_usb3dpphy_cfg,
39218c2ecf20Sopenharmony_ci	},
39228c2ecf20Sopenharmony_ci	{ }
39238c2ecf20Sopenharmony_ci};
39248c2ecf20Sopenharmony_ci
39258c2ecf20Sopenharmony_cistatic const struct dev_pm_ops qcom_qmp_phy_pm_ops = {
39268c2ecf20Sopenharmony_ci	SET_RUNTIME_PM_OPS(qcom_qmp_phy_runtime_suspend,
39278c2ecf20Sopenharmony_ci			   qcom_qmp_phy_runtime_resume, NULL)
39288c2ecf20Sopenharmony_ci};
39298c2ecf20Sopenharmony_ci
39308c2ecf20Sopenharmony_cistatic int qcom_qmp_phy_probe(struct platform_device *pdev)
39318c2ecf20Sopenharmony_ci{
39328c2ecf20Sopenharmony_ci	struct qcom_qmp *qmp;
39338c2ecf20Sopenharmony_ci	struct device *dev = &pdev->dev;
39348c2ecf20Sopenharmony_ci	struct device_node *child;
39358c2ecf20Sopenharmony_ci	struct phy_provider *phy_provider;
39368c2ecf20Sopenharmony_ci	void __iomem *serdes;
39378c2ecf20Sopenharmony_ci	void __iomem *usb_serdes;
39388c2ecf20Sopenharmony_ci	void __iomem *dp_serdes = NULL;
39398c2ecf20Sopenharmony_ci	const struct qmp_phy_combo_cfg *combo_cfg = NULL;
39408c2ecf20Sopenharmony_ci	const struct qmp_phy_cfg *cfg = NULL;
39418c2ecf20Sopenharmony_ci	const struct qmp_phy_cfg *usb_cfg = NULL;
39428c2ecf20Sopenharmony_ci	const struct qmp_phy_cfg *dp_cfg = NULL;
39438c2ecf20Sopenharmony_ci	int num, id, expected_phys;
39448c2ecf20Sopenharmony_ci	int ret;
39458c2ecf20Sopenharmony_ci
39468c2ecf20Sopenharmony_ci	qmp = devm_kzalloc(dev, sizeof(*qmp), GFP_KERNEL);
39478c2ecf20Sopenharmony_ci	if (!qmp)
39488c2ecf20Sopenharmony_ci		return -ENOMEM;
39498c2ecf20Sopenharmony_ci
39508c2ecf20Sopenharmony_ci	qmp->dev = dev;
39518c2ecf20Sopenharmony_ci	dev_set_drvdata(dev, qmp);
39528c2ecf20Sopenharmony_ci
39538c2ecf20Sopenharmony_ci	/* Get the specific init parameters of QMP phy */
39548c2ecf20Sopenharmony_ci	cfg = of_device_get_match_data(dev);
39558c2ecf20Sopenharmony_ci	if (!cfg) {
39568c2ecf20Sopenharmony_ci		const struct of_device_id *match;
39578c2ecf20Sopenharmony_ci
39588c2ecf20Sopenharmony_ci		match = of_match_device(qcom_qmp_combo_phy_of_match_table, dev);
39598c2ecf20Sopenharmony_ci		if (!match)
39608c2ecf20Sopenharmony_ci			return -EINVAL;
39618c2ecf20Sopenharmony_ci
39628c2ecf20Sopenharmony_ci		combo_cfg = match->data;
39638c2ecf20Sopenharmony_ci		if (!combo_cfg)
39648c2ecf20Sopenharmony_ci			return -EINVAL;
39658c2ecf20Sopenharmony_ci
39668c2ecf20Sopenharmony_ci		usb_cfg = combo_cfg->usb_cfg;
39678c2ecf20Sopenharmony_ci		cfg = usb_cfg; /* Setup clks and regulators */
39688c2ecf20Sopenharmony_ci	}
39698c2ecf20Sopenharmony_ci
39708c2ecf20Sopenharmony_ci	/* per PHY serdes; usually located at base address */
39718c2ecf20Sopenharmony_ci	usb_serdes = serdes = devm_platform_ioremap_resource(pdev, 0);
39728c2ecf20Sopenharmony_ci	if (IS_ERR(serdes))
39738c2ecf20Sopenharmony_ci		return PTR_ERR(serdes);
39748c2ecf20Sopenharmony_ci
39758c2ecf20Sopenharmony_ci	/* per PHY dp_com; if PHY has dp_com control block */
39768c2ecf20Sopenharmony_ci	if (combo_cfg || cfg->has_phy_dp_com_ctrl) {
39778c2ecf20Sopenharmony_ci		qmp->dp_com = devm_platform_ioremap_resource(pdev, 1);
39788c2ecf20Sopenharmony_ci		if (IS_ERR(qmp->dp_com))
39798c2ecf20Sopenharmony_ci			return PTR_ERR(qmp->dp_com);
39808c2ecf20Sopenharmony_ci	}
39818c2ecf20Sopenharmony_ci
39828c2ecf20Sopenharmony_ci	if (combo_cfg) {
39838c2ecf20Sopenharmony_ci		/* Only two serdes for combo PHY */
39848c2ecf20Sopenharmony_ci		dp_serdes = devm_platform_ioremap_resource(pdev, 2);
39858c2ecf20Sopenharmony_ci		if (IS_ERR(dp_serdes))
39868c2ecf20Sopenharmony_ci			return PTR_ERR(dp_serdes);
39878c2ecf20Sopenharmony_ci
39888c2ecf20Sopenharmony_ci		dp_cfg = combo_cfg->dp_cfg;
39898c2ecf20Sopenharmony_ci		expected_phys = 2;
39908c2ecf20Sopenharmony_ci	} else {
39918c2ecf20Sopenharmony_ci		expected_phys = cfg->nlanes;
39928c2ecf20Sopenharmony_ci	}
39938c2ecf20Sopenharmony_ci
39948c2ecf20Sopenharmony_ci	mutex_init(&qmp->phy_mutex);
39958c2ecf20Sopenharmony_ci
39968c2ecf20Sopenharmony_ci	ret = qcom_qmp_phy_clk_init(dev, cfg);
39978c2ecf20Sopenharmony_ci	if (ret)
39988c2ecf20Sopenharmony_ci		return ret;
39998c2ecf20Sopenharmony_ci
40008c2ecf20Sopenharmony_ci	ret = qcom_qmp_phy_reset_init(dev, cfg);
40018c2ecf20Sopenharmony_ci	if (ret)
40028c2ecf20Sopenharmony_ci		return ret;
40038c2ecf20Sopenharmony_ci
40048c2ecf20Sopenharmony_ci	ret = qcom_qmp_phy_vreg_init(dev, cfg);
40058c2ecf20Sopenharmony_ci	if (ret) {
40068c2ecf20Sopenharmony_ci		if (ret != -EPROBE_DEFER)
40078c2ecf20Sopenharmony_ci			dev_err(dev, "failed to get regulator supplies: %d\n",
40088c2ecf20Sopenharmony_ci				ret);
40098c2ecf20Sopenharmony_ci		return ret;
40108c2ecf20Sopenharmony_ci	}
40118c2ecf20Sopenharmony_ci
40128c2ecf20Sopenharmony_ci	num = of_get_available_child_count(dev->of_node);
40138c2ecf20Sopenharmony_ci	/* do we have a rogue child node ? */
40148c2ecf20Sopenharmony_ci	if (num > expected_phys)
40158c2ecf20Sopenharmony_ci		return -EINVAL;
40168c2ecf20Sopenharmony_ci
40178c2ecf20Sopenharmony_ci	qmp->phys = devm_kcalloc(dev, num, sizeof(*qmp->phys), GFP_KERNEL);
40188c2ecf20Sopenharmony_ci	if (!qmp->phys)
40198c2ecf20Sopenharmony_ci		return -ENOMEM;
40208c2ecf20Sopenharmony_ci
40218c2ecf20Sopenharmony_ci	pm_runtime_set_active(dev);
40228c2ecf20Sopenharmony_ci	pm_runtime_enable(dev);
40238c2ecf20Sopenharmony_ci	/*
40248c2ecf20Sopenharmony_ci	 * Prevent runtime pm from being ON by default. Users can enable
40258c2ecf20Sopenharmony_ci	 * it using power/control in sysfs.
40268c2ecf20Sopenharmony_ci	 */
40278c2ecf20Sopenharmony_ci	pm_runtime_forbid(dev);
40288c2ecf20Sopenharmony_ci
40298c2ecf20Sopenharmony_ci	id = 0;
40308c2ecf20Sopenharmony_ci	for_each_available_child_of_node(dev->of_node, child) {
40318c2ecf20Sopenharmony_ci		if (of_node_name_eq(child, "dp-phy")) {
40328c2ecf20Sopenharmony_ci			cfg = dp_cfg;
40338c2ecf20Sopenharmony_ci			serdes = dp_serdes;
40348c2ecf20Sopenharmony_ci		} else if (of_node_name_eq(child, "usb3-phy")) {
40358c2ecf20Sopenharmony_ci			cfg = usb_cfg;
40368c2ecf20Sopenharmony_ci			serdes = usb_serdes;
40378c2ecf20Sopenharmony_ci		}
40388c2ecf20Sopenharmony_ci
40398c2ecf20Sopenharmony_ci		/* Create per-lane phy */
40408c2ecf20Sopenharmony_ci		ret = qcom_qmp_phy_create(dev, child, id, serdes, cfg);
40418c2ecf20Sopenharmony_ci		if (ret) {
40428c2ecf20Sopenharmony_ci			dev_err(dev, "failed to create lane%d phy, %d\n",
40438c2ecf20Sopenharmony_ci				id, ret);
40448c2ecf20Sopenharmony_ci			goto err_node_put;
40458c2ecf20Sopenharmony_ci		}
40468c2ecf20Sopenharmony_ci
40478c2ecf20Sopenharmony_ci		/*
40488c2ecf20Sopenharmony_ci		 * Register the pipe clock provided by phy.
40498c2ecf20Sopenharmony_ci		 * See function description to see details of this pipe clock.
40508c2ecf20Sopenharmony_ci		 */
40518c2ecf20Sopenharmony_ci		if (cfg->type == PHY_TYPE_USB3 || cfg->type == PHY_TYPE_PCIE) {
40528c2ecf20Sopenharmony_ci			ret = phy_pipe_clk_register(qmp, child);
40538c2ecf20Sopenharmony_ci			if (ret) {
40548c2ecf20Sopenharmony_ci				dev_err(qmp->dev,
40558c2ecf20Sopenharmony_ci					"failed to register pipe clock source\n");
40568c2ecf20Sopenharmony_ci				goto err_node_put;
40578c2ecf20Sopenharmony_ci			}
40588c2ecf20Sopenharmony_ci		} else if (cfg->type == PHY_TYPE_DP) {
40598c2ecf20Sopenharmony_ci			ret = phy_dp_clks_register(qmp, qmp->phys[id], child);
40608c2ecf20Sopenharmony_ci			if (ret) {
40618c2ecf20Sopenharmony_ci				dev_err(qmp->dev,
40628c2ecf20Sopenharmony_ci					"failed to register DP clock source\n");
40638c2ecf20Sopenharmony_ci				goto err_node_put;
40648c2ecf20Sopenharmony_ci			}
40658c2ecf20Sopenharmony_ci		}
40668c2ecf20Sopenharmony_ci		id++;
40678c2ecf20Sopenharmony_ci	}
40688c2ecf20Sopenharmony_ci
40698c2ecf20Sopenharmony_ci	phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
40708c2ecf20Sopenharmony_ci	if (!IS_ERR(phy_provider))
40718c2ecf20Sopenharmony_ci		dev_info(dev, "Registered Qcom-QMP phy\n");
40728c2ecf20Sopenharmony_ci	else
40738c2ecf20Sopenharmony_ci		pm_runtime_disable(dev);
40748c2ecf20Sopenharmony_ci
40758c2ecf20Sopenharmony_ci	return PTR_ERR_OR_ZERO(phy_provider);
40768c2ecf20Sopenharmony_ci
40778c2ecf20Sopenharmony_cierr_node_put:
40788c2ecf20Sopenharmony_ci	pm_runtime_disable(dev);
40798c2ecf20Sopenharmony_ci	of_node_put(child);
40808c2ecf20Sopenharmony_ci	return ret;
40818c2ecf20Sopenharmony_ci}
40828c2ecf20Sopenharmony_ci
40838c2ecf20Sopenharmony_cistatic struct platform_driver qcom_qmp_phy_driver = {
40848c2ecf20Sopenharmony_ci	.probe		= qcom_qmp_phy_probe,
40858c2ecf20Sopenharmony_ci	.driver = {
40868c2ecf20Sopenharmony_ci		.name	= "qcom-qmp-phy",
40878c2ecf20Sopenharmony_ci		.pm	= &qcom_qmp_phy_pm_ops,
40888c2ecf20Sopenharmony_ci		.of_match_table = qcom_qmp_phy_of_match_table,
40898c2ecf20Sopenharmony_ci	},
40908c2ecf20Sopenharmony_ci};
40918c2ecf20Sopenharmony_ci
40928c2ecf20Sopenharmony_cimodule_platform_driver(qcom_qmp_phy_driver);
40938c2ecf20Sopenharmony_ci
40948c2ecf20Sopenharmony_ciMODULE_AUTHOR("Vivek Gautam <vivek.gautam@codeaurora.org>");
40958c2ecf20Sopenharmony_ciMODULE_DESCRIPTION("Qualcomm QMP PHY driver");
40968c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL v2");
4097