1
2
3
4
5
6
7
8
9
10 #ifndef __UCC_FAST_H__
11 #define __UCC_FAST_H__
12
13 #include <linux/kernel.h>
14
15 #include <soc/fsl/qe/immap_qe.h>
16 #include <soc/fsl/qe/qe.h>
17
18 #include <soc/fsl/qe/ucc.h>
19
20
21 #define R_E 0x80000000
22 #define R_W 0x20000000
23 #define R_I 0x10000000
24 #define R_L 0x08000000
25 #define R_F 0x04000000
26
27
28 #define T_R 0x80000000
29 #define T_W 0x20000000
30 #define T_I 0x10000000
31 #define T_L 0x08000000
32
33
34 #define R_E_S 0x8000
35 #define R_W_S 0x2000
36 #define R_I_S 0x1000
37 #define R_L_S 0x0800
38 #define R_F_S 0x0400
39 #define R_CM_S 0x0200
40 #define R_LG_S 0x0020
41 #define R_NO_S 0x0010
42 #define R_AB_S 0x0008
43 #define R_CR_S 0x0004
44 #define R_OV_S 0x0002
45 #define R_CD_S 0x0001
46
47
48 #define T_R_S 0x8000
49 #define T_W_S 0x2000
50 #define T_I_S 0x1000
51 #define T_L_S 0x0800
52 #define T_TC_S 0x0400
53 #define T_TM_S 0x0200
54 #define T_UN_S 0x0002
55 #define T_CT_S 0x0001
56
57
58 #define UCC_FAST_RX_ALIGN 4
59 #define UCC_FAST_MRBLR_ALIGNMENT 4
60 #define UCC_FAST_VIRT_FIFO_REGS_ALIGNMENT 8
61
62
63 #define UCC_FAST_URFS_MIN_VAL 0x88
64 #define UCC_FAST_RECEIVE_VIRTUAL_FIFO_SIZE_FUDGE_FACTOR 8
65
66
67 enum ucc_fast_channel_protocol_mode {
68 UCC_FAST_PROTOCOL_MODE_HDLC = 0x00000000,
69 UCC_FAST_PROTOCOL_MODE_RESERVED01 = 0x00000001,
70 UCC_FAST_PROTOCOL_MODE_RESERVED_QMC = 0x00000002,
71 UCC_FAST_PROTOCOL_MODE_RESERVED02 = 0x00000003,
72 UCC_FAST_PROTOCOL_MODE_RESERVED_UART = 0x00000004,
73 UCC_FAST_PROTOCOL_MODE_RESERVED03 = 0x00000005,
74 UCC_FAST_PROTOCOL_MODE_RESERVED_EX_MAC_1 = 0x00000006,
75 UCC_FAST_PROTOCOL_MODE_RESERVED_EX_MAC_2 = 0x00000007,
76 UCC_FAST_PROTOCOL_MODE_RESERVED_BISYNC = 0x00000008,
77 UCC_FAST_PROTOCOL_MODE_RESERVED04 = 0x00000009,
78 UCC_FAST_PROTOCOL_MODE_ATM = 0x0000000A,
79 UCC_FAST_PROTOCOL_MODE_RESERVED05 = 0x0000000B,
80 UCC_FAST_PROTOCOL_MODE_ETHERNET = 0x0000000C,
81 UCC_FAST_PROTOCOL_MODE_RESERVED06 = 0x0000000D,
82 UCC_FAST_PROTOCOL_MODE_POS = 0x0000000E,
83 UCC_FAST_PROTOCOL_MODE_RESERVED07 = 0x0000000F
84 };
85
86
87 enum ucc_fast_transparent_txrx {
88 UCC_FAST_GUMR_TRANSPARENT_TTX_TRX_NORMAL = 0x00000000,
89 UCC_FAST_GUMR_TRANSPARENT_TTX_TRX_TRANSPARENT = 0x18000000
90 };
91
92
93 enum ucc_fast_diag_mode {
94 UCC_FAST_DIAGNOSTIC_NORMAL = 0x0,
95 UCC_FAST_DIAGNOSTIC_LOCAL_LOOP_BACK = 0x40000000,
96 UCC_FAST_DIAGNOSTIC_AUTO_ECHO = 0x80000000,
97 UCC_FAST_DIAGNOSTIC_LOOP_BACK_AND_ECHO = 0xC0000000
98 };
99
100
101 enum ucc_fast_sync_len {
102 UCC_FAST_SYNC_LEN_NOT_USED = 0x0,
103 UCC_FAST_SYNC_LEN_AUTOMATIC = 0x00004000,
104 UCC_FAST_SYNC_LEN_8_BIT = 0x00008000,
105 UCC_FAST_SYNC_LEN_16_BIT = 0x0000C000
106 };
107
108
109 enum ucc_fast_ready_to_send {
110 UCC_FAST_SEND_IDLES_BETWEEN_FRAMES = 0x00000000,
111 UCC_FAST_SEND_FLAGS_BETWEEN_FRAMES = 0x00002000
112 };
113
114
115 enum ucc_fast_rx_decoding_method {
116 UCC_FAST_RX_ENCODING_NRZ = 0x00000000,
117 UCC_FAST_RX_ENCODING_NRZI = 0x00000800,
118 UCC_FAST_RX_ENCODING_RESERVED0 = 0x00001000,
119 UCC_FAST_RX_ENCODING_RESERVED1 = 0x00001800
120 };
121
122
123 enum ucc_fast_tx_encoding_method {
124 UCC_FAST_TX_ENCODING_NRZ = 0x00000000,
125 UCC_FAST_TX_ENCODING_NRZI = 0x00000100,
126 UCC_FAST_TX_ENCODING_RESERVED0 = 0x00000200,
127 UCC_FAST_TX_ENCODING_RESERVED1 = 0x00000300
128 };
129
130
131 enum ucc_fast_transparent_tcrc {
132 UCC_FAST_16_BIT_CRC = 0x00000000,
133 UCC_FAST_CRC_RESERVED0 = 0x00000040,
134 UCC_FAST_32_BIT_CRC = 0x00000080,
135 UCC_FAST_CRC_RESERVED1 = 0x000000C0
136 };
137
138
139 struct ucc_fast_info {
140 int ucc_num;
141 int tdm_num;
142 enum qe_clock rx_clock;
143 enum qe_clock tx_clock;
144 enum qe_clock rx_sync;
145 enum qe_clock tx_sync;
146 resource_size_t regs;
147 int irq;
148 u32 uccm_mask;
149 int bd_mem_part;
150 int brkpt_support;
151 int grant_support;
152 int tsa;
153 int cdp;
154 int cds;
155 int ctsp;
156 int ctss;
157 int tci;
158 int txsy;
159 int rtsm;
160 int revd;
161 int rsyn;
162 u16 max_rx_buf_length;
163 u16 urfs;
164 u16 urfet;
165 u16 urfset;
166 u16 utfs;
167 u16 utfet;
168 u16 utftt;
169 u16 ufpt;
170 enum ucc_fast_channel_protocol_mode mode;
171 enum ucc_fast_transparent_txrx ttx_trx;
172 enum ucc_fast_tx_encoding_method tenc;
173 enum ucc_fast_rx_decoding_method renc;
174 enum ucc_fast_transparent_tcrc tcrc;
175 enum ucc_fast_sync_len synl;
176 };
177
178 struct ucc_fast_private {
179 struct ucc_fast_info *uf_info;
180 struct ucc_fast __iomem *uf_regs;
181 u32 __iomem *p_ucce;
182 u32 __iomem *p_uccm;
183 #ifdef CONFIG_UGETH_TX_ON_DEMAND
184 u16 __iomem *p_utodr;
185 #endif
186 int enabled_tx;
187 int enabled_rx;
188 int stopped_tx;
189
190 int stopped_rx;
191 u32 ucc_fast_tx_virtual_fifo_base_offset;
192
193 u32 ucc_fast_rx_virtual_fifo_base_offset;
194
195 #ifdef STATISTICS
196 u32 tx_frames;
197 u32 rx_frames;
198
199 u32 tx_discarded;
200
201
202 u32 rx_discarded;
203
204
205 #endif
206 u16 mrblr;
207 };
208
209
210
211
212
213
214
215 int ucc_fast_init(struct ucc_fast_info * uf_info, struct ucc_fast_private ** uccf_ret);
216
217
218
219
220
221
222 void ucc_fast_free(struct ucc_fast_private * uccf);
223
224
225
226
227
228
229
230
231 void ucc_fast_enable(struct ucc_fast_private * uccf, enum comm_dir mode);
232
233
234
235
236
237
238
239
240 void ucc_fast_disable(struct ucc_fast_private * uccf, enum comm_dir mode);
241
242
243
244
245
246
247
248 void ucc_fast_irq(struct ucc_fast_private * uccf);
249
250
251
252
253
254
255
256
257
258
259
260
261 void ucc_fast_transmit_on_demand(struct ucc_fast_private * uccf);
262
263 u32 ucc_fast_get_qe_cr_subblock(int uccf_num);
264
265 void ucc_fast_dump_regs(struct ucc_fast_private * uccf);
266
267 #endif