31#ifndef _KSZ8031_DRIVER_H
32#define _KSZ8031_DRIVER_H
38#ifndef KSZ8031_PHY_ADDR
39 #define KSZ8031_PHY_ADDR 0
40#elif (KSZ8031_PHY_ADDR < 0 || KSZ8031_PHY_ADDR > 31)
41 #error KSZ8031_PHY_ADDR parameter is not valid
45#define KSZ8031_BMCR 0x00
46#define KSZ8031_BMSR 0x01
47#define KSZ8031_PHYID1 0x02
48#define KSZ8031_PHYID2 0x03
49#define KSZ8031_ANAR 0x04
50#define KSZ8031_ANLPAR 0x05
51#define KSZ8031_ANER 0x06
52#define KSZ8031_ANNPR 0x07
53#define KSZ8031_ANLPNPR 0x08
54#define KSZ8031_DRCON 0x10
55#define KSZ8031_AFECON1 0x11
56#define KSZ8031_RXERCTR 0x15
57#define KSZ8031_OMSO 0x16
58#define KSZ8031_OMSS 0x17
59#define KSZ8031_EXCON 0x18
60#define KSZ8031_ICSR 0x1B
61#define KSZ8031_LINKMD 0x1D
62#define KSZ8031_PHYCON1 0x1E
63#define KSZ8031_PHYCON2 0x1F
66#define KSZ8031_BMCR_RESET 0x8000
67#define KSZ8031_BMCR_LOOPBACK 0x4000
68#define KSZ8031_BMCR_SPEED_SEL 0x2000
69#define KSZ8031_BMCR_AN_EN 0x1000
70#define KSZ8031_BMCR_POWER_DOWN 0x0800
71#define KSZ8031_BMCR_ISOLATE 0x0400
72#define KSZ8031_BMCR_RESTART_AN 0x0200
73#define KSZ8031_BMCR_DUPLEX_MODE 0x0100
74#define KSZ8031_BMCR_COL_TEST 0x0080
77#define KSZ8031_BMSR_100BT4 0x8000
78#define KSZ8031_BMSR_100BTX_FD 0x4000
79#define KSZ8031_BMSR_100BTX_HD 0x2000
80#define KSZ8031_BMSR_10BT_FD 0x1000
81#define KSZ8031_BMSR_10BT_HD 0x0800
82#define KSZ8031_BMSR_NO_PREAMBLE 0x0040
83#define KSZ8031_BMSR_AN_COMPLETE 0x0020
84#define KSZ8031_BMSR_REMOTE_FAULT 0x0010
85#define KSZ8031_BMSR_AN_CAPABLE 0x0008
86#define KSZ8031_BMSR_LINK_STATUS 0x0004
87#define KSZ8031_BMSR_JABBER_DETECT 0x0002
88#define KSZ8031_BMSR_EXTENDED_CAPABLE 0x0001
91#define KSZ8031_PHYID1_PHY_ID_MSB 0xFFFF
92#define KSZ8031_PHYID1_PHY_ID_MSB_DEFAULT 0x0022
95#define KSZ8031_PHYID2_PHY_ID_LSB 0xFC00
96#define KSZ8031_PHYID2_PHY_ID_LSB_DEFAULT 0x1400
97#define KSZ8031_PHYID2_MODEL_NUM 0x03F0
98#define KSZ8031_PHYID2_MODEL_NUM_DEFAULT 0x0150
99#define KSZ8031_PHYID2_REVISION_NUM 0x000F
102#define KSZ8031_ANAR_NEXT_PAGE 0x8000
103#define KSZ8031_ANAR_REMOTE_FAULT 0x2000
104#define KSZ8031_ANAR_PAUSE 0x0C00
105#define KSZ8031_ANAR_100BT4 0x0200
106#define KSZ8031_ANAR_100BTX_FD 0x0100
107#define KSZ8031_ANAR_100BTX_HD 0x0080
108#define KSZ8031_ANAR_10BT_FD 0x0040
109#define KSZ8031_ANAR_10BT_HD 0x0020
110#define KSZ8031_ANAR_SELECTOR 0x001F
111#define KSZ8031_ANAR_SELECTOR_DEFAULT 0x0001
114#define KSZ8031_ANLPAR_NEXT_PAGE 0x8000
115#define KSZ8031_ANLPAR_ACK 0x4000
116#define KSZ8031_ANLPAR_REMOTE_FAULT 0x2000
117#define KSZ8031_ANLPAR_PAUSE 0x0C00
118#define KSZ8031_ANLPAR_100BT4 0x0200
119#define KSZ8031_ANLPAR_100BTX_FD 0x0100
120#define KSZ8031_ANLPAR_100BTX_HD 0x0080
121#define KSZ8031_ANLPAR_10BT_FD 0x0040
122#define KSZ8031_ANLPAR_10BT_HD 0x0020
123#define KSZ8031_ANLPAR_SELECTOR 0x001F
124#define KSZ8031_ANLPAR_SELECTOR_DEFAULT 0x0001
127#define KSZ8031_ANER_PAR_DETECT_FAULT 0x0010
128#define KSZ8031_ANER_LP_NEXT_PAGE_ABLE 0x0008
129#define KSZ8031_ANER_NEXT_PAGE_ABLE 0x0004
130#define KSZ8031_ANER_PAGE_RECEIVED 0x0002
131#define KSZ8031_ANER_LP_AN_ABLE 0x0001
134#define KSZ8031_ANNPR_NEXT_PAGE 0x8000
135#define KSZ8031_ANNPR_MSG_PAGE 0x2000
136#define KSZ8031_ANNPR_ACK2 0x1000
137#define KSZ8031_ANNPR_TOGGLE 0x0800
138#define KSZ8031_ANNPR_MESSAGE 0x07FF
141#define KSZ8031_ANLPNPR_NEXT_PAGE 0x8000
142#define KSZ8031_ANLPNPR_ACK 0x4000
143#define KSZ8031_ANLPNPR_MSG_PAGE 0x2000
144#define KSZ8031_ANLPNPR_ACK2 0x1000
145#define KSZ8031_ANLPNPR_TOGGLE 0x0800
146#define KSZ8031_ANLPNPR_MESSAGE 0x07FF
149#define KSZ8031_DRCON_PLL_OFF 0x0010
152#define KSZ8031_AFECON1_SLOW_OSC_MODE_EN 0x0020
155#define KSZ8031_OMSO_RMII_BTB_OVERRIDE 0x0040
156#define KSZ8031_OMSO_NAND_TREE_OVERRIDE 0x0020
157#define KSZ8031_OMSO_RMII_OVERRIDE 0x0002
160#define KSZ8031_OMSS_PHYAD 0xE000
161#define KSZ8031_OMSS_RMII_STRAP_STATUS 0x0002
164#define KSZ8031_EXCON_EDPD_DIS 0x0800
167#define KSZ8031_ICSR_JABBER_IE 0x8000
168#define KSZ8031_ICSR_RECEIVE_ERROR_IE 0x4000
169#define KSZ8031_ICSR_PAGE_RECEIVED_IE 0x2000
170#define KSZ8031_ICSR_PAR_DETECT_FAULT_IE 0x1000
171#define KSZ8031_ICSR_LP_ACK_IE 0x0800
172#define KSZ8031_ICSR_LINK_DOWN_IE 0x0400
173#define KSZ8031_ICSR_REMOTE_FAULT_IE 0x0200
174#define KSZ8031_ICSR_LINK_UP_IE 0x0100
175#define KSZ8031_ICSR_JABBER_IF 0x0080
176#define KSZ8031_ICSR_RECEIVE_ERROR_IF 0x0040
177#define KSZ8031_ICSR_PAGE_RECEIVED_IF 0x0020
178#define KSZ8031_ICSR_PAR_DETECT_FAULT_IF 0x0010
179#define KSZ8031_ICSR_LP_ACK_IF 0x0008
180#define KSZ8031_ICSR_LINK_DOWN_IF 0x0004
181#define KSZ8031_ICSR_REMOTE_FAULT_IF 0x0002
182#define KSZ8031_ICSR_LINK_UP_IF 0x0001
185#define KSZ8031_LINKMD_TEST_EN 0x8000
186#define KSZ8031_LINKMD_RESULT 0x6000
187#define KSZ8031_LINKMD_SHORT 0x1000
188#define KSZ8031_LINKMD_FAULT_COUNT 0x01FF
191#define KSZ8031_PHYCON1_PAUSE_EN 0x0200
192#define KSZ8031_PHYCON1_LINK_STATUS 0x0100
193#define KSZ8031_PHYCON1_POL_STATUS 0x0080
194#define KSZ8031_PHYCON1_MDIX_STATE 0x0020
195#define KSZ8031_PHYCON1_ENERGY_DETECT 0x0010
196#define KSZ8031_PHYCON1_PHY_ISOLATE 0x0008
197#define KSZ8031_PHYCON1_OP_MODE 0x0007
198#define KSZ8031_PHYCON1_OP_MODE_AN 0x0000
199#define KSZ8031_PHYCON1_OP_MODE_10BT_HD 0x0001
200#define KSZ8031_PHYCON1_OP_MODE_100BTX_HD 0x0002
201#define KSZ8031_PHYCON1_OP_MODE_10BT_FD 0x0005
202#define KSZ8031_PHYCON1_OP_MODE_100BTX_FD 0x0006
205#define KSZ8031_PHYCON2_HP_MDIX 0x8000
206#define KSZ8031_PHYCON2_MDIX_SEL 0x4000
207#define KSZ8031_PHYCON2_PAIR_SWAP_DIS 0x2000
208#define KSZ8031_PHYCON2_FORCE_LINK 0x0800
209#define KSZ8031_PHYCON2_POWER_SAVING 0x0400
210#define KSZ8031_PHYCON2_INT_LEVEL 0x0200
211#define KSZ8031_PHYCON2_JABBER_EN 0x0100
212#define KSZ8031_PHYCON2_RMII_REF_CLK_SEL 0x0080
213#define KSZ8031_PHYCON2_LED_MODE 0x0030
214#define KSZ8031_PHYCON2_TX_DIS 0x0008
215#define KSZ8031_PHYCON2_REMOTE_LOOPBACK 0x0004
216#define KSZ8031_PHYCON2_DATA_SCRAMBLING_DIS 0x0001
227error_t ksz8031Init(NetInterface *interface);
228void ksz8031InitHook(NetInterface *interface);
230void ksz8031Tick(NetInterface *interface);
232void ksz8031EnableIrq(NetInterface *interface);
233void ksz8031DisableIrq(NetInterface *interface);
235void ksz8031EventHandler(NetInterface *interface);
237void ksz8031WritePhyReg(NetInterface *interface, uint8_t address,
240uint16_t ksz8031ReadPhyReg(NetInterface *interface, uint8_t address);
242void ksz8031DumpPhyReg(NetInterface *interface);
error_t
Error codes.
Definition error.h:43
Network interface controller abstraction layer.
Ethernet PHY driver.
Definition nic.h:308