Skip to contentSkip to conversation

s3c2410_wdt.c watchdog patches

WATCHDOG Wim Van Sebroeck 1 participant 1 message Oct 3, 2004

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

Hi Andrew,

Another watchdog-patch (wdog-fix-memrelease.patch) to be tested; please do a

bk pull http://linux-watchdog.bkbits.net/linux-2.6-watchdog-mm

This will update the following files:

 arch/arm/configs/bast_defconfig              |   11 
 arch/arm/configs/s3c2410_defconfig           |    9 
 drivers/char/watchdog/Kconfig                |   16 
 drivers/char/watchdog/Makefile               |    1 
 drivers/char/watchdog/s3c2410_wdt.c          |  532 ++++++++++++++++++++++++++-
 include/asm-arm/arch-s3c2410/regs-watchdog.h |    1 
 6 files changed, 556 insertions(+), 14 deletions(-)

through these ChangeSets:

<[email protected]> (04/09/07 1.2058)
Add S3C2410 (Samsung ARM9 Mobile SoC) watchdog driver

<[email protected]> (04/10/03 1.2059)
[WATCHDOG] s3c2410_wdt.c-wdog-fix-memrelease.patch

fix the release of the memory resource at exit from the code, and tidy up the static variables at the start.

The ChangeSets can also be looked at on:

	http://linux-watchdog.bkbits.net:8080/linux-2.6-watchdog-mm

For completeness, I added the patches below.

Greetings,
Wim.

================================================================================

arch/arm/configs/bast_defconfig +9 -2
diff -Nru a/arch/arm/configs/bast_defconfig b/arch/arm/configs/bast_defconfig
@@ -479,12 +479,19 @@
 #
 # Watchdog Cards
 #
-# CONFIG_WATCHDOG is not set
+CONFIG_WATCHDOG=y
+# CONFIG_WATCHDOG_NOWAYOUT is not set
+
+#
+# Watchdog Device Drivers
+#
+# CONFIG_SOFT_WATCHDOG is not set
+CONFIG_S3C2410_WATCHDOG=y
 # CONFIG_NVRAM is not set
 CONFIG_RTC=y
 # CONFIG_DTLK is not set
 # CONFIG_R3964 is not set
-# CONFIG_APPLICOM is not set
+
 
 #
 # Ftape, the floppy tape device driver
arch/arm/configs/s3c2410_defconfig +8 -1
diff -Nru a/arch/arm/configs/s3c2410_defconfig b/arch/arm/configs/s3c2410_defconfig
@@ -493,7 +493,14 @@
 #
 # Watchdog Cards
 #
-# CONFIG_WATCHDOG is not set
+CONFIG_WATCHDOG=y
+# CONFIG_WATCHDOG_NOWAYOUT is not set
+
+#
+# Watchdog Device Drivers
+#
+# CONFIG_SOFT_WATCHDOG is not set
+CONFIG_S3C2410_WATCHDOG=y
 # CONFIG_NVRAM is not set
 CONFIG_RTC=y
 # CONFIG_DTLK is not set
drivers/char/watchdog/Kconfig +16 -0
diff -Nru a/drivers/char/watchdog/Kconfig b/drivers/char/watchdog/Kconfig
@@ -106,6 +106,22 @@
 
 	  Say N if you are unsure.
 
+config S3C2410_WATCHDOG
+	tristate "S3C2410 Watchdog"
+	depends on WATCHDOG && ARCH_S3C2410
+	help
+	  Watchdog timer block in the Samsung S3C2410 chips. This will
+	  reboot the system when the timer expires with the watchdog
+	  enabled.
+
+	  The driver is limited by the speed of the system's PCLK
+	  signal, so with reasonbaly fast systems (PCLK around 50-66MHz)
+	  then watchdog intervals of over approximately 20seconds are
+	  unavailable.
+
+	  The driver can be built as a module by choosing M, and will
+	  be called s3c2410_wdt
+
 config SA1100_WATCHDOG
 	tristate "SA1100/PXA2xx watchdog"
 	depends on WATCHDOG && ( ARCH_SA1100 || ARCH_PXA )
