Lines Matching +full:ports +full:- +full:word +full:- +full:length

1 // SPDX-License-Identifier: GPL-2.0+
4 * moxa.c -- MOXA Intellio family multiport serial driver.
6 * Copyright (C) 1999-2000 Moxa Technologies (support@moxa.com).
68 #define C218_key (C218_ConfBase + 4) /* WORD (0x218 for C218) */
69 #define C218DLoad_len (C218_ConfBase + 6) /* WORD */
72 #define C218_TestRx (C218_ConfBase + 0x10) /* 8 bytes for 8 ports */
73 #define C218_TestTx (C218_ConfBase + 0x18) /* 8 bytes for 8 ports */
74 #define C218_RXerr (C218_ConfBase + 0x20) /* 8 bytes for 8 ports */
75 #define C218_ErrFlag (C218_ConfBase + 0x28) /* 8 bytes for 8 ports */
90 #define C320_key C320_ConfBase + 4 /* WORD (0320H for C320) */
91 #define C320DLoad_len C320_ConfBase + 6 /* WORD */
92 #define C320check_sum C320_ConfBase + 8 /* WORD */
93 #define C320chksum_ok C320_ConfBase + 0x0a /* WORD (1:ok) */
94 #define C320bapi_len C320_ConfBase + 0x0c /* WORD */
95 #define C320UART_no C320_ConfBase + 0x0e /* WORD */
161 * Dual-Ported RAM
214 /* | | +--- RTS flow */
215 /* | +------ TX Xon/Xoff */
216 /* +--------- RX Xon/Xoff */
218 #define CD180TXirq 0x10 /* if non-0: enable TX irq */
241 #define C218rx_mask (C218rx_size - 1)
242 #define C218tx_mask (C218tx_size - 1)
246 #define C320p8rx_mask (C320p8rx_size - 1)
247 #define C320p8tx_mask (C320p8tx_size - 1)
251 #define C320p16rx_mask (C320p16rx_size - 1)
252 #define C320p16tx_mask (C320p16tx_size - 1)
256 #define C320p24rx_mask (C320p24rx_size - 1)
257 #define C320p24tx_mask (C320p24tx_size - 1)
261 #define C320p32rx_mask (C320p32rx_size - 1)
262 #define C320p32tx_mask (C320p32tx_size - 1)
265 #define Page_mask (Page_size - 1)
360 #define MOXA_IS_320(brd) ((brd)->boardType == MOXA_BOARD_C320_ISA || \
361 (brd)->boardType == MOXA_BOARD_C320_PCI)
383 "CP-204J series",
408 struct moxa_port *ports; member
576 len = (wptr - rptr) & mask; in moxa_low_water_check()
589 struct moxa_port *ch = tty->driver_data; in moxa_ioctl()
593 if (tty->index == MAX_PORTS) { in moxa_ioctl()
596 return -EINVAL; in moxa_ioctl()
598 return -ENODEV; in moxa_ioctl()
604 ret = -EFAULT; in moxa_ioctl()
616 p = moxa_boards[i].ports; in moxa_ioctl()
626 return -EFAULT; in moxa_ioctl()
645 p = moxa_boards[i].ports; in moxa_ioctl()
665 ttyp = tty_port_tty_get(&p->port); in moxa_ioctl()
667 tmp.cflag = p->cflag; in moxa_ioctl()
669 tmp.cflag = ttyp->termios.c_cflag; in moxa_ioctl()
673 return -EFAULT; in moxa_ioctl()
679 ret = -ENOIOCTLCMD; in moxa_ioctl()
686 struct moxa_port *port = tty->driver_data; in moxa_break_ctl()
688 moxafunc(port->tableAddr, state ? FC_SendBreak : FC_StopBreak, in moxa_break_ctl()
727 switch (brd->boardType) { in moxa_check_fw_model()
744 return -EINVAL; in moxa_check_fw_model()
752 return -EINVAL; in moxa_check_fw()
760 void __iomem *baseAddr = brd->basemem; in moxa_load_bios()
771 switch (brd->boardType) { in moxa_load_bios()
789 printk(KERN_ERR "MOXA: bios upload failed -- CPU/Basic " in moxa_load_bios()
791 return -EIO; in moxa_load_bios()
798 printk(KERN_ERR "MOXA: bios upload failed -- board not found\n"); in moxa_load_bios()
799 return -EIO; in moxa_load_bios()
805 void __iomem *baseAddr = brd->basemem; in moxa_load_320b()
808 printk(KERN_ERR "MOXA: invalid 320 bios -- too short\n"); in moxa_load_320b()
809 return -EINVAL; in moxa_load_320b()
812 writew(len - 7168 - 2, baseAddr + C320bapi_len); in moxa_load_320b()
816 memcpy_toio(baseAddr + DynPage_addr, ptr + 7168, len - 7168); in moxa_load_320b()
824 void __iomem *baseAddr = brd->basemem; in moxa_real_load_code()
831 keycode = (brd->boardType == MOXA_BOARD_CP204J) ? CP204J_KeyCode : in moxa_real_load_code()
834 switch (brd->boardType) { in moxa_real_load_code()
864 wlen -= len2; in moxa_real_load_code()
876 return -EIO; in moxa_real_load_code()
889 return -EIO; in moxa_real_load_code()
898 return -EIO; in moxa_real_load_code()
901 if (brd->busType == MOXA_BUS_TYPE_PCI) { /* ASIC board */ in moxa_real_load_code()
919 return -EIO; in moxa_real_load_code()
924 return -EIO; in moxa_real_load_code()
925 brd->numPorts = j * 8; in moxa_real_load_code()
934 return -EIO; in moxa_real_load_code()
936 brd->intNdx = baseAddr + IRQindex; in moxa_real_load_code()
937 brd->intPend = baseAddr + IRQpending; in moxa_real_load_code()
938 brd->intTable = baseAddr + IRQtable; in moxa_real_load_code()
946 void __iomem *ofsAddr, *baseAddr = brd->basemem; in moxa_load_code()
951 printk(KERN_ERR "MOXA: bios length is not even\n"); in moxa_load_code()
952 return -EINVAL; in moxa_load_code()
959 switch (brd->boardType) { in moxa_load_code()
963 port = brd->ports; in moxa_load_code()
964 for (i = 0; i < brd->numPorts; i++, port++) { in moxa_load_code()
965 port->board = brd; in moxa_load_code()
966 port->DCDState = 0; in moxa_load_code()
967 port->tableAddr = baseAddr + Extern_table + in moxa_load_code()
969 ofsAddr = port->tableAddr; in moxa_load_code()
981 port = brd->ports; in moxa_load_code()
982 for (i = 0; i < brd->numPorts; i++, port++) { in moxa_load_code()
983 port->board = brd; in moxa_load_code()
984 port->DCDState = 0; in moxa_load_code()
985 port->tableAddr = baseAddr + Extern_table + in moxa_load_code()
987 ofsAddr = port->tableAddr; in moxa_load_code()
988 switch (brd->numPorts) { in moxa_load_code()
1033 const void *ptr = fw->data; in moxa_load_fw()
1038 int ret = -EINVAL; in moxa_load_fw()
1048 BUILD_BUG_ON(ARRAY_SIZE(hdr->len) != ARRAY_SIZE(lens)); in moxa_load_fw()
1050 if (fw->size < MOXA_FW_HDRLEN) { in moxa_load_fw()
1054 if (hdr->magic != cpu_to_le32(0x30343034)) { in moxa_load_fw()
1055 sprintf(rsn, "bad magic: %.8x", le32_to_cpu(hdr->magic)); in moxa_load_fw()
1058 if (hdr->type != 3) { in moxa_load_fw()
1059 sprintf(rsn, "not for linux, type is %u", hdr->type); in moxa_load_fw()
1062 if (moxa_check_fw_model(brd, hdr->model)) { in moxa_load_fw()
1063 sprintf(rsn, "not for this card, model is %u", hdr->model); in moxa_load_fw()
1068 lencnt = hdr->model == 2 ? 5 : 3; in moxa_load_fw()
1070 lens[a] = le16_to_cpu(hdr->len[a]); in moxa_load_fw()
1071 if (lens[a] && len + lens[a] <= fw->size && in moxa_load_fw()
1072 moxa_check_fw(&fw->data[len])) in moxa_load_fw()
1082 if (len != fw->size) { in moxa_load_fw()
1083 sprintf(rsn, "bad length: %u (should be %u)", (u32)fw->size, in moxa_load_fw()
1101 if (hdr->model == 2) { in moxa_load_fw()
1128 brd->ports = kcalloc(MAX_PORTS_PER_BOARD, sizeof(*brd->ports), in moxa_init_board()
1130 if (brd->ports == NULL) { in moxa_init_board()
1131 printk(KERN_ERR "cannot allocate memory for ports\n"); in moxa_init_board()
1132 ret = -ENOMEM; in moxa_init_board()
1136 for (i = 0, p = brd->ports; i < MAX_PORTS_PER_BOARD; i++, p++) { in moxa_init_board()
1137 tty_port_init(&p->port); in moxa_init_board()
1138 p->port.ops = &moxa_port_ops; in moxa_init_board()
1139 p->type = PORT_16550A; in moxa_init_board()
1140 p->cflag = B9600 | CS8 | CREAD | CLOCAL | HUPCL; in moxa_init_board()
1143 switch (brd->boardType) { in moxa_init_board()
1173 brd->ready = 1; in moxa_init_board()
1178 first_idx = (brd - moxa_boards) * MAX_PORTS_PER_BOARD; in moxa_init_board()
1179 for (i = 0; i < brd->numPorts; i++) in moxa_init_board()
1180 tty_port_register_device(&brd->ports[i].port, moxaDriver, in moxa_init_board()
1186 tty_port_destroy(&brd->ports[i].port); in moxa_init_board()
1187 kfree(brd->ports); in moxa_init_board()
1198 brd->ready = 0; in moxa_board_deinit()
1201 /* pci hot-un-plug support */ in moxa_board_deinit()
1202 for (a = 0; a < brd->numPorts; a++) in moxa_board_deinit()
1203 if (tty_port_initialized(&brd->ports[a].port)) in moxa_board_deinit()
1204 tty_port_tty_hangup(&brd->ports[a].port, false); in moxa_board_deinit()
1207 tty_port_destroy(&brd->ports[a].port); in moxa_board_deinit()
1211 for (a = 0; a < brd->numPorts; a++) in moxa_board_deinit()
1212 if (tty_port_initialized(&brd->ports[a].port)) in moxa_board_deinit()
1221 first_idx = (brd - moxa_boards) * MAX_PORTS_PER_BOARD; in moxa_board_deinit()
1222 for (a = 0; a < brd->numPorts; a++) in moxa_board_deinit()
1225 iounmap(brd->basemem); in moxa_board_deinit()
1226 brd->basemem = NULL; in moxa_board_deinit()
1227 kfree(brd->ports); in moxa_board_deinit()
1236 int board_type = ent->driver_data; in moxa_pci_probe()
1241 dev_err(&pdev->dev, "can't enable pci device\n"); in moxa_pci_probe()
1249 retval = -ENODEV; in moxa_pci_probe()
1251 dev_warn(&pdev->dev, "more than %u MOXA Intellio family boards " in moxa_pci_probe()
1258 retval = pci_request_region(pdev, 2, "moxa-base"); in moxa_pci_probe()
1260 dev_err(&pdev->dev, "can't request pci region 2\n"); in moxa_pci_probe()
1264 board->basemem = ioremap(pci_resource_start(pdev, 2), 0x4000); in moxa_pci_probe()
1265 if (board->basemem == NULL) { in moxa_pci_probe()
1266 dev_err(&pdev->dev, "can't remap io space 2\n"); in moxa_pci_probe()
1267 retval = -ENOMEM; in moxa_pci_probe()
1271 board->boardType = board_type; in moxa_pci_probe()
1275 board->numPorts = 8; in moxa_pci_probe()
1279 board->numPorts = 4; in moxa_pci_probe()
1282 board->numPorts = 0; in moxa_pci_probe()
1285 board->busType = MOXA_BUS_TYPE_PCI; in moxa_pci_probe()
1287 retval = moxa_init_board(board, &pdev->dev); in moxa_pci_probe()
1293 dev_info(&pdev->dev, "board '%s' ready (%u ports, firmware loaded)\n", in moxa_pci_probe()
1294 moxa_brdname[board_type - 1], board->numPorts); in moxa_pci_probe()
1298 iounmap(board->basemem); in moxa_pci_probe()
1299 board->basemem = NULL; in moxa_pci_probe()
1341 moxaDriver->name = "ttyMX"; in moxa_init()
1342 moxaDriver->major = ttymajor; in moxa_init()
1343 moxaDriver->minor_start = 0; in moxa_init()
1344 moxaDriver->type = TTY_DRIVER_TYPE_SERIAL; in moxa_init()
1345 moxaDriver->subtype = SERIAL_TYPE_NORMAL; in moxa_init()
1346 moxaDriver->init_termios = tty_std_termios; in moxa_init()
1347 moxaDriver->init_termios.c_cflag = B9600 | CS8 | CREAD | CLOCAL | HUPCL; in moxa_init()
1348 moxaDriver->init_termios.c_ispeed = 9600; in moxa_init()
1349 moxaDriver->init_termios.c_ospeed = 9600; in moxa_init()
1357 return -1; in moxa_init()
1368 isabrds + 1, moxa_brdname[type[i] - 1], in moxa_init()
1370 brd->boardType = type[i]; in moxa_init()
1371 brd->numPorts = type[i] == MOXA_BOARD_C218_ISA ? 8 : in moxa_init()
1373 brd->busType = MOXA_BUS_TYPE_ISA; in moxa_init()
1374 brd->basemem = ioremap(baseaddr[i], 0x4000); in moxa_init()
1375 if (!brd->basemem) { in moxa_init()
1381 iounmap(brd->basemem); in moxa_init()
1382 brd->basemem = NULL; in moxa_init()
1387 "ready (%u ports, firmware loaded)\n", in moxa_init()
1388 baseaddr[i], brd->numPorts); in moxa_init()
1440 spin_lock_irq(&port->lock); in moxa_carrier_raised()
1441 dcd = ch->DCDState; in moxa_carrier_raised()
1442 spin_unlock_irq(&port->lock); in moxa_carrier_raised()
1459 port = tty->index; in moxa_open()
1461 return capable(CAP_SYS_ADMIN) ? 0 : -EPERM; in moxa_open()
1464 return -ERESTARTSYS; in moxa_open()
1466 if (!brd->ready) { in moxa_open()
1468 return -ENODEV; in moxa_open()
1471 if (port % MAX_PORTS_PER_BOARD >= brd->numPorts) { in moxa_open()
1473 return -ENODEV; in moxa_open()
1476 ch = &brd->ports[port % MAX_PORTS_PER_BOARD]; in moxa_open()
1477 ch->port.count++; in moxa_open()
1478 tty->driver_data = ch; in moxa_open()
1479 tty_port_tty_set(&ch->port, tty); in moxa_open()
1480 mutex_lock(&ch->port.mutex); in moxa_open()
1481 if (!tty_port_initialized(&ch->port)) { in moxa_open()
1482 ch->statusflags = 0; in moxa_open()
1483 moxa_set_tty_param(tty, &tty->termios); in moxa_open()
1486 MoxaSetFifo(ch, ch->type == PORT_16550A); in moxa_open()
1487 tty_port_set_initialized(&ch->port, true); in moxa_open()
1489 mutex_unlock(&ch->port.mutex); in moxa_open()
1492 return tty_port_block_til_ready(&ch->port, tty, filp); in moxa_open()
1497 struct moxa_port *ch = tty->driver_data; in moxa_close()
1498 ch->cflag = tty->termios.c_cflag; in moxa_close()
1499 tty_port_close(&ch->port, tty, filp); in moxa_close()
1504 struct moxa_port *ch = tty->driver_data; in moxa_write()
1515 set_bit(LOWWAIT, &ch->statusflags); in moxa_write()
1523 if (tty->flow.stopped) in moxa_write_room()
1525 ch = tty->driver_data; in moxa_write_room()
1533 struct moxa_port *ch = tty->driver_data; in moxa_flush_buffer()
1543 struct moxa_port *ch = tty->driver_data; in moxa_chars_in_buffer()
1552 set_bit(EMPTYWAIT, &ch->statusflags); in moxa_chars_in_buffer()
1558 struct moxa_port *ch = tty->driver_data; in moxa_tiocmget()
1585 ch = tty->driver_data; in moxa_tiocmset()
1588 return -EINVAL; in moxa_tiocmset()
1608 struct moxa_port *ch = tty->driver_data; in moxa_set_termios()
1613 if (!(old_termios->c_cflag & CLOCAL) && C_CLOCAL(tty)) in moxa_set_termios()
1614 wake_up_interruptible(&ch->port.open_wait); in moxa_set_termios()
1619 struct moxa_port *ch = tty->driver_data; in moxa_stop()
1624 set_bit(TXSTOPPED, &ch->statusflags); in moxa_stop()
1630 struct moxa_port *ch = tty->driver_data; in moxa_start()
1635 if (!test_bit(TXSTOPPED, &ch->statusflags)) in moxa_start()
1639 clear_bit(TXSTOPPED, &ch->statusflags); in moxa_start()
1644 struct moxa_port *ch = tty->driver_data; in moxa_hangup()
1645 tty_port_hangup(&ch->port); in moxa_hangup()
1653 spin_lock_irqsave(&p->port.lock, flags); in moxa_new_dcdstate()
1654 if (dcd != p->DCDState) { in moxa_new_dcdstate()
1655 p->DCDState = dcd; in moxa_new_dcdstate()
1656 spin_unlock_irqrestore(&p->port.lock, flags); in moxa_new_dcdstate()
1658 tty_port_tty_hangup(&p->port, true); in moxa_new_dcdstate()
1661 spin_unlock_irqrestore(&p->port.lock, flags); in moxa_new_dcdstate()
1667 struct tty_struct *tty = tty_port_tty_get(&p->port); in moxa_poll_port()
1668 bool inited = tty_port_initialized(&p->port); in moxa_poll_port()
1673 if (test_bit(EMPTYWAIT, &p->statusflags) && in moxa_poll_port()
1675 clear_bit(EMPTYWAIT, &p->statusflags); in moxa_poll_port()
1678 if (test_bit(LOWWAIT, &p->statusflags) && !tty->flow.stopped && in moxa_poll_port()
1680 clear_bit(LOWWAIT, &p->statusflags); in moxa_poll_port()
1687 tty_flip_buffer_push(&p->port); in moxa_poll_port()
1690 clear_bit(EMPTYWAIT, &p->statusflags); in moxa_poll_port()
1702 ofsAddr = p->tableAddr; in moxa_poll_port()
1711 tty_insert_flip_char(&p->port, 0, TTY_BREAK); in moxa_poll_port()
1712 tty_flip_buffer_push(&p->port); in moxa_poll_port()
1732 if (!brd->ready) in moxa_poll()
1738 if (readb(brd->intPend) == 0xff) in moxa_poll()
1739 ip = brd->intTable + readb(brd->intNdx); in moxa_poll()
1741 for (port = 0; port < brd->numPorts; port++) in moxa_poll()
1742 moxa_poll_port(&brd->ports[port], !!ip, ip + port); in moxa_poll()
1745 writeb(0, brd->intPend); /* ACK */ in moxa_poll()
1748 struct moxa_port *p = brd->ports; in moxa_poll()
1749 for (port = 0; port < brd->numPorts; port++, p++) in moxa_poll()
1750 if (p->lowChkFlag) { in moxa_poll()
1751 p->lowChkFlag = 0; in moxa_poll()
1752 moxa_low_water_check(p->tableAddr); in moxa_poll()
1768 register struct ktermios *ts = &tty->termios; in moxa_set_tty_param()
1769 struct moxa_port *ch = tty->driver_data; in moxa_set_tty_param()
1773 if (ts->c_cflag & CRTSCTS) in moxa_set_tty_param()
1775 if (ts->c_iflag & IXON) in moxa_set_tty_param()
1777 if (ts->c_iflag & IXOFF) in moxa_set_tty_param()
1779 if (ts->c_iflag & IXANY) in moxa_set_tty_param()
1784 if (baud == -1) in moxa_set_tty_param()
1799 ofsAddr = port->tableAddr; in MoxaPortFlushData()
1802 port->lowChkFlag = 0; in MoxaPortFlushData()
1810 * MOXA serial driver supports up to 4 MOXA-C218/C320 boards. And,
1814 * first board is C218, second board is C320-16 and third board is
1815 * C320-32. The port number of first board (C218 - 8 ports) is from
1816 * 0 to 7. The port number of second board (C320 - 16 ports) is form
1817 * 32 to 47. The port number of third board (C320 - 32 ports) is from
1836 * int port : port number (0 - 127)
1839 * -EINVAL
1840 * -ENOIOCTLCMD
1846 * int port : port number (0 - 127)
1852 * int port : port number (0 - 127)
1858 * int port : port number (0 - 127)
1859 * long baud : baud rate (50 - 115200)
1862 * 50 - 115200 : the real baud rate set to the port, if
1871 * int port : port number (0 - 127)
1875 * return: -1 : this port is invalid or termio == NULL
1882 * int port : port number (0 - 127)
1890 * return: -1 : this port is invalid
1897 * int port : port number (0 - 127)
1906 * int port : port number (0 - 127)
1917 * int port : port number (0 - 127)
1919 * return: Bit 0 - CTS state (0: off, 1: on)
1920 * Bit 1 - DSR state (0: off, 1: on)
1921 * Bit 2 - DCD state (0: off, 1: on)
1927 * int port : port number (0 - 127)
1936 * ssize_t MoxaPortWriteData(int port, u8 *buffer, size_t length);
1937 * int port : port number (0 - 127)
1939 * size_t length : write data length
1941 * return: 0 - length : real write data length
1947 * int port : port number (0 - 127)
1950 * return: 0 - length : real read data length
1956 * int port : port number (0 - 127)
1964 * int port : port number (0 - 127)
1972 * int port : port number (0 - 127)
1980 * int port : port number (0 - 127)
1986 * int port : port number (0 - 127)
1992 * int port : port number (0 - 127)
1994 * return: 0 - .. : BREAK signal count
2004 ofsAddr = port->tableAddr; in MoxaPortEnable()
2006 if (MOXA_IS_320(port->board)) in MoxaPortEnable()
2021 void __iomem *ofsAddr = port->tableAddr; in MoxaPortDisable()
2031 void __iomem *ofsAddr = port->tableAddr; in MoxaPortSetBaud()
2035 max = MOXA_IS_320(port->board) ? 460800 : 921600; in MoxaPortSetBaud()
2053 ofsAddr = port->tableAddr; in MoxaPortSetTermio()
2055 mode = termio->c_cflag & CSIZE; in MoxaPortSetTermio()
2065 if (termio->c_cflag & CSTOPB) { in MoxaPortSetTermio()
2073 if (termio->c_cflag & PARENB) { in MoxaPortSetTermio()
2074 if (termio->c_cflag & PARODD) { in MoxaPortSetTermio()
2075 if (termio->c_cflag & CMSPAR) in MoxaPortSetTermio()
2080 if (termio->c_cflag & CMSPAR) in MoxaPortSetTermio()
2090 if (MOXA_IS_320(port->board) && baud >= 921600) in MoxaPortSetTermio()
2091 return -1; in MoxaPortSetTermio()
2095 if (termio->c_iflag & (IXON | IXOFF | IXANY)) { in MoxaPortSetTermio()
2097 writeb(termio->c_cc[VSTART], ofsAddr + FuncArg); in MoxaPortSetTermio()
2098 writeb(termio->c_cc[VSTOP], ofsAddr + FuncArg1); in MoxaPortSetTermio()
2111 *dtr_active = port->lineCtrl & DTR_ON; in MoxaPortGetLineOut()
2113 *rts_active = port->lineCtrl & RTS_ON; in MoxaPortGetLineOut()
2126 port->lineCtrl = mode; in MoxaPortLineCtrl()
2127 moxafunc(port->tableAddr, FC_LineControl, mode); in MoxaPortLineCtrl()
2145 moxafunc(port->tableAddr, FC_SetFlowCtl, mode); in MoxaPortFlowCtrl()
2153 ofsAddr = port->tableAddr; in MoxaPortLineStatus()
2154 if (MOXA_IS_320(port->board)) in MoxaPortLineStatus()
2169 struct moxa_port *port = tty->driver_data; in MoxaPortWriteData()
2175 ofsAddr = port->tableAddr; in MoxaPortWriteData()
2176 baseAddr = port->board->basemem; in MoxaPortWriteData()
2182 c = (head > tail) ? (head - tail - 1) : (head - tail + tx_mask); in MoxaPortWriteData()
2185 moxaLog.txcnt[port->port.tty->index] += c; in MoxaPortWriteData()
2192 len = head - tail - 1; in MoxaPortWriteData()
2194 len = tx_mask + 1 - tail; in MoxaPortWriteData()
2200 c -= len; in MoxaPortWriteData()
2206 len = Page_size - pageofs; in MoxaPortWriteData()
2216 c -= len; in MoxaPortWriteData()
2227 struct tty_struct *tty = port->port.tty; in MoxaPortReadData()
2234 ofsAddr = port->tableAddr; in MoxaPortReadData()
2235 baseAddr = port->board->basemem; in MoxaPortReadData()
2241 count = (tail >= head) ? (tail - head) : (tail - head + rx_mask + 1); in MoxaPortReadData()
2246 moxaLog.rxcnt[tty->index] += total; in MoxaPortReadData()
2252 len = (tail >= head) ? (tail - head) : in MoxaPortReadData()
2253 (rx_mask + 1 - head); in MoxaPortReadData()
2254 len = tty_prepare_flip_string(&port->port, &dst, in MoxaPortReadData()
2258 count -= len; in MoxaPortReadData()
2266 len = tty_prepare_flip_string(&port->port, &dst, in MoxaPortReadData()
2267 min(Page_size - pageofs, count)); in MoxaPortReadData()
2270 count -= len; in MoxaPortReadData()
2280 port->lowChkFlag = 1; in MoxaPortReadData()
2288 void __iomem *ofsAddr = port->tableAddr; in MoxaPortTxQueue()
2294 return (wptr - rptr) & mask; in MoxaPortTxQueue()
2299 void __iomem *ofsAddr = port->tableAddr; in MoxaPortTxFree()
2305 return mask - ((wptr - rptr) & mask); in MoxaPortTxFree()
2310 void __iomem *ofsAddr = port->tableAddr; in MoxaPortRxQueue()
2316 return (wptr - rptr) & mask; in MoxaPortRxQueue()
2321 moxafunc(port->tableAddr, FC_SetXoffState, Magic_code); in MoxaPortTxDisable()
2326 moxafunc(port->tableAddr, FC_SetXonState, Magic_code); in MoxaPortTxEnable()
2332 struct moxa_port *info = tty->driver_data; in moxa_get_serial_info()
2334 if (tty->index == MAX_PORTS) in moxa_get_serial_info()
2335 return -EINVAL; in moxa_get_serial_info()
2337 return -ENODEV; in moxa_get_serial_info()
2338 mutex_lock(&info->port.mutex); in moxa_get_serial_info()
2339 ss->type = info->type; in moxa_get_serial_info()
2340 ss->line = info->port.tty->index; in moxa_get_serial_info()
2341 ss->flags = info->port.flags; in moxa_get_serial_info()
2342 ss->baud_base = 921600; in moxa_get_serial_info()
2343 ss->close_delay = jiffies_to_msecs(info->port.close_delay) / 10; in moxa_get_serial_info()
2344 mutex_unlock(&info->port.mutex); in moxa_get_serial_info()
2352 struct moxa_port *info = tty->driver_data; in moxa_set_serial_info()
2355 if (tty->index == MAX_PORTS) in moxa_set_serial_info()
2356 return -EINVAL; in moxa_set_serial_info()
2358 return -ENODEV; in moxa_set_serial_info()
2360 close_delay = msecs_to_jiffies(ss->close_delay * 10); in moxa_set_serial_info()
2362 mutex_lock(&info->port.mutex); in moxa_set_serial_info()
2364 if (close_delay != info->port.close_delay || in moxa_set_serial_info()
2365 ss->type != info->type || in moxa_set_serial_info()
2366 ((ss->flags & ~ASYNC_USR_MASK) != in moxa_set_serial_info()
2367 (info->port.flags & ~ASYNC_USR_MASK))) { in moxa_set_serial_info()
2368 mutex_unlock(&info->port.mutex); in moxa_set_serial_info()
2369 return -EPERM; in moxa_set_serial_info()
2372 info->port.close_delay = close_delay; in moxa_set_serial_info()
2374 MoxaSetFifo(info, ss->type == PORT_16550A); in moxa_set_serial_info()
2376 info->type = ss->type; in moxa_set_serial_info()
2378 mutex_unlock(&info->port.mutex); in moxa_set_serial_info()
2390 void __iomem *ofsAddr = port->tableAddr; in MoxaSetFifo()