mikroSDK Reference Manual
rtl8211e_driver.h
Go to the documentation of this file.
1
31#ifndef _RTL8211E_DRIVER_H
32#define _RTL8211E_DRIVER_H
33
34//Dependencies
35#include "core/nic.h"
36
37//PHY address
38#ifndef RTL8211E_PHY_ADDR
39 #define RTL8211E_PHY_ADDR 1
40#elif (RTL8211E_PHY_ADDR < 0 || RTL8211E_PHY_ADDR > 31)
41 #error RTL8211E_PHY_ADDR parameter is not valid
42#endif
43
44//RTL8211E PHY registers
45#define RTL8211E_BMCR 0x00
46#define RTL8211E_BMSR 0x01
47#define RTL8211E_PHYID1 0x02
48#define RTL8211E_PHYID2 0x03
49#define RTL8211E_ANAR 0x04
50#define RTL8211E_ANLPAR 0x05
51#define RTL8211E_ANER 0x06
52#define RTL8211E_ANNPTR 0x07
53#define RTL8211E_ANNPRR 0x08
54#define RTL8211E_GBCR 0x09
55#define RTL8211E_GBSR 0x0A
56#define RTL8211E_MMDACR 0x0D
57#define RTL8211E_MMDAADR 0x0E
58#define RTL8211E_GBESR 0x0F
59#define RTL8211E_PHYCR 0x10
60#define RTL8211E_PHYSR 0x11
61#define RTL8211E_INER 0x12
62#define RTL8211E_INSR 0x13
63#define RTL8211E_RXERC 0x18
64#define RTL8211E_LDPSR 0x1B
65#define RTL8211E_EPAGSR 0x1E
66#define RTL8211E_PAGSR 0x1F
67
68//Basic Mode Control register
69#define RTL8211E_BMCR_RESET 0x8000
70#define RTL8211E_BMCR_LOOPBACK 0x4000
71#define RTL8211E_BMCR_SPEED_SEL_LSB 0x2000
72#define RTL8211E_BMCR_AN_EN 0x1000
73#define RTL8211E_BMCR_POWER_DOWN 0x0800
74#define RTL8211E_BMCR_ISOLATE 0x0400
75#define RTL8211E_BMCR_RESTART_AN 0x0200
76#define RTL8211E_BMCR_DUPLEX_MODE 0x0100
77#define RTL8211E_BMCR_COL_TEST 0x0080
78#define RTL8211E_BMCR_SPEED_SEL_MSB 0x0040
79
80//Basic Mode Status register
81#define RTL8211E_BMSR_100BT4 0x8000
82#define RTL8211E_BMSR_100BTX_FD 0x4000
83#define RTL8211E_BMSR_100BTX_HD 0x2000
84#define RTL8211E_BMSR_10BT_FD 0x1000
85#define RTL8211E_BMSR_10BT_HD 0x0800
86#define RTL8211E_BMSR_100BT2_FD 0x0400
87#define RTL8211E_BMSR_100BT2_HD 0x0200
88#define RTL8211E_BMSR_EXTENDED_STATUS 0x0100
89#define RTL8211E_BMSR_PREAMBLE_SUPPR 0x0040
90#define RTL8211E_BMSR_AN_COMPLETE 0x0020
91#define RTL8211E_BMSR_REMOTE_FAULT 0x0010
92#define RTL8211E_BMSR_AN_CAPABLE 0x0008
93#define RTL8211E_BMSR_LINK_STATUS 0x0004
94#define RTL8211E_BMSR_JABBER_DETECT 0x0002
95#define RTL8211E_BMSR_EXTENDED_CAPABLE 0x0001
96
97//PHY Identifier 1 register
98#define RTL8211E_PHYID1_OUI_MSB 0xFFFF
99#define RTL8211E_PHYID1_OUI_MSB_DEFAULT 0x001C
100
101//PHY Identifier 2 register
102#define RTL8211E_PHYID2_OUI_LSB 0xFC00
103#define RTL8211E_PHYID2_OUI_LSB_DEFAULT 0xC800
104#define RTL8211E_PHYID2_MODEL_NUM 0x03F0
105#define RTL8211E_PHYID2_MODEL_NUM_DEFAULT 0x0110
106#define RTL8211E_PHYID2_REVISION_NUM 0x000F
107#define RTL8211E_PHYID2_REVISION_NUM_DEFAULT 0x0005
108
109//Auto-Negotiation Advertisement register
110#define RTL8211E_ANAR_NEXT_PAGE 0x8000
111#define RTL8211E_ANAR_REMOTE_FAULT 0x2000
112#define RTL8211E_ANAR_ASYM_PAUSE 0x0800
113#define RTL8211E_ANAR_PAUSE 0x0400
114#define RTL8211E_ANAR_100BT4 0x0200
115#define RTL8211E_ANAR_100BTX_FD 0x0100
116#define RTL8211E_ANAR_100BTX_HD 0x0080
117#define RTL8211E_ANAR_10BT_FD 0x0040
118#define RTL8211E_ANAR_10BT_HD 0x0020
119#define RTL8211E_ANAR_SELECTOR 0x001F
120#define RTL8211E_ANAR_SELECTOR_DEFAULT 0x0001
121
122//Auto-Negotiation Link Partner Ability register
123#define RTL8211E_ANLPAR_NEXT_PAGE 0x8000
124#define RTL8211E_ANLPAR_ACK 0x4000
125#define RTL8211E_ANLPAR_REMOTE_FAULT 0x2000
126#define RTL8211E_ANLPAR_ASYM_PAUSE 0x0800
127#define RTL8211E_ANLPAR_PAUSE 0x0400
128#define RTL8211E_ANLPAR_100BT4 0x0200
129#define RTL8211E_ANLPAR_100BTX_FD 0x0100
130#define RTL8211E_ANLPAR_100BTX_HD 0x0080
131#define RTL8211E_ANLPAR_10BT_FD 0x0040
132#define RTL8211E_ANLPAR_10BT_HD 0x0020
133#define RTL8211E_ANLPAR_SELECTOR 0x001F
134#define RTL8211E_ANLPAR_SELECTOR_DEFAULT 0x0001
135
136//Auto-Negotiation Expansion register
137#define RTL8211E_ANER_PAR_DETECT_FAULT 0x0010
138#define RTL8211E_ANER_LP_NEXT_PAGE_ABLE 0x0008
139#define RTL8211E_ANER_NEXT_PAGE_ABLE 0x0004
140#define RTL8211E_ANER_PAGE_RECEIVED 0x0002
141#define RTL8211E_ANER_LP_AN_ABLE 0x0001
142
143//Auto-Negotiation Next Page Transmit register
144#define RTL8211E_ANNPTR_NEXT_PAGE 0x8000
145#define RTL8211E_ANNPTR_MSG_PAGE 0x2000
146#define RTL8211E_ANNPTR_ACK2 0x1000
147#define RTL8211E_ANNPTR_TOGGLE 0x0800
148#define RTL8211E_ANNPTR_MESSAGE 0x07FF
149
150//Auto-Negotiation Next Page Receive register
151#define RTL8211E_ANNPRR_NEXT_PAGE 0x8000
152#define RTL8211E_ANNPRR_ACK 0x4000
153#define RTL8211E_ANNPRR_MSG_PAGE 0x2000
154#define RTL8211E_ANNPRR_ACK2 0x1000
155#define RTL8211E_ANNPRR_TOGGLE 0x0800
156#define RTL8211E_ANNPRR_MESSAGE 0x07FF
157
158//1000Base-T Control register
159#define RTL8211E_GBCR_TEST_MODE 0xE000
160#define RTL8211E_GBCR_MS_MAN_CONF_EN 0x1000
161#define RTL8211E_GBCR_MS_MAN_CONF_VAL 0x0800
162#define RTL8211E_GBCR_PORT_TYPE 0x0400
163#define RTL8211E_GBCR_1000BT_FD 0x0200
164
165//1000Base-T Status register
166#define RTL8211E_GBSR_MS_CONF_FAULT 0x8000
167#define RTL8211E_GBSR_MS_CONF_RES 0x4000
168#define RTL8211E_GBSR_LOCAL_RECEIVER_STATUS 0x2000
169#define RTL8211E_GBSR_REMOTE_RECEIVER_STATUS 0x1000
170#define RTL8211E_GBSR_LP_1000BT_FD 0x0800
171#define RTL8211E_GBSR_LP_1000BT_HD 0x0400
172#define RTL8211E_GBSR_IDLE_ERR_COUNT 0x00FF
173
174//MMD Access Control register
175#define RTL8211E_MMDACR_FUNC 0xC000
176#define RTL8211E_MMDACR_FUNC_ADDR 0x0000
177#define RTL8211E_MMDACR_FUNC_DATA_NO_POST_INC 0x4000
178#define RTL8211E_MMDACR_FUNC_DATA_POST_INC_RW 0x8000
179#define RTL8211E_MMDACR_FUNC_DATA_POST_INC_W 0xC000
180#define RTL8211E_MMDACR_DEVAD 0x001F
181
182//1000Base-T Extended Status register
183#define RTL8211E_GBESR_1000BX_FD 0x8000
184#define RTL8211E_GBESR_1000BX_HD 0x4000
185#define RTL8211E_GBESR_1000BT_FD 0x2000
186#define RTL8211E_GBESR_1000BT_HD 0x1000
187
188//PHY Specific Control register
189#define RTL8211E_PHYCR_RXC_DIS 0x8000
190#define RTL8211E_PHYCR_FPR_FAIL_SEL 0x7000
191#define RTL8211E_PHYCR_ASSERT_CRS_ON_TX 0x0800
192#define RTL8211E_PHYCR_FORCE_LINK_GOOD 0x0400
193#define RTL8211E_PHYCR_CROSSOVER_EN 0x0040
194#define RTL8211E_PHYCR_MDI_MODE 0x0020
195#define RTL8211E_PHYCR_CLK125_DIS 0x0010
196#define RTL8211E_PHYCR_JABBER_DIS 0x0001
197
198//PHY Specific Status register
199#define RTL8211E_PHYSR_SPEED 0xC000
200#define RTL8211E_PHYSR_SPEED_10MBPS 0x0000
201#define RTL8211E_PHYSR_SPEED_100MBPS 0x4000
202#define RTL8211E_PHYSR_SPEED_1000MBPS 0x8000
203#define RTL8211E_PHYSR_DUPLEX 0x2000
204#define RTL8211E_PHYSR_PAGE_RECEIVED 0x1000
205#define RTL8211E_PHYSR_SPEED_DUPLEX_RESOLVED 0x0800
206#define RTL8211E_PHYSR_LINK 0x0400
207#define RTL8211E_PHYSR_MDI_CROSSOVER_STATUS 0x0040
208#define RTL8211E_PHYSR_PRE_LINKOK 0x0002
209#define RTL8211E_PHYSR_JABBER 0x0001
210
211//Interrupt Enable register
212#define RTL8211E_INER_AN_ERROR 0x8000
213#define RTL8211E_INER_PAGE_RECEIVED 0x1000
214#define RTL8211E_INER_AN_COMPLETE 0x0800
215#define RTL8211E_INER_LINK_STATUS 0x0400
216#define RTL8211E_INER_SYMBOL_ERROR 0x0200
217#define RTL8211E_INER_FALSE_CARRIER 0x0100
218#define RTL8211E_INER_JABBER 0x0001
219
220//Interrupt Status register
221#define RTL8211E_INSR_AN_ERROR 0x8000
222#define RTL8211E_INSR_PAGE_RECEIVED 0x1000
223#define RTL8211E_INSR_AN_COMPLETE 0x0800
224#define RTL8211E_INSR_LINK_STATUS 0x0400
225#define RTL8211E_INSR_SYMBOL_ERROR 0x0200
226#define RTL8211E_INSR_FALSE_CARRIER 0x0100
227#define RTL8211E_INSR_JABBER 0x0001
228
229//Link Down Power Saving register
230#define RTL8211E_LDPSR_POWER_SAVE_MODE 0x0001
231
232//Extension Page Select register
233#define RTL8211E_EPAGSR_EXT_PAGE_SEL 0x00FF
234
235//Page Select register
236#define RTL8211E_PAGSR_PAGE_SEL 0x0007
237
238//C++ guard
239#ifdef __cplusplus
240extern "C" {
241#endif
242
243//RTL8211E Ethernet PHY driver
244extern const PhyDriver rtl8211ePhyDriver;
245
246//RTL8211E related functions
247error_t rtl8211eInit(NetInterface *interface);
248void rtl8211eInitHook(NetInterface *interface);
249
250void rtl8211eTick(NetInterface *interface);
251
252void rtl8211eEnableIrq(NetInterface *interface);
253void rtl8211eDisableIrq(NetInterface *interface);
254
255void rtl8211eEventHandler(NetInterface *interface);
256
257void rtl8211eWritePhyReg(NetInterface *interface, uint8_t address,
258 uint16_t data);
259
260uint16_t rtl8211eReadPhyReg(NetInterface *interface, uint8_t address);
261
262void rtl8211eDumpPhyReg(NetInterface *interface);
263
264void rtl8211eWriteMmdReg(NetInterface *interface, uint8_t devAddr,
265 uint16_t regAddr, uint16_t data);
266
267uint16_t rtl8211eReadMmdReg(NetInterface *interface, uint8_t devAddr,
268 uint16_t regAddr);
269
270//C++ guard
271#ifdef __cplusplus
272}
273#endif
274
275#endif
error_t
Error codes.
Definition error.h:43
Network interface controller abstraction layer.
Ethernet PHY driver.
Definition nic.h:308