]>
git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/blob - drivers/staging/comedi/drivers/ni_tio.h
1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Header file for NI general purpose counter support code (ni_tio.c)
5 * COMEDI - Linux Control and Measurement Device Interface
8 #ifndef _COMEDI_NI_TIO_H
9 #define _COMEDI_NI_TIO_H
11 #include "../comedidev.h"
13 enum ni_gpct_register
{
87 enum ni_gpct_variant
{
88 ni_gpct_variant_e_series
,
89 ni_gpct_variant_m_series
,
94 struct ni_gpct_device
*counter_dev
;
95 unsigned int counter_index
;
96 unsigned int chip_index
;
97 u64 clock_period_ps
; /* clock period in picoseconds */
98 struct mite_channel
*mite_chan
;
99 spinlock_t lock
; /* protects 'mite_chan' */
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
]; /* [num_chips][NITIO_NUM_REGS] */
112 spinlock_t regs_lock
; /* protects 'regs' */
113 const struct ni_route_tables
*routing_tables
; /* link to routes */
116 struct ni_gpct_device
*
117 ni_gpct_device_construct(struct comedi_device
*dev
,
118 void (*write
)(struct ni_gpct
*counter
,
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
);
146 * Retrieves the register value of the current source of the output selector for
147 * the given destination.
149 * If the terminal for the destination is not already configured as an output,
150 * this function returns -EINVAL as error.
152 * Return: the register value of the destination output selector;
153 * -EINVAL if terminal is not configured for output.
155 int ni_tio_get_routing(struct ni_gpct_device
*counter_dev
,
156 unsigned int destination
);
159 * Sets the register value of the selector MUX for the given destination.
160 * @counter_dev:Pointer to general counter device.
161 * @destination:Device-global identifier of route destination.
163 * The first several bits of this value should store the desired
164 * value to write to the register. All other bits are for
165 * transmitting information that modify the mode of the particular
166 * destination/gate. These mode bits might include a bitwise or of
167 * CR_INVERT and CR_EDGE. Note that the calling function should
168 * have already validated the correctness of this value.
170 int ni_tio_set_routing(struct ni_gpct_device
*counter_dev
,
171 unsigned int destination
, unsigned int register_value
);
174 * Sets the given destination MUX to its default value or disable it.
176 * Return: 0 if successful; -EINVAL if terminal is unknown.
178 int ni_tio_unset_routing(struct ni_gpct_device
*counter_dev
,
179 unsigned int destination
);
181 #endif /* _COMEDI_NI_TIO_H */