net: phy: qca808x: handle the active-high LED polarity mode
Subsystems (5)
PATCH v2 1/1 net: phy: qca808x: handle the active-high LED polarity mode
Commit a274465cc3be ("net: phy: support 'active-high' property for PHY LEDs") added PHY_LED_ACTIVE_HIGH but did not cover qca808x, so qca808x_led_polarity_set() returns -EINVAL for it. phy_probe() propagates that, leaving the mdio device unbound and phy_attach_direct() falling back to the genphy driver.
Accepting the mode alone is not enough: led_polarity_mode records active_low, so an explicit 'active-high' node stores 0, while qca808x_config_init() re-asserts QCA808X_LED_ACTIVE_HIGH only for -1. The bit does not survive the reset phy_init_hw() runs first, so the LED would come up active-low.
An 'active-low' node needs nothing here: the bit is clear after the reset, which is the polarity it asks for.
---
v2:
- No code change. Rebased onto net/main.
- Cc Rosen Penev and Christian Marangi, per Andrew Lunn -- they may have QCA808x hardware. Christian wrote f203c8c77c76 ("net: phy: qcom:
qca808x: default to LED active High if not set"), the default this patch extends. If either of you can put an 'active-high' LED node on
a QCA8081 and confirm the LED comes up the right way round, I would appreciate it.
- Say why an 'active-low' node needs nothing in qca808x_config_init().
v1: https://lore.kernel.org/netdev/[email protected]/
- Supersedes [PATCH net v3 3/3], [email protected], whose
Reviewed-by from Andrew Lunn is dropped: that version only accepted
the mode, this one also makes it survive the reset.
Compile-tested only (W=1, sparse). I have no QCA808x hardware, and there is no KUnit suite or MDIO mock under drivers/net/phy to exercise the MMD7 write without it.
drivers/net/phy/qcom/qca808x.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/net/phy/qcom/qca808x.c +5 -2
@@ -200,8 +200,8 @@ static int qca808x_config_init(struct phy_device *phydev)struct qca808x_priv *priv = phydev->priv;int ret; -/* Default to LED Active High if active-low not in DT */ -if (priv->led_polarity_mode ==-1 ) { +/* Set LED Active High unless active-low was requested in DT */ +if (priv->led_polarity_mode !=1 ) { ret =phy_set_bits_mmd (phydev,MDIO_MMD_AN ,QCA808X_MMD7_LED_POLARITY_CTRL ,QCA808X_LED_ACTIVE_HIGH );
@@ -603,6 +603,9 @@ static int qca808x_led_polarity_set(struct phy_device *phydev, int index,case PHY_LED_ACTIVE_LOW : active_low = true;break ; +case PHY_LED_ACTIVE_HIGH : + active_low = false; +break ;default :return -EINVAL ; }
base-commit: e6b6078ea1731b05b3b552497b3bce4bf8b014ae
Signature · 1 line
2.53.0
Quoted 22 lines · Donggeun Yoo
Commit
a274465cc3be("net: phy: support 'active-high' property for PHY LEDs") addedPHY_LED_ACTIVE_HIGHbut did not cover qca808x, soqca808x_led_polarity_set()returns-EINVALfor it.phy_probe()propagates that, leaving the mdio device unbound andphy_attach_direct()falling back to the genphy driver.Accepting the mode alone is not enough:
led_polarity_moderecordsactive_low, so an explicit 'active-high' node stores 0, whileqca808x_config_init()re-assertsQCA808X_LED_ACTIVE_HIGHonly for -1. The bit does not survive the resetphy_init_hw()runs first, so the LED would come up active-low.An 'active-low' node needs nothing here: the bit is clear after the reset, which is the polarity it asks for.
Reported-by Sashiko <[email protected]>Fixes a274465cc3be ("net: phy: support 'active-high' property for PHY LEDs")Signed-off-by Donggeun Yoo <[email protected]>Assisted-by Claude:claude-fable-5 sparse
Quoted 5 lines
---
v2:
- No code change. Rebased onto net/main.
- Cc Rosen Penev and Christian Marangi, per Andrew Lunn -- they may have QCA808x hardware.
In my case, qca8k controls the LEDs. I don't think I have any devices that control LEDs through qca808x.
Quoted 49 lines
Christian wrote
f203c8c77c76("net: phy: qcom:
qca808x: default to LED active High if not set"), the default this patch extends. If either of you can put an 'active-high' LED node on
a QCA8081 and confirm the LED comes up the right way round, I would appreciate it.
- Say why an 'active-low' node needs nothing inqca808x_config_init().
v1: https://lore.kernel.org/netdev/[email protected]/
- Supersedes [PATCH net v3 3/3], [email protected], whose
Reviewed-by from Andrew Lunn is dropped: that version only accepted
the mode, this one also makes it survive the reset.Compile-tested only (W=1, sparse). I have no QCA808x hardware, and there is no KUnit suite or MDIO mock under
drivers/net/phyto exercise the MMD7 write without it.drivers/net/phy/qcom/qca808x.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)drivers/net/phy/qcom/qca808x.c +5
-2@@ -200,8 +200,8 @@ static int qca808x_config_init(struct phy_device *phydev)struct qca808x_priv *priv = phydev->priv;int ret; -/* Default to LED Active High if active-low not in DT */ -if (priv->led_polarity_mode ==-1 ) { +/* Set LED Active High unless active-low was requested in DT */ +if (priv->led_polarity_mode !=1 ) { ret =phy_set_bits_mmd (phydev,MDIO_MMD_AN ,QCA808X_MMD7_LED_POLARITY_CTRL ,QCA808X_LED_ACTIVE_HIGH );@@ -603,6 +603,9 @@ static int qca808x_led_polarity_set(struct phy_device *phydev, int index,case PHY_LED_ACTIVE_LOW : active_low = true;break ; +case PHY_LED_ACTIVE_HIGH : + active_low = false; +break ;default :return -EINVAL ; }base-commit:
e6b6078ea1731b05b3b552497b3bce4bf8b014ae--
2.53.0
Il giorno lun 14 set 2026 alle ore 23:47 Donggeun Yoo <[email protected]> ha scritto:
Quoted 7 lines
Commit
a274465cc3be("net: phy: support 'active-high' property for PHY LEDs") addedPHY_LED_ACTIVE_HIGHbut did not cover qca808x, soqca808x_led_polarity_set()returns-EINVALfor it.phy_probe()propagates that, leaving the mdio device unbound andphy_attach_direct()falling back to the genphy driver.
Quoted 9 lines
Accepting the mode alone is not enough:
led_polarity_moderecordsactive_low, so an explicit 'active-high' node stores 0, whileqca808x_config_init()re-assertsQCA808X_LED_ACTIVE_HIGHonly for -1. The bit does not survive the resetphy_init_hw()runs first, so the LED would come up active-low.An 'active-low' node needs nothing here: the bit is clear after the reset, which is the polarity it asks for.
The commit description looks a bit "dense" and took me well 2-3 minutes to parse the english and understand the change. Was also the commit description assisted by LLM?
Anyway more comments below for the patch.
Quoted 34 lines
Reported-by Sashiko <[email protected]>Fixes a274465cc3be ("net: phy: support 'active-high' property for PHY LEDs")Signed-off-by Donggeun Yoo <[email protected]>Assisted-by Claude:claude-fable-5 sparse---
v2:
- No code change. Rebased onto net/main.
- Cc Rosen Penev and Christian Marangi, per Andrew Lunn -- they may have QCA808x hardware. Christian wrotef203c8c77c76("net: phy: qcom:
qca808x: default to LED active High if not set"), the default this patch extends. If either of you can put an 'active-high' LED node on
a QCA8081 and confirm the LED comes up the right way round, I would appreciate it.
- Say why an 'active-low' node needs nothing inqca808x_config_init().
v1: https://lore.kernel.org/netdev/[email protected]/
- Supersedes [PATCH net v3 3/3], [email protected], whose
Reviewed-by from Andrew Lunn is dropped: that version only accepted
the mode, this one also makes it survive the reset.Compile-tested only (W=1, sparse). I have no QCA808x hardware, and there is no KUnit suite or MDIO mock under
drivers/net/phyto exercise the MMD7 write without it.drivers/net/phy/qcom/qca808x.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)drivers/net/phy/qcom/qca808x.c +0
-0
drivers/net/phy/qcom/qca808x.c static int qca808x_config_init(struct phy_device *phydev) · line 203
Quoted 6 lines
drivers/net/phy/qcom/qca808x.c +1
-2@@ -200,8 +200,8 @@ static int qca808x_config_init(struct phy_device *phydev)struct qca808x_priv *priv = phydev->priv;int ret; -/* Default to LED Active High if active-low not in DT */ -if (priv->led_polarity_mode ==-1 ) { +/* Set LED Active High unless active-low was requested in DT */
Why the comment was changed if it does say exactly the same thing?
drivers/net/phy/qcom/qca808x.c static int qca808x_config_init(struct phy_device *phydev) · line 204
Quoted 1 line
drivers/net/phy/qcom/qca808x.c +1
-0+if (priv->led_polarity_mode !=1 ) {
This change is O.K but I would ask you to better clarify this. -1, 0 and 1 is very confusing here.
I would introduce a simple define like
#define QCA808X_PHY_LED_UNSET -1
And set this in probe and change the condition here to directly check for the macro PHY_LED_ACTIVE_LOW.
drivers/net/phy/qcom/qca808x.c static int qca808x_led_polarity_set(struct phy_device *phydev, int index, · line 608
Quoted 10 lines
drivers/net/phy/qcom/qca808x.c +3
-0ret =phy_set_bits_mmd (phydev,MDIO_MMD_AN ,QCA808X_MMD7_LED_POLARITY_CTRL ,QCA808X_LED_ACTIVE_HIGH );@@ -603,6 +603,9 @@ static int qca808x_led_polarity_set(struct phy_device *phydev, int index,case PHY_LED_ACTIVE_LOW : active_low = true;break ; +case PHY_LED_ACTIVE_HIGH : + active_low = false; +break ;
The ACTIVE_HIGH wasn't a thing when this was introduced if I'm not wrong. Anyway this change looks good. The only problem is that I feel it would be better to split this patch in 2 different commits.
This really addresses 2 different problems and splitting also makes the commit description easier to understand.
One doesn't account the case where phy is reset, the other doesn't account the mode in led_polarity set.
Quoted 4 lines
drivers/net/phy/qcom/qca808x.c +0
-0default :return -EINVAL ; }
Quoted 3 lines · Christian Marangi (Ansuel)
The commit description looks a bit "dense" and took me well 2-3 minutes to parse the english and understand the change. Was also the commit description assisted by LLM?
Yes, drafted with AI help - that is what the Assisted-by: trailer records - and reviewed carefully before sending. Which part cost you the most to get through? I would rather fix that than guess at it.
Quoted 4 lines
drivers/net/phy/qcom/qca808x.c static int qca808x_config_init(struct phy_device *phydev) · line 203
Quoted 2 lines
drivers/net/phy/qcom/qca808x.c +1
-1-/* Default to LED Active High if active-low not in DT */ +/* Set LED Active High unless active-low was requested in DT */ Why the comment was changed if it does say exactly the same thing?
Because after this patch it no longer does. Until now that branch ran only when DT said nothing about polarity, so "Default to" was exact. It now also runs when DT asks for active-high explicitly, and there the driver is following an instruction rather than applying a default.
Quoted 8 lines
This change is O.K but I would ask you to better clarify this. -1, 0 and 1 is very confusing here.
I would introduce a simple define like
#defineQCA808X_PHY_LED_UNSET-1And set this in probe and change the condition here to directly check for the macro
PHY_LED_ACTIVE_LOW.
Done in v3. The >= 0 test in qca808x_led_polarity_set() took the define too.
Quoted 8 lines
The only problem is that I feel it would be better to split this patch in 2 different commits.
This really addresses 2 different problems and splitting also makes the commit description easier to understand.
One doesn't account the case where phy is reset, the other doesn't account the mode in
led_polarityset.
Agreed, and v3 is split that way:
1/2 qca808x_led_polarity_set(): accept PHY_LED_ACTIVE_HIGH, so the PHY
binds at all.
2/2 qca808x_config_init(): re-assert the bit for an explicit
active-high, carrying QCA808X_PHY_LED_UNSET and the comment.
Both Fixes: a274465cc3be and Cc: stable, so they backport together. After 1/2 alone an 'active-high' node binds and the LED comes up active-low, which is still ahead of today, where led_polarity_set() returns -EINVAL, phy_probe() fails and the PHY falls back to genphy.
It is no longer compile-tested only. I put a synthetic MDIO bus behind phylib that answers as a QCA8081 and emulates MMD7 0x901a, with the reset clearing BIT(6) as your f203c8c77c76 describes, and ran the same harness over all three arms:
DT node base 1/2 only 1/2 + 2/2 active-high -EINVAL inverted correct active-low correct correct correct no polarity node correct correct correct high-impedance -EINVAL -EINVAL -EINVAL
The middle column is the reason the second patch exists. A confirmation on a real QCA8081 would still be worth more than an emulated register, if you have one to hand.
v3: https://lore.kernel.org/netdev/[email protected]/
Thanks for the review.