rk2928: add reset support
author黄涛 <huangtao@rock-chips.com>
Wed, 8 Aug 2012 10:20:43 +0000 (18:20 +0800)
committer黄涛 <huangtao@rock-chips.com>
Wed, 8 Aug 2012 10:20:54 +0000 (18:20 +0800)
arch/arm/mach-rk2928/common.c
arch/arm/mach-rk2928/reset.c

index 1236dca8f1e47e58e8c54f4ea80de4d25bee93e3..54a3c8da29d84df00856ca21dd4baf7f34ba4008 100644 (file)
@@ -11,7 +11,7 @@
 #include <plat/sram.h>
 #include <mach/board.h>
 #include <mach/gpio.h>
-//#include <mach/iomux.h>
+#include <mach/iomux.h>
 #include <mach/fiq.h>
 //#include <mach/loader.h>
 //#include <mach/ddr.h>
@@ -86,18 +86,11 @@ static void __init rk2928_l2_cache_init(void)
 static int boot_mode;
 static void __init rk2928_boot_mode_init(void)
 {
-#if 0
-       u32 boot_flag = readl_relaxed(RK2928_PMU_BASE + PMU_SYS_REG0);
-       boot_mode = readl_relaxed(RK2928_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;
-       }
+       u32 boot_flag = 0;
+       boot_mode = readl_relaxed(RK2928_GRF_BASE + GRF_OS_REG1);
+
        if (boot_mode || boot_flag)
                printk("Boot mode: %d flag: 0x%08x\n", boot_mode, boot_flag);
-#endif
 }
 
 int board_boot_mode(void)
index 24b088e9a1c2ee0d33c0411ce614c50295a3ac2b..5a0fb4cd00ed70be7ab557831aa00ac688989904 100644 (file)
@@ -1,11 +1,32 @@
 #include <linux/io.h>
 #include <linux/kernel.h>
-#include <mach/system.h>
 #include <linux/string.h>
+#include <mach/board.h>
+#include <mach/cru.h>
+#include <mach/iomux.h>
+#include <mach/system.h>
 
 static void rk2928_arch_reset(char mode, const char *cmd)
 {
-       while (1);
+       u32 boot_flag = 0;
+       u32 boot_mode = BOOT_MODE_REBOOT;
+
+       if (cmd) {
+               if (!strcmp(cmd, "charge"))
+                       boot_mode = BOOT_MODE_CHARGE;
+       } else {
+               if (system_state != SYSTEM_RESTART)
+                       boot_mode = BOOT_MODE_PANIC;
+       }
+       writel_relaxed(0xffff0000 | boot_mode, RK2928_GRF_BASE + GRF_OS_REG1);  // for linux
+       dsb();
+       /* disable remap */
+       writel_relaxed(1 << (12 + 16), RK2928_GRF_BASE + GRF_SOC_CON0);
+       /* pll enter slow mode */
+       writel_relaxed(PLL_MODE_SLOW(APLL_ID) | PLL_MODE_SLOW(CPLL_ID) | PLL_MODE_SLOW(GPLL_ID), RK2928_CRU_BASE + CRU_MODE_CON);
+       dsb();
+       writel_relaxed(0xeca8, RK2928_CRU_BASE + CRU_GLB_SRST_SND);
+       dsb();
 }
 
 void (*arch_reset)(char, const char *) = rk2928_arch_reset;