]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/isdn/hardware/mISDN/hfcmulti.c
mISDN: Cleanup hfc multiport driver
[linux-2.6-omap-h63xx.git] / drivers / isdn / hardware / mISDN / hfcmulti.c
index 1eac03f39d0005e0e75b75f3925e1924193e794b..ff5ec3cbeb775a6db7b38714795abd122fee661d 100644 (file)
  * #define HFC_REGISTER_DEBUG
  */
 
-static const char *hfcmulti_revision = "2.02";
+#define HFC_MULTI_VERSION      "2.03"
 
 #include <linux/module.h>
 #include <linux/pci.h>
@@ -165,15 +165,10 @@ static LIST_HEAD(HFClist);
 static spinlock_t HFClock; /* global hfc list lock */
 
 static void ph_state_change(struct dchannel *);
-static void (*hfc_interrupt)(void);
-static void (*register_interrupt)(void);
-static int (*unregister_interrupt)(void);
-static int interrupt_registered;
 
 static struct hfc_multi *syncmaster;
-int plxsd_master; /* if we have a master card (yet) */
+static int plxsd_master; /* if we have a master card (yet) */
 static spinlock_t plx_lock; /* may not acquire other lock inside */
-EXPORT_SYMBOL(plx_lock);
 
 #define        TYP_E1          1
 #define        TYP_4S          4
@@ -210,6 +205,7 @@ static int  HFC_cnt, Port_cnt, PCM_cnt = 99;
 
 MODULE_AUTHOR("Andreas Eversberg");
 MODULE_LICENSE("GPL");
+MODULE_VERSION(HFC_MULTI_VERSION);
 module_param(debug, uint, S_IRUGO | S_IWUSR);
 module_param(poll, uint, S_IRUGO | S_IWUSR);
 module_param(timer, uint, S_IRUGO | S_IWUSR);
@@ -422,7 +418,7 @@ HFC_wait_debug(struct hfc_multi *hc, const char *function, int line)
 #endif
 
 /* write fifo data (REGIO) */
-void
+static void
 write_fifo_regio(struct hfc_multi *hc, u_char *data, int len)
 {
        outb(A_FIFO_DATA0, (hc->pci_iobase)+4);
@@ -443,7 +439,7 @@ write_fifo_regio(struct hfc_multi *hc, u_char *data, int len)
        }
 }
 /* write fifo data (PCIMEM) */
-void
+static void
 write_fifo_pcimem(struct hfc_multi *hc, u_char *data, int len)
 {
        while (len>>2) {
@@ -465,7 +461,7 @@ write_fifo_pcimem(struct hfc_multi *hc, u_char *data, int len)
        }
 }
 /* read fifo data (REGIO) */
-void
+static void
 read_fifo_regio(struct hfc_multi *hc, u_char *data, int len)
 {
        outb(A_FIFO_DATA0, (hc->pci_iobase)+4);
@@ -487,7 +483,7 @@ read_fifo_regio(struct hfc_multi *hc, u_char *data, int len)
 }
 
 /* read fifo data (PCIMEM) */
