summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/dev/usb/if_axe.c30
-rw-r--r--sys/dev/usb/if_axereg.h5
2 files changed, 33 insertions, 2 deletions
diff --git a/sys/dev/usb/if_axe.c b/sys/dev/usb/if_axe.c
index 2a7c3f7d983..f1c683af957 100644
--- a/sys/dev/usb/if_axe.c
+++ b/sys/dev/usb/if_axe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_axe.c,v 1.129 2015/02/12 22:39:27 mpi Exp $ */
+/* $OpenBSD: if_axe.c,v 1.130 2015/05/17 02:44:38 canacar Exp $ */
/*
* Copyright (c) 2005, 2006, 2007 Jonathan Gray <jsg@openbsd.org>
@@ -575,6 +575,31 @@ axe_ax88178_init(struct axe_softc *sc)
axe_cmd(sc, AXE_CMD_RXCTL_WRITE, 0, 0, NULL);
}
+/* Read Ethernet Address from EEPROM if it is zero */
+void
+axe_ax88772b_nodeid(struct axe_softc *sc, u_char *eaddr)
+{
+ int i;
+ uint16_t val;
+
+ for (i = 0; i < ETHER_ADDR_LEN; i++) {
+ if (eaddr[i] != 0)
+ break;
+ }
+
+ /* We already have an ethernet address */
+ if (i != ETHER_ADDR_LEN)
+ return;
+
+ /* read from EEPROM */
+ for (i = 0; i < ETHER_ADDR_LEN/2; i++) {
+ axe_cmd(sc, AXE_CMD_SROM_READ, 0, AXE_EEPROM_772B_NODEID + i, &val);
+ val = ntohs(val);
+ *eaddr++ = (u_char)((val >> 8) & 0xff);
+ *eaddr++ = (u_char)(val & 0xff);
+ }
+}
+
void
axe_ax88772_init(struct axe_softc *sc)
{
@@ -761,6 +786,9 @@ axe_attach(struct device *parent, struct device *self, void *aux)
else
axe_cmd(sc, AXE_172_CMD_READ_NODEID, 0, 0, &eaddr);
+ if (sc->axe_flags & AX772B)
+ axe_ax88772b_nodeid(sc, eaddr);
+
/*
* Load IPG values
*/
diff --git a/sys/dev/usb/if_axereg.h b/sys/dev/usb/if_axereg.h
index 3af57ebfcd2..f7ec264e5af 100644
--- a/sys/dev/usb/if_axereg.h
+++ b/sys/dev/usb/if_axereg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_axereg.h,v 1.24 2013/05/31 15:20:49 yuo Exp $ */
+/* $OpenBSD: if_axereg.h,v 1.25 2015/05/17 02:44:38 canacar Exp $ */
/*
* Copyright (c) 1997, 1998, 1999, 2000-2003
@@ -187,6 +187,9 @@
#define AXE_CONFIG_NO 1
#define AXE_IFACE_IDX 0
+/* EEPROM Map */
+#define AXE_EEPROM_772B_NODEID 0x04
+
/*
* The interrupt endpoint is currently unused
* by the ASIX part.