Commit 2fbde4c0 authored by Jeff Garzik's avatar Jeff Garzik

[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: default avatarJeff Garzik <jgarzik@redhat.com>
parent bfc7c89f
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
#include <linux/isapnp.h> #include <linux/isapnp.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
extern const char *CardType[];
static const char *avm_pci_rev = "$Revision: 1.29.2.4 $"; static const char *avm_pci_rev = "$Revision: 1.29.2.4 $";
#define AVM_FRITZ_PCI 1 #define AVM_FRITZ_PCI 1
...@@ -726,34 +725,74 @@ AVM_card_msg(struct IsdnCardState *cs, int mt, void *arg) ...@@ -726,34 +725,74 @@ AVM_card_msg(struct IsdnCardState *cs, int mt, void *arg)
return(0); return(0);
} }
#ifdef CONFIG_PCI static int __devinit avm_setup_rest(struct IsdnCardState *cs)
static struct pci_dev *dev_avm __devinitdata = NULL;
#endif
#ifdef __ISAPNP__
static struct pnp_card *pnp_avm_c __devinitdata = NULL;
#endif
int __devinit
setup_avm_pcipnp(struct IsdnCard *card)
{ {
u_int val, ver; u_int val, ver;
struct IsdnCardState *cs = card->cs;
char tmp[64];
strcpy(tmp, avm_pci_rev); cs->hw.avm.isac = cs->hw.avm.cfg_reg + 0x10;
printk(KERN_INFO "HiSax: AVM PCI driver Rev. %s\n", HiSax_getrev(tmp)); if (!request_region(cs->hw.avm.cfg_reg, 32,
if (cs->typ != ISDN_CTYPE_FRITZPCI) (cs->subtyp == AVM_FRITZ_PCI) ? "avm PCI" : "avm PnP")) {
printk(KERN_WARNING
"HiSax: Fritz!PCI/PNP config port %x-%x already in use\n",
cs->hw.avm.cfg_reg,
cs->hw.avm.cfg_reg + 31);
return (0); return (0);
if (card->para[1]) {
/* old manual method */
cs->hw.avm.cfg_reg = card->para[1];
cs->irq = card->para[0];
cs->subtyp = AVM_FRITZ_PNP;
goto ready;
} }
#ifdef __ISAPNP__ switch (cs->subtyp) {
if (isapnp_present()) { case AVM_FRITZ_PCI:
val = inl(cs->hw.avm.cfg_reg);
printk(KERN_INFO "AVM PCI: stat %#x\n", val);
printk(KERN_INFO "AVM PCI: Class %X Rev %d\n",
val & 0xff, (val>>8) & 0xff);
cs->BC_Read_Reg = &ReadHDLC_s;
cs->BC_Write_Reg = &WriteHDLC_s;
break;
case AVM_FRITZ_PNP:
val = inb(cs->hw.avm.cfg_reg);
ver = inb(cs->hw.avm.cfg_reg + 1);
printk(KERN_INFO "AVM PnP: Class %X Rev %d\n", val, ver);
cs->BC_Read_Reg = &ReadHDLCPnP;
cs->BC_Write_Reg = &WriteHDLCPnP;
break;
default:
printk(KERN_WARNING "AVM unknown subtype %d\n", cs->subtyp);
return(0);
}
printk(KERN_INFO "HiSax: %s config irq:%d base:0x%X\n",
(cs->subtyp == AVM_FRITZ_PCI) ? "AVM Fritz!PCI" : "AVM Fritz!PnP",
cs->irq, cs->hw.avm.cfg_reg);
setup_isac(cs);
cs->readisac = &ReadISAC;
cs->writeisac = &WriteISAC;
cs->readisacfifo = &ReadISACfifo;
cs->writeisacfifo = &WriteISACfifo;
cs->BC_Send_Data = &hdlc_fill_fifo;
cs->cardmsg = &AVM_card_msg;
cs->irq_func = &avm_pcipnp_interrupt;
cs->writeisac(cs, ISAC_MASK, 0xFF);
ISACVersion(cs, (cs->subtyp == AVM_FRITZ_PCI) ? "AVM PCI:" : "AVM PnP:");
return (1);
}
#ifndef __ISAPNP__
static int __devinit avm_pnp_setup(struct IsdnCardState *cs)
{
return(1); /* no-op: success */
}
#else
static struct pnp_card *pnp_avm_c __devinitdata = NULL;
static int __devinit avm_pnp_setup(struct IsdnCardState *cs)
{
struct pnp_dev *pnp_avm_d = NULL; struct pnp_dev *pnp_avm_d = NULL;
if (!isapnp_present())
return(1); /* no-op: success */
if ((pnp_avm_c = pnp_find_card( if ((pnp_avm_c = pnp_find_card(
ISAPNP_VENDOR('A', 'V', 'M'), ISAPNP_VENDOR('A', 'V', 'M'),
ISAPNP_FUNCTION(0x0900), pnp_avm_c))) { ISAPNP_FUNCTION(0x0900), pnp_avm_c))) {
...@@ -781,82 +820,91 @@ setup_avm_pcipnp(struct IsdnCard *card) ...@@ -781,82 +820,91 @@ setup_avm_pcipnp(struct IsdnCard *card)
return(0); return(0);
} }
cs->subtyp = AVM_FRITZ_PNP; cs->subtyp = AVM_FRITZ_PNP;
goto ready;
} return (2); /* goto 'ready' label */
} }
} else {
printk(KERN_INFO "FritzPnP: no ISA PnP present\n");
} }
#endif
#ifdef CONFIG_PCI return (1);
}
#endif /* __ISAPNP__ */
#ifndef CONFIG_PCI
static int __devinit avm_pci_setup(struct IsdnCardState *cs)
{
return(1); /* no-op: success */
}
#else
static struct pci_dev *dev_avm __devinitdata = NULL;
static int __devinit avm_pci_setup(struct IsdnCardState *cs)
{
if ((dev_avm = pci_find_device(PCI_VENDOR_ID_AVM, if ((dev_avm = pci_find_device(PCI_VENDOR_ID_AVM,
PCI_DEVICE_ID_AVM_A1, dev_avm))) { PCI_DEVICE_ID_AVM_A1, dev_avm))) {
if (pci_enable_device(dev_avm)) if (pci_enable_device(dev_avm))
return(0); return(0);
cs->irq = dev_avm->irq; cs->irq = dev_avm->irq;
if (!cs->irq) { if (!cs->irq) {
printk(KERN_ERR "FritzPCI: No IRQ for PCI card found\n"); printk(KERN_ERR "FritzPCI: No IRQ for PCI card found\n");
return(0); return(0);
} }
cs->hw.avm.cfg_reg = pci_resource_start(dev_avm, 1); cs->hw.avm.cfg_reg = pci_resource_start(dev_avm, 1);
if (!cs->hw.avm.cfg_reg) { if (!cs->hw.avm.cfg_reg) {
printk(KERN_ERR "FritzPCI: No IO-Adr for PCI card found\n"); printk(KERN_ERR "FritzPCI: No IO-Adr for PCI card found\n");
return(0); return(0);
} }
cs->subtyp = AVM_FRITZ_PCI; cs->subtyp = AVM_FRITZ_PCI;
} else { } else {
printk(KERN_WARNING "FritzPCI: No PCI card found\n"); printk(KERN_WARNING "FritzPCI: No PCI card found\n");
return(0); return(0);
} }
cs->irq_flags |= IRQF_SHARED; cs->irq_flags |= IRQF_SHARED;
#else
printk(KERN_WARNING "FritzPCI: NO_PCI_BIOS\n"); return (1);
return (0); }
#endif /* CONFIG_PCI */ #endif /* CONFIG_PCI */
ready:
cs->hw.avm.isac = cs->hw.avm.cfg_reg + 0x10; int __devinit
if (!request_region(cs->hw.avm.cfg_reg, 32, setup_avm_pcipnp(struct IsdnCard *card)
(cs->subtyp == AVM_FRITZ_PCI) ? "avm PCI" : "avm PnP")) { {
printk(KERN_WARNING struct IsdnCardState *cs = card->cs;
"HiSax: %s config port %x-%x already in use\n", char tmp[64];
CardType[card->typ], int rc;
cs->hw.avm.cfg_reg,
cs->hw.avm.cfg_reg + 31); strcpy(tmp, avm_pci_rev);
printk(KERN_INFO "HiSax: AVM PCI driver Rev. %s\n", HiSax_getrev(tmp));
if (cs->typ != ISDN_CTYPE_FRITZPCI)
return (0); return (0);
if (card->para[1]) {
/* old manual method */
cs->hw.avm.cfg_reg = card->para[1];
cs->irq = card->para[0];
cs->subtyp = AVM_FRITZ_PNP;
goto ready;
} }
switch (cs->subtyp) {
case AVM_FRITZ_PCI:
val = inl(cs->hw.avm.cfg_reg);
printk(KERN_INFO "AVM PCI: stat %#x\n", val);
printk(KERN_INFO "AVM PCI: Class %X Rev %d\n",
val & 0xff, (val>>8) & 0xff);
cs->BC_Read_Reg = &ReadHDLC_s;
cs->BC_Write_Reg = &WriteHDLC_s;
break;
case AVM_FRITZ_PNP:
val = inb(cs->hw.avm.cfg_reg);
ver = inb(cs->hw.avm.cfg_reg + 1);
printk(KERN_INFO "AVM PnP: Class %X Rev %d\n", val, ver);
cs->BC_Read_Reg = &ReadHDLCPnP;
cs->BC_Write_Reg = &WriteHDLCPnP;
break;
default:
printk(KERN_WARNING "AVM unknown subtype %d\n", cs->subtyp);
return(0);
}
printk(KERN_INFO "HiSax: %s config irq:%d base:0x%X\n",
(cs->subtyp == AVM_FRITZ_PCI) ? "AVM Fritz!PCI" : "AVM Fritz!PnP",
cs->irq, cs->hw.avm.cfg_reg);
setup_isac(cs); rc = avm_pnp_setup(cs);
cs->readisac = &ReadISAC; if (rc < 1)
cs->writeisac = &WriteISAC; return (0);
cs->readisacfifo = &ReadISACfifo; if (rc == 2)
cs->writeisacfifo = &WriteISACfifo; goto ready;
cs->BC_Send_Data = &hdlc_fill_fifo;
cs->cardmsg = &AVM_card_msg; rc = avm_pci_setup(cs);
cs->irq_func = &avm_pcipnp_interrupt; if (rc < 1)
cs->writeisac(cs, ISAC_MASK, 0xFF); return (0);
ISACVersion(cs, (cs->subtyp == AVM_FRITZ_PCI) ? "AVM PCI:" : "AVM PnP:");
return (1); ready:
return avm_setup_rest(cs);
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment