diff options
Diffstat (limited to 'drivers/net/ethernet/8390/smc-mca.c')
-rw-r--r-- | drivers/net/ethernet/8390/smc-mca.c | 575 |
1 files changed, 0 insertions, 575 deletions
diff --git a/drivers/net/ethernet/8390/smc-mca.c b/drivers/net/ethernet/8390/smc-mca.c deleted file mode 100644 index 7a68590f2804..000000000000 --- a/drivers/net/ethernet/8390/smc-mca.c +++ /dev/null | |||
@@ -1,575 +0,0 @@ | |||
1 | /* smc-mca.c: A SMC Ultra ethernet driver for linux. */ | ||
2 | /* | ||
3 | Most of this driver, except for ultramca_probe is nearly | ||
4 | verbatim from smc-ultra.c by Donald Becker. The rest is | ||
5 | written and copyright 1996 by David Weis, weisd3458@uni.edu | ||
6 | |||
7 | This is a driver for the SMC Ultra and SMC EtherEZ ethercards. | ||
8 | |||
9 | This driver uses the cards in the 8390-compatible, shared memory mode. | ||
10 | Most of the run-time complexity is handled by the generic code in | ||
11 | 8390.c. | ||
12 | |||
13 | This driver enables the shared memory only when doing the actual data | ||
14 | transfers to avoid a bug in early version of the card that corrupted | ||
15 | data transferred by a AHA1542. | ||
16 | |||
17 | This driver does not support the programmed-I/O data transfer mode of | ||
18 | the EtherEZ. That support (if available) is smc-ez.c. Nor does it | ||
19 | use the non-8390-compatible "Altego" mode. (No support currently planned.) | ||
20 | |||
21 | Changelog: | ||
22 | |||
23 | Paul Gortmaker : multiple card support for module users. | ||
24 | David Weis : Micro Channel-ized it. | ||
25 | Tom Sightler : Added support for IBM PS/2 Ethernet Adapter/A | ||
26 | Christopher Turcksin : Changed MCA-probe so that multiple adapters are | ||
27 | found correctly (Jul 16, 1997) | ||
28 | Chris Beauregard : Tried to merge the two changes above (Dec 15, 1997) | ||
29 | Tom Sightler : Fixed minor detection bug caused by above merge | ||
30 | Tom Sightler : Added support for three more Western Digital | ||
31 | MCA-adapters | ||
32 | Tom Sightler : Added support for 2.2.x mca_find_unused_adapter | ||
33 | Hartmut Schmidt : - Modified parameter detection to handle each | ||
34 | card differently depending on a switch-list | ||
35 | - 'card_ver' removed from the adapter list | ||
36 | - Some minor bug fixes | ||
37 | */ | ||
38 | |||
39 | #include <linux/mca.h> | ||
40 | #include <linux/module.h> | ||
41 | #include <linux/kernel.h> | ||
42 | #include <linux/errno.h> | ||
43 | #include <linux/string.h> | ||
44 | #include <linux/init.h> | ||
45 | #include <linux/interrupt.h> | ||
46 | #include <linux/netdevice.h> | ||
47 | #include <linux/etherdevice.h> | ||
48 | |||
49 | #include <asm/io.h> | ||
50 | |||
51 | #include "8390.h" | ||
52 | |||
53 | #define DRV_NAME "smc-mca" | ||
54 | |||
55 | static int ultramca_open(struct net_device *dev); | ||
56 | static void ultramca_reset_8390(struct net_device *dev); | ||
57 | static void ultramca_get_8390_hdr(struct net_device *dev, | ||
58 | struct e8390_pkt_hdr *hdr, | ||
59 | int ring_page); | ||
60 | static void ultramca_block_input(struct net_device *dev, int count, | ||
61 | struct sk_buff *skb, | ||
62 | int ring_offset); | ||
63 | static void ultramca_block_output(struct net_device *dev, int count, | ||
64 | const unsigned char *buf, | ||
65 | const int start_page); | ||
66 | static int ultramca_close_card(struct net_device *dev); | ||
67 | |||
68 | #define START_PG 0x00 /* First page of TX buffer */ | ||
69 | |||
70 | #define ULTRA_CMDREG 0 /* Offset to ASIC command register. */ | ||
71 | #define ULTRA_RESET 0x80 /* Board reset, in ULTRA_CMDREG. */ | ||
72 | #define ULTRA_MEMENB 0x40 /* Enable the shared memory. */ | ||
73 | #define ULTRA_NIC_OFFSET 16 /* NIC register offset from the base_addr. */ | ||
74 | #define ULTRA_IO_EXTENT 32 | ||
75 | #define EN0_ERWCNT 0x08 /* Early receive warning count. */ | ||
76 | |||
77 | #define _61c8_SMC_Ethercard_PLUS_Elite_A_BNC_AUI_WD8013EP_A 0 | ||
78 | #define _61c9_SMC_Ethercard_PLUS_Elite_A_UTP_AUI_WD8013EP_A 1 | ||
79 | #define _6fc0_WD_Ethercard_PLUS_A_WD8003E_A_OR_WD8003ET_A 2 | ||
80 | #define _6fc1_WD_Starcard_PLUS_A_WD8003ST_A 3 | ||
81 | #define _6fc2_WD_Ethercard_PLUS_10T_A_WD8003W_A 4 | ||
82 | #define _efd4_IBM_PS2_Adapter_A_for_Ethernet_UTP_AUI_WD8013WP_A 5 | ||
83 | #define _efd5_IBM_PS2_Adapter_A_for_Ethernet_BNC_AUI_WD8013WP_A 6 | ||
84 | #define _efe5_IBM_PS2_Adapter_A_for_Ethernet 7 | ||
85 | |||
86 | struct smc_mca_adapters_t { | ||
87 | unsigned int id; | ||
88 | char *name; | ||
89 | }; | ||
90 | |||
91 | #define MAX_ULTRAMCA_CARDS 4 /* Max number of Ultra cards per module */ | ||
92 | |||
93 | static int ultra_io[MAX_ULTRAMCA_CARDS]; | ||
94 | static int ultra_irq[MAX_ULTRAMCA_CARDS]; | ||
95 | MODULE_LICENSE("GPL"); | ||
96 | |||
97 | module_param_array(ultra_io, int, NULL, 0); | ||
98 | module_param_array(ultra_irq, int, NULL, 0); | ||
99 | MODULE_PARM_DESC(ultra_io, "SMC Ultra/EtherEZ MCA I/O base address(es)"); | ||
100 | MODULE_PARM_DESC(ultra_irq, "SMC Ultra/EtherEZ MCA IRQ number(s)"); | ||
101 | |||
102 | static const struct { | ||
103 | unsigned int base_addr; | ||
104 | } addr_table[] = { | ||
105 | { 0x0800 }, | ||
106 | { 0x1800 }, | ||
107 | { 0x2800 }, | ||
108 | { 0x3800 }, | ||
109 | { 0x4800 }, | ||
110 | { 0x5800 }, | ||
111 | { 0x6800 }, | ||
112 | { 0x7800 }, | ||
113 | { 0x8800 }, | ||
114 | { 0x9800 }, | ||
115 | { 0xa800 }, | ||
116 | { 0xb800 }, | ||
117 | { 0xc800 }, | ||
118 | { 0xd800 }, | ||
119 | { 0xe800 }, | ||
120 | { 0xf800 } | ||
121 | }; | ||
122 | |||
123 | #define MEM_MASK 64 | ||
124 | |||
125 | static const struct { | ||
126 | unsigned char mem_index; | ||
127 | unsigned long mem_start; | ||
128 | unsigned char num_pages; | ||
129 | } mem_table[] = { | ||
130 | { 16, 0x0c0000, 40 }, | ||
131 | { 18, 0x0c4000, 40 }, | ||
132 | { 20, 0x0c8000, 40 }, | ||
133 | { 22, 0x0cc000, 40 }, | ||
134 | { 24, 0x0d0000, 40 }, | ||
135 | { 26, 0x0d4000, 40 }, | ||
136 | { 28, 0x0d8000, 40 }, | ||
137 | { 30, 0x0dc000, 40 }, | ||
138 | {144, 0xfc0000, 40 }, | ||
139 | {148, 0xfc8000, 40 }, | ||
140 | {154, 0xfd0000, 40 }, | ||
141 | {156, 0xfd8000, 40 }, | ||
142 | { 0, 0x0c0000, 20 }, | ||
143 | { 1, 0x0c2000, 20 }, | ||
144 | { 2, 0x0c4000, 20 }, | ||
145 | { 3, 0x0c6000, 20 } | ||
146 | }; | ||
147 | |||
148 | #define IRQ_MASK 243 | ||
149 | static const struct { | ||
150 | unsigned char new_irq; | ||
151 | unsigned char old_irq; | ||
152 | } irq_table[] = { | ||
153 | { 3, 3 }, | ||
154 | { 4, 4 }, | ||
155 | { 10, 10 }, | ||
156 | { 14, 15 } | ||
157 | }; | ||
158 | |||
159 | static short smc_mca_adapter_ids[] __initdata = { | ||
160 | 0x61c8, | ||
161 | 0x61c9, | ||
162 | 0x6fc0, | ||
163 | 0x6fc1, | ||
164 | 0x6fc2, | ||
165 | 0xefd4, | ||
166 | 0xefd5, | ||
167 | 0xefe5, | ||
168 | 0x0000 | ||
169 | }; | ||
170 | |||
171 | static char *smc_mca_adapter_names[] __initdata = { | ||
172 | "SMC Ethercard PLUS Elite/A BNC/AUI (WD8013EP/A)", | ||
173 | "SMC Ethercard PLUS Elite/A UTP/AUI (WD8013WP/A)", | ||
174 | "WD Ethercard PLUS/A (WD8003E/A or WD8003ET/A)", | ||
175 | "WD Starcard PLUS/A (WD8003ST/A)", | ||
176 | "WD Ethercard PLUS 10T/A (WD8003W/A)", | ||
177 | "IBM PS/2 Adapter/A for Ethernet UTP/AUI (WD8013WP/A)", | ||
178 | "IBM PS/2 Adapter/A for Ethernet BNC/AUI (WD8013EP/A)", | ||
179 | "IBM PS/2 Adapter/A for Ethernet", | ||
180 | NULL | ||
181 | }; | ||
182 | |||
183 | static int ultra_found = 0; | ||
184 | |||
185 | |||
186 | static const struct net_device_ops ultramca_netdev_ops = { | ||
187 | .ndo_open = ultramca_open, | ||
188 | .ndo_stop = ultramca_close_card, | ||
189 | |||
190 | .ndo_start_xmit = ei_start_xmit, | ||
191 | .ndo_tx_timeout = ei_tx_timeout, | ||
192 | .ndo_get_stats = ei_get_stats, | ||
193 | .ndo_set_rx_mode = ei_set_multicast_list, | ||
194 | .ndo_validate_addr = eth_validate_addr, | ||
195 | .ndo_set_mac_address = eth_mac_addr, | ||
196 | .ndo_change_mtu = eth_change_mtu, | ||
197 | #ifdef CONFIG_NET_POLL_CONTROLLER | ||
198 | .ndo_poll_controller = ei_poll, | ||
199 | #endif | ||
200 | }; | ||
201 | |||
202 | static int __init ultramca_probe(struct device *gen_dev) | ||
203 | { | ||
204 | unsigned short ioaddr; | ||
205 | struct net_device *dev; | ||
206 | unsigned char reg4, num_pages; | ||
207 | struct mca_device *mca_dev = to_mca_device(gen_dev); | ||
208 | char slot = mca_dev->slot; | ||
209 | unsigned char pos2 = 0xff, pos3 = 0xff, pos4 = 0xff, pos5 = 0xff; | ||
210 | int i, rc; | ||
211 | int adapter = mca_dev->index; | ||
212 | int tbase = 0; | ||
213 | int tirq = 0; | ||
214 | int base_addr = ultra_io[ultra_found]; | ||
215 | int irq = ultra_irq[ultra_found]; | ||
216 | |||
217 | if (base_addr || irq) { | ||
218 | printk(KERN_INFO "Probing for SMC MCA adapter"); | ||
219 | if (base_addr) { | ||
220 | printk(KERN_INFO " at I/O address 0x%04x%c", | ||
221 | base_addr, irq ? ' ' : '\n'); | ||
222 | } | ||
223 | if (irq) { | ||
224 | printk(KERN_INFO "using irq %d\n", irq); | ||
225 | } | ||
226 | } | ||
227 | |||
228 | tirq = 0; | ||
229 | tbase = 0; | ||
230 | |||
231 | /* If we're trying to match a specificied irq or io address, | ||
232 | * we'll reject the adapter found unless it's the one we're | ||
233 | * looking for */ | ||
234 | |||
235 | pos2 = mca_device_read_stored_pos(mca_dev, 2); /* io_addr */ | ||
236 | pos3 = mca_device_read_stored_pos(mca_dev, 3); /* shared mem */ | ||
237 | pos4 = mca_device_read_stored_pos(mca_dev, 4); /* ROM bios addr range */ | ||
238 | pos5 = mca_device_read_stored_pos(mca_dev, 5); /* irq, media and RIPL */ | ||
239 | |||
240 | /* Test the following conditions: | ||
241 | * - If an irq parameter is supplied, compare it | ||
242 | * with the irq of the adapter we found | ||
243 | * - If a base_addr paramater is given, compare it | ||
244 | * with the base_addr of the adapter we found | ||
245 | * - Check that the irq and the base_addr of the | ||
246 | * adapter we found is not already in use by | ||
247 | * this driver | ||
248 | */ | ||
249 | |||
250 | switch (mca_dev->index) { | ||
251 | case _61c8_SMC_Ethercard_PLUS_Elite_A_BNC_AUI_WD8013EP_A: | ||
252 | case _61c9_SMC_Ethercard_PLUS_Elite_A_UTP_AUI_WD8013EP_A: | ||
253 | case _efd4_IBM_PS2_Adapter_A_for_Ethernet_UTP_AUI_WD8013WP_A: | ||
254 | case _efd5_IBM_PS2_Adapter_A_for_Ethernet_BNC_AUI_WD8013WP_A: | ||
255 | { | ||
256 | tbase = addr_table[(pos2 & 0xf0) >> 4].base_addr; | ||
257 | tirq = irq_table[(pos5 & 0xc) >> 2].new_irq; | ||
258 | break; | ||
259 | } | ||
260 | case _6fc0_WD_Ethercard_PLUS_A_WD8003E_A_OR_WD8003ET_A: | ||
261 | case _6fc1_WD_Starcard_PLUS_A_WD8003ST_A: | ||
262 | case _6fc2_WD_Ethercard_PLUS_10T_A_WD8003W_A: | ||
263 | case _efe5_IBM_PS2_Adapter_A_for_Ethernet: | ||
264 | { | ||
265 | tbase = ((pos2 & 0x0fe) * 0x10); | ||
266 | tirq = irq_table[(pos5 & 3)].old_irq; | ||
267 | break; | ||
268 | } | ||
269 | } | ||
270 | |||
271 | if(!tirq || !tbase || | ||
272 | (irq && irq != tirq) || | ||
273 | (base_addr && tbase != base_addr)) | ||
274 | /* FIXME: we're trying to force the ordering of the | ||
275 | * devices here, there should be a way of getting this | ||
276 | * to happen */ | ||
277 | return -ENXIO; | ||
278 | |||
279 | /* Adapter found. */ | ||
280 | dev = alloc_ei_netdev(); | ||
281 | if(!dev) | ||
282 | return -ENODEV; | ||
283 | |||
284 | SET_NETDEV_DEV(dev, gen_dev); | ||
285 | mca_device_set_name(mca_dev, smc_mca_adapter_names[adapter]); | ||
286 | mca_device_set_claim(mca_dev, 1); | ||
287 | |||
288 | printk(KERN_INFO "smc_mca: %s found in slot %d\n", | ||
289 | smc_mca_adapter_names[adapter], slot + 1); | ||
290 | |||
291 | ultra_found++; | ||
292 | |||
293 | dev->base_addr = ioaddr = mca_device_transform_ioport(mca_dev, tbase); | ||
294 | dev->irq = mca_device_transform_irq(mca_dev, tirq); | ||
295 | dev->mem_start = 0; | ||
296 | num_pages = 40; | ||
297 | |||
298 | switch (adapter) { /* card-# in const array above [hs] */ | ||
299 | case _61c8_SMC_Ethercard_PLUS_Elite_A_BNC_AUI_WD8013EP_A: | ||
300 | case _61c9_SMC_Ethercard_PLUS_Elite_A_UTP_AUI_WD8013EP_A: | ||
301 | { | ||
302 | for (i = 0; i < 16; i++) { /* taking 16 counts | ||
303 | * up to 15 [hs] */ | ||
304 | if (mem_table[i].mem_index == (pos3 & ~MEM_MASK)) { | ||
305 | dev->mem_start = (unsigned long) | ||
306 | mca_device_transform_memory(mca_dev, (void *)mem_table[i].mem_start); | ||
307 | num_pages = mem_table[i].num_pages; | ||
308 | } | ||
309 | } | ||
310 | break; | ||
311 | } | ||
312 | case _6fc0_WD_Ethercard_PLUS_A_WD8003E_A_OR_WD8003ET_A: | ||
313 | case _6fc1_WD_Starcard_PLUS_A_WD8003ST_A: | ||
314 | case _6fc2_WD_Ethercard_PLUS_10T_A_WD8003W_A: | ||
315 | case _efe5_IBM_PS2_Adapter_A_for_Ethernet: | ||
316 | { | ||
317 | dev->mem_start = (unsigned long) | ||
318 | mca_device_transform_memory(mca_dev, (void *)((pos3 & 0xfc) * 0x1000)); | ||
319 | num_pages = 0x40; | ||
320 | break; | ||
321 | } | ||
322 | case _efd4_IBM_PS2_Adapter_A_for_Ethernet_UTP_AUI_WD8013WP_A: | ||
323 | case _efd5_IBM_PS2_Adapter_A_for_Ethernet_BNC_AUI_WD8013WP_A: | ||
324 | { | ||
325 | /* courtesy of gamera@quartz.ocn.ne.jp, pos3 indicates | ||
326 | * the index of the 0x2000 step. | ||
327 | * beware different number of pages [hs] | ||
328 | */ | ||
329 | dev->mem_start = (unsigned long) | ||
330 | mca_device_transform_memory(mca_dev, (void *)(0xc0000 + (0x2000 * (pos3 & 0xf)))); | ||
331 | num_pages = 0x20 + (2 * (pos3 & 0x10)); | ||
332 | break; | ||
333 | } | ||
334 | } | ||
335 | |||
336 | /* sanity check, shouldn't happen */ | ||
337 | if (dev->mem_start == 0) { | ||
338 | rc = -ENODEV; | ||
339 | goto err_unclaim; | ||
340 | } | ||
341 | |||
342 | if (!request_region(ioaddr, ULTRA_IO_EXTENT, DRV_NAME)) { | ||
343 | rc = -ENODEV; | ||
344 | goto err_unclaim; | ||
345 | } | ||
346 | |||
347 | reg4 = inb(ioaddr + 4) & 0x7f; | ||
348 | outb(reg4, ioaddr + 4); | ||
349 | |||
350 | for (i = 0; i < 6; i++) | ||
351 | dev->dev_addr[i] = inb(ioaddr + 8 + i); | ||
352 | |||
353 | printk(KERN_INFO "smc_mca[%d]: Parameters: %#3x, %pM", | ||
354 | slot + 1, ioaddr, dev->dev_addr); | ||
355 | |||
356 | /* Switch from the station address to the alternate register set | ||
357 | * and read the useful registers there. | ||
358 | */ | ||
359 | |||
360 | outb(0x80 | reg4, ioaddr + 4); | ||
361 | |||
362 | /* Enable FINE16 mode to avoid BIOS ROM width mismatches @ reboot. | ||
363 | */ | ||
364 | |||
365 | outb(0x80 | inb(ioaddr + 0x0c), ioaddr + 0x0c); | ||
366 | |||
367 | /* Switch back to the station address register set so that | ||
368 | * the MS-DOS driver can find the card after a warm boot. | ||
369 | */ | ||
370 | |||
371 | outb(reg4, ioaddr + 4); | ||
372 | |||
373 | dev_set_drvdata(gen_dev, dev); | ||
374 | |||
375 | /* The 8390 isn't at the base address, so fake the offset | ||
376 | */ | ||
377 | |||
378 | dev->base_addr = ioaddr + ULTRA_NIC_OFFSET; | ||
379 | |||
380 | ei_status.name = "SMC Ultra MCA"; | ||
381 | ei_status.word16 = 1; | ||
382 | ei_status.tx_start_page = START_PG; | ||
383 | ei_status.rx_start_page = START_PG + TX_PAGES; | ||
384 | ei_status.stop_page = num_pages; | ||
385 | |||
386 | ei_status.mem = ioremap(dev->mem_start, (ei_status.stop_page - START_PG) * 256); | ||
387 | if (!ei_status.mem) { | ||
388 | rc = -ENOMEM; | ||
389 | goto err_release_region; | ||
390 | } | ||
391 | |||
392 | dev->mem_end = dev->mem_start + (ei_status.stop_page - START_PG) * 256; | ||
393 | |||
394 | printk(", IRQ %d memory %#lx-%#lx.\n", | ||
395 | dev->irq, dev->mem_start, dev->mem_end - 1); | ||
396 | |||
397 | ei_status.reset_8390 = &ultramca_reset_8390; | ||
398 | ei_status.block_input = &ultramca_block_input; | ||
399 | ei_status.block_output = &ultramca_block_output; | ||
400 | ei_status.get_8390_hdr = &ultramca_get_8390_hdr; | ||
401 | |||
402 | ei_status.priv = slot; | ||
403 | |||
404 | dev->netdev_ops = &ultramca_netdev_ops; | ||
405 | |||
406 | NS8390_init(dev, 0); | ||
407 | |||
408 | rc = register_netdev(dev); | ||
409 | if (rc) | ||
410 | goto err_unmap; | ||
411 | |||
412 | return 0; | ||
413 | |||
414 | err_unmap: | ||
415 | iounmap(ei_status.mem); | ||
416 | err_release_region: | ||
417 | release_region(ioaddr, ULTRA_IO_EXTENT); | ||
418 | err_unclaim: | ||
419 | mca_device_set_claim(mca_dev, 0); | ||
420 | free_netdev(dev); | ||
421 | return rc; | ||
422 | } | ||
423 | |||
424 | static int ultramca_open(struct net_device *dev) | ||
425 | { | ||
426 | int ioaddr = dev->base_addr - ULTRA_NIC_OFFSET; /* ASIC addr */ | ||
427 | int retval; | ||
428 | |||
429 | if ((retval = request_irq(dev->irq, ei_interrupt, 0, dev->name, dev))) | ||
430 | return retval; | ||
431 | |||
432 | outb(ULTRA_MEMENB, ioaddr); /* Enable memory */ | ||
433 | outb(0x80, ioaddr + 5); /* ??? */ | ||
434 | outb(0x01, ioaddr + 6); /* Enable interrupts and memory. */ | ||
435 | outb(0x04, ioaddr + 5); /* ??? */ | ||
436 | |||
437 | /* Set the early receive warning level in window 0 high enough not | ||
438 | * to receive ERW interrupts. | ||
439 | */ | ||
440 | |||
441 | /* outb_p(E8390_NODMA + E8390_PAGE0, dev->base_addr); | ||
442 | * outb(0xff, dev->base_addr + EN0_ERWCNT); | ||
443 | */ | ||
444 | |||
445 | ei_open(dev); | ||
446 | return 0; | ||
447 | } | ||
448 | |||
449 | static void ultramca_reset_8390(struct net_device *dev) | ||
450 | { | ||
451 | int ioaddr = dev->base_addr - ULTRA_NIC_OFFSET; /* ASIC addr */ | ||
452 | |||
453 | outb(ULTRA_RESET, ioaddr); | ||
454 | if (ei_debug > 1) | ||
455 | printk("resetting Ultra, t=%ld...", jiffies); | ||
456 | ei_status.txing = 0; | ||
457 | |||
458 | outb(0x80, ioaddr + 5); /* ??? */ | ||
459 | outb(0x01, ioaddr + 6); /* Enable interrupts and memory. */ | ||
460 | |||
461 | if (ei_debug > 1) | ||
462 | printk("reset done\n"); | ||
463 | } | ||
464 | |||
465 | /* Grab the 8390 specific header. Similar to the block_input routine, but | ||
466 | * we don't need to be concerned with ring wrap as the header will be at | ||
467 | * the start of a page, so we optimize accordingly. | ||
468 | */ | ||
469 | |||
470 | static void ultramca_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr, int ring_page) | ||
471 | { | ||
472 | void __iomem *hdr_start = ei_status.mem + ((ring_page - START_PG) << 8); | ||
473 | |||
474 | #ifdef notdef | ||
475 | /* Officially this is what we are doing, but the readl() is faster */ | ||
476 | memcpy_fromio(hdr, hdr_start, sizeof(struct e8390_pkt_hdr)); | ||
477 | #else | ||
478 | ((unsigned int*)hdr)[0] = readl(hdr_start); | ||
479 | #endif | ||
480 | } | ||
481 | |||
482 | /* Block input and output are easy on shared memory ethercards, the only | ||
483 | * complication is when the ring buffer wraps. | ||
484 | */ | ||
485 | |||
486 | static void ultramca_block_input(struct net_device *dev, int count, struct sk_buff *skb, int ring_offset) | ||
487 | { | ||
488 | void __iomem *xfer_start = ei_status.mem + ring_offset - START_PG * 256; | ||
489 | |||
490 | if (ring_offset + count > ei_status.stop_page * 256) { | ||
491 | /* We must wrap the input move. */ | ||
492 | int semi_count = ei_status.stop_page * 256 - ring_offset; | ||
493 | memcpy_fromio(skb->data, xfer_start, semi_count); | ||
494 | count -= semi_count; | ||
495 | memcpy_fromio(skb->data + semi_count, ei_status.mem + TX_PAGES * 256, count); | ||
496 | } else { | ||
497 | memcpy_fromio(skb->data, xfer_start, count); | ||
498 | } | ||
499 | |||
500 | } | ||
501 | |||
502 | static void ultramca_block_output(struct net_device *dev, int count, const unsigned char *buf, | ||
503 | int start_page) | ||
504 | { | ||
505 | void __iomem *shmem = ei_status.mem + ((start_page - START_PG) << 8); | ||
506 | |||
507 | memcpy_toio(shmem, buf, count); | ||
508 | } | ||
509 | |||
510 | static int ultramca_close_card(struct net_device *dev) | ||
511 | { | ||
512 | int ioaddr = dev->base_addr - ULTRA_NIC_OFFSET; /* ASIC addr */ | ||
513 | |||
514 | netif_stop_queue(dev); | ||
515 | |||
516 | if (ei_debug > 1) | ||
517 | printk("%s: Shutting down ethercard.\n", dev->name); | ||
518 | |||
519 | outb(0x00, ioaddr + 6); /* Disable interrupts. */ | ||
520 | free_irq(dev->irq, dev); | ||
521 | |||
522 | NS8390_init(dev, 0); | ||
523 | /* We should someday disable shared memory and change to 8-bit mode | ||
524 | * "just in case"... | ||
525 | */ | ||
526 | |||
527 | return 0; | ||
528 | } | ||
529 | |||
530 | static int ultramca_remove(struct device *gen_dev) | ||
531 | { | ||
532 | struct mca_device *mca_dev = to_mca_device(gen_dev); | ||
533 | struct net_device *dev = dev_get_drvdata(gen_dev); | ||
534 | |||
535 | if (dev) { | ||
536 | /* NB: ultra_close_card() does free_irq */ | ||
537 | int ioaddr = dev->base_addr - ULTRA_NIC_OFFSET; | ||
538 | |||
539 | unregister_netdev(dev); | ||
540 | mca_device_set_claim(mca_dev, 0); | ||
541 | release_region(ioaddr, ULTRA_IO_EXTENT); | ||
542 | iounmap(ei_status.mem); | ||
543 | free_netdev(dev); | ||
544 | } | ||
545 | return 0; | ||
546 | } | ||
547 | |||
548 | |||
549 | static struct mca_driver ultra_driver = { | ||
550 | .id_table = smc_mca_adapter_ids, | ||
551 | .driver = { | ||
552 | .name = "smc-mca", | ||
553 | .bus = &mca_bus_type, | ||
554 | .probe = ultramca_probe, | ||
555 | .remove = ultramca_remove, | ||
556 | } | ||
557 | }; | ||
558 | |||
559 | static int __init ultramca_init_module(void) | ||
560 | { | ||
561 | if(!MCA_bus) | ||
562 | return -ENXIO; | ||
563 | |||
564 | mca_register_driver(&ultra_driver); | ||
565 | |||
566 | return ultra_found ? 0 : -ENXIO; | ||
567 | } | ||
568 | |||
569 | static void __exit ultramca_cleanup_module(void) | ||
570 | { | ||
571 | mca_unregister_driver(&ultra_driver); | ||
572 | } | ||
573 | module_init(ultramca_init_module); | ||
574 | module_exit(ultramca_cleanup_module); | ||
575 | |||