Go to the documentation of this file.
31 #ifndef _KSZ8091_DRIVER_H
32 #define _KSZ8091_DRIVER_H
38 #ifndef KSZ8091_PHY_ADDR
39 #define KSZ8091_PHY_ADDR 0
40 #elif (KSZ8091_PHY_ADDR < 0 || KSZ8091_PHY_ADDR > 31)
41 #error KSZ8091_PHY_ADDR parameter is not valid
45 #define KSZ8091_BMCR 0x00
46 #define KSZ8091_BMSR 0x01
47 #define KSZ8091_PHYID1 0x02
48 #define KSZ8091_PHYID2 0x03
49 #define KSZ8091_ANAR 0x04
50 #define KSZ8091_ANLPAR 0x05
51 #define KSZ8091_ANER 0x06
52 #define KSZ8091_ANNPR 0x07
53 #define KSZ8091_ANLPNPR 0x08
54 #define KSZ8091_MMDACR 0x0D
55 #define KSZ8091_MMDAADR 0x0E
56 #define KSZ8091_DRCON 0x10
57 #define KSZ8091_AFECON1 0x11
58 #define KSZ8091_AFECON4 0x13
59 #define KSZ8091_RXERCTR 0x15
60 #define KSZ8091_OMSO 0x16
61 #define KSZ8091_OMSS 0x17
62 #define KSZ8091_EXCON 0x18
63 #define KSZ8091_ICSR 0x1B
64 #define KSZ8091_LINKMD 0x1D
65 #define KSZ8091_PHYCON1 0x1E
66 #define KSZ8091_PHYCON2 0x1F
69 #define KSZ8091_PMA_PMD_CTRL1 0x01, 0x00
70 #define KSZ8091_PMA_PMD_STAT1 0x01, 0x01
71 #define KSZ8091_EEE_ADV 0x07, 0x3C
72 #define KSZ8091_EEE_LP_ADV 0x07, 0x3D
73 #define KSZ8091_DSP_10BT_CTRL 0x1C, 0x04
74 #define KSZ8091_WOL_CTRL 0x1F, 0x00
75 #define KSZ8091_WOL_CUSTOM_PKT_TYPE0_MASK0 0x1F, 0x01
76 #define KSZ8091_WOL_CUSTOM_PKT_TYPE0_MASK1 0x1F, 0x02
77 #define KSZ8091_WOL_CUSTOM_PKT_TYPE0_MASK2 0x1F, 0x03
78 #define KSZ8091_WOL_CUSTOM_PKT_TYPE0_MASK3 0x1F, 0x04
79 #define KSZ8091_WOL_CUSTOM_PKT_TYPE0_CRC0 0x1F, 0x05
80 #define KSZ8091_WOL_CUSTOM_PKT_TYPE0_CRC1 0x1F, 0x06
81 #define KSZ8091_WOL_CUSTOM_PKT_TYPE1_MASK0 0x1F, 0x07
82 #define KSZ8091_WOL_CUSTOM_PKT_TYPE1_MASK1 0x1F, 0x08
83 #define KSZ8091_WOL_CUSTOM_PKT_TYPE1_MASK2 0x1F, 0x09
84 #define KSZ8091_WOL_CUSTOM_PKT_TYPE1_MASK3 0x1F, 0x0A
85 #define KSZ8091_WOL_CUSTOM_PKT_TYPE1_CRC0 0x1F, 0x0B
86 #define KSZ8091_WOL_CUSTOM_PKT_TYPE1_CRC1 0x1F, 0x0C
87 #define KSZ8091_WOL_CUSTOM_PKT_TYPE2_MASK0 0x1F, 0x0D
88 #define KSZ8091_WOL_CUSTOM_PKT_TYPE2_MASK1 0x1F, 0x0E
89 #define KSZ8091_WOL_CUSTOM_PKT_TYPE2_MASK2 0x1F, 0x0F
90 #define KSZ8091_WOL_CUSTOM_PKT_TYPE2_MASK3 0x1F, 0x10
91 #define KSZ8091_WOL_CUSTOM_PKT_TYPE2_CRC0 0x1F, 0x11
92 #define KSZ8091_WOL_CUSTOM_PKT_TYPE2_CRC1 0x1F, 0x12
93 #define KSZ8091_WOL_CUSTOM_PKT_TYPE3_MASK0 0x1F, 0x13
94 #define KSZ8091_WOL_CUSTOM_PKT_TYPE3_MASK1 0x1F, 0x14
95 #define KSZ8091_WOL_CUSTOM_PKT_TYPE3_MASK2 0x1F, 0x15
96 #define KSZ8091_WOL_CUSTOM_PKT_TYPE3_MASK3 0x1F, 0x16
97 #define KSZ8091_WOL_CUSTOM_PKT_TYPE3_CRC0 0x1F, 0x17
98 #define KSZ8091_WOL_CUSTOM_PKT_TYPE3_CRC1 0x1F, 0x18
99 #define KSZ8091_WOL_MAGIC_PKT_MAC_DA0 0x1F, 0x19
100 #define KSZ8091_WOL_MAGIC_PKT_MAC_DA1 0x1F, 0x1A
101 #define KSZ8091_WOL_MAGIC_PKT_MAC_DA2 0x1F, 0x1B
104 #define KSZ8091_BMCR_RESET 0x8000
105 #define KSZ8091_BMCR_LOOPBACK 0x4000
106 #define KSZ8091_BMCR_SPEED_SEL 0x2000
107 #define KSZ8091_BMCR_AN_EN 0x1000
108 #define KSZ8091_BMCR_POWER_DOWN 0x0800
109 #define KSZ8091_BMCR_ISOLATE 0x0400
110 #define KSZ8091_BMCR_RESTART_AN 0x0200
111 #define KSZ8091_BMCR_DUPLEX_MODE 0x0100
112 #define KSZ8091_BMCR_COL_TEST 0x0080
115 #define KSZ8091_BMSR_100BT4 0x8000
116 #define KSZ8091_BMSR_100BTX_FD 0x4000
117 #define KSZ8091_BMSR_100BTX_HD 0x2000
118 #define KSZ8091_BMSR_10BT_FD 0x1000
119 #define KSZ8091_BMSR_10BT_HD 0x0800
120 #define KSZ8091_BMSR_NO_PREAMBLE 0x0040
121 #define KSZ8091_BMSR_AN_COMPLETE 0x0020
122 #define KSZ8091_BMSR_REMOTE_FAULT 0x0010
123 #define KSZ8091_BMSR_AN_CAPABLE 0x0008
124 #define KSZ8091_BMSR_LINK_STATUS 0x0004
125 #define KSZ8091_BMSR_JABBER_DETECT 0x0002
126 #define KSZ8091_BMSR_EXTENDED_CAPABLE 0x0001
129 #define KSZ8091_PHYID1_PHY_ID_MSB 0xFFFF
130 #define KSZ8091_PHYID1_PHY_ID_MSB_DEFAULT 0x0022
133 #define KSZ8091_PHYID2_PHY_ID_LSB 0xFC00
134 #define KSZ8091_PHYID2_PHY_ID_LSB_DEFAULT 0x1400
135 #define KSZ8091_PHYID2_MODEL_NUM 0x03F0
136 #define KSZ8091_PHYID2_MODEL_NUM_DEFAULT 0x0160
137 #define KSZ8091_PHYID2_REVISION_NUM 0x000F
140 #define KSZ8091_ANAR_NEXT_PAGE 0x8000
141 #define KSZ8091_ANAR_REMOTE_FAULT 0x2000
142 #define KSZ8091_ANAR_PAUSE 0x0C00
143 #define KSZ8091_ANAR_100BT4 0x0200
144 #define KSZ8091_ANAR_100BTX_FD 0x0100
145 #define KSZ8091_ANAR_100BTX_HD 0x0080
146 #define KSZ8091_ANAR_10BT_FD 0x0040
147 #define KSZ8091_ANAR_10BT_HD 0x0020
148 #define KSZ8091_ANAR_SELECTOR 0x001F
149 #define KSZ8091_ANAR_SELECTOR_DEFAULT 0x0001
152 #define KSZ8091_ANLPAR_NEXT_PAGE 0x8000
153 #define KSZ8091_ANLPAR_ACK 0x4000
154 #define KSZ8091_ANLPAR_REMOTE_FAULT 0x2000
155 #define KSZ8091_ANLPAR_PAUSE 0x0C00
156 #define KSZ8091_ANLPAR_100BT4 0x0200
157 #define KSZ8091_ANLPAR_100BTX_FD 0x0100
158 #define KSZ8091_ANLPAR_100BTX_HD 0x0080
159 #define KSZ8091_ANLPAR_10BT_FD 0x0040
160 #define KSZ8091_ANLPAR_10BT_HD 0x0020
161 #define KSZ8091_ANLPAR_SELECTOR 0x001F
162 #define KSZ8091_ANLPAR_SELECTOR_DEFAULT 0x0001
165 #define KSZ8091_ANER_PAR_DETECT_FAULT 0x0010
166 #define KSZ8091_ANER_LP_NEXT_PAGE_ABLE 0x0008
167 #define KSZ8091_ANER_NEXT_PAGE_ABLE 0x0004
168 #define KSZ8091_ANER_PAGE_RECEIVED 0x0002
169 #define KSZ8091_ANER_LP_AN_ABLE 0x0001
172 #define KSZ8091_ANNPR_NEXT_PAGE 0x8000
173 #define KSZ8091_ANNPR_MSG_PAGE 0x2000
174 #define KSZ8091_ANNPR_ACK2 0x1000
175 #define KSZ8091_ANNPR_TOGGLE 0x0800
176 #define KSZ8091_ANNPR_MESSAGE 0x07FF
179 #define KSZ8091_ANLPNPR_NEXT_PAGE 0x8000
180 #define KSZ8091_ANLPNPR_ACK 0x4000
181 #define KSZ8091_ANLPNPR_MSG_PAGE 0x2000
182 #define KSZ8091_ANLPNPR_ACK2 0x1000
183 #define KSZ8091_ANLPNPR_TOGGLE 0x0800
184 #define KSZ8091_ANLPNPR_MESSAGE 0x07FF
187 #define KSZ8091_MMDACR_FUNC 0xC000
188 #define KSZ8091_MMDACR_FUNC_ADDR 0x0000
189 #define KSZ8091_MMDACR_FUNC_DATA_NO_POST_INC 0x4000
190 #define KSZ8091_MMDACR_FUNC_DATA_POST_INC_RW 0x8000
191 #define KSZ8091_MMDACR_FUNC_DATA_POST_INC_W 0xC000
192 #define KSZ8091_MMDACR_DEVAD 0x001F
195 #define KSZ8091_DRCON_PLL_OFF 0x0010
198 #define KSZ8091_AFECON1_SLOW_OSC_MODE_EN 0x0020
201 #define KSZ8091_OMSO_PME_EN 0x8000
202 #define KSZ8091_OMSO_BCAST_OFF_OVERRIDE 0x0200
203 #define KSZ8091_OMSO_MII_BTB_OVERRIDE 0x0080
204 #define KSZ8091_OMSO_RMII_BTB_OVERRIDE 0x0040
205 #define KSZ8091_OMSO_NAND_TREE_OVERRIDE 0x0020
206 #define KSZ8091_OMSO_RMII_OVERRIDE 0x0002
207 #define KSZ8091_OMSO_MII_OVERRIDE 0x0001
210 #define KSZ8091_OMSS_PHYAD 0xE000
211 #define KSZ8091_OMSS_BCAST_OFF_STRAP_STATUS 0x0200
212 #define KSZ8091_OMSS_MII_BTB_STRAP_STATUS 0x0080
213 #define KSZ8091_OMSS_RMII_BTB_STRAP_STATUS 0x0040
214 #define KSZ8091_OMSS_NAND_TREE_STRAP_STATUS 0x0020
215 #define KSZ8091_OMSS_RMII_STRAP_STATUS 0x0002
216 #define KSZ8091_OMSS_MII_STRAP_STATUS 0x0001
219 #define KSZ8091_EXCON_EDPD_DIS 0x0800
220 #define KSZ8091_EXCON_100BTX_LATENCY 0x0400
221 #define KSZ8091_EXCON_10BT_PREAMBLE_RESTORE 0x0040
224 #define KSZ8091_ICSR_JABBER_IE 0x8000
225 #define KSZ8091_ICSR_RECEIVE_ERROR_IE 0x4000
226 #define KSZ8091_ICSR_PAGE_RECEIVED_IE 0x2000
227 #define KSZ8091_ICSR_PAR_DETECT_FAULT_IE 0x1000
228 #define KSZ8091_ICSR_LP_ACK_IE 0x0800
229 #define KSZ8091_ICSR_LINK_DOWN_IE 0x0400
230 #define KSZ8091_ICSR_REMOTE_FAULT_IE 0x0200
231 #define KSZ8091_ICSR_LINK_UP_IE 0x0100
232 #define KSZ8091_ICSR_JABBER_IF 0x0080
233 #define KSZ8091_ICSR_RECEIVE_ERROR_IF 0x0040
234 #define KSZ8091_ICSR_PAGE_RECEIVED_IF 0x0020
235 #define KSZ8091_ICSR_PAR_DETECT_FAULT_IF 0x0010
236 #define KSZ8091_ICSR_LP_ACK_IF 0x0008
237 #define KSZ8091_ICSR_LINK_DOWN_IF 0x0004
238 #define KSZ8091_ICSR_REMOTE_FAULT_IF 0x0002
239 #define KSZ8091_ICSR_LINK_UP_IF 0x0001
242 #define KSZ8091_LINKMD_TEST_EN 0x8000
243 #define KSZ8091_LINKMD_RESULT 0x6000
244 #define KSZ8091_LINKMD_SHORT 0x1000
245 #define KSZ8091_LINKMD_FAULT_COUNT 0x01FF
248 #define KSZ8091_PHYCON1_PAUSE_EN 0x0200
249 #define KSZ8091_PHYCON1_LINK_STATUS 0x0100
250 #define KSZ8091_PHYCON1_POL_STATUS 0x0080
251 #define KSZ8091_PHYCON1_MDIX_STATE 0x0020
252 #define KSZ8091_PHYCON1_ENERGY_DETECT 0x0010
253 #define KSZ8091_PHYCON1_PHY_ISOLATE 0x0008
254 #define KSZ8091_PHYCON1_OP_MODE 0x0007
255 #define KSZ8091_PHYCON1_OP_MODE_AN 0x0000
256 #define KSZ8091_PHYCON1_OP_MODE_10BT_HD 0x0001
257 #define KSZ8091_PHYCON1_OP_MODE_100BTX_HD 0x0002
258 #define KSZ8091_PHYCON1_OP_MODE_10BT_FD 0x0005
259 #define KSZ8091_PHYCON1_OP_MODE_100BTX_FD 0x0006
262 #define KSZ8091_PHYCON2_HP_MDIX 0x8000
263 #define KSZ8091_PHYCON2_MDIX_SEL 0x4000
264 #define KSZ8091_PHYCON2_PAIR_SWAP_DIS 0x2000
265 #define KSZ8091_PHYCON2_FORCE_LINK 0x0800
266 #define KSZ8091_PHYCON2_POWER_SAVING 0x0400
267 #define KSZ8091_PHYCON2_INT_LEVEL 0x0200
268 #define KSZ8091_PHYCON2_JABBER_EN 0x0100
269 #define KSZ8091_PHYCON2_RMII_REF_CLK_SEL 0x0080
270 #define KSZ8091_PHYCON2_LED_MODE 0x0030
271 #define KSZ8091_PHYCON2_TX_DIS 0x0008
272 #define KSZ8091_PHYCON2_REMOTE_LOOPBACK 0x0004
273 #define KSZ8091_PHYCON2_SQE_TEST_EN 0x0002
274 #define KSZ8091_PHYCON2_DATA_SCRAMBLING_DIS 0x0001
277 #define KSZ8091_PMA_PMD_CTRL1_LPI_EN 0x1000
280 #define KSZ8091_PMA_PMD_STAT1_LPI_STATE_ENTERED 0x0100
281 #define KSZ8091_PMA_PMD_STAT1_LPI_STATE_IND 0x0008
284 #define KSZ8091_EEE_ADV_1000BT_EEE_CAPABLE 0x0004
285 #define KSZ8091_EEE_ADV_100BTX_EEE_CAPABLE 0x0002
288 #define KSZ8091_EEE_LP_ADV_1000BT_EEE_CAPABLE 0x0004
289 #define KSZ8091_EEE_LP_ADV_100BTX_EEE_CAPABLE 0x0002
292 #define KSZ8091_DSP_10BT_CTRL_MODE_SEL 0x2000
295 #define KSZ8091_WOL_CTRL_PME_OUTPUT_SEL 0xC000
296 #define KSZ8091_WOL_CTRL_MAGIC_PKT_DETECT_EN 0x0040
297 #define KSZ8091_WOL_CTRL_CUSTOM_PKT_TYPE3_DETECT_EN 0x0020
298 #define KSZ8091_WOL_CTRL_CUSTOM_PKT_TYPE2_DETECT_EN 0x0010
299 #define KSZ8091_WOL_CTRL_CUSTOM_PKT_TYPE1_DETECT_EN 0x0008
300 #define KSZ8091_WOL_CTRL_CUSTOM_PKT_TYPE0_DETECT_EN 0x0004
301 #define KSZ8091_WOL_CTRL_LINK_DOWN_DETECT_EN 0x0002
302 #define KSZ8091_WOL_CTRL_LINK_UP_DETECT_EN 0x0001
void ksz8091EventHandler(NetInterface *interface)
KSZ8091 event handler.
void ksz8091EnableIrq(NetInterface *interface)
Enable interrupts.
void ksz8091DisableIrq(NetInterface *interface)
Disable interrupts.
error_t ksz8091Init(NetInterface *interface)
KSZ8091 PHY transceiver initialization.
uint16_t ksz8091ReadMmdReg(NetInterface *interface, uint8_t devAddr, uint16_t regAddr)
Read MMD register.
void ksz8091WritePhyReg(NetInterface *interface, uint8_t address, uint16_t data)
Write PHY register.
void ksz8091WriteMmdReg(NetInterface *interface, uint8_t devAddr, uint16_t regAddr, uint16_t data)
Write MMD register.
void ksz8091InitHook(NetInterface *interface)
KSZ8091 custom configuration.
void ksz8091Tick(NetInterface *interface)
KSZ8091 timer handler.
const PhyDriver ksz8091PhyDriver
KSZ8091 Ethernet PHY driver.
void ksz8091DumpPhyReg(NetInterface *interface)
Dump PHY registers for debugging purpose.
Network interface controller abstraction layer.
uint16_t ksz8091ReadPhyReg(NetInterface *interface, uint8_t address)
Read PHY register.