aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2009-02-11 18:38:38 -0500
committerWolfgang Denk <wd@denx.de>2009-03-20 22:39:10 +0100
commitb6b4625d175019e387e5b0f65a17322a78f6bb90 (patch)
treeb2ce2171c2fc2138f4a7d2f93a03e17559fd5b0a
parent06a0c4381a65ed500c816a05b9ae7b207c3b1d4b (diff)
downloadu-boot-linaro-stable-b6b4625d175019e387e5b0f65a17322a78f6bb90.tar.gz
boards: get mac address from environment
The boards that get converted here to use the environment for the mac address rather than global data: debris mgcoge mgsuvd muas3001 netstal pn62 sixnet vcma9 xilinx (the ones that use xilinx_enet) Signed-off-by: Mike Frysinger <vapier@gentoo.org> CC: Ben Warren <biggerbadderben@gmail.com> CC: Sangmoon Kim <dogoil@etinsys.com> CC: Heiko Schocher <hs@denx.de> CC: David Mueller <d.mueller@elsoft.ch> CC: Niklaus Giger <niklaus.giger@netstal.com> CC: Wolfgang Grandegger <wg@denx.de> CC: Dave Ellis <DGE@sixnetio.com> CC: Ricardo Ribalda <ricardo.ribalda@uam.es>
-rw-r--r--board/etin/debris/debris.c10
-rw-r--r--board/keymile/km8xx/km8xx.c4
-rw-r--r--board/keymile/mgcoge/mgcoge.c4
-rw-r--r--board/mpl/vcma9/cmd_vcma9.c11
-rw-r--r--board/muas3001/muas3001.c4
-rw-r--r--board/netstal/common/nm_bsp.c40
-rw-r--r--board/pn62/pn62.c24
-rw-r--r--board/sixnet/sixnet.c11
-rw-r--r--board/xilinx/xilinx_enet/emac_adapter.c8
9 files changed, 48 insertions, 68 deletions
diff --git a/board/etin/debris/debris.c b/board/etin/debris/debris.c
index 227c49a14..a971af3aa 100644
--- a/board/etin/debris/debris.c
+++ b/board/etin/debris/debris.c
@@ -173,9 +173,13 @@ void nvram_write(long dest, const void *src, size_t count)
int misc_init_r(void)
{
- /* Write ethernet addr in NVRAM for VxWorks */
- nvram_write(CONFIG_ENV_ADDR + CONFIG_SYS_NVRAM_VXWORKS_OFFS,
- (char*)&gd->bd->bi_enetaddr[0], 6);
+ uchar ethaddr[6];
+
+ if (eth_getenv_enetaddr("ethaddr", ethaddr))
+ /* Write ethernet addr in NVRAM for VxWorks */
+ nvram_write(CONFIG_ENV_ADDR + CONFIG_SYS_NVRAM_VXWORKS_OFFS,
+ ethaddr, 6);
+
return 0;
}
diff --git a/board/keymile/km8xx/km8xx.c b/board/keymile/km8xx/km8xx.c
index 845d3f2a0..7c5817977 100644
--- a/board/keymile/km8xx/km8xx.c
+++ b/board/keymile/km8xx/km8xx.c
@@ -174,6 +174,7 @@ void ft_blob_update (void *blob, bd_t *bd)
ulong memory_data[2] = {0};
ulong flash_data[4] = {0};
ulong flash_reg[3] = {0};
+ uchar enetaddr[6];
memory_data[0] = cpu_to_be32 (bd->bi_memstart);
memory_data[1] = cpu_to_be32 (bd->bi_memsize);
@@ -195,8 +196,9 @@ void ft_blob_update (void *blob, bd_t *bd)
sizeof (brg_data));
/* MAC adr */
+ eth_getenv_enetaddr("ethaddr", enetaddr);
fdt_set_node_and_value (blob, "/soc/cpm/ethernet", "mac-address",
- bd->bi_enetaddr, sizeof (u8) * 6);
+ enetaddr, sizeof (u8) * 6);
}
void ft_board_setup(void *blob, bd_t *bd)
diff --git a/board/keymile/mgcoge/mgcoge.c b/board/keymile/mgcoge/mgcoge.c
index 0e3aa49df..67722e708 100644
--- a/board/keymile/mgcoge/mgcoge.c
+++ b/board/keymile/mgcoge/mgcoge.c
@@ -326,6 +326,7 @@ void ft_blob_update (void *blob, bd_t *bd)
ulong memory_data[2] = {0};
ulong flash_data[8] = {0};
flash_info_t *info;
+ uchar enetaddr[6];
memory_data[0] = cpu_to_be32 (bd->bi_memstart);
memory_data[1] = cpu_to_be32 (bd->bi_memsize);
@@ -344,8 +345,9 @@ void ft_blob_update (void *blob, bd_t *bd)
fdt_set_node_and_value (blob, "/localbus", "ranges", flash_data,
sizeof (flash_data));
/* MAC addr */
+ eth_getenv_enetaddr("ethaddr", enetaddr);
fdt_set_node_and_value (blob, "/soc/cpm/ethernet", "mac-address",
- bd->bi_enetaddr, sizeof (u8) * 6);
+ enetaddr, sizeof (u8) * 6);
}
void ft_board_setup (void *blob, bd_t *bd)
diff --git a/board/mpl/vcma9/cmd_vcma9.c b/board/mpl/vcma9/cmd_vcma9.c
index 2748fa97f..7d2aa3cce 100644
--- a/board/mpl/vcma9/cmd_vcma9.c
+++ b/board/mpl/vcma9/cmd_vcma9.c
@@ -76,21 +76,18 @@ int do_vcma9(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
cs8900_e2prom_write(addr, data);
} else if (strcmp(argv[2], "setaddr") == 0) {
uchar addr, i, csum; ushort data;
+ uchar ethaddr[6];
/* check for valid ethaddr */
- for (i = 0; i < 6; i++)
- if (gd->bd->bi_enetaddr[i] != 0)
- break;
-
- if (i < 6) {
+ if (eth_getenv_enetaddr("ethaddr", ethaddr)) {
addr = 1;
data = 0x2158;
cs8900_e2prom_write(addr, data);
csum = cs8900_chksum(data);
addr++;
for (i = 0; i < 6; i+=2) {
- data = gd->bd->bi_enetaddr[i+1] << 8 |
- gd->bd->bi_enetaddr[i];
+ data = enetaddr[i+1] << 8 |
+ enetaddr[i];
cs8900_e2prom_write(addr, data);
csum += cs8900_chksum(data);
addr++;
diff --git a/board/muas3001/muas3001.c b/board/muas3001/muas3001.c
index 6b1e59f97..8f83dd9af 100644
--- a/board/muas3001/muas3001.c
+++ b/board/muas3001/muas3001.c
@@ -346,7 +346,9 @@ void ft_blob_update (void *blob, bd_t *bd)
/* MAC Adresse */
nodeoffset = fdt_path_offset (blob, "/soc/cpm/ethernet");
if (nodeoffset >= 0) {
- ret = fdt_setprop (blob, nodeoffset, "mac-address", bd->bi_enetaddr,
+ uchar ethaddr[6];
+ eth_getenv_enetaddr("ethaddr", ethaddr);
+ ret = fdt_setprop (blob, nodeoffset, "mac-address", ethaddr,
sizeof (uchar) * 6);
if (ret < 0)
printf ("ft_blob_update): cannot set /soc/cpm/ethernet/mac-address "
diff --git a/board/netstal/common/nm_bsp.c b/board/netstal/common/nm_bsp.c
index e38b7069c..237f4ed74 100644
--- a/board/netstal/common/nm_bsp.c
+++ b/board/netstal/common/nm_bsp.c
@@ -83,40 +83,20 @@ void set_params_for_sw_install(int install_requested, char *board_name )
void common_misc_init_r(void)
{
- char *s = getenv(DEFAULT_ETH_ADDR);
- char *e;
- int i;
- u32 serial = get_serial_number();
IPaddr_t ipaddr;
char *ipstring;
+ uchar ethaddr[6];
- for (i = 0; i < 6; ++i) {
- gd->bd->bi_enetaddr[i] = s ? simple_strtoul(s, &e, 16) : 0;
- if (s)
- s = (*e) ? e + 1 : e;
- }
-
- if (gd->bd->bi_enetaddr[3] == 0 &&
- gd->bd->bi_enetaddr[4] == 0 &&
- gd->bd->bi_enetaddr[5] == 0) {
- char ethaddr[22];
-
+ if (!eth_getenv_enetaddr(DEFAULT_ETH_ADDR, ethaddr)) {
/* Must be in sync with CONFIG_ETHADDR */
- gd->bd->bi_enetaddr[0] = 0x00;
- gd->bd->bi_enetaddr[1] = 0x60;
- gd->bd->bi_enetaddr[2] = 0x13;
- gd->bd->bi_enetaddr[3] = (serial >> 16) & 0xff;
- gd->bd->bi_enetaddr[4] = (serial >> 8) & 0xff;
- gd->bd->bi_enetaddr[5] = hcu_get_slot();
- sprintf(ethaddr, "%02X:%02X:%02X:%02X:%02X:%02X%c",
- gd->bd->bi_enetaddr[0], gd->bd->bi_enetaddr[1],
- gd->bd->bi_enetaddr[2], gd->bd->bi_enetaddr[3],
- gd->bd->bi_enetaddr[4],
- gd->bd->bi_enetaddr[5],
- 0) ;
- printf("%s: Setting eth %s serial 0x%x\n", __FUNCTION__,
- ethaddr, serial);
- setenv(DEFAULT_ETH_ADDR, ethaddr);
+ u32 serial = get_serial_number();
+ ethaddr[0] = 0x00;
+ ethaddr[1] = 0x60;
+ ethaddr[2] = 0x13;
+ ethaddr[3] = (serial >> 16) & 0xff;
+ ethaddr[4] = (serial >> 8) & 0xff;
+ ethaddr[5] = hcu_get_slot();
+ eth_setenv_enetaddr(DEFAULT_ETH_ADDR, ethaddr);
}
/* IP-Adress update */
diff --git a/board/pn62/pn62.c b/board/pn62/pn62.c
index 1b545bfa9..53d7e5763 100644
--- a/board/pn62/pn62.c
+++ b/board/pn62/pn62.c
@@ -30,7 +30,7 @@
DECLARE_GLOBAL_DATA_PTR;
static int get_serial_number (char *string, int size);
-static int get_mac_address (int id, u8 * mac, char *string, int size);
+static void get_mac_address(int id, u8 *mac);
#ifdef CONFIG_SHOW_BOOT_PROGRESS
void show_boot_progress (int phase)
@@ -138,18 +138,16 @@ int misc_init_r (void)
}
show_startup_phase (9);
- if (getenv ("ethaddr") == NULL &&
- get_mac_address (0, mac, str, sizeof (str)) > 0) {
- setenv ("ethaddr", str);
- memcpy (gd->bd->bi_enetaddr, mac, 6);
+ if (!eth_getenv_enetaddr("ethaddr", mac)) {
+ get_mac_address(0, mac);
+ eth_setenv_enetaddr("ethaddr", mac);
}
show_startup_phase (10);
#ifdef CONFIG_HAS_ETH1
- if (getenv ("eth1addr") == NULL &&
- get_mac_address (1, mac, str, sizeof (str)) > 0) {
- setenv ("eth1addr", str);
- memcpy (gd->bd->bi_enet1addr, mac, 6);
+ if (!eth_getenv_enetaddr("eth1addr", mac)) {
+ get_mac_address(1, mac);
+ eth_setenv_enetaddr("eth1addr", mac);
}
#endif /* CONFIG_HAS_ETH1 */
show_startup_phase (11);
@@ -177,15 +175,9 @@ static int get_serial_number (char *string, int size)
return i;
}
-static int get_mac_address (int id, u8 * mac, char *string, int size)
+static void get_mac_address(int id, u8 *mac)
{
- if (size < 6 * 3)
- return -1;
-
i2155x_read_vpd (I2155X_VPD_MAC0_START + 6 * id, 6, mac);
- return sprintf (string, "%02x:%02x:%02x:%02x:%02x:%02x",
- mac[0], mac[1], mac[2],
- mac[3], mac[4], mac[5]);
}
int board_eth_init(bd_t *bis)
diff --git a/board/sixnet/sixnet.c b/board/sixnet/sixnet.c
index 3ed581ec0..4fcd84b6f 100644
--- a/board/sixnet/sixnet.c
+++ b/board/sixnet/sixnet.c
@@ -264,6 +264,7 @@ int misc_init_r (void)
char* e;
int reg;
bd_t *bd = gd->bd;
+ uchar enetaddr[6];
memctl->memc_or2 = NVRAM_OR_PRELIM;
memctl->memc_br2 = NVRAM_BR_VALUE;
@@ -315,13 +316,9 @@ int misc_init_r (void)
* is present it gets a unique address, otherwise it
* shares the FEC address.
*/
- s = getenv("eth1addr");
- if (s == NULL)
- s = getenv("ethaddr");
- for (reg=0; reg<6; ++reg) {
- bd->bi_enet1addr[reg] = s ? simple_strtoul(s, &e, 16) : 0;
- if (s)
- s = (*e) ? e+1 : e;
+ if (!eth_getenv_enetaddr("eth1addr", enetaddr)) {
+ eth_getenv_enetaddr("ethaddr", enetaddr);
+ eth_setenv_enetaddr("eth1addr", enetaddr);
}
return (0);
diff --git a/board/xilinx/xilinx_enet/emac_adapter.c b/board/xilinx/xilinx_enet/emac_adapter.c
index 0b100d215..35bcc4d9d 100644
--- a/board/xilinx/xilinx_enet/emac_adapter.c
+++ b/board/xilinx/xilinx_enet/emac_adapter.c
@@ -74,6 +74,7 @@ eth_init(bd_t * bis)
{
u32 Options;
XStatus Result;
+ uchar enetaddr[6];
#ifdef DEBUG
printf("EMAC Initialization Started\n\r");
@@ -87,11 +88,14 @@ eth_init(bd_t * bis)
/* make sure the Emac is stopped before it is started */
(void) XEmac_Stop(&Emac);
+ if (!eth_getenv_enetaddr("ethaddr", enetaddr)) {
#ifdef CONFIG_ENV_IS_NOWHERE
- memcpy(bis->bi_enetaddr, EMACAddr, 6);
+ memcpy(enetaddr, EMACAddr, 6);
+ eth_setenv_enetaddr("ethaddr", enetaddr);
#endif
+ }
- Result = XEmac_SetMacAddress(&Emac, bis->bi_enetaddr);
+ Result = XEmac_SetMacAddress(&Emac, enetaddr);
if (Result != XST_SUCCESS) {
return 0;
}