Go to the documentation of this file.
31 #ifndef _KSZ8081_DRIVER_H
32 #define _KSZ8081_DRIVER_H
38 #ifndef KSZ8081_PHY_ADDR
39 #define KSZ8081_PHY_ADDR 0
40 #elif (KSZ8081_PHY_ADDR < 0 || KSZ8081_PHY_ADDR > 31)
41 #error KSZ8081_PHY_ADDR parameter is not valid
45 #ifndef KSZ8081_50MHZ_CLOCK_MODE_SUPPORT
46 #define KSZ8081_50MHZ_CLOCK_MODE_SUPPORT DISABLED
47 #elif (KSZ8081_50MHZ_CLOCK_MODE_SUPPORT != ENABLED && KSZ8081_50MHZ_CLOCK_MODE_SUPPORT != DISABLED)
48 #error KSZ8081_50MHZ_CLOCK_MODE_SUPPORT parameter is not valid
52 #define KSZ8081_BMCR 0x00
53 #define KSZ8081_BMSR 0x01
54 #define KSZ8081_PHYID1 0x02
55 #define KSZ8081_PHYID2 0x03
56 #define KSZ8081_ANAR 0x04
57 #define KSZ8081_ANLPAR 0x05
58 #define KSZ8081_ANER 0x06
59 #define KSZ8081_ANNPR 0x07
60 #define KSZ8081_ANLPNPR 0x08
61 #define KSZ8081_DRCON 0x10
62 #define KSZ8081_AFECON1 0x11
63 #define KSZ8081_RXERCTR 0x15
64 #define KSZ8081_OMSO 0x16
65 #define KSZ8081_OMSS 0x17
66 #define KSZ8081_EXCON 0x18
67 #define KSZ8081_ICSR 0x1B
68 #define KSZ8081_LINKMD 0x1D
69 #define KSZ8081_PHYCON1 0x1E
70 #define KSZ8081_PHYCON2 0x1F
73 #define KSZ8081_BMCR_RESET 0x8000
74 #define KSZ8081_BMCR_LOOPBACK 0x4000
75 #define KSZ8081_BMCR_SPEED_SEL 0x2000
76 #define KSZ8081_BMCR_AN_EN 0x1000
77 #define KSZ8081_BMCR_POWER_DOWN 0x0800
78 #define KSZ8081_BMCR_ISOLATE 0x0400
79 #define KSZ8081_BMCR_RESTART_AN 0x0200
80 #define KSZ8081_BMCR_DUPLEX_MODE 0x0100
81 #define KSZ8081_BMCR_COL_TEST 0x0080
84 #define KSZ8081_BMSR_100BT4 0x8000
85 #define KSZ8081_BMSR_100BTX_FD 0x4000
86 #define KSZ8081_BMSR_100BTX_HD 0x2000
87 #define KSZ8081_BMSR_10BT_FD 0x1000
88 #define KSZ8081_BMSR_10BT_HD 0x0800
89 #define KSZ8081_BMSR_NO_PREAMBLE 0x0040
90 #define KSZ8081_BMSR_AN_COMPLETE 0x0020
91 #define KSZ8081_BMSR_REMOTE_FAULT 0x0010
92 #define KSZ8081_BMSR_AN_CAPABLE 0x0008
93 #define KSZ8081_BMSR_LINK_STATUS 0x0004
94 #define KSZ8081_BMSR_JABBER_DETECT 0x0002
95 #define KSZ8081_BMSR_EXTENDED_CAPABLE 0x0001
98 #define KSZ8081_PHYID1_PHY_ID_MSB 0xFFFF
99 #define KSZ8081_PHYID1_PHY_ID_MSB_DEFAULT 0x0022
102 #define KSZ8081_PHYID2_PHY_ID_LSB 0xFC00
103 #define KSZ8081_PHYID2_PHY_ID_LSB_DEFAULT 0x1400
104 #define KSZ8081_PHYID2_MODEL_NUM 0x03F0
105 #define KSZ8081_PHYID2_MODEL_NUM_DEFAULT 0x0160
106 #define KSZ8081_PHYID2_REVISION_NUM 0x000F
109 #define KSZ8081_ANAR_NEXT_PAGE 0x8000
110 #define KSZ8081_ANAR_REMOTE_FAULT 0x2000
111 #define KSZ8081_ANAR_PAUSE 0x0C00
112 #define KSZ8081_ANAR_100BT4 0x0200
113 #define KSZ8081_ANAR_100BTX_FD 0x0100
114 #define KSZ8081_ANAR_100BTX_HD 0x0080
115 #define KSZ8081_ANAR_10BT_FD 0x0040
116 #define KSZ8081_ANAR_10BT_HD 0x0020
117 #define KSZ8081_ANAR_SELECTOR 0x001F
118 #define KSZ8081_ANAR_SELECTOR_DEFAULT 0x0001
121 #define KSZ8081_ANLPAR_NEXT_PAGE 0x8000
122 #define KSZ8081_ANLPAR_ACK 0x4000
123 #define KSZ8081_ANLPAR_REMOTE_FAULT 0x2000
124 #define KSZ8081_ANLPAR_PAUSE 0x0C00
125 #define KSZ8081_ANLPAR_100BT4 0x0200
126 #define KSZ8081_ANLPAR_100BTX_FD 0x0100
127 #define KSZ8081_ANLPAR_100BTX_HD 0x0080
128 #define KSZ8081_ANLPAR_10BT_FD 0x0040
129 #define KSZ8081_ANLPAR_10BT_HD 0x0020
130 #define KSZ8081_ANLPAR_SELECTOR 0x001F
131 #define KSZ8081_ANLPAR_SELECTOR_DEFAULT 0x0001
134 #define KSZ8081_ANER_PAR_DETECT_FAULT 0x0010
135 #define KSZ8081_ANER_LP_NEXT_PAGE_ABLE 0x0008
136 #define KSZ8081_ANER_NEXT_PAGE_ABLE 0x0004
137 #define KSZ8081_ANER_PAGE_RECEIVED 0x0002
138 #define KSZ8081_ANER_LP_AN_ABLE 0x0001
141 #define KSZ8081_ANNPR_MSG_PAGE 0x2000
142 #define KSZ8081_ANNPR_ACK2 0x1000
143 #define KSZ8081_ANNPR_TOGGLE 0x0800
144 #define KSZ8081_ANNPR_MESSAGE 0x07FF
147 #define KSZ8081_ANLPNPR_NEXT_PAGE 0x8000
148 #define KSZ8081_ANLPNPR_ACK 0x4000
149 #define KSZ8081_ANLPNPR_MSG_PAGE 0x2000
150 #define KSZ8081_ANLPNPR_ACK2 0x1000
151 #define KSZ8081_ANLPNPR_TOGGLE 0x0800
152 #define KSZ8081_ANLPNPR_MESSAGE 0x07FF
155 #define KSZ8081_DRCON_PLL_OFF 0x0010
158 #define KSZ8081_AFECON1_SLOW_OSC_MODE_EN 0x0020
161 #define KSZ8081_OMSO_FACTORY_TEST_MODE 0x8000
162 #define KSZ8081_OMSO_BCAST_OFF_OVERRIDE 0x0200
163 #define KSZ8081_OMSO_MII_BTB_OVERRIDE 0x0080
164 #define KSZ8081_OMSO_RMII_BTB_OVERRIDE 0x0040
165 #define KSZ8081_OMSO_NAND_TREE_OVERRIDE 0x0020
166 #define KSZ8081_OMSO_RMII_OVERRIDE 0x0002
167 #define KSZ8081_OMSO_MII_OVERRIDE 0x0001
170 #define KSZ8081_OMSS_PHYAD 0xE000
171 #define KSZ8081_OMSS_BCAST_OFF_STRAP_STATUS 0x0200
172 #define KSZ8081_OMSS_MII_BTB_STRAP_STATUS 0x0080
173 #define KSZ8081_OMSS_RMII_BTB_STRAP_STATUS 0x0040
174 #define KSZ8081_OMSS_NAND_TREE_STRAP_STATUS 0x0020
175 #define KSZ8081_OMSS_RMII_STRAP_STATUS 0x0002
176 #define KSZ8081_OMSS_MII_STRAP_STATUS 0x0001
179 #define KSZ8081_EXCON_EDPD_DIS 0x0800
180 #define KSZ8081_EXCON_100BTX_LATENCY 0x0400
181 #define KSZ8081_EXCON_10BT_PREAMBLE_RESTORE 0x0040
184 #define KSZ8081_ICSR_JABBER_IE 0x8000
185 #define KSZ8081_ICSR_RECEIVE_ERROR_IE 0x4000
186 #define KSZ8081_ICSR_PAGE_RECEIVED_IE 0x2000
187 #define KSZ8081_ICSR_PAR_DETECT_FAULT_IE 0x1000
188 #define KSZ8081_ICSR_LP_ACK_IE 0x0800
189 #define KSZ8081_ICSR_LINK_DOWN_IE 0x0400
190 #define KSZ8081_ICSR_REMOTE_FAULT_IE 0x0200
191 #define KSZ8081_ICSR_LINK_UP_IE 0x0100
192 #define KSZ8081_ICSR_JABBER_IF 0x0080
193 #define KSZ8081_ICSR_RECEIVE_ERROR_IF 0x0040
194 #define KSZ8081_ICSR_PAGE_RECEIVED_IF 0x0020
195 #define KSZ8081_ICSR_PAR_DETECT_FAULT_IF 0x0010
196 #define KSZ8081_ICSR_LP_ACK_IF 0x0008
197 #define KSZ8081_ICSR_LINK_DOWN_IF 0x0004
198 #define KSZ8081_ICSR_REMOTE_FAULT_IF 0x0002
199 #define KSZ8081_ICSR_LINK_UP_IF 0x0001
202 #define KSZ8081_LINKMD_TEST_EN 0x8000
203 #define KSZ8081_LINKMD_RESULT 0x6000
204 #define KSZ8081_LINKMD_SHORT 0x1000
205 #define KSZ8081_LINKMD_FAULT_COUNT 0x01FF
208 #define KSZ8081_PHYCON1_PAUSE_EN 0x0200
209 #define KSZ8081_PHYCON1_LINK_STATUS 0x0100
210 #define KSZ8081_PHYCON1_POL_STATUS 0x0080
211 #define KSZ8081_PHYCON1_MDIX_STATE 0x0020
212 #define KSZ8081_PHYCON1_ENERGY_DETECT 0x0010
213 #define KSZ8081_PHYCON1_PHY_ISOLATE 0x0008
214 #define KSZ8081_PHYCON1_OP_MODE 0x0007
215 #define KSZ8081_PHYCON1_OP_MODE_AN 0x0000
216 #define KSZ8081_PHYCON1_OP_MODE_10BT_HD 0x0001
217 #define KSZ8081_PHYCON1_OP_MODE_100BTX_HD 0x0002
218 #define KSZ8081_PHYCON1_OP_MODE_10BT_FD 0x0005
219 #define KSZ8081_PHYCON1_OP_MODE_100BTX_FD 0x0006
222 #define KSZ8081_PHYCON2_HP_MDIX 0x8000
223 #define KSZ8081_PHYCON2_MDIX_SEL 0x4000
224 #define KSZ8081_PHYCON2_PAIR_SWAP_DIS 0x2000
225 #define KSZ8081_PHYCON2_FORCE_LINK 0x0800
226 #define KSZ8081_PHYCON2_POWER_SAVING 0x0400
227 #define KSZ8081_PHYCON2_INT_LEVEL 0x0200
228 #define KSZ8081_PHYCON2_JABBER_EN 0x0100
229 #define KSZ8081_PHYCON2_RMII_REF_CLK_SEL 0x0080
230 #define KSZ8081_PHYCON2_LED_MODE 0x0030
231 #define KSZ8081_PHYCON2_TX_DIS 0x0008
232 #define KSZ8081_PHYCON2_REMOTE_LOOPBACK 0x0004
233 #define KSZ8081_PHYCON2_SQE_TEST_EN 0x0002
234 #define KSZ8081_PHYCON2_DATA_SCRAMBLING_DIS 0x0001
uint16_t ksz8081ReadPhyReg(NetInterface *interface, uint8_t address)
Read PHY register.
void ksz8081EnableIrq(NetInterface *interface)
Enable interrupts.
void ksz8081InitHook(NetInterface *interface)
KSZ8081 custom configuration.
void ksz8081Tick(NetInterface *interface)
KSZ8081 timer handler.
void ksz8081WritePhyReg(NetInterface *interface, uint8_t address, uint16_t data)
Write PHY register.
void ksz8081DisableIrq(NetInterface *interface)
Disable interrupts.
const PhyDriver ksz8081PhyDriver
KSZ8081 Ethernet PHY driver.
void ksz8081DumpPhyReg(NetInterface *interface)
Dump PHY registers for debugging purpose.
Network interface controller abstraction layer.
error_t ksz8081Init(NetInterface *interface)
KSZ8081 PHY transceiver initialization.
void ksz8081EventHandler(NetInterface *interface)
KSZ8081 event handler.