Newer device trees for the Raspberry Pi have reorganized the usb part
of the tree. This makes sure we can find the MAC address in those
trees as well. Hopefully we can simplify this at some point when we
have phased out old firmware.
ok?
Index: dev/usb/if_smsc.c
===================================================================
RCS file: /cvs/src/sys/dev/usb/if_smsc.c,v
retrieving revision 1.30
diff -u -p -r1.30 if_smsc.c
--- dev/usb/if_smsc.c 12 Feb 2017 04:29:57 -0000 1.30
+++ dev/usb/if_smsc.c 29 Jul 2017 16:11:02 -0000
@@ -183,20 +183,36 @@ const struct cfattach smsc_ca = {
void
smsc_enaddr_OF(struct smsc_softc *sc)
{
+ char *device = "/axi/usb/hub/ethernet";
+ char prop[64];
int node;
if (sc->sc_dev.dv_unit != 0)
return;
/*
- * Get the Raspberry Pi MAC address from FDT
- * also available via mailbox interface
+ * Get the Raspberry Pi MAC address from FDT. This is all
+ * much more complicated than strictly needed since the
+ * firmware device tree keeps changing as drivers get
+ * upstreamed. Sigh.
+ *
+ * Ultimately this should just use the "ethernet0" alias and
+ * the "local-mac-address" property.
*/
- if ((node = OF_finddevice("/axi/usb/hub/ethernet")) == -1)
+
+ if ((node = OF_finddevice("/aliases")) == -1)
return;
+ if (OF_getprop(node, "ethernet0", prop, sizeof(prop)) > 0 ||
+ OF_getprop(node, "ethernet", prop, sizeof(prop)) > 0)
+ device = prop;
- OF_getprop(node, "mac-address", sc->sc_ac.ac_enaddr,
- sizeof(sc->sc_ac.ac_enaddr));
+ if ((node = OF_finddevice(device)) == -1)
+ return;
+ if (OF_getprop(node, "local-mac-address", sc->sc_ac.ac_enaddr,
+ sizeof(sc->sc_ac.ac_enaddr)) != sizeof(sc->sc_ac.ac_enaddr)) {
+ OF_getprop(node, "mac-address", sc->sc_ac.ac_enaddr,
+ sizeof(sc->sc_ac.ac_enaddr));
+ }
}
#else
#define smsc_enaddr_OF(x) do {} while(0)