mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 2/7] watchdog: add at91sam9 watchdog support
Date: Mon, 19 Nov 2012 10:59:29 +0100	[thread overview]
Message-ID: <20121119095929.GH8327@game.jcrosoft.org> (raw)
In-Reply-To: <20121119093613.GI10369@pengutronix.de>

On 10:36 Mon 19 Nov     , Sascha Hauer wrote:
> 
> On Fri, Nov 16, 2012 at 06:55:40PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > with keep alive support
> > 
> > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> > ---
> >  drivers/watchdog/Kconfig        |    7 +++
> >  drivers/watchdog/Makefile       |    1 +
> >  drivers/watchdog/at91sam9_wdt.c |  131 +++++++++++++++++++++++++++++++++++++++
> >  drivers/watchdog/at91sam9_wdt.h |   38 ++++++++++++
> >  4 files changed, 177 insertions(+)
> >  create mode 100644 drivers/watchdog/at91sam9_wdt.c
> >  create mode 100644 drivers/watchdog/at91sam9_wdt.h
> > 
> > diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
> > index 21480a1..5bd1083 100644
> > --- a/drivers/watchdog/Kconfig
> > +++ b/drivers/watchdog/Kconfig
> > @@ -7,6 +7,13 @@ menuconfig WATCHDOG
> >  
> >  if WATCHDOG
> >  
> > +config WATCHDOG_AT91SAM9X
> > +	tristate "AT91SAM9X / AT91CAP9 watchdog"
> > +	depends on ARCH_AT91
> > +	help
> > +	  Watchdog timer embedded into AT91SAM9X and AT91CAP9 chips. This will
> > +	  reboot your system when the timeout is reached.
> > +
> >  config WATCHDOG_MXS28
> >  	bool "i.MX28"
> >  	depends on ARCH_IMX28
> > diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
> > index b29103b..4e863a5 100644
> > --- a/drivers/watchdog/Makefile
> > +++ b/drivers/watchdog/Makefile
> > @@ -1,2 +1,3 @@
> >  obj-$(CONFIG_WATCHDOG) += wd_core.o
> > +obj-$(CONFIG_WATCHDOG_AT91SAM9X) += at91sam9_wdt.o
> >  obj-$(CONFIG_WATCHDOG_MXS28) += im28wd.o
> > diff --git a/drivers/watchdog/at91sam9_wdt.c b/drivers/watchdog/at91sam9_wdt.c
> > new file mode 100644
> > index 0000000..203d83a
> > --- /dev/null
> > +++ b/drivers/watchdog/at91sam9_wdt.c
> > @@ -0,0 +1,131 @@
> > +/*
> > + * (c) 2012 Juergen Beisert <kernel@pengutronix.de>
> 
> Juergen Beisert?
> 
> > + *
> > + * This program is free software; you can redistribute it and/or modify
> > + * it under the terms of the GNU General Public License as published by
> > + * the Free Software Foundation; either version 2 of the License, or
> > + * (at your option) any later version.
> > + *
> > + * This program is distributed in the hope that it will be useful,
> > + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> > + * GNU General Public License for more details.
> > + *
> > + * Note: this driver works for the i.MX28 SoC. It might work for the
> > + * i.MX23 Soc as well, but is not tested yet.
> 
> This might work on i.MX23?
> 
> > +
> > +static void at91sam9_wdt_keep_alive(struct watchdog *wdt)
> > +{
> > +	struct at91sam9_wdt *at91wdt = to_at91sam9_wdt(wdt);
> > +
> > +	wdt_write(at91wdt, AT91_WDT_CR, AT91_WDT_KEY | AT91_WDT_WDRSTT);
> > +}
> > +
> > +static int at91sam9_wdt_settimeout(struct watchdog *wdt, unsigned int timeout)
> > +{
> > +	struct at91sam9_wdt *at91wdt = to_at91sam9_wdt(wdt);
> > +	unsigned int reg;
> > +	unsigned int mr;
> > +
> > +	/* Check if disabled */
> > +	mr = wdt_read(at91wdt, AT91_WDT_MR);
> > +	if (mr & AT91_WDT_WDDIS) {
> > +		pr_err("sorry, watchdog is disabled\n");
> > +		return -EIO;
> > +	}
> > +
> > +	if (!timeout) {
> > +		wdt_write(at91wdt, AT91_WDT_MR, AT91_WDT_WDDIS);
> > +		return 0;
> > +	}
> > +
> > +	/*
> > +	 * All counting occurs at SLOW_CLOCK / 128 = 256 Hz
> > +	 *
> > +	 * Since WDV is a 12-bit counter, the maximum period is
> > +	 * 4096 / 256 = 16 seconds.
> > +	 */
> > +	reg = AT91_WDT_WDRSTEN	/* causes watchdog reset */
> > +		/* | AT91_WDT_WDRPROC	causes processor reset only */
> > +		| AT91_WDT_WDDBGHLT	/* disabled in debug mode */
> > +		| AT91_WDT_WDD		/* restart at any time */
> > +		| (timeout & AT91_WDT_WDV);  /* timer value */
> > +	wdt_write(at91wdt, AT91_WDT_MR, reg);
> 
> This driver does not work like the watchdog API is supposed to work. It
> currently works in the way that the watchdog command calls the
> settimeout callback to keep the watchdog alive, hence we do not need
> an explicit keepalive callback. Whether this API is good is debatable,
> but this patch violates it and renders the watchdog command useless.
The watchdod commad just need to enable the watchdog/change the timeout or
diabled 

