From fa14e144f54d15b98d336fa68f7c8a463fbf428d Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E9=BB=84=E6=B6=9B?= Date: Fri, 30 Mar 2012 14:34:57 +0800 Subject: [PATCH] rk30: add boot mode support --- arch/arm/mach-rk30/common.c | 23 +++++++++++++++++++++++ arch/arm/mach-rk30/reset.c | 19 ++++++++++++++----- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/arch/arm/mach-rk30/common.c b/arch/arm/mach-rk30/common.c index b44b9ad0316b..92618597569d 100755 --- a/arch/arm/mach-rk30/common.c +++ b/arch/arm/mach-rk30/common.c @@ -12,6 +12,8 @@ #include #include #include +#include +#include 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, diff --git a/arch/arm/mach-rk30/reset.c b/arch/arm/mach-rk30/reset.c index 851162a2b12e..e2a22ba3eb05 100644 --- a/arch/arm/mach-rk30/reset.c +++ b/arch/arm/mach-rk30/reset.c @@ -5,18 +5,27 @@ #include #include #include +#include +#include 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); -- 2.34.1