cpu/: get mac address from environment

The environment is the canonical storage location of the mac address, so
we're killing off the global data location and moving everything to
querying the env directly.

The cpus that get converted here:
	at91rm9200
	mpc512x
	mpc5xxx
	mpc8260
	mpc8xx
	ppc4xx

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
CC: Ben Warren <biggerbadderben@gmail.com>
CC: John Rigby <jrigby@freescale.com>
CC: Stefan Roese <sr@denx.de>
This commit is contained in:
Mike Frysinger 2009-02-11 19:18:41 -05:00 committed by Wolfgang Denk
parent 03f3d8d3b3
commit 6bacfa6a8e
7 changed files with 27 additions and 19 deletions

View file

@ -155,6 +155,7 @@ int eth_init (bd_t * bd)
{
int ret;
int i;
uchar enetaddr[6];
p_mac = AT91C_BASE_EMAC;
@ -190,9 +191,10 @@ int eth_init (bd_t * bd)
rbfdt[RBF_FRAMEMAX - 1].addr |= RBF_WRAP;
rbfp = &rbfdt[0];
p_mac->EMAC_SA2L = (bd->bi_enetaddr[3] << 24) | (bd->bi_enetaddr[2] << 16)
| (bd->bi_enetaddr[1] << 8) | (bd->bi_enetaddr[0]);
p_mac->EMAC_SA2H = (bd->bi_enetaddr[5] << 8) | (bd->bi_enetaddr[4]);
eth_getenv_enetaddr("ethaddr", enetaddr);
p_mac->EMAC_SA2L = (enetaddr[3] << 24) | (enetaddr[2] << 16)
| (enetaddr[1] << 8) | (enetaddr[0]);
p_mac->EMAC_SA2H = (enetaddr[5] << 8) | (enetaddr[4]);
p_mac->EMAC_RBQP = (long) (&rbfdt[0]);
p_mac->EMAC_RSR &= ~(AT91C_EMAC_RSR_OVR | AT91C_EMAC_REC | AT91C_EMAC_BNA);

View file

@ -148,15 +148,17 @@ static void old_ft_cpu_setup(void *blob, bd_t *bd)
* avoid fixing up by path because that
* produces scary error messages
*/
uchar enetaddr[6];
/*
* old device trees have ethernet nodes with
* device_type = "network"
*/
eth_getenv_enetaddr("ethaddr", enetaddr);
do_fixup_by_prop(blob, "device_type", "network", 8,
"local-mac-address", bd->bi_enetaddr, 6, 0);
"local-mac-address", enetaddr, 6, 0);
do_fixup_by_prop(blob, "device_type", "network", 8,
"address", bd->bi_enetaddr, 6, 0);
"address", enetaddr, 6, 0);
/*
* old device trees have soc nodes with
* device_type = "soc"

View file

@ -121,6 +121,7 @@ void ft_cpu_setup(void *blob, bd_t *bd)
int div = in_8((void*)CONFIG_SYS_MBAR + 0x204) & 0x0020 ? 8 : 4;
char * cpu_path = "/cpus/" OF_CPU;
#ifdef CONFIG_MPC5xxx_FEC
uchar *enetaddr[6];
char * eth_path = "/" OF_SOC "/ethernet@3000";
#endif
@ -131,8 +132,9 @@ void ft_cpu_setup(void *blob, bd_t *bd)
do_fixup_by_path_u32(blob, "/" OF_SOC, "system-frequency",
bd->bi_busfreq*div, 1);
#ifdef CONFIG_MPC5xxx_FEC
do_fixup_by_path(blob, eth_path, "mac-address", bd->bi_enetaddr, 6, 0);
do_fixup_by_path(blob, eth_path, "local-mac-address", bd->bi_enetaddr, 6, 0);
eth_getenv_enetaddr("ethaddr", enetaddr);
do_fixup_by_path(blob, eth_path, "mac-address", enetaddr, 6, 0);
do_fixup_by_path(blob, eth_path, "local-mac-address", enetaddr, 6, 0);
#endif
}
#endif

View file

@ -654,7 +654,7 @@ eth_loopback_test (void)
puts ("FCC Ethernet External loopback test\n");
memcpy (NetOurEther, gd->bd->bi_enetaddr, 6);
eth_getenv_enetaddr("ethaddr", NetOurEther);
/*
* global initialisations for all FCC channels
@ -841,7 +841,7 @@ eth_loopback_test (void)
* So, far we have only been given one Ethernet address. We use
* the same address for all channels
*/
#define ea gd->bd->bi_enetaddr
#define ea NetOurEther
fpp->fen_paddrh = (ea[5] << 8) + ea[4];
fpp->fen_paddrm = (ea[3] << 8) + ea[2];
fpp->fen_paddrl = (ea[1] << 8) + ea[0];

