Merge branch 'isdn-cleanup' of master.kernel.org:/pub/scm/linux/kernel/git/jgarzik/misc-2.6

* 'isdn-cleanup' of master.kernel.org:/pub/scm/linux/kernel/git/jgarzik/misc-2.6:
  [ISDN] HiSax hfc_pci: minor cleanups
  [ISDN] HiSax bkm_a4t: split setup into two smaller functions
  [ISDN] HiSax enternow: split setup into 3 smaller functions
  [ISDN] HiSax netjet_u: split setup into 3 smaller functions
  [ISDN] HiSax netjet_s: code movement, prep for hotplug
  [ISDN] HiSax: move card state alloc/setup code into separate functions
  [ISDN] HiSax: move card setup into separate function
This commit is contained in:
Linus Torvalds 2007-07-17 15:23:37 -07:00
commit 96a6099d2f
6 changed files with 604 additions and 490 deletions

View file

@ -255,54 +255,38 @@ BKM_card_msg(struct IsdnCardState *cs, int mt, void *arg)
return (0); return (0);
} }
static struct pci_dev *dev_a4t __devinitdata = NULL; static int __devinit a4t_pci_probe(struct pci_dev *dev_a4t,
struct IsdnCardState *cs,
int __devinit u_int *found,
setup_bkm_a4t(struct IsdnCard *card) u_int *pci_memaddr)
{
u16 sub_sys;
u16 sub_vendor;
sub_vendor = dev_a4t->subsystem_vendor;
sub_sys = dev_a4t->subsystem_device;
if ((sub_sys == PCI_DEVICE_ID_BERKOM_A4T) && (sub_vendor == PCI_VENDOR_ID_BERKOM)) {
if (pci_enable_device(dev_a4t))
return (0); /* end loop & function */
*found = 1;
*pci_memaddr = pci_resource_start(dev_a4t, 0);
cs->irq = dev_a4t->irq;
return (1); /* end loop */
}
return (-1); /* continue looping */
}
static int __devinit a4t_cs_init(struct IsdnCard *card,
struct IsdnCardState *cs,
u_int pci_memaddr)
{ {
struct IsdnCardState *cs = card->cs;
char tmp[64];
u_int pci_memaddr = 0, found = 0;
I20_REGISTER_FILE *pI20_Regs; I20_REGISTER_FILE *pI20_Regs;
#ifdef CONFIG_PCI
#endif
strcpy(tmp, bkm_a4t_revision);
printk(KERN_INFO "HiSax: T-Berkom driver Rev. %s\n", HiSax_getrev(tmp));
if (cs->typ == ISDN_CTYPE_BKM_A4T) {
cs->subtyp = BKM_A4T;
} else
return (0);
#ifdef CONFIG_PCI
while ((dev_a4t = pci_find_device(PCI_VENDOR_ID_ZORAN,
PCI_DEVICE_ID_ZORAN_36120, dev_a4t))) {
u16 sub_sys;
u16 sub_vendor;
sub_vendor = dev_a4t->subsystem_vendor;
sub_sys = dev_a4t->subsystem_device;
if ((sub_sys == PCI_DEVICE_ID_BERKOM_A4T) && (sub_vendor == PCI_VENDOR_ID_BERKOM)) {
if (pci_enable_device(dev_a4t))
return(0);
found = 1;
pci_memaddr = pci_resource_start(dev_a4t, 0);
cs->irq = dev_a4t->irq;
break;
}
}
if (!found) {
printk(KERN_WARNING "HiSax: %s: Card not found\n", CardType[card->typ]);
return (0);
}
if (!cs->irq) { /* IRQ range check ?? */ if (!cs->irq) { /* IRQ range check ?? */
printk(KERN_WARNING "HiSax: %s: No IRQ\n", CardType[card->typ]); printk(KERN_WARNING "HiSax: %s: No IRQ\n", CardType[card->typ]);
return (0); return (0);
} }
if (!pci_memaddr) {
printk(KERN_WARNING "HiSax: %s: No Memory base address\n", CardType[card->typ]);
return (0);
}
cs->hw.ax.base = (long) ioremap(pci_memaddr, 4096); cs->hw.ax.base = (long) ioremap(pci_memaddr, 4096);
/* Check suspecious address */ /* Check suspecious address */
pI20_Regs = (I20_REGISTER_FILE *) (cs->hw.ax.base); pI20_Regs = (I20_REGISTER_FILE *) (cs->hw.ax.base);
@ -317,11 +301,7 @@ setup_bkm_a4t(struct IsdnCard *card)
cs->hw.ax.jade_adr = cs->hw.ax.base + PO_OFFSET; cs->hw.ax.jade_adr = cs->hw.ax.base + PO_OFFSET;
cs->hw.ax.isac_ale = GCS_1; cs->hw.ax.isac_ale = GCS_1;
cs->hw.ax.jade_ale = GCS_3; cs->hw.ax.jade_ale = GCS_3;
#else
printk(KERN_WARNING "HiSax: %s: NO_PCI_BIOS\n", CardType[card->typ]);
printk(KERN_WARNING "HiSax: %s: unable to configure\n", CardType[card->typ]);
return (0);
#endif /* CONFIG_PCI */
printk(KERN_INFO "HiSax: %s: Card configured at 0x%lX IRQ %d\n", printk(KERN_INFO "HiSax: %s: Card configured at 0x%lX IRQ %d\n",
CardType[card->typ], cs->hw.ax.base, cs->irq); CardType[card->typ], cs->hw.ax.base, cs->irq);
@ -339,5 +319,43 @@ setup_bkm_a4t(struct IsdnCard *card)
ISACVersion(cs, "Telekom A4T:"); ISACVersion(cs, "Telekom A4T:");
/* Jade version */ /* Jade version */
JadeVersion(cs, "Telekom A4T:"); JadeVersion(cs, "Telekom A4T:");
return (1); return (1);
} }
static struct pci_dev *dev_a4t __devinitdata = NULL;
int __devinit
setup_bkm_a4t(struct IsdnCard *card)
{
struct IsdnCardState *cs = card->cs;
char tmp[64];
u_int pci_memaddr = 0, found = 0;
int ret;
strcpy(tmp, bkm_a4t_revision);
printk(KERN_INFO "HiSax: T-Berkom driver Rev. %s\n", HiSax_getrev(tmp));
if (cs->typ == ISDN_CTYPE_BKM_A4T) {
cs->subtyp = BKM_A4T;
} else
return (0);
while ((dev_a4t = pci_find_device(PCI_VENDOR_ID_ZORAN,
PCI_DEVICE_ID_ZORAN_36120, dev_a4t))) {
ret = a4t_pci_probe(dev_a4t, cs, &found, &pci_memaddr);
if (!ret)
return (0);
if (ret > 0)
break;
}
if (!found) {
printk(KERN_WARNING "HiSax: %s: Card not found\n", CardType[card->typ]);
return (0);
}
if (!pci_memaddr) {
printk(KERN_WARNING "HiSax: %s: No Memory base address\n", CardType[card->typ]);
return (0);
}
return a4t_cs_init(card, cs, pci_memaddr);
}

View file

