1 /* $NetBSD: booke_autoconf.c,v 1.3 2011/06/17 19:03:03 matt Exp $ */ 2 /*- 3 * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc. 4 * All rights reserved. 5 * 6 * This code is derived from software contributed to The NetBSD Foundation 7 * by Raytheon BBN Technologies Corp and Defense Advanced Research Projects 8 * Agency and which was developed by Matt Thomas of 3am Software Foundry. 9 * 10 * This material is based upon work supported by the Defense Advanced Research 11 * Projects Agency and Space and Naval Warfare Systems Center, Pacific, under 12 * Contract No. N66001-09-C-2073. 13 * Approved for Public Release, Distribution Unlimited 14 * 15 * Redistribution and use in source and binary forms, with or without 16 * modification, are permitted provided that the following conditions 17 * are met: 18 * 1. Redistributions of source code must retain the above copyright 19 * notice, this list of conditions and the following disclaimer. 20 * 2. Redistributions in binary form must reproduce the above copyright 21 * notice, this list of conditions and the following disclaimer in the 22 * documentation and/or other materials provided with the distribution. 23 * 24 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 25 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 26 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 27 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 28 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 32 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34 * POSSIBILITY OF SUCH DAMAGE. 35 */ 36 37 #include <sys/cdefs.h> 38 __KERNEL_RCSID(0, "$NetBSD: booke_autoconf.c,v 1.3 2011/06/17 19:03:03 matt Exp $"); 39 40 #include <sys/param.h> 41 #include <sys/conf.h> 42 #include <sys/cpu.h> 43 #include <sys/device.h> 44 #include <sys/systm.h> 45 46 #include <net/if.h> 47 #include <net/if_ether.h> 48 49 #include <powerpc/booke/cpuvar.h> 50 51 void 52 e500_device_register(device_t dev, void *aux) 53 { 54 device_t parent = device_parent(dev); 55 56 if (device_is_a(dev, "etsec") && device_is_a(parent, "cpunode")) { 57 /* Set the mac-addr of the on-chip Ethernet. */ 58 struct cpunode_attach_args *cna = aux; 59 60 if (cna->cna_locs.cnl_instance < 4) { 61 prop_data_t pd; 62 char prop_name[15]; 63 64 snprintf(prop_name, sizeof(prop_name), 65 "etsec%d-mac-addr", cna->cna_locs.cnl_instance); 66 67 pd = prop_dictionary_get(board_properties, prop_name); 68 if (pd == NULL) { 69 printf("WARNING: unable to get mac-addr " 70 "property from board properties\n"); 71 return; 72 } 73 if (prop_dictionary_set(device_properties(dev), 74 "mac-address", pd) == false) { 75 printf("WARNING: unable to set mac-addr " 76 "property for %s\n", device_xname(dev)); 77 } 78 } 79 return; 80 } 81 } 82