public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/1] mx51/mx53/mx6: add watchdog
@ 2012-08-15 20:46 Troy Kisky
  2012-08-17 10:00 ` Stefano Babic
  0 siblings, 1 reply; 3+ messages in thread
From: Troy Kisky @ 2012-08-15 20:46 UTC (permalink / raw)
  To: u-boot

Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com>
---
 arch/arm/cpu/armv7/imx-common/Makefile   |    1 +
 arch/arm/cpu/armv7/imx-common/watchdog.c |   32 ++++++++++++++++++++++++++++++
 2 files changed, 33 insertions(+)
 create mode 100644 arch/arm/cpu/armv7/imx-common/watchdog.c

diff --git a/arch/arm/cpu/armv7/imx-common/Makefile b/arch/arm/cpu/armv7/imx-common/Makefile
index 16fba8d..f3a8e22 100644
--- a/arch/arm/cpu/armv7/imx-common/Makefile
+++ b/arch/arm/cpu/armv7/imx-common/Makefile
@@ -30,6 +30,7 @@ LIB     = $(obj)libimx-common.o
 COBJS-y	= iomux-v3.o timer.o cpu.o speed.o
 COBJS-$(CONFIG_I2C_MXC) += i2c.o
 COBJS-$(CONFIG_CMD_BMODE) += cmd_bmode.o
+COBJS-$(CONFIG_IMX_WATCHDOG) += watchdog.o
 COBJS	:= $(sort $(COBJS-y))
 
 SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
diff --git a/arch/arm/cpu/armv7/imx-common/watchdog.c b/arch/arm/cpu/armv7/imx-common/watchdog.c
new file mode 100644
index 0000000..eadf3e8
--- /dev/null
+++ b/arch/arm/cpu/armv7/imx-common/watchdog.c
@@ -0,0 +1,32 @@
+/*
+ * watchdog.c - driver for i.mx on-chip watchdog
+ *
+ * Licensed under the GPL-2 or later.
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <watchdog.h>
+#include <asm/arch/imx-regs.h>
+
+struct watchdog_regs {
+	u16	wcr;
+	u16	wsr;
+	u16	wrsr;
+	u16	wicr;
+	u16	wmcr;
+};
+
+void hw_watchdog_reset(void)
+{
+	struct watchdog_regs *wdog = (struct watchdog_regs *)WDOG1_BASE_ADDR;
+	writew(0x5555, &wdog->wsr);
+	writew(0xaaaa, &wdog->wsr);
+}
+
+void hw_watchdog_init(void)
+{
+	struct watchdog_regs *wdog = (struct watchdog_regs *)WDOG1_BASE_ADDR;
+	writew(0xFF8F, &wdog->wcr);
+	hw_watchdog_reset();
+}
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-08-17 18:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-15 20:46 [U-Boot] [PATCH 1/1] mx51/mx53/mx6: add watchdog Troy Kisky
2012-08-17 10:00 ` Stefano Babic
2012-08-17 18:09   ` Troy Kisky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox