Commit 41531f58 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'linux-watchdog-4.17-rc1' of git://www.linux-watchdog.org/linux-watchdog

Pull watchdog updates from Wim Van Sebroeck:

 - Add Nuvoton NPCM watchdog driver

 - renesas_wdt: Add R-Car Gen2 support

 - renesas_wdt: add suspend/resume and restart handler support

 - hpwdt: convert to watchdog core and improve NMI

 - improve timeout setting/handling in various drivers

 - coh901327: make license text and module licence match

 - fix error handling in asm9260_wdt, sprd_wdt and davinci_wdt

 - aspeed imrovements

 - dw improvements (for control register & suspend/resume)

 - add SPDX identifiers for watchdog subsystem

* tag 'linux-watchdog-4.17-rc1' of git://www.linux-watchdog.org/linux-watchdog: (35 commits)
  watchdog: davinci_wdt: fix error handling in davinci_wdt_probe()
  watchdog: add SPDX identifiers for watchdog subsystem
  watchdog: aspeed: Allow configuring for alternate boot
  watchdog: Add Nuvoton NPCM watchdog driver
  dt-bindings: watchdog: Add Nuvoton NPCM description
  watchdog: dw: save/restore control and timeout across suspend/resume
  watchdog: dw: RMW the control register
  watchdog: sprd_wdt: Fix error handling in sprd_wdt_enable()
  watchdog: aspeed: Fix translation of reset mode to ctrl register
  watchdog: renesas_wdt: Add restart handler
  watchdog: renesas_wdt: Add R-Car Gen2 support
  watchdog: renesas_wdt: Add suspend/resume support
  watchdog: f71808e_wdt: Fix WD_EN register read
  watchdog: hpwdt: Update driver version.
  watchdog: hpwdt: Add dynamic debug
  watchdog: hpwdt: Programable Pretimeout NMI
  watchdog: hpwdt: remove allow_kdump module parameter.
  watchdog: hpwdt: condition early return of NMI handler on iLO5
  watchdog: hpwdt: Modify to use watchdog core.
  watchdog: hpwdt: Update nmi_panic message.
  ...
