Re: [PATCH v6 1/2] drivers: watchdog: add a driver to support SAMA5D4 watchdog timer
On 08/27/2015 06:30 PM, Yang, Wenyou wrote: -Original Message- From: Guenter Roeck [mailto:li...@roeck-us.net] Sent: 2015年8月7日 23:26 To: Yang, Wenyou; w...@iguana.be; robh...@kernel.org; pawel.m...@arm.com; mark.rutl...@arm.com; ijc+devicet...@hellion.org.uk; ga...@codeaurora.org Cc: sylvain.roc...@finsecur.com; Ferre, Nicolas; boris.brezillon@free- electrons.com; devicetree@vger.kernel.org; linux-ker...@vger.kernel.org; linux- watch...@vger.kernel.org Subject: Re: [PATCH v6 1/2] drivers: watchdog: add a driver to support SAMA5D4 watchdog timer On 08/06/2015 03:16 AM, Wenyou Yang wrote: >From SAMA5D4, the watchdog timer is upgrated with a new feature, which is describled as in the datasheet, "WDT_MR can be written until a LOCKMR command is issued in WDT_CR". That is to say, as long as the bootstrap and u-boot don't issue a LOCKMR command, WDT_MR can be written more than once in the driver. So the SAMA5D4 watchdog driver's implementation is different from the at91sam9260 watchdog driver implemented in file at91sam9_wdt.c. The user application open the device file to enable the watchdog timer hardware, and close to disable it, and set the watchdog timer timeout by seting WDV and WDD fields of WDT_MR register, and ping the watchdog by issuing WDRSTT command to WDT_CR register with hard-coded key. Signed-off-by: Wenyou Yang Reviewed-by: Guenter Roeck Hi Vim, Can this patch series be merged? Could you please? It is included in the pull request I sent to Wim last week. Guenter -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [PATCH v6 1/2] drivers: watchdog: add a driver to support SAMA5D4 watchdog timer
> -Original Message- > From: Guenter Roeck [mailto:li...@roeck-us.net] > Sent: 2015年8月7日 23:26 > To: Yang, Wenyou; w...@iguana.be; robh...@kernel.org; pawel.m...@arm.com; > mark.rutl...@arm.com; ijc+devicet...@hellion.org.uk; ga...@codeaurora.org > Cc: sylvain.roc...@finsecur.com; Ferre, Nicolas; boris.brezillon@free- > electrons.com; devicetree@vger.kernel.org; linux-ker...@vger.kernel.org; > linux- > watch...@vger.kernel.org > Subject: Re: [PATCH v6 1/2] drivers: watchdog: add a driver to support SAMA5D4 > watchdog timer > > On 08/06/2015 03:16 AM, Wenyou Yang wrote: > >>From SAMA5D4, the watchdog timer is upgrated with a new feature, > > which is describled as in the datasheet, "WDT_MR can be written until > > a LOCKMR command is issued in WDT_CR". > > That is to say, as long as the bootstrap and u-boot don't issue a > > LOCKMR command, WDT_MR can be written more than once in the driver. > > > > So the SAMA5D4 watchdog driver's implementation is different from the > > at91sam9260 watchdog driver implemented in file at91sam9_wdt.c. > > The user application open the device file to enable the watchdog timer > > hardware, and close to disable it, and set the watchdog timer timeout > > by seting WDV and WDD fields of WDT_MR register, and ping the watchdog > > by issuing WDRSTT command to WDT_CR register with hard-coded key. > > > > Signed-off-by: Wenyou Yang > > Reviewed-by: Guenter Roeck Hi Vim, Can this patch series be merged? Could you please? Best Regards, Wenyou Yang
Re: [PATCH v6 1/2] drivers: watchdog: add a driver to support SAMA5D4 watchdog timer
On 08/06/2015 03:16 AM, Wenyou Yang wrote: From SAMA5D4, the watchdog timer is upgrated with a new feature, which is describled as in the datasheet, "WDT_MR can be written until a LOCKMR command is issued in WDT_CR". That is to say, as long as the bootstrap and u-boot don't issue a LOCKMR command, WDT_MR can be written more than once in the driver. So the SAMA5D4 watchdog driver's implementation is different from the at91sam9260 watchdog driver implemented in file at91sam9_wdt.c. The user application open the device file to enable the watchdog timer hardware, and close to disable it, and set the watchdog timer timeout by seting WDV and WDD fields of WDT_MR register, and ping the watchdog by issuing WDRSTT command to WDT_CR register with hard-coded key. Signed-off-by: Wenyou Yang Reviewed-by: Guenter Roeck -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v6 1/2] drivers: watchdog: add a driver to support SAMA5D4 watchdog timer
>From SAMA5D4, the watchdog timer is upgrated with a new feature, which is describled as in the datasheet, "WDT_MR can be written until a LOCKMR command is issued in WDT_CR". That is to say, as long as the bootstrap and u-boot don't issue a LOCKMR command, WDT_MR can be written more than once in the driver. So the SAMA5D4 watchdog driver's implementation is different from the at91sam9260 watchdog driver implemented in file at91sam9_wdt.c. The user application open the device file to enable the watchdog timer hardware, and close to disable it, and set the watchdog timer timeout by seting WDV and WDD fields of WDT_MR register, and ping the watchdog by issuing WDRSTT command to WDT_CR register with hard-coded key. Signed-off-by: Wenyou Yang --- drivers/watchdog/Kconfig|9 ++ drivers/watchdog/Makefile |1 + drivers/watchdog/at91sam9_wdt.h |2 + drivers/watchdog/sama5d4_wdt.c | 280 +++ 4 files changed, 292 insertions(+) create mode 100644 drivers/watchdog/sama5d4_wdt.c diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig index e5e7c55..47ad39a 100644 --- a/drivers/watchdog/Kconfig +++ b/drivers/watchdog/Kconfig @@ -167,6 +167,15 @@ config AT91SAM9X_WATCHDOG Watchdog timer embedded into AT91SAM9X and AT91CAP9 chips. This will reboot your system when the timeout is reached. +config SAMA5D4_WATCHDOG + tristate "Atmel SAMA5D4 Watchdog Timer" + depends on ARCH_AT91 + select WATCHDOG_CORE + help + Atmel SAMA5D4 watchdog timer is embedded into SAMA5D4 chips. + Its Watchdog Timer Mode Register can be written more than once. + This will reboot your system when the timeout is reached. + config CADENCE_WATCHDOG tristate "Cadence Watchdog Timer" select WATCHDOG_CORE diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile index 5c19294..f24b820 100644 --- a/drivers/watchdog/Makefile +++ b/drivers/watchdog/Makefile @@ -41,6 +41,7 @@ obj-$(CONFIG_IXP4XX_WATCHDOG) += ixp4xx_wdt.o obj-$(CONFIG_KS8695_WATCHDOG) += ks8695_wdt.o obj-$(CONFIG_S3C2410_WATCHDOG) += s3c2410_wdt.o obj-$(CONFIG_SA1100_WATCHDOG) += sa1100_wdt.o +obj-$(CONFIG_SAMA5D4_WATCHDOG) += sama5d4_wdt.o obj-$(CONFIG_DW_WATCHDOG) += dw_wdt.o obj-$(CONFIG_EP93XX_WATCHDOG) += ep93xx_wdt.o obj-$(CONFIG_PNX4008_WATCHDOG) += pnx4008_wdt.o diff --git a/drivers/watchdog/at91sam9_wdt.h b/drivers/watchdog/at91sam9_wdt.h index c6fbb2e6..b79a83b 100644 --- a/drivers/watchdog/at91sam9_wdt.h +++ b/drivers/watchdog/at91sam9_wdt.h @@ -22,11 +22,13 @@ #define AT91_WDT_MR0x04/* Watchdog Mode Register */ #defineAT91_WDT_WDV(0xfff << 0)/* Counter Value */ +#defineAT91_WDT_SET_WDV(x) ((x) & AT91_WDT_WDV) #defineAT91_WDT_WDFIEN (1 << 12) /* Fault Interrupt Enable */ #defineAT91_WDT_WDRSTEN(1 << 13) /* Reset Processor */ #defineAT91_WDT_WDRPROC(1 << 14) /* Timer Restart */ #defineAT91_WDT_WDDIS (1 << 15) /* Watchdog Disable */ #defineAT91_WDT_WDD(0xfff << 16) /* Delta Value */ +#defineAT91_WDT_SET_WDD(x) (((x) << 16) & AT91_WDT_WDD) #defineAT91_WDT_WDDBGHLT (1 << 28) /* Debug Halt */ #defineAT91_WDT_WDIDLEHLT (1 << 29) /* Idle Halt */ diff --git a/drivers/watchdog/sama5d4_wdt.c b/drivers/watchdog/sama5d4_wdt.c new file mode 100644 index 000..a49634c --- /dev/null +++ b/drivers/watchdog/sama5d4_wdt.c @@ -0,0 +1,280 @@ +/* + * Driver for Atmel SAMA5D4 Watchdog Timer + * + * Copyright (C) 2015 Atmel Corporation + * + * Licensed under GPLv2. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "at91sam9_wdt.h" + +/* minimum and maximum watchdog timeout, in seconds */ +#define MIN_WDT_TIMEOUT1 +#define MAX_WDT_TIMEOUT16 +#define WDT_DEFAULT_TIMEOUTMAX_WDT_TIMEOUT + +#define WDT_SEC2TICKS(s) ((s) ? (((s) << 8) - 1) : 0) + +struct sama5d4_wdt { + struct watchdog_device wdd; + void __iomem*reg_base; + u32 config; +}; + +static int wdt_timeout = WDT_DEFAULT_TIMEOUT; +static bool nowayout = WATCHDOG_NOWAYOUT; + +module_param(wdt_timeout, int, 0); +MODULE_PARM_DESC(wdt_timeout, + "Watchdog timeout in seconds. (default = " + __MODULE_STRING(WDT_DEFAULT_TIMEOUT) ")"); + +module_param(nowayout, bool, 0); +MODULE_PARM_DESC(nowayout, + "Watchdog cannot be stopped once started (default=" + __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); + +#define wdt_read(wdt, field) \ + readl_relaxed((wdt)->reg_base + (field)) + +#define wdt_write(wtd, field, val)