GNU Linux-libre 6.7.9-gnu
[releases.git] / drivers / comedi / drivers / ni_routing / ni_route_values.h
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  *  comedi/drivers/ni_routing/ni_route_values.h
4  *  Route information for NI boards.
5  *
6  *  COMEDI - Linux Control and Measurement Device Interface
7  *  Copyright (C) 2016 Spencer E. Olson <olsonse@umich.edu>
8  *
9  *  This program is free software; you can redistribute it and/or modify
10  *  it under the terms of the GNU General Public License as published by
11  *  the Free Software Foundation; either version 2 of the License, or
12  *  (at your option) any later version.
13  *
14  *  This program is distributed in the hope that it will be useful,
15  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  *  GNU General Public License for more details.
18  */
19
20 #ifndef _COMEDI_DRIVERS_NI_ROUTINT_NI_ROUTE_VALUES_H
21 #define _COMEDI_DRIVERS_NI_ROUTINT_NI_ROUTE_VALUES_H
22
23 #include <linux/comedi.h>
24 #include <linux/types.h>
25
26 /*
27  * This file includes the tables that are a list of all the values of various
28  * signals routes available on NI hardware.  In many cases, one does not
29  * explicitly make these routes, rather one might indicate that something is
30  * used as the source of one particular trigger or another (using
31  * *_src=TRIG_EXT).
32  *
33  * This file is meant to be included by comedi/drivers/ni_routes.c
34  */
35
36 #define B(x)    ((x) - NI_NAMES_BASE)
37
38 /** Marks a register value as valid, implemented, and tested. */
39 #define V(x)    (((x) & 0x7f) | 0x80)
40
41 #ifndef NI_ROUTE_VALUE_EXTERNAL_CONVERSION
42         /** Marks a register value as implemented but needing testing. */
43         #define I(x)    V(x)
44         /** Marks a register value as not implemented. */
45         #define U(x)    0x0
46
47         typedef u8 register_type;
48 #else
49         /** Marks a register value as implemented but needing testing. */
50         #define I(x)    (((x) & 0x7f) | 0x100)
51         /** Marks a register value as not implemented. */
52         #define U(x)    (((x) & 0x7f) | 0x200)
53
54         /** Tests whether a register is marked as valid/implemented/tested */
55         #define MARKED_V(x)     (((x) & 0x80) != 0)
56         /** Tests whether a register is implemented but not tested */
57         #define MARKED_I(x)     (((x) & 0x100) != 0)
58         /** Tests whether a register is not implemented */
59         #define MARKED_U(x)     (((x) & 0x200) != 0)
60
61         /* need more space to store extra marks */
62         typedef u16 register_type;
63 #endif
64
65 /* Mask out the marking bit(s). */
66 #define UNMARK(x)       ((x) & 0x7f)
67
68 /*
69  * Gi_SRC(x,1) implements Gi_Src_SubSelect = 1
70  *
71  * This appears to only really be a valid MUX for m-series devices.
72  */
73 #define Gi_SRC(val, subsel)     ((val) | ((subsel) << 6))
74
75 /**
76  * struct family_route_values - Register values for all routes for a particular
77  *                              family.
78  * @family: lower-case string representation of a specific series or family of
79  *          devices from National Instruments where each member of this family
80  *          shares the same register values for the various signal MUXes.  It
81  *          should be noted that not all devices of any family have access to
82  *          all routes defined.
83  * @register_values: Table of all register values for various signal MUXes on
84  *          National Instruments devices.  The first index of this table is the
85  *          signal destination (i.e. identification of the signal MUX).  The
86  *          second index of this table is the signal source (i.e. input of the
87  *          signal MUX).
88  */
89 struct family_route_values {
90         const char *family;
91         const register_type register_values[NI_NUM_NAMES][NI_NUM_NAMES];
92
93 };
94
95 extern const struct family_route_values *const ni_all_route_values[];
96
97 #endif /* _COMEDI_DRIVERS_NI_ROUTINT_NI_ROUTE_VALUES_H */