Read the phy address from the device tree and use it to find the phy device if not found then search in the range of 0 to 31. --- freebsd/sys/dev/cadence/if_cgem.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)
diff --git a/freebsd/sys/dev/cadence/if_cgem.c b/freebsd/sys/dev/cadence/if_cgem.c index 689c3611..0aab0771 100644 --- a/freebsd/sys/dev/cadence/if_cgem.c +++ b/freebsd/sys/dev/cadence/if_cgem.c @@ -1217,6 +1217,27 @@ cgem_intr(void *arg) CGEM_UNLOCK(sc); } +#ifdef __rtems__ +static int +cgem_get_phyaddr(phandle_t node) +{ + phandle_t phy_node; + pcell_t phy_handle, phy_reg; + + if (OF_getencprop(node, "phy-handle", (void *)&phy_handle, + sizeof(phy_handle)) <= 0) + return (MII_PHY_ANY); + + phy_node = OF_node_from_xref(phy_handle); + + if (OF_getencprop(phy_node, "reg", (void *)&phy_reg, + sizeof(phy_reg)) <= 0) + return (MII_PHY_ANY); + + return (phy_reg); +} +#endif /* __rtems__ */ + /* Reset hardware. */ static void cgem_reset(struct cgem_softc *sc) @@ -2091,10 +2112,19 @@ cgem_attach(device_t dev) cgem_reset(sc); CGEM_UNLOCK(sc); +#ifdef __rtems__ + int phy_addr = cgem_get_phyaddr(node); +#endif /* __rtems__ */ + /* Attach phy to mii bus. */ err = mii_attach(dev, &sc->miibus, ifp, cgem_ifmedia_upd, cgem_ifmedia_sts, +#ifdef __rtems__ + BMSR_DEFCAPMASK, phy_addr, MII_OFFSET_ANY, 0); +#else /* __rtems__ */ BMSR_DEFCAPMASK, MII_PHY_ANY, MII_OFFSET_ANY, 0); +#endif /* __rtems__ */ + if (err) { device_printf(dev, "attaching PHYs failed\n"); cgem_detach(dev); -- 2.25.1 _______________________________________________ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel