mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Marek Vasut <marex@denx.de>
To: Simon Horman <horms@kernel.org>
Cc: netdev@vger.kernel.org,
	Alexandre Torgue <alexandre.torgue@foss.st.com>,
	Andrew Lunn <andrew@lunn.ch>,
	Christophe Roullier <christophe.roullier@foss.st.com>,
	"David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Heiner Kallweit <hkallweit1@gmail.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Russell King <linux@armlinux.org.uk>,
	kernel@dh-electronics.com, linux-kernel@vger.kernel.org
Subject: Re: [net-next,PATCH v2] net: phy: realtek: Add support for PHY LEDs on RTL8211F
Date: Fri, 28 Jun 2024 20:58:51 +0200	[thread overview]
Message-ID: <a7f614cd-fe39-4746-8a83-2a2d14fc46f4@denx.de> (raw)
In-Reply-To: <20240628142742.GH783093@kernel.org>

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@denx.de>
>> ---
>> Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>
>> Cc: Andrew Lunn <andrew@lunn.ch>
>> Cc: Christophe Roullier <christophe.roullier@foss.st.com>
>> Cc: David S. Miller <davem@davemloft.net>
>> Cc: Eric Dumazet <edumazet@google.com>
>> Cc: Heiner Kallweit <hkallweit1@gmail.com>
>> Cc: Jakub Kicinski <kuba@kernel.org>
>> Cc: Paolo Abeni <pabeni@redhat.com>
>> Cc: Russell King <linux@armlinux.org.uk>
>> Cc: kernel@dh-electronics.com
>> Cc: linux-kernel@vger.kernel.org
>> Cc: netdev@vger.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.

  reply	other threads:[~2024-06-28 19:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-25 20:42 Marek Vasut
2024-06-28 14:27 ` Simon Horman
2024-06-28 18:58   ` Marek Vasut [this message]
2024-06-29  9:16     ` Simon Horman
2024-07-01  8:40 ` patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a7f614cd-fe39-4746-8a83-2a2d14fc46f4@denx.de \
    --to=marex@denx.de \
    --cc=alexandre.torgue@foss.st.com \
    --cc=andrew@lunn.ch \
    --cc=christophe.roullier@foss.st.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hkallweit1@gmail.com \
    --cc=horms@kernel.org \
    --cc=kernel@dh-electronics.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®