@ -847,95 +847,10 @@ static int init_card(struct IsdnCardState *cs)
return 3; return 3;
} }
static int checkcard(int cardnr, char *id, int *busy_flag, struct module *lockowner) static int hisax_cs_setup_card(struct IsdnCard *card)
{ {
int ret = 0; int ret;
struct IsdnCard *card = cards + cardnr;
struct IsdnCardState *cs;
cs = kzalloc(sizeof(struct IsdnCardState), GFP_ATOMIC);
if (!cs) {
printk(KERN_WARNING
"HiSax: No memory for IsdnCardState(card %d)\n",
cardnr + 1);
goto out;
}
card->cs = cs;
spin_lock_init(&cs->statlock);
spin_lock_init(&cs->lock);
cs->chanlimit = 2; /* maximum B-channel number */
cs->logecho = 0; /* No echo logging */
cs->cardnr = cardnr;
cs->debug = L1_DEB_WARN;
cs->HW_Flags = 0;
cs->busy_flag = busy_flag;
cs->irq_flags = I4L_IRQ_FLAG;
#if TEI_PER_CARD
if (card->protocol == ISDN_PTYPE_NI1)
test_and_set_bit(FLG_TWO_DCHAN, &cs->HW_Flags);
#else
test_and_set_bit(FLG_TWO_DCHAN, &cs->HW_Flags);
#endif
cs->protocol = card->protocol;
if (card->typ <= 0 || card->typ > ISDN_CTYPE_COUNT) {
printk(KERN_WARNING
"HiSax: Card Type %d out of range\n", card->typ);
goto outf_cs;
}
if (!(cs->dlog = kmalloc(MAX_DLOG_SPACE, GFP_ATOMIC))) {
printk(KERN_WARNING
"HiSax: No memory for dlog(card %d)\n", cardnr + 1);
goto outf_cs;
}
if (!(cs->status_buf = kmalloc(HISAX_STATUS_BUFSIZE, GFP_ATOMIC))) {
printk(KERN_WARNING
"HiSax: No memory for status_buf(card %d)\n",
cardnr + 1);
goto outf_dlog;
}
cs->stlist = NULL;
cs->status_read = cs->status_buf;
cs->status_write = cs->status_buf;
cs->status_end = cs->status_buf + HISAX_STATUS_BUFSIZE - 1;
cs->typ = card->typ;
#ifdef MODULE
cs->iif.owner = lockowner;
#endif
strcpy(cs->iif.id, id);
cs->iif.channels = 2;
cs->iif.maxbufsize = MAX_DATA_SIZE;
cs->iif.hl_hdrlen = MAX_HEADER_LEN;
cs->iif.features =
ISDN_FEATURE_L2_X75I |
ISDN_FEATURE_L2_HDLC |
ISDN_FEATURE_L2_HDLC_56K |
ISDN_FEATURE_L2_TRANS |
ISDN_FEATURE_L3_TRANS |
#ifdef CONFIG_HISAX_1TR6
ISDN_FEATURE_P_1TR6 |
#endif
#ifdef CONFIG_HISAX_EURO
ISDN_FEATURE_P_EURO |
#endif
#ifdef CONFIG_HISAX_NI1
ISDN_FEATURE_P_NI1 |
#endif
0;
cs->iif.command = HiSax_command;
cs->iif.writecmd = NULL;
cs->iif.writebuf_skb = HiSax_writebuf_skb;
cs->iif.readstat = HiSax_readstatus;
register_isdn(&cs->iif);
cs->myid = cs->iif.channels;
printk(KERN_INFO
"HiSax: Card %d Protocol %s Id=%s (%d)\n", cardnr + 1,
(card->protocol == ISDN_PTYPE_1TR6) ? "1TR6" :
(card->protocol == ISDN_PTYPE_EURO) ? "EDSS1" :
(card->protocol == ISDN_PTYPE_LEASED) ? "LEASED" :
(card->protocol == ISDN_PTYPE_NI1) ? "NI1" :
"NONE", cs->iif.id, cs->myid);
switch (card->typ) { switch (card->typ) {
#if CARD_TELES0 #if CARD_TELES0
case ISDN_CTYPE_16_0: case ISDN_CTYPE_16_0:
@ -1094,13 +1009,115 @@ static int checkcard(int cardnr, char *id, int *busy_flag, struct module *lockow
printk(KERN_WARNING printk(KERN_WARNING
"HiSax: Support for %s Card not selected\n", "HiSax: Support for %s Card not selected\n",
CardType[card->typ]); CardType[card->typ]);
ll_unload(cs); ret = 0;
break;
}
return ret;
}
static int hisax_cs_new(int cardnr, char *id, struct IsdnCard *card,
struct IsdnCardState **cs_out, int *busy_flag,
struct module *lockowner)
{
struct IsdnCardState *cs;
*cs_out = NULL;
cs = kzalloc(sizeof(struct IsdnCardState), GFP_ATOMIC);
if (!cs) {
printk(KERN_WARNING
"HiSax: No memory for IsdnCardState(card %d)\n",
cardnr + 1);
goto out;
}
card->cs = cs;
spin_lock_init(&cs->statlock);
spin_lock_init(&cs->lock);
cs->chanlimit = 2; /* maximum B-channel number */
cs->logecho = 0; /* No echo logging */
cs->cardnr = cardnr;
cs->debug = L1_DEB_WARN;
cs->HW_Flags = 0;
cs->busy_flag = busy_flag;
cs->irq_flags = I4L_IRQ_FLAG;
#if TEI_PER_CARD
if (card->protocol == ISDN_PTYPE_NI1)
test_and_set_bit(FLG_TWO_DCHAN, &cs->HW_Flags);
#else
test_and_set_bit(FLG_TWO_DCHAN, &cs->HW_Flags);
#endif
cs->protocol = card->protocol;
if (card->typ <= 0 || card->typ > ISDN_CTYPE_COUNT) {
printk(KERN_WARNING
"HiSax: Card Type %d out of range\n", card->typ);
goto outf_cs; goto outf_cs;
} }
if (!ret) { if (!(cs->dlog = kmalloc(MAX_DLOG_SPACE, GFP_ATOMIC))) {
ll_unload(cs); printk(KERN_WARNING
"HiSax: No memory for dlog(card %d)\n", cardnr + 1);
goto outf_cs; goto outf_cs;
} }
if (!(cs->status_buf = kmalloc(HISAX_STATUS_BUFSIZE, GFP_ATOMIC))) {
printk(KERN_WARNING
"HiSax: No memory for status_buf(card %d)\n",
cardnr + 1);
goto outf_dlog;
}
cs->stlist = NULL;
cs->status_read = cs->status_buf;
cs->status_write = cs->status_buf;
cs->status_end = cs->status_buf + HISAX_STATUS_BUFSIZE - 1;
cs->typ = card->typ;
#ifdef MODULE
cs->iif.owner = lockowner;
#endif
strcpy(cs->iif.id, id);
cs->iif.channels = 2;
cs->iif.maxbufsize = MAX_DATA_SIZE;
cs->iif.hl_hdrlen = MAX_HEADER_LEN;
cs->iif.features =
ISDN_FEATURE_L2_X75I |
ISDN_FEATURE_L2_HDLC |
ISDN_FEATURE_L2_HDLC_56K |
ISDN_FEATURE_L2_TRANS |
ISDN_FEATURE_L3_TRANS |
#ifdef CONFIG_HISAX_1TR6
ISDN_FEATURE_P_1TR6 |
#endif
#ifdef CONFIG_HISAX_EURO
ISDN_FEATURE_P_EURO |
#endif
#ifdef CONFIG_HISAX_NI1
ISDN_FEATURE_P_NI1 |
#endif
0;
cs->iif.command = HiSax_command;
cs->iif.writecmd = NULL;
cs->iif.writebuf_skb = HiSax_writebuf_skb;
cs->iif.readstat = HiSax_readstatus;
register_isdn(&cs->iif);
cs->myid = cs->iif.channels;
*cs_out = cs;
return 1; /* success */
outf_dlog:
kfree(cs->dlog);
outf_cs:
kfree(cs);
card->cs = NULL;
out:
return 0; /* error */
}
static int hisax_cs_setup(int cardnr, struct IsdnCard *card,
struct IsdnCardState *cs)
{
int ret;
if (!(cs->rcvbuf = kmalloc(MAX_DFRAME_LEN_L1, GFP_ATOMIC))) { if (!(cs->rcvbuf = kmalloc(MAX_DFRAME_LEN_L1, GFP_ATOMIC))) {
printk(KERN_WARNING "HiSax: No memory for isac rcvbuf\n"); printk(KERN_WARNING "HiSax: No memory for isac rcvbuf\n");
ll_unload(cs); ll_unload(cs);
@ -1143,11 +1160,41 @@ static int checkcard(int cardnr, char *id, int *busy_flag, struct module *lockow
if (!test_bit(HW_ISAR, &cs->HW_Flags)) if (!test_bit(HW_ISAR, &cs->HW_Flags))
ll_run(cs, 0); ll_run(cs, 0);
ret = 1; return 1;
outf_cs:
kfree(cs);
card->cs = NULL;
return ret;
}
static int checkcard(int cardnr, char *id, int *busy_flag, struct module *lockowner)
{
int ret;
struct IsdnCard *card = cards + cardnr;
struct IsdnCardState *cs;
ret = hisax_cs_new(cardnr, id, card, &cs, busy_flag, lockowner);
if (!ret)
return 0;
printk(KERN_INFO
"HiSax: Card %d Protocol %s Id=%s (%d)\n", cardnr + 1,
(card->protocol == ISDN_PTYPE_1TR6) ? "1TR6" :
(card->protocol == ISDN_PTYPE_EURO) ? "EDSS1" :
(card->protocol == ISDN_PTYPE_LEASED) ? "LEASED" :
(card->protocol == ISDN_PTYPE_NI1) ? "NI1" :
"NONE", cs->iif.id, cs->myid);
ret = hisax_cs_setup_card(card);
if (!ret) {
ll_unload(cs);
goto outf_cs;
}
ret = hisax_cs_setup(cardnr, card, cs);
goto out; goto out;
outf_dlog:
kfree(cs->dlog);
outf_cs: outf_cs:
kfree(cs); kfree(cs);
card->cs = NULL; card->cs = NULL;

View file

@ -300,98 +300,72 @@ enpci_interrupt(int intno, void *dev_id)
return IRQ_HANDLED; return IRQ_HANDLED;
} }
static int __devinit en_pci_probe(struct pci_dev *dev_netjet,
static struct pci_dev *dev_netjet __devinitdata = NULL; struct IsdnCardState *cs)
/* called by config.c */
int __devinit
setup_enternow_pci(struct IsdnCard *card)
{ {
int bytecnt; if (pci_enable_device(dev_netjet))
struct IsdnCardState *cs = card->cs; return(0);
char tmp[64]; cs->irq = dev_netjet->irq;
if (!cs->irq) {
#ifdef CONFIG_PCI printk(KERN_WARNING "enter:now PCI: No IRQ for PCI card found\n");
#ifdef __BIG_ENDIAN return(0);
#error "not running on big endian machines now" }
#endif cs->hw.njet.base = pci_resource_start(dev_netjet, 0);
strcpy(tmp, enternow_pci_rev); if (!cs->hw.njet.base) {
printk(KERN_INFO "HiSax: Formula-n Europe AG enter:now ISDN PCI driver Rev. %s\n", HiSax_getrev(tmp)); printk(KERN_WARNING "enter:now PCI: No IO-Adr for PCI card found\n");
if (cs->typ != ISDN_CTYPE_ENTERNOW) return(0);
}
/* checks Sub-Vendor ID because system crashes with Traverse-Card */
if ((dev_netjet->subsystem_vendor != 0x55) ||
(dev_netjet->subsystem_device != 0x02)) {
printk(KERN_WARNING "enter:now: You tried to load this driver with an incompatible TigerJet-card\n");
printk(KERN_WARNING "Use type=20 for Traverse NetJet PCI Card.\n");
return(0); return(0);
test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags);
for ( ;; )
{
if ((dev_netjet = pci_find_device(PCI_VENDOR_ID_TIGERJET,
PCI_DEVICE_ID_TIGERJET_300, dev_netjet))) {
if (pci_enable_device(dev_netjet))
return(0);
cs->irq = dev_netjet->irq;
if (!cs->irq) {
printk(KERN_WARNING "enter:now PCI: No IRQ for PCI card found\n");
return(0);
}
cs->hw.njet.base = pci_resource_start(dev_netjet, 0);
if (!cs->hw.njet.base) {
printk(KERN_WARNING "enter:now PCI: No IO-Adr for PCI card found\n");
return(0);
}
/* checks Sub-Vendor ID because system crashes with Traverse-Card */
if ((dev_netjet->subsystem_vendor != 0x55) ||
(dev_netjet->subsystem_device != 0x02)) {
printk(KERN_WARNING "enter:now: You tried to load this driver with an incompatible TigerJet-card\n");
printk(KERN_WARNING "Use type=20 for Traverse NetJet PCI Card.\n");
return(0);
}
} else {
printk(KERN_WARNING "enter:now PCI: No PCI card found\n");
return(0);
}
cs->hw.njet.auxa = cs->hw.njet.base + NETJET_AUXDATA;
cs->hw.njet.isac = cs->hw.njet.base + 0xC0; // Fenster zum AMD
/* Reset an */
cs->hw.njet.ctrl_reg = 0x07; // geändert von 0xff
outb(cs->hw.njet.ctrl_reg, cs->hw.njet.base + NETJET_CTRL);
/* 20 ms Pause */
mdelay(20);
cs->hw.njet.ctrl_reg = 0x30; /* Reset Off and status read clear */
outb(cs->hw.njet.ctrl_reg, cs->hw.njet.base + NETJET_CTRL);
mdelay(10);
cs->hw.njet.auxd = 0x00; // war 0xc0
cs->hw.njet.dmactrl = 0;
outb(~TJ_AMD_IRQ, cs->hw.njet.base + NETJET_AUXCTRL);
outb(TJ_AMD_IRQ, cs->hw.njet.base + NETJET_IRQMASK1);
outb(cs->hw.njet.auxd, cs->hw.njet.auxa);
break;
} }
#else
printk(KERN_WARNING "enter:now PCI: NO_PCI_BIOS\n"); return(1);
printk(KERN_WARNING "enter:now PCI: unable to config Formula-n enter:now ISDN PCI ab\n"); }
return (0);
#endif /* CONFIG_PCI */ static void __devinit en_cs_init(struct IsdnCard *card,
struct IsdnCardState *cs)
{
cs->hw.njet.auxa = cs->hw.njet.base + NETJET_AUXDATA;
cs->hw.njet.isac = cs->hw.njet.base + 0xC0; // Fenster zum AMD
bytecnt = 256; /* Reset an */
cs->hw.njet.ctrl_reg = 0x07; // geändert von 0xff
outb(cs->hw.njet.ctrl_reg, cs->hw.njet.base + NETJET_CTRL);
/* 20 ms Pause */
mdelay(20);
cs->hw.njet.ctrl_reg = 0x30; /* Reset Off and status read clear */
outb(cs->hw.njet.ctrl_reg, cs->hw.njet.base + NETJET_CTRL);
mdelay(10);
cs->hw.njet.auxd = 0x00; // war 0xc0
cs->hw.njet.dmactrl = 0;
outb(~TJ_AMD_IRQ, cs->hw.njet.base + NETJET_AUXCTRL);
outb(TJ_AMD_IRQ, cs->hw.njet.base + NETJET_IRQMASK1);
outb(cs->hw.njet.auxd, cs->hw.njet.auxa);
}
static int __devinit en_cs_init_rest(struct IsdnCard *card,
struct IsdnCardState *cs)
{
const int bytecnt = 256;
printk(KERN_INFO printk(KERN_INFO
"enter:now PCI: PCI card configured at 0x%lx IRQ %d\n", "enter:now PCI: PCI card configured at 0x%lx IRQ %d\n",
cs->hw.njet.base, cs->irq); cs->hw.njet.base, cs->irq);
if (!request_region(cs->hw.njet.base, bytecnt, "Fn_ISDN")) { if (!request_region(cs->hw.njet.base, bytecnt, "Fn_ISDN")) {
printk(KERN_WARNING printk(KERN_WARNING
"HiSax: %s config port %lx-%lx already in use\n", "HiSax: enter:now config port %lx-%lx already in use\n",
CardType[card->typ], cs->hw.njet.base,
cs->hw.njet.base, cs->hw.njet.base + bytecnt);
cs->hw.njet.base + bytecnt);
return (0); return (0);
} }
setup_Amd7930(cs); setup_Amd7930(cs);
cs->hw.njet.last_is0 = 0; cs->hw.njet.last_is0 = 0;
/* macro rByteAMD */ /* macro rByteAMD */
@ -407,5 +381,44 @@ setup_enternow_pci(struct IsdnCard *card)
cs->irq_func = &enpci_interrupt; cs->irq_func = &enpci_interrupt;
cs->irq_flags |= IRQF_SHARED; cs->irq_flags |= IRQF_SHARED;
return (1); return (1);
}
static struct pci_dev *dev_netjet __devinitdata = NULL;
/* called by config.c */
int __devinit
setup_enternow_pci(struct IsdnCard *card)
{
int ret;
struct IsdnCardState *cs = card->cs;
char tmp[64];
#ifdef __BIG_ENDIAN
#error "not running on big endian machines now"
#endif
strcpy(tmp, enternow_pci_rev);
printk(KERN_INFO "HiSax: Formula-n Europe AG enter:now ISDN PCI driver Rev. %s\n", HiSax_getrev(tmp));
if (cs->typ != ISDN_CTYPE_ENTERNOW)
return(0);
test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags);
for ( ;; )
{
if ((dev_netjet = pci_find_device(PCI_VENDOR_ID_TIGERJET,
PCI_DEVICE_ID_TIGERJET_300, dev_netjet))) {
ret = en_pci_probe(dev_netjet, cs);
if (!ret)
return(0);
} else {
printk(KERN_WARNING "enter:now PCI: No PCI card found\n");
return(0);
}
en_cs_init(card, cs);
break;
}
return en_cs_init_rest(card, cs);
} }

View file

@ -6,7 +6,7 @@
* based on existing driver for CCD hfc ISA cards * based on existing driver for CCD hfc ISA cards
* Copyright by Werner Cornelius <werner@isdn4linux.de> * Copyright by Werner Cornelius <werner@isdn4linux.de>
* by Karsten Keil <keil@isdn4linux.de> * by Karsten Keil <keil@isdn4linux.de>
* *
* This software may be used and distributed according to the terms * This software may be used and distributed according to the terms
* of the GNU General Public License, incorporated herein by reference. * of the GNU General Public License, incorporated herein by reference.
* *
@ -67,8 +67,6 @@ static const PCI_ENTRY id_list[] =
}; };
#ifdef CONFIG_PCI
/******************************************/ /******************************************/
/* free hardware resources used by driver */ /* free hardware resources used by driver */
/******************************************/ /******************************************/
@ -237,7 +235,7 @@ static void hfcpci_clear_fifo_rx(struct IsdnCardState *cs, int fifo)
if (fifo_state) if (fifo_state)
cs->hw.hfcpci.fifo_en |= fifo_state; cs->hw.hfcpci.fifo_en |= fifo_state;
Write_hfc(cs, HFCPCI_FIFO_EN, cs->hw.hfcpci.fifo_en); Write_hfc(cs, HFCPCI_FIFO_EN, cs->hw.hfcpci.fifo_en);
} }
/***************************************/ /***************************************/
/* clear the desired B-channel tx fifo */ /* clear the desired B-channel tx fifo */
@ -263,7 +261,7 @@ static void hfcpci_clear_fifo_tx(struct IsdnCardState *cs, int fifo)
if (fifo_state) if (fifo_state)
cs->hw.hfcpci.fifo_en |= fifo_state; cs->hw.hfcpci.fifo_en |= fifo_state;
Write_hfc(cs, HFCPCI_FIFO_EN, cs->hw.hfcpci.fifo_en); Write_hfc(cs, HFCPCI_FIFO_EN, cs->hw.hfcpci.fifo_en);
} }
/*********************************************/ /*********************************************/
/* read a complete B-frame out of the buffer */ /* read a complete B-frame out of the buffer */
@ -511,7 +509,6 @@ main_rec_hfcpci(struct BCState *bcs)
test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags); test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags);
if (count && receive) if (count && receive)
goto Begin; goto Begin;
return;
} }
/**************************/ /**************************/
@ -582,7 +579,6 @@ hfcpci_fill_dfifo(struct IsdnCardState *cs)
dev_kfree_skb_any(cs->tx_skb); dev_kfree_skb_any(cs->tx_skb);
cs->tx_skb = NULL; cs->tx_skb = NULL;
return;
} }
/**************************/ /**************************/
@ -729,7 +725,6 @@ hfcpci_fill_fifo(struct BCState *bcs)
dev_kfree_skb_any(bcs->tx_skb); dev_kfree_skb_any(bcs->tx_skb);
bcs->tx_skb = NULL; bcs->tx_skb = NULL;
test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag); test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag);
return;
} }
/**********************************************/ /**********************************************/
@ -924,7 +919,6 @@ receive_emsg(struct IsdnCardState *cs)
test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags); test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags);
if (count && receive) if (count && receive)
goto Begin; goto Begin;
return;
} /* receive_emsg */ } /* receive_emsg */
/*********************/ /*********************/
@ -1350,13 +1344,13 @@ mode_hfcpci(struct BCState *bcs, int mode, int bc)
cs->hw.hfcpci.sctrl_r |= SCTRL_B1_ENA; cs->hw.hfcpci.sctrl_r |= SCTRL_B1_ENA;
} }
if (fifo2) { if (fifo2) {
cs->hw.hfcpci.last_bfifo_cnt[1] = 0; cs->hw.hfcpci.last_bfifo_cnt[1] = 0;
cs->hw.hfcpci.fifo_en |= HFCPCI_FIFOEN_B2; cs->hw.hfcpci.fifo_en |= HFCPCI_FIFOEN_B2;
cs->hw.hfcpci.int_m1 |= (HFCPCI_INTS_B2TRANS + HFCPCI_INTS_B2REC); cs->hw.hfcpci.int_m1 |= (HFCPCI_INTS_B2TRANS + HFCPCI_INTS_B2REC);
cs->hw.hfcpci.ctmt &= ~2; cs->hw.hfcpci.ctmt &= ~2;
cs->hw.hfcpci.conn &= ~0x18; cs->hw.hfcpci.conn &= ~0x18;
} else { } else {
cs->hw.hfcpci.last_bfifo_cnt[0] = 0; cs->hw.hfcpci.last_bfifo_cnt[0] = 0;
cs->hw.hfcpci.fifo_en |= HFCPCI_FIFOEN_B1; cs->hw.hfcpci.fifo_en |= HFCPCI_FIFOEN_B1;
cs->hw.hfcpci.int_m1 |= (HFCPCI_INTS_B1TRANS + HFCPCI_INTS_B1REC); cs->hw.hfcpci.int_m1 |= (HFCPCI_INTS_B1TRANS + HFCPCI_INTS_B1REC);
cs->hw.hfcpci.ctmt &= ~1; cs->hw.hfcpci.ctmt &= ~1;
@ -1642,8 +1636,6 @@ hfcpci_card_msg(struct IsdnCardState *cs, int mt, void *arg)
/* this variable is used as card index when more than one cards are present */ /* this variable is used as card index when more than one cards are present */
static struct pci_dev *dev_hfcpci __devinitdata = NULL; static struct pci_dev *dev_hfcpci __devinitdata = NULL;
#endif /* CONFIG_PCI */
int __devinit int __devinit
setup_hfcpci(struct IsdnCard *card) setup_hfcpci(struct IsdnCard *card)
{ {
@ -1656,96 +1648,99 @@ setup_hfcpci(struct IsdnCard *card)
#ifdef __BIG_ENDIAN #ifdef __BIG_ENDIAN
#error "not running on big endian machines now" #error "not running on big endian machines now"
#endif #endif
strcpy(tmp, hfcpci_revision); strcpy(tmp, hfcpci_revision);
printk(KERN_INFO "HiSax: HFC-PCI driver Rev. %s\n", HiSax_getrev(tmp)); printk(KERN_INFO "HiSax: HFC-PCI driver Rev. %s\n", HiSax_getrev(tmp));
#ifdef CONFIG_PCI
cs->hw.hfcpci.int_s1 = 0; cs->hw.hfcpci.int_s1 = 0;
cs->dc.hfcpci.ph_state = 0; cs->dc.hfcpci.ph_state = 0;
cs->hw.hfcpci.fifo = 255; cs->hw.hfcpci.fifo = 255;
if (cs->typ == ISDN_CTYPE_HFC_PCI) { if (cs->typ != ISDN_CTYPE_HFC_PCI)
i = 0; return(0);
while (id_list[i].vendor_id) {
tmp_hfcpci = pci_find_device(id_list[i].vendor_id,
id_list[i].device_id,
dev_hfcpci);
i++;
if (tmp_hfcpci) {
if (pci_enable_device(tmp_hfcpci))
continue;
pci_set_master(tmp_hfcpci);
if ((card->para[0]) && (card->para[0] != (tmp_hfcpci->resource[ 0].start & PCI_BASE_ADDRESS_IO_MASK)))
continue;
else
break;
}
}
i = 0;
while (id_list[i].vendor_id) {
tmp_hfcpci = pci_find_device(id_list[i].vendor_id,
id_list[i].device_id,
dev_hfcpci);
i++;
if (tmp_hfcpci) { if (tmp_hfcpci) {
i--; if (pci_enable_device(tmp_hfcpci))
dev_hfcpci = tmp_hfcpci; /* old device */ continue;
cs->hw.hfcpci.dev = dev_hfcpci; pci_set_master(tmp_hfcpci);
cs->irq = dev_hfcpci->irq; if ((card->para[0]) && (card->para[0] != (tmp_hfcpci->resource[ 0].start & PCI_BASE_ADDRESS_IO_MASK)))
if (!cs->irq) { continue;
printk(KERN_WARNING "HFC-PCI: No IRQ for PCI card found\n"); else
return (0); break;
}
cs->hw.hfcpci.pci_io = (char *)(unsigned long)dev_hfcpci->resource[1].start;
printk(KERN_INFO "HiSax: HFC-PCI card manufacturer: %s card name: %s\n", id_list[i].vendor_name, id_list[i].card_name);
} else {
printk(KERN_WARNING "HFC-PCI: No PCI card found\n");
return (0);
} }
if (!cs->hw.hfcpci.pci_io) { }
printk(KERN_WARNING "HFC-PCI: No IO-Mem for PCI card found\n");
return (0); if (!tmp_hfcpci) {
} printk(KERN_WARNING "HFC-PCI: No PCI card found\n");
/* Allocate memory for FIFOS */ return (0);
/* Because the HFC-PCI needs a 32K physical alignment, we */ }
/* need to allocate the double mem and align the address */
if (!(cs->hw.hfcpci.share_start = kmalloc(65536, GFP_KERNEL))) { i--;
printk(KERN_WARNING "HFC-PCI: Error allocating memory for FIFO!\n"); dev_hfcpci = tmp_hfcpci; /* old device */
return 0; cs->hw.hfcpci.dev = dev_hfcpci;
} cs->irq = dev_hfcpci->irq;
cs->hw.hfcpci.fifos = (void *) if (!cs->irq) {
(((ulong) cs->hw.hfcpci.share_start) & ~0x7FFF) + 0x8000; printk(KERN_WARNING "HFC-PCI: No IRQ for PCI card found\n");
pci_write_config_dword(cs->hw.hfcpci.dev, 0x80, (u_int) virt_to_bus(cs->hw.hfcpci.fifos)); return (0);
cs->hw.hfcpci.pci_io = ioremap((ulong) cs->hw.hfcpci.pci_io, 256); }
printk(KERN_INFO cs->hw.hfcpci.pci_io = (char *)(unsigned long)dev_hfcpci->resource[1].start;
"HFC-PCI: defined at mem %p fifo %p(%#x) IRQ %d HZ %d\n", printk(KERN_INFO "HiSax: HFC-PCI card manufacturer: %s card name: %s\n", id_list[i].vendor_name, id_list[i].card_name);
cs->hw.hfcpci.pci_io,
cs->hw.hfcpci.fifos, if (!cs->hw.hfcpci.pci_io) {
(u_int) virt_to_bus(cs->hw.hfcpci.fifos), printk(KERN_WARNING "HFC-PCI: No IO-Mem for PCI card found\n");
cs->irq, HZ); return (0);
spin_lock_irqsave(&cs->lock, flags); }
pci_write_config_word(cs->hw.hfcpci.dev, PCI_COMMAND, PCI_ENA_MEMIO); /* enable memory mapped ports, disable busmaster */ /* Allocate memory for FIFOS */
cs->hw.hfcpci.int_m2 = 0; /* disable alle interrupts */ /* Because the HFC-PCI needs a 32K physical alignment, we */
cs->hw.hfcpci.int_m1 = 0; /* need to allocate the double mem and align the address */
Write_hfc(cs, HFCPCI_INT_M1, cs->hw.hfcpci.int_m1); if (!(cs->hw.hfcpci.share_start = kmalloc(65536, GFP_KERNEL))) {
Write_hfc(cs, HFCPCI_INT_M2, cs->hw.hfcpci.int_m2); printk(KERN_WARNING "HFC-PCI: Error allocating memory for FIFO!\n");
/* At this point the needed PCI config is done */ return 0;
/* fifos are still not enabled */ }
INIT_WORK(&cs->tqueue, hfcpci_bh); cs->hw.hfcpci.fifos = (void *)
cs->setstack_d = setstack_hfcpci; (((ulong) cs->hw.hfcpci.share_start) & ~0x7FFF) + 0x8000;
cs->BC_Send_Data = &hfcpci_send_data; pci_write_config_dword(cs->hw.hfcpci.dev, 0x80, (u_int) virt_to_bus(cs->hw.hfcpci.fifos));
cs->readisac = NULL; cs->hw.hfcpci.pci_io = ioremap((ulong) cs->hw.hfcpci.pci_io, 256);
cs->writeisac = NULL; printk(KERN_INFO
cs->readisacfifo = NULL; "HFC-PCI: defined at mem %p fifo %p(%#x) IRQ %d HZ %d\n",
cs->writeisacfifo = NULL; cs->hw.hfcpci.pci_io,
cs->BC_Read_Reg = NULL; cs->hw.hfcpci.fifos,
cs->BC_Write_Reg = NULL; (u_int) virt_to_bus(cs->hw.hfcpci.fifos),
cs->irq_func = &hfcpci_interrupt; cs->irq, HZ);
cs->irq_flags |= IRQF_SHARED;
cs->hw.hfcpci.timer.function = (void *) hfcpci_Timer; spin_lock_irqsave(&cs->lock, flags);
cs->hw.hfcpci.timer.data = (long) cs;
init_timer(&cs->hw.hfcpci.timer); pci_write_config_word(cs->hw.hfcpci.dev, PCI_COMMAND, PCI_ENA_MEMIO); /* enable memory mapped ports, disable busmaster */
cs->cardmsg = &hfcpci_card_msg; cs->hw.hfcpci.int_m2 = 0; /* disable alle interrupts */
cs->auxcmd = &hfcpci_auxcmd; cs->hw.hfcpci.int_m1 = 0;
spin_unlock_irqrestore(&cs->lock, flags); Write_hfc(cs, HFCPCI_INT_M1, cs->hw.hfcpci.int_m1);
return (1); Write_hfc(cs, HFCPCI_INT_M2, cs->hw.hfcpci.int_m2);
} else /* At this point the needed PCI config is done */
return (0); /* no valid card type */ /* fifos are still not enabled */
#else
printk(KERN_WARNING "HFC-PCI: NO_PCI_BIOS\n"); INIT_WORK(&cs->tqueue, hfcpci_bh);
return (0); cs->setstack_d = setstack_hfcpci;
#endif /* CONFIG_PCI */ cs->BC_Send_Data = &hfcpci_send_data;
cs->readisac = NULL;
cs->writeisac = NULL;
cs->readisacfifo = NULL;
cs->writeisacfifo = NULL;
cs->BC_Read_Reg = NULL;
cs->BC_Write_Reg = NULL;
cs->irq_func = &hfcpci_interrupt;
cs->irq_flags |= IRQF_SHARED;
cs->hw.hfcpci.timer.function = (void *) hfcpci_Timer;
cs->hw.hfcpci.timer.data = (long) cs;
init_timer(&cs->hw.hfcpci.timer);
cs->cardmsg = &hfcpci_card_msg;
cs->auxcmd = &hfcpci_auxcmd;
spin_unlock_irqrestore(&cs->lock, flags);
return (1);
} }

View file

@ -148,107 +148,87 @@ NETjet_S_card_msg(struct IsdnCardState *cs, int mt, void *arg)
return(0); return(0);
} }
static struct pci_dev *dev_netjet __devinitdata = NULL; static int __devinit njs_pci_probe(struct pci_dev *dev_netjet,
struct IsdnCardState *cs)
int __devinit
setup_netjet_s(struct IsdnCard *card)
{ {
int bytecnt,cfg; int cfg;
struct IsdnCardState *cs = card->cs;
char tmp[64];
#ifdef __BIG_ENDIAN if (pci_enable_device(dev_netjet))
#error "not running on big endian machines now" return(0);
#endif pci_set_master(dev_netjet);
strcpy(tmp, NETjet_S_revision); cs->irq = dev_netjet->irq;
printk(KERN_INFO "HiSax: Traverse Tech. NETjet-S driver Rev. %s\n", HiSax_getrev(tmp)); if (!cs->irq) {
if (cs->typ != ISDN_CTYPE_NETJET_S) printk(KERN_WARNING "NETjet-S: No IRQ for PCI card found\n");
return(0); return(0);
test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags);
#ifdef CONFIG_PCI
for ( ;; )
{
if ((dev_netjet = pci_find_device(PCI_VENDOR_ID_TIGERJET,
PCI_DEVICE_ID_TIGERJET_300, dev_netjet))) {
if (pci_enable_device(dev_netjet))
return(0);
pci_set_master(dev_netjet);
cs->irq = dev_netjet->irq;
if (!cs->irq) {
printk(KERN_WARNING "NETjet-S: No IRQ for PCI card found\n");
return(0);
}
cs->hw.njet.base = pci_resource_start(dev_netjet, 0);
if (!cs->hw.njet.base) {
printk(KERN_WARNING "NETjet-S: No IO-Adr for PCI card found\n");
return(0);
}
/* the TJ300 and TJ320 must be detected, the IRQ handling is different
* unfortunatly the chips use the same device ID, but the TJ320 has
* the bit20 in status PCI cfg register set
*/
pci_read_config_dword(dev_netjet, 0x04, &cfg);
if (cfg & 0x00100000)
cs->subtyp = 1; /* TJ320 */
else
cs->subtyp = 0; /* TJ300 */
/* 2001/10/04 Christoph Ersfeld, Formula-n Europe AG www.formula-n.com */
if ((dev_netjet->subsystem_vendor == 0x55) &&
(dev_netjet->subsystem_device == 0x02)) {
printk(KERN_WARNING "Netjet: You tried to load this driver with an incompatible TigerJet-card\n");
printk(KERN_WARNING "Use type=41 for Formula-n enter:now ISDN PCI and compatible\n");
return(0);
}
/* end new code */
} else {
printk(KERN_WARNING "NETjet-S: No PCI card found\n");
return(0);
}
cs->hw.njet.auxa = cs->hw.njet.base + NETJET_AUXDATA;
cs->hw.njet.isac = cs->hw.njet.base | NETJET_ISAC_OFF;
cs->hw.njet.ctrl_reg = 0xff; /* Reset On */
byteout(cs->hw.njet.base + NETJET_CTRL, cs->hw.njet.ctrl_reg);
mdelay(10);
cs->hw.njet.ctrl_reg = 0x00; /* Reset Off and status read clear */
byteout(cs->hw.njet.base + NETJET_CTRL, cs->hw.njet.ctrl_reg);
mdelay(10);
cs->hw.njet.auxd = 0xC0;
cs->hw.njet.dmactrl = 0;
byteout(cs->hw.njet.base + NETJET_AUXCTRL, ~NETJET_ISACIRQ);
byteout(cs->hw.njet.base + NETJET_IRQMASK1, NETJET_ISACIRQ);
byteout(cs->hw.njet.auxa, cs->hw.njet.auxd);
switch ( ( ( NETjet_ReadIC( cs, ISAC_RBCH ) >> 5 ) & 3 ) )
{
case 0 :
break;
case 3 :
printk( KERN_WARNING "NETjet-S: NETspider-U PCI card found\n" );
continue;
default :
printk( KERN_WARNING "NETjet-S: No PCI card found\n" );
return 0;
}
break;
} }
#else cs->hw.njet.base = pci_resource_start(dev_netjet, 0);
if (!cs->hw.njet.base) {
printk(KERN_WARNING "NETjet-S: No IO-Adr for PCI card found\n");
return(0);
}
/* the TJ300 and TJ320 must be detected, the IRQ handling is different
* unfortunatly the chips use the same device ID, but the TJ320 has
* the bit20 in status PCI cfg register set
*/
pci_read_config_dword(dev_netjet, 0x04, &cfg);
if (cfg & 0x00100000)
cs->subtyp = 1; /* TJ320 */
else
cs->subtyp = 0; /* TJ300 */
/* 2001/10/04 Christoph Ersfeld, Formula-n Europe AG www.formula-n.com */
if ((dev_netjet->subsystem_vendor == 0x55) &&
(dev_netjet->subsystem_device == 0x02)) {
printk(KERN_WARNING "Netjet: You tried to load this driver with an incompatible TigerJet-card\n");
printk(KERN_WARNING "Use type=41 for Formula-n enter:now ISDN PCI and compatible\n");
return(0);
}
/* end new code */
printk(KERN_WARNING "NETjet-S: NO_PCI_BIOS\n"); return(1);
printk(KERN_WARNING "NETjet-S: unable to config NETJET-S PCI\n"); }
return (0);
#endif /* CONFIG_PCI */ static int __devinit njs_cs_init(struct IsdnCard *card,
struct IsdnCardState *cs)
{
bytecnt = 256; cs->hw.njet.auxa = cs->hw.njet.base + NETJET_AUXDATA;
cs->hw.njet.isac = cs->hw.njet.base | NETJET_ISAC_OFF;
cs->hw.njet.ctrl_reg = 0xff; /* Reset On */
byteout(cs->hw.njet.base + NETJET_CTRL, cs->hw.njet.ctrl_reg);
mdelay(10);
cs->hw.njet.ctrl_reg = 0x00; /* Reset Off and status read clear */
byteout(cs->hw.njet.base + NETJET_CTRL, cs->hw.njet.ctrl_reg);
mdelay(10);
cs->hw.njet.auxd = 0xC0;
cs->hw.njet.dmactrl = 0;
byteout(cs->hw.njet.base + NETJET_AUXCTRL, ~NETJET_ISACIRQ);
byteout(cs->hw.njet.base + NETJET_IRQMASK1, NETJET_ISACIRQ);
byteout(cs->hw.njet.auxa, cs->hw.njet.auxd);
switch ( ( ( NETjet_ReadIC( cs, ISAC_RBCH ) >> 5 ) & 3 ) )
{
case 0 :
return 1; /* end loop */
case 3 :
printk( KERN_WARNING "NETjet-S: NETspider-U PCI card found\n" );
return -1; /* continue looping */
default :
printk( KERN_WARNING "NETjet-S: No PCI card found\n" );
return 0; /* end loop & function */
}
return 1; /* end loop */
}
static int __devinit njs_cs_init_rest(struct IsdnCard *card,
struct IsdnCardState *cs)
{
const int bytecnt = 256;
printk(KERN_INFO printk(KERN_INFO
"NETjet-S: %s card configured at %#lx IRQ %d\n", "NETjet-S: %s card configured at %#lx IRQ %d\n",
@ -273,5 +253,47 @@ setup_netjet_s(struct IsdnCard *card)
cs->irq_func = &netjet_s_interrupt; cs->irq_func = &netjet_s_interrupt;
cs->irq_flags |= IRQF_SHARED; cs->irq_flags |= IRQF_SHARED;
ISACVersion(cs, "NETjet-S:"); ISACVersion(cs, "NETjet-S:");
return (1); return (1);
} }
static struct pci_dev *dev_netjet __devinitdata = NULL;
int __devinit
setup_netjet_s(struct IsdnCard *card)
{
int ret;
struct IsdnCardState *cs = card->cs;
char tmp[64];
#ifdef __BIG_ENDIAN
#error "not running on big endian machines now"
#endif
strcpy(tmp, NETjet_S_revision);
printk(KERN_INFO "HiSax: Traverse Tech. NETjet-S driver Rev. %s\n", HiSax_getrev(tmp));
if (cs->typ != ISDN_CTYPE_NETJET_S)
return(0);
test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags);
for ( ;; )
{
if ((dev_netjet = pci_find_device(PCI_VENDOR_ID_TIGERJET,
PCI_DEVICE_ID_TIGERJET_300, dev_netjet))) {
ret = njs_pci_probe(dev_netjet, cs);
if (!ret)
return(0);
} else {
printk(KERN_WARNING "NETjet-S: No PCI card found\n");
return(0);
}
ret = njs_cs_init(card, cs);
if (!ret)
return(0);
if (ret > 0)
break;
/* otherwise, ret < 0, continue looping */
}
return njs_cs_init_rest(card, cs);
}

