]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
net: airoha: bind MDIO controller on Ethernet load
authorChristian Marangi <ansuelsmth@gmail.com>
Thu, 23 Oct 2025 17:07:45 +0000 (19:07 +0200)
committerJerome Forissier <jerome.forissier@linaro.org>
Mon, 1 Dec 2025 09:37:06 +0000 (10:37 +0100)
Bind MDIO controller on Ethernet Controller load. The Airoha AN7581 SoC
have an integrated Switch based on MT7531 (or more saying MT7988).

Attach it to the mdio node in the switch node to support scanning for
MDIO devices on the BUS with DM API.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
drivers/net/Kconfig
drivers/net/airoha_eth.c

index 544e302d600453153fffd09068e585b90a05efb7..f382a7752d5350d58b54d3775befb27f95528c17 100644 (file)
@@ -126,6 +126,7 @@ config AIROHA_ETH
        depends on ARCH_AIROHA
        select PHYLIB
        select DM_RESET
+       select MDIO_MT7531
        help
          This Driver support Airoha Ethernet QDMA Driver
          Say Y to enable support for the Airoha Ethernet QDMA.
index 3234d875887b99444d9ca9791b1f6ad10d8ff65a..046b677d78e328cb5a419ad450b4b092a843e729 100644 (file)
@@ -10,6 +10,7 @@
 
 #include <dm.h>
 #include <dm/devres.h>
+#include <dm/lists.h>
 #include <mapmem.h>
 #include <net.h>
 #include <regmap.h>
@@ -982,6 +983,36 @@ static int arht_eth_write_hwaddr(struct udevice *dev)
        return 0;
 }
 
+static int airoha_eth_bind(struct udevice *dev)
+{
+       ofnode switch_node, mdio_node;
+       struct udevice *mdio_dev;
+       int ret = 0;
+
+       if (!CONFIG_IS_ENABLED(MDIO_MT7531))
+               return 0;
+
+       switch_node = ofnode_by_compatible(ofnode_null(),
+                                          "airoha,en7581-switch");
+       if (!ofnode_valid(switch_node)) {
+               debug("Warning: missing switch node\n");
+               return 0;
+       }
+
+       mdio_node = ofnode_find_subnode(switch_node, "mdio");
+       if (!ofnode_valid(mdio_node)) {
+               debug("Warning: missing mdio node\n");
+               return 0;
+       }
+
+       ret = device_bind_driver_to_node(dev, "mt7531-mdio", "mdio",
+                                        mdio_node, &mdio_dev);
+       if (ret)
+               debug("Warning: failed to bind mdio controller\n");
+
+       return 0;
+}
+
 static const struct airoha_eth_soc_data en7523_data = {
        .xsi_rsts_names = en7523_xsi_rsts_names,
        .num_xsi_rsts = ARRAY_SIZE(en7523_xsi_rsts_names),
@@ -1018,6 +1049,7 @@ U_BOOT_DRIVER(airoha_eth) = {
        .id = UCLASS_ETH,
        .of_match = airoha_eth_ids,
        .probe = airoha_eth_probe,
+       .bind = airoha_eth_bind,
        .ops = &airoha_eth_ops,
        .priv_auto = sizeof(struct airoha_eth),
        .plat_auto = sizeof(struct eth_pdata),