blob: f2656ebba08489a0d7f229173a842fb3207a4bbc [file] [log] [blame]
Sergei Shtylyovc1566332015-06-11 01:01:43 +03001/* Renesas Ethernet AVB device driver
2 *
3 * Copyright (C) 2014-2015 Renesas Electronics Corporation
4 * Copyright (C) 2015 Renesas Solutions Corp.
5 * Copyright (C) 2015 Cogent Embedded, Inc. <source@cogentembedded.com>
6 *
7 * Based on the SuperH Ethernet driver
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms and conditions of the GNU General Public License version 2,
11 * as published by the Free Software Foundation.
12 */
13
14#ifndef __RAVB_H__
15#define __RAVB_H__
16
17#include <linux/interrupt.h>
18#include <linux/io.h>
19#include <linux/kernel.h>
20#include <linux/mdio-bitbang.h>
21#include <linux/netdevice.h>
22#include <linux/phy.h>
23
24#define BE_TX_RING_SIZE 64 /* TX ring size for Best Effort */
25#define BE_RX_RING_SIZE 1024 /* RX ring size for Best Effort */
26#define NC_TX_RING_SIZE 64 /* TX ring size for Network Control */
27#define NC_RX_RING_SIZE 64 /* RX ring size for Network Control */
28#define BE_TX_RING_MIN 64
29#define BE_RX_RING_MIN 64
30#define BE_TX_RING_MAX 1024
31#define BE_RX_RING_MAX 2048
32
33#define PKT_BUF_SZ 1538
34
35/* Driver's parameters */
36#define RAVB_ALIGN 128
37
38/* Hardware time stamp */
39#define RAVB_TXTSTAMP_VALID 0x00000001 /* TX timestamp valid */
40#define RAVB_TXTSTAMP_ENABLED 0x00000010 /* Enable TX timestamping */
41
42#define RAVB_RXTSTAMP_VALID 0x00000001 /* RX timestamp valid */
43#define RAVB_RXTSTAMP_TYPE 0x00000006 /* RX type mask */
44#define RAVB_RXTSTAMP_TYPE_V2_L2_EVENT 0x00000002
45#define RAVB_RXTSTAMP_TYPE_ALL 0x00000006
46#define RAVB_RXTSTAMP_ENABLED 0x00000010 /* Enable RX timestamping */
47
48enum ravb_reg {
49 /* AVB-DMAC registers */
50 CCC = 0x0000,
51 DBAT = 0x0004,
52 DLR = 0x0008,
53 CSR = 0x000C,
54 CDAR0 = 0x0010,
55 CDAR1 = 0x0014,
56 CDAR2 = 0x0018,
57 CDAR3 = 0x001C,
58 CDAR4 = 0x0020,
59 CDAR5 = 0x0024,
60 CDAR6 = 0x0028,
61 CDAR7 = 0x002C,
62 CDAR8 = 0x0030,
63 CDAR9 = 0x0034,
64 CDAR10 = 0x0038,
65 CDAR11 = 0x003C,
66 CDAR12 = 0x0040,
67 CDAR13 = 0x0044,
68 CDAR14 = 0x0048,
69 CDAR15 = 0x004C,
70 CDAR16 = 0x0050,
71 CDAR17 = 0x0054,
72 CDAR18 = 0x0058,
73 CDAR19 = 0x005C,
74 CDAR20 = 0x0060,
75 CDAR21 = 0x0064,
76 ESR = 0x0088,
77 RCR = 0x0090,
78 RQC0 = 0x0094,
79 RQC1 = 0x0098,
80 RQC2 = 0x009C,
81 RQC3 = 0x00A0,
82 RQC4 = 0x00A4,
83 RPC = 0x00B0,
84 UFCW = 0x00BC,
85 UFCS = 0x00C0,
86 UFCV0 = 0x00C4,
87 UFCV1 = 0x00C8,
88 UFCV2 = 0x00CC,
89 UFCV3 = 0x00D0,
90 UFCV4 = 0x00D4,
91 UFCD0 = 0x00E0,
92 UFCD1 = 0x00E4,
93 UFCD2 = 0x00E8,
94 UFCD3 = 0x00EC,
95 UFCD4 = 0x00F0,
96 SFO = 0x00FC,
97 SFP0 = 0x0100,
98 SFP1 = 0x0104,
99 SFP2 = 0x0108,
100 SFP3 = 0x010C,
101 SFP4 = 0x0110,
102 SFP5 = 0x0114,
103 SFP6 = 0x0118,
104 SFP7 = 0x011C,
105 SFP8 = 0x0120,
106 SFP9 = 0x0124,
107 SFP10 = 0x0128,
108 SFP11 = 0x012C,
109 SFP12 = 0x0130,
110 SFP13 = 0x0134,
111 SFP14 = 0x0138,
112 SFP15 = 0x013C,
113 SFP16 = 0x0140,
114 SFP17 = 0x0144,
115 SFP18 = 0x0148,
116 SFP19 = 0x014C,
117 SFP20 = 0x0150,
118 SFP21 = 0x0154,
119 SFP22 = 0x0158,
120 SFP23 = 0x015C,
121 SFP24 = 0x0160,
122 SFP25 = 0x0164,
123 SFP26 = 0x0168,
124 SFP27 = 0x016C,
125 SFP28 = 0x0170,
126 SFP29 = 0x0174,
127 SFP30 = 0x0178,
128 SFP31 = 0x017C,
129 SFM0 = 0x01C0,
130 SFM1 = 0x01C4,
131 TGC = 0x0300,
132 TCCR = 0x0304,
133 TSR = 0x0308,
134 TFA0 = 0x0310,
135 TFA1 = 0x0314,
136 TFA2 = 0x0318,
137 CIVR0 = 0x0320,
138 CIVR1 = 0x0324,
139 CDVR0 = 0x0328,
140 CDVR1 = 0x032C,
141 CUL0 = 0x0330,
142 CUL1 = 0x0334,
143 CLL0 = 0x0338,
144 CLL1 = 0x033C,
145 DIC = 0x0350,
146 DIS = 0x0354,
147 EIC = 0x0358,
148 EIS = 0x035C,
149 RIC0 = 0x0360,
150 RIS0 = 0x0364,
151 RIC1 = 0x0368,
152 RIS1 = 0x036C,
153 RIC2 = 0x0370,
154 RIS2 = 0x0374,
155 TIC = 0x0378,
156 TIS = 0x037C,
157 ISS = 0x0380,
158 GCCR = 0x0390,
159 GMTT = 0x0394,
160 GPTC = 0x0398,
161 GTI = 0x039C,
162 GTO0 = 0x03A0,
163 GTO1 = 0x03A4,
164 GTO2 = 0x03A8,
165 GIC = 0x03AC,
166 GIS = 0x03B0,
167 GCPT = 0x03B4, /* Undocumented? */
168 GCT0 = 0x03B8,
169 GCT1 = 0x03BC,
170 GCT2 = 0x03C0,
171
172 /* E-MAC registers */
173 ECMR = 0x0500,
174 RFLR = 0x0508,
175 ECSR = 0x0510,
176 ECSIPR = 0x0518,
177 PIR = 0x0520,
178 PSR = 0x0528,
179 PIPR = 0x052c,
180 MPR = 0x0558,
181 PFTCR = 0x055c,
182 PFRCR = 0x0560,
183 GECMR = 0x05b0,
184 MAHR = 0x05c0,
185 MALR = 0x05c8,
186 TROCR = 0x0700, /* Undocumented? */
187 CDCR = 0x0708, /* Undocumented? */
188 LCCR = 0x0710, /* Undocumented? */
189 CEFCR = 0x0740,
190 FRECR = 0x0748,
191 TSFRCR = 0x0750,
192 TLFRCR = 0x0758,
193 RFCR = 0x0760,
194 CERCR = 0x0768, /* Undocumented? */
195 CEECR = 0x0770, /* Undocumented? */
196 MAFCR = 0x0778,
197};
198
199
200/* Register bits of the Ethernet AVB */
201/* CCC */
202enum CCC_BIT {
203 CCC_OPC = 0x00000003,
204 CCC_OPC_RESET = 0x00000000,
205 CCC_OPC_CONFIG = 0x00000001,
206 CCC_OPC_OPERATION = 0x00000002,
207 CCC_DTSR = 0x00000100,
208 CCC_CSEL = 0x00030000,
209 CCC_CSEL_HPB = 0x00010000,
210 CCC_CSEL_ETH_TX = 0x00020000,
211 CCC_CSEL_GMII_REF = 0x00030000,
212 CCC_BOC = 0x00100000, /* Undocumented? */
213 CCC_LBME = 0x01000000,
214};
215
216/* CSR */
217enum CSR_BIT {
218 CSR_OPS = 0x0000000F,
219 CSR_OPS_RESET = 0x00000001,
220 CSR_OPS_CONFIG = 0x00000002,
221 CSR_OPS_OPERATION = 0x00000004,
222 CSR_OPS_STANDBY = 0x00000008, /* Undocumented? */
223 CSR_DTS = 0x00000100,
224 CSR_TPO0 = 0x00010000,
225 CSR_TPO1 = 0x00020000,
226 CSR_TPO2 = 0x00040000,
227 CSR_TPO3 = 0x00080000,
228 CSR_RPO = 0x00100000,
229};
230
231/* ESR */
232enum ESR_BIT {
233 ESR_EQN = 0x0000001F,
234 ESR_ET = 0x00000F00,
235 ESR_EIL = 0x00001000,
236};
237
238/* RCR */
239enum RCR_BIT {
240 RCR_EFFS = 0x00000001,
241 RCR_ENCF = 0x00000002,
242 RCR_ESF = 0x0000000C,
243 RCR_ETS0 = 0x00000010,
244 RCR_ETS2 = 0x00000020,
245 RCR_RFCL = 0x1FFF0000,
246};
247
248/* RQC0/1/2/3/4 */
249enum RQC_BIT {
250 RQC_RSM0 = 0x00000003,
251 RQC_UFCC0 = 0x00000030,
252 RQC_RSM1 = 0x00000300,
253 RQC_UFCC1 = 0x00003000,
254 RQC_RSM2 = 0x00030000,
255 RQC_UFCC2 = 0x00300000,
256 RQC_RSM3 = 0x03000000,
257 RQC_UFCC3 = 0x30000000,
258};
259
260/* RPC */
261enum RPC_BIT {
262 RPC_PCNT = 0x00000700,
263 RPC_DCNT = 0x00FF0000,
264};
265
266/* UFCW */
267enum UFCW_BIT {
268 UFCW_WL0 = 0x0000003F,
269 UFCW_WL1 = 0x00003F00,
270 UFCW_WL2 = 0x003F0000,
271 UFCW_WL3 = 0x3F000000,
272};
273
274/* UFCS */
275enum UFCS_BIT {
276 UFCS_SL0 = 0x0000003F,
277 UFCS_SL1 = 0x00003F00,
278 UFCS_SL2 = 0x003F0000,
279 UFCS_SL3 = 0x3F000000,
280};
281
282/* UFCV0/1/2/3/4 */
283enum UFCV_BIT {
284 UFCV_CV0 = 0x0000003F,
285 UFCV_CV1 = 0x00003F00,
286 UFCV_CV2 = 0x003F0000,
287 UFCV_CV3 = 0x3F000000,
288};
289
290/* UFCD0/1/2/3/4 */
291enum UFCD_BIT {
292 UFCD_DV0 = 0x0000003F,
293 UFCD_DV1 = 0x00003F00,
294 UFCD_DV2 = 0x003F0000,
295 UFCD_DV3 = 0x3F000000,
296};
297
298/* SFO */
299enum SFO_BIT {
300 SFO_FPB = 0x0000003F,
301};
302
303/* RTC */
304enum RTC_BIT {
305 RTC_MFL0 = 0x00000FFF,
306 RTC_MFL1 = 0x0FFF0000,
307};
308
309/* TGC */
310enum TGC_BIT {
311 TGC_TSM0 = 0x00000001,
312 TGC_TSM1 = 0x00000002,
313 TGC_TSM2 = 0x00000004,
314 TGC_TSM3 = 0x00000008,
315 TGC_TQP = 0x00000030,
316 TGC_TQP_NONAVB = 0x00000000,
317 TGC_TQP_AVBMODE1 = 0x00000010,
318 TGC_TQP_AVBMODE2 = 0x00000030,
319 TGC_TBD0 = 0x00000300,
320 TGC_TBD1 = 0x00003000,
321 TGC_TBD2 = 0x00030000,
322 TGC_TBD3 = 0x00300000,
323};
324
325/* TCCR */
326enum TCCR_BIT {
327 TCCR_TSRQ0 = 0x00000001,
328 TCCR_TSRQ1 = 0x00000002,
329 TCCR_TSRQ2 = 0x00000004,
330 TCCR_TSRQ3 = 0x00000008,
331 TCCR_TFEN = 0x00000100,
332 TCCR_TFR = 0x00000200,
333};
334
335/* TSR */
336enum TSR_BIT {
337 TSR_CCS0 = 0x00000003,
338 TSR_CCS1 = 0x0000000C,
339 TSR_TFFL = 0x00000700,
340};
341
342/* TFA2 */
343enum TFA2_BIT {
344 TFA2_TSV = 0x0000FFFF,
345 TFA2_TST = 0x03FF0000,
346};
347
348/* DIC */
349enum DIC_BIT {
350 DIC_DPE1 = 0x00000002,
351 DIC_DPE2 = 0x00000004,
352 DIC_DPE3 = 0x00000008,
353 DIC_DPE4 = 0x00000010,
354 DIC_DPE5 = 0x00000020,
355 DIC_DPE6 = 0x00000040,
356 DIC_DPE7 = 0x00000080,
357 DIC_DPE8 = 0x00000100,
358 DIC_DPE9 = 0x00000200,
359 DIC_DPE10 = 0x00000400,
360 DIC_DPE11 = 0x00000800,
361 DIC_DPE12 = 0x00001000,
362 DIC_DPE13 = 0x00002000,
363 DIC_DPE14 = 0x00004000,
364 DIC_DPE15 = 0x00008000,
365};
366
367/* DIS */
368enum DIS_BIT {
369 DIS_DPF1 = 0x00000002,
370 DIS_DPF2 = 0x00000004,
371 DIS_DPF3 = 0x00000008,
372 DIS_DPF4 = 0x00000010,
373 DIS_DPF5 = 0x00000020,
374 DIS_DPF6 = 0x00000040,
375 DIS_DPF7 = 0x00000080,
376 DIS_DPF8 = 0x00000100,
377 DIS_DPF9 = 0x00000200,
378 DIS_DPF10 = 0x00000400,
379 DIS_DPF11 = 0x00000800,
380 DIS_DPF12 = 0x00001000,
381 DIS_DPF13 = 0x00002000,
382 DIS_DPF14 = 0x00004000,
383 DIS_DPF15 = 0x00008000,
384};
385
386/* EIC */
387enum EIC_BIT {
388 EIC_MREE = 0x00000001,
389 EIC_MTEE = 0x00000002,
390 EIC_QEE = 0x00000004,
391 EIC_SEE = 0x00000008,
392 EIC_CLLE0 = 0x00000010,
393 EIC_CLLE1 = 0x00000020,
394 EIC_CULE0 = 0x00000040,
395 EIC_CULE1 = 0x00000080,
396 EIC_TFFE = 0x00000100,
397};
398
399/* EIS */
400enum EIS_BIT {
401 EIS_MREF = 0x00000001,
402 EIS_MTEF = 0x00000002,
403 EIS_QEF = 0x00000004,
404 EIS_SEF = 0x00000008,
405 EIS_CLLF0 = 0x00000010,
406 EIS_CLLF1 = 0x00000020,
407 EIS_CULF0 = 0x00000040,
408 EIS_CULF1 = 0x00000080,
409 EIS_TFFF = 0x00000100,
410 EIS_QFS = 0x00010000,
411};
412
413/* RIC0 */
414enum RIC0_BIT {
415 RIC0_FRE0 = 0x00000001,
416 RIC0_FRE1 = 0x00000002,
417 RIC0_FRE2 = 0x00000004,
418 RIC0_FRE3 = 0x00000008,
419 RIC0_FRE4 = 0x00000010,
420 RIC0_FRE5 = 0x00000020,
421 RIC0_FRE6 = 0x00000040,
422 RIC0_FRE7 = 0x00000080,
423 RIC0_FRE8 = 0x00000100,
424 RIC0_FRE9 = 0x00000200,
425 RIC0_FRE10 = 0x00000400,
426 RIC0_FRE11 = 0x00000800,
427 RIC0_FRE12 = 0x00001000,
428 RIC0_FRE13 = 0x00002000,
429 RIC0_FRE14 = 0x00004000,
430 RIC0_FRE15 = 0x00008000,
431 RIC0_FRE16 = 0x00010000,
432 RIC0_FRE17 = 0x00020000,
433};
434
435/* RIC0 */
436enum RIS0_BIT {
437 RIS0_FRF0 = 0x00000001,
438 RIS0_FRF1 = 0x00000002,
439 RIS0_FRF2 = 0x00000004,
440 RIS0_FRF3 = 0x00000008,
441 RIS0_FRF4 = 0x00000010,
442 RIS0_FRF5 = 0x00000020,
443 RIS0_FRF6 = 0x00000040,
444 RIS0_FRF7 = 0x00000080,
445 RIS0_FRF8 = 0x00000100,
446 RIS0_FRF9 = 0x00000200,
447 RIS0_FRF10 = 0x00000400,
448 RIS0_FRF11 = 0x00000800,
449 RIS0_FRF12 = 0x00001000,
450 RIS0_FRF13 = 0x00002000,
451 RIS0_FRF14 = 0x00004000,
452 RIS0_FRF15 = 0x00008000,
453 RIS0_FRF16 = 0x00010000,
454 RIS0_FRF17 = 0x00020000,
455};
456
457/* RIC1 */
458enum RIC1_BIT {
459 RIC1_RFWE = 0x80000000,
460};
461
462/* RIS1 */
463enum RIS1_BIT {
464 RIS1_RFWF = 0x80000000,
465};
466
467/* RIC2 */
468enum RIC2_BIT {
469 RIC2_QFE0 = 0x00000001,
470 RIC2_QFE1 = 0x00000002,
471 RIC2_QFE2 = 0x00000004,
472 RIC2_QFE3 = 0x00000008,
473 RIC2_QFE4 = 0x00000010,
474 RIC2_QFE5 = 0x00000020,
475 RIC2_QFE6 = 0x00000040,
476 RIC2_QFE7 = 0x00000080,
477 RIC2_QFE8 = 0x00000100,
478 RIC2_QFE9 = 0x00000200,
479 RIC2_QFE10 = 0x00000400,
480 RIC2_QFE11 = 0x00000800,
481 RIC2_QFE12 = 0x00001000,
482 RIC2_QFE13 = 0x00002000,
483 RIC2_QFE14 = 0x00004000,
484 RIC2_QFE15 = 0x00008000,
485 RIC2_QFE16 = 0x00010000,
486 RIC2_QFE17 = 0x00020000,
487 RIC2_RFFE = 0x80000000,
488};
489
490/* RIS2 */
491enum RIS2_BIT {
492 RIS2_QFF0 = 0x00000001,
493 RIS2_QFF1 = 0x00000002,
494 RIS2_QFF2 = 0x00000004,
495 RIS2_QFF3 = 0x00000008,
496 RIS2_QFF4 = 0x00000010,
497 RIS2_QFF5 = 0x00000020,
498 RIS2_QFF6 = 0x00000040,
499 RIS2_QFF7 = 0x00000080,
500 RIS2_QFF8 = 0x00000100,
501 RIS2_QFF9 = 0x00000200,
502 RIS2_QFF10 = 0x00000400,
503 RIS2_QFF11 = 0x00000800,
504 RIS2_QFF12 = 0x00001000,
505 RIS2_QFF13 = 0x00002000,
506 RIS2_QFF14 = 0x00004000,
507 RIS2_QFF15 = 0x00008000,
508 RIS2_QFF16 = 0x00010000,
509 RIS2_QFF17 = 0x00020000,
510 RIS2_RFFF = 0x80000000,
511};
512
513/* TIC */
514enum TIC_BIT {
515 TIC_FTE0 = 0x00000001, /* Undocumented? */
516 TIC_FTE1 = 0x00000002, /* Undocumented? */
517 TIC_TFUE = 0x00000100,
518 TIC_TFWE = 0x00000200,
519};
520
521/* TIS */
522enum TIS_BIT {
523 TIS_FTF0 = 0x00000001, /* Undocumented? */
524 TIS_FTF1 = 0x00000002, /* Undocumented? */
525 TIS_TFUF = 0x00000100,
526 TIS_TFWF = 0x00000200,
527};
528
529/* ISS */
530enum ISS_BIT {
531 ISS_FRS = 0x00000001, /* Undocumented? */
532 ISS_FTS = 0x00000004, /* Undocumented? */
533 ISS_ES = 0x00000040,
534 ISS_MS = 0x00000080,
535 ISS_TFUS = 0x00000100,
536 ISS_TFWS = 0x00000200,
537 ISS_RFWS = 0x00001000,
538 ISS_CGIS = 0x00002000,
539 ISS_DPS1 = 0x00020000,
540 ISS_DPS2 = 0x00040000,
541 ISS_DPS3 = 0x00080000,
542 ISS_DPS4 = 0x00100000,
543 ISS_DPS5 = 0x00200000,
544 ISS_DPS6 = 0x00400000,
545 ISS_DPS7 = 0x00800000,
546 ISS_DPS8 = 0x01000000,
547 ISS_DPS9 = 0x02000000,
548 ISS_DPS10 = 0x04000000,
549 ISS_DPS11 = 0x08000000,
550 ISS_DPS12 = 0x10000000,
551 ISS_DPS13 = 0x20000000,
552 ISS_DPS14 = 0x40000000,
553 ISS_DPS15 = 0x80000000,
554};
555
556/* GCCR */
557enum GCCR_BIT {
558 GCCR_TCR = 0x00000003,
559 GCCR_TCR_NOREQ = 0x00000000, /* No request */
560 GCCR_TCR_RESET = 0x00000001, /* gPTP/AVTP presentation timer reset */
561 GCCR_TCR_CAPTURE = 0x00000003, /* Capture value set in GCCR.TCSS */
562 GCCR_LTO = 0x00000004,
563 GCCR_LTI = 0x00000008,
564 GCCR_LPTC = 0x00000010,
565 GCCR_LMTT = 0x00000020,
566 GCCR_TCSS = 0x00000300,
567 GCCR_TCSS_GPTP = 0x00000000, /* gPTP timer value */
568 GCCR_TCSS_ADJGPTP = 0x00000100, /* Adjusted gPTP timer value */
569 GCCR_TCSS_AVTP = 0x00000200, /* AVTP presentation time value */
570};
571
572/* GTI */
573enum GTI_BIT {
574 GTI_TIV = 0x0FFFFFFF,
575};
576
577/* GIC */
578enum GIC_BIT {
579 GIC_PTCE = 0x00000001, /* Undocumented? */
580 GIC_PTME = 0x00000004,
581};
582
583/* GIS */
584enum GIS_BIT {
585 GIS_PTCF = 0x00000001, /* Undocumented? */
586 GIS_PTMF = 0x00000004,
587};
588
589/* ECMR */
590enum ECMR_BIT {
591 ECMR_PRM = 0x00000001,
592 ECMR_DM = 0x00000002,
593 ECMR_TE = 0x00000020,
594 ECMR_RE = 0x00000040,
595 ECMR_MPDE = 0x00000200,
596 ECMR_TXF = 0x00010000, /* Undocumented? */
597 ECMR_RXF = 0x00020000,
598 ECMR_PFR = 0x00040000,
599 ECMR_ZPF = 0x00080000, /* Undocumented? */
600 ECMR_RZPF = 0x00100000,
601 ECMR_DPAD = 0x00200000,
602 ECMR_RCSC = 0x00800000,
603 ECMR_TRCCM = 0x04000000,
604};
605
606/* ECSR */
607enum ECSR_BIT {
608 ECSR_ICD = 0x00000001,
609 ECSR_MPD = 0x00000002,
610 ECSR_LCHNG = 0x00000004,
611 ECSR_PHYI = 0x00000008,
612};
613
614/* ECSIPR */
615enum ECSIPR_BIT {
616 ECSIPR_ICDIP = 0x00000001,
617 ECSIPR_MPDIP = 0x00000002,
618 ECSIPR_LCHNGIP = 0x00000004, /* Undocumented? */
619};
620
621/* PIR */
622enum PIR_BIT {
623 PIR_MDC = 0x00000001,
624 PIR_MMD = 0x00000002,
625 PIR_MDO = 0x00000004,
626 PIR_MDI = 0x00000008,
627};
628
629/* PSR */
630enum PSR_BIT {
631 PSR_LMON = 0x00000001,
632};
633
634/* PIPR */
635enum PIPR_BIT {
636 PIPR_PHYIP = 0x00000001,
637};
638
639/* MPR */
640enum MPR_BIT {
641 MPR_MP = 0x0000ffff,
642};
643
644/* GECMR */
645enum GECMR_BIT {
646 GECMR_SPEED = 0x00000001,
647 GECMR_SPEED_100 = 0x00000000,
648 GECMR_SPEED_1000 = 0x00000001,
649};
650
651/* The Ethernet AVB descriptor definitions. */
652struct ravb_desc {
653 __le16 ds; /* Descriptor size */
654 u8 cc; /* Content control MSBs (reserved) */
655 u8 die_dt; /* Descriptor interrupt enable and type */
656 __le32 dptr; /* Descriptor pointer */
657};
658
659enum DIE_DT {
660 /* Frame data */
661 DT_FMID = 0x40,
662 DT_FSTART = 0x50,
663 DT_FEND = 0x60,
664 DT_FSINGLE = 0x70,
665 /* Chain control */
666 DT_LINK = 0x80,
667 DT_LINKFIX = 0x90,
668 DT_EOS = 0xa0,
669 /* HW/SW arbitration */
670 DT_FEMPTY = 0xc0,
671 DT_FEMPTY_IS = 0xd0,
672 DT_FEMPTY_IC = 0xe0,
673 DT_FEMPTY_ND = 0xf0,
674 DT_LEMPTY = 0x20,
675 DT_EEMPTY = 0x30,
676};
677
678struct ravb_rx_desc {
679 __le16 ds_cc; /* Descriptor size and content control LSBs */
680 u8 msc; /* MAC status code */
681 u8 die_dt; /* Descriptor interrupt enable and type */
682 __le32 dptr; /* Descpriptor pointer */
683};
684
685struct ravb_ex_rx_desc {
686 __le16 ds_cc; /* Descriptor size and content control lower bits */
687 u8 msc; /* MAC status code */
688 u8 die_dt; /* Descriptor interrupt enable and type */
689 __le32 dptr; /* Descpriptor pointer */
690 __le32 ts_n; /* Timestampe nsec */
691 __le32 ts_sl; /* Timestamp low */
692 __le16 ts_sh; /* Timestamp high */
693 __le16 res; /* Reserved bits */
694};
695
696enum RX_DS_CC_BIT {
697 RX_DS = 0x0fff, /* Data size */
698 RX_TR = 0x1000, /* Truncation indication */
699 RX_EI = 0x2000, /* Error indication */
700 RX_PS = 0xc000, /* Padding selection */
701};
702
703/* E-MAC status code */
704enum MSC_BIT {
705 MSC_CRC = 0x01, /* Frame CRC error */
706 MSC_RFE = 0x02, /* Frame reception error (flagged by PHY) */
707 MSC_RTSF = 0x04, /* Frame length error (frame too short) */
708 MSC_RTLF = 0x08, /* Frame length error (frame too long) */
709 MSC_FRE = 0x10, /* Fraction error (not a multiple of 8 bits) */
710 MSC_CRL = 0x20, /* Carrier lost */
711 MSC_CEEF = 0x40, /* Carrier extension error */
712 MSC_MC = 0x80, /* Multicast frame reception */
713};
714
715struct ravb_tx_desc {
716 __le16 ds_tagl; /* Descriptor size and frame tag LSBs */
717 u8 tagh_tsr; /* Frame tag MSBs and timestamp storage request bit */
718 u8 die_dt; /* Descriptor interrupt enable and type */
719 __le32 dptr; /* Descpriptor pointer */
720};
721
722enum TX_DS_TAGL_BIT {
723 TX_DS = 0x0fff, /* Data size */
724 TX_TAGL = 0xf000, /* Frame tag LSBs */
725};
726
727enum TX_TAGH_TSR_BIT {
728 TX_TAGH = 0x3f, /* Frame tag MSBs */
729 TX_TSR = 0x40, /* Timestamp storage request */
730};
731enum RAVB_QUEUE {
732 RAVB_BE = 0, /* Best Effort Queue */
733 RAVB_NC, /* Network Control Queue */
734};
735
736#define DBAT_ENTRY_NUM 22
737#define RX_QUEUE_OFFSET 4
738#define NUM_RX_QUEUE 2
739#define NUM_TX_QUEUE 2
740
741struct ravb_tstamp_skb {
742 struct list_head list;
743 struct sk_buff *skb;
744 u16 tag;
745};
746
747struct ravb_private {
748 struct net_device *ndev;
749 struct platform_device *pdev;
750 void __iomem *addr;
751 struct mdiobb_ctrl mdiobb;
752 u32 num_rx_ring[NUM_RX_QUEUE];
753 u32 num_tx_ring[NUM_TX_QUEUE];
754 u32 desc_bat_size;
755 dma_addr_t desc_bat_dma;
756 struct ravb_desc *desc_bat;
757 dma_addr_t rx_desc_dma[NUM_RX_QUEUE];
758 dma_addr_t tx_desc_dma[NUM_TX_QUEUE];
759 struct ravb_ex_rx_desc *rx_ring[NUM_RX_QUEUE];
760 struct ravb_tx_desc *tx_ring[NUM_TX_QUEUE];
761 struct sk_buff **rx_skb[NUM_RX_QUEUE];
762 struct sk_buff **tx_skb[NUM_TX_QUEUE];
763 void **tx_buffers[NUM_TX_QUEUE];
764 u32 rx_over_errors;
765 u32 rx_fifo_errors;
766 struct net_device_stats stats[NUM_RX_QUEUE];
767 u32 tstamp_tx_ctrl;
768 u32 tstamp_rx_ctrl;
769 struct list_head ts_skb_list;
770 u32 ts_skb_tag;
771 spinlock_t lock; /* Register access lock */
772 u32 cur_rx[NUM_RX_QUEUE]; /* Consumer ring indices */
773 u32 dirty_rx[NUM_RX_QUEUE]; /* Producer ring indices */
774 u32 cur_tx[NUM_TX_QUEUE];
775 u32 dirty_tx[NUM_TX_QUEUE];
776 struct napi_struct napi[NUM_RX_QUEUE];
777 struct work_struct work;
778 /* MII transceiver section. */
779 struct mii_bus *mii_bus; /* MDIO bus control */
780 struct phy_device *phydev; /* PHY device control */
781 int link;
782 phy_interface_t phy_interface;
783 int msg_enable;
784 int speed;
785 int duplex;
786
787 unsigned no_avb_link:1;
788 unsigned avb_link_active_low:1;
789};
790
791static inline u32 ravb_read(struct net_device *ndev, enum ravb_reg reg)
792{
793 struct ravb_private *priv = netdev_priv(ndev);
794
795 return ioread32(priv->addr + reg);
796}
797
798static inline void ravb_write(struct net_device *ndev, u32 data,
799 enum ravb_reg reg)
800{
801 struct ravb_private *priv = netdev_priv(ndev);
802
803 iowrite32(data, priv->addr + reg);
804}
805
806#endif /* #ifndef __RAVB_H__ */