static int on_ethaddr(const char *name, const char *value, enum env_op op, int flags) { int index; int retval; struct udevice *dev; /* look for an index after "eth" */ index = simple_strtoul(name + 3, NULL, 10); retval = uclass_find_device_by_seq(UCLASS_ETH, index, false, &dev); if (!retval) { struct eth_pdata *pdata = dev->platdata; switch (op) { case env_op_create: case env_op_overwrite: eth_parse_enetaddr(value, pdata->enetaddr); eth_write_hwaddr(dev); break; case env_op_delete: memset(pdata->enetaddr, 0, ARP_HLEN); } } return 0; }
static void set_mac_to_sh_giga_eth_register(int channel, char *mac_string) { struct ether_mac_regs *ether; unsigned char mac[6]; unsigned long val; eth_parse_enetaddr(mac_string, mac); if (!channel) ether = GETHER0_MAC_BASE; else ether = GETHER1_MAC_BASE; val = (mac[0] << 24) | (mac[1] << 16) | (mac[2] << 8) | mac[3]; writel(val, ðer->mahr); val = (mac[4] << 8) | mac[5]; writel(val, ðer->malr); }
int eth_initialize(bd_t *bis) { unsigned char rt2880_gmac1_mac[6]; int eth_number = 0, regValue=0; eth_devices = NULL; eth_current = NULL; #ifdef CONFIG_DB64360 mv6436x_eth_initialize(bis); #endif #ifdef CONFIG_CPCI750 mv6436x_eth_initialize(bis); #endif #ifdef CONFIG_DB64460 mv6446x_eth_initialize(bis); #endif #if defined(CONFIG_405GP) || defined(CONFIG_405EP) || \ ( defined(CONFIG_440) && !defined(CONFIG_NET_MULTI) ) ppc_4xx_eth_initialize(bis); #endif #if defined(CONFIG_440) && defined(CONFIG_NET_MULTI) ppc_440x_eth_initialize(bis); #endif #ifdef CONFIG_INCA_IP_SWITCH inca_switch_initialize(bis); #endif #ifdef CONFIG_PLB2800_ETHER plb2800_eth_initialize(bis); #endif #ifdef SCC_ENET scc_initialize(bis); #endif #if defined(FEC_ENET) || defined(CONFIG_ETHER_ON_FCC) fec_initialize(bis); #endif #if defined(CONFIG_MPC5xxx_FEC) mpc5xxx_fec_initialize(bis); #endif #if defined(CONFIG_MPC8220) mpc8220_fec_initialize(bis); #endif #if defined(CONFIG_SK98) skge_initialize(bis); #endif #if defined(CONFIG_MPC85XX_TSEC1) tsec_initialize(bis, 0); #endif #if defined(CONFIG_MPC85XX_TSEC2) tsec_initialize(bis, 1); #endif #if defined(CONFIG_MPC85XX_FEC) tsec_initialize(bis, 2); #endif #if defined(CONFIG_AU1X00) au1x00_enet_initialize(bis); #endif #ifdef CONFIG_E1000 e1000_initialize(bis); #endif #ifdef CONFIG_EEPRO100 eepro100_initialize(bis); #endif #ifdef CONFIG_TULIP dc21x4x_initialize(bis); #endif #ifdef CONFIG_3COM eth_3com_initialize(bis); #endif #ifdef CONFIG_PCNET pcnet_initialize(bis); #endif #ifdef CFG_GT_6426x gt6426x_eth_initialize(bis); #endif #ifdef CONFIG_NATSEMI natsemi_initialize(bis); #endif #ifdef CONFIG_NS8382X ns8382x_initialize(bis); #endif #if defined(CONFIG_RTL8139) rtl8139_initialize(bis); #endif #if defined(CONFIG_RTL8169) rtl8169_initialize(bis); #endif #if defined(CONFIG_RT2880_ETH) rt2880_eth_initialize(bis); #endif if (!eth_devices) { puts ("No ethernet found.\n"); } else { struct eth_device *dev = eth_devices; char *ethprime = getenv ("ethprime"); unsigned char empty_mac[6]={0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; do { if (eth_number) puts (", "); if (ethprime && strcmp (dev->name, ethprime) == 0) { eth_current = dev; puts (" [PRIME]"); } #if defined (MT7621_MP) #define GMAC0_OFFSET 0xE000 #else #define GMAC0_OFFSET 0x28 #endif //get Ethernet mac address from flash #if defined (CFG_ENV_IS_IN_NAND) ranand_read(rt2880_gmac1_mac, CFG_FACTORY_ADDR - CFG_FLASH_BASE + GMAC0_OFFSET, 6); #elif defined (CFG_ENV_IS_IN_SPI) raspi_read(rt2880_gmac1_mac, CFG_FACTORY_ADDR - CFG_FLASH_BASE + GMAC0_OFFSET, 6); #else //CFG_ENV_IS_IN_FLASH memmove(rt2880_gmac1_mac, CFG_FACTORY_ADDR + GMAC0_OFFSET, 6); #endif //if flash is empty, use default mac address if (memcmp(rt2880_gmac1_mac, empty_mac, 6) == 0) eth_parse_enetaddr(CONFIG_ETHADDR, rt2880_gmac1_mac); if (memcmp (rt2880_gmac1_mac, "\0\0\0\0\0\0", 6) == 0) eth_parse_enetaddr(CONFIG_ETHADDR, rt2880_gmac1_mac); memcpy(dev->enetaddr, rt2880_gmac1_mac, 6); eth_number++; dev = dev->next; } while(dev != eth_devices); #ifdef CONFIG_NET_MULTI /* update current ethernet name */ if (eth_current) { char *act = getenv("ethact"); if (act == NULL || strcmp(act, eth_current->name) != 0) setenv("ethact", eth_current->name); } else setenv("ethact", NULL); #endif //printf("\n eth_current->name = %s\n",eth_current->name); printf("\n"); } return eth_number; }
int eth_getenv_enetaddr(char *name, uchar *enetaddr) { eth_parse_enetaddr(getenv(name), enetaddr); return is_valid_ethaddr(enetaddr); }