Lines Matching +full:dcd +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) */
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 init_waitqueue_head(&info->status_event_wait_q); in mgslpc_probe()
534 init_waitqueue_head(&info->event_wait_q); in mgslpc_probe()
535 spin_lock_init(&info->lock); in mgslpc_probe()
536 spin_lock_init(&info->netlock); in mgslpc_probe()
537 memcpy(&info->params,&default_params,sizeof(MGSL_PARAMS)); in mgslpc_probe()
538 info->idle_mode = HDLC_TXIDLE_FLAGS; in mgslpc_probe()
539 info->imra_value = 0xffff; in mgslpc_probe()
540 info->imrb_value = 0xffff; in mgslpc_probe()
541 info->pim_value = 0xff; in mgslpc_probe()
543 info->p_dev = link; in mgslpc_probe()
544 link->priv = info; in mgslpc_probe()
561 tty_port_destroy(&info->port); in mgslpc_probe()
576 MGSLPC_INFO *info = link->priv; in mgslpc_config()
582 link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO; in mgslpc_config()
588 link->config_index = 8; in mgslpc_config()
589 link->config_regs = PRESENT_OPTION; in mgslpc_config()
598 info->io_base = link->resource[0]->start; in mgslpc_config()
599 info->irq_level = link->irq; in mgslpc_config()
604 return -ENODEV; in mgslpc_config()
626 ((MGSLPC_INFO *)link->priv)->stop = 1; in mgslpc_detach()
629 mgslpc_remove_device((MGSLPC_INFO *)link->priv); in mgslpc_detach()
634 MGSLPC_INFO *info = link->priv; in mgslpc_suspend()
636 info->stop = 1; in mgslpc_suspend()
643 MGSLPC_INFO *info = link->priv; in mgslpc_resume()
645 info->stop = 0; in mgslpc_resume()
664 if (info->magic != MGSLPC_MAGIC) { in mgslpc_paranoia_check()
704 MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; in tx_pause()
707 if (mgslpc_paranoia_check(info, tty->name, "tx_pause")) in tx_pause()
710 printk("tx_pause(%s)\n", info->device_name); in tx_pause()
712 spin_lock_irqsave(&info->lock, flags); in tx_pause()
713 if (info->tx_enabled) in tx_pause()
715 spin_unlock_irqrestore(&info->lock, flags); in tx_pause()
720 MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; in tx_release()
723 if (mgslpc_paranoia_check(info, tty->name, "tx_release")) in tx_release()
726 printk("tx_release(%s)\n", info->device_name); in tx_release()
728 spin_lock_irqsave(&info->lock, flags); in tx_release()
729 if (!info->tx_enabled) in tx_release()
731 spin_unlock_irqrestore(&info->lock, flags); in tx_release()
742 spin_lock_irqsave(&info->lock, flags); in bh_action()
744 if (info->pending_bh & BH_RECEIVE) { in bh_action()
745 info->pending_bh &= ~BH_RECEIVE; in bh_action()
747 } else if (info->pending_bh & BH_TRANSMIT) { in bh_action()
748 info->pending_bh &= ~BH_TRANSMIT; in bh_action()
750 } else if (info->pending_bh & BH_STATUS) { in bh_action()
751 info->pending_bh &= ~BH_STATUS; in bh_action()
757 info->bh_running = false; in bh_action()
758 info->bh_requested = false; in bh_action()
761 spin_unlock_irqrestore(&info->lock, flags); in bh_action()
774 __FILE__,__LINE__,info->device_name); in bh_handler()
776 info->bh_running = true; in bh_handler()
777 tty = tty_port_tty_get(&info->port); in bh_handler()
807 __FILE__,__LINE__,info->device_name); in bh_handler()
813 printk("bh_transmit() entry on %s\n", info->device_name); in bh_transmit()
821 info->ri_chkcount = 0; in bh_status()
822 info->dsr_chkcount = 0; in bh_status()
823 info->dcd_chkcount = 0; in bh_status()
824 info->cts_chkcount = 0; in bh_status()
827 /* eom: non-zero = end of frame */
832 RXBUF *buf = (RXBUF*)(info->rx_buf + (info->rx_put * info->rx_buf_size)); in rx_ready_hdlc()
837 if (!info->rx_enabled) in rx_ready_hdlc()
840 if (info->rx_frame_count >= info->rx_buf_count) { in rx_ready_hdlc()
843 info->pending_bh |= BH_RECEIVE; in rx_ready_hdlc()
844 info->rx_overflow = true; in rx_ready_hdlc()
845 info->icount.buf_overrun++; in rx_ready_hdlc()
865 fifo_count -= read_count; in rx_ready_hdlc()
867 buf->status = data[--read_count]; in rx_ready_hdlc()
870 if (buf->count >= info->max_frame_size) { in rx_ready_hdlc()
873 buf->count = 0; in rx_ready_hdlc()
876 *(buf->data + buf->count) = data[i]; in rx_ready_hdlc()
877 buf->count++; in rx_ready_hdlc()
882 info->pending_bh |= BH_RECEIVE; in rx_ready_hdlc()
883 info->rx_frame_count++; in rx_ready_hdlc()
884 info->rx_put++; in rx_ready_hdlc()
885 if (info->rx_put >= info->rx_buf_count) in rx_ready_hdlc()
886 info->rx_put = 0; in rx_ready_hdlc()
893 struct tty_port *port = &info->port; in rx_ready_async()
897 struct mgsl_icount *icount = &info->icount; in rx_ready_async()
916 fifo_count -= 2; in rx_ready_async()
918 icount->rx++; in rx_ready_async()
927 icount->parity++; in rx_ready_async()
929 icount->frame++; in rx_ready_async()
932 if (status & info->ignore_status_mask) in rx_ready_async()
935 status &= info->read_status_mask; in rx_ready_async()
950 __FILE__,__LINE__,icount->rx,icount->brk, in rx_ready_async()
951 icount->parity,icount->frame,icount->overrun); in rx_ready_async()
961 if (!info->tx_active) in tx_done()
964 info->tx_active = false; in tx_done()
965 info->tx_aborting = false; in tx_done()
967 if (info->params.mode == MGSL_MODE_ASYNC) in tx_done()
970 info->tx_count = info->tx_put = info->tx_get = 0; in tx_done()
971 del_timer(&info->tx_timer); in tx_done()
973 if (info->drop_rts_on_tx_done) { in tx_done()
975 if (info->serial_signals & SerialSignal_RTS) { in tx_done()
976 info->serial_signals &= ~SerialSignal_RTS; in tx_done()
979 info->drop_rts_on_tx_done = false; in tx_done()
983 if (info->netcount) in tx_done()
988 if (tty && (tty->flow.stopped || tty->hw_stopped)) { in tx_done()
992 info->pending_bh |= BH_TRANSMIT; in tx_done()
1002 printk("%s(%d):tx_ready(%s)\n", __FILE__, __LINE__, info->device_name); in tx_ready()
1004 if (info->params.mode == MGSL_MODE_HDLC) { in tx_ready()
1005 if (!info->tx_active) in tx_ready()
1008 if (tty && (tty->flow.stopped || tty->hw_stopped)) { in tx_ready()
1012 if (!info->tx_count) in tx_ready()
1013 info->tx_active = false; in tx_ready()
1016 if (!info->tx_count) in tx_ready()
1019 while (info->tx_count && fifo_count) { in tx_ready()
1020 c = min(2, min_t(int, fifo_count, min(info->tx_count, TXBUFSIZE - info->tx_get))); in tx_ready()
1023 write_reg(info, CHA + TXFIFO, *(info->tx_buf + info->tx_get)); in tx_ready()
1026 *((unsigned short*)(info->tx_buf + info->tx_get))); in tx_ready()
1028 info->tx_count -= c; in tx_ready()
1029 info->tx_get = (info->tx_get + c) & (TXBUFSIZE - 1); in tx_ready()
1030 fifo_count -= c; in tx_ready()
1033 if (info->params.mode == MGSL_MODE_ASYNC) { in tx_ready()
1034 if (info->tx_count < WAKEUP_CHARS) in tx_ready()
1035 info->pending_bh |= BH_TRANSMIT; in tx_ready()
1038 if (info->tx_count) in tx_ready()
1048 if ((info->cts_chkcount)++ >= IO_PIN_SHUTDOWN_LIMIT) in cts_change()
1050 info->icount.cts++; in cts_change()
1051 if (info->serial_signals & SerialSignal_CTS) in cts_change()
1052 info->input_signal_events.cts_up++; in cts_change()
1054 info->input_signal_events.cts_down++; in cts_change()
1055 wake_up_interruptible(&info->status_event_wait_q); in cts_change()
1056 wake_up_interruptible(&info->event_wait_q); in cts_change()
1058 if (tty && tty_port_cts_enabled(&info->port)) { in cts_change()
1059 if (tty->hw_stopped) { in cts_change()
1060 if (info->serial_signals & SerialSignal_CTS) { in cts_change()
1063 tty->hw_stopped = 0; in cts_change()
1065 info->pending_bh |= BH_TRANSMIT; in cts_change()
1069 if (!(info->serial_signals & SerialSignal_CTS)) { in cts_change()
1072 tty->hw_stopped = 1; in cts_change()
1077 info->pending_bh |= BH_STATUS; in cts_change()
1083 if ((info->dcd_chkcount)++ >= IO_PIN_SHUTDOWN_LIMIT) in dcd_change()
1085 info->icount.dcd++; in dcd_change()
1086 if (info->serial_signals & SerialSignal_DCD) { in dcd_change()
1087 info->input_signal_events.dcd_up++; in dcd_change()
1090 info->input_signal_events.dcd_down++; in dcd_change()
1092 if (info->netcount) { in dcd_change()
1093 if (info->serial_signals & SerialSignal_DCD) in dcd_change()
1094 netif_carrier_on(info->netdev); in dcd_change()
1096 netif_carrier_off(info->netdev); in dcd_change()
1099 wake_up_interruptible(&info->status_event_wait_q); in dcd_change()
1100 wake_up_interruptible(&info->event_wait_q); in dcd_change()
1102 if (tty_port_check_carrier(&info->port)) { in dcd_change()
1104 printk("%s CD now %s...", info->device_name, in dcd_change()
1105 (info->serial_signals & SerialSignal_DCD) ? "on" : "off"); in dcd_change()
1106 if (info->serial_signals & SerialSignal_DCD) in dcd_change()
1107 wake_up_interruptible(&info->port.open_wait); in dcd_change()
1115 info->pending_bh |= BH_STATUS; in dcd_change()
1121 if ((info->dsr_chkcount)++ >= IO_PIN_SHUTDOWN_LIMIT) in dsr_change()
1123 info->icount.dsr++; in dsr_change()
1124 if (info->serial_signals & SerialSignal_DSR) in dsr_change()
1125 info->input_signal_events.dsr_up++; in dsr_change()
1127 info->input_signal_events.dsr_down++; in dsr_change()
1128 wake_up_interruptible(&info->status_event_wait_q); in dsr_change()
1129 wake_up_interruptible(&info->event_wait_q); in dsr_change()
1130 info->pending_bh |= BH_STATUS; in dsr_change()
1136 if ((info->ri_chkcount)++ >= IO_PIN_SHUTDOWN_LIMIT) in ri_change()
1138 info->icount.rng++; in ri_change()
1139 if (info->serial_signals & SerialSignal_RI) in ri_change()
1140 info->input_signal_events.ri_up++; in ri_change()
1142 info->input_signal_events.ri_down++; in ri_change()
1143 wake_up_interruptible(&info->status_event_wait_q); in ri_change()
1144 wake_up_interruptible(&info->event_wait_q); in ri_change()
1145 info->pending_bh |= BH_STATUS; in ri_change()
1164 printk("mgslpc_isr(%d) entry.\n", info->irq_level); in mgslpc_isr()
1166 if (!(info->p_dev->_locked)) in mgslpc_isr()
1169 tty = tty_port_tty_get(&info->port); in mgslpc_isr()
1171 spin_lock(&info->lock); in mgslpc_isr()
1175 printk("mgslpc_isr %s gis=%04X\n", info->device_name,gis); in mgslpc_isr()
1194 info->irq_occurred = true; in mgslpc_isr()
1200 info->icount.exithunt++; in mgslpc_isr()
1201 wake_up_interruptible(&info->event_wait_q); in mgslpc_isr()
1204 info->icount.brk++; in mgslpc_isr()
1205 if (info->port.flags & ASYNC_SAK) in mgslpc_isr()
1212 if (info->params.mode == MGSL_MODE_HDLC) in mgslpc_isr()
1220 if (info->tx_aborting) in mgslpc_isr()
1221 info->icount.txabort++; in mgslpc_isr()
1223 info->icount.txunder++; in mgslpc_isr()
1227 info->icount.txok++; in mgslpc_isr()
1246 if (info->pending_bh && !info->bh_running && !info->bh_requested) { in mgslpc_isr()
1249 __FILE__,__LINE__,info->device_name); in mgslpc_isr()
1250 schedule_work(&info->task); in mgslpc_isr()
1251 info->bh_requested = true; in mgslpc_isr()
1254 spin_unlock(&info->lock); in mgslpc_isr()
1259 __FILE__, __LINE__, info->irq_level); in mgslpc_isr()
1271 printk("%s(%d):startup(%s)\n", __FILE__, __LINE__, info->device_name); in startup()
1273 if (tty_port_initialized(&info->port)) in startup()
1276 if (!info->tx_buf) { in startup()
1278 info->tx_buf = (unsigned char *)get_zeroed_page(GFP_KERNEL); in startup()
1279 if (!info->tx_buf) { in startup()
1281 __FILE__, __LINE__, info->device_name); in startup()
1282 return -ENOMEM; in startup()
1286 info->pending_bh = 0; in startup()
1288 memset(&info->icount, 0, sizeof(info->icount)); in startup()
1290 timer_setup(&info->tx_timer, tx_timeout, 0); in startup()
1301 set_bit(TTY_IO_ERROR, &tty->flags); in startup()
1310 clear_bit(TTY_IO_ERROR, &tty->flags); in startup()
1312 tty_port_set_initialized(&info->port, 1); in startup()
1323 if (!tty_port_initialized(&info->port)) in shutdown()
1328 __FILE__, __LINE__, info->device_name); in shutdown()
1332 wake_up_interruptible(&info->status_event_wait_q); in shutdown()
1333 wake_up_interruptible(&info->event_wait_q); in shutdown()
1335 del_timer_sync(&info->tx_timer); in shutdown()
1337 if (info->tx_buf) { in shutdown()
1338 free_page((unsigned long) info->tx_buf); in shutdown()
1339 info->tx_buf = NULL; in shutdown()
1342 spin_lock_irqsave(&info->lock, flags); in shutdown()
1351 info->serial_signals &= ~(SerialSignal_RTS | SerialSignal_DTR); in shutdown()
1355 spin_unlock_irqrestore(&info->lock, flags); in shutdown()
1360 set_bit(TTY_IO_ERROR, &tty->flags); in shutdown()
1362 tty_port_set_initialized(&info->port, 0); in shutdown()
1369 spin_lock_irqsave(&info->lock, flags); in mgslpc_program_hw()
1373 info->tx_count = info->tx_put = info->tx_get = 0; in mgslpc_program_hw()
1375 if (info->params.mode == MGSL_MODE_HDLC || info->netcount) in mgslpc_program_hw()
1382 info->dcd_chkcount = 0; in mgslpc_program_hw()
1383 info->cts_chkcount = 0; in mgslpc_program_hw()
1384 info->ri_chkcount = 0; in mgslpc_program_hw()
1385 info->dsr_chkcount = 0; in mgslpc_program_hw()
1391 if (info->netcount || (tty && C_CREAD(tty))) in mgslpc_program_hw()
1394 spin_unlock_irqrestore(&info->lock, flags); in mgslpc_program_hw()
1409 __FILE__, __LINE__, info->device_name); in mgslpc_change_params()
1411 cflag = tty->termios.c_cflag; in mgslpc_change_params()
1416 info->serial_signals |= SerialSignal_RTS | SerialSignal_DTR; in mgslpc_change_params()
1418 info->serial_signals &= ~(SerialSignal_RTS | SerialSignal_DTR); in mgslpc_change_params()
1424 tty->termios.c_cflag = cflag; in mgslpc_change_params()
1426 info->params.data_bits = tty_get_char_size(cflag); in mgslpc_change_params()
1429 info->params.stop_bits = 2; in mgslpc_change_params()
1431 info->params.stop_bits = 1; in mgslpc_change_params()
1433 info->params.parity = ASYNC_PARITY_NONE; in mgslpc_change_params()
1436 info->params.parity = ASYNC_PARITY_ODD; in mgslpc_change_params()
1438 info->params.parity = ASYNC_PARITY_EVEN; in mgslpc_change_params()
1440 info->params.parity = ASYNC_PARITY_SPACE; in mgslpc_change_params()
1446 bits_per_char = info->params.data_bits + in mgslpc_change_params()
1447 info->params.stop_bits + 1; in mgslpc_change_params()
1450 * allow tty settings to override, otherwise keep the in mgslpc_change_params()
1453 if (info->params.data_rate <= 460800) { in mgslpc_change_params()
1454 info->params.data_rate = tty_get_baud_rate(tty); in mgslpc_change_params()
1457 if (info->params.data_rate) { in mgslpc_change_params()
1458 info->timeout = (32*HZ*bits_per_char) / in mgslpc_change_params()
1459 info->params.data_rate; in mgslpc_change_params()
1461 info->timeout += HZ/50; /* Add .02 seconds of slop */ in mgslpc_change_params()
1463 tty_port_set_cts_flow(&info->port, cflag & CRTSCTS); in mgslpc_change_params()
1464 tty_port_set_check_carrier(&info->port, ~cflag & CLOCAL); in mgslpc_change_params()
1468 info->read_status_mask = 0; in mgslpc_change_params()
1470 info->read_status_mask |= BIT7 | BIT6; in mgslpc_change_params()
1472 info->ignore_status_mask |= BIT7 | BIT6; in mgslpc_change_params()
1481 MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; in mgslpc_put_char()
1486 __FILE__, __LINE__, ch, info->device_name); in mgslpc_put_char()
1489 if (mgslpc_paranoia_check(info, tty->name, "mgslpc_put_char")) in mgslpc_put_char()
1492 if (!info->tx_buf) in mgslpc_put_char()
1495 spin_lock_irqsave(&info->lock, flags); in mgslpc_put_char()
1497 if (info->params.mode == MGSL_MODE_ASYNC || !info->tx_active) { in mgslpc_put_char()
1498 if (info->tx_count < TXBUFSIZE - 1) { in mgslpc_put_char()
1499 info->tx_buf[info->tx_put++] = ch; in mgslpc_put_char()
1500 info->tx_put &= TXBUFSIZE-1; in mgslpc_put_char()
1501 info->tx_count++; in mgslpc_put_char()
1505 spin_unlock_irqrestore(&info->lock, flags); in mgslpc_put_char()
1514 MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; in mgslpc_flush_chars()
1519 __FILE__, __LINE__, info->device_name, info->tx_count); in mgslpc_flush_chars()
1521 if (mgslpc_paranoia_check(info, tty->name, "mgslpc_flush_chars")) in mgslpc_flush_chars()
1524 if (info->tx_count <= 0 || tty->flow.stopped || in mgslpc_flush_chars()
1525 tty->hw_stopped || !info->tx_buf) in mgslpc_flush_chars()
1530 __FILE__, __LINE__, info->device_name); in mgslpc_flush_chars()
1532 spin_lock_irqsave(&info->lock, flags); in mgslpc_flush_chars()
1533 if (!info->tx_active) in mgslpc_flush_chars()
1535 spin_unlock_irqrestore(&info->lock, flags); in mgslpc_flush_chars()
1552 MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; in mgslpc_write()
1557 __FILE__, __LINE__, info->device_name, count); in mgslpc_write()
1559 if (mgslpc_paranoia_check(info, tty->name, "mgslpc_write") || in mgslpc_write()
1560 !info->tx_buf) in mgslpc_write()
1563 if (info->params.mode == MGSL_MODE_HDLC) { in mgslpc_write()
1565 ret = -EIO; in mgslpc_write()
1568 if (info->tx_active) in mgslpc_write()
1570 else if (info->tx_count) in mgslpc_write()
1576 min(TXBUFSIZE - info->tx_count - 1, in mgslpc_write()
1577 TXBUFSIZE - info->tx_put)); in mgslpc_write()
1581 memcpy(info->tx_buf + info->tx_put, buf, c); in mgslpc_write()
1583 spin_lock_irqsave(&info->lock, flags); in mgslpc_write()
1584 info->tx_put = (info->tx_put + c) & (TXBUFSIZE-1); in mgslpc_write()
1585 info->tx_count += c; in mgslpc_write()
1586 spin_unlock_irqrestore(&info->lock, flags); in mgslpc_write()
1589 count -= c; in mgslpc_write()
1593 if (info->tx_count && !tty->flow.stopped && !tty->hw_stopped) { in mgslpc_write()
1594 spin_lock_irqsave(&info->lock, flags); in mgslpc_write()
1595 if (!info->tx_active) in mgslpc_write()
1597 spin_unlock_irqrestore(&info->lock, flags); in mgslpc_write()
1602 __FILE__, __LINE__, info->device_name, ret); in mgslpc_write()
1610 MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; in mgslpc_write_room()
1613 if (mgslpc_paranoia_check(info, tty->name, "mgslpc_write_room")) in mgslpc_write_room()
1616 if (info->params.mode == MGSL_MODE_HDLC) { in mgslpc_write_room()
1618 if (info->tx_active) in mgslpc_write_room()
1623 ret = TXBUFSIZE - info->tx_count - 1; in mgslpc_write_room()
1630 __FILE__, __LINE__, info->device_name, ret); in mgslpc_write_room()
1638 MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; in mgslpc_chars_in_buffer()
1643 __FILE__, __LINE__, info->device_name); in mgslpc_chars_in_buffer()
1645 if (mgslpc_paranoia_check(info, tty->name, "mgslpc_chars_in_buffer")) in mgslpc_chars_in_buffer()
1648 if (info->params.mode == MGSL_MODE_HDLC) in mgslpc_chars_in_buffer()
1649 rc = info->tx_active ? info->max_frame_size : 0; in mgslpc_chars_in_buffer()
1651 rc = info->tx_count; in mgslpc_chars_in_buffer()
1655 __FILE__, __LINE__, info->device_name, rc); in mgslpc_chars_in_buffer()
1664 MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; in mgslpc_flush_buffer()
1669 __FILE__, __LINE__, info->device_name); in mgslpc_flush_buffer()
1671 if (mgslpc_paranoia_check(info, tty->name, "mgslpc_flush_buffer")) in mgslpc_flush_buffer()
1674 spin_lock_irqsave(&info->lock, flags); in mgslpc_flush_buffer()
1675 info->tx_count = info->tx_put = info->tx_get = 0; in mgslpc_flush_buffer()
1676 del_timer(&info->tx_timer); in mgslpc_flush_buffer()
1677 spin_unlock_irqrestore(&info->lock, flags); in mgslpc_flush_buffer()
1679 wake_up_interruptible(&tty->write_wait); in mgslpc_flush_buffer()
1683 /* Send a high-priority XON/XOFF character
1687 MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; in mgslpc_send_xchar()
1692 __FILE__, __LINE__, info->device_name, ch); in mgslpc_send_xchar()
1694 if (mgslpc_paranoia_check(info, tty->name, "mgslpc_send_xchar")) in mgslpc_send_xchar()
1697 info->x_char = ch; in mgslpc_send_xchar()
1699 spin_lock_irqsave(&info->lock, flags); in mgslpc_send_xchar()
1700 if (!info->tx_enabled) in mgslpc_send_xchar()
1702 spin_unlock_irqrestore(&info->lock, flags); in mgslpc_send_xchar()
1710 MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; in mgslpc_throttle()
1715 __FILE__, __LINE__, info->device_name); in mgslpc_throttle()
1717 if (mgslpc_paranoia_check(info, tty->name, "mgslpc_throttle")) in mgslpc_throttle()
1724 spin_lock_irqsave(&info->lock, flags); in mgslpc_throttle()
1725 info->serial_signals &= ~SerialSignal_RTS; in mgslpc_throttle()
1727 spin_unlock_irqrestore(&info->lock, flags); in mgslpc_throttle()
1735 MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; in mgslpc_unthrottle()
1740 __FILE__, __LINE__, info->device_name); in mgslpc_unthrottle()
1742 if (mgslpc_paranoia_check(info, tty->name, "mgslpc_unthrottle")) in mgslpc_unthrottle()
1746 if (info->x_char) in mgslpc_unthrottle()
1747 info->x_char = 0; in mgslpc_unthrottle()
1753 spin_lock_irqsave(&info->lock, flags); in mgslpc_unthrottle()
1754 info->serial_signals |= SerialSignal_RTS; in mgslpc_unthrottle()
1756 spin_unlock_irqrestore(&info->lock, flags); in mgslpc_unthrottle()
1766 printk("get_params(%s)\n", info->device_name); in get_stats()
1768 memset(&info->icount, 0, sizeof(info->icount)); in get_stats()
1770 COPY_TO_USER(err, user_icount, &info->icount, sizeof(struct mgsl_icount)); in get_stats()
1772 return -EFAULT; in get_stats()
1783 printk("get_params(%s)\n", info->device_name); in get_params()
1784 COPY_TO_USER(err,user_params, &info->params, sizeof(MGSL_PARAMS)); in get_params()
1786 return -EFAULT; in get_params()
1807 info->device_name); in set_params()
1812 __FILE__, __LINE__, info->device_name); in set_params()
1813 return -EFAULT; in set_params()
1816 spin_lock_irqsave(&info->lock, flags); in set_params()
1817 memcpy(&info->params,&tmp_params,sizeof(MGSL_PARAMS)); in set_params()
1818 spin_unlock_irqrestore(&info->lock, flags); in set_params()
1829 printk("get_txidle(%s)=%d\n", info->device_name, info->idle_mode); in get_txidle()
1830 COPY_TO_USER(err,idle_mode, &info->idle_mode, sizeof(int)); in get_txidle()
1832 return -EFAULT; in get_txidle()
1840 printk("set_txidle(%s,%d)\n", info->device_name, idle_mode); in set_txidle()
1841 spin_lock_irqsave(&info->lock, flags); in set_txidle()
1842 info->idle_mode = idle_mode; in set_txidle()
1844 spin_unlock_irqrestore(&info->lock, flags); in set_txidle()
1852 printk("get_interface(%s)=%d\n", info->device_name, info->if_mode); in get_interface()
1853 COPY_TO_USER(err,if_mode, &info->if_mode, sizeof(int)); in get_interface()
1855 return -EFAULT; in get_interface()
1864 printk("set_interface(%s,%d)\n", info->device_name, if_mode); in set_interface()
1865 spin_lock_irqsave(&info->lock, flags); in set_interface()
1866 info->if_mode = if_mode; in set_interface()
1869 switch (info->if_mode) in set_interface()
1877 spin_unlock_irqrestore(&info->lock, flags); in set_interface()
1886 printk("set_txenable(%s,%d)\n", info->device_name, enable); in set_txenable()
1888 spin_lock_irqsave(&info->lock, flags); in set_txenable()
1890 if (!info->tx_enabled) in set_txenable()
1893 if (info->tx_enabled) in set_txenable()
1896 spin_unlock_irqrestore(&info->lock, flags); in set_txenable()
1905 printk("tx_abort(%s)\n", info->device_name); in tx_abort()
1907 spin_lock_irqsave(&info->lock, flags); in tx_abort()
1908 if (info->tx_active && info->tx_count && in tx_abort()
1909 info->params.mode == MGSL_MODE_HDLC) { in tx_abort()
1913 info->tx_count = info->tx_put = info->tx_get = 0; in tx_abort()
1914 info->tx_aborting = true; in tx_abort()
1916 spin_unlock_irqrestore(&info->lock, flags); in tx_abort()
1925 printk("set_rxenable(%s,%d)\n", info->device_name, enable); in set_rxenable()
1927 spin_lock_irqsave(&info->lock, flags); in set_rxenable()
1929 if (!info->rx_enabled) in set_rxenable()
1932 if (info->rx_enabled) in set_rxenable()
1935 spin_unlock_irqrestore(&info->lock, flags); in set_rxenable()
1960 return -EFAULT; in wait_events()
1963 printk("wait_events(%s,%d)\n", info->device_name, mask); in wait_events()
1965 spin_lock_irqsave(&info->lock, flags); in wait_events()
1969 s = info->serial_signals; in wait_events()
1976 spin_unlock_irqrestore(&info->lock, flags); in wait_events()
1981 cprev = info->icount; in wait_events()
1982 oldsigs = info->input_signal_events; in wait_events()
1984 if ((info->params.mode == MGSL_MODE_HDLC) && in wait_events()
1989 add_wait_queue(&info->event_wait_q, &wait); in wait_events()
1991 spin_unlock_irqrestore(&info->lock, flags); in wait_events()
1997 rc = -ERESTARTSYS; in wait_events()
2002 spin_lock_irqsave(&info->lock, flags); in wait_events()
2003 cnow = info->icount; in wait_events()
2004 newsigs = info->input_signal_events; in wait_events()
2006 spin_unlock_irqrestore(&info->lock, flags); in wait_events()
2019 rc = -EIO; in wait_events()
2041 remove_wait_queue(&info->event_wait_q, &wait); in wait_events()
2045 spin_lock_irqsave(&info->lock, flags); in wait_events()
2046 if (!waitqueue_active(&info->event_wait_q)) in wait_events()
2048 spin_unlock_irqrestore(&info->lock, flags); in wait_events()
2064 spin_lock_irqsave(&info->lock, flags); in modem_input_wait()
2065 cprev = info->icount; in modem_input_wait()
2066 add_wait_queue(&info->status_event_wait_q, &wait); in modem_input_wait()
2068 spin_unlock_irqrestore(&info->lock, flags); in modem_input_wait()
2073 rc = -ERESTARTSYS; in modem_input_wait()
2078 spin_lock_irqsave(&info->lock, flags); in modem_input_wait()
2079 cnow = info->icount; in modem_input_wait()
2081 spin_unlock_irqrestore(&info->lock, flags); in modem_input_wait()
2085 cnow.dcd == cprev.dcd && cnow.cts == cprev.cts) { in modem_input_wait()
2086 rc = -EIO; in modem_input_wait()
2093 (arg & TIOCM_CD && cnow.dcd != cprev.dcd) || in modem_input_wait()
2101 remove_wait_queue(&info->status_event_wait_q, &wait); in modem_input_wait()
2110 MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; in tiocmget()
2114 spin_lock_irqsave(&info->lock, flags); in tiocmget()
2116 spin_unlock_irqrestore(&info->lock, flags); in tiocmget()
2118 result = ((info->serial_signals & SerialSignal_RTS) ? TIOCM_RTS:0) + in tiocmget()
2119 ((info->serial_signals & SerialSignal_DTR) ? TIOCM_DTR:0) + in tiocmget()
2120 ((info->serial_signals & SerialSignal_DCD) ? TIOCM_CAR:0) + in tiocmget()
2121 ((info->serial_signals & SerialSignal_RI) ? TIOCM_RNG:0) + in tiocmget()
2122 ((info->serial_signals & SerialSignal_DSR) ? TIOCM_DSR:0) + in tiocmget()
2123 ((info->serial_signals & SerialSignal_CTS) ? TIOCM_CTS:0); in tiocmget()
2127 __FILE__, __LINE__, info->device_name, result); in tiocmget()
2136 MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; in tiocmset()
2141 __FILE__, __LINE__, info->device_name, set, clear); in tiocmset()
2144 info->serial_signals |= SerialSignal_RTS; in tiocmset()
2146 info->serial_signals |= SerialSignal_DTR; in tiocmset()
2148 info->serial_signals &= ~SerialSignal_RTS; in tiocmset()
2150 info->serial_signals &= ~SerialSignal_DTR; in tiocmset()
2152 spin_lock_irqsave(&info->lock, flags); in tiocmset()
2154 spin_unlock_irqrestore(&info->lock, flags); in tiocmset()
2162 * break_state -1=set break condition, 0=clear
2166 MGSLPC_INFO * info = (MGSLPC_INFO *)tty->driver_data; in mgslpc_break()
2171 __FILE__, __LINE__, info->device_name, break_state); in mgslpc_break()
2173 if (mgslpc_paranoia_check(info, tty->name, "mgslpc_break")) in mgslpc_break()
2174 return -EINVAL; in mgslpc_break()
2176 spin_lock_irqsave(&info->lock, flags); in mgslpc_break()
2177 if (break_state == -1) in mgslpc_break()
2181 spin_unlock_irqrestore(&info->lock, flags); in mgslpc_break()
2188 MGSLPC_INFO * info = (MGSLPC_INFO *)tty->driver_data; in mgslpc_get_icount()
2192 spin_lock_irqsave(&info->lock, flags); in mgslpc_get_icount()
2193 cnow = info->icount; in mgslpc_get_icount()
2194 spin_unlock_irqrestore(&info->lock, flags); in mgslpc_get_icount()
2196 icount->cts = cnow.cts; in mgslpc_get_icount()
2197 icount->dsr = cnow.dsr; in mgslpc_get_icount()
2198 icount->rng = cnow.rng; in mgslpc_get_icount()
2199 icount->dcd = cnow.dcd; in mgslpc_get_icount()
2200 icount->rx = cnow.rx; in mgslpc_get_icount()
2201 icount->tx = cnow.tx; in mgslpc_get_icount()
2202 icount->frame = cnow.frame; in mgslpc_get_icount()
2203 icount->overrun = cnow.overrun; in mgslpc_get_icount()
2204 icount->parity = cnow.parity; in mgslpc_get_icount()
2205 icount->brk = cnow.brk; in mgslpc_get_icount()
2206 icount->buf_overrun = cnow.buf_overrun; in mgslpc_get_icount()
2224 MGSLPC_INFO * info = (MGSLPC_INFO *)tty->driver_data; in mgslpc_ioctl()
2229 info->device_name, cmd); in mgslpc_ioctl()
2231 if (mgslpc_paranoia_check(info, tty->name, "mgslpc_ioctl")) in mgslpc_ioctl()
2232 return -ENODEV; in mgslpc_ioctl()
2236 return -EIO; in mgslpc_ioctl()
2265 return -ENOIOCTLCMD; in mgslpc_ioctl()
2280 MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; in mgslpc_set_termios()
2285 tty->driver->name); in mgslpc_set_termios()
2288 if ((tty->termios.c_cflag == old_termios->c_cflag) in mgslpc_set_termios()
2289 && (RELEVANT_IFLAG(tty->termios.c_iflag) in mgslpc_set_termios()
2290 == RELEVANT_IFLAG(old_termios->c_iflag))) in mgslpc_set_termios()
2296 if ((old_termios->c_cflag & CBAUD) && !C_BAUD(tty)) { in mgslpc_set_termios()
2297 info->serial_signals &= ~(SerialSignal_RTS | SerialSignal_DTR); in mgslpc_set_termios()
2298 spin_lock_irqsave(&info->lock, flags); in mgslpc_set_termios()
2300 spin_unlock_irqrestore(&info->lock, flags); in mgslpc_set_termios()
2304 if (!(old_termios->c_cflag & CBAUD) && C_BAUD(tty)) { in mgslpc_set_termios()
2305 info->serial_signals |= SerialSignal_DTR; in mgslpc_set_termios()
2307 info->serial_signals |= SerialSignal_RTS; in mgslpc_set_termios()
2308 spin_lock_irqsave(&info->lock, flags); in mgslpc_set_termios()
2310 spin_unlock_irqrestore(&info->lock, flags); in mgslpc_set_termios()
2314 if (old_termios->c_cflag & CRTSCTS && !C_CRTSCTS(tty)) { in mgslpc_set_termios()
2315 tty->hw_stopped = 0; in mgslpc_set_termios()
2322 MGSLPC_INFO * info = (MGSLPC_INFO *)tty->driver_data; in mgslpc_close()
2323 struct tty_port *port = &info->port; in mgslpc_close()
2325 if (mgslpc_paranoia_check(info, tty->name, "mgslpc_close")) in mgslpc_close()
2330 __FILE__, __LINE__, info->device_name, port->count); in mgslpc_close()
2336 mgslpc_wait_until_sent(tty, info->timeout); in mgslpc_close()
2348 tty->driver->name, port->count); in mgslpc_close()
2355 MGSLPC_INFO * info = (MGSLPC_INFO *)tty->driver_data; in mgslpc_wait_until_sent()
2363 __FILE__, __LINE__, info->device_name); in mgslpc_wait_until_sent()
2365 if (mgslpc_paranoia_check(info, tty->name, "mgslpc_wait_until_sent")) in mgslpc_wait_until_sent()
2368 if (!tty_port_initialized(&info->port)) in mgslpc_wait_until_sent()
2376 * Note: use tight timings here to satisfy the NIST-PCTS. in mgslpc_wait_until_sent()
2379 if (info->params.data_rate) { in mgslpc_wait_until_sent()
2380 char_time = info->timeout/(32 * 5); in mgslpc_wait_until_sent()
2389 if (info->params.mode == MGSL_MODE_HDLC) { in mgslpc_wait_until_sent()
2390 while (info->tx_active) { in mgslpc_wait_until_sent()
2398 while ((info->tx_count || info->tx_active) && in mgslpc_wait_until_sent()
2399 info->tx_enabled) { in mgslpc_wait_until_sent()
2411 __FILE__, __LINE__, info->device_name); in mgslpc_wait_until_sent()
2419 MGSLPC_INFO * info = (MGSLPC_INFO *)tty->driver_data; in mgslpc_hangup()
2423 __FILE__, __LINE__, info->device_name); in mgslpc_hangup()
2425 if (mgslpc_paranoia_check(info, tty->name, "mgslpc_hangup")) in mgslpc_hangup()
2430 tty_port_hangup(&info->port); in mgslpc_hangup()
2438 spin_lock_irqsave(&info->lock, flags); in carrier_raised()
2440 spin_unlock_irqrestore(&info->lock, flags); in carrier_raised()
2442 if (info->serial_signals & SerialSignal_DCD) in carrier_raised()
2452 spin_lock_irqsave(&info->lock, flags); in dtr_rts()
2454 info->serial_signals |= SerialSignal_RTS | SerialSignal_DTR; in dtr_rts()
2456 info->serial_signals &= ~(SerialSignal_RTS | SerialSignal_DTR); in dtr_rts()
2458 spin_unlock_irqrestore(&info->lock, flags); in dtr_rts()
2470 line = tty->index; in mgslpc_open()
2474 return -ENODEV; in mgslpc_open()
2479 while(info && info->line != line) in mgslpc_open()
2480 info = info->next_device; in mgslpc_open()
2481 if (mgslpc_paranoia_check(info, tty->name, "mgslpc_open")) in mgslpc_open()
2482 return -ENODEV; in mgslpc_open()
2484 port = &info->port; in mgslpc_open()
2485 tty->driver_data = info; in mgslpc_open()
2490 __FILE__, __LINE__, tty->driver->name, port->count); in mgslpc_open()
2492 spin_lock_irqsave(&info->netlock, flags); in mgslpc_open()
2493 if (info->netcount) { in mgslpc_open()
2494 retval = -EBUSY; in mgslpc_open()
2495 spin_unlock_irqrestore(&info->netlock, flags); in mgslpc_open()
2498 spin_lock(&port->lock); in mgslpc_open()
2499 port->count++; in mgslpc_open()
2500 spin_unlock(&port->lock); in mgslpc_open()
2501 spin_unlock_irqrestore(&info->netlock, flags); in mgslpc_open()
2503 if (port->count == 1) { in mgslpc_open()
2510 retval = tty_port_block_til_ready(&info->port, tty, filp); in mgslpc_open()
2514 __FILE__, __LINE__, info->device_name, retval); in mgslpc_open()
2520 __FILE__, __LINE__, info->device_name); in mgslpc_open()
2537 info->device_name, info->io_base, info->irq_level); in line_info()
2540 spin_lock_irqsave(&info->lock, flags); in line_info()
2542 spin_unlock_irqrestore(&info->lock, flags); in line_info()
2546 if (info->serial_signals & SerialSignal_RTS) in line_info()
2548 if (info->serial_signals & SerialSignal_CTS) in line_info()
2550 if (info->serial_signals & SerialSignal_DTR) in line_info()
2552 if (info->serial_signals & SerialSignal_DSR) in line_info()
2554 if (info->serial_signals & SerialSignal_DCD) in line_info()
2556 if (info->serial_signals & SerialSignal_RI) in line_info()
2559 if (info->params.mode == MGSL_MODE_HDLC) { in line_info()
2561 info->icount.txok, info->icount.rxok); in line_info()
2562 if (info->icount.txunder) in line_info()
2563 seq_printf(m, " txunder:%d", info->icount.txunder); in line_info()
2564 if (info->icount.txabort) in line_info()
2565 seq_printf(m, " txabort:%d", info->icount.txabort); in line_info()
2566 if (info->icount.rxshort) in line_info()
2567 seq_printf(m, " rxshort:%d", info->icount.rxshort); in line_info()
2568 if (info->icount.rxlong) in line_info()
2569 seq_printf(m, " rxlong:%d", info->icount.rxlong); in line_info()
2570 if (info->icount.rxover) in line_info()
2571 seq_printf(m, " rxover:%d", info->icount.rxover); in line_info()
2572 if (info->icount.rxcrc) in line_info()
2573 seq_printf(m, " rxcrc:%d", info->icount.rxcrc); in line_info()
2576 info->icount.tx, info->icount.rx); in line_info()
2577 if (info->icount.frame) in line_info()
2578 seq_printf(m, " fe:%d", info->icount.frame); in line_info()
2579 if (info->icount.parity) in line_info()
2580 seq_printf(m, " pe:%d", info->icount.parity); in line_info()
2581 if (info->icount.brk) in line_info()
2582 seq_printf(m, " brk:%d", info->icount.brk); in line_info()
2583 if (info->icount.overrun) in line_info()
2584 seq_printf(m, " oe:%d", info->icount.overrun); in line_info()
2591 info->tx_active,info->bh_requested,info->bh_running, in line_info()
2592 info->pending_bh); in line_info()
2606 info = info->next_device; in mgslpc_proc_show()
2614 info->rx_buf_size = sizeof(RXBUF) + info->max_frame_size; in rx_alloc_buffers()
2617 info->rx_buf_total_size = info->rx_buf_size * 8; in rx_alloc_buffers()
2620 if (info->rx_buf_total_size > 0x10000) in rx_alloc_buffers()
2621 info->rx_buf_total_size = 0x10000; in rx_alloc_buffers()
2624 info->rx_buf_count = info->rx_buf_total_size / info->rx_buf_size; in rx_alloc_buffers()
2626 info->rx_buf = kmalloc(info->rx_buf_total_size, GFP_KERNEL); in rx_alloc_buffers()
2627 if (info->rx_buf == NULL) in rx_alloc_buffers()
2628 return -ENOMEM; in rx_alloc_buffers()
2631 info->flag_buf = kzalloc(info->max_frame_size, GFP_KERNEL); in rx_alloc_buffers()
2632 if (!info->flag_buf) { in rx_alloc_buffers()
2633 kfree(info->rx_buf); in rx_alloc_buffers()
2634 info->rx_buf = NULL; in rx_alloc_buffers()
2635 return -ENOMEM; in rx_alloc_buffers()
2644 kfree(info->rx_buf); in rx_free_buffers()
2645 info->rx_buf = NULL; in rx_free_buffers()
2646 kfree(info->flag_buf); in rx_free_buffers()
2647 info->flag_buf = NULL; in rx_free_buffers()
2653 printk("Can't allocate rx buffer %s\n", info->device_name); in claim_resources()
2655 return -ENODEV; in claim_resources()
2663 printk("release_resources(%s)\n", info->device_name); in release_resources()
2678 info->next_device = NULL; in mgslpc_add_device()
2679 info->line = mgslpc_device_count; in mgslpc_add_device()
2680 sprintf(info->device_name,"ttySLP%d",info->line); in mgslpc_add_device()
2682 if (info->line < MAX_DEVICE_COUNT) { in mgslpc_add_device()
2683 if (maxframe[info->line]) in mgslpc_add_device()
2684 info->max_frame_size = maxframe[info->line]; in mgslpc_add_device()
2693 while (current_dev->next_device) in mgslpc_add_device()
2694 current_dev = current_dev->next_device; in mgslpc_add_device()
2695 current_dev->next_device = info; in mgslpc_add_device()
2698 if (info->max_frame_size < 4096) in mgslpc_add_device()
2699 info->max_frame_size = 4096; in mgslpc_add_device()
2700 else if (info->max_frame_size > 65535) in mgslpc_add_device()
2701 info->max_frame_size = 65535; in mgslpc_add_device()
2704 info->device_name, info->io_base, info->irq_level); in mgslpc_add_device()
2712 tty_dev = tty_port_register_device(&info->port, serial_driver, info->line, in mgslpc_add_device()
2713 &info->p_dev->dev); in mgslpc_add_device()
2726 current_dev->next_device = NULL; in mgslpc_add_device()
2729 mgslpc_device_count--; in mgslpc_add_device()
2741 last->next_device = info->next_device; in mgslpc_remove_device()
2743 mgslpc_device_list = info->next_device; in mgslpc_remove_device()
2744 tty_unregister_device(serial_driver, info->line); in mgslpc_remove_device()
2749 tty_port_destroy(&info->port); in mgslpc_remove_device()
2751 mgslpc_device_count--; in mgslpc_remove_device()
2755 info = info->next_device; in mgslpc_remove_device()
2818 serial_driver->driver_name = "synclink_cs"; in synclink_cs_init()
2819 serial_driver->name = "ttySLP"; in synclink_cs_init()
2820 serial_driver->major = ttymajor; in synclink_cs_init()
2821 serial_driver->minor_start = 64; in synclink_cs_init()
2822 serial_driver->type = TTY_DRIVER_TYPE_SERIAL; in synclink_cs_init()
2823 serial_driver->subtype = SERIAL_TYPE_NORMAL; in synclink_cs_init()
2824 serial_driver->init_termios = tty_std_termios; in synclink_cs_init()
2825 serial_driver->init_termios.c_cflag = in synclink_cs_init()
2841 serial_driver->major); in synclink_cs_init()
2878 N--; in mgslpc_set_rate()
2917 if (info->params.mode == MGSL_MODE_HDLC && info->params.clock_speed) in enable_auxclk()
2938 * 04 ODS Output Driver Select, 1=TxD is push-pull output in enable_auxclk()
2953 * 01 C32, CRC select, 0=CRC-16, 1=CRC-32 in enable_auxclk()
2958 if (info->params.mode == MGSL_MODE_HDLC && info->params.clock_speed) in enable_auxclk()
2979 if (info->params.mode == MGSL_MODE_HDLC && info->params.clock_speed) in enable_auxclk()
2980 mgslpc_set_rate(info, CHB, info->params.clock_speed); in enable_auxclk()
2998 if (info->params.clock_speed) in loopback_enable()
2999 mgslpc_set_rate(info, CHA, info->params.clock_speed); in loopback_enable()
3020 if (info->params.flags & HDLC_FLAG_RXC_DPLL in hdlc_mode()
3021 && info->params.flags & HDLC_FLAG_TXC_DPLL) { in hdlc_mode()
3024 } else if (info->params.flags & HDLC_FLAG_RXC_BRG in hdlc_mode()
3025 && info->params.flags & HDLC_FLAG_TXC_BRG) { in hdlc_mode()
3029 } else if (info->params.flags & HDLC_FLAG_RXC_DPLL) { in hdlc_mode()
3030 if (info->params.flags & HDLC_FLAG_TXC_BRG) { in hdlc_mode()
3038 } else if (info->params.flags & HDLC_FLAG_TXC_BRG) { in hdlc_mode()
3056 if (info->params.loopback) in hdlc_mode()
3060 if (info->serial_signals & SerialSignal_RTS) in hdlc_mode()
3075 switch (info->params.encoding) in hdlc_mode()
3097 * 04 ODS Output Driver Select, 1=TxD is push-pull output in hdlc_mode()
3113 * 01 C32, CRC select, 0=CRC-16, 1=CRC-32 in hdlc_mode()
3124 if (info->params.crc_type == HDLC_CRC_32_CCITT) in hdlc_mode()
3126 if (info->params.encoding == HDLC_ENCODING_NRZB) in hdlc_mode()
3143 if (info->params.crc_type == HDLC_CRC_NONE) in hdlc_mode()
3145 if (info->params.preamble != HDLC_PREAMBLE_PATTERN_NONE) in hdlc_mode()
3147 switch (info->params.preamble_length) in hdlc_mode()
3161 /* PRE - Preamble pattern */ in hdlc_mode()
3163 switch (info->params.preamble) in hdlc_mode()
3185 if (info->params.flags & HDLC_FLAG_RXC_DPLL) in hdlc_mode()
3186 mgslpc_set_rate(info, CHA, info->params.clock_speed * 16); in hdlc_mode()
3188 mgslpc_set_rate(info, CHA, info->params.clock_speed); in hdlc_mode()
3208 if (info->params.flags & HDLC_FLAG_AUTO_DCD) in hdlc_mode()
3212 if (info->params.loopback || info->testing_irq) in hdlc_mode()
3214 if (info->params.flags & HDLC_FLAG_AUTO_CTS) in hdlc_mode()
3239 if (!info->testing_irq) in hdlc_mode()
3252 __FILE__, __LINE__, info->device_name); in rx_stop()
3257 info->rx_enabled = false; in rx_stop()
3258 info->rx_overflow = false; in rx_stop()
3265 __FILE__, __LINE__, info->device_name); in rx_start()
3268 info->rx_enabled = false; in rx_start()
3269 info->rx_overflow = false; in rx_start()
3274 info->rx_enabled = true; in rx_start()
3281 __FILE__, __LINE__, info->device_name); in tx_start()
3283 if (info->tx_count) { in tx_start()
3287 info->drop_rts_on_tx_done = false; in tx_start()
3289 if (info->params.flags & HDLC_FLAG_AUTO_RTS) { in tx_start()
3291 if (!(info->serial_signals & SerialSignal_RTS)) { in tx_start()
3292 info->serial_signals |= SerialSignal_RTS; in tx_start()
3294 info->drop_rts_on_tx_done = true; in tx_start()
3298 if (info->params.mode == MGSL_MODE_ASYNC) { in tx_start()
3299 if (!info->tx_active) { in tx_start()
3300 info->tx_active = true; in tx_start()
3304 info->tx_active = true; in tx_start()
3306 mod_timer(&info->tx_timer, jiffies + in tx_start()
3311 if (!info->tx_enabled) in tx_start()
3312 info->tx_enabled = true; in tx_start()
3319 __FILE__, __LINE__, info->device_name); in tx_stop()
3321 del_timer(&info->tx_timer); in tx_stop()
3323 info->tx_enabled = false; in tx_stop()
3324 info->tx_active = false; in tx_stop()
3372 * 01..00 IC[1..0] Interrupt Config, 01=push-pull output, active low in reset_device()
3402 if (info->params.loopback) in async_mode()
3406 if (!(info->serial_signals & SerialSignal_RTS)) in async_mode()
3425 * 04 ODS Output Driver Select, 1=TxD is push-pull output in async_mode()
3467 mgslpc_set_rate(info, CHA, info->params.data_rate * 16); in async_mode()
3480 if (info->params.data_bits != 8) in async_mode()
3482 if (info->params.stop_bits != 1) in async_mode()
3484 if (info->params.parity != ASYNC_PARITY_NONE) in async_mode()
3487 if (info->params.parity == ASYNC_PARITY_ODD) in async_mode()
3525 if (info->params.flags & HDLC_FLAG_AUTO_DCD) in async_mode()
3528 if (info->params.flags & HDLC_FLAG_AUTO_CTS) in async_mode()
3534 if (info->params.flags & HDLC_FLAG_AUTO_CTS) { in async_mode()
3553 if (info->idle_mode == HDLC_TXIDLE_FLAGS) in tx_set_idle()
3566 info->serial_signals &= SerialSignal_RTS | SerialSignal_DTR; in get_signals()
3569 info->serial_signals |= SerialSignal_DCD; in get_signals()
3571 info->serial_signals |= SerialSignal_CTS; in get_signals()
3575 info->serial_signals |= SerialSignal_RI; in get_signals()
3577 info->serial_signals |= SerialSignal_DSR; in get_signals()
3588 if (info->params.mode == MGSL_MODE_ASYNC) { in set_signals()
3589 if (info->serial_signals & SerialSignal_RTS) in set_signals()
3594 if (info->serial_signals & SerialSignal_RTS) in set_signals()
3601 if (info->serial_signals & SerialSignal_DTR) in set_signals()
3612 info->rx_put = 0; in rx_reset_buffers()
3613 info->rx_get = 0; in rx_reset_buffers()
3614 info->rx_frame_count = 0; in rx_reset_buffers()
3615 for (i=0 ; i < info->rx_buf_count ; i++) { in rx_reset_buffers()
3616 buf = (RXBUF*)(info->rx_buf + (i * info->rx_buf_size)); in rx_reset_buffers()
3617 buf->status = buf->count = 0; in rx_reset_buffers()
3634 if (info->rx_frame_count == 0) in rx_get_frame()
3637 buf = (RXBUF*)(info->rx_buf + (info->rx_get * info->rx_buf_size)); in rx_get_frame()
3639 status = buf->status; in rx_get_frame()
3648 info->icount.rxabort++; in rx_get_frame()
3650 info->icount.rxover++; in rx_get_frame()
3652 info->icount.rxcrc++; in rx_get_frame()
3653 if (info->params.crc_type & HDLC_CRC_RETURN_EX) in rx_get_frame()
3659 info->netdev->stats.rx_errors++; in rx_get_frame()
3660 info->netdev->stats.rx_frame_errors++; in rx_get_frame()
3667 framesize = buf->count; in rx_get_frame()
3671 __FILE__, __LINE__, info->device_name, status, framesize); in rx_get_frame()
3674 trace_block(info, buf->data, framesize, 0); in rx_get_frame()
3677 if ((info->params.crc_type & HDLC_CRC_RETURN_EX && in rx_get_frame()
3678 framesize+1 > info->max_frame_size) || in rx_get_frame()
3679 framesize > info->max_frame_size) in rx_get_frame()
3680 info->icount.rxlong++; in rx_get_frame()
3683 info->icount.rxok++; in rx_get_frame()
3685 if (info->params.crc_type & HDLC_CRC_RETURN_EX) { in rx_get_frame()
3686 *(buf->data + framesize) = status & BIT5 ? RX_OK:RX_CRC_ERROR; in rx_get_frame()
3691 if (info->netcount) in rx_get_frame()
3692 hdlcdev_rx(info, buf->data, framesize); in rx_get_frame()
3695 ldisc_receive_buf(tty, buf->data, info->flag_buf, framesize); in rx_get_frame()
3699 spin_lock_irqsave(&info->lock, flags); in rx_get_frame()
3700 buf->status = buf->count = 0; in rx_get_frame()
3701 info->rx_frame_count--; in rx_get_frame()
3702 info->rx_get++; in rx_get_frame()
3703 if (info->rx_get >= info->rx_buf_count) in rx_get_frame()
3704 info->rx_get = 0; in rx_get_frame()
3705 spin_unlock_irqrestore(&info->lock, flags); in rx_get_frame()
3719 spin_lock_irqsave(&info->lock, flags); in register_test()
3732 spin_unlock_irqrestore(&info->lock, flags); in register_test()
3741 spin_lock_irqsave(&info->lock, flags); in irq_test()
3744 info->testing_irq = true; in irq_test()
3747 info->irq_occurred = false; in irq_test()
3755 spin_unlock_irqrestore(&info->lock, flags); in irq_test()
3758 while(end_time-- && !info->irq_occurred) { in irq_test()
3762 info->testing_irq = false; in irq_test()
3764 spin_lock_irqsave(&info->lock, flags); in irq_test()
3766 spin_unlock_irqrestore(&info->lock, flags); in irq_test()
3768 return info->irq_occurred; in irq_test()
3774 info->init_error = DiagStatus_AddressFailure; in adapter_test()
3776 __FILE__, __LINE__, info->device_name, (unsigned short)(info->io_base)); in adapter_test()
3777 return -ENODEV; in adapter_test()
3781 info->init_error = DiagStatus_IrqFailure; in adapter_test()
3783 __FILE__, __LINE__, info->device_name, (unsigned short)(info->irq_level)); in adapter_test()
3784 return -ENODEV; in adapter_test()
3789 __FILE__, __LINE__, info->device_name); in adapter_test()
3798 printk("%s tx data:\n", info->device_name); in trace_block()
3800 printk("%s rx data:\n", info->device_name); in trace_block()
3821 count -= linecount; in trace_block()
3835 __FILE__, __LINE__, info->device_name); in tx_timeout()
3836 if (info->tx_active && in tx_timeout()
3837 info->params.mode == MGSL_MODE_HDLC) { in tx_timeout()
3838 info->icount.txtimeout++; in tx_timeout()
3840 spin_lock_irqsave(&info->lock, flags); in tx_timeout()
3841 info->tx_active = false; in tx_timeout()
3842 info->tx_count = info->tx_put = info->tx_get = 0; in tx_timeout()
3844 spin_unlock_irqrestore(&info->lock, flags); in tx_timeout()
3847 if (info->netcount) in tx_timeout()
3852 struct tty_struct *tty = tty_port_tty_get(&info->port); in tx_timeout()
3879 if (info->port.count) in hdlcdev_attach()
3880 return -EBUSY; in hdlcdev_attach()
3889 default: return -EINVAL; in hdlcdev_attach()
3897 default: return -EINVAL; in hdlcdev_attach()
3900 info->params.encoding = new_encoding; in hdlcdev_attach()
3901 info->params.crc_type = new_crctype; in hdlcdev_attach()
3904 if (info->netcount) { in hdlcdev_attach()
3905 tty = tty_port_tty_get(&info->port); in hdlcdev_attach()
3926 printk(KERN_INFO "%s:hdlc_xmit(%s)\n", __FILE__, dev->name); in hdlcdev_xmit()
3932 skb_copy_from_linear_data(skb, info->tx_buf, skb->len); in hdlcdev_xmit()
3933 info->tx_get = 0; in hdlcdev_xmit()
3934 info->tx_put = info->tx_count = skb->len; in hdlcdev_xmit()
3937 dev->stats.tx_packets++; in hdlcdev_xmit()
3938 dev->stats.tx_bytes += skb->len; in hdlcdev_xmit()
3947 spin_lock_irqsave(&info->lock, flags); in hdlcdev_xmit()
3948 if (!info->tx_active) { in hdlcdev_xmit()
3949 struct tty_struct *tty = tty_port_tty_get(&info->port); in hdlcdev_xmit()
3953 spin_unlock_irqrestore(&info->lock, flags); in hdlcdev_xmit()
3974 printk("%s:hdlcdev_open(%s)\n", __FILE__, dev->name); in hdlcdev_open()
3982 spin_lock_irqsave(&info->netlock, flags); in hdlcdev_open()
3983 if (info->port.count != 0 || info->netcount != 0) { in hdlcdev_open()
3984 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name); in hdlcdev_open()
3985 spin_unlock_irqrestore(&info->netlock, flags); in hdlcdev_open()
3986 return -EBUSY; in hdlcdev_open()
3988 info->netcount=1; in hdlcdev_open()
3989 spin_unlock_irqrestore(&info->netlock, flags); in hdlcdev_open()
3991 tty = tty_port_tty_get(&info->port); in hdlcdev_open()
3996 spin_lock_irqsave(&info->netlock, flags); in hdlcdev_open()
3997 info->netcount=0; in hdlcdev_open()
3998 spin_unlock_irqrestore(&info->netlock, flags); in hdlcdev_open()
4002 info->serial_signals |= SerialSignal_RTS | SerialSignal_DTR; in hdlcdev_open()
4010 /* inform generic HDLC layer of current DCD status */ in hdlcdev_open()
4011 spin_lock_irqsave(&info->lock, flags); in hdlcdev_open()
4013 spin_unlock_irqrestore(&info->lock, flags); in hdlcdev_open()
4014 if (info->serial_signals & SerialSignal_DCD) in hdlcdev_open()
4032 struct tty_struct *tty = tty_port_tty_get(&info->port); in hdlcdev_close()
4036 printk("%s:hdlcdev_close(%s)\n", __FILE__, dev->name); in hdlcdev_close()
4045 spin_lock_irqsave(&info->netlock, flags); in hdlcdev_close()
4046 info->netcount=0; in hdlcdev_close()
4047 spin_unlock_irqrestore(&info->netlock, flags); in hdlcdev_close()
4064 sync_serial_settings __user *line = ifs->ifs_ifsu.sync; in hdlcdev_wan_ioctl()
4069 printk("%s:hdlcdev_ioctl(%s)\n", __FILE__, dev->name); in hdlcdev_wan_ioctl()
4072 if (info->port.count) in hdlcdev_wan_ioctl()
4073 return -EBUSY; in hdlcdev_wan_ioctl()
4077 switch (ifs->type) { in hdlcdev_wan_ioctl()
4080 ifs->type = IF_IFACE_SYNC_SERIAL; in hdlcdev_wan_ioctl()
4081 if (ifs->size < size) { in hdlcdev_wan_ioctl()
4082 ifs->size = size; /* data size wanted */ in hdlcdev_wan_ioctl()
4083 return -ENOBUFS; in hdlcdev_wan_ioctl()
4086 flags = info->params.flags & (HDLC_FLAG_RXC_RXCPIN | HDLC_FLAG_RXC_DPLL | in hdlcdev_wan_ioctl()
4099 new_line.clock_rate = info->params.clock_speed; in hdlcdev_wan_ioctl()
4100 new_line.loopback = info->params.loopback ? 1:0; in hdlcdev_wan_ioctl()
4103 return -EFAULT; in hdlcdev_wan_ioctl()
4109 return -EPERM; in hdlcdev_wan_ioctl()
4111 return -EFAULT; in hdlcdev_wan_ioctl()
4119 case CLOCK_DEFAULT: flags = info->params.flags & in hdlcdev_wan_ioctl()
4124 default: return -EINVAL; in hdlcdev_wan_ioctl()
4128 return -EINVAL; in hdlcdev_wan_ioctl()
4130 info->params.flags &= ~(HDLC_FLAG_RXC_RXCPIN | HDLC_FLAG_RXC_DPLL | in hdlcdev_wan_ioctl()
4134 info->params.flags |= flags; in hdlcdev_wan_ioctl()
4136 info->params.loopback = new_line.loopback; in hdlcdev_wan_ioctl()
4139 info->params.clock_speed = new_line.clock_rate; in hdlcdev_wan_ioctl()
4141 info->params.clock_speed = 0; in hdlcdev_wan_ioctl()
4144 if (info->netcount) { in hdlcdev_wan_ioctl()
4145 struct tty_struct *tty = tty_port_tty_get(&info->port); in hdlcdev_wan_ioctl()
4166 printk("hdlcdev_tx_timeout(%s)\n", dev->name); in hdlcdev_tx_timeout()
4168 dev->stats.tx_errors++; in hdlcdev_tx_timeout()
4169 dev->stats.tx_aborted_errors++; in hdlcdev_tx_timeout()
4171 spin_lock_irqsave(&info->lock, flags); in hdlcdev_tx_timeout()
4173 spin_unlock_irqrestore(&info->lock, flags); in hdlcdev_tx_timeout()
4186 if (netif_queue_stopped(info->netdev)) in hdlcdev_tx_done()
4187 netif_wake_queue(info->netdev); in hdlcdev_tx_done()
4201 struct net_device *dev = info->netdev; in hdlcdev_rx()
4204 printk("hdlcdev_rx(%s)\n", dev->name); in hdlcdev_rx()
4207 printk(KERN_NOTICE "%s: can't alloc skb, dropping packet\n", dev->name); in hdlcdev_rx()
4208 dev->stats.rx_dropped++; in hdlcdev_rx()
4214 skb->protocol = hdlc_type_trans(skb, dev); in hdlcdev_rx()
4216 dev->stats.rx_packets++; in hdlcdev_rx()
4217 dev->stats.rx_bytes += size; in hdlcdev_rx()
4249 return -ENOMEM; in hdlcdev_init()
4253 dev->base_addr = info->io_base; in hdlcdev_init()
4254 dev->irq = info->irq_level; in hdlcdev_init()
4257 dev->netdev_ops = &hdlcdev_ops; in hdlcdev_init()
4258 dev->watchdog_timeo = 10 * HZ; in hdlcdev_init()
4259 dev->tx_queue_len = 50; in hdlcdev_init()
4263 hdlc->attach = hdlcdev_attach; in hdlcdev_init()
4264 hdlc->xmit = hdlcdev_xmit; in hdlcdev_init()
4274 info->netdev = dev; in hdlcdev_init()
4286 unregister_hdlc_device(info->netdev); in hdlcdev_exit()
4287 free_netdev(info->netdev); in hdlcdev_exit()
4288 info->netdev = NULL; in hdlcdev_exit()