summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorWolfgang Denk <wd@denx.de>2009-03-21 22:15:49 +0100
committerWolfgang Denk <wd@denx.de>2009-03-21 22:15:49 +0100
commitee1702d75a30d076139d1841383a1fa7220a0e11 (patch)
treeb008c231b7d5e4e52ac49aec9a49bc73413aaf30 /drivers
parente60beb13cf0135dc71c541021487b5ccc4d269cb (diff)
parentfaac4fd852e39cb1d7a740801b060e41aeacef1f (diff)
downloadu-boot-imx-ee1702d75a30d076139d1841383a1fa7220a0e11.zip
u-boot-imx-ee1702d75a30d076139d1841383a1fa7220a0e11.tar.gz
u-boot-imx-ee1702d75a30d076139d1841383a1fa7220a0e11.tar.bz2
Merge branch 'next' of ../next
Diffstat (limited to 'drivers')
-rw-r--r--drivers/misc/ali512x.c2
-rw-r--r--drivers/net/3c589.c7
-rw-r--r--drivers/net/4xx_enet.c13
-rw-r--r--drivers/net/bcm570x.c4
-rw-r--r--drivers/net/bcm570x_lm.h2
-rw-r--r--drivers/net/bfin_mac.c16
-rw-r--r--drivers/net/bfin_mac.h2
-rw-r--r--drivers/net/cs8900.c56
-rw-r--r--drivers/net/dc2114x.c9
-rw-r--r--drivers/net/dm9000x.c26
-rw-r--r--drivers/net/enc28j60.c4
-rw-r--r--drivers/net/fsl_mcdmafec.c11
-rw-r--r--drivers/net/ks8695eth.c8
-rw-r--r--drivers/net/lan91c96.c75
-rw-r--r--drivers/net/mcffec.c10
-rw-r--r--drivers/net/rtl8019.c14
-rw-r--r--drivers/net/rtl8169.c2
-rw-r--r--drivers/net/s3c4510b_eth.c2
-rw-r--r--drivers/net/s3c4510b_eth.h2
-rw-r--r--drivers/net/sh_eth.c28
-rw-r--r--drivers/net/smc91111.c72
-rw-r--r--drivers/net/smc911x.c14
-rw-r--r--drivers/net/tigon3.c7
-rw-r--r--drivers/net/xilinx_emac.c12
-rw-r--r--drivers/net/xilinx_emaclite.c11
25 files changed, 131 insertions, 278 deletions
diff --git a/drivers/misc/ali512x.c b/drivers/misc/ali512x.c
index d6a2c1f..cda3b0d 100644
--- a/drivers/misc/ali512x.c
+++ b/drivers/misc/ali512x.c
@@ -34,7 +34,7 @@
#include <common.h>
#include <asm/io.h>
-#include <asm/ic/ali512x.h>
+#include <ali512x.h>
/* ALI M5123 Logical device numbers:
diff --git a/drivers/net/3c589.c b/drivers/net/3c589.c
index 0cf8dff..f2c7d32 100644
--- a/drivers/net/3c589.c
+++ b/drivers/net/3c589.c
@@ -259,10 +259,13 @@ static void el_reset(bd_t *bd)
/* set mac addr */
{
- unsigned char *mac_addr = bd->bi_enetaddr;
+ uchar mac_addr[6];
int i;
- el_get_mac_addr( mac_addr );
+ if (!eth_getenv_enetaddr("ethaddr", mac_addr)) {
+ el_get_mac_addr(mac_addr);
+ eth_setenv_enetaddr("ethaddr", mac_addr);
+ }
GO_WINDOW(2);
VX_BUSY_WAIT;
diff --git a/drivers/net/4xx_enet.c b/drivers/net/4xx_enet.c
index 1978269..918373b 100644
--- a/drivers/net/4xx_enet.c
+++ b/drivers/net/4xx_enet.c
@@ -1927,24 +1927,22 @@ int ppc_4xx_eth_initialize (bd_t * bis)
memcpy(ethaddr[eth_num], "\0\0\0\0\0\0", 6);
for (eth_num = 0; eth_num < LAST_EMAC_NUM; eth_num++) {
+ int ethaddr_idx = eth_num + CONFIG_EMAC_NR_START;
switch (eth_num) {
default: /* fall through */
case 0:
- memcpy(ethaddr[eth_num + CONFIG_EMAC_NR_START],
- bis->bi_enetaddr, 6);
+ eth_getenv_enetaddr("ethaddr", ethaddr[ethaddr_idx]);
hw_addr[eth_num] = 0x0;
break;
#ifdef CONFIG_HAS_ETH1
case 1:
- memcpy(ethaddr[eth_num + CONFIG_EMAC_NR_START],
- bis->bi_enet1addr, 6);
+ eth_getenv_enetaddr("eth1addr", ethaddr[ethaddr_idx]);
hw_addr[eth_num] = 0x100;
break;
#endif
#ifdef CONFIG_HAS_ETH2
case 2:
- memcpy(ethaddr[eth_num + CONFIG_EMAC_NR_START],
- bis->bi_enet2addr, 6);
+ eth_getenv_enetaddr("eth2addr", ethaddr[ethaddr_idx]);
#if defined(CONFIG_460GT)
hw_addr[eth_num] = 0x300;
#else
@@ -1954,8 +1952,7 @@ int ppc_4xx_eth_initialize (bd_t * bis)
#endif
#ifdef CONFIG_HAS_ETH3
case 3:
- memcpy(ethaddr[eth_num + CONFIG_EMAC_NR_START],
- bis->bi_enet3addr, 6);
+ eth_getenv_enetaddr("eth3addr", ethaddr[ethaddr_idx]);
#if defined(CONFIG_460GT)
hw_addr[eth_num] = 0x400;
#else
diff --git a/drivers/net/bcm570x.c b/drivers/net/bcm570x.c
index 185764e..c250d44 100644
--- a/drivers/net/bcm570x.c
+++ b/drivers/net/bcm570x.c
@@ -450,8 +450,8 @@ int eth_init (bd_t * bis)
+ 1);
strcpy (pUmDevice->name, board_info[bcm570xDevices[i].board_id].name);
- memcpy (pDevice->NodeAddress, bis->bi_enetaddr, 6);
- LM_SetMacAddress (pDevice, bis->bi_enetaddr);
+ eth_getenv_enetaddr("ethaddr", pDevice->NodeAddress);
+ LM_SetMacAddress (pDevice);
/* Init queues .. */
QQ_InitQueue (&pUmDevice->rx_out_of_buf_q.Container,
MAX_RX_PACKET_DESC_COUNT);
diff --git a/drivers/net/bcm570x_lm.h b/drivers/net/bcm570x_lm.h
index 2ea6ca8..c07b767 100644
--- a/drivers/net/bcm570x_lm.h
+++ b/drivers/net/bcm570x_lm.h
@@ -371,7 +371,7 @@ LM_STATUS LM_Abort (PLM_DEVICE_BLOCK pDevice);
LM_STATUS LM_MulticastAdd (PLM_DEVICE_BLOCK pDevice, PLM_UINT8 pMcAddress);
LM_STATUS LM_MulticastDel (PLM_DEVICE_BLOCK pDevice, PLM_UINT8 pMcAddress);
LM_STATUS LM_MulticastClear (PLM_DEVICE_BLOCK pDevice);
-LM_STATUS LM_SetMacAddress (PLM_DEVICE_BLOCK pDevice, PLM_UINT8 pMacAddress);
+LM_STATUS LM_SetMacAddress (PLM_DEVICE_BLOCK pDevice);
LM_STATUS LM_LoopbackAddress (PLM_DEVICE_BLOCK pDevice, PLM_UINT8 pAddress);
LM_UINT32 LM_GetCrcCounter (PLM_DEVICE_BLOCK pDevice);
diff --git a/drivers/net/bfin_mac.c b/drivers/net/bfin_mac.c
index 23f934a..12d98c2 100644
--- a/drivers/net/bfin_mac.c
+++ b/drivers/net/bfin_mac.c
@@ -315,7 +315,7 @@ static int bfin_EMAC_init(struct eth_device *dev, bd_t *bd)
return -1;
/* Initialize EMAC address */
- bfin_EMAC_setup_addr(bd);
+ bfin_EMAC_setup_addr(dev->enetaddr);
/* Initialize TX and RX buffer */
for (i = 0; i < PKTBUFSRX; i++) {
@@ -373,16 +373,16 @@ static void bfin_EMAC_halt(struct eth_device *dev)
}
-void bfin_EMAC_setup_addr(bd_t *bd)
+void bfin_EMAC_setup_addr(uchar *enetaddr)
{
*pEMAC_ADDRLO =
- bd->bi_enetaddr[0] |
- bd->bi_enetaddr[1] << 8 |
- bd->bi_enetaddr[2] << 16 |
- bd->bi_enetaddr[3] << 24;
+ enetaddr[0] |
+ enetaddr[1] << 8 |
+ enetaddr[2] << 16 |
+ enetaddr[3] << 24;
*pEMAC_ADDRHI =
- bd->bi_enetaddr[4] |
- bd->bi_enetaddr[5] << 8;
+ enetaddr[4] |
+ enetaddr[5] << 8;
}
ADI_ETHER_BUFFER *SetupRxBuffer(int no)
diff --git a/drivers/net/bfin_mac.h b/drivers/net/bfin_mac.h
index 084f533..8f467a3 100644
--- a/drivers/net/bfin_mac.h
+++ b/drivers/net/bfin_mac.h
@@ -61,6 +61,6 @@ static void bfin_EMAC_halt(struct eth_device *dev);
static int bfin_EMAC_send(struct eth_device *dev, volatile void *packet, int length);
static int bfin_EMAC_recv(struct eth_device *dev);
-static void bfin_EMAC_setup_addr(bd_t *bd);
+void bfin_EMAC_setup_addr(uchar *enetaddr);
#endif
diff --git a/drivers/net/cs8900.c b/drivers/net/cs8900.c
index 35a9baf..0557fcd 100644
--- a/drivers/net/cs8900.c
+++ b/drivers/net/cs8900.c
@@ -110,18 +110,14 @@ static void eth_reginit (void)
put_reg (PP_LineCTL, PP_LineCTL_Rx | PP_LineCTL_Tx);
}
-void cs8900_get_enetaddr (uchar * addr)
+void cs8900_get_enetaddr (void)
{
int i;
- unsigned char env_enetaddr[6];
- char *tmp = getenv ("ethaddr");
- char *end;
-
- for (i=0; i<6; i++) {
- env_enetaddr[i] = tmp ? simple_strtoul(tmp, &end, 16) : 0;
- if (tmp)
- tmp = (*end) ? end+1 : end;
- }
+ uchar enetaddr[6];
+
+ /* if the env is setup, then bail */
+ if (eth_getenv_enetaddr("ethaddr", enetaddr))
+ return;
/* verify chip id */
if (get_reg_init_bus (PP_ChipID) != 0x630e)
@@ -135,35 +131,12 @@ void cs8900_get_enetaddr (uchar * addr)
unsigned int Addr;
Addr = get_reg (PP_IA + i * 2);
- addr[i * 2] = Addr & 0xFF;
- addr[i * 2 + 1] = Addr >> 8;
+ enetaddr[i * 2] = Addr & 0xFF;
+ enetaddr[i * 2 + 1] = Addr >> 8;
}
- if (memcmp(env_enetaddr, "\0\0\0\0\0\0", 6) != 0 &&
- memcmp(env_enetaddr, addr, 6) != 0) {
- printf ("\nWarning: MAC addresses don't match:\n");
- printf ("\tHW MAC address: "
- "%02X:%02X:%02X:%02X:%02X:%02X\n",
- addr[0], addr[1],
- addr[2], addr[3],
- addr[4], addr[5] );
- printf ("\t\"ethaddr\" value: "
- "%02X:%02X:%02X:%02X:%02X:%02X\n",
- env_enetaddr[0], env_enetaddr[1],
- env_enetaddr[2], env_enetaddr[3],
- env_enetaddr[4], env_enetaddr[5]) ;
- debug ("### Set MAC addr from environment\n");
- memcpy (addr, env_enetaddr, 6);
- }
- if (!tmp) {
- char ethaddr[20];
- sprintf (ethaddr, "%02X:%02X:%02X:%02X:%02X:%02X",
- addr[0], addr[1],
- addr[2], addr[3],
- addr[4], addr[5]) ;
- debug ("### Set environment from HW MAC addr = \"%s\"\n", ethaddr);
- setenv ("ethaddr", ethaddr);
- }
+ eth_setenv_enetaddr("ethaddr", enetaddr);
+ debug("### Set environment from HW MAC addr = \"%pM\"\n", enetaddr);
}
}
@@ -178,6 +151,8 @@ void eth_halt (void)
int eth_init (bd_t * bd)
{
+ uchar *enetaddr[6];
+
/* verify chip id */
if (get_reg_init_bus (PP_ChipID) != 0x630e) {
printf ("CS8900 Ethernet chip not found?!\n");
@@ -186,9 +161,10 @@ int eth_init (bd_t * bd)
eth_reset ();
/* set the ethernet address */
- put_reg (PP_IA + 0, bd->bi_enetaddr[0] | (bd->bi_enetaddr[1] << 8));
- put_reg (PP_IA + 2, bd->bi_enetaddr[2] | (bd->bi_enetaddr[3] << 8));
- put_reg (PP_IA + 4, bd->bi_enetaddr[4] | (bd->bi_enetaddr[5] << 8));
+ eth_getenv_enetaddr("ethaddr", enetaddr);
+ put_reg (PP_IA + 0, enetaddr[0] | (enetaddr[1] << 8));
+ put_reg (PP_IA + 2, enetaddr[2] | (enetaddr[3] << 8));
+ put_reg (PP_IA + 4, enetaddr[4] | (enetaddr[5] << 8));
eth_reginit ();
return 0;
diff --git a/drivers/net/dc2114x.c b/drivers/net/dc2114x.c
index c0137a7..5ae53e8 100644
--- a/drivers/net/dc2114x.c
+++ b/drivers/net/dc2114x.c
@@ -752,11 +752,14 @@ static void update_srom(struct eth_device *dev, bd_t *bis)
0x0000, 0x0000, 0x0000, 0x0000, /* 38 */
0x0000, 0x0000, 0x0000, 0x4e07, /* 3c */
};
+ uchar enetaddr[6];
/* Ethernet Addr... */
- eeprom[0x0a] = ((bis->bi_enetaddr[1] & 0xff) << 8) | (bis->bi_enetaddr[0] & 0xff);
- eeprom[0x0b] = ((bis->bi_enetaddr[3] & 0xff) << 8) | (bis->bi_enetaddr[2] & 0xff);
- eeprom[0x0c] = ((bis->bi_enetaddr[5] & 0xff) << 8) | (bis->bi_enetaddr[4] & 0xff);
+ if (!eth_getenv_enetaddr("ethaddr", enetaddr))
+ return;
+ eeprom[0x0a] = (enetaddr[1] << 8) | enetaddr[0];
+ eeprom[0x0b] = (enetaddr[3] << 8) | enetaddr[2];
+ eeprom[0x0c] = (enetaddr[5] << 8) | enetaddr[4];
for (i=0; i<0x40; i++) {
write_srom(dev, DE4X5_APROM, i, eeprom[i]);
diff --git a/drivers/net/dm9000x.c b/drivers/net/dm9000x.c
index ffb739d..c52d307 100644
--- a/drivers/net/dm9000x.c
+++ b/drivers/net/dm9000x.c
@@ -287,6 +287,7 @@ eth_init(bd_t * bd)
int i, oft, lnk;
u8 io_mode;
struct board_info *db = &dm9000_info;
+ uchar enetaddr[6];
DM9000_DBG("eth_init()\n");
@@ -345,32 +346,19 @@ eth_init(bd_t * bd)
DM9000_iow(DM9000_ISR, ISR_ROOS | ISR_ROS | ISR_PTS | ISR_PRS);
/* Set Node address */
+ if (!eth_getenv_enetaddr("ethaddr", enetaddr)) {
#if !defined(CONFIG_AT91SAM9261EK)
- for (i = 0; i < 6; i++)
- ((u16 *) bd->bi_enetaddr)[i] = read_srom_word(i);
+ for (i = 0; i < 6; i++)
+ enetaddr[i] = read_srom_word(i);
+ eth_setenv_enetaddr("ethaddr", enetaddr);
#endif
-
- if (is_zero_ether_addr(bd->bi_enetaddr) ||
- is_multicast_ether_addr(bd->bi_enetaddr)) {
- /* try reading from environment */
- u8 i;
- char *s, *e;
- s = getenv ("ethaddr");
- for (i = 0; i < 6; ++i) {
- bd->bi_enetaddr[i] = s ?
- simple_strtoul (s, &e, 16) : 0;
- if (s)
- s = (*e) ? e + 1 : e;
- }
}
- printf("MAC: %02x:%02x:%02x:%02x:%02x:%02x\n", bd->bi_enetaddr[0],
- bd->bi_enetaddr[1], bd->bi_enetaddr[2], bd->bi_enetaddr[3],
- bd->bi_enetaddr[4], bd->bi_enetaddr[5]);
+ printf("MAC: %pM\n", enetaddr);
/* fill device MAC address registers */
for (i = 0, oft = DM9000_PAR; i < 6; i++, oft++)
- DM9000_iow(oft, bd->bi_enetaddr[i]);
+ DM9000_iow(oft, enetaddr[i]);
for (i = 0, oft = 0x16; i < 8; i++, oft++)
DM9000_iow(oft, 0xff);
diff --git a/drivers/net/enc28j60.c b/drivers/net/enc28j60.c
index 5c24b0d..3238a50 100644
--- a/drivers/net/enc28j60.c
+++ b/drivers/net/enc28j60.c
@@ -330,6 +330,7 @@ static int rxResetCounter = 0;
int eth_init (bd_t * bis)
{
unsigned char estatVal;
+ uchar enetaddr[6];
/* configure GPIO */
(*((volatile unsigned long *) IO1DIR)) |= ENC_SPI_SLAVE_CS;
@@ -351,7 +352,8 @@ int eth_init (bd_t * bis)
/* initialize controller */
encReset ();
- encInit (bis->bi_enetaddr);
+ eth_getenv_enetaddr("ethaddr", enetaddr);
+ encInit (enetaddr);
m_nic_bfs (CTL_REG_ECON1, ENC_ECON1_RXEN); /* enable receive */
diff --git a/drivers/net/fsl_mcdmafec.c b/drivers/net/fsl_mcdmafec.c
index d056010..35a6dfb 100644
--- a/drivers/net/fsl_mcdmafec.c
+++ b/drivers/net/fsl_mcdmafec.c
@@ -369,6 +369,7 @@ static int fec_init(struct eth_device *dev, bd_t * bd)
struct fec_info_dma *info = dev->priv;
volatile fecdma_t *fecp = (fecdma_t *) (info->iobase);
int i;
+ uchar enetaddr[6];
#ifdef ET_DEBUG
printf("fec_init: iobase 0x%08x ...\n", info->iobase);
@@ -397,11 +398,11 @@ static int fec_init(struct eth_device *dev, bd_t * bd)
fecp->eir = 0xffffffff;
/* Set station address */
- if ((u32) fecp == CONFIG_SYS_FEC0_IOBASE) {
- fec_set_hwaddr(fecp, bd->bi_enetaddr);
- } else {
- fec_set_hwaddr(fecp, bd->bi_enet1addr);
- }
+ if ((u32) fecp == CONFIG_SYS_FEC0_IOBASE)
+ eth_getenv_enetaddr("ethaddr", enetaddr);
+ else
+ eth_getenv_enetaddr("eth1addr", enetaddr);
+ fec_set_hwaddr(fecp, enetaddr);
/* Set Opcode/Pause Duration Register */
fecp->opd = 0x00010020;
diff --git a/drivers/net/ks8695eth.c b/drivers/net/ks8695eth.c
index 7f3e0c2..5ea6e7f 100644
--- a/drivers/net/ks8695eth.c
+++ b/drivers/net/ks8695eth.c
@@ -150,13 +150,7 @@ void eth_reset(bd_t *bd)
ks8695_write(KS8695_LAN_DMA_RX, 0x71);
ks8695_write(KS8695_LAN_DMA_RX_START, 0x1);
- printf("KS8695 ETHERNET: ");
- for (i = 0; (i < 5); i++) {
- bd->bi_enetaddr[i] = eth_mac[i];
- printf("%02x:", eth_mac[i]);
- }
- bd->bi_enetaddr[i] = eth_mac[i];
- printf("%02x\n", eth_mac[i]);
+ printf("KS8695 ETHERNET: %pM\n", eth_mac);
}
/****************************************************************************/
diff --git a/drivers/net/lan91c96.c b/drivers/net/lan91c96.c
index 318bdf4..65565bc 100644
--- a/drivers/net/lan91c96.c
+++ b/drivers/net/lan91c96.c
@@ -606,10 +606,8 @@ static int smc_open (bd_t *bd)
SMC_SELECT_BANK (1);
err = smc_get_ethaddr (bd); /* set smc_mac_addr, and sync it with u-boot globals */
- if (err < 0) {
- memset (bd->bi_enetaddr, 0, 6); /* hack to make error stick! upper code will abort if not set */
- return (-1); /* upper code ignores this, but NOT bi_enetaddr */
- }
+ if (err < 0)
+ return -1;
#ifdef USE_32_BIT
for (i = 0; i < 6; i += 2) {
word address;
@@ -869,69 +867,20 @@ static int smc_hw_init ()
int smc_get_ethaddr (bd_t * bd)
{
- int env_size = 0;
- int rom_valid = 0;
- int env_present = 0;
- int reg = 0;
- char *s = NULL;
- char *e = NULL;
- char *v_mac, es[] = "11:22:33:44:55:66";
- char s_env_mac[64];
- uchar v_env_mac[6];
- uchar v_rom_mac[6];
-
- env_size = getenv_r ("ethaddr", s_env_mac, sizeof (s_env_mac));
- if (env_size != sizeof(es)) { /* Ignore if env is bad or not set */
- printf ("\n*** Warning: ethaddr is not set properly, ignoring!!\n");
- } else {
- env_present = 1;
- s = s_env_mac;
-
- for (reg = 0; reg < 6; ++reg) { /* turn string into mac value */
- v_env_mac[reg] = s ? simple_strtoul (s, &e, 16) : 0;
- if (s)
- s = (*e) ? e + 1 : e;
- }
- }
+ uchar v_mac[6];
- rom_valid = get_rom_mac (v_rom_mac); /* get ROM mac value if any */
-
- if (!env_present) { /* if NO env */
- if (rom_valid) { /* but ROM is valid */
- v_mac = (char *)v_rom_mac;
- sprintf (s_env_mac, "%02X:%02X:%02X:%02X:%02X:%02X",
- v_mac[0], v_mac[1], v_mac[2], v_mac[3],
- v_mac[4], v_mac[5]);
- setenv ("ethaddr", s_env_mac);
- } else { /* no env, bad ROM */
- printf ("\n*** ERROR: ethaddr is NOT set !!\n");
- return (-1);
+ if (!eth_getenv_enetaddr("ethaddr", v_mac)) {
+ /* get ROM mac value if any */
+ if (!get_rom_mac(v_mac)) {
+ printf("\n*** ERROR: ethaddr is NOT set !!\n");
+ return -1;
}
- } else { /* good env, don't care ROM */
- v_mac = (char *)v_env_mac; /* always use a good env over a ROM */
+ eth_setenv_enetaddr("ethaddr", v_mac);
}
- if (env_present && rom_valid) { /* if both env and ROM are good */
- if (memcmp (v_env_mac, v_rom_mac, 6) != 0) {
- printf ("\nWarning: MAC addresses don't match:\n");
- printf ("\tHW MAC address: "
- "%02X:%02X:%02X:%02X:%02X:%02X\n",
- v_rom_mac[0], v_rom_mac[1],
- v_rom_mac[2], v_rom_mac[3],
- v_rom_mac[4], v_rom_mac[5] );
- printf ("\t\"ethaddr\" value: "
- "%02X:%02X:%02X:%02X:%02X:%02X\n",
- v_env_mac[0], v_env_mac[1],
- v_env_mac[2], v_env_mac[3],
- v_env_mac[4], v_env_mac[5]) ;
- debug ("### Set MAC addr from environment\n");
- }
- }
- memcpy (bd->bi_enetaddr, v_mac, 6); /* update global address to match env (allows env changing) */
- smc_set_mac_addr ((unsigned char *)v_mac); /* use old function to update smc default */
- PRINTK("Using MAC Address %02X:%02X:%02X:%02X:%02X:%02X\n", v_mac[0], v_mac[1],
- v_mac[2], v_mac[3], v_mac[4], v_mac[5]);
- return (0);
+ smc_set_mac_addr(v_mac); /* use old function to update smc default */
+ PRINTK("Using MAC Address %pM\n", v_mac);
+ return 0;
}
/*
diff --git a/drivers/net/mcffec.c b/drivers/net/mcffec.c
index 18240a8..64be5de 100644
--- a/drivers/net/mcffec.c
+++ b/drivers/net/mcffec.c
@@ -416,7 +416,7 @@ int fec_init(struct eth_device *dev, bd_t * bd)
struct fec_info_s *info = dev->priv;
volatile fec_t *fecp = (fec_t *) (info->iobase);
int i;
- u8 *ea = NULL;
+ uchar ea[6];
fecpin_setclear(dev, 1);
@@ -444,25 +444,25 @@ int fec_init(struct eth_device *dev, bd_t * bd)
if ((u32) fecp == CONFIG_SYS_FEC0_IOBASE) {
#ifdef CONFIG_SYS_FEC1_IOBASE
volatile fec_t *fecp1 = (fec_t *) (CONFIG_SYS_FEC1_IOBASE);
- ea = &bd->bi_enet1addr[0];
+ eth_getenv_enetaddr("eth1addr", ea);
fecp1->palr =
(ea[0] << 24) | (ea[1] << 16) | (ea[2] << 8) | (ea[3]);
fecp1->paur = (ea[4] << 24) | (ea[5] << 16);
#endif
- ea = &bd->bi_enetaddr[0];
+ eth_getenv_enetaddr("ethaddr", ea);
fecp->palr =
(ea[0] << 24) | (ea[1] << 16) | (ea[2] << 8) | (ea[3]);
fecp->paur = (ea[4] << 24) | (ea[5] << 16);
} else {
#ifdef CONFIG_SYS_FEC0_IOBASE
volatile fec_t *fecp0 = (fec_t *) (CONFIG_SYS_FEC0_IOBASE);
- ea = &bd->bi_enetaddr[0];
+ eth_getenv_enetaddr("ethaddr", ea);
fecp0->palr =
(ea[0] << 24) | (ea[1] << 16) | (ea[2] << 8) | (ea[3]);
fecp0->paur = (ea[4] << 24) | (ea[5] << 16);
#endif
#ifdef CONFIG_SYS_FEC1_IOBASE
- ea = &bd->bi_enet1addr[0];
+ eth_getenv_enetaddr("eth1addr", ea);
fecp->palr =
(ea[0] << 24) | (ea[1] << 16) | (ea[2] << 8) | (ea[3]);
fecp->paur = (ea[4] << 24) | (ea[5] << 16);
diff --git a/drivers/net/rtl8019.c b/drivers/net/rtl8019.c
index 3ddf917..f516afe 100644
--- a/drivers/net/rtl8019.c
+++ b/drivers/net/rtl8019.c
@@ -91,6 +91,7 @@ void eth_halt (void)
int eth_init (bd_t * bd)
{
+ uchar enetaddr[6];
eth_reset ();
put_reg (RTL8019_COMMAND, RTL8019_PAGE0STOP);
put_reg (RTL8019_DATACONFIGURATION, 0x48);
@@ -105,12 +106,13 @@ int eth_init (bd_t * bd)
put_reg (RTL8019_INTERRUPTSTATUS, 0xff);
put_reg (RTL8019_INTERRUPTMASK, 0x11); /*b; */
put_reg (RTL8019_COMMAND, RTL8019_PAGE1STOP);
- put_reg (RTL8019_PHYSICALADDRESS0, bd->bi_enetaddr[0]);
- put_reg (RTL8019_PHYSICALADDRESS1, bd->bi_enetaddr[1]);
- put_reg (RTL8019_PHYSICALADDRESS2, bd->bi_enetaddr[2]);
- put_reg (RTL8019_PHYSICALADDRESS3, bd->bi_enetaddr[3]);
- put_reg (RTL8019_PHYSICALADDRESS4, bd->bi_enetaddr[4]);
- put_reg (RTL8019_PHYSICALADDRESS5, bd->bi_enetaddr[5]);
+ eth_getenv_enetaddr("ethaddr", enetaddr);
+ put_reg (RTL8019_PHYSICALADDRESS0, enetaddr[0]);
+ put_reg (RTL8019_PHYSICALADDRESS1, enetaddr[1]);
+ put_reg (RTL8019_PHYSICALADDRESS2, enetaddr[2]);
+ put_reg (RTL8019_PHYSICALADDRESS3, enetaddr[3]);
+ put_reg (RTL8019_PHYSICALADDRESS4, enetaddr[4]);
+ put_reg (RTL8019_PHYSICALADDRESS5, enetaddr[5]);
put_reg (RTL8019_MULTIADDRESS0, 0x00);
put_reg (RTL8019_MULTIADDRESS1, 0x00);
put_reg (RTL8019_MULTIADDRESS2, 0x00);
diff --git a/drivers/net/rtl8169.c b/drivers/net/rtl8169.c
index e9f6391..f8c14b4 100644
--- a/drivers/net/rtl8169.c
+++ b/drivers/net/rtl8169.c
@@ -750,7 +750,7 @@ static int rtl_init(struct eth_device *dev, bd_t *bis)
/* Get MAC address. FIXME: read EEPROM */
for (i = 0; i < MAC_ADDR_LEN; i++)
- bis->bi_enetaddr[i] = dev->enetaddr[i] = RTL_R8(MAC0 + i);
+ dev->enetaddr[i] = RTL_R8(MAC0 + i);
#ifdef DEBUG_RTL8169
printf("chipset = %d\n", tpc->chipset);
diff --git a/drivers/net/s3c4510b_eth.c b/drivers/net/s3c4510b_eth.c
index 6dcb244..818ed3d 100644
--- a/drivers/net/s3c4510b_eth.c
+++ b/drivers/net/s3c4510b_eth.c
@@ -100,7 +100,7 @@ int eth_init(bd_t *bis)
ETH *eth = &m_eth;
/* store our MAC address */
- eth->m_mac = bis->bi_enetaddr;
+ eth_getenv_enetaddr("ethaddr", eth->m_mac);
/* setup DBMA and MAC */
PUT_REG( REG_BDMARXCON, ETH_BRxRS); /* reset BDMA RX machine */
diff --git a/drivers/net/s3c4510b_eth.h b/drivers/net/s3c4510b_eth.h
index 048307f..18a52a7 100644
--- a/drivers/net/s3c4510b_eth.h
+++ b/drivers/net/s3c4510b_eth.h
@@ -296,7 +296,7 @@ typedef struct __ETH {
TX_FrameDescriptor *m_baseTX_FD; /* pointer to base TX frame descriptor */
RX_FrameDescriptor *m_curRX_FD; /* pointer to current RX frame descriptor */
RX_FrameDescriptor *m_baseRX_FD; /* pointer to base RX frame descriptor */
- u8 *m_mac; /* pointer to our MAC address */
+ u8 m_mac[6]; /* pointer to our MAC address */
} ETH;
#endif
diff --git a/drivers/net/sh_eth.c b/drivers/net/sh_eth.c
index bee3f02..f24ded2 100644
--- a/drivers/net/sh_eth.c
+++ b/drivers/net/sh_eth.c
@@ -514,6 +514,7 @@ static int sh_eth_config(struct sh_eth_dev *eth, bd_t *bd)
int port = eth->port, ret = 0;
u32 val, phy_status;
struct sh_eth_info *port_info = &eth->port_info[port];
+ struct eth_device *dev = port_info->dev;
/* Configure e-dmac registers */
outl((inl(EDMR(port)) & ~EMDR_DESC_R) | EDMR_EL, EDMR(port));
@@ -529,11 +530,11 @@ static int sh_eth_config(struct sh_eth_dev *eth, bd_t *bd)
outl(0, ECSIPR(port));
/* Set Mac address */
- val = bd->bi_enetaddr[0] << 24 | bd->bi_enetaddr[1] << 16 |
- bd->bi_enetaddr[2] << 8 | bd->bi_enetaddr[3];
+ val = dev->enetaddr[0] << 24 | dev->enetaddr[1] << 16 |
+ dev->enetaddr[2] << 8 | dev->enetaddr[3];
outl(val, MAHR(port));
- val = bd->bi_enetaddr[4] << 8 | bd->bi_enetaddr[5];
+ val = dev->enetaddr[4] << 8 | dev->enetaddr[5];
outl(val, MALR(port));
outl(RFLR_RFL_MIN, RFLR(port));
@@ -589,24 +590,6 @@ static void sh_eth_stop(struct sh_eth_dev *eth)
outl(~EDRRR_R, EDRRR(eth->port));
}
-static int sh_eth_get_mac(bd_t *bd)
-{
- char *s, *e;
-
- s = getenv("ethaddr");
- if (s != NULL) {
- int i;
- for (i = 0; i < 6; ++i) {
- bd->bi_enetaddr[i] = s ? simple_strtoul(s, &e, 16) : 0;
- if (s)
- s = (*e) ? e + 1 : e;
- }
- } else {
- puts("Please set MAC address\n");
- }
- return 0;
-}
-
int sh_eth_init(struct eth_device *dev, bd_t *bd)
{
int ret = 0;
@@ -680,7 +663,8 @@ int sh_eth_initialize(bd_t *bd)
/* Register Device to EtherNet subsystem */
eth_register(dev);
- sh_eth_get_mac(bd);
+ if (!eth_getenv_enetaddr("ethaddr", dev->enetaddr))
+ puts("Please set MAC address\n");
return ret;
diff --git a/drivers/net/smc91111.c b/drivers/net/smc91111.c
index 82abb02..b41e4d2 100644
--- a/drivers/net/smc91111.c
+++ b/drivers/net/smc91111.c
@@ -834,10 +834,8 @@ static int smc_open (bd_t * bd)
SMC_SELECT_BANK (1);
err = smc_get_ethaddr (bd); /* set smc_mac_addr, and sync it with u-boot globals */
- if (err < 0) {
- memset (bd->bi_enetaddr, 0, 6); /* hack to make error stick! upper code will abort if not set */
- return (-1); /* upper code ignores this, but NOT bi_enetaddr */
- }
+ if (err < 0)
+ return -1;
#ifdef USE_32_BIT
for (i = 0; i < 6; i += 2) {
word address;
@@ -1535,66 +1533,20 @@ int eth_send(volatile void *packet, int length) {
int smc_get_ethaddr (bd_t * bd)
{
- int env_size, rom_valid, env_present = 0, reg;
- char *s = NULL, *e, es[] = "11:22:33:44:55:66";
- char s_env_mac[64];
- uchar v_env_mac[6], v_rom_mac[6], *v_mac;
-
- env_size = getenv_r ("ethaddr", s_env_mac, sizeof (s_env_mac));
- if ((env_size > 0) && (env_size < sizeof (es))) { /* exit if env is bad */
- printf ("\n*** ERROR: ethaddr is not set properly!!\n");
- return (-1);
- }
+ uchar v_mac[6];
- if (env_size > 0) {
- env_present = 1;
- s = s_env_mac;
- }
-
- for (reg = 0; reg < 6; ++reg) { /* turn string into mac value */
- v_env_mac[reg] = s ? simple_strtoul (s, &e, 16) : 0;
- if (s)
- s = (*e) ? e + 1 : e;
- }
-
- rom_valid = get_rom_mac (v_rom_mac); /* get ROM mac value if any */
-
- if (!env_present) { /* if NO env */
- if (rom_valid) { /* but ROM is valid */
- v_mac = v_rom_mac;
- sprintf (s_env_mac, "%02X:%02X:%02X:%02X:%02X:%02X",
- v_mac[0], v_mac[1], v_mac[2], v_mac[3],
- v_mac[4], v_mac[5]);
- setenv ("ethaddr", s_env_mac);
- } else { /* no env, bad ROM */
- printf ("\n*** ERROR: ethaddr is NOT set !!\n");
- return (-1);
+ if (!eth_getenv_enetaddr("ethaddr", v_mac)) {
+ /* get ROM mac value if any */
+ if (!get_rom_mac(v_mac)) {
+ printf("\n*** ERROR: ethaddr is NOT set !!\n");
+ return -1;
}
- } else { /* good env, don't care ROM */
- v_mac = v_env_mac; /* always use a good env over a ROM */
+ eth_setenv_enetaddr("ethaddr", v_mac);
}
- if (env_present && rom_valid) { /* if both env and ROM are good */
- if (memcmp (v_env_mac, v_rom_mac, 6) != 0) {
- printf ("\nWarning: MAC addresses don't match:\n");
- printf ("\tHW MAC address: "
- "%02X:%02X:%02X:%02X:%02X:%02X\n",
- v_rom_mac[0], v_rom_mac[1],
- v_rom_mac[2], v_rom_mac[3],
- v_rom_mac[4], v_rom_mac[5] );
- printf ("\t\"ethaddr\" value: "
- "%02X:%02X:%02X:%02X:%02X:%02X\n",
- v_env_mac[0], v_env_mac[1],
- v_env_mac[2], v_env_mac[3],
- v_env_mac[4], v_env_mac[5]) ;
- debug ("### Set MAC addr from environment\n");
- }
- }
- memcpy (bd->bi_enetaddr, v_mac, 6); /* update global address to match env (allows env changing) */
- smc_set_mac_addr ((uchar *)v_mac); /* use old function to update smc default */
- PRINTK("Using MAC Address %02X:%02X:%02X:%02X:%02X:%02X\n", v_mac[0], v_mac[1],
- v_mac[2], v_mac[3], v_mac[4], v_mac[5]);
- return (0);
+ smc_set_mac_addr(v_mac); /* use old function to update smc default */
+ PRINTK("Using MAC Address %pM\n", v_mac);
+ return 0;
}
int get_rom_mac (uchar *v_rom_mac)
diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c
index 1ded8f0..30f2dc2 100644
--- a/drivers/net/smc911x.c
+++ b/drivers/net/smc911x.c
@@ -39,15 +39,10 @@ void pkt_data_push(u32 addr, u32 val) \
static int smx911x_handle_mac_address(bd_t *bd)
{
unsigned long addrh, addrl;
- unsigned char *m = bd->bi_enetaddr;
+ uchar m[6];
/* if the environment has a valid mac address then use it */
- if ((m[0] | m[1] | m[2] | m[3] | m[4] | m[5])) {
- addrl = m[0] | m[1] << 8 | m[2] << 16 | m[3] << 24;
- addrh = m[4] | m[5] << 8;
- smc911x_set_mac_csr(ADDRH, addrh);
- smc911x_set_mac_csr(ADDRL, addrl);
- } else {
+ if (!eth_getenv_enetaddr("ethaddr", m)) {
/* if not, try to get one from the eeprom */
addrh = smc911x_get_mac_csr(ADDRH);
addrl = smc911x_get_mac_csr(ADDRL);
@@ -65,10 +60,11 @@ static int smx911x_handle_mac_address(bd_t *bd)
"and no eeprom found\n");
return -1;
}
+
+ eth_setenv_enetaddr("ethaddr", m);
}
- printf(DRIVERNAME ": MAC %02x:%02x:%02x:%02x:%02x:%02x\n",
- m[0], m[1], m[2], m[3], m[4], m[5]);
+ printf(DRIVERNAME ": MAC %pM\n", m);
return 0;
}
diff --git a/drivers/net/tigon3.c b/drivers/net/tigon3.c
index e4e004e..33cb447 100644
--- a/drivers/net/tigon3.c
+++ b/drivers/net/tigon3.c
@@ -2463,7 +2463,7 @@ LM_STATUS LM_ResetAdapter (PLM_DEVICE_BLOCK pDevice)
#endif /* T3_JUMBO_RCV_ENTRY_COUNT */
/* Configure the MAC address. */
- LM_SetMacAddress (pDevice, pDevice->NodeAddress);
+ LM_SetMacAddress (pDevice);
/* Initialize the transmit random backoff seed. */
Value32 = (pDevice->NodeAddress[0] + pDevice->NodeAddress[1] +
@@ -3428,7 +3428,7 @@ LM_STATUS LM_Halt (PLM_DEVICE_BLOCK pDevice)
(pDevice->SubsystemId << 16) | pDevice->SubsystemVendorId);
/* Reprogram the MAC address. */
- LM_SetMacAddress (pDevice, pDevice->NodeAddress);
+ LM_SetMacAddress (pDevice);
return LM_STATUS_SUCCESS;
} /* LM_Halt */
@@ -3833,9 +3833,10 @@ LM_STATUS LM_MulticastClear (PLM_DEVICE_BLOCK pDevice)
/* */
/* Return: */
/******************************************************************************/
-LM_STATUS LM_SetMacAddress (PLM_DEVICE_BLOCK pDevice, PLM_UINT8 pMacAddress)
+LM_STATUS LM_SetMacAddress (PLM_DEVICE_BLOCK pDevice)
{
LM_UINT32 j;
+ PLM_UINT8 pMacAddress = pDevice->NodeAddress;
for (j = 0; j < 4; j++) {
REG_WR (pDevice, MacCtrl.MacAddr[j].High,
diff --git a/drivers/net/xilinx_emac.c b/drivers/net/xilinx_emac.c
index c7f1a2a..a489aa9 100644
--- a/drivers/net/xilinx_emac.c
+++ b/drivers/net/xilinx_emac.c
@@ -166,6 +166,7 @@ void eth_halt(void)
int eth_init(bd_t * bis)
{
+ uchar enetaddr[6];
u32 helpreg;
debug ("EMAC Initialization Started\n\r");
@@ -200,15 +201,16 @@ int eth_init(bd_t * bis)
helpreg &= ~(XEM_ECR_XMIT_ENABLE_MASK | XEM_ECR_RECV_ENABLE_MASK);
out_be32 (emac.baseaddress + XEM_ECR_OFFSET, helpreg);
- if (!getenv("ethaddr")) {
- memcpy(bis->bi_enetaddr, emacaddr, ENET_ADDR_LENGTH);
+ if (!eth_getenv_enetaddr("ethaddr", enetaddr)) {
+ memcpy(enetaddr, emacaddr, ENET_ADDR_LENGTH);
+ eth_setenv_enetaddr("ethaddr", enetaddr);
}
/* Set the device station address high and low registers */
- helpreg = (bis->bi_enetaddr[0] << 8) | bis->bi_enetaddr[1];
+ helpreg = (enetaddr[0] << 8) | enetaddr[1];
out_be32 (emac.baseaddress + XEM_SAH_OFFSET, helpreg);
- helpreg = (bis->bi_enetaddr[2] << 24) | (bis->bi_enetaddr[3] << 16) |
- (bis->bi_enetaddr[4] << 8) | bis->bi_enetaddr[5];
+ helpreg = (enetaddr[2] << 24) | (enetaddr[3] << 16) |
+ (enetaddr[4] << 8) | enetaddr[5];
out_be32 (emac.baseaddress + XEM_SAL_OFFSET, helpreg);
helpreg = XEM_ECR_UNICAST_ENABLE_MASK | XEM_ECR_BROAD_ENABLE_MASK |
diff --git a/drivers/net/xilinx_emaclite.c b/drivers/net/xilinx_emaclite.c
index 0e96ef1..cf39573 100644
--- a/drivers/net/xilinx_emaclite.c
+++ b/drivers/net/xilinx_emaclite.c
@@ -140,12 +140,15 @@ void eth_halt (void)
int eth_init (bd_t * bis)
{
+ uchar enetaddr[6];
+
debug ("EmacLite Initialization Started\n");
memset (&emaclite, 0, sizeof (xemaclite));
emaclite.baseaddress = XILINX_EMACLITE_BASEADDR;
- if (!getenv("ethaddr")) {
- memcpy(bis->bi_enetaddr, emacaddr, ENET_ADDR_LENGTH);
+ if (!eth_getenv_enetaddr("ethaddr", enetaddr)) {
+ memcpy(enetaddr, emacaddr, ENET_ADDR_LENGTH);
+ eth_setenv_enetaddr("ethaddr", enetaddr);
}
/*
@@ -154,7 +157,7 @@ int eth_init (bd_t * bis)
/* Restart PING TX */
out_be32 (emaclite.baseaddress + XEL_TSR_OFFSET, 0);
/* Copy MAC address */
- xemaclite_alignedwrite (bis->bi_enetaddr,
+ xemaclite_alignedwrite (enetaddr,
emaclite.baseaddress, ENET_ADDR_LENGTH);
/* Set the length */
out_be32 (emaclite.baseaddress + XEL_TPLR_OFFSET, ENET_ADDR_LENGTH);
@@ -167,7 +170,7 @@ int eth_init (bd_t * bis)
#ifdef CONFIG_XILINX_EMACLITE_TX_PING_PONG
/* The same operation with PONG TX */
out_be32 (emaclite.baseaddress + XEL_TSR_OFFSET + XEL_BUFFER_OFFSET, 0);
- xemaclite_alignedwrite (bis->bi_enetaddr, emaclite.baseaddress +
+ xemaclite_alignedwrite (enetaddr, emaclite.baseaddress +
XEL_BUFFER_OFFSET, ENET_ADDR_LENGTH);
out_be32 (emaclite.baseaddress + XEL_TPLR_OFFSET, ENET_ADDR_LENGTH);
out_be32 (emaclite.baseaddress + XEL_TSR_OFFSET + XEL_BUFFER_OFFSET,