Commit 774ec60b74a7b8d356a2ec6249936b097631a726
Committed by
Stefano Babic
1 parent
b2ca8907d9
Exists in
smarc_8mq_lf_v2020.04
and in
11 other branches
Enable FEC driver to retrieve PHY address from device tree
Currently if we have more than one phy on the MDIO bus, we do not have a good mechanism for determining which should be used at runtime. Enable the FEC driver to determine the address for the PHY from the device tree. Signed-off-by: Martyn Welch <martyn.welch@collabora.com> Reviewed-by: Lukasz Majewski <lukma@denx.de>
Showing 1 changed file with 21 additions and 0 deletions Side-by-side Diff
drivers/net/fec_mxc.c
... | ... | @@ -1264,10 +1264,31 @@ |
1264 | 1264 | .read_rom_hwaddr = fecmxc_read_rom_hwaddr, |
1265 | 1265 | }; |
1266 | 1266 | |
1267 | +static int device_get_phy_addr(struct udevice *dev) | |
1268 | +{ | |
1269 | + struct ofnode_phandle_args phandle_args; | |
1270 | + int reg; | |
1271 | + | |
1272 | + if (dev_read_phandle_with_args(dev, "phy-handle", NULL, 0, 0, | |
1273 | + &phandle_args)) { | |
1274 | + debug("Failed to find phy-handle"); | |
1275 | + return -ENODEV; | |
1276 | + } | |
1277 | + | |
1278 | + reg = ofnode_read_u32_default(phandle_args.node, "reg", 0); | |
1279 | + | |
1280 | + return reg; | |
1281 | +} | |
1282 | + | |
1267 | 1283 | static int fec_phy_init(struct fec_priv *priv, struct udevice *dev) |
1268 | 1284 | { |
1269 | 1285 | struct phy_device *phydev; |
1286 | + int addr; | |
1270 | 1287 | int mask = 0xffffffff; |
1288 | + | |
1289 | + addr = device_get_phy_addr(dev); | |
1290 | + if (addr >= 0) | |
1291 | + mask = 1 << addr; | |
1271 | 1292 | |
1272 | 1293 | #ifdef CONFIG_FEC_MXC_PHYADDR |
1273 | 1294 | mask = 1 << CONFIG_FEC_MXC_PHYADDR; |
-
mentioned in merge request !2