This source file includes following definitions.
- axienet_ior
- axinet_ior_read_mcr
- axienet_iow
1
2
3
4
5
6
7
8
9 #ifndef XILINX_AXIENET_H
10 #define XILINX_AXIENET_H
11
12 #include <linux/netdevice.h>
13 #include <linux/spinlock.h>
14 #include <linux/interrupt.h>
15 #include <linux/if_vlan.h>
16 #include <linux/phylink.h>
17
18
19 #define XAE_HDR_SIZE 14
20 #define XAE_TRL_SIZE 4
21 #define XAE_MTU 1500
22 #define XAE_JUMBO_MTU 9000
23
24 #define XAE_MAX_FRAME_SIZE (XAE_MTU + XAE_HDR_SIZE + XAE_TRL_SIZE)
25 #define XAE_MAX_VLAN_FRAME_SIZE (XAE_MTU + VLAN_ETH_HLEN + XAE_TRL_SIZE)
26 #define XAE_MAX_JUMBO_FRAME_SIZE (XAE_JUMBO_MTU + XAE_HDR_SIZE + XAE_TRL_SIZE)
27
28
29
30
31 #define XAE_OPTION_PROMISC (1 << 0)
32
33
34 #define XAE_OPTION_JUMBO (1 << 1)
35
36
37 #define XAE_OPTION_VLAN (1 << 2)
38
39
40 #define XAE_OPTION_FLOW_CONTROL (1 << 4)
41
42
43
44
45 #define XAE_OPTION_FCS_STRIP (1 << 5)
46
47
48
49
50 #define XAE_OPTION_FCS_INSERT (1 << 6)
51
52
53
54
55
56
57
58 #define XAE_OPTION_LENTYPE_ERR (1 << 7)
59
60
61 #define XAE_OPTION_TXEN (1 << 11)
62
63
64 #define XAE_OPTION_RXEN (1 << 12)
65
66
67 #define XAE_OPTION_DEFAULTS \
68 (XAE_OPTION_TXEN | \
69 XAE_OPTION_FLOW_CONTROL | \
70 XAE_OPTION_RXEN)
71
72
73
74 #define XAXIDMA_TX_CR_OFFSET 0x00000000
75 #define XAXIDMA_TX_SR_OFFSET 0x00000004
76 #define XAXIDMA_TX_CDESC_OFFSET 0x00000008
77 #define XAXIDMA_TX_TDESC_OFFSET 0x00000010
78
79 #define XAXIDMA_RX_CR_OFFSET 0x00000030
80 #define XAXIDMA_RX_SR_OFFSET 0x00000034
81 #define XAXIDMA_RX_CDESC_OFFSET 0x00000038
82 #define XAXIDMA_RX_TDESC_OFFSET 0x00000040
83
84 #define XAXIDMA_CR_RUNSTOP_MASK 0x00000001
85 #define XAXIDMA_CR_RESET_MASK 0x00000004
86
87 #define XAXIDMA_SR_HALT_MASK 0x00000001
88
89 #define XAXIDMA_BD_NDESC_OFFSET 0x00
90 #define XAXIDMA_BD_BUFA_OFFSET 0x08
91 #define XAXIDMA_BD_CTRL_LEN_OFFSET 0x18
92 #define XAXIDMA_BD_STS_OFFSET 0x1C
93 #define XAXIDMA_BD_USR0_OFFSET 0x20
94 #define XAXIDMA_BD_USR1_OFFSET 0x24
95 #define XAXIDMA_BD_USR2_OFFSET 0x28
96 #define XAXIDMA_BD_USR3_OFFSET 0x2C
97 #define XAXIDMA_BD_USR4_OFFSET 0x30
98 #define XAXIDMA_BD_ID_OFFSET 0x34
99 #define XAXIDMA_BD_HAS_STSCNTRL_OFFSET 0x38
100 #define XAXIDMA_BD_HAS_DRE_OFFSET 0x3C
101
102 #define XAXIDMA_BD_HAS_DRE_SHIFT 8
103 #define XAXIDMA_BD_HAS_DRE_MASK 0xF00
104 #define XAXIDMA_BD_WORDLEN_MASK 0xFF
105
106 #define XAXIDMA_BD_CTRL_LENGTH_MASK 0x007FFFFF
107 #define XAXIDMA_BD_CTRL_TXSOF_MASK 0x08000000
108 #define XAXIDMA_BD_CTRL_TXEOF_MASK 0x04000000
109 #define XAXIDMA_BD_CTRL_ALL_MASK 0x0C000000
110
111 #define XAXIDMA_DELAY_MASK 0xFF000000
112 #define XAXIDMA_COALESCE_MASK 0x00FF0000
113
114 #define XAXIDMA_DELAY_SHIFT 24
115 #define XAXIDMA_COALESCE_SHIFT 16
116
117 #define XAXIDMA_IRQ_IOC_MASK 0x00001000
118 #define XAXIDMA_IRQ_DELAY_MASK 0x00002000
119 #define XAXIDMA_IRQ_ERROR_MASK 0x00004000
120 #define XAXIDMA_IRQ_ALL_MASK 0x00007000
121
122
123 #define XAXIDMA_DFT_TX_THRESHOLD 24
124 #define XAXIDMA_DFT_TX_WAITBOUND 254
125 #define XAXIDMA_DFT_RX_THRESHOLD 24
126 #define XAXIDMA_DFT_RX_WAITBOUND 254
127
128 #define XAXIDMA_BD_CTRL_TXSOF_MASK 0x08000000
129 #define XAXIDMA_BD_CTRL_TXEOF_MASK 0x04000000
130 #define XAXIDMA_BD_CTRL_ALL_MASK 0x0C000000
131
132 #define XAXIDMA_BD_STS_ACTUAL_LEN_MASK 0x007FFFFF
133 #define XAXIDMA_BD_STS_COMPLETE_MASK 0x80000000
134 #define XAXIDMA_BD_STS_DEC_ERR_MASK 0x40000000
135 #define XAXIDMA_BD_STS_SLV_ERR_MASK 0x20000000
136 #define XAXIDMA_BD_STS_INT_ERR_MASK 0x10000000
137 #define XAXIDMA_BD_STS_ALL_ERR_MASK 0x70000000
138 #define XAXIDMA_BD_STS_RXSOF_MASK 0x08000000
139 #define XAXIDMA_BD_STS_RXEOF_MASK 0x04000000
140 #define XAXIDMA_BD_STS_ALL_MASK 0xFC000000
141
142 #define XAXIDMA_BD_MINIMUM_ALIGNMENT 0x40
143
144
145 #define XAE_RAF_OFFSET 0x00000000
146 #define XAE_TPF_OFFSET 0x00000004
147 #define XAE_IFGP_OFFSET 0x00000008
148 #define XAE_IS_OFFSET 0x0000000C
149 #define XAE_IP_OFFSET 0x00000010
150 #define XAE_IE_OFFSET 0x00000014
151 #define XAE_TTAG_OFFSET 0x00000018
152 #define XAE_RTAG_OFFSET 0x0000001C
153 #define XAE_UAWL_OFFSET 0x00000020
154 #define XAE_UAWU_OFFSET 0x00000024
155 #define XAE_TPID0_OFFSET 0x00000028
156 #define XAE_TPID1_OFFSET 0x0000002C
157 #define XAE_PPST_OFFSET 0x00000030
158 #define XAE_RCW0_OFFSET 0x00000400
159 #define XAE_RCW1_OFFSET 0x00000404
160 #define XAE_TC_OFFSET 0x00000408
161 #define XAE_FCC_OFFSET 0x0000040C
162 #define XAE_EMMC_OFFSET 0x00000410
163 #define XAE_PHYC_OFFSET 0x00000414
164 #define XAE_MDIO_MC_OFFSET 0x00000500
165 #define XAE_MDIO_MCR_OFFSET 0x00000504
166 #define XAE_MDIO_MWD_OFFSET 0x00000508
167 #define XAE_MDIO_MRD_OFFSET 0x0000050C
168 #define XAE_MDIO_MIS_OFFSET 0x00000600
169
170 #define XAE_MDIO_MIP_OFFSET 0x00000620
171
172 #define XAE_MDIO_MIE_OFFSET 0x00000640
173
174 #define XAE_MDIO_MIC_OFFSET 0x00000660
175 #define XAE_UAW0_OFFSET 0x00000700
176 #define XAE_UAW1_OFFSET 0x00000704
177 #define XAE_FMI_OFFSET 0x00000708
178 #define XAE_AF0_OFFSET 0x00000710
179 #define XAE_AF1_OFFSET 0x00000714
180
181 #define XAE_TX_VLAN_DATA_OFFSET 0x00004000
182 #define XAE_RX_VLAN_DATA_OFFSET 0x00008000
183 #define XAE_MCAST_TABLE_OFFSET 0x00020000
184
185
186
187 #define XAE_RAF_MCSTREJ_MASK 0x00000002
188
189 #define XAE_RAF_BCSTREJ_MASK 0x00000004
190 #define XAE_RAF_TXVTAGMODE_MASK 0x00000018
191 #define XAE_RAF_RXVTAGMODE_MASK 0x00000060
192 #define XAE_RAF_TXVSTRPMODE_MASK 0x00000180
193 #define XAE_RAF_RXVSTRPMODE_MASK 0x00000600
194 #define XAE_RAF_NEWFNCENBL_MASK 0x00000800
195
196 #define XAE_RAF_EMULTIFLTRENBL_MASK 0x00001000
197 #define XAE_RAF_STATSRST_MASK 0x00002000
198 #define XAE_RAF_RXBADFRMEN_MASK 0x00004000
199 #define XAE_RAF_TXVTAGMODE_SHIFT 3
200 #define XAE_RAF_RXVTAGMODE_SHIFT 5
201 #define XAE_RAF_TXVSTRPMODE_SHIFT 7
202 #define XAE_RAF_RXVSTRPMODE_SHIFT 9
203
204
205 #define XAE_TPF_TPFV_MASK 0x0000FFFF
206
207 #define XAE_IFGP0_IFGP_MASK 0x0000007F
208
209
210
211
212
213 #define XAE_INT_HARDACSCMPLT_MASK 0x00000001
214
215 #define XAE_INT_AUTONEG_MASK 0x00000002
216 #define XAE_INT_RXCMPIT_MASK 0x00000004
217 #define XAE_INT_RXRJECT_MASK 0x00000008
218 #define XAE_INT_RXFIFOOVR_MASK 0x00000010
219 #define XAE_INT_TXCMPIT_MASK 0x00000020
220 #define XAE_INT_RXDCMLOCK_MASK 0x00000040
221 #define XAE_INT_MGTRDY_MASK 0x00000080
222 #define XAE_INT_PHYRSTCMPLT_MASK 0x00000100
223 #define XAE_INT_ALL_MASK 0x0000003F
224
225
226 #define XAE_INT_RECV_ERROR_MASK \
227 (XAE_INT_RXRJECT_MASK | XAE_INT_RXFIFOOVR_MASK)
228
229
230 #define XAE_TPID_0_MASK 0x0000FFFF
231 #define XAE_TPID_1_MASK 0xFFFF0000
232
233
234 #define XAE_TPID_2_MASK 0x0000FFFF
235 #define XAE_TPID_3_MASK 0xFFFF0000
236
237
238 #define XAE_RCW1_RST_MASK 0x80000000
239 #define XAE_RCW1_JUM_MASK 0x40000000
240
241 #define XAE_RCW1_FCS_MASK 0x20000000
242 #define XAE_RCW1_RX_MASK 0x10000000
243 #define XAE_RCW1_VLAN_MASK 0x08000000
244
245 #define XAE_RCW1_LT_DIS_MASK 0x02000000
246
247 #define XAE_RCW1_CL_DIS_MASK 0x01000000
248
249
250
251 #define XAE_RCW1_PAUSEADDR_MASK 0x0000FFFF
252
253
254 #define XAE_TC_RST_MASK 0x80000000
255 #define XAE_TC_JUM_MASK 0x40000000
256
257 #define XAE_TC_FCS_MASK 0x20000000
258 #define XAE_TC_TX_MASK 0x10000000
259 #define XAE_TC_VLAN_MASK 0x08000000
260
261 #define XAE_TC_IFG_MASK 0x02000000
262
263
264 #define XAE_FCC_FCRX_MASK 0x20000000
265 #define XAE_FCC_FCTX_MASK 0x40000000
266
267
268 #define XAE_EMMC_LINKSPEED_MASK 0xC0000000
269 #define XAE_EMMC_RGMII_MASK 0x20000000
270 #define XAE_EMMC_SGMII_MASK 0x10000000
271 #define XAE_EMMC_GPCS_MASK 0x08000000
272 #define XAE_EMMC_HOST_MASK 0x04000000
273 #define XAE_EMMC_TX16BIT 0x02000000
274 #define XAE_EMMC_RX16BIT 0x01000000
275 #define XAE_EMMC_LINKSPD_10 0x00000000
276 #define XAE_EMMC_LINKSPD_100 0x40000000
277 #define XAE_EMMC_LINKSPD_1000 0x80000000
278
279
280 #define XAE_PHYC_SGMIILINKSPEED_MASK 0xC0000000
281 #define XAE_PHYC_RGMIILINKSPEED_MASK 0x0000000C
282 #define XAE_PHYC_RGMIIHD_MASK 0x00000002
283 #define XAE_PHYC_RGMIILINK_MASK 0x00000001
284 #define XAE_PHYC_RGLINKSPD_10 0x00000000
285 #define XAE_PHYC_RGLINKSPD_100 0x00000004
286 #define XAE_PHYC_RGLINKSPD_1000 0x00000008
287 #define XAE_PHYC_SGLINKSPD_10 0x00000000
288 #define XAE_PHYC_SGLINKSPD_100 0x40000000
289 #define XAE_PHYC_SGLINKSPD_1000 0x80000000
290
291
292 #define XAE_MDIO_MC_MDIOEN_MASK 0x00000040
293 #define XAE_MDIO_MC_CLOCK_DIVIDE_MAX 0x3F
294
295
296 #define XAE_MDIO_MCR_PHYAD_MASK 0x1F000000
297 #define XAE_MDIO_MCR_PHYAD_SHIFT 24
298 #define XAE_MDIO_MCR_REGAD_MASK 0x001F0000
299 #define XAE_MDIO_MCR_REGAD_SHIFT 16
300 #define XAE_MDIO_MCR_OP_MASK 0x0000C000
301 #define XAE_MDIO_MCR_OP_SHIFT 13
302 #define XAE_MDIO_MCR_OP_READ_MASK 0x00008000
303 #define XAE_MDIO_MCR_OP_WRITE_MASK 0x00004000
304 #define XAE_MDIO_MCR_INITIATE_MASK 0x00000800
305 #define XAE_MDIO_MCR_READY_MASK 0x00000080
306
307
308 #define XAE_MDIO_INT_MIIM_RDY_MASK 0x00000001
309
310
311
312
313
314 #define XAE_UAW1_UNICASTADDR_MASK 0x0000FFFF
315
316
317 #define XAE_FMI_PM_MASK 0x80000000
318 #define XAE_FMI_IND_MASK 0x00000003
319
320 #define XAE_MDIO_DIV_DFT 29
321
322
323 #define XAE_PHY_TYPE_MII 0
324 #define XAE_PHY_TYPE_GMII 1
325 #define XAE_PHY_TYPE_RGMII_1_3 2
326 #define XAE_PHY_TYPE_RGMII_2_0 3
327 #define XAE_PHY_TYPE_SGMII 4
328 #define XAE_PHY_TYPE_1000BASE_X 5
329
330
331 #define XAE_MULTICAST_CAM_TABLE_NUM 4
332
333
334 #define XAE_FEATURE_PARTIAL_RX_CSUM (1 << 0)
335 #define XAE_FEATURE_PARTIAL_TX_CSUM (1 << 1)
336 #define XAE_FEATURE_FULL_RX_CSUM (1 << 2)
337 #define XAE_FEATURE_FULL_TX_CSUM (1 << 3)
338
339 #define XAE_NO_CSUM_OFFLOAD 0
340
341 #define XAE_FULL_CSUM_STATUS_MASK 0x00000038
342 #define XAE_IP_UDP_CSUM_VALIDATED 0x00000003
343 #define XAE_IP_TCP_CSUM_VALIDATED 0x00000002
344
345 #define DELAY_OF_ONE_MILLISEC 1000
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363 struct axidma_bd {
364 u32 next;
365 u32 reserved1;
366 u32 phys;
367 u32 reserved2;
368 u32 reserved3;
369 u32 reserved4;
370 u32 cntrl;
371 u32 status;
372 u32 app0;
373 u32 app1;
374 u32 app2;
375 u32 app3;
376 u32 app4;
377 struct sk_buff *skb;
378 } __aligned(XAXIDMA_BD_MINIMUM_ALIGNMENT);
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417 struct axienet_local {
418 struct net_device *ndev;
419 struct device *dev;
420
421
422 struct device_node *phy_node;
423
424 struct phylink *phylink;
425 struct phylink_config phylink_config;
426
427
428 struct clk *clk;
429
430
431 struct mii_bus *mii_bus;
432
433
434 resource_size_t regs_start;
435 void __iomem *regs;
436 void __iomem *dma_regs;
437
438 struct tasklet_struct dma_err_tasklet;
439
440 int tx_irq;
441 int rx_irq;
442 int eth_irq;
443 phy_interface_t phy_mode;
444
445 u32 options;
446 u32 features;
447
448
449 struct axidma_bd *tx_bd_v;
450 dma_addr_t tx_bd_p;
451 u32 tx_bd_num;
452 struct axidma_bd *rx_bd_v;
453 dma_addr_t rx_bd_p;
454 u32 rx_bd_num;
455 u32 tx_bd_ci;
456 u32 tx_bd_tail;
457 u32 rx_bd_ci;
458
459 u32 max_frm_size;
460 u32 rxmem;
461
462 int csum_offload_on_tx_path;
463 int csum_offload_on_rx_path;
464
465 u32 coalesce_count_rx;
466 u32 coalesce_count_tx;
467 };
468
469
470
471
472
473
474
475 struct axienet_option {
476 u32 opt;
477 u32 reg;
478 u32 m_or;
479 };
480
481
482
483
484
485
486
487
488
489
490 static inline u32 axienet_ior(struct axienet_local *lp, off_t offset)
491 {
492 return ioread32(lp->regs + offset);
493 }
494
495 static inline u32 axinet_ior_read_mcr(struct axienet_local *lp)
496 {
497 return axienet_ior(lp, XAE_MDIO_MCR_OFFSET);
498 }
499
500
501
502
503
504
505
506
507
508
509 static inline void axienet_iow(struct axienet_local *lp, off_t offset,
510 u32 value)
511 {
512 iowrite32(value, lp->regs + offset);
513 }
514
515
516 int axienet_mdio_enable(struct axienet_local *lp);
517 void axienet_mdio_disable(struct axienet_local *lp);
518 int axienet_mdio_setup(struct axienet_local *lp);
519 void axienet_mdio_teardown(struct axienet_local *lp);
520
521 #endif