From: Marc Vertes <marc.vertes@sigfox.com>
To: w.sang@pengutronix.de
Cc: Wim@vger.kernel.org, wim@iguana.be, Welte@vger.kernel.org,
Van@vger.kernel.org, Sebroeck@vger.kernel.org,
linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org,
HaraldWelte@viatech.com, Harald@vger.kernel.org
Subject: Re: [PATCH RFC] watchdog: add a new driver for VIA chipsets
Date: Tue, 22 Nov 2011 19:55:13 +0100 [thread overview]
Message-ID: <4ecbf011.dZASXe6D5kH4Uxve%marc.vertes@sigfox.com> (raw)
In-Reply-To: <4ecbe56d.0B7WEVDKkK1s88MJ%marc.vertes@sigfox.com>
Marc Vertes <marc.vertes@sigfox.com> wrote:
> Thanks for your comments, I'm preparing an update.
Here:
---
Add a new driver for the hardware watchdog timer on VIA chipsets.
This driver uses the new watchdog framework.
Tested on a Artigo A1100, VX855 chipset.
Signed-off-by: Marc Vertes <marc.vertes@sigfox.com>
---
Kconfig | 14 ++++++
Makefile | 1
via_wdt.c | 132 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 147 insertions(+)
--- linux-3.2-rc2/drivers/watchdog/Makefile.orig 2011-11-15 18:02:59.000000000 +0100
+++ linux-3.2-rc2/drivers/watchdog/Makefile 2011-11-18 18:13:36.594534635 +0100
@@ -100,6 +100,7 @@ obj-$(CONFIG_SBC7240_WDT) += sbc7240_wdt
obj-$(CONFIG_CPU5_WDT) += cpu5wdt.o
obj-$(CONFIG_SMSC_SCH311X_WDT) += sch311x_wdt.o
obj-$(CONFIG_SMSC37B787_WDT) += smsc37b787_wdt.o
+obj-$(CONFIG_VIA_WDT) += via_wdt.o
obj-$(CONFIG_W83627HF_WDT) += w83627hf_wdt.o
obj-$(CONFIG_W83697HF_WDT) += w83697hf_wdt.o
obj-$(CONFIG_W83697UG_WDT) += w83697ug_wdt.o
--- linux-3.2-rc2/drivers/watchdog/via_wdt.c.orig 2011-11-18 18:14:45.358174874 +0100
+++ linux-3.2-rc2/drivers/watchdog/via_wdt.c 2011-11-22 19:42:06.219529719 +0100
@@ -0,0 +1,132 @@
+/*
+ * VIA Chipset Watchdog Driver
+ *
+ * Copyright (C) 2011 Sigfox
+ * License terms: GNU General Public License (GPL) version 2
+ * Author: Marc Vertes <marc.vertes@sigfox.com>
+ * Based on a preliminary version from Harald Welte <HaraldWelte@viatech.com>
+ *
+ * The only way to activate the watchdog timer or to set its period is
+ * through BIOS setup.
+ */
+#include <linux/device.h>
+#include <linux/io.h>
+#include <linux/module.h>
+#include <linux/pci.h>
+#include <linux/watchdog.h>
+
+#define VIA_WDT_MB_OFFSET 0xe8 /* memory base offset */
+#define VIA_WDT_TRIGGER 0x80 /* start a new countdown */
+#define VIA_WDT_FIRED 0x02 /* set if last restart was caused
+ by expired watchdog timer */
+
+static int wdt_start(struct watchdog_device *wdev)
+{
+ /* Nothing to do. The watchdog can only be started by the BIOS. */
+ return 0;
+}
+
+static int wdt_stop(struct watchdog_device *wdev)
+{
+ /* Nothing to do. The watchdog can not be stopped. */
+ return 0;
+}
+
+static int wdt_ping(struct watchdog_device *wdev)
+{
+ void __iomem *wdt_mem = watchdog_get_drvdata(wdev);
+ unsigned int res = readl(wdt_mem); /* get status bits */
+
+ writel(res | VIA_WDT_TRIGGER, wdt_mem);
+ return 0;
+}
+
+static struct watchdog_info wdt_info = {
+ .identity = "VIA watchdog",
+ .options = WDIOF_CARDRESET,
+};
+
+static struct watchdog_ops wdt_ops = {
+ .owner = THIS_MODULE,
+ .start = wdt_start,
+ .stop = wdt_stop,
+ .ping = wdt_ping,
+};
+
+static struct watchdog_device wdt_dev = {
+ .info = &wdt_info,
+ .ops = &wdt_ops,
+};
+
+static int __devinit wdt_probe(struct pci_dev *pdev,
+ const struct pci_device_id *ent)
+{
+ unsigned int mmio = 0;
+ void __iomem *wdt_mem;
+ int ret;
+
+ if (pci_enable_device(pdev)) {
+ dev_err(&pdev->dev, "cannot enable PCI device\n");
+ return -ENODEV;
+ }
+ pci_read_config_dword(pdev, VIA_WDT_MB_OFFSET, &mmio);
+ if (mmio) {
+ dev_info(&pdev->dev, "VIA Chipset watchdog MMIO: %x\n", mmio);
+ } else {
+ dev_err(&pdev->dev, "watchdog timer is not enabled in BIOS\n");
+ return -ENODEV;
+ }
+ wdt_mem = ioremap(mmio, 8);
+ if (wdt_mem == NULL) {
+ dev_err(&pdev->dev, "cannot remap VIA wdt MMIO registers\n");
+ return -ENODEV;
+ }
+ ret = watchdog_register_device(&wdt_dev);
+ if (ret) {
+ iounmap(wdt_mem);
+ return ret;
+ }
+ watchdog_set_drvdata(&wdt_dev, wdt_mem);
+ if (readl(wdt_mem) & VIA_WDT_FIRED)
+ wdt_dev.bootstatus |= WDIOF_CARDRESET;
+ return 0;
+}
+
+static void __devexit wdt_remove(struct pci_dev *dev)
+{
+ void __iomem *wdt_mem = watchdog_get_drvdata(&wdt_dev);
+
+ watchdog_unregister_device(&wdt_dev);
+ iounmap(wdt_mem);
+}
+
+DEFINE_PCI_DEVICE_TABLE(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) },
+ { 0 }
+};
+
+static struct pci_driver wdt_driver = {
+ .name = "via_wdt",
+ .id_table = wdt_pci_table,
+ .probe = wdt_probe,
+ .remove = __devexit_p(wdt_remove),
+};
+
+static int __init wdt_init(void)
+{
+ return pci_register_driver(&wdt_driver);
+}
+
+static void __exit wdt_exit(void)
+{
+ pci_unregister_driver(&wdt_driver);
+}
+
+module_init(wdt_init);
+module_exit(wdt_exit);
+
+MODULE_AUTHOR("Marc Vertes");
+MODULE_DESCRIPTION("Driver for watchdog timer on VIA chipset");
+MODULE_LICENSE("GPL");
--- linux-3.2-rc2/drivers/watchdog/Kconfig.orig 2011-11-15 18:02:59.000000000 +0100
+++ linux-3.2-rc2/drivers/watchdog/Kconfig 2011-11-22 16:39:38.175325620 +0100
@@ -779,6 +779,20 @@ config SMSC37B787_WDT
Most people will say N.
+config VIA_WDT
+ tristate "VIA Watchdog Timer"
+ depends on X86
+ select WATCHDOG_CORE
+ ---help---
+ This is the driver for the hardware watchdog timer on VIA
+ southbridge chipset CX700, VX800, VX855. Watchdog setup
+ in BIOS is required.
+
+ To compile this driver as a module, choose M here; the module
+ will be called via_wdt.
+
+ Most people will say N.
+
config W83627HF_WDT
tristate "W83627HF/W83627DHG Watchdog Timer"
depends on X86
next prev parent reply other threads:[~2011-11-22 18:55 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-22 11:17 Marc Vertes
2011-11-22 11:22 ` Wolfram Sang
2011-11-22 12:56 ` Rahul Bedarkar
2011-11-22 17:05 ` Marc Vertes
2011-11-22 17:30 ` Wolfram Sang
2011-11-22 18:09 ` Marc Vertes
2011-11-22 18:55 ` Marc Vertes [this message]
2011-11-23 12:10 ` Dmitry Artamonow
2011-11-23 14:12 ` Marc Vertes
2011-11-23 14:37 ` Mark Brown
2011-11-23 19:25 ` Dmitry Artamonow
2011-11-23 21:43 ` Wolfram Sang
2011-11-23 18:22 ` Harald Welte
2011-11-23 21:41 ` Wim Van Sebroeck
2011-11-24 19:22 ` Marc Vertes
2011-11-24 19:34 ` Wim Van Sebroeck
2011-11-25 20:02 ` Marc Vertes
2011-11-22 17:32 ` Mark Brown
2011-11-22 18:40 ` Wolfram Sang
2011-11-23 9:59 ` Marc Vertes
2011-11-23 10:49 ` Wolfram Sang
2011-11-23 11:43 ` Marc Vertes
2011-11-23 12:13 ` Wim Van Sebroeck
2011-11-23 12:20 ` Mark Brown
2011-11-23 12:40 ` Wim Van Sebroeck
2011-11-23 14:46 ` Marc Vertes
2011-11-23 21:43 ` Wim Van Sebroeck
2011-11-23 21:52 ` Wolfram Sang
2011-11-24 8:29 ` Wim Van Sebroeck
2011-11-23 21:46 ` Wim Van Sebroeck
2011-11-24 10:57 ` Marc Vertes
2011-11-24 13:42 ` Wim Van Sebroeck
2011-11-24 14:42 ` Marc Vertes
2011-11-24 15:48 ` Wim Van Sebroeck
2011-11-24 16:47 ` Marc Vertes
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4ecbf011.dZASXe6D5kH4Uxve%marc.vertes@sigfox.com \
--to=marc.vertes@sigfox.com \
--cc=Harald@vger.kernel.org \
--cc=HaraldWelte@viatech.com \
--cc=Sebroeck@vger.kernel.org \
--cc=Van@vger.kernel.org \
--cc=Welte@vger.kernel.org \
--cc=Wim@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-watchdog@vger.kernel.org \
--cc=w.sang@pengutronix.de \
--cc=wim@iguana.be \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®