Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Linux ARCnet driver - COM20020 chipset support |
Joe Perches | cb33464 | 2015-05-05 10:05:47 -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 | * Written 1999 by Martin Mares <mj@ucw.cz>. |
| 7 | * Derived from skeleton.c by Donald Becker. |
| 8 | * |
| 9 | * Special thanks to Contemporary Controls, Inc. (www.ccontrols.com) |
| 10 | * for sponsoring the further development of this driver. |
| 11 | * |
| 12 | * ********************** |
| 13 | * |
| 14 | * The original copyright of skeleton.c was as follows: |
| 15 | * |
| 16 | * skeleton.c Written 1993 by Donald Becker. |
| 17 | * Copyright 1993 United States Government as represented by the |
| 18 | * Director, National Security Agency. This software may only be used |
| 19 | * and distributed according to the terms of the GNU General Public License as |
| 20 | * modified by SRC, incorporated herein by reference. |
| 21 | * |
| 22 | * ********************** |
| 23 | * |
| 24 | * For more details, see drivers/net/arcnet.c |
| 25 | * |
| 26 | * ********************** |
| 27 | */ |
Joe Perches | 05a24b2 | 2015-05-05 10:05:56 -0700 | [diff] [blame^] | 28 | |
| 29 | #define pr_fmt(fmt) "arcnet:" KBUILD_MODNAME ": " fmt |
| 30 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | #include <linux/module.h> |
| 32 | #include <linux/kernel.h> |
| 33 | #include <linux/types.h> |
| 34 | #include <linux/ioport.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | #include <linux/errno.h> |
| 36 | #include <linux/delay.h> |
| 37 | #include <linux/netdevice.h> |
| 38 | #include <linux/init.h> |
Alexey Dobriyan | a6b7a40 | 2011-06-06 10:43:46 +0000 | [diff] [blame] | 39 | #include <linux/interrupt.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | #include <linux/arcdevice.h> |
| 41 | #include <linux/com20020.h> |
| 42 | |
Joe Perches | 5e7ef91 | 2015-05-05 10:05:51 -0700 | [diff] [blame] | 43 | #include <linux/io.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | |
Joe Perches | 7f5e760 | 2015-05-05 10:05:49 -0700 | [diff] [blame] | 45 | static char *clockrates[] = { |
| 46 | "XXXXXXX", "XXXXXXXX", "XXXXXX", |
| 47 | "2.5 Mb/s", "1.25Mb/s", "625 Kb/s", "312.5 Kb/s", |
| 48 | "156.25 Kb/s", "Reserved", "Reserved", "Reserved" |
| 49 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | |
| 51 | static void com20020_command(struct net_device *dev, int command); |
| 52 | static int com20020_status(struct net_device *dev); |
| 53 | static void com20020_setmask(struct net_device *dev, int mask); |
| 54 | static int com20020_reset(struct net_device *dev, int really_reset); |
| 55 | static void com20020_copy_to_card(struct net_device *dev, int bufnum, |
| 56 | int offset, void *buf, int count); |
| 57 | static void com20020_copy_from_card(struct net_device *dev, int bufnum, |
| 58 | int offset, void *buf, int count); |
| 59 | static void com20020_set_mc_list(struct net_device *dev); |
| 60 | static void com20020_close(struct net_device *); |
| 61 | |
| 62 | static void com20020_copy_from_card(struct net_device *dev, int bufnum, |
| 63 | int offset, void *buf, int count) |
| 64 | { |
| 65 | int ioaddr = dev->base_addr, ofs = 512 * bufnum + offset; |
| 66 | |
| 67 | /* set up the address register */ |
| 68 | outb((ofs >> 8) | RDDATAflag | AUTOINCflag, _ADDR_HI); |
| 69 | outb(ofs & 0xff, _ADDR_LO); |
| 70 | |
| 71 | /* copy the data */ |
Joe Perches | a34c093 | 2015-05-05 10:05:55 -0700 | [diff] [blame] | 72 | TIME(dev, "insb", count, insb(_MEMDATA, buf, count)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | } |
| 74 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | static void com20020_copy_to_card(struct net_device *dev, int bufnum, |
| 76 | int offset, void *buf, int count) |
| 77 | { |
| 78 | int ioaddr = dev->base_addr, ofs = 512 * bufnum + offset; |
| 79 | |
| 80 | /* set up the address register */ |
| 81 | outb((ofs >> 8) | AUTOINCflag, _ADDR_HI); |
| 82 | outb(ofs & 0xff, _ADDR_LO); |
| 83 | |
| 84 | /* copy the data */ |
Joe Perches | a34c093 | 2015-05-05 10:05:55 -0700 | [diff] [blame] | 85 | TIME(dev, "outsb", count, outsb(_MEMDATA, buf, count)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | } |
| 87 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | /* Reset the card and check some basic stuff during the detection stage. */ |
| 89 | int com20020_check(struct net_device *dev) |
| 90 | { |
| 91 | int ioaddr = dev->base_addr, status; |
Wang Chen | 454d7c9 | 2008-11-12 23:37:49 -0800 | [diff] [blame] | 92 | struct arcnet_local *lp = netdev_priv(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | |
| 94 | ARCRESET0; |
| 95 | mdelay(RESETtime); |
| 96 | |
| 97 | lp->setup = lp->clockm ? 0 : (lp->clockp << 1); |
| 98 | lp->setup2 = (lp->clockm << 4) | 8; |
| 99 | |
| 100 | /* CHECK: should we do this for SOHARD cards ? */ |
| 101 | /* Enable P1Mode for backplane mode */ |
| 102 | lp->setup = lp->setup | P1MODE; |
| 103 | |
| 104 | SET_SUBADR(SUB_SETUP1); |
| 105 | outb(lp->setup, _XREG); |
| 106 | |
Joe Perches | 7f5e760 | 2015-05-05 10:05:49 -0700 | [diff] [blame] | 107 | if (lp->clockm != 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | SET_SUBADR(SUB_SETUP2); |
| 109 | outb(lp->setup2, _XREG); |
Joe Perches | cb33464 | 2015-05-05 10:05:47 -0700 | [diff] [blame] | 110 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 111 | /* must now write the magic "restart operation" command */ |
| 112 | mdelay(1); |
| 113 | outb(0x18, _COMMAND); |
| 114 | } |
| 115 | |
| 116 | lp->config = 0x21 | (lp->timeout << 3) | (lp->backplane << 2); |
| 117 | /* set node ID to 0x42 (but transmitter is disabled, so it's okay) */ |
| 118 | SETCONF; |
Joe Perches | cb33464 | 2015-05-05 10:05:47 -0700 | [diff] [blame] | 119 | outb(0x42, ioaddr + BUS_ALIGN * 7); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | |
| 121 | status = ASTATUS(); |
| 122 | |
| 123 | if ((status & 0x99) != (NORXflag | TXFREEflag | RESETflag)) { |
Joe Perches | a34c093 | 2015-05-05 10:05:55 -0700 | [diff] [blame] | 124 | arc_printk(D_NORMAL, dev, "status invalid (%Xh).\n", status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 125 | return -ENODEV; |
| 126 | } |
Joe Perches | a34c093 | 2015-05-05 10:05:55 -0700 | [diff] [blame] | 127 | arc_printk(D_INIT_REASONS, dev, "status after reset: %X\n", status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 128 | |
| 129 | /* Enable TX */ |
| 130 | outb(0x39, _CONFIG); |
Joe Perches | cb33464 | 2015-05-05 10:05:47 -0700 | [diff] [blame] | 131 | outb(inb(ioaddr + BUS_ALIGN * 8), ioaddr + BUS_ALIGN * 7); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | |
| 133 | ACOMMAND(CFLAGScmd | RESETclear | CONFIGclear); |
| 134 | |
| 135 | status = ASTATUS(); |
Joe Perches | a34c093 | 2015-05-05 10:05:55 -0700 | [diff] [blame] | 136 | arc_printk(D_INIT_REASONS, dev, "status after reset acknowledged: %X\n", |
| 137 | status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | |
| 139 | /* Read first location of memory */ |
| 140 | outb(0 | RDDATAflag | AUTOINCflag, _ADDR_HI); |
| 141 | outb(0, _ADDR_LO); |
| 142 | |
| 143 | if ((status = inb(_MEMDATA)) != TESTvalue) { |
Joe Perches | a34c093 | 2015-05-05 10:05:55 -0700 | [diff] [blame] | 144 | arc_printk(D_NORMAL, dev, "Signature byte not found (%02Xh != D1h).\n", |
| 145 | status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | return -ENODEV; |
| 147 | } |
| 148 | return 0; |
| 149 | } |
| 150 | |
Michael Grzeschik | a0d2e51 | 2014-09-29 11:55:35 +0200 | [diff] [blame] | 151 | static int com20020_set_hwaddr(struct net_device *dev, void *addr) |
| 152 | { |
| 153 | int ioaddr = dev->base_addr; |
| 154 | struct arcnet_local *lp = netdev_priv(dev); |
| 155 | struct sockaddr *hwaddr = addr; |
| 156 | |
| 157 | memcpy(dev->dev_addr, hwaddr->sa_data, 1); |
| 158 | SET_SUBADR(SUB_NODE); |
| 159 | outb(dev->dev_addr[0], _XREG); |
| 160 | |
| 161 | return 0; |
| 162 | } |
| 163 | |
Stephen Hemminger | a1799af | 2009-01-09 13:01:10 +0000 | [diff] [blame] | 164 | const struct net_device_ops com20020_netdev_ops = { |
| 165 | .ndo_open = arcnet_open, |
| 166 | .ndo_stop = arcnet_close, |
| 167 | .ndo_start_xmit = arcnet_send_packet, |
| 168 | .ndo_tx_timeout = arcnet_timeout, |
Michael Grzeschik | a0d2e51 | 2014-09-29 11:55:35 +0200 | [diff] [blame] | 169 | .ndo_set_mac_address = com20020_set_hwaddr, |
Jiri Pirko | afc4b13 | 2011-08-16 06:29:01 +0000 | [diff] [blame] | 170 | .ndo_set_rx_mode = com20020_set_mc_list, |
Stephen Hemminger | a1799af | 2009-01-09 13:01:10 +0000 | [diff] [blame] | 171 | }; |
| 172 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 173 | /* Set up the struct net_device associated with this card. Called after |
| 174 | * probing succeeds. |
| 175 | */ |
| 176 | int com20020_found(struct net_device *dev, int shared) |
| 177 | { |
| 178 | struct arcnet_local *lp; |
| 179 | int ioaddr = dev->base_addr; |
| 180 | |
| 181 | /* Initialize the rest of the device structure. */ |
| 182 | |
Wang Chen | 454d7c9 | 2008-11-12 23:37:49 -0800 | [diff] [blame] | 183 | lp = netdev_priv(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 184 | |
| 185 | lp->hw.owner = THIS_MODULE; |
| 186 | lp->hw.command = com20020_command; |
| 187 | lp->hw.status = com20020_status; |
| 188 | lp->hw.intmask = com20020_setmask; |
| 189 | lp->hw.reset = com20020_reset; |
| 190 | lp->hw.copy_to_card = com20020_copy_to_card; |
| 191 | lp->hw.copy_from_card = com20020_copy_from_card; |
| 192 | lp->hw.close = com20020_close; |
| 193 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 194 | if (!dev->dev_addr[0]) |
Joe Perches | cb33464 | 2015-05-05 10:05:47 -0700 | [diff] [blame] | 195 | dev->dev_addr[0] = inb(ioaddr + BUS_ALIGN * 8); /* FIXME: do this some other way! */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 196 | |
| 197 | SET_SUBADR(SUB_SETUP1); |
| 198 | outb(lp->setup, _XREG); |
| 199 | |
Joe Perches | 7f5e760 | 2015-05-05 10:05:49 -0700 | [diff] [blame] | 200 | if (lp->card_flags & ARC_CAN_10MBIT) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 201 | SET_SUBADR(SUB_SETUP2); |
| 202 | outb(lp->setup2, _XREG); |
Joe Perches | cb33464 | 2015-05-05 10:05:47 -0700 | [diff] [blame] | 203 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 204 | /* must now write the magic "restart operation" command */ |
| 205 | mdelay(1); |
| 206 | outb(0x18, _COMMAND); |
| 207 | } |
| 208 | |
| 209 | lp->config = 0x20 | (lp->timeout << 3) | (lp->backplane << 2) | 1; |
| 210 | /* Default 0x38 + register: Node ID */ |
| 211 | SETCONF; |
| 212 | outb(dev->dev_addr[0], _XREG); |
| 213 | |
| 214 | /* reserve the irq */ |
Joe Perches | a0607fd | 2009-11-18 23:29:17 -0800 | [diff] [blame] | 215 | if (request_irq(dev->irq, arcnet_interrupt, shared, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 216 | "arcnet (COM20020)", dev)) { |
Joe Perches | a34c093 | 2015-05-05 10:05:55 -0700 | [diff] [blame] | 217 | arc_printk(D_NORMAL, dev, "Can't get IRQ %d!\n", dev->irq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 218 | return -ENODEV; |
| 219 | } |
| 220 | |
| 221 | dev->base_addr = ioaddr; |
| 222 | |
Joe Perches | a34c093 | 2015-05-05 10:05:55 -0700 | [diff] [blame] | 223 | arc_printk(D_NORMAL, dev, "%s: station %02Xh found at %03lXh, IRQ %d.\n", |
| 224 | lp->card_name, dev->dev_addr[0], dev->base_addr, dev->irq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 225 | |
| 226 | if (lp->backplane) |
Joe Perches | a34c093 | 2015-05-05 10:05:55 -0700 | [diff] [blame] | 227 | arc_printk(D_NORMAL, dev, "Using backplane mode.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 228 | |
| 229 | if (lp->timeout != 3) |
Joe Perches | a34c093 | 2015-05-05 10:05:55 -0700 | [diff] [blame] | 230 | arc_printk(D_NORMAL, dev, "Using extended timeout value of %d\n", |
| 231 | lp->timeout); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 232 | |
Joe Perches | a34c093 | 2015-05-05 10:05:55 -0700 | [diff] [blame] | 233 | arc_printk(D_NORMAL, dev, "Using CKP %d - data rate %s\n", |
| 234 | lp->setup >> 1, |
| 235 | clockrates[3 - ((lp->setup2 & 0xF0) >> 4) + ((lp->setup & 0x0F) >> 1)]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 236 | |
| 237 | if (register_netdev(dev)) { |
| 238 | free_irq(dev->irq, dev); |
| 239 | return -EIO; |
| 240 | } |
| 241 | return 0; |
| 242 | } |
| 243 | |
Joe Perches | f2f0a16 | 2015-05-05 10:05:52 -0700 | [diff] [blame] | 244 | /* Do a hardware reset on the card, and set up necessary registers. |
Joe Perches | cb33464 | 2015-05-05 10:05:47 -0700 | [diff] [blame] | 245 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 246 | * This should be called as little as possible, because it disrupts the |
| 247 | * token on the network (causes a RECON) and requires a significant delay. |
| 248 | * |
| 249 | * However, it does make sure the card is in a defined state. |
| 250 | */ |
| 251 | static int com20020_reset(struct net_device *dev, int really_reset) |
| 252 | { |
Wang Chen | 454d7c9 | 2008-11-12 23:37:49 -0800 | [diff] [blame] | 253 | struct arcnet_local *lp = netdev_priv(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 254 | u_int ioaddr = dev->base_addr; |
| 255 | u_char inbyte; |
| 256 | |
Joe Perches | a34c093 | 2015-05-05 10:05:55 -0700 | [diff] [blame] | 257 | arc_printk(D_DEBUG, dev, "%s: %d: %s: dev: %p, lp: %p, dev->name: %s\n", |
| 258 | __FILE__, __LINE__, __func__, dev, lp, dev->name); |
| 259 | arc_printk(D_INIT, dev, "Resetting %s (status=%02Xh)\n", |
| 260 | dev->name, ASTATUS()); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 261 | |
Joe Perches | a34c093 | 2015-05-05 10:05:55 -0700 | [diff] [blame] | 262 | arc_printk(D_DEBUG, dev, "%s: %d: %s\n", __FILE__, __LINE__, __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 263 | lp->config = TXENcfg | (lp->timeout << 3) | (lp->backplane << 2); |
| 264 | /* power-up defaults */ |
| 265 | SETCONF; |
Joe Perches | a34c093 | 2015-05-05 10:05:55 -0700 | [diff] [blame] | 266 | arc_printk(D_DEBUG, dev, "%s: %d: %s\n", __FILE__, __LINE__, __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 267 | |
| 268 | if (really_reset) { |
| 269 | /* reset the card */ |
| 270 | ARCRESET; |
| 271 | mdelay(RESETtime * 2); /* COM20020 seems to be slower sometimes */ |
| 272 | } |
| 273 | /* clear flags & end reset */ |
Joe Perches | a34c093 | 2015-05-05 10:05:55 -0700 | [diff] [blame] | 274 | arc_printk(D_DEBUG, dev, "%s: %d: %s\n", __FILE__, __LINE__, __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 275 | ACOMMAND(CFLAGScmd | RESETclear | CONFIGclear); |
| 276 | |
| 277 | /* verify that the ARCnet signature byte is present */ |
Joe Perches | a34c093 | 2015-05-05 10:05:55 -0700 | [diff] [blame] | 278 | arc_printk(D_DEBUG, dev, "%s: %d: %s\n", __FILE__, __LINE__, __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 279 | |
| 280 | com20020_copy_from_card(dev, 0, 0, &inbyte, 1); |
Joe Perches | a34c093 | 2015-05-05 10:05:55 -0700 | [diff] [blame] | 281 | arc_printk(D_DEBUG, dev, "%s: %d: %s\n", __FILE__, __LINE__, __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 282 | if (inbyte != TESTvalue) { |
Joe Perches | a34c093 | 2015-05-05 10:05:55 -0700 | [diff] [blame] | 283 | arc_printk(D_DEBUG, dev, "%s: %d: %s\n", |
| 284 | __FILE__, __LINE__, __func__); |
| 285 | arc_printk(D_NORMAL, dev, "reset failed: TESTvalue not present.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 286 | return 1; |
| 287 | } |
| 288 | /* enable extended (512-byte) packets */ |
| 289 | ACOMMAND(CONFIGcmd | EXTconf); |
Joe Perches | a34c093 | 2015-05-05 10:05:55 -0700 | [diff] [blame] | 290 | arc_printk(D_DEBUG, dev, "%s: %d: %s\n", __FILE__, __LINE__, __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 291 | |
| 292 | /* done! return success. */ |
| 293 | return 0; |
| 294 | } |
| 295 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 296 | static void com20020_setmask(struct net_device *dev, int mask) |
| 297 | { |
| 298 | u_int ioaddr = dev->base_addr; |
Joe Perches | 01a1d5a | 2015-05-05 10:05:48 -0700 | [diff] [blame] | 299 | |
Joe Perches | a34c093 | 2015-05-05 10:05:55 -0700 | [diff] [blame] | 300 | arc_printk(D_DURING, dev, "Setting mask to %x at %x\n", mask, ioaddr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 301 | AINTMASK(mask); |
| 302 | } |
| 303 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 304 | static void com20020_command(struct net_device *dev, int cmd) |
| 305 | { |
| 306 | u_int ioaddr = dev->base_addr; |
Joe Perches | 01a1d5a | 2015-05-05 10:05:48 -0700 | [diff] [blame] | 307 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 308 | ACOMMAND(cmd); |
| 309 | } |
| 310 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 311 | static int com20020_status(struct net_device *dev) |
| 312 | { |
| 313 | u_int ioaddr = dev->base_addr; |
| 314 | |
Joe Perches | cb33464 | 2015-05-05 10:05:47 -0700 | [diff] [blame] | 315 | return ASTATUS() + (ADIAGSTATUS() << 8); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 316 | } |
| 317 | |
| 318 | static void com20020_close(struct net_device *dev) |
| 319 | { |
Wang Chen | 454d7c9 | 2008-11-12 23:37:49 -0800 | [diff] [blame] | 320 | struct arcnet_local *lp = netdev_priv(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 321 | int ioaddr = dev->base_addr; |
| 322 | |
| 323 | /* disable transmitter */ |
| 324 | lp->config &= ~TXENcfg; |
| 325 | SETCONF; |
| 326 | } |
| 327 | |
| 328 | /* Set or clear the multicast filter for this adaptor. |
| 329 | * num_addrs == -1 Promiscuous mode, receive all packets |
| 330 | * num_addrs == 0 Normal mode, clear multicast list |
| 331 | * num_addrs > 0 Multicast mode, receive normal and MC packets, and do |
| 332 | * best-effort filtering. |
| 333 | * FIXME - do multicast stuff, not just promiscuous. |
| 334 | */ |
| 335 | static void com20020_set_mc_list(struct net_device *dev) |
| 336 | { |
Wang Chen | 454d7c9 | 2008-11-12 23:37:49 -0800 | [diff] [blame] | 337 | struct arcnet_local *lp = netdev_priv(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 338 | int ioaddr = dev->base_addr; |
| 339 | |
| 340 | if ((dev->flags & IFF_PROMISC) && (dev->flags & IFF_UP)) { /* Enable promiscuous mode */ |
| 341 | if (!(lp->setup & PROMISCset)) |
Joe Perches | a34c093 | 2015-05-05 10:05:55 -0700 | [diff] [blame] | 342 | arc_printk(D_NORMAL, dev, "Setting promiscuous flag...\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 343 | SET_SUBADR(SUB_SETUP1); |
| 344 | lp->setup |= PROMISCset; |
| 345 | outb(lp->setup, _XREG); |
| 346 | } else |
| 347 | /* Disable promiscuous mode, use normal mode */ |
| 348 | { |
| 349 | if ((lp->setup & PROMISCset)) |
Joe Perches | a34c093 | 2015-05-05 10:05:55 -0700 | [diff] [blame] | 350 | arc_printk(D_NORMAL, dev, "Resetting promiscuous flag...\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 351 | SET_SUBADR(SUB_SETUP1); |
| 352 | lp->setup &= ~PROMISCset; |
| 353 | outb(lp->setup, _XREG); |
| 354 | } |
| 355 | } |
| 356 | |
Randy Dunlap | ace48ff | 2006-11-08 19:51:03 -0800 | [diff] [blame] | 357 | #if defined(CONFIG_ARCNET_COM20020_PCI_MODULE) || \ |
Randy Dunlap | 2a10387 | 2007-02-12 00:52:22 -0800 | [diff] [blame] | 358 | defined(CONFIG_ARCNET_COM20020_ISA_MODULE) || \ |
| 359 | defined(CONFIG_ARCNET_COM20020_CS_MODULE) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 360 | EXPORT_SYMBOL(com20020_check); |
| 361 | EXPORT_SYMBOL(com20020_found); |
David S. Miller | dd0a251 | 2009-01-25 21:17:25 -0800 | [diff] [blame] | 362 | EXPORT_SYMBOL(com20020_netdev_ops); |
Randy Dunlap | ace48ff | 2006-11-08 19:51:03 -0800 | [diff] [blame] | 363 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 364 | |
| 365 | MODULE_LICENSE("GPL"); |
| 366 | |
Randy Dunlap | ace48ff | 2006-11-08 19:51:03 -0800 | [diff] [blame] | 367 | #ifdef MODULE |
| 368 | |
Jon Schindler | 0ebd1c1 | 2008-02-28 01:31:08 -0600 | [diff] [blame] | 369 | static int __init com20020_module_init(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 370 | { |
Joe Perches | 72aeea4 | 2015-05-05 10:05:54 -0700 | [diff] [blame] | 371 | if (BUGLVL(D_NORMAL)) |
Joe Perches | 05a24b2 | 2015-05-05 10:05:56 -0700 | [diff] [blame^] | 372 | pr_info("%s\n", "COM20020 chipset support (by David Woodhouse et al.)\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 373 | return 0; |
| 374 | } |
| 375 | |
Jon Schindler | 0ebd1c1 | 2008-02-28 01:31:08 -0600 | [diff] [blame] | 376 | static void __exit com20020_module_exit(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 377 | { |
| 378 | } |
Jon Schindler | 0ebd1c1 | 2008-02-28 01:31:08 -0600 | [diff] [blame] | 379 | module_init(com20020_module_init); |
| 380 | module_exit(com20020_module_exit); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 381 | #endif /* MODULE */ |