Merge with Linux 2.4.0-test5-pre3.
[linux-2.6/linux-mips.git] / drivers / net / aironet4500_card.c
blobd6a9c505d9e7be5d896cc52fe7939090529d88d6
1 /*
2 * Aironet 4500 PCI-ISA-i365 driver
4 * Elmer Joandi, Januar 1999
5 * Copyright GPL
6 *
8 * Revision 0.1 ,started 30.12.1998
10 * Revision 0.2, Feb 27, 2000
11 * Jeff Garzik - softnet, cleanups
14 #ifdef MODULE
15 static const char *awc_version =
16 "aironet4500_cards.c v0.2 Feb 27, 2000 Elmer Joandi, elmer@ylenurme.ee.\n";
17 #endif
19 #include <linux/version.h>
20 #include <linux/config.h>
21 #include <linux/module.h>
23 #include <linux/kernel.h>
24 #include <linux/sched.h>
25 #include <linux/ptrace.h>
26 #include <linux/malloc.h>
27 #include <linux/string.h>
28 #include <linux/timer.h>
29 #include <linux/interrupt.h>
30 #include <linux/in.h>
31 #include <asm/io.h>
32 #include <asm/system.h>
33 #include <asm/bitops.h>
35 #include <linux/netdevice.h>
36 #include <linux/etherdevice.h>
37 #include <linux/skbuff.h>
38 #include <linux/if_arp.h>
39 #include <linux/ioport.h>
40 #include <linux/delay.h>
42 #include "aironet4500.h"
44 #define PCI_VENDOR_ID_AIRONET 0x14b9
45 #define PCI_DEVICE_AIRONET_4800_1 0x1
46 #define PCI_DEVICE_AIRONET_4800 0x4500
47 #define PCI_DEVICE_AIRONET_4500 0x4800
48 #define AIRONET4X00_IO_SIZE 0x40
49 #define AIRONET4X00_CIS_SIZE 0x300
50 #define AIRONET4X00_MEM_SIZE 0x300
52 #define AIRONET4500_PCI 1
53 #define AIRONET4500_PNP 2
54 #define AIRONET4500_ISA 3
55 #define AIRONET4500_365 4
58 #ifdef CONFIG_AIRONET4500_PCI
60 #include <linux/pci.h>
63 static int reverse_probe =0 ;
66 static int awc_pci_init(struct net_device * dev, struct pci_dev *pdev,
67 int ioaddr, int cis_addr, int mem_addr,u8 pci_irq_line) ;
70 int awc4500_pci_probe(struct net_device *dev)
72 int cards_found = 0;
73 static int pci_index = 0; /* Static, for multiple probe calls. */
74 u8 pci_irq_line = 0;
75 // int p;
77 unsigned char awc_pci_dev, awc_pci_bus;
79 if (!pci_present())
80 return -1;
82 for (;pci_index < 0xff; pci_index++) {
83 u16 vendor, device, pci_command, new_command;
84 u32 pci_memaddr;
85 u32 pci_ioaddr;
86 u32 pci_cisaddr;
87 struct pci_dev *pdev;
89 if (pcibios_find_class (PCI_CLASS_NETWORK_OTHER << 8,
90 reverse_probe ? 0xfe - pci_index : pci_index,
91 &awc_pci_bus, &awc_pci_dev) != PCIBIOS_SUCCESSFUL){
92 if (reverse_probe){
93 continue;
94 } else {
95 break;
98 pdev = pci_find_slot(awc_pci_bus, awc_pci_dev);
99 if (!pdev)
100 continue;
101 if (pci_enable_device(pdev))
102 continue;
103 vendor = pdev->vendor;
104 device = pdev->device;
105 pci_irq_line = pdev->irq;
106 pci_memaddr = pci_resource_start (pdev, 0);
107 pci_cisaddr = pci_resource_start (pdev, 1);
108 pci_ioaddr = pci_resource_start (pdev, 2);
110 // printk("\n pci capabilities %x and ptr %x \n",pci_caps,pci_caps_ptr);
111 /* Remove I/O space marker in bit 0. */
113 if (vendor != PCI_VENDOR_ID_AIRONET)
114 continue;
115 if (device != PCI_DEVICE_AIRONET_4800_1 &&
116 device != PCI_DEVICE_AIRONET_4800 &&
117 device != PCI_DEVICE_AIRONET_4500 )
118 continue;
120 // if (check_region(pci_ioaddr, AIRONET4X00_IO_SIZE) ||
121 // check_region(pci_cisaddr, AIRONET4X00_CIS_SIZE) ||
122 // check_region(pci_memaddr, AIRONET4X00_MEM_SIZE)) {
123 // printk(KERN_ERR "aironet4X00 mem addrs not available for maping \n");
124 // continue;
125 // }
126 if (!request_region(pci_ioaddr, AIRONET4X00_IO_SIZE, "aironet4x00 ioaddr"))
127 continue;
128 // request_region(pci_cisaddr, AIRONET4X00_CIS_SIZE, "aironet4x00 cis");
129 // request_region(pci_memaddr, AIRONET4X00_MEM_SIZE, "aironet4x00 mem");
131 // pci_write_config_word(pdev, PCI_COMMAND, 0);
132 udelay(10000);
134 pci_read_config_word(pdev, PCI_COMMAND, &pci_command);
135 new_command = pci_command |0x100 | PCI_COMMAND_MEMORY|PCI_COMMAND_IO;
136 if (pci_command != new_command) {
137 printk(KERN_INFO " The PCI BIOS has not enabled this"
138 " device! Updating PCI command %4.4x->%4.4x.\n",
139 pci_command, new_command);
140 pci_write_config_word(pdev, PCI_COMMAND, new_command);
144 /* if (device == PCI_DEVICE_AIRONET_4800)
145 pci_write_config_dword(pdev, 0x40, 0x00000000);
147 udelay(1000);
149 if (device == PCI_DEVICE_AIRONET_4800)
150 pci_write_config_dword(pdev, 0x40, 0x40000000);
152 if (awc_pci_init(dev, pdev, pci_ioaddr,pci_cisaddr,pci_memaddr,pci_irq_line)){
153 printk(KERN_ERR "awc4800 pci init failed \n");
154 break;
156 dev = 0;
157 cards_found++;
160 return cards_found ? 0 : -ENODEV;
164 static int awc_pci_init(struct net_device * dev, struct pci_dev *pdev,
165 int ioaddr, int cis_addr, int mem_addr, u8 pci_irq_line) {
167 int i;
169 if (!dev) {
170 dev = init_etherdev(dev, 0 );
172 dev->priv = kmalloc(sizeof(struct awc_private),GFP_KERNEL );
173 memset(dev->priv,0,sizeof(struct awc_private));
174 if (!dev->priv) {
175 printk(KERN_CRIT "aironet4x00: could not allocate device private, some unstability may follow\n");
176 return -1;
179 // ether_setup(dev);
181 // dev->tx_queue_len = tx_queue_len;
183 dev->hard_start_xmit = &awc_start_xmit;
184 // dev->set_config = &awc_config_misiganes,aga mitte awc_config;
185 dev->get_stats = &awc_get_stats;
186 // dev->set_multicast_list = &awc_set_multicast_list;
187 dev->change_mtu = awc_change_mtu;
188 dev->init = &awc_init;
189 dev->open = &awc_open;
190 dev->stop = &awc_close;
191 dev->base_addr = ioaddr;
192 dev->irq = pci_irq_line;
193 dev->tx_timeout = &awc_tx_timeout;
194 dev->watchdog_timeo = AWC_TX_TIMEOUT;
197 request_irq(dev->irq,awc_interrupt, SA_SHIRQ | SA_INTERRUPT ,"Aironet 4X00",dev);
199 awc_private_init( dev);
200 awc_init(dev);
202 i=0;
203 while (aironet4500_devices[i] && i < MAX_AWCS-1) i++;
204 if (!aironet4500_devices[i]){
205 aironet4500_devices[i]=dev;
206 ((struct awc_private *)
207 aironet4500_devices[i]->priv)->card_type = AIRONET4500_PCI;
209 if (awc_proc_set_fun)
210 awc_proc_set_fun(i);
213 // if (register_netdev(dev) != 0) {
214 // printk(KERN_NOTICE "awc_cs: register_netdev() failed\n");
215 // goto failed;
216 // }
218 return 0;
219 // failed:
220 // return -1;
224 #ifdef MODULE
225 static void awc_pci_release(void) {
227 // long flags;
228 int i=0;
230 DEBUG(0, "awc_detach \n");
232 i=0;
233 while ( i < MAX_AWCS) {
234 if (!aironet4500_devices[i])
235 {i++; continue;};
236 if (((struct awc_private *)aironet4500_devices[i]->priv)->card_type != AIRONET4500_PCI)
237 {i++; continue;}
239 if (awc_proc_unset_fun)
240 awc_proc_unset_fun(i);
241 release_region(aironet4500_devices[i]->base_addr, AIRONET4X00_IO_SIZE);
242 // release_region(pci_cisaddr, AIRONET4X00_CIS_SIZE, "aironet4x00 cis");
243 // release_region(pci_memaddr, AIRONET4X00_MEM_SIZE, "aironet4x00 mem");
245 unregister_netdev(aironet4500_devices[i]);
246 free_irq(aironet4500_devices[i]->irq,aironet4500_devices[i]);
247 kfree(aironet4500_devices[i]->priv);
248 kfree(aironet4500_devices[i]);
250 aironet4500_devices[i]=0;
253 i++;
260 #endif //MODULE
263 #endif /* CONFIG_AIRONET4500_PCI */
265 #ifdef CONFIG_AIRONET4500_PNP
267 #include <linux/isapnp.h>
268 #define AIRONET4X00_IO_SIZE 0x40
270 #define isapnp_logdev pci_dev
271 #define isapnp_dev pci_bus
272 #define isapnp_find_device isapnp_find_card
273 #define isapnp_find_logdev isapnp_find_dev
274 #define PNP_BUS bus
275 #define PNP_BUS_NUMBER number
276 #define PNP_DEV_NUMBER devfn
279 int awc4500_pnp_hw_reset(struct net_device *dev){
280 struct isapnp_logdev *logdev;
282 DEBUG(0, "awc_pnp_reset \n");
284 if (!dev->priv ) {
285 printk("awc4500 no dev->priv in hw_reset\n");
286 return -1;
289 logdev = ((struct isapnp_logdev *) ((struct awc_private *)dev->priv)->bus);
291 if (!logdev ) {
292 printk("awc4500 no pnp logdev in hw_reset\n");
293 return -1;
296 if (isapnp_cfg_begin(logdev->PNP_BUS->PNP_BUS_NUMBER, logdev->PNP_DEV_NUMBER)<0)
297 printk("isapnp cfg failed at release \n");
298 isapnp_deactivate(logdev->PNP_DEV_NUMBER);
299 isapnp_cfg_end();
301 udelay(100);
304 if (isapnp_cfg_begin(logdev->PNP_BUS->PNP_BUS_NUMBER, logdev->PNP_DEV_NUMBER) < 0) {
305 printk("%s cfg begin failed in hw_reset for csn %x devnum %x \n",
306 dev->name, logdev->PNP_BUS->PNP_BUS_NUMBER, logdev->PNP_DEV_NUMBER);
307 return -EAGAIN;
310 isapnp_activate(logdev->PNP_DEV_NUMBER); /* activate device */
311 isapnp_cfg_end();
313 return 0;
316 int awc4500_pnp_probe(struct net_device *dev)
318 int isa_index = 0;
319 int isa_irq_line = 0;
320 int isa_ioaddr = 0;
321 int card = 0;
322 int i=0;
323 struct isapnp_dev * pnp_dev ;
324 struct isapnp_logdev *logdev;
326 while (1) {
328 pnp_dev = isapnp_find_device(
329 ISAPNP_VENDOR('A','W','L'),
330 ISAPNP_DEVICE(1),
333 if (!pnp_dev) break;
335 isa_index++;
337 logdev = isapnp_find_logdev(pnp_dev, ISAPNP_VENDOR('A','W','L'),
338 ISAPNP_FUNCTION(1),
340 if (!logdev){
341 printk("No logical device found on Aironet board \n");
342 return -ENODEV;
344 if (isapnp_cfg_begin(logdev->PNP_BUS->PNP_BUS_NUMBER, logdev->PNP_DEV_NUMBER) < 0) {
345 printk("cfg begin failed for csn %x devnum %x \n",
346 logdev->PNP_BUS->PNP_BUS_NUMBER, logdev->PNP_DEV_NUMBER);
347 return -EAGAIN;
349 isapnp_activate(logdev->PNP_DEV_NUMBER); /* activate device */
350 isapnp_cfg_end();
352 isa_irq_line = logdev->irq;
353 isa_ioaddr = logdev->resource[0].start;
354 request_region(isa_ioaddr, AIRONET4X00_IO_SIZE, "aironet4x00 ioaddr");
356 if (!dev) {
357 dev = init_etherdev(dev, 0 );
359 dev->priv = kmalloc(sizeof(struct awc_private),GFP_KERNEL );
360 memset(dev->priv,0,sizeof(struct awc_private));
361 if (!dev->priv) {
362 printk(KERN_CRIT "aironet4x00: could not allocate device private, some unstability may follow\n");
363 return -1;
365 ((struct awc_private *)dev->priv)->bus = logdev;
367 // ether_setup(dev);
369 // dev->tx_queue_len = tx_queue_len;
371 dev->hard_start_xmit = &awc_start_xmit;
372 // dev->set_config = &awc_config_misiganes,aga mitte awc_config;
373 dev->get_stats = &awc_get_stats;
374 // dev->set_multicast_list = &awc_set_multicast_list;
375 dev->change_mtu = awc_change_mtu;
376 dev->init = &awc_init;
377 dev->open = &awc_open;
378 dev->stop = &awc_close;
379 dev->base_addr = isa_ioaddr;
380 dev->irq = isa_irq_line;
381 dev->tx_timeout = &awc_tx_timeout;
382 dev->watchdog_timeo = AWC_TX_TIMEOUT;
384 netif_start_queue (dev);
386 request_irq(dev->irq,awc_interrupt , SA_SHIRQ | SA_INTERRUPT ,"Aironet 4X00",dev);
388 awc_private_init( dev);
390 ((struct awc_private *)dev->priv)->bus = logdev;
392 cli();
393 if ( awc_init(dev) ){
394 printk("card not found at irq %x io %lx\n",dev->irq, dev->base_addr);
395 if (card==0){
396 sti();
397 return -1;
399 sti();
400 break;
402 udelay(10);
403 sti();
404 i=0;
405 while (aironet4500_devices[i] && i < MAX_AWCS-1) i++;
406 if (!aironet4500_devices[i] && i < MAX_AWCS-1 ){
407 aironet4500_devices[i]=dev;
409 ((struct awc_private *)
410 aironet4500_devices[i]->priv)->card_type = AIRONET4500_PNP;
412 if (awc_proc_set_fun)
413 awc_proc_set_fun(i);
414 } else {
415 printk(KERN_CRIT "Out of resources (MAX_AWCS) \n");
416 return -1;
419 card++;
422 if (card == 0) return -ENODEV;
423 return 0;
426 #ifdef MODULE
427 static void awc_pnp_release(void) {
429 // long flags;
430 int i=0;
431 struct isapnp_logdev *logdev;
433 DEBUG(0, "awc_detach \n");
435 i=0;
436 while ( i < MAX_AWCS) {
437 if (!aironet4500_devices[i])
438 {i++; continue;}
439 if (((struct awc_private *)aironet4500_devices[i]->priv)->card_type != AIRONET4500_PNP)
440 {i++; continue;}
442 logdev = ((struct isapnp_logdev *) ((struct awc_private *)aironet4500_devices[i]->priv)->bus);
444 if (!logdev )
445 printk("awc4500 no pnp logdev in pnp_release\n");
447 if (awc_proc_unset_fun)
448 awc_proc_unset_fun(i);
449 if (isapnp_cfg_begin(logdev->PNP_BUS->PNP_BUS_NUMBER, logdev->PNP_DEV_NUMBER)<0)
450 printk("isapnp cfg failed at release \n");
451 isapnp_deactivate(logdev->PNP_DEV_NUMBER);
452 isapnp_cfg_end();
454 release_region(aironet4500_devices[i]->base_addr, AIRONET4X00_IO_SIZE);
455 // release_region(isa_cisaddr, AIRONET4X00_CIS_SIZE, "aironet4x00 cis");
456 // release_region(isa_memaddr, AIRONET4X00_MEM_SIZE, "aironet4x00 mem");
458 unregister_netdev(aironet4500_devices[i]);
459 free_irq(aironet4500_devices[i]->irq,aironet4500_devices[i]);
460 kfree(aironet4500_devices[i]->priv);
461 kfree(aironet4500_devices[i]);
463 aironet4500_devices[i]=0;
466 i++;
472 #endif //MODULE
473 #endif /* CONFIG_AIRONET4500_PNP */
475 #ifdef CONFIG_AIRONET4500_ISA
477 static int irq[] = {0,0,0,0,0};
478 static int io[] = {0,0,0,0,0};
481 EXPORT_SYMBOL(irq);
482 EXPORT_SYMBOL(io);
484 MODULE_PARM(irq,"i");
485 MODULE_PARM_DESC(irq,"Aironet 4x00 ISA non-PNP irqs,required");
486 MODULE_PARM(io,"i");
487 MODULE_PARM_DESC(io,"Aironet 4x00 ISA non-PNP ioports,required");
491 int awc4500_isa_probe(struct net_device *dev)
493 // int cards_found = 0;
494 // static int isa_index = 0; /* Static, for multiple probe calls. */
495 int isa_irq_line = 0;
496 int isa_ioaddr = 0;
497 // int p;
498 int card = 0;
499 int i=0;
501 if (! io[0] || ! irq[0]){
503 // printk(" Both irq and io params must be supplied for ISA mode !!!\n");
504 return -ENODEV;
507 printk(KERN_WARNING " Aironet ISA Card in non-PNP(ISA) mode sometimes feels bad on interrupt \n");
508 printk(KERN_WARNING " Use aironet4500_pnp if any problems(i.e. card malfunctioning). \n");
509 printk(KERN_WARNING " Note that this isa probe is not friendly... must give exact parameters \n");
511 while (irq[card] !=0){
513 isa_ioaddr = io[card];
514 isa_irq_line = irq[card];
516 request_region(isa_ioaddr, AIRONET4X00_IO_SIZE, "aironet4x00 ioaddr");
518 if (!dev) {
519 dev = init_etherdev(dev, 0 );
521 dev->priv = kmalloc(sizeof(struct awc_private),GFP_KERNEL );
522 memset(dev->priv,0,sizeof(struct awc_private));
523 if (!dev->priv) {
524 printk(KERN_CRIT "aironet4x00: could not allocate device private, some unstability may follow\n");
525 return -1;
528 // ether_setup(dev);
530 // dev->tx_queue_len = tx_queue_len;
532 dev->hard_start_xmit = &awc_start_xmit;
533 // dev->set_config = &awc_config_misiganes,aga mitte awc_config;
534 dev->get_stats = &awc_get_stats;
535 // dev->set_multicast_list = &awc_set_multicast_list;
536 dev->change_mtu = awc_change_mtu;
537 dev->init = &awc_init;
538 dev->open = &awc_open;
539 dev->stop = &awc_close;
540 dev->base_addr = isa_ioaddr;
541 dev->irq = isa_irq_line;
542 dev->tx_timeout = &awc_tx_timeout;
543 dev->watchdog_timeo = AWC_TX_TIMEOUT;
545 request_irq(dev->irq,awc_interrupt ,SA_INTERRUPT ,"Aironet 4X00",dev);
547 awc_private_init( dev);
548 if ( awc_init(dev) ){
549 printk("card not found at irq %x mem %x\n",irq[card],io[card]);
550 if (card==0)
551 return -1;
552 break;
555 i=0;
556 while (aironet4500_devices[i] && i < MAX_AWCS-1) i++;
557 if (!aironet4500_devices[i]){
558 aironet4500_devices[i]=dev;
559 ((struct awc_private *)
560 aironet4500_devices[i]->priv)->card_type = AIRONET4500_ISA;
562 if (awc_proc_set_fun)
563 awc_proc_set_fun(i);
566 card++;
568 if (card == 0 ) {
569 return -ENODEV;
571 return 0;
574 #ifdef MODULE
575 static void awc_isa_release(void) {
577 // long flags;
578 int i=0;
580 DEBUG(0, "awc_detach \n");
582 i=0;
583 while ( i < MAX_AWCS) {
585 if (!aironet4500_devices[i])
586 {i++; continue;}
587 if (((struct awc_private *)aironet4500_devices[i]->priv)->card_type != AIRONET4500_ISA)
588 {i++; continue;}
590 if (awc_proc_unset_fun)
591 awc_proc_unset_fun(i);
592 release_region(aironet4500_devices[i]->base_addr, AIRONET4X00_IO_SIZE);
593 // release_region(isa_cisaddr, AIRONET4X00_CIS_SIZE, "aironet4x00 cis");
594 // release_region(isa_memaddr, AIRONET4X00_MEM_SIZE, "aironet4x00 mem");
596 unregister_netdev(aironet4500_devices[i]);
597 free_irq(aironet4500_devices[i]->irq,aironet4500_devices[i]);
598 kfree(aironet4500_devices[i]->priv);
599 kfree(aironet4500_devices[i]);
601 aironet4500_devices[i]=0;
604 i++;
610 #endif //MODULE
612 #endif /* CONFIG_AIRONET4500_ISA */
614 #ifdef CONFIG_AIRONET4500_365
616 #define port_range 0x40
618 int awc_i365_offset_ports[] = {0x3e0,0x3e0,0x3e2,0x3e2};
619 int awc_i365_data_ports [] = {0x3e1,0x3e1,0x3e3,0x3e3};
620 int awc_i365_irq[] = {5,5,11,12};
621 int awc_i365_io[] = {0x140,0x100,0x400,0x440};
622 int awc_i365_sockets = 0;
624 struct i365_socket {
625 int offset_port ;
626 int data_port;
627 int socket;
628 int irq;
629 int io;
630 int manufacturer;
631 int product;
634 inline u8 i365_in (struct i365_socket * s, int offset) {
635 outb(offset + (s->socket % 2)* 0x40, s->offset_port);
636 return inb(s->data_port);
639 inline void i365_out (struct i365_socket * s, int offset,int data){
640 outb(offset + (s->socket % 2)* 0x40 ,s->offset_port);
641 outb((data & 0xff),s->data_port) ;
645 void awc_i365_card_release(struct i365_socket * s){
647 i365_out(s, 0x5, 0); // clearing ints
648 i365_out(s, 0x6, 0x20); // mem 16 bits
649 i365_out(s, 0x7, 0); // clear IO
650 i365_out(s, 0x3, 0); // gen ctrl reset + mem mode
651 i365_out(s, 0x2, 0); // reset power
652 i365_out(s, 0x2, i365_in(s, 0x2) & 0x7f ); // cardenable off
653 i365_out(s, 0x2, 0); // remove power
657 int awc_i365_probe_once(struct i365_socket * s ){
660 int caps=i365_in(s, 0);
661 int ret;
662 unsigned long jiff;
663 // short rev = 0x3000;
664 unsigned char cis [0x3e3];
665 unsigned char * mem = phys_to_virt(0xd000);
666 int i;
667 int port ;
669 DEBUG(1," i365 control ID %x \n", caps);
671 if (caps & 0xC){
672 return 1;
675 ret = i365_in(s, 0x1);
677 if ((ret & 0xC0) != 0xC0){
678 printk("card in socket %d port %x not in known state, %x \n",
679 s->socket, s->offset_port, ret );
680 return -1;
684 awc_i365_card_release(s);
687 udelay(100000);
689 i365_out(s, 0x2, 0x10 ); // power enable
690 udelay(200000);
692 i365_out(s, 0x2, 0x10 | 0x01 | 0x04 | 0x80); //power enable
694 udelay(250000);
696 if (!s->irq)
697 s->irq = 11;
699 i365_out(s, 0x3, 0x40 | 0x20 | s->irq);
701 jiff = jiffies;
703 while (jiffies-jiff < HZ )
704 if (i365_in(s,0x1) & 0x20)
705 break;
707 if (! (i365_in(s,0x1) & 0x20) ){
708 printk("irq enable timeout on socket %x \n", s->socket);
709 return -1;
712 i365_out(s,0x10,0xd0);
713 i365_out(s,0x11,0x0);
714 i365_out(s,0x12,0xd0);
715 i365_out(s,0x13,0x0);
716 i365_out(s,0x14,0x30 );
717 i365_out(s,0x15,0x3f | 0x40); // enab mem reg bit
718 i365_out(s,0x06,0x01); // enab mem
720 udelay(10000);
722 cis[0] = 0x45;
724 // memcpy_toio( 0xd3e0, &(cis[0]),0x1);
726 // mem[0x3e0] = 0x0;
727 // mem[0] = 0x45;
729 mem[0x3e0] = 0x45;
731 udelay(10000);
733 memcpy_fromio(cis,0xD000, 0x3e0);
735 for (i = 0; i <= 0x3e2; i++)
736 printk("%02x", mem[i]);
737 for (i = 0; i <= 0x3e2; i++)
738 printk("%c", mem[i]);
740 i=0;
741 while (i < 0x3e0){
742 if (cis[i] == 0xff)
743 break;
744 if (cis[i] != 0x20 ){
745 i = i + 2 + cis[i+1];
746 continue;
747 }else {
748 s->manufacturer = cis[i+2] | (cis[i+3]<<8);
749 s->product = cis[i+4] | (cis[i+5]<<8);
750 break;
752 i++;
755 DEBUG(1,"socket %x manufacturer %x product %x \n",
756 s->socket, s->manufacturer,s->product);
758 i365_out(s,0x07, 0x1 | 0x2); // enable io 16bit
759 udelay(1000);
760 port = s->io;
761 i365_out(s,0x08, port & 0xff);
762 i365_out(s,0x09, (port & 0xff00)/ 0x100);
763 i365_out(s,0x0A, (port+port_range) & 0xff);
764 i365_out(s,0x0B, ((port+port_range) & 0xff00) /0x100);
766 i365_out(s,0x06, 0x40); // enable io window
768 udelay(1000);
770 i365_out(s,0x3e0,0x45);
772 outw(0x10, s->io);
774 jiff = jiffies;
775 while (!(inw(s->io + 0x30) & 0x10)){
777 if (jiffies - jiff > HZ ){
779 printk("timed out waitin for command ack \n");
780 break;
785 outw(0x10, s->io + 0x34);
786 udelay(10000);
788 return 0;
796 static int awc_i365_init(struct i365_socket * s) {
798 struct net_device * dev;
799 int i;
802 dev = init_etherdev(0, sizeof(struct awc_private) );
804 // dev->tx_queue_len = tx_queue_len;
805 ether_setup(dev);
807 dev->hard_start_xmit = &awc_start_xmit;
808 // dev->set_config = &awc_config_misiganes,aga mitte awc_config;
809 dev->get_stats = &awc_get_stats;
810 dev->set_multicast_list = &awc_set_multicast_list;
812 dev->init = &awc_init;
813 dev->open = &awc_open;
814 dev->stop = &awc_close;
815 dev->irq = s->irq;
816 dev->base_addr = s->io;
817 dev->tx_timeout = &awc_tx_timeout;
818 dev->watchdog_timeo = AWC_TX_TIMEOUT;
821 awc_private_init( dev);
823 i=0;
824 while (aironet4500_devices[i] && i < MAX_AWCS-1) i++;
825 if (!aironet4500_devices[i]){
826 aironet4500_devices[i]=dev;
828 ((struct awc_private *)
829 aironet4500_devices[i]->priv)->card_type = AIRONET4500_365;
831 if (awc_proc_set_fun)
832 awc_proc_set_fun(i);
835 if (register_netdev(dev) != 0) {
836 printk(KERN_NOTICE "awc_cs: register_netdev() failed\n");
837 goto failed;
840 return 0;
842 failed:
843 return -1;
847 static void awc_i365_release(void) {
849 // long flags;
850 int i=0;
852 DEBUG(0, "awc_detach \n");
854 i=0;
855 while ( i < MAX_AWCS) {
857 if (!aironet4500_devices[i])
858 {i++; continue;}
860 if (((struct awc_private *)aironet4500_devices[i]->priv)->card_type != AIRONET4500_365)
861 {i++; continue;}
863 if (awc_proc_unset_fun)
864 awc_proc_unset_fun(i);
866 unregister_netdev(aironet4500_devices[i]);
868 //kfree(aironet4500_devices[i]->priv);
869 kfree(aironet4500_devices[i]);
871 aironet4500_devices[i]=0;
874 i++;
886 int awc_i365_probe(void) {
888 int i = 1;
889 int k = 0;
890 int ret = 0;
891 int found=0;
893 struct i365_socket s;
894 /* Always emit the version, before any failure. */
896 if (!awc_i365_sockets) {
897 printk(" awc i82635 4x00: use bitfiel opts awc_i365_sockets=0x3 <- (1|2) to probe sockets 0 and 1\n");
898 return -1;
901 while (k < 4){
902 if (i & awc_i365_sockets){
904 s.offset_port = awc_i365_offset_ports[k];
905 s.data_port = awc_i365_data_ports[k];
906 s.socket = k;
907 s.manufacturer = 0;
908 s.product = 0;
909 s.irq = awc_i365_irq[k];
910 s.io = awc_i365_io[k];
912 ret = awc_i365_probe_once(&s);
913 if (!ret){
914 if (awc_i365_init(&s))
915 goto failed;
916 else found++;
917 } else if (ret == -1)
918 goto failed;
920 k++;
921 i *=2;
924 if (!found){
925 printk("no aironet 4x00 cards found\n");
926 return -1;
928 return 0;
930 failed:
931 awc_i365_release();
932 return -1;
937 #endif /* CONFIG_AIRONET4500_365 */
939 #ifdef MODULE
940 int init_module(void)
942 int found = 0;
944 printk("%s\n ", awc_version);
946 #ifdef CONFIG_AIRONET4500_PCI
947 if (awc4500_pci_probe(NULL) == -ENODEV){
948 // printk("PCI 4X00 aironet cards not found\n");
949 } else {
950 found++;
951 // printk("PCI 4X00 found some cards \n");
953 #endif
954 #ifdef CONFIG_AIRONET4500_PNP
955 if (awc4500_pnp_probe(NULL) == -ENODEV){
956 // printk("PNP 4X00 aironet cards not found\n");
957 } else {
958 found++;
959 // printk("PNP 4X00 found some cards \n");
961 #endif
962 #ifdef CONFIG_AIRONET4500_365
963 if ( awc_i365_probe() == -1) {
964 // printk("PCMCIA 4X00 aironet cards not found for i365(without card services) initialization\n");
965 } else {
966 found++ ;
967 // printk("PCMCIA 4X00 found some cards, take care, this code is not supposed to work yet \n");
969 #endif
970 #ifdef CONFIG_AIRONET4500_ISA
971 if (awc4500_isa_probe(NULL) == -ENODEV){
972 // printk("ISA 4X00 aironet ISA-bus non-PNP-mode cards not found\n");
973 } else {
974 found++;
975 // printk("ISA 4X00 found some cards \n");
977 #endif
978 if (!found) {
979 printk(KERN_ERR "No Aironet 4X00 cards were found. Note that for ISA \n cards you should use either automatic PNP mode or \n ISA mode with both io and irq param \n Aironet is also afraid of: being second PNP controller(by slot), having anything(brandname bios weirdnesses) in range 0x100-0x180 and maybe around 0xd0000\n If you PNP type card does not get found, try non-PNP switch before complainig. \n");
980 return -1;
982 return 0;
987 void cleanup_module(void)
989 DEBUG(0, "awc_cs: unloading %c ",'\n');
990 #ifdef CONFIG_AIRONET4500_PCI
991 awc_pci_release();
992 #endif
993 #ifdef CONFIG_AIRONET4500_PNP
994 awc_pnp_release();
995 #endif
996 #ifdef CONFIG_AIRONET4500_365
997 awc_i365_release();
998 #endif
999 #ifdef CONFIG_AIRONET4500_ISA
1000 awc_isa_release();
1001 #endif
1004 #endif