Subject: Re: change proposal sys/arch/arm/ep93xx
To: HAMAJIMA Katsuomi <hamajima@nagoya.bug.gr.jp>
From: Jason Thorpe <thorpej@shagadelic.org>
List: port-arm
Date: 10/21/2005 10:14:53
On Oct 18, 2005, at 12:08 PM, Jason Thorpe wrote:
>
> On Oct 18, 2005, at 10:46 AM, Jesse Off wrote:
>
>> I wrote the epe driver for the TS-7200 board. This board has the
>> MAC set by the RedBoot firmware and IIRC, I just leave the value
>> untouched. Just keep in mind if you overwrite the MAC using some
>> method specific to your board, it will break the TS-7200 unless
>> you make sure it happens only for your board.
>
> There is a better way to do this using properties. I'll follow-up
> more later.
...and now the follow-up.. sorry for the delay.
Take a look at sys/arch/evbppc/walnut/autoconf.c -- in particular,
the device_register() function:
.
.
.
if (strcmp(dev->dv_cfdata->cf_name, "emac") == 0 &&
strcmp(parent->dv_cfdata->cf_name, "opb") == 0) {
/* Set the mac-addr of the on-chip Ethernet. */
/* XXX 405GP only has one; what about CPUs with two? */
if (prop_set(dev_propdb, dev, "mac-addr",
&board_data.mac_address_local,
sizeof(board_data.mac_address_local),
PROP_CONST, 0) != 0)
printf("WARNING: unable to set mac-addr "
"property for %s\n", dev->dv_xname);
return;
}
.
.
.
...and now look at arch/powerpc/ibm4xx/dev/if_emac.c's emac_attach():
.
.
.
/* Fetch the Ethernet address. */
if (prop_get(dev_propdb, &sc->sc_dev, "mac-addr", enaddr,
sizeof(enaddr), NULL) != sizeof(enaddr)) {
printf("%s: unable to get mac-addr property\n",
sc->sc_dev.dv_xname);
return;
}
.
.
.
The dev_propdb property database is created in MI code (configure()
in subr_autoconf.c).
I think this represents a good way to handle board-specific ways of
fetching certain kinds of information for SOC devices for embedded
systems.
-- thorpej