Skip to content

Commit db456d9

Browse files
Furong Xudavem330
authored andcommitted
net: stmmac: xgmac: Enable support for multiple Flexible PPS outputs
From XGMAC Core 3.20 and later, each Flexible PPS has individual PPSEN bit to select Fixed mode or Flexible mode. The PPSEN must be set, or it stays in Fixed PPS mode by default. XGMAC Core prior 3.20, only PPSEN0(bit 4) is writable. PPSEN{1,2,3} are read-only reserved, and they are already in Flexible mode by default, our new code always set PPSEN{1,2,3} do not make things worse ;-) Fixes: 95eaf3c ("net: stmmac: dwxgmac: Add Flexible PPS support") Reviewed-by: Serge Semin <fancer.lancer@gmail.com> Reviewed-by: Jacob Keller <jacob.e.keller@intel.com> Signed-off-by: Furong Xu <0x1207@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent e8ae8ad commit db456d9

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@
259259
((val) << XGMAC_PPS_MINIDX(x))
260260
#define XGMAC_PPSCMD_START 0x2
261261
#define XGMAC_PPSCMD_STOP 0x5
262-
#define XGMAC_PPSEN0 BIT(4)
262+
#define XGMAC_PPSENx(x) BIT(4 + (x) * 8)
263263
#define XGMAC_PPSx_TARGET_TIME_SEC(x) (0x00000d80 + (x) * 0x10)
264264
#define XGMAC_PPSx_TARGET_TIME_NSEC(x) (0x00000d84 + (x) * 0x10)
265265
#define XGMAC_TRGTBUSY0 BIT(31)

drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1178,7 +1178,19 @@ static int dwxgmac2_flex_pps_config(void __iomem *ioaddr, int index,
11781178

11791179
val |= XGMAC_PPSCMDx(index, XGMAC_PPSCMD_START);
11801180
val |= XGMAC_TRGTMODSELx(index, XGMAC_PPSCMD_START);
1181-
val |= XGMAC_PPSEN0;
1181+
1182+
/* XGMAC Core has 4 PPS outputs at most.
1183+
*
1184+
* Prior XGMAC Core 3.20, Fixed mode or Flexible mode are selectable for
1185+
* PPS0 only via PPSEN0. PPS{1,2,3} are in Flexible mode by default,
1186+
* and can not be switched to Fixed mode, since PPSEN{1,2,3} are
1187+
* read-only reserved to 0.
1188+
* But we always set PPSEN{1,2,3} do not make things worse ;-)
1189+
*
1190+
* From XGMAC Core 3.20 and later, PPSEN{0,1,2,3} are writable and must
1191+
* be set, or the PPS outputs stay in Fixed PPS mode by default.
1192+
*/
1193+
val |= XGMAC_PPSENx(index);
11821194

11831195
writel(cfg->start.tv_sec, ioaddr + XGMAC_PPSx_TARGET_TIME_SEC(index));
11841196

0 commit comments

Comments
 (0)