rk30: add boot mode support
author黄涛 <huangtao@rock-chips.com>
Fri, 30 Mar 2012 06:34:57 +0000 (14:34 +0800)
committer黄涛 <huangtao@rock-chips.com>
Fri, 30 Mar 2012 06:35:21 +0000 (14:35 +0800)
arch/arm/mach-rk30/common.c
arch/arm/mach-rk30/reset.c

index b44b9ad0316b28329d8c22356df90f9de48b7663..92618597569d5d24d4a5e0fd2c8f7d6e8fcbeea8 100755 (executable)
@@ -12,6 +12,8 @@
 #include <mach/gpio.h>
 #include <mach/iomux.h>
 #include <mach/fiq.h>
+#include <mach/pmu.h>
+#include <mach/loader.h>
 
 static void __init rk30_cpu_axi_init(void)
 {
@@ -71,6 +73,26 @@ static void __init rk30_l2_cache_init(void)
 #endif
 }
 
+static int boot_mode;
+static void __init rk30_boot_mode_init(void)
+{
+       u32 boot_flag = readl_relaxed(RK30_PMU_BASE + PMU_SYS_REG0);
+       u32 boot_mode = readl_relaxed(RK30_PMU_BASE + PMU_SYS_REG1);
+
+       if (boot_flag == (SYS_KERNRL_REBOOT_FLAG | BOOT_RECOVER)) {
+               boot_mode = BOOT_MODE_RECOVERY;
+       } else if (strstr(boot_command_line, "(parameter)")) {
+               boot_mode = BOOT_MODE_RECOVERY;
+       }
+       if (boot_mode || boot_flag)
+               printk("Boot mode: %d flag: 0x%08x\n", boot_mode, boot_flag);
+}
+
+int board_boot_mode(void)
+{
+       return boot_mode;
+}
+EXPORT_SYMBOL(board_boot_mode);
 
 void __init rk30_init_irq(void)
 {
@@ -90,6 +112,7 @@ void __init rk30_map_io(void)
        board_clock_init();
        rk30_l2_cache_init();
        rk30_iomux_init();
+       rk30_boot_mode_init();
 }
 
 void __init rk30_fixup(struct machine_desc *desc, struct tag *tags,
index 851162a2b12e5b3c3fbbad77d4183e1386d606b9..e2a22ba3eb05476dd99830c7cfb8d20d9490ca12 100644 (file)
@@ -5,18 +5,27 @@
 #include <mach/cru.h>
 #include <mach/iomux.h>
 #include <mach/loader.h>
+#include <mach/board.h>
+#include <mach/pmu.h>
 
 static void rk30_arch_reset(char mode, const char *cmd)
 {
-       unsigned int reason = 0;
+       u32 boot_flag = 0;
+       u32 boot_mode = BOOT_MODE_REBOOT;
 
-       if(cmd) {
+       if (cmd) {
                if (!strcmp(cmd, "loader") || !strcmp(cmd, "bootloader")) 
-                       reason = SYS_LOADER_REBOOT_FLAG + BOOT_LOADER;
+                       boot_flag = SYS_LOADER_REBOOT_FLAG + BOOT_LOADER;
                else if(!strcmp(cmd, "recovery"))
-                       reason = SYS_LOADER_REBOOT_FLAG + BOOT_RECOVER;
+                       boot_flag = SYS_LOADER_REBOOT_FLAG + BOOT_RECOVER;
+               else if (!strcmp(cmd, "charge"))
+                       boot_mode = BOOT_MODE_CHARGE;
+       } else {
+               if (system_state != SYSTEM_RESTART)
+                       boot_mode = BOOT_MODE_PANIC;
        }
-       writel_relaxed(reason, RK30_PMU_PHYS + 0x40);  //PMU_OS_REG0
+       writel_relaxed(boot_flag, RK30_PMU_BASE + PMU_SYS_REG0);        // for loader
+       writel_relaxed(boot_mode, RK30_PMU_BASE + PMU_SYS_REG1);        // for linux
        dsb();
        /* disable remap */
        writel_relaxed(1 << (12 + 16), RK30_GRF_BASE + GRF_SOC_CON0);