From fae6b76e05ad01de6b934f9d428601625552756c Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E9=BB=84=E6=B6=9B?= Date: Mon, 1 Aug 2011 19:18:27 +0800 Subject: [PATCH] rk29: support get boot mode by register --- arch/arm/mach-rk29/devices.c | 13 +++++++++ arch/arm/mach-rk29/include/mach/board.h | 2 ++ arch/arm/mach-rk29/include/mach/loader.h | 35 ++++++++++++++++++++++++ arch/arm/mach-rk29/io.c | 2 ++ arch/arm/mach-rk29/reset.c | 22 +++++++++++---- 5 files changed, 69 insertions(+), 5 deletions(-) create mode 100644 arch/arm/mach-rk29/include/mach/loader.h diff --git a/arch/arm/mach-rk29/devices.c b/arch/arm/mach-rk29/devices.c index 364079e73c17..fb9e5d8038ee 100644 --- a/arch/arm/mach-rk29/devices.c +++ b/arch/arm/mach-rk29/devices.c @@ -24,6 +24,7 @@ #include #include /* ddl@rock-chips.com : camera support */ #include +#include #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; diff --git a/arch/arm/mach-rk29/include/mach/board.h b/arch/arm/mach-rk29/include/mach/board.h index c84a46614956..d9392b92400a 100755 --- a/arch/arm/mach-rk29/include/mach/board.h +++ b/arch/arm/mach-rk29/include/mach/board.h @@ -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 index 000000000000..3922fc5e972a --- /dev/null +++ b/arch/arm/mach-rk29/include/mach/loader.h @@ -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 diff --git a/arch/arm/mach-rk29/io.c b/arch/arm/mach-rk29/io.c index e4be8f679d4e..23b80c7b8d83 100644 --- a/arch/arm/mach-rk29/io.c +++ b/arch/arm/mach-rk29/io.c @@ -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(); } diff --git a/arch/arm/mach-rk29/reset.c b/arch/arm/mach-rk29/reset.c index 93e9a52861d2..d3e4ca5b9859 100755 --- a/arch/arm/mach-rk29/reset.c +++ b/arch/arm/mach-rk29/reset.c @@ -16,6 +16,8 @@ #include #include #include +#include +#include #include #include @@ -36,7 +38,7 @@ static void pwm2gpiodefault(void) memset((void *)RK29_PWM_BASE, 0, 0x40); } - +#if 0 extern void __rb( void* ); static void rb( void ) { @@ -51,6 +53,7 @@ static void rb( void ) //while(testflag); cb( uart_base ); } +#endif static volatile u32 __sramdata reboot_reason = 0; static void __sramfunc __noreturn rk29_rb_with_softreset(void) @@ -116,13 +119,22 @@ static void __sramfunc __noreturn rk29_rb_with_softreset(void) void rk29_arch_reset(int mode, const char *cmd) { void (*rb2)(void); + u32 boot_mode = BOOT_MODE_REBOOT; if (cmd) { - if (!strcmp(cmd, "loader") || !strcmp(cmd, "bootloader")) - reboot_reason = 0x1888AAFF; - else if (!strcmp(cmd, "recovery")) - reboot_reason = 0x5242C303; + if (!strcmp(cmd, "loader") || !strcmp(cmd, "bootloader")) { + reboot_reason = SYS_LOADER_ERR_FLAG; + } else if (!strcmp(cmd, "recovery")) { + reboot_reason = SYS_LOADER_REBOOT_FLAG + BOOT_RECOVER; + boot_mode = BOOT_MODE_RECOVERY; + } else if (!strcmp(cmd, "charge")) { + boot_mode = BOOT_MODE_CHARGE; + } + } else { + if (system_state != SYSTEM_RESTART) + boot_mode = BOOT_MODE_PANIC; } + writel(boot_mode, RK29_GRF_BASE + 0xdc); // GRF_OS_REG3 rb2 = (void(*)(void))((u32)rk29_rb_with_softreset - SRAM_CODE_OFFSET + 0x10130000); -- 2.34.1