Source
23
23
* Ported driver to kernel 2.6
24
24
* 20171016 Radu Rendec <rrendec@arista.com>
25
25
* Change driver to use the watchdog subsystem
26
26
* Add support for multiple 6300ESB devices
27
27
*/
28
28
29
29
/*
30
30
* Includes, defines, variables, module parameters, ...
31
31
*/
32
32
33
-
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
34
-
35
33
#include <linux/module.h>
36
34
#include <linux/types.h>
37
35
#include <linux/kernel.h>
38
36
#include <linux/fs.h>
39
37
#include <linux/mm.h>
40
38
#include <linux/miscdevice.h>
41
39
#include <linux/watchdog.h>
42
40
#include <linux/pci.h>
43
41
#include <linux/ioport.h>
44
42
#include <linux/uaccess.h>
45
43
#include <linux/io.h>
46
44
47
45
/* Module and version information */
48
-
#define ESB_VERSION "0.05"
49
46
#define ESB_MODULE_NAME "i6300ESB timer"
50
47
51
48
/* PCI configuration registers */
52
49
#define ESB_CONFIG_REG 0x60 /* Config register */
53
50
#define ESB_LOCK_REG 0x68 /* WDT lock register */
54
51
55
52
/* Memory mapped registers */
56
53
#define ESB_TIMER1_REG(w) ((w)->base + 0x00)/* Timer1 value after each reset */
57
54
#define ESB_TIMER2_REG(w) ((w)->base + 0x04)/* Timer2 value after each reset */
58
55
#define ESB_GINTSR_REG(w) ((w)->base + 0x08)/* General Interrupt Status Reg */
69
66
#define ESB_WDT_INTTYPE (0x03 << 0) /* Interrupt type on timer1 timeout */
70
67
71
68
/* Reload register bits */
72
69
#define ESB_WDT_TIMEOUT (0x01 << 9) /* Watchdog timed out */
73
70
#define ESB_WDT_RELOAD (0x01 << 8) /* prevent timeout */
74
71
75
72
/* Magic constants */
76
73
#define ESB_UNLOCK1 0x80 /* Step 1 to unlock reset registers */
77
74
#define ESB_UNLOCK2 0x86 /* Step 2 to unlock reset registers */
78
75
79
-
/* Probed devices counter; used only for printing the initial info message */
80
-
static int cards_found;
81
-
82
76
/* module parameters */
83
77
/* 30 sec default heartbeat (1 < heartbeat < 2*1023) */
84
78
#define ESB_HEARTBEAT_MIN 1
85
79
#define ESB_HEARTBEAT_MAX 2046
86
80
#define ESB_HEARTBEAT_DEFAULT 30
87
81
#define ESB_HEARTBEAT_RANGE __MODULE_STRING(ESB_HEARTBEAT_MIN) \
88
82
"<heartbeat<" __MODULE_STRING(ESB_HEARTBEAT_MAX)
89
83
static int heartbeat; /* in seconds */
90
84
module_param(heartbeat, int, 0);
91
85
MODULE_PARM_DESC(heartbeat,
295
289
/* And set the correct timeout value */
296
290
esb_timer_set_heartbeat(&edev->wdd, edev->wdd.timeout);
297
291
}
298
292
299
293
static int esb_probe(struct pci_dev *pdev,
300
294
const struct pci_device_id *ent)
301
295
{
302
296
struct esb_dev *edev;
303
297
int ret;
304
298
305
-
cards_found++;
306
-
if (cards_found == 1)
307
-
pr_info("Intel 6300ESB WatchDog Timer Driver v%s\n",
308
-
ESB_VERSION);
309
-
310
299
edev = devm_kzalloc(&pdev->dev, sizeof(*edev), GFP_KERNEL);
311
300
if (!edev)
312
301
return -ENOMEM;
313
302
314
303
/* Check whether or not the hardware watchdog is there */
315
304
edev->pdev = pdev;
316
305
if (!esb_getdevice(edev))
317
306
return -ENODEV;
318
307
319
308
/* Initialize the watchdog and make sure it does not run */