Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Linux ARCnet driver - COM20020 PCMCIA 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 1994-1999 by Avery Pennarun, |
| 5 | * based on an ISA version by David Woodhouse. |
| 6 | * Derived from ibmtr_cs.c by Steve Kipisz (pcmcia-cs 3.1.4) |
| 7 | * which was derived from pcnet_cs.c by David Hinds. |
| 8 | * Some additional portions derived from skeleton.c by Donald Becker. |
| 9 | * |
| 10 | * Special thanks to Contemporary Controls, Inc. (www.ccontrols.com) |
| 11 | * for sponsoring the further development of this driver. |
| 12 | * |
| 13 | * ********************** |
| 14 | * |
| 15 | * The original copyright of skeleton.c was as follows: |
| 16 | * |
| 17 | * skeleton.c Written 1993 by Donald Becker. |
| 18 | * Copyright 1993 United States Government as represented by the |
| 19 | * Director, National Security Agency. This software may only be used |
| 20 | * and distributed according to the terms of the GNU General Public License as |
| 21 | * modified by SRC, incorporated herein by reference. |
Joe Perches | cb33464 | 2015-05-05 10:05:47 -0700 | [diff] [blame] | 22 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | * ********************** |
| 24 | * Changes: |
| 25 | * Arnaldo Carvalho de Melo <acme@conectiva.com.br> - 08/08/2000 |
| 26 | * - reorganize kmallocs in com20020_attach, checking all for failure |
| 27 | * and releasing the previous allocations if one fails |
| 28 | * ********************** |
Joe Perches | cb33464 | 2015-05-05 10:05:47 -0700 | [diff] [blame] | 29 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | * For more details, see drivers/net/arcnet.c |
| 31 | * |
| 32 | * ********************** |
| 33 | */ |
Joe Perches | 05a24b2 | 2015-05-05 10:05:56 -0700 | [diff] [blame] | 34 | |
| 35 | #define pr_fmt(fmt) "arcnet:" KBUILD_MODNAME ": " fmt |
| 36 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | #include <linux/kernel.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | #include <linux/ptrace.h> |
| 39 | #include <linux/slab.h> |
| 40 | #include <linux/string.h> |
| 41 | #include <linux/timer.h> |
| 42 | #include <linux/delay.h> |
| 43 | #include <linux/module.h> |
| 44 | #include <linux/netdevice.h> |
Joe Perches | 26c6d28 | 2015-05-05 10:06:03 -0700 | [diff] [blame^] | 45 | #include <linux/io.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | #include <pcmcia/cistpl.h> |
| 47 | #include <pcmcia/ds.h> |
| 48 | |
Joe Perches | 26c6d28 | 2015-05-05 10:06:03 -0700 | [diff] [blame^] | 49 | #include "arcdevice.h" |
| 50 | #include "com20020.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | static void regdump(struct net_device *dev) |
| 53 | { |
Joe Perches | 636b811 | 2010-08-12 12:22:51 +0000 | [diff] [blame] | 54 | #ifdef DEBUG |
Joe Perches | cb33464 | 2015-05-05 10:05:47 -0700 | [diff] [blame] | 55 | int ioaddr = dev->base_addr; |
| 56 | int count; |
| 57 | |
| 58 | netdev_dbg(dev, "register dump:\n"); |
Joe Perches | 7f5e760 | 2015-05-05 10:05:49 -0700 | [diff] [blame] | 59 | for (count = ioaddr; count < ioaddr + 16; count++) { |
Joe Perches | cb33464 | 2015-05-05 10:05:47 -0700 | [diff] [blame] | 60 | if (!(count % 16)) |
| 61 | pr_cont("%04X:", count); |
| 62 | pr_cont(" %02X", inb(count)); |
| 63 | } |
| 64 | pr_cont("\n"); |
| 65 | |
| 66 | netdev_dbg(dev, "buffer0 dump:\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | /* set up the address register */ |
Joe Perches | cb33464 | 2015-05-05 10:05:47 -0700 | [diff] [blame] | 68 | count = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | outb((count >> 8) | RDDATAflag | AUTOINCflag, _ADDR_HI); |
| 70 | outb(count & 0xff, _ADDR_LO); |
Joe Perches | cb33464 | 2015-05-05 10:05:47 -0700 | [diff] [blame] | 71 | |
Joe Perches | 7f5e760 | 2015-05-05 10:05:49 -0700 | [diff] [blame] | 72 | for (count = 0; count < 256 + 32; count++) { |
Joe Perches | cb33464 | 2015-05-05 10:05:47 -0700 | [diff] [blame] | 73 | if (!(count % 16)) |
| 74 | pr_cont("%04X:", count); |
| 75 | |
| 76 | /* copy the data */ |
| 77 | pr_cont(" %02X", inb(_MEMDATA)); |
| 78 | } |
| 79 | pr_cont("\n"); |
Joe Perches | 636b811 | 2010-08-12 12:22:51 +0000 | [diff] [blame] | 80 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | } |
| 82 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | /*====================================================================*/ |
| 84 | |
| 85 | /* Parameters that can be set with 'insmod' */ |
| 86 | |
| 87 | static int node; |
| 88 | static int timeout = 3; |
| 89 | static int backplane; |
| 90 | static int clockp; |
| 91 | static int clockm; |
| 92 | |
| 93 | module_param(node, int, 0); |
| 94 | module_param(timeout, int, 0); |
| 95 | module_param(backplane, int, 0); |
| 96 | module_param(clockp, int, 0); |
| 97 | module_param(clockm, int, 0); |
| 98 | |
| 99 | MODULE_LICENSE("GPL"); |
| 100 | |
| 101 | /*====================================================================*/ |
| 102 | |
Dominik Brodowski | 15b99ac | 2006-03-31 17:26:06 +0200 | [diff] [blame] | 103 | static int com20020_config(struct pcmcia_device *link); |
Dominik Brodowski | fba395e | 2006-03-31 17:21:06 +0200 | [diff] [blame] | 104 | static void com20020_release(struct pcmcia_device *link); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 | |
Dominik Brodowski | cc3b486 | 2005-11-14 21:23:14 +0100 | [diff] [blame] | 106 | static void com20020_detach(struct pcmcia_device *p_dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | /*====================================================================*/ |
| 109 | |
Dominik Brodowski | 15b99ac | 2006-03-31 17:26:06 +0200 | [diff] [blame] | 110 | static int com20020_probe(struct pcmcia_device *p_dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 111 | { |
Joe Perches | cb33464 | 2015-05-05 10:05:47 -0700 | [diff] [blame] | 112 | struct com20020_dev *info; |
| 113 | struct net_device *dev; |
| 114 | struct arcnet_local *lp; |
Dominik Brodowski | f8cfa61 | 2005-11-14 21:25:51 +0100 | [diff] [blame] | 115 | |
Joe Perches | cb33464 | 2015-05-05 10:05:47 -0700 | [diff] [blame] | 116 | dev_dbg(&p_dev->dev, "com20020_attach()\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 | |
Joe Perches | cb33464 | 2015-05-05 10:05:47 -0700 | [diff] [blame] | 118 | /* Create new network device */ |
| 119 | info = kzalloc(sizeof(*info), GFP_KERNEL); |
| 120 | if (!info) |
| 121 | goto fail_alloc_info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 122 | |
Joe Perches | cb33464 | 2015-05-05 10:05:47 -0700 | [diff] [blame] | 123 | dev = alloc_arcdev(""); |
| 124 | if (!dev) |
| 125 | goto fail_alloc_dev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | |
Joe Perches | cb33464 | 2015-05-05 10:05:47 -0700 | [diff] [blame] | 127 | lp = netdev_priv(dev); |
| 128 | lp->timeout = timeout; |
| 129 | lp->backplane = backplane; |
| 130 | lp->clockp = clockp; |
| 131 | lp->clockm = clockm & 3; |
| 132 | lp->hw.owner = THIS_MODULE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 133 | |
Joe Perches | cb33464 | 2015-05-05 10:05:47 -0700 | [diff] [blame] | 134 | /* fill in our module parameters as defaults */ |
| 135 | dev->dev_addr[0] = node; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 | |
Joe Perches | cb33464 | 2015-05-05 10:05:47 -0700 | [diff] [blame] | 137 | p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_8; |
| 138 | p_dev->resource[0]->end = 16; |
| 139 | p_dev->config_flags |= CONF_ENABLE_IRQ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 140 | |
Joe Perches | cb33464 | 2015-05-05 10:05:47 -0700 | [diff] [blame] | 141 | info->dev = dev; |
| 142 | p_dev->priv = info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 143 | |
Joe Perches | cb33464 | 2015-05-05 10:05:47 -0700 | [diff] [blame] | 144 | return com20020_config(p_dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 145 | |
| 146 | fail_alloc_dev: |
Joe Perches | cb33464 | 2015-05-05 10:05:47 -0700 | [diff] [blame] | 147 | kfree(info); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 148 | fail_alloc_info: |
Joe Perches | cb33464 | 2015-05-05 10:05:47 -0700 | [diff] [blame] | 149 | return -ENOMEM; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 150 | } /* com20020_attach */ |
| 151 | |
Dominik Brodowski | fba395e | 2006-03-31 17:21:06 +0200 | [diff] [blame] | 152 | static void com20020_detach(struct pcmcia_device *link) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 153 | { |
Joe Perches | cb33464 | 2015-05-05 10:05:47 -0700 | [diff] [blame] | 154 | struct com20020_dev *info = link->priv; |
| 155 | struct net_device *dev = info->dev; |
Dominik Brodowski | b463581 | 2005-11-14 21:25:35 +0100 | [diff] [blame] | 156 | |
Joe Perches | cb33464 | 2015-05-05 10:05:47 -0700 | [diff] [blame] | 157 | dev_dbg(&link->dev, "detach...\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | |
Joe Perches | cb33464 | 2015-05-05 10:05:47 -0700 | [diff] [blame] | 159 | dev_dbg(&link->dev, "com20020_detach\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 160 | |
Joe Perches | cb33464 | 2015-05-05 10:05:47 -0700 | [diff] [blame] | 161 | dev_dbg(&link->dev, "unregister...\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 162 | |
Joe Perches | cb33464 | 2015-05-05 10:05:47 -0700 | [diff] [blame] | 163 | unregister_netdev(dev); |
Dominik Brodowski | b463581 | 2005-11-14 21:25:35 +0100 | [diff] [blame] | 164 | |
Joe Perches | f2f0a16 | 2015-05-05 10:05:52 -0700 | [diff] [blame] | 165 | /* this is necessary because we register our IRQ separately |
Joe Perches | cb33464 | 2015-05-05 10:05:47 -0700 | [diff] [blame] | 166 | * from card services. |
| 167 | */ |
| 168 | if (dev->irq) |
| 169 | free_irq(dev->irq, dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 170 | |
Joe Perches | cb33464 | 2015-05-05 10:05:47 -0700 | [diff] [blame] | 171 | com20020_release(link); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 172 | |
Joe Perches | cb33464 | 2015-05-05 10:05:47 -0700 | [diff] [blame] | 173 | /* Unlink device structure, free bits */ |
| 174 | dev_dbg(&link->dev, "unlinking...\n"); |
Joe Perches | 7f5e760 | 2015-05-05 10:05:49 -0700 | [diff] [blame] | 175 | if (link->priv) { |
Joe Perches | cb33464 | 2015-05-05 10:05:47 -0700 | [diff] [blame] | 176 | dev = info->dev; |
Joe Perches | 7f5e760 | 2015-05-05 10:05:49 -0700 | [diff] [blame] | 177 | if (dev) { |
Joe Perches | cb33464 | 2015-05-05 10:05:47 -0700 | [diff] [blame] | 178 | dev_dbg(&link->dev, "kfree...\n"); |
| 179 | free_netdev(dev); |
| 180 | } |
| 181 | dev_dbg(&link->dev, "kfree2...\n"); |
| 182 | kfree(info); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 183 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 184 | |
| 185 | } /* com20020_detach */ |
| 186 | |
Dominik Brodowski | 15b99ac | 2006-03-31 17:26:06 +0200 | [diff] [blame] | 187 | static int com20020_config(struct pcmcia_device *link) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 188 | { |
Joe Perches | cb33464 | 2015-05-05 10:05:47 -0700 | [diff] [blame] | 189 | struct arcnet_local *lp; |
| 190 | struct com20020_dev *info; |
| 191 | struct net_device *dev; |
| 192 | int i, ret; |
| 193 | int ioaddr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 194 | |
Joe Perches | cb33464 | 2015-05-05 10:05:47 -0700 | [diff] [blame] | 195 | info = link->priv; |
| 196 | dev = info->dev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 197 | |
Joe Perches | cb33464 | 2015-05-05 10:05:47 -0700 | [diff] [blame] | 198 | dev_dbg(&link->dev, "config...\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 199 | |
Joe Perches | cb33464 | 2015-05-05 10:05:47 -0700 | [diff] [blame] | 200 | dev_dbg(&link->dev, "com20020_config\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 201 | |
Joe Perches | cb33464 | 2015-05-05 10:05:47 -0700 | [diff] [blame] | 202 | dev_dbg(&link->dev, "baseport1 is %Xh\n", |
| 203 | (unsigned int)link->resource[0]->start); |
Dominik Brodowski | 90abdc3 | 2010-07-24 17:23:51 +0200 | [diff] [blame] | 204 | |
Joe Perches | cb33464 | 2015-05-05 10:05:47 -0700 | [diff] [blame] | 205 | i = -ENODEV; |
| 206 | link->io_lines = 16; |
Dominik Brodowski | 90abdc3 | 2010-07-24 17:23:51 +0200 | [diff] [blame] | 207 | |
Joe Perches | 7f5e760 | 2015-05-05 10:05:49 -0700 | [diff] [blame] | 208 | if (!link->resource[0]->start) { |
| 209 | for (ioaddr = 0x100; ioaddr < 0x400; ioaddr += 0x10) { |
Joe Perches | cb33464 | 2015-05-05 10:05:47 -0700 | [diff] [blame] | 210 | link->resource[0]->start = ioaddr; |
| 211 | i = pcmcia_request_io(link); |
| 212 | if (i == 0) |
| 213 | break; |
| 214 | } |
Joe Perches | 7f5e760 | 2015-05-05 10:05:49 -0700 | [diff] [blame] | 215 | } else { |
Joe Perches | cb33464 | 2015-05-05 10:05:47 -0700 | [diff] [blame] | 216 | i = pcmcia_request_io(link); |
Joe Perches | 7f5e760 | 2015-05-05 10:05:49 -0700 | [diff] [blame] | 217 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 218 | |
Joe Perches | 7f5e760 | 2015-05-05 10:05:49 -0700 | [diff] [blame] | 219 | if (i != 0) { |
Joe Perches | cb33464 | 2015-05-05 10:05:47 -0700 | [diff] [blame] | 220 | dev_dbg(&link->dev, "requestIO failed totally!\n"); |
| 221 | goto failed; |
| 222 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 223 | |
Joe Perches | cb33464 | 2015-05-05 10:05:47 -0700 | [diff] [blame] | 224 | ioaddr = dev->base_addr = link->resource[0]->start; |
| 225 | dev_dbg(&link->dev, "got ioaddr %Xh\n", ioaddr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 226 | |
Joe Perches | cb33464 | 2015-05-05 10:05:47 -0700 | [diff] [blame] | 227 | dev_dbg(&link->dev, "request IRQ %d\n", |
| 228 | link->irq); |
Joe Perches | 7f5e760 | 2015-05-05 10:05:49 -0700 | [diff] [blame] | 229 | if (!link->irq) { |
Joe Perches | cb33464 | 2015-05-05 10:05:47 -0700 | [diff] [blame] | 230 | dev_dbg(&link->dev, "requestIRQ failed totally!\n"); |
| 231 | goto failed; |
| 232 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 233 | |
Joe Perches | cb33464 | 2015-05-05 10:05:47 -0700 | [diff] [blame] | 234 | dev->irq = link->irq; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 235 | |
Joe Perches | cb33464 | 2015-05-05 10:05:47 -0700 | [diff] [blame] | 236 | ret = pcmcia_enable_device(link); |
| 237 | if (ret) |
| 238 | goto failed; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 239 | |
Joe Perches | 7f5e760 | 2015-05-05 10:05:49 -0700 | [diff] [blame] | 240 | if (com20020_check(dev)) { |
Joe Perches | cb33464 | 2015-05-05 10:05:47 -0700 | [diff] [blame] | 241 | regdump(dev); |
| 242 | goto failed; |
| 243 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 244 | |
Joe Perches | cb33464 | 2015-05-05 10:05:47 -0700 | [diff] [blame] | 245 | lp = netdev_priv(dev); |
| 246 | lp->card_name = "PCMCIA COM20020"; |
| 247 | lp->card_flags = ARC_CAN_10MBIT; /* pretend all of them can 10Mbit */ |
| 248 | |
| 249 | SET_NETDEV_DEV(dev, &link->dev); |
| 250 | |
| 251 | i = com20020_found(dev, 0); /* calls register_netdev */ |
| 252 | |
| 253 | if (i != 0) { |
| 254 | dev_notice(&link->dev, |
| 255 | "com20020_found() failed\n"); |
| 256 | goto failed; |
| 257 | } |
| 258 | |
| 259 | netdev_dbg(dev, "port %#3lx, irq %d\n", |
| 260 | dev->base_addr, dev->irq); |
| 261 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 262 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 263 | failed: |
Joe Perches | cb33464 | 2015-05-05 10:05:47 -0700 | [diff] [blame] | 264 | dev_dbg(&link->dev, "com20020_config failed...\n"); |
| 265 | com20020_release(link); |
| 266 | return -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 267 | } /* com20020_config */ |
| 268 | |
Dominik Brodowski | fba395e | 2006-03-31 17:21:06 +0200 | [diff] [blame] | 269 | static void com20020_release(struct pcmcia_device *link) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 270 | { |
Dominik Brodowski | dd0fab5 | 2009-10-24 15:51:05 +0200 | [diff] [blame] | 271 | dev_dbg(&link->dev, "com20020_release\n"); |
Dominik Brodowski | fba395e | 2006-03-31 17:21:06 +0200 | [diff] [blame] | 272 | pcmcia_disable_device(link); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 273 | } |
| 274 | |
Dominik Brodowski | fba395e | 2006-03-31 17:21:06 +0200 | [diff] [blame] | 275 | static int com20020_suspend(struct pcmcia_device *link) |
Dominik Brodowski | 98e4c28 | 2005-11-14 21:21:18 +0100 | [diff] [blame] | 276 | { |
Himangi Saraogi | 2dfd253 | 2014-08-09 21:37:18 +0530 | [diff] [blame] | 277 | struct com20020_dev *info = link->priv; |
Dominik Brodowski | 98e4c28 | 2005-11-14 21:21:18 +0100 | [diff] [blame] | 278 | struct net_device *dev = info->dev; |
| 279 | |
Dominik Brodowski | e2d4096 | 2006-03-02 00:09:29 +0100 | [diff] [blame] | 280 | if (link->open) |
Dominik Brodowski | 8661bb5 | 2006-03-02 00:02:33 +0100 | [diff] [blame] | 281 | netif_device_detach(dev); |
Dominik Brodowski | 98e4c28 | 2005-11-14 21:21:18 +0100 | [diff] [blame] | 282 | |
| 283 | return 0; |
| 284 | } |
| 285 | |
Dominik Brodowski | fba395e | 2006-03-31 17:21:06 +0200 | [diff] [blame] | 286 | static int com20020_resume(struct pcmcia_device *link) |
Dominik Brodowski | 98e4c28 | 2005-11-14 21:21:18 +0100 | [diff] [blame] | 287 | { |
Himangi Saraogi | 2dfd253 | 2014-08-09 21:37:18 +0530 | [diff] [blame] | 288 | struct com20020_dev *info = link->priv; |
Dominik Brodowski | 98e4c28 | 2005-11-14 21:21:18 +0100 | [diff] [blame] | 289 | struct net_device *dev = info->dev; |
| 290 | |
Dominik Brodowski | e2d4096 | 2006-03-02 00:09:29 +0100 | [diff] [blame] | 291 | if (link->open) { |
Dominik Brodowski | 8661bb5 | 2006-03-02 00:02:33 +0100 | [diff] [blame] | 292 | int ioaddr = dev->base_addr; |
Wang Chen | 4cf1653 | 2008-11-12 23:38:14 -0800 | [diff] [blame] | 293 | struct arcnet_local *lp = netdev_priv(dev); |
Joe Perches | 01a1d5a | 2015-05-05 10:05:48 -0700 | [diff] [blame] | 294 | |
Dominik Brodowski | 8661bb5 | 2006-03-02 00:02:33 +0100 | [diff] [blame] | 295 | ARCRESET; |
| 296 | } |
Dominik Brodowski | 98e4c28 | 2005-11-14 21:21:18 +0100 | [diff] [blame] | 297 | |
| 298 | return 0; |
| 299 | } |
| 300 | |
Joe Perches | 25f8f54 | 2011-05-03 19:29:01 -0700 | [diff] [blame] | 301 | static const struct pcmcia_device_id com20020_ids[] = { |
Marc Sowen | 6bb1c39 | 2006-06-25 01:56:24 -0700 | [diff] [blame] | 302 | PCMCIA_DEVICE_PROD_ID12("Contemporary Control Systems, Inc.", |
Joe Perches | cb33464 | 2015-05-05 10:05:47 -0700 | [diff] [blame] | 303 | "PCM20 Arcnet Adapter", 0x59991666, 0x95dfffaf), |
Marc Sowen | 6bb1c39 | 2006-06-25 01:56:24 -0700 | [diff] [blame] | 304 | PCMCIA_DEVICE_PROD_ID12("SoHard AG", |
Joe Perches | cb33464 | 2015-05-05 10:05:47 -0700 | [diff] [blame] | 305 | "SH ARC PCMCIA", 0xf8991729, 0x69dff0c7), |
Dominik Brodowski | 7fb22bb | 2005-06-27 16:28:38 -0700 | [diff] [blame] | 306 | PCMCIA_DEVICE_NULL |
| 307 | }; |
| 308 | MODULE_DEVICE_TABLE(pcmcia, com20020_ids); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 309 | |
| 310 | static struct pcmcia_driver com20020_cs_driver = { |
| 311 | .owner = THIS_MODULE, |
Dominik Brodowski | 2e9b981 | 2010-08-08 11:36:26 +0200 | [diff] [blame] | 312 | .name = "com20020_cs", |
Dominik Brodowski | 15b99ac | 2006-03-31 17:26:06 +0200 | [diff] [blame] | 313 | .probe = com20020_probe, |
Dominik Brodowski | cc3b486 | 2005-11-14 21:23:14 +0100 | [diff] [blame] | 314 | .remove = com20020_detach, |
Dominik Brodowski | 7fb22bb | 2005-06-27 16:28:38 -0700 | [diff] [blame] | 315 | .id_table = com20020_ids, |
Dominik Brodowski | 98e4c28 | 2005-11-14 21:21:18 +0100 | [diff] [blame] | 316 | .suspend = com20020_suspend, |
| 317 | .resume = com20020_resume, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 318 | }; |
H Hartley Sweeten | fdd3f29 | 2013-03-06 11:27:43 -0700 | [diff] [blame] | 319 | module_pcmcia_driver(com20020_cs_driver); |