Lines Matching +full:cts +full:- +full:override
83 #define COPY_FROM_USER(error,dest,src,size) error = copy_from_user(dest,src,size) ? -EFAULT : 0
85 #define COPY_TO_USER(error,dest,src,size) error = copy_to_user(dest,src,size) ? -EFAULT : 0
197 int if_mode; /* serial interface selection (RS-232, v.35 etc) */
295 #define IRQ_CTS BIT10 // CTS status change
309 #define CTS BIT1 // CTS state macro
321 #define write_reg(info, reg, val) outb((val),(info)->io_base + (reg))
322 #define read_reg(info, reg) inb((info)->io_base + (reg))
324 #define read_reg16(info, reg) inw((info)->io_base + (reg))
325 #define write_reg16(info, reg, val) outw((val), (info)->io_base + (reg))
339 info->imra_value |= mask; in irq_disable()
340 write_reg16(info, CHA + IMR, info->imra_value); in irq_disable()
342 info->imrb_value |= mask; in irq_disable()
343 write_reg16(info, CHB + IMR, info->imrb_value); in irq_disable()
349 info->imra_value &= ~mask; in irq_enable()
350 write_reg16(info, CHA + IMR, info->imra_value); in irq_enable()
352 info->imrb_value &= ~mask; in irq_enable()
353 write_reg16(info, CHB + IMR, info->imrb_value); in irq_enable()
358 { info->pim_value |= (mask); write_reg(info, PIM, info->pim_value); }
361 { info->pim_value &= ~(mask); write_reg(info, PIM, info->pim_value); }
384 #define dev_to_port(D) (dev_to_hdlc(D)->priv)
436 * Set this param to non-zero to load eax with the
438 * This is useful for use with gdb and add-symbol-file command.
478 * (gdb) to get the .text address for the add-symbol-file command.
492 * ldisc_receive_buf - pass receive data to line discipline
503 if (ld->ops->receive_buf) in ldisc_receive_buf()
504 ld->ops->receive_buf(tty, data, flags, count); in ldisc_receive_buf()
525 return -ENOMEM; in mgslpc_probe()
528 info->magic = MGSLPC_MAGIC; in mgslpc_probe()
529 tty_port_init(&info->port); in mgslpc_probe()
530 info->port.ops = &mgslpc_port_ops; in mgslpc_probe()
531 INIT_WORK(&info->task, bh_handler); in mgslpc_probe()
532 info->max_frame_size = 4096; in mgslpc_probe()
533 info->port.close_delay = 5*HZ/10; in mgslpc_probe()
534 info->port.closing_wait = 30*HZ; in mgslpc_probe()
535 init_waitqueue_head(&info->status_event_wait_q); in mgslpc_probe()
536 init_waitqueue_head(&info->event_wait_q); in mgslpc_probe()
537 spin_lock_init(&info->lock); in mgslpc_probe()
538 spin_lock_init(&info->netlock); in mgslpc_probe()
539 memcpy(&info->params,&default_params,sizeof(MGSL_PARAMS)); in mgslpc_probe()
540 info->idle_mode = HDLC_TXIDLE_FLAGS; in mgslpc_probe()
541 info->imra_value = 0xffff; in mgslpc_probe()
542 info->imrb_value = 0xffff; in mgslpc_probe()
543 info->pim_value = 0xff; in mgslpc_probe()
545 info->p_dev = link; in mgslpc_probe()
546 link->priv = info; in mgslpc_probe()
563 tty_port_destroy(&info->port); in mgslpc_probe()
578 MGSLPC_INFO *info = link->priv; in mgslpc_config()
584 link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO; in mgslpc_config()
590 link->config_index = 8; in mgslpc_config()
591 link->config_regs = PRESENT_OPTION; in mgslpc_config()
600 info->io_base = link->resource[0]->start; in mgslpc_config()
601 info->irq_level = link->irq; in mgslpc_config()
606 return -ENODEV; in mgslpc_config()
628 ((MGSLPC_INFO *)link->priv)->stop = 1; in mgslpc_detach()
631 mgslpc_remove_device((MGSLPC_INFO *)link->priv); in mgslpc_detach()
636 MGSLPC_INFO *info = link->priv; in mgslpc_suspend()
638 info->stop = 1; in mgslpc_suspend()
645 MGSLPC_INFO *info = link->priv; in mgslpc_resume()
647 info->stop = 0; in mgslpc_resume()
666 if (info->magic != MGSLPC_MAGIC) { in mgslpc_paranoia_check()
706 MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; in tx_pause()
709 if (mgslpc_paranoia_check(info, tty->name, "tx_pause")) in tx_pause()
712 printk("tx_pause(%s)\n", info->device_name); in tx_pause()
714 spin_lock_irqsave(&info->lock, flags); in tx_pause()
715 if (info->tx_enabled) in tx_pause()
717 spin_unlock_irqrestore(&info->lock, flags); in tx_pause()
722 MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; in tx_release()
725 if (mgslpc_paranoia_check(info, tty->name, "tx_release")) in tx_release()
728 printk("tx_release(%s)\n", info->device_name); in tx_release()
730 spin_lock_irqsave(&info->lock, flags); in tx_release()
731 if (!info->tx_enabled) in tx_release()
733 spin_unlock_irqrestore(&info->lock, flags); in tx_release()
744 spin_lock_irqsave(&info->lock, flags); in bh_action()
746 if (info->pending_bh & BH_RECEIVE) { in bh_action()
747 info->pending_bh &= ~BH_RECEIVE; in bh_action()
749 } else if (info->pending_bh & BH_TRANSMIT) { in bh_action()
750 info->pending_bh &= ~BH_TRANSMIT; in bh_action()
752 } else if (info->pending_bh & BH_STATUS) { in bh_action()
753 info->pending_bh &= ~BH_STATUS; in bh_action()
759 info->bh_running = false; in bh_action()
760 info->bh_requested = false; in bh_action()
763 spin_unlock_irqrestore(&info->lock, flags); in bh_action()
776 __FILE__,__LINE__,info->device_name); in bh_handler()
778 info->bh_running = true; in bh_handler()
779 tty = tty_port_tty_get(&info->port); in bh_handler()
809 __FILE__,__LINE__,info->device_name); in bh_handler()
815 printk("bh_transmit() entry on %s\n", info->device_name); in bh_transmit()
823 info->ri_chkcount = 0; in bh_status()
824 info->dsr_chkcount = 0; in bh_status()
825 info->dcd_chkcount = 0; in bh_status()
826 info->cts_chkcount = 0; in bh_status()
829 /* eom: non-zero = end of frame */
834 RXBUF *buf = (RXBUF*)(info->rx_buf + (info->rx_put * info->rx_buf_size)); in rx_ready_hdlc()
839 if (!info->rx_enabled) in rx_ready_hdlc()
842 if (info->rx_frame_count >= info->rx_buf_count) { in rx_ready_hdlc()
845 info->pending_bh |= BH_RECEIVE; in rx_ready_hdlc()
846 info->rx_overflow = true; in rx_ready_hdlc()
847 info->icount.buf_overrun++; in rx_ready_hdlc()
867 fifo_count -= read_count; in rx_ready_hdlc()
869 buf->status = data[--read_count]; in rx_ready_hdlc()
872 if (buf->count >= info->max_frame_size) { in rx_ready_hdlc()
875 buf->count = 0; in rx_ready_hdlc()
878 *(buf->data + buf->count) = data[i]; in rx_ready_hdlc()
879 buf->count++; in rx_ready_hdlc()
884 info->pending_bh |= BH_RECEIVE; in rx_ready_hdlc()
885 info->rx_frame_count++; in rx_ready_hdlc()
886 info->rx_put++; in rx_ready_hdlc()
887 if (info->rx_put >= info->rx_buf_count) in rx_ready_hdlc()
888 info->rx_put = 0; in rx_ready_hdlc()
895 struct tty_port *port = &info->port; in rx_ready_async()
899 struct mgsl_icount *icount = &info->icount; in rx_ready_async()
918 fifo_count -= 2; in rx_ready_async()
920 icount->rx++; in rx_ready_async()
929 icount->parity++; in rx_ready_async()
931 icount->frame++; in rx_ready_async()
934 if (status & info->ignore_status_mask) in rx_ready_async()
937 status &= info->read_status_mask; in rx_ready_async()
952 __FILE__,__LINE__,icount->rx,icount->brk, in rx_ready_async()
953 icount->parity,icount->frame,icount->overrun); in rx_ready_async()
963 if (!info->tx_active) in tx_done()
966 info->tx_active = false; in tx_done()
967 info->tx_aborting = false; in tx_done()
969 if (info->params.mode == MGSL_MODE_ASYNC) in tx_done()
972 info->tx_count = info->tx_put = info->tx_get = 0; in tx_done()
973 del_timer(&info->tx_timer); in tx_done()
975 if (info->drop_rts_on_tx_done) { in tx_done()
977 if (info->serial_signals & SerialSignal_RTS) { in tx_done()
978 info->serial_signals &= ~SerialSignal_RTS; in tx_done()
981 info->drop_rts_on_tx_done = false; in tx_done()
985 if (info->netcount) in tx_done()
990 if (tty && (tty->stopped || tty->hw_stopped)) { in tx_done()
994 info->pending_bh |= BH_TRANSMIT; in tx_done()
1004 printk("%s(%d):tx_ready(%s)\n", __FILE__, __LINE__, info->device_name); in tx_ready()
1006 if (info->params.mode == MGSL_MODE_HDLC) { in tx_ready()
1007 if (!info->tx_active) in tx_ready()
1010 if (tty && (tty->stopped || tty->hw_stopped)) { in tx_ready()
1014 if (!info->tx_count) in tx_ready()
1015 info->tx_active = false; in tx_ready()
1018 if (!info->tx_count) in tx_ready()
1021 while (info->tx_count && fifo_count) { in tx_ready()
1022 c = min(2, min_t(int, fifo_count, min(info->tx_count, TXBUFSIZE - info->tx_get))); in tx_ready()
1025 write_reg(info, CHA + TXFIFO, *(info->tx_buf + info->tx_get)); in tx_ready()
1028 *((unsigned short*)(info->tx_buf + info->tx_get))); in tx_ready()
1030 info->tx_count -= c; in tx_ready()
1031 info->tx_get = (info->tx_get + c) & (TXBUFSIZE - 1); in tx_ready()
1032 fifo_count -= c; in tx_ready()
1035 if (info->params.mode == MGSL_MODE_ASYNC) { in tx_ready()
1036 if (info->tx_count < WAKEUP_CHARS) in tx_ready()
1037 info->pending_bh |= BH_TRANSMIT; in tx_ready()
1040 if (info->tx_count) in tx_ready()
1050 if ((info->cts_chkcount)++ >= IO_PIN_SHUTDOWN_LIMIT) in cts_change()
1052 info->icount.cts++; in cts_change()
1053 if (info->serial_signals & SerialSignal_CTS) in cts_change()
1054 info->input_signal_events.cts_up++; in cts_change()
1056 info->input_signal_events.cts_down++; in cts_change()
1057 wake_up_interruptible(&info->status_event_wait_q); in cts_change()
1058 wake_up_interruptible(&info->event_wait_q); in cts_change()
1060 if (tty && tty_port_cts_enabled(&info->port)) { in cts_change()
1061 if (tty->hw_stopped) { in cts_change()
1062 if (info->serial_signals & SerialSignal_CTS) { in cts_change()
1064 printk("CTS tx start..."); in cts_change()
1065 tty->hw_stopped = 0; in cts_change()
1067 info->pending_bh |= BH_TRANSMIT; in cts_change()
1071 if (!(info->serial_signals & SerialSignal_CTS)) { in cts_change()
1073 printk("CTS tx stop..."); in cts_change()
1074 tty->hw_stopped = 1; in cts_change()
1079 info->pending_bh |= BH_STATUS; in cts_change()
1085 if ((info->dcd_chkcount)++ >= IO_PIN_SHUTDOWN_LIMIT) in dcd_change()
1087 info->icount.dcd++; in dcd_change()
1088 if (info->serial_signals & SerialSignal_DCD) { in dcd_change()
1089 info->input_signal_events.dcd_up++; in dcd_change()
1092 info->input_signal_events.dcd_down++; in dcd_change()
1094 if (info->netcount) { in dcd_change()
1095 if (info->serial_signals & SerialSignal_DCD) in dcd_change()
1096 netif_carrier_on(info->netdev); in dcd_change()
1098 netif_carrier_off(info->netdev); in dcd_change()
1101 wake_up_interruptible(&info->status_event_wait_q); in dcd_change()
1102 wake_up_interruptible(&info->event_wait_q); in dcd_change()
1104 if (tty_port_check_carrier(&info->port)) { in dcd_change()
1106 printk("%s CD now %s...", info->device_name, in dcd_change()
1107 (info->serial_signals & SerialSignal_DCD) ? "on" : "off"); in dcd_change()
1108 if (info->serial_signals & SerialSignal_DCD) in dcd_change()
1109 wake_up_interruptible(&info->port.open_wait); in dcd_change()
1117 info->pending_bh |= BH_STATUS; in dcd_change()
1123 if ((info->dsr_chkcount)++ >= IO_PIN_SHUTDOWN_LIMIT) in dsr_change()
1125 info->icount.dsr++; in dsr_change()
1126 if (info->serial_signals & SerialSignal_DSR) in dsr_change()
1127 info->input_signal_events.dsr_up++; in dsr_change()
1129 info->input_signal_events.dsr_down++; in dsr_change()
1130 wake_up_interruptible(&info->status_event_wait_q); in dsr_change()
1131 wake_up_interruptible(&info->event_wait_q); in dsr_change()
1132 info->pending_bh |= BH_STATUS; in dsr_change()
1138 if ((info->ri_chkcount)++ >= IO_PIN_SHUTDOWN_LIMIT) in ri_change()
1140 info->icount.rng++; in ri_change()
1141 if (info->serial_signals & SerialSignal_RI) in ri_change()
1142 info->input_signal_events.ri_up++; in ri_change()
1144 info->input_signal_events.ri_down++; in ri_change()
1145 wake_up_interruptible(&info->status_event_wait_q); in ri_change()
1146 wake_up_interruptible(&info->event_wait_q); in ri_change()
1147 info->pending_bh |= BH_STATUS; in ri_change()
1166 printk("mgslpc_isr(%d) entry.\n", info->irq_level); in mgslpc_isr()
1168 if (!(info->p_dev->_locked)) in mgslpc_isr()
1171 tty = tty_port_tty_get(&info->port); in mgslpc_isr()
1173 spin_lock(&info->lock); in mgslpc_isr()
1177 printk("mgslpc_isr %s gis=%04X\n", info->device_name,gis); in mgslpc_isr()
1196 info->irq_occurred = true; in mgslpc_isr()
1202 info->icount.exithunt++; in mgslpc_isr()
1203 wake_up_interruptible(&info->event_wait_q); in mgslpc_isr()
1206 info->icount.brk++; in mgslpc_isr()
1207 if (info->port.flags & ASYNC_SAK) in mgslpc_isr()
1214 if (info->params.mode == MGSL_MODE_HDLC) in mgslpc_isr()
1222 if (info->tx_aborting) in mgslpc_isr()
1223 info->icount.txabort++; in mgslpc_isr()
1225 info->icount.txunder++; in mgslpc_isr()
1229 info->icount.txok++; in mgslpc_isr()
1248 if (info->pending_bh && !info->bh_running && !info->bh_requested) { in mgslpc_isr()
1251 __FILE__,__LINE__,info->device_name); in mgslpc_isr()
1252 schedule_work(&info->task); in mgslpc_isr()
1253 info->bh_requested = true; in mgslpc_isr()
1256 spin_unlock(&info->lock); in mgslpc_isr()
1261 __FILE__, __LINE__, info->irq_level); in mgslpc_isr()
1273 printk("%s(%d):startup(%s)\n", __FILE__, __LINE__, info->device_name); in startup()
1275 if (tty_port_initialized(&info->port)) in startup()
1278 if (!info->tx_buf) { in startup()
1280 info->tx_buf = (unsigned char *)get_zeroed_page(GFP_KERNEL); in startup()
1281 if (!info->tx_buf) { in startup()
1283 __FILE__, __LINE__, info->device_name); in startup()
1284 return -ENOMEM; in startup()
1288 info->pending_bh = 0; in startup()
1290 memset(&info->icount, 0, sizeof(info->icount)); in startup()
1292 timer_setup(&info->tx_timer, tx_timeout, 0); in startup()
1303 set_bit(TTY_IO_ERROR, &tty->flags); in startup()
1312 clear_bit(TTY_IO_ERROR, &tty->flags); in startup()
1314 tty_port_set_initialized(&info->port, 1); in startup()
1325 if (!tty_port_initialized(&info->port)) in shutdown()
1330 __FILE__, __LINE__, info->device_name); in shutdown()
1334 wake_up_interruptible(&info->status_event_wait_q); in shutdown()
1335 wake_up_interruptible(&info->event_wait_q); in shutdown()
1337 del_timer_sync(&info->tx_timer); in shutdown()
1339 if (info->tx_buf) { in shutdown()
1340 free_page((unsigned long) info->tx_buf); in shutdown()
1341 info->tx_buf = NULL; in shutdown()
1344 spin_lock_irqsave(&info->lock, flags); in shutdown()
1353 info->serial_signals &= ~(SerialSignal_RTS | SerialSignal_DTR); in shutdown()
1357 spin_unlock_irqrestore(&info->lock, flags); in shutdown()
1362 set_bit(TTY_IO_ERROR, &tty->flags); in shutdown()
1364 tty_port_set_initialized(&info->port, 0); in shutdown()
1371 spin_lock_irqsave(&info->lock, flags); in mgslpc_program_hw()
1375 info->tx_count = info->tx_put = info->tx_get = 0; in mgslpc_program_hw()
1377 if (info->params.mode == MGSL_MODE_HDLC || info->netcount) in mgslpc_program_hw()
1384 info->dcd_chkcount = 0; in mgslpc_program_hw()
1385 info->cts_chkcount = 0; in mgslpc_program_hw()
1386 info->ri_chkcount = 0; in mgslpc_program_hw()
1387 info->dsr_chkcount = 0; in mgslpc_program_hw()
1393 if (info->netcount || (tty && C_CREAD(tty))) in mgslpc_program_hw()
1396 spin_unlock_irqrestore(&info->lock, flags); in mgslpc_program_hw()
1411 __FILE__, __LINE__, info->device_name); in mgslpc_change_params()
1413 cflag = tty->termios.c_cflag; in mgslpc_change_params()
1418 info->serial_signals |= SerialSignal_RTS | SerialSignal_DTR; in mgslpc_change_params()
1420 info->serial_signals &= ~(SerialSignal_RTS | SerialSignal_DTR); in mgslpc_change_params()
1425 case CS5: info->params.data_bits = 5; break; in mgslpc_change_params()
1426 case CS6: info->params.data_bits = 6; break; in mgslpc_change_params()
1427 case CS7: info->params.data_bits = 7; break; in mgslpc_change_params()
1428 case CS8: info->params.data_bits = 8; break; in mgslpc_change_params()
1429 default: info->params.data_bits = 7; break; in mgslpc_change_params()
1433 info->params.stop_bits = 2; in mgslpc_change_params()
1435 info->params.stop_bits = 1; in mgslpc_change_params()
1437 info->params.parity = ASYNC_PARITY_NONE; in mgslpc_change_params()
1440 info->params.parity = ASYNC_PARITY_ODD; in mgslpc_change_params()
1442 info->params.parity = ASYNC_PARITY_EVEN; in mgslpc_change_params()
1445 info->params.parity = ASYNC_PARITY_SPACE; in mgslpc_change_params()
1452 bits_per_char = info->params.data_bits + in mgslpc_change_params()
1453 info->params.stop_bits + 1; in mgslpc_change_params()
1456 * allow tty settings to override, otherwise keep the in mgslpc_change_params()
1459 if (info->params.data_rate <= 460800) { in mgslpc_change_params()
1460 info->params.data_rate = tty_get_baud_rate(tty); in mgslpc_change_params()
1463 if (info->params.data_rate) { in mgslpc_change_params()
1464 info->timeout = (32*HZ*bits_per_char) / in mgslpc_change_params()
1465 info->params.data_rate; in mgslpc_change_params()
1467 info->timeout += HZ/50; /* Add .02 seconds of slop */ in mgslpc_change_params()
1469 tty_port_set_cts_flow(&info->port, cflag & CRTSCTS); in mgslpc_change_params()
1470 tty_port_set_check_carrier(&info->port, ~cflag & CLOCAL); in mgslpc_change_params()
1474 info->read_status_mask = 0; in mgslpc_change_params()
1476 info->read_status_mask |= BIT7 | BIT6; in mgslpc_change_params()
1478 info->ignore_status_mask |= BIT7 | BIT6; in mgslpc_change_params()
1487 MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; in mgslpc_put_char()
1492 __FILE__, __LINE__, ch, info->device_name); in mgslpc_put_char()
1495 if (mgslpc_paranoia_check(info, tty->name, "mgslpc_put_char")) in mgslpc_put_char()
1498 if (!info->tx_buf) in mgslpc_put_char()
1501 spin_lock_irqsave(&info->lock, flags); in mgslpc_put_char()
1503 if (info->params.mode == MGSL_MODE_ASYNC || !info->tx_active) { in mgslpc_put_char()
1504 if (info->tx_count < TXBUFSIZE - 1) { in mgslpc_put_char()
1505 info->tx_buf[info->tx_put++] = ch; in mgslpc_put_char()
1506 info->tx_put &= TXBUFSIZE-1; in mgslpc_put_char()
1507 info->tx_count++; in mgslpc_put_char()
1511 spin_unlock_irqrestore(&info->lock, flags); in mgslpc_put_char()
1520 MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; in mgslpc_flush_chars()
1525 __FILE__, __LINE__, info->device_name, info->tx_count); in mgslpc_flush_chars()
1527 if (mgslpc_paranoia_check(info, tty->name, "mgslpc_flush_chars")) in mgslpc_flush_chars()
1530 if (info->tx_count <= 0 || tty->stopped || in mgslpc_flush_chars()
1531 tty->hw_stopped || !info->tx_buf) in mgslpc_flush_chars()
1536 __FILE__, __LINE__, info->device_name); in mgslpc_flush_chars()
1538 spin_lock_irqsave(&info->lock, flags); in mgslpc_flush_chars()
1539 if (!info->tx_active) in mgslpc_flush_chars()
1541 spin_unlock_irqrestore(&info->lock, flags); in mgslpc_flush_chars()
1558 MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; in mgslpc_write()
1563 __FILE__, __LINE__, info->device_name, count); in mgslpc_write()
1565 if (mgslpc_paranoia_check(info, tty->name, "mgslpc_write") || in mgslpc_write()
1566 !info->tx_buf) in mgslpc_write()
1569 if (info->params.mode == MGSL_MODE_HDLC) { in mgslpc_write()
1571 ret = -EIO; in mgslpc_write()
1574 if (info->tx_active) in mgslpc_write()
1576 else if (info->tx_count) in mgslpc_write()
1582 min(TXBUFSIZE - info->tx_count - 1, in mgslpc_write()
1583 TXBUFSIZE - info->tx_put)); in mgslpc_write()
1587 memcpy(info->tx_buf + info->tx_put, buf, c); in mgslpc_write()
1589 spin_lock_irqsave(&info->lock, flags); in mgslpc_write()
1590 info->tx_put = (info->tx_put + c) & (TXBUFSIZE-1); in mgslpc_write()
1591 info->tx_count += c; in mgslpc_write()
1592 spin_unlock_irqrestore(&info->lock, flags); in mgslpc_write()
1595 count -= c; in mgslpc_write()
1599 if (info->tx_count && !tty->stopped && !tty->hw_stopped) { in mgslpc_write()
1600 spin_lock_irqsave(&info->lock, flags); in mgslpc_write()
1601 if (!info->tx_active) in mgslpc_write()
1603 spin_unlock_irqrestore(&info->lock, flags); in mgslpc_write()
1608 __FILE__, __LINE__, info->device_name, ret); in mgslpc_write()
1616 MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; in mgslpc_write_room()
1619 if (mgslpc_paranoia_check(info, tty->name, "mgslpc_write_room")) in mgslpc_write_room()
1622 if (info->params.mode == MGSL_MODE_HDLC) { in mgslpc_write_room()
1624 if (info->tx_active) in mgslpc_write_room()
1629 ret = TXBUFSIZE - info->tx_count - 1; in mgslpc_write_room()
1636 __FILE__, __LINE__, info->device_name, ret); in mgslpc_write_room()
1644 MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; in mgslpc_chars_in_buffer()
1649 __FILE__, __LINE__, info->device_name); in mgslpc_chars_in_buffer()
1651 if (mgslpc_paranoia_check(info, tty->name, "mgslpc_chars_in_buffer")) in mgslpc_chars_in_buffer()
1654 if (info->params.mode == MGSL_MODE_HDLC) in mgslpc_chars_in_buffer()
1655 rc = info->tx_active ? info->max_frame_size : 0; in mgslpc_chars_in_buffer()
1657 rc = info->tx_count; in mgslpc_chars_in_buffer()
1661 __FILE__, __LINE__, info->device_name, rc); in mgslpc_chars_in_buffer()
1670 MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; in mgslpc_flush_buffer()
1675 __FILE__, __LINE__, info->device_name); in mgslpc_flush_buffer()
1677 if (mgslpc_paranoia_check(info, tty->name, "mgslpc_flush_buffer")) in mgslpc_flush_buffer()
1680 spin_lock_irqsave(&info->lock, flags); in mgslpc_flush_buffer()
1681 info->tx_count = info->tx_put = info->tx_get = 0; in mgslpc_flush_buffer()
1682 del_timer(&info->tx_timer); in mgslpc_flush_buffer()
1683 spin_unlock_irqrestore(&info->lock, flags); in mgslpc_flush_buffer()
1685 wake_up_interruptible(&tty->write_wait); in mgslpc_flush_buffer()
1689 /* Send a high-priority XON/XOFF character
1693 MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; in mgslpc_send_xchar()
1698 __FILE__, __LINE__, info->device_name, ch); in mgslpc_send_xchar()
1700 if (mgslpc_paranoia_check(info, tty->name, "mgslpc_send_xchar")) in mgslpc_send_xchar()
1703 info->x_char = ch; in mgslpc_send_xchar()
1705 spin_lock_irqsave(&info->lock, flags); in mgslpc_send_xchar()
1706 if (!info->tx_enabled) in mgslpc_send_xchar()
1708 spin_unlock_irqrestore(&info->lock, flags); in mgslpc_send_xchar()
1716 MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; in mgslpc_throttle()
1721 __FILE__, __LINE__, info->device_name); in mgslpc_throttle()
1723 if (mgslpc_paranoia_check(info, tty->name, "mgslpc_throttle")) in mgslpc_throttle()
1730 spin_lock_irqsave(&info->lock, flags); in mgslpc_throttle()
1731 info->serial_signals &= ~SerialSignal_RTS; in mgslpc_throttle()
1733 spin_unlock_irqrestore(&info->lock, flags); in mgslpc_throttle()
1741 MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; in mgslpc_unthrottle()
1746 __FILE__, __LINE__, info->device_name); in mgslpc_unthrottle()
1748 if (mgslpc_paranoia_check(info, tty->name, "mgslpc_unthrottle")) in mgslpc_unthrottle()
1752 if (info->x_char) in mgslpc_unthrottle()
1753 info->x_char = 0; in mgslpc_unthrottle()
1759 spin_lock_irqsave(&info->lock, flags); in mgslpc_unthrottle()
1760 info->serial_signals |= SerialSignal_RTS; in mgslpc_unthrottle()
1762 spin_unlock_irqrestore(&info->lock, flags); in mgslpc_unthrottle()
1772 printk("get_params(%s)\n", info->device_name); in get_stats()
1774 memset(&info->icount, 0, sizeof(info->icount)); in get_stats()
1776 COPY_TO_USER(err, user_icount, &info->icount, sizeof(struct mgsl_icount)); in get_stats()
1778 return -EFAULT; in get_stats()
1789 printk("get_params(%s)\n", info->device_name); in get_params()
1790 COPY_TO_USER(err,user_params, &info->params, sizeof(MGSL_PARAMS)); in get_params()
1792 return -EFAULT; in get_params()
1813 info->device_name); in set_params()
1818 __FILE__, __LINE__, info->device_name); in set_params()
1819 return -EFAULT; in set_params()
1822 spin_lock_irqsave(&info->lock, flags); in set_params()
1823 memcpy(&info->params,&tmp_params,sizeof(MGSL_PARAMS)); in set_params()
1824 spin_unlock_irqrestore(&info->lock, flags); in set_params()
1835 printk("get_txidle(%s)=%d\n", info->device_name, info->idle_mode); in get_txidle()
1836 COPY_TO_USER(err,idle_mode, &info->idle_mode, sizeof(int)); in get_txidle()
1838 return -EFAULT; in get_txidle()
1846 printk("set_txidle(%s,%d)\n", info->device_name, idle_mode); in set_txidle()
1847 spin_lock_irqsave(&info->lock, flags); in set_txidle()
1848 info->idle_mode = idle_mode; in set_txidle()
1850 spin_unlock_irqrestore(&info->lock, flags); in set_txidle()
1858 printk("get_interface(%s)=%d\n", info->device_name, info->if_mode); in get_interface()
1859 COPY_TO_USER(err,if_mode, &info->if_mode, sizeof(int)); in get_interface()
1861 return -EFAULT; in get_interface()
1870 printk("set_interface(%s,%d)\n", info->device_name, if_mode); in set_interface()
1871 spin_lock_irqsave(&info->lock, flags); in set_interface()
1872 info->if_mode = if_mode; in set_interface()
1875 switch (info->if_mode) in set_interface()
1883 spin_unlock_irqrestore(&info->lock, flags); in set_interface()
1892 printk("set_txenable(%s,%d)\n", info->device_name, enable); in set_txenable()
1894 spin_lock_irqsave(&info->lock, flags); in set_txenable()
1896 if (!info->tx_enabled) in set_txenable()
1899 if (info->tx_enabled) in set_txenable()
1902 spin_unlock_irqrestore(&info->lock, flags); in set_txenable()
1911 printk("tx_abort(%s)\n", info->device_name); in tx_abort()
1913 spin_lock_irqsave(&info->lock, flags); in tx_abort()
1914 if (info->tx_active && info->tx_count && in tx_abort()
1915 info->params.mode == MGSL_MODE_HDLC) { in tx_abort()
1919 info->tx_count = info->tx_put = info->tx_get = 0; in tx_abort()
1920 info->tx_aborting = true; in tx_abort()
1922 spin_unlock_irqrestore(&info->lock, flags); in tx_abort()
1931 printk("set_rxenable(%s,%d)\n", info->device_name, enable); in set_rxenable()
1933 spin_lock_irqsave(&info->lock, flags); in set_rxenable()
1935 if (!info->rx_enabled) in set_rxenable()
1938 if (info->rx_enabled) in set_rxenable()
1941 spin_unlock_irqrestore(&info->lock, flags); in set_rxenable()
1966 return -EFAULT; in wait_events()
1969 printk("wait_events(%s,%d)\n", info->device_name, mask); in wait_events()
1971 spin_lock_irqsave(&info->lock, flags); in wait_events()
1975 s = info->serial_signals; in wait_events()
1982 spin_unlock_irqrestore(&info->lock, flags); in wait_events()
1987 cprev = info->icount; in wait_events()
1988 oldsigs = info->input_signal_events; in wait_events()
1990 if ((info->params.mode == MGSL_MODE_HDLC) && in wait_events()
1995 add_wait_queue(&info->event_wait_q, &wait); in wait_events()
1997 spin_unlock_irqrestore(&info->lock, flags); in wait_events()
2003 rc = -ERESTARTSYS; in wait_events()
2008 spin_lock_irqsave(&info->lock, flags); in wait_events()
2009 cnow = info->icount; in wait_events()
2010 newsigs = info->input_signal_events; in wait_events()
2012 spin_unlock_irqrestore(&info->lock, flags); in wait_events()
2025 rc = -EIO; in wait_events()
2047 remove_wait_queue(&info->event_wait_q, &wait); in wait_events()
2051 spin_lock_irqsave(&info->lock, flags); in wait_events()
2052 if (!waitqueue_active(&info->event_wait_q)) in wait_events()
2054 spin_unlock_irqrestore(&info->lock, flags); in wait_events()
2070 spin_lock_irqsave(&info->lock, flags); in modem_input_wait()
2071 cprev = info->icount; in modem_input_wait()
2072 add_wait_queue(&info->status_event_wait_q, &wait); in modem_input_wait()
2074 spin_unlock_irqrestore(&info->lock, flags); in modem_input_wait()
2079 rc = -ERESTARTSYS; in modem_input_wait()
2084 spin_lock_irqsave(&info->lock, flags); in modem_input_wait()
2085 cnow = info->icount; in modem_input_wait()
2087 spin_unlock_irqrestore(&info->lock, flags); in modem_input_wait()
2091 cnow.dcd == cprev.dcd && cnow.cts == cprev.cts) { in modem_input_wait()
2092 rc = -EIO; in modem_input_wait()
2100 (arg & TIOCM_CTS && cnow.cts != cprev.cts)) { in modem_input_wait()
2107 remove_wait_queue(&info->status_event_wait_q, &wait); in modem_input_wait()
2116 MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; in tiocmget()
2120 spin_lock_irqsave(&info->lock, flags); in tiocmget()
2122 spin_unlock_irqrestore(&info->lock, flags); in tiocmget()
2124 result = ((info->serial_signals & SerialSignal_RTS) ? TIOCM_RTS:0) + in tiocmget()
2125 ((info->serial_signals & SerialSignal_DTR) ? TIOCM_DTR:0) + in tiocmget()
2126 ((info->serial_signals & SerialSignal_DCD) ? TIOCM_CAR:0) + in tiocmget()
2127 ((info->serial_signals & SerialSignal_RI) ? TIOCM_RNG:0) + in tiocmget()
2128 ((info->serial_signals & SerialSignal_DSR) ? TIOCM_DSR:0) + in tiocmget()
2129 ((info->serial_signals & SerialSignal_CTS) ? TIOCM_CTS:0); in tiocmget()
2133 __FILE__, __LINE__, info->device_name, result); in tiocmget()
2142 MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; in tiocmset()
2147 __FILE__, __LINE__, info->device_name, set, clear); in tiocmset()
2150 info->serial_signals |= SerialSignal_RTS; in tiocmset()
2152 info->serial_signals |= SerialSignal_DTR; in tiocmset()
2154 info->serial_signals &= ~SerialSignal_RTS; in tiocmset()
2156 info->serial_signals &= ~SerialSignal_DTR; in tiocmset()
2158 spin_lock_irqsave(&info->lock, flags); in tiocmset()
2160 spin_unlock_irqrestore(&info->lock, flags); in tiocmset()
2168 * break_state -1=set break condition, 0=clear
2172 MGSLPC_INFO * info = (MGSLPC_INFO *)tty->driver_data; in mgslpc_break()
2177 __FILE__, __LINE__, info->device_name, break_state); in mgslpc_break()
2179 if (mgslpc_paranoia_check(info, tty->name, "mgslpc_break")) in mgslpc_break()
2180 return -EINVAL; in mgslpc_break()
2182 spin_lock_irqsave(&info->lock, flags); in mgslpc_break()
2183 if (break_state == -1) in mgslpc_break()
2187 spin_unlock_irqrestore(&info->lock, flags); in mgslpc_break()
2194 MGSLPC_INFO * info = (MGSLPC_INFO *)tty->driver_data; in mgslpc_get_icount()
2198 spin_lock_irqsave(&info->lock, flags); in mgslpc_get_icount()
2199 cnow = info->icount; in mgslpc_get_icount()
2200 spin_unlock_irqrestore(&info->lock, flags); in mgslpc_get_icount()
2202 icount->cts = cnow.cts; in mgslpc_get_icount()
2203 icount->dsr = cnow.dsr; in mgslpc_get_icount()
2204 icount->rng = cnow.rng; in mgslpc_get_icount()
2205 icount->dcd = cnow.dcd; in mgslpc_get_icount()
2206 icount->rx = cnow.rx; in mgslpc_get_icount()
2207 icount->tx = cnow.tx; in mgslpc_get_icount()
2208 icount->frame = cnow.frame; in mgslpc_get_icount()
2209 icount->overrun = cnow.overrun; in mgslpc_get_icount()
2210 icount->parity = cnow.parity; in mgslpc_get_icount()
2211 icount->brk = cnow.brk; in mgslpc_get_icount()
2212 icount->buf_overrun = cnow.buf_overrun; in mgslpc_get_icount()
2230 MGSLPC_INFO * info = (MGSLPC_INFO *)tty->driver_data; in mgslpc_ioctl()
2235 info->device_name, cmd); in mgslpc_ioctl()
2237 if (mgslpc_paranoia_check(info, tty->name, "mgslpc_ioctl")) in mgslpc_ioctl()
2238 return -ENODEV; in mgslpc_ioctl()
2242 return -EIO; in mgslpc_ioctl()
2271 return -ENOIOCTLCMD; in mgslpc_ioctl()
2285 MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; in mgslpc_set_termios()
2290 tty->driver->name); in mgslpc_set_termios()
2293 if ((tty->termios.c_cflag == old_termios->c_cflag) in mgslpc_set_termios()
2294 && (RELEVANT_IFLAG(tty->termios.c_iflag) in mgslpc_set_termios()
2295 == RELEVANT_IFLAG(old_termios->c_iflag))) in mgslpc_set_termios()
2301 if ((old_termios->c_cflag & CBAUD) && !C_BAUD(tty)) { in mgslpc_set_termios()
2302 info->serial_signals &= ~(SerialSignal_RTS | SerialSignal_DTR); in mgslpc_set_termios()
2303 spin_lock_irqsave(&info->lock, flags); in mgslpc_set_termios()
2305 spin_unlock_irqrestore(&info->lock, flags); in mgslpc_set_termios()
2309 if (!(old_termios->c_cflag & CBAUD) && C_BAUD(tty)) { in mgslpc_set_termios()
2310 info->serial_signals |= SerialSignal_DTR; in mgslpc_set_termios()
2312 info->serial_signals |= SerialSignal_RTS; in mgslpc_set_termios()
2313 spin_lock_irqsave(&info->lock, flags); in mgslpc_set_termios()
2315 spin_unlock_irqrestore(&info->lock, flags); in mgslpc_set_termios()
2319 if (old_termios->c_cflag & CRTSCTS && !C_CRTSCTS(tty)) { in mgslpc_set_termios()
2320 tty->hw_stopped = 0; in mgslpc_set_termios()
2327 MGSLPC_INFO * info = (MGSLPC_INFO *)tty->driver_data; in mgslpc_close()
2328 struct tty_port *port = &info->port; in mgslpc_close()
2330 if (mgslpc_paranoia_check(info, tty->name, "mgslpc_close")) in mgslpc_close()
2335 __FILE__, __LINE__, info->device_name, port->count); in mgslpc_close()
2341 mgslpc_wait_until_sent(tty, info->timeout); in mgslpc_close()
2353 tty->driver->name, port->count); in mgslpc_close()
2360 MGSLPC_INFO * info = (MGSLPC_INFO *)tty->driver_data; in mgslpc_wait_until_sent()
2368 __FILE__, __LINE__, info->device_name); in mgslpc_wait_until_sent()
2370 if (mgslpc_paranoia_check(info, tty->name, "mgslpc_wait_until_sent")) in mgslpc_wait_until_sent()
2373 if (!tty_port_initialized(&info->port)) in mgslpc_wait_until_sent()
2381 * Note: use tight timings here to satisfy the NIST-PCTS. in mgslpc_wait_until_sent()
2384 if (info->params.data_rate) { in mgslpc_wait_until_sent()
2385 char_time = info->timeout/(32 * 5); in mgslpc_wait_until_sent()
2394 if (info->params.mode == MGSL_MODE_HDLC) { in mgslpc_wait_until_sent()
2395 while (info->tx_active) { in mgslpc_wait_until_sent()
2403 while ((info->tx_count || info->tx_active) && in mgslpc_wait_until_sent()
2404 info->tx_enabled) { in mgslpc_wait_until_sent()
2416 __FILE__, __LINE__, info->device_name); in mgslpc_wait_until_sent()
2424 MGSLPC_INFO * info = (MGSLPC_INFO *)tty->driver_data; in mgslpc_hangup()
2428 __FILE__, __LINE__, info->device_name); in mgslpc_hangup()
2430 if (mgslpc_paranoia_check(info, tty->name, "mgslpc_hangup")) in mgslpc_hangup()
2435 tty_port_hangup(&info->port); in mgslpc_hangup()
2443 spin_lock_irqsave(&info->lock, flags); in carrier_raised()
2445 spin_unlock_irqrestore(&info->lock, flags); in carrier_raised()
2447 if (info->serial_signals & SerialSignal_DCD) in carrier_raised()
2457 spin_lock_irqsave(&info->lock, flags); in dtr_rts()
2459 info->serial_signals |= SerialSignal_RTS | SerialSignal_DTR; in dtr_rts()
2461 info->serial_signals &= ~(SerialSignal_RTS | SerialSignal_DTR); in dtr_rts()
2463 spin_unlock_irqrestore(&info->lock, flags); in dtr_rts()
2475 line = tty->index; in mgslpc_open()
2479 return -ENODEV; in mgslpc_open()
2484 while(info && info->line != line) in mgslpc_open()
2485 info = info->next_device; in mgslpc_open()
2486 if (mgslpc_paranoia_check(info, tty->name, "mgslpc_open")) in mgslpc_open()
2487 return -ENODEV; in mgslpc_open()
2489 port = &info->port; in mgslpc_open()
2490 tty->driver_data = info; in mgslpc_open()
2495 __FILE__, __LINE__, tty->driver->name, port->count); in mgslpc_open()
2497 port->low_latency = (port->flags & ASYNC_LOW_LATENCY) ? 1 : 0; in mgslpc_open()
2499 spin_lock_irqsave(&info->netlock, flags); in mgslpc_open()
2500 if (info->netcount) { in mgslpc_open()
2501 retval = -EBUSY; in mgslpc_open()
2502 spin_unlock_irqrestore(&info->netlock, flags); in mgslpc_open()
2505 spin_lock(&port->lock); in mgslpc_open()
2506 port->count++; in mgslpc_open()
2507 spin_unlock(&port->lock); in mgslpc_open()
2508 spin_unlock_irqrestore(&info->netlock, flags); in mgslpc_open()
2510 if (port->count == 1) { in mgslpc_open()
2517 retval = tty_port_block_til_ready(&info->port, tty, filp); in mgslpc_open()
2521 __FILE__, __LINE__, info->device_name, retval); in mgslpc_open()
2527 __FILE__, __LINE__, info->device_name); in mgslpc_open()
2544 info->device_name, info->io_base, info->irq_level); in line_info()
2547 spin_lock_irqsave(&info->lock, flags); in line_info()
2549 spin_unlock_irqrestore(&info->lock, flags); in line_info()
2553 if (info->serial_signals & SerialSignal_RTS) in line_info()
2555 if (info->serial_signals & SerialSignal_CTS) in line_info()
2556 strcat(stat_buf, "|CTS"); in line_info()
2557 if (info->serial_signals & SerialSignal_DTR) in line_info()
2559 if (info->serial_signals & SerialSignal_DSR) in line_info()
2561 if (info->serial_signals & SerialSignal_DCD) in line_info()
2563 if (info->serial_signals & SerialSignal_RI) in line_info()
2566 if (info->params.mode == MGSL_MODE_HDLC) { in line_info()
2568 info->icount.txok, info->icount.rxok); in line_info()
2569 if (info->icount.txunder) in line_info()
2570 seq_printf(m, " txunder:%d", info->icount.txunder); in line_info()
2571 if (info->icount.txabort) in line_info()
2572 seq_printf(m, " txabort:%d", info->icount.txabort); in line_info()
2573 if (info->icount.rxshort) in line_info()
2574 seq_printf(m, " rxshort:%d", info->icount.rxshort); in line_info()
2575 if (info->icount.rxlong) in line_info()
2576 seq_printf(m, " rxlong:%d", info->icount.rxlong); in line_info()
2577 if (info->icount.rxover) in line_info()
2578 seq_printf(m, " rxover:%d", info->icount.rxover); in line_info()
2579 if (info->icount.rxcrc) in line_info()
2580 seq_printf(m, " rxcrc:%d", info->icount.rxcrc); in line_info()
2583 info->icount.tx, info->icount.rx); in line_info()
2584 if (info->icount.frame) in line_info()
2585 seq_printf(m, " fe:%d", info->icount.frame); in line_info()
2586 if (info->icount.parity) in line_info()
2587 seq_printf(m, " pe:%d", info->icount.parity); in line_info()
2588 if (info->icount.brk) in line_info()
2589 seq_printf(m, " brk:%d", info->icount.brk); in line_info()
2590 if (info->icount.overrun) in line_info()
2591 seq_printf(m, " oe:%d", info->icount.overrun); in line_info()
2598 info->tx_active,info->bh_requested,info->bh_running, in line_info()
2599 info->pending_bh); in line_info()
2613 info = info->next_device; in mgslpc_proc_show()
2621 info->rx_buf_size = sizeof(RXBUF) + info->max_frame_size; in rx_alloc_buffers()
2624 info->rx_buf_total_size = info->rx_buf_size * 8; in rx_alloc_buffers()
2627 if (info->rx_buf_total_size > 0x10000) in rx_alloc_buffers()
2628 info->rx_buf_total_size = 0x10000; in rx_alloc_buffers()
2631 info->rx_buf_count = info->rx_buf_total_size / info->rx_buf_size; in rx_alloc_buffers()
2633 info->rx_buf = kmalloc(info->rx_buf_total_size, GFP_KERNEL); in rx_alloc_buffers()
2634 if (info->rx_buf == NULL) in rx_alloc_buffers()
2635 return -ENOMEM; in rx_alloc_buffers()
2638 info->flag_buf = kzalloc(info->max_frame_size, GFP_KERNEL); in rx_alloc_buffers()
2639 if (!info->flag_buf) { in rx_alloc_buffers()
2640 kfree(info->rx_buf); in rx_alloc_buffers()
2641 info->rx_buf = NULL; in rx_alloc_buffers()
2642 return -ENOMEM; in rx_alloc_buffers()
2651 kfree(info->rx_buf); in rx_free_buffers()
2652 info->rx_buf = NULL; in rx_free_buffers()
2653 kfree(info->flag_buf); in rx_free_buffers()
2654 info->flag_buf = NULL; in rx_free_buffers()
2660 printk("Can't allocate rx buffer %s\n", info->device_name); in claim_resources()
2662 return -ENODEV; in claim_resources()
2670 printk("release_resources(%s)\n", info->device_name); in release_resources()
2685 info->next_device = NULL; in mgslpc_add_device()
2686 info->line = mgslpc_device_count; in mgslpc_add_device()
2687 sprintf(info->device_name,"ttySLP%d",info->line); in mgslpc_add_device()
2689 if (info->line < MAX_DEVICE_COUNT) { in mgslpc_add_device()
2690 if (maxframe[info->line]) in mgslpc_add_device()
2691 info->max_frame_size = maxframe[info->line]; in mgslpc_add_device()
2700 while (current_dev->next_device) in mgslpc_add_device()
2701 current_dev = current_dev->next_device; in mgslpc_add_device()
2702 current_dev->next_device = info; in mgslpc_add_device()
2705 if (info->max_frame_size < 4096) in mgslpc_add_device()
2706 info->max_frame_size = 4096; in mgslpc_add_device()
2707 else if (info->max_frame_size > 65535) in mgslpc_add_device()
2708 info->max_frame_size = 65535; in mgslpc_add_device()
2711 info->device_name, info->io_base, info->irq_level); in mgslpc_add_device()
2719 tty_dev = tty_port_register_device(&info->port, serial_driver, info->line, in mgslpc_add_device()
2720 &info->p_dev->dev); in mgslpc_add_device()
2733 current_dev->next_device = NULL; in mgslpc_add_device()
2736 mgslpc_device_count--; in mgslpc_add_device()
2748 last->next_device = info->next_device; in mgslpc_remove_device()
2750 mgslpc_device_list = info->next_device; in mgslpc_remove_device()
2751 tty_unregister_device(serial_driver, info->line); in mgslpc_remove_device()
2756 tty_port_destroy(&info->port); in mgslpc_remove_device()
2758 mgslpc_device_count--; in mgslpc_remove_device()
2762 info = info->next_device; in mgslpc_remove_device()
2825 serial_driver->driver_name = "synclink_cs"; in synclink_cs_init()
2826 serial_driver->name = "ttySLP"; in synclink_cs_init()
2827 serial_driver->major = ttymajor; in synclink_cs_init()
2828 serial_driver->minor_start = 64; in synclink_cs_init()
2829 serial_driver->type = TTY_DRIVER_TYPE_SERIAL; in synclink_cs_init()
2830 serial_driver->subtype = SERIAL_TYPE_NORMAL; in synclink_cs_init()
2831 serial_driver->init_termios = tty_std_termios; in synclink_cs_init()
2832 serial_driver->init_termios.c_cflag = in synclink_cs_init()
2848 serial_driver->major); in synclink_cs_init()
2885 N--; in mgslpc_set_rate()
2924 if (info->params.mode == MGSL_MODE_HDLC && info->params.clock_speed) in enable_auxclk()
2945 * 04 ODS Output Driver Select, 1=TxD is push-pull output in enable_auxclk()
2960 * 01 C32, CRC select, 0=CRC-16, 1=CRC-32 in enable_auxclk()
2965 if (info->params.mode == MGSL_MODE_HDLC && info->params.clock_speed) in enable_auxclk()
2984 * CTS transitions can be detected (requires TxC) in enable_auxclk()
2986 if (info->params.mode == MGSL_MODE_HDLC && info->params.clock_speed) in enable_auxclk()
2987 mgslpc_set_rate(info, CHB, info->params.clock_speed); in enable_auxclk()
3005 if (info->params.clock_speed) in loopback_enable()
3006 mgslpc_set_rate(info, CHA, info->params.clock_speed); in loopback_enable()
3027 if (info->params.flags & HDLC_FLAG_RXC_DPLL in hdlc_mode()
3028 && info->params.flags & HDLC_FLAG_TXC_DPLL) { in hdlc_mode()
3031 } else if (info->params.flags & HDLC_FLAG_RXC_BRG in hdlc_mode()
3032 && info->params.flags & HDLC_FLAG_TXC_BRG) { in hdlc_mode()
3036 } else if (info->params.flags & HDLC_FLAG_RXC_DPLL) { in hdlc_mode()
3037 if (info->params.flags & HDLC_FLAG_TXC_BRG) { in hdlc_mode()
3045 } else if (info->params.flags & HDLC_FLAG_TXC_BRG) { in hdlc_mode()
3063 if (info->params.loopback) in hdlc_mode()
3067 if (info->serial_signals & SerialSignal_RTS) in hdlc_mode()
3082 switch (info->params.encoding) in hdlc_mode()
3104 * 04 ODS Output Driver Select, 1=TxD is push-pull output in hdlc_mode()
3120 * 01 C32, CRC select, 0=CRC-16, 1=CRC-32 in hdlc_mode()
3131 if (info->params.crc_type == HDLC_CRC_32_CCITT) in hdlc_mode()
3133 if (info->params.encoding == HDLC_ENCODING_NRZB) in hdlc_mode()
3150 if (info->params.crc_type == HDLC_CRC_NONE) in hdlc_mode()
3152 if (info->params.preamble != HDLC_PREAMBLE_PATTERN_NONE) in hdlc_mode()
3154 switch (info->params.preamble_length) in hdlc_mode()
3168 /* PRE - Preamble pattern */ in hdlc_mode()
3170 switch (info->params.preamble) in hdlc_mode()
3192 if (info->params.flags & HDLC_FLAG_RXC_DPLL) in hdlc_mode()
3193 mgslpc_set_rate(info, CHA, info->params.clock_speed * 16); in hdlc_mode()
3195 mgslpc_set_rate(info, CHA, info->params.clock_speed); in hdlc_mode()
3215 if (info->params.flags & HDLC_FLAG_AUTO_DCD) in hdlc_mode()
3219 if (info->params.loopback || info->testing_irq) in hdlc_mode()
3221 if (info->params.flags & HDLC_FLAG_AUTO_CTS) in hdlc_mode()
3224 /* PVR[3] 1=AUTO CTS active */ in hdlc_mode()
3246 if (!info->testing_irq) in hdlc_mode()
3259 __FILE__, __LINE__, info->device_name); in rx_stop()
3264 info->rx_enabled = false; in rx_stop()
3265 info->rx_overflow = false; in rx_stop()
3272 __FILE__, __LINE__, info->device_name); in rx_start()
3275 info->rx_enabled = false; in rx_start()
3276 info->rx_overflow = false; in rx_start()
3281 info->rx_enabled = true; in rx_start()
3288 __FILE__, __LINE__, info->device_name); in tx_start()
3290 if (info->tx_count) { in tx_start()
3294 info->drop_rts_on_tx_done = false; in tx_start()
3296 if (info->params.flags & HDLC_FLAG_AUTO_RTS) { in tx_start()
3298 if (!(info->serial_signals & SerialSignal_RTS)) { in tx_start()
3299 info->serial_signals |= SerialSignal_RTS; in tx_start()
3301 info->drop_rts_on_tx_done = true; in tx_start()
3305 if (info->params.mode == MGSL_MODE_ASYNC) { in tx_start()
3306 if (!info->tx_active) { in tx_start()
3307 info->tx_active = true; in tx_start()
3311 info->tx_active = true; in tx_start()
3313 mod_timer(&info->tx_timer, jiffies + in tx_start()
3318 if (!info->tx_enabled) in tx_start()
3319 info->tx_enabled = true; in tx_start()
3326 __FILE__, __LINE__, info->device_name); in tx_stop()
3328 del_timer(&info->tx_timer); in tx_stop()
3330 info->tx_enabled = false; in tx_stop()
3331 info->tx_active = false; in tx_stop()
3352 * 03 output, 1=AUTO CTS control enabled in reset_device()
3364 * 03 AUTO CTS output 1=enabled in reset_device()
3379 * 01..00 IC[1..0] Interrupt Config, 01=push-pull output, active low in reset_device()
3399 * 05 FCTS Flow Control on CTS in async_mode()
3409 if (info->params.loopback) in async_mode()
3413 if (!(info->serial_signals & SerialSignal_RTS)) in async_mode()
3432 * 04 ODS Output Driver Select, 1=TxD is push-pull output in async_mode()
3474 mgslpc_set_rate(info, CHA, info->params.data_rate * 16); in async_mode()
3487 if (info->params.data_bits != 8) in async_mode()
3489 if (info->params.stop_bits != 1) in async_mode()
3491 if (info->params.parity != ASYNC_PARITY_NONE) in async_mode()
3494 if (info->params.parity == ASYNC_PARITY_ODD) in async_mode()
3532 if (info->params.flags & HDLC_FLAG_AUTO_DCD) in async_mode()
3535 if (info->params.flags & HDLC_FLAG_AUTO_CTS) in async_mode()
3541 if (info->params.flags & HDLC_FLAG_AUTO_CTS) { in async_mode()
3543 /* PVR[3] 1=AUTO CTS active */ in async_mode()
3560 if (info->idle_mode == HDLC_TXIDLE_FLAGS) in tx_set_idle()
3573 info->serial_signals &= SerialSignal_RTS | SerialSignal_DTR; in get_signals()
3576 info->serial_signals |= SerialSignal_DCD; in get_signals()
3578 info->serial_signals |= SerialSignal_CTS; in get_signals()
3582 info->serial_signals |= SerialSignal_RI; in get_signals()
3584 info->serial_signals |= SerialSignal_DSR; in get_signals()
3595 if (info->params.mode == MGSL_MODE_ASYNC) { in set_signals()
3596 if (info->serial_signals & SerialSignal_RTS) in set_signals()
3601 if (info->serial_signals & SerialSignal_RTS) in set_signals()
3608 if (info->serial_signals & SerialSignal_DTR) in set_signals()
3619 info->rx_put = 0; in rx_reset_buffers()
3620 info->rx_get = 0; in rx_reset_buffers()
3621 info->rx_frame_count = 0; in rx_reset_buffers()
3622 for (i=0 ; i < info->rx_buf_count ; i++) { in rx_reset_buffers()
3623 buf = (RXBUF*)(info->rx_buf + (i * info->rx_buf_size)); in rx_reset_buffers()
3624 buf->status = buf->count = 0; in rx_reset_buffers()
3641 if (info->rx_frame_count == 0) in rx_get_frame()
3644 buf = (RXBUF*)(info->rx_buf + (info->rx_get * info->rx_buf_size)); in rx_get_frame()
3646 status = buf->status; in rx_get_frame()
3655 info->icount.rxabort++; in rx_get_frame()
3657 info->icount.rxover++; in rx_get_frame()
3659 info->icount.rxcrc++; in rx_get_frame()
3660 if (info->params.crc_type & HDLC_CRC_RETURN_EX) in rx_get_frame()
3666 info->netdev->stats.rx_errors++; in rx_get_frame()
3667 info->netdev->stats.rx_frame_errors++; in rx_get_frame()
3674 framesize = buf->count; in rx_get_frame()
3678 __FILE__, __LINE__, info->device_name, status, framesize); in rx_get_frame()
3681 trace_block(info, buf->data, framesize, 0); in rx_get_frame()
3684 if ((info->params.crc_type & HDLC_CRC_RETURN_EX && in rx_get_frame()
3685 framesize+1 > info->max_frame_size) || in rx_get_frame()
3686 framesize > info->max_frame_size) in rx_get_frame()
3687 info->icount.rxlong++; in rx_get_frame()
3690 info->icount.rxok++; in rx_get_frame()
3692 if (info->params.crc_type & HDLC_CRC_RETURN_EX) { in rx_get_frame()
3693 *(buf->data + framesize) = status & BIT5 ? RX_OK:RX_CRC_ERROR; in rx_get_frame()
3698 if (info->netcount) in rx_get_frame()
3699 hdlcdev_rx(info, buf->data, framesize); in rx_get_frame()
3702 ldisc_receive_buf(tty, buf->data, info->flag_buf, framesize); in rx_get_frame()
3706 spin_lock_irqsave(&info->lock, flags); in rx_get_frame()
3707 buf->status = buf->count = 0; in rx_get_frame()
3708 info->rx_frame_count--; in rx_get_frame()
3709 info->rx_get++; in rx_get_frame()
3710 if (info->rx_get >= info->rx_buf_count) in rx_get_frame()
3711 info->rx_get = 0; in rx_get_frame()
3712 spin_unlock_irqrestore(&info->lock, flags); in rx_get_frame()
3726 spin_lock_irqsave(&info->lock, flags); in register_test()
3739 spin_unlock_irqrestore(&info->lock, flags); in register_test()
3748 spin_lock_irqsave(&info->lock, flags); in irq_test()
3751 info->testing_irq = true; in irq_test()
3754 info->irq_occurred = false; in irq_test()
3762 spin_unlock_irqrestore(&info->lock, flags); in irq_test()
3765 while(end_time-- && !info->irq_occurred) { in irq_test()
3769 info->testing_irq = false; in irq_test()
3771 spin_lock_irqsave(&info->lock, flags); in irq_test()
3773 spin_unlock_irqrestore(&info->lock, flags); in irq_test()
3775 return info->irq_occurred; in irq_test()
3781 info->init_error = DiagStatus_AddressFailure; in adapter_test()
3783 __FILE__, __LINE__, info->device_name, (unsigned short)(info->io_base)); in adapter_test()
3784 return -ENODEV; in adapter_test()
3788 info->init_error = DiagStatus_IrqFailure; in adapter_test()
3790 __FILE__, __LINE__, info->device_name, (unsigned short)(info->irq_level)); in adapter_test()
3791 return -ENODEV; in adapter_test()
3796 __FILE__, __LINE__, info->device_name); in adapter_test()
3805 printk("%s tx data:\n", info->device_name); in trace_block()
3807 printk("%s rx data:\n", info->device_name); in trace_block()
3828 count -= linecount; in trace_block()
3842 __FILE__, __LINE__, info->device_name); in tx_timeout()
3843 if (info->tx_active && in tx_timeout()
3844 info->params.mode == MGSL_MODE_HDLC) { in tx_timeout()
3845 info->icount.txtimeout++; in tx_timeout()
3847 spin_lock_irqsave(&info->lock, flags); in tx_timeout()
3848 info->tx_active = false; in tx_timeout()
3849 info->tx_count = info->tx_put = info->tx_get = 0; in tx_timeout()
3851 spin_unlock_irqrestore(&info->lock, flags); in tx_timeout()
3854 if (info->netcount) in tx_timeout()
3859 struct tty_struct *tty = tty_port_tty_get(&info->port); in tx_timeout()
3886 if (info->port.count) in hdlcdev_attach()
3887 return -EBUSY; in hdlcdev_attach()
3896 default: return -EINVAL; in hdlcdev_attach()
3904 default: return -EINVAL; in hdlcdev_attach()
3907 info->params.encoding = new_encoding; in hdlcdev_attach()
3908 info->params.crc_type = new_crctype; in hdlcdev_attach()
3911 if (info->netcount) { in hdlcdev_attach()
3912 tty = tty_port_tty_get(&info->port); in hdlcdev_attach()
3933 printk(KERN_INFO "%s:hdlc_xmit(%s)\n", __FILE__, dev->name); in hdlcdev_xmit()
3939 skb_copy_from_linear_data(skb, info->tx_buf, skb->len); in hdlcdev_xmit()
3940 info->tx_get = 0; in hdlcdev_xmit()
3941 info->tx_put = info->tx_count = skb->len; in hdlcdev_xmit()
3944 dev->stats.tx_packets++; in hdlcdev_xmit()
3945 dev->stats.tx_bytes += skb->len; in hdlcdev_xmit()
3954 spin_lock_irqsave(&info->lock, flags); in hdlcdev_xmit()
3955 if (!info->tx_active) { in hdlcdev_xmit()
3956 struct tty_struct *tty = tty_port_tty_get(&info->port); in hdlcdev_xmit()
3960 spin_unlock_irqrestore(&info->lock, flags); in hdlcdev_xmit()
3981 printk("%s:hdlcdev_open(%s)\n", __FILE__, dev->name); in hdlcdev_open()
3989 spin_lock_irqsave(&info->netlock, flags); in hdlcdev_open()
3990 if (info->port.count != 0 || info->netcount != 0) { in hdlcdev_open()
3991 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name); in hdlcdev_open()
3992 spin_unlock_irqrestore(&info->netlock, flags); in hdlcdev_open()
3993 return -EBUSY; in hdlcdev_open()
3995 info->netcount=1; in hdlcdev_open()
3996 spin_unlock_irqrestore(&info->netlock, flags); in hdlcdev_open()
3998 tty = tty_port_tty_get(&info->port); in hdlcdev_open()
4003 spin_lock_irqsave(&info->netlock, flags); in hdlcdev_open()
4004 info->netcount=0; in hdlcdev_open()
4005 spin_unlock_irqrestore(&info->netlock, flags); in hdlcdev_open()
4009 info->serial_signals |= SerialSignal_RTS | SerialSignal_DTR; in hdlcdev_open()
4018 spin_lock_irqsave(&info->lock, flags); in hdlcdev_open()
4020 spin_unlock_irqrestore(&info->lock, flags); in hdlcdev_open()
4021 if (info->serial_signals & SerialSignal_DCD) in hdlcdev_open()
4039 struct tty_struct *tty = tty_port_tty_get(&info->port); in hdlcdev_close()
4043 printk("%s:hdlcdev_close(%s)\n", __FILE__, dev->name); in hdlcdev_close()
4052 spin_lock_irqsave(&info->netlock, flags); in hdlcdev_close()
4053 info->netcount=0; in hdlcdev_close()
4054 spin_unlock_irqrestore(&info->netlock, flags); in hdlcdev_close()
4072 sync_serial_settings __user *line = ifr->ifr_settings.ifs_ifsu.sync; in hdlcdev_ioctl()
4077 printk("%s:hdlcdev_ioctl(%s)\n", __FILE__, dev->name); in hdlcdev_ioctl()
4080 if (info->port.count) in hdlcdev_ioctl()
4081 return -EBUSY; in hdlcdev_ioctl()
4088 switch(ifr->ifr_settings.type) { in hdlcdev_ioctl()
4091 ifr->ifr_settings.type = IF_IFACE_SYNC_SERIAL; in hdlcdev_ioctl()
4092 if (ifr->ifr_settings.size < size) { in hdlcdev_ioctl()
4093 ifr->ifr_settings.size = size; /* data size wanted */ in hdlcdev_ioctl()
4094 return -ENOBUFS; in hdlcdev_ioctl()
4097 flags = info->params.flags & (HDLC_FLAG_RXC_RXCPIN | HDLC_FLAG_RXC_DPLL | in hdlcdev_ioctl()
4110 new_line.clock_rate = info->params.clock_speed; in hdlcdev_ioctl()
4111 new_line.loopback = info->params.loopback ? 1:0; in hdlcdev_ioctl()
4114 return -EFAULT; in hdlcdev_ioctl()
4120 return -EPERM; in hdlcdev_ioctl()
4122 return -EFAULT; in hdlcdev_ioctl()
4130 case CLOCK_DEFAULT: flags = info->params.flags & in hdlcdev_ioctl()
4135 default: return -EINVAL; in hdlcdev_ioctl()
4139 return -EINVAL; in hdlcdev_ioctl()
4141 info->params.flags &= ~(HDLC_FLAG_RXC_RXCPIN | HDLC_FLAG_RXC_DPLL | in hdlcdev_ioctl()
4145 info->params.flags |= flags; in hdlcdev_ioctl()
4147 info->params.loopback = new_line.loopback; in hdlcdev_ioctl()
4150 info->params.clock_speed = new_line.clock_rate; in hdlcdev_ioctl()
4152 info->params.clock_speed = 0; in hdlcdev_ioctl()
4155 if (info->netcount) { in hdlcdev_ioctl()
4156 struct tty_struct *tty = tty_port_tty_get(&info->port); in hdlcdev_ioctl()
4178 printk("hdlcdev_tx_timeout(%s)\n", dev->name); in hdlcdev_tx_timeout()
4180 dev->stats.tx_errors++; in hdlcdev_tx_timeout()
4181 dev->stats.tx_aborted_errors++; in hdlcdev_tx_timeout()
4183 spin_lock_irqsave(&info->lock, flags); in hdlcdev_tx_timeout()
4185 spin_unlock_irqrestore(&info->lock, flags); in hdlcdev_tx_timeout()
4198 if (netif_queue_stopped(info->netdev)) in hdlcdev_tx_done()
4199 netif_wake_queue(info->netdev); in hdlcdev_tx_done()
4213 struct net_device *dev = info->netdev; in hdlcdev_rx()
4216 printk("hdlcdev_rx(%s)\n", dev->name); in hdlcdev_rx()
4219 printk(KERN_NOTICE "%s: can't alloc skb, dropping packet\n", dev->name); in hdlcdev_rx()
4220 dev->stats.rx_dropped++; in hdlcdev_rx()
4226 skb->protocol = hdlc_type_trans(skb, dev); in hdlcdev_rx()
4228 dev->stats.rx_packets++; in hdlcdev_rx()
4229 dev->stats.rx_bytes += size; in hdlcdev_rx()
4261 return -ENOMEM; in hdlcdev_init()
4265 dev->base_addr = info->io_base; in hdlcdev_init()
4266 dev->irq = info->irq_level; in hdlcdev_init()
4269 dev->netdev_ops = &hdlcdev_ops; in hdlcdev_init()
4270 dev->watchdog_timeo = 10 * HZ; in hdlcdev_init()
4271 dev->tx_queue_len = 50; in hdlcdev_init()
4275 hdlc->attach = hdlcdev_attach; in hdlcdev_init()
4276 hdlc->xmit = hdlcdev_xmit; in hdlcdev_init()
4286 info->netdev = dev; in hdlcdev_init()
4298 unregister_hdlc_device(info->netdev); in hdlcdev_exit()
4299 free_netdev(info->netdev); in hdlcdev_exit()
4300 info->netdev = NULL; in hdlcdev_exit()