From: Lothar Waßmann Date: Fri, 9 Jan 2015 11:33:40 +0000 (+0100) Subject: karo: introduce variables 'safeboot' and 'wdreset' X-Git-Tag: KARO-TX6-2015-02-05~6 X-Git-Url: https://git.kernelconcepts.de/?p=karo-tx-uboot.git;a=commitdiff_plain;h=5c7e86ebb3514bdac7ac9ae7c0885879f43b9e95 karo: introduce variables 'safeboot' and 'wdreset' The environment variable 'safeboot' will be set when is detected early in the boot process. 'wdreset' is set when the last boot cause was a watchdog reset. This makes it possible to handle these events from the boot scripts. --- diff --git a/board/karo/common/env.c b/board/karo/common/env.c index c6def4f9ee..7dbb7c86c3 100644 --- a/board/karo/common/env.c +++ b/board/karo/common/env.c @@ -28,6 +28,8 @@ static const char const *cleanup_vars[] = { "bootargs", "fileaddr", "filesize", + "safeboot", + "wdreset", }; void env_cleanup(void) diff --git a/board/karo/tx28/tx28.c b/board/karo/tx28/tx28.c index ca0b3bcb71..e140e22d51 100644 --- a/board/karo/tx28/tx28.c +++ b/board/karo/tx28/tx28.c @@ -147,7 +147,7 @@ int board_early_init_f(void) while ((rtc_stat = readl(&rtc_regs->hw_rtc_stat)) & RTC_STAT_STALE_REGS_PERSISTENT0) { if (timeout-- < 0) - return 0; + return 1; udelay(1); } boot_cause = readl(&rtc_regs->hw_rtc_persistent0); @@ -162,11 +162,16 @@ int board_early_init_f(void) rtc_err: serial_puts("Inconsistent value in RTC_PERSISTENT0 register; power-on-reset required\n"); - return 0; + return 1; } int board_init(void) { + if (ctrlc()) { + printf("CTRL-C detected; safeboot enabled\n"); + return 1; + } + /* Address of boot parameters */ #ifdef CONFIG_OF_LIBFDT gd->bd->bi_arch_number = -1; @@ -837,7 +842,10 @@ int board_late_init(void) env_cleanup(); - karo_fdt_move_fdt(); + if (had_ctrlc()) + setenv_ulong("safeboot", 1); + else + karo_fdt_move_fdt(); baseboard = getenv("baseboard"); if (!baseboard) diff --git a/board/karo/tx48/tx48.c b/board/karo/tx48/tx48.c index 539472a1b1..8bc8bc51a6 100644 --- a/board/karo/tx48/tx48.c +++ b/board/karo/tx48/tx48.c @@ -846,8 +846,12 @@ int board_init(void) /* address of boot parameters */ gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100; - if (ctrlc()) - printf("CTRL-C detected\n"); + if (ctrlc() || (prm_rstst & PRM_RSTST_WDT1_RST)) { + if (prm_rstst & PRM_RSTST_WDT1_RST) + printf("WDOG RESET detected\n"); + else + printf(" detected; safeboot enabled\n"); + } gpio_request_array(tx48_gpios, ARRAY_SIZE(tx48_gpios)); tx48_set_pin_mux(tx48_pads, ARRAY_SIZE(tx48_pads)); @@ -915,11 +919,9 @@ static void tx48_set_cpu_clock(void) return; if (had_ctrlc() || (prm_rstst & PRM_RSTST_WDT1_RST)) { - if (prm_rstst & PRM_RSTST_WDT1_RST) { - printf("Watchdog reset detected; skipping cpu clock change\n"); - } else { - printf(" detected; skipping cpu clock change\n"); - } + printf("%s detected; skipping cpu clock change\n", + (prm_rstst & PRM_RSTST_WDT1_RST) ? + "WDOG RESET" : ""); return; } @@ -969,7 +971,13 @@ int board_late_init(void) env_cleanup(); tx48_set_cpu_clock(); - karo_fdt_move_fdt(); + + if (had_ctrlc()) + setenv_ulong("safeboot", 1); + else if (prm_rstst & PRM_RSTST_WDT1_RST) + setenv_ulong("wdreset", 1); + else + karo_fdt_move_fdt(); baseboard = getenv("baseboard"); if (!baseboard) diff --git a/board/karo/tx51/tx51.c b/board/karo/tx51/tx51.c index 72c6584121..b94e537212 100644 --- a/board/karo/tx51/tx51.c +++ b/board/karo/tx51/tx51.c @@ -271,7 +271,10 @@ int board_init(void) gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x1000; if (ctrlc() || (wrsr & WRSR_TOUT)) { - printf("CTRL-C detected; Skipping boot critical setup\n"); + if (wrsr & WRSR_TOUT) + printf("WDOG RESET detected\n"); + else + printf(" detected; safeboot enabled\n"); return 1; } return 0; @@ -1046,7 +1049,13 @@ int board_late_init(void) env_cleanup(); tx51_set_cpu_clock(); - karo_fdt_move_fdt(); + + if (had_ctrlc()) + setenv_ulong("safeboot", 1); + else if (wrsr & WRSR_TOUT) + setenv_ulong("wdreset", 1); + else + karo_fdt_move_fdt(); baseboard = getenv("baseboard"); if (!baseboard) diff --git a/board/karo/tx53/tx53.c b/board/karo/tx53/tx53.c index 3074ae9615..9df8126ad4 100644 --- a/board/karo/tx53/tx53.c +++ b/board/karo/tx53/tx53.c @@ -486,7 +486,10 @@ int board_init(void) gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x1000; if (ctrlc() || (wrsr & WRSR_TOUT)) { - printf("CTRL-C detected; Skipping PMIC setup\n"); + if (wrsr & WRSR_TOUT) + printf("WDOG RESET detected; Skipping PMIC setup\n"); + else + printf(" detected; safeboot enabled\n"); return 1; } @@ -1289,11 +1292,14 @@ static void tx53_set_cpu_clock(void) { unsigned long cpu_clk = getenv_ulong("cpu_clk", 10, 0); - if (had_ctrlc() || (wrsr & WRSR_TOUT)) + if (cpu_clk == 0 || cpu_clk == mxc_get_clock(MXC_ARM_CLK) / 1000000) return; - if (cpu_clk == 0 || cpu_clk == mxc_get_clock(MXC_ARM_CLK) / 1000000) + if (had_ctrlc() || (wrsr & WRSR_TOUT)) { + printf("%s detected; skipping cpu clock change\n", + (wrsr & WRSR_TOUT) ? "WDOG RESET" : ""); return; + } if (mxc_set_clock(CONFIG_SYS_MX5_HCLK, cpu_clk, MXC_ARM_CLK) == 0) { cpu_clk = mxc_get_clock(MXC_ARM_CLK); @@ -1326,7 +1332,13 @@ int board_late_init(void) env_cleanup(); tx53_set_cpu_clock(); - karo_fdt_move_fdt(); + + if (had_ctrlc()) + setenv_ulong("safeboot", 1); + else if (wrsr & WRSR_TOUT) + setenv_ulong("wdreset", 1); + else + karo_fdt_move_fdt(); baseboard = getenv("baseboard"); if (!baseboard) diff --git a/board/karo/tx6/tx6qdl.c b/board/karo/tx6/tx6qdl.c index 72141365d2..1fa2d1f00c 100644 --- a/board/karo/tx6/tx6qdl.c +++ b/board/karo/tx6/tx6qdl.c @@ -261,11 +261,14 @@ int board_init(void) gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x1000; gd->bd->bi_arch_number = -1; - if (ctrlc()) { + if (ctrlc() || (wrsr & WRSR_TOUT)) { + if (wrsr & WRSR_TOUT) + printf("WDOG RESET detected; Skipping PMIC setup\n"); + else + printf(" detected; safeboot enabled\n"); #ifndef CONFIG_MX6_TEMPERATURE_HOT tx6_temp_check_enabled = false; #endif - printf("CTRL-C detected; Skipping PMIC setup\n"); return 1; } @@ -1078,12 +1081,14 @@ static void tx6qdl_set_cpu_clock(void) { unsigned long cpu_clk = getenv_ulong("cpu_clk", 10, 0); - if (had_ctrlc() || (wrsr & WRSR_TOUT)) - return; - if (cpu_clk == 0 || cpu_clk == mxc_get_clock(MXC_ARM_CLK) / 1000000) return; + if (had_ctrlc() || (wrsr & WRSR_TOUT)) { + printf("%s detected; skipping cpu clock change\n", + (wrsr & WRSR_TOUT) ? "WDOG RESET" : ""); + return; + } if (mxc_set_clock(CONFIG_SYS_MX6_HCLK, cpu_clk, MXC_ARM_CLK) == 0) { cpu_clk = mxc_get_clock(MXC_ARM_CLK); printf("CPU clock set to %lu.%03lu MHz\n", @@ -1118,7 +1123,12 @@ int board_late_init(void) check_cpu_temperature(1); tx6qdl_set_cpu_clock(); - if (!had_ctrlc()) + + if (had_ctrlc()) + setenv_ulong("safeboot", 1); + else if (wrsr & WRSR_TOUT) + setenv_ulong("wdreset", 1); + else karo_fdt_move_fdt(); baseboard = getenv("baseboard");