From 6bacfa6a8e9b264d37c1262fc1f3e948d1feab81 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Wed, 11 Feb 2009 19:18:41 -0500 Subject: 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 ++++++++------ 6 files changed, 25 insertions(+), 17 deletions(-) (limited to 'cpu') 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) -- cgit v1.2.3 From 740e8ba7d475c49c1b76058e1bf354e376b5c4e0 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Wed, 11 Feb 2009 19:19:54 -0500 Subject: npe: 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 resulting code can also be simplified even further. Signed-off-by: Mike Frysinger CC: Stefan Roese CC: Ben Warren --- cpu/ixp/npe/npe.c | 36 +++++++++++------------------------- 1 file changed, 11 insertions(+), 25 deletions(-) (limited to 'cpu') diff --git a/cpu/ixp/npe/npe.c b/cpu/ixp/npe/npe.c index 03e3bf7c16..2e6868960a 100644 --- a/cpu/ixp/npe/npe.c +++ b/cpu/ixp/npe/npe.c @@ -565,25 +565,19 @@ int npe_initialize(bd_t * bis) struct eth_device *dev; int eth_num = 0; struct npe *p_npe = NULL; + uchar enetaddr[6]; for (eth_num = 0; eth_num < CONFIG_SYS_NPE_NUMS; eth_num++) { /* See if we can actually bring up the interface, otherwise, skip it */ - switch (eth_num) { - default: /* fall through */ - case 0: - if (memcmp (bis->bi_enetaddr, "\0\0\0\0\0\0", 6) == 0) { - continue; - } - break; #ifdef CONFIG_HAS_ETH1 - case 1: - if (memcmp (bis->bi_enet1addr, "\0\0\0\0\0\0", 6) == 0) { + if (eth_num == 1) { + if (!eth_getenv_enetaddr("eth1addr", enetaddr)) continue; - } - break; + } else #endif - } + if (!eth_getenv_enetaddr("ethaddr", enetaddr)) + continue; /* Allocate device structure */ dev = (struct eth_device *)malloc(sizeof(*dev)); @@ -603,22 +597,14 @@ int npe_initialize(bd_t * bis) } memset(p_npe, 0, sizeof(struct npe)); - switch (eth_num) { - default: /* fall through */ - case 0: - memcpy(dev->enetaddr, bis->bi_enetaddr, 6); - p_npe->eth_id = 0; - p_npe->phy_no = CONFIG_PHY_ADDR; - break; - + p_npe->eth_id = eth_num; + memcpy(dev->enetaddr, enetaddr, 6); #ifdef CONFIG_HAS_ETH1 - case 1: - memcpy(dev->enetaddr, bis->bi_enet1addr, 6); - p_npe->eth_id = 1; + if (eth_num == 1) p_npe->phy_no = CONFIG_PHY1_ADDR; - break; + else #endif - } + p_npe->phy_no = CONFIG_PHY_ADDR; sprintf(dev->name, "NPE%d", eth_num); dev->priv = (void *)p_npe; -- cgit v1.2.3 From f62fb99941c625605aa16a0097b396a5c16d2c88 Mon Sep 17 00:00:00 2001 From: Trent Piepho Date: Wed, 18 Feb 2009 15:22:05 -0800 Subject: Fix all linker script to handle all rodata sections A recent gcc added a new unaligned rodata section called '.rodata.str1.1', which needs to be added the the linker script. Instead of just adding this one section, we use a wildcard ".rodata*" to get all rodata linker section gcc has now and might add in the future. However, '*(.rodata*)' by itself will result in sub-optimal section ordering. The sections will be sorted by object file, which causes extra padding between the unaligned rodata.str.1.1 of one object file and the aligned rodata of the next object file. This is easy to fix by using the SORT_BY_ALIGNMENT command. This patch has not be tested one most of the boards modified. Some boards have a linker script that looks something like this: *(.text) . = ALIGN(16); *(.rodata) *(.rodata.str1.4) *(.eh_frame) I change this to: *(.text) . = ALIGN(16); *(.eh_frame) *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) This means the start of rodata will no longer be 16 bytes aligned. However, the boundary between text and rodata/eh_frame is still aligned to 16 bytes, which is what I think the real purpose of the ALIGN call is. Signed-off-by: Trent Piepho --- cpu/arm926ejs/at91/u-boot.lds | 2 +- cpu/mpc5xx/u-boot.lds | 4 +--- cpu/mpc5xxx/u-boot-customlayout.lds | 4 +--- cpu/mpc5xxx/u-boot.lds | 4 +--- cpu/mpc8220/u-boot.lds | 4 +--- cpu/mpc824x/u-boot.lds | 4 +--- cpu/mpc8260/u-boot.lds | 4 +--- cpu/mpc83xx/u-boot.lds | 4 +--- 8 files changed, 8 insertions(+), 22 deletions(-) (limited to 'cpu') diff --git a/cpu/arm926ejs/at91/u-boot.lds b/cpu/arm926ejs/at91/u-boot.lds index 4778d1e039..ebb1f93864 100644 --- a/cpu/arm926ejs/at91/u-boot.lds +++ b/cpu/arm926ejs/at91/u-boot.lds @@ -37,7 +37,7 @@ SECTIONS } . = ALIGN(4); - .rodata : { *(.rodata) } + .rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) } . = ALIGN(4); .data : { *(.data) } diff --git a/cpu/mpc5xx/u-boot.lds b/cpu/mpc5xx/u-boot.lds index bf52179c58..cb17ca5d74 100644 --- a/cpu/mpc5xx/u-boot.lds +++ b/cpu/mpc5xx/u-boot.lds @@ -65,10 +65,8 @@ SECTIONS PROVIDE (etext = .); .rodata : { - *(.rodata) - *(.rodata1) - *(.rodata.str1.4) *(.eh_frame) + *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) } .fini : { *(.fini) } =0 .ctors : { *(.ctors) } diff --git a/cpu/mpc5xxx/u-boot-customlayout.lds b/cpu/mpc5xxx/u-boot-customlayout.lds index f6bb858a25..9563690321 100644 --- a/cpu/mpc5xxx/u-boot-customlayout.lds +++ b/cpu/mpc5xxx/u-boot-customlayout.lds @@ -68,10 +68,8 @@ SECTIONS *(.fixup) *(.got1) . = ALIGN(16); - *(.rodata) - *(.rodata1) - *(.rodata.str1.4) *(.eh_frame) + *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) } .fini : { *(.fini) } =0 .ctors : { *(.ctors) } diff --git a/cpu/mpc5xxx/u-boot.lds b/cpu/mpc5xxx/u-boot.lds index 8d1fa60d07..a6d4ff3888 100644 --- a/cpu/mpc5xxx/u-boot.lds +++ b/cpu/mpc5xxx/u-boot.lds @@ -57,10 +57,8 @@ SECTIONS *(.fixup) *(.got1) . = ALIGN(16); - *(.rodata) - *(.rodata1) - *(.rodata.str1.4) *(.eh_frame) + *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) } .fini : { *(.fini) } =0 .ctors : { *(.ctors) } diff --git a/cpu/mpc8220/u-boot.lds b/cpu/mpc8220/u-boot.lds index 2a12a698df..436423c3bb 100644 --- a/cpu/mpc8220/u-boot.lds +++ b/cpu/mpc8220/u-boot.lds @@ -57,10 +57,8 @@ SECTIONS *(.fixup) *(.got1) . = ALIGN(16); - *(.rodata) - *(.rodata1) - *(.rodata.str1.4) *(.eh_frame) + *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) } .fini : { *(.fini) } =0 .ctors : { *(.ctors) } diff --git a/cpu/mpc824x/u-boot.lds b/cpu/mpc824x/u-boot.lds index 8c7e1356d3..46f708738e 100644 --- a/cpu/mpc824x/u-boot.lds +++ b/cpu/mpc824x/u-boot.lds @@ -57,10 +57,8 @@ SECTIONS *(.fixup) *(.got1) . = ALIGN(16); - *(.rodata) - *(.rodata1) - *(.rodata.str1.4) *(.eh_frame) + *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) } .fini : { *(.fini) } =0 .ctors : { *(.ctors) } diff --git a/cpu/mpc8260/u-boot.lds b/cpu/mpc8260/u-boot.lds index d65a939872..b3a103dbcb 100644 --- a/cpu/mpc8260/u-boot.lds +++ b/cpu/mpc8260/u-boot.lds @@ -57,10 +57,8 @@ SECTIONS *(.fixup) *(.got1) . = ALIGN(16); - *(.rodata) - *(.rodata1) - *(.rodata.str1.4) *(.eh_frame) + *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) } .fini : { *(.fini) } =0 .ctors : { *(.ctors) } diff --git a/cpu/mpc83xx/u-boot.lds b/cpu/mpc83xx/u-boot.lds index 3a08f642a7..7d57ee4160 100644 --- a/cpu/mpc83xx/u-boot.lds +++ b/cpu/mpc83xx/u-boot.lds @@ -55,10 +55,8 @@ SECTIONS *(.fixup) *(.got1) . = ALIGN(16); - *(.rodata) - *(.rodata1) - *(.rodata.str1.4) *(.eh_frame) + *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) } .fini : { *(.fini) } =0 .ctors : { *(.ctors) } -- cgit v1.2.3 From 6d83e3ac61dcdbcb7f04664309a9689fe01c5704 Mon Sep 17 00:00:00 2001 From: Graeme Russ Date: Tue, 24 Feb 2009 21:12:20 +1100 Subject: Rename SC520 Configuration Options Options are now all uniformly CONFIG_SYS_SC520_