[U-Boot] [PATCH 1/1] mx51/mx53/mx6: add watchdog

Troy Kisky troy.kisky at boundarydevices.com
Wed Aug 15 22:46:59 CEST 2012


Signed-off-by: Troy Kisky <troy.kisky at 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



More information about the U-Boot mailing list