artik530: check the ALIVESCRATCH7 register to determine reboot mode
authorJaehoon Chung <jh80.chung@samsung.com>
Tue, 24 Oct 2017 10:51:34 +0000 (19:51 +0900)
committerJaehoon Chung <jh80.chung@samsung.com>
Mon, 26 Mar 2018 02:31:19 +0000 (11:31 +0900)
If kernel sets the reboot mode at ALIVESCRATCH7 register, bootloader
should check it to enter proper mode (e.g., download/fota/recovery).

Check the ALIVESCRATCH7 register to determine reboot mode.

Change-Id: Ia30f562f9c2fd8c07c27df53299171e8721bccc5
Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
Signed-off-by: Junghoon Kim <jhoon20.kim@samsung.com>
arch/arm/mach-nexell/include/mach/nexell.h
board/nexell/s5p4418/artik530_raptor/board.c

index b8a083171968279fcea7e4b624be95aad0bc6122..9fd4de99062df1f96d3e6cbc174038dc101705b5 100644 (file)
 
 #endif /* __ASSEMBLY__ */
 
+/* Use the ALIVESCRATCH7 For Tizen artik reboot */
+#define SCRATCHRSTREG7                 0xF4
+#define SCRATCHSETREG7                 0xF8
+#define SCRATCHREADREG7                        0xFC
+#define REBOOT_PREFIX                  0x12345670
+#define REBOOT_PREFIX_MASK             0xFFFFFFF0
+#define REBOOT_DOWNLOAD                        0x1
+#define REBOOT_RECOVERY                        0x2
+#define REBOOT_FOTA                            0x3
+
 #endif /* __NEXELL_H__ */
index 70e608dce9b553d14aa0c34774dbe9b2b6756087..2fd0e1148852bf573e0f10f9285dd99faea56e08 100644 (file)
@@ -277,6 +277,32 @@ void dram_init_banksize(void)
        gd->bd->bi_dram[0].size  = CONFIG_SYS_SDRAM_SIZE;
 }
 
+static void check_reboot_mode(void)
+{
+       u32 val;
+
+       val = readl(PHY_BASEADDR_ALIVE + SCRATCHREADREG7);
+
+       /* Clear the reboot mode */
+       writel(0xFFFFFFFF, PHY_BASEADDR_ALIVE + SCRATCHRSTREG7);
+       writel(0x0, PHY_BASEADDR_ALIVE + SCRATCHSETREG7);
+
+       if ((val & REBOOT_PREFIX_MASK) == REBOOT_PREFIX) {
+               val &= ~REBOOT_PREFIX;
+
+               if (val == REBOOT_DOWNLOAD)
+                       run_command("thordown", 0);
+               else if (val == REBOOT_RECOVERY)
+                       setenv("bootmode", "recovery");
+               else if (val == REBOOT_FOTA)
+                       setenv("bootmode", "fota");
+               else
+                       setenv("bootmode", "ramdisk");
+
+               saveenv();
+       }
+}
+
 #ifdef CONFIG_DM_PMIC_NXE2000
 void pmic_init(void)
 {
@@ -394,6 +420,8 @@ int board_late_init(void)
 #ifdef CONFIG_ARTIK_OTA
        check_ota_update();
 #endif
+       check_reboot_mode();
+
        set_booting_device();
 
        return 0;