]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
Merge remote-tracking branch 'watchdog/master'
authorStephen Rothwell <sfr@canb.auug.org.au>
Thu, 16 Jan 2014 02:57:21 +0000 (13:57 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Thu, 16 Jan 2014 02:57:21 +0000 (13:57 +1100)
24 files changed:
Documentation/devicetree/bindings/watchdog/davinci-wdt.txt
Documentation/devicetree/bindings/watchdog/gpio-wdt.txt [new file with mode: 0644]
Documentation/devicetree/bindings/watchdog/samsung-wdt.txt
arch/arm/configs/bcm_defconfig
drivers/watchdog/Kconfig
drivers/watchdog/Makefile
drivers/watchdog/alim1535_wdt.c
drivers/watchdog/alim7101_wdt.c
drivers/watchdog/bcm_kona_wdt.c [new file with mode: 0644]
drivers/watchdog/davinci_wdt.c
drivers/watchdog/dw_wdt.c
drivers/watchdog/gpio_wdt.c [new file with mode: 0644]
drivers/watchdog/hpwdt.c
drivers/watchdog/i6300esb.c
drivers/watchdog/imx2_wdt.c
drivers/watchdog/mpc8xxx_wdt.c
drivers/watchdog/nv_tco.c
drivers/watchdog/pcwd_pci.c
drivers/watchdog/s3c2410_wdt.c
drivers/watchdog/sirfsoc_wdt.c
drivers/watchdog/sp5100_tco.c
drivers/watchdog/via_wdt.c
drivers/watchdog/watchdog_core.c
drivers/watchdog/wdt_pci.c

index 75558ccd9a051e59af9233f279a660c27fa58f97..e60b9a13bdcbd5887078e110280dffe5e39ba5e5 100644 (file)
@@ -1,12 +1,24 @@
-DaVinci Watchdog Timer (WDT) Controller
+Texas Instruments DaVinci/Keystone Watchdog Timer (WDT) Controller
 
 Required properties:
-- compatible : Should be "ti,davinci-wdt"
+- compatible : Should be "ti,davinci-wdt", "ti,keystone-wdt"
 - reg : Should contain WDT registers location and length
 
+Optional properties:
+- timeout-sec : Contains the watchdog timeout in seconds
+- clocks : the clock feeding the watchdog timer.
+          Needed if platform uses clocks.
+          See clock-bindings.txt
+
+Documentation:
+Davinci DM646x - http://www.ti.com/lit/ug/spruer5b/spruer5b.pdf
+Keystone - http://www.ti.com/lit/ug/sprugv5a/sprugv5a.pdf
+
 Examples:
 
 wdt: wdt@2320000 {
        compatible = "ti,davinci-wdt";
        reg = <0x02320000 0x80>;
+       timeout-sec = <30>;
+       clocks = <&clkwdtimer0>;
 };
diff --git a/Documentation/devicetree/bindings/watchdog/gpio-wdt.txt b/Documentation/devicetree/bindings/watchdog/gpio-wdt.txt
new file mode 100644 (file)
index 0000000..37afec1
--- /dev/null
@@ -0,0 +1,23 @@
+* GPIO-controlled Watchdog
+
+Required Properties:
+- compatible: Should contain "linux,wdt-gpio".
+- gpios: From common gpio binding; gpio connection to WDT reset pin.
+- hw_algo: The algorithm used by the driver. Should be one of the
+  following values:
+  - toggle: Either a high-to-low or a low-to-high transition clears
+    the WDT counter. The watchdog timer is disabled when GPIO is
+    left floating or connected to a three-state buffer.
+  - level: Low or high level starts counting WDT timeout,
+    the opposite level disables the WDT. Active level is determined
+    by the GPIO flags.
+- hw_margin_ms: Maximum time to reset watchdog circuit (milliseconds).
+
+Example:
+       watchdog: watchdog {
+               /* ADM706 */
+               compatible = "linux,wdt-gpio";
+               gpios = <&gpio3 9 GPIO_ACTIVE_LOW>;
+               hw_algo = "toggle";
+               hw_margin_ms = <1600>;
+       };
index 2aa486cc1ff6a17ba8f1d95b75800a76941d2f5f..cfff37511aac0e3e1f3d42f6e9805c087a8bc286 100644 (file)
@@ -5,10 +5,29 @@ after a preset amount of time during which the WDT reset event has not
 occurred.
 
 Required properties:
-- compatible : should be "samsung,s3c2410-wdt"
+- compatible : should be one among the following
+       (a) "samsung,s3c2410-wdt" for Exynos4 and previous SoCs
+       (b) "samsung,exynos5250-wdt" for Exynos5250
+       (c) "samsung,exynos5420-wdt" for Exynos5420
+
 - reg : base physical address of the controller and length of memory mapped
        region.
 - interrupts : interrupt number to the cpu.
+- samsung,syscon-phandle : reference to syscon node (This property required only
+       in case of compatible being "samsung,exynos5250-wdt" or "samsung,exynos5420-wdt".
+       In case of Exynos5250 and 5420 this property points to syscon node holding the PMU
+       base address)
 
 Optional properties:
 - timeout-sec : contains the watchdog timeout in seconds.
+
+Example:
+
+watchdog@101D0000 {
+       compatible = "samsung,exynos5250-wdt";
+       reg = <0x101D0000 0x100>;
+       interrupts = <0 42 0>;
+       clocks = <&clock 336>;
+       clock-names = "watchdog";
+       samsung,syscon-phandle = <&pmu_syscon>;
+};
index 7a8564e0303ffb5f1ca4d471dcb78806d24cc502..176e842308a8986439c6c87d07582ec0062f1d4f 100644 (file)
@@ -125,3 +125,6 @@ CONFIG_CRC_ITU_T=y
 CONFIG_CRC7=y
 CONFIG_XZ_DEC=y
 CONFIG_AVERAGE=y
+CONFIG_WATCHDOG=y
+CONFIG_BCM_KONA_WDT=y
+CONFIG_BCM_KONA_WDT_DEBUG=y
index 5be6e919f7850d7d101542b55120163cec935162..8cb4f3dc8c948d451cda9fdd98716376964368ef 100644 (file)
@@ -87,6 +87,14 @@ config DA9055_WATCHDOG
          This driver can also be built as a module.  If so, the module
          will be called da9055_wdt.
 
+config GPIO_WATCHDOG
+       tristate "Watchdog device controlled through GPIO-line"
+       depends on OF_GPIO
+       select WATCHDOG_CORE
+       help
+         If you say yes here you get support for watchdog device
+         controlled through GPIO-line.
+
 config WM831X_WATCHDOG
        tristate "WM831x watchdog"
        depends on MFD_WM831X
@@ -188,6 +196,7 @@ config S3C2410_WATCHDOG
        tristate "S3C2410 Watchdog"
        depends on HAVE_S3C2410_WATCHDOG
        select WATCHDOG_CORE
+       select MFD_SYSCON if ARCH_EXYNOS5
        help
          Watchdog timer block in the Samsung SoCs. This will reboot
          the system when the timer expires with the watchdog enabled.
@@ -214,10 +223,9 @@ config SA1100_WATCHDOG
 
 config DW_WATCHDOG
        tristate "Synopsys DesignWare watchdog"
-       depends on ARM && HAVE_CLK
        help
          Say Y here if to include support for the Synopsys DesignWare
-         watchdog timer found in many ARM chips.
+         watchdog timer found in many chips.
          To compile this driver as a module, choose M here: the
          module will be called dw_wdt.
 
@@ -270,10 +278,11 @@ config IOP_WATCHDOG
 
 config DAVINCI_WATCHDOG
        tristate "DaVinci watchdog"
-       depends on ARCH_DAVINCI
+       depends on ARCH_DAVINCI || ARCH_KEYSTONE
+       select WATCHDOG_CORE
        help
          Say Y here if to include support for the watchdog timer
-         in the DaVinci DM644x/DM646x processors.
+         in the DaVinci DM644x/DM646x or Keystone processors.
          To compile this driver as a module, choose M here: the
          module will be called davinci_wdt.
 
@@ -1139,6 +1148,28 @@ config BCM2835_WDT
          To compile this driver as a loadable module, choose M here.
          The module will be called bcm2835_wdt.
 
+config BCM_KONA_WDT
+       tristate "BCM Kona Watchdog"
+       depends on ARCH_BCM
+       select WATCHDOG_CORE
+       help
+         Support for the watchdog timer on the following Broadcom BCM281xx
+         family, which includes BCM11130, BCM11140, BCM11351, BCM28145 and
+         BCM28155 variants.
+
+         Say 'Y' or 'M' here to enable the driver. The module will be called
+         bcm_kona_wdt.
+
+config BCM_KONA_WDT_DEBUG
+       bool "DEBUGFS support for BCM Kona Watchdog"
+       depends on BCM_KONA_WDT
+       help
+         If enabled, adds /sys/kernel/debug/bcm_kona_wdt/info which provides
+         access to the driver's internal data structures as well as watchdog
+         timer hardware registres.
+
+         If in doubt, say 'N'.
+
 config LANTIQ_WDT
        tristate "Lantiq SoC watchdog"
        depends on LANTIQ
@@ -1171,6 +1202,7 @@ config MPC5200_WDT
 config 8xxx_WDT
        tristate "MPC8xxx Platform Watchdog Timer"
        depends on PPC_8xx || PPC_83xx || PPC_86xx
+       select WATCHDOG_CORE
        help
          This driver is for a SoC level watchdog that exists on some
          Freescale PowerPC processors. So far this driver supports:
index 91bd95a64baf7bfe083e6f67ff803f2edc0ce2f9..985a66cda76f23ac89932672f1f813c9cab2dade 100644 (file)
@@ -57,6 +57,7 @@ obj-$(CONFIG_RETU_WATCHDOG) += retu_wdt.o
 obj-$(CONFIG_BCM2835_WDT) += bcm2835_wdt.o
 obj-$(CONFIG_MOXART_WDT) += moxart_wdt.o
 obj-$(CONFIG_SIRFSOC_WATCHDOG) += sirfsoc_wdt.o
+obj-$(CONFIG_BCM_KONA_WDT) += bcm_kona_wdt.o
 
 # AVR32 Architecture
 obj-$(CONFIG_AT32AP700X_WDT) += at32ap700x_wdt.o
@@ -171,6 +172,7 @@ obj-$(CONFIG_XEN_WDT) += xen_wdt.o
 # Architecture Independent
 obj-$(CONFIG_DA9052_WATCHDOG) += da9052_wdt.o
 obj-$(CONFIG_DA9055_WATCHDOG) += da9055_wdt.o
+obj-$(CONFIG_GPIO_WATCHDOG)    += gpio_wdt.o
 obj-$(CONFIG_WM831X_WATCHDOG) += wm831x_wdt.o
 obj-$(CONFIG_WM8350_WATCHDOG) += wm8350_wdt.o
 obj-$(CONFIG_MAX63XX_WATCHDOG) += max63xx_wdt.o
index fbb7b94cabfd5816e7532fe0093b579b831b63a8..3a17fbd39f8aed015f00ecafdbb5839a2e8296f4 100644 (file)
@@ -301,7 +301,7 @@ static int ali_notify_sys(struct notifier_block *this,
  *     want to register another driver on the same PCI id.
  */
 
-static DEFINE_PCI_DEVICE_TABLE(ali_pci_tbl) __used = {
+static const struct pci_device_id ali_pci_tbl[] __used = {
        { PCI_VENDOR_ID_AL, 0x1533, PCI_ANY_ID, PCI_ANY_ID,},
        { PCI_VENDOR_ID_AL, 0x1535, PCI_ANY_ID, PCI_ANY_ID,},
        { 0, },
index 12f0b762b528948b15e30fab605860a34c01ba57..996b2f7d330e94ec3143e6bebe0c86f74e162943 100644 (file)
@@ -414,7 +414,7 @@ err_out:
 module_init(alim7101_wdt_init);
 module_exit(alim7101_wdt_unload);
 
-static DEFINE_PCI_DEVICE_TABLE(alim7101_pci_tbl) __used = {
+static const struct pci_device_id alim7101_pci_tbl[] __used = {
        { PCI_DEVICE(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533) },
        { PCI_DEVICE(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M7101) },
        { }
diff --git a/drivers/watchdog/bcm_kona_wdt.c b/drivers/watchdog/bcm_kona_wdt.c
new file mode 100644 (file)
index 0000000..9c24809
--- /dev/null
@@ -0,0 +1,368 @@
+/*
+ * 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/delay.h>
+#include <linux/err.h>
+#include <linux/io.h>
+#include <linux/module.h>
+#include <linux/of_address.h>
+#include <linux/platform_device.h>
+#include <linux/watchdog.h>
+
+#define SECWDOG_CTRL_REG               0x00000000
+#define SECWDOG_COUNT_REG              0x00000004
+
+#define SECWDOG_RESERVED_MASK          0x1dffffff
+#define SECWDOG_WD_LOAD_FLAG           0x10000000
+#define SECWDOG_EN_MASK                        0x08000000
+#define SECWDOG_SRSTEN_MASK            0x04000000
+#define SECWDOG_RES_MASK               0x00f00000
+#define SECWDOG_COUNT_MASK             0x000fffff
+
+#define SECWDOG_MAX_COUNT              SECWDOG_COUNT_MASK
+#define SECWDOG_CLKS_SHIFT             20
+#define SECWDOG_MAX_RES                        15
+#define SECWDOG_DEFAULT_RESOLUTION     4
+#define SECWDOG_MAX_TRY                        1000
+
+#define SECS_TO_TICKS(x, w)            ((x) << (w)->resolution)
+#define TICKS_TO_SECS(x, w)            ((x) >> (w)->resolution)
+
+#define BCM_KONA_WDT_NAME              "bcm_kona_wdt"
+
+struct bcm_kona_wdt {
+       void __iomem *base;
+       /*
+        * One watchdog tick is 1/(2^resolution) seconds. Resolution can take
+        * the values 0-15, meaning one tick can be 1s to 30.52us. Our default
+        * resolution of 4 means one tick is 62.5ms.
+        *
+        * The watchdog counter is 20 bits. Depending on resolution, the maximum
+        * counter value of 0xfffff expires after about 12 days (resolution 0)
+        * down to only 32s (resolution 15). The default resolution of 4 gives
+        * us a maximum of about 18 hours and 12 minutes before the watchdog
+        * times out.
+        */
+       int resolution;
+       spinlock_t lock;
+#ifdef CONFIG_BCM_KONA_WDT_DEBUG
+       unsigned long busy_count;
+       struct dentry *debugfs;
+#endif
+};
+
+static int secure_register_read(struct bcm_kona_wdt *wdt, uint32_t offset)
+{
+       uint32_t val;
+       unsigned count = 0;
+
+       /*
+        * If the WD_LOAD_FLAG is set, the watchdog counter field is being
+        * updated in hardware. Once the WD timer is updated in hardware, it
+        * gets cleared.
+        */
+       do {
+               if (unlikely(count > 1))
+                       udelay(5);
+               val = readl_relaxed(wdt->base + offset);
+               count++;
+       } while ((val & SECWDOG_WD_LOAD_FLAG) && count < SECWDOG_MAX_TRY);
+
+#ifdef CONFIG_BCM_KONA_WDT_DEBUG
+       /* Remember the maximum number iterations due to WD_LOAD_FLAG */
+       if (count > wdt->busy_count)
+               wdt->busy_count = count;
+#endif
+
+       /* This is the only place we return a negative value. */
+       if (val & SECWDOG_WD_LOAD_FLAG)
+               return -ETIMEDOUT;
+
+       /* We always mask out reserved bits. */
+       val &= SECWDOG_RESERVED_MASK;
+
+       return val;
+}
+
+#ifdef CONFIG_BCM_KONA_WDT_DEBUG
+
+static int bcm_kona_wdt_dbg_show(struct seq_file *s, void *data)
+{
+       int ctl_val, cur_val, ret;
+       unsigned long flags;
+       struct bcm_kona_wdt *wdt = s->private;
+
+       if (!wdt)
+               return seq_puts(s, "No device pointer\n");
+
+       spin_lock_irqsave(&wdt->lock, flags);
+       ctl_val = secure_register_read(wdt, SECWDOG_CTRL_REG);
+       cur_val = secure_register_read(wdt, SECWDOG_COUNT_REG);
+       spin_unlock_irqrestore(&wdt->lock, flags);
+
+       if (ctl_val < 0 || cur_val < 0) {
+               ret = seq_puts(s, "Error accessing hardware\n");
+       } else {
+               int ctl, cur, ctl_sec, cur_sec, res;
+
+               ctl = ctl_val & SECWDOG_COUNT_MASK;
+               res = (ctl_val & SECWDOG_RES_MASK) >> SECWDOG_CLKS_SHIFT;
+               cur = cur_val & SECWDOG_COUNT_MASK;
+               ctl_sec = TICKS_TO_SECS(ctl, wdt);
+               cur_sec = TICKS_TO_SECS(cur, wdt);
+               ret = seq_printf(s, "Resolution: %d / %d\n"
+                               "Control: %d s / %d (%#x) ticks\n"
+                               "Current: %d s / %d (%#x) ticks\n"
+                               "Busy count: %lu\n", res,
+                               wdt->resolution, ctl_sec, ctl, ctl, cur_sec,
+                               cur, cur, wdt->busy_count);
+       }
+
+       return ret;
+}
+
+static int bcm_kona_dbg_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, bcm_kona_wdt_dbg_show, inode->i_private);
+}
+
+static const struct file_operations bcm_kona_dbg_operations = {
+       .open           = bcm_kona_dbg_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+};
+
+static void bcm_kona_wdt_debug_init(struct platform_device *pdev)
+{
+       struct dentry *dir;
+       struct bcm_kona_wdt *wdt = platform_get_drvdata(pdev);
+
+       if (!wdt)
+               return;
+
+       wdt->debugfs = NULL;
+
+       dir = debugfs_create_dir(BCM_KONA_WDT_NAME, NULL);
+       if (IS_ERR_OR_NULL(dir))
+               return;
+
+       if (debugfs_create_file("info", S_IFREG | S_IRUGO, dir, wdt,
+                               &bcm_kona_dbg_operations))
+               wdt->debugfs = dir;
+       else
+               debugfs_remove_recursive(dir);
+}
+
+static void bcm_kona_wdt_debug_exit(struct platform_device *pdev)
+{
+       struct bcm_kona_wdt *wdt = platform_get_drvdata(pdev);
+
+       if (wdt && wdt->debugfs) {
+               debugfs_remove_recursive(wdt->debugfs);
+               wdt->debugfs = NULL;
+       }
+}
+
+#else
+
+static void bcm_kona_wdt_debug_init(struct platform_device *pdev) {}
+static void bcm_kona_wdt_debug_exit(struct platform_device *pdev) {}
+
+#endif /* CONFIG_BCM_KONA_WDT_DEBUG */
+
+static int bcm_kona_wdt_ctrl_reg_modify(struct bcm_kona_wdt *wdt,
+                                       unsigned mask, unsigned newval)
+{
+       int val;
+       unsigned long flags;
+       int ret = 0;
+
+       spin_lock_irqsave(&wdt->lock, flags);
+
+       val = secure_register_read(wdt, SECWDOG_CTRL_REG);
+       if (val < 0) {
+               ret = val;
+       } else {
+               val &= ~mask;
+               val |= newval;
+               writel_relaxed(val, wdt->base + SECWDOG_CTRL_REG);
+       }
+
+       spin_unlock_irqrestore(&wdt->lock, flags);
+
+       return ret;
+}
+
+static int bcm_kona_wdt_set_resolution_reg(struct bcm_kona_wdt *wdt)
+{
+       if (wdt->resolution > SECWDOG_MAX_RES)
+               return -EINVAL;
+
+       return bcm_kona_wdt_ctrl_reg_modify(wdt, SECWDOG_RES_MASK,
+                                       wdt->resolution << SECWDOG_CLKS_SHIFT);
+}
+
+static int bcm_kona_wdt_set_timeout_reg(struct watchdog_device *wdog,
+                                       unsigned watchdog_flags)
+{
+       struct bcm_kona_wdt *wdt = watchdog_get_drvdata(wdog);
+
+       return bcm_kona_wdt_ctrl_reg_modify(wdt, SECWDOG_COUNT_MASK,
+                                       SECS_TO_TICKS(wdog->timeout, wdt) |
+                                       watchdog_flags);
+}
+
+static int bcm_kona_wdt_set_timeout(struct watchdog_device *wdog,
+       unsigned int t)
+{
+       wdog->timeout = t;
+       return 0;
+}
+
+static unsigned int bcm_kona_wdt_get_timeleft(struct watchdog_device *wdog)
+{
+       struct bcm_kona_wdt *wdt = watchdog_get_drvdata(wdog);
+       int val;
+       unsigned long flags;
+
+       spin_lock_irqsave(&wdt->lock, flags);
+       val = secure_register_read(wdt, SECWDOG_COUNT_REG);
+       spin_unlock_irqrestore(&wdt->lock, flags);
+
+       if (val < 0)
+               return val;
+
+       return TICKS_TO_SECS(val & SECWDOG_COUNT_MASK, wdt);
+}
+
+static int bcm_kona_wdt_start(struct watchdog_device *wdog)
+{
+       return bcm_kona_wdt_set_timeout_reg(wdog,
+                                       SECWDOG_EN_MASK | SECWDOG_SRSTEN_MASK);
+}
+
+static int bcm_kona_wdt_stop(struct watchdog_device *wdog)
+{
+       struct bcm_kona_wdt *wdt = watchdog_get_drvdata(wdog);
+
+       return bcm_kona_wdt_ctrl_reg_modify(wdt, SECWDOG_EN_MASK |
+                                           SECWDOG_SRSTEN_MASK, 0);
+}
+
+static struct watchdog_ops bcm_kona_wdt_ops = {
+       .owner =        THIS_MODULE,
+       .start =        bcm_kona_wdt_start,
+       .stop =         bcm_kona_wdt_stop,
+       .set_timeout =  bcm_kona_wdt_set_timeout,
+       .get_timeleft = bcm_kona_wdt_get_timeleft,
+};
+
+static struct watchdog_info bcm_kona_wdt_info = {
+       .options =      WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE |
+                       WDIOF_KEEPALIVEPING,
+       .identity =     "Broadcom Kona Watchdog Timer",
+};
+
+static struct watchdog_device bcm_kona_wdt_wdd = {
+       .info =         &bcm_kona_wdt_info,
+       .ops =          &bcm_kona_wdt_ops,
+       .min_timeout =  1,
+       .max_timeout =  SECWDOG_MAX_COUNT >> SECWDOG_DEFAULT_RESOLUTION,
+       .timeout =      SECWDOG_MAX_COUNT >> SECWDOG_DEFAULT_RESOLUTION,
+};
+
+static void bcm_kona_wdt_shutdown(struct platform_device *pdev)
+{
+       bcm_kona_wdt_stop(&bcm_kona_wdt_wdd);
+}
+
+static int bcm_kona_wdt_probe(struct platform_device *pdev)
+{
+       struct device *dev = &pdev->dev;
+       struct bcm_kona_wdt *wdt;
+       struct resource *res;
+       int ret;
+
+       wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL);
+       if (!wdt)
+               return -ENOMEM;
+
+       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+       wdt->base = devm_ioremap_resource(dev, res);
+       if (IS_ERR(wdt->base))
+               return -ENODEV;
+
+       wdt->resolution = SECWDOG_DEFAULT_RESOLUTION;
+       ret = bcm_kona_wdt_set_resolution_reg(wdt);
+       if (ret) {
+               dev_err(dev, "Failed to set resolution (error: %d)", ret);
+               return ret;
+       }
+
+       spin_lock_init(&wdt->lock);
+       platform_set_drvdata(pdev, wdt);
+       watchdog_set_drvdata(&bcm_kona_wdt_wdd, wdt);
+
+       ret = bcm_kona_wdt_set_timeout_reg(&bcm_kona_wdt_wdd, 0);
+       if (ret) {
+               dev_err(dev, "Failed set watchdog timeout");
+               return ret;
+       }
+
+       ret = watchdog_register_device(&bcm_kona_wdt_wdd);
+       if (ret) {
+               dev_err(dev, "Failed to register watchdog device");
+               return ret;
+       }
+
+       bcm_kona_wdt_debug_init(pdev);
+       dev_dbg(dev, "Broadcom Kona Watchdog Timer");
+
+       return 0;
+}
+
+static int bcm_kona_wdt_remove(struct platform_device *pdev)
+{
+       bcm_kona_wdt_debug_exit(pdev);
+       bcm_kona_wdt_shutdown(pdev);
+       watchdog_unregister_device(&bcm_kona_wdt_wdd);
+       dev_dbg(&pdev->dev, "Watchdog driver disabled");
+
+       return 0;
+}
+
+static const struct of_device_id bcm_kona_wdt_of_match[] = {
+       { .compatible = "brcm,kona-wdt", },
+       {},
+};
+MODULE_DEVICE_TABLE(of, bcm_kona_wdt_of_match);
+
+static struct platform_driver bcm_kona_wdt_driver = {
+       .driver = {
+                       .name = BCM_KONA_WDT_NAME,
+                       .owner = THIS_MODULE,
+                       .of_match_table = bcm_kona_wdt_of_match,
+                 },
+       .probe = bcm_kona_wdt_probe,
+       .remove = bcm_kona_wdt_remove,
+       .shutdown = bcm_kona_wdt_shutdown,
+};
+
+module_platform_driver(bcm_kona_wdt_driver);
+
+MODULE_ALIAS("platform:" BCM_KONA_WDT_NAME);
+MODULE_AUTHOR("Markus Mayer <mmayer@broadcom.com>");
+MODULE_DESCRIPTION("Broadcom Kona Watchdog Driver");
+MODULE_LICENSE("GPL v2");
index dd625cca1ae5669d4e513a8611736c1b82d33a62..f3774eb06ceda0fa5384cce6c2cd38cd9661cb7f 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Watchdog driver for DaVinci DM644x/DM646x processors
  *
- * Copyright (C) 2006 Texas Instruments.
+ * Copyright (C) 2006-2013 Texas Instruments.
  *
  * 2007 (c) MontaVista Software, Inc. This file is licensed under
  * the terms of the GNU General Public License version 2. This program
 #include <linux/moduleparam.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
-#include <linux/fs.h>
-#include <linux/miscdevice.h>
 #include <linux/watchdog.h>
 #include <linux/init.h>
-#include <linux/bitops.h>
 #include <linux/platform_device.h>
-#include <linux/spinlock.h>
-#include <linux/uaccess.h>
 #include <linux/io.h>
 #include <linux/device.h>
 #include <linux/clk.h>
-#include <linux/slab.h>
 #include <linux/err.h>
 
 #define MODULE_NAME "DAVINCI-WDT: "
 #define WDKEY_SEQ0             (0xa5c6 << 16)
 #define WDKEY_SEQ1             (0xda7e << 16)
 
-static int heartbeat = DEFAULT_HEARTBEAT;
+static int heartbeat;
 
-static DEFINE_SPINLOCK(io_lock);
-static unsigned long wdt_status;
-#define WDT_IN_USE        0
-#define WDT_OK_TO_CLOSE   1
-#define WDT_REGION_INITED 2
-#define WDT_DEVICE_INITED 3
-
-static void __iomem    *wdt_base;
-struct clk             *wdt_clk;
-
-static void wdt_service(void)
-{
-       spin_lock(&io_lock);
-
-       /* put watchdog in service state */
-       iowrite32(WDKEY_SEQ0, wdt_base + WDTCR);
-       /* put watchdog in active state */
-       iowrite32(WDKEY_SEQ1, wdt_base + WDTCR);
-
-       spin_unlock(&io_lock);
-}
+/*
+ * struct to hold data for each WDT device
+ * @base - base io address of WD device
+ * @clk - source clock of WDT
+ * @wdd - hold watchdog device as is in WDT core
+ */
+struct davinci_wdt_device {
+       void __iomem            *base;
+       struct clk              *clk;
+       struct watchdog_device  wdd;
+};
 
-static void wdt_enable(void)
+static int davinci_wdt_start(struct watchdog_device *wdd)
 {
        u32 tgcr;
        u32 timer_margin;
        unsigned long wdt_freq;
+       struct davinci_wdt_device *davinci_wdt = watchdog_get_drvdata(wdd);
 
-       wdt_freq = clk_get_rate(wdt_clk);
-
-       spin_lock(&io_lock);
+       wdt_freq = clk_get_rate(davinci_wdt->clk);
 
        /* disable, internal clock source */
-       iowrite32(0, wdt_base + TCR);
+       iowrite32(0, davinci_wdt->base + TCR);
        /* reset timer, set mode to 64-bit watchdog, and unreset */
-       iowrite32(0, wdt_base + TGCR);
+       iowrite32(0, davinci_wdt->base + TGCR);
        tgcr = TIMMODE_64BIT_WDOG | TIM12RS_UNRESET | TIM34RS_UNRESET;
-       iowrite32(tgcr, wdt_base + TGCR);
+       iowrite32(tgcr, davinci_wdt->base + TGCR);
        /* clear counter regs */
-       iowrite32(0, wdt_base + TIM12);
-       iowrite32(0, wdt_base + TIM34);
+       iowrite32(0, davinci_wdt->base + TIM12);
+       iowrite32(0, davinci_wdt->base + TIM34);
        /* set timeout period */
-       timer_margin = (((u64)heartbeat * wdt_freq) & 0xffffffff);
-       iowrite32(timer_margin, wdt_base + PRD12);
-       timer_margin = (((u64)heartbeat * wdt_freq) >> 32);
-       iowrite32(timer_margin, wdt_base + PRD34);
+       timer_margin = (((u64)wdd->timeout * wdt_freq) & 0xffffffff);
+       iowrite32(timer_margin, davinci_wdt->base + PRD12);
+       timer_margin = (((u64)wdd->timeout * wdt_freq) >> 32);
+       iowrite32(timer_margin, davinci_wdt->base + PRD34);
        /* enable run continuously */
-       iowrite32(ENAMODE12_PERIODIC, wdt_base + TCR);
+       iowrite32(ENAMODE12_PERIODIC, davinci_wdt->base + TCR);
        /* Once the WDT is in pre-active state write to
         * TIM12, TIM34, PRD12, PRD34, TCR, TGCR, WDTCR are
         * write protected (except for the WDKEY field)
         */
        /* put watchdog in pre-active state */
-       iowrite32(WDKEY_SEQ0 | WDEN, wdt_base + WDTCR);
+       iowrite32(WDKEY_SEQ0 | WDEN, davinci_wdt->base + WDTCR);
        /* put watchdog in active state */
-       iowrite32(WDKEY_SEQ1 | WDEN, wdt_base + WDTCR);
-
-       spin_unlock(&io_lock);
+       iowrite32(WDKEY_SEQ1 | WDEN, davinci_wdt->base + WDTCR);
+       return 0;
 }
 
-static int davinci_wdt_open(struct inode *inode, struct file *file)
+static int davinci_wdt_ping(struct watchdog_device *wdd)
 {
-       if (test_and_set_bit(WDT_IN_USE, &wdt_status))
-               return -EBUSY;
-
-       wdt_enable();
+       struct davinci_wdt_device *davinci_wdt = watchdog_get_drvdata(wdd);
 
-       return nonseekable_open(inode, file);
+       /* put watchdog in service state */
+       iowrite32(WDKEY_SEQ0, davinci_wdt->base + WDTCR);
+       /* put watchdog in active state */
+       iowrite32(WDKEY_SEQ1, davinci_wdt->base + WDTCR);
+       return 0;
 }
 
-static ssize_t
-davinci_wdt_write(struct file *file, const char *data, size_t len,
-                 loff_t *ppos)
+static unsigned int davinci_wdt_get_timeleft(struct watchdog_device *wdd)
 {
-       if (len)
-               wdt_service();
+       u64 timer_counter;
+       unsigned long freq;
+       u32 val;
+       struct davinci_wdt_device *davinci_wdt = watchdog_get_drvdata(wdd);
 
-       return len;
-}
+       /* if timeout has occured then return 0 */
+       val = ioread32(davinci_wdt->base + WDTCR);
+       if (val & WDFLAG)
+               return 0;
 
-static const struct watchdog_info ident = {
-       .options = WDIOF_KEEPALIVEPING,
-       .identity = "DaVinci Watchdog",
-};
+       freq = clk_get_rate(davinci_wdt->clk);
 
-static long davinci_wdt_ioctl(struct file *file,
-                                       unsigned int cmd, unsigned long arg)
-{
-       int ret = -ENOTTY;
-
-       switch (cmd) {
-       case WDIOC_GETSUPPORT:
-               ret = copy_to_user((struct watchdog_info *)arg, &ident,
-                                  sizeof(ident)) ? -EFAULT : 0;
-               break;
-
-       case WDIOC_GETSTATUS:
-       case WDIOC_GETBOOTSTATUS:
-               ret = put_user(0, (int *)arg);
-               break;
-
-       case WDIOC_KEEPALIVE:
-               wdt_service();
-               ret = 0;
-               break;
-
-       case WDIOC_GETTIMEOUT:
-               ret = put_user(heartbeat, (int *)arg);
-               break;
-       }
-       return ret;
-}
+       if (!freq)
+               return 0;
 
-static int davinci_wdt_release(struct inode *inode, struct file *file)
-{
-       wdt_service();
-       clear_bit(WDT_IN_USE, &wdt_status);
+       timer_counter = ioread32(davinci_wdt->base + TIM12);
+       timer_counter |= ((u64)ioread32(davinci_wdt->base + TIM34) << 32);
 
-       return 0;
+       do_div(timer_counter, freq);
+
+       return wdd->timeout - timer_counter;
 }
 
-static const struct file_operations davinci_wdt_fops = {
-       .owner = THIS_MODULE,
-       .llseek = no_llseek,
-       .write = davinci_wdt_write,
-       .unlocked_ioctl = davinci_wdt_ioctl,
-       .open = davinci_wdt_open,
-       .release = davinci_wdt_release,
+static const struct watchdog_info davinci_wdt_info = {
+       .options = WDIOF_KEEPALIVEPING,
+       .identity = "DaVinci/Keystone Watchdog",
 };
 
-static struct miscdevice davinci_wdt_miscdev = {
-       .minor = WATCHDOG_MINOR,
-       .name = "watchdog",
-       .fops = &davinci_wdt_fops,
+static const struct watchdog_ops davinci_wdt_ops = {
+       .owner          = THIS_MODULE,
+       .start          = davinci_wdt_start,
+       .stop           = davinci_wdt_ping,
+       .ping           = davinci_wdt_ping,
+       .get_timeleft   = davinci_wdt_get_timeleft,
 };
 
 static int davinci_wdt_probe(struct platform_device *pdev)
@@ -204,37 +159,53 @@ static int davinci_wdt_probe(struct platform_device *pdev)
        int ret = 0;
        struct device *dev = &pdev->dev;
        struct resource  *wdt_mem;
+       struct watchdog_device *wdd;
+       struct davinci_wdt_device *davinci_wdt;
+
+       davinci_wdt = devm_kzalloc(dev, sizeof(*davinci_wdt), GFP_KERNEL);
+       if (!davinci_wdt)
+               return -ENOMEM;
 
-       wdt_clk = devm_clk_get(dev, NULL);
-       if (WARN_ON(IS_ERR(wdt_clk)))
-               return PTR_ERR(wdt_clk);
+       davinci_wdt->clk = devm_clk_get(dev, NULL);
+       if (WARN_ON(IS_ERR(davinci_wdt->clk)))
+               return PTR_ERR(davinci_wdt->clk);
 
-       clk_prepare_enable(wdt_clk);
+       clk_prepare_enable(davinci_wdt->clk);
 
-       if (heartbeat < 1 || heartbeat > MAX_HEARTBEAT)
-               heartbeat = DEFAULT_HEARTBEAT;
+       platform_set_drvdata(pdev, davinci_wdt);
 
-       dev_info(dev, "heartbeat %d sec\n", heartbeat);
+       wdd                     = &davinci_wdt->wdd;
+       wdd->info               = &davinci_wdt_info;
+       wdd->ops                = &davinci_wdt_ops;
+       wdd->min_timeout        = 1;
+       wdd->max_timeout        = MAX_HEARTBEAT;
+       wdd->timeout            = DEFAULT_HEARTBEAT;
+
+       watchdog_init_timeout(wdd, heartbeat, dev);
+
+       dev_info(dev, "heartbeat %d sec\n", wdd->timeout);
+
+       watchdog_set_drvdata(wdd, davinci_wdt);
+       watchdog_set_nowayout(wdd, 1);
 
        wdt_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       wdt_base = devm_ioremap_resource(dev, wdt_mem);
-       if (IS_ERR(wdt_base))
-               return PTR_ERR(wdt_base);
+       davinci_wdt->base = devm_ioremap_resource(dev, wdt_mem);
+       if (IS_ERR(davinci_wdt->base))
+               return PTR_ERR(davinci_wdt->base);
 
-       ret = misc_register(&davinci_wdt_miscdev);
-       if (ret < 0) {
-               dev_err(dev, "cannot register misc device\n");
-       } else {
-               set_bit(WDT_DEVICE_INITED, &wdt_status);
-       }
+       ret = watchdog_register_device(wdd);
+       if (ret < 0)
+               dev_err(dev, "cannot register watchdog device\n");
 
        return ret;
 }
 
 static int davinci_wdt_remove(struct platform_device *pdev)
 {
-       misc_deregister(&davinci_wdt_miscdev);
-       clk_disable_unprepare(wdt_clk);
+       struct davinci_wdt_device *davinci_wdt = platform_get_drvdata(pdev);
+
+       watchdog_unregister_device(&davinci_wdt->wdd);
+       clk_disable_unprepare(davinci_wdt->clk);
 
        return 0;
 }
index a46f5c7ee7ff4e6c11eceb36a59ca7438949e5b5..ee4f86ba83eca1856dc85a0ad777e11732e4e5ea 100644 (file)
@@ -8,7 +8,7 @@
  * 2 of the License, or (at your option) any later version.
  *
  * This file implements a driver for the Synopsys DesignWare watchdog device
- * in the many ARM subsystems. The watchdog has 16 different timeout periods
+ * in the many subsystems. The watchdog has 16 different timeout periods
  * and these are a function of the input clock frequency.
  *
  * The DesignWare watchdog cannot be stopped once it has been started so we
diff --git a/drivers/watchdog/gpio_wdt.c b/drivers/watchdog/gpio_wdt.c
new file mode 100644 (file)
index 0000000..220a9e0
--- /dev/null
@@ -0,0 +1,254 @@
+/*
+ * Driver for watchdog device controlled through GPIO-line
+ *
+ * Author: 2013, Alexander Shiyan <shc_work@mail.ru>
+ *
+ * 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/err.h>
+#include <linux/delay.h>
+#include <linux/module.h>
+#include <linux/notifier.h>
+#include <linux/of_gpio.h>
+#include <linux/platform_device.h>
+#include <linux/reboot.h>
+#include <linux/watchdog.h>
+
+#define SOFT_TIMEOUT_MIN       1
+#define SOFT_TIMEOUT_DEF       60
+#define SOFT_TIMEOUT_MAX       0xffff
+
+enum {
+       HW_ALGO_TOGGLE,
+       HW_ALGO_LEVEL,
+};
+
+struct gpio_wdt_priv {
+       int                     gpio;
+       bool                    active_low;
+       bool                    state;
+       unsigned int            hw_algo;
+       unsigned int            hw_margin;
+       unsigned long           last_jiffies;
+       struct notifier_block   notifier;
+       struct timer_list       timer;
+       struct watchdog_device  wdd;
+};
+
+static void gpio_wdt_disable(struct gpio_wdt_priv *priv)
+{
+       gpio_set_value_cansleep(priv->gpio, !priv->active_low);
+
+       /* Put GPIO back to tristate */
+       if (priv->hw_algo == HW_ALGO_TOGGLE)
+               gpio_direction_input(priv->gpio);
+}
+
+static int gpio_wdt_start(struct watchdog_device *wdd)
+{
+       struct gpio_wdt_priv *priv = watchdog_get_drvdata(wdd);
+
+       priv->state = priv->active_low;
+       gpio_direction_output(priv->gpio, priv->state);
+       priv->last_jiffies = jiffies;
+       mod_timer(&priv->timer, priv->last_jiffies + priv->hw_margin);
+
+       return 0;
+}
+
+static int gpio_wdt_stop(struct watchdog_device *wdd)
+{
+       struct gpio_wdt_priv *priv = watchdog_get_drvdata(wdd);
+
+       mod_timer(&priv->timer, 0);
+       gpio_wdt_disable(priv);
+
+       return 0;
+}
+
+static int gpio_wdt_ping(struct watchdog_device *wdd)
+{
+       struct gpio_wdt_priv *priv = watchdog_get_drvdata(wdd);
+
+       priv->last_jiffies = jiffies;
+
+       return 0;
+}
+
+static int gpio_wdt_set_timeout(struct watchdog_device *wdd, unsigned int t)
+{
+       wdd->timeout = t;
+
+       return gpio_wdt_ping(wdd);
+}
+
+static void gpio_wdt_hwping(unsigned long data)
+{
+       struct watchdog_device *wdd = (struct watchdog_device *)data;
+       struct gpio_wdt_priv *priv = watchdog_get_drvdata(wdd);
+
+       if (time_after(jiffies, priv->last_jiffies +
+                      msecs_to_jiffies(wdd->timeout * 1000))) {
+               dev_crit(wdd->dev, "Timer expired. System will reboot soon!\n");
+               return;
+       }
+
+       /* Restart timer */
+       mod_timer(&priv->timer, jiffies + priv->hw_margin);
+
+       switch (priv->hw_algo) {
+       case HW_ALGO_TOGGLE:
+               /* Toggle output pin */
+               priv->state = !priv->state;
+               gpio_set_value_cansleep(priv->gpio, priv->state);
+               break;
+       case HW_ALGO_LEVEL:
+               /* Pulse */
+               gpio_set_value_cansleep(priv->gpio, !priv->active_low);
+               udelay(1);
+               gpio_set_value_cansleep(priv->gpio, priv->active_low);
+               break;
+       }
+}
+
+static int gpio_wdt_notify_sys(struct notifier_block *nb, unsigned long code,
+                              void *unused)
+{
+       struct gpio_wdt_priv *priv = container_of(nb, struct gpio_wdt_priv,
+                                                 notifier);
+
+       mod_timer(&priv->timer, 0);
+
+       switch (code) {
+       case SYS_HALT:
+       case SYS_POWER_OFF:
+               gpio_wdt_disable(priv);
+               break;
+       default:
+               break;
+       }
+
+       return NOTIFY_DONE;
+}
+
+static const struct watchdog_info gpio_wdt_ident = {
+       .options        = WDIOF_MAGICCLOSE | WDIOF_KEEPALIVEPING |
+                         WDIOF_SETTIMEOUT,
+       .identity       = "GPIO Watchdog",
+};
+
+static const struct watchdog_ops gpio_wdt_ops = {
+       .owner          = THIS_MODULE,
+       .start          = gpio_wdt_start,
+       .stop           = gpio_wdt_stop,
+       .ping           = gpio_wdt_ping,
+       .set_timeout    = gpio_wdt_set_timeout,
+};
+
+static int gpio_wdt_probe(struct platform_device *pdev)
+{
+       struct gpio_wdt_priv *priv;
+       enum of_gpio_flags flags;
+       unsigned int hw_margin;
+       unsigned long f = 0;
+       const char *algo;
+       int ret;
+
+       priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
+       if (!priv)
+               return -ENOMEM;
+
+       priv->gpio = of_get_gpio_flags(pdev->dev.of_node, 0, &flags);
+       if (!gpio_is_valid(priv->gpio))
+               return priv->gpio;
+
+       priv->active_low = flags & OF_GPIO_ACTIVE_LOW;
+
+       ret = of_property_read_string(pdev->dev.of_node, "hw_algo", &algo);
+       if (ret)
+               return ret;
+       if (!strncmp(algo, "toggle", 6)) {
+               priv->hw_algo = HW_ALGO_TOGGLE;
+               f = GPIOF_IN;
+       } else if (!strncmp(algo, "level", 5)) {
+               priv->hw_algo = HW_ALGO_LEVEL;
+               f = priv->active_low ? GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW;
+       } else {
+               return -EINVAL;
+       }
+
+       ret = devm_gpio_request_one(&pdev->dev, priv->gpio, f,
+                                   dev_name(&pdev->dev));
+       if (ret)
+               return ret;
+
+       ret = of_property_read_u32(pdev->dev.of_node,
+                                  "hw_margin_ms", &hw_margin);
+       if (ret)
+               return ret;
+       /* Disallow values lower than 2 and higher than 65535 ms */
+       if (hw_margin < 2 || hw_margin > 65535)
+               return -EINVAL;
+
+       /* Use safe value (1/2 of real timeout) */
+       priv->hw_margin = msecs_to_jiffies(hw_margin / 2);
+
+       watchdog_set_drvdata(&priv->wdd, priv);
+
+       priv->wdd.info          = &gpio_wdt_ident;
+       priv->wdd.ops           = &gpio_wdt_ops;
+       priv->wdd.min_timeout   = SOFT_TIMEOUT_MIN;
+       priv->wdd.max_timeout   = SOFT_TIMEOUT_MAX;
+
+       if (watchdog_init_timeout(&priv->wdd, 0, &pdev->dev) < 0)
+               priv->wdd.timeout = SOFT_TIMEOUT_DEF;
+
+       setup_timer(&priv->timer, gpio_wdt_hwping, (unsigned long)&priv->wdd);
+
+       ret = watchdog_register_device(&priv->wdd);
+       if (ret)
+               return ret;
+
+       priv->notifier.notifier_call = gpio_wdt_notify_sys;
+       ret = register_reboot_notifier(&priv->notifier);
+       if (ret)
+               watchdog_unregister_device(&priv->wdd);
+
+       return ret;
+}
+
+static int gpio_wdt_remove(struct platform_device *pdev)
+{
+       struct gpio_wdt_priv *priv = platform_get_drvdata(pdev);
+
+       del_timer_sync(&priv->timer);
+       unregister_reboot_notifier(&priv->notifier);
+       watchdog_unregister_device(&priv->wdd);
+
+       return 0;
+}
+
+static const struct of_device_id gpio_wdt_dt_ids[] = {
+       { .compatible = "linux,wdt-gpio", },
+       { }
+};
+MODULE_DEVICE_TABLE(of, gpio_wdt_dt_ids);
+
+static struct platform_driver gpio_wdt_driver = {
+       .driver = {
+               .name           = "gpio-wdt",
+               .owner          = THIS_MODULE,
+               .of_match_table = gpio_wdt_dt_ids,
+       },
+       .probe  = gpio_wdt_probe,
+       .remove = gpio_wdt_remove,
+};
+module_platform_driver(gpio_wdt_driver);
+
+MODULE_AUTHOR("Alexander Shiyan <shc_work@mail.ru>");
+MODULE_DESCRIPTION("GPIO Watchdog");
+MODULE_LICENSE("GPL");
index 45b979d9dd13acf223ac4ede12262c51fe6e1e9d..2b75e8b472796e987c3651599b7583442d5b1089 100644 (file)
@@ -39,7 +39,7 @@
 #endif /* CONFIG_HPWDT_NMI_DECODING */
 #include <asm/nmi.h>
 
-#define HPWDT_VERSION                  "1.3.2"
+#define HPWDT_VERSION                  "1.3.3"
 #define SECS_TO_TICKS(secs)            ((secs) * 1000 / 128)
 #define TICKS_TO_SECS(ticks)           ((ticks) * 128 / 1000)
 #define HPWDT_MAX_TIMER                        TICKS_TO_SECS(65535)
@@ -55,7 +55,7 @@ static void __iomem *pci_mem_addr;            /* the PCI-memory address */
 static unsigned long __iomem *hpwdt_timer_reg;
 static unsigned long __iomem *hpwdt_timer_con;
 
-static DEFINE_PCI_DEVICE_TABLE(hpwdt_devices) = {
+static const struct pci_device_id hpwdt_devices[] = {
        { PCI_DEVICE(PCI_VENDOR_ID_COMPAQ, 0xB203) },   /* iLO2 */
        { PCI_DEVICE(PCI_VENDOR_ID_HP, 0x3306) },       /* iLO3 */
        {0},                    /* terminate list */
@@ -501,8 +501,13 @@ static int hpwdt_pretimeout(unsigned int ulReason, struct pt_regs *regs)
                                "but unable to determine source.\n");
                }
        }
-       panic("An NMI occurred, please see the Integrated "
-               "Management Log for details.\n");
+       panic("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"
+               "2. OA Syslog\n"
+               "3. OA Forward Progress Log\n"
+               "4. iLO Event Log");
 
 out:
        return NMI_DONE;
index a72fe9361ddf028ef717959183cc5bdfc3ea0478..25a2bfdb4e9d2e41812b676e4b93b0c4219c47a9 100644 (file)
@@ -334,7 +334,7 @@ static struct miscdevice esb_miscdev = {
 /*
  * Data for PCI driver interface
  */
-static DEFINE_PCI_DEVICE_TABLE(esb_pci_tbl) = {
+static const struct pci_device_id esb_pci_tbl[] = {
        { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB_9), },
        { 0, },                 /* End of list */
 };
index b4786bccc42c3c062153ef06ce2419900d84a76d..dd51d9539b33df6ea6b9aa9960d9f0fa5fe7c169 100644 (file)
@@ -2,6 +2,7 @@
  * Watchdog driver for IMX2 and later processors
  *
  *  Copyright (C) 2010 Wolfram Sang, Pengutronix e.K. <w.sang@pengutronix.de>
+ *  Copyright (C) 2014 Freescale Semiconductor, Inc.
  *
  * some parts adapted by similar drivers from Darius Augulis and Vladimir
  * Zapolskiy, additional improvements by Wim Van Sebroeck.
@@ -40,6 +41,7 @@
 #define IMX2_WDT_WCR_WT                (0xFF << 8)     /* -> Watchdog Timeout Field */
 #define IMX2_WDT_WCR_WRE       (1 << 3)        /* -> WDOG Reset Enable */
 #define IMX2_WDT_WCR_WDE       (1 << 2)        /* -> Watchdog Enable */
+#define IMX2_WDT_WCR_WDZST     (1 << 0)        /* -> Watchdog timer Suspend */
 
 #define IMX2_WDT_WSR           0x02            /* Service Register */
 #define IMX2_WDT_SEQ1          0x5555          /* -> service sequence 1 */
@@ -87,6 +89,8 @@ static inline void imx2_wdt_setup(void)
 {
        u16 val = __raw_readw(imx2_wdt.base + IMX2_WDT_WCR);
 
+       /* Suspend timer in low power mode, write once-only */
+       val |= IMX2_WDT_WCR_WDZST;
        /* Strip the old watchdog Time-Out value */
        val &= ~IMX2_WDT_WCR_WT;
        /* Generate reset if WDOG times out */
index d82152077fd9fb1c512145c92a8700cb0ccaf385..c1f65b4c0aa4050442bd1742d32a0883e68537dd 100644 (file)
@@ -73,9 +73,7 @@ MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started "
  * to 0
  */
 static int prescale = 1;
-static unsigned int timeout_sec;
 
-static unsigned long wdt_is_open;
 static DEFINE_SPINLOCK(wdt_spinlock);
 
 static void mpc8xxx_wdt_keepalive(void)
@@ -87,39 +85,23 @@ static void mpc8xxx_wdt_keepalive(void)
        spin_unlock(&wdt_spinlock);
 }
 
+static struct watchdog_device mpc8xxx_wdt_dev;
 static void mpc8xxx_wdt_timer_ping(unsigned long arg);
-static DEFINE_TIMER(wdt_timer, mpc8xxx_wdt_timer_ping, 0, 0);
+static DEFINE_TIMER(wdt_timer, mpc8xxx_wdt_timer_ping, 0,
+               (unsigned long)&mpc8xxx_wdt_dev);
 
 static void mpc8xxx_wdt_timer_ping(unsigned long arg)
 {
+       struct watchdog_device *w = (struct watchdog_device *)arg;
+
        mpc8xxx_wdt_keepalive();
        /* We're pinging it twice faster than needed, just to be sure. */
-       mod_timer(&wdt_timer, jiffies + HZ * timeout_sec / 2);
-}
-
-static void mpc8xxx_wdt_pr_warn(const char *msg)
-{
-       pr_crit("%s, expect the %s soon!\n", msg,
-               reset ? "reset" : "machine check exception");
+       mod_timer(&wdt_timer, jiffies + HZ * w->timeout / 2);
 }
 
-static ssize_t mpc8xxx_wdt_write(struct file *file, const char __user *buf,
-                                size_t count, loff_t *ppos)
-{
-       if (count)
-               mpc8xxx_wdt_keepalive();
-       return count;
-}
-
-static int mpc8xxx_wdt_open(struct inode *inode, struct file *file)
+static int mpc8xxx_wdt_start(struct watchdog_device *w)
 {
        u32 tmp = SWCRR_SWEN;
-       if (test_and_set_bit(0, &wdt_is_open))
-               return -EBUSY;
-
-       /* Once we start the watchdog we can't stop it */
-       if (nowayout)
-               __module_get(THIS_MODULE);
 
        /* Good, fire up the show */
        if (prescale)
@@ -133,59 +115,37 @@ static int mpc8xxx_wdt_open(struct inode *inode, struct file *file)
 
        del_timer_sync(&wdt_timer);
 
-       return nonseekable_open(inode, file);
+       return 0;
 }
 
-static int mpc8xxx_wdt_release(struct inode *inode, struct file *file)
+static int mpc8xxx_wdt_ping(struct watchdog_device *w)
 {
-       if (!nowayout)
-               mpc8xxx_wdt_timer_ping(0);
-       else
-               mpc8xxx_wdt_pr_warn("watchdog closed");
-       clear_bit(0, &wdt_is_open);
+       mpc8xxx_wdt_keepalive();
        return 0;
 }
 
-static long mpc8xxx_wdt_ioctl(struct file *file, unsigned int cmd,
-                                                       unsigned long arg)
+static int mpc8xxx_wdt_stop(struct watchdog_device *w)
 {
-       void __user *argp = (void __user *)arg;
-       int __user *p = argp;
-       static const struct watchdog_info ident = {
-               .options = WDIOF_KEEPALIVEPING,
-               .firmware_version = 1,
-               .identity = "MPC8xxx",
-       };
-
-       switch (cmd) {
-       case WDIOC_GETSUPPORT:
-               return copy_to_user(argp, &ident, sizeof(ident)) ? -EFAULT : 0;
-       case WDIOC_GETSTATUS:
-       case WDIOC_GETBOOTSTATUS:
-               return put_user(0, p);
-       case WDIOC_KEEPALIVE:
-               mpc8xxx_wdt_keepalive();
-               return 0;
-       case WDIOC_GETTIMEOUT:
-               return put_user(timeout_sec, p);
-       default:
-               return -ENOTTY;
-       }
+       mod_timer(&wdt_timer, jiffies);
+       return 0;
 }
 
-static const struct file_operations mpc8xxx_wdt_fops = {
-       .owner          = THIS_MODULE,
-       .llseek         = no_llseek,
-       .write          = mpc8xxx_wdt_write,
-       .unlocked_ioctl = mpc8xxx_wdt_ioctl,
-       .open           = mpc8xxx_wdt_open,
-       .release        = mpc8xxx_wdt_release,
+static struct watchdog_info mpc8xxx_wdt_info = {
+       .options = WDIOF_KEEPALIVEPING,
+       .firmware_version = 1,
+       .identity = "MPC8xxx",
 };
 
-static struct miscdevice mpc8xxx_wdt_miscdev = {
-       .minor  = WATCHDOG_MINOR,
-       .name   = "watchdog",
-       .fops   = &mpc8xxx_wdt_fops,
+static struct watchdog_ops mpc8xxx_wdt_ops = {
+       .owner = THIS_MODULE,
+       .start = mpc8xxx_wdt_start,
+       .ping = mpc8xxx_wdt_ping,
+       .stop = mpc8xxx_wdt_stop,
+};
+
+static struct watchdog_device mpc8xxx_wdt_dev = {
+       .info = &mpc8xxx_wdt_info,
+       .ops = &mpc8xxx_wdt_ops,
 };
 
 static const struct of_device_id mpc8xxx_wdt_match[];
@@ -197,6 +157,7 @@ static int mpc8xxx_wdt_probe(struct platform_device *ofdev)
        const struct mpc8xxx_wdt_type *wdt_type;
        u32 freq = fsl_get_sys_freq();
        bool enabled;
+       unsigned int timeout_sec;
 
        match = of_match_device(mpc8xxx_wdt_match, &ofdev->dev);
        if (!match)
@@ -223,6 +184,7 @@ static int mpc8xxx_wdt_probe(struct platform_device *ofdev)
        else
                timeout_sec = timeout / freq;
 
+       mpc8xxx_wdt_dev.timeout = timeout_sec;
 #ifdef MODULE
        ret = mpc8xxx_wdt_init_late();
        if (ret)
@@ -238,7 +200,7 @@ static int mpc8xxx_wdt_probe(struct platform_device *ofdev)
         * userspace handles it.
         */
        if (enabled)
-               mpc8xxx_wdt_timer_ping(0);
+               mod_timer(&wdt_timer, jiffies);
        return 0;
 err_unmap:
        iounmap(wd_base);
@@ -248,9 +210,10 @@ err_unmap:
 
 static int mpc8xxx_wdt_remove(struct platform_device *ofdev)
 {
-       mpc8xxx_wdt_pr_warn("watchdog removed");
+       pr_crit("Watchdog removed, expect the %s soon!\n",
+               reset ? "reset" : "machine check exception");
        del_timer_sync(&wdt_timer);
-       misc_deregister(&mpc8xxx_wdt_miscdev);
+       watchdog_unregister_device(&mpc8xxx_wdt_dev);
        iounmap(wd_base);
 
        return 0;
@@ -302,10 +265,11 @@ static int mpc8xxx_wdt_init_late(void)
        if (!wd_base)
                return -ENODEV;
 
-       ret = misc_register(&mpc8xxx_wdt_miscdev);
+       watchdog_set_nowayout(&mpc8xxx_wdt_dev, nowayout);
+
+       ret = watchdog_register_device(&mpc8xxx_wdt_dev);
        if (ret) {
-               pr_err("cannot register miscdev on minor=%d (err=%d)\n",
-                      WATCHDOG_MINOR, ret);
+               pr_err("cannot register watchdog device (err=%d)\n", ret);
                return ret;
        }
        return 0;
index 231e5b9d5c8e079ec424b9331aca90912f42efae..0b9ec61e131330524e417197304702baaebdf272 100644 (file)
@@ -289,7 +289,7 @@ static struct miscdevice nv_tco_miscdev = {
  * register a pci_driver, because someone else might one day
  * want to register another driver on the same PCI id.
  */
-static DEFINE_PCI_DEVICE_TABLE(tco_pci_tbl) = {
+static const struct pci_device_id tco_pci_tbl[] = {
        { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_SMBUS,
          PCI_ANY_ID, PCI_ANY_ID, },
        { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_SMBUS,
index b4864f254b48940b7fd9b7febb368b6608af4716..c0d07eef2640b9cb0f2469acda6a579e57a16d94 100644 (file)
@@ -801,7 +801,7 @@ static void pcipcwd_card_exit(struct pci_dev *pdev)
        cards_found--;
 }
 
-static DEFINE_PCI_DEVICE_TABLE(pcipcwd_pci_tbl) = {
+static const struct pci_device_id pcipcwd_pci_tbl[] = {
        { PCI_VENDOR_ID_QUICKLOGIC, PCI_DEVICE_ID_WATCHDOG_PCIPCWD,
                PCI_ANY_ID, PCI_ANY_ID, },
        { 0 },                  /* End of list */
index 7d8fd041ee250d3759fc2b86519012a09ded76e2..aec946df6ed976d2479762dc51d69060a5504382 100644 (file)
@@ -40,6 +40,8 @@
 #include <linux/slab.h>
 #include <linux/err.h>
 #include <linux/of.h>
+#include <linux/mfd/syscon.h>
+#include <linux/regmap.h>
 
 #define S3C2410_WTCON          0x00
 #define S3C2410_WTDAT          0x04
 #define CONFIG_S3C2410_WATCHDOG_ATBOOT         (0)
 #define CONFIG_S3C2410_WATCHDOG_DEFAULT_TIME   (15)
 
+#define EXYNOS5_RST_STAT_REG_OFFSET            0x0404
+#define EXYNOS5_WDT_DISABLE_REG_OFFSET         0x0408
+#define EXYNOS5_WDT_MASK_RESET_REG_OFFSET      0x040c
+#define QUIRK_HAS_PMU_CONFIG                   (1 << 0)
+#define QUIRK_HAS_RST_STAT                     (1 << 1)
+
+/* These quirks require that we have a PMU register map */
+#define QUIRKS_HAVE_PMUREG                     (QUIRK_HAS_PMU_CONFIG | \
+                                                QUIRK_HAS_RST_STAT)
+
 static bool nowayout   = WATCHDOG_NOWAYOUT;
 static int tmr_margin;
 static int tmr_atboot  = CONFIG_S3C2410_WATCHDOG_ATBOOT;
@@ -83,6 +95,30 @@ MODULE_PARM_DESC(soft_noboot, "Watchdog action, set to 1 to ignore reboots, "
                        "0 to reboot (default 0)");
 MODULE_PARM_DESC(debug, "Watchdog debug, set to >1 for debug (default 0)");
 
+/**
+ * struct s3c2410_wdt_variant - Per-variant config data
+ *
+ * @disable_reg: Offset in pmureg for the register that disables the watchdog
+ * timer reset functionality.
+ * @mask_reset_reg: Offset in pmureg for the register that masks the watchdog
+ * timer reset functionality.
+ * @mask_bit: Bit number for the watchdog timer in the disable register and the
+ * mask reset register.
+ * @rst_stat_reg: Offset in pmureg for the register that has the reset status.
+ * @rst_stat_bit: Bit number in the rst_stat register indicating a watchdog
+ * reset.
+ * @quirks: A bitfield of quirks.
+ */
+
+struct s3c2410_wdt_variant {
+       int disable_reg;
+       int mask_reset_reg;
+       int mask_bit;
+       int rst_stat_reg;
+       int rst_stat_bit;
+       u32 quirks;
+};
+
 struct s3c2410_wdt {
        struct device           *dev;
        struct clk              *clock;
@@ -93,8 +129,54 @@ struct s3c2410_wdt {
        unsigned long           wtdat_save;
        struct watchdog_device  wdt_device;
        struct notifier_block   freq_transition;
+       struct s3c2410_wdt_variant *drv_data;
+       struct regmap *pmureg;
 };
 
+static const struct s3c2410_wdt_variant drv_data_s3c2410 = {
+       .quirks = 0
+};
+
+#ifdef CONFIG_OF
+static const struct s3c2410_wdt_variant drv_data_exynos5250  = {
+       .disable_reg = EXYNOS5_WDT_DISABLE_REG_OFFSET,
+       .mask_reset_reg = EXYNOS5_WDT_MASK_RESET_REG_OFFSET,
+       .mask_bit = 20,
+       .rst_stat_reg = EXYNOS5_RST_STAT_REG_OFFSET,
+       .rst_stat_bit = 20,
+       .quirks = QUIRK_HAS_PMU_CONFIG | QUIRK_HAS_RST_STAT,
+};
+
+static const struct s3c2410_wdt_variant drv_data_exynos5420 = {
+       .disable_reg = EXYNOS5_WDT_DISABLE_REG_OFFSET,
+       .mask_reset_reg = EXYNOS5_WDT_MASK_RESET_REG_OFFSET,
+       .mask_bit = 0,
+       .rst_stat_reg = EXYNOS5_RST_STAT_REG_OFFSET,
+       .rst_stat_bit = 9,
+       .quirks = QUIRK_HAS_PMU_CONFIG | QUIRK_HAS_RST_STAT,
+};
+
+static const struct of_device_id s3c2410_wdt_match[] = {
+       { .compatible = "samsung,s3c2410-wdt",
+         .data = &drv_data_s3c2410 },
+       { .compatible = "samsung,exynos5250-wdt",
+         .data = &drv_data_exynos5250 },
+       { .compatible = "samsung,exynos5420-wdt",
+         .data = &drv_data_exynos5420 },
+       {},
+};
+MODULE_DEVICE_TABLE(of, s3c2410_wdt_match);
+#endif
+
+static const struct platform_device_id s3c2410_wdt_ids[] = {
+       {
+               .name = "s3c2410-wdt",
+               .driver_data = (unsigned long)&drv_data_s3c2410,
+       },
+       {}
+};
+MODULE_DEVICE_TABLE(platform, s3c2410_wdt_ids);
+
 /* watchdog control routines */
 
 #define DBG(fmt, ...)                                  \
@@ -110,6 +192,35 @@ static inline struct s3c2410_wdt *freq_to_wdt(struct notifier_block *nb)
        return container_of(nb, struct s3c2410_wdt, freq_transition);
 }
 
+static int s3c2410wdt_mask_and_disable_reset(struct s3c2410_wdt *wdt, bool mask)
+{
+       int ret;
+       u32 mask_val = 1 << wdt->drv_data->mask_bit;
+       u32 val = 0;
+
+       /* No need to do anything if no PMU CONFIG needed */
+       if (!(wdt->drv_data->quirks & QUIRK_HAS_PMU_CONFIG))
+               return 0;
+
+       if (mask)
+               val = mask_val;
+
+       ret = regmap_update_bits(wdt->pmureg,
+                       wdt->drv_data->disable_reg,
+                       mask_val, val);
+       if (ret < 0)
+               goto error;
+
+       ret = regmap_update_bits(wdt->pmureg,
+                       wdt->drv_data->mask_reset_reg,
+                       mask_val, val);
+ error:
+       if (ret < 0)
+               dev_err(wdt->dev, "failed to update reg(%d)\n", ret);
+
+       return ret;
+}
+
 static int s3c2410wdt_keepalive(struct watchdog_device *wdd)
 {
        struct s3c2410_wdt *wdt = watchdog_get_drvdata(wdd);
@@ -188,7 +299,7 @@ static int s3c2410wdt_set_heartbeat(struct watchdog_device *wdd, unsigned timeou
        if (timeout < 1)
                return -EINVAL;
 
-       freq /= 128;
+       freq = DIV_ROUND_UP(freq, 128);
        count = timeout * freq;
 
        DBG("%s: count=%d, timeout=%d, freq=%lu\n",
@@ -200,21 +311,18 @@ static int s3c2410wdt_set_heartbeat(struct watchdog_device *wdd, unsigned timeou
        */
 
        if (count >= 0x10000) {
-               for (divisor = 1; divisor <= 0x100; divisor++) {
-                       if ((count / divisor) < 0x10000)
-                               break;
-               }
+               divisor = DIV_ROUND_UP(count, 0xffff);
 
-               if ((count / divisor) >= 0x10000) {
+               if (divisor > 0x100) {
                        dev_err(wdt->dev, "timeout %d too big\n", timeout);
                        return -EINVAL;
                }
        }
 
        DBG("%s: timeout=%d, divisor=%d, count=%d (%08x)\n",
-           __func__, timeout, divisor, count, count/divisor);
+           __func__, timeout, divisor, count, DIV_ROUND_UP(count, divisor));
 
-       count /= divisor;
+       count = DIV_ROUND_UP(count, divisor);
        wdt->count = count;
 
        /* update the pre-scaler */
@@ -264,7 +372,7 @@ static irqreturn_t s3c2410wdt_irq(int irqno, void *param)
        return IRQ_HANDLED;
 }
 
-#ifdef CONFIG_CPU_FREQ
+#ifdef CONFIG_ARM_S3C24XX_CPUFREQ
 
 static int s3c2410wdt_cpufreq_transition(struct notifier_block *nb,
                                          unsigned long val, void *data)
@@ -331,6 +439,37 @@ static inline void s3c2410wdt_cpufreq_deregister(struct s3c2410_wdt *wdt)
 }
 #endif
 
+static inline unsigned int s3c2410wdt_get_bootstatus(struct s3c2410_wdt *wdt)
+{
+       unsigned int rst_stat;
+       int ret;
+
+       if (!(wdt->drv_data->quirks & QUIRK_HAS_RST_STAT))
+               return 0;
+
+       ret = regmap_read(wdt->pmureg, wdt->drv_data->rst_stat_reg, &rst_stat);
+       if (ret)
+               dev_warn(wdt->dev, "Couldn't get RST_STAT register\n");
+       else if (rst_stat & BIT(wdt->drv_data->rst_stat_bit))
+               return WDIOF_CARDRESET;
+
+       return 0;
+}
+
+/* s3c2410_get_wdt_driver_data */
+static inline struct s3c2410_wdt_variant *
+get_wdt_drv_data(struct platform_device *pdev)
+{
+       if (pdev->dev.of_node) {
+               const struct of_device_id *match;
+               match = of_match_node(s3c2410_wdt_match, pdev->dev.of_node);
+               return (struct s3c2410_wdt_variant *)match->data;
+       } else {
+               return (struct s3c2410_wdt_variant *)
+                       platform_get_device_id(pdev)->driver_data;
+       }
+}
+
 static int s3c2410wdt_probe(struct platform_device *pdev)
 {
        struct device *dev;
@@ -353,6 +492,16 @@ static int s3c2410wdt_probe(struct platform_device *pdev)
        spin_lock_init(&wdt->lock);
        wdt->wdt_device = s3c2410_wdd;
 
+       wdt->drv_data = get_wdt_drv_data(pdev);
+       if (wdt->drv_data->quirks & QUIRKS_HAVE_PMUREG) {
+               wdt->pmureg = syscon_regmap_lookup_by_phandle(dev->of_node,
+                                               "samsung,syscon-phandle");
+               if (IS_ERR(wdt->pmureg)) {
+                       dev_err(dev, "syscon regmap lookup failed.\n");
+                       return PTR_ERR(wdt->pmureg);
+               }
+       }
+
        wdt_irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
        if (wdt_irq == NULL) {
                dev_err(dev, "no irq resource specified\n");
@@ -415,12 +564,18 @@ static int s3c2410wdt_probe(struct platform_device *pdev)
 
        watchdog_set_nowayout(&wdt->wdt_device, nowayout);
 
+       wdt->wdt_device.bootstatus = s3c2410wdt_get_bootstatus(wdt);
+
        ret = watchdog_register_device(&wdt->wdt_device);
        if (ret) {
                dev_err(dev, "cannot register watchdog (%d)\n", ret);
                goto err_cpufreq;
        }
 
+       ret = s3c2410wdt_mask_and_disable_reset(wdt, false);
+       if (ret < 0)
+               goto err_unregister;
+
        if (tmr_atboot && started == 0) {
                dev_info(dev, "starting watchdog timer\n");
                s3c2410wdt_start(&wdt->wdt_device);
@@ -445,6 +600,9 @@ static int s3c2410wdt_probe(struct platform_device *pdev)
 
        return 0;
 
+ err_unregister:
+       watchdog_unregister_device(&wdt->wdt_device);
+
  err_cpufreq:
        s3c2410wdt_cpufreq_deregister(wdt);
 
@@ -458,8 +616,13 @@ static int s3c2410wdt_probe(struct platform_device *pdev)
 
 static int s3c2410wdt_remove(struct platform_device *dev)
 {
+       int ret;
        struct s3c2410_wdt *wdt = platform_get_drvdata(dev);
 
+       ret = s3c2410wdt_mask_and_disable_reset(wdt, true);
+       if (ret < 0)
+               return ret;
+
        watchdog_unregister_device(&wdt->wdt_device);
 
        s3c2410wdt_cpufreq_deregister(wdt);
@@ -474,6 +637,8 @@ static void s3c2410wdt_shutdown(struct platform_device *dev)
 {
        struct s3c2410_wdt *wdt = platform_get_drvdata(dev);
 
+       s3c2410wdt_mask_and_disable_reset(wdt, true);
+
        s3c2410wdt_stop(&wdt->wdt_device);
 }
 
@@ -481,12 +646,17 @@ static void s3c2410wdt_shutdown(struct platform_device *dev)
 
 static int s3c2410wdt_suspend(struct device *dev)
 {
+       int ret;
        struct s3c2410_wdt *wdt = dev_get_drvdata(dev);
 
        /* Save watchdog state, and turn it off. */
        wdt->wtcon_save = readl(wdt->reg_base + S3C2410_WTCON);
        wdt->wtdat_save = readl(wdt->reg_base + S3C2410_WTDAT);
 
+       ret = s3c2410wdt_mask_and_disable_reset(wdt, true);
+       if (ret < 0)
+               return ret;
+
        /* Note that WTCNT doesn't need to be saved. */
        s3c2410wdt_stop(&wdt->wdt_device);
 
@@ -495,6 +665,7 @@ static int s3c2410wdt_suspend(struct device *dev)
 
 static int s3c2410wdt_resume(struct device *dev)
 {
+       int ret;
        struct s3c2410_wdt *wdt = dev_get_drvdata(dev);
 
        /* Restore watchdog state. */
@@ -502,6 +673,10 @@ static int s3c2410wdt_resume(struct device *dev)
        writel(wdt->wtdat_save, wdt->reg_base + S3C2410_WTCNT);/* Reset count */
        writel(wdt->wtcon_save, wdt->reg_base + S3C2410_WTCON);
 
+       ret = s3c2410wdt_mask_and_disable_reset(wdt, false);
+       if (ret < 0)
+               return ret;
+
        dev_info(dev, "watchdog %sabled\n",
                (wdt->wtcon_save & S3C2410_WTCON_ENABLE) ? "en" : "dis");
 
@@ -512,18 +687,11 @@ static int s3c2410wdt_resume(struct device *dev)
 static SIMPLE_DEV_PM_OPS(s3c2410wdt_pm_ops, s3c2410wdt_suspend,
                        s3c2410wdt_resume);
 
-#ifdef CONFIG_OF
-static const struct of_device_id s3c2410_wdt_match[] = {
-       { .compatible = "samsung,s3c2410-wdt" },
-       {},
-};
-MODULE_DEVICE_TABLE(of, s3c2410_wdt_match);
-#endif
-
 static struct platform_driver s3c2410wdt_driver = {
        .probe          = s3c2410wdt_probe,
        .remove         = s3c2410wdt_remove,
        .shutdown       = s3c2410wdt_shutdown,
+       .id_table       = s3c2410_wdt_ids,
        .driver         = {
                .owner  = THIS_MODULE,
                .name   = "s3c2410-wdt",
@@ -538,4 +706,3 @@ MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>, "
              "Dimitry Andric <dimitry.andric@tomtom.com>");
 MODULE_DESCRIPTION("S3C2410 Watchdog Device Driver");
 MODULE_LICENSE("GPL");
-MODULE_ALIAS("platform:s3c2410-wdt");
index ced3edc95957b471419f069e838084428a67f26b..702d07870808311b36d859570cbf03c096026faa 100644 (file)
@@ -212,7 +212,7 @@ static struct platform_driver sirfsoc_wdt_driver = {
                .name = "sirfsoc-wdt",
                .owner = THIS_MODULE,
                .pm = &sirfsoc_wdt_pm_ops,
-               .of_match_table = of_match_ptr(sirfsoc_wdt_of_match),
+               .of_match_table = sirfsoc_wdt_of_match,
        },
        .probe = sirfsoc_wdt_probe,
        .remove = sirfsoc_wdt_remove,
index ce63a1bbf395fa94ea5833aa0eb98d84aaa5dc75..5cca9cddb87d188f19a33e8e3b6a2fc2851f8a36 100644 (file)
@@ -303,7 +303,7 @@ static struct miscdevice sp5100_tco_miscdev = {
  * register a pci_driver, because someone else might
  * want to register another driver on the same PCI id.
  */
-static DEFINE_PCI_DEVICE_TABLE(sp5100_tco_pci_tbl) = {
+static const struct pci_device_id sp5100_tco_pci_tbl[] = {
        { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_SBX00_SMBUS, PCI_ANY_ID,
          PCI_ANY_ID, },
        { 0, },                 /* End of list */
index 1a68f760cf866a1da43ce6d6a9978daf7ec0d736..d2cd9f0bcb9a2df915472446f295139f04fc0ede 100644 (file)
@@ -239,7 +239,7 @@ static void wdt_remove(struct pci_dev *pdev)
        pci_disable_device(pdev);
 }
 
-static DEFINE_PCI_DEVICE_TABLE(wdt_pci_table) = {
+static const struct pci_device_id wdt_pci_table[] = {
        { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_CX700) },
        { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_VX800) },
        { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_VX855) },
index 461336c4519faf3acee6dad759030a6f0778876d..cec9b559647dee675439058efb07138fe866edb7 100644 (file)
@@ -78,7 +78,7 @@ int watchdog_init_timeout(struct watchdog_device *wdd,
        watchdog_check_min_max_timeout(wdd);
 
        /* try to get the timeout module parameter first */
-       if (!watchdog_timeout_invalid(wdd, timeout_parm)) {
+       if (!watchdog_timeout_invalid(wdd, timeout_parm) && timeout_parm) {
                wdd->timeout = timeout_parm;
                return ret;
        }
@@ -89,7 +89,7 @@ int watchdog_init_timeout(struct watchdog_device *wdd,
        if (dev == NULL || dev->of_node == NULL)
                return ret;
        of_property_read_u32(dev->of_node, "timeout-sec", &t);
-       if (!watchdog_timeout_invalid(wdd, t))
+       if (!watchdog_timeout_invalid(wdd, t) && t)
                wdd->timeout = t;
        else
                ret = -EINVAL;
index ee89ba4dea63c932ecad137b49712191b9a9b799..3dc578e7121110bea28748b16c7a44b6817a566f 100644 (file)
@@ -720,7 +720,7 @@ static void wdtpci_remove_one(struct pci_dev *pdev)
 }
 
 
-static DEFINE_PCI_DEVICE_TABLE(wdtpci_pci_tbl) = {
+static const struct pci_device_id wdtpci_pci_tbl[] = {
        {
                .vendor    = PCI_VENDOR_ID_ACCESSIO,
                .device    = PCI_DEVICE_ID_ACCESSIO_WDG_CSM,