1 /* Watchdog Related Defines */
3 #define ADDIDATA_TIMER 0
4 #define ADDIDATA_WATCHDOG 2
7 * (*insn_config) for the timer subdevice
9 * Configures The Timer, Counter or Watchdog
10 * Data Pointer contains configuration parameters as below
11 * data[0] : 0 Configure As Timer
12 * 1 Configure As Counter
13 * 2 Configure As Watchdog
14 * data[1] : 1 Enable Interrupt
17 * data[3] : Reload Value
19 static int apci3501_config_insn_timer(struct comedi_device *dev,
20 struct comedi_subdevice *s,
21 struct comedi_insn *insn,
24 struct apci3501_private *devpriv = dev->private;
27 if (data[0] != ADDIDATA_WATCHDOG &&
28 data[0] != ADDIDATA_TIMER)
31 devpriv->tsk_Current = current;
33 devpriv->timer_mode = data[0];
35 /* first, disable the watchdog or stop the timer */
36 if (devpriv->timer_mode == ADDIDATA_WATCHDOG) {
39 ctrl = inl(devpriv->tcw + ADDI_TCW_CTRL_REG);
42 outl(ctrl, devpriv->tcw + ADDI_TCW_CTRL_REG);
44 /* enable/disable the timer interrupt */
45 ctrl = (data[1] == 1) ? 0x2 : 0;
46 outl(ctrl, devpriv->tcw + ADDI_TCW_CTRL_REG);
48 outl(data[2], devpriv->tcw + ADDI_TCW_TIMEBASE_REG);
49 outl(data[3], devpriv->tcw + ADDI_TCW_RELOAD_REG);
51 ctrl = inl(devpriv->tcw + ADDI_TCW_CTRL_REG);
52 if (devpriv->timer_mode == ADDIDATA_WATCHDOG) {
53 /* Set the mode (e2->e0) NOTE: this doesn't look correct */
58 ctrl |= (2 << 13) | 0x10;
60 outl(ctrl, devpriv->tcw + ADDI_TCW_CTRL_REG);
66 * (*insn_write) for the timer subdevice
68 * Start / Stop The Selected Timer , Counter or Watchdog
69 * Data Pointer contains configuration parameters as below
77 static int apci3501_write_insn_timer(struct comedi_device *dev,
78 struct comedi_subdevice *s,
79 struct comedi_insn *insn,
82 struct apci3501_private *devpriv = dev->private;
85 if (devpriv->timer_mode == ADDIDATA_WATCHDOG ||
86 devpriv->timer_mode == ADDIDATA_TIMER) {
87 ctrl = inl(devpriv->tcw + ADDI_TCW_CTRL_REG);
90 if (data[1] == 1) { /* enable */
92 } else if (data[1] == 0) { /* stop */
93 if (devpriv->timer_mode == ADDIDATA_WATCHDOG)
97 } else if (data[1] == 2) { /* trigger */
100 outl(ctrl, devpriv->tcw + ADDI_TCW_CTRL_REG);
103 inl(devpriv->tcw + ADDI_TCW_STATUS_REG);
108 * (*insn_read) for the timer subdevice
110 * Read The Selected Timer, Counter or Watchdog
111 * Data Pointer contains configuration parameters as below
115 * data[1] : Timer Counter Watchdog Number
117 static int apci3501_read_insn_timer(struct comedi_device *dev,
118 struct comedi_subdevice *s,
119 struct comedi_insn *insn,
122 struct apci3501_private *devpriv = dev->private;
124 if (devpriv->timer_mode != ADDIDATA_TIMER &&
125 devpriv->timer_mode != ADDIDATA_WATCHDOG)
128 data[0] = inl(devpriv->tcw + ADDI_TCW_STATUS_REG) & 0x1;
129 data[1] = inl(devpriv->tcw + ADDI_TCW_VAL_REG);