On Agilex 5, an external timestamp trigger driven by the FPGA design never reaches the EMAC. The EMAC's trigger input takes its signal from an HPS pin unless the ppstrig_sel bit (bit 4) of the EMAC's tsn register in the System Manager selects the FPGA fabric. Nothing in the kernel sets that bit. Set the bit when the device tree has altr,f2h-ptp-aux-trig, and clear it otherwise. It has to be written while the EMAC is in reset, which is where the PHY mode is written to the same register. Tested on a Terasic DE25-Nano, with a separate series that makes external timestamps work on XGMAC: with the property, external timestamp channel 1 reports one event per pulse from a header pin. Signed-off-by: James Clark <j…@jclark.com> --- .../net/ethernet/stmicro/stmmac/dwmac-socfpga.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c index 4e0187ffe0d3..0a706624d285 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c @@ -28,6 +28,7 @@ #define SYSMGR_EMACGRP_CTRL_PHYSEL_MASK 0x00000003 #define SYSMGR_EMACGRP_CTRL_PTP_REF_CLK_MASK 0x00000010 #define SYSMGR_GEN10_EMACGRP_CTRL_PTP_REF_CLK_MASK 0x00000100 +#define SYSMGR_AGILEX5_TSN_PPSTRIG_SEL BIT(4) #define SYSMGR_FPGAGRP_MODULE_REG 0x00000028 #define SYSMGR_FPGAGRP_MODULE_EMAC 0x00000004 @@ -56,6 +57,8 @@ struct socfpga_dwmac_ops { int (*set_phy_mode)(struct socfpga_dwmac *dwmac_priv, struct device *dev); void (*setup_plat_dat)(struct socfpga_dwmac *dwmac_priv); + /* The control register has the ppstrig_sel bit */ + bool has_ppstrig_sel; }; struct socfpga_dwmac { @@ -69,6 +72,7 @@ struct socfpga_dwmac { void __iomem *tse_pcs_base; void __iomem *sgmii_adapter_base; bool f2h_ptp_ref_clk; + bool f2h_ptp_aux_trig; const struct socfpga_dwmac_ops *ops; }; @@ -154,6 +158,8 @@ static int socfpga_dwmac_parse_data(struct socfpga_dwmac *dwmac, struct device * } dwmac->f2h_ptp_ref_clk = of_property_read_bool(np, "altr,f2h_ptp_ref_clk"); + dwmac->f2h_ptp_aux_trig = + of_property_read_bool(np, "altr,f2h-ptp-aux-trig"); np_splitter = of_parse_phandle(np, "altr,emac-splitter", 0); if (np_splitter) { @@ -481,6 +487,16 @@ static int socfpga_gen10_set_phy_mode(struct socfpga_dwmac *dwmac, ctrl &= ~SYSMGR_GEN10_EMACGRP_CTRL_PTP_REF_CLK_MASK; } + /* Take the trigger of auxiliary snapshot 1 from the FPGA fabric, or + * from the HPS I/O pin multiplexer + */ + if (dwmac->ops->has_ppstrig_sel) { + if (dwmac->f2h_ptp_aux_trig) + ctrl |= SYSMGR_AGILEX5_TSN_PPSTRIG_SEL; + else + ctrl &= ~SYSMGR_AGILEX5_TSN_PPSTRIG_SEL; + } + regmap_write(sys_mgr_base_addr, reg_offset, ctrl); /* Deassert reset for the phy configuration to be sampled by @@ -702,6 +718,7 @@ static const struct socfpga_dwmac_ops socfpga_gen10_ops = { static const struct socfpga_dwmac_ops socfpga_agilex5_ops = { .set_phy_mode = socfpga_gen10_set_phy_mode, .setup_plat_dat = socfpga_agilex5_setup_plat_dat, + .has_ppstrig_sel = true, }; static const struct of_device_id socfpga_dwmac_match[] = {
-- 2.56.1