aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Hibbits <jhibbits@FreeBSD.org>2022-11-28 22:03:15 +0000
committerJustin Hibbits <jhibbits@FreeBSD.org>2022-11-28 22:03:15 +0000
commit82abe70fe98aaece817e35ba99fcc4aea4181067 (patch)
tree2bfb75e5e5cc2ade8cee61aa57c8e524dbe064b0
parent69cc1630014b7c50f754f5d49cfd4ed2905a5c48 (diff)
downloadsrc-82abe70fe98aaece817e35ba99fcc4aea4181067.tar.gz
src-82abe70fe98aaece817e35ba99fcc4aea4181067.zip
dpaa: Don't assume the MDIO is on the same fman as the MAC
The P5040 has the MDIO for FMAN2 on FMAN1 for some reason. Instead of trying to manually find the MDIO, use a real xref.
-rw-r--r--sys/dev/dpaa/fman_mdio.c2
-rw-r--r--sys/dev/dpaa/if_dtsec_fdt.c46
2 files changed, 17 insertions, 31 deletions
diff --git a/sys/dev/dpaa/fman_mdio.c b/sys/dev/dpaa/fman_mdio.c
index 28ade4e3b315..ee90ba0b9cf9 100644
--- a/sys/dev/dpaa/fman_mdio.c
+++ b/sys/dev/dpaa/fman_mdio.c
@@ -134,6 +134,8 @@ pqmdio_fdt_attach(device_t dev)
bus_get_resource(dev, SYS_RES_MEMORY, 0, &start, &count);
sc->sc_offset = start;
+ OF_device_register_xref(OF_xref_from_node(ofw_bus_get_node(dev)), dev);
+
mtx_init(&sc->sc_lock, device_get_nameunit(dev), "QorIQ MDIO lock",
MTX_DEF);
diff --git a/sys/dev/dpaa/if_dtsec_fdt.c b/sys/dev/dpaa/if_dtsec_fdt.c
index 179d620fcc3b..4bb96fa74f09 100644
--- a/sys/dev/dpaa/if_dtsec_fdt.c
+++ b/sys/dev/dpaa/if_dtsec_fdt.c
@@ -112,32 +112,10 @@ dtsec_fdt_probe(device_t dev)
}
static int
-find_mdio(phandle_t phy_node, device_t mac, device_t *mdio_dev)
-{
- device_t bus;
-
- while (phy_node > 0) {
- if (ofw_bus_node_is_compatible(phy_node, "fsl,fman-mdio"))
- break;
- phy_node = OF_parent(phy_node);
- }
-
- if (phy_node <= 0)
- return (ENOENT);
-
- bus = device_get_parent(mac);
- *mdio_dev = ofw_bus_find_child_device_by_phandle(bus, phy_node);
-
- if (*mdio_dev == NULL)
- return (ENOENT);
-
- return (0);
-}
-
-static int
dtsec_fdt_attach(device_t dev)
{
struct dtsec_softc *sc;
+ device_t phy_dev;
phandle_t enet_node, phy_node;
phandle_t fman_rxtx_node[2];
char phy_type[6];
@@ -162,24 +140,30 @@ dtsec_fdt_attach(device_t dev)
else
return(ENXIO);
- /* Get MAC memory offset in SoC */
- rid = 0;
- sc->sc_mem = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE);
- if (sc->sc_mem == NULL)
- return (ENXIO);
-
/* Get PHY address */
if (OF_getprop(enet_node, "phy-handle", (void *)&phy_node,
sizeof(phy_node)) <= 0)
return (ENXIO);
- phy_node = OF_instance_to_package(phy_node);
+ phy_node = OF_node_from_xref(phy_node);
if (OF_getprop(phy_node, "reg", (void *)&sc->sc_phy_addr,
sizeof(sc->sc_phy_addr)) <= 0)
return (ENXIO);
- if (find_mdio(phy_node, dev, &sc->sc_mdio) != 0)
+ phy_dev = OF_device_from_xref(OF_parent(phy_node));
+
+ if (phy_dev == NULL) {
+ device_printf(dev, "No PHY found.\n");
+ return (ENXIO);
+ }
+
+ sc->sc_mdio = phy_dev;
+
+ /* Get MAC memory offset in SoC */
+ rid = 0;
+ sc->sc_mem = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE);
+ if (sc->sc_mem == NULL)
return (ENXIO);
/* Get PHY connection type */