Message ID | 20240207111859.15463-1-csokas.bence@prolan.hu (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | net: fec: Add ECR bit macros, fix FEC_ECR_EN1588 being cleared on link-down | expand |
On 07.02.2024 12:18:59, Csókás Bence wrote: > Signed-off-by: Csókás Bence <csokas.bence@prolan.hu> Please provide a patch description. > --- > drivers/net/ethernet/freescale/fec_main.c | 17 +++++++++++++---- > 1 file changed, 13 insertions(+), 4 deletions(-) > > diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c > index 63707e065141..652251e48ad4 100644 > --- a/drivers/net/ethernet/freescale/fec_main.c > +++ b/drivers/net/ethernet/freescale/fec_main.c > @@ -273,8 +273,11 @@ MODULE_PARM_DESC(macaddr, "FEC Ethernet MAC address"); > #define FEC_MMFR_TA (2 << 16) > #define FEC_MMFR_DATA(v) (v & 0xffff) > /* FEC ECR bits definition */ > -#define FEC_ECR_MAGICEN (1 << 2) > -#define FEC_ECR_SLEEP (1 << 3) > +#define FEC_ECR_RESET BIT(0) > +#define FEC_ECR_ETHEREN BIT(1) > +#define FEC_ECR_MAGICEN BIT(2) > +#define FEC_ECR_SLEEP BIT(3) > +#define FEC_ECR_EN1588 BIT(4) nitpick: can you keep the original indention? > > #define FEC_MII_TIMEOUT 30000 /* us */ > > @@ -1213,7 +1216,7 @@ fec_restart(struct net_device *ndev) > } > > if (fep->bufdesc_ex) > - ecntl |= (1 << 4); > + ecntl |= FEC_ECR_EN1588; > > if (fep->quirks & FEC_QUIRK_DELAYED_CLKS_SUPPORT && > fep->rgmii_txc_dly) > @@ -1314,6 +1317,7 @@ fec_stop(struct net_device *ndev) > struct fec_enet_private *fep = netdev_priv(ndev); > u32 rmii_mode = readl(fep->hwp + FEC_R_CNTRL) & (1 << 8); > u32 val; > + u32 ecntl = 0; nitpick: please move it before the "u32 val;" so that it looks more reverse-xmas-treeish. > > /* We cannot expect a graceful transmit stop without link !!! */ > if (fep->link) { > @@ -1342,12 +1346,17 @@ fec_stop(struct net_device *ndev) > writel(fep->phy_speed, fep->hwp + FEC_MII_SPEED); > writel(FEC_DEFAULT_IMASK, fep->hwp + FEC_IMASK); > > + if (fep->bufdesc_ex) > + ecntl |= FEC_ECR_EN1588; > + > /* We have to keep ENET enabled to have MII interrupt stay working */ > if (fep->quirks & FEC_QUIRK_ENET_MAC && > !(fep->wol_flag & FEC_WOL_FLAG_SLEEP_ON)) { > - writel(2, fep->hwp + FEC_ECNTRL); > + ecntl |= FEC_ECR_ETHEREN; > writel(rmii_mode, fep->hwp + FEC_R_CNTRL); > } > + > + writel(ecntl, fep->hwp + FEC_ECNTRL); > } regards, Marc
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index 63707e065141..652251e48ad4 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -273,8 +273,11 @@ MODULE_PARM_DESC(macaddr, "FEC Ethernet MAC address"); #define FEC_MMFR_TA (2 << 16) #define FEC_MMFR_DATA(v) (v & 0xffff) /* FEC ECR bits definition */ -#define FEC_ECR_MAGICEN (1 << 2) -#define FEC_ECR_SLEEP (1 << 3) +#define FEC_ECR_RESET BIT(0) +#define FEC_ECR_ETHEREN BIT(1) +#define FEC_ECR_MAGICEN BIT(2) +#define FEC_ECR_SLEEP BIT(3) +#define FEC_ECR_EN1588 BIT(4) #define FEC_MII_TIMEOUT 30000 /* us */ @@ -1213,7 +1216,7 @@ fec_restart(struct net_device *ndev) } if (fep->bufdesc_ex) - ecntl |= (1 << 4); + ecntl |= FEC_ECR_EN1588; if (fep->quirks & FEC_QUIRK_DELAYED_CLKS_SUPPORT && fep->rgmii_txc_dly) @@ -1314,6 +1317,7 @@ fec_stop(struct net_device *ndev) struct fec_enet_private *fep = netdev_priv(ndev); u32 rmii_mode = readl(fep->hwp + FEC_R_CNTRL) & (1 << 8); u32 val; + u32 ecntl = 0; /* We cannot expect a graceful transmit stop without link !!! */ if (fep->link) { @@ -1342,12 +1346,17 @@ fec_stop(struct net_device *ndev) writel(fep->phy_speed, fep->hwp + FEC_MII_SPEED); writel(FEC_DEFAULT_IMASK, fep->hwp + FEC_IMASK); + if (fep->bufdesc_ex) + ecntl |= FEC_ECR_EN1588; + /* We have to keep ENET enabled to have MII interrupt stay working */ if (fep->quirks & FEC_QUIRK_ENET_MAC && !(fep->wol_flag & FEC_WOL_FLAG_SLEEP_ON)) { - writel(2, fep->hwp + FEC_ECNTRL); + ecntl |= FEC_ECR_ETHEREN; writel(rmii_mode, fep->hwp + FEC_R_CNTRL); } + + writel(ecntl, fep->hwp + FEC_ECNTRL); }
Signed-off-by: Csókás Bence <csokas.bence@prolan.hu> --- drivers/net/ethernet/freescale/fec_main.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-)