162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci *  linux/drivers/acorn/net/ether3.h
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci *  Copyright (C) 1995-2000 Russell King
662306a36Sopenharmony_ci *
762306a36Sopenharmony_ci *  network driver for Acorn/ANT Ether3 cards
862306a36Sopenharmony_ci */
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ci#ifndef _LINUX_ether3_H
1162306a36Sopenharmony_ci#define _LINUX_ether3_H
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ci/* use 0 for production, 1 for verification, >2 for debug. debug flags: */
1462306a36Sopenharmony_ci#define DEBUG_TX	 2
1562306a36Sopenharmony_ci#define DEBUG_RX	 4
1662306a36Sopenharmony_ci#define DEBUG_INT	 8
1762306a36Sopenharmony_ci#define DEBUG_IC	16
1862306a36Sopenharmony_ci#ifndef NET_DEBUG
1962306a36Sopenharmony_ci#define NET_DEBUG 	0
2062306a36Sopenharmony_ci#endif
2162306a36Sopenharmony_ci
2262306a36Sopenharmony_ci#define priv(dev)	((struct dev_priv *)netdev_priv(dev))
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_ci/* Command register definitions & bits */
2562306a36Sopenharmony_ci#define REG_COMMAND		(priv(dev)->seeq + 0x0000)
2662306a36Sopenharmony_ci#define CMD_ENINTDMA		0x0001
2762306a36Sopenharmony_ci#define CMD_ENINTRX		0x0002
2862306a36Sopenharmony_ci#define CMD_ENINTTX		0x0004
2962306a36Sopenharmony_ci#define CMD_ENINTBUFWIN		0x0008
3062306a36Sopenharmony_ci#define CMD_ACKINTDMA		0x0010
3162306a36Sopenharmony_ci#define CMD_ACKINTRX		0x0020
3262306a36Sopenharmony_ci#define CMD_ACKINTTX		0x0040
3362306a36Sopenharmony_ci#define CMD_ACKINTBUFWIN	0x0080
3462306a36Sopenharmony_ci#define CMD_DMAON		0x0100
3562306a36Sopenharmony_ci#define CMD_RXON		0x0200
3662306a36Sopenharmony_ci#define CMD_TXON		0x0400
3762306a36Sopenharmony_ci#define CMD_DMAOFF		0x0800
3862306a36Sopenharmony_ci#define CMD_RXOFF		0x1000
3962306a36Sopenharmony_ci#define CMD_TXOFF		0x2000
4062306a36Sopenharmony_ci#define CMD_FIFOREAD		0x4000
4162306a36Sopenharmony_ci#define CMD_FIFOWRITE		0x8000
4262306a36Sopenharmony_ci
4362306a36Sopenharmony_ci/* status register */
4462306a36Sopenharmony_ci#define REG_STATUS		(priv(dev)->seeq + 0x0000)
4562306a36Sopenharmony_ci#define STAT_ENINTSTAT		0x0001
4662306a36Sopenharmony_ci#define STAT_ENINTRX		0x0002
4762306a36Sopenharmony_ci#define STAT_ENINTTX		0x0004
4862306a36Sopenharmony_ci#define STAT_ENINTBUFWIN	0x0008
4962306a36Sopenharmony_ci#define STAT_INTDMA		0x0010
5062306a36Sopenharmony_ci#define STAT_INTRX		0x0020
5162306a36Sopenharmony_ci#define STAT_INTTX		0x0040
5262306a36Sopenharmony_ci#define STAT_INTBUFWIN		0x0080
5362306a36Sopenharmony_ci#define STAT_DMAON		0x0100
5462306a36Sopenharmony_ci#define STAT_RXON		0x0200
5562306a36Sopenharmony_ci#define STAT_TXON		0x0400
5662306a36Sopenharmony_ci#define STAT_FIFOFULL		0x2000
5762306a36Sopenharmony_ci#define STAT_FIFOEMPTY		0x4000
5862306a36Sopenharmony_ci#define STAT_FIFODIR		0x8000
5962306a36Sopenharmony_ci
6062306a36Sopenharmony_ci/* configuration register 1 */
6162306a36Sopenharmony_ci#define REG_CONFIG1		(priv(dev)->seeq + 0x0040)
6262306a36Sopenharmony_ci#define CFG1_BUFSELSTAT0	0x0000
6362306a36Sopenharmony_ci#define CFG1_BUFSELSTAT1	0x0001
6462306a36Sopenharmony_ci#define CFG1_BUFSELSTAT2	0x0002
6562306a36Sopenharmony_ci#define CFG1_BUFSELSTAT3	0x0003
6662306a36Sopenharmony_ci#define CFG1_BUFSELSTAT4	0x0004
6762306a36Sopenharmony_ci#define CFG1_BUFSELSTAT5	0x0005
6862306a36Sopenharmony_ci#define CFG1_ADDRPROM		0x0006
6962306a36Sopenharmony_ci#define CFG1_TRANSEND		0x0007
7062306a36Sopenharmony_ci#define CFG1_LOCBUFMEM		0x0008
7162306a36Sopenharmony_ci#define CFG1_INTVECTOR		0x0009
7262306a36Sopenharmony_ci#define CFG1_RECVSPECONLY	0x0000
7362306a36Sopenharmony_ci#define CFG1_RECVSPECBROAD	0x4000
7462306a36Sopenharmony_ci#define CFG1_RECVSPECBRMULTI	0x8000
7562306a36Sopenharmony_ci#define CFG1_RECVPROMISC	0xC000
7662306a36Sopenharmony_ci
7762306a36Sopenharmony_ci/* The following aren't in 8004 */
7862306a36Sopenharmony_ci#define CFG1_DMABURSTCONT	0x0000
7962306a36Sopenharmony_ci#define CFG1_DMABURST800NS	0x0010
8062306a36Sopenharmony_ci#define CFG1_DMABURST1600NS	0x0020
8162306a36Sopenharmony_ci#define CFG1_DMABURST3200NS	0x0030
8262306a36Sopenharmony_ci#define CFG1_DMABURST1		0x0000
8362306a36Sopenharmony_ci#define CFG1_DMABURST4		0x0040
8462306a36Sopenharmony_ci#define CFG1_DMABURST8		0x0080
8562306a36Sopenharmony_ci#define CFG1_DMABURST16		0x00C0
8662306a36Sopenharmony_ci#define CFG1_RECVCOMPSTAT0	0x0100
8762306a36Sopenharmony_ci#define CFG1_RECVCOMPSTAT1	0x0200
8862306a36Sopenharmony_ci#define CFG1_RECVCOMPSTAT2	0x0400
8962306a36Sopenharmony_ci#define CFG1_RECVCOMPSTAT3	0x0800
9062306a36Sopenharmony_ci#define CFG1_RECVCOMPSTAT4	0x1000
9162306a36Sopenharmony_ci#define CFG1_RECVCOMPSTAT5	0x2000
9262306a36Sopenharmony_ci
9362306a36Sopenharmony_ci/* configuration register 2 */
9462306a36Sopenharmony_ci#define REG_CONFIG2		(priv(dev)->seeq + 0x0080)
9562306a36Sopenharmony_ci#define CFG2_BYTESWAP		0x0001
9662306a36Sopenharmony_ci#define CFG2_ERRENCRC		0x0008
9762306a36Sopenharmony_ci#define CFG2_ERRENDRIBBLE	0x0010
9862306a36Sopenharmony_ci#define CFG2_ERRSHORTFRAME	0x0020
9962306a36Sopenharmony_ci#define CFG2_SLOTSELECT		0x0040
10062306a36Sopenharmony_ci#define CFG2_PREAMSELECT	0x0080
10162306a36Sopenharmony_ci#define CFG2_ADDRLENGTH		0x0100
10262306a36Sopenharmony_ci#define CFG2_RECVCRC		0x0200
10362306a36Sopenharmony_ci#define CFG2_XMITNOCRC		0x0400
10462306a36Sopenharmony_ci#define CFG2_LOOPBACK		0x0800
10562306a36Sopenharmony_ci#define CFG2_CTRLO		0x1000
10662306a36Sopenharmony_ci#define CFG2_RESET		0x8000
10762306a36Sopenharmony_ci
10862306a36Sopenharmony_ci#define REG_RECVEND		(priv(dev)->seeq + 0x00c0)
10962306a36Sopenharmony_ci
11062306a36Sopenharmony_ci#define REG_BUFWIN		(priv(dev)->seeq + 0x0100)
11162306a36Sopenharmony_ci
11262306a36Sopenharmony_ci#define REG_RECVPTR		(priv(dev)->seeq + 0x0140)
11362306a36Sopenharmony_ci
11462306a36Sopenharmony_ci#define REG_TRANSMITPTR		(priv(dev)->seeq + 0x0180)
11562306a36Sopenharmony_ci
11662306a36Sopenharmony_ci#define REG_DMAADDR		(priv(dev)->seeq + 0x01c0)
11762306a36Sopenharmony_ci
11862306a36Sopenharmony_ci/*
11962306a36Sopenharmony_ci * Cards transmit/receive headers
12062306a36Sopenharmony_ci */
12162306a36Sopenharmony_ci#define TX_NEXT			(0xffff)
12262306a36Sopenharmony_ci#define TXHDR_ENBABBLEINT	(1 << 16)
12362306a36Sopenharmony_ci#define TXHDR_ENCOLLISIONINT	(1 << 17)
12462306a36Sopenharmony_ci#define TXHDR_EN16COLLISION	(1 << 18)
12562306a36Sopenharmony_ci#define TXHDR_ENSUCCESS		(1 << 19)
12662306a36Sopenharmony_ci#define TXHDR_DATAFOLLOWS	(1 << 21)
12762306a36Sopenharmony_ci#define TXHDR_CHAINCONTINUE	(1 << 22)
12862306a36Sopenharmony_ci#define TXHDR_TRANSMIT		(1 << 23)
12962306a36Sopenharmony_ci#define TXSTAT_BABBLED		(1 << 24)
13062306a36Sopenharmony_ci#define TXSTAT_COLLISION	(1 << 25)
13162306a36Sopenharmony_ci#define TXSTAT_16COLLISIONS	(1 << 26)
13262306a36Sopenharmony_ci#define TXSTAT_DONE		(1 << 31)
13362306a36Sopenharmony_ci
13462306a36Sopenharmony_ci#define RX_NEXT			(0xffff)
13562306a36Sopenharmony_ci#define RXHDR_CHAINCONTINUE	(1 << 6)
13662306a36Sopenharmony_ci#define RXHDR_RECEIVE		(1 << 7)
13762306a36Sopenharmony_ci#define RXSTAT_OVERSIZE		(1 << 8)
13862306a36Sopenharmony_ci#define RXSTAT_CRCERROR		(1 << 9)
13962306a36Sopenharmony_ci#define RXSTAT_DRIBBLEERROR	(1 << 10)
14062306a36Sopenharmony_ci#define RXSTAT_SHORTPACKET	(1 << 11)
14162306a36Sopenharmony_ci#define RXSTAT_DONE		(1 << 15)
14262306a36Sopenharmony_ci
14362306a36Sopenharmony_ci
14462306a36Sopenharmony_ci#define TX_START	0x0000
14562306a36Sopenharmony_ci#define TX_END		0x6000
14662306a36Sopenharmony_ci#define RX_START	0x6000
14762306a36Sopenharmony_ci#define RX_LEN		0xA000
14862306a36Sopenharmony_ci#define RX_END		0x10000
14962306a36Sopenharmony_ci/* must be a power of 2 and greater than MAX_TX_BUFFERED */
15062306a36Sopenharmony_ci#define MAX_TXED	16
15162306a36Sopenharmony_ci#define MAX_TX_BUFFERED	10
15262306a36Sopenharmony_ci
15362306a36Sopenharmony_cistruct dev_priv {
15462306a36Sopenharmony_ci    void __iomem *base;
15562306a36Sopenharmony_ci    void __iomem *seeq;
15662306a36Sopenharmony_ci    struct {
15762306a36Sopenharmony_ci	unsigned int command;
15862306a36Sopenharmony_ci	unsigned int config1;
15962306a36Sopenharmony_ci	unsigned int config2;
16062306a36Sopenharmony_ci    } regs;
16162306a36Sopenharmony_ci    unsigned char tx_head;		/* buffer nr to insert next packet	 */
16262306a36Sopenharmony_ci    unsigned char tx_tail;		/* buffer nr of transmitting packet	 */
16362306a36Sopenharmony_ci    unsigned int rx_head;		/* address to fetch next packet from	 */
16462306a36Sopenharmony_ci    struct timer_list timer;
16562306a36Sopenharmony_ci    struct net_device *dev;
16662306a36Sopenharmony_ci    int broken;				/* 0 = ok, 1 = something went wrong	 */
16762306a36Sopenharmony_ci};
16862306a36Sopenharmony_ci
16962306a36Sopenharmony_cistruct ether3_data {
17062306a36Sopenharmony_ci	const char name[8];
17162306a36Sopenharmony_ci	unsigned long base_offset;
17262306a36Sopenharmony_ci};
17362306a36Sopenharmony_ci
17462306a36Sopenharmony_ci#endif
175