]> err.no Git - linux-2.6/blobdiff - drivers/char/cyclades.c
Char: cyclades, init card struct immediately
[linux-2.6] / drivers / char / cyclades.c
index 363beb16572911ff18963e0eae785318e58890ae..c7e1433bf8ea0359ba62d67e341e4acb5816e968 100644 (file)
 #undef CY_ENABLE_MONITORING
 #undef CY_PCI_DEBUG
 
-#if 0
-#define PAUSE __asm__("nop")
-#else
-#define PAUSE do {} while (0)
-#endif
-
 /*
  * Include section 
  */
                spin_unlock_irqrestore(&cy_card[info->card].card_lock, flags); \
                } while (0)
 
-#include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/pci.h>
 
@@ -682,13 +675,13 @@ static void cy_send_xchar(struct tty_struct *tty, char ch);
 #define IS_CYC_Z(card) ((card).num_chips == -1)
 
 #define Z_FPGA_CHECK(card) \
-       ((cy_readl(&((struct RUNTIME_9060 __iomem *) \
+       ((readl(&((struct RUNTIME_9060 __iomem *) \
                ((card).ctl_addr))->init_ctrl) & (1<<17)) != 0)
 
-#define ISZLOADED(card)        (((ZO_V1==cy_readl(&((struct RUNTIME_9060 __iomem *) \
+#define ISZLOADED(card)        (((ZO_V1==readl(&((struct RUNTIME_9060 __iomem *) \
                        ((card).ctl_addr))->mail_box_0)) || \
                        Z_FPGA_CHECK(card)) && \
