summaryrefslogtreecommitdiff
path: root/drivers/watchdog
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/watchdog')
-rw-r--r--drivers/watchdog/Kconfig22
-rw-r--r--drivers/watchdog/Makefile1
-rw-r--r--drivers/watchdog/alim7101_wdt.c4
-rw-r--r--drivers/watchdog/aspeed_wdt.c81
-rw-r--r--drivers/watchdog/at91sam9_wdt.c4
-rw-r--r--drivers/watchdog/bcm47xx_wdt.c4
-rw-r--r--drivers/watchdog/cpwd.c4
-rw-r--r--drivers/watchdog/cros_ec_wdt.c10
-rw-r--r--drivers/watchdog/lenovo_se30_wdt.c394
-rw-r--r--drivers/watchdog/lpc18xx_wdt.c4
-rw-r--r--drivers/watchdog/machzwd.c4
-rw-r--r--drivers/watchdog/mixcomwd.c4
-rw-r--r--drivers/watchdog/nic7018_wdt.c9
-rw-r--r--drivers/watchdog/npcm_wdt.c9
-rw-r--r--drivers/watchdog/pcwd.c2
-rw-r--r--drivers/watchdog/pika_wdt.c2
-rw-r--r--drivers/watchdog/s3c2410_wdt.c10
-rw-r--r--drivers/watchdog/sbc60xxwdt.c4
-rw-r--r--drivers/watchdog/sc520_wdt.c2
-rw-r--r--drivers/watchdog/shwdt.c2
-rw-r--r--drivers/watchdog/sunxi_wdt.c11
-rw-r--r--drivers/watchdog/via_wdt.c2
-rw-r--r--drivers/watchdog/w83877f_wdt.c4
-rw-r--r--drivers/watchdog/watchdog_core.c6
24 files changed, 548 insertions, 51 deletions
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index f81705f8539a..0d8d37f712e8 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -279,6 +279,18 @@ config LENOVO_SE10_WDT
This driver can also be built as a module. If so, the module
will be called lenovo-se10-wdt.
+config LENOVO_SE30_WDT
+ tristate "Lenovo SE30 Watchdog"
+ depends on (X86 && DMI) || COMPILE_TEST
+ depends on HAS_IOPORT
+ select WATCHDOG_CORE
+ help
+ If you say yes here you get support for the watchdog
+ functionality for the Lenovo SE30 platform.
+
+ This driver can also be built as a module. If so, the module
+ will be called lenovo-se30-wdt.
+
config MENF21BMC_WATCHDOG
tristate "MEN 14F021P00 BMC Watchdog"
depends on MFD_MENF21BMC || COMPILE_TEST
@@ -963,13 +975,14 @@ config RENESAS_RZG2LWDT
Renesas RZ/G2L SoCs. These watchdogs can be used to reset a system.
config RENESAS_RZV2HWDT
- tristate "Renesas RZ/V2H(P) WDT Watchdog"
- depends on ARCH_R9A09G057 || COMPILE_TEST
+ tristate "Renesas RZ/{G3E,V2H(P)} WDT Watchdog"
+ depends on ARCH_RENESAS || COMPILE_TEST
depends on PM || COMPILE_TEST
select WATCHDOG_CORE
help
This driver adds watchdog support for the integrated watchdogs in the
- Renesas RZ/V2H(P) SoCs. These watchdogs can be used to reset a system.
+ Renesas RZ/{G3E,V2H(P)} SoCs. These watchdogs can be used to reset a
+ system.
config ASPEED_WATCHDOG
tristate "Aspeed BMC watchdog support"
@@ -1730,7 +1743,8 @@ config NI903X_WDT
config NIC7018_WDT
tristate "NIC7018 Watchdog"
- depends on X86 && ACPI
+ depends on HAS_IOPORT
+ depends on ACPI || COMPILE_TEST
select WATCHDOG_CORE
help
Support for National Instruments NIC7018 Watchdog.
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
index 8411626fa162..c9482904bf87 100644
--- a/drivers/watchdog/Makefile
+++ b/drivers/watchdog/Makefile
@@ -124,6 +124,7 @@ obj-$(CONFIG_I6300ESB_WDT) += i6300esb.o
obj-$(CONFIG_IE6XX_WDT) += ie6xx_wdt.o
obj-$(CONFIG_ITCO_WDT) += iTCO_wdt.o
obj-$(CONFIG_LENOVO_SE10_WDT) += lenovo_se10_wdt.o
+obj-$(CONFIG_LENOVO_SE30_WDT) += lenovo_se30_wdt.o
ifeq ($(CONFIG_ITCO_VENDOR_SUPPORT),y)
obj-$(CONFIG_ITCO_WDT) += iTCO_vendor_support.o
endif
diff --git a/drivers/watchdog/alim7101_wdt.c b/drivers/watchdog/alim7101_wdt.c
index 9c7cf939ba3d..03a559b41f5b 100644
--- a/drivers/watchdog/alim7101_wdt.c
+++ b/drivers/watchdog/alim7101_wdt.c
@@ -166,7 +166,7 @@ static void wdt_startup(void)
static void wdt_turnoff(void)
{
/* Stop the timer */
- del_timer_sync(&timer);
+ timer_delete_sync(&timer);
wdt_change(WDT_DISABLE);
pr_info("Watchdog timer is now disabled...\n");
}
@@ -223,7 +223,7 @@ static int fop_close(struct inode *inode, struct file *file)
if (wdt_expect_close == 42)
wdt_turnoff();
else {
- /* wim: shouldn't there be a: del_timer(&timer); */
+ /* wim: shouldn't there be a: timer_delete(&timer); */
pr_crit("device file closed unexpectedly. Will not stop the WDT!\n");
}
clear_bit(0, &wdt_is_open);
diff --git a/drivers/watchdog/aspeed_wdt.c b/drivers/watchdog/aspeed_wdt.c
index b4773a6aaf8c..837e15701c0e 100644
--- a/drivers/watchdog/aspeed_wdt.c
+++ b/drivers/watchdog/aspeed_wdt.c
@@ -11,21 +11,30 @@
#include <linux/io.h>
#include <linux/kernel.h>
#include <linux/kstrtox.h>
+#include <linux/mfd/syscon.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_irq.h>
#include <linux/platform_device.h>
+#include <linux/regmap.h>
#include <linux/watchdog.h>
static bool nowayout = WATCHDOG_NOWAYOUT;
module_param(nowayout, bool, 0);
MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
__MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
+struct aspeed_wdt_scu {
+ const char *compatible;
+ u32 reset_status_reg;
+ u32 wdt_reset_mask;
+ u32 wdt_reset_mask_shift;
+};
struct aspeed_wdt_config {
u32 ext_pulse_width_mask;
u32 irq_shift;
u32 irq_mask;
+ struct aspeed_wdt_scu scu;
};
struct aspeed_wdt {
@@ -39,18 +48,36 @@ static const struct aspeed_wdt_config ast2400_config = {
.ext_pulse_width_mask = 0xff,
.irq_shift = 0,
.irq_mask = 0,
+ .scu = {
+ .compatible = "aspeed,ast2400-scu",
+ .reset_status_reg = 0x3c,
+ .wdt_reset_mask = 0x1,
+ .wdt_reset_mask_shift = 1,
+ },
};
static const struct aspeed_wdt_config ast2500_config = {
.ext_pulse_width_mask = 0xfffff,
.irq_shift = 12,
.irq_mask = GENMASK(31, 12),
+ .scu = {
+ .compatible = "aspeed,ast2500-scu",
+ .reset_status_reg = 0x3c,
+ .wdt_reset_mask = 0x1,
+ .wdt_reset_mask_shift = 2,
+ },
};
static const struct aspeed_wdt_config ast2600_config = {
.ext_pulse_width_mask = 0xfffff,
.irq_shift = 0,
.irq_mask = GENMASK(31, 10),
+ .scu = {
+ .compatible = "aspeed,ast2600-scu",
+ .reset_status_reg = 0x74,
+ .wdt_reset_mask = 0xf,
+ .wdt_reset_mask_shift = 16,
+ },
};
static const struct of_device_id aspeed_wdt_of_table[] = {
@@ -213,6 +240,56 @@ static int aspeed_wdt_restart(struct watchdog_device *wdd,
return 0;
}
+static void aspeed_wdt_update_bootstatus(struct platform_device *pdev,
+ struct aspeed_wdt *wdt)
+{
+ const struct resource *res;
+ struct aspeed_wdt_scu scu = wdt->cfg->scu;
+ struct regmap *scu_base;
+ u32 reset_mask_width;
+ u32 reset_mask_shift;
+ u32 idx = 0;
+ u32 status;
+ int ret;
+
+ if (!of_device_is_compatible(pdev->dev.of_node, "aspeed,ast2400-wdt")) {
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ idx = ((intptr_t)wdt->base & 0x00000fff) / (uintptr_t)resource_size(res);
+ }
+
+ scu_base = syscon_regmap_lookup_by_compatible(scu.compatible);
+ if (IS_ERR(scu_base)) {
+ wdt->wdd.bootstatus = WDIOS_UNKNOWN;
+ return;
+ }
+
+ ret = regmap_read(scu_base, scu.reset_status_reg, &status);
+ if (ret) {
+ wdt->wdd.bootstatus = WDIOS_UNKNOWN;
+ return;
+ }
+
+ reset_mask_width = hweight32(scu.wdt_reset_mask);
+ reset_mask_shift = scu.wdt_reset_mask_shift +
+ reset_mask_width * idx;
+
+ if (status & (scu.wdt_reset_mask << reset_mask_shift))
+ wdt->wdd.bootstatus = WDIOF_CARDRESET;
+
+ /* clear wdt reset event flag */
+ if (of_device_is_compatible(pdev->dev.of_node, "aspeed,ast2400-wdt") ||
+ of_device_is_compatible(pdev->dev.of_node, "aspeed,ast2500-wdt")) {
+ ret = regmap_read(scu_base, scu.reset_status_reg, &status);
+ if (!ret) {
+ status &= ~(scu.wdt_reset_mask << reset_mask_shift);
+ regmap_write(scu_base, scu.reset_status_reg, status);
+ }
+ } else {
+ regmap_write(scu_base, scu.reset_status_reg,
+ scu.wdt_reset_mask << reset_mask_shift);
+ }
+}
+
/* access_cs0 shows if cs0 is accessible, hence the reverted bit */
static ssize_t access_cs0_show(struct device *dev,
struct device_attribute *attr, char *buf)
@@ -458,10 +535,10 @@ static int aspeed_wdt_probe(struct platform_device *pdev)
writel(duration - 1, wdt->base + WDT_RESET_WIDTH);
}
+ aspeed_wdt_update_bootstatus(pdev, wdt);
+
status = readl(wdt->base + WDT_TIMEOUT_STATUS);
if (status & WDT_TIMEOUT_STATUS_BOOT_SECONDARY) {
- wdt->wdd.bootstatus = WDIOF_CARDRESET;
-
if (of_device_is_compatible(np, "aspeed,ast2400-wdt") ||
of_device_is_compatible(np, "aspeed,ast2500-wdt"))
wdt->wdd.groups = bswitch_groups;
diff --git a/drivers/watchdog/at91sam9_wdt.c b/drivers/watchdog/at91sam9_wdt.c
index 7be70b98d091..1b47a2fc7d17 100644
--- a/drivers/watchdog/at91sam9_wdt.c
+++ b/drivers/watchdog/at91sam9_wdt.c
@@ -242,7 +242,7 @@ static int at91_wdt_init(struct platform_device *pdev, struct at91wdt *wdt)
return 0;
out_stop_timer:
- del_timer(&wdt->timer);
+ timer_delete(&wdt->timer);
return err;
}
@@ -378,7 +378,7 @@ static void at91wdt_remove(struct platform_device *pdev)
watchdog_unregister_device(&wdt->wdd);
pr_warn("I quit now, hardware will probably reboot!\n");
- del_timer(&wdt->timer);
+ timer_delete(&wdt->timer);
}
#if defined(CONFIG_OF)
diff --git a/drivers/watchdog/bcm47xx_wdt.c b/drivers/watchdog/bcm47xx_wdt.c
index 06a54c7de40b..4c0951307421 100644
--- a/drivers/watchdog/bcm47xx_wdt.c
+++ b/drivers/watchdog/bcm47xx_wdt.c
@@ -139,7 +139,7 @@ static int bcm47xx_wdt_soft_stop(struct watchdog_device *wdd)
{
struct bcm47xx_wdt *wdt = bcm47xx_wdt_get(wdd);
- del_timer_sync(&wdt->soft_timer);
+ timer_delete_sync(&wdt->soft_timer);
wdt->timer_set(wdt, 0);
return 0;
@@ -213,7 +213,7 @@ static int bcm47xx_wdt_probe(struct platform_device *pdev)
err_timer:
if (soft)
- del_timer_sync(&wdt->soft_timer);
+ timer_delete_sync(&wdt->soft_timer);
return ret;
}
diff --git a/drivers/watchdog/cpwd.c b/drivers/watchdog/cpwd.c
index 4fb92c9e046a..13a4d47e68cd 100644
--- a/drivers/watchdog/cpwd.c
+++ b/drivers/watchdog/cpwd.c
@@ -240,7 +240,7 @@ static void cpwd_brokentimer(struct timer_list *unused)
* were called directly instead of by kernel timer
*/
if (timer_pending(&cpwd_timer))
- del_timer(&cpwd_timer);
+ timer_delete(&cpwd_timer);
for (id = 0; id < WD_NUMDEVS; id++) {
if (p->devs[id].runstatus & WD_STAT_BSTOP) {
@@ -629,7 +629,7 @@ static void cpwd_remove(struct platform_device *op)
}
if (p->broken)
- del_timer_sync(&cpwd_timer);
+ timer_delete_sync(&cpwd_timer);
if (p->initialized)
free_irq(p->irq, p);
diff --git a/drivers/watchdog/cros_ec_wdt.c b/drivers/watchdog/cros_ec_wdt.c
index ba045e29f9a5..716c23f4388c 100644
--- a/drivers/watchdog/cros_ec_wdt.c
+++ b/drivers/watchdog/cros_ec_wdt.c
@@ -58,7 +58,7 @@ static int cros_ec_wdt_ping(struct watchdog_device *wdd)
arg.req.command = EC_HANG_DETECT_CMD_RELOAD;
ret = cros_ec_wdt_send_cmd(cros_ec, &arg);
if (ret < 0)
- dev_dbg(wdd->parent, "Failed to ping watchdog (%d)", ret);
+ dev_dbg(wdd->parent, "Failed to ping watchdog (%d)\n", ret);
return ret;
}
@@ -74,7 +74,7 @@ static int cros_ec_wdt_start(struct watchdog_device *wdd)
arg.req.reboot_timeout_sec = wdd->timeout;
ret = cros_ec_wdt_send_cmd(cros_ec, &arg);
if (ret < 0)
- dev_dbg(wdd->parent, "Failed to start watchdog (%d)", ret);
+ dev_dbg(wdd->parent, "Failed to start watchdog (%d)\n", ret);
return ret;
}
@@ -88,7 +88,7 @@ static int cros_ec_wdt_stop(struct watchdog_device *wdd)
arg.req.command = EC_HANG_DETECT_CMD_CANCEL;
ret = cros_ec_wdt_send_cmd(cros_ec, &arg);
if (ret < 0)
- dev_dbg(wdd->parent, "Failed to stop watchdog (%d)", ret);
+ dev_dbg(wdd->parent, "Failed to stop watchdog (%d)\n", ret);
return ret;
}
@@ -136,7 +136,7 @@ static int cros_ec_wdt_probe(struct platform_device *pdev)
arg.req.command = EC_HANG_DETECT_CMD_GET_STATUS;
ret = cros_ec_wdt_send_cmd(cros_ec, &arg);
if (ret < 0)
- return dev_err_probe(dev, ret, "Failed to get watchdog bootstatus");
+ return dev_err_probe(dev, ret, "Failed to get watchdog bootstatus\n");
wdd->parent = &pdev->dev;
wdd->info = &cros_ec_wdt_ident;
@@ -150,7 +150,7 @@ static int cros_ec_wdt_probe(struct platform_device *pdev)
arg.req.command = EC_HANG_DETECT_CMD_CLEAR_STATUS;
ret = cros_ec_wdt_send_cmd(cros_ec, &arg);
if (ret < 0)
- return dev_err_probe(dev, ret, "Failed to clear watchdog bootstatus");
+ return dev_err_probe(dev, ret, "Failed to clear watchdog bootstatus\n");
watchdog_stop_on_reboot(wdd);
watchdog_stop_on_unregister(wdd);
diff --git a/drivers/watchdog/lenovo_se30_wdt.c b/drivers/watchdog/lenovo_se30_wdt.c
new file mode 100644
index 000000000000..024b842499b3
--- /dev/null
+++ b/drivers/watchdog/lenovo_se30_wdt.c
@@ -0,0 +1,394 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * WDT driver for Lenovo SE30 device
+ */
+
+#define dev_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include <linux/io.h>
+#include <linux/dmi.h>
+#include <linux/delay.h>
+#include <linux/iommu.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/platform_device.h>
+#include <linux/watchdog.h>
+
+#define IOREGION_OFFSET 4 /* Use EC port 1 */
+#define IOREGION_LENGTH 4
+
+#define WATCHDOG_TIMEOUT 60
+
+#define MIN_TIMEOUT 1
+#define MAX_TIMEOUT 255
+#define MAX_WAIT 10
+
+static int timeout; /* in seconds */
+module_param(timeout, int, 0);
+MODULE_PARM_DESC(timeout,
+ "Watchdog timeout in seconds. 1 <= timeout <= 255, default="
+ __MODULE_STRING(WATCHDOG_TIMEOUT) ".");
+
+static bool nowayout = WATCHDOG_NOWAYOUT;
+module_param(nowayout, bool, 0);
+MODULE_PARM_DESC(nowayout,
+ "Watchdog cannot be stopped once started (default="
+ __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
+
+#define LNV_SE30_NAME "lenovo-se30-wdt"
+#define LNV_SE30_ID 0x0110
+#define CHIPID_MASK 0xFFF0
+
+#define CHIPID_REG 0x20
+#define SIO_REG 0x2e
+#define LDN_REG 0x07
+#define UNLOCK_KEY 0x87
+#define LOCK_KEY 0xAA
+#define LD_NUM_SHM 0x0F
+#define LD_BASE_ADDR 0xF8
+
+#define WDT_MODULE 0x10
+#define WDT_CFG_INDEX 0x15 /* WD configuration register */
+#define WDT_CNT_INDEX 0x16 /* WD timer count register */
+#define WDT_CFG_RESET 0x2
+
+/* Host Interface WIN2 offset definition */
+#define SHM_WIN_SIZE 0xFF
+#define SHM_WIN_MOD_OFFSET 0x01
+#define SHM_WIN_CMD_OFFSET 0x02
+#define SHM_WIN_SEL_OFFSET 0x03
+#define SHM_WIN_CTL_OFFSET 0x04
+#define VAL_SHM_WIN_CTRL_WR 0x40
+#define VAL_SHM_WIN_CTRL_RD 0x80
+#define SHM_WIN_ID_OFFSET 0x08
+#define SHM_WIN_DAT_OFFSET 0x10
+
+struct nct6692_reg {
+ unsigned char mod;
+ unsigned char cmd;
+ unsigned char sel;
+ unsigned int idx;
+};
+
+/* Watchdog is based on NCT6692 device */
+struct lenovo_se30_wdt {
+ unsigned char __iomem *shm_base_addr;
+ struct nct6692_reg wdt_cfg;
+ struct nct6692_reg wdt_cnt;
+ struct watchdog_device wdt;
+};
+
+static inline void superio_outb(int ioreg, int reg, int val)
+{
+ outb(reg, ioreg);
+ outb(val, ioreg + 1);
+}
+
+static inline int superio_inb(int ioreg, int reg)
+{
+ outb(reg, ioreg);
+ return inb(ioreg + 1);
+}
+
+static inline int superio_enter(int key, int addr, const char *name)
+{
+ if (!request_muxed_region(addr, 2, name)) {
+ pr_err("I/O address 0x%04x already in use\n", addr);
+ return -EBUSY;
+ }
+ outb(key, addr); /* Enter extended function mode */
+ outb(key, addr); /* Again according to manual */
+
+ return 0;
+}
+
+static inline void superio_exit(int key, int addr)
+{
+ outb(key, addr); /* Leave extended function mode */
+ release_region(addr, 2);
+}
+
+static int shm_get_ready(unsigned char __iomem *shm_base_addr,
+ const struct nct6692_reg *reg)
+{
+ unsigned char pre_id, new_id;
+ int loop = 0;
+
+ iowrite8(reg->mod, shm_base_addr + SHM_WIN_MOD_OFFSET);
+ iowrite8(reg->cmd, shm_base_addr + SHM_WIN_CMD_OFFSET);
+ iowrite8(reg->sel, shm_base_addr + SHM_WIN_SEL_OFFSET);
+
+ pre_id = ioread8(shm_base_addr + SHM_WIN_ID_OFFSET);
+ iowrite8(VAL_SHM_WIN_CTRL_RD, shm_base_addr + SHM_WIN_CTL_OFFSET);
+
+ /* Loop checking when interface is ready */
+ while (loop < MAX_WAIT) {
+ new_id = ioread8(shm_base_addr + SHM_WIN_ID_OFFSET);
+ if (new_id != pre_id)
+ return 0;
+ loop++;
+ usleep_range(10, 125);
+ }
+ return -ETIMEDOUT;
+}
+
+static int read_shm_win(unsigned char __iomem *shm_base_addr,
+ const struct nct6692_reg *reg,
+ unsigned char idx_offset,
+ unsigned char *data)
+{
+ int err = shm_get_ready(shm_base_addr, reg);
+
+ if (err)
+ return err;
+ *data = ioread8(shm_base_addr + SHM_WIN_DAT_OFFSET + reg->idx + idx_offset);
+ return 0;
+}
+
+static int write_shm_win(unsigned char __iomem *shm_base_addr,
+ const struct nct6692_reg *reg,
+ unsigned char idx_offset,
+ unsigned char val)
+{
+ int err = shm_get_ready(shm_base_addr, reg);
+
+ if (err)
+ return err;
+ iowrite8(val, shm_base_addr + SHM_WIN_DAT_OFFSET + reg->idx + idx_offset);
+ iowrite8(VAL_SHM_WIN_CTRL_WR, shm_base_addr + SHM_WIN_CTL_OFFSET);
+ err = shm_get_ready(shm_base_addr, reg);
+ return err;
+}
+
+static int lenovo_se30_wdt_enable(struct lenovo_se30_wdt *data, unsigned int timeout)
+{
+ if (timeout) {
+ int err = write_shm_win(data->shm_base_addr, &data->wdt_cfg, 0, WDT_CFG_RESET);
+
+ if (err)
+ return err;
+ }
+ return write_shm_win(data->shm_base_addr, &data->wdt_cnt, 0, timeout);
+}
+
+static int lenovo_se30_wdt_start(struct watchdog_device *wdog)
+{
+ struct lenovo_se30_wdt *data = watchdog_get_drvdata(wdog);
+
+ return lenovo_se30_wdt_enable(data, wdog->timeout);
+}
+
+static int lenovo_se30_wdt_stop(struct watchdog_device *wdog)
+{
+ struct lenovo_se30_wdt *data = watchdog_get_drvdata(wdog);
+
+ return lenovo_se30_wdt_enable(data, 0);
+}
+
+static unsigned int lenovo_se30_wdt_get_timeleft(struct watchdog_device *wdog)
+{
+ struct lenovo_se30_wdt *data = watchdog_get_drvdata(wdog);
+ unsigned char timeleft;
+ int err;
+
+ err = read_shm_win(data->shm_base_addr, &data->wdt_cnt, 0, &timeleft);
+ if (err)
+ return 0;
+ return timeleft;
+}
+
+static int lenovo_se30_wdt_ping(struct watchdog_device *wdt)
+{
+ struct lenovo_se30_wdt *data = watchdog_get_drvdata(wdt);
+ int err = 0;
+
+ /*
+ * Device does not support refreshing WDT_TIMER_REG register when
+ * the watchdog is active. Need to disable, feed and enable again
+ */
+ err = lenovo_se30_wdt_enable(data, 0);
+ if (err)
+ return err;
+
+ err = write_shm_win(data->shm_base_addr, &data->wdt_cnt, 0, wdt->timeout);
+ if (!err)
+ err = lenovo_se30_wdt_enable(data, wdt->timeout);
+
+ return err;
+}
+
+static const struct watchdog_info lenovo_se30_wdt_info = {
+ .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING |
+ WDIOF_MAGICCLOSE,
+ .identity = "Lenovo SE30 watchdog",
+};
+
+static const struct watchdog_ops lenovo_se30_wdt_ops = {
+ .owner = THIS_MODULE,
+ .start = lenovo_se30_wdt_start,
+ .stop = lenovo_se30_wdt_stop,
+ .ping = lenovo_se30_wdt_ping,
+ .get_timeleft = lenovo_se30_wdt_get_timeleft,
+};
+
+static int lenovo_se30_wdt_probe(struct platform_device *pdev)
+{
+ struct device *dev = &pdev->dev;
+ struct lenovo_se30_wdt *priv;
+ unsigned long base_phys;
+ unsigned short val;
+ int err;
+
+ err = superio_enter(UNLOCK_KEY, SIO_REG, LNV_SE30_NAME);
+ if (err)
+ return err;
+
+ val = superio_inb(SIO_REG, CHIPID_REG) << 8;
+ val |= superio_inb(SIO_REG, CHIPID_REG + 1);
+
+ if ((val & CHIPID_MASK) != LNV_SE30_ID) {
+ superio_exit(LOCK_KEY, SIO_REG);
+ return -ENODEV;
+ }
+
+ superio_outb(SIO_REG, LDN_REG, LD_NUM_SHM);
+ base_phys = (superio_inb(SIO_REG, LD_BASE_ADDR) |
+ (superio_inb(SIO_REG, LD_BASE_ADDR + 1) << 8) |
+ (superio_inb(SIO_REG, LD_BASE_ADDR + 2) << 16) |
+ (superio_inb(SIO_REG, LD_BASE_ADDR + 3) << 24)) &
+ 0xFFFFFFFF;
+
+ superio_exit(LOCK_KEY, SIO_REG);
+ if (base_phys == 0xFFFFFFFF || base_phys == 0)
+ return -ENODEV;
+
+ priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
+ if (!priv)
+ return -ENOMEM;
+
+ if (!devm_request_mem_region(dev, base_phys, SHM_WIN_SIZE, LNV_SE30_NAME))
+ return -EBUSY;
+
+ priv->shm_base_addr = devm_ioremap(dev, base_phys, SHM_WIN_SIZE);
+
+ priv->wdt_cfg.mod = WDT_MODULE;
+ priv->wdt_cfg.idx = WDT_CFG_INDEX;
+ priv->wdt_cnt.mod = WDT_MODULE;
+ priv->wdt_cnt.idx = WDT_CNT_INDEX;
+
+ priv->wdt.ops = &lenovo_se30_wdt_ops;
+ priv->wdt.info = &lenovo_se30_wdt_info;
+ priv->wdt.timeout = WATCHDOG_TIMEOUT; /* Set default timeout */
+ priv->wdt.min_timeout = MIN_TIMEOUT;
+ priv->wdt.max_timeout = MAX_TIMEOUT;
+ priv->wdt.parent = dev;
+
+ watchdog_init_timeout(&priv->wdt, timeout, dev);
+ watchdog_set_drvdata(&priv->wdt, priv);
+ watchdog_set_nowayout(&priv->wdt, nowayout);
+ watchdog_stop_on_reboot(&priv->wdt);
+ watchdog_stop_on_unregister(&priv->wdt);
+
+ return devm_watchdog_register_device(dev, &priv->wdt);
+}
+
+static struct platform_device *pdev;
+
+static struct platform_driver lenovo_se30_wdt_driver = {
+ .driver = {
+ .name = LNV_SE30_NAME,
+ },
+ .probe = lenovo_se30_wdt_probe,
+};
+
+static int lenovo_se30_create_platform_device(const struct dmi_system_id *id)
+{
+ int err;
+
+ pdev = platform_device_alloc(LNV_SE30_NAME, -1);
+ if (!pdev)
+ return -ENOMEM;
+
+ err = platform_device_add(pdev);
+ if (err)
+ platform_device_put(pdev);
+
+ return err;
+}
+
+static const struct dmi_system_id lenovo_se30_wdt_dmi_table[] __initconst = {
+ {
+ .ident = "LENOVO-SE30",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
+ DMI_MATCH(DMI_PRODUCT_NAME, "11NA"),
+ },
+ .callback = lenovo_se30_create_platform_device,
+ },
+ {
+ .ident = "LENOVO-SE30",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
+ DMI_MATCH(DMI_PRODUCT_NAME, "11NB"),
+ },
+ .callback = lenovo_se30_create_platform_device,
+ },
+ {
+ .ident = "LENOVO-SE30",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
+ DMI_MATCH(DMI_PRODUCT_NAME, "11NC"),
+ },
+ .callback = lenovo_se30_create_platform_device,
+ },
+ {
+ .ident = "LENOVO-SE30",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
+ DMI_MATCH(DMI_PRODUCT_NAME, "11NH"),
+ },
+ .callback = lenovo_se30_create_platform_device,
+ },
+ {
+ .ident = "LENOVO-SE30",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
+ DMI_MATCH(DMI_PRODUCT_NAME, "11NJ"),
+ },
+ .callback = lenovo_se30_create_platform_device,
+ },
+ {
+ .ident = "LENOVO-SE30",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
+ DMI_MATCH(DMI_PRODUCT_NAME, "11NK"),
+ },
+ .callback = lenovo_se30_create_platform_device,
+ },
+ {}
+};
+MODULE_DEVICE_TABLE(dmi, lenovo_se30_wdt_dmi_table);
+
+static int __init lenovo_se30_wdt_init(void)
+{
+ if (!dmi_check_system(lenovo_se30_wdt_dmi_table))
+ return -ENODEV;
+
+ return platform_driver_register(&lenovo_se30_wdt_driver);
+}
+
+static void __exit lenovo_se30_wdt_exit(void)
+{
+ if (pdev)
+ platform_device_unregister(pdev);
+ platform_driver_unregister(&lenovo_se30_wdt_driver);
+}
+
+module_init(lenovo_se30_wdt_init);
+module_exit(lenovo_se30_wdt_exit);
+
+MODULE_AUTHOR("Mark Pearson <mpearson-lenovo@squebb.ca>");
+MODULE_AUTHOR("David Ober <dober@lenovo.com>");
+MODULE_DESCRIPTION("Lenovo SE30 watchdog driver");
+MODULE_LICENSE("GPL");
diff --git a/drivers/watchdog/lpc18xx_wdt.c b/drivers/watchdog/lpc18xx_wdt.c
index f19580e1b318..28e3fc0df4c6 100644
--- a/drivers/watchdog/lpc18xx_wdt.c
+++ b/drivers/watchdog/lpc18xx_wdt.c
@@ -135,7 +135,7 @@ static int lpc18xx_wdt_start(struct watchdog_device *wdt_dev)
unsigned int val;
if (timer_pending(&lpc18xx_wdt->timer))
- del_timer(&lpc18xx_wdt->timer);
+ timer_delete(&lpc18xx_wdt->timer);
val = readl(lpc18xx_wdt->base + LPC18XX_WDT_MOD);
val |= LPC18XX_WDT_MOD_WDEN;
@@ -266,7 +266,7 @@ static void lpc18xx_wdt_remove(struct platform_device *pdev)
struct lpc18xx_wdt_dev *lpc18xx_wdt = platform_get_drvdata(pdev);
dev_warn(&pdev->dev, "I quit now, hardware will probably reboot!\n");
- del_timer_sync(&lpc18xx_wdt->timer);
+ timer_delete_sync(&lpc18xx_wdt->timer);
}
static const struct of_device_id lpc18xx_wdt_match[] = {
diff --git a/drivers/watchdog/machzwd.c b/drivers/watchdog/machzwd.c
index 73d641486909..0ae8e5bc10ae 100644
--- a/drivers/watchdog/machzwd.c
+++ b/drivers/watchdog/machzwd.c
@@ -189,7 +189,7 @@ static void zf_timer_off(void)
unsigned long flags;
/* stop internal ping */
- del_timer_sync(&zf_timer);
+ timer_delete_sync(&zf_timer);
spin_lock_irqsave(&zf_port_lock, flags);
/* stop watchdog timer */
@@ -337,7 +337,7 @@ static int zf_close(struct inode *inode, struct file *file)
if (zf_expect_close == 42)
zf_timer_off();
else {
- del_timer(&zf_timer);
+ timer_delete(&zf_timer);
pr_err("device file closed unexpectedly. Will not stop the WDT!\n");
}
clear_bit(0, &zf_is_open);
diff --git a/drivers/watchdog/mixcomwd.c b/drivers/watchdog/mixcomwd.c
index 70d9cf84c342..1ecd5c48a005 100644
--- a/drivers/watchdog/mixcomwd.c
+++ b/drivers/watchdog/mixcomwd.c
@@ -141,7 +141,7 @@ static int mixcomwd_open(struct inode *inode, struct file *file)
__module_get(THIS_MODULE);
else {
if (mixcomwd_timer_alive) {
- del_timer(&mixcomwd_timer);
+ timer_delete(&mixcomwd_timer);
mixcomwd_timer_alive = 0;
}
}
@@ -295,7 +295,7 @@ static void __exit mixcomwd_exit(void)
if (!nowayout) {
if (mixcomwd_timer_alive) {
pr_warn("I quit now, hardware will probably reboot!\n");
- del_timer_sync(&mixcomwd_timer);
+ timer_delete_sync(&mixcomwd_timer);
mixcomwd_timer_alive = 0;
}
}
diff --git a/drivers/watchdog/nic7018_wdt.c b/drivers/watchdog/nic7018_wdt.c
index 44982b37ba6f..44b5298f599a 100644
--- a/drivers/watchdog/nic7018_wdt.c
+++ b/drivers/watchdog/nic7018_wdt.c
@@ -3,12 +3,13 @@
* Copyright (C) 2016 National Instruments Corp.
*/
-#include <linux/acpi.h>
#include <linux/bitops.h>
#include <linux/device.h>
#include <linux/io.h>
+#include <linux/mod_devicetable.h>
#include <linux/module.h>
#include <linux/platform_device.h>
+#include <linux/types.h>
#include <linux/watchdog.h>
#define LOCK 0xA5
@@ -229,8 +230,8 @@ static void nic7018_remove(struct platform_device *pdev)
}
static const struct acpi_device_id nic7018_device_ids[] = {
- {"NIC7018", 0},
- {"", 0},
+ { "NIC7018" },
+ { }
};
MODULE_DEVICE_TABLE(acpi, nic7018_device_ids);
@@ -239,7 +240,7 @@ static struct platform_driver watchdog_driver = {
.remove = nic7018_remove,
.driver = {
.name = KBUILD_MODNAME,
- .acpi_match_table = ACPI_PTR(nic7018_device_ids),
+ .acpi_match_table = nic7018_device_ids,
},
};
diff --git a/drivers/watchdog/npcm_wdt.c b/drivers/watchdog/npcm_wdt.c
index a5dd1c230137..e62ea054bc61 100644
--- a/drivers/watchdog/npcm_wdt.c
+++ b/drivers/watchdog/npcm_wdt.c
@@ -68,8 +68,7 @@ static int npcm_wdt_start(struct watchdog_device *wdd)
struct npcm_wdt *wdt = to_npcm_wdt(wdd);
u32 val;
- if (wdt->clk)
- clk_prepare_enable(wdt->clk);
+ clk_prepare_enable(wdt->clk);
if (wdd->timeout < 2)
val = 0x800;
@@ -105,8 +104,7 @@ static int npcm_wdt_stop(struct watchdog_device *wdd)
writel(0, wdt->reg);
- if (wdt->clk)
- clk_disable_unprepare(wdt->clk);
+ clk_disable_unprepare(wdt->clk);
return 0;
}
@@ -156,8 +154,7 @@ static int npcm_wdt_restart(struct watchdog_device *wdd,
struct npcm_wdt *wdt = to_npcm_wdt(wdd);
/* For reset, we start the WDT clock and leave it running. */
- if (wdt->clk)
- clk_prepare_enable(wdt->clk);
+ clk_prepare_enable(wdt->clk);
writel(NPCM_WTR | NPCM_WTRE | NPCM_WTE, wdt->reg);
udelay(1000);
diff --git a/drivers/watchdog/pcwd.c b/drivers/watchdog/pcwd.c
index 31d3dcbf815e..d4ea7d6ccd6a 100644
--- a/drivers/watchdog/pcwd.c
+++ b/drivers/watchdog/pcwd.c
@@ -432,7 +432,7 @@ static int pcwd_stop(void)
int stat_reg;
/* Stop the timer */
- del_timer(&pcwd_private.timer);
+ timer_delete(&pcwd_private.timer);
/* Disable the board */
if (pcwd_private.revision == PCWD_REVISION_C) {
diff --git a/drivers/watchdog/pika_wdt.c b/drivers/watchdog/pika_wdt.c
index 393aa4b1bc13..87b8988d2520 100644
--- a/drivers/watchdog/pika_wdt.c
+++ b/drivers/watchdog/pika_wdt.c
@@ -129,7 +129,7 @@ static int pikawdt_release(struct inode *inode, struct file *file)
{
/* stop internal ping */
if (!pikawdt_private.expect_close)
- del_timer(&pikawdt_private.timer);
+ timer_delete(&pikawdt_private.timer);
clear_bit(0, &pikawdt_private.open);
pikawdt_private.expect_close = 0;
diff --git a/drivers/watchdog/s3c2410_wdt.c b/drivers/watchdog/s3c2410_wdt.c
index 30450e99e5e9..bdd81d8074b2 100644
--- a/drivers/watchdog/s3c2410_wdt.c
+++ b/drivers/watchdog/s3c2410_wdt.c
@@ -72,6 +72,8 @@
#define EXYNOS850_CLUSTER1_WDTRESET_BIT 23
#define EXYNOSAUTOV9_CLUSTER0_WDTRESET_BIT 25
#define EXYNOSAUTOV9_CLUSTER1_WDTRESET_BIT 24
+#define EXYNOSAUTOV920_CLUSTER0_WDTRESET_BIT 0
+#define EXYNOSAUTOV920_CLUSTER1_WDTRESET_BIT 1
#define GS_CLUSTER0_NONCPU_OUT 0x1220
#define GS_CLUSTER1_NONCPU_OUT 0x1420
@@ -312,9 +314,9 @@ static const struct s3c2410_wdt_variant drv_data_exynosautov920_cl0 = {
.mask_bit = 2,
.mask_reset_inv = true,
.rst_stat_reg = EXYNOS5_RST_STAT_REG_OFFSET,
- .rst_stat_bit = EXYNOSAUTOV9_CLUSTER0_WDTRESET_BIT,
+ .rst_stat_bit = EXYNOSAUTOV920_CLUSTER0_WDTRESET_BIT,
.cnt_en_reg = EXYNOSAUTOV920_CLUSTER0_NONCPU_OUT,
- .cnt_en_bit = 7,
+ .cnt_en_bit = 8,
.quirks = QUIRK_HAS_WTCLRINT_REG | QUIRK_HAS_PMU_MASK_RESET |
QUIRK_HAS_PMU_RST_STAT | QUIRK_HAS_PMU_CNT_EN |
QUIRK_HAS_DBGACK_BIT,
@@ -325,9 +327,9 @@ static const struct s3c2410_wdt_variant drv_data_exynosautov920_cl1 = {
.mask_bit = 2,
.mask_reset_inv = true,
.rst_stat_reg = EXYNOS5_RST_STAT_REG_OFFSET,
- .rst_stat_bit = EXYNOSAUTOV9_CLUSTER1_WDTRESET_BIT,
+ .rst_stat_bit = EXYNOSAUTOV920_CLUSTER1_WDTRESET_BIT,
.cnt_en_reg = EXYNOSAUTOV920_CLUSTER1_NONCPU_OUT,
- .cnt_en_bit = 7,
+ .cnt_en_bit = 8,
.quirks = QUIRK_HAS_WTCLRINT_REG | QUIRK_HAS_PMU_MASK_RESET |
QUIRK_HAS_PMU_RST_STAT | QUIRK_HAS_PMU_CNT_EN |
QUIRK_HAS_DBGACK_BIT,
diff --git a/drivers/watchdog/sbc60xxwdt.c b/drivers/watchdog/sbc60xxwdt.c
index e9bf12918ed8..03eaf48c8f0f 100644
--- a/drivers/watchdog/sbc60xxwdt.c
+++ b/drivers/watchdog/sbc60xxwdt.c
@@ -146,7 +146,7 @@ static void wdt_startup(void)
static void wdt_turnoff(void)
{
/* Stop the timer */
- del_timer_sync(&timer);
+ timer_delete_sync(&timer);
inb_p(wdt_stop);
pr_info("Watchdog timer is now disabled...\n");
}
@@ -210,7 +210,7 @@ static int fop_close(struct inode *inode, struct file *file)
if (wdt_expect_close == 42)
wdt_turnoff();
else {
- del_timer(&timer);
+ timer_delete(&timer);
pr_crit("device file closed unexpectedly. Will not stop the WDT!\n");
}
clear_bit(0, &wdt_is_open);
diff --git a/drivers/watchdog/sc520_wdt.c b/drivers/watchdog/sc520_wdt.c
index e849e1af267b..005f62e4a4fb 100644
--- a/drivers/watchdog/sc520_wdt.c
+++ b/drivers/watchdog/sc520_wdt.c
@@ -186,7 +186,7 @@ static int wdt_startup(void)
static int wdt_turnoff(void)
{
/* Stop the timer */
- del_timer_sync(&timer);
+ timer_delete_sync(&timer);
/* Stop the watchdog */
wdt_config(0);
diff --git a/drivers/watchdog/shwdt.c b/drivers/watchdog/shwdt.c
index 7f0150c39421..95af9ad94d16 100644
--- a/drivers/watchdog/shwdt.c
+++ b/drivers/watchdog/shwdt.c
@@ -129,7 +129,7 @@ static int sh_wdt_stop(struct watchdog_device *wdt_dev)
spin_lock_irqsave(&wdt->lock, flags);
- del_timer(&wdt->timer);
+ timer_delete(&wdt->timer);
csr = sh_wdt_read_csr();
csr &= ~WTCSR_TME;
diff --git a/drivers/watchdog/sunxi_wdt.c b/drivers/watchdog/sunxi_wdt.c
index b85354a99582..b6c761acc3de 100644
--- a/drivers/watchdog/sunxi_wdt.c
+++ b/drivers/watchdog/sunxi_wdt.c
@@ -236,10 +236,21 @@ static const struct sunxi_wdt_reg sun20i_wdt_reg = {
.wdt_key_val = 0x16aa0000,
};
+static const struct sunxi_wdt_reg sun55i_wdt_reg = {
+ .wdt_ctrl = 0x0c,
+ .wdt_cfg = 0x10,
+ .wdt_mode = 0x14,
+ .wdt_timeout_shift = 4,
+ .wdt_reset_mask = 0x03,
+ .wdt_reset_val = 0x01,
+ .wdt_key_val = 0x16aa0000,
+};
+
static const struct of_device_id sunxi_wdt_dt_ids[] = {
{ .compatible = "allwinner,sun4i-a10-wdt", .data = &sun4i_wdt_reg },
{ .compatible = "allwinner,sun6i-a31-wdt", .data = &sun6i_wdt_reg },
{ .compatible = "allwinner,sun20i-d1-wdt", .data = &sun20i_wdt_reg },
+ { .compatible = "allwinner,sun55i-a523-wdt", .data = &sun55i_wdt_reg },
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, sunxi_wdt_dt_ids);
diff --git a/drivers/watchdog/via_wdt.c b/drivers/watchdog/via_wdt.c
index eeb39f96e72e..d647923d68fe 100644
--- a/drivers/watchdog/via_wdt.c
+++ b/drivers/watchdog/via_wdt.c
@@ -233,7 +233,7 @@ err_out_disable_device:
static void wdt_remove(struct pci_dev *pdev)
{
watchdog_unregister_device(&wdt_dev);
- del_timer_sync(&timer);
+ timer_delete_sync(&timer);
iounmap(wdt_mem);
release_mem_region(mmio, VIA_WDT_MMIO_LEN);
release_resource(&wdt_res);
diff --git a/drivers/watchdog/w83877f_wdt.c b/drivers/watchdog/w83877f_wdt.c
index 1937084c182c..53db59ef774b 100644
--- a/drivers/watchdog/w83877f_wdt.c
+++ b/drivers/watchdog/w83877f_wdt.c
@@ -166,7 +166,7 @@ static void wdt_startup(void)
static void wdt_turnoff(void)
{
/* Stop the timer */
- del_timer_sync(&timer);
+ timer_delete_sync(&timer);
wdt_change(WDT_DISABLE);
@@ -228,7 +228,7 @@ static int fop_close(struct inode *inode, struct file *file)
if (wdt_expect_close == 42)
wdt_turnoff();
else {
- del_timer(&timer);
+ timer_delete(&timer);
pr_crit("device file closed unexpectedly. Will not stop the WDT!\n");
}
clear_bit(0, &wdt_is_open);
diff --git a/drivers/watchdog/watchdog_core.c b/drivers/watchdog/watchdog_core.c
index d46d8c8c01f2..6152dba4b52c 100644
--- a/drivers/watchdog/watchdog_core.c
+++ b/drivers/watchdog/watchdog_core.c
@@ -33,7 +33,8 @@
#include <linux/init.h> /* For __init/__exit/... */
#include <linux/idr.h> /* For ida_* macros */
#include <linux/err.h> /* For IS_ERR macros */
-#include <linux/of.h> /* For of_get_timeout_sec */
+#include <linux/of.h> /* For of_alias_get_id */
+#include <linux/property.h> /* For device_property_read_u32 */
#include <linux/suspend.h>
#include "watchdog_core.h" /* For watchdog_dev_register/... */
@@ -137,8 +138,7 @@ int watchdog_init_timeout(struct watchdog_device *wdd,
}
/* try to get the timeout_sec property */
- if (dev && dev->of_node &&
- of_property_read_u32(dev->of_node, "timeout-sec", &t) == 0) {
+ if (dev && device_property_read_u32(dev, "timeout-sec", &t) == 0) {
if (t && !watchdog_timeout_invalid(wdd, t)) {
wdd->timeout = t;
return 0;