2 * Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module.
7 * Tel: +19(0)7223/9493-0
8 * Fax: +49(0)7223/9493-92
9 * http://www.addi-data.com
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the Free
14 * Software Foundation; either version 2 of the License, or (at your option)
18 #include <linux/sched.h>
19 #include <linux/interrupt.h>
21 #define LOWORD(W) (unsigned short)((W) & 0xFFFF)
22 #define HIWORD(W) (unsigned short)(((W) >> 16) & 0xFFFF)
25 #define ADDI_DISABLE 0
26 #define APCI1710_SAVE_INTERRUPT 1
28 #define ADDIDATA_EEPROM 1
29 #define ADDIDATA_NO_EEPROM 0
30 #define ADDIDATA_93C76 "93C76"
31 #define ADDIDATA_S5920 "S5920"
33 /* ADDIDATA Enable Disable */
34 #define ADDIDATA_ENABLE 1
35 #define ADDIDATA_DISABLE 0
39 /* structure for the boardtype */
41 const char *pc_DriverName; /* driver name */
43 int i_PCIEeprom; /* eeprom present or not */
44 char *pc_EepromChip; /* type of chip */
45 int i_NbrAiChannel; /* num of A/D chans */
46 int i_NbrAiChannelDiff; /* num of A/D chans in diff mode */
47 int i_AiChannelList; /* len of chanlist */
48 int i_NbrAoChannel; /* num of D/A chans */
49 int i_AiMaxdata; /* resolution of A/D */
50 int i_AoMaxdata; /* resolution of D/A */
51 const struct comedi_lrange *pr_AiRangelist; /* rangelist for A/D */
53 int i_NbrDiChannel; /* Number of DI channels */
54 int i_NbrDoChannel; /* Number of DO channels */
55 int i_DoMaxdata; /* data to set all channels high */
57 int i_Timer; /* timer subdevice present or not */
58 unsigned int ui_MinAcquisitiontimeNs; /* Minimum Acquisition in Nano secs */
59 unsigned int ui_MinDelaytimeNs; /* Minimum Delay in Nano secs */
61 /* interrupt and reset */
62 void (*interrupt)(int irq, void *d);
63 int (*reset)(struct comedi_device *);
65 /* Subdevice functions */
68 int (*ai_config)(struct comedi_device *, struct comedi_subdevice *,
69 struct comedi_insn *, unsigned int *);
70 int (*ai_read)(struct comedi_device *, struct comedi_subdevice *,
71 struct comedi_insn *, unsigned int *);
72 int (*ai_write)(struct comedi_device *, struct comedi_subdevice *,
73 struct comedi_insn *, unsigned int *);
74 int (*ai_bits)(struct comedi_device *, struct comedi_subdevice *,
75 struct comedi_insn *, unsigned int *);
76 int (*ai_cmdtest)(struct comedi_device *, struct comedi_subdevice *,
78 int (*ai_cmd)(struct comedi_device *, struct comedi_subdevice *);
79 int (*ai_cancel)(struct comedi_device *, struct comedi_subdevice *);
82 int (*ao_write)(struct comedi_device *, struct comedi_subdevice *,
83 struct comedi_insn *, unsigned int *);
86 int (*di_config)(struct comedi_device *, struct comedi_subdevice *,
87 struct comedi_insn *, unsigned int *);
88 int (*di_read)(struct comedi_device *, struct comedi_subdevice *,
89 struct comedi_insn *, unsigned int *);
90 int (*di_write)(struct comedi_device *, struct comedi_subdevice *,
91 struct comedi_insn *, unsigned int *);
92 int (*di_bits)(struct comedi_device *, struct comedi_subdevice *,
93 struct comedi_insn *, unsigned int *);
96 int (*do_config)(struct comedi_device *, struct comedi_subdevice *,
97 struct comedi_insn *, unsigned int *);
98 int (*do_write)(struct comedi_device *, struct comedi_subdevice *,
99 struct comedi_insn *, unsigned int *);
100 int (*do_bits)(struct comedi_device *, struct comedi_subdevice *,
101 struct comedi_insn *, unsigned int *);
102 int (*do_read)(struct comedi_device *, struct comedi_subdevice *,
103 struct comedi_insn *, unsigned int *);
106 int (*timer_config)(struct comedi_device *, struct comedi_subdevice *,
107 struct comedi_insn *, unsigned int *);
108 int (*timer_write)(struct comedi_device *, struct comedi_subdevice *,
109 struct comedi_insn *, unsigned int *);
110 int (*timer_read)(struct comedi_device *, struct comedi_subdevice *,
111 struct comedi_insn *, unsigned int *);
112 int (*timer_bits)(struct comedi_device *, struct comedi_subdevice *,
113 struct comedi_insn *, unsigned int *);
116 struct addi_private {
118 int i_IobaseAmcc; /* base+size for AMCC chip */
119 int i_IobaseAddon; /* addon base address */
120 int i_IobaseReserved;
121 unsigned char b_AiContinuous; /* we do unlimited AI */
122 unsigned int ui_AiActualScan; /* how many scans we finished */
123 unsigned int ui_AiNbrofChannels; /* how many channels is measured */
124 unsigned int ui_AiScanLength; /* Length of actual scanlist */
125 unsigned int *pui_AiChannelList; /* actual chanlist */
126 unsigned int ui_AiChannelList[32]; /* actual chanlist */
127 unsigned int ui_AiReadData[32];
128 unsigned int ui_AiTimer0; /* Timer Constant for Timer0 */
129 unsigned int ui_AiTimer1; /* Timer constant for Timer1 */
130 unsigned int ui_AiFlags;
131 unsigned int ui_AiDataLength;
132 unsigned int ui_AiNbrofScans; /* number of scans to do */
133 unsigned short us_UseDma; /* To use Dma or not */
134 unsigned char b_DmaDoubleBuffer; /* we can use double buffering */
135 unsigned int ui_DmaActualBuffer; /* which buffer is used now */
136 unsigned short *ul_DmaBufferVirtual[2]; /* pointers to DMA buffer */
137 unsigned int ul_DmaBufferHw[2]; /* hw address of DMA buff */
138 unsigned int ui_DmaBufferSize[2]; /* size of dma buffer in bytes */
139 unsigned int ui_DmaBufferUsesize[2]; /* which size we may now used for transfer */
140 unsigned int ui_DmaBufferPages[2]; /* number of pages in buffer */
141 unsigned char b_DigitalOutputRegister; /* Digital Output Register */
142 unsigned char b_OutputMemoryStatus;
143 unsigned char b_TimerSelectMode; /* Contain data written at iobase + 0C */
144 unsigned char b_ModeSelectRegister; /* Contain data written at iobase + 0E */
145 unsigned short us_OutputRegister; /* Contain data written at iobase + 0 */
146 unsigned char b_Timer2Mode; /* Specify the timer 2 mode */
147 unsigned char b_Timer2Interrupt; /* Timer2 interrupt enable or disable */
148 unsigned char b_AiCyclicAcquisition; /* indicate cyclic acquisition */
149 unsigned char b_InterruptMode; /* eoc eos or dma */
150 unsigned char b_EocEosInterrupt; /* Enable disable eoc eos interrupt */
151 unsigned int ui_EocEosConversionTime;
152 unsigned char b_SingelDiff;
153 unsigned char b_ExttrigEnable; /* To enable or disable external trigger */
155 /* Pointer to the current process */
156 struct task_struct *tsk_Current;
158 /* Parameters read from EEPROM overriding static board info */
160 int i_NbrAiChannel; /* num of A/D chans */
161 int i_NbrAoChannel; /* num of D/A chans */
162 int i_AiMaxdata; /* resolution of A/D */
163 int i_AoMaxdata; /* resolution of D/A */
164 int i_NbrDiChannel; /* Number of DI channels */
165 int i_NbrDoChannel; /* Number of DO channels */
166 int i_DoMaxdata; /* data to set all channels high */
167 int i_Timer; /* timer subdevice present or not */
168 unsigned int ui_MinAcquisitiontimeNs;
169 /* Minimum Acquisition in Nano secs */
170 unsigned int ui_MinDelaytimeNs;
171 /* Minimum Delay in Nano secs */