1
2
3
4
5
6
7
8 #ifndef _COMEDI_NI_TIO_H
9 #define _COMEDI_NI_TIO_H
10
11 #include "../comedidev.h"
12
13 enum ni_gpct_register {
14 NITIO_G0_AUTO_INC,
15 NITIO_G1_AUTO_INC,
16 NITIO_G2_AUTO_INC,
17 NITIO_G3_AUTO_INC,
18 NITIO_G0_CMD,
19 NITIO_G1_CMD,
20 NITIO_G2_CMD,
21 NITIO_G3_CMD,
22 NITIO_G0_HW_SAVE,
23 NITIO_G1_HW_SAVE,
24 NITIO_G2_HW_SAVE,
25 NITIO_G3_HW_SAVE,
26 NITIO_G0_SW_SAVE,
27 NITIO_G1_SW_SAVE,
28 NITIO_G2_SW_SAVE,
29 NITIO_G3_SW_SAVE,
30 NITIO_G0_MODE,
31 NITIO_G1_MODE,
32 NITIO_G2_MODE,
33 NITIO_G3_MODE,
34 NITIO_G0_LOADA,
35 NITIO_G1_LOADA,
36 NITIO_G2_LOADA,
37 NITIO_G3_LOADA,
38 NITIO_G0_LOADB,
39 NITIO_G1_LOADB,
40 NITIO_G2_LOADB,
41 NITIO_G3_LOADB,
42 NITIO_G0_INPUT_SEL,
43 NITIO_G1_INPUT_SEL,
44 NITIO_G2_INPUT_SEL,
45 NITIO_G3_INPUT_SEL,
46 NITIO_G0_CNT_MODE,
47 NITIO_G1_CNT_MODE,
48 NITIO_G2_CNT_MODE,
49 NITIO_G3_CNT_MODE,
50 NITIO_G0_GATE2,
51 NITIO_G1_GATE2,
52 NITIO_G2_GATE2,
53 NITIO_G3_GATE2,
54 NITIO_G01_STATUS,
55 NITIO_G23_STATUS,
56 NITIO_G01_RESET,
57 NITIO_G23_RESET,
58 NITIO_G01_STATUS1,
59 NITIO_G23_STATUS1,
60 NITIO_G01_STATUS2,
61 NITIO_G23_STATUS2,
62 NITIO_G0_DMA_CFG,
63 NITIO_G1_DMA_CFG,
64 NITIO_G2_DMA_CFG,
65 NITIO_G3_DMA_CFG,
66 NITIO_G0_DMA_STATUS,
67 NITIO_G1_DMA_STATUS,
68 NITIO_G2_DMA_STATUS,
69 NITIO_G3_DMA_STATUS,
70 NITIO_G0_ABZ,
71 NITIO_G1_ABZ,
72 NITIO_G0_INT_ACK,
73 NITIO_G1_INT_ACK,
74 NITIO_G2_INT_ACK,
75 NITIO_G3_INT_ACK,
76 NITIO_G0_STATUS,
77 NITIO_G1_STATUS,
78 NITIO_G2_STATUS,
79 NITIO_G3_STATUS,
80 NITIO_G0_INT_ENA,
81 NITIO_G1_INT_ENA,
82 NITIO_G2_INT_ENA,
83 NITIO_G3_INT_ENA,
84 NITIO_NUM_REGS,
85 };
86
87 enum ni_gpct_variant {
88 ni_gpct_variant_e_series,
89 ni_gpct_variant_m_series,
90 ni_gpct_variant_660x
91 };
92
93 struct ni_gpct {
94 struct ni_gpct_device *counter_dev;
95 unsigned int counter_index;
96 unsigned int chip_index;
97 u64 clock_period_ps;
98 struct mite_channel *mite_chan;
99 spinlock_t lock;
100 };
101
102 struct ni_gpct_device {
103 struct comedi_device *dev;
104 void (*write)(struct ni_gpct *counter, unsigned int value,
105 enum ni_gpct_register);
106 unsigned int (*read)(struct ni_gpct *counter, enum ni_gpct_register);
107 enum ni_gpct_variant variant;
108 struct ni_gpct *counters;
109 unsigned int num_counters;
110 unsigned int num_chips;
111 unsigned int (*regs)[NITIO_NUM_REGS];
112 spinlock_t regs_lock;
113 const struct ni_route_tables *routing_tables;
114 };
115
116 struct ni_gpct_device *
117 ni_gpct_device_construct(struct comedi_device *dev,
118 void (*write)(struct ni_gpct *counter,
119 unsigned int value,
120 enum ni_gpct_register),
121 unsigned int (*read)(struct ni_gpct *counter,
122 enum ni_gpct_register),
123 enum ni_gpct_variant,
124 unsigned int num_counters,
125 unsigned int counters_per_chip,
126 const struct ni_route_tables *routing_tables);
127 void ni_gpct_device_destroy(struct ni_gpct_device *counter_dev);
128 void ni_tio_init_counter(struct ni_gpct *counter);
129 int ni_tio_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
130 struct comedi_insn *insn, unsigned int *data);
131 int ni_tio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
132 struct comedi_insn *insn, unsigned int *data);
133 int ni_tio_insn_write(struct comedi_device *dev, struct comedi_subdevice *s,
134 struct comedi_insn *insn, unsigned int *data);
135 int ni_tio_cmd(struct comedi_device *dev, struct comedi_subdevice *s);
136 int ni_tio_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
137 struct comedi_cmd *cmd);
138 int ni_tio_cancel(struct ni_gpct *counter);
139 void ni_tio_handle_interrupt(struct ni_gpct *counter,
140 struct comedi_subdevice *s);
141 void ni_tio_set_mite_channel(struct ni_gpct *counter,
142 struct mite_channel *mite_chan);
143 void ni_tio_acknowledge(struct ni_gpct *counter);
144
145
146
147
148
149
150
151
152
153
154
155 int ni_tio_get_routing(struct ni_gpct_device *counter_dev,
156 unsigned int destination);
157
158
159
160
161
162
163
164
165
166
167
168
169
170 int ni_tio_set_routing(struct ni_gpct_device *counter_dev,
171 unsigned int destination, unsigned int register_value);
172
173
174
175
176
177
178 int ni_tio_unset_routing(struct ni_gpct_device *counter_dev,
179 unsigned int destination);
180
181 #endif