rk29: support get boot mode by register
author黄涛 <huangtao@rock-chips.com>
Mon, 1 Aug 2011 11:18:27 +0000 (19:18 +0800)
committer黄涛 <huangtao@rock-chips.com>
Mon, 1 Aug 2011 11:18:27 +0000 (19:18 +0800)
arch/arm/mach-rk29/devices.c
arch/arm/mach-rk29/include/mach/board.h
arch/arm/mach-rk29/include/mach/loader.h [new file with mode: 0644]
arch/arm/mach-rk29/io.c
arch/arm/mach-rk29/reset.c

index 364079e73c17c6d31f4b2ce10c6d91ba1434c47c..fb9e5d8038ee0b9e1fa2928a6b775b6fa0027da0 100644 (file)
@@ -24,6 +24,7 @@
 #include <mach/rk29-dma-pl330.h> 
 #include <mach/rk29_camera.h>                          /* ddl@rock-chips.com : camera support */
 #include <mach/board.h>
+#include <mach/loader.h>
 #include "devices.h"
 #ifdef CONFIG_ADC_RK29
 static struct resource rk29_adc_resource[] = {
@@ -825,6 +826,18 @@ static int __init boot_mode_init(char *s)
 }
 __setup("androidboot.mode=", boot_mode_init);
 
+void rk29_boot_mode_init_by_register(void)
+{
+       u32 flag = readl(RK29_TIMER0_BASE);
+       if (flag == (SYS_KERNRL_REBOOT_FLAG | BOOT_RECOVER)) {
+               boot_mode = BOOT_MODE_RECOVERY;
+       } else {
+               boot_mode = readl(RK29_GRF_BASE + 0xdc); // GRF_OS_REG3
+       }
+       if (boot_mode)
+               printk("Boot mode: %d\n", boot_mode);
+}
+
 int board_boot_mode(void)
 {
        return boot_mode;
index c84a4661495666577bde8cf3194bcc2beae00d53..d9392b92400a95480c4567d9b100c8cbcbd81e6b 100755 (executable)
@@ -318,6 +318,8 @@ void __init board_power_init(void);
 #define BOOT_MODE_CHARGE               3
 #define BOOT_MODE_POWER_TEST           4
 #define BOOT_MODE_OFFMODE_CHARGING     5
+#define BOOT_MODE_REBOOT               6
+#define BOOT_MODE_PANIC                        7
 int board_boot_mode(void);
 
 enum periph_pll {
diff --git a/arch/arm/mach-rk29/include/mach/loader.h b/arch/arm/mach-rk29/include/mach/loader.h
new file mode 100644 (file)
index 0000000..3922fc5
--- /dev/null
@@ -0,0 +1,35 @@
+/* arch/arm/mach-rk29/include/mach/loader.h
+ *
+ * Copyright (C) 2011 ROCKCHIP, Inc.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+#ifndef __ASM_ARCH_RK29_LOADER_H
+#define __ASM_ARCH_RK29_LOADER_H
+
+#define SYS_LOADER_ERR_FLAG      0x1888AAFF
+#define SYS_LOADER_REBOOT_FLAG   0x5242C300  //high 24 bits is tag, low 8 bits is type
+#define SYS_KERNRL_REBOOT_FLAG   0xC3524200  //high 24 bits is tag, low 8 bits is type
+
+enum {
+    BOOT_NORMAL = 0,
+    BOOT_LOADER,     /* enter loader rockusb mode */
+    BOOT_MASKROM,    /* enter maskrom rockusb mode*/
+    BOOT_RECOVER,    /* enter recover */
+    BOOT_NORECOVER,  /* do not enter recover */
+    BOOT_WINCE,      /* FOR OTHER SYSTEM */
+    BOOT_WIPEDATA,   /* enter recover and wipe data. */
+    BOOT_WIPEALL,    /* enter recover and wipe all data. */
+    BOOT_CHECKIMG,   /* check firmware img with backup part(in loader mode)*/
+    BOOT_MAX         /* MAX VALID BOOT TYPE.*/
+};
+
+#endif
index e4be8f679d4e76b97cb15926d25fdf9461529e60..23b80c7b8d83599ee2ca28e1fc86513b184cea47 100644 (file)
@@ -64,7 +64,9 @@ static struct map_desc rk29_io_desc[] __initdata = {
 #endif
 };
 
+extern void rk29_boot_mode_init_by_register(void);
 void __init rk29_map_common_io(void)
 {
        iotable_init(rk29_io_desc, ARRAY_SIZE(rk29_io_desc));
+       rk29_boot_mode_init_by_register();
 }
index 93e9a52861d2a14352ff64c5ffa71fb7a6711163..d3e4ca5b985968f8dc14a0cc37d35622f3499cc9 100755 (executable)
@@ -16,6 +16,8 @@
 #include <mach/memory.h>\r
 #include <mach/sram.h>\r
 #include <mach/pmu.h>\r
+#include <mach/loader.h>\r
+#include <mach/board.h>\r
 \r
 #include <asm/delay.h>\r
 #include <asm/tlbflush.h>\r
@@ -36,7 +38,7 @@ static void  pwm2gpiodefault(void)
        memset((void *)RK29_PWM_BASE, 0, 0x40);\r
 } \r
 \r
-\r
+#if 0\r
 extern void __rb( void*  );\r
 static void rb( void )\r
 {\r
@@ -51,6 +53,7 @@ static void rb( void )
     //while(testflag);    \r
     cb( uart_base );\r
 }\r
+#endif\r
 \r
 static volatile u32 __sramdata reboot_reason = 0;\r
 static void __sramfunc __noreturn rk29_rb_with_softreset(void)\r
@@ -116,13 +119,22 @@ static void __sramfunc __noreturn rk29_rb_with_softreset(void)
 void rk29_arch_reset(int mode, const char *cmd)\r
 {\r
        void (*rb2)(void);\r
+       u32 boot_mode = BOOT_MODE_REBOOT;\r
 \r
        if (cmd) {\r
-               if (!strcmp(cmd, "loader") || !strcmp(cmd, "bootloader"))\r
-                       reboot_reason = 0x1888AAFF;\r
-               else if (!strcmp(cmd, "recovery"))\r
-                       reboot_reason = 0x5242C303;\r
+               if (!strcmp(cmd, "loader") || !strcmp(cmd, "bootloader")) {\r
+                       reboot_reason = SYS_LOADER_ERR_FLAG;\r
+               } else if (!strcmp(cmd, "recovery")) {\r
+                       reboot_reason = SYS_LOADER_REBOOT_FLAG + BOOT_RECOVER;\r
+                       boot_mode = BOOT_MODE_RECOVERY;\r
+               } else if (!strcmp(cmd, "charge")) {\r
+                       boot_mode = BOOT_MODE_CHARGE;\r
+               }\r
+       } else {\r
+               if (system_state != SYSTEM_RESTART)\r
+                       boot_mode = BOOT_MODE_PANIC;\r
        }\r
+       writel(boot_mode, RK29_GRF_BASE + 0xdc); // GRF_OS_REG3\r
 \r
        rb2 = (void(*)(void))((u32)rk29_rb_with_softreset - SRAM_CODE_OFFSET + 0x10130000);\r
 \r