From: Timur Tabi <timur@freescale.com>
To: benh@kernel.crashing.org, linuxppc-dev@ozlabs.org,
kumar.gala@freescale.com, linux-watchdog@vger.kernel.org
Subject: [PATCH 2/2] powerpc/watchdog: allow the e500 watchdog driver to be compiled as a module
Date: Fri, 17 Sep 2010 17:53:28 -0500 [thread overview]
Message-ID: <1284764008-19469-2-git-send-email-timur@freescale.com> (raw)
In-Reply-To: <1284764008-19469-1-git-send-email-timur@freescale.com>
Register the __init and __exit functions in the PowerPC e500 watchdog driver
as module entry/exit functions, and modify the Kconfig entry.
Add a .release method for the PowerPC e500 watchdog driver, so that the
watchdog is disabled when the driver is closed.
Loosely based on original code from Jiang Yutang <b14898@freescale.com>.
Signed-off-by: Timur Tabi <timur@freescale.com>
---
This patch requires:
powerpc: export ppc_tb_freq so that modules can reference it
drivers/watchdog/Kconfig | 5 ++++-
drivers/watchdog/booke_wdt.c | 39 +++++++++++++++++++++++++++++++++++++--
2 files changed, 41 insertions(+), 3 deletions(-)
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index 24efd8e..d9cf5a9 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -957,9 +957,12 @@ config PIKA_WDT
the Warp platform.
config BOOKE_WDT
- bool "PowerPC Book-E Watchdog Timer"
+ tristate "PowerPC Book-E Watchdog Timer"
depends on BOOKE || 4xx
---help---
+ Watchdog driver for PowerPC e500 chips, such as the Freescale
+ MPC85xx SOCs.
+
Please see Documentation/watchdog/watchdog-api.txt for
more information.
diff --git a/drivers/watchdog/booke_wdt.c b/drivers/watchdog/booke_wdt.c
index 3d49671..a989998 100644
--- a/drivers/watchdog/booke_wdt.c
+++ b/drivers/watchdog/booke_wdt.c
@@ -4,7 +4,7 @@
* Author: Matthew McClintock
* Maintainer: Kumar Gala <galak@kernel.crashing.org>
*
- * Copyright 2005, 2008 Freescale Semiconductor Inc.
+ * Copyright 2005, 2008, 2010 Freescale Semiconductor Inc.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
@@ -114,6 +114,27 @@ static void __booke_wdt_enable(void *data)
mtspr(SPRN_TCR, val);
}
+/**
+ * booke_wdt_disable - disable the watchdog on the given CPU
+ *
+ * This function is called on each CPU. It disables the watchdog on that CPU.
+ *
+ * TCR[WRC] cannot be changed once it has been set to non-zero, but we can
+ * effectively disable the watchdog by setting its period to the maximum value.
+ */
+static void __booke_wdt_disable(void *data)
+{
+ u32 val;
+
+ val = mfspr(SPRN_TCR);
+ val &= ~(TCR_WIE | WDTP_MASK);
+ mtspr(SPRN_TCR, val);
+
+ /* clear status to make sure nothing is pending */
+ __booke_wdt_ping(NULL);
+
+}
+
static ssize_t booke_wdt_write(struct file *file, const char __user *buf,
size_t count, loff_t *ppos)
{
@@ -193,12 +214,21 @@ static int booke_wdt_open(struct inode *inode, struct file *file)
return nonseekable_open(inode, file);
}
+static int booke_wdt_release(struct inode *inode, struct file *file)
+{
+ on_each_cpu(__booke_wdt_disable, NULL, 0);
+ booke_wdt_enabled = 0;
+
+ return 0;
+}
+
static const struct file_operations booke_wdt_fops = {
.owner = THIS_MODULE,
.llseek = no_llseek,
.write = booke_wdt_write,
.unlocked_ioctl = booke_wdt_ioctl,
.open = booke_wdt_open,
+ .release = booke_wdt_release,
};
static struct miscdevice booke_wdt_miscdev = {
@@ -237,4 +267,9 @@ static int __init booke_wdt_init(void)
return ret;
}
-device_initcall(booke_wdt_init);
+
+module_init(booke_wdt_init);
+module_exit(booke_wdt_exit);
+
+MODULE_DESCRIPTION("PowerPC Book-E watchdog driver");
+MODULE_LICENSE("GPL");
--
1.7.2.3
next prev parent reply other threads:[~2010-09-17 23:08 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-17 22:53 [PATCH 1/2] powerpc: export ppc_tb_freq so that modules can reference it Timur Tabi
2010-09-17 22:53 ` Timur Tabi [this message]
2010-09-18 0:37 ` [PATCH 2/2] powerpc/watchdog: allow the e500 watchdog driver to be compiled as a module Josh Boyer
2010-09-20 15:51 ` Timur Tabi
2010-09-20 19:30 ` Josh Boyer
2010-09-20 19:53 ` Timur Tabi
2010-09-18 0:38 ` [PATCH 1/2] powerpc: export ppc_tb_freq so that modules can reference it Josh Boyer
2010-09-18 1:20 ` Timur Tabi
2010-09-18 3:14 ` Benjamin Herrenschmidt
2010-09-18 14:36 ` Tabi Timur-B04825
2010-09-18 15:34 ` Kumar Gala
2010-09-18 15:52 ` Vitaly Wool
2010-09-18 16:56 ` Josh Boyer
2010-09-18 17:36 ` Tabi Timur-B04825
2010-09-18 17:46 ` Josh Boyer
2010-09-18 17:55 ` Tabi Timur-B04825
2010-09-18 18:22 ` Josh Boyer
2010-09-20 18:51 ` Scott Wood
[not found] ` <20100920135136.04ceb772__36164.799918379$1285008751$gmane$org@udp111988uds.am.freescale.net>
2010-09-21 12:34 ` Detlev Zundel
2010-09-18 18:36 ` Kumar Gala
2010-09-19 2:42 ` Benjamin Herrenschmidt
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=1284764008-19469-2-git-send-email-timur@freescale.com \
--to=timur@freescale.com \
--cc=benh@kernel.crashing.org \
--cc=kumar.gala@freescale.com \
--cc=linux-watchdog@vger.kernel.org \
--cc=linuxppc-dev@ozlabs.org \
/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;
as well as URLs for NNTP newsgroup(s).