mdio is a child node of the switch, see example:

  switch: switch@1fb58000 {
    compatible = "airoha,en7581-switch";
    reg = <0 0x1fb58000 0 0x8000>;

    mdio: mdio {
      #address-cells = <1>;
      #size-cells = <0>;
    };
  };

so to get a switch base address, we need to lookup for a parent node

Signed-off-by: Mikhail Kshevetskiy <[email protected]>
---
 drivers/net/mdio-mt7531-mmio.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/net/mdio-mt7531-mmio.c b/drivers/net/mdio-mt7531-mmio.c
index 3e325ca58da..5a0725010f2 100644
--- a/drivers/net/mdio-mt7531-mmio.c
+++ b/drivers/net/mdio-mt7531-mmio.c
@@ -151,8 +151,13 @@ static const struct mdio_ops mt7531_mdio_ops = {
 static int mt7531_mdio_probe(struct udevice *dev)
 {
        struct mt7531_mdio_priv *priv = dev_get_priv(dev);
+       ofnode switch_node;
 
-       priv->switch_regs = dev_read_addr(dev);
+       switch_node = ofnode_get_parent(dev_ofnode(dev));
+       if (!ofnode_valid(switch_node))
+               return -EINVAL;
+
+       priv->switch_regs = ofnode_get_addr(switch_node);
        if (priv->switch_regs == FDT_ADDR_T_NONE)
                return -EINVAL;
 
-- 
2.51.0

Reply via email to