-                       (ZFIRM_ID==cy_readl(&((struct FIRM_ID __iomem *) \
+                       (ZFIRM_ID==readl(&((struct FIRM_ID __iomem *) \
                        ((card).base_addr+ID_ADDRESS))->signature)))
 
 #ifndef SERIAL_XMIT_SIZE
@@ -829,22 +822,23 @@ static unsigned short cy_pci_nboard;
 static unsigned short cy_isa_nboard;
 static unsigned short cy_nboard;
 #ifdef CONFIG_PCI
-static unsigned short cy_pci_dev_id[] = {
-       PCI_DEVICE_ID_CYCLOM_Y_Lo,      /* PCI < 1Mb */
-       PCI_DEVICE_ID_CYCLOM_Y_Hi,      /* PCI > 1Mb */
-       PCI_DEVICE_ID_CYCLOM_4Y_Lo,     /* 4Y PCI < 1Mb */
-       PCI_DEVICE_ID_CYCLOM_4Y_Hi,     /* 4Y PCI > 1Mb */
-       PCI_DEVICE_ID_CYCLOM_8Y_Lo,     /* 8Y PCI < 1Mb */
-       PCI_DEVICE_ID_CYCLOM_8Y_Hi,     /* 8Y PCI > 1Mb */
-       PCI_DEVICE_ID_CYCLOM_Z_Lo,      /* Z PCI < 1Mb */
-       PCI_DEVICE_ID_CYCLOM_Z_Hi,      /* Z PCI > 1Mb */
-       0                       /* end of table */
+static struct pci_device_id cy_pci_dev_id[] __devinitdata = {
+       { PCI_DEVICE(PCI_VENDOR_ID_CYCLADES, PCI_DEVICE_ID_CYCLOM_Y_Lo) },      /* PCI < 1Mb */
+       { PCI_DEVICE(PCI_VENDOR_ID_CYCLADES, PCI_DEVICE_ID_CYCLOM_Y_Hi) },      /* PCI > 1Mb */
+       { PCI_DEVICE(PCI_VENDOR_ID_CYCLADES, PCI_DEVICE_ID_CYCLOM_4Y_Lo) },     /* 4Y PCI < 1Mb */
+       { PCI_DEVICE(PCI_VENDOR_ID_CYCLADES, PCI_DEVICE_ID_CYCLOM_4Y_Hi) },     /* 4Y PCI > 1Mb */
+       { PCI_DEVICE(PCI_VENDOR_ID_CYCLADES, PCI_DEVICE_ID_CYCLOM_8Y_Lo) },     /* 8Y PCI < 1Mb */
+       { PCI_DEVICE(PCI_VENDOR_ID_CYCLADES, PCI_DEVICE_ID_CYCLOM_8Y_Hi) },     /* 8Y PCI > 1Mb */
+       { PCI_DEVICE(PCI_VENDOR_ID_CYCLADES, PCI_DEVICE_ID_CYCLOM_Z_Lo) },      /* Z PCI < 1Mb */
+       { PCI_DEVICE(PCI_VENDOR_ID_CYCLADES, PCI_DEVICE_ID_CYCLOM_Z_Hi) },      /* Z PCI > 1Mb */
+       { }                     /* end of table */
 };
+MODULE_DEVICE_TABLE(pci, cy_pci_dev_id);
 #endif
 
 static void cy_start(struct tty_struct *);
 static void set_line_char(struct cyclades_port *);
-static int cyz_issue_cmd(struct cyclades_card *, uclong, ucchar, uclong);
+static int cyz_issue_cmd(struct cyclades_card *, __u32, __u8, __u32);
 #ifdef CONFIG_ISA
 static unsigned detect_isa_irq(void __iomem *);
 #endif                         /* CONFIG_ISA */
@@ -857,7 +851,6 @@ static void cyz_poll(unsigned long);
 /* The Cyclades-Z polling cycle is defined by this variable */
 static long cyz_polling_cycle = CZ_DEF_POLL;
 
-static int cyz_timeron = 0;
 static DEFINE_TIMER(cyz_timerlist, cyz_poll, 0, 0);
 
 #else                          /* CONFIG_CYZ_INTR */
@@ -974,11 +967,11 @@ do_softint(struct work_struct *work)
  */
 static int cyy_issue_cmd(void __iomem * base_addr, u_char cmd, int index)
 {
-       volatile int i;
+       unsigned int i;
 
        /* Check to see that the previous command has completed */
        for (i = 0; i < 100; i++) {
-               if (cy_readb(base_addr + (CyCCR << index)) == 0) {
+               if (readb(base_addr + (CyCCR << index)) == 0) {
                        break;
                }
                udelay(10L);
@@ -1021,7 +1014,7 @@ static unsigned detect_isa_irq(void __iomem * address)
 
        cy_writeb(address + (CyCAR << index), 0);
        cy_writeb(address + (CySRER << index),
-                 cy_readb(address + (CySRER << index)) | CyTxRdy);
+                 readb(address + (CySRER << index)) | CyTxRdy);
        local_irq_restore(flags);
 
        /* Wait ... */
@@ -1031,11 +1024,11 @@ static unsigned detect_isa_irq(void __iomem * address)
        irq = probe_irq_off(irqs);
 
        /* Clean up */
-       save_xir = (u_char) cy_readb(address + (CyTIR << index));
-       save_car = cy_readb(address + (CyCAR << index));
+       save_xir = (u_char) readb(address + (CyTIR << index));
+       save_car = readb(address + (CyCAR << index));
        cy_writeb(address + (CyCAR << index), (save_xir & 0x3));
        cy_writeb(address + (CySRER << index),
-                 cy_readb(address + (CySRER << index)) & ~CyTxRdy);
+                 readb(address + (CySRER << index)) & ~CyTxRdy);
        cy_writeb(address + (CyTIR << index), (save_xir & 0x3f));
        cy_writeb(address + (CyCAR << index), (save_car));
        cy_writeb(address + (Cy_ClrIntr << index), 0);
@@ -1050,7 +1043,7 @@ static void cyy_intr_chip(struct cyclades_card *cinfo, int chip,
 {
        struct cyclades_port *info;
        struct tty_struct *tty;
-       volatile int char_count;
+       int char_count;
        int i, j, len, mdm_change, mdm_status, outch;
        int save_xir, channel, save_car;
        char data;
@@ -1061,34 +1054,34 @@ static void cyy_intr_chip(struct cyclades_card *cinfo, int chip,
 #endif
                /* determine the channel & change to that context */
                spin_lock(&cinfo->card_lock);
-               save_xir = (u_char) cy_readb(base_addr + (CyRIR << index));
+               save_xir = (u_char) readb(base_addr + (CyRIR << index));
                channel = (u_short) (save_xir & CyIRChannel);
                i = channel + chip * 4 + cinfo->first_line;
                info = &cy_port[i];
                info->last_active = jiffies;
-               save_car = cy_readb(base_addr + (CyCAR << index));
+               save_car = readb(base_addr + (CyCAR << index));
                cy_writeb(base_addr + (CyCAR << index), save_xir);
 
                /* if there is nowhere to put the data, discard it */
                if (info->tty == 0) {
-                       j = (cy_readb(base_addr + (CyRIVR << index)) &
+                       j = (readb(base_addr + (CyRIVR << index)) &
                                CyIVRMask);
                        if (j == CyIVRRxEx) {   /* exception */
-                               data = cy_readb(base_addr + (CyRDSR << index));
+                               data = readb(base_addr + (CyRDSR << index));
                        } else {        /* normal character reception */
-                               char_count = cy_readb(base_addr +
+                               char_count = readb(base_addr +
                                                (CyRDCR << index));
                                while (char_count--) {
-                                       data = cy_readb(base_addr +
+                                       data = readb(base_addr +
                                                (CyRDSR << index));
                                }
                        }
                } else {        /* there is an open port for this data */
                        tty = info->tty;
-                       j = (cy_readb(base_addr + (CyRIVR << index)) &
+                       j = (readb(base_addr + (CyRIVR << index)) &
                                        CyIVRMask);
                        if (j == CyIVRRxEx) {   /* exception */
-                               data = cy_readb(base_addr + (CyRDSR << index));
+                               data = readb(base_addr + (CyRDSR << index));
 
                                /* For statistics only */
                                if (data & CyBREAK)
@@ -1109,7 +1102,7 @@ static void cyy_intr_chip(struct cyclades_card *cinfo, int chip,
                                                if (data & CyBREAK) {
                                                        tty_insert_flip_char(
                                                                tty,
-                                                               cy_readb(
+                                                               readb(
                                                                base_addr +
                                                                (CyRDSR <<
                                                                        index)),
@@ -1122,7 +1115,7 @@ static void cyy_intr_chip(struct cyclades_card *cinfo, int chip,
                                                } else if (data & CyFRAME) {
                                                        tty_insert_flip_char(
                                                                tty,
-                                                               cy_readb(
+                                                               readb(
                                                                base_addr +
                                                                (CyRDSR <<
                                                                        index)),
@@ -1134,7 +1127,7 @@ static void cyy_intr_chip(struct cyclades_card *cinfo, int chip,
                                                        /* Pieces of seven... */
                                                        tty_insert_flip_char(
                                                                tty,
-                                                               cy_readb(
+                                                               readb(
                                                                base_addr +
                                                                (CyRDSR <<
                                                                        index)),
@@ -1153,7 +1146,7 @@ static void cyy_intr_chip(struct cyclades_card *cinfo, int chip,
                                                 */
                                                        tty_insert_flip_char(
                                                                tty,
-                                                               cy_readb(
+                                                               readb(
                                                                base_addr +
                                                                (CyRDSR <<
                                                                        index)),
@@ -1185,7 +1178,7 @@ static void cyy_intr_chip(struct cyclades_card *cinfo, int chip,
                                }
                        } else {        /* normal character reception */
                                /* load # chars available from the chip */
-                               char_count = cy_readb(base_addr +
+                               char_count = readb(base_addr +
                                                (CyRDCR << index));
 
 #ifdef CY_ENABLE_MONITORING
@@ -1197,7 +1190,7 @@ static void cyy_intr_chip(struct cyclades_card *cinfo, int chip,
 #endif
                                len = tty_buffer_request_room(tty, char_count);
                                while (len--) {
-                                       data = cy_readb(base_addr +
+                                       data = readb(base_addr +
                                                        (CyRDSR << index));
                                        tty_insert_flip_char(tty, data,
                                                        TTY_NORMAL);
@@ -1227,16 +1220,16 @@ static void cyy_intr_chip(struct cyclades_card *cinfo, int chip,
 
                /* determine the channel & change to that context */
                spin_lock(&cinfo->card_lock);
-               save_xir = (u_char) cy_readb(base_addr + (CyTIR << index));
+               save_xir = (u_char) readb(base_addr + (CyTIR << index));
                channel = (u_short) (save_xir & CyIRChannel);
                i = channel + chip * 4 + cinfo->first_line;
-               save_car = cy_readb(base_addr + (CyCAR << index));
+               save_car = readb(base_addr + (CyCAR << index));
                cy_writeb(base_addr + (CyCAR << index), save_xir);
 
                /* validate the port# (as configured and open) */
                if ((i < 0) || (NR_PORTS <= i)) {
                        cy_writeb(base_addr + (CySRER << index),
-                                 cy_readb(base_addr + (CySRER << index)) &
+                                 readb(base_addr + (CySRER << index)) &
                                  ~CyTxRdy);
                        goto txend;
                }
@@ -1244,7 +1237,7 @@ static void cyy_intr_chip(struct cyclades_card *cinfo, int chip,
                info->last_active = jiffies;
                if (info->tty == 0) {
                        cy_writeb(base_addr + (CySRER << index),
-                                 cy_readb(base_addr + (CySRER << index)) &
+                                 readb(base_addr + (CySRER << index)) &
                                  ~CyTxRdy);
                        goto txdone;
                }
@@ -1277,15 +1270,15 @@ static void cyy_intr_chip(struct cyclades_card *cinfo, int chip,
 
                while (char_count-- > 0) {
                        if (!info->xmit_cnt) {
-                               if (cy_readb(base_addr + (CySRER << index)) &
+                               if (readb(base_addr + (CySRER << index)) &
                                                CyTxMpty) {
                                        cy_writeb(base_addr + (CySRER << index),
-                                               cy_readb(base_addr +
+                                               readb(base_addr +
                                                        (CySRER << index)) &
                                                ~CyTxMpty);
                                } else {
                                        cy_writeb(base_addr + (CySRER << index),
-                                               (cy_readb(base_addr +
+                                               (readb(base_addr +
                                                        (CySRER << index)) &
                                                ~CyTxRdy) | CyTxMpty);
                                }
@@ -1293,13 +1286,13 @@ static void cyy_intr_chip(struct cyclades_card *cinfo, int chip,
                        }
                        if (info->xmit_buf == 0) {
                                cy_writeb(base_addr + (CySRER << index),
-                                       cy_readb(base_addr + (CySRER << index))&
+                                       readb(base_addr + (CySRER << index)) &
                                        ~CyTxRdy);
                                goto txdone;
                        }
                        if (info->tty->stopped || info->tty->hw_stopped) {
                                cy_writeb(base_addr + (CySRER << index),
-                                       cy_readb(base_addr + (CySRER << index))&
+                                       readb(base_addr + (CySRER << index)) &
                                        ~CyTxRdy);
                                goto txdone;
                        }
@@ -1352,15 +1345,15 @@ txend:
 
                /* determine the channel & change to that context */
                spin_lock(&cinfo->card_lock);
-               save_xir = (u_char) cy_readb(base_addr + (CyMIR << index));
+               save_xir = (u_char) readb(base_addr + (CyMIR << index));
                channel = (u_short) (save_xir & CyIRChannel);
                info = &cy_port[channel + chip * 4 + cinfo->first_line];
                info->last_active = jiffies;
-               save_car = cy_readb(base_addr + (CyCAR << index));
+               save_car = readb(base_addr + (CyCAR << index));
                cy_writeb(base_addr + (CyCAR << index), save_xir);
 
-               mdm_change = cy_readb(base_addr + (CyMISR << index));
-               mdm_status = cy_readb(base_addr + (CyMSVR1 << index));
+               mdm_change = readb(base_addr + (CyMISR << index));
+               mdm_status = readb(base_addr + (CyMSVR1 << index));
 
                if (info->tty == 0) {   /* no place for data, ignore it */
                        ;
@@ -1397,7 +1390,7 @@ txend:
                                                info->tty->hw_stopped = 0;
                                                cy_writeb(base_addr +
                                                        (CySRER << index),
-                                                       cy_readb(base_addr +
+                                                       readb(base_addr +
                                                                (CySRER <<
                                                                        index))|
                                                        CyTxRdy);
@@ -1411,7 +1404,7 @@ txend:
                                                info->tty->hw_stopped = 1;
                                                cy_writeb(base_addr +
                                                        (CySRER << index),
-                                                       cy_readb(base_addr +
+                                                       readb(base_addr +
                                                                (CySRER <<
                                                                index)) &
                                                        ~CyTxRdy);
@@ -1465,7 +1458,7 @@ static irqreturn_t cyy_interrupt(int irq, void *dev_id)
                        base_addr = cinfo->base_addr +
                                        (cy_chip_offset[chip] << index);
                        too_many = 0;
-                       while ((status = cy_readb(base_addr +
+                       while ((status = readb(base_addr +
                                                (CySVRR << index))) != 0x00) {
                                had_work++;
                        /* The purpose of the following test is to ensure that
@@ -1497,7 +1490,7 @@ static irqreturn_t cyy_interrupt(int irq, void *dev_id)
 
 static int
 cyz_fetch_msg(struct cyclades_card *cinfo,
-               uclong * channel, ucchar * cmd, uclong * param)
+               __u32 * channel, __u8 * cmd, __u32 * param)
 {
        struct FIRM_ID __iomem *firm_id;
        struct ZFW_CTRL __iomem *zfw_ctrl;
@@ -1508,16 +1501,15 @@ cyz_fetch_msg(struct cyclades_card *cinfo,
        if (!ISZLOADED(*cinfo)) {
                return -1;
        }
-       zfw_ctrl = cinfo->base_addr + (cy_readl(&firm_id->zfwctrl_addr) &
-                       0xfffff);
+       zfw_ctrl = cinfo->base_addr + (readl(&firm_id->zfwctrl_addr) & 0xfffff);
        board_ctrl = &zfw_ctrl->board_ctrl;
 
-       loc_doorbell = cy_readl(&((struct RUNTIME_9060 __iomem *)
+       loc_doorbell = readl(&((struct RUNTIME_9060 __iomem *)
                                  (cinfo->ctl_addr))->loc_doorbell);
        if (loc_doorbell) {
                *cmd = (char)(0xff & loc_doorbell);
-               *channel = cy_readl(&board_ctrl->fwcmd_channel);
-               *param = (uclong) cy_readl(&board_ctrl->fwcmd_param);
+               *channel = readl(&board_ctrl->fwcmd_channel);
+               *param = (__u32) readl(&board_ctrl->fwcmd_param);
                cy_writel(&((struct RUNTIME_9060 __iomem *)(cinfo->ctl_addr))->
                          loc_doorbell, 0xffffffff);
                return 1;
@@ -1527,28 +1519,27 @@ cyz_fetch_msg(struct cyclades_card *cinfo,
 
 static int
 cyz_issue_cmd(struct cyclades_card *cinfo,
-               uclong channel, ucchar cmd, uclong param)
+               __u32 channel, __u8 cmd, __u32 param)
 {
        struct FIRM_ID __iomem *firm_id;
        struct ZFW_CTRL __iomem *zfw_ctrl;
        struct BOARD_CTRL __iomem *board_ctrl;
-       unsigned long __iomem *pci_doorbell;
+       __u32 __iomem *pci_doorbell;
        int index;
 
        firm_id = cinfo->base_addr + ID_ADDRESS;
        if (!ISZLOADED(*cinfo)) {
                return -1;
        }
-       zfw_ctrl = cinfo->base_addr + (cy_readl(&firm_id->zfwctrl_addr) &
-                       0xfffff);
+       zfw_ctrl = cinfo->base_addr + (readl(&firm_id->zfwctrl_addr) & 0xfffff);
        board_ctrl = &zfw_ctrl->board_ctrl;
 
        index = 0;
        pci_doorbell =
            &((struct RUNTIME_9060 __iomem *)(cinfo->ctl_addr))->pci_doorbell;
-       while ((cy_readl(pci_doorbell) & 0xff) != 0) {
+       while ((readl(pci_doorbell) & 0xff) != 0) {
                if (index++ == 1000) {
-                       return (int)(cy_readl(pci_doorbell) & 0xff);
+                       return (int)(readl(pci_doorbell) & 0xff);
                }
                udelay(50L);
        }
@@ -1560,25 +1551,24 @@ cyz_issue_cmd(struct cyclades_card *cinfo,
 }                              /* cyz_issue_cmd */
 
 static void
-cyz_handle_rx(struct cyclades_port *info,
-               volatile struct CH_CTRL __iomem * ch_ctrl,
-               volatile struct BUF_CTRL __iomem * buf_ctrl)
+cyz_handle_rx(struct cyclades_port *info, struct CH_CTRL __iomem *ch_ctrl,
+               struct BUF_CTRL __iomem *buf_ctrl)
 {
        struct cyclades_card *cinfo = &cy_card[info->card];
        struct tty_struct *tty = info->tty;
-       volatile int char_count;
+       int char_count;
        int len;
 #ifdef BLOCKMOVE
        int small_count;
 #else
        char data;
 #endif
-       volatile uclong rx_put, rx_get, new_rx_get, rx_bufsize, rx_bufaddr;
+       __u32 rx_put, rx_get, new_rx_get, rx_bufsize, rx_bufaddr;
 
-       rx_get = new_rx_get = cy_readl(&buf_ctrl->rx_get);
-       rx_put = cy_readl(&buf_ctrl->rx_put);
-       rx_bufsize = cy_readl(&buf_ctrl->rx_bufsize);
-       rx_bufaddr = cy_readl(&buf_ctrl->rx_bufaddr);
+       rx_get = new_rx_get = readl(&buf_ctrl->rx_get);
+       rx_put = readl(&buf_ctrl->rx_put);
+       rx_bufsize = readl(&buf_ctrl->rx_bufsize);
+       rx_bufaddr = readl(&buf_ctrl->rx_bufaddr);
        if (rx_put >= rx_get)
                char_count = rx_put - rx_get;
        else
@@ -1628,7 +1618,7 @@ cyz_handle_rx(struct cyclades_port *info,
 #else
                        len = tty_buffer_request_room(tty, char_count);
                        while (len--) {
-                               data = cy_readb(cinfo->base_addr + rx_bufaddr +
+                               data = readb(cinfo->base_addr + rx_bufaddr +
                                                new_rx_get);
                                new_rx_get = (new_rx_get + 1)& (rx_bufsize - 1);
                                tty_insert_flip_char(tty, data, TTY_NORMAL);
@@ -1639,13 +1629,12 @@ cyz_handle_rx(struct cyclades_port *info,
 #ifdef CONFIG_CYZ_INTR
                /* Recalculate the number of chars in the RX buffer and issue
                   a cmd in case it's higher than the RX high water mark */
-                       rx_put = cy_readl(&buf_ctrl->rx_put);
+                       rx_put = readl(&buf_ctrl->rx_put);
                        if (rx_put >= rx_get)
                                char_count = rx_put - rx_get;
                        else
                                char_count = rx_put - rx_get + rx_bufsize;
-                       if (char_count >= (int)cy_readl(&buf_ctrl->
-                                       rx_threshold)) {
+                       if (char_count >= (int)readl(&buf_ctrl->rx_threshold)) {
                                cy_sched_event(info, Cy_EVENT_Z_RX_FULL);
                        }
 #endif
@@ -1658,26 +1647,25 @@ cyz_handle_rx(struct cyclades_port *info,
 }
 
 static void
-cyz_handle_tx(struct cyclades_port *info,
-               volatile struct CH_CTRL __iomem * ch_ctrl,
-               volatile struct BUF_CTRL __iomem * buf_ctrl)
+cyz_handle_tx(struct cyclades_port *info, struct CH_CTRL __iomem *ch_ctrl,
+               struct BUF_CTRL __iomem *buf_ctrl)
 {
        struct cyclades_card *cinfo = &cy_card[info->card];
        struct tty_struct *tty = info->tty;
        char data;
-       volatile int char_count;
+       int char_count;
 #ifdef BLOCKMOVE
        int small_count;
 #endif
-       volatile uclong tx_put, tx_get, tx_bufsize, tx_bufaddr;
+       __u32 tx_put, tx_get, tx_bufsize, tx_bufaddr;
 
        if (info->xmit_cnt <= 0)        /* Nothing to transmit */
                return;
 
-       tx_get = cy_readl(&buf_ctrl->tx_get);
-       tx_put = cy_readl(&buf_ctrl->tx_put);
-       tx_bufsize = cy_readl(&buf_ctrl->tx_bufsize);
-       tx_bufaddr = cy_readl(&buf_ctrl->tx_bufaddr);
+       tx_get = readl(&buf_ctrl->tx_get);
+       tx_put = readl(&buf_ctrl->tx_put);
+       tx_bufsize = readl(&buf_ctrl->tx_bufsize);
+       tx_bufaddr = readl(&buf_ctrl->tx_bufaddr);
        if (tx_put >= tx_get)
                char_count = tx_get - tx_put - 1 + tx_bufsize;
        else
@@ -1749,24 +1737,23 @@ static void cyz_handle_cmd(struct cyclades_card *cinfo)
 {
        struct tty_struct *tty;
        struct cyclades_port *info;
-       static volatile struct FIRM_ID __iomem *firm_id;
-       static volatile struct ZFW_CTRL __iomem *zfw_ctrl;
-       static volatile struct BOARD_CTRL __iomem *board_ctrl;
-       static volatile struct CH_CTRL __iomem *ch_ctrl;
-       static volatile struct BUF_CTRL __iomem *buf_ctrl;
-       uclong channel;
-       ucchar cmd;
-       uclong param;
-       uclong hw_ver, fw_ver;
+       static struct FIRM_ID __iomem *firm_id;
+       static struct ZFW_CTRL __iomem *zfw_ctrl;
+       static struct BOARD_CTRL __iomem *board_ctrl;
+       static struct CH_CTRL __iomem *ch_ctrl;
+       static struct BUF_CTRL __iomem *buf_ctrl;
+       __u32 channel;
+       __u8 cmd;
+       __u32 param;
+       __u32 hw_ver, fw_ver;
        int special_count;
        int delta_count;
 
        firm_id = cinfo->base_addr + ID_ADDRESS;
-       zfw_ctrl = cinfo->base_addr + (cy_readl(&firm_id->zfwctrl_addr) &
-                       0xfffff);
+       zfw_ctrl = cinfo->base_addr + (readl(&firm_id->zfwctrl_addr) & 0xfffff);
        board_ctrl = &zfw_ctrl->board_ctrl;
-       fw_ver = cy_readl(&board_ctrl->fw_version);
-       hw_ver = cy_readl(&((struct RUNTIME_9060 __iomem *)(cinfo->ctl_addr))->
+       fw_ver = readl(&board_ctrl->fw_version);
+       hw_ver = readl(&((struct RUNTIME_9060 __iomem *)(cinfo->ctl_addr))->
                        mail_box_0);
 
        while (cyz_fetch_msg(cinfo, &channel, &cmd, &param) == 1) {
@@ -1800,7 +1787,7 @@ static void cyz_handle_cmd(struct cyclades_card *cinfo)
                        delta_count++;
                        if (info->flags & ASYNC_CHECK_CD) {
                                if ((fw_ver > 241 ? ((u_long) param) :
-                                               cy_readl(&ch_ctrl->rs_status)) &
+                                               readl(&ch_ctrl->rs_status)) &
                                                C_RS_DCD) {
                                        cy_sched_event(info,
                                                        Cy_EVENT_OPEN_WAKEUP);
@@ -1891,7 +1878,7 @@ static void cyz_rx_restart(unsigned long arg)
        struct cyclades_port *info = (struct cyclades_port *)arg;
        int retval;
        int card = info->card;
-       uclong channel = (info->line) - (cy_card[card].first_line);
+       __u32 channel = (info->line) - (cy_card[card].first_line);
        unsigned long flags;
 
        CY_LOCK(info, flags);
@@ -1911,14 +1898,14 @@ static void cyz_poll(unsigned long arg)
        struct cyclades_card *cinfo;
        struct cyclades_port *info;
        struct tty_struct *tty;
-       static volatile struct FIRM_ID *firm_id;
-       static volatile struct ZFW_CTRL *zfw_ctrl;
-       static volatile struct BOARD_CTRL *board_ctrl;
-       static volatile struct CH_CTRL *ch_ctrl;
-       static volatile struct BUF_CTRL *buf_ctrl;
+       static struct FIRM_ID *firm_id;
+       static struct ZFW_CTRL *zfw_ctrl;
+       static struct BOARD_CTRL *board_ctrl;
+       static struct CH_CTRL *ch_ctrl;
+       static struct BUF_CTRL *buf_ctrl;
+       unsigned long expires = jiffies + HZ;
        int card, port;
 
-       cyz_timerlist.expires = jiffies + (HZ);
        for (card = 0; card < NR_CARDS; card++) {
                cinfo = &cy_card[card];
 
@@ -1929,12 +1916,12 @@ static void cyz_poll(unsigned long arg)
 
                firm_id = cinfo->base_addr + ID_ADDRESS;
                zfw_ctrl = cinfo->base_addr +
-                               (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff);
+                               (readl(&firm_id->zfwctrl_addr) & 0xfffff);
                board_ctrl = &(zfw_ctrl->board_ctrl);
 
        /* Skip first polling cycle to avoid racing conditions with the FW */
                if (!cinfo->intr_enabled) {
-                       cinfo->nports = (int)cy_readl(&board_ctrl->n_channel);
+                       cinfo->nports = (int)readl(&board_ctrl->n_channel);
                        cinfo->intr_enabled = 1;
                        continue;
                }
@@ -1952,9 +1939,9 @@ static void cyz_poll(unsigned long arg)
                        cyz_handle_tx(info, ch_ctrl, buf_ctrl);
                }
                /* poll every 'cyz_polling_cycle' period */
-               cyz_timerlist.expires = jiffies + cyz_polling_cycle;
+               expires = jiffies + cyz_polling_cycle;
        }
-       add_timer(&cyz_timerlist);
+       mod_timer(&cyz_timerlist, expires);
 }                              /* cyz_poll */
 
 #endif                         /* CONFIG_CYZ_INTR */
@@ -2035,12 +2022,12 @@ static int startup(struct cyclades_port *info)
 #ifdef CY_DEBUG_DTR
                printk("cyc:startup raising DTR\n");
                printk("     status: 0x%x, 0x%x\n",
-                       cy_readb(base_addr + (CyMSVR1 << index)),
-                       cy_readb(base_addr + (CyMSVR2 << index)));
+                       readb(base_addr + (CyMSVR1 << index)),
+                       readb(base_addr + (CyMSVR2 << index)));
 #endif
 
                cy_writeb(base_addr + (CySRER << index),
-                       cy_readb(base_addr + (CySRER << index)) | CyRxData);
+                       readb(base_addr + (CySRER << index)) | CyRxData);
                info->flags |= ASYNC_INITIALIZED;
 
                if (info->tty) {
@@ -2070,7 +2057,7 @@ static int startup(struct cyclades_port *info)
                }
 
                zfw_ctrl = cy_card[card].base_addr +
-                               (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff);
+                               (readl(&firm_id->zfwctrl_addr) & 0xfffff);
                board_ctrl = &zfw_ctrl->board_ctrl;
                ch_ctrl = zfw_ctrl->ch_ctrl;
 
@@ -2118,7 +2105,7 @@ static int startup(struct cyclades_port *info)
                /* set timeout !!! */
                /* set RTS and DTR !!! */
                cy_writel(&ch_ctrl[channel].rs_control,
-                       cy_readl(&ch_ctrl[channel].rs_control) | C_RS_RTS |
+                       readl(&ch_ctrl[channel].rs_control) | C_RS_RTS |
                        C_RS_DTR);
                retval = cyz_issue_cmd(&cy_card[info->card], channel,
                                C_CM_IOCTLM, 0L);
@@ -2174,7 +2161,7 @@ static void start_xmit(struct cyclades_port *info)
                CY_LOCK(info, flags);
                cy_writeb(base_addr + (CyCAR << index), channel);
                cy_writeb(base_addr + (CySRER << index),
-                       cy_readb(base_addr + (CySRER << index)) | CyTxRdy);
+                       readb(base_addr + (CySRER << index)) | CyTxRdy);
                CY_UNLOCK(info, flags);
        } else {
 #ifdef CONFIG_CYZ_INTR
@@ -2241,8 +2228,8 @@ static void shutdown(struct cyclades_port *info)
 #ifdef CY_DEBUG_DTR
                        printk("cyc shutdown dropping DTR\n");
                        printk("     status: 0x%x, 0x%x\n",
-                               cy_readb(base_addr + (CyMSVR1 << index)),
-                               cy_readb(base_addr + (CyMSVR2 << index)));
+                               readb(base_addr + (CyMSVR1 << index)),
+                               readb(base_addr + (CyMSVR2 << index)));
 #endif
                }
                cyy_issue_cmd(base_addr, CyCHAN_CTL | CyDIS_RCVR, index);
@@ -2273,7 +2260,7 @@ static void shutdown(struct cyclades_port *info)
                }
 
                zfw_ctrl = cy_card[card].base_addr +
-                               (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff);
+                               (readl(&firm_id->zfwctrl_addr) & 0xfffff);
                board_ctrl = &zfw_ctrl->board_ctrl;
                ch_ctrl = zfw_ctrl->ch_ctrl;
 
@@ -2288,7 +2275,7 @@ static void shutdown(struct cyclades_port *info)
 
                if (!info->tty || (info->tty->termios->c_cflag & HUPCL)) {
                        cy_writel(&ch_ctrl[channel].rs_control,
-                               (uclong)(cy_readl(&ch_ctrl[channel].rs_control)&
+                               (__u32)(readl(&ch_ctrl[channel].rs_control) &
                                        ~(C_RS_RTS | C_RS_DTR)));
                        retval = cyz_issue_cmd(&cy_card[info->card], channel,
                                        C_CM_IOCTLM, 0L);
@@ -2396,10 +2383,8 @@ block_til_ready(struct tty_struct *tty, struct file *filp,
 #ifdef CY_DEBUG_DTR
                                printk("cyc:block_til_ready raising DTR\n");
                                printk("     status: 0x%x, 0x%x\n",
-                                       cy_readb(base_addr +
-                                               (CyMSVR1 << index)),
-                                       cy_readb(base_addr +
-                                               (CyMSVR2 << index)));
+                                       readb(base_addr + (CyMSVR1 << index)),
+                                       readb(base_addr + (CyMSVR2 << index)));
 #endif
                        }
                        CY_UNLOCK(info, flags);
@@ -2416,7 +2401,7 @@ block_til_ready(struct tty_struct *tty, struct file *filp,
                        cy_writeb(base_addr + (CyCAR << index),
                                  (u_char) channel);
                        if (!(info->flags & ASYNC_CLOSING) && (C_CLOCAL(tty) ||
-                                       (cy_readb(base_addr +
+                                       (readb(base_addr +
                                                (CyMSVR1 << index)) & CyDCD))) {
                                CY_UNLOCK(info, flags);
                                break;
@@ -2445,24 +2430,22 @@ block_til_ready(struct tty_struct *tty, struct file *filp,
                base_addr = cinfo->base_addr;
                firm_id = base_addr + ID_ADDRESS;
                if (!ISZLOADED(*cinfo)) {
-                       current->state = TASK_RUNNING;
+                       __set_current_state(TASK_RUNNING);
                        remove_wait_queue(&info->open_wait, &wait);
                        return -EINVAL;
                }
 
-               zfw_ctrl = base_addr + (cy_readl(&firm_id->zfwctrl_addr) &
-                               0xfffff);
+               zfw_ctrl = base_addr + (readl(&firm_id->zfwctrl_addr)& 0xfffff);
                board_ctrl = &zfw_ctrl->board_ctrl;
                ch_ctrl = zfw_ctrl->ch_ctrl;
 
                while (1) {
                        if ((tty->termios->c_cflag & CBAUD)) {
                                cy_writel(&ch_ctrl[channel].rs_control,
-                                         cy_readl(&ch_ctrl[channel].
-                                                  rs_control) | (C_RS_RTS |
-                                                                 C_RS_DTR));
+                                       readl(&ch_ctrl[channel].rs_control) |
+                                       C_RS_RTS | C_RS_DTR);
                                retval = cyz_issue_cmd(&cy_card[info->card],
-                                               channel, C_CM_IOCTLM, 0L);
+                                       channel, C_CM_IOCTLM, 0L);
                                if (retval != 0) {
                                        printk("cyc:block_til_ready retval on "
                                                "ttyC%d was %x\n",
@@ -2481,7 +2464,7 @@ block_til_ready(struct tty_struct *tty, struct file *filp,
                                break;
                        }
                        if (!(info->flags & ASYNC_CLOSING) && (C_CLOCAL(tty) ||
-                                       (cy_readl(&ch_ctrl[channel].rs_status) &
+                                       (readl(&ch_ctrl[channel].rs_status) &
                                                C_RS_DCD))) {
                                break;
                        }
@@ -2498,7 +2481,7 @@ block_til_ready(struct tty_struct *tty, struct file *filp,
                        schedule();
                }
        }
-       current->state = TASK_RUNNING;
+       __set_current_state(TASK_RUNNING);
        remove_wait_queue(&info->open_wait, &wait);
        if (!tty_hung_up_p(filp)) {
                info->count++;
@@ -2546,11 +2529,10 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
                struct FIRM_ID __iomem *firm_id = cinfo->base_addr + ID_ADDRESS;
 
                if (!ISZLOADED(*cinfo)) {
-                       if (((ZE_V1 == cy_readl(
-                                       &((struct RUNTIME_9060 __iomem *)
+                       if (((ZE_V1 == readl(&((struct RUNTIME_9060 __iomem *)
                                         (cinfo->ctl_addr))->mail_box_0)) &&
                                        Z_FPGA_CHECK(*cinfo)) &&
-                                       (ZFIRM_HLT == cy_readl(
+                                       (ZFIRM_HLT == readl(
                                                &firm_id->signature))) {
                                printk("cyc:Cyclades-Z Error: you need an "
                                        "external power supply for this number "
@@ -2571,15 +2553,14 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
                                struct BOARD_CTRL __iomem *board_ctrl;
 
                                zfw_ctrl = cinfo->base_addr +
-                                       (cy_readl(&firm_id->zfwctrl_addr) &
-                                               0xfffff);
+                                       (readl(&firm_id->zfwctrl_addr) &
+                                        0xfffff);
 
                                board_ctrl = &zfw_ctrl->board_ctrl;
 
                                /* Enable interrupts on the PLX chip */
                                cy_writew(cinfo->ctl_addr + 0x68,
-                                         cy_readw(cinfo->ctl_addr +
-                                                  0x68) | 0x0900);
+                                       readw(cinfo->ctl_addr + 0x68) | 0x0900);
                                /* Enable interrupts on the FW */
                                retval = cyz_issue_cmd(cinfo, 0,
                                                C_CM_IRQ_ENBL, 0L);
@@ -2588,7 +2569,7 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
                                                retval);
                                }
                                cinfo->nports =
-                                       (int)cy_readl(&board_ctrl->n_channel);
+                                       (int)readl(&board_ctrl->n_channel);
                                cinfo->intr_enabled = 1;
                        }
                }
@@ -2655,7 +2636,7 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
  */
 static void cy_wait_until_sent(struct tty_struct *tty, int timeout)
 {
-       struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
+       struct cyclades_port *info = tty->driver_data;
        void __iomem *base_addr;
        int card, chip, channel, index;
        unsigned long orig_jiffies;
@@ -2707,7 +2688,7 @@ static void cy_wait_until_sent(struct tty_struct *tty, int timeout)
                index = cy_card[card].bus_index;
                base_addr =
                    cy_card[card].base_addr + (cy_chip_offset[chip] << index);
-               while (cy_readb(base_addr + (CySRER << index)) & CyTxRdy) {
+               while (readb(base_addr + (CySRER << index)) & CyTxRdy) {
 #ifdef CY_DEBUG_WAIT_UNTIL_SENT
                        printk("Not clean (jiff=%lu)...", jiffies);
 #endif
@@ -2732,7 +2713,7 @@ static void cy_wait_until_sent(struct tty_struct *tty, int timeout)
  */
 static void cy_close(struct tty_struct *tty, struct file *filp)
 {
-       struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
+       struct cyclades_port *info = tty->driver_data;
        unsigned long flags;
 
 #ifdef CY_DEBUG_OTHER
@@ -2800,7 +2781,7 @@ static void cy_close(struct tty_struct *tty, struct file *filp)
                channel &= 0x03;
                cy_writeb(base_addr + (CyCAR << index), (u_char) channel);
                cy_writeb(base_addr + (CySRER << index),
-                         cy_readb(base_addr + (CySRER << index)) & ~CyRxData);
+                         readb(base_addr + (CySRER << index)) & ~CyRxData);
                if (info->flags & ASYNC_INITIALIZED) {
                        /* Waiting for on-board buffers to be empty before closing
                           the port */
@@ -2814,12 +2795,12 @@ static void cy_close(struct tty_struct *tty, struct file *filp)
                void __iomem *base_addr = cy_card[info->card].base_addr;
                struct FIRM_ID __iomem *firm_id = base_addr + ID_ADDRESS;
                struct ZFW_CTRL __iomem *zfw_ctrl =
-                   base_addr + (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff);
+                   base_addr + (readl(&firm_id->zfwctrl_addr) & 0xfffff);
                struct CH_CTRL __iomem *ch_ctrl = zfw_ctrl->ch_ctrl;
                int channel = info->line - cy_card[info->card].first_line;
                int retval;
 
-               if (cy_readl(&ch_ctrl[channel].flow_status) != C_FS_TXIDLE) {
+               if (readl(&ch_ctrl[channel].flow_status) != C_FS_TXIDLE) {
                        retval = cyz_issue_cmd(&cy_card[info->card], channel,
                                                C_CM_IOCTLW, 0L);
                        if (retval != 0) {
@@ -2877,7 +2858,7 @@ static void cy_close(struct tty_struct *tty, struct file *filp)
  */
 static int cy_write(struct tty_struct *tty, const unsigned char *buf, int count)
 {
-       struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
+       struct cyclades_port *info = tty->driver_data;
        unsigned long flags;
        int c, ret = 0;
 
@@ -2928,7 +2909,7 @@ static int cy_write(struct tty_struct *tty, const unsigned char *buf, int count)
  */
 static void cy_put_char(struct tty_struct *tty, unsigned char ch)
 {
-       struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
+       struct cyclades_port *info = tty->driver_data;
        unsigned long flags;
 
 #ifdef CY_DEBUG_IO
@@ -2961,7 +2942,7 @@ static void cy_put_char(struct tty_struct *tty, unsigned char ch)
  */
 static void cy_flush_chars(struct tty_struct *tty)
 {
-       struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
+       struct cyclades_port *info = tty->driver_data;
 
 #ifdef CY_DEBUG_IO
        printk("cyc:cy_flush_chars ttyC%d\n", info->line);      /* */
@@ -2985,7 +2966,7 @@ static void cy_flush_chars(struct tty_struct *tty)
  */
 static int cy_write_room(struct tty_struct *tty)
 {
-       struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
+       struct cyclades_port *info = tty->driver_data;
        int ret;
 
 #ifdef CY_DEBUG_IO
@@ -3002,7 +2983,7 @@ static int cy_write_room(struct tty_struct *tty)
 
 static int cy_chars_in_buffer(struct tty_struct *tty)
 {
-       struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
+       struct cyclades_port *info = tty->driver_data;
        int card, channel;
 
        if (serial_paranoia_check(info, tty->name, "cy_chars_in_buffer"))
@@ -3020,22 +3001,22 @@ static int cy_chars_in_buffer(struct tty_struct *tty)
                return info->xmit_cnt;
 #ifdef Z_EXT_CHARS_IN_BUFFER
        } else {
-               static volatile struct FIRM_ID *firm_id;
-               static volatile struct ZFW_CTRL *zfw_ctrl;
-               static volatile struct CH_CTRL *ch_ctrl;
-               static volatile struct BUF_CTRL *buf_ctrl;
+               static struct FIRM_ID *firm_id;
+               static struct ZFW_CTRL *zfw_ctrl;
+               static struct CH_CTRL *ch_ctrl;
+               static struct BUF_CTRL *buf_ctrl;
                int char_count;
-               volatile uclong tx_put, tx_get, tx_bufsize;
+               __u32 tx_put, tx_get, tx_bufsize;
 
                firm_id = cy_card[card].base_addr + ID_ADDRESS;
                zfw_ctrl = cy_card[card].base_addr +
-                       (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff);
+                       (readl(&firm_id->zfwctrl_addr) & 0xfffff);
                ch_ctrl = &(zfw_ctrl->ch_ctrl[channel]);
                buf_ctrl = &(zfw_ctrl->buf_ctrl[channel]);
 
-               tx_get = cy_readl(&buf_ctrl->tx_get);
-               tx_put = cy_readl(&buf_ctrl->tx_put);
-               tx_bufsize = cy_readl(&buf_ctrl->tx_bufsize);
+               tx_get = readl(&buf_ctrl->tx_get);
+               tx_put = readl(&buf_ctrl->tx_put);
+               tx_bufsize = readl(&buf_ctrl->tx_bufsize);
                if (tx_put >= tx_get)
                        char_count = tx_put - tx_get;
                else
@@ -3054,10 +3035,10 @@ static int cy_chars_in_buffer(struct tty_struct *tty)
  * ------------------------------------------------------------
  */
 
-static void cyy_baud_calc(struct cyclades_port *info, uclong baud)
+static void cyy_baud_calc(struct cyclades_port *info, __u32 baud)
 {
        int co, co_val, bpr;
-       uclong cy_clock = ((info->chip_rev >= CD1400_REV_J) ? 60000000 :
+       __u32 cy_clock = ((info->chip_rev >= CD1400_REV_J) ? 60000000 :
                        25000000);
 
        if (baud == 0) {
@@ -3275,8 +3256,7 @@ static void set_line_char(struct cyclades_port *info)
                if (C_CLOCAL(info->tty)) {
                        /* without modem intr */
                        cy_writeb(base_addr + (CySRER << index),
-                                 cy_readb(base_addr +
-                                          (CySRER << index)) | CyMdmCh);
+                               readb(base_addr + (CySRER << index)) | CyMdmCh);
                        /* act on 1->0 modem transitions */
                        if ((cflag & CRTSCTS) && info->rflow) {
                                cy_writeb(base_addr + (CyMCOR1 << index),
@@ -3290,7 +3270,7 @@ static void set_line_char(struct cyclades_port *info)
                } else {
                        /* without modem intr */
                        cy_writeb(base_addr + (CySRER << index),
-                                 cy_readb(base_addr +
+                                 readb(base_addr +
                                           (CySRER << index)) | CyMdmCh);
                        /* act on 1->0 modem transitions */
                        if ((cflag & CRTSCTS) && info->rflow) {
@@ -3317,8 +3297,8 @@ static void set_line_char(struct cyclades_port *info)
 #ifdef CY_DEBUG_DTR
                        printk("cyc:set_line_char dropping DTR\n");
                        printk("     status: 0x%x, 0x%x\n",
-                               cy_readb(base_addr + (CyMSVR1 << index)),
-                               cy_readb(base_addr + (CyMSVR2 << index)));
+                               readb(base_addr + (CyMSVR1 << index)),
+                               readb(base_addr + (CyMSVR2 << index)));
 #endif
                } else {
                        if (info->rtsdtr_inv) {
@@ -3331,8 +3311,8 @@ static void set_line_char(struct cyclades_port *info)
 #ifdef CY_DEBUG_DTR
                        printk("cyc:set_line_char raising DTR\n");
                        printk("     status: 0x%x, 0x%x\n",
-                               cy_readb(base_addr + (CyMSVR1 << index)),
-                               cy_readb(base_addr + (CyMSVR2 << index)));
+                               readb(base_addr + (CyMSVR1 << index)),
+                               readb(base_addr + (CyMSVR2 << index)));
 #endif
                }
 
@@ -3347,7 +3327,7 @@ static void set_line_char(struct cyclades_port *info)
                struct BOARD_CTRL __iomem *board_ctrl;
                struct CH_CTRL __iomem *ch_ctrl;
                struct BUF_CTRL __iomem *buf_ctrl;
-               uclong sw_flow;
+               __u32 sw_flow;
                int retval;
 
                firm_id = cy_card[card].base_addr + ID_ADDRESS;
@@ -3356,7 +3336,7 @@ static void set_line_char(struct cyclades_port *info)
                }
 
                zfw_ctrl = cy_card[card].base_addr +
-                       (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff);
+                       (readl(&firm_id->zfwctrl_addr) & 0xfffff);
                board_ctrl = &zfw_ctrl->board_ctrl;
                ch_ctrl = &(zfw_ctrl->ch_ctrl[channel]);
                buf_ctrl = &zfw_ctrl->buf_ctrl[channel];
@@ -3407,10 +3387,10 @@ static void set_line_char(struct cyclades_port *info)
                }
                if (cflag & CSTOPB) {
                        cy_writel(&ch_ctrl->comm_data_l,
-                                 cy_readl(&ch_ctrl->comm_data_l) | C_DL_2STOP);
+                                 readl(&ch_ctrl->comm_data_l) | C_DL_2STOP);
                } else {
                        cy_writel(&ch_ctrl->comm_data_l,
-                                 cy_readl(&ch_ctrl->comm_data_l) | C_DL_1STOP);
+                                 readl(&ch_ctrl->comm_data_l) | C_DL_1STOP);
                }
                if (cflag & PARENB) {
                        if (cflag & PARODD) {
@@ -3425,12 +3405,10 @@ static void set_line_char(struct cyclades_port *info)
                /* CTS flow control flag */
                if (cflag & CRTSCTS) {
                        cy_writel(&ch_ctrl->hw_flow,
-                                 cy_readl(&ch_ctrl->
-                                          hw_flow) | C_RS_CTS | C_RS_RTS);
+                               readl(&ch_ctrl->hw_flow) | C_RS_CTS | C_RS_RTS);
                } else {
-                       cy_writel(&ch_ctrl->hw_flow,
-                                 cy_readl(&ch_ctrl->
-                                          hw_flow) & ~(C_RS_CTS | C_RS_RTS));
+                       cy_writel(&ch_ctrl->hw_flow, readl(&ch_ctrl->hw_flow) &
+                                       ~(C_RS_CTS | C_RS_RTS));
                }
                /* As the HW flow control is done in firmware, the driver
                   doesn't need to care about it */
@@ -3460,13 +3438,13 @@ static void set_line_char(struct cyclades_port *info)
 
                if (baud == 0) {        /* baud rate is zero, turn off line */
                        cy_writel(&ch_ctrl->rs_control,
-                                 cy_readl(&ch_ctrl->rs_control) & ~C_RS_DTR);
+                                 readl(&ch_ctrl->rs_control) & ~C_RS_DTR);
 #ifdef CY_DEBUG_DTR
                        printk("cyc:set_line_char dropping Z DTR\n");
 #endif
                } else {
                        cy_writel(&ch_ctrl->rs_control,
-                                 cy_readl(&ch_ctrl->rs_control) | C_RS_DTR);
+                                 readl(&ch_ctrl->rs_control) | C_RS_DTR);
 #ifdef CY_DEBUG_DTR
                        printk("cyc:set_line_char raising Z DTR\n");
 #endif
@@ -3500,6 +3478,7 @@ get_serial_info(struct cyclades_port *info,
        tmp.irq = cinfo->irq;
        tmp.flags = info->flags;
        tmp.close_delay = info->close_delay;
+       tmp.closing_wait = info->closing_wait;
        tmp.baud_base = info->baud;
        tmp.custom_divisor = info->custom_divisor;
        tmp.hub6 = 0;           /*!!! */
@@ -3580,7 +3559,7 @@ static int get_lsr_info(struct cyclades_port *info, unsigned int __user * value)
                    cy_card[card].base_addr + (cy_chip_offset[chip] << index);
 
                CY_LOCK(info, flags);
-               status = cy_readb(base_addr + (CySRER << index)) &
+               status = readb(base_addr + (CySRER << index)) &
                                (CyTxRdy | CyTxMpty);
                CY_UNLOCK(info, flags);
                result = (status ? 0 : TIOCSER_TEMT);
@@ -3593,7 +3572,7 @@ static int get_lsr_info(struct cyclades_port *info, unsigned int __user * value)
 
 static int cy_tiocmget(struct tty_struct *tty, struct file *file)
 {
-       struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
+       struct cyclades_port *info = tty->driver_data;
        int card, chip, channel, index;
        void __iomem *base_addr;
        unsigned long flags;
@@ -3619,8 +3598,8 @@ static int cy_tiocmget(struct tty_struct *tty, struct file *file)
 
                CY_LOCK(info, flags);
                cy_writeb(base_addr + (CyCAR << index), (u_char) channel);
-               status = cy_readb(base_addr + (CyMSVR1 << index));
-               status |= cy_readb(base_addr + (CyMSVR2 << index));
+               status = readb(base_addr + (CyMSVR1 << index));
+               status |= readb(base_addr + (CyMSVR2 << index));
                CY_UNLOCK(info, flags);
 
                if (info->rtsdtr_inv) {
@@ -3644,10 +3623,10 @@ static int cy_tiocmget(struct tty_struct *tty, struct file *file)
                firm_id = cy_card[card].base_addr + ID_ADDRESS;
                if (ISZLOADED(cy_card[card])) {
                        zfw_ctrl = cy_card[card].base_addr +
-                               (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff);
+                               (readl(&firm_id->zfwctrl_addr) & 0xfffff);
                        board_ctrl = &zfw_ctrl->board_ctrl;
                        ch_ctrl = zfw_ctrl->ch_ctrl;
-                       lstatus = cy_readl(&ch_ctrl[channel].rs_status);
+                       lstatus = readl(&ch_ctrl[channel].rs_status);
                        result = ((lstatus & C_RS_RTS) ? TIOCM_RTS : 0) |
                                ((lstatus & C_RS_DTR) ? TIOCM_DTR : 0) |
                                ((lstatus & C_RS_DCD) ? TIOCM_CAR : 0) |
@@ -3667,7 +3646,7 @@ static int
 cy_tiocmset(struct tty_struct *tty, struct file *file,
                unsigned int set, unsigned int clear)
 {
-       struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
+       struct cyclades_port *info = tty->driver_data;
        int card, chip, channel, index;
        void __iomem *base_addr;
        unsigned long flags;
@@ -3729,8 +3708,8 @@ cy_tiocmset(struct tty_struct *tty, struct file *file,
 #ifdef CY_DEBUG_DTR
                        printk("cyc:set_modem_info raising DTR\n");
                        printk("     status: 0x%x, 0x%x\n",
-                               cy_readb(base_addr + (CyMSVR1 << index)),
-                               cy_readb(base_addr + (CyMSVR2 << index)));
+                               readb(base_addr + (CyMSVR1 << index)),
+                               readb(base_addr + (CyMSVR2 << index)));
 #endif
                        CY_UNLOCK(info, flags);
                }
@@ -3749,8 +3728,8 @@ cy_tiocmset(struct tty_struct *tty, struct file *file,
 #ifdef CY_DEBUG_DTR
                        printk("cyc:set_modem_info dropping DTR\n");
                        printk("     status: 0x%x, 0x%x\n",
-                               cy_readb(base_addr + (CyMSVR1 << index)),
-                               cy_readb(base_addr + (CyMSVR2 << index)));
+                               readb(base_addr + (CyMSVR1 << index)),
+                               readb(base_addr + (CyMSVR2 << index)));
 #endif
                        CY_UNLOCK(info, flags);
                }
@@ -3760,29 +3739,29 @@ cy_tiocmset(struct tty_struct *tty, struct file *file,
                firm_id = cy_card[card].base_addr + ID_ADDRESS;
                if (ISZLOADED(cy_card[card])) {
                        zfw_ctrl = cy_card[card].base_addr +
-                               (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff);
+                               (readl(&firm_id->zfwctrl_addr) & 0xfffff);
                        board_ctrl = &zfw_ctrl->board_ctrl;
                        ch_ctrl = zfw_ctrl->ch_ctrl;
 
                        if (set & TIOCM_RTS) {
                                CY_LOCK(info, flags);
                                cy_writel(&ch_ctrl[channel].rs_control,
-                                         cy_readl(&ch_ctrl[channel].
-                                                  rs_control) | C_RS_RTS);
+                                       readl(&ch_ctrl[channel].rs_control) |
+                                       C_RS_RTS);
                                CY_UNLOCK(info, flags);
                        }
                        if (clear & TIOCM_RTS) {
                                CY_LOCK(info, flags);
                                cy_writel(&ch_ctrl[channel].rs_control,
-                                         cy_readl(&ch_ctrl[channel].
-                                                  rs_control) & ~C_RS_RTS);
+                                       readl(&ch_ctrl[channel].rs_control) &
+                                       ~C_RS_RTS);
                                CY_UNLOCK(info, flags);
                        }
                        if (set & TIOCM_DTR) {
                                CY_LOCK(info, flags);
                                cy_writel(&ch_ctrl[channel].rs_control,
-                                         cy_readl(&ch_ctrl[channel].
-                                                  rs_control) | C_RS_DTR);
+                                       readl(&ch_ctrl[channel].rs_control) |
+                                       C_RS_DTR);
 #ifdef CY_DEBUG_DTR
                                printk("cyc:set_modem_info raising Z DTR\n");
 #endif
@@ -3791,8 +3770,8 @@ cy_tiocmset(struct tty_struct *tty, struct file *file,
                        if (clear & TIOCM_DTR) {
                                CY_LOCK(info, flags);
                                cy_writel(&ch_ctrl[channel].rs_control,
-                                         cy_readl(&ch_ctrl[channel].
-                                                  rs_control) & ~C_RS_DTR);
+                                       readl(&ch_ctrl[channel].rs_control) &
+                                       ~C_RS_DTR);
 #ifdef CY_DEBUG_DTR
                                printk("cyc:set_modem_info clearing Z DTR\n");
 #endif
@@ -3818,7 +3797,7 @@ cy_tiocmset(struct tty_struct *tty, struct file *file,
  */
 static void cy_break(struct tty_struct *tty, int break_state)
 {
-       struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
+       struct cyclades_port *info = tty->driver_data;
        unsigned long flags;
 
        if (serial_paranoia_check(info, tty->name, "cy_break"))
@@ -3929,7 +3908,7 @@ get_threshold(struct cyclades_port *info, unsigned long __user * value)
                base_addr =
                    cy_card[card].base_addr + (cy_chip_offset[chip] << index);
 
-               tmp = cy_readb(base_addr + (CyCOR3 << index)) & CyREC_FIFO;
+               tmp = readb(base_addr + (CyCOR3 << index)) & CyREC_FIFO;
                return put_user(tmp, value);
        } else {
                /* Nothing to do! */
@@ -3989,7 +3968,7 @@ static int get_timeout(struct cyclades_port *info, unsigned long __user * value)
                base_addr =
                    cy_card[card].base_addr + (cy_chip_offset[chip] << index);
 
-               tmp = cy_readb(base_addr + (CyRTPR << index));
+               tmp = readb(base_addr + (CyRTPR << index));
                return put_user(tmp, value);
        } else {
                /* Nothing to do! */
@@ -4018,7 +3997,7 @@ static int
 cy_ioctl(struct tty_struct *tty, struct file *file,
         unsigned int cmd, unsigned long arg)
 {
-       struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
+       struct cyclades_port *info = tty->driver_data;
        struct cyclades_icount cprev, cnow;     /* kernel counter temps */
        struct serial_icounter_struct __user *p_cuser;  /* user space */
        int ret_val = 0;
@@ -4211,7 +4190,7 @@ cy_ioctl(struct tty_struct *tty, struct file *file,
  */
 static void cy_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
 {
-       struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
+       struct cyclades_port *info = tty->driver_data;
 
 #ifdef CY_DEBUG_OTHER
        printk("cyc:cy_set_termios ttyC%d\n", info->line);
@@ -4246,7 +4225,7 @@ static void cy_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
 */
 static void cy_send_xchar(struct tty_struct *tty, char ch)
 {
-       struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
+       struct cyclades_port *info = tty->driver_data;
        int card, channel;
 
        if (serial_paranoia_check(info, tty->name, "cy_send_xchar"))
@@ -4276,7 +4255,7 @@ static void cy_send_xchar(struct tty_struct *tty, char ch)
  */
 static void cy_throttle(struct tty_struct *tty)
 {
-       struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
+       struct cyclades_port *info = tty->driver_data;
        unsigned long flags;
        void __iomem *base_addr;
        int card, chip, channel, index;
@@ -4334,7 +4313,7 @@ static void cy_throttle(struct tty_struct *tty)
  */
 static void cy_unthrottle(struct tty_struct *tty)
 {
-       struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
+       struct cyclades_port *info = tty->driver_data;
        unsigned long flags;
        void __iomem *base_addr;
        int card, chip, channel, index;
@@ -4390,7 +4369,7 @@ static void cy_unthrottle(struct tty_struct *tty)
 static void cy_stop(struct tty_struct *tty)
 {
        struct cyclades_card *cinfo;
-       struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
+       struct cyclades_port *info = tty->driver_data;
        void __iomem *base_addr;
        int chip, channel, index;
        unsigned long flags;
@@ -4415,7 +4394,7 @@ static void cy_stop(struct tty_struct *tty)
                cy_writeb(base_addr + (CyCAR << index),
                        (u_char)(channel & 0x0003)); /* index channel */
                cy_writeb(base_addr + (CySRER << index),
-                         cy_readb(base_addr + (CySRER << index)) & ~CyTxRdy);
+                         readb(base_addr + (CySRER << index)) & ~CyTxRdy);
                CY_UNLOCK(info, flags);
        } else {
                /* Nothing to do! */
@@ -4425,7 +4404,7 @@ static void cy_stop(struct tty_struct *tty)
 static void cy_start(struct tty_struct *tty)
 {
        struct cyclades_card *cinfo;
-       struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
+       struct cyclades_port *info = tty->driver_data;
        void __iomem *base_addr;
        int chip, channel, index;
        unsigned long flags;
@@ -4449,7 +4428,7 @@ static void cy_start(struct tty_struct *tty)
                CY_LOCK(info, flags);
                cy_writeb(base_addr + (CyCAR << index), (u_char) (channel & 0x0003));   /* index channel */
                cy_writeb(base_addr + (CySRER << index),
-                         cy_readb(base_addr + (CySRER << index)) | CyTxRdy);
+                         readb(base_addr + (CySRER << index)) | CyTxRdy);
                CY_UNLOCK(info, flags);
        } else {
                /* Nothing to do! */
@@ -4458,7 +4437,7 @@ static void cy_start(struct tty_struct *tty)
 
 static void cy_flush_buffer(struct tty_struct *tty)
 {
-       struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
+       struct cyclades_port *info = tty->driver_data;
        int card, channel, retval;
        unsigned long flags;
 
@@ -4495,7 +4474,7 @@ static void cy_flush_buffer(struct tty_struct *tty)
  */
 static void cy_hangup(struct tty_struct *tty)
 {
-       struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
+       struct cyclades_port *info = tty->driver_data;
 
 #ifdef CY_DEBUG_OTHER
        printk("cyc:cy_hangup ttyC%d\n", info->line);   /* */
@@ -4524,6 +4503,159 @@ static void cy_hangup(struct tty_struct *tty)
  * ---------------------------------------------------------------------
  */
 
+static void __devinit cy_init_card(struct cyclades_card *cinfo,
+               const unsigned int board)
+{
+       struct cyclades_port *info;
+       u32 mailbox;
+       unsigned int nports;
+       unsigned short chip_number;
+       int index, port;
+
+       if (cinfo->num_chips == -1) {   /* Cyclades-Z */
+               mailbox = readl(&((struct RUNTIME_9060 __iomem *)
+                                    cinfo->ctl_addr)->mail_box_0);
+               nports = (mailbox == ZE_V1) ? ZE_V1_NPORTS : 8;
+               cinfo->intr_enabled = 0;
+               cinfo->nports = 0;      /* Will be correctly set later, after
+                                          Z FW is loaded */
+               spin_lock_init(&cinfo->card_lock);
+               for (port = cinfo->first_line;
+                    port < cinfo->first_line + nports; port++) {
+                       info = &cy_port[port];
+                       info->magic = CYCLADES_MAGIC;
+                       info->type = PORT_STARTECH;
+                       info->card = board;
+                       info->line = port;
+                       info->chip_rev = 0;
+                       info->flags = STD_COM_FLAGS;
+                       info->tty = NULL;
+                       if (mailbox == ZO_V1)
+                               info->xmit_fifo_size = CYZ_FIFO_SIZE;
+                       else
+                               info->xmit_fifo_size =
+                                   4 * CYZ_FIFO_SIZE;
+                       info->cor1 = 0;
+                       info->cor2 = 0;
+                       info->cor3 = 0;
+                       info->cor4 = 0;
+                       info->cor5 = 0;
+                       info->tbpr = 0;
+                       info->tco = 0;
+                       info->rbpr = 0;
+                       info->rco = 0;
+                       info->custom_divisor = 0;
+                       info->close_delay = 5 * HZ / 10;
+                       info->closing_wait = CLOSING_WAIT_DELAY;
+                       info->icount.cts = info->icount.dsr =
+                           info->icount.rng = info->icount.dcd = 0;
+                       info->icount.rx = info->icount.tx = 0;
+                       info->icount.frame = info->icount.parity = 0;
+                       info->icount.overrun = info->icount.brk = 0;
+                       info->x_char = 0;
+                       info->event = 0;
+                       info->count = 0;
+                       info->blocked_open = 0;
+                       info->default_threshold = 0;
+                       info->default_timeout = 0;
+                       INIT_WORK(&info->tqueue, do_softint);
+                       init_waitqueue_head(&info->open_wait);
+                       init_waitqueue_head(&info->close_wait);
+                       init_waitqueue_head(&info->shutdown_wait);
+                       init_waitqueue_head(&info->delta_msr_wait);
+                       /* info->session */
+                       /* info->pgrp */
+                       info->read_status_mask = 0;
+                       /* info->timeout */
+                       /* Bentson's vars */
+                       info->jiffies[0] = 0;
+                       info->jiffies[1] = 0;
+                       info->jiffies[2] = 0;
+                       info->rflush_count = 0;
+#ifdef CONFIG_CYZ_INTR
+                       init_timer(&cyz_rx_full_timer[port]);
+                       cyz_rx_full_timer[port].function = NULL;
+#endif
+               }
+#ifndef CONFIG_CYZ_INTR
+               if (!timer_pending(&cyz_timerlist)) {
+                       mod_timer(&cyz_timerlist, jiffies + 1);
+#ifdef CY_PCI_DEBUG
+                       printk("Cyclades-Z polling initialized\n");
+#endif
+               }
+#endif                         /* CONFIG_CYZ_INTR */
+
+       } else {        /* Cyclom-Y of some kind */
+               index = cinfo->bus_index;
+               spin_lock_init(&cinfo->card_lock);
+               cinfo->nports = CyPORTS_PER_CHIP * cinfo->num_chips;
+               for (port = cinfo->first_line;
+                    port < cinfo->first_line + cinfo->nports; port++) {
+                       info = &cy_port[port];
+                       info->magic = CYCLADES_MAGIC;
+                       info->type = PORT_CIRRUS;
+                       info->card = board;
+                       info->line = port;
+                       info->flags = STD_COM_FLAGS;
+                       info->tty = NULL;
+                       info->xmit_fifo_size = CyMAX_CHAR_FIFO;
+                       info->cor1 =
+                           CyPARITY_NONE | Cy_1_STOP | Cy_8_BITS;
+                       info->cor2 = CyETC;
+                       info->cor3 = 0x08;      /* _very_ small rcv threshold */
+                       info->cor4 = 0;
+                       info->cor5 = 0;
+                       info->custom_divisor = 0;
+                       info->close_delay = 5 * HZ / 10;
+                       info->closing_wait = CLOSING_WAIT_DELAY;
+                       info->icount.cts = info->icount.dsr =
+                           info->icount.rng = info->icount.dcd = 0;
+                       info->icount.rx = info->icount.tx = 0;
+                       info->icount.frame = info->icount.parity = 0;
+                       info->icount.overrun = info->icount.brk = 0;
+                       chip_number = (port - cinfo->first_line) / 4;
+                       if ((info->chip_rev =
+                            readb(cinfo->base_addr +
+                                     (cy_chip_offset[chip_number] <<
+                                      index) + (CyGFRCR << index))) >=
+                           CD1400_REV_J) {
+                               /* It is a CD1400 rev. J or later */
+                               info->tbpr = baud_bpr_60[13];   /* Tx BPR */
+                               info->tco = baud_co_60[13];     /* Tx CO */
+                               info->rbpr = baud_bpr_60[13];   /* Rx BPR */
+                               info->rco = baud_co_60[13];     /* Rx CO */
+                               info->rflow = 0;
+                               info->rtsdtr_inv = 1;
+                       } else {
+                               info->tbpr = baud_bpr_25[13];   /* Tx BPR */
+                               info->tco = baud_co_25[13];     /* Tx CO */
+                               info->rbpr = baud_bpr_25[13];   /* Rx BPR */
+                               info->rco = baud_co_25[13];     /* Rx CO */
+                               info->rflow = 0;
+                               info->rtsdtr_inv = 0;
+                       }
+                       info->x_char = 0;
+                       info->event = 0;
+                       info->count = 0;
+                       info->blocked_open = 0;
+                       info->default_threshold = 0;
+                       info->default_timeout = 0;
+                       INIT_WORK(&info->tqueue, do_softint);
+                       init_waitqueue_head(&info->open_wait);
+                       init_waitqueue_head(&info->close_wait);
+                       init_waitqueue_head(&info->shutdown_wait);
+                       init_waitqueue_head(&info->delta_msr_wait);
+                       /* info->session */
+                       /* info->pgrp */
+                       info->read_status_mask =
+                           CyTIMEOUT | CySPECHAR | CyBREAK
+                           | CyPARITY | CyFRAME | CyOVERRUN;
+                       /* info->timeout */
+               }
+       }
+}
+
 /* initialize chips on Cyclom-Y card -- return number of valid
    chips (which is number of ports/4) */
 static unsigned short __init
@@ -4542,7 +4674,7 @@ cyy_init_card(void __iomem * true_base_addr, int index)
                base_addr =
                    true_base_addr + (cy_chip_offset[chip_number] << index);
                mdelay(1);
-               if (cy_readb(base_addr + (CyCCR << index)) != 0x00) {
+               if (readb(base_addr + (CyCCR << index)) != 0x00) {
                        /*************
                        printk(" chip #%d at %#6lx is never idle (CCR != 0)\n",
                        chip_number, (unsigned long)base_addr);
@@ -4559,7 +4691,7 @@ cyy_init_card(void __iomem * true_base_addr, int index)
                   chip 4 GFRCR register appears at chip 0, there is no chip 4
                   and this must be a Cyclom-16Y, not a Cyclom-32Ye.
                 */
-               if (chip_number == 4 && cy_readb(true_base_addr +
+               if (chip_number == 4 && readb(true_base_addr +
                                (cy_chip_offset[0] << index) +
                                (CyGFRCR << index)) == 0) {
                        return chip_number;
@@ -4568,7 +4700,7 @@ cyy_init_card(void __iomem * true_base_addr, int index)
                cy_writeb(base_addr + (CyCCR << index), CyCHIP_RESET);
                mdelay(1);
 
-               if (cy_readb(base_addr + (CyGFRCR << index)) == 0x00) {
+               if (readb(base_addr + (CyGFRCR << index)) == 0x00) {
                        /*
                           printk(" chip #%d at %#6lx is not responding ",
                           chip_number, (unsigned long)base_addr);
@@ -4576,7 +4708,7 @@ cyy_init_card(void __iomem * true_base_addr, int index)
                         */
                        return chip_number;
                }
-               if ((0xf0 & (cy_readb(base_addr + (CyGFRCR << index)))) !=
+               if ((0xf0 & (readb(base_addr + (CyGFRCR << index)))) !=
                                0x40) {
                        /*
                        printk(" chip #%d at %#6lx is not valid (GFRCR == "
@@ -4587,7 +4719,7 @@ cyy_init_card(void __iomem * true_base_addr, int index)
                        return chip_number;
                }
                cy_writeb(base_addr + (CyGCR << index), CyCH0_SERIAL);
-               if (cy_readb(base_addr + (CyGFRCR << index)) >= CD1400_REV_J) {
+               if (readb(base_addr + (CyGFRCR << index)) >= CD1400_REV_J) {
                        /* It is a CD1400 rev. J or later */
                        /* Impossible to reach 5ms with this chip.
                           Changed to 2ms instead (f = 500 Hz). */
@@ -4600,7 +4732,7 @@ cyy_init_card(void __iomem * true_base_addr, int index)
                /*
                   printk(" chip #%d at %#6lx is rev 0x%2x\n",
                   chip_number, (unsigned long)base_addr,
-                  cy_readb(base_addr+(CyGFRCR<<index)));
+                  readb(base_addr+(CyGFRCR<<index)));
                 */
        }
        return chip_number;
@@ -4702,6 +4834,7 @@ static int __init cy_detect_isa(void)
                cy_card[j].bus_index = 0;
                cy_card[j].first_line = cy_next_channel;
                cy_card[j].num_chips = cy_isa_nchan / 4;
+               cy_init_card(&cy_card[j], j);
                nboard++;
 
                /* print message */
@@ -4719,425 +4852,380 @@ static int __init cy_detect_isa(void)
 #endif                         /* CONFIG_ISA */
 }                              /* cy_detect_isa */
 
-static void plx_init(void __iomem * addr, uclong initctl)
+#ifdef CONFIG_PCI
+static void __devinit plx_init(void __iomem * addr, __u32 initctl)
 {
        /* Reset PLX */
-       cy_writel(addr + initctl, cy_readl(addr + initctl) | 0x40000000);
+       cy_writel(addr + initctl, readl(addr + initctl) | 0x40000000);
        udelay(100L);
-       cy_writel(addr + initctl, cy_readl(addr + initctl) & ~0x40000000);
+       cy_writel(addr + initctl, readl(addr + initctl) & ~0x40000000);
 
        /* Reload Config. Registers from EEPROM */
-       cy_writel(addr + initctl, cy_readl(addr + initctl) | 0x20000000);
+       cy_writel(addr + initctl, readl(addr + initctl) | 0x20000000);
        udelay(100L);
-       cy_writel(addr + initctl, cy_readl(addr + initctl) & ~0x20000000);
+       cy_writel(addr + initctl, readl(addr + initctl) & ~0x20000000);
 }
 
-/*
- * ---------------------------------------------------------------------
- * cy_detect_pci() - Test PCI bus presence and Cyclom-Ye/PCI.
- * sets global variables and return the number of PCI boards found.
- * ---------------------------------------------------------------------
- */
-static int __init cy_detect_pci(void)
+static int __devinit cy_init_Ze(unsigned long cy_pci_phys0,
+               unsigned long cy_pci_phys2,
+               struct RUNTIME_9060 __iomem *cy_pci_addr0,
+               int cy_pci_irq, struct pci_dev *pdev)
 {
-#ifdef CONFIG_PCI
+       void __iomem *cy_pci_addr2;
+       unsigned int j;
+       unsigned short cy_pci_nchan;
 
-       struct pci_dev *pdev = NULL;
-       unsigned char cyy_rev_id;
-       unsigned char cy_pci_irq = 0;
-       uclong cy_pci_phys0, cy_pci_phys2;
-       void __iomem *cy_pci_addr0, *cy_pci_addr2;
-       unsigned short i, j, cy_pci_nchan, plx_ver;
-       unsigned short device_id, dev_index = 0;
-       uclong mailbox;
-       uclong ZeIndex = 0;
-       void __iomem *Ze_addr0[NR_CARDS], *Ze_addr2[NR_CARDS];
-       uclong Ze_phys0[NR_CARDS], Ze_phys2[NR_CARDS];
-       unsigned char Ze_irq[NR_CARDS];
-       struct pci_dev *Ze_pdev[NR_CARDS];
+       cy_pci_addr2 = pci_iomap(pdev, 2, CyPCI_Ze_win);
 
-       for (i = 0; i < NR_CARDS; i++) {
-               /* look for a Cyclades card by vendor and device id */
-               while ((device_id = cy_pci_dev_id[dev_index]) != 0) {
-                       if ((pdev = pci_get_device(PCI_VENDOR_ID_CYCLADES,
-                                                  device_id, pdev)) == NULL) {
-                               dev_index++;    /* try next device id */
-                       } else {
-                               break;  /* found a board */
-                       }
-               }
+       readl(&cy_pci_addr0->mail_box_0);
+#ifdef CY_PCI_DEBUG
+       printk("Cyclades-Z/PCI: relocate winaddr=0x%lx ctladdr=0x%lx\n",
+               (ulong)cy_pci_addr2, (ulong)cy_pci_addr0);
+       printk("Cyclades-Z/PCI: New Cyclades-Z board.  FPGA not "
+                       "loaded\n");
+#endif
+       /* This must be the new Cyclades-Ze/PCI. */
+       cy_pci_nchan = ZE_V1_NPORTS;
+
+       if ((cy_next_channel + cy_pci_nchan) > NR_PORTS) {
+               printk("Cyclades-Ze/PCI found at 0x%lx but no channels "
+                       "are available.\nChange NR_PORTS in cyclades.c "
+                       "and recompile kernel.\n",
+                       (ulong) cy_pci_phys2);
+               return -EIO;
+       }
 
-               if (device_id == 0)
+       /* fill the next cy_card structure available */
+       for (j = 0; j < NR_CARDS; j++) {
+               if (cy_card[j].base_addr == 0)
                        break;
+       }
+       if (j == NR_CARDS) {    /* no more cy_cards available */
+               printk("Cyclades-Ze/PCI found at 0x%lx but no more "
+                       "cards can be used.\nChange NR_CARDS in "
+                       "cyclades.c and recompile kernel.\n",
+                       (ulong) cy_pci_phys2);
+               return -EIO;
+       }
+#ifdef CONFIG_CYZ_INTR
+       /* allocate IRQ only if board has an IRQ */
+       if ((cy_pci_irq != 0) && (cy_pci_irq != 255)) {
+               if (request_irq(cy_pci_irq, cyz_interrupt,
+                               IRQF_SHARED, "Cyclades-Z",
+                               &cy_card[j])) {
+                       printk("Cyclom-Ze/PCI found at 0x%lx ",
+                               (ulong) cy_pci_phys2);
+                       printk("but could not allocate IRQ%d.\n",
+                               cy_pci_irq);
+                       return -EIO;
+               }
+       }
+#endif                         /* CONFIG_CYZ_INTR */
 
-               if (pci_enable_device(pdev))
-                       continue;
+       /* set cy_card */
+       cy_card[j].base_phys = cy_pci_phys2;
+       cy_card[j].ctl_phys = cy_pci_phys0;
+       cy_card[j].base_addr = cy_pci_addr2;
+       cy_card[j].ctl_addr = cy_pci_addr0;
+       cy_card[j].irq = (int)cy_pci_irq;
+       cy_card[j].bus_index = 1;
+       cy_card[j].first_line = cy_next_channel;
+       cy_card[j].num_chips = -1;
+       cy_card[j].pdev = pdev;
+       cy_init_card(&cy_card[j], j);
+       pci_set_drvdata(pdev, &cy_card[j]);
+
+       /* print message */
+#ifdef CONFIG_CYZ_INTR
+       /* don't report IRQ if board is no IRQ */
+       if ((cy_pci_irq != 0) && (cy_pci_irq != 255))
+               printk("Cyclades-Ze/PCI #%d: 0x%lx-0x%lx, IRQ%d, ",
+                       j + 1, (ulong) cy_pci_phys2,
+                       (ulong) (cy_pci_phys2 + CyPCI_Ze_win - 1),
+                       (int)cy_pci_irq);
+       else
+#endif                         /* CONFIG_CYZ_INTR */
+               printk("Cyclades-Ze/PCI #%d: 0x%lx-0x%lx, ",
+                       j + 1, (ulong) cy_pci_phys2,
+                       (ulong) (cy_pci_phys2 + CyPCI_Ze_win - 1));
+
+       printk("%d channels starting from port %d.\n",
+               cy_pci_nchan, cy_next_channel);
+       cy_next_channel += cy_pci_nchan;
+
+       return 0;
+}
+
+static int __devinit cy_pci_probe(struct pci_dev *pdev,
+               const struct pci_device_id *ent)
+{
+       unsigned char cyy_rev_id;
+       unsigned char cy_pci_irq;
+       __u32 cy_pci_phys0, cy_pci_phys2, mailbox;
+       void __iomem *cy_pci_addr0, *cy_pci_addr2;
+       unsigned int device_id;
+       unsigned short j, cy_pci_nchan, plx_ver;
+       int retval;
+
+       retval = pci_enable_device(pdev);
+       if (retval) {
+               dev_err(&pdev->dev, "cannot enable device\n");
+               return retval;
+       }
 
-               /* read PCI configuration area */
-               cy_pci_irq = pdev->irq;
-               cy_pci_phys0 = pci_resource_start(pdev, 0);
-               cy_pci_phys2 = pci_resource_start(pdev, 2);
-               pci_read_config_byte(pdev, PCI_REVISION_ID, &cyy_rev_id);
+       /* read PCI configuration area */
+       cy_pci_irq = pdev->irq;
+       cy_pci_phys0 = pci_resource_start(pdev, 0);
+       cy_pci_phys2 = pci_resource_start(pdev, 2);
+       pci_read_config_byte(pdev, PCI_REVISION_ID, &cyy_rev_id);
 
-               device_id &= ~PCI_DEVICE_ID_MASK;
+       device_id = pdev->device & ~PCI_DEVICE_ID_MASK;
 
-               if (device_id == PCI_DEVICE_ID_CYCLOM_Y_Lo ||
-                               device_id == PCI_DEVICE_ID_CYCLOM_Y_Hi) {
+       if (device_id == PCI_DEVICE_ID_CYCLOM_Y_Lo ||
+                       device_id == PCI_DEVICE_ID_CYCLOM_Y_Hi) {
 #ifdef CY_PCI_DEBUG
+               printk("Cyclom-Y/PCI (bus=0x0%x, pci_id=0x%x, ",
+                       pdev->bus->number, pdev->devfn);
+               printk("rev_id=%d) IRQ%d\n",
+                       cyy_rev_id, (int)cy_pci_irq);
+               printk("Cyclom-Y/PCI:found  winaddr=0x%lx "
+                       "ctladdr=0x%lx\n",
+                       (ulong)cy_pci_phys2, (ulong)cy_pci_phys0);
+#endif
+
+               if (pci_resource_flags(pdev, 2) & IORESOURCE_IO) {
+                       printk("  Warning: PCI I/O bit incorrectly "
+                               "set. Ignoring it...\n");
+                       pdev->resource[2].flags &= ~IORESOURCE_IO;
+               }
+
+               /* Although we don't use this I/O region, we should
+                  request it from the kernel anyway, to avoid problems
+                  with other drivers accessing it. */
+               retval = pci_request_regions(pdev, "Cyclom-Y");
+               if (retval) {
+                       printk(KERN_ERR "cyclades: failed to reserve "
+                                       "PCI resources\n");
+                       return retval;
+               }
+#if defined(__alpha__)
+               if (device_id == PCI_DEVICE_ID_CYCLOM_Y_Lo) {   /* below 1M? */
                        printk("Cyclom-Y/PCI (bus=0x0%x, pci_id=0x%x, ",
                                pdev->bus->number, pdev->devfn);
                        printk("rev_id=%d) IRQ%d\n",
                                cyy_rev_id, (int)cy_pci_irq);
                        printk("Cyclom-Y/PCI:found  winaddr=0x%lx "
                                "ctladdr=0x%lx\n",
-                               (ulong)cy_pci_phys2, (ulong)cy_pci_phys0);
-#endif
-
-                       if (pci_resource_flags(pdev, 2) & IORESOURCE_IO) {
-                               printk("  Warning: PCI I/O bit incorrectly "
-                                       "set. Ignoring it...\n");
-                               pdev->resource[2].flags &= ~IORESOURCE_IO;
-                       }
-
-                       /* Although we don't use this I/O region, we should
-                          request it from the kernel anyway, to avoid problems
-                          with other drivers accessing it. */
-                       if (pci_request_regions(pdev, "Cyclom-Y") != 0) {
-                               printk(KERN_ERR "cyclades: failed to reserve "
-                                               "PCI resources\n");
-                               continue;
-                       }
-#if defined(__alpha__)
-                       if (device_id == PCI_DEVICE_ID_CYCLOM_Y_Lo) {   /* below 1M? */
-                               printk("Cyclom-Y/PCI (bus=0x0%x, pci_id=0x%x, ",
-                                       pdev->bus->number, pdev->devfn);
-                               printk("rev_id=%d) IRQ%d\n",
-                                       cyy_rev_id, (int)cy_pci_irq);
-                               printk("Cyclom-Y/PCI:found  winaddr=0x%lx "
-                                       "ctladdr=0x%lx\n",
-                                       (ulong)cy_pci_phys2,
-                                       (ulong)cy_pci_phys0);
-                               printk("Cyclom-Y/PCI not supported for low "
-                                       "addresses in Alpha systems.\n");
-                               i--;
-                               continue;
-                       }
+                               (ulong)cy_pci_phys2,
+                               (ulong)cy_pci_phys0);
+                       printk("Cyclom-Y/PCI not supported for low "
+                               "addresses in Alpha systems.\n");
+                       return -EIO;
+               }
 #endif
-                       cy_pci_addr0 = ioremap(cy_pci_phys0, CyPCI_Yctl);
-                       cy_pci_addr2 = ioremap(cy_pci_phys2, CyPCI_Ywin);
+               cy_pci_addr0 = pci_iomap(pdev, 0, CyPCI_Yctl);
+               cy_pci_addr2 = pci_iomap(pdev, 2, CyPCI_Ywin);
 
 #ifdef CY_PCI_DEBUG
-                       printk("Cyclom-Y/PCI: relocate winaddr=0x%lx "
-                               "ctladdr=0x%lx\n",
-                               (u_long)cy_pci_addr2, (u_long)cy_pci_addr0);
+               printk("Cyclom-Y/PCI: relocate winaddr=0x%lx "
+                       "ctladdr=0x%lx\n",
+                       (u_long)cy_pci_addr2, (u_long)cy_pci_addr0);
 #endif
-                       cy_pci_nchan = (unsigned short)(CyPORTS_PER_CHIP *
-                                       cyy_init_card(cy_pci_addr2, 1));
-                       if (cy_pci_nchan == 0) {
-                               printk("Cyclom-Y PCI host card with ");
-                               printk("no Serial-Modules at 0x%lx.\n",
-                                       (ulong) cy_pci_phys2);
-                               i--;
-                               continue;
-                       }
-                       if ((cy_next_channel + cy_pci_nchan) > NR_PORTS) {
-                               printk("Cyclom-Y/PCI found at 0x%lx ",
-                                       (ulong) cy_pci_phys2);
-                               printk("but no channels are available.\n");
-                               printk("Change NR_PORTS in cyclades.c and "
-                                               "recompile kernel.\n");
-                               return i;
-                       }
-                       /* fill the next cy_card structure available */
-                       for (j = 0; j < NR_CARDS; j++) {
-                               if (cy_card[j].base_addr == 0)
-                                       break;
-                       }
-                       if (j == NR_CARDS) {    /* no more cy_cards available */
-                               printk("Cyclom-Y/PCI found at 0x%lx ",
-                                       (ulong) cy_pci_phys2);
-                               printk("but no more cards can be used.\n");
-                               printk("Change NR_CARDS in cyclades.c and "
-                                               "recompile kernel.\n");
-                               return i;
-                       }
-
-                       /* allocate IRQ */
-                       if (request_irq(cy_pci_irq, cyy_interrupt,
-                                       IRQF_SHARED, "Cyclom-Y", &cy_card[j])) {
-                               printk("Cyclom-Y/PCI found at 0x%lx ",
-                                       (ulong) cy_pci_phys2);
-                               printk("but could not allocate IRQ%d.\n",
-                                       cy_pci_irq);
-                               return i;
-                       }
-
-                       /* set cy_card */
-                       cy_card[j].base_phys = (ulong) cy_pci_phys2;
-                       cy_card[j].ctl_phys = (ulong) cy_pci_phys0;
-                       cy_card[j].base_addr = cy_pci_addr2;
-                       cy_card[j].ctl_addr = cy_pci_addr0;
-                       cy_card[j].irq = (int)cy_pci_irq;
-                       cy_card[j].bus_index = 1;
-                       cy_card[j].first_line = cy_next_channel;
-                       cy_card[j].num_chips = cy_pci_nchan / 4;
-                       cy_card[j].pdev = pdev;
-
-                       /* enable interrupts in the PCI interface */
-                       plx_ver = cy_readb(cy_pci_addr2 + CyPLX_VER) & 0x0f;
-                       switch (plx_ver) {
-                       case PLX_9050:
-
-                               cy_writeb(cy_pci_addr0 + 0x4c, 0x43);
+               cy_pci_nchan = (unsigned short)(CyPORTS_PER_CHIP *
+                               cyy_init_card(cy_pci_addr2, 1));
+               if (cy_pci_nchan == 0) {
+                       printk("Cyclom-Y PCI host card with ");
+                       printk("no Serial-Modules at 0x%lx.\n",
+                               (ulong) cy_pci_phys2);
+                       return -EIO;
+               }
+               if ((cy_next_channel + cy_pci_nchan) > NR_PORTS) {
+                       printk("Cyclom-Y/PCI found at 0x%lx ",
+                               (ulong) cy_pci_phys2);
+                       printk("but no channels are available.\n");
+                       printk("Change NR_PORTS in cyclades.c and "
+                                       "recompile kernel.\n");
+                       return -EIO;
+               }
+               /* fill the next cy_card structure available */
+               for (j = 0; j < NR_CARDS; j++) {
+                       if (cy_card[j].base_addr == 0)
                                break;
+               }
+               if (j == NR_CARDS) {    /* no more cy_cards available */
+                       printk("Cyclom-Y/PCI found at 0x%lx ",
+                               (ulong) cy_pci_phys2);
+                       printk("but no more cards can be used.\n");
+                       printk("Change NR_CARDS in cyclades.c and "
+                                       "recompile kernel.\n");
+                       return -EIO;
+               }
 
-                       case PLX_9060:
-                       case PLX_9080:
-                       default:        /* Old boards, use PLX_9060 */
-
-                               plx_init(cy_pci_addr0, 0x6c);
-                       /* For some yet unknown reason, once the PLX9060 reloads
-                          the EEPROM, the IRQ is lost and, thus, we have to
-                          re-write it to the PCI config. registers.
-                          This will remain here until we find a permanent
-                          fix. */
-                               pci_write_config_byte(pdev, PCI_INTERRUPT_LINE,
-                                               cy_pci_irq);
-
-                               cy_writew(cy_pci_addr0 + 0x68,
-                                         cy_readw(cy_pci_addr0 +
-                                                  0x68) | 0x0900);
-                               break;
-                       }
+               /* allocate IRQ */
+               retval = request_irq(cy_pci_irq, cyy_interrupt,
+                               IRQF_SHARED, "Cyclom-Y", &cy_card[j]);
+               if (retval) {
+                       printk("Cyclom-Y/PCI found at 0x%lx ",
+                               (ulong) cy_pci_phys2);
+                       printk("but could not allocate IRQ%d.\n",
+                               cy_pci_irq);
+                       return retval;
+               }
 
-                       /* print message */
-                       printk("Cyclom-Y/PCI #%d: 0x%lx-0x%lx, IRQ%d, ",
-                               j + 1, (ulong)cy_pci_phys2,
-                               (ulong) (cy_pci_phys2 + CyPCI_Ywin - 1),
-                               (int)cy_pci_irq);
-                       printk("%d channels starting from port %d.\n",
-                               cy_pci_nchan, cy_next_channel);
+               /* set cy_card */
+               cy_card[j].base_phys = (ulong) cy_pci_phys2;
+               cy_card[j].ctl_phys = (ulong) cy_pci_phys0;
+               cy_card[j].base_addr = cy_pci_addr2;
+               cy_card[j].ctl_addr = cy_pci_addr0;
+               cy_card[j].irq = (int)cy_pci_irq;
+               cy_card[j].bus_index = 1;
+               cy_card[j].first_line = cy_next_channel;
+               cy_card[j].num_chips = cy_pci_nchan / 4;
+               cy_card[j].pdev = pdev;
+               cy_init_card(&cy_card[j], j);
+               pci_set_drvdata(pdev, &cy_card[j]);
 
-                       cy_next_channel += cy_pci_nchan;
-               } else if (device_id == PCI_DEVICE_ID_CYCLOM_Z_Lo) {
-                       /* print message */
-                       printk("Cyclades-Z/PCI (bus=0x0%x, pci_id=0x%x, ",
-                               pdev->bus->number, pdev->devfn);
-                       printk("rev_id=%d) IRQ%d\n",
-                               cyy_rev_id, (int)cy_pci_irq);
-                       printk("Cyclades-Z/PCI: found winaddr=0x%lx "
-                               "ctladdr=0x%lx\n",
-                               (ulong)cy_pci_phys2, (ulong)cy_pci_phys0);
-                       printk("Cyclades-Z/PCI not supported for low "
-                               "addresses\n");
+               /* enable interrupts in the PCI interface */
+               plx_ver = readb(cy_pci_addr2 + CyPLX_VER) & 0x0f;
+               switch (plx_ver) {
+               case PLX_9050:
+
+                       cy_writeb(cy_pci_addr0 + 0x4c, 0x43);
                        break;
-               } else if (device_id == PCI_DEVICE_ID_CYCLOM_Z_Hi) {
-#ifdef CY_PCI_DEBUG
-                       printk("Cyclades-Z/PCI (bus=0x0%x, pci_id=0x%x, ",
-                               pdev->bus->number, pdev->devfn);
-                       printk("rev_id=%d) IRQ%d\n",
-                               cyy_rev_id, (int)cy_pci_irq);
-                       printk("Cyclades-Z/PCI: found winaddr=0x%lx "
-                               "ctladdr=0x%lx\n",
-                               (ulong) cy_pci_phys2, (ulong) cy_pci_phys0);
-#endif
-                       cy_pci_addr0 = ioremap(cy_pci_phys0, CyPCI_Zctl);
 
-                       /* Disable interrupts on the PLX before resetting it */
-                       cy_writew(cy_pci_addr0 + 0x68,
-                               cy_readw(cy_pci_addr0 + 0x68) & ~0x0900);
+               case PLX_9060:
+               case PLX_9080:
+               default:        /* Old boards, use PLX_9060 */
 
                        plx_init(cy_pci_addr0, 0x6c);
-                       /* For some yet unknown reason, once the PLX9060 reloads
-                          the EEPROM, the IRQ is lost and, thus, we have to
-                          re-write it to the PCI config. registers.
-                          This will remain here until we find a permanent
-                          fix. */
+               /* For some yet unknown reason, once the PLX9060 reloads
+                  the EEPROM, the IRQ is lost and, thus, we have to
+                  re-write it to the PCI config. registers.
+                  This will remain here until we find a permanent
+                  fix. */
                        pci_write_config_byte(pdev, PCI_INTERRUPT_LINE,
-                                               cy_pci_irq);
-
-                       mailbox =
-                           (uclong)cy_readl(&((struct RUNTIME_9060 __iomem *)
-                                               cy_pci_addr0)->mail_box_0);
-
-                       if (pci_resource_flags(pdev, 2) & IORESOURCE_IO) {
-                               printk("  Warning: PCI I/O bit incorrectly "
-                                       "set. Ignoring it...\n");
-                               pdev->resource[2].flags &= ~IORESOURCE_IO;
-                       }
+                                       cy_pci_irq);
 
-                       /* Although we don't use this I/O region, we should
-                          request it from the kernel anyway, to avoid problems
-                          with other drivers accessing it. */
-                       if (pci_request_regions(pdev, "Cyclades-Z") != 0) {
-                               printk(KERN_ERR "cyclades: failed to reserve "
-                                       "PCI resources\n");
-                               continue;
-                       }
+                       cy_writew(cy_pci_addr0 + 0x68,
+                               readw(cy_pci_addr0 + 0x68) | 0x0900);
+                       break;
+               }
 
-                       if (mailbox == ZE_V1) {
-                               cy_pci_addr2 = ioremap(cy_pci_phys2,
-                                               CyPCI_Ze_win);
-                               if (ZeIndex == NR_CARDS) {
-                                       printk("Cyclades-Ze/PCI found at "
-                                               "0x%lx but no more cards can "
-                                               "be used.\nChange NR_CARDS in "
-                                               "cyclades.c and recompile "
-                                               "kernel.\n",
-                                               (ulong)cy_pci_phys2);
-                               } else {
-                                       Ze_phys0[ZeIndex] = cy_pci_phys0;
-                                       Ze_phys2[ZeIndex] = cy_pci_phys2;
-                                       Ze_addr0[ZeIndex] = cy_pci_addr0;
-                                       Ze_addr2[ZeIndex] = cy_pci_addr2;
-                                       Ze_irq[ZeIndex] = cy_pci_irq;
-                                       Ze_pdev[ZeIndex] = pdev;
-                                       ZeIndex++;
-                               }
-                               i--;
-                               continue;
-                       } else {
-                               cy_pci_addr2 = ioremap(cy_pci_phys2,CyPCI_Zwin);
-                       }
+               /* print message */
+               printk("Cyclom-Y/PCI #%d: 0x%lx-0x%lx, IRQ%d, ",
+                       j + 1, (ulong)cy_pci_phys2,
+                       (ulong) (cy_pci_phys2 + CyPCI_Ywin - 1),
+                       (int)cy_pci_irq);
+               printk("%d channels starting from port %d.\n",
+                       cy_pci_nchan, cy_next_channel);
 
+               cy_next_channel += cy_pci_nchan;
+       } else if (device_id == PCI_DEVICE_ID_CYCLOM_Z_Lo) {
+               /* print message */
+               printk("Cyclades-Z/PCI (bus=0x0%x, pci_id=0x%x, ",
+                       pdev->bus->number, pdev->devfn);
+               printk("rev_id=%d) IRQ%d\n",
+                       cyy_rev_id, (int)cy_pci_irq);
+               printk("Cyclades-Z/PCI: found winaddr=0x%lx "
+                       "ctladdr=0x%lx\n",
+                       (ulong)cy_pci_phys2, (ulong)cy_pci_phys0);
+               printk("Cyclades-Z/PCI not supported for low "
+                       "addresses\n");
+               return -EIO;
+       } else if (device_id == PCI_DEVICE_ID_CYCLOM_Z_Hi) {
 #ifdef CY_PCI_DEBUG
-                       printk("Cyclades-Z/PCI: relocate winaddr=0x%lx "
-                               "ctladdr=0x%lx\n",
-                               (ulong) cy_pci_addr2, (ulong) cy_pci_addr0);
-                       if (mailbox == ZO_V1) {
-                               cy_writel(&((struct RUNTIME_9060 *)
-                                       (cy_pci_addr0))->loc_addr_base,
-                                       WIN_CREG);
-                               PAUSE;
-                               printk("Cyclades-8Zo/PCI: FPGA id %lx, ver "
-                                       "%lx\n", (ulong) (0xff &
-                                       cy_readl(&((struct CUSTOM_REG *)
-                                               (cy_pci_addr2))->fpga_id)),
-                                       (ulong)(0xff &
-                                       cy_readl(&((struct CUSTOM_REG *)
-                                               (cy_pci_addr2))->
-                                                       fpga_version)));
-                               cy_writel(&((struct RUNTIME_9060 *)
-                                       (cy_pci_addr0))->loc_addr_base,
-                                       WIN_RAM);
-                       } else {
-                               printk("Cyclades-Z/PCI: New Cyclades-Z board.  "
-                                               "FPGA not loaded\n");
-                       }
+               printk("Cyclades-Z/PCI (bus=0x0%x, pci_id=0x%x, ",
+                       pdev->bus->number, pdev->devfn);
+               printk("rev_id=%d) IRQ%d\n",
+                       cyy_rev_id, (int)cy_pci_irq);
+               printk("Cyclades-Z/PCI: found winaddr=0x%lx "
+                       "ctladdr=0x%lx\n",
+                       (ulong) cy_pci_phys2, (ulong) cy_pci_phys0);
 #endif
-                       /* The following clears the firmware id word.  This
-                          ensures that the driver will not attempt to talk to
-                          the board until it has been properly initialized.
-                        */
-                       PAUSE;
-                       if ((mailbox == ZO_V1) || (mailbox == ZO_V2))
-                               cy_writel(cy_pci_addr2 + ID_ADDRESS, 0L);
-
-                       /* This must be a Cyclades-8Zo/PCI.  The extendable
-                          version will have a different device_id and will
-                          be allocated its maximum number of ports. */
-                       cy_pci_nchan = 8;
-
-                       if ((cy_next_channel + cy_pci_nchan) > NR_PORTS) {
-                               printk("Cyclades-8Zo/PCI found at 0x%lx but"
-                                       "no channels are available.\nChange "
-                                       "NR_PORTS in cyclades.c and recompile "
-                                       "kernel.\n", (ulong)cy_pci_phys2);
-                               return i;
-                       }
+               cy_pci_addr0 = pci_iomap(pdev, 0, CyPCI_Zctl);
+
+               /* Disable interrupts on the PLX before resetting it */
+               cy_writew(cy_pci_addr0 + 0x68,
+                       readw(cy_pci_addr0 + 0x68) & ~0x0900);
+
+               plx_init(cy_pci_addr0, 0x6c);
+               /* For some yet unknown reason, once the PLX9060 reloads
+                  the EEPROM, the IRQ is lost and, thus, we have to
+                  re-write it to the PCI config. registers.
+                  This will remain here until we find a permanent
+                  fix. */
+               pci_write_config_byte(pdev, PCI_INTERRUPT_LINE,
+                                       cy_pci_irq);
 
-                       /* fill the next cy_card structure available */
-                       for (j = 0; j < NR_CARDS; j++) {
-                               if (cy_card[j].base_addr == 0)
-                                       break;
-                       }
-                       if (j == NR_CARDS) {    /* no more cy_cards available */
-                               printk("Cyclades-8Zo/PCI found at 0x%lx but"
-                                       "no more cards can be used.\nChange "
-                                       "NR_CARDS in cyclades.c and recompile "
-                                       "kernel.\n", (ulong)cy_pci_phys2);
-                               return i;
-                       }
-#ifdef CONFIG_CYZ_INTR
-                       /* allocate IRQ only if board has an IRQ */
-                       if ((cy_pci_irq != 0) && (cy_pci_irq != 255)) {
-                               if (request_irq(cy_pci_irq, cyz_interrupt,
-                                               IRQF_SHARED, "Cyclades-Z",
-                                               &cy_card[j])) {
-                                       printk("Cyclom-8Zo/PCI found at 0x%lx "
-                                               "but could not allocate "
-                                               "IRQ%d.\n", (ulong)cy_pci_phys2,
-                                               cy_pci_irq);
-                                       return i;
-                               }
-                       }
-#endif                         /* CONFIG_CYZ_INTR */
+               mailbox = (__u32)readl(&((struct RUNTIME_9060 __iomem *)
+                               cy_pci_addr0)->mail_box_0);
 
-                       /* set cy_card */
-                       cy_card[j].base_phys = cy_pci_phys2;
-                       cy_card[j].ctl_phys = cy_pci_phys0;
-                       cy_card[j].base_addr = cy_pci_addr2;
-                       cy_card[j].ctl_addr = cy_pci_addr0;
-                       cy_card[j].irq = (int)cy_pci_irq;
-                       cy_card[j].bus_index = 1;
-                       cy_card[j].first_line = cy_next_channel;
-                       cy_card[j].num_chips = -1;
-                       cy_card[j].pdev = pdev;
-
-                       /* print message */
-#ifdef CONFIG_CYZ_INTR
-                       /* don't report IRQ if board is no IRQ */
-                       if ((cy_pci_irq != 0) && (cy_pci_irq != 255))
-                               printk("Cyclades-8Zo/PCI #%d: 0x%lx-0x%lx, "
-                                       "IRQ%d, ", j + 1, (ulong)cy_pci_phys2,
-                                       (ulong) (cy_pci_phys2 + CyPCI_Zwin - 1),
-                                       (int)cy_pci_irq);
-                       else
-#endif                         /* CONFIG_CYZ_INTR */
-                               printk("Cyclades-8Zo/PCI #%d: 0x%lx-0x%lx, ",
-                                       j + 1, (ulong)cy_pci_phys2,
-                                       (ulong)(cy_pci_phys2 + CyPCI_Zwin - 1));
+               if (pci_resource_flags(pdev, 2) & IORESOURCE_IO) {
+                       printk("  Warning: PCI I/O bit incorrectly "
+                               "set. Ignoring it...\n");
+                       pdev->resource[2].flags &= ~IORESOURCE_IO;
+               }
 
-                       printk("%d channels starting from port %d.\n",
-                                       cy_pci_nchan, cy_next_channel);
-                       cy_next_channel += cy_pci_nchan;
+               /* Although we don't use this I/O region, we should
+                  request it from the kernel anyway, to avoid problems
+                  with other drivers accessing it. */
+               retval = pci_request_regions(pdev, "Cyclades-Z");
+               if (retval) {
+                       printk(KERN_ERR "cyclades: failed to reserve "
+                               "PCI resources\n");
+                       return retval;
                }
-       }
 
-       for (; ZeIndex != 0 && i < NR_CARDS; i++) {
-               cy_pci_phys0 = Ze_phys0[0];
-               cy_pci_phys2 = Ze_phys2[0];
-               cy_pci_addr0 = Ze_addr0[0];
-               cy_pci_addr2 = Ze_addr2[0];
-               cy_pci_irq = Ze_irq[0];
-               pdev = Ze_pdev[0];
-               for (j = 0; j < ZeIndex - 1; j++) {
-                       Ze_phys0[j] = Ze_phys0[j + 1];
-                       Ze_phys2[j] = Ze_phys2[j + 1];
-                       Ze_addr0[j] = Ze_addr0[j + 1];
-                       Ze_addr2[j] = Ze_addr2[j + 1];
-                       Ze_irq[j] = Ze_irq[j + 1];
-                       Ze_pdev[j] = Ze_pdev[j + 1];
+               if (mailbox == ZE_V1) {
+                       retval = cy_init_Ze(cy_pci_phys0, cy_pci_phys2,
+                                       cy_pci_addr0, cy_pci_irq, pdev);
+                       return retval;
+               } else {
+                       cy_pci_addr2 = pci_iomap(pdev, 2, CyPCI_Zwin);
                }
-               ZeIndex--;
-               mailbox = (uclong)cy_readl(&((struct RUNTIME_9060 __iomem *)
-                                               cy_pci_addr0)->mail_box_0);
+
 #ifdef CY_PCI_DEBUG
-               printk("Cyclades-Z/PCI: relocate winaddr=0x%lx ctladdr=0x%lx\n",
-                       (ulong)cy_pci_addr2, (ulong)cy_pci_addr0);
-               printk("Cyclades-Z/PCI: New Cyclades-Z board.  FPGA not "
-                               "loaded\n");
+               printk("Cyclades-Z/PCI: relocate winaddr=0x%lx "
+                       "ctladdr=0x%lx\n",
+                       (ulong) cy_pci_addr2, (ulong) cy_pci_addr0);
+               if (mailbox == ZO_V1) {
+                       cy_writel(&((struct RUNTIME_9060 *)
+                               (cy_pci_addr0))->loc_addr_base,
+                               WIN_CREG);
+                       printk("Cyclades-8Zo/PCI: FPGA id %lx, ver "
+                               "%lx\n", (ulong) (0xff &
+                               readl(&((struct CUSTOM_REG *)
+                                       (cy_pci_addr2))->fpga_id)),
+                               (ulong)(0xff &
+                               readl(&((struct CUSTOM_REG *)
+                                       (cy_pci_addr2))->
+                                               fpga_version)));
+                       cy_writel(&((struct RUNTIME_9060 *)
+                               (cy_pci_addr0))->loc_addr_base,
+                               WIN_RAM);
+               } else {
+                       printk("Cyclades-Z/PCI: New Cyclades-Z board.  "
+                                       "FPGA not loaded\n");
+               }
 #endif
-               PAUSE;
-               /* This must be the new Cyclades-Ze/PCI. */
-               cy_pci_nchan = ZE_V1_NPORTS;
+               /* The following clears the firmware id word.  This
+                  ensures that the driver will not attempt to talk to
+                  the board until it has been properly initialized.
+                */
+               if ((mailbox == ZO_V1) || (mailbox == ZO_V2))
+                       cy_writel(cy_pci_addr2 + ID_ADDRESS, 0L);
+
+               /* This must be a Cyclades-8Zo/PCI.  The extendable
+                  version will have a different device_id and will
+                  be allocated its maximum number of ports. */
+               cy_pci_nchan = 8;
 
                if ((cy_next_channel + cy_pci_nchan) > NR_PORTS) {
-                       printk("Cyclades-Ze/PCI found at 0x%lx but no channels "
-                               "are available.\nChange NR_PORTS in cyclades.c "
-                               "and recompile kernel.\n",
-                               (ulong) cy_pci_phys2);
-                       return i;
+                       printk("Cyclades-8Zo/PCI found at 0x%lx but"
+                               "no channels are available.\nChange "
+                               "NR_PORTS in cyclades.c and recompile "
+                               "kernel.\n", (ulong)cy_pci_phys2);
+                       return -EIO;
                }
 
                /* fill the next cy_card structure available */
@@ -5146,23 +5234,24 @@ static int __init cy_detect_pci(void)
                                break;
                }
                if (j == NR_CARDS) {    /* no more cy_cards available */
-                       printk("Cyclades-Ze/PCI found at 0x%lx but no more "
-                               "cards can be used.\nChange NR_CARDS in "
-                               "cyclades.c and recompile kernel.\n",
-                               (ulong) cy_pci_phys2);
-                       return i;
+                       printk("Cyclades-8Zo/PCI found at 0x%lx but"
+                               "no more cards can be used.\nChange "
+                               "NR_CARDS in cyclades.c and recompile "
+                               "kernel.\n", (ulong)cy_pci_phys2);
+                       return -EIO;
                }
 #ifdef CONFIG_CYZ_INTR
                /* allocate IRQ only if board has an IRQ */
                if ((cy_pci_irq != 0) && (cy_pci_irq != 255)) {
-                       if (request_irq(cy_pci_irq, cyz_interrupt,
+                       retval = request_irq(cy_pci_irq, cyz_interrupt,
                                        IRQF_SHARED, "Cyclades-Z",
-                                       &cy_card[j])) {
-                               printk("Cyclom-Ze/PCI found at 0x%lx ",
-                                       (ulong) cy_pci_phys2);
-                               printk("but could not allocate IRQ%d.\n",
+                                       &cy_card[j]);
+                       if (retval) {
+                               printk("Cyclom-8Zo/PCI found at 0x%lx "
+                                       "but could not allocate "
+                                       "IRQ%d.\n", (ulong)cy_pci_phys2,
                                        cy_pci_irq);
-                               return i;
+                               return retval;
                        }
                }
 #endif                         /* CONFIG_CYZ_INTR */
@@ -5177,36 +5266,92 @@ static int __init cy_detect_pci(void)
                cy_card[j].first_line = cy_next_channel;
                cy_card[j].num_chips = -1;
                cy_card[j].pdev = pdev;
+               cy_init_card(&cy_card[j], j);
+               pci_set_drvdata(pdev, &cy_card[j]);
 
                /* print message */
 #ifdef CONFIG_CYZ_INTR
                /* don't report IRQ if board is no IRQ */
                if ((cy_pci_irq != 0) && (cy_pci_irq != 255))
-                       printk("Cyclades-Ze/PCI #%d: 0x%lx-0x%lx, IRQ%d, ",
-                               j + 1, (ulong) cy_pci_phys2,
-                               (ulong) (cy_pci_phys2 + CyPCI_Ze_win - 1),
+                       printk("Cyclades-8Zo/PCI #%d: 0x%lx-0x%lx, "
+                               "IRQ%d, ", j + 1, (ulong)cy_pci_phys2,
+                               (ulong) (cy_pci_phys2 + CyPCI_Zwin - 1),
                                (int)cy_pci_irq);
                else
 #endif                         /* CONFIG_CYZ_INTR */
-                       printk("Cyclades-Ze/PCI #%d: 0x%lx-0x%lx, ",
-                               j + 1, (ulong) cy_pci_phys2,
-                               (ulong) (cy_pci_phys2 + CyPCI_Ze_win - 1));
+                       printk("Cyclades-8Zo/PCI #%d: 0x%lx-0x%lx, ",
+                               j + 1, (ulong)cy_pci_phys2,
+                               (ulong)(cy_pci_phys2 + CyPCI_Zwin - 1));
 
                printk("%d channels starting from port %d.\n",
-                       cy_pci_nchan, cy_next_channel);
+                               cy_pci_nchan, cy_next_channel);
                cy_next_channel += cy_pci_nchan;
        }
-       if (ZeIndex != 0) {
-               printk("Cyclades-Ze/PCI found at 0x%x but no more cards can be "
-                       "used.\nChange NR_CARDS in cyclades.c and recompile "
-                       "kernel.\n", (unsigned int)Ze_phys2[0]);
+
+       return 0;
+}
+#endif
+
+/*
+ * ---------------------------------------------------------------------
+ * cy_detect_pci() - Test PCI bus presence and Cyclom-Ye/PCI.
+ * sets global variables and return the number of PCI boards found.
+ * ---------------------------------------------------------------------
+ */
+static int __init cy_detect_pci(void)
+{
+#ifdef CONFIG_PCI
+       struct pci_dev *pdev = NULL;
+       unsigned int i, device_id, dev_index = 0;
+
+       for (i = 0; i < NR_CARDS; i++) {
+               /* look for a Cyclades card by vendor and device id */
+               while ((device_id = cy_pci_dev_id[dev_index].device) != 0) {
+                       if ((pdev = pci_get_device(PCI_VENDOR_ID_CYCLADES,
+                                                  device_id, pdev)) == NULL) {
+                               dev_index++;    /* try next device id */
+                       } else {
+                               break;  /* found a board */
+                       }
+               }
+
+               if (device_id == 0)
+                       break;
+
+               i -= !!cy_pci_probe(pdev, &cy_pci_dev_id[dev_index]);
        }
+
        return i;
 #else
        return 0;
 #endif                         /* ifdef CONFIG_PCI */
 }                              /* cy_detect_pci */
 
+static void __devexit cy_pci_release(struct pci_dev *pdev)
+{
+#ifdef CONFIG_PCI
+       struct cyclades_card *cinfo = pci_get_drvdata(pdev);
+       unsigned int i;
+
+       pci_iounmap(pdev, cinfo->base_addr);
+       if (cinfo->ctl_addr)
+               pci_iounmap(pdev, cinfo->ctl_addr);
+       if (cinfo->irq
+#ifndef CONFIG_CYZ_INTR
+               && cinfo->num_chips != -1 /* not a Z card */
+#endif /* CONFIG_CYZ_INTR */
+               )
+               free_irq(cinfo->irq, cinfo);
+       pci_release_regions(pdev);
+
+       cinfo->base_addr = NULL;
+       for (i = cinfo->first_line; i < cinfo->first_line + cinfo->nports; i++){
+               cy_port[i].line = -1;
+               cy_port[i].magic = -1;
+       }
+#endif
+}
+
 /*
  * This routine prints out the appropriate serial driver version number
  * and identifies which options were configured into this driver.
@@ -5317,13 +5462,7 @@ static const struct tty_operations cy_ops = {
 
 static int __init cy_init(void)
 {
-       struct cyclades_port *info;
-       struct cyclades_card *cinfo;
-       int number_z_boards = 0;
-       int board, port, i, index;
-       unsigned long mailbox;
-       unsigned short chip_number;
-       int nports;
+       unsigned int i;
 
        cy_serial_driver = alloc_tty_driver(NR_PORTS);
        if (!cy_serial_driver)
@@ -5353,6 +5492,12 @@ static int __init cy_init(void)
                cy_card[i].base_addr = NULL;
        }
 
+       /* invalidate remaining cy_port structures */
+       for (i = 0; i < NR_PORTS; i++) {
+               cy_port[i].line = -1;
+               cy_port[i].magic = -1;
+       }
+
        /* the code below is responsible to find the boards. Each different
           type of board has its own detection routine. If a board is found,
           the next cy_card structure available is set by the detection
@@ -5368,177 +5513,7 @@ static int __init cy_init(void)
 
        cy_nboard = cy_isa_nboard + cy_pci_nboard;
 
-       /* invalidate remaining cy_card structures */
-       for (i = 0; i < NR_CARDS; i++) {
-               if (cy_card[i].base_addr == 0) {
-                       cy_card[i].first_line = -1;
-                       cy_card[i].ctl_addr = NULL;
-                       cy_card[i].irq = 0;
-                       cy_card[i].bus_index = 0;
-                       cy_card[i].first_line = 0;
-                       cy_card[i].num_chips = 0;
-               }
-       }
-       /* invalidate remaining cy_port structures */
-       for (i = cy_next_channel; i < NR_PORTS; i++) {
-               cy_port[i].line = -1;
-               cy_port[i].magic = -1;
-       }
-
-       /* initialize per-port data structures for each valid board found */
-       for (board = 0; board < cy_nboard; board++) {
-               cinfo = &cy_card[board];
-               if (cinfo->num_chips == -1) {   /* Cyclades-Z */
-                       number_z_boards++;
-                       mailbox = cy_readl(&((struct RUNTIME_9060 __iomem *)
-                                            cy_card[board].ctl_addr)->
-                                          mail_box_0);
-                       nports = (mailbox == ZE_V1) ? ZE_V1_NPORTS : 8;
-                       cinfo->intr_enabled = 0;
-                       cinfo->nports = 0;      /* Will be correctly set later, after 
-                                                  Z FW is loaded */
-                       spin_lock_init(&cinfo->card_lock);
-                       for (port = cinfo->first_line;
-                            port < cinfo->first_line + nports; port++) {
-                               info = &cy_port[port];
-                               info->magic = CYCLADES_MAGIC;
-                               info->type = PORT_STARTECH;
-                               info->card = board;
-                               info->line = port;
-                               info->chip_rev = 0;
-                               info->flags = STD_COM_FLAGS;
-                               info->tty = NULL;
-                               if (mailbox == ZO_V1)
-                                       info->xmit_fifo_size = CYZ_FIFO_SIZE;
-                               else
-                                       info->xmit_fifo_size =
-                                           4 * CYZ_FIFO_SIZE;
-                               info->cor1 = 0;
-                               info->cor2 = 0;
-                               info->cor3 = 0;
-                               info->cor4 = 0;
-                               info->cor5 = 0;
-                               info->tbpr = 0;
-                               info->tco = 0;
-                               info->rbpr = 0;
-                               info->rco = 0;
-                               info->custom_divisor = 0;
-                               info->close_delay = 5 * HZ / 10;
-                               info->closing_wait = CLOSING_WAIT_DELAY;
-                               info->icount.cts = info->icount.dsr =
-                                   info->icount.rng = info->icount.dcd = 0;
-                               info->icount.rx = info->icount.tx = 0;
-                               info->icount.frame = info->icount.parity = 0;
-                               info->icount.overrun = info->icount.brk = 0;
-                               info->x_char = 0;
-                               info->event = 0;
-                               info->count = 0;
-                               info->blocked_open = 0;
-                               info->default_threshold = 0;
-                               info->default_timeout = 0;
-                               INIT_WORK(&info->tqueue, do_softint);
-                               init_waitqueue_head(&info->open_wait);
-                               init_waitqueue_head(&info->close_wait);
-                               init_waitqueue_head(&info->shutdown_wait);
-                               init_waitqueue_head(&info->delta_msr_wait);
-                               /* info->session */
-                               /* info->pgrp */
-                               info->read_status_mask = 0;
-                               /* info->timeout */
-                               /* Bentson's vars */
-                               info->jiffies[0] = 0;
-                               info->jiffies[1] = 0;
-                               info->jiffies[2] = 0;
-                               info->rflush_count = 0;
-#ifdef CONFIG_CYZ_INTR
-                               init_timer(&cyz_rx_full_timer[port]);
-                               cyz_rx_full_timer[port].function = NULL;
-#endif
-                       }
-                       continue;
-               } else {        /* Cyclom-Y of some kind */
-                       index = cinfo->bus_index;
-                       spin_lock_init(&cinfo->card_lock);
-                       cinfo->nports = CyPORTS_PER_CHIP * cinfo->num_chips;
-                       for (port = cinfo->first_line;
-                            port < cinfo->first_line + cinfo->nports; port++) {
-                               info = &cy_port[port];
-                               info->magic = CYCLADES_MAGIC;
-                               info->type = PORT_CIRRUS;
-                               info->card = board;
-                               info->line = port;
-                               info->flags = STD_COM_FLAGS;
-                               info->tty = NULL;
-                               info->xmit_fifo_size = CyMAX_CHAR_FIFO;
-                               info->cor1 =
-                                   CyPARITY_NONE | Cy_1_STOP | Cy_8_BITS;
-                               info->cor2 = CyETC;
-                               info->cor3 = 0x08;      /* _very_ small rcv threshold */
-                               info->cor4 = 0;
-                               info->cor5 = 0;
-                               info->custom_divisor = 0;
-                               info->close_delay = 5 * HZ / 10;
-                               info->closing_wait = CLOSING_WAIT_DELAY;
-                               info->icount.cts = info->icount.dsr =
-                                   info->icount.rng = info->icount.dcd = 0;
-                               info->icount.rx = info->icount.tx = 0;
-                               info->icount.frame = info->icount.parity = 0;
-                               info->icount.overrun = info->icount.brk = 0;
-                               chip_number = (port - cinfo->first_line) / 4;
-                               if ((info->chip_rev =
-                                    cy_readb(cinfo->base_addr +
-                                             (cy_chip_offset[chip_number] <<
-                                              index) + (CyGFRCR << index))) >=
-                                   CD1400_REV_J) {
-                                       /* It is a CD1400 rev. J or later */
-                                       info->tbpr = baud_bpr_60[13];   /* Tx BPR */
-                                       info->tco = baud_co_60[13];     /* Tx CO */
-                                       info->rbpr = baud_bpr_60[13];   /* Rx BPR */
-                                       info->rco = baud_co_60[13];     /* Rx CO */
-                                       info->rflow = 0;
-                                       info->rtsdtr_inv = 1;
-                               } else {
-                                       info->tbpr = baud_bpr_25[13];   /* Tx BPR */
-                                       info->tco = baud_co_25[13];     /* Tx CO */
-                                       info->rbpr = baud_bpr_25[13];   /* Rx BPR */
-                                       info->rco = baud_co_25[13];     /* Rx CO */
-                                       info->rflow = 0;
-                                       info->rtsdtr_inv = 0;
-                               }
-                               info->x_char = 0;
-                               info->event = 0;
-                               info->count = 0;
-                               info->blocked_open = 0;
-                               info->default_threshold = 0;
-                               info->default_timeout = 0;
-                               INIT_WORK(&info->tqueue, do_softint);
-                               init_waitqueue_head(&info->open_wait);
-                               init_waitqueue_head(&info->close_wait);
-                               init_waitqueue_head(&info->shutdown_wait);
-                               init_waitqueue_head(&info->delta_msr_wait);
-                               /* info->session */
-                               /* info->pgrp */
-                               info->read_status_mask =
-                                   CyTIMEOUT | CySPECHAR | CyBREAK
-                                   | CyPARITY | CyFRAME | CyOVERRUN;
-                               /* info->timeout */
-                       }
-               }
-       }
-
-#ifndef CONFIG_CYZ_INTR
-       if (number_z_boards && !cyz_timeron) {
-               cyz_timeron++;
-               cyz_timerlist.expires = jiffies + 1;
-               add_timer(&cyz_timerlist);
-#ifdef CY_PCI_DEBUG
-               printk("Cyclades-Z polling initialized\n");
-#endif
-       }
-#endif                         /* CONFIG_CYZ_INTR */
-
        return 0;
-
 }                              /* cy_init */
 
 static void __exit cy_cleanup_module(void)
@@ -5546,10 +5521,7 @@ static void __exit cy_cleanup_module(void)
        int i, e1;
 
 #ifndef CONFIG_CYZ_INTR
-       if (cyz_timeron){
-               cyz_timeron = 0;
-               del_timer(&cyz_timerlist);
-       }
+       del_timer_sync(&cyz_timerlist);
 #endif /* CONFIG_CYZ_INTR */
 
        if ((e1 = tty_unregister_driver(cy_serial_driver)))
@@ -5560,6 +5532,10 @@ static void __exit cy_cleanup_module(void)
 
        for (i = 0; i < NR_CARDS; i++) {
                if (cy_card[i].base_addr) {
+                       if (cy_card[i].pdev) {
+                               cy_pci_release(cy_card[i].pdev);
+                               continue;
+                       }
                        iounmap(cy_card[i].base_addr);
                        if (cy_card[i].ctl_addr)
                                iounmap(cy_card[i].ctl_addr);
@@ -5569,10 +5545,6 @@ static void __exit cy_cleanup_module(void)
 #endif /* CONFIG_CYZ_INTR */
                                )
                                free_irq(cy_card[i].irq, &cy_card[i]);
-#ifdef CONFIG_PCI
-                       if (cy_card[i].pdev)
-                               pci_release_regions(cy_card[i].pdev);
-#endif
                }
        }
 } /* cy_cleanup_module */