]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
net: sun8i-emac: Add support for active-low leds with internal PHY
authorPaul Kocialkowski <contact@paulk.fr>
Tue, 5 Aug 2025 17:48:27 +0000 (19:48 +0200)
committerAndre Przywara <andre.przywara@arm.com>
Mon, 27 Oct 2025 11:12:56 +0000 (11:12 +0000)
A device-tree property is already defined to indicate that the internal
PHY should be used with active-low leds, which corresponds to a
specific bit in the dedicated syscon register.

Add support for setting this bit when the property is present.

Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
drivers/net/sun8i_emac.c

index 6e95392b379b7f5443eff03c579dd886707d5c94..41c52f56d7a9b6df4dcd71dd868f0a521168aff1 100644 (file)
@@ -175,6 +175,7 @@ struct sun8i_eth_pdata {
        u32 reset_delays[3];
        int tx_delay_ps;
        int rx_delay_ps;
+       bool leds_active_low;
 };
 
 static int sun8i_mdio_read(struct mii_dev *bus, int addr, int devad, int reg)
@@ -298,6 +299,9 @@ static int sun8i_emac_set_syscon(struct sun8i_eth_pdata *pdata,
                reg |= priv->phyaddr << H3_EPHY_ADDR_SHIFT;
                reg |= H3_EPHY_CLK_SEL;
                reg |= H3_EPHY_SELECT;
+
+               if (pdata->leds_active_low)
+                       reg |= H3_EPHY_LED_POL;
        } else {
                reg |= H3_EPHY_SHUTDOWN;
        }
@@ -845,6 +849,10 @@ static int sun8i_emac_eth_of_to_plat(struct udevice *dev)
                printf("%s: Invalid RX delay value %d\n", __func__,
                       sun8i_pdata->rx_delay_ps);
 
+       sun8i_pdata->leds_active_low =
+               fdtdec_get_bool(gd->fdt_blob, dev_of_offset(dev),
+                               "allwinner,leds-active-low");
+
        if (fdtdec_get_bool(gd->fdt_blob, dev_of_offset(dev),
                            "snps,reset-active-low"))
                reset_flags |= GPIOD_ACTIVE_LOW;