Lines Matching refs:info
321 #define write_reg(info, reg, val) outb((val),(info)->io_base + (reg)) argument
322 #define read_reg(info, reg) inb((info)->io_base + (reg)) argument
324 #define read_reg16(info, reg) inw((info)->io_base + (reg)) argument
325 #define write_reg16(info, reg, val) outw((val), (info)->io_base + (reg)) argument
327 #define set_reg_bits(info, reg, mask) \ argument
328 write_reg(info, (reg), \
329 (unsigned char) (read_reg(info, (reg)) | (mask)))
330 #define clear_reg_bits(info, reg, mask) \ argument
331 write_reg(info, (reg), \
332 (unsigned char) (read_reg(info, (reg)) & ~(mask)))
336 static void irq_disable(MGSLPC_INFO *info, unsigned char channel, unsigned short mask) in irq_disable() argument
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()
346 static void irq_enable(MGSLPC_INFO *info, unsigned char channel, unsigned short mask) in irq_enable() argument
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()
357 #define port_irq_disable(info, mask) \ argument
358 { info->pim_value |= (mask); write_reg(info, PIM, info->pim_value); }
360 #define port_irq_enable(info, mask) \ argument
361 { info->pim_value &= ~(mask); write_reg(info, PIM, info->pim_value); }
363 static void rx_start(MGSLPC_INFO *info);
364 static void rx_stop(MGSLPC_INFO *info);
366 static void tx_start(MGSLPC_INFO *info, struct tty_struct *tty);
367 static void tx_stop(MGSLPC_INFO *info);
368 static void tx_set_idle(MGSLPC_INFO *info);
370 static void get_signals(MGSLPC_INFO *info);
371 static void set_signals(MGSLPC_INFO *info);
373 static void reset_device(MGSLPC_INFO *info);
375 static void hdlc_mode(MGSLPC_INFO *info);
376 static void async_mode(MGSLPC_INFO *info);
385 static void hdlcdev_tx_done(MGSLPC_INFO *info);
386 static void hdlcdev_rx(MGSLPC_INFO *info, char *buf, int size);
387 static int hdlcdev_init(MGSLPC_INFO *info);
388 static void hdlcdev_exit(MGSLPC_INFO *info);
391 static void trace_block(MGSLPC_INFO *info,const char* data, int count, int xmit);
393 static bool register_test(MGSLPC_INFO *info);
394 static bool irq_test(MGSLPC_INFO *info);
395 static int adapter_test(MGSLPC_INFO *info);
397 static int claim_resources(MGSLPC_INFO *info);
398 static void release_resources(MGSLPC_INFO *info);
399 static int mgslpc_add_device(MGSLPC_INFO *info);
400 static void mgslpc_remove_device(MGSLPC_INFO *info);
402 static bool rx_get_frame(MGSLPC_INFO *info, struct tty_struct *tty);
403 static void rx_reset_buffers(MGSLPC_INFO *info);
404 static int rx_alloc_buffers(MGSLPC_INFO *info);
405 static void rx_free_buffers(MGSLPC_INFO *info);
413 static void bh_transmit(MGSLPC_INFO *info, struct tty_struct *tty);
414 static void bh_status(MGSLPC_INFO *info);
422 static int get_stats(MGSLPC_INFO *info, struct mgsl_icount __user *user_icount);
423 static int get_params(MGSLPC_INFO *info, MGSL_PARAMS __user *user_params);
424 static int set_params(MGSLPC_INFO *info, MGSL_PARAMS __user *new_params, struct tty_struct *tty);
425 static int get_txidle(MGSLPC_INFO *info, int __user *idle_mode);
426 static int set_txidle(MGSLPC_INFO *info, int idle_mode);
427 static int set_txenable(MGSLPC_INFO *info, int enable, struct tty_struct *tty);
428 static int tx_abort(MGSLPC_INFO *info);
429 static int set_rxenable(MGSLPC_INFO *info, int enable);
430 static int wait_events(MGSLPC_INFO *info, int __user *mask);
466 static void mgslpc_change_params(MGSLPC_INFO *info, struct tty_struct *tty);
516 MGSLPC_INFO *info; in mgslpc_probe() local
522 info = kzalloc(sizeof(MGSLPC_INFO), GFP_KERNEL); in mgslpc_probe()
523 if (!info) { 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()
552 ret = mgslpc_add_device(info); in mgslpc_probe()
561 tty_port_destroy(&info->port); in mgslpc_probe()
562 kfree(info); in mgslpc_probe()
576 MGSLPC_INFO *info = link->priv; in mgslpc_config() local
598 info->io_base = link->resource[0]->start; in mgslpc_config()
599 info->irq_level = link->irq; in mgslpc_config()
634 MGSLPC_INFO *info = link->priv; in mgslpc_suspend() local
636 info->stop = 1; in mgslpc_suspend()
643 MGSLPC_INFO *info = link->priv; in mgslpc_resume() local
645 info->stop = 0; in mgslpc_resume()
651 static inline bool mgslpc_paranoia_check(MGSLPC_INFO *info, in mgslpc_paranoia_check() argument
660 if (!info) { in mgslpc_paranoia_check()
664 if (info->magic != MGSLPC_MAGIC) { in mgslpc_paranoia_check()
669 if (!info) in mgslpc_paranoia_check()
684 static bool wait_command_complete(MGSLPC_INFO *info, unsigned char channel) in wait_command_complete() argument
688 while (read_reg(info, (unsigned char)(channel+STAR)) & BIT2) { in wait_command_complete()
696 static void issue_command(MGSLPC_INFO *info, unsigned char channel, unsigned char cmd) in issue_command() argument
698 wait_command_complete(info, channel); in issue_command()
699 write_reg(info, (unsigned char) (channel + CMDR), cmd); in issue_command()
704 MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; in tx_pause() local
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()
714 tx_stop(info); 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() local
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()
730 tx_start(info, tty); in tx_release()
731 spin_unlock_irqrestore(&info->lock, flags); in tx_release()
737 static int bh_action(MGSLPC_INFO *info) in bh_action() argument
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()
768 MGSLPC_INFO *info = container_of(work, MGSLPC_INFO, task); in bh_handler() local
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()
779 while((action = bh_action(info)) != 0) { in bh_handler()
789 while(rx_get_frame(info, tty)); in bh_handler()
792 bh_transmit(info, tty); in bh_handler()
795 bh_status(info); in bh_handler()
807 __FILE__,__LINE__,info->device_name); in bh_handler()
810 static void bh_transmit(MGSLPC_INFO *info, struct tty_struct *tty) in bh_transmit() argument
813 printk("bh_transmit() entry on %s\n", info->device_name); in bh_transmit()
819 static void bh_status(MGSLPC_INFO *info) in bh_status() argument
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()
828 static void rx_ready_hdlc(MGSLPC_INFO *info, int eom) in rx_ready_hdlc() argument
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()
842 issue_command(info, CHA, CMD_RXRESET); 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()
851 fifo_count = (unsigned char)(read_reg(info, CHA+RBCL) & 0x1f); in rx_ready_hdlc()
860 data[0] = read_reg(info, CHA + RXFIFO); in rx_ready_hdlc()
863 *((unsigned short *) data) = read_reg16(info, CHA + RXFIFO); in rx_ready_hdlc()
870 if (buf->count >= info->max_frame_size) { in rx_ready_hdlc()
872 issue_command(info, CHA, CMD_RXRESET); 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()
888 issue_command(info, CHA, CMD_RXFIFO); in rx_ready_hdlc()
891 static void rx_ready_async(MGSLPC_INFO *info, int tcd) in rx_ready_async() argument
893 struct tty_port *port = &info->port; in rx_ready_async()
897 struct mgsl_icount *icount = &info->icount; in rx_ready_async()
901 fifo_count = (unsigned char)(read_reg(info, CHA+RBCL) & 0x1f); in rx_ready_async()
906 if (!fifo_count && (read_reg(info,CHA+STAR) & BIT5)) in rx_ready_async()
914 data = read_reg(info, CHA + RXFIFO); in rx_ready_async()
915 status = read_reg(info, CHA + RXFIFO); 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()
944 issue_command(info, CHA, CMD_RXFIFO); in rx_ready_async()
959 static void tx_done(MGSLPC_INFO *info, struct tty_struct *tty) in tx_done() argument
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()
974 get_signals(info); in tx_done()
975 if (info->serial_signals & SerialSignal_RTS) { in tx_done()
976 info->serial_signals &= ~SerialSignal_RTS; in tx_done()
977 set_signals(info); in tx_done()
979 info->drop_rts_on_tx_done = false; in tx_done()
983 if (info->netcount) in tx_done()
984 hdlcdev_tx_done(info); in tx_done()
989 tx_stop(info); in tx_done()
992 info->pending_bh |= BH_TRANSMIT; in tx_done()
996 static void tx_ready(MGSLPC_INFO *info, struct tty_struct *tty) in tx_ready() argument
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()
1009 tx_stop(info); 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()
1025 write_reg16(info, CHA + TXFIFO, 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()
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()
1036 issue_command(info, CHA, CMD_TXFIFO); in tx_ready()
1038 if (info->tx_count) in tx_ready()
1039 issue_command(info, CHA, CMD_TXFIFO); in tx_ready()
1041 issue_command(info, CHA, CMD_TXFIFO + CMD_TXEOM); in tx_ready()
1045 static void cts_change(MGSLPC_INFO *info, struct tty_struct *tty) in cts_change() argument
1047 get_signals(info); in cts_change()
1048 if ((info->cts_chkcount)++ >= IO_PIN_SHUTDOWN_LIMIT) in cts_change()
1049 irq_disable(info, CHB, IRQ_CTS); 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()
1060 if (info->serial_signals & SerialSignal_CTS) { in cts_change()
1064 tx_start(info, tty); in cts_change()
1065 info->pending_bh |= BH_TRANSMIT; in cts_change()
1069 if (!(info->serial_signals & SerialSignal_CTS)) { in cts_change()
1073 tx_stop(info); in cts_change()
1077 info->pending_bh |= BH_STATUS; in cts_change()
1080 static void dcd_change(MGSLPC_INFO *info, struct tty_struct *tty) in dcd_change() argument
1082 get_signals(info); in dcd_change()
1083 if ((info->dcd_chkcount)++ >= IO_PIN_SHUTDOWN_LIMIT) in dcd_change()
1084 irq_disable(info, CHB, IRQ_DCD); 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()
1118 static void dsr_change(MGSLPC_INFO *info) in dsr_change() argument
1120 get_signals(info); in dsr_change()
1121 if ((info->dsr_chkcount)++ >= IO_PIN_SHUTDOWN_LIMIT) in dsr_change()
1122 port_irq_disable(info, PVR_DSR); 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()
1133 static void ri_change(MGSLPC_INFO *info) in ri_change() argument
1135 get_signals(info); in ri_change()
1136 if ((info->ri_chkcount)++ >= IO_PIN_SHUTDOWN_LIMIT) in ri_change()
1137 port_irq_disable(info, PVR_RI); 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()
1157 MGSLPC_INFO *info = dev_id; in mgslpc_isr() local
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()
1173 while ((gis = read_reg(info, CHA + GIS))) { in mgslpc_isr()
1175 printk("mgslpc_isr %s gis=%04X\n", info->device_name,gis); in mgslpc_isr()
1184 isr = read_reg16(info, CHB + ISR); in mgslpc_isr()
1186 dcd_change(info, tty); in mgslpc_isr()
1188 cts_change(info, tty); in mgslpc_isr()
1192 isr = read_reg16(info, CHA + ISR); in mgslpc_isr()
1194 info->irq_occurred = true; in mgslpc_isr()
1195 irq_disable(info, CHA, IRQ_TIMER); 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()
1209 issue_command(info, CHA, CMD_RXFIFO_READ); in mgslpc_isr()
1212 if (info->params.mode == MGSL_MODE_HDLC) in mgslpc_isr()
1213 rx_ready_hdlc(info, isr & IRQ_RXEOM); in mgslpc_isr()
1215 rx_ready_async(info, isr & IRQ_RXEOM); 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()
1224 tx_done(info, tty); in mgslpc_isr()
1227 info->icount.txok++; in mgslpc_isr()
1228 tx_done(info, tty); in mgslpc_isr()
1231 tx_ready(info, tty); in mgslpc_isr()
1234 pis = read_reg(info, CHA + PIS); in mgslpc_isr()
1236 dsr_change(info); in mgslpc_isr()
1238 ri_change(info); 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()
1266 static int startup(MGSLPC_INFO * info, struct tty_struct *tty) in startup() argument
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()
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()
1293 retval = claim_resources(info); in startup()
1297 retval = adapter_test(info); in startup()
1302 release_resources(info); in startup()
1307 mgslpc_change_params(info, tty); in startup()
1312 tty_port_set_initialized(&info->port, 1); in startup()
1319 static void shutdown(MGSLPC_INFO * info, struct tty_struct *tty) in shutdown() argument
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()
1344 rx_stop(info); in shutdown()
1345 tx_stop(info); in shutdown()
1348 reset_device(info); in shutdown()
1351 info->serial_signals &= ~(SerialSignal_RTS | SerialSignal_DTR); in shutdown()
1352 set_signals(info); in shutdown()
1355 spin_unlock_irqrestore(&info->lock, flags); in shutdown()
1357 release_resources(info); in shutdown()
1362 tty_port_set_initialized(&info->port, 0); in shutdown()
1365 static void mgslpc_program_hw(MGSLPC_INFO *info, struct tty_struct *tty) in mgslpc_program_hw() argument
1369 spin_lock_irqsave(&info->lock, flags); in mgslpc_program_hw()
1371 rx_stop(info); in mgslpc_program_hw()
1372 tx_stop(info); 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()
1376 hdlc_mode(info); in mgslpc_program_hw()
1378 async_mode(info); in mgslpc_program_hw()
1380 set_signals(info); 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()
1387 irq_enable(info, CHB, IRQ_DCD | IRQ_CTS); in mgslpc_program_hw()
1388 port_irq_enable(info, (unsigned char) PVR_DSR | PVR_RI); in mgslpc_program_hw()
1389 get_signals(info); in mgslpc_program_hw()
1391 if (info->netcount || (tty && C_CREAD(tty))) in mgslpc_program_hw()
1392 rx_start(info); in mgslpc_program_hw()
1394 spin_unlock_irqrestore(&info->lock, flags); in mgslpc_program_hw()
1399 static void mgslpc_change_params(MGSLPC_INFO *info, struct tty_struct *tty) in mgslpc_change_params() argument
1409 __FILE__, __LINE__, info->device_name); 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()
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()
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()
1474 mgslpc_program_hw(info, tty); in mgslpc_change_params()
1481 MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; in mgslpc_put_char() local
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() local
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()
1534 tx_start(info, tty); 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() local
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()
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()
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()
1596 tx_start(info, tty); 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() local
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() local
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() local
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()
1687 MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; in mgslpc_send_xchar() local
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()
1701 tx_start(info, tty); 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() local
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()
1726 set_signals(info); 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() local
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()
1755 set_signals(info); in mgslpc_unthrottle()
1756 spin_unlock_irqrestore(&info->lock, flags); in mgslpc_unthrottle()
1762 static int get_stats(MGSLPC_INFO * info, struct mgsl_icount __user *user_icount) in get_stats() argument
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()
1779 static int get_params(MGSLPC_INFO * info, MGSL_PARAMS __user *user_params) in get_params() argument
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()
1799 static int set_params(MGSLPC_INFO * info, MGSL_PARAMS __user *new_params, struct tty_struct *tty) in set_params() argument
1807 info->device_name); in set_params()
1812 __FILE__, __LINE__, info->device_name); 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()
1820 mgslpc_change_params(info, tty); in set_params()
1825 static int get_txidle(MGSLPC_INFO * info, int __user *idle_mode) in get_txidle() argument
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()
1836 static int set_txidle(MGSLPC_INFO * info, int idle_mode) in set_txidle() argument
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()
1843 tx_set_idle(info); in set_txidle()
1844 spin_unlock_irqrestore(&info->lock, flags); in set_txidle()
1848 static int get_interface(MGSLPC_INFO * info, int __user *if_mode) in get_interface() argument
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()
1859 static int set_interface(MGSLPC_INFO * info, int if_mode) in set_interface() argument
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()
1868 val = read_reg(info, PVR) & 0x0f; in set_interface()
1869 switch (info->if_mode) in set_interface()
1875 write_reg(info, PVR, val); in set_interface()
1877 spin_unlock_irqrestore(&info->lock, flags); in set_interface()
1881 static int set_txenable(MGSLPC_INFO * info, int enable, struct tty_struct *tty) in set_txenable() argument
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()
1891 tx_start(info, tty); in set_txenable()
1893 if (info->tx_enabled) in set_txenable()
1894 tx_stop(info); in set_txenable()
1896 spin_unlock_irqrestore(&info->lock, flags); in set_txenable()
1900 static int tx_abort(MGSLPC_INFO * info) in tx_abort() argument
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()
1920 static int set_rxenable(MGSLPC_INFO * info, int enable) in set_rxenable() argument
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()
1930 rx_start(info); in set_rxenable()
1932 if (info->rx_enabled) in set_rxenable()
1933 rx_stop(info); in set_rxenable()
1935 spin_unlock_irqrestore(&info->lock, flags); in set_rxenable()
1947 static int wait_events(MGSLPC_INFO * info, int __user *mask_ptr) in wait_events() argument
1963 printk("wait_events(%s,%d)\n", info->device_name, mask); in wait_events()
1965 spin_lock_irqsave(&info->lock, flags); in wait_events()
1968 get_signals(info); 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()
1986 irq_enable(info, CHA, IRQ_EXITHUNT); 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()
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()
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()
2047 irq_disable(info, CHA, IRQ_EXITHUNT); in wait_events()
2048 spin_unlock_irqrestore(&info->lock, flags); in wait_events()
2056 static int modem_input_wait(MGSLPC_INFO *info,int arg) in modem_input_wait() argument
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()
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()
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() local
2114 spin_lock_irqsave(&info->lock, flags); in tiocmget()
2115 get_signals(info); 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() local
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()
2153 set_signals(info); in tiocmset()
2154 spin_unlock_irqrestore(&info->lock, flags); in tiocmset()
2166 MGSLPC_INFO * info = (MGSLPC_INFO *)tty->driver_data; in mgslpc_break() local
2171 __FILE__, __LINE__, info->device_name, break_state); in mgslpc_break()
2173 if (mgslpc_paranoia_check(info, tty->name, "mgslpc_break")) in mgslpc_break()
2176 spin_lock_irqsave(&info->lock, flags); in mgslpc_break()
2178 set_reg_bits(info, CHA+DAFO, BIT6); in mgslpc_break()
2180 clear_reg_bits(info, CHA+DAFO, BIT6); 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() local
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()
2224 MGSLPC_INFO * info = (MGSLPC_INFO *)tty->driver_data; in mgslpc_ioctl() local
2229 info->device_name, cmd); in mgslpc_ioctl()
2231 if (mgslpc_paranoia_check(info, tty->name, "mgslpc_ioctl")) in mgslpc_ioctl()
2241 return get_params(info, argp); in mgslpc_ioctl()
2243 return set_params(info, argp, tty); in mgslpc_ioctl()
2245 return get_txidle(info, argp); in mgslpc_ioctl()
2247 return set_txidle(info, (int)arg); in mgslpc_ioctl()
2249 return get_interface(info, argp); in mgslpc_ioctl()
2251 return set_interface(info,(int)arg); in mgslpc_ioctl()
2253 return set_txenable(info,(int)arg, tty); in mgslpc_ioctl()
2255 return set_rxenable(info,(int)arg); in mgslpc_ioctl()
2257 return tx_abort(info); in mgslpc_ioctl()
2259 return get_stats(info, argp); in mgslpc_ioctl()
2261 return wait_events(info, argp); in mgslpc_ioctl()
2263 return modem_input_wait(info,(int)arg); in mgslpc_ioctl()
2280 MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; in mgslpc_set_termios() local
2293 mgslpc_change_params(info, 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()
2299 set_signals(info); in mgslpc_set_termios()
2300 spin_unlock_irqrestore(&info->lock, flags); 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()
2309 set_signals(info); in mgslpc_set_termios()
2310 spin_unlock_irqrestore(&info->lock, flags); in mgslpc_set_termios()
2322 MGSLPC_INFO * info = (MGSLPC_INFO *)tty->driver_data; in mgslpc_close() local
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()
2341 shutdown(info, tty); in mgslpc_close()
2355 MGSLPC_INFO * info = (MGSLPC_INFO *)tty->driver_data; in mgslpc_wait_until_sent() local
2358 if (!info) 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()
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() local
2423 __FILE__, __LINE__, info->device_name); in mgslpc_hangup()
2425 if (mgslpc_paranoia_check(info, tty->name, "mgslpc_hangup")) in mgslpc_hangup()
2429 shutdown(info, tty); in mgslpc_hangup()
2430 tty_port_hangup(&info->port); in mgslpc_hangup()
2435 MGSLPC_INFO *info = container_of(port, MGSLPC_INFO, port); in carrier_raised() local
2438 spin_lock_irqsave(&info->lock, flags); in carrier_raised()
2439 get_signals(info); in carrier_raised()
2440 spin_unlock_irqrestore(&info->lock, flags); in carrier_raised()
2442 if (info->serial_signals & SerialSignal_DCD) in carrier_raised()
2449 MGSLPC_INFO *info = container_of(port, MGSLPC_INFO, port); in dtr_rts() local
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()
2457 set_signals(info); in dtr_rts()
2458 spin_unlock_irqrestore(&info->lock, flags); in dtr_rts()
2464 MGSLPC_INFO *info; in mgslpc_open() local
2478 info = mgslpc_device_list; 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()
2484 port = &info->port; in mgslpc_open()
2485 tty->driver_data = info; in mgslpc_open()
2492 spin_lock_irqsave(&info->netlock, flags); in mgslpc_open()
2493 if (info->netcount) { in mgslpc_open()
2495 spin_unlock_irqrestore(&info->netlock, flags); in mgslpc_open()
2501 spin_unlock_irqrestore(&info->netlock, flags); in mgslpc_open()
2505 retval = startup(info, tty); 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()
2531 static inline void line_info(struct seq_file *m, MGSLPC_INFO *info) in line_info() argument
2537 info->device_name, info->io_base, info->irq_level); in line_info()
2540 spin_lock_irqsave(&info->lock, flags); in line_info()
2541 get_signals(info); 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()
2599 MGSLPC_INFO *info; in mgslpc_proc_show() local
2603 info = mgslpc_device_list; in mgslpc_proc_show()
2604 while (info) { in mgslpc_proc_show()
2605 line_info(m, info); in mgslpc_proc_show()
2606 info = info->next_device; in mgslpc_proc_show()
2611 static int rx_alloc_buffers(MGSLPC_INFO *info) in rx_alloc_buffers() argument
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()
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()
2638 rx_reset_buffers(info); in rx_alloc_buffers()
2642 static void rx_free_buffers(MGSLPC_INFO *info) in rx_free_buffers() argument
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()
2650 static int claim_resources(MGSLPC_INFO *info) in claim_resources() argument
2652 if (rx_alloc_buffers(info) < 0) { in claim_resources()
2653 printk("Can't allocate rx buffer %s\n", info->device_name); in claim_resources()
2654 release_resources(info); in claim_resources()
2660 static void release_resources(MGSLPC_INFO *info) in release_resources() argument
2663 printk("release_resources(%s)\n", info->device_name); in release_resources()
2664 rx_free_buffers(info); in release_resources()
2672 static int mgslpc_add_device(MGSLPC_INFO *info) in mgslpc_add_device() argument
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()
2690 mgslpc_device_list = info; 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()
2707 ret = hdlcdev_init(info); 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()
2717 hdlcdev_exit(info); in mgslpc_add_device()
2735 MGSLPC_INFO *info = mgslpc_device_list; in mgslpc_remove_device() local
2738 while(info) { in mgslpc_remove_device()
2739 if (info == remove_info) { in mgslpc_remove_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()
2746 hdlcdev_exit(info); in mgslpc_remove_device()
2748 release_resources(info); in mgslpc_remove_device()
2749 tty_port_destroy(&info->port); in mgslpc_remove_device()
2750 kfree(info); in mgslpc_remove_device()
2754 last = info; in mgslpc_remove_device()
2755 info = info->next_device; in mgslpc_remove_device()
2862 static void mgslpc_set_rate(MGSLPC_INFO *info, unsigned char channel, unsigned int rate) in mgslpc_set_rate() argument
2888 write_reg(info, (unsigned char) (channel + BGR), in mgslpc_set_rate()
2890 val = read_reg(info, (unsigned char) (channel + CCR2)) & 0x3f; in mgslpc_set_rate()
2892 write_reg(info, (unsigned char) (channel + CCR2), val); in mgslpc_set_rate()
2898 static void enable_auxclk(MGSLPC_INFO *info) in enable_auxclk() argument
2917 if (info->params.mode == MGSL_MODE_HDLC && info->params.clock_speed) in enable_auxclk()
2919 write_reg(info, CHB + MODE, val); in enable_auxclk()
2931 write_reg(info, CHB + CCR0, 0xc0); in enable_auxclk()
2944 write_reg(info, CHB + CCR1, 0x17); in enable_auxclk()
2958 if (info->params.mode == MGSL_MODE_HDLC && info->params.clock_speed) in enable_auxclk()
2959 write_reg(info, CHB + CCR2, 0x38); in enable_auxclk()
2961 write_reg(info, CHB + CCR2, 0x30); in enable_auxclk()
2974 write_reg(info, CHB + CCR4, 0x50); 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()
2982 mgslpc_set_rate(info, CHB, 921600); in enable_auxclk()
2985 static void loopback_enable(MGSLPC_INFO *info) in loopback_enable() argument
2990 val = read_reg(info, CHA + CCR1) | (BIT2 | BIT1 | BIT0); in loopback_enable()
2991 write_reg(info, CHA + CCR1, val); in loopback_enable()
2994 val = read_reg(info, CHA + CCR2) | (BIT4 | BIT5); in loopback_enable()
2995 write_reg(info, CHA + CCR2, val); in loopback_enable()
2998 if (info->params.clock_speed) in loopback_enable()
2999 mgslpc_set_rate(info, CHA, info->params.clock_speed); in loopback_enable()
3001 mgslpc_set_rate(info, CHA, 1843200); in loopback_enable()
3004 val = read_reg(info, CHA + MODE) | BIT0; in loopback_enable()
3005 write_reg(info, CHA + MODE, val); in loopback_enable()
3008 static void hdlc_mode(MGSLPC_INFO *info) in hdlc_mode() argument
3014 irq_disable(info, CHA, 0xffff); in hdlc_mode()
3015 irq_disable(info, CHB, 0xffff); in hdlc_mode()
3016 port_irq_disable(info, 0xff); in hdlc_mode()
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()
3062 write_reg(info, CHA + MODE, val); in hdlc_mode()
3075 switch (info->params.encoding) in hdlc_mode()
3090 write_reg(info, CHA + CCR0, val); in hdlc_mode()
3104 write_reg(info, CHA + CCR1, val); 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()
3128 write_reg(info, CHA + CCR2, val); 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()
3159 write_reg(info, CHA + CCR3, val); in hdlc_mode()
3163 switch (info->params.preamble) in hdlc_mode()
3170 write_reg(info, CHA + PRE, val); in hdlc_mode()
3184 write_reg(info, CHA + CCR4, val); 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()
3195 write_reg(info, CHA + RLCR, 0); in hdlc_mode()
3208 if (info->params.flags & HDLC_FLAG_AUTO_DCD) in hdlc_mode()
3210 write_reg(info, CHA + XBCH, val); in hdlc_mode()
3211 enable_auxclk(info); in hdlc_mode()
3212 if (info->params.loopback || info->testing_irq) in hdlc_mode()
3213 loopback_enable(info); in hdlc_mode()
3214 if (info->params.flags & HDLC_FLAG_AUTO_CTS) in hdlc_mode()
3216 irq_enable(info, CHB, IRQ_CTS); in hdlc_mode()
3218 set_reg_bits(info, CHA + PVR, BIT3); in hdlc_mode()
3220 clear_reg_bits(info, CHA + PVR, BIT3); in hdlc_mode()
3222 irq_enable(info, CHA, in hdlc_mode()
3225 issue_command(info, CHA, CMD_TXRESET + CMD_RXRESET); in hdlc_mode()
3226 wait_command_complete(info, CHA); in hdlc_mode()
3227 read_reg16(info, CHA + ISR); /* clear pending IRQs */ in hdlc_mode()
3239 if (!info->testing_irq) in hdlc_mode()
3240 clear_reg_bits(info, CHA + CCR0, BIT6); in hdlc_mode()
3242 tx_set_idle(info); in hdlc_mode()
3244 tx_stop(info); in hdlc_mode()
3245 rx_stop(info); in hdlc_mode()
3248 static void rx_stop(MGSLPC_INFO *info) in rx_stop() argument
3252 __FILE__, __LINE__, info->device_name); in rx_stop()
3255 clear_reg_bits(info, CHA + MODE, BIT3); in rx_stop()
3257 info->rx_enabled = false; in rx_stop()
3258 info->rx_overflow = false; in rx_stop()
3261 static void rx_start(MGSLPC_INFO *info) in rx_start() argument
3265 __FILE__, __LINE__, info->device_name); in rx_start()
3267 rx_reset_buffers(info); in rx_start()
3268 info->rx_enabled = false; in rx_start()
3269 info->rx_overflow = false; in rx_start()
3272 set_reg_bits(info, CHA + MODE, BIT3); in rx_start()
3274 info->rx_enabled = true; in rx_start()
3277 static void tx_start(MGSLPC_INFO *info, struct tty_struct *tty) in tx_start() argument
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()
3290 get_signals(info); in tx_start()
3291 if (!(info->serial_signals & SerialSignal_RTS)) { in tx_start()
3292 info->serial_signals |= SerialSignal_RTS; in tx_start()
3293 set_signals(info); 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()
3301 tx_ready(info, tty); in tx_start()
3304 info->tx_active = true; in tx_start()
3305 tx_ready(info, tty); 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()
3315 static void tx_stop(MGSLPC_INFO *info) in tx_stop() argument
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()
3329 static void reset_device(MGSLPC_INFO *info) in reset_device() argument
3332 write_reg(info, CHA + CCR0, 0x80); in reset_device()
3333 write_reg(info, CHB + CCR0, 0x80); in reset_device()
3334 write_reg(info, CHA + MODE, 0); in reset_device()
3335 write_reg(info, CHB + MODE, 0); in reset_device()
3338 irq_disable(info, CHA, 0xffff); in reset_device()
3339 irq_disable(info, CHB, 0xffff); in reset_device()
3340 port_irq_disable(info, 0xff); in reset_device()
3352 write_reg(info, PCR, 0x06); in reset_device()
3376 write_reg(info, IPC, 0x05); in reset_device()
3379 static void async_mode(MGSLPC_INFO *info) in async_mode() argument
3384 irq_disable(info, CHA, 0xffff); in async_mode()
3385 irq_disable(info, CHB, 0xffff); in async_mode()
3386 port_irq_disable(info, 0xff); in async_mode()
3402 if (info->params.loopback) in async_mode()
3406 if (!(info->serial_signals & SerialSignal_RTS)) in async_mode()
3408 write_reg(info, CHA + MODE, val); in async_mode()
3420 write_reg(info, CHA + CCR0, 0x83); in async_mode()
3431 write_reg(info, CHA + CCR1, 0x1f); in async_mode()
3445 write_reg(info, CHA + CCR2, 0x10); in async_mode()
3454 write_reg(info, CHA + CCR3, 0); in async_mode()
3466 write_reg(info, CHA + CCR4, 0x50); 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()
3492 write_reg(info, CHA + DAFO, val); in async_mode()
3506 write_reg(info, CHA + RFC, 0x5c); in async_mode()
3512 write_reg(info, CHA + RLCR, 0); in async_mode()
3525 if (info->params.flags & HDLC_FLAG_AUTO_DCD) in async_mode()
3527 write_reg(info, CHA + XBCH, val); in async_mode()
3528 if (info->params.flags & HDLC_FLAG_AUTO_CTS) in async_mode()
3529 irq_enable(info, CHA, IRQ_CTS); in async_mode()
3532 set_reg_bits(info, CHA + MODE, BIT3); in async_mode()
3533 enable_auxclk(info); in async_mode()
3534 if (info->params.flags & HDLC_FLAG_AUTO_CTS) { in async_mode()
3535 irq_enable(info, CHB, IRQ_CTS); in async_mode()
3537 set_reg_bits(info, CHA + PVR, BIT3); in async_mode()
3539 clear_reg_bits(info, CHA + PVR, BIT3); in async_mode()
3540 irq_enable(info, CHA, in async_mode()
3543 issue_command(info, CHA, CMD_TXRESET + CMD_RXRESET); in async_mode()
3544 wait_command_complete(info, CHA); in async_mode()
3545 read_reg16(info, CHA + ISR); /* clear pending IRQs */ in async_mode()
3550 static void tx_set_idle(MGSLPC_INFO *info) in tx_set_idle() argument
3553 if (info->idle_mode == HDLC_TXIDLE_FLAGS) in tx_set_idle()
3554 set_reg_bits(info, CHA + CCR1, BIT3); in tx_set_idle()
3556 clear_reg_bits(info, CHA + CCR1, BIT3); in tx_set_idle()
3561 static void get_signals(MGSLPC_INFO *info) in get_signals() argument
3566 info->serial_signals &= SerialSignal_RTS | SerialSignal_DTR; in get_signals()
3568 if (read_reg(info, CHB + VSTR) & BIT7) in get_signals()
3569 info->serial_signals |= SerialSignal_DCD; in get_signals()
3570 if (read_reg(info, CHB + STAR) & BIT1) in get_signals()
3571 info->serial_signals |= SerialSignal_CTS; in get_signals()
3573 status = read_reg(info, CHA + PVR); in get_signals()
3575 info->serial_signals |= SerialSignal_RI; in get_signals()
3577 info->serial_signals |= SerialSignal_DSR; in get_signals()
3583 static void set_signals(MGSLPC_INFO *info) in set_signals() argument
3587 val = read_reg(info, CHA + MODE); in set_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()
3599 write_reg(info, CHA + MODE, val); in set_signals()
3601 if (info->serial_signals & SerialSignal_DTR) in set_signals()
3602 clear_reg_bits(info, CHA + PVR, PVR_DTR); in set_signals()
3604 set_reg_bits(info, CHA + PVR, PVR_DTR); in set_signals()
3607 static void rx_reset_buffers(MGSLPC_INFO *info) in rx_reset_buffers() argument
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()
3626 static bool rx_get_frame(MGSLPC_INFO *info, struct tty_struct *tty) in rx_get_frame() argument
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()
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()
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()
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()
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()
3710 static bool register_test(MGSLPC_INFO *info) in register_test() argument
3719 spin_lock_irqsave(&info->lock, flags); in register_test()
3720 reset_device(info); in register_test()
3723 write_reg(info, XAD1, patterns[i]); in register_test()
3724 write_reg(info, XAD2, patterns[(i + 1) % count]); in register_test()
3725 if ((read_reg(info, XAD1) != patterns[i]) || in register_test()
3726 (read_reg(info, XAD2) != patterns[(i + 1) % count])) { in register_test()
3732 spin_unlock_irqrestore(&info->lock, flags); in register_test()
3736 static bool irq_test(MGSLPC_INFO *info) in irq_test() argument
3741 spin_lock_irqsave(&info->lock, flags); in irq_test()
3742 reset_device(info); in irq_test()
3744 info->testing_irq = true; in irq_test()
3745 hdlc_mode(info); in irq_test()
3747 info->irq_occurred = false; in irq_test()
3751 irq_enable(info, CHA, IRQ_TIMER); in irq_test()
3752 write_reg(info, CHA + TIMR, 0); /* 512 cycles */ in irq_test()
3753 issue_command(info, CHA, CMD_START_TIMER); 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()
3765 reset_device(info); in irq_test()
3766 spin_unlock_irqrestore(&info->lock, flags); in irq_test()
3768 return info->irq_occurred; in irq_test()
3771 static int adapter_test(MGSLPC_INFO *info) in adapter_test() argument
3773 if (!register_test(info)) { in adapter_test()
3774 info->init_error = DiagStatus_AddressFailure; in adapter_test()
3776 __FILE__, __LINE__, info->device_name, (unsigned short)(info->io_base)); in adapter_test()
3780 if (!irq_test(info)) { 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()
3789 __FILE__, __LINE__, info->device_name); in adapter_test()
3793 static void trace_block(MGSLPC_INFO *info,const char* data, int count, int xmit) in trace_block() argument
3798 printk("%s tx data:\n", info->device_name); in trace_block()
3800 printk("%s rx data:\n", info->device_name); in trace_block()
3830 MGSLPC_INFO *info = from_timer(info, t, tx_timer); in tx_timeout() local
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()
3848 hdlcdev_tx_done(info); in tx_timeout()
3852 struct tty_struct *tty = tty_port_tty_get(&info->port); in tx_timeout()
3853 bh_transmit(info, tty); in tx_timeout()
3873 MGSLPC_INFO *info = dev_to_port(dev); in hdlcdev_attach() local
3879 if (info->port.count) 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()
3906 mgslpc_program_hw(info, tty); in hdlcdev_attach()
3922 MGSLPC_INFO *info = dev_to_port(dev); in hdlcdev_xmit() local
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()
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()
3950 tx_start(info, tty); in hdlcdev_xmit()
3953 spin_unlock_irqrestore(&info->lock, flags); in hdlcdev_xmit()
3968 MGSLPC_INFO *info = dev_to_port(dev); in hdlcdev_open() local
3982 spin_lock_irqsave(&info->netlock, flags); in hdlcdev_open()
3983 if (info->port.count != 0 || info->netcount != 0) { in hdlcdev_open()
3985 spin_unlock_irqrestore(&info->netlock, flags); 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()
3993 rc = startup(info, tty); 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()
4003 mgslpc_program_hw(info, tty); in hdlcdev_open()
4011 spin_lock_irqsave(&info->lock, flags); in hdlcdev_open()
4012 get_signals(info); in hdlcdev_open()
4013 spin_unlock_irqrestore(&info->lock, flags); in hdlcdev_open()
4014 if (info->serial_signals & SerialSignal_DCD) in hdlcdev_open()
4031 MGSLPC_INFO *info = dev_to_port(dev); in hdlcdev_close() local
4032 struct tty_struct *tty = tty_port_tty_get(&info->port); in hdlcdev_close()
4041 shutdown(info, tty); 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()
4065 MGSLPC_INFO *info = dev_to_port(dev); in hdlcdev_wan_ioctl() local
4072 if (info->port.count) 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()
4119 case CLOCK_DEFAULT: flags = info->params.flags & 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()
4146 mgslpc_program_hw(info, tty); in hdlcdev_wan_ioctl()
4162 MGSLPC_INFO *info = dev_to_port(dev); in hdlcdev_tx_timeout() local
4171 spin_lock_irqsave(&info->lock, flags); in hdlcdev_tx_timeout()
4172 tx_stop(info); in hdlcdev_tx_timeout()
4173 spin_unlock_irqrestore(&info->lock, flags); in hdlcdev_tx_timeout()
4184 static void hdlcdev_tx_done(MGSLPC_INFO *info) in hdlcdev_tx_done() argument
4186 if (netif_queue_stopped(info->netdev)) in hdlcdev_tx_done()
4187 netif_wake_queue(info->netdev); in hdlcdev_tx_done()
4198 static void hdlcdev_rx(MGSLPC_INFO *info, char *buf, int size) in hdlcdev_rx() argument
4201 struct net_device *dev = info->netdev; in hdlcdev_rx()
4238 static int hdlcdev_init(MGSLPC_INFO *info) in hdlcdev_init() argument
4246 dev = alloc_hdlcdev(info); in hdlcdev_init()
4253 dev->base_addr = info->io_base; in hdlcdev_init()
4254 dev->irq = info->irq_level; in hdlcdev_init()
4274 info->netdev = dev; in hdlcdev_init()
4284 static void hdlcdev_exit(MGSLPC_INFO *info) in hdlcdev_exit() argument
4286 unregister_hdlc_device(info->netdev); in hdlcdev_exit()
4287 free_netdev(info->netdev); in hdlcdev_exit()
4288 info->netdev = NULL; in hdlcdev_exit()