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

phy: airoha: Add dtime and Rx AEQ IO registers

Introduce Tx-Rx detection Time and Rx AEQ training mappings to
phy-airoha-pcie driver. This is a preliminary patch to introduce PCIe
support to En7581 SoC through the mediatek-gen3 PCIe driver.
This change is not introducing any backward compatibility issue since
the EN7581 dts is not upstream yet.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Link: https://lore.kernel.org/r/edf3b28926177166c65256604d69f2f576cb6fb3.1719682943.git.lorenzo@kernel.org
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Lorenzo Bianconi and committed by
Vinod Koul
2a011c3c 5854d0aa

+55
+17
drivers/phy/phy-airoha-pcie-regs.h
··· 474 474 #define REG_PCIE_PMA_DIG_RESERVE_27 0x0908 475 475 #define REG_PCIE_PMA_DIG_RESERVE_30 0x0914 476 476 477 + /* DTIME */ 478 + #define REG_PCIE_PEXTP_DIG_GLB44 0x00 479 + #define PCIE_XTP_RXDET_VCM_OFF_STB_T_SEL GENMASK(7, 0) 480 + #define PCIE_XTP_RXDET_EN_STB_T_SEL GENMASK(15, 8) 481 + #define PCIE_XTP_RXDET_FINISH_STB_T_SEL GENMASK(23, 16) 482 + #define PCIE_XTP_TXPD_TX_DATA_EN_DLY GENMASK(27, 24) 483 + #define PCIE_XTP_TXPD_RXDET_DONE_CDT BIT(28) 484 + #define PCIE_XTP_RXDET_LATCH_STB_T_SEL GENMASK(31, 29) 485 + 486 + /* RX AEQ */ 487 + #define REG_PCIE_PEXTP_DIG_LN_RX30_P0 0x0000 488 + #define PCIE_XTP_LN_RX_PDOWN_L1P2_EXIT_WAIT GENMASK(7, 0) 489 + #define PCIE_XTP_LN_RX_PDOWN_T2RLB_DIG_EN BIT(8) 490 + #define PCIE_XTP_LN_RX_PDOWN_E0_AEQEN_WAIT GENMASK(31, 16) 491 + 492 + #define REG_PCIE_PEXTP_DIG_LN_RX30_P1 0x0100 493 + 477 494 #endif /* _PHY_AIROHA_PCIE_H */
+38
drivers/phy/phy-airoha-pcie.c
··· 31 31 * @csr_2l: Analogic lane IO mapped register base address 32 32 * @pma0: IO mapped register base address of PMA0-PCIe 33 33 * @pma1: IO mapped register base address of PMA1-PCIe 34 + * @p0_xr_dtime: IO mapped register base address of port0 Tx-Rx detection time 35 + * @p1_xr_dtime: IO mapped register base address of port1 Tx-Rx detection time 36 + * @rx_aeq: IO mapped register base address of Rx AEQ training 34 37 */ 35 38 struct airoha_pcie_phy { 36 39 struct device *dev; ··· 41 38 void __iomem *csr_2l; 42 39 void __iomem *pma0; 43 40 void __iomem *pma1; 41 + void __iomem *p0_xr_dtime; 42 + void __iomem *p1_xr_dtime; 43 + void __iomem *rx_aeq; 44 44 }; 45 45 46 46 static void airoha_phy_clear_bits(void __iomem *reg, u32 mask) ··· 1107 1101 static int airoha_pcie_phy_init(struct phy *phy) 1108 1102 { 1109 1103 struct airoha_pcie_phy *pcie_phy = phy_get_drvdata(phy); 1104 + u32 val; 1105 + 1106 + /* Setup Tx-Rx detection time */ 1107 + val = FIELD_PREP(PCIE_XTP_RXDET_VCM_OFF_STB_T_SEL, 0x33) | 1108 + FIELD_PREP(PCIE_XTP_RXDET_EN_STB_T_SEL, 0x1) | 1109 + FIELD_PREP(PCIE_XTP_RXDET_FINISH_STB_T_SEL, 0x2) | 1110 + FIELD_PREP(PCIE_XTP_TXPD_TX_DATA_EN_DLY, 0x3) | 1111 + FIELD_PREP(PCIE_XTP_RXDET_LATCH_STB_T_SEL, 0x1); 1112 + writel(val, pcie_phy->p0_xr_dtime + REG_PCIE_PEXTP_DIG_GLB44); 1113 + writel(val, pcie_phy->p1_xr_dtime + REG_PCIE_PEXTP_DIG_GLB44); 1114 + /* Setup Rx AEQ training time */ 1115 + val = FIELD_PREP(PCIE_XTP_LN_RX_PDOWN_L1P2_EXIT_WAIT, 0x32) | 1116 + FIELD_PREP(PCIE_XTP_LN_RX_PDOWN_E0_AEQEN_WAIT, 0x5050); 1117 + writel(val, pcie_phy->rx_aeq + REG_PCIE_PEXTP_DIG_LN_RX30_P0); 1118 + writel(val, pcie_phy->rx_aeq + REG_PCIE_PEXTP_DIG_LN_RX30_P1); 1110 1119 1111 1120 /* enable load FLL-K flow */ 1112 1121 airoha_phy_pma0_set_bits(pcie_phy, REG_PCIE_PMA_DIG_RESERVE_14, ··· 1237 1216 if (IS_ERR(pcie_phy->phy)) 1238 1217 return dev_err_probe(dev, PTR_ERR(pcie_phy->phy), 1239 1218 "Failed to create PCIe phy\n"); 1219 + 1220 + pcie_phy->p0_xr_dtime = 1221 + devm_platform_ioremap_resource_byname(pdev, "p0-xr-dtime"); 1222 + if (IS_ERR(pcie_phy->p0_xr_dtime)) 1223 + return dev_err_probe(dev, PTR_ERR(pcie_phy->p0_xr_dtime), 1224 + "Failed to map P0 Tx-Rx dtime base\n"); 1225 + 1226 + pcie_phy->p1_xr_dtime = 1227 + devm_platform_ioremap_resource_byname(pdev, "p1-xr-dtime"); 1228 + if (IS_ERR(pcie_phy->p1_xr_dtime)) 1229 + return dev_err_probe(dev, PTR_ERR(pcie_phy->p1_xr_dtime), 1230 + "Failed to map P1 Tx-Rx dtime base\n"); 1231 + 1232 + pcie_phy->rx_aeq = devm_platform_ioremap_resource_byname(pdev, "rx-aeq"); 1233 + if (IS_ERR(pcie_phy->rx_aeq)) 1234 + return dev_err_probe(dev, PTR_ERR(pcie_phy->rx_aeq), 1235 + "Failed to map Rx AEQ base\n"); 1240 1236 1241 1237 pcie_phy->dev = dev; 1242 1238 phy_set_drvdata(pcie_phy->phy, pcie_phy);