mv88e6060_driver.h
Go to the documentation of this file.
1 /**
2  * @file mv88e6060_driver.h
3  * @brief 88E6060 6-port Ethernet switch 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 _MV88E6060_DRIVER_H
32 #define _MV88E6060_DRIVER_H
33 
34 //Dependencies
35 #include "core/nic.h"
36 
37 //PHY address
38 #ifndef MV88E6060_PHY_ADDR
39  #define MV88E6060_PHY_ADDR 16
40 #elif (MV88E6060_PHY_ADDR < 0 || MV88E6060_PHY_ADDR > 31)
41  #error MV88E6060_PHY_ADDR parameter is not valid
42 #endif
43 
44 //Port identifiers
45 #define MV88E6060_PORT0 1
46 #define MV88E6060_PORT1 2
47 #define MV88E6060_PORT2 3
48 #define MV88E6060_PORT3 4
49 #define MV88E6060_PORT4 5
50 #define MV88E6060_PORT5 6
51 
52 //Port masks
53 #define MV88E6060_PORT_MASK 0x3F
54 #define MV88E6060_PORT0_MASK 0x01
55 #define MV88E6060_PORT1_MASK 0x02
56 #define MV88E6060_PORT2_MASK 0x04
57 #define MV88E6060_PORT3_MASK 0x08
58 #define MV88E6060_PORT4_MASK 0x10
59 #define MV88E6060_PORT5_MASK 0x20
60 
61 //Size of of the MAC address lookup table
62 #define MV88E6060_ATU_TABLE_SIZE 1024
63 
64 //Ingress trailer (CPU to 88E6060)
65 #define MV88E6060_IG_OVERRIDE 0x80000000
66 #define MV88E6060_IG_LEARN_DISABLE 0x20000000
67 #define MV88E6060_IG_IGNORE_FCS 0x10000000
68 #define MV88E6060_IG_DPV 0x003F0000
69 #define MV88E6060_IG_DPV_PORT5 0x00200000
70 #define MV88E6060_IG_DPV_PORT4 0x00100000
71 #define MV88E6060_IG_DPV_PORT3 0x00080000
72 #define MV88E6060_IG_DPV_PORT2 0x00040000
73 #define MV88E6060_IG_DPV_PORT1 0x00020000
74 #define MV88E6060_IG_DPV_PORT0 0x00010000
75 #define MV88E6060_IG_MGMT 0x00001000
76 
77 //Egress trailer (88E6060 to CPU)
78 #define MV88E6060_EG_VALID 0x80000000
79 #define MV88E6060_EG_SPID 0x00070000
80 #define MV88E6060_EG_MGMT 0x00001000
81 
82 //88E6060 PHY registers
83 #define MV88E6060_BMCR 0x00
84 #define MV88E6060_BMSR 0x01
85 #define MV88E6060_PHYID1 0x02
86 #define MV88E6060_PHYID2 0x03
87 #define MV88E6060_ANAR 0x04
88 #define MV88E6060_ANLPAR 0x05
89 #define MV88E6060_ANER 0x06
90 #define MV88E6060_ANNPR 0x07
91 #define MV88E6060_ANLPNPR 0x08
92 #define MV88E6060_PHY_SPEC_CTRL 0x10
93 #define MV88E6060_PHY_SPEC_STAT 0x11
94 #define MV88E6060_PHY_INT_EN 0x12
95 #define MV88E6060_PHY_INT_STAT 0x13
96 #define MV88E6060_PHY_INT_PORT_SUMMARY 0x14
97 #define MV88E6060_RX_ERR_COUNTER 0x15
98 #define MV88E6060_LED_PAR_SEL 0x16
99 #define MV88E6060_LED_STREAM_SEL 0x17
100 #define MV88E6060_PHY_LED_CTRL 0x18
101 #define MV88E6060_PHY_MAN_LED_OVERRIDE 0x19
102 #define MV88E6060_VCT_TXPN 0x1A
103 #define MV88E6060_VCT_RXPN 0x1B
104 #define MV88E6060_PHY_SPEC_CTRL2 0x1C
105 
106 //88E6060 Switch Port registers
107 #define MV88E6060_PORT_STAT 0x00
108 #define MV88E6060_SWITCH_ID 0x03
109 #define MV88E6060_PORT_CTRL 0x04
110 #define MV88E6060_PORT_VLAN_MAP 0x06
111 #define MV88E6060_PORT_ASSOC_VECTOR 0x0B
112 #define MV88E6060_RX_COUNTER 0x10
113 #define MV88E6060_TX_COUNTER 0x11
114 
115 //88E6060 Switch Global registers
116 #define MV88E6060_SWITCH_GLOBAL_STAT 0x00
117 #define MV88E6060_SWITCH_MAC_ADDR_0_1 0x01
118 #define MV88E6060_SWITCH_MAC_ADDR_2_3 0x02
119 #define MV88E6060_SWITCH_MAC_ADDR_4_5 0x03
120 #define MV88E6060_SWITCH_GLOBAL_CTRL 0x04
121 #define MV88E6060_ATU_CTRL 0x0A
122 #define MV88E6060_ATU_OPERATION 0x0B
123 #define MV88E6060_ATU_DATA 0x0C
124 #define MV88E6060_ATU_MAC_ADDR_0_1 0x0D
125 #define MV88E6060_ATU_MAC_ADDR_2_3 0x0E
126 #define MV88E6060_ATU_MAC_ADDR_4_5 0x0F
127 
128 //PHY Control register
129 #define MV88E6060_BMCR_SW_RESET 0x8000
130 #define MV88E6060_BMCR_LOOPBACK 0x4000
131 #define MV88E6060_BMCR_SPEED_LSB 0x2000
132 #define MV88E6060_BMCR_ANEG_EN 0x1000
133 #define MV88E6060_BMCR_PWR_DWN 0x0800
134 #define MV88E6060_BMCR_ISOLATE 0x0400
135 #define MV88E6060_BMCR_RESTART_ANEG 0x0200
136 #define MV88E6060_BMCR_DUPLEX 0x0100
137 #define MV88E6060_BMCR_COL_TEST 0x0080
138 #define MV88E6060_BMCR_SPEED_MSB 0x0040
139 
140 //PHY Status register
141 #define MV88E6060_BMSR_100T4 0x8000
142 #define MV88E6060_BMSR_100FDX 0x4000
143 #define MV88E6060_BMSR_100HDX 0x2000
144 #define MV88E6060_BMSR_10FDX 0x1000
145 #define MV88E6060_BMSR_10HPX 0x0800
146 #define MV88E6060_BMSR_100T2FDX 0x0400
147 #define MV88E6060_BMSR_100T2HDX 0x0200
148 #define MV88E6060_BMSR_EXTD_STATUS 0x0100
149 #define MV88E6060_BMSR_MF_PRE_SUP 0x0040
150 #define MV88E6060_BMSR_ANEG_DONE 0x0020
151 #define MV88E6060_BMSR_REMOTE_FAULT 0x0010
152 #define MV88E6060_BMSR_ANEG_ABLE 0x0008
153 #define MV88E6060_BMSR_LINK 0x0004
154 #define MV88E6060_BMSR_JABBER_DET 0x0002
155 #define MV88E6060_BMSR_EXTD_REG 0x0001
156 
157 //PHY Identifier 1 register
158 #define MV88E6060_PHYID1_OUI_MSB 0xFFFF
159 #define MV88E6060_PHYID1_OUI_MSB_DEFAULT 0x0141
160 
161 //PHY Identifier 2 register
162 #define MV88E6060_PHYID2_OUI_LSB 0xFC00
163 #define MV88E6060_PHYID2_OUI_LSB_DEFAULT 0x0C00
164 #define MV88E6060_PHYID2_MODEL_NUM 0x03F0
165 #define MV88E6060_PHYID2_MODEL_NUM_DEFAULT 0x0080
166 #define MV88E6060_PHYID2_REV_NUM 0x000F
167 
168 //Auto-Negotiation Advertisement register
169 #define MV88E6060_ANAR_ANEG_AD_NXT_PAGE 0x8000
170 #define MV88E6060_ANAR_ACK 0x4000
171 #define MV88E6060_ANAR_ANEG_AD_RE_FAULT 0x2000
172 #define MV88E6060_ANAR_ANEG_AD_PAUSE 0x0400
173 #define MV88E6060_ANAR_ANEG_AD_100T4 0x0200
174 #define MV88E6060_ANAR_ANEG_AD_100FDX 0x0100
175 #define MV88E6060_ANAR_ANEG_AD_100HDX 0x0080
176 #define MV88E6060_ANAR_ANEG_AD_10FDX 0x0040
177 #define MV88E6060_ANAR_ANEG_AD_10HDX 0x0020
178 #define MV88E6060_ANAR_ANEG_AD_SELECTOR 0x001F
179 #define MV88E6060_ANAR_ANEG_AD_SELECTOR_DEFAULT 0x0001
180 
181 //Link Partner Ability register
182 #define MV88E6060_ANLPAR_LP_NXT_PAGE 0x8000
183 #define MV88E6060_ANLPAR_LP_ACK 0x4000
184 #define MV88E6060_ANLPAR_LP_REMOTE_FAULT 0x2000
185 #define MV88E6060_ANLPAR_LP_TECH_ABLE 0x1FE0
186 #define MV88E6060_ANLPAR_LP_SELECTOR 0x001F
187 
188 //Auto-Negotiation Expansion register
189 #define MV88E6060_ANER_PAR_FAULT_DET 0x0010
190 #define MV88E6060_ANER_LP_NXT_PG_ABLE 0x0008
191 #define MV88E6060_ANER_LOCAL_NXT_PG_ABLE 0x0004
192 #define MV88E6060_ANER_RX_NEW_PAGE 0x0002
193 #define MV88E6060_ANER_LP_ANEG_ABLE 0x0001
194 
195 //Next Page Transmit register
196 #define MV88E6060_ANNPR_TX_NXT_PAGE 0x8000
197 #define MV88E6060_ANNPR_TX_MESSAGE 0x2000
198 #define MV88E6060_ANNPR_TX_ACK2 0x1000
199 #define MV88E6060_ANNPR_TX_TOGGLE 0x0800
200 #define MV88E6060_ANNPR_TX_DATA 0x07FF
201 
202 //Link Partner Next Page register
203 #define MV88E6060_ANLPNPR_RX_NXT_PAGE 0x8000
204 #define MV88E6060_ANLPNPR_RX_ACK 0x4000
205 #define MV88E6060_ANLPNPR_RX_MESSAGE 0x2000
206 #define MV88E6060_ANLPNPR_RX_ACK2 0x1000
207 #define MV88E6060_ANLPNPR_RX_TOGGLE 0x0800
208 #define MV88E6060_ANLPNPR_RX_DATA 0x07FF
209 
210 //PHY Specific Control register
211 #define MV88E6060_PHY_SPEC_CTRL_E_DET 0x4000
212 #define MV88E6060_PHY_SPEC_CTRL_DIS_NLP_CHECK 0x2000
213 #define MV88E6060_PHY_SPEC_CTRL_REG8_NXT_PG 0x1000
214 #define MV88E6060_PHY_SPEC_CTRL_DIS_NLP_GEN 0x0800
215 #define MV88E6060_PHY_SPEC_CTRL_FORCE_LINK 0x0400
216 #define MV88E6060_PHY_SPEC_CTRL_DIS_SCRAMBLER 0x0200
217 #define MV88E6060_PHY_SPEC_CTRL_DIS_FEFI 0x0100
218 #define MV88E6060_PHY_SPEC_CTRL_EXTD_DISTANCE 0x0080
219 #define MV88E6060_PHY_SPEC_CTRL_TP_SELECT 0x0040
220 #define MV88E6060_PHY_SPEC_CTRL_AUTO_MDIX 0x0030
221 #define MV88E6060_PHY_SPEC_CTRL_RX_FIFO_DEPTH 0x000C
222 #define MV88E6060_PHY_SPEC_CTRL_AUTO_POL 0x0002
223 #define MV88E6060_PHY_SPEC_CTRL_DIS_JABBER 0x0001
224 
225 //PHY Specific Status register
226 #define MV88E6060_PHY_SPEC_STAT_RES_SPEED 0x4000
227 #define MV88E6060_PHY_SPEC_STAT_RES_DUPLEX 0x2000
228 #define MV88E6060_PHY_SPEC_STAT_RCV_PAGE 0x1000
229 #define MV88E6060_PHY_SPEC_STAT_RESOLVED 0x0800
230 #define MV88E6060_PHY_SPEC_STAT_RT_LINK 0x0400
231 #define MV88E6060_PHY_SPEC_STAT_MDI_MDIX 0x0040
232 #define MV88E6060_PHY_SPEC_STAT_SLEEP 0x0010
233 #define MV88E6060_PHY_SPEC_STAT_RT_POLARITY 0x0002
234 #define MV88E6060_PHY_SPEC_STAT_RT_JABBER 0x0001
235 
236 //PHY Interrupt Enable register
237 #define MV88E6060_PHY_INT_EN_SPEED_INT_EN 0x4000
238 #define MV88E6060_PHY_INT_EN_DUPLEX_INT_EN 0x2000
239 #define MV88E6060_PHY_INT_EN_RCV_PAGE_INT_EN 0x1000
240 #define MV88E6060_PHY_INT_EN_ANEG_DONE_INT_EN 0x0800
241 #define MV88E6060_PHY_INT_EN_LINK_INT_EN 0x0400
242 #define MV88E6060_PHY_INT_EN_SYM_ERR_INT_EN 0x0200
243 #define MV88E6060_PHY_INT_EN_FLS_CRS_INTEN 0x0100
244 #define MV88E6060_PHY_INT_EN_FIFO_ERR_INT 0x0080
245 #define MV88E6060_PHY_INT_EN_MDIX_INT_EN 0x0040
246 #define MV88E6060_PHY_INT_EN_E_DET_INT_EN 0x0010
247 #define MV88E6060_PHY_INT_EN_POLARITY_INT_EN 0x0002
248 #define MV88E6060_PHY_INT_EN_JABBER_INT_EN 0x0001
249 
250 //PHY Interrupt Status register
251 #define MV88E6060_PHY_INT_STAT_SPEED_INT 0x4000
252 #define MV88E6060_PHY_INT_STAT_DUPLEX_INT 0x2000
253 #define MV88E6060_PHY_INT_STAT_RCV_PAGE_INT 0x1000
254 #define MV88E6060_PHY_INT_STAT_ANEG_DONE_INT 0x0800
255 #define MV88E6060_PHY_INT_STAT_LINK_INT 0x0400
256 #define MV88E6060_PHY_INT_STAT_SYM_ERR_INT 0x0200
257 #define MV88E6060_PHY_INT_STAT_FLS_CRS_INT 0x0100
258 #define MV88E6060_PHY_INT_STAT_FIFO_ERR_INT 0x0080
259 #define MV88E6060_PHY_INT_STAT_MDIX_INT 0x0040
260 #define MV88E6060_PHY_INT_STAT_E_DET_INT 0x0010
261 #define MV88E6060_PHY_INT_STAT_POLARITY_INT 0x0002
262 #define MV88E6060_PHY_INT_STAT_JABBER_INT 0x0001
263 
264 //PHY Interrupt Port Summary register
265 #define MV88E6060_PHY_INT_PORT_SUMMARY_PORT4_INT_ACTIVE 0x0010
266 #define MV88E6060_PHY_INT_PORT_SUMMARY_PORT3_INT_ACTIVE 0x0008
267 #define MV88E6060_PHY_INT_PORT_SUMMARY_PORT2_INT_ACTIVE 0x0004
268 #define MV88E6060_PHY_INT_PORT_SUMMARY_PORT1_INT_ACTIVE 0x0002
269 #define MV88E6060_PHY_INT_PORT_SUMMARY_PORT0_INT_ACTIVE 0x0001
270 
271 //LED Parallel Select register
272 #define MV88E6060_LED_PAR_SEL_LED2 0x0F00
273 #define MV88E6060_LED_PAR_SEL_LED2_COLX 0x0000
274 #define MV88E6060_LED_PAR_SEL_LED2_ERROR 0x0100
275 #define MV88E6060_LED_PAR_SEL_LED2_DUPLEX 0x0200
276 #define MV88E6060_LED_PAR_SEL_LED2_DUPLEX_COLX 0x0300
277 #define MV88E6060_LED_PAR_SEL_LED2_SPEED 0x0400
278 #define MV88E6060_LED_PAR_SEL_LED2_LINK 0x0500
279 #define MV88E6060_LED_PAR_SEL_LED2_TX 0x0600
280 #define MV88E6060_LED_PAR_SEL_LED2_RX 0x0700
281 #define MV88E6060_LED_PAR_SEL_LED2_ACT 0x0800
282 #define MV88E6060_LED_PAR_SEL_LED2_LINK_RX 0x0900
283 #define MV88E6060_LED_PAR_SEL_LED2_ACT_BLINK 0x0B00
284 #define MV88E6060_LED_PAR_SEL_LED2_FORCE_1 0x0C00
285 #define MV88E6060_LED_PAR_SEL_LED1 0x00F0
286 #define MV88E6060_LED_PAR_SEL_LED1_COLX 0x0000
287 #define MV88E6060_LED_PAR_SEL_LED1_ERROR 0x0010
288 #define MV88E6060_LED_PAR_SEL_LED1_DUPLEX 0x0020
289 #define MV88E6060_LED_PAR_SEL_LED1_DUPLEX_COLX 0x0030
290 #define MV88E6060_LED_PAR_SEL_LED1_SPEED 0x0040
291 #define MV88E6060_LED_PAR_SEL_LED1_LINK 0x0050
292 #define MV88E6060_LED_PAR_SEL_LED1_TX 0x0060
293 #define MV88E6060_LED_PAR_SEL_LED1_RX 0x0070
294 #define MV88E6060_LED_PAR_SEL_LED1_ACT 0x0080
295 #define MV88E6060_LED_PAR_SEL_LED1_LINK_RX 0x0090
296 #define MV88E6060_LED_PAR_SEL_LED1_ACT_BLINK 0x00B0
297 #define MV88E6060_LED_PAR_SEL_LED1_FORCE_1 0x00C0
298 #define MV88E6060_LED_PAR_SEL_LED0 0x000F
299 #define MV88E6060_LED_PAR_SEL_LED0_COLX 0x0000
300 #define MV88E6060_LED_PAR_SEL_LED0_ERROR 0x0001
301 #define MV88E6060_LED_PAR_SEL_LED0_DUPLEX 0x0002
302 #define MV88E6060_LED_PAR_SEL_LED0_DUPLEX_COLX 0x0003
303 #define MV88E6060_LED_PAR_SEL_LED0_SPEED 0x0004
304 #define MV88E6060_LED_PAR_SEL_LED0_LINK 0x0005
305 #define MV88E6060_LED_PAR_SEL_LED0_TX 0x0006
306 #define MV88E6060_LED_PAR_SEL_LED0_RX 0x0007
307 #define MV88E6060_LED_PAR_SEL_LED0_ACT 0x0008
308 #define MV88E6060_LED_PAR_SEL_LED0_LINK_RX 0x0009
309 #define MV88E6060_LED_PAR_SEL_LED0_ACT_BLINK 0x000B
310 #define MV88E6060_LED_PAR_SEL_LED0_FORCE_1 0x000C
311 
312 //LED Stream Select for Serial LEDs register
313 #define MV88E6060_LED_STREAM_SEL_LED_LNK_ACTY 0xC000
314 #define MV88E6060_LED_STREAM_SEL_LED_LNK_ACTY_OFF 0x0000
315 #define MV88E6060_LED_STREAM_SEL_LED_LNK_ACTY_DUAL 0x8000
316 #define MV88E6060_LED_STREAM_SEL_LED_LNK_ACTY_SINGLE 0xC000
317 #define MV88E6060_LED_STREAM_SEL_LED_RCV_LNK 0x3000
318 #define MV88E6060_LED_STREAM_SEL_LED_RCV_LNK_OFF 0x0000
319 #define MV88E6060_LED_STREAM_SEL_LED_RCV_LNK_DUAL 0x2000
320 #define MV88E6060_LED_STREAM_SEL_LED_RCV_LNK_SINGLE 0x3000
321 #define MV88E6060_LED_STREAM_SEL_LED_ACTY 0x0C00
322 #define MV88E6060_LED_STREAM_SEL_LED_ACTY_OFF 0x0000
323 #define MV88E6060_LED_STREAM_SEL_LED_ACTY_DUAL 0x0800
324 #define MV88E6060_LED_STREAM_SEL_LED_ACTY_SINGLE 0x0C00
325 #define MV88E6060_LED_STREAM_SEL_LED_RCV 0x0300
326 #define MV88E6060_LED_STREAM_SEL_LED_RCV_OFF 0x0000
327 #define MV88E6060_LED_STREAM_SEL_LED_RCV_DUAL 0x0200
328 #define MV88E6060_LED_STREAM_SEL_LED_RCV_SINGLE 0x0300
329 #define MV88E6060_LED_STREAM_SEL_LED_TX 0x00C0
330 #define MV88E6060_LED_STREAM_SEL_LED_TX_OFF 0x0000
331 #define MV88E6060_LED_STREAM_SEL_LED_TX_DUAL 0x0080
332 #define MV88E6060_LED_STREAM_SEL_LED_TX_SINGLE 0x00C0
333 #define MV88E6060_LED_STREAM_SEL_LED_LNK 0x0030
334 #define MV88E6060_LED_STREAM_SEL_LED_LNK_OFF 0x0000
335 #define MV88E6060_LED_STREAM_SEL_LED_LNK_DUAL 0x0020
336 #define MV88E6060_LED_STREAM_SEL_LED_LNK_SINGLE 0x0030
337 #define MV88E6060_LED_STREAM_SEL_LED_SPD 0x000C
338 #define MV88E6060_LED_STREAM_SEL_LED_SPD_OFF 0x0000
339 #define MV88E6060_LED_STREAM_SEL_LED_SPD_DUAL 0x0008
340 #define MV88E6060_LED_STREAM_SEL_LED_SPD_SINGLE 0x000C
341 #define MV88E6060_LED_STREAM_SEL_LED_DX_COLX 0x0003
342 #define MV88E6060_LED_STREAM_SEL_LED_DX_COLX_OFF 0x0000
343 #define MV88E6060_LED_STREAM_SEL_LED_DX_COLX_DUAL 0x0002
344 #define MV88E6060_LED_STREAM_SEL_LED_DX_COLX_SINGLE 0x0003
345 
346 //PHY LED Control register
347 #define MV88E6060_PHY_LED_CTRL_PULSE_STRETCH 0x7000
348 #define MV88E6060_PHY_LED_CTRL_PULSE_STRETCH_NO 0x0000
349 #define MV88E6060_PHY_LED_CTRL_PULSE_STRETCH_21MS_TO_42MS 0x1000
350 #define MV88E6060_PHY_LED_CTRL_PULSE_STRETCH_42MS_TO_84MS 0x2000
351 #define MV88E6060_PHY_LED_CTRL_PULSE_STRETCH_84MS_TO_170MS 0x3000
352 #define MV88E6060_PHY_LED_CTRL_PULSE_STRETCH_170MS_TO_340MS 0x4000
353 #define MV88E6060_PHY_LED_CTRL_PULSE_STRETCH_340MS_TO_670MS 0x5000
354 #define MV88E6060_PHY_LED_CTRL_PULSE_STRETCH_670MS_TO_1_3S 0x6000
355 #define MV88E6060_PHY_LED_CTRL_PULSE_STRETCH_1_3S_TO_2_7S 0x7000
356 #define MV88E6060_PHY_LED_CTRL_BLINK_RATE 0x0E00
357 #define MV88E6060_PHY_LED_CTRL_BLINK_RATE_42MS 0x0000
358 #define MV88E6060_PHY_LED_CTRL_BLINK_RATE_84MS 0x0200
359 #define MV88E6060_PHY_LED_CTRL_BLINK_RATE_170MS 0x0400
360 #define MV88E6060_PHY_LED_CTRL_BLINK_RATE_340MS 0x0600
361 #define MV88E6060_PHY_LED_CTRL_BLINK_RATE_670MS 0x0800
362 #define MV88E6060_PHY_LED_CTRL_SR_STR_UPDATE 0x01C0
363 #define MV88E6060_PHY_LED_CTRL_SR_STR_UPDATE_10MS 0x0000
364 #define MV88E6060_PHY_LED_CTRL_SR_STR_UPDATE_21MS 0x0040
365 #define MV88E6060_PHY_LED_CTRL_SR_STR_UPDATE_42MS 0x0080
366 #define MV88E6060_PHY_LED_CTRL_SR_STR_UPDATE_84MS 0x00C0
367 #define MV88E6060_PHY_LED_CTRL_SR_STR_UPDATE_170MS 0x0100
368 #define MV88E6060_PHY_LED_CTRL_SR_STR_UPDATE_340MS 0x0140
369 #define MV88E6060_PHY_LED_CTRL_DUPLEX 0x0030
370 #define MV88E6060_PHY_LED_CTRL_DUPLEX_OFF 0x0000
371 #define MV88E6060_PHY_LED_CTRL_DUPLEX_DUAL 0x0020
372 #define MV88E6060_PHY_LED_CTRL_DUPLEX_SINGLE 0x0030
373 #define MV88E6060_PHY_LED_CTRL_ERROR 0x000C
374 #define MV88E6060_PHY_LED_CTRL_ERROR_OFF 0x0000
375 #define MV88E6060_PHY_LED_CTRL_ERROR_DUAL 0x0008
376 #define MV88E6060_PHY_LED_CTRL_ERROR_SINGLE 0x000C
377 #define MV88E6060_PHY_LED_CTRL_COLX 0x0003
378 #define MV88E6060_PHY_LED_CTRL_COLX_OFF 0x0000
379 #define MV88E6060_PHY_LED_CTRL_COLX_DUAL 0x0002
380 #define MV88E6060_PHY_LED_CTRL_COLX_SINGLE 0x0003
381 
382 //PHY Manual LED Override register
383 #define MV88E6060_PHY_MAN_LED_OVERRIDE_LED2 0x0030
384 #define MV88E6060_PHY_MAN_LED_OVERRIDE_LED2_NORMAL 0x0000
385 #define MV88E6060_PHY_MAN_LED_OVERRIDE_LED2_BLINK 0x0010
386 #define MV88E6060_PHY_MAN_LED_OVERRIDE_LED2_OFF 0x0020
387 #define MV88E6060_PHY_MAN_LED_OVERRIDE_LED2_ON 0x0030
388 #define MV88E6060_PHY_MAN_LED_OVERRIDE_LED1 0x000C
389 #define MV88E6060_PHY_MAN_LED_OVERRIDE_LED1_NORMAL 0x0000
390 #define MV88E6060_PHY_MAN_LED_OVERRIDE_LED1_BLINK 0x0004
391 #define MV88E6060_PHY_MAN_LED_OVERRIDE_LED1_OFF 0x0008
392 #define MV88E6060_PHY_MAN_LED_OVERRIDE_LED1_ON 0x000C
393 #define MV88E6060_PHY_MAN_LED_OVERRIDE_LED0 0x0003
394 #define MV88E6060_PHY_MAN_LED_OVERRIDE_LED0_NORMAL 0x0000
395 #define MV88E6060_PHY_MAN_LED_OVERRIDE_LED0_BLINK 0x0001
396 #define MV88E6060_PHY_MAN_LED_OVERRIDE_LED0_OFF 0x0002
397 #define MV88E6060_PHY_MAN_LED_OVERRIDE_LED0_ON 0x0003
398 
399 //VCT for TXP/N Pins register
400 #define MV88E6060_VCT_TXPN_EN_VCT 0x8000
401 #define MV88E6060_VCT_TXPN_VCT_TST 0x6000
402 #define MV88E6060_VCT_TXPN_VCT_TST_VALID_NORMAL 0x0000
403 #define MV88E6060_VCT_TXPN_VCT_TST_VALID_SHORT 0x2000
404 #define MV88E6060_VCT_TXPN_VCT_TST_VALID_OPEN 0x4000
405 #define MV88E6060_VCT_TXPN_VCT_TST_FAIL 0x6000
406 #define MV88E6060_VCT_TXPN_AMP_RFLN 0x1F00
407 #define MV88E6060_VCT_TXPN_DIST_RFLN 0x00FF
408 
409 //VCT for RXP/N Pins register
410 #define MV88E6060_VCT_RXPN_VCT_TST 0x6000
411 #define MV88E6060_VCT_RXPN_VCT_TST_VALID_NORMAL 0x0000
412 #define MV88E6060_VCT_RXPN_VCT_TST_VALID_SHORT 0x2000
413 #define MV88E6060_VCT_RXPN_VCT_TST_VALID_OPEN 0x4000
414 #define MV88E6060_VCT_RXPN_VCT_TST_FAIL 0x6000
415 #define MV88E6060_VCT_RXPN_AMP_RFLN 0x1F00
416 #define MV88E6060_VCT_RXPN_DIST_RFLN 0x00FF
417 
418 //PHY Specific Control 2 register
419 #define MV88E6060_PHY_SPEC_CTRL2_SEL_CLS_A 0x0001
420 
421 //Port Status register
422 #define MV88E6060_PORT_STAT_LINK_PAUSE 0x8000
423 #define MV88E6060_PORT_STAT_MY_PAUSE 0x4000
424 #define MV88E6060_PORT_STAT_RESOLVED 0x2000
425 #define MV88E6060_PORT_STAT_LINK 0x1000
426 #define MV88E6060_PORT_STAT_PORT_MODE 0x0800
427 #define MV88E6060_PORT_STAT_PHY_MODE 0x0400
428 #define MV88E6060_PORT_STAT_DUPLEX 0x0200
429 #define MV88E6060_PORT_STAT_SPEED 0x0100
430 
431 //Switch Identifier register
432 #define MV88E6060_SWITCH_ID_DEVICE_ID 0xFFF0
433 #define MV88E6060_SWITCH_ID_DEVICE_ID_DEFAULT 0x0600
434 #define MV88E6060_SWITCH_ID_REV_ID 0x000F
435 
436 //Port Control register
437 #define MV88E6060_PORT_CTRL_FORCE_FLOW_CONTROL 0x8000
438 #define MV88E6060_PORT_CTRL_TRAILER 0x4000
439 #define MV88E6060_PORT_CTRL_HEADER 0x0800
440 #define MV88E6060_PORT_CTRL_RESERVED 0x0600
441 #define MV88E6060_PORT_CTRL_INGRESS_MODE 0x0100
442 #define MV88E6060_PORT_CTRL_VLAN_TUNNEL 0x0080
443 #define MV88E6060_PORT_CTRL_PORT_STATE 0x0003
444 #define MV88E6060_PORT_CTRL_PORT_STATE_DISABLED 0x0000
445 #define MV88E6060_PORT_CTRL_PORT_STATE_BLOCKING 0x0001
446 #define MV88E6060_PORT_CTRL_PORT_STATE_LEARNING 0x0002
447 #define MV88E6060_PORT_CTRL_PORT_STATE_FORWARDING 0x0003
448 
449 //Port Based VLAN Map register
450 #define MV88E6060_PORT_VLAN_MAP_DB_NUM 0xF000
451 #define MV88E6060_PORT_VLAN_MAP_VLAN_TABLE 0x003F
452 #define MV88E6060_PORT_VLAN_MAP_VLAN_TABLE_PORT0 0x0001
453 #define MV88E6060_PORT_VLAN_MAP_VLAN_TABLE_PORT1 0x0002
454 #define MV88E6060_PORT_VLAN_MAP_VLAN_TABLE_PORT2 0x0004
455 #define MV88E6060_PORT_VLAN_MAP_VLAN_TABLE_PORT3 0x0008
456 #define MV88E6060_PORT_VLAN_MAP_VLAN_TABLE_PORT4 0x0010
457 #define MV88E6060_PORT_VLAN_MAP_VLAN_TABLE_PORT5 0x0020
458 
459 //Port Association Vector register
460 #define MV88E6060_PORT_ASSOC_VECTOR_INGRESS_MONITOR 0x8000
461 #define MV88E6060_PORT_ASSOC_VECTOR_PAV 0x003F
462 #define MV88E6060_PORT_ASSOC_VECTOR_PAV_PORT0 0x0001
463 #define MV88E6060_PORT_ASSOC_VECTOR_PAV_PORT1 0x0002
464 #define MV88E6060_PORT_ASSOC_VECTOR_PAV_PORT2 0x0004
465 #define MV88E6060_PORT_ASSOC_VECTOR_PAV_PORT3 0x0008
466 #define MV88E6060_PORT_ASSOC_VECTOR_PAV_PORT4 0x0010
467 #define MV88E6060_PORT_ASSOC_VECTOR_PAV_PORT5 0x0020
468 
469 //Switch Global Status register
470 #define MV88E6060_SWITCH_GLOBAL_STAT_SW_MODE 0x3000
471 #define MV88E6060_SWITCH_GLOBAL_STAT_INIT_READY 0x0800
472 #define MV88E6060_SWITCH_GLOBAL_STAT_ATU_FULL 0x0008
473 #define MV88E6060_SWITCH_GLOBAL_STAT_ATU_DONE 0x0004
474 #define MV88E6060_SWITCH_GLOBAL_STAT_PHY_INT 0x0002
475 #define MV88E6060_SWITCH_GLOBAL_STAT_EE_INT 0x0001
476 
477 //Switch MAC Address Bytes 0 and 1 register
478 #define MV88E6060_SWITCH_MAC_ADDR_0_1_MAC_BYTE0 0xFE00
479 #define MV88E6060_SWITCH_MAC_ADDR_0_1_DIFF_ADDR 0x0100
480 #define MV88E6060_SWITCH_MAC_ADDR_0_1_MAC_BYTE1 0x00FF
481 
482 //Switch MAC Address Bytes 2 and 3 register
483 #define MV88E6060_SWITCH_MAC_ADDR_2_3_MAC_BYTE2 0xFF00
484 #define MV88E6060_SWITCH_MAC_ADDR_2_3_MAC_BYTE3 0x00FF
485 
486 //Switch MAC Address Bytes 4 and 5 register
487 #define MV88E6060_SWITCH_MAC_ADDR_4_5_MAC_BYTE4 0xFF00
488 #define MV88E6060_SWITCH_MAC_ADDR_4_5_MAC_BYTE5 0x00FF
489 
490 //Switch Global Control register
491 #define MV88E6060_SWITCH_GLOBAL_CTRL_DISCARD_EXCESSIVE 0x2000
492 #define MV88E6060_SWITCH_GLOBAL_CTRL_MAX_FRAME_SIZE 0x0400
493 #define MV88E6060_SWITCH_GLOBAL_CTRL_RE_LOAD 0x0200
494 #define MV88E6060_SWITCH_GLOBAL_CTRL_CTR_MODE 0x0100
495 #define MV88E6060_SWITCH_GLOBAL_CTRL_ATU_FULL_INT_EN 0x0008
496 #define MV88E6060_SWITCH_GLOBAL_CTRL_ATU_DONE_INT_EN 0x0004
497 #define MV88E6060_SWITCH_GLOBAL_CTRL_PHY_INT_EN 0x0002
498 #define MV88E6060_SWITCH_GLOBAL_CTRL_EE_INT_EN 0x0001
499 
500 //ATU Control register
501 #define MV88E6060_ATU_CTRL_SW_RESET 0x8000
502 #define MV88E6060_ATU_CTRL_LEARN_DIS 0x4000
503 #define MV88E6060_ATU_CTRL_ATU_SIZE 0x3000
504 #define MV88E6060_ATU_CTRL_ATU_SIZE_256 0x0000
505 #define MV88E6060_ATU_CTRL_ATU_SIZE_512 0x1000
506 #define MV88E6060_ATU_CTRL_ATU_SIZE_1024 0x2000
507 #define MV88E6060_ATU_CTRL_AGE_TIME 0x0FF0
508 #define MV88E6060_ATU_CTRL_AGE_TIME_DEFAULT 0x0130
509 
510 //ATU Operation register
511 #define MV88E6060_ATU_OPERATION_ATU_BUSY 0x8000
512 #define MV88E6060_ATU_OPERATION_ATU_OP 0x7000
513 #define MV88E6060_ATU_OPERATION_ATU_OP_NOP 0x0000
514 #define MV88E6060_ATU_OPERATION_ATU_OP_FLUSH_ALL 0x1000
515 #define MV88E6060_ATU_OPERATION_ATU_OP_FLUSH_UNLOCKED 0x2000
516 #define MV88E6060_ATU_OPERATION_ATU_OP_LOAD_PURGE 0x3000
517 #define MV88E6060_ATU_OPERATION_ATU_OP_GET_NEXT_DB 0x4000
518 #define MV88E6060_ATU_OPERATION_ATU_OP_FLUSH_ALL_DB 0x5000
519 #define MV88E6060_ATU_OPERATION_ATU_OP_FLUSH_UNLOCKED_DB 0x6000
520 #define MV88E6060_ATU_OPERATION_DB_NUM 0x000F
521 
522 //ATU Data register
523 #define MV88E6060_ATU_DATA_DPV 0x03F0
524 #define MV88E6060_ATU_DATA_DPV_PORT0 0x0010
525 #define MV88E6060_ATU_DATA_DPV_PORT1 0x0020
526 #define MV88E6060_ATU_DATA_DPV_PORT2 0x0040
527 #define MV88E6060_ATU_DATA_DPV_PORT3 0x0080
528 #define MV88E6060_ATU_DATA_DPV_PORT4 0x0100
529 #define MV88E6060_ATU_DATA_DPV_PORT5 0x0200
530 #define MV88E6060_ATU_DATA_ENTRY_STATE 0x000F
531 #define MV88E6060_ATU_DATA_ENTRY_STATE_INVALID 0x0000
532 #define MV88E6060_ATU_DATA_ENTRY_STATE_LOCKED_MULTICAST 0x0007
533 #define MV88E6060_ATU_DATA_ENTRY_STATE_LOCKED_UNICAST 0x000F
534 #define MV88E6060_ATU_DATA_ENTRY_STATE_LOCKED_MGMT 0x000E
535 
536 //ATU Switch MAC Address Bytes 0 and 1 register
537 #define MV88E6060_ATU_MAC_ADDR_0_1_ATU_BYTE0 0xFF00
538 #define MV88E6060_ATU_MAC_ADDR_0_1_ATU_BYTE1 0x00FF
539 
540 //ATU Switch MAC Address Bytes 2 and 3 register
541 #define MV88E6060_ATU_MAC_ADDR_2_3_ATU_BYTE2 0xFF00
542 #define MV88E6060_ATU_MAC_ADDR_2_3_ATU_BYTE3 0x00FF
543 
544 //ATU Switch MAC Address Bytes 4 and 5 register
545 #define MV88E6060_ATU_MAC_ADDR_4_5_ATU_BYTE4 0xFF00
546 #define MV88E6060_ATU_MAC_ADDR_4_5_ATU_BYTE5 0x00FF
547 
548 //C++ guard
549 #ifdef __cplusplus
550 extern "C" {
551 #endif
552 
553 //88E6060 Ethernet switch driver
555 
556 //MV88E6060 related functions
558 void mv88e6060InitHook(NetInterface *interface);
559 
560 void mv88e6060Tick(NetInterface *interface);
561 
562 void mv88e6060EnableIrq(NetInterface *interface);
563 void mv88e6060DisableIrq(NetInterface *interface);
564 
565 void mv88e6060EventHandler(NetInterface *interface);
566 
567 error_t mv88e6060TagFrame(NetInterface *interface, NetBuffer *buffer,
568  size_t *offset, NetTxAncillary *ancillary);
569 
570 error_t mv88e6060UntagFrame(NetInterface *interface, uint8_t **frame,
571  size_t *length, NetRxAncillary *ancillary);
572 
573 bool_t mv88e6060GetLinkState(NetInterface *interface, uint8_t port);
574 uint32_t mv88e6060GetLinkSpeed(NetInterface *interface, uint8_t port);
576 
577 void mv88e6060SetPortState(NetInterface *interface, uint8_t port,
578  SwitchPortState state);
579 
581 
582 void mv88e6060SetAgingTime(NetInterface *interface, uint32_t agingTime);
583 
584 void mv88e6060EnableIgmpSnooping(NetInterface *interface, bool_t enable);
585 void mv88e6060EnableMldSnooping(NetInterface *interface, bool_t enable);
586 void mv88e6060EnableRsvdMcastTable(NetInterface *interface, bool_t enable);
587 
589  const SwitchFdbEntry *entry);
590 
592  const SwitchFdbEntry *entry);
593 
595  SwitchFdbEntry *entry);
596 
598 
600  SwitchFdbEntry *entry);
601 
602 void mv88e6060FlushDynamicFdbTable(NetInterface *interface, uint8_t port);
603 
605  bool_t enable, uint32_t forwardPorts);
606 
607 void mv88e6060WriteSmiReg(NetInterface *interface, uint8_t deviceAddr,
608  uint8_t regAddr, uint16_t data);
609 
610 uint16_t mv88e6060ReadSmiReg(NetInterface *interface, uint8_t deviceAddr,
611  uint8_t regAddr);
612 
613 void mv88e6060WritePhyReg(NetInterface *interface, uint8_t port,
614  uint8_t address, uint16_t data);
615 
616 uint16_t mv88e6060ReadPhyReg(NetInterface *interface, uint8_t port,
617  uint8_t address);
618 
619 void mv88e6060DumpPhyReg(NetInterface *interface, uint8_t port);
620 
621 void mv88e6060WriteSwitchPortReg(NetInterface *interface, uint8_t port,
622  uint8_t address, uint16_t data);
623 
624 uint16_t mv88e6060ReadSwitchPortReg(NetInterface *interface, uint8_t port,
625  uint8_t address);
626 
627 void mv88e6060WriteSwitchGlobalReg(NetInterface *interface, uint8_t address,
628  uint16_t data);
629 
630 uint16_t mv88e6060ReadSwitchGlobalReg(NetInterface *interface, uint8_t address);
631 
632 //C++ guard
633 #ifdef __cplusplus
634 }
635 #endif
636 
637 #endif
int bool_t
Definition: compiler_port.h:53
error_t mv88e6060GetDynamicFdbEntry(NetInterface *interface, uint_t index, SwitchFdbEntry *entry)
Read an entry from the dynamic MAC table.
error_t mv88e6060DeleteStaticFdbEntry(NetInterface *interface, const SwitchFdbEntry *entry)
Remove an entry from the static MAC table.
uint16_t mv88e6060ReadSwitchGlobalReg(NetInterface *interface, uint8_t address)
Read switch global register.
void mv88e6060SetUnknownMcastFwdPorts(NetInterface *interface, bool_t enable, uint32_t forwardPorts)
Set forward ports for unknown multicast packets.
void mv88e6060EnableMldSnooping(NetInterface *interface, bool_t enable)
Enable MLD snooping.
Structure describing a buffer that spans multiple chunks.
Definition: net_mem.h:89
uint8_t data[]
Definition: ethernet.h:222
void mv88e6060EnableRsvdMcastTable(NetInterface *interface, bool_t enable)
Enable reserved multicast table.
SwitchPortState mv88e6060GetPortState(NetInterface *interface, uint8_t port)
Get port state.
void mv88e6060DumpPhyReg(NetInterface *interface, uint8_t port)
Dump PHY registers for debugging purpose.
NicDuplexMode mv88e6060GetDuplexMode(NetInterface *interface, uint8_t port)
Get duplex mode.
uint16_t mv88e6060ReadSmiReg(NetInterface *interface, uint8_t deviceAddr, uint8_t regAddr)
Read SMI register.
void mv88e6060SetAgingTime(NetInterface *interface, uint32_t agingTime)
Set aging time for dynamic filtering entries.
uint16_t mv88e6060ReadSwitchPortReg(NetInterface *interface, uint8_t port, uint8_t address)
Read switch port register.
uint16_t mv88e6060ReadPhyReg(NetInterface *interface, uint8_t port, uint8_t address)
Read PHY register.
uint32_t mv88e6060GetLinkSpeed(NetInterface *interface, uint8_t port)
Get link speed.
bool_t mv88e6060GetLinkState(NetInterface *interface, uint8_t port)
Get link state.
error_t
Error codes.
Definition: error.h:43
void mv88e6060EnableIrq(NetInterface *interface)
Enable interrupts.
const SwitchDriver mv88e6060SwitchDriver
88E6060 Ethernet switch driver
#define NetRxAncillary
Definition: net_misc.h:40
#define NetInterface
Definition: net.h:36
error_t mv88e6060TagFrame(NetInterface *interface, NetBuffer *buffer, size_t *offset, NetTxAncillary *ancillary)
Add ingress trailer to Ethernet frame.
void mv88e6060WriteSwitchPortReg(NetInterface *interface, uint8_t port, uint8_t address, uint16_t data)
Write switch port register.
#define NetTxAncillary
Definition: net_misc.h:36
SwitchPortState
Switch port state.
Definition: nic.h:134
void mv88e6060Tick(NetInterface *interface)
88E6060 timer handler
uint8_t length
Definition: tcp.h:368
void mv88e6060WritePhyReg(NetInterface *interface, uint8_t port, uint8_t address, uint16_t data)
Write PHY register.
void mv88e6060EnableIgmpSnooping(NetInterface *interface, bool_t enable)
Enable IGMP snooping.
void mv88e6060EventHandler(NetInterface *interface)
88E6060 event handler
uint16_t port
Definition: dns_common.h:267
error_t mv88e6060AddStaticFdbEntry(NetInterface *interface, const SwitchFdbEntry *entry)
Add a new entry to the static MAC table.
uint16_t regAddr
Ethernet switch driver.
Definition: nic.h:325
void mv88e6060FlushStaticFdbTable(NetInterface *interface)
Flush static MAC table.
Ipv6Addr address[]
Definition: ipv6.h:325
void mv88e6060WriteSmiReg(NetInterface *interface, uint8_t deviceAddr, uint8_t regAddr, uint16_t data)
Write SMI register.
NicDuplexMode
Duplex mode.
Definition: nic.h:122
Network interface controller abstraction layer.
error_t mv88e6060UntagFrame(NetInterface *interface, uint8_t **frame, size_t *length, NetRxAncillary *ancillary)
Decode egress trailer from incoming Ethernet frame.
void mv88e6060FlushDynamicFdbTable(NetInterface *interface, uint8_t port)
Flush dynamic MAC table.
unsigned int uint_t
Definition: compiler_port.h:50
void mv88e6060SetPortState(NetInterface *interface, uint8_t port, SwitchPortState state)
Set port state.
error_t mv88e6060GetStaticFdbEntry(NetInterface *interface, uint_t index, SwitchFdbEntry *entry)
Read an entry from the static MAC table.
void mv88e6060DisableIrq(NetInterface *interface)
Disable interrupts.
void mv88e6060InitHook(NetInterface *interface)
88E6060 custom configuration
Forwarding database entry.
Definition: nic.h:149
void mv88e6060WriteSwitchGlobalReg(NetInterface *interface, uint8_t address, uint16_t data)
Write switch global register.
error_t mv88e6060Init(NetInterface *interface)
88E6060 Ethernet switch initialization