fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / drivers / isdn / hisax / nj_s.c
index 5fd47f6..c09ffb1 100644 (file)
@@ -5,7 +5,6 @@
  *
  */
 
-#include <linux/config.h>
 #include <linux/init.h>
 #include "hisax.h"
 #include "isac.h"
@@ -15,7 +14,7 @@
 #include <linux/ppp_defs.h>
 #include "netjet.h"
 
-const char *NETjet_S_revision = "$Revision: 2.13.2.4 $";
+static const char *NETjet_S_revision = "$Revision: 2.13.2.4 $";
 
 static u_char dummyrr(struct IsdnCardState *cs, int chan, u_char off)
 {
@@ -27,7 +26,7 @@ static void dummywr(struct IsdnCardState *cs, int chan, u_char off, u_char value
 }
 
 static irqreturn_t
-netjet_s_interrupt(int intno, void *dev_id, struct pt_regs *regs)
+netjet_s_interrupt(int intno, void *dev_id)
 {
        struct IsdnCardState *cs = dev_id;
        u_char val, s1val, s0val;
@@ -104,9 +103,12 @@ reset_netjet_s(struct IsdnCardState *cs)
        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 */
        /* now edge triggered for TJ320 GE 13/07/00 */
        /* see comment in IRQ function */
+       if (cs->subtyp) /* TJ320 */
+               cs->hw.njet.ctrl_reg = 0x40;  /* Reset Off and status read clear */
+       else
+               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 = 0;
@@ -146,12 +148,12 @@ NETjet_S_card_msg(struct IsdnCardState *cs, int mt, void *arg)
        return(0);
 }
 
-static struct pci_dev *dev_netjet __initdata = NULL;
+static struct pci_dev *dev_netjet __devinitdata = NULL;
 
-int __init
+int __devinit
 setup_netjet_s(struct IsdnCard *card)
 {
-       int bytecnt;
+       int bytecnt,cfg;
        struct IsdnCardState *cs = card->cs;
        char tmp[64];
 
@@ -164,7 +166,7 @@ setup_netjet_s(struct IsdnCard *card)
                return(0);
        test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags);
 
-#if CONFIG_PCI
+#ifdef CONFIG_PCI
 
        for ( ;; )
        {
@@ -183,6 +185,15 @@ setup_netjet_s(struct IsdnCard *card)
                                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)) {
@@ -240,8 +251,8 @@ setup_netjet_s(struct IsdnCard *card)
        bytecnt = 256;
 
        printk(KERN_INFO
-               "NETjet-S: PCI card configured at %#lx IRQ %d\n",
-               cs->hw.njet.base, cs->irq);
+               "NETjet-S: %s card configured at %#lx IRQ %d\n",
+               cs->subtyp ? "TJ320" : "TJ300", cs->hw.njet.base, cs->irq);
        if (!request_region(cs->hw.njet.base, bytecnt, "netjet-s isdn")) {
                printk(KERN_WARNING
                       "HiSax: %s config port %#lx-%#lx already in use\n",
@@ -260,7 +271,7 @@ setup_netjet_s(struct IsdnCard *card)
        setup_isac(cs);
        cs->cardmsg = &NETjet_S_card_msg;
        cs->irq_func = &netjet_s_interrupt;
-       cs->irq_flags |= SA_SHIRQ;
+       cs->irq_flags |= IRQF_SHARED;
        ISACVersion(cs, "NETjet-S:");
        return (1);
 }