Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

phy: airoha: Add PCIe PHY driver for EN7581 SoC.

Introduce support for Airoha PCIe PHY controller available in EN7581
SoC.

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Tested-by: Zhengping Zhang <zhengping.zhang@airoha.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Link: https://lore.kernel.org/r/20ac99aa8628d97778594f606681db7f868f24fe.1718485860.git.lorenzo@kernel.org
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Lorenzo Bianconi and committed by
Vinod Koul
d7d2818b e2d0317e

+1744
+8
MAINTAINERS
··· 682 682 F: fs/aio.c 683 683 F: include/linux/*aio*.h 684 684 685 + AIROHA PCIE PHY DRIVER 686 + M: Lorenzo Bianconi <lorenzo@kernel.org> 687 + L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) 688 + S: Maintained 689 + F: Documentation/devicetree/bindings/phy/airoha,en7581-pcie-phy.yaml 690 + F: drivers/phy/phy-airoha-pcie-regs.h 691 + F: drivers/phy/phy-airoha-pcie.c 692 + 685 693 AIROHA SPI SNFI DRIVER 686 694 M: Lorenzo Bianconi <lorenzo@kernel.org> 687 695 M: Ray Liu <ray.liu@airoha.com>
+10
drivers/phy/Kconfig
··· 72 72 functional modes using gpios and sets the attribute max link 73 73 rate, for CAN drivers. 74 74 75 + config PHY_AIROHA_PCIE 76 + tristate "Airoha PCIe-PHY Driver" 77 + depends on ARCH_AIROHA || COMPILE_TEST 78 + depends on OF 79 + select GENERIC_PHY 80 + help 81 + Say Y here to add support for Airoha PCIe PHY driver. 82 + This driver create the basic PHY instance and provides initialize 83 + callback for PCIe GEN3 port. 84 + 75 85 source "drivers/phy/allwinner/Kconfig" 76 86 source "drivers/phy/amlogic/Kconfig" 77 87 source "drivers/phy/broadcom/Kconfig"
+1
drivers/phy/Makefile
··· 10 10 obj-$(CONFIG_PHY_XGENE) += phy-xgene.o 11 11 obj-$(CONFIG_PHY_PISTACHIO_USB) += phy-pistachio-usb.o 12 12 obj-$(CONFIG_USB_LGM_PHY) += phy-lgm-usb.o 13 + obj-$(CONFIG_PHY_AIROHA_PCIE) += phy-airoha-pcie.o 13 14 obj-y += allwinner/ \ 14 15 amlogic/ \ 15 16 broadcom/ \
+477
drivers/phy/phy-airoha-pcie-regs.h
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + /* 3 + * Copyright (c) 2024 AIROHA Inc 4 + * Author: Lorenzo Bianconi <lorenzo@kernel.org> 5 + */ 6 + 7 + #ifndef _PHY_AIROHA_PCIE_H 8 + #define _PHY_AIROHA_PCIE_H 9 + 10 + /* CSR_2L */ 11 + #define REG_CSR_2L_CMN 0x0000 12 + #define CSR_2L_PXP_CMN_LANE_EN BIT(0) 13 + #define CSR_2L_PXP_CMN_TRIM_MASK GENMASK(28, 24) 14 + 15 + #define REG_CSR_2L_JCPLL_IB_EXT 0x0004 16 + #define REG_CSR_2L_JCPLL_LPF_SHCK_EN BIT(8) 17 + #define CSR_2L_PXP_JCPLL_CHP_IBIAS GENMASK(21, 16) 18 + #define CSR_2L_PXP_JCPLL_CHP_IOFST GENMASK(29, 24) 19 + 20 + #define REG_CSR_2L_JCPLL_LPF_BR 0x0008 21 + #define CSR_2L_PXP_JCPLL_LPF_BR GENMASK(4, 0) 22 + #define CSR_2L_PXP_JCPLL_LPF_BC GENMASK(12, 8) 23 + #define CSR_2L_PXP_JCPLL_LPF_BP GENMASK(20, 16) 24 + #define CSR_2L_PXP_JCPLL_LPF_BWR GENMASK(28, 24) 25 + 26 + #define REG_CSR_2L_JCPLL_LPF_BWC 0x000c 27 + #define CSR_2L_PXP_JCPLL_LPF_BWC GENMASK(4, 0) 28 + #define CSR_2L_PXP_JCPLL_KBAND_CODE GENMASK(23, 16) 29 + #define CSR_2L_PXP_JCPLL_KBAND_DIV GENMASK(26, 24) 30 + 31 + #define REG_CSR_2L_JCPLL_KBAND_KFC 0x0010 32 + #define CSR_2L_PXP_JCPLL_KBAND_KFC GENMASK(1, 0) 33 + #define CSR_2L_PXP_JCPLL_KBAND_KF GENMASK(9, 8) 34 + #define CSR_2L_PXP_JCPLL_KBAND_KS GENMASK(17, 16) 35 + #define CSR_2L_PXP_JCPLL_POSTDIV_EN BIT(24) 36 + 37 + #define REG_CSR_2L_JCPLL_MMD_PREDIV_MODE 0x0014 38 + #define CSR_2L_PXP_JCPLL_MMD_PREDIV_MODE GENMASK(1, 0) 39 + #define CSR_2L_PXP_JCPLL_POSTDIV_D2 BIT(16) 40 + #define CSR_2L_PXP_JCPLL_POSTDIV_D5 BIT(24) 41 + 42 + #define CSR_2L_PXP_JCPLL_MONCK 0x0018 43 + #define CSR_2L_PXP_JCPLL_REFIN_DIV GENMASK(25, 24) 44 + 45 + #define REG_CSR_2L_JCPLL_RST_DLY 0x001c 46 + #define CSR_2L_PXP_JCPLL_RST_DLY GENMASK(2, 0) 47 + #define CSR_2L_PXP_JCPLL_RST BIT(8) 48 + #define CSR_2L_PXP_JCPLL_SDM_DI_EN BIT(16) 49 + #define CSR_2L_PXP_JCPLL_SDM_DI_LS GENMASK(25, 24) 50 + 51 + #define REG_CSR_2L_JCPLL_SDM_IFM 0x0020 52 + #define CSR_2L_PXP_JCPLL_SDM_IFM BIT(0) 53 + 54 + #define REG_CSR_2L_JCPLL_SDM_HREN 0x0024 55 + #define CSR_2L_PXP_JCPLL_SDM_HREN BIT(0) 56 + #define CSR_2L_PXP_JCPLL_TCL_AMP_EN BIT(8) 57 + #define CSR_2L_PXP_JCPLL_TCL_AMP_GAIN GENMASK(18, 16) 58 + #define CSR_2L_PXP_JCPLL_TCL_AMP_VREF GENMASK(28, 24) 59 + 60 + #define REG_CSR_2L_JCPLL_TCL_CMP 0x0028 61 + #define CSR_2L_PXP_JCPLL_TCL_LPF_EN BIT(16) 62 + #define CSR_2L_PXP_JCPLL_TCL_LPF_BW GENMASK(26, 24) 63 + 64 + #define REG_CSR_2L_JCPLL_VCODIV 0x002c 65 + #define CSR_2L_PXP_JCPLL_VCO_CFIX GENMASK(9, 8) 66 + #define CSR_2L_PXP_JCPLL_VCO_HALFLSB_EN BIT(16) 67 + #define CSR_2L_PXP_JCPLL_VCO_SCAPWR GENMASK(26, 24) 68 + 69 + #define REG_CSR_2L_JCPLL_VCO_TCLVAR 0x0030 70 + #define CSR_2L_PXP_JCPLL_VCO_TCLVAR GENMASK(2, 0) 71 + 72 + #define REG_CSR_2L_JCPLL_SSC 0x0038 73 + #define CSR_2L_PXP_JCPLL_SSC_EN BIT(0) 74 + #define CSR_2L_PXP_JCPLL_SSC_PHASE_INI BIT(8) 75 + #define CSR_2L_PXP_JCPLL_SSC_TRI_EN BIT(16) 76 + 77 + #define REG_CSR_2L_JCPLL_SSC_DELTA1 0x003c 78 + #define CSR_2L_PXP_JCPLL_SSC_DELTA1 GENMASK(15, 0) 79 + #define CSR_2L_PXP_JCPLL_SSC_DELTA GENMASK(31, 16) 80 + 81 + #define REG_CSR_2L_JCPLL_SSC_PERIOD 0x0040 82 + #define CSR_2L_PXP_JCPLL_SSC_PERIOD GENMASK(15, 0) 83 + 84 + #define REG_CSR_2L_JCPLL_TCL_VTP_EN 0x004c 85 + #define CSR_2L_PXP_JCPLL_SPARE_LOW GENMASK(31, 24) 86 + 87 + #define REG_CSR_2L_JCPLL_TCL_KBAND_VREF 0x0050 88 + #define CSR_2L_PXP_JCPLL_TCL_KBAND_VREF GENMASK(4, 0) 89 + #define CSR_2L_PXP_JCPLL_VCO_KBAND_MEAS_EN BIT(24) 90 + 91 + #define REG_CSR_2L_750M_SYS_CK 0x0054 92 + #define CSR_2L_PXP_TXPLL_LPF_SHCK_EN BIT(16) 93 + #define CSR_2L_PXP_TXPLL_CHP_IBIAS GENMASK(29, 24) 94 + 95 + #define REG_CSR_2L_TXPLL_CHP_IOFST 0x0058 96 + #define CSR_2L_PXP_TXPLL_CHP_IOFST GENMASK(5, 0) 97 + #define CSR_2L_PXP_TXPLL_LPF_BR GENMASK(12, 8) 98 + #define CSR_2L_PXP_TXPLL_LPF_BC GENMASK(20, 16) 99 + #define CSR_2L_PXP_TXPLL_LPF_BP GENMASK(28, 24) 100 + 101 + #define REG_CSR_2L_TXPLL_LPF_BWR 0x005c 102 + #define CSR_2L_PXP_TXPLL_LPF_BWR GENMASK(4, 0) 103 + #define CSR_2L_PXP_TXPLL_LPF_BWC GENMASK(12, 8) 104 + #define CSR_2L_PXP_TXPLL_KBAND_CODE GENMASK(31, 24) 105 + 106 + #define REG_CSR_2L_TXPLL_KBAND_DIV 0x0060 107 + #define CSR_2L_PXP_TXPLL_KBAND_DIV GENMASK(2, 0) 108 + #define CSR_2L_PXP_TXPLL_KBAND_KFC GENMASK(9, 8) 109 + #define CSR_2L_PXP_TXPLL_KBAND_KF GENMASK(17, 16) 110 + #define CSR_2L_PXP_txpll_KBAND_KS GENMASK(25, 24) 111 + 112 + #define REG_CSR_2L_TXPLL_POSTDIV 0x0064 113 + #define CSR_2L_PXP_TXPLL_POSTDIV_EN BIT(0) 114 + #define CSR_2L_PXP_TXPLL_MMD_PREDIV_MODE GENMASK(9, 8) 115 + #define CSR_2L_PXP_TXPLL_PHY_CK1_EN BIT(24) 116 + 117 + #define REG_CSR_2L_TXPLL_PHY_CK2 0x0068 118 + #define CSR_2L_PXP_TXPLL_REFIN_INTERNAL BIT(24) 119 + 120 + #define REG_CSR_2L_TXPLL_REFIN_DIV 0x006c 121 + #define CSR_2L_PXP_TXPLL_REFIN_DIV GENMASK(1, 0) 122 + #define CSR_2L_PXP_TXPLL_RST_DLY GENMASK(10, 8) 123 + #define CSR_2L_PXP_TXPLL_PLL_RSTB BIT(16) 124 + 125 + #define REG_CSR_2L_TXPLL_SDM_DI_LS 0x0070 126 + #define CSR_2L_PXP_TXPLL_SDM_DI_LS GENMASK(1, 0) 127 + #define CSR_2L_PXP_TXPLL_SDM_IFM BIT(8) 128 + #define CSR_2L_PXP_TXPLL_SDM_ORD GENMASK(25, 24) 129 + 130 + #define REG_CSR_2L_TXPLL_SDM_OUT 0x0074 131 + #define CSR_2L_PXP_TXPLL_TCL_AMP_EN BIT(16) 132 + #define CSR_2L_PXP_TXPLL_TCL_AMP_GAIN GENMASK(26, 24) 133 + 134 + #define REG_CSR_2L_TXPLL_TCL_AMP_VREF 0x0078 135 + #define CSR_2L_PXP_TXPLL_TCL_AMP_VREF GENMASK(4, 0) 136 + #define CSR_2L_PXP_TXPLL_TCL_LPF_EN BIT(24) 137 + 138 + #define REG_CSR_2L_TXPLL_TCL_LPF_BW 0x007c 139 + #define CSR_2L_PXP_TXPLL_TCL_LPF_BW GENMASK(2, 0) 140 + #define CSR_2L_PXP_TXPLL_VCO_CFIX GENMASK(17, 16) 141 + #define CSR_2L_PXP_TXPLL_VCO_HALFLSB_EN BIT(24) 142 + 143 + #define REG_CSR_2L_TXPLL_VCO_SCAPWR 0x0080 144 + #define CSR_2L_PXP_TXPLL_VCO_SCAPWR GENMASK(2, 0) 145 + 146 + #define REG_CSR_2L_TXPLL_SSC 0x0084 147 + #define CSR_2L_PXP_TXPLL_SSC_EN BIT(0) 148 + #define CSR_2L_PXP_TXPLL_SSC_PHASE_INI BIT(8) 149 + 150 + #define REG_CSR_2L_TXPLL_SSC_DELTA1 0x0088 151 + #define CSR_2L_PXP_TXPLL_SSC_DELTA1 GENMASK(15, 0) 152 + #define CSR_2L_PXP_TXPLL_SSC_DELTA GENMASK(31, 16) 153 + 154 + #define REG_CSR_2L_TXPLL_SSC_PERIOD 0x008c 155 + #define CSR_2L_PXP_txpll_SSC_PERIOD GENMASK(15, 0) 156 + 157 + #define REG_CSR_2L_TXPLL_VTP 0x0090 158 + #define CSR_2L_PXP_TXPLL_VTP_EN BIT(0) 159 + 160 + #define REG_CSR_2L_TXPLL_TCL_VTP 0x0098 161 + #define CSR_2L_PXP_TXPLL_SPARE_L GENMASK(31, 24) 162 + 163 + #define REG_CSR_2L_TXPLL_TCL_KBAND_VREF 0x009c 164 + #define CSR_2L_PXP_TXPLL_TCL_KBAND_VREF GENMASK(4, 0) 165 + #define CSR_2L_PXP_TXPLL_VCO_KBAND_MEAS_EN BIT(24) 166 + 167 + #define REG_CSR_2L_TXPLL_POSTDIV_D256 0x00a0 168 + #define CSR_2L_PXP_CLKTX0_AMP GENMASK(10, 8) 169 + #define CSR_2L_PXP_CLKTX0_OFFSET GENMASK(17, 16) 170 + #define CSR_2L_PXP_CLKTX0_SR GENMASK(25, 24) 171 + 172 + #define REG_CSR_2L_CLKTX0_FORCE_OUT1 0x00a4 173 + #define CSR_2L_PXP_CLKTX0_HZ BIT(8) 174 + #define CSR_2L_PXP_CLKTX0_IMP_SEL GENMASK(20, 16) 175 + #define CSR_2L_PXP_CLKTX1_AMP GENMASK(26, 24) 176 + 177 + #define REG_CSR_2L_CLKTX1_OFFSET 0x00a8 178 + #define CSR_2L_PXP_CLKTX1_OFFSET GENMASK(1, 0) 179 + #define CSR_2L_PXP_CLKTX1_SR GENMASK(9, 8) 180 + #define CSR_2L_PXP_CLKTX1_HZ BIT(24) 181 + 182 + #define REG_CSR_2L_CLKTX1_IMP_SEL 0x00ac 183 + #define CSR_2L_PXP_CLKTX1_IMP_SEL GENMASK(4, 0) 184 + 185 + #define REG_CSR_2L_PLL_CMN_RESERVE0 0x00b0 186 + #define CSR_2L_PXP_PLL_RESERVE_MASK GENMASK(15, 0) 187 + 188 + #define REG_CSR_2L_TX0_CKLDO 0x00cc 189 + #define CSR_2L_PXP_TX0_CKLDO_EN BIT(0) 190 + #define CSR_2L_PXP_TX0_DMEDGEGEN_EN BIT(24) 191 + 192 + #define REG_CSR_2L_TX1_CKLDO 0x00e8 193 + #define CSR_2L_PXP_TX1_CKLDO_EN BIT(0) 194 + #define CSR_2L_PXP_TX1_DMEDGEGEN_EN BIT(24) 195 + 196 + #define REG_CSR_2L_TX1_MULTLANE 0x00ec 197 + #define CSR_2L_PXP_TX1_MULTLANE_EN BIT(0) 198 + 199 + #define REG_CSR_2L_RX0_REV0 0x00fc 200 + #define CSR_2L_PXP_VOS_PNINV GENMASK(3, 2) 201 + #define CSR_2L_PXP_FE_GAIN_NORMAL_MODE GENMASK(6, 4) 202 + #define CSR_2L_PXP_FE_GAIN_TRAIN_MODE GENMASK(10, 8) 203 + 204 + #define REG_CSR_2L_RX0_PHYCK_DIV 0x0100 205 + #define CSR_2L_PXP_RX0_PHYCK_SEL GENMASK(9, 8) 206 + #define CSR_2L_PXP_RX0_PHYCK_RSTB BIT(16) 207 + #define CSR_2L_PXP_RX0_TDC_CK_SEL BIT(24) 208 + 209 + #define REG_CSR_2L_CDR0_PD_PICAL_CKD8_INV 0x0104 210 + #define CSR_2L_PXP_CDR0_PD_EDGE_DISABLE BIT(8) 211 + 212 + #define REG_CSR_2L_CDR0_LPF_RATIO 0x0110 213 + #define CSR_2L_PXP_CDR0_LPF_TOP_LIM GENMASK(26, 8) 214 + 215 + #define REG_CSR_2L_CDR0_PR_INJ_MODE 0x011c 216 + #define CSR_2L_PXP_CDR0_INJ_FORCE_OFF BIT(24) 217 + 218 + #define REG_CSR_2L_CDR0_PR_BETA_DAC 0x0120 219 + #define CSR_2L_PXP_CDR0_PR_BETA_SEL GENMASK(19, 16) 220 + #define CSR_2L_PXP_CDR0_PR_KBAND_DIV GENMASK(26, 24) 221 + 222 + #define REG_CSR_2L_CDR0_PR_VREG_IBAND 0x0124 223 + #define CSR_2L_PXP_CDR0_PR_VREG_IBAND GENMASK(2, 0) 224 + #define CSR_2L_PXP_CDR0_PR_VREG_CKBUF GENMASK(10, 8) 225 + 226 + #define REG_CSR_2L_CDR0_PR_CKREF_DIV 0x0128 227 + #define CSR_2L_PXP_CDR0_PR_CKREF_DIV GENMASK(1, 0) 228 + 229 + #define REG_CSR_2L_CDR0_PR_MONCK 0x012c 230 + #define CSR_2L_PXP_CDR0_PR_MONCK_ENABLE BIT(0) 231 + #define CSR_2L_PXP_CDR0_PR_RESERVE0 GENMASK(19, 16) 232 + 233 + #define REG_CSR_2L_CDR0_PR_COR_HBW 0x0130 234 + #define CSR_2L_PXP_CDR0_PR_LDO_FORCE_ON BIT(8) 235 + #define CSR_2L_PXP_CDR0_PR_CKREF_DIV1 GENMASK(17, 16) 236 + 237 + #define REG_CSR_2L_CDR0_PR_MONPI 0x0134 238 + #define CSR_2L_PXP_CDR0_PR_XFICK_EN BIT(8) 239 + 240 + #define REG_CSR_2L_RX0_SIGDET_DCTEST 0x0140 241 + #define CSR_2L_PXP_RX0_SIGDET_LPF_CTRL GENMASK(9, 8) 242 + #define CSR_2L_PXP_RX0_SIGDET_PEAK GENMASK(25, 24) 243 + 244 + #define REG_CSR_2L_RX0_SIGDET_VTH_SEL 0x0144 245 + #define CSR_2L_PXP_RX0_SIGDET_VTH_SEL GENMASK(4, 0) 246 + #define CSR_2L_PXP_RX0_FE_VB_EQ1_EN BIT(24) 247 + 248 + #define REG_CSR_2L_PXP_RX0_FE_VB_EQ2 0x0148 249 + #define CSR_2L_PXP_RX0_FE_VB_EQ2_EN BIT(0) 250 + #define CSR_2L_PXP_RX0_FE_VB_EQ3_EN BIT(8) 251 + #define CSR_2L_PXP_RX0_FE_VCM_GEN_PWDB BIT(16) 252 + 253 + #define REG_CSR_2L_PXP_RX0_OSCAL_CTLE1IOS 0x0158 254 + #define CSR_2L_PXP_RX0_PR_OSCAL_VGA1IOS GENMASK(29, 24) 255 + 256 + #define REG_CSR_2L_PXP_RX0_OSCA_VGA1VOS 0x015c 257 + #define CSR_2L_PXP_RX0_PR_OSCAL_VGA1VOS GENMASK(5, 0) 258 + #define CSR_2L_PXP_RX0_PR_OSCAL_VGA2IOS GENMASK(13, 8) 259 + 260 + #define REG_CSR_2L_RX1_REV0 0x01b4 261 + 262 + #define REG_CSR_2L_RX1_PHYCK_DIV 0x01b8 263 + #define CSR_2L_PXP_RX1_PHYCK_SEL GENMASK(9, 8) 264 + #define CSR_2L_PXP_RX1_PHYCK_RSTB BIT(16) 265 + #define CSR_2L_PXP_RX1_TDC_CK_SEL BIT(24) 266 + 267 + #define REG_CSR_2L_CDR1_PD_PICAL_CKD8_INV 0x01bc 268 + #define CSR_2L_PXP_CDR1_PD_EDGE_DISABLE BIT(8) 269 + 270 + #define REG_CSR_2L_CDR1_PR_BETA_DAC 0x01d8 271 + #define CSR_2L_PXP_CDR1_PR_BETA_SEL GENMASK(19, 16) 272 + #define CSR_2L_PXP_CDR1_PR_KBAND_DIV GENMASK(26, 24) 273 + 274 + #define REG_CSR_2L_CDR1_PR_MONCK 0x01e4 275 + #define CSR_2L_PXP_CDR1_PR_MONCK_ENABLE BIT(0) 276 + #define CSR_2L_PXP_CDR1_PR_RESERVE0 GENMASK(19, 16) 277 + 278 + #define REG_CSR_2L_CDR1_LPF_RATIO 0x01c8 279 + #define CSR_2L_PXP_CDR1_LPF_TOP_LIM GENMASK(26, 8) 280 + 281 + #define REG_CSR_2L_CDR1_PR_INJ_MODE 0x01d4 282 + #define CSR_2L_PXP_CDR1_INJ_FORCE_OFF BIT(24) 283 + 284 + #define REG_CSR_2L_CDR1_PR_VREG_IBAND_VAL 0x01dc 285 + #define CSR_2L_PXP_CDR1_PR_VREG_IBAND GENMASK(2, 0) 286 + #define CSR_2L_PXP_CDR1_PR_VREG_CKBUF GENMASK(10, 8) 287 + 288 + #define REG_CSR_2L_CDR1_PR_CKREF_DIV 0x01e0 289 + #define CSR_2L_PXP_CDR1_PR_CKREF_DIV GENMASK(1, 0) 290 + 291 + #define REG_CSR_2L_CDR1_PR_COR_HBW 0x01e8 292 + #define CSR_2L_PXP_CDR1_PR_LDO_FORCE_ON BIT(8) 293 + #define CSR_2L_PXP_CDR1_PR_CKREF_DIV1 GENMASK(17, 16) 294 + 295 + #define REG_CSR_2L_CDR1_PR_MONPI 0x01ec 296 + #define CSR_2L_PXP_CDR1_PR_XFICK_EN BIT(8) 297 + 298 + #define REG_CSR_2L_RX1_DAC_RANGE_EYE 0x01f4 299 + #define CSR_2L_PXP_RX1_SIGDET_LPF_CTRL GENMASK(25, 24) 300 + 301 + #define REG_CSR_2L_RX1_SIGDET_NOVTH 0x01f8 302 + #define CSR_2L_PXP_RX1_SIGDET_PEAK GENMASK(9, 8) 303 + #define CSR_2L_PXP_RX1_SIGDET_VTH_SEL GENMASK(20, 16) 304 + 305 + #define REG_CSR_2L_RX1_FE_VB_EQ1 0x0200 306 + #define CSR_2L_PXP_RX1_FE_VB_EQ1_EN BIT(0) 307 + #define CSR_2L_PXP_RX1_FE_VB_EQ2_EN BIT(8) 308 + #define CSR_2L_PXP_RX1_FE_VB_EQ3_EN BIT(16) 309 + #define CSR_2L_PXP_RX1_FE_VCM_GEN_PWDB BIT(24) 310 + 311 + #define REG_CSR_2L_RX1_OSCAL_VGA1IOS 0x0214 312 + #define CSR_2L_PXP_RX1_PR_OSCAL_VGA1IOS GENMASK(5, 0) 313 + #define CSR_2L_PXP_RX1_PR_OSCAL_VGA1VOS GENMASK(13, 8) 314 + #define CSR_2L_PXP_RX1_PR_OSCAL_VGA2IOS GENMASK(21, 16) 315 + 316 + /* PMA */ 317 + #define REG_PCIE_PMA_SS_LCPLL_PWCTL_SETTING_1 0x0004 318 + #define PCIE_LCPLL_MAN_PWDB BIT(0) 319 + 320 + #define REG_PCIE_PMA_SEQUENCE_DISB_CTRL1 0x010c 321 + #define PCIE_DISB_RX_SDCAL_EN BIT(0) 322 + 323 + #define REG_PCIE_PMA_CTRL_SEQUENCE_FORCE_CTRL1 0x0114 324 + #define PCIE_FORCE_RX_SDCAL_EN BIT(0) 325 + 326 + #define REG_PCIE_PMA_SS_RX_FREQ_DET1 0x014c 327 + #define PCIE_PLL_FT_LOCK_CYCLECNT GENMASK(15, 0) 328 + #define PCIE_PLL_FT_UNLOCK_CYCLECNT GENMASK(31, 16) 329 + 330 + #define REG_PCIE_PMA_SS_RX_FREQ_DET2 0x0150 331 + #define PCIE_LOCK_TARGET_BEG GENMASK(15, 0) 332 + #define PCIE_LOCK_TARGET_END GENMASK(31, 16) 333 + 334 + #define REG_PCIE_PMA_SS_RX_FREQ_DET3 0x0154 335 + #define PCIE_UNLOCK_TARGET_BEG GENMASK(15, 0) 336 + #define PCIE_UNLOCK_TARGET_END GENMASK(31, 16) 337 + 338 + #define REG_PCIE_PMA_SS_RX_FREQ_DET4 0x0158 339 + #define PCIE_FREQLOCK_DET_EN GENMASK(2, 0) 340 + #define PCIE_LOCK_LOCKTH GENMASK(11, 8) 341 + #define PCIE_UNLOCK_LOCKTH GENMASK(15, 12) 342 + 343 + #define REG_PCIE_PMA_SS_RX_CAL1 0x0160 344 + #define REG_PCIE_PMA_SS_RX_CAL2 0x0164 345 + #define PCIE_CAL_OUT_OS GENMASK(11, 8) 346 + 347 + #define REG_PCIE_PMA_SS_RX_SIGDET0 0x0168 348 + #define PCIE_SIGDET_WIN_NONVLD_TIMES GENMASK(28, 24) 349 + 350 + #define REG_PCIE_PMA_TX_RESET 0x0260 351 + #define PCIE_TX_TOP_RST BIT(0) 352 + #define PCIE_TX_CAL_RST BIT(8) 353 + 354 + #define REG_PCIE_PMA_RX_FORCE_MODE0 0x0294 355 + #define PCIE_FORCE_DA_XPON_RX_FE_GAIN_CTRL GENMASK(1, 0) 356 + 357 + #define REG_PCIE_PMA_SS_DA_XPON_PWDB0 0x034c 358 + #define PCIE_DA_XPON_CDR_PR_PWDB BIT(8) 359 + 360 + #define REG_PCIE_PMA_SW_RESET 0x0460 361 + #define PCIE_SW_RX_FIFO_RST BIT(0) 362 + #define PCIE_SW_RX_RST BIT(1) 363 + #define PCIE_SW_TX_RST BIT(2) 364 + #define PCIE_SW_PMA_RST BIT(3) 365 + #define PCIE_SW_ALLPCS_RST BIT(4) 366 + #define PCIE_SW_REF_RST BIT(5) 367 + #define PCIE_SW_TX_FIFO_RST BIT(6) 368 + #define PCIE_SW_XFI_TXPCS_RST BIT(7) 369 + #define PCIE_SW_XFI_RXPCS_RST BIT(8) 370 + #define PCIE_SW_XFI_RXPCS_BIST_RST BIT(9) 371 + #define PCIE_SW_HSG_TXPCS_RST BIT(10) 372 + #define PCIE_SW_HSG_RXPCS_RST BIT(11) 373 + #define PCIE_PMA_SW_RST (PCIE_SW_RX_FIFO_RST | \ 374 + PCIE_SW_RX_RST | \ 375 + PCIE_SW_TX_RST | \ 376 + PCIE_SW_PMA_RST | \ 377 + PCIE_SW_ALLPCS_RST | \ 378 + PCIE_SW_REF_RST | \ 379 + PCIE_SW_TX_FIFO_RST | \ 380 + PCIE_SW_XFI_TXPCS_RST | \ 381 + PCIE_SW_XFI_RXPCS_RST | \ 382 + PCIE_SW_XFI_RXPCS_BIST_RST | \ 383 + PCIE_SW_HSG_TXPCS_RST | \ 384 + PCIE_SW_HSG_RXPCS_RST) 385 + 386 + #define REG_PCIE_PMA_RO_RX_FREQDET 0x0530 387 + #define PCIE_RO_FBCK_LOCK BIT(0) 388 + #define PCIE_RO_FL_OUT GENMASK(31, 16) 389 + 390 + #define REG_PCIE_PMA_FORCE_DA_PXP_CDR_PR_IDAC 0x0794 391 + #define PCIE_FORCE_DA_PXP_CDR_PR_IDAC GENMASK(10, 0) 392 + #define PCIE_FORCE_SEL_DA_PXP_CDR_PR_IDAC BIT(16) 393 + #define PCIE_FORCE_SEL_DA_PXP_TXPLL_SDM_PCW BIT(24) 394 + 395 + #define REG_PCIE_PMA_FORCE_DA_PXP_TXPLL_SDM_PCW 0x0798 396 + #define PCIE_FORCE_DA_PXP_TXPLL_SDM_PCW GENMASK(30, 0) 397 + 398 + #define REG_PCIE_PMA_FORCE_DA_PXP_RX_FE_VOS 0x079c 399 + #define PCIE_FORCE_SEL_DA_PXP_JCPLL_SDM_PCW BIT(16) 400 + 401 + #define REG_PCIE_PMA_FORCE_DA_PXP_JCPLL_SDM_PCW 0x0800 402 + #define PCIE_FORCE_DA_PXP_JCPLL_SDM_PCW GENMASK(30, 0) 403 + 404 + #define REG_PCIE_PMA_FORCE_DA_PXP_CDR_PD_PWDB 0x081c 405 + #define PCIE_FORCE_DA_PXP_CDR_PD_PWDB BIT(0) 406 + #define PCIE_FORCE_SEL_DA_PXP_CDR_PD_PWDB BIT(8) 407 + 408 + #define REG_PCIE_PMA_FORCE_DA_PXP_CDR_PR_LPF_C 0x0820 409 + #define PCIE_FORCE_DA_PXP_CDR_PR_LPF_C_EN BIT(0) 410 + #define PCIE_FORCE_SEL_DA_PXP_CDR_PR_LPF_C_EN BIT(8) 411 + #define PCIE_FORCE_DA_PXP_CDR_PR_LPF_R_EN BIT(16) 412 + #define PCIE_FORCE_SEL_DA_PXP_CDR_PR_LPF_R_EN BIT(24) 413 + 414 + #define REG_PCIE_PMA_FORCE_DA_PXP_CDR_PR_PIEYE_PWDB 0x0824 415 + #define PCIE_FORCE_DA_PXP_CDR_PR_PWDB BIT(16) 416 + #define PCIE_FORCE_SEL_DA_PXP_CDR_PR_PWDB BIT(24) 417 + 418 + #define REG_PCIE_PMA_FORCE_PXP_JCPLL_CKOUT 0x0828 419 + #define PCIE_FORCE_DA_PXP_JCPLL_CKOUT_EN BIT(0) 420 + #define PCIE_FORCE_SEL_DA_PXP_JCPLL_CKOUT_EN BIT(8) 421 + #define PCIE_FORCE_DA_PXP_JCPLL_EN BIT(16) 422 + #define PCIE_FORCE_SEL_DA_PXP_JCPLL_EN BIT(24) 423 + 424 + #define REG_PCIE_PMA_FORCE_DA_PXP_RX_SCAN_RST 0x0084c 425 + #define PCIE_FORCE_DA_PXP_RX_SIGDET_PWDB BIT(16) 426 + #define PCIE_FORCE_SEL_DA_PXP_RX_SIGDET_PWDB BIT(24) 427 + 428 + #define REG_PCIE_PMA_FORCE_DA_PXP_TXPLL_CKOUT 0x0854 429 + #define PCIE_FORCE_DA_PXP_TXPLL_CKOUT_EN BIT(0) 430 + #define PCIE_FORCE_SEL_DA_PXP_TXPLL_CKOUT_EN BIT(8) 431 + #define PCIE_FORCE_DA_PXP_TXPLL_EN BIT(16) 432 + #define PCIE_FORCE_SEL_DA_PXP_TXPLL_EN BIT(24) 433 + 434 + #define REG_PCIE_PMA_SCAN_MODE 0x0884 435 + #define PCIE_FORCE_DA_PXP_JCPLL_KBAND_LOAD_EN BIT(0) 436 + #define PCIE_FORCE_SEL_DA_PXP_JCPLL_KBAND_LOAD_EN BIT(8) 437 + 438 + #define REG_PCIE_PMA_DIG_RESERVE_13 0x08bc 439 + #define PCIE_FLL_IDAC_PCIEG1 GENMASK(10, 0) 440 + #define PCIE_FLL_IDAC_PCIEG2 GENMASK(26, 16) 441 + 442 + #define REG_PCIE_PMA_DIG_RESERVE_14 0x08c0 443 + #define PCIE_FLL_IDAC_PCIEG3 GENMASK(10, 0) 444 + #define PCIE_FLL_LOAD_EN BIT(16) 445 + 446 + #define REG_PCIE_PMA_FORCE_DA_PXP_RX_FE_GAIN_CTRL 0x088c 447 + #define PCIE_FORCE_DA_PXP_RX_FE_GAIN_CTRL GENMASK(1, 0) 448 + #define PCIE_FORCE_SEL_DA_PXP_RX_FE_GAIN_CTRL BIT(8) 449 + 450 + #define REG_PCIE_PMA_FORCE_DA_PXP_RX_FE_PWDB 0x0894 451 + #define PCIE_FORCE_DA_PXP_RX_FE_PWDB BIT(0) 452 + #define PCIE_FORCE_SEL_DA_PXP_RX_FE_PWDB BIT(8) 453 + 454 + #define REG_PCIE_PMA_DIG_RESERVE_12 0x08b8 455 + #define PCIE_FORCE_PMA_RX_SPEED GENMASK(7, 4) 456 + #define PCIE_FORCE_SEL_PMA_RX_SPEED BIT(7) 457 + 458 + #define REG_PCIE_PMA_DIG_RESERVE_17 0x08e0 459 + 460 + #define REG_PCIE_PMA_DIG_RESERVE_18 0x08e4 461 + #define PCIE_PXP_RX_VTH_SEL_PCIE_G1 GENMASK(4, 0) 462 + #define PCIE_PXP_RX_VTH_SEL_PCIE_G2 GENMASK(12, 8) 463 + #define PCIE_PXP_RX_VTH_SEL_PCIE_G3 GENMASK(20, 16) 464 + 465 + #define REG_PCIE_PMA_DIG_RESERVE_19 0x08e8 466 + #define PCIE_PCP_RX_REV0_PCIE_GEN1 GENMASK(31, 16) 467 + 468 + #define REG_PCIE_PMA_DIG_RESERVE_20 0x08ec 469 + #define PCIE_PCP_RX_REV0_PCIE_GEN2 GENMASK(15, 0) 470 + #define PCIE_PCP_RX_REV0_PCIE_GEN3 GENMASK(31, 16) 471 + 472 + #define REG_PCIE_PMA_DIG_RESERVE_21 0x08f0 473 + #define REG_PCIE_PMA_DIG_RESERVE_22 0x08f4 474 + #define REG_PCIE_PMA_DIG_RESERVE_27 0x0908 475 + #define REG_PCIE_PMA_DIG_RESERVE_30 0x0914 476 + 477 + #endif /* _PHY_AIROHA_PCIE_H */
+1248
drivers/phy/phy-airoha-pcie.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + /* 3 + * Copyright (c) 2024 AIROHA Inc 4 + * Author: Lorenzo Bianconi <lorenzo@kernel.org> 5 + */ 6 + 7 + #include <linux/bitfield.h> 8 + #include <linux/delay.h> 9 + #include <linux/io.h> 10 + #include <linux/module.h> 11 + #include <linux/of.h> 12 + #include <linux/phy/phy.h> 13 + #include <linux/platform_device.h> 14 + #include <linux/slab.h> 15 + 16 + #include "phy-airoha-pcie-regs.h" 17 + 18 + #define LEQ_LEN_CTRL_MAX_VAL 7 19 + #define FREQ_LOCK_MAX_ATTEMPT 10 20 + 21 + enum airoha_pcie_port_gen { 22 + PCIE_PORT_GEN1 = 1, 23 + PCIE_PORT_GEN2, 24 + PCIE_PORT_GEN3, 25 + }; 26 + 27 + /** 28 + * struct airoha_pcie_phy - PCIe phy driver main structure 29 + * @dev: pointer to device 30 + * @phy: pointer to generic phy 31 + * @csr_2l: Analogic lane IO mapped register base address 32 + * @pma0: IO mapped register base address of PMA0-PCIe 33 + * @pma1: IO mapped register base address of PMA1-PCIe 34 + */ 35 + struct airoha_pcie_phy { 36 + struct device *dev; 37 + struct phy *phy; 38 + void __iomem *csr_2l; 39 + void __iomem *pma0; 40 + void __iomem *pma1; 41 + }; 42 + 43 + static void airoha_phy_clear_bits(void __iomem *reg, u32 mask) 44 + { 45 + u32 val = readl(reg) & ~mask; 46 + 47 + writel(val, reg); 48 + } 49 + 50 + static void airoha_phy_set_bits(void __iomem *reg, u32 mask) 51 + { 52 + u32 val = readl(reg) | mask; 53 + 54 + writel(val, reg); 55 + } 56 + 57 + static void airoha_phy_update_bits(void __iomem *reg, u32 mask, u32 val) 58 + { 59 + u32 tmp = readl(reg); 60 + 61 + tmp &= ~mask; 62 + tmp |= val & mask; 63 + writel(tmp, reg); 64 + } 65 + 66 + #define airoha_phy_update_field(reg, mask, val) \ 67 + do { \ 68 + BUILD_BUG_ON_MSG(!__builtin_constant_p((mask)), \ 69 + "mask is not constant"); \ 70 + airoha_phy_update_bits((reg), (mask), \ 71 + FIELD_PREP((mask), (val))); \ 72 + } while (0) 73 + 74 + #define airoha_phy_csr_2l_clear_bits(pcie_phy, reg, mask) \ 75 + airoha_phy_clear_bits((pcie_phy)->csr_2l + (reg), (mask)) 76 + #define airoha_phy_csr_2l_set_bits(pcie_phy, reg, mask) \ 77 + airoha_phy_set_bits((pcie_phy)->csr_2l + (reg), (mask)) 78 + #define airoha_phy_csr_2l_update_field(pcie_phy, reg, mask, val) \ 79 + airoha_phy_update_field((pcie_phy)->csr_2l + (reg), (mask), (val)) 80 + #define airoha_phy_pma0_clear_bits(pcie_phy, reg, mask) \ 81 + airoha_phy_clear_bits((pcie_phy)->pma0 + (reg), (mask)) 82 + #define airoha_phy_pma1_clear_bits(pcie_phy, reg, mask) \ 83 + airoha_phy_clear_bits((pcie_phy)->pma1 + (reg), (mask)) 84 + #define airoha_phy_pma0_set_bits(pcie_phy, reg, mask) \ 85 + airoha_phy_set_bits((pcie_phy)->pma0 + (reg), (mask)) 86 + #define airoha_phy_pma1_set_bits(pcie_phy, reg, mask) \ 87 + airoha_phy_set_bits((pcie_phy)->pma1 + (reg), (mask)) 88 + #define airoha_phy_pma0_update_field(pcie_phy, reg, mask, val) \ 89 + airoha_phy_update_field((pcie_phy)->pma0 + (reg), (mask), (val)) 90 + #define airoha_phy_pma1_update_field(pcie_phy, reg, mask, val) \ 91 + airoha_phy_update_field((pcie_phy)->pma1 + (reg), (mask), (val)) 92 + 93 + static void 94 + airoha_phy_init_lane0_rx_fw_pre_calib(struct airoha_pcie_phy *pcie_phy, 95 + enum airoha_pcie_port_gen gen) 96 + { 97 + u32 fl_out_target = gen == PCIE_PORT_GEN3 ? 41600 : 41941; 98 + u32 lock_cyclecnt = gen == PCIE_PORT_GEN3 ? 26000 : 32767; 99 + u32 pr_idac, val, cdr_pr_idac_tmp = 0; 100 + int i; 101 + 102 + airoha_phy_pma0_set_bits(pcie_phy, 103 + REG_PCIE_PMA_SS_LCPLL_PWCTL_SETTING_1, 104 + PCIE_LCPLL_MAN_PWDB); 105 + airoha_phy_pma0_update_field(pcie_phy, REG_PCIE_PMA_SS_RX_FREQ_DET2, 106 + PCIE_LOCK_TARGET_BEG, 107 + fl_out_target - 100); 108 + airoha_phy_pma0_update_field(pcie_phy, REG_PCIE_PMA_SS_RX_FREQ_DET2, 109 + PCIE_LOCK_TARGET_END, 110 + fl_out_target + 100); 111 + airoha_phy_pma0_update_field(pcie_phy, REG_PCIE_PMA_SS_RX_FREQ_DET1, 112 + PCIE_PLL_FT_LOCK_CYCLECNT, lock_cyclecnt); 113 + airoha_phy_pma0_update_field(pcie_phy, REG_PCIE_PMA_SS_RX_FREQ_DET4, 114 + PCIE_LOCK_LOCKTH, 0x3); 115 + airoha_phy_pma0_update_field(pcie_phy, REG_PCIE_PMA_SS_RX_FREQ_DET3, 116 + PCIE_UNLOCK_TARGET_BEG, 117 + fl_out_target - 100); 118 + airoha_phy_pma0_update_field(pcie_phy, REG_PCIE_PMA_SS_RX_FREQ_DET3, 119 + PCIE_UNLOCK_TARGET_END, 120 + fl_out_target + 100); 121 + airoha_phy_pma0_update_field(pcie_phy, REG_PCIE_PMA_SS_RX_FREQ_DET1, 122 + PCIE_PLL_FT_UNLOCK_CYCLECNT, 123 + lock_cyclecnt); 124 + airoha_phy_pma0_update_field(pcie_phy, REG_PCIE_PMA_SS_RX_FREQ_DET4, 125 + PCIE_UNLOCK_LOCKTH, 0x3); 126 + 127 + airoha_phy_csr_2l_set_bits(pcie_phy, REG_CSR_2L_CDR0_PR_INJ_MODE, 128 + CSR_2L_PXP_CDR0_INJ_FORCE_OFF); 129 + 130 + airoha_phy_pma0_set_bits(pcie_phy, 131 + REG_PCIE_PMA_FORCE_DA_PXP_CDR_PR_LPF_C, 132 + PCIE_FORCE_SEL_DA_PXP_CDR_PR_LPF_R_EN); 133 + airoha_phy_pma0_set_bits(pcie_phy, 134 + REG_PCIE_PMA_FORCE_DA_PXP_CDR_PR_LPF_C, 135 + PCIE_FORCE_DA_PXP_CDR_PR_LPF_R_EN); 136 + airoha_phy_pma0_set_bits(pcie_phy, 137 + REG_PCIE_PMA_FORCE_DA_PXP_CDR_PR_LPF_C, 138 + PCIE_FORCE_SEL_DA_PXP_CDR_PR_LPF_C_EN); 139 + airoha_phy_pma0_clear_bits(pcie_phy, 140 + REG_PCIE_PMA_FORCE_DA_PXP_CDR_PR_LPF_C, 141 + PCIE_FORCE_DA_PXP_CDR_PR_LPF_C_EN); 142 + airoha_phy_pma0_set_bits(pcie_phy, 143 + REG_PCIE_PMA_FORCE_DA_PXP_CDR_PR_IDAC, 144 + PCIE_FORCE_SEL_DA_PXP_CDR_PR_IDAC); 145 + 146 + airoha_phy_pma0_set_bits(pcie_phy, 147 + REG_PCIE_PMA_FORCE_DA_PXP_CDR_PR_PIEYE_PWDB, 148 + PCIE_FORCE_SEL_DA_PXP_CDR_PR_PWDB); 149 + airoha_phy_pma0_clear_bits(pcie_phy, 150 + REG_PCIE_PMA_FORCE_DA_PXP_CDR_PR_PIEYE_PWDB, 151 + PCIE_FORCE_DA_PXP_CDR_PR_PWDB); 152 + airoha_phy_pma0_set_bits(pcie_phy, 153 + REG_PCIE_PMA_FORCE_DA_PXP_CDR_PR_PIEYE_PWDB, 154 + PCIE_FORCE_DA_PXP_CDR_PR_PWDB); 155 + 156 + for (i = 0; i < LEQ_LEN_CTRL_MAX_VAL; i++) { 157 + airoha_phy_pma0_update_field(pcie_phy, 158 + REG_PCIE_PMA_FORCE_DA_PXP_CDR_PR_IDAC, 159 + PCIE_FORCE_DA_PXP_CDR_PR_IDAC, i << 8); 160 + airoha_phy_pma0_clear_bits(pcie_phy, 161 + REG_PCIE_PMA_SS_RX_FREQ_DET4, 162 + PCIE_FREQLOCK_DET_EN); 163 + airoha_phy_pma0_update_field(pcie_phy, 164 + REG_PCIE_PMA_SS_RX_FREQ_DET4, 165 + PCIE_FREQLOCK_DET_EN, 0x3); 166 + 167 + usleep_range(10000, 15000); 168 + 169 + val = FIELD_GET(PCIE_RO_FL_OUT, 170 + readl(pcie_phy->pma0 + 171 + REG_PCIE_PMA_RO_RX_FREQDET)); 172 + if (val > fl_out_target) 173 + cdr_pr_idac_tmp = i << 8; 174 + } 175 + 176 + for (i = LEQ_LEN_CTRL_MAX_VAL; i >= 0; i--) { 177 + pr_idac = cdr_pr_idac_tmp | (0x1 << i); 178 + airoha_phy_pma0_update_field(pcie_phy, 179 + REG_PCIE_PMA_FORCE_DA_PXP_CDR_PR_IDAC, 180 + PCIE_FORCE_DA_PXP_CDR_PR_IDAC, pr_idac); 181 + airoha_phy_pma0_clear_bits(pcie_phy, 182 + REG_PCIE_PMA_SS_RX_FREQ_DET4, 183 + PCIE_FREQLOCK_DET_EN); 184 + airoha_phy_pma0_update_field(pcie_phy, 185 + REG_PCIE_PMA_SS_RX_FREQ_DET4, 186 + PCIE_FREQLOCK_DET_EN, 0x3); 187 + 188 + usleep_range(10000, 15000); 189 + 190 + val = FIELD_GET(PCIE_RO_FL_OUT, 191 + readl(pcie_phy->pma0 + 192 + REG_PCIE_PMA_RO_RX_FREQDET)); 193 + if (val < fl_out_target) 194 + pr_idac &= ~(0x1 << i); 195 + 196 + cdr_pr_idac_tmp = pr_idac; 197 + } 198 + 199 + airoha_phy_pma0_update_field(pcie_phy, 200 + REG_PCIE_PMA_FORCE_DA_PXP_CDR_PR_IDAC, 201 + PCIE_FORCE_DA_PXP_CDR_PR_IDAC, 202 + cdr_pr_idac_tmp); 203 + 204 + for (i = 0; i < FREQ_LOCK_MAX_ATTEMPT; i++) { 205 + u32 val; 206 + 207 + airoha_phy_pma0_clear_bits(pcie_phy, 208 + REG_PCIE_PMA_SS_RX_FREQ_DET4, 209 + PCIE_FREQLOCK_DET_EN); 210 + airoha_phy_pma0_update_field(pcie_phy, 211 + REG_PCIE_PMA_SS_RX_FREQ_DET4, 212 + PCIE_FREQLOCK_DET_EN, 0x3); 213 + 214 + usleep_range(10000, 15000); 215 + 216 + val = readl(pcie_phy->pma0 + REG_PCIE_PMA_RO_RX_FREQDET); 217 + if (val & PCIE_RO_FBCK_LOCK) 218 + break; 219 + } 220 + 221 + /* turn off force mode and update band values */ 222 + airoha_phy_csr_2l_clear_bits(pcie_phy, REG_CSR_2L_CDR0_PR_INJ_MODE, 223 + CSR_2L_PXP_CDR0_INJ_FORCE_OFF); 224 + 225 + airoha_phy_pma0_clear_bits(pcie_phy, 226 + REG_PCIE_PMA_FORCE_DA_PXP_CDR_PR_LPF_C, 227 + PCIE_FORCE_SEL_DA_PXP_CDR_PR_LPF_R_EN); 228 + airoha_phy_pma0_clear_bits(pcie_phy, 229 + REG_PCIE_PMA_FORCE_DA_PXP_CDR_PR_LPF_C, 230 + PCIE_FORCE_SEL_DA_PXP_CDR_PR_LPF_C_EN); 231 + airoha_phy_pma0_clear_bits(pcie_phy, 232 + REG_PCIE_PMA_FORCE_DA_PXP_CDR_PR_PIEYE_PWDB, 233 + PCIE_FORCE_SEL_DA_PXP_CDR_PR_PWDB); 234 + airoha_phy_pma0_clear_bits(pcie_phy, 235 + REG_PCIE_PMA_FORCE_DA_PXP_CDR_PR_IDAC, 236 + PCIE_FORCE_SEL_DA_PXP_CDR_PR_IDAC); 237 + if (gen == PCIE_PORT_GEN3) { 238 + airoha_phy_pma0_update_field(pcie_phy, 239 + REG_PCIE_PMA_DIG_RESERVE_14, 240 + PCIE_FLL_IDAC_PCIEG3, 241 + cdr_pr_idac_tmp); 242 + } else { 243 + airoha_phy_pma0_update_field(pcie_phy, 244 + REG_PCIE_PMA_DIG_RESERVE_13, 245 + PCIE_FLL_IDAC_PCIEG1, 246 + cdr_pr_idac_tmp); 247 + airoha_phy_pma0_update_field(pcie_phy, 248 + REG_PCIE_PMA_DIG_RESERVE_13, 249 + PCIE_FLL_IDAC_PCIEG2, 250 + cdr_pr_idac_tmp); 251 + } 252 + } 253 + 254 + static void 255 + airoha_phy_init_lane1_rx_fw_pre_calib(struct airoha_pcie_phy *pcie_phy, 256 + enum airoha_pcie_port_gen gen) 257 + { 258 + u32 fl_out_target = gen == PCIE_PORT_GEN3 ? 41600 : 41941; 259 + u32 lock_cyclecnt = gen == PCIE_PORT_GEN3 ? 26000 : 32767; 260 + u32 pr_idac, val, cdr_pr_idac_tmp = 0; 261 + int i; 262 + 263 + airoha_phy_pma1_set_bits(pcie_phy, 264 + REG_PCIE_PMA_SS_LCPLL_PWCTL_SETTING_1, 265 + PCIE_LCPLL_MAN_PWDB); 266 + airoha_phy_pma1_update_field(pcie_phy, REG_PCIE_PMA_SS_RX_FREQ_DET2, 267 + PCIE_LOCK_TARGET_BEG, 268 + fl_out_target - 100); 269 + airoha_phy_pma1_update_field(pcie_phy, REG_PCIE_PMA_SS_RX_FREQ_DET2, 270 + PCIE_LOCK_TARGET_END, 271 + fl_out_target + 100); 272 + airoha_phy_pma1_update_field(pcie_phy, REG_PCIE_PMA_SS_RX_FREQ_DET1, 273 + PCIE_PLL_FT_LOCK_CYCLECNT, lock_cyclecnt); 274 + airoha_phy_pma1_update_field(pcie_phy, REG_PCIE_PMA_SS_RX_FREQ_DET4, 275 + PCIE_LOCK_LOCKTH, 0x3); 276 + airoha_phy_pma1_update_field(pcie_phy, REG_PCIE_PMA_SS_RX_FREQ_DET3, 277 + PCIE_UNLOCK_TARGET_BEG, 278 + fl_out_target - 100); 279 + airoha_phy_pma1_update_field(pcie_phy, REG_PCIE_PMA_SS_RX_FREQ_DET3, 280 + PCIE_UNLOCK_TARGET_END, 281 + fl_out_target + 100); 282 + airoha_phy_pma1_update_field(pcie_phy, REG_PCIE_PMA_SS_RX_FREQ_DET1, 283 + PCIE_PLL_FT_UNLOCK_CYCLECNT, 284 + lock_cyclecnt); 285 + airoha_phy_pma1_update_field(pcie_phy, REG_PCIE_PMA_SS_RX_FREQ_DET4, 286 + PCIE_UNLOCK_LOCKTH, 0x3); 287 + 288 + airoha_phy_csr_2l_set_bits(pcie_phy, REG_CSR_2L_CDR1_PR_INJ_MODE, 289 + CSR_2L_PXP_CDR1_INJ_FORCE_OFF); 290 + 291 + airoha_phy_pma1_set_bits(pcie_phy, 292 + REG_PCIE_PMA_FORCE_DA_PXP_CDR_PR_LPF_C, 293 + PCIE_FORCE_SEL_DA_PXP_CDR_PR_LPF_R_EN); 294 + airoha_phy_pma1_set_bits(pcie_phy, 295 + REG_PCIE_PMA_FORCE_DA_PXP_CDR_PR_LPF_C, 296 + PCIE_FORCE_DA_PXP_CDR_PR_LPF_R_EN); 297 + airoha_phy_pma1_set_bits(pcie_phy, 298 + REG_PCIE_PMA_FORCE_DA_PXP_CDR_PR_LPF_C, 299 + PCIE_FORCE_SEL_DA_PXP_CDR_PR_LPF_C_EN); 300 + airoha_phy_pma1_clear_bits(pcie_phy, 301 + REG_PCIE_PMA_FORCE_DA_PXP_CDR_PR_LPF_C, 302 + PCIE_FORCE_DA_PXP_CDR_PR_LPF_C_EN); 303 + airoha_phy_pma1_set_bits(pcie_phy, 304 + REG_PCIE_PMA_FORCE_DA_PXP_CDR_PR_IDAC, 305 + PCIE_FORCE_SEL_DA_PXP_CDR_PR_IDAC); 306 + airoha_phy_pma1_set_bits(pcie_phy, 307 + REG_PCIE_PMA_FORCE_DA_PXP_CDR_PR_PIEYE_PWDB, 308 + PCIE_FORCE_SEL_DA_PXP_CDR_PR_PWDB); 309 + airoha_phy_pma1_clear_bits(pcie_phy, 310 + REG_PCIE_PMA_FORCE_DA_PXP_CDR_PR_PIEYE_PWDB, 311 + PCIE_FORCE_DA_PXP_CDR_PR_PWDB); 312 + airoha_phy_pma1_set_bits(pcie_phy, 313 + REG_PCIE_PMA_FORCE_DA_PXP_CDR_PR_PIEYE_PWDB, 314 + PCIE_FORCE_DA_PXP_CDR_PR_PWDB); 315 + 316 + for (i = 0; i < LEQ_LEN_CTRL_MAX_VAL; i++) { 317 + airoha_phy_pma1_update_field(pcie_phy, 318 + REG_PCIE_PMA_FORCE_DA_PXP_CDR_PR_IDAC, 319 + PCIE_FORCE_DA_PXP_CDR_PR_IDAC, i << 8); 320 + airoha_phy_pma1_clear_bits(pcie_phy, 321 + REG_PCIE_PMA_SS_RX_FREQ_DET4, 322 + PCIE_FREQLOCK_DET_EN); 323 + airoha_phy_pma1_update_field(pcie_phy, 324 + REG_PCIE_PMA_SS_RX_FREQ_DET4, 325 + PCIE_FREQLOCK_DET_EN, 0x3); 326 + 327 + usleep_range(10000, 15000); 328 + 329 + val = FIELD_GET(PCIE_RO_FL_OUT, 330 + readl(pcie_phy->pma1 + 331 + REG_PCIE_PMA_RO_RX_FREQDET)); 332 + if (val > fl_out_target) 333 + cdr_pr_idac_tmp = i << 8; 334 + } 335 + 336 + for (i = LEQ_LEN_CTRL_MAX_VAL; i >= 0; i--) { 337 + pr_idac = cdr_pr_idac_tmp | (0x1 << i); 338 + airoha_phy_pma1_update_field(pcie_phy, 339 + REG_PCIE_PMA_FORCE_DA_PXP_CDR_PR_IDAC, 340 + PCIE_FORCE_DA_PXP_CDR_PR_IDAC, pr_idac); 341 + airoha_phy_pma1_clear_bits(pcie_phy, 342 + REG_PCIE_PMA_SS_RX_FREQ_DET4, 343 + PCIE_FREQLOCK_DET_EN); 344 + airoha_phy_pma1_update_field(pcie_phy, 345 + REG_PCIE_PMA_SS_RX_FREQ_DET4, 346 + PCIE_FREQLOCK_DET_EN, 0x3); 347 + 348 + usleep_range(10000, 15000); 349 + 350 + val = FIELD_GET(PCIE_RO_FL_OUT, 351 + readl(pcie_phy->pma1 + 352 + REG_PCIE_PMA_RO_RX_FREQDET)); 353 + if (val < fl_out_target) 354 + pr_idac &= ~(0x1 << i); 355 + 356 + cdr_pr_idac_tmp = pr_idac; 357 + } 358 + 359 + airoha_phy_pma1_update_field(pcie_phy, 360 + REG_PCIE_PMA_FORCE_DA_PXP_CDR_PR_IDAC, 361 + PCIE_FORCE_DA_PXP_CDR_PR_IDAC, 362 + cdr_pr_idac_tmp); 363 + 364 + for (i = 0; i < FREQ_LOCK_MAX_ATTEMPT; i++) { 365 + u32 val; 366 + 367 + airoha_phy_pma1_clear_bits(pcie_phy, 368 + REG_PCIE_PMA_SS_RX_FREQ_DET4, 369 + PCIE_FREQLOCK_DET_EN); 370 + airoha_phy_pma1_update_field(pcie_phy, 371 + REG_PCIE_PMA_SS_RX_FREQ_DET4, 372 + PCIE_FREQLOCK_DET_EN, 0x3); 373 + 374 + usleep_range(10000, 15000); 375 + 376 + val = readl(pcie_phy->pma1 + REG_PCIE_PMA_RO_RX_FREQDET); 377 + if (val & PCIE_RO_FBCK_LOCK) 378 + break; 379 + } 380 + 381 + /* turn off force mode and update band values */ 382 + airoha_phy_csr_2l_clear_bits(pcie_phy, REG_CSR_2L_CDR1_PR_INJ_MODE, 383 + CSR_2L_PXP_CDR1_INJ_FORCE_OFF); 384 + 385 + airoha_phy_pma1_clear_bits(pcie_phy, 386 + REG_PCIE_PMA_FORCE_DA_PXP_CDR_PR_LPF_C, 387 + PCIE_FORCE_SEL_DA_PXP_CDR_PR_LPF_R_EN); 388 + airoha_phy_pma1_clear_bits(pcie_phy, 389 + REG_PCIE_PMA_FORCE_DA_PXP_CDR_PR_LPF_C, 390 + PCIE_FORCE_SEL_DA_PXP_CDR_PR_LPF_C_EN); 391 + airoha_phy_pma1_clear_bits(pcie_phy, 392 + REG_PCIE_PMA_FORCE_DA_PXP_CDR_PR_PIEYE_PWDB, 393 + PCIE_FORCE_SEL_DA_PXP_CDR_PR_PWDB); 394 + airoha_phy_pma1_clear_bits(pcie_phy, 395 + REG_PCIE_PMA_FORCE_DA_PXP_CDR_PR_IDAC, 396 + PCIE_FORCE_SEL_DA_PXP_CDR_PR_IDAC); 397 + if (gen == PCIE_PORT_GEN3) { 398 + airoha_phy_pma1_update_field(pcie_phy, 399 + REG_PCIE_PMA_DIG_RESERVE_14, 400 + PCIE_FLL_IDAC_PCIEG3, 401 + cdr_pr_idac_tmp); 402 + } else { 403 + airoha_phy_pma1_update_field(pcie_phy, 404 + REG_PCIE_PMA_DIG_RESERVE_13, 405 + PCIE_FLL_IDAC_PCIEG1, 406 + cdr_pr_idac_tmp); 407 + airoha_phy_pma1_update_field(pcie_phy, 408 + REG_PCIE_PMA_DIG_RESERVE_13, 409 + PCIE_FLL_IDAC_PCIEG2, 410 + cdr_pr_idac_tmp); 411 + } 412 + } 413 + 414 + static void airoha_pcie_phy_init_default(struct airoha_pcie_phy *pcie_phy) 415 + { 416 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_CMN, 417 + CSR_2L_PXP_CMN_TRIM_MASK, 0x10); 418 + writel(0xcccbcccb, pcie_phy->pma0 + REG_PCIE_PMA_DIG_RESERVE_21); 419 + writel(0xcccb, pcie_phy->pma0 + REG_PCIE_PMA_DIG_RESERVE_22); 420 + writel(0xcccbcccb, pcie_phy->pma1 + REG_PCIE_PMA_DIG_RESERVE_21); 421 + writel(0xcccb, pcie_phy->pma1 + REG_PCIE_PMA_DIG_RESERVE_22); 422 + airoha_phy_csr_2l_set_bits(pcie_phy, REG_CSR_2L_CMN, 423 + CSR_2L_PXP_CMN_LANE_EN); 424 + } 425 + 426 + static void airoha_pcie_phy_init_clk_out(struct airoha_pcie_phy *pcie_phy) 427 + { 428 + airoha_phy_csr_2l_update_field(pcie_phy, 429 + REG_CSR_2L_TXPLL_POSTDIV_D256, 430 + CSR_2L_PXP_CLKTX0_AMP, 0x5); 431 + airoha_phy_csr_2l_update_field(pcie_phy, 432 + REG_CSR_2L_CLKTX0_FORCE_OUT1, 433 + CSR_2L_PXP_CLKTX1_AMP, 0x5); 434 + airoha_phy_csr_2l_update_field(pcie_phy, 435 + REG_CSR_2L_TXPLL_POSTDIV_D256, 436 + CSR_2L_PXP_CLKTX0_OFFSET, 0x2); 437 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_CLKTX1_OFFSET, 438 + CSR_2L_PXP_CLKTX1_OFFSET, 0x2); 439 + airoha_phy_csr_2l_clear_bits(pcie_phy, REG_CSR_2L_CLKTX0_FORCE_OUT1, 440 + CSR_2L_PXP_CLKTX0_HZ); 441 + airoha_phy_csr_2l_clear_bits(pcie_phy, REG_CSR_2L_CLKTX1_OFFSET, 442 + CSR_2L_PXP_CLKTX1_HZ); 443 + airoha_phy_csr_2l_update_field(pcie_phy, 444 + REG_CSR_2L_CLKTX0_FORCE_OUT1, 445 + CSR_2L_PXP_CLKTX0_IMP_SEL, 0x12); 446 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_CLKTX1_IMP_SEL, 447 + CSR_2L_PXP_CLKTX1_IMP_SEL, 0x12); 448 + airoha_phy_csr_2l_clear_bits(pcie_phy, REG_CSR_2L_TXPLL_POSTDIV_D256, 449 + CSR_2L_PXP_CLKTX0_SR); 450 + airoha_phy_csr_2l_clear_bits(pcie_phy, REG_CSR_2L_CLKTX1_OFFSET, 451 + CSR_2L_PXP_CLKTX1_SR); 452 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_PLL_CMN_RESERVE0, 453 + CSR_2L_PXP_PLL_RESERVE_MASK, 0xdd); 454 + } 455 + 456 + static void airoha_pcie_phy_init_csr_2l(struct airoha_pcie_phy *pcie_phy) 457 + { 458 + airoha_phy_pma0_set_bits(pcie_phy, REG_PCIE_PMA_SW_RESET, 459 + PCIE_SW_XFI_RXPCS_RST | PCIE_SW_REF_RST | 460 + PCIE_SW_RX_RST); 461 + airoha_phy_pma1_set_bits(pcie_phy, REG_PCIE_PMA_SW_RESET, 462 + PCIE_SW_XFI_RXPCS_RST | PCIE_SW_REF_RST | 463 + PCIE_SW_RX_RST); 464 + airoha_phy_pma0_set_bits(pcie_phy, REG_PCIE_PMA_TX_RESET, 465 + PCIE_TX_TOP_RST | REG_PCIE_PMA_TX_RESET); 466 + airoha_phy_pma1_set_bits(pcie_phy, REG_PCIE_PMA_TX_RESET, 467 + PCIE_TX_TOP_RST | REG_PCIE_PMA_TX_RESET); 468 + } 469 + 470 + static void airoha_pcie_phy_init_rx(struct airoha_pcie_phy *pcie_phy) 471 + { 472 + writel(0x2a00090b, pcie_phy->pma0 + REG_PCIE_PMA_DIG_RESERVE_17); 473 + writel(0x2a00090b, pcie_phy->pma1 + REG_PCIE_PMA_DIG_RESERVE_17); 474 + airoha_phy_csr_2l_set_bits(pcie_phy, REG_CSR_2L_CDR0_PR_MONPI, 475 + CSR_2L_PXP_CDR0_PR_XFICK_EN); 476 + airoha_phy_csr_2l_set_bits(pcie_phy, REG_CSR_2L_CDR1_PR_MONPI, 477 + CSR_2L_PXP_CDR1_PR_XFICK_EN); 478 + airoha_phy_csr_2l_clear_bits(pcie_phy, 479 + REG_CSR_2L_CDR0_PD_PICAL_CKD8_INV, 480 + CSR_2L_PXP_CDR0_PD_EDGE_DISABLE); 481 + airoha_phy_csr_2l_clear_bits(pcie_phy, 482 + REG_CSR_2L_CDR1_PD_PICAL_CKD8_INV, 483 + CSR_2L_PXP_CDR1_PD_EDGE_DISABLE); 484 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_RX0_PHYCK_DIV, 485 + CSR_2L_PXP_RX0_PHYCK_SEL, 0x1); 486 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_RX1_PHYCK_DIV, 487 + CSR_2L_PXP_RX1_PHYCK_SEL, 0x1); 488 + } 489 + 490 + static void airoha_pcie_phy_init_jcpll(struct airoha_pcie_phy *pcie_phy) 491 + { 492 + airoha_phy_pma0_set_bits(pcie_phy, REG_PCIE_PMA_FORCE_PXP_JCPLL_CKOUT, 493 + PCIE_FORCE_SEL_DA_PXP_JCPLL_EN); 494 + airoha_phy_pma0_clear_bits(pcie_phy, 495 + REG_PCIE_PMA_FORCE_PXP_JCPLL_CKOUT, 496 + PCIE_FORCE_DA_PXP_JCPLL_EN); 497 + airoha_phy_pma1_set_bits(pcie_phy, REG_PCIE_PMA_FORCE_PXP_JCPLL_CKOUT, 498 + PCIE_FORCE_SEL_DA_PXP_JCPLL_EN); 499 + airoha_phy_pma1_clear_bits(pcie_phy, 500 + REG_PCIE_PMA_FORCE_PXP_JCPLL_CKOUT, 501 + PCIE_FORCE_DA_PXP_JCPLL_EN); 502 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_JCPLL_TCL_VTP_EN, 503 + CSR_2L_PXP_JCPLL_SPARE_LOW, 0x20); 504 + airoha_phy_csr_2l_set_bits(pcie_phy, REG_CSR_2L_JCPLL_RST_DLY, 505 + CSR_2L_PXP_JCPLL_RST); 506 + writel(0x0, pcie_phy->csr_2l + REG_CSR_2L_JCPLL_SSC_DELTA1); 507 + airoha_phy_csr_2l_clear_bits(pcie_phy, REG_CSR_2L_JCPLL_SSC_PERIOD, 508 + CSR_2L_PXP_JCPLL_SSC_PERIOD); 509 + airoha_phy_csr_2l_clear_bits(pcie_phy, REG_CSR_2L_JCPLL_SSC, 510 + CSR_2L_PXP_JCPLL_SSC_PHASE_INI); 511 + airoha_phy_csr_2l_clear_bits(pcie_phy, REG_CSR_2L_JCPLL_SSC, 512 + CSR_2L_PXP_JCPLL_SSC_TRI_EN); 513 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_JCPLL_LPF_BR, 514 + CSR_2L_PXP_JCPLL_LPF_BR, 0xa); 515 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_JCPLL_LPF_BR, 516 + CSR_2L_PXP_JCPLL_LPF_BP, 0xc); 517 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_JCPLL_LPF_BR, 518 + CSR_2L_PXP_JCPLL_LPF_BC, 0x1f); 519 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_JCPLL_LPF_BWC, 520 + CSR_2L_PXP_JCPLL_LPF_BWC, 0x1e); 521 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_JCPLL_LPF_BR, 522 + CSR_2L_PXP_JCPLL_LPF_BWR, 0xa); 523 + airoha_phy_csr_2l_update_field(pcie_phy, 524 + REG_CSR_2L_JCPLL_MMD_PREDIV_MODE, 525 + CSR_2L_PXP_JCPLL_MMD_PREDIV_MODE, 526 + 0x1); 527 + airoha_phy_csr_2l_clear_bits(pcie_phy, CSR_2L_PXP_JCPLL_MONCK, 528 + CSR_2L_PXP_JCPLL_REFIN_DIV); 529 + 530 + airoha_phy_pma0_set_bits(pcie_phy, REG_PCIE_PMA_FORCE_DA_PXP_RX_FE_VOS, 531 + PCIE_FORCE_SEL_DA_PXP_JCPLL_SDM_PCW); 532 + airoha_phy_pma1_set_bits(pcie_phy, REG_PCIE_PMA_FORCE_DA_PXP_RX_FE_VOS, 533 + PCIE_FORCE_SEL_DA_PXP_JCPLL_SDM_PCW); 534 + airoha_phy_pma0_update_field(pcie_phy, 535 + REG_PCIE_PMA_FORCE_DA_PXP_JCPLL_SDM_PCW, 536 + PCIE_FORCE_DA_PXP_JCPLL_SDM_PCW, 537 + 0x50000000); 538 + airoha_phy_pma1_update_field(pcie_phy, 539 + REG_PCIE_PMA_FORCE_DA_PXP_JCPLL_SDM_PCW, 540 + PCIE_FORCE_DA_PXP_JCPLL_SDM_PCW, 541 + 0x50000000); 542 + 543 + airoha_phy_csr_2l_set_bits(pcie_phy, 544 + REG_CSR_2L_JCPLL_MMD_PREDIV_MODE, 545 + CSR_2L_PXP_JCPLL_POSTDIV_D5); 546 + airoha_phy_csr_2l_set_bits(pcie_phy, 547 + REG_CSR_2L_JCPLL_MMD_PREDIV_MODE, 548 + CSR_2L_PXP_JCPLL_POSTDIV_D2); 549 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_JCPLL_RST_DLY, 550 + CSR_2L_PXP_JCPLL_RST_DLY, 0x4); 551 + airoha_phy_csr_2l_clear_bits(pcie_phy, REG_CSR_2L_JCPLL_RST_DLY, 552 + CSR_2L_PXP_JCPLL_SDM_DI_LS); 553 + airoha_phy_csr_2l_clear_bits(pcie_phy, REG_CSR_2L_JCPLL_TCL_KBAND_VREF, 554 + CSR_2L_PXP_JCPLL_VCO_KBAND_MEAS_EN); 555 + airoha_phy_csr_2l_clear_bits(pcie_phy, REG_CSR_2L_JCPLL_IB_EXT, 556 + CSR_2L_PXP_JCPLL_CHP_IOFST); 557 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_JCPLL_IB_EXT, 558 + CSR_2L_PXP_JCPLL_CHP_IBIAS, 0xc); 559 + airoha_phy_csr_2l_update_field(pcie_phy, 560 + REG_CSR_2L_JCPLL_MMD_PREDIV_MODE, 561 + CSR_2L_PXP_JCPLL_MMD_PREDIV_MODE, 562 + 0x1); 563 + airoha_phy_csr_2l_set_bits(pcie_phy, REG_CSR_2L_JCPLL_VCODIV, 564 + CSR_2L_PXP_JCPLL_VCO_HALFLSB_EN); 565 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_JCPLL_VCODIV, 566 + CSR_2L_PXP_JCPLL_VCO_CFIX, 0x1); 567 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_JCPLL_VCODIV, 568 + CSR_2L_PXP_JCPLL_VCO_SCAPWR, 0x4); 569 + airoha_phy_csr_2l_clear_bits(pcie_phy, REG_CSR_2L_JCPLL_IB_EXT, 570 + REG_CSR_2L_JCPLL_LPF_SHCK_EN); 571 + airoha_phy_csr_2l_set_bits(pcie_phy, REG_CSR_2L_JCPLL_KBAND_KFC, 572 + CSR_2L_PXP_JCPLL_POSTDIV_EN); 573 + airoha_phy_csr_2l_clear_bits(pcie_phy, REG_CSR_2L_JCPLL_KBAND_KFC, 574 + CSR_2L_PXP_JCPLL_KBAND_KFC); 575 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_JCPLL_KBAND_KFC, 576 + CSR_2L_PXP_JCPLL_KBAND_KF, 0x3); 577 + airoha_phy_csr_2l_clear_bits(pcie_phy, REG_CSR_2L_JCPLL_KBAND_KFC, 578 + CSR_2L_PXP_JCPLL_KBAND_KS); 579 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_JCPLL_LPF_BWC, 580 + CSR_2L_PXP_JCPLL_KBAND_DIV, 0x1); 581 + 582 + airoha_phy_pma0_set_bits(pcie_phy, REG_PCIE_PMA_SCAN_MODE, 583 + PCIE_FORCE_SEL_DA_PXP_JCPLL_KBAND_LOAD_EN); 584 + airoha_phy_pma0_clear_bits(pcie_phy, REG_PCIE_PMA_SCAN_MODE, 585 + PCIE_FORCE_DA_PXP_JCPLL_KBAND_LOAD_EN); 586 + 587 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_JCPLL_LPF_BWC, 588 + CSR_2L_PXP_JCPLL_KBAND_CODE, 0xe4); 589 + airoha_phy_csr_2l_set_bits(pcie_phy, REG_CSR_2L_JCPLL_SDM_HREN, 590 + CSR_2L_PXP_JCPLL_TCL_AMP_EN); 591 + airoha_phy_csr_2l_set_bits(pcie_phy, REG_CSR_2L_JCPLL_TCL_CMP, 592 + CSR_2L_PXP_JCPLL_TCL_LPF_EN); 593 + airoha_phy_csr_2l_update_field(pcie_phy, 594 + REG_CSR_2L_JCPLL_TCL_KBAND_VREF, 595 + CSR_2L_PXP_JCPLL_TCL_KBAND_VREF, 0xf); 596 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_JCPLL_SDM_HREN, 597 + CSR_2L_PXP_JCPLL_TCL_AMP_GAIN, 0x1); 598 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_JCPLL_SDM_HREN, 599 + CSR_2L_PXP_JCPLL_TCL_AMP_VREF, 0x5); 600 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_JCPLL_TCL_CMP, 601 + CSR_2L_PXP_JCPLL_TCL_LPF_BW, 0x1); 602 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_JCPLL_VCO_TCLVAR, 603 + CSR_2L_PXP_JCPLL_VCO_TCLVAR, 0x3); 604 + 605 + airoha_phy_pma0_set_bits(pcie_phy, REG_PCIE_PMA_FORCE_PXP_JCPLL_CKOUT, 606 + PCIE_FORCE_SEL_DA_PXP_JCPLL_CKOUT_EN); 607 + airoha_phy_pma0_set_bits(pcie_phy, REG_PCIE_PMA_FORCE_PXP_JCPLL_CKOUT, 608 + PCIE_FORCE_DA_PXP_JCPLL_CKOUT_EN); 609 + airoha_phy_pma1_set_bits(pcie_phy, REG_PCIE_PMA_FORCE_PXP_JCPLL_CKOUT, 610 + PCIE_FORCE_SEL_DA_PXP_JCPLL_CKOUT_EN); 611 + airoha_phy_pma1_set_bits(pcie_phy, REG_PCIE_PMA_FORCE_PXP_JCPLL_CKOUT, 612 + PCIE_FORCE_DA_PXP_JCPLL_CKOUT_EN); 613 + airoha_phy_pma0_set_bits(pcie_phy, REG_PCIE_PMA_FORCE_PXP_JCPLL_CKOUT, 614 + PCIE_FORCE_SEL_DA_PXP_JCPLL_EN); 615 + airoha_phy_pma0_set_bits(pcie_phy, REG_PCIE_PMA_FORCE_PXP_JCPLL_CKOUT, 616 + PCIE_FORCE_DA_PXP_JCPLL_EN); 617 + airoha_phy_pma1_set_bits(pcie_phy, REG_PCIE_PMA_FORCE_PXP_JCPLL_CKOUT, 618 + PCIE_FORCE_SEL_DA_PXP_JCPLL_EN); 619 + airoha_phy_pma1_set_bits(pcie_phy, REG_PCIE_PMA_FORCE_PXP_JCPLL_CKOUT, 620 + PCIE_FORCE_DA_PXP_JCPLL_EN); 621 + } 622 + 623 + static void airoha_pcie_phy_txpll(struct airoha_pcie_phy *pcie_phy) 624 + { 625 + airoha_phy_pma0_set_bits(pcie_phy, 626 + REG_PCIE_PMA_FORCE_DA_PXP_TXPLL_CKOUT, 627 + PCIE_FORCE_SEL_DA_PXP_TXPLL_EN); 628 + airoha_phy_pma0_clear_bits(pcie_phy, 629 + REG_PCIE_PMA_FORCE_DA_PXP_TXPLL_CKOUT, 630 + PCIE_FORCE_DA_PXP_TXPLL_EN); 631 + airoha_phy_pma1_set_bits(pcie_phy, 632 + REG_PCIE_PMA_FORCE_DA_PXP_TXPLL_CKOUT, 633 + PCIE_FORCE_SEL_DA_PXP_TXPLL_EN); 634 + airoha_phy_pma1_clear_bits(pcie_phy, 635 + REG_PCIE_PMA_FORCE_DA_PXP_TXPLL_CKOUT, 636 + PCIE_FORCE_DA_PXP_TXPLL_EN); 637 + 638 + airoha_phy_csr_2l_set_bits(pcie_phy, REG_CSR_2L_TXPLL_REFIN_DIV, 639 + CSR_2L_PXP_TXPLL_PLL_RSTB); 640 + writel(0x0, pcie_phy->csr_2l + REG_CSR_2L_TXPLL_SSC_DELTA1); 641 + airoha_phy_csr_2l_clear_bits(pcie_phy, REG_CSR_2L_TXPLL_SSC_PERIOD, 642 + CSR_2L_PXP_txpll_SSC_PERIOD); 643 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_TXPLL_CHP_IOFST, 644 + CSR_2L_PXP_TXPLL_CHP_IOFST, 0x1); 645 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_750M_SYS_CK, 646 + CSR_2L_PXP_TXPLL_CHP_IBIAS, 0x2d); 647 + airoha_phy_csr_2l_clear_bits(pcie_phy, REG_CSR_2L_TXPLL_REFIN_DIV, 648 + CSR_2L_PXP_TXPLL_REFIN_DIV); 649 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_TXPLL_TCL_LPF_BW, 650 + CSR_2L_PXP_TXPLL_VCO_CFIX, 0x3); 651 + 652 + airoha_phy_pma0_set_bits(pcie_phy, REG_PCIE_PMA_FORCE_DA_PXP_CDR_PR_IDAC, 653 + PCIE_FORCE_SEL_DA_PXP_TXPLL_SDM_PCW); 654 + airoha_phy_pma1_set_bits(pcie_phy, REG_PCIE_PMA_FORCE_DA_PXP_CDR_PR_IDAC, 655 + PCIE_FORCE_SEL_DA_PXP_TXPLL_SDM_PCW); 656 + airoha_phy_pma0_update_field(pcie_phy, 657 + REG_PCIE_PMA_FORCE_DA_PXP_TXPLL_SDM_PCW, 658 + PCIE_FORCE_DA_PXP_TXPLL_SDM_PCW, 659 + 0xc800000); 660 + airoha_phy_pma1_update_field(pcie_phy, 661 + REG_PCIE_PMA_FORCE_DA_PXP_TXPLL_SDM_PCW, 662 + PCIE_FORCE_DA_PXP_TXPLL_SDM_PCW, 663 + 0xc800000); 664 + 665 + airoha_phy_csr_2l_clear_bits(pcie_phy, REG_CSR_2L_TXPLL_SDM_DI_LS, 666 + CSR_2L_PXP_TXPLL_SDM_IFM); 667 + airoha_phy_csr_2l_clear_bits(pcie_phy, REG_CSR_2L_TXPLL_SSC, 668 + CSR_2L_PXP_TXPLL_SSC_PHASE_INI); 669 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_TXPLL_REFIN_DIV, 670 + CSR_2L_PXP_TXPLL_RST_DLY, 0x4); 671 + airoha_phy_csr_2l_clear_bits(pcie_phy, REG_CSR_2L_TXPLL_SDM_DI_LS, 672 + CSR_2L_PXP_TXPLL_SDM_DI_LS); 673 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_TXPLL_SDM_DI_LS, 674 + CSR_2L_PXP_TXPLL_SDM_ORD, 0x3); 675 + airoha_phy_csr_2l_clear_bits(pcie_phy, REG_CSR_2L_TXPLL_TCL_KBAND_VREF, 676 + CSR_2L_PXP_TXPLL_VCO_KBAND_MEAS_EN); 677 + writel(0x0, pcie_phy->csr_2l + REG_CSR_2L_TXPLL_SSC_DELTA1); 678 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_TXPLL_CHP_IOFST, 679 + CSR_2L_PXP_TXPLL_LPF_BP, 0x1); 680 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_TXPLL_CHP_IOFST, 681 + CSR_2L_PXP_TXPLL_LPF_BC, 0x18); 682 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_TXPLL_CHP_IOFST, 683 + CSR_2L_PXP_TXPLL_LPF_BR, 0x5); 684 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_TXPLL_CHP_IOFST, 685 + CSR_2L_PXP_TXPLL_CHP_IOFST, 0x1); 686 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_750M_SYS_CK, 687 + CSR_2L_PXP_TXPLL_CHP_IBIAS, 0x2d); 688 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_TXPLL_TCL_VTP, 689 + CSR_2L_PXP_TXPLL_SPARE_L, 0x1); 690 + airoha_phy_csr_2l_clear_bits(pcie_phy, REG_CSR_2L_TXPLL_LPF_BWR, 691 + CSR_2L_PXP_TXPLL_LPF_BWC); 692 + airoha_phy_csr_2l_clear_bits(pcie_phy, REG_CSR_2L_TXPLL_POSTDIV, 693 + CSR_2L_PXP_TXPLL_MMD_PREDIV_MODE); 694 + airoha_phy_csr_2l_clear_bits(pcie_phy, REG_CSR_2L_TXPLL_REFIN_DIV, 695 + CSR_2L_PXP_TXPLL_REFIN_DIV); 696 + airoha_phy_csr_2l_set_bits(pcie_phy, REG_CSR_2L_TXPLL_TCL_LPF_BW, 697 + CSR_2L_PXP_TXPLL_VCO_HALFLSB_EN); 698 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_TXPLL_VCO_SCAPWR, 699 + CSR_2L_PXP_TXPLL_VCO_SCAPWR, 0x7); 700 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_TXPLL_TCL_LPF_BW, 701 + CSR_2L_PXP_TXPLL_VCO_CFIX, 0x3); 702 + 703 + airoha_phy_pma0_set_bits(pcie_phy, 704 + REG_PCIE_PMA_FORCE_DA_PXP_CDR_PR_IDAC, 705 + PCIE_FORCE_SEL_DA_PXP_TXPLL_SDM_PCW); 706 + airoha_phy_pma1_set_bits(pcie_phy, 707 + REG_PCIE_PMA_FORCE_DA_PXP_CDR_PR_IDAC, 708 + PCIE_FORCE_SEL_DA_PXP_TXPLL_SDM_PCW); 709 + 710 + airoha_phy_csr_2l_clear_bits(pcie_phy, REG_CSR_2L_TXPLL_SSC, 711 + CSR_2L_PXP_TXPLL_SSC_PHASE_INI); 712 + airoha_phy_csr_2l_clear_bits(pcie_phy, REG_CSR_2L_TXPLL_LPF_BWR, 713 + CSR_2L_PXP_TXPLL_LPF_BWR); 714 + airoha_phy_csr_2l_set_bits(pcie_phy, REG_CSR_2L_TXPLL_PHY_CK2, 715 + CSR_2L_PXP_TXPLL_REFIN_INTERNAL); 716 + airoha_phy_csr_2l_clear_bits(pcie_phy, REG_CSR_2L_TXPLL_TCL_KBAND_VREF, 717 + CSR_2L_PXP_TXPLL_VCO_KBAND_MEAS_EN); 718 + airoha_phy_csr_2l_clear_bits(pcie_phy, REG_CSR_2L_TXPLL_VTP, 719 + CSR_2L_PXP_TXPLL_VTP_EN); 720 + airoha_phy_csr_2l_clear_bits(pcie_phy, REG_CSR_2L_TXPLL_POSTDIV, 721 + CSR_2L_PXP_TXPLL_PHY_CK1_EN); 722 + airoha_phy_csr_2l_set_bits(pcie_phy, REG_CSR_2L_TXPLL_PHY_CK2, 723 + CSR_2L_PXP_TXPLL_REFIN_INTERNAL); 724 + airoha_phy_csr_2l_clear_bits(pcie_phy, REG_CSR_2L_TXPLL_SSC, 725 + CSR_2L_PXP_TXPLL_SSC_EN); 726 + airoha_phy_csr_2l_clear_bits(pcie_phy, REG_CSR_2L_750M_SYS_CK, 727 + CSR_2L_PXP_TXPLL_LPF_SHCK_EN); 728 + airoha_phy_csr_2l_clear_bits(pcie_phy, REG_CSR_2L_TXPLL_POSTDIV, 729 + CSR_2L_PXP_TXPLL_POSTDIV_EN); 730 + airoha_phy_csr_2l_clear_bits(pcie_phy, REG_CSR_2L_TXPLL_KBAND_DIV, 731 + CSR_2L_PXP_TXPLL_KBAND_KFC); 732 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_TXPLL_KBAND_DIV, 733 + CSR_2L_PXP_TXPLL_KBAND_KF, 0x3); 734 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_TXPLL_KBAND_DIV, 735 + CSR_2L_PXP_txpll_KBAND_KS, 0x1); 736 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_TXPLL_KBAND_DIV, 737 + CSR_2L_PXP_TXPLL_KBAND_DIV, 0x4); 738 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_TXPLL_LPF_BWR, 739 + CSR_2L_PXP_TXPLL_KBAND_CODE, 0xe4); 740 + airoha_phy_csr_2l_set_bits(pcie_phy, REG_CSR_2L_TXPLL_SDM_OUT, 741 + CSR_2L_PXP_TXPLL_TCL_AMP_EN); 742 + airoha_phy_csr_2l_set_bits(pcie_phy, REG_CSR_2L_TXPLL_TCL_AMP_VREF, 743 + CSR_2L_PXP_TXPLL_TCL_LPF_EN); 744 + airoha_phy_csr_2l_update_field(pcie_phy, 745 + REG_CSR_2L_TXPLL_TCL_KBAND_VREF, 746 + CSR_2L_PXP_TXPLL_TCL_KBAND_VREF, 0xf); 747 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_TXPLL_SDM_OUT, 748 + CSR_2L_PXP_TXPLL_TCL_AMP_GAIN, 0x3); 749 + airoha_phy_csr_2l_update_field(pcie_phy, 750 + REG_CSR_2L_TXPLL_TCL_AMP_VREF, 751 + CSR_2L_PXP_TXPLL_TCL_AMP_VREF, 0xb); 752 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_TXPLL_TCL_LPF_BW, 753 + CSR_2L_PXP_TXPLL_TCL_LPF_BW, 0x3); 754 + 755 + airoha_phy_pma0_set_bits(pcie_phy, 756 + REG_PCIE_PMA_FORCE_DA_PXP_TXPLL_CKOUT, 757 + PCIE_FORCE_SEL_DA_PXP_TXPLL_CKOUT_EN); 758 + airoha_phy_pma0_set_bits(pcie_phy, 759 + REG_PCIE_PMA_FORCE_DA_PXP_TXPLL_CKOUT, 760 + PCIE_FORCE_DA_PXP_TXPLL_CKOUT_EN); 761 + airoha_phy_pma1_set_bits(pcie_phy, 762 + REG_PCIE_PMA_FORCE_DA_PXP_TXPLL_CKOUT, 763 + PCIE_FORCE_SEL_DA_PXP_TXPLL_CKOUT_EN); 764 + airoha_phy_pma1_set_bits(pcie_phy, 765 + REG_PCIE_PMA_FORCE_DA_PXP_TXPLL_CKOUT, 766 + PCIE_FORCE_DA_PXP_TXPLL_CKOUT_EN); 767 + airoha_phy_pma0_set_bits(pcie_phy, 768 + REG_PCIE_PMA_FORCE_DA_PXP_TXPLL_CKOUT, 769 + PCIE_FORCE_SEL_DA_PXP_TXPLL_EN); 770 + airoha_phy_pma0_set_bits(pcie_phy, 771 + REG_PCIE_PMA_FORCE_DA_PXP_TXPLL_CKOUT, 772 + PCIE_FORCE_DA_PXP_TXPLL_EN); 773 + airoha_phy_pma1_set_bits(pcie_phy, 774 + REG_PCIE_PMA_FORCE_DA_PXP_TXPLL_CKOUT, 775 + PCIE_FORCE_SEL_DA_PXP_TXPLL_EN); 776 + airoha_phy_pma1_set_bits(pcie_phy, 777 + REG_PCIE_PMA_FORCE_DA_PXP_TXPLL_CKOUT, 778 + PCIE_FORCE_DA_PXP_TXPLL_EN); 779 + } 780 + 781 + static void airoha_pcie_phy_init_ssc_jcpll(struct airoha_pcie_phy *pcie_phy) 782 + { 783 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_JCPLL_SSC_DELTA1, 784 + CSR_2L_PXP_JCPLL_SSC_DELTA1, 0x106); 785 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_JCPLL_SSC_DELTA1, 786 + CSR_2L_PXP_JCPLL_SSC_DELTA, 0x106); 787 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_JCPLL_SSC_PERIOD, 788 + CSR_2L_PXP_JCPLL_SSC_PERIOD, 0x31b); 789 + airoha_phy_csr_2l_set_bits(pcie_phy, REG_CSR_2L_JCPLL_SSC, 790 + CSR_2L_PXP_JCPLL_SSC_PHASE_INI); 791 + airoha_phy_csr_2l_set_bits(pcie_phy, REG_CSR_2L_JCPLL_SSC, 792 + CSR_2L_PXP_JCPLL_SSC_EN); 793 + airoha_phy_csr_2l_set_bits(pcie_phy, REG_CSR_2L_JCPLL_SDM_IFM, 794 + CSR_2L_PXP_JCPLL_SDM_IFM); 795 + airoha_phy_csr_2l_set_bits(pcie_phy, REG_CSR_2L_JCPLL_SDM_HREN, 796 + REG_CSR_2L_JCPLL_SDM_HREN); 797 + airoha_phy_csr_2l_clear_bits(pcie_phy, REG_CSR_2L_JCPLL_RST_DLY, 798 + CSR_2L_PXP_JCPLL_SDM_DI_EN); 799 + airoha_phy_csr_2l_set_bits(pcie_phy, REG_CSR_2L_JCPLL_SSC, 800 + CSR_2L_PXP_JCPLL_SSC_TRI_EN); 801 + } 802 + 803 + static void 804 + airoha_pcie_phy_set_rxlan0_signal_detect(struct airoha_pcie_phy *pcie_phy) 805 + { 806 + airoha_phy_csr_2l_set_bits(pcie_phy, REG_CSR_2L_CDR0_PR_COR_HBW, 807 + CSR_2L_PXP_CDR0_PR_LDO_FORCE_ON); 808 + 809 + usleep_range(100, 200); 810 + 811 + airoha_phy_pma0_update_field(pcie_phy, REG_PCIE_PMA_DIG_RESERVE_19, 812 + PCIE_PCP_RX_REV0_PCIE_GEN1, 0x18b0); 813 + airoha_phy_pma0_update_field(pcie_phy, REG_PCIE_PMA_DIG_RESERVE_20, 814 + PCIE_PCP_RX_REV0_PCIE_GEN2, 0x18b0); 815 + airoha_phy_pma0_update_field(pcie_phy, REG_PCIE_PMA_DIG_RESERVE_20, 816 + PCIE_PCP_RX_REV0_PCIE_GEN3, 0x1030); 817 + 818 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_RX0_SIGDET_DCTEST, 819 + CSR_2L_PXP_RX0_SIGDET_PEAK, 0x2); 820 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_RX0_SIGDET_VTH_SEL, 821 + CSR_2L_PXP_RX0_SIGDET_VTH_SEL, 0x5); 822 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_RX0_REV0, 823 + CSR_2L_PXP_VOS_PNINV, 0x2); 824 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_RX0_SIGDET_DCTEST, 825 + CSR_2L_PXP_RX0_SIGDET_LPF_CTRL, 0x1); 826 + 827 + airoha_phy_pma0_update_field(pcie_phy, REG_PCIE_PMA_SS_RX_CAL2, 828 + PCIE_CAL_OUT_OS, 0x0); 829 + 830 + airoha_phy_csr_2l_set_bits(pcie_phy, REG_CSR_2L_PXP_RX0_FE_VB_EQ2, 831 + CSR_2L_PXP_RX0_FE_VCM_GEN_PWDB); 832 + 833 + airoha_phy_pma0_set_bits(pcie_phy, 834 + REG_PCIE_PMA_FORCE_DA_PXP_RX_FE_GAIN_CTRL, 835 + PCIE_FORCE_SEL_DA_PXP_RX_FE_PWDB); 836 + airoha_phy_pma0_update_field(pcie_phy, 837 + REG_PCIE_PMA_FORCE_DA_PXP_RX_FE_GAIN_CTRL, 838 + PCIE_FORCE_DA_PXP_RX_FE_GAIN_CTRL, 0x3); 839 + airoha_phy_pma0_update_field(pcie_phy, REG_PCIE_PMA_RX_FORCE_MODE0, 840 + PCIE_FORCE_DA_XPON_RX_FE_GAIN_CTRL, 0x1); 841 + airoha_phy_pma0_update_field(pcie_phy, REG_PCIE_PMA_SS_RX_SIGDET0, 842 + PCIE_SIGDET_WIN_NONVLD_TIMES, 0x3); 843 + airoha_phy_pma0_clear_bits(pcie_phy, REG_PCIE_PMA_SEQUENCE_DISB_CTRL1, 844 + PCIE_DISB_RX_SDCAL_EN); 845 + 846 + airoha_phy_pma0_set_bits(pcie_phy, 847 + REG_PCIE_PMA_CTRL_SEQUENCE_FORCE_CTRL1, 848 + PCIE_FORCE_RX_SDCAL_EN); 849 + usleep_range(150, 200); 850 + airoha_phy_pma0_clear_bits(pcie_phy, 851 + REG_PCIE_PMA_CTRL_SEQUENCE_FORCE_CTRL1, 852 + PCIE_FORCE_RX_SDCAL_EN); 853 + } 854 + 855 + static void 856 + airoha_pcie_phy_set_rxlan1_signal_detect(struct airoha_pcie_phy *pcie_phy) 857 + { 858 + airoha_phy_csr_2l_set_bits(pcie_phy, REG_CSR_2L_CDR1_PR_COR_HBW, 859 + CSR_2L_PXP_CDR1_PR_LDO_FORCE_ON); 860 + 861 + usleep_range(100, 200); 862 + 863 + airoha_phy_pma1_update_field(pcie_phy, REG_PCIE_PMA_DIG_RESERVE_19, 864 + PCIE_PCP_RX_REV0_PCIE_GEN1, 0x18b0); 865 + airoha_phy_pma1_update_field(pcie_phy, REG_PCIE_PMA_DIG_RESERVE_20, 866 + PCIE_PCP_RX_REV0_PCIE_GEN2, 0x18b0); 867 + airoha_phy_pma1_update_field(pcie_phy, REG_PCIE_PMA_DIG_RESERVE_20, 868 + PCIE_PCP_RX_REV0_PCIE_GEN3, 0x1030); 869 + 870 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_RX1_SIGDET_NOVTH, 871 + CSR_2L_PXP_RX1_SIGDET_PEAK, 0x2); 872 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_RX1_SIGDET_NOVTH, 873 + CSR_2L_PXP_RX1_SIGDET_VTH_SEL, 0x5); 874 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_RX1_REV0, 875 + CSR_2L_PXP_VOS_PNINV, 0x2); 876 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_RX1_DAC_RANGE_EYE, 877 + CSR_2L_PXP_RX1_SIGDET_LPF_CTRL, 0x1); 878 + 879 + airoha_phy_pma1_update_field(pcie_phy, REG_PCIE_PMA_SS_RX_CAL2, 880 + PCIE_CAL_OUT_OS, 0x0); 881 + 882 + airoha_phy_csr_2l_set_bits(pcie_phy, REG_CSR_2L_RX1_FE_VB_EQ1, 883 + CSR_2L_PXP_RX1_FE_VCM_GEN_PWDB); 884 + 885 + airoha_phy_pma1_set_bits(pcie_phy, 886 + REG_PCIE_PMA_FORCE_DA_PXP_RX_FE_GAIN_CTRL, 887 + PCIE_FORCE_SEL_DA_PXP_RX_FE_PWDB); 888 + airoha_phy_pma1_update_field(pcie_phy, 889 + REG_PCIE_PMA_FORCE_DA_PXP_RX_FE_GAIN_CTRL, 890 + PCIE_FORCE_DA_PXP_RX_FE_GAIN_CTRL, 0x3); 891 + airoha_phy_pma1_update_field(pcie_phy, REG_PCIE_PMA_RX_FORCE_MODE0, 892 + PCIE_FORCE_DA_XPON_RX_FE_GAIN_CTRL, 0x1); 893 + airoha_phy_pma1_update_field(pcie_phy, REG_PCIE_PMA_SS_RX_SIGDET0, 894 + PCIE_SIGDET_WIN_NONVLD_TIMES, 0x3); 895 + airoha_phy_pma1_clear_bits(pcie_phy, REG_PCIE_PMA_SEQUENCE_DISB_CTRL1, 896 + PCIE_DISB_RX_SDCAL_EN); 897 + 898 + airoha_phy_pma1_set_bits(pcie_phy, 899 + REG_PCIE_PMA_CTRL_SEQUENCE_FORCE_CTRL1, 900 + PCIE_FORCE_RX_SDCAL_EN); 901 + usleep_range(150, 200); 902 + airoha_phy_pma1_clear_bits(pcie_phy, 903 + REG_PCIE_PMA_CTRL_SEQUENCE_FORCE_CTRL1, 904 + PCIE_FORCE_RX_SDCAL_EN); 905 + } 906 + 907 + static void airoha_pcie_phy_set_rxflow(struct airoha_pcie_phy *pcie_phy) 908 + { 909 + airoha_phy_pma0_set_bits(pcie_phy, 910 + REG_PCIE_PMA_FORCE_DA_PXP_RX_SCAN_RST, 911 + PCIE_FORCE_DA_PXP_RX_SIGDET_PWDB | 912 + PCIE_FORCE_SEL_DA_PXP_RX_SIGDET_PWDB); 913 + airoha_phy_pma1_set_bits(pcie_phy, 914 + REG_PCIE_PMA_FORCE_DA_PXP_RX_SCAN_RST, 915 + PCIE_FORCE_DA_PXP_RX_SIGDET_PWDB | 916 + PCIE_FORCE_SEL_DA_PXP_RX_SIGDET_PWDB); 917 + 918 + airoha_phy_pma0_set_bits(pcie_phy, 919 + REG_PCIE_PMA_FORCE_DA_PXP_CDR_PD_PWDB, 920 + PCIE_FORCE_DA_PXP_CDR_PD_PWDB | 921 + PCIE_FORCE_SEL_DA_PXP_CDR_PD_PWDB); 922 + airoha_phy_pma0_set_bits(pcie_phy, 923 + REG_PCIE_PMA_FORCE_DA_PXP_RX_FE_PWDB, 924 + PCIE_FORCE_DA_PXP_RX_FE_PWDB | 925 + PCIE_FORCE_SEL_DA_PXP_RX_FE_PWDB); 926 + airoha_phy_pma1_set_bits(pcie_phy, 927 + REG_PCIE_PMA_FORCE_DA_PXP_CDR_PD_PWDB, 928 + PCIE_FORCE_DA_PXP_CDR_PD_PWDB | 929 + PCIE_FORCE_SEL_DA_PXP_CDR_PD_PWDB); 930 + airoha_phy_pma1_set_bits(pcie_phy, 931 + REG_PCIE_PMA_FORCE_DA_PXP_RX_FE_PWDB, 932 + PCIE_FORCE_DA_PXP_RX_FE_PWDB | 933 + PCIE_FORCE_SEL_DA_PXP_RX_FE_PWDB); 934 + 935 + airoha_phy_csr_2l_set_bits(pcie_phy, REG_CSR_2L_RX0_PHYCK_DIV, 936 + CSR_2L_PXP_RX0_PHYCK_RSTB | 937 + CSR_2L_PXP_RX0_TDC_CK_SEL); 938 + airoha_phy_csr_2l_set_bits(pcie_phy, REG_CSR_2L_RX1_PHYCK_DIV, 939 + CSR_2L_PXP_RX1_PHYCK_RSTB | 940 + CSR_2L_PXP_RX1_TDC_CK_SEL); 941 + 942 + airoha_phy_pma0_set_bits(pcie_phy, REG_PCIE_PMA_SW_RESET, 943 + PCIE_SW_RX_FIFO_RST | PCIE_SW_TX_RST | 944 + PCIE_SW_PMA_RST | PCIE_SW_ALLPCS_RST | 945 + PCIE_SW_TX_FIFO_RST); 946 + airoha_phy_pma1_set_bits(pcie_phy, REG_PCIE_PMA_SW_RESET, 947 + PCIE_SW_RX_FIFO_RST | PCIE_SW_TX_RST | 948 + PCIE_SW_PMA_RST | PCIE_SW_ALLPCS_RST | 949 + PCIE_SW_TX_FIFO_RST); 950 + 951 + airoha_phy_csr_2l_set_bits(pcie_phy, REG_CSR_2L_PXP_RX0_FE_VB_EQ2, 952 + CSR_2L_PXP_RX0_FE_VB_EQ2_EN | 953 + CSR_2L_PXP_RX0_FE_VB_EQ3_EN); 954 + airoha_phy_csr_2l_set_bits(pcie_phy, REG_CSR_2L_RX0_SIGDET_VTH_SEL, 955 + CSR_2L_PXP_RX0_FE_VB_EQ1_EN); 956 + airoha_phy_csr_2l_set_bits(pcie_phy, REG_CSR_2L_RX1_FE_VB_EQ1, 957 + CSR_2L_PXP_RX1_FE_VB_EQ1_EN | 958 + CSR_2L_PXP_RX1_FE_VB_EQ2_EN | 959 + CSR_2L_PXP_RX1_FE_VB_EQ3_EN); 960 + 961 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_RX0_REV0, 962 + CSR_2L_PXP_FE_GAIN_NORMAL_MODE, 0x4); 963 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_RX0_REV0, 964 + CSR_2L_PXP_FE_GAIN_TRAIN_MODE, 0x4); 965 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_RX1_REV0, 966 + CSR_2L_PXP_FE_GAIN_NORMAL_MODE, 0x4); 967 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_RX1_REV0, 968 + CSR_2L_PXP_FE_GAIN_TRAIN_MODE, 0x4); 969 + } 970 + 971 + static void airoha_pcie_phy_set_pr(struct airoha_pcie_phy *pcie_phy) 972 + { 973 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_CDR0_PR_VREG_IBAND, 974 + CSR_2L_PXP_CDR0_PR_VREG_IBAND, 0x5); 975 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_CDR0_PR_VREG_IBAND, 976 + CSR_2L_PXP_CDR0_PR_VREG_CKBUF, 0x5); 977 + 978 + airoha_phy_csr_2l_clear_bits(pcie_phy, REG_CSR_2L_CDR0_PR_CKREF_DIV, 979 + CSR_2L_PXP_CDR0_PR_CKREF_DIV); 980 + airoha_phy_csr_2l_clear_bits(pcie_phy, REG_CSR_2L_CDR0_PR_COR_HBW, 981 + CSR_2L_PXP_CDR0_PR_CKREF_DIV1); 982 + 983 + airoha_phy_csr_2l_update_field(pcie_phy, 984 + REG_CSR_2L_CDR1_PR_VREG_IBAND_VAL, 985 + CSR_2L_PXP_CDR1_PR_VREG_IBAND, 0x5); 986 + airoha_phy_csr_2l_update_field(pcie_phy, 987 + REG_CSR_2L_CDR1_PR_VREG_IBAND_VAL, 988 + CSR_2L_PXP_CDR1_PR_VREG_CKBUF, 0x5); 989 + 990 + airoha_phy_csr_2l_clear_bits(pcie_phy, REG_CSR_2L_CDR1_PR_CKREF_DIV, 991 + CSR_2L_PXP_CDR1_PR_CKREF_DIV); 992 + airoha_phy_csr_2l_clear_bits(pcie_phy, REG_CSR_2L_CDR1_PR_COR_HBW, 993 + CSR_2L_PXP_CDR1_PR_CKREF_DIV1); 994 + 995 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_CDR0_LPF_RATIO, 996 + CSR_2L_PXP_CDR0_LPF_TOP_LIM, 0x20000); 997 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_CDR1_LPF_RATIO, 998 + CSR_2L_PXP_CDR1_LPF_TOP_LIM, 0x20000); 999 + 1000 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_CDR0_PR_BETA_DAC, 1001 + CSR_2L_PXP_CDR0_PR_BETA_SEL, 0x2); 1002 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_CDR1_PR_BETA_DAC, 1003 + CSR_2L_PXP_CDR1_PR_BETA_SEL, 0x2); 1004 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_CDR0_PR_BETA_DAC, 1005 + CSR_2L_PXP_CDR0_PR_KBAND_DIV, 0x4); 1006 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_CDR1_PR_BETA_DAC, 1007 + CSR_2L_PXP_CDR1_PR_KBAND_DIV, 0x4); 1008 + } 1009 + 1010 + static void airoha_pcie_phy_set_txflow(struct airoha_pcie_phy *pcie_phy) 1011 + { 1012 + airoha_phy_csr_2l_set_bits(pcie_phy, REG_CSR_2L_TX0_CKLDO, 1013 + CSR_2L_PXP_TX0_CKLDO_EN); 1014 + airoha_phy_csr_2l_set_bits(pcie_phy, REG_CSR_2L_TX1_CKLDO, 1015 + CSR_2L_PXP_TX1_CKLDO_EN); 1016 + 1017 + airoha_phy_csr_2l_set_bits(pcie_phy, REG_CSR_2L_TX0_CKLDO, 1018 + CSR_2L_PXP_TX0_DMEDGEGEN_EN); 1019 + airoha_phy_csr_2l_set_bits(pcie_phy, REG_CSR_2L_TX1_CKLDO, 1020 + CSR_2L_PXP_TX1_DMEDGEGEN_EN); 1021 + airoha_phy_csr_2l_clear_bits(pcie_phy, REG_CSR_2L_TX1_MULTLANE, 1022 + CSR_2L_PXP_TX1_MULTLANE_EN); 1023 + } 1024 + 1025 + static void airoha_pcie_phy_set_rx_mode(struct airoha_pcie_phy *pcie_phy) 1026 + { 1027 + writel(0x804000, pcie_phy->pma0 + REG_PCIE_PMA_DIG_RESERVE_27); 1028 + airoha_phy_pma0_update_field(pcie_phy, REG_PCIE_PMA_DIG_RESERVE_18, 1029 + PCIE_PXP_RX_VTH_SEL_PCIE_G1, 0x5); 1030 + airoha_phy_pma0_update_field(pcie_phy, REG_PCIE_PMA_DIG_RESERVE_18, 1031 + PCIE_PXP_RX_VTH_SEL_PCIE_G2, 0x5); 1032 + airoha_phy_pma0_update_field(pcie_phy, REG_PCIE_PMA_DIG_RESERVE_18, 1033 + PCIE_PXP_RX_VTH_SEL_PCIE_G3, 0x5); 1034 + airoha_phy_pma0_set_bits(pcie_phy, REG_PCIE_PMA_DIG_RESERVE_30, 1035 + 0x77700); 1036 + 1037 + airoha_phy_csr_2l_clear_bits(pcie_phy, REG_CSR_2L_CDR0_PR_MONCK, 1038 + CSR_2L_PXP_CDR0_PR_MONCK_ENABLE); 1039 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_CDR0_PR_MONCK, 1040 + CSR_2L_PXP_CDR0_PR_RESERVE0, 0x2); 1041 + airoha_phy_csr_2l_update_field(pcie_phy, 1042 + REG_CSR_2L_PXP_RX0_OSCAL_CTLE1IOS, 1043 + CSR_2L_PXP_RX0_PR_OSCAL_VGA1IOS, 0x19); 1044 + airoha_phy_csr_2l_update_field(pcie_phy, 1045 + REG_CSR_2L_PXP_RX0_OSCA_VGA1VOS, 1046 + CSR_2L_PXP_RX0_PR_OSCAL_VGA1VOS, 0x19); 1047 + airoha_phy_csr_2l_update_field(pcie_phy, 1048 + REG_CSR_2L_PXP_RX0_OSCA_VGA1VOS, 1049 + CSR_2L_PXP_RX0_PR_OSCAL_VGA2IOS, 0x14); 1050 + 1051 + writel(0x804000, pcie_phy->pma1 + REG_PCIE_PMA_DIG_RESERVE_27); 1052 + airoha_phy_pma1_update_field(pcie_phy, REG_PCIE_PMA_DIG_RESERVE_18, 1053 + PCIE_PXP_RX_VTH_SEL_PCIE_G1, 0x5); 1054 + airoha_phy_pma1_update_field(pcie_phy, REG_PCIE_PMA_DIG_RESERVE_18, 1055 + PCIE_PXP_RX_VTH_SEL_PCIE_G2, 0x5); 1056 + airoha_phy_pma1_update_field(pcie_phy, REG_PCIE_PMA_DIG_RESERVE_18, 1057 + PCIE_PXP_RX_VTH_SEL_PCIE_G3, 0x5); 1058 + 1059 + airoha_phy_pma1_set_bits(pcie_phy, REG_PCIE_PMA_DIG_RESERVE_30, 1060 + 0x77700); 1061 + 1062 + airoha_phy_csr_2l_clear_bits(pcie_phy, REG_CSR_2L_CDR1_PR_MONCK, 1063 + CSR_2L_PXP_CDR1_PR_MONCK_ENABLE); 1064 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_CDR1_PR_MONCK, 1065 + CSR_2L_PXP_CDR1_PR_RESERVE0, 0x2); 1066 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_RX1_OSCAL_VGA1IOS, 1067 + CSR_2L_PXP_RX1_PR_OSCAL_VGA1IOS, 0x19); 1068 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_RX1_OSCAL_VGA1IOS, 1069 + CSR_2L_PXP_RX1_PR_OSCAL_VGA1VOS, 0x19); 1070 + airoha_phy_csr_2l_update_field(pcie_phy, REG_CSR_2L_RX1_OSCAL_VGA1IOS, 1071 + CSR_2L_PXP_RX1_PR_OSCAL_VGA2IOS, 0x14); 1072 + } 1073 + 1074 + static void airoha_pcie_phy_load_kflow(struct airoha_pcie_phy *pcie_phy) 1075 + { 1076 + airoha_phy_pma0_update_field(pcie_phy, REG_PCIE_PMA_DIG_RESERVE_12, 1077 + PCIE_FORCE_PMA_RX_SPEED, 0xa); 1078 + airoha_phy_pma1_update_field(pcie_phy, REG_PCIE_PMA_DIG_RESERVE_12, 1079 + PCIE_FORCE_PMA_RX_SPEED, 0xa); 1080 + airoha_phy_init_lane0_rx_fw_pre_calib(pcie_phy, PCIE_PORT_GEN3); 1081 + airoha_phy_init_lane1_rx_fw_pre_calib(pcie_phy, PCIE_PORT_GEN3); 1082 + 1083 + airoha_phy_pma0_clear_bits(pcie_phy, REG_PCIE_PMA_DIG_RESERVE_12, 1084 + PCIE_FORCE_PMA_RX_SPEED); 1085 + airoha_phy_pma1_clear_bits(pcie_phy, REG_PCIE_PMA_DIG_RESERVE_12, 1086 + PCIE_FORCE_PMA_RX_SPEED); 1087 + usleep_range(100, 200); 1088 + 1089 + airoha_phy_init_lane0_rx_fw_pre_calib(pcie_phy, PCIE_PORT_GEN2); 1090 + airoha_phy_init_lane1_rx_fw_pre_calib(pcie_phy, PCIE_PORT_GEN2); 1091 + } 1092 + 1093 + /** 1094 + * airoha_pcie_phy_init() - Initialize the phy 1095 + * @phy: the phy to be initialized 1096 + * 1097 + * Initialize the phy registers. 1098 + * The hardware settings will be reset during suspend, it should be 1099 + * reinitialized when the consumer calls phy_init() again on resume. 1100 + */ 1101 + static int airoha_pcie_phy_init(struct phy *phy) 1102 + { 1103 + struct airoha_pcie_phy *pcie_phy = phy_get_drvdata(phy); 1104 + 1105 + /* enable load FLL-K flow */ 1106 + airoha_phy_pma0_set_bits(pcie_phy, REG_PCIE_PMA_DIG_RESERVE_14, 1107 + PCIE_FLL_LOAD_EN); 1108 + airoha_phy_pma1_set_bits(pcie_phy, REG_PCIE_PMA_DIG_RESERVE_14, 1109 + PCIE_FLL_LOAD_EN); 1110 + 1111 + airoha_pcie_phy_init_default(pcie_phy); 1112 + airoha_pcie_phy_init_clk_out(pcie_phy); 1113 + airoha_pcie_phy_init_csr_2l(pcie_phy); 1114 + 1115 + usleep_range(100, 200); 1116 + 1117 + airoha_pcie_phy_init_rx(pcie_phy); 1118 + /* phase 1, no ssc for K TXPLL */ 1119 + airoha_pcie_phy_init_jcpll(pcie_phy); 1120 + 1121 + usleep_range(500, 600); 1122 + 1123 + /* TX PLL settings */ 1124 + airoha_pcie_phy_txpll(pcie_phy); 1125 + 1126 + usleep_range(200, 300); 1127 + 1128 + /* SSC JCPLL setting */ 1129 + airoha_pcie_phy_init_ssc_jcpll(pcie_phy); 1130 + 1131 + usleep_range(100, 200); 1132 + 1133 + /* Rx lan0 signal detect */ 1134 + airoha_pcie_phy_set_rxlan0_signal_detect(pcie_phy); 1135 + /* Rx lan1 signal detect */ 1136 + airoha_pcie_phy_set_rxlan1_signal_detect(pcie_phy); 1137 + /* RX FLOW */ 1138 + airoha_pcie_phy_set_rxflow(pcie_phy); 1139 + 1140 + usleep_range(100, 200); 1141 + 1142 + airoha_pcie_phy_set_pr(pcie_phy); 1143 + /* TX FLOW */ 1144 + airoha_pcie_phy_set_txflow(pcie_phy); 1145 + 1146 + usleep_range(100, 200); 1147 + /* RX mode setting */ 1148 + airoha_pcie_phy_set_rx_mode(pcie_phy); 1149 + /* Load K-Flow */ 1150 + airoha_pcie_phy_load_kflow(pcie_phy); 1151 + airoha_phy_pma0_clear_bits(pcie_phy, REG_PCIE_PMA_SS_DA_XPON_PWDB0, 1152 + PCIE_DA_XPON_CDR_PR_PWDB); 1153 + airoha_phy_pma1_clear_bits(pcie_phy, REG_PCIE_PMA_SS_DA_XPON_PWDB0, 1154 + PCIE_DA_XPON_CDR_PR_PWDB); 1155 + 1156 + usleep_range(100, 200); 1157 + 1158 + airoha_phy_pma0_set_bits(pcie_phy, REG_PCIE_PMA_SS_DA_XPON_PWDB0, 1159 + PCIE_DA_XPON_CDR_PR_PWDB); 1160 + airoha_phy_pma1_set_bits(pcie_phy, REG_PCIE_PMA_SS_DA_XPON_PWDB0, 1161 + PCIE_DA_XPON_CDR_PR_PWDB); 1162 + 1163 + usleep_range(100, 200); 1164 + 1165 + return 0; 1166 + } 1167 + 1168 + static int airoha_pcie_phy_exit(struct phy *phy) 1169 + { 1170 + struct airoha_pcie_phy *pcie_phy = phy_get_drvdata(phy); 1171 + 1172 + airoha_phy_pma0_clear_bits(pcie_phy, REG_PCIE_PMA_SW_RESET, 1173 + PCIE_PMA_SW_RST); 1174 + airoha_phy_pma1_clear_bits(pcie_phy, REG_PCIE_PMA_SW_RESET, 1175 + PCIE_PMA_SW_RST); 1176 + airoha_phy_csr_2l_clear_bits(pcie_phy, REG_CSR_2L_JCPLL_SSC, 1177 + CSR_2L_PXP_JCPLL_SSC_PHASE_INI | 1178 + CSR_2L_PXP_JCPLL_SSC_TRI_EN | 1179 + CSR_2L_PXP_JCPLL_SSC_EN); 1180 + 1181 + return 0; 1182 + } 1183 + 1184 + static const struct phy_ops airoha_pcie_phy_ops = { 1185 + .init = airoha_pcie_phy_init, 1186 + .exit = airoha_pcie_phy_exit, 1187 + .owner = THIS_MODULE, 1188 + }; 1189 + 1190 + static int airoha_pcie_phy_probe(struct platform_device *pdev) 1191 + { 1192 + struct airoha_pcie_phy *pcie_phy; 1193 + struct device *dev = &pdev->dev; 1194 + struct phy_provider *provider; 1195 + 1196 + pcie_phy = devm_kzalloc(dev, sizeof(*pcie_phy), GFP_KERNEL); 1197 + if (!pcie_phy) 1198 + return -ENOMEM; 1199 + 1200 + pcie_phy->csr_2l = devm_platform_ioremap_resource_byname(pdev, "csr-2l"); 1201 + if (IS_ERR(pcie_phy->csr_2l)) 1202 + return dev_err_probe(dev, PTR_ERR(pcie_phy->csr_2l), 1203 + "Failed to map phy-csr-2l base\n"); 1204 + 1205 + pcie_phy->pma0 = devm_platform_ioremap_resource_byname(pdev, "pma0"); 1206 + if (IS_ERR(pcie_phy->pma0)) 1207 + return dev_err_probe(dev, PTR_ERR(pcie_phy->pma0), 1208 + "Failed to map phy-pma0 base\n"); 1209 + 1210 + pcie_phy->pma1 = devm_platform_ioremap_resource_byname(pdev, "pma1"); 1211 + if (IS_ERR(pcie_phy->pma1)) 1212 + return dev_err_probe(dev, PTR_ERR(pcie_phy->pma1), 1213 + "Failed to map phy-pma1 base\n"); 1214 + 1215 + pcie_phy->phy = devm_phy_create(dev, dev->of_node, &airoha_pcie_phy_ops); 1216 + if (IS_ERR(pcie_phy->phy)) 1217 + return dev_err_probe(dev, PTR_ERR(pcie_phy->phy), 1218 + "Failed to create PCIe phy\n"); 1219 + 1220 + pcie_phy->dev = dev; 1221 + phy_set_drvdata(pcie_phy->phy, pcie_phy); 1222 + 1223 + provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); 1224 + if (IS_ERR(provider)) 1225 + return dev_err_probe(dev, PTR_ERR(provider), 1226 + "PCIe phy probe failed\n"); 1227 + 1228 + return 0; 1229 + } 1230 + 1231 + static const struct of_device_id airoha_pcie_phy_of_match[] = { 1232 + { .compatible = "airoha,en7581-pcie-phy" }, 1233 + { /* sentinel */ } 1234 + }; 1235 + MODULE_DEVICE_TABLE(of, airoha_pcie_phy_of_match); 1236 + 1237 + static struct platform_driver airoha_pcie_phy_driver = { 1238 + .probe = airoha_pcie_phy_probe, 1239 + .driver = { 1240 + .name = "airoha-pcie-phy", 1241 + .of_match_table = airoha_pcie_phy_of_match, 1242 + }, 1243 + }; 1244 + module_platform_driver(airoha_pcie_phy_driver); 1245 + 1246 + MODULE_DESCRIPTION("Airoha PCIe PHY driver"); 1247 + MODULE_AUTHOR("Lorenzo Bianconi <lorenzo@kernel.org>"); 1248 + MODULE_LICENSE("GPL");