freebsd/if_cgem: Fail probe for unterminated MII

When the MII bus is unterminated on unused interfaces, it results in PHY
read timeouts which manifest as spurious PHYs during the attach call.
Detect these timeouts during the probe so the device can be ignored.
This commit is contained in:
Kinsey Moore 2021-07-09 09:47:34 -05:00 committed by Joel Sherrill
parent b0c8153d54
commit 14576608a9

View File

@ -1953,6 +1953,25 @@ cgem_probe(device_t dev)
if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0)
return (ENXIO);
#else /* __rtems__ */
struct cgem_softc *sc = device_get_softc(dev);
int val, rid = 0;
/* Check for PHY read timeouts which indicate an unterminated MII bus */
sc->mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid,
RF_ACTIVE);
val = cgem_miibus_readreg(dev, 0, MII_BMSR);
if (val == -1) {
bus_release_resource(dev, SYS_RES_MEMORY, &rid,
sc->mem_res);
sc->mem_res = NULL;
return (ENXIO);
}
bus_release_resource(dev, SYS_RES_MEMORY, &rid,
sc->mem_res);
sc->mem_res = NULL;
#endif /* __rtems__ */
device_set_desc(dev, "Cadence CGEM Gigabit Ethernet Interface");