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

Stefano Babic sbabic at denx.de
Fri Aug 17 12:00:03 CEST 2012


On 15/08/2012 22:46, Troy Kisky wrote:
> 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
> 

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
=====================================================================


More information about the U-Boot mailing list