18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * mace.h - definitions for the registers in the Am79C940 MACE
48c2ecf20Sopenharmony_ci * (Medium Access Control for Ethernet) controller.
58c2ecf20Sopenharmony_ci *
68c2ecf20Sopenharmony_ci * Copyright (C) 1996 Paul Mackerras.
78c2ecf20Sopenharmony_ci */
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#define REG(x)	volatile unsigned char x; char x ## _pad[15]
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_cistruct mace {
128c2ecf20Sopenharmony_ci	REG(rcvfifo);		/* receive FIFO */
138c2ecf20Sopenharmony_ci	REG(xmtfifo);		/* transmit FIFO */
148c2ecf20Sopenharmony_ci	REG(xmtfc);		/* transmit frame control */
158c2ecf20Sopenharmony_ci	REG(xmtfs);		/* transmit frame status */
168c2ecf20Sopenharmony_ci	REG(xmtrc);		/* transmit retry count */
178c2ecf20Sopenharmony_ci	REG(rcvfc);		/* receive frame control */
188c2ecf20Sopenharmony_ci	REG(rcvfs);		/* receive frame status (4 bytes) */
198c2ecf20Sopenharmony_ci	REG(fifofc);		/* FIFO frame count */
208c2ecf20Sopenharmony_ci	REG(ir);		/* interrupt register */
218c2ecf20Sopenharmony_ci	REG(imr);		/* interrupt mask register */
228c2ecf20Sopenharmony_ci	REG(pr);		/* poll register */
238c2ecf20Sopenharmony_ci	REG(biucc);		/* bus interface unit config control */
248c2ecf20Sopenharmony_ci	REG(fifocc);		/* FIFO configuration control */
258c2ecf20Sopenharmony_ci	REG(maccc);		/* medium access control config control */
268c2ecf20Sopenharmony_ci	REG(plscc);		/* phys layer signalling config control */
278c2ecf20Sopenharmony_ci	REG(phycc);		/* physical configuration control */
288c2ecf20Sopenharmony_ci	REG(chipid_lo);		/* chip ID, lsb */
298c2ecf20Sopenharmony_ci	REG(chipid_hi);		/* chip ID, msb */
308c2ecf20Sopenharmony_ci	REG(iac);		/* internal address config */
318c2ecf20Sopenharmony_ci	REG(reg19);
328c2ecf20Sopenharmony_ci	REG(ladrf);		/* logical address filter (8 bytes) */
338c2ecf20Sopenharmony_ci	REG(padr);		/* physical address (6 bytes) */
348c2ecf20Sopenharmony_ci	REG(reg22);
358c2ecf20Sopenharmony_ci	REG(reg23);
368c2ecf20Sopenharmony_ci	REG(mpc);		/* missed packet count (clears when read) */
378c2ecf20Sopenharmony_ci	REG(reg25);
388c2ecf20Sopenharmony_ci	REG(rntpc);		/* runt packet count (clears when read) */
398c2ecf20Sopenharmony_ci	REG(rcvcc);		/* recv collision count (clears when read) */
408c2ecf20Sopenharmony_ci	REG(reg28);
418c2ecf20Sopenharmony_ci	REG(utr);		/* user test reg */
428c2ecf20Sopenharmony_ci	REG(reg30);
438c2ecf20Sopenharmony_ci	REG(reg31);
448c2ecf20Sopenharmony_ci};
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_ci/* Bits in XMTFC */
478c2ecf20Sopenharmony_ci#define DRTRY		0x80	/* don't retry transmission after collision */
488c2ecf20Sopenharmony_ci#define DXMTFCS		0x08	/* don't append FCS to transmitted frame */
498c2ecf20Sopenharmony_ci#define AUTO_PAD_XMIT	0x01	/* auto-pad short packets on transmission */
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_ci/* Bits in XMTFS: only valid when XMTSV is set in PR and XMTFS */
528c2ecf20Sopenharmony_ci#define XMTSV		0x80	/* transmit status (i.e. XMTFS) valid */
538c2ecf20Sopenharmony_ci#define UFLO		0x40	/* underflow - xmit fifo ran dry */
548c2ecf20Sopenharmony_ci#define LCOL		0x20	/* late collision (transmission aborted) */
558c2ecf20Sopenharmony_ci#define MORE		0x10	/* 2 or more retries needed to xmit frame */
568c2ecf20Sopenharmony_ci#define ONE		0x08	/* 1 retry needed to xmit frame */
578c2ecf20Sopenharmony_ci#define DEFER		0x04	/* MACE had to defer xmission (enet busy) */
588c2ecf20Sopenharmony_ci#define LCAR		0x02	/* loss of carrier (transmission aborted) */
598c2ecf20Sopenharmony_ci#define RTRY		0x01	/* too many retries (transmission aborted) */
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ci/* Bits in XMTRC: only valid when XMTSV is set in PR (and XMTFS) */
628c2ecf20Sopenharmony_ci#define EXDEF		0x80	/* had to defer for excessive time */
638c2ecf20Sopenharmony_ci#define RETRY_MASK	0x0f	/* number of retries (0 - 15) */
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_ci/* Bits in RCVFC */
668c2ecf20Sopenharmony_ci#define LLRCV		0x08	/* low latency receive: early DMA request */
678c2ecf20Sopenharmony_ci#define M_RBAR		0x04	/* sets function of EAM/R pin */
688c2ecf20Sopenharmony_ci#define AUTO_STRIP_RCV	0x01	/* auto-strip short LLC frames on recv */
698c2ecf20Sopenharmony_ci
708c2ecf20Sopenharmony_ci/*
718c2ecf20Sopenharmony_ci * Bits in RCVFS.  After a frame is received, four bytes of status
728c2ecf20Sopenharmony_ci * are automatically read from this register and appended to the frame
738c2ecf20Sopenharmony_ci * data in memory.  These are:
748c2ecf20Sopenharmony_ci * Byte 0 and 1: message byte count and frame status
758c2ecf20Sopenharmony_ci * Byte 2: runt packet count
768c2ecf20Sopenharmony_ci * Byte 3: receive collision count
778c2ecf20Sopenharmony_ci */
788c2ecf20Sopenharmony_ci#define RS_OFLO		0x8000	/* receive FIFO overflowed */
798c2ecf20Sopenharmony_ci#define RS_CLSN		0x4000	/* received frame suffered (late) collision */
808c2ecf20Sopenharmony_ci#define RS_FRAMERR	0x2000	/* framing error flag */
818c2ecf20Sopenharmony_ci#define RS_FCSERR	0x1000	/* frame had FCS error */
828c2ecf20Sopenharmony_ci#define RS_COUNT	0x0fff	/* mask for byte count field */
838c2ecf20Sopenharmony_ci
848c2ecf20Sopenharmony_ci/* Bits (fields) in FIFOFC */
858c2ecf20Sopenharmony_ci#define RCVFC_SH	4	/* receive frame count in FIFO */
868c2ecf20Sopenharmony_ci#define RCVFC_MASK	0x0f
878c2ecf20Sopenharmony_ci#define XMTFC_SH	0	/* transmit frame count in FIFO */
888c2ecf20Sopenharmony_ci#define XMTFC_MASK	0x0f
898c2ecf20Sopenharmony_ci
908c2ecf20Sopenharmony_ci/*
918c2ecf20Sopenharmony_ci * Bits in IR and IMR.  The IR clears itself when read.
928c2ecf20Sopenharmony_ci * Setting a bit in the IMR will disable the corresponding interrupt.
938c2ecf20Sopenharmony_ci */
948c2ecf20Sopenharmony_ci#define JABBER		0x80	/* jabber error - 10baseT xmission too long */
958c2ecf20Sopenharmony_ci#define BABBLE		0x40	/* babble - xmitter xmitting for too long */
968c2ecf20Sopenharmony_ci#define CERR		0x20	/* collision err - no SQE test (heartbeat) */
978c2ecf20Sopenharmony_ci#define RCVCCO		0x10	/* RCVCC overflow */
988c2ecf20Sopenharmony_ci#define RNTPCO		0x08	/* RNTPC overflow */
998c2ecf20Sopenharmony_ci#define MPCO		0x04	/* MPC overflow */
1008c2ecf20Sopenharmony_ci#define RCVINT		0x02	/* receive interrupt */
1018c2ecf20Sopenharmony_ci#define XMTINT		0x01	/* transmitter interrupt */
1028c2ecf20Sopenharmony_ci
1038c2ecf20Sopenharmony_ci/* Bits in PR */
1048c2ecf20Sopenharmony_ci#define XMTSV		0x80	/* XMTFS valid (same as in XMTFS) */
1058c2ecf20Sopenharmony_ci#define TDTREQ		0x40	/* set when xmit fifo is requesting data */
1068c2ecf20Sopenharmony_ci#define RDTREQ		0x20	/* set when recv fifo requests data xfer */
1078c2ecf20Sopenharmony_ci
1088c2ecf20Sopenharmony_ci/* Bits in BIUCC */
1098c2ecf20Sopenharmony_ci#define BSWP		0x40	/* byte swap, i.e. big-endian bus */
1108c2ecf20Sopenharmony_ci#define XMTSP_4		0x00	/* start xmitting when 4 bytes in FIFO */
1118c2ecf20Sopenharmony_ci#define XMTSP_16	0x10	/* start xmitting when 16 bytes in FIFO */
1128c2ecf20Sopenharmony_ci#define XMTSP_64	0x20	/* start xmitting when 64 bytes in FIFO */
1138c2ecf20Sopenharmony_ci#define XMTSP_112	0x30	/* start xmitting when 112 bytes in FIFO */
1148c2ecf20Sopenharmony_ci#define SWRST		0x01	/* software reset */
1158c2ecf20Sopenharmony_ci
1168c2ecf20Sopenharmony_ci/* Bits in FIFOCC */
1178c2ecf20Sopenharmony_ci#define XMTFW_8		0x00	/* xmit fifo watermark = 8 words free */
1188c2ecf20Sopenharmony_ci#define XMTFW_16	0x40	/*  16 words free */
1198c2ecf20Sopenharmony_ci#define XMTFW_32	0x80	/*  32 words free */
1208c2ecf20Sopenharmony_ci#define RCVFW_16	0x00	/* recv fifo watermark = 16 bytes avail */
1218c2ecf20Sopenharmony_ci#define RCVFW_32	0x10	/*  32 bytes avail */
1228c2ecf20Sopenharmony_ci#define RCVFW_64	0x20	/*  64 bytes avail */
1238c2ecf20Sopenharmony_ci#define XMTFWU		0x08	/* xmit fifo watermark update enable */
1248c2ecf20Sopenharmony_ci#define RCVFWU		0x04	/* recv fifo watermark update enable */
1258c2ecf20Sopenharmony_ci#define XMTBRST		0x02	/* enable transmit burst mode */
1268c2ecf20Sopenharmony_ci#define RCVBRST		0x01	/* enable receive burst mode */
1278c2ecf20Sopenharmony_ci
1288c2ecf20Sopenharmony_ci/* Bits in MACCC */
1298c2ecf20Sopenharmony_ci#define PROM		0x80	/* promiscuous mode */
1308c2ecf20Sopenharmony_ci#define DXMT2PD		0x40	/* disable xmit two-part deferral algorithm */
1318c2ecf20Sopenharmony_ci#define EMBA		0x20	/* enable modified backoff algorithm */
1328c2ecf20Sopenharmony_ci#define DRCVPA		0x08	/* disable receiving physical address */
1338c2ecf20Sopenharmony_ci#define DRCVBC		0x04	/* disable receiving broadcasts */
1348c2ecf20Sopenharmony_ci#define ENXMT		0x02	/* enable transmitter */
1358c2ecf20Sopenharmony_ci#define ENRCV		0x01	/* enable receiver */
1368c2ecf20Sopenharmony_ci
1378c2ecf20Sopenharmony_ci/* Bits in PLSCC */
1388c2ecf20Sopenharmony_ci#define XMTSEL		0x08	/* select DO+/DO- state when idle */
1398c2ecf20Sopenharmony_ci#define PORTSEL_AUI	0x00	/* select AUI port */
1408c2ecf20Sopenharmony_ci#define PORTSEL_10T	0x02	/* select 10Base-T port */
1418c2ecf20Sopenharmony_ci#define PORTSEL_DAI	0x04	/* select DAI port */
1428c2ecf20Sopenharmony_ci#define PORTSEL_GPSI	0x06	/* select GPSI port */
1438c2ecf20Sopenharmony_ci#define ENPLSIO		0x01	/* enable optional PLS I/O pins */
1448c2ecf20Sopenharmony_ci
1458c2ecf20Sopenharmony_ci/* Bits in PHYCC */
1468c2ecf20Sopenharmony_ci#define LNKFL		0x80	/* reports 10Base-T link failure */
1478c2ecf20Sopenharmony_ci#define DLNKTST		0x40	/* disable 10Base-T link test */
1488c2ecf20Sopenharmony_ci#define REVPOL		0x20	/* 10Base-T receiver polarity reversed */
1498c2ecf20Sopenharmony_ci#define DAPC		0x10	/* disable auto receiver polarity correction */
1508c2ecf20Sopenharmony_ci#define LRT		0x08	/* low receive threshold for long links */
1518c2ecf20Sopenharmony_ci#define ASEL		0x04	/* auto-select AUI or 10Base-T port */
1528c2ecf20Sopenharmony_ci#define RWAKE		0x02	/* remote wake function */
1538c2ecf20Sopenharmony_ci#define AWAKE		0x01	/* auto wake function */
1548c2ecf20Sopenharmony_ci
1558c2ecf20Sopenharmony_ci/* Bits in IAC */
1568c2ecf20Sopenharmony_ci#define ADDRCHG		0x80	/* request address change */
1578c2ecf20Sopenharmony_ci#define PHYADDR		0x04	/* access physical address */
1588c2ecf20Sopenharmony_ci#define LOGADDR		0x02	/* access multicast filter */
1598c2ecf20Sopenharmony_ci
1608c2ecf20Sopenharmony_ci/* Bits in UTR */
1618c2ecf20Sopenharmony_ci#define RTRE		0x80	/* reserved test register enable. DON'T SET. */
1628c2ecf20Sopenharmony_ci#define RTRD		0x40	/* reserved test register disable.  Sticky */
1638c2ecf20Sopenharmony_ci#define RPAC		0x20	/* accept runt packets */
1648c2ecf20Sopenharmony_ci#define FCOLL		0x10	/* force collision */
1658c2ecf20Sopenharmony_ci#define RCVFCSE		0x08	/* receive FCS enable */
1668c2ecf20Sopenharmony_ci#define LOOP_NONE	0x00	/* no loopback */
1678c2ecf20Sopenharmony_ci#define LOOP_EXT	0x02	/* external loopback */
1688c2ecf20Sopenharmony_ci#define LOOP_INT	0x04	/* internal loopback, excludes MENDEC */
1698c2ecf20Sopenharmony_ci#define LOOP_MENDEC	0x06	/* internal loopback, includes MENDEC */
170