-void
+static void
 read_fifo_pcimem(struct hfc_multi *hc, u_char *data, int len)
 {
        while (len>>2) {
@@ -706,7 +702,7 @@ vpm_out(struct hfc_multi *c, int which, unsigned short addr,
 }
 
 
-void
+static void
 vpm_init(struct hfc_multi *wc)
 {
        unsigned char reg;
@@ -789,7 +785,8 @@ vpm_init(struct hfc_multi *wc)
        }
 }
 
-void
+#ifdef UNUSED
+static void
 vpm_check(struct hfc_multi *hctmp)
 {
        unsigned char gpi2;
@@ -799,6 +796,7 @@ vpm_check(struct hfc_multi *hctmp)
        if ((gpi2 & 0x3) != 0x3)
                printk(KERN_DEBUG "Got interrupt 0x%x from VPM!\n", gpi2);
 }
+#endif /* UNUSED */
 
 
 /*
@@ -812,7 +810,7 @@ vpm_check(struct hfc_multi *hctmp)
  *
  */
 
-void
+static void
 vpm_echocan_on(struct hfc_multi *hc, int ch, int taps)
 {
        unsigned int timeslot;
@@ -844,7 +842,7 @@ vpm_echocan_on(struct hfc_multi *hc, int ch, int taps)
        vpm_out(hc, unit, timeslot, 0x7e);
 }
 
-void
+static void
 vpm_echocan_off(struct hfc_multi *hc, int ch)
 {
        unsigned int timeslot;
@@ -887,8 +885,9 @@ vpm_echocan_off(struct hfc_multi *hc, int ch)
 static inline void
 hfcmulti_resync(struct hfc_multi *locked, struct hfc_multi *newmaster, int rm)
 {
-       struct hfc_multi *hc, *next, *pcmmaster = 0;
-       u_int *plx_acc_32, pv;
+       struct hfc_multi *hc, *next, *pcmmaster = NULL;
+       void __iomem *plx_acc_32;
+       u_int pv;
        u_long flags;
 
        spin_lock_irqsave(&HFClock, flags);
@@ -916,7 +915,7 @@ hfcmulti_resync(struct hfc_multi *locked, struct hfc_multi *newmaster, int rm)
        /* Disable sync of all cards */
        list_for_each_entry_safe(hc, next, &HFClist, list) {
                if (test_bit(HFC_CHIP_PLXSD, &hc->chip)) {
-                       plx_acc_32 = (u_int *)(hc->plx_membase+PLX_GPIOC);
+                       plx_acc_32 = hc->plx_membase + PLX_GPIOC;
                        pv = readl(plx_acc_32);
                        pv &= ~PLX_SYNC_O_EN;
                        writel(pv, plx_acc_32);
@@ -938,7 +937,7 @@ hfcmulti_resync(struct hfc_multi *locked, struct hfc_multi *newmaster, int rm)
                        printk(KERN_DEBUG "id=%d (0x%p) = syncronized with "
                                "interface.\n", hc->id, hc);
                /* Enable new sync master */
-               plx_acc_32 = (u_int *)(hc->plx_membase+PLX_GPIOC);
+               plx_acc_32 = hc->plx_membase + PLX_GPIOC;
                pv = readl(plx_acc_32);
                pv |= PLX_SYNC_O_EN;
                writel(pv, plx_acc_32);
@@ -968,7 +967,7 @@ hfcmulti_resync(struct hfc_multi *locked, struct hfc_multi *newmaster, int rm)
                                            "QUARTZ is automatically "
                                            "enabled by HFC-%dS\n", hc->type);
                        }
-                       plx_acc_32 = (u_int *)(hc->plx_membase+PLX_GPIOC);
+                       plx_acc_32 = hc->plx_membase + PLX_GPIOC;
                        pv = readl(plx_acc_32);
                        pv |= PLX_SYNC_O_EN;
                        writel(pv, plx_acc_32);
@@ -1013,7 +1012,8 @@ plxsd_checksync(struct hfc_multi *hc, int rm)
 static void
 release_io_hfcmulti(struct hfc_multi *hc)
 {
-       u_int   *plx_acc_32, pv;
+       void __iomem *plx_acc_32;
+       u_int   pv;
        u_long  plx_flags;
 
        if (debug & DEBUG_HFCMULTI_INIT)
@@ -1033,7 +1033,7 @@ release_io_hfcmulti(struct hfc_multi *hc)
                        printk(KERN_DEBUG "%s: release PLXSD card %d\n",
                            __func__, hc->id + 1);
                spin_lock_irqsave(&plx_lock, plx_flags);
-               plx_acc_32 = (u_int *)(hc->plx_membase+PLX_GPIOC);
+               plx_acc_32 = hc->plx_membase + PLX_GPIOC;
                writel(PLX_GPIOC_INIT, plx_acc_32);
                pv = readl(plx_acc_32);
                /* Termination off */
@@ -1055,9 +1055,9 @@ release_io_hfcmulti(struct hfc_multi *hc)
        test_and_clear_bit(HFC_CHIP_PLXSD, &hc->chip); /* prevent resync */
        pci_write_config_word(hc->pci_dev, PCI_COMMAND, 0);
        if (hc->pci_membase)
-               iounmap((void *)hc->pci_membase);
+               iounmap(hc->pci_membase);
        if (hc->plx_membase)
-               iounmap((void *)hc->plx_membase);
+               iounmap(hc->plx_membase);
        if (hc->pci_iobase)
                release_region(hc->pci_iobase, 8);
 
@@ -1080,7 +1080,8 @@ init_chip(struct hfc_multi *hc)
        u_long                  flags, val, val2 = 0, rev;
        int                     i, err = 0;
        u_char                  r_conf_en, rval;
-       u_int                   *plx_acc_32, pv;
+       void __iomem            *plx_acc_32;
+       u_int                   pv;
        u_long                  plx_flags, hfc_flags;
        int                     plx_count;
        struct hfc_multi        *pos, *next, *plx_last_hc;
@@ -1154,7 +1155,7 @@ init_chip(struct hfc_multi *hc)
                        printk(KERN_DEBUG "%s: initializing PLXSD card %d\n",
                            __func__, hc->id + 1);
                spin_lock_irqsave(&plx_lock, plx_flags);
-               plx_acc_32 = (u_int *)(hc->plx_membase+PLX_GPIOC);
+               plx_acc_32 = hc->plx_membase + PLX_GPIOC;
                writel(PLX_GPIOC_INIT, plx_acc_32);
                pv = readl(plx_acc_32);
                /* The first and the last cards are terminating the PCM bus */
@@ -1190,8 +1191,7 @@ init_chip(struct hfc_multi *hc)
                                        "we disable termination\n",
                                    __func__, plx_last_hc->id + 1);
                        spin_lock_irqsave(&plx_lock, plx_flags);
-                       plx_acc_32 = (u_int *)(plx_last_hc->plx_membase
-                                       + PLX_GPIOC);
+                       plx_acc_32 = plx_last_hc->plx_membase + PLX_GPIOC;
                        pv = readl(plx_acc_32);
                        pv &= ~PLX_TERM_ON;
                        writel(pv, plx_acc_32);
@@ -1240,7 +1240,7 @@ init_chip(struct hfc_multi *hc)
        /* Speech Design PLX bridge pcm and sync mode */
        if (test_bit(HFC_CHIP_PLXSD, &hc->chip)) {
                spin_lock_irqsave(&plx_lock, plx_flags);
-               plx_acc_32 = (u_int *)(hc->plx_membase+PLX_GPIOC);
+               plx_acc_32 = hc->plx_membase + PLX_GPIOC;
                pv = readl(plx_acc_32);
                /* Connect PCM */
                if (hc->hw.r_pcm_md0 & V_PCM_MD) {
@@ -1352,8 +1352,7 @@ controller_fail:
                        /* retry with master clock */
                        if (test_bit(HFC_CHIP_PLXSD, &hc->chip)) {
                                spin_lock_irqsave(&plx_lock, plx_flags);
-                               plx_acc_32 = (u_int *)(hc->plx_membase +
-                                       PLX_GPIOC);
+                               plx_acc_32 = hc->plx_membase + PLX_GPIOC;
                                pv = readl(plx_acc_32);
                                pv |= PLX_MASTER_EN | PLX_SLAVE_EN_N;
                                pv |= PLX_SYNC_O_EN;
@@ -1389,7 +1388,7 @@ controller_fail:
                if (test_bit(HFC_CHIP_PCM_MASTER, &hc->chip))
                        plxsd_master = 1;
                spin_lock_irqsave(&plx_lock, plx_flags);
-               plx_acc_32 = (u_int *)(hc->plx_membase+PLX_GPIOC);
+               plx_acc_32 = hc->plx_membase + PLX_GPIOC;
                pv = readl(plx_acc_32);
                pv |=  PLX_DSP_RES_N;
                writel(pv, plx_acc_32);
@@ -1417,19 +1416,6 @@ controller_fail:
        HFC_outb(hc, R_TI_WD, poll_timer);
        hc->hw.r_irqmsk_misc |= V_TI_IRQMSK;
 
-       /*
-        * set up 125us interrupt, only if function pointer is available
-        * and module parameter timer is set
-        */
-       if (timer && hfc_interrupt && register_interrupt) {
-               /* only one chip should use this interrupt */
-               timer = 0;
-               interrupt_registered = 1;
-               hc->hw.r_irqmsk_misc |= V_PROC_IRQMSK;
-               /* deactivate other interrupts in ztdummy */
-               register_interrupt();
-       }
-
        /* set E1 state machine IRQ */
        if (hc->type == 1)
                hc->hw.r_irqmsk_misc |= V_STA_IRQMSK;
@@ -2581,12 +2567,12 @@ hfcmulti_interrupt(int intno, void *dev_id)
        static int iq1 = 0, iq2 = 0, iq3 = 0, iq4 = 0,
            iq5 = 0, iq6 = 0, iqcnt = 0;
 #endif
-       static int              count;
        struct hfc_multi        *hc = dev_id;
        struct dchannel         *dch;
        u_char                  r_irq_statech, status, r_irq_misc, r_irq_oview;
        int                     i;
-       u_short                 *plx_acc, wval;
+       void __iomem            *plx_acc;
+       u_short                 wval;
        u_char                  e1_syncsta, temp;
        u_long                  flags;
 
@@ -2606,7 +2592,7 @@ hfcmulti_interrupt(int intno, void *dev_id)
 
        if (test_bit(HFC_CHIP_PLXSD, &hc->chip)) {
                spin_lock_irqsave(&plx_lock, flags);
-               plx_acc = (u_short *)(hc->plx_membase + PLX_INTCSR);
+               plx_acc = hc->plx_membase + PLX_INTCSR;
                wval = readw(plx_acc);
                spin_unlock_irqrestore(&plx_lock, flags);
                if (!(wval & PLX_INTCSR_LINTI1_STATUS))
@@ -2695,16 +2681,11 @@ hfcmulti_interrupt(int intno, void *dev_id)
                        /* -> DTMF IRQ */
                        hfcmulti_dtmf(hc);
                }
-               /* TODO: REPLACE !!!! 125 us Interrupts are not acceptable  */
                if (r_irq_misc & V_IRQ_PROC) {
-                       /* IRQ every 125us */
-                       count++;
-                       /* generate 1kHz signal */
-                       if (count == 8) {
-                               if (hfc_interrupt)
-                                       hfc_interrupt();
-                               count = 0;
-                       }
+                       static int irq_proc_cnt;
+                       if (!irq_proc_cnt++)
+                               printk(KERN_WARNING "%s: got V_IRQ_PROC -"
+                                   " this should not happen\n", __func__);
                }
 
        }
@@ -4091,7 +4072,7 @@ init_card(struct hfc_multi *hc)
 {
        int     err = -EIO;
        u_long  flags;
-       u_short *plx_acc;
+       void    __iomem *plx_acc;
        u_long  plx_flags;
 
        if (debug & DEBUG_HFCMULTI_INIT)
@@ -4113,7 +4094,7 @@ init_card(struct hfc_multi *hc)
 
        if (test_bit(HFC_CHIP_PLXSD, &hc->chip)) {
                spin_lock_irqsave(&plx_lock, plx_flags);
-               plx_acc = (u_short *)(hc->plx_membase+PLX_INTCSR);
+               plx_acc = hc->plx_membase + PLX_INTCSR;
                writew((PLX_INTCSR_PCIINT_ENABLE | PLX_INTCSR_LINTI1_ENABLE),
                        plx_acc); /* enable PCI & LINT1 irq */
                spin_unlock_irqrestore(&plx_lock, plx_flags);
@@ -4162,7 +4143,7 @@ init_card(struct hfc_multi *hc)
 error:
        if (test_bit(HFC_CHIP_PLXSD, &hc->chip)) {
                spin_lock_irqsave(&plx_lock, plx_flags);
-               plx_acc = (u_short *)(hc->plx_membase+PLX_INTCSR);
+               plx_acc = hc->plx_membase + PLX_INTCSR;
                writew(0x00, plx_acc); /*disable IRQs*/
                spin_unlock_irqrestore(&plx_lock, plx_flags);
        }
@@ -4942,9 +4923,7 @@ hfcmulti_init(struct pci_dev *pdev, const struct pci_device_id *ent)
        switch (m->dip_type) {
        case DIP_4S:
                /*
-                * get DIP Setting for beroNet 1S/2S/4S cards
-                *  check if Port Jumper config matches
-                * module param 'protocol'
+                * Get DIP setting for beroNet 1S/2S/4S cards
                 * DIP Setting: (collect GPIO 13/14/15 (R_GPIO_IN1) +
                 * GPI 19/23 (R_GPI_IN2))
                 */
@@ -4963,9 +4942,8 @@ hfcmulti_init(struct pci_dev *pdev, const struct pci_device_id *ent)
                break;
        case DIP_8S:
                /*
-                * get DIP Setting for beroNet 8S0+ cards
-                *
-                * enable PCI auxbridge function
+                * Get DIP Setting for beroNet 8S0+ cards
+                * Enable PCI auxbridge function
                 */
                HFC_outb(hc, R_BRG_PCM_CFG, 1 | V_PCM_CLK);
                /* prepare access to auxport */
@@ -5134,8 +5112,7 @@ static struct pci_device_id hfmultipci_ids[] __devinitdata = {
        { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC8S, PCI_VENDOR_ID_CCD,
        PCI_DEVICE_ID_CCD_HFC8S, 0, 0, H(14)}, /* old Eval */
        { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC8S, PCI_VENDOR_ID_CCD,
-       PCI_SUBDEVICE_ID_CCD_IOB8STR, 0, 0, H(15)},
-           /* IOB8ST Recording */
+       PCI_SUBDEVICE_ID_CCD_IOB8STR, 0, 0, H(15)}, /* IOB8ST Recording */
        { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC8S, PCI_VENDOR_ID_CCD,
                PCI_SUBDEVICE_ID_CCD_IOB8ST, 0, 0, H(16)}, /* IOB8ST  */
        { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC8S, PCI_VENDOR_ID_CCD,
@@ -5185,18 +5162,16 @@ hfcmulti_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        struct hm_map   *m = (struct hm_map *)ent->driver_data;
        int             ret;
 
-       if (m == NULL) {
-               if (ent->vendor == PCI_VENDOR_ID_CCD)
-                       if (ent->device == PCI_DEVICE_ID_CCD_HFC4S ||
-                           ent->device == PCI_DEVICE_ID_CCD_HFC8S ||
-                           ent->device == PCI_DEVICE_ID_CCD_HFCE1)
-                               printk(KERN_ERR
-                                   "unknown HFC multiport controller "
-                                   "(vendor:%x device:%x subvendor:%x "
-                                   "subdevice:%x) Please contact the "
-                                   "driver maintainer for support.\n",
-                                   ent->vendor, ent->device,
-                                   ent->subvendor, ent->subdevice);
+       if (m == NULL && ent->vendor == PCI_VENDOR_ID_CCD && (
+           ent->device == PCI_DEVICE_ID_CCD_HFC4S ||
+           ent->device == PCI_DEVICE_ID_CCD_HFC8S ||
+           ent->device == PCI_DEVICE_ID_CCD_HFCE1)) {
+               printk(KERN_ERR
+                   "Unknown HFC multiport controller (vendor:%x device:%x "
+                   "subvendor:%x subdevice:%x)\n", ent->vendor, ent->device,
+                   ent->subvendor, ent->subdevice);
+               printk(KERN_ERR
+                   "Please contact the driver maintainer for support.\n");
                return -ENODEV;
        }
        ret = hfcmulti_init(pdev, ent);
@@ -5219,22 +5194,9 @@ HFCmulti_cleanup(void)
 {
        struct hfc_multi *card, *next;
 
-       /* unload interrupt function symbol */
-       if (hfc_interrupt)
-               symbol_put(ztdummy_extern_interrupt);
-       if (register_interrupt)
-               symbol_put(ztdummy_register_interrupt);
-       if (unregister_interrupt) {
-               if (interrupt_registered) {
-                       interrupt_registered = 0;
-                       unregister_interrupt();
-               }
-               symbol_put(ztdummy_unregister_interrupt);
-       }
-
+       /* get rid of all devices of this driver */
        list_for_each_entry_safe(card, next, &HFClist, list)
                release_card(card);
-       /* get rid of all devices of this driver */
        pci_unregister_driver(&hfcmultipci_driver);
 }
 
@@ -5243,8 +5205,10 @@ HFCmulti_init(void)
 {
        int err;
 
+       printk(KERN_INFO "mISDN: HFC-multi driver %s\n", HFC_MULTI_VERSION);
+
 #ifdef IRQ_DEBUG
-       printk(KERN_ERR "%s: IRQ_DEBUG IS ENABLED!\n", __func__);
+       printk(KERN_DEBUG "%s: IRQ_DEBUG IS ENABLED!\n", __func__);
 #endif
 
        spin_lock_init(&HFClock);
@@ -5253,22 +5217,11 @@ HFCmulti_init(void)
        if (debug & DEBUG_HFCMULTI_INIT)
                printk(KERN_DEBUG "%s: init entered\n", __func__);
 
-       hfc_interrupt = symbol_get(ztdummy_extern_interrupt);
-       register_interrupt = symbol_get(ztdummy_register_interrupt);
-       unregister_interrupt = symbol_get(ztdummy_unregister_interrupt);
-       printk(KERN_INFO "mISDN: HFC-multi driver %s\n",
-           hfcmulti_revision);
-
        switch (poll) {
        case 0:
                poll_timer = 6;
                poll = 128;
                break;
-               /*
-                * wenn dieses break nochmal verschwindet,
-                * gibt es heisse ohren :-)
-                * "without the break you will get hot ears ???"
-                */
        case 8:
                poll_timer = 2;
                break;
@@ -5298,17 +5251,6 @@ HFCmulti_init(void)
        err = pci_register_driver(&hfcmultipci_driver);
        if (err < 0) {
                printk(KERN_ERR "error registering pci driver: %x\n", err);
-               if (hfc_interrupt)
-                       symbol_put(ztdummy_extern_interrupt);
-               if (register_interrupt)
-                       symbol_put(ztdummy_register_interrupt);
-               if (unregister_interrupt) {
-                       if (interrupt_registered) {
-                               interrupt_registered = 0;
-                               unregister_interrupt();
-                       }
-                       symbol_put(ztdummy_unregister_interrupt);
-               }
                return err;
        }
        return 0;