summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2017-02-12 04:29:58 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2017-02-12 04:29:58 +0000
commit4b08de3d09c3269f2cad2b3b810091084b7f6083 (patch)
treef1d2b9a48e894f0562df5cc21fbb262d29f0bdbf /sys/dev
parentb90e23decf3f3b7709850dc2202c269d772825d4 (diff)
The videocore portion of the raspberry pi which boots the arm cores and
runs the mailbox interface knows about a MAC address that appears to be derived from a unique serial number along with the raspberry pi foundation oui. It modifies the device tree when booting to store the MAC address in /axi/usb/hub/ethernet/mac-address so fetch and use this value for the integrated smsc(4) Ethernet. A different smsc adapter plugged into one of the USB ports probes later with a different unit number and skips this path.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/usb/if_smsc.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/sys/dev/usb/if_smsc.c b/sys/dev/usb/if_smsc.c
index f3b89ebad91..f7dd7b5a021 100644
--- a/sys/dev/usb/if_smsc.c
+++ b/sys/dev/usb/if_smsc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_smsc.c,v 1.29 2017/01/22 10:17:39 dlg Exp $ */
+/* $OpenBSD: if_smsc.c,v 1.30 2017/02/12 04:29:57 jsg Exp $ */
/* $FreeBSD: src/sys/dev/usb/net/if_smsc.c,v 1.1 2012/08/15 04:03:55 gonzo Exp $ */
/*-
* Copyright (c) 2012
@@ -176,6 +176,32 @@ const struct cfattach smsc_ca = {
sizeof(struct smsc_softc), smsc_match, smsc_attach, smsc_detach,
};
+#if defined(__arm__) || defined(__arm64__)
+
+#include <dev/ofw/openfirm.h>
+
+void
+smsc_enaddr_OF(struct smsc_softc *sc)
+{
+ int node;
+
+ if (sc->sc_dev.dv_unit != 0)
+ return;
+
+ /*
+ * Get the Raspberry Pi MAC address from FDT
+ * also available via mailbox interface
+ */
+ if ((node = OF_finddevice("/axi/usb/hub/ethernet")) == -1)
+ return;
+
+ 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)
+#endif
+
int
smsc_read_reg(struct smsc_softc *sc, uint32_t off, uint32_t *data)
{
@@ -993,6 +1019,8 @@ smsc_attach(struct device *parent, struct device *self, void *aux)
sc->sc_ac.ac_enaddr[1] = (uint8_t)((mac_l >> 8) & 0xff);
sc->sc_ac.ac_enaddr[0] = (uint8_t)((mac_l) & 0xff);
}
+
+ smsc_enaddr_OF(sc);
printf("%s: address %s\n", sc->sc_dev.dv_xname,
ether_sprintf(sc->sc_ac.ac_enaddr));