1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0-or-later */ 2*4882a593Smuzhiyun /* 3*4882a593Smuzhiyun * mace.h - definitions for the registers in the Am79C940 MACE 4*4882a593Smuzhiyun * (Medium Access Control for Ethernet) controller. 5*4882a593Smuzhiyun * 6*4882a593Smuzhiyun * Copyright (C) 1996 Paul Mackerras. 7*4882a593Smuzhiyun */ 8*4882a593Smuzhiyun 9*4882a593Smuzhiyun #define REG(x) volatile unsigned char x; char x ## _pad[15] 10*4882a593Smuzhiyun 11*4882a593Smuzhiyun struct mace { 12*4882a593Smuzhiyun REG(rcvfifo); /* receive FIFO */ 13*4882a593Smuzhiyun REG(xmtfifo); /* transmit FIFO */ 14*4882a593Smuzhiyun REG(xmtfc); /* transmit frame control */ 15*4882a593Smuzhiyun REG(xmtfs); /* transmit frame status */ 16*4882a593Smuzhiyun REG(xmtrc); /* transmit retry count */ 17*4882a593Smuzhiyun REG(rcvfc); /* receive frame control */ 18*4882a593Smuzhiyun REG(rcvfs); /* receive frame status (4 bytes) */ 19*4882a593Smuzhiyun REG(fifofc); /* FIFO frame count */ 20*4882a593Smuzhiyun REG(ir); /* interrupt register */ 21*4882a593Smuzhiyun REG(imr); /* interrupt mask register */ 22*4882a593Smuzhiyun REG(pr); /* poll register */ 23*4882a593Smuzhiyun REG(biucc); /* bus interface unit config control */ 24*4882a593Smuzhiyun REG(fifocc); /* FIFO configuration control */ 25*4882a593Smuzhiyun REG(maccc); /* medium access control config control */ 26*4882a593Smuzhiyun REG(plscc); /* phys layer signalling config control */ 27*4882a593Smuzhiyun REG(phycc); /* physical configuration control */ 28*4882a593Smuzhiyun REG(chipid_lo); /* chip ID, lsb */ 29*4882a593Smuzhiyun REG(chipid_hi); /* chip ID, msb */ 30*4882a593Smuzhiyun REG(iac); /* internal address config */ 31*4882a593Smuzhiyun REG(reg19); 32*4882a593Smuzhiyun REG(ladrf); /* logical address filter (8 bytes) */ 33*4882a593Smuzhiyun REG(padr); /* physical address (6 bytes) */ 34*4882a593Smuzhiyun REG(reg22); 35*4882a593Smuzhiyun REG(reg23); 36*4882a593Smuzhiyun REG(mpc); /* missed packet count (clears when read) */ 37*4882a593Smuzhiyun REG(reg25); 38*4882a593Smuzhiyun REG(rntpc); /* runt packet count (clears when read) */ 39*4882a593Smuzhiyun REG(rcvcc); /* recv collision count (clears when read) */ 40*4882a593Smuzhiyun REG(reg28); 41*4882a593Smuzhiyun REG(utr); /* user test reg */ 42*4882a593Smuzhiyun REG(reg30); 43*4882a593Smuzhiyun REG(reg31); 44*4882a593Smuzhiyun }; 45*4882a593Smuzhiyun 46*4882a593Smuzhiyun /* Bits in XMTFC */ 47*4882a593Smuzhiyun #define DRTRY 0x80 /* don't retry transmission after collision */ 48*4882a593Smuzhiyun #define DXMTFCS 0x08 /* don't append FCS to transmitted frame */ 49*4882a593Smuzhiyun #define AUTO_PAD_XMIT 0x01 /* auto-pad short packets on transmission */ 50*4882a593Smuzhiyun 51*4882a593Smuzhiyun /* Bits in XMTFS: only valid when XMTSV is set in PR and XMTFS */ 52*4882a593Smuzhiyun #define XMTSV 0x80 /* transmit status (i.e. XMTFS) valid */ 53*4882a593Smuzhiyun #define UFLO 0x40 /* underflow - xmit fifo ran dry */ 54*4882a593Smuzhiyun #define LCOL 0x20 /* late collision (transmission aborted) */ 55*4882a593Smuzhiyun #define MORE 0x10 /* 2 or more retries needed to xmit frame */ 56*4882a593Smuzhiyun #define ONE 0x08 /* 1 retry needed to xmit frame */ 57*4882a593Smuzhiyun #define DEFER 0x04 /* MACE had to defer xmission (enet busy) */ 58*4882a593Smuzhiyun #define LCAR 0x02 /* loss of carrier (transmission aborted) */ 59*4882a593Smuzhiyun #define RTRY 0x01 /* too many retries (transmission aborted) */ 60*4882a593Smuzhiyun 61*4882a593Smuzhiyun /* Bits in XMTRC: only valid when XMTSV is set in PR (and XMTFS) */ 62*4882a593Smuzhiyun #define EXDEF 0x80 /* had to defer for excessive time */ 63*4882a593Smuzhiyun #define RETRY_MASK 0x0f /* number of retries (0 - 15) */ 64*4882a593Smuzhiyun 65*4882a593Smuzhiyun /* Bits in RCVFC */ 66*4882a593Smuzhiyun #define LLRCV 0x08 /* low latency receive: early DMA request */ 67*4882a593Smuzhiyun #define M_RBAR 0x04 /* sets function of EAM/R pin */ 68*4882a593Smuzhiyun #define AUTO_STRIP_RCV 0x01 /* auto-strip short LLC frames on recv */ 69*4882a593Smuzhiyun 70*4882a593Smuzhiyun /* 71*4882a593Smuzhiyun * Bits in RCVFS. After a frame is received, four bytes of status 72*4882a593Smuzhiyun * are automatically read from this register and appended to the frame 73*4882a593Smuzhiyun * data in memory. These are: 74*4882a593Smuzhiyun * Byte 0 and 1: message byte count and frame status 75*4882a593Smuzhiyun * Byte 2: runt packet count 76*4882a593Smuzhiyun * Byte 3: receive collision count 77*4882a593Smuzhiyun */ 78*4882a593Smuzhiyun #define RS_OFLO 0x8000 /* receive FIFO overflowed */ 79*4882a593Smuzhiyun #define RS_CLSN 0x4000 /* received frame suffered (late) collision */ 80*4882a593Smuzhiyun #define RS_FRAMERR 0x2000 /* framing error flag */ 81*4882a593Smuzhiyun #define RS_FCSERR 0x1000 /* frame had FCS error */ 82*4882a593Smuzhiyun #define RS_COUNT 0x0fff /* mask for byte count field */ 83*4882a593Smuzhiyun 84*4882a593Smuzhiyun /* Bits (fields) in FIFOFC */ 85*4882a593Smuzhiyun #define RCVFC_SH 4 /* receive frame count in FIFO */ 86*4882a593Smuzhiyun #define RCVFC_MASK 0x0f 87*4882a593Smuzhiyun #define XMTFC_SH 0 /* transmit frame count in FIFO */ 88*4882a593Smuzhiyun #define XMTFC_MASK 0x0f 89*4882a593Smuzhiyun 90*4882a593Smuzhiyun /* 91*4882a593Smuzhiyun * Bits in IR and IMR. The IR clears itself when read. 92*4882a593Smuzhiyun * Setting a bit in the IMR will disable the corresponding interrupt. 93*4882a593Smuzhiyun */ 94*4882a593Smuzhiyun #define JABBER 0x80 /* jabber error - 10baseT xmission too long */ 95*4882a593Smuzhiyun #define BABBLE 0x40 /* babble - xmitter xmitting for too long */ 96*4882a593Smuzhiyun #define CERR 0x20 /* collision err - no SQE test (heartbeat) */ 97*4882a593Smuzhiyun #define RCVCCO 0x10 /* RCVCC overflow */ 98*4882a593Smuzhiyun #define RNTPCO 0x08 /* RNTPC overflow */ 99*4882a593Smuzhiyun #define MPCO 0x04 /* MPC overflow */ 100*4882a593Smuzhiyun #define RCVINT 0x02 /* receive interrupt */ 101*4882a593Smuzhiyun #define XMTINT 0x01 /* transmitter interrupt */ 102*4882a593Smuzhiyun 103*4882a593Smuzhiyun /* Bits in PR */ 104*4882a593Smuzhiyun #define XMTSV 0x80 /* XMTFS valid (same as in XMTFS) */ 105*4882a593Smuzhiyun #define TDTREQ 0x40 /* set when xmit fifo is requesting data */ 106*4882a593Smuzhiyun #define RDTREQ 0x20 /* set when recv fifo requests data xfer */ 107*4882a593Smuzhiyun 108*4882a593Smuzhiyun /* Bits in BIUCC */ 109*4882a593Smuzhiyun #define BSWP 0x40 /* byte swap, i.e. big-endian bus */ 110*4882a593Smuzhiyun #define XMTSP_4 0x00 /* start xmitting when 4 bytes in FIFO */ 111*4882a593Smuzhiyun #define XMTSP_16 0x10 /* start xmitting when 16 bytes in FIFO */ 112*4882a593Smuzhiyun #define XMTSP_64 0x20 /* start xmitting when 64 bytes in FIFO */ 113*4882a593Smuzhiyun #define XMTSP_112 0x30 /* start xmitting when 112 bytes in FIFO */ 114*4882a593Smuzhiyun #define SWRST 0x01 /* software reset */ 115*4882a593Smuzhiyun 116*4882a593Smuzhiyun /* Bits in FIFOCC */ 117*4882a593Smuzhiyun #define XMTFW_8 0x00 /* xmit fifo watermark = 8 words free */ 118*4882a593Smuzhiyun #define XMTFW_16 0x40 /* 16 words free */ 119*4882a593Smuzhiyun #define XMTFW_32 0x80 /* 32 words free */ 120*4882a593Smuzhiyun #define RCVFW_16 0x00 /* recv fifo watermark = 16 bytes avail */ 121*4882a593Smuzhiyun #define RCVFW_32 0x10 /* 32 bytes avail */ 122*4882a593Smuzhiyun #define RCVFW_64 0x20 /* 64 bytes avail */ 123*4882a593Smuzhiyun #define XMTFWU 0x08 /* xmit fifo watermark update enable */ 124*4882a593Smuzhiyun #define RCVFWU 0x04 /* recv fifo watermark update enable */ 125*4882a593Smuzhiyun #define XMTBRST 0x02 /* enable transmit burst mode */ 126*4882a593Smuzhiyun #define RCVBRST 0x01 /* enable receive burst mode */ 127*4882a593Smuzhiyun 128*4882a593Smuzhiyun /* Bits in MACCC */ 129*4882a593Smuzhiyun #define PROM 0x80 /* promiscuous mode */ 130*4882a593Smuzhiyun #define DXMT2PD 0x40 /* disable xmit two-part deferral algorithm */ 131*4882a593Smuzhiyun #define EMBA 0x20 /* enable modified backoff algorithm */ 132*4882a593Smuzhiyun #define DRCVPA 0x08 /* disable receiving physical address */ 133*4882a593Smuzhiyun #define DRCVBC 0x04 /* disable receiving broadcasts */ 134*4882a593Smuzhiyun #define ENXMT 0x02 /* enable transmitter */ 135*4882a593Smuzhiyun #define ENRCV 0x01 /* enable receiver */ 136*4882a593Smuzhiyun 137*4882a593Smuzhiyun /* Bits in PLSCC */ 138*4882a593Smuzhiyun #define XMTSEL 0x08 /* select DO+/DO- state when idle */ 139*4882a593Smuzhiyun #define PORTSEL_AUI 0x00 /* select AUI port */ 140*4882a593Smuzhiyun #define PORTSEL_10T 0x02 /* select 10Base-T port */ 141*4882a593Smuzhiyun #define PORTSEL_DAI 0x04 /* select DAI port */ 142*4882a593Smuzhiyun #define PORTSEL_GPSI 0x06 /* select GPSI port */ 143*4882a593Smuzhiyun #define ENPLSIO 0x01 /* enable optional PLS I/O pins */ 144*4882a593Smuzhiyun 145*4882a593Smuzhiyun /* Bits in PHYCC */ 146*4882a593Smuzhiyun #define LNKFL 0x80 /* reports 10Base-T link failure */ 147*4882a593Smuzhiyun #define DLNKTST 0x40 /* disable 10Base-T link test */ 148*4882a593Smuzhiyun #define REVPOL 0x20 /* 10Base-T receiver polarity reversed */ 149*4882a593Smuzhiyun #define DAPC 0x10 /* disable auto receiver polarity correction */ 150*4882a593Smuzhiyun #define LRT 0x08 /* low receive threshold for long links */ 151*4882a593Smuzhiyun #define ASEL 0x04 /* auto-select AUI or 10Base-T port */ 152*4882a593Smuzhiyun #define RWAKE 0x02 /* remote wake function */ 153*4882a593Smuzhiyun #define AWAKE 0x01 /* auto wake function */ 154*4882a593Smuzhiyun 155*4882a593Smuzhiyun /* Bits in IAC */ 156*4882a593Smuzhiyun #define ADDRCHG 0x80 /* request address change */ 157*4882a593Smuzhiyun #define PHYADDR 0x04 /* access physical address */ 158*4882a593Smuzhiyun #define LOGADDR 0x02 /* access multicast filter */ 159*4882a593Smuzhiyun 160*4882a593Smuzhiyun /* Bits in UTR */ 161*4882a593Smuzhiyun #define RTRE 0x80 /* reserved test register enable. DON'T SET. */ 162*4882a593Smuzhiyun #define RTRD 0x40 /* reserved test register disable. Sticky */ 163*4882a593Smuzhiyun #define RPAC 0x20 /* accept runt packets */ 164*4882a593Smuzhiyun #define FCOLL 0x10 /* force collision */ 165*4882a593Smuzhiyun #define RCVFCSE 0x08 /* receive FCS enable */ 166*4882a593Smuzhiyun #define LOOP_NONE 0x00 /* no loopback */ 167*4882a593Smuzhiyun #define LOOP_EXT 0x02 /* external loopback */ 168*4882a593Smuzhiyun #define LOOP_INT 0x04 /* internal loopback, excludes MENDEC */ 169*4882a593Smuzhiyun #define LOOP_MENDEC 0x06 /* internal loopback, includes MENDEC */ 170