1 /*! 2 \file gd32e50x_enet.h 3 \brief definitions for the ENET 4 5 \version 2020-03-10, V1.0.0, firmware for GD32E50x 6 \version 2020-08-26, V1.1.0, firmware for GD32E50x 7 \version 2021-03-23, V1.2.0, firmware for GD32E50x 8 */ 9 10 /* 11 Copyright (c) 2021, GigaDevice Semiconductor Inc. 12 13 Redistribution and use in source and binary forms, with or without modification, 14 are permitted provided that the following conditions are met: 15 16 1. Redistributions of source code must retain the above copyright notice, this 17 list of conditions and the following disclaimer. 18 2. Redistributions in binary form must reproduce the above copyright notice, 19 this list of conditions and the following disclaimer in the documentation 20 and/or other materials provided with the distribution. 21 3. Neither the name of the copyright holder nor the names of its contributors 22 may be used to endorse or promote products derived from this software without 23 specific prior written permission. 24 25 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 26 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 27 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 28 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 29 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 30 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 31 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 32 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 34 OF SUCH DAMAGE. 35 */ 36 37 #ifndef GD32E50X_ENET_H 38 #define GD32E50X_ENET_H 39 40 #include "gd32e50x.h" 41 42 #define IF_USE_EXTERNPHY_LIB 0 43 #if (1 == IF_USE_EXTERNPHY_LIB) 44 #include "phy.h" 45 #endif 46 47 #ifndef ENET_RXBUF_NUM 48 #define ENET_RXBUF_NUM 5U /*!< ethernet Rx DMA descriptor number */ 49 #endif 50 51 #ifndef ENET_TXBUF_NUM 52 #define ENET_TXBUF_NUM 5U /*!< ethernet Tx DMA descriptor number */ 53 #endif 54 55 #ifndef ENET_RXBUF_SIZE 56 #define ENET_RXBUF_SIZE ENET_MAX_FRAME_SIZE /*!< ethernet receive buffer size */ 57 #endif 58 59 #ifndef ENET_TXBUF_SIZE 60 #define ENET_TXBUF_SIZE ENET_MAX_FRAME_SIZE /*!< ethernet transmit buffer size */ 61 #endif 62 63 /* #define SELECT_DESCRIPTORS_ENHANCED_MODE */ 64 65 /* #define USE_DELAY */ 66 67 #ifndef _PHY_H_ 68 #define DP83848 0 69 #define LAN8700 1 70 #define PHY_TYPE DP83848 71 72 #define PHY_ADDRESS ((uint16_t)1U) /*!< phy address determined by the hardware */ 73 74 /* PHY read write timeouts */ 75 #define PHY_READ_TO ((uint32_t)0x0004FFFFU) /*!< PHY read timeout */ 76 #define PHY_WRITE_TO ((uint32_t)0x0004FFFFU) /*!< PHY write timeout */ 77 78 /* PHY delay */ 79 #define PHY_RESETDELAY ((uint32_t)0x008FFFFFU) /*!< PHY reset delay */ 80 #define PHY_CONFIGDELAY ((uint32_t)0x00FFFFFFU) /*!< PHY configure delay */ 81 82 /* PHY register address */ 83 #define PHY_REG_BCR 0U /*!< tranceiver basic control register */ 84 #define PHY_REG_BSR 1U /*!< tranceiver basic status register */ 85 86 /* PHY basic control register */ 87 #define PHY_RESET ((uint16_t)0x8000) /*!< PHY reset */ 88 #define PHY_LOOPBACK ((uint16_t)0x4000) /*!< enable phy loop-back mode */ 89 #define PHY_FULLDUPLEX_100M ((uint16_t)0x2100) /*!< configure speed to 100 Mbit/s and the full-duplex mode */ 90 #define PHY_HALFDUPLEX_100M ((uint16_t)0x2000) /*!< configure speed to 100 Mbit/s and the half-duplex mode */ 91 #define PHY_FULLDUPLEX_10M ((uint16_t)0x0100) /*!< configure speed to 10 Mbit/s and the full-duplex mode */ 92 #define PHY_HALFDUPLEX_10M ((uint16_t)0x0000) /*!< configure speed to 10 Mbit/s and the half-duplex mode */ 93 #define PHY_AUTONEGOTIATION ((uint16_t)0x1000) /*!< enable auto-negotiation function */ 94 #define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200) /*!< restart auto-negotiation function */ 95 #define PHY_POWERDOWN ((uint16_t)0x0800) /*!< enable the power down mode */ 96 #define PHY_ISOLATE ((uint16_t)0x0400) /*!< isolate PHY from MII */ 97 98 /* PHY basic status register */ 99 #define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020) /*!< auto-negotioation process completed */ 100 #define PHY_LINKED_STATUS ((uint16_t)0x0004) /*!< valid link established */ 101 #define PHY_JABBER_DETECTION ((uint16_t)0x0002) /*!< jabber condition detected */ 102 103 #if(PHY_TYPE == LAN8700) 104 #define PHY_SR 31U /*!< tranceiver status register */ 105 #define PHY_SPEED_STATUS ((uint16_t)0x0004) /*!< configured information of speed: 10Mbit/s */ 106 #define PHY_DUPLEX_STATUS ((uint16_t)0x0010) /*!< configured information of duplex: full-duplex */ 107 #elif(PHY_TYPE == DP83848) 108 #define PHY_SR 16U /*!< tranceiver status register */ 109 #define PHY_SPEED_STATUS ((uint16_t)0x0002) /*!< configured information of speed: 10Mbit/s */ 110 #define PHY_DUPLEX_STATUS ((uint16_t)0x0004) /*!< configured information of duplex: full-duplex */ 111 #endif /* PHY_TYPE */ 112 113 #endif /* _PHY_H_ */ 114 115 116 /* ENET definitions */ 117 #define ENET ENET_BASE 118 119 /* registers definitions */ 120 #define ENET_MAC_CFG REG32((ENET) + 0x00U) /*!< ethernet MAC configuration register */ 121 #define ENET_MAC_FRMF REG32((ENET) + 0x04U) /*!< ethernet MAC frame filter register */ 122 #define ENET_MAC_HLH REG32((ENET) + 0x08U) /*!< ethernet MAC hash list high register */ 123 #define ENET_MAC_HLL REG32((ENET) + 0x0CU) /*!< ethernet MAC hash list low register */ 124 #define ENET_MAC_PHY_CTL REG32((ENET) + 0x10U) /*!< ethernet MAC PHY control register */ 125 #define ENET_MAC_PHY_DATA REG32((ENET) + 0x14U) /*!< ethernet MAC MII data register */ 126 #define ENET_MAC_FCTL REG32((ENET) + 0x18U) /*!< ethernet MAC flow control register */ 127 #define ENET_MAC_VLT REG32((ENET) + 0x1CU) /*!< ethernet MAC VLAN tag register */ 128 #define ENET_MAC_RWFF REG32((ENET) + 0x28U) /*!< ethernet MAC remote wakeup frame filter register */ 129 #define ENET_MAC_WUM REG32((ENET) + 0x2CU) /*!< ethernet MAC wakeup management register */ 130 #define ENET_MAC_DBG REG32((ENET) + 0x34U) /*!< ethernet MAC debug register */ 131 #define ENET_MAC_INTF REG32((ENET) + 0x38U) /*!< ethernet MAC interrupt flag register */ 132 #define ENET_MAC_INTMSK REG32((ENET) + 0x3CU) /*!< ethernet MAC interrupt mask register */ 133 #define ENET_MAC_ADDR0H REG32((ENET) + 0x40U) /*!< ethernet MAC address 0 high register */ 134 #define ENET_MAC_ADDR0L REG32((ENET) + 0x44U) /*!< ethernet MAC address 0 low register */ 135 #define ENET_MAC_ADDR1H REG32((ENET) + 0x48U) /*!< ethernet MAC address 1 high register */ 136 #define ENET_MAC_ADDR1L REG32((ENET) + 0x4CU) /*!< ethernet MAC address 1 low register */ 137 #define ENET_MAC_ADDT2H REG32((ENET) + 0x50U) /*!< ethernet MAC address 2 high register */ 138 #define ENET_MAC_ADDR2L REG32((ENET) + 0x54U) /*!< ethernet MAC address 2 low register */ 139 #define ENET_MAC_ADDR3H REG32((ENET) + 0x58U) /*!< ethernet MAC address 3 high register */ 140 #define ENET_MAC_ADDR3L REG32((ENET) + 0x5CU) /*!< ethernet MAC address 3 low register */ 141 #define ENET_MAC_FCTH REG32((ENET) + 0x1080U) /*!< ethernet MAC flow control threshold register */ 142 143 #define ENET_MSC_CTL REG32((ENET) + 0x100U) /*!< ethernet MSC control register */ 144 #define ENET_MSC_RINTF REG32((ENET) + 0x104U) /*!< ethernet MSC receive interrupt flag register */ 145 #define ENET_MSC_TINTF REG32((ENET) + 0x108U) /*!< ethernet MSC transmit interrupt flag register */ 146 #define ENET_MSC_RINTMSK REG32((ENET) + 0x10CU) /*!< ethernet MSC receive interrupt mask register */ 147 #define ENET_MSC_TINTMSK REG32((ENET) + 0x110U) /*!< ethernet MSC transmit interrupt mask register */ 148 #define ENET_MSC_SCCNT REG32((ENET) + 0x14CU) /*!< ethernet MSC transmitted good frames after a single collision counter register */ 149 #define ENET_MSC_MSCCNT REG32((ENET) + 0x150U) /*!< ethernet MSC transmitted good frames after more than a single collision counter register */ 150 #define ENET_MSC_TGFCNT REG32((ENET) + 0x168U) /*!< ethernet MSC transmitted good frames counter register */ 151 #define ENET_MSC_RFCECNT REG32((ENET) + 0x194U) /*!< ethernet MSC received frames with CRC error counter register */ 152 #define ENET_MSC_RFAECNT REG32((ENET) + 0x198U) /*!< ethernet MSC received frames with alignment error counter register */ 153 #define ENET_MSC_RGUFCNT REG32((ENET) + 0x1C4U) /*!< ethernet MSC received good unicast frames counter register */ 154 155 #define ENET_PTP_TSCTL REG32((ENET) + 0x700U) /*!< ethernet PTP time stamp control register */ 156 #define ENET_PTP_SSINC REG32((ENET) + 0x704U) /*!< ethernet PTP subsecond increment register */ 157 #define ENET_PTP_TSH REG32((ENET) + 0x708U) /*!< ethernet PTP time stamp high register */ 158 #define ENET_PTP_TSL REG32((ENET) + 0x70CU) /*!< ethernet PTP time stamp low register */ 159 #define ENET_PTP_TSUH REG32((ENET) + 0x710U) /*!< ethernet PTP time stamp update high register */ 160 #define ENET_PTP_TSUL REG32((ENET) + 0x714U) /*!< ethernet PTP time stamp update low register */ 161 #define ENET_PTP_TSADDEND REG32((ENET) + 0x718U) /*!< ethernet PTP time stamp addend register */ 162 #define ENET_PTP_ETH REG32((ENET) + 0x71CU) /*!< ethernet PTP expected time high register */ 163 #define ENET_PTP_ETL REG32((ENET) + 0x720U) /*!< ethernet PTP expected time low register */ 164 #define ENET_PTP_TSF REG32((ENET) + 0x728U) /*!< ethernet PTP time stamp flag register */ 165 #define ENET_PTP_PPSCTL REG32((ENET) + 0x72CU) /*!< ethernet PTP PPS control register */ 166 167 #define ENET_DMA_BCTL REG32((ENET) + 0x1000U) /*!< ethernet DMA bus control register */ 168 #define ENET_DMA_TPEN REG32((ENET) + 0x1004U) /*!< ethernet DMA transmit poll enable register */ 169 #define ENET_DMA_RPEN REG32((ENET) + 0x1008U) /*!< ethernet DMA receive poll enable register */ 170 #define ENET_DMA_RDTADDR REG32((ENET) + 0x100CU) /*!< ethernet DMA receive descriptor table address register */ 171 #define ENET_DMA_TDTADDR REG32((ENET) + 0x1010U) /*!< ethernet DMA transmit descriptor table address register */ 172 #define ENET_DMA_STAT REG32((ENET) + 0x1014U) /*!< ethernet DMA status register */ 173 #define ENET_DMA_CTL REG32((ENET) + 0x1018U) /*!< ethernet DMA control register */ 174 #define ENET_DMA_INTEN REG32((ENET) + 0x101CU) /*!< ethernet DMA interrupt enable register */ 175 #define ENET_DMA_MFBOCNT REG32((ENET) + 0x1020U) /*!< ethernet DMA missed frame and buffer overflow counter register */ 176 #define ENET_DMA_RSWDC REG32((ENET) + 0x1024U) /*!< ethernet DMA receive state watchdog counter register */ 177 #define ENET_DMA_CTDADDR REG32((ENET) + 0x1048U) /*!< ethernet DMA current transmit descriptor address register */ 178 #define ENET_DMA_CRDADDR REG32((ENET) + 0x104CU) /*!< ethernet DMA current receive descriptor address register */ 179 #define ENET_DMA_CTBADDR REG32((ENET) + 0x1050U) /*!< ethernet DMA current transmit buffer address register */ 180 #define ENET_DMA_CRBADDR REG32((ENET) + 0x1054U) /*!< ethernet DMA current receive buffer address register */ 181 182 /* bits definitions */ 183 /* ENET_MAC_CFG */ 184 #define ENET_MAC_CFG_REN BIT(2) /*!< receiver enable */ 185 #define ENET_MAC_CFG_TEN BIT(3) /*!< transmitter enable */ 186 #define ENET_MAC_CFG_DFC BIT(4) /*!< defferal check */ 187 #define ENET_MAC_CFG_BOL BITS(5,6) /*!< back-off limit */ 188 #define ENET_MAC_CFG_APCD BIT(7) /*!< automatic pad/CRC drop */ 189 #define ENET_MAC_CFG_RTD BIT(9) /*!< retry disable */ 190 #define ENET_MAC_CFG_IPFCO BIT(10) /*!< IP frame checksum offload */ 191 #define ENET_MAC_CFG_DPM BIT(11) /*!< duplex mode */ 192 #define ENET_MAC_CFG_LBM BIT(12) /*!< loopback mode */ 193 #define ENET_MAC_CFG_ROD BIT(13) /*!< receive own disable */ 194 #define ENET_MAC_CFG_SPD BIT(14) /*!< fast eneternet speed */ 195 #define ENET_MAC_CFG_CSD BIT(16) /*!< carrier sense disable */ 196 #define ENET_MAC_CFG_IGBS BITS(17,19) /*!< inter-frame gap bit selection */ 197 #define ENET_MAC_CFG_JBD BIT(22) /*!< jabber disable */ 198 #define ENET_MAC_CFG_WDD BIT(23) /*!< watchdog disable */ 199 #define ENET_MAC_CFG_TFCD BIT(25) /*!< type frame CRC dropping */ 200 201 /* ENET_MAC_FRMF */ 202 #define ENET_MAC_FRMF_PM BIT(0) /*!< promiscuous mode */ 203 #define ENET_MAC_FRMF_HUF BIT(1) /*!< hash unicast filter */ 204 #define ENET_MAC_FRMF_HMF BIT(2) /*!< hash multicast filter */ 205 #define ENET_MAC_FRMF_DAIFLT BIT(3) /*!< destination address inverse filtering enable */ 206 #define ENET_MAC_FRMF_MFD BIT(4) /*!< multicast filter disable */ 207 #define ENET_MAC_FRMF_BFRMD BIT(5) /*!< broadcast frame disable */ 208 #define ENET_MAC_FRMF_PCFRM BITS(6,7) /*!< pass control frames */ 209 #define ENET_MAC_FRMF_SAIFLT BIT(8) /*!< source address inverse filtering */ 210 #define ENET_MAC_FRMF_SAFLT BIT(9) /*!< source address filter */ 211 #define ENET_MAC_FRMF_HPFLT BIT(10) /*!< hash or perfect filter */ 212 #define ENET_MAC_FRMF_FAR BIT(31) /*!< frames all receive */ 213 214 /* ENET_MAC_HLH */ 215 #define ENET_MAC_HLH_HLH BITS(0,31) /*!< hash list high */ 216 217 /* ENET_MAC_HLL */ 218 #define ENET_MAC_HLL_HLL BITS(0,31) /*!< hash list low */ 219 220 /* ENET_MAC_PHY_CTL */ 221 #define ENET_MAC_PHY_CTL_PB BIT(0) /*!< PHY busy */ 222 #define ENET_MAC_PHY_CTL_PW BIT(1) /*!< PHY write */ 223 #define ENET_MAC_PHY_CTL_CLR BITS(2,4) /*!< clock range */ 224 #define ENET_MAC_PHY_CTL_PR BITS(6,10) /*!< PHY register */ 225 #define ENET_MAC_PHY_CTL_PA BITS(11,15) /*!< PHY address */ 226 227 /* ENET_MAC_PHY_DATA */ 228 #define ENET_MAC_PHY_DATA_PD BITS(0,15) /*!< PHY data */ 229 230 /* ENET_MAC_FCTL */ 231 #define ENET_MAC_FCTL_FLCBBKPA BIT(0) /*!< flow control busy(in full duplex mode)/backpressure activate(in half duplex mode) */ 232 #define ENET_MAC_FCTL_TFCEN BIT(1) /*!< transmit flow control enable */ 233 #define ENET_MAC_FCTL_RFCEN BIT(2) /*!< receive flow control enable */ 234 #define ENET_MAC_FCTL_UPFDT BIT(3) /*!< unicast pause frame detect */ 235 #define ENET_MAC_FCTL_PLTS BITS(4,5) /*!< pause low threshold */ 236 #define ENET_MAC_FCTL_DZQP BIT(7) /*!< disable zero-quanta pause */ 237 #define ENET_MAC_FCTL_PTM BITS(16,31) /*!< pause time */ 238 239 /* ENET_MAC_VLT */ 240 #define ENET_MAC_VLT_VLTI BITS(0,15) /*!< VLAN tag identifier(for receive frames) */ 241 #define ENET_MAC_VLT_VLTC BIT(16) /*!< 12-bit VLAN tag comparison */ 242 243 /* ENET_MAC_RWFF */ 244 #define ENET_MAC_RWFF_DATA BITS(0,31) /*!< wakeup frame filter register data */ 245 246 /* ENET_MAC_WUM */ 247 #define ENET_MAC_WUM_PWD BIT(0) /*!< power down */ 248 #define ENET_MAC_WUM_MPEN BIT(1) /*!< magic packet enable */ 249 #define ENET_MAC_WUM_WFEN BIT(2) /*!< wakeup frame enable */ 250 #define ENET_MAC_WUM_MPKR BIT(5) /*!< magic packet received */ 251 #define ENET_MAC_WUM_WUFR BIT(6) /*!< wakeup frame received */ 252 #define ENET_MAC_WUM_GU BIT(9) /*!< global unicast */ 253 #define ENET_MAC_WUM_WUFFRPR BIT(31) /*!< wakeup frame filter register pointer reset */ 254 255 /* ENET_MAC_DBG */ 256 #define ENET_MAC_DBG_MRNI BIT(0) /*!< MAC receive state not idle */ 257 #define ENET_MAC_DBG_RXAFS BITS(1,2) /*!< Rx asynchronous FIFO status */ 258 #define ENET_MAC_DBG_RXFW BIT(4) /*!< RxFIFO is writing */ 259 #define ENET_MAC_DBG_RXFRS BITS(5,6) /*!< RxFIFO read operation status */ 260 #define ENET_MAC_DBG_RXFS BITS(8,9) /*!< RxFIFO state */ 261 #define ENET_MAC_DBG_MTNI BIT(16) /*!< MAC transmit state not idle */ 262 #define ENET_MAC_DBG_SOMT BITS(17,18) /*!< status of mac transmitter */ 263 #define ENET_MAC_DBG_PCS BIT(19) /*!< pause condition status */ 264 #define ENET_MAC_DBG_TXFRS BITS(20,21) /*!< TxFIFO read operation status */ 265 #define ENET_MAC_DBG_TXFW BIT(22) /*!< TxFIFO is writing */ 266 #define ENET_MAC_DBG_TXFNE BIT(24) /*!< TxFIFO not empty flag */ 267 #define ENET_MAC_DBG_TXFF BIT(25) /*!< TxFIFO full flag */ 268 269 /* ENET_MAC_INTF */ 270 #define ENET_MAC_INTF_WUM BIT(3) /*!< WUM status */ 271 #define ENET_MAC_INTF_MSC BIT(4) /*!< MSC status */ 272 #define ENET_MAC_INTF_MSCR BIT(5) /*!< MSC receive status */ 273 #define ENET_MAC_INTF_MSCT BIT(6) /*!< MSC transmit status */ 274 #define ENET_MAC_INTF_TMST BIT(9) /*!< timestamp trigger status */ 275 276 /* ENET_MAC_INTMSK */ 277 #define ENET_MAC_INTMSK_WUMIM BIT(3) /*!< WUM interrupt mask */ 278 #define ENET_MAC_INTMSK_TMSTIM BIT(9) /*!< timestamp trigger interrupt mask */ 279 280 /* ENET_MAC_ADDR0H */ 281 #define ENET_MAC_ADDR0H_ADDR0H BITS(0,15) /*!< MAC address0 high */ 282 #define ENET_MAC_ADDR0H_MO BIT(31) /*!< always read 1 and must be kept */ 283 284 /* ENET_MAC_ADDR0L */ 285 #define ENET_MAC_ADDR0L_ADDR0L BITS(0,31) /*!< MAC address0 low */ 286 287 /* ENET_MAC_ADDR1H */ 288 #define ENET_MAC_ADDR1H_ADDR1H BITS(0,15) /*!< MAC address1 high */ 289 #define ENET_MAC_ADDR1H_MB BITS(24,29) /*!< mask byte */ 290 #define ENET_MAC_ADDR1H_SAF BIT(30) /*!< source address filter */ 291 #define ENET_MAC_ADDR1H_AFE BIT(31) /*!< address filter enable */ 292 293 /* ENET_MAC_ADDR1L */ 294 #define ENET_MAC_ADDR1L_ADDR1L BITS(0,31) /*!< MAC address1 low */ 295 296 /* ENET_MAC_ADDR2H */ 297 #define ENET_MAC_ADDR2H_ADDR2H BITS(0,15) /*!< MAC address2 high */ 298 #define ENET_MAC_ADDR2H_MB BITS(24,29) /*!< mask byte */ 299 #define ENET_MAC_ADDR2H_SAF BIT(30) /*!< source address filter */ 300 #define ENET_MAC_ADDR2H_AFE BIT(31) /*!< address filter enable */ 301 302 /* ENET_MAC_ADDR2L */ 303 #define ENET_MAC_ADDR2L_ADDR2L BITS(0,31) /*!< MAC address2 low */ 304 305 /* ENET_MAC_ADDR3H */ 306 #define ENET_MAC_ADDR3H_ADDR3H BITS(0,15) /*!< MAC address3 high */ 307 #define ENET_MAC_ADDR3H_MB BITS(24,29) /*!< mask byte */ 308 #define ENET_MAC_ADDR3H_SAF BIT(30) /*!< source address filter */ 309 #define ENET_MAC_ADDR3H_AFE BIT(31) /*!< address filter enable */ 310 311 /* ENET_MAC_ADDR3L */ 312 #define ENET_MAC_ADDR3L_ADDR3L BITS(0,31) /*!< MAC address3 low */ 313 314 /* ENET_MAC_FCTH */ 315 #define ENET_MAC_FCTH_RFA BITS(0,2) /*!< threshold of active flow control */ 316 #define ENET_MAC_FCTH_RFD BITS(4,6) /*!< threshold of deactive flow control */ 317 318 /* ENET_MSC_CTL */ 319 #define ENET_MSC_CTL_CTR BIT(0) /*!< counter reset */ 320 #define ENET_MSC_CTL_CTSR BIT(1) /*!< counter stop rollover */ 321 #define ENET_MSC_CTL_RTOR BIT(2) /*!< reset on read */ 322 #define ENET_MSC_CTL_MCFZ BIT(3) /*!< MSC counter freeze */ 323 #define ENET_MSC_CTL_PMC BIT(4) /*!< preset MSC counter */ 324 #define ENET_MSC_CTL_AFHPM BIT(5) /*!< almost full or half preset mode */ 325 326 /* ENET_MSC_RINTF */ 327 #define ENET_MSC_RINTF_RFCE BIT(5) /*!< received frames CRC error */ 328 #define ENET_MSC_RINTF_RFAE BIT(6) /*!< received frames alignment error */ 329 #define ENET_MSC_RINTF_RGUF BIT(17) /*!< receive good unicast frames */ 330 331 /* ENET_MSC_TINTF */ 332 #define ENET_MSC_TINTF_TGFSC BIT(14) /*!< transmitted good frames single collision */ 333 #define ENET_MSC_TINTF_TGFMSC BIT(15) /*!< transmitted good frames more single collision */ 334 #define ENET_MSC_TINTF_TGF BIT(21) /*!< transmitted good frames */ 335 336 /* ENET_MSC_RINTMSK */ 337 #define ENET_MSC_RINTMSK_RFCEIM BIT(5) /*!< received frame CRC error interrupt mask */ 338 #define ENET_MSC_RINTMSK_RFAEIM BIT(6) /*!< received frames alignment error interrupt mask */ 339 #define ENET_MSC_RINTMSK_RGUFIM BIT(17) /*!< received good unicast frames interrupt mask */ 340 341 /* ENET_MSC_TINTMSK */ 342 #define ENET_MSC_TINTMSK_TGFSCIM BIT(14) /*!< transmitted good frames single collision interrupt mask */ 343 #define ENET_MSC_TINTMSK_TGFMSCIM BIT(15) /*!< transmitted good frames more single collision interrupt mask */ 344 #define ENET_MSC_TINTMSK_TGFIM BIT(21) /*!< transmitted good frames interrupt mask */ 345 346 /* ENET_MSC_SCCNT */ 347 #define ENET_MSC_SCCNT_SCC BITS(0,31) /*!< transmitted good frames single collision counter */ 348 349 /* ENET_MSC_MSCCNT */ 350 #define ENET_MSC_MSCCNT_MSCC BITS(0,31) /*!< transmitted good frames more one single collision counter */ 351 352 /* ENET_MSC_TGFCNT */ 353 #define ENET_MSC_TGFCNT_TGF BITS(0,31) /*!< transmitted good frames counter */ 354 355 /* ENET_MSC_RFCECNT */ 356 #define ENET_MSC_RFCECNT_RFCER BITS(0,31) /*!< received frames with CRC error counter */ 357 358 /* ENET_MSC_RFAECNT */ 359 #define ENET_MSC_RFAECNT_RFAER BITS(0,31) /*!< received frames alignment error counter */ 360 361 /* ENET_MSC_RGUFCNT */ 362 #define ENET_MSC_RGUFCNT_RGUF BITS(0,31) /*!< received good unicast frames counter */ 363 364 /* ENET_PTP_TSCTL */ 365 #define ENET_PTP_TSCTL_TMSEN BIT(0) /*!< timestamp enable */ 366 #define ENET_PTP_TSCTL_TMSFCU BIT(1) /*!< timestamp fine or coarse update */ 367 #define ENET_PTP_TSCTL_TMSSTI BIT(2) /*!< timestamp system time initialize */ 368 #define ENET_PTP_TSCTL_TMSSTU BIT(3) /*!< timestamp system time update */ 369 #define ENET_PTP_TSCTL_TMSITEN BIT(4) /*!< timestamp interrupt trigger enable */ 370 #define ENET_PTP_TSCTL_TMSARU BIT(5) /*!< timestamp addend register update */ 371 #define ENET_PTP_TSCTL_ARFSEN BIT(8) /*!< all received frames snapshot enable */ 372 #define ENET_PTP_TSCTL_SCROM BIT(9) /*!< subsecond counter rollover mode */ 373 #define ENET_PTP_TSCTL_PFSV BIT(10) /*!< PTP frame snooping version */ 374 #define ENET_PTP_TSCTL_ESEN BIT(11) /*!< received Ethernet snapshot enable */ 375 #define ENET_PTP_TSCTL_IP6SEN BIT(12) /*!< received IPv6 snapshot enable */ 376 #define ENET_PTP_TSCTL_IP4SEN BIT(13) /*!< received IPv4 snapshot enable */ 377 #define ENET_PTP_TSCTL_ETMSEN BIT(14) /*!< received event type message snapshot enable */ 378 #define ENET_PTP_TSCTL_MNMSEN BIT(15) /*!< received master node message snapshot enable */ 379 #define ENET_PTP_TSCTL_CKNT BITS(16,17) /*!< clock node type for time stamp */ 380 #define ENET_PTP_TSCTL_MAFEN BIT(18) /*!< MAC address filter enable for PTP frame */ 381 382 /* ENET_PTP_SSINC */ 383 #define ENET_PTP_SSINC_STMSSI BITS(0,7) /*!< system time subsecond increment */ 384 385 /* ENET_PTP_TSH */ 386 #define ENET_PTP_TSH_STMS BITS(0,31) /*!< system time second */ 387 388 /* ENET_PTP_TSL */ 389 #define ENET_PTP_TSL_STMSS BITS(0,30) /*!< system time subseconds */ 390 #define ENET_PTP_TSL_STS BIT(31) /*!< system time sign */ 391 392 /* ENET_PTP_TSUH */ 393 #define ENET_PTP_TSUH_TMSUS BITS(0,31) /*!< timestamp update seconds */ 394 395 /* ENET_PTP_TSUL */ 396 #define ENET_PTP_TSUL_TMSUSS BITS(0,30) /*!< timestamp update subseconds */ 397 #define ENET_PTP_TSUL_TMSUPNS BIT(31) /*!< timestamp update positive or negative sign */ 398 399 /* ENET_PTP_TSADDEND */ 400 #define ENET_PTP_TSADDEND_TMSA BITS(0,31) /*!< timestamp addend */ 401 402 /* ENET_PTP_ETH */ 403 #define ENET_PTP_ETH_ETSH BITS(0,31) /*!< expected time high */ 404 405 /* ENET_PTP_ETL */ 406 #define ENET_PTP_ETL_ETSL BITS(0,31) /*!< expected time low */ 407 408 /* ENET_PTP_TSF */ 409 #define ENET_PTP_TSF_TSSCO BIT(0) /*!< timestamp second counter overflow */ 410 #define ENET_PTP_TSF_TTM BIT(1) /*!< target time match */ 411 412 /* ENET_PTP_PPSCTL */ 413 #define ENET_PTP_PPSCTL_PPSOFC BITS(0,3) /*!< PPS output frequency configure */ 414 415 /* ENET_DMA_BCTL */ 416 #define ENET_DMA_BCTL_SWR BIT(0) /*!< software reset */ 417 #define ENET_DMA_BCTL_DAB BIT(1) /*!< DMA arbitration */ 418 #define ENET_DMA_BCTL_DPSL BITS(2,6) /*!< descriptor skip length */ 419 #define ENET_DMA_BCTL_DFM BIT(7) /*!< descriptor format mode */ 420 #define ENET_DMA_BCTL_PGBL BITS(8,13) /*!< programmable burst length */ 421 #define ENET_DMA_BCTL_RTPR BITS(14,15) /*!< RxDMA and TxDMA transfer priority ratio */ 422 #define ENET_DMA_BCTL_FB BIT(16) /*!< fixed Burst */ 423 #define ENET_DMA_BCTL_RXDP BITS(17,22) /*!< RxDMA PGBL */ 424 #define ENET_DMA_BCTL_UIP BIT(23) /*!< use independent PGBL */ 425 #define ENET_DMA_BCTL_FPBL BIT(24) /*!< four times PGBL mode */ 426 #define ENET_DMA_BCTL_AA BIT(25) /*!< address-aligned */ 427 #define ENET_DMA_BCTL_MB BIT(26) /*!< mixed burst */ 428 429 /* ENET_DMA_TPEN */ 430 #define ENET_DMA_TPEN_TPE BITS(0,31) /*!< transmit poll enable */ 431 432 /* ENET_DMA_RPEN */ 433 #define ENET_DMA_RPEN_RPE BITS(0,31) /*!< receive poll enable */ 434 435 /* ENET_DMA_RDTADDR */ 436 #define ENET_DMA_RDTADDR_SRT BITS(0,31) /*!< start address of receive table */ 437 438 /* ENET_DMA_TDTADDR */ 439 #define ENET_DMA_TDTADDR_STT BITS(0,31) /*!< start address of transmit table */ 440 441 /* ENET_DMA_STAT */ 442 #define ENET_DMA_STAT_TS BIT(0) /*!< transmit status */ 443 #define ENET_DMA_STAT_TPS BIT(1) /*!< transmit process stopped status */ 444 #define ENET_DMA_STAT_TBU BIT(2) /*!< transmit buffer unavailable status */ 445 #define ENET_DMA_STAT_TJT BIT(3) /*!< transmit jabber timeout status */ 446 #define ENET_DMA_STAT_RO BIT(4) /*!< receive overflow status */ 447 #define ENET_DMA_STAT_TU BIT(5) /*!< transmit underflow status */ 448 #define ENET_DMA_STAT_RS BIT(6) /*!< receive status */ 449 #define ENET_DMA_STAT_RBU BIT(7) /*!< receive buffer unavailable status */ 450 #define ENET_DMA_STAT_RPS BIT(8) /*!< receive process stopped status */ 451 #define ENET_DMA_STAT_RWT BIT(9) /*!< receive watchdog timeout status */ 452 #define ENET_DMA_STAT_ET BIT(10) /*!< early transmit status */ 453 #define ENET_DMA_STAT_FBE BIT(13) /*!< fatal bus error status */ 454 #define ENET_DMA_STAT_ER BIT(14) /*!< early receive status */ 455 #define ENET_DMA_STAT_AI BIT(15) /*!< abnormal interrupt summary */ 456 #define ENET_DMA_STAT_NI BIT(16) /*!< normal interrupt summary */ 457 #define ENET_DMA_STAT_RP BITS(17,19) /*!< receive process state */ 458 #define ENET_DMA_STAT_TP BITS(20,22) /*!< transmit process state */ 459 #define ENET_DMA_STAT_EB BITS(23,25) /*!< error bits status */ 460 #define ENET_DMA_STAT_MSC BIT(27) /*!< MSC status */ 461 #define ENET_DMA_STAT_WUM BIT(28) /*!< WUM status */ 462 #define ENET_DMA_STAT_TST BIT(29) /*!< timestamp trigger status */ 463 464 /* ENET_DMA_CTL */ 465 #define ENET_DMA_CTL_SRE BIT(1) /*!< start/stop receive enable */ 466 #define ENET_DMA_CTL_OSF BIT(2) /*!< operate on second frame */ 467 #define ENET_DMA_CTL_RTHC BITS(3,4) /*!< receive threshold control */ 468 #define ENET_DMA_CTL_FUF BIT(6) /*!< forward undersized good frames */ 469 #define ENET_DMA_CTL_FERF BIT(7) /*!< forward error frames */ 470 #define ENET_DMA_CTL_STE BIT(13) /*!< start/stop transmission enable */ 471 #define ENET_DMA_CTL_TTHC BITS(14,16) /*!< transmit threshold control */ 472 #define ENET_DMA_CTL_FTF BIT(20) /*!< flush transmit FIFO */ 473 #define ENET_DMA_CTL_TSFD BIT(21) /*!< transmit store-and-forward */ 474 #define ENET_DMA_CTL_DAFRF BIT(24) /*!< disable flushing of received frames */ 475 #define ENET_DMA_CTL_RSFD BIT(25) /*!< receive store-and-forward */ 476 #define ENET_DMA_CTL_DTCERFD BIT(26) /*!< dropping of TCP/IP checksum error frames disable */ 477 478 /* ENET_DMA_INTEN */ 479 #define ENET_DMA_INTEN_TIE BIT(0) /*!< transmit interrupt enable */ 480 #define ENET_DMA_INTEN_TPSIE BIT(1) /*!< transmit process stopped interrupt enable */ 481 #define ENET_DMA_INTEN_TBUIE BIT(2) /*!< transmit buffer unavailable interrupt enable */ 482 #define ENET_DMA_INTEN_TJTIE BIT(3) /*!< transmit jabber timeout interrupt enable */ 483 #define ENET_DMA_INTEN_ROIE BIT(4) /*!< receive overflow interrupt enable */ 484 #define ENET_DMA_INTEN_TUIE BIT(5) /*!< transmit underflow interrupt enable */ 485 #define ENET_DMA_INTEN_RIE BIT(6) /*!< receive interrupt enable */ 486 #define ENET_DMA_INTEN_RBUIE BIT(7) /*!< receive buffer unavailable interrupt enable */ 487 #define ENET_DMA_INTEN_RPSIE BIT(8) /*!< receive process stopped interrupt enable */ 488 #define ENET_DMA_INTEN_RWTIE BIT(9) /*!< receive watchdog timeout interrupt enable */ 489 #define ENET_DMA_INTEN_ETIE BIT(10) /*!< early transmit interrupt enable */ 490 #define ENET_DMA_INTEN_FBEIE BIT(13) /*!< fatal bus error interrupt enable */ 491 #define ENET_DMA_INTEN_ERIE BIT(14) /*!< early receive interrupt enable */ 492 #define ENET_DMA_INTEN_AIE BIT(15) /*!< abnormal interrupt summary enable */ 493 #define ENET_DMA_INTEN_NIE BIT(16) /*!< normal interrupt summary enable */ 494 495 /* ENET_DMA_MFBOCNT */ 496 #define ENET_DMA_MFBOCNT_MSFC BITS(0,15) /*!< missed frames by the controller */ 497 #define ENET_DMA_MFBOCNT_MSFA BITS(17,27) /*!< missed frames by the application */ 498 499 /* ENET_DMA_RSWDC */ 500 #define ENET_DMA_RSWDC_WDCFRS BITS(0,7) /*!< watchdog counter for receive status (RS) */ 501 502 /* ENET_DMA_CTDADDR */ 503 #define ENET_DMA_CTDADDR_TDAP BITS(0,31) /*!< transmit descriptor address pointer */ 504 505 /* ENET_DMA_CRDADDR */ 506 #define ENET_DMA_CRDADDR_RDAP BITS(0,31) /*!< receive descriptor address pointer */ 507 508 /* ENET_DMA_CTBADDR */ 509 #define ENET_DMA_CTBADDR_TBAP BITS(0,31) /*!< transmit buffer address pointer */ 510 511 /* ENET_DMA_CRBADDR */ 512 #define ENET_DMA_CRBADDR_RBAP BITS(0,31) /*!< receive buffer address pointer */ 513 514 /* ENET DMA Tx descriptor TDES0 */ 515 #define ENET_TDES0_DB BIT(0) /*!< deferred */ 516 #define ENET_TDES0_UFE BIT(1) /*!< underflow error */ 517 #define ENET_TDES0_EXD BIT(2) /*!< excessive deferral */ 518 #define ENET_TDES0_COCNT BITS(3,6) /*!< collision count */ 519 #define ENET_TDES0_VFRM BIT(7) /*!< VLAN frame */ 520 #define ENET_TDES0_ECO BIT(8) /*!< excessive collision */ 521 #define ENET_TDES0_LCO BIT(9) /*!< late collision */ 522 #define ENET_TDES0_NCA BIT(10) /*!< no carrier */ 523 #define ENET_TDES0_LCA BIT(11) /*!< loss of carrier */ 524 #define ENET_TDES0_IPPE BIT(12) /*!< IP payload error */ 525 #define ENET_TDES0_FRMF BIT(13) /*!< frame flushed */ 526 #define ENET_TDES0_JT BIT(14) /*!< jabber timeout */ 527 #define ENET_TDES0_ES BIT(15) /*!< error summary */ 528 #define ENET_TDES0_IPHE BIT(16) /*!< IP header error */ 529 #define ENET_TDES0_TTMSS BIT(17) /*!< transmit timestamp status */ 530 #define ENET_TDES0_TCHM BIT(20) /*!< the second address chained mode */ 531 #define ENET_TDES0_TERM BIT(21) /*!< transmit end of ring mode*/ 532 #define ENET_TDES0_CM BITS(22,23) /*!< checksum mode */ 533 #define ENET_TDES0_TTSEN BIT(25) /*!< transmit timestamp function enable */ 534 #define ENET_TDES0_DPAD BIT(26) /*!< disable adding pad */ 535 #define ENET_TDES0_DCRC BIT(27) /*!< disable CRC */ 536 #define ENET_TDES0_FSG BIT(28) /*!< first segment */ 537 #define ENET_TDES0_LSG BIT(29) /*!< last segment */ 538 #define ENET_TDES0_INTC BIT(30) /*!< interrupt on completion */ 539 #define ENET_TDES0_DAV BIT(31) /*!< DAV bit */ 540 541 /* ENET DMA Tx descriptor TDES1 */ 542 #define ENET_TDES1_TB1S BITS(0,12) /*!< transmit buffer 1 size */ 543 #define ENET_TDES1_TB2S BITS(16,28) /*!< transmit buffer 2 size */ 544 545 /* ENET DMA Tx descriptor TDES2 */ 546 #define ENET_TDES2_TB1AP BITS(0,31) /*!< transmit buffer 1 address pointer/transmit frame timestamp low 32-bit value */ 547 548 /* ENET DMA Tx descriptor TDES3 */ 549 #define ENET_TDES3_TB2AP BITS(0,31) /*!< transmit buffer 2 address pointer (or next descriptor address) / transmit frame timestamp high 32-bit value */ 550 551 #ifdef SELECT_DESCRIPTORS_ENHANCED_MODE 552 /* ENET DMA Tx descriptor TDES6 */ 553 #define ENET_TDES6_TTSL BITS(0,31) /*!< transmit frame timestamp low 32-bit value */ 554 555 /* ENET DMA Tx descriptor TDES7 */ 556 #define ENET_TDES7_TTSH BITS(0,31) /*!< transmit frame timestamp high 32-bit value */ 557 #endif /* SELECT_DESCRIPTORS_ENHANCED_MODE */ 558 559 /* ENET DMA Rx descriptor RDES0 */ 560 #define ENET_RDES0_PCERR BIT(0) /*!< payload checksum error */ 561 #define ENET_RDES0_EXSV BIT(0) /*!< extended status valid */ 562 #define ENET_RDES0_CERR BIT(1) /*!< CRC error */ 563 #define ENET_RDES0_DBERR BIT(2) /*!< dribble bit error */ 564 #define ENET_RDES0_RERR BIT(3) /*!< receive error */ 565 #define ENET_RDES0_RWDT BIT(4) /*!< receive watchdog timeout */ 566 #define ENET_RDES0_FRMT BIT(5) /*!< frame type */ 567 #define ENET_RDES0_LCO BIT(6) /*!< late collision */ 568 #define ENET_RDES0_IPHERR BIT(7) /*!< IP frame header error */ 569 #define ENET_RDES0_TSV BIT(7) /*!< timestamp valid */ 570 #define ENET_RDES0_LDES BIT(8) /*!< last descriptor */ 571 #define ENET_RDES0_FDES BIT(9) /*!< first descriptor */ 572 #define ENET_RDES0_VTAG BIT(10) /*!< VLAN tag */ 573 #define ENET_RDES0_OERR BIT(11) /*!< overflow Error */ 574 #define ENET_RDES0_LERR BIT(12) /*!< length error */ 575 #define ENET_RDES0_SAFF BIT(13) /*!< SA filter fail */ 576 #define ENET_RDES0_DERR BIT(14) /*!< descriptor error */ 577 #define ENET_RDES0_ERRS BIT(15) /*!< error summary */ 578 #define ENET_RDES0_FRML BITS(16,29) /*!< frame length */ 579 #define ENET_RDES0_DAFF BIT(30) /*!< destination address filter fail */ 580 #define ENET_RDES0_DAV BIT(31) /*!< descriptor available */ 581 582 /* ENET DMA Rx descriptor RDES1 */ 583 #define ENET_RDES1_RB1S BITS(0,12) /*!< receive buffer 1 size */ 584 #define ENET_RDES1_RCHM BIT(14) /*!< receive chained mode for second address */ 585 #define ENET_RDES1_RERM BIT(15) /*!< receive end of ring mode*/ 586 #define ENET_RDES1_RB2S BITS(16,28) /*!< receive buffer 2 size */ 587 #define ENET_RDES1_DINTC BIT(31) /*!< disable interrupt on completion */ 588 589 /* ENET DMA Rx descriptor RDES2 */ 590 #define ENET_RDES2_RB1AP BITS(0,31) /*!< receive buffer 1 address pointer / receive frame timestamp low 32-bit */ 591 592 /* ENET DMA Rx descriptor RDES3 */ 593 #define ENET_RDES3_RB2AP BITS(0,31) /*!< receive buffer 2 address pointer (next descriptor address)/receive frame timestamp high 32-bit value */ 594 595 #ifdef SELECT_DESCRIPTORS_ENHANCED_MODE 596 /* ENET DMA Rx descriptor RDES4 */ 597 #define ENET_RDES4_IPPLDT BITS(0,2) /*!< IP frame payload type */ 598 #define ENET_RDES4_IPHERR BIT(3) /*!< IP frame header error */ 599 #define ENET_RDES4_IPPLDERR BIT(4) /*!< IP frame payload error */ 600 #define ENET_RDES4_IPCKSB BIT(5) /*!< IP frame checksum bypassed */ 601 #define ENET_RDES4_IPF4 BIT(6) /*!< IP frame in version 4 */ 602 #define ENET_RDES4_IPF6 BIT(7) /*!< IP frame in version 6 */ 603 #define ENET_RDES4_PTPMT BITS(8,11) /*!< PTP message type */ 604 #define ENET_RDES4_PTPOEF BIT(12) /*!< PTP on ethernet frame */ 605 #define ENET_RDES4_PTPVF BIT(13) /*!< PTP version format */ 606 607 /* ENET DMA Rx descriptor RDES6 */ 608 #define ENET_RDES6_RTSL BITS(0,31) /*!< receive frame timestamp low 32-bit value */ 609 610 /* ENET DMA Rx descriptor RDES7 */ 611 #define ENET_RDES7_RTSH BITS(0,31) /*!< receive frame timestamp high 32-bit value */ 612 #endif /* SELECT_DESCRIPTORS_ENHANCED_MODE */ 613 614 /* constants definitions */ 615 /* define bit position and its register index offset */ 616 #define ENET_REGIDX_BIT(regidx, bitpos) (((uint32_t)(regidx) << 6) | (uint32_t)(bitpos)) 617 #define ENET_REG_VAL(periph) (REG32(ENET + ((uint32_t)(periph)>>6))) 618 #define ENET_BIT_POS(val) ((uint32_t)(val) & 0x1FU) 619 620 /* ENET clock range judgement */ 621 #define ENET_RANGE(hclk, n, m) (((hclk) >= (n))&&((hclk) < (m))) 622 623 /* define MAC address configuration and reference address */ 624 #define ENET_SET_MACADDRH(p) (((uint32_t)(p)[5] << 8) | (uint32_t)(p)[4]) 625 #define ENET_SET_MACADDRL(p) (((uint32_t)(p)[3] << 24) | ((uint32_t)(p)[2] << 16) | ((uint32_t)(p)[1] << 8) | (uint32_t)(p)[0]) 626 #define ENET_ADDRH_BASE ((ENET) + 0x40U) 627 #define ENET_ADDRL_BASE ((ENET) + 0x44U) 628 #define ENET_GET_MACADDR(offset, n) ((uint8_t)((REG32((ENET_ADDRL_BASE + (offset)) - (((n) / 4U) * 4U)) >> (8U * ((n) % 4U))) & 0xFFU)) 629 630 /* register offset */ 631 #define MAC_FCTL_REG_OFFSET 0x0018U /*!< MAC flow control register offset */ 632 #define MAC_WUM_REG_OFFSET 0x002CU /*!< MAC wakeup management register offset */ 633 #define MAC_INTF_REG_OFFSET 0x0038U /*!< MAC interrupt flag register offset */ 634 #define MAC_INTMSK_REG_OFFSET 0x003CU /*!< MAC interrupt mask register offset */ 635 636 #define MSC_RINTF_REG_OFFSET 0x0104U /*!< MSC receive interrupt flag register offset */ 637 #define MSC_TINTF_REG_OFFSET 0x0108U /*!< MSC transmit interrupt flag register offset */ 638 #define MSC_RINTMSK_REG_OFFSET 0x010CU /*!< MSC receive interrupt mask register offset */ 639 #define MSC_TINTMSK_REG_OFFSET 0x0110U /*!< MSC transmit interrupt mask register offset */ 640 #define MSC_SCCNT_REG_OFFSET 0x014CU /*!< MSC transmitted good frames after a single collision counter register offset */ 641 #define MSC_MSCCNT_REG_OFFSET 0x0150U /*!< MSC transmitted good frames after more than a single collision counter register offset */ 642 #define MSC_TGFCNT_REG_OFFSET 0x0168U /*!< MSC transmitted good frames counter register offset */ 643 #define MSC_RFCECNT_REG_OFFSET 0x0194U /*!< MSC received frames with CRC error counter register offset */ 644 #define MSC_RFAECNT_REG_OFFSET 0x0198U /*!< MSC received frames with alignment error counter register offset */ 645 #define MSC_RGUFCNT_REG_OFFSET 0x01C4U /*!< MSC received good unicast frames counter register offset */ 646 647 #define PTP_TSF_REG_OFFSET 0x0728U /*!< PTP time stamp flag register offset */ 648 649 #define DMA_STAT_REG_OFFSET 0x1014U /*!< DMA status register offset */ 650 #define DMA_INTEN_REG_OFFSET 0x101CU /*!< DMA interrupt enable register offset */ 651 #define DMA_TDTADDR_REG_OFFSET 0x1010U /*!< DMA transmit descriptor table address register offset */ 652 #define DMA_CTDADDR_REG_OFFSET 0x1048U /*!< DMA current transmit descriptor address register */ 653 #define DMA_CTBADDR_REG_OFFSET 0x1050U /*!< DMA current transmit buffer address register */ 654 #define DMA_RDTADDR_REG_OFFSET 0x100CU /*!< DMA receive descriptor table address register */ 655 #define DMA_CRDADDR_REG_OFFSET 0x104CU /*!< DMA current receive descriptor address register */ 656 #define DMA_CRBADDR_REG_OFFSET 0x1054U /*!< DMA current receive buffer address register */ 657 658 /* ENET status flag get */ 659 typedef enum 660 { 661 /* ENET_MAC_WUM register */ 662 ENET_MAC_FLAG_MPKR = ENET_REGIDX_BIT(MAC_WUM_REG_OFFSET, 5U), /*!< magic packet received flag */ 663 ENET_MAC_FLAG_WUFR = ENET_REGIDX_BIT(MAC_WUM_REG_OFFSET, 6U), /*!< wakeup frame received flag */ 664 /* ENET_MAC_FCTL register */ 665 ENET_MAC_FLAG_FLOWCONTROL = ENET_REGIDX_BIT(MAC_FCTL_REG_OFFSET, 0U), /*!< flow control status flag */ 666 /* ENET_MAC_INTF register */ 667 ENET_MAC_FLAG_WUM = ENET_REGIDX_BIT(MAC_INTF_REG_OFFSET, 3U), /*!< WUM status flag */ 668 ENET_MAC_FLAG_MSC = ENET_REGIDX_BIT(MAC_INTF_REG_OFFSET, 4U), /*!< MSC status flag */ 669 ENET_MAC_FLAG_MSCR = ENET_REGIDX_BIT(MAC_INTF_REG_OFFSET, 5U), /*!< MSC receive status flag */ 670 ENET_MAC_FLAG_MSCT = ENET_REGIDX_BIT(MAC_INTF_REG_OFFSET, 6U), /*!< MSC transmit status flag */ 671 ENET_MAC_FLAG_TMST = ENET_REGIDX_BIT(MAC_INTF_REG_OFFSET, 9U), /*!< timestamp trigger status flag */ 672 /* ENET_PTP_TSF register */ 673 ENET_PTP_FLAG_TSSCO = ENET_REGIDX_BIT(PTP_TSF_REG_OFFSET, 0U), /*!< timestamp second counter overflow flag */ 674 ENET_PTP_FLAG_TTM = ENET_REGIDX_BIT(PTP_TSF_REG_OFFSET, 1U), /*!< target time match flag */ 675 /* ENET_MSC_RINTF register */ 676 ENET_MSC_FLAG_RFCE = ENET_REGIDX_BIT(MSC_RINTF_REG_OFFSET, 5U), /*!< received frames CRC error flag */ 677 ENET_MSC_FLAG_RFAE = ENET_REGIDX_BIT(MSC_RINTF_REG_OFFSET, 6U), /*!< received frames alignment error flag */ 678 ENET_MSC_FLAG_RGUF = ENET_REGIDX_BIT(MSC_RINTF_REG_OFFSET, 17U), /*!< received good unicast frames flag */ 679 /* ENET_MSC_TINTF register */ 680 ENET_MSC_FLAG_TGFSC = ENET_REGIDX_BIT(MSC_TINTF_REG_OFFSET, 14U), /*!< transmitted good frames single collision flag */ 681 ENET_MSC_FLAG_TGFMSC = ENET_REGIDX_BIT(MSC_TINTF_REG_OFFSET, 15U), /*!< transmitted good frames more single collision flag */ 682 ENET_MSC_FLAG_TGF = ENET_REGIDX_BIT(MSC_TINTF_REG_OFFSET, 21U), /*!< transmitted good frames flag */ 683 /* ENET_DMA_STAT register */ 684 ENET_DMA_FLAG_TS = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 0U), /*!< transmit status flag */ 685 ENET_DMA_FLAG_TPS = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 1U), /*!< transmit process stopped status flag */ 686 ENET_DMA_FLAG_TBU = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 2U), /*!< transmit buffer unavailable status flag */ 687 ENET_DMA_FLAG_TJT = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 3U), /*!< transmit jabber timeout status flag */ 688 ENET_DMA_FLAG_RO = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 4U), /*!< receive overflow status flag */ 689 ENET_DMA_FLAG_TU = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 5U), /*!< transmit underflow status flag */ 690 ENET_DMA_FLAG_RS = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 6U), /*!< receive status flag */ 691 ENET_DMA_FLAG_RBU = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 7U), /*!< receive buffer unavailable status flag */ 692 ENET_DMA_FLAG_RPS = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 8U), /*!< receive process stopped status flag */ 693 ENET_DMA_FLAG_RWT = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 9U), /*!< receive watchdog timeout status flag */ 694 ENET_DMA_FLAG_ET = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 10U), /*!< early transmit status flag */ 695 ENET_DMA_FLAG_FBE = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 13U), /*!< fatal bus error status flag */ 696 ENET_DMA_FLAG_ER = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 14U), /*!< early receive status flag */ 697 ENET_DMA_FLAG_AI = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 15U), /*!< abnormal interrupt summary flag */ 698 ENET_DMA_FLAG_NI = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 16U), /*!< normal interrupt summary flag */ 699 ENET_DMA_FLAG_EB_DMA_ERROR = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 23U), /*!< error during data transfer by RxDMA/TxDMA flag */ 700 ENET_DMA_FLAG_EB_TRANSFER_ERROR = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 24U), /*!< error during write/read transfer flag */ 701 ENET_DMA_FLAG_EB_ACCESS_ERROR = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 25U), /*!< error during data buffer/descriptor access flag */ 702 ENET_DMA_FLAG_MSC = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 27U), /*!< MSC status flag */ 703 ENET_DMA_FLAG_WUM = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 28U), /*!< WUM status flag */ 704 ENET_DMA_FLAG_TST = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 29U), /*!< timestamp trigger status flag */ 705 }enet_flag_enum; 706 707 /* ENET stutus flag clear */ 708 typedef enum 709 { 710 /* ENET_DMA_STAT register */ 711 ENET_DMA_FLAG_TS_CLR = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 0U), /*!< transmit status flag */ 712 ENET_DMA_FLAG_TPS_CLR = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 1U), /*!< transmit process stopped status flag */ 713 ENET_DMA_FLAG_TBU_CLR = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 2U), /*!< transmit buffer unavailable status flag */ 714 ENET_DMA_FLAG_TJT_CLR = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 3U), /*!< transmit jabber timeout status flag */ 715 ENET_DMA_FLAG_RO_CLR = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 4U), /*!< receive overflow status flag */ 716 ENET_DMA_FLAG_TU_CLR = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 5U), /*!< transmit underflow status flag */ 717 ENET_DMA_FLAG_RS_CLR = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 6U), /*!< receive status flag */ 718 ENET_DMA_FLAG_RBU_CLR = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 7U), /*!< receive buffer unavailable status flag */ 719 ENET_DMA_FLAG_RPS_CLR = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 8U), /*!< receive process stopped status flag */ 720 ENET_DMA_FLAG_RWT_CLR = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 9U), /*!< receive watchdog timeout status flag */ 721 ENET_DMA_FLAG_ET_CLR = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 10U), /*!< early transmit status flag */ 722 ENET_DMA_FLAG_FBE_CLR = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 13U), /*!< fatal bus error status flag */ 723 ENET_DMA_FLAG_ER_CLR = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 14U), /*!< early receive status flag */ 724 ENET_DMA_FLAG_AI_CLR = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 15U), /*!< abnormal interrupt summary flag */ 725 ENET_DMA_FLAG_NI_CLR = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 16U), /*!< normal interrupt summary flag */ 726 }enet_flag_clear_enum; 727 728 /* ENET interrupt enable/disable */ 729 typedef enum 730 { 731 /* ENET_MAC_INTMSK register */ 732 ENET_MAC_INT_WUMIM = ENET_REGIDX_BIT(MAC_INTMSK_REG_OFFSET, 3U), /*!< WUM interrupt mask */ 733 ENET_MAC_INT_TMSTIM = ENET_REGIDX_BIT(MAC_INTMSK_REG_OFFSET, 9U), /*!< timestamp trigger interrupt mask */ 734 /* ENET_MSC_RINTMSK register */ 735 ENET_MSC_INT_RFCEIM = ENET_REGIDX_BIT(MSC_RINTMSK_REG_OFFSET, 5U), /*!< received frame CRC error interrupt mask */ 736 ENET_MSC_INT_RFAEIM = ENET_REGIDX_BIT(MSC_RINTMSK_REG_OFFSET, 6U), /*!< received frames alignment error interrupt mask */ 737 ENET_MSC_INT_RGUFIM = ENET_REGIDX_BIT(MSC_RINTMSK_REG_OFFSET, 17U), /*!< received good unicast frames interrupt mask */ 738 /* ENET_MSC_TINTMSK register */ 739 ENET_MSC_INT_TGFSCIM = ENET_REGIDX_BIT(MSC_TINTMSK_REG_OFFSET, 14U), /*!< transmitted good frames single collision interrupt mask */ 740 ENET_MSC_INT_TGFMSCIM = ENET_REGIDX_BIT(MSC_TINTMSK_REG_OFFSET, 15U), /*!< transmitted good frames more single collision interrupt mask */ 741 ENET_MSC_INT_TGFIM = ENET_REGIDX_BIT(MSC_TINTMSK_REG_OFFSET, 21U), /*!< transmitted good frames interrupt mask */ 742 /* ENET_DMA_INTEN register */ 743 ENET_DMA_INT_TIE = ENET_REGIDX_BIT(DMA_INTEN_REG_OFFSET, 0U), /*!< transmit interrupt enable */ 744 ENET_DMA_INT_TPSIE = ENET_REGIDX_BIT(DMA_INTEN_REG_OFFSET, 1U), /*!< transmit process stopped interrupt enable */ 745 ENET_DMA_INT_TBUIE = ENET_REGIDX_BIT(DMA_INTEN_REG_OFFSET, 2U), /*!< transmit buffer unavailable interrupt enable */ 746 ENET_DMA_INT_TJTIE = ENET_REGIDX_BIT(DMA_INTEN_REG_OFFSET, 3U), /*!< transmit jabber timeout interrupt enable */ 747 ENET_DMA_INT_ROIE = ENET_REGIDX_BIT(DMA_INTEN_REG_OFFSET, 4U), /*!< receive overflow interrupt enable */ 748 ENET_DMA_INT_TUIE = ENET_REGIDX_BIT(DMA_INTEN_REG_OFFSET, 5U), /*!< transmit underflow interrupt enable */ 749 ENET_DMA_INT_RIE = ENET_REGIDX_BIT(DMA_INTEN_REG_OFFSET, 6U), /*!< receive interrupt enable */ 750 ENET_DMA_INT_RBUIE = ENET_REGIDX_BIT(DMA_INTEN_REG_OFFSET, 7U), /*!< receive buffer unavailable interrupt enable */ 751 ENET_DMA_INT_RPSIE = ENET_REGIDX_BIT(DMA_INTEN_REG_OFFSET, 8U), /*!< receive process stopped interrupt enable */ 752 ENET_DMA_INT_RWTIE = ENET_REGIDX_BIT(DMA_INTEN_REG_OFFSET, 9U), /*!< receive watchdog timeout interrupt enable */ 753 ENET_DMA_INT_ETIE = ENET_REGIDX_BIT(DMA_INTEN_REG_OFFSET, 10U), /*!< early transmit interrupt enable */ 754 ENET_DMA_INT_FBEIE = ENET_REGIDX_BIT(DMA_INTEN_REG_OFFSET, 13U), /*!< fatal bus error interrupt enable */ 755 ENET_DMA_INT_ERIE = ENET_REGIDX_BIT(DMA_INTEN_REG_OFFSET, 14U), /*!< early receive interrupt enable */ 756 ENET_DMA_INT_AIE = ENET_REGIDX_BIT(DMA_INTEN_REG_OFFSET, 15U), /*!< abnormal interrupt summary enable */ 757 ENET_DMA_INT_NIE = ENET_REGIDX_BIT(DMA_INTEN_REG_OFFSET, 16U), /*!< normal interrupt summary enable */ 758 }enet_int_enum; 759 760 /* ENET interrupt flag get */ 761 typedef enum 762 { 763 /* ENET_MAC_INTF register */ 764 ENET_MAC_INT_FLAG_WUM = ENET_REGIDX_BIT(MAC_INTF_REG_OFFSET, 3U), /*!< WUM status flag */ 765 ENET_MAC_INT_FLAG_MSC = ENET_REGIDX_BIT(MAC_INTF_REG_OFFSET, 4U), /*!< MSC status flag */ 766 ENET_MAC_INT_FLAG_MSCR = ENET_REGIDX_BIT(MAC_INTF_REG_OFFSET, 5U), /*!< MSC receive status flag */ 767 ENET_MAC_INT_FLAG_MSCT = ENET_REGIDX_BIT(MAC_INTF_REG_OFFSET, 6U), /*!< MSC transmit status flag */ 768 ENET_MAC_INT_FLAG_TMST = ENET_REGIDX_BIT(MAC_INTF_REG_OFFSET, 9U), /*!< timestamp trigger status flag */ 769 /* ENET_MSC_RINTF register */ 770 ENET_MSC_INT_FLAG_RFCE = ENET_REGIDX_BIT(MSC_RINTF_REG_OFFSET, 5U), /*!< received frames CRC error flag */ 771 ENET_MSC_INT_FLAG_RFAE = ENET_REGIDX_BIT(MSC_RINTF_REG_OFFSET, 6U), /*!< received frames alignment error flag */ 772 ENET_MSC_INT_FLAG_RGUF = ENET_REGIDX_BIT(MSC_RINTF_REG_OFFSET, 17U), /*!< received good unicast frames flag */ 773 /* ENET_MSC_TINTF register */ 774 ENET_MSC_INT_FLAG_TGFSC = ENET_REGIDX_BIT(MSC_TINTF_REG_OFFSET, 14U), /*!< transmitted good frames single collision flag */ 775 ENET_MSC_INT_FLAG_TGFMSC = ENET_REGIDX_BIT(MSC_TINTF_REG_OFFSET, 15U), /*!< transmitted good frames more single collision flag */ 776 ENET_MSC_INT_FLAG_TGF = ENET_REGIDX_BIT(MSC_TINTF_REG_OFFSET, 21U), /*!< transmitted good frames flag */ 777 /* ENET_DMA_STAT register */ 778 ENET_DMA_INT_FLAG_TS = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 0U), /*!< transmit status flag */ 779 ENET_DMA_INT_FLAG_TPS = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 1U), /*!< transmit process stopped status flag */ 780 ENET_DMA_INT_FLAG_TBU = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 2U), /*!< transmit buffer unavailable status flag */ 781 ENET_DMA_INT_FLAG_TJT = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 3U), /*!< transmit jabber timeout status flag */ 782 ENET_DMA_INT_FLAG_RO = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 4U), /*!< receive overflow status flag */ 783 ENET_DMA_INT_FLAG_TU = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 5U), /*!< transmit underflow status flag */ 784 ENET_DMA_INT_FLAG_RS = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 6U), /*!< receive status flag */ 785 ENET_DMA_INT_FLAG_RBU = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 7U), /*!< receive buffer unavailable status flag */ 786 ENET_DMA_INT_FLAG_RPS = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 8U), /*!< receive process stopped status flag */ 787 ENET_DMA_INT_FLAG_RWT = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 9U), /*!< receive watchdog timeout status flag */ 788 ENET_DMA_INT_FLAG_ET = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 10U), /*!< early transmit status flag */ 789 ENET_DMA_INT_FLAG_FBE = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 13U), /*!< fatal bus error status flag */ 790 ENET_DMA_INT_FLAG_ER = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 14U), /*!< early receive status flag */ 791 ENET_DMA_INT_FLAG_AI = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 15U), /*!< abnormal interrupt summary flag */ 792 ENET_DMA_INT_FLAG_NI = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 16U), /*!< normal interrupt summary flag */ 793 ENET_DMA_INT_FLAG_MSC = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 27U), /*!< MSC status flag */ 794 ENET_DMA_INT_FLAG_WUM = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 28U), /*!< WUM status flag */ 795 ENET_DMA_INT_FLAG_TST = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 29U), /*!< timestamp trigger status flag */ 796 }enet_int_flag_enum; 797 798 /* ENET interrupt flag clear */ 799 typedef enum 800 { 801 /* ENET_DMA_STAT register */ 802 ENET_DMA_INT_FLAG_TS_CLR = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 0U), /*!< transmit status flag */ 803 ENET_DMA_INT_FLAG_TPS_CLR = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 1U), /*!< transmit process stopped status flag */ 804 ENET_DMA_INT_FLAG_TBU_CLR = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 2U), /*!< transmit buffer unavailable status flag */ 805 ENET_DMA_INT_FLAG_TJT_CLR = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 3U), /*!< transmit jabber timeout status flag */ 806 ENET_DMA_INT_FLAG_RO_CLR = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 4U), /*!< receive overflow status flag */ 807 ENET_DMA_INT_FLAG_TU_CLR = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 5U), /*!< transmit underflow status flag */ 808 ENET_DMA_INT_FLAG_RS_CLR = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 6U), /*!< receive status flag */ 809 ENET_DMA_INT_FLAG_RBU_CLR = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 7U), /*!< receive buffer unavailable status flag */ 810 ENET_DMA_INT_FLAG_RPS_CLR = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 8U), /*!< receive process stopped status flag */ 811 ENET_DMA_INT_FLAG_RWT_CLR = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 9U), /*!< receive watchdog timeout status flag */ 812 ENET_DMA_INT_FLAG_ET_CLR = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 10U), /*!< early transmit status flag */ 813 ENET_DMA_INT_FLAG_FBE_CLR = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 13U), /*!< fatal bus error status flag */ 814 ENET_DMA_INT_FLAG_ER_CLR = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 14U), /*!< early receive status flag */ 815 ENET_DMA_INT_FLAG_AI_CLR = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 15U), /*!< abnormal interrupt summary flag */ 816 ENET_DMA_INT_FLAG_NI_CLR = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 16U), /*!< normal interrupt summary flag */ 817 }enet_int_flag_clear_enum; 818 819 /* current RX/TX descriptor/buffer/descriptor table address get */ 820 typedef enum 821 { 822 ENET_RX_DESC_TABLE = DMA_RDTADDR_REG_OFFSET, /*!< RX descriptor table */ 823 ENET_RX_CURRENT_DESC = DMA_CRDADDR_REG_OFFSET, /*!< current RX descriptor */ 824 ENET_RX_CURRENT_BUFFER = DMA_CRBADDR_REG_OFFSET, /*!< current RX buffer */ 825 ENET_TX_DESC_TABLE = DMA_TDTADDR_REG_OFFSET, /*!< TX descriptor table */ 826 ENET_TX_CURRENT_DESC = DMA_CTDADDR_REG_OFFSET, /*!< current TX descriptor */ 827 ENET_TX_CURRENT_BUFFER = DMA_CTBADDR_REG_OFFSET /*!< current TX buffer */ 828 }enet_desc_reg_enum; 829 830 /* MAC statistics counter get */ 831 typedef enum 832 { 833 ENET_MSC_TX_SCCNT = MSC_SCCNT_REG_OFFSET, /*!< MSC transmitted good frames after a single collision counter */ 834 ENET_MSC_TX_MSCCNT = MSC_MSCCNT_REG_OFFSET, /*!< MSC transmitted good frames after more than a single collision counter */ 835 ENET_MSC_TX_TGFCNT = MSC_TGFCNT_REG_OFFSET, /*!< MSC transmitted good frames counter */ 836 ENET_MSC_RX_RFCECNT = MSC_RFCECNT_REG_OFFSET, /*!< MSC received frames with CRC error counter */ 837 ENET_MSC_RX_RFAECNT = MSC_RFAECNT_REG_OFFSET, /*!< MSC received frames with alignment error counter */ 838 ENET_MSC_RX_RGUFCNT = MSC_RGUFCNT_REG_OFFSET /*!< MSC received good unicast frames counter */ 839 }enet_msc_counter_enum; 840 841 /* function option, used for ENET initialization */ 842 typedef enum 843 { 844 FORWARD_OPTION = BIT(0), /*!< configure the frame forward related parameters */ 845 DMABUS_OPTION = BIT(1), /*!< configure the DMA bus mode related parameters */ 846 DMA_MAXBURST_OPTION = BIT(2), /*!< configure the DMA max burst related parameters */ 847 DMA_ARBITRATION_OPTION = BIT(3), /*!< configure the DMA arbitration related parameters */ 848 STORE_OPTION = BIT(4), /*!< configure the store forward mode related parameters */ 849 DMA_OPTION = BIT(5), /*!< configure the DMA control related parameters */ 850 VLAN_OPTION = BIT(6), /*!< configure the VLAN tag related parameters */ 851 FLOWCTL_OPTION = BIT(7), /*!< configure the flow control related parameters */ 852 HASHH_OPTION = BIT(8), /*!< configure the hash list high 32-bit related parameters */ 853 HASHL_OPTION = BIT(9), /*!< configure the hash list low 32-bit related parameters */ 854 FILTER_OPTION = BIT(10), /*!< configure the frame filter control related parameters */ 855 HALFDUPLEX_OPTION = BIT(11), /*!< configure the halfduplex related parameters */ 856 TIMER_OPTION = BIT(12), /*!< configure the frame timer related parameters */ 857 INTERFRAMEGAP_OPTION = BIT(13), /*!< configure the inter frame gap related parameters */ 858 }enet_option_enum; 859 860 /* phy mode and mac loopback configurations */ 861 typedef enum 862 { 863 ENET_AUTO_NEGOTIATION = 0x01u, /*!< PHY auto negotiation */ 864 ENET_100M_FULLDUPLEX = (ENET_MAC_CFG_SPD | ENET_MAC_CFG_DPM), /*!< 100Mbit/s, full-duplex */ 865 ENET_100M_HALFDUPLEX = ENET_MAC_CFG_SPD , /*!< 100Mbit/s, half-duplex */ 866 ENET_10M_FULLDUPLEX = ENET_MAC_CFG_DPM, /*!< 10Mbit/s, full-duplex */ 867 ENET_10M_HALFDUPLEX = (uint32_t)0x00000000U, /*!< 10Mbit/s, half-duplex */ 868 ENET_LOOPBACKMODE = (ENET_MAC_CFG_LBM | ENET_MAC_CFG_DPM) /*!< MAC in loopback mode at the MII */ 869 }enet_mediamode_enum; 870 871 /* IP frame checksum function */ 872 typedef enum 873 { 874 ENET_NO_AUTOCHECKSUM = (uint32_t)0x00000000U, /*!< disable IP frame checksum function */ 875 ENET_AUTOCHECKSUM_DROP_FAILFRAMES = ENET_MAC_CFG_IPFCO, /*!< enable IP frame checksum function */ 876 ENET_AUTOCHECKSUM_ACCEPT_FAILFRAMES = (ENET_MAC_CFG_IPFCO|ENET_DMA_CTL_DTCERFD) /*!< enable IP frame checksum function, and the received frame 877 with only payload error but no other errors will not be dropped */ 878 }enet_chksumconf_enum; 879 880 /* received frame filter function */ 881 typedef enum 882 { 883 ENET_PROMISCUOUS_MODE = ENET_MAC_FRMF_PM, /*!< promiscuous mode enabled */ 884 ENET_RECEIVEALL = (int32_t)ENET_MAC_FRMF_FAR, /*!< all received frame are forwarded to application */ 885 ENET_BROADCAST_FRAMES_PASS = (uint32_t)0x00000000U, /*!< the address filters pass all received broadcast frames */ 886 ENET_BROADCAST_FRAMES_DROP = ENET_MAC_FRMF_BFRMD /*!< the address filters filter all incoming broadcast frames */ 887 }enet_frmrecept_enum; 888 889 /* register group value get */ 890 typedef enum 891 { 892 ALL_MAC_REG = 0, /*!< MAC register group */ 893 ALL_MSC_REG = 22, /*!< MSC register group */ 894 ALL_PTP_REG = 33, /*!< PTP register group */ 895 ALL_DMA_REG = 44, /*!< DMA register group */ 896 }enet_registers_type_enum; 897 898 /* dma direction select */ 899 typedef enum 900 { 901 ENET_DMA_TX = ENET_DMA_STAT_TP, /*!< DMA transmit direction */ 902 ENET_DMA_RX = ENET_DMA_STAT_RP /*!< DMA receive direction */ 903 }enet_dmadirection_enum; 904 905 /* PHY operation direction select */ 906 typedef enum 907 { 908 ENET_PHY_READ = (uint32_t)0x00000000, /*!< read PHY */ 909 ENET_PHY_WRITE = ENET_MAC_PHY_CTL_PW /*!< write PHY */ 910 }enet_phydirection_enum; 911 912 /* register operation direction select */ 913 typedef enum 914 { 915 ENET_REG_READ, /*!< read register */ 916 ENET_REG_WRITE /*!< write register */ 917 }enet_regdirection_enum; 918 919 /* ENET MAC addresses */ 920 typedef enum 921 { 922 ENET_MAC_ADDRESS0 = ((uint32_t)0x00000000), /*!< MAC address0 */ 923 ENET_MAC_ADDRESS1 = ((uint32_t)0x00000008), /*!< MAC address1 */ 924 ENET_MAC_ADDRESS2 = ((uint32_t)0x00000010), /*!< MAC address2 */ 925 ENET_MAC_ADDRESS3 = ((uint32_t)0x00000018) /*!< MAC address3 */ 926 }enet_macaddress_enum; 927 928 /* descriptor information */ 929 typedef enum 930 { 931 TXDESC_COLLISION_COUNT, /*!< the number of collisions occurred before the frame was transmitted */ 932 TXDESC_BUFFER_1_ADDR, /*!< transmit frame buffer 1 address */ 933 RXDESC_FRAME_LENGTH, /*!< the byte length of the received frame that was transferred to the buffer */ 934 RXDESC_BUFFER_1_SIZE, /*!< receive buffer 1 size */ 935 RXDESC_BUFFER_2_SIZE, /*!< receive buffer 2 size */ 936 RXDESC_BUFFER_1_ADDR /*!< receive frame buffer 1 address */ 937 }enet_descstate_enum; 938 939 /* MSC counters preset mode */ 940 typedef enum 941 { 942 ENET_MSC_PRESET_NONE = 0U, /*!< do not preset MSC counter */ 943 ENET_MSC_PRESET_HALF = ENET_MSC_CTL_PMC, /*!< preset all MSC counters to almost-half(0x7FFF FFF0) value */ 944 ENET_MSC_PRESET_FULL = ENET_MSC_CTL_PMC | ENET_MSC_CTL_AFHPM /*!< preset all MSC counters to almost-full(0xFFFF FFF0) value */ 945 }enet_msc_preset_enum; 946 947 /* structure for initialization of the ENET */ 948 typedef struct 949 { 950 uint32_t option_enable; /*!< select which function to configure */ 951 uint32_t forward_frame; /*!< frame forward related parameters */ 952 uint32_t dmabus_mode; /*!< DMA bus mode related parameters */ 953 uint32_t dma_maxburst; /*!< DMA max burst related parameters */ 954 uint32_t dma_arbitration; /*!< DMA Tx and Rx arbitration related parameters */ 955 uint32_t store_forward_mode; /*!< store forward mode related parameters */ 956 uint32_t dma_function; /*!< DMA control related parameters */ 957 uint32_t vlan_config; /*!< VLAN tag related parameters */ 958 uint32_t flow_control; /*!< flow control related parameters */ 959 uint32_t hashtable_high; /*!< hash list high 32-bit related parameters */ 960 uint32_t hashtable_low; /*!< hash list low 32-bit related parameters */ 961 uint32_t framesfilter_mode; /*!< frame filter control related parameters */ 962 uint32_t halfduplex_param; /*!< halfduplex related parameters */ 963 uint32_t timer_config; /*!< frame timer related parameters */ 964 uint32_t interframegap; /*!< inter frame gap related parameters */ 965 }enet_initpara_struct; 966 967 /* structure for ENET DMA desciptors */ 968 typedef struct 969 { 970 uint32_t status; /*!< status */ 971 uint32_t control_buffer_size; /*!< control and buffer1, buffer2 lengths */ 972 uint32_t buffer1_addr; /*!< buffer1 address pointer/timestamp low */ 973 uint32_t buffer2_next_desc_addr; /*!< buffer2 or next descriptor address pointer/timestamp high */ 974 975 #ifdef SELECT_DESCRIPTORS_ENHANCED_MODE 976 uint32_t extended_status; /*!< extended status */ 977 uint32_t reserved; /*!< reserved */ 978 uint32_t timestamp_low; /*!< timestamp low */ 979 uint32_t timestamp_high; /*!< timestamp high */ 980 #endif /* SELECT_DESCRIPTORS_ENHANCED_MODE */ 981 982 } enet_descriptors_struct; 983 984 /* structure of PTP system time */ 985 typedef struct 986 { 987 uint32_t second; /*!< second of system time */ 988 uint32_t nanosecond; /*!< nanosecond of system time */ 989 uint32_t sign; /*!< sign of system time */ 990 }enet_ptp_systime_struct; 991 992 /* mac_cfg register value */ 993 #define MAC_CFG_BOL(regval) (BITS(5,6) & ((uint32_t)(regval) << 5)) /*!< write value to ENET_MAC_CFG_BOL bit field */ 994 #define ENET_BACKOFFLIMIT_10 MAC_CFG_BOL(0) /*!< min (n, 10) */ 995 #define ENET_BACKOFFLIMIT_8 MAC_CFG_BOL(1) /*!< min (n, 8) */ 996 #define ENET_BACKOFFLIMIT_4 MAC_CFG_BOL(2) /*!< min (n, 4) */ 997 #define ENET_BACKOFFLIMIT_1 MAC_CFG_BOL(3) /*!< min (n, 1) */ 998 999 #define MAC_CFG_IGBS(regval) (BITS(17,19) & ((uint32_t)(regval) << 17)) /*!< write value to ENET_MAC_CFG_IGBS bit field */ 1000 #define ENET_INTERFRAMEGAP_96BIT MAC_CFG_IGBS(0) /*!< minimum 96 bit times */ 1001 #define ENET_INTERFRAMEGAP_88BIT MAC_CFG_IGBS(1) /*!< minimum 88 bit times */ 1002 #define ENET_INTERFRAMEGAP_80BIT MAC_CFG_IGBS(2) /*!< minimum 80 bit times */ 1003 #define ENET_INTERFRAMEGAP_72BIT MAC_CFG_IGBS(3) /*!< minimum 72 bit times */ 1004 #define ENET_INTERFRAMEGAP_64BIT MAC_CFG_IGBS(4) /*!< minimum 64 bit times */ 1005 #define ENET_INTERFRAMEGAP_56BIT MAC_CFG_IGBS(5) /*!< minimum 56 bit times */ 1006 #define ENET_INTERFRAMEGAP_48BIT MAC_CFG_IGBS(6) /*!< minimum 48 bit times */ 1007 #define ENET_INTERFRAMEGAP_40BIT MAC_CFG_IGBS(7) /*!< minimum 40 bit times */ 1008 1009 #define ENET_TYPEFRAME_CRC_DROP_ENABLE ENET_MAC_CFG_TFCD /*!< FCS field(last 4 bytes) of frame will be dropped before forwarding */ 1010 #define ENET_TYPEFRAME_CRC_DROP_DISABLE ((uint32_t)0x00000000U) /*!< FCS field(last 4 bytes) of frame will not be dropped before forwarding */ 1011 #define ENET_TYPEFRAME_CRC_DROP ENET_MAC_CFG_TFCD /*!< the function that FCS field(last 4 bytes) of frame will be dropped before forwarding */ 1012 1013 #define ENET_WATCHDOG_ENABLE ((uint32_t)0x00000000U) /*!< the MAC allows no more than 2048 bytes of the frame being received */ 1014 #define ENET_WATCHDOG_DISABLE ENET_MAC_CFG_WDD /*!< the MAC disables the watchdog timer on the receiver, and can receive frames of up to 16384 bytes */ 1015 1016 #define ENET_JABBER_ENABLE ((uint32_t)0x00000000U) /*!< the maximum transmission byte is 2048 */ 1017 #define ENET_JABBER_DISABLE ENET_MAC_CFG_JBD /*!< the maximum transmission byte can be 16384 */ 1018 1019 #define ENET_CARRIERSENSE_ENABLE ((uint32_t)0x00000000U) /*!< the MAC transmitter generates carrier sense error and aborts the transmission */ 1020 #define ENET_CARRIERSENSE_DISABLE ENET_MAC_CFG_CSD /*!< the MAC transmitter ignores the MII CRS signal during frame transmission in half-duplex mode */ 1021 1022 #define ENET_SPEEDMODE_10M ((uint32_t)0x00000000U) /*!< 10 Mbit/s */ 1023 #define ENET_SPEEDMODE_100M ENET_MAC_CFG_SPD /*!< 100 Mbit/s */ 1024 1025 #define ENET_RECEIVEOWN_ENABLE ((uint32_t)0x00000000U) /*!< the MAC receives all packets that are given by the PHY while transmitting */ 1026 #define ENET_RECEIVEOWN_DISABLE ENET_MAC_CFG_ROD /*!< the MAC disables the reception of frames in half-duplex mode */ 1027 1028 #define ENET_LOOPBACKMODE_ENABLE ENET_MAC_CFG_LBM /*!< the MAC operates in loopback mode at the MII */ 1029 #define ENET_LOOPBACKMODE_DISABLE ((uint32_t)0x00000000U) /*!< the MAC operates in normal mode */ 1030 1031 #define ENET_MODE_FULLDUPLEX ENET_MAC_CFG_DPM /*!< full-duplex mode enable */ 1032 #define ENET_MODE_HALFDUPLEX ((uint32_t)0x00000000U) /*!< half-duplex mode enable */ 1033 1034 #define ENET_CHECKSUMOFFLOAD_ENABLE ENET_MAC_CFG_IPFCO /*!< IP frame checksum offload function enabled for received IP frame */ 1035 #define ENET_CHECKSUMOFFLOAD_DISABLE ((uint32_t)0x00000000U) /*!< the checksum offload function in the receiver is disabled */ 1036 1037 #define ENET_RETRYTRANSMISSION_ENABLE ((uint32_t)0x00000000U) /*!< the MAC attempts retries up to 16 times based on the settings of BOL*/ 1038 #define ENET_RETRYTRANSMISSION_DISABLE ENET_MAC_CFG_RTD /*!< the MAC attempts only 1 transmission */ 1039 1040 #define ENET_AUTO_PADCRC_DROP_ENABLE ENET_MAC_CFG_APCD /*!< the MAC strips the Pad/FCS field on received frames */ 1041 #define ENET_AUTO_PADCRC_DROP_DISABLE ((uint32_t)0x00000000U) /*!< the MAC forwards all received frames without modify it */ 1042 #define ENET_AUTO_PADCRC_DROP ENET_MAC_CFG_APCD /*!< the function of the MAC strips the Pad/FCS field on received frames */ 1043 1044 #define ENET_DEFERRALCHECK_ENABLE ENET_MAC_CFG_DFC /*!< the deferral check function is enabled in the MAC */ 1045 #define ENET_DEFERRALCHECK_DISABLE ((uint32_t)0x00000000U) /*!< the deferral check function is disabled */ 1046 1047 /* mac_frmf register value */ 1048 #define MAC_FRMF_PCFRM(regval) (BITS(6,7) & ((uint32_t)(regval) << 6)) /*!< write value to ENET_MAC_FRMF_PCFRM bit field */ 1049 #define ENET_PCFRM_PREVENT_ALL MAC_FRMF_PCFRM(0) /*!< MAC prevents all control frames from reaching the application */ 1050 #define ENET_PCFRM_PREVENT_PAUSEFRAME MAC_FRMF_PCFRM(1) /*!< MAC only forwards all other control frames except pause control frame */ 1051 #define ENET_PCFRM_FORWARD_ALL MAC_FRMF_PCFRM(2) /*!< MAC forwards all control frames to application even if they fail the address filter */ 1052 #define ENET_PCFRM_FORWARD_FILTERED MAC_FRMF_PCFRM(3) /*!< MAC forwards control frames that only pass the address filter */ 1053 1054 #define ENET_RX_FILTER_DISABLE ENET_MAC_FRMF_FAR /*!< all received frame are forwarded to application */ 1055 #define ENET_RX_FILTER_ENABLE ((uint32_t)0x00000000U) /*!< only the frame passed the filter can be forwarded to application */ 1056 1057 #define ENET_SRC_FILTER_NORMAL_ENABLE ENET_MAC_FRMF_SAFLT /*!< filter source address */ 1058 #define ENET_SRC_FILTER_INVERSE_ENABLE (ENET_MAC_FRMF_SAFLT | ENET_MAC_FRMF_SAIFLT) /*!< inverse source address filtering result */ 1059 #define ENET_SRC_FILTER_DISABLE ((uint32_t)0x00000000U) /*!< source address function in filter disable */ 1060 #define ENET_SRC_FILTER ENET_MAC_FRMF_SAFLT /*!< filter source address function */ 1061 #define ENET_SRC_FILTER_INVERSE ENET_MAC_FRMF_SAIFLT /*!< inverse source address filtering result function */ 1062 1063 #define ENET_BROADCASTFRAMES_ENABLE ((uint32_t)0x00000000U) /*!< the address filters pass all received broadcast frames */ 1064 #define ENET_BROADCASTFRAMES_DISABLE ENET_MAC_FRMF_BFRMD /*!< the address filters filter all incoming broadcast frames */ 1065 1066 #define ENET_DEST_FILTER_INVERSE_ENABLE ENET_MAC_FRMF_DAIFLT /*!< inverse DA filtering result */ 1067 #define ENET_DEST_FILTER_INVERSE_DISABLE ((uint32_t)0x00000000U) /*!< not inverse DA filtering result */ 1068 #define ENET_DEST_FILTER_INVERSE ENET_MAC_FRMF_DAIFLT /*!< inverse DA filtering result function */ 1069 1070 #define ENET_PROMISCUOUS_ENABLE ENET_MAC_FRMF_PM /*!< promiscuous mode enabled */ 1071 #define ENET_PROMISCUOUS_DISABLE ((uint32_t)0x00000000U) /*!< promiscuous mode disabled */ 1072 1073 #define ENET_MULTICAST_FILTER_HASH_OR_PERFECT (ENET_MAC_FRMF_HMF | ENET_MAC_FRMF_HPFLT) /*!< pass multicast frames that match either the perfect or the hash filtering */ 1074 #define ENET_MULTICAST_FILTER_HASH ENET_MAC_FRMF_HMF /*!< pass multicast frames that match the hash filtering */ 1075 #define ENET_MULTICAST_FILTER_PERFECT ((uint32_t)0x00000000U) /*!< pass multicast frames that match the perfect filtering */ 1076 #define ENET_MULTICAST_FILTER_NONE ENET_MAC_FRMF_MFD /*!< all multicast frames are passed */ 1077 #define ENET_MULTICAST_FILTER_PASS ENET_MAC_FRMF_MFD /*!< pass all multicast frames function */ 1078 #define ENET_MULTICAST_FILTER_HASH_MODE ENET_MAC_FRMF_HMF /*!< HASH multicast filter function */ 1079 #define ENET_FILTER_MODE_EITHER ENET_MAC_FRMF_HPFLT /*!< HASH or perfect filter function */ 1080 1081 #define ENET_UNICAST_FILTER_EITHER (ENET_MAC_FRMF_HUF | ENET_MAC_FRMF_HPFLT) /*!< pass unicast frames that match either the perfect or the hash filtering */ 1082 #define ENET_UNICAST_FILTER_HASH ENET_MAC_FRMF_HUF /*!< pass unicast frames that match the hash filtering */ 1083 #define ENET_UNICAST_FILTER_PERFECT ((uint32_t)0x00000000U) /*!< pass unicast frames that match the perfect filtering */ 1084 #define ENET_UNICAST_FILTER_HASH_MODE ENET_MAC_FRMF_HUF /*!< HASH unicast filter function */ 1085 1086 /* mac_phy_ctl register value */ 1087 #define MAC_PHY_CTL_CLR(regval) (BITS(2,4) & ((uint32_t)(regval) << 2)) /*!< write value to ENET_MAC_PHY_CTL_CLR bit field */ 1088 #define ENET_MDC_HCLK_DIV42 MAC_PHY_CTL_CLR(0) /*!< HCLK:60-100 MHz; MDC clock= HCLK/42 */ 1089 #define ENET_MDC_HCLK_DIV62 MAC_PHY_CTL_CLR(1) /*!< HCLK:100-150 MHz; MDC clock= HCLK/62 */ 1090 #define ENET_MDC_HCLK_DIV16 MAC_PHY_CTL_CLR(2) /*!< HCLK:20-35 MHz; MDC clock= HCLK/16 */ 1091 #define ENET_MDC_HCLK_DIV26 MAC_PHY_CTL_CLR(3) /*!< HCLK:35-60 MHz; MDC clock= HCLK/26 */ 1092 #define ENET_MDC_HCLK_DIV102 MAC_PHY_CTL_CLR(4) /*!< HCLK:150-180 MHz; MDC clock= HCLK/102 */ 1093 1094 #define MAC_PHY_CTL_PR(regval) (BITS(6,10) & ((uint32_t)(regval) << 6)) /*!< write value to ENET_MAC_PHY_CTL_PR bit field */ 1095 1096 #define MAC_PHY_CTL_PA(regval) (BITS(11,15) & ((uint32_t)(regval) << 11)) /*!< write value to ENET_MAC_PHY_CTL_PA bit field */ 1097 1098 /* mac_phy_data register value */ 1099 #define MAC_PHY_DATA_PD(regval) (BITS(0,15) & ((uint32_t)(regval) << 0)) /*!< write value to ENET_MAC_PHY_DATA_PD bit field */ 1100 1101 /* mac_fctl register value */ 1102 #define MAC_FCTL_PLTS(regval) (BITS(4,5) & ((uint32_t)(regval) << 4)) /*!< write value to ENET_MAC_FCTL_PLTS bit field */ 1103 #define ENET_PAUSETIME_MINUS4 MAC_FCTL_PLTS(0) /*!< pause time minus 4 slot times */ 1104 #define ENET_PAUSETIME_MINUS28 MAC_FCTL_PLTS(1) /*!< pause time minus 28 slot times */ 1105 #define ENET_PAUSETIME_MINUS144 MAC_FCTL_PLTS(2) /*!< pause time minus 144 slot times */ 1106 #define ENET_PAUSETIME_MINUS256 MAC_FCTL_PLTS(3) /*!< pause time minus 256 slot times */ 1107 1108 #define ENET_ZERO_QUANTA_PAUSE_ENABLE ((uint32_t)0x00000000U) /*!< enable the automatic zero-quanta generation function */ 1109 #define ENET_ZERO_QUANTA_PAUSE_DISABLE ENET_MAC_FCTL_DZQP /*!< disable the automatic zero-quanta generation function */ 1110 #define ENET_ZERO_QUANTA_PAUSE ENET_MAC_FCTL_DZQP /*!< the automatic zero-quanta generation function */ 1111 1112 #define ENET_MAC0_AND_UNIQUE_ADDRESS_PAUSEDETECT ENET_MAC_FCTL_UPFDT /*!< besides the unique multicast address, MAC also use the MAC0 address to detect pause frame */ 1113 #define ENET_UNIQUE_PAUSEDETECT ((uint32_t)0x00000000U) /*!< only the unique multicast address for pause frame which is specified in IEEE802.3 can be detected */ 1114 1115 #define ENET_RX_FLOWCONTROL_ENABLE ENET_MAC_FCTL_RFCEN /*!< enable decoding function for the received pause frame and process it */ 1116 #define ENET_RX_FLOWCONTROL_DISABLE ((uint32_t)0x00000000U) /*!< decode function for pause frame is disabled */ 1117 #define ENET_RX_FLOWCONTROL ENET_MAC_FCTL_RFCEN /*!< decoding function for the received pause frame and process it */ 1118 1119 #define ENET_TX_FLOWCONTROL_ENABLE ENET_MAC_FCTL_TFCEN /*!< enable the flow control operation in the MAC */ 1120 #define ENET_TX_FLOWCONTROL_DISABLE ((uint32_t)0x00000000U) /*!< disable the flow control operation in the MAC */ 1121 #define ENET_TX_FLOWCONTROL ENET_MAC_FCTL_TFCEN /*!< the flow control operation in the MAC */ 1122 1123 #define ENET_BACK_PRESSURE_ENABLE ENET_MAC_FCTL_FLCBBKPA /*!< enable the back pressure operation in the MAC */ 1124 #define ENET_BACK_PRESSURE_DISABLE ((uint32_t)0x00000000U) /*!< disable the back pressure operation in the MAC */ 1125 #define ENET_BACK_PRESSURE ENET_MAC_FCTL_FLCBBKPA /*!< the back pressure operation in the MAC */ 1126 1127 #define MAC_FCTL_PTM(regval) (BITS(16,31) & ((uint32_t)(regval) << 16)) /*!< write value to ENET_MAC_FCTL_PTM bit field */ 1128 /* mac_vlt register value */ 1129 #define MAC_VLT_VLTI(regval) (BITS(0,15) & ((uint32_t)(regval) << 0)) /*!< write value to ENET_MAC_VLT_VLTI bit field */ 1130 1131 #define ENET_VLANTAGCOMPARISON_12BIT ENET_MAC_VLT_VLTC /*!< only low 12 bits of the VLAN tag are used for comparison */ 1132 #define ENET_VLANTAGCOMPARISON_16BIT ((uint32_t)0x00000000U) /*!< all 16 bits of the VLAN tag are used for comparison */ 1133 1134 /* mac_wum register value */ 1135 #define ENET_WUM_FLAG_WUFFRPR ENET_MAC_WUM_WUFFRPR /*!< wakeup frame filter register poniter reset */ 1136 #define ENET_WUM_FLAG_WUFR ENET_MAC_WUM_WUFR /*!< wakeup frame received */ 1137 #define ENET_WUM_FLAG_MPKR ENET_MAC_WUM_MPKR /*!< magic packet received */ 1138 #define ENET_WUM_POWER_DOWN ENET_MAC_WUM_PWD /*!< power down mode */ 1139 #define ENET_WUM_MAGIC_PACKET_FRAME ENET_MAC_WUM_MPEN /*!< enable a wakeup event due to magic packet reception */ 1140 #define ENET_WUM_WAKE_UP_FRAME ENET_MAC_WUM_WFEN /*!< enable a wakeup event due to wakeup frame reception */ 1141 #define ENET_WUM_GLOBAL_UNICAST ENET_MAC_WUM_GU /*!< any received unicast frame passed filter is considered to be a wakeup frame */ 1142 1143 /* mac_dbg register value */ 1144 #define ENET_MAC_RECEIVER_NOT_IDLE ENET_MAC_DBG_MRNI /*!< MAC receiver is not in idle state */ 1145 #define ENET_RX_ASYNCHRONOUS_FIFO_STATE ENET_MAC_DBG_RXAFS /*!< Rx asynchronous FIFO status */ 1146 #define ENET_RXFIFO_WRITING ENET_MAC_DBG_RXFW /*!< RxFIFO is doing write operation */ 1147 #define ENET_RXFIFO_READ_STATUS ENET_MAC_DBG_RXFRS /*!< RxFIFO read operation status */ 1148 #define ENET_RXFIFO_STATE ENET_MAC_DBG_RXFS /*!< RxFIFO state */ 1149 #define ENET_MAC_TRANSMITTER_NOT_IDLE ENET_MAC_DBG_MTNI /*!< MAC transmitter is not in idle state */ 1150 #define ENET_MAC_TRANSMITTER_STATUS ENET_MAC_DBG_SOMT /*!< status of MAC transmitter */ 1151 #define ENET_PAUSE_CONDITION_STATUS ENET_MAC_DBG_PCS /*!< pause condition status */ 1152 #define ENET_TXFIFO_READ_STATUS ENET_MAC_DBG_TXFRS /*!< TxFIFO read operation status */ 1153 #define ENET_TXFIFO_WRITING ENET_MAC_DBG_TXFW /*!< TxFIFO is doing write operation */ 1154 #define ENET_TXFIFO_NOT_EMPTY ENET_MAC_DBG_TXFNE /*!< TxFIFO is not empty */ 1155 #define ENET_TXFIFO_FULL ENET_MAC_DBG_TXFF /*!< TxFIFO is full */ 1156 1157 #define GET_MAC_DBG_RXAFS(regval) GET_BITS((regval),1,2) /*!< get value of ENET_MAC_DBG_RXAFS bit field */ 1158 1159 #define GET_MAC_DBG_RXFRS(regval) GET_BITS((regval),5,6) /*!< get value of ENET_MAC_DBG_RXFRS bit field */ 1160 1161 #define GET_MAC_DBG_RXFS(regval) GET_BITS((regval),8,9) /*!< get value of ENET_MAC_DBG_RXFS bit field */ 1162 1163 #define GET_MAC_DBG_SOMT(regval) GET_BITS((regval),17,18) /*!< get value of ENET_MAC_DBG_SOMT bit field */ 1164 1165 #define GET_MAC_DBG_TXFRS(regval) GET_BITS((regval),20,21) /*!< get value of ENET_MAC_DBG_TXFRS bit field */ 1166 1167 /* mac_addr0h register value */ 1168 #define MAC_ADDR0H_ADDR0H(regval) (BITS(0,15) & ((uint32_t)(regval) << 0)) /*!< write value to ENET_MAC_ADDR0H_ADDR0H bit field */ 1169 1170 /* mac_addrxh register value, x = 1,2,3 */ 1171 #define MAC_ADDR123H_ADDR123H(regval) (BITS(0,15) & ((uint32_t)(regval) << 0)) /*!< write value to ENET_MAC_ADDRxH_ADDRxH(x=1,2,3) bit field */ 1172 1173 #define ENET_ADDRESS_MASK_BYTE0 BIT(24) /*!< low register bits [7:0] */ 1174 #define ENET_ADDRESS_MASK_BYTE1 BIT(25) /*!< low register bits [15:8] */ 1175 #define ENET_ADDRESS_MASK_BYTE2 BIT(26) /*!< low register bits [23:16] */ 1176 #define ENET_ADDRESS_MASK_BYTE3 BIT(27) /*!< low register bits [31:24] */ 1177 #define ENET_ADDRESS_MASK_BYTE4 BIT(28) /*!< high register bits [7:0] */ 1178 #define ENET_ADDRESS_MASK_BYTE5 BIT(29) /*!< high register bits [15:8] */ 1179 1180 #define ENET_ADDRESS_FILTER_SA BIT(30) /*!< use MAC address[47:0] is to compare with the SA fields of the received frame */ 1181 #define ENET_ADDRESS_FILTER_DA ((uint32_t)0x00000000) /*!< use MAC address[47:0] is to compare with the DA fields of the received frame */ 1182 1183 /* mac_fcth register value */ 1184 #define MAC_FCTH_RFA(regval) ((BITS(0,2) & ((uint32_t)(regval) << 0)) << 8) /*!< write value to ENET_MAC_FCTH_RFA bit field */ 1185 #define ENET_ACTIVE_THRESHOLD_256BYTES MAC_FCTH_RFA(0) /*!< threshold level is 256 bytes */ 1186 #define ENET_ACTIVE_THRESHOLD_512BYTES MAC_FCTH_RFA(1) /*!< threshold level is 512 bytes */ 1187 #define ENET_ACTIVE_THRESHOLD_768BYTES MAC_FCTH_RFA(2) /*!< threshold level is 768 bytes */ 1188 #define ENET_ACTIVE_THRESHOLD_1024BYTES MAC_FCTH_RFA(3) /*!< threshold level is 1024 bytes */ 1189 #define ENET_ACTIVE_THRESHOLD_1280BYTES MAC_FCTH_RFA(4) /*!< threshold level is 1280 bytes */ 1190 #define ENET_ACTIVE_THRESHOLD_1536BYTES MAC_FCTH_RFA(5) /*!< threshold level is 1536 bytes */ 1191 #define ENET_ACTIVE_THRESHOLD_1792BYTES MAC_FCTH_RFA(6) /*!< threshold level is 1792 bytes */ 1192 1193 #define MAC_FCTH_RFD(regval) ((BITS(4,6) & ((uint32_t)(regval) << 4)) << 8) /*!< write value to ENET_MAC_FCTH_RFD bit field */ 1194 #define ENET_DEACTIVE_THRESHOLD_256BYTES MAC_FCTH_RFD(0) /*!< threshold level is 256 bytes */ 1195 #define ENET_DEACTIVE_THRESHOLD_512BYTES MAC_FCTH_RFD(1) /*!< threshold level is 512 bytes */ 1196 #define ENET_DEACTIVE_THRESHOLD_768BYTES MAC_FCTH_RFD(2) /*!< threshold level is 768 bytes */ 1197 #define ENET_DEACTIVE_THRESHOLD_1024BYTES MAC_FCTH_RFD(3) /*!< threshold level is 1024 bytes */ 1198 #define ENET_DEACTIVE_THRESHOLD_1280BYTES MAC_FCTH_RFD(4) /*!< threshold level is 1280 bytes */ 1199 #define ENET_DEACTIVE_THRESHOLD_1536BYTES MAC_FCTH_RFD(5) /*!< threshold level is 1536 bytes */ 1200 #define ENET_DEACTIVE_THRESHOLD_1792BYTES MAC_FCTH_RFD(6) /*!< threshold level is 1792 bytes */ 1201 1202 /* msc_ctl register value */ 1203 #define ENET_MSC_COUNTER_STOP_ROLLOVER ENET_MSC_CTL_CTSR /*!< counter stop rollover */ 1204 #define ENET_MSC_RESET_ON_READ ENET_MSC_CTL_RTOR /*!< reset on read */ 1205 #define ENET_MSC_COUNTERS_FREEZE ENET_MSC_CTL_MCFZ /*!< MSC counter freeze */ 1206 1207 /* ptp_tsctl register value */ 1208 #define PTP_TSCTL_CKNT(regval) (BITS(16,17) & ((uint32_t)(regval) << 16)) /*!< write value to ENET_PTP_TSCTL_CKNT bit field */ 1209 1210 #define ENET_RXTX_TIMESTAMP ENET_PTP_TSCTL_TMSEN /*!< enable timestamp function for transmit and receive frames */ 1211 #define ENET_PTP_TIMESTAMP_INT ENET_PTP_TSCTL_TMSITEN /*!< timestamp interrupt trigger enable */ 1212 #define ENET_ALL_RX_TIMESTAMP ENET_PTP_TSCTL_ARFSEN /*!< all received frames are taken snapshot */ 1213 #define ENET_NONTYPE_FRAME_SNAPSHOT ENET_PTP_TSCTL_ESEN /*!< take snapshot when received non type frame */ 1214 #define ENET_IPV6_FRAME_SNAPSHOT ENET_PTP_TSCTL_IP6SEN /*!< take snapshot for IPv6 frame */ 1215 #define ENET_IPV4_FRAME_SNAPSHOT ENET_PTP_TSCTL_IP4SEN /*!< take snapshot for IPv4 frame */ 1216 #define ENET_PTP_FRAME_USE_MACADDRESS_FILTER ENET_PTP_TSCTL_MAFEN /*!< enable MAC address1-3 to filter the PTP frame */ 1217 1218 /* ptp_ssinc register value */ 1219 #define PTP_SSINC_STMSSI(regval) (BITS(0,7) & ((uint32_t)(regval) << 0)) /*!< write value to ENET_PTP_SSINC_STMSSI bit field */ 1220 1221 /* ptp_tsl register value */ 1222 #define GET_PTP_TSL_STMSS(regval) GET_BITS((uint32_t)(regval),0,30) /*!< get value of ENET_PTP_TSL_STMSS bit field */ 1223 1224 #define ENET_PTP_TIME_POSITIVE ((uint32_t)0x00000000) /*!< time value is positive */ 1225 #define ENET_PTP_TIME_NEGATIVE ENET_PTP_TSL_STS /*!< time value is negative */ 1226 1227 #define GET_PTP_TSL_STS(regval) (((regval) & BIT(31)) >> (31U)) /*!< get value of ENET_PTP_TSL_STS bit field */ 1228 1229 /* ptp_tsul register value */ 1230 #define PTP_TSUL_TMSUSS(regval) (BITS(0,30) & ((uint32_t)(regval) << 0)) /*!< write value to ENET_PTP_TSUL_TMSUSS bit field */ 1231 1232 #define ENET_PTP_ADD_TO_TIME ((uint32_t)0x00000000) /*!< timestamp update value is added to system time */ 1233 #define ENET_PTP_SUBSTRACT_FROM_TIME ENET_PTP_TSUL_TMSUPNS /*!< timestamp update value is subtracted from system time */ 1234 1235 /* ptp_ppsctl register value */ 1236 #define PTP_PPSCTL_PPSOFC(regval) (BITS(0,3) & ((uint32_t)(regval) << 0)) /*!< write value to ENET_PTP_PPSCTL_PPSOFC bit field */ 1237 #define ENET_PPSOFC_1HZ PTP_PPSCTL_PPSOFC(0) /*!< PPS output 1Hz frequency */ 1238 #define ENET_PPSOFC_2HZ PTP_PPSCTL_PPSOFC(1) /*!< PPS output 2Hz frequency */ 1239 #define ENET_PPSOFC_4HZ PTP_PPSCTL_PPSOFC(2) /*!< PPS output 4Hz frequency */ 1240 #define ENET_PPSOFC_8HZ PTP_PPSCTL_PPSOFC(3) /*!< PPS output 8Hz frequency */ 1241 #define ENET_PPSOFC_16HZ PTP_PPSCTL_PPSOFC(4) /*!< PPS output 16Hz frequency */ 1242 #define ENET_PPSOFC_32HZ PTP_PPSCTL_PPSOFC(5) /*!< PPS output 32Hz frequency */ 1243 #define ENET_PPSOFC_64HZ PTP_PPSCTL_PPSOFC(6) /*!< PPS output 64Hz frequency */ 1244 #define ENET_PPSOFC_128HZ PTP_PPSCTL_PPSOFC(7) /*!< PPS output 128Hz frequency */ 1245 #define ENET_PPSOFC_256HZ PTP_PPSCTL_PPSOFC(8) /*!< PPS output 256Hz frequency */ 1246 #define ENET_PPSOFC_512HZ PTP_PPSCTL_PPSOFC(9) /*!< PPS output 512Hz frequency */ 1247 #define ENET_PPSOFC_1024HZ PTP_PPSCTL_PPSOFC(10) /*!< PPS output 1024Hz frequency */ 1248 #define ENET_PPSOFC_2048HZ PTP_PPSCTL_PPSOFC(11) /*!< PPS output 2048Hz frequency */ 1249 #define ENET_PPSOFC_4096HZ PTP_PPSCTL_PPSOFC(12) /*!< PPS output 4096Hz frequency */ 1250 #define ENET_PPSOFC_8192HZ PTP_PPSCTL_PPSOFC(13) /*!< PPS output 8192Hz frequency */ 1251 #define ENET_PPSOFC_16384HZ PTP_PPSCTL_PPSOFC(14) /*!< PPS output 16384Hz frequency */ 1252 #define ENET_PPSOFC_32768HZ PTP_PPSCTL_PPSOFC(15) /*!< PPS output 32768Hz frequency */ 1253 1254 /* dma_bctl register value */ 1255 #define DMA_BCTL_DPSL(regval) (BITS(2,6) & ((uint32_t)(regval) << 2)) /*!< write value to ENET_DMA_BCTL_DPSL bit field */ 1256 #define GET_DMA_BCTL_DPSL(regval) GET_BITS((regval),2,6) /*!< get value of ENET_DMA_BCTL_DPSL bit field */ 1257 1258 #define ENET_ENHANCED_DESCRIPTOR ENET_DMA_BCTL_DFM /*!< enhanced mode descriptor */ 1259 #define ENET_NORMAL_DESCRIPTOR ((uint32_t)0x00000000) /*!< normal mode descriptor */ 1260 1261 #define DMA_BCTL_PGBL(regval) (BITS(8,13) & ((uint32_t)(regval) << 8)) /*!< write value to ENET_DMA_BCTL_PGBL bit field */ 1262 #define ENET_PGBL_1BEAT DMA_BCTL_PGBL(1) /*!< maximum number of beats is 1 */ 1263 #define ENET_PGBL_2BEAT DMA_BCTL_PGBL(2) /*!< maximum number of beats is 2 */ 1264 #define ENET_PGBL_4BEAT DMA_BCTL_PGBL(4) /*!< maximum number of beats is 4 */ 1265 #define ENET_PGBL_8BEAT DMA_BCTL_PGBL(8) /*!< maximum number of beats is 8 */ 1266 #define ENET_PGBL_16BEAT DMA_BCTL_PGBL(16) /*!< maximum number of beats is 16 */ 1267 #define ENET_PGBL_32BEAT DMA_BCTL_PGBL(32) /*!< maximum number of beats is 32 */ 1268 #define ENET_PGBL_4xPGBL_4BEAT (DMA_BCTL_PGBL(1)|ENET_DMA_BCTL_FPBL) /*!< maximum number of beats is 4 */ 1269 #define ENET_PGBL_4xPGBL_8BEAT (DMA_BCTL_PGBL(2)|ENET_DMA_BCTL_FPBL) /*!< maximum number of beats is 8 */ 1270 #define ENET_PGBL_4xPGBL_16BEAT (DMA_BCTL_PGBL(4)|ENET_DMA_BCTL_FPBL) /*!< maximum number of beats is 16 */ 1271 #define ENET_PGBL_4xPGBL_32BEAT (DMA_BCTL_PGBL(8)|ENET_DMA_BCTL_FPBL) /*!< maximum number of beats is 32 */ 1272 #define ENET_PGBL_4xPGBL_64BEAT (DMA_BCTL_PGBL(16)|ENET_DMA_BCTL_FPBL) /*!< maximum number of beats is 64 */ 1273 #define ENET_PGBL_4xPGBL_128BEAT (DMA_BCTL_PGBL(32)|ENET_DMA_BCTL_FPBL) /*!< maximum number of beats is 128 */ 1274 1275 #define DMA_BCTL_RTPR(regval) (BITS(14,15) & ((uint32_t)(regval) << 14)) /*!< write value to ENET_DMA_BCTL_RTPR bit field */ 1276 #define ENET_ARBITRATION_RXTX_1_1 DMA_BCTL_RTPR(0) /*!< receive and transmit priority ratio is 1:1*/ 1277 #define ENET_ARBITRATION_RXTX_2_1 DMA_BCTL_RTPR(1) /*!< receive and transmit priority ratio is 2:1*/ 1278 #define ENET_ARBITRATION_RXTX_3_1 DMA_BCTL_RTPR(2) /*!< receive and transmit priority ratio is 3:1 */ 1279 #define ENET_ARBITRATION_RXTX_4_1 DMA_BCTL_RTPR(3) /*!< receive and transmit priority ratio is 4:1 */ 1280 #define ENET_ARBITRATION_RXPRIORTX ENET_DMA_BCTL_DAB /*!< RxDMA has higher priority than TxDMA */ 1281 1282 #define ENET_FIXED_BURST_ENABLE ENET_DMA_BCTL_FB /*!< AHB can only use SINGLE/INCR4/INCR8/INCR16 during start of normal burst transfers */ 1283 #define ENET_FIXED_BURST_DISABLE ((uint32_t)0x00000000) /*!< AHB can use SINGLE/INCR burst transfer operations */ 1284 1285 #define DMA_BCTL_RXDP(regval) (BITS(17,22) & ((uint32_t)(regval) << 17)) /*!< write value to ENET_DMA_BCTL_RXDP bit field */ 1286 #define ENET_RXDP_1BEAT DMA_BCTL_RXDP(1) /*!< maximum number of beats 1 */ 1287 #define ENET_RXDP_2BEAT DMA_BCTL_RXDP(2) /*!< maximum number of beats 2 */ 1288 #define ENET_RXDP_4BEAT DMA_BCTL_RXDP(4) /*!< maximum number of beats 4 */ 1289 #define ENET_RXDP_8BEAT DMA_BCTL_RXDP(8) /*!< maximum number of beats 8 */ 1290 #define ENET_RXDP_16BEAT DMA_BCTL_RXDP(16) /*!< maximum number of beats 16 */ 1291 #define ENET_RXDP_32BEAT DMA_BCTL_RXDP(32) /*!< maximum number of beats 32 */ 1292 #define ENET_RXDP_4xPGBL_4BEAT (DMA_BCTL_RXDP(1)|ENET_DMA_BCTL_FPBL) /*!< maximum number of beats 4 */ 1293 #define ENET_RXDP_4xPGBL_8BEAT (DMA_BCTL_RXDP(2)|ENET_DMA_BCTL_FPBL) /*!< maximum number of beats 8 */ 1294 #define ENET_RXDP_4xPGBL_16BEAT (DMA_BCTL_RXDP(4)|ENET_DMA_BCTL_FPBL) /*!< maximum number of beats 16 */ 1295 #define ENET_RXDP_4xPGBL_32BEAT (DMA_BCTL_RXDP(8)|ENET_DMA_BCTL_FPBL) /*!< maximum number of beats 32 */ 1296 #define ENET_RXDP_4xPGBL_64BEAT (DMA_BCTL_RXDP(16)|ENET_DMA_BCTL_FPBL) /*!< maximum number of beats 64 */ 1297 #define ENET_RXDP_4xPGBL_128BEAT (DMA_BCTL_RXDP(32)|ENET_DMA_BCTL_FPBL) /*!< maximum number of beats 128 */ 1298 1299 #define ENET_RXTX_DIFFERENT_PGBL ENET_DMA_BCTL_UIP /*!< RxDMA uses the RXDP[5:0], while TxDMA uses the PGBL[5:0] */ 1300 #define ENET_RXTX_SAME_PGBL ((uint32_t)0x00000000) /*!< RxDMA/TxDMA uses PGBL[5:0] */ 1301 1302 #define ENET_ADDRESS_ALIGN_ENABLE ENET_DMA_BCTL_AA /*!< enabled address-aligned */ 1303 #define ENET_ADDRESS_ALIGN_DISABLE ((uint32_t)0x00000000) /*!< disable address-aligned */ 1304 1305 #define ENET_MIXED_BURST_ENABLE ENET_DMA_BCTL_MB /*!< AHB master interface transfer burst length greater than 16 with INCR */ 1306 #define ENET_MIXED_BURST_DISABLE ((uint32_t)0x00000000) /*!< AHB master interface only transfer fixed burst length with 16 and below */ 1307 1308 /* dma_stat register value */ 1309 #define GET_DMA_STAT_RP(regval) GET_BITS((uint32_t)(regval),17,19) /*!< get value of ENET_DMA_STAT_RP bit field */ 1310 #define ENET_RX_STATE_STOPPED ((uint32_t)0x00000000) /*!< reset or stop rx command issued */ 1311 #define ENET_RX_STATE_FETCHING BIT(17) /*!< fetching the Rx descriptor */ 1312 #define ENET_RX_STATE_WAITING (BIT(17)|BIT(18)) /*!< waiting for receive packet */ 1313 #define ENET_RX_STATE_SUSPENDED BIT(19) /*!< Rx descriptor unavailable */ 1314 #define ENET_RX_STATE_CLOSING (BIT(17)|BIT(19)) /*!< closing receive descriptor */ 1315 #define ENET_RX_STATE_QUEUING ENET_DMA_STAT_RP /*!< transferring the receive packet data from recevie buffer to host memory */ 1316 1317 #define GET_DMA_STAT_TP(regval) GET_BITS((uint32_t)(regval),20,22) /*!< get value of ENET_DMA_STAT_TP bit field */ 1318 #define ENET_TX_STATE_STOPPED ((uint32_t)0x00000000) /*!< reset or stop Tx Command issued */ 1319 #define ENET_TX_STATE_FETCHING BIT(20) /*!< fetching the Tx descriptor */ 1320 #define ENET_TX_STATE_WAITING BIT(21) /*!< waiting for status */ 1321 #define ENET_TX_STATE_READING (BIT(20)|BIT(21)) /*!< reading the data from host memory buffer and queuing it to transmit buffer */ 1322 #define ENET_TX_STATE_SUSPENDED (BIT(21)|BIT(22)) /*!< Tx descriptor unavailabe or transmit buffer underflow */ 1323 #define ENET_TX_STATE_CLOSING ENET_DMA_STAT_TP /*!< closing Tx descriptor */ 1324 1325 #define GET_DMA_STAT_EB(regval) GET_BITS((uint32_t)(regval),23,25) /*!< get value of ENET_DMA_STAT_EB bit field */ 1326 #define ENET_ERROR_TXDATA_TRANSFER BIT(23) /*!< error during data transfer by TxDMA or RxDMA */ 1327 #define ENET_ERROR_READ_TRANSFER BIT(24) /*!< error during write transfer or read transfer */ 1328 #define ENET_ERROR_DESC_ACCESS BIT(25) /*!< error during descriptor or buffer access */ 1329 1330 /* dma_ctl register value */ 1331 #define DMA_CTL_RTHC(regval) (BITS(3,4) & ((uint32_t)(regval) << 3)) /*!< write value to ENET_DMA_CTL_RTHC bit field */ 1332 #define ENET_RX_THRESHOLD_64BYTES DMA_CTL_RTHC(0) /*!< threshold level is 64 Bytes */ 1333 #define ENET_RX_THRESHOLD_32BYTES DMA_CTL_RTHC(1) /*!< threshold level is 32 Bytes */ 1334 #define ENET_RX_THRESHOLD_96BYTES DMA_CTL_RTHC(2) /*!< threshold level is 96 Bytes */ 1335 #define ENET_RX_THRESHOLD_128BYTES DMA_CTL_RTHC(3) /*!< threshold level is 128 Bytes */ 1336 1337 #define DMA_CTL_TTHC(regval) (BITS(14,16) & ((uint32_t)(regval) << 14)) /*!< write value to ENET_DMA_CTL_TTHC bit field */ 1338 #define ENET_TX_THRESHOLD_64BYTES DMA_CTL_TTHC(0) /*!< threshold level is 64 Bytes */ 1339 #define ENET_TX_THRESHOLD_128BYTES DMA_CTL_TTHC(1) /*!< threshold level is 128 Bytes */ 1340 #define ENET_TX_THRESHOLD_192BYTES DMA_CTL_TTHC(2) /*!< threshold level is 192 Bytes */ 1341 #define ENET_TX_THRESHOLD_256BYTES DMA_CTL_TTHC(3) /*!< threshold level is 256 Bytes */ 1342 #define ENET_TX_THRESHOLD_40BYTES DMA_CTL_TTHC(4) /*!< threshold level is 40 Bytes */ 1343 #define ENET_TX_THRESHOLD_32BYTES DMA_CTL_TTHC(5) /*!< threshold level is 32 Bytes */ 1344 #define ENET_TX_THRESHOLD_24BYTES DMA_CTL_TTHC(6) /*!< threshold level is 24 Bytes */ 1345 #define ENET_TX_THRESHOLD_16BYTES DMA_CTL_TTHC(7) /*!< threshold level is 16 Bytes */ 1346 1347 #define ENET_TCPIP_CKSUMERROR_ACCEPT ENET_DMA_CTL_DTCERFD /*!< Rx frame with only payload error but no other errors will not be dropped */ 1348 #define ENET_TCPIP_CKSUMERROR_DROP ((uint32_t)0x00000000) /*!< all error frames will be dropped when FERF = 0 */ 1349 1350 #define ENET_RX_MODE_STOREFORWARD ENET_DMA_CTL_RSFD /*!< RxFIFO operates in store-and-forward mode */ 1351 #define ENET_RX_MODE_CUTTHROUGH ((uint32_t)0x00000000) /*!< RxFIFO operates in cut-through mode */ 1352 1353 #define ENET_FLUSH_RXFRAME_ENABLE ((uint32_t)0x00000000) /*!< RxDMA flushes all frames */ 1354 #define ENET_FLUSH_RXFRAME_DISABLE ENET_DMA_CTL_DAFRF /*!< RxDMA does not flush any frames */ 1355 #define ENET_NO_FLUSH_RXFRAME ENET_DMA_CTL_DAFRF /*!< RxDMA does not flush frames function */ 1356 1357 #define ENET_TX_MODE_STOREFORWARD ENET_DMA_CTL_TSFD /*!< TxFIFO operates in store-and-forward mode */ 1358 #define ENET_TX_MODE_CUTTHROUGH ((uint32_t)0x00000000) /*!< TxFIFO operates in cut-through mode */ 1359 1360 #define ENET_FORWARD_ERRFRAMES_ENABLE (ENET_DMA_CTL_FERF << 2) /*!< all frame received with error except runt error are forwarded to memory */ 1361 #define ENET_FORWARD_ERRFRAMES_DISABLE ((uint32_t)0x00000000) /*!< RxFIFO drop error frame */ 1362 #define ENET_FORWARD_ERRFRAMES (ENET_DMA_CTL_FERF << 2) /*!< the function that all frame received with error except runt error are forwarded to memory */ 1363 1364 #define ENET_FORWARD_UNDERSZ_GOODFRAMES_ENABLE (ENET_DMA_CTL_FUF << 2) /*!< forward undersized good frames */ 1365 #define ENET_FORWARD_UNDERSZ_GOODFRAMES_DISABLE ((uint32_t)0x00000000) /*!< RxFIFO drops all frames whose length is less than 64 bytes */ 1366 #define ENET_FORWARD_UNDERSZ_GOODFRAMES (ENET_DMA_CTL_FUF << 2) /*!< the function that forwarding undersized good frames */ 1367 1368 #define ENET_SECONDFRAME_OPT_ENABLE ENET_DMA_CTL_OSF /*!< TxDMA controller operate on second frame mode enable*/ 1369 #define ENET_SECONDFRAME_OPT_DISABLE ((uint32_t)0x00000000) /*!< TxDMA controller operate on second frame mode disable */ 1370 #define ENET_SECONDFRAME_OPT ENET_DMA_CTL_OSF /*!< TxDMA controller operate on second frame function */ 1371 1372 /* dma_mfbocnt register value */ 1373 #define GET_DMA_MFBOCNT_MSFC(regval) GET_BITS((regval),0,15) /*!< get value of ENET_DMA_MFBOCNT_MSFC bit field */ 1374 1375 #define GET_DMA_MFBOCNT_MSFA(regval) GET_BITS((regval),17,27) /*!< get value of ENET_DMA_MFBOCNT_MSFA bit field */ 1376 1377 /* dma_rswdc register value */ 1378 #define DMA_RSWDC_WDCFRS(regval) (BITS(0,7) & ((uint32_t)(regval) << 0)) /*!< write value to ENET_DMA_RSWDC_WDCFRS bit field */ 1379 1380 /* dma tx descriptor tdes0 register value */ 1381 #define TDES0_CONT(regval) (BITS(3,6) & ((uint32_t)(regval) << 3)) /*!< write value to ENET DMA TDES0 CONT bit field */ 1382 #define GET_TDES0_COCNT(regval) GET_BITS((regval),3,6) /*!< get value of ENET DMA TDES0 CONT bit field */ 1383 1384 #define TDES0_CM(regval) (BITS(22,23) & ((uint32_t)(regval) << 22)) /*!< write value to ENET DMA TDES0 CM bit field */ 1385 #define ENET_CHECKSUM_DISABLE TDES0_CM(0) /*!< checksum insertion disabled */ 1386 #define ENET_CHECKSUM_IPV4HEADER TDES0_CM(1) /*!< only IP header checksum calculation and insertion are enabled */ 1387 #define ENET_CHECKSUM_TCPUDPICMP_SEGMENT TDES0_CM(2) /*!< TCP/UDP/ICMP checksum insertion calculated but pseudo-header */ 1388 #define ENET_CHECKSUM_TCPUDPICMP_FULL TDES0_CM(3) /*!< TCP/UDP/ICMP checksum insertion fully calculated */ 1389 1390 /* dma tx descriptor tdes1 register value */ 1391 #define TDES1_TB1S(regval) (BITS(0,12) & ((uint32_t)(regval) << 0)) /*!< write value to ENET DMA TDES1 TB1S bit field */ 1392 1393 #define TDES1_TB2S(regval) (BITS(16,28) & ((uint32_t)(regval) << 16)) /*!< write value to ENET DMA TDES1 TB2S bit field */ 1394 1395 /* dma rx descriptor rdes0 register value */ 1396 #define RDES0_FRML(regval) (BITS(16,29) & ((uint32_t)(regval) << 16)) /*!< write value to ENET DMA RDES0 FRML bit field */ 1397 #define GET_RDES0_FRML(regval) GET_BITS((regval),16,29) /*!< get value of ENET DMA RDES0 FRML bit field */ 1398 1399 /* dma rx descriptor rdes1 register value */ 1400 #define ENET_RECEIVE_COMPLETE_INT_ENABLE ((uint32_t)0x00000000U) /*!< RS bit immediately set after Rx completed */ 1401 #define ENET_RECEIVE_COMPLETE_INT_DISABLE ENET_RDES1_DINTC /*!< RS bit not immediately set after Rx completed */ 1402 1403 #define GET_RDES1_RB1S(regval) GET_BITS((regval),0,12) /*!< get value of ENET DMA RDES1 RB1S bit field */ 1404 1405 #define GET_RDES1_RB2S(regval) GET_BITS((regval),16,28) /*!< get value of ENET DMA RDES1 RB2S bit field */ 1406 1407 /* dma rx descriptor rdes4 register value */ 1408 #define RDES4_IPPLDT(regval) (BITS(0,2) & ((uint32_t)(regval) << 0)) /*!< write value to ENET DMA RDES4 IPPLDT bit field */ 1409 #define GET_RDES4_IPPLDT(regval) GET_BITS((regval),0,2) /*!< get value of ENET DMA RDES4 IPPLDT bit field */ 1410 1411 #define RDES4_PTPMT(regval) (BITS(8,11) & ((uint32_t)(regval) << 8)) /*!< write value to ENET DMA RDES4 PTPMT bit field */ 1412 #define GET_RDES4_PTPMT(regval) GET_BITS((regval),8,11) /*!< get value of ENET DMA RDES4 PTPMT bit field */ 1413 1414 /* ENET register mask value */ 1415 #define MAC_CFG_MASK ((uint32_t)0xFD30810FU) /*!< ENET_MAC_CFG register mask */ 1416 #define MAC_FCTL_MASK ((uint32_t)0x0000FF41U) /*!< ENET_MAC_FCTL register mask */ 1417 #define DMA_CTL_MASK ((uint32_t)0xF8DE3F23U) /*!< ENET_DMA_CTL register mask */ 1418 #define DMA_BCTL_MASK ((uint32_t)0xF800007DU) /*!< ENET_DMA_BCTL register mask */ 1419 #define ENET_MSC_PRESET_MASK (~(ENET_MSC_CTL_PMC | ENET_MSC_CTL_AFHPM)) /*!< ENET_MSC_CTL preset mask */ 1420 1421 #ifdef SELECT_DESCRIPTORS_ENHANCED_MODE 1422 #define ETH_DMATXDESC_SIZE 0x20U /*!< TxDMA enhanced descriptor size */ 1423 #define ETH_DMARXDESC_SIZE 0x20U /*!< RxDMA enhanced descriptor size */ 1424 #else 1425 #define ETH_DMATXDESC_SIZE 0x10U /*!< TxDMA descriptor size */ 1426 #define ETH_DMARXDESC_SIZE 0x10U /*!< RxDMA descriptor size */ 1427 #endif /* SELECT_DESCRIPTORS_ENHANCED_MODE */ 1428 1429 1430 typedef enum{ 1431 ENET_CKNT_ORDINARY = PTP_TSCTL_CKNT(0), /*!< type of ordinary clock node type for timestamp */ 1432 ENET_CKNT_BOUNDARY = PTP_TSCTL_CKNT(1), /*!< type of boundary clock node type for timestamp */ 1433 ENET_CKNT_END_TO_END = PTP_TSCTL_CKNT(2), /*!< type of end-to-end transparent clock node type for timestamp */ 1434 ENET_CKNT_PEER_TO_PEER = PTP_TSCTL_CKNT(3), /*!< type of peer-to-peer transparent clock node type for timestamp */ 1435 ENET_PTP_SYSTIME_INIT = ENET_PTP_TSCTL_TMSSTI, /*!< timestamp initialize */ 1436 ENET_PTP_SYSTIME_UPDATE = ENET_PTP_TSCTL_TMSSTU, /*!< timestamp update */ 1437 ENET_PTP_ADDEND_UPDATE = ENET_PTP_TSCTL_TMSARU, /*!< addend register update */ 1438 ENET_PTP_FINEMODE = (int32_t)(ENET_PTP_TSCTL_TMSFCU| BIT(31)), /*!< the system timestamp uses the fine method for updating */ 1439 ENET_PTP_COARSEMODE = ENET_PTP_TSCTL_TMSFCU, /*!< the system timestamp uses the coarse method for updating */ 1440 ENET_SUBSECOND_DIGITAL_ROLLOVER = (int32_t)(ENET_PTP_TSCTL_SCROM | BIT(31)), /*!< digital rollover mode */ 1441 ENET_SUBSECOND_BINARY_ROLLOVER = ENET_PTP_TSCTL_SCROM, /*!< binary rollover mode */ 1442 ENET_SNOOPING_PTP_VERSION_2 = (int32_t)(ENET_PTP_TSCTL_PFSV| BIT(31)), /*!< version 2 */ 1443 ENET_SNOOPING_PTP_VERSION_1 = ENET_PTP_TSCTL_PFSV, /*!< version 1 */ 1444 ENET_EVENT_TYPE_MESSAGES_SNAPSHOT = (int32_t)(ENET_PTP_TSCTL_ETMSEN| BIT(31)), /*!< only event type messages are taken snapshot */ 1445 ENET_ALL_TYPE_MESSAGES_SNAPSHOT = ENET_PTP_TSCTL_ETMSEN, /*!< all type messages are taken snapshot except announce, management and signaling message */ 1446 ENET_MASTER_NODE_MESSAGE_SNAPSHOT = (int32_t)(ENET_PTP_TSCTL_MNMSEN| BIT(31)), /*!< snapshot is only take for master node message */ 1447 ENET_SLAVE_NODE_MESSAGE_SNAPSHOT = ENET_PTP_TSCTL_MNMSEN, /*!< snapshot is only taken for slave node message */ 1448 }enet_ptp_function_enum; 1449 1450 1451 /* ENET remote wake-up frame register length */ 1452 #define ETH_WAKEUP_REGISTER_LENGTH 8U /*!< remote wake-up frame register length */ 1453 1454 /* ENET frame size */ 1455 #define ENET_MAX_FRAME_SIZE 1524U /*!< header + frame_extra + payload + CRC */ 1456 1457 /* ENET delay timeout */ 1458 #define ENET_DELAY_TO ((uint32_t)0x0004FFFFU) /*!< ENET delay timeout */ 1459 #define ENET_RESET_TO ((uint32_t)0x000004FFU) /*!< ENET reset timeout */ 1460 1461 1462 1463 /* function declarations */ 1464 /* main function */ 1465 /* deinitialize the ENET, and reset structure parameters for ENET initialization */ 1466 void enet_deinit(void); 1467 /* configure the parameters which are usually less cared for initialization */ 1468 void enet_initpara_config(enet_option_enum option, uint32_t para); 1469 /* initialize ENET peripheral with generally concerned parameters and the less cared parameters */ 1470 ErrStatus enet_init(enet_mediamode_enum mediamode, enet_chksumconf_enum checksum, enet_frmrecept_enum recept); 1471 /* reset all core internal registers located in CLK_TX and CLK_RX */ 1472 ErrStatus enet_software_reset(void); 1473 /* check receive frame valid and return frame size */ 1474 uint32_t enet_rxframe_size_get(void); 1475 /* initialize the dma tx/rx descriptors's parameters in chain mode */ 1476 void enet_descriptors_chain_init(enet_dmadirection_enum direction); 1477 /* initialize the dma tx/rx descriptors's parameters in ring mode */ 1478 void enet_descriptors_ring_init(enet_dmadirection_enum direction); 1479 /* handle current received frame data to application buffer */ 1480 ErrStatus enet_frame_receive(uint8_t *buffer, uint32_t bufsize); 1481 /* handle current received frame but without data copy to application buffer */ 1482 #define ENET_NOCOPY_FRAME_RECEIVE() enet_frame_receive(NULL, 0U) 1483 /* handle application buffer data to transmit it */ 1484 ErrStatus enet_frame_transmit(uint8_t *buffer, uint32_t length); 1485 /* handle current transmit frame but without data copy from application buffer */ 1486 #define ENET_NOCOPY_FRAME_TRANSMIT(len) enet_frame_transmit(NULL, (len)) 1487 /* configure the transmit IP frame checksum offload calculation and insertion */ 1488 ErrStatus enet_transmit_checksum_config(enet_descriptors_struct *desc, uint32_t checksum); 1489 /* ENET Tx and Rx function enable (include MAC and DMA module) */ 1490 void enet_enable(void); 1491 /* ENET Tx and Rx function disable (include MAC and DMA module) */ 1492 void enet_disable(void); 1493 /* configure MAC address */ 1494 void enet_mac_address_set(enet_macaddress_enum mac_addr, uint8_t paddr[]); 1495 /* get MAC address */ 1496 ErrStatus enet_mac_address_get(enet_macaddress_enum mac_addr, uint8_t paddr[], uint8_t bufsize); 1497 1498 /* get the ENET MAC/MSC/PTP/DMA status flag */ 1499 FlagStatus enet_flag_get(enet_flag_enum enet_flag); 1500 /* clear the ENET DMA status flag */ 1501 void enet_flag_clear(enet_flag_clear_enum enet_flag); 1502 /* enable ENET MAC/MSC/DMA interrupt */ 1503 void enet_interrupt_enable(enet_int_enum enet_int); 1504 /* disable ENET MAC/MSC/DMA interrupt */ 1505 void enet_interrupt_disable(enet_int_enum enet_int); 1506 /* get ENET MAC/MSC/DMA interrupt flag */ 1507 FlagStatus enet_interrupt_flag_get(enet_int_flag_enum int_flag); 1508 /* clear ENET DMA interrupt flag */ 1509 void enet_interrupt_flag_clear(enet_int_flag_clear_enum int_flag_clear); 1510 1511 /* MAC function */ 1512 /* ENET Tx function enable (include MAC and DMA module) */ 1513 void enet_tx_enable(void); 1514 /* ENET Tx function disable (include MAC and DMA module) */ 1515 void enet_tx_disable(void); 1516 /* ENET Rx function enable (include MAC and DMA module) */ 1517 void enet_rx_enable(void); 1518 /* ENET Rx function disable (include MAC and DMA module) */ 1519 void enet_rx_disable(void); 1520 /* put registers value into the application buffer */ 1521 void enet_registers_get(enet_registers_type_enum type, uint32_t *preg, uint32_t num); 1522 /* get the enet debug status from the debug register */ 1523 uint32_t enet_debug_status_get(uint32_t mac_debug); 1524 /* enable the MAC address filter */ 1525 void enet_address_filter_enable(enet_macaddress_enum mac_addr); 1526 /* disable the MAC address filter */ 1527 void enet_address_filter_disable(enet_macaddress_enum mac_addr); 1528 /* configure the MAC address filter */ 1529 void enet_address_filter_config(enet_macaddress_enum mac_addr, uint32_t addr_mask, uint32_t filter_type); 1530 /* PHY interface configuration (configure SMI clock and reset PHY chip) */ 1531 ErrStatus enet_phy_config(void); 1532 /* write to/read from a PHY register */ 1533 ErrStatus enet_phy_write_read(enet_phydirection_enum direction, uint16_t phy_address, uint16_t phy_reg, uint16_t *pvalue); 1534 /* enable the loopback function of phy chip */ 1535 ErrStatus enet_phyloopback_enable(void); 1536 /* disable the loopback function of phy chip */ 1537 ErrStatus enet_phyloopback_disable(void); 1538 /* enable ENET forward feature */ 1539 void enet_forward_feature_enable(uint32_t feature); 1540 /* disable ENET forward feature */ 1541 void enet_forward_feature_disable(uint32_t feature); 1542 /* enable ENET fliter feature */ 1543 void enet_fliter_feature_enable(uint32_t feature); 1544 /* disable ENET fliter feature */ 1545 void enet_fliter_feature_disable(uint32_t feature); 1546 1547 /* flow control function */ 1548 /* generate the pause frame, ENET will send pause frame after enable transmit flow control */ 1549 ErrStatus enet_pauseframe_generate(void); 1550 /* configure the pause frame detect type */ 1551 void enet_pauseframe_detect_config(uint32_t detect); 1552 /* configure the pause frame parameters */ 1553 void enet_pauseframe_config(uint32_t pausetime, uint32_t pause_threshold); 1554 /* configure the threshold of the flow control(deactive and active threshold) */ 1555 void enet_flowcontrol_threshold_config(uint32_t deactive, uint32_t active); 1556 /* enable ENET flow control feature */ 1557 void enet_flowcontrol_feature_enable(uint32_t feature); 1558 /* disable ENET flow control feature */ 1559 void enet_flowcontrol_feature_disable(uint32_t feature); 1560 1561 /* DMA function */ 1562 /* get the dma transmit/receive process state */ 1563 uint32_t enet_dmaprocess_state_get(enet_dmadirection_enum direction); 1564 /* poll the dma transmission/reception enable */ 1565 void enet_dmaprocess_resume(enet_dmadirection_enum direction); 1566 /* check and recover the Rx process */ 1567 void enet_rxprocess_check_recovery(void); 1568 /* flush the ENET transmit fifo, and wait until the flush operation completes */ 1569 ErrStatus enet_txfifo_flush(void); 1570 /* get the transmit/receive address of current descriptor, or current buffer, or descriptor table */ 1571 uint32_t enet_current_desc_address_get(enet_desc_reg_enum addr_get); 1572 /* get the Tx or Rx descriptor information */ 1573 uint32_t enet_desc_information_get(enet_descriptors_struct *desc, enet_descstate_enum info_get); 1574 /* get the number of missed frames during receiving */ 1575 void enet_missed_frame_counter_get(uint32_t *rxfifo_drop, uint32_t *rxdma_drop); 1576 1577 /* descriptor function */ 1578 /* get the bit flag of ENET dma descriptor */ 1579 FlagStatus enet_desc_flag_get(enet_descriptors_struct *desc, uint32_t desc_flag); 1580 /* set the bit flag of ENET dma tx descriptor */ 1581 void enet_desc_flag_set(enet_descriptors_struct *desc, uint32_t desc_flag); 1582 /* clear the bit flag of ENET dma tx descriptor */ 1583 void enet_desc_flag_clear(enet_descriptors_struct *desc, uint32_t desc_flag); 1584 /* when receiving the completed, set RS bit in ENET_DMA_STAT register will immediately set */ 1585 void enet_rx_desc_immediate_receive_complete_interrupt(enet_descriptors_struct *desc); 1586 /* when receiving the completed, set RS bit in ENET_DMA_STAT register will is set after a configurable delay time */ 1587 void enet_rx_desc_delay_receive_complete_interrupt(enet_descriptors_struct *desc, uint32_t delay_time); 1588 /* drop current receive frame */ 1589 void enet_rxframe_drop(void); 1590 /* enable DMA feature */ 1591 void enet_dma_feature_enable(uint32_t feature); 1592 /* disable DMA feature */ 1593 void enet_dma_feature_disable(uint32_t feature); 1594 1595 1596 /* special enhanced mode function */ 1597 #ifdef SELECT_DESCRIPTORS_ENHANCED_MODE 1598 /* get the bit of extended status flag in ENET DMA descriptor */ 1599 uint32_t enet_rx_desc_enhanced_status_get(enet_descriptors_struct *desc, uint32_t desc_status); 1600 /* configure descriptor to work in enhanced mode */ 1601 void enet_desc_select_enhanced_mode(void); 1602 /* initialize the dma Tx/Rx descriptors's parameters in enhanced chain mode with ptp function */ 1603 void enet_ptp_enhanced_descriptors_chain_init(enet_dmadirection_enum direction); 1604 /* initialize the dma Tx/Rx descriptors's parameters in enhanced ring mode with ptp function */ 1605 void enet_ptp_enhanced_descriptors_ring_init(enet_dmadirection_enum direction); 1606 /* receive a packet data with timestamp values to application buffer, when the DMA is in enhanced mode */ 1607 ErrStatus enet_ptpframe_receive_enhanced_mode(uint8_t *buffer, uint32_t bufsize, uint32_t timestamp[]); 1608 /* handle current received frame but without data copy to application buffer in PTP enhanced mode */ 1609 #define ENET_NOCOPY_PTPFRAME_RECEIVE_ENHANCED_MODE(ptr) enet_ptpframe_receive_enhanced_mode(NULL, 0U, (ptr)) 1610 /* send data with timestamp values in application buffer as a transmit packet, when the DMA is in enhanced mode */ 1611 ErrStatus enet_ptpframe_transmit_enhanced_mode(uint8_t *buffer, uint32_t length, uint32_t timestamp[]); 1612 /* handle current transmit frame but without data copy from application buffer in PTP enhanced mode */ 1613 #define ENET_NOCOPY_PTPFRAME_TRANSMIT_ENHANCED_MODE(len, ptr) enet_ptpframe_transmit_enhanced_mode(NULL, (len), (ptr)) 1614 1615 #else 1616 1617 /* configure descriptor to work in normal mode */ 1618 void enet_desc_select_normal_mode(void); 1619 /* initialize the dma Tx/Rx descriptors's parameters in normal chain mode with ptp function */ 1620 void enet_ptp_normal_descriptors_chain_init(enet_dmadirection_enum direction, enet_descriptors_struct *desc_ptptab); 1621 /* initialize the dma Tx/Rx descriptors's parameters in normal ring mode with ptp function */ 1622 void enet_ptp_normal_descriptors_ring_init(enet_dmadirection_enum direction, enet_descriptors_struct *desc_ptptab); 1623 /* receive a packet data with timestamp values to application buffer, when the DMA is in normal mode */ 1624 ErrStatus enet_ptpframe_receive_normal_mode(uint8_t *buffer, uint32_t bufsize, uint32_t timestamp[]); 1625 /* handle current received frame but without data copy to application buffer in PTP normal mode */ 1626 #define ENET_NOCOPY_PTPFRAME_RECEIVE_NORMAL_MODE(ptr) enet_ptpframe_receive_normal_mode(NULL, 0U, (ptr)) 1627 /* send data with timestamp values in application buffer as a transmit packet, when the DMA is in normal mode */ 1628 ErrStatus enet_ptpframe_transmit_normal_mode(uint8_t *buffer, uint32_t length, uint32_t timestamp[]); 1629 /* handle current transmit frame but without data copy from application buffer in PTP normal mode */ 1630 #define ENET_NOCOPY_PTPFRAME_TRANSMIT_NORMAL_MODE(len, ptr) enet_ptpframe_transmit_normal_mode(NULL, (len), (ptr)) 1631 1632 #endif /* SELECT_DESCRIPTORS_ENHANCED_MODE */ 1633 1634 /* WUM function */ 1635 /* wakeup frame filter register pointer reset */ 1636 void enet_wum_filter_register_pointer_reset(void); 1637 /* set the remote wakeup frame registers */ 1638 void enet_wum_filter_config(uint32_t pdata[]); 1639 /* enable wakeup management features */ 1640 void enet_wum_feature_enable(uint32_t feature); 1641 /* disable wakeup management features */ 1642 void enet_wum_feature_disable(uint32_t feature); 1643 1644 /* MSC function */ 1645 /* reset the MAC statistics counters */ 1646 void enet_msc_counters_reset(void); 1647 /* enable the MAC statistics counter features */ 1648 void enet_msc_feature_enable(uint32_t feature); 1649 /* disable the MAC statistics counter features */ 1650 void enet_msc_feature_disable(uint32_t feature); 1651 /* configure MAC statistics counters preset mode */ 1652 void enet_msc_counters_preset_config(enet_msc_preset_enum mode); 1653 /* get MAC statistics counter */ 1654 uint32_t enet_msc_counters_get(enet_msc_counter_enum counter); 1655 1656 /* PTP function */ 1657 /* change subsecond to nanosecond */ 1658 uint32_t enet_ptp_subsecond_2_nanosecond(uint32_t subsecond); 1659 /* change nanosecond to subsecond */ 1660 uint32_t enet_ptp_nanosecond_2_subsecond(uint32_t nanosecond); 1661 /* enable the PTP features */ 1662 void enet_ptp_feature_enable(uint32_t feature); 1663 /* disable the PTP features */ 1664 void enet_ptp_feature_disable(uint32_t feature); 1665 /* configure the PTP timestamp function */ 1666 ErrStatus enet_ptp_timestamp_function_config(enet_ptp_function_enum func); 1667 /* configure the PTP system time subsecond increment value */ 1668 void enet_ptp_subsecond_increment_config(uint32_t subsecond); 1669 /* adjusting the PTP clock frequency only in fine update mode */ 1670 void enet_ptp_timestamp_addend_config(uint32_t add); 1671 /* initializing or adding/subtracting to second of the PTP system time */ 1672 void enet_ptp_timestamp_update_config(uint32_t sign, uint32_t second, uint32_t subsecond); 1673 /* configure the PTP expected target time */ 1674 void enet_ptp_expected_time_config(uint32_t second, uint32_t nanosecond); 1675 /* get the PTP current system time */ 1676 void enet_ptp_system_time_get(enet_ptp_systime_struct *systime_struct); 1677 /* configure the PPS output frequency */ 1678 void enet_ptp_pps_output_frequency_config(uint32_t freq); 1679 /* configure and start PTP timestamp counter */ 1680 void enet_ptp_start(int32_t updatemethod, uint32_t init_sec, uint32_t init_subsec, uint32_t carry_cfg, uint32_t accuracy_cfg); 1681 /* adjust frequency in fine method by configure addend register */ 1682 void enet_ptp_finecorrection_adjfreq(int32_t carry_cfg); 1683 /* update system time in coarse method */ 1684 void enet_ptp_coarsecorrection_systime_update(enet_ptp_systime_struct *systime_struct); 1685 /* set system time in fine method */ 1686 void enet_ptp_finecorrection_settime(enet_ptp_systime_struct * systime_struct); 1687 /* get the ptp flag status */ 1688 FlagStatus enet_ptp_flag_get(uint32_t flag); 1689 1690 /* internal function */ 1691 /* reset the ENET initpara struct, call it before using enet_initpara_config() */ 1692 void enet_initpara_reset(void); 1693 #ifdef USE_DELAY 1694 /* user can provide more timing precise _ENET_DELAY_ function */ 1695 #define _ENET_DELAY_ delay_ms 1696 #else 1697 /* default _ENET_DELAY_ function with less precise timing */ 1698 #define _ENET_DELAY_ enet_delay 1699 #endif 1700 1701 #endif /* GD32E50X_ENET_H */ 1702