Skip to content

Commit 2a011c3

Browse files
LorenzoBianconivinodkoul
authored andcommitted
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>
1 parent 5854d0a commit 2a011c3

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

drivers/phy/phy-airoha-pcie-regs.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,4 +474,21 @@
474474
#define REG_PCIE_PMA_DIG_RESERVE_27 0x0908
475475
#define REG_PCIE_PMA_DIG_RESERVE_30 0x0914
476476

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+
477494
#endif /* _PHY_AIROHA_PCIE_H */

drivers/phy/phy-airoha-pcie.c

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,19 @@ enum airoha_pcie_port_gen {
3131
* @csr_2l: Analogic lane IO mapped register base address
3232
* @pma0: IO mapped register base address of PMA0-PCIe
3333
* @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
3437
*/
3538
struct airoha_pcie_phy {
3639
struct device *dev;
3740
struct phy *phy;
3841
void __iomem *csr_2l;
3942
void __iomem *pma0;
4043
void __iomem *pma1;
44+
void __iomem *p0_xr_dtime;
45+
void __iomem *p1_xr_dtime;
46+
void __iomem *rx_aeq;
4147
};
4248

4349
static void airoha_phy_clear_bits(void __iomem *reg, u32 mask)
@@ -1101,6 +1107,21 @@ static void airoha_pcie_phy_load_kflow(struct airoha_pcie_phy *pcie_phy)
11011107
static int airoha_pcie_phy_init(struct phy *phy)
11021108
{
11031109
struct airoha_pcie_phy *pcie_phy = phy_get_drvdata(phy);
1110+
u32 val;
1111+
1112+
/* Setup Tx-Rx detection time */
1113+
val = FIELD_PREP(PCIE_XTP_RXDET_VCM_OFF_STB_T_SEL, 0x33) |
1114+
FIELD_PREP(PCIE_XTP_RXDET_EN_STB_T_SEL, 0x1) |
1115+
FIELD_PREP(PCIE_XTP_RXDET_FINISH_STB_T_SEL, 0x2) |
1116+
FIELD_PREP(PCIE_XTP_TXPD_TX_DATA_EN_DLY, 0x3) |
1117+
FIELD_PREP(PCIE_XTP_RXDET_LATCH_STB_T_SEL, 0x1);
1118+
writel(val, pcie_phy->p0_xr_dtime + REG_PCIE_PEXTP_DIG_GLB44);
1119+
writel(val, pcie_phy->p1_xr_dtime + REG_PCIE_PEXTP_DIG_GLB44);
1120+
/* Setup Rx AEQ training time */
1121+
val = FIELD_PREP(PCIE_XTP_LN_RX_PDOWN_L1P2_EXIT_WAIT, 0x32) |
1122+
FIELD_PREP(PCIE_XTP_LN_RX_PDOWN_E0_AEQEN_WAIT, 0x5050);
1123+
writel(val, pcie_phy->rx_aeq + REG_PCIE_PEXTP_DIG_LN_RX30_P0);
1124+
writel(val, pcie_phy->rx_aeq + REG_PCIE_PEXTP_DIG_LN_RX30_P1);
11041125

11051126
/* enable load FLL-K flow */
11061127
airoha_phy_pma0_set_bits(pcie_phy, REG_PCIE_PMA_DIG_RESERVE_14,
@@ -1217,6 +1238,23 @@ static int airoha_pcie_phy_probe(struct platform_device *pdev)
12171238
return dev_err_probe(dev, PTR_ERR(pcie_phy->phy),
12181239
"Failed to create PCIe phy\n");
12191240

1241+
pcie_phy->p0_xr_dtime =
1242+
devm_platform_ioremap_resource_byname(pdev, "p0-xr-dtime");
1243+
if (IS_ERR(pcie_phy->p0_xr_dtime))
1244+
return dev_err_probe(dev, PTR_ERR(pcie_phy->p0_xr_dtime),
1245+
"Failed to map P0 Tx-Rx dtime base\n");
1246+
1247+
pcie_phy->p1_xr_dtime =
1248+
devm_platform_ioremap_resource_byname(pdev, "p1-xr-dtime");
1249+
if (IS_ERR(pcie_phy->p1_xr_dtime))
1250+
return dev_err_probe(dev, PTR_ERR(pcie_phy->p1_xr_dtime),
1251+
"Failed to map P1 Tx-Rx dtime base\n");
1252+
1253+
pcie_phy->rx_aeq = devm_platform_ioremap_resource_byname(pdev, "rx-aeq");
1254+
if (IS_ERR(pcie_phy->rx_aeq))
1255+
return dev_err_probe(dev, PTR_ERR(pcie_phy->rx_aeq),
1256+
"Failed to map Rx AEQ base\n");
1257+
12201258
pcie_phy->dev = dev;
12211259
phy_set_drvdata(pcie_phy->phy, pcie_phy);
12221260

0 commit comments

Comments
 (0)