lan8651_driver.h
Go to the documentation of this file.
1 /**
2  * @file lan8651_driver.h
3  * @brief LAN8651 10Base-T1S Ethernet controller
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 _LAN8651_DRIVER_H
32 #define _LAN8651_DRIVER_H
33 
34 //Dependencies
35 #include "core/nic.h"
36 
37 //PLCA support
38 #ifndef LAN8651_PLCA_SUPPORT
39  #define LAN8651_PLCA_SUPPORT ENABLED
40 #elif (LAN8651_PLCA_SUPPORT != ENABLED && LAN8651_PLCA_SUPPORT != DISABLED)
41  #error LAN8651_PLCA_SUPPORT parameter is not valid
42 #endif
43 
44 //Node count
45 #ifndef LAN8651_NODE_COUNT
46  #define LAN8651_NODE_COUNT 8
47 #elif (LAN8651_NODE_COUNT < 0 || LAN8651_NODE_COUNT > 255)
48  #error LAN8651_NODE_COUNT parameter is not valid
49 #endif
50 
51 //Local ID
52 #ifndef LAN8651_LOCAL_ID
53  #define LAN8651_LOCAL_ID 1
54 #elif (LAN8651_LOCAL_ID < 0 || LAN8651_LOCAL_ID > 255)
55  #error LAN8651_LOCAL_ID parameter is not valid
56 #endif
57 
58 //RX buffer size
59 #ifndef LAN8651_ETH_RX_BUFFER_SIZE
60  #define LAN8651_ETH_RX_BUFFER_SIZE 1536
61 #elif (LAN8651_ETH_RX_BUFFER_SIZE != 1536)
62  #error LAN8651_ETH_RX_BUFFER_SIZE parameter is not valid
63 #endif
64 
65 //Chunk payload size
66 #define LAN8651_CHUNK_PAYLOAD_SIZE 64
67 
68 //Transmit data header
69 #define LAN8651_TX_HEADER_DNC 0x80000000
70 #define LAN8651_TX_HEADER_SEQ 0x40000000
71 #define LAN8651_TX_HEADER_NORX 0x20000000
72 #define LAN8651_TX_HEADER_VS 0x00C00000
73 #define LAN8651_TX_HEADER_DV 0x00200000
74 #define LAN8651_TX_HEADER_SV 0x00100000
75 #define LAN8651_TX_HEADER_SWO 0x000F0000
76 #define LAN8651_TX_HEADER_EV 0x00004000
77 #define LAN8651_TX_HEADER_EBO 0x00003F00
78 #define LAN8651_TX_HEADER_TSC 0x000000C0
79 #define LAN8651_TX_HEADER_P 0x00000001
80 
81 //Receive data footer
82 #define LAN8651_RX_FOOTER_EXST 0x80000000
83 #define LAN8651_RX_FOOTER_HDRB 0x40000000
84 #define LAN8651_RX_FOOTER_SYNC 0x20000000
85 #define LAN8651_RX_FOOTER_RCA 0x1F000000
86 #define LAN8651_RX_FOOTER_VS 0x00C00000
87 #define LAN8651_RX_FOOTER_DV 0x00200000
88 #define LAN8651_RX_FOOTER_SV 0x00100000
89 #define LAN8651_RX_FOOTER_SWO 0x000F0000
90 #define LAN8651_RX_FOOTER_FD 0x00008000
91 #define LAN8651_RX_FOOTER_EV 0x00004000
92 #define LAN8651_RX_FOOTER_EBO 0x00003F00
93 #define LAN8651_RX_FOOTER_RTSA 0x00000080
94 #define LAN8651_RX_FOOTER_RTSP 0x00000040
95 #define LAN8651_RX_FOOTER_TXC 0x0000003E
96 #define LAN8651_RX_FOOTER_P 0x00000001
97 
98 //Control command header
99 #define LAN8651_CTRL_HEADER_DNC 0x80000000
100 #define LAN8651_CTRL_HEADER_HDRB 0x40000000
101 #define LAN8651_CTRL_HEADER_WNR 0x20000000
102 #define LAN8651_CTRL_HEADER_AID 0x10000000
103 #define LAN8651_CTRL_HEADER_MMS 0x0F000000
104 #define LAN8651_CTRL_HEADER_ADDR 0x00FFFF00
105 #define LAN8651_CTRL_HEADER_LEN 0x000000FE
106 #define LAN8651_CTRL_HEADER_P 0x00000001
107 
108 //Memory map selectors
109 #define LAN8651_MMS_STD 0x00
110 #define LAN8651_MMS_MAC 0x01
111 #define LAN8651_MMS_PHY_PCS 0x02
112 #define LAN8651_MMS_PHY_PMA_PMD 0x03
113 #define LAN8651_MMS_PHY_VS 0x04
114 #define LAN8651_MMS_PHY_MISC 0x0A
115 
116 //LAN8651 Open Alliance Standard registers (MMS 0)
117 #define LAN8651_OA_ID 0x00, 0x0000
118 #define LAN8651_OA_PHYID 0x00, 0x0001
119 #define LAN8651_OA_STDCAP 0x00, 0x0002
120 #define LAN8651_OA_RESET 0x00, 0x0003
121 #define LAN8651_OA_CONFIG0 0x00, 0x0004
122 #define LAN8651_OA_STATUS0 0x00, 0x0008
123 #define LAN8651_OA_STATUS1 0x00, 0x0009
124 #define LAN8651_OA_BUFSTS 0x00, 0x000B
125 #define LAN8651_OA_IMASK0 0x00, 0x000C
126 #define LAN8651_OA_MASK1 0x00, 0x000D
127 #define LAN8651_TTSCAH 0x00, 0x0010
128 #define LAN8651_TTSCAL 0x00, 0x0011
129 #define LAN8651_TTSCBH 0x00, 0x0012
130 #define LAN8651_TTSCBL 0x00, 0x0013
131 #define LAN8651_TTSCCH 0x00, 0x0014
132 #define LAN8651_TTSCCL 0x00, 0x0015
133 #define LAN8651_BASIC_CONTROL 0x00, 0xFF00
134 #define LAN8651_BASIC_STATUS 0x00, 0xFF01
135 #define LAN8651_PHY_ID1 0x00, 0xFF02
136 #define LAN8651_PHY_ID2 0x00, 0xFF03
137 #define LAN8651_MMDCTRL 0x00, 0xFF0D
138 #define LAN8651_MMDAD 0x00, 0xFF0E
139 
140 //LAN8651 MAC registers (MMS 1)
141 #define LAN8651_MAC_NCR 0x01, 0x0000
142 #define LAN8651_MAC_NCFGR 0x01, 0x0001
143 #define LAN8651_MAC_HRB 0x01, 0x0020
144 #define LAN8651_MAC_HRT 0x01, 0x0021
145 #define LAN8651_MAC_SAB1 0x01, 0x0022
146 #define LAN8651_MAC_SAT1 0x01, 0x0023
147 #define LAN8651_MAC_SAB2 0x01, 0x0024
148 #define LAN8651_MAC_SAT2 0x01, 0x0025
149 #define LAN8651_MAC_SAB3 0x01, 0x0026
150 #define LAN8651_MAC_SAT3 0x01, 0x0027
151 #define LAN8651_MAC_SAB4 0x01, 0x0028
152 #define LAN8651_MAC_SAT4 0x01, 0x0029
153 #define LAN8651_MAC_TIDM1 0x01, 0x002A
154 #define LAN8651_MAC_TIDM2 0x01, 0x002B
155 #define LAN8651_MAC_TIDM3 0x01, 0x002C
156 #define LAN8651_MAC_TIDM4 0x01, 0x002D
157 #define LAN8651_MAC_SAMB1 0x01, 0x0032
158 #define LAN8651_MAC_SAMT1 0x01, 0x0033
159 #define LAN8651_MAC_TISUBN 0x01, 0x006F
160 #define LAN8651_MAC_TSH 0x01, 0x0070
161 #define LAN8651_MAC_TSL 0x01, 0x0074
162 #define LAN8651_MAC_TN 0x01, 0x0075
163 #define LAN8651_MAC_TA 0x01, 0x0076
164 #define LAN8651_MAC_TI 0x01, 0x0077
165 #define LAN8651_BMGR_CTL 0x01, 0x0280
166 #define LAN8651_STATS0 0x01, 0x0288
167 #define LAN8651_STATS1 0x01, 0x0289
168 #define LAN8651_STATS2 0x01, 0x028A
169 #define LAN8651_STATS3 0x01, 0x028B
170 #define LAN8651_STATS4 0x01, 0x028C
171 #define LAN8651_STATS5 0x01, 0x028D
172 #define LAN8651_STATS6 0x01, 0x028E
173 #define LAN8651_STATS7 0x01, 0x028F
174 #define LAN8651_STATS8 0x01, 0x0290
175 #define LAN8651_STATS9 0x01, 0x0291
176 #define LAN8651_STATS10 0x01, 0x0292
177 #define LAN8651_STATS11 0x01, 0x0293
178 #define LAN8651_STATS12 0x01, 0x0294
179 
180 //LAN8651 PHY PCS registers (MMS 2)
181 #define LAN8651_T1SPCSCTL 0x02, 0x08F3
182 #define LAN8651_T1SPCSSTS 0x02, 0x08F4
183 #define LAN8651_T1SPCSDIAG1 0x02, 0x08F5
184 #define LAN8651_T1SPCSDIAG2 0x02, 0x08F6
185 
186 //LAN8651 PHY PMA/PMD registers (MMS 3)
187 #define LAN8651_T1PMAPMDEXTA 0x03, 0x0012
188 #define LAN8651_T1PMAPMDCTL 0x03, 0x0834
189 #define LAN8651_T1SPMACTL 0x03, 0x08F9
190 #define LAN8651_T1SPMASTS 0x03, 0x08FA
191 #define LAN8651_T1STSTCTL 0x03, 0x08FB
192 
193 //LAN8651 Vendor Specific registers (MMS 4)
194 #define LAN8651_CTRL1 0x04, 0x0010
195 #define LAN8651_STS1 0x04, 0x0018
196 #define LAN8651_STS2 0x04, 0x0019
197 #define LAN8651_STS3 0x04, 0x001A
198 #define LAN8651_IMSK1 0x04, 0x001C
199 #define LAN8651_IMSK2 0x04, 0x001D
200 #define LAN8651_CTRCTRL 0x04, 0x0020
201 #define LAN8651_TOCNTH 0x04, 0x0024
202 #define LAN8651_TOCNTL 0x04, 0x0025
203 #define LAN8651_BCNCNTH 0x04, 0x0026
204 #define LAN8651_BCNCNTL 0x04, 0x0027
205 #define LAN8651_PRTMGMT2 0x04, 0x003D
206 #define LAN8651_IWDTOH 0x04, 0x003E
207 #define LAN8651_IWDTOL 0x04, 0x003F
208 #define LAN8651_SLPCTL0 0x04, 0x0080
209 #define LAN8651_SLPCTL1 0x04, 0x0081
210 #define LAN8651_ANALOG5 0x04, 0x00D5
211 #define LAN8651_MIDVER 0x04, 0xCA00
212 #define LAN8651_PLCA_CTRL0 0x04, 0xCA01
213 #define LAN8651_PLCA_CTRL1 0x04, 0xCA02
214 #define LAN8651_PLCA_STS 0x04, 0xCA03
215 #define LAN8651_PLCA_TOTMR 0x04, 0xCA04
216 #define LAN8651_PLCA_BURST 0x04, 0xCA05
217 
218 //LAN8651 Miscellaneous registers (MMS 10)
219 #define LAN8651_QTXCFG 0x0A, 0x81
220 #define LAN8651_QRXCFG 0x0A, 0x82
221 #define LAN8651_PADCTRL 0x0A, 0x88
222 #define LAN8651_MISC 0x0A, 0x8C
223 #define LAN8651_DEVID 0x0A, 0x94
224 
225 //OA_ID register
226 #define LAN8651_OA_ID_MAJVER 0x000000F0
227 #define LAN8651_OA_ID_MAJVER_DEFAULT 0x00000010
228 #define LAN8651_OA_ID_MINVER 0x0000000F
229 #define LAN8651_OA_ID_MINVER_DEFAULT 0x00000001
230 
231 //OA_PHYID register
232 #define LAN8651_OA_PHYID_OUI 0xFFFFFC00
233 #define LAN8651_OA_PHYID_OUI_DEFAULT 0x02003C00
234 #define LAN8651_OA_PHYID_MODEL 0x000003F0
235 #define LAN8651_OA_PHYID_MODEL_DEFAULT 0x000001B0
236 #define LAN8651_OA_PHYID_REV 0x0000000F
237 #define LAN8651_OA_PHYID_REV_DEFAULT 0x00000003
238 
239 //OA_STDCAP register
240 #define LAN8651_OA_STDCAP_TXFCSVC 0x00000400
241 #define LAN8651_OA_STDCAP_IPRAC 0x00000200
242 #define LAN8651_OA_STDCAP_DPRAC 0x00000100
243 #define LAN8651_OA_STDCAP_CTC 0x00000080
244 #define LAN8651_OA_STDCAP_FTSC 0x00000040
245 #define LAN8651_OA_STDCAP_AIDC 0x00000020
246 #define LAN8651_OA_STDCAP_SEQC 0x00000010
247 #define LAN8651_OA_STDCAP_MINCPS 0x00000007
248 
249 //OA_RESET register
250 #define LAN8651_OA_RESET_SWRESET 0x00000001
251 
252 //OA_CONFIG0 register
253 #define LAN8651_OA_CONFIG0_SYNC 0x00008000
254 #define LAN8651_OA_CONFIG0_TXFCSVE 0x00004000
255 #define LAN8651_OA_CONFIG0_RFA 0x00003000
256 #define LAN8651_OA_CONFIG0_RFA_DEFAULT 0x00000000
257 #define LAN8651_OA_CONFIG0_RFA_ZARFE 0x00001000
258 #define LAN8651_OA_CONFIG0_RFA_CSARFE 0x00002000
259 #define LAN8651_OA_CONFIG0_RFA_INVALID 0x00003000
260 #define LAN8651_OA_CONFIG0_TXCTHRESH 0x00000C00
261 #define LAN8651_OA_CONFIG0_TXCTHRESH_1_CREDIT 0x00000000
262 #define LAN8651_OA_CONFIG0_TXCTHRESH_4_CREDITS 0x00000400
263 #define LAN8651_OA_CONFIG0_TXCTHRESH_8_CREDITS 0x00000800
264 #define LAN8651_OA_CONFIG0_TXCTHRESH_16_CREDITS 0x00000C00
265 #define LAN8651_OA_CONFIG0_TXCTE 0x00000200
266 #define LAN8651_OA_CONFIG0_RXCTE 0x00000100
267 #define LAN8651_OA_CONFIG0_FTSE 0x00000080
268 #define LAN8651_OA_CONFIG0_FTSS 0x00000040
269 #define LAN8651_OA_CONFIG0_PROTE 0x00000020
270 #define LAN8651_OA_CONFIG0_SEQE 0x00000010
271 #define LAN8651_OA_CONFIG0_CPS 0x00000007
272 #define LAN8651_OA_CONFIG0_CPS_32_BYTES 0x00000005
273 #define LAN8651_OA_CONFIG0_CPS_64_BYTES 0x00000006
274 
275 //OA_STATUS0 register
276 #define LAN8651_OA_STATUS0_CPDE 0x00001000
277 #define LAN8651_OA_STATUS0_TXFSE 0x00000800
278 #define LAN8651_OA_STATUS0_TTSCAC 0x00000400
279 #define LAN8651_OA_STATUS0_TTSCAB 0x00000200
280 #define LAN8651_OA_STATUS0_TTSCAA 0x00000100
281 #define LAN8651_OA_STATUS0_PHYINT 0x00000080
282 #define LAN8651_OA_STATUS0_RESETC 0x00000040
283 #define LAN8651_OA_STATUS0_HDRE 0x00000020
284 #define LAN8651_OA_STATUS0_LOFE 0x00000010
285 #define LAN8651_OA_STATUS0_RXBOE 0x00000008
286 #define LAN8651_OA_STATUS0_TXBUE 0x00000004
287 #define LAN8651_OA_STATUS0_TXBOE 0x00000002
288 #define LAN8651_OA_STATUS0_TXPE 0x00000001
289 
290 //OA_STATUS1 register
291 #define LAN8651_OA_STATUS1_UV18 0x00080000
292 
293 //OA_BUFSTS register
294 #define LAN8651_OA_BUFSTS_TXC 0x0000FF00
295 #define LAN8651_OA_BUFSTS_RCA 0x000000FF
296 
297 //OA_IMASK0 register
298 #define LAN8651_OA_IMASK0_CPDEM 0x00001000
299 #define LAN8651_OA_IMASK0_TXFCSEM 0x00000800
300 #define LAN8651_OA_IMASK0_TTSCACM 0x00000400
301 #define LAN8651_OA_IMASK0_TTSCABM 0x00000200
302 #define LAN8651_OA_IMASK0_TTSCAAM 0x00000100
303 #define LAN8651_OA_IMASK0_PHYINTM 0x00000080
304 #define LAN8651_OA_IMASK0_RESETCM 0x00000040
305 #define LAN8651_OA_IMASK0_HDREM 0x00000020
306 #define LAN8651_OA_IMASK0_LOFEM 0x00000010
307 #define LAN8651_OA_IMASK0_RXBOEM 0x00000008
308 #define LAN8651_OA_IMASK0_TXBUEM 0x00000004
309 #define LAN8651_OA_IMASK0_TXBOEM 0x00000002
310 #define LAN8651_OA_IMASK0_TXPEM 0x00000001
311 
312 //OA_MASK1 register
313 #define LAN8651_OA_MASK1_UV18 0x00080000
314 
315 //TTSCAH register
316 #define LAN8651_TTSCAH_TIMESTAMPA_63_32 0xFFFFFFFF
317 
318 //TTSCAL register
319 #define LAN8651_TTSCAL_TIMESTAMPA_31_0 0xFFFFFFFF
320 
321 //TTSCBH register
322 #define LAN8651_TTSCBH_TIMESTAMPB_63_32 0xFFFFFFFF
323 
324 //TTSCBL register
325 #define LAN8651_TTSCBL_TIMESTAMPB_31_0 0xFFFFFFFF
326 
327 //TTSCCH register
328 #define LAN8651_TTSCCH_TIMESTAMPC_63_32 0xFFFFFFFF
329 
330 //TTSCCL register
331 #define LAN8651_TTSCCL_TIMESTAMPC_31_0 0xFFFFFFFF
332 
333 //BASIC_CONTROL register
334 #define LAN8651_BASIC_CONTROL_SW_RESET 0x8000
335 #define LAN8651_BASIC_CONTROL_LOOPBACK 0x4000
336 #define LAN8651_BASIC_CONTROL_SPD_SEL_LSB 0x2000
337 #define LAN8651_BASIC_CONTROL_AUTONEGEN 0x1000
338 #define LAN8651_BASIC_CONTROL_PD 0x0800
339 #define LAN8651_BASIC_CONTROL_REAUTONEG 0x0200
340 #define LAN8651_BASIC_CONTROL_DUPLEXMD 0x0100
341 #define LAN8651_BASIC_CONTROL_SPD_SEL_MSB 0x0040
342 
343 //BASIC_STATUS register
344 #define LAN8651_BASIC_STATUS_100BT4A 0x8000
345 #define LAN8651_BASIC_STATUS_100BTXFDA 0x4000
346 #define LAN8651_BASIC_STATUS_100BTXHDA 0x2000
347 #define LAN8651_BASIC_STATUS_10BTFDA 0x1000
348 #define LAN8651_BASIC_STATUS_10BTHDA 0x0800
349 #define LAN8651_BASIC_STATUS_100BT2FDA 0x0400
350 #define LAN8651_BASIC_STATUS_100BT2HDA 0x0200
351 #define LAN8651_BASIC_STATUS_EXTSTS 0x0100
352 #define LAN8651_BASIC_STATUS_AUTONEGC 0x0020
353 #define LAN8651_BASIC_STATUS_RMTFLTD 0x0010
354 #define LAN8651_BASIC_STATUS_AUTONEGA 0x0008
355 #define LAN8651_BASIC_STATUS_LNKSTS 0x0004
356 #define LAN8651_BASIC_STATUS_JABDET 0x0002
357 #define LAN8651_BASIC_STATUS_EXTCAPA 0x0001
358 
359 //PHY_ID1 register
360 #define LAN8651_PHY_ID1_OUI_2_9 0x0000FF00
361 #define LAN8651_PHY_ID1_OUI_2_9_DEFAULT 0x00000000
362 #define LAN8651_PHY_ID1_OUI_10_17 0x000000FF
363 #define LAN8651_PHY_ID1_OUI_10_17_DEFAULT 0x00000007
364 
365 //PHY_ID2 register
366 #define LAN8651_PHY_ID2_OUI_18_23 0x0000FC00
367 #define LAN8651_PHY_ID2_OUI_18_23_DEFAULT 0x0000C000
368 #define LAN8651_PHY_ID2_MODEL 0x000003F0
369 #define LAN8651_PHY_ID2_MODEL_DEFAULT 0x000001B0
370 #define LAN8651_PHY_ID2_REV 0x0000000F
371 #define LAN8651_PHY_ID2_REV_3 0x00000003
372 
373 //MMDCTRL register
374 #define LAN8651_MMDCTRL_FNCTN 0xC000
375 #define LAN8651_MMDCTRL_FNCTN_ADDR 0x0000
376 #define LAN8651_MMDCTRL_FNCTN_DATA_NO_POST_INC 0x4000
377 #define LAN8651_MMDCTRL_FNCTN_DATA_POST_INC_RW 0x8000
378 #define LAN8651_MMDCTRL_FNCTN_DATA_POST_INC_W 0xC000
379 #define LAN8651_MMDCTRL_DEVAD 0x001F
380 #define LAN8651_MMDCTRL_DEVAD_PMA_PMD 0x0001
381 #define LAN8651_MMDCTRL_DEVAD_PCS 0x0002
382 #define LAN8651_MMDCTRL_DEVAD_VENDOR_SPECIFIC_2 0x001F
383 
384 //MMDAD register
385 #define LAN8651_MMDAD_ADR_DATA 0xFFFF
386 
387 //MAC_NCR register
388 #define LAN8651_MAC_NCR_TXEN 0x00000008
389 #define LAN8651_MAC_NCR_RXEN 0x00000004
390 #define LAN8651_MAC_NCR_LBL 0x00000002
391 
392 //MAC_NCFGR register
393 #define LAN8651_MAC_NCFGR_RXBP 0x20000000
394 #define LAN8651_MAC_NCFGR_IRXFCS 0x04000000
395 #define LAN8651_MAC_NCFGR_EFRHD 0x02000000
396 #define LAN8651_MAC_NCFGR_RFCS 0x00020000
397 #define LAN8651_MAC_NCFGR_LFERD 0x00010000
398 #define LAN8651_MAC_NCFGR_MAXFS 0x00000100
399 #define LAN8651_MAC_NCFGR_UNIHEN 0x00000080
400 #define LAN8651_MAC_NCFGR_MTIHEN 0x00000040
401 #define LAN8651_MAC_NCFGR_NBC 0x00000020
402 #define LAN8651_MAC_NCFGR_CAF 0x00000010
403 #define LAN8651_MAC_NCFGR_DNVLAN 0x00000004
404 
405 //MAC_SAB1 register
406 #define LAN8651_MAC_SAB1_ADDR_31_0 0xFFFFFFFF
407 
408 //MAC_SAT1 register
409 #define LAN8651_MAC_SAT1_FLTTYP 0x00010000
410 #define LAN8651_MAC_SAT1_ADDR_47_32 0x0000FFFF
411 
412 //MAC_SAB2 register
413 #define LAN8651_MAC_SAB2_ADDR_31_0 0xFFFFFFFF
414 
415 //MAC_SAT2 register
416 #define LAN8651_MAC_SAT2_FLTTYP 0x00010000
417 #define LAN8651_MAC_SAT2_ADDR_47_32 0x0000FFFF
418 
419 //MAC_SAB3 register
420 #define LAN8651_MAC_SAB3_ADDR_31_0 0xFFFFFFFF
421 
422 //MAC_SAT3 register
423 #define LAN8651_MAC_SAT3_FLTTYP 0x00010000
424 #define LAN8651_MAC_SAT3_ADDR_47_32 0x0000FFFF
425 
426 //MAC_SAB4 register
427 #define LAN8651_MAC_SAB4_ADDR_31_0 0xFFFFFFFF
428 
429 //MAC_SAT4 register
430 #define LAN8651_MAC_SAT4_FLTTYP 0x00010000
431 #define LAN8651_MAC_SAT4_ADDR_47_32 0x0000FFFF
432 
433 //MAC_TIDM1 register
434 #define LAN8651_MAC_TIDM1_ENID 0x80000000
435 #define LAN8651_MAC_TIDM1_TID 0x0000FFFF
436 
437 //MAC_TIDM2 register
438 #define LAN8651_MAC_TIDM2_ENID 0x80000000
439 #define LAN8651_MAC_TIDM2_TID 0x0000FFFF
440 
441 //MAC_TIDM3 register
442 #define LAN8651_MAC_TIDM3_ENID 0x80000000
443 #define LAN8651_MAC_TIDM3_TID 0x0000FFFF
444 
445 //MAC_TIDM4 register
446 #define LAN8651_MAC_TIDM4_ENID 0x80000000
447 #define LAN8651_MAC_TIDM4_TID 0x0000FFFF
448 
449 //MAC_SAMB1 register
450 #define LAN8651_MAC_SAMB1_ADDR_31_0 0xFFFFFFFF
451 
452 //MAC_SAMT1 register
453 #define LAN8651_MAC_SAMT1_ADDR_47_32 0x0000FFFF
454 
455 //MAC_TISUBN register
456 #define LAN8651_MAC_TISUBN_LSBTIR 0xFF000000
457 #define LAN8651_MAC_TISUBN_MSBTIR 0x0000FFFF
458 
459 //MAC_TSH register
460 #define LAN8651_MAC_TSH_TCS_47_32 0x0000FFFF
461 
462 //MAC_TSL register
463 #define LAN8651_MAC_TSL_TCS_31_0 0xFFFFFFFF
464 
465 //MAC_TN register
466 #define LAN8651_MAC_TN_TNS 0x3FFFFFFF
467 
468 //MAC_TA register
469 #define LAN8651_MAC_TA_ADJ 0x80000000
470 #define LAN8651_MAC_TA_ITDT 0x3FFFFFFF
471 
472 //MAC_TI register
473 #define LAN8651_MAC_TI_CNS 0x000000FF
474 
475 //BMGR_CTL register
476 #define LAN8651_BMGR_CTL_SNAPSTATS 0x00000020
477 #define LAN8651_BMGR_CTL_CLRSTATS 0x00000010
478 
479 //STATS0 register
480 #define LAN8651_STATS0_RXSE 0xFF000000
481 #define LAN8651_STATS0_LFER 0x00FF0000
482 #define LAN8651_STATS0_OFRX 0x0000FF00
483 #define LAN8651_STATS0_UFRX 0x000000FF
484 
485 //STATS1 register
486 #define LAN8651_STATS1_RXRER 0xFF000000
487 #define LAN8651_STATS1_RXBOVR 0x00FF0000
488 #define LAN8651_STATS1_RXFOVR 0x0000FF00
489 
490 //STATS2 register
491 #define LAN8651_STATS2_FCSE 0x000000FF
492 
493 //STATS3 register
494 #define LAN8651_STATS3_TID4MCNT 0xFF000000
495 #define LAN8651_STATS3_TID3MCNT 0x00FF0000
496 #define LAN8651_STATS3_TID2MCNT 0x0000FF00
497 #define LAN8651_STATS3_TID1MCNT 0x000000FF
498 
499 //STATS4 register
500 #define LAN8651_STATS4_SA4MCNT 0xFF000000
501 #define LAN8651_STATS4_SA3MCNT 0x00FF0000
502 #define LAN8651_STATS4_SA2MCNT 0x0000FF00
503 #define LAN8651_STATS4_SA1MCNT 0x000000FF
504 
505 //STATS5 register
506 #define LAN8651_STATS5_UHMFRX 0xFF000000
507 #define LAN8651_STATS5_MHMFRX 0x00FF0000
508 #define LAN8651_STATS5_BFRX 0x0000FF00
509 #define LAN8651_STATS5_VTRX 0x000000FF
510 
511 //STATS6 register
512 #define LAN8651_STATS6_TFRX 0xFFFFFFFF
513 
514 //STATS7 register
515 #define LAN8651_STATS7_FRX 0xFFFFFFFF
516 
517 //STATS8 register
518 #define LAN8651_STATS8_TXAIE 0x000000FF
519 
520 //STATS9 register
521 #define LAN8651_STATS9_TXAEE 0xFF000000
522 #define LAN8651_STATS9_TXFUR 0x00FF0000
523 #define LAN8651_STATS9_TXBUR 0x0000FF00
524 
525 //STATS10 register
526 #define LAN8651_STATS10_XCOL 0x000000FF
527 
528 //STATS11 register
529 #define LAN8651_STATS11_TFTX 0xFFFFFFFF
530 
531 //STATS12 register
532 #define LAN8651_STATS12_FTX 0xFFFFFFFF
533 
534 //T1SPCSCTL register
535 #define LAN8651_T1SPCSCTL_RST 0x8000
536 #define LAN8651_T1SPCSCTL_LBE 0x4000
537 #define LAN8651_T1SPCSCTL_DUPLEX 0x0100
538 
539 //T1SPCSSTS register
540 #define LAN8651_T1SPCSSTS_FAULT 0x0080
541 
542 //T1SPCSDIAG1 register
543 #define LAN8651_T1SPCSDIAG1_RMTJABCNT 0xFFFF
544 
545 //T1SPCSDIAG2 register
546 #define LAN8651_T1SPCSDIAG2_CORTXCNT 0xFFFF
547 
548 //T1PMAPMDEXTA register
549 #define LAN8651_T1PMAPMDEXTA_T1SABL 0x0008
550 #define LAN8651_T1PMAPMDEXTA_T1LABL 0x0004
551 
552 //T1PMAPMDCTL register
553 #define LAN8651_T1PMAPMDCTL_TYPSEL 0x000F
554 #define LAN8651_T1PMAPMDCTL_TYPSEL_100BT1 0x0000
555 #define LAN8651_T1PMAPMDCTL_TYPSEL_1000BT1 0x0001
556 #define LAN8651_T1PMAPMDCTL_TYPSEL_10BT1L 0x0002
557 #define LAN8651_T1PMAPMDCTL_TYPSEL_10BT1S 0x0003
558 
559 //T1SPMACTL register
560 #define LAN8651_T1SPMACTL_RST 0x8000
561 #define LAN8651_T1SPMACTL_TXD 0x4000
562 #define LAN8651_T1SPMACTL_LPE 0x0800
563 #define LAN8651_T1SPMACTL_MDE 0x0400
564 #define LAN8651_T1SPMACTL_LBE 0x0001
565 
566 //T1SPMASTS register
567 #define LAN8651_T1SPMASTS_LBA 0x2000
568 #define LAN8651_T1SPMASTS_LPA 0x0800
569 #define LAN8651_T1SPMASTS_MDA 0x0400
570 #define LAN8651_T1SPMASTS_RXFA 0x0200
571 #define LAN8651_T1SPMASTS_RXFD 0x0002
572 
573 //T1STSTCTL register
574 #define LAN8651_T1STSTCTL_TSTCTL 0xE000
575 #define LAN8651_T1STSTCTL_TSTCTL_NORMAL 0x0000
576 #define LAN8651_T1STSTCTL_TSTCTL_TEST_MODE_1 0x2000
577 #define LAN8651_T1STSTCTL_TSTCTL_TEST_MODE_2 0x4000
578 #define LAN8651_T1STSTCTL_TSTCTL_TEST_MODE_3 0x6000
579 #define LAN8651_T1STSTCTL_TSTCTL_TEST_MODE_4 0x8000
580 
581 //CTRL1 register
582 #define LAN8651_CTRL1_IWDE 0x0008
583 #define LAN8651_CTRL1_DIGLBE 0x0002
584 
585 //STS1 register
586 #define LAN8651_STS1_PSTC 0x0800
587 #define LAN8651_STS1_TXCOL 0x0400
588 #define LAN8651_STS1_TXJAB 0x0200
589 #define LAN8651_STS1_EMPCYC 0x0080
590 #define LAN8651_STS1_RXINTO 0x0040
591 #define LAN8651_STS1_UNEXPB 0x0020
592 #define LAN8651_STS1_BCNBFTO 0x0010
593 #define LAN8651_STS1_PLCASYM 0x0004
594 #define LAN8651_STS1_ESDERR 0x0002
595 #define LAN8651_STS1_DEC5B 0x0001
596 
597 //STS2 register
598 #define LAN8651_STS2_WKEMDI 0x0400
599 #define LAN8651_STS2_WKEWI 0x0200
600 #define LAN8651_STS2_UV33 0x0100
601 #define LAN8651_STS2_OT 0x0040
602 #define LAN8651_STS2_IWDTO 0x0020
603 
604 //STS3 register
605 #define LAN8651_STS3_ERRTOID 0x00FF
606 
607 //IMSK1 register
608 #define LAN8651_IMSK1_PSTCM 0x0800
609 #define LAN8651_IMSK1_TXCOLM 0x0400
610 #define LAN8651_IMSK1_TXJABM 0x0200
611 #define LAN8651_IMSK1_EMPCYCM 0x0080
612 #define LAN8651_IMSK1_RXINTOM 0x0040
613 #define LAN8651_IMSK1_UNEXPBM 0x0020
614 #define LAN8651_IMSK1_BCNBFTOM 0x0010
615 #define LAN8651_IMSK1_PLCASYMM 0x0004
616 #define LAN8651_IMSK1_ESDERRM 0x0002
617 #define LAN8651_IMSK1_DEC5BM 0x0001
618 
619 //IMSK2 register
620 #define LAN8651_IMSK2_WKEMDIM 0x0400
621 #define LAN8651_IMSK2_WKEWIM 0x0200
622 #define LAN8651_IMSK2_UV33M 0x0100
623 #define LAN8651_IMSK2_OTM 0x0040
624 #define LAN8651_IMSK2_IWDTOM 0x0020
625 
626 //CTRCTRL register
627 #define LAN8651_CTRCTRL_TOCTRE 0x0002
628 #define LAN8651_CTRCTRL_BCNCTRE 0x0001
629 
630 //TOCNTH register
631 #define LAN8651_TOCNTH_TOCNT_31_16 0xFFFF
632 
633 //TOCNTL register
634 #define LAN8651_TOCNTL_TOCNT_15_0 0xFFFF
635 
636 //BCNCNTH register
637 #define LAN8651_BCNCNTH_BCNCNT_31_16 0xFFFF
638 
639 //BCNCNTL register
640 #define LAN8651_BCNCNTL_BCNCNT_15_0 0xFFFF
641 
642 //PRTMGMT2 register
643 #define LAN8651_PRTMGMT2_MIRXWDEN 0x2000
644 #define LAN8651_PRTMGMT2_PRIWDEN 0x1000
645 #define LAN8651_PRTMGMT2_MITXWDEN 0x0800
646 
647 //IWDTOH register
648 #define LAN8651_IWDTOH_TIMEOUT_31_16 0xFFFF
649 
650 //IWDTOL register
651 #define LAN8651_IWDTOL_TIMEOUT_15_0 0xFFFF
652 
653 //SLPCTL0 register
654 #define LAN8651_SLPCTL0_SLPEN 0x8000
655 #define LAN8651_SLPCTL0_WKINEN 0x4000
656 #define LAN8651_SLPCTL0_MDIWKEN 0x2000
657 #define LAN8651_SLPCTL0_SLPINHDLY 0x1800
658 #define LAN8651_SLPCTL0_SLPINHDLY_0MS 0x0000
659 #define LAN8651_SLPCTL0_SLPINHDLY_50MS 0x0800
660 #define LAN8651_SLPCTL0_SLPINHDLY_100MS 0x1000
661 #define LAN8651_SLPCTL0_SLPINHDLY_200MS 0x1800
662 
663 //SLPCTL1 register
664 #define LAN8651_SLPCTL1_WIPOL 0x0020
665 #define LAN8651_SLPCTL1_WAKEIND 0x0010
666 #define LAN8651_SLPCTL1_CLRWKI 0x0008
667 #define LAN8651_SLPCTL1_MWKFWD 0x0004
668 #define LAN8651_SLPCTL1_WKOFWDEN 0x0002
669 #define LAN8651_SLPCTL1_MDIFWDEN 0x0001
670 
671 //ANALOG5 register
672 #define LAN8651_ANALOG5_UV33FTM 0xFF00
673 #define LAN8651_ANALOG5_UV33FTM_DEFAULT 0x1400
674 
675 //MIDVER register
676 #define LAN8651_MIDVER_IDM 0xFF00
677 #define LAN8651_MIDVER_IDM_DEFAULT 0x0A00
678 #define LAN8651_MIDVER_VER 0x00FF
679 #define LAN8651_MIDVER_VER_DEFAULT 0x0010
680 
681 //PLCA_CTRL0 register
682 #define LAN8651_PLCA_CTRL0_EN 0x8000
683 #define LAN8651_PLCA_CTRL0_RST 0x4000
684 
685 //PLCA_CTRL1 register
686 #define LAN8651_PLCA_CTRL1_NCNT 0xFF00
687 #define LAN8651_PLCA_CTRL1_ID 0x00FF
688 
689 //PLCA_STS register
690 #define LAN8651_PLCA_STS_PST 0x8000
691 
692 //PLCA_TOTMR register
693 #define LAN8651_PLCA_TOTMR_TOTMR 0x00FF
694 #define LAN8651_PLCA_TOTMR_TOTMR_DEFAULT 0x0020
695 
696 //PLCA_BURST register
697 #define LAN8651_PLCA_BURST_MAXBC 0xFF00
698 #define LAN8651_PLCA_BURST_MAXBC_DEFAULT 0x0000
699 #define LAN8651_PLCA_BURST_BTMR 0x00FF
700 #define LAN8651_PLCA_BURST_BTMR_DEFAULT 0x0080
701 
702 //QTXCFG register
703 #define LAN8651_QTXCFG_CTTHR 0xC0000000
704 #define LAN8651_QTXCFG_CTTHR_1_CHUNK 0x00000000
705 #define LAN8651_QTXCFG_CTTHR_2_CHUNKS 0x40000000
706 #define LAN8651_QTXCFG_CTTHR_3_CHUNKS 0x80000000
707 #define LAN8651_QTXCFG_CTTHR_4_CHUNKS 0xC0000000
708 #define LAN8651_QTXCFG_BUFSZ 0x00700000
709 #define LAN8651_QTXCFG_BUFSZ_32_BYTES 0x00000000
710 #define LAN8651_QTXCFG_BUFSZ_64_BYTES 0x00100000
711 #define LAN8651_QTXCFG_MACFCSDIS 0x00080000
712 
713 //QRXCFG register
714 #define LAN8651_QRXCFG_BUFSZ 0x00700000
715 #define LAN8651_QRXCFG_BUFSZ_32_BYTES 0x00000000
716 #define LAN8651_QRXCFG_BUFSZ_64_BYTES 0x00100000
717 
718 //PADCTRL register
719 #define LAN8651_PADCTRL_PDRV3 0xC0000000
720 #define LAN8651_PADCTRL_PDRV3_LOW 0x00000000
721 #define LAN8651_PADCTRL_PDRV3_MEDIUM_LOW 0x40000000
722 #define LAN8651_PADCTRL_PDRV3_MEDIUM_HIGH 0x80000000
723 #define LAN8651_PADCTRL_PDRV3_HIGH 0xC0000000
724 #define LAN8651_PADCTRL_PDRV2 0x30000000
725 #define LAN8651_PADCTRL_PDRV2_LOW 0x00000000
726 #define LAN8651_PADCTRL_PDRV2_MEDIUM_LOW 0x10000000
727 #define LAN8651_PADCTRL_PDRV2_MEDIUM_HIGH 0x20000000
728 #define LAN8651_PADCTRL_PDRV2_HIGH 0x30000000
729 #define LAN8651_PADCTRL_PDRV1 0x0C000000
730 #define LAN8651_PADCTRL_PDRV1_LOW 0x00000000
731 #define LAN8651_PADCTRL_PDRV1_MEDIUM_LOW 0x04000000
732 #define LAN8651_PADCTRL_PDRV1_MEDIUM_HIGH 0x08000000
733 #define LAN8651_PADCTRL_PDRV1_HIGH 0x0C000000
734 
735 //MISC register
736 #define LAN8651_MISC_UV18FEN 0x00001000
737 #define LAN8651_MISC_UV18FTM 0x00000FFF
738 #define LAN8651_MISC_UV18FTM_DEFAULT 0x00000040
739 
740 //DEVID register
741 #define LAN8651_DEVID_MODEL 0x000FFFF0
742 #define LAN8651_DEVID_MODEL_DEFAULT 0x00086510
743 #define LAN8651_DEVID_REV 0x0000000F
744 #define LAN8651_DEVID_REV_1 0x00000001
745 
746 //C++ guard
747 #ifdef __cplusplus
748 extern "C" {
749 #endif
750 
751 //LAN8651 driver
752 extern const NicDriver lan8651Driver;
753 
754 //LAN8651 related functions
755 error_t lan8651Init(NetInterface *interface);
756 void lan8651InitHook(NetInterface *interface);
757 
758 void lan8651Config(NetInterface *interface);
759 
760 void lan8651Tick(NetInterface *interface);
761 
762 void lan8651EnableIrq(NetInterface *interface);
763 void lan8651DisableIrq(NetInterface *interface);
765 void lan8651EventHandler(NetInterface *interface);
766 
768  const NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary);
769 
771 
773 
774 void lan8651WriteReg(NetInterface *interface, uint8_t mms, uint16_t address,
775  uint32_t data);
776 
777 uint32_t lan8651ReadReg(NetInterface *interface, uint8_t mms,
778  uint16_t address);
779 
780 void lan8651DumpReg(NetInterface *interface, uint8_t mms, uint16_t address,
781  uint_t num);
782 
783 void lan8651WriteMmdReg(NetInterface *interface, uint8_t devAddr,
784  uint16_t regAddr, uint16_t data);
785 
786 uint16_t lan8651ReadMmdReg(NetInterface *interface, uint8_t devAddr,
787  uint16_t regAddr);
788 
789 int8_t lan8651ReadIndirectReg(NetInterface *interface, uint8_t address);
790 
791 uint32_t lan8651CalcParity(uint32_t data);
792 
793 //C++ guard
794 #ifdef __cplusplus
795 }
796 #endif
797 
798 #endif
uint16_t lan8651ReadMmdReg(NetInterface *interface, uint8_t devAddr, uint16_t regAddr)
Read MMD register.
int bool_t
Definition: compiler_port.h:53
error_t lan8651SendPacket(NetInterface *interface, const NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary)
Send a packet.
Structure describing a buffer that spans multiple chunks.
Definition: net_mem.h:89
uint8_t data[]
Definition: ethernet.h:222
void lan8651InitHook(NetInterface *interface)
LAN8651 custom configuration.
void lan8651EnableIrq(NetInterface *interface)
Enable interrupts.
error_t lan8651Init(NetInterface *interface)
LAN8651 controller initialization.
void lan8651WriteReg(NetInterface *interface, uint8_t mms, uint16_t address, uint32_t data)
Write register.
void lan8651Tick(NetInterface *interface)
LAN8651 timer handler.
uint32_t lan8651ReadReg(NetInterface *interface, uint8_t mms, uint16_t address)
Read register.
error_t
Error codes.
Definition: error.h:43
int8_t lan8651ReadIndirectReg(NetInterface *interface, uint8_t address)
Read indirect register.
void lan8651EventHandler(NetInterface *interface)
LAN8651 event handler.
#define NetInterface
Definition: net.h:36
#define NetTxAncillary
Definition: net_misc.h:36
void lan8651DumpReg(NetInterface *interface, uint8_t mms, uint16_t address, uint_t num)
Dump registers for debugging purpose.
void lan8651WriteMmdReg(NetInterface *interface, uint8_t devAddr, uint16_t regAddr, uint16_t data)
Write MMD register.
void lan8651DisableIrq(NetInterface *interface)
Disable interrupts.
error_t lan8651UpdateMacAddrFilter(NetInterface *interface)
Configure MAC address filtering.
void lan8651Config(NetInterface *interface)
LAN8651 controller configuration.
uint16_t regAddr
Ipv6Addr address[]
Definition: ipv6.h:325
const NicDriver lan8651Driver
LAN8651 driver.
Network interface controller abstraction layer.
error_t lan8651ReceivePacket(NetInterface *interface)
Receive a packet.
uint32_t lan8651CalcParity(uint32_t data)
Calculate parity bit over a 32-bit data.
bool_t lan8651IrqHandler(NetInterface *interface)
LAN8651 interrupt service routine.
unsigned int uint_t
Definition: compiler_port.h:50
NIC driver.
Definition: nic.h:286