00001 #ifndef _LPC17XX_EMAC_H_ 00002 #define _LPC17XX_EMAC_H_ 00003 00004 /* 00005 * Copyright (C) 2012 by Ole Reinhardt (ole.reinhardt@embedded-it.de) 00006 * 00007 * All rights reserved. 00008 * 00009 * Redistribution and use in source and binary forms, with or without 00010 * modification, are permitted provided that the following conditions 00011 * are met: 00012 * 00013 * 1. Redistributions of source code must retain the above copyright 00014 * notice, this list of conditions and the following disclaimer. 00015 * 2. Redistributions in binary form must reproduce the above copyright 00016 * notice, this list of conditions and the following disclaimer in the 00017 * documentation and/or other materials provided with the distribution. 00018 * 3. Neither the name of the copyright holders nor the names of 00019 * contributors may be used to endorse or promote products derived 00020 * from this software without specific prior written permission. 00021 * 00022 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00023 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00024 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00025 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00026 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00027 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00028 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 00029 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 00030 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00031 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 00032 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00033 * SUCH DAMAGE. 00034 * 00035 * For additional information see http://www.ethernut.de/ 00036 * 00037 * 00038 * Parts taken from lpc177x_8x_emac.h 2011-06-02 00039 * file lpc177x_8x_emac.h 00040 * brief Contains all macro definitions and function prototypes 00041 * support for Ethernet MAC firmware library on LPC177x_8x 00042 * version 1.0 00043 * date 02. June. 2011 00044 * author NXP MCU SW Application Team 00045 * 00046 * Copyright(C) 2011, NXP Semiconductor 00047 * All rights reserved. 00048 * 00049 *********************************************************************** 00050 * Software that is described herein is for illustrative purposes only 00051 * which provides customers with programming information regarding the 00052 * products. This software is supplied "AS IS" without any warranties. 00053 * NXP Semiconductors assumes no responsibility or liability for the 00054 * use of the software, conveys no license or title under any patent, 00055 * copyright, or mask work right to the product. NXP Semiconductors 00056 * reserves the right to make changes in the software without 00057 * notification. NXP Semiconductors also make no representation or 00058 * warranty that such application will be suitable for the specified 00059 * use without further testing or modification. 00060 **********************************************************************/ 00061 00069 /*============================================================================* 00070 Ethernet MAC register defines 00071 *============================================================================*/ 00072 00073 /*----------------------------------------------------------------------------* 00074 MAC Configuration Register 1 00075 *----------------------------------------------------------------------------*/ 00076 00077 #define EMAC_MAC1_MASK 0xcf1f /* MAC1 register mask */ 00078 #define EMAC_MAC1_REC_EN 0x00000001 /* Receive Enable */ 00079 #define EMAC_MAC1_PASS_ALL 0x00000002 /* Pass All Receive Frames */ 00080 #define EMAC_MAC1_RX_FLOWC 0x00000004 /* RX Flow Control */ 00081 #define EMAC_MAC1_TX_FLOWC 0x00000008 /* TX Flow Control */ 00082 #define EMAC_MAC1_LOOPB 0x00000010 /* Loop Back Mode */ 00083 #define EMAC_MAC1_RES_TX 0x00000100 /* Reset TX Logic */ 00084 #define EMAC_MAC1_RES_MCS_TX 0x00000200 /* Reset MAC TX Control Sublayer */ 00085 #define EMAC_MAC1_RES_RX 0x00000400 /* Reset RX Logic */ 00086 #define EMAC_MAC1_RES_MCS_RX 0x00000800 /* Reset MAC RX Control Sublayer */ 00087 #define EMAC_MAC1_SIM_RES 0x00004000 /* Simulation Reset */ 00088 #define EMAC_MAC1_SOFT_RES 0x00008000 /* Soft Reset MAC */ 00089 00090 /*----------------------------------------------------------------------------* 00091 MAC Configuration Register 2 00092 *----------------------------------------------------------------------------*/ 00093 00094 #define EMAC_MAC2_MASK 0x73ff /* MAC2 register mask */ 00095 #define EMAC_MAC2_FULL_DUP 0x00000001 /* Full-Duplex Mode */ 00096 #define EMAC_MAC2_FRM_LEN_CHK 0x00000002 /* Frame Length Checking */ 00097 #define EMAC_MAC2_HUGE_FRM_EN 0x00000004 /* Huge Frame Enable */ 00098 #define EMAC_MAC2_DLY_CRC 0x00000008 /* Delayed CRC Mode */ 00099 #define EMAC_MAC2_CRC_EN 0x00000010 /* Append CRC to every Frame */ 00100 #define EMAC_MAC2_PAD_EN 0x00000020 /* Pad all Short Frames */ 00101 #define EMAC_MAC2_VLAN_PAD_EN 0x00000040 /* VLAN Pad Enable */ 00102 #define EMAC_MAC2_ADET_PAD_EN 0x00000080 /* Auto Detect Pad Enable */ 00103 #define EMAC_MAC2_PPREAM_ENF 0x00000100 /* Pure Preamble Enforcement */ 00104 #define EMAC_MAC2_LPREAM_ENF 0x00000200 /* Long Preamble Enforcement */ 00105 #define EMAC_MAC2_NO_BACKOFF 0x00001000 /* No Backoff Algorithm */ 00106 #define EMAC_MAC2_BACK_PRESSURE 0x00002000 /* Backoff Presurre / No Backoff */ 00107 #define EMAC_MAC2_EXCESS_DEF 0x00004000 /* Excess Defer */ 00108 00109 00110 /*----------------------------------------------------------------------------* 00111 Back-to-Back Inter-Packet-Gap register defines 00112 *----------------------------------------------------------------------------*/ 00113 00114 /* Programmable field representing the nibble time offset of the minimum possible period 00115 * between the end of any transmitted packet to the beginning of the next */ 00116 #define EMAC_IPGT_BBIPG(n) (n&0x7F) 00117 00118 /* Recommended value for Full Duplex of Programmable field representing the nibble time 00119 * offset of the minimum possible period between the end of any transmitted packet to the 00120 * beginning of the next */ 00121 #define EMAC_IPGT_FULL_DUP (EMAC_IPGT_BBIPG(0x15)) 00122 00123 /* Recommended value for Half Duplex of Programmable field representing the nibble time 00124 * offset of the minimum possible period between the end of any transmitted packet to the 00125 * beginning of the next */ 00126 #define EMAC_IPGT_HALF_DUP (EMAC_IPGT_BBIPG(0x12)) 00127 00128 00129 /*----------------------------------------------------------------------------* 00130 Non Back-to-Back Inter-Packet-Gap register defines 00131 *----------------------------------------------------------------------------*/ 00132 00133 /* Programmable field representing the Non-Back-to-Back Inter-Packet-Gap */ 00134 #define EMAC_IPGR_NBBIPG_P2(n) (n&0x7F) 00135 00136 /* Recommended value for Programmable field representing the Non-Back-to-Back Inter-Packet-Gap Part 1 */ 00137 #define EMAC_IPGR_P2_DEF (EMAC_IPGR_NBBIPG_P2(0x12)) 00138 00139 /* Programmable field representing the optional carrierSense window referenced in 00140 * IEEE 802.3/4.2.3.2.1 'Carrier Deference' */ 00141 #define EMAC_IPGR_NBBIPG_P1(n) ((n&0x7F)<<8) 00142 00143 /* Recommended value for Programmable field representing the Non-Back-to-Back Inter-Packet-Gap Part 2 */ 00144 #define EMAC_IPGR_P1_DEF EMAC_IPGR_NBBIPG_P1(0x0C) 00145 00146 00147 /*----------------------------------------------------------------------------* 00148 Collision Window/Retry register defines 00149 *----------------------------------------------------------------------------*/ 00150 00151 /* Programmable field specifying the number of retransmission attempts following a collision before 00152 * aborting the packet due to excessive collisions */ 00153 #define EMAC_CLRT_MAX_RETX(n) (n&0x0F) 00154 00155 /* Programmable field representing the slot time or collision window during which collisions occur 00156 * in properly configured networks */ 00157 #define EMAC_CLRT_COLL(n) ((n&0x3F)<<8) 00158 00159 /* Default value for Collision Window / Retry register */ 00160 #define EMAC_CLRT_DEF ((EMAC_CLRT_MAX_RETX(0x0F))|(EMAC_CLRT_COLL(0x37))) 00161 00162 00163 /*----------------------------------------------------------------------------* 00164 Maximum Frame register defines 00165 *----------------------------------------------------------------------------*/ 00166 00167 /* Represents a maximum receive frame of 1536 octets */ 00168 #define EMAC_MAXF_MAXFRMLEN(n) (n&0xFFFF) 00169 #define EMAC_MAXF_MAXFRMLEN_DEF (0x6000) 00170 00171 00172 00173 /*----------------------------------------------------------------------------* 00174 PHY Support register 00175 *----------------------------------------------------------------------------*/ 00176 00177 #define EMAC_SUPP_SPEED 0x00000100 /* Reduced MII Logic Current Speed */ 00178 #define EMAC_SUPP_RES_RMII 0x00000800 /* Reset Reduced MII Logic */ 00179 00180 00181 /*----------------------------------------------------------------------------* 00182 Test register 00183 *----------------------------------------------------------------------------*/ 00184 00185 #define EMAC_TEST_SHCUT_PQUANTA 0x00000001 /* Shortcut Pause Quanta */ 00186 #define EMAC_TEST_TST_PAUSE 0x00000002 /* Test Pause */ 00187 #define EMAC_TEST_TST_BACKP 0x00000004 /* Test Back Pressure */ 00188 00189 00190 /*----------------------------------------------------------------------------* 00191 MII Management Configuration register 00192 *----------------------------------------------------------------------------*/ 00193 00194 #define EMAC_MCFG_SCAN_INC 0x00000001 /* Scan Increment PHY Address */ 00195 #define EMAC_MCFG_SUPP_PREAM 0x00000002 /* Suppress Preamble */ 00196 #define EMAC_MCFG_CLK_SEL(n) ((n&0x0F)<<2) /* Clock Select Field */ 00197 #define EMAC_MCFG_RES_MII 0x00008000 /* Reset MII Management Hardware */ 00198 #define EMAC_MCFG_MII_MAXCLK 2500000UL /* MII Clock max */ 00199 00200 00201 /*----------------------------------------------------------------------------* 00202 MII Management Command register 00203 *----------------------------------------------------------------------------*/ 00204 00205 #define EMAC_MCMD_READ 0x00000001 /* MII Read */ 00206 #define EMAC_MCMD_SCAN 0x00000002 /* MII Scan continuously */ 00207 00208 #define EMAC_MII_WR_TOUT 0x00050000 /* MII Write timeout count */ 00209 #define EMAC_MII_RD_TOUT 0x00050000 /* MII Read timeout count */ 00210 00211 00212 /*----------------------------------------------------------------------------* 00213 MII Management Address register 00214 *----------------------------------------------------------------------------*/ 00215 00216 #define EMAC_MADR_REG_ADR(n) (n&0x1F) /* MII Register Address field */ 00217 #define EMAC_MADR_PHY_ADR(n) ((n&0x1F)<<8) /* PHY Address Field */ 00218 00219 00220 /*----------------------------------------------------------------------------* 00221 MII Management Write Data register 00222 *----------------------------------------------------------------------------*/ 00223 00224 #define EMAC_MWTD_DATA(n) (n&0xFFFF) /* Data field for MMI Management Write Data register */ 00225 00226 00227 /*----------------------------------------------------------------------------* 00228 MII Management Read Data register 00229 *----------------------------------------------------------------------------*/ 00230 00231 #define EMAC_MRDD_DATA(n) (n&0xFFFF) /* Data field for MMI Management Read Data register */ 00232 00233 00234 /*----------------------------------------------------------------------------* 00235 MII Management Indicators register 00236 *----------------------------------------------------------------------------*/ 00237 00238 #define EMAC_MIND_BUSY 0x00000001 /* MII is Busy */ 00239 #define EMAC_MIND_SCAN 0x00000002 /* MII Scanning in Progress */ 00240 #define EMAC_MIND_NOT_VAL 0x00000004 /* MII Read Data not valid */ 00241 #define EMAC_MIND_MII_LINK_FAIL 0x00000008 /* MII Link Failedv */ 00242 00243 /* Station Address 0 Register */ 00244 /* Station Address 1 Register */ 00245 /* Station Address 2 Register */ 00246 00247 00248 /*============================================================================* 00249 Controle register defines 00250 *============================================================================*/ 00251 00252 /*----------------------------------------------------------------------------* 00253 Command register defines 00254 *----------------------------------------------------------------------------*/ 00255 00256 #define EMAC_CR_RX_EN 0x00000001 /* Enable Receive */ 00257 #define EMAC_CR_TX_EN 0x00000002 /* Enable Transmit */ 00258 #define EMAC_CR_REG_RES 0x00000008 /* Reset Host Registers */ 00259 #define EMAC_CR_TX_RES 0x00000010 /* Reset Transmit Datapath */ 00260 #define EMAC_CR_RX_RES 0x00000020 /* Reset Receive Datapath */ 00261 #define EMAC_CR_PASS_RUNT_FRM 0x00000040 /* Pass Runt Frames */ 00262 #define EMAC_CR_PASS_RX_FILT 0x00000080 /* Pass RX Filter */ 00263 #define EMAC_CR_TX_FLOW_CTRL 0x00000100 /* TX Flow Control */ 00264 #define EMAC_CR_RMII 0x00000200 /* Reduced MII Interface */ 00265 #define EMAC_CR_FULL_DUP 0x00000400 /* Full Duplex */ 00266 00267 /*----------------------------------------------------------------------------* 00268 Status register defines 00269 *----------------------------------------------------------------------------*/ 00270 00271 #define EMAC_SR_RX_EN 0x00000001 /* Enable Receive */ 00272 #define EMAC_SR_TX_EN 0x00000002 /* Enable Transmit */ 00273 00274 00275 00276 /* Receive Descriptor Base Address Register */ 00277 00278 /* Receive Status Base Address Register */ 00279 00280 /* Receive Number of Descriptors Register */ 00281 00282 /* Receive Produce Index Register */ 00283 00284 /* Receive Consume Index Register */ 00285 00286 /* Transmit Descriptor Base Address Register */ 00287 00288 /* Transmit Status Base Address Register */ 00289 00290 /* Transmit Number of Descriptors Register */ 00291 00292 /* Transmit Produce Index Register */ 00293 00294 /* Transmit Consume Index Register */ 00295 00296 00297 00298 /*----------------------------------------------------------------------------* 00299 Transmit Status Vector 0 register defines 00300 *----------------------------------------------------------------------------*/ 00301 00302 #define EMAC_TSV0_CRC_ERR 0x00000001 /* CRC error */ 00303 #define EMAC_TSV0_LEN_CHKERR 0x00000002 /* Length Check Error */ 00304 #define EMAC_TSV0_LEN_OUTRNG 0x00000004 /* Length Out of Range */ 00305 #define EMAC_TSV0_DONE 0x00000008 /* Tramsmission Completed */ 00306 #define EMAC_TSV0_MCAST 0x00000010 /* Multicast Destination */ 00307 #define EMAC_TSV0_BCAST 0x00000020 /* Broadcast Destination */ 00308 #define EMAC_TSV0_PKT_DEFER 0x00000040 /* Packet Deferred */ 00309 #define EMAC_TSV0_EXC_DEFER 0x00000080 /* Excessive Packet Deferral */ 00310 #define EMAC_TSV0_EXC_COLL 0x00000100 /* Excessive Collision */ 00311 #define EMAC_TSV0_LATE_COLL 0x00000200 /* Late Collision Occured */ 00312 #define EMAC_TSV0_GIANT 0x00000400 /* Giant Frame */ 00313 #define EMAC_TSV0_UNDERRUN 0x00000800 /* Buffer Underrun */ 00314 #define EMAC_TSV0_BYTES 0x0FFFF000 /* Total Bytes Transferred */ 00315 #define EMAC_TSV0_CTRL_FRAME 0x10000000 /* Control Frame */ 00316 #define EMAC_TSV0_PAUSE 0x20000000 /* Pause Frame */ 00317 #define EMAC_TSV0_BACK_PRESS 0x40000000 /* Backpressure Method Applied */ 00318 #define EMAC_TSV0_VLAN 0x80000000 /* VLAN Frame */ 00319 00320 00321 00322 /*----------------------------------------------------------------------------* 00323 Transmit Status Vector 1 register defines 00324 *----------------------------------------------------------------------------*/ 00325 00326 #define EMAC_TSV1_BYTE_CNT 0x0000FFFF /* Transmit Byte Count */ 00327 #define EMAC_TSV1_COLL_CNT 0x000F0000 /* Transmit Collision Count */ 00328 00329 00330 /*----------------------------------------------------------------------------* 00331 Receive Status Vector register defines 00332 *----------------------------------------------------------------------------*/ 00333 00334 #define EMAC_RSV_BYTE_CNT 0x0000FFFF /* Receive Byte Count */ 00335 #define EMAC_RSV_PKT_IGNORED 0x00010000 /* Packet Previously Ignored */ 00336 #define EMAC_RSV_RXDV_SEEN 0x00020000 /* RXDV Event Previously Seen */ 00337 #define EMAC_RSV_CARR_SEEN 0x00040000 /* Carrier Event Previously Seen */ 00338 #define EMAC_RSV_REC_CODEV 0x00080000 /* Receive Code Violation */ 00339 #define EMAC_RSV_CRC_ERR 0x00100000 /* CRC Error */ 00340 #define EMAC_RSV_LEN_CHKERR 0x00200000 /* Length Check Error */ 00341 #define EMAC_RSV_LEN_OUTRNG 0x00400000 /* Length Out of Range */ 00342 #define EMAC_RSV_REC_OK 0x00800000 /* Frame Received OK */ 00343 #define EMAC_RSV_MCAST 0x01000000 /* Multicast Frame */ 00344 #define EMAC_RSV_BCAST 0x02000000 /* Broadcast Frame */ 00345 #define EMAC_RSV_DRIB_NIBB 0x04000000 /* Dribble Nibble */ 00346 #define EMAC_RSV_CTRL_FRAME 0x08000000 /* Control Frame */ 00347 #define EMAC_RSV_PAUSE 0x10000000 /* Pause Frame */ 00348 #define EMAC_RSV_UNSUPP_OPC 0x20000000 /* Unsupported Opcode */ 00349 #define EMAC_RSV_VLAN 0x40000000 /* VLAN Frame */ 00350 00351 00352 /*----------------------------------------------------------------------------* 00353 Flow Control Counter register defines 00354 *----------------------------------------------------------------------------*/ 00355 00356 #define EMAC_FCC_MIRR_CNT(n) (n&0xFFFF) /* Mirror Counter */ 00357 #define EMAC_FCC_PAUSE_TIM(n) ((n&0xFFFF)<<16) /* Pause Timer */ 00358 00359 00360 /*----------------------------------------------------------------------------* 00361 Flow Control Status register defines 00362 *----------------------------------------------------------------------------*/ 00363 00364 #define EMAC_FCS_MIRR_CNT(n) (n&0xFFFF) /* Mirror Counter Current */ 00365 00366 00367 /*============================================================================* 00368 Receive filter register register 00369 *============================================================================*/ 00370 00371 /*----------------------------------------------------------------------------* 00372 Receive filter control register 00373 *----------------------------------------------------------------------------*/ 00374 00375 #define EMAC_RFC_UCAST_EN 0x00000001 /* Accept Unicast Frames Enable */ 00376 #define EMAC_RFC_BCAST_EN 0x00000002 /* Accept Broadcast Frames Enable */ 00377 #define EMAC_RFC_MCAST_EN 0x00000004 /* Accept Multicast Frames Enable */ 00378 #define EMAC_RFC_UCAST_HASH_EN 0x00000008 /* Accept Unicast Hash Filter */ 00379 #define EMAC_RFC_MCAST_HASH_EN 0x00000010 /* Accept Multicast Hash Filter Fram. */ 00380 #define EMAC_RFC_PERFECT_EN 0x00000020 /* Accept Perfect Match Enable */ 00381 #define EMAC_RFC_MAGP_WOL_EN 0x00001000 /* Magic Packet Filter WoL Enable */ 00382 #define EMAC_RFC_PFILT_WOL_EN 0x00002000 /* Perfect Filter WoL Enable */ 00383 00384 00385 /*----------------------------------------------------------------------------* 00386 Receive Filter WoL Status/Clear register defines 00387 *----------------------------------------------------------------------------*/ 00388 00389 #define EMAC_WOL_UCAST 0x00000001 /* Unicast Frame caused WoL */ 00390 #define EMAC_WOL_BCAST 0x00000002 /* Broadcast Frame caused WoL */ 00391 #define EMAC_WOL_MCAST 0x00000004 /* Multicast Frame caused WoL */ 00392 #define EMAC_WOL_UCAST_HASH 0x00000008 /* Unicast Hash Filter Frame WoL */ 00393 #define EMAC_WOL_MCAST_HASH 0x00000010 /* Multicast Hash Filter Frame WoL */ 00394 #define EMAC_WOL_PERFECT 0x00000020 /* Perfect Filter WoL */ 00395 #define EMAC_WOL_RX_FILTER 0x00000080 /* RX Filter caused WoL */ 00396 #define EMAC_WOL_MAG_PACKET 0x00000100 /* Magic Packet Filter caused WoL */ 00397 #define EMAC_WOL_BITMASK 0x01BF /* Receive Filter WoL Status/Clear bitmasl value */ 00398 00399 /* Hash Filter Table LSBs Register */ 00400 00401 /* Hash Filter Table MSBs Register */ 00402 00403 00404 /*============================================================================* 00405 Module control register defines 00406 *============================================================================*/ 00407 00408 /*----------------------------------------------------------------------------* 00409 Interrupt Status/Enable/Clear/Set Registers 00410 *----------------------------------------------------------------------------*/ 00411 00412 #define EMAC_INT_RX_OVERRUN 0x00000001 /* Overrun Error in RX Queue */ 00413 #define EMAC_INT_RX_ERR 0x00000002 /* Receive Error */ 00414 #define EMAC_INT_RX_FIN 0x00000004 /* RX Finished Process Descriptors */ 00415 #define EMAC_INT_RX_DONE 0x00000008 /* Receive Done */ 00416 #define EMAC_INT_TX_UNDERRUN 0x00000010 /* Transmit Underrun */ 00417 #define EMAC_INT_TX_ERR 0x00000020 /* Transmit Error */ 00418 #define EMAC_INT_TX_FIN 0x00000040 /* TX Finished Process Descriptors */ 00419 #define EMAC_INT_TX_DONE 0x00000080 /* Transmit Done */ 00420 #define EMAC_INT_SOFT_INT 0x00001000 /* Software Triggered Interrupt */ 00421 #define EMAC_INT_WAKEUP 0x00002000 /* Wakeup Event Interrupt */ 00422 00423 00424 /*----------------------------------------------------------------------------* 00425 Power Down Register 00426 *----------------------------------------------------------------------------*/ 00427 00428 #define EMAC_PD_POWER_DOWN 0x80000000 /* Power Down MAC */ 00429 00430 00431 00432 /*============================================================================* 00433 Descriptor and status formats 00434 *============================================================================*/ 00435 00436 /*----------------------------------------------------------------------------* 00437 RX and TX descriptor and status definitions. 00438 *----------------------------------------------------------------------------*/ 00439 00440 /* EMAC Memory Buffer configuration for 16K Ethernet RAM */ 00441 #define EMAC_NUM_RX_FRAG 6 /* Num.of RX Fragments 6*1536= 9.0kB */ 00442 #define EMAC_NUM_TX_FRAG 4 /* Num.of TX Fragments 4*1536= 6.0kB */ 00443 #define EMAC_ETH_MAX_FLEN 1536 /* Max. Ethernet Frame Size */ 00444 #define EMAC_TX_FRAME_TOUT 0x00100000 /* Frame Transmit timeout count */ 00445 00446 /* EMAC variables located in 16K Ethernet SRAM */ 00447 #define RX_DESC_BASE 0x20004000 00448 #define RX_STAT_BASE (RX_DESC_BASE + EMAC_NUM_RX_FRAG * 8) 00449 #define TX_DESC_BASE (RX_STAT_BASE + EMAC_NUM_RX_FRAG * 8) 00450 #define TX_STAT_BASE (TX_DESC_BASE + EMAC_NUM_TX_FRAG * 8) 00451 #define RX_BUF_BASE (TX_STAT_BASE + EMAC_NUM_TX_FRAG * 4) 00452 #define TX_BUF_BASE (RX_BUF_BASE + EMAC_NUM_RX_FRAG * EMAC_ETH_MAX_FLEN) 00453 00454 /* RX Descriptor structure type definition */ 00455 #define RX_DESC_PACKET(i) (*(uint32_t *)(RX_DESC_BASE + 8 * i)) 00456 #define RX_DESC_CTRL(i) (*(uint32_t *)(RX_DESC_BASE + 4 + 8 * i)) 00457 00458 /* RX Status structure type definition */ 00459 #define RX_STAT_INFO(i) (*(uint32_t *)(RX_STAT_BASE + 8 * i)) 00460 #define RX_STAT_HASHCRC(i) (*(uint32_t *)(RX_STAT_BASE + 4 + 8 * i)) 00461 00462 /* TX Descriptor structure type definition */ 00463 #define TX_DESC_PACKET(i) (*(uint32_t *)(TX_DESC_BASE + 8 * i)) 00464 #define TX_DESC_CTRL(i) (*(uint32_t *)(TX_DESC_BASE + 4 + 8 * i)) 00465 00466 /* TX Status structure type definition */ 00467 #define TX_STAT_INFO(i) (*(uint32_t *)(TX_STAT_BASE + 4 * i)) 00468 00469 00470 /*----------------------------------------------------------------------------* 00471 TX Data Buffer structure definition definitions 00472 *----------------------------------------------------------------------------*/ 00473 00474 #define RX_BUF(i) (RX_BUF_BASE + EMAC_ETH_MAX_FLEN * i) 00475 #define TX_BUF(i) (TX_BUF_BASE + EMAC_ETH_MAX_FLEN * i) 00476 00477 /* RX Descriptor Control Word */ 00478 #define EMAC_RCTRL_SIZE(n) (n&0x7FF) /* Buffer size field */ 00479 #define EMAC_RCTRL_INT 0x80000000 /* Generate RxDone Interrupt */ 00480 00481 /* RX Status Hash CRC Word */ 00482 #define EMAC_RHASH_SA 0x000001FF /* Hash CRC for Source Address */ 00483 #define EMAC_RHASH_DA 0x001FF000 /* Hash CRC for Destination Address */ 00484 00485 /* RX Status Information Word */ 00486 #define EMAC_RINFO_SIZE 0x000007FF /* Data size in bytes */ 00487 #define EMAC_RINFO_CTRL_FRAME 0x00040000 /* Control Frame */ 00488 #define EMAC_RINFO_VLAN 0x00080000 /* VLAN Frame */ 00489 #define EMAC_RINFO_FAIL_FILT 0x00100000 /* RX Filter Failed */ 00490 #define EMAC_RINFO_MCAST 0x00200000 /* Multicast Frame */ 00491 #define EMAC_RINFO_BCAST 0x00400000 /* Broadcast Frame */ 00492 #define EMAC_RINFO_CRC_ERR 0x00800000 /* CRC Error in Frame */ 00493 #define EMAC_RINFO_SYM_ERR 0x01000000 /* Symbol Error from PHY */ 00494 #define EMAC_RINFO_LEN_ERR 0x02000000 /* Length Error */ 00495 #define EMAC_RINFO_RANGE_ERR 0x04000000 /* Range Error (exceeded max. size) */ 00496 #define EMAC_RINFO_ALIGN_ERR 0x08000000 /* Alignment Error */ 00497 #define EMAC_RINFO_OVERRUN 0x10000000 /* Receive overrun */ 00498 #define EMAC_RINFO_NO_DESCR 0x20000000 /* No new Descriptor available */ 00499 #define EMAC_RINFO_LAST_FLAG 0x40000000 /* Last Fragment in Frame */ 00500 #define EMAC_RINFO_ERR 0x80000000 /* Error Occured (OR of all errors) */ 00501 00502 /* RX Status Information word mask */ 00503 #define EMAC_RINFO_ERR_MASK (EMAC_RINFO_FAIL_FILT | EMAC_RINFO_CRC_ERR | \ 00504 EMAC_RINFO_SYM_ERR | EMAC_RINFO_LEN_ERR | \ 00505 EMAC_RINFO_ALIGN_ERR | EMAC_RINFO_OVERRUN) 00506 00507 /* TX Descriptor Control Word */ 00508 #define EMAC_TCTRL_SIZE 0x000007FF /* Size of data buffer in bytes */ 00509 #define EMAC_TCTRL_OVERRIDE 0x04000000 /* Override Default MAC Registers */ 00510 #define EMAC_TCTRL_HUGE 0x08000000 /* Enable Huge Frame */ 00511 #define EMAC_TCTRL_PAD 0x10000000 /* Pad short Frames to 64 bytes */ 00512 #define EMAC_TCTRL_CRC 0x20000000 /* Append a hardware CRC to Frame */ 00513 #define EMAC_TCTRL_LAST 0x40000000 /* Last Descriptor for TX Frame */ 00514 #define EMAC_TCTRL_INT 0x80000000 /* Generate TxDone Interrupt */ 00515 00516 /* TX Status Information Word */ 00517 #define EMAC_TINFO_COL_CNT 0x01E00000 /* Collision Count */ 00518 #define EMAC_TINFO_DEFER 0x02000000 /* Packet Deferred (not an error) */ 00519 #define EMAC_TINFO_EXCESS_DEF 0x04000000 /* Excessive Deferral */ 00520 #define EMAC_TINFO_EXCESS_COL 0x08000000 /* Excessive Collision */ 00521 #define EMAC_TINFO_LATE_COL 0x10000000 /* Late Collision Occured */ 00522 #define EMAC_TINFO_UNDERRUN 0x20000000 /* Transmit Underrun */ 00523 #define EMAC_TINFO_NO_DESCR 0x40000000 /* No new Descriptor available */ 00524 #define EMAC_TINFO_ERR 0x80000000 /* Error Occured (OR of all errors) */ 00525 00526 /* EMAC Buffer status definitions */ 00527 typedef enum { 00528 EMAC_BUFF_EMPTY, /* buffer is empty */ 00529 EMAC_BUFF_PARTIAL_FULL, /* buffer contains some packets */ 00530 EMAC_BUFF_FULL, /* buffer is full */ 00531 } EMAC_BUFF_STATUS; 00532 00533 /* EMAC Buffer Index definition */ 00534 00535 typedef enum { 00536 EMAC_TX_BUFF, /* transmit buffer */ 00537 EMAC_RX_BUFF, /* receive buffer */ 00538 } EMAC_BUFF_IDX; 00539 00540 #endif /* _LPC17XX_EMAC_H_ */