the rest need to be automatic

so we need to fix the API

because I can not add wd command in long nfs or tftp transfert

Best Regards,
J.

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2012-11-19 10:01 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-16 17:53 [PATCH 0/7 v2] at91sam9 add watchdog support with keep alive Jean-Christophe PLAGNIOL-VILLARD
2012-11-16 17:55 ` [PATCH 1/7] watchdog: add keep alive support Jean-Christophe PLAGNIOL-VILLARD
2012-11-16 17:55   ` [PATCH 2/7] watchdog: add at91sam9 watchdog support Jean-Christophe PLAGNIOL-VILLARD
2012-11-19  9:36     ` Sascha Hauer
2012-11-19  9:59       ` Jean-Christophe PLAGNIOL-VILLARD [this message]
2012-11-16 17:55   ` [PATCH 3/7] at91sam9260/9g20: add wathdog support Jean-Christophe PLAGNIOL-VILLARD
2012-11-16 17:55   ` [PATCH 4/7] at91sam9261/9g10: " Jean-Christophe PLAGNIOL-VILLARD
2012-11-16 17:55   ` [PATCH 5/7] at91sam9263: " Jean-Christophe PLAGNIOL-VILLARD
2012-11-16 17:55   ` [PATCH 6/7] at91sam9g45: " Jean-Christophe PLAGNIOL-VILLARD
2012-11-16 17:55   ` [PATCH 7/7] at91sam9x5: " Jean-Christophe PLAGNIOL-VILLARD
2012-11-19  9:38   ` [PATCH 1/7] watchdog: add keep alive support Sascha Hauer
2012-11-19 10:08     ` Jean-Christophe PLAGNIOL-VILLARD
2013-01-17  9:36 ` [PATCH 0/7 v2] at91sam9 add watchdog support with keep alive Fabio Porcedda
  -- strict thread matches above, loose matches on Subject: below --
2012-11-16 16:57 [PATCH 0/7] " Jean-Christophe PLAGNIOL-VILLARD
2012-11-16 17:02 ` [PATCH 1/7] watchdog: add keep alive support Jean-Christophe PLAGNIOL-VILLARD
2012-11-16 17:03   ` [PATCH 2/7] watchdog: add at91sam9 watchdog support Jean-Christophe PLAGNIOL-VILLARD

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=20121119095929.GH8327@game.jcrosoft.org \
    --to=plagnioj@jcrosoft.com \
    --cc=barebox@lists.infradead.org \
    --cc=s.hauer@pengutronix.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