summaryrefslogtreecommitdiff
path: root/board
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2009-02-16 18:03:14 -0500
committerWolfgang Denk <wd@denx.de>2009-03-20 22:39:12 +0100
commitd8d21e699d7fcfb6ab11635110266dd09b7edc62 (patch)
treeec591b9aaf82e817558bde954ba6dc616bc908fd /board
parentf11e6ff5b1859d9213f0d501b3309e065f487543 (diff)
downloadu-boot-imx-d8d21e699d7fcfb6ab11635110266dd09b7edc62.zip
u-boot-imx-d8d21e699d7fcfb6ab11635110266dd09b7edc62.tar.gz
u-boot-imx-d8d21e699d7fcfb6ab11635110266dd09b7edc62.tar.bz2
boards: move board_get_enetaddr() into board-specific init
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. Rather than have the common ppc code have board-specific hooks, move the board_get_enetaddr() function into the board-specific init functions. Signed-off-by: Mike Frysinger <vapier@gentoo.org> CC: Ben Warren <biggerbadderben@gmail.com>
Diffstat (limited to 'board')
-rw-r--r--board/RPXClassic/RPXClassic.c16
-rw-r--r--board/mbx8xx/mbx8xx.c14
-rw-r--r--board/sandburst/common/sb_common.c4
-rw-r--r--board/sandburst/common/sb_common.h1
-rw-r--r--board/sandburst/karef/karef.c29
-rw-r--r--board/sandburst/metrobox/metrobox.c29
-rw-r--r--board/siemens/IAD210/IAD210.c14
-rw-r--r--board/v38b/v38b.c12
-rw-r--r--board/xpedite1k/xpedite1k.c51
9 files changed, 151 insertions, 19 deletions
diff --git a/board/RPXClassic/RPXClassic.c b/board/RPXClassic/RPXClassic.c
index 9fdf700..5aa713f 100644
--- a/board/RPXClassic/RPXClassic.c
+++ b/board/RPXClassic/RPXClassic.c
@@ -105,7 +105,7 @@ int checkboard (void)
* board_get_enetaddr -- Read the MAC Address in the I2C EEPROM
*-----------------------------------------------------------------------------
*/
-void board_get_enetaddr (uchar * enet)
+static void board_get_enetaddr(uchar *enet)
{
int i;
char buff[256], *cp;
@@ -142,9 +142,19 @@ void board_get_enetaddr (uchar * enet)
enet[3] |= 0x80;
#endif
- printf ("MAC address = %02x:%02x:%02x:%02x:%02x:%02x\n",
- enet[0], enet[1], enet[2], enet[3], enet[4], enet[5]);
+ printf("MAC address = %pM\n", enet);
+}
+
+int misc_init_r(void)
+{
+ uchar enetaddr[6];
+
+ if (!eth_getenv_enetaddr("ethaddr", enetaddr)) {
+ board_get_enetaddr(enetaddr);
+ eth_putenv_enetaddr("ethaddr", enetaddr);
+ }
+ return 0;
}
void rpxclassic_init (void)
diff --git a/board/mbx8xx/mbx8xx.c b/board/mbx8xx/mbx8xx.c
index af4f57d..a3bf1f7 100644
--- a/board/mbx8xx/mbx8xx.c
+++ b/board/mbx8xx/mbx8xx.c
@@ -241,7 +241,7 @@ static unsigned int get_reffreq (void)
return *((ulong *) packet->data);
}
-void board_get_enetaddr (uchar * addr)
+static void board_get_enetaddr(uchar *addr)
{
int i;
vpd_packet_t *packet;
@@ -251,6 +251,18 @@ void board_get_enetaddr (uchar * addr)
addr[i] = packet->data[i];
}
+int misc_init_r(void)
+{
+ uchar enetaddr[6];
+
+ if (!eth_getenv_enetaddr("ethaddr", enetaddr)) {
+ board_get_enetaddr(enetaddr);
+ eth_putenv_enetaddr("ethaddr", enetaddr);
+ }
+
+ return 0;
+}
+
/*
* Check Board Identity:
*/
diff --git a/board/sandburst/common/sb_common.c b/board/sandburst/common/sb_common.c
index f6ea16f..b8160c8 100644
--- a/board/sandburst/common/sb_common.c
+++ b/board/sandburst/common/sb_common.c
@@ -394,9 +394,8 @@ int is_pci_host(struct pci_controller *hose)
* mgmt mac address.
*
************************************************************************/
-static int macaddr_idx = 0;
-void board_get_enetaddr (uchar * enet)
+void board_get_enetaddr(int macaddr_idx, uchar *enet)
{
int i;
unsigned short tmp;
@@ -419,7 +418,6 @@ void board_get_enetaddr (uchar * enet)
tmp += 31;
memcpy(&enet[4], &tmp, 2);
- macaddr_idx++;
} else {
enet[0] = 0x02;
enet[1] = 0x00;
diff --git a/board/sandburst/common/sb_common.h b/board/sandburst/common/sb_common.h
index 888e4f0..e652ba8 100644
--- a/board/sandburst/common/sb_common.h
+++ b/board/sandburst/common/sb_common.h
@@ -72,5 +72,6 @@ int sbcommon_get_master(void);
int sbcommon_secondary_present(void);
unsigned short sbcommon_get_serial_number(void);
void sbcommon_fans(void);
+void board_get_enetaddr(int macaddr_idx, uchar *enet);
#endif /* __SBCOMMON_H__ */
diff --git a/board/sandburst/karef/karef.c b/board/sandburst/karef/karef.c
index 9b94af5..55310d7 100644
--- a/board/sandburst/karef/karef.c
+++ b/board/sandburst/karef/karef.c
@@ -354,6 +354,7 @@ int misc_init_r (void)
{
unsigned short sernum;
char envstr[255];
+ uchar enetaddr[6];
KAREF_FPGA_REGS_ST *karef_ps;
OFEM_FPGA_REGS_ST *ofem_ps;
@@ -408,6 +409,34 @@ int misc_init_r (void)
printf("fakeled is set. use 'setenv fakeled ; setenv bootdelay 5 ; saveenv' to recover\n");
}
+#ifdef CONFIG_HAS_ETH0
+ if (!eth_getenv_enetaddr("ethaddr", enetaddr)) {
+ board_get_enetaddr(0, enetaddr);
+ eth_putenv_enetaddr("ethaddr", enetaddr);
+ }
+#endif
+
+#ifdef CONFIG_HAS_ETH1
+ if (!eth_getenv_enetaddr("eth1addr", enetaddr)) {
+ board_get_enetaddr(1, enetaddr);
+ eth_putenv_enetaddr("eth1addr", enetaddr);
+ }
+#endif
+
+#ifdef CONFIG_HAS_ETH2
+ if (!eth_getenv_enetaddr("eth2addr", enetaddr)) {
+ board_get_enetaddr(2, enetaddr);
+ eth_putenv_enetaddr("eth2addr", enetaddr);
+ }
+#endif
+
+#ifdef CONFIG_HAS_ETH3
+ if (!eth_getenv_enetaddr("eth3addr", enetaddr)) {
+ board_get_enetaddr(3, enetaddr);
+ eth_putenv_enetaddr("eth3addr", enetaddr);
+ }
+#endif
+
return (0);
}
diff --git a/board/sandburst/metrobox/metrobox.c b/board/sandburst/metrobox/metrobox.c
index ec4c451..8bb8c02 100644
--- a/board/sandburst/metrobox/metrobox.c
+++ b/board/sandburst/metrobox/metrobox.c
@@ -321,6 +321,7 @@ int misc_init_r (void)
{
unsigned short sernum;
char envstr[255];
+ uchar enetaddr[6];
unsigned char opto_rev;
OPTO_FPGA_REGS_ST *opto_ps;
@@ -379,6 +380,34 @@ int misc_init_r (void)
}
}
+#ifdef CONFIG_HAS_ETH0
+ if (!eth_getenv_enetaddr("ethaddr", enetaddr)) {
+ board_get_enetaddr(0, enetaddr);
+ eth_putenv_enetaddr("ethaddr", enetaddr);
+ }
+#endif
+
+#ifdef CONFIG_HAS_ETH1
+ if (!eth_getenv_enetaddr("eth1addr", enetaddr)) {
+ board_get_enetaddr(1, enetaddr);
+ eth_putenv_enetaddr("eth1addr", enetaddr);
+ }
+#endif
+
+#ifdef CONFIG_HAS_ETH2
+ if (!eth_getenv_enetaddr("eth2addr", enetaddr)) {
+ board_get_enetaddr(2, enetaddr);
+ eth_putenv_enetaddr("eth2addr", enetaddr);
+ }
+#endif
+
+#ifdef CONFIG_HAS_ETH3
+ if (!eth_getenv_enetaddr("eth3addr", enetaddr)) {
+ board_get_enetaddr(3, enetaddr);
+ eth_putenv_enetaddr("eth3addr", enetaddr);
+ }
+#endif
+
return (0);
}
diff --git a/board/siemens/IAD210/IAD210.c b/board/siemens/IAD210/IAD210.c
index e21bb24..67e5c8f 100644
--- a/board/siemens/IAD210/IAD210.c
+++ b/board/siemens/IAD210/IAD210.c
@@ -258,7 +258,7 @@ int board_early_init_f (void)
return 0;
}
-void board_get_enetaddr (uchar * addr)
+static void board_get_enetaddr(uchar *addr)
{
int i;
volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
@@ -284,3 +284,15 @@ void board_get_enetaddr (uchar * addr)
cpm->cp_rccr = rccrtmp;
}
+
+int misc_init_r(void)
+{
+ uchar enetaddr[6];
+
+ if (!eth_getenv_enetaddr("ethaddr", enetaddr)) {
+ board_get_enetaddr(enetaddr);
+ eth_putenv_enetaddr("ethaddr", enetaddr);
+ }
+
+ return 0;
+}
diff --git a/board/v38b/v38b.c b/board/v38b/v38b.c
index d774295..9e7c1d7 100644
--- a/board/v38b/v38b.c
+++ b/board/v38b/v38b.c
@@ -223,6 +223,18 @@ int board_early_init_r(void)
return 0;
}
+extern void board_get_enetaddr(uchar *enetaddr);
+int misc_init_r(void)
+{
+ uchar enetaddr[6];
+
+ if (!eth_getenv_enetaddr("ethaddr", enetaddr)) {
+ board_get_enetaddr(enetaddr);
+ eth_putenv_enetaddr("ethaddr", enetaddr);
+ }
+
+ return 0;
+}
#if defined(CONFIG_CMD_IDE) && defined(CONFIG_IDE_RESET)
void init_ide_reset(void)
diff --git a/board/xpedite1k/xpedite1k.c b/board/xpedite1k/xpedite1k.c
index 58bcfaf..cd1a368 100644
--- a/board/xpedite1k/xpedite1k.c
+++ b/board/xpedite1k/xpedite1k.c
@@ -335,29 +335,58 @@ ulong post_word_load (void)
* board_get_enetaddr -- Read the MAC Addresses in the I2C EEPROM
*-----------------------------------------------------------------------------
*/
-static int enetaddr_num = 0;
-void board_get_enetaddr (uchar * enet)
+static int read_i2c;
+static void board_get_enetaddr(uchar *enet)
{
int i;
unsigned char buff[0x100], *cp;
+ if (read_i2c)
+ return;
+
/* Initialize I2C */
i2c_init (CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
/* Read 256 bytes in EEPROM */
i2c_read (0x50, 0, 1, buff, 0x100);
- if (enetaddr_num == 0) {
- cp = &buff[0xF4];
- enetaddr_num = 1;
- }
- else
- cp = &buff[0xFA];
-
+ cp = &buff[0xF4];
for (i = 0; i < 6; i++,cp++)
enet[i] = *cp;
- printf ("MAC address = %02x:%02x:%02x:%02x:%02x:%02x\n",
- enet[0], enet[1], enet[2], enet[3], enet[4], enet[5]);
+ printf("MAC address = %pM\n", enet);
+ read_i2c = 1;
+}
+
+int misc_init_r(void)
+{
+ uchar enetaddr[6], i2c_enetaddr[6];
+
+ if (!eth_getenv_enetaddr("ethaddr", enetaddr)) {
+ board_get_enetaddr(i2c_enetaddr);
+ eth_putenv_enetaddr("ethaddr", i2c_enetaddr);
+ }
+
+#ifdef CONFIG_HAS_ETH1
+ if (!eth_getenv_enetaddr("eth1addr", enetaddr)) {
+ board_get_enetaddr(i2c_enetaddr);
+ eth_putenv_enetaddr("eth1addr", i2c_enetaddr);
+ }
+#endif
+
+#ifdef CONFIG_HAS_ETH2
+ if (!eth_getenv_enetaddr("eth2addr", enetaddr)) {
+ board_get_enetaddr(i2c_enetaddr);
+ eth_putenv_enetaddr("eth2addr", i2c_enetaddr);
+ }
+#endif
+#ifdef CONFIG_HAS_ETH3
+ if (!eth_getenv_enetaddr("eth3addr", enetaddr)) {
+ board_get_enetaddr(i2c_enetaddr);
+ eth_putenv_enetaddr("eth3addr", i2c_enetaddr);
+ }
+#endif
+
+ return 0;
}