diff options
author | Timur Tabi <timur@freescale.com> | 2010-09-20 12:23:42 -0400 |
---|---|---|
committer | Kumar Gala <galak@kernel.crashing.org> | 2010-10-14 01:52:44 -0400 |
commit | fbdd7144ceadd578bc2a875af1dabd67e80ba0d0 (patch) | |
tree | a60c4bde8498c38da4b8897fb7083e7cdad5a900 /drivers | |
parent | 55ec2fca3e99f83b5c674e9aba713d848392f6cc (diff) |
powerpc/watchdog: Allow the Book-E driver to be compiled as a module
Register the __init and __exit functions in the PowerPC Book-E Watchdog
driver as module entry/exit functions, and modify the Kconfig entry.
Add a .release method for the PowerPC Book-E 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>
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/watchdog/Kconfig | 5 | ||||
-rw-r--r-- | drivers/watchdog/booke_wdt.c | 39 |
2 files changed, 41 insertions, 3 deletions
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig index 24efd8ea41bb..a6812eb31fa1 100644 --- a/drivers/watchdog/Kconfig +++ b/drivers/watchdog/Kconfig | |||
@@ -957,9 +957,12 @@ config PIKA_WDT | |||
957 | the Warp platform. | 957 | the Warp platform. |
958 | 958 | ||
959 | config BOOKE_WDT | 959 | config BOOKE_WDT |
960 | bool "PowerPC Book-E Watchdog Timer" | 960 | tristate "PowerPC Book-E Watchdog Timer" |
961 | depends on BOOKE || 4xx | 961 | depends on BOOKE || 4xx |
962 | ---help--- | 962 | ---help--- |
963 | Watchdog driver for PowerPC Book-E chips, such as the Freescale | ||
964 | MPC85xx SOCs and the IBM PowerPC 440. | ||
965 | |||
963 | Please see Documentation/watchdog/watchdog-api.txt for | 966 | Please see Documentation/watchdog/watchdog-api.txt for |
964 | more information. | 967 | more information. |
965 | 968 | ||
diff --git a/drivers/watchdog/booke_wdt.c b/drivers/watchdog/booke_wdt.c index 3d49671cdf5a..a9899981fd97 100644 --- a/drivers/watchdog/booke_wdt.c +++ b/drivers/watchdog/booke_wdt.c | |||
@@ -4,7 +4,7 @@ | |||
4 | * Author: Matthew McClintock | 4 | * Author: Matthew McClintock |
5 | * Maintainer: Kumar Gala <galak@kernel.crashing.org> | 5 | * Maintainer: Kumar Gala <galak@kernel.crashing.org> |
6 | * | 6 | * |
7 | * Copyright 2005, 2008 Freescale Semiconductor Inc. | 7 | * Copyright 2005, 2008, 2010 Freescale Semiconductor Inc. |
8 | * | 8 | * |
9 | * This program is free software; you can redistribute it and/or modify it | 9 | * This program is free software; you can redistribute it and/or modify it |
10 | * under the terms of the GNU General Public License as published by the | 10 | * under the terms of the GNU General Public License as published by the |
@@ -114,6 +114,27 @@ static void __booke_wdt_enable(void *data) | |||
114 | mtspr(SPRN_TCR, val); | 114 | mtspr(SPRN_TCR, val); |
115 | } | 115 | } |
116 | 116 | ||
117 | /** | ||
118 | * booke_wdt_disable - disable the watchdog on the given CPU | ||
119 | * | ||
120 | * This function is called on each CPU. It disables the watchdog on that CPU. | ||
121 | * | ||
122 | * TCR[WRC] cannot be changed once it has been set to non-zero, but we can | ||
123 | * effectively disable the watchdog by setting its period to the maximum value. | ||
124 | */ | ||
125 | static void __booke_wdt_disable(void *data) | ||
126 | { | ||
127 | u32 val; | ||
128 | |||
129 | val = mfspr(SPRN_TCR); | ||
130 | val &= ~(TCR_WIE | WDTP_MASK); | ||
131 | mtspr(SPRN_TCR, val); | ||
132 | |||
133 | /* clear status to make sure nothing is pending */ | ||
134 | __booke_wdt_ping(NULL); | ||
135 | |||
136 | } | ||
137 | |||
117 | static ssize_t booke_wdt_write(struct file *file, const char __user *buf, | 138 | static ssize_t booke_wdt_write(struct file *file, const char __user *buf, |
118 | size_t count, loff_t *ppos) | 139 | size_t count, loff_t *ppos) |
119 | { | 140 | { |
@@ -193,12 +214,21 @@ static int booke_wdt_open(struct inode *inode, struct file *file) | |||
193 | return nonseekable_open(inode, file); | 214 | return nonseekable_open(inode, file); |
194 | } | 215 | } |
195 | 216 | ||
217 | static int booke_wdt_release(struct inode *inode, struct file *file) | ||
218 | { | ||
219 | on_each_cpu(__booke_wdt_disable, NULL, 0); | ||
220 | booke_wdt_enabled = 0; | ||
221 | |||
222 | return 0; | ||
223 | } | ||
224 | |||
196 | static const struct file_operations booke_wdt_fops = { | 225 | static const struct file_operations booke_wdt_fops = { |
197 | .owner = THIS_MODULE, | 226 | .owner = THIS_MODULE, |
198 | .llseek = no_llseek, | 227 | .llseek = no_llseek, |
199 | .write = booke_wdt_write, | 228 | .write = booke_wdt_write, |
200 | .unlocked_ioctl = booke_wdt_ioctl, | 229 | .unlocked_ioctl = booke_wdt_ioctl, |
201 | .open = booke_wdt_open, | 230 | .open = booke_wdt_open, |
231 | .release = booke_wdt_release, | ||
202 | }; | 232 | }; |
203 | 233 | ||
204 | static struct miscdevice booke_wdt_miscdev = { | 234 | static struct miscdevice booke_wdt_miscdev = { |
@@ -237,4 +267,9 @@ static int __init booke_wdt_init(void) | |||
237 | 267 | ||
238 | return ret; | 268 | return ret; |
239 | } | 269 | } |
240 | device_initcall(booke_wdt_init); | 270 | |
271 | module_init(booke_wdt_init); | ||
272 | module_exit(booke_wdt_exit); | ||
273 | |||
274 | MODULE_DESCRIPTION("PowerPC Book-E watchdog driver"); | ||
275 | MODULE_LICENSE("GPL"); | ||