Add the rt linux 4.1.3-rt3 as base
[kvmfornfv.git] / kernel / drivers / staging / comedi / drivers / z8536.h
1 /*
2  * Z8536 CIO Internal registers
3  */
4
5 #ifndef _Z8536_H
6 #define _Z8536_H
7
8 /* Master Interrupt Control register */
9 #define Z8536_INT_CTRL_REG              0x00
10 #define Z8536_INT_CTRL_MIE              BIT(7)  /* Master Interrupt Enable */
11 #define Z8536_INT_CTRL_DLC              BIT(6)  /* Disable Lower Chain */
12 #define Z8536_INT_CTRL_NV               BIT(5)  /* No Vector */
13 #define Z8536_INT_CTRL_PA_VIS           BIT(4)  /* Port A Vect Inc Status */
14 #define Z8536_INT_CTRL_PB_VIS           BIT(3)  /* Port B Vect Inc Status */
15 #define Z8536_INT_CTRL_VT_VIS           BIT(2)  /* C/T Vect Inc Status */
16 #define Z8536_INT_CTRL_RJA              BIT(1)  /* Right Justified Addresses */
17 #define Z8536_INT_CTRL_RESET            BIT(0)  /* Reset */
18
19 /* Master Configuration Control register */
20 #define Z8536_CFG_CTRL_REG              0x01
21 #define Z8536_CFG_CTRL_PBE              BIT(7)  /* Port B Enable */
22 #define Z8536_CFG_CTRL_CT1E             BIT(6)  /* C/T 1 Enable */
23 #define Z8536_CFG_CTRL_CT2E             BIT(5)  /* C/T 2 Enable */
24 #define Z8536_CFG_CTRL_PCE_CT3E         BIT(4)  /* Port C & C/T 3 Enable */
25 #define Z8536_CFG_CTRL_PLC              BIT(3)  /* Port A/B Link Control */
26 #define Z8536_CFG_CTRL_PAE              BIT(2)  /* Port A Enable */
27 #define Z8536_CFG_CTRL_LC_INDEP         (0 << 0)/* C/Ts Independent */
28 #define Z8536_CFG_CTRL_LC_GATE          (1 << 0)/* C/T 1 Out Gates C/T 2 */
29 #define Z8536_CFG_CTRL_LC_TRIG          (2 << 0)/* C/T 1 Out Triggers C/T 2 */
30 #define Z8536_CFG_CTRL_LC_CLK           (3 << 0)/* C/T 1 Out Clocks C/T 2 */
31 #define Z8536_CFG_CTRL_LC_MASK          (3 << 0)/* C/T Link Control mask */
32
33 /* Interrupt Vector registers */
34 #define Z8536_PA_INT_VECT_REG           0x02
35 #define Z8536_PB_INT_VECT_REG           0x03
36 #define Z8536_CT_INT_VECT_REG           0x04
37 #define Z8536_CURR_INT_VECT_REG         0x1f
38
39 /* Port A/B & Counter/Timer 1/2/3 Command and Status registers */
40 #define Z8536_PA_CMDSTAT_REG            0x08
41 #define Z8536_PB_CMDSTAT_REG            0x09
42 #define Z8536_CT1_CMDSTAT_REG           0x0a
43 #define Z8536_CT2_CMDSTAT_REG           0x0b
44 #define Z8536_CT3_CMDSTAT_REG           0x0c
45 #define Z8536_CT_CMDSTAT_REG(x)         (0x0a + (x))
46 #define Z8536_CMD_NULL                  (0 << 5)/* Null Code */
47 #define Z8536_CMD_CLR_IP_IUS            (1 << 5)/* Clear IP & IUS */
48 #define Z8536_CMD_SET_IUS               (2 << 5)/* Set IUS */
49 #define Z8536_CMD_CLR_IUS               (3 << 5)/* Clear IUS */
50 #define Z8536_CMD_SET_IP                (4 << 5)/* Set IP */
51 #define Z8536_CMD_CLR_IP                (5 << 5)/* Clear IP */
52 #define Z8536_CMD_SET_IE                (6 << 5)/* Set IE */
53 #define Z8536_CMD_CLR_IE                (7 << 5)/* Clear IE */
54 #define Z8536_CMD_MASK                  (7 << 5)
55
56 #define Z8536_STAT_IUS                  BIT(7)  /* Interrupt Under Service */
57 #define Z8536_STAT_IE                   BIT(6)  /* Interrupt Enable */
58 #define Z8536_STAT_IP                   BIT(5)  /* Interrupt Pending */
59 #define Z8536_STAT_ERR                  BIT(4)  /* Interrupt Error */
60 #define Z8536_STAT_IE_IP                (Z8536_STAT_IE | Z8536_STAT_IP)
61
62 #define Z8536_PAB_STAT_ORE              BIT(3)  /* Output Register Empty */
63 #define Z8536_PAB_STAT_IRF              BIT(2)  /* Input Register Full */
64 #define Z8536_PAB_STAT_PMF              BIT(1)  /* Pattern Match Flag */
65 #define Z8536_PAB_CMDSTAT_IOE           BIT(0)  /* Interrupt On Error */
66
67 #define Z8536_CT_CMD_RCC                BIT(3)  /* Read Counter Control */
68 #define Z8536_CT_CMDSTAT_GCB            BIT(2)  /* Gate Command Bit */
69 #define Z8536_CT_CMD_TCB                BIT(1)  /* Trigger Command Bit */
70 #define Z8536_CT_STAT_CIP               BIT(0)  /* Count In Progress */
71
72 /* Port Data registers */
73 #define Z8536_PA_DATA_REG               0x0d
74 #define Z8536_PB_DATA_REG               0x0e
75 #define Z8536_PC_DATA_REG               0x0f
76
77 /* Counter/Timer 1/2/3 Current Count registers */
78 #define Z8536_CT1_VAL_MSB_REG           0x10
79 #define Z8536_CT1_VAL_LSB_REG           0x11
80 #define Z8536_CT2_VAL_MSB_REG           0x12
81 #define Z8536_CT2_VAL_LSB_REG           0x13
82 #define Z8536_CT3_VAL_MSB_REG           0x14
83 #define Z8536_CT3_VAL_LSB_REG           0x15
84 #define Z8536_CT_VAL_MSB_REG(x)         (0x10 + ((x) * 2))
85 #define Z8536_CT_VAL_LSB_REG(x)         (0x11 + ((x) * 2))
86
87 /* Counter/Timer 1/2/3 Time Constant registers */
88 #define Z8536_CT1_RELOAD_MSB_REG        0x16
89 #define Z8536_CT1_RELOAD_LSB_REG        0x17
90 #define Z8536_CT2_RELOAD_MSB_REG        0x18
91 #define Z8536_CT2_RELOAD_LSB_REG        0x19
92 #define Z8536_CT3_RELOAD_MSB_REG        0x1a
93 #define Z8536_CT3_RELOAD_LSB_REG        0x1b
94 #define Z8536_CT_RELOAD_MSB_REG(x)      (0x16 + ((x) * 2))
95 #define Z8536_CT_RELOAD_LSB_REG(x)      (0x17 + ((x) * 2))
96
97 /* Counter/Timer 1/2/3 Mode Specification registers */
98 #define Z8536_CT1_MODE_REG              0x1c
99 #define Z8536_CT2_MODE_REG              0x1d
100 #define Z8536_CT3_MODE_REG              0x1e
101 #define Z8536_CT_MODE_REG(x)            (0x1c + (x))
102 #define Z8536_CT_MODE_CSC               BIT(7)  /* Continuous/Single Cycle */
103 #define Z8536_CT_MODE_EOE               BIT(6)  /* External Output Enable */
104 #define Z8536_CT_MODE_ECE               BIT(5)  /* External Count Enable */
105 #define Z8536_CT_MODE_ETE               BIT(4)  /* External Trigger Enable */
106 #define Z8536_CT_MODE_EGE               BIT(3)  /* External Gate Enable */
107 #define Z8536_CT_MODE_REB               BIT(2)  /* Retrigger Enable Bit */
108 #define Z8536_CT_MODE_DCS_PULSE         (0 << 0)/* Duty Cycle - Pulse */
109 #define Z8536_CT_MODE_DCS_ONESHOT       (1 << 0)/* Duty Cycle - One-Shot */
110 #define Z8536_CT_MODE_DCS_SQRWAVE       (2 << 0)/* Duty Cycle - Square Wave */
111 #define Z8536_CT_MODE_DCS_DO_NOT_USE    (3 << 0)/* Duty Cycle - Do Not Use */
112 #define Z8536_CT_MODE_DCS_MASK          (3 << 0)/* Duty Cycle mask */
113
114 /* Port A/B Mode Specification registers */
115 #define Z8536_PA_MODE_REG               0x20
116 #define Z8536_PB_MODE_REG               0x28
117 #define Z8536_PAB_MODE_PTS_BIT          (0 << 6)/* Bit Port */
118 #define Z8536_PAB_MODE_PTS_INPUT        (1 << 6)/* Input Port */
119 #define Z8536_PAB_MODE_PTS_OUTPUT       (2 << 6)/* Output Port */
120 #define Z8536_PAB_MODE_PTS_BIDIR        (3 << 6)/* Bidirectional Port */
121 #define Z8536_PAB_MODE_PTS_MASK         (3 << 6)/* Port Type Select mask */
122 #define Z8536_PAB_MODE_ITB              BIT(5)  /* Interrupt on Two Bytes */
123 #define Z8536_PAB_MODE_SB               BIT(4)  /* Single Buffered mode */
124 #define Z8536_PAB_MODE_IMO              BIT(3)  /* Interrupt on Match Only */
125 #define Z8536_PAB_MODE_PMS_DISABLE      (0 << 1)/* Disable Pattern Match */
126 #define Z8536_PAB_MODE_PMS_AND          (1 << 1)/* "AND" mode */
127 #define Z8536_PAB_MODE_PMS_OR           (2 << 1)/* "OR" mode */
128 #define Z8536_PAB_MODE_PMS_OR_PEV       (3 << 1)/* "OR-Priority" mode */
129 #define Z8536_PAB_MODE_PMS_MASK         (3 << 1)/* Pattern Mode mask */
130 #define Z8536_PAB_MODE_LPM              BIT(0)  /* Latch on Pattern Match */
131 #define Z8536_PAB_MODE_DTE              BIT(0)  /* Deskew Timer Enabled */
132
133 /* Port A/B Handshake Specification registers */
134 #define Z8536_PA_HANDSHAKE_REG          0x21
135 #define Z8536_PB_HANDSHAKE_REG          0x29
136 #define Z8536_PAB_HANDSHAKE_HST_INTER   (0 << 6)/* Interlocked Handshake */
137 #define Z8536_PAB_HANDSHAKE_HST_STROBED (1 << 6)/* Strobed Handshake */
138 #define Z8536_PAB_HANDSHAKE_HST_PULSED  (2 << 6)/* Pulsed Handshake */
139 #define Z8536_PAB_HANDSHAKE_HST_3WIRE   (3 << 6)/* Three-Wire Handshake */
140 #define Z8536_PAB_HANDSHAKE_HST_MASK    (3 << 6)/* Handshake Type mask */
141 #define Z8536_PAB_HANDSHAKE_RWS_DISABLE (0 << 3)/* Req/Wait Disabled */
142 #define Z8536_PAB_HANDSHAKE_RWS_OUTWAIT (1 << 3)/* Output Wait */
143 #define Z8536_PAB_HANDSHAKE_RWS_INWAIT  (3 << 3)/* Input Wait */
144 #define Z8536_PAB_HANDSHAKE_RWS_SPREQ   (4 << 3)/* Special Request */
145 #define Z8536_PAB_HANDSHAKE_RWS_OUTREQ  (5 << 4)/* Output Request */
146 #define Z8536_PAB_HANDSHAKE_RWS_INREQ   (7 << 3)/* Input Request */
147 #define Z8536_PAB_HANDSHAKE_RWS_MASK    (7 << 3)/* Req/Wait mask */
148 #define Z8536_PAB_HANDSHAKE_DESKEW(x)   ((x) << 0)/* Deskew Time */
149 #define Z8536_PAB_HANDSHAKE_DESKEW_MASK (3 << 0)/* Deskew Time mask */
150
151 /*
152  * Port A/B/C Data Path Polarity registers
153  *
154  *      0 = Non-Inverting
155  *      1 = Inverting
156  */
157 #define Z8536_PA_DPP_REG                0x22
158 #define Z8536_PB_DPP_REG                0x2a
159 #define Z8536_PC_DPP_REG                0x05
160
161 /*
162  * Port A/B/C Data Direction registers
163  *
164  *      0 = Output bit
165  *      1 = Input bit
166  */
167 #define Z8536_PA_DD_REG                 0x23
168 #define Z8536_PB_DD_REG                 0x2b
169 #define Z8536_PC_DD_REG                 0x06
170
171 /*
172  * Port A/B/C Special I/O Control registers
173  *
174  *      0 = Normal Input or Output
175  *      1 = Output with open drain or Input with 1's catcher
176  */
177 #define Z8536_PA_SIO_REG                0x24
178 #define Z8536_PB_SIO_REG                0x2c
179 #define Z8536_PC_SIO_REG                0x07
180
181 /*
182  * Port A/B Pattern Polarity/Transition/Mask registers
183  *
184  *      PM PT PP  Pattern Specification
185  *      -- -- --  -------------------------------------
186  *       0  0  x  Bit masked off
187  *       0  1  x  Any transition
188  *       1  0  0  Zero (low-level)
189  *       1  0  1  One (high-level)
190  *       1  1  0  One-to-zero transition (falling-edge)
191  *       1  1  1  Zero-to-one transition (rising-edge)
192  */
193 #define Z8536_PA_PP_REG                 0x25
194 #define Z8536_PB_PP_REG                 0x2d
195
196 #define Z8536_PA_PT_REG                 0x26
197 #define Z8536_PB_PT_REG                 0x2e
198
199 #define Z8536_PA_PM_REG                 0x27
200 #define Z8536_PB_PM_REG                 0x2f
201
202 #endif  /* _Z8536_H */