| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* | 
|  | 2 | *  skisa.c: A network driver for SK-NET TMS380-based ISA token ring cards. | 
|  | 3 | * | 
|  | 4 | *  Based on tmspci written 1999 by Adam Fritzler | 
|  | 5 | * | 
|  | 6 | *  Written 2000 by Jochen Friedrich | 
|  | 7 | *  Dedicated to my girlfriend Steffi Bopp | 
|  | 8 | * | 
|  | 9 | *  This software may be used and distributed according to the terms | 
|  | 10 | *  of the GNU General Public License, incorporated herein by reference. | 
|  | 11 | * | 
|  | 12 | *  This driver module supports the following cards: | 
|  | 13 | *	- SysKonnect TR4/16(+) ISA	(SK-4190) | 
|  | 14 | * | 
|  | 15 | *  Maintainer(s): | 
|  | 16 | *    AF        Adam Fritzler           mid@auk.cx | 
|  | 17 | *    JF	Jochen Friedrich	jochen@scram.de | 
|  | 18 | * | 
|  | 19 | *  Modification History: | 
|  | 20 | *	14-Jan-01	JF	Created | 
|  | 21 | *	28-Oct-02	JF	Fixed probe of card for static compilation. | 
|  | 22 | *				Fixed module init to not make hotplug go wild. | 
|  | 23 | *	09-Nov-02	JF	Fixed early bail out on out of memory | 
|  | 24 | *				situations if multiple cards are found. | 
|  | 25 | *				Cleaned up some unnecessary console SPAM. | 
|  | 26 | *	09-Dec-02	JF	Fixed module reference counting. | 
|  | 27 | *	02-Jan-03	JF	Renamed to skisa.c | 
|  | 28 | * | 
|  | 29 | */ | 
|  | 30 | static const char version[] = "skisa.c: v1.03 09/12/2002 by Jochen Friedrich\n"; | 
|  | 31 |  | 
|  | 32 | #include <linux/module.h> | 
|  | 33 | #include <linux/kernel.h> | 
|  | 34 | #include <linux/errno.h> | 
|  | 35 | #include <linux/pci.h> | 
|  | 36 | #include <linux/init.h> | 
|  | 37 | #include <linux/netdevice.h> | 
|  | 38 | #include <linux/trdevice.h> | 
| Russell King | d052d1b | 2005-10-29 19:07:23 +0100 | [diff] [blame] | 39 | #include <linux/platform_device.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 |  | 
|  | 41 | #include <asm/system.h> | 
|  | 42 | #include <asm/io.h> | 
|  | 43 | #include <asm/irq.h> | 
|  | 44 | #include <asm/pci.h> | 
|  | 45 | #include <asm/dma.h> | 
|  | 46 |  | 
|  | 47 | #include "tms380tr.h" | 
|  | 48 |  | 
|  | 49 | #define SK_ISA_IO_EXTENT 32 | 
|  | 50 |  | 
|  | 51 | /* A zero-terminated list of I/O addresses to be probed. */ | 
|  | 52 | static unsigned int portlist[] __initdata = { | 
|  | 53 | 0x0A20, 0x1A20, 0x0B20, 0x1B20, 0x0980, 0x1980, 0x0900, 0x1900,// SK | 
|  | 54 | 0 | 
|  | 55 | }; | 
|  | 56 |  | 
|  | 57 | /* A zero-terminated list of IRQs to be probed. | 
|  | 58 | * Used again after initial probe for sktr_chipset_init, called from sktr_open. | 
|  | 59 | */ | 
|  | 60 | static const unsigned short irqlist[] = { | 
|  | 61 | 3, 5, 9, 10, 11, 12, 15, | 
|  | 62 | 0 | 
|  | 63 | }; | 
|  | 64 |  | 
|  | 65 | /* A zero-terminated list of DMAs to be probed. */ | 
|  | 66 | static int dmalist[] __initdata = { | 
|  | 67 | 5, 6, 7, | 
|  | 68 | 0 | 
|  | 69 | }; | 
|  | 70 |  | 
|  | 71 | static char isa_cardname[] = "SK NET TR 4/16 ISA\0"; | 
| Jochen Friedrich | 504ff16 | 2005-07-27 01:14:50 -0700 | [diff] [blame] | 72 | static u64 dma_mask = ISA_MAX_ADDRESS; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | static int sk_isa_open(struct net_device *dev); | 
|  | 74 | static void sk_isa_read_eeprom(struct net_device *dev); | 
|  | 75 | static unsigned short sk_isa_setnselout_pins(struct net_device *dev); | 
|  | 76 |  | 
|  | 77 | static unsigned short sk_isa_sifreadb(struct net_device *dev, unsigned short reg) | 
|  | 78 | { | 
|  | 79 | return inb(dev->base_addr + reg); | 
|  | 80 | } | 
|  | 81 |  | 
|  | 82 | static unsigned short sk_isa_sifreadw(struct net_device *dev, unsigned short reg) | 
|  | 83 | { | 
|  | 84 | return inw(dev->base_addr + reg); | 
|  | 85 | } | 
|  | 86 |  | 
|  | 87 | static void sk_isa_sifwriteb(struct net_device *dev, unsigned short val, unsigned short reg) | 
|  | 88 | { | 
|  | 89 | outb(val, dev->base_addr + reg); | 
|  | 90 | } | 
|  | 91 |  | 
|  | 92 | static void sk_isa_sifwritew(struct net_device *dev, unsigned short val, unsigned short reg) | 
|  | 93 | { | 
|  | 94 | outw(val, dev->base_addr + reg); | 
|  | 95 | } | 
|  | 96 |  | 
|  | 97 |  | 
|  | 98 | static int __init sk_isa_probe1(struct net_device *dev, int ioaddr) | 
|  | 99 | { | 
|  | 100 | unsigned char old, chk1, chk2; | 
|  | 101 |  | 
|  | 102 | if (!request_region(ioaddr, SK_ISA_IO_EXTENT, isa_cardname)) | 
|  | 103 | return -ENODEV; | 
|  | 104 |  | 
|  | 105 | old = inb(ioaddr + SIFADR);	/* Get the old SIFADR value */ | 
|  | 106 |  | 
|  | 107 | chk1 = 0;	/* Begin with check value 0 */ | 
|  | 108 | do { | 
|  | 109 | /* Write new SIFADR value */ | 
|  | 110 | outb(chk1, ioaddr + SIFADR); | 
|  | 111 |  | 
|  | 112 | /* Read, invert and write */ | 
|  | 113 | chk2 = inb(ioaddr + SIFADD); | 
|  | 114 | chk2 ^= 0x0FE; | 
|  | 115 | outb(chk2, ioaddr + SIFADR); | 
|  | 116 |  | 
|  | 117 | /* Read, invert and compare */ | 
|  | 118 | chk2 = inb(ioaddr + SIFADD); | 
|  | 119 | chk2 ^= 0x0FE; | 
|  | 120 |  | 
|  | 121 | if(chk1 != chk2) { | 
|  | 122 | release_region(ioaddr, SK_ISA_IO_EXTENT); | 
|  | 123 | return -ENODEV; | 
|  | 124 | } | 
|  | 125 |  | 
|  | 126 | chk1 -= 2; | 
|  | 127 | } while(chk1 != 0);	/* Repeat 128 times (all byte values) */ | 
|  | 128 |  | 
|  | 129 | /* Restore the SIFADR value */ | 
|  | 130 | outb(old, ioaddr + SIFADR); | 
|  | 131 |  | 
|  | 132 | dev->base_addr = ioaddr; | 
|  | 133 | return 0; | 
|  | 134 | } | 
|  | 135 |  | 
| Jochen Friedrich | 504ff16 | 2005-07-27 01:14:50 -0700 | [diff] [blame] | 136 | static int __init setup_card(struct net_device *dev, struct device *pdev) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | { | 
|  | 138 | struct net_local *tp; | 
|  | 139 | static int versionprinted; | 
|  | 140 | const unsigned *port; | 
|  | 141 | int j, err = 0; | 
|  | 142 |  | 
|  | 143 | if (!dev) | 
|  | 144 | return -ENOMEM; | 
|  | 145 |  | 
|  | 146 | SET_MODULE_OWNER(dev); | 
|  | 147 | if (dev->base_addr)	/* probe specific location */ | 
|  | 148 | err = sk_isa_probe1(dev, dev->base_addr); | 
|  | 149 | else { | 
|  | 150 | for (port = portlist; *port; port++) { | 
|  | 151 | err = sk_isa_probe1(dev, *port); | 
|  | 152 | if (!err) | 
|  | 153 | break; | 
|  | 154 | } | 
|  | 155 | } | 
|  | 156 | if (err) | 
| Jochen Friedrich | 504ff16 | 2005-07-27 01:14:50 -0700 | [diff] [blame] | 157 | goto out5; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 |  | 
|  | 159 | /* At this point we have found a valid card. */ | 
|  | 160 |  | 
|  | 161 | if (versionprinted++ == 0) | 
|  | 162 | printk(KERN_DEBUG "%s", version); | 
|  | 163 |  | 
|  | 164 | err = -EIO; | 
| Jochen Friedrich | 504ff16 | 2005-07-27 01:14:50 -0700 | [diff] [blame] | 165 | pdev->dma_mask = &dma_mask; | 
| Jochen Friedrich | 84c3ea0 | 2005-08-19 21:05:56 -0400 | [diff] [blame] | 166 | if (tmsdev_init(dev, pdev)) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 | goto out4; | 
|  | 168 |  | 
|  | 169 | dev->base_addr &= ~3; | 
|  | 170 |  | 
|  | 171 | sk_isa_read_eeprom(dev); | 
|  | 172 |  | 
| Jochen Friedrich | 504ff16 | 2005-07-27 01:14:50 -0700 | [diff] [blame] | 173 | printk(KERN_DEBUG "skisa.c:    Ring Station Address: "); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 174 | printk("%2.2x", dev->dev_addr[0]); | 
|  | 175 | for (j = 1; j < 6; j++) | 
|  | 176 | printk(":%2.2x", dev->dev_addr[j]); | 
|  | 177 | printk("\n"); | 
|  | 178 |  | 
|  | 179 | tp = netdev_priv(dev); | 
|  | 180 | tp->setnselout = sk_isa_setnselout_pins; | 
|  | 181 |  | 
|  | 182 | tp->sifreadb = sk_isa_sifreadb; | 
|  | 183 | tp->sifreadw = sk_isa_sifreadw; | 
|  | 184 | tp->sifwriteb = sk_isa_sifwriteb; | 
|  | 185 | tp->sifwritew = sk_isa_sifwritew; | 
|  | 186 |  | 
|  | 187 | memcpy(tp->ProductID, isa_cardname, PROD_ID_SIZE + 1); | 
|  | 188 |  | 
|  | 189 | tp->tmspriv = NULL; | 
|  | 190 |  | 
|  | 191 | dev->open = sk_isa_open; | 
|  | 192 | dev->stop = tms380tr_close; | 
|  | 193 |  | 
|  | 194 | if (dev->irq == 0) | 
|  | 195 | { | 
|  | 196 | for(j = 0; irqlist[j] != 0; j++) | 
|  | 197 | { | 
|  | 198 | dev->irq = irqlist[j]; | 
|  | 199 | if (!request_irq(dev->irq, tms380tr_interrupt, 0, | 
|  | 200 | isa_cardname, dev)) | 
|  | 201 | break; | 
|  | 202 | } | 
|  | 203 |  | 
|  | 204 | if(irqlist[j] == 0) | 
|  | 205 | { | 
| Jochen Friedrich | 504ff16 | 2005-07-27 01:14:50 -0700 | [diff] [blame] | 206 | printk(KERN_INFO "skisa.c: AutoSelect no IRQ available\n"); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 207 | goto out3; | 
|  | 208 | } | 
|  | 209 | } | 
|  | 210 | else | 
|  | 211 | { | 
|  | 212 | for(j = 0; irqlist[j] != 0; j++) | 
|  | 213 | if (irqlist[j] == dev->irq) | 
|  | 214 | break; | 
|  | 215 | if (irqlist[j] == 0) | 
|  | 216 | { | 
| Jochen Friedrich | 504ff16 | 2005-07-27 01:14:50 -0700 | [diff] [blame] | 217 | printk(KERN_INFO "skisa.c: Illegal IRQ %d specified\n", | 
|  | 218 | dev->irq); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 219 | goto out3; | 
|  | 220 | } | 
|  | 221 | if (request_irq(dev->irq, tms380tr_interrupt, 0, | 
|  | 222 | isa_cardname, dev)) | 
|  | 223 | { | 
| Jochen Friedrich | 504ff16 | 2005-07-27 01:14:50 -0700 | [diff] [blame] | 224 | printk(KERN_INFO "skisa.c: Selected IRQ %d not available\n", | 
|  | 225 | dev->irq); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 226 | goto out3; | 
|  | 227 | } | 
|  | 228 | } | 
|  | 229 |  | 
|  | 230 | if (dev->dma == 0) | 
|  | 231 | { | 
|  | 232 | for(j = 0; dmalist[j] != 0; j++) | 
|  | 233 | { | 
|  | 234 | dev->dma = dmalist[j]; | 
|  | 235 | if (!request_dma(dev->dma, isa_cardname)) | 
|  | 236 | break; | 
|  | 237 | } | 
|  | 238 |  | 
|  | 239 | if(dmalist[j] == 0) | 
|  | 240 | { | 
| Jochen Friedrich | 504ff16 | 2005-07-27 01:14:50 -0700 | [diff] [blame] | 241 | printk(KERN_INFO "skisa.c: AutoSelect no DMA available\n"); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 242 | goto out2; | 
|  | 243 | } | 
|  | 244 | } | 
|  | 245 | else | 
|  | 246 | { | 
|  | 247 | for(j = 0; dmalist[j] != 0; j++) | 
|  | 248 | if (dmalist[j] == dev->dma) | 
|  | 249 | break; | 
|  | 250 | if (dmalist[j] == 0) | 
|  | 251 | { | 
| Jochen Friedrich | 504ff16 | 2005-07-27 01:14:50 -0700 | [diff] [blame] | 252 | printk(KERN_INFO "skisa.c: Illegal DMA %d specified\n", | 
|  | 253 | dev->dma); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 254 | goto out2; | 
|  | 255 | } | 
|  | 256 | if (request_dma(dev->dma, isa_cardname)) | 
|  | 257 | { | 
| Jochen Friedrich | 504ff16 | 2005-07-27 01:14:50 -0700 | [diff] [blame] | 258 | printk(KERN_INFO "skisa.c: Selected DMA %d not available\n", | 
|  | 259 | dev->dma); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 260 | goto out2; | 
|  | 261 | } | 
|  | 262 | } | 
|  | 263 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 264 | err = register_netdev(dev); | 
|  | 265 | if (err) | 
|  | 266 | goto out; | 
|  | 267 |  | 
| Jochen Friedrich | 504ff16 | 2005-07-27 01:14:50 -0700 | [diff] [blame] | 268 | printk(KERN_DEBUG "%s:    IO: %#4lx  IRQ: %d  DMA: %d\n", | 
|  | 269 | dev->name, dev->base_addr, dev->irq, dev->dma); | 
|  | 270 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 271 | return 0; | 
|  | 272 | out: | 
|  | 273 | free_dma(dev->dma); | 
|  | 274 | out2: | 
|  | 275 | free_irq(dev->irq, dev); | 
|  | 276 | out3: | 
|  | 277 | tmsdev_term(dev); | 
|  | 278 | out4: | 
| Jochen Friedrich | 504ff16 | 2005-07-27 01:14:50 -0700 | [diff] [blame] | 279 | release_region(dev->base_addr, SK_ISA_IO_EXTENT); | 
|  | 280 | out5: | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 281 | return err; | 
|  | 282 | } | 
|  | 283 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 284 | /* | 
|  | 285 | * Reads MAC address from adapter RAM, which should've read it from | 
|  | 286 | * the onboard ROM. | 
|  | 287 | * | 
|  | 288 | * Calling this on a board that does not support it can be a very | 
|  | 289 | * dangerous thing.  The Madge board, for instance, will lock your | 
|  | 290 | * machine hard when this is called.  Luckily, its supported in a | 
|  | 291 | * separate driver.  --ASF | 
|  | 292 | */ | 
|  | 293 | static void sk_isa_read_eeprom(struct net_device *dev) | 
|  | 294 | { | 
|  | 295 | int i; | 
|  | 296 |  | 
|  | 297 | /* Address: 0000:0000 */ | 
|  | 298 | sk_isa_sifwritew(dev, 0, SIFADX); | 
|  | 299 | sk_isa_sifwritew(dev, 0, SIFADR); | 
|  | 300 |  | 
|  | 301 | /* Read six byte MAC address data */ | 
|  | 302 | dev->addr_len = 6; | 
|  | 303 | for(i = 0; i < 6; i++) | 
|  | 304 | dev->dev_addr[i] = sk_isa_sifreadw(dev, SIFINC) >> 8; | 
|  | 305 | } | 
|  | 306 |  | 
|  | 307 | unsigned short sk_isa_setnselout_pins(struct net_device *dev) | 
|  | 308 | { | 
|  | 309 | return 0; | 
|  | 310 | } | 
|  | 311 |  | 
|  | 312 | static int sk_isa_open(struct net_device *dev) | 
|  | 313 | { | 
|  | 314 | struct net_local *tp = netdev_priv(dev); | 
|  | 315 | unsigned short val = 0; | 
|  | 316 | unsigned short oldval; | 
|  | 317 | int i; | 
|  | 318 |  | 
|  | 319 | val = 0; | 
|  | 320 | for(i = 0; irqlist[i] != 0; i++) | 
|  | 321 | { | 
|  | 322 | if(irqlist[i] == dev->irq) | 
|  | 323 | break; | 
|  | 324 | } | 
|  | 325 |  | 
|  | 326 | val |= CYCLE_TIME << 2; | 
|  | 327 | val |= i << 4; | 
|  | 328 | i = dev->dma - 5; | 
|  | 329 | val |= i; | 
|  | 330 | if(tp->DataRate == SPEED_4) | 
|  | 331 | val |= LINE_SPEED_BIT; | 
|  | 332 | else | 
|  | 333 | val &= ~LINE_SPEED_BIT; | 
|  | 334 | oldval = sk_isa_sifreadb(dev, POSREG); | 
|  | 335 | /* Leave cycle bits alone */ | 
|  | 336 | oldval |= 0xf3; | 
|  | 337 | val &= oldval; | 
|  | 338 | sk_isa_sifwriteb(dev, val, POSREG); | 
|  | 339 |  | 
|  | 340 | return tms380tr_open(dev); | 
|  | 341 | } | 
|  | 342 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 343 | #define ISATR_MAX_ADAPTERS 3 | 
|  | 344 |  | 
|  | 345 | static int io[ISATR_MAX_ADAPTERS]; | 
|  | 346 | static int irq[ISATR_MAX_ADAPTERS]; | 
|  | 347 | static int dma[ISATR_MAX_ADAPTERS]; | 
|  | 348 |  | 
|  | 349 | MODULE_LICENSE("GPL"); | 
|  | 350 |  | 
|  | 351 | module_param_array(io, int, NULL, 0); | 
|  | 352 | module_param_array(irq, int, NULL, 0); | 
|  | 353 | module_param_array(dma, int, NULL, 0); | 
|  | 354 |  | 
| Jochen Friedrich | 504ff16 | 2005-07-27 01:14:50 -0700 | [diff] [blame] | 355 | static struct platform_device *sk_isa_dev[ISATR_MAX_ADAPTERS]; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 356 |  | 
| Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 357 | static struct platform_driver sk_isa_driver = { | 
|  | 358 | .driver		= { | 
|  | 359 | .name	= "skisa", | 
|  | 360 | }, | 
| Jochen Friedrich | 504ff16 | 2005-07-27 01:14:50 -0700 | [diff] [blame] | 361 | }; | 
|  | 362 |  | 
|  | 363 | static int __init sk_isa_init(void) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 364 | { | 
|  | 365 | struct net_device *dev; | 
| Jochen Friedrich | 504ff16 | 2005-07-27 01:14:50 -0700 | [diff] [blame] | 366 | struct platform_device *pdev; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 367 | int i, num = 0, err = 0; | 
|  | 368 |  | 
| Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 369 | err = platform_driver_register(&sk_isa_driver); | 
| Jochen Friedrich | 504ff16 | 2005-07-27 01:14:50 -0700 | [diff] [blame] | 370 | if (err) | 
|  | 371 | return err; | 
|  | 372 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 373 | for (i = 0; i < ISATR_MAX_ADAPTERS ; i++) { | 
|  | 374 | dev = alloc_trdev(sizeof(struct net_local)); | 
|  | 375 | if (!dev) | 
|  | 376 | continue; | 
|  | 377 |  | 
|  | 378 | dev->base_addr = io[i]; | 
|  | 379 | dev->irq = irq[i]; | 
|  | 380 | dev->dma = dma[i]; | 
| Jochen Friedrich | 504ff16 | 2005-07-27 01:14:50 -0700 | [diff] [blame] | 381 | pdev = platform_device_register_simple("skisa", | 
|  | 382 | i, NULL, 0); | 
|  | 383 | err = setup_card(dev, &pdev->dev); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 384 | if (!err) { | 
| Jochen Friedrich | 504ff16 | 2005-07-27 01:14:50 -0700 | [diff] [blame] | 385 | sk_isa_dev[i] = pdev; | 
| Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 386 | platform_set_drvdata(sk_isa_dev[i], dev); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 387 | ++num; | 
|  | 388 | } else { | 
| Jochen Friedrich | 504ff16 | 2005-07-27 01:14:50 -0700 | [diff] [blame] | 389 | platform_device_unregister(pdev); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 390 | free_netdev(dev); | 
|  | 391 | } | 
|  | 392 | } | 
|  | 393 |  | 
|  | 394 | printk(KERN_NOTICE "skisa.c: %d cards found.\n", num); | 
|  | 395 | /* Probe for cards. */ | 
|  | 396 | if (num == 0) { | 
|  | 397 | printk(KERN_NOTICE "skisa.c: No cards found.\n"); | 
|  | 398 | return (-ENODEV); | 
|  | 399 | } | 
|  | 400 | return (0); | 
|  | 401 | } | 
|  | 402 |  | 
| Jochen Friedrich | 504ff16 | 2005-07-27 01:14:50 -0700 | [diff] [blame] | 403 | static void __exit sk_isa_cleanup(void) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 404 | { | 
| Jochen Friedrich | 504ff16 | 2005-07-27 01:14:50 -0700 | [diff] [blame] | 405 | struct net_device *dev; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 406 | int i; | 
|  | 407 |  | 
|  | 408 | for (i = 0; i < ISATR_MAX_ADAPTERS ; i++) { | 
| Jochen Friedrich | 504ff16 | 2005-07-27 01:14:50 -0700 | [diff] [blame] | 409 | struct platform_device *pdev = sk_isa_dev[i]; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 410 |  | 
| Jochen Friedrich | 504ff16 | 2005-07-27 01:14:50 -0700 | [diff] [blame] | 411 | if (!pdev) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 412 | continue; | 
| Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 413 | dev = platform_get_drvdata(pdev); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 414 | unregister_netdev(dev); | 
|  | 415 | release_region(dev->base_addr, SK_ISA_IO_EXTENT); | 
|  | 416 | free_irq(dev->irq, dev); | 
|  | 417 | free_dma(dev->dma); | 
|  | 418 | tmsdev_term(dev); | 
|  | 419 | free_netdev(dev); | 
| Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 420 | platform_set_drvdata(pdev, NULL); | 
| Jochen Friedrich | 504ff16 | 2005-07-27 01:14:50 -0700 | [diff] [blame] | 421 | platform_device_unregister(pdev); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 422 | } | 
| Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 423 | platform_driver_unregister(&sk_isa_driver); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 424 | } | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 425 |  | 
| Jochen Friedrich | 504ff16 | 2005-07-27 01:14:50 -0700 | [diff] [blame] | 426 | module_init(sk_isa_init); | 
|  | 427 | module_exit(sk_isa_cleanup); |