]> git.baikalelectronics.ru Git - uboot.git/commitdiff
board: amlogic: Add Odroid-N2 board support
authorPascal Vizeli <pvizeli@syshack.ch>
Thu, 18 Jun 2020 14:40:37 +0000 (16:40 +0200)
committerNeil Armstrong <narmstrong@baylibre.com>
Wed, 8 Jul 2020 08:52:45 +0000 (10:52 +0200)
Add a proper Odroid-N2 board support to handle the Ethernet MAC
address stored in the in-SoC eFuses.

Signed-off-by: Pascal Vizeli <pvizeli@syshack.ch>
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
Tested-by: Anand Moon <linux.amoon@gmail.com>
board/amlogic/odroid-n2/MAINTAINERS [new file with mode: 0644]
board/amlogic/odroid-n2/Makefile [new file with mode: 0644]
board/amlogic/odroid-n2/odroid-n2.c [new file with mode: 0644]
board/amlogic/w400/MAINTAINERS
configs/odroid-n2_defconfig

diff --git a/board/amlogic/odroid-n2/MAINTAINERS b/board/amlogic/odroid-n2/MAINTAINERS
new file mode 100644 (file)
index 0000000..5627e54
--- /dev/null
@@ -0,0 +1,7 @@
+ODROID-N2
+M:     Neil Armstrong <narmstrong@baylibre.com>
+S:     Maintained
+L:     u-boot-amlogic@groups.io
+F:     board/amlogic/odroid-n2/
+F:     configs/odroid-n2_defconfig
+F:     doc/board/amlogic/odroid-n2.rst
diff --git a/board/amlogic/odroid-n2/Makefile b/board/amlogic/odroid-n2/Makefile
new file mode 100644 (file)
index 0000000..68e4e2a
--- /dev/null
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# (C) Copyright 2020 BayLibre, SAS
+# Author: Neil Armstrong <narmstrong@baylibre.com>
+
+obj-y  := odroid-n2.o
diff --git a/board/amlogic/odroid-n2/odroid-n2.c b/board/amlogic/odroid-n2/odroid-n2.c
new file mode 100644 (file)
index 0000000..caf7fd6
--- /dev/null
@@ -0,0 +1,49 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2020 BayLibre, SAS
+ * Author: Neil Armstrong <narmstrong@baylibre.com>
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <env.h>
+#include <init.h>
+#include <net.h>
+#include <asm/io.h>
+#include <asm/arch/sm.h>
+#include <asm/arch/eth.h>
+
+#define EFUSE_MAC_OFFSET       20
+#define EFUSE_MAC_SIZE         12
+#define MAC_ADDR_LEN           6
+
+int misc_init_r(void)
+{
+       u8 mac_addr[MAC_ADDR_LEN];
+       char efuse_mac_addr[EFUSE_MAC_SIZE], tmp[3];
+       ssize_t len;
+
+       meson_eth_init(PHY_INTERFACE_MODE_RGMII, 0);
+
+       if (!eth_env_get_enetaddr("ethaddr", mac_addr)) {
+               len = meson_sm_read_efuse(EFUSE_MAC_OFFSET,
+                                         efuse_mac_addr, EFUSE_MAC_SIZE);
+               if (len != EFUSE_MAC_SIZE)
+                       return 0;
+
+               /* MAC is stored in ASCII format, 1bytes = 2characters */
+               for (int i = 0; i < 6; i++) {
+                       tmp[0] = efuse_mac_addr[i * 2];
+                       tmp[1] = efuse_mac_addr[i * 2 + 1];
+                       tmp[2] = '\0';
+                       mac_addr[i] = simple_strtoul(tmp, NULL, 16);
+               }
+
+               if (is_valid_ethaddr(mac_addr))
+                       eth_env_set_enetaddr("ethaddr", mac_addr);
+               else
+                       meson_generate_serial_ethaddr();
+       }
+
+       return 0;
+}
index 5e837cfaef3cff40f9c243b89e0c248de26fadb1..a1b0ac8636e73d0988ea88ed795140bd4501434a 100644 (file)
@@ -5,8 +5,6 @@ L:      u-boot-amlogic@groups.io
 F:     board/amlogic/w400/
 F:     configs/khadas-vim3_defconfig
 F:     configs/khadas-vim3l_defconfig
-F:     configs/odroid-n2_defconfig
 F:     doc/board/amlogic/w400.rst
 F:     doc/board/amlogic/khadas-vim3.rst
 F:     doc/board/amlogic/khadas-vim3l.rst
-F:     doc/board/amlogic/odroid-n2.rst
index e0cc6e37294290088bbd0079e66309eb3dcb1002..063809416ea5bd3397b4fe0c450495070d7752ca 100644 (file)
@@ -1,5 +1,5 @@
 CONFIG_ARM=y
-CONFIG_SYS_BOARD="w400"
+CONFIG_SYS_BOARD="odroid-n2"
 CONFIG_ARCH_MESON=y
 CONFIG_SYS_TEXT_BASE=0x01000000
 CONFIG_ENV_SIZE=0x2000