vsc8662_driver.h
Go to the documentation of this file.
1 /**
2  * @file vsc8662_driver.h
3  * @brief VSC8662 Gigabit 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 _VSC8662_DRIVER_H
32 #define _VSC8662_DRIVER_H
33 
34 //Dependencies
35 #include "core/nic.h"
36 
37 //PHY address
38 #ifndef VSC8662_PHY_ADDR
39  #define VSC8662_PHY_ADDR 0
40 #elif (VSC8662_PHY_ADDR < 0 || VSC8662_PHY_ADDR > 31)
41  #error VSC8662_PHY_ADDR parameter is not valid
42 #endif
43 
44 //VSC8662 PHY registers
45 #define VSC8662_BMCR 0x00
46 #define VSC8662_BMSR 0x01
47 #define VSC8662_PHYID1 0x02
48 #define VSC8662_PHYID2 0x03
49 #define VSC8662_ANAR 0x04
50 #define VSC8662_ANLPAR 0x05
51 #define VSC8662_ANER 0x06
52 #define VSC8662_ANNPTR 0x07
53 #define VSC8662_ANLPNPR 0x08
54 #define VSC8662_1000BT_CTRL 0x09
55 #define VSC8662_1000BT_STAT 0x0A
56 #define VSC8662_1000BT_EXT_STAT1 0x0F
57 
58 //VSC8662 PHY registers (page 0)
59 #define VSC8662_100BTX_EXT_STAT 0x10
60 #define VSC8662_1000BT_EXT_STAT2 0x11
61 #define VSC8662_BYPASS_CTRL 0x12
62 #define VSC8662_ERR_CNT1 0x13
63 #define VSC8662_ERR_CNT2 0x14
64 #define VSC8662_ERR_CNT3 0x15
65 #define VSC8662_EXT_CTRL_STAT 0x16
66 #define VSC8662_EXT_PHY_CTRL1 0x17
67 #define VSC8662_EXT_PHY_CTRL2 0x18
68 #define VSC8662_INT_MASK 0x19
69 #define VSC8662_INT_STATUS 0x1A
70 #define VSC8662_MAC_AN_CTRL_STAT 0x1B
71 #define VSC8662_AUX_CTRL_STAT 0x1C
72 #define VSC8662_LED_MODE_SEL 0x1D
73 #define VSC8662_LED_BEHAVIOR 0x1E
74 #define VSC8662_EXT_PAGE_ACCESS 0x1F
75 
76 //VSC8662 PHY registers (page 1)
77 #define VSC8662_SERDES_MEDIA_CTRL 0x10
78 #define VSC8662_SERDES_MAC_MEDIA_CTRL 0x11
79 #define VSC8662_CRC_GOOD_CNT 0x12
80 #define VSC8662_SERDES_LOOPBACK_SIGDET_CTRL 0x13
81 #define VSC8662_EXT_PHY_CTRL3 0x14
82 #define VSC8662_EXT_PHY_CTRL4 0x17
83 #define VSC8662_SERDES_MAC_MEDIA_STAT 0x1C
84 #define VSC8662_EPG_CTRL1 0x1D
85 #define VSC8662_EPG_CTRL2 0x1E
86 
87 //VSC8662 PHY registers (page 16)
88 #define VSC8662_SIGDET_GPIO_CTRL 0x0D
89 #define VSC8662_GPIO_INPUT 0x0F
90 #define VSC8662_GPIO_OUTPUT 0x10
91 #define VSC8662_GPIO_OUTPUT_EN 0x11
92 #define VSC8662_FAST_LINK_FAIL_CTRL 0x13
93 #define VSC8662_I2C_MUX_CTRL1 0x14
94 #define VSC8662_I2C_MUX_CTRL2 0x15
95 #define VSC8662_I2C_MUX_DATA_RW 0x16
96 #define VSC8662_RECOVERED_CLOCK1 0x17
97 #define VSC8662_RECOVERED_CLOCK2 0x18
98 #define VSC8662_LED_PORT_SWAPPING 0x19
99 
100 //Mode control register
101 #define VSC8662_BMCR_RESET 0x8000
102 #define VSC8662_BMCR_LOOPBACK 0x4000
103 #define VSC8662_BMCR_SPEED_SEL_LSB 0x2000
104 #define VSC8662_BMCR_AN_EN 0x1000
105 #define VSC8662_BMCR_POWER_DOWN 0x0800
106 #define VSC8662_BMCR_ISOLATE 0x0400
107 #define VSC8662_BMCR_RESTART_AN 0x0200
108 #define VSC8662_BMCR_DUPLEX_MODE 0x0100
109 #define VSC8662_BMCR_COL_TEST 0x0080
110 #define VSC8662_BMCR_SPEED_SEL_MSB 0x0040
111 #define VSC8662_BMCR_UNIDIRECTIONAL_EN 0x0020
112 
113 //Mode status register
114 #define VSC8662_BMSR_100BT4 0x8000
115 #define VSC8662_BMSR_100BTX_FD 0x4000
116 #define VSC8662_BMSR_100BTX_HD 0x2000
117 #define VSC8662_BMSR_10BT_FD 0x1000
118 #define VSC8662_BMSR_10BT_HD 0x0800
119 #define VSC8662_BMSR_100BT2_FD 0x0400
120 #define VSC8662_BMSR_100BT2_HD 0x0200
121 #define VSC8662_BMSR_EXTENDED_STATUS 0x0100
122 #define VSC8662_BMSR_UNIDIRECTIONAL_ABLE 0x0080
123 #define VSC8662_BMSR_PREAMBLE_SUPPR 0x0040
124 #define VSC8662_BMSR_AN_COMPLETE 0x0020
125 #define VSC8662_BMSR_REMOTE_FAULT 0x0010
126 #define VSC8662_BMSR_AN_CAPABLE 0x0008
127 #define VSC8662_BMSR_LINK_STATUS 0x0004
128 #define VSC8662_BMSR_JABBER_DETECT 0x0002
129 #define VSC8662_BMSR_EXTENDED_CAPABLE 0x0001
130 
131 //PHY identifier 1 register
132 #define VSC8662_PHYID1_OUI_MSB 0xFFFF
133 #define VSC8662_PHYID1_OUI_MSB_DEFAULT 0x0007
134 
135 //PHY identifier 2 register
136 #define VSC8662_PHYID2_OUI_LSB 0xFC00
137 #define VSC8662_PHYID2_OUI_LSB_DEFAULT 0x0400
138 #define VSC8662_PHYID2_MODEL_NUM 0x03F0
139 #define VSC8662_PHYID2_MODEL_NUM_DEFAULT 0x0260
140 #define VSC8662_PHYID2_REVISION_NUM 0x000F
141 
142 //Auto-negotiation advertisement register
143 #define VSC8662_ANAR_NEXT_PAGE 0x8000
144 #define VSC8662_ANAR_REMOTE_FAULT 0x2000
145 #define VSC8662_ANAR_ASYM_PAUSE 0x0800
146 #define VSC8662_ANAR_SYM_PAUSE 0x0400
147 #define VSC8662_ANAR_100BT4 0x0200
148 #define VSC8662_ANAR_100BTX_FD 0x0100
149 #define VSC8662_ANAR_100BTX_HD 0x0080
150 #define VSC8662_ANAR_10BT_FD 0x0040
151 #define VSC8662_ANAR_10BT_HD 0x0020
152 #define VSC8662_ANAR_SELECTOR 0x001F
153 #define VSC8662_ANAR_SELECTOR_DEFAULT 0x0001
154 
155 //Auto-negotiation link partner ability register
156 #define VSC8662_ANLPAR_NEXT_PAGE 0x8000
157 #define VSC8662_ANLPAR_ACK 0x4000
158 #define VSC8662_ANLPAR_REMOTE_FAULT 0x2000
159 #define VSC8662_ANLPAR_ASYM_PAUSE 0x0800
160 #define VSC8662_ANLPAR_SYM_PAUSE 0x0400
161 #define VSC8662_ANLPAR_100BT4 0x0200
162 #define VSC8662_ANLPAR_100BTX_FD 0x0100
163 #define VSC8662_ANLPAR_100BTX_HD 0x0080
164 #define VSC8662_ANLPAR_10BT_FD 0x0040
165 #define VSC8662_ANLPAR_10BT_HD 0x0020
166 #define VSC8662_ANLPAR_SELECTOR 0x001F
167 #define VSC8662_ANLPAR_SELECTOR_DEFAULT 0x0001
168 
169 //Auto-negotiation expansion register
170 #define VSC8662_ANER_PAR_DETECT_FAULT 0x0010
171 #define VSC8662_ANER_LP_NEXT_PAGE_ABLE 0x0008
172 #define VSC8662_ANER_NEXT_PAGE_ABLE 0x0004
173 #define VSC8662_ANER_PAGE_RECEIVED 0x0002
174 #define VSC8662_ANER_LP_AN_ABLE 0x0001
175 
176 //Auto-negotiation next-page transmit register
177 #define VSC8662_ANNPTR_NEXT_PAGE 0x8000
178 #define VSC8662_ANNPTR_MSG_PAGE 0x2000
179 #define VSC8662_ANNPTR_ACK2 0x1000
180 #define VSC8662_ANNPTR_TOGGLE 0x0800
181 #define VSC8662_ANNPTR_MESSAGE 0x07FF
182 
183 //Auto-negotiation link partner next-page receive register
184 #define VSC8662_ANLPNPR_NEXT_PAGE 0x8000
185 #define VSC8662_ANLPNPR_ACK 0x4000
186 #define VSC8662_ANLPNPR_MSG_PAGE 0x2000
187 #define VSC8662_ANLPNPR_ACK2 0x1000
188 #define VSC8662_ANLPNPR_TOGGLE 0x0800
189 #define VSC8662_ANLPNPR_MESSAGE 0x07FF
190 
191 //1000BASE-T control register
192 #define VSC8662_1000BT_CTRL_TEST_MODE 0xE000
193 #define VSC8662_1000BT_CTRL_MS_MAN_CONF_EN 0x1000
194 #define VSC8662_1000BT_CTRL_MS_MAN_CONF_VAL 0x0800
195 #define VSC8662_1000BT_CTRL_PORT_TYPE 0x0400
196 #define VSC8662_1000BT_CTRL_1000BT_FD 0x0200
197 #define VSC8662_1000BT_CTRL_1000BT_HD 0x0100
198 
199 //1000BASE-T status register
200 #define VSC8662_1000BT_STAT_MS_CONF_FAULT 0x8000
201 #define VSC8662_1000BT_STAT_MS_CONF_RES 0x4000
202 #define VSC8662_1000BT_STAT_LOCAL_RECEIVER_STATUS 0x2000
203 #define VSC8662_1000BT_STAT_REMOTE_RECEIVER_STATUS 0x1000
204 #define VSC8662_1000BT_STAT_LP_1000BT_FD 0x0800
205 #define VSC8662_1000BT_STAT_LP_1000BT_HD 0x0400
206 #define VSC8662_1000BT_STAT_IDLE_ERR_COUNT 0x00FF
207 
208 //1000BASE-T status extension 1 register
209 #define VSC8662_1000BT_EXT_STAT1_1000BX_FD 0x8000
210 #define VSC8662_1000BT_EXT_STAT1_1000BX_HD 0x4000
211 #define VSC8662_1000BT_EXT_STAT1_1000BT_FD 0x2000
212 #define VSC8662_1000BT_EXT_STAT1_1000BT_HD 0x1000
213 
214 //100BASE-TX status extension register
215 #define VSC8662_100BTX_EXT_STAT_DESCRAMBLER 0x8000
216 #define VSC8662_100BTX_EXT_STAT_LOCK_ERROR 0x4000
217 #define VSC8662_100BTX_EXT_STAT_DISCONNECT_STATE 0x2000
218 #define VSC8662_100BTX_EXT_STAT_LINK_STATUS 0x1000
219 #define VSC8662_100BTX_EXT_STAT_RECEIVE_ERROR 0x0800
220 #define VSC8662_100BTX_EXT_STAT_TRANSMIT_ERROR 0x0400
221 #define VSC8662_100BTX_EXT_STAT_SSD_ERROR 0x0200
222 #define VSC8662_100BTX_EXT_STAT_ESD_ERROR 0x0100
223 
224 //1000BASE-T status extension 2 register
225 #define VSC8662_1000BT_EXT_STAT2_DESCRAMBLER 0x8000
226 #define VSC8662_1000BT_EXT_STAT2_LOCK_ERROR 0x4000
227 #define VSC8662_1000BT_EXT_STAT2_DISCONNECT_STATE 0x2000
228 #define VSC8662_1000BT_EXT_STAT2_LINK_STATUS 0x1000
229 #define VSC8662_1000BT_EXT_STAT2_RECEIVE_ERROR 0x0800
230 #define VSC8662_1000BT_EXT_STAT2_TRANSMIT_ERROR 0x0400
231 #define VSC8662_1000BT_EXT_STAT2_SSD_ERROR 0x0200
232 #define VSC8662_1000BT_EXT_STAT2_ESD_ERROR 0x0100
233 #define VSC8662_1000BT_EXT_STAT2_CARRIER_EXT_ERROR 0x0080
234 #define VSC8662_1000BT_EXT_STAT2_NON_COMP_BCM5400_DETECT 0x0040
235 #define VSC8662_1000BT_EXT_STAT2_MDI_CROSSOVER_ERROR 0x0020
236 
237 //Bypass control register
238 #define VSC8662_BYPASS_CTRL_TRANSMIT_DIS 0x8000
239 #define VSC8662_BYPASS_CTRL_4B5B_ENC_DEC 0x4000
240 #define VSC8662_BYPASS_CTRL_SCRAMBLER 0x2000
241 #define VSC8662_BYPASS_CTRL_DESCRAMBLER 0x1000
242 #define VSC8662_BYPASS_CTRL_PCS_RECEIVE 0x0800
243 #define VSC8662_BYPASS_CTRL_PCS_TRANSMIT 0x0400
244 #define VSC8662_BYPASS_CTRL_LFI_TIMER 0x0200
245 #define VSC8662_BYPASS_CTRL_AUTO_MDX_10_100 0x0080
246 #define VSC8662_BYPASS_CTRL_NON_COMP_BCM5400_DETECT_DIS 0x0040
247 #define VSC8662_BYPASS_CTRL_PAIR_SWAP_CORR_DIS 0x0020
248 #define VSC8662_BYPASS_CTRL_POL_CORR_DIS 0x0010
249 #define VSC8662_BYPASS_CTRL_PAR_DETECT_CONTROL 0x0008
250 #define VSC8662_BYPASS_CTRL_PULSE_SHAPING_FILTER 0x0004
251 #define VSC8662_BYPASS_CTRL_AUTO_1000BT_NP_DIS 0x0002
252 #define VSC8662_BYPASS_CTRL_CLKOUT_OUTPUT_EN 0x0001
253 
254 //Error Counter 1 register
255 #define VSC8662_ERR_CNT1_VALUE 0x00FF
256 
257 //Error Counter 2 register
258 #define VSC8662_ERR_CNT2_VALUE 0x00FF
259 
260 //Error Counter 3 register
261 #define VSC8662_ERR_CNT3_VALUE 0x00FF
262 
263 //Extended control and status register
264 #define VSC8662_EXT_CTRL_STAT_FORCE_10BT_LINK 0x8000
265 #define VSC8662_EXT_CTRL_STAT_JABBER_DETECT_DIS 0x4000
266 #define VSC8662_EXT_CTRL_STAT_10BT_ECHO_DIS 0x2000
267 #define VSC8662_EXT_CTRL_STAT_SQE_MODE_DIS 0x1000
268 #define VSC8662_EXT_CTRL_STAT_10BT_SQUELCH_CONTROL 0x0C00
269 #define VSC8662_EXT_CTRL_STAT_STICKY_RESET_EN 0x0200
270 #define VSC8662_EXT_CTRL_STAT_EOF_ERROR 0x0100
271 #define VSC8662_EXT_CTRL_STAT_10BT_DISCONNECT_STATE 0x0080
272 #define VSC8662_EXT_CTRL_STAT_10BT_LINK_STATUS 0x0040
273 #define VSC8662_EXT_CTRL_STAT_CRS_CONTROL 0x0006
274 #define VSC8662_EXT_CTRL_STAT_SMI_BROADCAST_WRITE 0x0001
275 
276 //Extended PHY control 1 register
277 #define VSC8662_EXT_PHY_CTRL1_MAC_AN 0x2000
278 #define VSC8662_EXT_PHY_CTRL1_MAC_MODE 0x1000
279 #define VSC8662_EXT_PHY_CTRL1_AMS_PREFERENCE 0x0800
280 #define VSC8662_EXT_PHY_CTRL1_MEDIA_OP_MODE 0x0700
281 #define VSC8662_EXT_PHY_CTRL1_FORCE_AMS_OVERRIDE 0x00C0
282 #define VSC8662_EXT_PHY_CTRL1_FAR_END_LOOPBACK 0x0008
283 #define VSC8662_EXT_PHY_CTRL1_SGMII_ALIGN_ERROR_STATUS 0x0002
284 
285 //Extended PHY control 2 register
286 #define VSC8662_EXT_PHY_CTRL2_100BTX_EDGE_RATE_CONTROL 0xE000
287 #define VSC8662_EXT_PHY_CTRL2_PICMG_2_16_REDUCED_PWR_MODE 0x1000
288 #define VSC8662_EXT_PHY_CTRL2_SGMII_INPUT_PREAMBLE 0x0180
289 #define VSC8662_EXT_PHY_CTRL2_SGMII_OUTPUT_PREAMBLE 0x0040
290 #define VSC8662_EXT_PHY_CTRL2_JUMBO_PACKET_MODE 0x0030
291 #define VSC8662_EXT_PHY_CTRL2_100BTX_TX_AMPLITUDE_CONTROL 0x000E
292 #define VSC8662_EXT_PHY_CTRL2_1000BT_CONNECTOR_LOOPBACK 0x0001
293 
294 //Interrupt mask register
295 #define VSC8662_INT_MASK_MDINT 0x8000
296 #define VSC8662_INT_MASK_SPEED_CHANGE 0x4000
297 #define VSC8662_INT_MASK_LINK_CHANGE 0x2000
298 #define VSC8662_INT_MASK_FDX_CHANGE 0x1000
299 #define VSC8662_INT_MASK_AN_ERROR 0x0800
300 #define VSC8662_INT_MASK_AN_COMPLETE 0x0400
301 #define VSC8662_INT_MASK_POE_DETECT 0x0200
302 #define VSC8662_INT_MASK_SYMBOL_ERROR 0x0100
303 #define VSC8662_INT_MASK_FAST_LINK_FAILURE 0x0080
304 #define VSC8662_INT_MASK_TX_FIFO_OVER_UNDERFLOW 0x0040
305 #define VSC8662_INT_MASK_RX_FIFO_OVER_UNDERFLOW 0x0020
306 #define VSC8662_INT_MASK_AMS_MEDIA_CHANGE 0x0010
307 #define VSC8662_INT_MASK_FALSE_CARRIER 0x0008
308 #define VSC8662_INT_MASK_LINK_SPEED_DOWNSHIFT 0x0004
309 #define VSC8662_INT_MASK_MS_RESOLUTION_ERROR 0x0002
310 #define VSC8662_INT_MASK_RX_ER 0x0001
311 
312 //Interrupt status register
313 #define VSC8662_INT_STATUS_MDINT 0x8000
314 #define VSC8662_INT_STATUS_SPEED_CHANGE 0x4000
315 #define VSC8662_INT_STATUS_LINK_CHANGE 0x2000
316 #define VSC8662_INT_STATUS_FDX_CHANGE 0x1000
317 #define VSC8662_INT_STATUS_AN_ERROR 0x0800
318 #define VSC8662_INT_STATUS_AN_COMPLETE 0x0400
319 #define VSC8662_INT_STATUS_POE_DETECT 0x0200
320 #define VSC8662_INT_STATUS_SYMBOL_ERROR 0x0100
321 #define VSC8662_INT_STATUS_FAST_LINK_FAILURE 0x0080
322 #define VSC8662_INT_STATUS_TX_FIFO_OVER_UNDERFLOW 0x0040
323 #define VSC8662_INT_STATUS_RX_FIFO_OVER_UNDERFLOW 0x0020
324 #define VSC8662_INT_STATUS_AMS_MEDIA_CHANGE 0x0010
325 #define VSC8662_INT_STATUS_FALSE_CARRIER 0x0008
326 #define VSC8662_INT_STATUS_LINK_SPEED_DOWNSHIFT 0x0004
327 #define VSC8662_INT_STATUS_MS_RESOLUTION_ERROR 0x0002
328 #define VSC8662_INT_STATUS_RX_ER 0x0001
329 
330 //MAC interface auto-negotiation control and status register
331 #define VSC8662_MAC_AN_CTRL_STAT_MAC_MEDIA_INTERLOCK 0x8000
332 #define VSC8662_MAC_AN_CTRL_STAT_RESTART_AN_INTERLOCK 0x4000
333 #define VSC8662_MAC_AN_CTRL_STAT_AN_AUTO_SENSE 0x2000
334 #define VSC8662_MAC_AN_CTRL_STAT_AN_RESTART 0x1000
335 #define VSC8662_MAC_AN_CTRL_STAT_LP_RESTART_REQ 0x0800
336 #define VSC8662_MAC_AN_CTRL_STAT_REMOTE_FAULT 0x0300
337 #define VSC8662_MAC_AN_CTRL_STAT_ASYM_PAUSE_ADV 0x0080
338 #define VSC8662_MAC_AN_CTRL_STAT_SYM_PAUSE_ADV 0x0040
339 #define VSC8662_MAC_AN_CTRL_STAT_FD_ADV 0x0020
340 #define VSC8662_MAC_AN_CTRL_STAT_HD_ADV 0x0010
341 #define VSC8662_MAC_AN_CTRL_STAT_AN_ABLE 0x0008
342 #define VSC8662_MAC_AN_CTRL_STAT_LINK_STATUS 0x0004
343 #define VSC8662_MAC_AN_CTRL_STAT_AN_COMPLETE 0x0002
344 #define VSC8662_MAC_AN_CTRL_STAT_SIGNAL_DETECT 0x0001
345 
346 //Auxiliary control and status register
347 #define VSC8662_AUX_CTRL_STAT_AN_COMPLETE 0x8000
348 #define VSC8662_AUX_CTRL_STAT_AN_DIS 0x4000
349 #define VSC8662_AUX_CTRL_STAT_MDI_MDIX_IND 0x2000
350 #define VSC8662_AUX_CTRL_STAT_CD_PAIR_SWAP 0x1000
351 #define VSC8662_AUX_CTRL_STAT_A_POLARITY_INVERSION 0x0800
352 #define VSC8662_AUX_CTRL_STAT_B_POLARITY_INVERSION 0x0400
353 #define VSC8662_AUX_CTRL_STAT_C_POLARITY_INVERSION 0x0200
354 #define VSC8662_AUX_CTRL_STAT_D_POLARITY_INVERSION 0x0100
355 #define VSC8662_AUX_CTRL_STAT_ACTIPHY_LINK_STAT_TMO_MSB 0x0080
356 #define VSC8662_AUX_CTRL_STAT_ACTIPHY_MODE_EN 0x0040
357 #define VSC8662_AUX_CTRL_STAT_FDX_STATUS 0x0020
358 #define VSC8662_AUX_CTRL_STAT_SPEED_STATUS 0x0018
359 #define VSC8662_AUX_CTRL_STAT_SPEED_STATUS_10 0x0000
360 #define VSC8662_AUX_CTRL_STAT_SPEED_STATUS_100 0x0008
361 #define VSC8662_AUX_CTRL_STAT_SPEED_STATUS_1000 0x0010
362 #define VSC8662_AUX_CTRL_STAT_ACTIPHY_LINK_STAT_TMO_LSB 0x0004
363 #define VSC8662_AUX_CTRL_STAT_MEDIA_MODE_STATUS 0x0003
364 
365 //LED mode select register
366 #define VSC8662_LED_MODE_SEL_LED3 0xF000
367 #define VSC8662_LED_MODE_SEL_LED2 0x0F00
368 #define VSC8662_LED_MODE_SEL_LED1 0x00F0
369 #define VSC8662_LED_MODE_SEL_LED0 0x000F
370 
371 //LED behavior register
372 #define VSC8662_LED_BEHAVIOR_COPPER_FIBER_LED_COMBINE_DIS 0x8000
373 #define VSC8662_LED_BEHAVIOR_ACTIVITY_OUTPUT_SEL 0x4000
374 #define VSC8662_LED_BEHAVIOR_LED_PULSING_EN 0x1000
375 #define VSC8662_LED_BEHAVIOR_LED_BLINK_PULSE_STRETCH_RATE 0x0C00
376 #define VSC8662_LED_BEHAVIOR_LED3_PULSE_STRETCH_BLINK_SEL 0x0100
377 #define VSC8662_LED_BEHAVIOR_LED2_PULSE_STRETCH_BLINK_SEL 0x0080
378 #define VSC8662_LED_BEHAVIOR_LED1_PULSE_STRETCH_BLINK_SEL 0x0040
379 #define VSC8662_LED_BEHAVIOR_LED0_PULSE_STRETCH_BLINK_SEL 0x0020
380 #define VSC8662_LED_BEHAVIOR_LED3_COMBINE_FEATURE_DIS 0x0008
381 #define VSC8662_LED_BEHAVIOR_LED2_COMBINE_FEATURE_DIS 0x0004
382 #define VSC8662_LED_BEHAVIOR_LED1_COMBINE_FEATURE_DIS 0x0002
383 #define VSC8662_LED_BEHAVIOR_LED0_COMBINE_FEATURE_DIS 0x0001
384 
385 //Extended register page access register
386 #define VSC8662_EXT_PAGE_ACCESS_MAIN 0x0000
387 #define VSC8662_EXT_PAGE_ACCESS_EXTENDED 0x0001
388 #define VSC8662_EXT_PAGE_ACCESS_GPIO 0x0010
389 
390 //SerDes Media control register
391 #define VSC8662_SERDES_MEDIA_CTRL_TRANSMIT_REMOTE_FAULT 0xC000
392 #define VSC8662_SERDES_MEDIA_CTRL_LP_REMOTE_FAULT 0x3000
393 #define VSC8662_SERDES_MEDIA_CTRL_PARALLEL_DETECT 0x0800
394 #define VSC8662_SERDES_MEDIA_CTRL_SERDES_MEDIA_SIGNAL_DETECT 0x0400
395 #define VSC8662_SERDES_MEDIA_CTRL_ALLOW_1000BX_LINK_UP 0x0200
396 #define VSC8662_SERDES_MEDIA_CTRL_ALLOW_100BX_LINK_UP 0x0100
397 #define VSC8662_SERDES_MEDIA_CTRL_SERDES_MEDIA_LP_RESTART_REQ 0x0080
398 #define VSC8662_SERDES_MEDIA_CTRL_FAR_END_FAULT_DETECT_100BFX 0x0040
399 
400 //SerDes MAC/Media control register
401 #define VSC8662_SERDES_MAC_MEDIA_CTRL_SERDES_MEDIA_RX_EQUAL 0x0200
402 #define VSC8662_SERDES_MAC_MEDIA_CTRL_SERDES_MEDIA_OUT_SWING 0x00E0
403 #define VSC8662_SERDES_MAC_MEDIA_CTRL_SERDES_MAC_OUT_SWING 0x001C
404 #define VSC8662_SERDES_MAC_MEDIA_CTRL_SERDES_MAC_HYSTERESIS 0x0002
405 #define VSC8662_SERDES_MAC_MEDIA_CTRL_SERDES_MEDIA_HYSTERESIS 0x0001
406 
407 //CRC good counter register
408 #define VSC8662_CRC_GOOD_CNT_PKT_SINCE_LAST_READ 0x8000
409 #define VSC8662_CRC_GOOD_CNT_CONTENTS 0x3FFF
410 
411 //SerDes loopback and SIGDET control register
412 #define VSC8662_SERDES_LOOPBACK_SIGDET_CTRL_LED3_EXT_MODE 0x8000
413 #define VSC8662_SERDES_LOOPBACK_SIGDET_CTRL_LED2_EXT_MODE 0x4000
414 #define VSC8662_SERDES_LOOPBACK_SIGDET_CTRL_LED1_EXT_MODE 0x2000
415 #define VSC8662_SERDES_LOOPBACK_SIGDET_CTRL_LED0_EXT_MODE 0x1000
416 #define VSC8662_SERDES_LOOPBACK_SIGDET_CTRL_LED_RESET_BLINK_SUPPR 0x0800
417 #define VSC8662_SERDES_LOOPBACK_SIGDET_CTRL_SERDES_MEDIA_LOOPBACK_EN 0x0400
418 #define VSC8662_SERDES_LOOPBACK_SIGDET_CTRL_SERDES_MEDIA_LOOPBACK_MODE 0x0300
419 #define VSC8662_SERDES_LOOPBACK_SIGDET_CTRL_SERDES_MAC_LOOPBACK_EN 0x0080
420 #define VSC8662_SERDES_LOOPBACK_SIGDET_CTRL_SERDES_MAC_LOOPBACK_MODE 0x0060
421 #define VSC8662_SERDES_LOOPBACK_SIGDET_CTRL_FAST_LINK_FAILURE_IND 0x0010
422 #define VSC8662_SERDES_LOOPBACK_SIGDET_CTRL_FORCE_MDI_CROSSOVER 0x000C
423 #define VSC8662_SERDES_LOOPBACK_SIGDET_CTRL_SIGDET_POLARITY 0x0001
424 
425 //Extended PHY control 3 (ActiPHY) register
426 #define VSC8662_EXT_PHY_CTRL3_CARRIER_EXT_DIS 0x8000
427 #define VSC8662_EXT_PHY_CTRL3_ACTIPHY_SLEEP_TIMER 0x6000
428 #define VSC8662_EXT_PHY_CTRL3_ACTIPHY_WAKE_UP_TIMER 0x1800
429 #define VSC8662_EXT_PHY_CTRL3_PHY_ADDR_REVERSAL 0x0200
430 #define VSC8662_EXT_PHY_CTRL3_CLKOUT_FREQ 0x0100
431 #define VSC8662_EXT_PHY_CTRL3_MEDIA_MODE_STATUS 0x00C0
432 #define VSC8662_EXT_PHY_CTRL3_10BT_NO_PREAMBLE_MODE_EN 0x0020
433 #define VSC8662_EXT_PHY_CTRL3_LINK_SPEED_AUTODOWNSHIFT_EN 0x0010
434 #define VSC8662_EXT_PHY_CTRL3_LINK_SPEED_AUTODOWNSHIFT_CTRL 0x000C
435 #define VSC8662_EXT_PHY_CTRL3_LINK_SPEED_AUTODOWNSHIFT_STAT 0x0002
436 
437 //Extended PHY control 4 (PoE and CRC error counter) register
438 #define VSC8662_EXT_PHY_CTRL4_PHY_ADDR 0xF800
439 #define VSC8662_EXT_PHY_CTRL4_INLINE_PWR_DEVICE_DETECT 0x0400
440 #define VSC8662_EXT_PHY_CTRL4_INLINE_PWR_DEVICE_DETECT_STAT 0x0300
441 #define VSC8662_EXT_PHY_CTRL4_CRC_ERROR_CNT 0x00FF
442 
443 //SerDes MAC/media status register
444 #define VSC8662_SERDES_MAC_MEDIA_STAT_MAC_SYNC_STATUS_FAIL 0x0800
445 #define VSC8662_SERDES_MAC_MEDIA_STAT_MAC_CGBAD 0x0400
446 #define VSC8662_SERDES_MAC_MEDIA_STAT_MAC_PHASE_LOCK_LOSS 0x0200
447 #define VSC8662_SERDES_MAC_MEDIA_STAT_MAC_RX_PLL_LOCK_LOSS 0x0100
448 #define VSC8662_SERDES_MAC_MEDIA_STAT_SERDES_MEDIA_SYNC_STATUS_FAIL 0x0008
449 #define VSC8662_SERDES_MAC_MEDIA_STAT_SERDES_MEDIA_CGBAD 0x0004
450 #define VSC8662_SERDES_MAC_MEDIA_STAT_SERDES_MEDIA_PHASE_LOCK_LOSS 0x0002
451 #define VSC8662_SERDES_MAC_MEDIA_STAT_SERDES_MEDIA_RX_PLL_LOCK_LOSS 0x0001
452 
453 //Ethernet packet generator control 1 register
454 #define VSC8662_EPG_CTRL1_EPG_EN 0x8000
455 #define VSC8662_EPG_CTRL1_EPG_RUN_STOP 0x4000
456 #define VSC8662_EPG_CTRL1_TRANSMISSION_DURATION 0x2000
457 #define VSC8662_EPG_CTRL1_PACKET_LENGTH 0x1800
458 #define VSC8662_EPG_CTRL1_INTER_PACKET_GAP 0x0400
459 #define VSC8662_EPG_CTRL1_DEST_ADDR 0x03C0
460 #define VSC8662_EPG_CTRL1_SOURCE_ADDR 0x003C
461 #define VSC8662_EPG_CTRL1_PAYLOAD_TYPE 0x0002
462 #define VSC8662_EPG_CTRL1_BAD_FCS_GENERATION 0x0001
463 
464 //Ethernet packet generator control 2 register
465 #define VSC8662_EPG_CTRL2_EPG_PACKET_PAYLOAD 0xFFFF
466 
467 //SIGDET vs. GPIO control register
468 #define VSC8662_SIGDET_GPIO_CTRL_SIGDET1 0x000C
469 #define VSC8662_SIGDET_GPIO_CTRL_SIGDET0 0x0003
470 
471 //Fast link fail control register
472 #define VSC8662_FAST_LINK_FAIL_CTRL_PORT 0x0001
473 
474 //I2C mux control 1 register
475 #define VSC8662_I2C_MUX_CTRL1_DEV_ADDR 0xFE00
476 #define VSC8662_I2C_MUX_CTRL1_SCL_CLOCK_FREQ 0x0030
477 #define VSC8662_I2C_MUX_CTRL1_MUX_PORT_1_EN 0x0002
478 #define VSC8662_I2C_MUX_CTRL1_MUX_PORT_0_EN 0x0001
479 
480 //I2C mux control 2 register
481 #define VSC8662_I2C_MUX_CTRL2_MUX_READY 0x8000
482 #define VSC8662_I2C_MUX_CTRL2_PHY_PORT_ADDR 0x0400
483 #define VSC8662_I2C_MUX_CTRL2_MUX_ACCESS_EN 0x0200
484 #define VSC8662_I2C_MUX_CTRL2_MUX_READ_WRITE 0x0100
485 #define VSC8662_I2C_MUX_CTRL2_MUX_ADDR 0x00FF
486 
487 //I2C mux data read/write register
488 #define VSC8662_I2C_MUX_DATA_RW_MUX_READ_DATA 0xFF00
489 #define VSC8662_I2C_MUX_DATA_RW_MUX_WRITE_DATA 0x00FF
490 
491 //Recovered clock 1 register
492 #define VSC8662_RECOVERED_CLOCK1_RCVRD_CLK1_EN 0x8000
493 #define VSC8662_RECOVERED_CLOCK1_PHY_CLOCKOUT_SEL 0x1000
494 #define VSC8662_RECOVERED_CLOCK1_CLOCK_FREQ 0x0100
495 #define VSC8662_RECOVERED_CLOCK1_CLOCK_SQUELCH 0x0030
496 #define VSC8662_RECOVERED_CLOCK1_CLOCK_SEL 0x0003
497 
498 //Recovered clock 2 register
499 #define VSC8662_RECOVERED_CLOCK2_RCVRD_CLK2_EN 0x8000
500 #define VSC8662_RECOVERED_CLOCK2_PHY_CLOCKOUT_SEL 0x1000
501 #define VSC8662_RECOVERED_CLOCK2_CLOCK_FREQ 0x0100
502 #define VSC8662_RECOVERED_CLOCK2_CLOCK_SQUELCH 0x0030
503 #define VSC8662_RECOVERED_CLOCK2_CLOCK_SEL 0x0003
504 
505 //LED port swapping register
506 #define VSC8662_LED_PORT_SWAPPING_LED_PORT_SWAPPING 0x0001
507 
508 //C++ guard
509 #ifdef __cplusplus
510 extern "C" {
511 #endif
512 
513 //VSC8662 Ethernet PHY driver
514 extern const PhyDriver vsc8662PhyDriver;
515 
516 //VSC8662 related functions
517 error_t vsc8662Init(NetInterface *interface);
518 void vsc8662InitHook(NetInterface *interface);
519 
520 void vsc8662Tick(NetInterface *interface);
521 
522 void vsc8662EnableIrq(NetInterface *interface);
523 void vsc8662DisableIrq(NetInterface *interface);
524 
525 void vsc8662EventHandler(NetInterface *interface);
526 
527 void vsc8662WritePhyReg(NetInterface *interface, uint8_t address,
528  uint16_t data);
529 
530 uint16_t vsc8662ReadPhyReg(NetInterface *interface, uint8_t address);
531 
532 void vsc8662DumpPhyReg(NetInterface *interface);
533 
534 //C++ guard
535 #ifdef __cplusplus
536 }
537 #endif
538 
539 #endif
uint16_t vsc8662ReadPhyReg(NetInterface *interface, uint8_t address)
Read PHY register.
Ethernet PHY driver.
Definition: nic.h:311
uint8_t data[]
Definition: ethernet.h:222
void vsc8662DumpPhyReg(NetInterface *interface)
Dump PHY registers for debugging purpose.
void vsc8662EventHandler(NetInterface *interface)
VSC8662 event handler.
void vsc8662Tick(NetInterface *interface)
VSC8662 timer handler.
error_t
Error codes.
Definition: error.h:43
void vsc8662InitHook(NetInterface *interface)
VSC8662 custom configuration.
#define NetInterface
Definition: net.h:36
error_t vsc8662Init(NetInterface *interface)
VSC8662 PHY transceiver initialization.
const PhyDriver vsc8662PhyDriver
VSC8662 Ethernet PHY driver.
void vsc8662DisableIrq(NetInterface *interface)
Disable interrupts.
Ipv6Addr address[]
Definition: ipv6.h:325
Network interface controller abstraction layer.
void vsc8662EnableIrq(NetInterface *interface)
Enable interrupts.
void vsc8662WritePhyReg(NetInterface *interface, uint8_t address, uint16_t data)
Write PHY register.