1
2
3
4
5
6
7
8
9
10
11
12
13
14
15#ifndef __UCC_SLOW_H__
16#define __UCC_SLOW_H__
17
18#include <linux/kernel.h>
19
20#include <soc/fsl/qe/immap_qe.h>
21#include <soc/fsl/qe/qe.h>
22
23#include <soc/fsl/qe/ucc.h>
24
25
26#define T_R 0x80000000
27#define T_PAD 0x40000000
28#define T_W 0x20000000
29#define T_I 0x10000000
30#define T_L 0x08000000
31
32#define T_A 0x04000000
33
34#define T_TC 0x04000000
35#define T_CM 0x02000000
36#define T_DEF 0x02000000
37#define T_P 0x01000000
38
39#define T_HB 0x01000000
40#define T_NS 0x00800000
41#define T_LC 0x00800000
42#define T_RL 0x00400000
43#define T_UN 0x00020000
44#define T_CT 0x00010000
45#define T_CSL 0x00010000
46#define T_RC 0x003c0000
47
48
49#define R_E 0x80000000
50#define R_W 0x20000000
51#define R_I 0x10000000
52#define R_L 0x08000000
53#define R_C 0x08000000
54
55#define R_F 0x04000000
56#define R_A 0x04000000
57
58#define R_CM 0x02000000
59#define R_ID 0x01000000
60#define R_M 0x01000000
61
62#define R_AM 0x00800000
63#define R_DE 0x00800000
64#define R_LG 0x00200000
65#define R_BR 0x00200000
66#define R_NO 0x00100000
67#define R_FR 0x00100000
68
69#define R_PR 0x00080000
70#define R_AB 0x00080000
71#define R_SH 0x00080000
72#define R_CR 0x00040000
73#define R_OV 0x00020000
74#define R_CD 0x00010000
75#define R_CL 0x00010000
76
77
78
79#define UCC_SLOW_RX_ALIGN 4
80#define UCC_SLOW_MRBLR_ALIGNMENT 4
81#define UCC_SLOW_PRAM_SIZE 0x100
82#define ALIGNMENT_OF_UCC_SLOW_PRAM 64
83
84
85enum ucc_slow_channel_protocol_mode {
86 UCC_SLOW_CHANNEL_PROTOCOL_MODE_QMC = 0x00000002,
87 UCC_SLOW_CHANNEL_PROTOCOL_MODE_UART = 0x00000004,
88 UCC_SLOW_CHANNEL_PROTOCOL_MODE_BISYNC = 0x00000008,
89};
90
91
92enum ucc_slow_transparent_tcrc {
93
94 UCC_SLOW_TRANSPARENT_TCRC_CCITT_CRC16 = 0x00000000,
95
96 UCC_SLOW_TRANSPARENT_TCRC_CRC16 = 0x00004000,
97
98 UCC_SLOW_TRANSPARENT_TCRC_CCITT_CRC32 = 0x00008000,
99};
100
101
102enum ucc_slow_tx_oversampling_rate {
103
104 UCC_SLOW_OVERSAMPLING_RATE_TX_TDCR_1 = 0x00000000,
105
106 UCC_SLOW_OVERSAMPLING_RATE_TX_TDCR_8 = 0x00010000,
107
108 UCC_SLOW_OVERSAMPLING_RATE_TX_TDCR_16 = 0x00020000,
109
110 UCC_SLOW_OVERSAMPLING_RATE_TX_TDCR_32 = 0x00030000,
111};
112
113
114
115enum ucc_slow_rx_oversampling_rate {
116
117 UCC_SLOW_OVERSAMPLING_RATE_RX_RDCR_1 = 0x00000000,
118
119 UCC_SLOW_OVERSAMPLING_RATE_RX_RDCR_8 = 0x00004000,
120
121 UCC_SLOW_OVERSAMPLING_RATE_RX_RDCR_16 = 0x00008000,
122
123 UCC_SLOW_OVERSAMPLING_RATE_RX_RDCR_32 = 0x0000c000,
124};
125
126
127
128enum ucc_slow_tx_encoding_method {
129 UCC_SLOW_TRANSMITTER_ENCODING_METHOD_TENC_NRZ = 0x00000000,
130 UCC_SLOW_TRANSMITTER_ENCODING_METHOD_TENC_NRZI = 0x00000100
131};
132
133
134
135enum ucc_slow_rx_decoding_method {
136 UCC_SLOW_RECEIVER_DECODING_METHOD_RENC_NRZ = 0x00000000,
137 UCC_SLOW_RECEIVER_DECODING_METHOD_RENC_NRZI = 0x00000800
138};
139
140
141
142enum ucc_slow_diag_mode {
143 UCC_SLOW_DIAG_MODE_NORMAL = 0x00000000,
144 UCC_SLOW_DIAG_MODE_LOOPBACK = 0x00000040,
145 UCC_SLOW_DIAG_MODE_ECHO = 0x00000080,
146 UCC_SLOW_DIAG_MODE_LOOPBACK_ECHO = 0x000000c0
147};
148
149struct ucc_slow_info {
150 int ucc_num;
151 int protocol;
152 enum qe_clock rx_clock;
153 enum qe_clock tx_clock;
154 phys_addr_t regs;
155 int irq;
156 u16 uccm_mask;
157 int data_mem_part;
158 int init_tx;
159 int init_rx;
160 u32 tx_bd_ring_len;
161 u32 rx_bd_ring_len;
162 int rx_interrupts;
163 int brkpt_support;
164 int grant_support;
165 int tsa;
166 int cdp;
167 int cds;
168 int ctsp;
169 int ctss;
170 int rinv;
171 int tinv;
172 int rtsm;
173 int rfw;
174 int tci;
175 int tend;
176 int tfl;
177 int txsy;
178 u16 max_rx_buf_length;
179 enum ucc_slow_transparent_tcrc tcrc;
180 enum ucc_slow_channel_protocol_mode mode;
181 enum ucc_slow_diag_mode diag;
182 enum ucc_slow_tx_oversampling_rate tdcr;
183 enum ucc_slow_rx_oversampling_rate rdcr;
184 enum ucc_slow_tx_encoding_method tenc;
185 enum ucc_slow_rx_decoding_method renc;
186};
187
188struct ucc_slow_private {
189 struct ucc_slow_info *us_info;
190 struct ucc_slow __iomem *us_regs;
191 struct ucc_slow_pram *us_pram;
192 u32 us_pram_offset;
193 int enabled_tx;
194 int enabled_rx;
195 int stopped_tx;
196
197 int stopped_rx;
198 struct list_head confQ;
199 u32 first_tx_bd_mask;
200
201 u32 tx_base_offset;
202 u32 rx_base_offset;
203 struct qe_bd *confBd;
204 struct qe_bd *tx_bd;
205 struct qe_bd *rx_bd;
206 void *p_rx_frame;
207 u16 *p_ucce;
208
209 u16 *p_uccm;
210 u16 saved_uccm;
211#ifdef STATISTICS
212 u32 tx_frames;
213 u32 rx_frames;
214
215 u32 rx_discarded;
216
217
218#endif
219};
220
221
222
223
224
225
226
227int ucc_slow_init(struct ucc_slow_info * us_info, struct ucc_slow_private ** uccs_ret);
228
229
230
231
232
233
234void ucc_slow_free(struct ucc_slow_private * uccs);
235
236
237
238
239
240
241
242
243void ucc_slow_enable(struct ucc_slow_private * uccs, enum comm_dir mode);
244
245
246
247
248
249
250
251
252void ucc_slow_disable(struct ucc_slow_private * uccs, enum comm_dir mode);
253
254
255
256
257
258
259void ucc_slow_graceful_stop_tx(struct ucc_slow_private * uccs);
260
261
262
263
264
265
266void ucc_slow_stop_tx(struct ucc_slow_private * uccs);
267
268
269
270
271
272
273void ucc_slow_restart_tx(struct ucc_slow_private *uccs);
274
275u32 ucc_slow_get_qe_cr_subblock(int uccs_num);
276
277#endif
278