/* 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;
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
#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
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]);
int i, oft, lnk;
u8 io_mode;
struct board_info *db = &dm9000_info;
+ uchar enetaddr[6];
DM9000_DBG("eth_init()\n");
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);
int eth_init (bd_t * bis)
{
unsigned char estatVal;
+ uchar enetaddr[6];
/* configure GPIO */
(*((volatile unsigned long *) IO1DIR)) |= ENC_SPI_SLAVE_CS;
/* 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 */
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);
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;
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);
}
/****************************************************************************/
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);
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);
int eth_init (bd_t * bd)
{
+ uchar enetaddr[6];
eth_reset ();
put_reg (RTL8019_COMMAND, RTL8019_PAGE0STOP);
put_reg (RTL8019_DATACONFIGURATION, 0x48);
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);
/* 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);
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 */
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
int eth_init(bd_t * bis)
{
+ uchar enetaddr[6];
u32 helpreg;
debug ("EMAC Initialization Started\n\r");
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 |
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);
}
/*
/* 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);
#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,