diff options
author | Jeff Garzik <jeff@garzik.org> | 2007-10-03 15:23:49 -0400 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2007-10-12 09:16:48 -0400 |
commit | 2fbde4c0923f53bca9975a46059b5c481a3551ba (patch) | |
tree | 4559197c4df03f30612d9f12f7f6b17e8b287e35 /drivers/isdn/hisax | |
parent | bfc7c89f068bbbc2c48588385529d15c6feef802 (diff) |
[ISDN] HiSax avm_pci: split setup into three smaller functions
Preparation for new ISA/PNP/PCI APIs.
Just code movement, and the glue to call the new functions.
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers/isdn/hisax')
-rw-r--r-- | drivers/isdn/hisax/avm_pci.c | 224 |
1 files changed, 136 insertions, 88 deletions
diff --git a/drivers/isdn/hisax/avm_pci.c b/drivers/isdn/hisax/avm_pci.c index b04a178e5021..f8b79783c8b3 100644 --- a/drivers/isdn/hisax/avm_pci.c +++ b/drivers/isdn/hisax/avm_pci.c | |||
@@ -20,7 +20,6 @@ | |||
20 | #include <linux/isapnp.h> | 20 | #include <linux/isapnp.h> |
21 | #include <linux/interrupt.h> | 21 | #include <linux/interrupt.h> |
22 | 22 | ||
23 | extern const char *CardType[]; | ||
24 | static const char *avm_pci_rev = "$Revision: 1.29.2.4 $"; | 23 | static const char *avm_pci_rev = "$Revision: 1.29.2.4 $"; |
25 | 24 | ||
26 | #define AVM_FRITZ_PCI 1 | 25 | #define AVM_FRITZ_PCI 1 |
@@ -726,100 +725,15 @@ AVM_card_msg(struct IsdnCardState *cs, int mt, void *arg) | |||
726 | return(0); | 725 | return(0); |
727 | } | 726 | } |
728 | 727 | ||
729 | #ifdef CONFIG_PCI | 728 | static int __devinit avm_setup_rest(struct IsdnCardState *cs) |
730 | static struct pci_dev *dev_avm __devinitdata = NULL; | ||
731 | #endif | ||
732 | #ifdef __ISAPNP__ | ||
733 | static struct pnp_card *pnp_avm_c __devinitdata = NULL; | ||
734 | #endif | ||
735 | |||
736 | int __devinit | ||
737 | setup_avm_pcipnp(struct IsdnCard *card) | ||
738 | { | 729 | { |
739 | u_int val, ver; | 730 | u_int val, ver; |
740 | struct IsdnCardState *cs = card->cs; | ||
741 | char tmp[64]; | ||
742 | 731 | ||
743 | strcpy(tmp, avm_pci_rev); | ||
744 | printk(KERN_INFO "HiSax: AVM PCI driver Rev. %s\n", HiSax_getrev(tmp)); | ||
745 | if (cs->typ != ISDN_CTYPE_FRITZPCI) | ||
746 | return (0); | ||
747 | if (card->para[1]) { | ||
748 | /* old manual method */ | ||
749 | cs->hw.avm.cfg_reg = card->para[1]; | ||
750 | cs->irq = card->para[0]; | ||
751 | cs->subtyp = AVM_FRITZ_PNP; | ||
752 | goto ready; | ||
753 | } | ||
754 | #ifdef __ISAPNP__ | ||
755 | if (isapnp_present()) { | ||
756 | struct pnp_dev *pnp_avm_d = NULL; | ||
757 | if ((pnp_avm_c = pnp_find_card( | ||
758 | ISAPNP_VENDOR('A', 'V', 'M'), | ||
759 | ISAPNP_FUNCTION(0x0900), pnp_avm_c))) { | ||
760 | if ((pnp_avm_d = pnp_find_dev(pnp_avm_c, | ||
761 | ISAPNP_VENDOR('A', 'V', 'M'), | ||
762 | ISAPNP_FUNCTION(0x0900), pnp_avm_d))) { | ||
763 | int err; | ||
764 | |||
765 | pnp_disable_dev(pnp_avm_d); | ||
766 | err = pnp_activate_dev(pnp_avm_d); | ||
767 | if (err<0) { | ||
768 | printk(KERN_WARNING "%s: pnp_activate_dev ret(%d)\n", | ||
769 | __FUNCTION__, err); | ||
770 | return(0); | ||
771 | } | ||
772 | cs->hw.avm.cfg_reg = | ||
773 | pnp_port_start(pnp_avm_d, 0); | ||
774 | cs->irq = pnp_irq(pnp_avm_d, 0); | ||
775 | if (!cs->irq) { | ||
776 | printk(KERN_ERR "FritzPnP:No IRQ\n"); | ||
777 | return(0); | ||
778 | } | ||
779 | if (!cs->hw.avm.cfg_reg) { | ||
780 | printk(KERN_ERR "FritzPnP:No IO address\n"); | ||
781 | return(0); | ||
782 | } | ||
783 | cs->subtyp = AVM_FRITZ_PNP; | ||
784 | goto ready; | ||
785 | } | ||
786 | } | ||
787 | } else { | ||
788 | printk(KERN_INFO "FritzPnP: no ISA PnP present\n"); | ||
789 | } | ||
790 | #endif | ||
791 | #ifdef CONFIG_PCI | ||
792 | if ((dev_avm = pci_find_device(PCI_VENDOR_ID_AVM, | ||
793 | PCI_DEVICE_ID_AVM_A1, dev_avm))) { | ||
794 | if (pci_enable_device(dev_avm)) | ||
795 | return(0); | ||
796 | cs->irq = dev_avm->irq; | ||
797 | if (!cs->irq) { | ||
798 | printk(KERN_ERR "FritzPCI: No IRQ for PCI card found\n"); | ||
799 | return(0); | ||
800 | } | ||
801 | cs->hw.avm.cfg_reg = pci_resource_start(dev_avm, 1); | ||
802 | if (!cs->hw.avm.cfg_reg) { | ||
803 | printk(KERN_ERR "FritzPCI: No IO-Adr for PCI card found\n"); | ||
804 | return(0); | ||
805 | } | ||
806 | cs->subtyp = AVM_FRITZ_PCI; | ||
807 | } else { | ||
808 | printk(KERN_WARNING "FritzPCI: No PCI card found\n"); | ||
809 | return(0); | ||
810 | } | ||
811 | cs->irq_flags |= IRQF_SHARED; | ||
812 | #else | ||
813 | printk(KERN_WARNING "FritzPCI: NO_PCI_BIOS\n"); | ||
814 | return (0); | ||
815 | #endif /* CONFIG_PCI */ | ||
816 | ready: | ||
817 | cs->hw.avm.isac = cs->hw.avm.cfg_reg + 0x10; | 732 | cs->hw.avm.isac = cs->hw.avm.cfg_reg + 0x10; |
818 | if (!request_region(cs->hw.avm.cfg_reg, 32, | 733 | if (!request_region(cs->hw.avm.cfg_reg, 32, |
819 | (cs->subtyp == AVM_FRITZ_PCI) ? "avm PCI" : "avm PnP")) { | 734 | (cs->subtyp == AVM_FRITZ_PCI) ? "avm PCI" : "avm PnP")) { |
820 | printk(KERN_WARNING | 735 | printk(KERN_WARNING |
821 | "HiSax: %s config port %x-%x already in use\n", | 736 | "HiSax: Fritz!PCI/PNP config port %x-%x already in use\n", |
822 | CardType[card->typ], | ||
823 | cs->hw.avm.cfg_reg, | 737 | cs->hw.avm.cfg_reg, |
824 | cs->hw.avm.cfg_reg + 31); | 738 | cs->hw.avm.cfg_reg + 31); |
825 | return (0); | 739 | return (0); |
@@ -860,3 +774,137 @@ ready: | |||
860 | ISACVersion(cs, (cs->subtyp == AVM_FRITZ_PCI) ? "AVM PCI:" : "AVM PnP:"); | 774 | ISACVersion(cs, (cs->subtyp == AVM_FRITZ_PCI) ? "AVM PCI:" : "AVM PnP:"); |
861 | return (1); | 775 | return (1); |
862 | } | 776 | } |
777 | |||
778 | #ifndef __ISAPNP__ | ||
779 | |||
780 | static int __devinit avm_pnp_setup(struct IsdnCardState *cs) | ||
781 | { | ||
782 | return(1); /* no-op: success */ | ||
783 | } | ||
784 | |||
785 | #else | ||
786 | |||
787 | static struct pnp_card *pnp_avm_c __devinitdata = NULL; | ||
788 | |||
789 | static int __devinit avm_pnp_setup(struct IsdnCardState *cs) | ||
790 | { | ||
791 | struct pnp_dev *pnp_avm_d = NULL; | ||
792 | |||
793 | if (!isapnp_present()) | ||
794 | return(1); /* no-op: success */ | ||
795 | |||
796 | if ((pnp_avm_c = pnp_find_card( | ||
797 | ISAPNP_VENDOR('A', 'V', 'M'), | ||
798 | ISAPNP_FUNCTION(0x0900), pnp_avm_c))) { | ||
799 | if ((pnp_avm_d = pnp_find_dev(pnp_avm_c, | ||
800 | ISAPNP_VENDOR('A', 'V', 'M'), | ||
801 | ISAPNP_FUNCTION(0x0900), pnp_avm_d))) { | ||
802 | int err; | ||
803 | |||
804 | pnp_disable_dev(pnp_avm_d); | ||
805 | err = pnp_activate_dev(pnp_avm_d); | ||
806 | if (err<0) { | ||
807 | printk(KERN_WARNING "%s: pnp_activate_dev ret(%d)\n", | ||
808 | __FUNCTION__, err); | ||
809 | return(0); | ||
810 | } | ||
811 | cs->hw.avm.cfg_reg = | ||
812 | pnp_port_start(pnp_avm_d, 0); | ||
813 | cs->irq = pnp_irq(pnp_avm_d, 0); | ||
814 | if (!cs->irq) { | ||
815 | printk(KERN_ERR "FritzPnP:No IRQ\n"); | ||
816 | return(0); | ||
817 | } | ||
818 | if (!cs->hw.avm.cfg_reg) { | ||
819 | printk(KERN_ERR "FritzPnP:No IO address\n"); | ||
820 | return(0); | ||
821 | } | ||
822 | cs->subtyp = AVM_FRITZ_PNP; | ||
823 | |||
824 | return (2); /* goto 'ready' label */ | ||
825 | } | ||
826 | } | ||
827 | |||
828 | return (1); | ||
829 | } | ||
830 | |||
831 | #endif /* __ISAPNP__ */ | ||
832 | |||
833 | #ifndef CONFIG_PCI | ||
834 | |||
835 | static int __devinit avm_pci_setup(struct IsdnCardState *cs) | ||
836 | { | ||
837 | return(1); /* no-op: success */ | ||
838 | } | ||
839 | |||
840 | #else | ||
841 | |||
842 | static struct pci_dev *dev_avm __devinitdata = NULL; | ||
843 | |||
844 | static int __devinit avm_pci_setup(struct IsdnCardState *cs) | ||
845 | { | ||
846 | if ((dev_avm = pci_find_device(PCI_VENDOR_ID_AVM, | ||
847 | PCI_DEVICE_ID_AVM_A1, dev_avm))) { | ||
848 | |||
849 | if (pci_enable_device(dev_avm)) | ||
850 | return(0); | ||
851 | |||
852 | cs->irq = dev_avm->irq; | ||
853 | if (!cs->irq) { | ||
854 | printk(KERN_ERR "FritzPCI: No IRQ for PCI card found\n"); | ||
855 | return(0); | ||
856 | } | ||
857 | |||
858 | cs->hw.avm.cfg_reg = pci_resource_start(dev_avm, 1); | ||
859 | if (!cs->hw.avm.cfg_reg) { | ||
860 | printk(KERN_ERR "FritzPCI: No IO-Adr for PCI card found\n"); | ||
861 | return(0); | ||
862 | } | ||
863 | |||
864 | cs->subtyp = AVM_FRITZ_PCI; | ||
865 | } else { | ||
866 | printk(KERN_WARNING "FritzPCI: No PCI card found\n"); | ||
867 | return(0); | ||
868 | } | ||
869 | |||
870 | cs->irq_flags |= IRQF_SHARED; | ||
871 | |||
872 | return (1); | ||
873 | } | ||
874 | |||
875 | #endif /* CONFIG_PCI */ | ||
876 | |||
877 | int __devinit | ||
878 | setup_avm_pcipnp(struct IsdnCard *card) | ||
879 | { | ||
880 | struct IsdnCardState *cs = card->cs; | ||
881 | char tmp[64]; | ||
882 | int rc; | ||
883 | |||
884 | strcpy(tmp, avm_pci_rev); | ||
885 | printk(KERN_INFO "HiSax: AVM PCI driver Rev. %s\n", HiSax_getrev(tmp)); | ||
886 | |||
887 | if (cs->typ != ISDN_CTYPE_FRITZPCI) | ||
888 | return (0); | ||
889 | |||
890 | if (card->para[1]) { | ||
891 | /* old manual method */ | ||
892 | cs->hw.avm.cfg_reg = card->para[1]; | ||
893 | cs->irq = card->para[0]; | ||
894 | cs->subtyp = AVM_FRITZ_PNP; | ||
895 | goto ready; | ||
896 | } | ||
897 | |||
898 | rc = avm_pnp_setup(cs); | ||
899 | if (rc < 1) | ||
900 | return (0); | ||
901 | if (rc == 2) | ||
902 | goto ready; | ||
903 | |||
904 | rc = avm_pci_setup(cs); | ||
905 | if (rc < 1) | ||
906 | return (0); | ||
907 | |||
908 | ready: | ||
909 | return avm_setup_rest(cs); | ||
910 | } | ||