Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 | /* * Aironet 4500 PCI-ISA-i365 driver * * Elmer Joandi, Januar 1999 * Copyright GPL * * * Revision 0.1 ,started 30.12.1998 * * Revision 0.2, Feb 27, 2000 * Jeff Garzik - softnet, cleanups * */ #ifdef MODULE static const char *awc_version = "aironet4500_cards.c v0.2 Feb 27, 2000 Elmer Joandi, elmer@ylenurme.ee.\n"; #endif #include <linux/version.h> #include <linux/config.h> #include <linux/module.h> #include <linux/kernel.h> #include <linux/sched.h> #include <linux/ptrace.h> #include <linux/slab.h> #include <linux/string.h> #include <linux/timer.h> #include <linux/interrupt.h> #include <linux/in.h> #include <asm/io.h> #include <asm/system.h> #include <asm/bitops.h> #include <linux/netdevice.h> #include <linux/etherdevice.h> #include <linux/skbuff.h> #include <linux/if_arp.h> #include <linux/ioport.h> #include <linux/delay.h> #include "aironet4500.h" #define PCI_VENDOR_ID_AIRONET 0x14b9 #define PCI_DEVICE_AIRONET_4800_1 0x1 #define PCI_DEVICE_AIRONET_4800 0x4500 #define PCI_DEVICE_AIRONET_4500 0x4800 #define AIRONET4X00_IO_SIZE 0x40 #define AIRONET4X00_CIS_SIZE 0x300 #define AIRONET4X00_MEM_SIZE 0x300 #define AIRONET4500_PCI 1 #define AIRONET4500_PNP 2 #define AIRONET4500_ISA 3 #define AIRONET4500_365 4 #ifdef CONFIG_AIRONET4500_PCI #include <linux/pci.h> static int reverse_probe; static int awc_pci_init(struct net_device * dev, struct pci_dev *pdev, int ioaddr, int cis_addr, int mem_addr,u8 pci_irq_line) ; int awc4500_pci_probe(struct net_device *dev) { int cards_found = 0; static int pci_index; /* Static, for multiple probe calls. */ u8 pci_irq_line = 0; // int p; unsigned char awc_pci_dev, awc_pci_bus; if (!pci_present()) return -1; for (;pci_index < 0xff; pci_index++) { u16 vendor, device, pci_command, new_command; u32 pci_memaddr; u32 pci_ioaddr; u32 pci_cisaddr; struct pci_dev *pdev; if (pcibios_find_class (PCI_CLASS_NETWORK_OTHER << 8, reverse_probe ? 0xfe - pci_index : pci_index, &awc_pci_bus, &awc_pci_dev) != PCIBIOS_SUCCESSFUL){ if (reverse_probe){ continue; } else { break; } } pdev = pci_find_slot(awc_pci_bus, awc_pci_dev); if (!pdev) continue; if (pci_enable_device(pdev)) continue; vendor = pdev->vendor; device = pdev->device; pci_irq_line = pdev->irq; pci_memaddr = pci_resource_start (pdev, 0); pci_cisaddr = pci_resource_start (pdev, 1); pci_ioaddr = pci_resource_start (pdev, 2); // printk("\n pci capabilities %x and ptr %x \n",pci_caps,pci_caps_ptr); /* Remove I/O space marker in bit 0. */ if (vendor != PCI_VENDOR_ID_AIRONET) continue; if (device != PCI_DEVICE_AIRONET_4800_1 && device != PCI_DEVICE_AIRONET_4800 && device != PCI_DEVICE_AIRONET_4500 ) continue; // if (check_region(pci_ioaddr, AIRONET4X00_IO_SIZE) || // check_region(pci_cisaddr, AIRONET4X00_CIS_SIZE) || // check_region(pci_memaddr, AIRONET4X00_MEM_SIZE)) { // printk(KERN_ERR "aironet4X00 mem addrs not available for maping \n"); // continue; // } if (!request_region(pci_ioaddr, AIRONET4X00_IO_SIZE, "aironet4x00 ioaddr")) continue; // request_region(pci_cisaddr, AIRONET4X00_CIS_SIZE, "aironet4x00 cis"); // request_region(pci_memaddr, AIRONET4X00_MEM_SIZE, "aironet4x00 mem"); mdelay(10); pci_read_config_word(pdev, PCI_COMMAND, &pci_command); new_command = pci_command | PCI_COMMAND_SERR; if (pci_command != new_command) pci_write_config_word(pdev, PCI_COMMAND, new_command); /* if (device == PCI_DEVICE_AIRONET_4800) pci_write_config_dword(pdev, 0x40, 0x00000000); udelay(1000); */ if (device == PCI_DEVICE_AIRONET_4800) pci_write_config_dword(pdev, 0x40, 0x40000000); if (awc_pci_init(dev, pdev, pci_ioaddr,pci_cisaddr,pci_memaddr,pci_irq_line)){ printk(KERN_ERR "awc4800 pci init failed \n"); break; } dev = 0; cards_found++; } return cards_found ? 0 : -ENODEV; } static int awc_pci_init(struct net_device * dev, struct pci_dev *pdev, int ioaddr, int cis_addr, int mem_addr, u8 pci_irq_line) { int i, allocd_dev = 0; if (!dev) { dev = init_etherdev(NULL, 0); if (!dev) return -ENOMEM; allocd_dev = 1; } dev->priv = kmalloc(sizeof(struct awc_private),GFP_KERNEL ); memset(dev->priv,0,sizeof(struct awc_private)); if (!dev->priv) { printk(KERN_CRIT "aironet4x00: could not allocate device private, some unstability may follow\n"); if (allocd_dev) { unregister_netdev(dev); kfree(dev); } return -ENOMEM; }; // ether_setup(dev); // dev->tx_queue_len = tx_queue_len; dev->hard_start_xmit = &awc_start_xmit; // dev->set_config = &awc_config_misiganes,aga mitte awc_config; dev->get_stats = &awc_get_stats; // dev->set_multicast_list = &awc_set_multicast_list; dev->change_mtu = awc_change_mtu; dev->init = &awc_init; dev->open = &awc_open; dev->stop = &awc_close; dev->base_addr = ioaddr; dev->irq = pci_irq_line; dev->tx_timeout = &awc_tx_timeout; dev->watchdog_timeo = AWC_TX_TIMEOUT; i = request_irq(dev->irq,awc_interrupt, SA_SHIRQ | SA_INTERRUPT, dev->name, dev); if (i) { kfree(dev->priv); dev->priv = NULL; if (allocd_dev) { unregister_netdev(dev); kfree(dev); } return i; } awc_private_init( dev); awc_init(dev); i=0; while (aironet4500_devices[i] && i < MAX_AWCS-1) i++; if (!aironet4500_devices[i]){ aironet4500_devices[i]=dev; ((struct awc_private *) aironet4500_devices[i]->priv)->card_type = AIRONET4500_PCI; if (awc_proc_set_fun) awc_proc_set_fun(i); } // if (register_netdev(dev) != 0) { // printk(KERN_NOTICE "awc_cs: register_netdev() failed\n"); // goto failed; // } return 0; // failed: // return -1; } #ifdef MODULE static void awc_pci_release(void) { // long flags; int i=0; DEBUG(0, "awc_detach \n"); i=0; while ( i < MAX_AWCS) { if (!aironet4500_devices[i]) {i++; continue;}; if (((struct awc_private *)aironet4500_devices[i]->priv)->card_type != AIRONET4500_PCI) {i++; continue;} if (awc_proc_unset_fun) awc_proc_unset_fun(i); release_region(aironet4500_devices[i]->base_addr, AIRONET4X00_IO_SIZE); // release_region(pci_cisaddr, AIRONET4X00_CIS_SIZE, "aironet4x00 cis"); // release_region(pci_memaddr, AIRONET4X00_MEM_SIZE, "aironet4x00 mem"); unregister_netdev(aironet4500_devices[i]); free_irq(aironet4500_devices[i]->irq,aironet4500_devices[i]); kfree(aironet4500_devices[i]->priv); kfree(aironet4500_devices[i]); aironet4500_devices[i]=0; i++; } } #endif //MODULE #endif /* CONFIG_AIRONET4500_PCI */ #ifdef CONFIG_AIRONET4500_PNP #include <linux/isapnp.h> #define AIRONET4X00_IO_SIZE 0x40 #define isapnp_logdev pci_dev #define isapnp_dev pci_bus #define isapnp_find_device isapnp_find_card #define isapnp_find_logdev isapnp_find_dev #define PNP_BUS bus #define PNP_BUS_NUMBER number #define PNP_DEV_NUMBER devfn int awc4500_pnp_hw_reset(struct net_device *dev){ struct isapnp_logdev *logdev; DEBUG(0, "awc_pnp_reset \n"); if (!dev->priv ) { printk("awc4500 no dev->priv in hw_reset\n"); return -1; }; logdev = ((struct isapnp_logdev *) ((struct awc_private *)dev->priv)->bus); if (!logdev ) { printk("awc4500 no pnp logdev in hw_reset\n"); return -1; }; if (isapnp_cfg_begin(logdev->PNP_BUS->PNP_BUS_NUMBER, logdev->PNP_DEV_NUMBER)<0) printk("isapnp cfg failed at release \n"); isapnp_deactivate(logdev->PNP_DEV_NUMBER); isapnp_cfg_end(); udelay(100); if (isapnp_cfg_begin(logdev->PNP_BUS->PNP_BUS_NUMBER, logdev->PNP_DEV_NUMBER) < 0) { printk("%s cfg begin failed in hw_reset for csn %x devnum %x \n", dev->name, logdev->PNP_BUS->PNP_BUS_NUMBER, logdev->PNP_DEV_NUMBER); return -EAGAIN; } isapnp_activate(logdev->PNP_DEV_NUMBER); /* activate device */ isapnp_cfg_end(); return 0; } int awc4500_pnp_probe(struct net_device *dev) { int isa_index = 0; int isa_irq_line = 0; int isa_ioaddr = 0; int card = 0; int i=0; struct isapnp_dev * pnp_dev ; struct isapnp_logdev *logdev; while (1) { pnp_dev = isapnp_find_device( ISAPNP_VENDOR('A','W','L'), ISAPNP_DEVICE(1), 0); if (!pnp_dev) break; isa_index++; logdev = isapnp_find_logdev(pnp_dev, ISAPNP_VENDOR('A','W','L'), ISAPNP_FUNCTION(1), 0); if (!logdev){ printk("No logical device found on Aironet board \n"); return -ENODEV; } if (isapnp_cfg_begin(logdev->PNP_BUS->PNP_BUS_NUMBER, logdev->PNP_DEV_NUMBER) < 0) { printk("cfg begin failed for csn %x devnum %x \n", logdev->PNP_BUS->PNP_BUS_NUMBER, logdev->PNP_DEV_NUMBER); return -EAGAIN; } isapnp_activate(logdev->PNP_DEV_NUMBER); /* activate device */ isapnp_cfg_end(); isa_irq_line = logdev->irq; isa_ioaddr = logdev->resource[0].start; request_region(isa_ioaddr, AIRONET4X00_IO_SIZE, "aironet4x00 ioaddr"); if (!dev) { dev = init_etherdev(NULL, 0); if (!dev) { release_region(isa_ioaddr, AIRONET4X00_IO_SIZE); isapnp_cfg_begin(logdev->PNP_BUS->PNP_BUS_NUMBER, logdev->PNP_DEV_NUMBER); isapnp_deactivate(logdev->PNP_DEV_NUMBER); isapnp_cfg_end(); return -ENOMEM; } } dev->priv = kmalloc(sizeof(struct awc_private),GFP_KERNEL ); memset(dev->priv,0,sizeof(struct awc_private)); if (!dev->priv) { printk(KERN_CRIT "aironet4x00: could not allocate device private, some unstability may follow\n"); return -1; }; ((struct awc_private *)dev->priv)->bus = logdev; // ether_setup(dev); // dev->tx_queue_len = tx_queue_len; dev->hard_start_xmit = &awc_start_xmit; // dev->set_config = &awc_config_misiganes,aga mitte awc_config; dev->get_stats = &awc_get_stats; // dev->set_multicast_list = &awc_set_multicast_list; dev->change_mtu = awc_change_mtu; dev->init = &awc_init; dev->open = &awc_open; dev->stop = &awc_close; dev->base_addr = isa_ioaddr; dev->irq = isa_irq_line; dev->tx_timeout = &awc_tx_timeout; dev->watchdog_timeo = AWC_TX_TIMEOUT; netif_start_queue (dev); request_irq(dev->irq,awc_interrupt , SA_SHIRQ | SA_INTERRUPT ,"Aironet 4X00",dev); awc_private_init( dev); ((struct awc_private *)dev->priv)->bus = logdev; cli(); if ( awc_init(dev) ){ printk("card not found at irq %x io %lx\n",dev->irq, dev->base_addr); if (card==0){ sti(); return -1; } sti(); break; } udelay(10); sti(); i=0; while (aironet4500_devices[i] && i < MAX_AWCS-1) i++; if (!aironet4500_devices[i] && i < MAX_AWCS-1 ){ aironet4500_devices[i]=dev; ((struct awc_private *) aironet4500_devices[i]->priv)->card_type = AIRONET4500_PNP; if (awc_proc_set_fun) awc_proc_set_fun(i); } else { printk(KERN_CRIT "Out of resources (MAX_AWCS) \n"); return -1; } card++; } if (card == 0) return -ENODEV; return 0; } #ifdef MODULE static void awc_pnp_release(void) { // long flags; int i=0; struct isapnp_logdev *logdev; DEBUG(0, "awc_detach \n"); i=0; while ( i < MAX_AWCS) { if (!aironet4500_devices[i]) {i++; continue;} if (((struct awc_private *)aironet4500_devices[i]->priv)->card_type != AIRONET4500_PNP) {i++; continue;} logdev = ((struct isapnp_logdev *) ((struct awc_private *)aironet4500_devices[i]->priv)->bus); if (!logdev ) printk("awc4500 no pnp logdev in pnp_release\n"); if (awc_proc_unset_fun) awc_proc_unset_fun(i); if (isapnp_cfg_begin(logdev->PNP_BUS->PNP_BUS_NUMBER, logdev->PNP_DEV_NUMBER)<0) printk("isapnp cfg failed at release \n"); isapnp_deactivate(logdev->PNP_DEV_NUMBER); isapnp_cfg_end(); release_region(aironet4500_devices[i]->base_addr, AIRONET4X00_IO_SIZE); // release_region(isa_cisaddr, AIRONET4X00_CIS_SIZE, "aironet4x00 cis"); // release_region(isa_memaddr, AIRONET4X00_MEM_SIZE, "aironet4x00 mem"); unregister_netdev(aironet4500_devices[i]); free_irq(aironet4500_devices[i]->irq,aironet4500_devices[i]); kfree(aironet4500_devices[i]->priv); kfree(aironet4500_devices[i]); aironet4500_devices[i]=0; i++; } } #endif //MODULE #endif /* CONFIG_AIRONET4500_PNP */ #ifdef CONFIG_AIRONET4500_ISA static int irq[] = {0,0,0,0,0}; static int io[] = {0,0,0,0,0}; /* EXPORT_SYMBOL(irq); EXPORT_SYMBOL(io); */ MODULE_PARM(irq,"i"); MODULE_PARM_DESC(irq,"Aironet 4x00 ISA non-PNP irqs,required"); MODULE_PARM(io,"i"); MODULE_PARM_DESC(io,"Aironet 4x00 ISA non-PNP ioports,required"); int awc4500_isa_probe(struct net_device *dev) { // int cards_found = 0; // static int isa_index; /* Static, for multiple probe calls. */ int isa_irq_line = 0; int isa_ioaddr = 0; // int p; int card = 0; int i=0; if (! io[0] || ! irq[0]){ // printk(" Both irq and io params must be supplied for ISA mode !!!\n"); return -ENODEV; } printk(KERN_WARNING " Aironet ISA Card in non-PNP(ISA) mode sometimes feels bad on interrupt \n"); printk(KERN_WARNING " Use aironet4500_pnp if any problems(i.e. card malfunctioning). \n"); printk(KERN_WARNING " Note that this isa probe is not friendly... must give exact parameters \n"); while (irq[card] != 0){ isa_ioaddr = io[card]; isa_irq_line = irq[card]; request_region(isa_ioaddr, AIRONET4X00_IO_SIZE, "aironet4x00 ioaddr"); if (!dev) { dev = init_etherdev(NULL, 0); if (!dev) { release_region(isa_ioaddr, AIRONET4X00_IO_SIZE); return (card == 0) ? -ENOMEM : 0; } } dev->priv = kmalloc(sizeof(struct awc_private),GFP_KERNEL ); memset(dev->priv,0,sizeof(struct awc_private)); if (!dev->priv) { printk(KERN_CRIT "aironet4x00: could not allocate device private, some unstability may follow\n"); return -1; }; // ether_setup(dev); // dev->tx_queue_len = tx_queue_len; dev->hard_start_xmit = &awc_start_xmit; // dev->set_config = &awc_config_misiganes,aga mitte awc_config; dev->get_stats = &awc_get_stats; // dev->set_multicast_list = &awc_set_multicast_list; dev->change_mtu = awc_change_mtu; dev->init = &awc_init; dev->open = &awc_open; dev->stop = &awc_close; dev->base_addr = isa_ioaddr; dev->irq = isa_irq_line; dev->tx_timeout = &awc_tx_timeout; dev->watchdog_timeo = AWC_TX_TIMEOUT; request_irq(dev->irq,awc_interrupt ,SA_INTERRUPT ,"Aironet 4X00",dev); awc_private_init( dev); if ( awc_init(dev) ){ printk("card not found at irq %x mem %x\n",irq[card],io[card]); if (card==0) return -1; break; } i=0; while (aironet4500_devices[i] && i < MAX_AWCS-1) i++; if (!aironet4500_devices[i]){ aironet4500_devices[i]=dev; ((struct awc_private *) aironet4500_devices[i]->priv)->card_type = AIRONET4500_ISA; if (awc_proc_set_fun) awc_proc_set_fun(i); } card++; } if (card == 0 ) { return -ENODEV; }; return 0; } #ifdef MODULE static void awc_isa_release(void) { // long flags; int i=0; DEBUG(0, "awc_detach \n"); i=0; while ( i < MAX_AWCS) { if (!aironet4500_devices[i]) {i++; continue;} if (((struct awc_private *)aironet4500_devices[i]->priv)->card_type != AIRONET4500_ISA) {i++; continue;} if (awc_proc_unset_fun) awc_proc_unset_fun(i); release_region(aironet4500_devices[i]->base_addr, AIRONET4X00_IO_SIZE); // release_region(isa_cisaddr, AIRONET4X00_CIS_SIZE, "aironet4x00 cis"); // release_region(isa_memaddr, AIRONET4X00_MEM_SIZE, "aironet4x00 mem"); unregister_netdev(aironet4500_devices[i]); free_irq(aironet4500_devices[i]->irq,aironet4500_devices[i]); kfree(aironet4500_devices[i]->priv); kfree(aironet4500_devices[i]); aironet4500_devices[i]=0; i++; } } #endif //MODULE #endif /* CONFIG_AIRONET4500_ISA */ #ifdef CONFIG_AIRONET4500_365 #define port_range 0x40 int awc_i365_offset_ports[] = {0x3e0,0x3e0,0x3e2,0x3e2}; int awc_i365_data_ports [] = {0x3e1,0x3e1,0x3e3,0x3e3}; int awc_i365_irq[] = {5,5,11,12}; int awc_i365_io[] = {0x140,0x100,0x400,0x440}; int awc_i365_sockets = 0; struct i365_socket { int offset_port ; int data_port; int socket; int irq; int io; int manufacturer; int product; }; inline u8 i365_in (struct i365_socket * s, int offset) { outb(offset + (s->socket % 2)* 0x40, s->offset_port); return inb(s->data_port); }; inline void i365_out (struct i365_socket * s, int offset,int data){ outb(offset + (s->socket % 2)* 0x40 ,s->offset_port); outb((data & 0xff),s->data_port) ; }; void awc_i365_card_release(struct i365_socket * s){ i365_out(s, 0x5, 0); // clearing ints i365_out(s, 0x6, 0x20); // mem 16 bits i365_out(s, 0x7, 0); // clear IO i365_out(s, 0x3, 0); // gen ctrl reset + mem mode i365_out(s, 0x2, 0); // reset power i365_out(s, 0x2, i365_in(s, 0x2) & 0x7f ); // cardenable off i365_out(s, 0x2, 0); // remove power }; int awc_i365_probe_once(struct i365_socket * s ){ int caps=i365_in(s, 0); int ret; unsigned long jiff; // short rev = 0x3000; unsigned char cis [0x3e3]; unsigned char * mem = phys_to_virt(0xd000); int i; int port ; DEBUG(1," i365 control ID %x \n", caps); if (caps & 0xC){ return 1; }; ret = i365_in(s, 0x1); if ((ret & 0xC0) != 0xC0){ printk("card in socket %d port %x not in known state, %x \n", s->socket, s->offset_port, ret ); return -1; }; awc_i365_card_release(s); mdelay(100); i365_out(s, 0x2, 0x10 ); // power enable mdelay(200); i365_out(s, 0x2, 0x10 | 0x01 | 0x04 | 0x80); //power enable mdelay(250); if (!s->irq) s->irq = 11; i365_out(s, 0x3, 0x40 | 0x20 | s->irq); jiff = jiffies; while (jiffies-jiff < HZ ) if (i365_in(s,0x1) & 0x20) break; if (! (i365_in(s,0x1) & 0x20) ){ printk("irq enable timeout on socket %x \n", s->socket); return -1; }; i365_out(s,0x10,0xd0); i365_out(s,0x11,0x0); i365_out(s,0x12,0xd0); i365_out(s,0x13,0x0); i365_out(s,0x14,0x30 ); i365_out(s,0x15,0x3f | 0x40); // enab mem reg bit i365_out(s,0x06,0x01); // enab mem mdelay(10); cis[0] = 0x45; // memcpy_toio( 0xd3e0, &(cis[0]),0x1); // mem[0x3e0] = 0x0; // mem[0] = 0x45; mem[0x3e0] = 0x45; mdelay(10); memcpy_fromio(cis,0xD000, 0x3e0); for (i = 0; i <= 0x3e2; i++) printk("%02x", mem[i]); for (i = 0; i <= 0x3e2; i++) printk("%c", mem[i]); i=0; while (i < 0x3e0){ if (cis[i] == 0xff) break; if (cis[i] != 0x20 ){ i = i + 2 + cis[i+1]; continue; }else { s->manufacturer = cis[i+2] | (cis[i+3]<<8); s->product = cis[i+4] | (cis[i+5]<<8); break; }; i++; }; DEBUG(1,"socket %x manufacturer %x product %x \n", s->socket, s->manufacturer,s->product); i365_out(s,0x07, 0x1 | 0x2); // enable io 16bit mdelay(1); port = s->io; i365_out(s,0x08, port & 0xff); i365_out(s,0x09, (port & 0xff00)/ 0x100); i365_out(s,0x0A, (port+port_range) & 0xff); i365_out(s,0x0B, ((port+port_range) & 0xff00) /0x100); i365_out(s,0x06, 0x40); // enable io window mdelay(1); i365_out(s,0x3e0,0x45); outw(0x10, s->io); jiff = jiffies; while (!(inw(s->io + 0x30) & 0x10)){ if (jiffies - jiff > HZ ){ printk("timed out waitin for command ack \n"); break; } }; outw(0x10, s->io + 0x34); mdelay(10); return 0; }; static int awc_i365_init(struct i365_socket * s) { struct net_device * dev; int i; dev = init_etherdev(0, sizeof(struct awc_private) ); // dev->tx_queue_len = tx_queue_len; ether_setup(dev); dev->hard_start_xmit = &awc_start_xmit; // dev->set_config = &awc_config_misiganes,aga mitte awc_config; dev->get_stats = &awc_get_stats; dev->set_multicast_list = &awc_set_multicast_list; dev->init = &awc_init; dev->open = &awc_open; dev->stop = &awc_close; dev->irq = s->irq; dev->base_addr = s->io; dev->tx_timeout = &awc_tx_timeout; dev->watchdog_timeo = AWC_TX_TIMEOUT; awc_private_init( dev); i=0; while (aironet4500_devices[i] && i < MAX_AWCS-1) i++; if (!aironet4500_devices[i]){ aironet4500_devices[i]=dev; ((struct awc_private *) aironet4500_devices[i]->priv)->card_type = AIRONET4500_365; if (awc_proc_set_fun) awc_proc_set_fun(i); } if (register_netdev(dev) != 0) { printk(KERN_NOTICE "awc_cs: register_netdev() failed\n"); goto failed; } return 0; failed: return -1; } static void awc_i365_release(void) { // long flags; int i=0; DEBUG(0, "awc_detach \n"); i=0; while ( i < MAX_AWCS) { if (!aironet4500_devices[i]) {i++; continue;} if (((struct awc_private *)aironet4500_devices[i]->priv)->card_type != AIRONET4500_365) {i++; continue;} if (awc_proc_unset_fun) awc_proc_unset_fun(i); unregister_netdev(aironet4500_devices[i]); //kfree(aironet4500_devices[i]->priv); kfree(aironet4500_devices[i]); aironet4500_devices[i]=0; i++; } } int awc_i365_probe(void) { int i = 1; int k = 0; int ret = 0; int found=0; struct i365_socket s; /* Always emit the version, before any failure. */ if (!awc_i365_sockets) { printk(" awc i82635 4x00: use bitfiel opts awc_i365_sockets=0x3 <- (1|2) to probe sockets 0 and 1\n"); return -1; }; while (k < 4){ if (i & awc_i365_sockets){ s.offset_port = awc_i365_offset_ports[k]; s.data_port = awc_i365_data_ports[k]; s.socket = k; s.manufacturer = 0; s.product = 0; s.irq = awc_i365_irq[k]; s.io = awc_i365_io[k]; ret = awc_i365_probe_once(&s); if (!ret){ if (awc_i365_init(&s)) goto failed; else found++; } else if (ret == -1) goto failed; }; k++; i *=2; }; if (!found){ printk("no aironet 4x00 cards found\n"); return -1; } return 0; failed: awc_i365_release(); return -1; } #endif /* CONFIG_AIRONET4500_365 */ #ifdef MODULE int init_module(void) { int found = 0; printk("%s\n ", awc_version); #ifdef CONFIG_AIRONET4500_PCI if (awc4500_pci_probe(NULL) == -ENODEV){ // printk("PCI 4X00 aironet cards not found\n"); } else { found++; // printk("PCI 4X00 found some cards \n"); } #endif #ifdef CONFIG_AIRONET4500_PNP if (awc4500_pnp_probe(NULL) == -ENODEV){ // printk("PNP 4X00 aironet cards not found\n"); } else { found++; // printk("PNP 4X00 found some cards \n"); } #endif #ifdef CONFIG_AIRONET4500_365 if ( awc_i365_probe() == -1) { // printk("PCMCIA 4X00 aironet cards not found for i365(without card services) initialization\n"); } else { found++ ; // printk("PCMCIA 4X00 found some cards, take care, this code is not supposed to work yet \n"); } #endif #ifdef CONFIG_AIRONET4500_ISA if (awc4500_isa_probe(NULL) == -ENODEV){ // printk("ISA 4X00 aironet ISA-bus non-PNP-mode cards not found\n"); } else { found++; // printk("ISA 4X00 found some cards \n"); } #endif if (!found) { 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"); return -1; } return 0; } void cleanup_module(void) { DEBUG(0, "awc_cs: unloading %c ",'\n'); #ifdef CONFIG_AIRONET4500_PCI awc_pci_release(); #endif #ifdef CONFIG_AIRONET4500_PNP awc_pnp_release(); #endif #ifdef CONFIG_AIRONET4500_365 awc_i365_release(); #endif #ifdef CONFIG_AIRONET4500_ISA awc_isa_release(); #endif } #endif |