rfLPC
A low level library for using NXP's LPC17xx SoC. Config is given for MBED prototyping board
eth_const.h
Go to the documentation of this file.
1 /* This file is part of rflpc. Copyright 2010-2011 Michael Hauspie
2  *
3  * rflpc is free software: you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation, either version 3 of the License, or
6  * (at your option) any later version.
7  *
8  * rflpc is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with rflpc. If not, see <http://www.gnu.org/licenses/>.
15  */
16 /*
17  Author: Michael Hauspie <michael.hauspie@univ-lille1.fr>
18  Created: 2011-07-04
19  Time-stamp: <2012-12-14 15:59:52 (hauspie)>
20 
21  all ethernet constants, register definition, bits etc..
22 
23 */
27 #ifndef __RFLPC_ETH_CONST_H__
28 #define __RFLPC_ETH_CONST_H__
29 
30 
31 
32 #ifdef RFLPC_CONFIG_ENABLE_ETHERNET
33 
40 #define RFLPC_ETH_PCENET_BIT (1 << 30)
41 
50 #define RFLPC_ETH_PIN_TXD0 RFLPC_PIN_P1_0
51 
52 #define RFLPC_ETH_PIN_TXD1 RFLPC_PIN_P1_1
53 
54 #define RFLPC_ETH_PIN_TX_EN RFLPC_PIN_P1_4
55 
56 #define RFLPC_ETH_PIN_CRS RFLPC_PIN_P1_8
57 
58 #define RFLPC_ETH_PIN_RXD0 RFLPC_PIN_P1_9
59 
60 #define RFLPC_ETH_PIN_RXD1 RFLPC_PIN_P1_10
61 
62 #define RFLPC_ETH_PIN_RX_ER RFLPC_PIN_P1_14
63 
64 #define RFLPC_ETH_PIN_REF_CLK RFLPC_PIN_P1_15
65 
66 #define RFLPC_ETH_PIN_MDC RFLPC_PIN_P1_16
67 
68 #define RFLPC_ETH_PIN_MDIO RFLPC_PIN_P1_17
69 
75 /* MAC Configuration Register 1, bits definition */
77 #define RFLPC_ETH_MAC1_RECEIVE_ENABLE (1 << 0)
78 
79 #define RFLPC_ETH_MAC1_PASS_ALL_FRAMES (1 << 1)
80 
81 #define RFLPC_ETH_MAC1_RX_FLOW_CONTROL (1 << 2)
82 
83 #define RFLPC_ETH_MAC1_TX_FLOW_CONTROL (1 << 3)
84 
85 #define RFLPC_ETH_MAC1_LOOPBACK (1 << 4)
86 
87 #define RFLPC_ETH_MAC1_RESET_TX (1 << 8)
88 
89 #define RFLPC_ETH_MAC1_RESET_MCS_TX (1 << 9)
90 
91 #define RFLPC_ETH_MAC1_RESET_RX (1 << 10)
92 
93 #define RFLPC_ETH_MAC1_RESET_MCS_RX (1 << 11)
94 
95 #define RFLPC_ETH_MAC1_SIM_RESET (1 << 14)
96 
97 #define RFLPC_ETH_MAC1_SOFT_RESET (1 << 15)
98 
99 /* MAC Configuration Register 2, bits definition */
101 #define RFLPC_ETH_MAC2_FULL_DUPLEX (1 << 0)
102 
103 #define RFLPC_ETH_MAC2_FRAME_LENGTH_CHK (1 << 1)
104 
105 #define RFLPC_ETH_MAC2_HUGE_FRAME_ENABLE (1 << 2)
106 
107 #define RFLPC_ETH_MAC2_DELAYED_CRC (1 << 3)
108 
109 #define RFLPC_ETH_MAC2_CRC_ENABLE (1 << 4)
110 
111 #define RFLPC_ETH_MAC2_PAD_CRC_ENABLE (1 << 5)
112 
113 #define RFLPC_ETH_MAC2_VLAN_PAD_ENABLE (1 << 6)
114 
115 #define RFLPC_ETH_MAC2_AUTO_DETECT_PAD_ENABLE (1 << 7)
116 
117 #define RFLPC_ETH_MAC2_PURE_PREAMBLE_ENFORCE (1 << 8)
118 
119 #define RFLPC_ETH_MAC2_LONG_PREAMBLE_ENFORCE (1 << 9)
120 
121 #define RFLPC_ETH_MAC2_NO_BACKOFF (1 << 12)
122 
123 #define RFLPC_ETH_MAC2_BACK_PRESSURE (1 << 13)
124 
127 #define RFLPC_ETH_MAC2_EXCESS_DEFER (1 << 14)
128 
135 /* MAC Control register bits */
136 #define RFLPC_ETH_CMD_RX_ENABLE (1 << 0)
137 #define RFLPC_ETH_CMD_TX_ENABLE (1 << 1)
138 #define RFLPC_ETH_CMD_REG_RESET (1 << 3)
139 #define RFLPC_ETH_CMD_TX_RESET (1 << 4)
140 #define RFLPC_ETH_CMD_RX_RESET (1 << 5)
141 #define RFLPC_ETH_CMD_PASS_RUNT_FRAMES (1 << 6)
142 #define RFLPC_ETH_CMD_PASS_RX_FILTER (1 << 7)
143 #define RFLPC_ETH_CMD_TX_FLOW_CONTROL (1 << 8)
144 #define RFLPC_ETH_CMD_RMII (1 << 9)
145 #define RFLPC_ETH_CMD_FULL_DUPLEX (1 << 10)
146 
152 #define RFLPC_ETH_RXFILTER_UNICAST_EN (1 << 0)
153 #define RFLPC_ETH_RXFILTER_BROADCAST_EN (1 << 1)
154 #define RFLPC_ETH_RXFILTER_MULTICAST_EN (1 << 2)
155 #define RFLPC_ETH_RXFILTER_UNICAST_HASH_EN (1 << 3)
156 #define RFLPC_ETH_RXFILTER_MULTICAST_HASH_EN (1 << 4)
157 #define RFLPC_ETH_RXFILTER_PERFECT_EN (1 << 5)
158 #define RFLPC_ETH_RXFILTER_MAGIC_WOL_EN (1 << 12)
159 #define RFLPC_ETH_RXFILTER_RXFILTER_WOL_EN (1 << 13)
160 
166 /* MIND Control register */
167 #define RFLPC_ETH_MIND_BUSY (1)
168 #define RFLPC_ETH_MIND_SCANNING (1 << 1)
169 #define RFLPC_ETH_MIND_NOT_VALID (1 << 2)
170 #define RFLPC_ETH_MIND_MII_LINK_FAIL (1 << 3)
171 
177 #define RFLPC_ETH_SUPP_10MBPS (0)
178 #define RFLPC_ETH_SUPP_100MBPS (1 << 8)
179 
185 #define RFLPC_ETH_MCFG_SCAN_INCREMENT (1 << 0)
186 #define RFLPC_ETH_MCFG_SUPPRESS_PREAMBLE (1 << 1)
187 #define RFLPC_ETH_MCFG_RESET_MIIM (1 << 15)
188 
199 #define RFLPC_ETH_MAX_FRAME_LENGTH 1538
200 
201 #define RFLPC_ETH_MAX_CLOCK 2500000
202 
203 
204 /* Address of the DP83848J PHY registers */
209 #define RFLPC_ETH_PHY_BMCR (0x0)
210 #define RFLPC_ETH_PHY_BMSR (0x1)
211 
212 /* Phy extented registers */
213 #ifdef RFLPC_ETH_USE_EXTENDED_MII
214 #define RFLPC_ETH_PHY_PHYIDR1 (0x2)
215 #define RFLPC_ETH_PHY_PHYIDR2 (0x3)
216 #define RFLPC_ETH_PHY_ANAR (0x4)
217 #define RFLPC_ETH_PHY_ANLPAR (0x5)
218 #define RFLPC_ETH_PHY_ANLPARNP (0x5) /* Not a bug, it IS the same addr (p. 36 of the DP83848J datasheet */
219 #define RFLPC_ETH_PHY_ANER (0x6)
220 #define RFLPC_ETH_PHY_ANNPTR (0x7)
221 #define RFLPC_ETH_PHY_PHYSTS (0x10)
222 #define RFLPC_ETH_PHY_FCSCR (0x14)
223 #define RFLPC_ETH_PHY_RECR (0x15)
224 #define RFLPC_ETH_PHY_PCSR (0x16)
225 #define RFLPC_ETH_PHY_RBR (0x17)
226 #define RFLPC_ETH_PHY_LEDCR (0x18)
227 #define RFLPC_ETH_PHY_PHYCR (0x19)
228 #define RFLPC_ETH_PHY_10BTSCR (0x1A)
229 #define RFLPC_ETH_PHY_CDCTRL1 (0x1B)
230 #define RFLPC_ETH_PHY_EDCR (0x1D)
231 #endif /* extended registers */
232 
234 /* PHY register bits */
239 #define RFLPC_ETH_BMCR_RESET (1 << 15)
240 #define RFLPC_ETH_BMCR_LOOPBACK (1 << 14)
241 #define RFLPC_ETH_BMCR_SPEED_SELECT (1 << 13)
242 #define RFLPC_ETH_BMCR_ENABLE_AUTO_NEG (1 << 12)
243 #define RFLPC_ETH_BMCR_POWER_DOWN (1 << 11)
244 #define RFLPC_ETH_BMCR_ISOLATE (1 << 10)
245 #define RFLPC_ETH_BMCR_RESTART_AUTO_NEG (1 << 9)
246 #define RFLPC_ETH_BMCR_DUPLEX_MODE (1 << 8)
247 #define RFLPC_ETH_BMCR_COLLISION_TEST (1 << 7)
248 
254 #define RFLPC_ETH_BMSR_100BASET4 (1 << 15)
255 #define RFLPC_ETH_BMSR_100BASETX_FULL (1 << 14)
256 #define RFLPC_ETH_BMSR_100BASETX_HALF (1 << 13)
257 #define RFLPC_ETH_BMSR_10BASET_FULL (1 << 12)
258 #define RFLPC_ETH_BMSR_10BASET_HALF (1 << 11)
259 #define RFLPC_ETH_BMSR_MF_PREAMBLE_SUPPRESSION (1 << 6)
260 #define RFLPC_ETH_BMSR_AUTO_NEG_COMPLETE (1 << 5)
261 #define RFLPC_ETH_BMSR_REMOTE_FAULT (1 << 4)
262 #define RFLPC_ETH_BMSR_CAN_AUTO_NEG (1 << 3)
263 #define RFLPC_ETH_BMSR_LINK_STATUS (1 << 2)
264 #define RFLPC_ETH_BMSR_JABBER_DETECT (1 << 1)
265 #define RFLPC_ETH_BMSR_EXT_REGISTER_CAPS (1 << 0)
266 
269 /* Phy extented registers */
270 #ifdef RFLPC_ETH_USE_EXTENDED_MII
271 
275 #define RFLPC_ETH_ANAR_ASM_DIR (1 << 11)
276 #define RFLPC_ETH_ANAR_PAUSE (1 << 10)
277 #define RFLPC_ETH_ANAR_T4 (1 << 9)
278 #define RFLPC_ETH_ANAR_TX_FD (1 << 8)
279 #define RFLPC_ETH_ANAR_TX (1 << 7)
280 #define RFLPC_ETH_ANAR_10_FD (1 << 6)
281 #define RFLPC_ETH_ANAR_10 (1 << 5)
282 
288 #define RFLPC_ETH_PHYSTS_MDI_X (1 << 14)
289 #define RFLPC_ETH_PHYSTS_RX_ERROR_LATCH (1 << 13)
290 #define RFLPC_ETH_PHYSTS_POLARITY_STATUS (1 << 12)
291 #define RFLPC_ETH_PHYSTS_FALSE_CARRIER_SENSE_LATCH (1 << 11)
292 #define RFLPC_ETH_PHYSTS_SIGNAL_DETECT (1 << 10)
293 #define RFLPC_ETH_PHYSTS_DESCRAMBLER_LOCK (1 << 9)
294 #define RFLPC_ETH_PHYSTS_PAGE_RECEIVED (1 << 8)
295 #define RFLPC_ETH_PHYSTS_REMOTE_FAULT (1 << 6)
296 #define RFLPC_ETH_PHYSTS_JABBER_DETECT (1 << 5)
297 #define RFLPC_ETH_PHYSTS_AUTO_NEG_COMPLETE (1 << 4)
298 #define RFLPC_ETH_PHYSTS_LOOPBACK_STATUS (1 << 3)
299 #define RFLPC_ETH_PHYSTS_DUPLEX_STATUS (1 << 2)
300 #define RFLPC_ETH_PHYSTS_SPEED_STATUS (1 << 1)
301 #define RFLPC_ETH_PHYSTS_LINK_STATUS (1 << 0)
302 
303 #endif /* extended registers */
304 
309 /* Interrupt enable bits */
310 #define RFLPC_ETH_IRQ_EN_RX_OVERRUN (1 << 0)
311 #define RFLPC_ETH_IRQ_EN_RX_ERROR (1 << 1)
312 #define RFLPC_ETH_IRQ_EN_RX_FINISHED (1 << 2)
313 #define RFLPC_ETH_IRQ_EN_RX_DONE (1 << 3)
314 #define RFLPC_ETH_IRQ_EN_TX_UNDERRUN (1 << 4)
315 #define RFLPC_ETH_IRQ_EN_TX_ERROR (1 << 5)
316 #define RFLPC_ETH_IRQ_EN_TX_FINISHED (1 << 6)
317 #define RFLPC_ETH_IRQ_EN_TX_DONE (1 << 7)
318 #define RFLPC_ETH_IRQ_EN_SOFT (1 << 12)
319 #define RFLPC_ETH_IRQ_EN_WAKE_UP (1 << 13)
320 
324 #endif /* ENABLE_ETHERNET */
325 
326 #endif