[U-Boot] [PATCH 1/3] rockchip: rk3399: detect boot mode

Kever Yang kever.yang at rock-chips.com
Wed Aug 9 10:18:57 UTC 2017


U-Boot fastboot, kernel may reboot with parameter which require
bootloader to get into different boot mode, detect it and enter
proper mode.

Signed-off-by: Kever Yang <kever.yang at rock-chips.com>
---

 arch/arm/mach-rockchip/rk3399/Kconfig  |  1 +
 arch/arm/mach-rockchip/rk3399/rk3399.c | 42 +++++++++++++++++++++++++++++++++-
 2 files changed, 42 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-rockchip/rk3399/Kconfig b/arch/arm/mach-rockchip/rk3399/Kconfig
index 415466a..c4a6d46 100644
--- a/arch/arm/mach-rockchip/rk3399/Kconfig
+++ b/arch/arm/mach-rockchip/rk3399/Kconfig
@@ -5,6 +5,7 @@ choice
 
 config TARGET_EVB_RK3399
 	bool "RK3399 evaluation board"
+	select BOARD_LATE_INIT
 	help
 	  RK3399evb is a evaluation board for Rockchp rk3399,
 	  with full function and phisical connectors support like type-C ports,
diff --git a/arch/arm/mach-rockchip/rk3399/rk3399.c b/arch/arm/mach-rockchip/rk3399/rk3399.c
index 3484b28..d7a8aa6 100644
--- a/arch/arm/mach-rockchip/rk3399/rk3399.c
+++ b/arch/arm/mach-rockchip/rk3399/rk3399.c
@@ -5,9 +5,13 @@
  */
 
 #include <common.h>
+#include <syscon.h>
 #include <asm/armv8/mmu.h>
-#include <asm/io.h>
+#include <asm/arch/boot_mode.h>
+#include <asm/arch/clock.h>
+#include <asm/arch/grf_rk3399.h>
 #include <asm/arch/hardware.h>
+#include <asm/io.h>
 
 #define GRF_EMMCCORE_CON11 0xff77f02c
 
@@ -53,3 +57,39 @@ int arch_cpu_init(void)
 
 	return 0;
 }
+
+static void setup_boot_mode(void)
+{
+	struct rk3399_pmugrf_regs *pmugrf;
+	int boot_mode;
+
+	pmugrf = syscon_get_first_range(ROCKCHIP_SYSCON_PMUGRF);
+	boot_mode = readl(&pmugrf->os_reg0);
+	debug("boot mode %x\n", boot_mode);
+
+	/* Clear boot mode */
+	writel(BOOT_NORMAL, &pmugrf->os_reg0);
+
+	switch (boot_mode) {
+	case BOOT_FASTBOOT:
+		printf("enter fastboot!\n");
+		setenv("preboot", "setenv preboot; fastboot usb0");
+		break;
+	case BOOT_UMS:
+		printf("enter UMS!\n");
+		setenv("preboot", "setenv preboot; if mmc dev 0;"
+		       "then ums mmc 0; else ums mmc 1;fi");
+		break;
+	case BOOT_LOADER:
+		printf("enter Rockusb!\n");
+		setenv("preboot", "setenv preboot; rockusb 0 mmc 0");
+		break;
+	}
+}
+
+int board_late_init(void)
+{
+	setup_boot_mode();
+
+	return 0;
+}
-- 
1.9.1



More information about the U-Boot mailing list