Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Linux ARCnet driver - COM20020 chipset support - function declarations |
Joe Perches | 0fec651 | 2015-05-05 10:06:06 -0700 | [diff] [blame] | 3 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | * Written 1997 by David Woodhouse. |
| 5 | * Written 1994-1999 by Avery Pennarun. |
| 6 | * Derived from skeleton.c by Donald Becker. |
| 7 | * |
| 8 | * Special thanks to Contemporary Controls, Inc. (www.ccontrols.com) |
| 9 | * for sponsoring the further development of this driver. |
| 10 | * |
| 11 | * ********************** |
| 12 | * |
| 13 | * The original copyright of skeleton.c was as follows: |
| 14 | * |
| 15 | * skeleton.c Written 1993 by Donald Becker. |
| 16 | * Copyright 1993 United States Government as represented by the |
| 17 | * Director, National Security Agency. This software may only be used |
| 18 | * and distributed according to the terms of the GNU General Public License as |
| 19 | * modified by SRC, incorporated herein by reference. |
| 20 | * |
| 21 | * ********************** |
| 22 | * |
| 23 | * For more details, see drivers/net/arcnet.c |
| 24 | * |
| 25 | * ********************** |
| 26 | */ |
| 27 | #ifndef __COM20020_H |
| 28 | #define __COM20020_H |
Michael Grzeschik | 8890624 | 2014-09-18 00:12:50 +0200 | [diff] [blame] | 29 | #include <linux/leds.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | |
| 31 | int com20020_check(struct net_device *dev); |
| 32 | int com20020_found(struct net_device *dev, int shared); |
David S. Miller | 0db155d | 2009-01-23 22:28:48 -0800 | [diff] [blame] | 33 | extern const struct net_device_ops com20020_netdev_ops; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | |
| 35 | /* The number of low I/O ports used by the card. */ |
| 36 | #define ARCNET_TOTAL_SIZE 8 |
| 37 | |
Michael Grzeschik | c51da42 | 2014-09-29 11:55:37 +0200 | [diff] [blame] | 38 | #define PLX_PCI_MAX_CARDS 2 |
Michael Grzeschik | 8c14f9c | 2014-09-29 11:55:36 +0200 | [diff] [blame] | 39 | |
Michael Grzeschik | 8890624 | 2014-09-18 00:12:50 +0200 | [diff] [blame] | 40 | struct ledoffsets { |
| 41 | int green; |
| 42 | int red; |
| 43 | }; |
| 44 | |
Michael Grzeschik | 8c14f9c | 2014-09-29 11:55:36 +0200 | [diff] [blame] | 45 | struct com20020_pci_channel_map { |
| 46 | u32 bar; |
| 47 | u32 offset; |
| 48 | u32 size; /* 0x00 - auto, e.g. length of entire bar */ |
| 49 | }; |
| 50 | |
| 51 | struct com20020_pci_card_info { |
| 52 | const char *name; |
| 53 | int devcount; |
| 54 | |
| 55 | struct com20020_pci_channel_map chan_map_tbl[PLX_PCI_MAX_CARDS]; |
Michael Grzeschik | 5ef216c | 2014-09-18 00:12:50 +0200 | [diff] [blame] | 56 | struct com20020_pci_channel_map misc_map; |
| 57 | |
Michael Grzeschik | 8890624 | 2014-09-18 00:12:50 +0200 | [diff] [blame] | 58 | struct ledoffsets leds[PLX_PCI_MAX_CARDS]; |
Michael Grzeschik | 5ef216c | 2014-09-18 00:12:50 +0200 | [diff] [blame] | 59 | int rotary; |
Michael Grzeschik | 8c14f9c | 2014-09-29 11:55:36 +0200 | [diff] [blame] | 60 | |
| 61 | unsigned int flags; |
| 62 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | |
Michael Grzeschik | c51da42 | 2014-09-29 11:55:37 +0200 | [diff] [blame] | 64 | struct com20020_priv { |
| 65 | struct com20020_pci_card_info *ci; |
| 66 | struct list_head list_dev; |
Michael Grzeschik | 5ef216c | 2014-09-18 00:12:50 +0200 | [diff] [blame] | 67 | resource_size_t misc; |
Michael Grzeschik | c51da42 | 2014-09-29 11:55:37 +0200 | [diff] [blame] | 68 | }; |
| 69 | |
| 70 | struct com20020_dev { |
| 71 | struct list_head list; |
| 72 | struct net_device *dev; |
| 73 | |
Michael Grzeschik | 8890624 | 2014-09-18 00:12:50 +0200 | [diff] [blame] | 74 | struct led_classdev tx_led; |
| 75 | struct led_classdev recon_led; |
| 76 | |
Michael Grzeschik | c51da42 | 2014-09-29 11:55:37 +0200 | [diff] [blame] | 77 | struct com20020_priv *pci_priv; |
| 78 | int index; |
| 79 | }; |
| 80 | |
Joe Perches | 0fec651 | 2015-05-05 10:06:06 -0700 | [diff] [blame] | 81 | #define COM20020_REG_W_INTMASK 0 /* writable */ |
| 82 | #define COM20020_REG_R_STATUS 0 /* readable */ |
| 83 | #define COM20020_REG_W_COMMAND 1 /* standard arcnet commands */ |
| 84 | #define COM20020_REG_R_DIAGSTAT 1 /* diagnostic status */ |
| 85 | #define COM20020_REG_W_ADDR_HI 2 /* control for IO-mapped memory */ |
| 86 | #define COM20020_REG_W_ADDR_LO 3 |
| 87 | #define COM20020_REG_RW_MEMDATA 4 /* data port for IO-mapped memory */ |
| 88 | #define COM20020_REG_W_SUBADR 5 /* the extended port _XREG refers to */ |
| 89 | #define COM20020_REG_W_CONFIG 6 /* configuration */ |
| 90 | #define COM20020_REG_W_XREG 7 /* extra |
| 91 | * (indexed by _CONFIG or _SUBADDR) |
| 92 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | |
| 94 | /* in the ADDR_HI register */ |
| 95 | #define RDDATAflag 0x80 /* next access is a read (not a write) */ |
| 96 | |
| 97 | /* in the DIAGSTAT register */ |
| 98 | #define NEWNXTIDflag 0x02 /* ID to which token is passed has changed */ |
| 99 | |
| 100 | /* in the CONFIG register */ |
| 101 | #define RESETcfg 0x80 /* put card in reset state */ |
| 102 | #define TXENcfg 0x20 /* enable TX */ |
Michael Grzeschik | 84286f1 | 2015-04-15 11:43:57 +0200 | [diff] [blame] | 103 | #define XTOcfg(x) ((x) << 3) /* extended timeout */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | |
| 105 | /* in SETUP register */ |
| 106 | #define PROMISCset 0x10 /* enable RCV_ALL */ |
| 107 | #define P1MODE 0x80 /* enable P1-MODE for Backplane */ |
| 108 | #define SLOWARB 0x01 /* enable Slow Arbitration for >=5Mbps */ |
| 109 | |
| 110 | /* COM2002x */ |
| 111 | #define SUB_TENTATIVE 0 /* tentative node ID */ |
| 112 | #define SUB_NODE 1 /* node ID */ |
| 113 | #define SUB_SETUP1 2 /* various options */ |
| 114 | #define SUB_TEST 3 /* test/diag register */ |
| 115 | |
| 116 | /* COM20022 only */ |
| 117 | #define SUB_SETUP2 4 /* sundry options */ |
| 118 | #define SUB_BUSCTL 5 /* bus control options */ |
| 119 | #define SUB_DMACOUNT 6 /* DMA count options */ |
| 120 | |
Joe Perches | 0fec651 | 2015-05-05 10:06:06 -0700 | [diff] [blame] | 121 | static inline void com20020_set_subaddress(struct arcnet_local *lp, |
| 122 | int ioaddr, int val) |
| 123 | { |
| 124 | if (val < 4) { |
| 125 | lp->config = (lp->config & ~0x03) | val; |
| 126 | arcnet_outb(lp->config, ioaddr, COM20020_REG_W_CONFIG); |
| 127 | } else { |
| 128 | arcnet_outb(val, ioaddr, COM20020_REG_W_SUBADR); |
| 129 | } |
| 130 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 131 | |
| 132 | #endif /* __COM20020_H */ |