[PATCH u-boot-sunxi] sunxi: use random parts of SID to set ethaddr

71 views
Skip to first unread message

Jonathan Liu

unread,
May 27, 2014, 6:46:18 AM5/27/14
to linux...@googlegroups.com, Hans de Goede, Jonathan Liu
Signed-off-by: Jonathan Liu <net...@gmail.com>
---
board/sunxi/board.c | 28 ++++++++++++++++++++++++++++
include/configs/sunxi-common.h | 2 ++
2 files changed, 30 insertions(+)

diff --git a/board/sunxi/board.c b/board/sunxi/board.c
index 6c362a3..0db46b0 100644
--- a/board/sunxi/board.c
+++ b/board/sunxi/board.c
@@ -22,9 +22,12 @@
#include <axp221.h>
#endif
#include <asm/arch/clock.h>
+#include <asm/arch/cpu.h>
#include <asm/arch/dram.h>
#include <asm/arch/gpio.h>
#include <asm/arch/mmc.h>
+#include <asm/io.h>
+#include <net.h>

DECLARE_GLOBAL_DATA_PTR;

@@ -213,3 +216,28 @@ void spl_display_print(void)
printf("Board: %s\n", CONFIG_SYS_BOARD_NAME);
}
#endif
+
+#ifdef CONFIG_MISC_INIT_R
+int misc_init_r(void)
+{
+ if (!getenv("ethaddr")) {
+ uint32_t reg_val = readl(SUNXI_SID_BASE);
+
+ if (reg_val) {
+ uint8_t mac_addr[6];
+
+ mac_addr[0] = 0x02; /* Non OUI / registered MAC address */
+ mac_addr[1] = (reg_val >> 0) & 0xff;
+ reg_val = readl(SUNXI_SID_BASE + 0x0c);
+ mac_addr[2] = (reg_val >> 24) & 0xff;
+ mac_addr[3] = (reg_val >> 16) & 0xff;
+ mac_addr[4] = (reg_val >> 8) & 0xff;
+ mac_addr[5] = (reg_val >> 0) & 0xff;
+
+ eth_setenv_enetaddr("ethaddr", mac_addr);
+ }
+ }
+
+ return 0;
+}
+#endif
diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h
index e11c4ee..948a49d 100644
--- a/include/configs/sunxi-common.h
+++ b/include/configs/sunxi-common.h
@@ -419,6 +419,8 @@
#define CONFIG_ENV_IS_NOWHERE
#endif

+#define CONFIG_MISC_INIT_R
+
#ifndef CONFIG_SPL_BUILD
#include <config_distro_defaults.h>
#endif
--
1.9.3

Jonathan Liu

unread,
Jun 7, 2014, 7:00:28 AM6/7/14
to linux...@googlegroups.com, Hans de Goede
Bump. Any comments or suggestions?

Regards,
Jonathan

Hans de Goede

unread,
Jun 8, 2014, 4:48:02 AM6/8/14
to Jonathan Liu, linux...@googlegroups.com
Hi,
I've looking into this on my todo list, hopefully I'll get around to it today
or tomorrow.

Many thanks for writing this patch!

Regards,

Hans

Rajesh Mallah

unread,
Jun 9, 2014, 5:09:23 AM6/9/14
to linux...@googlegroups.com
Dear Jonathan,

thanks for finding the time to patch it , it shall be immensely helpful.
We use mele-M3 netbooting  to a thinclient OS. we do not have to
hardcode the macs in the uEnv.txt anymore.

regds
mallah.




--
You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Hans de Goede

unread,
Jun 14, 2014, 2:54:27 AM6/14/14
to Jonathan Liu, linux...@googlegroups.com
Hi,

On 05/27/2014 12:54 PM, Jonathan Liu wrote:
> Signed-off-by: Jonathan Liu <net...@gmail.com>

Thanks, applied. Note I've expanded the commit message a bit,
to hopefully make review of this patch for upstream u-boot
go more smooth, see:
https://github.com/linux-sunxi/u-boot-sunxi/commit/4af825f11fbdac9e9c5560b2532474da6203cb53

Regards,

Hans
Reply all
Reply to author
Forward
0 new messages