aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/isdn/hisax/sedlbauer.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/isdn/hisax/sedlbauer.c')
-rw-r--r--drivers/isdn/hisax/sedlbauer.c276
1 files changed, 157 insertions, 119 deletions
diff --git a/drivers/isdn/hisax/sedlbauer.c b/drivers/isdn/hisax/sedlbauer.c
index ad06f3cc60fb..03dfc32166a0 100644
--- a/drivers/isdn/hisax/sedlbauer.c
+++ b/drivers/isdn/hisax/sedlbauer.c
@@ -518,8 +518,6 @@ Sedl_card_msg(struct IsdnCardState *cs, int mt, void *arg)
518 return(0); 518 return(0);
519} 519}
520 520
521static struct pci_dev *dev_sedl __devinitdata = NULL;
522
523#ifdef __ISAPNP__ 521#ifdef __ISAPNP__
524static struct isapnp_device_id sedl_ids[] __devinitdata = { 522static struct isapnp_device_id sedl_ids[] __devinitdata = {
525 { ISAPNP_VENDOR('S', 'A', 'G'), ISAPNP_FUNCTION(0x01), 523 { ISAPNP_VENDOR('S', 'A', 'G'), ISAPNP_FUNCTION(0x01),
@@ -533,15 +531,158 @@ static struct isapnp_device_id sedl_ids[] __devinitdata = {
533 531
534static struct isapnp_device_id *ipid __devinitdata = &sedl_ids[0]; 532static struct isapnp_device_id *ipid __devinitdata = &sedl_ids[0];
535static struct pnp_card *pnp_c __devinitdata = NULL; 533static struct pnp_card *pnp_c __devinitdata = NULL;
536#endif 534
535static int __devinit
536setup_sedlbauer_isapnp(struct IsdnCard *card, int *bytecnt)
537{
538 struct IsdnCardState *cs = card->cs;
539 struct pnp_dev *pnp_d;
540
541 if (!isapnp_present())
542 return -1;
543
544 while(ipid->card_vendor) {
545 if ((pnp_c = pnp_find_card(ipid->card_vendor,
546 ipid->card_device, pnp_c))) {
547 pnp_d = NULL;
548 if ((pnp_d = pnp_find_dev(pnp_c,
549 ipid->vendor, ipid->function, pnp_d))) {
550 int err;
551
552 printk(KERN_INFO "HiSax: %s detected\n",
553 (char *)ipid->driver_data);
554 pnp_disable_dev(pnp_d);
555 err = pnp_activate_dev(pnp_d);
556 if (err<0) {
557 printk(KERN_WARNING "%s: pnp_activate_dev ret(%d)\n",
558 __FUNCTION__, err);
559 return(0);
560 }
561 card->para[1] = pnp_port_start(pnp_d, 0);
562 card->para[0] = pnp_irq(pnp_d, 0);
563
564 if (!card->para[0] || !card->para[1]) {
565 printk(KERN_ERR "Sedlbauer PnP:some resources are missing %ld/%lx\n",
566 card->para[0], card->para[1]);
567 pnp_disable_dev(pnp_d);
568 return(0);
569 }
570 cs->hw.sedl.cfg_reg = card->para[1];
571 cs->irq = card->para[0];
572 if (ipid->function == ISAPNP_FUNCTION(0x2)) {
573 cs->subtyp = SEDL_SPEED_FAX;
574 cs->hw.sedl.chip = SEDL_CHIP_ISAC_ISAR;
575 *bytecnt = 16;
576 } else {
577 cs->subtyp = SEDL_SPEED_CARD_WIN;
578 cs->hw.sedl.chip = SEDL_CHIP_TEST;
579 }
580
581 return (1);
582 } else {
583 printk(KERN_ERR "Sedlbauer PnP: PnP error card found, no device\n");
584 return(0);
585 }
586 }
587 ipid++;
588 pnp_c = NULL;
589 }
590
591 printk(KERN_INFO "Sedlbauer PnP: no ISAPnP card found\n");
592 return -1;
593}
594#else
595
596static int __devinit
597setup_sedlbauer_isapnp(struct IsdnCard *card, int *bytecnt)
598{
599 return -1;
600}
601#endif /* __ISAPNP__ */
602
603#ifdef CONFIG_PCI
604static struct pci_dev *dev_sedl __devinitdata = NULL;
605
606static int __devinit
607setup_sedlbauer_pci(struct IsdnCard *card)
608{
609 struct IsdnCardState *cs = card->cs;
610 u16 sub_vendor_id, sub_id;
611
612 if ((dev_sedl = pci_find_device(PCI_VENDOR_ID_TIGERJET,
613 PCI_DEVICE_ID_TIGERJET_100, dev_sedl))) {
614 if (pci_enable_device(dev_sedl))
615 return(0);
616 cs->irq = dev_sedl->irq;
617 if (!cs->irq) {
618 printk(KERN_WARNING "Sedlbauer: No IRQ for PCI card found\n");
619 return(0);
620 }
621 cs->hw.sedl.cfg_reg = pci_resource_start(dev_sedl, 0);
622 } else {
623 printk(KERN_WARNING "Sedlbauer: No PCI card found\n");
624 return(0);
625 }
626 cs->irq_flags |= IRQF_SHARED;
627 cs->hw.sedl.bus = SEDL_BUS_PCI;
628 sub_vendor_id = dev_sedl->subsystem_vendor;
629 sub_id = dev_sedl->subsystem_device;
630 printk(KERN_INFO "Sedlbauer: PCI subvendor:%x subid %x\n",
631 sub_vendor_id, sub_id);
632 printk(KERN_INFO "Sedlbauer: PCI base adr %#x\n",
633 cs->hw.sedl.cfg_reg);
634 if (sub_id != PCI_SUB_ID_SEDLBAUER) {
635 printk(KERN_ERR "Sedlbauer: unknown sub id %#x\n", sub_id);
636 return(0);
637 }
638 if (sub_vendor_id == PCI_SUBVENDOR_SPEEDFAX_PYRAMID) {
639 cs->hw.sedl.chip = SEDL_CHIP_ISAC_ISAR;
640 cs->subtyp = SEDL_SPEEDFAX_PYRAMID;
641 } else if (sub_vendor_id == PCI_SUBVENDOR_SPEEDFAX_PCI) {
642 cs->hw.sedl.chip = SEDL_CHIP_ISAC_ISAR;
643 cs->subtyp = SEDL_SPEEDFAX_PCI;
644 } else if (sub_vendor_id == PCI_SUBVENDOR_HST_SAPHIR3) {
645 cs->hw.sedl.chip = SEDL_CHIP_IPAC;
646 cs->subtyp = HST_SAPHIR3;
647 } else if (sub_vendor_id == PCI_SUBVENDOR_SEDLBAUER_PCI) {
648 cs->hw.sedl.chip = SEDL_CHIP_IPAC;
649 cs->subtyp = SEDL_SPEED_PCI;
650 } else {
651 printk(KERN_ERR "Sedlbauer: unknown sub vendor id %#x\n",
652 sub_vendor_id);
653 return(0);
654 }
655
656 cs->hw.sedl.reset_on = SEDL_ISAR_PCI_ISAR_RESET_ON;
657 cs->hw.sedl.reset_off = SEDL_ISAR_PCI_ISAR_RESET_OFF;
658 byteout(cs->hw.sedl.cfg_reg, 0xff);
659 byteout(cs->hw.sedl.cfg_reg, 0x00);
660 byteout(cs->hw.sedl.cfg_reg+ 2, 0xdd);
661 byteout(cs->hw.sedl.cfg_reg+ 5, 0); /* disable all IRQ */
662 byteout(cs->hw.sedl.cfg_reg +3, cs->hw.sedl.reset_on);
663 mdelay(2);
664 byteout(cs->hw.sedl.cfg_reg +3, cs->hw.sedl.reset_off);
665 mdelay(10);
666
667 return (1);
668}
669
670#else
671
672static int __devinit
673setup_sedlbauer_pci(struct IsdnCard *card)
674{
675 return (1);
676}
677
678#endif /* CONFIG_PCI */
537 679
538int __devinit 680int __devinit
539setup_sedlbauer(struct IsdnCard *card) 681setup_sedlbauer(struct IsdnCard *card)
540{ 682{
541 int bytecnt, ver, val; 683 int bytecnt = 8, ver, val, rc;
542 struct IsdnCardState *cs = card->cs; 684 struct IsdnCardState *cs = card->cs;
543 char tmp[64]; 685 char tmp[64];
544 u16 sub_vendor_id, sub_id;
545 686
546 strcpy(tmp, Sedlbauer_revision); 687 strcpy(tmp, Sedlbauer_revision);
547 printk(KERN_INFO "HiSax: Sedlbauer driver Rev. %s\n", HiSax_getrev(tmp)); 688 printk(KERN_INFO "HiSax: Sedlbauer driver Rev. %s\n", HiSax_getrev(tmp));
@@ -569,124 +710,21 @@ setup_sedlbauer(struct IsdnCard *card)
569 bytecnt = 16; 710 bytecnt = 16;
570 } 711 }
571 } else { 712 } else {
572#ifdef __ISAPNP__ 713 rc = setup_sedlbauer_isapnp(card, &bytecnt);
573 if (isapnp_present()) { 714 if (!rc)
574 struct pnp_dev *pnp_d; 715 return (0);
575 while(ipid->card_vendor) { 716 if (rc > 0)
576 if ((pnp_c = pnp_find_card(ipid->card_vendor, 717 goto ready;
577 ipid->card_device, pnp_c))) { 718
578 pnp_d = NULL; 719 /* Probe for Sedlbauer speed pci */
579 if ((pnp_d = pnp_find_dev(pnp_c, 720 rc = setup_sedlbauer_pci(card);
580 ipid->vendor, ipid->function, pnp_d))) { 721 if (!rc)
581 int err; 722 return (0);
582 723
583 printk(KERN_INFO "HiSax: %s detected\n",
584 (char *)ipid->driver_data);
585 pnp_disable_dev(pnp_d);
586 err = pnp_activate_dev(pnp_d);
587 if (err<0) {
588 printk(KERN_WARNING "%s: pnp_activate_dev ret(%d)\n",
589 __FUNCTION__, err);
590 return(0);
591 }
592 card->para[1] = pnp_port_start(pnp_d, 0);
593 card->para[0] = pnp_irq(pnp_d, 0);
594
595 if (!card->para[0] || !card->para[1]) {
596 printk(KERN_ERR "Sedlbauer PnP:some resources are missing %ld/%lx\n",
597 card->para[0], card->para[1]);
598 pnp_disable_dev(pnp_d);
599 return(0);
600 }
601 cs->hw.sedl.cfg_reg = card->para[1];
602 cs->irq = card->para[0];
603 if (ipid->function == ISAPNP_FUNCTION(0x2)) {
604 cs->subtyp = SEDL_SPEED_FAX;
605 cs->hw.sedl.chip = SEDL_CHIP_ISAC_ISAR;
606 bytecnt = 16;
607 } else {
608 cs->subtyp = SEDL_SPEED_CARD_WIN;
609 cs->hw.sedl.chip = SEDL_CHIP_TEST;
610 }
611 goto ready;
612 } else {
613 printk(KERN_ERR "Sedlbauer PnP: PnP error card found, no device\n");
614 return(0);
615 }
616 }
617 ipid++;
618 pnp_c = NULL;
619 }
620 if (!ipid->card_vendor) {
621 printk(KERN_INFO "Sedlbauer PnP: no ISAPnP card found\n");
622 }
623 }
624#endif
625/* Probe for Sedlbauer speed pci */
626#ifdef CONFIG_PCI
627 if ((dev_sedl = pci_find_device(PCI_VENDOR_ID_TIGERJET,
628 PCI_DEVICE_ID_TIGERJET_100, dev_sedl))) {
629 if (pci_enable_device(dev_sedl))
630 return(0);
631 cs->irq = dev_sedl->irq;
632 if (!cs->irq) {
633 printk(KERN_WARNING "Sedlbauer: No IRQ for PCI card found\n");
634 return(0);
635 }
636 cs->hw.sedl.cfg_reg = pci_resource_start(dev_sedl, 0);
637 } else {
638 printk(KERN_WARNING "Sedlbauer: No PCI card found\n");
639 return(0);
640 }
641 cs->irq_flags |= IRQF_SHARED;
642 cs->hw.sedl.bus = SEDL_BUS_PCI;
643 sub_vendor_id = dev_sedl->subsystem_vendor;
644 sub_id = dev_sedl->subsystem_device;
645 printk(KERN_INFO "Sedlbauer: PCI subvendor:%x subid %x\n",
646 sub_vendor_id, sub_id);
647 printk(KERN_INFO "Sedlbauer: PCI base adr %#x\n",
648 cs->hw.sedl.cfg_reg);
649 if (sub_id != PCI_SUB_ID_SEDLBAUER) {
650 printk(KERN_ERR "Sedlbauer: unknown sub id %#x\n", sub_id);
651 return(0);
652 }
653 if (sub_vendor_id == PCI_SUBVENDOR_SPEEDFAX_PYRAMID) {
654 cs->hw.sedl.chip = SEDL_CHIP_ISAC_ISAR;
655 cs->subtyp = SEDL_SPEEDFAX_PYRAMID;
656 } else if (sub_vendor_id == PCI_SUBVENDOR_SPEEDFAX_PCI) {
657 cs->hw.sedl.chip = SEDL_CHIP_ISAC_ISAR;
658 cs->subtyp = SEDL_SPEEDFAX_PCI;
659 } else if (sub_vendor_id == PCI_SUBVENDOR_HST_SAPHIR3) {
660 cs->hw.sedl.chip = SEDL_CHIP_IPAC;
661 cs->subtyp = HST_SAPHIR3;
662 } else if (sub_vendor_id == PCI_SUBVENDOR_SEDLBAUER_PCI) {
663 cs->hw.sedl.chip = SEDL_CHIP_IPAC;
664 cs->subtyp = SEDL_SPEED_PCI;
665 } else {
666 printk(KERN_ERR "Sedlbauer: unknown sub vendor id %#x\n",
667 sub_vendor_id);
668 return(0);
669 }
670 bytecnt = 256; 724 bytecnt = 256;
671 cs->hw.sedl.reset_on = SEDL_ISAR_PCI_ISAR_RESET_ON;
672 cs->hw.sedl.reset_off = SEDL_ISAR_PCI_ISAR_RESET_OFF;
673 byteout(cs->hw.sedl.cfg_reg, 0xff);
674 byteout(cs->hw.sedl.cfg_reg, 0x00);
675 byteout(cs->hw.sedl.cfg_reg+ 2, 0xdd);
676 byteout(cs->hw.sedl.cfg_reg+ 5, 0); /* disable all IRQ */
677 byteout(cs->hw.sedl.cfg_reg +3, cs->hw.sedl.reset_on);
678 mdelay(2);
679 byteout(cs->hw.sedl.cfg_reg +3, cs->hw.sedl.reset_off);
680 mdelay(10);
681#else
682 printk(KERN_WARNING "Sedlbauer: NO_PCI_BIOS\n");
683 return (0);
684#endif /* CONFIG_PCI */
685 } 725 }
686 726
687#ifdef __ISAPNP__
688ready: 727ready:
689#endif
690 728
691 /* In case of the sedlbauer pcmcia card, this region is in use, 729 /* In case of the sedlbauer pcmcia card, this region is in use,
692 * reserved for us by the card manager. So we do not check it 730 * reserved for us by the card manager. So we do not check it