m467_eth_driver.h
Go to the documentation of this file.
1 /**
2  * @file m467_eth_driver.h
3  * @brief Nuvoton M467 Ethernet MAC driver
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2024 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneTCP Open.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26  *
27  * @author Oryx Embedded SARL (www.oryx-embedded.com)
28  * @version 2.4.4
29  **/
30 
31 #ifndef _M467_ETH_DRIVER_H
32 #define _M467_ETH_DRIVER_H
33 
34 //Dependencies
35 #include "core/nic.h"
36 
37 //Number of TX buffers
38 #ifndef M467_ETH_TX_BUFFER_COUNT
39  #define M467_ETH_TX_BUFFER_COUNT 3
40 #elif (M467_ETH_TX_BUFFER_COUNT < 1)
41  #error M467_ETH_TX_BUFFER_COUNT parameter is not valid
42 #endif
43 
44 //TX buffer size
45 #ifndef M467_ETH_TX_BUFFER_SIZE
46  #define M467_ETH_TX_BUFFER_SIZE 1536
47 #elif (M467_ETH_TX_BUFFER_SIZE != 1536)
48  #error M467_ETH_TX_BUFFER_SIZE parameter is not valid
49 #endif
50 
51 //Number of RX buffers
52 #ifndef M467_ETH_RX_BUFFER_COUNT
53  #define M467_ETH_RX_BUFFER_COUNT 6
54 #elif (M467_ETH_RX_BUFFER_COUNT < 1)
55  #error M467_ETH_RX_BUFFER_COUNT parameter is not valid
56 #endif
57 
58 //RX buffer size
59 #ifndef M467_ETH_RX_BUFFER_SIZE
60  #define M467_ETH_RX_BUFFER_SIZE 1536
61 #elif (M467_ETH_RX_BUFFER_SIZE != 1536)
62  #error M467_ETH_RX_BUFFER_SIZE parameter is not valid
63 #endif
64 
65 //Interrupt priority grouping
66 #ifndef M467_ETH_IRQ_PRIORITY_GROUPING
67  #define M467_ETH_IRQ_PRIORITY_GROUPING 3
68 #elif (M467_ETH_IRQ_PRIORITY_GROUPING < 0)
69  #error M467_ETH_IRQ_PRIORITY_GROUPING parameter is not valid
70 #endif
71 
72 //Ethernet interrupt group priority
73 #ifndef M467_ETH_IRQ_GROUP_PRIORITY
74  #define M467_ETH_IRQ_GROUP_PRIORITY 12
75 #elif (M467_ETH_IRQ_GROUP_PRIORITY < 0)
76  #error M467_ETH_IRQ_GROUP_PRIORITY parameter is not valid
77 #endif
78 
79 //Ethernet interrupt subpriority
80 #ifndef M467_ETH_IRQ_SUB_PRIORITY
81  #define M467_ETH_IRQ_SUB_PRIORITY 0
82 #elif (M467_ETH_IRQ_SUB_PRIORITY < 0)
83  #error M467_ETH_IRQ_SUB_PRIORITY parameter is not valid
84 #endif
85 
86 //EMAC registers
87 #define EMAC_MAC_CONFIG *((volatile uint32_t *) (EMAC_BASE + 0x0000))
88 #define EMAC_MAC_FRAME_FILTER *((volatile uint32_t *) (EMAC_BASE + 0x0004))
89 #define EMAC_GMII_ADDR *((volatile uint32_t *) (EMAC_BASE + 0x0010))
90 #define EMAC_GMII_DATA *((volatile uint32_t *) (EMAC_BASE + 0x0014))
91 #define EMAC_FLOW_CONTROL *((volatile uint32_t *) (EMAC_BASE + 0x0018))
92 #define EMAC_VLAN_TAG *((volatile uint32_t *) (EMAC_BASE + 0x001C))
93 #define EMAC_VERSION *((volatile uint32_t *) (EMAC_BASE + 0x0020))
94 #define EMAC_DEBUG *((volatile uint32_t *) (EMAC_BASE + 0x0024))
95 #define EMAC_PMT_CONTROL_STATUS *((volatile uint32_t *) (EMAC_BASE + 0x002C))
96 #define EMAC_INTERRUPT_STATUS *((volatile uint32_t *) (EMAC_BASE + 0x0038))
97 #define EMAC_INTERRUPT_MASK *((volatile uint32_t *) (EMAC_BASE + 0x003C))
98 #define EMAC_MAC_ADDR0_HIGH *((volatile uint32_t *) (EMAC_BASE + 0x0040))
99 #define EMAC_MAC_ADDR0_LOW *((volatile uint32_t *) (EMAC_BASE + 0x0044))
100 #define EMAC_MAC_ADDR1_HIGH *((volatile uint32_t *) (EMAC_BASE + 0x0048))
101 #define EMAC_MAC_ADDR1_LOW *((volatile uint32_t *) (EMAC_BASE + 0x004C))
102 #define EMAC_MAC_ADDR2_HIGH *((volatile uint32_t *) (EMAC_BASE + 0x0050))
103 #define EMAC_MAC_ADDR2_LOW *((volatile uint32_t *) (EMAC_BASE + 0x0054))
104 #define EMAC_MAC_ADDR3_HIGH *((volatile uint32_t *) (EMAC_BASE + 0x0058))
105 #define EMAC_MAC_ADDR3_LOW *((volatile uint32_t *) (EMAC_BASE + 0x005C))
106 #define EMAC_MAC_ADDR4_HIGH *((volatile uint32_t *) (EMAC_BASE + 0x0060))
107 #define EMAC_MAC_ADDR4_LOW *((volatile uint32_t *) (EMAC_BASE + 0x0064))
108 #define EMAC_MAC_ADDR5_HIGH *((volatile uint32_t *) (EMAC_BASE + 0x0068))
109 #define EMAC_MAC_ADDR5_LOW *((volatile uint32_t *) (EMAC_BASE + 0x006C))
110 #define EMAC_MAC_ADDR6_HIGH *((volatile uint32_t *) (EMAC_BASE + 0x0070))
111 #define EMAC_MAC_ADDR6_LOW *((volatile uint32_t *) (EMAC_BASE + 0x0074))
112 #define EMAC_MAC_ADDR7_HIGH *((volatile uint32_t *) (EMAC_BASE + 0x0078))
113 #define EMAC_MAC_ADDR7_LOW *((volatile uint32_t *) (EMAC_BASE + 0x007C))
114 #define EMAC_MAC_ADDR8_HIGH *((volatile uint32_t *) (EMAC_BASE + 0x0080))
115 #define EMAC_MAC_ADDR8_LOW *((volatile uint32_t *) (EMAC_BASE + 0x0084))
116 #define EMAC_WDOG_TIMEOUT *((volatile uint32_t *) (EMAC_BASE + 0x00DC))
117 #define EMAC_VLAN_INCL_REG *((volatile uint32_t *) (EMAC_BASE + 0x0584))
118 #define EMAC_TIMESTAMP_CONTROL *((volatile uint32_t *) (EMAC_BASE + 0x0700))
119 #define EMAC_SUB_SECOND_INCREMENT *((volatile uint32_t *) (EMAC_BASE + 0x0704))
120 #define EMAC_SYSTEM_TIME_SECONDS *((volatile uint32_t *) (EMAC_BASE + 0x0708))
121 #define EMAC_SYSTEM_TIME_NANOSECONDS *((volatile uint32_t *) (EMAC_BASE + 0x070C))
122 #define EMAC_SYSTEM_TIME_SECONDS_UPDATE *((volatile uint32_t *) (EMAC_BASE + 0x0710))
123 #define EMAC_SYSTEM_TIME_NANOSECONDS_UPDATE *((volatile uint32_t *) (EMAC_BASE + 0x0714))
124 #define EMAC_TIMESTAMP_ADDEND *((volatile uint32_t *) (EMAC_BASE + 0x0718))
125 #define EMAC_TARGET_TIME_SECONDS *((volatile uint32_t *) (EMAC_BASE + 0x071C))
126 #define EMAC_TARGET_TIME_NANOSECONDS *((volatile uint32_t *) (EMAC_BASE + 0x0720))
127 #define EMAC_SYSTEM_TIME_HIGHER_WORD_SECONDS *((volatile uint32_t *) (EMAC_BASE + 0x0724))
128 #define EMAC_TIMESTAMP_STATUS *((volatile uint32_t *) (EMAC_BASE + 0x0728))
129 #define EMAC_PPS_CONTROL *((volatile uint32_t *) (EMAC_BASE + 0x072C))
130 #define EMAC_PPS0_INTERVAL *((volatile uint32_t *) (EMAC_BASE + 0x0760))
131 #define EMAC_PPS0_WIDTH *((volatile uint32_t *) (EMAC_BASE + 0x0764))
132 #define EMAC_BUS_MODE *((volatile uint32_t *) (EMAC_BASE + 0x1000))
133 #define EMAC_TRANSMIT_POLL_DEMAND *((volatile uint32_t *) (EMAC_BASE + 0x1004))
134 #define EMAC_RECEIVE_POLL_DEMAND *((volatile uint32_t *) (EMAC_BASE + 0x1008))
135 #define EMAC_RECEIVE_DESCRIPTOR_LIST_ADDR *((volatile uint32_t *) (EMAC_BASE + 0x100C))
136 #define EMAC_TRANSMIT_DESCRIPTOR_LIST_ADDR *((volatile uint32_t *) (EMAC_BASE + 0x1010))
137 #define EMAC_STATUS *((volatile uint32_t *) (EMAC_BASE + 0x1014))
138 #define EMAC_OPERATION_MODE *((volatile uint32_t *) (EMAC_BASE + 0x1018))
139 #define EMAC_INTERRUPT_ENABLE *((volatile uint32_t *) (EMAC_BASE + 0x101C))
140 #define EMAC_MISSED_FRAME_AND_BUFFER_OVERFLOW_CNT *((volatile uint32_t *) (EMAC_BASE + 0x1020))
141 #define EMAC_RECEIVE_INTERRUPT_WATCHDOG_TIMER *((volatile uint32_t *) (EMAC_BASE + 0x1024))
142 #define EMAC_AHB_STATUS *((volatile uint32_t *) (EMAC_BASE + 0x102C))
143 #define EMAC_CURRENT_HOST_TRANSMIT_DESCRIPTOR *((volatile uint32_t *) (EMAC_BASE + 0x1048))
144 #define EMAC_CURRENT_HOST_RECEIVE_DESCRIPTOR *((volatile uint32_t *) (EMAC_BASE + 0x104C))
145 #define EMAC_CURRENT_HOST_TRANSMIT_BUFFER_ADDR *((volatile uint32_t *) (EMAC_BASE + 0x1050))
146 #define EMAC_CURRENT_HOST_RECEIVE_BUFFER_ADDR *((volatile uint32_t *) (EMAC_BASE + 0x1054))
147 #define EMAC_HW_FEATURE *((volatile uint32_t *) (EMAC_BASE + 0x1058))
148 
149 //MAC Configuration register
150 #define EMAC_MAC_CONFIG_SARC 0xF0000000
151 #define EMAC_MAC_CONFIG_TWOKPE 0x08000000
152 #define EMAC_MAC_CONFIG_CST 0x02000000
153 #define EMAC_MAC_CONFIG_WD 0x00800000
154 #define EMAC_MAC_CONFIG_JD 0x00400000
155 #define EMAC_MAC_CONFIG_JE 0x00100000
156 #define EMAC_MAC_CONFIG_IFG 0x000E0000
157 #define EMAC_MAC_CONFIG_DCRS 0x00010000
158 #define EMAC_MAC_CONFIG_FES 0x00004000
159 #define EMAC_MAC_CONFIG_DO 0x00002000
160 #define EMAC_MAC_CONFIG_LM 0x00001000
161 #define EMAC_MAC_CONFIG_DM 0x00000800
162 #define EMAC_MAC_CONFIG_IPC 0x00000400
163 #define EMAC_MAC_CONFIG_DR 0x00000200
164 #define EMAC_MAC_CONFIG_ACS 0x00000080
165 #define EMAC_MAC_CONFIG_BL 0x00000060
166 #define EMAC_MAC_CONFIG_DC 0x00000010
167 #define EMAC_MAC_CONFIG_TE 0x00000008
168 #define EMAC_MAC_CONFIG_RE 0x00000004
169 #define EMAC_MAC_CONFIG_PRELEN 0x00000003
170 
171 //MAC Frame Filter register
172 #define EMAC_MAC_FRAME_FILTER_RA 0x80000000
173 #define EMAC_MAC_FRAME_FILTER_VTFE 0x00010000
174 #define EMAC_MAC_FRAME_FILTER_SAF 0x00000200
175 #define EMAC_MAC_FRAME_FILTER_SAIF 0x00000100
176 #define EMAC_MAC_FRAME_FILTER_PCF 0x000000C0
177 #define EMAC_MAC_FRAME_FILTER_DBF 0x00000020
178 #define EMAC_MAC_FRAME_FILTER_PM 0x00000010
179 #define EMAC_MAC_FRAME_FILTER_DAIF 0x00000008
180 #define EMAC_MAC_FRAME_FILTER_PR 0x00000001
181 
182 //GMII Address register
183 #define EMAC_GMII_ADDR_PA 0x0000F800
184 #define EMAC_GMII_ADDR_GR 0x000007C0
185 #define EMAC_GMII_ADDR_CR 0x0000003C
186 #define EMAC_GMII_ADDR_CR_DIV_42 0x00000000
187 #define EMAC_GMII_ADDR_CR_DIV_62 0x00000004
188 #define EMAC_GMII_ADDR_CR_DIV_16 0x00000008
189 #define EMAC_GMII_ADDR_CR_DIV_26 0x0000000C
190 #define EMAC_GMII_ADDR_CR_DIV_102 0x00000010
191 #define EMAC_GMII_ADDR_CR_DIV_124 0x00000014
192 #define EMAC_GMII_ADDR_GW 0x00000002
193 #define EMAC_GMII_ADDR_GB 0x00000001
194 
195 //GMII Data register
196 #define EMAC_GMII_DATA_GD 0x0000FFFF
197 
198 //Flow Control register
199 #define EMAC_FLOW_CONTROL_PT 0xFFFF0000
200 #define EMAC_FLOW_CONTROL_DZQP 0x00000080
201 #define EMAC_FLOW_CONTROL_PLT 0x00000030
202 #define EMAC_FLOW_CONTROL_UP 0x00000008
203 #define EMAC_FLOW_CONTROL_RFE 0x00000004
204 #define EMAC_FLOW_CONTROL_TFE 0x00000002
205 #define EMAC_FLOW_CONTROL_FCA_BPA 0x00000001
206 
207 //VLAN Tag register
208 #define EMAC_VLAN_TAG_ESVL 0x00040000
209 #define EMAC_VLAN_TAG_VTIM 0x00020000
210 #define EMAC_VLAN_TAG_ETV 0x00010000
211 #define EMAC_VLAN_TAG_VL 0x0000FFFF
212 
213 //Debug register
214 #define EMAC_DEBUG_TXSTSFSTS 0x02000000
215 #define EMAC_DEBUG_TXFSTS 0x01000000
216 #define EMAC_DEBUG_TWCSTS 0x00400000
217 #define EMAC_DEBUG_TRCSTS 0x00300000
218 #define EMAC_DEBUG_TXPAUSED 0x00080000
219 #define EMAC_DEBUG_TFCSTS 0x00060000
220 #define EMAC_DEBUG_TPESTS 0x00010000
221 #define EMAC_DEBUG_RXFSTS 0x00000300
222 #define EMAC_DEBUG_RRCSTS 0x00000060
223 #define EMAC_DEBUG_RWCSTS 0x00000010
224 #define EMAC_DEBUG_RFCFCSTS 0x00000006
225 #define EMAC_DEBUG_RPESTS 0x00000001
226 
227 //PMT Control and Status register
228 #define EMAC_PMT_CONTROL_STATUS_MGKPRCVD 0x00000020
229 #define EMAC_PMT_CONTROL_STATUS_MGKPKTEN 0x00000002
230 #define EMAC_PMT_CONTROL_STATUS_PWRDWN 0x00000001
231 
232 //Interrupt register
233 #define EMAC_INTERRUPT_STATUS_TSIS 0x00000200
234 #define EMAC_INTERRUPT_STATUS_PMTIS 0x00000008
235 
236 //Interrupt Mask register
237 #define EMAC_INTERRUPT_MASK_TSIM 0x00000200
238 #define EMAC_INTERRUPT_MASK_PMTIM 0x00000008
239 
240 //MAC Address0 High register
241 #define EMAC_MAC_ADDR0_HIGH_AE 0x80000000
242 #define EMAC_MAC_ADDR0_HIGH_ADDRHI 0x0000FFFF
243 
244 //MAC Address0 Low register
245 #define EMAC_MAC_ADDR0_LOW_ADDRLO 0xFFFFFFFF
246 
247 //MAC Address1 High register
248 #define EMAC_MAC_ADDR1_HIGH_AE 0x80000000
249 #define EMAC_MAC_ADDR1_HIGH_SA 0x40000000
250 #define EMAC_MAC_ADDR1_HIGH_MBC 0x3F000000
251 #define EMAC_MAC_ADDR1_HIGH_ADDRHI 0x0000FFFF
252 
253 //MAC Address1 Low register
254 #define EMAC_MAC_ADDR1_LOW_ADDRLO 0xFFFFFFFF
255 
256 //MAC Address2 High register
257 #define EMAC_MAC_ADDR2_HIGH_AE 0x80000000
258 #define EMAC_MAC_ADDR2_HIGH_SA 0x40000000
259 #define EMAC_MAC_ADDR2_HIGH_MBC 0x3F000000
260 #define EMAC_MAC_ADDR2_HIGH_ADDRHI 0x0000FFFF
261 
262 //MAC Address2 Low register
263 #define EMAC_MAC_ADDR2_LOW_ADDRLO 0xFFFFFFFF
264 
265 //MAC Address3 High register
266 #define EMAC_MAC_ADDR3_HIGH_AE 0x80000000
267 #define EMAC_MAC_ADDR3_HIGH_SA 0x40000000
268 #define EMAC_MAC_ADDR3_HIGH_MBC 0x3F000000
269 #define EMAC_MAC_ADDR3_HIGH_ADDRHI 0x0000FFFF
270 
271 //MAC Address3 Low register
272 #define EMAC_MAC_ADDR3_LOW_ADDRLO 0xFFFFFFFF
273 
274 //MAC Address4 High register
275 #define EMAC_MAC_ADDR4_HIGH_AE 0x80000000
276 #define EMAC_MAC_ADDR4_HIGH_SA 0x40000000
277 #define EMAC_MAC_ADDR4_HIGH_MBC 0x3F000000
278 #define EMAC_MAC_ADDR4_HIGH_ADDRHI 0x0000FFFF
279 
280 //MAC Address4 Low register
281 #define EMAC_MAC_ADDR4_LOW_ADDRLO 0xFFFFFFFF
282 
283 //MAC Address5 High register
284 #define EMAC_MAC_ADDR5_HIGH_AE 0x80000000
285 #define EMAC_MAC_ADDR5_HIGH_SA 0x40000000
286 #define EMAC_MAC_ADDR5_HIGH_MBC 0x3F000000
287 #define EMAC_MAC_ADDR5_HIGH_ADDRHI 0x0000FFFF
288 
289 //MAC Address5 Low register
290 #define EMAC_MAC_ADDR5_LOW_ADDRLO 0xFFFFFFFF
291 
292 //MAC Address6 High register
293 #define EMAC_MAC_ADDR6_HIGH_AE 0x80000000
294 #define EMAC_MAC_ADDR6_HIGH_SA 0x40000000
295 #define EMAC_MAC_ADDR6_HIGH_MBC 0x3F000000
296 #define EMAC_MAC_ADDR6_HIGH_ADDRHI 0x0000FFFF
297 
298 //MAC Address6 Low register
299 #define EMAC_MAC_ADDR6_LOW_ADDRLO 0xFFFFFFFF
300 
301 //MAC Address7 High register
302 #define EMAC_MAC_ADDR7_HIGH_AE 0x80000000
303 #define EMAC_MAC_ADDR7_HIGH_SA 0x40000000
304 #define EMAC_MAC_ADDR7_HIGH_MBC 0x3F000000
305 #define EMAC_MAC_ADDR7_HIGH_ADDRHI 0x0000FFFF
306 
307 //MAC Address7 Low register
308 #define EMAC_MAC_ADDR7_LOW_ADDRLO 0xFFFFFFFF
309 
310 //MAC Address8 High register
311 #define EMAC_MAC_ADDR8_HIGH_AE 0x80000000
312 #define EMAC_MAC_ADDR8_HIGH_SA 0x40000000
313 #define EMAC_MAC_ADDR8_HIGH_MBC 0x3F000000
314 #define EMAC_MAC_ADDR8_HIGH_ADDRHI 0x0000FFFF
315 
316 //MAC Address8 Low register
317 #define EMAC_MAC_ADDR8_LOW_ADDRLO 0xFFFFFFFF
318 
319 //Watchdog Timeout register
320 #define EMAC_WDOG_TIMEOUT_PWE 0x00010000
321 #define EMAC_WDOG_TIMEOUT_WTO 0x00003FFF
322 
323 //VLAN Tag Inclusion or Replacement register
324 #define EMAC_VLAN_INCL_REG_CSVL 0x00080000
325 #define EMAC_VLAN_INCL_REG_VLP 0x00040000
326 #define EMAC_VLAN_INCL_REG_VLC 0x00030000
327 #define EMAC_VLAN_INCL_REG_VLT 0x0000FFFF
328 
329 //Timestamp Control register
330 #define EMAC_TIMESTAMP_CONTROL_TSENMACADDR 0x00040000
331 #define EMAC_TIMESTAMP_CONTROL_SNAPTYPSEL 0x00030000
332 #define EMAC_TIMESTAMP_CONTROL_TSMSTRENA 0x00008000
333 #define EMAC_TIMESTAMP_CONTROL_TSEVNTENA 0x00004000
334 #define EMAC_TIMESTAMP_CONTROL_TSIPV4ENA 0x00002000
335 #define EMAC_TIMESTAMP_CONTROL_TSIPV6ENA 0x00001000
336 #define EMAC_TIMESTAMP_CONTROL_TSIPENA 0x00000800
337 #define EMAC_TIMESTAMP_CONTROL_TSVER2ENA 0x00000400
338 #define EMAC_TIMESTAMP_CONTROL_TSCTRLSSR 0x00000200
339 #define EMAC_TIMESTAMP_CONTROL_TSENALL 0x00000100
340 #define EMAC_TIMESTAMP_CONTROL_TSADDREG 0x00000020
341 #define EMAC_TIMESTAMP_CONTROL_TSTRIG 0x00000010
342 #define EMAC_TIMESTAMP_CONTROL_TSUPDT 0x00000008
343 #define EMAC_TIMESTAMP_CONTROL_TSINIT 0x00000004
344 #define EMAC_TIMESTAMP_CONTROL_TSCFUPDT 0x00000002
345 #define EMAC_TIMESTAMP_CONTROL_TSENA 0x00000001
346 
347 //Sub-Second Increment register
348 #define EMAC_SUB_SECOND_INCREMENT_SSINC 0x000000FF
349 
350 //System Time Seconds register
351 #define EMAC_SYSTEM_TIME_SECONDS_TSS 0xFFFFFFFF
352 
353 //System Time Nanoseconds register
354 #define EMAC_SYSTEM_TIME_NANOSECONDS_TSSS 0x7FFFFFFF
355 
356 //System Time Seconds Update register
357 #define EMAC_SYSTEM_TIME_SECONDS_UPDATE_TSS 0xFFFFFFFF
358 
359 //System Time Nanoseconds Update register
360 #define EMAC_SYSTEM_TIME_NANOSECONDS_UPDATE_ADDSUB 0x80000000
361 #define EMAC_SYSTEM_TIME_NANOSECONDS_UPDATE_TSSS 0x7FFFFFFF
362 
363 //Timestamp Addend register
364 #define EMAC_TIMESTAMP_ADDEND_TSAR 0xFFFFFFFF
365 
366 //Target Time Seconds register
367 #define EMAC_TARGET_TIME_SECONDS_TSTR 0xFFFFFFFF
368 
369 //Target Time Nanoseconds register
370 #define EMAC_TARGET_TIME_NANOSECONDS_TTSLO 0xFFFFFFFF
371 
372 //System Time Higher Word Seconds register
373 #define EMAC_SYSTEM_TIME_HIGHER_WORD_SECONDS_TSHWR 0x0000FFFF
374 
375 //Timestamp Status register
376 #define EMAC_TIMESTAMP_STATUS_ATSSTN 0x000F0000
377 #define EMAC_TIMESTAMP_STATUS_TSTRGTERR 0x00000008
378 #define EMAC_TIMESTAMP_STATUS_TSTARGT 0x00000002
379 #define EMAC_TIMESTAMP_STATUS_TSSOVF 0x00000001
380 
381 //PPS Control register
382 #define EMAC_PPS_CONTROL_TRGTMODSEL0 0x00000060
383 #define EMAC_PPS_CONTROL_PPSEN0 0x00000010
384 #define EMAC_PPS_CONTROL_PPSCTRL_PPSCMD 0x0000000F
385 
386 //PPS0 Interval register
387 #define EMAC_PPS0_INTERVAL_PPSINT 0xFFFFFFFF
388 
389 //PPS0 Width register
390 #define EMAC_PPS0_WIDTH_PPSWIDTH 0xFFFFFFFF
391 
392 //Bus Mode register
393 #define EMAC_BUS_MODE_AAB 0x02000000
394 #define EMAC_BUS_MODE_PBLX8 0x01000000
395 #define EMAC_BUS_MODE_USP 0x00800000
396 #define EMAC_BUS_MODE_RPBL 0x007E0000
397 #define EMAC_BUS_MODE_RPBL_1 0x00020000
398 #define EMAC_BUS_MODE_RPBL_2 0x00040000
399 #define EMAC_BUS_MODE_RPBL_4 0x00080000
400 #define EMAC_BUS_MODE_RPBL_8 0x00100000
401 #define EMAC_BUS_MODE_RPBL_16 0x00200000
402 #define EMAC_BUS_MODE_RPBL_32 0x00400000
403 #define EMAC_BUS_MODE_FB 0x00010000
404 #define EMAC_BUS_MODE_PBL 0x00003F00
405 #define EMAC_BUS_MODE_PBL_1 0x00000100
406 #define EMAC_BUS_MODE_PBL_2 0x00000200
407 #define EMAC_BUS_MODE_PBL_4 0x00000400
408 #define EMAC_BUS_MODE_PBL_8 0x00000800
409 #define EMAC_BUS_MODE_PBL_16 0x00001000
410 #define EMAC_BUS_MODE_PBL_32 0x00002000
411 #define EMAC_BUS_MODE_ATDS 0x00000080
412 #define EMAC_BUS_MODE_DSL 0x0000007C
413 #define EMAC_BUS_MODE_DSL_0 0x00000000
414 #define EMAC_BUS_MODE_DSL_1 0x00000004
415 #define EMAC_BUS_MODE_DSL_2 0x00000008
416 #define EMAC_BUS_MODE_DSL_4 0x00000010
417 #define EMAC_BUS_MODE_DSL_8 0x00000020
418 #define EMAC_BUS_MODE_DSL_16 0x00000040
419 #define EMAC_BUS_MODE_SWR 0x00000001
420 
421 //Transmit Poll Demand register
422 #define EMAC_TRANSMIT_POLL_DEMAND_TPD 0xFFFFFFFF
423 
424 //Receive Poll Demand register
425 #define EMAC_RECEIVE_POLL_DEMAND_RPD 0xFFFFFFFF
426 
427 //Receive Descriptor List Address register
428 #define EMAC_RECEIVE_DESCRIPTOR_LIST_ADDR_RDESLA 0xFFFFFFFF
429 
430 //Transmit Descriptor List Address register
431 #define EMAC_TRANSMIT_DESCRIPTOR_LIST_ADDR_TDESLA 0xFFFFFFFF
432 
433 //Status register
434 #define EMAC_STATUS_TTI 0x20000000
435 #define EMAC_STATUS_GPI 0x10000000
436 #define EMAC_STATUS_EB 0x03800000
437 #define EMAC_STATUS_TS 0x00700000
438 #define EMAC_STATUS_RS 0x000E0000
439 #define EMAC_STATUS_NIS 0x00010000
440 #define EMAC_STATUS_AIS 0x00008000
441 #define EMAC_STATUS_ERI 0x00004000
442 #define EMAC_STATUS_FBI 0x00002000
443 #define EMAC_STATUS_ETI 0x00000400
444 #define EMAC_STATUS_RWT 0x00000200
445 #define EMAC_STATUS_RPS 0x00000100
446 #define EMAC_STATUS_RU 0x00000080
447 #define EMAC_STATUS_RI 0x00000040
448 #define EMAC_STATUS_UNF 0x00000020
449 #define EMAC_STATUS_OVF 0x00000010
450 #define EMAC_STATUS_TJT 0x00000008
451 #define EMAC_STATUS_TU 0x00000004
452 #define EMAC_STATUS_TPS 0x00000002
453 #define EMAC_STATUS_TI 0x00000001
454 
455 //Operation Mode register
456 #define EMAC_OPERATION_MODE_DT 0x04000000
457 #define EMAC_OPERATION_MODE_RSF 0x02000000
458 #define EMAC_OPERATION_MODE_DFF 0x01000000
459 #define EMAC_OPERATION_MODE_TSF 0x00200000
460 #define EMAC_OPERATION_MODE_FTF 0x00100000
461 #define EMAC_OPERATION_MODE_TTC 0x0001C000
462 #define EMAC_OPERATION_MODE_ST 0x00002000
463 #define EMAC_OPERATION_MODE_RFD 0x00001800
464 #define EMAC_OPERATION_MODE_RFA 0x00000600
465 #define EMAC_OPERATION_MODE_EFC 0x00000100
466 #define EMAC_OPERATION_MODE_FEF 0x00000080
467 #define EMAC_OPERATION_MODE_FUF 0x00000040
468 #define EMAC_OPERATION_MODE_DGF 0x00000020
469 #define EMAC_OPERATION_MODE_RTC 0x00000018
470 #define EMAC_OPERATION_MODE_OSF 0x00000004
471 #define EMAC_OPERATION_MODE_SR 0x00000002
472 
473 //Interrupt Enable register
474 #define EMAC_INTERRUPT_ENABLE_NIE 0x00010000
475 #define EMAC_INTERRUPT_ENABLE_AIE 0x00008000
476 #define EMAC_INTERRUPT_ENABLE_ERE 0x00004000
477 #define EMAC_INTERRUPT_ENABLE_FBE 0x00002000
478 #define EMAC_INTERRUPT_ENABLE_ETE 0x00000400
479 #define EMAC_INTERRUPT_ENABLE_RWE 0x00000200
480 #define EMAC_INTERRUPT_ENABLE_RSE 0x00000100
481 #define EMAC_INTERRUPT_ENABLE_RUE 0x00000080
482 #define EMAC_INTERRUPT_ENABLE_RIE 0x00000040
483 #define EMAC_INTERRUPT_ENABLE_UNE 0x00000020
484 #define EMAC_INTERRUPT_ENABLE_OVE 0x00000010
485 #define EMAC_INTERRUPT_ENABLE_TJE 0x00000008
486 #define EMAC_INTERRUPT_ENABLE_TUE 0x00000004
487 #define EMAC_INTERRUPT_ENABLE_TSE 0x00000002
488 #define EMAC_INTERRUPT_ENABLE_TIE 0x00000001
489 
490 //Missed Frame and Buffer Overflow Counter register
491 #define EMAC_MISSED_FRAME_AND_BUFFER_OVERFLOW_CNT_OVFCNTOVF 0x10000000
492 #define EMAC_MISSED_FRAME_AND_BUFFER_OVERFLOW_CNT_OVFFRMCNT 0x0FFE0000
493 #define EMAC_MISSED_FRAME_AND_BUFFER_OVERFLOW_CNT_MISCNTOVF 0x00010000
494 #define EMAC_MISSED_FRAME_AND_BUFFER_OVERFLOW_CNT_MISFRMCNT 0x0000FFFF
495 
496 //Receive Interrupt Watchdog Timer register
497 #define EMAC_RECEIVE_INTERRUPT_WATCHDOG_TIMER_RIWT 0x000000FF
498 
499 //AHB Status register
500 #define EMAC_AHB_STATUS_AXIRDSTS 0x00000002
501 #define EMAC_AHB_STATUS_AXWHSTS 0x00000001
502 
503 //Current Host Transmit Descriptor register
504 #define EMAC_CURRENT_HOST_TRANSMIT_DESCRIPTOR_CURTDESAPTR 0xFFFFFFFF
505 
506 //Current Host Receive Descriptor register
507 #define EMAC_CURRENT_HOST_RECEIVE_DESCRIPTOR_CURRDESAPTR 0xFFFFFFFF
508 
509 //Current Host Transmit Buffer Address register
510 #define EMAC_CURRENT_HOST_TRANSMIT_BUFFER_ADDR_CURTBUFAPTR 0xFFFFFFFF
511 
512 //Current Host Receive Buffer Address register
513 #define EMAC_CURRENT_HOST_RECEIVE_BUFFER_ADDR_CURRBUFAPTR 0xFFFFFFFF
514 
515 //HW Feature register
516 #define EMAC_HW_FEATURE_ACTPHYIF 0x70000000
517 #define EMAC_HW_FEATURE_SAVLANINS 0x08000000
518 #define EMAC_HW_FEATURE_FLEXIPPSEN 0x04000000
519 #define EMAC_HW_FEATURE_INTTSEN 0x02000000
520 #define EMAC_HW_FEATURE_ENHDESSEL 0x01000000
521 #define EMAC_HW_FEATURE_TXCHCNT 0x00C00000
522 #define EMAC_HW_FEATURE_RXCHCNT 0x00300000
523 #define EMAC_HW_FEATURE_RXFIFOSIZE 0x00080000
524 #define EMAC_HW_FEATURE_RXTYP2COE 0x00040000
525 #define EMAC_HW_FEATURE_RXTYP1COE 0x00020000
526 #define EMAC_HW_FEATURE_TXCOESEL 0x00010000
527 #define EMAC_HW_FEATURE_EEESEL 0x00004000
528 #define EMAC_HW_FEATURE_TSVER2SEL 0x00002000
529 #define EMAC_HW_FEATURE_TSVER1SEL 0x00001000
530 #define EMAC_HW_FEATURE_MMCSEL 0x00000800
531 #define EMAC_HW_FEATURE_MGKSEL 0x00000400
532 #define EMAC_HW_FEATURE_RWKSEL 0x00000200
533 #define EMAC_HW_FEATURE_SMASEL 0x00000100
534 #define EMAC_HW_FEATURE_L3L4FLTREN 0x00000080
535 #define EMAC_HW_FEATURE_PCSSEL 0x00000040
536 #define EMAC_HW_FEATURE_ADDMACADRSEL 0x00000020
537 #define EMAC_HW_FEATURE_HASHSEL 0x00000010
538 #define EMAC_HW_FEATURE_EXTHASHEN 0x00000008
539 #define EMAC_HW_FEATURE_HDSEL 0x00000004
540 #define EMAC_HW_FEATURE_MIISEL 0x00000001
541 
542 //Transmit DMA descriptor flags
543 #define EMAC_TDES0_OWN 0x80000000
544 #define EMAC_TDES0_IC 0x40000000
545 #define EMAC_TDES0_LS 0x20000000
546 #define EMAC_TDES0_FS 0x10000000
547 #define EMAC_TDES0_DC 0x08000000
548 #define EMAC_TDES0_DP 0x04000000
549 #define EMAC_TDES0_TTSE 0x02000000
550 #define EMAC_TDES0_CRCR 0x01000000
551 #define EMAC_TDES0_CIC 0x00C00000
552 #define EMAC_TDES0_TER 0x00200000
553 #define EMAC_TDES0_TCH 0x00100000
554 #define EMAC_TDES0_VLIC 0x000C0000
555 #define EMAC_TDES0_TTSS 0x00020000
556 #define EMAC_TDES0_IHE 0x00010000
557 #define EMAC_TDES0_ES 0x00008000
558 #define EMAC_TDES0_JT 0x00004000
559 #define EMAC_TDES0_FF 0x00002000
560 #define EMAC_TDES0_IPE 0x00001000
561 #define EMAC_TDES0_LOC 0x00000800
562 #define EMAC_TDES0_NC 0x00000400
563 #define EMAC_TDES0_LC 0x00000200
564 #define EMAC_TDES0_EC 0x00000100
565 #define EMAC_TDES0_VF 0x00000080
566 #define EMAC_TDES0_CC 0x00000078
567 #define EMAC_TDES0_ED 0x00000004
568 #define EMAC_TDES0_UF 0x00000002
569 #define EMAC_TDES0_DB 0x00000001
570 #define EMAC_TDES1_SAIC 0xE0000000
571 #define EMAC_TDES1_TBS2 0x1FFF0000
572 #define EMAC_TDES1_TBS1 0x00001FFF
573 #define EMAC_TDES2_TBAP1 0xFFFFFFFF
574 #define EMAC_TDES3_TBAP2 0xFFFFFFFF
575 #define EMAC_TDES6_TTSL 0xFFFFFFFF
576 #define EMAC_TDES7_TTSH 0xFFFFFFFF
577 
578 //Receive DMA descriptor flags
579 #define EMAC_RDES0_OWN 0x80000000
580 #define EMAC_RDES0_AFM 0x40000000
581 #define EMAC_RDES0_FL 0x3FFF0000
582 #define EMAC_RDES0_ES 0x00008000
583 #define EMAC_RDES0_DE 0x00004000
584 #define EMAC_RDES0_SAF 0x00002000
585 #define EMAC_RDES0_LE 0x00001000
586 #define EMAC_RDES0_OE 0x00000800
587 #define EMAC_RDES0_VLAN 0x00000400
588 #define EMAC_RDES0_FS 0x00000200
589 #define EMAC_RDES0_LS 0x00000100
590 #define EMAC_RDES0_IPHCE_TSV 0x00000080
591 #define EMAC_RDES0_LC 0x00000040
592 #define EMAC_RDES0_FT 0x00000020
593 #define EMAC_RDES0_RWT 0x00000010
594 #define EMAC_RDES0_RE 0x00000008
595 #define EMAC_RDES0_DBE 0x00000004
596 #define EMAC_RDES0_CE 0x00000002
597 #define EMAC_RDES0_PCE_ESA 0x00000001
598 #define EMAC_RDES1_DIC 0x80000000
599 #define EMAC_RDES1_RBS2 0x1FFF0000
600 #define EMAC_RDES1_RER 0x00008000
601 #define EMAC_RDES1_RCH 0x00004000
602 #define EMAC_RDES1_RBS1 0x00001FFF
603 #define EMAC_RDES2_RBAP1 0xFFFFFFFF
604 #define EMAC_RDES3_RBAP2 0xFFFFFFFF
605 #define EMAC_RDES4_L3L4FNM 0x0C000000
606 #define EMAC_RDES4_L4FM 0x02000000
607 #define EMAC_RDES4_L3FM 0x01000000
608 #define EMAC_RDES4_TSD 0x00004000
609 #define EMAC_RDES4_PV 0x00002000
610 #define EMAC_RDES4_PFT 0x00001000
611 #define EMAC_RDES4_PMT 0x00000F00
612 #define EMAC_RDES4_IPV6PR 0x00000080
613 #define EMAC_RDES4_IPV4PR 0x00000040
614 #define EMAC_RDES4_IPCB 0x00000020
615 #define EMAC_RDES4_IPPE 0x00000010
616 #define EMAC_RDES4_IPHE 0x00000008
617 #define EMAC_RDES4_IPPT 0x00000007
618 #define EMAC_RDES6_RTSL 0xFFFFFFFF
619 #define EMAC_RDES7_RTSH 0xFFFFFFFF
620 
621 //C++ guard
622 #ifdef __cplusplus
623 extern "C" {
624 #endif
625 
626 
627 /**
628  * @brief Enhanced TX DMA descriptor
629  **/
630 
631 typedef struct
632 {
633  uint32_t tdes0;
634  uint32_t tdes1;
635  uint32_t tdes2;
636  uint32_t tdes3;
637  uint32_t tdes4;
638  uint32_t tdes5;
639  uint32_t tdes6;
640  uint32_t tdes7;
641 } M467TxDmaDesc;
642 
643 
644 /**
645  * @brief Enhanced RX DMA descriptor
646  **/
647 
648 typedef struct
649 {
650  uint32_t rdes0;
651  uint32_t rdes1;
652  uint32_t rdes2;
653  uint32_t rdes3;
654  uint32_t rdes4;
655  uint32_t rdes5;
656  uint32_t rdes6;
657  uint32_t rdes7;
658 } M467RxDmaDesc;
659 
660 
661 //M467 Ethernet MAC driver
662 extern const NicDriver m467EthDriver;
663 
664 //M467 Ethernet MAC related functions
665 error_t m467EthInit(NetInterface *interface);
666 void m467EthInitGpio(NetInterface *interface);
667 void m467EthInitDmaDesc(NetInterface *interface);
668 
669 void m467EthTick(NetInterface *interface);
670 
671 void m467EthEnableIrq(NetInterface *interface);
672 void m467EthDisableIrq(NetInterface *interface);
673 void m467EthEventHandler(NetInterface *interface);
674 
676  const NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary);
677 
679 
682 
683 void m467EthWritePhyReg(uint8_t opcode, uint8_t phyAddr,
684  uint8_t regAddr, uint16_t data);
685 
686 uint16_t m467EthReadPhyReg(uint8_t opcode, uint8_t phyAddr,
687  uint8_t regAddr);
688 
689 //C++ guard
690 #ifdef __cplusplus
691 }
692 #endif
693 
694 #endif
const NicDriver m467EthDriver
M467 Ethernet MAC driver.
uint8_t opcode
Definition: dns_common.h:188
void m467EthTick(NetInterface *interface)
M467 Ethernet MAC timer handler.
Structure describing a buffer that spans multiple chunks.
Definition: net_mem.h:89
uint8_t data[]
Definition: ethernet.h:222
error_t m467EthUpdateMacConfig(NetInterface *interface)
Adjust MAC configuration parameters for proper operation.
uint16_t m467EthReadPhyReg(uint8_t opcode, uint8_t phyAddr, uint8_t regAddr)
Read PHY register.
error_t
Error codes.
Definition: error.h:43
void m467EthDisableIrq(NetInterface *interface)
Disable interrupts.
#define NetInterface
Definition: net.h:36
error_t m467EthSendPacket(NetInterface *interface, const NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary)
Send a packet.
#define NetTxAncillary
Definition: net_misc.h:36
void m467EthEventHandler(NetInterface *interface)
M467 Ethernet MAC event handler.
error_t m467EthReceivePacket(NetInterface *interface)
Receive a packet.
Enhanced RX DMA descriptor.
error_t m467EthInit(NetInterface *interface)
M467 Ethernet MAC initialization.
uint16_t regAddr
error_t m467EthUpdateMacAddrFilter(NetInterface *interface)
Configure MAC address filtering.
Network interface controller abstraction layer.
void m467EthInitDmaDesc(NetInterface *interface)
Initialize DMA descriptor lists.
Enhanced TX DMA descriptor.
NIC driver.
Definition: nic.h:286
void m467EthInitGpio(NetInterface *interface)
GPIO configuration.
void m467EthWritePhyReg(uint8_t opcode, uint8_t phyAddr, uint8_t regAddr, uint16_t data)
Write PHY register.
void m467EthEnableIrq(NetInterface *interface)
Enable interrupts.