[U-Boot] [PATCH 3/5] ARM: uniphier: do not overwrite bootmode environment

Masahiro Yamada yamada.masahiro at socionext.com
Tue Jun 7 14:03:45 CEST 2016


This code auto-detects the boot mode, but it should respect the
user's choice if "bootmode" environment is found in a saved set
of environments.

Signed-off-by: Masahiro Yamada <yamada.masahiro at socionext.com>
---

 arch/arm/mach-uniphier/board_late_init.c | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/arch/arm/mach-uniphier/board_late_init.c b/arch/arm/mach-uniphier/board_late_init.c
index a454126..b3fe016 100644
--- a/arch/arm/mach-uniphier/board_late_init.c
+++ b/arch/arm/mach-uniphier/board_late_init.c
@@ -62,33 +62,46 @@ static int uniphier_set_fdt_file(void)
 	return setenv("fdt_file", dtb_name);
 }
 
+static int uniphier_set_bootmode(const char *bootmode)
+{
+	if (getenv("bootmode"))
+		return 0;	/* do nothing if it is already set */
+
+	return setenv("bootenv", bootmode);
+}
+
 int board_late_init(void)
 {
+	const char *bootmode;
+
 	puts("MODE:  ");
 
 	switch (spl_boot_device_raw()) {
 	case BOOT_DEVICE_MMC1:
 		printf("eMMC Boot\n");
-		setenv("bootmode", "emmcboot");
+		bootmode = "emmcboot";
 		break;
 	case BOOT_DEVICE_NAND:
 		printf("NAND Boot\n");
-		setenv("bootmode", "nandboot");
 		nand_denali_wp_disable();
+		bootmode = "nandboot";
 		break;
 	case BOOT_DEVICE_NOR:
 		printf("NOR Boot\n");
-		setenv("bootmode", "norboot");
+		bootmode = "norboot";
 		break;
 	case BOOT_DEVICE_USB:
 		printf("USB Boot\n");
-		setenv("bootmode", "usbboot");
+		bootmode = "usbboot";
 		break;
 	default:
 		printf("Unknown\n");
-		break;
+		return;
 	}
 
+	if (uniphier_set_bootmode(bootmode))
+		printf("bootmode environment was not set correctly\n");
+
 	if (uniphier_set_fdt_file())
 		printf("fdt_file environment was not set correctly\n");
 
-- 
1.9.1



More information about the U-Boot mailing list