19 #ifndef __ANALOGY_NI_TIO_H__ 20 #define __ANALOGY_NI_TIO_H__ 22 #include <rtdm/analogy/device.h> 28 enum ni_gpct_register {
29 NITIO_G0_Autoincrement_Reg,
30 NITIO_G1_Autoincrement_Reg,
31 NITIO_G2_Autoincrement_Reg,
32 NITIO_G3_Autoincrement_Reg,
57 NITIO_G0_Input_Select_Reg,
58 NITIO_G1_Input_Select_Reg,
59 NITIO_G2_Input_Select_Reg,
60 NITIO_G3_Input_Select_Reg,
61 NITIO_G0_Counting_Mode_Reg,
62 NITIO_G1_Counting_Mode_Reg,
63 NITIO_G2_Counting_Mode_Reg,
64 NITIO_G3_Counting_Mode_Reg,
65 NITIO_G0_Second_Gate_Reg,
66 NITIO_G1_Second_Gate_Reg,
67 NITIO_G2_Second_Gate_Reg,
68 NITIO_G3_Second_Gate_Reg,
71 NITIO_G01_Joint_Reset_Reg,
72 NITIO_G23_Joint_Reset_Reg,
73 NITIO_G01_Joint_Status1_Reg,
74 NITIO_G23_Joint_Status1_Reg,
75 NITIO_G01_Joint_Status2_Reg,
76 NITIO_G23_Joint_Status2_Reg,
77 NITIO_G0_DMA_Config_Reg,
78 NITIO_G1_DMA_Config_Reg,
79 NITIO_G2_DMA_Config_Reg,
80 NITIO_G3_DMA_Config_Reg,
81 NITIO_G0_DMA_Status_Reg,
82 NITIO_G1_DMA_Status_Reg,
83 NITIO_G2_DMA_Status_Reg,
84 NITIO_G3_DMA_Status_Reg,
87 NITIO_G0_Interrupt_Acknowledge_Reg,
88 NITIO_G1_Interrupt_Acknowledge_Reg,
89 NITIO_G2_Interrupt_Acknowledge_Reg,
90 NITIO_G3_Interrupt_Acknowledge_Reg,
95 NITIO_G0_Interrupt_Enable_Reg,
96 NITIO_G1_Interrupt_Enable_Reg,
97 NITIO_G2_Interrupt_Enable_Reg,
98 NITIO_G3_Interrupt_Enable_Reg,
102 static inline enum ni_gpct_register NITIO_Gi_Autoincrement_Reg(
unsigned 105 switch (counter_index) {
107 return NITIO_G0_Autoincrement_Reg;
110 return NITIO_G1_Autoincrement_Reg;
113 return NITIO_G2_Autoincrement_Reg;
116 return NITIO_G3_Autoincrement_Reg;
125 static inline enum ni_gpct_register NITIO_Gi_Command_Reg(
unsigned counter_index)
127 switch (counter_index) {
129 return NITIO_G0_Command_Reg;
132 return NITIO_G1_Command_Reg;
135 return NITIO_G2_Command_Reg;
138 return NITIO_G3_Command_Reg;
147 static inline enum ni_gpct_register NITIO_Gi_Counting_Mode_Reg(
unsigned 150 switch (counter_index) {
152 return NITIO_G0_Counting_Mode_Reg;
155 return NITIO_G1_Counting_Mode_Reg;
158 return NITIO_G2_Counting_Mode_Reg;
161 return NITIO_G3_Counting_Mode_Reg;
170 static inline enum ni_gpct_register NITIO_Gi_Input_Select_Reg(
unsigned 173 switch (counter_index) {
175 return NITIO_G0_Input_Select_Reg;
178 return NITIO_G1_Input_Select_Reg;
181 return NITIO_G2_Input_Select_Reg;
184 return NITIO_G3_Input_Select_Reg;
193 static inline enum ni_gpct_register NITIO_Gxx_Joint_Reset_Reg(
unsigned 196 switch (counter_index) {
199 return NITIO_G01_Joint_Reset_Reg;
203 return NITIO_G23_Joint_Reset_Reg;
212 static inline enum ni_gpct_register NITIO_Gxx_Joint_Status1_Reg(
unsigned 215 switch (counter_index) {
218 return NITIO_G01_Joint_Status1_Reg;
222 return NITIO_G23_Joint_Status1_Reg;
231 static inline enum ni_gpct_register NITIO_Gxx_Joint_Status2_Reg(
unsigned 234 switch (counter_index) {
237 return NITIO_G01_Joint_Status2_Reg;
241 return NITIO_G23_Joint_Status2_Reg;
250 static inline enum ni_gpct_register NITIO_Gxx_Status_Reg(
unsigned counter_index)
252 switch (counter_index) {
255 return NITIO_G01_Status_Reg;
259 return NITIO_G23_Status_Reg;
268 static inline enum ni_gpct_register NITIO_Gi_LoadA_Reg(
unsigned counter_index)
270 switch (counter_index) {
272 return NITIO_G0_LoadA_Reg;
275 return NITIO_G1_LoadA_Reg;
278 return NITIO_G2_LoadA_Reg;
281 return NITIO_G3_LoadA_Reg;
290 static inline enum ni_gpct_register NITIO_Gi_LoadB_Reg(
unsigned counter_index)
292 switch (counter_index) {
294 return NITIO_G0_LoadB_Reg;
297 return NITIO_G1_LoadB_Reg;
300 return NITIO_G2_LoadB_Reg;
303 return NITIO_G3_LoadB_Reg;
312 static inline enum ni_gpct_register NITIO_Gi_Mode_Reg(
unsigned counter_index)
314 switch (counter_index) {
316 return NITIO_G0_Mode_Reg;
319 return NITIO_G1_Mode_Reg;
322 return NITIO_G2_Mode_Reg;
325 return NITIO_G3_Mode_Reg;
334 static inline enum ni_gpct_register NITIO_Gi_SW_Save_Reg(
int counter_index)
336 switch (counter_index) {
338 return NITIO_G0_SW_Save_Reg;
341 return NITIO_G1_SW_Save_Reg;
344 return NITIO_G2_SW_Save_Reg;
347 return NITIO_G3_SW_Save_Reg;
356 static inline enum ni_gpct_register NITIO_Gi_Second_Gate_Reg(
int counter_index)
358 switch (counter_index) {
360 return NITIO_G0_Second_Gate_Reg;
363 return NITIO_G1_Second_Gate_Reg;
366 return NITIO_G2_Second_Gate_Reg;
369 return NITIO_G3_Second_Gate_Reg;
378 static inline enum ni_gpct_register NITIO_Gi_DMA_Config_Reg(
int counter_index)
380 switch (counter_index) {
382 return NITIO_G0_DMA_Config_Reg;
385 return NITIO_G1_DMA_Config_Reg;
388 return NITIO_G2_DMA_Config_Reg;
391 return NITIO_G3_DMA_Config_Reg;
400 static inline enum ni_gpct_register NITIO_Gi_DMA_Status_Reg(
int counter_index)
402 switch (counter_index) {
404 return NITIO_G0_DMA_Status_Reg;
407 return NITIO_G1_DMA_Status_Reg;
410 return NITIO_G2_DMA_Status_Reg;
413 return NITIO_G3_DMA_Status_Reg;
422 static inline enum ni_gpct_register NITIO_Gi_ABZ_Reg(
int counter_index)
424 switch (counter_index) {
426 return NITIO_G0_ABZ_Reg;
429 return NITIO_G1_ABZ_Reg;
438 static inline enum ni_gpct_register NITIO_Gi_Interrupt_Acknowledge_Reg(
int 441 switch (counter_index) {
443 return NITIO_G0_Interrupt_Acknowledge_Reg;
446 return NITIO_G1_Interrupt_Acknowledge_Reg;
449 return NITIO_G2_Interrupt_Acknowledge_Reg;
452 return NITIO_G3_Interrupt_Acknowledge_Reg;
461 static inline enum ni_gpct_register NITIO_Gi_Status_Reg(
int counter_index)
463 switch (counter_index) {
465 return NITIO_G0_Status_Reg;
468 return NITIO_G1_Status_Reg;
471 return NITIO_G2_Status_Reg;
474 return NITIO_G3_Status_Reg;
483 static inline enum ni_gpct_register NITIO_Gi_Interrupt_Enable_Reg(
int 486 switch (counter_index) {
488 return NITIO_G0_Interrupt_Enable_Reg;
491 return NITIO_G1_Interrupt_Enable_Reg;
494 return NITIO_G2_Interrupt_Enable_Reg;
497 return NITIO_G3_Interrupt_Enable_Reg;
506 enum ni_gpct_variant {
507 ni_gpct_variant_e_series,
508 ni_gpct_variant_m_series,
513 struct ni_gpct_device *counter_dev;
514 unsigned counter_index;
516 uint64_t clock_period_ps;
517 struct mite_channel *mite_chan;
521 struct ni_gpct_device {
522 struct a4l_device *dev;
523 void (*write_register)(
struct ni_gpct * counter,
524 unsigned int bits,
enum ni_gpct_register reg);
525 unsigned (*read_register)(
struct ni_gpct * counter,
526 enum ni_gpct_register reg);
527 enum ni_gpct_variant variant;
528 struct ni_gpct **counters;
529 unsigned num_counters;
530 unsigned regs[NITIO_Num_Registers];
534 #define Gi_Auto_Increment_Mask 0xff 535 #define Gi_Up_Down_Shift 5 537 #define Gi_Arm_Bit 0x1 538 #define Gi_Save_Trace_Bit 0x2 539 #define Gi_Load_Bit 0x4 540 #define Gi_Disarm_Bit 0x10 541 #define Gi_Up_Down_Mask (0x3 << Gi_Up_Down_Shift) 542 #define Gi_Always_Down_Bits (0x0 << Gi_Up_Down_Shift) 543 #define Gi_Always_Up_Bits (0x1 << Gi_Up_Down_Shift) 544 #define Gi_Up_Down_Hardware_IO_Bits (0x2 << Gi_Up_Down_Shift) 545 #define Gi_Up_Down_Hardware_Gate_Bits (0x3 << Gi_Up_Down_Shift) 546 #define Gi_Write_Switch_Bit 0x80 547 #define Gi_Synchronize_Gate_Bit 0x100 548 #define Gi_Little_Big_Endian_Bit 0x200 549 #define Gi_Bank_Switch_Start_Bit 0x400 550 #define Gi_Bank_Switch_Mode_Bit 0x800 551 #define Gi_Bank_Switch_Enable_Bit 0x1000 552 #define Gi_Arm_Copy_Bit 0x2000 553 #define Gi_Save_Trace_Copy_Bit 0x4000 554 #define Gi_Disarm_Copy_Bit 0x8000 556 #define Gi_Index_Phase_Bitshift 5 557 #define Gi_HW_Arm_Select_Shift 8 559 #define Gi_Counting_Mode_Mask 0x7 560 #define Gi_Counting_Mode_Normal_Bits 0x0 561 #define Gi_Counting_Mode_QuadratureX1_Bits 0x1 562 #define Gi_Counting_Mode_QuadratureX2_Bits 0x2 563 #define Gi_Counting_Mode_QuadratureX4_Bits 0x3 564 #define Gi_Counting_Mode_Two_Pulse_Bits 0x4 565 #define Gi_Counting_Mode_Sync_Source_Bits 0x6 566 #define Gi_Index_Mode_Bit 0x10 567 #define Gi_Index_Phase_Mask (0x3 << Gi_Index_Phase_Bitshift) 568 #define Gi_Index_Phase_LowA_LowB (0x0 << Gi_Index_Phase_Bitshift) 569 #define Gi_Index_Phase_LowA_HighB (0x1 << Gi_Index_Phase_Bitshift) 570 #define Gi_Index_Phase_HighA_LowB (0x2 << Gi_Index_Phase_Bitshift) 571 #define Gi_Index_Phase_HighA_HighB (0x3 << Gi_Index_Phase_Bitshift) 575 #define Gi_HW_Arm_Enable_Bit 0x80 578 #define Gi_660x_HW_Arm_Select_Mask (0x7 << Gi_HW_Arm_Select_Shift) 579 #define Gi_660x_Prescale_X8_Bit 0x1000 580 #define Gi_M_Series_Prescale_X8_Bit 0x2000 581 #define Gi_M_Series_HW_Arm_Select_Mask (0x1f << Gi_HW_Arm_Select_Shift) 584 #define Gi_660x_Alternate_Sync_Bit 0x2000 585 #define Gi_M_Series_Alternate_Sync_Bit 0x4000 588 #define Gi_660x_Prescale_X2_Bit 0x4000 589 #define Gi_M_Series_Prescale_X2_Bit 0x8000 591 static inline unsigned int Gi_Alternate_Sync_Bit(
enum ni_gpct_variant variant)
594 case ni_gpct_variant_e_series:
597 case ni_gpct_variant_m_series:
598 return Gi_M_Series_Alternate_Sync_Bit;
600 case ni_gpct_variant_660x:
601 return Gi_660x_Alternate_Sync_Bit;
610 static inline unsigned int Gi_Prescale_X2_Bit(
enum ni_gpct_variant variant)
613 case ni_gpct_variant_e_series:
616 case ni_gpct_variant_m_series:
617 return Gi_M_Series_Prescale_X2_Bit;
619 case ni_gpct_variant_660x:
620 return Gi_660x_Prescale_X2_Bit;
629 static inline unsigned int Gi_Prescale_X8_Bit(
enum ni_gpct_variant variant)
632 case ni_gpct_variant_e_series:
635 case ni_gpct_variant_m_series:
636 return Gi_M_Series_Prescale_X8_Bit;
638 case ni_gpct_variant_660x:
639 return Gi_660x_Prescale_X8_Bit;
648 static inline unsigned int Gi_HW_Arm_Select_Mask(
enum ni_gpct_variant variant)
651 case ni_gpct_variant_e_series:
654 case ni_gpct_variant_m_series:
655 return Gi_M_Series_HW_Arm_Select_Mask;
657 case ni_gpct_variant_660x:
658 return Gi_660x_HW_Arm_Select_Mask;
667 #define NI_660x_Timebase_1_Clock 0x0 668 #define NI_660x_Source_Pin_i_Clock 0x1 669 #define NI_660x_Next_Gate_Clock 0xa 670 #define NI_660x_Timebase_2_Clock 0x12 671 #define NI_660x_Next_TC_Clock 0x13 672 #define NI_660x_Timebase_3_Clock 0x1e 673 #define NI_660x_Logic_Low_Clock 0x1f 675 #define ni_660x_max_rtsi_channel 6 676 #define ni_660x_max_source_pin 7 678 static inline unsigned int NI_660x_RTSI_Clock(
unsigned int n)
680 BUG_ON(n > ni_660x_max_rtsi_channel);
684 static inline unsigned int NI_660x_Source_Pin_Clock(
unsigned int n)
686 BUG_ON(n > ni_660x_max_source_pin);
692 #define NI_M_Series_Timebase_1_Clock 0x0 693 #define NI_M_Series_Timebase_2_Clock 0x12 694 #define NI_M_Series_Next_TC_Clock 0x13 695 #define NI_M_Series_Next_Gate_Clock 0x14 696 #define NI_M_Series_PXI_Star_Trigger_Clock 0x14 697 #define NI_M_Series_PXI10_Clock 0x1d 698 #define NI_M_Series_Timebase_3_Clock 0x1e 699 #define NI_M_Series_Analog_Trigger_Out_Clock 0x1e 700 #define NI_M_Series_Logic_Low_Clock 0x1f 702 #define ni_m_series_max_pfi_channel 15 703 #define ni_m_series_max_rtsi_channel 7 705 static inline unsigned int NI_M_Series_PFI_Clock(
unsigned int n)
707 BUG_ON(n > ni_m_series_max_pfi_channel);
714 static inline unsigned int NI_M_Series_RTSI_Clock(
unsigned int n)
716 BUG_ON(n > ni_m_series_max_rtsi_channel);
723 #define NI_660x_Source_Pin_i_Gate_Select 0x0 724 #define NI_660x_Gate_Pin_i_Gate_Select 0x1 725 #define NI_660x_Next_SRC_Gate_Select 0xa 726 #define NI_660x_Next_Out_Gate_Select 0x14 727 #define NI_660x_Logic_Low_Gate_Select 0x1f 728 #define ni_660x_max_gate_pin 7 730 static inline unsigned int NI_660x_Gate_Pin_Gate_Select(
unsigned int n)
732 BUG_ON(n > ni_660x_max_gate_pin);
736 static inline unsigned int NI_660x_RTSI_Gate_Select(
unsigned int n)
738 BUG_ON(n > ni_660x_max_rtsi_channel);
743 #define NI_M_Series_Timestamp_Mux_Gate_Select 0x0 744 #define NI_M_Series_AI_START2_Gate_Select 0x12 745 #define NI_M_Series_PXI_Star_Trigger_Gate_Select 0x13 746 #define NI_M_Series_Next_Out_Gate_Select 0x14 747 #define NI_M_Series_AI_START1_Gate_Select 0x1c 748 #define NI_M_Series_Next_SRC_Gate_Select 0x1d 749 #define NI_M_Series_Analog_Trigger_Out_Gate_Select 0x1e 750 #define NI_M_Series_Logic_Low_Gate_Select 0x1f 752 static inline unsigned int NI_M_Series_RTSI_Gate_Select(
unsigned int n)
754 BUG_ON(n > ni_m_series_max_rtsi_channel);
760 static inline unsigned int NI_M_Series_PFI_Gate_Select(
unsigned int n)
762 BUG_ON(n > ni_m_series_max_pfi_channel);
769 #define Gi_Source_Select_Shift 2 770 #define Gi_Gate_Select_Shift 7 772 #define Gi_Read_Acknowledges_Irq 0x1 773 #define Gi_Write_Acknowledges_Irq 0x2 774 #define Gi_Source_Select_Mask 0x7c 775 #define Gi_Gate_Select_Mask (0x1f << Gi_Gate_Select_Shift) 776 #define Gi_Gate_Select_Load_Source_Bit 0x1000 777 #define Gi_Or_Gate_Bit 0x2000 778 #define Gi_Output_Polarity_Bit 0x4000 779 #define Gi_Source_Polarity_Bit 0x8000 781 #define Gi_Source_Select_Bits(x) ((x << Gi_Source_Select_Shift) & \ 782 Gi_Source_Select_Mask) 783 #define Gi_Gate_Select_Bits(x) ((x << Gi_Gate_Select_Shift) & \ 786 #define Gi_Gating_Mode_Mask 0x3 787 #define Gi_Gating_Disabled_Bits 0x0 788 #define Gi_Level_Gating_Bits 0x1 789 #define Gi_Rising_Edge_Gating_Bits 0x2 790 #define Gi_Falling_Edge_Gating_Bits 0x3 791 #define Gi_Gate_On_Both_Edges_Bit 0x4 793 #define Gi_Trigger_Mode_for_Edge_Gate_Mask 0x18 794 #define Gi_Edge_Gate_Starts_Stops_Bits 0x0 795 #define Gi_Edge_Gate_Stops_Starts_Bits 0x8 796 #define Gi_Edge_Gate_Starts_Bits 0x10 797 #define Gi_Edge_Gate_No_Starts_or_Stops_Bits 0x18 798 #define Gi_Stop_Mode_Mask 0x60 799 #define Gi_Stop_on_Gate_Bits 0x00 800 #define Gi_Stop_on_Gate_or_TC_Bits 0x20 801 #define Gi_Stop_on_Gate_or_Second_TC_Bits 0x40 802 #define Gi_Load_Source_Select_Bit 0x80 803 #define Gi_Output_Mode_Mask 0x300 804 #define Gi_Output_TC_Pulse_Bits 0x100 805 #define Gi_Output_TC_Toggle_Bits 0x200 806 #define Gi_Output_TC_or_Gate_Toggle_Bits 0x300 807 #define Gi_Counting_Once_Mask 0xc00 808 #define Gi_No_Hardware_Disarm_Bits 0x000 809 #define Gi_Disarm_at_TC_Bits 0x400 810 #define Gi_Disarm_at_Gate_Bits 0x800 811 #define Gi_Disarm_at_TC_or_Gate_Bits 0xc00 812 #define Gi_Loading_On_TC_Bit 0x1000 813 #define Gi_Gate_Polarity_Bit 0x2000 814 #define Gi_Loading_On_Gate_Bit 0x4000 815 #define Gi_Reload_Source_Switching_Bit 0x8000 817 #define NI_660x_Source_Pin_i_Second_Gate_Select 0x0 818 #define NI_660x_Up_Down_Pin_i_Second_Gate_Select 0x1 819 #define NI_660x_Next_SRC_Second_Gate_Select 0xa 820 #define NI_660x_Next_Out_Second_Gate_Select 0x14 821 #define NI_660x_Selected_Gate_Second_Gate_Select 0x1e 822 #define NI_660x_Logic_Low_Second_Gate_Select 0x1f 824 #define ni_660x_max_up_down_pin 7 827 unsigned int NI_660x_Up_Down_Pin_Second_Gate_Select(
unsigned int n)
829 BUG_ON(n > ni_660x_max_up_down_pin);
833 unsigned int NI_660x_RTSI_Second_Gate_Select(
unsigned int n)
835 BUG_ON(n > ni_660x_max_rtsi_channel);
839 #define Gi_Second_Gate_Select_Shift 7 843 #define Gi_Second_Gate_Mode_Bit 0x1 844 #define Gi_Second_Gate_Select_Mask (0x1f << Gi_Second_Gate_Select_Shift) 845 #define Gi_Second_Gate_Polarity_Bit 0x2000 846 #define Gi_Second_Gate_Subselect_Bit 0x4000 847 #define Gi_Source_Subselect_Bit 0x8000 850 unsigned int Gi_Second_Gate_Select_Bits(
unsigned int second_gate_select)
852 return (second_gate_select << Gi_Second_Gate_Select_Shift) &
853 Gi_Second_Gate_Select_Mask;
856 #define G0_Save_Bit 0x1 857 #define G1_Save_Bit 0x2 858 #define G0_Counting_Bit 0x4 859 #define G1_Counting_Bit 0x8 860 #define G0_Next_Load_Source_Bit 0x10 861 #define G1_Next_Load_Source_Bit 0x20 862 #define G0_Stale_Data_Bit 0x40 863 #define G1_Stale_Data_Bit 0x80 864 #define G0_Armed_Bit 0x100 865 #define G1_Armed_Bit 0x200 866 #define G0_No_Load_Between_Gates_Bit 0x400 867 #define G1_No_Load_Between_Gates_Bit 0x800 868 #define G0_TC_Error_Bit 0x1000 869 #define G1_TC_Error_Bit 0x2000 870 #define G0_Gate_Error_Bit 0x4000 871 #define G1_Gate_Error_Bit 0x8000 873 static inline unsigned int Gi_Counting_Bit(
unsigned int counter_index)
875 if (counter_index % 2)
876 return G1_Counting_Bit;
877 return G0_Counting_Bit;
880 static inline unsigned int Gi_Armed_Bit(
unsigned int counter_index)
882 if (counter_index % 2)
887 static inline unsigned int Gi_Next_Load_Source_Bit(
unsigned counter_index)
889 if (counter_index % 2)
890 return G1_Next_Load_Source_Bit;
891 return G0_Next_Load_Source_Bit;
894 static inline unsigned int Gi_Stale_Data_Bit(
unsigned int counter_index)
896 if (counter_index % 2)
897 return G1_Stale_Data_Bit;
898 return G0_Stale_Data_Bit;
901 static inline unsigned int Gi_TC_Error_Bit(
unsigned int counter_index)
903 if (counter_index % 2)
904 return G1_TC_Error_Bit;
905 return G0_TC_Error_Bit;
908 static inline unsigned int Gi_Gate_Error_Bit(
unsigned int counter_index)
910 if (counter_index % 2)
911 return G1_Gate_Error_Bit;
912 return G0_Gate_Error_Bit;
916 static inline unsigned Gi_Reset_Bit(
unsigned int counter_index)
918 return 0x1 << (2 + (counter_index % 2));
921 #define G0_Output_Bit 0x1 922 #define G1_Output_Bit 0x2 923 #define G0_HW_Save_Bit 0x1000 924 #define G1_HW_Save_Bit 0x2000 925 #define G0_Permanent_Stale_Bit 0x4000 926 #define G1_Permanent_Stale_Bit 0x8000 928 static inline unsigned int Gi_Permanent_Stale_Bit(
unsigned 931 if (counter_index % 2)
932 return G1_Permanent_Stale_Bit;
933 return G0_Permanent_Stale_Bit;
936 #define Gi_DMA_Enable_Bit 0x1 937 #define Gi_DMA_Write_Bit 0x2 938 #define Gi_DMA_Int_Bit 0x4 940 #define Gi_DMA_Readbank_Bit 0x2000 941 #define Gi_DRQ_Error_Bit 0x4000 942 #define Gi_DRQ_Status_Bit 0x8000 944 #define G0_Gate_Error_Confirm_Bit 0x20 945 #define G0_TC_Error_Confirm_Bit 0x40 947 #define G1_Gate_Error_Confirm_Bit 0x2 948 #define G1_TC_Error_Confirm_Bit 0x4 950 static inline unsigned int Gi_Gate_Error_Confirm_Bit(
unsigned int counter_index)
952 if (counter_index % 2)
953 return G1_Gate_Error_Confirm_Bit;
954 return G0_Gate_Error_Confirm_Bit;
957 static inline unsigned int Gi_TC_Error_Confirm_Bit(
unsigned int counter_index)
959 if (counter_index % 2)
960 return G1_TC_Error_Confirm_Bit;
961 return G0_TC_Error_Confirm_Bit;
965 #define Gi_TC_Interrupt_Ack_Bit 0x4000 966 #define Gi_Gate_Interrupt_Ack_Bit 0x8000 968 #define Gi_Gate_Interrupt_Bit 0x4 969 #define Gi_TC_Bit 0x8 970 #define Gi_Interrupt_Bit 0x8000 972 #define G0_TC_Interrupt_Enable_Bit 0x40 973 #define G0_Gate_Interrupt_Enable_Bit 0x100 975 #define G1_TC_Interrupt_Enable_Bit 0x200 976 #define G1_Gate_Interrupt_Enable_Bit 0x400 978 static inline unsigned int Gi_Gate_Interrupt_Enable_Bit(
unsigned int counter_index)
982 if (counter_index % 2) {
983 bit = G1_Gate_Interrupt_Enable_Bit;
985 bit = G0_Gate_Interrupt_Enable_Bit;
990 #define counter_status_mask (A4L_COUNTER_ARMED | A4L_COUNTER_COUNTING) 992 #define NI_USUAL_PFI_SELECT(x) ((x < 10) ? (0x1 + x) : (0xb + x)) 993 #define NI_USUAL_RTSI_SELECT(x) ((x < 7 ) ? (0xb + x) : (0x1b + x)) 997 #define NI_GPCT_COUNTING_MODE_SHIFT 16 998 #define NI_GPCT_INDEX_PHASE_BITSHIFT 20 999 #define NI_GPCT_COUNTING_DIRECTION_SHIFT 24 1001 #define NI_GPCT_GATE_ON_BOTH_EDGES_BIT 0x4 1002 #define NI_GPCT_EDGE_GATE_MODE_MASK 0x18 1003 #define NI_GPCT_EDGE_GATE_STARTS_STOPS_BITS 0x0 1004 #define NI_GPCT_EDGE_GATE_STOPS_STARTS_BITS 0x8 1005 #define NI_GPCT_EDGE_GATE_STARTS_BITS 0x10 1006 #define NI_GPCT_EDGE_GATE_NO_STARTS_NO_STOPS_BITS 0x18 1007 #define NI_GPCT_STOP_MODE_MASK 0x60 1008 #define NI_GPCT_STOP_ON_GATE_BITS 0x00 1009 #define NI_GPCT_STOP_ON_GATE_OR_TC_BITS 0x20 1010 #define NI_GPCT_STOP_ON_GATE_OR_SECOND_TC_BITS 0x40 1011 #define NI_GPCT_LOAD_B_SELECT_BIT 0x80 1012 #define NI_GPCT_OUTPUT_MODE_MASK 0x300 1013 #define NI_GPCT_OUTPUT_TC_PULSE_BITS 0x100 1014 #define NI_GPCT_OUTPUT_TC_TOGGLE_BITS 0x200 1015 #define NI_GPCT_OUTPUT_TC_OR_GATE_TOGGLE_BITS 0x300 1016 #define NI_GPCT_HARDWARE_DISARM_MASK 0xc00 1017 #define NI_GPCT_NO_HARDWARE_DISARM_BITS 0x000 1018 #define NI_GPCT_DISARM_AT_TC_BITS 0x400 1019 #define NI_GPCT_DISARM_AT_GATE_BITS 0x800 1020 #define NI_GPCT_DISARM_AT_TC_OR_GATE_BITS 0xc00 1021 #define NI_GPCT_LOADING_ON_TC_BIT 0x1000 1022 #define NI_GPCT_LOADING_ON_GATE_BIT 0x4000 1023 #define NI_GPCT_COUNTING_MODE_MASK 0x7 << NI_GPCT_COUNTING_MODE_SHIFT 1024 #define NI_GPCT_COUNTING_MODE_NORMAL_BITS 0x0 << NI_GPCT_COUNTING_MODE_SHIFT 1025 #define NI_GPCT_COUNTING_MODE_QUADRATURE_X1_BITS 0x1 << NI_GPCT_COUNTING_MODE_SHIFT 1026 #define NI_GPCT_COUNTING_MODE_QUADRATURE_X2_BITS 0x2 << NI_GPCT_COUNTING_MODE_SHIFT 1027 #define NI_GPCT_COUNTING_MODE_QUADRATURE_X4_BITS 0x3 << NI_GPCT_COUNTING_MODE_SHIFT 1028 #define NI_GPCT_COUNTING_MODE_TWO_PULSE_BITS 0x4 << NI_GPCT_COUNTING_MODE_SHIFT 1029 #define NI_GPCT_COUNTING_MODE_SYNC_SOURCE_BITS 0x6 << NI_GPCT_COUNTING_MODE_SHIFT 1030 #define NI_GPCT_INDEX_PHASE_MASK 0x3 << NI_GPCT_INDEX_PHASE_BITSHIFT 1031 #define NI_GPCT_INDEX_PHASE_LOW_A_LOW_B_BITS 0x0 << NI_GPCT_INDEX_PHASE_BITSHIFT 1032 #define NI_GPCT_INDEX_PHASE_LOW_A_HIGH_B_BITS 0x1 << NI_GPCT_INDEX_PHASE_BITSHIFT 1033 #define NI_GPCT_INDEX_PHASE_HIGH_A_LOW_B_BITS 0x2 << NI_GPCT_INDEX_PHASE_BITSHIFT 1034 #define NI_GPCT_INDEX_PHASE_HIGH_A_HIGH_B_BITS 0x3 << NI_GPCT_INDEX_PHASE_BITSHIFT 1035 #define NI_GPCT_INDEX_ENABLE_BIT 0x400000 1036 #define NI_GPCT_COUNTING_DIRECTION_MASK 0x3 << NI_GPCT_COUNTING_DIRECTION_SHIFT 1037 #define NI_GPCT_COUNTING_DIRECTION_DOWN_BITS 0x00 << NI_GPCT_COUNTING_DIRECTION_SHIFT 1038 #define NI_GPCT_COUNTING_DIRECTION_UP_BITS 0x1 << NI_GPCT_COUNTING_DIRECTION_SHIFT 1039 #define NI_GPCT_COUNTING_DIRECTION_HW_UP_DOWN_BITS 0x2 << NI_GPCT_COUNTING_DIRECTION_SHIFT 1040 #define NI_GPCT_COUNTING_DIRECTION_HW_GATE_BITS 0x3 << NI_GPCT_COUNTING_DIRECTION_SHIFT 1041 #define NI_GPCT_RELOAD_SOURCE_MASK 0xc000000 1042 #define NI_GPCT_RELOAD_SOURCE_FIXED_BITS 0x0 1043 #define NI_GPCT_RELOAD_SOURCE_SWITCHING_BITS 0x4000000 1044 #define NI_GPCT_RELOAD_SOURCE_GATE_SELECT_BITS 0x8000000 1045 #define NI_GPCT_OR_GATE_BIT 0x10000000 1046 #define NI_GPCT_INVERT_OUTPUT_BIT 0x20000000 1050 #define NI_GPCT_CLOCK_SRC_SELECT_MASK 0x3f 1051 #define NI_GPCT_TIMEBASE_1_CLOCK_SRC_BITS 0x0 1052 #define NI_GPCT_TIMEBASE_2_CLOCK_SRC_BITS 0x1 1053 #define NI_GPCT_TIMEBASE_3_CLOCK_SRC_BITS 0x2 1054 #define NI_GPCT_LOGIC_LOW_CLOCK_SRC_BITS 0x3 1055 #define NI_GPCT_NEXT_GATE_CLOCK_SRC_BITS 0x4 1056 #define NI_GPCT_NEXT_TC_CLOCK_SRC_BITS 0x5 1057 #define NI_GPCT_SOURCE_PIN_i_CLOCK_SRC_BITS 0x6 1058 #define NI_GPCT_PXI10_CLOCK_SRC_BITS 0x7 1059 #define NI_GPCT_PXI_STAR_TRIGGER_CLOCK_SRC_BITS 0x8 1060 #define NI_GPCT_ANALOG_TRIGGER_OUT_CLOCK_SRC_BITS 0x9 1061 #define NI_GPCT_PRESCALE_MODE_CLOCK_SRC_MASK 0x30000000 1062 #define NI_GPCT_NO_PRESCALE_CLOCK_SRC_BITS 0x0 1063 #define NI_GPCT_PRESCALE_X2_CLOCK_SRC_BITS 0x10000000 1064 #define NI_GPCT_PRESCALE_X8_CLOCK_SRC_BITS 0x20000000 1065 #define NI_GPCT_INVERT_CLOCK_SRC_BIT 0x80000000 1066 #define NI_GPCT_SOURCE_PIN_CLOCK_SRC_BITS(x) (0x10 + x) 1067 #define NI_GPCT_RTSI_CLOCK_SRC_BITS(x) (0x18 + x) 1068 #define NI_GPCT_PFI_CLOCK_SRC_BITS(x) (0x20 + x) 1074 #define NI_GPCT_TIMESTAMP_MUX_GATE_SELECT 0x0 1075 #define NI_GPCT_AI_START2_GATE_SELECT 0x12 1076 #define NI_GPCT_PXI_STAR_TRIGGER_GATE_SELECT 0x13 1077 #define NI_GPCT_NEXT_OUT_GATE_SELECT 0x14 1078 #define NI_GPCT_AI_START1_GATE_SELECT 0x1c 1079 #define NI_GPCT_NEXT_SOURCE_GATE_SELECT 0x1d 1080 #define NI_GPCT_ANALOG_TRIGGER_OUT_GATE_SELECT 0x1e 1081 #define NI_GPCT_LOGIC_LOW_GATE_SELECT 0x1f 1083 #define NI_GPCT_SOURCE_PIN_i_GATE_SELECT 0x100 1084 #define NI_GPCT_GATE_PIN_i_GATE_SELECT 0x101 1086 #define NI_GPCT_UP_DOWN_PIN_i_GATE_SELECT 0x201 1087 #define NI_GPCT_SELECTED_GATE_GATE_SELECT 0x21e 1090 #define NI_GPCT_DISABLED_GATE_SELECT 0x8000 1091 #define NI_GPCT_GATE_PIN_GATE_SELECT(x) (0x102 + x) 1092 #define NI_GPCT_RTSI_GATE_SELECT(x) NI_USUAL_RTSI_SELECT(x) 1093 #define NI_GPCT_PFI_GATE_SELECT(x) NI_USUAL_PFI_SELECT(x) 1094 #define NI_GPCT_UP_DOWN_PIN_GATE_SELECT(x) (0x202 + x) 1098 #define NI_GPCT_SOURCE_ENCODER_A 0 1099 #define NI_GPCT_SOURCE_ENCODER_B 1 1100 #define NI_GPCT_SOURCE_ENCODER_Z 2 1103 #define NI_GPCT_DISABLED_OTHER_SELECT 0x8000 1104 #define NI_GPCT_PFI_OTHER_SELECT(x) NI_USUAL_PFI_SELECT(x) 1108 #define NI_GPCT_ARM_IMMEDIATE 0x0 1111 #define NI_GPCT_ARM_PAIRED_IMMEDIATE 0x1 1117 #define NI_GPCT_ARM_UNKNOWN 0x1000 1121 #define NI_GPCT_FILTER_OFF 0x0 1122 #define NI_GPCT_FILTER_TIMEBASE_3_SYNC 0x1 1123 #define NI_GPCT_FILTER_100x_TIMEBASE_1 0x2 1124 #define NI_GPCT_FILTER_20x_TIMEBASE_1 0x3 1125 #define NI_GPCT_FILTER_10x_TIMEBASE_1 0x4 1126 #define NI_GPCT_FILTER_2x_TIMEBASE_1 0x5 1127 #define NI_GPCT_FILTER_2x_TIMEBASE_3 0x6 1131 #define NI_MIO_INTERNAL_CLOCK 0 1132 #define NI_MIO_RTSI_CLOCK 1 1135 #define NI_MIO_PLL_PXI_STAR_TRIGGER_CLOCK 2 1136 #define NI_MIO_PLL_PXI10_CLOCK 3 1137 #define NI_MIO_PLL_RTSI0_CLOCK 4 1139 #define NI_MIO_PLL_RTSI_CLOCK(x) (NI_MIO_PLL_RTSI0_CLOCK + (x)) 1144 #define NI_RTSI_OUTPUT_ADR_START1 0 1145 #define NI_RTSI_OUTPUT_ADR_START2 1 1146 #define NI_RTSI_OUTPUT_SCLKG 2 1147 #define NI_RTSI_OUTPUT_DACUPDN 3 1148 #define NI_RTSI_OUTPUT_DA_START1 4 1149 #define NI_RTSI_OUTPUT_G_SRC0 5 1150 #define NI_RTSI_OUTPUT_G_GATE0 6 1151 #define NI_RTSI_OUTPUT_RGOUT0 7 1152 #define NI_RTSI_OUTPUT_RTSI_BRD_0 8 1154 #define NI_RTSI_OUTPUT_RTSI_OSC 12 1156 #define NI_RTSI_OUTPUT_RTSI_BRD(x) (NI_RTSI_OUTPUT_RTSI_BRD_0 + (x)) 1159 int a4l_ni_tio_rinsn(
struct ni_gpct *counter,
struct a4l_kernel_instruction *insn);
1160 int a4l_ni_tio_winsn(
struct ni_gpct *counter,
struct a4l_kernel_instruction *insn);
1161 int a4l_ni_tio_insn_config(
struct ni_gpct *counter,
struct a4l_kernel_instruction *insn);
1162 void a4l_ni_tio_init_counter(
struct ni_gpct *counter);
1164 struct ni_gpct_device *a4l_ni_gpct_device_construct(
struct a4l_device * dev,
1165 void (*write_register) (
struct ni_gpct * counter,
unsigned int bits,
1166 enum ni_gpct_register reg),
1167 unsigned int (*read_register) (
struct ni_gpct * counter,
1168 enum ni_gpct_register reg),
enum ni_gpct_variant variant,
1169 unsigned int num_counters);
1170 void a4l_ni_gpct_device_destroy(
struct ni_gpct_device *counter_dev);
1172 #if (defined(CONFIG_XENO_DRIVERS_ANALOGY_NI_MITE) || \ 1173 defined(CONFIG_XENO_DRIVERS_ANALOGY_NI_MITE_MODULE)) 1177 int a4l_ni_tio_input_inttrig(
struct ni_gpct *counter, lsampl_t trignum);
1178 int a4l_ni_tio_cmd(
struct ni_gpct *counter,
struct a4l_cmd_desc *cmd);
1179 int a4l_ni_tio_cmdtest(
struct ni_gpct *counter,
struct a4l_cmd_desc *cmd);
1180 int a4l_ni_tio_cancel(
struct ni_gpct *counter);
1182 void a4l_ni_tio_handle_interrupt(
struct ni_gpct *counter,
struct a4l_device *dev);
1183 void a4l_ni_tio_set_mite_channel(
struct ni_gpct *counter,
1184 struct mite_channel *mite_chan);
1185 void a4l_ni_tio_acknowledge_and_confirm(
struct ni_gpct *counter,
1188 int *perm_stale_data,
int *stale_data);
ipipe_spinlock_t rtdm_lock_t
Lock variable.
Definition: driver.h:551
Structure describing the asynchronous instruction.
Definition: analogy.h:289