xref: /openbmc/linux/drivers/net/arcnet/com20020.h (revision 5ef216c1)
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 #define PLX_PCI_MAX_CARDS 2
3826c6d281SJoe Perches 
3926c6d281SJoe Perches struct com20020_pci_channel_map {
4026c6d281SJoe Perches 	u32 bar;
4126c6d281SJoe Perches 	u32 offset;
4226c6d281SJoe Perches 	u32 size;               /* 0x00 - auto, e.g. length of entire bar */
4326c6d281SJoe Perches };
4426c6d281SJoe Perches 
4526c6d281SJoe Perches struct com20020_pci_card_info {
4626c6d281SJoe Perches 	const char *name;
4726c6d281SJoe Perches 	int devcount;
4826c6d281SJoe Perches 
4926c6d281SJoe Perches 	struct com20020_pci_channel_map chan_map_tbl[PLX_PCI_MAX_CARDS];
505ef216c1SMichael Grzeschik 	struct com20020_pci_channel_map misc_map;
515ef216c1SMichael Grzeschik 
525ef216c1SMichael Grzeschik 	int rotary;
5326c6d281SJoe Perches 
5426c6d281SJoe Perches 	unsigned int flags;
5526c6d281SJoe Perches };
5626c6d281SJoe Perches 
5726c6d281SJoe Perches struct com20020_priv {
5826c6d281SJoe Perches 	struct com20020_pci_card_info *ci;
5926c6d281SJoe Perches 	struct list_head list_dev;
605ef216c1SMichael Grzeschik 	resource_size_t misc;
6126c6d281SJoe Perches };
6226c6d281SJoe Perches 
6326c6d281SJoe Perches struct com20020_dev {
6426c6d281SJoe Perches 	struct list_head list;
6526c6d281SJoe Perches 	struct net_device *dev;
6626c6d281SJoe Perches 
6726c6d281SJoe Perches 	struct com20020_priv *pci_priv;
6826c6d281SJoe Perches 	int index;
6926c6d281SJoe Perches };
7026c6d281SJoe Perches 
710fec6513SJoe Perches #define COM20020_REG_W_INTMASK	0	/* writable */
720fec6513SJoe Perches #define COM20020_REG_R_STATUS	0	/* readable */
730fec6513SJoe Perches #define COM20020_REG_W_COMMAND	1	/* standard arcnet commands */
740fec6513SJoe Perches #define COM20020_REG_R_DIAGSTAT	1	/* diagnostic status */
750fec6513SJoe Perches #define COM20020_REG_W_ADDR_HI	2	/* control for IO-mapped memory */
760fec6513SJoe Perches #define COM20020_REG_W_ADDR_LO	3
770fec6513SJoe Perches #define COM20020_REG_RW_MEMDATA	4	/* data port for IO-mapped memory */
780fec6513SJoe Perches #define COM20020_REG_W_SUBADR	5	/* the extended port _XREG refers to */
790fec6513SJoe Perches #define COM20020_REG_W_CONFIG	6	/* configuration */
800fec6513SJoe Perches #define COM20020_REG_W_XREG	7	/* extra
810fec6513SJoe Perches 					 * (indexed by _CONFIG or _SUBADDR)
820fec6513SJoe Perches 					 */
8326c6d281SJoe Perches 
8426c6d281SJoe Perches /* in the ADDR_HI register */
8526c6d281SJoe Perches #define RDDATAflag	0x80	/* next access is a read (not a write) */
8626c6d281SJoe Perches 
8726c6d281SJoe Perches /* in the DIAGSTAT register */
8826c6d281SJoe Perches #define NEWNXTIDflag	0x02	/* ID to which token is passed has changed */
8926c6d281SJoe Perches 
9026c6d281SJoe Perches /* in the CONFIG register */
9126c6d281SJoe Perches #define RESETcfg	0x80	/* put card in reset state */
9226c6d281SJoe Perches #define TXENcfg		0x20	/* enable TX */
9384286f19SMichael Grzeschik #define XTOcfg(x)	((x) << 3)	/* extended timeout */
9426c6d281SJoe Perches 
9526c6d281SJoe Perches /* in SETUP register */
9626c6d281SJoe Perches #define PROMISCset	0x10	/* enable RCV_ALL */
9726c6d281SJoe Perches #define P1MODE		0x80    /* enable P1-MODE for Backplane */
9826c6d281SJoe Perches #define SLOWARB		0x01    /* enable Slow Arbitration for >=5Mbps */
9926c6d281SJoe Perches 
10026c6d281SJoe Perches /* COM2002x */
10126c6d281SJoe Perches #define SUB_TENTATIVE	0	/* tentative node ID */
10226c6d281SJoe Perches #define SUB_NODE	1	/* node ID */
10326c6d281SJoe Perches #define SUB_SETUP1	2	/* various options */
10426c6d281SJoe Perches #define SUB_TEST	3	/* test/diag register */
10526c6d281SJoe Perches 
10626c6d281SJoe Perches /* COM20022 only */
10726c6d281SJoe Perches #define SUB_SETUP2	4	/* sundry options */
10826c6d281SJoe Perches #define SUB_BUSCTL	5	/* bus control options */
10926c6d281SJoe Perches #define SUB_DMACOUNT	6	/* DMA count options */
11026c6d281SJoe Perches 
1110fec6513SJoe Perches static inline void com20020_set_subaddress(struct arcnet_local *lp,
1120fec6513SJoe Perches 					   int ioaddr, int val)
1130fec6513SJoe Perches {
1140fec6513SJoe Perches 	if (val < 4) {
1150fec6513SJoe Perches 		lp->config = (lp->config & ~0x03) | val;
1160fec6513SJoe Perches 		arcnet_outb(lp->config, ioaddr, COM20020_REG_W_CONFIG);
1170fec6513SJoe Perches 	} else {
1180fec6513SJoe Perches 		arcnet_outb(val, ioaddr, COM20020_REG_W_SUBADR);
11926c6d281SJoe Perches 	}
12026c6d281SJoe Perches }
12126c6d281SJoe Perches 
12226c6d281SJoe Perches #endif /* __COM20020_H */
123