if_enetreg.h revision 1.4
1/* $NetBSD: if_enetreg.h,v 1.4 2019/11/12 05:09:29 hkenken Exp $ */ 2 3/*- 4 * Copyright (c) 2014 Ryo Shimizu <ryo@nerv.org> 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 20 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 24 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 25 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 * POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29/* 30 * i.MX6,7 10/100/1000-Mbps ethernet MAC (ENET) 31 */ 32 33#ifndef _ARM_IMX_IF_ENETREG_H_ 34#define _ARM_IMX_IF_ENETREG_H_ 35 36#include <sys/cdefs.h> 37 38#define ENET_EIR 0x00000004 39# define ENET_EIR_BABR __BIT(30) 40# define ENET_EIR_BABT __BIT(29) 41# define ENET_EIR_GRA __BIT(28) 42# define ENET_EIR_TXF __BIT(27) 43# define ENET_EIR_TXB __BIT(26) 44# define ENET_EIR_RXF __BIT(25) 45# define ENET_EIR_RXB __BIT(24) 46# define ENET_EIR_MII __BIT(23) 47# define ENET_EIR_EBERR __BIT(22) 48# define ENET_EIR_LC __BIT(21) 49# define ENET_EIR_RL __BIT(20) 50# define ENET_EIR_UN __BIT(19) 51# define ENET_EIR_PLR __BIT(18) 52# define ENET_EIR_WAKEUP __BIT(17) 53# define ENET_EIR_TS_AVAIL __BIT(16) 54# define ENET_EIR_TS_TIMER __BIT(15) 55# define ENET_EIR_RXFLUSH_2 __BIT(14) /* imx7 */ 56# define ENET_EIR_RXFLUSH_1 __BIT(13) /* imx7 */ 57# define ENET_EIR_RXFLUSH_0 __BIT(12) /* imx7 */ 58# define ENET_EIR_TXF2 __BIT(7) /* imx7 */ 59# define ENET_EIR_TXB2 __BIT(6) /* imx7 */ 60# define ENET_EIR_RXF2 __BIT(5) /* imx7 */ 61# define ENET_EIR_RXB2 __BIT(4) /* imx7 */ 62# define ENET_EIR_TXF1 __BIT(3) /* imx7 */ 63# define ENET_EIR_TXB1 __BIT(2) /* imx7 */ 64# define ENET_EIR_RXF1 __BIT(1) /* imx7 */ 65# define ENET_EIR_RXB1 __BIT(1) /* imx7 */ 66#define ENET_EIMR 0x00000008 67#define ENET_RDAR 0x00000010 68# define ENET_RDAR_ACTIVE __BIT(24) 69#define ENET_TDAR 0x00000014 70# define ENET_TDAR_ACTIVE __BIT(24) 71 72#define ENET_ECR 0x00000024 73# define ENET_ECR_SVLANDBL __BIT(11) /* imx7 */ 74# define ENET_ECR_VLANUE2ND __BIT(10) /* imx7 */ 75# define ENET_ECR_SVLANEN __BIT(9) /* imx7 */ 76# define ENET_ECR_DBSWP __BIT(8) 77# define ENET_ECR_STOPEN __BIT(7) 78# define ENET_ECR_DBGEN __BIT(6) 79# define ENET_ECR_SPEED __BIT(5) 80# define ENET_ECR_EN1588 __BIT(4) 81# define ENET_ECR_SLEEP __BIT(3) 82# define ENET_ECR_MAGICEN __BIT(2) 83# define ENET_ECR_ETHEREN __BIT(1) 84# define ENET_ECR_RESET __BIT(0) 85#define ENET_MMFR 0x00000040 86# define ENET_MMFR_ST 0x40000000 87# define ENET_MMFR_OP_FORCEWRITE 0x00000000 88# define ENET_MMFR_OP_WRITE 0x10000000 89# define ENET_MMFR_OP_READ 0x20000000 90# define ENET_MMFR_OP_FORCEREAD 0x30000000 91# define ENET_MMFR_TA 0x00020000 92# define ENET_MMFR_PHY_ADDR(phy) __SHIFTIN(phy, __BITS(27, 23)) 93# define ENET_MMFR_PHY_REG(reg) __SHIFTIN(reg, __BITS(22, 18)) 94# define ENET_MMFR_DATAMASK 0x0000ffff 95#define ENET_MSCR 0x00000044 96# define ENET_MSCR_HOLDTIME __BIT(10, 8) 97# define ENET_MSCR_DIS_PRE __BIT(7) 98# define ENET_MSCR_MII_SPEED __BITS(6, 1) 99 100#define ENET_MIBC 0x00000064 101# define ENET_MIBC_MIB_DIS __BIT(31) 102# define ENET_MIBC_MIB_IDLE __BIT(30) 103# define ENET_MIBC_MIB_CLEAR __BIT(29) 104 105#define ENET_RCR 0x00000084 106# define ENET_RCR_GRS __BIT(31) 107# define ENET_RCR_NLC __BIT(30) 108# define ENET_RCR_MAX_FL(n) __SHIFTIN(n, __BITS(29, 16)) 109# define ENET_RCR_CFEN __BIT(15) 110# define ENET_RCR_CRCFWD __BIT(14) 111# define ENET_RCR_PAUFWD __BIT(13) 112# define ENET_RCR_PADEN __BIT(12) 113# define ENET_RCR_RMII_10T __BIT(9) 114# define ENET_RCR_RMII_MODE __BIT(8) 115# define ENET_RCR_RGMII_EN __BIT(6) 116# define ENET_RCR_FCE __BIT(5) 117# define ENET_RCR_BC_REJ __BIT(4) 118# define ENET_RCR_PROM __BIT(3) 119# define ENET_RCR_MII_MODE __BIT(2) 120# define ENET_RCR_DRT __BIT(1) 121# define ENET_RCR_LOOP __BIT(0) 122 123#define ENET_TCR 0x000000c4 124# define ENET_TCR_FDEN __BIT(2) 125 126#define ENET_PALR 0x000000e4 127#define ENET_PAUR 0x000000e8 128#define ENET_OPD 0x000000ec 129 130#define ENET_TXIC0 0x000000f0 /* imx7 */ 131#define ENET_TXIC1 0x000000f4 /* imx7 */ 132#define ENET_TXIC2 0x000000f8 /* imx7 */ 133#define ENET_RXIC0 0x00000100 /* imx7 */ 134#define ENET_RXIC1 0x00000104 /* imx7 */ 135#define ENET_RXIC2 0x00000108 /* imx7 */ 136 137#define ENET_IAUR 0x00000118 138#define ENET_IALR 0x0000011c 139#define ENET_GAUR 0x00000120 140#define ENET_GALR 0x00000124 141#define ENET_TFWR 0x00000144 142# define ENET_TFWR_STRFWD __BIT(8) 143# define ENET_TFWR_FIFO(n) __SHIFTIN(((n) / 64), __BITS(5, 0)) 144 145#define ENET_RDSR1 0x00000160 /* imx7 */ 146#define ENET_TDSR1 0x00000164 /* imx7 */ 147#define ENET_MRBR1 0x00000168 /* imx7 */ 148#define ENET_RDSR2 0x0000016c /* imx7 */ 149#define ENET_TDSR2 0x00000170 /* imx7 */ 150#define ENET_MRBR2 0x00000174 /* imx7 */ 151 152#define ENET_RDSR 0x00000180 153#define ENET_TDSR 0x00000184 154#define ENET_MRBR 0x00000188 155#define ENET_RSFL 0x00000190 156#define ENET_RSEM 0x00000194 157#define ENET_RAEM 0x00000198 158#define ENET_RAFL 0x0000019c 159#define ENET_TSEM 0x000001a0 160#define ENET_TAEM 0x000001a4 161#define ENET_TAFL 0x000001a8 162#define ENET_TIPG 0x000001ac 163#define ENET_FTRL 0x000001b0 164#define ENET_TACC 0x000001c0 165# define ENET_TACC_PROCHK __BIT(4) 166# define ENET_TACC_IPCHK __BIT(3) 167# define ENET_TACC_SHIFT16 __BIT(0) 168#define ENET_RACC 0x000001c4 169# define ENET_RACC_SHIFT16 __BIT(7) 170# define ENET_RACC_LINEDIS __BIT(6) 171# define ENET_RACC_PRODIS __BIT(2) 172# define ENET_RACC_IPDIS __BIT(1) 173# define ENET_RACC_PADREM __BIT(0) 174 175#define ENET_RCMR1 0x000001c8 /* imx7 */ 176#define ENET_RCMR2 0x000001cc /* imx7 */ 177#define ENET_DMA1CFG 0x000001d8 /* imx7 */ 178#define ENET_DMA2CFG 0x000001dc /* imx7 */ 179#define ENET_RDAR1 0x000001e0 /* imx7 */ 180#define ENET_TDAR1 0x000001e4 /* imx7 */ 181#define ENET_RDAR2 0x000001e8 /* imx7 */ 182#define ENET_TDAR2 0x000001ec /* imx7 */ 183#define ENET_QOS 0x000001f0 /* imx7 */ 184 185/* Statistics counters */ 186#define ENET_RMON_T_DROP 0x00000200 187#define ENET_RMON_T_PACKETS 0x00000204 188#define ENET_RMON_T_BC_PKT 0x00000208 189#define ENET_RMON_T_MC_PKT 0x0000020c 190#define ENET_RMON_T_CRC_ALIGN 0x00000210 191#define ENET_RMON_T_UNDERSIZE 0x00000214 192#define ENET_RMON_T_OVERSIZE 0x00000218 193#define ENET_RMON_T_FRAG 0x0000021c 194#define ENET_RMON_T_JAB 0x00000220 195#define ENET_RMON_T_COL 0x00000224 196#define ENET_RMON_T_P64 0x00000228 197#define ENET_RMON_T_P65TO127N 0x0000022c 198#define ENET_RMON_T_P128TO255N 0x00000230 199#define ENET_RMON_T_P256TO511 0x00000234 200#define ENET_RMON_T_P512TO1023 0x00000238 201#define ENET_RMON_T_P1024TO2047 0x0000023c 202#define ENET_RMON_T_P_GTE2048 0x00000240 203#define ENET_RMON_T_OCTETS 0x00000244 204#define ENET_IEEE_T_DROP 0x00000248 205#define ENET_IEEE_T_FRAME_OK 0x0000024c 206#define ENET_IEEE_T_1COL 0x00000250 207#define ENET_IEEE_T_MCOL 0x00000254 208#define ENET_IEEE_T_DEF 0x00000258 209#define ENET_IEEE_T_LCOL 0x0000025c 210#define ENET_IEEE_T_EXCOL 0x00000260 211#define ENET_IEEE_T_MACERR 0x00000264 212#define ENET_IEEE_T_CSERR 0x00000268 213#define ENET_IEEE_T_SQE 0x0000026c 214#define ENET_IEEE_T_FDXFC 0x00000270 215#define ENET_IEEE_T_OCTETS_OK 0x00000274 216#define ENET_RMON_R_PACKETS 0x00000284 217#define ENET_RMON_R_BC_PKT 0x00000288 218#define ENET_RMON_R_MC_PKT 0x0000028c 219#define ENET_RMON_R_CRC_ALIGN 0x00000290 220#define ENET_RMON_R_UNDERSIZE 0x00000294 221#define ENET_RMON_R_OVERSIZE 0x00000298 222#define ENET_RMON_R_FRAG 0x0000029c 223#define ENET_RMON_R_JAB 0x000002a0 224#define ENET_RMON_R_RESVD_0 0x000002a4 225#define ENET_RMON_R_P64 0x000002a8 226#define ENET_RMON_R_P65TO127 0x000002ac 227#define ENET_RMON_R_P128TO255 0x000002b0 228#define ENET_RMON_R_P256TO511 0x000002b4 229#define ENET_RMON_R_P512TO1023 0x000002b8 230#define ENET_RMON_R_P1024TO2047 0x000002bc 231#define ENET_RMON_R_P_GTE2048 0x000002c0 232#define ENET_RMON_R_OCTETS 0x000002c4 233#define ENET_IEEE_R_DROP 0x000002c8 234#define ENET_IEEE_R_FRAME_OK 0x000002cc 235#define ENET_IEEE_R_CRC 0x000002d0 236#define ENET_IEEE_R_ALIGN 0x000002d4 237#define ENET_IEEE_R_MACERR 0x000002d8 238#define ENET_IEEE_R_FDXFC 0x000002dc 239#define ENET_IEEE_R_OCTETS_OK 0x000002e0 240 241/* IEEE1588 control */ 242#define ENET_ATCR 0x00000400 243#define ENET_ATVR 0x00000404 244#define ENET_ATOFF 0x00000408 245#define ENET_ATPER 0x0000040c 246#define ENET_ATCOR 0x00000410 247#define ENET_ATINC 0x00000414 248#define ENET_ATSTMP 0x00000418 249 250/* Capture/compare block */ 251#define ENET_TGSR 0x00000604 252#define ENET_TCSR0 0x00000608 253#define ENET_TCCR0 0x0000060c 254#define ENET_TCSR1 0x00000610 255#define ENET_TCCR1 0x00000614 256#define ENET_TCSR2 0x00000618 257#define ENET_TCCR2 0x0000061c 258#define ENET_TCSR3 0x00000620 259#define ENET_TCCR3 0x00000624 260 261#define AIPS_ENET_SIZE 0x00000800 262 263/* enhanced transmit buffer descriptor */ 264struct enet_txdesc { 265 uint32_t tx_flags1_len; 266#define TXFLAGS1_R __BIT(31) /* Ready */ 267#define TXFLAGS1_T1 __BIT(30) /* TX software owner1 */ 268#define TXFLAGS1_W __BIT(29) /* Wrap */ 269#define TXFLAGS1_T2 __BIT(28) /* TX software owner2 */ 270#define TXFLAGS1_L __BIT(27) /* Last in frame */ 271#define TXFLAGS1_TC __BIT(26) /* Transmit CRC */ 272#define TXFLAGS1_ABC __BIT(25) /* Append bad CRC */ 273#define TXFLAGS1_LEN(n) ((n) & 0xffff) 274 uint32_t tx_databuf; 275 uint32_t tx_flags2; 276#define TXFLAGS2_INT __BIT(30) /* Interrupt */ 277#define TXFLAGS2_TS __BIT(29) /* Timestamp */ 278#define TXFLAGS2_PINS __BIT(28) /* Insert Proto csum */ 279#define TXFLAGS2_IINS __BIT(27) /* Insert IP csum */ 280#define TXFLAGS2_TXE __BIT(15) /* Transmit error */ 281#define TXFLAGS2_UE __BIT(13) /* Underflow error */ 282#define TXFLAGS2_EE __BIT(12) /* Excess colls Err */ 283#define TXFLAGS2_FE __BIT(11) /* Frame Error */ 284#define TXFLAGS2_LCE __BIT(10) /* Late collision Err */ 285#define TXFLAGS2_OE __BIT(9) /* Overfow Error */ 286#define TXFLAGS2_TSE __BIT(8) /* Timestamp Error */ 287 uint32_t tx__reserved1; 288 uint32_t tx_flags3; 289#define TXFLAGS3_BDU __BIT(31) 290 uint32_t tx_1588timestamp; 291 uint32_t tx__reserved2; 292 uint32_t tx__reserved3; 293} __packed; 294 295/* enhanced receive buffer descriptor */ 296struct enet_rxdesc { 297 uint32_t rx_flags1_len; 298#define RXFLAGS1_E __BIT(31) /* Empty */ 299#define RXFLAGS1_R1 __BIT(30) /* RX software owner1 */ 300#define RXFLAGS1_W __BIT(29) /* Wrap */ 301#define RXFLAGS1_R2 __BIT(28) /* RX software owner2 */ 302#define RXFLAGS1_L __BIT(27) /* Last in frame */ 303#define RXFLAGS1_M __BIT(24) /* Miss */ 304#define RXFLAGS1_BC __BIT(23) /* Broadcast */ 305#define RXFLAGS1_MC __BIT(22) /* Multicast */ 306#define RXFLAGS1_LG __BIT(21) /* Length Violation */ 307#define RXFLAGS1_NO __BIT(20) /* Non-Octet aligned */ 308#define RXFLAGS1_CR __BIT(18) /* CRC or frame error */ 309#define RXFLAGS1_OV __BIT(17) /* Overrun */ 310#define RXFLAGS1_TR __BIT(16) /* Truncated */ 311#define RXFLAGS1_LEN(n) ((n) & 0xffff) 312 uint32_t rx_databuf; 313 uint32_t rx_flags2; 314#define RXFLAGS2_ME __BIT(31) /* MAC error */ 315#define RXFLAGS2_PE __BIT(26) /* PHY error */ 316#define RXFLAGS2_CE __BIT(25) /* Collision */ 317#define RXFLAGS2_UC __BIT(24) /* Unicast */ 318#define RXFLAGS2_INT __BIT(23) /* RXB/RXF interrupt */ 319#define RXFLAGS2_VPCP __BITS(15, 31) /* VLAN prio pts (imx7) */ 320#define RXFLAGS2_ICE __BIT(5) /* IP csum error */ 321#define RXFLAGS2_PCR __BIT(4) /* Proto csum error */ 322#define RXFLAGS2_VLAN __BIT(2) /* VLAN */ 323#define RXFLAGS2_IPV6 __BIT(1) /* IPv6 frame */ 324#define RXFLAGS2_FRAG __BIT(0) /* IPv4 fragment */ 325#if _BYTE_ORDER == _LITTLE_ENDIAN 326 uint16_t rx_cksum; 327 uint8_t rx_proto; 328 uint8_t rx_hl; 329#else 330 uint8_t rx_hl; 331 uint8_t rx_proto; 332 uint16_t rx_cksum; 333#endif 334 uint32_t rx_flags3; 335#define RXFLAGS3_BDU __BIT(31) 336 uint32_t rx_1588timestamp; 337 uint32_t rx__reserved2; 338 uint32_t rx__reserved3; 339} __packed; 340 341#endif /* _ARM_IMX_IF_ENETREG_H_ */ 342