mikroSDK Reference Manual
ksz8795_driver.h
Go to the documentation of this file.
1
31#ifndef _KSZ8795_DRIVER_H
32#define _KSZ8795_DRIVER_H
33
34//Dependencies
35#include "core/nic.h"
36
37//Port identifiers
38#define KSZ8795_PORT1 1
39#define KSZ8795_PORT2 2
40#define KSZ8795_PORT3 3
41#define KSZ8795_PORT4 4
42#define KSZ8795_PORT5 5
43
44//Port masks
45#define KSZ8795_PORT_MASK 0x1F
46#define KSZ8795_PORT1_MASK 0x01
47#define KSZ8795_PORT2_MASK 0x02
48#define KSZ8795_PORT3_MASK 0x04
49#define KSZ8795_PORT4_MASK 0x08
50#define KSZ8795_PORT5_MASK 0x10
51
52//SPI command byte
53#define KSZ8795_SPI_CMD_WRITE 0x4000
54#define KSZ8795_SPI_CMD_READ 0x6000
55#define KSZ8795_SPI_CMD_ADDR 0x1FFE
56
57//Size of static and dynamic MAC tables
58#define KSZ8795_STATIC_MAC_TABLE_SIZE 32
59#define KSZ8795_DYNAMIC_MAC_TABLE_SIZE 1024
60
61//Tail tag rules (host to KSZ8795)
62#define KSZ8795_TAIL_TAG_NORMAL_ADDR_LOOKUP 0x80
63#define KSZ8795_TAIL_TAG_PORT_SEL 0x40
64#define KSZ8795_TAIL_TAG_DEST_QUEUE 0x30
65#define KSZ8795_TAIL_TAG_DEST_PORT4 0x08
66#define KSZ8795_TAIL_TAG_DEST_PORT3 0x04
67#define KSZ8795_TAIL_TAG_DEST_PORT2 0x02
68#define KSZ8795_TAIL_TAG_DEST_PORT1 0x01
69
70//Tail tag rules (KSZ8795 to host)
71#define KSZ8795_TAIL_TAG_SRC_PORT 0x03
72
73//KSZ8795 PHY registers
74#define KSZ8795_BMCR 0x00
75#define KSZ8795_BMSR 0x01
76#define KSZ8795_PHYID1 0x02
77#define KSZ8795_PHYID2 0x03
78#define KSZ8795_ANAR 0x04
79#define KSZ8795_ANLPAR 0x05
80#define KSZ8795_LINKMD 0x1D
81#define KSZ8795_PHYSCS 0x1F
82
83//KSZ8795 Switch registers
84#define KSZ8795_CHIP_ID0 0x00
85#define KSZ8795_CHIP_ID1 0x01
86#define KSZ8795_GLOBAL_CTRL0 0x02
87#define KSZ8795_GLOBAL_CTRL1 0x03
88#define KSZ8795_GLOBAL_CTRL2 0x04
89#define KSZ8795_GLOBAL_CTRL3 0x05
90#define KSZ8795_GLOBAL_CTRL4 0x06
91#define KSZ8795_GLOBAL_CTRL5 0x07
92#define KSZ8795_GLOBAL_CTRL6_MIB_CTRL 0x08
93#define KSZ8795_GLOBAL_CTRL7 0x09
94#define KSZ8795_GLOBAL_CTRL8 0x0A
95#define KSZ8795_GLOBAL_CTRL9 0x0B
96#define KSZ8795_GLOBAL_CTRL10 0x0C
97#define KSZ8795_GLOBAL_CTRL11 0x0D
98#define KSZ8795_PD_MGMT_CTRL1 0x0E
99#define KSZ8795_PD_MGMT_CTRL2 0x0F
100#define KSZ8795_PORT1_CTRL0 0x10
101#define KSZ8795_PORT1_CTRL1 0x11
102#define KSZ8795_PORT1_CTRL2 0x12
103#define KSZ8795_PORT1_CTRL3 0x13
104#define KSZ8795_PORT1_CTRL4 0x14
105#define KSZ8795_PORT1_CTRL5 0x15
106#define KSZ8795_PORT1_CTRL7 0x17
107#define KSZ8795_PORT1_STAT0 0x18
108#define KSZ8795_PORT1_STAT1 0x19
109#define KSZ8795_PORT1_PHY_CTRL8 0x1A
110#define KSZ8795_PORT1_LINKMD 0x1B
111#define KSZ8795_PORT1_CTRL9 0x1C
112#define KSZ8795_PORT1_CTRL10 0x1D
113#define KSZ8795_PORT1_STAT2 0x1E
114#define KSZ8795_PORT1_CTRL11_STAT3 0x1F
115#define KSZ8795_PORT2_CTRL0 0x20
116#define KSZ8795_PORT2_CTRL1 0x21
117#define KSZ8795_PORT2_CTRL2 0x22
118#define KSZ8795_PORT2_CTRL3 0x23
119#define KSZ8795_PORT2_CTRL4 0x24
120#define KSZ8795_PORT2_CTRL5 0x25
121#define KSZ8795_PORT2_CTRL7 0x27
122#define KSZ8795_PORT2_STAT0 0x28
123#define KSZ8795_PORT2_STAT1 0x29
124#define KSZ8795_PORT2_PHY_CTRL8 0x2A
125#define KSZ8795_PORT2_LINKMD 0x2B
126#define KSZ8795_PORT2_CTRL9 0x2C
127#define KSZ8795_PORT2_CTRL10 0x2D
128#define KSZ8795_PORT2_STAT2 0x2E
129#define KSZ8795_PORT2_CTRL11_STAT3 0x2F
130#define KSZ8795_PORT3_CTRL0 0x30
131#define KSZ8795_PORT3_CTRL1 0x31
132#define KSZ8795_PORT3_CTRL2 0x32
133#define KSZ8795_PORT3_CTRL3 0x33
134#define KSZ8795_PORT3_CTRL4 0x34
135#define KSZ8795_PORT3_CTRL5 0x35
136#define KSZ8795_PORT3_CTRL7 0x37
137#define KSZ8795_PORT3_STAT0 0x38
138#define KSZ8795_PORT3_STAT1 0x39
139#define KSZ8795_PORT3_PHY_CTRL8 0x3A
140#define KSZ8795_PORT3_LINKMD 0x3B
141#define KSZ8795_PORT3_CTRL9 0x3C
142#define KSZ8795_PORT3_CTRL10 0x3D
143#define KSZ8795_PORT3_STAT2 0x3E
144#define KSZ8795_PORT3_CTRL11_STAT3 0x3F
145#define KSZ8795_PORT4_CTRL0 0x40
146#define KSZ8795_PORT4_CTRL1 0x41
147#define KSZ8795_PORT4_CTRL2 0x42
148#define KSZ8795_PORT4_CTRL3 0x43
149#define KSZ8795_PORT4_CTRL4 0x44
150#define KSZ8795_PORT4_CTRL5 0x45
151#define KSZ8795_PORT4_CTRL7 0x47
152#define KSZ8795_PORT4_STAT0 0x48
153#define KSZ8795_PORT4_STAT1 0x49
154#define KSZ8795_PORT4_PHY_CTRL8 0x4A
155#define KSZ8795_PORT4_LINKMD 0x4B
156#define KSZ8795_PORT4_CTRL9 0x4C
157#define KSZ8795_PORT4_CTRL10 0x4D
158#define KSZ8795_PORT4_STAT2 0x4E
159#define KSZ8795_PORT4_CTRL11_STAT3 0x4F
160#define KSZ8795_PORT5_CTRL0 0x50
161#define KSZ8795_PORT5_CTRL1 0x51
162#define KSZ8795_PORT5_CTRL2 0x52
163#define KSZ8795_PORT5_CTRL3 0x53
164#define KSZ8795_PORT5_CTRL4 0x54
165#define KSZ8795_PORT5_CTRL5 0x55
166#define KSZ8795_PORT5_IF_CTRL6 0x56
167#define KSZ8795_MAC_ADDR0 0x68
168#define KSZ8795_MAC_ADDR1 0x69
169#define KSZ8795_MAC_ADDR2 0x6A
170#define KSZ8795_MAC_ADDR3 0x6B
171#define KSZ8795_MAC_ADDR4 0x6C
172#define KSZ8795_MAC_ADDR5 0x6D
173#define KSZ8795_INDIRECT_CTRL0 0x6E
174#define KSZ8795_INDIRECT_CTRL1 0x6F
175#define KSZ8795_INDIRECT_DATA8 0x70
176#define KSZ8795_INDIRECT_DATA7 0x71
177#define KSZ8795_INDIRECT_DATA6 0x72
178#define KSZ8795_INDIRECT_DATA5 0x73
179#define KSZ8795_INDIRECT_DATA4 0x74
180#define KSZ8795_INDIRECT_DATA3 0x75
181#define KSZ8795_INDIRECT_DATA2 0x76
182#define KSZ8795_INDIRECT_DATA1 0x77
183#define KSZ8795_INDIRECT_DATA0 0x78
184#define KSZ8795_INT_STAT 0x7C
185#define KSZ8795_INT_MASK 0x7D
186#define KSZ8795_ACL_INT_STAT 0x7E
187#define KSZ8795_ACL_INT_CTRL 0x7F
188#define KSZ8795_GLOBAL_CTRL12 0x80
189#define KSZ8795_GLOBAL_CTRL13 0x81
190#define KSZ8795_GLOBAL_CTRL14 0x82
191#define KSZ8795_GLOBAL_CTRL15 0x83
192#define KSZ8795_GLOBAL_CTRL16 0x84
193#define KSZ8795_GLOBAL_CTRL17 0x85
194#define KSZ8795_GLOBAL_CTRL18 0x86
195#define KSZ8795_GLOBAL_CTRL19 0x87
196#define KSZ8795_TOS_PRIO_CTRL0 0x90
197#define KSZ8795_TOS_PRIO_CTRL1 0x91
198#define KSZ8795_TOS_PRIO_CTRL2 0x92
199#define KSZ8795_TOS_PRIO_CTRL3 0x93
200#define KSZ8795_TOS_PRIO_CTRL4 0x94
201#define KSZ8795_TOS_PRIO_CTRL5 0x95
202#define KSZ8795_TOS_PRIO_CTRL6 0x96
203#define KSZ8795_TOS_PRIO_CTRL7 0x97
204#define KSZ8795_TOS_PRIO_CTRL8 0x98
205#define KSZ8795_TOS_PRIO_CTRL9 0x99
206#define KSZ8795_TOS_PRIO_CTRL10 0x9A
207#define KSZ8795_TOS_PRIO_CTRL11 0x9B
208#define KSZ8795_TOS_PRIO_CTRL12 0x9C
209#define KSZ8795_TOS_PRIO_CTRL13 0x9D
210#define KSZ8795_TOS_PRIO_CTRL14 0x9E
211#define KSZ8795_TOS_PRIO_CTRL15 0x9F
212#define KSZ8795_INDIRECT_BYTE 0xA0
213#define KSZ8795_GLOBAL_CTRL20 0xA3
214#define KSZ8795_GLOBAL_CTRL21 0xA4
215#define KSZ8795_PORT1_CTRL12 0xB0
216#define KSZ8795_PORT1_CTRL13 0xB1
217#define KSZ8795_PORT1_CTRL14 0xB2
218#define KSZ8795_PORT1_CTRL15 0xB3
219#define KSZ8795_PORT1_CTRL16 0xB4
220#define KSZ8795_PORT1_CTRL17 0xB5
221#define KSZ8795_PORT1_RATE_LIMIT_CTRL 0xB6
222#define KSZ8795_PORT1_PRIO0_IG_LIMIT_CTRL1 0xB7
223#define KSZ8795_PORT1_PRIO1_IG_LIMIT_CTRL2 0xB8
224#define KSZ8795_PORT1_PRIO2_IG_LIMIT_CTRL3 0xB9
225#define KSZ8795_PORT1_PRIO3_IG_LIMIT_CTRL4 0xBA
226#define KSZ8795_PORT1_QUEUE0_EG_LIMIT_CTRL1 0xBB
227#define KSZ8795_PORT1_QUEUE1_EG_LIMIT_CTRL2 0xBC
228#define KSZ8795_PORT1_QUEUE2_EG_LIMIT_CTRL3 0xBD
229#define KSZ8795_PORT1_QUEUE3_EG_LIMIT_CTRL4 0xBE
230#define KSZ8795_TEST 0xBF
231#define KSZ8795_PORT2_CTRL12 0xC0
232#define KSZ8795_PORT2_CTRL13 0xC1
233#define KSZ8795_PORT2_CTRL14 0xC2
234#define KSZ8795_PORT2_CTRL15 0xC3
235#define KSZ8795_PORT2_CTRL16 0xC4
236#define KSZ8795_PORT2_CTRL17 0xC5
237#define KSZ8795_PORT2_RATE_LIMIT_CTRL 0xC6
238#define KSZ8795_PORT2_PRIO0_IG_LIMIT_CTRL1 0xC7
239#define KSZ8795_PORT2_PRIO1_IG_LIMIT_CTRL2 0xC8
240#define KSZ8795_PORT2_PRIO2_IG_LIMIT_CTRL3 0xC9
241#define KSZ8795_PORT2_PRIO3_IG_LIMIT_CTRL4 0xCA
242#define KSZ8795_PORT2_QUEUE0_EG_LIMIT_CTRL1 0xCB
243#define KSZ8795_PORT2_QUEUE1_EG_LIMIT_CTRL2 0xCC
244#define KSZ8795_PORT2_QUEUE2_EG_LIMIT_CTRL3 0xCD
245#define KSZ8795_PORT2_QUEUE3_EG_LIMIT_CTRL4 0xCE
246#define KSZ8795_PORT3_CTRL12 0xD0
247#define KSZ8795_PORT3_CTRL13 0xD1
248#define KSZ8795_PORT3_CTRL14 0xD2
249#define KSZ8795_PORT3_CTRL15 0xD3
250#define KSZ8795_PORT3_CTRL16 0xD4
251#define KSZ8795_PORT3_CTRL17 0xD5
252#define KSZ8795_PORT3_RATE_LIMIT_CTRL 0xD6
253#define KSZ8795_PORT3_PRIO0_IG_LIMIT_CTRL1 0xD7
254#define KSZ8795_PORT3_PRIO1_IG_LIMIT_CTRL2 0xD8
255#define KSZ8795_PORT3_PRIO2_IG_LIMIT_CTRL3 0xD9
256#define KSZ8795_PORT3_PRIO3_IG_LIMIT_CTRL4 0xDA
257#define KSZ8795_PORT3_QUEUE0_EG_LIMIT_CTRL1 0xDB
258#define KSZ8795_PORT3_QUEUE1_EG_LIMIT_CTRL2 0xDC
259#define KSZ8795_PORT3_QUEUE2_EG_LIMIT_CTRL3 0xDD
260#define KSZ8795_PORT3_QUEUE3_EG_LIMIT_CTRL4 0xDE
261#define KSZ8795_TEST2 0xDF
262#define KSZ8795_PORT4_CTRL12 0xE0
263#define KSZ8795_PORT4_CTRL13 0xE1
264#define KSZ8795_PORT4_CTRL14 0xE2
265#define KSZ8795_PORT4_CTRL15 0xE3
266#define KSZ8795_PORT4_CTRL16 0xE4
267#define KSZ8795_PORT4_CTRL17 0xE5
268#define KSZ8795_PORT4_RATE_LIMIT_CTRL 0xE6
269#define KSZ8795_PORT4_PRIO0_IG_LIMIT_CTRL1 0xE7
270#define KSZ8795_PORT4_PRIO1_IG_LIMIT_CTRL2 0xE8
271#define KSZ8795_PORT4_PRIO2_IG_LIMIT_CTRL3 0xE9
272#define KSZ8795_PORT4_PRIO3_IG_LIMIT_CTRL4 0xEA
273#define KSZ8795_PORT4_QUEUE0_EG_LIMIT_CTRL1 0xEB
274#define KSZ8795_PORT4_QUEUE1_EG_LIMIT_CTRL2 0xEC
275#define KSZ8795_PORT4_QUEUE2_EG_LIMIT_CTRL3 0xED
276#define KSZ8795_PORT4_QUEUE3_EG_LIMIT_CTRL4 0xEE
277#define KSZ8795_TEST3 0xEF
278#define KSZ8795_PORT5_CTRL12 0xF0
279#define KSZ8795_PORT5_CTRL13 0xF1
280#define KSZ8795_PORT5_CTRL14 0xF2
281#define KSZ8795_PORT5_CTRL15 0xF3
282#define KSZ8795_PORT5_CTRL16 0xF4
283#define KSZ8795_PORT5_CTRL17 0xF5
284#define KSZ8795_PORT5_RATE_LIMIT_CTRL 0xF6
285#define KSZ8795_PORT5_PRIO0_IG_LIMIT_CTRL1 0xF7
286#define KSZ8795_PORT5_PRIO1_IG_LIMIT_CTRL2 0xF8
287#define KSZ8795_PORT5_PRIO2_IG_LIMIT_CTRL3 0xF9
288#define KSZ8795_PORT5_PRIO3_IG_LIMIT_CTRL4 0xFA
289#define KSZ8795_PORT5_QUEUE0_EG_LIMIT_CTRL1 0xFB
290#define KSZ8795_PORT5_QUEUE1_EG_LIMIT_CTRL2 0xFC
291#define KSZ8795_PORT5_QUEUE2_EG_LIMIT_CTRL3 0xFD
292#define KSZ8795_PORT5_QUEUE3_EG_LIMIT_CTRL4 0xFE
293#define KSZ8795_TEST4 0xFF
294
295//KSZ8795 Switch register access macros
296#define KSZ8795_PORTn_CTRL0(port) (0x00 + ((port) * 0x10))
297#define KSZ8795_PORTn_CTRL1(port) (0x01 + ((port) * 0x10))
298#define KSZ8795_PORTn_CTRL2(port) (0x02 + ((port) * 0x10))
299#define KSZ8795_PORTn_CTRL3(port) (0x03 + ((port) * 0x10))
300#define KSZ8795_PORTn_CTRL4(port) (0x04 + ((port) * 0x10))
301#define KSZ8795_PORTn_CTRL5(port) (0x05 + ((port) * 0x10))
302#define KSZ8795_PORTn_CTRL7(port) (0x07 + ((port) * 0x10))
303#define KSZ8795_PORTn_STAT0(port) (0x08 + ((port) * 0x10))
304#define KSZ8795_PORTn_STAT1(port) (0x09 + ((port) * 0x10))
305#define KSZ8795_PORTn_PHY_CTRL8(port) (0x0A + ((port) * 0x10))
306#define KSZ8795_PORTn_LINKMD(port) (0x0B + ((port) * 0x10))
307#define KSZ8795_PORTn_CTRL9(port) (0x0C + ((port) * 0x10))
308#define KSZ8795_PORTn_CTRL10(port) (0x0D + ((port) * 0x10))
309#define KSZ8795_PORTn_STAT2(port) (0x0E + ((port) * 0x10))
310#define KSZ8795_PORTn_CTRL11_STAT3(port) (0x0F + ((port) * 0x10))
311#define KSZ8795_PORTn_CTRL12(port) (0xA0 + ((port) * 0x10))
312#define KSZ8795_PORTn_CTRL13(port) (0xA1 + ((port) * 0x10))
313#define KSZ8795_PORTn_CTRL14(port) (0xA2 + ((port) * 0x10))
314#define KSZ8795_PORTn_CTRL15(port) (0xA3 + ((port) * 0x10))
315#define KSZ8795_PORTn_CTRL16(port) (0xA4 + ((port) * 0x10))
316#define KSZ8795_PORTn_CTRL17(port) (0xA5 + ((port) * 0x10))
317#define KSZ8795_PORTn_RATE_LIMIT_CTRL(port) (0xA6 + ((port) * 0x10))
318#define KSZ8795_PORTn_PRIO0_IG_LIMIT_CTRL1(port) (0xA7 + ((port) * 0x10))
319#define KSZ8795_PORTn_PRIO1_IG_LIMIT_CTRL2(port) (0xA8 + ((port) * 0x10))
320#define KSZ8795_PORTn_PRIO2_IG_LIMIT_CTRL3(port) (0xA9 + ((port) * 0x10))
321#define KSZ8795_PORTn_PRIO3_IG_LIMIT_CTRL4(port) (0xAA + ((port) * 0x10))
322#define KSZ8795_PORTn_QUEUE0_EG_LIMIT_CTRL1(port) (0xAB + ((port) * 0x10))
323#define KSZ8795_PORTn_QUEUE1_EG_LIMIT_CTRL2(port) (0xAC + ((port) * 0x10))
324#define KSZ8795_PORTn_QUEUE2_EG_LIMIT_CTRL3(port) (0xAD + ((port) * 0x10))
325#define KSZ8795_PORTn_QUEUE3_EG_LIMIT_CTRL4(port) (0xAE + ((port) * 0x10))
326
327//Basic Control register
328#define KSZ8795_BMCR_RESET 0x8000
329#define KSZ8795_BMCR_LOOPBACK 0x4000
330#define KSZ8795_BMCR_FORCE_100 0x2000
331#define KSZ8795_BMCR_AN_EN 0x1000
332#define KSZ8795_BMCR_POWER_DOWN 0x0800
333#define KSZ8795_BMCR_ISOLATE 0x0400
334#define KSZ8795_BMCR_RESTART_AN 0x0200
335#define KSZ8795_BMCR_FORCE_FULL_DUPLEX 0x0100
336#define KSZ8795_BMCR_HP_MDIX 0x0020
337#define KSZ8795_BMCR_FORCE_MDI 0x0010
338#define KSZ8795_BMCR_AUTO_MDIX_DIS 0x0008
339#define KSZ8795_BMCR_FAR_END_FAULT_DIS 0x0004
340#define KSZ8795_BMCR_TRANSMIT_DIS 0x0002
341#define KSZ8795_BMCR_LED_DIS 0x0001
342
343//Basic Status register
344#define KSZ8795_BMSR_100BT4 0x8000
345#define KSZ8795_BMSR_100BTX_FD 0x4000
346#define KSZ8795_BMSR_100BTX_HD 0x2000
347#define KSZ8795_BMSR_10BT_FD 0x1000
348#define KSZ8795_BMSR_10BT_HD 0x0800
349#define KSZ8795_BMSR_AN_COMPLETE 0x0020
350#define KSZ8795_BMSR_FAR_END_FAULT 0x0010
351#define KSZ8795_BMSR_AN_CAPABLE 0x0008
352#define KSZ8795_BMSR_LINK_STATUS 0x0004
353#define KSZ8795_BMSR_EXTENDED_CAPABLE 0x0001
354
355//PHYID High register
356#define KSZ8795_PHYID1_DEFAULT 0x0022
357
358//PHYID Low register
359#define KSZ8795_PHYID2_DEFAULT 0x1550
360
361//Advertisement Ability register
362#define KSZ8795_ANAR_PAUSE 0x0400
363#define KSZ8795_ANAR_100BTX_FD 0x0100
364#define KSZ8795_ANAR_100BTX_HD 0x0080
365#define KSZ8795_ANAR_10BT_FD 0x0040
366#define KSZ8795_ANAR_10BT_HD 0x0020
367#define KSZ8795_ANAR_SELECTOR 0x001F
368#define KSZ8795_ANAR_SELECTOR_DEFAULT 0x0001
369
370//Link Partner Ability register
371#define KSZ8795_ANLPAR_PAUSE 0x0400
372#define KSZ8795_ANLPAR_100BTX_FD 0x0100
373#define KSZ8795_ANLPAR_100BTX_HD 0x0080
374#define KSZ8795_ANLPAR_10BT_FD 0x0040
375#define KSZ8795_ANLPAR_10BT_HD 0x0020
376
377//LinkMD Control/Status register
378#define KSZ8795_LINKMD_TEST_EN 0x8000
379#define KSZ8795_LINKMD_RESULT 0x6000
380#define KSZ8795_LINKMD_SHORT 0x1000
381#define KSZ8795_LINKMD_FAULT_COUNT 0x01FF
382
383//PHY Special Control/Status register
384#define KSZ8795_PHYSCS_OP_MODE 0x0700
385#define KSZ8795_PHYSCS_OP_MODE_AN 0x0100
386#define KSZ8795_PHYSCS_OP_MODE_10BT_HD 0x0200
387#define KSZ8795_PHYSCS_OP_MODE_100BTX_HD 0x0300
388#define KSZ8795_PHYSCS_OP_MODE_10BT_FD 0x0500
389#define KSZ8795_PHYSCS_OP_MODE_100BTX_FD 0x0600
390#define KSZ8795_PHYSCS_OP_MODE_ISOLATE 0x0700
391#define KSZ8795_PHYSCS_POLRVS 0x0020
392#define KSZ8795_PHYSCS_MDIX_STATUS 0x0010
393#define KSZ8795_PHYSCS_FORCE_LINK 0x0008
394#define KSZ8795_PHYSCS_PWRSAVE 0x0004
395#define KSZ8795_PHYSCS_REMOTE_LOOPBACK 0x0002
396
397//Chip ID0 register
398#define KSZ8795_CHIP_ID0_FAMILY_ID 0xFF
399#define KSZ8795_CHIP_ID0_FAMILY_ID_DEFAULT 0x87
400
401//Chip ID1 / Start Switch register
402#define KSZ8795_CHIP_ID1_CHIP_ID 0xF0
403#define KSZ8795_CHIP_ID1_CHIP_ID_DEFAULT 0x90
404#define KSZ8795_CHIP_ID1_REVISION_ID 0x0E
405#define KSZ8795_CHIP_ID1_START_SWITCH 0x01
406
407//Global Control 0 register
408#define KSZ8795_GLOBAL_CTRL0_NEW_BACK_OFF_EN 0x80
409#define KSZ8795_GLOBAL_CTRL0_GLOBAL_SOFT_RESET_EN 0x40
410#define KSZ8795_GLOBAL_CTRL0_FLUSH_DYNAMIC_MAC_TABLE 0x20
411#define KSZ8795_GLOBAL_CTRL0_FLUSH_STATIC_MAC_TABLE 0x10
412#define KSZ8795_GLOBAL_CTRL0_UNH_MODE 0x02
413#define KSZ8795_GLOBAL_CTRL0_LINK_CHANGE_AGE 0x01
414
415//Global Control 1 register
416#define KSZ8795_GLOBAL_CTRL1_2KB_PKT_SUPPORT 0x40
417#define KSZ8795_GLOBAL_CTRL1_TX_FLOW_CTRL_DIS 0x20
418#define KSZ8795_GLOBAL_CTRL1_RX_FLOW_CTRL_DIS 0x10
419#define KSZ8795_GLOBAL_CTRL1_FRAME_LEN_CHECK_EN 0x08
420#define KSZ8795_GLOBAL_CTRL1_AGING_EN 0x04
421#define KSZ8795_GLOBAL_CTRL1_FAST_AGE_EN 0x02
422#define KSZ8795_GLOBAL_CTRL1_AGGRESSIVE_BACK_OFF_EN 0x01
423
424//Global Control 2 register
425#define KSZ8795_GLOBAL_CTRL2_UNI_VLAN_MISMATCH_DISCARD 0x80
426#define KSZ8795_GLOBAL_CTRL2_MCAST_STORM_PROTECT_DIS 0x40
427#define KSZ8795_GLOBAL_CTRL2_BACK_PRESSURE_MODE 0x20
428#define KSZ8795_GLOBAL_CTRL2_FLOW_CTRL_FAIR_MODE 0x10
429#define KSZ8795_GLOBAL_CTRL2_NO_EXCESSIVE_COL_DROP 0x08
430#define KSZ8795_GLOBAL_CTRL2_MAX_PKT_SIZE_CHECK_DIS 0x02
431
432//Global Control 3 register
433#define KSZ8795_GLOBAL_CTRL3_VLAN_EN 0x80
434#define KSZ8795_GLOBAL_CTRL3_SW5_IGMP_SNOOP_EN 0x40
435#define KSZ8795_GLOBAL_CTRL3_SNIFF_MODE_SEL 0x01
436
437//Global Control 4 register
438#define KSZ8795_GLOBAL_CTRL4_SW5_BACK_PRESSURE_EN 0x80
439#define KSZ8795_GLOBAL_CTRL4_SW5_HALF_DUPLEX_MODE 0x40
440#define KSZ8795_GLOBAL_CTRL4_SW5_FLOW_CTRL_EN 0x20
441#define KSZ8795_GLOBAL_CTRL4_SW5_SPEED 0x10
442#define KSZ8795_GLOBAL_CTRL4_NULL_VID_REPLACEMENT 0x08
443#define KSZ8795_GLOBAL_CTRL4_BCAST_STORM_PROTECT_RATE_MSB 0x07
444
445//Global Control 5 register
446#define KSZ8795_GLOBAL_CTRL5_BCAST_STORM_PROTECT_RATE_LSB 0xFF
447
448//Global Control 6 MIB Control register
449#define KSZ8795_GLOBAL_CTRL6_MIB_CTRL_FLUSH_COUNTER 0x80
450#define KSZ8795_GLOBAL_CTRL6_MIB_CTRL_FREEZE_COUNTER 0x40
451#define KSZ8795_GLOBAL_CTRL6_MIB_CTRL_CONTROL_EN 0x1F
452#define KSZ8795_GLOBAL_CTRL6_MIB_CTRL_CONTROL_EN_PORT1 0x01
453#define KSZ8795_GLOBAL_CTRL6_MIB_CTRL_CONTROL_EN_PORT2 0x02
454#define KSZ8795_GLOBAL_CTRL6_MIB_CTRL_CONTROL_EN_PORT3 0x04
455#define KSZ8795_GLOBAL_CTRL6_MIB_CTRL_CONTROL_EN_PORT4 0x08
456#define KSZ8795_GLOBAL_CTRL6_MIB_CTRL_CONTROL_EN_PORT5 0x10
457
458//Global Control 7 register
459#define KSZ8795_GLOBAL_CTRL7_FACTORY_TESTING 0xFF
460
461//Global Control 8 register
462#define KSZ8795_GLOBAL_CTRL8_FACTORY_TESTING 0xFF
463
464//Global Control 9 register
465#define KSZ8795_GLOBAL_CTRL9_SW5_REFCLK_EDGE_SEL 0x40
466#define KSZ8795_GLOBAL_CTRL9_SW5_REFCLK_EDGE_SEL_RISING 0x00
467#define KSZ8795_GLOBAL_CTRL9_SW5_REFCLK_EDGE_SEL_FALLING 0x40
468#define KSZ8795_GLOBAL_CTRL9_LED_MODE 0x30
469#define KSZ8795_GLOBAL_CTRL9_LED_MODE_LED0_LNK_ACT_LED1_SPD 0x00
470#define KSZ8795_GLOBAL_CTRL9_LED_MODE_LED0_LNK_LED1_ACT 0x10
471#define KSZ8795_GLOBAL_CTRL9_LED_MODE_LED0_LNK_ACT_LED1_DPLX 0x20
472#define KSZ8795_GLOBAL_CTRL9_LED_MODE_LED0_LNK_LED1_ACT_DPLX 0x30
473#define KSZ8795_GLOBAL_CTRL9_REFCLKO_ENABLE 0x02
474#define KSZ8795_GLOBAL_CTRL9_SPI_READ_CLK_EDGE_SEL 0x01
475#define KSZ8795_GLOBAL_CTRL9_SPI_READ_CLK_EDGE_SEL_FALLING 0x00
476#define KSZ8795_GLOBAL_CTRL9_SPI_READ_CLK_EDGE_SEL_RISING 0x01
477
478//Global Control 10 register
479#define KSZ8795_GLOBAL_CTRL10_TAIL_TAG_EN 0x02
480#define KSZ8795_GLOBAL_CTRL10_PASS_FLOW_CTRL_PKT 0x01
481
482//Global Control 11 register
483#define KSZ8795_GLOBAL_CTRL11_FACTORY_TESTING 0xFF
484
485//Power-Down Management Control 1 register
486#define KSZ8795_PD_MGMT_CTRL1_PLL_PWR_DOWN 0x20
487#define KSZ8795_PD_MGMT_CTRL1_PWR_MGMT_MODE 0x18
488#define KSZ8795_PD_MGMT_CTRL1_PWR_MGMT_MODE_NORMAL 0x00
489#define KSZ8795_PD_MGMT_CTRL1_PWR_MGMT_MODE_ENERGY_DETECT 0x08
490#define KSZ8795_PD_MGMT_CTRL1_PWR_MGMT_MODE_SOFT_PWR_DOWN 0x10
491
492//Power-Down Management Control 2 register
493#define KSZ8795_PD_MGMT_CTRL2_GO_SLEEP_TIME 0xFF
494
495//Port N Control 0 register
496#define KSZ8795_PORTn_CTRL0_BCAST_STORM_PROTECT_EN 0x80
497#define KSZ8795_PORTn_CTRL0_DIFFSERV_PRIO_CLASS_EN 0x40
498#define KSZ8795_PORTn_CTRL0_802_1P_PRIO_CLASS_EN 0x20
499#define KSZ8795_PORTn_CTRL0_PORT_PRIO_CLASS_EN 0x18
500#define KSZ8795_PORTn_CTRL0_TAG_INSERTION 0x04
501#define KSZ8795_PORTn_CTRL0_TAG_REMOVAL 0x02
502#define KSZ8795_PORTn_CTRL0_TWO_QUEUE_SPLIT_EN 0x01
503
504//Port N Control 1 register
505#define KSZ8795_PORTn_CTRL1_SNIFFER_PORT 0x80
506#define KSZ8795_PORTn_CTRL1_RECEIVE_SNIFF 0x40
507#define KSZ8795_PORTn_CTRL1_TRANSMIT_SNIFF 0x20
508#define KSZ8795_PORTn_CTRL1_PORT_VLAN_MEMBERSHIP 0x1F
509
510//Port N Control 2 register
511#define KSZ8795_PORTn_CTRL2_USER_PRIO_CEILING 0x80
512#define KSZ8795_PORTn_CTRL2_INGRESS_VLAN_FILT 0x40
513#define KSZ8795_PORTn_CTRL2_DISCARD_NON_PVID_PKT 0x20
514#define KSZ8795_PORTn_CTRL2_FORCE_FLOW_CTRL 0x10
515#define KSZ8795_PORTn_CTRL2_BACK_PRESSURE_EN 0x08
516#define KSZ8795_PORTn_CTRL2_TRANSMIT_EN 0x04
517#define KSZ8795_PORTn_CTRL2_RECEIVE_EN 0x02
518#define KSZ8795_PORTn_CTRL2_LEARNING_DIS 0x01
519
520//Port N Control 3 register
521#define KSZ8795_PORTn_CTRL3_DEFAULT_USER_PRIO 0xE0
522#define KSZ8795_PORTn_CTRL3_DEFAULT_CFI 0x10
523#define KSZ8795_PORTn_CTRL3_DEFAULT_VID_MSB 0x0F
524
525//Port N Control 4 register
526#define KSZ8795_PORTn_CTRL4_DEFAULT_VID_LSB 0xFF
527
528//Port 5 Interface Control 6 register
529#define KSZ8795_PORT5_IF_CTRL6_RMII_CLK_SEL 0x80
530#define KSZ8795_PORT5_IF_CTRL6_IS_1GBPS 0x40
531#define KSZ8795_PORT5_IF_CTRL6_RGMII_ID_IG_EN 0x10
532#define KSZ8795_PORT5_IF_CTRL6_RGMII_ID_EG_EN 0x08
533#define KSZ8795_PORT5_IF_CTRL6_GMII_MII_MODE_SEL 0x04
534#define KSZ8795_PORT5_IF_CTRL6_GMII_MII_MODE_SEL_PHY 0x00
535#define KSZ8795_PORT5_IF_CTRL6_GMII_MII_MODE_SEL_MAC 0x04
536#define KSZ8795_PORT5_IF_CTRL6_IF_MODE_SEL 0x03
537#define KSZ8795_PORT5_IF_CTRL6_IF_MODE_SEL_MII 0x00
538#define KSZ8795_PORT5_IF_CTRL6_IF_MODE_SEL_RMII 0x01
539#define KSZ8795_PORT5_IF_CTRL6_IF_MODE_SEL_GMII 0x02
540#define KSZ8795_PORT5_IF_CTRL6_IF_MODE_SEL_RGMII 0x03
541
542//Port N Status 0 register
543#define KSZ8795_PORTn_STAT0_LP_FLOW_CTRL_CAPABLE 0x30
544#define KSZ8795_PORTn_STAT0_LP_100BTX_FD_CAPABLE 0x08
545#define KSZ8795_PORTn_STAT0_LP_100BTX_HF_CAPABLE 0x04
546#define KSZ8795_PORTn_STAT0_LP_10BT_FD_CAPABLE 0x02
547#define KSZ8795_PORTn_STAT0_LP_10BT_HD_CAPABLE 0x01
548
549//Port N Status 1 register
550#define KSZ8795_PORTn_STAT1_HP_MDIX 0x80
551#define KSZ8795_PORTn_STAT1_FACTORY_TESTING 0x40
552#define KSZ8795_PORTn_STAT1_POLRVS 0x20
553#define KSZ8795_PORTn_STAT1_TX_FLOW_CTRL_EN 0x10
554#define KSZ8795_PORTn_STAT1_RX_FLOW_CTRL_EN 0x08
555#define KSZ8795_PORTn_STAT1_OP_SPEED 0x04
556#define KSZ8795_PORTn_STAT1_OP_DUPLEX 0x02
557
558//Port N Control 9 register
559#define KSZ8795_PORTn_CTRL9_AN_DIS 0x80
560#define KSZ8795_PORTn_CTRL9_FORCED_SPEED 0x40
561#define KSZ8795_PORTn_CTRL9_FORCED_DUPLEX 0x20
562
563//Port N Control 10 register
564#define KSZ8795_PORTn_CTRL10_LED_OFF 0x80
565#define KSZ8795_PORTn_CTRL10_TX_DIS 0x40
566#define KSZ8795_PORTn_CTRL10_RESTART_AN 0x20
567#define KSZ8795_PORTn_CTRL10_POWER_DOWN 0x08
568#define KSZ8795_PORTn_CTRL10_AUTO_MDIX_DIS 0x04
569#define KSZ8795_PORTn_CTRL10_FORCED_MDI 0x02
570#define KSZ8795_PORTn_CTRL10_MAC_LOOPBACK 0x01
571
572//Port N Status 2 register
573#define KSZ8795_PORTn_STAT2_MDIX_STATUS 0x80
574#define KSZ8795_PORTn_STAT2_AN_DONE 0x40
575#define KSZ8795_PORTn_STAT2_LINK_GOOD 0x20
576
577//Port N Control 11 / Status 3 register
578#define KSZ8795_PORTn_CTRL11_STAT3_PHY_LOOPBACK 0x80
579#define KSZ8795_PORTn_CTRL11_STAT3_PHY_ISOLATE 0x20
580#define KSZ8795_PORTn_CTRL11_STAT3_SOFT_RESET 0x10
581#define KSZ8795_PORTn_CTRL11_STAT3_FORCE_LINK 0x08
582#define KSZ8795_PORTn_CTRL11_STAT3_OP_MODE 0x07
583#define KSZ8795_PORTn_CTRL11_STAT3_OP_MODE_AN 0x01
584#define KSZ8795_PORTn_CTRL11_STAT3_OP_MODE_10BT_HD 0x02
585#define KSZ8795_PORTn_CTRL11_STAT3_OP_MODE_100BTX_HD 0x03
586#define KSZ8795_PORTn_CTRL11_STAT3_OP_MODE_10BT_FD 0x05
587#define KSZ8795_PORTn_CTRL11_STAT3_OP_MODE_100BTX_FD 0x06
588
589//Indirect Access Control 0 register
590#define KSZ8795_INDIRECT_CTRL0_FUNC_SEL 0xE0
591#define KSZ8795_INDIRECT_CTRL0_FUNC_SEL_INDIRECT_MODE 0x00
592#define KSZ8795_INDIRECT_CTRL0_FUNC_SEL_EEE 0x20
593#define KSZ8795_INDIRECT_CTRL0_FUNC_SEL_ACL 0x40
594#define KSZ8795_INDIRECT_CTRL0_FUNC_SEL_PME 0x80
595#define KSZ8795_INDIRECT_CTRL0_FUNC_SEL_LINKMD 0xA0
596#define KSZ8795_INDIRECT_CTRL0_WRITE 0x00
597#define KSZ8795_INDIRECT_CTRL0_READ 0x10
598#define KSZ8795_INDIRECT_CTRL0_TABLE_SEL 0x0C
599#define KSZ8795_INDIRECT_CTRL0_TABLE_SEL_STATIC_MAC 0x00
600#define KSZ8795_INDIRECT_CTRL0_TABLE_SEL_VLAN 0x04
601#define KSZ8795_INDIRECT_CTRL0_TABLE_SEL_DYNAMIC_MAC 0x08
602#define KSZ8795_INDIRECT_CTRL0_TABLE_SEL_MIB_COUNTER 0x0C
603#define KSZ8795_INDIRECT_CTRL0_ADDR_11_8 0x0F
604#define KSZ8795_INDIRECT_CTRL0_ADDR_9_8 0x03
605
606//Indirect Access Control 1 register
607#define KSZ8795_INDIRECT_CTRL1_ADDR_7_0 0xFF
608
609//Interrupt Status register
610#define KSZ8795_INT_STAT_PME 0x10
611#define KSZ8795_INT_STAT_PORT4 0x08
612#define KSZ8795_INT_STAT_PORT3 0x04
613#define KSZ8795_INT_STAT_PORT2 0x02
614#define KSZ8795_INT_STAT_PORT1 0x01
615
616//Interrupt Mask register
617#define KSZ8795_INT_MASK_PME 0x10
618#define KSZ8795_INT_MASK_PORT4 0x08
619#define KSZ8795_INT_MASK_PORT3 0x04
620#define KSZ8795_INT_MASK_PORT2 0x02
621#define KSZ8795_INT_MASK_PORT1 0x01
622
623//ACL Interrupt Status register
624#define KSZ8795_ACL_INT_STAT_PORT5 0x10
625#define KSZ8795_ACL_INT_STAT_PORT4 0x08
626#define KSZ8795_ACL_INT_STAT_PORT3 0x04
627#define KSZ8795_ACL_INT_STAT_PORT2 0x02
628#define KSZ8795_ACL_INT_STAT_PORT1 0x01
629
630//ACL Interrupt Control register
631#define KSZ8795_ACL_INT_CTRL_PORT5 0x10
632#define KSZ8795_ACL_INT_CTRL_PORT4 0x08
633#define KSZ8795_ACL_INT_CTRL_PORT3 0x04
634#define KSZ8795_ACL_INT_CTRL_PORT2 0x02
635#define KSZ8795_ACL_INT_CTRL_PORT1 0x01
636
637//Global Control 12 register
638#define KSZ8795_GLOBAL_CTRL12_TAG3 0xC0
639#define KSZ8795_GLOBAL_CTRL12_TAG2 0x30
640#define KSZ8795_GLOBAL_CTRL12_TAG1 0x0C
641#define KSZ8795_GLOBAL_CTRL12_TAG0 0x03
642
643//Global Control 13 register
644#define KSZ8795_GLOBAL_CTRL13_TAG7 0xC0
645#define KSZ8795_GLOBAL_CTRL13_TAG6 0x30
646#define KSZ8795_GLOBAL_CTRL13_TAG5 0x0C
647#define KSZ8795_GLOBAL_CTRL13_TAG4 0x03
648
649//Global Control 14 register
650#define KSZ8795_GLOBAL_CTRL14_PRI_2Q 0xC0
651
652//Global Control 15 register
653#define KSZ8795_GLOBAL_CTRL15_UNKNOWN_UNICAST_FWD 0x20
654#define KSZ8795_GLOBAL_CTRL15_UNKNOWN_UNICAST_FWD_MAP 0x1F
655#define KSZ8795_GLOBAL_CTRL15_UNKNOWN_UNICAST_FWD_MAP_FILT 0x00
656#define KSZ8795_GLOBAL_CTRL15_UNKNOWN_UNICAST_FWD_MAP_PORT1 0x01
657#define KSZ8795_GLOBAL_CTRL15_UNKNOWN_UNICAST_FWD_MAP_PORT2 0x02
658#define KSZ8795_GLOBAL_CTRL15_UNKNOWN_UNICAST_FWD_MAP_PORT3 0x04
659#define KSZ8795_GLOBAL_CTRL15_UNKNOWN_UNICAST_FWD_MAP_PORT4 0x08
660#define KSZ8795_GLOBAL_CTRL15_UNKNOWN_UNICAST_FWD_MAP_PORT5 0x10
661#define KSZ8795_GLOBAL_CTRL15_UNKNOWN_UNICAST_FWD_MAP_ALL 0x1F
662
663//Global Control 16 register
664#define KSZ8795_GLOBAL_CTRL16_UNKNOWN_MCAST_FWD 0x20
665#define KSZ8795_GLOBAL_CTRL16_UNKNOWN_MCAST_FWD_MAP 0x1F
666#define KSZ8795_GLOBAL_CTRL16_UNKNOWN_MCAST_FWD_MAP_FILT 0x00
667#define KSZ8795_GLOBAL_CTRL16_UNKNOWN_MCAST_FWD_MAP_PORT1 0x01
668#define KSZ8795_GLOBAL_CTRL16_UNKNOWN_MCAST_FWD_MAP_PORT2 0x02
669#define KSZ8795_GLOBAL_CTRL16_UNKNOWN_MCAST_FWD_MAP_PORT3 0x04
670#define KSZ8795_GLOBAL_CTRL16_UNKNOWN_MCAST_FWD_MAP_PORT4 0x08
671#define KSZ8795_GLOBAL_CTRL16_UNKNOWN_MCAST_FWD_MAP_PORT5 0x10
672#define KSZ8795_GLOBAL_CTRL16_UNKNOWN_MCAST_FWD_MAP_ALL 0x1F
673
674//Global Control 17 register
675#define KSZ8795_GLOBAL_CTRL17_UNKNOWN_VID_FWD 0x20
676#define KSZ8795_GLOBAL_CTRL17_UNKNOWN_VID_FWD_MAP 0x1F
677#define KSZ8795_GLOBAL_CTRL17_UNKNOWN_VID_FWD_MAP_FILT 0x00
678#define KSZ8795_GLOBAL_CTRL17_UNKNOWN_VID_FWD_MAP_PORT1 0x01
679#define KSZ8795_GLOBAL_CTRL17_UNKNOWN_VID_FWD_MAP_PORT2 0x02
680#define KSZ8795_GLOBAL_CTRL17_UNKNOWN_VID_FWD_MAP_PORT3 0x04
681#define KSZ8795_GLOBAL_CTRL17_UNKNOWN_VID_FWD_MAP_PORT4 0x08
682#define KSZ8795_GLOBAL_CTRL17_UNKNOWN_VID_FWD_MAP_PORT5 0x10
683#define KSZ8795_GLOBAL_CTRL17_UNKNOWN_VID_FWD_MAP_ALL 0x1F
684
685//Global Control 18 register
686#define KSZ8795_GLOBAL_CTRL18_SELF_ADDR_FILTER_EN 0x40
687#define KSZ8795_GLOBAL_CTRL18_UNKNOWN_IP_MCAST_FWD 0x20
688#define KSZ8795_GLOBAL_CTRL18_UNKNOWN_IP_MCAST_FWD_MAP 0x1F
689#define KSZ8795_GLOBAL_CTRL18_UNKNOWN_IP_MCAST_FWD_MAP_FILT 0x00
690#define KSZ8795_GLOBAL_CTRL18_UNKNOWN_IP_MCAST_FWD_MAP_PORT1 0x01
691#define KSZ8795_GLOBAL_CTRL18_UNKNOWN_IP_MCAST_FWD_MAP_PORT2 0x02
692#define KSZ8795_GLOBAL_CTRL18_UNKNOWN_IP_MCAST_FWD_MAP_PORT3 0x04
693#define KSZ8795_GLOBAL_CTRL18_UNKNOWN_IP_MCAST_FWD_MAP_PORT4 0x08
694#define KSZ8795_GLOBAL_CTRL18_UNKNOWN_IP_MCAST_FWD_MAP_PORT5 0x10
695#define KSZ8795_GLOBAL_CTRL18_UNKNOWN_IP_MCAST_FWD_MAP_ALL 0x1F
696
697//Global Control 19 register
698#define KSZ8795_GLOBAL_CTRL19_IG_RATE_LIMIT_PERIOD 0x30
699#define KSZ8795_GLOBAL_CTRL19_IG_RATE_LIMIT_PERIOD_16MS 0x00
700#define KSZ8795_GLOBAL_CTRL19_IG_RATE_LIMIT_PERIOD_64MS 0x10
701#define KSZ8795_GLOBAL_CTRL19_IG_RATE_LIMIT_PERIOD_256MS 0x20
702#define KSZ8795_GLOBAL_CTRL19_QUEUE_BASED_EG_RATE_LIMITE_EN 0x08
703#define KSZ8795_GLOBAL_CTRL19_INSERT_SRC_PORT_PVID_TAG_EN 0x04
704
705//Global Control 20 register
706#define KSZ8795_GLOBAL_CTRL20_HIGH_SPEED_DRIVE_STRENGTH 0x70
707#define KSZ8795_GLOBAL_CTRL20_HIGH_SPEED_DRIVE_STRENGTH_2MA 0x00
708#define KSZ8795_GLOBAL_CTRL20_HIGH_SPEED_DRIVE_STRENGTH_4MA 0x10
709#define KSZ8795_GLOBAL_CTRL20_HIGH_SPEED_DRIVE_STRENGTH_8MA 0x20
710#define KSZ8795_GLOBAL_CTRL20_HIGH_SPEED_DRIVE_STRENGTH_12MA 0x30
711#define KSZ8795_GLOBAL_CTRL20_HIGH_SPEED_DRIVE_STRENGTH_16MA 0x40
712#define KSZ8795_GLOBAL_CTRL20_HIGH_SPEED_DRIVE_STRENGTH_20MA 0x50
713#define KSZ8795_GLOBAL_CTRL20_HIGH_SPEED_DRIVE_STRENGTH_24MA 0x60
714#define KSZ8795_GLOBAL_CTRL20_HIGH_SPEED_DRIVE_STRENGTH_28MA 0x70
715#define KSZ8795_GLOBAL_CTRL20_LOW_SPEED_DRIVE_STRENGTH 0x07
716#define KSZ8795_GLOBAL_CTRL20_LOW_SPEED_DRIVE_STRENGTH_2MA 0x00
717#define KSZ8795_GLOBAL_CTRL20_LOW_SPEED_DRIVE_STRENGTH_4MA 0x01
718#define KSZ8795_GLOBAL_CTRL20_LOW_SPEED_DRIVE_STRENGTH_8MA 0x02
719#define KSZ8795_GLOBAL_CTRL20_LOW_SPEED_DRIVE_STRENGTH_12MA 0x03
720#define KSZ8795_GLOBAL_CTRL20_LOW_SPEED_DRIVE_STRENGTH_16MA 0x04
721#define KSZ8795_GLOBAL_CTRL20_LOW_SPEED_DRIVE_STRENGTH_20MA 0x05
722#define KSZ8795_GLOBAL_CTRL20_LOW_SPEED_DRIVE_STRENGTH_24MA 0x06
723#define KSZ8795_GLOBAL_CTRL20_LOW_SPEED_DRIVE_STRENGTH_28MA 0x07
724
725//Global Control 21 register
726#define KSZ8795_GLOBAL_CTRL21_MLD_SNOOP_OPT 0x08
727#define KSZ8795_GLOBAL_CTRL21_MLD_SNOOP_EN 0x04
728
729//C++ guard
730#ifdef __cplusplus
731extern "C" {
732#endif
733
734//CodeWarrior or Win32 compiler?
735#if defined(__CWCC__) || defined(_WIN32)
736 #pragma pack(push, 1)
737#endif
738
739
744typedef struct
745{
746#if defined(_CPU_BIG_ENDIAN) && !defined(__ICCRX__)
747 uint8_t fid : 7; //0
748 uint8_t useFid : 1;
749 uint8_t reserved : 1; //1
750 uint8_t override : 1;
751 uint8_t valid : 1;
752 uint8_t forwardPorts : 5;
753#else
754 uint8_t useFid : 1; //0
755 uint8_t fid : 7;
756 uint8_t forwardPorts : 5; //1
757 uint8_t valid : 1;
758 uint8_t override : 1;
759 uint8_t reserved : 1;
760#endif
761 MacAddr macAddr; //2-7
763
764
769typedef struct
770{
771 uint8_t fid; //0
772#if defined(_CPU_BIG_ENDIAN) && !defined(__ICCRX__)
773 uint8_t useFid : 1; //1
774 uint8_t override : 1;
775 uint8_t valid : 1;
776 uint8_t forwardPorts : 5;
777#else
778 uint8_t forwardPorts : 5; //1
779 uint8_t valid : 1;
780 uint8_t override : 1;
781 uint8_t useFid : 1;
782#endif
783 MacAddr macAddr; //2-7
785
786
791typedef struct
792{
793#if defined(_CPU_BIG_ENDIAN) && !defined(__ICCRX__)
794 uint8_t macEmpty : 1; //0
795 uint8_t numValidEntriesH : 7;
796 uint8_t numValidEntriesL : 3; //1
797 uint8_t timestamp : 2;
798 uint8_t sourcePort : 3;
799 uint8_t dataNotReady : 1; //2
800 uint8_t fid : 7;
801#else
802 uint8_t numValidEntriesH : 7; //0
803 uint8_t macEmpty : 1;
804 uint8_t sourcePort : 3; //1
805 uint8_t timestamp : 2;
806 uint8_t numValidEntriesL : 3;
807 uint8_t fid : 7; //2
808 uint8_t dataNotReady : 1;
809#endif
810 MacAddr macAddr; //3-8
812
813
814//CodeWarrior or Win32 compiler?
815#if defined(__CWCC__) || defined(_WIN32)
816 #pragma pack(pop)
817#endif
818
819//KSZ8795 Ethernet switch driver
820extern const SwitchDriver ksz8795SwitchDriver;
821
822//KSZ8795 related functions
823error_t ksz8795Init(NetInterface *interface);
824void ksz8795InitHook(NetInterface *interface);
825
826void ksz8795Tick(NetInterface *interface);
827
828void ksz8795EnableIrq(NetInterface *interface);
829void ksz8795DisableIrq(NetInterface *interface);
830
831void ksz8795EventHandler(NetInterface *interface);
832
833error_t ksz8795TagFrame(NetInterface *interface, NetBuffer *buffer,
834 size_t *offset, NetTxAncillary *ancillary);
835
836error_t ksz8795UntagFrame(NetInterface *interface, uint8_t **frame,
837 size_t *length, NetRxAncillary *ancillary);
838
839bool_t ksz8795GetLinkState(NetInterface *interface, uint8_t port);
840uint32_t ksz8795GetLinkSpeed(NetInterface *interface, uint8_t port);
841NicDuplexMode ksz8795GetDuplexMode(NetInterface *interface, uint8_t port);
842
843void ksz8795SetPortState(NetInterface *interface, uint8_t port,
844 SwitchPortState state);
845
846SwitchPortState ksz8795GetPortState(NetInterface *interface, uint8_t port);
847
848void ksz8795SetAgingTime(NetInterface *interface, uint32_t agingTime);
849
850void ksz8795EnableIgmpSnooping(NetInterface *interface, bool_t enable);
851void ksz8795EnableMldSnooping(NetInterface *interface, bool_t enable);
852void ksz8795EnableRsvdMcastTable(NetInterface *interface, bool_t enable);
853
854error_t ksz8795AddStaticFdbEntry(NetInterface *interface,
855 const SwitchFdbEntry *entry);
856
857error_t ksz8795DeleteStaticFdbEntry(NetInterface *interface,
858 const SwitchFdbEntry *entry);
859
860error_t ksz8795GetStaticFdbEntry(NetInterface *interface, uint_t index,
861 SwitchFdbEntry *entry);
862
863void ksz8795FlushStaticFdbTable(NetInterface *interface);
864
865error_t ksz8795GetDynamicFdbEntry(NetInterface *interface, uint_t index,
866 SwitchFdbEntry *entry);
867
868void ksz8795FlushDynamicFdbTable(NetInterface *interface, uint8_t port);
869
870void ksz8795SetUnknownMcastFwdPorts(NetInterface *interface,
871 bool_t enable, uint32_t forwardPorts);
872
873void ksz8795WritePhyReg(NetInterface *interface, uint8_t port,
874 uint8_t address, uint16_t data);
875
876uint16_t ksz8795ReadPhyReg(NetInterface *interface, uint8_t port,
877 uint8_t address);
878
879void ksz8795DumpPhyReg(NetInterface *interface, uint8_t port);
880
881void ksz8795WriteSwitchReg(NetInterface *interface, uint16_t address,
882 uint8_t data);
883
884uint8_t ksz8795ReadSwitchReg(NetInterface *interface, uint16_t address);
885
886void ksz8795DumpSwitchReg(NetInterface *interface);
887
888//C++ guard
889#ifdef __cplusplus
890}
891#endif
892
893#endif
error_t
Error codes.
Definition error.h:43
Network interface controller abstraction layer.
NicDuplexMode
Duplex mode.
Definition nic.h:122
SwitchPortState
Switch port state.
Definition nic.h:134
Dynamic MAC table entry.
Definition ksz8795_driver.h:792
Static MAC table entry (read operation)
Definition ksz8795_driver.h:745
Static MAC table entry (write operation)
Definition ksz8795_driver.h:770
Structure describing a buffer that spans multiple chunks.
Definition net_mem.h:89
Ethernet switch driver.
Definition nic.h:322
Forwarding database entry.
Definition nic.h:149