net: phy: mxl-gpy: correctly describe LED polarity

According the datasheet covering the LED (0x1b) register:
0B Active High LEDx pin driven high when activated
1B Active Low LEDx pin driven low when activated

Make use of the now available 'active-high' property and correctly
reflect the polarity setting which was previously inverted.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Link: https://patch.msgid.link/180ccafa837f09908b852a8a874a3808c5ecd2d0.1728558223.git.daniel@makrotopia.org
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
This commit is contained in:
Daniel Golle 2024-10-10 13:55:17 +01:00 committed by Paolo Abeni
parent 9d55e68b19
commit eb89c79c1b

View File

@ -989,7 +989,7 @@ static int gpy_led_hw_control_set(struct phy_device *phydev, u8 index,
static int gpy_led_polarity_set(struct phy_device *phydev, int index, static int gpy_led_polarity_set(struct phy_device *phydev, int index,
unsigned long modes) unsigned long modes)
{ {
bool active_low = false; bool force_active_low = false, force_active_high = false;
u32 mode; u32 mode;
if (index >= GPY_MAX_LEDS) if (index >= GPY_MAX_LEDS)
@ -998,15 +998,23 @@ static int gpy_led_polarity_set(struct phy_device *phydev, int index,
for_each_set_bit(mode, &modes, __PHY_LED_MODES_NUM) { for_each_set_bit(mode, &modes, __PHY_LED_MODES_NUM) {
switch (mode) { switch (mode) {
case PHY_LED_ACTIVE_LOW: case PHY_LED_ACTIVE_LOW:
active_low = true; force_active_low = true;
break;
case PHY_LED_ACTIVE_HIGH:
force_active_high = true;
break; break;
default: default:
return -EINVAL; return -EINVAL;
} }
} }
return phy_modify(phydev, PHY_LED, PHY_LED_POLARITY(index), if (force_active_low)
active_low ? 0 : PHY_LED_POLARITY(index)); return phy_set_bits(phydev, PHY_LED, PHY_LED_POLARITY(index));
if (force_active_high)
return phy_clear_bits(phydev, PHY_LED, PHY_LED_POLARITY(index));
unreachable();
} }
static struct phy_driver gpy_drivers[] = { static struct phy_driver gpy_drivers[] = {