linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: arnd@arndb.de (Arnd Bergmann)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCHv2 5/5] ARM: picoxcell: implement watchdog restart
Date: Sat, 17 Dec 2011 21:17 +0100	[thread overview]
Message-ID: <1771411.xn5pEUbjJo@wuerfel> (raw)
In-Reply-To: <1324129357-16030-6-git-send-email-jamie@jamieiles.com>

On Saturday 17 December 2011 13:42:37 Jamie Iles wrote:
> Allow the platform to be restarted by triggering the watchdog to expire
> with the shortest possible expiry.  This should reset the CPU core and
> all on-chip peripherals.
> 
> Signed-off-by: Jamie Iles <jamie@jamieiles.com>

Hi Jamie,

> @@ -23,6 +24,22 @@
>  
>  #include "common.h"
>  
> +#define WDT_CTRL_REG_EN_MASK	(1 << 0)
> +#define WDT_CTRL_REG_OFFS	(0x00)
> +#define WDT_TIMEOUT_REG_OFFS	(0x04)
> +static void __iomem *wdt_regs;
> +
> +static void picoxcell_setup_restart(void)
> +{
> +	struct device_node *np = of_find_compatible_node(NULL, NULL,
> +							 "snps,dw-apb-wdg");
> +	if (WARN(!np, "unable to setup watchdog restart"))
> +		return;
> +
> +	wdt_regs = of_iomap(np, 0);
> +	WARN(!wdt_regs, "failed to remap watchdog regs");
> +}

Can you do this at restart time? I think it would be nicer to
avoid the global variable and init function and instead have
everything in a single function call for restart

> +static void picoxcell_wdt_restart(char mode, const char *cmd)
> +{
> +	/*
> +	 * Configure the watchdog to reset with the shortest possible timeout
> +	 * and give it chance to do the reset.
> +	 */
> +	if (wdt_regs) {
> +		__raw_writel(WDT_CTRL_REG_EN_MASK, wdt_regs + WDT_CTRL_REG_OFFS);
> +		__raw_writel(0, wdt_regs + WDT_TIMEOUT_REG_OFFS);
> +		mdelay(500);
> +	}
> +}

Does this work if the real watchdog is still running, on a preemtible kernel?

Also, please always use writel_relaxed instead of __raw_writel, and try to use
msleep instead of mdelay by default. If msleep doesn't work here because it
actually causes the system not to be reset, just add a comment.

	Arnd

  reply	other threads:[~2011-12-17 20:17 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-17 13:42 [PATCHv2 0/5] Misc picoxcell updates for 3.3 Jamie Iles
2011-12-17 13:42 ` [PATCHv2 1/5] ARM: picoxcell: remove mach/memory.h Jamie Iles
2011-12-17 13:42 ` [PATCHv2 2/5] ARM: picoxcell: don't reserve irq_descs Jamie Iles
2011-12-17 13:42 ` [PATCHv2 3/5] ARM: picoxcell: move io mappings to common.c Jamie Iles
2011-12-17 13:42 ` [PATCHv2 4/5] MAINTAINERS: add maintainer entry for Picochip picoxcell Jamie Iles
2011-12-17 13:42 ` [PATCHv2 5/5] ARM: picoxcell: implement watchdog restart Jamie Iles
2011-12-17 20:17   ` Arnd Bergmann [this message]
2011-12-18  0:05     ` Jamie Iles
2011-12-18  8:13     ` Russell King - ARM Linux
2011-12-18  9:41       ` Jamie Iles
2011-12-17 20:18 ` [PATCHv2 0/5] Misc picoxcell updates for 3.3 Arnd Bergmann

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=1771411.xn5pEUbjJo@wuerfel \
    --to=arnd@arndb.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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;
as well as URLs for NNTP newsgroup(s).