summaryrefslogtreecommitdiff
path: root/board/xpedite1k
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/xpedite1k
parentf11e6ff5b1859d9213f0d501b3309e065f487543 (diff)
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/xpedite1k')
-rw-r--r--board/xpedite1k/xpedite1k.c51
1 files changed, 40 insertions, 11 deletions
diff --git a/board/xpedite1k/xpedite1k.c b/board/xpedite1k/xpedite1k.c
index 58bcfaf7b..cd1a368ec 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;
}