booke_autoconf.c revision 1.2
11.2Smatt/* $NetBSD: booke_autoconf.c,v 1.2 2011/01/18 01:02:52 matt Exp $ */ 21.2Smatt/*- 31.2Smatt * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc. 41.2Smatt * All rights reserved. 51.2Smatt * 61.2Smatt * This code is derived from software contributed to The NetBSD Foundation 71.2Smatt * by Raytheon BBN Technologies Corp and Defense Advanced Research Projects 81.2Smatt * Agency and which was developed by Matt Thomas of 3am Software Foundry. 91.2Smatt * 101.2Smatt * This material is based upon work supported by the Defense Advanced Research 111.2Smatt * Projects Agency and Space and Naval Warfare Systems Center, Pacific, under 121.2Smatt * Contract No. N66001-09-C-2073. 131.2Smatt * Approved for Public Release, Distribution Unlimited 141.2Smatt * 151.2Smatt * Redistribution and use in source and binary forms, with or without 161.2Smatt * modification, are permitted provided that the following conditions 171.2Smatt * are met: 181.2Smatt * 1. Redistributions of source code must retain the above copyright 191.2Smatt * notice, this list of conditions and the following disclaimer. 201.2Smatt * 2. Redistributions in binary form must reproduce the above copyright 211.2Smatt * notice, this list of conditions and the following disclaimer in the 221.2Smatt * documentation and/or other materials provided with the distribution. 231.2Smatt * 241.2Smatt * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 251.2Smatt * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 261.2Smatt * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 271.2Smatt * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 281.2Smatt * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 291.2Smatt * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 301.2Smatt * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 311.2Smatt * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 321.2Smatt * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 331.2Smatt * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 341.2Smatt * POSSIBILITY OF SUCH DAMAGE. 351.2Smatt */ 361.2Smatt 371.2Smatt#include <sys/cdefs.h> 381.2Smatt__KERNEL_RCSID(0, "$NetBSD: booke_autoconf.c,v 1.2 2011/01/18 01:02:52 matt Exp $"); 391.2Smatt 401.2Smatt#include <sys/param.h> 411.2Smatt#include <sys/conf.h> 421.2Smatt#include <sys/cpu.h> 431.2Smatt#include <sys/device.h> 441.2Smatt#include <sys/systm.h> 451.2Smatt 461.2Smatt#include <net/if.h> 471.2Smatt#include <net/if_ether.h> 481.2Smatt 491.2Smatt#include <powerpc/booke/cpuvar.h> 501.2Smatt 511.2Smattvoid 521.2Smatte500_device_register(device_t dev, void *aux) 531.2Smatt{ 541.2Smatt device_t parent = device_parent(dev); 551.2Smatt 561.2Smatt if (device_is_a(dev, "etsec") && device_is_a(parent, "cpunode")) { 571.2Smatt /* Set the mac-addr of the on-chip Ethernet. */ 581.2Smatt struct cpunode_attach_args *cna = aux; 591.2Smatt 601.2Smatt if (cna->cna_locs.cnl_instance < 4) { 611.2Smatt prop_data_t pd; 621.2Smatt char prop_name[15]; 631.2Smatt 641.2Smatt snprintf(prop_name, sizeof(prop_name), 651.2Smatt "etsec%d-mac-addr", cna->cna_locs.cnl_instance); 661.2Smatt 671.2Smatt pd = prop_dictionary_get(board_properties, prop_name); 681.2Smatt if (pd == NULL) { 691.2Smatt printf("WARNING: unable to get mac-addr " 701.2Smatt "property from board properties\n"); 711.2Smatt return; 721.2Smatt } 731.2Smatt if (prop_dictionary_set(device_properties(dev), 741.2Smatt "mac-address", pd) == false) { 751.2Smatt printf("WARNING: unable to set mac-addr " 761.2Smatt "property for %s\n", dev->dv_xname); 771.2Smatt } 781.2Smatt } 791.2Smatt return; 801.2Smatt } 811.2Smatt} 82