* [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
* [U-Boot] [PATCH 1/1] mx51/mx53/mx6: add watchdog
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
0 siblings, 1 reply; 3+ messages in thread
From: Stefano Babic @ 2012-08-17 10:00 UTC (permalink / raw)
To: u-boot
On 15/08/2012 22:46, Troy Kisky wrote:
> 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
>
Hi Troy,
> 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);
we should use clrsetbit instead
Number of seconds is fix. Should be configurable ?
> + hw_watchdog_reset();
> +}
I have understood that the watchdog is common on all i.MX. At the
moment, quite the same implementation is in mainline for i.MX31, you can
find it under arch/arm/cpu/arm1136/mx31/timer.c.
Then it is not a bad idea to have a watchdog driver in drivers/watchdog.
Feel free to add a driver here and replacing the i.MX31 stuff.
Best regards,
Stefano Babic
--
=====================================================================
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================
^ permalink raw reply [flat|nested] 3+ messages in thread
* [U-Boot] [PATCH 1/1] mx51/mx53/mx6: add watchdog
2012-08-17 10:00 ` Stefano Babic
@ 2012-08-17 18:09 ` Troy Kisky
0 siblings, 0 replies; 3+ messages in thread
From: Troy Kisky @ 2012-08-17 18:09 UTC (permalink / raw)
To: u-boot
On 8/17/2012 3:00 AM, Stefano Babic wrote:
> I have understood that the watchdog is common on all i.MX. At the
> moment, quite the same implementation is in mainline for i.MX31, you
> can find it under arch/arm/cpu/arm1136/mx31/timer.c. Then it is not a
> bad idea to have a watchdog driver in drivers/watchdog. Feel free to
> add a driver here and replacing the i.MX31 stuff. Best regards,
> Stefano Babic
Will do.
Thanks
Troy
^ permalink raw reply [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