kernel: backport some useful LED_FUNCTION_* defines for DT
[openwrt/openwrt.git] / target / linux / generic / backport-6.1 / 715-v6.9-02-net-phy-qcom-qca808x-default-to-LED-active-High-if-n.patch
1 From f203c8c77c7616c099647636f4c67d59a45fe8a2 Mon Sep 17 00:00:00 2001
2 From: Christian Marangi <ansuelsmth@gmail.com>
3 Date: Thu, 1 Feb 2024 14:46:01 +0100
4 Subject: [PATCH 2/2] net: phy: qcom: qca808x: default to LED active High if
5 not set
6
7 qca808x PHY provide support for the led_polarity_set OP to configure
8 and apply the active-low property but on PHY reset, the Active High bit
9 is not set resulting in the LED driven as active-low.
10
11 To fix this, check if active-low is not set in DT and enable Active High
12 polarity by default to restore correct funcionality of the LED.
13
14 Fixes: 7196062b64ee ("net: phy: at803x: add LED support for qca808x")
15 Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
16 Signed-off-by: David S. Miller <davem@davemloft.net>
17 ---
18 drivers/net/phy/qcom/qca808x.c | 10 ++++++++++
19 1 file changed, 10 insertions(+)
20
21 --- a/drivers/net/phy/qcom/qca808x.c
22 +++ b/drivers/net/phy/qcom/qca808x.c
23 @@ -290,8 +290,18 @@ static int qca808x_probe(struct phy_devi
24
25 static int qca808x_config_init(struct phy_device *phydev)
26 {
27 + struct qca808x_priv *priv = phydev->priv;
28 int ret;
29
30 + /* Default to LED Active High if active-low not in DT */
31 + if (priv->led_polarity_mode == -1) {
32 + ret = phy_set_bits_mmd(phydev, MDIO_MMD_AN,
33 + QCA808X_MMD7_LED_POLARITY_CTRL,
34 + QCA808X_LED_ACTIVE_HIGH);
35 + if (ret)
36 + return ret;
37 + }
38 +
39 /* Active adc&vga on 802.3az for the link 1000M and 100M */
40 ret = phy_modify_mmd(phydev, MDIO_MMD_PCS, QCA808X_PHY_MMD3_ADDR_CLD_CTRL7,
41 QCA808X_8023AZ_AFE_CTRL_MASK, QCA808X_8023AZ_AFE_EN);