Go to the documentation of this file.
31 #ifndef _LAN8740_DRIVER_H
32 #define _LAN8740_DRIVER_H
38 #ifndef LAN8740_PHY_ADDR
39 #define LAN8740_PHY_ADDR 0
40 #elif (LAN8740_PHY_ADDR < 0 || LAN8740_PHY_ADDR > 31)
41 #error LAN8740_PHY_ADDR parameter is not valid
45 #define LAN8740_BMCR 0x00
46 #define LAN8740_BMSR 0x01
47 #define LAN8740_PHYID1 0x02
48 #define LAN8740_PHYID2 0x03
49 #define LAN8740_ANAR 0x04
50 #define LAN8740_ANLPAR 0x05
51 #define LAN8740_ANER 0x06
52 #define LAN8740_ANNPTR 0x07
53 #define LAN8740_ANNPRR 0x08
54 #define LAN8740_MMDACR 0x0D
55 #define LAN8740_MMDAADR 0x0E
56 #define LAN8740_ENCTECR 0x10
57 #define LAN8740_MCSR 0x11
58 #define LAN8740_SMR 0x12
59 #define LAN8740_TDRPDCR 0x18
60 #define LAN8740_TDRCSR 0x19
61 #define LAN8740_SECR 0x1A
62 #define LAN8740_SCSIR 0x1B
63 #define LAN8740_CLR 0x1C
64 #define LAN8740_ISR 0x1D
65 #define LAN8740_IMR 0x1E
66 #define LAN8740_PSCSR 0x1F
69 #define LAN8740_PCS_CTRL1 0x03, 0x0000
70 #define LAN8740_PCS_STAT1 0x03, 0x0001
71 #define LAN8740_PCS_MMD_DEV_PRES1 0x03, 0x0005
72 #define LAN8740_PCS_MMD_DEV_PRES2 0x03, 0x0006
73 #define LAN8740_EEE_CAPABILITY 0x03, 0x0014
74 #define LAN8740_EEE_WAKE_ERROR 0x03, 0x0016
75 #define LAN8740_WUCSR 0x03, 0x8010
76 #define LAN8740_WUF_CFGA 0x03, 0x8011
77 #define LAN8740_WUF_CFGB 0x03, 0x8012
78 #define LAN8740_WUF_MASK 0x03, 0x8021
79 #define LAN8740_RX_ADDRA 0x03, 0x8061
80 #define LAN8740_RX_ADDRB 0x03, 0x8062
81 #define LAN8740_RX_ADDRC 0x03, 0x8063
82 #define LAN8740_MCFGR 0x03, 0x8064
83 #define LAN8740_AN_MMD_DEV_PRES1 0x07, 0x0005
84 #define LAN8740_AN_MMD_DEV_PRES2 0x07, 0x0006
85 #define LAN8740_EEE_ADV 0x07, 0x003C
86 #define LAN8740_EEE_LP_ADV 0x07, 0x003D
87 #define LAN8740_VENDOR_SPECIFIC_MMD1_DEV_ID1 0x1E, 0x0002
88 #define LAN8740_VENDOR_SPECIFIC_MMD1_DEV_ID2 0x1E, 0x0003
89 #define LAN8740_VENDOR_SPECIFIC_MMD1_DEV_PRES1 0x1E, 0x0005
90 #define LAN8740_VENDOR_SPECIFIC_MMD1_DEV_PRES2 0x1E, 0x0006
91 #define LAN8740_VENDOR_SPECIFIC_MMD1_STAT 0x1E, 0x0008
92 #define LAN8740_TDR_MATCH_THRESHOLD 0x1E, 0x000B
93 #define LAN8740_TDR_SHORT_OPEN_THRESHOLD 0x1E, 0x000C
94 #define LAN8740_VENDOR_SPECIFIC_MMD1_PKG_ID1 0x1E, 0x000E
95 #define LAN8740_VENDOR_SPECIFIC_MMD1_PKG_ID2 0x1E, 0x000F
98 #define LAN8740_BMCR_RESET 0x8000
99 #define LAN8740_BMCR_LOOPBACK 0x4000
100 #define LAN8740_BMCR_SPEED_SEL 0x2000
101 #define LAN8740_BMCR_AN_EN 0x1000
102 #define LAN8740_BMCR_POWER_DOWN 0x0800
103 #define LAN8740_BMCR_ISOLATE 0x0400
104 #define LAN8740_BMCR_RESTART_AN 0x0200
105 #define LAN8740_BMCR_DUPLEX_MODE 0x0100
106 #define LAN8740_BMCR_COL_TEST 0x0080
109 #define LAN8740_BMSR_100BT4 0x8000
110 #define LAN8740_BMSR_100BTX_FD 0x4000
111 #define LAN8740_BMSR_100BTX_HD 0x2000
112 #define LAN8740_BMSR_10BT_FD 0x1000
113 #define LAN8740_BMSR_10BT_HD 0x0800
114 #define LAN8740_BMSR_100BT2_FD 0x0400
115 #define LAN8740_BMSR_100BT2_HD 0x0200
116 #define LAN8740_BMSR_EXTENDED_STATUS 0x0100
117 #define LAN8740_BMSR_AN_COMPLETE 0x0020
118 #define LAN8740_BMSR_REMOTE_FAULT 0x0010
119 #define LAN8740_BMSR_AN_CAPABLE 0x0008
120 #define LAN8740_BMSR_LINK_STATUS 0x0004
121 #define LAN8740_BMSR_JABBER_DETECT 0x0002
122 #define LAN8740_BMSR_EXTENDED_CAPABLE 0x0001
125 #define LAN8740_PHYID1_PHY_ID_MSB 0xFFFF
126 #define LAN8740_PHYID1_PHY_ID_MSB_DEFAULT 0x0007
129 #define LAN8740_PHYID2_PHY_ID_LSB 0xFC00
130 #define LAN8740_PHYID2_PHY_ID_LSB_DEFAULT 0xC000
131 #define LAN8740_PHYID2_MODEL_NUM 0x03F0
132 #define LAN8740_PHYID2_MODEL_NUM_DEFAULT 0x0110
133 #define LAN8740_PHYID2_REVISION_NUM 0x000F
136 #define LAN8740_ANAR_NEXT_PAGE 0x8000
137 #define LAN8740_ANAR_REMOTE_FAULT 0x2000
138 #define LAN8740_ANAR_PAUSE 0x0C00
139 #define LAN8740_ANAR_100BTX_FD 0x0100
140 #define LAN8740_ANAR_100BTX_HD 0x0080
141 #define LAN8740_ANAR_10BT_FD 0x0040
142 #define LAN8740_ANAR_10BT_HD 0x0020
143 #define LAN8740_ANAR_SELECTOR 0x001F
144 #define LAN8740_ANAR_SELECTOR_DEFAULT 0x0001
147 #define LAN8740_ANLPAR_NEXT_PAGE 0x8000
148 #define LAN8740_ANLPAR_ACK 0x4000
149 #define LAN8740_ANLPAR_REMOTE_FAULT 0x2000
150 #define LAN8740_ANLPAR_PAUSE 0x0400
151 #define LAN8740_ANLPAR_100BT4 0x0200
152 #define LAN8740_ANLPAR_100BTX_FD 0x0100
153 #define LAN8740_ANLPAR_100BTX_HD 0x0080
154 #define LAN8740_ANLPAR_10BT_FD 0x0040
155 #define LAN8740_ANLPAR_10BT_HD 0x0020
156 #define LAN8740_ANLPAR_SELECTOR 0x001F
157 #define LAN8740_ANLPAR_SELECTOR_DEFAULT 0x0001
160 #define LAN8740_ANER_RECEIVE_NP_LOC_ABLE 0x0040
161 #define LAN8740_ANER_RECEIVE_NP_STOR_LOC 0x0020
162 #define LAN8740_ANER_PAR_DETECT_FAULT 0x0010
163 #define LAN8740_ANER_LP_NEXT_PAGE_ABLE 0x0008
164 #define LAN8740_ANER_NEXT_PAGE_ABLE 0x0004
165 #define LAN8740_ANER_PAGE_RECEIVED 0x0002
166 #define LAN8740_ANER_LP_AN_ABLE 0x0001
169 #define LAN8740_ANNPTR_NEXT_PAGE 0x8000
170 #define LAN8740_ANNPTR_MSG_PAGE 0x2000
171 #define LAN8740_ANNPTR_ACK2 0x1000
172 #define LAN8740_ANNPTR_TOGGLE 0x0800
173 #define LAN8740_ANNPTR_MESSAGE 0x07FF
176 #define LAN8740_ANNPRR_NEXT_PAGE 0x8000
177 #define LAN8740_ANNPRR_ACK 0x4000
178 #define LAN8740_ANNPRR_MSG_PAGE 0x2000
179 #define LAN8740_ANNPRR_ACK2 0x1000
180 #define LAN8740_ANNPRR_TOGGLE 0x0800
181 #define LAN8740_ANNPRR_MESSAGE 0x07FF
184 #define LAN8740_MMDACR_FUNC 0xC000
185 #define LAN8740_MMDACR_FUNC_ADDR 0x0000
186 #define LAN8740_MMDACR_FUNC_DATA_NO_POST_INC 0x4000
187 #define LAN8740_MMDACR_DEVAD 0x001F
190 #define LAN8740_ENCTECR_EDPD_TX_NLP_EN 0x8000
191 #define LAN8740_ENCTECR_EDPD_TX_NLP_ITS 0x6000
192 #define LAN8740_ENCTECR_RX_NLP_WAKE_EN 0x1000
193 #define LAN8740_ENCTECR_RX_NLP_MIDS 0x0C00
194 #define LAN8740_ENCTECR_PHY_EEE_EN 0x0004
195 #define LAN8740_ENCTECR_EDPD_EXT_CROSSOVER 0x0002
196 #define LAN8740_ENCTECR_EXT_CROSSOVER_TIME 0x0001
199 #define LAN8740_MCSR_EDPWRDOWN 0x2000
200 #define LAN8740_MCSR_FARLOOPBACK 0x0200
201 #define LAN8740_MCSR_ALTINT 0x0040
202 #define LAN8740_MCSR_ENERGYON 0x0002
205 #define LAN8740_SMR_MIIMODE 0x4000
206 #define LAN8740_SMR_MODE 0x00E0
207 #define LAN8740_SMR_PHYAD 0x001F
210 #define LAN8740_TDRPDCR_DELAY_IN 0x8000
211 #define LAN8740_TDRPDCR_LINE_BREAK_COUNT 0x7000
212 #define LAN8740_TDRPDCR_PATTERN_HIGH 0x0FC0
213 #define LAN8740_TDRPDCR_PATTERN_LOW 0x003F
216 #define LAN8740_TDRCSR_TDR_EN 0x8000
217 #define LAN8740_TDRCSR_AD_FILTER_EN 0x4000
218 #define LAN8740_TDRCSR_CH_CABLE_TYPE 0x0600
219 #define LAN8740_TDRCSR_CH_STATUS 0x0100
220 #define LAN8740_TDRCSR_CH_LENGTH 0x00FF
223 #define LAN8740_SECR_SYM_ERR_CNT 0xFFFF
226 #define LAN8740_SCSIR_AMDIXCTRL 0x8000
227 #define LAN8740_SCSIR_CH_SELECT 0x2000
228 #define LAN8740_SCSIR_SQEOFF 0x0800
229 #define LAN8740_SCSIR_XPOL 0x0010
232 #define LAN8740_CLR_CBLN 0xF000
235 #define LAN8740_ISR_WOL 0x0100
236 #define LAN8740_ISR_ENERGYON 0x0080
237 #define LAN8740_ISR_AN_COMPLETE 0x0040
238 #define LAN8740_ISR_REMOTE_FAULT 0x0020
239 #define LAN8740_ISR_LINK_DOWN 0x0010
240 #define LAN8740_ISR_AN_LP_ACK 0x0008
241 #define LAN8740_ISR_PAR_DETECT_FAULT 0x0004
242 #define LAN8740_ISR_AN_PAGE_RECEIVED 0x0002
245 #define LAN8740_IMR_WOL 0x0100
246 #define LAN8740_IMR_ENERGYON 0x0080
247 #define LAN8740_IMR_AN_COMPLETE 0x0040
248 #define LAN8740_IMR_REMOTE_FAULT 0x0020
249 #define LAN8740_IMR_LINK_DOWN 0x0010
250 #define LAN8740_IMR_AN_LP_ACK 0x0008
251 #define LAN8740_IMR_PAR_DETECT_FAULT 0x0004
252 #define LAN8740_IMR_AN_PAGE_RECEIVED 0x0002
255 #define LAN8740_PSCSR_AUTODONE 0x1000
256 #define LAN8740_PSCSR_4B5B_EN 0x0040
257 #define LAN8740_PSCSR_HCDSPEED 0x001C
258 #define LAN8740_PSCSR_HCDSPEED_10BT_HD 0x0004
259 #define LAN8740_PSCSR_HCDSPEED_100BTX_HD 0x0008
260 #define LAN8740_PSCSR_HCDSPEED_10BT_FD 0x0014
261 #define LAN8740_PSCSR_HCDSPEED_100BTX_FD 0x0018
const PhyDriver lan8740PhyDriver
LAN8740 Ethernet PHY driver.
void lan8740DumpPhyReg(NetInterface *interface)
Dump PHY registers for debugging purpose.
void lan8740WriteMmdReg(NetInterface *interface, uint8_t devAddr, uint16_t regAddr, uint16_t data)
Write MMD register.
uint16_t lan8740ReadMmdReg(NetInterface *interface, uint8_t devAddr, uint16_t regAddr)
Read MMD register.
void lan8740Tick(NetInterface *interface)
LAN8740 timer handler.
void lan8740InitHook(NetInterface *interface)
LAN8740 custom configuration.
void lan8740EnableIrq(NetInterface *interface)
Enable interrupts.
uint16_t lan8740ReadPhyReg(NetInterface *interface, uint8_t address)
Read PHY register.
void lan8740WritePhyReg(NetInterface *interface, uint8_t address, uint16_t data)
Write PHY register.
error_t lan8740Init(NetInterface *interface)
LAN8740 PHY transceiver initialization.
Network interface controller abstraction layer.
void lan8740DisableIrq(NetInterface *interface)
Disable interrupts.
void lan8740EventHandler(NetInterface *interface)
LAN8740 event handler.