aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/watchdog
diff options
context:
space:
mode:
authorPaul Walmsley <paul@pwsan.com>2012-10-29 22:49:44 -0400
committerPaul Walmsley <paul@pwsan.com>2012-11-08 14:33:07 -0500
commit129f557723701b20257f5ad4deb89aac0afb95ac (patch)
tree5dd1c9e652aeaa92f78edacfcbfd0963ad26da97 /drivers/watchdog
parent37c67d03989eca60b28d67398d9388f653454c5d (diff)
watchdog: OMAP: use standard GETBOOTSTATUS interface; use platform_data fn ptr
Previously the OMAP watchdog driver used a non-standard way to report the chip reset source via the GETBOOTSTATUS ioctl. This patch converts the driver to use the standard WDIOF_* flags for this purpose. This patch may break existing userspace code that uses the existing non-standard data format returned by the OMAP watchdog driver's GETBOOTSTATUS ioctl. To fetch detailed reset source information, userspace code will need to retrieve it directly from the CGRM or PRM drivers when those are completed. Previously, to fetch the reset source, the driver either read a register outside the watchdog IP block (OMAP1), or called a function exported directly from arch/arm/mach-omap2. Both approaches are broken. This patch also converts the driver to use a platform_data function pointer. This approach is temporary, and is due to the lack of drivers for the OMAP16xx+ Clock Generation and Reset Management IP block and the OMAP2+ Power and Reset Management IP block. Once drivers are available for those IP blocks, the watchdog driver can be converted to call exported functions from those drivers directly. At that point, the platform_data function pointer can be removed. In the short term, this patch is needed to allow the PRM code to be removed from arch/arm/mach-omap2 (it is being moved to a driver). This version integrates a fix from Jon Hunter <jon-hunter@ti.com> that avoids a NULL pointer dereference in a DT-only boot, and integrates a patch commit message fix from Felipe Balbi <balbi@ti.com>. Signed-off-by: Paul Walmsley <paul@pwsan.com> Cc: Wim Van Sebroeck <wim@iguana.be> Acked-by: Wim Van Sebroeck <wim@iguana.be> [paul@pwsan.com: integrated pdata fix from Jon Hunter] Cc: Jon Hunter <jon-hunter@ti.com> [paul@pwsan.com: integrated changelog fix from Felipe Balbi] Cc: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/watchdog')
-rw-r--r--drivers/watchdog/omap_wdt.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/drivers/watchdog/omap_wdt.c b/drivers/watchdog/omap_wdt.c
index f5db18dbc0f..477a1d47a64 100644
--- a/drivers/watchdog/omap_wdt.c
+++ b/drivers/watchdog/omap_wdt.c
@@ -46,8 +46,8 @@
46#include <linux/slab.h> 46#include <linux/slab.h>
47#include <linux/pm_runtime.h> 47#include <linux/pm_runtime.h>
48#include <mach/hardware.h> 48#include <mach/hardware.h>
49#include <plat/cpu.h> 49
50#include <plat/prcm.h> 50#include <linux/platform_data/omap-wd-timer.h>
51 51
52#include "omap_wdt.h" 52#include "omap_wdt.h"
53 53
@@ -202,8 +202,10 @@ static ssize_t omap_wdt_write(struct file *file, const char __user *data,
202static long omap_wdt_ioctl(struct file *file, unsigned int cmd, 202static long omap_wdt_ioctl(struct file *file, unsigned int cmd,
203 unsigned long arg) 203 unsigned long arg)
204{ 204{
205 struct omap_wd_timer_platform_data *pdata;
205 struct omap_wdt_dev *wdev; 206 struct omap_wdt_dev *wdev;
206 int new_margin; 207 u32 rs;
208 int new_margin, bs;
207 static const struct watchdog_info ident = { 209 static const struct watchdog_info ident = {
208 .identity = "OMAP Watchdog", 210 .identity = "OMAP Watchdog",
209 .options = WDIOF_SETTIMEOUT, 211 .options = WDIOF_SETTIMEOUT,
@@ -211,6 +213,7 @@ static long omap_wdt_ioctl(struct file *file, unsigned int cmd,
211 }; 213 };
212 214
213 wdev = file->private_data; 215 wdev = file->private_data;
216 pdata = wdev->dev->platform_data;
214 217
215 switch (cmd) { 218 switch (cmd) {
216 case WDIOC_GETSUPPORT: 219 case WDIOC_GETSUPPORT:
@@ -219,17 +222,12 @@ static long omap_wdt_ioctl(struct file *file, unsigned int cmd,
219 case WDIOC_GETSTATUS: 222 case WDIOC_GETSTATUS:
220 return put_user(0, (int __user *)arg); 223 return put_user(0, (int __user *)arg);
221 case WDIOC_GETBOOTSTATUS: 224 case WDIOC_GETBOOTSTATUS:
222#ifdef CONFIG_ARCH_OMAP1 225 if (!pdata || !pdata->read_reset_sources)
223 if (cpu_is_omap16xx()) 226 return put_user(0, (int __user *)arg);
224 return put_user(__raw_readw(ARM_SYSST), 227 rs = pdata->read_reset_sources();
225 (int __user *)arg); 228 bs = (rs & (1 << OMAP_MPU_WD_RST_SRC_ID_SHIFT)) ?
226#endif 229 WDIOF_CARDRESET : 0;
227#ifdef CONFIG_ARCH_OMAP2PLUS 230 return put_user(bs, (int __user *)arg);
228 if (cpu_is_omap24xx())
229 return put_user(omap_prcm_get_reset_sources(),
230 (int __user *)arg);
231#endif
232 return put_user(0, (int __user *)arg);
233 case WDIOC_KEEPALIVE: 231 case WDIOC_KEEPALIVE:
234 spin_lock(&wdt_lock); 232 spin_lock(&wdt_lock);
235 omap_wdt_ping(wdev); 233 omap_wdt_ping(wdev);