From 4526ee77da78c287a3860ee9a8a484e9e34d09c7 Mon Sep 17 00:00:00 2001 From: Gianfranco Mariotti <gianfranco.mariotti@seco.com> Date: Fri, 24 May 2024 16:00:01 +0200 Subject: [PATCH] [DRIVER] dp83867: fix LED configuration set-up support Avoid erroneous discard of valid set-up configurations. --- drivers/net/phy/dp83867.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/drivers/net/phy/dp83867.c b/drivers/net/phy/dp83867.c index 9919627f699c2b..972015764d888b 100644 --- a/drivers/net/phy/dp83867.c +++ b/drivers/net/phy/dp83867.c @@ -521,13 +521,13 @@ static int dp83867_of_init(struct phy_device *phydev) } if(of_property_read_u32(of_node, "ti,leds-conf", &dp83867->leds_conf)) - dp83867->leds_conf = 0; + dp83867->leds_conf = -1; if(of_property_read_u32(of_node, "ti,leds-polarity", &dp83867->leds_polarity)) - dp83867->leds_polarity = 0; + dp83867->leds_polarity = -1; if(of_property_read_u32(of_node, "ti,gpio0-conf", &dp83867->gpio0_conf)) - dp83867->gpio0_conf = 0; + dp83867->gpio0_conf = -1; if (of_property_read_bool(of_node, "ti,max-output-impedance")) dp83867->io_impedance = DP83867_IO_MUX_CFG_IO_IMPEDANCE_MAX; @@ -697,24 +697,23 @@ static int dp83867_config_init(struct phy_device *phydev) if (ret) return ret; - /* LEDs */ - if(dp83867->gpio0_conf) { + /* GPIOs */ + if(dp83867->gpio0_conf != -1) { ret = phy_write_mmd(phydev, DP83867_DEVADDR, DP83867_GPIO_MUX_CTRL, dp83867->gpio0_conf); - if (ret) - return ret; + if (ret) + return ret; } - if(dp83867->leds_conf) { - ret = phy_write(phydev, DP83867_LEDCR1,dp83867->leds_conf); - if (ret) - return ret; + /* LEDs */ + if(dp83867->leds_conf != -1) { + ret = phy_write(phydev, DP83867_LEDCR1, dp83867->leds_conf); + if (ret) + return ret; } - if(dp83867->leds_polarity) { - val = phy_read(phydev, DP83867_LEDCR2); - val = val & ~(dp83867->leds_polarity); - ret = phy_write(phydev, DP83867_LEDCR2,val); - if (ret) - return ret; + if(dp83867->leds_polarity != -1) { + ret = phy_write(phydev, DP83867_LEDCR2, dp83867->leds_polarity); + if (ret) + return ret; } /* If rgmii mode with no internal delay is selected, we do NOT use -- GitLab