public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Stefano Babic <sbabic@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 1/1] mx51/mx53/mx6: add watchdog
Date: Fri, 17 Aug 2012 12:00:03 +0200	[thread overview]
Message-ID: <502E1623.1080902@denx.de> (raw)
In-Reply-To: <1345063619-19308-1-git-send-email-troy.kisky@boundarydevices.com>

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

  reply	other threads:[~2012-08-17 10:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-15 20:46 [U-Boot] [PATCH 1/1] mx51/mx53/mx6: add watchdog Troy Kisky
2012-08-17 10:00 ` Stefano Babic [this message]
2012-08-17 18:09   ` Troy Kisky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=502E1623.1080902@denx.de \
    --to=sbabic@denx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox