diff options
Diffstat (limited to 'drivers/char/cyclades.c')
-rw-r--r-- | drivers/char/cyclades.c | 290 |
1 files changed, 125 insertions, 165 deletions
diff --git a/drivers/char/cyclades.c b/drivers/char/cyclades.c index 1fdb9f657d8f..f3366d3f06cf 100644 --- a/drivers/char/cyclades.c +++ b/drivers/char/cyclades.c | |||
@@ -604,7 +604,6 @@ | |||
604 | 604 | ||
605 | #define NR_PORTS 256 | 605 | #define NR_PORTS 256 |
606 | 606 | ||
607 | #define ZE_V1_NPORTS 64 | ||
608 | #define ZO_V1 0 | 607 | #define ZO_V1 0 |
609 | #define ZO_V2 1 | 608 | #define ZO_V2 1 |
610 | #define ZE_V1 2 | 609 | #define ZE_V1 2 |
@@ -663,18 +662,6 @@ | |||
663 | static void cy_throttle(struct tty_struct *tty); | 662 | static void cy_throttle(struct tty_struct *tty); |
664 | static void cy_send_xchar(struct tty_struct *tty, char ch); | 663 | static void cy_send_xchar(struct tty_struct *tty, char ch); |
665 | 664 | ||
666 | #define IS_CYC_Z(card) ((card).num_chips == (unsigned int)-1) | ||
667 | |||
668 | #define Z_FPGA_CHECK(card) \ | ||
669 | ((readl(&((struct RUNTIME_9060 __iomem *) \ | ||
670 | ((card).ctl_addr))->init_ctrl) & (1<<17)) != 0) | ||
671 | |||
672 | #define ISZLOADED(card) (((ZO_V1 == readl(&((struct RUNTIME_9060 __iomem *) \ | ||
673 | ((card).ctl_addr))->mail_box_0)) || \ | ||
674 | Z_FPGA_CHECK(card)) && \ | ||
675 | (ZFIRM_ID == readl(&((struct FIRM_ID __iomem *) \ | ||
676 | ((card).base_addr+ID_ADDRESS))->signature))) | ||
677 | |||
678 | #ifndef SERIAL_XMIT_SIZE | 665 | #ifndef SERIAL_XMIT_SIZE |
679 | #define SERIAL_XMIT_SIZE (min(PAGE_SIZE, 4096)) | 666 | #define SERIAL_XMIT_SIZE (min(PAGE_SIZE, 4096)) |
680 | #endif | 667 | #endif |
@@ -687,8 +674,6 @@ static void cy_send_xchar(struct tty_struct *tty, char ch); | |||
687 | #define DRIVER_VERSION 0x02010203 | 674 | #define DRIVER_VERSION 0x02010203 |
688 | #define RAM_SIZE 0x80000 | 675 | #define RAM_SIZE 0x80000 |
689 | 676 | ||
690 | #define Z_FPGA_LOADED(X) ((readl(&(X)->init_ctrl) & (1<<17)) != 0) | ||
691 | |||
692 | enum zblock_type { | 677 | enum zblock_type { |
693 | ZBLOCK_PRG = 0, | 678 | ZBLOCK_PRG = 0, |
694 | ZBLOCK_FPGA = 1 | 679 | ZBLOCK_FPGA = 1 |
@@ -883,6 +868,29 @@ static void cyz_rx_restart(unsigned long); | |||
883 | static struct timer_list cyz_rx_full_timer[NR_PORTS]; | 868 | static struct timer_list cyz_rx_full_timer[NR_PORTS]; |
884 | #endif /* CONFIG_CYZ_INTR */ | 869 | #endif /* CONFIG_CYZ_INTR */ |
885 | 870 | ||
871 | static inline bool cy_is_Z(struct cyclades_card *card) | ||
872 | { | ||
873 | return card->num_chips == (unsigned int)-1; | ||
874 | } | ||
875 | |||
876 | static inline bool __cyz_fpga_loaded(struct RUNTIME_9060 __iomem *ctl_addr) | ||
877 | { | ||
878 | return readl(&ctl_addr->init_ctrl) & (1 << 17); | ||
879 | } | ||
880 | |||
881 | static inline bool cyz_fpga_loaded(struct cyclades_card *card) | ||
882 | { | ||
883 | return __cyz_fpga_loaded(card->ctl_addr.p9060); | ||
884 | } | ||
885 | |||
886 | static inline bool cyz_is_loaded(struct cyclades_card *card) | ||
887 | { | ||
888 | struct FIRM_ID __iomem *fw_id = card->base_addr + ID_ADDRESS; | ||
889 | |||
890 | return (card->hw_ver == ZO_V1 || cyz_fpga_loaded(card)) && | ||
891 | readl(&fw_id->signature) == ZFIRM_ID; | ||
892 | } | ||
893 | |||
886 | static inline int serial_paranoia_check(struct cyclades_port *info, | 894 | static inline int serial_paranoia_check(struct cyclades_port *info, |
887 | char *name, const char *routine) | 895 | char *name, const char *routine) |
888 | { | 896 | { |
@@ -1395,19 +1403,15 @@ cyz_fetch_msg(struct cyclades_card *cinfo, | |||
1395 | unsigned long loc_doorbell; | 1403 | unsigned long loc_doorbell; |
1396 | 1404 | ||
1397 | firm_id = cinfo->base_addr + ID_ADDRESS; | 1405 | firm_id = cinfo->base_addr + ID_ADDRESS; |
1398 | if (!ISZLOADED(*cinfo)) | ||
1399 | return -1; | ||
1400 | zfw_ctrl = cinfo->base_addr + (readl(&firm_id->zfwctrl_addr) & 0xfffff); | 1406 | zfw_ctrl = cinfo->base_addr + (readl(&firm_id->zfwctrl_addr) & 0xfffff); |
1401 | board_ctrl = &zfw_ctrl->board_ctrl; | 1407 | board_ctrl = &zfw_ctrl->board_ctrl; |
1402 | 1408 | ||
1403 | loc_doorbell = readl(&((struct RUNTIME_9060 __iomem *) | 1409 | loc_doorbell = readl(&cinfo->ctl_addr.p9060->loc_doorbell); |
1404 | (cinfo->ctl_addr))->loc_doorbell); | ||
1405 | if (loc_doorbell) { | 1410 | if (loc_doorbell) { |
1406 | *cmd = (char)(0xff & loc_doorbell); | 1411 | *cmd = (char)(0xff & loc_doorbell); |
1407 | *channel = readl(&board_ctrl->fwcmd_channel); | 1412 | *channel = readl(&board_ctrl->fwcmd_channel); |
1408 | *param = (__u32) readl(&board_ctrl->fwcmd_param); | 1413 | *param = (__u32) readl(&board_ctrl->fwcmd_param); |
1409 | cy_writel(&((struct RUNTIME_9060 __iomem *)(cinfo->ctl_addr))-> | 1414 | cy_writel(&cinfo->ctl_addr.p9060->loc_doorbell, 0xffffffff); |
1410 | loc_doorbell, 0xffffffff); | ||
1411 | return 1; | 1415 | return 1; |
1412 | } | 1416 | } |
1413 | return 0; | 1417 | return 0; |
@@ -1424,15 +1428,14 @@ cyz_issue_cmd(struct cyclades_card *cinfo, | |||
1424 | unsigned int index; | 1428 | unsigned int index; |
1425 | 1429 | ||
1426 | firm_id = cinfo->base_addr + ID_ADDRESS; | 1430 | firm_id = cinfo->base_addr + ID_ADDRESS; |
1427 | if (!ISZLOADED(*cinfo)) | 1431 | if (!cyz_is_loaded(cinfo)) |
1428 | return -1; | 1432 | return -1; |
1429 | 1433 | ||
1430 | zfw_ctrl = cinfo->base_addr + (readl(&firm_id->zfwctrl_addr) & 0xfffff); | 1434 | zfw_ctrl = cinfo->base_addr + (readl(&firm_id->zfwctrl_addr) & 0xfffff); |
1431 | board_ctrl = &zfw_ctrl->board_ctrl; | 1435 | board_ctrl = &zfw_ctrl->board_ctrl; |
1432 | 1436 | ||
1433 | index = 0; | 1437 | index = 0; |
1434 | pci_doorbell = | 1438 | pci_doorbell = &cinfo->ctl_addr.p9060->pci_doorbell; |
1435 | &((struct RUNTIME_9060 __iomem *)(cinfo->ctl_addr))->pci_doorbell; | ||
1436 | while ((readl(pci_doorbell) & 0xff) != 0) { | 1439 | while ((readl(pci_doorbell) & 0xff) != 0) { |
1437 | if (index++ == 1000) | 1440 | if (index++ == 1000) |
1438 | return (int)(readl(pci_doorbell) & 0xff); | 1441 | return (int)(readl(pci_doorbell) & 0xff); |
@@ -1624,10 +1627,8 @@ static void cyz_handle_cmd(struct cyclades_card *cinfo) | |||
1624 | static struct BOARD_CTRL __iomem *board_ctrl; | 1627 | static struct BOARD_CTRL __iomem *board_ctrl; |
1625 | static struct CH_CTRL __iomem *ch_ctrl; | 1628 | static struct CH_CTRL __iomem *ch_ctrl; |
1626 | static struct BUF_CTRL __iomem *buf_ctrl; | 1629 | static struct BUF_CTRL __iomem *buf_ctrl; |
1627 | __u32 channel; | 1630 | __u32 channel, param, fw_ver; |
1628 | __u8 cmd; | 1631 | __u8 cmd; |
1629 | __u32 param; | ||
1630 | __u32 hw_ver, fw_ver; | ||
1631 | int special_count; | 1632 | int special_count; |
1632 | int delta_count; | 1633 | int delta_count; |
1633 | 1634 | ||
@@ -1635,8 +1636,6 @@ static void cyz_handle_cmd(struct cyclades_card *cinfo) | |||
1635 | zfw_ctrl = cinfo->base_addr + (readl(&firm_id->zfwctrl_addr) & 0xfffff); | 1636 | zfw_ctrl = cinfo->base_addr + (readl(&firm_id->zfwctrl_addr) & 0xfffff); |
1636 | board_ctrl = &zfw_ctrl->board_ctrl; | 1637 | board_ctrl = &zfw_ctrl->board_ctrl; |
1637 | fw_ver = readl(&board_ctrl->fw_version); | 1638 | fw_ver = readl(&board_ctrl->fw_version); |
1638 | hw_ver = readl(&((struct RUNTIME_9060 __iomem *)(cinfo->ctl_addr))-> | ||
1639 | mail_box_0); | ||
1640 | 1639 | ||
1641 | while (cyz_fetch_msg(cinfo, &channel, &cmd, ¶m) == 1) { | 1640 | while (cyz_fetch_msg(cinfo, &channel, &cmd, ¶m) == 1) { |
1642 | special_count = 0; | 1641 | special_count = 0; |
@@ -1737,15 +1736,7 @@ static irqreturn_t cyz_interrupt(int irq, void *dev_id) | |||
1737 | { | 1736 | { |
1738 | struct cyclades_card *cinfo = dev_id; | 1737 | struct cyclades_card *cinfo = dev_id; |
1739 | 1738 | ||
1740 | if (unlikely(cinfo == NULL)) { | 1739 | if (unlikely(!cyz_is_loaded(cinfo))) { |
1741 | #ifdef CY_DEBUG_INTERRUPTS | ||
1742 | printk(KERN_DEBUG "cyz_interrupt: spurious interrupt %d\n", | ||
1743 | irq); | ||
1744 | #endif | ||
1745 | return IRQ_NONE; /* spurious interrupt */ | ||
1746 | } | ||
1747 | |||
1748 | if (unlikely(!ISZLOADED(*cinfo))) { | ||
1749 | #ifdef CY_DEBUG_INTERRUPTS | 1740 | #ifdef CY_DEBUG_INTERRUPTS |
1750 | printk(KERN_DEBUG "cyz_interrupt: board not yet loaded " | 1741 | printk(KERN_DEBUG "cyz_interrupt: board not yet loaded " |
1751 | "(IRQ%d).\n", irq); | 1742 | "(IRQ%d).\n", irq); |
@@ -1785,7 +1776,6 @@ static void cyz_poll(unsigned long arg) | |||
1785 | struct tty_struct *tty; | 1776 | struct tty_struct *tty; |
1786 | struct FIRM_ID __iomem *firm_id; | 1777 | struct FIRM_ID __iomem *firm_id; |
1787 | struct ZFW_CTRL __iomem *zfw_ctrl; | 1778 | struct ZFW_CTRL __iomem *zfw_ctrl; |
1788 | struct BOARD_CTRL __iomem *board_ctrl; | ||
1789 | struct BUF_CTRL __iomem *buf_ctrl; | 1779 | struct BUF_CTRL __iomem *buf_ctrl; |
1790 | unsigned long expires = jiffies + HZ; | 1780 | unsigned long expires = jiffies + HZ; |
1791 | unsigned int port, card; | 1781 | unsigned int port, card; |
@@ -1793,19 +1783,17 @@ static void cyz_poll(unsigned long arg) | |||
1793 | for (card = 0; card < NR_CARDS; card++) { | 1783 | for (card = 0; card < NR_CARDS; card++) { |
1794 | cinfo = &cy_card[card]; | 1784 | cinfo = &cy_card[card]; |
1795 | 1785 | ||
1796 | if (!IS_CYC_Z(*cinfo)) | 1786 | if (!cy_is_Z(cinfo)) |
1797 | continue; | 1787 | continue; |
1798 | if (!ISZLOADED(*cinfo)) | 1788 | if (!cyz_is_loaded(cinfo)) |
1799 | continue; | 1789 | continue; |
1800 | 1790 | ||
1801 | firm_id = cinfo->base_addr + ID_ADDRESS; | 1791 | firm_id = cinfo->base_addr + ID_ADDRESS; |
1802 | zfw_ctrl = cinfo->base_addr + | 1792 | zfw_ctrl = cinfo->base_addr + |
1803 | (readl(&firm_id->zfwctrl_addr) & 0xfffff); | 1793 | (readl(&firm_id->zfwctrl_addr) & 0xfffff); |
1804 | board_ctrl = &(zfw_ctrl->board_ctrl); | ||
1805 | 1794 | ||
1806 | /* Skip first polling cycle to avoid racing conditions with the FW */ | 1795 | /* Skip first polling cycle to avoid racing conditions with the FW */ |
1807 | if (!cinfo->intr_enabled) { | 1796 | if (!cinfo->intr_enabled) { |
1808 | cinfo->nports = (int)readl(&board_ctrl->n_channel); | ||
1809 | cinfo->intr_enabled = 1; | 1797 | cinfo->intr_enabled = 1; |
1810 | continue; | 1798 | continue; |
1811 | } | 1799 | } |
@@ -1874,7 +1862,7 @@ static int startup(struct cyclades_port *info) | |||
1874 | 1862 | ||
1875 | set_line_char(info); | 1863 | set_line_char(info); |
1876 | 1864 | ||
1877 | if (!IS_CYC_Z(*card)) { | 1865 | if (!cy_is_Z(card)) { |
1878 | chip = channel >> 2; | 1866 | chip = channel >> 2; |
1879 | channel &= 0x03; | 1867 | channel &= 0x03; |
1880 | index = card->bus_index; | 1868 | index = card->bus_index; |
@@ -1931,7 +1919,7 @@ static int startup(struct cyclades_port *info) | |||
1931 | base_addr = card->base_addr; | 1919 | base_addr = card->base_addr; |
1932 | 1920 | ||
1933 | firm_id = base_addr + ID_ADDRESS; | 1921 | firm_id = base_addr + ID_ADDRESS; |
1934 | if (!ISZLOADED(*card)) | 1922 | if (!cyz_is_loaded(card)) |
1935 | return -ENODEV; | 1923 | return -ENODEV; |
1936 | 1924 | ||
1937 | zfw_ctrl = card->base_addr + | 1925 | zfw_ctrl = card->base_addr + |
@@ -2026,7 +2014,7 @@ static void start_xmit(struct cyclades_port *info) | |||
2026 | 2014 | ||
2027 | card = info->card; | 2015 | card = info->card; |
2028 | channel = info->line - card->first_line; | 2016 | channel = info->line - card->first_line; |
2029 | if (!IS_CYC_Z(*card)) { | 2017 | if (!cy_is_Z(card)) { |
2030 | chip = channel >> 2; | 2018 | chip = channel >> 2; |
2031 | channel &= 0x03; | 2019 | channel &= 0x03; |
2032 | index = card->bus_index; | 2020 | index = card->bus_index; |
@@ -2070,7 +2058,7 @@ static void shutdown(struct cyclades_port *info) | |||
2070 | 2058 | ||
2071 | card = info->card; | 2059 | card = info->card; |
2072 | channel = info->line - card->first_line; | 2060 | channel = info->line - card->first_line; |
2073 | if (!IS_CYC_Z(*card)) { | 2061 | if (!cy_is_Z(card)) { |
2074 | chip = channel >> 2; | 2062 | chip = channel >> 2; |
2075 | channel &= 0x03; | 2063 | channel &= 0x03; |
2076 | index = card->bus_index; | 2064 | index = card->bus_index; |
@@ -2126,7 +2114,7 @@ static void shutdown(struct cyclades_port *info) | |||
2126 | #endif | 2114 | #endif |
2127 | 2115 | ||
2128 | firm_id = base_addr + ID_ADDRESS; | 2116 | firm_id = base_addr + ID_ADDRESS; |
2129 | if (!ISZLOADED(*card)) | 2117 | if (!cyz_is_loaded(card)) |
2130 | return; | 2118 | return; |
2131 | 2119 | ||
2132 | zfw_ctrl = card->base_addr + | 2120 | zfw_ctrl = card->base_addr + |
@@ -2233,7 +2221,7 @@ block_til_ready(struct tty_struct *tty, struct file *filp, | |||
2233 | #endif | 2221 | #endif |
2234 | info->port.blocked_open++; | 2222 | info->port.blocked_open++; |
2235 | 2223 | ||
2236 | if (!IS_CYC_Z(*cinfo)) { | 2224 | if (!cy_is_Z(cinfo)) { |
2237 | chip = channel >> 2; | 2225 | chip = channel >> 2; |
2238 | channel &= 0x03; | 2226 | channel &= 0x03; |
2239 | index = cinfo->bus_index; | 2227 | index = cinfo->bus_index; |
@@ -2296,7 +2284,7 @@ block_til_ready(struct tty_struct *tty, struct file *filp, | |||
2296 | 2284 | ||
2297 | base_addr = cinfo->base_addr; | 2285 | base_addr = cinfo->base_addr; |
2298 | firm_id = base_addr + ID_ADDRESS; | 2286 | firm_id = base_addr + ID_ADDRESS; |
2299 | if (!ISZLOADED(*cinfo)) { | 2287 | if (!cyz_is_loaded(cinfo)) { |
2300 | __set_current_state(TASK_RUNNING); | 2288 | __set_current_state(TASK_RUNNING); |
2301 | remove_wait_queue(&info->port.open_wait, &wait); | 2289 | remove_wait_queue(&info->port.open_wait, &wait); |
2302 | return -EINVAL; | 2290 | return -EINVAL; |
@@ -2397,16 +2385,14 @@ static int cy_open(struct tty_struct *tty, struct file *filp) | |||
2397 | treat it as absent from the system. This | 2385 | treat it as absent from the system. This |
2398 | will make the user pay attention. | 2386 | will make the user pay attention. |
2399 | */ | 2387 | */ |
2400 | if (IS_CYC_Z(*info->card)) { | 2388 | if (cy_is_Z(info->card)) { |
2401 | struct cyclades_card *cinfo = info->card; | 2389 | struct cyclades_card *cinfo = info->card; |
2402 | struct FIRM_ID __iomem *firm_id = cinfo->base_addr + ID_ADDRESS; | 2390 | struct FIRM_ID __iomem *firm_id = cinfo->base_addr + ID_ADDRESS; |
2403 | 2391 | ||
2404 | if (!ISZLOADED(*cinfo)) { | 2392 | if (!cyz_is_loaded(cinfo)) { |
2405 | if (((ZE_V1 == readl(&((struct RUNTIME_9060 __iomem *) | 2393 | if (cinfo->hw_ver == ZE_V1 && cyz_fpga_loaded(cinfo) && |
2406 | (cinfo->ctl_addr))->mail_box_0)) && | 2394 | readl(&firm_id->signature) == |
2407 | Z_FPGA_CHECK(*cinfo)) && | 2395 | ZFIRM_HLT) { |
2408 | (ZFIRM_HLT == readl( | ||
2409 | &firm_id->signature))) { | ||
2410 | printk(KERN_ERR "cyc:Cyclades-Z Error: you " | 2396 | printk(KERN_ERR "cyc:Cyclades-Z Error: you " |
2411 | "need an external power supply for " | 2397 | "need an external power supply for " |
2412 | "this number of ports.\nFirmware " | 2398 | "this number of ports.\nFirmware " |
@@ -2423,18 +2409,13 @@ static int cy_open(struct tty_struct *tty, struct file *filp) | |||
2423 | interrupts should be enabled as soon as the first open | 2409 | interrupts should be enabled as soon as the first open |
2424 | happens to one of its ports. */ | 2410 | happens to one of its ports. */ |
2425 | if (!cinfo->intr_enabled) { | 2411 | if (!cinfo->intr_enabled) { |
2426 | struct ZFW_CTRL __iomem *zfw_ctrl; | 2412 | u16 intr; |
2427 | struct BOARD_CTRL __iomem *board_ctrl; | ||
2428 | |||
2429 | zfw_ctrl = cinfo->base_addr + | ||
2430 | (readl(&firm_id->zfwctrl_addr) & | ||
2431 | 0xfffff); | ||
2432 | |||
2433 | board_ctrl = &zfw_ctrl->board_ctrl; | ||
2434 | 2413 | ||
2435 | /* Enable interrupts on the PLX chip */ | 2414 | /* Enable interrupts on the PLX chip */ |
2436 | cy_writew(cinfo->ctl_addr + 0x68, | 2415 | intr = readw(&cinfo->ctl_addr.p9060-> |
2437 | readw(cinfo->ctl_addr + 0x68) | 0x0900); | 2416 | intr_ctrl_stat) | 0x0900; |
2417 | cy_writew(&cinfo->ctl_addr.p9060-> | ||
2418 | intr_ctrl_stat, intr); | ||
2438 | /* Enable interrupts on the FW */ | 2419 | /* Enable interrupts on the FW */ |
2439 | retval = cyz_issue_cmd(cinfo, 0, | 2420 | retval = cyz_issue_cmd(cinfo, 0, |
2440 | C_CM_IRQ_ENBL, 0L); | 2421 | C_CM_IRQ_ENBL, 0L); |
@@ -2442,8 +2423,6 @@ static int cy_open(struct tty_struct *tty, struct file *filp) | |||
2442 | printk(KERN_ERR "cyc:IRQ enable retval " | 2423 | printk(KERN_ERR "cyc:IRQ enable retval " |
2443 | "was %x\n", retval); | 2424 | "was %x\n", retval); |
2444 | } | 2425 | } |
2445 | cinfo->nports = | ||
2446 | (int)readl(&board_ctrl->n_channel); | ||
2447 | cinfo->intr_enabled = 1; | 2426 | cinfo->intr_enabled = 1; |
2448 | } | 2427 | } |
2449 | } | 2428 | } |
@@ -2556,7 +2535,7 @@ static void cy_wait_until_sent(struct tty_struct *tty, int timeout) | |||
2556 | #endif | 2535 | #endif |
2557 | card = info->card; | 2536 | card = info->card; |
2558 | channel = (info->line) - (card->first_line); | 2537 | channel = (info->line) - (card->first_line); |
2559 | if (!IS_CYC_Z(*card)) { | 2538 | if (!cy_is_Z(card)) { |
2560 | chip = channel >> 2; | 2539 | chip = channel >> 2; |
2561 | channel &= 0x03; | 2540 | channel &= 0x03; |
2562 | index = card->bus_index; | 2541 | index = card->bus_index; |
@@ -2601,7 +2580,7 @@ static void cy_flush_buffer(struct tty_struct *tty) | |||
2601 | info->xmit_cnt = info->xmit_head = info->xmit_tail = 0; | 2580 | info->xmit_cnt = info->xmit_head = info->xmit_tail = 0; |
2602 | spin_unlock_irqrestore(&card->card_lock, flags); | 2581 | spin_unlock_irqrestore(&card->card_lock, flags); |
2603 | 2582 | ||
2604 | if (IS_CYC_Z(*card)) { /* If it is a Z card, flush the on-board | 2583 | if (cy_is_Z(card)) { /* If it is a Z card, flush the on-board |
2605 | buffers as well */ | 2584 | buffers as well */ |
2606 | spin_lock_irqsave(&card->card_lock, flags); | 2585 | spin_lock_irqsave(&card->card_lock, flags); |
2607 | retval = cyz_issue_cmd(card, channel, C_CM_FLUSH_TX, 0L); | 2586 | retval = cyz_issue_cmd(card, channel, C_CM_FLUSH_TX, 0L); |
@@ -2682,7 +2661,7 @@ static void cy_close(struct tty_struct *tty, struct file *filp) | |||
2682 | 2661 | ||
2683 | spin_lock_irqsave(&card->card_lock, flags); | 2662 | spin_lock_irqsave(&card->card_lock, flags); |
2684 | 2663 | ||
2685 | if (!IS_CYC_Z(*card)) { | 2664 | if (!cy_is_Z(card)) { |
2686 | int channel = info->line - card->first_line; | 2665 | int channel = info->line - card->first_line; |
2687 | int index = card->bus_index; | 2666 | int index = card->bus_index; |
2688 | void __iomem *base_addr = card->base_addr + | 2667 | void __iomem *base_addr = card->base_addr + |
@@ -2902,7 +2881,7 @@ static int cy_chars_in_buffer(struct tty_struct *tty) | |||
2902 | channel = (info->line) - (card->first_line); | 2881 | channel = (info->line) - (card->first_line); |
2903 | 2882 | ||
2904 | #ifdef Z_EXT_CHARS_IN_BUFFER | 2883 | #ifdef Z_EXT_CHARS_IN_BUFFER |
2905 | if (!IS_CYC_Z(cy_card[card])) { | 2884 | if (!cy_is_Z(card)) { |
2906 | #endif /* Z_EXT_CHARS_IN_BUFFER */ | 2885 | #endif /* Z_EXT_CHARS_IN_BUFFER */ |
2907 | #ifdef CY_DEBUG_IO | 2886 | #ifdef CY_DEBUG_IO |
2908 | printk(KERN_DEBUG "cyc:cy_chars_in_buffer ttyC%d %d\n", | 2887 | printk(KERN_DEBUG "cyc:cy_chars_in_buffer ttyC%d %d\n", |
@@ -2984,7 +2963,6 @@ static void set_line_char(struct cyclades_port *info) | |||
2984 | void __iomem *base_addr; | 2963 | void __iomem *base_addr; |
2985 | int chip, channel, index; | 2964 | int chip, channel, index; |
2986 | unsigned cflag, iflag; | 2965 | unsigned cflag, iflag; |
2987 | unsigned short chip_number; | ||
2988 | int baud, baud_rate = 0; | 2966 | int baud, baud_rate = 0; |
2989 | int i; | 2967 | int i; |
2990 | 2968 | ||
@@ -3013,9 +2991,8 @@ static void set_line_char(struct cyclades_port *info) | |||
3013 | 2991 | ||
3014 | card = info->card; | 2992 | card = info->card; |
3015 | channel = info->line - card->first_line; | 2993 | channel = info->line - card->first_line; |
3016 | chip_number = channel / 4; | ||
3017 | 2994 | ||
3018 | if (!IS_CYC_Z(*card)) { | 2995 | if (!cy_is_Z(card)) { |
3019 | 2996 | ||
3020 | index = card->bus_index; | 2997 | index = card->bus_index; |
3021 | 2998 | ||
@@ -3233,21 +3210,17 @@ static void set_line_char(struct cyclades_port *info) | |||
3233 | } else { | 3210 | } else { |
3234 | struct FIRM_ID __iomem *firm_id; | 3211 | struct FIRM_ID __iomem *firm_id; |
3235 | struct ZFW_CTRL __iomem *zfw_ctrl; | 3212 | struct ZFW_CTRL __iomem *zfw_ctrl; |
3236 | struct BOARD_CTRL __iomem *board_ctrl; | ||
3237 | struct CH_CTRL __iomem *ch_ctrl; | 3213 | struct CH_CTRL __iomem *ch_ctrl; |
3238 | struct BUF_CTRL __iomem *buf_ctrl; | ||
3239 | __u32 sw_flow; | 3214 | __u32 sw_flow; |
3240 | int retval; | 3215 | int retval; |
3241 | 3216 | ||
3242 | firm_id = card->base_addr + ID_ADDRESS; | 3217 | firm_id = card->base_addr + ID_ADDRESS; |
3243 | if (!ISZLOADED(*card)) | 3218 | if (!cyz_is_loaded(card)) |
3244 | return; | 3219 | return; |
3245 | 3220 | ||
3246 | zfw_ctrl = card->base_addr + | 3221 | zfw_ctrl = card->base_addr + |
3247 | (readl(&firm_id->zfwctrl_addr) & 0xfffff); | 3222 | (readl(&firm_id->zfwctrl_addr) & 0xfffff); |
3248 | board_ctrl = &zfw_ctrl->board_ctrl; | ||
3249 | ch_ctrl = &(zfw_ctrl->ch_ctrl[channel]); | 3223 | ch_ctrl = &(zfw_ctrl->ch_ctrl[channel]); |
3250 | buf_ctrl = &zfw_ctrl->buf_ctrl[channel]; | ||
3251 | 3224 | ||
3252 | /* baud rate */ | 3225 | /* baud rate */ |
3253 | baud = tty_get_baud_rate(info->port.tty); | 3226 | baud = tty_get_baud_rate(info->port.tty); |
@@ -3457,7 +3430,7 @@ static int get_lsr_info(struct cyclades_port *info, unsigned int __user *value) | |||
3457 | 3430 | ||
3458 | card = info->card; | 3431 | card = info->card; |
3459 | channel = (info->line) - (card->first_line); | 3432 | channel = (info->line) - (card->first_line); |
3460 | if (!IS_CYC_Z(*card)) { | 3433 | if (!cy_is_Z(card)) { |
3461 | chip = channel >> 2; | 3434 | chip = channel >> 2; |
3462 | channel &= 0x03; | 3435 | channel &= 0x03; |
3463 | index = card->bus_index; | 3436 | index = card->bus_index; |
@@ -3497,7 +3470,7 @@ static int cy_tiocmget(struct tty_struct *tty, struct file *file) | |||
3497 | 3470 | ||
3498 | card = info->card; | 3471 | card = info->card; |
3499 | channel = info->line - card->first_line; | 3472 | channel = info->line - card->first_line; |
3500 | if (!IS_CYC_Z(*card)) { | 3473 | if (!cy_is_Z(card)) { |
3501 | chip = channel >> 2; | 3474 | chip = channel >> 2; |
3502 | channel &= 0x03; | 3475 | channel &= 0x03; |
3503 | index = card->bus_index; | 3476 | index = card->bus_index; |
@@ -3523,7 +3496,7 @@ static int cy_tiocmget(struct tty_struct *tty, struct file *file) | |||
3523 | } else { | 3496 | } else { |
3524 | base_addr = card->base_addr; | 3497 | base_addr = card->base_addr; |
3525 | firm_id = card->base_addr + ID_ADDRESS; | 3498 | firm_id = card->base_addr + ID_ADDRESS; |
3526 | if (ISZLOADED(*card)) { | 3499 | if (cyz_is_loaded(card)) { |
3527 | zfw_ctrl = card->base_addr + | 3500 | zfw_ctrl = card->base_addr + |
3528 | (readl(&firm_id->zfwctrl_addr) & 0xfffff); | 3501 | (readl(&firm_id->zfwctrl_addr) & 0xfffff); |
3529 | board_ctrl = &zfw_ctrl->board_ctrl; | 3502 | board_ctrl = &zfw_ctrl->board_ctrl; |
@@ -3566,7 +3539,7 @@ cy_tiocmset(struct tty_struct *tty, struct file *file, | |||
3566 | 3539 | ||
3567 | card = info->card; | 3540 | card = info->card; |
3568 | channel = (info->line) - (card->first_line); | 3541 | channel = (info->line) - (card->first_line); |
3569 | if (!IS_CYC_Z(*card)) { | 3542 | if (!cy_is_Z(card)) { |
3570 | chip = channel >> 2; | 3543 | chip = channel >> 2; |
3571 | channel &= 0x03; | 3544 | channel &= 0x03; |
3572 | index = card->bus_index; | 3545 | index = card->bus_index; |
@@ -3641,7 +3614,7 @@ cy_tiocmset(struct tty_struct *tty, struct file *file, | |||
3641 | base_addr = card->base_addr; | 3614 | base_addr = card->base_addr; |
3642 | 3615 | ||
3643 | firm_id = card->base_addr + ID_ADDRESS; | 3616 | firm_id = card->base_addr + ID_ADDRESS; |
3644 | if (ISZLOADED(*card)) { | 3617 | if (cyz_is_loaded(card)) { |
3645 | zfw_ctrl = card->base_addr + | 3618 | zfw_ctrl = card->base_addr + |
3646 | (readl(&firm_id->zfwctrl_addr) & 0xfffff); | 3619 | (readl(&firm_id->zfwctrl_addr) & 0xfffff); |
3647 | board_ctrl = &zfw_ctrl->board_ctrl; | 3620 | board_ctrl = &zfw_ctrl->board_ctrl; |
@@ -3713,7 +3686,7 @@ static int cy_break(struct tty_struct *tty, int break_state) | |||
3713 | card = info->card; | 3686 | card = info->card; |
3714 | 3687 | ||
3715 | spin_lock_irqsave(&card->card_lock, flags); | 3688 | spin_lock_irqsave(&card->card_lock, flags); |
3716 | if (!IS_CYC_Z(*card)) { | 3689 | if (!cy_is_Z(card)) { |
3717 | /* Let the transmit ISR take care of this (since it | 3690 | /* Let the transmit ISR take care of this (since it |
3718 | requires stuffing characters into the output stream). | 3691 | requires stuffing characters into the output stream). |
3719 | */ | 3692 | */ |
@@ -3782,7 +3755,7 @@ static int set_threshold(struct cyclades_port *info, unsigned long value) | |||
3782 | 3755 | ||
3783 | card = info->card; | 3756 | card = info->card; |
3784 | channel = info->line - card->first_line; | 3757 | channel = info->line - card->first_line; |
3785 | if (!IS_CYC_Z(*card)) { | 3758 | if (!cy_is_Z(card)) { |
3786 | chip = channel >> 2; | 3759 | chip = channel >> 2; |
3787 | channel &= 0x03; | 3760 | channel &= 0x03; |
3788 | index = card->bus_index; | 3761 | index = card->bus_index; |
@@ -3810,7 +3783,7 @@ static int get_threshold(struct cyclades_port *info, | |||
3810 | 3783 | ||
3811 | card = info->card; | 3784 | card = info->card; |
3812 | channel = info->line - card->first_line; | 3785 | channel = info->line - card->first_line; |
3813 | if (!IS_CYC_Z(*card)) { | 3786 | if (!cy_is_Z(card)) { |
3814 | chip = channel >> 2; | 3787 | chip = channel >> 2; |
3815 | channel &= 0x03; | 3788 | channel &= 0x03; |
3816 | index = card->bus_index; | 3789 | index = card->bus_index; |
@@ -3844,7 +3817,7 @@ static int set_timeout(struct cyclades_port *info, unsigned long value) | |||
3844 | 3817 | ||
3845 | card = info->card; | 3818 | card = info->card; |
3846 | channel = info->line - card->first_line; | 3819 | channel = info->line - card->first_line; |
3847 | if (!IS_CYC_Z(*card)) { | 3820 | if (!cy_is_Z(card)) { |
3848 | chip = channel >> 2; | 3821 | chip = channel >> 2; |
3849 | channel &= 0x03; | 3822 | channel &= 0x03; |
3850 | index = card->bus_index; | 3823 | index = card->bus_index; |
@@ -3867,7 +3840,7 @@ static int get_timeout(struct cyclades_port *info, | |||
3867 | 3840 | ||
3868 | card = info->card; | 3841 | card = info->card; |
3869 | channel = info->line - card->first_line; | 3842 | channel = info->line - card->first_line; |
3870 | if (!IS_CYC_Z(*card)) { | 3843 | if (!cy_is_Z(card)) { |
3871 | chip = channel >> 2; | 3844 | chip = channel >> 2; |
3872 | channel &= 0x03; | 3845 | channel &= 0x03; |
3873 | index = card->bus_index; | 3846 | index = card->bus_index; |
@@ -4121,7 +4094,7 @@ static void cy_send_xchar(struct tty_struct *tty, char ch) | |||
4121 | card = info->card; | 4094 | card = info->card; |
4122 | channel = info->line - card->first_line; | 4095 | channel = info->line - card->first_line; |
4123 | 4096 | ||
4124 | if (IS_CYC_Z(*card)) { | 4097 | if (cy_is_Z(card)) { |
4125 | if (ch == STOP_CHAR(tty)) | 4098 | if (ch == STOP_CHAR(tty)) |
4126 | cyz_issue_cmd(card, channel, C_CM_SENDXOFF, 0L); | 4099 | cyz_issue_cmd(card, channel, C_CM_SENDXOFF, 0L); |
4127 | else if (ch == START_CHAR(tty)) | 4100 | else if (ch == START_CHAR(tty)) |
@@ -4154,7 +4127,7 @@ static void cy_throttle(struct tty_struct *tty) | |||
4154 | card = info->card; | 4127 | card = info->card; |
4155 | 4128 | ||
4156 | if (I_IXOFF(tty)) { | 4129 | if (I_IXOFF(tty)) { |
4157 | if (!IS_CYC_Z(*card)) | 4130 | if (!cy_is_Z(card)) |
4158 | cy_send_xchar(tty, STOP_CHAR(tty)); | 4131 | cy_send_xchar(tty, STOP_CHAR(tty)); |
4159 | else | 4132 | else |
4160 | info->throttle = 1; | 4133 | info->throttle = 1; |
@@ -4162,7 +4135,7 @@ static void cy_throttle(struct tty_struct *tty) | |||
4162 | 4135 | ||
4163 | if (tty->termios->c_cflag & CRTSCTS) { | 4136 | if (tty->termios->c_cflag & CRTSCTS) { |
4164 | channel = info->line - card->first_line; | 4137 | channel = info->line - card->first_line; |
4165 | if (!IS_CYC_Z(*card)) { | 4138 | if (!cy_is_Z(card)) { |
4166 | chip = channel >> 2; | 4139 | chip = channel >> 2; |
4167 | channel &= 0x03; | 4140 | channel &= 0x03; |
4168 | index = card->bus_index; | 4141 | index = card->bus_index; |
@@ -4219,7 +4192,7 @@ static void cy_unthrottle(struct tty_struct *tty) | |||
4219 | if (tty->termios->c_cflag & CRTSCTS) { | 4192 | if (tty->termios->c_cflag & CRTSCTS) { |
4220 | card = info->card; | 4193 | card = info->card; |
4221 | channel = info->line - card->first_line; | 4194 | channel = info->line - card->first_line; |
4222 | if (!IS_CYC_Z(*card)) { | 4195 | if (!cy_is_Z(card)) { |
4223 | chip = channel >> 2; | 4196 | chip = channel >> 2; |
4224 | channel &= 0x03; | 4197 | channel &= 0x03; |
4225 | index = card->bus_index; | 4198 | index = card->bus_index; |
@@ -4263,7 +4236,7 @@ static void cy_stop(struct tty_struct *tty) | |||
4263 | 4236 | ||
4264 | cinfo = info->card; | 4237 | cinfo = info->card; |
4265 | channel = info->line - cinfo->first_line; | 4238 | channel = info->line - cinfo->first_line; |
4266 | if (!IS_CYC_Z(*cinfo)) { | 4239 | if (!cy_is_Z(cinfo)) { |
4267 | index = cinfo->bus_index; | 4240 | index = cinfo->bus_index; |
4268 | chip = channel >> 2; | 4241 | chip = channel >> 2; |
4269 | channel &= 0x03; | 4242 | channel &= 0x03; |
@@ -4296,7 +4269,7 @@ static void cy_start(struct tty_struct *tty) | |||
4296 | cinfo = info->card; | 4269 | cinfo = info->card; |
4297 | channel = info->line - cinfo->first_line; | 4270 | channel = info->line - cinfo->first_line; |
4298 | index = cinfo->bus_index; | 4271 | index = cinfo->bus_index; |
4299 | if (!IS_CYC_Z(*cinfo)) { | 4272 | if (!cy_is_Z(cinfo)) { |
4300 | chip = channel >> 2; | 4273 | chip = channel >> 2; |
4301 | channel &= 0x03; | 4274 | channel &= 0x03; |
4302 | base_addr = cinfo->base_addr + (cy_chip_offset[chip] << index); | 4275 | base_addr = cinfo->base_addr + (cy_chip_offset[chip] << index); |
@@ -4347,33 +4320,20 @@ static void cy_hangup(struct tty_struct *tty) | |||
4347 | static int __devinit cy_init_card(struct cyclades_card *cinfo) | 4320 | static int __devinit cy_init_card(struct cyclades_card *cinfo) |
4348 | { | 4321 | { |
4349 | struct cyclades_port *info; | 4322 | struct cyclades_port *info; |
4350 | u32 uninitialized_var(mailbox); | 4323 | unsigned int port; |
4351 | unsigned int nports, port; | ||
4352 | unsigned short chip_number; | 4324 | unsigned short chip_number; |
4353 | int uninitialized_var(index); | ||
4354 | 4325 | ||
4355 | spin_lock_init(&cinfo->card_lock); | 4326 | spin_lock_init(&cinfo->card_lock); |
4327 | cinfo->intr_enabled = 0; | ||
4356 | 4328 | ||
4357 | if (IS_CYC_Z(*cinfo)) { /* Cyclades-Z */ | 4329 | cinfo->ports = kcalloc(cinfo->nports, sizeof(*cinfo->ports), |
4358 | mailbox = readl(&((struct RUNTIME_9060 __iomem *) | 4330 | GFP_KERNEL); |
4359 | cinfo->ctl_addr)->mail_box_0); | ||
4360 | nports = (mailbox == ZE_V1) ? ZE_V1_NPORTS : 8; | ||
4361 | cinfo->intr_enabled = 0; | ||
4362 | cinfo->nports = 0; /* Will be correctly set later, after | ||
4363 | Z FW is loaded */ | ||
4364 | } else { | ||
4365 | index = cinfo->bus_index; | ||
4366 | nports = cinfo->nports = CyPORTS_PER_CHIP * cinfo->num_chips; | ||
4367 | } | ||
4368 | |||
4369 | cinfo->ports = kzalloc(sizeof(*cinfo->ports) * nports, GFP_KERNEL); | ||
4370 | if (cinfo->ports == NULL) { | 4331 | if (cinfo->ports == NULL) { |
4371 | printk(KERN_ERR "Cyclades: cannot allocate ports\n"); | 4332 | printk(KERN_ERR "Cyclades: cannot allocate ports\n"); |
4372 | cinfo->nports = 0; | ||
4373 | return -ENOMEM; | 4333 | return -ENOMEM; |
4374 | } | 4334 | } |
4375 | 4335 | ||
4376 | for (port = cinfo->first_line; port < cinfo->first_line + nports; | 4336 | for (port = cinfo->first_line; port < cinfo->first_line + cinfo->nports; |
4377 | port++) { | 4337 | port++) { |
4378 | info = &cinfo->ports[port - cinfo->first_line]; | 4338 | info = &cinfo->ports[port - cinfo->first_line]; |
4379 | tty_port_init(&info->port); | 4339 | tty_port_init(&info->port); |
@@ -4387,9 +4347,9 @@ static int __devinit cy_init_card(struct cyclades_card *cinfo) | |||
4387 | init_completion(&info->shutdown_wait); | 4347 | init_completion(&info->shutdown_wait); |
4388 | init_waitqueue_head(&info->delta_msr_wait); | 4348 | init_waitqueue_head(&info->delta_msr_wait); |
4389 | 4349 | ||
4390 | if (IS_CYC_Z(*cinfo)) { | 4350 | if (cy_is_Z(cinfo)) { |
4391 | info->type = PORT_STARTECH; | 4351 | info->type = PORT_STARTECH; |
4392 | if (mailbox == ZO_V1) | 4352 | if (cinfo->hw_ver == ZO_V1) |
4393 | info->xmit_fifo_size = CYZ_FIFO_SIZE; | 4353 | info->xmit_fifo_size = CYZ_FIFO_SIZE; |
4394 | else | 4354 | else |
4395 | info->xmit_fifo_size = 4 * CYZ_FIFO_SIZE; | 4355 | info->xmit_fifo_size = 4 * CYZ_FIFO_SIZE; |
@@ -4398,6 +4358,7 @@ static int __devinit cy_init_card(struct cyclades_card *cinfo) | |||
4398 | cyz_rx_restart, (unsigned long)info); | 4358 | cyz_rx_restart, (unsigned long)info); |
4399 | #endif | 4359 | #endif |
4400 | } else { | 4360 | } else { |
4361 | int index = cinfo->bus_index; | ||
4401 | info->type = PORT_CIRRUS; | 4362 | info->type = PORT_CIRRUS; |
4402 | info->xmit_fifo_size = CyMAX_CHAR_FIFO; | 4363 | info->xmit_fifo_size = CyMAX_CHAR_FIFO; |
4403 | info->cor1 = CyPARITY_NONE | Cy_1_STOP | Cy_8_BITS; | 4364 | info->cor1 = CyPARITY_NONE | Cy_1_STOP | Cy_8_BITS; |
@@ -4430,7 +4391,7 @@ static int __devinit cy_init_card(struct cyclades_card *cinfo) | |||
4430 | } | 4391 | } |
4431 | 4392 | ||
4432 | #ifndef CONFIG_CYZ_INTR | 4393 | #ifndef CONFIG_CYZ_INTR |
4433 | if (IS_CYC_Z(*cinfo) && !timer_pending(&cyz_timerlist)) { | 4394 | if (cy_is_Z(cinfo) && !timer_pending(&cyz_timerlist)) { |
4434 | mod_timer(&cyz_timerlist, jiffies + 1); | 4395 | mod_timer(&cyz_timerlist, jiffies + 1); |
4435 | #ifdef CY_PCI_DEBUG | 4396 | #ifdef CY_PCI_DEBUG |
4436 | printk(KERN_DEBUG "Cyclades-Z polling initialized\n"); | 4397 | printk(KERN_DEBUG "Cyclades-Z polling initialized\n"); |
@@ -4621,11 +4582,12 @@ static int __init cy_detect_isa(void) | |||
4621 | 4582 | ||
4622 | /* set cy_card */ | 4583 | /* set cy_card */ |
4623 | cy_card[j].base_addr = cy_isa_address; | 4584 | cy_card[j].base_addr = cy_isa_address; |
4624 | cy_card[j].ctl_addr = NULL; | 4585 | cy_card[j].ctl_addr.p9050 = NULL; |
4625 | cy_card[j].irq = (int)cy_isa_irq; | 4586 | cy_card[j].irq = (int)cy_isa_irq; |
4626 | cy_card[j].bus_index = 0; | 4587 | cy_card[j].bus_index = 0; |
4627 | cy_card[j].first_line = cy_next_channel; | 4588 | cy_card[j].first_line = cy_next_channel; |
4628 | cy_card[j].num_chips = cy_isa_nchan / 4; | 4589 | cy_card[j].num_chips = cy_isa_nchan / CyPORTS_PER_CHIP; |
4590 | cy_card[j].nports = cy_isa_nchan; | ||
4629 | if (cy_init_card(&cy_card[j])) { | 4591 | if (cy_init_card(&cy_card[j])) { |
4630 | cy_card[j].base_addr = NULL; | 4592 | cy_card[j].base_addr = NULL; |
4631 | free_irq(cy_isa_irq, &cy_card[j]); | 4593 | free_irq(cy_isa_irq, &cy_card[j]); |
@@ -4781,7 +4743,7 @@ static int __devinit cyz_load_fw(struct pci_dev *pdev, void __iomem *base_addr, | |||
4781 | struct CUSTOM_REG __iomem *cust = base_addr; | 4743 | struct CUSTOM_REG __iomem *cust = base_addr; |
4782 | struct ZFW_CTRL __iomem *pt_zfwctrl; | 4744 | struct ZFW_CTRL __iomem *pt_zfwctrl; |
4783 | void __iomem *tmp; | 4745 | void __iomem *tmp; |
4784 | u32 mailbox, status; | 4746 | u32 mailbox, status, nchan; |
4785 | unsigned int i; | 4747 | unsigned int i; |
4786 | int retval; | 4748 | int retval; |
4787 | 4749 | ||
@@ -4793,7 +4755,7 @@ static int __devinit cyz_load_fw(struct pci_dev *pdev, void __iomem *base_addr, | |||
4793 | 4755 | ||
4794 | /* Check whether the firmware is already loaded and running. If | 4756 | /* Check whether the firmware is already loaded and running. If |
4795 | positive, skip this board */ | 4757 | positive, skip this board */ |
4796 | if (Z_FPGA_LOADED(ctl_addr) && readl(&fid->signature) == ZFIRM_ID) { | 4758 | if (__cyz_fpga_loaded(ctl_addr) && readl(&fid->signature) == ZFIRM_ID) { |
4797 | u32 cntval = readl(base_addr + 0x190); | 4759 | u32 cntval = readl(base_addr + 0x190); |
4798 | 4760 | ||
4799 | udelay(100); | 4761 | udelay(100); |
@@ -4812,7 +4774,7 @@ static int __devinit cyz_load_fw(struct pci_dev *pdev, void __iomem *base_addr, | |||
4812 | 4774 | ||
4813 | mailbox = readl(&ctl_addr->mail_box_0); | 4775 | mailbox = readl(&ctl_addr->mail_box_0); |
4814 | 4776 | ||
4815 | if (mailbox == 0 || Z_FPGA_LOADED(ctl_addr)) { | 4777 | if (mailbox == 0 || __cyz_fpga_loaded(ctl_addr)) { |
4816 | /* stops CPU and set window to beginning of RAM */ | 4778 | /* stops CPU and set window to beginning of RAM */ |
4817 | cy_writel(&ctl_addr->loc_addr_base, WIN_CREG); | 4779 | cy_writel(&ctl_addr->loc_addr_base, WIN_CREG); |
4818 | cy_writel(&cust->cpu_stop, 0); | 4780 | cy_writel(&cust->cpu_stop, 0); |
@@ -4828,7 +4790,7 @@ static int __devinit cyz_load_fw(struct pci_dev *pdev, void __iomem *base_addr, | |||
4828 | base_addr); | 4790 | base_addr); |
4829 | if (retval) | 4791 | if (retval) |
4830 | goto err_rel; | 4792 | goto err_rel; |
4831 | if (!Z_FPGA_LOADED(ctl_addr)) { | 4793 | if (!__cyz_fpga_loaded(ctl_addr)) { |
4832 | dev_err(&pdev->dev, "fw upload successful, but fw is " | 4794 | dev_err(&pdev->dev, "fw upload successful, but fw is " |
4833 | "not loaded\n"); | 4795 | "not loaded\n"); |
4834 | goto err_rel; | 4796 | goto err_rel; |
@@ -4887,7 +4849,7 @@ static int __devinit cyz_load_fw(struct pci_dev *pdev, void __iomem *base_addr, | |||
4887 | "system before loading the new FW to the " | 4849 | "system before loading the new FW to the " |
4888 | "Cyclades-Z.\n"); | 4850 | "Cyclades-Z.\n"); |
4889 | 4851 | ||
4890 | if (Z_FPGA_LOADED(ctl_addr)) | 4852 | if (__cyz_fpga_loaded(ctl_addr)) |
4891 | plx_init(pdev, irq, ctl_addr); | 4853 | plx_init(pdev, irq, ctl_addr); |
4892 | 4854 | ||
4893 | retval = -EIO; | 4855 | retval = -EIO; |
@@ -4902,16 +4864,16 @@ static int __devinit cyz_load_fw(struct pci_dev *pdev, void __iomem *base_addr, | |||
4902 | base_addr + ID_ADDRESS, readl(&fid->zfwctrl_addr), | 4864 | base_addr + ID_ADDRESS, readl(&fid->zfwctrl_addr), |
4903 | base_addr + readl(&fid->zfwctrl_addr)); | 4865 | base_addr + readl(&fid->zfwctrl_addr)); |
4904 | 4866 | ||
4867 | nchan = readl(&pt_zfwctrl->board_ctrl.n_channel); | ||
4905 | dev_info(&pdev->dev, "Cyclades-Z FW loaded: version = %x, ports = %u\n", | 4868 | dev_info(&pdev->dev, "Cyclades-Z FW loaded: version = %x, ports = %u\n", |
4906 | readl(&pt_zfwctrl->board_ctrl.fw_version), | 4869 | readl(&pt_zfwctrl->board_ctrl.fw_version), nchan); |
4907 | readl(&pt_zfwctrl->board_ctrl.n_channel)); | ||
4908 | 4870 | ||
4909 | if (readl(&pt_zfwctrl->board_ctrl.n_channel) == 0) { | 4871 | if (nchan == 0) { |
4910 | dev_warn(&pdev->dev, "no Cyclades-Z ports were found. Please " | 4872 | dev_warn(&pdev->dev, "no Cyclades-Z ports were found. Please " |
4911 | "check the connection between the Z host card and the " | 4873 | "check the connection between the Z host card and the " |
4912 | "serial expanders.\n"); | 4874 | "serial expanders.\n"); |
4913 | 4875 | ||
4914 | if (Z_FPGA_LOADED(ctl_addr)) | 4876 | if (__cyz_fpga_loaded(ctl_addr)) |
4915 | plx_init(pdev, irq, ctl_addr); | 4877 | plx_init(pdev, irq, ctl_addr); |
4916 | 4878 | ||
4917 | dev_info(&pdev->dev, "Null number of ports detected. Board " | 4879 | dev_info(&pdev->dev, "Null number of ports detected. Board " |
@@ -4932,9 +4894,7 @@ static int __devinit cyz_load_fw(struct pci_dev *pdev, void __iomem *base_addr, | |||
4932 | cy_writel(&ctl_addr->intr_ctrl_stat, readl(&ctl_addr->intr_ctrl_stat) | | 4894 | cy_writel(&ctl_addr->intr_ctrl_stat, readl(&ctl_addr->intr_ctrl_stat) | |
4933 | 0x00030800UL); | 4895 | 0x00030800UL); |
4934 | 4896 | ||
4935 | plx_init(pdev, irq, ctl_addr); | 4897 | return nchan; |
4936 | |||
4937 | return 0; | ||
4938 | err_rel: | 4898 | err_rel: |
4939 | release_firmware(fw); | 4899 | release_firmware(fw); |
4940 | err: | 4900 | err: |
@@ -4946,7 +4906,7 @@ static int __devinit cy_pci_probe(struct pci_dev *pdev, | |||
4946 | { | 4906 | { |
4947 | void __iomem *addr0 = NULL, *addr2 = NULL; | 4907 | void __iomem *addr0 = NULL, *addr2 = NULL; |
4948 | char *card_name = NULL; | 4908 | char *card_name = NULL; |
4949 | u32 mailbox; | 4909 | u32 uninitialized_var(mailbox); |
4950 | unsigned int device_id, nchan = 0, card_no, i; | 4910 | unsigned int device_id, nchan = 0, card_no, i; |
4951 | unsigned char plx_ver; | 4911 | unsigned char plx_ver; |
4952 | int retval, irq; | 4912 | int retval, irq; |
@@ -5023,11 +4983,12 @@ static int __devinit cy_pci_probe(struct pci_dev *pdev, | |||
5023 | } | 4983 | } |
5024 | 4984 | ||
5025 | /* Disable interrupts on the PLX before resetting it */ | 4985 | /* Disable interrupts on the PLX before resetting it */ |
5026 | cy_writew(addr0 + 0x68, readw(addr0 + 0x68) & ~0x0900); | 4986 | cy_writew(&ctl_addr->intr_ctrl_stat, |
4987 | readw(&ctl_addr->intr_ctrl_stat) & ~0x0900); | ||
5027 | 4988 | ||
5028 | plx_init(pdev, irq, addr0); | 4989 | plx_init(pdev, irq, addr0); |
5029 | 4990 | ||
5030 | mailbox = (u32)readl(&ctl_addr->mail_box_0); | 4991 | mailbox = readl(&ctl_addr->mail_box_0); |
5031 | 4992 | ||
5032 | addr2 = ioremap_nocache(pci_resource_start(pdev, 2), | 4993 | addr2 = ioremap_nocache(pci_resource_start(pdev, 2), |
5033 | mailbox == ZE_V1 ? CyPCI_Ze_win : CyPCI_Zwin); | 4994 | mailbox == ZE_V1 ? CyPCI_Ze_win : CyPCI_Zwin); |
@@ -5038,12 +4999,8 @@ static int __devinit cy_pci_probe(struct pci_dev *pdev, | |||
5038 | 4999 | ||
5039 | if (mailbox == ZE_V1) { | 5000 | if (mailbox == ZE_V1) { |
5040 | card_name = "Cyclades-Ze"; | 5001 | card_name = "Cyclades-Ze"; |
5041 | |||
5042 | readl(&ctl_addr->mail_box_0); | ||
5043 | nchan = ZE_V1_NPORTS; | ||
5044 | } else { | 5002 | } else { |
5045 | card_name = "Cyclades-8Zo"; | 5003 | card_name = "Cyclades-8Zo"; |
5046 | |||
5047 | #ifdef CY_PCI_DEBUG | 5004 | #ifdef CY_PCI_DEBUG |
5048 | if (mailbox == ZO_V1) { | 5005 | if (mailbox == ZO_V1) { |
5049 | cy_writel(&ctl_addr->loc_addr_base, WIN_CREG); | 5006 | cy_writel(&ctl_addr->loc_addr_base, WIN_CREG); |
@@ -5065,15 +5022,12 @@ static int __devinit cy_pci_probe(struct pci_dev *pdev, | |||
5065 | */ | 5022 | */ |
5066 | if ((mailbox == ZO_V1) || (mailbox == ZO_V2)) | 5023 | if ((mailbox == ZO_V1) || (mailbox == ZO_V2)) |
5067 | cy_writel(addr2 + ID_ADDRESS, 0L); | 5024 | cy_writel(addr2 + ID_ADDRESS, 0L); |
5068 | |||
5069 | retval = cyz_load_fw(pdev, addr2, addr0, irq); | ||
5070 | if (retval) | ||
5071 | goto err_unmap; | ||
5072 | /* This must be a Cyclades-8Zo/PCI. The extendable | ||
5073 | version will have a different device_id and will | ||
5074 | be allocated its maximum number of ports. */ | ||
5075 | nchan = 8; | ||
5076 | } | 5025 | } |
5026 | |||
5027 | retval = cyz_load_fw(pdev, addr2, addr0, irq); | ||
5028 | if (retval <= 0) | ||
5029 | goto err_unmap; | ||
5030 | nchan = retval; | ||
5077 | } | 5031 | } |
5078 | 5032 | ||
5079 | if ((cy_next_channel + nchan) > NR_PORTS) { | 5033 | if ((cy_next_channel + nchan) > NR_PORTS) { |
@@ -5103,8 +5057,10 @@ static int __devinit cy_pci_probe(struct pci_dev *pdev, | |||
5103 | dev_err(&pdev->dev, "could not allocate IRQ\n"); | 5057 | dev_err(&pdev->dev, "could not allocate IRQ\n"); |
5104 | goto err_unmap; | 5058 | goto err_unmap; |
5105 | } | 5059 | } |
5106 | cy_card[card_no].num_chips = nchan / 4; | 5060 | cy_card[card_no].num_chips = nchan / CyPORTS_PER_CHIP; |
5107 | } else { | 5061 | } else { |
5062 | cy_card[card_no].hw_ver = mailbox; | ||
5063 | cy_card[card_no].num_chips = (unsigned int)-1; | ||
5108 | #ifdef CONFIG_CYZ_INTR | 5064 | #ifdef CONFIG_CYZ_INTR |
5109 | /* allocate IRQ only if board has an IRQ */ | 5065 | /* allocate IRQ only if board has an IRQ */ |
5110 | if (irq != 0 && irq != 255) { | 5066 | if (irq != 0 && irq != 255) { |
@@ -5117,15 +5073,15 @@ static int __devinit cy_pci_probe(struct pci_dev *pdev, | |||
5117 | } | 5073 | } |
5118 | } | 5074 | } |
5119 | #endif /* CONFIG_CYZ_INTR */ | 5075 | #endif /* CONFIG_CYZ_INTR */ |
5120 | cy_card[card_no].num_chips = (unsigned int)-1; | ||
5121 | } | 5076 | } |
5122 | 5077 | ||
5123 | /* set cy_card */ | 5078 | /* set cy_card */ |
5124 | cy_card[card_no].base_addr = addr2; | 5079 | cy_card[card_no].base_addr = addr2; |
5125 | cy_card[card_no].ctl_addr = addr0; | 5080 | cy_card[card_no].ctl_addr.p9050 = addr0; |
5126 | cy_card[card_no].irq = irq; | 5081 | cy_card[card_no].irq = irq; |
5127 | cy_card[card_no].bus_index = 1; | 5082 | cy_card[card_no].bus_index = 1; |
5128 | cy_card[card_no].first_line = cy_next_channel; | 5083 | cy_card[card_no].first_line = cy_next_channel; |
5084 | cy_card[card_no].nports = nchan; | ||
5129 | retval = cy_init_card(&cy_card[card_no]); | 5085 | retval = cy_init_card(&cy_card[card_no]); |
5130 | if (retval) | 5086 | if (retval) |
5131 | goto err_null; | 5087 | goto err_null; |
@@ -5138,17 +5094,20 @@ static int __devinit cy_pci_probe(struct pci_dev *pdev, | |||
5138 | plx_ver = readb(addr2 + CyPLX_VER) & 0x0f; | 5094 | plx_ver = readb(addr2 + CyPLX_VER) & 0x0f; |
5139 | switch (plx_ver) { | 5095 | switch (plx_ver) { |
5140 | case PLX_9050: | 5096 | case PLX_9050: |
5141 | |||
5142 | cy_writeb(addr0 + 0x4c, 0x43); | 5097 | cy_writeb(addr0 + 0x4c, 0x43); |
5143 | break; | 5098 | break; |
5144 | 5099 | ||
5145 | case PLX_9060: | 5100 | case PLX_9060: |
5146 | case PLX_9080: | 5101 | case PLX_9080: |
5147 | default: /* Old boards, use PLX_9060 */ | 5102 | default: /* Old boards, use PLX_9060 */ |
5148 | plx_init(pdev, irq, addr0); | 5103 | { |
5149 | cy_writew(addr0 + 0x68, readw(addr0 + 0x68) | 0x0900); | 5104 | struct RUNTIME_9060 __iomem *ctl_addr = addr0; |
5105 | plx_init(pdev, irq, ctl_addr); | ||
5106 | cy_writew(&ctl_addr->intr_ctrl_stat, | ||
5107 | readw(&ctl_addr->intr_ctrl_stat) | 0x0900); | ||
5150 | break; | 5108 | break; |
5151 | } | 5109 | } |
5110 | } | ||
5152 | } | 5111 | } |
5153 | 5112 | ||
5154 | dev_info(&pdev->dev, "%s/PCI #%d found: %d channels starting from " | 5113 | dev_info(&pdev->dev, "%s/PCI #%d found: %d channels starting from " |
@@ -5179,22 +5138,23 @@ static void __devexit cy_pci_remove(struct pci_dev *pdev) | |||
5179 | unsigned int i; | 5138 | unsigned int i; |
5180 | 5139 | ||
5181 | /* non-Z with old PLX */ | 5140 | /* non-Z with old PLX */ |
5182 | if (!IS_CYC_Z(*cinfo) && (readb(cinfo->base_addr + CyPLX_VER) & 0x0f) == | 5141 | if (!cy_is_Z(cinfo) && (readb(cinfo->base_addr + CyPLX_VER) & 0x0f) == |
5183 | PLX_9050) | 5142 | PLX_9050) |
5184 | cy_writeb(cinfo->ctl_addr + 0x4c, 0); | 5143 | cy_writeb(cinfo->ctl_addr.p9050 + 0x4c, 0); |
5185 | else | 5144 | else |
5186 | #ifndef CONFIG_CYZ_INTR | 5145 | #ifndef CONFIG_CYZ_INTR |
5187 | if (!IS_CYC_Z(*cinfo)) | 5146 | if (!cy_is_Z(cinfo)) |
5188 | #endif | 5147 | #endif |
5189 | cy_writew(cinfo->ctl_addr + 0x68, | 5148 | cy_writew(&cinfo->ctl_addr.p9060->intr_ctrl_stat, |
5190 | readw(cinfo->ctl_addr + 0x68) & ~0x0900); | 5149 | readw(&cinfo->ctl_addr.p9060->intr_ctrl_stat) & |
5150 | ~0x0900); | ||
5191 | 5151 | ||
5192 | iounmap(cinfo->base_addr); | 5152 | iounmap(cinfo->base_addr); |
5193 | if (cinfo->ctl_addr) | 5153 | if (cinfo->ctl_addr.p9050) |
5194 | iounmap(cinfo->ctl_addr); | 5154 | iounmap(cinfo->ctl_addr.p9050); |
5195 | if (cinfo->irq | 5155 | if (cinfo->irq |
5196 | #ifndef CONFIG_CYZ_INTR | 5156 | #ifndef CONFIG_CYZ_INTR |
5197 | && !IS_CYC_Z(*cinfo) | 5157 | && !cy_is_Z(cinfo) |
5198 | #endif /* CONFIG_CYZ_INTR */ | 5158 | #endif /* CONFIG_CYZ_INTR */ |
5199 | ) | 5159 | ) |
5200 | free_irq(cinfo->irq, cinfo); | 5160 | free_irq(cinfo->irq, cinfo); |
@@ -5240,7 +5200,7 @@ static int cyclades_proc_show(struct seq_file *m, void *v) | |||
5240 | (cur_jifs - info->idle_stats.recv_idle)/ | 5200 | (cur_jifs - info->idle_stats.recv_idle)/ |
5241 | HZ, info->idle_stats.overruns, | 5201 | HZ, info->idle_stats.overruns, |
5242 | /* FIXME: double check locking */ | 5202 | /* FIXME: double check locking */ |
5243 | (long)info->port.tty->ldisc.ops->num); | 5203 | (long)info->port.tty->ldisc->ops->num); |
5244 | else | 5204 | else |
5245 | seq_printf(m, "%3d %8lu %10lu %8lu " | 5205 | seq_printf(m, "%3d %8lu %10lu %8lu " |
5246 | "%10lu %8lu %9lu %6ld\n", | 5206 | "%10lu %8lu %9lu %6ld\n", |
@@ -5386,11 +5346,11 @@ static void __exit cy_cleanup_module(void) | |||
5386 | /* clear interrupt */ | 5346 | /* clear interrupt */ |
5387 | cy_writeb(card->base_addr + Cy_ClrIntr, 0); | 5347 | cy_writeb(card->base_addr + Cy_ClrIntr, 0); |
5388 | iounmap(card->base_addr); | 5348 | iounmap(card->base_addr); |
5389 | if (card->ctl_addr) | 5349 | if (card->ctl_addr.p9050) |
5390 | iounmap(card->ctl_addr); | 5350 | iounmap(card->ctl_addr.p9050); |
5391 | if (card->irq | 5351 | if (card->irq |
5392 | #ifndef CONFIG_CYZ_INTR | 5352 | #ifndef CONFIG_CYZ_INTR |
5393 | && !IS_CYC_Z(*card) | 5353 | && !cy_is_Z(card) |
5394 | #endif /* CONFIG_CYZ_INTR */ | 5354 | #endif /* CONFIG_CYZ_INTR */ |
5395 | ) | 5355 | ) |
5396 | free_irq(card->irq, card); | 5356 | free_irq(card->irq, card); |