diff options
author | Can Erkin Acar <canacar@cvs.openbsd.org> | 2015-05-17 02:44:39 +0000 |
---|---|---|
committer | Can Erkin Acar <canacar@cvs.openbsd.org> | 2015-05-17 02:44:39 +0000 |
commit | 18e7f73b9c21d699d87642497d669f2852f14f72 (patch) | |
tree | d015eae45f33bb37830bbf202ccbc4218a9f6d19 /sys/dev/usb/if_axe.c | |
parent | b898fc4540ce9cbde9d07f26544e56696949312f (diff) |
Read ethernet address from EEPROM on AX88772B based on FreeBSD
ok djm@ jsg@
Diffstat (limited to 'sys/dev/usb/if_axe.c')
-rw-r--r-- | sys/dev/usb/if_axe.c | 30 |
1 files changed, 29 insertions, 1 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 */ |