Skip to contentSkip to conversation

at91sam9 add watchdog support with keep alive

PATCH Superseded Jean-Christophe PLAGNIOL-VILLARD 1 participant 8 messages Nov 16, 2012

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover at91sam9 add watchdog support with keep alive

HI,

The following patch series add the at91sam9 watchdog present on sam9260/9g20/9261/9g10/9g45/9x5

and introdudce the kep a live support so we can reset the watchdog via poller

The following changes since commit 281b927f44ae94280648714e3587efa4419f6ce3:

Release v2012.11.0 (2012-11-16 13:54:49 +0100)

are available in the git repository at:

git://git.jcrosoft.org/barebox.git delivery/at91sam9_wdt

for you to fetch changes up to 9bef4b05631b352e9dc842fbf68f84532c5cc257:

at91sam9x5: add wathdog support (2012-11-15 03:24:29 +0800)

----------------------------------------------------------------
Jean-Christophe PLAGNIOL-VILLARD (7):
watchdog: add keep alive support
watchdog: add at91sam9 watchdog support
at91sam9260/9g20: add wathdog support
at91sam9261/9g10: add wathdog support
at91sam9263: add wathdog support
at91sam9g45: add wathdog support
at91sam9x5: add wathdog support

 arch/arm/mach-at91/at91sam9260_devices.c |   12 ++++++++++++
 arch/arm/mach-at91/at91sam9261_devices.c |   12 ++++++++++++
 arch/arm/mach-at91/at91sam9263_devices.c |   11 +++++++++++
 arch/arm/mach-at91/at91sam9g45_devices.c |   12 ++++++++++++
 arch/arm/mach-at91/at91sam9x5_devices.c  |   12 ++++++++++++
 drivers/watchdog/Kconfig                 |    8 ++++++++
 drivers/watchdog/Makefile                |    1 +
 drivers/watchdog/at91sam9_wdt.c          |  131 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/watchdog/at91sam9_wdt.h          |   38 ++++++++++++++++++++++++++++++++++++++
 drivers/watchdog/wd_core.c               |   20 ++++++++++++++++++++
 include/watchdog.h                       |    2 ++
 11 files changed, 259 insertions(+)
 create mode 100644 drivers/watchdog/at91sam9_wdt.c
 create mode 100644 drivers/watchdog/at91sam9_wdt.h

Best Regards,
J.

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#1 lore raw

PATCH 1/7 watchdog: add keep alive support

this will allow to ping the watchdog via poller

---
 drivers/watchdog/Kconfig   |    1 +
 drivers/watchdog/wd_core.c |   20 ++++++++++++++++++++
 include/watchdog.h         |    2 ++
 3 files changed, 23 insertions(+)
drivers/watchdog/Kconfig +1 -0
index 8fdc7a5..21480a1 100644
@@ -1,5 +1,6 @@
 menuconfig WATCHDOG
 	bool "Watchdog support              "
+	select GENERIC_POLLER
 	help
 	  Many platforms support a watchdog to keep track of a working machine.
 	  This framework provides routines to handle these watchdogs.
drivers/watchdog/wd_core.c +20 -0
index 3d0cfc6..f0a43f3 100644
@@ -17,18 +17,38 @@
 #include <errno.h>
 #include <linux/ctype.h>
 #include <watchdog.h>
+#include <poller.h>
 
 /*
  * Note: this simple framework supports one watchdog only.
  */
 static struct watchdog *watchdog;
 
+static void watchdog_poller_func(struct poller_struct *poller)
+{
+	watchdog->keep_alive(watchdog);
+}
+
+struct poller_struct watchdog_poller = {
+	.func = watchdog_poller_func,
+};
+
 int watchdog_register(struct watchdog *wd)
 {
 	if (watchdog != NULL)
 		return -EBUSY;
 
+	if (watchdog->keep_alive) {
+		int ret;
+	
+		ret = poller_register(&watchdog_poller);
+		if (ret)
+			return ret;
+	}
+
 	watchdog = wd;
+
+
 	return 0;
 }
 EXPORT_SYMBOL(watchdog_register);
include/watchdog.h +2 -0
index 3e2d08e..d5ecf2f 100644
@@ -13,8 +13,10 @@
 #ifndef INCLUDE_WATCHDOG_H
 # define INCLUDE_WATCHDOG_H
 
+
 struct watchdog {
 	int (*set_timeout)(struct watchdog *, unsigned);
+	void (*keep_alive)(struct watchdog *);
 };
 
 int watchdog_register(struct watchdog *);
Signature · 7 lines
1.7.10.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw

PATCH 2/7 watchdog: add at91sam9 watchdog support

with keep alive support

---
 drivers/watchdog/Kconfig        |    7 +++
 drivers/watchdog/Makefile       |    1 +
 drivers/watchdog/at91sam9_wdt.c |  131 +++++++++++++++++++++++++++++++++++++++
 drivers/watchdog/at91sam9_wdt.h |   38 ++++++++++++
 4 files changed, 177 insertions(+)
 create mode 100644 drivers/watchdog/at91sam9_wdt.c
 create mode 100644 drivers/watchdog/at91sam9_wdt.h