View file

@ -128,93 +128,69 @@ NETjet_U_card_msg(struct IsdnCardState *cs, int mt, void *arg)
return(0); return(0);
} }
static struct pci_dev *dev_netjet __devinitdata = NULL; static int __devinit nju_pci_probe(struct pci_dev *dev_netjet,
struct IsdnCardState *cs)
int __devinit
setup_netjet_u(struct IsdnCard *card)
{ {
int bytecnt; if (pci_enable_device(dev_netjet))
struct IsdnCardState *cs = card->cs; return(0);
char tmp[64]; pci_set_master(dev_netjet);
#ifdef CONFIG_PCI cs->irq = dev_netjet->irq;
#endif if (!cs->irq) {
#ifdef __BIG_ENDIAN printk(KERN_WARNING "NETspider-U: No IRQ for PCI card found\n");
#error "not running on big endian machines now" return(0);
#endif }
strcpy(tmp, NETjet_U_revision); cs->hw.njet.base = pci_resource_start(dev_netjet, 0);
printk(KERN_INFO "HiSax: Traverse Tech. NETspider-U driver Rev. %s\n", HiSax_getrev(tmp)); if (!cs->hw.njet.base) {
if (cs->typ != ISDN_CTYPE_NETJET_U) printk(KERN_WARNING "NETspider-U: No IO-Adr for PCI card found\n");
return(0); return(0);
test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags);
#ifdef CONFIG_PCI
for ( ;; )
{
if ((dev_netjet = pci_find_device(PCI_VENDOR_ID_TIGERJET,
PCI_DEVICE_ID_TIGERJET_300, dev_netjet))) {
if (pci_enable_device(dev_netjet))
return(0);
pci_set_master(dev_netjet);
cs->irq = dev_netjet->irq;
if (!cs->irq) {
printk(KERN_WARNING "NETspider-U: No IRQ for PCI card found\n");
return(0);
}
cs->hw.njet.base = pci_resource_start(dev_netjet, 0);
if (!cs->hw.njet.base) {
printk(KERN_WARNING "NETspider-U: No IO-Adr for PCI card found\n");
return(0);
}
} else {
printk(KERN_WARNING "NETspider-U: No PCI card found\n");
return(0);
}
cs->hw.njet.auxa = cs->hw.njet.base + NETJET_AUXDATA;
cs->hw.njet.isac = cs->hw.njet.base | NETJET_ISAC_OFF;
mdelay(10);
cs->hw.njet.ctrl_reg = 0xff; /* Reset On */
byteout(cs->hw.njet.base + NETJET_CTRL, cs->hw.njet.ctrl_reg);
mdelay(10);
cs->hw.njet.ctrl_reg = 0x00; /* Reset Off and status read clear */
byteout(cs->hw.njet.base + NETJET_CTRL, cs->hw.njet.ctrl_reg);
mdelay(10);
cs->hw.njet.auxd = 0xC0;
cs->hw.njet.dmactrl = 0;
byteout(cs->hw.njet.auxa, 0);
byteout(cs->hw.njet.base + NETJET_AUXCTRL, ~NETJET_ISACIRQ);
byteout(cs->hw.njet.base + NETJET_IRQMASK1, NETJET_ISACIRQ);
byteout(cs->hw.njet.auxa, cs->hw.njet.auxd);
switch ( ( ( NETjet_ReadIC( cs, ICC_RBCH ) >> 5 ) & 3 ) )
{
case 3 :
break;
case 0 :
printk( KERN_WARNING "NETspider-U: NETjet-S PCI card found\n" );
continue;
default :
printk( KERN_WARNING "NETspider-U: No PCI card found\n" );
return 0;
}
break;
} }
#else
printk(KERN_WARNING "NETspider-U: NO_PCI_BIOS\n"); return (1);
printk(KERN_WARNING "NETspider-U: unable to config NETspider-U PCI\n"); }
return (0);
#endif /* CONFIG_PCI */ static int __devinit nju_cs_init(struct IsdnCard *card,
struct IsdnCardState *cs)
{
cs->hw.njet.auxa = cs->hw.njet.base + NETJET_AUXDATA;
cs->hw.njet.isac = cs->hw.njet.base | NETJET_ISAC_OFF;
mdelay(10);
bytecnt = 256; cs->hw.njet.ctrl_reg = 0xff; /* Reset On */
byteout(cs->hw.njet.base + NETJET_CTRL, cs->hw.njet.ctrl_reg);
mdelay(10);
cs->hw.njet.ctrl_reg = 0x00; /* Reset Off and status read clear */
byteout(cs->hw.njet.base + NETJET_CTRL, cs->hw.njet.ctrl_reg);
mdelay(10);
cs->hw.njet.auxd = 0xC0;
cs->hw.njet.dmactrl = 0;
byteout(cs->hw.njet.auxa, 0);
byteout(cs->hw.njet.base + NETJET_AUXCTRL, ~NETJET_ISACIRQ);
byteout(cs->hw.njet.base + NETJET_IRQMASK1, NETJET_ISACIRQ);
byteout(cs->hw.njet.auxa, cs->hw.njet.auxd);
switch ( ( ( NETjet_ReadIC( cs, ICC_RBCH ) >> 5 ) & 3 ) )
{
case 3 :
return 1; /* end loop */
case 0 :
printk( KERN_WARNING "NETspider-U: NETjet-S PCI card found\n" );
return -1; /* continue looping */
default :
printk( KERN_WARNING "NETspider-U: No PCI card found\n" );
return 0; /* end loop & function */
}
return 1; /* end loop */
}
static int __devinit nju_cs_init_rest(struct IsdnCard *card,
struct IsdnCardState *cs)
{
const int bytecnt = 256;
printk(KERN_INFO printk(KERN_INFO
"NETspider-U: PCI card configured at %#lx IRQ %d\n", "NETspider-U: PCI card configured at %#lx IRQ %d\n",
@ -239,5 +215,48 @@ setup_netjet_u(struct IsdnCard *card)
cs->irq_func = &netjet_u_interrupt; cs->irq_func = &netjet_u_interrupt;
cs->irq_flags |= IRQF_SHARED; cs->irq_flags |= IRQF_SHARED;
ICCVersion(cs, "NETspider-U:"); ICCVersion(cs, "NETspider-U:");
return (1); return (1);
} }
static struct pci_dev *dev_netjet __devinitdata = NULL;
int __devinit
setup_netjet_u(struct IsdnCard *card)
{
int ret;
struct IsdnCardState *cs = card->cs;
char tmp[64];
#ifdef __BIG_ENDIAN
#error "not running on big endian machines now"
#endif
strcpy(tmp, NETjet_U_revision);
printk(KERN_INFO "HiSax: Traverse Tech. NETspider-U driver Rev. %s\n", HiSax_getrev(tmp));
if (cs->typ != ISDN_CTYPE_NETJET_U)
return(0);
test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags);
for ( ;; )
{
if ((dev_netjet = pci_find_device(PCI_VENDOR_ID_TIGERJET,
PCI_DEVICE_ID_TIGERJET_300, dev_netjet))) {
ret = nju_pci_probe(dev_netjet, cs);
if (!ret)
return(0);
} else {
printk(KERN_WARNING "NETspider-U: No PCI card found\n");
return(0);
}
ret = nju_cs_init(card, cs);
if (!ret)
return (0);
if (ret > 0)
break;
/* ret < 0 == continue looping */
}
return nju_cs_init_rest(card, cs);
}