Message ID | 20240131075048.1092551-1-alexander.stein@ew.tq-group.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 447b80a9330ef2d9a94fc5a9bf35b6eac061f38b |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [net-next,RESEND,1/1] net: phy: dp83867: Add support for active-low LEDs | expand |
On Wed, Jan 31, 2024 at 08:50:48AM +0100, Alexander Stein wrote: > Add the led_polarity_set callback for setting LED polarity. > > Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Andrew
Hello: This patch was applied to netdev/net-next.git (main) by David S. Miller <davem@davemloft.net>: On Wed, 31 Jan 2024 08:50:48 +0100 you wrote: > Add the led_polarity_set callback for setting LED polarity. > > Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com> > --- > With the addition of LED polarity modes, PHY LEDs attached to this PHY can > be configured as active-low. > > [...] Here is the summary with links: - [net-next,RESEND,1/1] net: phy: dp83867: Add support for active-low LEDs https://git.kernel.org/netdev/net-next/c/447b80a9330e You are awesome, thank you!
diff --git a/drivers/net/phy/dp83867.c b/drivers/net/phy/dp83867.c index 5f08f9d38bd7a..4120385c5a79d 100644 --- a/drivers/net/phy/dp83867.c +++ b/drivers/net/phy/dp83867.c @@ -158,6 +158,7 @@ /* LED_DRV bits */ #define DP83867_LED_DRV_EN(x) BIT((x) * 4) #define DP83867_LED_DRV_VAL(x) BIT((x) * 4 + 1) +#define DP83867_LED_POLARITY(x) BIT((x) * 4 + 2) #define DP83867_LED_FN(idx, val) (((val) & 0xf) << ((idx) * 4)) #define DP83867_LED_FN_MASK(idx) (0xf << ((idx) * 4)) @@ -1152,6 +1153,26 @@ static int dp83867_led_hw_control_get(struct phy_device *phydev, u8 index, return 0; } +static int dp83867_led_polarity_set(struct phy_device *phydev, int index, + unsigned long modes) +{ + /* Default active high */ + u16 polarity = DP83867_LED_POLARITY(index); + u32 mode; + + for_each_set_bit(mode, &modes, __PHY_LED_MODES_NUM) { + switch (mode) { + case PHY_LED_ACTIVE_LOW: + polarity = 0; + break; + default: + return -EINVAL; + } + } + return phy_modify(phydev, DP83867_LEDCR2, + DP83867_LED_POLARITY(index), polarity); +} + static struct phy_driver dp83867_driver[] = { { .phy_id = DP83867_PHY_ID, @@ -1184,6 +1205,7 @@ static struct phy_driver dp83867_driver[] = { .led_hw_is_supported = dp83867_led_hw_is_supported, .led_hw_control_set = dp83867_led_hw_control_set, .led_hw_control_get = dp83867_led_hw_control_get, + .led_polarity_set = dp83867_led_polarity_set, }, }; module_phy_driver(dp83867_driver);
Add the led_polarity_set callback for setting LED polarity. Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com> --- With the addition of LED polarity modes, PHY LEDs attached to this PHY can be configured as active-low. Note1: This callback is only called if at least once bit of 'enum phy_led_modes' is set. This works only because active-high is default on this hardware. Note2: DP83867_SW_RESET in dp83867_phy_reset clears any previously set config. This needs to be addressed as well. Same for interface down/up cycle which might include a hardware reset as well. So LED config needs to be cached. But that's independent from this change. This is just a resend with target tree named in subject [1] https://lore.kernel.org/all/20240125203702.4552-4-ansuelsmth@gmail.com/ drivers/net/phy/dp83867.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)