Parcourir la source

[ARM] 3132/1: S3C2410 - reset on decompression error

Patch from Ben Dooks

Force a watchdog reset if the system fails to
decompress properly.

Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Ben Dooks il y a 19 ans
Parent
commit
f8c905d368

+ 6 - 0
arch/arm/boot/compressed/misc.c

@@ -283,8 +283,14 @@ void flush_window(void)
 	putstr(".");
 	putstr(".");
 }
 }
 
 
+#ifndef arch_error
+#define arch_error(x)
+#endif
+
 static void error(char *x)
 static void error(char *x)
 {
 {
+	arch_error(x);
+
 	putstr("\n\n");
 	putstr("\n\n");
 	putstr(x);
 	putstr(x);
 	putstr("\n\n -- System halted");
 	putstr("\n\n -- System halted");

+ 8 - 0
arch/arm/mach-s3c2410/Kconfig

@@ -121,6 +121,14 @@ config S3C2410_BOOT_WATCHDOG
 	  system resets depends on the value of PCLK. The timeout on an
 	  system resets depends on the value of PCLK. The timeout on an
 	  200MHz s3c2410 should be about 30 seconds.
 	  200MHz s3c2410 should be about 30 seconds.
 
 
+config S3C2410_BOOT_ERROR_RESET
+	bool "S3C2410 Reboot on decompression error"
+	depends on ARCH_S3C2410
+	help
+	  Say y here to use the watchdog to reset the system if the
+	  kernel decompressor detects an error during decompression.
+
+
 comment "S3C2410 Setup"
 comment "S3C2410 Setup"
 
 
 config S3C2410_DMA
 config S3C2410_DMA

+ 20 - 2
include/asm-arm/arch-s3c2410/uncompress.h

@@ -116,6 +116,8 @@ putstr(const char *ptr)
 	}
 	}
 }
 }
 
 
+#define __raw_writel(d,ad) do { *((volatile unsigned int *)(ad)) = (d); } while(0)
+
 /* CONFIG_S3C2410_BOOT_WATCHDOG
 /* CONFIG_S3C2410_BOOT_WATCHDOG
  *
  *
  * Simple boot-time watchdog setup, to reboot the system if there is
  * Simple boot-time watchdog setup, to reboot the system if there is
@@ -126,8 +128,6 @@ putstr(const char *ptr)
 
 
 #define WDOG_COUNT (0xff00)
 #define WDOG_COUNT (0xff00)
 
 
-#define __raw_writel(d,ad) do { *((volatile unsigned int *)(ad)) = (d); } while(0)
-
 static inline void arch_decomp_wdog(void)
 static inline void arch_decomp_wdog(void)
 {
 {
 	__raw_writel(WDOG_COUNT, S3C2410_WTCNT);
 	__raw_writel(WDOG_COUNT, S3C2410_WTCNT);
@@ -145,6 +145,24 @@ static void arch_decomp_wdog_start(void)
 #define arch_decomp_wdog()
 #define arch_decomp_wdog()
 #endif
 #endif
 
 
+#ifdef CONFIG_S3C2410_BOOT_ERROR_RESET
+
+static void arch_decomp_error(const char *x)
+{
+	putstr("\n\n");
+	putstr(x);
+	putstr("\n\n -- System resetting\n");
+
+	__raw_writel(0x4000, S3C2410_WTDAT);
+	__raw_writel(0x4000, S3C2410_WTCNT);
+	__raw_writel(S3C2410_WTCON_ENABLE | S3C2410_WTCON_DIV128 | S3C2410_WTCON_RSTEN | S3C2410_WTCON_PRESCALE(0x40), S3C2410_WTCON);
+
+	while(1);
+}
+
+#define arch_error arch_decomp_error
+#endif
+
 static void error(char *err);
 static void error(char *err);
 
 
 static void
 static void