35#ifndef LIBOPENCM3_ETHERNET_H
36#define LIBOPENCM3_ETHERNET_H
51#define ETH_MACCR MMIO32(ETHERNET_BASE + 0x00)
52#define ETH_MACFFR MMIO32(ETHERNET_BASE + 0x04)
53#define ETH_MACHTHR MMIO32(ETHERNET_BASE + 0x08)
54#define ETH_MACHTLR MMIO32(ETHERNET_BASE + 0x0C)
55#define ETH_MACMIIAR MMIO32(ETHERNET_BASE + 0x10)
56#define ETH_MACMIIDR MMIO32(ETHERNET_BASE + 0x14)
57#define ETH_MACFCR MMIO32(ETHERNET_BASE + 0x18)
58#define ETH_MACVLANTR MMIO32(ETHERNET_BASE + 0x1C)
59#define ETH_MACRWUFFR MMIO32(ETHERNET_BASE + 0x28)
60#define ETH_MACPMTCSR MMIO32(ETHERNET_BASE + 0x2C)
61#define ETH_MACDBGR MMIO32(ETHERNET_BASE + 0x34)
62#define ETH_MACSR MMIO32(ETHERNET_BASE + 0x38)
63#define ETH_MACIMR MMIO32(ETHERNET_BASE + 0x3C)
66#define ETH_MACAHR(i) MMIO32(ETHERNET_BASE + 0x40+(i)*8)
68#define ETH_MACALR(i) MMIO32(ETHERNET_BASE + 0x44+(i)*8)
71#define ETH_MMCCR MMIO32(ETHERNET_BASE + 0x100)
72#define ETH_MMCRIR MMIO32(ETHERNET_BASE + 0x104)
73#define ETH_MMCTIR MMIO32(ETHERNET_BASE + 0x108)
74#define ETH_MMCRIMR MMIO32(ETHERNET_BASE + 0x10C)
75#define ETH_MMCTIMR MMIO32(ETHERNET_BASE + 0x110)
76#define ETH_MMCTGFSCCR MMIO32(ETHERNET_BASE + 0x14C)
77#define ETH_MMCTGFMSCCR MMIO32(ETHERNET_BASE + 0x150)
78#define ETH_MMCTGFCR MMIO32(ETHERNET_BASE + 0x168)
79#define ETH_MMCRFCECR MMIO32(ETHERNET_BASE + 0x194)
80#define ETH_MMCRFAECR MMIO32(ETHERNET_BASE + 0x198)
81#define ETH_MMCRGUFCR MMIO32(ETHERNET_BASE + 0x1C4)
84#define ETH_PTPTSCR MMIO32(ETHERNET_BASE + 0x700)
85#define ETH_PTPSSIR MMIO32(ETHERNET_BASE + 0x704)
86#define ETH_PTPTSHR MMIO32(ETHERNET_BASE + 0x708)
87#define ETH_PTPTSLR MMIO32(ETHERNET_BASE + 0x70C)
88#define ETH_PTPTSHUR MMIO32(ETHERNET_BASE + 0x710)
89#define ETH_PTPTSLUR MMIO32(ETHERNET_BASE + 0x714)
90#define ETH_PTPTSAR MMIO32(ETHERNET_BASE + 0x718)
91#define ETH_PTPTTHR MMIO32(ETHERNET_BASE + 0x71C)
92#define ETH_PTPTTLR MMIO32(ETHERNET_BASE + 0x720)
93#define ETH_PTPTSSR MMIO32(ETHERNET_BASE + 0x728)
94#define ETH_PTPPPSCR MMIO32(ETHERNET_BASE + 0x72C)
97#define ETH_DMABMR MMIO32(ETHERNET_BASE + 0x1000)
98#define ETH_DMATPDR MMIO32(ETHERNET_BASE + 0x1004)
99#define ETH_DMARPDR MMIO32(ETHERNET_BASE + 0x1008)
100#define ETH_DMARDLAR MMIO32(ETHERNET_BASE + 0x100C)
101#define ETH_DMATDLAR MMIO32(ETHERNET_BASE + 0x1010)
102#define ETH_DMASR MMIO32(ETHERNET_BASE + 0x1014)
103#define ETH_DMAOMR MMIO32(ETHERNET_BASE + 0x1018)
104#define ETH_DMAIER MMIO32(ETHERNET_BASE + 0x101C)
105#define ETH_DMAMFBOCR MMIO32(ETHERNET_BASE + 0x1020)
106#define ETH_DMARSWTR MMIO32(ETHERNET_BASE + 0x1024)
107#define ETH_DMACHTDR MMIO32(ETHERNET_BASE + 0x1048)
108#define ETH_DMACHRDR MMIO32(ETHERNET_BASE + 0x104C)
109#define ETH_DMACHTBAR MMIO32(ETHERNET_BASE + 0x1050)
110#define ETH_DMACHRBAR MMIO32(ETHERNET_BASE + 0x1054)
113#define ETH_DES(n, base) MMIO32((base) + (n)*4)
114#define ETH_DES0(base) ETH_DES(0, base)
115#define ETH_DES1(base) ETH_DES(1, base)
116#define ETH_DES2(base) ETH_DES(2, base)
117#define ETH_DES3(base) ETH_DES(3, base)
120#define ETH_DES4(base) ETH_DES(4, base)
121#define ETH_DES5(base) ETH_DES(5, base)
122#define ETH_DES6(base) ETH_DES(6, base)
123#define ETH_DES7(base) ETH_DES(7, base)
132#define ETH_MACCR_RE (1<<2)
133#define ETH_MACCR_TE (1<<3)
134#define ETH_MACCR_DC (1<<4)
136#define ETH_MACCR_BL_SHIFT 5
137#define ETH_MACCR_BL (3 << ETH_MACCR_BL_SHIFT)
138#define ETH_MACCR_BL_MIN10 (0 << ETH_MACCR_BL_SHIFT)
139#define ETH_MACCR_BL_MIN8 (1 << ETH_MACCR_BL_SHIFT)
140#define ETH_MACCR_BL_MIN4 (2 << ETH_MACCR_BL_SHIFT)
141#define ETH_MACCR_BL_MIN1 (3 << ETH_MACCR_BL_SHIFT)
143#define ETH_MACCR_APCS (1<<7)
144#define ETH_MACCR_RD (1<<9)
145#define ETH_MACCR_IPCO (1<<10)
146#define ETH_MACCR_DM (1<<11)
147#define ETH_MACCR_LM (1<<12)
148#define ETH_MACCR_ROD (1<<13)
149#define ETH_MACCR_FES (1<<14)
150#define ETH_MACCR_CSD (1<<16)
152#define ETH_MACCR_IFG_SHIFT 17
153#define ETH_MACCR_IFG (7<<ETH_MACCR_IFG_SHIFT)
155#define ETH_MACCR_JD (1<<22)
156#define ETH_MACCR_WD (1<<23)
157#define ETH_MACCR_CSTF (1<<25)
161#define ETH_MACFFR_PM (1<<0)
162#define ETH_MACFFR_HU (1<<1)
163#define ETH_MACFFR_HM (1<<2)
164#define ETH_MACFFR_DAIF (1<<3)
165#define ETH_MACFFR_PAM (1<<4)
166#define ETH_MACFFR_BFD (1<<5)
168#define ETH_MACFFR_PCF_SHIFT 6
169#define ETH_MACFFR_PCF (3<<ETH_MACFFR_PCF_SHIFT)
170#define ETH_MACFFR_PCF_DISABLE (0<<ETH_MACFFR_PCF_SHIFT)
171#define ETH_MACFFR_PCF_NOPAUSE (1<<ETH_MACFFR_PCF_SHIFT)
172#define ETH_MACFFR_PCF_ALL (2<<ETH_MACFFR_PCF_SHIFT)
173#define ETH_MACFFR_PCF_PASS (3<<ETH_MACFFR_PCF_SHIFT)
175#define ETH_MACFFR_SAIF (1<<8)
176#define ETH_MACFFR_SAF (1<<9)
177#define ETH_MACFFR_HPF (1<<10)
178#define ETH_MACFFR_RA (1<<31)
183#define ETH_MACMIIAR_MB (1<<0)
184#define ETH_MACMIIAR_MW (1<<1)
186#define ETH_MACMIIAR_CR_SHIFT 2
187#define ETH_MACMIIAR_CR (7<<ETH_MACMIIAR_CR_SHIFT)
189#define ETH_MACMIIAR_CR_HCLK_DIV_42 (0<<ETH_MACMIIAR_CR_SHIFT)
191#define ETH_MACMIIAR_CR_HCLK_DIV_62 (1<<ETH_MACMIIAR_CR_SHIFT)
193#define ETH_MACMIIAR_CR_HCLK_DIV_16 (2<<ETH_MACMIIAR_CR_SHIFT)
195#define ETH_MACMIIAR_CR_HCLK_DIV_26 (3<<ETH_MACMIIAR_CR_SHIFT)
197#define ETH_MACMIIAR_CR_HCLK_DIV_102 (4<<ETH_MACMIIAR_CR_SHIFT)
199#define ETH_MACMIIAR_MR_SHIFT 6
200#define ETH_MACMIIAR_MR (0x1F << ETH_MACMIIAR_MR_SHIFT)
202#define ETH_MACMIIAR_PA_SHIFT 11
203#define ETH_MACMIIAR_PA (0x1F << ETH_MACMIIAR_MR_SHIFT)
208#define ETH_MACMIIDR_MD 0xFFFF
212#define ETH_MACFCR_FCB (1<<0)
213#define ETH_MACFCR_BPA (1<<0)
214#define ETH_MACFCR_TFCE (1<<1)
215#define ETH_MACFCR_RFCE (1<<2)
216#define ETH_MACFCR_UPFD (1<<3)
218#define ETH_MACFCR_PLT_SHIFT 4
219#define ETH_MACFCR_PLT (0x03 << ETH_MACFCR_PLT_SHIFT)
220#define ETH_MACFCR_PLT_4 (0 << ETH_MACFCR_PLT_SHIFT)
221#define ETH_MACFCR_PLT_28 (1 << ETH_MACFCR_PLT_SHIFT)
222#define ETH_MACFCR_PLT_144 (2 << ETH_MACFCR_PLT_SHIFT)
223#define ETH_MACFCR_PLT_256 (3 << ETH_MACFCR_PLT_SHIFT)
225#define ETH_MACFCR_ZQPD (1<<7)
227#define ETH_MACFCR_PT_SHIFT 16
228#define ETH_MACFCR_PT (0xFFFF << ETH_MACFCR_PT)
232#define ETH_MACVLANTR_VLANTI_SHIFT 0
233#define ETH_MACVLANTR_VLANTI (0xFFFF << ETH_MACVLANTR_VLANTI_SHIFT)
234#define ETH_MACVLANTR_VLANTC (1<<16)
239#define ETH_MACPMTCSR_PD (1<<0)
240#define ETH_MACPMTCSR_MPE (1<<1)
241#define ETH_MACPMTCSR_WFE (1<<2)
242#define ETH_MACPMTCSR_MPR (1<<5)
243#define ETH_MACPMTCSR_WFR (1<<6)
244#define ETH_MACPMTCSR_GU (1<<9)
245#define ETH_MACPMTCSR_WFFRPR (1<<31)
251#define ETH_MACDBGR_MMRPEA (1<<0)
252#define ETH_MACDBGR_MSFRWCS (3<<1)
253#define ETH_MACDBGR_RFWRA (1<<4)
255#define ETH_MACDBGR_RFRCS_SHIFT 5
256#define ETH_MACDBGR_RFRCS (3<<ETH_MACDBGR_RFRCS_SHIFT)
257#define ETH_MACDBGR_RFRCS_IDLE (0<<ETH_MACDBGR_RFRCS_SHIFT)
258#define ETH_MACDBGR_RFRCS_RDATA (1<<ETH_MACDBGR_RFRCS_SHIFT)
259#define ETH_MACDBGR_RFRCS_RSTAT (2<<ETH_MACDBGR_RFRCS_SHIFT)
260#define ETH_MACDBGR_RFRCS_FLUSH (3<<ETH_MACDBGR_RFRCS_SHIFT)
262#define ETH_MACDBGR_RFFL_SHIFT 8
263#define ETH_MACDBGR_RFFL (3<<ETH_MACDBGR_RFFL_SHIFT)
264#define ETH_MACDBGR_RFFL_EMPTY (0<<ETH_MACDBGR_RFFL_SHIFT)
265#define ETH_MACDBGR_RFFL_BELOW (1<<ETH_MACDBGR_RFFL_SHIFT)
266#define ETH_MACDBGR_RFFL_ABOVE (2<<ETH_MACDBGR_RFFL_SHIFT)
267#define ETH_MACDBGR_RFFL_FULL (3<<ETH_MACDBGR_RFFL_SHIFT)
269#define ETH_MACDBGR_MMTEA (1<<16)
271#define ETH_MACDBGR_MTFCS_SHIFT 17
272#define ETH_MACDBGR_MTFCS (3 << ETH_MACDBGR_MTFCS_SHIFT)
273#define ETH_MACDBGR_MTFCS_IDLE (0 << ETH_MACDBGR_MTFCS_SHIFT)
274#define ETH_MACDBGR_MTFCS_WAIT (1 << ETH_MACDBGR_MTFCS_SHIFT)
275#define ETH_MACDBGR_MTFCS_PAUSE (2 << ETH_MACDBGR_MTFCS_SHIFT)
276#define ETH_MACDBGR_MTFCS_TRANSFER (3 << ETH_MACDBGR_MTFCS_SHIFT)
278#define ETH_MACDBGR_MTP (1<<19)
280#define ETH_MACDBGR_TFRS_SHIFT 20
281#define ETH_MACDBGR_TFRS (3<<ETH_MACDBGR_TFRS_SHIFT)
282#define ETH_MACDBGR_TFRS_IDLE (0<<ETH_MACDBGR_TFRS_SHIFT)
283#define ETH_MACDBGR_TFRS_READ (1<<ETH_MACDBGR_TFRS_SHIFT)
284#define ETH_MACDBGR_TFRS_WAIT (2<<ETH_MACDBGR_TFRS_SHIFT)
285#define ETH_MACDBGR_TFRS_FLUSH (3<<ETH_MACDBGR_TFRS_SHIFT)
287#define ETH_MACDBGR_TFWA (1<<22)
288#define ETH_MACDBGR_TFNE (1<<24)
289#define ETH_MACDBGR_TFF (1<<25)
295#define ETH_MACSR_PMTS (1<<3)
296#define ETH_MACSR_MMCS (1<<4)
297#define ETH_MACSR_MMCRS (1<<5)
298#define ETH_MACSR_MMCTS (1<<6)
299#define ETH_MACSR_TSTS (1<<9)
305#define ETH_MACIMR_PMTIM (1<<3)
306#define ETH_MACIMR_TSTIM (1<<9)
311#define ETH_MACA0HR_MACA0H (0xFFFF<<0)
312#define ETH_MACA0HR_MO (1<<31)
317#define ETH_MACAHR_MACAH (0xFFFF<<0)
318#define ETH_MACAHR_MBC_ALL (63<<24)
319#define ETH_MACAHR_MBC_0 (1<<24)
320#define ETH_MACAHR_MBC_1 (1<<25)
321#define ETH_MACAHR_MBC_2 (1<<26)
322#define ETH_MACAHR_MBC_3 (1<<27)
323#define ETH_MACAHR_MBC_4 (1<<28)
324#define ETH_MACAHR_MBC_5 (1<<29)
325#define ETH_MACAHR_SA (1<<30)
326#define ETH_MACAHR_AE (1<<31)
331#define ETH_MMCCR_CR (1<<0)
332#define ETH_MMCCR_CSR (1<<1)
333#define ETH_MMCCR_ROR (1<<2)
334#define ETH_MMCCR_MCF (1<<3)
335#define ETH_MMCCR_MCP (1<<4)
336#define ETH_MMCCR_MCFHP (1<<5)
342#define ETH_MMCRIR_RFCES (1<<5)
343#define ETH_MMCRIR_RFAES (1<<6)
344#define ETH_MMCRIR_RGUFS (1<<17)
349#define ETH_MMCTIR_TGFSCS (1<<14)
350#define ETH_MMCTIR_TGFMSCS (1<<15)
351#define ETH_MMCTIR_TGFS (1<<21)
356#define ETH_MMCRIMR_RFCEM (1<<5)
357#define ETH_MMCRIMR_RFAEM (1<<6)
358#define ETH_MMCRIMR_RGUFM (1<<17)
363#define ETH_MMCTIMR_TGFSCS (1<<14)
364#define ETH_MMCTIMR_TGFMSCS (1<<15)
365#define ETH_MMCTIMR_TGFS (1<<21)
370#define ETH_PTPTSCR_TSE (1<<0)
371#define ETH_PTPTSCR_TSFCU (1<<1)
372#define ETH_PTPTSCR_TSSTI (1<<2)
373#define ETH_PTPTSCR_TSSTU (1<<3)
374#define ETH_PTPTSCR_TSITE (1<<4)
375#define ETH_PTPTSCR_TTSARU (1<<5)
378#define ETH_PTPTSCR_TSSARFE (1<<8)
379#define ETH_PTPTSCR_TSSSR (1<<9)
380#define ETH_PTPTSCR_TSPTPPSV2E (1<<10)
381#define ETH_PTPTSCR_TSSPTPOEFE (1<<11)
382#define ETH_PTPTSCR_TSSIPV6FE (1<<12)
383#define ETH_PTPTSCR_TSSIPV4FE (1<<13)
384#define ETH_PTPTSCR_TSSEME (1<<14)
385#define ETH_PTPTSCR_TSSMRME (1<<15)
387#define ETH_PTPTSCR_TSCNT_SHIFT 16
388#define ETH_PTPTSCR_TSCNT (3 << ETH_PTPTSCR_TSCNT_SHIFT)
389#define ETH_PTPTSCR_TSCNT_ORD (0 << ETH_PTPTSCR_TSCNT_SHIFT)
390#define ETH_PTPTSCR_TSCNT_BOUND (1 << ETH_PTPTSCR_TSCNT_SHIFT)
391#define ETH_PTPTSCR_TSCNT_ETETC (2 << ETH_PTPTSCR_TSCNT_SHIFT)
392#define ETH_PTPTSCR_TSCNT_PTPTC (3 << ETH_PTPTSCR_TSCNT_SHIFT)
394#define ETH_PTPTSCR_TSPFFMAE (1<<18)
400#define ETH_PTPSSIR_STSSI 0xFF
405#define ETH_PTPTSLR_STSS 0x7FFFFFFF
406#define ETH_PTPTSLR_STPNS (1<<31)
411#define ETH_PTPTSLUR_TSUSS 0x7FFFFFFF
412#define ETH_PTPTSLUR_TSUPNS (1<<31)
418#define ETH_PTPTSSR_TSSO (1<<0)
419#define ETH_PTPTSSR_TSTTR (1<<1)
426#define ETH_PTPPPSCR_PPSFREQ_MASK (0x0F<<0)
427#define ETH_PTPPPSCR_PPSFREQ_1HZ (0x00<<0)
428#define ETH_PTPPPSCR_PPSFREQ_2HZ (0x01<<0)
429#define ETH_PTPPPSCR_PPSFREQ_4HZ (0x02<<0)
430#define ETH_PTPPPSCR_PPSFREQ_8HZ (0x03<<0)
431#define ETH_PTPPPSCR_PPSFREQ_16HZ (0x04<<0)
432#define ETH_PTPPPSCR_PPSFREQ_32HZ (0x05<<0)
433#define ETH_PTPPPSCR_PPSFREQ_64HZ (0x06<<0)
434#define ETH_PTPPPSCR_PPSFREQ_128HZ (0x07<<0)
435#define ETH_PTPPPSCR_PPSFREQ_256HZ (0x08<<0)
436#define ETH_PTPPPSCR_PPSFREQ_512HZ (0x09<<0)
437#define ETH_PTPPPSCR_PPSFREQ_1024HZ (0x0A<<0)
438#define ETH_PTPPPSCR_PPSFREQ_2048HZ (0x0B<<0)
439#define ETH_PTPPPSCR_PPSFREQ_4096HZ (0x0C<<0)
440#define ETH_PTPPPSCR_PPSFREQ_8192HZ (0x0D<<0)
441#define ETH_PTPPPSCR_PPSFREQ_16384HZ (0x0E<<0)
442#define ETH_PTPPPSCR_PPSFREQ_32768HZ (0x0F<<0)
448#define ETH_DMABMR_SR (1<<0)
449#define ETH_DMABMR_DA (1<<1)
451#define ETH_DMABMR_DSL_SHIFT 2
452#define ETH_DMABMR_DSL (0x1F << ETH_DMABR_DSL_SHIFT)
454#define ETH_DMABMR_EDFE (1<<7)
456#define ETH_DMABMR_PBL_SHIFT 8
457#define ETH_DMABMR_PBL (0x3F << ETH_DMABR_PBL_SHIFT)
459#define ETH_DMABMR_PM_SHIFT 14
460#define ETH_DMABMR_PM (0x03 << ETH_DMABMR_PM_SHIFT)
461#define ETH_DMABMR_PM_1_1 (0 << ETH_DMABMR_PM_SHIFT)
462#define ETH_DMABMR_PM_2_1 (1 << ETH_DMABMR_PM_SHIFT)
463#define ETH_DMABMR_PM_3_1 (2 << ETH_DMABMR_PM_SHIFT)
464#define ETH_DMABMR_PM_4_1 (3 << ETH_DMABMR_PM_SHIFT)
466#define ETH_DMABMR_FB (1<<16)
468#define ETH_DMABMR_RDP_SHIFT 17
469#define ETH_DMABMR_RDP (0x3F << ETH_DMABMR_RDP_SHIFT)
471#define ETH_DMABMR_USP (1<<23)
472#define ETH_DMABMR_FPM (1<<24)
473#define ETH_DMABMR_AAB (1<<25)
474#define ETH_DMABMR_MB (1<<26)
479#define ETH_DMASR_TS (1<<0)
480#define ETH_DMASR_TPSS (1<<1)
481#define ETH_DMASR_TBUS (1<<2)
482#define ETH_DMASR_TJTS (1<<3)
483#define ETH_DMASR_ROS (1<<4)
484#define ETH_DMASR_TUS (1<<5)
485#define ETH_DMASR_RS (1<<6)
486#define ETH_DMASR_RBUS (1<<7)
487#define ETH_DMASR_RPSS (1<<8)
488#define ETH_DMASR_RWTS (1<<9)
489#define ETH_DMASR_ETS (1<<10)
490#define ETH_DMASR_FBES (1<<13)
491#define ETH_DMASR_ERS (1<<14)
492#define ETH_DMASR_AIS (1<<15)
493#define ETH_DMASR_NIS (1<<16)
495#define ETH_DMASR_RPS_SHIFT 17
496#define ETH_DMASR_RPS (7<<ETH_DMASR_RPS_SHIFT)
497#define ETH_DMASR_RPS_STOP (0<<ETH_DMASR_RPS_SHIFT)
498#define ETH_DMASR_RPS_FETCH (1<<ETH_DMASR_RPS_SHIFT)
499#define ETH_DMASR_RPS_WAIT (3<<ETH_DMASR_RPS_SHIFT)
500#define ETH_DMASR_RPS_SUSPEND (4<<ETH_DMASR_RPS_SHIFT)
501#define ETH_DMASR_RPS_CLOSE (5<<ETH_DMASR_RPS_SHIFT)
502#define ETH_DMASR_RPS_TRANSFER (7<<ETH_DMASR_RPS_SHIFT)
504#define ETH_DMASR_TPS_SHIFT 20
505#define ETH_DMASR_TPS (7<<ETH_DMASR_TPS_SHIFT)
506#define ETH_DMASR_TPS_STOP (0<<ETH_DMASR_TPS_SHIFT)
507#define ETH_DMASR_TPS_FETCH (1<<ETH_DMASR_TPS_SHIFT)
508#define ETH_DMASR_TPS_WAIT (2<<ETH_DMASR_TPS_SHIFT)
509#define ETH_DMASR_TPS_TRANSFER (3<<ETH_DMASR_TPS_SHIFT)
510#define ETH_DMASR_TPS_SUSPEND (6<<ETH_DMASR_TPS_SHIFT)
511#define ETH_DMASR_TPS_CLOSE (7<<ETH_DMASR_TPS_SHIFT)
513#define ETH_DMASR_EBS_SHIFT 23
514#define ETH_DMASR_EBS (7<<ETH_DMASR_EBS_SHIFT)
516#define ETH_DMASR_MMCS (1<<27)
517#define ETH_DMASR_PMTS (1<<28)
518#define ETH_DMASR_TSTS (1<<29)
523#define ETH_DMAOMR_SR (1<<1)
524#define ETH_DMAOMR_OSF (1<<2)
526#define ETH_DMAOMR_RTC_SHIFT 3
527#define ETH_DMAOMR_RTC (3 << ETH_DMAOMR_RTC_SHIFT)
528#define ETH_DMAOMR_RTC_64 (0 << ETH_DMAOMR_RTC_SHIFT)
529#define ETH_DMAOMR_RTC_32 (1 << ETH_DMAOMR_RTC_SHIFT)
530#define ETH_DMAOMR_RTC_96 (2 << ETH_DMAOMR_RTC_SHIFT)
531#define ETH_DMAOMR_RTC_128 (3 << ETH_DMAOMR_RTC_SHIFT)
533#define ETH_DMAOMR_FUGF (1<<6)
534#define ETH_DMAOMR_FEF (1<<7)
535#define ETH_DMAOMR_ST (1<<13)
537#define ETH_DMAOMR_TTC_SHIFT 14
538#define ETH_DMAOMR_TTC (0x07 << ETH_DMAOMR_TTC_SHIFT)
539#define ETH_DMAOMR_TTC_64 (0 << ETH_DMAOMR_TTC_SHIFT)
540#define ETH_DMAOMR_TTC_128 (1 << ETH_DMAOMR_TTC_SHIFT)
541#define ETH_DMAOMR_TTC_192 (2 << ETH_DMAOMR_TTC_SHIFT)
542#define ETH_DMAOMR_TTC_256 (3 << ETH_DMAOMR_TTC_SHIFT)
543#define ETH_DMAOMR_TTC_40 (4 << ETH_DMAOMR_TTC_SHIFT)
544#define ETH_DMAOMR_TTC_32 (5 << ETH_DMAOMR_TTC_SHIFT)
545#define ETH_DMAOMR_TTC_24 (6 << ETH_DMAOMR_TTC_SHIFT)
546#define ETH_DMAOMR_TTC_16 (7 << ETH_DMAOMR_TTC_SHIFT)
548#define ETH_DMAOMR_FTF (1<<20)
549#define ETH_DMAOMR_TSF (1<<21)
550#define ETH_DMAOMR_DFRF (1<<24)
551#define ETH_DMAOMR_RSF (1<<25)
552#define ETH_DMAOMR_DTCEFD (1<<26)
557#define ETH_DMAIER_TIE (1<<0)
558#define ETH_DMAIER_TPSIE (1<<1)
559#define ETH_DMAIER_TBUIE (1<<2)
560#define ETH_DMAIER_TJTIE (1<<3)
561#define ETH_DMAIER_ROIE (1<<4)
562#define ETH_DMAIER_TUIE (1<<5)
563#define ETH_DMAIER_RIE (1<<6)
564#define ETH_DMAIER_RBUIE (1<<7)
565#define ETH_DMAIER_RPSIE (1<<8)
566#define ETH_DMAIER_RWTIE (1<<9)
567#define ETH_DMAIER_ETIE (1<<10)
568#define ETH_DMAIER_FBEIE (1<<13)
569#define ETH_DMAIER_ERIE (1<<14)
570#define ETH_DMAIER_AISE (1<<15)
571#define ETH_DMAIER_NISE (1<<16)
576#define ETH_DMAMFBOCR_MFC_SHIFT 0
577#define ETH_DMAMFBOCR_MFC (0xFFFF << ETH_DMAMFBOCR_MFC_SHIFT)
578#define ETH_DMAMFBOCR_OMFC (1<<16)
579#define ETH_DMAMFBOCR_MFA (0x7FF << ETH_DMAMFBOCR_MFA_SHIFT)
580#define ETH_DMAMFBOCR_OFOC (1<<28)
586#define ETH_DMARSWTR_RSWTC 0xFF
593#define ETH_DES_STD_SIZE 16
594#define ETH_DES_EXT_SIZE 32
598#define ETH_TDES0_DB (1<<0)
599#define ETH_TDES0_UF (1<<1)
600#define ETH_TDES0_ED (1<<2)
602#define ETH_TDES0_CC_SHIFT 3
603#define ETH_TDES0_CC (0x0F << ETH_TDES0_CC_SHIFT)
605#define ETH_TDES0_VF (1<<7)
606#define ETH_TDES0_EC (1<<8)
607#define ETH_TDES0_LCO (1<<9)
608#define ETH_TDES0_NC (1<<10)
609#define ETH_TDES0_LCA (1<<11)
610#define ETH_TDES0_IPE (1<<12)
611#define ETH_TDES0_FF (1<<13)
612#define ETH_TDES0_JT (1<<14)
613#define ETH_TDES0_ES (1<<15)
614#define ETH_TDES0_IHE (1<<16)
615#define ETH_TDES0_TTSS (1<<17)
616#define ETH_TDES0_TCH (1<<20)
617#define ETH_TDES0_TER (1<<21)
619#define ETH_TDES0_CIC_SHIFT 22
620#define ETH_TDES0_CIC (3<<ETH_TDES0_CIC_SHIFT)
621#define ETH_TDES0_CIC_DISABLED (0<<ETH_TDES0_CIC_SHIFT)
622#define ETH_TDES0_CIC_IP (1<<ETH_TDES0_CIC_SHIFT)
623#define ETH_TDES0_CIC_IPPL (2<<ETH_TDES0_CIC_SHIFT)
624#define ETH_TDES0_CIC_IPPLPH (3<<ETH_TDES0_CIC_SHIFT)
626#define ETH_TDES0_TTSE (1<<25)
627#define ETH_TDES0_DP (1<<26)
628#define ETH_TDES0_DC (1<<27)
629#define ETH_TDES0_FS (1<<28)
630#define ETH_TDES0_LS (1<<29)
631#define ETH_TDES0_IC (1<<30)
632#define ETH_TDES0_OWN (1<<31)
637#define ETH_TDES1_TBS1_SHIFT 0
638#define ETH_TDES1_TBS1 (0x1FFF<<ETH_TDES1_TBS1_SHIFT)
640#define ETH_TDES1_TBS2_SHIFT 16
641#define ETH_TDES1_TBS2 (0x1FFF<<ETH_TDES1_TBS1_SHIFT)
651#define ETH_RDES0_PCE (1<<0)
652#define ETH_RDES0_ESA (1<<0)
653#define ETH_RDES0_CE (1<<1)
654#define ETH_RDES0_DE (1<<2)
655#define ETH_RDES0_RE (1<<3)
656#define ETH_RDES0_RWT (1<<4)
657#define ETH_RDES0_FT (1<<5)
658#define ETH_RDES0_LCO (1<<6)
659#define ETH_RDES0_IPHCE (1<<7)
660#define ETH_RDES0_TSV (1<<7)
661#define ETH_RDES0_LS (1<<8)
662#define ETH_RDES0_FS (1<<9)
663#define ETH_RDES0_VLAN (1<<10)
664#define ETH_RDES0_OE (1<<11)
665#define ETH_RDES0_LE (1<<12)
666#define ETH_RDES0_SAF (1<<13)
667#define ETH_RDES0_DCE (1<<14)
668#define ETH_RDES0_ES (1<<15)
670#define ETH_RDES0_FL_SHIFT 16
671#define ETH_RDES0_FL (0x3FFF<<ETH_RDES0_FL_SHIFT)
673#define ETH_RDES0_AFM (1<<30)
674#define ETH_RDES0_OWN (1<<31)
679#define ETH_RDES1_RBS1_SHIFT 0
680#define ETH_RDES1_RBS1 (0x1FFF<<ETH_RDES1_RBS1_SHIFT)
682#define ETH_RDES1_RCH (1<<14)
683#define ETH_RDES1_RER (1<<15)
685#define ETH_RDES1_RBS2_SHIFT 16
686#define ETH_RDES1_RBS2 (0x1FFF<<ETH_RDES1_RBS2_SHIFT)
688#define ETH_RDES1_DIC (1<<31)
693#define ETH_RDES4_IPPT_SHIFT 0
694#define ETH_RDES4_IPPT (7<<ETH_RDES4_IPPT_SHIFT)
695#define ETH_RDES4_IPPT_UNKNOWN (0<<ETH_RDES4_IPPT_SHIFT)
696#define ETH_RDES4_IPPT_UDP (1<<ETH_RDES4_IPPT_SHIFT)
697#define ETH_RDES4_IPPT_TCP (2<<ETH_RDES4_IPPT_SHIFT)
698#define ETH_RDES4_IPPT_ICMP (3<<ETH_RDES4_IPPT_SHIFT)
700#define ETH_RDES4_IPHE (1<<3)
701#define ETH_RDES4_IPPE (1<<4)
702#define ETH_RDES4_IPCB (1<<5)
703#define ETH_RDES4_IPV4PR (1<<6)
704#define ETH_RDES4_IPV6PR (1<<7)
706#define ETH_RDES4_PMT_SHIFT 8
707#define ETH_RDES4_PMT (0x0F<<ETH_RDES4_PMT_SHIFT)
708#define ETH_RDES4_PMT_NO (0x00<<ETH_RDES4_PMT_SHIFT)
709#define ETH_RDES4_PMT_SYNC (0x01<<ETH_RDES4_PMT_SHIFT)
710#define ETH_RDES4_PMT_FOLLOW (0x02<<ETH_RDES4_PMT_SHIFT)
711#define ETH_RDES4_PMT_DLYRQ (0x03<<ETH_RDES4_PMT_SHIFT)
712#define ETH_RDES4_PMT_DLYRSP (0x04<<ETH_RDES4_PMT_SHIFT)
713#define ETH_RDES4_PMT_PDLYRQ (0x05<<ETH_RDES4_PMT_SHIFT)
714#define ETH_RDES4_PMT_PDLYRSP (0x06<<ETH_RDES4_PMT_SHIFT)
715#define ETH_RDES4_PMT_PDLYRSPFUP (0x07<<ETH_RDES4_PMT_SHIFT)
717#define ETH_RDES4_PFT (1<<12)
718#define ETH_RDES4_PV (1<<13)
740void eth_smi_bit_op(uint8_t phy, uint8_t reg, uint16_t bits, uint16_t mask);
745void eth_desc_init(uint8_t *buf, uint32_t nTx, uint32_t nRx, uint32_t cTx,
746 uint32_t cRx,
bool isext);
747bool eth_tx(uint8_t *ppkt, uint32_t n);
748bool eth_rx(uint8_t *ppkt, uint32_t *len, uint32_t maxlen);
#define ETH_MACMIIAR_CR_HCLK_DIV_102
void eth_irq_enable(uint32_t reason)
Enable the Ethernet IRQ.
bool eth_irq_ack_pending(uint32_t reason)
Check if IRQ is pending, and acknowledge it.
#define ETH_MACMIIAR_CR_HCLK_DIV_42
bool eth_tx(uint8_t *ppkt, uint32_t n)
Transmit packet.
#define ETH_MACMIIAR_CR_HCLK_DIV_16
void eth_enable_checksum_offload(void)
Enable checksum offload feature.
void eth_desc_init(uint8_t *buf, uint32_t nTx, uint32_t nRx, uint32_t cTx, uint32_t cRx, bool isext)
Initialize buffers and descriptors.
void eth_irq_disable(uint32_t reason)
Disable the Ethernet IRQ.
void eth_smi_write(uint8_t phy, uint8_t reg, uint16_t data)
Write 16-bit register to the PHY.
bool eth_rx(uint8_t *ppkt, uint32_t *len, uint32_t maxlen)
Receive packet.
#define ETH_MACMIIAR_CR_HCLK_DIV_62
uint16_t eth_smi_read(uint8_t phy, uint8_t reg)
Read the 16-bit register from the PHY.
void eth_init(uint8_t phy, enum eth_clk clock)
Initialize ethernet.
void eth_smi_bit_clear(uint8_t phy, uint8_t reg, uint16_t clearbits)
Clear bits in the register.
bool eth_irq_is_pending(uint32_t reason)
Check if IRQ is pending.
void eth_set_mac(const uint8_t *mac)
Set MAC to the PHY.
void eth_start(void)
Start the Ethernet DMA processing.
void eth_smi_bit_set(uint8_t phy, uint8_t reg, uint16_t setbits)
Set bits in the register.
#define ETH_MACMIIAR_CR_HCLK_DIV_26
void eth_smi_bit_op(uint8_t phy, uint8_t reg, uint16_t bits, uint16_t mask)
Process the bit-operation on PHY register.