int misc_init_r(void) { uint8_t tmp[20], addr[10]; if (getenv("ethaddr") == NULL) { /* Read Ethernet MAC address from EEPROM */ if (dvevm_read_mac_address(addr)) { /* Set Ethernet MAC address from EEPROM */ davinci_sync_env_enetaddr(addr); } else { get_mac_addr(addr); } if (is_multicast_ether_addr(addr) || is_zero_ether_addr(addr)) { printf("Invalid MAC address read.\n"); return -EINVAL; } sprintf((char *)tmp, "%02x:%02x:%02x:%02x:%02x:%02x", addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]); setenv("ethaddr", (char *)tmp); } #ifdef CONFIG_DRIVER_TI_EMAC_USE_RMII /* Select RMII fucntion through the expander */ if (rmii_hw_init()) printf("RMII hardware init failed!!!\n"); #endif dspwake(); return 0; }
int misc_init_r(void) { uint8_t eeprom_enetaddr[6]; /* Read Ethernet MAC address from EEPROM if available. */ if (dvevm_read_mac_address(eeprom_enetaddr)) davinci_sync_env_enetaddr(eeprom_enetaddr); return(0); }
int board_eth_init(bd_t *bis) { uint8_t enetaddr[6]; /* Configure PINMUX 3 to enable EMAC pins */ writel((readl(PINMUX3) | 0x1affff), PINMUX3); /* Using this function for setting a random mac address */ davinci_sync_env_enetaddr(enetaddr); davinci_emac_initialize(); return 0; }
int misc_init_r(void) { uint8_t video_mode; uint8_t eeprom_enetaddr[6]; /* Read Ethernet MAC address from EEPROM if available. */ if (dvevm_read_mac_address(eeprom_enetaddr)) davinci_sync_env_enetaddr(eeprom_enetaddr); i2c_read(0x39, 0x00, 1, &video_mode, 1); setenv("videostd", ((video_mode & 0x80) ? "pal" : "ntsc")); return(0); }
int board_eth_init(bd_t *bis) { uint8_t eeprom_enetaddr[6]; int i; struct davinci_gpio *gpio1_base = (struct davinci_gpio *)DAVINCI_GPIO_BANK01; /* Configure PINMUX 3 to enable EMAC pins */ writel((readl(PINMUX3) | 0x1affff), PINMUX3); /* Configure GPIO20 as output */ writel((readl(&gpio1_base->dir) & ~(1 << 20)), &gpio1_base->dir); /* Toggle GPIO 20 */ for (i = 0; i < 20; i++) { /* GPIO 20 low */ writel((readl(&gpio1_base->out_data) & ~(1 << 20)), &gpio1_base->out_data); udelay(1000); /* GPIO 20 high */ writel((readl(&gpio1_base->out_data) | (1 << 20)), &gpio1_base->out_data); } /* Configure I2C pins so that EEPROM can be read */ writel((readl(PINMUX3) | 0x01400000), PINMUX3); /* Read Ethernet MAC address from EEPROM */ if (dvevm_read_mac_address(eeprom_enetaddr)) davinci_sync_env_enetaddr(eeprom_enetaddr); davinci_emac_initialize(); return 0; }
/* * Initializes on-board ethernet controllers. */ int board_eth_init(bd_t *bis) { u_int8_t mac_addr[6]; u_int8_t switch_start_cmd[2] = { 0x01, 0x23 }; struct eth_device *dev; /* Read Ethernet MAC address from EEPROM */ if (dvevm_read_mac_address(mac_addr)) /* set address env if not already set */ davinci_sync_env_enetaddr(mac_addr); /* read the address back from env */ if (!eth_getenv_enetaddr("ethaddr", mac_addr)) return -1; /* enable the Ethernet switch in the 3 port PHY */ if (i2c_write(PHY_SW_I2C_ADDR, 0, 0, switch_start_cmd, sizeof(switch_start_cmd))) { printf("Ethernet switch start failed!\n"); return -1; } /* finally, initialise the driver */ if (!davinci_emac_initialize()) { printf("Error: Ethernet init failed!\n"); return -1; } dev = eth_get_dev(); /* provide the resulting addr to the driver */ memcpy(dev->enetaddr, mac_addr, 6); dev->write_hwaddr(dev); return 0; }
int misc_init_r(void) { dspwake(); #if defined(CONFIG_MAC_ADDR_IN_SPIFLASH) || defined(CONFIG_MAC_ADDR_IN_EEPROM) uchar env_enetaddr[6]; int enetaddr_found; enetaddr_found = eth_env_get_enetaddr("ethaddr", env_enetaddr); #ifdef CONFIG_MAC_ADDR_IN_SPIFLASH int spi_mac_read; uchar buff[6]; spi_mac_read = get_mac_addr(buff); /* * MAC address not present in the environment * try and read the MAC address from SPI flash * and set it. */ if (!enetaddr_found) { if (!spi_mac_read) { if (is_valid_ethaddr(buff)) { if (eth_env_set_enetaddr("ethaddr", buff)) { printf("Warning: Failed to " "set MAC address from SPI flash\n"); } } else { printf("Warning: Invalid " "MAC address read from SPI flash\n"); } } } else { /* * MAC address present in environment compare it with * the MAC address in SPI flash and warn on mismatch */ if (!spi_mac_read && is_valid_ethaddr(buff) && memcmp(env_enetaddr, buff, 6)) printf("Warning: MAC address in SPI flash don't match " "with the MAC address in the environment\n"); printf("Default using MAC address from environment\n"); } #endif uint8_t enetaddr[8]; int eeprom_mac_read; /* Read Ethernet MAC address from EEPROM */ eeprom_mac_read = dvevm_read_mac_address(enetaddr); /* * MAC address not present in the environment * try and read the MAC address from EEPROM flash * and set it. */ if (!enetaddr_found) { if (eeprom_mac_read) /* Set Ethernet MAC address from EEPROM */ davinci_sync_env_enetaddr(enetaddr); } else { /* * MAC address present in environment compare it with * the MAC address in EEPROM and warn on mismatch */ if (eeprom_mac_read && memcmp(enetaddr, env_enetaddr, 6)) printf("Warning: MAC address in EEPROM don't match " "with the MAC address in the environment\n"); printf("Default using MAC address from environment\n"); } #endif return 0; }