1 From a274465cc3bef2dfd9c9ea5100848dda0a8641e1 Mon Sep 17 00:00:00 2001
2 From: Daniel Golle <daniel@makrotopia.org>
3 Date: Thu, 10 Oct 2024 13:54:19 +0100
4 Subject: [PATCH 1/4] net: phy: support 'active-high' property for PHY LEDs
6 In addition to 'active-low' and 'inactive-high-impedance' also
7 support 'active-high' property for PHY LED pin configuration.
8 As only either 'active-high' or 'active-low' can be set at the
9 same time, WARN and return an error in case both are set.
11 Signed-off-by: Daniel Golle <daniel@makrotopia.org>
12 Reviewed-by: Andrew Lunn <andrew@lunn.ch>
13 Link: https://patch.msgid.link/91598487773d768f254d5faf06cf65b13e972f0e.1728558223.git.daniel@makrotopia.org
14 Signed-off-by: Paolo Abeni <pabeni@redhat.com>
16 drivers/net/phy/phy_device.c | 6 ++++++
17 include/linux/phy.h | 5 +++--
18 2 files changed, 9 insertions(+), 2 deletions(-)
20 --- a/drivers/net/phy/phy_device.c
21 +++ b/drivers/net/phy/phy_device.c
22 @@ -3220,11 +3220,17 @@ static int of_phy_led(struct phy_device
26 + if (of_property_read_bool(led, "active-high"))
27 + set_bit(PHY_LED_ACTIVE_HIGH, &modes);
28 if (of_property_read_bool(led, "active-low"))
29 set_bit(PHY_LED_ACTIVE_LOW, &modes);
30 if (of_property_read_bool(led, "inactive-high-impedance"))
31 set_bit(PHY_LED_INACTIVE_HIGH_IMPEDANCE, &modes);
33 + if (WARN_ON(modes & BIT(PHY_LED_ACTIVE_LOW) &&
34 + modes & BIT(PHY_LED_ACTIVE_HIGH)))
38 /* Return error if asked to set polarity modes but not supported */
39 if (!phydev->drv->led_polarity_set)
40 --- a/include/linux/phy.h
41 +++ b/include/linux/phy.h
42 @@ -872,8 +872,9 @@ struct phy_led {
44 /* Modes for PHY LED configuration */
46 - PHY_LED_ACTIVE_LOW = 0,
47 - PHY_LED_INACTIVE_HIGH_IMPEDANCE = 1,
48 + PHY_LED_ACTIVE_HIGH = 0,
49 + PHY_LED_ACTIVE_LOW = 1,
50 + PHY_LED_INACTIVE_HIGH_IMPEDANCE = 2,