ksz8864_driver.h
Go to the documentation of this file.
1 /**
2  * @file ksz8864_driver.h
3  * @brief KSZ8864 4-port Ethernet switch driver
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2026 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.6.0
29  **/
30 
31 #ifndef _KSZ8864_DRIVER_H
32 #define _KSZ8864_DRIVER_H
33 
34 //Dependencies
35 #include "core/nic.h"
36 
37 //Port identifiers
38 #define KSZ8864_PORT1 1
39 #define KSZ8864_PORT2 2
40 #define KSZ8864_PORT3 3
41 #define KSZ8864_PORT4 4
42 
43 //Port masks
44 #define KSZ8864_PORT_MASK 0x0F
45 #define KSZ8864_PORT1_MASK 0x01
46 #define KSZ8864_PORT2_MASK 0x02
47 #define KSZ8864_PORT3_MASK 0x04
48 #define KSZ8864_PORT4_MASK 0x08
49 
50 //SPI command byte
51 #define KSZ8864_SPI_CMD_WRITE 0x02
52 #define KSZ8864_SPI_CMD_READ 0x03
53 
54 //Size of static and dynamic MAC tables
55 #define KSZ8864_STATIC_MAC_TABLE_SIZE 32
56 #define KSZ8864_DYNAMIC_MAC_TABLE_SIZE 1024
57 
58 //Tail tag rules (host to KSZ8864)
59 #define KSZ8864_TAIL_TAG_NORMAL_ADDR_LOOKUP 0x80
60 #define KSZ8864_TAIL_TAG_PORT_SEL 0x40
61 #define KSZ8864_TAIL_TAG_DEST_QUEUE 0x30
62 #define KSZ8864_TAIL_TAG_DEST_PORT3 0x08
63 #define KSZ8864_TAIL_TAG_DEST_PORT2 0x04
64 #define KSZ8864_TAIL_TAG_DEST_PORT1 0x02
65 
66 //Tail tag rules (KSZ8864 to host)
67 #define KSZ8864_TAIL_TAG_SRC_PORT 0x03
68 
69 //KSZ8864 PHY registers
70 #define KSZ8864_BMCR 0x00
71 #define KSZ8864_BMSR 0x01
72 #define KSZ8864_PHYID1 0x02
73 #define KSZ8864_PHYID2 0x03
74 #define KSZ8864_ANAR 0x04
75 #define KSZ8864_ANLPAR 0x05
76 #define KSZ8864_LINKMD 0x1D
77 #define KSZ8864_PHYSCS 0x1F
78 
79 //KSZ8864 Switch registers
80 #define KSZ8864_CHIP_ID0 0x00
81 #define KSZ8864_CHIP_ID1 0x01
82 #define KSZ8864_GLOBAL_CTRL0 0x02
83 #define KSZ8864_GLOBAL_CTRL1 0x03
84 #define KSZ8864_GLOBAL_CTRL2 0x04
85 #define KSZ8864_GLOBAL_CTRL3 0x05
86 #define KSZ8864_GLOBAL_CTRL4 0x06
87 #define KSZ8864_GLOBAL_CTRL5 0x07
88 #define KSZ8864_GLOBAL_CTRL6 0x08
89 #define KSZ8864_GLOBAL_CTRL7 0x09
90 #define KSZ8864_GLOBAL_CTRL8 0x0A
91 #define KSZ8864_GLOBAL_CTRL9 0x0B
92 #define KSZ8864_GLOBAL_CTRL10 0x0C
93 #define KSZ8864_GLOBAL_CTRL11 0x0D
94 #define KSZ8864_PD_MGMT_CTRL1 0x0E
95 #define KSZ8864_PD_MGMT_CTRL2 0x0F
96 #define KSZ8864_PORT1_CTRL0 0x20
97 #define KSZ8864_PORT1_CTRL1 0x21
98 #define KSZ8864_PORT1_CTRL2 0x22
99 #define KSZ8864_PORT1_CTRL3 0x23
100 #define KSZ8864_PORT1_CTRL4 0x24
101 #define KSZ8864_PORT1_STAT0 0x29
102 #define KSZ8864_PORT1_PSCS 0x2A
103 #define KSZ8864_PORT1_LINKMD 0x2B
104 #define KSZ8864_PORT1_CTRL5 0x2C
105 #define KSZ8864_PORT1_CTRL6 0x2D
106 #define KSZ8864_PORT1_STAT1 0x2E
107 #define KSZ8864_PORT1_CTRL7_STAT2 0x2F
108 #define KSZ8864_PORT2_CTRL0 0x30
109 #define KSZ8864_PORT2_CTRL1 0x31
110 #define KSZ8864_PORT2_CTRL2 0x32
111 #define KSZ8864_PORT2_CTRL3 0x33
112 #define KSZ8864_PORT2_CTRL4 0x34
113 #define KSZ8864_PORT2_STAT0 0x39
114 #define KSZ8864_PORT2_PSCS 0x3A
115 #define KSZ8864_PORT2_LINKMD 0x3B
116 #define KSZ8864_PORT2_CTRL5 0x3C
117 #define KSZ8864_PORT2_CTRL6 0x3D
118 #define KSZ8864_PORT2_STAT1 0x3E
119 #define KSZ8864_PORT2_CTRL7_STAT2 0x3F
120 #define KSZ8864_PORT3_CTRL0 0x40
121 #define KSZ8864_PORT3_CTRL1 0x41
122 #define KSZ8864_PORT3_CTRL2 0x42
123 #define KSZ8864_PORT3_CTRL3 0x43
124 #define KSZ8864_PORT3_CTRL4 0x44
125 #define KSZ8864_PORT3_CTRL6 0x4D
126 #define KSZ8864_PORT4_CTRL0 0x50
127 #define KSZ8864_PORT4_CTRL1 0x51
128 #define KSZ8864_PORT4_CTRL2 0x52
129 #define KSZ8864_PORT4_CTRL3 0x53
130 #define KSZ8864_PORT4_CTRL4 0x54
131 #define KSZ8864_RMII_MGMT_CTRL 0x57
132 #define KSZ8864_PORT4_CTRL6 0x5D
133 #define KSZ8864_MAC_ADDR0 0x68
134 #define KSZ8864_MAC_ADDR1 0x69
135 #define KSZ8864_MAC_ADDR2 0x6A
136 #define KSZ8864_MAC_ADDR3 0x6B
137 #define KSZ8864_MAC_ADDR4 0x6C
138 #define KSZ8864_MAC_ADDR5 0x6D
139 #define KSZ8864_INDIRECT_CTRL0 0x6E
140 #define KSZ8864_INDIRECT_CTRL1 0x6F
141 #define KSZ8864_INDIRECT_DATA8 0x70
142 #define KSZ8864_INDIRECT_DATA7 0x71
143 #define KSZ8864_INDIRECT_DATA6 0x72
144 #define KSZ8864_INDIRECT_DATA5 0x73
145 #define KSZ8864_INDIRECT_DATA4 0x74
146 #define KSZ8864_INDIRECT_DATA3 0x75
147 #define KSZ8864_INDIRECT_DATA2 0x76
148 #define KSZ8864_INDIRECT_DATA1 0x77
149 #define KSZ8864_INDIRECT_DATA0 0x78
150 #define KSZ8864_INT_STAT 0x7C
151 #define KSZ8864_INT_MASK 0x7D
152 #define KSZ8864_GLOBAL_CTRL12 0x80
153 #define KSZ8864_GLOBAL_CTRL13 0x81
154 #define KSZ8864_GLOBAL_CTRL14 0x82
155 #define KSZ8864_GLOBAL_CTRL15 0x83
156 #define KSZ8864_GLOBAL_CTRL16 0x84
157 #define KSZ8864_GLOBAL_CTRL17 0x85
158 #define KSZ8864_GLOBAL_CTRL18 0x86
159 #define KSZ8864_GLOBAL_CTRL19 0x87
160 #define KSZ8864_ID 0x89
161 #define KSZ8864_TOS_PRIO_CTRL0 0x90
162 #define KSZ8864_TOS_PRIO_CTRL1 0x91
163 #define KSZ8864_TOS_PRIO_CTRL2 0x92
164 #define KSZ8864_TOS_PRIO_CTRL3 0x93
165 #define KSZ8864_TOS_PRIO_CTRL4 0x94
166 #define KSZ8864_TOS_PRIO_CTRL5 0x95
167 #define KSZ8864_TOS_PRIO_CTRL6 0x96
168 #define KSZ8864_TOS_PRIO_CTRL7 0x97
169 #define KSZ8864_TOS_PRIO_CTRL8 0x98
170 #define KSZ8864_TOS_PRIO_CTRL9 0x99
171 #define KSZ8864_TOS_PRIO_CTRL10 0x9A
172 #define KSZ8864_TOS_PRIO_CTRL11 0x9B
173 #define KSZ8864_TOS_PRIO_CTRL12 0x9C
174 #define KSZ8864_TOS_PRIO_CTRL13 0x9D
175 #define KSZ8864_TOS_PRIO_CTRL14 0x9E
176 #define KSZ8864_TOS_PRIO_CTRL15 0x9F
177 #define KSZ8864_TEST 0xBF
178 #define KSZ8864_PORT1_CTRL8 0xC0
179 #define KSZ8864_PORT1_CTRL9 0xC1
180 #define KSZ8864_PORT1_CTRL10 0xC2
181 #define KSZ8864_PORT1_CTRL11 0xC3
182 #define KSZ8864_PORT1_CTRL12 0xC4
183 #define KSZ8864_PORT1_CTRL13 0xC5
184 #define KSZ8864_PORT1_RATE_LIMIT_CTRL 0xC6
185 #define KSZ8864_PORT1_PRIO0_IG_LIMIT_CTRL1 0xC7
186 #define KSZ8864_PORT1_PRIO1_IG_LIMIT_CTRL2 0xC8
187 #define KSZ8864_PORT1_PRIO2_IG_LIMIT_CTRL3 0xC9
188 #define KSZ8864_PORT1_PRIO3_IG_LIMIT_CTRL4 0xCA
189 #define KSZ8864_PORT1_QUEUE0_EG_LIMIT_CTRL1 0xCB
190 #define KSZ8864_PORT1_QUEUE1_EG_LIMIT_CTRL2 0xCC
191 #define KSZ8864_PORT1_QUEUE2_EG_LIMIT_CTRL3 0xCD
192 #define KSZ8864_PORT1_QUEUE3_EG_LIMIT_CTRL4 0xCE
193 #define KSZ8864_TEST_PORT3_CTRL1 0xCF
194 #define KSZ8864_PORT2_CTRL8 0xD0
195 #define KSZ8864_PORT2_CTRL9 0xD1
196 #define KSZ8864_PORT2_CTRL10 0xD2
197 #define KSZ8864_PORT2_CTRL11 0xD3
198 #define KSZ8864_PORT2_CTRL12 0xD4
199 #define KSZ8864_PORT2_CTRL13 0xD5
200 #define KSZ8864_PORT2_RATE_LIMIT_CTRL 0xD6
201 #define KSZ8864_PORT2_PRIO0_IG_LIMIT_CTRL1 0xD7
202 #define KSZ8864_PORT2_PRIO1_IG_LIMIT_CTRL2 0xD8
203 #define KSZ8864_PORT2_PRIO2_IG_LIMIT_CTRL3 0xD9
204 #define KSZ8864_PORT2_PRIO3_IG_LIMIT_CTRL4 0xDA
205 #define KSZ8864_PORT2_QUEUE0_EG_LIMIT_CTRL1 0xDB
206 #define KSZ8864_PORT2_QUEUE1_EG_LIMIT_CTRL2 0xDC
207 #define KSZ8864_PORT2_QUEUE2_EG_LIMIT_CTRL3 0xDD
208 #define KSZ8864_PORT2_QUEUE3_EG_LIMIT_CTRL4 0xDE
209 #define KSZ8864_TEST_PORT3_CTRL2 0xDF
210 #define KSZ8864_PORT3_CTRL8 0xE0
211 #define KSZ8864_PORT3_CTRL9 0xE1
212 #define KSZ8864_PORT3_CTRL10 0xE2
213 #define KSZ8864_PORT3_CTRL11 0xE3
214 #define KSZ8864_PORT3_CTRL12 0xE4
215 #define KSZ8864_PORT3_CTRL13 0xE5
216 #define KSZ8864_PORT3_RATE_LIMIT_CTRL 0xE6
217 #define KSZ8864_PORT3_PRIO0_IG_LIMIT_CTRL1 0xE7
218 #define KSZ8864_PORT3_PRIO1_IG_LIMIT_CTRL2 0xE8
219 #define KSZ8864_PORT3_PRIO2_IG_LIMIT_CTRL3 0xE9
220 #define KSZ8864_PORT3_PRIO3_IG_LIMIT_CTRL4 0xEA
221 #define KSZ8864_PORT3_QUEUE0_EG_LIMIT_CTRL1 0xEB
222 #define KSZ8864_PORT3_QUEUE1_EG_LIMIT_CTRL2 0xEC
223 #define KSZ8864_PORT3_QUEUE2_EG_LIMIT_CTRL3 0xED
224 #define KSZ8864_PORT3_QUEUE3_EG_LIMIT_CTRL4 0xEE
225 #define KSZ8864_TEST3 0xEF
226 #define KSZ8864_PORT4_CTRL8 0xF0
227 #define KSZ8864_PORT4_CTRL9 0xF1
228 #define KSZ8864_PORT4_CTRL10 0xF2
229 #define KSZ8864_PORT4_CTRL11 0xF3
230 #define KSZ8864_PORT4_CTRL12 0xF4
231 #define KSZ8864_PORT4_CTRL13 0xF5
232 #define KSZ8864_PORT4_RATE_LIMIT_CTRL 0xF6
233 #define KSZ8864_PORT4_PRIO0_IG_LIMIT_CTRL1 0xF7
234 #define KSZ8864_PORT4_PRIO1_IG_LIMIT_CTRL2 0xF8
235 #define KSZ8864_PORT4_PRIO2_IG_LIMIT_CTRL3 0xF9
236 #define KSZ8864_PORT4_PRIO3_IG_LIMIT_CTRL4 0xFA
237 #define KSZ8864_PORT4_QUEUE0_EG_LIMIT_CTRL1 0xFB
238 #define KSZ8864_PORT4_QUEUE1_EG_LIMIT_CTRL2 0xFC
239 #define KSZ8864_PORT4_QUEUE2_EG_LIMIT_CTRL3 0xFD
240 #define KSZ8864_PORT4_QUEUE3_EG_LIMIT_CTRL4 0xFE
241 #define KSZ8864_TEST4 0xFF
242 
243 //KSZ8864 Switch register access macros
244 #define KSZ8864_PORTn_CTRL0(port) (0x10 + ((port) * 0x10))
245 #define KSZ8864_PORTn_CTRL1(port) (0x11 + ((port) * 0x10))
246 #define KSZ8864_PORTn_CTRL2(port) (0x12 + ((port) * 0x10))
247 #define KSZ8864_PORTn_CTRL3(port) (0x13 + ((port) * 0x10))
248 #define KSZ8864_PORTn_CTRL4(port) (0x14 + ((port) * 0x10))
249 #define KSZ8864_PORTn_STAT0(port) (0x19 + ((port) * 0x10))
250 #define KSZ8864_PORTn_PSCS(port) (0x1A + ((port) * 0x10))
251 #define KSZ8864_PORTn_LINKMD(port) (0x1B + ((port) * 0x10))
252 #define KSZ8864_PORTn_CTRL5(port) (0x1C + ((port) * 0x10))
253 #define KSZ8864_PORTn_CTRL6(port) (0x1D + ((port) * 0x10))
254 #define KSZ8864_PORTn_STAT1(port) (0x1E + ((port) * 0x10))
255 #define KSZ8864_PORTn_CTRL7_STAT2(port) (0x1F + ((port) * 0x10))
256 #define KSZ8864_PORTn_CTRL8(port) (0xB0 + ((port) * 0x10))
257 #define KSZ8864_PORTn_CTRL9(port) (0xB1 + ((port) * 0x10))
258 #define KSZ8864_PORTn_CTRL10(port) (0xB2 + ((port) * 0x10))
259 #define KSZ8864_PORTn_CTRL11(port) (0xB3 + ((port) * 0x10))
260 #define KSZ8864_PORTn_CTRL12(port) (0xB4 + ((port) * 0x10))
261 #define KSZ8864_PORTn_CTRL13(port) (0xB5 + ((port) * 0x10))
262 #define KSZ8864_PORTn_RATE_LIMIT_CTRL(port) (0xB6 + ((port) * 0x10))
263 #define KSZ8864_PORTn_PRIO0_IG_LIMIT_CTRL1(port) (0xB7 + ((port) * 0x10))
264 #define KSZ8864_PORTn_PRIO1_IG_LIMIT_CTRL2(port) (0xB8 + ((port) * 0x10))
265 #define KSZ8864_PORTn_PRIO2_IG_LIMIT_CTRL3(port) (0xB9 + ((port) * 0x10))
266 #define KSZ8864_PORTn_PRIO3_IG_LIMIT_CTRL4(port) (0xBA + ((port) * 0x10))
267 #define KSZ8864_PORTn_QUEUE0_EG_LIMIT_CTRL1(port) (0xBB + ((port) * 0x10))
268 #define KSZ8864_PORTn_QUEUE1_EG_LIMIT_CTRL2(port) (0xBC + ((port) * 0x10))
269 #define KSZ8864_PORTn_QUEUE2_EG_LIMIT_CTRL3(port) (0xBD + ((port) * 0x10))
270 #define KSZ8864_PORTn_QUEUE3_EG_LIMIT_CTRL4(port) (0xBE + ((port) * 0x10))
271 
272 //MII Control register
273 #define KSZ8864_BMCR_RESET 0x8000
274 #define KSZ8864_BMCR_LOOPBACK 0x4000
275 #define KSZ8864_BMCR_FORCE_100 0x2000
276 #define KSZ8864_BMCR_AN_EN 0x1000
277 #define KSZ8864_BMCR_POWER_DOWN 0x0800
278 #define KSZ8864_BMCR_ISOLATE 0x0400
279 #define KSZ8864_BMCR_RESTART_AN 0x0200
280 #define KSZ8864_BMCR_FORCE_FULL_DUPLEX 0x0100
281 #define KSZ8864_BMCR_COL_TEST 0x0080
282 #define KSZ8864_BMCR_HP_MDIX 0x0020
283 #define KSZ8864_BMCR_FORCE_MDI 0x0010
284 #define KSZ8864_BMCR_AUTO_MDIX_DIS 0x0008
285 #define KSZ8864_BMCR_FAR_END_FAULT_DIS 0x0004
286 #define KSZ8864_BMCR_TRANSMIT_DIS 0x0002
287 #define KSZ8864_BMCR_LED_DIS 0x0001
288 
289 //MII Status register
290 #define KSZ8864_BMSR_100BT4 0x8000
291 #define KSZ8864_BMSR_100BTX_FD 0x4000
292 #define KSZ8864_BMSR_100BTX_HD 0x2000
293 #define KSZ8864_BMSR_10BT_FD 0x1000
294 #define KSZ8864_BMSR_10BT_HD 0x0800
295 #define KSZ8864_BMSR_PREAMBLE_SUPPR 0x0040
296 #define KSZ8864_BMSR_AN_COMPLETE 0x0020
297 #define KSZ8864_BMSR_FAR_END_FAULT 0x0010
298 #define KSZ8864_BMSR_AN_CAPABLE 0x0008
299 #define KSZ8864_BMSR_LINK_STATUS 0x0004
300 #define KSZ8864_BMSR_JABBER_TEST 0x0002
301 #define KSZ8864_BMSR_EXTENDED_CAPABLE 0x0001
302 
303 //PHYID High register
304 #define KSZ8864_PHYID1_DEFAULT 0x0022
305 
306 //PHYID Low register
307 #define KSZ8864_PHYID2_DEFAULT 0x1450
308 
309 //Advertisement Ability register
310 #define KSZ8864_ANAR_NEXT_PAGE 0x8000
311 #define KSZ8864_ANAR_REMOTE_FAULT 0x2000
312 #define KSZ8864_ANAR_PAUSE 0x0400
313 #define KSZ8864_ANAR_100BTX_FD 0x0100
314 #define KSZ8864_ANAR_100BTX_HD 0x0080
315 #define KSZ8864_ANAR_10BT_FD 0x0040
316 #define KSZ8864_ANAR_10BT_HD 0x0020
317 #define KSZ8864_ANAR_SELECTOR 0x001F
318 #define KSZ8864_ANAR_SELECTOR_DEFAULT 0x0001
319 
320 //Link Partner Ability register
321 #define KSZ8864_ANLPAR_NEXT_PAGE 0x8000
322 #define KSZ8864_ANLPAR_LP_ACK 0x4000
323 #define KSZ8864_ANLPAR_REMOTE_FAULT 0x2000
324 #define KSZ8864_ANLPAR_PAUSE 0x0400
325 #define KSZ8864_ANLPAR_100BTX_FD 0x0100
326 #define KSZ8864_ANLPAR_100BTX_HD 0x0080
327 #define KSZ8864_ANLPAR_10BT_FD 0x0040
328 #define KSZ8864_ANLPAR_10BT_HD 0x0020
329 
330 //LinkMD Control/Status register
331 #define KSZ8864_LINKMD_TEST_EN 0x8000
332 #define KSZ8864_LINKMD_RESULT 0x6000
333 #define KSZ8864_LINKMD_SHORT 0x1000
334 #define KSZ8864_LINKMD_FAULT_COUNT 0x01FF
335 
336 //PHY Special Control/Status register
337 #define KSZ8864_PHYSCS_OP_MODE 0x0700
338 #define KSZ8864_PHYSCS_OP_MODE_AN 0x0100
339 #define KSZ8864_PHYSCS_OP_MODE_10BT_HD 0x0200
340 #define KSZ8864_PHYSCS_OP_MODE_100BTX_HD 0x0300
341 #define KSZ8864_PHYSCS_OP_MODE_10BT_FD 0x0500
342 #define KSZ8864_PHYSCS_OP_MODE_100BTX_FD 0x0600
343 #define KSZ8864_PHYSCS_OP_MODE_ISOLATE 0x0700
344 #define KSZ8864_PHYSCS_POLRVS 0x0020
345 #define KSZ8864_PHYSCS_MDIX_STATUS 0x0010
346 #define KSZ8864_PHYSCS_FORCE_LINK 0x0008
347 #define KSZ8864_PHYSCS_PWRSAVE 0x0004
348 #define KSZ8864_PHYSCS_REMOTE_LOOPBACK 0x0002
349 
350 //Chip ID0 register
351 #define KSZ8864_CHIP_ID0_FAMILY_ID 0xFF
352 #define KSZ8864_CHIP_ID0_FAMILY_ID_DEFAULT 0x95
353 
354 //Chip ID1 / Start Switch register
355 #define KSZ8864_CHIP_ID1_REVISION_ID 0x0E
356 #define KSZ8864_CHIP_ID1_START_SWITCH 0x01
357 
358 //Global Control 0 register
359 #define KSZ8864_GLOBAL_CTRL0_NEW_BACK_OFF_EN 0x80
360 #define KSZ8864_GLOBAL_CTRL0_FLUSH_DYNAMIC_MAC_TABLE 0x20
361 #define KSZ8864_GLOBAL_CTRL0_FLUSH_STATIC_MAC_TABLE 0x10
362 #define KSZ8864_GLOBAL_CTRL0_UNH_MODE 0x02
363 #define KSZ8864_GLOBAL_CTRL0_LINK_CHANGE_AGE 0x01
364 
365 //Global Control 1 register
366 #define KSZ8864_GLOBAL_CTRL1_PASS_ALL_FRAMES 0x80
367 #define KSZ8864_GLOBAL_CTRL1_2KB_PKT_SUPPORT 0x40
368 #define KSZ8864_GLOBAL_CTRL1_TX_FLOW_CTRL_DIS 0x20
369 #define KSZ8864_GLOBAL_CTRL1_RX_FLOW_CTRL_DIS 0x10
370 #define KSZ8864_GLOBAL_CTRL1_FRAME_LEN_CHECK_EN 0x08
371 #define KSZ8864_GLOBAL_CTRL1_AGING_EN 0x04
372 #define KSZ8864_GLOBAL_CTRL1_FAST_AGE_EN 0x02
373 #define KSZ8864_GLOBAL_CTRL1_AGGRESSIVE_BACK_OFF_EN 0x01
374 
375 //Global Control 2 register
376 #define KSZ8864_GLOBAL_CTRL2_UNI_VLAN_MISMATCH_DISCARD 0x80
377 #define KSZ8864_GLOBAL_CTRL2_MCAST_STORM_PROTECT_DIS 0x40
378 #define KSZ8864_GLOBAL_CTRL2_BACK_PRESSURE_MODE 0x20
379 #define KSZ8864_GLOBAL_CTRL2_FLOW_CTRL_FAIR_MODE 0x10
380 #define KSZ8864_GLOBAL_CTRL2_NO_EXCESSIVE_COL_DROP 0x08
381 #define KSZ8864_GLOBAL_CTRL2_HUGE_PKT_SUPPORT 0x04
382 #define KSZ8864_GLOBAL_CTRL2_MAX_PKT_SIZE_CHECK_DIS 0x02
383 
384 //Global Control 3 register
385 #define KSZ8864_GLOBAL_CTRL3_VLAN_EN 0x80
386 #define KSZ8864_GLOBAL_CTRL3_SW4_IGMP_SNOOP_EN 0x40
387 #define KSZ8864_GLOBAL_CTRL3_SW4_DIRECT_MODE_EN 0x20
388 #define KSZ8864_GLOBAL_CTRL3_SW4_PRE_TAG_EN 0x10
389 #define KSZ8864_GLOBAL_CTRL3_TAG_MASK_EN 0x02
390 #define KSZ8864_GLOBAL_CTRL3_SNIFF_MODE_SEL 0x01
391 
392 //Global Control 4 register
393 #define KSZ8864_GLOBAL_CTRL4_SW4_BACK_PRESSURE_EN 0x80
394 #define KSZ8864_GLOBAL_CTRL4_SW4_HALF_DUPLEX_MODE 0x40
395 #define KSZ8864_GLOBAL_CTRL4_SW4_FLOW_CTRL_EN 0x20
396 #define KSZ8864_GLOBAL_CTRL4_SW4_SPEED 0x10
397 #define KSZ8864_GLOBAL_CTRL4_NULL_VID_REPLACEMENT 0x08
398 #define KSZ8864_GLOBAL_CTRL4_BCAST_STORM_PROTECT_RATE_MSB 0x07
399 
400 //Global Control 5 register
401 #define KSZ8864_GLOBAL_CTRL5_BCAST_STORM_PROTECT_RATE_LSB 0xFF
402 
403 //Global Control 6 register
404 #define KSZ8864_GLOBAL_CTRL6_FACTORY_TESTING 0xFF
405 
406 //Global Control 7 register
407 #define KSZ8864_GLOBAL_CTRL7_FACTORY_TESTING 0xFF
408 
409 //Global Control 8 register
410 #define KSZ8864_GLOBAL_CTRL8_FACTORY_TESTING 0xFF
411 
412 //Global Control 9 register
413 #define KSZ8864_GLOBAL_CTRL9_SW3_REFCLK_EDGE_SEL 0x80
414 #define KSZ8864_GLOBAL_CTRL9_SW3_REFCLK_EDGE_SEL_RISING 0x00
415 #define KSZ8864_GLOBAL_CTRL9_SW3_REFCLK_EDGE_SEL_FALLING 0x80
416 #define KSZ8864_GLOBAL_CTRL9_SW4_REFCLK_EDGE_SEL 0x40
417 #define KSZ8864_GLOBAL_CTRL9_SW4_REFCLK_EDGE_SEL_RISING 0x00
418 #define KSZ8864_GLOBAL_CTRL9_SW4_REFCLK_EDGE_SEL_FALLING 0x40
419 #define KSZ8864_GLOBAL_CTRL9_PHY_PWR_SAVE 0x08
420 #define KSZ8864_GLOBAL_CTRL9_LED_MODE 0x02
421 #define KSZ8864_GLOBAL_CTRL9_SPI_READ_CLK_EDGE_SEL 0x01
422 #define KSZ8864_GLOBAL_CTRL9_SPI_READ_CLK_EDGE_SEL_FALLING 0x00
423 #define KSZ8864_GLOBAL_CTRL9_SPI_READ_CLK_EDGE_SEL_RISING 0x01
424 
425 //Global Control 10 register
426 #define KSZ8864_GLOBAL_CTRL10_CLK_MODE 0x40
427 #define KSZ8864_GLOBAL_CTRL10_CPU_CLK_SEL 0x30
428 #define KSZ8864_GLOBAL_CTRL10_TAIL_TAG_EN 0x02
429 #define KSZ8864_GLOBAL_CTRL10_PASS_FLOW_CTRL_PKT 0x01
430 
431 //Global Control 11 register
432 #define KSZ8864_GLOBAL_CTRL11_FACTORY_TESTING 0xFF
433 
434 //Power-Down Management Control 1 register
435 #define KSZ8864_PD_MGMT_CTRL1_PLL_PWR_DOWN 0x20
436 #define KSZ8864_PD_MGMT_CTRL1_PWR_MGMT_MODE 0x18
437 #define KSZ8864_PD_MGMT_CTRL1_PWR_MGMT_MODE_NORMAL 0x00
438 #define KSZ8864_PD_MGMT_CTRL1_PWR_MGMT_MODE_ENERGY_DETECT 0x08
439 #define KSZ8864_PD_MGMT_CTRL1_PWR_MGMT_MODE_SOFT_PWR_DOWN 0x10
440 #define KSZ8864_PD_MGMT_CTRL1_PWR_MGMT_MODE_PWR_SAVING 0x18
441 
442 //Power-Down Management Control 2 register
443 #define KSZ8864_PD_MGMT_CTRL2_GO_SLEEP_TIME 0xFF
444 
445 //Port N Control 0 register
446 #define KSZ8864_PORTn_CTRL0_BCAST_STORM_PROTECT_EN 0x80
447 #define KSZ8864_PORTn_CTRL0_DIFFSERV_PRIO_CLASS_EN 0x40
448 #define KSZ8864_PORTn_CTRL0_802_1P_PRIO_CLASS_EN 0x20
449 #define KSZ8864_PORTn_CTRL0_PORT_PRIO_CLASS_EN 0x18
450 #define KSZ8864_PORTn_CTRL0_TAG_INSERTION 0x04
451 #define KSZ8864_PORTn_CTRL0_TAG_REMOVAL 0x02
452 #define KSZ8864_PORTn_CTRL0_TWO_QUEUE_SPLIT_EN 0x01
453 
454 //Port N Control 1 register
455 #define KSZ8864_PORTn_CTRL1_SNIFFER_PORT 0x80
456 #define KSZ8864_PORTn_CTRL1_RECEIVE_SNIFF 0x40
457 #define KSZ8864_PORTn_CTRL1_TRANSMIT_SNIFF 0x20
458 #define KSZ8864_PORTn_CTRL1_PORT_VLAN_MEMBERSHIP 0x1F
459 
460 //Port N Control 2 register
461 #define KSZ8864_PORTn_CTRL2_USER_PRIO_CEILING 0x80
462 #define KSZ8864_PORTn_CTRL2_INGRESS_VLAN_FILT 0x40
463 #define KSZ8864_PORTn_CTRL2_DISCARD_NON_PVID_PKT 0x20
464 #define KSZ8864_PORTn_CTRL2_FORCE_FLOW_CTRL 0x10
465 #define KSZ8864_PORTn_CTRL2_BACK_PRESSURE_EN 0x08
466 #define KSZ8864_PORTn_CTRL2_TRANSMIT_EN 0x04
467 #define KSZ8864_PORTn_CTRL2_RECEIVE_EN 0x02
468 #define KSZ8864_PORTn_CTRL2_LEARNING_DIS 0x01
469 
470 //Port N Control 3 register
471 #define KSZ8864_PORTn_CTRL3_DEFAULT_USER_PRIO 0xE0
472 #define KSZ8864_PORTn_CTRL3_DEFAULT_CFI 0x10
473 #define KSZ8864_PORTn_CTRL3_DEFAULT_VID_MSB 0x0F
474 
475 //Port N Control 4 register
476 #define KSZ8864_PORTn_CTRL4_DEFAULT_VID_LSB 0xFF
477 
478 //RMII Management Control register
479 #define KSZ8864_RMII_MGMT_CTRL_SW4_CLK_OUT_DIS 0x08
480 #define KSZ8864_RMII_MGMT_CTRL_SW3_CLK_OUT_DIS 0x04
481 
482 //Port N Status 0 register
483 #define KSZ8864_PORTn_STAT0_HP_MDIX 0x80
484 #define KSZ8864_PORTn_STAT0_POLRVS 0x20
485 #define KSZ8864_PORTn_STAT0_TX_FLOW_CTRL_EN 0x10
486 #define KSZ8864_PORTn_STAT0_RX_FLOW_CTRL_EN 0x08
487 #define KSZ8864_PORTn_STAT0_OP_SPEED 0x04
488 #define KSZ8864_PORTn_STAT0_OP_DUPLEX 0x02
489 
490 //Port N PHY Special Control/Status register
491 #define KSZ8864_PORTn_PSCS_VCT_10M_SHORT 0x80
492 #define KSZ8864_PORTn_PSCS_VCT_RESULT 0x60
493 #define KSZ8864_PORTn_PSCS_VCT_EN 0x10
494 #define KSZ8864_PORTn_PSCS_FORCE_LNK 0x08
495 #define KSZ8864_PORTn_PSCS_PWRSAVE 0x04
496 #define KSZ8864_PORTn_PSCS_REMOTE_LOOPBACK 0x02
497 #define KSZ8864_PORTn_PSCS_VCT_FAULT_COUNT_MSB 0x01
498 
499 //Port N LinkMD Result register
500 #define KSZ8864_PORTn_LINKMD_VCT_FAULT_COUNT_LSB 0xFF
501 
502 //Port N Control 5 register
503 #define KSZ8864_PORTn_CTRL5_AN_DIS 0x80
504 #define KSZ8864_PORTn_CTRL5_FORCED_SPEED 0x40
505 #define KSZ8864_PORTn_CTRL5_FORCED_DUPLEX 0x20
506 #define KSZ8864_PORTn_CTRL5_ADV_FLOW_CTRL 0x10
507 #define KSZ8864_PORTn_CTRL5_ADV_100BT_FD 0x08
508 #define KSZ8864_PORTn_CTRL5_ADV_100BT_HD 0x04
509 #define KSZ8864_PORTn_CTRL5_ADV_10BT_FD 0x02
510 #define KSZ8864_PORTn_CTRL5_ADV_10BT_HD 0x01
511 
512 //Port N Control 6 register
513 #define KSZ8864_PORTn_CTRL6_LED_OFF 0x80
514 #define KSZ8864_PORTn_CTRL6_TX_DIS 0x40
515 #define KSZ8864_PORTn_CTRL6_RESTART_AN 0x20
516 #define KSZ8864_PORTn_CTRL6_POWER_DOWN 0x08
517 #define KSZ8864_PORTn_CTRL6_AUTO_MDIX_DIS 0x04
518 #define KSZ8864_PORTn_CTRL6_FORCED_MDI 0x02
519 #define KSZ8864_PORTn_CTRL6_MAC_LOOPBACK 0x01
520 
521 //Port N Status 1 register
522 #define KSZ8864_PORTn_STAT1_MDIX_STATUS 0x80
523 #define KSZ8864_PORTn_STAT1_AN_DONE 0x40
524 #define KSZ8864_PORTn_STAT1_LINK_GOOD 0x20
525 #define KSZ8864_PORTn_STAT1_LP_FLOW_CTRL_CAPABLE 0x10
526 #define KSZ8864_PORTn_STAT1_LP_100BTX_FD_CAPABLE 0x08
527 #define KSZ8864_PORTn_STAT1_LP_100BTX_HF_CAPABLE 0x04
528 #define KSZ8864_PORTn_STAT1_LP_10BT_FD_CAPABLE 0x02
529 #define KSZ8864_PORTn_STAT1_LP_10BT_HD_CAPABLE 0x01
530 
531 //Port N Control 7 / Status 2 register
532 #define KSZ8864_PORTn_CTRL7_STAT2_PHY_LOOPBACK 0x80
533 #define KSZ8864_PORTn_CTRL7_STAT2_PHY_ISOLATE 0x20
534 #define KSZ8864_PORTn_CTRL7_STAT2_SOFT_RESET 0x10
535 #define KSZ8864_PORTn_CTRL7_STAT2_FORCE_LINK 0x08
536 #define KSZ8864_PORTn_CTRL7_STAT2_OP_MODE 0x07
537 #define KSZ8864_PORTn_CTRL7_STAT2_OP_MODE_AN 0x01
538 #define KSZ8864_PORTn_CTRL7_STAT2_OP_MODE_10BT_HD 0x02
539 #define KSZ8864_PORTn_CTRL7_STAT2_OP_MODE_100BTX_HD 0x03
540 #define KSZ8864_PORTn_CTRL7_STAT2_OP_MODE_10BT_FD 0x05
541 #define KSZ8864_PORTn_CTRL7_STAT2_OP_MODE_100BTX_FD 0x06
542 
543 //MAC Address 0 register
544 #define KSZ8864_MAC_ADDR0_MACA_47_40 0xFF
545 
546 //MAC Address 1 register
547 #define KSZ8864_MAC_ADDR1_MACA_39_32 0xFF
548 
549 //MAC Address 2 register
550 #define KSZ8864_MAC_ADDR2_MACA_31_24 0xFF
551 
552 //MAC Address 3 register
553 #define KSZ8864_MAC_ADDR3_MACA_23_16 0xFF
554 
555 //MAC Address 4 register
556 #define KSZ8864_MAC_ADDR4_MACA_15_8 0xFF
557 
558 //MAC Address 5 register
559 #define KSZ8864_MAC_ADDR5_MACA_7_0 0xFF
560 
561 //Indirect Access Control 0 register
562 #define KSZ8864_INDIRECT_CTRL0_WRITE 0x00
563 #define KSZ8864_INDIRECT_CTRL0_READ 0x10
564 #define KSZ8864_INDIRECT_CTRL0_TABLE_SEL 0x0C
565 #define KSZ8864_INDIRECT_CTRL0_TABLE_SEL_STATIC_MAC 0x00
566 #define KSZ8864_INDIRECT_CTRL0_TABLE_SEL_VLAN 0x04
567 #define KSZ8864_INDIRECT_CTRL0_TABLE_SEL_DYNAMIC_MAC 0x08
568 #define KSZ8864_INDIRECT_CTRL0_TABLE_SEL_MIB_COUNTER 0x0C
569 #define KSZ8864_INDIRECT_CTRL0_ADDR_H 0x03
570 
571 //Indirect Access Control 1 register
572 #define KSZ8864_INDIRECT_CTRL1_ADDR_L 0xFF
573 
574 //Interrupt Status register
575 #define KSZ8864_INT_STAT_PORT2 0x04
576 #define KSZ8864_INT_STAT_PORT1 0x02
577 
578 //Interrupt Mask register
579 #define KSZ8864_INT_MASK_PORT2 0x04
580 #define KSZ8864_INT_MASK_PORT1 0x02
581 
582 //Global Control 12 register
583 #define KSZ8864_GLOBAL_CTRL12_TAG3 0xC0
584 #define KSZ8864_GLOBAL_CTRL12_TAG2 0x30
585 #define KSZ8864_GLOBAL_CTRL12_TAG1 0x0C
586 #define KSZ8864_GLOBAL_CTRL12_TAG0 0x03
587 
588 //Global Control 13 register
589 #define KSZ8864_GLOBAL_CTRL13_TAG7 0xC0
590 #define KSZ8864_GLOBAL_CTRL13_TAG6 0x30
591 #define KSZ8864_GLOBAL_CTRL13_TAG5 0x0C
592 #define KSZ8864_GLOBAL_CTRL13_TAG4 0x03
593 
594 //Global Control 14 register
595 #define KSZ8864_GLOBAL_CTRL14_PRI_2Q 0xC0
596 
597 //Global Control 15 register
598 #define KSZ8864_GLOBAL_CTRL15_UNKNOWN_UNICAST_FWD 0x20
599 #define KSZ8864_GLOBAL_CTRL15_UNKNOWN_UNICAST_FWD_MAP 0x1F
600 #define KSZ8864_GLOBAL_CTRL15_UNKNOWN_UNICAST_FWD_MAP_FILT 0x00
601 #define KSZ8864_GLOBAL_CTRL15_UNKNOWN_UNICAST_FWD_MAP_PORT1 0x02
602 #define KSZ8864_GLOBAL_CTRL15_UNKNOWN_UNICAST_FWD_MAP_PORT2 0x04
603 #define KSZ8864_GLOBAL_CTRL15_UNKNOWN_UNICAST_FWD_MAP_PORT3 0x08
604 #define KSZ8864_GLOBAL_CTRL15_UNKNOWN_UNICAST_FWD_MAP_PORT4 0x10
605 #define KSZ8864_GLOBAL_CTRL15_UNKNOWN_UNICAST_FWD_MAP_ALL 0x1E
606 
607 //Global Control 16 register
608 #define KSZ8864_GLOBAL_CTRL16_CHIP_OUT_DRIVE_STRENGTH 0xC0
609 #define KSZ8864_GLOBAL_CTRL16_CHIP_OUT_DRIVE_STRENGTH_4MA 0x00
610 #define KSZ8864_GLOBAL_CTRL16_CHIP_OUT_DRIVE_STRENGTH_8MA 0x40
611 #define KSZ8864_GLOBAL_CTRL16_CHIP_OUT_DRIVE_STRENGTH_10MA 0x80
612 #define KSZ8864_GLOBAL_CTRL16_CHIP_OUT_DRIVE_STRENGTH_14MA 0xC0
613 #define KSZ8864_GLOBAL_CTRL16_UNKNOWN_MCAST_FWD 0x20
614 #define KSZ8864_GLOBAL_CTRL16_UNKNOWN_MCAST_FWD_MAP 0x1F
615 #define KSZ8864_GLOBAL_CTRL16_UNKNOWN_MCAST_FWD_MAP_FILT 0x00
616 #define KSZ8864_GLOBAL_CTRL16_UNKNOWN_MCAST_FWD_MAP_PORT1 0x02
617 #define KSZ8864_GLOBAL_CTRL16_UNKNOWN_MCAST_FWD_MAP_PORT2 0x04
618 #define KSZ8864_GLOBAL_CTRL16_UNKNOWN_MCAST_FWD_MAP_PORT3 0x08
619 #define KSZ8864_GLOBAL_CTRL16_UNKNOWN_MCAST_FWD_MAP_PORT4 0x10
620 #define KSZ8864_GLOBAL_CTRL16_UNKNOWN_MCAST_FWD_MAP_ALL 0x1E
621 
622 //Global Control 17 register
623 #define KSZ8864_GLOBAL_CTRL17_UNKNOWN_VID_FWD 0x20
624 #define KSZ8864_GLOBAL_CTRL17_UNKNOWN_VID_FWD_MAP 0x1F
625 #define KSZ8864_GLOBAL_CTRL17_UNKNOWN_VID_FWD_MAP_FILT 0x00
626 #define KSZ8864_GLOBAL_CTRL17_UNKNOWN_VID_FWD_MAP_PORT1 0x02
627 #define KSZ8864_GLOBAL_CTRL17_UNKNOWN_VID_FWD_MAP_PORT2 0x04
628 #define KSZ8864_GLOBAL_CTRL17_UNKNOWN_VID_FWD_MAP_PORT3 0x08
629 #define KSZ8864_GLOBAL_CTRL17_UNKNOWN_VID_FWD_MAP_PORT4 0x10
630 #define KSZ8864_GLOBAL_CTRL17_UNKNOWN_VID_FWD_MAP_ALL 0x1E
631 
632 //Global Control 18 register
633 #define KSZ8864_GLOBAL_CTRL18_SELF_ADDR_FILTER_EN 0x40
634 #define KSZ8864_GLOBAL_CTRL18_UNKNOWN_IP_MCAST_FWD 0x20
635 #define KSZ8864_GLOBAL_CTRL18_UNKNOWN_IP_MCAST_FWD_MAP 0x1F
636 #define KSZ8864_GLOBAL_CTRL18_UNKNOWN_IP_MCAST_FWD_MAP_FILT 0x00
637 #define KSZ8864_GLOBAL_CTRL18_UNKNOWN_IP_MCAST_FWD_MAP_PORT1 0x02
638 #define KSZ8864_GLOBAL_CTRL18_UNKNOWN_IP_MCAST_FWD_MAP_PORT2 0x04
639 #define KSZ8864_GLOBAL_CTRL18_UNKNOWN_IP_MCAST_FWD_MAP_PORT3 0x08
640 #define KSZ8864_GLOBAL_CTRL18_UNKNOWN_IP_MCAST_FWD_MAP_PORT4 0x10
641 #define KSZ8864_GLOBAL_CTRL18_UNKNOWN_IP_MCAST_FWD_MAP_ALL 0x1E
642 
643 //Global Control 19 register
644 #define KSZ8864_GLOBAL_CTRL19_IG_RATE_LIMIT_PERIOD 0x30
645 #define KSZ8864_GLOBAL_CTRL19_IG_RATE_LIMIT_PERIOD_16MS 0x00
646 #define KSZ8864_GLOBAL_CTRL19_IG_RATE_LIMIT_PERIOD_64MS 0x10
647 #define KSZ8864_GLOBAL_CTRL19_IG_RATE_LIMIT_PERIOD_256MS 0x20
648 #define KSZ8864_GLOBAL_CTRL19_QUEUE_BASED_EG_RATE_LIMITE_EN 0x08
649 #define KSZ8864_GLOBAL_CTRL19_INSERT_SRC_PORT_PVID_TAG_EN 0x04
650 
651 //Identification register
652 #define KSZ8864_ID_REVISION_ID 0xF0
653 #define KSZ8864_ID_REVISION_ID_CNX_REV_A2 0x40
654 #define KSZ8864_ID_REVISION_ID_RMNUB_REV_B2 0x40
655 #define KSZ8864_ID_REVISION_ID_CNX_REV_A3 0x50
656 #define KSZ8864_ID_REVISION_ID_CNX_REV_A4 0x60
657 
658 //TOS Priority Control 0 register
659 #define KSZ8864_TOS_PRIO_CTRL0_DSCP_7_6 0xC0
660 #define KSZ8864_TOS_PRIO_CTRL0_DSCP_5_4 0x30
661 #define KSZ8864_TOS_PRIO_CTRL0_DSCP_3_2 0x0C
662 #define KSZ8864_TOS_PRIO_CTRL0_DSCP_1_0 0x03
663 
664 //TOS Priority Control 1 register
665 #define KSZ8864_TOS_PRIO_CTRL1_DSCP_15_14 0xC0
666 #define KSZ8864_TOS_PRIO_CTRL1_DSCP_13_12 0x30
667 #define KSZ8864_TOS_PRIO_CTRL1_DSCP_11_10 0x0C
668 #define KSZ8864_TOS_PRIO_CTRL1_DSCP_9_8 0x03
669 
670 //TOS Priority Control 2 register
671 #define KSZ8864_TOS_PRIO_CTRL2_DSCP_23_22 0xC0
672 #define KSZ8864_TOS_PRIO_CTRL2_DSCP_21_20 0x30
673 #define KSZ8864_TOS_PRIO_CTRL2_DSCP_19_18 0x0C
674 #define KSZ8864_TOS_PRIO_CTRL2_DSCP_17_16 0x03
675 
676 //TOS Priority Control 3 register
677 #define KSZ8864_TOS_PRIO_CTRL3_DSCP_31_30 0xC0
678 #define KSZ8864_TOS_PRIO_CTRL3_DSCP_29_28 0x30
679 #define KSZ8864_TOS_PRIO_CTRL3_DSCP_27_26 0x0C
680 #define KSZ8864_TOS_PRIO_CTRL3_DSCP_25_24 0x03
681 
682 //TOS Priority Control 4 register
683 #define KSZ8864_TOS_PRIO_CTRL4_DSCP_39_38 0xC0
684 #define KSZ8864_TOS_PRIO_CTRL4_DSCP_37_36 0x30
685 #define KSZ8864_TOS_PRIO_CTRL4_DSCP_35_34 0x0C
686 #define KSZ8864_TOS_PRIO_CTRL4_DSCP_33_32 0x03
687 
688 //TOS Priority Control 5 register
689 #define KSZ8864_TOS_PRIO_CTRL5_DSCP_47_46 0xC0
690 #define KSZ8864_TOS_PRIO_CTRL5_DSCP_45_44 0x30
691 #define KSZ8864_TOS_PRIO_CTRL5_DSCP_43_42 0x0C
692 #define KSZ8864_TOS_PRIO_CTRL5_DSCP_41_40 0x03
693 
694 //TOS Priority Control 6 register
695 #define KSZ8864_TOS_PRIO_CTRL6_DSCP_55_54 0xC0
696 #define KSZ8864_TOS_PRIO_CTRL6_DSCP_53_52 0x30
697 #define KSZ8864_TOS_PRIO_CTRL6_DSCP_51_50 0x0C
698 #define KSZ8864_TOS_PRIO_CTRL6_DSCP_49_48 0x03
699 
700 //TOS Priority Control 7 register
701 #define KSZ8864_TOS_PRIO_CTRL7_DSCP_63_62 0xC0
702 #define KSZ8864_TOS_PRIO_CTRL7_DSCP_61_60 0x30
703 #define KSZ8864_TOS_PRIO_CTRL7_DSCP_59_58 0x0C
704 #define KSZ8864_TOS_PRIO_CTRL7_DSCP_57_56 0x03
705 
706 //TOS Priority Control 8 register
707 #define KSZ8864_TOS_PRIO_CTRL8_DSCP_71_70 0xC0
708 #define KSZ8864_TOS_PRIO_CTRL8_DSCP_69_68 0x30
709 #define KSZ8864_TOS_PRIO_CTRL8_DSCP_67_66 0x0C
710 #define KSZ8864_TOS_PRIO_CTRL8_DSCP_65_64 0x03
711 
712 //TOS Priority Control 9 register
713 #define KSZ8864_TOS_PRIO_CTRL9_DSCP_79_78 0xC0
714 #define KSZ8864_TOS_PRIO_CTRL9_DSCP_77_76 0x30
715 #define KSZ8864_TOS_PRIO_CTRL9_DSCP_75_74 0x0C
716 #define KSZ8864_TOS_PRIO_CTRL9_DSCP_73_72 0x03
717 
718 //TOS Priority Control 10 register
719 #define KSZ8864_TOS_PRIO_CTRL10_DSCP_87_86 0xC0
720 #define KSZ8864_TOS_PRIO_CTRL10_DSCP_85_84 0x30
721 #define KSZ8864_TOS_PRIO_CTRL10_DSCP_83_82 0x0C
722 #define KSZ8864_TOS_PRIO_CTRL10_DSCP_81_80 0x03
723 
724 //TOS Priority Control 11 register
725 #define KSZ8864_TOS_PRIO_CTRL11_DSCP_95_94 0xC0
726 #define KSZ8864_TOS_PRIO_CTRL11_DSCP_93_92 0x30
727 #define KSZ8864_TOS_PRIO_CTRL11_DSCP_91_90 0x0C
728 #define KSZ8864_TOS_PRIO_CTRL11_DSCP_89_88 0x03
729 
730 //TOS Priority Control 12 register
731 #define KSZ8864_TOS_PRIO_CTRL12_DSCP_103_102 0xC0
732 #define KSZ8864_TOS_PRIO_CTRL12_DSCP_101_100 0x30
733 #define KSZ8864_TOS_PRIO_CTRL12_DSCP_99_98 0x0C
734 #define KSZ8864_TOS_PRIO_CTRL12_DSCP_97_96 0x03
735 
736 //TOS Priority Control 13 register
737 #define KSZ8864_TOS_PRIO_CTRL13_DSCP_111_110 0xC0
738 #define KSZ8864_TOS_PRIO_CTRL13_DSCP_109_108 0x30
739 #define KSZ8864_TOS_PRIO_CTRL13_DSCP_107_106 0x0C
740 #define KSZ8864_TOS_PRIO_CTRL13_DSCP_105_104 0x03
741 
742 //TOS Priority Control 14 register
743 #define KSZ8864_TOS_PRIO_CTRL14_DSCP_119_118 0xC0
744 #define KSZ8864_TOS_PRIO_CTRL14_DSCP_117_116 0x30
745 #define KSZ8864_TOS_PRIO_CTRL14_DSCP_115_114 0x0C
746 #define KSZ8864_TOS_PRIO_CTRL14_DSCP_113_112 0x03
747 
748 //TOS Priority Control 15 register
749 #define KSZ8864_TOS_PRIO_CTRL15_DSCP_127_126 0xC0
750 #define KSZ8864_TOS_PRIO_CTRL15_DSCP_125_124 0x30
751 #define KSZ8864_TOS_PRIO_CTRL15_DSCP_123_122 0x0C
752 #define KSZ8864_TOS_PRIO_CTRL15_DSCP_121_120 0x03
753 
754 //Port N Control 9 register
755 #define KSZ8864_PORTn_CTRL9_FOUR_QUEUE_SPLIT_EN 0x02
756 #define KSZ8864_PORTn_CTRL9_DROPPING_TAG_EN 0x01
757 
758 //Port N Control 10 register
759 #define KSZ8864_PORTn_CTRL10_PORT_TX_QUEUE3_RATIO_EN 0x80
760 #define KSZ8864_PORTn_CTRL10_PORT_TX_QUEUE3_RATIO 0x7F
761 
762 //Port N Control 11 register
763 #define KSZ8864_PORTn_CTRL11_PORT_TX_QUEUE2_RATIO_EN 0x80
764 #define KSZ8864_PORTn_CTRL11_PORT_TX_QUEUE2_RATIO 0x7F
765 
766 //Port N Control 12 register
767 #define KSZ8864_PORTn_CTRL12_PORT_TX_QUEUE1_RATIO_EN 0x80
768 #define KSZ8864_PORTn_CTRL12_PORT_TX_QUEUE1_RATIO 0x7F
769 
770 //Port N Control 13 register
771 #define KSZ8864_PORTn_CTRL13_PORT_TX_QUEUE0_RATIO_EN 0x80
772 #define KSZ8864_PORTn_CTRL13_PORT_TX_QUEUE0_RATIO 0x7F
773 
774 //Port N Rate Limit Control register
775 #define KSZ8864_PORTn_RATE_LIMIT_CTRL_LIMIT_EN 0x10
776 #define KSZ8864_PORTn_RATE_LIMIT_CTRL_LIMIT_MODE 0x0C
777 #define KSZ8864_PORTn_RATE_LIMIT_CTRL_COUNT_IFG 0x02
778 #define KSZ8864_PORTn_RATE_LIMIT_CTRL_COUNT_PRE 0x01
779 
780 //Testing and port 3 Control 1 register
781 #define KSZ8864_TEST_PORT3_CTRL1_SW3_HALF_DUPLEX_MODE 0x80
782 #define KSZ8864_TEST_PORT3_CTRL1_SW3_FLOW_CONTROL_EN 0x40
783 #define KSZ8864_TEST_PORT3_CTRL1_SW3_SPEED 0x20
784 #define KSZ8864_TEST_PORT3_CTRL1_SW3_SPEED_100 0x00
785 #define KSZ8864_TEST_PORT3_CTRL1_SW3_SPEED_10 0x20
786 
787 //Testing and port 3 Control 2 register
788 #define KSZ8864_TEST_PORT3_CTRL2_SW3_MII_IF_MODE 0x40
789 #define KSZ8864_TEST_PORT3_CTRL2_SW3_MII_IF_MODE_PHY 0x00
790 #define KSZ8864_TEST_PORT3_CTRL2_SW3_MII_IF_MODE_MAC 0x40
791 
792 //Test 4 register
793 #define KSZ8864_TEST4_SW4_RMII_INV_SMTXC 0x40
794 #define KSZ8864_TEST4_SW4_RMII_INV_SMRXC 0x10
795 
796 //C++ guard
797 #ifdef __cplusplus
798 extern "C" {
799 #endif
800 
801 //CC-RX, CodeWarrior or Win32 compiler?
802 #if defined(__CCRX__)
803  #pragma pack
804 #elif defined(__CWCC__) || defined(_WIN32)
805  #pragma pack(push, 1)
806 #endif
807 
808 
809 /**
810  * @brief Static MAC table entry (read operation)
811  **/
812 
813 typedef struct
814 {
815 #if defined(_CPU_BIG_ENDIAN) && !defined(__ICCRX__)
816  uint8_t fid : 7; //0
817  uint8_t useFid : 1;
818  uint8_t reserved1 : 1; //1
819  uint8_t override : 1;
820  uint8_t valid : 1;
821  uint8_t forwardPorts : 4;
822  uint8_t reserved2 : 1;
823 #else
824  uint8_t useFid : 1; //0
825  uint8_t fid : 7;
826  uint8_t reserved2 : 1; //1
827  uint8_t forwardPorts : 4;
828  uint8_t valid : 1;
829  uint8_t override : 1;
830  uint8_t reserved1 : 1;
831 #endif
834 
835 
836 /**
837  * @brief Static MAC table entry (write operation)
838  **/
839 
840 typedef struct
841 {
842  uint8_t fid; //0
843 #if defined(_CPU_BIG_ENDIAN) && !defined(__ICCRX__)
844  uint8_t useFid : 1; //1
845  uint8_t override : 1;
846  uint8_t valid : 1;
847  uint8_t forwardPorts : 4;
848  uint8_t reserved : 1;
849 #else
850  uint8_t reserved : 1; //1
851  uint8_t forwardPorts : 4;
852  uint8_t valid : 1;
853  uint8_t override : 1;
854  uint8_t useFid : 1;
855 #endif
858 
859 
860 /**
861  * @brief Dynamic MAC table entry
862  **/
863 
864 typedef struct
865 {
866 #if defined(_CPU_BIG_ENDIAN) && !defined(__ICCRX__)
867  uint8_t macEmpty : 1; //0
868  uint8_t numValidEntriesH : 7;
869  uint8_t numValidEntriesL : 3; //1
870  uint8_t timestamp : 2;
871  uint8_t sourcePort : 3;
872  uint8_t dataNotReady : 1; //2
873  uint8_t fid : 7;
874 #else
875  uint8_t numValidEntriesH : 7; //0
876  uint8_t macEmpty : 1;
877  uint8_t sourcePort : 3; //1
878  uint8_t timestamp : 2;
879  uint8_t numValidEntriesL : 3;
880  uint8_t fid : 7; //2
881  uint8_t dataNotReady : 1;
882 #endif
885 
886 
887 //CC-RX, CodeWarrior or Win32 compiler?
888 #if defined(__CCRX__)
889  #pragma unpack
890 #elif defined(__CWCC__) || defined(_WIN32)
891  #pragma pack(pop)
892 #endif
893 
894 //KSZ8864 Ethernet switch driver
895 extern const SwitchDriver ksz8864SwitchDriver;
896 
897 //KSZ8864 related functions
898 error_t ksz8864Init(NetInterface *interface);
899 void ksz8864InitHook(NetInterface *interface);
900 
901 void ksz8864Tick(NetInterface *interface);
902 
903 void ksz8864EnableIrq(NetInterface *interface);
904 void ksz8864DisableIrq(NetInterface *interface);
905 
906 void ksz8864EventHandler(NetInterface *interface);
907 
908 error_t ksz8864TagFrame(NetInterface *interface, NetBuffer *buffer,
909  size_t *offset, NetTxAncillary *ancillary);
910 
911 error_t ksz8864UntagFrame(NetInterface *interface, uint8_t **frame,
912  size_t *length, NetRxAncillary *ancillary);
913 
914 bool_t ksz8864GetLinkState(NetInterface *interface, uint8_t port);
915 uint32_t ksz8864GetLinkSpeed(NetInterface *interface, uint8_t port);
917 
918 void ksz8864SetPortState(NetInterface *interface, uint8_t port,
919  SwitchPortState state);
920 
922 
923 void ksz8864SetAgingTime(NetInterface *interface, uint32_t agingTime);
924 
925 void ksz8864EnableIgmpSnooping(NetInterface *interface, bool_t enable);
926 void ksz8864EnableMldSnooping(NetInterface *interface, bool_t enable);
927 void ksz8864EnableRsvdMcastTable(NetInterface *interface, bool_t enable);
928 
930  const SwitchFdbEntry *entry);
931 
933  const SwitchFdbEntry *entry);
934 
936  SwitchFdbEntry *entry);
937 
939 
941  SwitchFdbEntry *entry);
942 
943 void ksz8864FlushDynamicFdbTable(NetInterface *interface, uint8_t port);
944 
946  bool_t enable, uint32_t forwardPorts);
947 
948 void ksz8864WritePhyReg(NetInterface *interface, uint8_t port,
949  uint8_t address, uint16_t data);
950 
951 uint16_t ksz8864ReadPhyReg(NetInterface *interface, uint8_t port,
952  uint8_t address);
953 
954 void ksz8864DumpPhyReg(NetInterface *interface, uint8_t port);
955 
956 void ksz8864WriteSwitchReg(NetInterface *interface, uint8_t address,
957  uint8_t data);
958 
959 uint8_t ksz8864ReadSwitchReg(NetInterface *interface, uint8_t address);
960 
961 void ksz8864DumpSwitchReg(NetInterface *interface);
962 
963 //C++ guard
964 #ifdef __cplusplus
965 }
966 #endif
967 
968 #endif
void ksz8864SetAgingTime(NetInterface *interface, uint32_t agingTime)
Set aging time for dynamic filtering entries.
int bool_t
Definition: compiler_port.h:63
void ksz8864EnableIrq(NetInterface *interface)
Enable interrupts.
uint8_t ksz8864ReadSwitchReg(NetInterface *interface, uint8_t address)
Read switch register.
Structure describing a buffer that spans multiple chunks.
Definition: net_mem.h:89
void ksz8864EnableMldSnooping(NetInterface *interface, bool_t enable)
Enable MLD snooping.
uint8_t macEmpty
uint8_t data[]
Definition: ethernet.h:224
uint8_t dataNotReady
void ksz8864Tick(NetInterface *interface)
KSZ8864 timer handler.
void ksz8864EventHandler(NetInterface *interface)
KSZ8864 event handler.
uint8_t useFid
error_t ksz8864GetStaticFdbEntry(NetInterface *interface, uint_t index, SwitchFdbEntry *entry)
Read an entry from the static MAC table.
uint8_t forwardPorts
void ksz8864DisableIrq(NetInterface *interface)
Disable interrupts.
uint8_t reserved
Definition: igmp_common.h:250
uint8_t override
uint8_t useFid
const SwitchDriver ksz8864SwitchDriver
KSZ8864 Ethernet switch driver.
error_t
Error codes.
Definition: error.h:43
uint16_t ksz8864ReadPhyReg(NetInterface *interface, uint8_t port, uint8_t address)
Read PHY register.
Static MAC table entry (read operation)
uint8_t sourcePort
void ksz8864SetUnknownMcastFwdPorts(NetInterface *interface, bool_t enable, uint32_t forwardPorts)
Set forward ports for unknown multicast packets.
MacAddr macAddr
NicDuplexMode ksz8864GetDuplexMode(NetInterface *interface, uint8_t port)
Get duplex mode.
uint8_t reserved1
Definition: tcp.h:356
#define NetRxAncillary
Definition: net_misc.h:40
Static MAC table entry (write operation)
#define NetInterface
Definition: net.h:40
error_t ksz8864GetDynamicFdbEntry(NetInterface *interface, uint_t index, SwitchFdbEntry *entry)
Read an entry from the dynamic MAC table.
#define NetTxAncillary
Definition: net_misc.h:36
SwitchPortState
Switch port state.
Definition: nic.h:134
uint8_t fid
uint8_t length
Definition: tcp.h:375
uint8_t forwardPorts
bool_t ksz8864GetLinkState(NetInterface *interface, uint8_t port)
Get link state.
SwitchPortState ksz8864GetPortState(NetInterface *interface, uint8_t port)
Get port state.
MacAddr macAddr
uint8_t fid
uint8_t timestamp
uint8_t valid
error_t ksz8864TagFrame(NetInterface *interface, NetBuffer *buffer, size_t *offset, NetTxAncillary *ancillary)
Add tail tag to Ethernet frame.
MacAddr
Definition: ethernet.h:197
error_t ksz8864AddStaticFdbEntry(NetInterface *interface, const SwitchFdbEntry *entry)
Add a new entry to the static MAC table.
uint16_t port
Definition: dns_common.h:270
void ksz8864EnableRsvdMcastTable(NetInterface *interface, bool_t enable)
Enable reserved multicast table.
error_t ksz8864UntagFrame(NetInterface *interface, uint8_t **frame, size_t *length, NetRxAncillary *ancillary)
Decode tail tag from incoming Ethernet frame.
uint8_t reserved2
Definition: tcp.h:359
MacAddr macAddr
uint8_t reserved1
error_t ksz8864DeleteStaticFdbEntry(NetInterface *interface, const SwitchFdbEntry *entry)
Remove an entry from the static MAC table.
uint8_t numValidEntriesL
Ethernet switch driver.
Definition: nic.h:325
Dynamic MAC table entry.
Ipv6Addr address[]
Definition: ipv6.h:345
NicDuplexMode
Duplex mode.
Definition: nic.h:122
Network interface controller abstraction layer.
void ksz8864InitHook(NetInterface *interface)
KSZ8864 custom configuration.
void ksz8864WriteSwitchReg(NetInterface *interface, uint8_t address, uint8_t data)
Write switch register.
void ksz8864DumpPhyReg(NetInterface *interface, uint8_t port)
Dump PHY registers for debugging purpose.
uint32_t ksz8864GetLinkSpeed(NetInterface *interface, uint8_t port)
Get link speed.
uint8_t fid
uint8_t numValidEntriesH
unsigned int uint_t
Definition: compiler_port.h:57
void ksz8864FlushStaticFdbTable(NetInterface *interface)
Flush static MAC table.
uint8_t valid
void ksz8864WritePhyReg(NetInterface *interface, uint8_t port, uint8_t address, uint16_t data)
Write PHY register.
void ksz8864EnableIgmpSnooping(NetInterface *interface, bool_t enable)
Enable IGMP snooping.
void ksz8864FlushDynamicFdbTable(NetInterface *interface, uint8_t port)
Flush dynamic MAC table.
error_t ksz8864Init(NetInterface *interface)
KSZ8864 Ethernet switch initialization.
Forwarding database entry.
Definition: nic.h:149
void ksz8864DumpSwitchReg(NetInterface *interface)
Dump switch registers for debugging purpose.
uint8_t reserved
void ksz8864SetPortState(NetInterface *interface, uint8_t port, SwitchPortState state)
Set port state.
uint8_t reserved2
uint8_t override