From 6bacfa6a8e9b264d37c1262fc1f3e948d1feab81 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Wed, 11 Feb 2009 19:18:41 -0500 Subject: [PATCH] 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 CC: Ben Warren CC: John Rigby CC: Stefan Roese --- cpu/arm920t/at91rm9200/ether.c | 8 +++++--- cpu/mpc512x/cpu.c | 6 ++++-- cpu/mpc5xxx/cpu.c | 6 ++++-- cpu/mpc8260/ether_fcc.c | 4 ++-- cpu/mpc8260/ether_scc.c | 4 ++-- cpu/ppc4xx/cpu_init.c | 14 ++++++++------ post/cpu/mpc8xx/ether.c | 4 ++-- 7 files changed, 27 insertions(+), 19 deletions(-) diff --git a/cpu/arm920t/at91rm9200/ether.c b/cpu/arm920t/at91rm9200/ether.c index f20e070343..b00b948ee8 100644 --- a/cpu/arm920t/at91rm9200/ether.c +++ b/cpu/arm920t/at91rm9200/ether.c @@ -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); diff --git a/cpu/mpc512x/cpu.c b/cpu/mpc512x/cpu.c index b9069b065e..be532afdc3 100644 --- a/cpu/mpc512x/cpu.c +++ b/cpu/mpc512x/cpu.c @@ -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" diff --git a/cpu/mpc5xxx/cpu.c b/cpu/mpc5xxx/cpu.c index 9c6ab76a6f..ad5ef8e371 100644 --- a/cpu/mpc5xxx/cpu.c +++ b/cpu/mpc5xxx/cpu.c @@ -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 diff --git a/cpu/mpc8260/ether_fcc.c b/cpu/mpc8260/ether_fcc.c index 3ab57eb5b4..5ac02a09c0 100644 --- a/cpu/mpc8260/ether_fcc.c +++ b/cpu/mpc8260/ether_fcc.c @@ -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]; diff --git a/cpu/mpc8260/ether_scc.c b/cpu/mpc8260/ether_scc.c index 3671ef1dfb..432111df4c 100644 --- a/cpu/mpc8260/ether_scc.c +++ b/cpu/mpc8260/ether_scc.c @@ -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) */ diff --git a/cpu/ppc4xx/cpu_init.c b/cpu/ppc4xx/cpu_init.c index b5d81f2e6d..a8f589a9f1 100644 --- a/cpu/ppc4xx/cpu_init.c +++ b/cpu/ppc4xx/cpu_init.c @@ -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) diff --git a/post/cpu/mpc8xx/ether.c b/post/cpu/mpc8xx/ether.c index 5622cb7d2a..fe6c39eb3c 100644 --- a/post/cpu/mpc8xx/ether.c +++ b/post/cpu/mpc8xx/ether.c @@ -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) */ -- 2.39.5