drivers/char/watchdog/Makefile +1 -0
diff -Nru a/drivers/char/watchdog/Makefile b/drivers/char/watchdog/Makefile
@@ -21,6 +21,7 @@
 obj-$(CONFIG_I8XX_TCO) += i8xx_tco.o
 obj-$(CONFIG_MACHZ_WDT) += machzwd.o
 obj-$(CONFIG_SH_WDT) += shwdt.o
+obj-$(CONFIG_S3C2410_WATCHDOG) += s3c2410_wdt.o
 obj-$(CONFIG_SA1100_WATCHDOG) += sa1100_wdt.o
 obj-$(CONFIG_EUROTECH_WDT) += eurotechwdt.o
 obj-$(CONFIG_SOFT_WATCHDOG) += softdog.o
drivers/char/watchdog/s3c2410_wdt.c new file +507 -0

507 lines not on this page · raw message

include/asm-arm/arch-s3c2410/regs-watchdog.h +1 -0
diff -Nru a/include/asm-arm/arch-s3c2410/regs-watchdog.h b/include/asm-arm/arch-s3c2410/regs-watchdog.h
@@ -38,6 +38,7 @@
 #define S3C2410_WTCON_DIV128  (3<<3)
 
 #define S3C2410_WTCON_PRESCALE(x) ((x) << 8)
+#define S3C2410_WTCON_PRESCALE_MASK (0xff00)
 
 #endif /* __ASM_ARCH_REGS_WATCHDOG_H */
 
drivers/char/watchdog/s3c2410_wdt.c +14 -11
diff -Nru a/drivers/char/watchdog/s3c2410_wdt.c b/drivers/char/watchdog/s3c2410_wdt.c
@@ -93,13 +93,13 @@
 	CLOSE_STATE_ALLOW=0x4021
 } close_state_t;
 
-static struct semaphore open_lock;
-static struct resource *wdt_mem;
-static struct resource *wdt_irq;
-static struct clk      *wdt_clock;
-static unsigned long    wdt_base;
-static unsigned int     wdt_count;
-static close_state_t    allow_close;
+static struct semaphore	 open_lock;
+static struct resource	*wdt_mem;
+static struct resource	*wdt_irq;
+static struct clk	*wdt_clock;
+static void __iomem	*wdt_base;
+static unsigned int	 wdt_count;
+static close_state_t	 allow_close;
 
 static unsigned int tmr_count;
 
@@ -370,6 +370,7 @@
 	struct resource *res;
 	int started = 0;
 	int ret;
+	int size;
 
 	pr_debug("%s: probe=%p, device=%p\n", __FUNCTION__, pdev, dev);
 
@@ -381,12 +382,14 @@
 		return -ENOENT;
 	}
 
-	if (!request_mem_region(res->start, res->end-res->start, pdev->name)) {
+	size = (res->end-res->start)+1;
+	wdt_mem = request_mem_region(res->start, size, pdev->name);
+	if (wdt_mem == NULL) {
 		printk(KERN_INFO PFX "failed to get memory region\n");
 		return -ENOENT;
 	}
 
-	wdt_base = (unsigned long)ioremap(res->start, res->end - res->start);
+	wdt_base = ioremap(res->start, size);
 	if (wdt_base == 0) {
 		printk(KERN_INFO PFX "failed to ioremap() region\n");
 		return -EINVAL;
@@ -454,8 +457,8 @@
 static int s3c2410wdt_remove(struct device *dev)
 {
 	if (wdt_mem != NULL) {
-		release_mem_region(wdt_mem->start,
-				   wdt_mem->end - wdt_mem->start);
+		release_resource(wdt_mem);
+		kfree(wdt_mem);
 		wdt_mem = NULL;
 	}