From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
To: barebox@lists.infradead.org
Subject: [PATCH 3/3] animeo_ip: retrieve the mac from the macb and set private mac to asix
Date: Fri, 20 Sep 2013 07:40:50 +0200 [thread overview]
Message-ID: <1379655650-23221-3-git-send-email-plagnioj@jcrosoft.com> (raw)
In-Reply-To: <1379655650-23221-1-git-send-email-plagnioj@jcrosoft.com>
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>
---
arch/arm/boards/animeo_ip/init.c | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/arch/arm/boards/animeo_ip/init.c b/arch/arm/boards/animeo_ip/init.c
index c98493f..b6cd996 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;
@@ -255,8 +256,40 @@ 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)
{
+ 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);
}
--
1.8.4.rc1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2013-09-20 5:40 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-20 5:39 [PATCH 0/3] Animeo IP: macb support improvement Jean-Christophe PLAGNIOL-VILLARD
2013-09-20 5:40 ` [PATCH 1/3] introduce helper to generate mac address with OUI Jean-Christophe PLAGNIOL-VILLARD
2013-09-20 5:40 ` [PATCH 2/3] animeo_ip: ensure the phy is reset correctly Jean-Christophe PLAGNIOL-VILLARD
2013-09-20 5:40 ` Jean-Christophe PLAGNIOL-VILLARD [this message]
2013-09-20 5:46 [PATCH 0/3 v2] Animeo IP: macb support improvement Jean-Christophe PLAGNIOL-VILLARD
2013-09-20 5:47 ` [PATCH 1/3] introduce helper to generate mac address with OUI Jean-Christophe PLAGNIOL-VILLARD
2013-09-20 5:47 ` [PATCH 3/3] animeo_ip: retrieve the mac from the macb and set private mac to asix Jean-Christophe PLAGNIOL-VILLARD
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1379655650-23221-3-git-send-email-plagnioj@jcrosoft.com \
--to=plagnioj@jcrosoft.com \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox