Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* depca.c: A DIGITAL DEPCA & EtherWORKS ethernet driver for linux. |
| 2 | |
| 3 | Written 1994, 1995 by David C. Davies. |
| 4 | |
| 5 | |
| 6 | Copyright 1994 David C. Davies |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 7 | and |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | United States Government |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 9 | (as represented by the Director, National Security Agency). |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | |
| 11 | Copyright 1995 Digital Equipment Corporation. |
| 12 | |
| 13 | |
| 14 | This software may be used and distributed according to the terms of |
| 15 | the GNU General Public License, incorporated herein by reference. |
| 16 | |
| 17 | This driver is written for the Digital Equipment Corporation series |
| 18 | of DEPCA and EtherWORKS ethernet cards: |
| 19 | |
| 20 | DEPCA (the original) |
| 21 | DE100 |
| 22 | DE101 |
| 23 | DE200 Turbo |
| 24 | DE201 Turbo |
| 25 | DE202 Turbo (TP BNC) |
| 26 | DE210 |
| 27 | DE422 (EISA) |
| 28 | |
| 29 | The driver has been tested on DE100, DE200 and DE202 cards in a |
| 30 | relatively busy network. The DE422 has been tested a little. |
| 31 | |
| 32 | This driver will NOT work for the DE203, DE204 and DE205 series of |
| 33 | cards, since they have a new custom ASIC in place of the AMD LANCE |
| 34 | chip. See the 'ewrk3.c' driver in the Linux source tree for running |
| 35 | those cards. |
| 36 | |
| 37 | I have benchmarked the driver with a DE100 at 595kB/s to (542kB/s from) |
| 38 | a DECstation 5000/200. |
| 39 | |
| 40 | The author may be reached at davies@maniac.ultranet.com |
| 41 | |
| 42 | ========================================================================= |
| 43 | |
| 44 | The driver was originally based on the 'lance.c' driver from Donald |
| 45 | Becker which is included with the standard driver distribution for |
| 46 | linux. V0.4 is a complete re-write with only the kernel interface |
| 47 | remaining from the original code. |
| 48 | |
| 49 | 1) Lance.c code in /linux/drivers/net/ |
| 50 | 2) "Ethernet/IEEE 802.3 Family. 1992 World Network Data Book/Handbook", |
| 51 | AMD, 1992 [(800) 222-9323]. |
| 52 | 3) "Am79C90 CMOS Local Area Network Controller for Ethernet (C-LANCE)", |
| 53 | AMD, Pub. #17881, May 1993. |
| 54 | 4) "Am79C960 PCnet-ISA(tm), Single-Chip Ethernet Controller for ISA", |
| 55 | AMD, Pub. #16907, May 1992 |
| 56 | 5) "DEC EtherWORKS LC Ethernet Controller Owners Manual", |
| 57 | Digital Equipment corporation, 1990, Pub. #EK-DE100-OM.003 |
| 58 | 6) "DEC EtherWORKS Turbo Ethernet Controller Owners Manual", |
| 59 | Digital Equipment corporation, 1990, Pub. #EK-DE200-OM.003 |
| 60 | 7) "DEPCA Hardware Reference Manual", Pub. #EK-DEPCA-PR |
| 61 | Digital Equipment Corporation, 1989 |
| 62 | 8) "DEC EtherWORKS Turbo_(TP BNC) Ethernet Controller Owners Manual", |
| 63 | Digital Equipment corporation, 1991, Pub. #EK-DE202-OM.001 |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 64 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | |
| 66 | Peter Bauer's depca.c (V0.5) was referred to when debugging V0.1 of this |
| 67 | driver. |
| 68 | |
| 69 | The original DEPCA card requires that the ethernet ROM address counter |
| 70 | be enabled to count and has an 8 bit NICSR. The ROM counter enabling is |
| 71 | only done when a 0x08 is read as the first address octet (to minimise |
| 72 | the chances of writing over some other hardware's I/O register). The |
| 73 | NICSR accesses have been changed to byte accesses for all the cards |
| 74 | supported by this driver, since there is only one useful bit in the MSB |
| 75 | (remote boot timeout) and it is not used. Also, there is a maximum of |
| 76 | only 48kB network RAM for this card. My thanks to Torbjorn Lindh for |
| 77 | help debugging all this (and holding my feet to the fire until I got it |
| 78 | right). |
| 79 | |
| 80 | The DE200 series boards have on-board 64kB RAM for use as a shared |
| 81 | memory network buffer. Only the DE100 cards make use of a 2kB buffer |
| 82 | mode which has not been implemented in this driver (only the 32kB and |
| 83 | 64kB modes are supported [16kB/48kB for the original DEPCA]). |
| 84 | |
| 85 | At the most only 2 DEPCA cards can be supported on the ISA bus because |
| 86 | there is only provision for two I/O base addresses on each card (0x300 |
| 87 | and 0x200). The I/O address is detected by searching for a byte sequence |
| 88 | in the Ethernet station address PROM at the expected I/O address for the |
| 89 | Ethernet PROM. The shared memory base address is 'autoprobed' by |
| 90 | looking for the self test PROM and detecting the card name. When a |
| 91 | second DEPCA is detected, information is placed in the base_addr |
| 92 | variable of the next device structure (which is created if necessary), |
| 93 | thus enabling ethif_probe initialization for the device. More than 2 |
| 94 | EISA cards can be supported, but care will be needed assigning the |
| 95 | shared memory to ensure that each slot has the correct IRQ, I/O address |
| 96 | and shared memory address assigned. |
| 97 | |
| 98 | ************************************************************************ |
| 99 | |
| 100 | NOTE: If you are using two ISA DEPCAs, it is important that you assign |
| 101 | the base memory addresses correctly. The driver autoprobes I/O 0x300 |
| 102 | then 0x200. The base memory address for the first device must be less |
| 103 | than that of the second so that the auto probe will correctly assign the |
| 104 | I/O and memory addresses on the same card. I can't think of a way to do |
| 105 | this unambiguously at the moment, since there is nothing on the cards to |
| 106 | tie I/O and memory information together. |
| 107 | |
| 108 | I am unable to test 2 cards together for now, so this code is |
| 109 | unchecked. All reports, good or bad, are welcome. |
| 110 | |
| 111 | ************************************************************************ |
| 112 | |
| 113 | The board IRQ setting must be at an unused IRQ which is auto-probed |
| 114 | using Donald Becker's autoprobe routines. DEPCA and DE100 board IRQs are |
| 115 | {2,3,4,5,7}, whereas the DE200 is at {5,9,10,11,15}. Note that IRQ2 is |
| 116 | really IRQ9 in machines with 16 IRQ lines. |
| 117 | |
| 118 | No 16MB memory limitation should exist with this driver as DMA is not |
| 119 | used and the common memory area is in low memory on the network card (my |
| 120 | current system has 20MB and I've not had problems yet). |
| 121 | |
| 122 | The ability to load this driver as a loadable module has been added. To |
| 123 | utilise this ability, you have to do <8 things: |
| 124 | |
| 125 | 0) have a copy of the loadable modules code installed on your system. |
| 126 | 1) copy depca.c from the /linux/drivers/net directory to your favourite |
| 127 | temporary directory. |
| 128 | 2) if you wish, edit the source code near line 1530 to reflect the I/O |
| 129 | address and IRQ you're using (see also 5). |
| 130 | 3) compile depca.c, but include -DMODULE in the command line to ensure |
| 131 | that the correct bits are compiled (see end of source code). |
| 132 | 4) if you are wanting to add a new card, goto 5. Otherwise, recompile a |
| 133 | kernel with the depca configuration turned off and reboot. |
| 134 | 5) insmod depca.o [irq=7] [io=0x200] [mem=0xd0000] [adapter_name=DE100] |
| 135 | [Alan Cox: Changed the code to allow command line irq/io assignments] |
| 136 | [Dave Davies: Changed the code to allow command line mem/name |
| 137 | assignments] |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 138 | 6) run the net startup bits for your eth?? interface manually |
| 139 | (usually /etc/rc.inet[12] at boot time). |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 140 | 7) enjoy! |
| 141 | |
| 142 | Note that autoprobing is not allowed in loadable modules - the system is |
| 143 | already up and running and you're messing with interrupts. |
| 144 | |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 145 | To unload a module, turn off the associated interface |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | 'ifconfig eth?? down' then 'rmmod depca'. |
| 147 | |
| 148 | To assign a base memory address for the shared memory when running as a |
| 149 | loadable module, see 5 above. To include the adapter name (if you have |
| 150 | no PROM but know the card name) also see 5 above. Note that this last |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 151 | option will not work with kernel built-in depca's. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | |
| 153 | The shared memory assignment for a loadable module makes sense to avoid |
| 154 | the 'memory autoprobe' picking the wrong shared memory (for the case of |
| 155 | 2 depca's in a PC). |
| 156 | |
| 157 | ************************************************************************ |
| 158 | Support for MCA EtherWORKS cards added 11-3-98. |
| 159 | Verified to work with up to 2 DE212 cards in a system (although not |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 160 | fully stress-tested). |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 161 | |
| 162 | Currently known bugs/limitations: |
| 163 | |
| 164 | Note: with the MCA stuff as a module, it trusts the MCA configuration, |
| 165 | not the command line for IRQ and memory address. You can |
| 166 | specify them if you want, but it will throw your values out. |
| 167 | You still have to pass the IO address it was configured as |
| 168 | though. |
| 169 | |
| 170 | ************************************************************************ |
| 171 | TO DO: |
| 172 | ------ |
| 173 | |
| 174 | |
| 175 | Revision History |
| 176 | ---------------- |
| 177 | |
| 178 | Version Date Description |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 179 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 180 | 0.1 25-jan-94 Initial writing. |
| 181 | 0.2 27-jan-94 Added LANCE TX hardware buffer chaining. |
| 182 | 0.3 1-feb-94 Added multiple DEPCA support. |
| 183 | 0.31 4-feb-94 Added DE202 recognition. |
| 184 | 0.32 19-feb-94 Tidy up. Improve multi-DEPCA support. |
| 185 | 0.33 25-feb-94 Fix DEPCA ethernet ROM counter enable. |
| 186 | Add jabber packet fix from murf@perftech.com |
| 187 | and becker@super.org |
| 188 | 0.34 7-mar-94 Fix DEPCA max network memory RAM & NICSR access. |
| 189 | 0.35 8-mar-94 Added DE201 recognition. Tidied up. |
| 190 | 0.351 30-apr-94 Added EISA support. Added DE422 recognition. |
| 191 | 0.36 16-may-94 DE422 fix released. |
| 192 | 0.37 22-jul-94 Added MODULE support |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 193 | 0.38 15-aug-94 Added DBR ROM switch in depca_close(). |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 194 | Multi DEPCA bug fix. |
| 195 | 0.38axp 15-sep-94 Special version for Alpha AXP Linux V1.0. |
| 196 | 0.381 12-dec-94 Added DE101 recognition, fix multicast bug. |
| 197 | 0.382 9-feb-95 Fix recognition bug reported by <bkm@star.rl.ac.uk>. |
| 198 | 0.383 22-feb-95 Fix for conflict with VESA SCSI reported by |
| 199 | <stromain@alf.dec.com> |
| 200 | 0.384 17-mar-95 Fix a ring full bug reported by <bkm@star.rl.ac.uk> |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 201 | 0.385 3-apr-95 Fix a recognition bug reported by |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 202 | <ryan.niemi@lastfrontier.com> |
| 203 | 0.386 21-apr-95 Fix the last fix...sorry, must be galloping senility |
| 204 | 0.40 25-May-95 Rewrite for portability & updated. |
| 205 | ALPHA support from <jestabro@amt.tay1.dec.com> |
| 206 | 0.41 26-Jun-95 Added verify_area() calls in depca_ioctl() from |
| 207 | suggestion by <heiko@colossus.escape.de> |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 208 | 0.42 27-Dec-95 Add 'mem' shared memory assignment for loadable |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 209 | modules. |
| 210 | Add 'adapter_name' for loadable modules when no PROM. |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 211 | Both above from a suggestion by |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 212 | <pchen@woodruffs121.residence.gatech.edu>. |
| 213 | Add new multicasting code. |
| 214 | 0.421 22-Apr-96 Fix alloc_device() bug <jari@markkus2.fimr.fi> |
| 215 | 0.422 29-Apr-96 Fix depca_hw_init() bug <jari@markkus2.fimr.fi> |
| 216 | 0.423 7-Jun-96 Fix module load bug <kmg@barco.be> |
| 217 | 0.43 16-Aug-96 Update alloc_device() to conform to de4x5.c |
| 218 | 0.44 1-Sep-97 Fix *_probe() to test check_region() first - bug |
| 219 | reported by <mmogilvi@elbert.uccs.edu> |
| 220 | 0.45 3-Nov-98 Added support for MCA EtherWORKS (DE210/DE212) cards |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 221 | by <tymm@computer.org> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 222 | 0.451 5-Nov-98 Fixed mca stuff cuz I'm a dummy. <tymm@computer.org> |
| 223 | 0.5 14-Nov-98 Re-spin for 2.1.x kernels. |
| 224 | 0.51 27-Jun-99 Correct received packet length for CRC from |
| 225 | report by <worm@dkik.dk> |
| 226 | 0.52 16-Oct-00 Fixes for 2.3 io memory accesses |
| 227 | Fix show-stopper (ints left masked) in depca_interrupt |
| 228 | by <peterd@pnd-pc.demon.co.uk> |
| 229 | 0.53 12-Jan-01 Release resources on failure, bss tidbits |
| 230 | by acme@conectiva.com.br |
| 231 | 0.54 08-Nov-01 use library crc32 functions |
| 232 | by Matt_Domsch@dell.com |
| 233 | 0.55 01-Mar-03 Use EISA/sysfs framework <maz@wild-wind.fr.eu.org> |
| 234 | |
| 235 | ========================================================================= |
| 236 | */ |
| 237 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 238 | #include <linux/module.h> |
| 239 | #include <linux/kernel.h> |
| 240 | #include <linux/string.h> |
| 241 | #include <linux/errno.h> |
| 242 | #include <linux/ioport.h> |
| 243 | #include <linux/slab.h> |
| 244 | #include <linux/interrupt.h> |
| 245 | #include <linux/delay.h> |
| 246 | #include <linux/init.h> |
| 247 | #include <linux/crc32.h> |
| 248 | #include <linux/netdevice.h> |
| 249 | #include <linux/etherdevice.h> |
| 250 | #include <linux/skbuff.h> |
| 251 | #include <linux/time.h> |
| 252 | #include <linux/types.h> |
| 253 | #include <linux/unistd.h> |
| 254 | #include <linux/ctype.h> |
| 255 | #include <linux/moduleparam.h> |
Russell King | d052d1b | 2005-10-29 19:07:23 +0100 | [diff] [blame] | 256 | #include <linux/platform_device.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 257 | #include <linux/bitops.h> |
| 258 | |
| 259 | #include <asm/uaccess.h> |
| 260 | #include <asm/io.h> |
| 261 | #include <asm/dma.h> |
| 262 | |
| 263 | #ifdef CONFIG_MCA |
| 264 | #include <linux/mca.h> |
| 265 | #endif |
| 266 | |
| 267 | #ifdef CONFIG_EISA |
| 268 | #include <linux/eisa.h> |
| 269 | #endif |
| 270 | |
| 271 | #include "depca.h" |
| 272 | |
| 273 | static char version[] __initdata = "depca.c:v0.53 2001/1/12 davies@maniac.ultranet.com\n"; |
| 274 | |
| 275 | #ifdef DEPCA_DEBUG |
| 276 | static int depca_debug = DEPCA_DEBUG; |
| 277 | #else |
| 278 | static int depca_debug = 1; |
| 279 | #endif |
| 280 | |
| 281 | #define DEPCA_NDA 0xffe0 /* No Device Address */ |
| 282 | |
| 283 | #define TX_TIMEOUT (1*HZ) |
| 284 | |
| 285 | /* |
| 286 | ** Ethernet PROM defines |
| 287 | */ |
| 288 | #define PROBE_LENGTH 32 |
| 289 | #define ETH_PROM_SIG 0xAA5500FFUL |
| 290 | |
| 291 | /* |
| 292 | ** Set the number of Tx and Rx buffers. Ensure that the memory requested |
| 293 | ** here is <= to the amount of shared memory set up by the board switches. |
| 294 | ** The number of descriptors MUST BE A POWER OF 2. |
| 295 | ** |
| 296 | ** total_memory = NUM_RX_DESC*(8+RX_BUFF_SZ) + NUM_TX_DESC*(8+TX_BUFF_SZ) |
| 297 | */ |
| 298 | #define NUM_RX_DESC 8 /* Number of RX descriptors */ |
| 299 | #define NUM_TX_DESC 8 /* Number of TX descriptors */ |
| 300 | #define RX_BUFF_SZ 1536 /* Buffer size for each Rx buffer */ |
| 301 | #define TX_BUFF_SZ 1536 /* Buffer size for each Tx buffer */ |
| 302 | |
| 303 | /* |
| 304 | ** EISA bus defines |
| 305 | */ |
| 306 | #define DEPCA_EISA_IO_PORTS 0x0c00 /* I/O port base address, slot 0 */ |
| 307 | |
| 308 | /* |
| 309 | ** ISA Bus defines |
| 310 | */ |
| 311 | #define DEPCA_RAM_BASE_ADDRESSES {0xc0000,0xd0000,0xe0000,0x00000} |
| 312 | #define DEPCA_TOTAL_SIZE 0x10 |
| 313 | |
| 314 | static struct { |
| 315 | u_long iobase; |
| 316 | struct platform_device *device; |
| 317 | } depca_io_ports[] = { |
| 318 | { 0x300, NULL }, |
| 319 | { 0x200, NULL }, |
| 320 | { 0 , NULL }, |
| 321 | }; |
| 322 | |
| 323 | /* |
| 324 | ** Name <-> Adapter mapping |
| 325 | */ |
| 326 | #define DEPCA_SIGNATURE {"DEPCA",\ |
| 327 | "DE100","DE101",\ |
| 328 | "DE200","DE201","DE202",\ |
| 329 | "DE210","DE212",\ |
| 330 | "DE422",\ |
| 331 | ""} |
| 332 | |
| 333 | static char* __initdata depca_signature[] = DEPCA_SIGNATURE; |
| 334 | |
| 335 | enum depca_type { |
| 336 | DEPCA, de100, de101, de200, de201, de202, de210, de212, de422, unknown |
| 337 | }; |
| 338 | |
| 339 | static char depca_string[] = "depca"; |
| 340 | |
| 341 | static int depca_device_remove (struct device *device); |
| 342 | |
| 343 | #ifdef CONFIG_EISA |
| 344 | static struct eisa_device_id depca_eisa_ids[] = { |
| 345 | { "DEC4220", de422 }, |
| 346 | { "" } |
| 347 | }; |
| 348 | MODULE_DEVICE_TABLE(eisa, depca_eisa_ids); |
| 349 | |
| 350 | static int depca_eisa_probe (struct device *device); |
| 351 | |
| 352 | static struct eisa_driver depca_eisa_driver = { |
| 353 | .id_table = depca_eisa_ids, |
| 354 | .driver = { |
| 355 | .name = depca_string, |
| 356 | .probe = depca_eisa_probe, |
| 357 | .remove = __devexit_p (depca_device_remove) |
| 358 | } |
| 359 | }; |
| 360 | #endif |
| 361 | |
| 362 | #ifdef CONFIG_MCA |
| 363 | /* |
| 364 | ** Adapter ID for the MCA EtherWORKS DE210/212 adapter |
| 365 | */ |
| 366 | #define DE210_ID 0x628d |
| 367 | #define DE212_ID 0x6def |
| 368 | |
| 369 | static short depca_mca_adapter_ids[] = { |
| 370 | DE210_ID, |
| 371 | DE212_ID, |
| 372 | 0x0000 |
| 373 | }; |
| 374 | |
| 375 | static char *depca_mca_adapter_name[] = { |
| 376 | "DEC EtherWORKS MC Adapter (DE210)", |
| 377 | "DEC EtherWORKS MC Adapter (DE212)", |
| 378 | NULL |
| 379 | }; |
| 380 | |
| 381 | static enum depca_type depca_mca_adapter_type[] = { |
| 382 | de210, |
| 383 | de212, |
| 384 | 0 |
| 385 | }; |
| 386 | |
| 387 | static int depca_mca_probe (struct device *); |
| 388 | |
| 389 | static struct mca_driver depca_mca_driver = { |
| 390 | .id_table = depca_mca_adapter_ids, |
| 391 | .driver = { |
| 392 | .name = depca_string, |
| 393 | .bus = &mca_bus_type, |
| 394 | .probe = depca_mca_probe, |
| 395 | .remove = __devexit_p(depca_device_remove), |
| 396 | }, |
| 397 | }; |
| 398 | #endif |
| 399 | |
Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 400 | static int depca_isa_probe (struct platform_device *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 401 | |
Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 402 | static int __devexit depca_isa_remove(struct platform_device *pdev) |
| 403 | { |
| 404 | return depca_device_remove(&pdev->dev); |
| 405 | } |
| 406 | |
| 407 | static struct platform_driver depca_isa_driver = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 408 | .probe = depca_isa_probe, |
Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 409 | .remove = __devexit_p(depca_isa_remove), |
| 410 | .driver = { |
| 411 | .name = depca_string, |
| 412 | }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 413 | }; |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 414 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 415 | /* |
| 416 | ** Miscellaneous info... |
| 417 | */ |
| 418 | #define DEPCA_STRLEN 16 |
| 419 | |
| 420 | /* |
| 421 | ** Memory Alignment. Each descriptor is 4 longwords long. To force a |
| 422 | ** particular alignment on the TX descriptor, adjust DESC_SKIP_LEN and |
| 423 | ** DESC_ALIGN. DEPCA_ALIGN aligns the start address of the private memory area |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 424 | ** and hence the RX descriptor ring's first entry. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 425 | */ |
| 426 | #define DEPCA_ALIGN4 ((u_long)4 - 1) /* 1 longword align */ |
| 427 | #define DEPCA_ALIGN8 ((u_long)8 - 1) /* 2 longword (quadword) align */ |
| 428 | #define DEPCA_ALIGN DEPCA_ALIGN8 /* Keep the LANCE happy... */ |
| 429 | |
| 430 | /* |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 431 | ** The DEPCA Rx and Tx ring descriptors. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 432 | */ |
| 433 | struct depca_rx_desc { |
| 434 | volatile s32 base; |
| 435 | s16 buf_length; /* This length is negative 2's complement! */ |
| 436 | s16 msg_length; /* This length is "normal". */ |
| 437 | }; |
| 438 | |
| 439 | struct depca_tx_desc { |
| 440 | volatile s32 base; |
| 441 | s16 length; /* This length is negative 2's complement! */ |
| 442 | s16 misc; /* Errors and TDR info */ |
| 443 | }; |
| 444 | |
| 445 | #define LA_MASK 0x0000ffff /* LANCE address mask for mapping network RAM |
| 446 | to LANCE memory address space */ |
| 447 | |
| 448 | /* |
| 449 | ** The Lance initialization block, described in databook, in common memory. |
| 450 | */ |
| 451 | struct depca_init { |
| 452 | u16 mode; /* Mode register */ |
| 453 | u8 phys_addr[ETH_ALEN]; /* Physical ethernet address */ |
| 454 | u8 mcast_table[8]; /* Multicast Hash Table. */ |
| 455 | u32 rx_ring; /* Rx ring base pointer & ring length */ |
| 456 | u32 tx_ring; /* Tx ring base pointer & ring length */ |
| 457 | }; |
| 458 | |
| 459 | #define DEPCA_PKT_STAT_SZ 16 |
| 460 | #define DEPCA_PKT_BIN_SZ 128 /* Should be >=100 unless you |
| 461 | increase DEPCA_PKT_STAT_SZ */ |
| 462 | struct depca_private { |
| 463 | char adapter_name[DEPCA_STRLEN]; /* /proc/ioports string */ |
| 464 | enum depca_type adapter; /* Adapter type */ |
| 465 | enum { |
| 466 | DEPCA_BUS_MCA = 1, |
| 467 | DEPCA_BUS_ISA, |
| 468 | DEPCA_BUS_EISA, |
| 469 | } depca_bus; /* type of bus */ |
| 470 | struct depca_init init_block; /* Shadow Initialization block */ |
| 471 | /* CPU address space fields */ |
| 472 | struct depca_rx_desc __iomem *rx_ring; /* Pointer to start of RX descriptor ring */ |
| 473 | struct depca_tx_desc __iomem *tx_ring; /* Pointer to start of TX descriptor ring */ |
| 474 | void __iomem *rx_buff[NUM_RX_DESC]; /* CPU virt address of sh'd memory buffs */ |
| 475 | void __iomem *tx_buff[NUM_TX_DESC]; /* CPU virt address of sh'd memory buffs */ |
| 476 | void __iomem *sh_mem; /* CPU mapped virt address of device RAM */ |
| 477 | u_long mem_start; /* Bus address of device RAM (before remap) */ |
| 478 | u_long mem_len; /* device memory size */ |
| 479 | /* Device address space fields */ |
| 480 | u_long device_ram_start; /* Start of RAM in device addr space */ |
| 481 | /* Offsets used in both address spaces */ |
| 482 | u_long rx_ring_offset; /* Offset from start of RAM to rx_ring */ |
| 483 | u_long tx_ring_offset; /* Offset from start of RAM to tx_ring */ |
| 484 | u_long buffs_offset; /* LANCE Rx and Tx buffers start address. */ |
| 485 | /* Kernel-only (not device) fields */ |
| 486 | int rx_new, tx_new; /* The next free ring entry */ |
| 487 | int rx_old, tx_old; /* The ring entries to be free()ed. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 488 | spinlock_t lock; |
| 489 | struct { /* Private stats counters */ |
| 490 | u32 bins[DEPCA_PKT_STAT_SZ]; |
| 491 | u32 unicast; |
| 492 | u32 multicast; |
| 493 | u32 broadcast; |
| 494 | u32 excessive_collisions; |
| 495 | u32 tx_underruns; |
| 496 | u32 excessive_underruns; |
| 497 | } pktStats; |
| 498 | int txRingMask; /* TX ring mask */ |
| 499 | int rxRingMask; /* RX ring mask */ |
| 500 | s32 rx_rlen; /* log2(rxRingMask+1) for the descriptors */ |
| 501 | s32 tx_rlen; /* log2(txRingMask+1) for the descriptors */ |
| 502 | }; |
| 503 | |
| 504 | /* |
| 505 | ** The transmit ring full condition is described by the tx_old and tx_new |
| 506 | ** pointers by: |
| 507 | ** tx_old = tx_new Empty ring |
| 508 | ** tx_old = tx_new+1 Full ring |
| 509 | ** tx_old+txRingMask = tx_new Full ring (wrapped condition) |
| 510 | */ |
| 511 | #define TX_BUFFS_AVAIL ((lp->tx_old<=lp->tx_new)?\ |
| 512 | lp->tx_old+lp->txRingMask-lp->tx_new:\ |
| 513 | lp->tx_old -lp->tx_new-1) |
| 514 | |
| 515 | /* |
| 516 | ** Public Functions |
| 517 | */ |
| 518 | static int depca_open(struct net_device *dev); |
| 519 | static int depca_start_xmit(struct sk_buff *skb, struct net_device *dev); |
David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 520 | static irqreturn_t depca_interrupt(int irq, void *dev_id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 521 | static int depca_close(struct net_device *dev); |
| 522 | static int depca_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); |
| 523 | static void depca_tx_timeout(struct net_device *dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 524 | static void set_multicast_list(struct net_device *dev); |
| 525 | |
| 526 | /* |
| 527 | ** Private functions |
| 528 | */ |
| 529 | static void depca_init_ring(struct net_device *dev); |
| 530 | static int depca_rx(struct net_device *dev); |
| 531 | static int depca_tx(struct net_device *dev); |
| 532 | |
| 533 | static void LoadCSRs(struct net_device *dev); |
| 534 | static int InitRestartDepca(struct net_device *dev); |
| 535 | static int DepcaSignature(char *name, u_long paddr); |
| 536 | static int DevicePresent(u_long ioaddr); |
| 537 | static int get_hw_addr(struct net_device *dev); |
| 538 | static void SetMulticastFilter(struct net_device *dev); |
| 539 | static int load_packet(struct net_device *dev, struct sk_buff *skb); |
| 540 | static void depca_dbg_open(struct net_device *dev); |
| 541 | |
| 542 | static u_char de1xx_irq[] __initdata = { 2, 3, 4, 5, 7, 9, 0 }; |
| 543 | static u_char de2xx_irq[] __initdata = { 5, 9, 10, 11, 15, 0 }; |
| 544 | static u_char de422_irq[] __initdata = { 5, 9, 10, 11, 0 }; |
| 545 | static u_char *depca_irq; |
| 546 | |
| 547 | static int irq; |
| 548 | static int io; |
| 549 | static char *adapter_name; |
| 550 | static int mem; /* For loadable module assignment |
| 551 | use insmod mem=0x????? .... */ |
| 552 | module_param (irq, int, 0); |
| 553 | module_param (io, int, 0); |
| 554 | module_param (adapter_name, charp, 0); |
| 555 | module_param (mem, int, 0); |
| 556 | MODULE_PARM_DESC(irq, "DEPCA IRQ number"); |
| 557 | MODULE_PARM_DESC(io, "DEPCA I/O base address"); |
| 558 | MODULE_PARM_DESC(adapter_name, "DEPCA adapter name"); |
| 559 | MODULE_PARM_DESC(mem, "DEPCA shared memory address"); |
| 560 | MODULE_LICENSE("GPL"); |
| 561 | |
| 562 | /* |
| 563 | ** Miscellaneous defines... |
| 564 | */ |
| 565 | #define STOP_DEPCA \ |
| 566 | outw(CSR0, DEPCA_ADDR);\ |
| 567 | outw(STOP, DEPCA_DATA) |
| 568 | |
| 569 | static int __init depca_hw_init (struct net_device *dev, struct device *device) |
| 570 | { |
| 571 | struct depca_private *lp; |
| 572 | int i, j, offset, netRAM, mem_len, status = 0; |
| 573 | s16 nicsr; |
| 574 | u_long ioaddr; |
| 575 | u_long mem_start; |
Joe Perches | 0795af5 | 2007-10-03 17:59:30 -0700 | [diff] [blame] | 576 | DECLARE_MAC_BUF(mac); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 577 | |
| 578 | /* |
| 579 | * We are now supposed to enter this function with the |
| 580 | * following fields filled with proper values : |
| 581 | * |
| 582 | * dev->base_addr |
| 583 | * lp->mem_start |
| 584 | * lp->depca_bus |
| 585 | * lp->adapter |
| 586 | * |
| 587 | * dev->irq can be set if known from device configuration (on |
| 588 | * MCA or EISA) or module option. Otherwise, it will be auto |
| 589 | * detected. |
| 590 | */ |
| 591 | |
| 592 | ioaddr = dev->base_addr; |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 593 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 594 | STOP_DEPCA; |
| 595 | |
| 596 | nicsr = inb(DEPCA_NICSR); |
| 597 | nicsr = ((nicsr & ~SHE & ~RBE & ~IEN) | IM); |
| 598 | outb(nicsr, DEPCA_NICSR); |
| 599 | |
| 600 | if (inw(DEPCA_DATA) != STOP) { |
| 601 | return -ENXIO; |
| 602 | } |
| 603 | |
| 604 | lp = (struct depca_private *) dev->priv; |
| 605 | mem_start = lp->mem_start; |
| 606 | |
| 607 | if (!mem_start || lp->adapter < DEPCA || lp->adapter >=unknown) |
| 608 | return -ENXIO; |
| 609 | |
| 610 | printk ("%s: %s at 0x%04lx", |
| 611 | device->bus_id, depca_signature[lp->adapter], ioaddr); |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 612 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 613 | switch (lp->depca_bus) { |
| 614 | #ifdef CONFIG_MCA |
| 615 | case DEPCA_BUS_MCA: |
| 616 | printk(" (MCA slot %d)", to_mca_device(device)->slot + 1); |
| 617 | break; |
| 618 | #endif |
| 619 | |
| 620 | #ifdef CONFIG_EISA |
| 621 | case DEPCA_BUS_EISA: |
| 622 | printk(" (EISA slot %d)", to_eisa_device(device)->slot); |
| 623 | break; |
| 624 | #endif |
| 625 | |
| 626 | case DEPCA_BUS_ISA: |
| 627 | break; |
| 628 | |
| 629 | default: |
| 630 | printk("Unknown DEPCA bus %d\n", lp->depca_bus); |
| 631 | return -ENXIO; |
| 632 | } |
| 633 | |
| 634 | printk(", h/w address "); |
| 635 | status = get_hw_addr(dev); |
Joe Perches | 0795af5 | 2007-10-03 17:59:30 -0700 | [diff] [blame] | 636 | printk("%s", print_mac(mac, dev->dev_addr)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 637 | if (status != 0) { |
| 638 | printk(" which has an Ethernet PROM CRC error.\n"); |
| 639 | return -ENXIO; |
| 640 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 641 | |
| 642 | /* Set up the maximum amount of network RAM(kB) */ |
| 643 | netRAM = ((lp->adapter != DEPCA) ? 64 : 48); |
| 644 | if ((nicsr & _128KB) && (lp->adapter == de422)) |
| 645 | netRAM = 128; |
| 646 | |
| 647 | /* Shared Memory Base Address */ |
| 648 | if (nicsr & BUF) { |
| 649 | nicsr &= ~BS; /* DEPCA RAM in top 32k */ |
| 650 | netRAM -= 32; |
| 651 | |
| 652 | /* Only EISA/ISA needs start address to be re-computed */ |
| 653 | if (lp->depca_bus != DEPCA_BUS_MCA) |
| 654 | mem_start += 0x8000; |
| 655 | } |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 656 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 657 | if ((mem_len = (NUM_RX_DESC * (sizeof(struct depca_rx_desc) + RX_BUFF_SZ) + NUM_TX_DESC * (sizeof(struct depca_tx_desc) + TX_BUFF_SZ) + sizeof(struct depca_init))) |
| 658 | > (netRAM << 10)) { |
| 659 | printk(",\n requests %dkB RAM: only %dkB is available!\n", (mem_len >> 10), netRAM); |
| 660 | return -ENXIO; |
| 661 | } |
| 662 | |
| 663 | printk(",\n has %dkB RAM at 0x%.5lx", netRAM, mem_start); |
| 664 | |
| 665 | /* Enable the shadow RAM. */ |
| 666 | if (lp->adapter != DEPCA) { |
| 667 | nicsr |= SHE; |
| 668 | outb(nicsr, DEPCA_NICSR); |
| 669 | } |
| 670 | |
| 671 | spin_lock_init(&lp->lock); |
| 672 | sprintf(lp->adapter_name, "%s (%s)", |
| 673 | depca_signature[lp->adapter], device->bus_id); |
| 674 | status = -EBUSY; |
| 675 | |
| 676 | /* Initialisation Block */ |
| 677 | if (!request_mem_region (mem_start, mem_len, lp->adapter_name)) { |
| 678 | printk(KERN_ERR "depca: cannot request ISA memory, aborting\n"); |
| 679 | goto out_priv; |
| 680 | } |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 681 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 682 | status = -EIO; |
| 683 | lp->sh_mem = ioremap(mem_start, mem_len); |
| 684 | if (lp->sh_mem == NULL) { |
| 685 | printk(KERN_ERR "depca: cannot remap ISA memory, aborting\n"); |
| 686 | goto out1; |
| 687 | } |
| 688 | |
| 689 | lp->mem_start = mem_start; |
| 690 | lp->mem_len = mem_len; |
| 691 | lp->device_ram_start = mem_start & LA_MASK; |
| 692 | |
| 693 | offset = 0; |
| 694 | offset += sizeof(struct depca_init); |
| 695 | |
| 696 | /* Tx & Rx descriptors (aligned to a quadword boundary) */ |
| 697 | offset = (offset + DEPCA_ALIGN) & ~DEPCA_ALIGN; |
| 698 | lp->rx_ring = (struct depca_rx_desc __iomem *) (lp->sh_mem + offset); |
| 699 | lp->rx_ring_offset = offset; |
| 700 | |
| 701 | offset += (sizeof(struct depca_rx_desc) * NUM_RX_DESC); |
| 702 | lp->tx_ring = (struct depca_tx_desc __iomem *) (lp->sh_mem + offset); |
| 703 | lp->tx_ring_offset = offset; |
| 704 | |
| 705 | offset += (sizeof(struct depca_tx_desc) * NUM_TX_DESC); |
| 706 | |
| 707 | lp->buffs_offset = offset; |
| 708 | |
| 709 | /* Finish initialising the ring information. */ |
| 710 | lp->rxRingMask = NUM_RX_DESC - 1; |
| 711 | lp->txRingMask = NUM_TX_DESC - 1; |
| 712 | |
| 713 | /* Calculate Tx/Rx RLEN size for the descriptors. */ |
| 714 | for (i = 0, j = lp->rxRingMask; j > 0; i++) { |
| 715 | j >>= 1; |
| 716 | } |
| 717 | lp->rx_rlen = (s32) (i << 29); |
| 718 | for (i = 0, j = lp->txRingMask; j > 0; i++) { |
| 719 | j >>= 1; |
| 720 | } |
| 721 | lp->tx_rlen = (s32) (i << 29); |
| 722 | |
| 723 | /* Load the initialisation block */ |
| 724 | depca_init_ring(dev); |
| 725 | |
| 726 | /* Initialise the control and status registers */ |
| 727 | LoadCSRs(dev); |
| 728 | |
| 729 | /* Enable DEPCA board interrupts for autoprobing */ |
| 730 | nicsr = ((nicsr & ~IM) | IEN); |
| 731 | outb(nicsr, DEPCA_NICSR); |
| 732 | |
| 733 | /* To auto-IRQ we enable the initialization-done and DMA err, |
| 734 | interrupts. For now we will always get a DMA error. */ |
| 735 | if (dev->irq < 2) { |
| 736 | unsigned char irqnum; |
| 737 | unsigned long irq_mask, delay; |
| 738 | |
| 739 | irq_mask = probe_irq_on(); |
| 740 | |
| 741 | /* Assign the correct irq list */ |
| 742 | switch (lp->adapter) { |
| 743 | case DEPCA: |
| 744 | case de100: |
| 745 | case de101: |
| 746 | depca_irq = de1xx_irq; |
| 747 | break; |
| 748 | case de200: |
| 749 | case de201: |
| 750 | case de202: |
| 751 | case de210: |
| 752 | case de212: |
| 753 | depca_irq = de2xx_irq; |
| 754 | break; |
| 755 | case de422: |
| 756 | depca_irq = de422_irq; |
| 757 | break; |
| 758 | |
| 759 | default: |
| 760 | break; /* Not reached */ |
| 761 | } |
| 762 | |
| 763 | /* Trigger an initialization just for the interrupt. */ |
| 764 | outw(INEA | INIT, DEPCA_DATA); |
| 765 | |
| 766 | delay = jiffies + HZ/50; |
| 767 | while (time_before(jiffies, delay)) |
| 768 | yield(); |
| 769 | |
| 770 | irqnum = probe_irq_off(irq_mask); |
| 771 | |
| 772 | status = -ENXIO; |
| 773 | if (!irqnum) { |
| 774 | printk(" and failed to detect IRQ line.\n"); |
| 775 | goto out2; |
| 776 | } else { |
| 777 | for (dev->irq = 0, i = 0; (depca_irq[i]) && (!dev->irq); i++) |
| 778 | if (irqnum == depca_irq[i]) { |
| 779 | dev->irq = irqnum; |
| 780 | printk(" and uses IRQ%d.\n", dev->irq); |
| 781 | } |
| 782 | |
| 783 | if (!dev->irq) { |
| 784 | printk(" but incorrect IRQ line detected.\n"); |
| 785 | goto out2; |
| 786 | } |
| 787 | } |
| 788 | } else { |
| 789 | printk(" and assigned IRQ%d.\n", dev->irq); |
| 790 | } |
| 791 | |
| 792 | if (depca_debug > 1) { |
| 793 | printk(version); |
| 794 | } |
| 795 | |
| 796 | /* The DEPCA-specific entries in the device structure. */ |
| 797 | dev->open = &depca_open; |
| 798 | dev->hard_start_xmit = &depca_start_xmit; |
| 799 | dev->stop = &depca_close; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 800 | dev->set_multicast_list = &set_multicast_list; |
| 801 | dev->do_ioctl = &depca_ioctl; |
| 802 | dev->tx_timeout = depca_tx_timeout; |
| 803 | dev->watchdog_timeo = TX_TIMEOUT; |
| 804 | |
| 805 | dev->mem_start = 0; |
| 806 | |
| 807 | device->driver_data = dev; |
| 808 | SET_NETDEV_DEV (dev, device); |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 809 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 810 | status = register_netdev(dev); |
| 811 | if (status == 0) |
| 812 | return 0; |
| 813 | out2: |
| 814 | iounmap(lp->sh_mem); |
| 815 | out1: |
| 816 | release_mem_region (mem_start, mem_len); |
| 817 | out_priv: |
| 818 | return status; |
| 819 | } |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 820 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 821 | |
| 822 | static int depca_open(struct net_device *dev) |
| 823 | { |
| 824 | struct depca_private *lp = (struct depca_private *) dev->priv; |
| 825 | u_long ioaddr = dev->base_addr; |
| 826 | s16 nicsr; |
| 827 | int status = 0; |
| 828 | |
| 829 | STOP_DEPCA; |
| 830 | nicsr = inb(DEPCA_NICSR); |
| 831 | |
| 832 | /* Make sure the shadow RAM is enabled */ |
| 833 | if (lp->adapter != DEPCA) { |
| 834 | nicsr |= SHE; |
| 835 | outb(nicsr, DEPCA_NICSR); |
| 836 | } |
| 837 | |
| 838 | /* Re-initialize the DEPCA... */ |
| 839 | depca_init_ring(dev); |
| 840 | LoadCSRs(dev); |
| 841 | |
| 842 | depca_dbg_open(dev); |
| 843 | |
| 844 | if (request_irq(dev->irq, &depca_interrupt, 0, lp->adapter_name, dev)) { |
| 845 | printk("depca_open(): Requested IRQ%d is busy\n", dev->irq); |
| 846 | status = -EAGAIN; |
| 847 | } else { |
| 848 | |
| 849 | /* Enable DEPCA board interrupts and turn off LED */ |
| 850 | nicsr = ((nicsr & ~IM & ~LED) | IEN); |
| 851 | outb(nicsr, DEPCA_NICSR); |
| 852 | outw(CSR0, DEPCA_ADDR); |
| 853 | |
| 854 | netif_start_queue(dev); |
| 855 | |
| 856 | status = InitRestartDepca(dev); |
| 857 | |
| 858 | if (depca_debug > 1) { |
| 859 | printk("CSR0: 0x%4.4x\n", inw(DEPCA_DATA)); |
| 860 | printk("nicsr: 0x%02x\n", inb(DEPCA_NICSR)); |
| 861 | } |
| 862 | } |
| 863 | return status; |
| 864 | } |
| 865 | |
| 866 | /* Initialize the lance Rx and Tx descriptor rings. */ |
| 867 | static void depca_init_ring(struct net_device *dev) |
| 868 | { |
| 869 | struct depca_private *lp = (struct depca_private *) dev->priv; |
| 870 | u_int i; |
| 871 | u_long offset; |
| 872 | |
| 873 | /* Lock out other processes whilst setting up the hardware */ |
| 874 | netif_stop_queue(dev); |
| 875 | |
| 876 | lp->rx_new = lp->tx_new = 0; |
| 877 | lp->rx_old = lp->tx_old = 0; |
| 878 | |
| 879 | /* Initialize the base address and length of each buffer in the ring */ |
| 880 | for (i = 0; i <= lp->rxRingMask; i++) { |
| 881 | offset = lp->buffs_offset + i * RX_BUFF_SZ; |
| 882 | writel((lp->device_ram_start + offset) | R_OWN, &lp->rx_ring[i].base); |
| 883 | writew(-RX_BUFF_SZ, &lp->rx_ring[i].buf_length); |
| 884 | lp->rx_buff[i] = lp->sh_mem + offset; |
| 885 | } |
| 886 | |
| 887 | for (i = 0; i <= lp->txRingMask; i++) { |
| 888 | offset = lp->buffs_offset + (i + lp->rxRingMask + 1) * TX_BUFF_SZ; |
| 889 | writel((lp->device_ram_start + offset) & 0x00ffffff, &lp->tx_ring[i].base); |
| 890 | lp->tx_buff[i] = lp->sh_mem + offset; |
| 891 | } |
| 892 | |
| 893 | /* Set up the initialization block */ |
| 894 | lp->init_block.rx_ring = (lp->device_ram_start + lp->rx_ring_offset) | lp->rx_rlen; |
| 895 | lp->init_block.tx_ring = (lp->device_ram_start + lp->tx_ring_offset) | lp->tx_rlen; |
| 896 | |
| 897 | SetMulticastFilter(dev); |
| 898 | |
| 899 | for (i = 0; i < ETH_ALEN; i++) { |
| 900 | lp->init_block.phys_addr[i] = dev->dev_addr[i]; |
| 901 | } |
| 902 | |
| 903 | lp->init_block.mode = 0x0000; /* Enable the Tx and Rx */ |
| 904 | } |
| 905 | |
| 906 | |
| 907 | static void depca_tx_timeout(struct net_device *dev) |
| 908 | { |
| 909 | u_long ioaddr = dev->base_addr; |
| 910 | |
| 911 | printk("%s: transmit timed out, status %04x, resetting.\n", dev->name, inw(DEPCA_DATA)); |
| 912 | |
| 913 | STOP_DEPCA; |
| 914 | depca_init_ring(dev); |
| 915 | LoadCSRs(dev); |
| 916 | dev->trans_start = jiffies; |
| 917 | netif_wake_queue(dev); |
| 918 | InitRestartDepca(dev); |
| 919 | } |
| 920 | |
| 921 | |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 922 | /* |
| 923 | ** Writes a socket buffer to TX descriptor ring and starts transmission |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 924 | */ |
| 925 | static int depca_start_xmit(struct sk_buff *skb, struct net_device *dev) |
| 926 | { |
| 927 | struct depca_private *lp = (struct depca_private *) dev->priv; |
| 928 | u_long ioaddr = dev->base_addr; |
| 929 | int status = 0; |
| 930 | |
| 931 | /* Transmitter timeout, serious problems. */ |
| 932 | if (skb->len < 1) |
| 933 | goto out; |
| 934 | |
Herbert Xu | 5b057c6 | 2006-06-23 02:06:41 -0700 | [diff] [blame] | 935 | if (skb_padto(skb, ETH_ZLEN)) |
| 936 | goto out; |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 937 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 938 | netif_stop_queue(dev); |
| 939 | |
| 940 | if (TX_BUFFS_AVAIL) { /* Fill in a Tx ring entry */ |
| 941 | status = load_packet(dev, skb); |
| 942 | |
| 943 | if (!status) { |
| 944 | /* Trigger an immediate send demand. */ |
| 945 | outw(CSR0, DEPCA_ADDR); |
| 946 | outw(INEA | TDMD, DEPCA_DATA); |
| 947 | |
| 948 | dev->trans_start = jiffies; |
| 949 | dev_kfree_skb(skb); |
| 950 | } |
| 951 | if (TX_BUFFS_AVAIL) |
| 952 | netif_start_queue(dev); |
| 953 | } else |
| 954 | status = -1; |
| 955 | |
| 956 | out: |
| 957 | return status; |
| 958 | } |
| 959 | |
| 960 | /* |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 961 | ** The DEPCA interrupt handler. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 962 | */ |
David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 963 | static irqreturn_t depca_interrupt(int irq, void *dev_id) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 964 | { |
| 965 | struct net_device *dev = dev_id; |
| 966 | struct depca_private *lp; |
| 967 | s16 csr0, nicsr; |
| 968 | u_long ioaddr; |
| 969 | |
| 970 | if (dev == NULL) { |
| 971 | printk("depca_interrupt(): irq %d for unknown device.\n", irq); |
| 972 | return IRQ_NONE; |
| 973 | } |
| 974 | |
| 975 | lp = (struct depca_private *) dev->priv; |
| 976 | ioaddr = dev->base_addr; |
| 977 | |
| 978 | spin_lock(&lp->lock); |
| 979 | |
| 980 | /* mask the DEPCA board interrupts and turn on the LED */ |
| 981 | nicsr = inb(DEPCA_NICSR); |
| 982 | nicsr |= (IM | LED); |
| 983 | outb(nicsr, DEPCA_NICSR); |
| 984 | |
| 985 | outw(CSR0, DEPCA_ADDR); |
| 986 | csr0 = inw(DEPCA_DATA); |
| 987 | |
| 988 | /* Acknowledge all of the current interrupt sources ASAP. */ |
| 989 | outw(csr0 & INTE, DEPCA_DATA); |
| 990 | |
| 991 | if (csr0 & RINT) /* Rx interrupt (packet arrived) */ |
| 992 | depca_rx(dev); |
| 993 | |
| 994 | if (csr0 & TINT) /* Tx interrupt (packet sent) */ |
| 995 | depca_tx(dev); |
| 996 | |
| 997 | /* Any resources available? */ |
| 998 | if ((TX_BUFFS_AVAIL >= 0) && netif_queue_stopped(dev)) { |
| 999 | netif_wake_queue(dev); |
| 1000 | } |
| 1001 | |
| 1002 | /* Unmask the DEPCA board interrupts and turn off the LED */ |
| 1003 | nicsr = (nicsr & ~IM & ~LED); |
| 1004 | outb(nicsr, DEPCA_NICSR); |
| 1005 | |
| 1006 | spin_unlock(&lp->lock); |
| 1007 | return IRQ_HANDLED; |
| 1008 | } |
| 1009 | |
| 1010 | /* Called with lp->lock held */ |
| 1011 | static int depca_rx(struct net_device *dev) |
| 1012 | { |
| 1013 | struct depca_private *lp = (struct depca_private *) dev->priv; |
| 1014 | int i, entry; |
| 1015 | s32 status; |
| 1016 | |
| 1017 | for (entry = lp->rx_new; !(readl(&lp->rx_ring[entry].base) & R_OWN); entry = lp->rx_new) { |
| 1018 | status = readl(&lp->rx_ring[entry].base) >> 16; |
| 1019 | if (status & R_STP) { /* Remember start of frame */ |
| 1020 | lp->rx_old = entry; |
| 1021 | } |
| 1022 | if (status & R_ENP) { /* Valid frame status */ |
| 1023 | if (status & R_ERR) { /* There was an error. */ |
Jeff Garzik | 09f75cd | 2007-10-03 17:41:50 -0700 | [diff] [blame] | 1024 | dev->stats.rx_errors++; /* Update the error stats. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1025 | if (status & R_FRAM) |
Jeff Garzik | 09f75cd | 2007-10-03 17:41:50 -0700 | [diff] [blame] | 1026 | dev->stats.rx_frame_errors++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1027 | if (status & R_OFLO) |
Jeff Garzik | 09f75cd | 2007-10-03 17:41:50 -0700 | [diff] [blame] | 1028 | dev->stats.rx_over_errors++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1029 | if (status & R_CRC) |
Jeff Garzik | 09f75cd | 2007-10-03 17:41:50 -0700 | [diff] [blame] | 1030 | dev->stats.rx_crc_errors++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1031 | if (status & R_BUFF) |
Jeff Garzik | 09f75cd | 2007-10-03 17:41:50 -0700 | [diff] [blame] | 1032 | dev->stats.rx_fifo_errors++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1033 | } else { |
| 1034 | short len, pkt_len = readw(&lp->rx_ring[entry].msg_length) - 4; |
| 1035 | struct sk_buff *skb; |
| 1036 | |
| 1037 | skb = dev_alloc_skb(pkt_len + 2); |
| 1038 | if (skb != NULL) { |
| 1039 | unsigned char *buf; |
| 1040 | skb_reserve(skb, 2); /* 16 byte align the IP header */ |
| 1041 | buf = skb_put(skb, pkt_len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1042 | if (entry < lp->rx_old) { /* Wrapped buffer */ |
| 1043 | len = (lp->rxRingMask - lp->rx_old + 1) * RX_BUFF_SZ; |
| 1044 | memcpy_fromio(buf, lp->rx_buff[lp->rx_old], len); |
| 1045 | memcpy_fromio(buf + len, lp->rx_buff[0], pkt_len - len); |
| 1046 | } else { /* Linear buffer */ |
| 1047 | memcpy_fromio(buf, lp->rx_buff[lp->rx_old], pkt_len); |
| 1048 | } |
| 1049 | |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 1050 | /* |
| 1051 | ** Notify the upper protocol layers that there is another |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1052 | ** packet to handle |
| 1053 | */ |
| 1054 | skb->protocol = eth_type_trans(skb, dev); |
| 1055 | netif_rx(skb); |
| 1056 | |
| 1057 | /* |
| 1058 | ** Update stats |
| 1059 | */ |
| 1060 | dev->last_rx = jiffies; |
Jeff Garzik | 09f75cd | 2007-10-03 17:41:50 -0700 | [diff] [blame] | 1061 | dev->stats.rx_packets++; |
| 1062 | dev->stats.rx_bytes += pkt_len; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1063 | for (i = 1; i < DEPCA_PKT_STAT_SZ - 1; i++) { |
| 1064 | if (pkt_len < (i * DEPCA_PKT_BIN_SZ)) { |
| 1065 | lp->pktStats.bins[i]++; |
| 1066 | i = DEPCA_PKT_STAT_SZ; |
| 1067 | } |
| 1068 | } |
| 1069 | if (buf[0] & 0x01) { /* Multicast/Broadcast */ |
| 1070 | if ((*(s16 *) & buf[0] == -1) && (*(s16 *) & buf[2] == -1) && (*(s16 *) & buf[4] == -1)) { |
| 1071 | lp->pktStats.broadcast++; |
| 1072 | } else { |
| 1073 | lp->pktStats.multicast++; |
| 1074 | } |
| 1075 | } else if ((*(s16 *) & buf[0] == *(s16 *) & dev->dev_addr[0]) && (*(s16 *) & buf[2] == *(s16 *) & dev->dev_addr[2]) && (*(s16 *) & buf[4] == *(s16 *) & dev->dev_addr[4])) { |
| 1076 | lp->pktStats.unicast++; |
| 1077 | } |
| 1078 | |
| 1079 | lp->pktStats.bins[0]++; /* Duplicates stats.rx_packets */ |
| 1080 | if (lp->pktStats.bins[0] == 0) { /* Reset counters */ |
| 1081 | memset((char *) &lp->pktStats, 0, sizeof(lp->pktStats)); |
| 1082 | } |
| 1083 | } else { |
| 1084 | printk("%s: Memory squeeze, deferring packet.\n", dev->name); |
Jeff Garzik | 09f75cd | 2007-10-03 17:41:50 -0700 | [diff] [blame] | 1085 | dev->stats.rx_dropped++; /* Really, deferred. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1086 | break; |
| 1087 | } |
| 1088 | } |
| 1089 | /* Change buffer ownership for this last frame, back to the adapter */ |
| 1090 | for (; lp->rx_old != entry; lp->rx_old = (++lp->rx_old) & lp->rxRingMask) { |
| 1091 | writel(readl(&lp->rx_ring[lp->rx_old].base) | R_OWN, &lp->rx_ring[lp->rx_old].base); |
| 1092 | } |
| 1093 | writel(readl(&lp->rx_ring[entry].base) | R_OWN, &lp->rx_ring[entry].base); |
| 1094 | } |
| 1095 | |
| 1096 | /* |
| 1097 | ** Update entry information |
| 1098 | */ |
| 1099 | lp->rx_new = (++lp->rx_new) & lp->rxRingMask; |
| 1100 | } |
| 1101 | |
| 1102 | return 0; |
| 1103 | } |
| 1104 | |
| 1105 | /* |
| 1106 | ** Buffer sent - check for buffer errors. |
| 1107 | ** Called with lp->lock held |
| 1108 | */ |
| 1109 | static int depca_tx(struct net_device *dev) |
| 1110 | { |
| 1111 | struct depca_private *lp = (struct depca_private *) dev->priv; |
| 1112 | int entry; |
| 1113 | s32 status; |
| 1114 | u_long ioaddr = dev->base_addr; |
| 1115 | |
| 1116 | for (entry = lp->tx_old; entry != lp->tx_new; entry = lp->tx_old) { |
| 1117 | status = readl(&lp->tx_ring[entry].base) >> 16; |
| 1118 | |
| 1119 | if (status < 0) { /* Packet not yet sent! */ |
| 1120 | break; |
| 1121 | } else if (status & T_ERR) { /* An error occurred. */ |
| 1122 | status = readl(&lp->tx_ring[entry].misc); |
Jeff Garzik | 09f75cd | 2007-10-03 17:41:50 -0700 | [diff] [blame] | 1123 | dev->stats.tx_errors++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1124 | if (status & TMD3_RTRY) |
Jeff Garzik | 09f75cd | 2007-10-03 17:41:50 -0700 | [diff] [blame] | 1125 | dev->stats.tx_aborted_errors++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1126 | if (status & TMD3_LCAR) |
Jeff Garzik | 09f75cd | 2007-10-03 17:41:50 -0700 | [diff] [blame] | 1127 | dev->stats.tx_carrier_errors++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1128 | if (status & TMD3_LCOL) |
Jeff Garzik | 09f75cd | 2007-10-03 17:41:50 -0700 | [diff] [blame] | 1129 | dev->stats.tx_window_errors++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1130 | if (status & TMD3_UFLO) |
Jeff Garzik | 09f75cd | 2007-10-03 17:41:50 -0700 | [diff] [blame] | 1131 | dev->stats.tx_fifo_errors++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1132 | if (status & (TMD3_BUFF | TMD3_UFLO)) { |
| 1133 | /* Trigger an immediate send demand. */ |
| 1134 | outw(CSR0, DEPCA_ADDR); |
| 1135 | outw(INEA | TDMD, DEPCA_DATA); |
| 1136 | } |
| 1137 | } else if (status & (T_MORE | T_ONE)) { |
Jeff Garzik | 09f75cd | 2007-10-03 17:41:50 -0700 | [diff] [blame] | 1138 | dev->stats.collisions++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1139 | } else { |
Jeff Garzik | 09f75cd | 2007-10-03 17:41:50 -0700 | [diff] [blame] | 1140 | dev->stats.tx_packets++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1141 | } |
| 1142 | |
| 1143 | /* Update all the pointers */ |
| 1144 | lp->tx_old = (++lp->tx_old) & lp->txRingMask; |
| 1145 | } |
| 1146 | |
| 1147 | return 0; |
| 1148 | } |
| 1149 | |
| 1150 | static int depca_close(struct net_device *dev) |
| 1151 | { |
| 1152 | struct depca_private *lp = (struct depca_private *) dev->priv; |
| 1153 | s16 nicsr; |
| 1154 | u_long ioaddr = dev->base_addr; |
| 1155 | |
| 1156 | netif_stop_queue(dev); |
| 1157 | |
| 1158 | outw(CSR0, DEPCA_ADDR); |
| 1159 | |
| 1160 | if (depca_debug > 1) { |
| 1161 | printk("%s: Shutting down ethercard, status was %2.2x.\n", dev->name, inw(DEPCA_DATA)); |
| 1162 | } |
| 1163 | |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 1164 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1165 | ** We stop the DEPCA here -- it occasionally polls |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 1166 | ** memory if we don't. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1167 | */ |
| 1168 | outw(STOP, DEPCA_DATA); |
| 1169 | |
| 1170 | /* |
| 1171 | ** Give back the ROM in case the user wants to go to DOS |
| 1172 | */ |
| 1173 | if (lp->adapter != DEPCA) { |
| 1174 | nicsr = inb(DEPCA_NICSR); |
| 1175 | nicsr &= ~SHE; |
| 1176 | outb(nicsr, DEPCA_NICSR); |
| 1177 | } |
| 1178 | |
| 1179 | /* |
| 1180 | ** Free the associated irq |
| 1181 | */ |
| 1182 | free_irq(dev->irq, dev); |
| 1183 | return 0; |
| 1184 | } |
| 1185 | |
| 1186 | static void LoadCSRs(struct net_device *dev) |
| 1187 | { |
| 1188 | struct depca_private *lp = (struct depca_private *) dev->priv; |
| 1189 | u_long ioaddr = dev->base_addr; |
| 1190 | |
| 1191 | outw(CSR1, DEPCA_ADDR); /* initialisation block address LSW */ |
| 1192 | outw((u16) lp->device_ram_start, DEPCA_DATA); |
| 1193 | outw(CSR2, DEPCA_ADDR); /* initialisation block address MSW */ |
| 1194 | outw((u16) (lp->device_ram_start >> 16), DEPCA_DATA); |
| 1195 | outw(CSR3, DEPCA_ADDR); /* ALE control */ |
| 1196 | outw(ACON, DEPCA_DATA); |
| 1197 | |
| 1198 | outw(CSR0, DEPCA_ADDR); /* Point back to CSR0 */ |
| 1199 | |
| 1200 | return; |
| 1201 | } |
| 1202 | |
| 1203 | static int InitRestartDepca(struct net_device *dev) |
| 1204 | { |
| 1205 | struct depca_private *lp = (struct depca_private *) dev->priv; |
| 1206 | u_long ioaddr = dev->base_addr; |
| 1207 | int i, status = 0; |
| 1208 | |
| 1209 | /* Copy the shadow init_block to shared memory */ |
| 1210 | memcpy_toio(lp->sh_mem, &lp->init_block, sizeof(struct depca_init)); |
| 1211 | |
| 1212 | outw(CSR0, DEPCA_ADDR); /* point back to CSR0 */ |
| 1213 | outw(INIT, DEPCA_DATA); /* initialize DEPCA */ |
| 1214 | |
| 1215 | /* wait for lance to complete initialisation */ |
| 1216 | for (i = 0; (i < 100) && !(inw(DEPCA_DATA) & IDON); i++); |
| 1217 | |
| 1218 | if (i != 100) { |
| 1219 | /* clear IDON by writing a "1", enable interrupts and start lance */ |
| 1220 | outw(IDON | INEA | STRT, DEPCA_DATA); |
| 1221 | if (depca_debug > 2) { |
| 1222 | printk("%s: DEPCA open after %d ticks, init block 0x%08lx csr0 %4.4x.\n", dev->name, i, lp->mem_start, inw(DEPCA_DATA)); |
| 1223 | } |
| 1224 | } else { |
| 1225 | printk("%s: DEPCA unopen after %d ticks, init block 0x%08lx csr0 %4.4x.\n", dev->name, i, lp->mem_start, inw(DEPCA_DATA)); |
| 1226 | status = -1; |
| 1227 | } |
| 1228 | |
| 1229 | return status; |
| 1230 | } |
| 1231 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1232 | /* |
| 1233 | ** Set or clear the multicast filter for this adaptor. |
| 1234 | */ |
| 1235 | static void set_multicast_list(struct net_device *dev) |
| 1236 | { |
| 1237 | struct depca_private *lp = (struct depca_private *) dev->priv; |
| 1238 | u_long ioaddr = dev->base_addr; |
| 1239 | |
Eric Sesterhenn | 107ce6d | 2006-10-10 14:33:28 -0700 | [diff] [blame] | 1240 | netif_stop_queue(dev); |
| 1241 | while (lp->tx_old != lp->tx_new); /* Wait for the ring to empty */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1242 | |
Eric Sesterhenn | 107ce6d | 2006-10-10 14:33:28 -0700 | [diff] [blame] | 1243 | STOP_DEPCA; /* Temporarily stop the depca. */ |
| 1244 | depca_init_ring(dev); /* Initialize the descriptor rings */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1245 | |
Eric Sesterhenn | 107ce6d | 2006-10-10 14:33:28 -0700 | [diff] [blame] | 1246 | if (dev->flags & IFF_PROMISC) { /* Set promiscuous mode */ |
| 1247 | lp->init_block.mode |= PROM; |
| 1248 | } else { |
| 1249 | SetMulticastFilter(dev); |
| 1250 | lp->init_block.mode &= ~PROM; /* Unset promiscuous mode */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1251 | } |
Eric Sesterhenn | 107ce6d | 2006-10-10 14:33:28 -0700 | [diff] [blame] | 1252 | |
| 1253 | LoadCSRs(dev); /* Reload CSR3 */ |
| 1254 | InitRestartDepca(dev); /* Resume normal operation. */ |
| 1255 | netif_start_queue(dev); /* Unlock the TX ring */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1256 | } |
| 1257 | |
| 1258 | /* |
| 1259 | ** Calculate the hash code and update the logical address filter |
| 1260 | ** from a list of ethernet multicast addresses. |
| 1261 | ** Big endian crc one liner is mine, all mine, ha ha ha ha! |
| 1262 | ** LANCE calculates its hash codes big endian. |
| 1263 | */ |
| 1264 | static void SetMulticastFilter(struct net_device *dev) |
| 1265 | { |
| 1266 | struct depca_private *lp = (struct depca_private *) dev->priv; |
| 1267 | struct dev_mc_list *dmi = dev->mc_list; |
| 1268 | char *addrs; |
| 1269 | int i, j, bit, byte; |
| 1270 | u16 hashcode; |
| 1271 | u32 crc; |
| 1272 | |
| 1273 | if (dev->flags & IFF_ALLMULTI) { /* Set all multicast bits */ |
| 1274 | for (i = 0; i < (HASH_TABLE_LEN >> 3); i++) { |
| 1275 | lp->init_block.mcast_table[i] = (char) 0xff; |
| 1276 | } |
| 1277 | } else { |
| 1278 | for (i = 0; i < (HASH_TABLE_LEN >> 3); i++) { /* Clear the multicast table */ |
| 1279 | lp->init_block.mcast_table[i] = 0; |
| 1280 | } |
| 1281 | /* Add multicast addresses */ |
| 1282 | for (i = 0; i < dev->mc_count; i++) { /* for each address in the list */ |
| 1283 | addrs = dmi->dmi_addr; |
| 1284 | dmi = dmi->next; |
| 1285 | if ((*addrs & 0x01) == 1) { /* multicast address? */ |
| 1286 | crc = ether_crc(ETH_ALEN, addrs); |
| 1287 | hashcode = (crc & 1); /* hashcode is 6 LSb of CRC ... */ |
| 1288 | for (j = 0; j < 5; j++) { /* ... in reverse order. */ |
| 1289 | hashcode = (hashcode << 1) | ((crc >>= 1) & 1); |
| 1290 | } |
| 1291 | |
| 1292 | |
| 1293 | byte = hashcode >> 3; /* bit[3-5] -> byte in filter */ |
| 1294 | bit = 1 << (hashcode & 0x07); /* bit[0-2] -> bit in byte */ |
| 1295 | lp->init_block.mcast_table[byte] |= bit; |
| 1296 | } |
| 1297 | } |
| 1298 | } |
| 1299 | |
| 1300 | return; |
| 1301 | } |
| 1302 | |
| 1303 | static int __init depca_common_init (u_long ioaddr, struct net_device **devp) |
| 1304 | { |
| 1305 | int status = 0; |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 1306 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1307 | if (!request_region (ioaddr, DEPCA_TOTAL_SIZE, depca_string)) { |
| 1308 | status = -EBUSY; |
| 1309 | goto out; |
| 1310 | } |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 1311 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1312 | if (DevicePresent(ioaddr)) { |
| 1313 | status = -ENODEV; |
| 1314 | goto out_release; |
| 1315 | } |
| 1316 | |
| 1317 | if (!(*devp = alloc_etherdev (sizeof (struct depca_private)))) { |
| 1318 | status = -ENOMEM; |
| 1319 | goto out_release; |
| 1320 | } |
| 1321 | |
| 1322 | return 0; |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 1323 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1324 | out_release: |
| 1325 | release_region (ioaddr, DEPCA_TOTAL_SIZE); |
| 1326 | out: |
| 1327 | return status; |
| 1328 | } |
| 1329 | |
| 1330 | #ifdef CONFIG_MCA |
| 1331 | /* |
| 1332 | ** Microchannel bus I/O device probe |
| 1333 | */ |
| 1334 | static int __init depca_mca_probe(struct device *device) |
| 1335 | { |
| 1336 | unsigned char pos[2]; |
| 1337 | unsigned char where; |
| 1338 | unsigned long iobase, mem_start; |
| 1339 | int irq, err; |
| 1340 | struct mca_device *mdev = to_mca_device (device); |
| 1341 | struct net_device *dev; |
| 1342 | struct depca_private *lp; |
| 1343 | |
| 1344 | /* |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 1345 | ** Search for the adapter. If an address has been given, search |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1346 | ** specifically for the card at that address. Otherwise find the |
| 1347 | ** first card in the system. |
| 1348 | */ |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 1349 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1350 | pos[0] = mca_device_read_stored_pos(mdev, 2); |
| 1351 | pos[1] = mca_device_read_stored_pos(mdev, 3); |
| 1352 | |
| 1353 | /* |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 1354 | ** IO of card is handled by bits 1 and 2 of pos0. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1355 | ** |
| 1356 | ** bit2 bit1 IO |
| 1357 | ** 0 0 0x2c00 |
| 1358 | ** 0 1 0x2c10 |
| 1359 | ** 1 0 0x2c20 |
| 1360 | ** 1 1 0x2c30 |
| 1361 | */ |
| 1362 | where = (pos[0] & 6) >> 1; |
| 1363 | iobase = 0x2c00 + (0x10 * where); |
| 1364 | |
| 1365 | /* |
| 1366 | ** Found the adapter we were looking for. Now start setting it up. |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 1367 | ** |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1368 | ** First work on decoding the IRQ. It's stored in the lower 4 bits |
| 1369 | ** of pos1. Bits are as follows (from the ADF file): |
| 1370 | ** |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 1371 | ** Bits |
| 1372 | ** 3 2 1 0 IRQ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1373 | ** -------------------- |
| 1374 | ** 0 0 1 0 5 |
| 1375 | ** 0 0 0 1 9 |
| 1376 | ** 0 1 0 0 10 |
| 1377 | ** 1 0 0 0 11 |
| 1378 | */ |
| 1379 | where = pos[1] & 0x0f; |
| 1380 | switch (where) { |
| 1381 | case 1: |
| 1382 | irq = 9; |
| 1383 | break; |
| 1384 | case 2: |
| 1385 | irq = 5; |
| 1386 | break; |
| 1387 | case 4: |
| 1388 | irq = 10; |
| 1389 | break; |
| 1390 | case 8: |
| 1391 | irq = 11; |
| 1392 | break; |
| 1393 | default: |
Eric Sesterhenn | 6a6bbd2 | 2006-03-22 22:49:48 +0100 | [diff] [blame] | 1394 | printk("%s: mca_probe IRQ error. You should never get here (%d).\n", mdev->name, where); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1395 | return -EINVAL; |
| 1396 | } |
| 1397 | |
| 1398 | /* |
| 1399 | ** Shared memory address of adapter is stored in bits 3-5 of pos0. |
| 1400 | ** They are mapped as follows: |
| 1401 | ** |
| 1402 | ** Bit |
| 1403 | ** 5 4 3 Memory Addresses |
| 1404 | ** 0 0 0 C0000-CFFFF (64K) |
| 1405 | ** 1 0 0 C8000-CFFFF (32K) |
| 1406 | ** 0 0 1 D0000-DFFFF (64K) |
| 1407 | ** 1 0 1 D8000-DFFFF (32K) |
| 1408 | ** 0 1 0 E0000-EFFFF (64K) |
| 1409 | ** 1 1 0 E8000-EFFFF (32K) |
| 1410 | */ |
| 1411 | where = (pos[0] & 0x18) >> 3; |
| 1412 | mem_start = 0xc0000 + (where * 0x10000); |
| 1413 | if (pos[0] & 0x20) { |
| 1414 | mem_start += 0x8000; |
| 1415 | } |
| 1416 | |
| 1417 | /* claim the slot */ |
| 1418 | strncpy(mdev->name, depca_mca_adapter_name[mdev->index], |
| 1419 | sizeof(mdev->name)); |
| 1420 | mca_device_set_claim(mdev, 1); |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 1421 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1422 | /* |
| 1423 | ** Get everything allocated and initialized... (almost just |
| 1424 | ** like the ISA and EISA probes) |
| 1425 | */ |
| 1426 | irq = mca_device_transform_irq(mdev, irq); |
| 1427 | iobase = mca_device_transform_ioport(mdev, iobase); |
| 1428 | |
| 1429 | if ((err = depca_common_init (iobase, &dev))) |
| 1430 | goto out_unclaim; |
| 1431 | |
| 1432 | dev->irq = irq; |
| 1433 | dev->base_addr = iobase; |
| 1434 | lp = dev->priv; |
| 1435 | lp->depca_bus = DEPCA_BUS_MCA; |
| 1436 | lp->adapter = depca_mca_adapter_type[mdev->index]; |
| 1437 | lp->mem_start = mem_start; |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 1438 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1439 | if ((err = depca_hw_init(dev, device))) |
| 1440 | goto out_free; |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 1441 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1442 | return 0; |
| 1443 | |
| 1444 | out_free: |
| 1445 | free_netdev (dev); |
| 1446 | release_region (iobase, DEPCA_TOTAL_SIZE); |
| 1447 | out_unclaim: |
| 1448 | mca_device_set_claim(mdev, 0); |
| 1449 | |
| 1450 | return err; |
| 1451 | } |
| 1452 | #endif |
| 1453 | |
| 1454 | /* |
| 1455 | ** ISA bus I/O device probe |
| 1456 | */ |
| 1457 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1458 | static void __init depca_platform_probe (void) |
| 1459 | { |
| 1460 | int i; |
| 1461 | struct platform_device *pldev; |
| 1462 | |
| 1463 | for (i = 0; depca_io_ports[i].iobase; i++) { |
| 1464 | depca_io_ports[i].device = NULL; |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 1465 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1466 | /* if an address has been specified on the command |
| 1467 | * line, use it (if valid) */ |
| 1468 | if (io && io != depca_io_ports[i].iobase) |
| 1469 | continue; |
Russell King | 5d994b7 | 2005-11-05 21:20:21 +0000 | [diff] [blame] | 1470 | |
| 1471 | pldev = platform_device_alloc(depca_string, i); |
| 1472 | if (!pldev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1473 | continue; |
| 1474 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1475 | pldev->dev.platform_data = (void *) depca_io_ports[i].iobase; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1476 | depca_io_ports[i].device = pldev; |
| 1477 | |
Russell King | 5d994b7 | 2005-11-05 21:20:21 +0000 | [diff] [blame] | 1478 | if (platform_device_add(pldev)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1479 | depca_io_ports[i].device = NULL; |
Andrea Righi | d91c088 | 2007-04-24 12:40:57 -0400 | [diff] [blame] | 1480 | pldev->dev.platform_data = NULL; |
| 1481 | platform_device_put(pldev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1482 | continue; |
| 1483 | } |
| 1484 | |
| 1485 | if (!pldev->dev.driver) { |
| 1486 | /* The driver was not bound to this device, there was |
| 1487 | * no hardware at this address. Unregister it, as the |
| 1488 | * release fuction will take care of freeing the |
| 1489 | * allocated structure */ |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 1490 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1491 | depca_io_ports[i].device = NULL; |
Russell King | 5d994b7 | 2005-11-05 21:20:21 +0000 | [diff] [blame] | 1492 | pldev->dev.platform_data = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1493 | platform_device_unregister (pldev); |
| 1494 | } |
| 1495 | } |
| 1496 | } |
| 1497 | |
| 1498 | static enum depca_type __init depca_shmem_probe (ulong *mem_start) |
| 1499 | { |
| 1500 | u_long mem_base[] = DEPCA_RAM_BASE_ADDRESSES; |
| 1501 | enum depca_type adapter = unknown; |
| 1502 | int i; |
| 1503 | |
| 1504 | for (i = 0; mem_base[i]; i++) { |
| 1505 | *mem_start = mem ? mem : mem_base[i]; |
| 1506 | adapter = DepcaSignature (adapter_name, *mem_start); |
| 1507 | if (adapter != unknown) |
| 1508 | break; |
| 1509 | } |
| 1510 | |
| 1511 | return adapter; |
| 1512 | } |
| 1513 | |
Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 1514 | static int __init depca_isa_probe (struct platform_device *device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1515 | { |
| 1516 | struct net_device *dev; |
| 1517 | struct depca_private *lp; |
| 1518 | u_long ioaddr, mem_start = 0; |
| 1519 | enum depca_type adapter = unknown; |
| 1520 | int status = 0; |
| 1521 | |
Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 1522 | ioaddr = (u_long) device->dev.platform_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1523 | |
| 1524 | if ((status = depca_common_init (ioaddr, &dev))) |
| 1525 | goto out; |
| 1526 | |
| 1527 | adapter = depca_shmem_probe (&mem_start); |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 1528 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1529 | if (adapter == unknown) { |
| 1530 | status = -ENODEV; |
| 1531 | goto out_free; |
| 1532 | } |
| 1533 | |
| 1534 | dev->base_addr = ioaddr; |
| 1535 | dev->irq = irq; /* Use whatever value the user gave |
| 1536 | * us, and 0 if he didn't. */ |
| 1537 | lp = dev->priv; |
| 1538 | lp->depca_bus = DEPCA_BUS_ISA; |
| 1539 | lp->adapter = adapter; |
| 1540 | lp->mem_start = mem_start; |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 1541 | |
Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 1542 | if ((status = depca_hw_init(dev, &device->dev))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1543 | goto out_free; |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 1544 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1545 | return 0; |
| 1546 | |
| 1547 | out_free: |
| 1548 | free_netdev (dev); |
| 1549 | release_region (ioaddr, DEPCA_TOTAL_SIZE); |
| 1550 | out: |
| 1551 | return status; |
| 1552 | } |
| 1553 | |
| 1554 | /* |
| 1555 | ** EISA callbacks from sysfs. |
| 1556 | */ |
| 1557 | |
| 1558 | #ifdef CONFIG_EISA |
| 1559 | static int __init depca_eisa_probe (struct device *device) |
| 1560 | { |
| 1561 | struct eisa_device *edev; |
| 1562 | struct net_device *dev; |
| 1563 | struct depca_private *lp; |
| 1564 | u_long ioaddr, mem_start; |
| 1565 | int status = 0; |
| 1566 | |
| 1567 | edev = to_eisa_device (device); |
| 1568 | ioaddr = edev->base_addr + DEPCA_EISA_IO_PORTS; |
| 1569 | |
| 1570 | if ((status = depca_common_init (ioaddr, &dev))) |
| 1571 | goto out; |
| 1572 | |
| 1573 | /* It would have been nice to get card configuration from the |
| 1574 | * card. Unfortunately, this register is write-only (shares |
| 1575 | * it's address with the ethernet prom)... As we don't parse |
| 1576 | * the EISA configuration structures (yet... :-), just rely on |
| 1577 | * the ISA probing to sort it out... */ |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 1578 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1579 | depca_shmem_probe (&mem_start); |
| 1580 | |
| 1581 | dev->base_addr = ioaddr; |
| 1582 | dev->irq = irq; |
| 1583 | lp = dev->priv; |
| 1584 | lp->depca_bus = DEPCA_BUS_EISA; |
| 1585 | lp->adapter = edev->id.driver_data; |
| 1586 | lp->mem_start = mem_start; |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 1587 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1588 | if ((status = depca_hw_init(dev, device))) |
| 1589 | goto out_free; |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 1590 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1591 | return 0; |
| 1592 | |
| 1593 | out_free: |
| 1594 | free_netdev (dev); |
| 1595 | release_region (ioaddr, DEPCA_TOTAL_SIZE); |
| 1596 | out: |
| 1597 | return status; |
| 1598 | } |
| 1599 | #endif |
| 1600 | |
| 1601 | static int __devexit depca_device_remove (struct device *device) |
| 1602 | { |
| 1603 | struct net_device *dev; |
| 1604 | struct depca_private *lp; |
| 1605 | int bus; |
| 1606 | |
| 1607 | dev = device->driver_data; |
| 1608 | lp = dev->priv; |
| 1609 | |
| 1610 | unregister_netdev (dev); |
| 1611 | iounmap (lp->sh_mem); |
| 1612 | release_mem_region (lp->mem_start, lp->mem_len); |
| 1613 | release_region (dev->base_addr, DEPCA_TOTAL_SIZE); |
| 1614 | bus = lp->depca_bus; |
| 1615 | free_netdev (dev); |
| 1616 | |
| 1617 | return 0; |
| 1618 | } |
| 1619 | |
| 1620 | /* |
| 1621 | ** Look for a particular board name in the on-board Remote Diagnostics |
| 1622 | ** and Boot (readb) ROM. This will also give us a clue to the network RAM |
| 1623 | ** base address. |
| 1624 | */ |
| 1625 | static int __init DepcaSignature(char *name, u_long base_addr) |
| 1626 | { |
| 1627 | u_int i, j, k; |
| 1628 | void __iomem *ptr; |
| 1629 | char tmpstr[16]; |
| 1630 | u_long prom_addr = base_addr + 0xc000; |
| 1631 | u_long mem_addr = base_addr + 0x8000; /* 32KB */ |
| 1632 | |
| 1633 | /* Can't reserve the prom region, it is already marked as |
| 1634 | * used, at least on x86. Instead, reserve a memory region a |
| 1635 | * board would certainly use. If it works, go ahead. If not, |
| 1636 | * run like hell... */ |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 1637 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1638 | if (!request_mem_region (mem_addr, 16, depca_string)) |
| 1639 | return unknown; |
| 1640 | |
| 1641 | /* Copy the first 16 bytes of ROM */ |
| 1642 | |
| 1643 | ptr = ioremap(prom_addr, 16); |
| 1644 | if (ptr == NULL) { |
| 1645 | printk(KERN_ERR "depca: I/O remap failed at %lx\n", prom_addr); |
| 1646 | return unknown; |
| 1647 | } |
| 1648 | for (i = 0; i < 16; i++) { |
| 1649 | tmpstr[i] = readb(ptr + i); |
| 1650 | } |
| 1651 | iounmap(ptr); |
| 1652 | |
| 1653 | release_mem_region (mem_addr, 16); |
| 1654 | |
| 1655 | /* Check if PROM contains a valid string */ |
| 1656 | for (i = 0; *depca_signature[i] != '\0'; i++) { |
| 1657 | for (j = 0, k = 0; j < 16 && k < strlen(depca_signature[i]); j++) { |
| 1658 | if (depca_signature[i][k] == tmpstr[j]) { /* track signature */ |
| 1659 | k++; |
| 1660 | } else { /* lost signature; begin search again */ |
| 1661 | k = 0; |
| 1662 | } |
| 1663 | } |
| 1664 | if (k == strlen(depca_signature[i])) |
| 1665 | break; |
| 1666 | } |
| 1667 | |
| 1668 | /* Check if name string is valid, provided there's no PROM */ |
| 1669 | if (name && *name && (i == unknown)) { |
| 1670 | for (i = 0; *depca_signature[i] != '\0'; i++) { |
| 1671 | if (strcmp(name, depca_signature[i]) == 0) |
| 1672 | break; |
| 1673 | } |
| 1674 | } |
| 1675 | |
| 1676 | return i; |
| 1677 | } |
| 1678 | |
| 1679 | /* |
| 1680 | ** Look for a special sequence in the Ethernet station address PROM that |
| 1681 | ** is common across all DEPCA products. Note that the original DEPCA needs |
| 1682 | ** its ROM address counter to be initialized and enabled. Only enable |
| 1683 | ** if the first address octet is a 0x08 - this minimises the chances of |
| 1684 | ** messing around with some other hardware, but it assumes that this DEPCA |
| 1685 | ** card initialized itself correctly. |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 1686 | ** |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1687 | ** Search the Ethernet address ROM for the signature. Since the ROM address |
| 1688 | ** counter can start at an arbitrary point, the search must include the entire |
| 1689 | ** probe sequence length plus the (length_of_the_signature - 1). |
| 1690 | ** Stop the search IMMEDIATELY after the signature is found so that the |
| 1691 | ** PROM address counter is correctly positioned at the start of the |
| 1692 | ** ethernet address for later read out. |
| 1693 | */ |
| 1694 | static int __init DevicePresent(u_long ioaddr) |
| 1695 | { |
| 1696 | union { |
| 1697 | struct { |
| 1698 | u32 a; |
| 1699 | u32 b; |
| 1700 | } llsig; |
| 1701 | char Sig[sizeof(u32) << 1]; |
| 1702 | } |
| 1703 | dev; |
| 1704 | short sigLength = 0; |
| 1705 | s8 data; |
| 1706 | s16 nicsr; |
| 1707 | int i, j, status = 0; |
| 1708 | |
| 1709 | data = inb(DEPCA_PROM); /* clear counter on DEPCA */ |
| 1710 | data = inb(DEPCA_PROM); /* read data */ |
| 1711 | |
| 1712 | if (data == 0x08) { /* Enable counter on DEPCA */ |
| 1713 | nicsr = inb(DEPCA_NICSR); |
| 1714 | nicsr |= AAC; |
| 1715 | outb(nicsr, DEPCA_NICSR); |
| 1716 | } |
| 1717 | |
| 1718 | dev.llsig.a = ETH_PROM_SIG; |
| 1719 | dev.llsig.b = ETH_PROM_SIG; |
| 1720 | sigLength = sizeof(u32) << 1; |
| 1721 | |
| 1722 | for (i = 0, j = 0; j < sigLength && i < PROBE_LENGTH + sigLength - 1; i++) { |
| 1723 | data = inb(DEPCA_PROM); |
| 1724 | if (dev.Sig[j] == data) { /* track signature */ |
| 1725 | j++; |
| 1726 | } else { /* lost signature; begin search again */ |
| 1727 | if (data == dev.Sig[0]) { /* rare case.... */ |
| 1728 | j = 1; |
| 1729 | } else { |
| 1730 | j = 0; |
| 1731 | } |
| 1732 | } |
| 1733 | } |
| 1734 | |
| 1735 | if (j != sigLength) { |
| 1736 | status = -ENODEV; /* search failed */ |
| 1737 | } |
| 1738 | |
| 1739 | return status; |
| 1740 | } |
| 1741 | |
| 1742 | /* |
| 1743 | ** The DE100 and DE101 PROM accesses were made non-standard for some bizarre |
| 1744 | ** reason: access the upper half of the PROM with x=0; access the lower half |
| 1745 | ** with x=1. |
| 1746 | */ |
| 1747 | static int __init get_hw_addr(struct net_device *dev) |
| 1748 | { |
| 1749 | u_long ioaddr = dev->base_addr; |
| 1750 | struct depca_private *lp = dev->priv; |
| 1751 | int i, k, tmp, status = 0; |
| 1752 | u_short j, x, chksum; |
| 1753 | |
| 1754 | x = (((lp->adapter == de100) || (lp->adapter == de101)) ? 1 : 0); |
| 1755 | |
| 1756 | for (i = 0, k = 0, j = 0; j < 3; j++) { |
| 1757 | k <<= 1; |
| 1758 | if (k > 0xffff) |
| 1759 | k -= 0xffff; |
| 1760 | |
| 1761 | k += (u_char) (tmp = inb(DEPCA_PROM + x)); |
| 1762 | dev->dev_addr[i++] = (u_char) tmp; |
| 1763 | k += (u_short) ((tmp = inb(DEPCA_PROM + x)) << 8); |
| 1764 | dev->dev_addr[i++] = (u_char) tmp; |
| 1765 | |
| 1766 | if (k > 0xffff) |
| 1767 | k -= 0xffff; |
| 1768 | } |
| 1769 | if (k == 0xffff) |
| 1770 | k = 0; |
| 1771 | |
| 1772 | chksum = (u_char) inb(DEPCA_PROM + x); |
| 1773 | chksum |= (u_short) (inb(DEPCA_PROM + x) << 8); |
| 1774 | if (k != chksum) |
| 1775 | status = -1; |
| 1776 | |
| 1777 | return status; |
| 1778 | } |
| 1779 | |
| 1780 | /* |
| 1781 | ** Load a packet into the shared memory |
| 1782 | */ |
| 1783 | static int load_packet(struct net_device *dev, struct sk_buff *skb) |
| 1784 | { |
| 1785 | struct depca_private *lp = (struct depca_private *) dev->priv; |
| 1786 | int i, entry, end, len, status = 0; |
| 1787 | |
| 1788 | entry = lp->tx_new; /* Ring around buffer number. */ |
| 1789 | end = (entry + (skb->len - 1) / TX_BUFF_SZ) & lp->txRingMask; |
| 1790 | if (!(readl(&lp->tx_ring[end].base) & T_OWN)) { /* Enough room? */ |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 1791 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1792 | ** Caution: the write order is important here... don't set up the |
| 1793 | ** ownership rights until all the other information is in place. |
| 1794 | */ |
| 1795 | if (end < entry) { /* wrapped buffer */ |
| 1796 | len = (lp->txRingMask - entry + 1) * TX_BUFF_SZ; |
| 1797 | memcpy_toio(lp->tx_buff[entry], skb->data, len); |
| 1798 | memcpy_toio(lp->tx_buff[0], skb->data + len, skb->len - len); |
| 1799 | } else { /* linear buffer */ |
| 1800 | memcpy_toio(lp->tx_buff[entry], skb->data, skb->len); |
| 1801 | } |
| 1802 | |
| 1803 | /* set up the buffer descriptors */ |
| 1804 | len = (skb->len < ETH_ZLEN) ? ETH_ZLEN : skb->len; |
| 1805 | for (i = entry; i != end; i = (i+1) & lp->txRingMask) { |
| 1806 | /* clean out flags */ |
| 1807 | writel(readl(&lp->tx_ring[i].base) & ~T_FLAGS, &lp->tx_ring[i].base); |
| 1808 | writew(0x0000, &lp->tx_ring[i].misc); /* clears other error flags */ |
| 1809 | writew(-TX_BUFF_SZ, &lp->tx_ring[i].length); /* packet length in buffer */ |
| 1810 | len -= TX_BUFF_SZ; |
| 1811 | } |
| 1812 | /* clean out flags */ |
| 1813 | writel(readl(&lp->tx_ring[end].base) & ~T_FLAGS, &lp->tx_ring[end].base); |
| 1814 | writew(0x0000, &lp->tx_ring[end].misc); /* clears other error flags */ |
| 1815 | writew(-len, &lp->tx_ring[end].length); /* packet length in last buff */ |
| 1816 | |
| 1817 | /* start of packet */ |
| 1818 | writel(readl(&lp->tx_ring[entry].base) | T_STP, &lp->tx_ring[entry].base); |
| 1819 | /* end of packet */ |
| 1820 | writel(readl(&lp->tx_ring[end].base) | T_ENP, &lp->tx_ring[end].base); |
| 1821 | |
| 1822 | for (i = end; i != entry; --i) { |
| 1823 | /* ownership of packet */ |
| 1824 | writel(readl(&lp->tx_ring[i].base) | T_OWN, &lp->tx_ring[i].base); |
| 1825 | if (i == 0) |
| 1826 | i = lp->txRingMask + 1; |
| 1827 | } |
| 1828 | writel(readl(&lp->tx_ring[entry].base) | T_OWN, &lp->tx_ring[entry].base); |
| 1829 | |
| 1830 | lp->tx_new = (++end) & lp->txRingMask; /* update current pointers */ |
| 1831 | } else { |
| 1832 | status = -1; |
| 1833 | } |
| 1834 | |
| 1835 | return status; |
| 1836 | } |
| 1837 | |
| 1838 | static void depca_dbg_open(struct net_device *dev) |
| 1839 | { |
| 1840 | struct depca_private *lp = (struct depca_private *) dev->priv; |
| 1841 | u_long ioaddr = dev->base_addr; |
| 1842 | struct depca_init *p = &lp->init_block; |
| 1843 | int i; |
Joe Perches | 0795af5 | 2007-10-03 17:59:30 -0700 | [diff] [blame] | 1844 | DECLARE_MAC_BUF(mac); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1845 | |
| 1846 | if (depca_debug > 1) { |
| 1847 | /* Do not copy the shadow init block into shared memory */ |
| 1848 | /* Debugging should not affect normal operation! */ |
| 1849 | /* The shadow init block will get copied across during InitRestartDepca */ |
| 1850 | printk("%s: depca open with irq %d\n", dev->name, dev->irq); |
| 1851 | printk("Descriptor head addresses (CPU):\n"); |
| 1852 | printk(" 0x%lx 0x%lx\n", (u_long) lp->rx_ring, (u_long) lp->tx_ring); |
| 1853 | printk("Descriptor addresses (CPU):\nRX: "); |
| 1854 | for (i = 0; i < lp->rxRingMask; i++) { |
| 1855 | if (i < 3) { |
| 1856 | printk("%p ", &lp->rx_ring[i].base); |
| 1857 | } |
| 1858 | } |
| 1859 | printk("...%p\n", &lp->rx_ring[i].base); |
| 1860 | printk("TX: "); |
| 1861 | for (i = 0; i < lp->txRingMask; i++) { |
| 1862 | if (i < 3) { |
| 1863 | printk("%p ", &lp->tx_ring[i].base); |
| 1864 | } |
| 1865 | } |
| 1866 | printk("...%p\n", &lp->tx_ring[i].base); |
| 1867 | printk("\nDescriptor buffers (Device):\nRX: "); |
| 1868 | for (i = 0; i < lp->rxRingMask; i++) { |
| 1869 | if (i < 3) { |
| 1870 | printk("0x%8.8x ", readl(&lp->rx_ring[i].base)); |
| 1871 | } |
| 1872 | } |
| 1873 | printk("...0x%8.8x\n", readl(&lp->rx_ring[i].base)); |
| 1874 | printk("TX: "); |
| 1875 | for (i = 0; i < lp->txRingMask; i++) { |
| 1876 | if (i < 3) { |
| 1877 | printk("0x%8.8x ", readl(&lp->tx_ring[i].base)); |
| 1878 | } |
| 1879 | } |
| 1880 | printk("...0x%8.8x\n", readl(&lp->tx_ring[i].base)); |
| 1881 | printk("Initialisation block at 0x%8.8lx(Phys)\n", lp->mem_start); |
| 1882 | printk(" mode: 0x%4.4x\n", p->mode); |
Joe Perches | 0795af5 | 2007-10-03 17:59:30 -0700 | [diff] [blame] | 1883 | printk(" physical address: %s\n", print_mac(mac, p->phys_addr)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1884 | printk(" multicast hash table: "); |
| 1885 | for (i = 0; i < (HASH_TABLE_LEN >> 3) - 1; i++) { |
| 1886 | printk("%2.2x:", p->mcast_table[i]); |
| 1887 | } |
| 1888 | printk("%2.2x\n", p->mcast_table[i]); |
| 1889 | printk(" rx_ring at: 0x%8.8x\n", p->rx_ring); |
| 1890 | printk(" tx_ring at: 0x%8.8x\n", p->tx_ring); |
| 1891 | printk("buffers (Phys): 0x%8.8lx\n", lp->mem_start + lp->buffs_offset); |
| 1892 | printk("Ring size:\nRX: %d Log2(rxRingMask): 0x%8.8x\n", (int) lp->rxRingMask + 1, lp->rx_rlen); |
| 1893 | printk("TX: %d Log2(txRingMask): 0x%8.8x\n", (int) lp->txRingMask + 1, lp->tx_rlen); |
| 1894 | outw(CSR2, DEPCA_ADDR); |
| 1895 | printk("CSR2&1: 0x%4.4x", inw(DEPCA_DATA)); |
| 1896 | outw(CSR1, DEPCA_ADDR); |
| 1897 | printk("%4.4x\n", inw(DEPCA_DATA)); |
| 1898 | outw(CSR3, DEPCA_ADDR); |
| 1899 | printk("CSR3: 0x%4.4x\n", inw(DEPCA_DATA)); |
| 1900 | } |
| 1901 | |
| 1902 | return; |
| 1903 | } |
| 1904 | |
| 1905 | /* |
| 1906 | ** Perform IOCTL call functions here. Some are privileged operations and the |
| 1907 | ** effective uid is checked in those cases. |
| 1908 | ** All multicast IOCTLs will not work here and are for testing purposes only. |
| 1909 | */ |
| 1910 | static int depca_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) |
| 1911 | { |
| 1912 | struct depca_private *lp = (struct depca_private *) dev->priv; |
| 1913 | struct depca_ioctl *ioc = (struct depca_ioctl *) &rq->ifr_ifru; |
| 1914 | int i, status = 0; |
| 1915 | u_long ioaddr = dev->base_addr; |
| 1916 | union { |
| 1917 | u8 addr[(HASH_TABLE_LEN * ETH_ALEN)]; |
| 1918 | u16 sval[(HASH_TABLE_LEN * ETH_ALEN) >> 1]; |
| 1919 | u32 lval[(HASH_TABLE_LEN * ETH_ALEN) >> 2]; |
| 1920 | } tmp; |
| 1921 | unsigned long flags; |
| 1922 | void *buf; |
| 1923 | |
| 1924 | switch (ioc->cmd) { |
| 1925 | case DEPCA_GET_HWADDR: /* Get the hardware address */ |
| 1926 | for (i = 0; i < ETH_ALEN; i++) { |
| 1927 | tmp.addr[i] = dev->dev_addr[i]; |
| 1928 | } |
| 1929 | ioc->len = ETH_ALEN; |
| 1930 | if (copy_to_user(ioc->data, tmp.addr, ioc->len)) |
| 1931 | return -EFAULT; |
| 1932 | break; |
| 1933 | |
| 1934 | case DEPCA_SET_HWADDR: /* Set the hardware address */ |
| 1935 | if (!capable(CAP_NET_ADMIN)) |
| 1936 | return -EPERM; |
| 1937 | if (copy_from_user(tmp.addr, ioc->data, ETH_ALEN)) |
| 1938 | return -EFAULT; |
| 1939 | for (i = 0; i < ETH_ALEN; i++) { |
| 1940 | dev->dev_addr[i] = tmp.addr[i]; |
| 1941 | } |
| 1942 | netif_stop_queue(dev); |
| 1943 | while (lp->tx_old != lp->tx_new) |
| 1944 | cpu_relax(); /* Wait for the ring to empty */ |
| 1945 | |
| 1946 | STOP_DEPCA; /* Temporarily stop the depca. */ |
| 1947 | depca_init_ring(dev); /* Initialize the descriptor rings */ |
| 1948 | LoadCSRs(dev); /* Reload CSR3 */ |
| 1949 | InitRestartDepca(dev); /* Resume normal operation. */ |
| 1950 | netif_start_queue(dev); /* Unlock the TX ring */ |
| 1951 | break; |
| 1952 | |
| 1953 | case DEPCA_SET_PROM: /* Set Promiscuous Mode */ |
| 1954 | if (!capable(CAP_NET_ADMIN)) |
| 1955 | return -EPERM; |
| 1956 | netif_stop_queue(dev); |
| 1957 | while (lp->tx_old != lp->tx_new) |
| 1958 | cpu_relax(); /* Wait for the ring to empty */ |
| 1959 | |
| 1960 | STOP_DEPCA; /* Temporarily stop the depca. */ |
| 1961 | depca_init_ring(dev); /* Initialize the descriptor rings */ |
| 1962 | lp->init_block.mode |= PROM; /* Set promiscuous mode */ |
| 1963 | |
| 1964 | LoadCSRs(dev); /* Reload CSR3 */ |
| 1965 | InitRestartDepca(dev); /* Resume normal operation. */ |
| 1966 | netif_start_queue(dev); /* Unlock the TX ring */ |
| 1967 | break; |
| 1968 | |
| 1969 | case DEPCA_CLR_PROM: /* Clear Promiscuous Mode */ |
| 1970 | if (!capable(CAP_NET_ADMIN)) |
| 1971 | return -EPERM; |
| 1972 | netif_stop_queue(dev); |
| 1973 | while (lp->tx_old != lp->tx_new) |
| 1974 | cpu_relax(); /* Wait for the ring to empty */ |
| 1975 | |
| 1976 | STOP_DEPCA; /* Temporarily stop the depca. */ |
| 1977 | depca_init_ring(dev); /* Initialize the descriptor rings */ |
| 1978 | lp->init_block.mode &= ~PROM; /* Clear promiscuous mode */ |
| 1979 | |
| 1980 | LoadCSRs(dev); /* Reload CSR3 */ |
| 1981 | InitRestartDepca(dev); /* Resume normal operation. */ |
| 1982 | netif_start_queue(dev); /* Unlock the TX ring */ |
| 1983 | break; |
| 1984 | |
| 1985 | case DEPCA_SAY_BOO: /* Say "Boo!" to the kernel log file */ |
| 1986 | if(!capable(CAP_NET_ADMIN)) |
| 1987 | return -EPERM; |
| 1988 | printk("%s: Boo!\n", dev->name); |
| 1989 | break; |
| 1990 | |
| 1991 | case DEPCA_GET_MCA: /* Get the multicast address table */ |
| 1992 | ioc->len = (HASH_TABLE_LEN >> 3); |
| 1993 | if (copy_to_user(ioc->data, lp->init_block.mcast_table, ioc->len)) |
| 1994 | return -EFAULT; |
| 1995 | break; |
| 1996 | |
| 1997 | case DEPCA_SET_MCA: /* Set a multicast address */ |
| 1998 | if (!capable(CAP_NET_ADMIN)) |
| 1999 | return -EPERM; |
| 2000 | if (ioc->len >= HASH_TABLE_LEN) |
| 2001 | return -EINVAL; |
| 2002 | if (copy_from_user(tmp.addr, ioc->data, ETH_ALEN * ioc->len)) |
| 2003 | return -EFAULT; |
| 2004 | set_multicast_list(dev); |
| 2005 | break; |
| 2006 | |
| 2007 | case DEPCA_CLR_MCA: /* Clear all multicast addresses */ |
| 2008 | if (!capable(CAP_NET_ADMIN)) |
| 2009 | return -EPERM; |
| 2010 | set_multicast_list(dev); |
| 2011 | break; |
| 2012 | |
| 2013 | case DEPCA_MCA_EN: /* Enable pass all multicast addressing */ |
| 2014 | if (!capable(CAP_NET_ADMIN)) |
| 2015 | return -EPERM; |
| 2016 | set_multicast_list(dev); |
| 2017 | break; |
| 2018 | |
| 2019 | case DEPCA_GET_STATS: /* Get the driver statistics */ |
| 2020 | ioc->len = sizeof(lp->pktStats); |
| 2021 | buf = kmalloc(ioc->len, GFP_KERNEL); |
| 2022 | if(!buf) |
| 2023 | return -ENOMEM; |
| 2024 | spin_lock_irqsave(&lp->lock, flags); |
| 2025 | memcpy(buf, &lp->pktStats, ioc->len); |
| 2026 | spin_unlock_irqrestore(&lp->lock, flags); |
| 2027 | if (copy_to_user(ioc->data, buf, ioc->len)) |
| 2028 | status = -EFAULT; |
| 2029 | kfree(buf); |
| 2030 | break; |
| 2031 | |
| 2032 | case DEPCA_CLR_STATS: /* Zero out the driver statistics */ |
| 2033 | if (!capable(CAP_NET_ADMIN)) |
| 2034 | return -EPERM; |
| 2035 | spin_lock_irqsave(&lp->lock, flags); |
| 2036 | memset(&lp->pktStats, 0, sizeof(lp->pktStats)); |
| 2037 | spin_unlock_irqrestore(&lp->lock, flags); |
| 2038 | break; |
| 2039 | |
| 2040 | case DEPCA_GET_REG: /* Get the DEPCA Registers */ |
| 2041 | i = 0; |
| 2042 | tmp.sval[i++] = inw(DEPCA_NICSR); |
| 2043 | outw(CSR0, DEPCA_ADDR); /* status register */ |
| 2044 | tmp.sval[i++] = inw(DEPCA_DATA); |
| 2045 | memcpy(&tmp.sval[i], &lp->init_block, sizeof(struct depca_init)); |
| 2046 | ioc->len = i + sizeof(struct depca_init); |
| 2047 | if (copy_to_user(ioc->data, tmp.addr, ioc->len)) |
| 2048 | return -EFAULT; |
| 2049 | break; |
| 2050 | |
| 2051 | default: |
| 2052 | return -EOPNOTSUPP; |
| 2053 | } |
| 2054 | |
| 2055 | return status; |
| 2056 | } |
| 2057 | |
| 2058 | static int __init depca_module_init (void) |
| 2059 | { |
| 2060 | int err = 0; |
| 2061 | |
| 2062 | #ifdef CONFIG_MCA |
| 2063 | err = mca_register_driver (&depca_mca_driver); |
| 2064 | #endif |
| 2065 | #ifdef CONFIG_EISA |
| 2066 | err |= eisa_driver_register (&depca_eisa_driver); |
| 2067 | #endif |
Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 2068 | err |= platform_driver_register (&depca_isa_driver); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2069 | depca_platform_probe (); |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 2070 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2071 | return err; |
| 2072 | } |
| 2073 | |
| 2074 | static void __exit depca_module_exit (void) |
| 2075 | { |
| 2076 | int i; |
| 2077 | #ifdef CONFIG_MCA |
| 2078 | mca_unregister_driver (&depca_mca_driver); |
| 2079 | #endif |
| 2080 | #ifdef CONFIG_EISA |
| 2081 | eisa_driver_unregister (&depca_eisa_driver); |
| 2082 | #endif |
Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 2083 | platform_driver_unregister (&depca_isa_driver); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2084 | |
| 2085 | for (i = 0; depca_io_ports[i].iobase; i++) { |
| 2086 | if (depca_io_ports[i].device) { |
Russell King | 5d994b7 | 2005-11-05 21:20:21 +0000 | [diff] [blame] | 2087 | depca_io_ports[i].device->dev.platform_data = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2088 | platform_device_unregister (depca_io_ports[i].device); |
| 2089 | depca_io_ports[i].device = NULL; |
| 2090 | } |
| 2091 | } |
| 2092 | } |
| 2093 | |
| 2094 | module_init (depca_module_init); |
| 2095 | module_exit (depca_module_exit); |