summaryrefslogtreecommitdiffstats
path: root/arch/arm/boards/animeo_ip/init.c
diff options
context:
space:
mode:
authorJean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>2013-09-20 07:47:45 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2013-09-23 08:22:24 +0200
commita99a74f87faf6ae2cb7922095b1e24a39c74c166 (patch)
tree25c2f2f01c09843f0344dedd30c82de824bb8380 /arch/arm/boards/animeo_ip/init.c
parent6e419891d209ebbae87b361a90c089fec747693a (diff)
downloadbarebox-a99a74f87faf6ae2cb7922095b1e24a39c74c166.tar.gz
barebox-a99a74f87faf6ae2cb7922095b1e24a39c74c166.tar.xz
animeo_ip: retrieve the mac from the macb and set private mac to asix
if the macb's mac is not a valid public mac set a private with "smf" as OUI as the mac address might be set by the previous bootloader set a private with "smf" as OUI for asix Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/arm/boards/animeo_ip/init.c')
-rw-r--r--arch/arm/boards/animeo_ip/init.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/arch/arm/boards/animeo_ip/init.c b/arch/arm/boards/animeo_ip/init.c
index b30605dd3d..5f070d2c09 100644
--- a/arch/arm/boards/animeo_ip/init.c
+++ b/arch/arm/boards/animeo_ip/init.c
@@ -27,6 +27,7 @@
#include <mach/io.h>
#include <mach/at91_pmc.h>
#include <mach/at91_rstc.h>
+#include <local_mac_address.h>
static bool animeo_ip_is_buco;
static bool animeo_ip_is_io;
@@ -237,8 +238,42 @@ static void animeo_ip_phy_reset(void)
at91_sys_write(AT91_RSTC_MR, AT91_RSTC_KEY | (rstc) | AT91_RSTC_URSTEN);
}
+#define MACB_SA1B 0x0098
+#define MACB_SA1T 0x009c
+
+static int animeo_ip_get_macb_ethaddr(u8 *addr)
+{
+ u32 top, bottom;
+ void __iomem *base = IOMEM(AT91SAM9260_BASE_EMAC);
+
+ bottom = readl(base + MACB_SA1B);
+ top = readl(base + MACB_SA1T);
+ addr[0] = bottom & 0xff;
+ addr[1] = (bottom >> 8) & 0xff;
+ addr[2] = (bottom >> 16) & 0xff;
+ addr[3] = (bottom >> 24) & 0xff;
+ addr[4] = top & 0xff;
+ addr[5] = (top >> 8) & 0xff;
+
+ /* valid and not private */
+ if (is_valid_ether_addr(addr) && !(addr[0] & 0x02))
+ return 0;
+
+ return -EINVAL;
+}
+
static void animeo_ip_add_device_eth(void)
{
+ u8 enetaddr[6];
+
+ if (!animeo_ip_get_macb_ethaddr(enetaddr))
+ eth_register_ethaddr(0, enetaddr);
+ else
+ local_mac_address_register(0, "smf");
+
+ /* for usb asix */
+ local_mac_address_register(1, "smf");
+
animeo_ip_phy_reset();
at91_add_device_eth(0, &macb_pdata);
}