]> Git Repo - J-u-boot.git/blobdiff - drivers/net/fec_mxc.c
Enable FEC driver to retrieve PHY address from device tree
[J-u-boot.git] / drivers / net / fec_mxc.c
index 32fb34b79323dcabcf596cc892fdaf1d178d63f5..1a59026a62f82032a24438fd3fcea03428ada85b 100644 (file)
@@ -1264,11 +1264,32 @@ static const struct eth_ops fecmxc_ops = {
        .read_rom_hwaddr        = fecmxc_read_rom_hwaddr,
 };
 
+static int device_get_phy_addr(struct udevice *dev)
+{
+       struct ofnode_phandle_args phandle_args;
+       int reg;
+
+       if (dev_read_phandle_with_args(dev, "phy-handle", NULL, 0, 0,
+                                      &phandle_args)) {
+               debug("Failed to find phy-handle");
+               return -ENODEV;
+       }
+
+       reg = ofnode_read_u32_default(phandle_args.node, "reg", 0);
+
+       return reg;
+}
+
 static int fec_phy_init(struct fec_priv *priv, struct udevice *dev)
 {
        struct phy_device *phydev;
+       int addr;
        int mask = 0xffffffff;
 
+       addr = device_get_phy_addr(dev);
+       if (addr >= 0)
+               mask = 1 << addr;
+
 #ifdef CONFIG_FEC_MXC_PHYADDR
        mask = 1 << CONFIG_FEC_MXC_PHYADDR;
 #endif
This page took 0.026978 seconds and 4 git commands to generate.