drivers/watchdog/Kconfig +7 -0
index 21480a1..5bd1083 100644
@@ -7,6 +7,13 @@ menuconfig WATCHDOG
 
 if WATCHDOG
 
+config WATCHDOG_AT91SAM9X
+	tristate "AT91SAM9X / AT91CAP9 watchdog"
+	depends on ARCH_AT91
+	help
+	  Watchdog timer embedded into AT91SAM9X and AT91CAP9 chips. This will
+	  reboot your system when the timeout is reached.
+
 config WATCHDOG_MXS28
 	bool "i.MX28"
 	depends on ARCH_IMX28
drivers/watchdog/Makefile +1 -0
index b29103b..4e863a5 100644
@@ -1,2 +1,3 @@
 obj-$(CONFIG_WATCHDOG) += wd_core.o
+obj-$(CONFIG_WATCHDOG_AT91SAM9X) += at91sam9_wdt.o
 obj-$(CONFIG_WATCHDOG_MXS28) += im28wd.o
drivers/watchdog/at91sam9_wdt.c new file +131 -0

131 lines not on this page · raw message

drivers/watchdog/at91sam9_wdt.h new file +38 -0
new file mode 100644
index 0000000..2b68c1a
@@ -0,0 +1,38 @@
+/*
+ * drivers/watchdog/at91sam9_wdt.h
+ *
+ * Copyright (C) 2007 Andrew Victor
+ * Copyright (C) 2007 Atmel Corporation.
+ *
+ * Watchdog Timer (WDT) - System peripherals regsters.
+ * Based on AT91SAM9261 datasheet revision D.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#ifndef AT91_WDT_H
+#define AT91_WDT_H
+
+#define AT91_WDT_CR		0x00			/* Watchdog Control Register */
+#define		AT91_WDT_WDRSTT		(1    << 0)		/* Restart */
+#define		AT91_WDT_KEY		(0xa5 << 24)		/* KEY Password */
+
+#define AT91_WDT_MR		0x04			/* Watchdog Mode Register */
+#define		AT91_WDT_WDV		(0xfff << 0)		/* Counter Value */
+#define		AT91_WDT_WDFIEN		(1     << 12)		/* Fault Interrupt Enable */
+#define		AT91_WDT_WDRSTEN	(1     << 13)		/* Reset Processor */
+#define		AT91_WDT_WDRPROC	(1     << 14)		/* Timer Restart */
+#define		AT91_WDT_WDDIS		(1     << 15)		/* Watchdog Disable */
+#define		AT91_WDT_WDD		(0xfff << 16)		/* Delta Value */
+#define		AT91_WDT_WDDBGHLT	(1     << 28)		/* Debug Halt */
+#define		AT91_WDT_WDIDLEHLT	(1     << 29)		/* Idle Halt */
+
+#define AT91_WDT_SR		0x08			/* Watchdog Status Register */
+#define		AT91_WDT_WDUNF		(1 << 0)		/* Watchdog Underflow */
+#define		AT91_WDT_WDERR		(1 << 1)		/* Watchdog Error */
+
+
+#endif
Signature · 7 lines
1.7.10.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#3 lore raw

PATCH 3/7 at91sam9260/9g20: add wathdog support

In reply to Jean-Christophe PLAGNIOL-VILLARD
---
 arch/arm/mach-at91/at91sam9260_devices.c |   12 ++++++++++++
 1 file changed, 12 insertions(+)
arch/arm/mach-at91/at91sam9260_devices.c +12 -0
index 9c9534e..e781de0 100644
@@ -10,6 +10,7 @@
  *
  */
 #include <common.h>
+#include <init.h>
 #include <sizes.h>
 #include <asm/armlinux.h>
 #include <asm/hardware.h>
@@ -356,3 +357,14 @@ void at91_add_device_mci(short mmc_id, struct atmel_mci_platform_data *data)
 #else
 void at91_add_device_mci(short mmc_id, struct atmel_mci_platform_data *data) {}
 #endif
+
+#ifdef CONFIG_WATCHDOG_AT91SAM9X
+static int at91_add_device_watchdog(void)
+{
+	add_generic_device("at91sam9_wdt", DEVICE_ID_SINGLE, NULL,
+		AT91_WDT + AT91_BASE_SYS, 16, IORESOURCE_MEM, NULL);
+
+	return 0;
+}
+coredevice_initcall(at91_add_device_watchdog);
+#endif
Signature · 7 lines
1.7.10.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#4 lore raw

PATCH 4/7 at91sam9261/9g10: add wathdog support

In reply to Jean-Christophe PLAGNIOL-VILLARD
---
 arch/arm/mach-at91/at91sam9261_devices.c |   12 ++++++++++++
 1 file changed, 12 insertions(+)