View file

@ -199,6 +199,7 @@ static int sec_init(struct eth_device *dev, bd_t *bis)
volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
scc_enet_t *pram_ptr;
uint dpaddr;
uchar ea[6];
rxIdx = 0;
txIdx = 0;
@ -261,11 +262,10 @@ static int sec_init(struct eth_device *dev, bd_t *bis)
pram_ptr->sen_gaddr3 = 0x0; /* Group Address Filter 3 (unused) */
pram_ptr->sen_gaddr4 = 0x0; /* Group Address Filter 4 (unused) */
# define ea bis->bi_enetaddr
eth_getenv_enetaddr("ethaddr", ea);
pram_ptr->sen_paddrh = (ea[5] << 8) + ea[4];
pram_ptr->sen_paddrm = (ea[3] << 8) + ea[2];
pram_ptr->sen_paddrl = (ea[1] << 8) + ea[0];
# undef ea
pram_ptr->sen_pper = 0x0; /* Persistence (unused) */

View file

@ -324,6 +324,7 @@ int cpu_init_r (void)
#if defined(CONFIG_405GP) || defined(CONFIG_405EP)
bd_t *bd = gd->bd;
unsigned long reg;
uchar enetaddr[6];
#if defined(CONFIG_405GP)
uint pvr = get_pvr();
#endif
@ -332,19 +333,20 @@ int cpu_init_r (void)
* Write Ethernetaddress into on-chip register
*/
reg = 0x00000000;
reg |= bd->bi_enetaddr[0]; /* set high address */
eth_getenv_enetaddr("ethaddr", enetaddr);
reg |= enetaddr[0]; /* set high address */
reg = reg << 8;
reg |= bd->bi_enetaddr[1];
reg |= enetaddr[1];
out32 (EMAC_IAH, reg);
reg = 0x00000000;
reg |= bd->bi_enetaddr[2]; /* set low address */
reg |= enetaddr[2]; /* set low address */
reg = reg << 8;
reg |= bd->bi_enetaddr[3];
reg |= enetaddr[3];
reg = reg << 8;
reg |= bd->bi_enetaddr[4];
reg |= enetaddr[4];
reg = reg << 8;
reg |= bd->bi_enetaddr[5];
reg |= enetaddr[5];
out32 (EMAC_IAL, reg);
#if defined(CONFIG_405GP)

View file

@ -110,6 +110,7 @@ static RTXBD *rtx;
static void scc_init (int scc_index)
{
bd_t *bd = gd->bd;
uchar ea[6];
static int proff[] =
{ PROFF_SCC1, PROFF_SCC2, PROFF_SCC3, PROFF_SCC4 };
@ -296,11 +297,10 @@ CPM_CR_CH_SCC4 };
pram_ptr->sen_gaddr3 = 0x0; /* Group Address Filter 3 (unused) */
pram_ptr->sen_gaddr4 = 0x0; /* Group Address Filter 4 (unused) */
#define ea bd->bi_enetaddr
eth_getenv_enetaddr("ethaddr", ea);
pram_ptr->sen_paddrh = (ea[5] << 8) + ea[4];
pram_ptr->sen_paddrm = (ea[3] << 8) + ea[2];
pram_ptr->sen_paddrl = (ea[1] << 8) + ea[0];
#undef ea
pram_ptr->sen_pper = 0x0; /* Persistence (unused) */
pram_ptr->sen_iaddr1 = 0x0; /* Individual Address Filter 1 (unused) */