aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/watchdog.h
diff options
context:
space:
mode:
authorJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
committerJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
commit8dea78da5cee153b8af9c07a2745f6c55057fe12 (patch)
treea8f4d49d63b1ecc92f2fddceba0655b2472c5bd9 /include/linux/watchdog.h
parent406089d01562f1e2bf9f089fd7637009ebaad589 (diff)
Patched in Tegra support.
Diffstat (limited to 'include/linux/watchdog.h')
-rw-r--r--include/linux/watchdog.h98
1 files changed, 52 insertions, 46 deletions
diff --git a/include/linux/watchdog.h b/include/linux/watchdog.h
index 3a9df2f43be..111843f88b2 100644
--- a/include/linux/watchdog.h
+++ b/include/linux/watchdog.h
@@ -5,14 +5,59 @@
5 * by Ken Hollis <khollis@bitgate.com> 5 * by Ken Hollis <khollis@bitgate.com>
6 * 6 *
7 */ 7 */
8
8#ifndef _LINUX_WATCHDOG_H 9#ifndef _LINUX_WATCHDOG_H
9#define _LINUX_WATCHDOG_H 10#define _LINUX_WATCHDOG_H
10 11
12#include <linux/ioctl.h>
13#include <linux/types.h>
14
15#define WATCHDOG_IOCTL_BASE 'W'
16
17struct watchdog_info {
18 __u32 options; /* Options the card/driver supports */
19 __u32 firmware_version; /* Firmware version of the card */
20 __u8 identity[32]; /* Identity of the board */
21};
22
23#define WDIOC_GETSUPPORT _IOR(WATCHDOG_IOCTL_BASE, 0, struct watchdog_info)
24#define WDIOC_GETSTATUS _IOR(WATCHDOG_IOCTL_BASE, 1, int)
25#define WDIOC_GETBOOTSTATUS _IOR(WATCHDOG_IOCTL_BASE, 2, int)
26#define WDIOC_GETTEMP _IOR(WATCHDOG_IOCTL_BASE, 3, int)
27#define WDIOC_SETOPTIONS _IOR(WATCHDOG_IOCTL_BASE, 4, int)
28#define WDIOC_KEEPALIVE _IOR(WATCHDOG_IOCTL_BASE, 5, int)
29#define WDIOC_SETTIMEOUT _IOWR(WATCHDOG_IOCTL_BASE, 6, int)
30#define WDIOC_GETTIMEOUT _IOR(WATCHDOG_IOCTL_BASE, 7, int)
31#define WDIOC_SETPRETIMEOUT _IOWR(WATCHDOG_IOCTL_BASE, 8, int)
32#define WDIOC_GETPRETIMEOUT _IOR(WATCHDOG_IOCTL_BASE, 9, int)
33#define WDIOC_GETTIMELEFT _IOR(WATCHDOG_IOCTL_BASE, 10, int)
34
35#define WDIOF_UNKNOWN -1 /* Unknown flag error */
36#define WDIOS_UNKNOWN -1 /* Unknown status error */
11 37
12#include <linux/bitops.h> 38#define WDIOF_OVERHEAT 0x0001 /* Reset due to CPU overheat */
13#include <linux/device.h> 39#define WDIOF_FANFAULT 0x0002 /* Fan failed */
14#include <linux/cdev.h> 40#define WDIOF_EXTERN1 0x0004 /* External relay 1 */
15#include <uapi/linux/watchdog.h> 41#define WDIOF_EXTERN2 0x0008 /* External relay 2 */
42#define WDIOF_POWERUNDER 0x0010 /* Power bad/power fault */
43#define WDIOF_CARDRESET 0x0020 /* Card previously reset the CPU */
44#define WDIOF_POWEROVER 0x0040 /* Power over voltage */
45#define WDIOF_SETTIMEOUT 0x0080 /* Set timeout (in seconds) */
46#define WDIOF_MAGICCLOSE 0x0100 /* Supports magic close char */
47#define WDIOF_PRETIMEOUT 0x0200 /* Pretimeout (in seconds), get/set */
48#define WDIOF_KEEPALIVEPING 0x8000 /* Keep alive ping reply */
49
50#define WDIOS_DISABLECARD 0x0001 /* Turn off the watchdog timer */
51#define WDIOS_ENABLECARD 0x0002 /* Turn on the watchdog timer */
52#define WDIOS_TEMPPANIC 0x0004 /* Kernel panic on temperature trip */
53
54#ifdef __KERNEL__
55
56#ifdef CONFIG_WATCHDOG_NOWAYOUT
57#define WATCHDOG_NOWAYOUT 1
58#else
59#define WATCHDOG_NOWAYOUT 0
60#endif
16 61
17struct watchdog_ops; 62struct watchdog_ops;
18struct watchdog_device; 63struct watchdog_device;
@@ -25,9 +70,6 @@ struct watchdog_device;
25 * @ping: The routine that sends a keepalive ping to the watchdog device. 70 * @ping: The routine that sends a keepalive ping to the watchdog device.
26 * @status: The routine that shows the status of the watchdog device. 71 * @status: The routine that shows the status of the watchdog device.
27 * @set_timeout:The routine for setting the watchdog devices timeout value. 72 * @set_timeout:The routine for setting the watchdog devices timeout value.
28 * @get_timeleft:The routine that get's the time that's left before a reset.
29 * @ref: The ref operation for dyn. allocated watchdog_device structs
30 * @unref: The unref operation for dyn. allocated watchdog_device structs
31 * @ioctl: The routines that handles extra ioctl calls. 73 * @ioctl: The routines that handles extra ioctl calls.
32 * 74 *
33 * The watchdog_ops structure contains a list of low-level operations 75 * The watchdog_ops structure contains a list of low-level operations
@@ -44,18 +86,11 @@ struct watchdog_ops {
44 int (*ping)(struct watchdog_device *); 86 int (*ping)(struct watchdog_device *);
45 unsigned int (*status)(struct watchdog_device *); 87 unsigned int (*status)(struct watchdog_device *);
46 int (*set_timeout)(struct watchdog_device *, unsigned int); 88 int (*set_timeout)(struct watchdog_device *, unsigned int);
47 unsigned int (*get_timeleft)(struct watchdog_device *);
48 void (*ref)(struct watchdog_device *);
49 void (*unref)(struct watchdog_device *);
50 long (*ioctl)(struct watchdog_device *, unsigned int, unsigned long); 89 long (*ioctl)(struct watchdog_device *, unsigned int, unsigned long);
51}; 90};
52 91
53/** struct watchdog_device - The structure that defines a watchdog device 92/** struct watchdog_device - The structure that defines a watchdog device
54 * 93 *
55 * @id: The watchdog's ID. (Allocated by watchdog_register_device)
56 * @cdev: The watchdog's Character device.
57 * @dev: The device for our watchdog
58 * @parent: The parent bus device
59 * @info: Pointer to a watchdog_info structure. 94 * @info: Pointer to a watchdog_info structure.
60 * @ops: Pointer to the list of watchdog operations. 95 * @ops: Pointer to the list of watchdog operations.
61 * @bootstatus: Status of the watchdog device at boot. 96 * @bootstatus: Status of the watchdog device at boot.
@@ -63,7 +98,6 @@ struct watchdog_ops {
63 * @min_timeout:The watchdog devices minimum timeout value. 98 * @min_timeout:The watchdog devices minimum timeout value.
64 * @max_timeout:The watchdog devices maximum timeout value. 99 * @max_timeout:The watchdog devices maximum timeout value.
65 * @driver-data:Pointer to the drivers private data. 100 * @driver-data:Pointer to the drivers private data.
66 * @lock: Lock for watchdog core internal use only.
67 * @status: Field that contains the devices internal status bits. 101 * @status: Field that contains the devices internal status bits.
68 * 102 *
69 * The watchdog_device structure contains all information about a 103 * The watchdog_device structure contains all information about a
@@ -71,15 +105,8 @@ struct watchdog_ops {
71 * 105 *
72 * The driver-data field may not be accessed directly. It must be accessed 106 * The driver-data field may not be accessed directly. It must be accessed
73 * via the watchdog_set_drvdata and watchdog_get_drvdata helpers. 107 * via the watchdog_set_drvdata and watchdog_get_drvdata helpers.
74 *
75 * The lock field is for watchdog core internal use only and should not be
76 * touched.
77 */ 108 */
78struct watchdog_device { 109struct watchdog_device {
79 int id;
80 struct cdev cdev;
81 struct device *dev;
82 struct device *parent;
83 const struct watchdog_info *info; 110 const struct watchdog_info *info;
84 const struct watchdog_ops *ops; 111 const struct watchdog_ops *ops;
85 unsigned int bootstatus; 112 unsigned int bootstatus;
@@ -87,37 +114,14 @@ struct watchdog_device {
87 unsigned int min_timeout; 114 unsigned int min_timeout;
88 unsigned int max_timeout; 115 unsigned int max_timeout;
89 void *driver_data; 116 void *driver_data;
90 struct mutex lock;
91 unsigned long status; 117 unsigned long status;
92/* Bit numbers for status flags */ 118/* Bit numbers for status flags */
93#define WDOG_ACTIVE 0 /* Is the watchdog running/active */ 119#define WDOG_ACTIVE 0 /* Is the watchdog running/active */
94#define WDOG_DEV_OPEN 1 /* Opened via /dev/watchdog ? */ 120#define WDOG_DEV_OPEN 1 /* Opened via /dev/watchdog ? */
95#define WDOG_ALLOW_RELEASE 2 /* Did we receive the magic char ? */ 121#define WDOG_ALLOW_RELEASE 2 /* Did we receive the magic char ? */
96#define WDOG_NO_WAY_OUT 3 /* Is 'nowayout' feature set ? */ 122#define WDOG_NO_WAY_OUT 3 /* Is 'nowayout' feature set ? */
97#define WDOG_UNREGISTERED 4 /* Has the device been unregistered */
98}; 123};
99 124
100#ifdef CONFIG_WATCHDOG_NOWAYOUT
101#define WATCHDOG_NOWAYOUT 1
102#define WATCHDOG_NOWAYOUT_INIT_STATUS (1 << WDOG_NO_WAY_OUT)
103#else
104#define WATCHDOG_NOWAYOUT 0
105#define WATCHDOG_NOWAYOUT_INIT_STATUS 0
106#endif
107
108/* Use the following function to check whether or not the watchdog is active */
109static inline bool watchdog_active(struct watchdog_device *wdd)
110{
111 return test_bit(WDOG_ACTIVE, &wdd->status);
112}
113
114/* Use the following function to set the nowayout feature */
115static inline void watchdog_set_nowayout(struct watchdog_device *wdd, bool nowayout)
116{
117 if (nowayout)
118 set_bit(WDOG_NO_WAY_OUT, &wdd->status);
119}
120
121/* Use the following functions to manipulate watchdog driver specific data */ 125/* Use the following functions to manipulate watchdog driver specific data */
122static inline void watchdog_set_drvdata(struct watchdog_device *wdd, void *data) 126static inline void watchdog_set_drvdata(struct watchdog_device *wdd, void *data)
123{ 127{
@@ -129,8 +133,10 @@ static inline void *watchdog_get_drvdata(struct watchdog_device *wdd)
129 return wdd->driver_data; 133 return wdd->driver_data;
130} 134}
131 135
132/* drivers/watchdog/watchdog_core.c */ 136/* drivers/watchdog/core/watchdog_core.c */
133extern int watchdog_register_device(struct watchdog_device *); 137extern int watchdog_register_device(struct watchdog_device *);
134extern void watchdog_unregister_device(struct watchdog_device *); 138extern void watchdog_unregister_device(struct watchdog_device *);
135 139
140#endif /* __KERNEL__ */
141
136#endif /* ifndef _LINUX_WATCHDOG_H */ 142#endif /* ifndef _LINUX_WATCHDOG_H */