18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci *  linux/drivers/acorn/net/ether3.h
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci *  Copyright (C) 1995-2000 Russell King
68c2ecf20Sopenharmony_ci *
78c2ecf20Sopenharmony_ci *  network driver for Acorn/ANT Ether3 cards
88c2ecf20Sopenharmony_ci */
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci#ifndef _LINUX_ether3_H
118c2ecf20Sopenharmony_ci#define _LINUX_ether3_H
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci/* use 0 for production, 1 for verification, >2 for debug. debug flags: */
148c2ecf20Sopenharmony_ci#define DEBUG_TX	 2
158c2ecf20Sopenharmony_ci#define DEBUG_RX	 4
168c2ecf20Sopenharmony_ci#define DEBUG_INT	 8
178c2ecf20Sopenharmony_ci#define DEBUG_IC	16
188c2ecf20Sopenharmony_ci#ifndef NET_DEBUG
198c2ecf20Sopenharmony_ci#define NET_DEBUG 	0
208c2ecf20Sopenharmony_ci#endif
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ci#define priv(dev)	((struct dev_priv *)netdev_priv(dev))
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci/* Command register definitions & bits */
258c2ecf20Sopenharmony_ci#define REG_COMMAND		(priv(dev)->seeq + 0x0000)
268c2ecf20Sopenharmony_ci#define CMD_ENINTDMA		0x0001
278c2ecf20Sopenharmony_ci#define CMD_ENINTRX		0x0002
288c2ecf20Sopenharmony_ci#define CMD_ENINTTX		0x0004
298c2ecf20Sopenharmony_ci#define CMD_ENINTBUFWIN		0x0008
308c2ecf20Sopenharmony_ci#define CMD_ACKINTDMA		0x0010
318c2ecf20Sopenharmony_ci#define CMD_ACKINTRX		0x0020
328c2ecf20Sopenharmony_ci#define CMD_ACKINTTX		0x0040
338c2ecf20Sopenharmony_ci#define CMD_ACKINTBUFWIN	0x0080
348c2ecf20Sopenharmony_ci#define CMD_DMAON		0x0100
358c2ecf20Sopenharmony_ci#define CMD_RXON		0x0200
368c2ecf20Sopenharmony_ci#define CMD_TXON		0x0400
378c2ecf20Sopenharmony_ci#define CMD_DMAOFF		0x0800
388c2ecf20Sopenharmony_ci#define CMD_RXOFF		0x1000
398c2ecf20Sopenharmony_ci#define CMD_TXOFF		0x2000
408c2ecf20Sopenharmony_ci#define CMD_FIFOREAD		0x4000
418c2ecf20Sopenharmony_ci#define CMD_FIFOWRITE		0x8000
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci/* status register */
448c2ecf20Sopenharmony_ci#define REG_STATUS		(priv(dev)->seeq + 0x0000)
458c2ecf20Sopenharmony_ci#define STAT_ENINTSTAT		0x0001
468c2ecf20Sopenharmony_ci#define STAT_ENINTRX		0x0002
478c2ecf20Sopenharmony_ci#define STAT_ENINTTX		0x0004
488c2ecf20Sopenharmony_ci#define STAT_ENINTBUFWIN	0x0008
498c2ecf20Sopenharmony_ci#define STAT_INTDMA		0x0010
508c2ecf20Sopenharmony_ci#define STAT_INTRX		0x0020
518c2ecf20Sopenharmony_ci#define STAT_INTTX		0x0040
528c2ecf20Sopenharmony_ci#define STAT_INTBUFWIN		0x0080
538c2ecf20Sopenharmony_ci#define STAT_DMAON		0x0100
548c2ecf20Sopenharmony_ci#define STAT_RXON		0x0200
558c2ecf20Sopenharmony_ci#define STAT_TXON		0x0400
568c2ecf20Sopenharmony_ci#define STAT_FIFOFULL		0x2000
578c2ecf20Sopenharmony_ci#define STAT_FIFOEMPTY		0x4000
588c2ecf20Sopenharmony_ci#define STAT_FIFODIR		0x8000
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_ci/* configuration register 1 */
618c2ecf20Sopenharmony_ci#define REG_CONFIG1		(priv(dev)->seeq + 0x0040)
628c2ecf20Sopenharmony_ci#define CFG1_BUFSELSTAT0	0x0000
638c2ecf20Sopenharmony_ci#define CFG1_BUFSELSTAT1	0x0001
648c2ecf20Sopenharmony_ci#define CFG1_BUFSELSTAT2	0x0002
658c2ecf20Sopenharmony_ci#define CFG1_BUFSELSTAT3	0x0003
668c2ecf20Sopenharmony_ci#define CFG1_BUFSELSTAT4	0x0004
678c2ecf20Sopenharmony_ci#define CFG1_BUFSELSTAT5	0x0005
688c2ecf20Sopenharmony_ci#define CFG1_ADDRPROM		0x0006
698c2ecf20Sopenharmony_ci#define CFG1_TRANSEND		0x0007
708c2ecf20Sopenharmony_ci#define CFG1_LOCBUFMEM		0x0008
718c2ecf20Sopenharmony_ci#define CFG1_INTVECTOR		0x0009
728c2ecf20Sopenharmony_ci#define CFG1_RECVSPECONLY	0x0000
738c2ecf20Sopenharmony_ci#define CFG1_RECVSPECBROAD	0x4000
748c2ecf20Sopenharmony_ci#define CFG1_RECVSPECBRMULTI	0x8000
758c2ecf20Sopenharmony_ci#define CFG1_RECVPROMISC	0xC000
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_ci/* The following aren't in 8004 */
788c2ecf20Sopenharmony_ci#define CFG1_DMABURSTCONT	0x0000
798c2ecf20Sopenharmony_ci#define CFG1_DMABURST800NS	0x0010
808c2ecf20Sopenharmony_ci#define CFG1_DMABURST1600NS	0x0020
818c2ecf20Sopenharmony_ci#define CFG1_DMABURST3200NS	0x0030
828c2ecf20Sopenharmony_ci#define CFG1_DMABURST1		0x0000
838c2ecf20Sopenharmony_ci#define CFG1_DMABURST4		0x0040
848c2ecf20Sopenharmony_ci#define CFG1_DMABURST8		0x0080
858c2ecf20Sopenharmony_ci#define CFG1_DMABURST16		0x00C0
868c2ecf20Sopenharmony_ci#define CFG1_RECVCOMPSTAT0	0x0100
878c2ecf20Sopenharmony_ci#define CFG1_RECVCOMPSTAT1	0x0200
888c2ecf20Sopenharmony_ci#define CFG1_RECVCOMPSTAT2	0x0400
898c2ecf20Sopenharmony_ci#define CFG1_RECVCOMPSTAT3	0x0800
908c2ecf20Sopenharmony_ci#define CFG1_RECVCOMPSTAT4	0x1000
918c2ecf20Sopenharmony_ci#define CFG1_RECVCOMPSTAT5	0x2000
928c2ecf20Sopenharmony_ci
938c2ecf20Sopenharmony_ci/* configuration register 2 */
948c2ecf20Sopenharmony_ci#define REG_CONFIG2		(priv(dev)->seeq + 0x0080)
958c2ecf20Sopenharmony_ci#define CFG2_BYTESWAP		0x0001
968c2ecf20Sopenharmony_ci#define CFG2_ERRENCRC		0x0008
978c2ecf20Sopenharmony_ci#define CFG2_ERRENDRIBBLE	0x0010
988c2ecf20Sopenharmony_ci#define CFG2_ERRSHORTFRAME	0x0020
998c2ecf20Sopenharmony_ci#define CFG2_SLOTSELECT		0x0040
1008c2ecf20Sopenharmony_ci#define CFG2_PREAMSELECT	0x0080
1018c2ecf20Sopenharmony_ci#define CFG2_ADDRLENGTH		0x0100
1028c2ecf20Sopenharmony_ci#define CFG2_RECVCRC		0x0200
1038c2ecf20Sopenharmony_ci#define CFG2_XMITNOCRC		0x0400
1048c2ecf20Sopenharmony_ci#define CFG2_LOOPBACK		0x0800
1058c2ecf20Sopenharmony_ci#define CFG2_CTRLO		0x1000
1068c2ecf20Sopenharmony_ci#define CFG2_RESET		0x8000
1078c2ecf20Sopenharmony_ci
1088c2ecf20Sopenharmony_ci#define REG_RECVEND		(priv(dev)->seeq + 0x00c0)
1098c2ecf20Sopenharmony_ci
1108c2ecf20Sopenharmony_ci#define REG_BUFWIN		(priv(dev)->seeq + 0x0100)
1118c2ecf20Sopenharmony_ci
1128c2ecf20Sopenharmony_ci#define REG_RECVPTR		(priv(dev)->seeq + 0x0140)
1138c2ecf20Sopenharmony_ci
1148c2ecf20Sopenharmony_ci#define REG_TRANSMITPTR		(priv(dev)->seeq + 0x0180)
1158c2ecf20Sopenharmony_ci
1168c2ecf20Sopenharmony_ci#define REG_DMAADDR		(priv(dev)->seeq + 0x01c0)
1178c2ecf20Sopenharmony_ci
1188c2ecf20Sopenharmony_ci/*
1198c2ecf20Sopenharmony_ci * Cards transmit/receive headers
1208c2ecf20Sopenharmony_ci */
1218c2ecf20Sopenharmony_ci#define TX_NEXT			(0xffff)
1228c2ecf20Sopenharmony_ci#define TXHDR_ENBABBLEINT	(1 << 16)
1238c2ecf20Sopenharmony_ci#define TXHDR_ENCOLLISIONINT	(1 << 17)
1248c2ecf20Sopenharmony_ci#define TXHDR_EN16COLLISION	(1 << 18)
1258c2ecf20Sopenharmony_ci#define TXHDR_ENSUCCESS		(1 << 19)
1268c2ecf20Sopenharmony_ci#define TXHDR_DATAFOLLOWS	(1 << 21)
1278c2ecf20Sopenharmony_ci#define TXHDR_CHAINCONTINUE	(1 << 22)
1288c2ecf20Sopenharmony_ci#define TXHDR_TRANSMIT		(1 << 23)
1298c2ecf20Sopenharmony_ci#define TXSTAT_BABBLED		(1 << 24)
1308c2ecf20Sopenharmony_ci#define TXSTAT_COLLISION	(1 << 25)
1318c2ecf20Sopenharmony_ci#define TXSTAT_16COLLISIONS	(1 << 26)
1328c2ecf20Sopenharmony_ci#define TXSTAT_DONE		(1 << 31)
1338c2ecf20Sopenharmony_ci
1348c2ecf20Sopenharmony_ci#define RX_NEXT			(0xffff)
1358c2ecf20Sopenharmony_ci#define RXHDR_CHAINCONTINUE	(1 << 6)
1368c2ecf20Sopenharmony_ci#define RXHDR_RECEIVE		(1 << 7)
1378c2ecf20Sopenharmony_ci#define RXSTAT_OVERSIZE		(1 << 8)
1388c2ecf20Sopenharmony_ci#define RXSTAT_CRCERROR		(1 << 9)
1398c2ecf20Sopenharmony_ci#define RXSTAT_DRIBBLEERROR	(1 << 10)
1408c2ecf20Sopenharmony_ci#define RXSTAT_SHORTPACKET	(1 << 11)
1418c2ecf20Sopenharmony_ci#define RXSTAT_DONE		(1 << 15)
1428c2ecf20Sopenharmony_ci
1438c2ecf20Sopenharmony_ci
1448c2ecf20Sopenharmony_ci#define TX_START	0x0000
1458c2ecf20Sopenharmony_ci#define TX_END		0x6000
1468c2ecf20Sopenharmony_ci#define RX_START	0x6000
1478c2ecf20Sopenharmony_ci#define RX_LEN		0xA000
1488c2ecf20Sopenharmony_ci#define RX_END		0x10000
1498c2ecf20Sopenharmony_ci/* must be a power of 2 and greater than MAX_TX_BUFFERED */
1508c2ecf20Sopenharmony_ci#define MAX_TXED	16
1518c2ecf20Sopenharmony_ci#define MAX_TX_BUFFERED	10
1528c2ecf20Sopenharmony_ci
1538c2ecf20Sopenharmony_cistruct dev_priv {
1548c2ecf20Sopenharmony_ci    void __iomem *base;
1558c2ecf20Sopenharmony_ci    void __iomem *seeq;
1568c2ecf20Sopenharmony_ci    struct {
1578c2ecf20Sopenharmony_ci	unsigned int command;
1588c2ecf20Sopenharmony_ci	unsigned int config1;
1598c2ecf20Sopenharmony_ci	unsigned int config2;
1608c2ecf20Sopenharmony_ci    } regs;
1618c2ecf20Sopenharmony_ci    unsigned char tx_head;		/* buffer nr to insert next packet	 */
1628c2ecf20Sopenharmony_ci    unsigned char tx_tail;		/* buffer nr of transmitting packet	 */
1638c2ecf20Sopenharmony_ci    unsigned int rx_head;		/* address to fetch next packet from	 */
1648c2ecf20Sopenharmony_ci    struct timer_list timer;
1658c2ecf20Sopenharmony_ci    struct net_device *dev;
1668c2ecf20Sopenharmony_ci    int broken;				/* 0 = ok, 1 = something went wrong	 */
1678c2ecf20Sopenharmony_ci};
1688c2ecf20Sopenharmony_ci
1698c2ecf20Sopenharmony_cistruct ether3_data {
1708c2ecf20Sopenharmony_ci	const char name[8];
1718c2ecf20Sopenharmony_ci	unsigned long base_offset;
1728c2ecf20Sopenharmony_ci};
1738c2ecf20Sopenharmony_ci
1748c2ecf20Sopenharmony_ci#endif
175