Index: sys/dev/etherswitch/e6000sw/e6000sw.c =================================================================== --- sys/dev/etherswitch/e6000sw/e6000sw.c +++ sys/dev/etherswitch/e6000sw/e6000sw.c @@ -45,8 +45,8 @@ #include #include -#include #include +#include #include "e6000swreg.h" #include "etherswitch_if.h" @@ -187,7 +187,6 @@ static void e6000sw_identify(driver_t *driver, device_t parent) { - if (device_find_child(parent, "e6000sw", -1) == NULL) BUS_ADD_CHILD(parent, 0, "e6000sw", -1); } @@ -197,15 +196,17 @@ { e6000sw_softc_t *sc; const char *description; - phandle_t dsa_node, switch_node; + phandle_t switch_node; - dsa_node = fdt_find_compatible(OF_finddevice("/"), - "marvell,dsa", 0); - switch_node = OF_child(dsa_node); + switch_node = ofw_bus_find_compatible(OF_finddevice("/"), + "marvell,mv88e6085"); if (switch_node == 0) return (ENXIO); + if (bootverbose) + device_printf(dev, "Found switch_node: 0x%x\n", switch_node); + sc = device_get_softc(dev); sc->dev = dev; sc->node = switch_node; @@ -214,8 +215,12 @@ sizeof(sc->sw_addr)) < 0) return (ENXIO); - if (!OF_hasprop(sc->node, "single-chip-addressing") && - (sc->sw_addr != 0 && (sc->sw_addr % 2) == 0)) + /* + * According to the Linux source code, all of the Switch IDs we support + * are multi_chip capable, and should go into multi-chip mode if the + * sw_addr != 0. + */ + if (!OF_hasprop(sc->node, "single-chip-addressing") && sc->sw_addr != 0) sc->multi_chip = true; /* @@ -264,9 +269,9 @@ static int e6000sw_parse_child_fdt(e6000sw_softc_t *sc, phandle_t child, int *pport) { - char *name, *portlabel; + char *portlabel; int speed; - phandle_t fixed_link; + phandle_t fixed_link, switch_eth, switch_eth_handle; uint32_t port; if (pport == NULL) @@ -287,23 +292,31 @@ free(portlabel, M_OFWPROP); } - fixed_link = OF_child(child); - if (fixed_link != 0 && - OF_getprop_alloc(fixed_link, "name", (void **)&name) > 0) { - if (strncmp(name, "fixed-link", 10) == 0) { - /* Assume defaults: 1g - full-duplex. */ - sc->fixed_mask |= (1 << port); - if (OF_getencprop(fixed_link, "speed", &speed, - sizeof(speed)) > 0) { - if (speed == 2500 && - (MVSWITCH(sc, MV88E6141) || - MVSWITCH(sc, MV88E6341))) { - sc->fixed25_mask |= (1 << port); + if (OF_getencprop(child, "ethernet", (void*)&switch_eth_handle, + sizeof(switch_eth_handle)) > 0) { + if (switch_eth_handle > 0) { + switch_eth = OF_node_from_xref(switch_eth_handle); + + fixed_link = ofw_bus_find_child(switch_eth, + "fixed-link"); + + if (fixed_link != 0) { + sc->fixed_mask |= (1 << port); + if (OF_getencprop(fixed_link, "speed", &speed, + sizeof(speed)) > 0) { + if (speed == 2500 && + (MVSWITCH(sc, MV88E6141) || + MVSWITCH(sc, MV88E6341))) { + sc->fixed25_mask |= (1 << port); + } } } - } - free(name, M_OFWPROP); + } else + device_printf(sc->dev, + "Port %d has ethernet property but it points " + "to an invalid location\n", port); } + if ((sc->fixed_mask & (1 << port)) != 0) device_printf(sc->dev, "fixed port at %d\n", port); else @@ -354,7 +367,7 @@ e6000sw_attach(device_t dev) { e6000sw_softc_t *sc; - phandle_t child; + phandle_t child, ports; int err, port; uint32_t reg; @@ -371,7 +384,9 @@ E6000SW_LOCK(sc); e6000sw_setup(dev, sc); - for (child = OF_child(sc->node); child != 0; child = OF_peer(child)) { + ports = ofw_bus_find_child(sc->node, "ports"); + + for (child = OF_child(ports); child != 0; child = OF_peer(child)) { err = e6000sw_parse_child_fdt(sc, child, &port); if (err != 0) { device_printf(sc->dev, "failed to parse DTS\n"); Index: sys/dev/neta/if_mvneta.c =================================================================== --- sys/dev/neta/if_mvneta.c +++ sys/dev/neta/if_mvneta.c @@ -414,20 +414,35 @@ STATIC boolean_t mvneta_has_switch(device_t self) { - phandle_t node, switch_node, switch_eth, switch_eth_handle; + phandle_t node, switch_node, switch_eth, switch_eth_handle, ports, child; node = ofw_bus_get_node(self); - switch_node = - ofw_bus_find_compatible(OF_finddevice("/"), "marvell,dsa"); + /* XXX: We need a better way to find out if we are refenced by any + * switches, since I doubt the mv88e6058 is the only one, but I have no + * idea how + */ + switch_node = ofw_bus_find_compatible(OF_finddevice("/"), + "marvell,mv88e6085"); switch_eth = 0; - OF_getencprop(switch_node, "dsa,ethernet", - (void*)&switch_eth_handle, sizeof(switch_eth_handle)); + if (switch_node == 0) { + return false; + } + + ports = ofw_bus_find_child(switch_node, "ports"); - if (switch_eth_handle > 0) - switch_eth = OF_node_from_xref(switch_eth_handle); + for (child = OF_child(ports); child != 0; child = OF_peer(child)) { + if (OF_getencprop(child, "ethernet", (void*)&switch_eth_handle, + sizeof(switch_eth_handle)) > 0) { + if (switch_eth_handle > 0) { + switch_eth = OF_node_from_xref( + switch_eth_handle); + break; + } + } + } - /* Return true if dsa,ethernet cell points to us */ + /* Return true if ethernet cell points to us */ return (node == switch_eth); } @@ -799,6 +814,8 @@ if_link_state_change(sc->ifp, LINK_STATE_UP); if (mvneta_has_switch(self)) { + if (bootverbose) + device_printf(self, "This device is attached to a switch\n"); child = device_add_child(sc->dev, "mdio", -1); if (child == NULL) { ether_ifdetach(sc->ifp); @@ -807,6 +824,8 @@ } bus_generic_attach(sc->dev); bus_generic_attach(child); + } else if (bootverbose) { + device_printf(self, "This device is not attached to a switch\n"); } /* Configure MAC media */