}
#define EEPROM_LEN 256
-void load_sernum_ethaddr (void)
+static void load_ethaddr(void)
{
+ int ok_ethaddr, ok_eth1addr;
int ret;
char buf[EEPROM_LEN];
char mac[32];
char *use_eeprom;
u16 checksumcrc16 = 0;
+ /* If the env is sane, then nothing for us to do */
+ ok_ethaddr = eth_getenv_enetaddr("ethaddr", buf);
+ ok_eth1addr = eth_getenv_enetaddr("eth1addr", buf);
+ if (ok_ethaddr && ok_eth1addr)
+ return;
+
/* read the MACs from EEprom */
status_led_set (0, STATUS_LED_ON);
status_led_set (1, STATUS_LED_ON);
printf("%s: EEPROM Checksum not OK\n", __FUNCTION__);
} else {
/* get the MACs */
- sprintf (mac, "%02x:%02x:%02x:%02x:%02x:%02x",
- buf[3],
- buf[4],
- buf[5],
- buf[6],
- buf[7],
- buf[8]);
- setenv ("ethaddr", (char *) mac);
- sprintf (mac, "%02x:%02x:%02x:%02x:%02x:%02x",
- buf[9],
- buf[10],
- buf[11],
- buf[12],
- buf[13],
- buf[14]);
- setenv ("eth1addr", (char *) mac);
+ if (!ok_ethaddr)
+ eth_setenv_enetaddr("ethaddr", &buf[3]);
+ if (!ok_eth1addr)
+ eth_setenv_enetaddr("eth1addr", &buf[9]);
return;
}
}
uint pbcr;
int size_val = 0;
+ load_ethaddr();
+
/* Re-do sizing to get full correct info */
mtdcr(ebccfga, pb0cr);
pbcr = mfdcr(ebccfgd);
#ifdef CONFIG_MISC_INIT_R
+extern void load_sernum_ethaddr(void);
int misc_init_r (void)
{
volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
volatile memctl8xx_t *memctl = &immap->im_memctl;
+ load_sernum_ethaddr();
+
#ifdef CONFIG_SYS_OR_TIMING_FLASH_AT_50MHZ
int scy, trlx, flash_or_timing, clk_diff;
void perform_soft_reset(void);
#endif
-void load_sernum_ethaddr (void);
-
/* $(BOARD)/$(BOARD).c */
int board_early_init_f (void);
int board_late_init (void);
}
#endif
-#if defined(CONFIG_TQM8xxL) || defined(CONFIG_TQM8260) || \
- defined(CONFIG_TQM8272) || \
- defined(CONFIG_CCM) || defined(CONFIG_KUP4K) || \
- defined(CONFIG_KUP4X) || defined(CONFIG_PCS440EP)
- load_sernum_ethaddr ();
-#endif
/* IP Address */
bd->bi_ip_addr = getenv_IPaddr ("ipaddr");