arch/arm/mach-at91/at91sam9261_devices.c +12 -0
index 0091e2d..5784e13 100644
@@ -10,6 +10,7 @@
  *
  */
 #include <common.h>
+#include <init.h>
 #include <sizes.h>
 #include <asm/armlinux.h>
 #include <asm/hardware.h>
@@ -257,3 +258,14 @@ void at91_add_device_mci(short mmc_id, struct atmel_mci_platform_data *data)
 #else
 void at91_add_device_mci(short mmc_id, struct atmel_mci_platform_data *data) {}
 #endif
+
+#ifdef CONFIG_WATCHDOG_AT91SAM9X
+static int at91_add_device_watchdog(void)
+{
+	add_generic_device("at91sam9_wdt", DEVICE_ID_SINGLE, NULL,
+		AT91_WDT + AT91_BASE_SYS, 16, IORESOURCE_MEM, NULL);
+
+	return 0;
+}
+coredevice_initcall(at91_add_device_watchdog);
+#endif
Signature · 7 lines
1.7.10.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#5 lore raw

PATCH 5/7 at91sam9263: add wathdog support

In reply to Jean-Christophe PLAGNIOL-VILLARD
---
 arch/arm/mach-at91/at91sam9263_devices.c |   11 +++++++++++
 1 file changed, 11 insertions(+)
arch/arm/mach-at91/at91sam9263_devices.c +11 -0
index e686480..0386d79 100644
@@ -10,6 +10,7 @@
  *
  */
 #include <common.h>
+#include <init.h>
 #include <sizes.h>
 #include <asm/armlinux.h>
 #include <asm/hardware.h>
@@ -351,3 +352,13 @@ void at91_add_device_mci(short mmc_id, struct atmel_mci_platform_data *data)
 void at91_add_device_mci(short mmc_id, struct atmel_mci_platform_data *data) {}
 #endif
 
+#ifdef CONFIG_WATCHDOG_AT91SAM9X
+static int at91_add_device_watchdog(void)
+{
+	add_generic_device("at91sam9_wdt", DEVICE_ID_SINGLE, NULL,
+		AT91_WDT + AT91_BASE_SYS, 16, IORESOURCE_MEM, NULL);
+
+	return 0;
+}
+coredevice_initcall(at91_add_device_watchdog);
+#endif
Signature · 7 lines
1.7.10.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#6 lore raw

PATCH 6/7 at91sam9g45: add wathdog support

In reply to Jean-Christophe PLAGNIOL-VILLARD
---
 arch/arm/mach-at91/at91sam9g45_devices.c |   12 ++++++++++++
 1 file changed, 12 insertions(+)
arch/arm/mach-at91/at91sam9g45_devices.c +12 -0
index 22b455e..38593fc 100644
@@ -10,6 +10,7 @@
  *
  */
 #include <common.h>
+#include <init.h>
 #include <sizes.h>
 #include <asm/armlinux.h>
 #include <asm/hardware.h>
@@ -324,3 +325,14 @@ void at91_add_device_spi(int spi_id, struct at91_spi_platform_data *pdata)
 #else
 void at91_add_device_spi(int spi_id, struct at91_spi_platform_data *pdata) {}
 #endif
+
+#ifdef CONFIG_WATCHDOG_AT91SAM9X
+static int at91_add_device_watchdog(void)
+{
+	add_generic_device("at91sam9_wdt", DEVICE_ID_SINGLE, NULL,
+		AT91_WDT + AT91_BASE_SYS, 16, IORESOURCE_MEM, NULL);
+
+	return 0;
+}
+coredevice_initcall(at91_add_device_watchdog);
+#endif
Signature · 7 lines
1.7.10.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#7 lore raw

PATCH 7/7 at91sam9x5: add wathdog support

In reply to Jean-Christophe PLAGNIOL-VILLARD
---
 arch/arm/mach-at91/at91sam9x5_devices.c |   12 ++++++++++++
 1 file changed, 12 insertions(+)
arch/arm/mach-at91/at91sam9x5_devices.c +12 -0
index 26a380d..27e9ec9 100644
@@ -10,6 +10,7 @@
  *
  */
 #include <common.h>
+#include <init.h>
 #include <sizes.h>
 #include <asm/armlinux.h>
 #include <asm/hardware.h>
@@ -234,3 +235,14 @@ resource_size_t __init at91_configure_usart3(unsigned pins)
 	return AT91SAM9X5_BASE_USART3;
 }
 #endif
+
+#ifdef CONFIG_WATCHDOG_AT91SAM9X
+static int at91_add_device_watchdog(void)
+{
+	add_generic_device("at91sam9_wdt", DEVICE_ID_SINGLE, NULL,
+		AT91_WDT + AT91_BASE_SYS, 16, IORESOURCE_MEM, NULL);
+
+	return 0;
+}
+coredevice_initcall(at91_add_device_watchdog);
+#endif
Signature · 7 lines
1.7.10.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox