mv88e1512_driver.h
Go to the documentation of this file.
1 /**
2  * @file mv88e1512_driver.h
3  * @brief 88E1512 Gigabit Ethernet PHY transceiver
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2019 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneTCP Open.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26  *
27  * @author Oryx Embedded SARL (www.oryx-embedded.com)
28  * @version 1.9.4
29  **/
30 
31 #ifndef _MV88E1512_DRIVER_H
32 #define _MV88E1512_DRIVER_H
33 
34 //Dependencies
35 #include "core/nic.h"
36 
37 //PHY address
38 #ifndef MV88E1512_PHY_ADDR
39  #define MV88E1512_PHY_ADDR 0
40 #elif (MV88E1512_PHY_ADDR < 0 || MV88E1512_PHY_ADDR > 31)
41  #error MV88E1512_PHY_ADDR parameter is not valid
42 #endif
43 
44 //88E1512 PHY registers
45 #define MV88E1512_BMCR 0x00
46 #define MV88E1512_BMSR 0x01
47 #define MV88E1512_PHYID1 0x02
48 #define MV88E1512_PHYID2 0x03
49 #define MV88E1512_ANAR 0x04
50 #define MV88E1512_ANLPAR 0x05
51 #define MV88E1512_ANER 0x06
52 #define MV88E1512_ANNPR 0x07
53 #define MV88E1512_ANLPNPR 0x08
54 #define MV88E1512_GBCR 0x09
55 #define MV88E1512_GBSR 0x0A
56 #define MV88E1512_GBESR 0x0F
57 #define MV88E1512_SCR1 0x10
58 #define MV88E1512_SSR1 0x11
59 #define MV88E1512_IER 0x12
60 #define MV88E1512_ISR 0x13
61 #define MV88E1512_SCR2 0x14
62 #define MV88E1512_RECR 0x15
63 #define MV88E1512_PAGSR 0x16
64 #define MV88E1512_GISR 0x17
65 
66 //Copper Control register
67 #define MV88E1512_BMCR_RESET 0x8000
68 #define MV88E1512_BMCR_LOOPBACK 0x4000
69 #define MV88E1512_BMCR_SPEED_SEL_LSB 0x2000
70 #define MV88E1512_BMCR_AN_EN 0x1000
71 #define MV88E1512_BMCR_POWER_DOWN 0x0800
72 #define MV88E1512_BMCR_ISOLATE 0x0400
73 #define MV88E1512_BMCR_RESTART_AN 0x0200
74 #define MV88E1512_BMCR_DUPLEX_MODE 0x0100
75 #define MV88E1512_BMCR_COL_TEST 0x0080
76 #define MV88E1512_BMCR_SPEED_SEL_MSB 0x0040
77 
78 //Copper Status register
79 #define MV88E1512_BMSR_100BT4 0x8000
80 #define MV88E1512_BMSR_100BTX_FD 0x4000
81 #define MV88E1512_BMSR_100BTX_HD 0x2000
82 #define MV88E1512_BMSR_10BT_FD 0x1000
83 #define MV88E1512_BMSR_10BT_HD 0x0800
84 #define MV88E1512_BMSR_100BT2_FD 0x0400
85 #define MV88E1512_BMSR_100BT2_HD 0x0200
86 #define MV88E1512_BMSR_EXTENDED_STATUS 0x0100
87 #define MV88E1512_BMSR_MF_PREAMBLE_SUPPR 0x0040
88 #define MV88E1512_BMSR_AN_COMPLETE 0x0020
89 #define MV88E1512_BMSR_REMOTE_FAULT 0x0010
90 #define MV88E1512_BMSR_AN_CAPABLE 0x0008
91 #define MV88E1512_BMSR_LINK_STATUS 0x0004
92 #define MV88E1512_BMSR_JABBER_DETECT 0x0002
93 #define MV88E1512_BMSR_EXTENDED_CAPABLE 0x0001
94 
95 //PHY Identifier 1 register
96 #define MV88E1512_PHYID1_OUI_MSB 0xFFFF
97 #define MV88E1512_PHYID1_OUI_MSB_DEFAULT 0x0141
98 
99 //PHY Identifier 2 register
100 #define MV88E1512_PHYID2_OUI_LSB 0xFC00
101 #define MV88E1512_PHYID2_OUI_LSB_DEFAULT 0x0C00
102 #define MV88E1512_PHYID2_MODEL_NUM 0x03F0
103 #define MV88E1512_PHYID2_MODEL_NUM_DEFAULT 0x01D0
104 #define MV88E1512_PHYID2_REVISION_NUM 0x000F
105 
106 //Copper Auto-Negotiation Advertisement register
107 #define MV88E1512_ANAR_NEXT_PAGE 0x8000
108 #define MV88E1512_ANAR_ACK 0x4000
109 #define MV88E1512_ANAR_REMOTE_FAULT 0x2000
110 #define MV88E1512_ANAR_ASYM_PAUSE 0x0800
111 #define MV88E1512_ANAR_PAUSE 0x0400
112 #define MV88E1512_ANAR_100BT4 0x0200
113 #define MV88E1512_ANAR_100BTX_FD 0x0100
114 #define MV88E1512_ANAR_100BTX_HD 0x0080
115 #define MV88E1512_ANAR_10BT_FD 0x0040
116 #define MV88E1512_ANAR_10BT_HD 0x0020
117 #define MV88E1512_ANAR_SELECTOR 0x001F
118 #define MV88E1512_ANAR_SELECTOR_DEFAULT 0x0001
119 
120 //Copper Link Partner Ability register
121 #define MV88E1512_ANLPAR_NEXT_PAGE 0x8000
122 #define MV88E1512_ANLPAR_ACK 0x4000
123 #define MV88E1512_ANLPAR_REMOTE_FAULT 0x2000
124 #define MV88E1512_ANLPAR_TECH_ABLE 0x1000
125 #define MV88E1512_ANLPAR_ASYM_PAUSE 0x0800
126 #define MV88E1512_ANLPAR_PAUSE 0x0400
127 #define MV88E1512_ANLPAR_100BT4 0x0200
128 #define MV88E1512_ANLPAR_100BTX_FD 0x0100
129 #define MV88E1512_ANLPAR_100BTX_HD 0x0080
130 #define MV88E1512_ANLPAR_10BT_FD 0x0040
131 #define MV88E1512_ANLPAR_10BT_HD 0x0020
132 #define MV88E1512_ANLPAR_SELECTOR 0x001F
133 #define MV88E1512_ANLPAR_SELECTOR_DEFAULT 0x0001
134 
135 //Copper Auto-Negotiation Expansion register
136 #define MV88E1512_ANER_PAR_DETECT_FAULT 0x0010
137 #define MV88E1512_ANER_LP_NEXT_PAGE_ABLE 0x0008
138 #define MV88E1512_ANER_NEXT_PAGE_ABLE 0x0004
139 #define MV88E1512_ANER_PAGE_RECEIVED 0x0002
140 #define MV88E1512_ANER_LP_AN_ABLE 0x0001
141 
142 //Copper Next Page Transmit register
143 #define MV88E1512_ANNPR_NEXT_PAGE 0x8000
144 #define MV88E1512_ANNPR_MSG_PAGE 0x2000
145 #define MV88E1512_ANNPR_ACK2 0x1000
146 #define MV88E1512_ANNPR_TOGGLE 0x0800
147 #define MV88E1512_ANNPR_MESSAGE 0x07FF
148 
149 //Copper Link Partner Next Page register
150 #define MV88E1512_ANLPNPR_NEXT_PAGE 0x8000
151 #define MV88E1512_ANLPNPR_ACK 0x4000
152 #define MV88E1512_ANLPNPR_MSG_PAGE 0x2000
153 #define MV88E1512_ANLPNPR_ACK2 0x1000
154 #define MV88E1512_ANLPNPR_TOGGLE 0x0800
155 #define MV88E1512_ANLPNPR_MESSAGE 0x07FF
156 
157 //1000BASE-T Control register
158 #define MV88E1512_GBCR_TEST_MODE 0xE000
159 #define MV88E1512_GBCR_MS_MAN_CONF_EN 0x1000
160 #define MV88E1512_GBCR_MS_MAN_CONF_VAL 0x0800
161 #define MV88E1512_GBCR_PORT_TYPE 0x0400
162 #define MV88E1512_GBCR_1000BT_FD 0x0200
163 #define MV88E1512_GBCR_1000BT_HD 0x0100
164 
165 //1000BASE-T Status register
166 #define MV88E1512_GBSR_MS_CONF_FAULT 0x8000
167 #define MV88E1512_GBSR_MS_CONF_RES 0x4000
168 #define MV88E1512_GBSR_LOCAL_RECEIVER_STATUS 0x2000
169 #define MV88E1512_GBSR_REMOTE_RECEIVER_STATUS 0x1000
170 #define MV88E1512_GBSR_LP_1000BT_FD 0x0800
171 #define MV88E1512_GBSR_LP_1000BT_HD 0x0400
172 #define MV88E1512_GBSR_IDLE_ERR_COUNT 0x00FF
173 
174 //Extended Status register
175 #define MV88E1512_GBESR_1000BX_FD 0x8000
176 #define MV88E1512_GBESR_1000BX_HD 0x4000
177 #define MV88E1512_GBESR_1000BT_FD 0x2000
178 #define MV88E1512_GBESR_1000BT_HD 0x1000
179 
180 //Copper Specific Control 1 register
181 #define MV88E1512_SCR1_LINK_PULSE_DIS 0x8000
182 #define MV88E1512_SCR1_FORCE_LINK_GOOD 0x0400
183 #define MV88E1512_SCR1_ENERGY_DETECT 0x0300
184 #define MV88E1512_SCR1_MDIX_MODE 0x0060
185 #define MV88E1512_SCR1_MDIX_MODE_MANUAL_MDI 0x0000
186 #define MV88E1512_SCR1_MDIX_MODE_MANUAL_MDIX 0x0020
187 #define MV88E1512_SCR1_MDIX_MODE_AUTO 0x0060
188 #define MV88E1512_SCR1_TX_DIS 0x0008
189 #define MV88E1512_SCR1_POWER_DOWN 0x0004
190 #define MV88E1512_SCR1_POLARITY_REVERSAL_DIS 0x0002
191 #define MV88E1512_SCR1_JABBER_DIS 0x0001
192 
193 //Copper Specific Status 1 register
194 #define MV88E1512_SSR1_SPEED 0xC000
195 #define MV88E1512_SSR1_SPEED_10MBPS 0x0000
196 #define MV88E1512_SSR1_SPEED_100MBPS 0x4000
197 #define MV88E1512_SSR1_SPEED_1000MBPS 0x8000
198 #define MV88E1512_SSR1_DUPLEX 0x2000
199 #define MV88E1512_SSR1_PAGE_RECEIVED 0x1000
200 #define MV88E1512_SSR1_SPEED_DUPLEX_RESOLVED 0x0800
201 #define MV88E1512_SSR1_LINK 0x0400
202 #define MV88E1512_SSR1_TX_PAUSE_EN 0x0200
203 #define MV88E1512_SSR1_RX_PAUSE_EN 0x0100
204 #define MV88E1512_SSR1_MDI_CROSSOVER_STATUS 0x0040
205 #define MV88E1512_SSR1_ENERGY_DETECT_STATUS 0x0010
206 #define MV88E1512_SSR1_GLOBAL_LINK_STATUS 0x0008
207 #define MV88E1512_SSR1_POLARITY 0x0002
208 #define MV88E1512_SSR1_JABBER 0x0001
209 
210 //Copper Specific Interrupt Enable register
211 #define MV88E1512_IER_AN_ERROR 0x8000
212 #define MV88E1512_IER_SPEED_CHANGED 0x4000
213 #define MV88E1512_IER_DUPLEX_CHANGED 0x2000
214 #define MV88E1512_IER_PAGE_RECEIVED 0x1000
215 #define MV88E1512_IER_AN_COMPLETE 0x0800
216 #define MV88E1512_IER_LINK_STATUS_CHANGED 0x0400
217 #define MV88E1512_IER_SYMBOL_ERROR 0x0200
218 #define MV88E1512_IER_FALSE_CARRIER 0x0100
219 #define MV88E1512_IER_MDI_CROSSOVER_CHANGED 0x0040
220 #define MV88E1512_IER_ENERGY_DETECT 0x0010
221 #define MV88E1512_IER_FLP_COMPLETE 0x0008
222 #define MV88E1512_IER_POLARITY_CHANGED 0x0002
223 #define MV88E1512_IER_JABBER 0x0001
224 
225 //Copper Interrupt Status register
226 #define MV88E1512_ISR_AN_ERROR 0x8000
227 #define MV88E1512_ISR_SPEED_CHANGED 0x4000
228 #define MV88E1512_ISR_DUPLEX_CHANGED 0x2000
229 #define MV88E1512_ISR_PAGE_RECEIVED 0x1000
230 #define MV88E1512_ISR_AN_COMPLETE 0x0800
231 #define MV88E1512_ISR_LINK_STATUS_CHANGED 0x0400
232 #define MV88E1512_ISR_SYMBOL_ERROR 0x0200
233 #define MV88E1512_ISR_FALSE_CARRIER 0x0100
234 #define MV88E1512_ISR_MDI_CROSSOVER_CHANGED 0x0040
235 #define MV88E1512_ISR_ENERGY_DETECT 0x0010
236 #define MV88E1512_ISR_FLP_COMPLETE 0x0008
237 #define MV88E1512_ISR_POLARITY_CHANGED 0x0002
238 #define MV88E1512_ISR_JABBER 0x0001
239 
240 //Copper Specific Control 2 register
241 #define MV88E1512_SCR2_BREAK_LINK_ON_INSUF_IPG 0x0040
242 #define MV88E1512_SCR2_REVERSE_MDIPN3_TX_POL 0x0008
243 #define MV88E1512_SCR2_REVERSE_MDIPN2_TX_POL 0x0004
244 #define MV88E1512_SCR2_REVERSE_MDIPN1_TX_POL 0x0002
245 #define MV88E1512_SCR2_REVERSE_MDIPN0_TX_POL 0x0001
246 
247 //Page Address register
248 #define MV88E1512_PAGSR_PAGE_SEL 0x00FF
249 
250 //Global Interrupt Status register
251 #define MV88E1512_GISR_INTERRUPT 0x0001
252 
253 //C++ guard
254 #ifdef __cplusplus
255  extern "C" {
256 #endif
257 
258 //88E1512 Ethernet PHY driver
259 extern const PhyDriver mv88e1512PhyDriver;
260 
261 //88E1512 related functions
263 
264 void mv88e1512Tick(NetInterface *interface);
265 
266 void mv88e1512EnableIrq(NetInterface *interface);
267 void mv88e1512DisableIrq(NetInterface *interface);
268 
269 void mv88e1512EventHandler(NetInterface *interface);
270 
271 void mv88e1512WritePhyReg(NetInterface *interface, uint8_t address,
272  uint16_t data);
273 
274 uint16_t mv88e1512ReadPhyReg(NetInterface *interface, uint8_t address);
275 
276 void mv88e1512DumpPhyReg(NetInterface *interface);
277 
278 //C++ guard
279 #ifdef __cplusplus
280  }
281 #endif
282 
283 #endif
void mv88e1512EnableIrq(NetInterface *interface)
Enable interrupts.
void mv88e1512DumpPhyReg(NetInterface *interface)
Dump PHY registers for debugging purpose.
void mv88e1512DisableIrq(NetInterface *interface)
Disable interrupts.
void mv88e1512EventHandler(NetInterface *interface)
88E1512 event handler
error_t mv88e1512Init(NetInterface *interface)
88E1512 PHY transceiver initialization
void mv88e1512Tick(NetInterface *interface)
88E1512 timer handler
const PhyDriver mv88e1512PhyDriver
88E1512 Ethernet PHY driver
PHY driver.
Definition: nic.h:214
Ipv6Addr address
error_t
Error codes.
Definition: error.h:42
uint8_t data[]
Definition: dtls_misc.h:169
#define NetInterface
Definition: net.h:36
void mv88e1512WritePhyReg(NetInterface *interface, uint8_t address, uint16_t data)
Write PHY register.
Network interface controller abstraction layer.
uint16_t mv88e1512ReadPhyReg(NetInterface *interface, uint8_t address)
Read PHY register.