From 124511af7716a0fed2a2f91fe0a0db5d43ff04f2 Mon Sep 17 00:00:00 2001 From: martin Date: Sun, 20 Apr 2014 10:06:08 +0000 Subject: [PATCH] Fetch the ethernet address from u-boot boardinfo and provide it as mac-address property for ethernet controllers. --- sys/arch/evbarm/cubie/cubie_machdep.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/sys/arch/evbarm/cubie/cubie_machdep.c b/sys/arch/evbarm/cubie/cubie_machdep.c index 4f4526774520..e5058247ab45 100644 --- a/sys/arch/evbarm/cubie/cubie_machdep.c +++ b/sys/arch/evbarm/cubie/cubie_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: cubie_machdep.c,v 1.17 2014/04/18 06:53:13 matt Exp $ */ +/* $NetBSD: cubie_machdep.c,v 1.18 2014/04/20 10:06:08 martin Exp $ */ /* * Machine dependent functions for kernel setup for TI OSK5912 board. @@ -125,7 +125,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cubie_machdep.c,v 1.17 2014/04/18 06:53:13 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cubie_machdep.c,v 1.18 2014/04/20 10:06:08 martin Exp $"); #include "opt_machdep.h" #include "opt_ddb.h" @@ -185,11 +185,13 @@ __KERNEL_RCSID(0, "$NetBSD: cubie_machdep.c,v 1.17 2014/04/18 06:53:13 matt Exp #include #include +#include BootConfig bootconfig; /* Boot config storage */ static char bootargs[MAX_BOOT_STRING]; char *boot_args = NULL; char *boot_file = NULL; +static uint8_t uboot_enaddr[ETHER_ADDR_LEN]; bool cubietruck_p; /* @@ -329,6 +331,8 @@ initarm(void *arg) printf("\nNetBSD/evbarm (cubie) booting ...\n"); #endif + const uint8_t *uboot_bootinfo = (void*)uboot_args[0]; + #ifdef BOOT_ARGS char mi_bootargs[] = BOOT_ARGS; parse_mi_bootargs(mi_bootargs); @@ -403,8 +407,16 @@ initarm(void *arg) (uboot_args[3] + KERNEL_BASE_VOFFSET); strlcpy(bootargs, args, sizeof(bootargs)); } + if (uboot_args[0] + && uboot_args[0] - AWIN_SDRAM_PBASE < ram_size) { + uboot_bootinfo = + (void*)(uboot_args[0] + KERNEL_BASE_VOFFSET); + } } + /* copy u-boot bootinfo ethernet address */ + memcpy(uboot_enaddr, uboot_bootinfo + 0x250, sizeof(uboot_enaddr)); + boot_args = bootargs; parse_mi_bootargs(boot_args); @@ -602,6 +614,12 @@ cubie_device_register(device_t self, void *aux) prop_dictionary_set_uint32(dict, "nc-i", 0x003fc03f); return; } + if (device_is_a(self, "awge") || device_is_a(self, "awe")) { + prop_data_t blob = + prop_data_create_data(uboot_enaddr, ETHER_ADDR_LEN); + prop_dictionary_set(dict, "mac-address", blob); + prop_object_release(blob); + } if (device_is_a(self, "ehci")) { return;