29 #ifndef _COMEDI_NI_STC_H
30 #define _COMEDI_NI_STC_H
51 #define NUM_PFI_OUTPUT_SELECT_REGS 6
55 #define Interrupt_A_Ack_Register 2
56 #define G0_Gate_Interrupt_Ack _bit15
57 #define G0_TC_Interrupt_Ack _bit14
58 #define AI_Error_Interrupt_Ack _bit13
59 #define AI_STOP_Interrupt_Ack _bit12
60 #define AI_START_Interrupt_Ack _bit11
61 #define AI_START2_Interrupt_Ack _bit10
62 #define AI_START1_Interrupt_Ack _bit9
63 #define AI_SC_TC_Interrupt_Ack _bit8
64 #define AI_SC_TC_Error_Confirm _bit7
65 #define G0_TC_Error_Confirm _bit6
66 #define G0_Gate_Error_Confirm _bit5
68 #define AI_Status_1_Register 2
69 #define Interrupt_A_St 0x8000
70 #define AI_FIFO_Full_St 0x4000
71 #define AI_FIFO_Half_Full_St 0x2000
72 #define AI_FIFO_Empty_St 0x1000
73 #define AI_Overrun_St 0x0800
74 #define AI_Overflow_St 0x0400
75 #define AI_SC_TC_Error_St 0x0200
76 #define AI_START2_St 0x0100
77 #define AI_START1_St 0x0080
78 #define AI_SC_TC_St 0x0040
79 #define AI_START_St 0x0020
80 #define AI_STOP_St 0x0010
81 #define G0_TC_St 0x0008
82 #define G0_Gate_Interrupt_St 0x0004
83 #define AI_FIFO_Request_St 0x0002
84 #define Pass_Thru_0_Interrupt_St 0x0001
86 #define AI_Status_2_Register 5
88 #define Interrupt_B_Ack_Register 3
107 #define AO_Status_1_Register 3
108 #define Interrupt_B_St _bit15
109 #define AO_FIFO_Full_St _bit14
110 #define AO_FIFO_Half_Full_St _bit13
111 #define AO_FIFO_Empty_St _bit12
112 #define AO_BC_TC_Error_St _bit11
113 #define AO_START_St _bit10
114 #define AO_Overrun_St _bit9
115 #define AO_START1_St _bit8
116 #define AO_BC_TC_St _bit7
117 #define AO_UC_TC_St _bit6
118 #define AO_UPDATE_St _bit5
119 #define AO_UI2_TC_St _bit4
120 #define G1_TC_St _bit3
121 #define G1_Gate_Interrupt_St _bit2
122 #define AO_FIFO_Request_St _bit1
123 #define Pass_Thru_1_Interrupt_St _bit0
125 #define AI_Command_2_Register 4
126 #define AI_End_On_SC_TC _bit15
127 #define AI_End_On_End_Of_Scan _bit14
128 #define AI_START1_Disable _bit11
129 #define AI_SC_Save_Trace _bit10
130 #define AI_SI_Switch_Load_On_SC_TC _bit9
131 #define AI_SI_Switch_Load_On_STOP _bit8
132 #define AI_SI_Switch_Load_On_TC _bit7
133 #define AI_SC_Switch_Load_On_TC _bit4
134 #define AI_STOP_Pulse _bit3
135 #define AI_START_Pulse _bit2
136 #define AI_START2_Pulse _bit1
137 #define AI_START1_Pulse _bit0
139 #define AO_Command_2_Register 5
140 #define AO_End_On_BC_TC(x) (((x) & 0x3) << 14)
141 #define AO_Start_Stop_Gate_Enable _bit13
142 #define AO_UC_Save_Trace _bit12
143 #define AO_BC_Gate_Enable _bit11
144 #define AO_BC_Save_Trace _bit10
145 #define AO_UI_Switch_Load_On_BC_TC _bit9
146 #define AO_UI_Switch_Load_On_Stop _bit8
147 #define AO_UI_Switch_Load_On_TC _bit7
148 #define AO_UC_Switch_Load_On_BC_TC _bit6
149 #define AO_UC_Switch_Load_On_TC _bit5
150 #define AO_BC_Switch_Load_On_TC _bit4
151 #define AO_Mute_B _bit3
152 #define AO_Mute_A _bit2
153 #define AO_UPDATE2_Pulse _bit1
154 #define AO_START1_Pulse _bit0
156 #define AO_Status_2_Register 6
158 #define DIO_Parallel_Input_Register 7
160 #define AI_Command_1_Register 8
161 #define AI_Analog_Trigger_Reset _bit14
162 #define AI_Disarm _bit13
163 #define AI_SI2_Arm _bit12
164 #define AI_SI2_Load _bit11
165 #define AI_SI_Arm _bit10
166 #define AI_SI_Load _bit9
167 #define AI_DIV_Arm _bit8
168 #define AI_DIV_Load _bit7
169 #define AI_SC_Arm _bit6
170 #define AI_SC_Load _bit5
171 #define AI_SCAN_IN_PROG_Pulse _bit4
172 #define AI_EXTMUX_CLK_Pulse _bit3
173 #define AI_LOCALMUX_CLK_Pulse _bit2
174 #define AI_SC_TC_Pulse _bit1
175 #define AI_CONVERT_Pulse _bit0
177 #define AO_Command_1_Register 9
178 #define AO_Analog_Trigger_Reset _bit15
179 #define AO_START_Pulse _bit14
180 #define AO_Disarm _bit13
181 #define AO_UI2_Arm_Disarm _bit12
182 #define AO_UI2_Load _bit11
183 #define AO_UI_Arm _bit10
184 #define AO_UI_Load _bit9
185 #define AO_UC_Arm _bit8
186 #define AO_UC_Load _bit7
187 #define AO_BC_Arm _bit6
188 #define AO_BC_Load _bit5
189 #define AO_DAC1_Update_Mode _bit4
190 #define AO_LDAC1_Source_Select _bit3
191 #define AO_DAC0_Update_Mode _bit2
192 #define AO_LDAC0_Source_Select _bit1
193 #define AO_UPDATE_Pulse _bit0
195 #define DIO_Output_Register 10
196 #define DIO_Parallel_Data_Out(a) ((a)&0xff)
197 #define DIO_Parallel_Data_Mask 0xff
198 #define DIO_SDOUT _bit0
199 #define DIO_SDIN _bit4
200 #define DIO_Serial_Data_Out(a) (((a)&0xff)<<8)
201 #define DIO_Serial_Data_Mask 0xff00
203 #define DIO_Control_Register 11
204 #define DIO_Software_Serial_Control _bit11
205 #define DIO_HW_Serial_Timebase _bit10
206 #define DIO_HW_Serial_Enable _bit9
207 #define DIO_HW_Serial_Start _bit8
208 #define DIO_Pins_Dir(a) ((a)&0xff)
209 #define DIO_Pins_Dir_Mask 0xff
211 #define AI_Mode_1_Register 12
212 #define AI_CONVERT_Source_Select(a) (((a) & 0x1f) << 11)
213 #define AI_SI_Source_select(a) (((a) & 0x1f) << 6)
214 #define AI_CONVERT_Source_Polarity _bit5
215 #define AI_SI_Source_Polarity _bit4
216 #define AI_Start_Stop _bit3
217 #define AI_Mode_1_Reserved _bit2
218 #define AI_Continuous _bit1
219 #define AI_Trigger_Once _bit0
221 #define AI_Mode_2_Register 13
222 #define AI_SC_Gate_Enable _bit15
223 #define AI_Start_Stop_Gate_Enable _bit14
224 #define AI_Pre_Trigger _bit13
225 #define AI_External_MUX_Present _bit12
226 #define AI_SI2_Initial_Load_Source _bit9
227 #define AI_SI2_Reload_Mode _bit8
228 #define AI_SI_Initial_Load_Source _bit7
229 #define AI_SI_Reload_Mode(a) (((a) & 0x7)<<4)
230 #define AI_SI_Write_Switch _bit3
231 #define AI_SC_Initial_Load_Source _bit2
232 #define AI_SC_Reload_Mode _bit1
233 #define AI_SC_Write_Switch _bit0
235 #define AI_SI_Load_A_Registers 14
236 #define AI_SI_Load_B_Registers 16
237 #define AI_SC_Load_A_Registers 18
238 #define AI_SC_Load_B_Registers 20
239 #define AI_SI_Save_Registers 64
240 #define AI_SC_Save_Registers 66
242 #define AI_SI2_Load_A_Register 23
243 #define AI_SI2_Load_B_Register 25
245 #define Joint_Status_1_Register 27
246 #define DIO_Serial_IO_In_Progress_St _bit12
248 #define DIO_Serial_Input_Register 28
249 #define Joint_Status_2_Register 29
254 #define AO_Mode_1_Register 38
255 #define AO_UPDATE_Source_Select(x) (((x)&0x1f)<<11)
256 #define AO_UI_Source_Select(x) (((x)&0x1f)<<6)
257 #define AO_Multiple_Channels _bit5
258 #define AO_UPDATE_Source_Polarity _bit4
259 #define AO_UI_Source_Polarity _bit3
260 #define AO_UC_Switch_Load_Every_TC _bit2
261 #define AO_Continuous _bit1
262 #define AO_Trigger_Once _bit0
264 #define AO_Mode_2_Register 39
265 #define AO_FIFO_Mode_Mask (0x3 << 14)
272 #define AO_FIFO_Retransmit_Enable _bit13
273 #define AO_START1_Disable _bit12
274 #define AO_UC_Initial_Load_Source _bit11
275 #define AO_UC_Write_Switch _bit10
276 #define AO_UI2_Initial_Load_Source _bit9
277 #define AO_UI2_Reload_Mode _bit8
278 #define AO_UI_Initial_Load_Source _bit7
279 #define AO_UI_Reload_Mode(x) (((x) & 0x7) << 4)
280 #define AO_UI_Write_Switch _bit3
281 #define AO_BC_Initial_Load_Source _bit2
282 #define AO_BC_Reload_Mode _bit1
283 #define AO_BC_Write_Switch _bit0
285 #define AO_UI_Load_A_Register 40
286 #define AO_UI_Load_A_Register_High 40
287 #define AO_UI_Load_A_Register_Low 41
288 #define AO_UI_Load_B_Register 42
289 #define AO_UI_Save_Registers 16
290 #define AO_BC_Load_A_Register 44
291 #define AO_BC_Load_A_Register_High 44
292 #define AO_BC_Load_A_Register_Low 45
293 #define AO_BC_Load_B_Register 46
294 #define AO_BC_Load_B_Register_High 46
295 #define AO_BC_Load_B_Register_Low 47
296 #define AO_BC_Save_Registers 18
297 #define AO_UC_Load_A_Register 48
298 #define AO_UC_Load_A_Register_High 48
299 #define AO_UC_Load_A_Register_Low 49
300 #define AO_UC_Load_B_Register 50
301 #define AO_UC_Save_Registers 20
303 #define Clock_and_FOUT_Register 56
319 static inline unsigned FOUT_Divider(
unsigned divider)
324 #define IO_Bidirection_Pin_Register 57
325 #define RTSI_Trig_Direction_Register 58
330 static inline unsigned RTSI_Output_Bit(
unsigned channel,
int is_mseries)
332 unsigned max_channel;
333 unsigned base_bit_shift;
341 if (channel > max_channel) {
342 printk(
"%s: bug, invalid RTSI_channel=%i\n", __func__, channel);
345 return 1 << (base_bit_shift +
channel);
348 #define Interrupt_Control_Register 59
349 #define Interrupt_B_Enable _bit15
350 #define Interrupt_B_Output_Select(x) ((x)<<12)
351 #define Interrupt_A_Enable _bit11
352 #define Interrupt_A_Output_Select(x) ((x)<<8)
353 #define Pass_Thru_0_Interrupt_Polarity _bit3
354 #define Pass_Thru_1_Interrupt_Polarity _bit2
355 #define Interrupt_Output_On_3_Pins _bit1
356 #define Interrupt_Output_Polarity _bit0
358 #define AI_Output_Control_Register 60
359 #define AI_START_Output_Select _bit10
360 #define AI_SCAN_IN_PROG_Output_Select(x) (((x) & 0x3) << 8)
361 #define AI_EXTMUX_CLK_Output_Select(x) (((x) & 0x3) << 6)
362 #define AI_LOCALMUX_CLK_Output_Select(x) ((x)<<4)
363 #define AI_SC_TC_Output_Select(x) ((x)<<2)
373 return selection & 0x3;
376 #define AI_START_STOP_Select_Register 62
377 #define AI_START_Polarity _bit15
378 #define AI_STOP_Polarity _bit14
379 #define AI_STOP_Sync _bit13
380 #define AI_STOP_Edge _bit12
381 #define AI_STOP_Select(a) (((a) & 0x1f)<<7)
382 #define AI_START_Sync _bit6
383 #define AI_START_Edge _bit5
384 #define AI_START_Select(a) ((a) & 0x1f)
386 #define AI_Trigger_Select_Register 63
387 #define AI_START1_Polarity _bit15
388 #define AI_START2_Polarity _bit14
389 #define AI_START2_Sync _bit13
390 #define AI_START2_Edge _bit12
391 #define AI_START2_Select(a) (((a) & 0x1f) << 7)
392 #define AI_START1_Sync _bit6
393 #define AI_START1_Edge _bit5
394 #define AI_START1_Select(a) ((a) & 0x1f)
396 #define AI_DIV_Load_A_Register 64
398 #define AO_Start_Select_Register 66
399 #define AO_UI2_Software_Gate _bit15
400 #define AO_UI2_External_Gate_Polarity _bit14
401 #define AO_START_Polarity _bit13
402 #define AO_AOFREQ_Enable _bit12
403 #define AO_UI2_External_Gate_Select(a) (((a) & 0x1f) << 7)
404 #define AO_START_Sync _bit6
405 #define AO_START_Edge _bit5
406 #define AO_START_Select(a) ((a) & 0x1f)
408 #define AO_Trigger_Select_Register 67
409 #define AO_UI2_External_Gate_Enable _bit15
410 #define AO_Delayed_START1 _bit14
411 #define AO_START1_Polarity _bit13
412 #define AO_UI2_Source_Polarity _bit12
413 #define AO_UI2_Source_Select(x) (((x)&0x1f)<<7)
414 #define AO_START1_Sync _bit6
415 #define AO_START1_Edge _bit5
416 #define AO_START1_Select(x) (((x)&0x1f)<<0)
418 #define AO_Mode_3_Register 70
419 #define AO_UI2_Switch_Load_Next_TC _bit13
420 #define AO_UC_Switch_Load_Every_BC_TC _bit12
421 #define AO_Trigger_Length _bit11
422 #define AO_Stop_On_Overrun_Error _bit5
423 #define AO_Stop_On_BC_TC_Trigger_Error _bit4
424 #define AO_Stop_On_BC_TC_Error _bit3
425 #define AO_Not_An_UPDATE _bit2
426 #define AO_Software_Gate _bit1
427 #define AO_Last_Gate_Disable _bit0
429 #define Joint_Reset_Register 72
430 #define Software_Reset _bit11
431 #define AO_Configuration_End _bit9
432 #define AI_Configuration_End _bit8
433 #define AO_Configuration_Start _bit5
434 #define AI_Configuration_Start _bit4
435 #define G1_Reset _bit3
436 #define G0_Reset _bit2
437 #define AO_Reset _bit1
438 #define AI_Reset _bit0
440 #define Interrupt_A_Enable_Register 73
441 #define Pass_Thru_0_Interrupt_Enable _bit9
442 #define G0_Gate_Interrupt_Enable _bit8
443 #define AI_FIFO_Interrupt_Enable _bit7
444 #define G0_TC_Interrupt_Enable _bit6
445 #define AI_Error_Interrupt_Enable _bit5
446 #define AI_STOP_Interrupt_Enable _bit4
447 #define AI_START_Interrupt_Enable _bit3
448 #define AI_START2_Interrupt_Enable _bit2
449 #define AI_START1_Interrupt_Enable _bit1
450 #define AI_SC_TC_Interrupt_Enable _bit0
452 #define Interrupt_B_Enable_Register 75
453 #define Pass_Thru_1_Interrupt_Enable _bit11
454 #define G1_Gate_Interrupt_Enable _bit10
455 #define G1_TC_Interrupt_Enable _bit9
456 #define AO_FIFO_Interrupt_Enable _bit8
457 #define AO_UI2_TC_Interrupt_Enable _bit7
458 #define AO_UC_TC_Interrupt_Enable _bit6
459 #define AO_Error_Interrupt_Enable _bit5
460 #define AO_STOP_Interrupt_Enable _bit4
461 #define AO_START_Interrupt_Enable _bit3
462 #define AO_UPDATE_Interrupt_Enable _bit2
463 #define AO_START1_Interrupt_Enable _bit1
464 #define AO_BC_TC_Interrupt_Enable _bit0
466 #define Second_IRQ_A_Enable_Register 74
480 #define Second_IRQ_B_Enable_Register 76
496 #define AI_Personal_Register 77
497 #define AI_SHIFTIN_Pulse_Width _bit15
498 #define AI_EOC_Polarity _bit14
499 #define AI_SOC_Polarity _bit13
500 #define AI_SHIFTIN_Polarity _bit12
501 #define AI_CONVERT_Pulse_Timebase _bit11
502 #define AI_CONVERT_Pulse_Width _bit10
503 #define AI_CONVERT_Original_Pulse _bit9
504 #define AI_FIFO_Flags_Polarity _bit8
505 #define AI_Overrun_Mode _bit7
506 #define AI_EXTMUX_CLK_Pulse_Width _bit6
507 #define AI_LOCALMUX_CLK_Pulse_Width _bit5
508 #define AI_AIFREQ_Polarity _bit4
510 #define AO_Personal_Register 78
526 #define RTSI_Trig_A_Output_Register 79
527 #define RTSI_Trig_B_Output_Register 80
531 static inline unsigned RTSI_Trig_Output_Bits(
unsigned rtsi_channel,
534 return (source & 0xf) << ((rtsi_channel % 4) * 4);
537 static inline unsigned RTSI_Trig_Output_Mask(
unsigned rtsi_channel)
539 return 0xf << ((rtsi_channel % 4) * 4);
543 static inline unsigned RTSI_Trig_Output_Source(
unsigned rtsi_channel,
546 return (bits >> ((rtsi_channel % 4) * 4)) & 0xf;
549 #define RTSI_Board_Register 81
550 #define Write_Strobe_0_Register 82
551 #define Write_Strobe_1_Register 83
552 #define Write_Strobe_2_Register 84
553 #define Write_Strobe_3_Register 85
555 #define AO_Output_Control_Register 86
556 #define AO_External_Gate_Enable _bit15
557 #define AO_External_Gate_Select(x) (((x)&0x1f)<<10)
558 #define AO_Number_Of_Channels(x) (((x)&0xf)<<6)
559 #define AO_UPDATE2_Output_Select(x) (((x)&0x3)<<4)
560 #define AO_External_Gate_Polarity _bit3
561 #define AO_UPDATE2_Output_Toggle _bit2
571 return selection & 0x3;
574 #define AI_Mode_3_Register 87
575 #define AI_Trigger_Length _bit15
576 #define AI_Delay_START _bit14
577 #define AI_Software_Gate _bit13
578 #define AI_SI_Special_Trigger_Delay _bit12
579 #define AI_SI2_Source_Select _bit11
580 #define AI_Delayed_START2 _bit10
581 #define AI_Delayed_START1 _bit9
582 #define AI_External_Gate_Mode _bit8
583 #define AI_FIFO_Mode_HF_to_E (3<<6)
584 #define AI_FIFO_Mode_F (2<<6)
585 #define AI_FIFO_Mode_HF (1<<6)
586 #define AI_FIFO_Mode_NE (0<<6)
587 #define AI_External_Gate_Polarity _bit5
588 #define AI_External_Gate_Select(a) ((a) & 0x1f)
590 #define G_Autoincrement_Register(a) (68+(a))
591 #define G_Command_Register(a) (6+(a))
592 #define G_HW_Save_Register(a) (8+(a)*2)
593 #define G_HW_Save_Register_High(a) (8+(a)*2)
594 #define G_HW_Save_Register_Low(a) (9+(a)*2)
595 #define G_Input_Select_Register(a) (36+(a))
596 #define G_Load_A_Register(a) (28+(a)*4)
597 #define G_Load_A_Register_High(a) (28+(a)*4)
598 #define G_Load_A_Register_Low(a) (29+(a)*4)
599 #define G_Load_B_Register(a) (30+(a)*4)
600 #define G_Load_B_Register_High(a) (30+(a)*4)
601 #define G_Load_B_Register_Low(a) (31+(a)*4)
602 #define G_Mode_Register(a) (26+(a))
603 #define G_Save_Register(a) (12+(a)*2)
604 #define G_Save_Register_High(a) (12+(a)*2)
605 #define G_Save_Register_Low(a) (13+(a)*2)
606 #define G_Status_Register 4
607 #define Analog_Trigger_Etc_Register 61
610 #define G_Disarm_Copy _bit15
611 #define G_Save_Trace_Copy _bit14
612 #define G_Arm_Copy _bit13
613 #define G_Bank_Switch_Start _bit10
614 #define G_Little_Big_Endian _bit9
615 #define G_Synchronized_Gate _bit8
616 #define G_Write_Switch _bit7
617 #define G_Up_Down(a) (((a)&0x03)<<5)
618 #define G_Disarm _bit4
619 #define G_Analog_Trigger_Reset _bit3
620 #define G_Save_Trace _bit1
624 #define G_Bank_Switch_Enable _bit12
625 #define G_Bank_Switch_Mode _bit11
629 #define G_Gate_Select(a) (((a)&0x1f)<<7)
630 #define G_Source_Select(a) (((a)&0x1f)<<2)
631 #define G_Write_Acknowledges_Irq _bit1
632 #define G_Read_Acknowledges_Irq _bit0
635 #define G_Source_Polarity _bit15
636 #define G_Output_Polarity _bit14
637 #define G_OR_Gate _bit13
638 #define G_Gate_Select_Load_Source _bit12
641 #define G_Loading_On_TC _bit12
642 #define G_Output_Mode(a) (((a)&0x03)<<8)
643 #define G_Trigger_Mode_For_Edge_Gate(a) (((a)&0x03)<<3)
644 #define G_Gating_Mode(a) (((a)&0x03)<<0)
647 #define G_Load_Source_Select _bit7
648 #define G_Reload_Source_Switching _bit15
649 #define G_Loading_On_Gate _bit14
650 #define G_Gate_Polarity _bit13
652 #define G_Counting_Once(a) (((a)&0x03)<<10)
653 #define G_Stop_Mode(a) (((a)&0x03)<<5)
654 #define G_Gate_On_Both_Edges _bit2
657 #define G1_Gate_Error_St _bit15
658 #define G0_Gate_Error_St _bit14
659 #define G1_TC_Error_St _bit13
660 #define G0_TC_Error_St _bit12
661 #define G1_No_Load_Between_Gates_St _bit11
662 #define G0_No_Load_Between_Gates_St _bit10
663 #define G1_Armed_St _bit9
664 #define G0_Armed_St _bit8
665 #define G1_Stale_Data_St _bit7
666 #define G0_Stale_Data_St _bit6
667 #define G1_Next_Load_Source_St _bit5
668 #define G0_Next_Load_Source_St _bit4
669 #define G1_Counting_St _bit3
670 #define G0_Counting_St _bit2
671 #define G1_Save_St _bit1
672 #define G0_Save_St _bit0
675 #define G_Autoincrement(a) ((a)<<0)
678 #define Analog_Trigger_Mode(x) ((x) & 0x7)
679 #define Analog_Trigger_Enable _bit3
680 #define Analog_Trigger_Drive _bit4
681 #define GPFO_1_Output_Select _bit7
682 #define GPFO_0_Output_Select(a) ((a)<<11)
683 #define GPFO_0_Output_Enable _bit14
684 #define GPFO_1_Output_Enable _bit15
689 #define Window_Address 0x00
690 #define Window_Data 0x02
692 #define Configuration_Memory_Clear 82
693 #define ADC_FIFO_Clear 83
694 #define DAC_FIFO_Clear 84
699 #define XXX_Status 0x01
704 #define Serial_Command 0x0d
705 #define Misc_Command 0x0f
709 #define Configuration 0x1f
711 #define Channel_A_Mode 0x03
712 #define Channel_B_Mode 0x05
713 #define Channel_C_Mode 0x07
714 #define AI_AO_Select 0x09
721 #define G0_G1_Select 0x0b
722 static inline unsigned ni_stc_dma_channel_select_bitfield(
unsigned channel)
734 static inline unsigned GPCT_DMA_Select_Bits(
unsigned gpct_index,
738 return ni_stc_dma_channel_select_bitfield(mite_channel) << (4 *
742 static inline unsigned GPCT_DMA_Select_Mask(
unsigned gpct_index)
745 return 0xf << (4 * gpct_index);
750 #define Configuration_Memory_Low 0x10
755 #define Configuration_Memory_High 0x12
762 static inline unsigned int AI_CONFIG_CHANNEL(
unsigned int channel)
764 return channel & 0x3f;
767 #define ADC_FIFO_Data_Register 0x1c
769 #define AO_Configuration 0x16
770 #define AO_Bipolar _bit0
771 #define AO_Deglitch _bit1
772 #define AO_Ext_Ref _bit2
773 #define AO_Ground_Ref _bit3
774 #define AO_Channel(x) ((x) << 8)
776 #define DAC_FIFO_Data 0x1e
777 #define DAC0_Direct_Data 0x18
778 #define DAC1_Direct_Data 0x1a
782 #define Magic_611x 0x19
783 #define Calibration_Channel_Select_611x 0x1a
784 #define ADC_FIFO_Data_611x 0x1c
785 #define AI_FIFO_Offset_Load_611x 0x05
786 #define DAC_FIFO_Data_611x 0x14
787 #define Cal_Gain_Select_611x 0x05
789 #define AO_Window_Address_611x 0x18
790 #define AO_Window_Data_611x 0x1e
793 #define Magic_6143 0x19
794 #define G0G1_DMA_Select_6143 0x0B
795 #define PipelineDelay_6143 0x1f
796 #define EOC_Set_6143 0x1D
797 #define AIDMA_Select_6143 0x09
798 #define AIFIFO_Data_6143 0x8C
799 #define AIFIFO_Flag_6143 0x84
800 #define AIFIFO_Control_6143 0x88
801 #define AIFIFO_Status_6143 0x88
802 #define AIFIFO_DMAThreshold_6143 0x90
803 #define AIFIFO_Words_Available_6143 0x94
805 #define Calibration_Channel_6143 0x42
806 #define Calibration_LowTime_6143 0x20
807 #define Calibration_HighTime_6143 0x22
808 #define Relay_Counter_Load_Val__6143 0x4C
809 #define Signature_6143 0x50
810 #define Release_Date_6143 0x54
811 #define Release_Oldest_Date_6143 0x58
813 #define Calibration_Channel_6143_RelayOn 0x8000
814 #define Calibration_Channel_6143_RelayOff 0x4000
815 #define Calibration_Channel_Gnd_Gnd 0x00
816 #define Calibration_Channel_2v5_Gnd 0x02
817 #define Calibration_Channel_Pwm_Gnd 0x05
818 #define Calibration_Channel_2v5_Pwm 0x0a
819 #define Calibration_Channel_Pwm_Pwm 0x0d
820 #define Calibration_Channel_Gnd_Pwm 0x0e
840 static inline unsigned int DACx_Direct_Data_671x(
int channel)
872 static inline unsigned int CS5529_CONFIG_DOUT(
int output)
874 return 1 << (18 + output);
877 static inline unsigned int CS5529_CONFIG_AOUT(
int output)
879 return 1 << (22 + output);
898 #define SerDacLd(x) (0x08<<(x))
1069 static inline int M_Offset_AO_Waveform_Order(
int channel)
1074 static inline int M_Offset_AO_Config_Bank(
int channel)
1079 static inline int M_Offset_DAC_Direct_Data(
int channel)
1084 static inline int M_Offset_Gen_PWM(
int channel)
1089 static inline int M_Offset_Static_AI_Control(
int i)
1098 printk(
"%s: invalid channel=%i\n", __func__, i);
1104 static inline int M_Offset_AO_Reference_Attenuation(
int channel)
1112 if (((
unsigned)channel) >=
ARRAY_SIZE(offset)) {
1113 printk(
"%s: invalid channel=%i\n", __func__, channel);
1119 static inline unsigned M_Offset_PFI_Output_Select(
unsigned n)
1122 printk(
"%s: invalid pfi output select register=%i\n",
1141 static inline unsigned MSeries_AI_Config_Channel_Bits(
unsigned channel)
1143 return channel & 0xf;
1146 static inline unsigned MSeries_AI_Config_Bank_Bits(
enum ni_reg_type reg_type,
1149 unsigned bits = channel & 0x30;
1157 static inline unsigned MSeries_AI_Config_Gain_Bits(
unsigned range)
1159 return (range & 0x7) << 9;
1175 static inline unsigned MSeries_PLL_In_Source_Select_RTSI_Bits(
unsigned
1178 if (RTSI_channel > 7) {
1179 printk(
"%s: bug, invalid RTSI_channel=%i\n", __func__,
1183 if (RTSI_channel == 7)
1196 static inline unsigned MSeries_PLL_Divisor_Bits(
unsigned divisor)
1198 static const unsigned max_divisor = 0x10;
1199 if (divisor < 1 || divisor > max_divisor) {
1200 printk(
"%s: bug, invalid divisor=%i\n", __func__, divisor);
1203 return (divisor & 0xf) << 8;
1206 static inline unsigned MSeries_PLL_Multiplier_Bits(
unsigned multiplier)
1208 static const unsigned max_multiplier = 0x100;
1209 if (multiplier < 1 || multiplier > max_multiplier) {
1210 printk(
"%s: bug, invalid multiplier=%i\n", __func__,
1214 return multiplier & 0xff;
1233 static inline unsigned MSeries_AI_Bypass_Cal_Sel_Pos_Bits(
int
1239 static inline unsigned MSeries_AI_Bypass_Cal_Sel_Neg_Bits(
int
1245 static inline unsigned MSeries_AI_Bypass_Gain_Bits(
int gain)
1265 static inline unsigned MSeries_Cal_PWM_High_Time_Bits(
unsigned count)
1267 return (count << 16) & 0xffff0000;
1270 static inline unsigned MSeries_Cal_PWM_Low_Time_Bits(
unsigned count)
1272 return count & 0xffff;
1275 static inline unsigned MSeries_PFI_Output_Select_Mask(
unsigned channel)
1277 return 0x1f << (channel % 3) * 5;
1280 static inline unsigned MSeries_PFI_Output_Select_Bits(
unsigned channel,
1283 return (source & 0x1f) << ((channel % 3) * 5);
1287 static inline unsigned MSeries_PFI_Output_Select_Source(
unsigned channel,
1290 return (bits >> ((channel % 3) * 5)) & 0x1f;
1301 static inline unsigned MSeries_PFI_Filter_Select_Mask(
unsigned channel)
1303 return 0x3 << (channel * 2);
1306 static inline unsigned MSeries_PFI_Filter_Select_Bits(
unsigned channel,
1309 return (filter << (channel *
1310 2)) & MSeries_PFI_Filter_Select_Mask(channel);
1393 #define M_SERIES_EEPROM_SIZE 1024
1424 #define n_ni_boards (sizeof(ni_boards)/sizeof(struct ni_board_struct))
1426 #define boardtype (*(struct ni_board_struct *)dev->board_ptr)
1428 #define MAX_N_AO_CHAN 8
1431 #define NI_PRIVATE_COMMON \
1432 uint16_t (*stc_readw)(struct comedi_device *dev, int register); \
1433 uint32_t (*stc_readl)(struct comedi_device *dev, int register); \
1434 void (*stc_writew)(struct comedi_device *dev, uint16_t value, int register); \
1435 void (*stc_writel)(struct comedi_device *dev, uint32_t value, int register); \
1437 unsigned short dio_output; \
1438 unsigned short dio_control; \
1445 int ai_continuous; \
1448 unsigned int ai_calib_source; \
1449 unsigned int ai_calib_source_enabled; \
1450 spinlock_t window_lock; \
1451 spinlock_t soft_reg_copy_lock; \
1452 spinlock_t mite_channel_lock; \
1454 int changain_state; \
1455 unsigned int changain_spec; \
1457 unsigned int caldac_maxdata_list[MAX_N_CALDACS]; \
1458 unsigned short ao[MAX_N_AO_CHAN]; \
1459 unsigned short caldacs[MAX_N_CALDACS]; \
1461 unsigned short ai_cmd2; \
1463 unsigned short ao_conf[MAX_N_AO_CHAN]; \
1464 unsigned short ao_mode1; \
1465 unsigned short ao_mode2; \
1466 unsigned short ao_mode3; \
1467 unsigned short ao_cmd1; \
1468 unsigned short ao_cmd2; \
1469 unsigned short ao_cmd3; \
1470 unsigned short ao_trigger_select; \
1472 struct ni_gpct_device *counter_dev; \
1473 unsigned short an_trig_etc_reg; \
1475 unsigned ai_offset[512]; \
1477 unsigned long serial_interval_ns; \
1478 unsigned char serial_hw_mode; \
1479 unsigned short clock_and_fout; \
1480 unsigned short clock_and_fout2; \
1482 unsigned short int_a_enable_reg; \
1483 unsigned short int_b_enable_reg; \
1484 unsigned short io_bidirection_pin_reg; \
1485 unsigned short rtsi_trig_direction_reg; \
1486 unsigned short rtsi_trig_a_output_reg; \
1487 unsigned short rtsi_trig_b_output_reg; \
1488 unsigned short pfi_output_select_reg[NUM_PFI_OUTPUT_SELECT_REGS]; \
1489 unsigned short ai_ao_select_reg; \
1490 unsigned short g0_g1_select_reg; \
1491 unsigned short cdio_dma_select_reg; \
1493 unsigned clock_ns; \
1494 unsigned clock_source; \
1496 unsigned short atrig_mode; \
1497 unsigned short atrig_high; \
1498 unsigned short atrig_low; \
1500 unsigned short pwm_up_count; \
1501 unsigned short pwm_down_count; \
1503 short ai_fifo_buffer[0x2000]; \
1504 uint8_t eeprom_buffer[M_SERIES_EEPROM_SIZE]; \
1505 uint32_t serial_number; \
1507 struct mite_struct *mite; \
1508 struct mite_channel *ai_mite_chan; \
1509 struct mite_channel *ao_mite_chan;\
1510 struct mite_channel *cdo_mite_chan;\
1511 struct mite_dma_descriptor_ring *ai_mite_ring; \
1512 struct mite_dma_descriptor_ring *ao_mite_ring; \
1513 struct mite_dma_descriptor_ring *cdo_mite_ring; \
1514 struct mite_dma_descriptor_ring *gpct_mite_ring[NUM_GPCT];