staging: comedi: ni_stc.h: tidy up Joint_Status_1_Register
[firefly-linux-kernel-4.4.55.git] / drivers / staging / comedi / drivers / ni_stc.h
1 /*
2     module/ni_stc.h
3     Register descriptions for NI DAQ-STC chip
4
5     COMEDI - Linux Control and Measurement Device Interface
6     Copyright (C) 1998-9 David A. Schleef <ds@schleef.org>
7
8     This program is free software; you can redistribute it and/or modify
9     it under the terms of the GNU General Public License as published by
10     the Free Software Foundation; either version 2 of the License, or
11     (at your option) any later version.
12
13     This program is distributed in the hope that it will be useful,
14     but WITHOUT ANY WARRANTY; without even the implied warranty of
15     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16     GNU General Public License for more details.
17 */
18
19 /*
20         References:
21             DAQ-STC Technical Reference Manual
22 */
23
24 #ifndef _COMEDI_NI_STC_H
25 #define _COMEDI_NI_STC_H
26
27 #include "ni_tio.h"
28
29 #define _bit15          0x8000
30 #define _bit14          0x4000
31 #define _bit13          0x2000
32 #define _bit12          0x1000
33 #define _bit11          0x0800
34 #define _bit10          0x0400
35 #define _bit9           0x0200
36 #define _bit8           0x0100
37 #define _bit7           0x0080
38 #define _bit6           0x0040
39 #define _bit5           0x0020
40 #define _bit4           0x0010
41 #define _bit3           0x0008
42 #define _bit2           0x0004
43 #define _bit1           0x0002
44 #define _bit0           0x0001
45
46 #define NUM_PFI_OUTPUT_SELECT_REGS 6
47
48 /*
49  * Registers in the National Instruments DAQ-STC chip
50  */
51
52 #define NISTC_INTA_ACK_REG              2
53 #define NISTC_INTA_ACK_G0_GATE          BIT(15)
54 #define NISTC_INTA_ACK_G0_TC            BIT(14)
55 #define NISTC_INTA_ACK_AI_ERR           BIT(13)
56 #define NISTC_INTA_ACK_AI_STOP          BIT(12)
57 #define NISTC_INTA_ACK_AI_START         BIT(11)
58 #define NISTC_INTA_ACK_AI_START2        BIT(10)
59 #define NISTC_INTA_ACK_AI_START1        BIT(9)
60 #define NISTC_INTA_ACK_AI_SC_TC         BIT(8)
61 #define NISTC_INTA_ACK_AI_SC_TC_ERR     BIT(7)
62 #define NISTC_INTA_ACK_G0_TC_ERR        BIT(6)
63 #define NISTC_INTA_ACK_G0_GATE_ERR      BIT(5)
64 #define NISTC_INTA_ACK_AI_ALL           (NISTC_INTA_ACK_AI_ERR |        \
65                                          NISTC_INTA_ACK_AI_STOP |       \
66                                          NISTC_INTA_ACK_AI_START |      \
67                                          NISTC_INTA_ACK_AI_START2 |     \
68                                          NISTC_INTA_ACK_AI_START1 |     \
69                                          NISTC_INTA_ACK_AI_SC_TC |      \
70                                          NISTC_INTA_ACK_AI_SC_TC_ERR)
71
72 #define NISTC_INTB_ACK_REG              3
73 #define NISTC_INTB_ACK_G1_GATE          BIT(15)
74 #define NISTC_INTB_ACK_G1_TC            BIT(14)
75 #define NISTC_INTB_ACK_AO_ERR           BIT(13)
76 #define NISTC_INTB_ACK_AO_STOP          BIT(12)
77 #define NISTC_INTB_ACK_AO_START         BIT(11)
78 #define NISTC_INTB_ACK_AO_UPDATE        BIT(10)
79 #define NISTC_INTB_ACK_AO_START1        BIT(9)
80 #define NISTC_INTB_ACK_AO_BC_TC         BIT(8)
81 #define NISTC_INTB_ACK_AO_UC_TC         BIT(7)
82 #define NISTC_INTB_ACK_AO_UI2_TC        BIT(6)
83 #define NISTC_INTB_ACK_AO_UI2_TC_ERR    BIT(5)
84 #define NISTC_INTB_ACK_AO_BC_TC_ERR     BIT(4)
85 #define NISTC_INTB_ACK_AO_BC_TC_TRIG_ERR BIT(3)
86 #define NISTC_INTB_ACK_G1_TC_ERR        BIT(2)
87 #define NISTC_INTB_ACK_G1_GATE_ERR      BIT(1)
88 #define NISTC_INTB_ACK_AO_ALL           (NISTC_INTB_ACK_AO_ERR |        \
89                                          NISTC_INTB_ACK_AO_STOP |       \
90                                          NISTC_INTB_ACK_AO_START |      \
91                                          NISTC_INTB_ACK_AO_UPDATE |     \
92                                          NISTC_INTB_ACK_AO_START1 |     \
93                                          NISTC_INTB_ACK_AO_BC_TC |      \
94                                          NISTC_INTB_ACK_AO_UC_TC |      \
95                                          NISTC_INTB_ACK_AO_BC_TC_ERR |  \
96                                          NISTC_INTB_ACK_AO_BC_TC_TRIG_ERR)
97
98 #define NISTC_AI_CMD2_REG               4
99 #define NISTC_AI_CMD2_END_ON_SC_TC      BIT(15)
100 #define NISTC_AI_CMD2_END_ON_EOS        BIT(14)
101 #define NISTC_AI_CMD2_START1_DISABLE    BIT(11)
102 #define NISTC_AI_CMD2_SC_SAVE_TRACE     BIT(10)
103 #define NISTC_AI_CMD2_SI_SW_ON_SC_TC    BIT(9)
104 #define NISTC_AI_CMD2_SI_SW_ON_STOP     BIT(8)
105 #define NISTC_AI_CMD2_SI_SW_ON_TC       BIT(7)
106 #define NISTC_AI_CMD2_SC_SW_ON_TC       BIT(4)
107 #define NISTC_AI_CMD2_STOP_PULSE        BIT(3)
108 #define NISTC_AI_CMD2_START_PULSE       BIT(2)
109 #define NISTC_AI_CMD2_START2_PULSE      BIT(1)
110 #define NISTC_AI_CMD2_START1_PULSE      BIT(0)
111
112 #define NISTC_AO_CMD2_REG               5
113 #define NISTC_AO_CMD2_END_ON_BC_TC(x)   (((x) & 0x3) << 14)
114 #define NISTC_AO_CMD2_START_STOP_GATE_ENA BIT(13)
115 #define NISTC_AO_CMD2_UC_SAVE_TRACE     BIT(12)
116 #define NISTC_AO_CMD2_BC_GATE_ENA       BIT(11)
117 #define NISTC_AO_CMD2_BC_SAVE_TRACE     BIT(10)
118 #define NISTC_AO_CMD2_UI_SW_ON_BC_TC    BIT(9)
119 #define NISTC_AO_CMD2_UI_SW_ON_STOP     BIT(8)
120 #define NISTC_AO_CMD2_UI_SW_ON_TC       BIT(7)
121 #define NISTC_AO_CMD2_UC_SW_ON_BC_TC    BIT(6)
122 #define NISTC_AO_CMD2_UC_SW_ON_TC       BIT(5)
123 #define NISTC_AO_CMD2_BC_SW_ON_TC       BIT(4)
124 #define NISTC_AO_CMD2_MUTE_B            BIT(3)
125 #define NISTC_AO_CMD2_MUTE_A            BIT(2)
126 #define NISTC_AO_CMD2_UPDATE2_PULSE     BIT(1)
127 #define NISTC_AO_CMD2_START1_PULSE      BIT(0)
128
129 #define NISTC_G0_CMD_REG                6
130 #define NISTC_G1_CMD_REG                7
131
132 #define NISTC_AI_CMD1_REG               8
133 #define NISTC_AI_CMD1_ATRIG_RESET       BIT(14)
134 #define NISTC_AI_CMD1_DISARM            BIT(13)
135 #define NISTC_AI_CMD1_SI2_ARM           BIT(12)
136 #define NISTC_AI_CMD1_SI2_LOAD          BIT(11)
137 #define NISTC_AI_CMD1_SI_ARM            BIT(10)
138 #define NISTC_AI_CMD1_SI_LOAD           BIT(9)
139 #define NISTC_AI_CMD1_DIV_ARM           BIT(8)
140 #define NISTC_AI_CMD1_DIV_LOAD          BIT(7)
141 #define NISTC_AI_CMD1_SC_ARM            BIT(6)
142 #define NISTC_AI_CMD1_SC_LOAD           BIT(5)
143 #define NISTC_AI_CMD1_SCAN_IN_PROG_PULSE BIT(4)
144 #define NISTC_AI_CMD1_EXTMUX_CLK_PULSE  BIT(3)
145 #define NISTC_AI_CMD1_LOCALMUX_CLK_PULSE BIT(2)
146 #define NISTC_AI_CMD1_SC_TC_PULSE       BIT(1)
147 #define NISTC_AI_CMD1_CONVERT_PULSE     BIT(0)
148
149 #define NISTC_AO_CMD1_REG               9
150 #define NISTC_AO_CMD1_ATRIG_RESET       BIT(15)
151 #define NISTC_AO_CMD1_START_PULSE       BIT(14)
152 #define NISTC_AO_CMD1_DISARM            BIT(13)
153 #define NISTC_AO_CMD1_UI2_ARM_DISARM    BIT(12)
154 #define NISTC_AO_CMD1_UI2_LOAD          BIT(11)
155 #define NISTC_AO_CMD1_UI_ARM            BIT(10)
156 #define NISTC_AO_CMD1_UI_LOAD           BIT(9)
157 #define NISTC_AO_CMD1_UC_ARM            BIT(8)
158 #define NISTC_AO_CMD1_UC_LOAD           BIT(7)
159 #define NISTC_AO_CMD1_BC_ARM            BIT(6)
160 #define NISTC_AO_CMD1_BC_LOAD           BIT(5)
161 #define NISTC_AO_CMD1_DAC1_UPDATE_MODE  BIT(4)
162 #define NISTC_AO_CMD1_LDAC1_SRC_SEL     BIT(3)
163 #define NISTC_AO_CMD1_DAC0_UPDATE_MODE  BIT(2)
164 #define NISTC_AO_CMD1_LDAC0_SRC_SEL     BIT(1)
165 #define NISTC_AO_CMD1_UPDATE_PULSE      BIT(0)
166
167 #define NISTC_DIO_OUT_REG               10
168 #define NISTC_DIO_OUT_SERIAL(x) (((x) & 0xff) << 8)
169 #define NISTC_DIO_OUT_SERIAL_MASK       NISTC_DIO_OUT_SERIAL(0xff)
170 #define NISTC_DIO_OUT_PARALLEL(x)       ((x) & 0xff)
171 #define NISTC_DIO_OUT_PARALLEL_MASK     NISTC_DIO_OUT_PARALLEL(0xff)
172 #define NISTC_DIO_SDIN                  BIT(4)
173 #define NISTC_DIO_SDOUT                 BIT(0)
174
175 #define NISTC_DIO_CTRL_REG              11
176 #define NISTC_DIO_SDCLK                 BIT(11)
177 #define NISTC_DIO_CTRL_HW_SER_TIMEBASE  BIT(10)
178 #define NISTC_DIO_CTRL_HW_SER_ENA       BIT(9)
179 #define NISTC_DIO_CTRL_HW_SER_START     BIT(8)
180 #define NISTC_DIO_CTRL_DIR(x)           ((x) & 0xff)
181 #define NISTC_DIO_CTRL_DIR_MASK         NISTC_DIO_CTRL_DIR(0xff)
182
183 #define NISTC_AI_MODE1_REG              12
184 #define NISTC_AI_MODE1_CONVERT_SRC(x)   (((x) & 0x1f) << 11)
185 #define NISTC_AI_MODE1_SI_SRC(x)        (((x) & 0x1f) << 6)
186 #define NISTC_AI_MODE1_CONVERT_POLARITY BIT(5)
187 #define NISTC_AI_MODE1_SI_POLARITY      BIT(4)
188 #define NISTC_AI_MODE1_START_STOP       BIT(3)
189 #define NISTC_AI_MODE1_RSVD             BIT(2)
190 #define NISTC_AI_MODE1_CONTINUOUS       BIT(1)
191 #define NISTC_AI_MODE1_TRIGGER_ONCE     BIT(0)
192
193 #define NISTC_AI_MODE2_REG              13
194 #define NISTC_AI_MODE2_SC_GATE_ENA      BIT(15)
195 #define NISTC_AI_MODE2_START_STOP_GATE_ENA BIT(14)
196 #define NISTC_AI_MODE2_PRE_TRIGGER      BIT(13)
197 #define NISTC_AI_MODE2_EXTMUX_PRESENT   BIT(12)
198 #define NISTC_AI_MODE2_SI2_INIT_LOAD_SRC BIT(9)
199 #define NISTC_AI_MODE2_SI2_RELOAD_MODE  BIT(8)
200 #define NISTC_AI_MODE2_SI_INIT_LOAD_SRC BIT(7)
201 #define NISTC_AI_MODE2_SI_RELOAD_MODE(x) (((x) & 0x7) << 4)
202 #define NISTC_AI_MODE2_SI_WR_SWITCH     BIT(3)
203 #define NISTC_AI_MODE2_SC_INIT_LOAD_SRC BIT(2)
204 #define NISTC_AI_MODE2_SC_RELOAD_MODE   BIT(1)
205 #define NISTC_AI_MODE2_SC_WR_SWITCH     BIT(0)
206
207 #define NISTC_AI_SI_LOADA_REG           14
208 #define NISTC_AI_SI_LOADB_REG           16
209 #define NISTC_AI_SC_LOADA_REG           18
210 #define NISTC_AI_SC_LOADB_REG           20
211 #define NISTC_AI_SI2_LOADA_REG          23
212 #define NISTC_AI_SI2_LOADB_REG          25
213
214 #define NISTC_G0_MODE_REG               26
215 #define NISTC_G1_MODE_REG               27
216 #define NISTC_G0_LOADA_REG              28
217 #define NISTC_G0_LOADB_REG              30
218 #define NISTC_G1_LOADA_REG              32
219 #define NISTC_G1_LOADB_REG              34
220 #define NISTC_G0_INPUT_SEL_REG          36
221 #define NISTC_G1_INPUT_SEL_REG          37
222
223 #define NISTC_AO_MODE1_REG              38
224 #define NISTC_AO_MODE1_UPDATE_SRC(x)    (((x) & 0x1f) << 11)
225 #define NISTC_AO_MODE1_UPDATE_SRC_MASK  NISTC_AO_MODE1_UPDATE_SRC(0x1f)
226 #define NISTC_AO_MODE1_UI_SRC(x)        (((x) & 0x1f) << 6)
227 #define NISTC_AO_MODE1_UI_SRC_MASK      NISTC_AO_MODE1_UI_SRC(0x1f)
228 #define NISTC_AO_MODE1_MULTI_CHAN       BIT(5)
229 #define NISTC_AO_MODE1_UPDATE_SRC_POLARITY BIT(4)
230 #define NISTC_AO_MODE1_UI_SRC_POLARITY  BIT(3)
231 #define NISTC_AO_MODE1_UC_SW_EVERY_TC   BIT(2)
232 #define NISTC_AO_MODE1_CONTINUOUS       BIT(1)
233 #define NISTC_AO_MODE1_TRIGGER_ONCE     BIT(0)
234
235 #define NISTC_AO_MODE2_REG              39
236 #define NISTC_AO_MODE2_FIFO_MODE(x)     (((x) & 0x3) << 14)
237 #define NISTC_AO_MODE2_FIFO_MODE_MASK   NISTC_AO_MODE2_FIFO_MODE(3)
238 #define NISTC_AO_MODE2_FIFO_MODE_E      NISTC_AO_MODE2_FIFO_MODE(0)
239 #define NISTC_AO_MODE2_FIFO_MODE_HF     NISTC_AO_MODE2_FIFO_MODE(1)
240 #define NISTC_AO_MODE2_FIFO_MODE_F      NISTC_AO_MODE2_FIFO_MODE(2)
241 #define NISTC_AO_MODE2_FIFO_MODE_HF_F   NISTC_AO_MODE2_FIFO_MODE(3)
242 #define NISTC_AO_MODE2_FIFO_REXMIT_ENA  BIT(13)
243 #define NISTC_AO_MODE2_START1_DISABLE   BIT(12)
244 #define NISTC_AO_MODE2_UC_INIT_LOAD_SRC BIT(11)
245 #define NISTC_AO_MODE2_UC_WR_SWITCH     BIT(10)
246 #define NISTC_AO_MODE2_UI2_INIT_LOAD_SRC BIT(9)
247 #define NISTC_AO_MODE2_UI2_RELOAD_MODE  BIT(8)
248 #define NISTC_AO_MODE2_UI_INIT_LOAD_SRC BIT(7)
249 #define NISTC_AO_MODE2_UI_RELOAD_MODE(x) (((x) & 0x7) << 4)
250 #define NISTC_AO_MODE2_UI_WR_SWITCH     BIT(3)
251 #define NISTC_AO_MODE2_BC_INIT_LOAD_SRC BIT(2)
252 #define NISTC_AO_MODE2_BC_RELOAD_MODE   BIT(1)
253 #define NISTC_AO_MODE2_BC_WR_SWITCH     BIT(0)
254
255 #define NISTC_AO_UI_LOADA_REG           40
256 #define NISTC_AO_UI_LOADB_REG           42
257 #define NISTC_AO_BC_LOADA_REG           44
258 #define NISTC_AO_BC_LOADB_REG           46
259 #define NISTC_AO_UC_LOADA_REG           48
260 #define NISTC_AO_UC_LOADB_REG           50
261
262 #define NISTC_CLK_FOUT_REG              56
263 #define NISTC_CLK_FOUT_ENA              BIT(15)
264 #define NISTC_CLK_FOUT_TIMEBASE_SEL     BIT(14)
265 #define NISTC_CLK_FOUT_DIO_SER_OUT_DIV2 BIT(13)
266 #define NISTC_CLK_FOUT_SLOW_DIV2        BIT(12)
267 #define NISTC_CLK_FOUT_SLOW_TIMEBASE    BIT(11)
268 #define NISTC_CLK_FOUT_G_SRC_DIV2       BIT(10)
269 #define NISTC_CLK_FOUT_TO_BOARD_DIV2    BIT(9)
270 #define NISTC_CLK_FOUT_TO_BOARD         BIT(8)
271 #define NISTC_CLK_FOUT_AI_OUT_DIV2      BIT(7)
272 #define NISTC_CLK_FOUT_AI_SRC_DIV2      BIT(6)
273 #define NISTC_CLK_FOUT_AO_OUT_DIV2      BIT(5)
274 #define NISTC_CLK_FOUT_AO_SRC_DIV2      BIT(4)
275 #define NISTC_CLK_FOUT_DIVIDER(x)       (((x) & 0xf) << 0)
276 #define NISTC_CLK_FOUT_TO_DIVIDER(x)    (((x) >> 0) & 0xf)
277 #define NISTC_CLK_FOUT_DIVIDER_MASK     NISTC_CLK_FOUT_DIVIDER(0xf)
278
279 #define NISTC_IO_BIDIR_PIN_REG          57
280
281 #define NISTC_RTSI_TRIG_DIR_REG         58
282 #define NISTC_RTSI_TRIG_OLD_CLK_CHAN    7
283 #define NISTC_RTSI_TRIG_NUM_CHAN(_m)    ((_m) ? 8 : 7)
284 #define NISTC_RTSI_TRIG_DIR(_c, _m)     ((_m) ? BIT(8 + (_c)) : BIT(7 + (_c)))
285 #define NISTC_RTSI_TRIG_USE_CLK         BIT(1)
286 #define NISTC_RTSI_TRIG_DRV_CLK         BIT(0)
287
288 #define NISTC_INT_CTRL_REG              59
289 #define NISTC_INT_CTRL_INTB_ENA         BIT(15)
290 #define NISTC_INT_CTRL_INTB_SEL(x)      (((x) & 0x7) << 12)
291 #define NISTC_INT_CTRL_INTA_ENA         BIT(11)
292 #define NISTC_INT_CTRL_INTA_SEL(x)      (((x) & 0x7) << 8)
293 #define NISTC_INT_CTRL_PASSTHRU0_POL    BIT(3)
294 #define NISTC_INT_CTRL_PASSTHRU1_POL    BIT(2)
295 #define NISTC_INT_CTRL_3PIN_INT         BIT(1)
296 #define NISTC_INT_CTRL_INT_POL          BIT(0)
297
298 #define NISTC_AI_OUT_CTRL_REG           60
299 #define NISTC_AI_OUT_CTRL_START_SEL     BIT(10)
300 #define NISTC_AI_OUT_CTRL_SCAN_IN_PROG_SEL(x)   (((x) & 0x3) << 8)
301 #define NISTC_AI_OUT_CTRL_EXTMUX_CLK_SEL(x)     (((x) & 0x3) << 6)
302 #define NISTC_AI_OUT_CTRL_LOCALMUX_CLK_SEL(x)   (((x) & 0x3) << 4)
303 #define NISTC_AI_OUT_CTRL_SC_TC_SEL(x)          (((x) & 0x3) << 2)
304 #define NISTC_AI_OUT_CTRL_CONVERT_SEL(x)        (((x) & 0x3) << 0)
305 #define NISTC_AI_OUT_CTRL_CONVERT_HIGH_Z        NISTC_AI_OUT_CTRL_CONVERT_SEL(0)
306 #define NISTC_AI_OUT_CTRL_CONVERT_GND           NISTC_AI_OUT_CTRL_CONVERT_SEL(1)
307 #define NISTC_AI_OUT_CTRL_CONVERT_LOW           NISTC_AI_OUT_CTRL_CONVERT_SEL(2)
308 #define NISTC_AI_OUT_CTRL_CONVERT_HIGH          NISTC_AI_OUT_CTRL_CONVERT_SEL(3)
309
310 #define NISTC_ATRIG_ETC_REG             61
311 #define NISTC_ATRIG_ETC_GPFO_1_ENA      BIT(15)
312 #define NISTC_ATRIG_ETC_GPFO_0_ENA      BIT(14)
313 #define NISTC_ATRIG_ETC_GPFO_0_SEL(x)   (((x) & 0x3) << 11)
314 #define NISTC_ATRIG_ETC_GPFO_1_SEL      BIT(7)
315 #define NISTC_ATRIG_ETC_DRV             BIT(4)
316 #define NISTC_ATRIG_ETC_ENA             BIT(3)
317 #define NISTC_ATRIG_ETC_MODE(x)         (((x) & 0x7) << 0)
318
319 #define NISTC_AI_START_STOP_REG         62
320 #define NISTC_AI_START_POLARITY         BIT(15)
321 #define NISTC_AI_STOP_POLARITY          BIT(14)
322 #define NISTC_AI_STOP_SYNC              BIT(13)
323 #define NISTC_AI_STOP_EDGE              BIT(12)
324 #define NISTC_AI_STOP_SEL(x)            (((x) & 0x1f) << 7)
325 #define NISTC_AI_START_SYNC             BIT(6)
326 #define NISTC_AI_START_EDGE             BIT(5)
327 #define NISTC_AI_START_SEL(x)           (((x) & 0x1f) << 0)
328
329 #define NISTC_AI_TRIG_SEL_REG           63
330 #define NISTC_AI_TRIG_START1_POLARITY   BIT(15)
331 #define NISTC_AI_TRIG_START2_POLARITY   BIT(14)
332 #define NISTC_AI_TRIG_START2_SYNC       BIT(13)
333 #define NISTC_AI_TRIG_START2_EDGE       BIT(12)
334 #define NISTC_AI_TRIG_START2_SEL(x)     (((x) & 0x1f) << 7)
335 #define NISTC_AI_TRIG_START1_SYNC       BIT(6)
336 #define NISTC_AI_TRIG_START1_EDGE       BIT(5)
337 #define NISTC_AI_TRIG_START1_SEL(x)     (((x) & 0x1f) << 0)
338
339 #define NISTC_AI_DIV_LOADA_REG          64
340
341 #define NISTC_AO_START_SEL_REG          66
342 #define NISTC_AO_START_UI2_SW_GATE      BIT(15)
343 #define NISTC_AO_START_UI2_EXT_GATE_POL BIT(14)
344 #define NISTC_AO_START_POLARITY         BIT(13)
345 #define NISTC_AO_START_AOFREQ_ENA       BIT(12)
346 #define NISTC_AO_START_UI2_EXT_GATE_SEL(x) (((x) & 0x1f) << 7)
347 #define NISTC_AO_START_SYNC             BIT(6)
348 #define NISTC_AO_START_EDGE             BIT(5)
349 #define NISTC_AO_START_SEL(x)           (((x) & 0x1f) << 0)
350
351 #define NISTC_AO_TRIG_SEL_REG           67
352 #define NISTC_AO_TRIG_UI2_EXT_GATE_ENA  BIT(15)
353 #define NISTC_AO_TRIG_DELAYED_START1    BIT(14)
354 #define NISTC_AO_TRIG_START1_POLARITY   BIT(13)
355 #define NISTC_AO_TRIG_UI2_SRC_POLARITY  BIT(12)
356 #define NISTC_AO_TRIG_UI2_SRC_SEL(x)    (((x) & 0x1f) << 7)
357 #define NISTC_AO_TRIG_START1_SYNC       BIT(6)
358 #define NISTC_AO_TRIG_START1_EDGE       BIT(5)
359 #define NISTC_AO_TRIG_START1_SEL(x)     (((x) & 0x1f) << 0)
360 #define NISTC_AO_TRIG_START1_SEL_MASK   NISTC_AO_TRIG_START1_SEL(0x1f)
361
362 #define NISTC_G0_AUTOINC_REG            68
363 #define NISTC_G1_AUTOINC_REG            69
364
365 #define NISTC_AO_MODE3_REG              70
366 #define NISTC_AO_MODE3_UI2_SW_NEXT_TC           BIT(13)
367 #define NISTC_AO_MODE3_UC_SW_EVERY_BC_TC        BIT(12)
368 #define NISTC_AO_MODE3_TRIG_LEN                 BIT(11)
369 #define NISTC_AO_MODE3_STOP_ON_OVERRUN_ERR      BIT(5)
370 #define NISTC_AO_MODE3_STOP_ON_BC_TC_TRIG_ERR   BIT(4)
371 #define NISTC_AO_MODE3_STOP_ON_BC_TC_ERR        BIT(3)
372 #define NISTC_AO_MODE3_NOT_AN_UPDATE            BIT(2)
373 #define NISTC_AO_MODE3_SW_GATE                  BIT(1)
374 #define NISTC_AO_MODE3_LAST_GATE_DISABLE        BIT(0)  /* M-Series only */
375
376 #define NISTC_RESET_REG                 72
377 #define NISTC_RESET_SOFTWARE            BIT(11)
378 #define NISTC_RESET_AO_CFG_END          BIT(9)
379 #define NISTC_RESET_AI_CFG_END          BIT(8)
380 #define NISTC_RESET_AO_CFG_START        BIT(5)
381 #define NISTC_RESET_AI_CFG_START        BIT(4)
382 #define NISTC_RESET_G1                  BIT(3)
383 #define NISTC_RESET_G0                  BIT(2)
384 #define NISTC_RESET_AO                  BIT(1)
385 #define NISTC_RESET_AI                  BIT(0)
386
387 #define NISTC_INTA_ENA_REG              73
388 #define NISTC_INTA2_ENA_REG             74
389 #define NISTC_INTA_ENA_PASSTHRU0        BIT(9)
390 #define NISTC_INTA_ENA_G0_GATE          BIT(8)
391 #define NISTC_INTA_ENA_AI_FIFO          BIT(7)
392 #define NISTC_INTA_ENA_G0_TC            BIT(6)
393 #define NISTC_INTA_ENA_AI_ERR           BIT(5)
394 #define NISTC_INTA_ENA_AI_STOP          BIT(4)
395 #define NISTC_INTA_ENA_AI_START         BIT(3)
396 #define NISTC_INTA_ENA_AI_START2        BIT(2)
397 #define NISTC_INTA_ENA_AI_START1        BIT(1)
398 #define NISTC_INTA_ENA_AI_SC_TC         BIT(0)
399 #define NISTC_INTA_ENA_AI_MASK          (NISTC_INTA_ENA_AI_FIFO |       \
400                                          NISTC_INTA_ENA_AI_ERR |        \
401                                          NISTC_INTA_ENA_AI_STOP |       \
402                                          NISTC_INTA_ENA_AI_START |      \
403                                          NISTC_INTA_ENA_AI_START2 |     \
404                                          NISTC_INTA_ENA_AI_START1 |     \
405                                          NISTC_INTA_ENA_AI_SC_TC)
406
407 #define NISTC_INTB_ENA_REG              75
408 #define NISTC_INTB2_ENA_REG             76
409 #define NISTC_INTB_ENA_PASSTHRU1        BIT(11)
410 #define NISTC_INTB_ENA_G1_GATE          BIT(10)
411 #define NISTC_INTB_ENA_G1_TC            BIT(9)
412 #define NISTC_INTB_ENA_AO_FIFO          BIT(8)
413 #define NISTC_INTB_ENA_AO_UI2_TC        BIT(7)
414 #define NISTC_INTB_ENA_AO_UC_TC         BIT(6)
415 #define NISTC_INTB_ENA_AO_ERR           BIT(5)
416 #define NISTC_INTB_ENA_AO_STOP          BIT(4)
417 #define NISTC_INTB_ENA_AO_START         BIT(3)
418 #define NISTC_INTB_ENA_AO_UPDATE        BIT(2)
419 #define NISTC_INTB_ENA_AO_START1        BIT(1)
420 #define NISTC_INTB_ENA_AO_BC_TC         BIT(0)
421
422 #define NISTC_AI_PERSONAL_REG           77
423 #define NISTC_AI_PERSONAL_SHIFTIN_PW            BIT(15)
424 #define NISTC_AI_PERSONAL_EOC_POLARITY          BIT(14)
425 #define NISTC_AI_PERSONAL_SOC_POLARITY          BIT(13)
426 #define NISTC_AI_PERSONAL_SHIFTIN_POL           BIT(12)
427 #define NISTC_AI_PERSONAL_CONVERT_TIMEBASE      BIT(11)
428 #define NISTC_AI_PERSONAL_CONVERT_PW            BIT(10)
429 #define NISTC_AI_PERSONAL_CONVERT_ORIG_PULSE    BIT(9)
430 #define NISTC_AI_PERSONAL_FIFO_FLAGS_POL        BIT(8)
431 #define NISTC_AI_PERSONAL_OVERRUN_MODE          BIT(7)
432 #define NISTC_AI_PERSONAL_EXTMUX_CLK_PW         BIT(6)
433 #define NISTC_AI_PERSONAL_LOCALMUX_CLK_PW       BIT(5)
434 #define NISTC_AI_PERSONAL_AIFREQ_POL            BIT(4)
435
436 #define NISTC_AO_PERSONAL_REG           78
437 #define NISTC_AO_PERSONAL_MULTI_DACS            BIT(15) /* M-Series only */
438 #define NISTC_AO_PERSONAL_NUM_DAC               BIT(14) /* 1:single; 0:dual */
439 #define NISTC_AO_PERSONAL_FAST_CPU              BIT(13) /* M-Series reserved */
440 #define NISTC_AO_PERSONAL_TMRDACWR_PW           BIT(12)
441 #define NISTC_AO_PERSONAL_FIFO_FLAGS_POL        BIT(11) /* M-Series reserved */
442 #define NISTC_AO_PERSONAL_FIFO_ENA              BIT(10)
443 #define NISTC_AO_PERSONAL_AOFREQ_POL            BIT(9)  /* M-Series reserved */
444 #define NISTC_AO_PERSONAL_DMA_PIO_CTRL          BIT(8)  /* M-Series reserved */
445 #define NISTC_AO_PERSONAL_UPDATE_ORIG_PULSE     BIT(7)
446 #define NISTC_AO_PERSONAL_UPDATE_TIMEBASE       BIT(6)
447 #define NISTC_AO_PERSONAL_UPDATE_PW             BIT(5)
448 #define NISTC_AO_PERSONAL_BC_SRC_SEL            BIT(4)
449 #define NISTC_AO_PERSONAL_INTERVAL_BUFFER_MODE  BIT(3)
450
451 #define NISTC_RTSI_TRIGA_OUT_REG        79
452 #define NISTC_RTSI_TRIGB_OUT_REG        80
453 #define NISTC_RTSI_TRIGB_SUB_SEL1       BIT(15) /* not for M-Series */
454 #define NISTC_RTSI_TRIG(_c, _s)         (((_s) & 0xf) << (((_c) % 4) * 4))
455 #define NISTC_RTSI_TRIG_MASK(_c)        NISTC_RTSI_TRIG((_c), 0xf)
456 #define NISTC_RTSI_TRIG_TO_SRC(_c, _b)  (((_b) >> (((_c) % 4) * 4)) & 0xf)
457
458 #define NISTC_RTSI_BOARD_REG            81
459
460 #define NISTC_CFG_MEM_CLR_REG           82
461 #define NISTC_ADC_FIFO_CLR_REG          83
462 #define NISTC_DAC_FIFO_CLR_REG          84
463 #define NISTC_WR_STROBE3_REG            85
464
465 #define NISTC_AO_OUT_CTRL_REG           86
466 #define NISTC_AO_OUT_CTRL_EXT_GATE_ENA          BIT(15)
467 #define NISTC_AO_OUT_CTRL_EXT_GATE_SEL(x)       (((x) & 0x1f) << 10)
468 #define NISTC_AO_OUT_CTRL_CHANS(x)              (((x) & 0xf) << 6)
469 #define NISTC_AO_OUT_CTRL_UPDATE2_SEL(x)        (((x) & 0x3) << 4)
470 #define NISTC_AO_OUT_CTRL_EXT_GATE_POL          BIT(3)
471 #define NISTC_AO_OUT_CTRL_UPDATE2_TOGGLE        BIT(2)
472 #define NISTC_AO_OUT_CTRL_UPDATE_SEL(x)         (((x) & 0x3) << 0)
473 #define NISTC_AO_OUT_CTRL_UPDATE_SEL_HIGHZ      NISTC_AO_OUT_CTRL_UPDATE_SEL(0)
474 #define NISTC_AO_OUT_CTRL_UPDATE_SEL_GND        NISTC_AO_OUT_CTRL_UPDATE_SEL(1)
475 #define NISTC_AO_OUT_CTRL_UPDATE_SEL_LOW        NISTC_AO_OUT_CTRL_UPDATE_SEL(2)
476 #define NISTC_AO_OUT_CTRL_UPDATE_SEL_HIGH       NISTC_AO_OUT_CTRL_UPDATE_SEL(3)
477
478 #define NISTC_AI_MODE3_REG              87
479 #define NISTC_AI_MODE3_TRIG_LEN         BIT(15)
480 #define NISTC_AI_MODE3_DELAY_START      BIT(14)
481 #define NISTC_AI_MODE3_SOFTWARE_GATE    BIT(13)
482 #define NISTC_AI_MODE3_SI_TRIG_DELAY    BIT(12)
483 #define NISTC_AI_MODE3_SI2_SRC_SEL      BIT(11)
484 #define NISTC_AI_MODE3_DELAYED_START2   BIT(10)
485 #define NISTC_AI_MODE3_DELAYED_START1   BIT(9)
486 #define NISTC_AI_MODE3_EXT_GATE_MODE    BIT(8)
487 #define NISTC_AI_MODE3_FIFO_MODE(x)     (((x) & 0x3) << 6)
488 #define NISTC_AI_MODE3_FIFO_MODE_NE     NISTC_AI_MODE3_FIFO_MODE(0)
489 #define NISTC_AI_MODE3_FIFO_MODE_HF     NISTC_AI_MODE3_FIFO_MODE(1)
490 #define NISTC_AI_MODE3_FIFO_MODE_F      NISTC_AI_MODE3_FIFO_MODE(2)
491 #define NISTC_AI_MODE3_FIFO_MODE_HF_E   NISTC_AI_MODE3_FIFO_MODE(3)
492 #define NISTC_AI_MODE3_EXT_GATE_POL     BIT(5)
493 #define NISTC_AI_MODE3_EXT_GATE_SEL(x)  (((x) & 0x1f) << 0)
494
495 #define NISTC_AI_STATUS1_REG            2
496 #define NISTC_AI_STATUS1_INTA           BIT(15)
497 #define NISTC_AI_STATUS1_FIFO_F         BIT(14)
498 #define NISTC_AI_STATUS1_FIFO_HF        BIT(13)
499 #define NISTC_AI_STATUS1_FIFO_E         BIT(12)
500 #define NISTC_AI_STATUS1_OVERRUN        BIT(11)
501 #define NISTC_AI_STATUS1_OVERFLOW       BIT(10)
502 #define NISTC_AI_STATUS1_SC_TC_ERR      BIT(9)
503 #define NISTC_AI_STATUS1_OVER           (NISTC_AI_STATUS1_OVERRUN |     \
504                                          NISTC_AI_STATUS1_OVERFLOW)
505 #define NISTC_AI_STATUS1_ERR            (NISTC_AI_STATUS1_OVER |        \
506                                          NISTC_AI_STATUS1_SC_TC_ERR)
507 #define NISTC_AI_STATUS1_START2         BIT(8)
508 #define NISTC_AI_STATUS1_START1         BIT(7)
509 #define NISTC_AI_STATUS1_SC_TC          BIT(6)
510 #define NISTC_AI_STATUS1_START          BIT(5)
511 #define NISTC_AI_STATUS1_STOP           BIT(4)
512 #define NISTC_AI_STATUS1_G0_TC          BIT(3)
513 #define NISTC_AI_STATUS1_G0_GATE        BIT(2)
514 #define NISTC_AI_STATUS1_FIFO_REQ       BIT(1)
515 #define NISTC_AI_STATUS1_PASSTHRU0      BIT(0)
516
517 #define NISTC_AO_STATUS1_REG            3
518 #define NISTC_AO_STATUS1_INTB           BIT(15)
519 #define NISTC_AO_STATUS1_FIFO_F         BIT(14)
520 #define NISTC_AO_STATUS1_FIFO_HF        BIT(13)
521 #define NISTC_AO_STATUS1_FIFO_E         BIT(12)
522 #define NISTC_AO_STATUS1_BC_TC_ERR      BIT(11)
523 #define NISTC_AO_STATUS1_START          BIT(10)
524 #define NISTC_AO_STATUS1_OVERRUN        BIT(9)
525 #define NISTC_AO_STATUS1_START1         BIT(8)
526 #define NISTC_AO_STATUS1_BC_TC          BIT(7)
527 #define NISTC_AO_STATUS1_UC_TC          BIT(6)
528 #define NISTC_AO_STATUS1_UPDATE         BIT(5)
529 #define NISTC_AO_STATUS1_UI2_TC         BIT(4)
530 #define NISTC_AO_STATUS1_G1_TC          BIT(3)
531 #define NISTC_AO_STATUS1_G1_GATE        BIT(2)
532 #define NISTC_AO_STATUS1_FIFO_REQ       BIT(1)
533 #define NISTC_AO_STATUS1_PASSTHRU1      BIT(0)
534
535 #define NISTC_G01_STATUS_REG            4
536
537 #define NISTC_AI_STATUS2_REG            5
538
539 #define NISTC_AO_STATUS2_REG            6
540
541 #define NISTC_DIO_IN_REG                7
542
543 #define NISTC_G0_HW_SAVE_REG            8
544 #define NISTC_G1_HW_SAVE_REG            10
545
546 #define NISTC_G0_SAVE_REG               12
547 #define NISTC_G1_SAVE_REG               14
548
549 #define NISTC_AO_UI_SAVE_REG            16
550 #define NISTC_AO_BC_SAVE_REG            18
551 #define NISTC_AO_UC_SAVE_REG            20
552
553 #define NISTC_STATUS1_REG               27
554 #define NISTC_STATUS1_SERIO_IN_PROG     BIT(12)
555
556 #define AI_SI_Save_Registers            64
557 #define AI_SC_Save_Registers            66
558
559 #define DIO_Serial_Input_Register       28
560 #define Joint_Status_2_Register         29
561 enum Joint_Status_2_Bits {
562         AO_TMRDACWRs_In_Progress_St = 0x20,
563 };
564
565 /* command register */
566 #define G_Disarm_Copy                   _bit15  /* strobe */
567 #define G_Save_Trace_Copy               _bit14
568 #define G_Arm_Copy                      _bit13  /* strobe */
569 #define G_Bank_Switch_Start             _bit10  /* strobe */
570 #define G_Little_Big_Endian             _bit9
571 #define G_Synchronized_Gate             _bit8
572 #define G_Write_Switch                  _bit7
573 #define G_Up_Down(a)                    (((a)&0x03)<<5)
574 #define G_Disarm                        _bit4   /* strobe */
575 #define G_Analog_Trigger_Reset          _bit3   /* strobe */
576 #define G_Save_Trace                    _bit1
577 #define G_Arm                           _bit0   /* strobe */
578
579 /*channel agnostic names for the command register #defines */
580 #define G_Bank_Switch_Enable            _bit12
581 #define G_Bank_Switch_Mode              _bit11
582 #define G_Load                          _bit2   /* strobe */
583
584 /* input select register */
585 #define G_Gate_Select(a)                (((a)&0x1f)<<7)
586 #define G_Source_Select(a)              (((a)&0x1f)<<2)
587 #define G_Write_Acknowledges_Irq        _bit1
588 #define G_Read_Acknowledges_Irq         _bit0
589
590 /* same input select register, but with channel agnostic names */
591 #define G_Source_Polarity               _bit15
592 #define G_Output_Polarity               _bit14
593 #define G_OR_Gate                       _bit13
594 #define G_Gate_Select_Load_Source       _bit12
595
596 /* mode register */
597 #define G_Loading_On_TC                 _bit12
598 #define G_Output_Mode(a)                (((a)&0x03)<<8)
599 #define G_Trigger_Mode_For_Edge_Gate(a) (((a)&0x03)<<3)
600 #define G_Gating_Mode(a)                (((a)&0x03)<<0)
601
602 /* same input mode register, but with channel agnostic names */
603 #define G_Load_Source_Select            _bit7
604 #define G_Reload_Source_Switching       _bit15
605 #define G_Loading_On_Gate               _bit14
606 #define G_Gate_Polarity                 _bit13
607
608 #define G_Counting_Once(a)              (((a)&0x03)<<10)
609 #define G_Stop_Mode(a)                  (((a)&0x03)<<5)
610 #define G_Gate_On_Both_Edges            _bit2
611
612 /* G_Status_Register */
613 #define G1_Gate_Error_St                _bit15
614 #define G0_Gate_Error_St                _bit14
615 #define G1_TC_Error_St                  _bit13
616 #define G0_TC_Error_St                  _bit12
617 #define G1_No_Load_Between_Gates_St     _bit11
618 #define G0_No_Load_Between_Gates_St     _bit10
619 #define G1_Armed_St                     _bit9
620 #define G0_Armed_St                     _bit8
621 #define G1_Stale_Data_St                _bit7
622 #define G0_Stale_Data_St                _bit6
623 #define G1_Next_Load_Source_St          _bit5
624 #define G0_Next_Load_Source_St          _bit4
625 #define G1_Counting_St                  _bit3
626 #define G0_Counting_St                  _bit2
627 #define G1_Save_St                      _bit1
628 #define G0_Save_St                      _bit0
629
630 /* general purpose counter timer */
631 #define G_Autoincrement(a)              ((a)<<0)
632
633 /* Additional windowed registers unique to E series */
634
635 /* 16 bit registers shadowed from DAQ-STC */
636 #define Window_Address                  0x00
637 #define Window_Data                     0x02
638
639 /* i/o port offsets */
640
641 /* 8 bit registers */
642 #define XXX_Status                      0x01
643 enum XXX_Status_Bits {
644         PROMOUT = 0x1,
645         AI_FIFO_LOWER_NOT_EMPTY = 0x8,
646 };
647 #define Serial_Command                  0x0d
648 #define Misc_Command                    0x0f
649 #define Port_A                          0x19
650 #define Port_B                          0x1b
651 #define Port_C                          0x1d
652 #define Configuration                   0x1f
653 #define Strobes                         0x01
654 #define Channel_A_Mode                  0x03
655 #define Channel_B_Mode                  0x05
656 #define Channel_C_Mode                  0x07
657 #define AI_AO_Select                    0x09
658 enum AI_AO_Select_Bits {
659         AI_DMA_Select_Shift = 0,
660         AI_DMA_Select_Mask = 0xf,
661         AO_DMA_Select_Shift = 4,
662         AO_DMA_Select_Mask = 0xf << AO_DMA_Select_Shift
663 };
664 #define G0_G1_Select                    0x0b
665 static inline unsigned ni_stc_dma_channel_select_bitfield(unsigned channel)
666 {
667         if (channel < 4)
668                 return 1 << channel;
669         if (channel == 4)
670                 return 0x3;
671         if (channel == 5)
672                 return 0x5;
673         BUG();
674         return 0;
675 }
676
677 static inline unsigned GPCT_DMA_Select_Bits(unsigned gpct_index,
678                                             unsigned mite_channel)
679 {
680         BUG_ON(gpct_index > 1);
681         return ni_stc_dma_channel_select_bitfield(mite_channel) << (4 *
682                                                                     gpct_index);
683 }
684
685 static inline unsigned GPCT_DMA_Select_Mask(unsigned gpct_index)
686 {
687         BUG_ON(gpct_index > 1);
688         return 0xf << (4 * gpct_index);
689 }
690
691 /* 16 bit registers */
692
693 #define Configuration_Memory_Low        0x10
694 enum Configuration_Memory_Low_Bits {
695         AI_DITHER = 0x200,
696         AI_LAST_CHANNEL = 0x8000,
697 };
698 #define Configuration_Memory_High       0x12
699 enum Configuration_Memory_High_Bits {
700         AI_AC_COUPLE = 0x800,
701         AI_DIFFERENTIAL = 0x1000,
702         AI_COMMON = 0x2000,
703         AI_GROUND = 0x3000,
704 };
705 static inline unsigned int AI_CONFIG_CHANNEL(unsigned int channel)
706 {
707         return channel & 0x3f;
708 }
709
710 #define ADC_FIFO_Data_Register          0x1c
711
712 #define AO_Configuration                0x16
713 #define AO_Bipolar              _bit0
714 #define AO_Deglitch             _bit1
715 #define AO_Ext_Ref              _bit2
716 #define AO_Ground_Ref           _bit3
717 #define AO_Channel(x)           ((x) << 8)
718
719 #define DAC_FIFO_Data                   0x1e
720 #define DAC0_Direct_Data                0x18
721 #define DAC1_Direct_Data                0x1a
722
723 /* 611x registers (these boards differ from the e-series) */
724
725 #define Magic_611x                      0x19    /* w8 (new) */
726 #define Calibration_Channel_Select_611x 0x1a    /* w16 (new) */
727 #define ADC_FIFO_Data_611x              0x1c    /* r32 (incompatible) */
728 #define AI_FIFO_Offset_Load_611x        0x05    /* r8 (new) */
729 #define DAC_FIFO_Data_611x              0x14    /* w32 (incompatible) */
730 #define Cal_Gain_Select_611x            0x05    /* w8 (new) */
731
732 #define AO_Window_Address_611x          0x18
733 #define AO_Window_Data_611x             0x1e
734
735 /* 6143 registers */
736 #define Magic_6143                      0x19    /* w8 */
737 #define G0G1_DMA_Select_6143            0x0B    /* w8 */
738 #define PipelineDelay_6143              0x1f    /* w8 */
739 #define EOC_Set_6143                    0x1D    /* w8 */
740 #define AIDMA_Select_6143               0x09    /* w8 */
741 #define AIFIFO_Data_6143                0x8C    /* w32 */
742 #define AIFIFO_Flag_6143                0x84    /* w32 */
743 #define AIFIFO_Control_6143             0x88    /* w32 */
744 #define AIFIFO_Status_6143              0x88    /* w32 */
745 #define AIFIFO_DMAThreshold_6143        0x90    /* w32 */
746 #define AIFIFO_Words_Available_6143     0x94    /* w32 */
747
748 #define Calibration_Channel_6143        0x42    /* w16 */
749 #define Calibration_LowTime_6143        0x20    /* w16 */
750 #define Calibration_HighTime_6143       0x22    /* w16 */
751 #define Relay_Counter_Load_Val__6143    0x4C    /* w32 */
752 #define Signature_6143                  0x50    /* w32 */
753 #define Release_Date_6143               0x54    /* w32 */
754 #define Release_Oldest_Date_6143        0x58    /* w32 */
755
756 #define Calibration_Channel_6143_RelayOn        0x8000  /* Calibration relay switch On */
757 #define Calibration_Channel_6143_RelayOff       0x4000  /* Calibration relay switch Off */
758 #define Calibration_Channel_Gnd_Gnd     0x00    /* Offset Calibration */
759 #define Calibration_Channel_2v5_Gnd     0x02    /* 2.5V Reference */
760 #define Calibration_Channel_Pwm_Gnd     0x05    /* +/- 5V Self Cal */
761 #define Calibration_Channel_2v5_Pwm     0x0a    /* PWM Calibration */
762 #define Calibration_Channel_Pwm_Pwm     0x0d    /* CMRR */
763 #define Calibration_Channel_Gnd_Pwm     0x0e    /* PWM Calibration */
764
765 /* 671x, 611x registers */
766
767 /* 671xi, 611x windowed ao registers */
768 enum windowed_regs_67xx_61xx {
769         AO_Immediate_671x = 0x11,       /* W 16 */
770         AO_Timed_611x = 0x10,   /* W 16 */
771         AO_FIFO_Offset_Load_611x = 0x13,        /* W32 */
772         AO_Later_Single_Point_Updates = 0x14,   /* W 16 */
773         AO_Waveform_Generation_611x = 0x15,     /* W 16 */
774         AO_Misc_611x = 0x16,    /* W 16 */
775         AO_Calibration_Channel_Select_67xx = 0x17,      /* W 16 */
776         AO_Configuration_2_67xx = 0x18, /* W 16 */
777         CAL_ADC_Command_67xx = 0x19,    /* W 8 */
778         CAL_ADC_Status_67xx = 0x1a,     /* R 8 */
779         CAL_ADC_Data_67xx = 0x1b,       /* R 16 */
780         CAL_ADC_Config_Data_High_Word_67xx = 0x1c,      /* RW 16 */
781         CAL_ADC_Config_Data_Low_Word_67xx = 0x1d,       /* RW 16 */
782 };
783 static inline unsigned int DACx_Direct_Data_671x(int channel)
784 {
785         return channel;
786 }
787
788 enum AO_Misc_611x_Bits {
789         CLEAR_WG = 1,
790 };
791 enum cs5529_configuration_bits {
792         CSCFG_CAL_CONTROL_MASK = 0x7,
793         CSCFG_SELF_CAL_OFFSET = 0x1,
794         CSCFG_SELF_CAL_GAIN = 0x2,
795         CSCFG_SELF_CAL_OFFSET_GAIN = 0x3,
796         CSCFG_SYSTEM_CAL_OFFSET = 0x5,
797         CSCFG_SYSTEM_CAL_GAIN = 0x6,
798         CSCFG_DONE = 1 << 3,
799         CSCFG_POWER_SAVE_SELECT = 1 << 4,
800         CSCFG_PORT_MODE = 1 << 5,
801         CSCFG_RESET_VALID = 1 << 6,
802         CSCFG_RESET = 1 << 7,
803         CSCFG_UNIPOLAR = 1 << 12,
804         CSCFG_WORD_RATE_2180_CYCLES = 0x0 << 13,
805         CSCFG_WORD_RATE_1092_CYCLES = 0x1 << 13,
806         CSCFG_WORD_RATE_532_CYCLES = 0x2 << 13,
807         CSCFG_WORD_RATE_388_CYCLES = 0x3 << 13,
808         CSCFG_WORD_RATE_324_CYCLES = 0x4 << 13,
809         CSCFG_WORD_RATE_17444_CYCLES = 0x5 << 13,
810         CSCFG_WORD_RATE_8724_CYCLES = 0x6 << 13,
811         CSCFG_WORD_RATE_4364_CYCLES = 0x7 << 13,
812         CSCFG_WORD_RATE_MASK = 0x7 << 13,
813         CSCFG_LOW_POWER = 1 << 16,
814 };
815 static inline unsigned int CS5529_CONFIG_DOUT(int output)
816 {
817         return 1 << (18 + output);
818 }
819
820 static inline unsigned int CS5529_CONFIG_AOUT(int output)
821 {
822         return 1 << (22 + output);
823 }
824
825 enum cs5529_command_bits {
826         CSCMD_POWER_SAVE = 0x1,
827         CSCMD_REGISTER_SELECT_MASK = 0xe,
828         CSCMD_OFFSET_REGISTER = 0x0,
829         CSCMD_GAIN_REGISTER = 0x2,
830         CSCMD_CONFIG_REGISTER = 0x4,
831         CSCMD_READ = 0x10,
832         CSCMD_CONTINUOUS_CONVERSIONS = 0x20,
833         CSCMD_SINGLE_CONVERSION = 0x40,
834         CSCMD_COMMAND = 0x80,
835 };
836 enum cs5529_status_bits {
837         CSS_ADC_BUSY = 0x1,
838         CSS_OSC_DETECT = 0x2,   /* indicates adc error */
839         CSS_OVERRANGE = 0x4,
840 };
841 #define SerDacLd(x)                     (0x08<<(x))
842
843 /*
844         This is stuff unique to the NI E series drivers,
845         but I thought I'd put it here anyway.
846 */
847
848 enum { ai_gain_16 =
849             0, ai_gain_8, ai_gain_14, ai_gain_4, ai_gain_611x, ai_gain_622x,
850         ai_gain_628x, ai_gain_6143
851 };
852 enum caldac_enum { caldac_none = 0, mb88341, dac8800, dac8043, ad8522,
853         ad8804, ad8842, ad8804_debug
854 };
855 enum ni_reg_type {
856         ni_reg_normal = 0x0,
857         ni_reg_611x = 0x1,
858         ni_reg_6711 = 0x2,
859         ni_reg_6713 = 0x4,
860         ni_reg_67xx_mask = 0x6,
861         ni_reg_6xxx_mask = 0x7,
862         ni_reg_622x = 0x8,
863         ni_reg_625x = 0x10,
864         ni_reg_628x = 0x18,
865         ni_reg_m_series_mask = 0x18,
866         ni_reg_6143 = 0x20
867 };
868
869 static const struct comedi_lrange range_ni_E_ao_ext;
870
871 /*
872  * M-Series specific registers not handled by the DAQ-STC and GPCT register
873  * remapping.
874  */
875 #define NI_M_CDIO_DMA_SEL_REG           0x007
876 #define NI_M_CDIO_DMA_SEL_CDO(x)        (((x) & 0xf) << 4)
877 #define NI_M_CDIO_DMA_SEL_CDO_MASK      NI_M_CDIO_DMA_SEL_CDO(0xf)
878 #define NI_M_CDIO_DMA_SEL_CDI(x)        (((x) & 0xf) << 0)
879 #define NI_M_CDIO_DMA_SEL_CDI_MASK      NI_M_CDIO_DMA_SEL_CDI(0xf)
880 #define NI_M_SCXI_STATUS_REG            0x007
881 #define NI_M_AI_AO_SEL_REG              0x009
882 #define NI_M_G0_G1_SEL_REG              0x00b
883 #define NI_M_MISC_CMD_REG               0x00f
884 #define NI_M_SCXI_SER_DO_REG            0x011
885 #define NI_M_SCXI_CTRL_REG              0x013
886 #define NI_M_SCXI_OUT_ENA_REG           0x015
887 #define NI_M_AI_FIFO_DATA_REG           0x01c
888 #define NI_M_DIO_REG                    0x024
889 #define NI_M_DIO_DIR_REG                0x028
890 #define NI_M_CAL_PWM_REG                0x040
891 #define NI_M_CAL_PWM_HIGH_TIME(x)       (((x) & 0xffff) << 16)
892 #define NI_M_CAL_PWM_LOW_TIME(x)        (((x) & 0xffff) << 0)
893 #define NI_M_GEN_PWM_REG(x)             (0x044 + ((x) * 2))
894 #define NI_M_AI_CFG_FIFO_DATA_REG       0x05e
895 #define NI_M_AI_CFG_LAST_CHAN           BIT(14)
896 #define NI_M_AI_CFG_DITHER              BIT(13)
897 #define NI_M_AI_CFG_POLARITY            BIT(12)
898 #define NI_M_AI_CFG_GAIN(x)             (((x) & 0x7) << 9)
899 #define NI_M_AI_CFG_CHAN_TYPE(x)        (((x) & 0x7) << 6)
900 #define NI_M_AI_CFG_CHAN_TYPE_MASK      NI_M_AI_CFG_CHAN_TYPE(7)
901 #define NI_M_AI_CFG_CHAN_TYPE_CALIB     NI_M_AI_CFG_CHAN_TYPE(0)
902 #define NI_M_AI_CFG_CHAN_TYPE_DIFF      NI_M_AI_CFG_CHAN_TYPE(1)
903 #define NI_M_AI_CFG_CHAN_TYPE_COMMON    NI_M_AI_CFG_CHAN_TYPE(2)
904 #define NI_M_AI_CFG_CHAN_TYPE_GROUND    NI_M_AI_CFG_CHAN_TYPE(3)
905 #define NI_M_AI_CFG_CHAN_TYPE_AUX       NI_M_AI_CFG_CHAN_TYPE(5)
906 #define NI_M_AI_CFG_CHAN_TYPE_GHOST     NI_M_AI_CFG_CHAN_TYPE(7)
907 #define NI_M_AI_CFG_BANK_SEL(x)         ((((x) & 0x40) << 4) | ((x) & 0x30))
908 #define NI_M_AI_CFG_CHAN_SEL(x)         (((x) & 0xf) << 0)
909 #define NI_M_INTC_ENA_REG               0x088
910 #define NI_M_INTC_ENA                   BIT(0)
911 #define NI_M_INTC_STATUS_REG            0x088
912 #define NI_M_INTC_STATUS                BIT(0)
913 #define NI_M_ATRIG_CTRL_REG             0x08c
914 #define NI_M_AO_SER_INT_ENA_REG         0x0a0
915 #define NI_M_AO_SER_INT_ACK_REG         0x0a1
916 #define NI_M_AO_SER_INT_STATUS_REG      0x0a1
917 #define NI_M_AO_CALIB_REG               0x0a3
918 #define NI_M_AO_FIFO_DATA_REG           0x0a4
919 #define NI_M_PFI_FILTER_REG             0x0b0
920 #define NI_M_PFI_FILTER_SEL(_c, _f)     (((_f) & 0x3) << ((_c) * 2))
921 #define NI_M_PFI_FILTER_SEL_MASK(_c)    NI_M_PFI_FILTER_SEL((_c), 0x3)
922 #define NI_M_RTSI_FILTER_REG            0x0b4
923 #define NI_M_SCXI_LEGACY_COMPAT_REG     0x0bc
924 #define NI_M_DAC_DIRECT_DATA_REG(x)     (0x0c0 + ((x) * 4))
925 #define NI_M_AO_WAVEFORM_ORDER_REG(x)   (0x0c2 + ((x) * 4))
926 #define NI_M_AO_CFG_BANK_REG(x)         (0x0c3 + ((x) * 4))
927 #define NI_M_AO_CFG_BANK_BIPOLAR        BIT(7)
928 #define NI_M_AO_CFG_BANK_UPDATE_TIMED   BIT(6)
929 #define NI_M_AO_CFG_BANK_REF(x)         (((x) & 0x7) << 3)
930 #define NI_M_AO_CFG_BANK_REF_MASK       NI_M_AO_CFG_BANK_REF(7)
931 #define NI_M_AO_CFG_BANK_REF_INT_10V    NI_M_AO_CFG_BANK_REF(0)
932 #define NI_M_AO_CFG_BANK_REF_INT_5V     NI_M_AO_CFG_BANK_REF(1)
933 #define NI_M_AO_CFG_BANK_OFFSET(x)      (((x) & 0x7) << 0)
934 #define NI_M_AO_CFG_BANK_OFFSET_MASK    NI_M_AO_CFG_BANK_OFFSET(7)
935 #define NI_M_AO_CFG_BANK_OFFSET_0V      NI_M_AO_CFG_BANK_OFFSET(0)
936 #define NI_M_AO_CFG_BANK_OFFSET_5V      NI_M_AO_CFG_BANK_OFFSET(1)
937 #define NI_M_RTSI_SHARED_MUX_REG        0x1a2
938 #define NI_M_CLK_FOUT2_REG              0x1c4
939 #define NI_M_CLK_FOUT2_RTSI_10MHZ       BIT(7)
940 #define NI_M_CLK_FOUT2_TIMEBASE3_PLL    BIT(6)
941 #define NI_M_CLK_FOUT2_TIMEBASE1_PLL    BIT(5)
942 #define NI_M_CLK_FOUT2_PLL_SRC(x)       (((x) & 0x1f) << 0)
943 #define NI_M_CLK_FOUT2_PLL_SRC_MASK     NI_M_CLK_FOUT2_PLL_SRC(0x1f)
944 #define NI_M_MAX_RTSI_CHAN              7
945 #define NI_M_CLK_FOUT2_PLL_SRC_RTSI(x)  (((x) == NI_M_MAX_RTSI_CHAN)    \
946                                          ? NI_M_CLK_FOUT2_PLL_SRC(0x1b) \
947                                          : NI_M_CLK_FOUT2_PLL_SRC(0xb + (x)))
948 #define NI_M_CLK_FOUT2_PLL_SRC_STAR     NI_M_CLK_FOUT2_PLL_SRC(0x14)
949 #define NI_M_CLK_FOUT2_PLL_SRC_PXI10    NI_M_CLK_FOUT2_PLL_SRC(0x1d)
950 #define NI_M_PLL_CTRL_REG               0x1c6
951 #define NI_M_PLL_CTRL_VCO_MODE(x)       (((x) & 0x3) << 13)
952 #define NI_M_PLL_CTRL_VCO_MODE_200_325MHZ NI_M_PLL_CTRL_VCO_MODE(0)
953 #define NI_M_PLL_CTRL_VCO_MODE_175_225MHZ NI_M_PLL_CTRL_VCO_MODE(1)
954 #define NI_M_PLL_CTRL_VCO_MODE_100_225MHZ NI_M_PLL_CTRL_VCO_MODE(2)
955 #define NI_M_PLL_CTRL_VCO_MODE_75_150MHZ  NI_M_PLL_CTRL_VCO_MODE(3)
956 #define NI_M_PLL_CTRL_ENA               BIT(12)
957 #define NI_M_PLL_MAX_DIVISOR            0x10
958 #define NI_M_PLL_CTRL_DIVISOR(x)        (((x) & 0xf) << 8)
959 #define NI_M_PLL_MAX_MULTIPLIER         0x100
960 #define NI_M_PLL_CTRL_MULTIPLIER(x)     (((x) & 0xff) << 0)
961 #define NI_M_PLL_STATUS_REG             0x1c8
962 #define NI_M_PLL_STATUS_LOCKED          BIT(0)
963 #define NI_M_PFI_OUT_SEL_REG(x)         (0x1d0 + ((x) * 2))
964 #define NI_M_PFI_CHAN(_c)               (((_c) % 3) * 5)
965 #define NI_M_PFI_OUT_SEL(_c, _s)        (((_s) & 0x1f) << NI_M_PFI_CHAN(_c))
966 #define NI_M_PFI_OUT_SEL_MASK(_c)       (0x1f << NI_M_PFI_CHAN(_c))
967 #define NI_M_PFI_OUT_SEL_TO_SRC(_c, _b) (((_b) >> NI_M_PFI_CHAN(_c)) & 0x1f)
968 #define NI_M_PFI_DI_REG                 0x1dc
969 #define NI_M_PFI_DO_REG                 0x1de
970 #define NI_M_CFG_BYPASS_FIFO_REG        0x218
971 #define NI_M_CFG_BYPASS_FIFO            BIT(31)
972 #define NI_M_CFG_BYPASS_AI_POLARITY     BIT(22)
973 #define NI_M_CFG_BYPASS_AI_DITHER       BIT(21)
974 #define NI_M_CFG_BYPASS_AI_GAIN(x)      (((x) & 0x7) << 18)
975 #define NI_M_CFG_BYPASS_AO_CAL(x)       (((x) & 0xf) << 15)
976 #define NI_M_CFG_BYPASS_AO_CAL_MASK     NI_M_CFG_BYPASS_AO_CAL(0xf)
977 #define NI_M_CFG_BYPASS_AI_MODE_MUX(x)  (((x) & 0x3) << 13)
978 #define NI_M_CFG_BYPASS_AI_MODE_MUX_MASK NI_M_CFG_BYPASS_AI_MODE_MUX(3)
979 #define NI_M_CFG_BYPASS_AI_CAL_NEG(x)   (((x) & 0x7) << 10)
980 #define NI_M_CFG_BYPASS_AI_CAL_NEG_MASK NI_M_CFG_BYPASS_AI_CAL_NEG(7)
981 #define NI_M_CFG_BYPASS_AI_CAL_POS(x)   (((x) & 0x7) << 7)
982 #define NI_M_CFG_BYPASS_AI_CAL_POS_MASK NI_M_CFG_BYPASS_AI_CAL_POS(7)
983 #define NI_M_CFG_BYPASS_AI_CAL_MASK     (NI_M_CFG_BYPASS_AI_CAL_POS_MASK | \
984                                          NI_M_CFG_BYPASS_AI_CAL_NEG_MASK | \
985                                          NI_M_CFG_BYPASS_AI_MODE_MUX_MASK | \
986                                          NI_M_CFG_BYPASS_AO_CAL_MASK)
987 #define NI_M_CFG_BYPASS_AI_BANK(x)      (((x) & 0xf) << 3)
988 #define NI_M_CFG_BYPASS_AI_BANK_MASK    NI_M_CFG_BYPASS_AI_BANK(0xf)
989 #define NI_M_CFG_BYPASS_AI_CHAN(x)      (((x) & 0x7) << 0)
990 #define NI_M_CFG_BYPASS_AI_CHAN_MASK    NI_M_CFG_BYPASS_AI_CHAN(7)
991 #define NI_M_SCXI_DIO_ENA_REG           0x21c
992 #define NI_M_CDI_FIFO_DATA_REG          0x220
993 #define NI_M_CDO_FIFO_DATA_REG          0x220
994 #define NI_M_CDIO_STATUS_REG            0x224
995 #define NI_M_CDIO_STATUS_CDI_OVERFLOW   BIT(20)
996 #define NI_M_CDIO_STATUS_CDI_OVERRUN    BIT(19)
997 #define NI_M_CDIO_STATUS_CDI_ERROR      (NI_M_CDIO_STATUS_CDI_OVERFLOW | \
998                                          NI_M_CDIO_STATUS_CDI_OVERRUN)
999 #define NI_M_CDIO_STATUS_CDI_FIFO_REQ   BIT(18)
1000 #define NI_M_CDIO_STATUS_CDI_FIFO_FULL  BIT(17)
1001 #define NI_M_CDIO_STATUS_CDI_FIFO_EMPTY BIT(16)
1002 #define NI_M_CDIO_STATUS_CDO_UNDERFLOW  BIT(4)
1003 #define NI_M_CDIO_STATUS_CDO_OVERRUN    BIT(3)
1004 #define NI_M_CDIO_STATUS_CDO_ERROR      (NI_M_CDIO_STATUS_CDO_UNDERFLOW | \
1005                                          NI_M_CDIO_STATUS_CDO_OVERRUN)
1006 #define NI_M_CDIO_STATUS_CDO_FIFO_REQ   BIT(2)
1007 #define NI_M_CDIO_STATUS_CDO_FIFO_FULL  BIT(1)
1008 #define NI_M_CDIO_STATUS_CDO_FIFO_EMPTY BIT(0)
1009 #define NI_M_CDIO_CMD_REG               0x224
1010 #define NI_M_CDI_CMD_SW_UPDATE          BIT(20)
1011 #define NI_M_CDO_CMD_SW_UPDATE          BIT(19)
1012 #define NI_M_CDO_CMD_F_E_INT_ENA_CLR    BIT(17)
1013 #define NI_M_CDO_CMD_F_E_INT_ENA_SET    BIT(16)
1014 #define NI_M_CDI_CMD_ERR_INT_CONFIRM    BIT(15)
1015 #define NI_M_CDO_CMD_ERR_INT_CONFIRM    BIT(14)
1016 #define NI_M_CDI_CMD_F_REQ_INT_ENA_CLR  BIT(13)
1017 #define NI_M_CDI_CMD_F_REQ_INT_ENA_SET  BIT(12)
1018 #define NI_M_CDO_CMD_F_REQ_INT_ENA_CLR  BIT(11)
1019 #define NI_M_CDO_CMD_F_REQ_INT_ENA_SET  BIT(10)
1020 #define NI_M_CDI_CMD_ERR_INT_ENA_CLR    BIT(9)
1021 #define NI_M_CDI_CMD_ERR_INT_ENA_SET    BIT(8)
1022 #define NI_M_CDO_CMD_ERR_INT_ENA_CLR    BIT(7)
1023 #define NI_M_CDO_CMD_ERR_INT_ENA_SET    BIT(6)
1024 #define NI_M_CDI_CMD_RESET              BIT(5)
1025 #define NI_M_CDO_CMD_RESET              BIT(4)
1026 #define NI_M_CDI_CMD_ARM                BIT(3)
1027 #define NI_M_CDI_CMD_DISARM             BIT(2)
1028 #define NI_M_CDO_CMD_ARM                BIT(1)
1029 #define NI_M_CDO_CMD_DISARM             BIT(0)
1030 #define NI_M_CDI_MODE_REG               0x228
1031 #define NI_M_CDI_MODE_DATA_LANE(x)      (((x) & 0x3) << 12)
1032 #define NI_M_CDI_MODE_DATA_LANE_MASK    NI_M_CDI_MODE_DATA_LANE(3)
1033 #define NI_M_CDI_MODE_DATA_LANE_0_15    NI_M_CDI_MODE_DATA_LANE(0)
1034 #define NI_M_CDI_MODE_DATA_LANE_16_31   NI_M_CDI_MODE_DATA_LANE(1)
1035 #define NI_M_CDI_MODE_DATA_LANE_0_7     NI_M_CDI_MODE_DATA_LANE(0)
1036 #define NI_M_CDI_MODE_DATA_LANE_8_15    NI_M_CDI_MODE_DATA_LANE(1)
1037 #define NI_M_CDI_MODE_DATA_LANE_16_23   NI_M_CDI_MODE_DATA_LANE(2)
1038 #define NI_M_CDI_MODE_DATA_LANE_24_31   NI_M_CDI_MODE_DATA_LANE(3)
1039 #define NI_M_CDI_MODE_FIFO_MODE         BIT(11)
1040 #define NI_M_CDI_MODE_POLARITY          BIT(10)
1041 #define NI_M_CDI_MODE_HALT_ON_ERROR     BIT(9)
1042 #define NI_M_CDI_MODE_SAMPLE_SRC(x)     (((x) & 0x3f) << 0)
1043 #define NI_M_CDI_MODE_SAMPLE_SRC_MASK   NI_M_CDI_MODE_SAMPLE_SRC(0x3f)
1044 #define NI_M_CDO_MODE_REG               0x22c
1045 #define NI_M_CDO_MODE_DATA_LANE(x)      (((x) & 0x3) << 12)
1046 #define NI_M_CDO_MODE_DATA_LANE_MASK    NI_M_CDO_MODE_DATA_LANE(3)
1047 #define NI_M_CDO_MODE_DATA_LANE_0_15    NI_M_CDO_MODE_DATA_LANE(0)
1048 #define NI_M_CDO_MODE_DATA_LANE_16_31   NI_M_CDO_MODE_DATA_LANE(1)
1049 #define NI_M_CDO_MODE_DATA_LANE_0_7     NI_M_CDO_MODE_DATA_LANE(0)
1050 #define NI_M_CDO_MODE_DATA_LANE_8_15    NI_M_CDO_MODE_DATA_LANE(1)
1051 #define NI_M_CDO_MODE_DATA_LANE_16_23   NI_M_CDO_MODE_DATA_LANE(2)
1052 #define NI_M_CDO_MODE_DATA_LANE_24_31   NI_M_CDO_MODE_DATA_LANE(3)
1053 #define NI_M_CDO_MODE_FIFO_MODE         BIT(11)
1054 #define NI_M_CDO_MODE_POLARITY          BIT(10)
1055 #define NI_M_CDO_MODE_HALT_ON_ERROR     BIT(9)
1056 #define NI_M_CDO_MODE_RETRANSMIT        BIT(8)
1057 #define NI_M_CDO_MODE_SAMPLE_SRC(x)     (((x) & 0x3f) << 0)
1058 #define NI_M_CDO_MODE_SAMPLE_SRC_MASK   NI_M_CDO_MODE_SAMPLE_SRC(0x3f)
1059 #define NI_M_CDI_MASK_ENA_REG           0x230
1060 #define NI_M_CDO_MASK_ENA_REG           0x234
1061 #define NI_M_STATIC_AI_CTRL_REG(x)      ((x) ? (0x260 + (x)) : 0x064)
1062 #define NI_M_AO_REF_ATTENUATION_REG(x)  (0x264 + (x))
1063 #define NI_M_AO_REF_ATTENUATION_X5      BIT(0)
1064
1065 #define M_SERIES_EEPROM_SIZE 1024
1066
1067 struct ni_board_struct {
1068         const char *name;
1069         int device_id;
1070         int isapnp_id;
1071
1072         int n_adchan;
1073         unsigned int ai_maxdata;
1074
1075         int ai_fifo_depth;
1076         unsigned int alwaysdither:1;
1077         int gainlkup;
1078         int ai_speed;
1079
1080         int n_aochan;
1081         unsigned int ao_maxdata;
1082         int ao_fifo_depth;
1083         const struct comedi_lrange *ao_range_table;
1084         unsigned ao_speed;
1085
1086         int reg_type;
1087         unsigned int has_8255:1;
1088         unsigned int has_32dio_chan:1;
1089
1090         enum caldac_enum caldac[3];
1091 };
1092
1093 #define MAX_N_CALDACS   34
1094 #define MAX_N_AO_CHAN   8
1095 #define NUM_GPCT        2
1096
1097 struct ni_private {
1098         unsigned short dio_output;
1099         unsigned short dio_control;
1100         int aimode;
1101         unsigned int ai_calib_source;
1102         unsigned int ai_calib_source_enabled;
1103         spinlock_t window_lock;
1104         spinlock_t soft_reg_copy_lock;
1105         spinlock_t mite_channel_lock;
1106
1107         int changain_state;
1108         unsigned int changain_spec;
1109
1110         unsigned int caldac_maxdata_list[MAX_N_CALDACS];
1111         unsigned short caldacs[MAX_N_CALDACS];
1112
1113         unsigned short ai_cmd2;
1114
1115         unsigned short ao_conf[MAX_N_AO_CHAN];
1116         unsigned short ao_mode1;
1117         unsigned short ao_mode2;
1118         unsigned short ao_mode3;
1119         unsigned short ao_cmd1;
1120         unsigned short ao_cmd2;
1121         unsigned short ao_trigger_select;
1122
1123         struct ni_gpct_device *counter_dev;
1124         unsigned short an_trig_etc_reg;
1125
1126         unsigned ai_offset[512];
1127
1128         unsigned long serial_interval_ns;
1129         unsigned char serial_hw_mode;
1130         unsigned short clock_and_fout;
1131         unsigned short clock_and_fout2;
1132
1133         unsigned short int_a_enable_reg;
1134         unsigned short int_b_enable_reg;
1135         unsigned short io_bidirection_pin_reg;
1136         unsigned short rtsi_trig_direction_reg;
1137         unsigned short rtsi_trig_a_output_reg;
1138         unsigned short rtsi_trig_b_output_reg;
1139         unsigned short pfi_output_select_reg[NUM_PFI_OUTPUT_SELECT_REGS];
1140         unsigned short ai_ao_select_reg;
1141         unsigned short g0_g1_select_reg;
1142         unsigned short cdio_dma_select_reg;
1143
1144         unsigned clock_ns;
1145         unsigned clock_source;
1146
1147         unsigned short pwm_up_count;
1148         unsigned short pwm_down_count;
1149
1150         unsigned short ai_fifo_buffer[0x2000];
1151         uint8_t eeprom_buffer[M_SERIES_EEPROM_SIZE];
1152         __be32 serial_number;
1153
1154         struct mite_struct *mite;
1155         struct mite_channel *ai_mite_chan;
1156         struct mite_channel *ao_mite_chan;
1157         struct mite_channel *cdo_mite_chan;
1158         struct mite_dma_descriptor_ring *ai_mite_ring;
1159         struct mite_dma_descriptor_ring *ao_mite_ring;
1160         struct mite_dma_descriptor_ring *cdo_mite_ring;
1161         struct mite_dma_descriptor_ring *gpct_mite_ring[NUM_GPCT];
1162
1163         /* ni_pcimio board type flags (based on the boardinfo reg_type) */
1164         unsigned int is_m_series:1;
1165         unsigned int is_6xxx:1;
1166         unsigned int is_611x:1;
1167         unsigned int is_6143:1;
1168         unsigned int is_622x:1;
1169         unsigned int is_625x:1;
1170         unsigned int is_628x:1;
1171         unsigned int is_67xx:1;
1172         unsigned int is_6711:1;
1173         unsigned int is_6713:1;
1174 };
1175
1176 #endif /* _COMEDI_NI_STC_H */