mirror of
https://github.com/u-boot/u-boot.git
synced 2024-11-25 21:24:21 +08:00
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>
This commit is contained in:
parent
f11e6ff5b1
commit
d8d21e699d
@ -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)
|
||||
|
@ -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:
|
||||
*/
|
||||
|
@ -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;
|
||||
|
@ -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__ */
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -352,13 +352,6 @@ void board_serial_init (void);
|
||||
void board_ether_init (void);
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_RPXCLASSIC) || defined(CONFIG_MBX) || \
|
||||
defined(CONFIG_IAD210) || defined(CONFIG_XPEDITE1K) || \
|
||||
defined(CONFIG_METROBOX) || defined(CONFIG_KAREF) || \
|
||||
defined(CONFIG_V38B)
|
||||
void board_get_enetaddr (uchar *addr);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_HERMES
|
||||
/* $(BOARD)/hermes.c */
|
||||
void hermes_start_lxt980 (int speed);
|
||||
|
@ -67,6 +67,7 @@
|
||||
|
||||
/* using this define saves us updating another source file */
|
||||
#define CONFIG_BOARD_EARLY_INIT_F 1
|
||||
#define CONFIG_MISC_INIT_R
|
||||
|
||||
#undef CONFIG_BOOTARGS
|
||||
/* #define CONFIG_BOOTCOMMAND \
|
||||
|
@ -50,6 +50,8 @@
|
||||
#undef CONFIG_8xx_TFTP_MODE
|
||||
#endif
|
||||
|
||||
#define CONFIG_MISC_INIT_R
|
||||
|
||||
#define CONFIG_DRAM_SPEED (CONFIG_8xx_BUSCLOCK) /* MHz */
|
||||
#define CONFIG_BOOTCOMMAND "bootm FE020000" /* autoboot command */
|
||||
#define CONFIG_BOOTARGS " "
|
||||
|
@ -53,6 +53,7 @@
|
||||
#define CONFIG_SYS_DISCOVER_PHY 1
|
||||
#define CONFIG_MII 1
|
||||
#endif /* CONFIG_FEC_ENET */
|
||||
#define CONFIG_MISC_INIT_R
|
||||
|
||||
/* Video console (graphic: Epson SED13806 on ECCX board, no keyboard */
|
||||
#if 1
|
||||
|
@ -38,6 +38,7 @@
|
||||
#define CONFIG_440 1
|
||||
#define CONFIG_440GX 1 /* 440 GX */
|
||||
#define CONFIG_BOARD_EARLY_INIT_F 1 /* Call board_pre_init */
|
||||
#define CONFIG_MISC_INIT_R
|
||||
#undef CONFIG_SYS_DRAM_TEST /* Disable-takes long time! */
|
||||
#define CONFIG_SYS_CLK_FREQ 33333333 /* external freq to pll */
|
||||
|
||||
|
@ -40,6 +40,7 @@
|
||||
|
||||
#define CONFIG_BOARD_EARLY_INIT_R 1 /* do board-specific init */
|
||||
#define CONFIG_BOARD_EARLY_INIT_F 1 /* do board-specific init */
|
||||
#define CONFIG_MISC_INIT_R
|
||||
|
||||
#define CONFIG_SYS_XLB_PIPELINING 1 /* gives better performance */
|
||||
|
||||
|
@ -879,14 +879,6 @@ void board_init_r (gd_t *id, ulong dest_addr)
|
||||
#endif
|
||||
|
||||
s = getenv ("ethaddr");
|
||||
#if defined (CONFIG_MBX) || \
|
||||
defined (CONFIG_RPXCLASSIC) || \
|
||||
defined(CONFIG_IAD210) || \
|
||||
defined(CONFIG_V38B)
|
||||
if (s == NULL)
|
||||
board_get_enetaddr (bd->bi_enetaddr);
|
||||
else
|
||||
#endif
|
||||
for (i = 0; i < 6; ++i) {
|
||||
bd->bi_enetaddr[i] = s ? simple_strtoul (s, &e, 16) : 0;
|
||||
if (s)
|
||||
@ -914,11 +906,6 @@ void board_init_r (gd_t *id, ulong dest_addr)
|
||||
/* handle the 3rd ethernet address */
|
||||
|
||||
s = getenv ("eth2addr");
|
||||
#if defined(CONFIG_XPEDITE1K) || defined(CONFIG_METROBOX) || defined(CONFIG_KAREF)
|
||||
if (s == NULL)
|
||||
board_get_enetaddr(bd->bi_enet2addr);
|
||||
else
|
||||
#endif
|
||||
for (i = 0; i < 6; ++i) {
|
||||
bd->bi_enet2addr[i] = s ? simple_strtoul (s, &e, 16) : 0;
|
||||
if (s)
|
||||
@ -929,11 +916,6 @@ void board_init_r (gd_t *id, ulong dest_addr)
|
||||
#ifdef CONFIG_HAS_ETH3
|
||||
/* handle 4th ethernet address */
|
||||
s = getenv("eth3addr");
|
||||
#if defined(CONFIG_XPEDITE1K) || defined(CONFIG_METROBOX) || defined(CONFIG_KAREF)
|
||||
if (s == NULL)
|
||||
board_get_enetaddr(bd->bi_enet3addr);
|
||||
else
|
||||
#endif
|
||||
for (i = 0; i < 6; ++i) {
|
||||
bd->bi_enet3addr[i] = s ? simple_strtoul (s, &e, 16) : 0;
|
||||
if (s)
|
||||
@ -944,11 +926,6 @@ void board_init_r (gd_t *id, ulong dest_addr)
|
||||
#ifdef CONFIG_HAS_ETH4
|
||||
/* handle 5th ethernet address */
|
||||
s = getenv("eth4addr");
|
||||
#if defined(CONFIG_XPEDITE1K) || defined(CONFIG_METROBOX) || defined(CONFIG_KAREF)
|
||||
if (s == NULL)
|
||||
board_get_enetaddr(bd->bi_enet4addr);
|
||||
else
|
||||
#endif
|
||||
for (i = 0; i < 6; ++i) {
|
||||
bd->bi_enet4addr[i] = s ? simple_strtoul (s, &e, 16) : 0;
|
||||
if (s)
|
||||
@ -959,11 +936,6 @@ void board_init_r (gd_t *id, ulong dest_addr)
|
||||
#ifdef CONFIG_HAS_ETH5
|
||||
/* handle 6th ethernet address */
|
||||
s = getenv("eth5addr");
|
||||
#if defined(CONFIG_XPEDITE1K) || defined(CONFIG_METROBOX) || defined(CONFIG_KAREF)
|
||||
if (s == NULL)
|
||||
board_get_enetaddr(bd->bi_enet5addr);
|
||||
else
|
||||
#endif
|
||||
for (i = 0; i < 6; ++i) {
|
||||
bd->bi_enet5addr[i] = s ? simple_strtoul (s, &e, 16) : 0;
|
||||
if (s)
|
||||
|
Loading…
Reference in New Issue
Block a user