162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * mace.h - definitions for the registers in the Am79C940 MACE 462306a36Sopenharmony_ci * (Medium Access Control for Ethernet) controller. 562306a36Sopenharmony_ci * 662306a36Sopenharmony_ci * Copyright (C) 1996 Paul Mackerras. 762306a36Sopenharmony_ci */ 862306a36Sopenharmony_ci 962306a36Sopenharmony_ci#define REG(x) volatile unsigned char x; char x ## _pad[15] 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_cistruct mace { 1262306a36Sopenharmony_ci REG(rcvfifo); /* receive FIFO */ 1362306a36Sopenharmony_ci REG(xmtfifo); /* transmit FIFO */ 1462306a36Sopenharmony_ci REG(xmtfc); /* transmit frame control */ 1562306a36Sopenharmony_ci REG(xmtfs); /* transmit frame status */ 1662306a36Sopenharmony_ci REG(xmtrc); /* transmit retry count */ 1762306a36Sopenharmony_ci REG(rcvfc); /* receive frame control */ 1862306a36Sopenharmony_ci REG(rcvfs); /* receive frame status (4 bytes) */ 1962306a36Sopenharmony_ci REG(fifofc); /* FIFO frame count */ 2062306a36Sopenharmony_ci REG(ir); /* interrupt register */ 2162306a36Sopenharmony_ci REG(imr); /* interrupt mask register */ 2262306a36Sopenharmony_ci REG(pr); /* poll register */ 2362306a36Sopenharmony_ci REG(biucc); /* bus interface unit config control */ 2462306a36Sopenharmony_ci REG(fifocc); /* FIFO configuration control */ 2562306a36Sopenharmony_ci REG(maccc); /* medium access control config control */ 2662306a36Sopenharmony_ci REG(plscc); /* phys layer signalling config control */ 2762306a36Sopenharmony_ci REG(phycc); /* physical configuration control */ 2862306a36Sopenharmony_ci REG(chipid_lo); /* chip ID, lsb */ 2962306a36Sopenharmony_ci REG(chipid_hi); /* chip ID, msb */ 3062306a36Sopenharmony_ci REG(iac); /* internal address config */ 3162306a36Sopenharmony_ci REG(reg19); 3262306a36Sopenharmony_ci REG(ladrf); /* logical address filter (8 bytes) */ 3362306a36Sopenharmony_ci REG(padr); /* physical address (6 bytes) */ 3462306a36Sopenharmony_ci REG(reg22); 3562306a36Sopenharmony_ci REG(reg23); 3662306a36Sopenharmony_ci REG(mpc); /* missed packet count (clears when read) */ 3762306a36Sopenharmony_ci REG(reg25); 3862306a36Sopenharmony_ci REG(rntpc); /* runt packet count (clears when read) */ 3962306a36Sopenharmony_ci REG(rcvcc); /* recv collision count (clears when read) */ 4062306a36Sopenharmony_ci REG(reg28); 4162306a36Sopenharmony_ci REG(utr); /* user test reg */ 4262306a36Sopenharmony_ci REG(reg30); 4362306a36Sopenharmony_ci REG(reg31); 4462306a36Sopenharmony_ci}; 4562306a36Sopenharmony_ci 4662306a36Sopenharmony_ci/* Bits in XMTFC */ 4762306a36Sopenharmony_ci#define DRTRY 0x80 /* don't retry transmission after collision */ 4862306a36Sopenharmony_ci#define DXMTFCS 0x08 /* don't append FCS to transmitted frame */ 4962306a36Sopenharmony_ci#define AUTO_PAD_XMIT 0x01 /* auto-pad short packets on transmission */ 5062306a36Sopenharmony_ci 5162306a36Sopenharmony_ci/* Bits in XMTFS: only valid when XMTSV is set in PR and XMTFS */ 5262306a36Sopenharmony_ci#define XMTSV 0x80 /* transmit status (i.e. XMTFS) valid */ 5362306a36Sopenharmony_ci#define UFLO 0x40 /* underflow - xmit fifo ran dry */ 5462306a36Sopenharmony_ci#define LCOL 0x20 /* late collision (transmission aborted) */ 5562306a36Sopenharmony_ci#define MORE 0x10 /* 2 or more retries needed to xmit frame */ 5662306a36Sopenharmony_ci#define ONE 0x08 /* 1 retry needed to xmit frame */ 5762306a36Sopenharmony_ci#define DEFER 0x04 /* MACE had to defer xmission (enet busy) */ 5862306a36Sopenharmony_ci#define LCAR 0x02 /* loss of carrier (transmission aborted) */ 5962306a36Sopenharmony_ci#define RTRY 0x01 /* too many retries (transmission aborted) */ 6062306a36Sopenharmony_ci 6162306a36Sopenharmony_ci/* Bits in XMTRC: only valid when XMTSV is set in PR (and XMTFS) */ 6262306a36Sopenharmony_ci#define EXDEF 0x80 /* had to defer for excessive time */ 6362306a36Sopenharmony_ci#define RETRY_MASK 0x0f /* number of retries (0 - 15) */ 6462306a36Sopenharmony_ci 6562306a36Sopenharmony_ci/* Bits in RCVFC */ 6662306a36Sopenharmony_ci#define LLRCV 0x08 /* low latency receive: early DMA request */ 6762306a36Sopenharmony_ci#define M_RBAR 0x04 /* sets function of EAM/R pin */ 6862306a36Sopenharmony_ci#define AUTO_STRIP_RCV 0x01 /* auto-strip short LLC frames on recv */ 6962306a36Sopenharmony_ci 7062306a36Sopenharmony_ci/* 7162306a36Sopenharmony_ci * Bits in RCVFS. After a frame is received, four bytes of status 7262306a36Sopenharmony_ci * are automatically read from this register and appended to the frame 7362306a36Sopenharmony_ci * data in memory. These are: 7462306a36Sopenharmony_ci * Byte 0 and 1: message byte count and frame status 7562306a36Sopenharmony_ci * Byte 2: runt packet count 7662306a36Sopenharmony_ci * Byte 3: receive collision count 7762306a36Sopenharmony_ci */ 7862306a36Sopenharmony_ci#define RS_OFLO 0x8000 /* receive FIFO overflowed */ 7962306a36Sopenharmony_ci#define RS_CLSN 0x4000 /* received frame suffered (late) collision */ 8062306a36Sopenharmony_ci#define RS_FRAMERR 0x2000 /* framing error flag */ 8162306a36Sopenharmony_ci#define RS_FCSERR 0x1000 /* frame had FCS error */ 8262306a36Sopenharmony_ci#define RS_COUNT 0x0fff /* mask for byte count field */ 8362306a36Sopenharmony_ci 8462306a36Sopenharmony_ci/* Bits (fields) in FIFOFC */ 8562306a36Sopenharmony_ci#define RCVFC_SH 4 /* receive frame count in FIFO */ 8662306a36Sopenharmony_ci#define RCVFC_MASK 0x0f 8762306a36Sopenharmony_ci#define XMTFC_SH 0 /* transmit frame count in FIFO */ 8862306a36Sopenharmony_ci#define XMTFC_MASK 0x0f 8962306a36Sopenharmony_ci 9062306a36Sopenharmony_ci/* 9162306a36Sopenharmony_ci * Bits in IR and IMR. The IR clears itself when read. 9262306a36Sopenharmony_ci * Setting a bit in the IMR will disable the corresponding interrupt. 9362306a36Sopenharmony_ci */ 9462306a36Sopenharmony_ci#define JABBER 0x80 /* jabber error - 10baseT xmission too long */ 9562306a36Sopenharmony_ci#define BABBLE 0x40 /* babble - xmitter xmitting for too long */ 9662306a36Sopenharmony_ci#define CERR 0x20 /* collision err - no SQE test (heartbeat) */ 9762306a36Sopenharmony_ci#define RCVCCO 0x10 /* RCVCC overflow */ 9862306a36Sopenharmony_ci#define RNTPCO 0x08 /* RNTPC overflow */ 9962306a36Sopenharmony_ci#define MPCO 0x04 /* MPC overflow */ 10062306a36Sopenharmony_ci#define RCVINT 0x02 /* receive interrupt */ 10162306a36Sopenharmony_ci#define XMTINT 0x01 /* transmitter interrupt */ 10262306a36Sopenharmony_ci 10362306a36Sopenharmony_ci/* Bits in PR */ 10462306a36Sopenharmony_ci#define XMTSV 0x80 /* XMTFS valid (same as in XMTFS) */ 10562306a36Sopenharmony_ci#define TDTREQ 0x40 /* set when xmit fifo is requesting data */ 10662306a36Sopenharmony_ci#define RDTREQ 0x20 /* set when recv fifo requests data xfer */ 10762306a36Sopenharmony_ci 10862306a36Sopenharmony_ci/* Bits in BIUCC */ 10962306a36Sopenharmony_ci#define BSWP 0x40 /* byte swap, i.e. big-endian bus */ 11062306a36Sopenharmony_ci#define XMTSP_4 0x00 /* start xmitting when 4 bytes in FIFO */ 11162306a36Sopenharmony_ci#define XMTSP_16 0x10 /* start xmitting when 16 bytes in FIFO */ 11262306a36Sopenharmony_ci#define XMTSP_64 0x20 /* start xmitting when 64 bytes in FIFO */ 11362306a36Sopenharmony_ci#define XMTSP_112 0x30 /* start xmitting when 112 bytes in FIFO */ 11462306a36Sopenharmony_ci#define SWRST 0x01 /* software reset */ 11562306a36Sopenharmony_ci 11662306a36Sopenharmony_ci/* Bits in FIFOCC */ 11762306a36Sopenharmony_ci#define XMTFW_8 0x00 /* xmit fifo watermark = 8 words free */ 11862306a36Sopenharmony_ci#define XMTFW_16 0x40 /* 16 words free */ 11962306a36Sopenharmony_ci#define XMTFW_32 0x80 /* 32 words free */ 12062306a36Sopenharmony_ci#define RCVFW_16 0x00 /* recv fifo watermark = 16 bytes avail */ 12162306a36Sopenharmony_ci#define RCVFW_32 0x10 /* 32 bytes avail */ 12262306a36Sopenharmony_ci#define RCVFW_64 0x20 /* 64 bytes avail */ 12362306a36Sopenharmony_ci#define XMTFWU 0x08 /* xmit fifo watermark update enable */ 12462306a36Sopenharmony_ci#define RCVFWU 0x04 /* recv fifo watermark update enable */ 12562306a36Sopenharmony_ci#define XMTBRST 0x02 /* enable transmit burst mode */ 12662306a36Sopenharmony_ci#define RCVBRST 0x01 /* enable receive burst mode */ 12762306a36Sopenharmony_ci 12862306a36Sopenharmony_ci/* Bits in MACCC */ 12962306a36Sopenharmony_ci#define PROM 0x80 /* promiscuous mode */ 13062306a36Sopenharmony_ci#define DXMT2PD 0x40 /* disable xmit two-part deferral algorithm */ 13162306a36Sopenharmony_ci#define EMBA 0x20 /* enable modified backoff algorithm */ 13262306a36Sopenharmony_ci#define DRCVPA 0x08 /* disable receiving physical address */ 13362306a36Sopenharmony_ci#define DRCVBC 0x04 /* disable receiving broadcasts */ 13462306a36Sopenharmony_ci#define ENXMT 0x02 /* enable transmitter */ 13562306a36Sopenharmony_ci#define ENRCV 0x01 /* enable receiver */ 13662306a36Sopenharmony_ci 13762306a36Sopenharmony_ci/* Bits in PLSCC */ 13862306a36Sopenharmony_ci#define XMTSEL 0x08 /* select DO+/DO- state when idle */ 13962306a36Sopenharmony_ci#define PORTSEL_AUI 0x00 /* select AUI port */ 14062306a36Sopenharmony_ci#define PORTSEL_10T 0x02 /* select 10Base-T port */ 14162306a36Sopenharmony_ci#define PORTSEL_DAI 0x04 /* select DAI port */ 14262306a36Sopenharmony_ci#define PORTSEL_GPSI 0x06 /* select GPSI port */ 14362306a36Sopenharmony_ci#define ENPLSIO 0x01 /* enable optional PLS I/O pins */ 14462306a36Sopenharmony_ci 14562306a36Sopenharmony_ci/* Bits in PHYCC */ 14662306a36Sopenharmony_ci#define LNKFL 0x80 /* reports 10Base-T link failure */ 14762306a36Sopenharmony_ci#define DLNKTST 0x40 /* disable 10Base-T link test */ 14862306a36Sopenharmony_ci#define REVPOL 0x20 /* 10Base-T receiver polarity reversed */ 14962306a36Sopenharmony_ci#define DAPC 0x10 /* disable auto receiver polarity correction */ 15062306a36Sopenharmony_ci#define LRT 0x08 /* low receive threshold for long links */ 15162306a36Sopenharmony_ci#define ASEL 0x04 /* auto-select AUI or 10Base-T port */ 15262306a36Sopenharmony_ci#define RWAKE 0x02 /* remote wake function */ 15362306a36Sopenharmony_ci#define AWAKE 0x01 /* auto wake function */ 15462306a36Sopenharmony_ci 15562306a36Sopenharmony_ci/* Bits in IAC */ 15662306a36Sopenharmony_ci#define ADDRCHG 0x80 /* request address change */ 15762306a36Sopenharmony_ci#define PHYADDR 0x04 /* access physical address */ 15862306a36Sopenharmony_ci#define LOGADDR 0x02 /* access multicast filter */ 15962306a36Sopenharmony_ci 16062306a36Sopenharmony_ci/* Bits in UTR */ 16162306a36Sopenharmony_ci#define RTRE 0x80 /* reserved test register enable. DON'T SET. */ 16262306a36Sopenharmony_ci#define RTRD 0x40 /* reserved test register disable. Sticky */ 16362306a36Sopenharmony_ci#define RPAC 0x20 /* accept runt packets */ 16462306a36Sopenharmony_ci#define FCOLL 0x10 /* force collision */ 16562306a36Sopenharmony_ci#define RCVFCSE 0x08 /* receive FCS enable */ 16662306a36Sopenharmony_ci#define LOOP_NONE 0x00 /* no loopback */ 16762306a36Sopenharmony_ci#define LOOP_EXT 0x02 /* external loopback */ 16862306a36Sopenharmony_ci#define LOOP_INT 0x04 /* internal loopback, excludes MENDEC */ 16962306a36Sopenharmony_ci#define LOOP_MENDEC 0x06 /* internal loopback, includes MENDEC */ 170