diff options
-rw-r--r-- | drivers/isdn/hisax/diva.c | 513 |
1 files changed, 294 insertions, 219 deletions
diff --git a/drivers/isdn/hisax/diva.c b/drivers/isdn/hisax/diva.c index 6eebeb441bfd..826745078746 100644 --- a/drivers/isdn/hisax/diva.c +++ b/drivers/isdn/hisax/diva.c | |||
@@ -25,8 +25,6 @@ | |||
25 | #include <linux/pci.h> | 25 | #include <linux/pci.h> |
26 | #include <linux/isapnp.h> | 26 | #include <linux/isapnp.h> |
27 | 27 | ||
28 | extern const char *CardType[]; | ||
29 | |||
30 | static const char *Diva_revision = "$Revision: 1.33.2.6 $"; | 28 | static const char *Diva_revision = "$Revision: 1.33.2.6 $"; |
31 | 29 | ||
32 | #define byteout(addr,val) outb(val,addr) | 30 | #define byteout(addr,val) outb(val,addr) |
@@ -906,225 +904,15 @@ Diva_card_msg(struct IsdnCardState *cs, int mt, void *arg) | |||
906 | return(0); | 904 | return(0); |
907 | } | 905 | } |
908 | 906 | ||
909 | static struct pci_dev *dev_diva __devinitdata = NULL; | 907 | static int __devinit setup_diva_common(struct IsdnCardState *cs) |
910 | static struct pci_dev *dev_diva_u __devinitdata = NULL; | ||
911 | static struct pci_dev *dev_diva201 __devinitdata = NULL; | ||
912 | static struct pci_dev *dev_diva202 __devinitdata = NULL; | ||
913 | |||
914 | #ifdef __ISAPNP__ | ||
915 | static struct isapnp_device_id diva_ids[] __devinitdata = { | ||
916 | { ISAPNP_VENDOR('G', 'D', 'I'), ISAPNP_FUNCTION(0x51), | ||
917 | ISAPNP_VENDOR('G', 'D', 'I'), ISAPNP_FUNCTION(0x51), | ||
918 | (unsigned long) "Diva picola" }, | ||
919 | { ISAPNP_VENDOR('G', 'D', 'I'), ISAPNP_FUNCTION(0x51), | ||
920 | ISAPNP_VENDOR('E', 'I', 'C'), ISAPNP_FUNCTION(0x51), | ||
921 | (unsigned long) "Diva picola" }, | ||
922 | { ISAPNP_VENDOR('G', 'D', 'I'), ISAPNP_FUNCTION(0x71), | ||
923 | ISAPNP_VENDOR('G', 'D', 'I'), ISAPNP_FUNCTION(0x71), | ||
924 | (unsigned long) "Diva 2.0" }, | ||
925 | { ISAPNP_VENDOR('G', 'D', 'I'), ISAPNP_FUNCTION(0x71), | ||
926 | ISAPNP_VENDOR('E', 'I', 'C'), ISAPNP_FUNCTION(0x71), | ||
927 | (unsigned long) "Diva 2.0" }, | ||
928 | { ISAPNP_VENDOR('G', 'D', 'I'), ISAPNP_FUNCTION(0xA1), | ||
929 | ISAPNP_VENDOR('G', 'D', 'I'), ISAPNP_FUNCTION(0xA1), | ||
930 | (unsigned long) "Diva 2.01" }, | ||
931 | { ISAPNP_VENDOR('G', 'D', 'I'), ISAPNP_FUNCTION(0xA1), | ||
932 | ISAPNP_VENDOR('E', 'I', 'C'), ISAPNP_FUNCTION(0xA1), | ||
933 | (unsigned long) "Diva 2.01" }, | ||
934 | { 0, } | ||
935 | }; | ||
936 | |||
937 | static struct isapnp_device_id *ipid __devinitdata = &diva_ids[0]; | ||
938 | static struct pnp_card *pnp_c __devinitdata = NULL; | ||
939 | #endif | ||
940 | |||
941 | |||
942 | int __devinit | ||
943 | setup_diva(struct IsdnCard *card) | ||
944 | { | 908 | { |
945 | int bytecnt = 8; | 909 | int bytecnt; |
946 | u_char val; | 910 | u_char val; |
947 | struct IsdnCardState *cs = card->cs; | ||
948 | char tmp[64]; | ||
949 | |||
950 | strcpy(tmp, Diva_revision); | ||
951 | printk(KERN_INFO "HiSax: Eicon.Diehl Diva driver Rev. %s\n", HiSax_getrev(tmp)); | ||
952 | if (cs->typ != ISDN_CTYPE_DIEHLDIVA) | ||
953 | return(0); | ||
954 | cs->hw.diva.status = 0; | ||
955 | if (card->para[1]) { | ||
956 | cs->hw.diva.ctrl_reg = 0; | ||
957 | cs->hw.diva.cfg_reg = card->para[1]; | ||
958 | val = readreg(cs->hw.diva.cfg_reg + DIVA_IPAC_ADR, | ||
959 | cs->hw.diva.cfg_reg + DIVA_IPAC_DATA, IPAC_ID); | ||
960 | printk(KERN_INFO "Diva: IPAC version %x\n", val); | ||
961 | if ((val == 1) || (val==2)) { | ||
962 | cs->subtyp = DIVA_IPAC_ISA; | ||
963 | cs->hw.diva.ctrl = 0; | ||
964 | cs->hw.diva.isac = card->para[1] + DIVA_IPAC_DATA; | ||
965 | cs->hw.diva.hscx = card->para[1] + DIVA_IPAC_DATA; | ||
966 | cs->hw.diva.isac_adr = card->para[1] + DIVA_IPAC_ADR; | ||
967 | cs->hw.diva.hscx_adr = card->para[1] + DIVA_IPAC_ADR; | ||
968 | test_and_set_bit(HW_IPAC, &cs->HW_Flags); | ||
969 | } else { | ||
970 | cs->subtyp = DIVA_ISA; | ||
971 | cs->hw.diva.ctrl = card->para[1] + DIVA_ISA_CTRL; | ||
972 | cs->hw.diva.isac = card->para[1] + DIVA_ISA_ISAC_DATA; | ||
973 | cs->hw.diva.hscx = card->para[1] + DIVA_HSCX_DATA; | ||
974 | cs->hw.diva.isac_adr = card->para[1] + DIVA_ISA_ISAC_ADR; | ||
975 | cs->hw.diva.hscx_adr = card->para[1] + DIVA_HSCX_ADR; | ||
976 | } | ||
977 | cs->irq = card->para[0]; | ||
978 | } else { | ||
979 | #ifdef __ISAPNP__ | ||
980 | if (isapnp_present()) { | ||
981 | struct pnp_dev *pnp_d; | ||
982 | while(ipid->card_vendor) { | ||
983 | if ((pnp_c = pnp_find_card(ipid->card_vendor, | ||
984 | ipid->card_device, pnp_c))) { | ||
985 | pnp_d = NULL; | ||
986 | if ((pnp_d = pnp_find_dev(pnp_c, | ||
987 | ipid->vendor, ipid->function, pnp_d))) { | ||
988 | int err; | ||
989 | |||
990 | printk(KERN_INFO "HiSax: %s detected\n", | ||
991 | (char *)ipid->driver_data); | ||
992 | pnp_disable_dev(pnp_d); | ||
993 | err = pnp_activate_dev(pnp_d); | ||
994 | if (err<0) { | ||
995 | printk(KERN_WARNING "%s: pnp_activate_dev ret(%d)\n", | ||
996 | __FUNCTION__, err); | ||
997 | return(0); | ||
998 | } | ||
999 | card->para[1] = pnp_port_start(pnp_d, 0); | ||
1000 | card->para[0] = pnp_irq(pnp_d, 0); | ||
1001 | if (!card->para[0] || !card->para[1]) { | ||
1002 | printk(KERN_ERR "Diva PnP:some resources are missing %ld/%lx\n", | ||
1003 | card->para[0], card->para[1]); | ||
1004 | pnp_disable_dev(pnp_d); | ||
1005 | return(0); | ||
1006 | } | ||
1007 | cs->hw.diva.cfg_reg = card->para[1]; | ||
1008 | cs->irq = card->para[0]; | ||
1009 | if (ipid->function == ISAPNP_FUNCTION(0xA1)) { | ||
1010 | cs->subtyp = DIVA_IPAC_ISA; | ||
1011 | cs->hw.diva.ctrl = 0; | ||
1012 | cs->hw.diva.isac = | ||
1013 | card->para[1] + DIVA_IPAC_DATA; | ||
1014 | cs->hw.diva.hscx = | ||
1015 | card->para[1] + DIVA_IPAC_DATA; | ||
1016 | cs->hw.diva.isac_adr = | ||
1017 | card->para[1] + DIVA_IPAC_ADR; | ||
1018 | cs->hw.diva.hscx_adr = | ||
1019 | card->para[1] + DIVA_IPAC_ADR; | ||
1020 | test_and_set_bit(HW_IPAC, &cs->HW_Flags); | ||
1021 | } else { | ||
1022 | cs->subtyp = DIVA_ISA; | ||
1023 | cs->hw.diva.ctrl = | ||
1024 | card->para[1] + DIVA_ISA_CTRL; | ||
1025 | cs->hw.diva.isac = | ||
1026 | card->para[1] + DIVA_ISA_ISAC_DATA; | ||
1027 | cs->hw.diva.hscx = | ||
1028 | card->para[1] + DIVA_HSCX_DATA; | ||
1029 | cs->hw.diva.isac_adr = | ||
1030 | card->para[1] + DIVA_ISA_ISAC_ADR; | ||
1031 | cs->hw.diva.hscx_adr = | ||
1032 | card->para[1] + DIVA_HSCX_ADR; | ||
1033 | } | ||
1034 | goto ready; | ||
1035 | } else { | ||
1036 | printk(KERN_ERR "Diva PnP: PnP error card found, no device\n"); | ||
1037 | return(0); | ||
1038 | } | ||
1039 | } | ||
1040 | ipid++; | ||
1041 | pnp_c=NULL; | ||
1042 | } | ||
1043 | if (!ipid->card_vendor) { | ||
1044 | printk(KERN_INFO "Diva PnP: no ISAPnP card found\n"); | ||
1045 | } | ||
1046 | } | ||
1047 | #endif | ||
1048 | #ifdef CONFIG_PCI | ||
1049 | cs->subtyp = 0; | ||
1050 | if ((dev_diva = pci_find_device(PCI_VENDOR_ID_EICON, | ||
1051 | PCI_DEVICE_ID_EICON_DIVA20, dev_diva))) { | ||
1052 | if (pci_enable_device(dev_diva)) | ||
1053 | return(0); | ||
1054 | cs->subtyp = DIVA_PCI; | ||
1055 | cs->irq = dev_diva->irq; | ||
1056 | cs->hw.diva.cfg_reg = pci_resource_start(dev_diva, 2); | ||
1057 | } else if ((dev_diva_u = pci_find_device(PCI_VENDOR_ID_EICON, | ||
1058 | PCI_DEVICE_ID_EICON_DIVA20_U, dev_diva_u))) { | ||
1059 | if (pci_enable_device(dev_diva_u)) | ||
1060 | return(0); | ||
1061 | cs->subtyp = DIVA_PCI; | ||
1062 | cs->irq = dev_diva_u->irq; | ||
1063 | cs->hw.diva.cfg_reg = pci_resource_start(dev_diva_u, 2); | ||
1064 | } else if ((dev_diva201 = pci_find_device(PCI_VENDOR_ID_EICON, | ||
1065 | PCI_DEVICE_ID_EICON_DIVA201, dev_diva201))) { | ||
1066 | if (pci_enable_device(dev_diva201)) | ||
1067 | return(0); | ||
1068 | cs->subtyp = DIVA_IPAC_PCI; | ||
1069 | cs->irq = dev_diva201->irq; | ||
1070 | cs->hw.diva.pci_cfg = | ||
1071 | (ulong) ioremap(pci_resource_start(dev_diva201, 0), 4096); | ||
1072 | cs->hw.diva.cfg_reg = | ||
1073 | (ulong) ioremap(pci_resource_start(dev_diva201, 1), 4096); | ||
1074 | } else if ((dev_diva202 = pci_find_device(PCI_VENDOR_ID_EICON, | ||
1075 | PCI_DEVICE_ID_EICON_DIVA202, dev_diva202))) { | ||
1076 | if (pci_enable_device(dev_diva202)) | ||
1077 | return(0); | ||
1078 | cs->subtyp = DIVA_IPACX_PCI; | ||
1079 | cs->irq = dev_diva202->irq; | ||
1080 | cs->hw.diva.pci_cfg = | ||
1081 | (ulong) ioremap(pci_resource_start(dev_diva202, 0), 4096); | ||
1082 | cs->hw.diva.cfg_reg = | ||
1083 | (ulong) ioremap(pci_resource_start(dev_diva202, 1), 4096); | ||
1084 | } else { | ||
1085 | printk(KERN_WARNING "Diva: No PCI card found\n"); | ||
1086 | return(0); | ||
1087 | } | ||
1088 | |||
1089 | if (!cs->irq) { | ||
1090 | printk(KERN_WARNING "Diva: No IRQ for PCI card found\n"); | ||
1091 | iounmap_diva(cs); | ||
1092 | return(0); | ||
1093 | } | ||
1094 | |||
1095 | if (!cs->hw.diva.cfg_reg) { | ||
1096 | printk(KERN_WARNING "Diva: No IO-Adr for PCI card found\n"); | ||
1097 | iounmap_diva(cs); | ||
1098 | return(0); | ||
1099 | } | ||
1100 | cs->irq_flags |= IRQF_SHARED; | ||
1101 | #else | ||
1102 | printk(KERN_WARNING "Diva: cfgreg 0 and NO_PCI_BIOS\n"); | ||
1103 | printk(KERN_WARNING "Diva: unable to config DIVA PCI\n"); | ||
1104 | return (0); | ||
1105 | #endif /* CONFIG_PCI */ | ||
1106 | if ((cs->subtyp == DIVA_IPAC_PCI) || | ||
1107 | (cs->subtyp == DIVA_IPACX_PCI) ) { | ||
1108 | cs->hw.diva.ctrl = 0; | ||
1109 | cs->hw.diva.isac = 0; | ||
1110 | cs->hw.diva.hscx = 0; | ||
1111 | cs->hw.diva.isac_adr = 0; | ||
1112 | cs->hw.diva.hscx_adr = 0; | ||
1113 | test_and_set_bit(HW_IPAC, &cs->HW_Flags); | ||
1114 | bytecnt = 0; | ||
1115 | } else { | ||
1116 | cs->hw.diva.ctrl = cs->hw.diva.cfg_reg + DIVA_PCI_CTRL; | ||
1117 | cs->hw.diva.isac = cs->hw.diva.cfg_reg + DIVA_PCI_ISAC_DATA; | ||
1118 | cs->hw.diva.hscx = cs->hw.diva.cfg_reg + DIVA_HSCX_DATA; | ||
1119 | cs->hw.diva.isac_adr = cs->hw.diva.cfg_reg + DIVA_PCI_ISAC_ADR; | ||
1120 | cs->hw.diva.hscx_adr = cs->hw.diva.cfg_reg + DIVA_HSCX_ADR; | ||
1121 | bytecnt = 32; | ||
1122 | } | ||
1123 | } | ||
1124 | 911 | ||
1125 | #ifdef __ISAPNP__ | 912 | if ((cs->subtyp == DIVA_ISA) || (cs->subtyp == DIVA_IPAC_ISA)) |
1126 | ready: | 913 | bytecnt = 8; |
1127 | #endif | 914 | else |
915 | bytecnt = 32; | ||
1128 | 916 | ||
1129 | printk(KERN_INFO | 917 | printk(KERN_INFO |
1130 | "Diva: %s card configured at %#lx IRQ %d\n", | 918 | "Diva: %s card configured at %#lx IRQ %d\n", |
@@ -1145,7 +933,7 @@ ready: | |||
1145 | if (!request_region(cs->hw.diva.cfg_reg, bytecnt, "diva isdn")) { | 933 | if (!request_region(cs->hw.diva.cfg_reg, bytecnt, "diva isdn")) { |
1146 | printk(KERN_WARNING | 934 | printk(KERN_WARNING |
1147 | "HiSax: %s config port %lx-%lx already in use\n", | 935 | "HiSax: %s config port %lx-%lx already in use\n", |
1148 | CardType[card->typ], | 936 | "diva", |
1149 | cs->hw.diva.cfg_reg, | 937 | cs->hw.diva.cfg_reg, |
1150 | cs->hw.diva.cfg_reg + bytecnt); | 938 | cs->hw.diva.cfg_reg + bytecnt); |
1151 | iounmap_diva(cs); | 939 | iounmap_diva(cs); |
@@ -1206,3 +994,290 @@ ready: | |||
1206 | } | 994 | } |
1207 | return (1); | 995 | return (1); |
1208 | } | 996 | } |
997 | |||
998 | #ifdef CONFIG_ISA | ||
999 | |||
1000 | static int __devinit setup_diva_isa(struct IsdnCard *card) | ||
1001 | { | ||
1002 | struct IsdnCardState *cs = card->cs; | ||
1003 | u_char val; | ||
1004 | |||
1005 | if (!card->para[1]) | ||
1006 | return (-1); /* card not found; continue search */ | ||
1007 | |||
1008 | cs->hw.diva.ctrl_reg = 0; | ||
1009 | cs->hw.diva.cfg_reg = card->para[1]; | ||
1010 | val = readreg(cs->hw.diva.cfg_reg + DIVA_IPAC_ADR, | ||
1011 | cs->hw.diva.cfg_reg + DIVA_IPAC_DATA, IPAC_ID); | ||
1012 | printk(KERN_INFO "Diva: IPAC version %x\n", val); | ||
1013 | if ((val == 1) || (val==2)) { | ||
1014 | cs->subtyp = DIVA_IPAC_ISA; | ||
1015 | cs->hw.diva.ctrl = 0; | ||
1016 | cs->hw.diva.isac = card->para[1] + DIVA_IPAC_DATA; | ||
1017 | cs->hw.diva.hscx = card->para[1] + DIVA_IPAC_DATA; | ||
1018 | cs->hw.diva.isac_adr = card->para[1] + DIVA_IPAC_ADR; | ||
1019 | cs->hw.diva.hscx_adr = card->para[1] + DIVA_IPAC_ADR; | ||
1020 | test_and_set_bit(HW_IPAC, &cs->HW_Flags); | ||
1021 | } else { | ||
1022 | cs->subtyp = DIVA_ISA; | ||
1023 | cs->hw.diva.ctrl = card->para[1] + DIVA_ISA_CTRL; | ||
1024 | cs->hw.diva.isac = card->para[1] + DIVA_ISA_ISAC_DATA; | ||
1025 | cs->hw.diva.hscx = card->para[1] + DIVA_HSCX_DATA; | ||
1026 | cs->hw.diva.isac_adr = card->para[1] + DIVA_ISA_ISAC_ADR; | ||
1027 | cs->hw.diva.hscx_adr = card->para[1] + DIVA_HSCX_ADR; | ||
1028 | } | ||
1029 | cs->irq = card->para[0]; | ||
1030 | |||
1031 | return (1); /* card found */ | ||
1032 | } | ||
1033 | |||
1034 | #else /* if !CONFIG_ISA */ | ||
1035 | |||
1036 | static int __devinit setup_diva_isa(struct IsdnCard *card) | ||
1037 | { | ||
1038 | return (-1); /* card not found; continue search */ | ||
1039 | } | ||
1040 | |||
1041 | #endif /* CONFIG_ISA */ | ||
1042 | |||
1043 | #ifdef __ISAPNP__ | ||
1044 | static struct isapnp_device_id diva_ids[] __devinitdata = { | ||
1045 | { ISAPNP_VENDOR('G', 'D', 'I'), ISAPNP_FUNCTION(0x51), | ||
1046 | ISAPNP_VENDOR('G', 'D', 'I'), ISAPNP_FUNCTION(0x51), | ||
1047 | (unsigned long) "Diva picola" }, | ||
1048 | { ISAPNP_VENDOR('G', 'D', 'I'), ISAPNP_FUNCTION(0x51), | ||
1049 | ISAPNP_VENDOR('E', 'I', 'C'), ISAPNP_FUNCTION(0x51), | ||
1050 | (unsigned long) "Diva picola" }, | ||
1051 | { ISAPNP_VENDOR('G', 'D', 'I'), ISAPNP_FUNCTION(0x71), | ||
1052 | ISAPNP_VENDOR('G', 'D', 'I'), ISAPNP_FUNCTION(0x71), | ||
1053 | (unsigned long) "Diva 2.0" }, | ||
1054 | { ISAPNP_VENDOR('G', 'D', 'I'), ISAPNP_FUNCTION(0x71), | ||
1055 | ISAPNP_VENDOR('E', 'I', 'C'), ISAPNP_FUNCTION(0x71), | ||
1056 | (unsigned long) "Diva 2.0" }, | ||
1057 | { ISAPNP_VENDOR('G', 'D', 'I'), ISAPNP_FUNCTION(0xA1), | ||
1058 | ISAPNP_VENDOR('G', 'D', 'I'), ISAPNP_FUNCTION(0xA1), | ||
1059 | (unsigned long) "Diva 2.01" }, | ||
1060 | { ISAPNP_VENDOR('G', 'D', 'I'), ISAPNP_FUNCTION(0xA1), | ||
1061 | ISAPNP_VENDOR('E', 'I', 'C'), ISAPNP_FUNCTION(0xA1), | ||
1062 | (unsigned long) "Diva 2.01" }, | ||
1063 | { 0, } | ||
1064 | }; | ||
1065 | |||
1066 | static struct isapnp_device_id *ipid __devinitdata = &diva_ids[0]; | ||
1067 | static struct pnp_card *pnp_c __devinitdata = NULL; | ||
1068 | |||
1069 | static int __devinit setup_diva_isapnp(struct IsdnCard *card) | ||
1070 | { | ||
1071 | struct IsdnCardState *cs = card->cs; | ||
1072 | struct pnp_dev *pnp_d; | ||
1073 | |||
1074 | if (!isapnp_present()) | ||
1075 | return (-1); /* card not found; continue search */ | ||
1076 | |||
1077 | while(ipid->card_vendor) { | ||
1078 | if ((pnp_c = pnp_find_card(ipid->card_vendor, | ||
1079 | ipid->card_device, pnp_c))) { | ||
1080 | pnp_d = NULL; | ||
1081 | if ((pnp_d = pnp_find_dev(pnp_c, | ||
1082 | ipid->vendor, ipid->function, pnp_d))) { | ||
1083 | int err; | ||
1084 | |||
1085 | printk(KERN_INFO "HiSax: %s detected\n", | ||
1086 | (char *)ipid->driver_data); | ||
1087 | pnp_disable_dev(pnp_d); | ||
1088 | err = pnp_activate_dev(pnp_d); | ||
1089 | if (err<0) { | ||
1090 | printk(KERN_WARNING "%s: pnp_activate_dev ret(%d)\n", | ||
1091 | __FUNCTION__, err); | ||
1092 | return(0); | ||
1093 | } | ||
1094 | card->para[1] = pnp_port_start(pnp_d, 0); | ||
1095 | card->para[0] = pnp_irq(pnp_d, 0); | ||
1096 | if (!card->para[0] || !card->para[1]) { | ||
1097 | printk(KERN_ERR "Diva PnP:some resources are missing %ld/%lx\n", | ||
1098 | card->para[0], card->para[1]); | ||
1099 | pnp_disable_dev(pnp_d); | ||
1100 | return(0); | ||
1101 | } | ||
1102 | cs->hw.diva.cfg_reg = card->para[1]; | ||
1103 | cs->irq = card->para[0]; | ||
1104 | if (ipid->function == ISAPNP_FUNCTION(0xA1)) { | ||
1105 | cs->subtyp = DIVA_IPAC_ISA; | ||
1106 | cs->hw.diva.ctrl = 0; | ||
1107 | cs->hw.diva.isac = | ||
1108 | card->para[1] + DIVA_IPAC_DATA; | ||
1109 | cs->hw.diva.hscx = | ||
1110 | card->para[1] + DIVA_IPAC_DATA; | ||
1111 | cs->hw.diva.isac_adr = | ||
1112 | card->para[1] + DIVA_IPAC_ADR; | ||
1113 | cs->hw.diva.hscx_adr = | ||
1114 | card->para[1] + DIVA_IPAC_ADR; | ||
1115 | test_and_set_bit(HW_IPAC, &cs->HW_Flags); | ||
1116 | } else { | ||
1117 | cs->subtyp = DIVA_ISA; | ||
1118 | cs->hw.diva.ctrl = | ||
1119 | card->para[1] + DIVA_ISA_CTRL; | ||
1120 | cs->hw.diva.isac = | ||
1121 | card->para[1] + DIVA_ISA_ISAC_DATA; | ||
1122 | cs->hw.diva.hscx = | ||
1123 | card->para[1] + DIVA_HSCX_DATA; | ||
1124 | cs->hw.diva.isac_adr = | ||
1125 | card->para[1] + DIVA_ISA_ISAC_ADR; | ||
1126 | cs->hw.diva.hscx_adr = | ||
1127 | card->para[1] + DIVA_HSCX_ADR; | ||
1128 | } | ||
1129 | return (1); /* card found */ | ||
1130 | } else { | ||
1131 | printk(KERN_ERR "Diva PnP: PnP error card found, no device\n"); | ||
1132 | return(0); | ||
1133 | } | ||
1134 | } | ||
1135 | ipid++; | ||
1136 | pnp_c=NULL; | ||
1137 | } | ||
1138 | |||
1139 | return (-1); /* card not found; continue search */ | ||
1140 | } | ||
1141 | |||
1142 | #else /* if !ISAPNP */ | ||
1143 | |||
1144 | static int __devinit setup_diva_isapnp(struct IsdnCard *card) | ||
1145 | { | ||
1146 | return (-1); /* card not found; continue search */ | ||
1147 | } | ||
1148 | |||
1149 | #endif /* ISAPNP */ | ||
1150 | |||
1151 | #ifdef CONFIG_PCI | ||
1152 | static struct pci_dev *dev_diva __devinitdata = NULL; | ||
1153 | static struct pci_dev *dev_diva_u __devinitdata = NULL; | ||
1154 | static struct pci_dev *dev_diva201 __devinitdata = NULL; | ||
1155 | static struct pci_dev *dev_diva202 __devinitdata = NULL; | ||
1156 | |||
1157 | static int __devinit setup_diva_pci(struct IsdnCard *card) | ||
1158 | { | ||
1159 | struct IsdnCardState *cs = card->cs; | ||
1160 | |||
1161 | cs->subtyp = 0; | ||
1162 | if ((dev_diva = pci_find_device(PCI_VENDOR_ID_EICON, | ||
1163 | PCI_DEVICE_ID_EICON_DIVA20, dev_diva))) { | ||
1164 | if (pci_enable_device(dev_diva)) | ||
1165 | return(0); | ||
1166 | cs->subtyp = DIVA_PCI; | ||
1167 | cs->irq = dev_diva->irq; | ||
1168 | cs->hw.diva.cfg_reg = pci_resource_start(dev_diva, 2); | ||
1169 | } else if ((dev_diva_u = pci_find_device(PCI_VENDOR_ID_EICON, | ||
1170 | PCI_DEVICE_ID_EICON_DIVA20_U, dev_diva_u))) { | ||
1171 | if (pci_enable_device(dev_diva_u)) | ||
1172 | return(0); | ||
1173 | cs->subtyp = DIVA_PCI; | ||
1174 | cs->irq = dev_diva_u->irq; | ||
1175 | cs->hw.diva.cfg_reg = pci_resource_start(dev_diva_u, 2); | ||
1176 | } else if ((dev_diva201 = pci_find_device(PCI_VENDOR_ID_EICON, | ||
1177 | PCI_DEVICE_ID_EICON_DIVA201, dev_diva201))) { | ||
1178 | if (pci_enable_device(dev_diva201)) | ||
1179 | return(0); | ||
1180 | cs->subtyp = DIVA_IPAC_PCI; | ||
1181 | cs->irq = dev_diva201->irq; | ||
1182 | cs->hw.diva.pci_cfg = | ||
1183 | (ulong) ioremap(pci_resource_start(dev_diva201, 0), 4096); | ||
1184 | cs->hw.diva.cfg_reg = | ||
1185 | (ulong) ioremap(pci_resource_start(dev_diva201, 1), 4096); | ||
1186 | } else if ((dev_diva202 = pci_find_device(PCI_VENDOR_ID_EICON, | ||
1187 | PCI_DEVICE_ID_EICON_DIVA202, dev_diva202))) { | ||
1188 | if (pci_enable_device(dev_diva202)) | ||
1189 | return(0); | ||
1190 | cs->subtyp = DIVA_IPACX_PCI; | ||
1191 | cs->irq = dev_diva202->irq; | ||
1192 | cs->hw.diva.pci_cfg = | ||
1193 | (ulong) ioremap(pci_resource_start(dev_diva202, 0), 4096); | ||
1194 | cs->hw.diva.cfg_reg = | ||
1195 | (ulong) ioremap(pci_resource_start(dev_diva202, 1), 4096); | ||
1196 | } else { | ||
1197 | return (-1); /* card not found; continue search */ | ||
1198 | } | ||
1199 | |||
1200 | if (!cs->irq) { | ||
1201 | printk(KERN_WARNING "Diva: No IRQ for PCI card found\n"); | ||
1202 | iounmap_diva(cs); | ||
1203 | return(0); | ||
1204 | } | ||
1205 | |||
1206 | if (!cs->hw.diva.cfg_reg) { | ||
1207 | printk(KERN_WARNING "Diva: No IO-Adr for PCI card found\n"); | ||
1208 | iounmap_diva(cs); | ||
1209 | return(0); | ||
1210 | } | ||
1211 | cs->irq_flags |= IRQF_SHARED; | ||
1212 | |||
1213 | if ((cs->subtyp == DIVA_IPAC_PCI) || | ||
1214 | (cs->subtyp == DIVA_IPACX_PCI) ) { | ||
1215 | cs->hw.diva.ctrl = 0; | ||
1216 | cs->hw.diva.isac = 0; | ||
1217 | cs->hw.diva.hscx = 0; | ||
1218 | cs->hw.diva.isac_adr = 0; | ||
1219 | cs->hw.diva.hscx_adr = 0; | ||
1220 | test_and_set_bit(HW_IPAC, &cs->HW_Flags); | ||
1221 | } else { | ||
1222 | cs->hw.diva.ctrl = cs->hw.diva.cfg_reg + DIVA_PCI_CTRL; | ||
1223 | cs->hw.diva.isac = cs->hw.diva.cfg_reg + DIVA_PCI_ISAC_DATA; | ||
1224 | cs->hw.diva.hscx = cs->hw.diva.cfg_reg + DIVA_HSCX_DATA; | ||
1225 | cs->hw.diva.isac_adr = cs->hw.diva.cfg_reg + DIVA_PCI_ISAC_ADR; | ||
1226 | cs->hw.diva.hscx_adr = cs->hw.diva.cfg_reg + DIVA_HSCX_ADR; | ||
1227 | } | ||
1228 | |||
1229 | return (1); /* card found */ | ||
1230 | } | ||
1231 | |||
1232 | #else /* if !CONFIG_PCI */ | ||
1233 | |||
1234 | static int __devinit setup_diva_pci(struct IsdnCard *card) | ||
1235 | { | ||
1236 | return (-1); /* card not found; continue search */ | ||
1237 | } | ||
1238 | |||
1239 | #endif /* CONFIG_PCI */ | ||
1240 | |||
1241 | int __devinit | ||
1242 | setup_diva(struct IsdnCard *card) | ||
1243 | { | ||
1244 | int rc, have_card = 0; | ||
1245 | struct IsdnCardState *cs = card->cs; | ||
1246 | char tmp[64]; | ||
1247 | |||
1248 | strcpy(tmp, Diva_revision); | ||
1249 | printk(KERN_INFO "HiSax: Eicon.Diehl Diva driver Rev. %s\n", HiSax_getrev(tmp)); | ||
1250 | if (cs->typ != ISDN_CTYPE_DIEHLDIVA) | ||
1251 | return(0); | ||
1252 | cs->hw.diva.status = 0; | ||
1253 | |||
1254 | rc = setup_diva_isa(card); | ||
1255 | if (!rc) | ||
1256 | return rc; | ||
1257 | if (rc > 0) { | ||
1258 | have_card = 1; | ||
1259 | goto ready; | ||
1260 | } | ||
1261 | |||
1262 | rc = setup_diva_isapnp(card); | ||
1263 | if (!rc) | ||
1264 | return rc; | ||
1265 | if (rc > 0) { | ||
1266 | have_card = 1; | ||
1267 | goto ready; | ||
1268 | } | ||
1269 | |||
1270 | rc = setup_diva_pci(card); | ||
1271 | if (!rc) | ||
1272 | return rc; | ||
1273 | if (rc > 0) | ||
1274 | have_card = 1; | ||
1275 | |||
1276 | ready: | ||
1277 | if (!have_card) { | ||
1278 | printk(KERN_WARNING "Diva: No ISA, ISAPNP or PCI card found\n"); | ||
1279 | return(0); | ||
1280 | } | ||
1281 | |||
1282 | return setup_diva_common(card->cs); | ||
1283 | } | ||