Module Name: src Committed By: macallan Date: Thu Oct 8 17:55:58 UTC 2015
Modified Files: src/sys/arch/mips/ingenic: ingenic_dme.c Log Message: use the MAC address passed as a property if available instead of relying on u-boot to program it into the chip for us ( which it may not do if we're not netbooting ) To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/mips/ingenic/ingenic_dme.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/mips/ingenic/ingenic_dme.c diff -u src/sys/arch/mips/ingenic/ingenic_dme.c:1.1 src/sys/arch/mips/ingenic/ingenic_dme.c:1.2 --- src/sys/arch/mips/ingenic/ingenic_dme.c:1.1 Tue Mar 10 18:15:47 2015 +++ src/sys/arch/mips/ingenic/ingenic_dme.c Thu Oct 8 17:55:58 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: ingenic_dme.c,v 1.1 2015/03/10 18:15:47 macallan Exp $ */ +/* $NetBSD: ingenic_dme.c,v 1.2 2015/10/08 17:55:58 macallan Exp $ */ /*- * Copyright (c) 2015 Michael Lorenz @@ -27,7 +27,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ingenic_dme.c,v 1.1 2015/03/10 18:15:47 macallan Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ingenic_dme.c,v 1.2 2015/10/08 17:55:58 macallan Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -76,6 +76,7 @@ ingenic_dme_attach(device_t parent, devi { struct dme_softc *sc = device_private(self); struct apbus_attach_args *aa = aux; + prop_data_t eaddrprop; void *ih; static uint8_t enaddr[ETHER_ADDR_LEN]; int error; @@ -132,12 +133,21 @@ ingenic_dme_attach(device_t parent, devi goto fail; } - /* - * XXX grab MAC address set by uboot - * I'm not sure uboot will program the MAC address into the chip when - * not netbooting, so this needs to go away - */ - dme_read_c(sc, DM9000_PAB0, enaddr, 6); + eaddrprop = prop_dictionary_get(device_properties(self), "mac-address"); + + if (eaddrprop != NULL && prop_data_size(eaddrprop) == ETHER_ADDR_LEN) { + memcpy(enaddr, prop_data_data_nocopy(eaddrprop), + ETHER_ADDR_LEN); + aprint_debug_dev(self, "got MAC address!\n"); + } else { + /* + * XXX + * if we don't get the MAC address as a property we hope like + * hell that uboot programmed it into the network chip + */ + aprint_error_dev(self, "reading MAC address from chip\n"); + dme_read_c(sc, DM9000_PAB0, enaddr, 6); + } dme_attach(sc, enaddr); return; fail: