Lines Matching +full:overrun +full:- +full:throttle +full:- +full:ms
1 // SPDX-License-Identifier: GPL-2.0
13 * Copyright (C) 2007-2009 Jiri Slaby <jirislaby@gmail.com>
17 * extensively rewritten by Theodore Ts'o, 8/16/92 -- 9/14/92,
137 Cyclom-Y/ISA boards at all addresses in here. If you want the
165 /* This is the per-card data structure containing address, irq, number of
175 * are accessed via settings in info->port.flags.
226 * CD1400-based boards (rev. 6.00 or later), there is no need for special
236 /* The Cyclom-Ye has placed the sequential chips in non-sequential
237 * address order. This look-up table overcomes that problem.
284 /* The Cyclades-Z polling cycle is defined by this variable */
295 struct cyclades_card *card = port->card; in cyy_writeb()
297 cy_writeb(port->u.cyy.base_addr + (reg << card->bus_index), val); in cyy_writeb()
302 struct cyclades_card *card = port->card; in cyy_readb()
304 return readb(port->u.cyy.base_addr + (reg << card->bus_index)); in cyy_readb()
309 return card->num_chips == (unsigned int)-1; in cy_is_Z()
314 return readl(&ctl_addr->init_ctrl) & (1 << 17); in __cyz_fpga_loaded()
319 return __cyz_fpga_loaded(card->ctl_addr.p9060); in cyz_fpga_loaded()
324 struct FIRM_ID __iomem *fw_id = card->base_addr + ID_ADDRESS; in cyz_is_loaded()
326 return (card->hw_ver == ZO_V1 || cyz_fpga_loaded(card)) && in cyz_is_loaded()
327 readl(&fw_id->signature) == ZFIRM_ID; in cyz_is_loaded()
340 if (info->magic != CYCLADES_MAGIC) { in serial_paranoia_check()
350 /********* Start of block of Cyclom-Y specific code ********/
352 /* This routine waits up to 1000 micro-seconds for the previous
357 This function is only called from inside spinlock-protected code.
373 return -1; in __cyy_issue_cmd()
383 return __cyy_issue_cmd(port->u.cyy.base_addr, cmd, in cyy_issue_cmd()
384 port->card->bus_index); in cyy_issue_cmd()
443 int len, index = cinfo->bus_index; in cyy_chip_rx()
452 info = &cinfo->ports[channel + chip * 4]; in cyy_chip_rx()
453 port = &info->port; in cyy_chip_rx()
464 info->icount.brk++; in cyy_chip_rx()
466 info->icount.frame++; in cyy_chip_rx()
468 info->icount.parity++; in cyy_chip_rx()
470 info->icount.overrun++; in cyy_chip_rx()
472 if (data & info->ignore_status_mask) { in cyy_chip_rx()
473 info->icount.rx++; in cyy_chip_rx()
477 if (data & info->read_status_mask) { in cyy_chip_rx()
482 info->icount.rx++; in cyy_chip_rx()
483 if (port->flags & ASYNC_SAK) { in cyy_chip_rx()
495 info->icount.rx++; in cyy_chip_rx()
496 info->idle_stats.frame_errs++; in cyy_chip_rx()
502 info->icount.rx++; in cyy_chip_rx()
503 info->idle_stats.parity_errs++; in cyy_chip_rx()
507 info->icount.rx++; in cyy_chip_rx()
515 info->icount.rx++; in cyy_chip_rx()
516 info->idle_stats.overruns++; in cyy_chip_rx()
524 info->icount.rx++; in cyy_chip_rx()
528 info->icount.rx++; in cyy_chip_rx()
531 /* there was a software buffer overrun and nothing in cyy_chip_rx()
533 info->icount.buf_overrun++; in cyy_chip_rx()
534 info->idle_stats.overruns++; in cyy_chip_rx()
541 ++info->mon.int_count; in cyy_chip_rx()
542 info->mon.char_count += char_count; in cyy_chip_rx()
543 if (char_count > info->mon.char_max) in cyy_chip_rx()
544 info->mon.char_max = char_count; in cyy_chip_rx()
545 info->mon.char_last = char_count; in cyy_chip_rx()
548 while (len--) { in cyy_chip_rx()
551 info->idle_stats.recv_bytes++; in cyy_chip_rx()
552 info->icount.rx++; in cyy_chip_rx()
557 info->idle_stats.recv_idle = jiffies; in cyy_chip_rx()
571 int char_count, index = cinfo->bus_index; in cyy_chip_tx()
587 info = &cinfo->ports[channel + chip * 4]; in cyy_chip_tx()
588 tty = tty_port_tty_get(&info->port); in cyy_chip_tx()
594 /* load the on-chip space for outbound data */ in cyy_chip_tx()
595 char_count = info->xmit_fifo_size; in cyy_chip_tx()
597 if (info->x_char) { /* send special char */ in cyy_chip_tx()
598 outch = info->x_char; in cyy_chip_tx()
600 char_count--; in cyy_chip_tx()
601 info->icount.tx++; in cyy_chip_tx()
602 info->x_char = 0; in cyy_chip_tx()
605 if (info->breakon || info->breakoff) { in cyy_chip_tx()
606 if (info->breakon) { in cyy_chip_tx()
609 info->breakon = 0; in cyy_chip_tx()
610 char_count -= 2; in cyy_chip_tx()
612 if (info->breakoff) { in cyy_chip_tx()
615 info->breakoff = 0; in cyy_chip_tx()
616 char_count -= 2; in cyy_chip_tx()
620 while (char_count-- > 0) { in cyy_chip_tx()
621 if (!info->xmit_cnt) { in cyy_chip_tx()
631 if (info->port.xmit_buf == NULL) { in cyy_chip_tx()
636 if (tty->stopped || tty->hw_stopped) { in cyy_chip_tx()
650 outch = info->port.xmit_buf[info->xmit_tail]; in cyy_chip_tx()
652 info->xmit_cnt--; in cyy_chip_tx()
653 info->xmit_tail = (info->xmit_tail + 1) & in cyy_chip_tx()
654 (SERIAL_XMIT_SIZE - 1); in cyy_chip_tx()
656 info->icount.tx++; in cyy_chip_tx()
659 info->xmit_cnt--; in cyy_chip_tx()
660 info->xmit_tail = (info->xmit_tail + 1) & in cyy_chip_tx()
661 (SERIAL_XMIT_SIZE - 1); in cyy_chip_tx()
664 info->icount.tx++; in cyy_chip_tx()
665 char_count--; in cyy_chip_tx()
684 int index = cinfo->bus_index; in cyy_chip_modem()
690 info = &cinfo->ports[channel + chip * 4]; in cyy_chip_modem()
697 tty = tty_port_tty_get(&info->port); in cyy_chip_modem()
704 info->icount.dcd++; in cyy_chip_modem()
706 info->icount.cts++; in cyy_chip_modem()
708 info->icount.dsr++; in cyy_chip_modem()
710 info->icount.rng++; in cyy_chip_modem()
712 wake_up_interruptible(&info->port.delta_msr_wait); in cyy_chip_modem()
715 if ((mdm_change & CyDCD) && tty_port_check_carrier(&info->port)) { in cyy_chip_modem()
717 wake_up_interruptible(&info->port.open_wait); in cyy_chip_modem()
721 if ((mdm_change & CyCTS) && tty_port_cts_enabled(&info->port)) { in cyy_chip_modem()
722 if (tty->hw_stopped) { in cyy_chip_modem()
726 tty->hw_stopped = 0; in cyy_chip_modem()
735 tty->hw_stopped = 1; in cyy_chip_modem()
753 whenever the card wants its hand held--chars
772 card_base_addr = cinfo->base_addr; in cyy_interrupt()
773 index = cinfo->bus_index; in cyy_interrupt()
786 for (chip = 0; chip < cinfo->num_chips; chip++) { in cyy_interrupt()
787 base_addr = cinfo->base_addr + in cyy_interrupt()
795 chips to be checked in a round-robin fashion (after in cyy_interrupt()
800 spin_lock(&cinfo->card_lock); in cyy_interrupt()
807 spin_unlock(&cinfo->card_lock); in cyy_interrupt()
813 spin_lock(&cinfo->card_lock); in cyy_interrupt()
816 spin_unlock(&cinfo->card_lock); in cyy_interrupt()
823 struct cyclades_card *card = info->card; in cyy_change_rts_dtr()
824 int channel = info->line - card->first_line; in cyy_change_rts_dtr()
829 if (info->rtsdtr_inv) { in cyy_change_rts_dtr()
871 /********* End of block of Cyclom-Y specific code **********/
872 /******** Start of block of Cyclades-Z specific code *******/
879 struct BOARD_CTRL __iomem *board_ctrl = cinfo->board_ctrl; in cyz_fetch_msg()
882 loc_doorbell = readl(&cinfo->ctl_addr.p9060->loc_doorbell); in cyz_fetch_msg()
885 *channel = readl(&board_ctrl->fwcmd_channel); in cyz_fetch_msg()
886 *param = (__u32) readl(&board_ctrl->fwcmd_param); in cyz_fetch_msg()
887 cy_writel(&cinfo->ctl_addr.p9060->loc_doorbell, 0xffffffff); in cyz_fetch_msg()
897 struct BOARD_CTRL __iomem *board_ctrl = cinfo->board_ctrl; in cyz_issue_cmd()
902 return -1; in cyz_issue_cmd()
905 pci_doorbell = &cinfo->ctl_addr.p9060->pci_doorbell; in cyz_issue_cmd()
911 cy_writel(&board_ctrl->hcmd_channel, channel); in cyz_issue_cmd()
912 cy_writel(&board_ctrl->hcmd_param, param); in cyz_issue_cmd()
920 struct BUF_CTRL __iomem *buf_ctrl = info->u.cyz.buf_ctrl; in cyz_handle_rx()
921 struct cyclades_card *cinfo = info->card; in cyz_handle_rx()
922 struct tty_port *port = &info->port; in cyz_handle_rx()
932 rx_get = new_rx_get = readl(&buf_ctrl->rx_get); in cyz_handle_rx()
933 rx_put = readl(&buf_ctrl->rx_put); in cyz_handle_rx()
934 rx_bufsize = readl(&buf_ctrl->rx_bufsize); in cyz_handle_rx()
935 rx_bufaddr = readl(&buf_ctrl->rx_bufaddr); in cyz_handle_rx()
937 char_count = rx_put - rx_get; in cyz_handle_rx()
939 char_count = rx_put - rx_get + rx_bufsize; in cyz_handle_rx()
945 info->mon.int_count++; in cyz_handle_rx()
946 info->mon.char_count += char_count; in cyz_handle_rx()
947 if (char_count > info->mon.char_max) in cyz_handle_rx()
948 info->mon.char_max = char_count; in cyz_handle_rx()
949 info->mon.char_last = char_count; in cyz_handle_rx()
963 rx_bufsize - new_rx_get); in cyz_handle_rx()
965 memcpy_fromio(buf, cinfo->base_addr + in cyz_handle_rx()
969 (rx_bufsize - 1); in cyz_handle_rx()
970 char_count -= len; in cyz_handle_rx()
971 info->icount.rx += len; in cyz_handle_rx()
972 info->idle_stats.recv_bytes += len; in cyz_handle_rx()
976 while (len--) { in cyz_handle_rx()
977 data = readb(cinfo->base_addr + rx_bufaddr + in cyz_handle_rx()
980 (rx_bufsize - 1); in cyz_handle_rx()
982 info->idle_stats.recv_bytes++; in cyz_handle_rx()
983 info->icount.rx++; in cyz_handle_rx()
989 rx_put = readl(&buf_ctrl->rx_put); in cyz_handle_rx()
991 char_count = rx_put - rx_get; in cyz_handle_rx()
993 char_count = rx_put - rx_get + rx_bufsize; in cyz_handle_rx()
994 if (char_count >= readl(&buf_ctrl->rx_threshold) && in cyz_handle_rx()
995 !timer_pending(&info->rx_full_timer)) in cyz_handle_rx()
996 mod_timer(&info->rx_full_timer, jiffies + 1); in cyz_handle_rx()
998 info->idle_stats.recv_idle = jiffies; in cyz_handle_rx()
999 tty_schedule_flip(&info->port); in cyz_handle_rx()
1002 cy_writel(&buf_ctrl->rx_get, new_rx_get); in cyz_handle_rx()
1007 struct BUF_CTRL __iomem *buf_ctrl = info->u.cyz.buf_ctrl; in cyz_handle_tx()
1008 struct cyclades_card *cinfo = info->card; in cyz_handle_tx()
1017 if (info->xmit_cnt <= 0) /* Nothing to transmit */ in cyz_handle_tx()
1020 tx_get = readl(&buf_ctrl->tx_get); in cyz_handle_tx()
1021 tx_put = readl(&buf_ctrl->tx_put); in cyz_handle_tx()
1022 tx_bufsize = readl(&buf_ctrl->tx_bufsize); in cyz_handle_tx()
1023 tx_bufaddr = readl(&buf_ctrl->tx_bufaddr); in cyz_handle_tx()
1025 char_count = tx_get - tx_put - 1 + tx_bufsize; in cyz_handle_tx()
1027 char_count = tx_get - tx_put - 1; in cyz_handle_tx()
1032 tty = tty_port_tty_get(&info->port); in cyz_handle_tx()
1036 if (info->x_char) { /* send special char */ in cyz_handle_tx()
1037 data = info->x_char; in cyz_handle_tx()
1039 cy_writeb(cinfo->base_addr + tx_bufaddr + tx_put, data); in cyz_handle_tx()
1040 tx_put = (tx_put + 1) & (tx_bufsize - 1); in cyz_handle_tx()
1041 info->x_char = 0; in cyz_handle_tx()
1042 char_count--; in cyz_handle_tx()
1043 info->icount.tx++; in cyz_handle_tx()
1047 tx_bufsize - tx_put, min_t(unsigned int, in cyz_handle_tx()
1048 (SERIAL_XMIT_SIZE - info->xmit_tail), in cyz_handle_tx()
1049 min_t(unsigned int, info->xmit_cnt, in cyz_handle_tx()
1052 memcpy_toio((char *)(cinfo->base_addr + tx_bufaddr + tx_put), in cyz_handle_tx()
1053 &info->port.xmit_buf[info->xmit_tail], in cyz_handle_tx()
1056 tx_put = (tx_put + small_count) & (tx_bufsize - 1); in cyz_handle_tx()
1057 char_count -= small_count; in cyz_handle_tx()
1058 info->icount.tx += small_count; in cyz_handle_tx()
1059 info->xmit_cnt -= small_count; in cyz_handle_tx()
1060 info->xmit_tail = (info->xmit_tail + small_count) & in cyz_handle_tx()
1061 (SERIAL_XMIT_SIZE - 1); in cyz_handle_tx()
1064 while (info->xmit_cnt && char_count) { in cyz_handle_tx()
1065 data = info->port.xmit_buf[info->xmit_tail]; in cyz_handle_tx()
1066 info->xmit_cnt--; in cyz_handle_tx()
1067 info->xmit_tail = (info->xmit_tail + 1) & in cyz_handle_tx()
1068 (SERIAL_XMIT_SIZE - 1); in cyz_handle_tx()
1070 cy_writeb(cinfo->base_addr + tx_bufaddr + tx_put, data); in cyz_handle_tx()
1071 tx_put = (tx_put + 1) & (tx_bufsize - 1); in cyz_handle_tx()
1072 char_count--; in cyz_handle_tx()
1073 info->icount.tx++; in cyz_handle_tx()
1080 cy_writel(&buf_ctrl->tx_put, tx_put); in cyz_handle_tx()
1085 struct BOARD_CTRL __iomem *board_ctrl = cinfo->board_ctrl; in cyz_handle_cmd()
1092 fw_ver = readl(&board_ctrl->fw_version); in cyz_handle_cmd()
1097 info = &cinfo->ports[channel]; in cyz_handle_cmd()
1101 tty_insert_flip_char(&info->port, 0, TTY_PARITY); in cyz_handle_cmd()
1102 info->icount.rx++; in cyz_handle_cmd()
1106 tty_insert_flip_char(&info->port, 0, TTY_FRAME); in cyz_handle_cmd()
1107 info->icount.rx++; in cyz_handle_cmd()
1111 tty_insert_flip_char(&info->port, 0, TTY_BREAK); in cyz_handle_cmd()
1112 info->icount.rx++; in cyz_handle_cmd()
1116 info->icount.dcd++; in cyz_handle_cmd()
1118 if (tty_port_check_carrier(&info->port)) { in cyz_handle_cmd()
1120 readl(&info->u.cyz.ch_ctrl->rs_status); in cyz_handle_cmd()
1122 wake_up_interruptible(&info->port.open_wait); in cyz_handle_cmd()
1124 tty_port_tty_hangup(&info->port, false); in cyz_handle_cmd()
1128 info->icount.cts++; in cyz_handle_cmd()
1132 info->icount.rng++; in cyz_handle_cmd()
1136 info->icount.dsr++; in cyz_handle_cmd()
1141 complete(&info->shutdown_wait); in cyz_handle_cmd()
1151 "port %ld\n", info->card, channel); in cyz_handle_cmd()
1161 "port %ld\n", info->card, channel); in cyz_handle_cmd()
1173 wake_up_interruptible(&info->port.delta_msr_wait); in cyz_handle_cmd()
1175 tty_schedule_flip(&info->port); in cyz_handle_cmd()
1201 struct cyclades_card *card = info->card; in cyz_rx_restart()
1203 __u32 channel = info->line - card->first_line; in cyz_rx_restart()
1206 spin_lock_irqsave(&card->card_lock, flags); in cyz_rx_restart()
1210 info->line, retval); in cyz_rx_restart()
1212 spin_unlock_irqrestore(&card->card_lock, flags); in cyz_rx_restart()
1233 if (!cinfo->intr_enabled) { in cyz_poll()
1234 cinfo->intr_enabled = 1; in cyz_poll()
1240 for (port = 0; port < cinfo->nports; port++) { in cyz_poll()
1241 info = &cinfo->ports[port]; in cyz_poll()
1243 if (!info->throttle) in cyz_poll()
1255 /********** End of block of Cyclades-Z specific code *********/
1269 card = info->card; in cy_startup()
1270 channel = info->line - card->first_line; in cy_startup()
1274 return -ENOMEM; in cy_startup()
1276 spin_lock_irqsave(&card->card_lock, flags); in cy_startup()
1278 if (tty_port_initialized(&info->port)) in cy_startup()
1281 if (!info->type) { in cy_startup()
1282 set_bit(TTY_IO_ERROR, &tty->flags); in cy_startup()
1286 if (info->port.xmit_buf) in cy_startup()
1289 info->port.xmit_buf = (unsigned char *)page; in cy_startup()
1291 spin_unlock_irqrestore(&card->card_lock, flags); in cy_startup()
1298 spin_lock_irqsave(&card->card_lock, flags); in cy_startup()
1303 (info->default_timeout ? info->default_timeout : 0x02)); in cy_startup()
1304 /* 10ms rx timeout */ in cy_startup()
1312 struct CH_CTRL __iomem *ch_ctrl = info->u.cyz.ch_ctrl; in cy_startup()
1315 return -ENODEV; in cy_startup()
1319 "base_addr %p\n", card, channel, card->base_addr); in cy_startup()
1321 spin_lock_irqsave(&card->card_lock, flags); in cy_startup()
1323 cy_writel(&ch_ctrl->op_mode, C_CH_ENABLE); in cy_startup()
1326 cy_writel(&ch_ctrl->intr_enable, in cy_startup()
1330 cy_writel(&ch_ctrl->intr_enable, in cy_startup()
1335 cy_writel(&ch_ctrl->intr_enable, in cy_startup()
1339 cy_writel(&ch_ctrl->intr_enable, C_IN_MDCD); in cy_startup()
1346 "%x\n", info->line, retval); in cy_startup()
1353 "%x\n", info->line, retval); in cy_startup()
1358 tty_port_raise_dtr_rts(&info->port); in cy_startup()
1363 tty_port_set_initialized(&info->port, 1); in cy_startup()
1365 clear_bit(TTY_IO_ERROR, &tty->flags); in cy_startup()
1366 info->xmit_cnt = info->xmit_head = info->xmit_tail = 0; in cy_startup()
1367 info->breakon = info->breakoff = 0; in cy_startup()
1368 memset((char *)&info->idle_stats, 0, sizeof(info->idle_stats)); in cy_startup()
1369 info->idle_stats.in_use = in cy_startup()
1370 info->idle_stats.recv_idle = in cy_startup()
1371 info->idle_stats.xmit_idle = jiffies; in cy_startup()
1373 spin_unlock_irqrestore(&card->card_lock, flags); in cy_startup()
1381 spin_unlock_irqrestore(&card->card_lock, flags); in cy_startup()
1388 struct cyclades_card *card = info->card; in start_xmit()
1390 int channel = info->line - card->first_line; in start_xmit()
1393 spin_lock_irqsave(&card->card_lock, flags); in start_xmit()
1396 spin_unlock_irqrestore(&card->card_lock, flags); in start_xmit()
1401 spin_lock_irqsave(&card->card_lock, flags); in start_xmit()
1405 "%x\n", info->line, retval); in start_xmit()
1407 spin_unlock_irqrestore(&card->card_lock, flags); in start_xmit()
1423 if (!tty_port_initialized(&info->port)) in cy_shutdown()
1426 card = info->card; in cy_shutdown()
1428 spin_lock_irqsave(&card->card_lock, flags); in cy_shutdown()
1431 wake_up_interruptible(&info->port.delta_msr_wait); in cy_shutdown()
1433 if (info->port.xmit_buf) { in cy_shutdown()
1435 temp = info->port.xmit_buf; in cy_shutdown()
1436 info->port.xmit_buf = NULL; in cy_shutdown()
1446 set_bit(TTY_IO_ERROR, &tty->flags); in cy_shutdown()
1447 tty_port_set_initialized(&info->port, 0); in cy_shutdown()
1448 spin_unlock_irqrestore(&card->card_lock, flags); in cy_shutdown()
1451 int channel = info->line - card->first_line; in cy_shutdown()
1453 "base_addr %p\n", card, channel, card->base_addr); in cy_shutdown()
1459 spin_lock_irqsave(&card->card_lock, flags); in cy_shutdown()
1461 if (info->port.xmit_buf) { in cy_shutdown()
1463 temp = info->port.xmit_buf; in cy_shutdown()
1464 info->port.xmit_buf = NULL; in cy_shutdown()
1469 tty_port_lower_dtr_rts(&info->port); in cy_shutdown()
1471 set_bit(TTY_IO_ERROR, &tty->flags); in cy_shutdown()
1472 tty_port_set_initialized(&info->port, 0); in cy_shutdown()
1474 spin_unlock_irqrestore(&card->card_lock, flags); in cy_shutdown()
1483 * ------------------------------------------------------------
1485 * ------------------------------------------------------------
1490 * performs the serial-specific initialization for the tty structure.
1495 unsigned int i, line = tty->index; in cy_open()
1503 return -ENODEV; in cy_open()
1504 info = &cy_card[i].ports[line - cy_card[i].first_line]; in cy_open()
1505 if (info->line < 0) in cy_open()
1506 return -ENODEV; in cy_open()
1512 if (cy_is_Z(info->card)) { in cy_open()
1513 struct cyclades_card *cinfo = info->card; in cy_open()
1514 struct FIRM_ID __iomem *firm_id = cinfo->base_addr + ID_ADDRESS; in cy_open()
1517 if (cinfo->hw_ver == ZE_V1 && cyz_fpga_loaded(cinfo) && in cy_open()
1518 readl(&firm_id->signature) == in cy_open()
1520 printk(KERN_ERR "cyc:Cyclades-Z Error: you " in cy_open()
1525 printk(KERN_ERR "cyc:Cyclades-Z firmware not " in cy_open()
1528 return -ENODEV; in cy_open()
1535 if (!cinfo->intr_enabled) { in cy_open()
1539 intr = readw(&cinfo->ctl_addr.p9060-> in cy_open()
1541 cy_writew(&cinfo->ctl_addr.p9060-> in cy_open()
1550 cinfo->intr_enabled = 1; in cy_open()
1555 if (info->line > (cinfo->first_line + cinfo->nports - 1)) in cy_open()
1556 return -ENODEV; in cy_open()
1559 printk(KERN_DEBUG "cyc:cy_open ttyC%d\n", info->line); in cy_open()
1561 tty->driver_data = info; in cy_open()
1562 if (serial_paranoia_check(info, tty->name, "cy_open")) in cy_open()
1563 return -ENODEV; in cy_open()
1566 printk(KERN_DEBUG "cyc:cy_open ttyC%d, count = %d\n", info->line, in cy_open()
1567 info->port.count); in cy_open()
1569 info->port.count++; in cy_open()
1572 current->pid, info->port.count); in cy_open()
1582 retval = tty_port_block_til_ready(&info->port, tty, filp); in cy_open()
1591 info->throttle = 0; in cy_open()
1592 tty_port_tty_set(&info->port, tty); in cy_open()
1601 * cy_wait_until_sent() --- wait until the transmitter is empty
1606 struct cyclades_port *info = tty->driver_data; in cy_wait_until_sent()
1610 if (serial_paranoia_check(info, tty->name, "cy_wait_until_sent")) in cy_wait_until_sent()
1613 if (info->xmit_fifo_size == 0) in cy_wait_until_sent()
1623 * the NIST-PCTS. in cy_wait_until_sent()
1625 char_time = (info->timeout - HZ / 50) / info->xmit_fifo_size; in cy_wait_until_sent()
1638 * takes longer than info->timeout, this is probably due to a in cy_wait_until_sent()
1640 * 2*info->timeout. in cy_wait_until_sent()
1642 if (!timeout || timeout > 2 * info->timeout) in cy_wait_until_sent()
1643 timeout = 2 * info->timeout; in cy_wait_until_sent()
1645 card = info->card; in cy_wait_until_sent()
1661 struct cyclades_port *info = tty->driver_data; in cy_flush_buffer()
1667 printk(KERN_DEBUG "cyc:cy_flush_buffer ttyC%d\n", info->line); in cy_flush_buffer()
1670 if (serial_paranoia_check(info, tty->name, "cy_flush_buffer")) in cy_flush_buffer()
1673 card = info->card; in cy_flush_buffer()
1674 channel = info->line - card->first_line; in cy_flush_buffer()
1676 spin_lock_irqsave(&card->card_lock, flags); in cy_flush_buffer()
1677 info->xmit_cnt = info->xmit_head = info->xmit_tail = 0; in cy_flush_buffer()
1678 spin_unlock_irqrestore(&card->card_lock, flags); in cy_flush_buffer()
1680 if (cy_is_Z(card)) { /* If it is a Z card, flush the on-board in cy_flush_buffer()
1682 spin_lock_irqsave(&card->card_lock, flags); in cy_flush_buffer()
1686 "was %x\n", info->line, retval); in cy_flush_buffer()
1688 spin_unlock_irqrestore(&card->card_lock, flags); in cy_flush_buffer()
1702 card = info->card; in cy_do_close()
1703 channel = info->line - card->first_line; in cy_do_close()
1704 spin_lock_irqsave(&card->card_lock, flags); in cy_do_close()
1710 if (tty_port_initialized(&info->port)) { in cy_do_close()
1711 /* Waiting for on-board buffers to be empty before in cy_do_close()
1713 spin_unlock_irqrestore(&card->card_lock, flags); in cy_do_close()
1714 cy_wait_until_sent(port->tty, info->timeout); in cy_do_close()
1715 spin_lock_irqsave(&card->card_lock, flags); in cy_do_close()
1719 /* Waiting for on-board buffers to be empty before closing in cy_do_close()
1721 struct CH_CTRL __iomem *ch_ctrl = info->u.cyz.ch_ctrl; in cy_do_close()
1724 if (readl(&ch_ctrl->flow_status) != C_FS_TXIDLE) { in cy_do_close()
1728 "ttyC%d was %x\n", info->line, retval); in cy_do_close()
1730 spin_unlock_irqrestore(&card->card_lock, flags); in cy_do_close()
1731 wait_for_completion_interruptible(&info->shutdown_wait); in cy_do_close()
1732 spin_lock_irqsave(&card->card_lock, flags); in cy_do_close()
1736 spin_unlock_irqrestore(&card->card_lock, flags); in cy_do_close()
1737 cy_shutdown(info, port->tty); in cy_do_close()
1745 struct cyclades_port *info = tty->driver_data; in cy_close()
1746 if (!info || serial_paranoia_check(info, tty->name, "cy_close")) in cy_close()
1748 tty_port_close(&info->port, tty, filp); in cy_close()
1766 struct cyclades_port *info = tty->driver_data; in cy_write()
1771 printk(KERN_DEBUG "cyc:cy_write ttyC%d\n", info->line); in cy_write()
1774 if (serial_paranoia_check(info, tty->name, "cy_write")) in cy_write()
1777 if (!info->port.xmit_buf) in cy_write()
1780 spin_lock_irqsave(&info->card->card_lock, flags); in cy_write()
1782 c = min(count, (int)(SERIAL_XMIT_SIZE - info->xmit_cnt - 1)); in cy_write()
1783 c = min(c, (int)(SERIAL_XMIT_SIZE - info->xmit_head)); in cy_write()
1788 memcpy(info->port.xmit_buf + info->xmit_head, buf, c); in cy_write()
1789 info->xmit_head = (info->xmit_head + c) & in cy_write()
1790 (SERIAL_XMIT_SIZE - 1); in cy_write()
1791 info->xmit_cnt += c; in cy_write()
1793 count -= c; in cy_write()
1796 spin_unlock_irqrestore(&info->card->card_lock, flags); in cy_write()
1798 info->idle_stats.xmit_bytes += ret; in cy_write()
1799 info->idle_stats.xmit_idle = jiffies; in cy_write()
1801 if (info->xmit_cnt && !tty->stopped && !tty->hw_stopped) in cy_write()
1816 struct cyclades_port *info = tty->driver_data; in cy_put_char()
1820 printk(KERN_DEBUG "cyc:cy_put_char ttyC%d\n", info->line); in cy_put_char()
1823 if (serial_paranoia_check(info, tty->name, "cy_put_char")) in cy_put_char()
1826 if (!info->port.xmit_buf) in cy_put_char()
1829 spin_lock_irqsave(&info->card->card_lock, flags); in cy_put_char()
1830 if (info->xmit_cnt >= (int)(SERIAL_XMIT_SIZE - 1)) { in cy_put_char()
1831 spin_unlock_irqrestore(&info->card->card_lock, flags); in cy_put_char()
1835 info->port.xmit_buf[info->xmit_head++] = ch; in cy_put_char()
1836 info->xmit_head &= SERIAL_XMIT_SIZE - 1; in cy_put_char()
1837 info->xmit_cnt++; in cy_put_char()
1838 info->idle_stats.xmit_bytes++; in cy_put_char()
1839 info->idle_stats.xmit_idle = jiffies; in cy_put_char()
1840 spin_unlock_irqrestore(&info->card->card_lock, flags); in cy_put_char()
1850 struct cyclades_port *info = tty->driver_data; in cy_flush_chars()
1853 printk(KERN_DEBUG "cyc:cy_flush_chars ttyC%d\n", info->line); in cy_flush_chars()
1856 if (serial_paranoia_check(info, tty->name, "cy_flush_chars")) in cy_flush_chars()
1859 if (info->xmit_cnt <= 0 || tty->stopped || tty->hw_stopped || in cy_flush_chars()
1860 !info->port.xmit_buf) in cy_flush_chars()
1874 struct cyclades_port *info = tty->driver_data; in cy_write_room()
1878 printk(KERN_DEBUG "cyc:cy_write_room ttyC%d\n", info->line); in cy_write_room()
1881 if (serial_paranoia_check(info, tty->name, "cy_write_room")) in cy_write_room()
1883 ret = SERIAL_XMIT_SIZE - info->xmit_cnt - 1; in cy_write_room()
1891 struct cyclades_port *info = tty->driver_data; in cy_chars_in_buffer()
1893 if (serial_paranoia_check(info, tty->name, "cy_chars_in_buffer")) in cy_chars_in_buffer()
1897 if (!cy_is_Z(info->card)) { in cy_chars_in_buffer()
1901 info->line, info->xmit_cnt); in cy_chars_in_buffer()
1903 return info->xmit_cnt; in cy_chars_in_buffer()
1906 struct BUF_CTRL __iomem *buf_ctrl = info->u.cyz.buf_ctrl; in cy_chars_in_buffer()
1910 tx_get = readl(&buf_ctrl->tx_get); in cy_chars_in_buffer()
1911 tx_put = readl(&buf_ctrl->tx_put); in cy_chars_in_buffer()
1912 tx_bufsize = readl(&buf_ctrl->tx_bufsize); in cy_chars_in_buffer()
1914 char_count = tx_put - tx_get; in cy_chars_in_buffer()
1916 char_count = tx_put - tx_get + tx_bufsize; in cy_chars_in_buffer()
1919 info->line, info->xmit_cnt + char_count); in cy_chars_in_buffer()
1921 return info->xmit_cnt + char_count; in cy_chars_in_buffer()
1927 * ------------------------------------------------------------
1929 * ------------------------------------------------------------
1935 __u32 cy_clock = ((info->chip_rev >= CD1400_REV_J) ? 60000000 : in cyy_baud_calc()
1939 info->tbpr = info->tco = info->rbpr = info->rco = 0; in cyy_baud_calc()
1944 for (co = 4, co_val = 2048; co; co--, co_val >>= 2) { in cyy_baud_calc()
1953 info->tbpr = info->rbpr = bpr; in cyy_baud_calc()
1954 info->tco = info->rco = co; in cyy_baud_calc()
1970 if (info->line == -1) in cy_set_line_char()
1973 cflag = tty->termios.c_cflag; in cy_set_line_char()
1974 iflag = tty->termios.c_iflag; in cy_set_line_char()
1976 card = info->card; in cy_set_line_char()
1977 channel = info->line - card->first_line; in cy_set_line_char()
1984 if (baud == 38400 && (info->port.flags & ASYNC_SPD_MASK) == in cy_set_line_char()
1986 if (info->custom_divisor) in cy_set_line_char()
1987 baud_rate = info->baud / info->custom_divisor; in cy_set_line_char()
1989 baud_rate = info->baud; in cy_set_line_char()
2001 if (baud == 38400 && (info->port.flags & ASYNC_SPD_MASK) == in cy_set_line_char()
2005 if (info->chip_rev >= CD1400_REV_J) { in cy_set_line_char()
2007 info->tbpr = baud_bpr_60[i]; /* Tx BPR */ in cy_set_line_char()
2008 info->tco = baud_co_60[i]; /* Tx CO */ in cy_set_line_char()
2009 info->rbpr = baud_bpr_60[i]; /* Rx BPR */ in cy_set_line_char()
2010 info->rco = baud_co_60[i]; /* Rx CO */ in cy_set_line_char()
2012 info->tbpr = baud_bpr_25[i]; /* Tx BPR */ in cy_set_line_char()
2013 info->tco = baud_co_25[i]; /* Tx CO */ in cy_set_line_char()
2014 info->rbpr = baud_bpr_25[i]; /* Rx BPR */ in cy_set_line_char()
2015 info->rco = baud_co_25[i]; /* Rx CO */ in cy_set_line_char()
2020 info->timeout = (info->xmit_fifo_size * HZ * 30 / 269) + in cy_set_line_char()
2022 } else if (baud == 38400 && (info->port.flags & ASYNC_SPD_MASK) == in cy_set_line_char()
2024 info->timeout = (info->xmit_fifo_size * HZ * 15 / in cy_set_line_char()
2027 info->timeout = (info->xmit_fifo_size * HZ * 15 / in cy_set_line_char()
2031 info->timeout = 0; in cy_set_line_char()
2038 info->cor5 = 0; in cy_set_line_char()
2039 info->cor4 = 0; in cy_set_line_char()
2041 info->cor3 = (info->default_threshold ? in cy_set_line_char()
2042 info->default_threshold : baud_cor3[i]); in cy_set_line_char()
2043 info->cor2 = CyETC; in cy_set_line_char()
2046 info->cor1 = Cy_5_BITS; in cy_set_line_char()
2049 info->cor1 = Cy_6_BITS; in cy_set_line_char()
2052 info->cor1 = Cy_7_BITS; in cy_set_line_char()
2055 info->cor1 = Cy_8_BITS; in cy_set_line_char()
2059 info->cor1 |= Cy_2_STOP; in cy_set_line_char()
2063 info->cor1 |= CyPARITY_O; in cy_set_line_char()
2065 info->cor1 |= CyPARITY_E; in cy_set_line_char()
2067 info->cor1 |= CyPARITY_NONE; in cy_set_line_char()
2070 tty_port_set_cts_flow(&info->port, cflag & CRTSCTS); in cy_set_line_char()
2072 info->cor2 |= CyCtsAE; in cy_set_line_char()
2074 info->cor2 &= ~CyCtsAE; in cy_set_line_char()
2075 tty_port_set_check_carrier(&info->port, ~cflag & CLOCAL); in cy_set_line_char()
2083 appropriate signals for use with a non-standard in cy_set_line_char()
2089 spin_lock_irqsave(&card->card_lock, flags); in cy_set_line_char()
2094 cyy_writeb(info, CyTCOR, info->tco); in cy_set_line_char()
2095 cyy_writeb(info, CyTBPR, info->tbpr); in cy_set_line_char()
2096 cyy_writeb(info, CyRCOR, info->rco); in cy_set_line_char()
2097 cyy_writeb(info, CyRBPR, info->rbpr); in cy_set_line_char()
2103 cyy_writeb(info, CyCOR1, info->cor1); in cy_set_line_char()
2104 cyy_writeb(info, CyCOR2, info->cor2); in cy_set_line_char()
2105 cyy_writeb(info, CyCOR3, info->cor3); in cy_set_line_char()
2106 cyy_writeb(info, CyCOR4, info->cor4); in cy_set_line_char()
2107 cyy_writeb(info, CyCOR5, info->cor5); in cy_set_line_char()
2115 (info->default_timeout ? info->default_timeout : 0x02)); in cy_set_line_char()
2116 /* 10ms rx timeout */ in cy_set_line_char()
2123 /* act on 1->0 modem transitions */ in cy_set_line_char()
2124 if ((cflag & CRTSCTS) && info->rflow) in cy_set_line_char()
2128 /* act on 0->1 modem transitions */ in cy_set_line_char()
2136 clear_bit(TTY_IO_ERROR, &tty->flags); in cy_set_line_char()
2137 spin_unlock_irqrestore(&card->card_lock, flags); in cy_set_line_char()
2140 struct CH_CTRL __iomem *ch_ctrl = info->u.cyz.ch_ctrl; in cy_set_line_char()
2149 if (baud == 38400 && (info->port.flags & ASYNC_SPD_MASK) == in cy_set_line_char()
2151 if (info->custom_divisor) in cy_set_line_char()
2152 baud_rate = info->baud / info->custom_divisor; in cy_set_line_char()
2154 baud_rate = info->baud; in cy_set_line_char()
2158 cy_writel(&ch_ctrl->comm_baud, baud); in cy_set_line_char()
2162 info->timeout = (info->xmit_fifo_size * HZ * 30 / 269) + in cy_set_line_char()
2164 } else if (baud == 38400 && (info->port.flags & ASYNC_SPD_MASK) == in cy_set_line_char()
2166 info->timeout = (info->xmit_fifo_size * HZ * 15 / in cy_set_line_char()
2169 info->timeout = (info->xmit_fifo_size * HZ * 15 / in cy_set_line_char()
2173 info->timeout = 0; in cy_set_line_char()
2179 cy_writel(&ch_ctrl->comm_data_l, C_DL_CS5); in cy_set_line_char()
2182 cy_writel(&ch_ctrl->comm_data_l, C_DL_CS6); in cy_set_line_char()
2185 cy_writel(&ch_ctrl->comm_data_l, C_DL_CS7); in cy_set_line_char()
2188 cy_writel(&ch_ctrl->comm_data_l, C_DL_CS8); in cy_set_line_char()
2192 cy_writel(&ch_ctrl->comm_data_l, in cy_set_line_char()
2193 readl(&ch_ctrl->comm_data_l) | C_DL_2STOP); in cy_set_line_char()
2195 cy_writel(&ch_ctrl->comm_data_l, in cy_set_line_char()
2196 readl(&ch_ctrl->comm_data_l) | C_DL_1STOP); in cy_set_line_char()
2200 cy_writel(&ch_ctrl->comm_parity, C_PR_ODD); in cy_set_line_char()
2202 cy_writel(&ch_ctrl->comm_parity, C_PR_EVEN); in cy_set_line_char()
2204 cy_writel(&ch_ctrl->comm_parity, C_PR_NONE); in cy_set_line_char()
2208 cy_writel(&ch_ctrl->hw_flow, in cy_set_line_char()
2209 readl(&ch_ctrl->hw_flow) | C_RS_CTS | C_RS_RTS); in cy_set_line_char()
2211 cy_writel(&ch_ctrl->hw_flow, readl(&ch_ctrl->hw_flow) & in cy_set_line_char()
2216 tty_port_set_cts_flow(&info->port, 0); in cy_set_line_char()
2225 cy_writel(&ch_ctrl->sw_flow, sw_flow); in cy_set_line_char()
2230 "was %x\n", info->line, retval); in cy_set_line_char()
2234 tty_port_set_check_carrier(&info->port, ~cflag & CLOCAL); in cy_set_line_char()
2237 cy_writel(&ch_ctrl->rs_control, in cy_set_line_char()
2238 readl(&ch_ctrl->rs_control) & ~C_RS_DTR); in cy_set_line_char()
2243 cy_writel(&ch_ctrl->rs_control, in cy_set_line_char()
2244 readl(&ch_ctrl->rs_control) | C_RS_DTR); in cy_set_line_char()
2253 "was %x\n", info->line, retval); in cy_set_line_char()
2256 clear_bit(TTY_IO_ERROR, &tty->flags); in cy_set_line_char()
2263 struct cyclades_port *info = tty->driver_data; in cy_get_serial_info()
2264 struct cyclades_card *cinfo = info->card; in cy_get_serial_info()
2266 if (serial_paranoia_check(info, tty->name, "cy_ioctl")) in cy_get_serial_info()
2267 return -ENODEV; in cy_get_serial_info()
2268 ss->type = info->type; in cy_get_serial_info()
2269 ss->line = info->line; in cy_get_serial_info()
2270 ss->port = (info->card - cy_card) * 0x100 + info->line - in cy_get_serial_info()
2271 cinfo->first_line; in cy_get_serial_info()
2272 ss->irq = cinfo->irq; in cy_get_serial_info()
2273 ss->flags = info->port.flags; in cy_get_serial_info()
2274 ss->close_delay = info->port.close_delay; in cy_get_serial_info()
2275 ss->closing_wait = info->port.closing_wait; in cy_get_serial_info()
2276 ss->baud_base = info->baud; in cy_get_serial_info()
2277 ss->custom_divisor = info->custom_divisor; in cy_get_serial_info()
2284 struct cyclades_port *info = tty->driver_data; in cy_set_serial_info()
2288 if (serial_paranoia_check(info, tty->name, "cy_ioctl")) in cy_set_serial_info()
2289 return -ENODEV; in cy_set_serial_info()
2291 mutex_lock(&info->port.mutex); in cy_set_serial_info()
2293 old_flags = info->port.flags; in cy_set_serial_info()
2296 if (ss->close_delay != info->port.close_delay || in cy_set_serial_info()
2297 ss->baud_base != info->baud || in cy_set_serial_info()
2298 (ss->flags & ASYNC_FLAGS & in cy_set_serial_info()
2300 (info->port.flags & ASYNC_FLAGS & ~ASYNC_USR_MASK)) in cy_set_serial_info()
2302 mutex_unlock(&info->port.mutex); in cy_set_serial_info()
2303 return -EPERM; in cy_set_serial_info()
2305 info->port.flags = (info->port.flags & ~ASYNC_USR_MASK) | in cy_set_serial_info()
2306 (ss->flags & ASYNC_USR_MASK); in cy_set_serial_info()
2307 info->baud = ss->baud_base; in cy_set_serial_info()
2308 info->custom_divisor = ss->custom_divisor; in cy_set_serial_info()
2317 info->baud = ss->baud_base; in cy_set_serial_info()
2318 info->custom_divisor = ss->custom_divisor; in cy_set_serial_info()
2319 info->port.flags = (info->port.flags & ~ASYNC_FLAGS) | in cy_set_serial_info()
2320 (ss->flags & ASYNC_FLAGS); in cy_set_serial_info()
2321 info->port.close_delay = ss->close_delay * HZ / 100; in cy_set_serial_info()
2322 info->port.closing_wait = ss->closing_wait * HZ / 100; in cy_set_serial_info()
2325 if (tty_port_initialized(&info->port)) { in cy_set_serial_info()
2326 if ((ss->flags ^ old_flags) & ASYNC_SPD_MASK) { in cy_set_serial_info()
2328 if (ss->flags & ASYNC_SPD_MASK) in cy_set_serial_info()
2329 dev_warn_ratelimited(tty->dev, "use of SPD flags is deprecated\n"); in cy_set_serial_info()
2336 mutex_unlock(&info->port.mutex); in cy_set_serial_info()
2341 * get_lsr_info - get line status register info
2352 struct cyclades_card *card = info->card; in get_lsr_info()
2358 spin_lock_irqsave(&card->card_lock, flags); in get_lsr_info()
2360 spin_unlock_irqrestore(&card->card_lock, flags); in get_lsr_info()
2364 return -EINVAL; in get_lsr_info()
2371 struct cyclades_port *info = tty->driver_data; in cy_tiocmget()
2375 if (serial_paranoia_check(info, tty->name, __func__)) in cy_tiocmget()
2376 return -ENODEV; in cy_tiocmget()
2378 card = info->card; in cy_tiocmget()
2382 int channel = info->line - card->first_line; in cy_tiocmget()
2385 spin_lock_irqsave(&card->card_lock, flags); in cy_tiocmget()
2389 spin_unlock_irqrestore(&card->card_lock, flags); in cy_tiocmget()
2391 if (info->rtsdtr_inv) { in cy_tiocmget()
2406 result = -ENODEV; in cy_tiocmget()
2410 lstatus = readl(&info->u.cyz.ch_ctrl->rs_status); in cy_tiocmget()
2426 struct cyclades_port *info = tty->driver_data; in cy_tiocmset()
2430 if (serial_paranoia_check(info, tty->name, __func__)) in cy_tiocmset()
2431 return -ENODEV; in cy_tiocmset()
2433 card = info->card; in cy_tiocmset()
2435 spin_lock_irqsave(&card->card_lock, flags); in cy_tiocmset()
2437 spin_unlock_irqrestore(&card->card_lock, flags); in cy_tiocmset()
2439 struct CH_CTRL __iomem *ch_ctrl = info->u.cyz.ch_ctrl; in cy_tiocmset()
2440 int retval, channel = info->line - card->first_line; in cy_tiocmset()
2444 return -ENODEV; in cy_tiocmset()
2446 spin_lock_irqsave(&card->card_lock, flags); in cy_tiocmset()
2447 rs = readl(&ch_ctrl->rs_control); in cy_tiocmset()
2465 cy_writel(&ch_ctrl->rs_control, rs); in cy_tiocmset()
2467 spin_unlock_irqrestore(&card->card_lock, flags); in cy_tiocmset()
2470 "was %x\n", info->line, retval); in cy_tiocmset()
2477 * cy_break() --- routine which turns the break handling on or off
2481 struct cyclades_port *info = tty->driver_data; in cy_break()
2486 if (serial_paranoia_check(info, tty->name, "cy_break")) in cy_break()
2487 return -EINVAL; in cy_break()
2489 card = info->card; in cy_break()
2491 spin_lock_irqsave(&card->card_lock, flags); in cy_break()
2496 if (break_state == -1) { in cy_break()
2497 if (!info->breakon) { in cy_break()
2498 info->breakon = 1; in cy_break()
2499 if (!info->xmit_cnt) { in cy_break()
2500 spin_unlock_irqrestore(&card->card_lock, flags); in cy_break()
2502 spin_lock_irqsave(&card->card_lock, flags); in cy_break()
2506 if (!info->breakoff) { in cy_break()
2507 info->breakoff = 1; in cy_break()
2508 if (!info->xmit_cnt) { in cy_break()
2509 spin_unlock_irqrestore(&card->card_lock, flags); in cy_break()
2511 spin_lock_irqsave(&card->card_lock, flags); in cy_break()
2516 if (break_state == -1) { in cy_break()
2518 info->line - card->first_line, in cy_break()
2522 "ttyC%d was %x\n", info->line, retval); in cy_break()
2526 info->line - card->first_line, in cy_break()
2530 "on ttyC%d was %x\n", info->line, in cy_break()
2535 spin_unlock_irqrestore(&card->card_lock, flags); in cy_break()
2541 struct cyclades_card *card = info->card; in set_threshold()
2545 info->cor3 &= ~CyREC_FIFO; in set_threshold()
2546 info->cor3 |= value & CyREC_FIFO; in set_threshold()
2548 spin_lock_irqsave(&card->card_lock, flags); in set_threshold()
2549 cyy_writeb(info, CyCOR3, info->cor3); in set_threshold()
2551 spin_unlock_irqrestore(&card->card_lock, flags); in set_threshold()
2559 struct cyclades_card *card = info->card; in get_threshold()
2570 struct cyclades_card *card = info->card; in set_timeout()
2574 spin_lock_irqsave(&card->card_lock, flags); in set_timeout()
2576 spin_unlock_irqrestore(&card->card_lock, flags); in set_timeout()
2584 struct cyclades_card *card = info->card; in get_timeout()
2600 spin_lock_irqsave(&info->card->card_lock, flags); in cy_cflags_changed()
2601 cnow = info->icount; /* atomic copy */ in cy_cflags_changed()
2602 spin_unlock_irqrestore(&info->card->card_lock, flags); in cy_cflags_changed()
2604 ret = ((arg & TIOCM_RNG) && (cnow.rng != cprev->rng)) || in cy_cflags_changed()
2605 ((arg & TIOCM_DSR) && (cnow.dsr != cprev->dsr)) || in cy_cflags_changed()
2606 ((arg & TIOCM_CD) && (cnow.dcd != cprev->dcd)) || in cy_cflags_changed()
2607 ((arg & TIOCM_CTS) && (cnow.cts != cprev->cts)); in cy_cflags_changed()
2615 * This routine allows the tty driver to implement device-
2623 struct cyclades_port *info = tty->driver_data; in cy_ioctl()
2629 if (serial_paranoia_check(info, tty->name, "cy_ioctl")) in cy_ioctl()
2630 return -ENODEV; in cy_ioctl()
2634 info->line, cmd, arg); in cy_ioctl()
2639 if (copy_to_user(argp, &info->mon, sizeof(info->mon))) { in cy_ioctl()
2640 ret_val = -EFAULT; in cy_ioctl()
2643 memset(&info->mon, 0, sizeof(info->mon)); in cy_ioctl()
2652 ret_val = put_user(info->default_threshold, in cy_ioctl()
2656 info->default_threshold = arg & 0x0f; in cy_ioctl()
2665 ret_val = put_user(info->default_timeout, in cy_ioctl()
2669 info->default_timeout = arg & 0xff; in cy_ioctl()
2672 info->rflow = (int)arg; in cy_ioctl()
2675 ret_val = info->rflow; in cy_ioctl()
2678 info->rtsdtr_inv = (int)arg; in cy_ioctl()
2681 ret_val = info->rtsdtr_inv; in cy_ioctl()
2684 ret_val = info->chip_rev; in cy_ioctl()
2689 return -ENODEV; in cy_ioctl()
2697 info->port.closing_wait = (unsigned short)arg * HZ / 100; in cy_ioctl()
2700 ret_val = info->port.closing_wait / (HZ / 100); in cy_ioctl()
2707 * - mask passed in arg for lines of interest in cy_ioctl()
2712 spin_lock_irqsave(&info->card->card_lock, flags); in cy_ioctl()
2714 cnow = info->icount; in cy_ioctl()
2715 spin_unlock_irqrestore(&info->card->card_lock, flags); in cy_ioctl()
2716 ret_val = wait_event_interruptible(info->port.delta_msr_wait, in cy_ioctl()
2723 * NB: both 1->0 and 0->1 transitions are counted except for in cy_ioctl()
2724 * RI where only 0->1 is counted. in cy_ioctl()
2727 ret_val = -ENOIOCTLCMD; in cy_ioctl()
2739 struct cyclades_port *info = tty->driver_data; in cy_get_icount()
2743 spin_lock_irqsave(&info->card->card_lock, flags); in cy_get_icount()
2744 cnow = info->icount; in cy_get_icount()
2745 spin_unlock_irqrestore(&info->card->card_lock, flags); in cy_get_icount()
2747 sic->cts = cnow.cts; in cy_get_icount()
2748 sic->dsr = cnow.dsr; in cy_get_icount()
2749 sic->rng = cnow.rng; in cy_get_icount()
2750 sic->dcd = cnow.dcd; in cy_get_icount()
2751 sic->rx = cnow.rx; in cy_get_icount()
2752 sic->tx = cnow.tx; in cy_get_icount()
2753 sic->frame = cnow.frame; in cy_get_icount()
2754 sic->overrun = cnow.overrun; in cy_get_icount()
2755 sic->parity = cnow.parity; in cy_get_icount()
2756 sic->brk = cnow.brk; in cy_get_icount()
2757 sic->buf_overrun = cnow.buf_overrun; in cy_get_icount()
2764 * well-designed tty driver should be prepared to accept the case
2769 struct cyclades_port *info = tty->driver_data; in cy_set_termios()
2772 printk(KERN_DEBUG "cyc:cy_set_termios ttyC%d\n", info->line); in cy_set_termios()
2777 if ((old_termios->c_cflag & CRTSCTS) && !C_CRTSCTS(tty)) { in cy_set_termios()
2778 tty->hw_stopped = 0; in cy_set_termios()
2788 if (!(old_termios->c_cflag & CLOCAL) && C_CLOCAL(tty)) in cy_set_termios()
2789 wake_up_interruptible(&info->port.open_wait); in cy_set_termios()
2793 /* This function is used to send a high-priority XON/XOFF character to
2798 struct cyclades_port *info = tty->driver_data; in cy_send_xchar()
2802 if (serial_paranoia_check(info, tty->name, "cy_send_xchar")) in cy_send_xchar()
2805 info->x_char = ch; in cy_send_xchar()
2810 card = info->card; in cy_send_xchar()
2811 channel = info->line - card->first_line; in cy_send_xchar()
2821 /* This routine is called by the upper-layer tty layer to signal
2827 struct cyclades_port *info = tty->driver_data; in cy_throttle()
2832 printk(KERN_DEBUG "cyc:throttle %s ...ttyC%d\n", tty_name(tty), in cy_throttle()
2833 info->line); in cy_throttle()
2836 if (serial_paranoia_check(info, tty->name, "cy_throttle")) in cy_throttle()
2839 card = info->card; in cy_throttle()
2845 info->throttle = 1; in cy_throttle()
2850 spin_lock_irqsave(&card->card_lock, flags); in cy_throttle()
2852 spin_unlock_irqrestore(&card->card_lock, flags); in cy_throttle()
2854 info->throttle = 1; in cy_throttle()
2866 struct cyclades_port *info = tty->driver_data; in cy_unthrottle()
2872 tty_name(tty), info->line); in cy_unthrottle()
2875 if (serial_paranoia_check(info, tty->name, "cy_unthrottle")) in cy_unthrottle()
2879 if (info->x_char) in cy_unthrottle()
2880 info->x_char = 0; in cy_unthrottle()
2886 card = info->card; in cy_unthrottle()
2888 spin_lock_irqsave(&card->card_lock, flags); in cy_unthrottle()
2890 spin_unlock_irqrestore(&card->card_lock, flags); in cy_unthrottle()
2892 info->throttle = 0; in cy_unthrottle()
2903 struct cyclades_port *info = tty->driver_data; in cy_stop()
2908 printk(KERN_DEBUG "cyc:cy_stop ttyC%d\n", info->line); in cy_stop()
2911 if (serial_paranoia_check(info, tty->name, "cy_stop")) in cy_stop()
2914 cinfo = info->card; in cy_stop()
2915 channel = info->line - cinfo->first_line; in cy_stop()
2917 spin_lock_irqsave(&cinfo->card_lock, flags); in cy_stop()
2920 spin_unlock_irqrestore(&cinfo->card_lock, flags); in cy_stop()
2927 struct cyclades_port *info = tty->driver_data; in cy_start()
2932 printk(KERN_DEBUG "cyc:cy_start ttyC%d\n", info->line); in cy_start()
2935 if (serial_paranoia_check(info, tty->name, "cy_start")) in cy_start()
2938 cinfo = info->card; in cy_start()
2939 channel = info->line - cinfo->first_line; in cy_start()
2941 spin_lock_irqsave(&cinfo->card_lock, flags); in cy_start()
2944 spin_unlock_irqrestore(&cinfo->card_lock, flags); in cy_start()
2949 * cy_hangup() --- called by tty_hangup() when a hangup is signaled.
2953 struct cyclades_port *info = tty->driver_data; in cy_hangup()
2956 printk(KERN_DEBUG "cyc:cy_hangup ttyC%d\n", info->line); in cy_hangup()
2959 if (serial_paranoia_check(info, tty->name, "cy_hangup")) in cy_hangup()
2964 tty_port_hangup(&info->port); in cy_hangup()
2971 struct cyclades_card *cinfo = info->card; in cyy_carrier_raised()
2973 int channel = info->line - cinfo->first_line; in cyy_carrier_raised()
2976 spin_lock_irqsave(&cinfo->card_lock, flags); in cyy_carrier_raised()
2979 spin_unlock_irqrestore(&cinfo->card_lock, flags); in cyy_carrier_raised()
2988 struct cyclades_card *cinfo = info->card; in cyy_dtr_rts()
2991 spin_lock_irqsave(&cinfo->card_lock, flags); in cyy_dtr_rts()
2994 spin_unlock_irqrestore(&cinfo->card_lock, flags); in cyy_dtr_rts()
3002 return readl(&info->u.cyz.ch_ctrl->rs_status) & C_RS_DCD; in cyz_carrier_raised()
3009 struct cyclades_card *cinfo = info->card; in cyz_dtr_rts()
3010 struct CH_CTRL __iomem *ch_ctrl = info->u.cyz.ch_ctrl; in cyz_dtr_rts()
3011 int ret, channel = info->line - cinfo->first_line; in cyz_dtr_rts()
3014 rs = readl(&ch_ctrl->rs_control); in cyz_dtr_rts()
3019 cy_writel(&ch_ctrl->rs_control, rs); in cyz_dtr_rts()
3023 __func__, info->line, ret); in cyz_dtr_rts()
3042 * ---------------------------------------------------------------------
3045 * cy_init() is called at boot-time to initialize the serial driver.
3046 * ---------------------------------------------------------------------
3054 spin_lock_init(&cinfo->card_lock); in cy_init_card()
3055 cinfo->intr_enabled = 0; in cy_init_card()
3057 cinfo->ports = kcalloc(cinfo->nports, sizeof(*cinfo->ports), in cy_init_card()
3059 if (cinfo->ports == NULL) { in cy_init_card()
3061 return -ENOMEM; in cy_init_card()
3064 for (channel = 0, port = cinfo->first_line; channel < cinfo->nports; in cy_init_card()
3066 info = &cinfo->ports[channel]; in cy_init_card()
3067 tty_port_init(&info->port); in cy_init_card()
3068 info->magic = CYCLADES_MAGIC; in cy_init_card()
3069 info->card = cinfo; in cy_init_card()
3070 info->line = port; in cy_init_card()
3072 info->port.closing_wait = CLOSING_WAIT_DELAY; in cy_init_card()
3073 info->port.close_delay = 5 * HZ / 10; in cy_init_card()
3074 init_completion(&info->shutdown_wait); in cy_init_card()
3077 struct FIRM_ID *firm_id = cinfo->base_addr + ID_ADDRESS; in cy_init_card()
3080 info->port.ops = &cyz_port_ops; in cy_init_card()
3081 info->type = PORT_STARTECH; in cy_init_card()
3083 zfw_ctrl = cinfo->base_addr + in cy_init_card()
3084 (readl(&firm_id->zfwctrl_addr) & 0xfffff); in cy_init_card()
3085 info->u.cyz.ch_ctrl = &zfw_ctrl->ch_ctrl[channel]; in cy_init_card()
3086 info->u.cyz.buf_ctrl = &zfw_ctrl->buf_ctrl[channel]; in cy_init_card()
3088 if (cinfo->hw_ver == ZO_V1) in cy_init_card()
3089 info->xmit_fifo_size = CYZ_FIFO_SIZE; in cy_init_card()
3091 info->xmit_fifo_size = 4 * CYZ_FIFO_SIZE; in cy_init_card()
3093 timer_setup(&info->rx_full_timer, cyz_rx_restart, 0); in cy_init_card()
3097 int index = cinfo->bus_index; in cy_init_card()
3099 info->port.ops = &cyy_port_ops; in cy_init_card()
3100 info->type = PORT_CIRRUS; in cy_init_card()
3101 info->xmit_fifo_size = CyMAX_CHAR_FIFO; in cy_init_card()
3102 info->cor1 = CyPARITY_NONE | Cy_1_STOP | Cy_8_BITS; in cy_init_card()
3103 info->cor2 = CyETC; in cy_init_card()
3104 info->cor3 = 0x08; /* _very_ small rcv threshold */ in cy_init_card()
3107 info->u.cyy.base_addr = cinfo->base_addr + in cy_init_card()
3109 info->chip_rev = cyy_readb(info, CyGFRCR); in cy_init_card()
3111 if (info->chip_rev >= CD1400_REV_J) { in cy_init_card()
3113 info->tbpr = baud_bpr_60[13]; /* Tx BPR */ in cy_init_card()
3114 info->tco = baud_co_60[13]; /* Tx CO */ in cy_init_card()
3115 info->rbpr = baud_bpr_60[13]; /* Rx BPR */ in cy_init_card()
3116 info->rco = baud_co_60[13]; /* Rx CO */ in cy_init_card()
3117 info->rtsdtr_inv = 1; in cy_init_card()
3119 info->tbpr = baud_bpr_25[13]; /* Tx BPR */ in cy_init_card()
3120 info->tco = baud_co_25[13]; /* Tx CO */ in cy_init_card()
3121 info->rbpr = baud_bpr_25[13]; /* Rx BPR */ in cy_init_card()
3122 info->rco = baud_co_25[13]; /* Rx CO */ in cy_init_card()
3123 info->rtsdtr_inv = 0; in cy_init_card()
3125 info->read_status_mask = CyTIMEOUT | CySPECHAR | in cy_init_card()
3135 printk(KERN_DEBUG "Cyclades-Z polling initialized\n"); in cy_init_card()
3142 /* initialize chips on Cyclom-Y card -- return number of valid
3172 /* The Cyclom-16Y does not decode address bit 9 and therefore in cyy_init_card()
3173 cannot distinguish between references to chip 0 and a non- in cyy_init_card()
3176 and this must be a Cyclom-16Y, not a Cyclom-32Ye. in cyy_init_card()
3208 /* Impossible to reach 5ms with this chip. in cyy_init_card()
3209 Changed to 2ms instead (f = 500 Hz). */ in cyy_init_card()
3226 * ---------------------------------------------------------------------
3227 * cy_detect_isa() - Probe for Cyclom-Y/ISA boards.
3229 * ---------------------------------------------------------------------
3252 /* scan the address table probing for Cyclom-Y/ISA boards */ in cy_detect_isa()
3261 printk(KERN_ERR "Cyclom-Y/ISA: can't remap base " in cy_detect_isa()
3278 printk(KERN_ERR "Cyclom-Y/ISA found at 0x%lx, but the " in cy_detect_isa()
3286 printk(KERN_ERR "Cyclom-Y/ISA found at 0x%lx, but no " in cy_detect_isa()
3296 if (card->base_addr == NULL) in cy_detect_isa()
3300 printk(KERN_ERR "Cyclom-Y/ISA found at 0x%lx, but no " in cy_detect_isa()
3310 0, "Cyclom-Y", card)) { in cy_detect_isa()
3311 printk(KERN_ERR "Cyclom-Y/ISA found at 0x%lx, but " in cy_detect_isa()
3319 card->base_addr = cy_isa_address; in cy_detect_isa()
3320 card->ctl_addr.p9050 = NULL; in cy_detect_isa()
3321 card->irq = (int)cy_isa_irq; in cy_detect_isa()
3322 card->bus_index = 0; in cy_detect_isa()
3323 card->first_line = cy_next_channel; in cy_detect_isa()
3324 card->num_chips = cy_isa_nchan / CyPORTS_PER_CHIP; in cy_detect_isa()
3325 card->nports = cy_isa_nchan; in cy_detect_isa()
3327 card->base_addr = NULL; in cy_detect_isa()
3334 printk(KERN_INFO "Cyclom-Y/ISA #%d: 0x%lx-0x%lx, IRQ%d found: " in cy_detect_isa()
3337 (unsigned long)(cy_isa_address + (CyISA_Ywin - 1)), in cy_detect_isa()
3342 tty_port_register_device(&card->ports[k].port, in cy_detect_isa()
3359 return -EINVAL; in cyc_isfwstr()
3363 return -EINVAL; in cyc_isfwstr()
3371 for (; size > 0; size--) { in cyz_fpga_copy()
3381 cy_writel(&addr->init_ctrl, readl(&addr->init_ctrl) | 0x40000000); in plx_init()
3383 cy_writel(&addr->init_ctrl, readl(&addr->init_ctrl) & ~0x40000000); in plx_init()
3386 cy_writel(&addr->init_ctrl, readl(&addr->init_ctrl) | 0x20000000); in plx_init()
3388 cy_writel(&addr->init_ctrl, readl(&addr->init_ctrl) & ~0x20000000); in plx_init()
3391 * the IRQ is lost and, thus, we have to re-write it to the PCI config. in plx_init()
3401 const void *ptr = fw->data; in __cyz_load_fw()
3405 unsigned int a, tmp, len = fw->size; in __cyz_load_fw()
3409 return -EINVAL; in __cyz_load_fw()
3412 cs = ptr + h->config_offset; in __cyz_load_fw()
3413 bs = ptr + h->block_offset; in __cyz_load_fw()
3415 if ((void *)(cs + h->n_config) > ptr + len || in __cyz_load_fw()
3416 (void *)(bs + h->n_blocks) > ptr + len) { in __cyz_load_fw()
3418 return -EINVAL; in __cyz_load_fw()
3421 if (cyc_isfwstr(h->name, sizeof(h->name)) || in __cyz_load_fw()
3422 cyc_isfwstr(h->date, sizeof(h->date))) { in __cyz_load_fw()
3424 return -EINVAL; in __cyz_load_fw()
3427 if (strncmp(name, h->name, sizeof(h->name))) { in __cyz_load_fw()
3428 printk(BAD_FW "bad name '%s' (expected '%s')\n", h->name, name); in __cyz_load_fw()
3429 return -EINVAL; in __cyz_load_fw()
3433 for (c = cs; c < cs + h->n_config; c++) { in __cyz_load_fw()
3434 for (a = 0; a < c->n_blocks; a++) in __cyz_load_fw()
3435 if (c->block_list[a] > h->n_blocks) { in __cyz_load_fw()
3437 return -EINVAL; in __cyz_load_fw()
3439 if (c->mailbox == mailbox && c->function == 0) /* 0 is normal */ in __cyz_load_fw()
3444 return -EINVAL; in __cyz_load_fw()
3447 for (b = bs; b < bs + h->n_blocks; b++) in __cyz_load_fw()
3448 if (b->file_offset + b->size > len) { in __cyz_load_fw()
3450 return -EINVAL; in __cyz_load_fw()
3454 for (c = cs; c < cs + h->n_config; c++) in __cyz_load_fw()
3455 if (c->mailbox == mailbox && c->function == 0) in __cyz_load_fw()
3458 for (a = 0; a < c->n_blocks; a++) { in __cyz_load_fw()
3459 b = &bs[c->block_list[a]]; in __cyz_load_fw()
3460 if (b->type == ZBLOCK_FPGA) { in __cyz_load_fw()
3462 cyz_fpga_copy(fpga, ptr + b->file_offset, in __cyz_load_fw()
3463 b->size); in __cyz_load_fw()
3466 memcpy_toio(base + b->ram_offset, in __cyz_load_fw()
3467 ptr + b->file_offset, b->size); in __cyz_load_fw()
3486 retval = request_firmware(&fw, "cyzfirm.bin", &pdev->dev); in cyz_load_fw()
3488 dev_err(&pdev->dev, "can't get firmware\n"); in cyz_load_fw()
3494 if (__cyz_fpga_loaded(ctl_addr) && readl(&fid->signature) == ZFIRM_ID) { in cyz_load_fw()
3500 dev_dbg(&pdev->dev, "Cyclades-Z FW already loaded. " in cyz_load_fw()
3508 cy_writel(&ctl_addr->intr_ctrl_stat, readl(&ctl_addr->intr_ctrl_stat) & in cyz_load_fw()
3511 mailbox = readl(&ctl_addr->mail_box_0); in cyz_load_fw()
3515 cy_writel(&ctl_addr->loc_addr_base, WIN_CREG); in cyz_load_fw()
3516 cy_writel(&cust->cpu_stop, 0); in cyz_load_fw()
3517 cy_writel(&ctl_addr->loc_addr_base, WIN_RAM); in cyz_load_fw()
3525 retval = __cyz_load_fw(fw, "Cyclom-Z", mailbox, NULL, in cyz_load_fw()
3530 dev_err(&pdev->dev, "fw upload successful, but fw is " in cyz_load_fw()
3537 cy_writel(&ctl_addr->loc_addr_base, WIN_CREG); in cyz_load_fw()
3538 cy_writel(&cust->cpu_stop, 0); in cyz_load_fw()
3539 cy_writel(&ctl_addr->loc_addr_base, WIN_RAM); in cyz_load_fw()
3547 cy_writel(&ctl_addr->loc_addr_base, WIN_RAM + RAM_SIZE); in cyz_load_fw()
3551 cy_writel(&ctl_addr->loc_addr_base, WIN_RAM); in cyz_load_fw()
3554 retval = __cyz_load_fw(fw, "Cyclom-Z", mailbox, base_addr, NULL); in cyz_load_fw()
3560 cy_writel(&ctl_addr->loc_addr_base, WIN_CREG); in cyz_load_fw()
3561 cy_writel(&cust->cpu_start, 0); in cyz_load_fw()
3562 cy_writel(&ctl_addr->loc_addr_base, WIN_RAM); in cyz_load_fw()
3564 while ((status = readl(&fid->signature)) != ZFIRM_ID && i++ < 40) in cyz_load_fw()
3568 dev_err(&pdev->dev, "you need an external power supply " in cyz_load_fw()
3571 retval = -EIO; in cyz_load_fw()
3574 dev_warn(&pdev->dev, "fid->signature = 0x%x... Waiting " in cyz_load_fw()
3576 while ((status = readl(&fid->signature)) != ZFIRM_ID && in cyz_load_fw()
3580 dev_err(&pdev->dev, "Board not started in 20 seconds! " in cyz_load_fw()
3581 "Giving up. (fid->signature = 0x%x)\n", in cyz_load_fw()
3583 dev_info(&pdev->dev, "*** Warning ***: if you are " in cyz_load_fw()
3586 "Cyclades-Z.\n"); in cyz_load_fw()
3591 retval = -EIO; in cyz_load_fw()
3594 dev_dbg(&pdev->dev, "Firmware started after %d seconds.\n", in cyz_load_fw()
3597 pt_zfwctrl = base_addr + readl(&fid->zfwctrl_addr); in cyz_load_fw()
3599 dev_dbg(&pdev->dev, "fid=> %p, zfwctrl_addr=> %x, npt_zfwctrl=> %p\n", in cyz_load_fw()
3600 base_addr + ID_ADDRESS, readl(&fid->zfwctrl_addr), in cyz_load_fw()
3601 base_addr + readl(&fid->zfwctrl_addr)); in cyz_load_fw()
3603 nchan = readl(&pt_zfwctrl->board_ctrl.n_channel); in cyz_load_fw()
3604 dev_info(&pdev->dev, "Cyclades-Z FW loaded: version = %x, ports = %u\n", in cyz_load_fw()
3605 readl(&pt_zfwctrl->board_ctrl.fw_version), nchan); in cyz_load_fw()
3608 dev_warn(&pdev->dev, "no Cyclades-Z ports were found. Please " in cyz_load_fw()
3615 dev_info(&pdev->dev, "Null number of ports detected. Board " in cyz_load_fw()
3621 cy_writel(&pt_zfwctrl->board_ctrl.op_system, C_OS_LINUX); in cyz_load_fw()
3622 cy_writel(&pt_zfwctrl->board_ctrl.dr_version, DRIVER_VERSION); in cyz_load_fw()
3628 cy_writel(&ctl_addr->intr_ctrl_stat, readl(&ctl_addr->intr_ctrl_stat) | in cyz_load_fw()
3630 cy_writel(&ctl_addr->intr_ctrl_stat, readl(&ctl_addr->intr_ctrl_stat) | in cyz_load_fw()
3653 dev_err(&pdev->dev, "cannot enable device\n"); in cy_pci_probe()
3658 irq = pdev->irq; in cy_pci_probe()
3659 device_id = pdev->device & ~PCI_DEVICE_ID_MASK; in cy_pci_probe()
3663 dev_err(&pdev->dev, "Cyclom-Y/PCI not supported for low " in cy_pci_probe()
3665 retval = -EIO; in cy_pci_probe()
3670 dev_err(&pdev->dev, "Cyclades-Z/PCI not supported for low " in cy_pci_probe()
3672 retval = -EIO; in cy_pci_probe()
3677 dev_warn(&pdev->dev, "PCI I/O bit incorrectly set. Ignoring " in cy_pci_probe()
3679 pdev->resource[2].flags &= ~IORESOURCE_IO; in cy_pci_probe()
3684 dev_err(&pdev->dev, "failed to reserve resources\n"); in cy_pci_probe()
3688 retval = -EIO; in cy_pci_probe()
3691 card_name = "Cyclom-Y"; in cy_pci_probe()
3696 dev_err(&pdev->dev, "can't remap ctl region\n"); in cy_pci_probe()
3702 dev_err(&pdev->dev, "can't remap base region\n"); in cy_pci_probe()
3708 dev_err(&pdev->dev, "Cyclom-Y PCI host card with no " in cy_pci_probe()
3709 "Serial-Modules\n"); in cy_pci_probe()
3718 dev_err(&pdev->dev, "can't remap ctl region\n"); in cy_pci_probe()
3723 cy_writew(&ctl_addr->intr_ctrl_stat, in cy_pci_probe()
3724 readw(&ctl_addr->intr_ctrl_stat) & ~0x0900); in cy_pci_probe()
3728 mailbox = readl(&ctl_addr->mail_box_0); in cy_pci_probe()
3733 dev_err(&pdev->dev, "can't remap base region\n"); in cy_pci_probe()
3738 card_name = "Cyclades-Ze"; in cy_pci_probe()
3740 card_name = "Cyclades-8Zo"; in cy_pci_probe()
3743 cy_writel(&ctl_addr->loc_addr_base, WIN_CREG); in cy_pci_probe()
3744 dev_info(&pdev->dev, "Cyclades-8Zo/PCI: FPGA " in cy_pci_probe()
3746 readl(&((struct CUSTOM_REG *)addr2)-> in cy_pci_probe()
3748 readl(&((struct CUSTOM_REG *)addr2)-> in cy_pci_probe()
3750 cy_writel(&ctl_addr->loc_addr_base, WIN_RAM); in cy_pci_probe()
3752 dev_info(&pdev->dev, "Cyclades-Z/PCI: New " in cy_pci_probe()
3753 "Cyclades-Z board. FPGA not loaded\n"); in cy_pci_probe()
3771 dev_err(&pdev->dev, "Cyclades-8Zo/PCI found, but no " in cy_pci_probe()
3779 if (card->base_addr == NULL) in cy_pci_probe()
3783 dev_err(&pdev->dev, "Cyclades-8Zo/PCI found, but no " in cy_pci_probe()
3793 IRQF_SHARED, "Cyclom-Y", card); in cy_pci_probe()
3795 dev_err(&pdev->dev, "could not allocate IRQ\n"); in cy_pci_probe()
3798 card->num_chips = nchan / CyPORTS_PER_CHIP; in cy_pci_probe()
3803 zfw_ctrl = addr2 + (readl(&firm_id->zfwctrl_addr) & 0xfffff); in cy_pci_probe()
3805 card->hw_ver = mailbox; in cy_pci_probe()
3806 card->num_chips = (unsigned int)-1; in cy_pci_probe()
3807 card->board_ctrl = &zfw_ctrl->board_ctrl; in cy_pci_probe()
3812 IRQF_SHARED, "Cyclades-Z", card); in cy_pci_probe()
3814 dev_err(&pdev->dev, "could not allocate IRQ\n"); in cy_pci_probe()
3822 card->base_addr = addr2; in cy_pci_probe()
3823 card->ctl_addr.p9050 = addr0; in cy_pci_probe()
3824 card->irq = irq; in cy_pci_probe()
3825 card->bus_index = 1; in cy_pci_probe()
3826 card->first_line = cy_next_channel; in cy_pci_probe()
3827 card->nports = nchan; in cy_pci_probe()
3849 cy_writew(&ctl_addr->intr_ctrl_stat, in cy_pci_probe()
3850 readw(&ctl_addr->intr_ctrl_stat) | 0x0900); in cy_pci_probe()
3856 dev_info(&pdev->dev, "%s/PCI #%d found: %d channels starting from " in cy_pci_probe()
3859 tty_port_register_device(&card->ports[j].port, in cy_pci_probe()
3860 cy_serial_driver, i, &pdev->dev); in cy_pci_probe()
3865 card->base_addr = NULL; in cy_pci_probe()
3884 /* non-Z with old PLX */ in cy_pci_remove()
3885 if (!cy_is_Z(cinfo) && (readb(cinfo->base_addr + CyPLX_VER) & 0x0f) == in cy_pci_remove()
3887 cy_writeb(cinfo->ctl_addr.p9050 + 0x4c, 0); in cy_pci_remove()
3892 cy_writew(&cinfo->ctl_addr.p9060->intr_ctrl_stat, in cy_pci_remove()
3893 readw(&cinfo->ctl_addr.p9060->intr_ctrl_stat) & in cy_pci_remove()
3896 iounmap(cinfo->base_addr); in cy_pci_remove()
3897 if (cinfo->ctl_addr.p9050) in cy_pci_remove()
3898 iounmap(cinfo->ctl_addr.p9050); in cy_pci_remove()
3899 if (cinfo->irq in cy_pci_remove()
3904 free_irq(cinfo->irq, cinfo); in cy_pci_remove()
3907 cinfo->base_addr = NULL; in cy_pci_remove()
3908 for (channel = 0, i = cinfo->first_line; i < cinfo->first_line + in cy_pci_remove()
3909 cinfo->nports; i++, channel++) { in cy_pci_remove()
3911 tty_port_destroy(&cinfo->ports[channel].port); in cy_pci_remove()
3913 cinfo->nports = 0; in cy_pci_remove()
3914 kfree(cinfo->ports); in cy_pci_remove()
3939 if (info->port.count) { in cyclades_proc_show()
3944 tty = tty_port_tty_get(&info->port); in cyclades_proc_show()
3948 num = ld->ops->num; in cyclades_proc_show()
3954 "%10lu %8lu %9lu %6d\n", info->line, in cyclades_proc_show()
3955 (cur_jifs - info->idle_stats.in_use) / in cyclades_proc_show()
3956 HZ, info->idle_stats.xmit_bytes, in cyclades_proc_show()
3957 (cur_jifs - info->idle_stats.xmit_idle)/ in cyclades_proc_show()
3958 HZ, info->idle_stats.recv_bytes, in cyclades_proc_show()
3959 (cur_jifs - info->idle_stats.recv_idle)/ in cyclades_proc_show()
3960 HZ, info->idle_stats.overruns, in cyclades_proc_show()
3965 info->line, 0L, 0L, 0L, 0L, 0L, 0L, 0L); in cyclades_proc_show()
3970 /* The serial driver boot-time initialization code!
3976 fashion. If an 8-port card is replaced with a 16-port card, the
3998 .throttle = cy_throttle,
4017 int retval = -ENOMEM; in cy_init()
4027 cy_serial_driver->driver_name = "cyclades"; in cy_init()
4028 cy_serial_driver->name = "ttyC"; in cy_init()
4029 cy_serial_driver->major = CYCLADES_MAJOR; in cy_init()
4030 cy_serial_driver->minor_start = 0; in cy_init()
4031 cy_serial_driver->type = TTY_DRIVER_TYPE_SERIAL; in cy_init()
4032 cy_serial_driver->subtype = SERIAL_TYPE_NORMAL; in cy_init()
4033 cy_serial_driver->init_termios = tty_std_termios; in cy_init()
4034 cy_serial_driver->init_termios.c_cflag = in cy_init()
4036 cy_serial_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV; in cy_init()
4091 if (card->base_addr) { in cy_cleanup_module()
4093 cy_writeb(card->base_addr + Cy_ClrIntr, 0); in cy_cleanup_module()
4094 iounmap(card->base_addr); in cy_cleanup_module()
4095 if (card->ctl_addr.p9050) in cy_cleanup_module()
4096 iounmap(card->ctl_addr.p9050); in cy_cleanup_module()
4097 if (card->irq in cy_cleanup_module()
4102 free_irq(card->irq, card); in cy_cleanup_module()
4103 for (e1 = card->first_line; e1 < card->first_line + in cy_cleanup_module()
4104 card->nports; e1++) in cy_cleanup_module()
4106 kfree(card->ports); in cy_cleanup_module()