]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
arm: mvebu: ds414: Auto-populate env if appropriate
authorPhil Sutter <phil@nwl.cc>
Fri, 5 Mar 2021 20:05:11 +0000 (21:05 +0100)
committerStefan Roese <sr@denx.de>
Thu, 8 Apr 2021 06:50:41 +0000 (08:50 +0200)
Define a misc_init_r() which calls "syno populate_env" if the
environment seems incomplete (or default), indicated by missing
"ethaddr" variable. With this in place, no random MAC address fallback
is needed anymore.

Signed-off-by: Phil Sutter <phil@nwl.cc>
board/Synology/ds414/cmd_syno.c
board/Synology/ds414/cmd_syno.h [new file with mode: 0644]
board/Synology/ds414/ds414.c
configs/ds414_defconfig

index a120c3123ffb3089b41b1c4e181841737b14beaf..a62658a2eb6b2e18f9c9185be06be44e404f729d 100644 (file)
 #include <asm/io.h>
 #include "../drivers/ddr/marvell/axp/ddr3_init.h"
 
-#define ETHADDR_MAX            4
-#define SYNO_SN_TAG            "SN="
-#define SYNO_CHKSUM_TAG                "CHK="
+#include "cmd_syno.h"
 
-
-static int do_syno_populate(int argc, char *const argv[])
+int do_syno_populate(int argc, char *const argv[])
 {
        unsigned int bus = CONFIG_SF_DEFAULT_BUS;
        unsigned int cs = CONFIG_SF_DEFAULT_CS;
@@ -57,7 +54,7 @@ static int do_syno_populate(int argc, char *const argv[])
                goto out_unmap;
        }
 
-       for (n = 0; n < ETHADDR_MAX; n++) {
+       for (n = 0; n < SYNO_ETHADDR_MAX; n++) {
                char ethaddr[ETH_ALEN];
                int i, sum = 0;
                unsigned char csum = 0;
diff --git a/board/Synology/ds414/cmd_syno.h b/board/Synology/ds414/cmd_syno.h
new file mode 100644 (file)
index 0000000..42e435c
--- /dev/null
@@ -0,0 +1,17 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Commands to deal with Synology specifics.
+ *
+ * Copyright (C) 2021  Phil Sutter <phil@nwl.cc>
+ */
+
+#ifndef _CMD_SYNO_H
+#define _CMD_SYNO_H
+
+#define SYNO_ETHADDR_MAX       4
+#define SYNO_SN_TAG            "SN="
+#define SYNO_CHKSUM_TAG                "CHK="
+
+int do_syno_populate(int argc, char *const argv[]);
+
+#endif /* _CMD_SYNO_H */
index 9c4ce670ddfbdc51644378a46d451334e74b5ad4..abe6f9eb5e23d76ea356ff9b7e30e5e4beb5dbc2 100644 (file)
@@ -18,6 +18,8 @@
 #include "../arch/arm/mach-mvebu/serdes/axp/high_speed_env_spec.h"
 #include "../arch/arm/mach-mvebu/serdes/axp/board_env_spec.h"
 
+#include "cmd_syno.h"
+
 DECLARE_GLOBAL_DATA_PTR;
 
 /* GPP and MPP settings as found in mvBoardEnvSpec.c of Synology's U-Boot */
@@ -179,6 +181,15 @@ int board_init(void)
        return 0;
 }
 
+int misc_init_r(void)
+{
+       if (!env_get("ethaddr")) {
+               puts("Incomplete environment, populating from SPI flash\n");
+               do_syno_populate(0, NULL);
+       }
+       return 0;
+}
+
 int checkboard(void)
 {
        puts("Board: DS414\n");
index 8ef2e79dc91b092f1c270b9323feb5a712d6a620..e1c0f693f30868e26984b6a6d05942ea91894bb9 100644 (file)
@@ -24,6 +24,7 @@ CONFIG_BOOTARGS="console=ttyS0,115200 ip=off initrd=0x8000040,8M root=/dev/md0 r
 # CONFIG_USE_PREBOOT is not set
 # CONFIG_DISPLAY_BOARDINFO is not set
 CONFIG_DISPLAY_BOARDINFO_LATE=y
+CONFIG_MISC_INIT_R=y
 CONFIG_SPL_I2C_SUPPORT=y
 # CONFIG_CMD_FLASH is not set
 CONFIG_CMD_I2C=y
@@ -46,7 +47,6 @@ CONFIG_ENV_OVERWRITE=y
 CONFIG_USE_ENV_SPI_MAX_HZ=y
 CONFIG_ENV_SPI_MAX_HZ=50000000
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
-CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_SPL_OF_TRANSLATE=y
 CONFIG_BLK=y
 # CONFIG_MMC is not set