dp83822_driver.h
Go to the documentation of this file.
1 /**
2  * @file dp83822_driver.h
3  * @brief DP83822 Ethernet PHY 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 _DP83822_DRIVER_H
32 #define _DP83822_DRIVER_H
33 
34 //Dependencies
35 #include "core/nic.h"
36 
37 //PHY address
38 #ifndef DP83822_PHY_ADDR
39  #define DP83822_PHY_ADDR 1
40 #elif (DP83822_PHY_ADDR < 0 || DP83822_PHY_ADDR > 31)
41  #error DP83822_PHY_ADDR parameter is not valid
42 #endif
43 
44 //DP83822 PHY registers
45 #define DP83822_BMCR 0x00
46 #define DP83822_BMSR 0x01
47 #define DP83822_PHYIDR1 0x02
48 #define DP83822_PHYIDR2 0x03
49 #define DP83822_ANAR 0x04
50 #define DP83822_ANLPAR 0x05
51 #define DP83822_ANER 0x06
52 #define DP83822_ANNPTR 0x07
53 #define DP83822_ANLNPTR 0x08
54 #define DP83822_CR1 0x09
55 #define DP83822_CR2 0x0A
56 #define DP83822_CR3 0x0B
57 #define DP83822_REGCR 0x0D
58 #define DP83822_ADDAR 0x0E
59 #define DP83822_FLDS 0x0F
60 #define DP83822_PHYSTS 0x10
61 #define DP83822_PHYSCR 0x11
62 #define DP83822_MISR1 0x12
63 #define DP83822_MISR2 0x13
64 #define DP83822_FCSCR 0x14
65 #define DP83822_RECR 0x15
66 #define DP83822_BISCR 0x16
67 #define DP83822_RCSR 0x17
68 #define DP83822_LEDCR 0x18
69 #define DP83822_PHYCR 0x19
70 #define DP83822_10BTSCR 0x1A
71 #define DP83822_BICSR1 0x1B
72 #define DP83822_BICSR2 0x1C
73 #define DP83822_CDCR 0x1E
74 #define DP83822_PHYRCR 0x1F
75 
76 //DP83822 MMD registers
77 #define DP83822_MMD3_PCS_CTRL_1 0x03, 0x3000
78 #define DP83822_MMD3_PCS_STATUS_1 0x03, 0x3001
79 #define DP83822_MMD3_EEE_CAPABILITY 0x03, 0x3014
80 #define DP83822_MMD3_WAKE_ERR_CNT 0x03, 0x3016
81 #define DP83822_MMD7_EEE_ADVERTISEMENT 0x07, 0x703C
82 #define DP83822_MMD7_EEE_LP_ABILITY 0x07, 0x703D
83 #define DP83822_MLEDCR 0x1F, 0x0025
84 #define DP83822_COMPT 0x1F, 0x0027
85 #define DP83822_PTPPSEL 0x1F, 0x003E
86 #define DP83822_PTPCFG 0x1F, 0x003F
87 #define DP83822_TXCPSR 0x1F, 0x0042
88 #define DP83822_DFCR1 0x1F, 0x0106
89 #define DP83822_DFCR2 0x1F, 0x0107
90 #define DP83822_DSPCR 0x1F, 0x010F
91 #define DP83822_DFECR 0x1F, 0x0114
92 #define DP83822_AGCBCR 0x1F, 0x0116
93 #define DP83822_DETR 0x1F, 0x0126
94 #define DP83822_ALCDRR1 0x1F, 0x0155
95 #define DP83822_CDSCR 0x1F, 0x0170
96 #define DP83822_CDSCR2 0x1F, 0x0171
97 #define DP83822_CDSCR3 0x1F, 0x0173
98 #define DP83822_CDSCR4 0x1F, 0x0177
99 #define DP83822_CDLRR1 0x1F, 0x0180
100 #define DP83822_CDLRR2 0x1F, 0x0181
101 #define DP83822_CDLRR3 0x1F, 0x0182
102 #define DP83822_CDLRR4 0x1F, 0x0183
103 #define DP83822_CDLRR5 0x1F, 0x0184
104 #define DP83822_CDLAR1 0x1F, 0x0185
105 #define DP83822_CDLAR2 0x1F, 0x0186
106 #define DP83822_CDLAR3 0x1F, 0x0187
107 #define DP83822_CDLAR4 0x1F, 0x0188
108 #define DP83822_CDLAR5 0x1F, 0x0189
109 #define DP83822_CDLGR 0x1F, 0x018A
110 #define DP83822_ALCDRR2 0x1F, 0x0215
111 #define DP83822_ALCDRR3 0x1F, 0x021D
112 #define DP83822_LDCTRL 0x1F, 0x0403
113 #define DP83822_LDCSEL 0x1F, 0x0404
114 #define DP83822_DPDWN 0x1F, 0x0428
115 #define DP83822_GENCFG 0x1F, 0x0456
116 #define DP83822_LEDCFG1 0x1F, 0x0460
117 #define DP83822_IOCTRL 0x1F, 0x0461
118 #define DP83822_IOCTRL1 0x1F, 0x0462
119 #define DP83822_IOCTRL2 0x1F, 0x0463
120 #define DP83822_FIBER_GENCFG 0x1F, 0x0465
121 #define DP83822_SOR1 0x1F, 0x0467
122 #define DP83822_SOR2 0x1F, 0x0468
123 #define DP83822_LEDCFG2 0x1F, 0x0469
124 #define DP83822_RXFCFG 0x1F, 0x04A0
125 #define DP83822_RXFS 0x1F, 0x04A1
126 #define DP83822_RXFPMD1 0x1F, 0x04A2
127 #define DP83822_RXFPMD2 0x1F, 0x04A3
128 #define DP83822_RXFPMD3 0x1F, 0x04A4
129 #define DP83822_RXFSOP1 0x1F, 0x04A5
130 #define DP83822_RXFSOP2 0x1F, 0x04A6
131 #define DP83822_RXFSOP3 0x1F, 0x04A7
132 #define DP83822_RXFPAT1 0x1F, 0x04A8
133 #define DP83822_RXFPAT2 0x1F, 0x04A9
134 #define DP83822_RXFPAT3 0x1F, 0x04AA
135 #define DP83822_RXFPAT4 0x1F, 0x04AB
136 #define DP83822_RXFPAT5 0x1F, 0x04AC
137 #define DP83822_RXFPAT6 0x1F, 0x04AD
138 #define DP83822_RXFPAT7 0x1F, 0x04AE
139 #define DP83822_RXFPAT8 0x1F, 0x04AF
140 #define DP83822_RXFPAT9 0x1F, 0x04B0
141 #define DP83822_RXFPAT10 0x1F, 0x04B1
142 #define DP83822_RXFPAT11 0x1F, 0x04B2
143 #define DP83822_RXFPAT12 0x1F, 0x04B3
144 #define DP83822_RXFPAT13 0x1F, 0x04B4
145 #define DP83822_RXFPAT14 0x1F, 0x04B5
146 #define DP83822_RXFPAT15 0x1F, 0x04B6
147 #define DP83822_RXFPAT16 0x1F, 0x04B7
148 #define DP83822_RXFPAT17 0x1F, 0x04B8
149 #define DP83822_RXFPAT18 0x1F, 0x04B9
150 #define DP83822_RXFPAT19 0x1F, 0x04BA
151 #define DP83822_RXFPAT20 0x1F, 0x04BB
152 #define DP83822_RXFPAT21 0x1F, 0x04BC
153 #define DP83822_RXFPAT22 0x1F, 0x04BD
154 #define DP83822_RXFPAT23 0x1F, 0x04BE
155 #define DP83822_RXFPAT24 0x1F, 0x04BF
156 #define DP83822_RXFPAT25 0x1F, 0x04C0
157 #define DP83822_RXFPAT26 0x1F, 0x04C1
158 #define DP83822_RXFPAT27 0x1F, 0x04C2
159 #define DP83822_RXFPAT28 0x1F, 0x04C3
160 #define DP83822_RXFPAT29 0x1F, 0x04C4
161 #define DP83822_RXFPAT30 0x1F, 0x04C5
162 #define DP83822_RXFPAT31 0x1F, 0x04C6
163 #define DP83822_RXFPAT32 0x1F, 0x04C7
164 #define DP83822_RXFPBM1 0x1F, 0x04C8
165 #define DP83822_RXFPBM2 0x1F, 0x04C9
166 #define DP83822_RXFPBM3 0x1F, 0x04CA
167 #define DP83822_RXFPBM4 0x1F, 0x04CB
168 #define DP83822_RXFPATC 0x1F, 0x04CC
169 #define DP83822_EEECFG2 0x1F, 0x04D0
170 #define DP83822_EEECFG3 0x1F, 0x04D1
171 #define DP83822_TLBCR1 0x1F, 0x04D4
172 #define DP83822_TLBCR2 0x1F, 0x04D5
173 #define DP83822_TLBCR3 0x1F, 0x04D6
174 
175 //Basic Mode Control register
176 #define DP83822_BMCR_RESET 0x8000
177 #define DP83822_BMCR_LOOPBACK 0x4000
178 #define DP83822_BMCR_SPEED_SEL 0x2000
179 #define DP83822_BMCR_AN_EN 0x1000
180 #define DP83822_BMCR_POWER_DOWN 0x0800
181 #define DP83822_BMCR_ISOLATE 0x0400
182 #define DP83822_BMCR_RESTART_AN 0x0200
183 #define DP83822_BMCR_DUPLEX_MODE 0x0100
184 #define DP83822_BMCR_COL_TEST 0x0080
185 
186 //Basic Mode Status register
187 #define DP83822_BMSR_100BT4 0x8000
188 #define DP83822_BMSR_100BTX_FD 0x4000
189 #define DP83822_BMSR_100BTX_HD 0x2000
190 #define DP83822_BMSR_10BT_FD 0x1000
191 #define DP83822_BMSR_10BT_HD 0x0800
192 #define DP83822_BMSR_SMI_PREAMBLE_SUPPR 0x0040
193 #define DP83822_BMSR_AN_COMPLETE 0x0020
194 #define DP83822_BMSR_REMOTE_FAULT 0x0010
195 #define DP83822_BMSR_AN_CAPABLE 0x0008
196 #define DP83822_BMSR_LINK_STATUS 0x0004
197 #define DP83822_BMSR_JABBER_DETECT 0x0002
198 #define DP83822_BMSR_EXTENDED_CAPABLE 0x0001
199 
200 //PHY Identifier 1 register
201 #define DP83822_PHYIDR1_OUI_MSB 0xFFFF
202 #define DP83822_PHYIDR1_OUI_MSB_DEFAULT 0x2000
203 
204 //PHY Identifier 2 register
205 #define DP83822_PHYIDR2_OUI_LSB 0xFC00
206 #define DP83822_PHYIDR2_OUI_LSB_DEFAULT 0xA000
207 #define DP83822_PHYIDR2_MODEL_NUMBER 0x03F0
208 #define DP83822_PHYIDR2_MODEL_NUMBER_DEFAULT 0x0240
209 #define DP83822_PHYIDR2_REV_NUMBER 0x000F
210 
211 //Auto-Negotiation Advertisement register
212 #define DP83822_ANAR_NEXT_PAGE 0x8000
213 #define DP83822_ANAR_REMOTE_FAULT 0x2000
214 #define DP83822_ANAR_ASYM_DIR 0x0800
215 #define DP83822_ANAR_PAUSE 0x0400
216 #define DP83822_ANAR_100BT4 0x0200
217 #define DP83822_ANAR_100BTX_FD 0x0100
218 #define DP83822_ANAR_100BTX_HD 0x0080
219 #define DP83822_ANAR_10BT_FD 0x0040
220 #define DP83822_ANAR_10BT_HD 0x0020
221 #define DP83822_ANAR_SELECTOR 0x001F
222 #define DP83822_ANAR_SELECTOR_DEFAULT 0x0001
223 
224 //Auto-Negotiation Link Partner Ability register
225 #define DP83822_ANLPAR_NEXT_PAGE 0x8000
226 #define DP83822_ANLPAR_ACK 0x4000
227 #define DP83822_ANLPAR_REMOTE_FAULT 0x2000
228 #define DP83822_ANLPAR_ASYM_DIR 0x0800
229 #define DP83822_ANLPAR_PAUSE 0x0400
230 #define DP83822_ANLPAR_100BT4 0x0200
231 #define DP83822_ANLPAR_100BTX_FD 0x0100
232 #define DP83822_ANLPAR_100BTX_HD 0x0080
233 #define DP83822_ANLPAR_10BT_FD 0x0040
234 #define DP83822_ANLPAR_10BT_HD 0x0020
235 #define DP83822_ANLPAR_SELECTOR 0x001F
236 #define DP83822_ANLPAR_SELECTOR_DEFAULT 0x0001
237 
238 //Auto-Negotiation Expansion register
239 #define DP83822_ANER_PAR_DETECT_FAULT 0x0010
240 #define DP83822_ANER_LP_NEXT_PAGE_ABLE 0x0008
241 #define DP83822_ANER_NEXT_PAGE_ABLE 0x0004
242 #define DP83822_ANER_PAGE_RECEIVED 0x0002
243 #define DP83822_ANER_LP_AN_ABLE 0x0001
244 
245 //Auto-Negotiation Next Page TX register
246 #define DP83822_ANNPTR_NEXT_PAGE 0x8000
247 #define DP83822_ANNPTR_MSG_PAGE 0x2000
248 #define DP83822_ANNPTR_ACK2 0x1000
249 #define DP83822_ANNPTR_TOGGLE 0x0800
250 #define DP83822_ANNPTR_CODE 0x07FF
251 
252 //Auto-Negotiation Link Partner Ability Next Page register
253 #define DP83822_ANLNPTR_NEXT_PAGE 0x8000
254 #define DP83822_ANLNPTR_ACK 0x4000
255 #define DP83822_ANLNPTR_MSG_PAGE 0x2000
256 #define DP83822_ANLNPTR_ACK2 0x1000
257 #define DP83822_ANLNPTR_TOGGLE 0x0800
258 #define DP83822_ANLNPTR_MESSAGE 0x07FF
259 
260 //Control 1 register
261 #define DP83822_CR1_RMII_ENHANCED_MODE 0x0200
262 #define DP83822_CR1_TDR_AUTO_RUN 0x0100
263 #define DP83822_CR1_LINK_LOSS_RECOVERY 0x0080
264 #define DP83822_CR1_FAST_AUTO_MDIX 0x0040
265 #define DP83822_CR1_ROBUST_AUTO_MDIX 0x0020
266 #define DP83822_CR1_FAST_AN_EN 0x0010
267 #define DP83822_CR1_FAST_AN_SEL 0x000C
268 #define DP83822_CR1_FAST_RX_DV_DETECT 0x0002
269 
270 //Control 2 register
271 #define DP83822_CR2_FORCE_FAR_END_LINK_DROP 0x8000
272 #define DP83822_CR2_100BFX_EN 0x4000
273 #define DP83822_CR2_FAST_LINK_UP_IN_PD 0x0040
274 #define DP83822_CR2_EXTENDED_FD_ABLE 0x0020
275 #define DP83822_CR2_ENHANCED_LED_LINK 0x0010
276 #define DP83822_CR2_ISOLATE_MII 0x0008
277 #define DP83822_CR2_RX_ER_DURING_IDLE 0x0004
278 #define DP83822_CR2_ODD_NIBBLE_DETECT_DIS 0x0002
279 #define DP83822_CR2_RMII_RECEIVE_CLK 0x0001
280 
281 //Control 3 register
282 #define DP83822_CR3_DESCRAMBLER_FAST_LINK_DOWN 0x0400
283 #define DP83822_CR3_POLARITY_SWAP 0x0040
284 #define DP83822_CR3_MDIX_SWAP 0x0020
285 #define DP83822_CR3_FAST_LINK_DOWN_MODE 0x000F
286 
287 //Register Control register
288 #define DP83822_REGCR_CMD 0xC000
289 #define DP83822_REGCR_CMD_ADDR 0x0000
290 #define DP83822_REGCR_CMD_DATA_NO_POST_INC 0x4000
291 #define DP83822_REGCR_CMD_DATA_POST_INC_RW 0x8000
292 #define DP83822_REGCR_CMD_DATA_POST_INC_W 0xC000
293 #define DP83822_REGCR_DEVAD 0x001F
294 
295 //Fast Link Down Status register
296 #define DP83822_FLDS_FAST_LINK_DOWN_STATUS 0x01F0
297 
298 //PHY Status register
299 #define DP83822_PHYSTS_MDIX_MODE 0x4000
300 #define DP83822_PHYSTS_RECEIVE_ERROR_LATCH 0x2000
301 #define DP83822_PHYSTS_POLARITY_STATUS 0x1000
302 #define DP83822_PHYSTS_FALSE_CARRIER_SENSE_LATCH 0x0800
303 #define DP83822_PHYSTS_SIGNAL_DETECT 0x0400
304 #define DP83822_PHYSTS_DESCRAMBLER_LOCK 0x0200
305 #define DP83822_PHYSTS_PAGE_RECEIVED 0x0100
306 #define DP83822_PHYSTS_MII_INTERRUPT 0x0080
307 #define DP83822_PHYSTS_REMOTE_FAULT 0x0040
308 #define DP83822_PHYSTS_JABBER_DETECT 0x0020
309 #define DP83822_PHYSTS_AN_STATUS 0x0010
310 #define DP83822_PHYSTS_LOOPBACK_STATUS 0x0008
311 #define DP83822_PHYSTS_DUPLEX_STATUS 0x0004
312 #define DP83822_PHYSTS_SPEED_STATUS 0x0002
313 #define DP83822_PHYSTS_LINK_STATUS 0x0001
314 
315 //PHY Specific Control register
316 #define DP83822_PHYSCR_PLL_DIS 0x8000
317 #define DP83822_PHYSCR_POWER_SAVE_MODE_EN 0x4000
318 #define DP83822_PHYSCR_POWER_SAVE_MODE 0x3000
319 #define DP83822_PHYSCR_SCRAMBLER_BYPASS 0x0800
320 #define DP83822_PHYSCR_LOOPBACK_FIFO_DEPTH 0x0300
321 #define DP83822_PHYSCR_COL_FD_EN 0x0010
322 #define DP83822_PHYSCR_INT_POLARITY 0x0008
323 #define DP83822_PHYSCR_TEST_INT 0x0004
324 #define DP83822_PHYSCR_INT_EN 0x0002
325 #define DP83822_PHYSCR_INT_OE 0x0001
326 
327 //MII Interrupt Status 1 register
328 #define DP83822_MISR1_LQ_INT 0x8000
329 #define DP83822_MISR1_ED_INT 0x4000
330 #define DP83822_MISR1_LINK_INT 0x2000
331 #define DP83822_MISR1_SPD_INT 0x1000
332 #define DP83822_MISR1_DUP_INT 0x0800
333 #define DP83822_MISR1_ANC_INT 0x0400
334 #define DP83822_MISR1_FHF_INT 0x0200
335 #define DP83822_MISR1_RHF_INT 0x0100
336 #define DP83822_MISR1_LQ_INT_EN 0x0080
337 #define DP83822_MISR1_ED_INT_EN 0x0040
338 #define DP83822_MISR1_LINK_INT_EN 0x0020
339 #define DP83822_MISR1_SPD_INT_EN 0x0010
340 #define DP83822_MISR1_DUP_INT_EN 0x0008
341 #define DP83822_MISR1_ANC_INT_EN 0x0004
342 #define DP83822_MISR1_FHF_INT_EN 0x0002
343 #define DP83822_MISR1_RHF_INT_EN 0x0001
344 
345 //MII Interrupt Status 2 register
346 #define DP83822_MISR2_EEE_ERROR_INT 0x8000
347 #define DP83822_MISR2_AN_ERROR_INT 0x4000
348 #define DP83822_MISR2_PR_INT 0x2000
349 #define DP83822_MISR2_FIFO_OF_UF_INT 0x1000
350 #define DP83822_MISR2_MDI_CHANGE_INT 0x0800
351 #define DP83822_MISR2_SLEEP_MODE_INT 0x0400
352 #define DP83822_MISR2_POL_CHANGE_INT 0x0200
353 #define DP83822_MISR2_JABBER_DETECT_INT 0x0100
354 #define DP83822_MISR2_EEE_ERROR_INT_EN 0x0080
355 #define DP83822_MISR2_AN_ERROR_INT_EN 0x0040
356 #define DP83822_MISR2_PR_INT_EN 0x0020
357 #define DP83822_MISR2_FIFO_OF_UF_INT_EN 0x0010
358 #define DP83822_MISR2_MDI_CHANGE_INT_EN 0x0008
359 #define DP83822_MISR2_SLEEP_MODE_INT_EN 0x0004
360 #define DP83822_MISR2_POL_CHANGE_INT_EN 0x0002
361 #define DP83822_MISR2_JABBER_DETECT_INT_EN 0x0001
362 
363 //False Carrier Sense Counter register
364 #define DP83822_FCSCR_FCSCNT 0x00FF
365 
366 //Receive Error Counter register
367 #define DP83822_RECR_RXERCNT 0xFFFF
368 
369 //BIST Control register
370 #define DP83822_BISCR_ERROR_COUNTER_MODE 0x4000
371 #define DP83822_BISCR_PRBS_CHECKER 0x2000
372 #define DP83822_BISCR_PACKET_GEN_EN 0x1000
373 #define DP83822_BISCR_PRBS_CHECKER_LOCK_SYNC 0x0800
374 #define DP83822_BISCR_PRBS_CHECKER_SYNC_LOSS 0x0400
375 #define DP83822_BISCR_PACKET_GEN_STATUS 0x0200
376 #define DP83822_BISCR_POWER_MODE 0x0100
377 #define DP83822_BISCR_TX_MII_LOOPBACK 0x0040
378 #define DP83822_BISCR_LOOPBACK_MODE 0x001F
379 #define DP83822_BISCR_LOOPBACK_MODE_PCS_INPUT 0x0001
380 #define DP83822_BISCR_LOOPBACK_MODE_PCS_OUTPUT 0x0002
381 #define DP83822_BISCR_LOOPBACK_MODE_DIGITAL 0x0004
382 #define DP83822_BISCR_LOOPBACK_MODE_ANALOG 0x0008
383 #define DP83822_BISCR_LOOPBACK_MODE_REVERSE 0x0010
384 
385 //RMII and Status register
386 #define DP83822_RCSR_RGMII_RX_CLK_SHIFT 0x1000
387 #define DP83822_RCSR_RGMII_TX_CLK_SHIFT 0x0800
388 #define DP83822_RCSR_RGMII_TX_SYNCED 0x0400
389 #define DP83822_RCSR_RGMII_MODE 0x0200
390 #define DP83822_RCSR_RMII_TX_CLOCK_SHIFT 0x0100
391 #define DP83822_RCSR_RMII_CLK_SEL 0x0080
392 #define DP83822_RCSR_RMII_ASYNC_FIFO_BYPASS 0x0040
393 #define DP83822_RCSR_RMII_MODE 0x0020
394 #define DP83822_RCSR_RMII_REV_SEL 0x0010
395 #define DP83822_RCSR_RMII_OVF_STATUS 0x0008
396 #define DP83822_RCSR_RMII_UNF_STATUS 0x0004
397 #define DP83822_RCSR_RX_ELAST_BUFFER_SIZE 0x0003
398 #define DP83822_RCSR_RX_ELAST_BUFFER_SIZE_14_BITS 0x0000
399 #define DP83822_RCSR_RX_ELAST_BUFFER_SIZE_2_BITS 0x0001
400 #define DP83822_RCSR_RX_ELAST_BUFFER_SIZE_6_BITS 0x0002
401 #define DP83822_RCSR_RX_ELAST_BUFFER_SIZE_10_BITS 0x0003
402 
403 //LED Direct Control register
404 #define DP83822_LEDCR_BLINK_RATE 0x0600
405 #define DP83822_LEDCR_BLINK_RATE_20MHZ 0x0000
406 #define DP83822_LEDCR_BLINK_RATE_10MHZ 0x0200
407 #define DP83822_LEDCR_BLINK_RATE_5MHZ 0x0400
408 #define DP83822_LEDCR_BLINK_RATE_2MHZ 0x0600
409 #define DP83822_LEDCR_LED_0_POLARITY 0x0080
410 #define DP83822_LEDCR_DRIVE_LED_0 0x0010
411 #define DP83822_LEDCR_LED_0_ON_OFF 0x0002
412 
413 //PHY Control register
414 #define DP83822_PHYCR_MDIX_EN 0x8000
415 #define DP83822_PHYCR_FORCE_MDIX 0x4000
416 #define DP83822_PHYCR_PAUSE_RX_STATUS 0x2000
417 #define DP83822_PHYCR_PAUSE_TX_STATUS 0x1000
418 #define DP83822_PHYCR_MII_LINK_STATUS 0x0800
419 #define DP83822_PHYCR_BYPASS_LED_STRETCH 0x0080
420 #define DP83822_PHYCR_LED_CONFIG 0x0020
421 #define DP83822_PHYCR_PHY_ADDR 0x001F
422 
423 //10Base-T Status/Control register
424 #define DP83822_10BTSCR_RX_THRESHOLD_EN 0x2000
425 #define DP83822_10BTSCR_SQUELCH 0x1E00
426 #define DP83822_10BTSCR_SQUELCH_200MV 0x0000
427 #define DP83822_10BTSCR_SQUELCH_250MV 0x0200
428 #define DP83822_10BTSCR_SQUELCH_300MV 0x0400
429 #define DP83822_10BTSCR_SQUELCH_350MV 0x0600
430 #define DP83822_10BTSCR_SQUELCH_400MV 0x0800
431 #define DP83822_10BTSCR_SQUELCH_450MV 0x0A00
432 #define DP83822_10BTSCR_SQUELCH_500MV 0x0C00
433 #define DP83822_10BTSCR_SQUELCH_550MV 0x0E00
434 #define DP83822_10BTSCR_SQUELCH_600MV 0x1000
435 #define DP83822_10BTSCR_NLP_DIS 0x0080
436 #define DP83822_10BTSCR_POLARITY_STATUS 0x0010
437 #define DP83822_10BTSCR_JABBER_DIS 0x0001
438 
439 //BIST Control and Status 1 register
440 #define DP83822_BICSR1_BIST_ERROR_COUNT 0xFF00
441 #define DP83822_BICSR1_BIST_IPG_LENGTH 0x00FF
442 
443 //BIST Control and Status 2 register
444 #define DP83822_BICSR2_BIST_PACKET_LENGTH 0x07FF
445 
446 //Cable Diagnostic Control register
447 #define DP83822_CDCR_CABLE_DIAG_START 0x8000
448 #define DP83822_CDCR_CDCR_CABLE_DIAG_STATUS 0x0002
449 #define DP83822_CDCR_CDCR_CABLE_DIAG_TEST_FAIL 0x0001
450 
451 //PHY Reset Control register
452 #define DP83822_PHYRCR_SOFT_RESET 0x8000
453 #define DP83822_PHYRCR_DIGITAL_RESTART 0x4000
454 
455 //Multi-LED Control register
456 #define DP83822_MLEDCR_MLED_POLARITY_SWAP 0x0200
457 #define DP83822_MLEDCR_MLED_CONFIG 0x0078
458 #define DP83822_MLEDCR_MLED_CONFIG_LINK 0x0000
459 #define DP83822_MLEDCR_MLED_CONFIG_ACT 0x0008
460 #define DP83822_MLEDCR_MLED_CONFIG_TX_ACT 0x0010
461 #define DP83822_MLEDCR_MLED_CONFIG_RX_ACT 0x0018
462 #define DP83822_MLEDCR_MLED_CONFIG_COL 0x0020
463 #define DP83822_MLEDCR_MLED_CONFIG_SPEED_100 0x0028
464 #define DP83822_MLEDCR_MLED_CONFIG_SPEED_10 0x0030
465 #define DP83822_MLEDCR_MLED_CONFIG_FD 0x0038
466 #define DP83822_MLEDCR_MLED_CONFIG_LINK_ACT 0x0040
467 #define DP83822_MLEDCR_MLED_CONFIG_ACT_STRETCH_SIG 0x0048
468 #define DP83822_MLEDCR_MLED_CONFIG_MII_LINK 0x0050
469 #define DP83822_MLEDCR_MLED_CONFIG_LPI_MODE 0x0058
470 #define DP83822_MLEDCR_MLED_CONFIG_MII_ERR 0x0060
471 #define DP83822_MLEDCR_MLED_CONFIG_LINK_LOST 0x0068
472 #define DP83822_MLEDCR_MLED_CONFIG_PRBS_ERR 0x0070
473 #define DP83822_MLEDCR_MLED_ROUTE 0x0003
474 #define DP83822_MLEDCR_MLED_ROUTE_COL 0x0000
475 #define DP83822_MLEDCR_MLED_ROUTE_LED0 0x0003
476 
477 //C++ guard
478 #ifdef __cplusplus
479 extern "C" {
480 #endif
481 
482 //DP83822 Ethernet PHY driver
483 extern const PhyDriver dp83822PhyDriver;
484 
485 //DP83822 related functions
486 error_t dp83822Init(NetInterface *interface);
487 void dp83822InitHook(NetInterface *interface);
488 
489 void dp83822Tick(NetInterface *interface);
490 
491 void dp83822EnableIrq(NetInterface *interface);
492 void dp83822DisableIrq(NetInterface *interface);
493 
494 void dp83822EventHandler(NetInterface *interface);
495 
496 void dp83822WritePhyReg(NetInterface *interface, uint8_t address,
497  uint16_t data);
498 
499 uint16_t dp83822ReadPhyReg(NetInterface *interface, uint8_t address);
500 
501 void dp83822DumpPhyReg(NetInterface *interface);
502 
503 void dp83822WriteMmdReg(NetInterface *interface, uint8_t devAddr,
504  uint16_t regAddr, uint16_t data);
505 
506 uint16_t dp83822ReadMmdReg(NetInterface *interface, uint8_t devAddr,
507  uint16_t regAddr);
508 
509 //C++ guard
510 #ifdef __cplusplus
511 }
512 #endif
513 
514 #endif
Ethernet PHY driver.
Definition: nic.h:311
uint8_t data[]
Definition: ethernet.h:222
void dp83822EventHandler(NetInterface *interface)
DP83822 event handler.
void dp83822DisableIrq(NetInterface *interface)
Disable interrupts.
uint16_t dp83822ReadPhyReg(NetInterface *interface, uint8_t address)
Read PHY register.
void dp83822WriteMmdReg(NetInterface *interface, uint8_t devAddr, uint16_t regAddr, uint16_t data)
Write MMD register.
void dp83822InitHook(NetInterface *interface)
DP83822 custom configuration.
const PhyDriver dp83822PhyDriver
DP83822 Ethernet PHY driver.
error_t
Error codes.
Definition: error.h:43
#define NetInterface
Definition: net.h:36
void dp83822WritePhyReg(NetInterface *interface, uint8_t address, uint16_t data)
Write PHY register.
uint16_t regAddr
void dp83822EnableIrq(NetInterface *interface)
Enable interrupts.
Ipv6Addr address[]
Definition: ipv6.h:325
Network interface controller abstraction layer.
error_t dp83822Init(NetInterface *interface)
DP83822 PHY transceiver initialization.
void dp83822DumpPhyReg(NetInterface *interface)
Dump PHY registers for debugging purpose.
void dp83822Tick(NetInterface *interface)
DP83822 timer handler.
uint16_t dp83822ReadMmdReg(NetInterface *interface, uint8_t devAddr, uint16_t regAddr)
Read MMD register.