Manu Gautam | 3405bd7 | 2018-01-16 16:27:12 +0530 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2017, The Linux Foundation. All rights reserved. |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <linux/clk.h> |
| 7 | #include <linux/clk-provider.h> |
| 8 | #include <linux/delay.h> |
| 9 | #include <linux/err.h> |
| 10 | #include <linux/io.h> |
| 11 | #include <linux/iopoll.h> |
| 12 | #include <linux/kernel.h> |
| 13 | #include <linux/module.h> |
| 14 | #include <linux/of.h> |
| 15 | #include <linux/of_device.h> |
| 16 | #include <linux/of_address.h> |
| 17 | #include <linux/phy/phy.h> |
| 18 | #include <linux/platform_device.h> |
| 19 | #include <linux/regulator/consumer.h> |
| 20 | #include <linux/reset.h> |
| 21 | #include <linux/slab.h> |
| 22 | |
| 23 | #include <dt-bindings/phy/phy.h> |
| 24 | |
Manu Gautam | e224861 | 2018-01-16 16:27:05 +0530 | [diff] [blame] | 25 | #include "phy-qcom-qmp.h" |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 26 | |
| 27 | /* QPHY_SW_RESET bit */ |
| 28 | #define SW_RESET BIT(0) |
| 29 | /* QPHY_POWER_DOWN_CONTROL */ |
| 30 | #define SW_PWRDN BIT(0) |
| 31 | #define REFCLK_DRV_DSBL BIT(1) |
| 32 | /* QPHY_START_CONTROL bits */ |
| 33 | #define SERDES_START BIT(0) |
| 34 | #define PCS_START BIT(1) |
| 35 | #define PLL_READY_GATE_EN BIT(3) |
| 36 | /* QPHY_PCS_STATUS bit */ |
| 37 | #define PHYSTATUS BIT(6) |
Bjorn Andersson | 14ced7e | 2019-08-05 17:42:56 -0700 | [diff] [blame] | 38 | /* QPHY_PCS_READY_STATUS & QPHY_COM_PCS_READY_STATUS bit */ |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 39 | #define PCS_READY BIT(0) |
| 40 | |
Manu Gautam | efb05a5 | 2018-01-16 16:27:08 +0530 | [diff] [blame] | 41 | /* QPHY_V3_DP_COM_RESET_OVRD_CTRL register bits */ |
| 42 | /* DP PHY soft reset */ |
| 43 | #define SW_DPPHY_RESET BIT(0) |
| 44 | /* mux to select DP PHY reset control, 0:HW control, 1: software reset */ |
| 45 | #define SW_DPPHY_RESET_MUX BIT(1) |
| 46 | /* USB3 PHY soft reset */ |
| 47 | #define SW_USB3PHY_RESET BIT(2) |
| 48 | /* mux to select USB3 PHY reset control, 0:HW control, 1: software reset */ |
| 49 | #define SW_USB3PHY_RESET_MUX BIT(3) |
| 50 | |
| 51 | /* QPHY_V3_DP_COM_PHY_MODE_CTRL register bits */ |
| 52 | #define USB3_MODE BIT(0) /* enables USB3 mode */ |
| 53 | #define DP_MODE BIT(1) /* enables DP mode */ |
| 54 | |
Manu Gautam | ac0d239 | 2018-01-16 16:27:11 +0530 | [diff] [blame] | 55 | /* QPHY_PCS_AUTONOMOUS_MODE_CTRL register bits */ |
| 56 | #define ARCVR_DTCT_EN BIT(0) |
| 57 | #define ALFPS_DTCT_EN BIT(1) |
| 58 | #define ARCVR_DTCT_EVENT_SEL BIT(4) |
| 59 | |
| 60 | /* QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR register bits */ |
| 61 | #define IRQ_CLEAR BIT(0) |
| 62 | |
| 63 | /* QPHY_PCS_LFPS_RXTERM_IRQ_STATUS register bits */ |
| 64 | #define RCVR_DETECT BIT(0) |
| 65 | |
| 66 | /* QPHY_V3_PCS_MISC_CLAMP_ENABLE register bits */ |
| 67 | #define CLAMP_EN BIT(0) /* enables i/o clamp_n */ |
Manu Gautam | efb05a5 | 2018-01-16 16:27:08 +0530 | [diff] [blame] | 68 | |
Bjorn Andersson | cd217ee | 2019-12-20 15:47:15 +0530 | [diff] [blame] | 69 | #define PHY_INIT_COMPLETE_TIMEOUT 10000 |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 70 | #define POWER_DOWN_DELAY_US_MIN 10 |
| 71 | #define POWER_DOWN_DELAY_US_MAX 11 |
| 72 | |
| 73 | #define MAX_PROP_NAME 32 |
| 74 | |
Evan Green | 5e17b95 | 2018-12-10 11:28:23 -0800 | [diff] [blame] | 75 | /* Define the assumed distance between lanes for underspecified device trees. */ |
| 76 | #define QMP_PHY_LEGACY_LANE_STRIDE 0x400 |
| 77 | |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 78 | struct qmp_phy_init_tbl { |
| 79 | unsigned int offset; |
| 80 | unsigned int val; |
| 81 | /* |
| 82 | * register part of layout ? |
| 83 | * if yes, then offset gives index in the reg-layout |
| 84 | */ |
| 85 | int in_layout; |
| 86 | }; |
| 87 | |
| 88 | #define QMP_PHY_INIT_CFG(o, v) \ |
| 89 | { \ |
| 90 | .offset = o, \ |
| 91 | .val = v, \ |
| 92 | } |
| 93 | |
| 94 | #define QMP_PHY_INIT_CFG_L(o, v) \ |
| 95 | { \ |
| 96 | .offset = o, \ |
| 97 | .val = v, \ |
| 98 | .in_layout = 1, \ |
| 99 | } |
| 100 | |
| 101 | /* set of registers with offsets different per-PHY */ |
| 102 | enum qphy_reg_layout { |
| 103 | /* Common block control registers */ |
| 104 | QPHY_COM_SW_RESET, |
| 105 | QPHY_COM_POWER_DOWN_CONTROL, |
| 106 | QPHY_COM_START_CONTROL, |
| 107 | QPHY_COM_PCS_READY_STATUS, |
| 108 | /* PCS registers */ |
| 109 | QPHY_PLL_LOCK_CHK_DLY_TIME, |
| 110 | QPHY_FLL_CNTRL1, |
| 111 | QPHY_FLL_CNTRL2, |
| 112 | QPHY_FLL_CNT_VAL_L, |
| 113 | QPHY_FLL_CNT_VAL_H_TOL, |
| 114 | QPHY_FLL_MAN_CODE, |
| 115 | QPHY_SW_RESET, |
| 116 | QPHY_START_CTRL, |
| 117 | QPHY_PCS_READY_STATUS, |
Bjorn Andersson | 14ced7e | 2019-08-05 17:42:56 -0700 | [diff] [blame] | 118 | QPHY_PCS_STATUS, |
Manu Gautam | ac0d239 | 2018-01-16 16:27:11 +0530 | [diff] [blame] | 119 | QPHY_PCS_AUTONOMOUS_MODE_CTRL, |
| 120 | QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR, |
| 121 | QPHY_PCS_LFPS_RXTERM_IRQ_STATUS, |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 122 | }; |
| 123 | |
Bjorn Andersson | 0347f0d | 2020-01-24 16:08:03 -0800 | [diff] [blame] | 124 | static const unsigned int msm8996_ufsphy_regs_layout[] = { |
| 125 | [QPHY_START_CTRL] = 0x00, |
| 126 | [QPHY_PCS_READY_STATUS] = 0x168, |
| 127 | }; |
| 128 | |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 129 | static const unsigned int pciephy_regs_layout[] = { |
| 130 | [QPHY_COM_SW_RESET] = 0x400, |
| 131 | [QPHY_COM_POWER_DOWN_CONTROL] = 0x404, |
| 132 | [QPHY_COM_START_CONTROL] = 0x408, |
| 133 | [QPHY_COM_PCS_READY_STATUS] = 0x448, |
| 134 | [QPHY_PLL_LOCK_CHK_DLY_TIME] = 0xa8, |
| 135 | [QPHY_FLL_CNTRL1] = 0xc4, |
| 136 | [QPHY_FLL_CNTRL2] = 0xc8, |
| 137 | [QPHY_FLL_CNT_VAL_L] = 0xcc, |
| 138 | [QPHY_FLL_CNT_VAL_H_TOL] = 0xd0, |
| 139 | [QPHY_FLL_MAN_CODE] = 0xd4, |
| 140 | [QPHY_SW_RESET] = 0x00, |
| 141 | [QPHY_START_CTRL] = 0x08, |
Bjorn Andersson | 14ced7e | 2019-08-05 17:42:56 -0700 | [diff] [blame] | 142 | [QPHY_PCS_STATUS] = 0x174, |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 143 | }; |
| 144 | |
| 145 | static const unsigned int usb3phy_regs_layout[] = { |
| 146 | [QPHY_FLL_CNTRL1] = 0xc0, |
| 147 | [QPHY_FLL_CNTRL2] = 0xc4, |
| 148 | [QPHY_FLL_CNT_VAL_L] = 0xc8, |
| 149 | [QPHY_FLL_CNT_VAL_H_TOL] = 0xcc, |
| 150 | [QPHY_FLL_MAN_CODE] = 0xd0, |
| 151 | [QPHY_SW_RESET] = 0x00, |
| 152 | [QPHY_START_CTRL] = 0x08, |
Bjorn Andersson | 14ced7e | 2019-08-05 17:42:56 -0700 | [diff] [blame] | 153 | [QPHY_PCS_STATUS] = 0x17c, |
Manu Gautam | ac0d239 | 2018-01-16 16:27:11 +0530 | [diff] [blame] | 154 | [QPHY_PCS_AUTONOMOUS_MODE_CTRL] = 0x0d4, |
| 155 | [QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR] = 0x0d8, |
| 156 | [QPHY_PCS_LFPS_RXTERM_IRQ_STATUS] = 0x178, |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 157 | }; |
| 158 | |
Manu Gautam | efb05a5 | 2018-01-16 16:27:08 +0530 | [diff] [blame] | 159 | static const unsigned int qmp_v3_usb3phy_regs_layout[] = { |
| 160 | [QPHY_SW_RESET] = 0x00, |
| 161 | [QPHY_START_CTRL] = 0x08, |
Bjorn Andersson | 14ced7e | 2019-08-05 17:42:56 -0700 | [diff] [blame] | 162 | [QPHY_PCS_STATUS] = 0x174, |
Manu Gautam | ac0d239 | 2018-01-16 16:27:11 +0530 | [diff] [blame] | 163 | [QPHY_PCS_AUTONOMOUS_MODE_CTRL] = 0x0d8, |
| 164 | [QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR] = 0x0dc, |
| 165 | [QPHY_PCS_LFPS_RXTERM_IRQ_STATUS] = 0x170, |
Manu Gautam | efb05a5 | 2018-01-16 16:27:08 +0530 | [diff] [blame] | 166 | }; |
| 167 | |
Bjorn Andersson | 421c9a0 | 2020-01-06 00:18:20 -0800 | [diff] [blame] | 168 | static const unsigned int sdm845_qmp_pciephy_regs_layout[] = { |
| 169 | [QPHY_SW_RESET] = 0x00, |
| 170 | [QPHY_START_CTRL] = 0x08, |
| 171 | [QPHY_PCS_STATUS] = 0x174, |
| 172 | }; |
| 173 | |
Bjorn Andersson | 909a5c7 | 2020-01-06 00:18:21 -0800 | [diff] [blame] | 174 | static const unsigned int sdm845_qhp_pciephy_regs_layout[] = { |
| 175 | [QPHY_SW_RESET] = 0x00, |
| 176 | [QPHY_START_CTRL] = 0x08, |
| 177 | [QPHY_PCS_STATUS] = 0x2ac, |
| 178 | }; |
| 179 | |
Jack Pham | 9a24b92 | 2020-05-04 16:54:25 -0700 | [diff] [blame^] | 180 | static const unsigned int qmp_v4_usb3phy_regs_layout[] = { |
| 181 | [QPHY_SW_RESET] = 0x00, |
| 182 | [QPHY_START_CTRL] = 0x44, |
| 183 | [QPHY_PCS_STATUS] = 0x14, |
| 184 | }; |
| 185 | |
Can Guo | cc31cdb | 2018-09-20 21:27:56 -0700 | [diff] [blame] | 186 | static const unsigned int sdm845_ufsphy_regs_layout[] = { |
| 187 | [QPHY_START_CTRL] = 0x00, |
| 188 | [QPHY_PCS_READY_STATUS] = 0x160, |
| 189 | }; |
| 190 | |
Vinod Koul | a88c85e | 2019-10-24 13:18:02 +0530 | [diff] [blame] | 191 | static const unsigned int sm8150_ufsphy_regs_layout[] = { |
Vinod Koul | 730430d | 2019-12-23 20:00:43 +0530 | [diff] [blame] | 192 | [QPHY_START_CTRL] = QPHY_V4_PHY_START, |
| 193 | [QPHY_PCS_READY_STATUS] = QPHY_V4_PCS_READY_STATUS, |
Vinod Koul | d0312fd | 2019-12-23 20:00:46 +0530 | [diff] [blame] | 194 | [QPHY_SW_RESET] = QPHY_V4_SW_RESET, |
Vinod Koul | a88c85e | 2019-10-24 13:18:02 +0530 | [diff] [blame] | 195 | }; |
| 196 | |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 197 | static const struct qmp_phy_init_tbl msm8996_pcie_serdes_tbl[] = { |
| 198 | QMP_PHY_INIT_CFG(QSERDES_COM_BIAS_EN_CLKBUFLR_EN, 0x1c), |
| 199 | QMP_PHY_INIT_CFG(QSERDES_COM_CLK_ENABLE1, 0x10), |
| 200 | QMP_PHY_INIT_CFG(QSERDES_COM_CLK_SELECT, 0x33), |
| 201 | QMP_PHY_INIT_CFG(QSERDES_COM_CMN_CONFIG, 0x06), |
| 202 | QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP_EN, 0x42), |
| 203 | QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_MAP, 0x00), |
| 204 | QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_TIMER1, 0xff), |
| 205 | QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_TIMER2, 0x1f), |
| 206 | QMP_PHY_INIT_CFG(QSERDES_COM_HSCLK_SEL, 0x01), |
| 207 | QMP_PHY_INIT_CFG(QSERDES_COM_SVS_MODE_CLK_SEL, 0x01), |
| 208 | QMP_PHY_INIT_CFG(QSERDES_COM_CORE_CLK_EN, 0x00), |
| 209 | QMP_PHY_INIT_CFG(QSERDES_COM_CORECLK_DIV, 0x0a), |
| 210 | QMP_PHY_INIT_CFG(QSERDES_COM_BG_TIMER, 0x09), |
| 211 | QMP_PHY_INIT_CFG(QSERDES_COM_DEC_START_MODE0, 0x82), |
| 212 | QMP_PHY_INIT_CFG(QSERDES_COM_DIV_FRAC_START3_MODE0, 0x03), |
| 213 | QMP_PHY_INIT_CFG(QSERDES_COM_DIV_FRAC_START2_MODE0, 0x55), |
| 214 | QMP_PHY_INIT_CFG(QSERDES_COM_DIV_FRAC_START1_MODE0, 0x55), |
| 215 | QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP3_MODE0, 0x00), |
| 216 | QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP2_MODE0, 0x1a), |
| 217 | QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP1_MODE0, 0x0a), |
| 218 | QMP_PHY_INIT_CFG(QSERDES_COM_CLK_SELECT, 0x33), |
| 219 | QMP_PHY_INIT_CFG(QSERDES_COM_SYS_CLK_CTRL, 0x02), |
| 220 | QMP_PHY_INIT_CFG(QSERDES_COM_SYSCLK_BUF_ENABLE, 0x1f), |
| 221 | QMP_PHY_INIT_CFG(QSERDES_COM_SYSCLK_EN_SEL, 0x04), |
| 222 | QMP_PHY_INIT_CFG(QSERDES_COM_CP_CTRL_MODE0, 0x0b), |
| 223 | QMP_PHY_INIT_CFG(QSERDES_COM_PLL_RCTRL_MODE0, 0x16), |
| 224 | QMP_PHY_INIT_CFG(QSERDES_COM_PLL_CCTRL_MODE0, 0x28), |
| 225 | QMP_PHY_INIT_CFG(QSERDES_COM_INTEGLOOP_GAIN1_MODE0, 0x00), |
| 226 | QMP_PHY_INIT_CFG(QSERDES_COM_INTEGLOOP_GAIN0_MODE0, 0x80), |
| 227 | QMP_PHY_INIT_CFG(QSERDES_COM_SSC_EN_CENTER, 0x01), |
| 228 | QMP_PHY_INIT_CFG(QSERDES_COM_SSC_PER1, 0x31), |
| 229 | QMP_PHY_INIT_CFG(QSERDES_COM_SSC_PER2, 0x01), |
| 230 | QMP_PHY_INIT_CFG(QSERDES_COM_SSC_ADJ_PER1, 0x02), |
| 231 | QMP_PHY_INIT_CFG(QSERDES_COM_SSC_ADJ_PER2, 0x00), |
| 232 | QMP_PHY_INIT_CFG(QSERDES_COM_SSC_STEP_SIZE1, 0x2f), |
| 233 | QMP_PHY_INIT_CFG(QSERDES_COM_SSC_STEP_SIZE2, 0x19), |
| 234 | QMP_PHY_INIT_CFG(QSERDES_COM_RESCODE_DIV_NUM, 0x15), |
| 235 | QMP_PHY_INIT_CFG(QSERDES_COM_BG_TRIM, 0x0f), |
| 236 | QMP_PHY_INIT_CFG(QSERDES_COM_PLL_IVCO, 0x0f), |
| 237 | QMP_PHY_INIT_CFG(QSERDES_COM_CLK_EP_DIV, 0x19), |
| 238 | QMP_PHY_INIT_CFG(QSERDES_COM_CLK_ENABLE1, 0x10), |
| 239 | QMP_PHY_INIT_CFG(QSERDES_COM_HSCLK_SEL, 0x00), |
| 240 | QMP_PHY_INIT_CFG(QSERDES_COM_RESCODE_DIV_NUM, 0x40), |
| 241 | }; |
| 242 | |
| 243 | static const struct qmp_phy_init_tbl msm8996_pcie_tx_tbl[] = { |
| 244 | QMP_PHY_INIT_CFG(QSERDES_TX_HIGHZ_TRANSCEIVEREN_BIAS_DRVR_EN, 0x45), |
| 245 | QMP_PHY_INIT_CFG(QSERDES_TX_LANE_MODE, 0x06), |
| 246 | }; |
| 247 | |
| 248 | static const struct qmp_phy_init_tbl msm8996_pcie_rx_tbl[] = { |
| 249 | QMP_PHY_INIT_CFG(QSERDES_RX_SIGDET_ENABLES, 0x1c), |
| 250 | QMP_PHY_INIT_CFG(QSERDES_RX_RX_EQU_ADAPTOR_CNTRL2, 0x01), |
| 251 | QMP_PHY_INIT_CFG(QSERDES_RX_RX_EQU_ADAPTOR_CNTRL3, 0x00), |
| 252 | QMP_PHY_INIT_CFG(QSERDES_RX_RX_EQU_ADAPTOR_CNTRL4, 0xdb), |
| 253 | QMP_PHY_INIT_CFG(QSERDES_RX_RX_BAND, 0x18), |
| 254 | QMP_PHY_INIT_CFG(QSERDES_RX_UCDR_SO_GAIN, 0x04), |
| 255 | QMP_PHY_INIT_CFG(QSERDES_RX_UCDR_SO_GAIN_HALF, 0x04), |
| 256 | QMP_PHY_INIT_CFG(QSERDES_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x4b), |
| 257 | QMP_PHY_INIT_CFG(QSERDES_RX_SIGDET_DEGLITCH_CNTRL, 0x14), |
| 258 | QMP_PHY_INIT_CFG(QSERDES_RX_SIGDET_LVL, 0x19), |
| 259 | }; |
| 260 | |
| 261 | static const struct qmp_phy_init_tbl msm8996_pcie_pcs_tbl[] = { |
| 262 | QMP_PHY_INIT_CFG(QPHY_RX_IDLE_DTCT_CNTRL, 0x4c), |
| 263 | QMP_PHY_INIT_CFG(QPHY_PWRUP_RESET_DLY_TIME_AUXCLK, 0x00), |
| 264 | QMP_PHY_INIT_CFG(QPHY_LP_WAKEUP_DLY_TIME_AUXCLK, 0x01), |
| 265 | |
| 266 | QMP_PHY_INIT_CFG_L(QPHY_PLL_LOCK_CHK_DLY_TIME, 0x05), |
| 267 | |
| 268 | QMP_PHY_INIT_CFG(QPHY_ENDPOINT_REFCLK_DRIVE, 0x05), |
| 269 | QMP_PHY_INIT_CFG(QPHY_POWER_DOWN_CONTROL, 0x02), |
| 270 | QMP_PHY_INIT_CFG(QPHY_POWER_STATE_CONFIG4, 0x00), |
| 271 | QMP_PHY_INIT_CFG(QPHY_POWER_STATE_CONFIG1, 0xa3), |
| 272 | QMP_PHY_INIT_CFG(QPHY_TXDEEMPH_M3P5DB_V0, 0x0e), |
| 273 | }; |
| 274 | |
Marc Gonzalez | 73d7ec8 | 2019-04-09 14:48:22 +0200 | [diff] [blame] | 275 | static const struct qmp_phy_init_tbl msm8998_pcie_serdes_tbl[] = { |
| 276 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_BIAS_EN_CLKBUFLR_EN, 0x14), |
| 277 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_SELECT, 0x30), |
| 278 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_IVCO, 0x0f), |
| 279 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CMN_CONFIG, 0x06), |
| 280 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP_EN, 0x01), |
| 281 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_RESETSM_CNTRL, 0x20), |
| 282 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_MAP, 0x00), |
| 283 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE2_MODE0, 0x01), |
| 284 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE1_MODE0, 0xc9), |
| 285 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_TIMER1, 0xff), |
| 286 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_TIMER2, 0x3f), |
| 287 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SVS_MODE_CLK_SEL, 0x01), |
| 288 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CORE_CLK_EN, 0x00), |
| 289 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CORECLK_DIV_MODE0, 0x0a), |
| 290 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_EP_DIV, 0x19), |
| 291 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_ENABLE1, 0x90), |
| 292 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_DEC_START_MODE0, 0x82), |
| 293 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START3_MODE0, 0x03), |
| 294 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START2_MODE0, 0x55), |
| 295 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START1_MODE0, 0x55), |
| 296 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP3_MODE0, 0x00), |
| 297 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP2_MODE0, 0x0d), |
| 298 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP1_MODE0, 0x04), |
| 299 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_HSCLK_SEL, 0x00), |
| 300 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CP_CTRL_MODE0, 0x08), |
| 301 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_RCTRL_MODE0, 0x16), |
| 302 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_CCTRL_MODE0, 0x34), |
| 303 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CMN_CONFIG, 0x06), |
| 304 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_SELECT, 0x33), |
| 305 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYS_CLK_CTRL, 0x02), |
| 306 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYSCLK_BUF_ENABLE, 0x07), |
| 307 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYSCLK_EN_SEL, 0x04), |
| 308 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN1_MODE0, 0x00), |
| 309 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN0_MODE0, 0x3f), |
| 310 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_BG_TIMER, 0x09), |
| 311 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_EN_CENTER, 0x01), |
| 312 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_PER1, 0x40), |
| 313 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_PER2, 0x01), |
| 314 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_ADJ_PER1, 0x02), |
| 315 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_ADJ_PER2, 0x00), |
| 316 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_STEP_SIZE1, 0x7e), |
| 317 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_STEP_SIZE2, 0x15), |
| 318 | }; |
| 319 | |
| 320 | static const struct qmp_phy_init_tbl msm8998_pcie_tx_tbl[] = { |
| 321 | QMP_PHY_INIT_CFG(QSERDES_V3_TX_RES_CODE_LANE_OFFSET_TX, 0x02), |
| 322 | QMP_PHY_INIT_CFG(QSERDES_V3_TX_RCV_DETECT_LVL_2, 0x12), |
| 323 | QMP_PHY_INIT_CFG(QSERDES_V3_TX_HIGHZ_DRVR_EN, 0x10), |
| 324 | QMP_PHY_INIT_CFG(QSERDES_V3_TX_LANE_MODE_1, 0x06), |
| 325 | }; |
| 326 | |
| 327 | static const struct qmp_phy_init_tbl msm8998_pcie_rx_tbl[] = { |
| 328 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_CNTRL, 0x03), |
| 329 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_ENABLES, 0x1c), |
| 330 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_DEGLITCH_CNTRL, 0x14), |
| 331 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL2, 0x0a), |
| 332 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL3, 0x04), |
| 333 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL4, 0x1a), |
| 334 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x4b), |
| 335 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SO_GAIN, 0x04), |
| 336 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SO_GAIN_HALF, 0x04), |
| 337 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1, 0x00), |
| 338 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_OFFSET_ADAPTOR_CNTRL2, 0x80), |
| 339 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_INTERFACE_MODE, 0x40), |
| 340 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_PI_CONTROLS, 0x71), |
| 341 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_FASTLOCK_COUNT_LOW, 0x40), |
| 342 | }; |
| 343 | |
| 344 | static const struct qmp_phy_init_tbl msm8998_pcie_pcs_tbl[] = { |
| 345 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_ENDPOINT_REFCLK_DRIVE, 0x04), |
| 346 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_OSC_DTCT_ACTIONS, 0x00), |
| 347 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_PWRUP_RESET_DLY_TIME_AUXCLK, 0x01), |
| 348 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_L1SS_WAKEUP_DLY_TIME_AUXCLK_MSB, 0x00), |
| 349 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_L1SS_WAKEUP_DLY_TIME_AUXCLK_LSB, 0x20), |
| 350 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_LP_WAKEUP_DLY_TIME_AUXCLK_MSB, 0x00), |
| 351 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_LP_WAKEUP_DLY_TIME_AUXCLK, 0x01), |
| 352 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_PLL_LOCK_CHK_DLY_TIME, 0x73), |
| 353 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_RX_SIGDET_LVL, 0x99), |
| 354 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_SIGDET_CNTRL, 0x03), |
| 355 | }; |
| 356 | |
Bjorn Andersson | 0347f0d | 2020-01-24 16:08:03 -0800 | [diff] [blame] | 357 | static const struct qmp_phy_init_tbl msm8996_ufs_serdes_tbl[] = { |
| 358 | QMP_PHY_INIT_CFG(QPHY_POWER_DOWN_CONTROL, 0x01), |
| 359 | QMP_PHY_INIT_CFG(QSERDES_COM_CMN_CONFIG, 0x0e), |
| 360 | QMP_PHY_INIT_CFG(QSERDES_COM_SYSCLK_EN_SEL, 0xd7), |
| 361 | QMP_PHY_INIT_CFG(QSERDES_COM_CLK_SELECT, 0x30), |
| 362 | QMP_PHY_INIT_CFG(QSERDES_COM_SYS_CLK_CTRL, 0x06), |
| 363 | QMP_PHY_INIT_CFG(QSERDES_COM_BIAS_EN_CLKBUFLR_EN, 0x08), |
| 364 | QMP_PHY_INIT_CFG(QSERDES_COM_BG_TIMER, 0x0a), |
| 365 | QMP_PHY_INIT_CFG(QSERDES_COM_HSCLK_SEL, 0x05), |
| 366 | QMP_PHY_INIT_CFG(QSERDES_COM_CORECLK_DIV, 0x0a), |
| 367 | QMP_PHY_INIT_CFG(QSERDES_COM_CORECLK_DIV_MODE1, 0x0a), |
| 368 | QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP_EN, 0x01), |
| 369 | QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_CTRL, 0x10), |
| 370 | QMP_PHY_INIT_CFG(QSERDES_COM_RESETSM_CNTRL, 0x20), |
| 371 | QMP_PHY_INIT_CFG(QSERDES_COM_CORE_CLK_EN, 0x00), |
| 372 | QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP_CFG, 0x00), |
| 373 | QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_TIMER1, 0xff), |
| 374 | QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_TIMER2, 0x3f), |
| 375 | QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_MAP, 0x54), |
| 376 | QMP_PHY_INIT_CFG(QSERDES_COM_SVS_MODE_CLK_SEL, 0x05), |
| 377 | QMP_PHY_INIT_CFG(QSERDES_COM_DEC_START_MODE0, 0x82), |
| 378 | QMP_PHY_INIT_CFG(QSERDES_COM_DIV_FRAC_START1_MODE0, 0x00), |
| 379 | QMP_PHY_INIT_CFG(QSERDES_COM_DIV_FRAC_START2_MODE0, 0x00), |
| 380 | QMP_PHY_INIT_CFG(QSERDES_COM_DIV_FRAC_START3_MODE0, 0x00), |
| 381 | QMP_PHY_INIT_CFG(QSERDES_COM_CP_CTRL_MODE0, 0x0b), |
| 382 | QMP_PHY_INIT_CFG(QSERDES_COM_PLL_RCTRL_MODE0, 0x16), |
| 383 | QMP_PHY_INIT_CFG(QSERDES_COM_PLL_CCTRL_MODE0, 0x28), |
| 384 | QMP_PHY_INIT_CFG(QSERDES_COM_INTEGLOOP_GAIN0_MODE0, 0x80), |
| 385 | QMP_PHY_INIT_CFG(QSERDES_COM_INTEGLOOP_GAIN1_MODE0, 0x00), |
| 386 | QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE1_MODE0, 0x28), |
| 387 | QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE2_MODE0, 0x02), |
| 388 | QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP1_MODE0, 0xff), |
| 389 | QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP2_MODE0, 0x0c), |
| 390 | QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP3_MODE0, 0x00), |
| 391 | QMP_PHY_INIT_CFG(QSERDES_COM_DEC_START_MODE1, 0x98), |
| 392 | QMP_PHY_INIT_CFG(QSERDES_COM_DIV_FRAC_START1_MODE1, 0x00), |
| 393 | QMP_PHY_INIT_CFG(QSERDES_COM_DIV_FRAC_START2_MODE1, 0x00), |
| 394 | QMP_PHY_INIT_CFG(QSERDES_COM_DIV_FRAC_START3_MODE1, 0x00), |
| 395 | QMP_PHY_INIT_CFG(QSERDES_COM_CP_CTRL_MODE1, 0x0b), |
| 396 | QMP_PHY_INIT_CFG(QSERDES_COM_PLL_RCTRL_MODE1, 0x16), |
| 397 | QMP_PHY_INIT_CFG(QSERDES_COM_PLL_CCTRL_MODE1, 0x28), |
| 398 | QMP_PHY_INIT_CFG(QSERDES_COM_INTEGLOOP_GAIN0_MODE1, 0x80), |
| 399 | QMP_PHY_INIT_CFG(QSERDES_COM_INTEGLOOP_GAIN1_MODE1, 0x00), |
| 400 | QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE1_MODE1, 0xd6), |
| 401 | QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE2_MODE1, 0x00), |
| 402 | QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP1_MODE1, 0x32), |
| 403 | QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP2_MODE1, 0x0f), |
| 404 | QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP3_MODE1, 0x00), |
| 405 | }; |
| 406 | |
| 407 | static const struct qmp_phy_init_tbl msm8996_ufs_tx_tbl[] = { |
| 408 | QMP_PHY_INIT_CFG(QSERDES_TX_HIGHZ_TRANSCEIVEREN_BIAS_DRVR_EN, 0x45), |
| 409 | QMP_PHY_INIT_CFG(QSERDES_TX_LANE_MODE, 0x02), |
| 410 | }; |
| 411 | |
| 412 | static const struct qmp_phy_init_tbl msm8996_ufs_rx_tbl[] = { |
| 413 | QMP_PHY_INIT_CFG(QSERDES_RX_SIGDET_LVL, 0x24), |
| 414 | QMP_PHY_INIT_CFG(QSERDES_RX_SIGDET_CNTRL, 0x02), |
| 415 | QMP_PHY_INIT_CFG(QSERDES_RX_RX_INTERFACE_MODE, 0x00), |
| 416 | QMP_PHY_INIT_CFG(QSERDES_RX_SIGDET_DEGLITCH_CNTRL, 0x18), |
| 417 | QMP_PHY_INIT_CFG(QSERDES_RX_UCDR_FASTLOCK_FO_GAIN, 0x0B), |
| 418 | QMP_PHY_INIT_CFG(QSERDES_RX_RX_TERM_BW, 0x5b), |
| 419 | QMP_PHY_INIT_CFG(QSERDES_RX_RX_EQ_GAIN1_LSB, 0xff), |
| 420 | QMP_PHY_INIT_CFG(QSERDES_RX_RX_EQ_GAIN1_MSB, 0x3f), |
| 421 | QMP_PHY_INIT_CFG(QSERDES_RX_RX_EQ_GAIN2_LSB, 0xff), |
| 422 | QMP_PHY_INIT_CFG(QSERDES_RX_RX_EQ_GAIN2_MSB, 0x0f), |
| 423 | QMP_PHY_INIT_CFG(QSERDES_RX_RX_EQU_ADAPTOR_CNTRL2, 0x0E), |
| 424 | }; |
| 425 | |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 426 | static const struct qmp_phy_init_tbl msm8996_usb3_serdes_tbl[] = { |
| 427 | QMP_PHY_INIT_CFG(QSERDES_COM_SYSCLK_EN_SEL, 0x14), |
| 428 | QMP_PHY_INIT_CFG(QSERDES_COM_BIAS_EN_CLKBUFLR_EN, 0x08), |
| 429 | QMP_PHY_INIT_CFG(QSERDES_COM_CLK_SELECT, 0x30), |
| 430 | QMP_PHY_INIT_CFG(QSERDES_COM_CMN_CONFIG, 0x06), |
| 431 | QMP_PHY_INIT_CFG(QSERDES_COM_SVS_MODE_CLK_SEL, 0x01), |
| 432 | QMP_PHY_INIT_CFG(QSERDES_COM_HSCLK_SEL, 0x00), |
| 433 | QMP_PHY_INIT_CFG(QSERDES_COM_BG_TRIM, 0x0f), |
| 434 | QMP_PHY_INIT_CFG(QSERDES_COM_PLL_IVCO, 0x0f), |
| 435 | QMP_PHY_INIT_CFG(QSERDES_COM_SYS_CLK_CTRL, 0x04), |
| 436 | /* PLL and Loop filter settings */ |
| 437 | QMP_PHY_INIT_CFG(QSERDES_COM_DEC_START_MODE0, 0x82), |
| 438 | QMP_PHY_INIT_CFG(QSERDES_COM_DIV_FRAC_START1_MODE0, 0x55), |
| 439 | QMP_PHY_INIT_CFG(QSERDES_COM_DIV_FRAC_START2_MODE0, 0x55), |
| 440 | QMP_PHY_INIT_CFG(QSERDES_COM_DIV_FRAC_START3_MODE0, 0x03), |
| 441 | QMP_PHY_INIT_CFG(QSERDES_COM_CP_CTRL_MODE0, 0x0b), |
| 442 | QMP_PHY_INIT_CFG(QSERDES_COM_PLL_RCTRL_MODE0, 0x16), |
| 443 | QMP_PHY_INIT_CFG(QSERDES_COM_PLL_CCTRL_MODE0, 0x28), |
| 444 | QMP_PHY_INIT_CFG(QSERDES_COM_INTEGLOOP_GAIN0_MODE0, 0x80), |
| 445 | QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_CTRL, 0x00), |
| 446 | QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP1_MODE0, 0x15), |
| 447 | QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP2_MODE0, 0x34), |
| 448 | QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP3_MODE0, 0x00), |
| 449 | QMP_PHY_INIT_CFG(QSERDES_COM_CORE_CLK_EN, 0x00), |
| 450 | QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP_CFG, 0x00), |
| 451 | QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_MAP, 0x00), |
| 452 | QMP_PHY_INIT_CFG(QSERDES_COM_BG_TIMER, 0x0a), |
| 453 | /* SSC settings */ |
| 454 | QMP_PHY_INIT_CFG(QSERDES_COM_SSC_EN_CENTER, 0x01), |
| 455 | QMP_PHY_INIT_CFG(QSERDES_COM_SSC_PER1, 0x31), |
| 456 | QMP_PHY_INIT_CFG(QSERDES_COM_SSC_PER2, 0x01), |
| 457 | QMP_PHY_INIT_CFG(QSERDES_COM_SSC_ADJ_PER1, 0x00), |
| 458 | QMP_PHY_INIT_CFG(QSERDES_COM_SSC_ADJ_PER2, 0x00), |
| 459 | QMP_PHY_INIT_CFG(QSERDES_COM_SSC_STEP_SIZE1, 0xde), |
| 460 | QMP_PHY_INIT_CFG(QSERDES_COM_SSC_STEP_SIZE2, 0x07), |
| 461 | }; |
| 462 | |
| 463 | static const struct qmp_phy_init_tbl msm8996_usb3_tx_tbl[] = { |
| 464 | QMP_PHY_INIT_CFG(QSERDES_TX_HIGHZ_TRANSCEIVEREN_BIAS_DRVR_EN, 0x45), |
| 465 | QMP_PHY_INIT_CFG(QSERDES_TX_RCV_DETECT_LVL_2, 0x12), |
| 466 | QMP_PHY_INIT_CFG(QSERDES_TX_LANE_MODE, 0x06), |
| 467 | }; |
| 468 | |
| 469 | static const struct qmp_phy_init_tbl msm8996_usb3_rx_tbl[] = { |
| 470 | QMP_PHY_INIT_CFG(QSERDES_RX_UCDR_FASTLOCK_FO_GAIN, 0x0b), |
| 471 | QMP_PHY_INIT_CFG(QSERDES_RX_UCDR_SO_GAIN, 0x04), |
| 472 | QMP_PHY_INIT_CFG(QSERDES_RX_RX_EQU_ADAPTOR_CNTRL2, 0x02), |
| 473 | QMP_PHY_INIT_CFG(QSERDES_RX_RX_EQU_ADAPTOR_CNTRL3, 0x4c), |
| 474 | QMP_PHY_INIT_CFG(QSERDES_RX_RX_EQU_ADAPTOR_CNTRL4, 0xbb), |
| 475 | QMP_PHY_INIT_CFG(QSERDES_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1, 0x77), |
| 476 | QMP_PHY_INIT_CFG(QSERDES_RX_RX_OFFSET_ADAPTOR_CNTRL2, 0x80), |
| 477 | QMP_PHY_INIT_CFG(QSERDES_RX_SIGDET_CNTRL, 0x03), |
| 478 | QMP_PHY_INIT_CFG(QSERDES_RX_SIGDET_LVL, 0x18), |
| 479 | QMP_PHY_INIT_CFG(QSERDES_RX_SIGDET_DEGLITCH_CNTRL, 0x16), |
| 480 | }; |
| 481 | |
| 482 | static const struct qmp_phy_init_tbl msm8996_usb3_pcs_tbl[] = { |
| 483 | /* FLL settings */ |
| 484 | QMP_PHY_INIT_CFG_L(QPHY_FLL_CNTRL2, 0x03), |
| 485 | QMP_PHY_INIT_CFG_L(QPHY_FLL_CNTRL1, 0x02), |
| 486 | QMP_PHY_INIT_CFG_L(QPHY_FLL_CNT_VAL_L, 0x09), |
| 487 | QMP_PHY_INIT_CFG_L(QPHY_FLL_CNT_VAL_H_TOL, 0x42), |
| 488 | QMP_PHY_INIT_CFG_L(QPHY_FLL_MAN_CODE, 0x85), |
| 489 | |
| 490 | /* Lock Det settings */ |
| 491 | QMP_PHY_INIT_CFG(QPHY_LOCK_DETECT_CONFIG1, 0xd1), |
| 492 | QMP_PHY_INIT_CFG(QPHY_LOCK_DETECT_CONFIG2, 0x1f), |
| 493 | QMP_PHY_INIT_CFG(QPHY_LOCK_DETECT_CONFIG3, 0x47), |
| 494 | QMP_PHY_INIT_CFG(QPHY_POWER_STATE_CONFIG2, 0x08), |
| 495 | }; |
| 496 | |
Varadarajan Narayanan | eef243d | 2017-07-31 12:04:14 +0530 | [diff] [blame] | 497 | static const struct qmp_phy_init_tbl ipq8074_pcie_serdes_tbl[] = { |
| 498 | QMP_PHY_INIT_CFG(QSERDES_COM_BIAS_EN_CLKBUFLR_EN, 0x18), |
| 499 | QMP_PHY_INIT_CFG(QSERDES_COM_CLK_ENABLE1, 0x10), |
| 500 | QMP_PHY_INIT_CFG(QSERDES_COM_BG_TRIM, 0xf), |
| 501 | QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP_EN, 0x1), |
| 502 | QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_MAP, 0x0), |
| 503 | QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_TIMER1, 0x1f), |
| 504 | QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_TIMER2, 0x3f), |
| 505 | QMP_PHY_INIT_CFG(QSERDES_COM_CMN_CONFIG, 0x6), |
| 506 | QMP_PHY_INIT_CFG(QSERDES_COM_PLL_IVCO, 0xf), |
| 507 | QMP_PHY_INIT_CFG(QSERDES_COM_HSCLK_SEL, 0x0), |
| 508 | QMP_PHY_INIT_CFG(QSERDES_COM_SVS_MODE_CLK_SEL, 0x1), |
| 509 | QMP_PHY_INIT_CFG(QSERDES_COM_CORE_CLK_EN, 0x20), |
| 510 | QMP_PHY_INIT_CFG(QSERDES_COM_CORECLK_DIV, 0xa), |
| 511 | QMP_PHY_INIT_CFG(QSERDES_COM_RESETSM_CNTRL, 0x20), |
| 512 | QMP_PHY_INIT_CFG(QSERDES_COM_BG_TIMER, 0xa), |
| 513 | QMP_PHY_INIT_CFG(QSERDES_COM_SYSCLK_EN_SEL, 0xa), |
| 514 | QMP_PHY_INIT_CFG(QSERDES_COM_DEC_START_MODE0, 0x82), |
| 515 | QMP_PHY_INIT_CFG(QSERDES_COM_DIV_FRAC_START3_MODE0, 0x3), |
| 516 | QMP_PHY_INIT_CFG(QSERDES_COM_DIV_FRAC_START2_MODE0, 0x55), |
| 517 | QMP_PHY_INIT_CFG(QSERDES_COM_DIV_FRAC_START1_MODE0, 0x55), |
| 518 | QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP3_MODE0, 0x0), |
| 519 | QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP2_MODE0, 0xD), |
| 520 | QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP1_MODE0, 0xD04), |
| 521 | QMP_PHY_INIT_CFG(QSERDES_COM_CLK_SELECT, 0x33), |
| 522 | QMP_PHY_INIT_CFG(QSERDES_COM_SYS_CLK_CTRL, 0x2), |
| 523 | QMP_PHY_INIT_CFG(QSERDES_COM_SYSCLK_BUF_ENABLE, 0x1f), |
| 524 | QMP_PHY_INIT_CFG(QSERDES_COM_CP_CTRL_MODE0, 0xb), |
| 525 | QMP_PHY_INIT_CFG(QSERDES_COM_PLL_RCTRL_MODE0, 0x16), |
| 526 | QMP_PHY_INIT_CFG(QSERDES_COM_PLL_CCTRL_MODE0, 0x28), |
| 527 | QMP_PHY_INIT_CFG(QSERDES_COM_INTEGLOOP_GAIN1_MODE0, 0x0), |
| 528 | QMP_PHY_INIT_CFG(QSERDES_COM_INTEGLOOP_GAIN0_MODE0, 0x80), |
| 529 | QMP_PHY_INIT_CFG(QSERDES_COM_BIAS_EN_CTRL_BY_PSM, 0x1), |
| 530 | QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_CTRL, 0xa), |
| 531 | QMP_PHY_INIT_CFG(QSERDES_COM_SSC_EN_CENTER, 0x1), |
| 532 | QMP_PHY_INIT_CFG(QSERDES_COM_SSC_PER1, 0x31), |
| 533 | QMP_PHY_INIT_CFG(QSERDES_COM_SSC_PER2, 0x1), |
| 534 | QMP_PHY_INIT_CFG(QSERDES_COM_SSC_ADJ_PER1, 0x2), |
| 535 | QMP_PHY_INIT_CFG(QSERDES_COM_SSC_ADJ_PER2, 0x0), |
| 536 | QMP_PHY_INIT_CFG(QSERDES_COM_SSC_STEP_SIZE1, 0x2f), |
| 537 | QMP_PHY_INIT_CFG(QSERDES_COM_SSC_STEP_SIZE2, 0x19), |
| 538 | QMP_PHY_INIT_CFG(QSERDES_COM_CLK_EP_DIV, 0x19), |
| 539 | QMP_PHY_INIT_CFG(QSERDES_RX_SIGDET_CNTRL, 0x7), |
| 540 | }; |
| 541 | |
| 542 | static const struct qmp_phy_init_tbl ipq8074_pcie_tx_tbl[] = { |
| 543 | QMP_PHY_INIT_CFG(QSERDES_TX_HIGHZ_TRANSCEIVEREN_BIAS_DRVR_EN, 0x45), |
| 544 | QMP_PHY_INIT_CFG(QSERDES_TX_LANE_MODE, 0x6), |
| 545 | QMP_PHY_INIT_CFG(QSERDES_TX_RES_CODE_LANE_OFFSET, 0x2), |
| 546 | QMP_PHY_INIT_CFG(QSERDES_TX_RCV_DETECT_LVL_2, 0x12), |
| 547 | }; |
| 548 | |
| 549 | static const struct qmp_phy_init_tbl ipq8074_pcie_rx_tbl[] = { |
| 550 | QMP_PHY_INIT_CFG(QSERDES_RX_SIGDET_ENABLES, 0x1c), |
| 551 | QMP_PHY_INIT_CFG(QSERDES_RX_SIGDET_DEGLITCH_CNTRL, 0x14), |
| 552 | QMP_PHY_INIT_CFG(QSERDES_RX_RX_EQU_ADAPTOR_CNTRL2, 0x1), |
| 553 | QMP_PHY_INIT_CFG(QSERDES_RX_RX_EQU_ADAPTOR_CNTRL3, 0x0), |
| 554 | QMP_PHY_INIT_CFG(QSERDES_RX_RX_EQU_ADAPTOR_CNTRL4, 0xdb), |
| 555 | QMP_PHY_INIT_CFG(QSERDES_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x4b), |
| 556 | QMP_PHY_INIT_CFG(QSERDES_RX_UCDR_SO_GAIN, 0x4), |
| 557 | QMP_PHY_INIT_CFG(QSERDES_RX_UCDR_SO_GAIN_HALF, 0x4), |
| 558 | }; |
| 559 | |
| 560 | static const struct qmp_phy_init_tbl ipq8074_pcie_pcs_tbl[] = { |
| 561 | QMP_PHY_INIT_CFG(QPHY_ENDPOINT_REFCLK_DRIVE, 0x4), |
| 562 | QMP_PHY_INIT_CFG(QPHY_OSC_DTCT_ACTIONS, 0x0), |
| 563 | QMP_PHY_INIT_CFG(QPHY_PWRUP_RESET_DLY_TIME_AUXCLK, 0x40), |
| 564 | QMP_PHY_INIT_CFG(QPHY_L1SS_WAKEUP_DLY_TIME_AUXCLK_MSB, 0x0), |
| 565 | QMP_PHY_INIT_CFG(QPHY_L1SS_WAKEUP_DLY_TIME_AUXCLK_LSB, 0x40), |
| 566 | QMP_PHY_INIT_CFG(QPHY_PLL_LOCK_CHK_DLY_TIME_AUXCLK_LSB, 0x0), |
| 567 | QMP_PHY_INIT_CFG(QPHY_LP_WAKEUP_DLY_TIME_AUXCLK, 0x40), |
| 568 | QMP_PHY_INIT_CFG_L(QPHY_PLL_LOCK_CHK_DLY_TIME, 0x73), |
| 569 | QMP_PHY_INIT_CFG(QPHY_RX_SIGDET_LVL, 0x99), |
| 570 | QMP_PHY_INIT_CFG(QPHY_TXDEEMPH_M6DB_V0, 0x15), |
| 571 | QMP_PHY_INIT_CFG(QPHY_TXDEEMPH_M3P5DB_V0, 0xe), |
| 572 | QMP_PHY_INIT_CFG_L(QPHY_SW_RESET, 0x0), |
| 573 | QMP_PHY_INIT_CFG_L(QPHY_START_CTRL, 0x3), |
| 574 | }; |
| 575 | |
Bjorn Andersson | 421c9a0 | 2020-01-06 00:18:20 -0800 | [diff] [blame] | 576 | static const struct qmp_phy_init_tbl sdm845_qmp_pcie_serdes_tbl[] = { |
| 577 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_BIAS_EN_CLKBUFLR_EN, 0x14), |
| 578 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_SELECT, 0x30), |
| 579 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_IVCO, 0x007), |
| 580 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CMN_CONFIG, 0x06), |
| 581 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP_EN, 0x01), |
| 582 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_RESETSM_CNTRL, 0x20), |
| 583 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_MAP, 0x00), |
| 584 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE2_MODE0, 0x01), |
| 585 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE1_MODE0, 0xc9), |
| 586 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_TIMER1, 0xff), |
| 587 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_TIMER2, 0x3f), |
| 588 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SVS_MODE_CLK_SEL, 0x01), |
| 589 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CORE_CLK_EN, 0x00), |
| 590 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CORECLK_DIV_MODE0, 0x0a), |
| 591 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_EP_DIV, 0x19), |
| 592 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_ENABLE1, 0x90), |
| 593 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_DEC_START_MODE0, 0x82), |
| 594 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START3_MODE0, 0x02), |
| 595 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START2_MODE0, 0xea), |
| 596 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START1_MODE0, 0xab), |
| 597 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP3_MODE0, 0x00), |
| 598 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP2_MODE0, 0x0d), |
| 599 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP1_MODE0, 0x04), |
| 600 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_HSCLK_SEL, 0x00), |
| 601 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CP_CTRL_MODE0, 0x06), |
| 602 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_RCTRL_MODE0, 0x16), |
| 603 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_CCTRL_MODE0, 0x36), |
| 604 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CMN_MODE, 0x01), |
| 605 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_SELECT, 0x33), |
| 606 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYS_CLK_CTRL, 0x02), |
| 607 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYSCLK_BUF_ENABLE, 0x06), |
| 608 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYSCLK_EN_SEL, 0x04), |
| 609 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN1_MODE0, 0x00), |
| 610 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN0_MODE0, 0x3f), |
| 611 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_BG_TIMER, 0x09), |
| 612 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_EN_CENTER, 0x01), |
| 613 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_PER1, 0x40), |
| 614 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_PER2, 0x01), |
| 615 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_ADJ_PER1, 0x02), |
| 616 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_ADJ_PER2, 0x00), |
| 617 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_STEP_SIZE1, 0x7e), |
| 618 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_STEP_SIZE2, 0x15), |
| 619 | }; |
| 620 | |
| 621 | static const struct qmp_phy_init_tbl sdm845_qmp_pcie_tx_tbl[] = { |
| 622 | QMP_PHY_INIT_CFG(QSERDES_V3_TX_RES_CODE_LANE_OFFSET_TX, 0x02), |
| 623 | QMP_PHY_INIT_CFG(QSERDES_V3_TX_RCV_DETECT_LVL_2, 0x12), |
| 624 | QMP_PHY_INIT_CFG(QSERDES_V3_TX_HIGHZ_DRVR_EN, 0x10), |
| 625 | QMP_PHY_INIT_CFG(QSERDES_V3_TX_LANE_MODE_1, 0x06), |
| 626 | }; |
| 627 | |
| 628 | static const struct qmp_phy_init_tbl sdm845_qmp_pcie_rx_tbl[] = { |
| 629 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_CNTRL, 0x03), |
| 630 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_ENABLES, 0x10), |
| 631 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_DEGLITCH_CNTRL, 0x14), |
| 632 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL2, 0x0e), |
| 633 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL3, 0x04), |
| 634 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL4, 0x1a), |
| 635 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x4b), |
| 636 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SO_GAIN, 0x04), |
| 637 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SO_GAIN_HALF, 0x04), |
| 638 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1, 0x71), |
| 639 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_MODE_00, 0x59), |
| 640 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_MODE_01, 0x59), |
| 641 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_OFFSET_ADAPTOR_CNTRL2, 0x80), |
| 642 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_INTERFACE_MODE, 0x40), |
| 643 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_PI_CONTROLS, 0x71), |
| 644 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_FASTLOCK_COUNT_LOW, 0x40), |
| 645 | }; |
| 646 | |
| 647 | static const struct qmp_phy_init_tbl sdm845_qmp_pcie_pcs_tbl[] = { |
| 648 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_ENDPOINT_REFCLK_DRIVE, 0x04), |
| 649 | |
| 650 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNTRL2, 0x83), |
| 651 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNT_VAL_L, 0x09), |
| 652 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNT_VAL_H_TOL, 0xa2), |
| 653 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_MAN_CODE, 0x40), |
| 654 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNTRL1, 0x02), |
| 655 | |
| 656 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_OSC_DTCT_ACTIONS, 0x00), |
| 657 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_PWRUP_RESET_DLY_TIME_AUXCLK, 0x01), |
| 658 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_L1SS_WAKEUP_DLY_TIME_AUXCLK_MSB, 0x00), |
| 659 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_L1SS_WAKEUP_DLY_TIME_AUXCLK_LSB, 0x20), |
| 660 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_LP_WAKEUP_DLY_TIME_AUXCLK_MSB, 0x00), |
| 661 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_LP_WAKEUP_DLY_TIME_AUXCLK, 0x01), |
| 662 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_PLL_LOCK_CHK_DLY_TIME, 0x73), |
| 663 | |
| 664 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_RX_SIGDET_LVL, 0xbb), |
| 665 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_SIGDET_CNTRL, 0x03), |
| 666 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_REFGEN_REQ_CONFIG1, 0x0d), |
| 667 | |
| 668 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_POWER_STATE_CONFIG4, 0x00), |
| 669 | }; |
| 670 | |
| 671 | static const struct qmp_phy_init_tbl sdm845_qmp_pcie_pcs_misc_tbl[] = { |
| 672 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_MISC_OSC_DTCT_CONFIG2, 0x52), |
| 673 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_MISC_OSC_DTCT_MODE2_CONFIG2, 0x10), |
| 674 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_MISC_OSC_DTCT_MODE2_CONFIG4, 0x1a), |
| 675 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_MISC_OSC_DTCT_MODE2_CONFIG5, 0x06), |
| 676 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_MISC_PCIE_INT_AUX_CLK_CONFIG1, 0x00), |
| 677 | }; |
| 678 | |
Bjorn Andersson | 909a5c7 | 2020-01-06 00:18:21 -0800 | [diff] [blame] | 679 | static const struct qmp_phy_init_tbl sdm845_qhp_pcie_serdes_tbl[] = { |
| 680 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_SYSCLK_EN_SEL, 0x27), |
| 681 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_SSC_EN_CENTER, 0x01), |
| 682 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_SSC_PER1, 0x31), |
| 683 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_SSC_PER2, 0x01), |
| 684 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_SSC_STEP_SIZE1, 0xde), |
| 685 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_SSC_STEP_SIZE2, 0x07), |
| 686 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_SSC_STEP_SIZE1_MODE1, 0x4c), |
| 687 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_SSC_STEP_SIZE2_MODE1, 0x06), |
| 688 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_BIAS_EN_CKBUFLR_EN, 0x18), |
| 689 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_CLK_ENABLE1, 0xb0), |
| 690 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_LOCK_CMP1_MODE0, 0x8c), |
| 691 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_LOCK_CMP2_MODE0, 0x20), |
| 692 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_LOCK_CMP1_MODE1, 0x14), |
| 693 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_LOCK_CMP2_MODE1, 0x34), |
| 694 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_CP_CTRL_MODE0, 0x06), |
| 695 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_CP_CTRL_MODE1, 0x06), |
| 696 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_PLL_RCTRL_MODE0, 0x16), |
| 697 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_PLL_RCTRL_MODE1, 0x16), |
| 698 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_PLL_CCTRL_MODE0, 0x36), |
| 699 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_PLL_CCTRL_MODE1, 0x36), |
| 700 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_RESTRIM_CTRL2, 0x05), |
| 701 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_LOCK_CMP_EN, 0x42), |
| 702 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_DEC_START_MODE0, 0x82), |
| 703 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_DEC_START_MODE1, 0x68), |
| 704 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_DIV_FRAC_START1_MODE0, 0x55), |
| 705 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_DIV_FRAC_START2_MODE0, 0x55), |
| 706 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_DIV_FRAC_START3_MODE0, 0x03), |
| 707 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_DIV_FRAC_START1_MODE1, 0xab), |
| 708 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_DIV_FRAC_START2_MODE1, 0xaa), |
| 709 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_DIV_FRAC_START3_MODE1, 0x02), |
| 710 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_INTEGLOOP_GAIN0_MODE0, 0x3f), |
| 711 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_INTEGLOOP_GAIN0_MODE1, 0x3f), |
| 712 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_VCO_TUNE_MAP, 0x10), |
| 713 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_CLK_SELECT, 0x04), |
| 714 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_HSCLK_SEL1, 0x30), |
| 715 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_CORECLK_DIV, 0x04), |
| 716 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_CORE_CLK_EN, 0x73), |
| 717 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_CMN_CONFIG, 0x0c), |
| 718 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_SVS_MODE_CLK_SEL, 0x15), |
| 719 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_CORECLK_DIV_MODE1, 0x04), |
| 720 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_CMN_MODE, 0x01), |
| 721 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_VREGCLK_DIV1, 0x22), |
| 722 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_VREGCLK_DIV2, 0x00), |
| 723 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_BGV_TRIM, 0x20), |
| 724 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_COM_BG_CTRL, 0x07), |
| 725 | }; |
| 726 | |
| 727 | static const struct qmp_phy_init_tbl sdm845_qhp_pcie_tx_tbl[] = { |
| 728 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_DRVR_CTRL0, 0x00), |
| 729 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_DRVR_TAP_EN, 0x0d), |
| 730 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_TX_BAND_MODE, 0x01), |
| 731 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_LANE_MODE, 0x1a), |
| 732 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_PARALLEL_RATE, 0x2f), |
| 733 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_CML_CTRL_MODE0, 0x09), |
| 734 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_CML_CTRL_MODE1, 0x09), |
| 735 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_CML_CTRL_MODE2, 0x1b), |
| 736 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_PREAMP_CTRL_MODE1, 0x01), |
| 737 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_PREAMP_CTRL_MODE2, 0x07), |
| 738 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_MIXER_CTRL_MODE0, 0x31), |
| 739 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_MIXER_CTRL_MODE1, 0x31), |
| 740 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_MIXER_CTRL_MODE2, 0x03), |
| 741 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_CTLE_THRESH_DFE, 0x02), |
| 742 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_CGA_THRESH_DFE, 0x00), |
| 743 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RXENGINE_EN0, 0x12), |
| 744 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_CTLE_TRAIN_TIME, 0x25), |
| 745 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_CTLE_DFE_OVRLP_TIME, 0x00), |
| 746 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_DFE_REFRESH_TIME, 0x05), |
| 747 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_DFE_ENABLE_TIME, 0x01), |
| 748 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_VGA_GAIN, 0x26), |
| 749 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_DFE_GAIN, 0x12), |
| 750 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_EQ_GAIN, 0x04), |
| 751 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_OFFSET_GAIN, 0x04), |
| 752 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_PRE_GAIN, 0x09), |
| 753 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_EQ_INTVAL, 0x15), |
| 754 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_EDAC_INITVAL, 0x28), |
| 755 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RXEQ_INITB0, 0x7f), |
| 756 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RXEQ_INITB1, 0x07), |
| 757 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RCVRDONE_THRESH1, 0x04), |
| 758 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RXEQ_CTRL, 0x70), |
| 759 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_UCDR_FO_GAIN_MODE0, 0x8b), |
| 760 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_UCDR_FO_GAIN_MODE1, 0x08), |
| 761 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_UCDR_FO_GAIN_MODE2, 0x0a), |
| 762 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_UCDR_SO_GAIN_MODE0, 0x03), |
| 763 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_UCDR_SO_GAIN_MODE1, 0x04), |
| 764 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_UCDR_SO_GAIN_MODE2, 0x04), |
| 765 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_UCDR_SO_CONFIG, 0x0c), |
| 766 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RX_BAND, 0x02), |
| 767 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RX_RCVR_PATH1_MODE0, 0x5c), |
| 768 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RX_RCVR_PATH1_MODE1, 0x3e), |
| 769 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RX_RCVR_PATH1_MODE2, 0x3f), |
| 770 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_SIGDET_ENABLES, 0x01), |
| 771 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_SIGDET_CNTRL, 0xa0), |
| 772 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_SIGDET_DEGLITCH_CNTRL, 0x08), |
| 773 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_DCC_GAIN, 0x01), |
| 774 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RX_EN_SIGNAL, 0xc3), |
| 775 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_PSM_RX_EN_CAL, 0x00), |
| 776 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RX_MISC_CNTRL0, 0xbc), |
| 777 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_TS0_TIMER, 0x7f), |
| 778 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_DLL_HIGHDATARATE, 0x15), |
| 779 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_DRVR_CTRL1, 0x0c), |
| 780 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_DRVR_CTRL2, 0x0f), |
| 781 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RX_RESETCODE_OFFSET, 0x04), |
| 782 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_VGA_INITVAL, 0x20), |
| 783 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_L0_RSM_START, 0x01), |
| 784 | }; |
| 785 | |
| 786 | static const struct qmp_phy_init_tbl sdm845_qhp_pcie_rx_tbl[] = { |
| 787 | }; |
| 788 | |
| 789 | static const struct qmp_phy_init_tbl sdm845_qhp_pcie_pcs_tbl[] = { |
| 790 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_PHY_POWER_STATE_CONFIG, 0x3f), |
| 791 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_PHY_PCS_TX_RX_CONFIG, 0x50), |
| 792 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_PHY_TXMGN_MAIN_V0_M3P5DB, 0x19), |
| 793 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_PHY_TXMGN_POST_V0_M3P5DB, 0x07), |
| 794 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_PHY_TXMGN_MAIN_V0_M6DB, 0x17), |
| 795 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_PHY_TXMGN_POST_V0_M6DB, 0x09), |
| 796 | QMP_PHY_INIT_CFG(PCIE_GEN3_QHP_PHY_POWER_STATE_CONFIG5, 0x9f), |
| 797 | }; |
| 798 | |
Manu Gautam | efb05a5 | 2018-01-16 16:27:08 +0530 | [diff] [blame] | 799 | static const struct qmp_phy_init_tbl qmp_v3_usb3_serdes_tbl[] = { |
| 800 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_IVCO, 0x07), |
| 801 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYSCLK_EN_SEL, 0x14), |
| 802 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_BIAS_EN_CLKBUFLR_EN, 0x08), |
| 803 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_SELECT, 0x30), |
| 804 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYS_CLK_CTRL, 0x02), |
| 805 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_RESETSM_CNTRL2, 0x08), |
| 806 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CMN_CONFIG, 0x16), |
| 807 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SVS_MODE_CLK_SEL, 0x01), |
| 808 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_HSCLK_SEL, 0x80), |
| 809 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_DEC_START_MODE0, 0x82), |
| 810 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START1_MODE0, 0xab), |
| 811 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START2_MODE0, 0xea), |
| 812 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START3_MODE0, 0x02), |
| 813 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CP_CTRL_MODE0, 0x06), |
| 814 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_RCTRL_MODE0, 0x16), |
| 815 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_CCTRL_MODE0, 0x36), |
| 816 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN1_MODE0, 0x00), |
| 817 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN0_MODE0, 0x3f), |
| 818 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE2_MODE0, 0x01), |
| 819 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE1_MODE0, 0xc9), |
| 820 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CORECLK_DIV_MODE0, 0x0a), |
| 821 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP3_MODE0, 0x00), |
| 822 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP2_MODE0, 0x34), |
| 823 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP1_MODE0, 0x15), |
| 824 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP_EN, 0x04), |
| 825 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CORE_CLK_EN, 0x00), |
| 826 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP_CFG, 0x00), |
| 827 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_MAP, 0x00), |
| 828 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYSCLK_BUF_ENABLE, 0x0a), |
| 829 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_EN_CENTER, 0x01), |
| 830 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_PER1, 0x31), |
| 831 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_PER2, 0x01), |
| 832 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_ADJ_PER1, 0x00), |
| 833 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_ADJ_PER2, 0x00), |
| 834 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_STEP_SIZE1, 0x85), |
| 835 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_STEP_SIZE2, 0x07), |
| 836 | }; |
| 837 | |
| 838 | static const struct qmp_phy_init_tbl qmp_v3_usb3_tx_tbl[] = { |
| 839 | QMP_PHY_INIT_CFG(QSERDES_V3_TX_HIGHZ_DRVR_EN, 0x10), |
| 840 | QMP_PHY_INIT_CFG(QSERDES_V3_TX_RCV_DETECT_LVL_2, 0x12), |
| 841 | QMP_PHY_INIT_CFG(QSERDES_V3_TX_LANE_MODE_1, 0x16), |
| 842 | QMP_PHY_INIT_CFG(QSERDES_V3_TX_RES_CODE_LANE_OFFSET_RX, 0x09), |
| 843 | QMP_PHY_INIT_CFG(QSERDES_V3_TX_RES_CODE_LANE_OFFSET_TX, 0x06), |
| 844 | }; |
| 845 | |
| 846 | static const struct qmp_phy_init_tbl qmp_v3_usb3_rx_tbl[] = { |
| 847 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_FASTLOCK_FO_GAIN, 0x0b), |
| 848 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL2, 0x0f), |
| 849 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL3, 0x4e), |
| 850 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL4, 0x18), |
| 851 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1, 0x77), |
| 852 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_OFFSET_ADAPTOR_CNTRL2, 0x80), |
| 853 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_CNTRL, 0x03), |
| 854 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_DEGLITCH_CNTRL, 0x16), |
| 855 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x75), |
| 856 | }; |
| 857 | |
| 858 | static const struct qmp_phy_init_tbl qmp_v3_usb3_pcs_tbl[] = { |
| 859 | /* FLL settings */ |
| 860 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNTRL2, 0x83), |
| 861 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNT_VAL_L, 0x09), |
| 862 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNT_VAL_H_TOL, 0xa2), |
| 863 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_MAN_CODE, 0x40), |
| 864 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNTRL1, 0x02), |
| 865 | |
| 866 | /* Lock Det settings */ |
| 867 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_LOCK_DETECT_CONFIG1, 0xd1), |
| 868 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_LOCK_DETECT_CONFIG2, 0x1f), |
| 869 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_LOCK_DETECT_CONFIG3, 0x47), |
| 870 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_POWER_STATE_CONFIG2, 0x1b), |
| 871 | |
| 872 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_RX_SIGDET_LVL, 0xba), |
| 873 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_V0, 0x9f), |
| 874 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_V1, 0x9f), |
| 875 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_V2, 0xb7), |
| 876 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_V3, 0x4e), |
| 877 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_V4, 0x65), |
| 878 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_LS, 0x6b), |
| 879 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_V0, 0x15), |
| 880 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_V0, 0x0d), |
| 881 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_V1, 0x15), |
| 882 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_V1, 0x0d), |
| 883 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_V2, 0x15), |
| 884 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_V2, 0x0d), |
| 885 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_V3, 0x15), |
| 886 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_V3, 0x1d), |
| 887 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_V4, 0x15), |
| 888 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_V4, 0x0d), |
| 889 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_LS, 0x15), |
| 890 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_LS, 0x0d), |
| 891 | |
| 892 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_RATE_SLEW_CNTRL, 0x02), |
| 893 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_PWRUP_RESET_DLY_TIME_AUXCLK, 0x04), |
| 894 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TSYNC_RSYNC_TIME, 0x44), |
| 895 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_PWRUP_RESET_DLY_TIME_AUXCLK, 0x04), |
| 896 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_RCVR_DTCT_DLY_P1U2_L, 0xe7), |
| 897 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_RCVR_DTCT_DLY_P1U2_H, 0x03), |
| 898 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_RCVR_DTCT_DLY_U3_L, 0x40), |
| 899 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_RCVR_DTCT_DLY_U3_H, 0x00), |
| 900 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_RXEQTRAINING_WAIT_TIME, 0x75), |
| 901 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_LFPS_TX_ECSTART_EQTLOCK, 0x86), |
| 902 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_RXEQTRAINING_RUN_TIME, 0x13), |
| 903 | }; |
| 904 | |
Manu Gautam | f6721e5 | 2018-05-03 02:36:12 +0530 | [diff] [blame] | 905 | static const struct qmp_phy_init_tbl qmp_v3_usb3_uniphy_serdes_tbl[] = { |
| 906 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_IVCO, 0x07), |
| 907 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYSCLK_EN_SEL, 0x14), |
| 908 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_BIAS_EN_CLKBUFLR_EN, 0x04), |
| 909 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_SELECT, 0x30), |
| 910 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYS_CLK_CTRL, 0x02), |
| 911 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_RESETSM_CNTRL2, 0x08), |
| 912 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CMN_CONFIG, 0x06), |
| 913 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SVS_MODE_CLK_SEL, 0x01), |
| 914 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_HSCLK_SEL, 0x80), |
| 915 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_DEC_START_MODE0, 0x82), |
| 916 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START1_MODE0, 0xab), |
| 917 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START2_MODE0, 0xea), |
| 918 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START3_MODE0, 0x02), |
| 919 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CP_CTRL_MODE0, 0x06), |
| 920 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_RCTRL_MODE0, 0x16), |
| 921 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_CCTRL_MODE0, 0x36), |
| 922 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN1_MODE0, 0x00), |
| 923 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN0_MODE0, 0x3f), |
| 924 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE2_MODE0, 0x01), |
| 925 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE1_MODE0, 0xc9), |
| 926 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CORECLK_DIV_MODE0, 0x0a), |
| 927 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP3_MODE0, 0x00), |
| 928 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP2_MODE0, 0x34), |
| 929 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP1_MODE0, 0x15), |
| 930 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP_EN, 0x04), |
| 931 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CORE_CLK_EN, 0x00), |
| 932 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP_CFG, 0x00), |
| 933 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_MAP, 0x00), |
| 934 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYSCLK_BUF_ENABLE, 0x0a), |
| 935 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_EN_CENTER, 0x01), |
| 936 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_PER1, 0x31), |
| 937 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_PER2, 0x01), |
| 938 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_ADJ_PER1, 0x00), |
| 939 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_ADJ_PER2, 0x00), |
| 940 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_STEP_SIZE1, 0x85), |
| 941 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_STEP_SIZE2, 0x07), |
| 942 | }; |
| 943 | |
| 944 | static const struct qmp_phy_init_tbl qmp_v3_usb3_uniphy_tx_tbl[] = { |
| 945 | QMP_PHY_INIT_CFG(QSERDES_V3_TX_HIGHZ_DRVR_EN, 0x10), |
| 946 | QMP_PHY_INIT_CFG(QSERDES_V3_TX_RCV_DETECT_LVL_2, 0x12), |
| 947 | QMP_PHY_INIT_CFG(QSERDES_V3_TX_LANE_MODE_1, 0xc6), |
| 948 | QMP_PHY_INIT_CFG(QSERDES_V3_TX_RES_CODE_LANE_OFFSET_RX, 0x06), |
| 949 | QMP_PHY_INIT_CFG(QSERDES_V3_TX_RES_CODE_LANE_OFFSET_TX, 0x06), |
| 950 | }; |
| 951 | |
| 952 | static const struct qmp_phy_init_tbl qmp_v3_usb3_uniphy_rx_tbl[] = { |
| 953 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_VGA_CAL_CNTRL2, 0x0c), |
| 954 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_MODE_00, 0x50), |
| 955 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_FASTLOCK_FO_GAIN, 0x0b), |
| 956 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL2, 0x0e), |
| 957 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL3, 0x4e), |
| 958 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL4, 0x18), |
| 959 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1, 0x77), |
| 960 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_OFFSET_ADAPTOR_CNTRL2, 0x80), |
| 961 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_CNTRL, 0x03), |
| 962 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_DEGLITCH_CNTRL, 0x1c), |
| 963 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x75), |
| 964 | }; |
| 965 | |
| 966 | static const struct qmp_phy_init_tbl qmp_v3_usb3_uniphy_pcs_tbl[] = { |
| 967 | /* FLL settings */ |
| 968 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNTRL2, 0x83), |
| 969 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNT_VAL_L, 0x09), |
| 970 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNT_VAL_H_TOL, 0xa2), |
| 971 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_MAN_CODE, 0x40), |
| 972 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNTRL1, 0x02), |
| 973 | |
| 974 | /* Lock Det settings */ |
| 975 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_LOCK_DETECT_CONFIG1, 0xd1), |
| 976 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_LOCK_DETECT_CONFIG2, 0x1f), |
| 977 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_LOCK_DETECT_CONFIG3, 0x47), |
| 978 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_POWER_STATE_CONFIG2, 0x1b), |
| 979 | |
| 980 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_RX_SIGDET_LVL, 0xba), |
| 981 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_V0, 0x9f), |
| 982 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_V1, 0x9f), |
| 983 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_V2, 0xb5), |
| 984 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_V3, 0x4c), |
| 985 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_V4, 0x64), |
| 986 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_LS, 0x6a), |
| 987 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_V0, 0x15), |
| 988 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_V0, 0x0d), |
| 989 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_V1, 0x15), |
| 990 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_V1, 0x0d), |
| 991 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_V2, 0x15), |
| 992 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_V2, 0x0d), |
| 993 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_V3, 0x15), |
| 994 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_V3, 0x1d), |
| 995 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_V4, 0x15), |
| 996 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_V4, 0x0d), |
| 997 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_LS, 0x15), |
| 998 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_LS, 0x0d), |
| 999 | |
| 1000 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_RATE_SLEW_CNTRL, 0x02), |
| 1001 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_PWRUP_RESET_DLY_TIME_AUXCLK, 0x04), |
| 1002 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TSYNC_RSYNC_TIME, 0x44), |
| 1003 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_PWRUP_RESET_DLY_TIME_AUXCLK, 0x04), |
| 1004 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_RCVR_DTCT_DLY_P1U2_L, 0xe7), |
| 1005 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_RCVR_DTCT_DLY_P1U2_H, 0x03), |
| 1006 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_RCVR_DTCT_DLY_U3_L, 0x40), |
| 1007 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_RCVR_DTCT_DLY_U3_H, 0x00), |
| 1008 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_RXEQTRAINING_WAIT_TIME, 0x75), |
| 1009 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_LFPS_TX_ECSTART_EQTLOCK, 0x86), |
| 1010 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_RXEQTRAINING_RUN_TIME, 0x13), |
| 1011 | |
| 1012 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_REFGEN_REQ_CONFIG1, 0x21), |
| 1013 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_REFGEN_REQ_CONFIG2, 0x60), |
| 1014 | }; |
| 1015 | |
Can Guo | cc31cdb | 2018-09-20 21:27:56 -0700 | [diff] [blame] | 1016 | static const struct qmp_phy_init_tbl sdm845_ufsphy_serdes_tbl[] = { |
| 1017 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYS_CLK_CTRL, 0x02), |
| 1018 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_BIAS_EN_CLKBUFLR_EN, 0x04), |
| 1019 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_BG_TIMER, 0x0a), |
| 1020 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_IVCO, 0x07), |
| 1021 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CMN_CONFIG, 0x06), |
| 1022 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYSCLK_EN_SEL, 0xd5), |
| 1023 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_RESETSM_CNTRL, 0x20), |
| 1024 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_SELECT, 0x30), |
| 1025 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_HSCLK_SEL, 0x00), |
| 1026 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP_EN, 0x01), |
| 1027 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_CTRL, 0x00), |
| 1028 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CORE_CLK_EN, 0x00), |
| 1029 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_MAP, 0x04), |
| 1030 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SVS_MODE_CLK_SEL, 0x05), |
| 1031 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_INITVAL1, 0xff), |
| 1032 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_INITVAL2, 0x00), |
| 1033 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_DEC_START_MODE0, 0x82), |
| 1034 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CP_CTRL_MODE0, 0x06), |
| 1035 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_RCTRL_MODE0, 0x16), |
| 1036 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_CCTRL_MODE0, 0x36), |
| 1037 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN0_MODE0, 0x3f), |
| 1038 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN1_MODE0, 0x00), |
| 1039 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE1_MODE0, 0xda), |
| 1040 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE2_MODE0, 0x01), |
| 1041 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP1_MODE0, 0xff), |
| 1042 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP2_MODE0, 0x0c), |
| 1043 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_DEC_START_MODE1, 0x98), |
| 1044 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CP_CTRL_MODE1, 0x06), |
| 1045 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_RCTRL_MODE1, 0x16), |
| 1046 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_CCTRL_MODE1, 0x36), |
| 1047 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN0_MODE1, 0x3f), |
| 1048 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN1_MODE1, 0x00), |
| 1049 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE1_MODE1, 0xc1), |
| 1050 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE2_MODE1, 0x00), |
| 1051 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP1_MODE1, 0x32), |
| 1052 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP2_MODE1, 0x0f), |
| 1053 | |
| 1054 | /* Rate B */ |
| 1055 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_MAP, 0x44), |
| 1056 | }; |
| 1057 | |
| 1058 | static const struct qmp_phy_init_tbl sdm845_ufsphy_tx_tbl[] = { |
| 1059 | QMP_PHY_INIT_CFG(QSERDES_V3_TX_LANE_MODE_1, 0x06), |
| 1060 | QMP_PHY_INIT_CFG(QSERDES_V3_TX_RES_CODE_LANE_OFFSET_TX, 0x04), |
| 1061 | QMP_PHY_INIT_CFG(QSERDES_V3_TX_RES_CODE_LANE_OFFSET_RX, 0x07), |
| 1062 | }; |
| 1063 | |
| 1064 | static const struct qmp_phy_init_tbl sdm845_ufsphy_rx_tbl[] = { |
| 1065 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_LVL, 0x24), |
| 1066 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_CNTRL, 0x0f), |
| 1067 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_DEGLITCH_CNTRL, 0x1e), |
| 1068 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_INTERFACE_MODE, 0x40), |
| 1069 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_FASTLOCK_FO_GAIN, 0x0b), |
| 1070 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_TERM_BW, 0x5b), |
| 1071 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL2, 0x06), |
| 1072 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL3, 0x04), |
| 1073 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL4, 0x1b), |
| 1074 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SVS_SO_GAIN_HALF, 0x04), |
| 1075 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SVS_SO_GAIN_QUARTER, 0x04), |
| 1076 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SVS_SO_GAIN, 0x04), |
| 1077 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x4b), |
| 1078 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_PI_CONTROLS, 0x81), |
| 1079 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_FASTLOCK_COUNT_LOW, 0x80), |
| 1080 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_MODE_00, 0x59), |
| 1081 | }; |
| 1082 | |
| 1083 | static const struct qmp_phy_init_tbl sdm845_ufsphy_pcs_tbl[] = { |
| 1084 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_RX_SIGDET_CTRL2, 0x6e), |
| 1085 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TX_LARGE_AMP_DRV_LVL, 0x0a), |
| 1086 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TX_SMALL_AMP_DRV_LVL, 0x02), |
| 1087 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_RX_SYM_RESYNC_CTRL, 0x03), |
| 1088 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TX_MID_TERM_CTRL1, 0x43), |
| 1089 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_RX_SIGDET_CTRL1, 0x0f), |
| 1090 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_RX_MIN_HIBERN8_TIME, 0x9a), |
| 1091 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_MULTI_LANE_CTRL1, 0x02), |
| 1092 | }; |
Manu Gautam | f6721e5 | 2018-05-03 02:36:12 +0530 | [diff] [blame] | 1093 | |
Jeffrey Hugo | a51969f | 2019-01-14 09:36:59 -0700 | [diff] [blame] | 1094 | static const struct qmp_phy_init_tbl msm8998_usb3_serdes_tbl[] = { |
| 1095 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_SELECT, 0x30), |
| 1096 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_BIAS_EN_CLKBUFLR_EN, 0x04), |
| 1097 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYSCLK_EN_SEL, 0x14), |
| 1098 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYS_CLK_CTRL, 0x06), |
| 1099 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_RESETSM_CNTRL2, 0x08), |
| 1100 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CMN_CONFIG, 0x06), |
| 1101 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SVS_MODE_CLK_SEL, 0x01), |
| 1102 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_HSCLK_SEL, 0x80), |
| 1103 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_DEC_START_MODE0, 0x82), |
| 1104 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START1_MODE0, 0xab), |
| 1105 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START2_MODE0, 0xea), |
| 1106 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START3_MODE0, 0x02), |
| 1107 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CP_CTRL_MODE0, 0x06), |
| 1108 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_RCTRL_MODE0, 0x16), |
| 1109 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_CCTRL_MODE0, 0x36), |
| 1110 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN1_MODE0, 0x00), |
| 1111 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN0_MODE0, 0x3f), |
| 1112 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE2_MODE0, 0x01), |
| 1113 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE1_MODE0, 0xc9), |
| 1114 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CORECLK_DIV_MODE0, 0x0a), |
| 1115 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP3_MODE0, 0x00), |
| 1116 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP2_MODE0, 0x34), |
| 1117 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP1_MODE0, 0x15), |
| 1118 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP_EN, 0x04), |
| 1119 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CORE_CLK_EN, 0x00), |
| 1120 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP_CFG, 0x00), |
| 1121 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_MAP, 0x00), |
| 1122 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_BG_TIMER, 0x0a), |
| 1123 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_IVCO, 0x07), |
| 1124 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_INITVAL, 0x80), |
| 1125 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_CMN_MODE, 0x01), |
| 1126 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_EN_CENTER, 0x01), |
| 1127 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_PER1, 0x31), |
| 1128 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_PER2, 0x01), |
| 1129 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_ADJ_PER1, 0x00), |
| 1130 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_ADJ_PER2, 0x00), |
| 1131 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_STEP_SIZE1, 0x85), |
| 1132 | QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_STEP_SIZE2, 0x07), |
| 1133 | }; |
| 1134 | |
| 1135 | static const struct qmp_phy_init_tbl msm8998_usb3_tx_tbl[] = { |
| 1136 | QMP_PHY_INIT_CFG(QSERDES_V3_TX_HIGHZ_DRVR_EN, 0x10), |
| 1137 | QMP_PHY_INIT_CFG(QSERDES_V3_TX_RCV_DETECT_LVL_2, 0x12), |
| 1138 | QMP_PHY_INIT_CFG(QSERDES_V3_TX_LANE_MODE_1, 0x16), |
| 1139 | QMP_PHY_INIT_CFG(QSERDES_V3_TX_RES_CODE_LANE_OFFSET_TX, 0x00), |
| 1140 | }; |
| 1141 | |
| 1142 | static const struct qmp_phy_init_tbl msm8998_usb3_rx_tbl[] = { |
| 1143 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_FASTLOCK_FO_GAIN, 0x0b), |
| 1144 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL2, 0x0f), |
| 1145 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL3, 0x4e), |
| 1146 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL4, 0x18), |
| 1147 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1, 0x07), |
| 1148 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_OFFSET_ADAPTOR_CNTRL2, 0x80), |
| 1149 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_CNTRL, 0x43), |
| 1150 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_DEGLITCH_CNTRL, 0x1c), |
| 1151 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x75), |
| 1152 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_FASTLOCK_COUNT_LOW, 0x00), |
| 1153 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_FASTLOCK_COUNT_HIGH, 0x00), |
| 1154 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_PI_CONTROLS, 0x80), |
| 1155 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_FO_GAIN, 0x0a), |
| 1156 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SO_GAIN, 0x06), |
| 1157 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_ENABLES, 0x00), |
| 1158 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_VGA_CAL_CNTRL2, 0x03), |
| 1159 | QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_MODE_00, 0x05), |
| 1160 | }; |
| 1161 | |
| 1162 | static const struct qmp_phy_init_tbl msm8998_usb3_pcs_tbl[] = { |
| 1163 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNTRL2, 0x83), |
| 1164 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNT_VAL_L, 0x09), |
| 1165 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNT_VAL_H_TOL, 0xa2), |
| 1166 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_MAN_CODE, 0x40), |
| 1167 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNTRL1, 0x02), |
| 1168 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_LOCK_DETECT_CONFIG1, 0xd1), |
| 1169 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_LOCK_DETECT_CONFIG2, 0x1f), |
| 1170 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_LOCK_DETECT_CONFIG3, 0x47), |
| 1171 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_POWER_STATE_CONFIG2, 0x1b), |
| 1172 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_V0, 0x9f), |
| 1173 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_V1, 0x9f), |
| 1174 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_V2, 0xb7), |
| 1175 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_V3, 0x4e), |
| 1176 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_V4, 0x65), |
| 1177 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_LS, 0x6b), |
| 1178 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_V0, 0x15), |
| 1179 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_V0, 0x0d), |
| 1180 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TX_LARGE_AMP_DRV_LVL, 0x15), |
| 1181 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_V1, 0x0d), |
| 1182 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_V2, 0x15), |
| 1183 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_V2, 0x0d), |
| 1184 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_V3, 0x15), |
| 1185 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_V3, 0x0d), |
| 1186 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_V4, 0x15), |
| 1187 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_V4, 0x0d), |
| 1188 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_LS, 0x15), |
| 1189 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_LS, 0x0d), |
| 1190 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_RATE_SLEW_CNTRL, 0x02), |
| 1191 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_PWRUP_RESET_DLY_TIME_AUXCLK, 0x04), |
| 1192 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_TSYNC_RSYNC_TIME, 0x44), |
| 1193 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_RCVR_DTCT_DLY_P1U2_L, 0xe7), |
| 1194 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_RCVR_DTCT_DLY_P1U2_H, 0x03), |
| 1195 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_RCVR_DTCT_DLY_U3_L, 0x40), |
| 1196 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_RCVR_DTCT_DLY_U3_H, 0x00), |
| 1197 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_RX_SIGDET_LVL, 0x8a), |
| 1198 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_RXEQTRAINING_WAIT_TIME, 0x75), |
| 1199 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_LFPS_TX_ECSTART_EQTLOCK, 0x86), |
| 1200 | QMP_PHY_INIT_CFG(QPHY_V3_PCS_RXEQTRAINING_RUN_TIME, 0x13), |
| 1201 | }; |
| 1202 | |
Vinod Koul | a88c85e | 2019-10-24 13:18:02 +0530 | [diff] [blame] | 1203 | static const struct qmp_phy_init_tbl sm8150_ufsphy_serdes_tbl[] = { |
Vinod Koul | a88c85e | 2019-10-24 13:18:02 +0530 | [diff] [blame] | 1204 | QMP_PHY_INIT_CFG(QSERDES_V4_COM_SYSCLK_EN_SEL, 0xd9), |
| 1205 | QMP_PHY_INIT_CFG(QSERDES_V4_COM_HSCLK_SEL, 0x11), |
| 1206 | QMP_PHY_INIT_CFG(QSERDES_V4_COM_HSCLK_HS_SWITCH_SEL, 0x00), |
| 1207 | QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP_EN, 0x01), |
| 1208 | QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE_MAP, 0x02), |
| 1209 | QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_IVCO, 0x0f), |
| 1210 | QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE_INITVAL2, 0x00), |
| 1211 | QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_HSCLK_SEL, 0x11), |
| 1212 | QMP_PHY_INIT_CFG(QSERDES_V4_COM_DEC_START_MODE0, 0x82), |
| 1213 | QMP_PHY_INIT_CFG(QSERDES_V4_COM_CP_CTRL_MODE0, 0x06), |
| 1214 | QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_RCTRL_MODE0, 0x16), |
| 1215 | QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_CCTRL_MODE0, 0x36), |
| 1216 | QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP1_MODE0, 0xff), |
| 1217 | QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP2_MODE0, 0x0c), |
| 1218 | QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE1_MODE0, 0xac), |
| 1219 | QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE2_MODE0, 0x1e), |
| 1220 | QMP_PHY_INIT_CFG(QSERDES_V4_COM_DEC_START_MODE1, 0x98), |
| 1221 | QMP_PHY_INIT_CFG(QSERDES_V4_COM_CP_CTRL_MODE1, 0x06), |
| 1222 | QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_RCTRL_MODE1, 0x16), |
| 1223 | QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_CCTRL_MODE1, 0x36), |
| 1224 | QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP1_MODE1, 0x32), |
| 1225 | QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP2_MODE1, 0x0f), |
| 1226 | QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE1_MODE1, 0xdd), |
| 1227 | QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE2_MODE1, 0x23), |
| 1228 | |
| 1229 | /* Rate B */ |
| 1230 | QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE_MAP, 0x06), |
| 1231 | }; |
| 1232 | |
| 1233 | static const struct qmp_phy_init_tbl sm8150_ufsphy_tx_tbl[] = { |
| 1234 | QMP_PHY_INIT_CFG(QSERDES_V4_TX_PWM_GEAR_1_DIVIDER_BAND0_1, 0x06), |
| 1235 | QMP_PHY_INIT_CFG(QSERDES_V4_TX_PWM_GEAR_2_DIVIDER_BAND0_1, 0x03), |
| 1236 | QMP_PHY_INIT_CFG(QSERDES_V4_TX_PWM_GEAR_3_DIVIDER_BAND0_1, 0x01), |
| 1237 | QMP_PHY_INIT_CFG(QSERDES_V4_TX_PWM_GEAR_4_DIVIDER_BAND0_1, 0x00), |
| 1238 | QMP_PHY_INIT_CFG(QSERDES_V4_TX_LANE_MODE_1, 0x05), |
| 1239 | QMP_PHY_INIT_CFG(QSERDES_V4_TX_TRAN_DRVR_EMP_EN, 0x0c), |
| 1240 | }; |
| 1241 | |
| 1242 | static const struct qmp_phy_init_tbl sm8150_ufsphy_rx_tbl[] = { |
| 1243 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_LVL, 0x24), |
| 1244 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_CNTRL, 0x0f), |
| 1245 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_DEGLITCH_CNTRL, 0x1e), |
| 1246 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_BAND, 0x18), |
| 1247 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_FASTLOCK_FO_GAIN, 0x0a), |
| 1248 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x4b), |
| 1249 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_PI_CONTROLS, 0xf1), |
| 1250 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_FASTLOCK_COUNT_LOW, 0x80), |
| 1251 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_PI_CTRL2, 0x80), |
| 1252 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_FO_GAIN, 0x0c), |
| 1253 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SO_GAIN, 0x04), |
| 1254 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_TERM_BW, 0x1b), |
| 1255 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL2, 0x06), |
| 1256 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL3, 0x04), |
| 1257 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL4, 0x1d), |
| 1258 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_OFFSET_ADAPTOR_CNTRL2, 0x00), |
| 1259 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_IDAC_MEASURE_TIME, 0x10), |
| 1260 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_IDAC_TSETTLE_LOW, 0xc0), |
| 1261 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_IDAC_TSETTLE_HIGH, 0x00), |
| 1262 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_LOW, 0x36), |
| 1263 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH, 0x36), |
| 1264 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH2, 0xf6), |
| 1265 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH3, 0x3b), |
| 1266 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH4, 0x3d), |
| 1267 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_LOW, 0xe0), |
| 1268 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH, 0xc8), |
| 1269 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH2, 0xc8), |
| 1270 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH3, 0x3b), |
| 1271 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH4, 0xb1), |
| 1272 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_LOW, 0xe0), |
| 1273 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH, 0xc8), |
| 1274 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH2, 0xc8), |
| 1275 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH3, 0x3b), |
| 1276 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_10_HIGH4, 0xb1), |
| 1277 | |
| 1278 | }; |
| 1279 | |
| 1280 | static const struct qmp_phy_init_tbl sm8150_ufsphy_pcs_tbl[] = { |
| 1281 | QMP_PHY_INIT_CFG(QPHY_V4_RX_SIGDET_CTRL2, 0x6d), |
| 1282 | QMP_PHY_INIT_CFG(QPHY_V4_TX_LARGE_AMP_DRV_LVL, 0x0a), |
| 1283 | QMP_PHY_INIT_CFG(QPHY_V4_TX_SMALL_AMP_DRV_LVL, 0x02), |
| 1284 | QMP_PHY_INIT_CFG(QPHY_V4_TX_MID_TERM_CTRL1, 0x43), |
| 1285 | QMP_PHY_INIT_CFG(QPHY_V4_DEBUG_BUS_CLKSEL, 0x1f), |
| 1286 | QMP_PHY_INIT_CFG(QPHY_V4_RX_MIN_HIBERN8_TIME, 0xff), |
| 1287 | QMP_PHY_INIT_CFG(QPHY_V4_MULTI_LANE_CTRL1, 0x02), |
| 1288 | }; |
Jeffrey Hugo | a51969f | 2019-01-14 09:36:59 -0700 | [diff] [blame] | 1289 | |
Jack Pham | 9a24b92 | 2020-05-04 16:54:25 -0700 | [diff] [blame^] | 1290 | static const struct qmp_phy_init_tbl sm8150_usb3_serdes_tbl[] = { |
| 1291 | QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_EN_CENTER, 0x01), |
| 1292 | QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_PER1, 0x31), |
| 1293 | QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_PER2, 0x01), |
| 1294 | QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_STEP_SIZE1_MODE0, 0xde), |
| 1295 | QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_STEP_SIZE2_MODE0, 0x07), |
| 1296 | QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_STEP_SIZE1_MODE1, 0xde), |
| 1297 | QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_STEP_SIZE2_MODE1, 0x07), |
| 1298 | QMP_PHY_INIT_CFG(QSERDES_V4_COM_SYSCLK_BUF_ENABLE, 0x0a), |
| 1299 | QMP_PHY_INIT_CFG(QSERDES_V4_COM_CMN_IPTRIM, 0x20), |
| 1300 | QMP_PHY_INIT_CFG(QSERDES_V4_COM_CP_CTRL_MODE0, 0x06), |
| 1301 | QMP_PHY_INIT_CFG(QSERDES_V4_COM_CP_CTRL_MODE1, 0x06), |
| 1302 | QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_RCTRL_MODE0, 0x16), |
| 1303 | QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_RCTRL_MODE1, 0x16), |
| 1304 | QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_CCTRL_MODE0, 0x36), |
| 1305 | QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_CCTRL_MODE1, 0x36), |
| 1306 | QMP_PHY_INIT_CFG(QSERDES_V4_COM_SYSCLK_EN_SEL, 0x1a), |
| 1307 | QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP_EN, 0x04), |
| 1308 | QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP1_MODE0, 0x14), |
| 1309 | QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP2_MODE0, 0x34), |
| 1310 | QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP1_MODE1, 0x34), |
| 1311 | QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP2_MODE1, 0x82), |
| 1312 | QMP_PHY_INIT_CFG(QSERDES_V4_COM_DEC_START_MODE0, 0x82), |
| 1313 | QMP_PHY_INIT_CFG(QSERDES_V4_COM_DEC_START_MODE1, 0x82), |
| 1314 | QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START1_MODE0, 0xab), |
| 1315 | QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START2_MODE0, 0xea), |
| 1316 | QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START3_MODE0, 0x02), |
| 1317 | QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE_MAP, 0x02), |
| 1318 | QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START1_MODE1, 0xab), |
| 1319 | QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START2_MODE1, 0xea), |
| 1320 | QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START3_MODE1, 0x02), |
| 1321 | QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE1_MODE0, 0x24), |
| 1322 | QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE1_MODE1, 0x24), |
| 1323 | QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE2_MODE1, 0x02), |
| 1324 | QMP_PHY_INIT_CFG(QSERDES_V4_COM_HSCLK_SEL, 0x01), |
| 1325 | QMP_PHY_INIT_CFG(QSERDES_V4_COM_CORECLK_DIV_MODE1, 0x08), |
| 1326 | QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE1_MODE0, 0xca), |
| 1327 | QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE2_MODE0, 0x1e), |
| 1328 | QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE1_MODE1, 0xca), |
| 1329 | QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE2_MODE1, 0x1e), |
| 1330 | QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_HSCLK_SEL, 0x11), |
| 1331 | }; |
| 1332 | |
| 1333 | static const struct qmp_phy_init_tbl sm8150_usb3_tx_tbl[] = { |
| 1334 | QMP_PHY_INIT_CFG(QSERDES_V4_TX_RES_CODE_LANE_TX, 0x00), |
| 1335 | QMP_PHY_INIT_CFG(QSERDES_V4_TX_RES_CODE_LANE_RX, 0x00), |
| 1336 | QMP_PHY_INIT_CFG(QSERDES_V4_TX_LANE_MODE_1, 0xd5), |
| 1337 | QMP_PHY_INIT_CFG(QSERDES_V4_TX_RCV_DETECT_LVL_2, 0x12), |
| 1338 | QMP_PHY_INIT_CFG(QSERDES_V4_TX_PI_QEC_CTRL, 0x20), |
| 1339 | }; |
| 1340 | |
| 1341 | static const struct qmp_phy_init_tbl sm8150_usb3_rx_tbl[] = { |
| 1342 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SO_GAIN, 0x05), |
| 1343 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_FASTLOCK_FO_GAIN, 0x2f), |
| 1344 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x7f), |
| 1345 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_FASTLOCK_COUNT_LOW, 0xff), |
| 1346 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_FASTLOCK_COUNT_HIGH, 0x0f), |
| 1347 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_PI_CONTROLS, 0x99), |
| 1348 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SB2_THRESH1, 0x04), |
| 1349 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SB2_THRESH2, 0x08), |
| 1350 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SB2_GAIN1, 0x05), |
| 1351 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SB2_GAIN2, 0x05), |
| 1352 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_VGA_CAL_CNTRL1, 0x54), |
| 1353 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_VGA_CAL_CNTRL2, 0x0e), |
| 1354 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL2, 0x0f), |
| 1355 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL3, 0x4a), |
| 1356 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL4, 0x0a), |
| 1357 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_IDAC_TSETTLE_LOW, 0xc0), |
| 1358 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_IDAC_TSETTLE_HIGH, 0x00), |
| 1359 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1, 0x77), |
| 1360 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_CNTRL, 0x04), |
| 1361 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_DEGLITCH_CNTRL, 0x0e), |
| 1362 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_LOW, 0xbf), |
| 1363 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH, 0xbf), |
| 1364 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH2, 0x3f), |
| 1365 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH3, 0x7f), |
| 1366 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH4, 0x94), |
| 1367 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_LOW, 0xdc), |
| 1368 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH, 0xdc), |
| 1369 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH2, 0x5c), |
| 1370 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH3, 0x0b), |
| 1371 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH4, 0xb3), |
| 1372 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_DFE_EN_TIMER, 0x04), |
| 1373 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_DFE_CTLE_POST_CAL_OFFSET, 0x38), |
| 1374 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_AUX_DATA_TCOARSE_TFINE, 0xa0), |
| 1375 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_DCC_CTRL1, 0x0c), |
| 1376 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_GM_CAL, 0x1f), |
| 1377 | QMP_PHY_INIT_CFG(QSERDES_V4_RX_VTH_CODE, 0x10), |
| 1378 | }; |
| 1379 | |
| 1380 | static const struct qmp_phy_init_tbl sm8150_usb3_pcs_tbl[] = { |
| 1381 | /* Lock Det settings */ |
| 1382 | QMP_PHY_INIT_CFG(QPHY_V4_PCS_LOCK_DETECT_CONFIG1, 0xd0), |
| 1383 | QMP_PHY_INIT_CFG(QPHY_V4_PCS_LOCK_DETECT_CONFIG2, 0x07), |
| 1384 | QMP_PHY_INIT_CFG(QPHY_V4_PCS_LOCK_DETECT_CONFIG6, 0x13), |
| 1385 | |
| 1386 | QMP_PHY_INIT_CFG(QPHY_V4_PCS_REFGEN_REQ_CONFIG1, 0x21), |
| 1387 | QMP_PHY_INIT_CFG(QPHY_V4_PCS_RX_SIGDET_LVL, 0xaa), |
| 1388 | QMP_PHY_INIT_CFG(QPHY_V4_PCS_CDR_RESET_TIME, 0x0a), |
| 1389 | QMP_PHY_INIT_CFG(QPHY_V4_PCS_ALIGN_DETECT_CONFIG1, 0x88), |
| 1390 | QMP_PHY_INIT_CFG(QPHY_V4_PCS_ALIGN_DETECT_CONFIG2, 0x13), |
| 1391 | QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCS_TX_RX_CONFIG, 0x0c), |
| 1392 | QMP_PHY_INIT_CFG(QPHY_V4_PCS_EQ_CONFIG1, 0x4b), |
| 1393 | QMP_PHY_INIT_CFG(QPHY_V4_PCS_EQ_CONFIG5, 0x10), |
| 1394 | QMP_PHY_INIT_CFG(QPHY_V4_PCS_USB3_LFPS_DET_HIGH_COUNT_VAL, 0xf8), |
| 1395 | QMP_PHY_INIT_CFG(QPHY_V4_PCS_USB3_RXEQTRAINING_DFE_TIME_S2, 0x07), |
| 1396 | }; |
| 1397 | |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 1398 | /* struct qmp_phy_cfg - per-PHY initialization config */ |
| 1399 | struct qmp_phy_cfg { |
| 1400 | /* phy-type - PCIE/UFS/USB */ |
| 1401 | unsigned int type; |
| 1402 | /* number of lanes provided by phy */ |
| 1403 | int nlanes; |
| 1404 | |
| 1405 | /* Init sequence for PHY blocks - serdes, tx, rx, pcs */ |
| 1406 | const struct qmp_phy_init_tbl *serdes_tbl; |
| 1407 | int serdes_tbl_num; |
| 1408 | const struct qmp_phy_init_tbl *tx_tbl; |
| 1409 | int tx_tbl_num; |
| 1410 | const struct qmp_phy_init_tbl *rx_tbl; |
| 1411 | int rx_tbl_num; |
| 1412 | const struct qmp_phy_init_tbl *pcs_tbl; |
| 1413 | int pcs_tbl_num; |
Bjorn Andersson | 421c9a0 | 2020-01-06 00:18:20 -0800 | [diff] [blame] | 1414 | const struct qmp_phy_init_tbl *pcs_misc_tbl; |
| 1415 | int pcs_misc_tbl_num; |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 1416 | |
| 1417 | /* clock ids to be requested */ |
| 1418 | const char * const *clk_list; |
| 1419 | int num_clks; |
| 1420 | /* resets to be requested */ |
| 1421 | const char * const *reset_list; |
| 1422 | int num_resets; |
| 1423 | /* regulators to be requested */ |
| 1424 | const char * const *vreg_list; |
| 1425 | int num_vregs; |
| 1426 | |
| 1427 | /* array of registers with different offsets */ |
| 1428 | const unsigned int *regs; |
| 1429 | |
| 1430 | unsigned int start_ctrl; |
| 1431 | unsigned int pwrdn_ctrl; |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 1432 | unsigned int mask_com_pcs_ready; |
| 1433 | |
| 1434 | /* true, if PHY has a separate PHY_COM control block */ |
| 1435 | bool has_phy_com_ctrl; |
| 1436 | /* true, if PHY has a reset for individual lanes */ |
| 1437 | bool has_lane_rst; |
| 1438 | /* true, if PHY needs delay after POWER_DOWN */ |
| 1439 | bool has_pwrdn_delay; |
| 1440 | /* power_down delay in usec */ |
| 1441 | int pwrdn_delay_min; |
| 1442 | int pwrdn_delay_max; |
Manu Gautam | efb05a5 | 2018-01-16 16:27:08 +0530 | [diff] [blame] | 1443 | |
| 1444 | /* true, if PHY has a separate DP_COM control block */ |
| 1445 | bool has_phy_dp_com_ctrl; |
Can Guo | 6b04526 | 2018-09-20 21:27:55 -0700 | [diff] [blame] | 1446 | /* true, if PHY has secondary tx/rx lanes to be configured */ |
| 1447 | bool is_dual_lane_phy; |
Can Guo | cc31cdb | 2018-09-20 21:27:56 -0700 | [diff] [blame] | 1448 | |
| 1449 | /* true, if PCS block has no separate SW_RESET register */ |
| 1450 | bool no_pcs_sw_reset; |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 1451 | }; |
| 1452 | |
| 1453 | /** |
| 1454 | * struct qmp_phy - per-lane phy descriptor |
| 1455 | * |
| 1456 | * @phy: generic phy |
| 1457 | * @tx: iomapped memory space for lane's tx |
| 1458 | * @rx: iomapped memory space for lane's rx |
| 1459 | * @pcs: iomapped memory space for lane's pcs |
Evan Green | 5e17b95 | 2018-12-10 11:28:23 -0800 | [diff] [blame] | 1460 | * @tx2: iomapped memory space for second lane's tx (in dual lane PHYs) |
| 1461 | * @rx2: iomapped memory space for second lane's rx (in dual lane PHYs) |
Manu Gautam | ac0d239 | 2018-01-16 16:27:11 +0530 | [diff] [blame] | 1462 | * @pcs_misc: iomapped memory space for lane's pcs_misc |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 1463 | * @pipe_clk: pipe lock |
| 1464 | * @index: lane index |
| 1465 | * @qmp: QMP phy to which this lane belongs |
| 1466 | * @lane_rst: lane's reset controller |
| 1467 | */ |
| 1468 | struct qmp_phy { |
| 1469 | struct phy *phy; |
| 1470 | void __iomem *tx; |
| 1471 | void __iomem *rx; |
| 1472 | void __iomem *pcs; |
Evan Green | 5e17b95 | 2018-12-10 11:28:23 -0800 | [diff] [blame] | 1473 | void __iomem *tx2; |
| 1474 | void __iomem *rx2; |
Manu Gautam | ac0d239 | 2018-01-16 16:27:11 +0530 | [diff] [blame] | 1475 | void __iomem *pcs_misc; |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 1476 | struct clk *pipe_clk; |
| 1477 | unsigned int index; |
| 1478 | struct qcom_qmp *qmp; |
| 1479 | struct reset_control *lane_rst; |
| 1480 | }; |
| 1481 | |
| 1482 | /** |
| 1483 | * struct qcom_qmp - structure holding QMP phy block attributes |
| 1484 | * |
| 1485 | * @dev: device |
| 1486 | * @serdes: iomapped memory space for phy's serdes |
Manu Gautam | efb05a5 | 2018-01-16 16:27:08 +0530 | [diff] [blame] | 1487 | * @dp_com: iomapped memory space for phy's dp_com control block |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 1488 | * |
| 1489 | * @clks: array of clocks required by phy |
| 1490 | * @resets: array of resets required by phy |
| 1491 | * @vregs: regulator supplies bulk data |
| 1492 | * |
| 1493 | * @cfg: phy specific configuration |
| 1494 | * @phys: array of per-lane phy descriptors |
| 1495 | * @phy_mutex: mutex lock for PHY common block initialization |
| 1496 | * @init_count: phy common block initialization count |
Manu Gautam | ac0d239 | 2018-01-16 16:27:11 +0530 | [diff] [blame] | 1497 | * @phy_initialized: indicate if PHY has been initialized |
| 1498 | * @mode: current PHY mode |
Evan Green | c9b5897 | 2019-03-21 10:17:59 -0700 | [diff] [blame] | 1499 | * @ufs_reset: optional UFS PHY reset handle |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 1500 | */ |
| 1501 | struct qcom_qmp { |
| 1502 | struct device *dev; |
| 1503 | void __iomem *serdes; |
Manu Gautam | efb05a5 | 2018-01-16 16:27:08 +0530 | [diff] [blame] | 1504 | void __iomem *dp_com; |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 1505 | |
Vivek Gautam | 10939b1 | 2018-01-16 16:26:57 +0530 | [diff] [blame] | 1506 | struct clk_bulk_data *clks; |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 1507 | struct reset_control **resets; |
| 1508 | struct regulator_bulk_data *vregs; |
| 1509 | |
| 1510 | const struct qmp_phy_cfg *cfg; |
| 1511 | struct qmp_phy **phys; |
| 1512 | |
| 1513 | struct mutex phy_mutex; |
| 1514 | int init_count; |
Manu Gautam | ac0d239 | 2018-01-16 16:27:11 +0530 | [diff] [blame] | 1515 | bool phy_initialized; |
| 1516 | enum phy_mode mode; |
Evan Green | c9b5897 | 2019-03-21 10:17:59 -0700 | [diff] [blame] | 1517 | |
| 1518 | struct reset_control *ufs_reset; |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 1519 | }; |
| 1520 | |
| 1521 | static inline void qphy_setbits(void __iomem *base, u32 offset, u32 val) |
| 1522 | { |
| 1523 | u32 reg; |
| 1524 | |
| 1525 | reg = readl(base + offset); |
| 1526 | reg |= val; |
| 1527 | writel(reg, base + offset); |
| 1528 | |
| 1529 | /* ensure that above write is through */ |
| 1530 | readl(base + offset); |
| 1531 | } |
| 1532 | |
| 1533 | static inline void qphy_clrbits(void __iomem *base, u32 offset, u32 val) |
| 1534 | { |
| 1535 | u32 reg; |
| 1536 | |
| 1537 | reg = readl(base + offset); |
| 1538 | reg &= ~val; |
| 1539 | writel(reg, base + offset); |
| 1540 | |
| 1541 | /* ensure that above write is through */ |
| 1542 | readl(base + offset); |
| 1543 | } |
| 1544 | |
| 1545 | /* list of clocks required by phy */ |
| 1546 | static const char * const msm8996_phy_clk_l[] = { |
| 1547 | "aux", "cfg_ahb", "ref", |
| 1548 | }; |
| 1549 | |
Bjorn Andersson | 0347f0d | 2020-01-24 16:08:03 -0800 | [diff] [blame] | 1550 | static const char * const msm8996_ufs_phy_clk_l[] = { |
| 1551 | "ref", |
| 1552 | }; |
| 1553 | |
Manu Gautam | efb05a5 | 2018-01-16 16:27:08 +0530 | [diff] [blame] | 1554 | static const char * const qmp_v3_phy_clk_l[] = { |
| 1555 | "aux", "cfg_ahb", "ref", "com_aux", |
| 1556 | }; |
| 1557 | |
Bjorn Andersson | 421c9a0 | 2020-01-06 00:18:20 -0800 | [diff] [blame] | 1558 | static const char * const sdm845_pciephy_clk_l[] = { |
| 1559 | "aux", "cfg_ahb", "ref", "refgen", |
| 1560 | }; |
| 1561 | |
Jack Pham | 9a24b92 | 2020-05-04 16:54:25 -0700 | [diff] [blame^] | 1562 | static const char * const qmp_v4_phy_clk_l[] = { |
| 1563 | "aux", "ref_clk_src", "ref", "com_aux", |
| 1564 | }; |
| 1565 | |
Can Guo | cc31cdb | 2018-09-20 21:27:56 -0700 | [diff] [blame] | 1566 | static const char * const sdm845_ufs_phy_clk_l[] = { |
| 1567 | "ref", "ref_aux", |
| 1568 | }; |
| 1569 | |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 1570 | /* list of resets */ |
| 1571 | static const char * const msm8996_pciephy_reset_l[] = { |
| 1572 | "phy", "common", "cfg", |
| 1573 | }; |
| 1574 | |
| 1575 | static const char * const msm8996_usb3phy_reset_l[] = { |
| 1576 | "phy", "common", |
| 1577 | }; |
| 1578 | |
Bjorn Andersson | 421c9a0 | 2020-01-06 00:18:20 -0800 | [diff] [blame] | 1579 | static const char * const sdm845_pciephy_reset_l[] = { |
| 1580 | "phy", |
| 1581 | }; |
| 1582 | |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 1583 | /* list of regulators */ |
Can Guo | 6b04526 | 2018-09-20 21:27:55 -0700 | [diff] [blame] | 1584 | static const char * const qmp_phy_vreg_l[] = { |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 1585 | "vdda-phy", "vdda-pll", |
| 1586 | }; |
| 1587 | |
| 1588 | static const struct qmp_phy_cfg msm8996_pciephy_cfg = { |
| 1589 | .type = PHY_TYPE_PCIE, |
| 1590 | .nlanes = 3, |
| 1591 | |
| 1592 | .serdes_tbl = msm8996_pcie_serdes_tbl, |
| 1593 | .serdes_tbl_num = ARRAY_SIZE(msm8996_pcie_serdes_tbl), |
| 1594 | .tx_tbl = msm8996_pcie_tx_tbl, |
| 1595 | .tx_tbl_num = ARRAY_SIZE(msm8996_pcie_tx_tbl), |
| 1596 | .rx_tbl = msm8996_pcie_rx_tbl, |
| 1597 | .rx_tbl_num = ARRAY_SIZE(msm8996_pcie_rx_tbl), |
| 1598 | .pcs_tbl = msm8996_pcie_pcs_tbl, |
| 1599 | .pcs_tbl_num = ARRAY_SIZE(msm8996_pcie_pcs_tbl), |
| 1600 | .clk_list = msm8996_phy_clk_l, |
| 1601 | .num_clks = ARRAY_SIZE(msm8996_phy_clk_l), |
| 1602 | .reset_list = msm8996_pciephy_reset_l, |
| 1603 | .num_resets = ARRAY_SIZE(msm8996_pciephy_reset_l), |
Can Guo | 6b04526 | 2018-09-20 21:27:55 -0700 | [diff] [blame] | 1604 | .vreg_list = qmp_phy_vreg_l, |
| 1605 | .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 1606 | .regs = pciephy_regs_layout, |
| 1607 | |
| 1608 | .start_ctrl = PCS_START | PLL_READY_GATE_EN, |
| 1609 | .pwrdn_ctrl = SW_PWRDN | REFCLK_DRV_DSBL, |
| 1610 | .mask_com_pcs_ready = PCS_READY, |
| 1611 | |
| 1612 | .has_phy_com_ctrl = true, |
| 1613 | .has_lane_rst = true, |
| 1614 | .has_pwrdn_delay = true, |
| 1615 | .pwrdn_delay_min = POWER_DOWN_DELAY_US_MIN, |
| 1616 | .pwrdn_delay_max = POWER_DOWN_DELAY_US_MAX, |
| 1617 | }; |
| 1618 | |
Bjorn Andersson | 0347f0d | 2020-01-24 16:08:03 -0800 | [diff] [blame] | 1619 | static const struct qmp_phy_cfg msm8996_ufs_cfg = { |
| 1620 | .type = PHY_TYPE_UFS, |
| 1621 | .nlanes = 1, |
| 1622 | |
| 1623 | .serdes_tbl = msm8996_ufs_serdes_tbl, |
| 1624 | .serdes_tbl_num = ARRAY_SIZE(msm8996_ufs_serdes_tbl), |
| 1625 | .tx_tbl = msm8996_ufs_tx_tbl, |
| 1626 | .tx_tbl_num = ARRAY_SIZE(msm8996_ufs_tx_tbl), |
| 1627 | .rx_tbl = msm8996_ufs_rx_tbl, |
| 1628 | .rx_tbl_num = ARRAY_SIZE(msm8996_ufs_rx_tbl), |
| 1629 | |
| 1630 | .clk_list = msm8996_ufs_phy_clk_l, |
| 1631 | .num_clks = ARRAY_SIZE(msm8996_ufs_phy_clk_l), |
| 1632 | |
| 1633 | .vreg_list = qmp_phy_vreg_l, |
| 1634 | .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), |
| 1635 | |
| 1636 | .regs = msm8996_ufsphy_regs_layout, |
| 1637 | |
| 1638 | .start_ctrl = SERDES_START, |
| 1639 | .pwrdn_ctrl = SW_PWRDN, |
| 1640 | |
| 1641 | .no_pcs_sw_reset = true, |
| 1642 | }; |
| 1643 | |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 1644 | static const struct qmp_phy_cfg msm8996_usb3phy_cfg = { |
| 1645 | .type = PHY_TYPE_USB3, |
| 1646 | .nlanes = 1, |
| 1647 | |
| 1648 | .serdes_tbl = msm8996_usb3_serdes_tbl, |
| 1649 | .serdes_tbl_num = ARRAY_SIZE(msm8996_usb3_serdes_tbl), |
| 1650 | .tx_tbl = msm8996_usb3_tx_tbl, |
| 1651 | .tx_tbl_num = ARRAY_SIZE(msm8996_usb3_tx_tbl), |
| 1652 | .rx_tbl = msm8996_usb3_rx_tbl, |
| 1653 | .rx_tbl_num = ARRAY_SIZE(msm8996_usb3_rx_tbl), |
| 1654 | .pcs_tbl = msm8996_usb3_pcs_tbl, |
| 1655 | .pcs_tbl_num = ARRAY_SIZE(msm8996_usb3_pcs_tbl), |
| 1656 | .clk_list = msm8996_phy_clk_l, |
| 1657 | .num_clks = ARRAY_SIZE(msm8996_phy_clk_l), |
| 1658 | .reset_list = msm8996_usb3phy_reset_l, |
| 1659 | .num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l), |
Can Guo | 6b04526 | 2018-09-20 21:27:55 -0700 | [diff] [blame] | 1660 | .vreg_list = qmp_phy_vreg_l, |
| 1661 | .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 1662 | .regs = usb3phy_regs_layout, |
| 1663 | |
| 1664 | .start_ctrl = SERDES_START | PCS_START, |
| 1665 | .pwrdn_ctrl = SW_PWRDN, |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 1666 | }; |
| 1667 | |
Varadarajan Narayanan | eef243d | 2017-07-31 12:04:14 +0530 | [diff] [blame] | 1668 | /* list of resets */ |
| 1669 | static const char * const ipq8074_pciephy_reset_l[] = { |
| 1670 | "phy", "common", |
| 1671 | }; |
| 1672 | |
| 1673 | static const struct qmp_phy_cfg ipq8074_pciephy_cfg = { |
| 1674 | .type = PHY_TYPE_PCIE, |
| 1675 | .nlanes = 1, |
| 1676 | |
| 1677 | .serdes_tbl = ipq8074_pcie_serdes_tbl, |
| 1678 | .serdes_tbl_num = ARRAY_SIZE(ipq8074_pcie_serdes_tbl), |
| 1679 | .tx_tbl = ipq8074_pcie_tx_tbl, |
| 1680 | .tx_tbl_num = ARRAY_SIZE(ipq8074_pcie_tx_tbl), |
| 1681 | .rx_tbl = ipq8074_pcie_rx_tbl, |
| 1682 | .rx_tbl_num = ARRAY_SIZE(ipq8074_pcie_rx_tbl), |
| 1683 | .pcs_tbl = ipq8074_pcie_pcs_tbl, |
| 1684 | .pcs_tbl_num = ARRAY_SIZE(ipq8074_pcie_pcs_tbl), |
| 1685 | .clk_list = NULL, |
| 1686 | .num_clks = 0, |
| 1687 | .reset_list = ipq8074_pciephy_reset_l, |
| 1688 | .num_resets = ARRAY_SIZE(ipq8074_pciephy_reset_l), |
| 1689 | .vreg_list = NULL, |
| 1690 | .num_vregs = 0, |
| 1691 | .regs = pciephy_regs_layout, |
| 1692 | |
| 1693 | .start_ctrl = SERDES_START | PCS_START, |
| 1694 | .pwrdn_ctrl = SW_PWRDN | REFCLK_DRV_DSBL, |
Varadarajan Narayanan | eef243d | 2017-07-31 12:04:14 +0530 | [diff] [blame] | 1695 | |
| 1696 | .has_phy_com_ctrl = false, |
| 1697 | .has_lane_rst = false, |
| 1698 | .has_pwrdn_delay = true, |
| 1699 | .pwrdn_delay_min = 995, /* us */ |
| 1700 | .pwrdn_delay_max = 1005, /* us */ |
| 1701 | }; |
| 1702 | |
Bjorn Andersson | 421c9a0 | 2020-01-06 00:18:20 -0800 | [diff] [blame] | 1703 | static const struct qmp_phy_cfg sdm845_qmp_pciephy_cfg = { |
| 1704 | .type = PHY_TYPE_PCIE, |
| 1705 | .nlanes = 1, |
| 1706 | |
| 1707 | .serdes_tbl = sdm845_qmp_pcie_serdes_tbl, |
| 1708 | .serdes_tbl_num = ARRAY_SIZE(sdm845_qmp_pcie_serdes_tbl), |
| 1709 | .tx_tbl = sdm845_qmp_pcie_tx_tbl, |
| 1710 | .tx_tbl_num = ARRAY_SIZE(sdm845_qmp_pcie_tx_tbl), |
| 1711 | .rx_tbl = sdm845_qmp_pcie_rx_tbl, |
| 1712 | .rx_tbl_num = ARRAY_SIZE(sdm845_qmp_pcie_rx_tbl), |
| 1713 | .pcs_tbl = sdm845_qmp_pcie_pcs_tbl, |
| 1714 | .pcs_tbl_num = ARRAY_SIZE(sdm845_qmp_pcie_pcs_tbl), |
| 1715 | .pcs_misc_tbl = sdm845_qmp_pcie_pcs_misc_tbl, |
| 1716 | .pcs_misc_tbl_num = ARRAY_SIZE(sdm845_qmp_pcie_pcs_misc_tbl), |
| 1717 | .clk_list = sdm845_pciephy_clk_l, |
| 1718 | .num_clks = ARRAY_SIZE(sdm845_pciephy_clk_l), |
| 1719 | .reset_list = sdm845_pciephy_reset_l, |
| 1720 | .num_resets = ARRAY_SIZE(sdm845_pciephy_reset_l), |
| 1721 | .vreg_list = qmp_phy_vreg_l, |
| 1722 | .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), |
| 1723 | .regs = sdm845_qmp_pciephy_regs_layout, |
| 1724 | |
| 1725 | .start_ctrl = PCS_START | SERDES_START, |
| 1726 | .pwrdn_ctrl = SW_PWRDN | REFCLK_DRV_DSBL, |
| 1727 | |
| 1728 | .has_pwrdn_delay = true, |
| 1729 | .pwrdn_delay_min = 995, /* us */ |
| 1730 | .pwrdn_delay_max = 1005, /* us */ |
| 1731 | }; |
| 1732 | |
Bjorn Andersson | 909a5c7 | 2020-01-06 00:18:21 -0800 | [diff] [blame] | 1733 | static const struct qmp_phy_cfg sdm845_qhp_pciephy_cfg = { |
| 1734 | .type = PHY_TYPE_PCIE, |
| 1735 | .nlanes = 1, |
| 1736 | |
| 1737 | .serdes_tbl = sdm845_qhp_pcie_serdes_tbl, |
| 1738 | .serdes_tbl_num = ARRAY_SIZE(sdm845_qhp_pcie_serdes_tbl), |
| 1739 | .tx_tbl = sdm845_qhp_pcie_tx_tbl, |
| 1740 | .tx_tbl_num = ARRAY_SIZE(sdm845_qhp_pcie_tx_tbl), |
| 1741 | .rx_tbl = sdm845_qhp_pcie_rx_tbl, |
| 1742 | .rx_tbl_num = ARRAY_SIZE(sdm845_qhp_pcie_rx_tbl), |
| 1743 | .pcs_tbl = sdm845_qhp_pcie_pcs_tbl, |
| 1744 | .pcs_tbl_num = ARRAY_SIZE(sdm845_qhp_pcie_pcs_tbl), |
| 1745 | .clk_list = sdm845_pciephy_clk_l, |
| 1746 | .num_clks = ARRAY_SIZE(sdm845_pciephy_clk_l), |
| 1747 | .reset_list = sdm845_pciephy_reset_l, |
| 1748 | .num_resets = ARRAY_SIZE(sdm845_pciephy_reset_l), |
| 1749 | .vreg_list = qmp_phy_vreg_l, |
| 1750 | .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), |
| 1751 | .regs = sdm845_qhp_pciephy_regs_layout, |
| 1752 | |
| 1753 | .start_ctrl = PCS_START | SERDES_START, |
| 1754 | .pwrdn_ctrl = SW_PWRDN | REFCLK_DRV_DSBL, |
| 1755 | |
| 1756 | .has_pwrdn_delay = true, |
| 1757 | .pwrdn_delay_min = 995, /* us */ |
| 1758 | .pwrdn_delay_max = 1005, /* us */ |
| 1759 | }; |
| 1760 | |
Manu Gautam | efb05a5 | 2018-01-16 16:27:08 +0530 | [diff] [blame] | 1761 | static const struct qmp_phy_cfg qmp_v3_usb3phy_cfg = { |
| 1762 | .type = PHY_TYPE_USB3, |
| 1763 | .nlanes = 1, |
| 1764 | |
| 1765 | .serdes_tbl = qmp_v3_usb3_serdes_tbl, |
| 1766 | .serdes_tbl_num = ARRAY_SIZE(qmp_v3_usb3_serdes_tbl), |
| 1767 | .tx_tbl = qmp_v3_usb3_tx_tbl, |
| 1768 | .tx_tbl_num = ARRAY_SIZE(qmp_v3_usb3_tx_tbl), |
| 1769 | .rx_tbl = qmp_v3_usb3_rx_tbl, |
| 1770 | .rx_tbl_num = ARRAY_SIZE(qmp_v3_usb3_rx_tbl), |
| 1771 | .pcs_tbl = qmp_v3_usb3_pcs_tbl, |
| 1772 | .pcs_tbl_num = ARRAY_SIZE(qmp_v3_usb3_pcs_tbl), |
| 1773 | .clk_list = qmp_v3_phy_clk_l, |
| 1774 | .num_clks = ARRAY_SIZE(qmp_v3_phy_clk_l), |
| 1775 | .reset_list = msm8996_usb3phy_reset_l, |
| 1776 | .num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l), |
Can Guo | 6b04526 | 2018-09-20 21:27:55 -0700 | [diff] [blame] | 1777 | .vreg_list = qmp_phy_vreg_l, |
| 1778 | .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), |
Manu Gautam | efb05a5 | 2018-01-16 16:27:08 +0530 | [diff] [blame] | 1779 | .regs = qmp_v3_usb3phy_regs_layout, |
| 1780 | |
| 1781 | .start_ctrl = SERDES_START | PCS_START, |
| 1782 | .pwrdn_ctrl = SW_PWRDN, |
Manu Gautam | efb05a5 | 2018-01-16 16:27:08 +0530 | [diff] [blame] | 1783 | |
Manu Gautam | f6721e5 | 2018-05-03 02:36:12 +0530 | [diff] [blame] | 1784 | .has_pwrdn_delay = true, |
Manu Gautam | efb05a5 | 2018-01-16 16:27:08 +0530 | [diff] [blame] | 1785 | .pwrdn_delay_min = POWER_DOWN_DELAY_US_MIN, |
| 1786 | .pwrdn_delay_max = POWER_DOWN_DELAY_US_MAX, |
| 1787 | |
| 1788 | .has_phy_dp_com_ctrl = true, |
Can Guo | 6b04526 | 2018-09-20 21:27:55 -0700 | [diff] [blame] | 1789 | .is_dual_lane_phy = true, |
Manu Gautam | efb05a5 | 2018-01-16 16:27:08 +0530 | [diff] [blame] | 1790 | }; |
| 1791 | |
Manu Gautam | f6721e5 | 2018-05-03 02:36:12 +0530 | [diff] [blame] | 1792 | static const struct qmp_phy_cfg qmp_v3_usb3_uniphy_cfg = { |
| 1793 | .type = PHY_TYPE_USB3, |
| 1794 | .nlanes = 1, |
| 1795 | |
| 1796 | .serdes_tbl = qmp_v3_usb3_uniphy_serdes_tbl, |
| 1797 | .serdes_tbl_num = ARRAY_SIZE(qmp_v3_usb3_uniphy_serdes_tbl), |
| 1798 | .tx_tbl = qmp_v3_usb3_uniphy_tx_tbl, |
| 1799 | .tx_tbl_num = ARRAY_SIZE(qmp_v3_usb3_uniphy_tx_tbl), |
| 1800 | .rx_tbl = qmp_v3_usb3_uniphy_rx_tbl, |
| 1801 | .rx_tbl_num = ARRAY_SIZE(qmp_v3_usb3_uniphy_rx_tbl), |
| 1802 | .pcs_tbl = qmp_v3_usb3_uniphy_pcs_tbl, |
| 1803 | .pcs_tbl_num = ARRAY_SIZE(qmp_v3_usb3_uniphy_pcs_tbl), |
| 1804 | .clk_list = qmp_v3_phy_clk_l, |
| 1805 | .num_clks = ARRAY_SIZE(qmp_v3_phy_clk_l), |
| 1806 | .reset_list = msm8996_usb3phy_reset_l, |
| 1807 | .num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l), |
Can Guo | 6b04526 | 2018-09-20 21:27:55 -0700 | [diff] [blame] | 1808 | .vreg_list = qmp_phy_vreg_l, |
| 1809 | .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), |
Manu Gautam | f6721e5 | 2018-05-03 02:36:12 +0530 | [diff] [blame] | 1810 | .regs = qmp_v3_usb3phy_regs_layout, |
| 1811 | |
| 1812 | .start_ctrl = SERDES_START | PCS_START, |
| 1813 | .pwrdn_ctrl = SW_PWRDN, |
Manu Gautam | f6721e5 | 2018-05-03 02:36:12 +0530 | [diff] [blame] | 1814 | |
| 1815 | .has_pwrdn_delay = true, |
| 1816 | .pwrdn_delay_min = POWER_DOWN_DELAY_US_MIN, |
| 1817 | .pwrdn_delay_max = POWER_DOWN_DELAY_US_MAX, |
| 1818 | }; |
| 1819 | |
Can Guo | cc31cdb | 2018-09-20 21:27:56 -0700 | [diff] [blame] | 1820 | static const struct qmp_phy_cfg sdm845_ufsphy_cfg = { |
| 1821 | .type = PHY_TYPE_UFS, |
| 1822 | .nlanes = 2, |
| 1823 | |
| 1824 | .serdes_tbl = sdm845_ufsphy_serdes_tbl, |
| 1825 | .serdes_tbl_num = ARRAY_SIZE(sdm845_ufsphy_serdes_tbl), |
| 1826 | .tx_tbl = sdm845_ufsphy_tx_tbl, |
| 1827 | .tx_tbl_num = ARRAY_SIZE(sdm845_ufsphy_tx_tbl), |
| 1828 | .rx_tbl = sdm845_ufsphy_rx_tbl, |
| 1829 | .rx_tbl_num = ARRAY_SIZE(sdm845_ufsphy_rx_tbl), |
| 1830 | .pcs_tbl = sdm845_ufsphy_pcs_tbl, |
| 1831 | .pcs_tbl_num = ARRAY_SIZE(sdm845_ufsphy_pcs_tbl), |
| 1832 | .clk_list = sdm845_ufs_phy_clk_l, |
| 1833 | .num_clks = ARRAY_SIZE(sdm845_ufs_phy_clk_l), |
| 1834 | .vreg_list = qmp_phy_vreg_l, |
| 1835 | .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), |
| 1836 | .regs = sdm845_ufsphy_regs_layout, |
| 1837 | |
| 1838 | .start_ctrl = SERDES_START, |
| 1839 | .pwrdn_ctrl = SW_PWRDN, |
Can Guo | cc31cdb | 2018-09-20 21:27:56 -0700 | [diff] [blame] | 1840 | |
| 1841 | .is_dual_lane_phy = true, |
Can Guo | cc31cdb | 2018-09-20 21:27:56 -0700 | [diff] [blame] | 1842 | .no_pcs_sw_reset = true, |
| 1843 | }; |
| 1844 | |
Marc Gonzalez | 73d7ec8 | 2019-04-09 14:48:22 +0200 | [diff] [blame] | 1845 | static const struct qmp_phy_cfg msm8998_pciephy_cfg = { |
| 1846 | .type = PHY_TYPE_PCIE, |
| 1847 | .nlanes = 1, |
| 1848 | |
| 1849 | .serdes_tbl = msm8998_pcie_serdes_tbl, |
| 1850 | .serdes_tbl_num = ARRAY_SIZE(msm8998_pcie_serdes_tbl), |
| 1851 | .tx_tbl = msm8998_pcie_tx_tbl, |
| 1852 | .tx_tbl_num = ARRAY_SIZE(msm8998_pcie_tx_tbl), |
| 1853 | .rx_tbl = msm8998_pcie_rx_tbl, |
| 1854 | .rx_tbl_num = ARRAY_SIZE(msm8998_pcie_rx_tbl), |
| 1855 | .pcs_tbl = msm8998_pcie_pcs_tbl, |
| 1856 | .pcs_tbl_num = ARRAY_SIZE(msm8998_pcie_pcs_tbl), |
| 1857 | .clk_list = msm8996_phy_clk_l, |
| 1858 | .num_clks = ARRAY_SIZE(msm8996_phy_clk_l), |
| 1859 | .reset_list = ipq8074_pciephy_reset_l, |
| 1860 | .num_resets = ARRAY_SIZE(ipq8074_pciephy_reset_l), |
| 1861 | .vreg_list = qmp_phy_vreg_l, |
| 1862 | .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), |
| 1863 | .regs = pciephy_regs_layout, |
| 1864 | |
| 1865 | .start_ctrl = SERDES_START | PCS_START, |
| 1866 | .pwrdn_ctrl = SW_PWRDN | REFCLK_DRV_DSBL, |
Marc Gonzalez | 73d7ec8 | 2019-04-09 14:48:22 +0200 | [diff] [blame] | 1867 | }; |
| 1868 | |
Jeffrey Hugo | a51969f | 2019-01-14 09:36:59 -0700 | [diff] [blame] | 1869 | static const struct qmp_phy_cfg msm8998_usb3phy_cfg = { |
| 1870 | .type = PHY_TYPE_USB3, |
| 1871 | .nlanes = 1, |
| 1872 | |
| 1873 | .serdes_tbl = msm8998_usb3_serdes_tbl, |
| 1874 | .serdes_tbl_num = ARRAY_SIZE(msm8998_usb3_serdes_tbl), |
| 1875 | .tx_tbl = msm8998_usb3_tx_tbl, |
| 1876 | .tx_tbl_num = ARRAY_SIZE(msm8998_usb3_tx_tbl), |
| 1877 | .rx_tbl = msm8998_usb3_rx_tbl, |
| 1878 | .rx_tbl_num = ARRAY_SIZE(msm8998_usb3_rx_tbl), |
| 1879 | .pcs_tbl = msm8998_usb3_pcs_tbl, |
| 1880 | .pcs_tbl_num = ARRAY_SIZE(msm8998_usb3_pcs_tbl), |
| 1881 | .clk_list = msm8996_phy_clk_l, |
| 1882 | .num_clks = ARRAY_SIZE(msm8996_phy_clk_l), |
| 1883 | .reset_list = msm8996_usb3phy_reset_l, |
| 1884 | .num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l), |
| 1885 | .vreg_list = qmp_phy_vreg_l, |
| 1886 | .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), |
| 1887 | .regs = qmp_v3_usb3phy_regs_layout, |
| 1888 | |
| 1889 | .start_ctrl = SERDES_START | PCS_START, |
| 1890 | .pwrdn_ctrl = SW_PWRDN, |
Jeffrey Hugo | a51969f | 2019-01-14 09:36:59 -0700 | [diff] [blame] | 1891 | |
| 1892 | .is_dual_lane_phy = true, |
| 1893 | }; |
| 1894 | |
Vinod Koul | a88c85e | 2019-10-24 13:18:02 +0530 | [diff] [blame] | 1895 | static const struct qmp_phy_cfg sm8150_ufsphy_cfg = { |
| 1896 | .type = PHY_TYPE_UFS, |
| 1897 | .nlanes = 2, |
| 1898 | |
| 1899 | .serdes_tbl = sm8150_ufsphy_serdes_tbl, |
| 1900 | .serdes_tbl_num = ARRAY_SIZE(sm8150_ufsphy_serdes_tbl), |
| 1901 | .tx_tbl = sm8150_ufsphy_tx_tbl, |
| 1902 | .tx_tbl_num = ARRAY_SIZE(sm8150_ufsphy_tx_tbl), |
| 1903 | .rx_tbl = sm8150_ufsphy_rx_tbl, |
| 1904 | .rx_tbl_num = ARRAY_SIZE(sm8150_ufsphy_rx_tbl), |
| 1905 | .pcs_tbl = sm8150_ufsphy_pcs_tbl, |
| 1906 | .pcs_tbl_num = ARRAY_SIZE(sm8150_ufsphy_pcs_tbl), |
| 1907 | .clk_list = sdm845_ufs_phy_clk_l, |
| 1908 | .num_clks = ARRAY_SIZE(sdm845_ufs_phy_clk_l), |
| 1909 | .vreg_list = qmp_phy_vreg_l, |
| 1910 | .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), |
| 1911 | .regs = sm8150_ufsphy_regs_layout, |
| 1912 | |
| 1913 | .start_ctrl = SERDES_START, |
| 1914 | .pwrdn_ctrl = SW_PWRDN, |
| 1915 | |
| 1916 | .is_dual_lane_phy = true, |
Vinod Koul | a88c85e | 2019-10-24 13:18:02 +0530 | [diff] [blame] | 1917 | }; |
| 1918 | |
Jack Pham | 9a24b92 | 2020-05-04 16:54:25 -0700 | [diff] [blame^] | 1919 | static const struct qmp_phy_cfg sm8150_usb3phy_cfg = { |
| 1920 | .type = PHY_TYPE_USB3, |
| 1921 | .nlanes = 1, |
| 1922 | |
| 1923 | .serdes_tbl = sm8150_usb3_serdes_tbl, |
| 1924 | .serdes_tbl_num = ARRAY_SIZE(sm8150_usb3_serdes_tbl), |
| 1925 | .tx_tbl = sm8150_usb3_tx_tbl, |
| 1926 | .tx_tbl_num = ARRAY_SIZE(sm8150_usb3_tx_tbl), |
| 1927 | .rx_tbl = sm8150_usb3_rx_tbl, |
| 1928 | .rx_tbl_num = ARRAY_SIZE(sm8150_usb3_rx_tbl), |
| 1929 | .pcs_tbl = sm8150_usb3_pcs_tbl, |
| 1930 | .pcs_tbl_num = ARRAY_SIZE(sm8150_usb3_pcs_tbl), |
| 1931 | .clk_list = qmp_v4_phy_clk_l, |
| 1932 | .num_clks = ARRAY_SIZE(qmp_v4_phy_clk_l), |
| 1933 | .reset_list = msm8996_usb3phy_reset_l, |
| 1934 | .num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l), |
| 1935 | .vreg_list = qmp_phy_vreg_l, |
| 1936 | .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), |
| 1937 | .regs = qmp_v4_usb3phy_regs_layout, |
| 1938 | |
| 1939 | .start_ctrl = SERDES_START | PCS_START, |
| 1940 | .pwrdn_ctrl = SW_PWRDN, |
| 1941 | |
| 1942 | .has_pwrdn_delay = true, |
| 1943 | .pwrdn_delay_min = POWER_DOWN_DELAY_US_MIN, |
| 1944 | .pwrdn_delay_max = POWER_DOWN_DELAY_US_MAX, |
| 1945 | |
| 1946 | .has_phy_dp_com_ctrl = true, |
| 1947 | .is_dual_lane_phy = true, |
| 1948 | }; |
| 1949 | |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 1950 | static void qcom_qmp_phy_configure(void __iomem *base, |
| 1951 | const unsigned int *regs, |
| 1952 | const struct qmp_phy_init_tbl tbl[], |
| 1953 | int num) |
| 1954 | { |
| 1955 | int i; |
| 1956 | const struct qmp_phy_init_tbl *t = tbl; |
| 1957 | |
| 1958 | if (!t) |
| 1959 | return; |
| 1960 | |
| 1961 | for (i = 0; i < num; i++, t++) { |
| 1962 | if (t->in_layout) |
| 1963 | writel(t->val, base + regs[t->offset]); |
| 1964 | else |
| 1965 | writel(t->val, base + t->offset); |
| 1966 | } |
| 1967 | } |
| 1968 | |
Can Guo | 0d58280 | 2018-09-20 21:27:54 -0700 | [diff] [blame] | 1969 | static int qcom_qmp_phy_com_init(struct qmp_phy *qphy) |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 1970 | { |
Can Guo | 0d58280 | 2018-09-20 21:27:54 -0700 | [diff] [blame] | 1971 | struct qcom_qmp *qmp = qphy->qmp; |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 1972 | const struct qmp_phy_cfg *cfg = qmp->cfg; |
| 1973 | void __iomem *serdes = qmp->serdes; |
Can Guo | 0d58280 | 2018-09-20 21:27:54 -0700 | [diff] [blame] | 1974 | void __iomem *pcs = qphy->pcs; |
Manu Gautam | efb05a5 | 2018-01-16 16:27:08 +0530 | [diff] [blame] | 1975 | void __iomem *dp_com = qmp->dp_com; |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 1976 | int ret, i; |
| 1977 | |
| 1978 | mutex_lock(&qmp->phy_mutex); |
| 1979 | if (qmp->init_count++) { |
| 1980 | mutex_unlock(&qmp->phy_mutex); |
| 1981 | return 0; |
| 1982 | } |
| 1983 | |
Manu Gautam | 717dab9 | 2018-01-16 16:26:58 +0530 | [diff] [blame] | 1984 | /* turn on regulator supplies */ |
| 1985 | ret = regulator_bulk_enable(cfg->num_vregs, qmp->vregs); |
| 1986 | if (ret) { |
| 1987 | dev_err(qmp->dev, "failed to enable regulators, err=%d\n", ret); |
| 1988 | goto err_reg_enable; |
| 1989 | } |
| 1990 | |
Manu Gautam | c6549f0 | 2018-01-16 16:27:00 +0530 | [diff] [blame] | 1991 | for (i = 0; i < cfg->num_resets; i++) { |
| 1992 | ret = reset_control_assert(qmp->resets[i]); |
| 1993 | if (ret) { |
| 1994 | dev_err(qmp->dev, "%s reset assert failed\n", |
| 1995 | cfg->reset_list[i]); |
| 1996 | goto err_rst_assert; |
| 1997 | } |
Manu Gautam | 717dab9 | 2018-01-16 16:26:58 +0530 | [diff] [blame] | 1998 | } |
| 1999 | |
Manu Gautam | c6549f0 | 2018-01-16 16:27:00 +0530 | [diff] [blame] | 2000 | for (i = cfg->num_resets - 1; i >= 0; i--) { |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 2001 | ret = reset_control_deassert(qmp->resets[i]); |
| 2002 | if (ret) { |
| 2003 | dev_err(qmp->dev, "%s reset deassert failed\n", |
| 2004 | qmp->cfg->reset_list[i]); |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 2005 | goto err_rst; |
| 2006 | } |
| 2007 | } |
| 2008 | |
Manu Gautam | c6549f0 | 2018-01-16 16:27:00 +0530 | [diff] [blame] | 2009 | ret = clk_bulk_prepare_enable(cfg->num_clks, qmp->clks); |
| 2010 | if (ret) { |
| 2011 | dev_err(qmp->dev, "failed to enable clks, err=%d\n", ret); |
| 2012 | goto err_rst; |
| 2013 | } |
| 2014 | |
Manu Gautam | efb05a5 | 2018-01-16 16:27:08 +0530 | [diff] [blame] | 2015 | if (cfg->has_phy_dp_com_ctrl) { |
| 2016 | qphy_setbits(dp_com, QPHY_V3_DP_COM_POWER_DOWN_CTRL, |
| 2017 | SW_PWRDN); |
| 2018 | /* override hardware control for reset of qmp phy */ |
| 2019 | qphy_setbits(dp_com, QPHY_V3_DP_COM_RESET_OVRD_CTRL, |
| 2020 | SW_DPPHY_RESET_MUX | SW_DPPHY_RESET | |
| 2021 | SW_USB3PHY_RESET_MUX | SW_USB3PHY_RESET); |
| 2022 | |
| 2023 | qphy_setbits(dp_com, QPHY_V3_DP_COM_PHY_MODE_CTRL, |
| 2024 | USB3_MODE | DP_MODE); |
| 2025 | |
| 2026 | /* bring both QMP USB and QMP DP PHYs PCS block out of reset */ |
| 2027 | qphy_clrbits(dp_com, QPHY_V3_DP_COM_RESET_OVRD_CTRL, |
| 2028 | SW_DPPHY_RESET_MUX | SW_DPPHY_RESET | |
| 2029 | SW_USB3PHY_RESET_MUX | SW_USB3PHY_RESET); |
| 2030 | } |
| 2031 | |
Can Guo | 0d58280 | 2018-09-20 21:27:54 -0700 | [diff] [blame] | 2032 | if (cfg->has_phy_com_ctrl) |
| 2033 | qphy_setbits(serdes, cfg->regs[QPHY_COM_POWER_DOWN_CONTROL], |
| 2034 | SW_PWRDN); |
| 2035 | else |
| 2036 | qphy_setbits(pcs, QPHY_POWER_DOWN_CONTROL, cfg->pwrdn_ctrl); |
| 2037 | |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 2038 | /* Serdes configuration */ |
| 2039 | qcom_qmp_phy_configure(serdes, cfg->regs, cfg->serdes_tbl, |
| 2040 | cfg->serdes_tbl_num); |
| 2041 | |
| 2042 | if (cfg->has_phy_com_ctrl) { |
| 2043 | void __iomem *status; |
| 2044 | unsigned int mask, val; |
| 2045 | |
| 2046 | qphy_clrbits(serdes, cfg->regs[QPHY_COM_SW_RESET], SW_RESET); |
| 2047 | qphy_setbits(serdes, cfg->regs[QPHY_COM_START_CONTROL], |
| 2048 | SERDES_START | PCS_START); |
| 2049 | |
| 2050 | status = serdes + cfg->regs[QPHY_COM_PCS_READY_STATUS]; |
| 2051 | mask = cfg->mask_com_pcs_ready; |
| 2052 | |
| 2053 | ret = readl_poll_timeout(status, val, (val & mask), 10, |
| 2054 | PHY_INIT_COMPLETE_TIMEOUT); |
| 2055 | if (ret) { |
| 2056 | dev_err(qmp->dev, |
| 2057 | "phy common block init timed-out\n"); |
Manu Gautam | c6549f0 | 2018-01-16 16:27:00 +0530 | [diff] [blame] | 2058 | goto err_com_init; |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 2059 | } |
| 2060 | } |
| 2061 | |
| 2062 | mutex_unlock(&qmp->phy_mutex); |
| 2063 | |
| 2064 | return 0; |
| 2065 | |
Manu Gautam | c6549f0 | 2018-01-16 16:27:00 +0530 | [diff] [blame] | 2066 | err_com_init: |
Manu Gautam | 717dab9 | 2018-01-16 16:26:58 +0530 | [diff] [blame] | 2067 | clk_bulk_disable_unprepare(cfg->num_clks, qmp->clks); |
Manu Gautam | c6549f0 | 2018-01-16 16:27:00 +0530 | [diff] [blame] | 2068 | err_rst: |
| 2069 | while (++i < cfg->num_resets) |
| 2070 | reset_control_assert(qmp->resets[i]); |
| 2071 | err_rst_assert: |
Manu Gautam | 717dab9 | 2018-01-16 16:26:58 +0530 | [diff] [blame] | 2072 | regulator_bulk_disable(cfg->num_vregs, qmp->vregs); |
| 2073 | err_reg_enable: |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 2074 | mutex_unlock(&qmp->phy_mutex); |
Vivek Gautam | 8387c57 | 2017-06-20 11:27:18 +0530 | [diff] [blame] | 2075 | |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 2076 | return ret; |
| 2077 | } |
| 2078 | |
| 2079 | static int qcom_qmp_phy_com_exit(struct qcom_qmp *qmp) |
| 2080 | { |
| 2081 | const struct qmp_phy_cfg *cfg = qmp->cfg; |
| 2082 | void __iomem *serdes = qmp->serdes; |
| 2083 | int i = cfg->num_resets; |
| 2084 | |
| 2085 | mutex_lock(&qmp->phy_mutex); |
| 2086 | if (--qmp->init_count) { |
| 2087 | mutex_unlock(&qmp->phy_mutex); |
| 2088 | return 0; |
| 2089 | } |
| 2090 | |
Evan Green | c9b5897 | 2019-03-21 10:17:59 -0700 | [diff] [blame] | 2091 | reset_control_assert(qmp->ufs_reset); |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 2092 | if (cfg->has_phy_com_ctrl) { |
| 2093 | qphy_setbits(serdes, cfg->regs[QPHY_COM_START_CONTROL], |
| 2094 | SERDES_START | PCS_START); |
| 2095 | qphy_clrbits(serdes, cfg->regs[QPHY_COM_SW_RESET], |
| 2096 | SW_RESET); |
| 2097 | qphy_setbits(serdes, cfg->regs[QPHY_COM_POWER_DOWN_CONTROL], |
| 2098 | SW_PWRDN); |
| 2099 | } |
| 2100 | |
| 2101 | while (--i >= 0) |
| 2102 | reset_control_assert(qmp->resets[i]); |
| 2103 | |
Manu Gautam | 717dab9 | 2018-01-16 16:26:58 +0530 | [diff] [blame] | 2104 | clk_bulk_disable_unprepare(cfg->num_clks, qmp->clks); |
| 2105 | |
| 2106 | regulator_bulk_disable(cfg->num_vregs, qmp->vregs); |
| 2107 | |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 2108 | mutex_unlock(&qmp->phy_mutex); |
| 2109 | |
| 2110 | return 0; |
| 2111 | } |
| 2112 | |
Evan Green | 3f6d176 | 2019-03-21 10:18:00 -0700 | [diff] [blame] | 2113 | static int qcom_qmp_phy_enable(struct phy *phy) |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 2114 | { |
| 2115 | struct qmp_phy *qphy = phy_get_drvdata(phy); |
| 2116 | struct qcom_qmp *qmp = qphy->qmp; |
| 2117 | const struct qmp_phy_cfg *cfg = qmp->cfg; |
| 2118 | void __iomem *tx = qphy->tx; |
| 2119 | void __iomem *rx = qphy->rx; |
| 2120 | void __iomem *pcs = qphy->pcs; |
Bjorn Andersson | 421c9a0 | 2020-01-06 00:18:20 -0800 | [diff] [blame] | 2121 | void __iomem *pcs_misc = qphy->pcs_misc; |
Manu Gautam | efb05a5 | 2018-01-16 16:27:08 +0530 | [diff] [blame] | 2122 | void __iomem *dp_com = qmp->dp_com; |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 2123 | void __iomem *status; |
Bjorn Andersson | 14ced7e | 2019-08-05 17:42:56 -0700 | [diff] [blame] | 2124 | unsigned int mask, val, ready; |
Vivek Gautam | 10939b1 | 2018-01-16 16:26:57 +0530 | [diff] [blame] | 2125 | int ret; |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 2126 | |
| 2127 | dev_vdbg(qmp->dev, "Initializing QMP phy\n"); |
| 2128 | |
Evan Green | c9b5897 | 2019-03-21 10:17:59 -0700 | [diff] [blame] | 2129 | if (cfg->no_pcs_sw_reset) { |
| 2130 | /* |
| 2131 | * Get UFS reset, which is delayed until now to avoid a |
| 2132 | * circular dependency where UFS needs its PHY, but the PHY |
| 2133 | * needs this UFS reset. |
| 2134 | */ |
| 2135 | if (!qmp->ufs_reset) { |
| 2136 | qmp->ufs_reset = |
| 2137 | devm_reset_control_get_exclusive(qmp->dev, |
| 2138 | "ufsphy"); |
| 2139 | |
| 2140 | if (IS_ERR(qmp->ufs_reset)) { |
| 2141 | ret = PTR_ERR(qmp->ufs_reset); |
| 2142 | dev_err(qmp->dev, |
| 2143 | "failed to get UFS reset: %d\n", |
| 2144 | ret); |
| 2145 | |
| 2146 | qmp->ufs_reset = NULL; |
| 2147 | return ret; |
| 2148 | } |
| 2149 | } |
| 2150 | |
| 2151 | ret = reset_control_assert(qmp->ufs_reset); |
| 2152 | if (ret) |
| 2153 | goto err_lane_rst; |
| 2154 | } |
| 2155 | |
Can Guo | 0d58280 | 2018-09-20 21:27:54 -0700 | [diff] [blame] | 2156 | ret = qcom_qmp_phy_com_init(qphy); |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 2157 | if (ret) |
Manu Gautam | 717dab9 | 2018-01-16 16:26:58 +0530 | [diff] [blame] | 2158 | return ret; |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 2159 | |
| 2160 | if (cfg->has_lane_rst) { |
| 2161 | ret = reset_control_deassert(qphy->lane_rst); |
| 2162 | if (ret) { |
| 2163 | dev_err(qmp->dev, "lane%d reset deassert failed\n", |
| 2164 | qphy->index); |
| 2165 | goto err_lane_rst; |
| 2166 | } |
| 2167 | } |
| 2168 | |
Manu Gautam | fdf37e1 | 2018-05-03 02:36:09 +0530 | [diff] [blame] | 2169 | ret = clk_prepare_enable(qphy->pipe_clk); |
| 2170 | if (ret) { |
| 2171 | dev_err(qmp->dev, "pipe_clk enable failed err=%d\n", ret); |
| 2172 | goto err_clk_enable; |
| 2173 | } |
| 2174 | |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 2175 | /* Tx, Rx, and PCS configurations */ |
| 2176 | qcom_qmp_phy_configure(tx, cfg->regs, cfg->tx_tbl, cfg->tx_tbl_num); |
Manu Gautam | efb05a5 | 2018-01-16 16:27:08 +0530 | [diff] [blame] | 2177 | /* Configuration for other LANE for USB-DP combo PHY */ |
Can Guo | 6b04526 | 2018-09-20 21:27:55 -0700 | [diff] [blame] | 2178 | if (cfg->is_dual_lane_phy) |
Evan Green | 5e17b95 | 2018-12-10 11:28:23 -0800 | [diff] [blame] | 2179 | qcom_qmp_phy_configure(qphy->tx2, cfg->regs, |
Manu Gautam | efb05a5 | 2018-01-16 16:27:08 +0530 | [diff] [blame] | 2180 | cfg->tx_tbl, cfg->tx_tbl_num); |
| 2181 | |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 2182 | qcom_qmp_phy_configure(rx, cfg->regs, cfg->rx_tbl, cfg->rx_tbl_num); |
Can Guo | 6b04526 | 2018-09-20 21:27:55 -0700 | [diff] [blame] | 2183 | if (cfg->is_dual_lane_phy) |
Evan Green | 5e17b95 | 2018-12-10 11:28:23 -0800 | [diff] [blame] | 2184 | qcom_qmp_phy_configure(qphy->rx2, cfg->regs, |
Manu Gautam | efb05a5 | 2018-01-16 16:27:08 +0530 | [diff] [blame] | 2185 | cfg->rx_tbl, cfg->rx_tbl_num); |
| 2186 | |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 2187 | qcom_qmp_phy_configure(pcs, cfg->regs, cfg->pcs_tbl, cfg->pcs_tbl_num); |
Evan Green | c9b5897 | 2019-03-21 10:17:59 -0700 | [diff] [blame] | 2188 | ret = reset_control_deassert(qmp->ufs_reset); |
| 2189 | if (ret) |
| 2190 | goto err_lane_rst; |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 2191 | |
Bjorn Andersson | 421c9a0 | 2020-01-06 00:18:20 -0800 | [diff] [blame] | 2192 | qcom_qmp_phy_configure(pcs_misc, cfg->regs, cfg->pcs_misc_tbl, |
| 2193 | cfg->pcs_misc_tbl_num); |
| 2194 | |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 2195 | /* |
| 2196 | * Pull out PHY from POWER DOWN state. |
| 2197 | * This is active low enable signal to power-down PHY. |
| 2198 | */ |
Can Guo | 0d58280 | 2018-09-20 21:27:54 -0700 | [diff] [blame] | 2199 | if(cfg->type == PHY_TYPE_PCIE) |
| 2200 | qphy_setbits(pcs, QPHY_POWER_DOWN_CONTROL, cfg->pwrdn_ctrl); |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 2201 | |
| 2202 | if (cfg->has_pwrdn_delay) |
| 2203 | usleep_range(cfg->pwrdn_delay_min, cfg->pwrdn_delay_max); |
| 2204 | |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 2205 | /* Pull PHY out of reset state */ |
Evan Green | 3f6d176 | 2019-03-21 10:18:00 -0700 | [diff] [blame] | 2206 | if (!cfg->no_pcs_sw_reset) |
| 2207 | qphy_clrbits(pcs, cfg->regs[QPHY_SW_RESET], SW_RESET); |
| 2208 | |
Manu Gautam | efb05a5 | 2018-01-16 16:27:08 +0530 | [diff] [blame] | 2209 | if (cfg->has_phy_dp_com_ctrl) |
| 2210 | qphy_clrbits(dp_com, QPHY_V3_DP_COM_SW_RESET, SW_RESET); |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 2211 | |
Manu Gautam | 76ddd30 | 2018-01-16 16:27:01 +0530 | [diff] [blame] | 2212 | /* start SerDes and Phy-Coding-Sublayer */ |
| 2213 | qphy_setbits(pcs, cfg->regs[QPHY_START_CTRL], cfg->start_ctrl); |
| 2214 | |
Bjorn Andersson | 14ced7e | 2019-08-05 17:42:56 -0700 | [diff] [blame] | 2215 | if (cfg->type == PHY_TYPE_UFS) { |
| 2216 | status = pcs + cfg->regs[QPHY_PCS_READY_STATUS]; |
| 2217 | mask = PCS_READY; |
| 2218 | ready = PCS_READY; |
| 2219 | } else { |
| 2220 | status = pcs + cfg->regs[QPHY_PCS_STATUS]; |
| 2221 | mask = PHYSTATUS; |
| 2222 | ready = 0; |
| 2223 | } |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 2224 | |
Bjorn Andersson | 14ced7e | 2019-08-05 17:42:56 -0700 | [diff] [blame] | 2225 | ret = readl_poll_timeout(status, val, (val & mask) == ready, 10, |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 2226 | PHY_INIT_COMPLETE_TIMEOUT); |
| 2227 | if (ret) { |
| 2228 | dev_err(qmp->dev, "phy initialization timed-out\n"); |
| 2229 | goto err_pcs_ready; |
| 2230 | } |
Manu Gautam | ac0d239 | 2018-01-16 16:27:11 +0530 | [diff] [blame] | 2231 | qmp->phy_initialized = true; |
Evan Green | 3f6d176 | 2019-03-21 10:18:00 -0700 | [diff] [blame] | 2232 | return 0; |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 2233 | |
| 2234 | err_pcs_ready: |
Evan Green | 3f6d176 | 2019-03-21 10:18:00 -0700 | [diff] [blame] | 2235 | reset_control_assert(qmp->ufs_reset); |
Manu Gautam | fdf37e1 | 2018-05-03 02:36:09 +0530 | [diff] [blame] | 2236 | clk_disable_unprepare(qphy->pipe_clk); |
| 2237 | err_clk_enable: |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 2238 | if (cfg->has_lane_rst) |
| 2239 | reset_control_assert(qphy->lane_rst); |
| 2240 | err_lane_rst: |
| 2241 | qcom_qmp_phy_com_exit(qmp); |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 2242 | |
| 2243 | return ret; |
| 2244 | } |
| 2245 | |
Evan Green | 3f6d176 | 2019-03-21 10:18:00 -0700 | [diff] [blame] | 2246 | static int qcom_qmp_phy_disable(struct phy *phy) |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 2247 | { |
| 2248 | struct qmp_phy *qphy = phy_get_drvdata(phy); |
| 2249 | struct qcom_qmp *qmp = qphy->qmp; |
| 2250 | const struct qmp_phy_cfg *cfg = qmp->cfg; |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 2251 | |
Vivek Gautam | f8ba22a3 | 2018-01-16 16:26:56 +0530 | [diff] [blame] | 2252 | clk_disable_unprepare(qphy->pipe_clk); |
| 2253 | |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 2254 | /* PHY reset */ |
Can Guo | cc31cdb | 2018-09-20 21:27:56 -0700 | [diff] [blame] | 2255 | if (!cfg->no_pcs_sw_reset) |
| 2256 | qphy_setbits(qphy->pcs, cfg->regs[QPHY_SW_RESET], SW_RESET); |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 2257 | |
| 2258 | /* stop SerDes and Phy-Coding-Sublayer */ |
| 2259 | qphy_clrbits(qphy->pcs, cfg->regs[QPHY_START_CTRL], cfg->start_ctrl); |
| 2260 | |
| 2261 | /* Put PHY into POWER DOWN state: active low */ |
| 2262 | qphy_clrbits(qphy->pcs, QPHY_POWER_DOWN_CONTROL, cfg->pwrdn_ctrl); |
| 2263 | |
| 2264 | if (cfg->has_lane_rst) |
| 2265 | reset_control_assert(qphy->lane_rst); |
| 2266 | |
| 2267 | qcom_qmp_phy_com_exit(qmp); |
| 2268 | |
Manu Gautam | ac0d239 | 2018-01-16 16:27:11 +0530 | [diff] [blame] | 2269 | qmp->phy_initialized = false; |
| 2270 | |
| 2271 | return 0; |
| 2272 | } |
| 2273 | |
Grygorii Strashko | 79a5a18 | 2018-11-19 19:24:20 -0600 | [diff] [blame] | 2274 | static int qcom_qmp_phy_set_mode(struct phy *phy, |
| 2275 | enum phy_mode mode, int submode) |
Manu Gautam | ac0d239 | 2018-01-16 16:27:11 +0530 | [diff] [blame] | 2276 | { |
| 2277 | struct qmp_phy *qphy = phy_get_drvdata(phy); |
| 2278 | struct qcom_qmp *qmp = qphy->qmp; |
| 2279 | |
| 2280 | qmp->mode = mode; |
| 2281 | |
| 2282 | return 0; |
| 2283 | } |
| 2284 | |
| 2285 | static void qcom_qmp_phy_enable_autonomous_mode(struct qmp_phy *qphy) |
| 2286 | { |
| 2287 | struct qcom_qmp *qmp = qphy->qmp; |
| 2288 | const struct qmp_phy_cfg *cfg = qmp->cfg; |
| 2289 | void __iomem *pcs = qphy->pcs; |
| 2290 | void __iomem *pcs_misc = qphy->pcs_misc; |
| 2291 | u32 intr_mask; |
| 2292 | |
| 2293 | if (qmp->mode == PHY_MODE_USB_HOST_SS || |
| 2294 | qmp->mode == PHY_MODE_USB_DEVICE_SS) |
| 2295 | intr_mask = ARCVR_DTCT_EN | ALFPS_DTCT_EN; |
| 2296 | else |
| 2297 | intr_mask = ARCVR_DTCT_EN | ARCVR_DTCT_EVENT_SEL; |
| 2298 | |
| 2299 | /* Clear any pending interrupts status */ |
| 2300 | qphy_setbits(pcs, cfg->regs[QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR], IRQ_CLEAR); |
| 2301 | /* Writing 1 followed by 0 clears the interrupt */ |
| 2302 | qphy_clrbits(pcs, cfg->regs[QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR], IRQ_CLEAR); |
| 2303 | |
| 2304 | qphy_clrbits(pcs, cfg->regs[QPHY_PCS_AUTONOMOUS_MODE_CTRL], |
| 2305 | ARCVR_DTCT_EN | ALFPS_DTCT_EN | ARCVR_DTCT_EVENT_SEL); |
| 2306 | |
| 2307 | /* Enable required PHY autonomous mode interrupts */ |
| 2308 | qphy_setbits(pcs, cfg->regs[QPHY_PCS_AUTONOMOUS_MODE_CTRL], intr_mask); |
| 2309 | |
| 2310 | /* Enable i/o clamp_n for autonomous mode */ |
| 2311 | if (pcs_misc) |
| 2312 | qphy_clrbits(pcs_misc, QPHY_V3_PCS_MISC_CLAMP_ENABLE, CLAMP_EN); |
| 2313 | } |
| 2314 | |
| 2315 | static void qcom_qmp_phy_disable_autonomous_mode(struct qmp_phy *qphy) |
| 2316 | { |
| 2317 | struct qcom_qmp *qmp = qphy->qmp; |
| 2318 | const struct qmp_phy_cfg *cfg = qmp->cfg; |
| 2319 | void __iomem *pcs = qphy->pcs; |
| 2320 | void __iomem *pcs_misc = qphy->pcs_misc; |
| 2321 | |
| 2322 | /* Disable i/o clamp_n on resume for normal mode */ |
| 2323 | if (pcs_misc) |
| 2324 | qphy_setbits(pcs_misc, QPHY_V3_PCS_MISC_CLAMP_ENABLE, CLAMP_EN); |
| 2325 | |
| 2326 | qphy_clrbits(pcs, cfg->regs[QPHY_PCS_AUTONOMOUS_MODE_CTRL], |
| 2327 | ARCVR_DTCT_EN | ARCVR_DTCT_EVENT_SEL | ALFPS_DTCT_EN); |
| 2328 | |
| 2329 | qphy_setbits(pcs, cfg->regs[QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR], IRQ_CLEAR); |
| 2330 | /* Writing 1 followed by 0 clears the interrupt */ |
| 2331 | qphy_clrbits(pcs, cfg->regs[QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR], IRQ_CLEAR); |
| 2332 | } |
| 2333 | |
| 2334 | static int __maybe_unused qcom_qmp_phy_runtime_suspend(struct device *dev) |
| 2335 | { |
| 2336 | struct qcom_qmp *qmp = dev_get_drvdata(dev); |
| 2337 | struct qmp_phy *qphy = qmp->phys[0]; |
| 2338 | const struct qmp_phy_cfg *cfg = qmp->cfg; |
| 2339 | |
| 2340 | dev_vdbg(dev, "Suspending QMP phy, mode:%d\n", qmp->mode); |
| 2341 | |
| 2342 | /* Supported only for USB3 PHY */ |
| 2343 | if (cfg->type != PHY_TYPE_USB3) |
| 2344 | return 0; |
| 2345 | |
| 2346 | if (!qmp->phy_initialized) { |
| 2347 | dev_vdbg(dev, "PHY not initialized, bailing out\n"); |
| 2348 | return 0; |
| 2349 | } |
| 2350 | |
| 2351 | qcom_qmp_phy_enable_autonomous_mode(qphy); |
| 2352 | |
| 2353 | clk_disable_unprepare(qphy->pipe_clk); |
| 2354 | clk_bulk_disable_unprepare(cfg->num_clks, qmp->clks); |
| 2355 | |
| 2356 | return 0; |
| 2357 | } |
| 2358 | |
| 2359 | static int __maybe_unused qcom_qmp_phy_runtime_resume(struct device *dev) |
| 2360 | { |
| 2361 | struct qcom_qmp *qmp = dev_get_drvdata(dev); |
| 2362 | struct qmp_phy *qphy = qmp->phys[0]; |
| 2363 | const struct qmp_phy_cfg *cfg = qmp->cfg; |
| 2364 | int ret = 0; |
| 2365 | |
| 2366 | dev_vdbg(dev, "Resuming QMP phy, mode:%d\n", qmp->mode); |
| 2367 | |
| 2368 | /* Supported only for USB3 PHY */ |
| 2369 | if (cfg->type != PHY_TYPE_USB3) |
| 2370 | return 0; |
| 2371 | |
| 2372 | if (!qmp->phy_initialized) { |
| 2373 | dev_vdbg(dev, "PHY not initialized, bailing out\n"); |
| 2374 | return 0; |
| 2375 | } |
| 2376 | |
| 2377 | ret = clk_bulk_prepare_enable(cfg->num_clks, qmp->clks); |
| 2378 | if (ret) { |
| 2379 | dev_err(qmp->dev, "failed to enable clks, err=%d\n", ret); |
| 2380 | return ret; |
| 2381 | } |
| 2382 | |
| 2383 | ret = clk_prepare_enable(qphy->pipe_clk); |
| 2384 | if (ret) { |
| 2385 | dev_err(dev, "pipe_clk enable failed, err=%d\n", ret); |
| 2386 | clk_bulk_disable_unprepare(cfg->num_clks, qmp->clks); |
| 2387 | return ret; |
| 2388 | } |
| 2389 | |
| 2390 | qcom_qmp_phy_disable_autonomous_mode(qphy); |
| 2391 | |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 2392 | return 0; |
| 2393 | } |
| 2394 | |
| 2395 | static int qcom_qmp_phy_vreg_init(struct device *dev) |
| 2396 | { |
| 2397 | struct qcom_qmp *qmp = dev_get_drvdata(dev); |
| 2398 | int num = qmp->cfg->num_vregs; |
| 2399 | int i; |
| 2400 | |
Fengguang Wu | 9605bc4 | 2017-05-16 20:41:45 +0800 | [diff] [blame] | 2401 | qmp->vregs = devm_kcalloc(dev, num, sizeof(*qmp->vregs), GFP_KERNEL); |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 2402 | if (!qmp->vregs) |
| 2403 | return -ENOMEM; |
| 2404 | |
| 2405 | for (i = 0; i < num; i++) |
| 2406 | qmp->vregs[i].supply = qmp->cfg->vreg_list[i]; |
| 2407 | |
| 2408 | return devm_regulator_bulk_get(dev, num, qmp->vregs); |
| 2409 | } |
| 2410 | |
| 2411 | static int qcom_qmp_phy_reset_init(struct device *dev) |
| 2412 | { |
| 2413 | struct qcom_qmp *qmp = dev_get_drvdata(dev); |
| 2414 | int i; |
| 2415 | |
| 2416 | qmp->resets = devm_kcalloc(dev, qmp->cfg->num_resets, |
| 2417 | sizeof(*qmp->resets), GFP_KERNEL); |
| 2418 | if (!qmp->resets) |
| 2419 | return -ENOMEM; |
| 2420 | |
| 2421 | for (i = 0; i < qmp->cfg->num_resets; i++) { |
| 2422 | struct reset_control *rst; |
| 2423 | const char *name = qmp->cfg->reset_list[i]; |
| 2424 | |
| 2425 | rst = devm_reset_control_get(dev, name); |
| 2426 | if (IS_ERR(rst)) { |
| 2427 | dev_err(dev, "failed to get %s reset\n", name); |
| 2428 | return PTR_ERR(rst); |
| 2429 | } |
| 2430 | qmp->resets[i] = rst; |
| 2431 | } |
| 2432 | |
| 2433 | return 0; |
| 2434 | } |
| 2435 | |
| 2436 | static int qcom_qmp_phy_clk_init(struct device *dev) |
| 2437 | { |
| 2438 | struct qcom_qmp *qmp = dev_get_drvdata(dev); |
Vivek Gautam | 10939b1 | 2018-01-16 16:26:57 +0530 | [diff] [blame] | 2439 | int num = qmp->cfg->num_clks; |
| 2440 | int i; |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 2441 | |
Vivek Gautam | 10939b1 | 2018-01-16 16:26:57 +0530 | [diff] [blame] | 2442 | qmp->clks = devm_kcalloc(dev, num, sizeof(*qmp->clks), GFP_KERNEL); |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 2443 | if (!qmp->clks) |
| 2444 | return -ENOMEM; |
| 2445 | |
Vivek Gautam | 10939b1 | 2018-01-16 16:26:57 +0530 | [diff] [blame] | 2446 | for (i = 0; i < num; i++) |
| 2447 | qmp->clks[i].id = qmp->cfg->clk_list[i]; |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 2448 | |
Vivek Gautam | 10939b1 | 2018-01-16 16:26:57 +0530 | [diff] [blame] | 2449 | return devm_clk_bulk_get(dev, num, qmp->clks); |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 2450 | } |
| 2451 | |
Evan Green | 2e38c2e | 2018-12-10 11:32:07 -0800 | [diff] [blame] | 2452 | static void phy_pipe_clk_release_provider(void *res) |
| 2453 | { |
| 2454 | of_clk_del_provider(res); |
| 2455 | } |
| 2456 | |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 2457 | /* |
| 2458 | * Register a fixed rate pipe clock. |
| 2459 | * |
| 2460 | * The <s>_pipe_clksrc generated by PHY goes to the GCC that gate |
| 2461 | * controls it. The <s>_pipe_clk coming out of the GCC is requested |
| 2462 | * by the PHY driver for its operations. |
| 2463 | * We register the <s>_pipe_clksrc here. The gcc driver takes care |
| 2464 | * of assigning this <s>_pipe_clksrc as parent to <s>_pipe_clk. |
| 2465 | * Below picture shows this relationship. |
| 2466 | * |
| 2467 | * +---------------+ |
| 2468 | * | PHY block |<<---------------------------------------+ |
| 2469 | * | | | |
| 2470 | * | +-------+ | +-----+ | |
| 2471 | * I/P---^-->| PLL |---^--->pipe_clksrc--->| GCC |--->pipe_clk---+ |
| 2472 | * clk | +-------+ | +-----+ |
| 2473 | * +---------------+ |
| 2474 | */ |
Varadarajan Narayanan | 2a9316b | 2017-07-31 12:04:13 +0530 | [diff] [blame] | 2475 | static int phy_pipe_clk_register(struct qcom_qmp *qmp, struct device_node *np) |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 2476 | { |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 2477 | struct clk_fixed_rate *fixed; |
| 2478 | struct clk_init_data init = { }; |
Varadarajan Narayanan | 2a9316b | 2017-07-31 12:04:13 +0530 | [diff] [blame] | 2479 | int ret; |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 2480 | |
Varadarajan Narayanan | 2a9316b | 2017-07-31 12:04:13 +0530 | [diff] [blame] | 2481 | if ((qmp->cfg->type != PHY_TYPE_USB3) && |
| 2482 | (qmp->cfg->type != PHY_TYPE_PCIE)) { |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 2483 | /* not all phys register pipe clocks, so return success */ |
| 2484 | return 0; |
| 2485 | } |
| 2486 | |
Varadarajan Narayanan | 2a9316b | 2017-07-31 12:04:13 +0530 | [diff] [blame] | 2487 | ret = of_property_read_string(np, "clock-output-names", &init.name); |
| 2488 | if (ret) { |
Rob Herring | ac9ba7d | 2018-08-27 20:52:40 -0500 | [diff] [blame] | 2489 | dev_err(qmp->dev, "%pOFn: No clock-output-names\n", np); |
Varadarajan Narayanan | 2a9316b | 2017-07-31 12:04:13 +0530 | [diff] [blame] | 2490 | return ret; |
| 2491 | } |
| 2492 | |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 2493 | fixed = devm_kzalloc(qmp->dev, sizeof(*fixed), GFP_KERNEL); |
| 2494 | if (!fixed) |
| 2495 | return -ENOMEM; |
| 2496 | |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 2497 | init.ops = &clk_fixed_rate_ops; |
| 2498 | |
| 2499 | /* controllers using QMP phys use 125MHz pipe clock interface */ |
| 2500 | fixed->fixed_rate = 125000000; |
| 2501 | fixed->hw.init = &init; |
| 2502 | |
Evan Green | 2e38c2e | 2018-12-10 11:32:07 -0800 | [diff] [blame] | 2503 | ret = devm_clk_hw_register(qmp->dev, &fixed->hw); |
| 2504 | if (ret) |
| 2505 | return ret; |
| 2506 | |
| 2507 | ret = of_clk_add_hw_provider(np, of_clk_hw_simple_get, &fixed->hw); |
| 2508 | if (ret) |
| 2509 | return ret; |
| 2510 | |
| 2511 | /* |
| 2512 | * Roll a devm action because the clock provider is the child node, but |
| 2513 | * the child node is not actually a device. |
| 2514 | */ |
| 2515 | ret = devm_add_action(qmp->dev, phy_pipe_clk_release_provider, np); |
| 2516 | if (ret) |
| 2517 | phy_pipe_clk_release_provider(np); |
| 2518 | |
| 2519 | return ret; |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 2520 | } |
| 2521 | |
| 2522 | static const struct phy_ops qcom_qmp_phy_gen_ops = { |
Evan Green | 3f6d176 | 2019-03-21 10:18:00 -0700 | [diff] [blame] | 2523 | .init = qcom_qmp_phy_enable, |
| 2524 | .exit = qcom_qmp_phy_disable, |
| 2525 | .set_mode = qcom_qmp_phy_set_mode, |
| 2526 | .owner = THIS_MODULE, |
| 2527 | }; |
| 2528 | |
Bjorn Andersson | cc1e06f | 2020-01-06 00:11:42 -0800 | [diff] [blame] | 2529 | static const struct phy_ops qcom_qmp_pcie_ufs_ops = { |
Evan Green | 3f6d176 | 2019-03-21 10:18:00 -0700 | [diff] [blame] | 2530 | .power_on = qcom_qmp_phy_enable, |
| 2531 | .power_off = qcom_qmp_phy_disable, |
Manu Gautam | ac0d239 | 2018-01-16 16:27:11 +0530 | [diff] [blame] | 2532 | .set_mode = qcom_qmp_phy_set_mode, |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 2533 | .owner = THIS_MODULE, |
| 2534 | }; |
| 2535 | |
| 2536 | static |
| 2537 | int qcom_qmp_phy_create(struct device *dev, struct device_node *np, int id) |
| 2538 | { |
| 2539 | struct qcom_qmp *qmp = dev_get_drvdata(dev); |
| 2540 | struct phy *generic_phy; |
| 2541 | struct qmp_phy *qphy; |
Evan Green | 3f6d176 | 2019-03-21 10:18:00 -0700 | [diff] [blame] | 2542 | const struct phy_ops *ops = &qcom_qmp_phy_gen_ops; |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 2543 | char prop_name[MAX_PROP_NAME]; |
| 2544 | int ret; |
| 2545 | |
| 2546 | qphy = devm_kzalloc(dev, sizeof(*qphy), GFP_KERNEL); |
| 2547 | if (!qphy) |
| 2548 | return -ENOMEM; |
| 2549 | |
| 2550 | /* |
| 2551 | * Get memory resources for each phy lane: |
Evan Green | 5e17b95 | 2018-12-10 11:28:23 -0800 | [diff] [blame] | 2552 | * Resources are indexed as: tx -> 0; rx -> 1; pcs -> 2. |
| 2553 | * For dual lane PHYs: tx2 -> 3, rx2 -> 4, pcs_misc (optional) -> 5 |
| 2554 | * For single lane PHYs: pcs_misc (optional) -> 3. |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 2555 | */ |
| 2556 | qphy->tx = of_iomap(np, 0); |
Wei Yongjun | 53bf959 | 2017-04-25 03:14:54 +0000 | [diff] [blame] | 2557 | if (!qphy->tx) |
| 2558 | return -ENOMEM; |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 2559 | |
| 2560 | qphy->rx = of_iomap(np, 1); |
Wei Yongjun | 53bf959 | 2017-04-25 03:14:54 +0000 | [diff] [blame] | 2561 | if (!qphy->rx) |
| 2562 | return -ENOMEM; |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 2563 | |
| 2564 | qphy->pcs = of_iomap(np, 2); |
Wei Yongjun | 53bf959 | 2017-04-25 03:14:54 +0000 | [diff] [blame] | 2565 | if (!qphy->pcs) |
| 2566 | return -ENOMEM; |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 2567 | |
Evan Green | 5e17b95 | 2018-12-10 11:28:23 -0800 | [diff] [blame] | 2568 | /* |
| 2569 | * If this is a dual-lane PHY, then there should be registers for the |
| 2570 | * second lane. Some old device trees did not specify this, so fall |
| 2571 | * back to old legacy behavior of assuming they can be reached at an |
| 2572 | * offset from the first lane. |
| 2573 | */ |
| 2574 | if (qmp->cfg->is_dual_lane_phy) { |
| 2575 | qphy->tx2 = of_iomap(np, 3); |
| 2576 | qphy->rx2 = of_iomap(np, 4); |
| 2577 | if (!qphy->tx2 || !qphy->rx2) { |
| 2578 | dev_warn(dev, |
| 2579 | "Underspecified device tree, falling back to legacy register regions\n"); |
| 2580 | |
| 2581 | /* In the old version, pcs_misc is at index 3. */ |
| 2582 | qphy->pcs_misc = qphy->tx2; |
| 2583 | qphy->tx2 = qphy->tx + QMP_PHY_LEGACY_LANE_STRIDE; |
| 2584 | qphy->rx2 = qphy->rx + QMP_PHY_LEGACY_LANE_STRIDE; |
| 2585 | |
| 2586 | } else { |
| 2587 | qphy->pcs_misc = of_iomap(np, 5); |
| 2588 | } |
| 2589 | |
| 2590 | } else { |
| 2591 | qphy->pcs_misc = of_iomap(np, 3); |
| 2592 | } |
| 2593 | |
Manu Gautam | ac0d239 | 2018-01-16 16:27:11 +0530 | [diff] [blame] | 2594 | if (!qphy->pcs_misc) |
| 2595 | dev_vdbg(dev, "PHY pcs_misc-reg not used\n"); |
| 2596 | |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 2597 | /* |
| 2598 | * Get PHY's Pipe clock, if any. USB3 and PCIe are PIPE3 |
| 2599 | * based phys, so they essentially have pipe clock. So, |
| 2600 | * we return error in case phy is USB3 or PIPE type. |
| 2601 | * Otherwise, we initialize pipe clock to NULL for |
| 2602 | * all phys that don't need this. |
| 2603 | */ |
| 2604 | snprintf(prop_name, sizeof(prop_name), "pipe%d", id); |
| 2605 | qphy->pipe_clk = of_clk_get_by_name(np, prop_name); |
| 2606 | if (IS_ERR(qphy->pipe_clk)) { |
| 2607 | if (qmp->cfg->type == PHY_TYPE_PCIE || |
| 2608 | qmp->cfg->type == PHY_TYPE_USB3) { |
| 2609 | ret = PTR_ERR(qphy->pipe_clk); |
| 2610 | if (ret != -EPROBE_DEFER) |
| 2611 | dev_err(dev, |
| 2612 | "failed to get lane%d pipe_clk, %d\n", |
| 2613 | id, ret); |
| 2614 | return ret; |
| 2615 | } |
| 2616 | qphy->pipe_clk = NULL; |
| 2617 | } |
| 2618 | |
| 2619 | /* Get lane reset, if any */ |
| 2620 | if (qmp->cfg->has_lane_rst) { |
| 2621 | snprintf(prop_name, sizeof(prop_name), "lane%d", id); |
| 2622 | qphy->lane_rst = of_reset_control_get(np, prop_name); |
| 2623 | if (IS_ERR(qphy->lane_rst)) { |
| 2624 | dev_err(dev, "failed to get lane%d reset\n", id); |
| 2625 | return PTR_ERR(qphy->lane_rst); |
| 2626 | } |
| 2627 | } |
| 2628 | |
Bjorn Andersson | cc1e06f | 2020-01-06 00:11:42 -0800 | [diff] [blame] | 2629 | if (qmp->cfg->type == PHY_TYPE_UFS || qmp->cfg->type == PHY_TYPE_PCIE) |
| 2630 | ops = &qcom_qmp_pcie_ufs_ops; |
Evan Green | 3f6d176 | 2019-03-21 10:18:00 -0700 | [diff] [blame] | 2631 | |
| 2632 | generic_phy = devm_phy_create(dev, np, ops); |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 2633 | if (IS_ERR(generic_phy)) { |
| 2634 | ret = PTR_ERR(generic_phy); |
| 2635 | dev_err(dev, "failed to create qphy %d\n", ret); |
| 2636 | return ret; |
| 2637 | } |
| 2638 | |
| 2639 | qphy->phy = generic_phy; |
| 2640 | qphy->index = id; |
| 2641 | qphy->qmp = qmp; |
| 2642 | qmp->phys[id] = qphy; |
| 2643 | phy_set_drvdata(generic_phy, qphy); |
| 2644 | |
| 2645 | return 0; |
| 2646 | } |
| 2647 | |
| 2648 | static const struct of_device_id qcom_qmp_phy_of_match_table[] = { |
| 2649 | { |
| 2650 | .compatible = "qcom,msm8996-qmp-pcie-phy", |
| 2651 | .data = &msm8996_pciephy_cfg, |
| 2652 | }, { |
Bjorn Andersson | 0347f0d | 2020-01-24 16:08:03 -0800 | [diff] [blame] | 2653 | .compatible = "qcom,msm8996-qmp-ufs-phy", |
| 2654 | .data = &msm8996_ufs_cfg, |
| 2655 | }, { |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 2656 | .compatible = "qcom,msm8996-qmp-usb3-phy", |
| 2657 | .data = &msm8996_usb3phy_cfg, |
Varadarajan Narayanan | eef243d | 2017-07-31 12:04:14 +0530 | [diff] [blame] | 2658 | }, { |
Marc Gonzalez | 73d7ec8 | 2019-04-09 14:48:22 +0200 | [diff] [blame] | 2659 | .compatible = "qcom,msm8998-qmp-pcie-phy", |
| 2660 | .data = &msm8998_pciephy_cfg, |
| 2661 | }, { |
Marc Gonzalez | 203d9b1 | 2019-02-08 23:14:30 +0100 | [diff] [blame] | 2662 | .compatible = "qcom,msm8998-qmp-ufs-phy", |
| 2663 | .data = &sdm845_ufsphy_cfg, |
| 2664 | }, { |
Varadarajan Narayanan | eef243d | 2017-07-31 12:04:14 +0530 | [diff] [blame] | 2665 | .compatible = "qcom,ipq8074-qmp-pcie-phy", |
| 2666 | .data = &ipq8074_pciephy_cfg, |
Manu Gautam | efb05a5 | 2018-01-16 16:27:08 +0530 | [diff] [blame] | 2667 | }, { |
Bjorn Andersson | 909a5c7 | 2020-01-06 00:18:21 -0800 | [diff] [blame] | 2668 | .compatible = "qcom,sdm845-qhp-pcie-phy", |
| 2669 | .data = &sdm845_qhp_pciephy_cfg, |
| 2670 | }, { |
Bjorn Andersson | 421c9a0 | 2020-01-06 00:18:20 -0800 | [diff] [blame] | 2671 | .compatible = "qcom,sdm845-qmp-pcie-phy", |
| 2672 | .data = &sdm845_qmp_pciephy_cfg, |
| 2673 | }, { |
Manu Gautam | f6721e5 | 2018-05-03 02:36:12 +0530 | [diff] [blame] | 2674 | .compatible = "qcom,sdm845-qmp-usb3-phy", |
Manu Gautam | efb05a5 | 2018-01-16 16:27:08 +0530 | [diff] [blame] | 2675 | .data = &qmp_v3_usb3phy_cfg, |
Manu Gautam | f6721e5 | 2018-05-03 02:36:12 +0530 | [diff] [blame] | 2676 | }, { |
| 2677 | .compatible = "qcom,sdm845-qmp-usb3-uni-phy", |
| 2678 | .data = &qmp_v3_usb3_uniphy_cfg, |
Can Guo | cc31cdb | 2018-09-20 21:27:56 -0700 | [diff] [blame] | 2679 | }, { |
| 2680 | .compatible = "qcom,sdm845-qmp-ufs-phy", |
| 2681 | .data = &sdm845_ufsphy_cfg, |
Jeffrey Hugo | a51969f | 2019-01-14 09:36:59 -0700 | [diff] [blame] | 2682 | }, { |
| 2683 | .compatible = "qcom,msm8998-qmp-usb3-phy", |
| 2684 | .data = &msm8998_usb3phy_cfg, |
Vinod Koul | a88c85e | 2019-10-24 13:18:02 +0530 | [diff] [blame] | 2685 | }, { |
| 2686 | .compatible = "qcom,sm8150-qmp-ufs-phy", |
| 2687 | .data = &sm8150_ufsphy_cfg, |
Bjorn Andersson | 2f29298 | 2020-04-14 23:07:45 -0700 | [diff] [blame] | 2688 | }, { |
| 2689 | .compatible = "qcom,sm8250-qmp-ufs-phy", |
| 2690 | .data = &sm8150_ufsphy_cfg, |
Jack Pham | 9a24b92 | 2020-05-04 16:54:25 -0700 | [diff] [blame^] | 2691 | }, { |
| 2692 | .compatible = "qcom,sm8150-qmp-usb3-phy", |
| 2693 | .data = &sm8150_usb3phy_cfg, |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 2694 | }, |
| 2695 | { }, |
| 2696 | }; |
| 2697 | MODULE_DEVICE_TABLE(of, qcom_qmp_phy_of_match_table); |
| 2698 | |
Manu Gautam | ac0d239 | 2018-01-16 16:27:11 +0530 | [diff] [blame] | 2699 | static const struct dev_pm_ops qcom_qmp_phy_pm_ops = { |
| 2700 | SET_RUNTIME_PM_OPS(qcom_qmp_phy_runtime_suspend, |
| 2701 | qcom_qmp_phy_runtime_resume, NULL) |
| 2702 | }; |
| 2703 | |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 2704 | static int qcom_qmp_phy_probe(struct platform_device *pdev) |
| 2705 | { |
| 2706 | struct qcom_qmp *qmp; |
| 2707 | struct device *dev = &pdev->dev; |
| 2708 | struct resource *res; |
| 2709 | struct device_node *child; |
| 2710 | struct phy_provider *phy_provider; |
| 2711 | void __iomem *base; |
| 2712 | int num, id; |
| 2713 | int ret; |
| 2714 | |
| 2715 | qmp = devm_kzalloc(dev, sizeof(*qmp), GFP_KERNEL); |
| 2716 | if (!qmp) |
| 2717 | return -ENOMEM; |
| 2718 | |
| 2719 | qmp->dev = dev; |
| 2720 | dev_set_drvdata(dev, qmp); |
| 2721 | |
Manu Gautam | efb05a5 | 2018-01-16 16:27:08 +0530 | [diff] [blame] | 2722 | /* Get the specific init parameters of QMP phy */ |
| 2723 | qmp->cfg = of_device_get_match_data(dev); |
| 2724 | if (!qmp->cfg) |
| 2725 | return -EINVAL; |
| 2726 | |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 2727 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 2728 | base = devm_ioremap_resource(dev, res); |
| 2729 | if (IS_ERR(base)) |
| 2730 | return PTR_ERR(base); |
| 2731 | |
| 2732 | /* per PHY serdes; usually located at base address */ |
| 2733 | qmp->serdes = base; |
| 2734 | |
Manu Gautam | efb05a5 | 2018-01-16 16:27:08 +0530 | [diff] [blame] | 2735 | /* per PHY dp_com; if PHY has dp_com control block */ |
| 2736 | if (qmp->cfg->has_phy_dp_com_ctrl) { |
| 2737 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, |
| 2738 | "dp_com"); |
| 2739 | base = devm_ioremap_resource(dev, res); |
| 2740 | if (IS_ERR(base)) |
| 2741 | return PTR_ERR(base); |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 2742 | |
Manu Gautam | efb05a5 | 2018-01-16 16:27:08 +0530 | [diff] [blame] | 2743 | qmp->dp_com = base; |
| 2744 | } |
| 2745 | |
| 2746 | mutex_init(&qmp->phy_mutex); |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 2747 | |
| 2748 | ret = qcom_qmp_phy_clk_init(dev); |
| 2749 | if (ret) |
| 2750 | return ret; |
| 2751 | |
| 2752 | ret = qcom_qmp_phy_reset_init(dev); |
| 2753 | if (ret) |
| 2754 | return ret; |
| 2755 | |
| 2756 | ret = qcom_qmp_phy_vreg_init(dev); |
| 2757 | if (ret) { |
Douglas Anderson | 22fa10e | 2018-05-14 15:42:21 -0700 | [diff] [blame] | 2758 | if (ret != -EPROBE_DEFER) |
| 2759 | dev_err(dev, "failed to get regulator supplies: %d\n", |
| 2760 | ret); |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 2761 | return ret; |
| 2762 | } |
| 2763 | |
| 2764 | num = of_get_available_child_count(dev->of_node); |
| 2765 | /* do we have a rogue child node ? */ |
| 2766 | if (num > qmp->cfg->nlanes) |
| 2767 | return -EINVAL; |
| 2768 | |
| 2769 | qmp->phys = devm_kcalloc(dev, num, sizeof(*qmp->phys), GFP_KERNEL); |
| 2770 | if (!qmp->phys) |
| 2771 | return -ENOMEM; |
| 2772 | |
| 2773 | id = 0; |
Manu Gautam | ac0d239 | 2018-01-16 16:27:11 +0530 | [diff] [blame] | 2774 | pm_runtime_set_active(dev); |
| 2775 | pm_runtime_enable(dev); |
| 2776 | /* |
| 2777 | * Prevent runtime pm from being ON by default. Users can enable |
| 2778 | * it using power/control in sysfs. |
| 2779 | */ |
| 2780 | pm_runtime_forbid(dev); |
| 2781 | |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 2782 | for_each_available_child_of_node(dev->of_node, child) { |
| 2783 | /* Create per-lane phy */ |
| 2784 | ret = qcom_qmp_phy_create(dev, child, id); |
| 2785 | if (ret) { |
| 2786 | dev_err(dev, "failed to create lane%d phy, %d\n", |
| 2787 | id, ret); |
Nishka Dasgupta | be0345b | 2019-08-08 12:59:37 +0530 | [diff] [blame] | 2788 | goto err_node_put; |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 2789 | } |
| 2790 | |
| 2791 | /* |
| 2792 | * Register the pipe clock provided by phy. |
| 2793 | * See function description to see details of this pipe clock. |
| 2794 | */ |
Varadarajan Narayanan | 2a9316b | 2017-07-31 12:04:13 +0530 | [diff] [blame] | 2795 | ret = phy_pipe_clk_register(qmp, child); |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 2796 | if (ret) { |
| 2797 | dev_err(qmp->dev, |
| 2798 | "failed to register pipe clock source\n"); |
Nishka Dasgupta | be0345b | 2019-08-08 12:59:37 +0530 | [diff] [blame] | 2799 | goto err_node_put; |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 2800 | } |
| 2801 | id++; |
| 2802 | } |
| 2803 | |
| 2804 | phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); |
| 2805 | if (!IS_ERR(phy_provider)) |
| 2806 | dev_info(dev, "Registered Qcom-QMP phy\n"); |
Manu Gautam | ac0d239 | 2018-01-16 16:27:11 +0530 | [diff] [blame] | 2807 | else |
| 2808 | pm_runtime_disable(dev); |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 2809 | |
| 2810 | return PTR_ERR_OR_ZERO(phy_provider); |
Nishka Dasgupta | be0345b | 2019-08-08 12:59:37 +0530 | [diff] [blame] | 2811 | |
| 2812 | err_node_put: |
| 2813 | pm_runtime_disable(dev); |
| 2814 | of_node_put(child); |
| 2815 | return ret; |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 2816 | } |
| 2817 | |
| 2818 | static struct platform_driver qcom_qmp_phy_driver = { |
| 2819 | .probe = qcom_qmp_phy_probe, |
| 2820 | .driver = { |
| 2821 | .name = "qcom-qmp-phy", |
Manu Gautam | ac0d239 | 2018-01-16 16:27:11 +0530 | [diff] [blame] | 2822 | .pm = &qcom_qmp_phy_pm_ops, |
Vivek Gautam | e78f3d15 | 2017-04-06 11:21:25 +0530 | [diff] [blame] | 2823 | .of_match_table = qcom_qmp_phy_of_match_table, |
| 2824 | }, |
| 2825 | }; |
| 2826 | |
| 2827 | module_platform_driver(qcom_qmp_phy_driver); |
| 2828 | |
| 2829 | MODULE_AUTHOR("Vivek Gautam <vivek.gautam@codeaurora.org>"); |
| 2830 | MODULE_DESCRIPTION("Qualcomm QMP PHY driver"); |
| 2831 | MODULE_LICENSE("GPL v2"); |