On Dec 05, James Clark wrote: > On a Terasic DE25-Nano (Agilex 5, XGMAC core 3.10), disabling PPS > output 0 with PTP_PEROUT_REQUEST leaves about 15 pulses a second on the > pin instead of stopping it. > > In the XGMAC register MAC_PPS_CONTROL, bit PPSEN0 selects what bits 3:0 > mean. When PPSEN0 is set, they are PPSCMD0, a command to the flexible > PPS logic. When it is clear, they are PPSCTRL0, the frequency of output > 0 in fixed PPS mode. The disable path in dwxgmac2_flex_pps_config() > clears PPSEN0 and then writes the stop command (0x5). The MAC reads > this as PPSCTRL0 = 5, so output 0 switches to fixed mode at that > frequency setting. > > Set PPSENx when disabling, as the enable path does. Commit 520cf6002147 > ("net: stmmac: fix disabling flexible PPS output") made the same fix > for dwmac5 after the XGMAC code was copied from it. > > Fix tested on the DE25-Nano. > > Fixes: 95eaf3cd0a90 ("net: stmmac: dwxgmac: Add Flexible PPS support") > Signed-off-by: James Clark Reviewed-by: Lorenzo Bianconi > --- > I used an LLM coding assistant to help prepare this patch. > > This can be tested on the DE25-Nano using the FPGA design at > https://github.com/jclark/de25-nano-debian, which connects periodic > output channel 0 to pin 6 of JP1. > > drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c > index 6b2bfc241109..c43e8c597a09 100644 > --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c > +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c > @@ -1171,6 +1171,7 @@ static int dwxgmac2_flex_pps_config(void __iomem *ioaddr, int index, > > if (!enable) { > val |= XGMAC_PPSCMDx(index, XGMAC_PPSCMD_STOP); > + val |= XGMAC_PPSENx(index); > writel(val, ioaddr + XGMAC_PPS_CONTROL); > return 0; > } > -- > 2.56.1 > >