int eth_init (bd_t * bd)
{
u32 ID;
int i,j;
u16 * mac =(u16 *) bd->bi_enetaddr;
ID = GetDM9000ID();
if ( ID != DM9000_ID)
{
printf("not found the dm9000 ID:%x\n",ID);
return 1;
}
printf("Found DM9000 ID:%x at address %x !\n", ID, DM9000_BASE);
dmfe_init_dm9000();
{
int env_size;
char *s = NULL, *e = NULL;
unsigned char env_mac[20];
env_size = getenv_r("ethaddr", env_mac, sizeof(env_mac));
if(env_size != 18)
{
printf("\n***ERROR: ethaddr is not set properly!!\n");
#if 0
for (i=0; i<3; i++) /* read MAC from EEPROM */
mac[i]= read_srom_word(i);
#else
mac[0]=0x1100;
mac[1]=0x3322;
mac[2]=0x5544;
#endif
}
else
{
s = env_mac;
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("bd->bi_entaddr: %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("[eth_init]MAC:");
for(i=0,j=0x10; i<6; i++,j++)
{
iow(j,bd->bi_enetaddr[i]);
printf("%x:",bd->bi_enetaddr[i]);
}
printf("\n");
return 0;
}
{
u32 ID;
int i,j;
u16 * mac =(u16 *) bd->bi_enetaddr;
ID = GetDM9000ID();
if ( ID != DM9000_ID)
{
printf("not found the dm9000 ID:%x\n",ID);
return 1;
}
printf("Found DM9000 ID:%x at address %x !\n", ID, DM9000_BASE);
dmfe_init_dm9000();
{
int env_size;
char *s = NULL, *e = NULL;
unsigned char env_mac[20];
env_size = getenv_r("ethaddr", env_mac, sizeof(env_mac));
if(env_size != 18)
{
printf("\n***ERROR: ethaddr is not set properly!!\n");
#if 0
for (i=0; i<3; i++) /* read MAC from EEPROM */
mac[i]= read_srom_word(i);
#else
mac[0]=0x1100;
mac[1]=0x3322;
mac[2]=0x5544;
#endif
}
else
{
s = env_mac;
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("bd->bi_entaddr: %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("[eth_init]MAC:");
for(i=0,j=0x10; i<6; i++,j++)
{
iow(j,bd->bi_enetaddr[i]);
printf("%x:",bd->bi_enetaddr[i]);
}
printf("\n");
return 0;
}