Add support for getting the mac-address from the device properties.

This commit is contained in:
matt 2012-09-04 22:58:35 +00:00
parent b8a85c6989
commit f4db8120ae

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_smsh_gpmc.c,v 1.2 2012/09/04 00:19:48 matt Exp $ */
/* $NetBSD: if_smsh_gpmc.c,v 1.3 2012/09/04 22:58:35 matt Exp $ */
/*
* Copyright (c) 2010 KIYOHARA Takashi
* All rights reserved.
@ -26,7 +26,9 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_smsh_gpmc.c,v 1.2 2012/09/04 00:19:48 matt Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_smsh_gpmc.c,v 1.3 2012/09/04 22:58:35 matt Exp $");
#include "locators.h"
#include <sys/param.h>
#include <sys/device.h>
@ -34,8 +36,6 @@ __KERNEL_RCSID(0, "$NetBSD: if_smsh_gpmc.c,v 1.2 2012/09/04 00:19:48 matt Exp $"
#include <sys/bus.h>
#include <sys/systm.h>
#include <arm/omap/omap2_gpmcvar.h>
#include <net/if.h>
#include <net/if_ether.h>
#include <net/if_media.h>
@ -45,7 +45,7 @@ __KERNEL_RCSID(0, "$NetBSD: if_smsh_gpmc.c,v 1.2 2012/09/04 00:19:48 matt Exp $"
#include <dev/ic/lan9118var.h>
#include <dev/ic/lan9118reg.h>
#include "locators.h"
#include <arm/omap/omap2_gpmcvar.h>
static int smsh_gpmc_match(device_t, struct cfdata *, void *);
@ -90,10 +90,23 @@ smsh_gpmc_attach(device_t parent, device_t self, void *aux)
{
struct lan9118_softc *sc = device_private(self);
struct gpmc_attach_args *gpmc = aux;
prop_dictionary_t dict = device_properties(self);
void *ih;
sc->sc_dev = self;
/*
* Prefer the Ethernet address in device properties.
*/
prop_data_t ea = prop_dictionary_get(dict, "mac-address");
if (ea != NULL) {
KASSERT(prop_object_type(ea) == PROP_TYPE_DATA);
KASSERT(prop_data_size(ea) == ETHER_ADDR_LEN);
memcpy(sc->sc_enaddr, prop_data_data_nocopy(ea),
ETHER_ADDR_LEN);
sc->sc_flags |= LAN9118_FLAGS_NO_EEPROM;
}
/* Map i/o space. */
if (bus_space_map(gpmc->gpmc_iot, gpmc->gpmc_addr, LAN9118_IOSIZE, 0,
&sc->sc_ioh))