Re: [PATCH 2/3] watchdog: sam9x60_wdt: introduce sam9x60 watchdog timer driver

From: Eugen.Hristev
Date: Mon Oct 07 2019 - 03:58:52 EST




On 02.10.2019 16:16, Guenter Roeck wrote:

>
> On 10/2/19 12:35 AM, Eugen.Hristev@xxxxxxxxxxxxx wrote:
>> From: Eugen Hristev <eugen.hristev@xxxxxxxxxxxxx>
>>
>> This is the driver for SAM9X60 watchdog timer.
>> The offered functionality is the same as sama5d4_wdt.
>> The difference comes in register map, way to configure the timeout and
>> interrupts.
>> Developed starting from sama5d4_wdt.c
>>
>> Signed-off-by: Eugen Hristev <eugen.hristev@xxxxxxxxxxxxx>
>> ---
>> Â drivers/watchdog/KconfigÂÂÂÂÂÂ |ÂÂ 9 ++
>> Â drivers/watchdog/MakefileÂÂÂÂÂ |ÂÂ 1 +
>> Â drivers/watchdog/sam9x60_wdt.c | 335
>> +++++++++++++++++++++++++++++++++++++++++
>> Â 3 files changed, 345 insertions(+)
>> Â create mode 100644 drivers/watchdog/sam9x60_wdt.c
>>
>> diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
>> index 58e7c10..3562e26 100644
>> --- a/drivers/watchdog/Kconfig
>> +++ b/drivers/watchdog/Kconfig
>> @@ -416,6 +416,15 @@ config SAMA5D4_WATCHDOG
>> ÂÂÂÂÂÂÂ Its Watchdog Timer Mode Register can be written more than once.
>> ÂÂÂÂÂÂÂ This will reboot your system when the timeout is reached.
>> +config SAM9X60_WATCHDOG
>> +ÂÂÂ tristate "Microchip SAM9X60 Watchdog Timer"
>> +ÂÂÂ depends on ARCH_AT91 || COMPILE_TEST
>
> depends on HAS_IOMEM
>
>> +ÂÂÂ select WATCHDOG_CORE
>> +ÂÂÂ help
>> +ÂÂÂÂÂ Microchip SAM9X60 watchdog timer is embedded into SAM9X60 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"
>> ÂÂÂÂÂ depends on HAS_IOMEM
>> diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
>> index 2ee352b..93ba599 100644
>> --- a/drivers/watchdog/Makefile
>> +++ b/drivers/watchdog/Makefile
>> @@ -52,6 +52,7 @@ obj-$(CONFIG_IXP4XX_WATCHDOG) += ixp4xx_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_SAM9X60_WATCHDOG) += sam9x60_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/sam9x60_wdt.c
>> b/drivers/watchdog/sam9x60_wdt.c
>> new file mode 100644
>> index 00000000..f612230
>> --- /dev/null
>> +++ b/drivers/watchdog/sam9x60_wdt.c
>> @@ -0,0 +1,335 @@
>> +// SPDX-License-Identifier: GPL-2.0
>> +/*
>> + * Driver for Microchip SAM9X60 Watchdog Timer
>> + *
>> + * Copyright (C) 2019 Microchip Technology, Inc.
>> + * Author: Eugen Hristev <eugen.hristev@xxxxxxxxxxxxx>
>> + *
>> + */
>> +
>> +#include <linux/delay.h>
>> +#include <linux/interrupt.h>
>> +#include <linux/io.h>
>> +#include <linux/kernel.h>
>> +#include <linux/module.h>
>> +#include <linux/of.h>
>> +#include <linux/of_irq.h>
>> +#include <linux/platform_device.h>
>> +#include <linux/reboot.h>
>> +#include <linux/watchdog.h>
>> +
>> +#define AT91_WDT_CRÂÂÂÂÂÂÂ 0x00ÂÂÂÂÂÂÂÂÂÂÂ /* Watchdog Control
>> Register */
>> +#defineÂÂÂÂÂÂÂ AT91_WDT_WDRSTTÂÂÂÂÂÂÂ BIT(0)ÂÂÂÂÂÂÂ /* Restart */
>> +#defineÂÂÂÂÂÂÂ AT91_WDT_KEYÂÂÂÂÂÂÂ (0xa5 << 24)ÂÂÂÂÂÂÂ /* KEY
>> Password */
>> +
>> +#define AT91_WDT_MRÂÂÂÂÂÂÂ 0x04ÂÂÂÂÂÂÂÂÂÂÂ /* Watchdog Mode Register */
>> +#defineÂÂÂÂÂÂÂ AT91_WDT_PERIODRSTÂÂÂ BIT(4)ÂÂÂÂÂÂÂ /* Period Reset */
>> +#defineÂÂÂÂÂÂÂ AT91_WDT_RPTHRSTÂÂÂ BIT(5)ÂÂÂÂÂÂÂ /* Minimum Restart
>> Period */
>> +#defineÂÂÂÂÂÂÂ AT91_WDT_WDDISÂÂÂÂÂÂÂ BIT(12)ÂÂÂÂÂÂÂ /* Disable */
>> +#defineÂÂÂÂÂÂÂ AT91_WDT_WDDBGHLTÂÂÂ BIT(28)ÂÂÂÂÂÂÂ /* Debug Halt */
>> +#defineÂÂÂÂÂÂÂ AT91_WDT_WDIDLEHLTÂÂÂ BIT(29)ÂÂÂÂÂÂÂ /* Idle Halt */
>> +
>> +#define AT91_WDT_VRÂÂÂÂÂÂÂ 0x08ÂÂÂÂÂÂÂÂÂÂÂ /* Watchdog Timer Value
>> Register */
>> +
>> +#define AT91_WDT_WLRÂÂÂÂÂÂÂ 0x0c
>> +#defineÂÂÂÂÂÂÂ AT91_WDT_COUNTERÂÂÂ (0xfff << 0)ÂÂÂÂÂÂÂ /* Watchdog
>> Period Value */
>> +#defineÂÂÂÂÂÂÂ AT91_WDT_SET_COUNTER(x)ÂÂÂ ((x) & AT91_WDT_COUNTER)
>> +
>> +#define AT91_WDT_IERÂÂÂÂÂÂÂ 0x14ÂÂÂÂÂÂÂÂÂÂÂ /* Interrupt Enable
>> Register */
>> +#defineÂÂÂÂÂÂÂ AT91_WDT_PERINTÂÂÂÂÂÂÂ BIT(0)ÂÂÂÂÂÂÂ /* Period
>> Interrupt Enable */
>> +#define AT91_WDT_IDRÂÂÂÂÂÂÂ 0x18ÂÂÂÂÂÂÂÂÂÂÂ /* Interrupt Disable
>> Register */
>> +#define AT91_WDT_ISRÂÂÂÂÂÂÂ 0x1cÂÂÂÂÂÂÂÂÂÂÂ /* Interrupt Status
>> Register */
>> +
>> +/* minimum and maximum watchdog timeout, in seconds */
>> +#define MIN_WDT_TIMEOUTÂÂÂÂÂÂÂ 1
>> +#define MAX_WDT_TIMEOUTÂÂÂÂÂÂÂ 16
>> +#define WDT_DEFAULT_TIMEOUTÂÂÂ MAX_WDT_TIMEOUT
>> +
>> +#define WDT_SEC2TICKS(s)ÂÂÂ ((s) ? (((s) << 8) - 1) : 0)
>> +
>> +struct sam9x60_wdt {
>> +ÂÂÂ struct watchdog_deviceÂÂÂ wdd;
>> +ÂÂÂ void __iomemÂÂÂÂÂÂÂ *reg_base;
>> +ÂÂÂ u32ÂÂÂÂÂÂÂÂÂÂÂ mr;
>> +ÂÂÂ u32ÂÂÂÂÂÂÂÂÂÂÂ ir;
>> +ÂÂÂ unsigned longÂÂÂÂÂÂÂ last_ping;
>> +};
>> +
>> +static int wdt_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_enabled (!(wdt->mr & AT91_WDT_WDDIS))
>
> Please no use in variables in macros without referencing them in the
> argument.
>
>> +
>> +#define wdt_read(wdt, field) \
>> +ÂÂÂ readl_relaxed((wdt)->reg_base + (field))
>> +
>> +/* 4 slow clock periods is 4/32768 = 122.07us*/
>> +#define WDT_DELAYÂÂÂ usecs_to_jiffies(123)
>> +
>> +static void wdt_write(struct sam9x60_wdt *wdt, u32 field, u32 val)
>> +{
>> +ÂÂÂ /*
>> +ÂÂÂÂ * WDT_CR and WDT_MR must not be modified within three slow clock
>> +ÂÂÂÂ * periods following a restart of the watchdog performed by a write
>> +ÂÂÂÂ * access in WDT_CR.
>> +ÂÂÂÂ */
>> +ÂÂÂ while (time_before(jiffies, wdt->last_ping + WDT_DELAY))
>> +ÂÂÂÂÂÂÂ usleep_range(30, 125);
>> +ÂÂÂ writel_relaxed(val, wdt->reg_base + field);
>> +ÂÂÂ wdt->last_ping = jiffies;
>> +}
>> +
>> +static void wdt_write_nosleep(struct sam9x60_wdt *wdt, u32 field, u32
>> val)
>> +{
>> +ÂÂÂ if (time_before(jiffies, wdt->last_ping + WDT_DELAY))
>
> WDT_DELAY is most likely 1 under all circumstances. If the last access
> was just before
> a tick, this won't guarantee that really 123 uS expired.
>
> In situations like this, I would suggest not to rely on jiffies related
> functions.
> If the last access time is stored based on ktime_get(), the remaining
> time in
> us can be calculated using ktime_us_delta(). Then just sleep (or delay
> in case
> of nosleep) for that amount of microseconds.
>
> Also, I don't see why this second function would be necessary.
> A single function with an if() should be sufficient.
>
> ÂÂÂÂktime_t delta = WDT_DELAY_US - ktime_us_delta(ktime_get(),
> wdt->last_ping);
>
> ÂÂÂÂif (delta > 0)
> ÂÂÂÂÂÂÂ usleep_range(delta, delta * 2);
> ÂÂÂÂwritel_relaxed(val, wdt->reg_base + field);
> ÂÂÂÂwdt->last_ping = ktime_get();
>
>> +ÂÂÂÂÂÂÂ usleep_range(123, 250);
>> +ÂÂÂ writel_relaxed(val, wdt->reg_base + field);
>> +ÂÂÂ wdt->last_ping = jiffies;
>> +}
>> +
>> +static int sam9x60_wdt_start(struct watchdog_device *wdd)
>> +{
>> +ÂÂÂ struct sam9x60_wdt *wdt = watchdog_get_drvdata(wdd);
>> +
>> +ÂÂÂ wdt->mr &= ~AT91_WDT_WDDIS;
>> +ÂÂÂ wdt_write(wdt, AT91_WDT_MR, wdt->mr);
>> +ÂÂÂ wdt_write_nosleep(wdt, AT91_WDT_IER, wdt->ir);
>> +
>> +ÂÂÂ return 0;
>> +}
>> +
>> +static int sam9x60_wdt_stop(struct watchdog_device *wdd)
>> +{
>> +ÂÂÂ struct sam9x60_wdt *wdt = watchdog_get_drvdata(wdd);
>> +
>> +ÂÂÂ wdt->mr |= AT91_WDT_WDDIS;
>> +ÂÂÂ wdt_write(wdt, AT91_WDT_MR, wdt->mr);
>> +ÂÂÂ wdt_write_nosleep(wdt, AT91_WDT_IDR, wdt->ir);
>> +
>> +ÂÂÂ return 0;
>> +}
>> +
>> +static int sam9x60_wdt_ping(struct watchdog_device *wdd)
>> +{
>> +ÂÂÂ struct sam9x60_wdt *wdt = watchdog_get_drvdata(wdd);
>> +
>> +ÂÂÂ wdt_write(wdt, AT91_WDT_CR, AT91_WDT_KEY | AT91_WDT_WDRSTT);
>> +
>> +ÂÂÂ return 0;
>> +}
>> +
>> +static int sam9x60_wdt_set_timeout(struct watchdog_device *wdd,
>> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ unsigned int timeout)
>> +{
>> +ÂÂÂ struct sam9x60_wdt *wdt = watchdog_get_drvdata(wdd);
>> +
>> +ÂÂÂ wdt_write(wdt, AT91_WDT_WLR,
>> +ÂÂÂÂÂÂÂÂÂ AT91_WDT_SET_COUNTER(WDT_SEC2TICKS(timeout)));
>> +
>> +ÂÂÂ wdd->timeout = timeout;
>> +
>> +ÂÂÂ return 0;
>> +}
>> +
>> +static const struct watchdog_info sam9x60_wdt_info = {
>> +ÂÂÂ .options = WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE |
>> WDIOF_KEEPALIVEPING,
>> +ÂÂÂ .identity = "Microchip SAM9X60 Watchdog",
>> +};
>> +
>> +static const struct watchdog_ops sam9x60_wdt_ops = {
>> +ÂÂÂ .owner = THIS_MODULE,
>> +ÂÂÂ .start = sam9x60_wdt_start,
>> +ÂÂÂ .stop = sam9x60_wdt_stop,
>> +ÂÂÂ .ping = sam9x60_wdt_ping,
>> +ÂÂÂ .set_timeout = sam9x60_wdt_set_timeout,
>> +};
>> +
>> +static irqreturn_t sam9x60_wdt_irq_handler(int irq, void *dev_id)
>> +{
>> +ÂÂÂ struct sam9x60_wdt *wdt = platform_get_drvdata(dev_id);
>> +
>> +ÂÂÂ if (wdt_read(wdt, AT91_WDT_ISR)) {
>> +ÂÂÂÂÂÂÂ pr_crit("Microchip Watchdog Software Reset\n");
>> +ÂÂÂÂÂÂÂ emergency_restart();
>> +ÂÂÂÂÂÂÂ pr_crit("Reboot didn't succeed\n");
>> +ÂÂÂ }
>> +
>> +ÂÂÂ return IRQ_HANDLED;
>> +}
>> +
>> +static int of_sam9x60_wdt_init(struct device_node *np, struct
>> sam9x60_wdt *wdt)
>> +{
>> +ÂÂÂ const char *tmp;
>> +
>> +ÂÂÂ wdt->mr = AT91_WDT_WDDIS;
>> +
>> +ÂÂÂ if (!of_property_read_string(np, "atmel,watchdog-type", &tmp) &&
>> +ÂÂÂÂÂÂÂ !strcmp(tmp, "software"))
>> +ÂÂÂÂÂÂÂ wdt->ir = AT91_WDT_PERINT;
>> +ÂÂÂ else
>> +ÂÂÂÂÂÂÂ wdt->mr |= AT91_WDT_PERIODRST;
>> +
>> +ÂÂÂ if (of_property_read_bool(np, "atmel,idle-halt"))
>> +ÂÂÂÂÂÂÂ wdt->mr |= AT91_WDT_WDIDLEHLT;
>> +
>> +ÂÂÂ if (of_property_read_bool(np, "atmel,dbg-halt"))
>> +ÂÂÂÂÂÂÂ wdt->mr |= AT91_WDT_WDDBGHLT;
>> +
>> +ÂÂÂ return 0;
>> +}
>> +
>> +static int sam9x60_wdt_init(struct sam9x60_wdt *wdt)
>> +{
>> +ÂÂÂ u32 reg;
>> +ÂÂÂ /*
>> +ÂÂÂÂ * When booting and resuming, the bootloader may have changed the
>> +ÂÂÂÂ * watchdog configuration.
>> +ÂÂÂÂ * If the watchdog is already running, we can safely update it.
>> +ÂÂÂÂ * Else, we have to disable it properly.
>> +ÂÂÂÂ */
>> +ÂÂÂ if (wdt_enabled) {
>> +ÂÂÂÂÂÂÂ wdt_write_nosleep(wdt, AT91_WDT_MR, wdt->mr);
>> +ÂÂÂÂÂÂÂ wdt_write_nosleep(wdt, AT91_WDT_IER, wdt->ir);
>> +ÂÂÂÂÂÂÂ wdt_write(wdt, AT91_WDT_WLR,
>> +ÂÂÂÂÂÂÂÂÂÂÂÂÂ AT91_WDT_SET_COUNTER(WDT_SEC2TICKS(WDT_DEFAULT_TIMEOUT)));
>> +
>> +ÂÂÂ } else {
>> +ÂÂÂÂÂÂÂ reg = wdt_read(wdt, AT91_WDT_MR);
>> +ÂÂÂÂÂÂÂ if (!(reg & AT91_WDT_WDDIS))
>> +ÂÂÂÂÂÂÂÂÂÂÂ wdt_write_nosleep(wdt, AT91_WDT_MR,
>> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ reg | AT91_WDT_WDDIS);
>> +ÂÂÂ }
>
> If the watchdog may be running at boot time, the watchdog core
> should be informed about it.
>
>> +ÂÂÂ return 0;
>> +}
>> +
>> +static int sam9x60_wdt_probe(struct platform_device *pdev)
>> +{
>> +ÂÂÂ struct watchdog_device *wdd;
>> +ÂÂÂ struct sam9x60_wdt *wdt;
>> +ÂÂÂ struct resource *res;
>> +ÂÂÂ void __iomem *regs;
>> +ÂÂÂ u32 irq = 0;
>
> Unnecessary initialization.
>
>> +ÂÂÂ int ret;
>> +
>> +ÂÂÂ wdt = devm_kzalloc(&pdev->dev, sizeof(*wdt), GFP_KERNEL);
>> +ÂÂÂ if (!wdt)
>> +ÂÂÂÂÂÂÂ return -ENOMEM;
>> +
>> +ÂÂÂ wdd = &wdt->wdd;
>> +ÂÂÂ wdd->timeout = WDT_DEFAULT_TIMEOUT;
>> +ÂÂÂ wdd->info = &sam9x60_wdt_info;
>> +ÂÂÂ wdd->ops = &sam9x60_wdt_ops;
>> +ÂÂÂ wdd->min_timeout = MIN_WDT_TIMEOUT;
>> +ÂÂÂ wdd->max_timeout = MAX_WDT_TIMEOUT;
>> +ÂÂÂ wdt->last_ping = jiffies;
>> +
>> +ÂÂÂ watchdog_set_drvdata(wdd, wdt);
>> +
>> +ÂÂÂ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>> +ÂÂÂ regs = devm_ioremap_resource(&pdev->dev, res);
>
> devm_platform_ioremap_resource()
>
>> +ÂÂÂ if (IS_ERR(regs))
>> +ÂÂÂÂÂÂÂ return PTR_ERR(regs);
>> +
>> +ÂÂÂ wdt->reg_base = regs;
>> +
>> +ÂÂÂ irq = irq_of_parse_and_map(pdev->dev.of_node, 0);
>> +ÂÂÂ if (!irq)
>> +ÂÂÂÂÂÂÂ dev_warn(&pdev->dev, "failed to get IRQ from DT\n");
>> +
>
> The interrupt property is optional. Not providing it does not warrant a
> warning.
>
>> +ÂÂÂ ret = of_sam9x60_wdt_init(pdev->dev.of_node, wdt);
>> +ÂÂÂ if (ret)
>> +ÂÂÂÂÂÂÂ return ret;
>> +
>> +ÂÂÂ if ((wdt->ir & AT91_WDT_PERINT) && irq) {
>
> ... even more so if it isn't actually used in some cases.
> irq_of_parse_and_map()
> should probably only be called in the first place if AT91_WDT_PERINT is
> set.
>
>> +ÂÂÂÂÂÂÂ ret = devm_request_irq(&pdev->dev, irq, sam9x60_wdt_irq_handler,
>> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ IRQF_SHARED | IRQF_IRQPOLL |
>> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ IRQF_NO_SUSPEND, pdev->name, pdev);
>> +ÂÂÂÂÂÂÂ if (ret) {
>> +ÂÂÂÂÂÂÂÂÂÂÂ dev_err(&pdev->dev,
>> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ "cannot register interrupt handler\n");
>> +ÂÂÂÂÂÂÂÂÂÂÂ return ret;
>> +ÂÂÂÂÂÂÂ }
>> +ÂÂÂ }
>> +
>> +ÂÂÂ watchdog_init_timeout(wdd, wdt_timeout, &pdev->dev);
>> +
>> +ÂÂÂ ret = sam9x60_wdt_init(wdt);
>> +ÂÂÂ if (ret)
>> +ÂÂÂÂÂÂÂ return ret;
>> +
>> +ÂÂÂ watchdog_set_nowayout(wdd, nowayout);
>> +
>> +ÂÂÂ ret = watchdog_register_device(wdd);
>> +ÂÂÂ if (ret) {
>> +ÂÂÂÂÂÂÂ dev_err(&pdev->dev, "failed to register watchdog device\n");
>> +ÂÂÂÂÂÂÂ return ret;
>> +ÂÂÂ }
>> +
>> +ÂÂÂ platform_set_drvdata(pdev, wdt);
>> +
>> +ÂÂÂ dev_info(&pdev->dev, "initialized (timeout = %d sec, nowayout =
>> %d)\n",
>> +ÂÂÂÂÂÂÂÂ wdd->timeout, nowayout);
>> +
>> +ÂÂÂ return 0;
>> +}
>> +
>> +static int sam9x60_wdt_remove(struct platform_device *pdev)
>> +{
>> +ÂÂÂ struct sam9x60_wdt *wdt = platform_get_drvdata(pdev);
>> +
>> +ÂÂÂ sam9x60_wdt_stop(&wdt->wdd);
>> +
>
> Please use watchdog_stop_on_unregister() instead.
>
>> +ÂÂÂ watchdog_unregister_device(&wdt->wdd);
>> +
>
> Please use devm_watchdog_register_device() and drop the remove function.
>
>> +ÂÂÂ return 0;
>> +}
>> +
>> +static const struct of_device_id sam9x60_wdt_of_match[] = {
>> +ÂÂÂ { .compatible = "microchip,sam9x60-wdt", },
>> +ÂÂÂ { }
>> +};
>> +MODULE_DEVICE_TABLE(of, sam9x60_wdt_of_match);
>> +
>> +#ifdef CONFIG_PM_SLEEP
>
> Please use __maybe_unused
>
>> +static int sam9x60_wdt_resume(struct device *dev)
>> +{
>> +ÂÂÂ struct sam9x60_wdt *wdt = dev_get_drvdata(dev);
>> +
>> +ÂÂÂ /*
>> +ÂÂÂÂ * FIXME: writing MR also pings the watchdog which may not be
>> desired.
>> +ÂÂÂÂ * This should only be done when the registers are lost on
>> suspend but
>> +ÂÂÂÂ * there is no way to get this information right now.
>> +ÂÂÂÂ */
>
> This seems wrong. The bootloader may have stopped the watchdog in the
> suspend/resume cycle. This does not properly re-initialize it.
>
> Also, is there really no need to stop the watchdog on suspend ?
>
>> +ÂÂÂ sam9x60_wdt_init(wdt);
>> +
>> +ÂÂÂ return 0;
>> +}
>> +#endif
>> +
>> +static SIMPLE_DEV_PM_OPS(sam9x60_wdt_pm_ops, NULL,
>> +ÂÂÂÂÂÂÂÂÂÂÂÂ sam9x60_wdt_resume);
>> +
>> +static struct platform_driver sam9x60_wdt_driver = {
>> +ÂÂÂ .probeÂÂÂÂÂÂÂ = sam9x60_wdt_probe,
>> +ÂÂÂ .removeÂÂÂÂÂÂÂ = sam9x60_wdt_remove,
>> +ÂÂÂ .driverÂÂÂÂÂÂÂ = {
>> +ÂÂÂÂÂÂÂ .nameÂÂÂ = "sam9x60_wdt",
>> +ÂÂÂÂÂÂÂ .pmÂÂÂ = &sam9x60_wdt_pm_ops,
>> +ÂÂÂÂÂÂÂ .of_match_table = sam9x60_wdt_of_match,
>> +ÂÂÂ }
>> +};
>> +module_platform_driver(sam9x60_wdt_driver);
>> +
>> +MODULE_AUTHOR("Eugen Hristev");
>> +MODULE_DESCRIPTION("Microchip SAM9X60 Watchdog Timer driver");
>> +MODULE_LICENSE("GPL v2");
>>
>

Hello Guenter,

Thank you for the feedback.
After reviewing this, can you please guide me towards one of the
possible two directions: merge this driver with sama5d4_wdt , and have a
single driver with support for both hardware blocks; or, have this
driver separately , as in this patch series?

According to this, I will work on the next version of the patches.

Thanks,

Eugen