blob: 33a050f85ddfb641e6cd077f090c200fdb880797 [file] [log] [blame]
Haavard Skinnemoen89e57852006-11-09 14:51:17 +01001/*
2 * Atmel MACB Ethernet Controller driver
3 *
4 * Copyright (C) 2004-2006 Atmel Corporation
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10#ifndef _MACB_H
11#define _MACB_H
12
13/* MACB register offsets */
14#define MACB_NCR 0x0000
15#define MACB_NCFGR 0x0004
16#define MACB_NSR 0x0008
Joachim Eastwood1fd3ca4e2012-10-18 11:01:06 +000017#define MACB_TAR 0x000c /* AT91RM9200 only */
18#define MACB_TCR 0x0010 /* AT91RM9200 only */
Haavard Skinnemoen89e57852006-11-09 14:51:17 +010019#define MACB_TSR 0x0014
20#define MACB_RBQP 0x0018
21#define MACB_TBQP 0x001c
22#define MACB_RSR 0x0020
23#define MACB_ISR 0x0024
24#define MACB_IER 0x0028
25#define MACB_IDR 0x002c
26#define MACB_IMR 0x0030
27#define MACB_MAN 0x0034
28#define MACB_PTR 0x0038
29#define MACB_PFR 0x003c
30#define MACB_FTO 0x0040
31#define MACB_SCF 0x0044
32#define MACB_MCF 0x0048
33#define MACB_FRO 0x004c
34#define MACB_FCSE 0x0050
35#define MACB_ALE 0x0054
36#define MACB_DTF 0x0058
37#define MACB_LCOL 0x005c
38#define MACB_EXCOL 0x0060
39#define MACB_TUND 0x0064
40#define MACB_CSE 0x0068
41#define MACB_RRE 0x006c
42#define MACB_ROVR 0x0070
43#define MACB_RSE 0x0074
44#define MACB_ELE 0x0078
45#define MACB_RJA 0x007c
46#define MACB_USF 0x0080
47#define MACB_STE 0x0084
48#define MACB_RLE 0x0088
49#define MACB_TPF 0x008c
50#define MACB_HRB 0x0090
51#define MACB_HRT 0x0094
52#define MACB_SA1B 0x0098
53#define MACB_SA1T 0x009c
54#define MACB_SA2B 0x00a0
55#define MACB_SA2T 0x00a4
56#define MACB_SA3B 0x00a8
57#define MACB_SA3T 0x00ac
58#define MACB_SA4B 0x00b0
59#define MACB_SA4T 0x00b4
60#define MACB_TID 0x00b8
61#define MACB_TPQ 0x00bc
62#define MACB_USRIO 0x00c0
63#define MACB_WOL 0x00c4
Jamie Ilesf75ba502011-11-08 10:12:32 +000064#define MACB_MID 0x00fc
65
66/* GEM register offsets. */
67#define GEM_NCFGR 0x0004
68#define GEM_USRIO 0x000c
Jamie Iles0116da42011-03-14 17:38:30 +000069#define GEM_DMACFG 0x0010
Jamie Ilesf75ba502011-11-08 10:12:32 +000070#define GEM_HRB 0x0080
71#define GEM_HRT 0x0084
72#define GEM_SA1B 0x0088
73#define GEM_SA1T 0x008C
Jamie Ilesa494ed82011-03-09 16:26:35 +000074#define GEM_OTX 0x0100
Jamie Iles757a03c2011-03-09 16:29:59 +000075#define GEM_DCFG1 0x0280
76#define GEM_DCFG2 0x0284
77#define GEM_DCFG3 0x0288
78#define GEM_DCFG4 0x028c
79#define GEM_DCFG5 0x0290
80#define GEM_DCFG6 0x0294
81#define GEM_DCFG7 0x0298
Haavard Skinnemoen89e57852006-11-09 14:51:17 +010082
83/* Bitfields in NCR */
84#define MACB_LB_OFFSET 0
85#define MACB_LB_SIZE 1
86#define MACB_LLB_OFFSET 1
87#define MACB_LLB_SIZE 1
88#define MACB_RE_OFFSET 2
89#define MACB_RE_SIZE 1
90#define MACB_TE_OFFSET 3
91#define MACB_TE_SIZE 1
92#define MACB_MPE_OFFSET 4
93#define MACB_MPE_SIZE 1
94#define MACB_CLRSTAT_OFFSET 5
95#define MACB_CLRSTAT_SIZE 1
96#define MACB_INCSTAT_OFFSET 6
97#define MACB_INCSTAT_SIZE 1
98#define MACB_WESTAT_OFFSET 7
99#define MACB_WESTAT_SIZE 1
100#define MACB_BP_OFFSET 8
101#define MACB_BP_SIZE 1
102#define MACB_TSTART_OFFSET 9
103#define MACB_TSTART_SIZE 1
104#define MACB_THALT_OFFSET 10
105#define MACB_THALT_SIZE 1
106#define MACB_NCR_TPF_OFFSET 11
107#define MACB_NCR_TPF_SIZE 1
108#define MACB_TZQ_OFFSET 12
109#define MACB_TZQ_SIZE 1
110
111/* Bitfields in NCFGR */
112#define MACB_SPD_OFFSET 0
113#define MACB_SPD_SIZE 1
114#define MACB_FD_OFFSET 1
115#define MACB_FD_SIZE 1
116#define MACB_BIT_RATE_OFFSET 2
117#define MACB_BIT_RATE_SIZE 1
118#define MACB_JFRAME_OFFSET 3
119#define MACB_JFRAME_SIZE 1
120#define MACB_CAF_OFFSET 4
121#define MACB_CAF_SIZE 1
122#define MACB_NBC_OFFSET 5
123#define MACB_NBC_SIZE 1
124#define MACB_NCFGR_MTI_OFFSET 6
125#define MACB_NCFGR_MTI_SIZE 1
126#define MACB_UNI_OFFSET 7
127#define MACB_UNI_SIZE 1
128#define MACB_BIG_OFFSET 8
129#define MACB_BIG_SIZE 1
130#define MACB_EAE_OFFSET 9
131#define MACB_EAE_SIZE 1
132#define MACB_CLK_OFFSET 10
133#define MACB_CLK_SIZE 2
134#define MACB_RTY_OFFSET 12
135#define MACB_RTY_SIZE 1
136#define MACB_PAE_OFFSET 13
137#define MACB_PAE_SIZE 1
Joachim Eastwood1fd3ca4e2012-10-18 11:01:06 +0000138#define MACB_RM9200_RMII_OFFSET 13 /* AT91RM9200 only */
139#define MACB_RM9200_RMII_SIZE 1 /* AT91RM9200 only */
Haavard Skinnemoen89e57852006-11-09 14:51:17 +0100140#define MACB_RBOF_OFFSET 14
141#define MACB_RBOF_SIZE 2
142#define MACB_RLCE_OFFSET 16
143#define MACB_RLCE_SIZE 1
144#define MACB_DRFCS_OFFSET 17
145#define MACB_DRFCS_SIZE 1
146#define MACB_EFRHD_OFFSET 18
147#define MACB_EFRHD_SIZE 1
148#define MACB_IRXFCS_OFFSET 19
149#define MACB_IRXFCS_SIZE 1
150
Jamie Iles70c9f3d2011-03-09 16:22:54 +0000151/* GEM specific NCFGR bitfields. */
Patrice Vilchez140b7552012-10-31 06:04:50 +0000152#define GEM_GBE_OFFSET 10
153#define GEM_GBE_SIZE 1
Jamie Iles70c9f3d2011-03-09 16:22:54 +0000154#define GEM_CLK_OFFSET 18
155#define GEM_CLK_SIZE 3
Jamie Iles757a03c2011-03-09 16:29:59 +0000156#define GEM_DBW_OFFSET 21
157#define GEM_DBW_SIZE 2
158
159/* Constants for data bus width. */
160#define GEM_DBW32 0
161#define GEM_DBW64 1
162#define GEM_DBW128 2
163
Jamie Iles0116da42011-03-14 17:38:30 +0000164/* Bitfields in DMACFG. */
165#define GEM_RXBS_OFFSET 16
166#define GEM_RXBS_SIZE 8
167
Haavard Skinnemoen89e57852006-11-09 14:51:17 +0100168/* Bitfields in NSR */
169#define MACB_NSR_LINK_OFFSET 0
170#define MACB_NSR_LINK_SIZE 1
171#define MACB_MDIO_OFFSET 1
172#define MACB_MDIO_SIZE 1
173#define MACB_IDLE_OFFSET 2
174#define MACB_IDLE_SIZE 1
175
176/* Bitfields in TSR */
177#define MACB_UBR_OFFSET 0
178#define MACB_UBR_SIZE 1
179#define MACB_COL_OFFSET 1
180#define MACB_COL_SIZE 1
181#define MACB_TSR_RLE_OFFSET 2
182#define MACB_TSR_RLE_SIZE 1
183#define MACB_TGO_OFFSET 3
184#define MACB_TGO_SIZE 1
185#define MACB_BEX_OFFSET 4
186#define MACB_BEX_SIZE 1
Joachim Eastwood1fd3ca4e2012-10-18 11:01:06 +0000187#define MACB_RM9200_BNQ_OFFSET 4 /* AT91RM9200 only */
188#define MACB_RM9200_BNQ_SIZE 1 /* AT91RM9200 only */
Haavard Skinnemoen89e57852006-11-09 14:51:17 +0100189#define MACB_COMP_OFFSET 5
190#define MACB_COMP_SIZE 1
191#define MACB_UND_OFFSET 6
192#define MACB_UND_SIZE 1
193
194/* Bitfields in RSR */
195#define MACB_BNA_OFFSET 0
196#define MACB_BNA_SIZE 1
197#define MACB_REC_OFFSET 1
198#define MACB_REC_SIZE 1
199#define MACB_OVR_OFFSET 2
200#define MACB_OVR_SIZE 1
201
202/* Bitfields in ISR/IER/IDR/IMR */
203#define MACB_MFD_OFFSET 0
204#define MACB_MFD_SIZE 1
205#define MACB_RCOMP_OFFSET 1
206#define MACB_RCOMP_SIZE 1
207#define MACB_RXUBR_OFFSET 2
208#define MACB_RXUBR_SIZE 1
209#define MACB_TXUBR_OFFSET 3
210#define MACB_TXUBR_SIZE 1
211#define MACB_ISR_TUND_OFFSET 4
212#define MACB_ISR_TUND_SIZE 1
213#define MACB_ISR_RLE_OFFSET 5
214#define MACB_ISR_RLE_SIZE 1
215#define MACB_TXERR_OFFSET 6
216#define MACB_TXERR_SIZE 1
217#define MACB_TCOMP_OFFSET 7
218#define MACB_TCOMP_SIZE 1
219#define MACB_ISR_LINK_OFFSET 9
220#define MACB_ISR_LINK_SIZE 1
221#define MACB_ISR_ROVR_OFFSET 10
222#define MACB_ISR_ROVR_SIZE 1
223#define MACB_HRESP_OFFSET 11
224#define MACB_HRESP_SIZE 1
225#define MACB_PFR_OFFSET 12
226#define MACB_PFR_SIZE 1
227#define MACB_PTZ_OFFSET 13
228#define MACB_PTZ_SIZE 1
229
230/* Bitfields in MAN */
231#define MACB_DATA_OFFSET 0
232#define MACB_DATA_SIZE 16
233#define MACB_CODE_OFFSET 16
234#define MACB_CODE_SIZE 2
235#define MACB_REGA_OFFSET 18
236#define MACB_REGA_SIZE 5
237#define MACB_PHYA_OFFSET 23
238#define MACB_PHYA_SIZE 5
239#define MACB_RW_OFFSET 28
240#define MACB_RW_SIZE 2
241#define MACB_SOF_OFFSET 30
242#define MACB_SOF_SIZE 2
243
Andrew Victor0cc86742007-02-07 16:40:44 +0100244/* Bitfields in USRIO (AVR32) */
Haavard Skinnemoen89e57852006-11-09 14:51:17 +0100245#define MACB_MII_OFFSET 0
246#define MACB_MII_SIZE 1
247#define MACB_EAM_OFFSET 1
248#define MACB_EAM_SIZE 1
249#define MACB_TX_PAUSE_OFFSET 2
250#define MACB_TX_PAUSE_SIZE 1
251#define MACB_TX_PAUSE_ZERO_OFFSET 3
252#define MACB_TX_PAUSE_ZERO_SIZE 1
253
Andrew Victor0cc86742007-02-07 16:40:44 +0100254/* Bitfields in USRIO (AT91) */
255#define MACB_RMII_OFFSET 0
256#define MACB_RMII_SIZE 1
Patrice Vilchez140b7552012-10-31 06:04:50 +0000257#define GEM_RGMII_OFFSET 0 /* GEM gigabit mode */
258#define GEM_RGMII_SIZE 1
Andrew Victor0cc86742007-02-07 16:40:44 +0100259#define MACB_CLKEN_OFFSET 1
260#define MACB_CLKEN_SIZE 1
261
Haavard Skinnemoen89e57852006-11-09 14:51:17 +0100262/* Bitfields in WOL */
263#define MACB_IP_OFFSET 0
264#define MACB_IP_SIZE 16
265#define MACB_MAG_OFFSET 16
266#define MACB_MAG_SIZE 1
267#define MACB_ARP_OFFSET 17
268#define MACB_ARP_SIZE 1
269#define MACB_SA1_OFFSET 18
270#define MACB_SA1_SIZE 1
271#define MACB_WOL_MTI_OFFSET 19
272#define MACB_WOL_MTI_SIZE 1
273
Jamie Ilesf75ba502011-11-08 10:12:32 +0000274/* Bitfields in MID */
275#define MACB_IDNUM_OFFSET 16
276#define MACB_IDNUM_SIZE 16
277#define MACB_REV_OFFSET 0
278#define MACB_REV_SIZE 16
279
Jamie Iles757a03c2011-03-09 16:29:59 +0000280/* Bitfields in DCFG1. */
281#define GEM_DBWDEF_OFFSET 25
282#define GEM_DBWDEF_SIZE 3
283
Haavard Skinnemoen89e57852006-11-09 14:51:17 +0100284/* Constants for CLK */
285#define MACB_CLK_DIV8 0
286#define MACB_CLK_DIV16 1
287#define MACB_CLK_DIV32 2
288#define MACB_CLK_DIV64 3
289
Jamie Iles70c9f3d2011-03-09 16:22:54 +0000290/* GEM specific constants for CLK. */
291#define GEM_CLK_DIV8 0
292#define GEM_CLK_DIV16 1
293#define GEM_CLK_DIV32 2
294#define GEM_CLK_DIV48 3
295#define GEM_CLK_DIV64 4
296#define GEM_CLK_DIV96 5
297
Haavard Skinnemoen89e57852006-11-09 14:51:17 +0100298/* Constants for MAN register */
299#define MACB_MAN_SOF 1
300#define MACB_MAN_WRITE 1
301#define MACB_MAN_READ 2
302#define MACB_MAN_CODE 2
303
304/* Bit manipulation macros */
305#define MACB_BIT(name) \
306 (1 << MACB_##name##_OFFSET)
307#define MACB_BF(name,value) \
308 (((value) & ((1 << MACB_##name##_SIZE) - 1)) \
309 << MACB_##name##_OFFSET)
310#define MACB_BFEXT(name,value)\
311 (((value) >> MACB_##name##_OFFSET) \
312 & ((1 << MACB_##name##_SIZE) - 1))
313#define MACB_BFINS(name,value,old) \
314 (((old) & ~(((1 << MACB_##name##_SIZE) - 1) \
315 << MACB_##name##_OFFSET)) \
316 | MACB_BF(name,value))
317
Jamie Ilesf75ba502011-11-08 10:12:32 +0000318#define GEM_BIT(name) \
319 (1 << GEM_##name##_OFFSET)
320#define GEM_BF(name, value) \
321 (((value) & ((1 << GEM_##name##_SIZE) - 1)) \
322 << GEM_##name##_OFFSET)
323#define GEM_BFEXT(name, value)\
324 (((value) >> GEM_##name##_OFFSET) \
325 & ((1 << GEM_##name##_SIZE) - 1))
326#define GEM_BFINS(name, value, old) \
327 (((old) & ~(((1 << GEM_##name##_SIZE) - 1) \
328 << GEM_##name##_OFFSET)) \
329 | GEM_BF(name, value))
330
Haavard Skinnemoen89e57852006-11-09 14:51:17 +0100331/* Register access macros */
332#define macb_readl(port,reg) \
Haavard Skinnemoen0f0d84e2006-12-08 14:38:30 +0100333 __raw_readl((port)->regs + MACB_##reg)
Haavard Skinnemoen89e57852006-11-09 14:51:17 +0100334#define macb_writel(port,reg,value) \
Haavard Skinnemoen0f0d84e2006-12-08 14:38:30 +0100335 __raw_writel((value), (port)->regs + MACB_##reg)
Jamie Ilesf75ba502011-11-08 10:12:32 +0000336#define gem_readl(port, reg) \
337 __raw_readl((port)->regs + GEM_##reg)
338#define gem_writel(port, reg, value) \
339 __raw_writel((value), (port)->regs + GEM_##reg)
340
341/*
342 * Conditional GEM/MACB macros. These perform the operation to the correct
343 * register dependent on whether the device is a GEM or a MACB. For registers
344 * and bitfields that are common across both devices, use macb_{read,write}l
345 * to avoid the cost of the conditional.
346 */
347#define macb_or_gem_writel(__bp, __reg, __value) \
348 ({ \
349 if (macb_is_gem((__bp))) \
350 gem_writel((__bp), __reg, __value); \
351 else \
352 macb_writel((__bp), __reg, __value); \
353 })
354
355#define macb_or_gem_readl(__bp, __reg) \
356 ({ \
357 u32 __v; \
358 if (macb_is_gem((__bp))) \
359 __v = gem_readl((__bp), __reg); \
360 else \
361 __v = macb_readl((__bp), __reg); \
362 __v; \
363 })
Haavard Skinnemoen89e57852006-11-09 14:51:17 +0100364
365struct dma_desc {
366 u32 addr;
367 u32 ctrl;
368};
369
370/* DMA descriptor bitfields */
371#define MACB_RX_USED_OFFSET 0
372#define MACB_RX_USED_SIZE 1
373#define MACB_RX_WRAP_OFFSET 1
374#define MACB_RX_WRAP_SIZE 1
375#define MACB_RX_WADDR_OFFSET 2
376#define MACB_RX_WADDR_SIZE 30
377
378#define MACB_RX_FRMLEN_OFFSET 0
379#define MACB_RX_FRMLEN_SIZE 12
380#define MACB_RX_OFFSET_OFFSET 12
381#define MACB_RX_OFFSET_SIZE 2
382#define MACB_RX_SOF_OFFSET 14
383#define MACB_RX_SOF_SIZE 1
384#define MACB_RX_EOF_OFFSET 15
385#define MACB_RX_EOF_SIZE 1
386#define MACB_RX_CFI_OFFSET 16
387#define MACB_RX_CFI_SIZE 1
388#define MACB_RX_VLAN_PRI_OFFSET 17
389#define MACB_RX_VLAN_PRI_SIZE 3
390#define MACB_RX_PRI_TAG_OFFSET 20
391#define MACB_RX_PRI_TAG_SIZE 1
392#define MACB_RX_VLAN_TAG_OFFSET 21
393#define MACB_RX_VLAN_TAG_SIZE 1
394#define MACB_RX_TYPEID_MATCH_OFFSET 22
395#define MACB_RX_TYPEID_MATCH_SIZE 1
396#define MACB_RX_SA4_MATCH_OFFSET 23
397#define MACB_RX_SA4_MATCH_SIZE 1
398#define MACB_RX_SA3_MATCH_OFFSET 24
399#define MACB_RX_SA3_MATCH_SIZE 1
400#define MACB_RX_SA2_MATCH_OFFSET 25
401#define MACB_RX_SA2_MATCH_SIZE 1
402#define MACB_RX_SA1_MATCH_OFFSET 26
403#define MACB_RX_SA1_MATCH_SIZE 1
404#define MACB_RX_EXT_MATCH_OFFSET 28
405#define MACB_RX_EXT_MATCH_SIZE 1
406#define MACB_RX_UHASH_MATCH_OFFSET 29
407#define MACB_RX_UHASH_MATCH_SIZE 1
408#define MACB_RX_MHASH_MATCH_OFFSET 30
409#define MACB_RX_MHASH_MATCH_SIZE 1
410#define MACB_RX_BROADCAST_OFFSET 31
411#define MACB_RX_BROADCAST_SIZE 1
412
413#define MACB_TX_FRMLEN_OFFSET 0
414#define MACB_TX_FRMLEN_SIZE 11
415#define MACB_TX_LAST_OFFSET 15
416#define MACB_TX_LAST_SIZE 1
417#define MACB_TX_NOCRC_OFFSET 16
418#define MACB_TX_NOCRC_SIZE 1
419#define MACB_TX_BUF_EXHAUSTED_OFFSET 27
420#define MACB_TX_BUF_EXHAUSTED_SIZE 1
421#define MACB_TX_UNDERRUN_OFFSET 28
422#define MACB_TX_UNDERRUN_SIZE 1
423#define MACB_TX_ERROR_OFFSET 29
424#define MACB_TX_ERROR_SIZE 1
425#define MACB_TX_WRAP_OFFSET 30
426#define MACB_TX_WRAP_SIZE 1
427#define MACB_TX_USED_OFFSET 31
428#define MACB_TX_USED_SIZE 1
429
430struct ring_info {
431 struct sk_buff *skb;
432 dma_addr_t mapping;
433};
434
435/*
436 * Hardware-collected statistics. Used when updating the network
437 * device stats by a periodic timer.
438 */
439struct macb_stats {
440 u32 rx_pause_frames;
441 u32 tx_ok;
442 u32 tx_single_cols;
443 u32 tx_multiple_cols;
444 u32 rx_ok;
445 u32 rx_fcs_errors;
446 u32 rx_align_errors;
447 u32 tx_deferred;
448 u32 tx_late_cols;
449 u32 tx_excessive_cols;
450 u32 tx_underruns;
451 u32 tx_carrier_errors;
452 u32 rx_resource_errors;
453 u32 rx_overruns;
454 u32 rx_symbol_errors;
455 u32 rx_oversize_pkts;
456 u32 rx_jabbers;
457 u32 rx_undersize_pkts;
458 u32 sqe_test_errors;
459 u32 rx_length_mismatch;
460 u32 tx_pause_frames;
461};
462
Jamie Ilesa494ed82011-03-09 16:26:35 +0000463struct gem_stats {
464 u32 tx_octets_31_0;
465 u32 tx_octets_47_32;
466 u32 tx_frames;
467 u32 tx_broadcast_frames;
468 u32 tx_multicast_frames;
469 u32 tx_pause_frames;
470 u32 tx_64_byte_frames;
471 u32 tx_65_127_byte_frames;
472 u32 tx_128_255_byte_frames;
473 u32 tx_256_511_byte_frames;
474 u32 tx_512_1023_byte_frames;
475 u32 tx_1024_1518_byte_frames;
476 u32 tx_greater_than_1518_byte_frames;
477 u32 tx_underrun;
478 u32 tx_single_collision_frames;
479 u32 tx_multiple_collision_frames;
480 u32 tx_excessive_collisions;
481 u32 tx_late_collisions;
482 u32 tx_deferred_frames;
483 u32 tx_carrier_sense_errors;
484 u32 rx_octets_31_0;
485 u32 rx_octets_47_32;
486 u32 rx_frames;
487 u32 rx_broadcast_frames;
488 u32 rx_multicast_frames;
489 u32 rx_pause_frames;
490 u32 rx_64_byte_frames;
491 u32 rx_65_127_byte_frames;
492 u32 rx_128_255_byte_frames;
493 u32 rx_256_511_byte_frames;
494 u32 rx_512_1023_byte_frames;
495 u32 rx_1024_1518_byte_frames;
496 u32 rx_greater_than_1518_byte_frames;
497 u32 rx_undersized_frames;
498 u32 rx_oversize_frames;
499 u32 rx_jabbers;
500 u32 rx_frame_check_sequence_errors;
501 u32 rx_length_field_frame_errors;
502 u32 rx_symbol_errors;
503 u32 rx_alignment_errors;
504 u32 rx_resource_errors;
505 u32 rx_overruns;
506 u32 rx_ip_header_checksum_errors;
507 u32 rx_tcp_checksum_errors;
508 u32 rx_udp_checksum_errors;
509};
510
Haavard Skinnemoen89e57852006-11-09 14:51:17 +0100511struct macb {
512 void __iomem *regs;
513
514 unsigned int rx_tail;
515 struct dma_desc *rx_ring;
516 void *rx_buffers;
517
518 unsigned int tx_head, tx_tail;
519 struct dma_desc *tx_ring;
520 struct ring_info *tx_skb;
521
522 spinlock_t lock;
523 struct platform_device *pdev;
524 struct clk *pclk;
525 struct clk *hclk;
526 struct net_device *dev;
Stephen Hemmingerbea33482007-10-03 16:41:36 -0700527 struct napi_struct napi;
Haavard Skinnemoen89e57852006-11-09 14:51:17 +0100528 struct net_device_stats stats;
Jamie Ilesa494ed82011-03-09 16:26:35 +0000529 union {
530 struct macb_stats macb;
531 struct gem_stats gem;
532 } hw_stats;
Haavard Skinnemoen89e57852006-11-09 14:51:17 +0100533
534 dma_addr_t rx_ring_dma;
535 dma_addr_t tx_ring_dma;
536 dma_addr_t rx_buffers_dma;
537
538 unsigned int rx_pending, tx_pending;
539
Lennert Buytenhek298cf9b2008-10-08 16:29:57 -0700540 struct mii_bus *mii_bus;
frederic RODO6c36a702007-07-12 19:07:24 +0200541 struct phy_device *phy_dev;
542 unsigned int link;
543 unsigned int speed;
544 unsigned int duplex;
Jean-Christophe PLAGNIOL-VILLARDfb97a842011-11-18 15:29:25 +0100545
546 phy_interface_t phy_interface;
Joachim Eastwoodb85008b2012-10-18 11:01:10 +0000547
548 /* at91_private */
Joachim Eastwoodb85008b2012-10-18 11:01:10 +0000549 struct macb_platform_data board_data; /* board-specific
550 * configuration (shared with
551 * macb for common data */
Joachim Eastwoodb85008b2012-10-18 11:01:10 +0000552
Joachim Eastwoodb85008b2012-10-18 11:01:10 +0000553 /* Transmit */
554 struct sk_buff *skb; /* holds skb until xmit interrupt completes */
555 dma_addr_t skb_physaddr; /* phys addr from pci_map_single */
556 int skb_length; /* saved skb length for pci_unmap_single */
Haavard Skinnemoen89e57852006-11-09 14:51:17 +0100557};
558
Joachim Eastwood0005f542012-10-18 11:01:12 +0000559extern const struct ethtool_ops macb_ethtool_ops;
560
561int macb_mii_init(struct macb *bp);
562int macb_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
Joachim Eastwoode0da1f12012-10-18 11:01:15 +0000563void macb_set_rx_mode(struct net_device *dev);
Joachim Eastwood0005f542012-10-18 11:01:12 +0000564
Jamie Ilesf75ba502011-11-08 10:12:32 +0000565static inline bool macb_is_gem(struct macb *bp)
566{
567 return MACB_BFEXT(IDNUM, macb_readl(bp, MID)) == 0x2;
568}
569
Haavard Skinnemoen89e57852006-11-09 14:51:17 +0100570#endif /* _MACB_H */