[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240629091602.GJ837606@kernel.org>
Date: Sat, 29 Jun 2024 10:16:02 +0100
From: Simon Horman <horms@...nel.org>
To: Marek Vasut <marex@...x.de>
Cc: netdev@...r.kernel.org, Alexandre Torgue <alexandre.torgue@...s.st.com>,
Andrew Lunn <andrew@...n.ch>,
Christophe Roullier <christophe.roullier@...s.st.com>,
"David S . Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Heiner Kallweit <hkallweit1@...il.com>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
Russell King <linux@...linux.org.uk>, kernel@...electronics.com,
linux-kernel@...r.kernel.org
Subject: Re: [net-next,PATCH v2] net: phy: realtek: Add support for PHY LEDs
on RTL8211F
On Fri, Jun 28, 2024 at 08:58:51PM +0200, Marek Vasut wrote:
> On 6/28/24 4:27 PM, Simon Horman wrote:
> > On Tue, Jun 25, 2024 at 10:42:17PM +0200, Marek Vasut wrote:
> > > Realtek RTL8211F Ethernet PHY supports 3 LED pins which are used to
> > > indicate link status and activity. Add minimal LED controller driver
> > > supporting the most common uses with the 'netdev' trigger.
> > >
> > > Signed-off-by: Marek Vasut <marex@...x.de>
> > > ---
> > > Cc: Alexandre Torgue <alexandre.torgue@...s.st.com>
> > > Cc: Andrew Lunn <andrew@...n.ch>
> > > Cc: Christophe Roullier <christophe.roullier@...s.st.com>
> > > Cc: David S. Miller <davem@...emloft.net>
> > > Cc: Eric Dumazet <edumazet@...gle.com>
> > > Cc: Heiner Kallweit <hkallweit1@...il.com>
> > > Cc: Jakub Kicinski <kuba@...nel.org>
> > > Cc: Paolo Abeni <pabeni@...hat.com>
> > > Cc: Russell King <linux@...linux.org.uk>
> > > Cc: kernel@...electronics.com
> > > Cc: linux-kernel@...r.kernel.org
> > > Cc: netdev@...r.kernel.org
> > > ---
> > > V2: - RX and TX are not differentiated, either both are set or not set,
> > > filter this in rtl8211f_led_hw_is_supported()
> > > ---
> > > drivers/net/phy/realtek.c | 106 ++++++++++++++++++++++++++++++++++++++
> > > 1 file changed, 106 insertions(+)
> > >
> > > diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c
> > > index 2174893c974f3..bed839237fb55 100644
> > > --- a/drivers/net/phy/realtek.c
> > > +++ b/drivers/net/phy/realtek.c
> > > @@ -32,6 +32,15 @@
> > > #define RTL8211F_PHYCR2 0x19
> > > #define RTL8211F_INSR 0x1d
> > > +#define RTL8211F_LEDCR 0x10
> > > +#define RTL8211F_LEDCR_MODE BIT(15)
> > > +#define RTL8211F_LEDCR_ACT_TXRX BIT(4)
> > > +#define RTL8211F_LEDCR_LINK_1000 BIT(3)
> > > +#define RTL8211F_LEDCR_LINK_100 BIT(1)
> > > +#define RTL8211F_LEDCR_LINK_10 BIT(0)
> > > +#define RTL8211F_LEDCR_MASK GENMASK(4, 0)
> > > +#define RTL8211F_LEDCR_SHIFT 5
> > > +
> >
> > Hi Marek,
> >
> > FWIIW, I think that if you use FIELD_PREP and FIELD_GET then
> > RTL8211F_LEDCR_SHIFT can be removed.
>
> FIELD_PREP/FIELD_GET only works for constant mask, in this case the mask is
> not constant but shifted by SHIFT*index .
>
> Other drivers introduce workarounds like this for exactly this issue:
>
> drivers/clk/at91/pmc.h:#define field_prep(_mask, _val) (((_val) <<
> (ffs(_mask) - 1)) & (_mask))
>
> I don't think it is worth perpetuating that.
Thanks Marek,
Sorry for missing that the mask is not constant.
And in that case I agree with the approach you have taken in this patch.
Powered by blists - more mailing lists