drivers: power: report battery voltage in AOSP compatible format
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / staging / comedi / drivers / addi-data / hwdrv_apci035.c
CommitLineData
c995fe94
ADG
1/**
2@verbatim
3
4Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module.
5
356cdbcb
BP
6 ADDI-DATA GmbH
7 Dieselstrasse 3
8 D-77833 Ottersweier
9 Tel: +19(0)7223/9493-0
10 Fax: +49(0)7223/9493-92
25417922 11 http://www.addi-data.com
356cdbcb 12 info@addi-data.com
c995fe94
ADG
13
14This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
15
16This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
17
18You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
39cfb97b 20You should also find the complete GPL in the COPYING file accompanying this source code.
c995fe94
ADG
21
22@endverbatim
23*/
24/*
25
26 +-----------------------------------------------------------------------+
27 | (C) ADDI-DATA GmbH Dieselstraße 3 D-77833 Ottersweier |
28 +-----------------------------------------------------------------------+
29 | Tel : +49 (0) 7223/9493-0 | email : info@addi-data.com |
30 | Fax : +49 (0) 7223/9493-92 | Internet : http://www.addi-data.com |
31 +-------------------------------+---------------------------------------+
32 | Project : APCI-035 | Compiler : GCC |
33 | Module name : hwdrv_apci035.c | Version : 2.96 |
34 +-------------------------------+---------------------------------------+
35 | Project manager: Eric Stolz | Date : 02/12/2002 |
36 +-------------------------------+---------------------------------------+
6cd5a9a3 37 | Description : Hardware Layer Access For APCI-035 |
c995fe94
ADG
38 +-----------------------------------------------------------------------+
39 | UPDATES |
40 +----------+-----------+------------------------------------------------+
41 | Date | Author | Description of updates |
42 +----------+-----------+------------------------------------------------+
43 | | | |
44 | | | |
45 | | | |
46 +----------+-----------+------------------------------------------------+
47*/
48
9b2b9a34
HS
49/* Card Specific information */
50#define APCI035_ADDRESS_RANGE 255
51
52/* Timer / Watchdog Related Defines */
53#define APCI035_TCW_SYNC_ENABLEDISABLE 0
54#define APCI035_TCW_RELOAD_VALUE 4
55#define APCI035_TCW_TIMEBASE 8
56#define APCI035_TCW_PROG 12
57#define APCI035_TCW_TRIG_STATUS 16
58#define APCI035_TCW_IRQ 20
59#define APCI035_TCW_WARN_TIMEVAL 24
60#define APCI035_TCW_WARN_TIMEBASE 28
61
62#define ADDIDATA_TIMER 0
63/* #define ADDIDATA_WATCHDOG 1 */
64
65#define APCI035_TW1 0
66#define APCI035_TW2 32
67#define APCI035_TW3 64
68#define APCI035_TW4 96
69
70#define APCI035_AI_OFFSET 0
71#define APCI035_TEMP 128
72#define APCI035_ALR_SEQ 4
73#define APCI035_START_STOP_INDEX 8
74#define APCI035_ALR_START_STOP 12
75#define APCI035_ALR_IRQ 16
76#define APCI035_EOS 20
77#define APCI035_CHAN_NO 24
78#define APCI035_CHAN_VAL 28
79#define APCI035_CONV_TIME_TIME_BASE 36
80#define APCI035_RELOAD_CONV_TIME_VAL 32
81#define APCI035_DELAY_TIME_TIME_BASE 44
82#define APCI035_RELOAD_DELAY_TIME_VAL 40
83#define ENABLE_EXT_TRIG 1
84#define ENABLE_EXT_GATE 2
85#define ENABLE_EXT_TRIG_GATE 3
86
87#define ANALOG_INPUT 0
88#define TEMPERATURE 1
89#define RESISTANCE 2
90
91#define ADDIDATA_GREATER_THAN_TEST 0
92#define ADDIDATA_LESS_THAN_TEST 1
93
94#define APCI035_MAXVOLT 2.5
95
96#define ADDIDATA_UNIPOLAR 1
97#define ADDIDATA_BIPOLAR 2
98
9b2b9a34
HS
99/* ANALOG INPUT RANGE */
100static struct comedi_lrange range_apci035_ai = {
101 8, {
102 BIP_RANGE(10),
103 BIP_RANGE(5),
104 BIP_RANGE(2),
105 BIP_RANGE(1),
106 UNI_RANGE(10),
107 UNI_RANGE(5),
108 UNI_RANGE(2),
109 UNI_RANGE(1)
110 }
111};
112
08b93e7b
GKH
113static int i_WatchdogNbr = 0;
114static int i_Temp = 0;
115static int i_Flag = 1;
c995fe94
ADG
116/*
117+----------------------------------------------------------------------------+
118| Function Name : int i_APCI035_ConfigTimerWatchdog |
34c43922 119| (struct comedi_device *dev,struct comedi_subdevice *s, |
90035c08 120| struct comedi_insn *insn,unsigned int *data) |
c995fe94
ADG
121+----------------------------------------------------------------------------+
122| Task : Configures The Timer , Counter or Watchdog |
123+----------------------------------------------------------------------------+
71b5f4f1 124| Input Parameters : struct comedi_device *dev : Driver handle |
117102b0 125| unsigned int *data : Data Pointer contains |
c995fe94
ADG
126| configuration parameters as below |
127| |
128| data[0] : 0 Configure As Timer |
129| 1 Configure As Watchdog |
356cdbcb 130| data[1] : Watchdog number
c995fe94
ADG
131| data[2] : Time base Unit |
132| data[3] : Reload Value |
356cdbcb
BP
133| data[4] : External Trigger |
134| 1:Enable
135| 0:Disable
136| data[5] :External Trigger Level
137| 00 Trigger Disabled
138| 01 Trigger Enabled (Low level)
139| 10 Trigger Enabled (High Level)
140| 11 Trigger Enabled (High/Low level)
141| data[6] : External Gate |
142| 1:Enable
143| 0:Disable
144| data[7] : External Gate level
145| 00 Gate Disabled
146| 01 Gate Enabled (Low level)
147| 10 Gate Enabled (High Level)
148| data[8] :Warning Relay
149| 1: ENABLE
150| 0: DISABLE
151| data[9] :Warning Delay available
152| data[10] :Warning Relay Time unit
153| data[11] :Warning Relay Time Reload value
154| data[12] :Reset Relay
155| 1 : ENABLE
156| 0 : DISABLE
157| data[13] :Interrupt
158| 1 : ENABLE
159| 0 : DISABLE
160|
c995fe94
ADG
161|
162+----------------------------------------------------------------------------+
163| Output Parameters : -- |
164+----------------------------------------------------------------------------+
165| Return Value : TRUE : No error occur |
166| : FALSE : Error occur. Return the error |
167| |
168+----------------------------------------------------------------------------+
169*/
dcd7ef33
HS
170static int i_APCI035_ConfigTimerWatchdog(struct comedi_device *dev,
171 struct comedi_subdevice *s,
172 struct comedi_insn *insn,
173 unsigned int *data)
c995fe94 174{
843690b7 175 struct addi_private *devpriv = dev->private;
117102b0
BP
176 unsigned int ui_Status = 0;
177 unsigned int ui_Command = 0;
178 unsigned int ui_Mode = 0;
843690b7 179
c995fe94
ADG
180 i_Temp = 0;
181 devpriv->tsk_Current = current;
182 devpriv->b_TimerSelectMode = data[0];
183 i_WatchdogNbr = data[1];
184 if (data[0] == 0) {
185 ui_Mode = 2;
186 } else {
187 ui_Mode = 0;
188 }
2696fb57 189/* ui_Command = inl(devpriv->iobase+((i_WatchdogNbr-1)*32)+12); */
c995fe94 190 ui_Command = 0;
2696fb57 191/* ui_Command = ui_Command & 0xFFFFF9FEUL; */
c995fe94
ADG
192 outl(ui_Command, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12);
193 ui_Command = 0;
194 ui_Command = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12);
195/************************/
196/* Set the reload value */
197/************************/
198 outl(data[3], devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 4);
199/*********************/
200/* Set the time unit */
201/*********************/
202 outl(data[2], devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 8);
203 if (data[0] == ADDIDATA_TIMER) {
204
205 /******************************/
206 /* Set the mode : */
207 /* - Disable the hardware */
208 /* - Disable the counter mode */
209 /* - Disable the warning */
210 /* - Disable the reset */
211 /* - Enable the timer mode */
212 /* - Set the timer mode */
213 /******************************/
214
215 ui_Command =
216 (ui_Command & 0xFFF719E2UL) | ui_Mode << 13UL | 0x10UL;
217
2696fb57 218 } /* if (data[0] == ADDIDATA_TIMER) */
c995fe94
ADG
219 else {
220 if (data[0] == ADDIDATA_WATCHDOG) {
221
222 /******************************/
223 /* Set the mode : */
224 /* - Disable the hardware */
225 /* - Disable the counter mode */
226 /* - Disable the warning */
227 /* - Disable the reset */
228 /* - Disable the timer mode */
229 /******************************/
230
231 ui_Command = ui_Command & 0xFFF819E2UL;
232
233 } else {
234 printk("\n The parameter for Timer/watchdog selection is in error\n");
235 return -EINVAL;
236 }
237 }
238 outl(ui_Command, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12);
239 ui_Command = 0;
240 ui_Command = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12);
241/********************************/
242/* Disable the hardware trigger */
243/********************************/
244 ui_Command = ui_Command & 0xFFFFF89FUL;
245 if (data[4] == ADDIDATA_ENABLE) {
246 /**********************************/
247 /* Set the hardware trigger level */
248 /**********************************/
249 ui_Command = ui_Command | (data[5] << 5);
250 }
251 outl(ui_Command, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12);
252 ui_Command = 0;
253 ui_Command = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12);
254/*****************************/
255/* Disable the hardware gate */
256/*****************************/
257 ui_Command = ui_Command & 0xFFFFF87FUL;
258 if (data[6] == ADDIDATA_ENABLE) {
259/*******************************/
260/* Set the hardware gate level */
261/*******************************/
262 ui_Command = ui_Command | (data[7] << 7);
263 }
264 outl(ui_Command, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12);
265 ui_Command = 0;
266 ui_Command = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12);
267/*******************************/
268/* Disable the hardware output */
269/*******************************/
270 ui_Command = ui_Command & 0xFFFFF9FBUL;
271/*********************************/
272/* Set the hardware output level */
273/*********************************/
274 ui_Command = ui_Command | (data[8] << 2);
275 outl(ui_Command, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12);
276 if (data[9] == ADDIDATA_ENABLE) {
277 /************************/
278 /* Set the reload value */
279 /************************/
280 outl(data[11],
281 devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 24);
282 /**********************/
283 /* Set the time unite */
284 /**********************/
285 outl(data[10],
286 devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 28);
287 }
288
289 ui_Command = 0;
290 ui_Command = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12);
291 /*******************************/
292 /* Disable the hardware output */
293 /*******************************/
294 ui_Command = ui_Command & 0xFFFFF9F7UL;
295 /*********************************/
296 /* Set the hardware output level */
297 /*********************************/
298 ui_Command = ui_Command | (data[12] << 3);
299 outl(ui_Command, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12);
300 /*************************************/
301 /** Enable the watchdog interrupt **/
302 /*************************************/
303 ui_Command = 0;
304 ui_Command = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12);
305/*******************************/
306/* Set the interrupt selection */
307/*******************************/
308 ui_Status = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 16);
309
310 ui_Command = (ui_Command & 0xFFFFF9FDUL) | (data[13] << 1);
311 outl(ui_Command, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12);
312
313 return insn->n;
314}
315
316/*
317+----------------------------------------------------------------------------+
318| Function Name : int i_APCI035_StartStopWriteTimerWatchdog |
34c43922 319| (struct comedi_device *dev,struct comedi_subdevice *s, |
90035c08 320| struct comedi_insn *insn,unsigned int *data) |
c995fe94
ADG
321+----------------------------------------------------------------------------+
322| Task : Start / Stop The Selected Timer , or Watchdog |
323+----------------------------------------------------------------------------+
71b5f4f1 324| Input Parameters : struct comedi_device *dev : Driver handle |
117102b0 325| unsigned int *data : Data Pointer contains |
c995fe94
ADG
326| configuration parameters as below |
327| |
328| data[0] : 0 - Stop Selected Timer/Watchdog |
329| 1 - Start Selected Timer/Watchdog |
330| 2 - Trigger Selected Timer/Watchdog |
331| 3 - Stop All Timer/Watchdog |
332| 4 - Start All Timer/Watchdog |
333| 5 - Trigger All Timer/Watchdog |
334| |
335+----------------------------------------------------------------------------+
336| Output Parameters : -- |
337+----------------------------------------------------------------------------+
338| Return Value : TRUE : No error occur |
339| : FALSE : Error occur. Return the error |
340| |
341+----------------------------------------------------------------------------+
342*/
dcd7ef33
HS
343static int i_APCI035_StartStopWriteTimerWatchdog(struct comedi_device *dev,
344 struct comedi_subdevice *s,
345 struct comedi_insn *insn,
346 unsigned int *data)
c995fe94 347{
843690b7 348 struct addi_private *devpriv = dev->private;
117102b0 349 unsigned int ui_Command = 0;
74b894e5 350 int i_Count = 0;
843690b7 351
c995fe94
ADG
352 if (data[0] == 1) {
353 ui_Command =
354 inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12);
355 /**********************/
356 /* Start the hardware */
357 /**********************/
358 ui_Command = (ui_Command & 0xFFFFF9FFUL) | 0x1UL;
359 outl(ui_Command,
360 devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12);
2696fb57 361 } /* if (data[0]==1) */
c995fe94
ADG
362 if (data[0] == 2) {
363 ui_Command =
364 inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12);
365 /***************************/
366 /* Set the trigger command */
367 /***************************/
368 ui_Command = (ui_Command & 0xFFFFF9FFUL) | 0x200UL;
369 outl(ui_Command,
370 devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12);
371 }
372
2696fb57 373 if (data[0] == 0) /* Stop The Watchdog */
c995fe94 374 {
2696fb57 375 /* Stop The Watchdog */
c995fe94 376 ui_Command = 0;
2696fb57
BP
377/*
378* ui_Command = inl(devpriv->iobase+((i_WatchdogNbr-1)*32)+12);
379* ui_Command = ui_Command & 0xFFFFF9FEUL;
380*/
c995fe94
ADG
381 outl(ui_Command,
382 devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12);
2696fb57
BP
383 } /* if (data[1]==0) */
384 if (data[0] == 3) /* stop all Watchdogs */
c995fe94
ADG
385 {
386 ui_Command = 0;
387 for (i_Count = 1; i_Count <= 4; i_Count++) {
388 if (devpriv->b_TimerSelectMode == ADDIDATA_WATCHDOG) {
389 ui_Command = 0x2UL;
390 } else {
391 ui_Command = 0x10UL;
392 }
393 i_WatchdogNbr = i_Count;
394 outl(ui_Command,
395 devpriv->iobase + ((i_WatchdogNbr - 1) * 32) +
396 0);
397 }
398
399 }
2696fb57 400 if (data[0] == 4) /* start all Watchdogs */
c995fe94
ADG
401 {
402 ui_Command = 0;
403 for (i_Count = 1; i_Count <= 4; i_Count++) {
404 if (devpriv->b_TimerSelectMode == ADDIDATA_WATCHDOG) {
405 ui_Command = 0x1UL;
406 } else {
407 ui_Command = 0x8UL;
408 }
409 i_WatchdogNbr = i_Count;
410 outl(ui_Command,
411 devpriv->iobase + ((i_WatchdogNbr - 1) * 32) +
412 0);
413 }
414 }
2696fb57 415 if (data[0] == 5) /* trigger all Watchdogs */
c995fe94
ADG
416 {
417 ui_Command = 0;
418 for (i_Count = 1; i_Count <= 4; i_Count++) {
419 if (devpriv->b_TimerSelectMode == ADDIDATA_WATCHDOG) {
420 ui_Command = 0x4UL;
421 } else {
422 ui_Command = 0x20UL;
423 }
424
425 i_WatchdogNbr = i_Count;
426 outl(ui_Command,
427 devpriv->iobase + ((i_WatchdogNbr - 1) * 32) +
428 0);
429 }
430 i_Temp = 1;
431 }
432 return insn->n;
433}
434
435/*
436+----------------------------------------------------------------------------+
437| Function Name : int i_APCI035_ReadTimerWatchdog |
34c43922 438| (struct comedi_device *dev,struct comedi_subdevice *s, |
90035c08 439| struct comedi_insn *insn,unsigned int *data) |
c995fe94
ADG
440+----------------------------------------------------------------------------+
441| Task : Read The Selected Timer , Counter or Watchdog |
442+----------------------------------------------------------------------------+
71b5f4f1 443| Input Parameters : struct comedi_device *dev : Driver handle |
117102b0 444| unsigned int *data : Data Pointer contains |
c995fe94
ADG
445| configuration parameters as below |
446| |
447| |
448+----------------------------------------------------------------------------+
449| Output Parameters : data[0] : software trigger status
356cdbcb
BP
450| data[1] : hardware trigger status
451| data[2] : Software clear status
452| data[3] : Overflow status
453| data[4] : Timer actual value
454|
c995fe94
ADG
455
456+----------------------------------------------------------------------------+
457| Return Value : TRUE : No error occur |
458| : FALSE : Error occur. Return the error |
459| |
460+----------------------------------------------------------------------------+
461*/
dcd7ef33
HS
462static int i_APCI035_ReadTimerWatchdog(struct comedi_device *dev,
463 struct comedi_subdevice *s,
464 struct comedi_insn *insn,
465 unsigned int *data)
c995fe94 466{
843690b7 467 struct addi_private *devpriv = dev->private;
2696fb57 468 unsigned int ui_Status = 0; /* Status register */
843690b7 469
c995fe94 470 i_WatchdogNbr = insn->unused[0];
356cdbcb
BP
471
472 /******************/
c995fe94 473 /* Get the status */
356cdbcb
BP
474 /******************/
475
c995fe94 476 ui_Status = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 16);
356cdbcb
BP
477
478 /***********************************/
c995fe94 479 /* Get the software trigger status */
356cdbcb
BP
480 /***********************************/
481
c995fe94 482 data[0] = ((ui_Status >> 1) & 1);
356cdbcb 483 /***********************************/
c995fe94 484 /* Get the hardware trigger status */
356cdbcb 485 /***********************************/
c995fe94 486 data[1] = ((ui_Status >> 2) & 1);
356cdbcb 487 /*********************************/
c995fe94 488 /* Get the software clear status */
356cdbcb 489 /*********************************/
c995fe94 490 data[2] = ((ui_Status >> 3) & 1);
356cdbcb 491 /***************************/
c995fe94 492 /* Get the overflow status */
356cdbcb 493 /***************************/
c995fe94
ADG
494 data[3] = ((ui_Status >> 0) & 1);
495 if (devpriv->b_TimerSelectMode == ADDIDATA_TIMER) {
496 data[4] = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 0);
497
2696fb57 498 } /* if (devpriv->b_TimerSelectMode==ADDIDATA_TIMER) */
c995fe94
ADG
499
500 return insn->n;
501}
502
503/*
504+----------------------------------------------------------------------------+
74b894e5 505| Function Name : int i_APCI035_ConfigAnalogInput |
34c43922 506| (struct comedi_device *dev,struct comedi_subdevice *s, |
90035c08 507| struct comedi_insn *insn,unsigned int *data) |
c995fe94
ADG
508+----------------------------------------------------------------------------+
509| Task : Configures The Analog Input Subdevice |
510+----------------------------------------------------------------------------+
71b5f4f1 511| Input Parameters : struct comedi_device *dev : Driver handle |
34c43922 512| struct comedi_subdevice *s : Subdevice Pointer |
90035c08 513| struct comedi_insn *insn : Insn Structure Pointer |
790c5541 514| unsigned int *data : Data Pointer contains |
c995fe94
ADG
515| configuration parameters as below |
516| data[0] : Warning delay value
517| |
518+----------------------------------------------------------------------------+
519| Output Parameters : -- |
520+----------------------------------------------------------------------------+
521| Return Value : TRUE : No error occur |
522| : FALSE : Error occur. Return the error |
523| |
524+----------------------------------------------------------------------------+
525*/
dcd7ef33
HS
526static int i_APCI035_ConfigAnalogInput(struct comedi_device *dev,
527 struct comedi_subdevice *s,
528 struct comedi_insn *insn,
529 unsigned int *data)
c995fe94 530{
843690b7
HS
531 struct addi_private *devpriv = dev->private;
532
c995fe94
ADG
533 devpriv->tsk_Current = current;
534 outl(0x200 | 0, devpriv->iobase + 128 + 0x4);
535 outl(0, devpriv->iobase + 128 + 0);
536/********************************/
537/* Initialise the warning value */
538/********************************/
539 outl(0x300 | 0, devpriv->iobase + 128 + 0x4);
540 outl((data[0] << 8), devpriv->iobase + 128 + 0);
541 outl(0x200000UL, devpriv->iobase + 128 + 12);
542
543 return insn->n;
544}
545
546/*
547+----------------------------------------------------------------------------+
548| Function Name : int i_APCI035_ReadAnalogInput |
34c43922 549| (struct comedi_device *dev,struct comedi_subdevice *s, |
90035c08 550| struct comedi_insn *insn,unsigned int *data) |
c995fe94
ADG
551+----------------------------------------------------------------------------+
552| Task : Read value of the selected channel |
553+----------------------------------------------------------------------------+
71b5f4f1 554| Input Parameters : struct comedi_device *dev : Driver handle |
117102b0
BP
555| unsigned int ui_NoOfChannels : No Of Channels To read |
556| unsigned int *data : Data Pointer to read status |
c995fe94
ADG
557+----------------------------------------------------------------------------+
558| Output Parameters : -- |
559| data[0] : Digital Value Of Input |
560| |
561+----------------------------------------------------------------------------+
562| Return Value : TRUE : No error occur |
563| : FALSE : Error occur. Return the error |
564| |
565+----------------------------------------------------------------------------+
566*/
dcd7ef33
HS
567static int i_APCI035_ReadAnalogInput(struct comedi_device *dev,
568 struct comedi_subdevice *s,
569 struct comedi_insn *insn,
570 unsigned int *data)
c995fe94 571{
843690b7 572 struct addi_private *devpriv = dev->private;
117102b0 573 unsigned int ui_CommandRegister = 0;
843690b7 574
c995fe94
ADG
575/******************/
576/* Set the start */
577/******************/
578 ui_CommandRegister = 0x80000;
579 /******************************/
580 /* Write the command register */
581 /******************************/
582 outl(ui_CommandRegister, devpriv->iobase + 128 + 8);
583
584/***************************************/
585/* Read the digital value of the input */
586/***************************************/
587 data[0] = inl(devpriv->iobase + 128 + 28);
588 return insn->n;
589}
590
591/*
592+----------------------------------------------------------------------------+
71b5f4f1 593| Function Name : int i_APCI035_Reset(struct comedi_device *dev) |
c995fe94
ADG
594| |
595+----------------------------------------------------------------------------+
596| Task :Resets the registers of the card |
597+----------------------------------------------------------------------------+
598| Input Parameters : |
599+----------------------------------------------------------------------------+
600| Output Parameters : -- |
601+----------------------------------------------------------------------------+
602| Return Value : |
603| |
604+----------------------------------------------------------------------------+
605*/
dcd7ef33 606static int i_APCI035_Reset(struct comedi_device *dev)
c995fe94 607{
843690b7 608 struct addi_private *devpriv = dev->private;
74b894e5 609 int i_Count = 0;
843690b7 610
c995fe94
ADG
611 for (i_Count = 1; i_Count <= 4; i_Count++) {
612 i_WatchdogNbr = i_Count;
2696fb57 613 outl(0x0, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 0); /* stop all timers */
c995fe94 614 }
2696fb57 615 outl(0x0, devpriv->iobase + 128 + 12); /* Disable the warning delay */
c995fe94
ADG
616
617 return 0;
618}
619
620/*
621+----------------------------------------------------------------------------+
622| Function Name : static void v_APCI035_Interrupt |
623| (int irq , void *d) |
624+----------------------------------------------------------------------------+
625| Task : Interrupt processing Routine |
626+----------------------------------------------------------------------------+
627| Input Parameters : int irq : irq number |
628| void *d : void pointer |
629+----------------------------------------------------------------------------+
630| Output Parameters : -- |
631+----------------------------------------------------------------------------+
632| Return Value : TRUE : No error occur |
633| : FALSE : Error occur. Return the error |
634| |
635+----------------------------------------------------------------------------+
636*/
637static void v_APCI035_Interrupt(int irq, void *d)
638{
71b5f4f1 639 struct comedi_device *dev = d;
843690b7 640 struct addi_private *devpriv = dev->private;
117102b0
BP
641 unsigned int ui_StatusRegister1 = 0;
642 unsigned int ui_StatusRegister2 = 0;
643 unsigned int ui_ReadCommand = 0;
644 unsigned int ui_ChannelNumber = 0;
645 unsigned int ui_DigitalTemperature = 0;
843690b7 646
c995fe94
ADG
647 if (i_Temp == 1) {
648 i_WatchdogNbr = i_Flag;
649 i_Flag = i_Flag + 1;
650 }
651 /**************************************/
652 /* Read the interrupt status register of temperature Warning */
653 /**************************************/
654 ui_StatusRegister1 = inl(devpriv->iobase + 128 + 16);
655 /**************************************/
656 /* Read the interrupt status register for Watchdog/timer */
657 /**************************************/
658
659 ui_StatusRegister2 =
660 inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 20);
661
2696fb57 662 if ((((ui_StatusRegister1) & 0x8) == 0x8)) /* Test if warning relay interrupt */
c995fe94
ADG
663 {
664 /**********************************/
665 /* Disable the temperature warning */
666 /**********************************/
667 ui_ReadCommand = inl(devpriv->iobase + 128 + 12);
668 ui_ReadCommand = ui_ReadCommand & 0xFFDF0000UL;
669 outl(ui_ReadCommand, devpriv->iobase + 128 + 12);
670 /***************************/
671 /* Read the channel number */
672 /***************************/
673 ui_ChannelNumber = inl(devpriv->iobase + 128 + 60);
674 /**************************************/
675 /* Read the digital temperature value */
676 /**************************************/
677 ui_DigitalTemperature = inl(devpriv->iobase + 128 + 60);
2696fb57
BP
678 send_sig(SIGIO, devpriv->tsk_Current, 0); /* send signal to the sample */
679 } /* if (((ui_StatusRegister1 & 0x8) == 0x8)) */
c995fe94
ADG
680
681 else {
682 if ((ui_StatusRegister2 & 0x1) == 0x1) {
2696fb57 683 send_sig(SIGIO, devpriv->tsk_Current, 0); /* send signal to the sample */
c995fe94 684 }
2696fb57 685 } /* else if (((ui_StatusRegister1 & 0x8) == 0x8)) */
c995fe94
ADG
686
687 return;
688}