samsung: misc: support to check reboot mode with inform register
authorJaehoon Chung <jh80.chung@samsung.com>
Mon, 25 Jul 2016 12:04:15 +0000 (21:04 +0900)
committerJaehoon Chung <jh80.chung@samsung.com>
Thu, 10 Oct 2019 04:38:37 +0000 (13:38 +0900)
To support the reboot mode, add the check_reboot_mode() function.
This function is checking which reboot mode is with INFORM register.
"inform-num" can get from device-tree with "samsung,reboot-mode"
compatible.

Change-Id: Ib3e201a6ab17afbc163376b139b1a9977fbf7fb6
Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
board/samsung/common/misc.c
include/samsung/misc.h

index 9e652803f51a9bbc5aa139883ad386ef39337269..2b79ae6da8d69e879025259cda99d5850cf38cc6 100644 (file)
@@ -17,6 +17,7 @@
 #include <memalign.h>
 #include <linux/sizes.h>
 #include <asm/arch/cpu.h>
+#include <asm/arch/power.h>
 #include <asm/gpio.h>
 #include <dm.h>
 /*
@@ -934,6 +935,32 @@ void keys_init(void)
 }
 #endif /* CONFIG_LCD_MENU */
 
+void check_reboot_mode(void) {
+       u32 val;
+       int node, inform_num;
+
+       node = fdt_node_offset_by_compatible(gd->fdt_blob, 0,
+                       "samsung,reboot-mode");
+       if (node < 0)
+               return;
+
+       inform_num = fdtdec_get_int(gd->fdt_blob, node, "inform-num", -1);
+       if (inform_num < 0)
+               return;
+
+       /* Get the value from INFORM register */
+       val = get_inform_value(inform_num);
+       if (val < 0)
+               return;
+
+       clear_inform_value(inform_num);
+
+       val &= ~REBOOT_MODE_PREFIX;
+       if (val & REBOOT_DOWNLOAD) {
+               run_command("thordown", 0);
+       }
+}
+
 #ifdef CONFIG_CMD_BMP
 void draw_logo(void)
 {
index 398822dd73ddd78cffd22320632debc1d4f6bb98..c2a67ecd295309acaef49c6cccae512a517cb8ac 100644 (file)
@@ -11,6 +11,11 @@ u32 get_board_rev(void);
 void set_board_info(void);
 #endif
 
+/* Check which reboot mode is */
+#define REBOOT_MODE_PREFIX     0x12345670
+#define REBOOT_DOWNLOAD                0x1
+void check_reboot_mode(void);
+
 #if defined(CONFIG_LCD_MENU) || defined(CONFIG_INTERACTIVE_CHARGER)
 void keys_init(void);
 int check_keys(void);