Lines Matching +full:dcd +full:- +full:override

1 // SPDX-License-Identifier: GPL-1.0+
28 * DBGINFO information - most verbose output
130 MODULE_PARM_DESC(ttymajor, "TTY major device number override: 0=auto assigned");
146 #define dev_to_port(D) (dev_to_hdlc(D)->priv)
497 printk("%s %s data:\n",info->device_name, label); in trace_block()
512 count -= linecount; in trace_block()
523 printk("tbuf_current=%d\n", info->tbuf_current); in dump_tbufs()
524 for (i=0 ; i < info->tbuf_count ; i++) { in dump_tbufs()
526 i, le16_to_cpu(info->tbufs[i].count), le16_to_cpu(info->tbufs[i].status)); in dump_tbufs()
537 printk("rbuf_current=%d\n", info->rbuf_current); in dump_rbufs()
538 for (i=0 ; i < info->rbuf_count ; i++) { in dump_rbufs()
540 i, le16_to_cpu(info->rbufs[i].count), le16_to_cpu(info->rbufs[i].status)); in dump_rbufs()
567 * ldisc_receive_buf - pass receive data to line discipline
577 if (ld->ops->receive_buf) in ldisc_receive_buf()
578 ld->ops->receive_buf(tty, data, flags, count); in ldisc_receive_buf()
591 line = tty->index; in open()
594 return -ENODEV; in open()
598 while(info && info->line != line) in open()
599 info = info->next_device; in open()
600 if (sanity_check(info, tty->name, "open")) in open()
601 return -ENODEV; in open()
602 if (info->init_error) { in open()
603 DBGERR(("%s init error=%d\n", info->device_name, info->init_error)); in open()
604 return -ENODEV; in open()
607 tty->driver_data = info; in open()
608 info->port.tty = tty; in open()
610 DBGINFO(("%s open, old ref count = %d\n", info->device_name, info->port.count)); in open()
612 mutex_lock(&info->port.mutex); in open()
614 spin_lock_irqsave(&info->netlock, flags); in open()
615 if (info->netcount) { in open()
616 retval = -EBUSY; in open()
617 spin_unlock_irqrestore(&info->netlock, flags); in open()
618 mutex_unlock(&info->port.mutex); in open()
621 info->port.count++; in open()
622 spin_unlock_irqrestore(&info->netlock, flags); in open()
624 if (info->port.count == 1) { in open()
628 mutex_unlock(&info->port.mutex); in open()
632 mutex_unlock(&info->port.mutex); in open()
635 DBGINFO(("%s block_til_ready rc=%d\n", info->device_name, retval)); in open()
643 if (tty->count == 1) in open()
644 info->port.tty = NULL; /* tty layer will release tty struct */ in open()
645 if(info->port.count) in open()
646 info->port.count--; in open()
649 DBGINFO(("%s open rc=%d\n", info->device_name, retval)); in open()
655 struct slgt_info *info = tty->driver_data; in close()
657 if (sanity_check(info, tty->name, "close")) in close()
659 DBGINFO(("%s close entry, count=%d\n", info->device_name, info->port.count)); in close()
661 if (tty_port_close_start(&info->port, tty, filp) == 0) in close()
664 mutex_lock(&info->port.mutex); in close()
665 if (tty_port_initialized(&info->port)) in close()
666 wait_until_sent(tty, info->timeout); in close()
671 mutex_unlock(&info->port.mutex); in close()
673 tty_port_close_end(&info->port, tty); in close()
674 info->port.tty = NULL; in close()
676 DBGINFO(("%s close exit, count=%d\n", tty->driver->name, info->port.count)); in close()
681 struct slgt_info *info = tty->driver_data; in hangup()
684 if (sanity_check(info, tty->name, "hangup")) in hangup()
686 DBGINFO(("%s hangup\n", info->device_name)); in hangup()
690 mutex_lock(&info->port.mutex); in hangup()
693 spin_lock_irqsave(&info->port.lock, flags); in hangup()
694 info->port.count = 0; in hangup()
695 info->port.tty = NULL; in hangup()
696 spin_unlock_irqrestore(&info->port.lock, flags); in hangup()
697 tty_port_set_active(&info->port, 0); in hangup()
698 mutex_unlock(&info->port.mutex); in hangup()
700 wake_up_interruptible(&info->port.open_wait); in hangup()
706 struct slgt_info *info = tty->driver_data; in set_termios()
709 DBGINFO(("%s set_termios\n", tty->driver->name)); in set_termios()
714 if ((old_termios->c_cflag & CBAUD) && !C_BAUD(tty)) { in set_termios()
715 info->signals &= ~(SerialSignal_RTS | SerialSignal_DTR); in set_termios()
716 spin_lock_irqsave(&info->lock,flags); in set_termios()
718 spin_unlock_irqrestore(&info->lock,flags); in set_termios()
722 if (!(old_termios->c_cflag & CBAUD) && C_BAUD(tty)) { in set_termios()
723 info->signals |= SerialSignal_DTR; in set_termios()
725 info->signals |= SerialSignal_RTS; in set_termios()
726 spin_lock_irqsave(&info->lock,flags); in set_termios()
728 spin_unlock_irqrestore(&info->lock,flags); in set_termios()
732 if ((old_termios->c_cflag & CRTSCTS) && !C_CRTSCTS(tty)) { in set_termios()
733 tty->hw_stopped = 0; in set_termios()
744 if (info->params.mode == MGSL_MODE_HDLC) { in update_tx_timer()
746 mod_timer(&info->tx_timer, jiffies + msecs_to_jiffies(timeout)); in update_tx_timer()
754 struct slgt_info *info = tty->driver_data; in write()
757 if (sanity_check(info, tty->name, "write")) in write()
758 return -EIO; in write()
760 DBGINFO(("%s write count=%d\n", info->device_name, count)); in write()
762 if (!info->tx_buf || (count > info->max_frame_size)) in write()
763 return -EIO; in write()
765 if (!count || tty->flow.stopped || tty->hw_stopped) in write()
768 spin_lock_irqsave(&info->lock, flags); in write()
770 if (info->tx_count) { in write()
772 if (!tx_load(info, info->tx_buf, info->tx_count)) in write()
774 info->tx_count = 0; in write()
781 spin_unlock_irqrestore(&info->lock, flags); in write()
782 DBGINFO(("%s write rc=%d\n", info->device_name, ret)); in write()
788 struct slgt_info *info = tty->driver_data; in put_char()
792 if (sanity_check(info, tty->name, "put_char")) in put_char()
794 DBGINFO(("%s put_char(%d)\n", info->device_name, ch)); in put_char()
795 if (!info->tx_buf) in put_char()
797 spin_lock_irqsave(&info->lock,flags); in put_char()
798 if (info->tx_count < info->max_frame_size) { in put_char()
799 info->tx_buf[info->tx_count++] = ch; in put_char()
802 spin_unlock_irqrestore(&info->lock,flags); in put_char()
808 struct slgt_info *info = tty->driver_data; in send_xchar()
811 if (sanity_check(info, tty->name, "send_xchar")) in send_xchar()
813 DBGINFO(("%s send_xchar(%d)\n", info->device_name, ch)); in send_xchar()
814 info->x_char = ch; in send_xchar()
816 spin_lock_irqsave(&info->lock,flags); in send_xchar()
817 if (!info->tx_enabled) in send_xchar()
819 spin_unlock_irqrestore(&info->lock,flags); in send_xchar()
825 struct slgt_info *info = tty->driver_data; in wait_until_sent()
830 if (sanity_check(info, tty->name, "wait_until_sent")) in wait_until_sent()
832 DBGINFO(("%s wait_until_sent entry\n", info->device_name)); in wait_until_sent()
833 if (!tty_port_initialized(&info->port)) in wait_until_sent()
841 * Note: use tight timings here to satisfy the NIST-PCTS. in wait_until_sent()
844 if (info->params.data_rate) { in wait_until_sent()
845 char_time = info->timeout/(32 * 5); in wait_until_sent()
854 while (info->tx_active) { in wait_until_sent()
862 DBGINFO(("%s wait_until_sent exit\n", info->device_name)); in wait_until_sent()
867 struct slgt_info *info = tty->driver_data; in write_room()
870 if (sanity_check(info, tty->name, "write_room")) in write_room()
872 ret = (info->tx_active) ? 0 : HDLC_MAX_FRAME_SIZE; in write_room()
873 DBGINFO(("%s write_room=%u\n", info->device_name, ret)); in write_room()
879 struct slgt_info *info = tty->driver_data; in flush_chars()
882 if (sanity_check(info, tty->name, "flush_chars")) in flush_chars()
884 DBGINFO(("%s flush_chars entry tx_count=%d\n", info->device_name, info->tx_count)); in flush_chars()
886 if (info->tx_count <= 0 || tty->flow.stopped || in flush_chars()
887 tty->hw_stopped || !info->tx_buf) in flush_chars()
890 DBGINFO(("%s flush_chars start transmit\n", info->device_name)); in flush_chars()
892 spin_lock_irqsave(&info->lock,flags); in flush_chars()
893 if (info->tx_count && tx_load(info, info->tx_buf, info->tx_count)) in flush_chars()
894 info->tx_count = 0; in flush_chars()
895 spin_unlock_irqrestore(&info->lock,flags); in flush_chars()
900 struct slgt_info *info = tty->driver_data; in flush_buffer()
903 if (sanity_check(info, tty->name, "flush_buffer")) in flush_buffer()
905 DBGINFO(("%s flush_buffer\n", info->device_name)); in flush_buffer()
907 spin_lock_irqsave(&info->lock, flags); in flush_buffer()
908 info->tx_count = 0; in flush_buffer()
909 spin_unlock_irqrestore(&info->lock, flags); in flush_buffer()
919 struct slgt_info *info = tty->driver_data; in tx_hold()
922 if (sanity_check(info, tty->name, "tx_hold")) in tx_hold()
924 DBGINFO(("%s tx_hold\n", info->device_name)); in tx_hold()
925 spin_lock_irqsave(&info->lock,flags); in tx_hold()
926 if (info->tx_enabled && info->params.mode == MGSL_MODE_ASYNC) in tx_hold()
928 spin_unlock_irqrestore(&info->lock,flags); in tx_hold()
936 struct slgt_info *info = tty->driver_data; in tx_release()
939 if (sanity_check(info, tty->name, "tx_release")) in tx_release()
941 DBGINFO(("%s tx_release\n", info->device_name)); in tx_release()
942 spin_lock_irqsave(&info->lock, flags); in tx_release()
943 if (info->tx_count && tx_load(info, info->tx_buf, info->tx_count)) in tx_release()
944 info->tx_count = 0; in tx_release()
945 spin_unlock_irqrestore(&info->lock, flags); in tx_release()
962 struct slgt_info *info = tty->driver_data; in ioctl()
966 if (sanity_check(info, tty->name, "ioctl")) in ioctl()
967 return -ENODEV; in ioctl()
968 DBGINFO(("%s ioctl() cmd=%08X\n", info->device_name, cmd)); in ioctl()
972 return -EIO; in ioctl()
995 mutex_lock(&info->port.mutex); in ioctl()
1028 ret = -ENOIOCTLCMD; in ioctl()
1030 mutex_unlock(&info->port.mutex); in ioctl()
1038 struct slgt_info *info = tty->driver_data; in get_icount()
1042 spin_lock_irqsave(&info->lock,flags); in get_icount()
1043 cnow = info->icount; in get_icount()
1044 spin_unlock_irqrestore(&info->lock,flags); in get_icount()
1046 icount->cts = cnow.cts; in get_icount()
1047 icount->dsr = cnow.dsr; in get_icount()
1048 icount->rng = cnow.rng; in get_icount()
1049 icount->dcd = cnow.dcd; in get_icount()
1050 icount->rx = cnow.rx; in get_icount()
1051 icount->tx = cnow.tx; in get_icount()
1052 icount->frame = cnow.frame; in get_icount()
1053 icount->overrun = cnow.overrun; in get_icount()
1054 icount->parity = cnow.parity; in get_icount()
1055 icount->brk = cnow.brk; in get_icount()
1056 icount->buf_overrun = cnow.buf_overrun; in get_icount()
1069 DBGINFO(("%s get_params32\n", info->device_name)); in get_params32()
1071 tmp_params.mode = (compat_ulong_t)info->params.mode; in get_params32()
1072 tmp_params.loopback = info->params.loopback; in get_params32()
1073 tmp_params.flags = info->params.flags; in get_params32()
1074 tmp_params.encoding = info->params.encoding; in get_params32()
1075 tmp_params.clock_speed = (compat_ulong_t)info->params.clock_speed; in get_params32()
1076 tmp_params.addr_filter = info->params.addr_filter; in get_params32()
1077 tmp_params.crc_type = info->params.crc_type; in get_params32()
1078 tmp_params.preamble_length = info->params.preamble_length; in get_params32()
1079 tmp_params.preamble = info->params.preamble; in get_params32()
1080 tmp_params.data_rate = (compat_ulong_t)info->params.data_rate; in get_params32()
1081 tmp_params.data_bits = info->params.data_bits; in get_params32()
1082 tmp_params.stop_bits = info->params.stop_bits; in get_params32()
1083 tmp_params.parity = info->params.parity; in get_params32()
1085 return -EFAULT; in get_params32()
1093 DBGINFO(("%s set_params32\n", info->device_name)); in set_params32()
1095 return -EFAULT; in set_params32()
1097 spin_lock(&info->lock); in set_params32()
1099 info->base_clock = tmp_params.clock_speed; in set_params32()
1101 info->params.mode = tmp_params.mode; in set_params32()
1102 info->params.loopback = tmp_params.loopback; in set_params32()
1103 info->params.flags = tmp_params.flags; in set_params32()
1104 info->params.encoding = tmp_params.encoding; in set_params32()
1105 info->params.clock_speed = tmp_params.clock_speed; in set_params32()
1106 info->params.addr_filter = tmp_params.addr_filter; in set_params32()
1107 info->params.crc_type = tmp_params.crc_type; in set_params32()
1108 info->params.preamble_length = tmp_params.preamble_length; in set_params32()
1109 info->params.preamble = tmp_params.preamble; in set_params32()
1110 info->params.data_rate = tmp_params.data_rate; in set_params32()
1111 info->params.data_bits = tmp_params.data_bits; in set_params32()
1112 info->params.stop_bits = tmp_params.stop_bits; in set_params32()
1113 info->params.parity = tmp_params.parity; in set_params32()
1115 spin_unlock(&info->lock); in set_params32()
1125 struct slgt_info *info = tty->driver_data; in slgt_compat_ioctl()
1128 if (sanity_check(info, tty->name, "compat_ioctl")) in slgt_compat_ioctl()
1129 return -ENODEV; in slgt_compat_ioctl()
1130 DBGINFO(("%s compat_ioctl() cmd=%08X\n", info->device_name, cmd)); in slgt_compat_ioctl()
1157 DBGINFO(("%s compat_ioctl() cmd=%08X rc=%d\n", info->device_name, cmd, rc)); in slgt_compat_ioctl()
1173 info->device_name, info->phys_reg_addr, in line_info()
1174 info->irq_level, info->max_frame_size); in line_info()
1177 spin_lock_irqsave(&info->lock,flags); in line_info()
1179 spin_unlock_irqrestore(&info->lock,flags); in line_info()
1183 if (info->signals & SerialSignal_RTS) in line_info()
1185 if (info->signals & SerialSignal_CTS) in line_info()
1187 if (info->signals & SerialSignal_DTR) in line_info()
1189 if (info->signals & SerialSignal_DSR) in line_info()
1191 if (info->signals & SerialSignal_DCD) in line_info()
1193 if (info->signals & SerialSignal_RI) in line_info()
1196 if (info->params.mode != MGSL_MODE_ASYNC) { in line_info()
1198 info->icount.txok, info->icount.rxok); in line_info()
1199 if (info->icount.txunder) in line_info()
1200 seq_printf(m, " txunder:%d", info->icount.txunder); in line_info()
1201 if (info->icount.txabort) in line_info()
1202 seq_printf(m, " txabort:%d", info->icount.txabort); in line_info()
1203 if (info->icount.rxshort) in line_info()
1204 seq_printf(m, " rxshort:%d", info->icount.rxshort); in line_info()
1205 if (info->icount.rxlong) in line_info()
1206 seq_printf(m, " rxlong:%d", info->icount.rxlong); in line_info()
1207 if (info->icount.rxover) in line_info()
1208 seq_printf(m, " rxover:%d", info->icount.rxover); in line_info()
1209 if (info->icount.rxcrc) in line_info()
1210 seq_printf(m, " rxcrc:%d", info->icount.rxcrc); in line_info()
1213 info->icount.tx, info->icount.rx); in line_info()
1214 if (info->icount.frame) in line_info()
1215 seq_printf(m, " fe:%d", info->icount.frame); in line_info()
1216 if (info->icount.parity) in line_info()
1217 seq_printf(m, " pe:%d", info->icount.parity); in line_info()
1218 if (info->icount.brk) in line_info()
1219 seq_printf(m, " brk:%d", info->icount.brk); in line_info()
1220 if (info->icount.overrun) in line_info()
1221 seq_printf(m, " oe:%d", info->icount.overrun); in line_info()
1228 info->tx_active,info->bh_requested,info->bh_running, in line_info()
1229 info->pending_bh); in line_info()
1243 info = info->next_device; in synclink_gt_proc_show()
1253 struct slgt_info *info = tty->driver_data; in chars_in_buffer()
1255 if (sanity_check(info, tty->name, "chars_in_buffer")) in chars_in_buffer()
1258 DBGINFO(("%s chars_in_buffer()=%u\n", info->device_name, count)); in chars_in_buffer()
1267 struct slgt_info *info = tty->driver_data; in throttle()
1270 if (sanity_check(info, tty->name, "throttle")) in throttle()
1272 DBGINFO(("%s throttle\n", info->device_name)); in throttle()
1276 spin_lock_irqsave(&info->lock,flags); in throttle()
1277 info->signals &= ~SerialSignal_RTS; in throttle()
1279 spin_unlock_irqrestore(&info->lock,flags); in throttle()
1288 struct slgt_info *info = tty->driver_data; in unthrottle()
1291 if (sanity_check(info, tty->name, "unthrottle")) in unthrottle()
1293 DBGINFO(("%s unthrottle\n", info->device_name)); in unthrottle()
1295 if (info->x_char) in unthrottle()
1296 info->x_char = 0; in unthrottle()
1301 spin_lock_irqsave(&info->lock,flags); in unthrottle()
1302 info->signals |= SerialSignal_RTS; in unthrottle()
1304 spin_unlock_irqrestore(&info->lock,flags); in unthrottle()
1310 * break_state -1=set break condition, 0=clear
1314 struct slgt_info *info = tty->driver_data; in set_break()
1318 if (sanity_check(info, tty->name, "set_break")) in set_break()
1319 return -EINVAL; in set_break()
1320 DBGINFO(("%s set_break(%d)\n", info->device_name, break_state)); in set_break()
1322 spin_lock_irqsave(&info->lock,flags); in set_break()
1324 if (break_state == -1) in set_break()
1329 spin_unlock_irqrestore(&info->lock,flags); in set_break()
1336 * hdlcdev_attach - called by generic HDLC layer when protocol selected (PPP, frame relay, etc.)
1353 if (info->port.count) in hdlcdev_attach()
1354 return -EBUSY; in hdlcdev_attach()
1356 DBGINFO(("%s hdlcdev_attach\n", info->device_name)); in hdlcdev_attach()
1365 default: return -EINVAL; in hdlcdev_attach()
1373 default: return -EINVAL; in hdlcdev_attach()
1376 info->params.encoding = new_encoding; in hdlcdev_attach()
1377 info->params.crc_type = new_crctype; in hdlcdev_attach()
1380 if (info->netcount) in hdlcdev_attach()
1387 * hdlcdev_xmit - called by generic HDLC layer to send a frame
1397 DBGINFO(("%s hdlc_xmit\n", dev->name)); in hdlcdev_xmit()
1399 if (!skb->len) in hdlcdev_xmit()
1406 dev->stats.tx_packets++; in hdlcdev_xmit()
1407 dev->stats.tx_bytes += skb->len; in hdlcdev_xmit()
1412 spin_lock_irqsave(&info->lock, flags); in hdlcdev_xmit()
1413 tx_load(info, skb->data, skb->len); in hdlcdev_xmit()
1414 spin_unlock_irqrestore(&info->lock, flags); in hdlcdev_xmit()
1423 * hdlcdev_open - called by network layer when interface enabled
1437 return -EBUSY; in hdlcdev_open()
1439 DBGINFO(("%s hdlcdev_open\n", dev->name)); in hdlcdev_open()
1447 spin_lock_irqsave(&info->netlock, flags); in hdlcdev_open()
1448 if (info->port.count != 0 || info->netcount != 0) { in hdlcdev_open()
1449 DBGINFO(("%s hdlc_open busy\n", dev->name)); in hdlcdev_open()
1450 spin_unlock_irqrestore(&info->netlock, flags); in hdlcdev_open()
1451 return -EBUSY; in hdlcdev_open()
1453 info->netcount=1; in hdlcdev_open()
1454 spin_unlock_irqrestore(&info->netlock, flags); in hdlcdev_open()
1458 spin_lock_irqsave(&info->netlock, flags); in hdlcdev_open()
1459 info->netcount=0; in hdlcdev_open()
1460 spin_unlock_irqrestore(&info->netlock, flags); in hdlcdev_open()
1465 info->signals |= SerialSignal_RTS | SerialSignal_DTR; in hdlcdev_open()
1472 /* inform generic HDLC layer of current DCD status */ in hdlcdev_open()
1473 spin_lock_irqsave(&info->lock, flags); in hdlcdev_open()
1475 spin_unlock_irqrestore(&info->lock, flags); in hdlcdev_open()
1476 if (info->signals & SerialSignal_DCD) in hdlcdev_open()
1484 * hdlcdev_close - called by network layer when interface is disabled
1496 DBGINFO(("%s hdlcdev_close\n", dev->name)); in hdlcdev_close()
1505 spin_lock_irqsave(&info->netlock, flags); in hdlcdev_close()
1506 info->netcount=0; in hdlcdev_close()
1507 spin_unlock_irqrestore(&info->netlock, flags); in hdlcdev_close()
1514 * hdlcdev_ioctl - called by network layer to process IOCTL call to network device
1525 sync_serial_settings __user *line = ifs->ifs_ifsu.sync; in hdlcdev_ioctl()
1529 DBGINFO(("%s hdlcdev_ioctl\n", dev->name)); in hdlcdev_ioctl()
1532 if (info->port.count) in hdlcdev_ioctl()
1533 return -EBUSY; in hdlcdev_ioctl()
1537 switch (ifs->type) { in hdlcdev_ioctl()
1540 ifs->type = IF_IFACE_SYNC_SERIAL; in hdlcdev_ioctl()
1541 if (ifs->size < size) { in hdlcdev_ioctl()
1542 ifs->size = size; /* data size wanted */ in hdlcdev_ioctl()
1543 return -ENOBUFS; in hdlcdev_ioctl()
1546 flags = info->params.flags & (HDLC_FLAG_RXC_RXCPIN | HDLC_FLAG_RXC_DPLL | in hdlcdev_ioctl()
1559 new_line.clock_rate = info->params.clock_speed; in hdlcdev_ioctl()
1560 new_line.loopback = info->params.loopback ? 1:0; in hdlcdev_ioctl()
1563 return -EFAULT; in hdlcdev_ioctl()
1569 return -EPERM; in hdlcdev_ioctl()
1571 return -EFAULT; in hdlcdev_ioctl()
1579 case CLOCK_DEFAULT: flags = info->params.flags & in hdlcdev_ioctl()
1584 default: return -EINVAL; in hdlcdev_ioctl()
1588 return -EINVAL; in hdlcdev_ioctl()
1590 info->params.flags &= ~(HDLC_FLAG_RXC_RXCPIN | HDLC_FLAG_RXC_DPLL | in hdlcdev_ioctl()
1594 info->params.flags |= flags; in hdlcdev_ioctl()
1596 info->params.loopback = new_line.loopback; in hdlcdev_ioctl()
1599 info->params.clock_speed = new_line.clock_rate; in hdlcdev_ioctl()
1601 info->params.clock_speed = 0; in hdlcdev_ioctl()
1604 if (info->netcount) in hdlcdev_ioctl()
1614 * hdlcdev_tx_timeout - called by network layer when transmit timeout is detected
1623 DBGINFO(("%s hdlcdev_tx_timeout\n", dev->name)); in hdlcdev_tx_timeout()
1625 dev->stats.tx_errors++; in hdlcdev_tx_timeout()
1626 dev->stats.tx_aborted_errors++; in hdlcdev_tx_timeout()
1628 spin_lock_irqsave(&info->lock,flags); in hdlcdev_tx_timeout()
1630 spin_unlock_irqrestore(&info->lock,flags); in hdlcdev_tx_timeout()
1636 * hdlcdev_tx_done - called by device driver when transmit completes
1643 if (netif_queue_stopped(info->netdev)) in hdlcdev_tx_done()
1644 netif_wake_queue(info->netdev); in hdlcdev_tx_done()
1648 * hdlcdev_rx - called by device driver when frame received
1658 struct net_device *dev = info->netdev; in hdlcdev_rx()
1660 DBGINFO(("%s hdlcdev_rx\n", dev->name)); in hdlcdev_rx()
1663 DBGERR(("%s: can't alloc skb, drop packet\n", dev->name)); in hdlcdev_rx()
1664 dev->stats.rx_dropped++; in hdlcdev_rx()
1670 skb->protocol = hdlc_type_trans(skb, dev); in hdlcdev_rx()
1672 dev->stats.rx_packets++; in hdlcdev_rx()
1673 dev->stats.rx_bytes += size; in hdlcdev_rx()
1687 * hdlcdev_init - called by device driver when adding device instance
1704 printk(KERN_ERR "%s hdlc device alloc failure\n", info->device_name); in hdlcdev_init()
1705 return -ENOMEM; in hdlcdev_init()
1709 dev->mem_start = info->phys_reg_addr; in hdlcdev_init()
1710 dev->mem_end = info->phys_reg_addr + SLGT_REG_SIZE - 1; in hdlcdev_init()
1711 dev->irq = info->irq_level; in hdlcdev_init()
1714 dev->netdev_ops = &hdlcdev_ops; in hdlcdev_init()
1715 dev->watchdog_timeo = 10 * HZ; in hdlcdev_init()
1716 dev->tx_queue_len = 50; in hdlcdev_init()
1720 hdlc->attach = hdlcdev_attach; in hdlcdev_init()
1721 hdlc->xmit = hdlcdev_xmit; in hdlcdev_init()
1731 info->netdev = dev; in hdlcdev_init()
1736 * hdlcdev_exit - called by device driver when removing device instance
1743 if (!info->netdev) in hdlcdev_exit()
1745 unregister_hdlc_device(info->netdev); in hdlcdev_exit()
1746 free_netdev(info->netdev); in hdlcdev_exit()
1747 info->netdev = NULL; in hdlcdev_exit()
1757 struct mgsl_icount *icount = &info->icount; in rx_async()
1761 struct slgt_desc *bufs = info->rbufs; in rx_async()
1767 start = end = info->rbuf_current; in rx_async()
1770 count = desc_count(bufs[end]) - info->rbuf_index; in rx_async()
1771 p = bufs[end].buf + info->rbuf_index; in rx_async()
1773 DBGISR(("%s rx_async count=%d\n", info->device_name, count)); in rx_async()
1778 icount->rx++; in rx_async()
1785 icount->parity++; in rx_async()
1787 icount->frame++; in rx_async()
1789 if (status & info->ignore_status_mask) in rx_async()
1796 tty_insert_flip_char(&info->port, ch, stat); in rx_async()
1802 info->rbuf_index += i; in rx_async()
1803 mod_timer(&info->rx_timer, jiffies + 1); in rx_async()
1807 info->rbuf_index = 0; in rx_async()
1810 if (++end == info->rbuf_count) in rx_async()
1819 tty_flip_buffer_push(&info->port); in rx_async()
1830 spin_lock_irqsave(&info->lock,flags); in bh_action()
1832 if (info->pending_bh & BH_RECEIVE) { in bh_action()
1833 info->pending_bh &= ~BH_RECEIVE; in bh_action()
1835 } else if (info->pending_bh & BH_TRANSMIT) { in bh_action()
1836 info->pending_bh &= ~BH_TRANSMIT; in bh_action()
1838 } else if (info->pending_bh & BH_STATUS) { in bh_action()
1839 info->pending_bh &= ~BH_STATUS; in bh_action()
1843 info->bh_running = false; in bh_action()
1844 info->bh_requested = false; in bh_action()
1848 spin_unlock_irqrestore(&info->lock,flags); in bh_action()
1861 info->bh_running = true; in bh_handler()
1866 DBGBH(("%s bh receive\n", info->device_name)); in bh_handler()
1867 switch(info->params.mode) { in bh_handler()
1882 if (info->rx_restart) in bh_handler()
1889 DBGBH(("%s bh status\n", info->device_name)); in bh_handler()
1890 info->ri_chkcount = 0; in bh_handler()
1891 info->dsr_chkcount = 0; in bh_handler()
1892 info->dcd_chkcount = 0; in bh_handler()
1893 info->cts_chkcount = 0; in bh_handler()
1896 DBGBH(("%s unknown action\n", info->device_name)); in bh_handler()
1900 DBGBH(("%s bh_handler exit\n", info->device_name)); in bh_handler()
1905 struct tty_struct *tty = info->port.tty; in bh_transmit()
1907 DBGBH(("%s bh_transmit\n", info->device_name)); in bh_transmit()
1915 info->signals |= SerialSignal_DSR; in dsr_change()
1916 info->input_signal_events.dsr_up++; in dsr_change()
1918 info->signals &= ~SerialSignal_DSR; in dsr_change()
1919 info->input_signal_events.dsr_down++; in dsr_change()
1921 DBGISR(("dsr_change %s signals=%04X\n", info->device_name, info->signals)); in dsr_change()
1922 if ((info->dsr_chkcount)++ == IO_PIN_SHUTDOWN_LIMIT) { in dsr_change()
1926 info->icount.dsr++; in dsr_change()
1927 wake_up_interruptible(&info->status_event_wait_q); in dsr_change()
1928 wake_up_interruptible(&info->event_wait_q); in dsr_change()
1929 info->pending_bh |= BH_STATUS; in dsr_change()
1935 info->signals |= SerialSignal_CTS; in cts_change()
1936 info->input_signal_events.cts_up++; in cts_change()
1938 info->signals &= ~SerialSignal_CTS; in cts_change()
1939 info->input_signal_events.cts_down++; in cts_change()
1941 DBGISR(("cts_change %s signals=%04X\n", info->device_name, info->signals)); in cts_change()
1942 if ((info->cts_chkcount)++ == IO_PIN_SHUTDOWN_LIMIT) { in cts_change()
1946 info->icount.cts++; in cts_change()
1947 wake_up_interruptible(&info->status_event_wait_q); in cts_change()
1948 wake_up_interruptible(&info->event_wait_q); in cts_change()
1949 info->pending_bh |= BH_STATUS; in cts_change()
1951 if (tty_port_cts_enabled(&info->port)) { in cts_change()
1952 if (info->port.tty) { in cts_change()
1953 if (info->port.tty->hw_stopped) { in cts_change()
1954 if (info->signals & SerialSignal_CTS) { in cts_change()
1955 info->port.tty->hw_stopped = 0; in cts_change()
1956 info->pending_bh |= BH_TRANSMIT; in cts_change()
1960 if (!(info->signals & SerialSignal_CTS)) in cts_change()
1961 info->port.tty->hw_stopped = 1; in cts_change()
1970 info->signals |= SerialSignal_DCD; in dcd_change()
1971 info->input_signal_events.dcd_up++; in dcd_change()
1973 info->signals &= ~SerialSignal_DCD; in dcd_change()
1974 info->input_signal_events.dcd_down++; in dcd_change()
1976 DBGISR(("dcd_change %s signals=%04X\n", info->device_name, info->signals)); in dcd_change()
1977 if ((info->dcd_chkcount)++ == IO_PIN_SHUTDOWN_LIMIT) { in dcd_change()
1981 info->icount.dcd++; in dcd_change()
1983 if (info->netcount) { in dcd_change()
1984 if (info->signals & SerialSignal_DCD) in dcd_change()
1985 netif_carrier_on(info->netdev); in dcd_change()
1987 netif_carrier_off(info->netdev); in dcd_change()
1990 wake_up_interruptible(&info->status_event_wait_q); in dcd_change()
1991 wake_up_interruptible(&info->event_wait_q); in dcd_change()
1992 info->pending_bh |= BH_STATUS; in dcd_change()
1994 if (tty_port_check_carrier(&info->port)) { in dcd_change()
1995 if (info->signals & SerialSignal_DCD) in dcd_change()
1996 wake_up_interruptible(&info->port.open_wait); in dcd_change()
1998 if (info->port.tty) in dcd_change()
1999 tty_hangup(info->port.tty); in dcd_change()
2007 info->signals |= SerialSignal_RI; in ri_change()
2008 info->input_signal_events.ri_up++; in ri_change()
2010 info->signals &= ~SerialSignal_RI; in ri_change()
2011 info->input_signal_events.ri_down++; in ri_change()
2013 DBGISR(("ri_change %s signals=%04X\n", info->device_name, info->signals)); in ri_change()
2014 if ((info->ri_chkcount)++ == IO_PIN_SHUTDOWN_LIMIT) { in ri_change()
2018 info->icount.rng++; in ri_change()
2019 wake_up_interruptible(&info->status_event_wait_q); in ri_change()
2020 wake_up_interruptible(&info->event_wait_q); in ri_change()
2021 info->pending_bh |= BH_STATUS; in ri_change()
2026 unsigned int count = info->rbuf_fill_count; in isr_rxdata()
2027 unsigned int i = info->rbuf_fill_index; in isr_rxdata()
2032 DBGISR(("isr_rxdata %s RDR=%04X\n", info->device_name, reg)); in isr_rxdata()
2033 if (desc_complete(info->rbufs[i])) { in isr_rxdata()
2036 info->rx_restart = true; in isr_rxdata()
2039 info->rbufs[i].buf[count++] = (unsigned char)reg; in isr_rxdata()
2041 if (info->params.mode == MGSL_MODE_ASYNC) in isr_rxdata()
2042 info->rbufs[i].buf[count++] = (unsigned char)(reg >> 8); in isr_rxdata()
2043 if (count == info->rbuf_fill_level || (reg & BIT10)) { in isr_rxdata()
2045 set_desc_count(info->rbufs[i], count); in isr_rxdata()
2046 set_desc_status(info->rbufs[i], BIT15 | (reg >> 8)); in isr_rxdata()
2047 info->rbuf_fill_count = count = 0; in isr_rxdata()
2048 if (++i == info->rbuf_count) in isr_rxdata()
2050 info->pending_bh |= BH_RECEIVE; in isr_rxdata()
2054 info->rbuf_fill_index = i; in isr_rxdata()
2055 info->rbuf_fill_count = count; in isr_rxdata()
2062 DBGISR(("%s isr_serial status=%04X\n", info->device_name, status)); in isr_serial()
2066 info->irq_occurred = true; in isr_serial()
2068 if (info->params.mode == MGSL_MODE_ASYNC) { in isr_serial()
2070 if (info->tx_active) in isr_serial()
2073 if (info->rx_pio && (status & IRQ_RXDATA)) in isr_serial()
2076 info->icount.brk++; in isr_serial()
2078 if (info->port.tty) { in isr_serial()
2079 if (!(status & info->ignore_status_mask)) { in isr_serial()
2080 if (info->read_status_mask & MASK_BREAK) { in isr_serial()
2081 tty_insert_flip_char(&info->port, 0, TTY_BREAK); in isr_serial()
2082 if (info->port.flags & ASYNC_SAK) in isr_serial()
2083 do_SAK(info->port.tty); in isr_serial()
2091 if (info->rx_pio && (status & IRQ_RXDATA)) in isr_serial()
2095 info->icount.rxidle++; in isr_serial()
2097 info->icount.exithunt++; in isr_serial()
2098 wake_up_interruptible(&info->event_wait_q); in isr_serial()
2119 DBGISR(("%s isr_rdma status=%08x\n", info->device_name, status)); in isr_rdma()
2135 DBGISR(("%s isr_rdma rx_restart=1\n", info->device_name)); in isr_rdma()
2136 info->rx_restart = true; in isr_rdma()
2138 info->pending_bh |= BH_RECEIVE; in isr_rdma()
2145 DBGISR(("%s isr_tdma status=%08x\n", info->device_name, status)); in isr_tdma()
2162 info->pending_bh |= BH_TRANSMIT; in isr_tdma()
2169 * if there are unsent buffers then info->tbuf_start
2174 unsigned int i = info->tbuf_current; in unsent_tbufs()
2184 i--; in unsent_tbufs()
2186 i = info->tbuf_count - 1; in unsent_tbufs()
2187 if (!desc_count(info->tbufs[i])) in unsent_tbufs()
2189 info->tbuf_start = i; in unsent_tbufs()
2191 } while (i != info->tbuf_current); in unsent_tbufs()
2198 DBGISR(("%s txeom status=%04x\n", info->device_name, status)); in isr_txeom()
2208 if (info->tx_active) { in isr_txeom()
2209 if (info->params.mode != MGSL_MODE_ASYNC) { in isr_txeom()
2211 info->icount.txunder++; in isr_txeom()
2213 info->icount.txok++; in isr_txeom()
2221 info->tx_active = false; in isr_txeom()
2223 del_timer(&info->tx_timer); in isr_txeom()
2225 if (info->params.mode != MGSL_MODE_ASYNC && info->drop_rts_on_tx_done) { in isr_txeom()
2226 info->signals &= ~SerialSignal_RTS; in isr_txeom()
2227 info->drop_rts_on_tx_done = false; in isr_txeom()
2232 if (info->netcount) in isr_txeom()
2237 if (info->port.tty && (info->port.tty->flow.stopped || info->port.tty->hw_stopped)) { in isr_txeom()
2241 info->pending_bh |= BH_TRANSMIT; in isr_txeom()
2251 for (w = info->gpio_wait_q, prev = NULL ; w != NULL ; w = w->next) { in isr_gpio()
2252 if (w->data & changed) { in isr_gpio()
2253 w->data = state; in isr_gpio()
2254 wake_up_interruptible(&w->q); in isr_gpio()
2256 prev->next = w->next; in isr_gpio()
2258 info->gpio_wait_q = w->next; in isr_gpio()
2275 DBGISR(("slgt_interrupt irq=%d entry\n", info->irq_level)); in slgt_interrupt()
2278 DBGISR(("%s gsr=%08x\n", info->device_name, gsr)); in slgt_interrupt()
2279 info->irq_occurred = true; in slgt_interrupt()
2280 for(i=0; i < info->port_count ; i++) { in slgt_interrupt()
2281 if (info->port_array[i] == NULL) in slgt_interrupt()
2283 spin_lock(&info->port_array[i]->lock); in slgt_interrupt()
2285 isr_serial(info->port_array[i]); in slgt_interrupt()
2287 isr_rdma(info->port_array[i]); in slgt_interrupt()
2289 isr_tdma(info->port_array[i]); in slgt_interrupt()
2290 spin_unlock(&info->port_array[i]->lock); in slgt_interrupt()
2294 if (info->gpio_present) { in slgt_interrupt()
2297 spin_lock(&info->lock); in slgt_interrupt()
2299 DBGISR(("%s iosr=%08x\n", info->device_name, changed)); in slgt_interrupt()
2304 for (i=0 ; i < info->port_count ; i++) { in slgt_interrupt()
2305 if (info->port_array[i] != NULL) in slgt_interrupt()
2306 isr_gpio(info->port_array[i], changed, state); in slgt_interrupt()
2309 spin_unlock(&info->lock); in slgt_interrupt()
2312 for(i=0; i < info->port_count ; i++) { in slgt_interrupt()
2313 struct slgt_info *port = info->port_array[i]; in slgt_interrupt()
2316 spin_lock(&port->lock); in slgt_interrupt()
2317 if ((port->port.count || port->netcount) && in slgt_interrupt()
2318 port->pending_bh && !port->bh_running && in slgt_interrupt()
2319 !port->bh_requested) { in slgt_interrupt()
2320 DBGISR(("%s bh queued\n", port->device_name)); in slgt_interrupt()
2321 schedule_work(&port->task); in slgt_interrupt()
2322 port->bh_requested = true; in slgt_interrupt()
2324 spin_unlock(&port->lock); in slgt_interrupt()
2327 DBGISR(("slgt_interrupt irq=%d exit\n", info->irq_level)); in slgt_interrupt()
2333 DBGINFO(("%s startup\n", info->device_name)); in startup()
2335 if (tty_port_initialized(&info->port)) in startup()
2338 if (!info->tx_buf) { in startup()
2339 info->tx_buf = kmalloc(info->max_frame_size, GFP_KERNEL); in startup()
2340 if (!info->tx_buf) { in startup()
2341 DBGERR(("%s can't allocate tx buffer\n", info->device_name)); in startup()
2342 return -ENOMEM; in startup()
2346 info->pending_bh = 0; in startup()
2348 memset(&info->icount, 0, sizeof(info->icount)); in startup()
2353 if (info->port.tty) in startup()
2354 clear_bit(TTY_IO_ERROR, &info->port.tty->flags); in startup()
2356 tty_port_set_initialized(&info->port, 1); in startup()
2368 if (!tty_port_initialized(&info->port)) in shutdown()
2371 DBGINFO(("%s shutdown\n", info->device_name)); in shutdown()
2375 wake_up_interruptible(&info->status_event_wait_q); in shutdown()
2376 wake_up_interruptible(&info->event_wait_q); in shutdown()
2378 del_timer_sync(&info->tx_timer); in shutdown()
2379 del_timer_sync(&info->rx_timer); in shutdown()
2381 kfree(info->tx_buf); in shutdown()
2382 info->tx_buf = NULL; in shutdown()
2384 spin_lock_irqsave(&info->lock,flags); in shutdown()
2391 if (!info->port.tty || info->port.tty->termios.c_cflag & HUPCL) { in shutdown()
2392 info->signals &= ~(SerialSignal_RTS | SerialSignal_DTR); in shutdown()
2396 flush_cond_wait(&info->gpio_wait_q); in shutdown()
2398 spin_unlock_irqrestore(&info->lock,flags); in shutdown()
2400 if (info->port.tty) in shutdown()
2401 set_bit(TTY_IO_ERROR, &info->port.tty->flags); in shutdown()
2403 tty_port_set_initialized(&info->port, 0); in shutdown()
2410 spin_lock_irqsave(&info->lock,flags); in program_hw()
2415 if (info->params.mode != MGSL_MODE_ASYNC || in program_hw()
2416 info->netcount) in program_hw()
2423 info->dcd_chkcount = 0; in program_hw()
2424 info->cts_chkcount = 0; in program_hw()
2425 info->ri_chkcount = 0; in program_hw()
2426 info->dsr_chkcount = 0; in program_hw()
2431 if (info->netcount || in program_hw()
2432 (info->port.tty && info->port.tty->termios.c_cflag & CREAD)) in program_hw()
2435 spin_unlock_irqrestore(&info->lock,flags); in program_hw()
2446 if (!info->port.tty) in change_params()
2448 DBGINFO(("%s change_params\n", info->device_name)); in change_params()
2450 cflag = info->port.tty->termios.c_cflag; in change_params()
2455 info->signals |= SerialSignal_RTS | SerialSignal_DTR; in change_params()
2457 info->signals &= ~(SerialSignal_RTS | SerialSignal_DTR); in change_params()
2461 info->params.data_bits = tty_get_char_size(cflag); in change_params()
2462 info->params.stop_bits = (cflag & CSTOPB) ? 2 : 1; in change_params()
2465 info->params.parity = (cflag & PARODD) ? ASYNC_PARITY_ODD : ASYNC_PARITY_EVEN; in change_params()
2467 info->params.parity = ASYNC_PARITY_NONE; in change_params()
2472 bits_per_char = info->params.data_bits + in change_params()
2473 info->params.stop_bits + 1; in change_params()
2475 info->params.data_rate = tty_get_baud_rate(info->port.tty); in change_params()
2477 if (info->params.data_rate) { in change_params()
2478 info->timeout = (32*HZ*bits_per_char) / in change_params()
2479 info->params.data_rate; in change_params()
2481 info->timeout += HZ/50; /* Add .02 seconds of slop */ in change_params()
2483 tty_port_set_cts_flow(&info->port, cflag & CRTSCTS); in change_params()
2484 tty_port_set_check_carrier(&info->port, ~cflag & CLOCAL); in change_params()
2488 info->read_status_mask = IRQ_RXOVER; in change_params()
2489 if (I_INPCK(info->port.tty)) in change_params()
2490 info->read_status_mask |= MASK_PARITY | MASK_FRAMING; in change_params()
2491 if (I_BRKINT(info->port.tty) || I_PARMRK(info->port.tty)) in change_params()
2492 info->read_status_mask |= MASK_BREAK; in change_params()
2493 if (I_IGNPAR(info->port.tty)) in change_params()
2494 info->ignore_status_mask |= MASK_PARITY | MASK_FRAMING; in change_params()
2495 if (I_IGNBRK(info->port.tty)) { in change_params()
2496 info->ignore_status_mask |= MASK_BREAK; in change_params()
2500 if (I_IGNPAR(info->port.tty)) in change_params()
2501 info->ignore_status_mask |= MASK_OVERRUN; in change_params()
2509 DBGINFO(("%s get_stats\n", info->device_name)); in get_stats()
2511 memset(&info->icount, 0, sizeof(info->icount)); in get_stats()
2513 if (copy_to_user(user_icount, &info->icount, sizeof(struct mgsl_icount))) in get_stats()
2514 return -EFAULT; in get_stats()
2521 DBGINFO(("%s get_params\n", info->device_name)); in get_params()
2522 if (copy_to_user(user_params, &info->params, sizeof(MGSL_PARAMS))) in get_params()
2523 return -EFAULT; in get_params()
2532 DBGINFO(("%s set_params\n", info->device_name)); in set_params()
2534 return -EFAULT; in set_params()
2536 spin_lock_irqsave(&info->lock, flags); in set_params()
2538 info->base_clock = tmp_params.clock_speed; in set_params()
2540 memcpy(&info->params, &tmp_params, sizeof(MGSL_PARAMS)); in set_params()
2541 spin_unlock_irqrestore(&info->lock, flags); in set_params()
2550 DBGINFO(("%s get_txidle=%d\n", info->device_name, info->idle_mode)); in get_txidle()
2551 if (put_user(info->idle_mode, idle_mode)) in get_txidle()
2552 return -EFAULT; in get_txidle()
2559 DBGINFO(("%s set_txidle(%d)\n", info->device_name, idle_mode)); in set_txidle()
2560 spin_lock_irqsave(&info->lock,flags); in set_txidle()
2561 info->idle_mode = idle_mode; in set_txidle()
2562 if (info->params.mode != MGSL_MODE_ASYNC) in set_txidle()
2564 spin_unlock_irqrestore(&info->lock,flags); in set_txidle()
2571 DBGINFO(("%s tx_enable(%d)\n", info->device_name, enable)); in tx_enable()
2572 spin_lock_irqsave(&info->lock,flags); in tx_enable()
2574 if (!info->tx_enabled) in tx_enable()
2577 if (info->tx_enabled) in tx_enable()
2580 spin_unlock_irqrestore(&info->lock,flags); in tx_enable()
2590 DBGINFO(("%s tx_abort\n", info->device_name)); in tx_abort()
2591 spin_lock_irqsave(&info->lock,flags); in tx_abort()
2593 spin_unlock_irqrestore(&info->lock,flags); in tx_abort()
2601 DBGINFO(("%s rx_enable(%08x)\n", info->device_name, enable)); in rx_enable()
2602 spin_lock_irqsave(&info->lock,flags); in rx_enable()
2611 spin_unlock_irqrestore(&info->lock, flags); in rx_enable()
2612 return -EINVAL; in rx_enable()
2614 info->rbuf_fill_level = rbuf_fill_level; in rx_enable()
2616 info->rx_pio = 1; /* PIO mode */ in rx_enable()
2618 info->rx_pio = 0; /* DMA mode */ in rx_enable()
2630 if (!info->rx_enabled) in rx_enable()
2637 if (info->rx_enabled) in rx_enable()
2640 spin_unlock_irqrestore(&info->lock,flags); in rx_enable()
2659 return -EFAULT; in wait_mgsl_event()
2661 DBGINFO(("%s wait_mgsl_event(%d)\n", info->device_name, mask)); in wait_mgsl_event()
2663 spin_lock_irqsave(&info->lock,flags); in wait_mgsl_event()
2667 s = info->signals; in wait_mgsl_event()
2675 spin_unlock_irqrestore(&info->lock,flags); in wait_mgsl_event()
2680 cprev = info->icount; in wait_mgsl_event()
2681 oldsigs = info->input_signal_events; in wait_mgsl_event()
2691 add_wait_queue(&info->event_wait_q, &wait); in wait_mgsl_event()
2693 spin_unlock_irqrestore(&info->lock,flags); in wait_mgsl_event()
2698 rc = -ERESTARTSYS; in wait_mgsl_event()
2703 spin_lock_irqsave(&info->lock,flags); in wait_mgsl_event()
2704 cnow = info->icount; in wait_mgsl_event()
2705 newsigs = info->input_signal_events; in wait_mgsl_event()
2707 spin_unlock_irqrestore(&info->lock,flags); in wait_mgsl_event()
2720 rc = -EIO; in wait_mgsl_event()
2742 remove_wait_queue(&info->event_wait_q, &wait); in wait_mgsl_event()
2747 spin_lock_irqsave(&info->lock,flags); in wait_mgsl_event()
2748 if (!waitqueue_active(&info->event_wait_q)) { in wait_mgsl_event()
2753 spin_unlock_irqrestore(&info->lock,flags); in wait_mgsl_event()
2763 DBGINFO(("%s get_interface=%x\n", info->device_name, info->if_mode)); in get_interface()
2764 if (put_user(info->if_mode, if_mode)) in get_interface()
2765 return -EFAULT; in get_interface()
2774 DBGINFO(("%s set_interface=%x)\n", info->device_name, if_mode)); in set_interface()
2775 spin_lock_irqsave(&info->lock,flags); in set_interface()
2776 info->if_mode = if_mode; in set_interface()
2782 if (info->if_mode & MGSL_INTERFACE_RTS_EN) in set_interface()
2788 spin_unlock_irqrestore(&info->lock,flags); in set_interface()
2794 DBGINFO(("%s get_xsync=%x\n", info->device_name, info->xsync)); in get_xsync()
2795 if (put_user(info->xsync, xsync)) in get_xsync()
2796 return -EFAULT; in get_xsync()
2810 DBGINFO(("%s set_xsync=%x)\n", info->device_name, xsync)); in set_xsync()
2811 spin_lock_irqsave(&info->lock, flags); in set_xsync()
2812 info->xsync = xsync; in set_xsync()
2814 spin_unlock_irqrestore(&info->lock, flags); in set_xsync()
2820 DBGINFO(("%s get_xctrl=%x\n", info->device_name, info->xctrl)); in get_xctrl()
2821 if (put_user(info->xctrl, xctrl)) in get_xctrl()
2822 return -EFAULT; in get_xctrl()
2847 DBGINFO(("%s set_xctrl=%x)\n", info->device_name, xctrl)); in set_xctrl()
2848 spin_lock_irqsave(&info->lock, flags); in set_xctrl()
2849 info->xctrl = xctrl; in set_xctrl()
2851 spin_unlock_irqrestore(&info->lock, flags); in set_xctrl()
2870 if (!info->gpio_present) in set_gpio()
2871 return -EINVAL; in set_gpio()
2873 return -EFAULT; in set_gpio()
2875 info->device_name, gpio.state, gpio.smask, in set_gpio()
2878 spin_lock_irqsave(&info->port_array[0]->lock, flags); in set_gpio()
2891 spin_unlock_irqrestore(&info->port_array[0]->lock, flags); in set_gpio()
2902 if (!info->gpio_present) in get_gpio()
2903 return -EINVAL; in get_gpio()
2909 return -EFAULT; in get_gpio()
2911 info->device_name, gpio.state, gpio.dir)); in get_gpio()
2920 init_waitqueue_head(&w->q); in init_cond_wait()
2921 init_waitqueue_entry(&w->wait, current); in init_cond_wait()
2922 w->data = data; in init_cond_wait()
2928 add_wait_queue(&w->q, &w->wait); in add_cond_wait()
2929 w->next = *head; in add_cond_wait()
2936 remove_wait_queue(&cw->q, &cw->wait); in remove_cond_wait()
2938 for (w = *head, prev = NULL ; w != NULL ; prev = w, w = w->next) { in remove_cond_wait()
2941 prev->next = w->next; in remove_cond_wait()
2943 *head = w->next; in remove_cond_wait()
2952 wake_up_interruptible(&(*head)->q); in flush_cond_wait()
2953 *head = (*head)->next; in flush_cond_wait()
2961 * state - bit indicates target pin state
2962 * smask - set bit indicates watched pin
2965 * state. When 0 (no error) is returned, user_gpio->state is set to the
2981 if (!info->gpio_present) in wait_gpio()
2982 return -EINVAL; in wait_gpio()
2984 return -EFAULT; in wait_gpio()
2986 info->device_name, gpio.state, gpio.smask)); in wait_gpio()
2989 return -EINVAL; in wait_gpio()
2992 spin_lock_irqsave(&info->port_array[0]->lock, flags); in wait_gpio()
3003 add_cond_wait(&info->gpio_wait_q, &wait); in wait_gpio()
3004 spin_unlock_irqrestore(&info->port_array[0]->lock, flags); in wait_gpio()
3007 rc = -ERESTARTSYS; in wait_gpio()
3010 spin_lock_irqsave(&info->port_array[0]->lock, flags); in wait_gpio()
3011 remove_cond_wait(&info->gpio_wait_q, &wait); in wait_gpio()
3015 if (info->gpio_wait_q == NULL) in wait_gpio()
3017 spin_unlock_irqrestore(&info->port_array[0]->lock, flags); in wait_gpio()
3020 rc = -EFAULT; in wait_gpio()
3032 spin_lock_irqsave(&info->lock,flags); in modem_input_wait()
3033 cprev = info->icount; in modem_input_wait()
3034 add_wait_queue(&info->status_event_wait_q, &wait); in modem_input_wait()
3036 spin_unlock_irqrestore(&info->lock,flags); in modem_input_wait()
3041 rc = -ERESTARTSYS; in modem_input_wait()
3046 spin_lock_irqsave(&info->lock,flags); in modem_input_wait()
3047 cnow = info->icount; in modem_input_wait()
3049 spin_unlock_irqrestore(&info->lock,flags); in modem_input_wait()
3053 cnow.dcd == cprev.dcd && cnow.cts == cprev.cts) { in modem_input_wait()
3054 rc = -EIO; in modem_input_wait()
3061 (arg & TIOCM_CD && cnow.dcd != cprev.dcd) || in modem_input_wait()
3069 remove_wait_queue(&info->status_event_wait_q, &wait); in modem_input_wait()
3079 struct slgt_info *info = tty->driver_data; in tiocmget()
3083 spin_lock_irqsave(&info->lock,flags); in tiocmget()
3085 spin_unlock_irqrestore(&info->lock,flags); in tiocmget()
3087 result = ((info->signals & SerialSignal_RTS) ? TIOCM_RTS:0) + in tiocmget()
3088 ((info->signals & SerialSignal_DTR) ? TIOCM_DTR:0) + in tiocmget()
3089 ((info->signals & SerialSignal_DCD) ? TIOCM_CAR:0) + in tiocmget()
3090 ((info->signals & SerialSignal_RI) ? TIOCM_RNG:0) + in tiocmget()
3091 ((info->signals & SerialSignal_DSR) ? TIOCM_DSR:0) + in tiocmget()
3092 ((info->signals & SerialSignal_CTS) ? TIOCM_CTS:0); in tiocmget()
3094 DBGINFO(("%s tiocmget value=%08X\n", info->device_name, result)); in tiocmget()
3108 struct slgt_info *info = tty->driver_data; in tiocmset()
3111 DBGINFO(("%s tiocmset(%x,%x)\n", info->device_name, set, clear)); in tiocmset()
3114 info->signals |= SerialSignal_RTS; in tiocmset()
3116 info->signals |= SerialSignal_DTR; in tiocmset()
3118 info->signals &= ~SerialSignal_RTS; in tiocmset()
3120 info->signals &= ~SerialSignal_DTR; in tiocmset()
3122 spin_lock_irqsave(&info->lock,flags); in tiocmset()
3124 spin_unlock_irqrestore(&info->lock,flags); in tiocmset()
3133 spin_lock_irqsave(&info->lock,flags); in carrier_raised()
3135 spin_unlock_irqrestore(&info->lock,flags); in carrier_raised()
3136 return (info->signals & SerialSignal_DCD) ? 1 : 0; in carrier_raised()
3144 spin_lock_irqsave(&info->lock,flags); in dtr_rts()
3146 info->signals |= SerialSignal_RTS | SerialSignal_DTR; in dtr_rts()
3148 info->signals &= ~(SerialSignal_RTS | SerialSignal_DTR); in dtr_rts()
3150 spin_unlock_irqrestore(&info->lock,flags); in dtr_rts()
3165 struct tty_port *port = &info->port; in block_til_ready()
3167 DBGINFO(("%s block_til_ready\n", tty->driver->name)); in block_til_ready()
3169 if (filp->f_flags & O_NONBLOCK || tty_io_error(tty)) { in block_til_ready()
3180 * this loop, port->count is dropped by one, so that in block_til_ready()
3186 add_wait_queue(&port->open_wait, &wait); in block_til_ready()
3188 spin_lock_irqsave(&info->lock, flags); in block_til_ready()
3189 port->count--; in block_til_ready()
3190 spin_unlock_irqrestore(&info->lock, flags); in block_til_ready()
3191 port->blocked_open++; in block_til_ready()
3200 retval = (port->flags & ASYNC_HUP_NOTIFY) ? in block_til_ready()
3201 -EAGAIN : -ERESTARTSYS; in block_til_ready()
3210 retval = -ERESTARTSYS; in block_til_ready()
3214 DBGINFO(("%s block_til_ready wait\n", tty->driver->name)); in block_til_ready()
3221 remove_wait_queue(&port->open_wait, &wait); in block_til_ready()
3224 port->count++; in block_til_ready()
3225 port->blocked_open--; in block_til_ready()
3230 DBGINFO(("%s block_til_ready ready, rc=%d\n", tty->driver->name, retval)); in block_til_ready()
3238 * 32-bit CRC and status byte when configured to do so
3242 info->tmp_rbuf = kmalloc(info->max_frame_size + 5, GFP_KERNEL); in alloc_tmp_rbuf()
3243 if (info->tmp_rbuf == NULL) in alloc_tmp_rbuf()
3244 return -ENOMEM; in alloc_tmp_rbuf()
3246 info->flag_buf = kzalloc(info->max_frame_size + 5, GFP_KERNEL); in alloc_tmp_rbuf()
3247 if (!info->flag_buf) { in alloc_tmp_rbuf()
3248 kfree(info->tmp_rbuf); in alloc_tmp_rbuf()
3249 info->tmp_rbuf = NULL; in alloc_tmp_rbuf()
3250 return -ENOMEM; in alloc_tmp_rbuf()
3257 kfree(info->tmp_rbuf); in free_tmp_rbuf()
3258 info->tmp_rbuf = NULL; in free_tmp_rbuf()
3259 kfree(info->flag_buf); in free_tmp_rbuf()
3260 info->flag_buf = NULL; in free_tmp_rbuf()
3272 info->bufs = dma_alloc_coherent(&info->pdev->dev, DESC_LIST_SIZE, in alloc_desc()
3273 &info->bufs_dma_addr, GFP_KERNEL); in alloc_desc()
3274 if (info->bufs == NULL) in alloc_desc()
3275 return -ENOMEM; in alloc_desc()
3277 info->rbufs = (struct slgt_desc*)info->bufs; in alloc_desc()
3278 info->tbufs = ((struct slgt_desc*)info->bufs) + info->rbuf_count; in alloc_desc()
3280 pbufs = (unsigned int)info->bufs_dma_addr; in alloc_desc()
3286 for (i=0; i < info->rbuf_count; i++) { in alloc_desc()
3288 info->rbufs[i].pdesc = pbufs + (i * sizeof(struct slgt_desc)); in alloc_desc()
3291 if (i == info->rbuf_count - 1) in alloc_desc()
3292 info->rbufs[i].next = cpu_to_le32(pbufs); in alloc_desc()
3294 info->rbufs[i].next = cpu_to_le32(pbufs + ((i+1) * sizeof(struct slgt_desc))); in alloc_desc()
3295 set_desc_count(info->rbufs[i], DMABUFSIZE); in alloc_desc()
3298 for (i=0; i < info->tbuf_count; i++) { in alloc_desc()
3300 info->tbufs[i].pdesc = pbufs + ((info->rbuf_count + i) * sizeof(struct slgt_desc)); in alloc_desc()
3303 if (i == info->tbuf_count - 1) in alloc_desc()
3304 info->tbufs[i].next = cpu_to_le32(pbufs + info->rbuf_count * sizeof(struct slgt_desc)); in alloc_desc()
3306 …info->tbufs[i].next = cpu_to_le32(pbufs + ((info->rbuf_count + i + 1) * sizeof(struct slgt_desc))); in alloc_desc()
3314 if (info->bufs != NULL) { in free_desc()
3315 dma_free_coherent(&info->pdev->dev, DESC_LIST_SIZE, in free_desc()
3316 info->bufs, info->bufs_dma_addr); in free_desc()
3317 info->bufs = NULL; in free_desc()
3318 info->rbufs = NULL; in free_desc()
3319 info->tbufs = NULL; in free_desc()
3327 bufs[i].buf = dma_alloc_coherent(&info->pdev->dev, DMABUFSIZE, in alloc_bufs()
3330 return -ENOMEM; in alloc_bufs()
3342 dma_free_coherent(&info->pdev->dev, DMABUFSIZE, bufs[i].buf, in free_bufs()
3350 info->rbuf_count = 32; in alloc_dma_bufs()
3351 info->tbuf_count = 32; in alloc_dma_bufs()
3354 alloc_bufs(info, info->rbufs, info->rbuf_count) < 0 || in alloc_dma_bufs()
3355 alloc_bufs(info, info->tbufs, info->tbuf_count) < 0 || in alloc_dma_bufs()
3357 DBGERR(("%s DMA buffer alloc fail\n", info->device_name)); in alloc_dma_bufs()
3358 return -ENOMEM; in alloc_dma_bufs()
3366 if (info->bufs) { in free_dma_bufs()
3367 free_bufs(info, info->rbufs, info->rbuf_count); in free_dma_bufs()
3368 free_bufs(info, info->tbufs, info->tbuf_count); in free_dma_bufs()
3376 if (request_mem_region(info->phys_reg_addr, SLGT_REG_SIZE, "synclink_gt") == NULL) { in claim_resources()
3378 info->device_name, info->phys_reg_addr)); in claim_resources()
3379 info->init_error = DiagStatus_AddressConflict; in claim_resources()
3383 info->reg_addr_requested = true; in claim_resources()
3385 info->reg_addr = ioremap(info->phys_reg_addr, SLGT_REG_SIZE); in claim_resources()
3386 if (!info->reg_addr) { in claim_resources()
3388 info->device_name, info->phys_reg_addr)); in claim_resources()
3389 info->init_error = DiagStatus_CantAssignPciResources; in claim_resources()
3396 return -ENODEV; in claim_resources()
3401 if (info->irq_requested) { in release_resources()
3402 free_irq(info->irq_level, info); in release_resources()
3403 info->irq_requested = false; in release_resources()
3406 if (info->reg_addr_requested) { in release_resources()
3407 release_mem_region(info->phys_reg_addr, SLGT_REG_SIZE); in release_resources()
3408 info->reg_addr_requested = false; in release_resources()
3411 if (info->reg_addr) { in release_resources()
3412 iounmap(info->reg_addr); in release_resources()
3413 info->reg_addr = NULL; in release_resources()
3424 info->next_device = NULL; in add_device()
3425 info->line = slgt_device_count; in add_device()
3426 sprintf(info->device_name, "%s%d", tty_dev_prefix, info->line); in add_device()
3428 if (info->line < MAX_DEVICES) { in add_device()
3429 if (maxframe[info->line]) in add_device()
3430 info->max_frame_size = maxframe[info->line]; in add_device()
3439 while(current_dev->next_device) in add_device()
3440 current_dev = current_dev->next_device; in add_device()
3441 current_dev->next_device = info; in add_device()
3444 if (info->max_frame_size < 4096) in add_device()
3445 info->max_frame_size = 4096; in add_device()
3446 else if (info->max_frame_size > 65535) in add_device()
3447 info->max_frame_size = 65535; in add_device()
3449 switch(info->pdev->device) { in add_device()
3461 info->params.mode = MGSL_MODE_ASYNC; in add_device()
3467 devstr, info->device_name, info->phys_reg_addr, in add_device()
3468 info->irq_level, info->max_frame_size); in add_device()
3493 tty_port_init(&info->port); in alloc_dev()
3494 info->port.ops = &slgt_port_ops; in alloc_dev()
3495 INIT_WORK(&info->task, bh_handler); in alloc_dev()
3496 info->max_frame_size = 4096; in alloc_dev()
3497 info->base_clock = 14745600; in alloc_dev()
3498 info->rbuf_fill_level = DMABUFSIZE; in alloc_dev()
3499 init_waitqueue_head(&info->status_event_wait_q); in alloc_dev()
3500 init_waitqueue_head(&info->event_wait_q); in alloc_dev()
3501 spin_lock_init(&info->netlock); in alloc_dev()
3502 memcpy(&info->params,&default_params,sizeof(MGSL_PARAMS)); in alloc_dev()
3503 info->idle_mode = HDLC_TXIDLE_FLAGS; in alloc_dev()
3504 info->adapter_num = adapter_num; in alloc_dev()
3505 info->port_num = port_num; in alloc_dev()
3507 timer_setup(&info->tx_timer, tx_timeout, 0); in alloc_dev()
3508 timer_setup(&info->rx_timer, rx_timeout, 0); in alloc_dev()
3511 info->pdev = pdev; in alloc_dev()
3512 info->irq_level = pdev->irq; in alloc_dev()
3513 info->phys_reg_addr = pci_resource_start(pdev,0); in alloc_dev()
3515 info->bus_type = MGSL_BUS_TYPE_PCI; in alloc_dev()
3516 info->irq_flags = IRQF_SHARED; in alloc_dev()
3518 info->init_error = -1; /* assume error, set to 0 on successful init */ in alloc_dev()
3530 if (pdev->device == SYNCLINK_GT2_DEVICE_ID) in device_init()
3532 else if (pdev->device == SYNCLINK_GT4_DEVICE_ID) in device_init()
3539 for (--i; i >= 0; --i) { in device_init()
3540 tty_port_destroy(&port_array[i]->port); in device_init()
3549 memcpy(port_array[i]->port_array, port_array, sizeof(port_array)); in device_init()
3551 port_array[i]->port_count = port_count; in device_init()
3552 spin_lock_init(&port_array[i]->lock); in device_init()
3562 port_array[i]->irq_level = port_array[0]->irq_level; in device_init()
3563 port_array[i]->reg_addr = port_array[0]->reg_addr; in device_init()
3567 if (request_irq(port_array[0]->irq_level, in device_init()
3569 port_array[0]->irq_flags, in device_init()
3570 port_array[0]->device_name, in device_init()
3573 port_array[0]->device_name, in device_init()
3574 port_array[0]->irq_level)); in device_init()
3576 port_array[0]->irq_requested = true; in device_init()
3579 port_array[i]->init_error = port_array[0]->init_error; in device_init()
3580 port_array[i]->gpio_present = port_array[0]->gpio_present; in device_init()
3587 tty_port_register_device(&info->port, serial_driver, info->line, in device_init()
3588 &info->pdev->dev); in device_init()
3597 return -EIO; in init_one()
3642 for (info=slgt_device_list ; info != NULL ; info=info->next_device) in slgt_cleanup()
3643 tty_unregister_device(serial_driver, info->line); in slgt_cleanup()
3652 info = info->next_device; in slgt_cleanup()
3663 if (info->port_num == 0) in slgt_cleanup()
3666 info = info->next_device; in slgt_cleanup()
3667 tty_port_destroy(&tmp->port); in slgt_cleanup()
3693 serial_driver->driver_name = slgt_driver_name; in slgt_init()
3694 serial_driver->name = tty_dev_prefix; in slgt_init()
3695 serial_driver->major = ttymajor; in slgt_init()
3696 serial_driver->minor_start = 64; in slgt_init()
3697 serial_driver->type = TTY_DRIVER_TYPE_SERIAL; in slgt_init()
3698 serial_driver->subtype = SERIAL_TYPE_NORMAL; in slgt_init()
3699 serial_driver->init_termios = tty_std_termios; in slgt_init()
3700 serial_driver->init_termios.c_cflag = in slgt_init()
3702 serial_driver->init_termios.c_ispeed = 9600; in slgt_init()
3703 serial_driver->init_termios.c_ospeed = 9600; in slgt_init()
3713 driver_name, serial_driver->major); in slgt_init()
3745 unsigned long reg_addr = ((unsigned long)info->reg_addr) + addr; \
3747 reg_addr += (info->port_num) * 32; \
3749 reg_addr += (info->port_num) * 16;
3823 if (info->params.mode != MGSL_MODE_ASYNC) { in enable_loopback()
3835 if (info->params.clock_speed) in enable_loopback()
3836 set_rate(info, info->params.clock_speed); in enable_loopback()
3848 unsigned int osc = info->base_clock; in set_rate()
3850 /* div = osc/rate - 1 in set_rate()
3859 div--; in set_rate()
3880 info->rx_enabled = false; in rx_stop()
3881 info->rx_restart = false; in rx_stop()
3901 if (info->rx_pio) { in rx_start()
3905 if (info->params.mode == MGSL_MODE_ASYNC) { in rx_start()
3913 wr_reg32(info, RDDAR, info->rbufs[0].pdesc); in rx_start()
3915 if (info->params.mode != MGSL_MODE_ASYNC) { in rx_start()
3929 info->rx_restart = false; in rx_start()
3930 info->rx_enabled = true; in rx_start()
3935 if (!info->tx_enabled) { in tx_start()
3938 info->tx_enabled = true; in tx_start()
3941 if (desc_count(info->tbufs[info->tbuf_start])) { in tx_start()
3942 info->drop_rts_on_tx_done = false; in tx_start()
3944 if (info->params.mode != MGSL_MODE_ASYNC) { in tx_start()
3945 if (info->params.flags & HDLC_FLAG_AUTO_RTS) { in tx_start()
3947 if (!(info->signals & SerialSignal_RTS)) { in tx_start()
3948 info->signals |= SerialSignal_RTS; in tx_start()
3950 info->drop_rts_on_tx_done = true; in tx_start()
3965 wr_reg32(info, TDDAR, info->tbufs[info->tbuf_start].pdesc); in tx_start()
3967 info->tx_active = true; in tx_start()
3975 del_timer(&info->tx_timer); in tx_stop()
3990 info->tx_enabled = false; in tx_stop()
3991 info->tx_active = false; in tx_stop()
3996 if (!info->reg_addr) in reset_port()
4002 info->signals &= ~(SerialSignal_RTS | SerialSignal_DTR); in reset_port()
4011 for (i=0; i < info->port_count; ++i) { in reset_adapter()
4012 if (info->port_array[i]) in reset_adapter()
4013 reset_port(info->port_array[i]); in reset_adapter()
4041 * 00 auto-CTS enable in async_mode()
4045 if (info->if_mode & MGSL_INTERFACE_RTS_EN) in async_mode()
4048 if (info->params.parity != ASYNC_PARITY_NONE) { in async_mode()
4050 if (info->params.parity == ASYNC_PARITY_ODD) in async_mode()
4054 switch (info->params.data_bits) in async_mode()
4061 if (info->params.stop_bits != 1) in async_mode()
4064 if (info->params.flags & HDLC_FLAG_AUTO_CTS) in async_mode()
4084 * 00 auto-DCD enable in async_mode()
4088 if (info->params.parity != ASYNC_PARITY_NONE) { in async_mode()
4090 if (info->params.parity == ASYNC_PARITY_ODD) in async_mode()
4094 switch (info->params.data_bits) in async_mode()
4101 if (info->params.flags & HDLC_FLAG_AUTO_DCD) in async_mode()
4131 * 05 DCD IRQ enable in async_mode()
4134 * 02 1=txd->rxd internal loopback enable in async_mode()
4140 if ((rd_reg32(info, JCR) & BIT8) && info->params.data_rate && in async_mode()
4141 ((info->base_clock < (info->params.data_rate * 16)) || in async_mode()
4142 (info->base_clock % (info->params.data_rate * 16)))) { in async_mode()
4145 set_rate(info, info->params.data_rate * 8); in async_mode()
4148 set_rate(info, info->params.data_rate * 16); in async_mode()
4154 if (info->params.loopback) in async_mode()
4184 * 00 auto-CTS enable in sync_mode()
4188 switch(info->params.mode) { in sync_mode()
4196 if (info->if_mode & MGSL_INTERFACE_RTS_EN) in sync_mode()
4199 switch(info->params.encoding) in sync_mode()
4210 switch (info->params.crc_type & HDLC_CRC_MASK) in sync_mode()
4216 if (info->params.preamble != HDLC_PREAMBLE_PATTERN_NONE) in sync_mode()
4219 switch (info->params.preamble_length) in sync_mode()
4226 if (info->params.flags & HDLC_FLAG_AUTO_CTS) in sync_mode()
4233 switch (info->params.preamble) in sync_mode()
4259 * 00 auto-DCD enable in sync_mode()
4263 switch(info->params.mode) { in sync_mode()
4272 switch(info->params.encoding) in sync_mode()
4283 switch (info->params.crc_type & HDLC_CRC_MASK) in sync_mode()
4289 if (info->params.flags & HDLC_FLAG_AUTO_DCD) in sync_mode()
4303 if (info->params.flags & HDLC_FLAG_TXC_BRG) in sync_mode()
4308 if (info->params.flags & HDLC_FLAG_RXC_DPLL) in sync_mode()
4313 else if (info->params.flags & HDLC_FLAG_TXC_DPLL) in sync_mode()
4315 else if (info->params.flags & HDLC_FLAG_TXC_RXCPIN) in sync_mode()
4318 if (info->params.flags & HDLC_FLAG_RXC_BRG) in sync_mode()
4320 else if (info->params.flags & HDLC_FLAG_RXC_DPLL) in sync_mode()
4322 else if (info->params.flags & HDLC_FLAG_RXC_TXCPIN) in sync_mode()
4325 if (info->params.clock_speed) in sync_mode()
4330 if (info->params.flags & (HDLC_FLAG_TXC_DPLL + HDLC_FLAG_RXC_DPLL)) in sync_mode()
4333 switch(info->params.encoding) in sync_mode()
4346 set_rate(info, info->params.clock_speed * 16); in sync_mode()
4349 set_rate(info, info->params.clock_speed); in sync_mode()
4367 * 05 DCD IRQ enable in sync_mode()
4370 * 02 1=txd->rxd internal loopback enable in sync_mode()
4376 if (info->params.loopback) in sync_mode()
4392 if (info->idle_mode & HDLC_TXIDLE_CUSTOM_16) { in tx_set_idle()
4396 wr_reg8(info, TPR, (unsigned char)((info->idle_mode >> 8) & 0xff)); in tx_set_idle()
4403 if (info->idle_mode & (HDLC_TXIDLE_CUSTOM_8 | HDLC_TXIDLE_CUSTOM_16)) { in tx_set_idle()
4405 val = (unsigned char)(info->idle_mode & 0xff); in tx_set_idle()
4408 switch(info->idle_mode) in tx_set_idle()
4430 info->signals &= SerialSignal_RTS | SerialSignal_DTR; in get_gtsignals()
4433 info->signals |= SerialSignal_DSR; in get_gtsignals()
4435 info->signals |= SerialSignal_CTS; in get_gtsignals()
4437 info->signals |= SerialSignal_DCD; in get_gtsignals()
4439 info->signals |= SerialSignal_RI; in get_gtsignals()
4458 switch(info->if_mode & MGSL_INTERFACE_MASK) in msc_set_vcr()
4471 if (info->if_mode & MGSL_INTERFACE_MSB_FIRST) in msc_set_vcr()
4473 if (info->signals & SerialSignal_DTR) in msc_set_vcr()
4475 if (info->signals & SerialSignal_RTS) in msc_set_vcr()
4477 if (info->if_mode & MGSL_INTERFACE_LL) in msc_set_vcr()
4479 if (info->if_mode & MGSL_INTERFACE_RL) in msc_set_vcr()
4490 if (info->signals & SerialSignal_DTR) in set_gtsignals()
4494 if (info->signals & SerialSignal_RTS) in set_gtsignals()
4510 info->rbufs[i].status = 0; in free_rbufs()
4511 set_desc_count(info->rbufs[i], info->rbuf_fill_level); in free_rbufs()
4514 if (++i == info->rbuf_count) in free_rbufs()
4517 info->rbuf_current = i; in free_rbufs()
4525 free_rbufs(info, 0, info->rbuf_count - 1); in reset_rbufs()
4526 info->rbuf_fill_index = 0; in reset_rbufs()
4527 info->rbuf_fill_count = 0; in reset_rbufs()
4541 struct tty_struct *tty = info->port.tty; in rx_get_frame()
4545 switch (info->params.crc_type & HDLC_CRC_MASK) { in rx_get_frame()
4554 start = end = info->rbuf_current; in rx_get_frame()
4557 if (!desc_complete(info->rbufs[end])) in rx_get_frame()
4560 if (framesize == 0 && info->params.addr_filter != 0xff) in rx_get_frame()
4561 addr_field = info->rbufs[end].buf[0]; in rx_get_frame()
4563 framesize += desc_count(info->rbufs[end]); in rx_get_frame()
4565 if (desc_eof(info->rbufs[end])) in rx_get_frame()
4568 if (++end == info->rbuf_count) in rx_get_frame()
4571 if (end == info->rbuf_current) { in rx_get_frame()
4572 if (info->rx_enabled){ in rx_get_frame()
4573 spin_lock_irqsave(&info->lock,flags); in rx_get_frame()
4575 spin_unlock_irqrestore(&info->lock,flags); in rx_get_frame()
4590 status = desc_status(info->rbufs[end]); in rx_get_frame()
4593 if ((info->params.crc_type & HDLC_CRC_MASK) == HDLC_CRC_NONE) in rx_get_frame()
4597 (addr_field != 0xff && addr_field != info->params.addr_filter)) { in rx_get_frame()
4603 info->icount.rxshort++; in rx_get_frame()
4606 info->icount.rxcrc++; in rx_get_frame()
4607 if (!(info->params.crc_type & HDLC_CRC_RETURN_EX)) in rx_get_frame()
4613 info->netdev->stats.rx_errors++; in rx_get_frame()
4614 info->netdev->stats.rx_frame_errors++; in rx_get_frame()
4619 info->device_name, status, framesize)); in rx_get_frame()
4620 DBGDATA(info, info->rbufs[start].buf, min_t(int, framesize, info->rbuf_fill_level), "rx"); in rx_get_frame()
4623 if (!(info->params.crc_type & HDLC_CRC_RETURN_EX)) { in rx_get_frame()
4624 framesize -= crc_size; in rx_get_frame()
4628 if (framesize > info->max_frame_size + crc_size) in rx_get_frame()
4629 info->icount.rxlong++; in rx_get_frame()
4634 unsigned char *p = info->tmp_rbuf; in rx_get_frame()
4635 info->tmp_rbuf_count = framesize; in rx_get_frame()
4637 info->icount.rxok++; in rx_get_frame()
4640 int partial_count = min_t(int, copy_count, info->rbuf_fill_level); in rx_get_frame()
4641 memcpy(p, info->rbufs[i].buf, partial_count); in rx_get_frame()
4643 copy_count -= partial_count; in rx_get_frame()
4644 if (++i == info->rbuf_count) in rx_get_frame()
4648 if (info->params.crc_type & HDLC_CRC_RETURN_EX) { in rx_get_frame()
4654 if (info->netcount) in rx_get_frame()
4655 hdlcdev_rx(info,info->tmp_rbuf, framesize); in rx_get_frame()
4658 ldisc_receive_buf(tty, info->tmp_rbuf, info->flag_buf, framesize); in rx_get_frame()
4674 unsigned int i = info->rbuf_current; in rx_get_buf()
4677 if (!desc_complete(info->rbufs[i])) in rx_get_buf()
4679 count = desc_count(info->rbufs[i]); in rx_get_buf()
4680 switch(info->params.mode) { in rx_get_buf()
4685 if (desc_residue(info->rbufs[i])) in rx_get_buf()
4686 count--; in rx_get_buf()
4689 DBGDATA(info, info->rbufs[i].buf, count, "rx"); in rx_get_buf()
4692 ldisc_receive_buf(info->port.tty, info->rbufs[i].buf, in rx_get_buf()
4693 info->flag_buf, count); in rx_get_buf()
4701 info->tbuf_current = 0; in reset_tbufs()
4702 for (i=0 ; i < info->tbuf_count ; i++) { in reset_tbufs()
4703 info->tbufs[i].status = 0; in reset_tbufs()
4704 info->tbufs[i].count = 0; in reset_tbufs()
4714 unsigned int i = info->tbuf_current; in free_tbuf_count()
4718 if (desc_count(info->tbufs[i])) in free_tbuf_count()
4721 if (++i == info->tbuf_count) in free_tbuf_count()
4723 } while (i != info->tbuf_current); in free_tbuf_count()
4727 --count; in free_tbuf_count()
4739 unsigned int i = info->tbuf_current; in tbuf_bytes()
4756 count = desc_count(info->tbufs[i]); in tbuf_bytes()
4760 active_buf_count = info->tbufs[i].buf_count; in tbuf_bytes()
4761 if (++i == info->tbuf_count) in tbuf_bytes()
4763 } while (i != info->tbuf_current); in tbuf_bytes()
4776 if (info->tx_active) in tbuf_bytes()
4809 info->tbuf_start = i = info->tbuf_current; in tx_load()
4812 d = &info->tbufs[i]; in tx_load()
4815 memcpy(d->buf, buf, count); in tx_load()
4817 size -= count; in tx_load()
4824 if ((!size && info->params.mode == MGSL_MODE_HDLC) || in tx_load()
4825 info->params.mode == MGSL_MODE_RAW) in tx_load()
4831 if (i != info->tbuf_start) in tx_load()
4833 d->buf_count = count; in tx_load()
4835 if (++i == info->tbuf_count) in tx_load()
4839 info->tbuf_current = i; in tx_load()
4842 d = &info->tbufs[info->tbuf_start]; in tx_load()
4843 set_desc_count(*d, d->buf_count); in tx_load()
4846 if (!info->tx_active) in tx_load()
4866 rc = -ENODEV; in register_test()
4870 info->gpio_present = (rd_reg32(info, JCR) & BIT5) ? 1 : 0; in register_test()
4871 info->init_error = rc ? 0 : DiagStatus_AddressFailure; in register_test()
4879 struct tty_struct *oldtty = info->port.tty; in irq_test()
4880 u32 speed = info->params.data_rate; in irq_test()
4882 info->params.data_rate = 921600; in irq_test()
4883 info->port.tty = NULL; in irq_test()
4885 spin_lock_irqsave(&info->lock, flags); in irq_test()
4897 info->init_error = DiagStatus_IrqFailure; in irq_test()
4898 info->irq_occurred = false; in irq_test()
4900 spin_unlock_irqrestore(&info->lock, flags); in irq_test()
4903 while(timeout-- && !info->irq_occurred) in irq_test()
4906 spin_lock_irqsave(&info->lock,flags); in irq_test()
4908 spin_unlock_irqrestore(&info->lock,flags); in irq_test()
4910 info->params.data_rate = speed; in irq_test()
4911 info->port.tty = oldtty; in irq_test()
4913 info->init_error = info->irq_occurred ? 0 : DiagStatus_IrqFailure; in irq_test()
4914 return info->irq_occurred ? 0 : -ENODEV; in irq_test()
4922 if (desc_complete(info->rbufs[0])) { in loopback_test_rx()
4923 count = desc_count(info->rbufs[0]); in loopback_test_rx()
4924 src = info->rbufs[0].buf; in loopback_test_rx()
4925 dest = info->tmp_rbuf; in loopback_test_rx()
4927 for( ; count ; count-=2, src+=2) { in loopback_test_rx()
4932 info->tmp_rbuf_count++; in loopback_test_rx()
4935 DBGDATA(info, info->tmp_rbuf, info->tmp_rbuf_count, "rx"); in loopback_test_rx()
4948 int rc = -ENODEV; in loopback_test()
4951 struct tty_struct *oldtty = info->port.tty; in loopback_test()
4954 memcpy(&params, &info->params, sizeof(params)); in loopback_test()
4956 info->params.mode = MGSL_MODE_ASYNC; in loopback_test()
4957 info->params.data_rate = 921600; in loopback_test()
4958 info->params.loopback = 1; in loopback_test()
4959 info->port.tty = NULL; in loopback_test()
4965 info->tmp_rbuf_count = 0; in loopback_test()
4966 memset(info->tmp_rbuf, 0, TESTFRAMESIZE); in loopback_test()
4969 spin_lock_irqsave(&info->lock,flags); in loopback_test()
4973 spin_unlock_irqrestore(&info->lock, flags); in loopback_test()
4976 for (timeout = 100; timeout; --timeout) { in loopback_test()
4985 if (!rc && (info->tmp_rbuf_count != count || in loopback_test()
4986 memcmp(buf, info->tmp_rbuf, count))) { in loopback_test()
4987 rc = -ENODEV; in loopback_test()
4990 spin_lock_irqsave(&info->lock,flags); in loopback_test()
4992 spin_unlock_irqrestore(&info->lock,flags); in loopback_test()
4994 memcpy(&info->params, &params, sizeof(info->params)); in loopback_test()
4995 info->port.tty = oldtty; in loopback_test()
4997 info->init_error = rc ? DiagStatus_DmaFailure : 0; in loopback_test()
5003 DBGINFO(("testing %s\n", info->device_name)); in adapter_test()
5006 info->device_name, info->phys_reg_addr); in adapter_test()
5009 info->device_name, info->irq_level); in adapter_test()
5011 printk("loopback test failure %s\n", info->device_name); in adapter_test()
5013 return info->init_error; in adapter_test()
5024 DBGINFO(("%s tx_timeout\n", info->device_name)); in tx_timeout()
5025 if(info->tx_active && info->params.mode == MGSL_MODE_HDLC) { in tx_timeout()
5026 info->icount.txtimeout++; in tx_timeout()
5028 spin_lock_irqsave(&info->lock,flags); in tx_timeout()
5030 spin_unlock_irqrestore(&info->lock,flags); in tx_timeout()
5033 if (info->netcount) in tx_timeout()
5048 DBGINFO(("%s rx_timeout\n", info->device_name)); in rx_timeout()
5049 spin_lock_irqsave(&info->lock, flags); in rx_timeout()
5050 info->pending_bh |= BH_RECEIVE; in rx_timeout()
5051 spin_unlock_irqrestore(&info->lock, flags); in rx_timeout()
5052 bh_handler(&info->task); in rx_timeout()