parents 80a17a5f 1991a55d
...@@ -11,6 +11,7 @@ Optional properties: ...@@ -11,6 +11,7 @@ Optional properties:
detail please see: Documentation/devicetree/bindings/regmap/regmap.txt. detail please see: Documentation/devicetree/bindings/regmap/regmap.txt.
- fsl,ext-reset-output: If present the watchdog device is configured to - fsl,ext-reset-output: If present the watchdog device is configured to
assert its external reset (WDOG_B) instead of issuing a software reset. assert its external reset (WDOG_B) instead of issuing a software reset.
- timeout-sec : Contains the watchdog timeout in seconds
Examples: Examples:
...@@ -19,4 +20,5 @@ wdt@73f98000 { ...@@ -19,4 +20,5 @@ wdt@73f98000 {
reg = <0x73f98000 0x4000>; reg = <0x73f98000 0x4000>;
interrupts = <58>; interrupts = <58>;
big-endian; big-endian;
timeout-sec = <20>;
}; };
...@@ -9,9 +9,13 @@ Required properties: ...@@ -9,9 +9,13 @@ Required properties:
"amlogic,meson8m2-wdt" and "amlogic,meson8b-wdt" on Meson8m2 SoCs "amlogic,meson8m2-wdt" and "amlogic,meson8b-wdt" on Meson8m2 SoCs
- reg : Specifies base physical address and size of the registers. - reg : Specifies base physical address and size of the registers.
Optional properties:
- timeout-sec: contains the watchdog timeout in seconds.
Example: Example:
wdt: watchdog@c1109900 { wdt: watchdog@c1109900 {
compatible = "amlogic,meson6-wdt"; compatible = "amlogic,meson6-wdt";
reg = <0xc1109900 0x8>; reg = <0xc1109900 0x8>;
timeout-sec = <10>;
}; };
...@@ -11,9 +11,13 @@ Required properties: ...@@ -11,9 +11,13 @@ Required properties:
- reg : Specifies base physical address and size of the registers. - reg : Specifies base physical address and size of the registers.
Optional properties:
- timeout-sec: contains the watchdog timeout in seconds.
Example: Example:
wdt: watchdog@10000000 { wdt: watchdog@10000000 {
compatible = "mediatek,mt6589-wdt"; compatible = "mediatek,mt6589-wdt";
reg = <0x10000000 0x18>; reg = <0x10000000 0x18>;
timeout-sec = <10>;
}; };
Nuvoton NPCM Watchdog
Nuvoton NPCM timer module provides five 24-bit timer counters, and a watchdog.
The watchdog supports a pre-timeout interrupt that fires 10ms before the
expiry.
Required properties:
- compatible : "nuvoton,npcm750-wdt" for NPCM750 (Poleg).
- reg : Offset and length of the register set for the device.
- interrupts : Contain the timer interrupt with flags for
falling edge.
Required clocking property, have to be one of:
- clocks : phandle of timer reference clock.
- clock-frequency : The frequency in Hz of the clock that drives the NPCM7xx
timer (usually 25000000).
Optional properties:
- timeout-sec : Contains the watchdog timeout in seconds
Example:
timer@f000801c {
compatible = "nuvoton,npcm750-wdt";
interrupts = <GIC_SPI 47 IRQ_TYPE_LEVEL_HIGH>;
reg = <0xf000801c 0x4>;
clocks = <&clk NPCM7XX_CLK_TIMER>;
};
...@@ -5,10 +5,14 @@ Required properties: ...@@ -5,10 +5,14 @@ Required properties:
- reg: Address range of tick timer/WDT register set - reg: Address range of tick timer/WDT register set
- interrupts: interrupt number to the cpu - interrupts: interrupt number to the cpu
Optional properties:
- timeout-sec : Contains the watchdog timeout in seconds
Example: Example:
timer@b0020000 { timer@b0020000 {
compatible = "sirf,prima2-tick"; compatible = "sirf,prima2-tick";
reg = <0xb0020000 0x1000>; reg = <0xb0020000 0x1000>;
interrupts = <0>; interrupts = <0>;
timeout-sec = <30>;
}; };
...@@ -8,9 +8,13 @@ Required properties: ...@@ -8,9 +8,13 @@ Required properties:
"allwinner,sun50i-a64-wdt","allwinner,sun6i-a31-wdt" "allwinner,sun50i-a64-wdt","allwinner,sun6i-a31-wdt"
- reg : Specifies base physical address and size of the registers. - reg : Specifies base physical address and size of the registers.
Optional properties:
- timeout-sec : Contains the watchdog timeout in seconds
Example: Example:
wdt: watchdog@1c20c90 { wdt: watchdog@1c20c90 {
compatible = "allwinner,sun4i-a10-wdt"; compatible = "allwinner,sun4i-a10-wdt";
reg = <0x01c20c90 0x10>; reg = <0x01c20c90 0x10>;
timeout-sec = <10>;
}; };
...@@ -514,6 +514,17 @@ config COH901327_WATCHDOG ...@@ -514,6 +514,17 @@ config COH901327_WATCHDOG
This watchdog is used to reset the system and thus cannot be This watchdog is used to reset the system and thus cannot be
compiled as a module. compiled as a module.
config NPCM7XX_WATCHDOG
bool "Nuvoton NPCM750 watchdog"
depends on ARCH_NPCM || COMPILE_TEST
default y if ARCH_NPCM750
select WATCHDOG_CORE
help
Say Y here to include Watchdog timer support for the
watchdog embedded into the NPCM7xx.
This watchdog is used to reset the system and thus cannot be
compiled as a module.
config TWL4030_WATCHDOG config TWL4030_WATCHDOG
tristate "TWL4030 Watchdog" tristate "TWL4030 Watchdog"
depends on TWL4030_CORE depends on TWL4030_CORE
...@@ -1102,6 +1113,7 @@ config IT87_WDT ...@@ -1102,6 +1113,7 @@ config IT87_WDT
config HP_WATCHDOG config HP_WATCHDOG
tristate "HP ProLiant iLO2+ Hardware Watchdog Timer" tristate "HP ProLiant iLO2+ Hardware Watchdog Timer"
select WATCHDOG_CORE
depends on X86 && PCI depends on X86 && PCI
help help
A software monitoring watchdog and NMI sourcing driver. This driver A software monitoring watchdog and NMI sourcing driver. This driver
......
...@@ -61,6 +61,7 @@ obj-$(CONFIG_ORION_WATCHDOG) += orion_wdt.o ...@@ -61,6 +61,7 @@ obj-$(CONFIG_ORION_WATCHDOG) += orion_wdt.o
obj-$(CONFIG_SUNXI_WATCHDOG) += sunxi_wdt.o obj-$(CONFIG_SUNXI_WATCHDOG) += sunxi_wdt.o
obj-$(CONFIG_RN5T618_WATCHDOG) += rn5t618_wdt.o obj-$(CONFIG_RN5T618_WATCHDOG) += rn5t618_wdt.o
obj-$(CONFIG_COH901327_WATCHDOG) += coh901327_wdt.o obj-$(CONFIG_COH901327_WATCHDOG) += coh901327_wdt.o
obj-$(CONFIG_NPCM7XX_WATCHDOG) += npcm_wdt.o
obj-$(CONFIG_STMP3XXX_RTC_WATCHDOG) += stmp3xxx_rtc_wdt.o obj-$(CONFIG_STMP3XXX_RTC_WATCHDOG) += stmp3xxx_rtc_wdt.o
obj-$(CONFIG_NUC900_WATCHDOG) += nuc900_wdt.o obj-$(CONFIG_NUC900_WATCHDOG) += nuc900_wdt.o
obj-$(CONFIG_TS4800_WATCHDOG) += ts4800_wdt.o obj-$(CONFIG_TS4800_WATCHDOG) += ts4800_wdt.o
......
// SPDX-License-Identifier: GPL-2.0+
/* /*
* drivers/watchdog/ar7_wdt.c * drivers/watchdog/ar7_wdt.c
* *
...@@ -8,19 +9,6 @@ ...@@ -8,19 +9,6 @@
* National Semiconductor SCx200 Watchdog support * National Semiconductor SCx200 Watchdog support
* Copyright (c) 2001,2002 Christer Weinigel <wingel@nano-system.com> * Copyright (c) 2001,2002 Christer Weinigel <wingel@nano-system.com>
* *
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
......
...@@ -292,14 +292,14 @@ static int asm9260_wdt_probe(struct platform_device *pdev) ...@@ -292,14 +292,14 @@ static int asm9260_wdt_probe(struct platform_device *pdev)
if (IS_ERR(priv->iobase)) if (IS_ERR(priv->iobase))
return PTR_ERR(priv->iobase); return PTR_ERR(priv->iobase);
ret = asm9260_wdt_get_dt_clks(priv);
if (ret)
return ret;
priv->rst = devm_reset_control_get_exclusive(&pdev->dev, "wdt_rst"); priv->rst = devm_reset_control_get_exclusive(&pdev->dev, "wdt_rst");
if (IS_ERR(priv->rst)) if (IS_ERR(priv->rst))
return PTR_ERR(priv->rst); return PTR_ERR(priv->rst);
ret = asm9260_wdt_get_dt_clks(priv);
if (ret)
return ret;
wdd = &priv->wdd; wdd = &priv->wdd;
wdd->info = &asm9260_wdt_ident; wdd->info = &asm9260_wdt_ident;
wdd->ops = &asm9260_wdt_ops; wdd->ops = &asm9260_wdt_ops;
......
...@@ -46,6 +46,7 @@ MODULE_DEVICE_TABLE(of, aspeed_wdt_of_table); ...@@ -46,6 +46,7 @@ MODULE_DEVICE_TABLE(of, aspeed_wdt_of_table);
#define WDT_RELOAD_VALUE 0x04 #define WDT_RELOAD_VALUE 0x04
#define WDT_RESTART 0x08 #define WDT_RESTART 0x08
#define WDT_CTRL 0x0C #define WDT_CTRL 0x0C
#define WDT_CTRL_BOOT_SECONDARY BIT(7)
#define WDT_CTRL_RESET_MODE_SOC (0x00 << 5) #define WDT_CTRL_RESET_MODE_SOC (0x00 << 5)
#define WDT_CTRL_RESET_MODE_FULL_CHIP (0x01 << 5) #define WDT_CTRL_RESET_MODE_FULL_CHIP (0x01 << 5)
#define WDT_CTRL_RESET_MODE_ARM_CPU (0x10 << 5) #define WDT_CTRL_RESET_MODE_ARM_CPU (0x10 << 5)
...@@ -158,6 +159,7 @@ static int aspeed_wdt_restart(struct watchdog_device *wdd, ...@@ -158,6 +159,7 @@ static int aspeed_wdt_restart(struct watchdog_device *wdd,
{ {
struct aspeed_wdt *wdt = to_aspeed_wdt(wdd); struct aspeed_wdt *wdt = to_aspeed_wdt(wdd);
wdt->ctrl &= ~WDT_CTRL_BOOT_SECONDARY;
aspeed_wdt_enable(wdt, 128 * WDT_RATE_1MHZ / 1000); aspeed_wdt_enable(wdt, 128 * WDT_RATE_1MHZ / 1000);
mdelay(1000); mdelay(1000);
...@@ -232,16 +234,21 @@ static int aspeed_wdt_probe(struct platform_device *pdev) ...@@ -232,16 +234,21 @@ static int aspeed_wdt_probe(struct platform_device *pdev)
wdt->ctrl |= WDT_CTRL_RESET_MODE_SOC | WDT_CTRL_RESET_SYSTEM; wdt->ctrl |= WDT_CTRL_RESET_MODE_SOC | WDT_CTRL_RESET_SYSTEM;
} else { } else {
if (!strcmp(reset_type, "cpu")) if (!strcmp(reset_type, "cpu"))
wdt->ctrl |= WDT_CTRL_RESET_MODE_ARM_CPU; wdt->ctrl |= WDT_CTRL_RESET_MODE_ARM_CPU |
WDT_CTRL_RESET_SYSTEM;
else if (!strcmp(reset_type, "soc")) else if (!strcmp(reset_type, "soc"))
wdt->ctrl |= WDT_CTRL_RESET_MODE_SOC; wdt->ctrl |= WDT_CTRL_RESET_MODE_SOC |
WDT_CTRL_RESET_SYSTEM;
else if (!strcmp(reset_type, "system")) else if (!strcmp(reset_type, "system"))
wdt->ctrl |= WDT_CTRL_RESET_SYSTEM; wdt->ctrl |= WDT_CTRL_RESET_MODE_FULL_CHIP |
WDT_CTRL_RESET_SYSTEM;
else if (strcmp(reset_type, "none")) else if (strcmp(reset_type, "none"))
return -EINVAL; return -EINVAL;
} }
if (of_property_read_bool(np, "aspeed,external-signal")) if (of_property_read_bool(np, "aspeed,external-signal"))
wdt->ctrl |= WDT_CTRL_WDT_EXT; wdt->ctrl |= WDT_CTRL_WDT_EXT;
if (of_property_read_bool(np, "aspeed,alt-boot"))
wdt->ctrl |= WDT_CTRL_BOOT_SECONDARY;
if (readl(wdt->base + WDT_CTRL) & WDT_CTRL_ENABLE) { if (readl(wdt->base + WDT_CTRL) & WDT_CTRL_ENABLE) {
/* /*
......
// SPDX-License-Identifier: GPL-2.0+
/* /*
* Watchdog driver for Atmel AT91RM9200 (Thunder) * Watchdog driver for Atmel AT91RM9200 (Thunder)
* *
* Copyright (C) 2003 SAN People (Pty) Ltd * Copyright (C) 2003 SAN People (Pty) Ltd
* *
* 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.
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
......
// SPDX-License-Identifier: GPL-2.0+
/* /*
* Watchdog driver for Atmel AT91SAM9x processors. * Watchdog driver for Atmel AT91SAM9x processors.
* *
* Copyright (C) 2008 Renaud CERRATO r.cerrato@til-technologies.fr * Copyright (C) 2008 Renaud CERRATO r.cerrato@til-technologies.fr
* *
* 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.
*/ */
/* /*
......
/* SPDX-License-Identifier: GPL-2.0+ */
/* /*
* drivers/watchdog/at91sam9_wdt.h * drivers/watchdog/at91sam9_wdt.h
* *
...@@ -7,10 +8,6 @@ ...@@ -7,10 +8,6 @@
* Watchdog Timer (WDT) - System peripherals regsters. * Watchdog Timer (WDT) - System peripherals regsters.
* Based on AT91SAM9261 datasheet revision D. * Based on AT91SAM9261 datasheet revision D.
* *
* 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.
*/ */
#ifndef AT91_WDT_H #ifndef AT91_WDT_H
......
// SPDX-License-Identifier: GPL-2.0+
/* /*
* Watchdog driver for Broadcom BCM2835 * Watchdog driver for Broadcom BCM2835
* *
...@@ -7,10 +8,6 @@ ...@@ -7,10 +8,6 @@
* *
* Copyright (C) 2013 Lubomir Rintel <lkundrak@v3.sk> * Copyright (C) 2013 Lubomir Rintel <lkundrak@v3.sk>
* *
* 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.
*/ */
#include <linux/delay.h> #include <linux/delay.h>
......
// SPDX-License-Identifier: GPL-2.0+
/* /*
* Watchdog driver for Broadcom BCM47XX * Watchdog driver for Broadcom BCM47XX
* *
...@@ -5,10 +6,6 @@ ...@@ -5,10 +6,6 @@
* Copyright (C) 2009 Matthieu CASTET <castet.matthieu@free.fr> * Copyright (C) 2009 Matthieu CASTET <castet.matthieu@free.fr>
* Copyright (C) 2012-2013 Hauke Mehrtens <hauke@hauke-m.de> * Copyright (C) 2012-2013 Hauke Mehrtens <hauke@hauke-m.de>
* *
* 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.
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
......
// SPDX-License-Identifier: GPL-2.0+
/* /*
* Broadcom BCM63xx SoC watchdog driver * Broadcom BCM63xx SoC watchdog driver
* *
* Copyright (C) 2007, Miguel Gaio <miguel.gaio@efixo.com> * Copyright (C) 2007, Miguel Gaio <miguel.gaio@efixo.com>
* Copyright (C) 2008, Florian Fainelli <florian@openwrt.org> * Copyright (C) 2008, Florian Fainelli <florian@openwrt.org>
* *
* 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.
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
......
// SPDX-License-Identifier: GPL-2.0+
/* /*
* Copyright (C) 2015 Broadcom Corporation * Copyright (C) 2015 Broadcom Corporation
* *
* 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.
*/ */
#include <linux/clk.h> #include <linux/clk.h>
...@@ -235,6 +227,6 @@ module_platform_driver(bcm7038_wdt_driver); ...@@ -235,6 +227,6 @@ module_platform_driver(bcm7038_wdt_driver);
module_param(nowayout, bool, 0); module_param(nowayout, bool, 0);
MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
__MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
MODULE_LICENSE("GPL v2"); MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("Driver for Broadcom 7038 SoCs Watchdog"); MODULE_DESCRIPTION("Driver for Broadcom 7038 SoCs Watchdog");
MODULE_AUTHOR("Justin Chen"); MODULE_AUTHOR("Justin Chen");
// SPDX-License-Identifier: GPL-2.0
/* /*
* Copyright (C) 2013 Broadcom Corporation * Copyright (C) 2013 Broadcom Corporation
* *
* 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 version 2.
*
* This program is distributed "as is" WITHOUT ANY WARRANTY of any
* kind, whether express or implied; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/ */
#include <linux/debugfs.h> #include <linux/debugfs.h>
......
// SPDX-License-Identifier: GPL-2.0+
/* /*
* Cadence WDT driver - Used by Xilinx Zynq * Cadence WDT driver - Used by Xilinx Zynq
* *
* Copyright (C) 2010 - 2014 Xilinx, Inc. * Copyright (C) 2010 - 2014 Xilinx, Inc.
* *
* 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.
*/ */
#include <linux/clk.h> #include <linux/clk.h>
......
// SPDX-License-Identifier: GPL-2.0
/* /*
* coh901327_wdt.c * coh901327_wdt.c
* *
* Copyright (C) 2008-2009 ST-Ericsson AB * Copyright (C) 2008-2009 ST-Ericsson AB
* License terms: GNU General Public License (GPL) version 2
* Watchdog driver for the ST-Ericsson AB COH 901 327 IP core * Watchdog driver for the ST-Ericsson AB COH 901 327 IP core
* Author: Linus Walleij <linus.walleij@stericsson.com> * Author: Linus Walleij <linus.walleij@stericsson.com>
*/ */
...@@ -67,7 +67,9 @@ ...@@ -67,7 +67,9 @@
#define U300_WDOG_IFR_WILL_BARK_IRQ_FORCE_ENABLE 0x0001U #define U300_WDOG_IFR_WILL_BARK_IRQ_FORCE_ENABLE 0x0001U
/* Default timeout in seconds = 1 minute */ /* Default timeout in seconds = 1 minute */
static unsigned int margin = 60; #define U300_WDOG_DEFAULT_TIMEOUT 60
static unsigned int margin;
static int irq; static int irq;
static void __iomem *virtbase; static void __iomem *virtbase;
static struct device *parent; static struct device *parent;
...@@ -235,8 +237,9 @@ static struct watchdog_device coh901327_wdt = { ...@@ -235,8 +237,9 @@ static struct watchdog_device coh901327_wdt = {
* timeout register is max * timeout register is max
* 0x7FFF = 327670ms ~= 327s. * 0x7FFF = 327670ms ~= 327s.
*/ */
.min_timeout = 0, .min_timeout = 1,
.max_timeout = 327, .max_timeout = 327,
.timeout = U300_WDOG_DEFAULT_TIMEOUT,
}; };
static int __exit coh901327_remove(struct platform_device *pdev) static int __exit coh901327_remove(struct platform_device *pdev)
...@@ -315,16 +318,15 @@ static int __init coh901327_probe(struct platform_device *pdev) ...@@ -315,16 +318,15 @@ static int __init coh901327_probe(struct platform_device *pdev)
goto out_no_irq; goto out_no_irq;
} }
ret = watchdog_init_timeout(&coh901327_wdt, margin, dev); watchdog_init_timeout(&coh901327_wdt, margin, dev);
if (ret < 0)
coh901327_wdt.timeout = 60;
coh901327_wdt.parent = dev; coh901327_wdt.parent = dev;
ret = watchdog_register_device(&coh901327_wdt); ret = watchdog_register_device(&coh901327_wdt);
if (ret) if (ret)
goto out_no_wdog; goto out_no_wdog;
dev_info(dev, "initialized. timer margin=%d sec\n", margin); dev_info(dev, "initialized. (timeout=%d sec)\n",
coh901327_wdt.timeout);
return 0; return 0;
out_no_wdog: out_no_wdog:
...@@ -419,5 +421,5 @@ MODULE_DESCRIPTION("COH 901 327 Watchdog"); ...@@ -419,5 +421,5 @@ MODULE_DESCRIPTION("COH 901 327 Watchdog");
module_param(margin, uint, 0); module_param(margin, uint, 0);
MODULE_PARM_DESC(margin, "Watchdog margin in seconds (default 60s)"); MODULE_PARM_DESC(margin, "Watchdog margin in seconds (default 60s)");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL v2");
MODULE_ALIAS("platform:coh901327-watchdog"); MODULE_ALIAS("platform:coh901327-watchdog");
// SPDX-License-Identifier: GPL-2.0+
/* /*
* System monitoring driver for DA9052 PMICs. * System monitoring driver for DA9052 PMICs.
* *
...@@ -5,11 +6,6 @@ ...@@ -5,11 +6,6 @@
* *
* Author: Anthony Olech <Anthony.Olech@diasemi.com> * Author: Anthony Olech <Anthony.Olech@diasemi.com>
* *
* 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.
*
*/ */
#include <linux/module.h> #include <linux/module.h>
......
// SPDX-License-Identifier: GPL-2.0+
/* /*
* System monitoring driver for DA9055 PMICs. * System monitoring driver for DA9055 PMICs.
* *
...@@ -5,11 +6,6 @@ ...@@ -5,11 +6,6 @@
* *
* Author: David Dajun Chen <dchen@diasemi.com> * Author: David Dajun Chen <dchen@diasemi.com>
* *
* 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.
*
*/ */
#include <linux/module.h> #include <linux/module.h>
......
// SPDX-License-Identifier: GPL-2.0+
/* /*
* Watchdog device driver for DA9062 and DA9061 PMICs * Watchdog device driver for DA9062 and DA9061 PMICs
* Copyright (C) 2015 Dialog Semiconductor Ltd. * Copyright (C) 2015 Dialog Semiconductor Ltd.
* *
* 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.
*/ */
#include <linux/kernel.h> #include <linux/kernel.h>
......
// SPDX-License-Identifier: GPL-2.0+
/* /*
* Watchdog driver for DA9063 PMICs. * Watchdog driver for DA9063 PMICs.
* *
...@@ -5,10 +6,6 @@ ...@@ -5,10 +6,6 @@
* *
* Author: Mariusz Wojtasik <mariusz.wojtasik@diasemi.com> * Author: Mariusz Wojtasik <mariusz.wojtasik@diasemi.com>
* *
* 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.
*/ */
#include <linux/kernel.h> #include <linux/kernel.h>
......
...@@ -236,15 +236,22 @@ static int davinci_wdt_probe(struct platform_device *pdev) ...@@ -236,15 +236,22 @@ static int davinci_wdt_probe(struct platform_device *pdev)
wdt_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); wdt_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
davinci_wdt->base = devm_ioremap_resource(dev, wdt_mem); davinci_wdt->base = devm_ioremap_resource(dev, wdt_mem);
if (IS_ERR(davinci_wdt->base)) if (IS_ERR(davinci_wdt->base)) {
return PTR_ERR(davinci_wdt->base); ret = PTR_ERR(davinci_wdt->base);
goto err_clk_disable;
}
ret = watchdog_register_device(wdd); ret = watchdog_register_device(wdd);
if (ret < 0) { if (ret) {
clk_disable_unprepare(davinci_wdt->clk);
dev_err(dev, "cannot register watchdog device\n"); dev_err(dev, "cannot register watchdog device\n");
goto err_clk_disable;
} }
return 0;
err_clk_disable:
clk_disable_unprepare(davinci_wdt->clk);
return ret; return ret;
} }
......
// SPDX-License-Identifier: GPL-2.0+
/* /*
* Watchdog driver for Conexant Digicolor * Watchdog driver for Conexant Digicolor
* *
* Copyright (C) 2015 Paradox Innovation Ltd. * Copyright (C) 2015 Paradox Innovation Ltd.
* *
* 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.
*/ */
#include <linux/types.h> #include <linux/types.h>
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#define WDOG_CONTROL_REG_OFFSET 0x00 #define WDOG_CONTROL_REG_OFFSET 0x00
#define WDOG_CONTROL_REG_WDT_EN_MASK 0x01 #define WDOG_CONTROL_REG_WDT_EN_MASK 0x01
#define WDOG_CONTROL_REG_RESP_MODE_MASK 0x02
#define WDOG_TIMEOUT_RANGE_REG_OFFSET 0x04 #define WDOG_TIMEOUT_RANGE_REG_OFFSET 0x04
#define WDOG_TIMEOUT_RANGE_TOPINIT_SHIFT 4 #define WDOG_TIMEOUT_RANGE_TOPINIT_SHIFT 4
#define WDOG_CURRENT_COUNT_REG_OFFSET 0x08 #define WDOG_CURRENT_COUNT_REG_OFFSET 0x08
...@@ -56,6 +57,9 @@ struct dw_wdt { ...@@ -56,6 +57,9 @@ struct dw_wdt {
unsigned long rate; unsigned long rate;
struct watchdog_device wdd; struct watchdog_device wdd;
struct reset_control *rst; struct reset_control *rst;
/* Save/restore */
u32 control;
u32 timeout;
}; };
#define to_dw_wdt(wdd) container_of(wdd, struct dw_wdt, wdd) #define to_dw_wdt(wdd) container_of(wdd, struct dw_wdt, wdd)
...@@ -121,14 +125,23 @@ static int dw_wdt_set_timeout(struct watchdog_device *wdd, unsigned int top_s) ...@@ -121,14 +125,23 @@ static int dw_wdt_set_timeout(struct watchdog_device *wdd, unsigned int top_s)
return 0; return 0;
} }
static void dw_wdt_arm_system_reset(struct dw_wdt *dw_wdt)
{
u32 val = readl(dw_wdt->regs + WDOG_CONTROL_REG_OFFSET);
/* Disable interrupt mode; always perform system reset. */
val &= ~WDOG_CONTROL_REG_RESP_MODE_MASK;
/* Enable watchdog. */
val |= WDOG_CONTROL_REG_WDT_EN_MASK;
writel(val, dw_wdt->regs + WDOG_CONTROL_REG_OFFSET);
}
static int dw_wdt_start(struct watchdog_device *wdd) static int dw_wdt_start(struct watchdog_device *wdd)
{ {
struct dw_wdt *dw_wdt = to_dw_wdt(wdd); struct dw_wdt *dw_wdt = to_dw_wdt(wdd);
dw_wdt_set_timeout(wdd, wdd->timeout); dw_wdt_set_timeout(wdd, wdd->timeout);
dw_wdt_arm_system_reset(dw_wdt);
writel(WDOG_CONTROL_REG_WDT_EN_MASK,
dw_wdt->regs + WDOG_CONTROL_REG_OFFSET);
return 0; return 0;
} }
...@@ -152,16 +165,13 @@ static int dw_wdt_restart(struct watchdog_device *wdd, ...@@ -152,16 +165,13 @@ static int dw_wdt_restart(struct watchdog_device *wdd,
unsigned long action, void *data) unsigned long action, void *data)
{ {
struct dw_wdt *dw_wdt = to_dw_wdt(wdd); struct dw_wdt *dw_wdt = to_dw_wdt(wdd);
u32 val;
writel(0, dw_wdt->regs + WDOG_TIMEOUT_RANGE_REG_OFFSET); writel(0, dw_wdt->regs + WDOG_TIMEOUT_RANGE_REG_OFFSET);
val = readl(dw_wdt->regs + WDOG_CONTROL_REG_OFFSET); if (dw_wdt_is_enabled(dw_wdt))
if (val & WDOG_CONTROL_REG_WDT_EN_MASK)
writel(WDOG_COUNTER_RESTART_KICK_VALUE, writel(WDOG_COUNTER_RESTART_KICK_VALUE,
dw_wdt->regs + WDOG_COUNTER_RESTART_REG_OFFSET); dw_wdt->regs + WDOG_COUNTER_RESTART_REG_OFFSET);
else else
writel(WDOG_CONTROL_REG_WDT_EN_MASK, dw_wdt_arm_system_reset(dw_wdt);
dw_wdt->regs + WDOG_CONTROL_REG_OFFSET);
/* wait for reset to assert... */ /* wait for reset to assert... */
mdelay(500); mdelay(500);
...@@ -198,6 +208,9 @@ static int dw_wdt_suspend(struct device *dev) ...@@ -198,6 +208,9 @@ static int dw_wdt_suspend(struct device *dev)
{ {
struct dw_wdt *dw_wdt = dev_get_drvdata(dev); struct dw_wdt *dw_wdt = dev_get_drvdata(dev);
dw_wdt->control = readl(dw_wdt->regs + WDOG_CONTROL_REG_OFFSET);
dw_wdt->timeout = readl(dw_wdt->regs + WDOG_TIMEOUT_RANGE_REG_OFFSET);
clk_disable_unprepare(dw_wdt->clk); clk_disable_unprepare(dw_wdt->clk);
return 0; return 0;
...@@ -211,6 +224,9 @@ static int dw_wdt_resume(struct device *dev) ...@@ -211,6 +224,9 @@ static int dw_wdt_resume(struct device *dev)
if (err) if (err)
return err; return err;
writel(dw_wdt->timeout, dw_wdt->regs + WDOG_TIMEOUT_RANGE_REG_OFFSET);
writel(dw_wdt->control, dw_wdt->regs + WDOG_CONTROL_REG_OFFSET);
dw_wdt_ping(&dw_wdt->wdd); dw_wdt_ping(&dw_wdt->wdd);
return 0; return 0;
......
// SPDX-License-Identifier: GPL-2.0
/* /*
* Watchdog timer driver for the WinSystems EBC-C384 * Watchdog timer driver for the WinSystems EBC-C384
* Copyright (C) 2016 William Breathitt Gray * Copyright (C) 2016 William Breathitt Gray
......
...@@ -496,7 +496,7 @@ static bool watchdog_is_running(void) ...@@ -496,7 +496,7 @@ static bool watchdog_is_running(void)
is_running = (superio_inb(watchdog.sioaddr, SIO_REG_ENABLE) & BIT(0)) is_running = (superio_inb(watchdog.sioaddr, SIO_REG_ENABLE) & BIT(0))
&& (superio_inb(watchdog.sioaddr, F71808FG_REG_WDT_CONF) && (superio_inb(watchdog.sioaddr, F71808FG_REG_WDT_CONF)
& F71808FG_FLAG_WD_EN); & BIT(F71808FG_FLAG_WD_EN));
superio_exit(watchdog.sioaddr); superio_exit(watchdog.sioaddr);
......
...@@ -152,9 +152,9 @@ static int gpio_wdt_probe(struct platform_device *pdev) ...@@ -152,9 +152,9 @@ static int gpio_wdt_probe(struct platform_device *pdev)
priv->wdd.min_timeout = SOFT_TIMEOUT_MIN; priv->wdd.min_timeout = SOFT_TIMEOUT_MIN;
priv->wdd.max_hw_heartbeat_ms = hw_margin; priv->wdd.max_hw_heartbeat_ms = hw_margin;
priv->wdd.parent = dev; priv->wdd.parent = dev;
priv->wdd.timeout = SOFT_TIMEOUT_DEF;
if (watchdog_init_timeout(&priv->wdd, 0, dev) < 0) watchdog_init_timeout(&priv->wdd, 0, &pdev->dev);
priv->wdd.timeout = SOFT_TIMEOUT_DEF;
watchdog_stop_on_reboot(&priv->wdd); watchdog_stop_on_reboot(&priv->wdd);
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* *
* SoftDog 0.05: A Software Watchdog Device * SoftDog 0.05: A Software Watchdog Device
* *
* (c) Copyright 2015 Hewlett Packard Enterprise Development LP * (c) Copyright 2018 Hewlett Packard Enterprise Development LP
* Thomas Mingarelli <thomas.mingarelli@hpe.com> * Thomas Mingarelli <thomas.mingarelli@hpe.com>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -16,34 +16,27 @@ ...@@ -16,34 +16,27 @@
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/device.h> #include <linux/device.h>
#include <linux/fs.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/bitops.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/miscdevice.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/moduleparam.h> #include <linux/moduleparam.h>
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/pci_ids.h> #include <linux/pci_ids.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/uaccess.h>
#include <linux/watchdog.h> #include <linux/watchdog.h>
#include <asm/nmi.h> #include <asm/nmi.h>
#define HPWDT_VERSION "1.4.0" #define HPWDT_VERSION "2.0.0"
#define SECS_TO_TICKS(secs) ((secs) * 1000 / 128) #define SECS_TO_TICKS(secs) ((secs) * 1000 / 128)
#define TICKS_TO_SECS(ticks) ((ticks) * 128 / 1000) #define TICKS_TO_SECS(ticks) ((ticks) * 128 / 1000)
#define HPWDT_MAX_TIMER TICKS_TO_SECS(65535) #define HPWDT_MAX_TIMER TICKS_TO_SECS(65535)
#define DEFAULT_MARGIN 30 #define DEFAULT_MARGIN 30
#define PRETIMEOUT_SEC 9
static bool ilo5;
static unsigned int soft_margin = DEFAULT_MARGIN; /* in seconds */ static unsigned int soft_margin = DEFAULT_MARGIN; /* in seconds */
static unsigned int reload; /* the computed soft_margin */
static bool nowayout = WATCHDOG_NOWAYOUT; static bool nowayout = WATCHDOG_NOWAYOUT;
#ifdef CONFIG_HPWDT_NMI_DECODING static bool pretimeout = IS_ENABLED(CONFIG_HPWDT_NMI_DECODING);
static unsigned int allow_kdump = 1;
#endif
static char expect_release;
static unsigned long hpwdt_is_open;
static void __iomem *pci_mem_addr; /* the PCI-memory address */ static void __iomem *pci_mem_addr; /* the PCI-memory address */
static unsigned long __iomem *hpwdt_nmistat; static unsigned long __iomem *hpwdt_nmistat;
...@@ -61,48 +54,92 @@ MODULE_DEVICE_TABLE(pci, hpwdt_devices); ...@@ -61,48 +54,92 @@ MODULE_DEVICE_TABLE(pci, hpwdt_devices);
/* /*
* Watchdog operations * Watchdog operations
*/ */
static void hpwdt_start(void) static int hpwdt_start(struct watchdog_device *wdd)
{ {
reload = SECS_TO_TICKS(soft_margin); int control = 0x81 | (pretimeout ? 0x4 : 0);
int reload = SECS_TO_TICKS(wdd->timeout);
dev_dbg(wdd->parent, "start watchdog 0x%08x:0x%02x\n", reload, control);
iowrite16(reload, hpwdt_timer_reg); iowrite16(reload, hpwdt_timer_reg);
iowrite8(0x85, hpwdt_timer_con); iowrite8(control, hpwdt_timer_con);
return 0;
} }
static void hpwdt_stop(void) static void hpwdt_stop(void)
{ {
unsigned long data; unsigned long data;
pr_debug("stop watchdog\n");
data = ioread8(hpwdt_timer_con); data = ioread8(hpwdt_timer_con);
data &= 0xFE; data &= 0xFE;
iowrite8(data, hpwdt_timer_con); iowrite8(data, hpwdt_timer_con);
} }
static void hpwdt_ping(void) static int hpwdt_stop_core(struct watchdog_device *wdd)
{ {
iowrite16(reload, hpwdt_timer_reg); hpwdt_stop();
return 0;
} }
static int hpwdt_change_timer(int new_margin) static int hpwdt_ping(struct watchdog_device *wdd)
{ {
if (new_margin < 1 || new_margin > HPWDT_MAX_TIMER) { int reload = SECS_TO_TICKS(wdd->timeout);
pr_warn("New value passed in is invalid: %d seconds\n",
new_margin);
return -EINVAL;
}
soft_margin = new_margin; dev_dbg(wdd->parent, "ping watchdog 0x%08x\n", reload);
pr_debug("New timer passed in is %d seconds\n", new_margin); iowrite16(reload, hpwdt_timer_reg);
reload = SECS_TO_TICKS(soft_margin);
return 0; return 0;
} }
static int hpwdt_time_left(void) static unsigned int hpwdt_gettimeleft(struct watchdog_device *wdd)
{ {
return TICKS_TO_SECS(ioread16(hpwdt_timer_reg)); return TICKS_TO_SECS(ioread16(hpwdt_timer_reg));
} }
static int hpwdt_settimeout(struct watchdog_device *wdd, unsigned int val)
{
dev_dbg(wdd->parent, "set_timeout = %d\n", val);
wdd->timeout = val;
if (val <= wdd->pretimeout) {
dev_dbg(wdd->parent, "pretimeout < timeout. Setting to zero\n");
wdd->pretimeout = 0;
pretimeout = 0;
if (watchdog_active(wdd))
hpwdt_start(wdd);
}
hpwdt_ping(wdd);
return 0;
}
#ifdef CONFIG_HPWDT_NMI_DECODING #ifdef CONFIG_HPWDT_NMI_DECODING
static int hpwdt_set_pretimeout(struct watchdog_device *wdd, unsigned int req)
{
unsigned int val = 0;
dev_dbg(wdd->parent, "set_pretimeout = %d\n", req);
if (req) {
val = PRETIMEOUT_SEC;
if (val >= wdd->timeout)
return -EINVAL;
}
if (val != req)
dev_dbg(wdd->parent, "Rounding pretimeout to: %d\n", val);
wdd->pretimeout = val;
pretimeout = !!val;
if (watchdog_active(wdd))
hpwdt_start(wdd);
return 0;
}
static int hpwdt_my_nmi(void) static int hpwdt_my_nmi(void)
{ {
return ioread8(hpwdt_nmistat) & 0x6; return ioread8(hpwdt_nmistat) & 0x6;
...@@ -113,178 +150,71 @@ static int hpwdt_my_nmi(void) ...@@ -113,178 +150,71 @@ static int hpwdt_my_nmi(void)
*/ */
static int hpwdt_pretimeout(unsigned int ulReason, struct pt_regs *regs) static int hpwdt_pretimeout(unsigned int ulReason, struct pt_regs *regs)
{ {
if ((ulReason == NMI_UNKNOWN) && !hpwdt_my_nmi()) unsigned int mynmi = hpwdt_my_nmi();
return NMI_DONE; static char panic_msg[] =
"00: An NMI occurred. Depending on your system the reason "
if (allow_kdump) "for the NMI is logged in any one of the following resources:\n"
hpwdt_stop();
nmi_panic(regs, "An NMI occurred. Depending on your system the reason "
"for the NMI is logged in any one of the following "
"resources:\n"
"1. Integrated Management Log (IML)\n" "1. Integrated Management Log (IML)\n"
"2. OA Syslog\n" "2. OA Syslog\n"
"3. OA Forward Progress Log\n" "3. OA Forward Progress Log\n"
"4. iLO Event Log"); "4. iLO Event Log";
return NMI_HANDLED;
}
#endif /* CONFIG_HPWDT_NMI_DECODING */
/*
* /dev/watchdog handling
*/
static int hpwdt_open(struct inode *inode, struct file *file)
{
/* /dev/watchdog can only be opened once */
if (test_and_set_bit(0, &hpwdt_is_open))
return -EBUSY;
/* Start the watchdog */ if (ilo5 && ulReason == NMI_UNKNOWN && mynmi)
hpwdt_start(); return NMI_DONE;
hpwdt_ping();
return nonseekable_open(inode, file);
}
static int hpwdt_release(struct inode *inode, struct file *file) if (ilo5 && !pretimeout)
{ return NMI_DONE;
/* Stop the watchdog */
if (expect_release == 42) {
hpwdt_stop();
} else {
pr_crit("Unexpected close, not stopping watchdog!\n");
hpwdt_ping();
}
expect_release = 0; hpwdt_stop();
/* /dev/watchdog is being closed, make sure it can be re-opened */ hex_byte_pack(panic_msg, mynmi);
clear_bit(0, &hpwdt_is_open); nmi_panic(regs, panic_msg);
return 0; return NMI_HANDLED;
} }
#endif /* CONFIG_HPWDT_NMI_DECODING */
static ssize_t hpwdt_write(struct file *file, const char __user *data,
size_t len, loff_t *ppos)
{
/* See if we got the magic character 'V' and reload the timer */
if (len) {
if (!nowayout) {
size_t i;
/* note: just in case someone wrote the magic character
* five months ago... */
expect_release = 0;
/* scan to see whether or not we got the magic char. */
for (i = 0; i != len; i++) {
char c;
if (get_user(c, data + i))
return -EFAULT;
if (c == 'V')
expect_release = 42;
}
}
/* someone wrote to us, we should reload the timer */
hpwdt_ping();
}
return len;
}
static const struct watchdog_info ident = { static const struct watchdog_info ident = {
.options = WDIOF_SETTIMEOUT | .options = WDIOF_PRETIMEOUT |
WDIOF_SETTIMEOUT |
WDIOF_KEEPALIVEPING | WDIOF_KEEPALIVEPING |
WDIOF_MAGICCLOSE, WDIOF_MAGICCLOSE,
.identity = "HPE iLO2+ HW Watchdog Timer", .identity = "HPE iLO2+ HW Watchdog Timer",
}; };
static long hpwdt_ioctl(struct file *file, unsigned int cmd,
unsigned long arg)
{
void __user *argp = (void __user *)arg;
int __user *p = argp;
int new_margin, options;
int ret = -ENOTTY;
switch (cmd) {
case WDIOC_GETSUPPORT:
ret = 0;
if (copy_to_user(argp, &ident, sizeof(ident)))
ret = -EFAULT;
break;
case WDIOC_GETSTATUS:
case WDIOC_GETBOOTSTATUS:
ret = put_user(0, p);
break;
case WDIOC_KEEPALIVE:
hpwdt_ping();
ret = 0;
break;
case WDIOC_SETOPTIONS:
ret = get_user(options, p);
if (ret)
break;
if (options & WDIOS_DISABLECARD)
hpwdt_stop();
if (options & WDIOS_ENABLECARD) {
hpwdt_start();
hpwdt_ping();
}
break;
case WDIOC_SETTIMEOUT:
ret = get_user(new_margin, p);
if (ret)
break;
ret = hpwdt_change_timer(new_margin);
if (ret)
break;
hpwdt_ping();
/* Fall */
case WDIOC_GETTIMEOUT:
ret = put_user(soft_margin, p);
break;
case WDIOC_GETTIMELEFT:
ret = put_user(hpwdt_time_left(), p);
break;
}
return ret;
}
/* /*
* Kernel interfaces * Kernel interfaces
*/ */
static const struct file_operations hpwdt_fops = {
.owner = THIS_MODULE, static const struct watchdog_ops hpwdt_ops = {
.llseek = no_llseek, .owner = THIS_MODULE,
.write = hpwdt_write, .start = hpwdt_start,
.unlocked_ioctl = hpwdt_ioctl, .stop = hpwdt_stop_core,
.open = hpwdt_open, .ping = hpwdt_ping,
.release = hpwdt_release, .set_timeout = hpwdt_settimeout,
.get_timeleft = hpwdt_gettimeleft,
#ifdef CONFIG_HPWDT_NMI_DECODING
.set_pretimeout = hpwdt_set_pretimeout,
#endif
}; };
static struct miscdevice hpwdt_miscdev = { static struct watchdog_device hpwdt_dev = {
.minor = WATCHDOG_MINOR, .info = &ident,
.name = "watchdog", .ops = &hpwdt_ops,
.fops = &hpwdt_fops, .min_timeout = 1,
.max_timeout = HPWDT_MAX_TIMER,
.timeout = DEFAULT_MARGIN,
#ifdef CONFIG_HPWDT_NMI_DECODING
.pretimeout = PRETIMEOUT_SEC,
#endif
}; };
/* /*
* Init & Exit * Init & Exit
*/ */
static int hpwdt_init_nmi_decoding(struct pci_dev *dev) static int hpwdt_init_nmi_decoding(struct pci_dev *dev)
{ {
#ifdef CONFIG_HPWDT_NMI_DECODING #ifdef CONFIG_HPWDT_NMI_DECODING
...@@ -303,9 +233,8 @@ static int hpwdt_init_nmi_decoding(struct pci_dev *dev) ...@@ -303,9 +233,8 @@ static int hpwdt_init_nmi_decoding(struct pci_dev *dev)
goto error2; goto error2;
dev_info(&dev->dev, dev_info(&dev->dev,
"HPE Watchdog Timer Driver: NMI decoding initialized" "HPE Watchdog Timer Driver: NMI decoding initialized\n");
", allow kernel dump: %s (default = 1/ON)\n",
(allow_kdump == 0) ? "OFF" : "ON");
return 0; return 0;
error2: error2:
...@@ -375,29 +304,32 @@ static int hpwdt_init_one(struct pci_dev *dev, ...@@ -375,29 +304,32 @@ static int hpwdt_init_one(struct pci_dev *dev,
/* Make sure that timer is disabled until /dev/watchdog is opened */ /* Make sure that timer is disabled until /dev/watchdog is opened */
hpwdt_stop(); hpwdt_stop();
/* Make sure that we have a valid soft_margin */
if (hpwdt_change_timer(soft_margin))
hpwdt_change_timer(DEFAULT_MARGIN);
/* Initialize NMI Decoding functionality */ /* Initialize NMI Decoding functionality */
retval = hpwdt_init_nmi_decoding(dev); retval = hpwdt_init_nmi_decoding(dev);
if (retval != 0) if (retval != 0)
goto error_init_nmi_decoding; goto error_init_nmi_decoding;
retval = misc_register(&hpwdt_miscdev); watchdog_set_nowayout(&hpwdt_dev, nowayout);
if (watchdog_init_timeout(&hpwdt_dev, soft_margin, NULL))
dev_warn(&dev->dev, "Invalid soft_margin: %d.\n", soft_margin);
hpwdt_dev.parent = &dev->dev;
retval = watchdog_register_device(&hpwdt_dev);
if (retval < 0) { if (retval < 0) {
dev_warn(&dev->dev, dev_err(&dev->dev, "watchdog register failed: %d.\n", retval);
"Unable to register miscdev on minor=%d (err=%d).\n", goto error_wd_register;
WATCHDOG_MINOR, retval);
goto error_misc_register;
} }
dev_info(&dev->dev, "HPE Watchdog Timer Driver: %s" dev_info(&dev->dev, "HPE Watchdog Timer Driver: %s"
", timer margin: %d seconds (nowayout=%d).\n", ", timer margin: %d seconds (nowayout=%d).\n",
HPWDT_VERSION, soft_margin, nowayout); HPWDT_VERSION, hpwdt_dev.timeout, nowayout);
if (dev->subsystem_vendor == PCI_VENDOR_ID_HP_3PAR)
ilo5 = true;
return 0; return 0;
error_misc_register: error_wd_register:
hpwdt_exit_nmi_decoding(); hpwdt_exit_nmi_decoding();
error_init_nmi_decoding: error_init_nmi_decoding:
pci_iounmap(dev, pci_mem_addr); pci_iounmap(dev, pci_mem_addr);
...@@ -411,7 +343,7 @@ static void hpwdt_exit(struct pci_dev *dev) ...@@ -411,7 +343,7 @@ static void hpwdt_exit(struct pci_dev *dev)
if (!nowayout) if (!nowayout)
hpwdt_stop(); hpwdt_stop();
misc_deregister(&hpwdt_miscdev); watchdog_unregister_device(&hpwdt_dev);
hpwdt_exit_nmi_decoding(); hpwdt_exit_nmi_decoding();
pci_iounmap(dev, pci_mem_addr); pci_iounmap(dev, pci_mem_addr);
pci_disable_device(dev); pci_disable_device(dev);
...@@ -425,7 +357,7 @@ static struct pci_driver hpwdt_driver = { ...@@ -425,7 +357,7 @@ static struct pci_driver hpwdt_driver = {
}; };
MODULE_AUTHOR("Tom Mingarelli"); MODULE_AUTHOR("Tom Mingarelli");
MODULE_DESCRIPTION("hp watchdog driver"); MODULE_DESCRIPTION("hpe watchdog driver");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_VERSION(HPWDT_VERSION); MODULE_VERSION(HPWDT_VERSION);
...@@ -437,8 +369,8 @@ MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" ...@@ -437,8 +369,8 @@ MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
__MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
#ifdef CONFIG_HPWDT_NMI_DECODING #ifdef CONFIG_HPWDT_NMI_DECODING
module_param(allow_kdump, int, 0); module_param(pretimeout, bool, 0);
MODULE_PARM_DESC(allow_kdump, "Start a kernel dump after NMI occurs"); MODULE_PARM_DESC(pretimeout, "Watchdog pretimeout enabled");
#endif /* CONFIG_HPWDT_NMI_DECODING */ #endif
module_pci_driver(hpwdt_driver); module_pci_driver(hpwdt_driver);
...@@ -76,7 +76,7 @@ MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" ...@@ -76,7 +76,7 @@ MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
__MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
static unsigned timeout = IMX2_WDT_DEFAULT_TIME; static unsigned timeout;
module_param(timeout, uint, 0); module_param(timeout, uint, 0);
MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds (default=" MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds (default="
__MODULE_STRING(IMX2_WDT_DEFAULT_TIME) ")"); __MODULE_STRING(IMX2_WDT_DEFAULT_TIME) ")");
...@@ -281,6 +281,7 @@ static int __init imx2_wdt_probe(struct platform_device *pdev) ...@@ -281,6 +281,7 @@ static int __init imx2_wdt_probe(struct platform_device *pdev)
wdog->info = &imx2_wdt_info; wdog->info = &imx2_wdt_info;
wdog->ops = &imx2_wdt_ops; wdog->ops = &imx2_wdt_ops;
wdog->min_timeout = 1; wdog->min_timeout = 1;
wdog->timeout = IMX2_WDT_DEFAULT_TIME;
wdog->max_hw_heartbeat_ms = IMX2_WDT_MAX_TIME * 1000; wdog->max_hw_heartbeat_ms = IMX2_WDT_MAX_TIME * 1000;
wdog->parent = &pdev->dev; wdog->parent = &pdev->dev;
...@@ -299,11 +300,6 @@ static int __init imx2_wdt_probe(struct platform_device *pdev) ...@@ -299,11 +300,6 @@ static int __init imx2_wdt_probe(struct platform_device *pdev)
wdev->ext_reset = of_property_read_bool(pdev->dev.of_node, wdev->ext_reset = of_property_read_bool(pdev->dev.of_node,
"fsl,ext-reset-output"); "fsl,ext-reset-output");
wdog->timeout = clamp_t(unsigned, timeout, 1, IMX2_WDT_MAX_TIME);
if (wdog->timeout != timeout)
dev_warn(&pdev->dev, "Initial timeout out of range! Clamped from %u to %u\n",
timeout, wdog->timeout);
platform_set_drvdata(pdev, wdog); platform_set_drvdata(pdev, wdog);
watchdog_set_drvdata(wdog, wdev); watchdog_set_drvdata(wdog, wdev);
watchdog_set_nowayout(wdog, nowayout); watchdog_set_nowayout(wdog, nowayout);
......
...@@ -265,7 +265,7 @@ static int lpc18xx_wdt_probe(struct platform_device *pdev) ...@@ -265,7 +265,7 @@ static int lpc18xx_wdt_probe(struct platform_device *pdev)
lpc18xx_wdt->wdt_dev.parent = dev; lpc18xx_wdt->wdt_dev.parent = dev;
watchdog_set_drvdata(&lpc18xx_wdt->wdt_dev, lpc18xx_wdt); watchdog_set_drvdata(&lpc18xx_wdt->wdt_dev, lpc18xx_wdt);
ret = watchdog_init_timeout(&lpc18xx_wdt->wdt_dev, heartbeat, dev); watchdog_init_timeout(&lpc18xx_wdt->wdt_dev, heartbeat, dev);
__lpc18xx_wdt_set_timeout(lpc18xx_wdt); __lpc18xx_wdt_set_timeout(lpc18xx_wdt);
......
// SPDX-License-Identifier: GPL-2.0
/* /*
* Intel Management Engine Interface (Intel MEI) Linux driver * Intel Management Engine Interface (Intel MEI) Linux driver
* Copyright (c) 2015, Intel Corporation. * Copyright (c) 2015, Intel Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope 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.
*/ */
#include <linux/module.h> #include <linux/module.h>
...@@ -687,5 +679,5 @@ static struct mei_cl_driver mei_wdt_driver = { ...@@ -687,5 +679,5 @@ static struct mei_cl_driver mei_wdt_driver = {
module_mei_cl_driver(mei_wdt_driver); module_mei_cl_driver(mei_wdt_driver);
MODULE_AUTHOR("Intel Corporation"); MODULE_AUTHOR("Intel Corporation");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL v2");
MODULE_DESCRIPTION("Device driver for Intel MEI iAMT watchdog"); MODULE_DESCRIPTION("Device driver for Intel MEI iAMT watchdog");
// SPDX-License-Identifier: GPL-2.0+
/* /*
* Watchdog driver for the A21 VME CPU Boards * Watchdog driver for the A21 VME CPU Boards
* *
* Copyright (C) 2013 MEN Mikro Elektronik Nuernberg GmbH * Copyright (C) 2013 MEN Mikro Elektronik Nuernberg GmbH
* *
* 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
*/ */
#include <linux/module.h> #include <linux/module.h>
#include <linux/moduleparam.h> #include <linux/moduleparam.h>
......
// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
/* /*
* This file is provided under a dual BSD/GPLv2 license. When using or
* redistributing this file, you may do so under either license.
*
* GPL LICENSE SUMMARY
*
* Copyright (c) 2016 BayLibre, SAS. * Copyright (c) 2016 BayLibre, SAS.
* Author: Neil Armstrong <narmstrong@baylibre.com> * Author: Neil Armstrong <narmstrong@baylibre.com>
* *
* This program is free software; you can redistribute it and/or modify
* it under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
* The full GNU General Public License is included in this distribution
* in the file called COPYING.
*
* BSD LICENSE
*
* Copyright (c) 2016 BayLibre, SAS.
* Author: Neil Armstrong <narmstrong@baylibre.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Intel Corporation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/err.h> #include <linux/err.h>
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
#define MESON_SEC_TO_TC(s, c) ((s) * (c)) #define MESON_SEC_TO_TC(s, c) ((s) * (c))
static bool nowayout = WATCHDOG_NOWAYOUT; static bool nowayout = WATCHDOG_NOWAYOUT;
static unsigned int timeout = MESON_WDT_TIMEOUT; static unsigned int timeout;
struct meson_wdt_data { struct meson_wdt_data {
unsigned int enable; unsigned int enable;
......
// SPDX-License-Identifier: GPL-2.0+
/* /*
* Mediatek Watchdog Driver * Mediatek Watchdog Driver
* *
...@@ -5,16 +6,6 @@ ...@@ -5,16 +6,6 @@
* *
* Matthias Brugger <matthias.bgg@gmail.com> * Matthias Brugger <matthias.bgg@gmail.com>
* *
* 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.
*
* Based on sunxi_wdt.c * Based on sunxi_wdt.c
*/ */
...@@ -57,7 +48,7 @@ ...@@ -57,7 +48,7 @@
#define DRV_VERSION "1.0" #define DRV_VERSION "1.0"
static bool nowayout = WATCHDOG_NOWAYOUT; static bool nowayout = WATCHDOG_NOWAYOUT;
static unsigned int timeout = WDT_MAX_TIMEOUT; static unsigned int timeout;
struct mtk_wdt_dev { struct mtk_wdt_dev {
struct watchdog_device wdt_dev; struct watchdog_device wdt_dev;
......
// SPDX-License-Identifier: GPL-2.0+
/* /*
* Driver for the MTX-1 Watchdog. * Driver for the MTX-1 Watchdog.
* *
...@@ -6,16 +7,6 @@ ...@@ -6,16 +7,6 @@
* http://www.4g-systems.biz * http://www.4g-systems.biz
* *
* (C) Copyright 2007 OpenWrt.org, Florian Fainelli <florian@openwrt.org> * (C) Copyright 2007 OpenWrt.org, Florian Fainelli <florian@openwrt.org>
*
* 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.
*
* Neither Michael Stickel nor 4G Systems admit liability nor provide
* warranty for any of this software. This material is provided
* "AS-IS" and at no charge.
*
* (c) Copyright 2005 4G Systems <info@4g-systems.biz> * (c) Copyright 2005 4G Systems <info@4g-systems.biz>
* *
* Release 0.01. * Release 0.01.
......
// SPDX-License-Identifier: GPL-2.0
// Copyright (c) 2018 Nuvoton Technology corporation.
// Copyright (c) 2018 IBM Corp.
#include <linux/bitops.h>
#include <linux/delay.h>
#include <linux/interrupt.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/of_irq.h>
#include <linux/platform_device.h>
#include <linux/slab.h>
#include <linux/watchdog.h>
#define NPCM_WTCR 0x1C
#define NPCM_WTCLK (BIT(10) | BIT(11)) /* Clock divider */
#define NPCM_WTE BIT(7) /* Enable */
#define NPCM_WTIE BIT(6) /* Enable irq */
#define NPCM_WTIS (BIT(4) | BIT(5)) /* Interval selection */
#define NPCM_WTIF BIT(3) /* Interrupt flag*/
#define NPCM_WTRF BIT(2) /* Reset flag */
#define NPCM_WTRE BIT(1) /* Reset enable */
#define NPCM_WTR BIT(0) /* Reset counter */
/*
* Watchdog timeouts
*
* 170 msec: WTCLK=01 WTIS=00 VAL= 0x400
* 670 msec: WTCLK=01 WTIS=01 VAL= 0x410
* 1360 msec: WTCLK=10 WTIS=00 VAL= 0x800
* 2700 msec: WTCLK=01 WTIS=10 VAL= 0x420
* 5360 msec: WTCLK=10 WTIS=01 VAL= 0x810
* 10700 msec: WTCLK=01 WTIS=11 VAL= 0x430
* 21600 msec: WTCLK=10 WTIS=10 VAL= 0x820
* 43000 msec: WTCLK=11 WTIS=00 VAL= 0xC00
* 85600 msec: WTCLK=10 WTIS=11 VAL= 0x830
* 172000 msec: WTCLK=11 WTIS=01 VAL= 0xC10
* 687000 msec: WTCLK=11 WTIS=10 VAL= 0xC20
* 2750000 msec: WTCLK=11 WTIS=11 VAL= 0xC30
*/
struct npcm_wdt {
struct watchdog_device wdd;
void __iomem *reg;
};
static inline struct npcm_wdt *to_npcm_wdt(struct watchdog_device *wdd)
{
return container_of(wdd, struct npcm_wdt, wdd);
}
static int npcm_wdt_ping(struct watchdog_device *wdd)
{
struct npcm_wdt *wdt = to_npcm_wdt(wdd);
u32 val;
val = readl(wdt->reg);
writel(val | NPCM_WTR, wdt->reg);
return 0;
}
static int npcm_wdt_start(struct watchdog_device *wdd)
{
struct npcm_wdt *wdt = to_npcm_wdt(wdd);
u32 val;
if (wdd->timeout < 2)
val = 0x800;
else if (wdd->timeout < 3)
val = 0x420;
else if (wdd->timeout < 6)
val = 0x810;
else if (wdd->timeout < 11)
val = 0x430;
else if (wdd->timeout < 22)
val = 0x820;
else if (wdd->timeout < 44)
val = 0xC00;
else if (wdd->timeout < 87)
val = 0x830;
else if (wdd->timeout < 173)
val = 0xC10;
else if (wdd->timeout < 688)
val = 0xC20;
else
val = 0xC30;
val |= NPCM_WTRE | NPCM_WTE | NPCM_WTR | NPCM_WTIE;
writel(val, wdt->reg);
return 0;
}
static int npcm_wdt_stop(struct watchdog_device *wdd)
{
struct npcm_wdt *wdt = to_npcm_wdt(wdd);
writel(0, wdt->reg);
return 0;
}
static int npcm_wdt_set_timeout(struct watchdog_device *wdd,
unsigned int timeout)
{
if (timeout < 2)
wdd->timeout = 1;
else if (timeout < 3)
wdd->timeout = 2;
else if (timeout < 6)
wdd->timeout = 5;
else if (timeout < 11)
wdd->timeout = 10;
else if (timeout < 22)
wdd->timeout = 21;
else if (timeout < 44)
wdd->timeout = 43;
else if (timeout < 87)
wdd->timeout = 86;
else if (timeout < 173)
wdd->timeout = 172;
else if (timeout < 688)
wdd->timeout = 687;
else
wdd->timeout = 2750;
if (watchdog_active(wdd))
npcm_wdt_start(wdd);
return 0;
}
static irqreturn_t npcm_wdt_interrupt(int irq, void *data)
{
struct npcm_wdt *wdt = data;
watchdog_notify_pretimeout(&wdt->wdd);
return IRQ_HANDLED;
}
static int npcm_wdt_restart(struct watchdog_device *wdd,
unsigned long action, void *data)
{
struct npcm_wdt *wdt = to_npcm_wdt(wdd);
writel(NPCM_WTR | NPCM_WTRE | NPCM_WTE, wdt->reg);
udelay(1000);
return 0;
}
static bool npcm_is_running(struct watchdog_device *wdd)
{
struct npcm_wdt *wdt = to_npcm_wdt(wdd);
return readl(wdt->reg) & NPCM_WTE;
}
static const struct watchdog_info npcm_wdt_info = {
.identity = KBUILD_MODNAME,
.options = WDIOF_SETTIMEOUT
| WDIOF_KEEPALIVEPING
| WDIOF_MAGICCLOSE,
};
static const struct watchdog_ops npcm_wdt_ops = {
.owner = THIS_MODULE,
.start = npcm_wdt_start,
.stop = npcm_wdt_stop,
.ping = npcm_wdt_ping,
.set_timeout = npcm_wdt_set_timeout,
.restart = npcm_wdt_restart,
};
static int npcm_wdt_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct npcm_wdt *wdt;
struct resource *res;
int irq;
int ret;
wdt = devm_kzalloc(&pdev->dev, sizeof(*wdt), GFP_KERNEL);
if (!wdt)
return -ENOMEM;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
wdt->reg = devm_ioremap_resource(dev, res);
if (IS_ERR(wdt->reg))
return PTR_ERR(wdt->reg);
irq = platform_get_irq(pdev, 0);
if (irq < 0)
return irq;
wdt->wdd.info = &npcm_wdt_info;
wdt->wdd.ops = &npcm_wdt_ops;
wdt->wdd.min_timeout = 1;
wdt->wdd.max_timeout = 2750;
wdt->wdd.parent = dev;
wdt->wdd.timeout = 86;
watchdog_init_timeout(&wdt->wdd, 0, dev);
/* Ensure timeout is able to be represented by the hardware */
npcm_wdt_set_timeout(&wdt->wdd, wdt->wdd.timeout);
if (npcm_is_running(&wdt->wdd)) {
/* Restart with the default or device-tree specified timeout */
npcm_wdt_start(&wdt->wdd);
set_bit(WDOG_HW_RUNNING, &wdt->wdd.status);
}
ret = devm_request_irq(dev, irq, npcm_wdt_interrupt, 0,
"watchdog", wdt);
if (ret)
return ret;
ret = devm_watchdog_register_device(dev, &wdt->wdd);
if (ret) {
dev_err(dev, "failed to register watchdog\n");
return ret;
}
dev_info(dev, "NPCM watchdog driver enabled\n");
return 0;
}
#ifdef CONFIG_OF
static const struct of_device_id npcm_wdt_match[] = {
{.compatible = "nuvoton,npcm750-wdt"},
{},
};
MODULE_DEVICE_TABLE(of, npcm_wdt_match);
#endif
static struct platform_driver npcm_wdt_driver = {
.probe = npcm_wdt_probe,
.driver = {
.name = "npcm-wdt",
.of_match_table = of_match_ptr(npcm_wdt_match),
},
};
module_platform_driver(npcm_wdt_driver);
MODULE_AUTHOR("Joel Stanley");
MODULE_DESCRIPTION("Watchdog driver for NPCM");
MODULE_LICENSE("GPL v2");
// SPDX-License-Identifier: GPL-2.0+
/* /*
* Watchdog Device Driver for Xilinx axi/xps_timebase_wdt * Watchdog Device Driver for Xilinx axi/xps_timebase_wdt
* *
* (C) Copyright 2013 - 2014 Xilinx, Inc. * (C) Copyright 2013 - 2014 Xilinx, Inc.
* (C) Copyright 2011 (Alejandro Cabrera <aldaya@gmail.com>) * (C) Copyright 2011 (Alejandro Cabrera <aldaya@gmail.com>)
*
* 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.
*/ */
#include <linux/clk.h> #include <linux/clk.h>
...@@ -323,4 +319,4 @@ module_platform_driver(xwdt_driver); ...@@ -323,4 +319,4 @@ module_platform_driver(xwdt_driver);
MODULE_AUTHOR("Alejandro Cabrera <aldaya@gmail.com>"); MODULE_AUTHOR("Alejandro Cabrera <aldaya@gmail.com>");
MODULE_DESCRIPTION("Xilinx Watchdog driver"); MODULE_DESCRIPTION("Xilinx Watchdog driver");
MODULE_LICENSE("GPL v2"); MODULE_LICENSE("GPL");
...@@ -253,10 +253,10 @@ static int omap_wdt_probe(struct platform_device *pdev) ...@@ -253,10 +253,10 @@ static int omap_wdt_probe(struct platform_device *pdev)
wdev->wdog.ops = &omap_wdt_ops; wdev->wdog.ops = &omap_wdt_ops;
wdev->wdog.min_timeout = TIMER_MARGIN_MIN; wdev->wdog.min_timeout = TIMER_MARGIN_MIN;
wdev->wdog.max_timeout = TIMER_MARGIN_MAX; wdev->wdog.max_timeout = TIMER_MARGIN_MAX;
wdev->wdog.timeout = TIMER_MARGIN_DEFAULT;
wdev->wdog.parent = &pdev->dev; wdev->wdog.parent = &pdev->dev;
if (watchdog_init_timeout(&wdev->wdog, timer_margin, &pdev->dev) < 0) watchdog_init_timeout(&wdev->wdog, timer_margin, &pdev->dev);
wdev->wdog.timeout = TIMER_MARGIN_DEFAULT;
watchdog_set_nowayout(&wdev->wdog, nowayout); watchdog_set_nowayout(&wdev->wdog, nowayout);
......
...@@ -78,7 +78,7 @@ ...@@ -78,7 +78,7 @@
#define WDOG_COUNTER_RATE 13000000 /*the counter clock is 13 MHz fixed */ #define WDOG_COUNTER_RATE 13000000 /*the counter clock is 13 MHz fixed */
static bool nowayout = WATCHDOG_NOWAYOUT; static bool nowayout = WATCHDOG_NOWAYOUT;
static unsigned int heartbeat = DEFAULT_HEARTBEAT; static unsigned int heartbeat;
static DEFINE_SPINLOCK(io_lock); static DEFINE_SPINLOCK(io_lock);
static void __iomem *wdt_base; static void __iomem *wdt_base;
......
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
#include <linux/of.h> #include <linux/of.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/pm_runtime.h> #include <linux/pm_runtime.h>
#include <linux/smp.h>
#include <linux/sys_soc.h>
#include <linux/watchdog.h> #include <linux/watchdog.h>
#define RWTCNT 0 #define RWTCNT 0
...@@ -49,6 +51,7 @@ struct rwdt_priv { ...@@ -49,6 +51,7 @@ struct rwdt_priv {
void __iomem *base; void __iomem *base;
struct watchdog_device wdev; struct watchdog_device wdev;
unsigned long clk_rate; unsigned long clk_rate;
u16 time_left;
u8 cks; u8 cks;
}; };
...@@ -107,6 +110,16 @@ static unsigned int rwdt_get_timeleft(struct watchdog_device *wdev) ...@@ -107,6 +110,16 @@ static unsigned int rwdt_get_timeleft(struct watchdog_device *wdev)
return DIV_BY_CLKS_PER_SEC(priv, 65536 - val); return DIV_BY_CLKS_PER_SEC(priv, 65536 - val);
} }
static int rwdt_restart(struct watchdog_device *wdev, unsigned long action,
void *data)
{
struct rwdt_priv *priv = watchdog_get_drvdata(wdev);
rwdt_start(wdev);
rwdt_write(priv, 0xffff, RWTCNT);
return 0;
}
static const struct watchdog_info rwdt_ident = { static const struct watchdog_info rwdt_ident = {
.options = WDIOF_MAGICCLOSE | WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT, .options = WDIOF_MAGICCLOSE | WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT,
.identity = "Renesas WDT Watchdog", .identity = "Renesas WDT Watchdog",
...@@ -118,8 +131,47 @@ static const struct watchdog_ops rwdt_ops = { ...@@ -118,8 +131,47 @@ static const struct watchdog_ops rwdt_ops = {
.stop = rwdt_stop, .stop = rwdt_stop,
.ping = rwdt_init_timeout, .ping = rwdt_init_timeout,
.get_timeleft = rwdt_get_timeleft, .get_timeleft = rwdt_get_timeleft,
.restart = rwdt_restart,
}; };
#if defined(CONFIG_ARCH_RCAR_GEN2) && defined(CONFIG_SMP)
/*
* Watchdog-reset integration is broken on early revisions of R-Car Gen2 SoCs
*/
static const struct soc_device_attribute rwdt_quirks_match[] = {
{
.soc_id = "r8a7790",
.revision = "ES1.*",
.data = (void *)1, /* needs single CPU */
}, {
.soc_id = "r8a7791",
.revision = "ES[12].*",
.data = (void *)1, /* needs single CPU */
}, {
.soc_id = "r8a7792",
.revision = "*",
.data = (void *)0, /* needs SMP disabled */
},
{ /* sentinel */ }
};
static bool rwdt_blacklisted(struct device *dev)
{
const struct soc_device_attribute *attr;
attr = soc_device_match(rwdt_quirks_match);
if (attr && setup_max_cpus > (uintptr_t)attr->data) {
dev_info(dev, "Watchdog blacklisted on %s %s\n", attr->soc_id,
attr->revision);
return true;
}
return false;
}
#else /* !CONFIG_ARCH_RCAR_GEN2 || !CONFIG_SMP */
static inline bool rwdt_blacklisted(struct device *dev) { return false; }
#endif /* !CONFIG_ARCH_RCAR_GEN2 || !CONFIG_SMP */
static int rwdt_probe(struct platform_device *pdev) static int rwdt_probe(struct platform_device *pdev)
{ {
struct rwdt_priv *priv; struct rwdt_priv *priv;
...@@ -128,6 +180,9 @@ static int rwdt_probe(struct platform_device *pdev) ...@@ -128,6 +180,9 @@ static int rwdt_probe(struct platform_device *pdev)
unsigned long clks_per_sec; unsigned long clks_per_sec;
int ret, i; int ret, i;
if (rwdt_blacklisted(&pdev->dev))
return -ENODEV;
priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
if (!priv) if (!priv)
return -ENOMEM; return -ENOMEM;
...@@ -176,6 +231,7 @@ static int rwdt_probe(struct platform_device *pdev) ...@@ -176,6 +231,7 @@ static int rwdt_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, priv); platform_set_drvdata(pdev, priv);
watchdog_set_drvdata(&priv->wdev, priv); watchdog_set_drvdata(&priv->wdev, priv);
watchdog_set_nowayout(&priv->wdev, nowayout); watchdog_set_nowayout(&priv->wdev, nowayout);
watchdog_set_restart_priority(&priv->wdev, 0);
/* This overrides the default timeout only if DT configuration was found */ /* This overrides the default timeout only if DT configuration was found */
ret = watchdog_init_timeout(&priv->wdev, 0, &pdev->dev); ret = watchdog_init_timeout(&priv->wdev, 0, &pdev->dev);
...@@ -203,12 +259,32 @@ static int rwdt_remove(struct platform_device *pdev) ...@@ -203,12 +259,32 @@ static int rwdt_remove(struct platform_device *pdev)
return 0; return 0;
} }
/* static int __maybe_unused rwdt_suspend(struct device *dev)
* This driver does also fit for R-Car Gen2 (r8a779[0-4]) WDT. However, for SMP {
* to work there, one also needs a RESET (RST) driver which does not exist yet struct rwdt_priv *priv = dev_get_drvdata(dev);
* due to HW issues. This needs to be solved before adding compatibles here.
*/ if (watchdog_active(&priv->wdev)) {
priv->time_left = readw(priv->base + RWTCNT);
rwdt_stop(&priv->wdev);
}
return 0;
}
static int __maybe_unused rwdt_resume(struct device *dev)
{
struct rwdt_priv *priv = dev_get_drvdata(dev);
if (watchdog_active(&priv->wdev)) {
rwdt_start(&priv->wdev);
rwdt_write(priv, priv->time_left, RWTCNT);
}
return 0;
}
static SIMPLE_DEV_PM_OPS(rwdt_pm_ops, rwdt_suspend, rwdt_resume);
static const struct of_device_id rwdt_ids[] = { static const struct of_device_id rwdt_ids[] = {
{ .compatible = "renesas,rcar-gen2-wdt", },
{ .compatible = "renesas,rcar-gen3-wdt", }, { .compatible = "renesas,rcar-gen3-wdt", },
{ /* sentinel */ } { /* sentinel */ }
}; };
...@@ -218,6 +294,7 @@ static struct platform_driver rwdt_driver = { ...@@ -218,6 +294,7 @@ static struct platform_driver rwdt_driver = {
.driver = { .driver = {
.name = "renesas_wdt", .name = "renesas_wdt",
.of_match_table = rwdt_ids, .of_match_table = rwdt_ids,
.pm = &rwdt_pm_ops,
}, },
.probe = rwdt_probe, .probe = rwdt_probe,
.remove = rwdt_remove, .remove = rwdt_remove,
......
...@@ -33,7 +33,7 @@ struct sama5d4_wdt { ...@@ -33,7 +33,7 @@ struct sama5d4_wdt {
unsigned long last_ping; unsigned long last_ping;
}; };
static int wdt_timeout = WDT_DEFAULT_TIMEOUT; static int wdt_timeout;
static bool nowayout = WATCHDOG_NOWAYOUT; static bool nowayout = WATCHDOG_NOWAYOUT;
module_param(wdt_timeout, int, 0); module_param(wdt_timeout, int, 0);
...@@ -212,7 +212,7 @@ static int sama5d4_wdt_probe(struct platform_device *pdev) ...@@ -212,7 +212,7 @@ static int sama5d4_wdt_probe(struct platform_device *pdev)
return -ENOMEM; return -ENOMEM;
wdd = &wdt->wdd; wdd = &wdt->wdd;
wdd->timeout = wdt_timeout; wdd->timeout = WDT_DEFAULT_TIMEOUT;
wdd->info = &sama5d4_wdt_info; wdd->info = &sama5d4_wdt_info;
wdd->ops = &sama5d4_wdt_ops; wdd->ops = &sama5d4_wdt_ops;
wdd->min_timeout = MIN_WDT_TIMEOUT; wdd->min_timeout = MIN_WDT_TIMEOUT;
...@@ -273,7 +273,7 @@ static int sama5d4_wdt_probe(struct platform_device *pdev) ...@@ -273,7 +273,7 @@ static int sama5d4_wdt_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, wdt); platform_set_drvdata(pdev, wdt);
dev_info(&pdev->dev, "initialized (timeout = %d sec, nowayout = %d)\n", dev_info(&pdev->dev, "initialized (timeout = %d sec, nowayout = %d)\n",
wdt_timeout, nowayout); wdd->timeout, nowayout);
return 0; return 0;
} }
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#define SIRFSOC_WDT_MAX_TIMEOUT (10 * 60) /* 10 mins */ #define SIRFSOC_WDT_MAX_TIMEOUT (10 * 60) /* 10 mins */
#define SIRFSOC_WDT_DEFAULT_TIMEOUT 30 /* 30 secs */ #define SIRFSOC_WDT_DEFAULT_TIMEOUT 30 /* 30 secs */
static unsigned int timeout = SIRFSOC_WDT_DEFAULT_TIMEOUT; static unsigned int timeout;
static bool nowayout = WATCHDOG_NOWAYOUT; static bool nowayout = WATCHDOG_NOWAYOUT;
module_param(timeout, uint, 0); module_param(timeout, uint, 0);
......
...@@ -154,8 +154,10 @@ static int sprd_wdt_enable(struct sprd_wdt *wdt) ...@@ -154,8 +154,10 @@ static int sprd_wdt_enable(struct sprd_wdt *wdt)
if (ret) if (ret)
return ret; return ret;
ret = clk_prepare_enable(wdt->rtc_enable); ret = clk_prepare_enable(wdt->rtc_enable);
if (ret) if (ret) {
clk_disable_unprepare(wdt->enable);
return ret; return ret;
}
sprd_wdt_unlock(wdt->base); sprd_wdt_unlock(wdt->base);
val = readl_relaxed(wdt->base + SPRD_WDT_CTRL); val = readl_relaxed(wdt->base + SPRD_WDT_CTRL);
......
// SPDX-License-Identifier: GPL-2.0+
/* /*
* ST's LPC Watchdog * ST's LPC Watchdog
* *
...@@ -5,11 +6,6 @@ ...@@ -5,11 +6,6 @@
* *
* Author: David Paris <david.paris@st.com> for STMicroelectronics * Author: David Paris <david.paris@st.com> for STMicroelectronics
* Lee Jones <lee.jones@linaro.org> for STMicroelectronics * Lee Jones <lee.jones@linaro.org> for STMicroelectronics
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public Licence
* as published by the Free Software Foundation; either version
* 2 of the Licence, or (at your option) any later version.
*/ */
#include <linux/clk.h> #include <linux/clk.h>
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
#define DRV_VERSION "1.0" #define DRV_VERSION "1.0"
static bool nowayout = WATCHDOG_NOWAYOUT; static bool nowayout = WATCHDOG_NOWAYOUT;
static unsigned int timeout = WDT_MAX_TIMEOUT; static unsigned int timeout;
/* /*
* This structure stores the register offsets for different variants * This structure stores the register offsets for different variants
......
// SPDX-License-Identifier: GPL-2.0+
/* /*
* Copyright (C) 2015 Mans Rullgard <mans@mansr.com> * Copyright (C) 2015 Mans Rullgard <mans@mansr.com>
* SMP86xx/SMP87xx Watchdog driver * SMP86xx/SMP87xx Watchdog driver
*
* 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.
*/ */
#include <linux/bitops.h> #include <linux/bitops.h>
......
// SPDX-License-Identifier: GPL-2.0
/* /*
* Copyright (c) 2014, NVIDIA CORPORATION. All rights reserved. * Copyright (c) 2014, NVIDIA CORPORATION. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope 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.
*/ */
#include <linux/kernel.h> #include <linux/kernel.h>
......
// SPDX-License-Identifier: GPL-2.0
/* /*
* Watchdog driver for the UniPhier watchdog timer * Watchdog driver for the UniPhier watchdog timer
* *
* (c) Copyright 2014 Panasonic Corporation * (c) Copyright 2014 Panasonic Corporation
* (c) Copyright 2016 Socionext Inc. * (c) Copyright 2016 Socionext Inc.
* All rights reserved. * All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* 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.
*/ */
#include <linux/bitops.h> #include <linux/bitops.h>
...@@ -212,11 +204,10 @@ static int uniphier_wdt_probe(struct platform_device *pdev) ...@@ -212,11 +204,10 @@ static int uniphier_wdt_probe(struct platform_device *pdev)
wdev->wdt_dev.ops = &uniphier_wdt_ops; wdev->wdt_dev.ops = &uniphier_wdt_ops;
wdev->wdt_dev.max_timeout = WDT_PERIOD_MAX; wdev->wdt_dev.max_timeout = WDT_PERIOD_MAX;
wdev->wdt_dev.min_timeout = WDT_PERIOD_MIN; wdev->wdt_dev.min_timeout = WDT_PERIOD_MIN;
wdev->wdt_dev.timeout = WDT_DEFAULT_TIMEOUT;
wdev->wdt_dev.parent = dev; wdev->wdt_dev.parent = dev;
if (watchdog_init_timeout(&wdev->wdt_dev, timeout, dev) < 0) { watchdog_init_timeout(&wdev->wdt_dev, timeout, dev);
wdev->wdt_dev.timeout = WDT_DEFAULT_TIMEOUT;
}
watchdog_set_nowayout(&wdev->wdt_dev, nowayout); watchdog_set_nowayout(&wdev->wdt_dev, nowayout);
watchdog_stop_on_reboot(&wdev->wdt_dev); watchdog_stop_on_reboot(&wdev->wdt_dev);
......
// SPDX-License-Identifier: GPL-2.0+
/* /*
* Watchdog driver for the wm831x PMICs * Watchdog driver for the wm831x PMICs
* *
* Copyright (C) 2009 Wolfson Microelectronics * Copyright (C) 2009 Wolfson Microelectronics
*
* 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
*/ */
#include <linux/module.h> #include <linux/module.h>
......
// SPDX-License-Identifier: GPL-2.0+
/* /*
* Watchdog driver for the wm8350 * Watchdog driver for the wm8350
* *
* Copyright (C) 2007, 2008 Wolfson Microelectronics <linux@wolfsonmicro.com> * Copyright (C) 2007, 2008 Wolfson Microelectronics <linux@wolfsonmicro.com>
*
* 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
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment