xref: /openbmc/linux/drivers/net/arcnet/com20020.h (revision 26c6d281)
126c6d281SJoe Perches /*
226c6d281SJoe Perches  * Linux ARCnet driver - COM20020 chipset support - function declarations
326c6d281SJoe Perches  *
426c6d281SJoe Perches  * Written 1997 by David Woodhouse.
526c6d281SJoe Perches  * Written 1994-1999 by Avery Pennarun.
626c6d281SJoe Perches  * Derived from skeleton.c by Donald Becker.
726c6d281SJoe Perches  *
826c6d281SJoe Perches  * Special thanks to Contemporary Controls, Inc. (www.ccontrols.com)
926c6d281SJoe Perches  *  for sponsoring the further development of this driver.
1026c6d281SJoe Perches  *
1126c6d281SJoe Perches  * **********************
1226c6d281SJoe Perches  *
1326c6d281SJoe Perches  * The original copyright of skeleton.c was as follows:
1426c6d281SJoe Perches  *
1526c6d281SJoe Perches  * skeleton.c Written 1993 by Donald Becker.
1626c6d281SJoe Perches  * Copyright 1993 United States Government as represented by the
1726c6d281SJoe Perches  * Director, National Security Agency.  This software may only be used
1826c6d281SJoe Perches  * and distributed according to the terms of the GNU General Public License as
1926c6d281SJoe Perches  * modified by SRC, incorporated herein by reference.
2026c6d281SJoe Perches  *
2126c6d281SJoe Perches  * **********************
2226c6d281SJoe Perches  *
2326c6d281SJoe Perches  * For more details, see drivers/net/arcnet.c
2426c6d281SJoe Perches  *
2526c6d281SJoe Perches  * **********************
2626c6d281SJoe Perches  */
2726c6d281SJoe Perches #ifndef __COM20020_H
2826c6d281SJoe Perches #define __COM20020_H
2926c6d281SJoe Perches 
3026c6d281SJoe Perches int com20020_check(struct net_device *dev);
3126c6d281SJoe Perches int com20020_found(struct net_device *dev, int shared);
3226c6d281SJoe Perches extern const struct net_device_ops com20020_netdev_ops;
3326c6d281SJoe Perches 
3426c6d281SJoe Perches /* The number of low I/O ports used by the card. */
3526c6d281SJoe Perches #define ARCNET_TOTAL_SIZE 8
3626c6d281SJoe Perches 
3726c6d281SJoe Perches /* various register addresses */
3826c6d281SJoe Perches #ifdef CONFIG_SA1100_CT6001
3926c6d281SJoe Perches #define BUS_ALIGN  2  /* 8 bit device on a 16 bit bus - needs padding */
4026c6d281SJoe Perches #else
4126c6d281SJoe Perches #define BUS_ALIGN  1
4226c6d281SJoe Perches #endif
4326c6d281SJoe Perches 
4426c6d281SJoe Perches #define PLX_PCI_MAX_CARDS 2
4526c6d281SJoe Perches 
4626c6d281SJoe Perches struct com20020_pci_channel_map {
4726c6d281SJoe Perches 	u32 bar;
4826c6d281SJoe Perches 	u32 offset;
4926c6d281SJoe Perches 	u32 size;               /* 0x00 - auto, e.g. length of entire bar */
5026c6d281SJoe Perches };
5126c6d281SJoe Perches 
5226c6d281SJoe Perches struct com20020_pci_card_info {
5326c6d281SJoe Perches 	const char *name;
5426c6d281SJoe Perches 	int devcount;
5526c6d281SJoe Perches 
5626c6d281SJoe Perches 	struct com20020_pci_channel_map chan_map_tbl[PLX_PCI_MAX_CARDS];
5726c6d281SJoe Perches 
5826c6d281SJoe Perches 	unsigned int flags;
5926c6d281SJoe Perches };
6026c6d281SJoe Perches 
6126c6d281SJoe Perches struct com20020_priv {
6226c6d281SJoe Perches 	struct com20020_pci_card_info *ci;
6326c6d281SJoe Perches 	struct list_head list_dev;
6426c6d281SJoe Perches };
6526c6d281SJoe Perches 
6626c6d281SJoe Perches struct com20020_dev {
6726c6d281SJoe Perches 	struct list_head list;
6826c6d281SJoe Perches 	struct net_device *dev;
6926c6d281SJoe Perches 
7026c6d281SJoe Perches 	struct com20020_priv *pci_priv;
7126c6d281SJoe Perches 	int index;
7226c6d281SJoe Perches };
7326c6d281SJoe Perches 
7426c6d281SJoe Perches #define _INTMASK  (ioaddr+BUS_ALIGN*0)	/* writable */
7526c6d281SJoe Perches #define _STATUS   (ioaddr+BUS_ALIGN*0)	/* readable */
7626c6d281SJoe Perches #define _COMMAND  (ioaddr+BUS_ALIGN*1)	/* standard arcnet commands */
7726c6d281SJoe Perches #define _DIAGSTAT (ioaddr+BUS_ALIGN*1)	/* diagnostic status register */
7826c6d281SJoe Perches #define _ADDR_HI  (ioaddr+BUS_ALIGN*2)	/* control registers for IO-mapped memory */
7926c6d281SJoe Perches #define _ADDR_LO  (ioaddr+BUS_ALIGN*3)
8026c6d281SJoe Perches #define _MEMDATA  (ioaddr+BUS_ALIGN*4)	/* data port for IO-mapped memory */
8126c6d281SJoe Perches #define _SUBADR   (ioaddr+BUS_ALIGN*5)	/* the extended port _XREG refers to */
8226c6d281SJoe Perches #define _CONFIG   (ioaddr+BUS_ALIGN*6)	/* configuration register */
8326c6d281SJoe Perches #define _XREG     (ioaddr+BUS_ALIGN*7)	/* extra registers (indexed by _CONFIG
8426c6d281SJoe Perches   					or _SUBADR) */
8526c6d281SJoe Perches 
8626c6d281SJoe Perches /* in the ADDR_HI register */
8726c6d281SJoe Perches #define RDDATAflag	0x80	/* next access is a read (not a write) */
8826c6d281SJoe Perches 
8926c6d281SJoe Perches /* in the DIAGSTAT register */
9026c6d281SJoe Perches #define NEWNXTIDflag	0x02	/* ID to which token is passed has changed */
9126c6d281SJoe Perches 
9226c6d281SJoe Perches /* in the CONFIG register */
9326c6d281SJoe Perches #define RESETcfg	0x80	/* put card in reset state */
9426c6d281SJoe Perches #define TXENcfg		0x20	/* enable TX */
9526c6d281SJoe Perches 
9626c6d281SJoe Perches /* in SETUP register */
9726c6d281SJoe Perches #define PROMISCset	0x10	/* enable RCV_ALL */
9826c6d281SJoe Perches #define P1MODE		0x80    /* enable P1-MODE for Backplane */
9926c6d281SJoe Perches #define SLOWARB		0x01    /* enable Slow Arbitration for >=5Mbps */
10026c6d281SJoe Perches 
10126c6d281SJoe Perches /* COM2002x */
10226c6d281SJoe Perches #define SUB_TENTATIVE	0	/* tentative node ID */
10326c6d281SJoe Perches #define SUB_NODE	1	/* node ID */
10426c6d281SJoe Perches #define SUB_SETUP1	2	/* various options */
10526c6d281SJoe Perches #define SUB_TEST	3	/* test/diag register */
10626c6d281SJoe Perches 
10726c6d281SJoe Perches /* COM20022 only */
10826c6d281SJoe Perches #define SUB_SETUP2	4	/* sundry options */
10926c6d281SJoe Perches #define SUB_BUSCTL	5	/* bus control options */
11026c6d281SJoe Perches #define SUB_DMACOUNT	6	/* DMA count options */
11126c6d281SJoe Perches 
11226c6d281SJoe Perches #define SET_SUBADR(x) do { \
11326c6d281SJoe Perches 	if ((x) < 4) \
11426c6d281SJoe Perches 	{ \
11526c6d281SJoe Perches 		lp->config = (lp->config & ~0x03) | (x); \
11626c6d281SJoe Perches 		SETCONF; \
11726c6d281SJoe Perches 	} \
11826c6d281SJoe Perches 	else \
11926c6d281SJoe Perches 	{ \
12026c6d281SJoe Perches 		outb(x, _SUBADR); \
12126c6d281SJoe Perches 	} \
12226c6d281SJoe Perches } while (0)
12326c6d281SJoe Perches 
12426c6d281SJoe Perches #undef ARCRESET
12526c6d281SJoe Perches #undef ASTATUS
12626c6d281SJoe Perches #undef ACOMMAND
12726c6d281SJoe Perches #undef AINTMASK
12826c6d281SJoe Perches 
12926c6d281SJoe Perches #define ARCRESET { outb(lp->config | 0x80, _CONFIG); \
13026c6d281SJoe Perches 		    udelay(5);                        \
13126c6d281SJoe Perches 		    outb(lp->config , _CONFIG);       \
13226c6d281SJoe Perches                   }
13326c6d281SJoe Perches #define ARCRESET0 { outb(0x18 | 0x80, _CONFIG);   \
13426c6d281SJoe Perches 		    udelay(5);                       \
13526c6d281SJoe Perches 		    outb(0x18 , _CONFIG);            \
13626c6d281SJoe Perches                   }
13726c6d281SJoe Perches 
13826c6d281SJoe Perches #define ASTATUS()	inb(_STATUS)
13926c6d281SJoe Perches #define ADIAGSTATUS()	inb(_DIAGSTAT)
14026c6d281SJoe Perches #define ACOMMAND(cmd)	outb((cmd),_COMMAND)
14126c6d281SJoe Perches #define AINTMASK(msk)	outb((msk),_INTMASK)
14226c6d281SJoe Perches 
14326c6d281SJoe Perches #define SETCONF		outb(lp->config, _CONFIG)
14426c6d281SJoe Perches 
14526c6d281SJoe Perches #endif /* __COM20020_H */
146