lan8770_driver.h
Go to the documentation of this file.
1 /**
2  * @file lan8770_driver.h
3  * @brief LAN8770 100Base-T1 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 _LAN8770_DRIVER_H
32 #define _LAN8770_DRIVER_H
33 
34 //Dependencies
35 #include "core/nic.h"
36 
37 //PHY address
38 #ifndef LAN8770_PHY_ADDR
39  #define LAN8770_PHY_ADDR 4
40 #elif (LAN8770_PHY_ADDR < 0 || LAN8770_PHY_ADDR > 31)
41  #error LAN8770_PHY_ADDR parameter is not valid
42 #endif
43 
44 //LAN8770 PHY registers
45 #define LAN8770_BASIC_CONTROL 0x00
46 #define LAN8770_BASIC_STATUS 0x01
47 #define LAN8770_PHY_ID1 0x02
48 #define LAN8770_PHY_ID2 0x03
49 #define LAN8770_MASTER_SLAVE_CONTROL 0x09
50 #define LAN8770_MASTER_SLAVE_STATUS 0x0A
51 #define LAN8770_MDIO_CONTROL2 0x10
52 #define LAN8770_MODE_STATUS 0x11
53 #define LAN8770_EXT_REG_CTL 0x14
54 #define LAN8770_EXT_REG_RD_DATA 0x15
55 #define LAN8770_EXT_REG_WR_DATA 0x16
56 #define LAN8770_PCS_CONTROL 0x17
57 #define LAN8770_INTERRUPT_SOURCE 0x18
58 #define LAN8770_INTERRUPT_MASK 0x19
59 #define LAN8770_POWER_DOWN_CONTROL 0x1A
60 #define LAN8770_PCS_RX_ERR_CNT_STS 0x1E
61 
62 //LAN8770 MISC registers (bank 1)
63 #define LAN8770_REV_ID 0x01, 0x01
64 #define LAN8770_INTERRUPT2_SOURCE 0x01, 0x08
65 #define LAN8770_INTERRUPT2_MASK 0x01, 0x09
66 #define LAN8770_CTRL_0 0x01, 0x10
67 #define LAN8770_CTRL_1 0x01, 0x11
68 #define LAN8770_CTRL_2 0x01, 0x15
69 #define LAN8770_CTRL_3 0x01, 0x17
70 #define LAN8770_DCQ_ERR_MAX 0x01, 0x1A
71 #define LAN8770_WKP_COM_CTL0 0x01, 0x20
72 #define LAN8770_WKP_COM_CTL1 0x01, 0x21
73 #define LAN8770_WKP_DBG_STS 0x01, 0x22
74 #define LAN8770_WKP_PRT_CTL 0x01, 0x24
75 
76 //LAN8770 PCS registers (bank 2)
77 #define LAN8770_SLEEP_WAKE_DET 0x02, 0x20
78 
79 //LAN8770 AFE registers (bank 3)
80 #define LAN8770_AFE_PORT_CFG1 0x03, 0x0B
81 
82 //LAN8770 DSP registers (bank 4)
83 #define LAN8770_COEF_CLK_PWR_DN_CFG 0x04, 0x04
84 #define LAN8770_COEF_RW_CTL_CFG 0x04, 0x0D
85 #define LAN8770_DCQ_CONFIG1 0x04, 0x2E
86 #define LAN8770_DCQ_CONFIG2 0x04, 0x4A
87 #define LAN8770_SQI_SQU_MEAN_LSB 0x04, 0x82
88 #define LAN8770_SQI_SQU_MEAN_MSB 0x04, 0x83
89 #define LAN8770_SQI_TBL0 0x04, 0xBA
90 #define LAN8770_SQI_TBL1 0x04, 0xBB
91 #define LAN8770_SQI_TBL2 0x04, 0xBC
92 #define LAN8770_SQI_TBL3 0x04, 0xBD
93 #define LAN8770_SQI_TBL4 0x04, 0xBE
94 #define LAN8770_SQI_TBL5 0x04, 0xBF
95 #define LAN8770_SQI_TBL6 0x04, 0xC0
96 #define LAN8770_DCQ_MSE 0x04, 0xC1
97 #define LAN8770_DCQ_MSE_WC 0x04, 0xC2
98 #define LAN8770_DCQ_SQI 0x04, 0xC3
99 #define LAN8770_DCQ_PMSE 0x04, 0xC4
100 #define LAN8770_BER_RATE_CNT 0x04, 0xF3
101 #define LAN8770_BER_RATE_WIN_TOG 0x04, 0xF4
102 
103 //Basic Control register
104 #define LAN8770_BASIC_CONTROL_SW_RESET 0x8000
105 #define LAN8770_BASIC_CONTROL_LOOPBACK 0x4000
106 #define LAN8770_BASIC_CONTROL_SPEED_SEL_LSB 0x2000
107 #define LAN8770_BASIC_CONTROL_AN_EN 0x1000
108 #define LAN8770_BASIC_CONTROL_POWER_DOWN 0x0800
109 #define LAN8770_BASIC_CONTROL_ISOLATE 0x0400
110 #define LAN8770_BASIC_CONTROL_RESTART_AN 0x0200
111 #define LAN8770_BASIC_CONTROL_DUPLEX_MODE 0x0100
112 #define LAN8770_BASIC_CONTROL_COL_TEST 0x0080
113 #define LAN8770_BASIC_CONTROL_SPEED_SEL_MSB 0x0040
114 #define LAN8770_BASIC_CONTROL_UNIDIRECTIONAL_EN 0x0020
115 
116 //Basic Status register
117 #define LAN8770_BASIC_STATUS_100BT4 0x8000
118 #define LAN8770_BASIC_STATUS_100BTX_FD 0x4000
119 #define LAN8770_BASIC_STATUS_100BTX_HD 0x2000
120 #define LAN8770_BASIC_STATUS_10BT_FD 0x1000
121 #define LAN8770_BASIC_STATUS_10BT_HD 0x0800
122 #define LAN8770_BASIC_STATUS_100BT2_FD 0x0400
123 #define LAN8770_BASIC_STATUS_100BT2_HD 0x0200
124 #define LAN8770_BASIC_STATUS_EXTENDED_STATUS 0x0100
125 #define LAN8770_BASIC_STATUS_UNIDIRECTIONAL_EN 0x0080
126 #define LAN8770_BASIC_STATUS_MF_PREAMBLE_SUPPR 0x0040
127 #define LAN8770_BASIC_STATUS_AN_COMPLETE 0x0020
128 #define LAN8770_BASIC_STATUS_REMOTE_FAULT 0x0010
129 #define LAN8770_BASIC_STATUS_AN_CAPABLE 0x0008
130 #define LAN8770_BASIC_STATUS_LINK_STATUS 0x0004
131 #define LAN8770_BASIC_STATUS_JABBER_DETECT 0x0002
132 #define LAN8770_BASIC_STATUS_EXTENDED_CAPABLE 0x0001
133 
134 //PHY Identifier 1 register
135 #define LAN8770_PHY_ID1_PHY_ID_MSB 0xFFFF
136 #define LAN8770_PHY_ID1_PHY_ID_MSB_DEFAULT 0x0007
137 
138 //PHY Identifier 2 register
139 #define LAN8770_PHY_ID2_PHY_ID_LSB 0xFC00
140 #define LAN8770_PHY_ID2_PHY_ID_LSB_DEFAULT 0xC000
141 #define LAN8770_PHY_ID2_MODEL_NUM 0x03F0
142 #define LAN8770_PHY_ID2_MODEL_NUM_DEFAULT 0x0150
143 #define LAN8770_PHY_ID2_REVISION_NUM 0x000F
144 
145 //Master/Slave Control register
146 #define LAN8770_MASTER_SLAVE_CONTROL_TEST_MODE 0xE000
147 #define LAN8770_MASTER_SLAVE_CONTROL_MS_MAN_CONF_EN 0x1000
148 #define LAN8770_MASTER_SLAVE_CONTROL_MS_MAN_CONF_VAL 0x0800
149 #define LAN8770_MASTER_SLAVE_CONTROL_PORT_TYPE 0x0400
150 #define LAN8770_MASTER_SLAVE_CONTROL_1000BT_FD 0x0200
151 #define LAN8770_MASTER_SLAVE_CONTROL_1000BT_HD 0x0100
152 
153 //Master/Slave Status register
154 #define LAN8770_MASTER_SLAVE_STATUS_MS_CONF_FAULT 0x8000
155 #define LAN8770_MASTER_SLAVE_STATUS_MS_CONF_RES 0x4000
156 #define LAN8770_MASTER_SLAVE_STATUS_LOC_RCVR_STATUS 0x2000
157 #define LAN8770_MASTER_SLAVE_STATUS_REM_RCVR_STATUS 0x1000
158 #define LAN8770_MASTER_SLAVE_STATUS_LP_1000BT_FD 0x0800
159 #define LAN8770_MASTER_SLAVE_STATUS_LP_1000BT_HD 0x0400
160 #define LAN8770_MASTER_SLAVE_STATUS_IDLE_ERR_COUNT 0x00FF
161 
162 //MDIO Control 2 register
163 #define LAN8770_MDIO_CONTROL2_WAKE_REQ 0x2000
164 #define LAN8770_MDIO_CONTROL2_SLEEP_REQ 0x1000
165 
166 //Mode Status register
167 #define LAN8770_MODE_STATUS_ENERGY_STATUS 0x0040
168 #define LAN8770_MODE_STATUS_DSCR_LOCK_STATUS 0x0008
169 #define LAN8770_MODE_STATUS_LINK_UP 0x0001
170 
171 //Extended Register Control register
172 #define LAN8770_EXT_REG_CTL_READ_CONTROL 0x1000
173 #define LAN8770_EXT_REG_CTL_WRITE_CONTROL 0x0800
174 #define LAN8770_EXT_REG_CTL_REGISTER_BANK 0x0700
175 #define LAN8770_EXT_REG_CTL_REGISTER_BANK_MISC 0x0100
176 #define LAN8770_EXT_REG_CTL_REGISTER_BANK_PCS 0x0200
177 #define LAN8770_EXT_REG_CTL_REGISTER_BANK_AFE 0x0300
178 #define LAN8770_EXT_REG_CTL_REGISTER_BANK_DSP 0x0400
179 #define LAN8770_EXT_REG_CTL_REGISTER_ADDR 0x00FF
180 
181 //PCS Control register
182 #define LAN8770_PCS_CONTROL_POL_FLIP_RX_CTRL 0x0200
183 #define LAN8770_PCS_CONTROL_POL_FLIP_TX_CTRL 0x0100
184 #define LAN8770_PCS_CONTROL_POL_FLIP_MAN_CTRL 0x0080
185 
186 //Interrupt Source register
187 #define LAN8770_INTERRUPT_SOURCE_SOFT 0x8000
188 #define LAN8770_INTERRUPT_SOURCE_WAKE_IN 0x4000
189 #define LAN8770_INTERRUPT_SOURCE_BER_TOGGLE 0x2000
190 #define LAN8770_INTERRUPT_SOURCE_DCQ_ERROR 0x1000
191 #define LAN8770_INTERRUPT_SOURCE_OVER_TEMP_ERROR 0x0800
192 #define LAN8770_INTERRUPT_SOURCE_RECEIVE_WAKE 0x0400
193 #define LAN8770_INTERRUPT_SOURCE_ENERGY_OFF 0x0040
194 #define LAN8770_INTERRUPT_SOURCE_RECEIVE_LPS 0x0020
195 #define LAN8770_INTERRUPT_SOURCE_JABBER_DETECT 0x0008
196 #define LAN8770_INTERRUPT_SOURCE_LINK_UP 0x0004
197 #define LAN8770_INTERRUPT_SOURCE_LINK_DOWN 0x0002
198 #define LAN8770_INTERRUPT_SOURCE_ENERGY_ON 0x0001
199 
200 //Interrupt Mask register
201 #define LAN8770_INTERRUPT_MASK_SOFT 0x8000
202 #define LAN8770_INTERRUPT_MASK_WAKE_IN 0x4000
203 #define LAN8770_INTERRUPT_MASK_BER_TOGGLE 0x2000
204 #define LAN8770_INTERRUPT_MASK_DCQ_ERROR 0x1000
205 #define LAN8770_INTERRUPT_MASK_OVER_TEMP_ERROR 0x0800
206 #define LAN8770_INTERRUPT_MASK_RECEIVE_WAKE 0x0400
207 #define LAN8770_INTERRUPT_MASK_ENERGY_OFF 0x0040
208 #define LAN8770_INTERRUPT_MASK_RECEIVE_LPS 0x0020
209 #define LAN8770_INTERRUPT_MASK_JABBER_DETECT 0x0008
210 #define LAN8770_INTERRUPT_MASK_LINK_UP 0x0004
211 #define LAN8770_INTERRUPT_MASK_LINK_DOWN 0x0002
212 #define LAN8770_INTERRUPT_MASK_ENERGY_ON 0x0001
213 
214 //Power Down Control register
215 #define LAN8770_POWER_DOWN_CONTROL_HARD_INIT_SEQ_EN 0x0100
216 
217 //PCS Receive Error Count Status register
218 #define LAN8770_PCS_RX_ERR_CNT_STS_PCS_RX_ERR_CNT 0xFFFF
219 
220 //Revision and ID register
221 #define LAN8770_REV_ID_REVISION 0x00FF
222 
223 //Interrupt 2 Source register
224 #define LAN8770_INTERRUPT2_SOURCE_POR_RDY_STS 0x0800
225 #define LAN8770_INTERRUPT2_SOURCE_COMM_READY 0x0400
226 #define LAN8770_INTERRUPT2_SOURCE_REM_RCVR_STS_DOWN 0x0080
227 #define LAN8770_INTERRUPT2_SOURCE_REM_RCVR_STS_UP 0x0040
228 #define LAN8770_INTERRUPT2_SOURCE_LOC_RCVR_STS_DOWN 0x0020
229 #define LAN8770_INTERRUPT2_SOURCE_LOC_RCVR_STS_UP 0x0010
230 #define LAN8770_INTERRUPT2_SOURCE_DSP_CBL_DIAG_DONE 0x0008
231 #define LAN8770_INTERRUPT2_SOURCE_HW_INIT_DONE 0x0004
232 
233 //Interrupt 2 Mask register
234 #define LAN8770_INTERRUPT2_MASK_POR_RDY 0x0800
235 #define LAN8770_INTERRUPT2_MASK_COMM_READY 0x0400
236 #define LAN8770_INTERRUPT2_MASK_REM_RCVR_STS_DOWN 0x0080
237 #define LAN8770_INTERRUPT2_MASK_REM_RCVR_STS_UP 0x0040
238 #define LAN8770_INTERRUPT2_MASK_LOC_RCVR_STS_DOWN 0x0020
239 #define LAN8770_INTERRUPT2_MASK_LOC_RCVR_STS_UP 0x0010
240 #define LAN8770_INTERRUPT2_MASK_DSP_CBL_DIAG 0x0008
241 #define LAN8770_INTERRUPT2_MASK_HW_INIT_DONE 0x0004
242 
243 //Control 0 register
244 #define LAN8770_CTRL_0_REG_OFF_CONF_STRAP 0x0400
245 #define LAN8770_CTRL_0_PHYAD1_CONF_STRAP 0x0200
246 #define LAN8770_CTRL_0_PHYAD0_CONF_STRAP 0x0100
247 #define LAN8770_CTRL_0_MODE3_CONF_STRAP 0x0080
248 #define LAN8770_CTRL_0_MODE2_CONF_STRAP 0x0040
249 #define LAN8770_CTRL_0_MODE1_CONF_STRAP 0x0020
250 #define LAN8770_CTRL_0_MODE0_CONF_STRAP 0x0010
251 #define LAN8770_CTRL_0_LED_EN 0x0008
252 #define LAN8770_CTRL_0_LED_MODE 0x0007
253 #define LAN8770_CTRL_0_LED_MODE_LINK_UP 0x0000
254 #define LAN8770_CTRL_0_LED_MODE_LINK_UP_REM_STATUS 0x0001
255 #define LAN8770_CTRL_0_LED_MODE_LINK_UP_LOC_STATUS 0x0002
256 
257 //Control 1 register
258 #define LAN8770_CTRL_1_CLK125_EDGE_MODE 0x8000
259 #define LAN8770_CTRL_1_RGMII_TXC_DELAY_EN 0x4000
260 #define LAN8770_CTRL_1_RGMII_RXC_DELAY_EN 0x2000
261 #define LAN8770_CTRL_1_BROADCAST_ADDR_EN 0x1000
262 #define LAN8770_CTRL_1_MISC_DRIVER 0x0C00
263 #define LAN8770_CTRL_1_MISC_DRIVER_2MA 0x0000
264 #define LAN8770_CTRL_1_MISC_DRIVER_4MA 0x0400
265 #define LAN8770_CTRL_1_MISC_DRIVER_8MA 0x0800
266 #define LAN8770_CTRL_1_MISC_DRIVER_10MA 0x0C00
267 #define LAN8770_CTRL_1_MII_DRIVER 0x0300
268 #define LAN8770_CTRL_1_MII_DRIVER_2MA 0x0000
269 #define LAN8770_CTRL_1_MII_DRIVER_4MA 0x0100
270 #define LAN8770_CTRL_1_MII_DRIVER_8MA 0x0200
271 #define LAN8770_CTRL_1_MII_DRIVER_10MA 0x0300
272 #define LAN8770_CTRL_1_MII_EXT_LOOPBACK_EN 0x0008
273 #define LAN8770_CTRL_1_RMII_EXT_LOOPBACK_EN 0x0004
274 #define LAN8770_CTRL_1_PMA_LOOPBACK_EN 0x0002
275 
276 //Control 2 register
277 #define LAN8770_CTRL_2_CLK125_EN 0x8000
278 #define LAN8770_CTRL_2_XMII_MODE 0x0380
279 #define LAN8770_CTRL_2_XMII_MODE_MII 0x0000
280 #define LAN8770_CTRL_2_XMII_MODE_RMII_REFCLK_IN 0x0080
281 #define LAN8770_CTRL_2_XMII_MODE_RMII_REFCLK_OUT 0x0100
282 #define LAN8770_CTRL_2_XMII_MODE_REVERSE_MII 0x0180
283 #define LAN8770_CTRL_2_XMII_MODE_RGMII 0x0200
284 #define LAN8770_CTRL_2_DCQ_INT_SEL 0x0007
285 #define LAN8770_CTRL_2_DCQ_INT_SEL_DCQ_SQI_METHOD_B 0x0000
286 #define LAN8770_CTRL_2_DCQ_INT_SEL_DCQ_MSE 0x0001
287 #define LAN8770_CTRL_2_DCQ_INT_SEL_DCQ_SQI_METHOD_A 0x0002
288 #define LAN8770_CTRL_2_DCQ_INT_SEL_DCQ_PMSE 0x0003
289 
290 //Control 3 register
291 #define LAN8770_CTRL_3_OVER_TEMP_DETECT_STATUS 0x0200
292 #define LAN8770_CTRL_3_TSD_ADJ 0x001C
293 #define LAN8770_CTRL_3_OVER_TEMP_EN 0x0001
294 
295 //Wakeup Common Control 0 register
296 #define LAN8770_WKP_COM_CTL0_VBAT_COMMON_REG_WRITE 0x8000
297 #define LAN8770_WKP_COM_CTL0_RING_OSC_STATUS 0x0040
298 #define LAN8770_WKP_COM_CTL0_RING_OSC_EN 0x0020
299 #define LAN8770_WKP_COM_CTL0_WAKE_DEBOUNCE_UNITS 0x0008
300 #define LAN8770_WKP_COM_CTL0_SLEEP_EN 0x0004
301 #define LAN8770_WKP_COM_CTL0_INH_EN 0x0002
302 #define LAN8770_WKP_COM_CTL0_WAKE_IN_EN 0x0001
303 
304 //Wakeup Common Control 1 register
305 #define LAN8770_WKP_COM_CTL1_WAKE_IN_DEBOUNCE_VALUE 0xFF00
306 
307 //Wakeup Debug Status register
308 #define LAN8770_WKP_DBG_STS_TC10_STATE 0x0007
309 #define LAN8770_WKP_DBG_STS_TC10_STATE_START 0x0000
310 #define LAN8770_WKP_DBG_STS_TC10_STATE_NORMAL 0x0001
311 #define LAN8770_WKP_DBG_STS_TC10_STATE_SLEEP_ACK 0x0002
312 #define LAN8770_WKP_DBG_STS_TC10_STATE_SLEEP_REQ 0x0003
313 #define LAN8770_WKP_DBG_STS_TC10_STATE_SLEEP_FAIL 0x0004
314 #define LAN8770_WKP_DBG_STS_TC10_STATE_SLEEP_SILENT 0x0005
315 #define LAN8770_WKP_DBG_STS_TC10_STATE_SLEEP 0x0006
316 
317 //Wakeup Port Control register
318 #define LAN8770_WKP_PRT_CTL_VBAT_PORT_REG_WRITE 0x8000
319 #define LAN8770_WKP_PRT_CTL_WUP_AUTO_FORWARD_EN 0x1000
320 #define LAN8770_WKP_PRT_CTL_WAKEUP_DEBOUNCE_UNITS 0x0800
321 #define LAN8770_WKP_PRT_CTL_SD_TUNE 0x0600
322 #define LAN8770_WKP_PRT_CTL_MDI_WAKE_EN 0x0100
323 #define LAN8770_WKP_PRT_CTL_WUP_DEBOUNCE_VALUE 0x00FF
324 
325 //Sleep Wake Detect register
326 #define LAN8770_SLEEP_WAKE_DET_WUR_DETECT_LEN 0xFF00
327 #define LAN8770_SLEEP_WAKE_DET_WUR_DETECT_LEN_DEFAULT 0x2800
328 #define LAN8770_SLEEP_WAKE_DET_LPS_DETECT_LEN 0x00FF
329 #define LAN8770_SLEEP_WAKE_DET_LPS_DETECT_LEN_DEFAULT 0x003C
330 
331 //AFE Port Configuration 1 register
332 #define LAN8770_AFE_PORT_CFG1_TX_PD 0x0020
333 #define LAN8770_AFE_PORT_CFG1_TX_AMP 0x001E
334 #define LAN8770_AFE_PORT_CFG1_TX_AMP_DEFAULT 0x0008
335 #define LAN8770_AFE_PORT_CFG1_TX_SRC 0x0001
336 
337 //Coefficient Clock Power Down Configuration register
338 #define LAN8770_COEF_CLK_PWR_DN_CFG_COEF_CLK_PWR_DN_EN 0x0001
339 
340 //Coefficient Control Configuration register
341 #define LAN8770_COEF_RW_CTL_CFG_TAP_EN 0x0020
342 #define LAN8770_COEF_RW_CTL_CFG_TAP_DIS 0x0010
343 #define LAN8770_COEF_RW_CTL_CFG_OVERRIDE_COEF_DIS 0x0008
344 #define LAN8770_COEF_RW_CTL_CFG_OVERRIDE_COEF_EN 0x0004
345 #define LAN8770_COEF_RW_CTL_CFG_POKE_COEF_EN 0x0002
346 #define LAN8770_COEF_RW_CTL_CFG_PEAK_COEF_EN 0x0001
347 
348 //DCQ Configuration 1 register
349 #define LAN8770_DCQ_CONFIG1_PMSE_SCALING_FACTOR 0xC000
350 #define LAN8770_DCQ_CONFIG1_PMSE_KP_FACTOR 0x3C00
351 #define LAN8770_DCQ_CONFIG1_MSE_SCALING_FACTOR 0x0300
352 #define LAN8770_DCQ_CONFIG1_DCQ_RESET 0x0080
353 #define LAN8770_DCQ_CONFIG1_SQI_METHOD_B_MODE_SEL 0x0040
354 #define LAN8770_DCQ_CONFIG1_SQI_METHOD_B_EN 0x0020
355 #define LAN8770_DCQ_CONFIG1_SQI_KP 0x001F
356 
357 //DCQ Configuration 2 register
358 #define LAN8770_DCQ_CONFIG2_DCQ_PMSE_EN 0x0002
359 #define LAN8770_DCQ_CONFIG2_DCQ_MSE_SQI_METHOD_A_EN 0x0001
360 
361 //SQI Method A Table 0 register
362 #define LAN8770_SQI_TBL0_SQI_METHOD_A_VALUE 0x01FF
363 
364 //SQI Method A Table 1 register
365 #define LAN8770_SQI_TBL1_SQI_METHOD_A_VALUE 0x01FF
366 
367 //SQI Method A Table 2 register
368 #define LAN8770_SQI_TBL2_SQI_METHOD_A_VALUE 0x01FF
369 
370 //SQI Method A Table 3 register
371 #define LAN8770_SQI_TBL3_SQI_METHOD_A_VALUE 0x01FF
372 
373 //SQI Method A Table 4 register
374 #define LAN8770_SQI_TBL4_SQI_METHOD_A_VALUE 0x01FF
375 
376 //SQI Method A Table 5 register
377 #define LAN8770_SQI_TBL5_SQI_METHOD_A_VALUE 0x01FF
378 
379 //SQI Method A Table 6 register
380 #define LAN8770_SQI_TBL6_SQI_METHOD_A_VALUE 0x01FF
381 
382 //DCQ Mean Square Error register
383 #define LAN8770_DCQ_MSE_MSE_VALUE_VALID 0x0200
384 #define LAN8770_DCQ_MSE_MSE_VALUE 0x01FF
385 
386 //DCQ Mean Square Error Worst Case register
387 #define LAN8770_DCQ_MSE_WC_MSE_WORST_CASE_VALUE_VALID 0x0200
388 #define LAN8770_DCQ_MSE_WC_MSE_WORST_CASE_VALUE 0x01FF
389 
390 //DCQ SQI Method A register
391 #define LAN8770_DCQ_SQI_DCQ_SQI_METHOD_A_WORST_CASE 0x00E0
392 #define LAN8770_DCQ_SQI_DCQ_SQI_METHOD_A_VALUE 0x000E
393 
394 //DCQ Peak MSE register
395 #define LAN8770_DCQ_PMSE_PEAK_MSE_WORST_CASE 0xFF00
396 #define LAN8770_DCQ_PMSE_PEAK_MSE_VALUE 0x00FF
397 
398 //DCQ Peak MSE register
399 #define LAN8770_BER_RATE_WIN_TOG_BER_WINDOW_TOGGLE 0x0001
400 
401 //C++ guard
402 #ifdef __cplusplus
403 extern "C" {
404 #endif
405 
406 //LAN8770 Ethernet PHY driver
407 extern const PhyDriver lan8770PhyDriver;
408 
409 //LAN8770 related functions
410 error_t lan8770Init(NetInterface *interface);
411 void lan8770InitHook(NetInterface *interface);
412 
413 void lan8770Tick(NetInterface *interface);
414 
415 void lan8770EnableIrq(NetInterface *interface);
416 void lan8770DisableIrq(NetInterface *interface);
417 
418 void lan8770EventHandler(NetInterface *interface);
419 
420 void lan8770WritePhyReg(NetInterface *interface, uint8_t address,
421  uint16_t data);
422 
423 uint16_t lan8770ReadPhyReg(NetInterface *interface, uint8_t address);
424 
425 void lan8770DumpPhyReg(NetInterface *interface);
426 
427 void lan8770WriteExtReg(NetInterface *interface, uint8_t bank,
428  uint8_t addr, uint16_t data);
429 
430 uint16_t lan8770ReadExtReg(NetInterface *interface, uint8_t bank,
431  uint8_t addr);
432 
433 //C++ guard
434 #ifdef __cplusplus
435 }
436 #endif
437 
438 #endif
void lan8770InitHook(NetInterface *interface)
LAN8770 custom configuration.
Ethernet PHY driver.
Definition: nic.h:311
uint8_t data[]
Definition: ethernet.h:222
uint16_t lan8770ReadExtReg(NetInterface *interface, uint8_t bank, uint8_t addr)
Read extended register.
void lan8770WritePhyReg(NetInterface *interface, uint8_t address, uint16_t data)
Write PHY register.
error_t
Error codes.
Definition: error.h:43
void lan8770DumpPhyReg(NetInterface *interface)
Dump PHY registers for debugging purpose.
#define NetInterface
Definition: net.h:36
void lan8770WriteExtReg(NetInterface *interface, uint8_t bank, uint8_t addr, uint16_t data)
Write extended register.
const PhyDriver lan8770PhyDriver
LAN8770 Ethernet PHY driver.
void lan8770EnableIrq(NetInterface *interface)
Enable interrupts.
void lan8770Tick(NetInterface *interface)
LAN8770 timer handler.
uint16_t lan8770ReadPhyReg(NetInterface *interface, uint8_t address)
Read PHY register.
Ipv6Addr address[]
Definition: ipv6.h:325
Network interface controller abstraction layer.
void lan8770EventHandler(NetInterface *interface)
LAN8770 event handler.
Ipv4Addr addr
Definition: nbns_common.h:123
error_t lan8770Init(NetInterface *interface)
LAN8770 PHY transceiver initialization.
void lan8770DisableIrq(NetInterface *interface)
Disable interrupts.