#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[] = {
}
__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;
#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 {
--- /dev/null
+/* 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
#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();
}
#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
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
//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
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