Browse Source

arm: mvebu: ds414: Auto-populate env if appropriate

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>
Phil Sutter 3 years ago
parent
commit
a770159f88

+ 3 - 6
board/Synology/ds414/cmd_syno.c

@@ -17,12 +17,9 @@
 #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;

+ 17 - 0
board/Synology/ds414/cmd_syno.h

@@ -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 */

+ 11 - 0
board/Synology/ds414/ds414.c

@@ -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");

+ 1 - 1
configs/ds414_defconfig

@@ -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