31#ifndef _KSZ8863_DRIVER_H
32#define _KSZ8863_DRIVER_H
38#define KSZ8863_PORT1 1
39#define KSZ8863_PORT2 2
40#define KSZ8863_PORT3 3
43#define KSZ8863_PORT_MASK 0x07
44#define KSZ8863_PORT1_MASK 0x01
45#define KSZ8863_PORT2_MASK 0x02
46#define KSZ8863_PORT3_MASK 0x04
49#define KSZ8863_SPI_CMD_WRITE 0x02
50#define KSZ8863_SPI_CMD_READ 0x03
53#define KSZ8863_STATIC_MAC_TABLE_SIZE 8
54#define KSZ8863_DYNAMIC_MAC_TABLE_SIZE 1024
57#define KSZ8863_TAIL_TAG_PRIORITY 0x0C
58#define KSZ8863_TAIL_TAG_DEST_PORT2 0x02
59#define KSZ8863_TAIL_TAG_DEST_PORT1 0x01
60#define KSZ8863_TAIL_TAG_NORMAL_ADDR_LOOKUP 0x00
63#define KSZ8863_TAIL_TAG_SRC_PORT 0x01
66#define KSZ8863_BMCR 0x00
67#define KSZ8863_BMSR 0x01
68#define KSZ8863_PHYID1 0x02
69#define KSZ8863_PHYID2 0x03
70#define KSZ8863_ANAR 0x04
71#define KSZ8863_ANLPAR 0x05
72#define KSZ8863_LINKMD 0x1D
73#define KSZ8863_PHYSCS 0x1F
76#define KSZ8863_CHIP_ID0 0x00
77#define KSZ8863_CHIP_ID1 0x01
78#define KSZ8863_GLOBAL_CTRL0 0x02
79#define KSZ8863_GLOBAL_CTRL1 0x03
80#define KSZ8863_GLOBAL_CTRL2 0x04
81#define KSZ8863_GLOBAL_CTRL3 0x05
82#define KSZ8863_GLOBAL_CTRL4 0x06
83#define KSZ8863_GLOBAL_CTRL5 0x07
84#define KSZ8863_GLOBAL_CTRL6 0x08
85#define KSZ8863_GLOBAL_CTRL7 0x09
86#define KSZ8863_GLOBAL_CTRL8 0x0A
87#define KSZ8863_GLOBAL_CTRL9 0x0B
88#define KSZ8863_GLOBAL_CTRL10 0x0C
89#define KSZ8863_GLOBAL_CTRL11 0x0D
90#define KSZ8863_GLOBAL_CTRL12 0x0E
91#define KSZ8863_GLOBAL_CTRL13 0x0F
92#define KSZ8863_PORT1_CTRL0 0x10
93#define KSZ8863_PORT1_CTRL1 0x11
94#define KSZ8863_PORT1_CTRL2 0x12
95#define KSZ8863_PORT1_CTRL3 0x13
96#define KSZ8863_PORT1_CTRL4 0x14
97#define KSZ8863_PORT1_CTRL5 0x15
98#define KSZ8863_PORT1_Q0_IG_LIMIT 0x16
99#define KSZ8863_PORT1_Q1_IG_LIMIT 0x17
100#define KSZ8863_PORT1_Q2_IG_LIMIT 0x18
101#define KSZ8863_PORT1_Q3_IG_LIMIT 0x19
102#define KSZ8863_PORT1_PSCS 0x1A
103#define KSZ8863_PORT1_LINKMD 0x1B
104#define KSZ8863_PORT1_CTRL12 0x1C
105#define KSZ8863_PORT1_CTRL13 0x1D
106#define KSZ8863_PORT1_STAT0 0x1E
107#define KSZ8863_PORT1_STAT1 0x1F
108#define KSZ8863_PORT2_CTRL0 0x20
109#define KSZ8863_PORT2_CTRL1 0x21
110#define KSZ8863_PORT2_CTRL2 0x22
111#define KSZ8863_PORT2_CTRL3 0x23
112#define KSZ8863_PORT2_CTRL4 0x24
113#define KSZ8863_PORT2_CTRL5 0x25
114#define KSZ8863_PORT2_Q0_IG_LIMIT 0x26
115#define KSZ8863_PORT2_Q1_IG_LIMIT 0x27
116#define KSZ8863_PORT2_Q2_IG_LIMIT 0x28
117#define KSZ8863_PORT2_Q3_IG_LIMIT 0x29
118#define KSZ8863_PORT2_PSCS 0x2A
119#define KSZ8863_PORT2_LINKMD 0x2B
120#define KSZ8863_PORT2_CTRL12 0x2C
121#define KSZ8863_PORT2_CTRL13 0x2D
122#define KSZ8863_PORT2_STAT0 0x2E
123#define KSZ8863_PORT2_STAT1 0x2F
124#define KSZ8863_PORT3_CTRL0 0x30
125#define KSZ8863_PORT3_CTRL1 0x31
126#define KSZ8863_PORT3_CTRL2 0x32
127#define KSZ8863_PORT3_CTRL3 0x33
128#define KSZ8863_PORT3_CTRL4 0x34
129#define KSZ8863_PORT3_CTRL5 0x35
130#define KSZ8863_PORT3_Q0_IG_LIMIT 0x36
131#define KSZ8863_PORT3_Q1_IG_LIMIT 0x37
132#define KSZ8863_PORT3_Q2_IG_LIMIT 0x38
133#define KSZ8863_PORT3_Q3_IG_LIMIT 0x39
134#define KSZ8863_PORT3_STAT0 0x3E
135#define KSZ8863_PORT3_STAT1 0x3F
136#define KSZ8863_RESET 0x43
137#define KSZ8863_TOS_PRIO_CTRL0 0x60
138#define KSZ8863_TOS_PRIO_CTRL1 0x61
139#define KSZ8863_TOS_PRIO_CTRL2 0x62
140#define KSZ8863_TOS_PRIO_CTRL3 0x63
141#define KSZ8863_TOS_PRIO_CTRL4 0x64
142#define KSZ8863_TOS_PRIO_CTRL5 0x65
143#define KSZ8863_TOS_PRIO_CTRL6 0x66
144#define KSZ8863_TOS_PRIO_CTRL7 0x67
145#define KSZ8863_TOS_PRIO_CTRL8 0x68
146#define KSZ8863_TOS_PRIO_CTRL9 0x69
147#define KSZ8863_TOS_PRIO_CTRL10 0x6A
148#define KSZ8863_TOS_PRIO_CTRL11 0x6B
149#define KSZ8863_TOS_PRIO_CTRL12 0x6C
150#define KSZ8863_TOS_PRIO_CTRL13 0x6D
151#define KSZ8863_TOS_PRIO_CTRL14 0x6E
152#define KSZ8863_TOS_PRIO_CTRL15 0x6F
153#define KSZ8863_MAC_ADDR0 0x70
154#define KSZ8863_MAC_ADDR1 0x71
155#define KSZ8863_MAC_ADDR2 0x72
156#define KSZ8863_MAC_ADDR3 0x73
157#define KSZ8863_MAC_ADDR4 0x74
158#define KSZ8863_MAC_ADDR5 0x75
159#define KSZ8863_UDR1 0x76
160#define KSZ8863_UDR2 0x77
161#define KSZ8863_UDR3 0x78
162#define KSZ8863_INDIRECT_CTRL0 0x79
163#define KSZ8863_INDIRECT_CTRL1 0x7A
164#define KSZ8863_INDIRECT_DATA8 0x7B
165#define KSZ8863_INDIRECT_DATA7 0x7C
166#define KSZ8863_INDIRECT_DATA6 0x7D
167#define KSZ8863_INDIRECT_DATA5 0x7E
168#define KSZ8863_INDIRECT_DATA4 0x7F
169#define KSZ8863_INDIRECT_DATA3 0x80
170#define KSZ8863_INDIRECT_DATA2 0x81
171#define KSZ8863_INDIRECT_DATA1 0x82
172#define KSZ8863_INDIRECT_DATA0 0x83
173#define KSZ8863_MACA1 0x8E
174#define KSZ8863_MACA2 0x94
175#define KSZ8863_PORT1_Q0_EG_LIMIT 0x9A
176#define KSZ8863_PORT1_Q1_EG_LIMIT 0x9B
177#define KSZ8863_PORT1_Q2_EG_LIMIT 0x9C
178#define KSZ8863_PORT1_Q3_EG_LIMIT 0x9D
179#define KSZ8863_PORT2_Q0_EG_LIMIT 0x9E
180#define KSZ8863_PORT2_Q1_EG_LIMIT 0x9F
181#define KSZ8863_PORT2_Q2_EG_LIMIT 0xA0
182#define KSZ8863_PORT2_Q3_EG_LIMIT 0xA1
183#define KSZ8863_PORT3_Q0_EG_LIMIT 0xA2
184#define KSZ8863_PORT3_Q1_EG_LIMIT 0xA3
185#define KSZ8863_PORT3_Q2_EG_LIMIT 0xA4
186#define KSZ8863_PORT3_Q3_EG_LIMIT 0xA5
187#define KSZ8863_MODE_INDICATOR 0xA6
188#define KSZ8863_HIGH_PRIO_PKT_BUF_Q3 0xA7
189#define KSZ8863_HIGH_PRIO_PKT_BUF_Q2 0xA8
190#define KSZ8863_HIGH_PRIO_PKT_BUF_Q1 0xA9
191#define KSZ8863_HIGH_PRIO_PKT_BUF_Q0 0xAA
192#define KSZ8863_PM_USAGE_FLOW_CTRL_SEL_MODE1 0xAB
193#define KSZ8863_PM_USAGE_FLOW_CTRL_SEL_MODE2 0xAC
194#define KSZ8863_PM_USAGE_FLOW_CTRL_SEL_MODE3 0xAD
195#define KSZ8863_PM_USAGE_FLOW_CTRL_SEL_MODE4 0xAE
196#define KSZ8863_PORT1_Q3_TXQ_SPLIT 0xAF
197#define KSZ8863_PORT1_Q2_TXQ_SPLIT 0xB0
198#define KSZ8863_PORT1_Q1_TXQ_SPLIT 0xB1
199#define KSZ8863_PORT1_Q0_TXQ_SPLIT 0xB2
200#define KSZ8863_PORT2_Q3_TXQ_SPLIT 0xB3
201#define KSZ8863_PORT2_Q2_TXQ_SPLIT 0xB4
202#define KSZ8863_PORT2_Q1_TXQ_SPLIT 0xB5
203#define KSZ8863_PORT2_Q0_TXQ_SPLIT 0xB6
204#define KSZ8863_PORT3_Q3_TXQ_SPLIT 0xB7
205#define KSZ8863_PORT3_Q2_TXQ_SPLIT 0xB8
206#define KSZ8863_PORT3_Q1_TXQ_SPLIT 0xB9
207#define KSZ8863_PORT3_Q0_TXQ_SPLIT 0xBA
208#define KSZ8863_INT_EN 0xBB
209#define KSZ8863_LINK_CHANGE_INT 0xBC
210#define KSZ8863_FORCE_PAUSE_OFF_LIMIT_EN 0xBD
211#define KSZ8863_FIBER_SIGNAL_THRESHOLD 0xC0
212#define KSZ8863_INTERNAL_LDO_CTRL 0xC1
213#define KSZ8863_INSERT_SRC_PVID 0xC2
214#define KSZ8863_PWR_MGMT_LED_MODE 0xC3
215#define KSZ8863_SLEEP_MODE 0xC4
216#define KSZ8863_FWD_INVALID_VID_HOST_MODE 0xC6
219#define KSZ8863_PORTn_CTRL0(port) (0x00 + ((port) * 0x10))
220#define KSZ8863_PORTn_CTRL1(port) (0x01 + ((port) * 0x10))
221#define KSZ8863_PORTn_CTRL2(port) (0x02 + ((port) * 0x10))
222#define KSZ8863_PORTn_CTRL3(port) (0x03 + ((port) * 0x10))
223#define KSZ8863_PORTn_CTRL4(port) (0x04 + ((port) * 0x10))
224#define KSZ8863_PORTn_CTRL5(port) (0x05 + ((port) * 0x10))
225#define KSZ8863_PORTn_Q0_IG_LIMIT(port) (0x06 + ((port) * 0x10))
226#define KSZ8863_PORTn_Q1_IG_LIMIT(port) (0x07 + ((port) * 0x10))
227#define KSZ8863_PORTn_Q2_IG_LIMIT(port) (0x08 + ((port) * 0x10))
228#define KSZ8863_PORTn_Q3_IG_LIMIT(port) (0x09 + ((port) * 0x10))
229#define KSZ8863_PORTn_PSCS(port) (0x0A + ((port) * 0x10))
230#define KSZ8863_PORTn_LINKMD(port) (0x0B + ((port) * 0x10))
231#define KSZ8863_PORTn_CTRL12(port) (0x0C + ((port) * 0x10))
232#define KSZ8863_PORTn_CTRL13(port) (0x0D + ((port) * 0x10))
233#define KSZ8863_PORTn_STAT0(port) (0x0E + ((port) * 0x10))
234#define KSZ8863_PORTn_STAT1(port) (0x0F + ((port) * 0x10))
235#define KSZ8863_PORTn_Q0_EG_LIMIT(port) (0x96 + ((port) * 0x04))
236#define KSZ8863_PORTn_Q1_EG_LIMIT(port) (0x97 + ((port) * 0x04))
237#define KSZ8863_PORTn_Q2_EG_LIMIT(port) (0x98 + ((port) * 0x04))
238#define KSZ8863_PORTn_Q3_EG_LIMIT(port) (0x99 + ((port) * 0x04))
239#define KSZ8863_PORTn_Q3_TXQ_SPLIT(port) (0xAB + ((port) * 0x04))
240#define KSZ8863_PORTn_Q2_TXQ_SPLIT(port) (0xAC + ((port) * 0x04))
241#define KSZ8863_PORTn_Q1_TXQ_SPLIT(port) (0xAD + ((port) * 0x04))
242#define KSZ8863_PORTn_Q0_TXQ_SPLIT(port) (0xAE + ((port) * 0x04))
245#define KSZ8863_BMCR_RESET 0x8000
246#define KSZ8863_BMCR_LOOPBACK 0x4000
247#define KSZ8863_BMCR_FORCE_100 0x2000
248#define KSZ8863_BMCR_AN_EN 0x1000
249#define KSZ8863_BMCR_POWER_DOWN 0x0800
250#define KSZ8863_BMCR_ISOLATE 0x0400
251#define KSZ8863_BMCR_RESTART_AN 0x0200
252#define KSZ8863_BMCR_FORCE_FULL_DUPLEX 0x0100
253#define KSZ8863_BMCR_COL_TEST 0x0080
254#define KSZ8863_BMCR_HP_MDIX 0x0020
255#define KSZ8863_BMCR_FORCE_MDI 0x0010
256#define KSZ8863_BMCR_AUTO_MDIX_DIS 0x0008
257#define KSZ8863_BMCR_FAR_END_FAULT_DIS 0x0004
258#define KSZ8863_BMCR_TRANSMIT_DIS 0x0002
259#define KSZ8863_BMCR_LED_DIS 0x0001
262#define KSZ8863_BMSR_100BT4 0x8000
263#define KSZ8863_BMSR_100BTX_FD 0x4000
264#define KSZ8863_BMSR_100BTX_HD 0x2000
265#define KSZ8863_BMSR_10BT_FD 0x1000
266#define KSZ8863_BMSR_10BT_HD 0x0800
267#define KSZ8863_BMSR_PREAMBLE_SUPPR 0x0040
268#define KSZ8863_BMSR_AN_COMPLETE 0x0020
269#define KSZ8863_BMSR_FAR_END_FAULT 0x0010
270#define KSZ8863_BMSR_AN_CAPABLE 0x0008
271#define KSZ8863_BMSR_LINK_STATUS 0x0004
272#define KSZ8863_BMSR_JABBER_TEST 0x0002
273#define KSZ8863_BMSR_EXTENDED_CAPABLE 0x0001
276#define KSZ8863_PHYID1_DEFAULT 0x0022
279#define KSZ8863_PHYID2_DEFAULT 0x1430
282#define KSZ8863_ANAR_NEXT_PAGE 0x8000
283#define KSZ8863_ANAR_REMOTE_FAULT 0x2000
284#define KSZ8863_ANAR_PAUSE 0x0400
285#define KSZ8863_ANAR_100BTX_FD 0x0100
286#define KSZ8863_ANAR_100BTX_HD 0x0080
287#define KSZ8863_ANAR_10BT_FD 0x0040
288#define KSZ8863_ANAR_10BT_HD 0x0020
289#define KSZ8863_ANAR_SELECTOR 0x001F
290#define KSZ8863_ANAR_SELECTOR_DEFAULT 0x0001
293#define KSZ8863_ANLPAR_NEXT_PAGE 0x8000
294#define KSZ8863_ANLPAR_LP_ACK 0x4000
295#define KSZ8863_ANLPAR_REMOTE_FAULT 0x2000
296#define KSZ8863_ANLPAR_PAUSE 0x0400
297#define KSZ8863_ANLPAR_100BTX_FD 0x0100
298#define KSZ8863_ANLPAR_100BTX_HD 0x0080
299#define KSZ8863_ANLPAR_10BT_FD 0x0040
300#define KSZ8863_ANLPAR_10BT_HD 0x0020
303#define KSZ8863_LINKMD_TEST_EN 0x8000
304#define KSZ8863_LINKMD_RESULT 0x6000
305#define KSZ8863_LINKMD_SHORT 0x1000
306#define KSZ8863_LINKMD_FAULT_COUNT 0x01FF
309#define KSZ8863_PHYSCS_OP_MODE 0x0700
310#define KSZ8863_PHYSCS_OP_MODE_AN 0x0100
311#define KSZ8863_PHYSCS_OP_MODE_10BT_HD 0x0200
312#define KSZ8863_PHYSCS_OP_MODE_100BTX_HD 0x0300
313#define KSZ8863_PHYSCS_OP_MODE_10BT_FD 0x0500
314#define KSZ8863_PHYSCS_OP_MODE_100BTX_FD 0x0600
315#define KSZ8863_PHYSCS_OP_MODE_ISOLATE 0x0700
316#define KSZ8863_PHYSCS_POLRVS 0x0020
317#define KSZ8863_PHYSCS_MDIX_STATUS 0x0010
318#define KSZ8863_PHYSCS_FORCE_LINK 0x0008
319#define KSZ8863_PHYSCS_PWRSAVE 0x0004
320#define KSZ8863_PHYSCS_REMOTE_LOOPBACK 0x0002
323#define KSZ8863_CHIP_ID0_FAMILY_ID 0xFF
324#define KSZ8863_CHIP_ID0_FAMILY_ID_DEFAULT 0x88
327#define KSZ8863_CHIP_ID1_CHIP_ID 0xF0
328#define KSZ8863_CHIP_ID1_CHIP_ID_DEFAULT 0x30
329#define KSZ8863_CHIP_ID1_REVISION_ID 0x0E
330#define KSZ8863_CHIP_ID1_START_SWITCH 0x01
333#define KSZ8863_GLOBAL_CTRL0_NEW_BACK_OFF_EN 0x80
334#define KSZ8863_GLOBAL_CTRL0_FLUSH_DYNAMIC_MAC_TABLE 0x20
335#define KSZ8863_GLOBAL_CTRL0_FLUSH_STATIC_MAC_TABLE 0x10
336#define KSZ8863_GLOBAL_CTRL0_PASS_FLOW_CTRL_PKT 0x08
339#define KSZ8863_GLOBAL_CTRL1_PASS_ALL_FRAMES 0x80
340#define KSZ8863_GLOBAL_CTRL1_TAIL_TAG_EN 0x40
341#define KSZ8863_GLOBAL_CTRL1_TX_FLOW_CTRL_EN 0x20
342#define KSZ8863_GLOBAL_CTRL1_RX_FLOW_CTRL_EN 0x10
343#define KSZ8863_GLOBAL_CTRL1_FRAME_LEN_CHECK_EN 0x08
344#define KSZ8863_GLOBAL_CTRL1_AGING_EN 0x04
345#define KSZ8863_GLOBAL_CTRL1_FAST_AGE_EN 0x02
346#define KSZ8863_GLOBAL_CTRL1_AGGRESSIVE_BACK_OFF_EN 0x01
349#define KSZ8863_GLOBAL_CTRL2_UNI_VLAN_MISMATCH_DISCARD 0x80
350#define KSZ8863_GLOBAL_CTRL2_MCAST_STORM_PROTECT_DIS 0x40
351#define KSZ8863_GLOBAL_CTRL2_BACK_PRESSURE_MODE 0x20
352#define KSZ8863_GLOBAL_CTRL2_FLOW_CTRL_FAIR_MODE 0x10
353#define KSZ8863_GLOBAL_CTRL2_NO_EXCESSIVE_COL_DROP 0x08
354#define KSZ8863_GLOBAL_CTRL2_HUGE_PKT_SUPPORT 0x04
355#define KSZ8863_GLOBAL_CTRL2_MAX_PKT_SIZE_CHECK_EN 0x02
358#define KSZ8863_GLOBAL_CTRL3_VLAN_EN 0x80
359#define KSZ8863_GLOBAL_CTRL3_IGMP_SNOOP_EN 0x40
360#define KSZ8863_GLOBAL_CTRL3_WEIGHTED_FAIR_QUEUE_EN 0x08
361#define KSZ8863_GLOBAL_CTRL3_SNIFF_MODE_SEL 0x01
364#define KSZ8863_GLOBAL_CTRL4_SW_MII_HALF_DUPLEX_MODE 0x40
365#define KSZ8863_GLOBAL_CTRL4_SW_MII_FLOW_CTRL_EN 0x20
366#define KSZ8863_GLOBAL_CTRL4_SW_MII_10BT 0x10
367#define KSZ8863_GLOBAL_CTRL4_NULL_VID_REPLACEMENT 0x08
368#define KSZ8863_GLOBAL_CTRL4_BCAST_STORM_PROTECT_RATE_MSB 0x07
371#define KSZ8863_GLOBAL_CTRL5_BCAST_STORM_PROTECT_RATE_LSB 0xFF
374#define KSZ8863_GLOBAL_CTRL6_FACTORY_TESTING 0xFF
377#define KSZ8863_GLOBAL_CTRL7_FACTORY_TESTING 0xFF
380#define KSZ8863_GLOBAL_CTRL8_FACTORY_TESTING 0xFF
383#define KSZ8863_GLOBAL_CTRL9_CPU_IF_CLK_SEL 0xC0
384#define KSZ8863_GLOBAL_CTRL9_CPU_IF_CLK_SEL_31_25MHZ 0x00
385#define KSZ8863_GLOBAL_CTRL9_CPU_IF_CLK_SEL_62_5MHZ 0x40
386#define KSZ8863_GLOBAL_CTRL9_CPU_IF_CLK_SEL_125MHZ 0x80
389#define KSZ8863_GLOBAL_CTRL10_TAG3 0xC0
390#define KSZ8863_GLOBAL_CTRL10_TAG2 0x30
391#define KSZ8863_GLOBAL_CTRL10_TAG1 0x0C
392#define KSZ8863_GLOBAL_CTRL10_TAG0 0x03
395#define KSZ8863_GLOBAL_CTRL11_TAG7 0xC0
396#define KSZ8863_GLOBAL_CTRL11_TAG6 0x30
397#define KSZ8863_GLOBAL_CTRL11_TAG5 0x0C
398#define KSZ8863_GLOBAL_CTRL11_TAG4 0x03
401#define KSZ8863_GLOBAL_CTRL12_UNKNOWN_PKT_DEFAULT_PORT_EN 0x80
402#define KSZ8863_GLOBAL_CTRL12_DRIVER_STRENGTH 0x40
403#define KSZ8863_GLOBAL_CTRL12_DRIVER_STRENGTH_8MA 0x00
404#define KSZ8863_GLOBAL_CTRL12_DRIVER_STRENGTH_16MA 0x40
405#define KSZ8863_GLOBAL_CTRL12_UNKNOWN_PKT_DEFAULT_PORT 0x07
406#define KSZ8863_GLOBAL_CTRL12_UNKNOWN_PKT_DEFAULT_PORT_PORT1 0x01
407#define KSZ8863_GLOBAL_CTRL12_UNKNOWN_PKT_DEFAULT_PORT_PORT2 0x02
408#define KSZ8863_GLOBAL_CTRL12_UNKNOWN_PKT_DEFAULT_PORT_PORT3 0x04
411#define KSZ8863_GLOBAL_CTRL13_PHY_ADDR 0xF8
414#define KSZ8863_PORTn_CTRL0_BCAST_STORM_PROTECT_EN 0x80
415#define KSZ8863_PORTn_CTRL0_DIFFSERV_PRIO_CLASS_EN 0x40
416#define KSZ8863_PORTn_CTRL0_802_1P_PRIO_CLASS_EN 0x20
417#define KSZ8863_PORTn_CTRL0_PORT_PRIO_CLASS_EN 0x18
418#define KSZ8863_PORTn_CTRL0_TAG_INSERTION 0x04
419#define KSZ8863_PORTn_CTRL0_TAG_REMOVAL 0x02
420#define KSZ8863_PORTn_CTRL0_TXQ_SPLIT_EN 0x01
423#define KSZ8863_PORTn_CTRL1_SNIFFER_PORT 0x80
424#define KSZ8863_PORTn_CTRL1_RECEIVE_SNIFF 0x40
425#define KSZ8863_PORTn_CTRL1_TRANSMIT_SNIFF 0x20
426#define KSZ8863_PORTn_CTRL1_DOUBLE_TAG 0x10
427#define KSZ8863_PORTn_CTRL1_USER_PRIO_CEILING 0x08
428#define KSZ8863_PORTn_CTRL1_PORT_VLAN_MEMBERSHIP 0x07
431#define KSZ8863_PORTn_CTRL2_TWO_QUEUE_SPLIT_EN 0x80
432#define KSZ8863_PORTn_CTRL2_INGRESS_VLAN_FILT 0x40
433#define KSZ8863_PORTn_CTRL2_DISCARD_NON_PVID_PKT 0x20
434#define KSZ8863_PORTn_CTRL2_FORCE_FLOW_CTRL 0x10
435#define KSZ8863_PORTn_CTRL2_BACK_PRESSURE_EN 0x08
436#define KSZ8863_PORTn_CTRL2_TRANSMIT_EN 0x04
437#define KSZ8863_PORTn_CTRL2_RECEIVE_EN 0x02
438#define KSZ8863_PORTn_CTRL2_LEARNING_DIS 0x01
441#define KSZ8863_PORTn_CTRL3_DEFAULT_USER_PRIO 0xE0
442#define KSZ8863_PORTn_CTRL3_DEFAULT_CFI 0x10
443#define KSZ8863_PORTn_CTRL3_DEFAULT_VID_MSB 0x0F
446#define KSZ8863_PORTn_CTRL4_DEFAULT_VID_LSB 0xFF
449#define KSZ8863_PORTn_CTRL5_PORT3_MII_MODE_SEL 0x80
450#define KSZ8863_PORTn_CTRL5_PORT3_MII_MODE_SEL_PHY 0x00
451#define KSZ8863_PORTn_CTRL5_PORT3_MII_MODE_SEL_MAC 0x80
452#define KSZ8863_PORTn_CTRL5_SELF_ADDR_FILTER_EN_MACA1 0x40
453#define KSZ8863_PORTn_CTRL5_SELF_ADDR_FILTER_EN_MACA2 0x20
454#define KSZ8863_PORTn_CTRL5_DROP_IG_TAGGED_FRAME 0x10
455#define KSZ8863_PORTn_CTRL5_LIMIT_MODE 0x0C
456#define KSZ8863_PORTn_CTRL5_COUNT_IFG 0x02
457#define KSZ8863_PORTn_CTRL5_COUNT_PRE 0x01
460#define KSZ8863_PORTn_Q0_IG_LIMIT_RMII_REFCLK_INVERT 0x80
461#define KSZ8863_PORTn_Q0_IG_LIMIT_Q0_IG_DATA_RATE_LIMIT 0x7F
464#define KSZ8863_PORTn_Q1_IG_LIMIT_Q1_IG_DATA_RATE_LIMIT 0x7F
467#define KSZ8863_PORTn_Q2_IG_LIMIT_Q2_IG_DATA_RATE_LIMIT 0x7F
470#define KSZ8863_PORTn_Q3_IG_LIMIT_Q3_IG_DATA_RATE_LIMIT 0x7F
473#define KSZ8863_PORTn_PSCS_VCT_10M_SHORT 0x80
474#define KSZ8863_PORTn_PSCS_VCT_RESULT 0x60
475#define KSZ8863_PORTn_PSCS_VCT_EN 0x10
476#define KSZ8863_PORTn_PSCS_FORCE_LNK 0x08
477#define KSZ8863_PORTn_PSCS_REMOTE_LOOPBACK 0x02
478#define KSZ8863_PORTn_PSCS_VCT_FAULT_COUNT_MSB 0x01
481#define KSZ8863_PORTn_LINKMD_VCT_FAULT_COUNT_LSB 0xFF
484#define KSZ8863_PORTn_CTRL12_AN_EN 0x80
485#define KSZ8863_PORTn_CTRL12_FORCE_SPEED 0x40
486#define KSZ8863_PORTn_CTRL12_FORCE_DUPLEX 0x20
487#define KSZ8863_PORTn_CTRL12_ADV_FLOW_CTRL 0x10
488#define KSZ8863_PORTn_CTRL12_ADV_100BT_FD 0x08
489#define KSZ8863_PORTn_CTRL12_ADV_100BT_HD 0x04
490#define KSZ8863_PORTn_CTRL12_ADV_10BT_FD 0x02
491#define KSZ8863_PORTn_CTRL12_ADV_10BT_HD 0x01
494#define KSZ8863_PORTn_CTRL13_LED_OFF 0x80
495#define KSZ8863_PORTn_CTRL13_TX_DIS 0x40
496#define KSZ8863_PORTn_CTRL13_RESTART_AN 0x20
497#define KSZ8863_PORTn_CTRL13_FAR_END_FAULT_DIS 0x10
498#define KSZ8863_PORTn_CTRL13_POWER_DOWN 0x08
499#define KSZ8863_PORTn_CTRL13_AUTO_MDIX_DIS 0x04
500#define KSZ8863_PORTn_CTRL13_FORCE_MDI 0x02
501#define KSZ8863_PORTn_CTRL13_LOOPBACK 0x01
504#define KSZ8863_PORTn_STAT0_MDIX_STATUS 0x80
505#define KSZ8863_PORTn_STAT0_AN_DONE 0x40
506#define KSZ8863_PORTn_STAT0_LINK_GOOD 0x20
507#define KSZ8863_PORTn_STAT0_LP_FLOW_CTRL_CAPABLE 0x10
508#define KSZ8863_PORTn_STAT0_LP_100BTX_FD_CAPABLE 0x08
509#define KSZ8863_PORTn_STAT0_LP_100BTX_HF_CAPABLE 0x04
510#define KSZ8863_PORTn_STAT0_LP_10BT_FD_CAPABLE 0x02
511#define KSZ8863_PORTn_STAT0_LP_10BT_HD_CAPABLE 0x01
514#define KSZ8863_PORTn_STAT1_HP_MDIX 0x80
515#define KSZ8863_PORTn_STAT1_POLRVS 0x20
516#define KSZ8863_PORTn_STAT1_TX_FLOW_CTRL_EN 0x10
517#define KSZ8863_PORTn_STAT1_RX_FLOW_CTRL_EN 0x08
518#define KSZ8863_PORTn_STAT1_OP_SPEED 0x04
519#define KSZ8863_PORTn_STAT1_OP_DUPLEX 0x02
520#define KSZ8863_PORTn_STAT1_FAR_END_FAULT 0x01
523#define KSZ8863_RESET_SOFT_RESET 0x10
524#define KSZ8863_RESET_PCS_RESET 0x01
527#define KSZ8863_INDIRECT_CTRL0_WRITE 0x00
528#define KSZ8863_INDIRECT_CTRL0_READ 0x10
529#define KSZ8863_INDIRECT_CTRL0_TABLE_SEL 0x0C
530#define KSZ8863_INDIRECT_CTRL0_TABLE_SEL_STATIC_MAC 0x00
531#define KSZ8863_INDIRECT_CTRL0_TABLE_SEL_VLAN 0x04
532#define KSZ8863_INDIRECT_CTRL0_TABLE_SEL_DYNAMIC_MAC 0x08
533#define KSZ8863_INDIRECT_CTRL0_TABLE_SEL_MIB_COUNTER 0x0C
534#define KSZ8863_INDIRECT_CTRL0_ADDR_H 0x03
537#define KSZ8863_INDIRECT_CTRL1_ADDR_L 0xFF
540#define KSZ8863_INDIRECT_DATA8_CPU_READ_STATUS 0x80
541#define KSZ8863_INDIRECT_DATA8_DATA 0x07
544#define KSZ8863_MODE_INDICATOR_FLL 0x41
545#define KSZ8863_MODE_INDICATOR_MLL 0x43
546#define KSZ8863_MODE_INDICATOR_RLL 0x53
549#define KSZ8863_PORTn_Q3_TXQ_SPLIT_PRIORITY_SEL 0x80
552#define KSZ8863_PORTn_Q2_TXQ_SPLIT_PRIORITY_SEL 0x80
555#define KSZ8863_PORTn_Q1_TXQ_SPLIT_PRIORITY_SEL 0x80
558#define KSZ8863_PORTn_Q0_TXQ_SPLIT_PRIORITY_SEL 0x80
561#define KSZ8863_INT_EN_P1_OR_P2_LC_INT 0x80
562#define KSZ8863_INT_EN_P3_LC_INT 0x04
563#define KSZ8863_INT_EN_P2_LC_INT 0x02
564#define KSZ8863_INT_EN_P1_LC_INT 0x01
567#define KSZ8863_LINK_CHANGE_INT_P1_OR_P2_LC_INT 0x80
568#define KSZ8863_LINK_CHANGE_INT_P3_LC_INT 0x04
569#define KSZ8863_LINK_CHANGE_INT_P2_LC_INT 0x02
570#define KSZ8863_LINK_CHANGE_INT_P1_LC_INT 0x01
573#define KSZ8863_FIBER_SIGNAL_THRESHOLD_P2_THRESHOLD 0x80
574#define KSZ8863_FIBER_SIGNAL_THRESHOLD_P2_THRESHOLD_1_2V 0x00
575#define KSZ8863_FIBER_SIGNAL_THRESHOLD_P2_THRESHOLD_2_0V 0x80
576#define KSZ8863_FIBER_SIGNAL_THRESHOLD_P1_THRESHOLD 0x40
577#define KSZ8863_FIBER_SIGNAL_THRESHOLD_P1_THRESHOLD_1_2V 0x00
578#define KSZ8863_FIBER_SIGNAL_THRESHOLD_P1_THRESHOLD_2_0V 0x40
581#define KSZ8863_INTERNAL_LDO_CTRL_INTERNAL_LDO_DIS 0x40
584#define KSZ8863_INSERT_SRC_PVID_INSERT_SRC_P1_PVID_AT_P2 0x20
585#define KSZ8863_INSERT_SRC_PVID_INSERT_SRC_P1_PVID_AT_P3 0x10
586#define KSZ8863_INSERT_SRC_PVID_INSERT_SRC_P2_PVID_AT_P1 0x08
587#define KSZ8863_INSERT_SRC_PVID_INSERT_SRC_P2_PVID_AT_P3 0x04
588#define KSZ8863_INSERT_SRC_PVID_INSERT_SRC_P3_PVID_AT_P1 0x02
589#define KSZ8863_INSERT_SRC_PVID_INSERT_SRC_P3_PVID_AT_P2 0x01
592#define KSZ8863_PWR_MGMT_LED_MODE_CPU_IF_POWER_DOWN 0x80
593#define KSZ8863_PWR_MGMT_LED_MODE_SWITCH_POWER_DOWN 0x40
594#define KSZ8863_PWR_MGMT_LED_MODE_LED_MODE 0x30
595#define KSZ8863_PWR_MGMT_LED_MODE_LED_MODE_LED0_LNK_ACT_LED1_SPD 0x00
596#define KSZ8863_PWR_MGMT_LED_MODE_LED_MODE_LED0_LNK_LED1_ACT 0x10
597#define KSZ8863_PWR_MGMT_LED_MODE_LED_MODE_LED0_LNK_ACT_LED1_DPLX 0x20
598#define KSZ8863_PWR_MGMT_LED_MODE_LED_MODE_LED0_LNK_LED1_DPLX 0x30
599#define KSZ8863_PWR_MGMT_LED_MODE_LED_OUT_MODE 0x08
600#define KSZ8863_PWR_MGMT_LED_MODE_PLL_OFF_EN 0x04
601#define KSZ8863_PWR_MGMT_LED_MODE_POWER_MGMT_MODE 0x03
604#define KSZ8863_FWD_INVALID_VID_HOST_MODE_FWD_INVALID_VID_FRAME 0x70
605#define KSZ8863_FWD_INVALID_VID_HOST_MODE_P3_RMII_CLK_SEL 0x08
606#define KSZ8863_FWD_INVALID_VID_HOST_MODE_P3_RMII_CLK_SEL_EXTERNAL 0x00
607#define KSZ8863_FWD_INVALID_VID_HOST_MODE_P3_RMII_CLK_SEL_INTERNAL 0x08
608#define KSZ8863_FWD_INVALID_VID_HOST_MODE_P1_RMII_CLK_SEL 0x04
609#define KSZ8863_FWD_INVALID_VID_HOST_MODE_P1_RMII_CLK_SEL_EXTERNAL 0x00
610#define KSZ8863_FWD_INVALID_VID_HOST_MODE_P1_RMII_CLK_SEL_INTERNAL 0x04
611#define KSZ8863_FWD_INVALID_VID_HOST_MODE_HOST_MODE 0x03
612#define KSZ8863_FWD_INVALID_VID_HOST_MODE_HOST_MODE_I2C_MASTER 0x00
613#define KSZ8863_FWD_INVALID_VID_HOST_MODE_HOST_MODE_I2C_SLAVE 0x01
614#define KSZ8863_FWD_INVALID_VID_HOST_MODE_HOST_MODE_SPI_SLAVE 0x02
615#define KSZ8863_FWD_INVALID_VID_HOST_MODE_HOST_MODE_SMI 0x03
623#if defined(__CWCC__) || defined(_WIN32)
624 #pragma pack(push, 1)
634#if defined(_CPU_BIG_ENDIAN) && !defined(__ICCRX__)
635 uint8_t reserved : 6;
639 uint8_t override : 1;
641 uint8_t forwardPorts : 3;
644 uint8_t reserved : 6;
645 uint8_t forwardPorts : 3;
647 uint8_t override : 1;
661#if defined(_CPU_BIG_ENDIAN) && !defined(__ICCRX__)
662 uint8_t dataNotReady : 1;
663 uint8_t reserved : 4;
664 uint8_t macEmpty : 1;
665 uint8_t numValidEntriesH : 2;
666 uint8_t numValidEntriesL;
667 uint8_t timestamp : 2;
668 uint8_t sourcePort : 2;
671 uint8_t numValidEntriesH : 2;
672 uint8_t macEmpty : 1;
673 uint8_t reserved : 4;
674 uint8_t dataNotReady : 1;
675 uint8_t numValidEntriesL;
677 uint8_t sourcePort : 2;
678 uint8_t timestamp : 2;
685#if defined(__CWCC__) || defined(_WIN32)
693error_t ksz8863Init(NetInterface *interface);
694void ksz8863InitHook(NetInterface *interface);
696void ksz8863Tick(NetInterface *interface);
698void ksz8863EnableIrq(NetInterface *interface);
699void ksz8863DisableIrq(NetInterface *interface);
701void ksz8863EventHandler(NetInterface *interface);
704 size_t *offset, NetTxAncillary *ancillary);
706error_t ksz8863UntagFrame(NetInterface *interface, uint8_t **frame,
707 size_t *length, NetRxAncillary *ancillary);
709bool_t ksz8863GetLinkState(NetInterface *interface, uint8_t port);
710uint32_t ksz8863GetLinkSpeed(NetInterface *interface, uint8_t port);
711NicDuplexMode ksz8863GetDuplexMode(NetInterface *interface, uint8_t port);
713void ksz8863SetPortState(NetInterface *interface, uint8_t port,
716SwitchPortState ksz8863GetPortState(NetInterface *interface, uint8_t port);
718void ksz8863SetAgingTime(NetInterface *interface, uint32_t agingTime);
720void ksz8863EnableIgmpSnooping(NetInterface *interface, bool_t enable);
721void ksz8863EnableMldSnooping(NetInterface *interface, bool_t enable);
722void ksz8863EnableRsvdMcastTable(NetInterface *interface, bool_t enable);
724error_t ksz8863AddStaticFdbEntry(NetInterface *interface,
727error_t ksz8863DeleteStaticFdbEntry(NetInterface *interface,
730error_t ksz8863GetStaticFdbEntry(NetInterface *interface, uint_t index,
733void ksz8863FlushStaticFdbTable(NetInterface *interface);
735error_t ksz8863GetDynamicFdbEntry(NetInterface *interface, uint_t index,
738void ksz8863FlushDynamicFdbTable(NetInterface *interface, uint8_t port);
740void ksz8863SetUnknownMcastFwdPorts(NetInterface *interface,
741 bool_t enable, uint32_t forwardPorts);
743void ksz8863WritePhyReg(NetInterface *interface, uint8_t port,
744 uint8_t address, uint16_t data);
746uint16_t ksz8863ReadPhyReg(NetInterface *interface, uint8_t port,
749void ksz8863DumpPhyReg(NetInterface *interface, uint8_t port);
751void ksz8863WriteSwitchReg(NetInterface *interface, uint8_t address,
754uint8_t ksz8863ReadSwitchReg(NetInterface *interface, uint8_t address);
756void ksz8863DumpSwitchReg(NetInterface *interface);
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 ksz8863_driver.h:660
Static MAC table entry.
Definition ksz8863_driver.h:633
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