/* Read the MAC address from FEC's registers PALR PAUR. User is supposed to configure these registers when MAC address is known from another source (fuse), but on TS4800, MAC address is not fused and the bootrom configure these registers on startup.  */
static int fec_get_mac_from_register(uint32_t base_addr)
/* Read the MAC address from FEC's registers PALR PAUR. User is supposed to configure these registers when MAC address is known from another source (fuse), but on TS4800, MAC address is not fused and the bootrom configure these registers on startup.  */
static int fec_get_mac_from_register(uint32_t base_addr)
{
	unsigned char ethaddr[6];
	u32 reg_mac[2];
	int i;
	reg_mac[0] = in_be32(base_addr + 0xE4);
	reg_mac[1] = in_be32(base_addr + 0xE8);
	for(i = 0; i < 6; i++)
		ethaddr[i] = (reg_mac[i / 4] >> ((i % 4) * 8)) & 0xFF;
	if (is_valid_ethaddr(ethaddr)) {
		eth_env_set_enetaddr("ethaddr", ethaddr);
		return 0;
	}
	return -1;
}