Lines Matching refs:info
572 static void sppp_init(SLMP_INFO *info);
573 static void sppp_delete(SLMP_INFO *info);
574 static void sppp_rx_done(SLMP_INFO *info, char *buf, int size);
575 static void sppp_tx_done(SLMP_INFO *info);
587 static int get_stats(SLMP_INFO *info, struct mgsl_icount *user_icount);
588 static int get_params(SLMP_INFO *info, MGSL_PARAMS *params);
589 static int set_params(SLMP_INFO *info, MGSL_PARAMS *params);
590 static int get_txidle(SLMP_INFO *info, int*idle_mode);
591 static int set_txidle(SLMP_INFO *info, int idle_mode);
592 static int tx_enable(SLMP_INFO *info, int enable);
593 static int tx_abort(SLMP_INFO *info);
594 static int rx_enable(SLMP_INFO *info, int enable);
596 static int modem_input_wait(SLMP_INFO *info,int arg);
597 static int wait_mgsl_event(SLMP_INFO *info, int *mask_ptr);
598 static int get_modem_info(SLMP_INFO *info, unsigned int *value);
599 static int set_modem_info(SLMP_INFO *info, unsigned int cmd,unsigned int *value);
602 static void add_device(SLMP_INFO *info);
604 static int claim_resources(SLMP_INFO *info);
605 static void release_resources(SLMP_INFO *info);
607 static int startup(SLMP_INFO *info);
608 static int block_til_ready(struct tty_struct *tty, struct file * filp,SLMP_INFO *info);
609 static void shutdown(SLMP_INFO *info);
610 static void program_hw(SLMP_INFO *info);
611 static void change_params(SLMP_INFO *info);
613 static int init_adapter(SLMP_INFO *info);
614 static int register_test(SLMP_INFO *info);
615 static int irq_test(SLMP_INFO *info);
616 static int loopback_test(SLMP_INFO *info);
617 static int adapter_test(SLMP_INFO *info);
618 static int memory_test(SLMP_INFO *info);
620 static void reset_adapter(SLMP_INFO *info);
621 static void reset_port(SLMP_INFO *info);
622 static void async_mode(SLMP_INFO *info);
623 static void hdlc_mode(SLMP_INFO *info);
625 static void rx_stop(SLMP_INFO *info);
626 static void rx_start(SLMP_INFO *info);
627 static void rx_reset_buffers(SLMP_INFO *info);
628 static void rx_free_frame_buffers(SLMP_INFO *info, unsigned int first, unsigned int last);
629 static int rx_get_frame(SLMP_INFO *info);
631 static void tx_start(SLMP_INFO *info);
632 static void tx_stop(SLMP_INFO *info);
633 static void tx_load_fifo(SLMP_INFO *info);
634 static void tx_set_idle(SLMP_INFO *info);
635 static void tx_load_dma_buffer(SLMP_INFO *info, const char *buf, unsigned int count);
637 static void get_signals(SLMP_INFO *info);
638 static void set_signals(SLMP_INFO *info);
639 static void enable_loopback(SLMP_INFO *info, int enable);
640 static void set_rate(SLMP_INFO *info, u32 data_rate);
642 static int bh_action(SLMP_INFO *info);
644 static void bh_receive(SLMP_INFO *info);
645 static void bh_transmit(SLMP_INFO *info);
646 static void bh_status(SLMP_INFO *info);
647 static void isr_timer(SLMP_INFO *info);
648 static void isr_rxint(SLMP_INFO *info);
649 static void isr_rxrdy(SLMP_INFO *info);
650 static void isr_txint(SLMP_INFO *info);
651 static void isr_txrdy(SLMP_INFO *info);
652 static void isr_rxdmaok(SLMP_INFO *info);
653 static void isr_rxdmaerror(SLMP_INFO *info);
654 static void isr_txdmaok(SLMP_INFO *info);
655 static void isr_txdmaerror(SLMP_INFO *info);
656 static void isr_io_pin(SLMP_INFO *info, u16 status);
659 static int alloc_dma_bufs(SLMP_INFO *info);
660 static void free_dma_bufs(SLMP_INFO *info);
661 static int alloc_buf_list(SLMP_INFO *info);
662 static int alloc_frame_bufs(SLMP_INFO *info, SCADESC *list, SCADESC_EX *list_ex,int count);
663 static int alloc_tmp_rx_buf(SLMP_INFO *info);
664 static void free_tmp_rx_buf(SLMP_INFO *info);
666 static void load_pci_memory(SLMP_INFO *info, char* dest, const char* src, unsigned short count);
667 static void trace_block(SLMP_INFO *info, const char* data, int count, int xmit);
671 static unsigned char read_reg(SLMP_INFO *info, unsigned char addr);
672 static void write_reg(SLMP_INFO *info, unsigned char addr, unsigned char val);
673 static u16 read_reg16(SLMP_INFO *info, unsigned char addr);
674 static void write_reg16(SLMP_INFO *info, unsigned char addr, u16 val);
675 static unsigned char read_status_reg(SLMP_INFO * info);
676 static void write_control_reg(SLMP_INFO * info);
714 static inline int sanity_check(SLMP_INFO *info, in sanity_check() argument
723 if (!info) { in sanity_check()
727 if (info->magic != MGSL_MAGIC) { in sanity_check()
732 if (!info) in sanity_check()
767 SLMP_INFO *info; in open() local
778 info = synclinkmp_device_list; in open()
779 while(info && info->line != line) in open()
780 info = info->next_device; in open()
781 if (sanity_check(info, tty->device, "open")) in open()
783 if ( info->init_error ) { in open()
785 __FILE__,__LINE__,info->device_name,info->init_error); in open()
789 tty->driver_data = info; in open()
790 info->tty = tty; in open()
794 __FILE__,__LINE__,tty->driver.name, info->count); in open()
799 if (tty_hung_up_p(filp) || info->flags & ASYNC_CLOSING){ in open()
800 if (info->flags & ASYNC_CLOSING) in open()
801 interruptible_sleep_on(&info->close_wait); in open()
802 retval = ((info->flags & ASYNC_HUP_NOTIFY) ? in open()
807 info->tty->low_latency = (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0; in open()
809 spin_lock_irqsave(&info->netlock, flags); in open()
810 if (info->netcount) { in open()
812 spin_unlock_irqrestore(&info->netlock, flags); in open()
815 info->count++; in open()
816 spin_unlock_irqrestore(&info->netlock, flags); in open()
818 if (info->count == 1) { in open()
820 retval = startup(info); in open()
825 retval = block_til_ready(tty, filp, info); in open()
829 __FILE__,__LINE__, info->device_name, retval); in open()
833 if ((info->count == 1) && in open()
834 info->flags & ASYNC_SPLIT_TERMIOS) { in open()
836 *tty->termios = info->normal_termios; in open()
838 *tty->termios = info->callout_termios; in open()
839 change_params(info); in open()
842 info->session = current->session; in open()
843 info->pgrp = current->pgrp; in open()
847 __FILE__,__LINE__, info->device_name); in open()
853 info->tty = 0; /* tty layer will release tty struct */ in open()
856 if(info->count) in open()
857 info->count--; in open()
868 SLMP_INFO * info = (SLMP_INFO *)tty->driver_data; in close() local
870 if (sanity_check(info, tty->device, "close")) in close()
875 __FILE__,__LINE__, info->device_name, info->count); in close()
877 if (!info->count) in close()
883 if ((tty->count == 1) && (info->count != 1)) { in close()
891 __FILE__,__LINE__, info->device_name, info->count); in close()
892 info->count = 1; in close()
895 info->count--; in close()
898 if (info->count) in close()
901 info->flags |= ASYNC_CLOSING; in close()
906 if (info->flags & ASYNC_NORMAL_ACTIVE) in close()
907 info->normal_termios = *tty->termios; in close()
908 if (info->flags & ASYNC_CALLOUT_ACTIVE) in close()
909 info->callout_termios = *tty->termios; in close()
919 if (info->closing_wait != ASYNC_CLOSING_WAIT_NONE) { in close()
922 __FILE__,__LINE__, info->device_name ); in close()
923 tty_wait_until_sent(tty, info->closing_wait); in close()
926 if (info->flags & ASYNC_INITIALIZED) in close()
927 wait_until_sent(tty, info->timeout); in close()
934 shutdown(info); in close()
937 info->tty = 0; in close()
939 if (info->blocked_open) { in close()
940 if (info->close_delay) { in close()
942 schedule_timeout(info->close_delay); in close()
944 wake_up_interruptible(&info->open_wait); in close()
947 info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CALLOUT_ACTIVE| in close()
950 wake_up_interruptible(&info->close_wait); in close()
955 tty->driver.name, info->count); in close()
965 SLMP_INFO *info = (SLMP_INFO *)tty->driver_data; in hangup() local
969 __FILE__,__LINE__, info->device_name ); in hangup()
971 if (sanity_check(info, tty->device, "hangup")) in hangup()
975 shutdown(info); in hangup()
977 info->count = 0; in hangup()
978 info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CALLOUT_ACTIVE); in hangup()
979 info->tty = 0; in hangup()
981 wake_up_interruptible(&info->open_wait); in hangup()
988 SLMP_INFO *info = (SLMP_INFO *)tty->driver_data; in set_termios() local
1001 change_params(info); in set_termios()
1006 info->serial_signals &= ~(SerialSignal_RTS + SerialSignal_DTR); in set_termios()
1007 spin_lock_irqsave(&info->lock,flags); in set_termios()
1008 set_signals(info); in set_termios()
1009 spin_unlock_irqrestore(&info->lock,flags); in set_termios()
1015 info->serial_signals |= SerialSignal_DTR; in set_termios()
1018 info->serial_signals |= SerialSignal_RTS; in set_termios()
1020 spin_lock_irqsave(&info->lock,flags); in set_termios()
1021 set_signals(info); in set_termios()
1022 spin_unlock_irqrestore(&info->lock,flags); in set_termios()
1048 SLMP_INFO *info = (SLMP_INFO *)tty->driver_data; in write() local
1053 __FILE__,__LINE__,info->device_name,count); in write()
1055 if (sanity_check(info, tty->device, "write")) in write()
1058 if (!tty || !info->tx_buf) in write()
1061 if (info->params.mode == MGSL_MODE_HDLC) { in write()
1062 if (count > info->max_frame_size) { in write()
1066 if (info->tx_active) in write()
1068 if (info->tx_count) { in write()
1071 tx_load_dma_buffer(info, info->tx_buf, info->tx_count); in write()
1075 ret = info->tx_count = count; in write()
1076 tx_load_dma_buffer(info, buf, count); in write()
1083 MIN(info->max_frame_size - info->tx_count - 1, in write()
1084 info->max_frame_size - info->tx_put)); in write()
1089 COPY_FROM_USER(err, info->tx_buf + info->tx_put, buf, c); in write()
1096 memcpy(info->tx_buf + info->tx_put, buf, c); in write()
1098 spin_lock_irqsave(&info->lock,flags); in write()
1099 info->tx_put += c; in write()
1100 if (info->tx_put >= info->max_frame_size) in write()
1101 info->tx_put -= info->max_frame_size; in write()
1102 info->tx_count += c; in write()
1103 spin_unlock_irqrestore(&info->lock,flags); in write()
1110 if (info->params.mode == MGSL_MODE_HDLC) { in write()
1112 ret = info->tx_count = 0; in write()
1115 tx_load_dma_buffer(info, info->tx_buf, info->tx_count); in write()
1118 if (info->tx_count && !tty->stopped && !tty->hw_stopped) { in write()
1119 spin_lock_irqsave(&info->lock,flags); in write()
1120 if (!info->tx_active) in write()
1121 tx_start(info); in write()
1122 spin_unlock_irqrestore(&info->lock,flags); in write()
1128 __FILE__,__LINE__,info->device_name,ret); in write()
1136 SLMP_INFO *info = (SLMP_INFO *)tty->driver_data; in put_char() local
1141 __FILE__,__LINE__,info->device_name,ch); in put_char()
1144 if (sanity_check(info, tty->device, "put_char")) in put_char()
1147 if (!tty || !info->tx_buf) in put_char()
1150 spin_lock_irqsave(&info->lock,flags); in put_char()
1152 if ( (info->params.mode != MGSL_MODE_HDLC) || in put_char()
1153 !info->tx_active ) { in put_char()
1155 if (info->tx_count < info->max_frame_size - 1) { in put_char()
1156 info->tx_buf[info->tx_put++] = ch; in put_char()
1157 if (info->tx_put >= info->max_frame_size) in put_char()
1158 info->tx_put -= info->max_frame_size; in put_char()
1159 info->tx_count++; in put_char()
1163 spin_unlock_irqrestore(&info->lock,flags); in put_char()
1170 SLMP_INFO *info = (SLMP_INFO *)tty->driver_data; in send_xchar() local
1175 __FILE__,__LINE__, info->device_name, ch ); in send_xchar()
1177 if (sanity_check(info, tty->device, "send_xchar")) in send_xchar()
1180 info->x_char = ch; in send_xchar()
1183 spin_lock_irqsave(&info->lock,flags); in send_xchar()
1184 if (!info->tx_enabled) in send_xchar()
1185 tx_start(info); in send_xchar()
1186 spin_unlock_irqrestore(&info->lock,flags); in send_xchar()
1194 SLMP_INFO * info = (SLMP_INFO *)tty->driver_data; in wait_until_sent() local
1197 if (!info ) in wait_until_sent()
1202 __FILE__,__LINE__, info->device_name ); in wait_until_sent()
1204 if (sanity_check(info, tty->device, "wait_until_sent")) in wait_until_sent()
1207 if (!(info->flags & ASYNC_INITIALIZED)) in wait_until_sent()
1218 if ( info->params.data_rate ) { in wait_until_sent()
1219 char_time = info->timeout/(32 * 5); in wait_until_sent()
1228 if ( info->params.mode == MGSL_MODE_HDLC ) { in wait_until_sent()
1229 while (info->tx_active) { in wait_until_sent()
1240 while ( info->tx_active && info->tx_enabled) { in wait_until_sent()
1253 __FILE__,__LINE__, info->device_name ); in wait_until_sent()
1260 SLMP_INFO *info = (SLMP_INFO *)tty->driver_data; in write_room() local
1263 if (sanity_check(info, tty->device, "write_room")) in write_room()
1266 if (info->params.mode == MGSL_MODE_HDLC) { in write_room()
1267 ret = (info->tx_active) ? 0 : HDLC_MAX_FRAME_SIZE; in write_room()
1269 ret = info->max_frame_size - info->tx_count - 1; in write_room()
1276 __FILE__, __LINE__, info->device_name, ret); in write_room()
1285 SLMP_INFO *info = (SLMP_INFO *)tty->driver_data; in flush_chars() local
1290 __FILE__,__LINE__,info->device_name,info->tx_count); in flush_chars()
1292 if (sanity_check(info, tty->device, "flush_chars")) in flush_chars()
1295 if (info->tx_count <= 0 || tty->stopped || tty->hw_stopped || in flush_chars()
1296 !info->tx_buf) in flush_chars()
1301 __FILE__,__LINE__,info->device_name ); in flush_chars()
1303 spin_lock_irqsave(&info->lock,flags); in flush_chars()
1305 if (!info->tx_active) { in flush_chars()
1306 if ( (info->params.mode == MGSL_MODE_HDLC) && in flush_chars()
1307 info->tx_count ) { in flush_chars()
1311 tx_load_dma_buffer(info, in flush_chars()
1312 info->tx_buf,info->tx_count); in flush_chars()
1314 tx_start(info); in flush_chars()
1317 spin_unlock_irqrestore(&info->lock,flags); in flush_chars()
1324 SLMP_INFO *info = (SLMP_INFO *)tty->driver_data; in flush_buffer() local
1329 __FILE__,__LINE__, info->device_name ); in flush_buffer()
1331 if (sanity_check(info, tty->device, "flush_buffer")) in flush_buffer()
1334 spin_lock_irqsave(&info->lock,flags); in flush_buffer()
1335 info->tx_count = info->tx_put = info->tx_get = 0; in flush_buffer()
1336 del_timer(&info->tx_timer); in flush_buffer()
1337 spin_unlock_irqrestore(&info->lock,flags); in flush_buffer()
1347 SLMP_INFO *info = (SLMP_INFO *)tty->driver_data; in tx_hold() local
1350 if (sanity_check(info, tty->device, "tx_hold")) in tx_hold()
1355 __FILE__,__LINE__,info->device_name); in tx_hold()
1357 spin_lock_irqsave(&info->lock,flags); in tx_hold()
1358 if (info->tx_enabled) in tx_hold()
1359 tx_stop(info); in tx_hold()
1360 spin_unlock_irqrestore(&info->lock,flags); in tx_hold()
1367 SLMP_INFO *info = (SLMP_INFO *)tty->driver_data; in tx_release() local
1370 if (sanity_check(info, tty->device, "tx_release")) in tx_release()
1375 __FILE__,__LINE__,info->device_name); in tx_release()
1377 spin_lock_irqsave(&info->lock,flags); in tx_release()
1378 if (!info->tx_enabled) in tx_release()
1379 tx_start(info); in tx_release()
1380 spin_unlock_irqrestore(&info->lock,flags); in tx_release()
1397 SLMP_INFO *info = (SLMP_INFO *)tty->driver_data; in ioctl() local
1405 info->device_name, cmd ); in ioctl()
1407 if (sanity_check(info, tty->device, "ioctl")) in ioctl()
1418 return get_modem_info(info, (unsigned int *) arg); in ioctl()
1422 return set_modem_info(info, cmd, (unsigned int *) arg); in ioctl()
1424 return get_params(info,(MGSL_PARAMS *)arg); in ioctl()
1426 return set_params(info,(MGSL_PARAMS *)arg); in ioctl()
1428 return get_txidle(info,(int*)arg); in ioctl()
1430 return set_txidle(info,(int)arg); in ioctl()
1432 return tx_enable(info,(int)arg); in ioctl()
1434 return rx_enable(info,(int)arg); in ioctl()
1436 return tx_abort(info); in ioctl()
1438 return get_stats(info,(struct mgsl_icount*)arg); in ioctl()
1440 return wait_mgsl_event(info,(int*)arg); in ioctl()
1451 return modem_input_wait(info,(int)arg); in ioctl()
1460 spin_lock_irqsave(&info->lock,flags); in ioctl()
1461 cnow = info->icount; in ioctl()
1462 spin_unlock_irqrestore(&info->lock,flags); in ioctl()
1497 static inline int line_info(char *buf, SLMP_INFO *info) in line_info() argument
1505 info->device_name, in line_info()
1506 info->phys_sca_base, in line_info()
1507 info->phys_memory_base, in line_info()
1508 info->phys_statctrl_base, in line_info()
1509 info->phys_lcr_base, in line_info()
1510 info->irq_level, in line_info()
1511 info->max_frame_size ); in line_info()
1514 spin_lock_irqsave(&info->lock,flags); in line_info()
1515 get_signals(info); in line_info()
1516 spin_unlock_irqrestore(&info->lock,flags); in line_info()
1520 if (info->serial_signals & SerialSignal_RTS) in line_info()
1522 if (info->serial_signals & SerialSignal_CTS) in line_info()
1524 if (info->serial_signals & SerialSignal_DTR) in line_info()
1526 if (info->serial_signals & SerialSignal_DSR) in line_info()
1528 if (info->serial_signals & SerialSignal_DCD) in line_info()
1530 if (info->serial_signals & SerialSignal_RI) in line_info()
1533 if (info->params.mode == MGSL_MODE_HDLC) { in line_info()
1535 info->icount.txok, info->icount.rxok); in line_info()
1536 if (info->icount.txunder) in line_info()
1537 ret += sprintf(buf+ret, " txunder:%d", info->icount.txunder); in line_info()
1538 if (info->icount.txabort) in line_info()
1539 ret += sprintf(buf+ret, " txabort:%d", info->icount.txabort); in line_info()
1540 if (info->icount.rxshort) in line_info()
1541 ret += sprintf(buf+ret, " rxshort:%d", info->icount.rxshort); in line_info()
1542 if (info->icount.rxlong) in line_info()
1543 ret += sprintf(buf+ret, " rxlong:%d", info->icount.rxlong); in line_info()
1544 if (info->icount.rxover) in line_info()
1545 ret += sprintf(buf+ret, " rxover:%d", info->icount.rxover); in line_info()
1546 if (info->icount.rxcrc) in line_info()
1547 ret += sprintf(buf+ret, " rxlong:%d", info->icount.rxcrc); in line_info()
1550 info->icount.tx, info->icount.rx); in line_info()
1551 if (info->icount.frame) in line_info()
1552 ret += sprintf(buf+ret, " fe:%d", info->icount.frame); in line_info()
1553 if (info->icount.parity) in line_info()
1554 ret += sprintf(buf+ret, " pe:%d", info->icount.parity); in line_info()
1555 if (info->icount.brk) in line_info()
1556 ret += sprintf(buf+ret, " brk:%d", info->icount.brk); in line_info()
1557 if (info->icount.overrun) in line_info()
1558 ret += sprintf(buf+ret, " oe:%d", info->icount.overrun); in line_info()
1565 info->tx_active,info->bh_requested,info->bh_running, in line_info()
1566 info->pending_bh); in line_info()
1578 SLMP_INFO *info; in read_proc() local
1582 info = synclinkmp_device_list; in read_proc()
1583 while( info ) { in read_proc()
1584 l = line_info(page + len, info); in read_proc()
1592 info = info->next_device; in read_proc()
1607 SLMP_INFO *info = (SLMP_INFO *)tty->driver_data; in chars_in_buffer() local
1609 if (sanity_check(info, tty->device, "chars_in_buffer")) in chars_in_buffer()
1614 __FILE__, __LINE__, info->device_name, info->tx_count); in chars_in_buffer()
1616 return info->tx_count; in chars_in_buffer()
1623 SLMP_INFO *info = (SLMP_INFO *)tty->driver_data; in throttle() local
1628 __FILE__,__LINE__, info->device_name ); in throttle()
1630 if (sanity_check(info, tty->device, "throttle")) in throttle()
1637 spin_lock_irqsave(&info->lock,flags); in throttle()
1638 info->serial_signals &= ~SerialSignal_RTS; in throttle()
1639 set_signals(info); in throttle()
1640 spin_unlock_irqrestore(&info->lock,flags); in throttle()
1648 SLMP_INFO *info = (SLMP_INFO *)tty->driver_data; in unthrottle() local
1653 __FILE__,__LINE__, info->device_name ); in unthrottle()
1655 if (sanity_check(info, tty->device, "unthrottle")) in unthrottle()
1659 if (info->x_char) in unthrottle()
1660 info->x_char = 0; in unthrottle()
1666 spin_lock_irqsave(&info->lock,flags); in unthrottle()
1667 info->serial_signals |= SerialSignal_RTS; in unthrottle()
1668 set_signals(info); in unthrottle()
1669 spin_unlock_irqrestore(&info->lock,flags); in unthrottle()
1679 SLMP_INFO * info = (SLMP_INFO *)tty->driver_data; in set_break() local
1684 __FILE__,__LINE__, info->device_name, break_state); in set_break()
1686 if (sanity_check(info, tty->device, "set_break")) in set_break()
1689 spin_lock_irqsave(&info->lock,flags); in set_break()
1690 RegValue = read_reg(info, CTL); in set_break()
1695 write_reg(info, CTL, RegValue); in set_break()
1696 spin_unlock_irqrestore(&info->lock,flags); in set_break()
1703 static void sppp_init(SLMP_INFO *info) in sppp_init() argument
1707 sprintf(info->netname,"mgslm%dp%d",info->adapter_num,info->port_num); in sppp_init()
1709 info->if_ptr = &info->pppdev; in sppp_init()
1710 info->netdev = info->pppdev.dev = &info->netdevice; in sppp_init()
1712 sppp_attach(&info->pppdev); in sppp_init()
1714 d = info->netdev; in sppp_init()
1715 strcpy(d->name,info->netname); in sppp_init()
1717 d->irq = info->irq_level; in sppp_init()
1719 d->priv = info; in sppp_init()
1735 sppp_detach(info->netdev); in sppp_init()
1740 printk("sppp_init(%s)\n",info->netname); in sppp_init()
1743 static void sppp_delete(SLMP_INFO *info) in sppp_delete() argument
1746 printk("sppp_delete(%s)\n",info->netname); in sppp_delete()
1747 sppp_detach(info->netdev); in sppp_delete()
1748 unregister_netdev(info->netdev); in sppp_delete()
1753 SLMP_INFO *info = d->priv; in sppp_cb_open() local
1757 printk("sppp_cb_open(%s)\n",info->netname); in sppp_cb_open()
1759 spin_lock_irqsave(&info->netlock, flags); in sppp_cb_open()
1760 if (info->count != 0 || info->netcount != 0) { in sppp_cb_open()
1761 printk(KERN_WARNING "%s: sppp_cb_open returning busy\n", info->netname); in sppp_cb_open()
1762 spin_unlock_irqrestore(&info->netlock, flags); in sppp_cb_open()
1765 info->netcount=1; in sppp_cb_open()
1767 spin_unlock_irqrestore(&info->netlock, flags); in sppp_cb_open()
1770 if ((err = startup(info)) != 0) in sppp_cb_open()
1775 shutdown(info); in sppp_cb_open()
1779 info->serial_signals |= SerialSignal_RTS + SerialSignal_DTR; in sppp_cb_open()
1780 program_hw(info); in sppp_cb_open()
1787 spin_lock_irqsave(&info->netlock, flags); in sppp_cb_open()
1788 info->netcount=0; in sppp_cb_open()
1790 spin_unlock_irqrestore(&info->netlock, flags); in sppp_cb_open()
1796 SLMP_INFO *info = dev->priv; in sppp_cb_tx_timeout() local
1800 printk("sppp_tx_timeout(%s)\n",info->netname); in sppp_cb_tx_timeout()
1802 info->netstats.tx_errors++; in sppp_cb_tx_timeout()
1803 info->netstats.tx_aborted_errors++; in sppp_cb_tx_timeout()
1805 spin_lock_irqsave(&info->lock,flags); in sppp_cb_tx_timeout()
1806 tx_stop(info); in sppp_cb_tx_timeout()
1807 spin_unlock_irqrestore(&info->lock,flags); in sppp_cb_tx_timeout()
1814 SLMP_INFO *info = dev->priv; in sppp_cb_tx() local
1818 printk("sppp_tx(%s)\n",info->netname); in sppp_cb_tx()
1822 info->tx_count = skb->len; in sppp_cb_tx()
1823 tx_load_dma_buffer(info, skb->data, skb->len); in sppp_cb_tx()
1824 info->netstats.tx_packets++; in sppp_cb_tx()
1825 info->netstats.tx_bytes += skb->len; in sppp_cb_tx()
1830 spin_lock_irqsave(&info->lock,flags); in sppp_cb_tx()
1831 if (!info->tx_active) in sppp_cb_tx()
1832 tx_start(info); in sppp_cb_tx()
1833 spin_unlock_irqrestore(&info->lock,flags); in sppp_cb_tx()
1840 SLMP_INFO *info = d->priv; in sppp_cb_close() local
1844 printk("sppp_cb_close(%s)\n",info->netname); in sppp_cb_close()
1847 shutdown(info); in sppp_cb_close()
1853 spin_lock_irqsave(&info->netlock, flags); in sppp_cb_close()
1854 info->netcount=0; in sppp_cb_close()
1856 spin_unlock_irqrestore(&info->netlock, flags); in sppp_cb_close()
1860 static void sppp_rx_done(SLMP_INFO *info, char *buf, int size) in sppp_rx_done() argument
1864 printk("sppp_rx_done(%s)\n",info->netname); in sppp_rx_done()
1867 info->netname); in sppp_rx_done()
1868 info->netstats.rx_dropped++; in sppp_rx_done()
1875 skb->dev = info->netdev; in sppp_rx_done()
1877 info->netstats.rx_packets++; in sppp_rx_done()
1878 info->netstats.rx_bytes += size; in sppp_rx_done()
1880 info->netdev->trans_start = jiffies; in sppp_rx_done()
1883 static void sppp_tx_done(SLMP_INFO *info) in sppp_tx_done() argument
1885 if (netif_queue_stopped(info->netdev)) in sppp_tx_done()
1886 netif_wake_queue(info->netdev); in sppp_tx_done()
1891 SLMP_INFO *info = dev->priv; in sppp_cb_net_stats() local
1893 printk("net_stats(%s)\n",info->netname); in sppp_cb_net_stats()
1894 return &info->netstats; in sppp_cb_net_stats()
1899 SLMP_INFO *info = (SLMP_INFO *)dev->priv; in sppp_cb_ioctl() local
1902 info->netname, cmd ); in sppp_cb_ioctl()
1912 int bh_action(SLMP_INFO *info) in bh_action() argument
1917 spin_lock_irqsave(&info->lock,flags); in bh_action()
1919 if (info->pending_bh & BH_RECEIVE) { in bh_action()
1920 info->pending_bh &= ~BH_RECEIVE; in bh_action()
1922 } else if (info->pending_bh & BH_TRANSMIT) { in bh_action()
1923 info->pending_bh &= ~BH_TRANSMIT; in bh_action()
1925 } else if (info->pending_bh & BH_STATUS) { in bh_action()
1926 info->pending_bh &= ~BH_STATUS; in bh_action()
1932 info->bh_running = 0; in bh_action()
1933 info->bh_requested = 0; in bh_action()
1936 spin_unlock_irqrestore(&info->lock,flags); in bh_action()
1945 SLMP_INFO *info = (SLMP_INFO*)Context; in bh_handler() local
1948 if (!info) in bh_handler()
1953 __FILE__,__LINE__,info->device_name); in bh_handler()
1955 info->bh_running = 1; in bh_handler()
1957 while((action = bh_action(info)) != 0) { in bh_handler()
1962 __FILE__,__LINE__,info->device_name, action); in bh_handler()
1967 bh_receive(info); in bh_handler()
1970 bh_transmit(info); in bh_handler()
1973 bh_status(info); in bh_handler()
1978 __FILE__,__LINE__,info->device_name,action); in bh_handler()
1985 __FILE__,__LINE__,info->device_name); in bh_handler()
1988 void bh_receive(SLMP_INFO *info) in bh_receive() argument
1992 __FILE__,__LINE__,info->device_name); in bh_receive()
1994 while( rx_get_frame(info) ); in bh_receive()
1997 void bh_transmit(SLMP_INFO *info) in bh_transmit() argument
1999 struct tty_struct *tty = info->tty; in bh_transmit()
2003 __FILE__,__LINE__,info->device_name); in bh_transmit()
2011 void bh_status(SLMP_INFO *info) in bh_status() argument
2015 __FILE__,__LINE__,info->device_name); in bh_status()
2017 info->ri_chkcount = 0; in bh_status()
2018 info->dsr_chkcount = 0; in bh_status()
2019 info->dcd_chkcount = 0; in bh_status()
2020 info->cts_chkcount = 0; in bh_status()
2023 void isr_timer(SLMP_INFO * info) in isr_timer() argument
2025 unsigned char timer = (info->port_num & 1) ? TIMER2 : TIMER0; in isr_timer()
2028 write_reg(info, IER2, 0); in isr_timer()
2040 write_reg(info, (unsigned char)(timer + TMCS), 0); in isr_timer()
2042 info->irq_occurred = TRUE; in isr_timer()
2046 __FILE__,__LINE__,info->device_name); in isr_timer()
2049 void isr_rxint(SLMP_INFO * info) in isr_rxint() argument
2051 struct tty_struct *tty = info->tty; in isr_rxint()
2052 struct mgsl_icount *icount = &info->icount; in isr_rxint()
2053 unsigned char status = read_reg(info, SR1) & info->ie1_value & (FLGD + IDLD + CDCD + BRKD); in isr_rxint()
2054 unsigned char status2 = read_reg(info, SR2) & info->ie2_value & OVRN; in isr_rxint()
2058 write_reg(info, SR1, status); in isr_rxint()
2061 write_reg(info, SR2, status2); in isr_rxint()
2065 __FILE__,__LINE__,info->device_name,status,status2); in isr_rxint()
2067 if (info->params.mode == MGSL_MODE_ASYNC) { in isr_rxint()
2075 if (!(status & info->ignore_status_mask1)) { in isr_rxint()
2076 if (info->read_status_mask1 & BRKD) { in isr_rxint()
2078 if (info->flags & ASYNC_SAK) in isr_rxint()
2088 info->icount.exithunt++; in isr_rxint()
2090 info->icount.rxidle++; in isr_rxint()
2091 wake_up_interruptible(&info->event_wait_q); in isr_rxint()
2099 get_signals( info ); in isr_rxint()
2100 isr_io_pin(info, in isr_rxint()
2101 MISCSTATUS_DCD_LATCHED|(info->serial_signals&SerialSignal_DCD)); in isr_rxint()
2108 void isr_rxrdy(SLMP_INFO * info) in isr_rxrdy() argument
2112 struct tty_struct *tty = info->tty; in isr_rxrdy()
2113 struct mgsl_icount *icount = &info->icount; in isr_rxrdy()
2117 __FILE__,__LINE__,info->device_name); in isr_rxrdy()
2119 while((status = read_reg(info,CST0)) & BIT0) in isr_rxrdy()
2121 DataByte = read_reg(info,TRB); in isr_rxrdy()
2135 __FILE__,__LINE__,info->device_name,status); in isr_rxrdy()
2146 if (status & info->ignore_status_mask2) in isr_rxrdy()
2149 status &= info->read_status_mask2; in isr_rxrdy()
2180 __FILE__,__LINE__,info->device_name, in isr_rxrdy()
2183 __FILE__,__LINE__,info->device_name, in isr_rxrdy()
2192 void isr_txeom(SLMP_INFO * info, unsigned char status) in isr_txeom() argument
2196 __FILE__,__LINE__,info->device_name,status); in isr_txeom()
2198 write_reg(info, TXDMA + DIR, 0x00); /* disable Tx DMA IRQs */ in isr_txeom()
2199 write_reg(info, TXDMA + DSR, 0xc0); /* clear IRQs and disable DMA */ in isr_txeom()
2200 write_reg(info, TXDMA + DCMD, SWABORT); /* reset/init DMA channel */ in isr_txeom()
2203 write_reg(info, CMD, TXRESET); in isr_txeom()
2204 write_reg(info, CMD, TXENABLE); in isr_txeom()
2206 write_reg(info, CMD, TXBUFCLR); in isr_txeom()
2209 info->ie0_value &= ~TXRDYE; in isr_txeom()
2210 info->ie1_value &= ~(IDLE + UDRN); in isr_txeom()
2211 write_reg16(info, IE0, (unsigned short)((info->ie1_value << 8) + info->ie0_value)); in isr_txeom()
2212 write_reg(info, SR1, (unsigned char)(UDRN + IDLE)); in isr_txeom()
2214 if ( info->tx_active ) { in isr_txeom()
2215 if (info->params.mode != MGSL_MODE_ASYNC) { in isr_txeom()
2217 info->icount.txunder++; in isr_txeom()
2219 info->icount.txok++; in isr_txeom()
2222 info->tx_active = 0; in isr_txeom()
2223 info->tx_count = info->tx_put = info->tx_get = 0; in isr_txeom()
2225 del_timer(&info->tx_timer); in isr_txeom()
2227 if (info->params.mode != MGSL_MODE_ASYNC && info->drop_rts_on_tx_done ) { in isr_txeom()
2228 info->serial_signals &= ~SerialSignal_RTS; in isr_txeom()
2229 info->drop_rts_on_tx_done = 0; in isr_txeom()
2230 set_signals(info); in isr_txeom()
2234 if (info->netcount) in isr_txeom()
2235 sppp_tx_done(info); in isr_txeom()
2239 if (info->tty && (info->tty->stopped || info->tty->hw_stopped)) { in isr_txeom()
2240 tx_stop(info); in isr_txeom()
2243 info->pending_bh |= BH_TRANSMIT; in isr_txeom()
2252 void isr_txint(SLMP_INFO * info) in isr_txint() argument
2254 unsigned char status = read_reg(info, SR1) & info->ie1_value & (UDRN + IDLE + CCTS); in isr_txint()
2257 write_reg(info, SR1, status); in isr_txint()
2261 __FILE__,__LINE__,info->device_name,status); in isr_txint()
2264 isr_txeom(info, status); in isr_txint()
2270 get_signals( info ); in isr_txint()
2271 isr_io_pin(info, in isr_txint()
2272 MISCSTATUS_CTS_LATCHED|(info->serial_signals&SerialSignal_CTS)); in isr_txint()
2280 void isr_txrdy(SLMP_INFO * info) in isr_txrdy() argument
2284 __FILE__,__LINE__,info->device_name,info->tx_count); in isr_txrdy()
2286 if (info->params.mode != MGSL_MODE_ASYNC) { in isr_txrdy()
2288 info->ie0_value &= ~TXRDYE; in isr_txrdy()
2289 info->ie1_value |= IDLE; in isr_txrdy()
2290 write_reg16(info, IE0, (unsigned short)((info->ie1_value << 8) + info->ie0_value)); in isr_txrdy()
2294 if (info->tty && (info->tty->stopped || info->tty->hw_stopped)) { in isr_txrdy()
2295 tx_stop(info); in isr_txrdy()
2299 if ( info->tx_count ) in isr_txrdy()
2300 tx_load_fifo( info ); in isr_txrdy()
2302 info->tx_active = 0; in isr_txrdy()
2303 info->ie0_value &= ~TXRDYE; in isr_txrdy()
2304 write_reg(info, IE0, info->ie0_value); in isr_txrdy()
2307 if (info->tx_count < WAKEUP_CHARS) in isr_txrdy()
2308 info->pending_bh |= BH_TRANSMIT; in isr_txrdy()
2311 void isr_rxdmaok(SLMP_INFO * info) in isr_rxdmaok() argument
2316 unsigned char status = read_reg(info,RXDMA + DSR) & 0xc0; in isr_rxdmaok()
2319 write_reg(info, RXDMA + DSR, (unsigned char)(status | 1)); in isr_rxdmaok()
2323 __FILE__,__LINE__,info->device_name,status); in isr_rxdmaok()
2325 info->pending_bh |= BH_RECEIVE; in isr_rxdmaok()
2328 void isr_rxdmaerror(SLMP_INFO * info) in isr_rxdmaerror() argument
2333 unsigned char status = read_reg(info,RXDMA + DSR) & 0x30; in isr_rxdmaerror()
2336 write_reg(info, RXDMA + DSR, (unsigned char)(status | 1)); in isr_rxdmaerror()
2340 __FILE__,__LINE__,info->device_name,status); in isr_rxdmaerror()
2342 info->rx_overflow = TRUE; in isr_rxdmaerror()
2343 info->pending_bh |= BH_RECEIVE; in isr_rxdmaerror()
2346 void isr_txdmaok(SLMP_INFO * info) in isr_txdmaok() argument
2348 unsigned char status_reg1 = read_reg(info, SR1); in isr_txdmaok()
2350 write_reg(info, TXDMA + DIR, 0x00); /* disable Tx DMA IRQs */ in isr_txdmaok()
2351 write_reg(info, TXDMA + DSR, 0xc0); /* clear IRQs and disable DMA */ in isr_txdmaok()
2352 write_reg(info, TXDMA + DCMD, SWABORT); /* reset/init DMA channel */ in isr_txdmaok()
2356 __FILE__,__LINE__,info->device_name,status_reg1); in isr_txdmaok()
2359 write_reg16(info, TRC0, 0); in isr_txdmaok()
2360 info->ie0_value |= TXRDYE; in isr_txdmaok()
2361 write_reg(info, IE0, info->ie0_value); in isr_txdmaok()
2364 void isr_txdmaerror(SLMP_INFO * info) in isr_txdmaerror() argument
2369 unsigned char status = read_reg(info,TXDMA + DSR) & 0x30; in isr_txdmaerror()
2372 write_reg(info, TXDMA + DSR, (unsigned char)(status | 1)); in isr_txdmaerror()
2376 __FILE__,__LINE__,info->device_name,status); in isr_txdmaerror()
2381 void isr_io_pin( SLMP_INFO *info, u16 status ) in isr_io_pin() argument
2391 icount = &info->icount; in isr_io_pin()
2396 info->input_signal_events.ri_up++; in isr_io_pin()
2398 info->input_signal_events.ri_down++; in isr_io_pin()
2403 info->input_signal_events.dsr_up++; in isr_io_pin()
2405 info->input_signal_events.dsr_down++; in isr_io_pin()
2408 if ((info->dcd_chkcount)++ >= IO_PIN_SHUTDOWN_LIMIT) { in isr_io_pin()
2409 info->ie1_value &= ~CDCD; in isr_io_pin()
2410 write_reg(info, IE1, info->ie1_value); in isr_io_pin()
2414 info->input_signal_events.dcd_up++; in isr_io_pin()
2416 if (info->netcount) in isr_io_pin()
2417 sppp_reopen(info->netdev); in isr_io_pin()
2420 info->input_signal_events.dcd_down++; in isr_io_pin()
2424 if ((info->cts_chkcount)++ >= IO_PIN_SHUTDOWN_LIMIT) { in isr_io_pin()
2425 info->ie1_value &= ~CCTS; in isr_io_pin()
2426 write_reg(info, IE1, info->ie1_value); in isr_io_pin()
2430 info->input_signal_events.cts_up++; in isr_io_pin()
2432 info->input_signal_events.cts_down++; in isr_io_pin()
2434 wake_up_interruptible(&info->status_event_wait_q); in isr_io_pin()
2435 wake_up_interruptible(&info->event_wait_q); in isr_io_pin()
2437 if ( (info->flags & ASYNC_CHECK_CD) && in isr_io_pin()
2440 printk("%s CD now %s...", info->device_name, in isr_io_pin()
2443 wake_up_interruptible(&info->open_wait); in isr_io_pin()
2444 else if (!((info->flags & ASYNC_CALLOUT_ACTIVE) && in isr_io_pin()
2445 (info->flags & ASYNC_CALLOUT_NOHUP))) { in isr_io_pin()
2448 if (info->tty) in isr_io_pin()
2449 tty_hangup(info->tty); in isr_io_pin()
2453 if ( (info->flags & ASYNC_CTS_FLOW) && in isr_io_pin()
2455 if ( info->tty ) { in isr_io_pin()
2456 if (info->tty->hw_stopped) { in isr_io_pin()
2460 info->tty->hw_stopped = 0; in isr_io_pin()
2461 tx_start(info); in isr_io_pin()
2462 info->pending_bh |= BH_TRANSMIT; in isr_io_pin()
2469 info->tty->hw_stopped = 1; in isr_io_pin()
2470 tx_stop(info); in isr_io_pin()
2477 info->pending_bh |= BH_STATUS; in isr_io_pin()
2489 SLMP_INFO * info; in synclinkmp_interrupt() local
2501 info = (SLMP_INFO *)dev_id; in synclinkmp_interrupt()
2502 if (!info) in synclinkmp_interrupt()
2505 spin_lock(&info->lock); in synclinkmp_interrupt()
2510 tmp = read_reg16(info, ISR0); /* get ISR0 and ISR1 in one read */ in synclinkmp_interrupt()
2513 timerstatus0 = read_reg(info, ISR2); in synclinkmp_interrupt()
2517 __FILE__,__LINE__,info->device_name, in synclinkmp_interrupt()
2520 if (info->port_count == 4) { in synclinkmp_interrupt()
2522 tmp = read_reg16(info->port_array[2], ISR0); in synclinkmp_interrupt()
2525 timerstatus1 = read_reg(info->port_array[2], ISR2); in synclinkmp_interrupt()
2529 __FILE__,__LINE__,info->device_name, in synclinkmp_interrupt()
2537 for(i=0; i < info->port_count ; i++) { in synclinkmp_interrupt()
2538 if (info->port_array[i] == NULL) in synclinkmp_interrupt()
2551 isr_rxrdy(info->port_array[i]); in synclinkmp_interrupt()
2553 isr_txrdy(info->port_array[i]); in synclinkmp_interrupt()
2555 isr_rxint(info->port_array[i]); in synclinkmp_interrupt()
2557 isr_txint(info->port_array[i]); in synclinkmp_interrupt()
2560 isr_rxdmaerror(info->port_array[i]); in synclinkmp_interrupt()
2562 isr_rxdmaok(info->port_array[i]); in synclinkmp_interrupt()
2564 isr_txdmaerror(info->port_array[i]); in synclinkmp_interrupt()
2566 isr_txdmaok(info->port_array[i]); in synclinkmp_interrupt()
2570 isr_timer(info->port_array[0]); in synclinkmp_interrupt()
2572 isr_timer(info->port_array[1]); in synclinkmp_interrupt()
2574 isr_timer(info->port_array[2]); in synclinkmp_interrupt()
2576 isr_timer(info->port_array[3]); in synclinkmp_interrupt()
2579 for(i=0; i < info->port_count ; i++) { in synclinkmp_interrupt()
2580 SLMP_INFO * port = info->port_array[i]; in synclinkmp_interrupt()
2601 spin_unlock(&info->lock); in synclinkmp_interrupt()
2610 static int startup(SLMP_INFO * info) in startup() argument
2613 printk("%s(%d):%s tx_releaseup()\n",__FILE__,__LINE__,info->device_name); in startup()
2615 if (info->flags & ASYNC_INITIALIZED) in startup()
2618 if (!info->tx_buf) { in startup()
2619 info->tx_buf = (unsigned char *)kmalloc(info->max_frame_size, GFP_KERNEL); in startup()
2620 if (!info->tx_buf) { in startup()
2622 __FILE__,__LINE__,info->device_name); in startup()
2627 info->pending_bh = 0; in startup()
2629 init_timer(&info->tx_timer); in startup()
2630 info->tx_timer.data = (unsigned long)info; in startup()
2631 info->tx_timer.function = tx_timeout; in startup()
2634 reset_port(info); in startup()
2636 change_params(info); in startup()
2638 init_timer(&info->status_timer); in startup()
2639 info->status_timer.data = (unsigned long)info; in startup()
2640 info->status_timer.function = status_timeout; in startup()
2641 info->status_timer.expires = jiffies + jiffies_from_ms(10); in startup()
2642 add_timer(&info->status_timer); in startup()
2644 if (info->tty) in startup()
2645 clear_bit(TTY_IO_ERROR, &info->tty->flags); in startup()
2647 info->flags |= ASYNC_INITIALIZED; in startup()
2654 static void shutdown(SLMP_INFO * info) in shutdown() argument
2658 if (!(info->flags & ASYNC_INITIALIZED)) in shutdown()
2663 __FILE__,__LINE__, info->device_name ); in shutdown()
2667 wake_up_interruptible(&info->status_event_wait_q); in shutdown()
2668 wake_up_interruptible(&info->event_wait_q); in shutdown()
2670 del_timer(&info->tx_timer); in shutdown()
2671 del_timer(&info->status_timer); in shutdown()
2673 if (info->tx_buf) { in shutdown()
2674 free_page((unsigned long) info->tx_buf); in shutdown()
2675 info->tx_buf = 0; in shutdown()
2678 spin_lock_irqsave(&info->lock,flags); in shutdown()
2680 reset_port(info); in shutdown()
2682 if (!info->tty || info->tty->termios->c_cflag & HUPCL) { in shutdown()
2683 info->serial_signals &= ~(SerialSignal_DTR + SerialSignal_RTS); in shutdown()
2684 set_signals(info); in shutdown()
2687 spin_unlock_irqrestore(&info->lock,flags); in shutdown()
2689 if (info->tty) in shutdown()
2690 set_bit(TTY_IO_ERROR, &info->tty->flags); in shutdown()
2692 info->flags &= ~ASYNC_INITIALIZED; in shutdown()
2695 static void program_hw(SLMP_INFO *info) in program_hw() argument
2699 spin_lock_irqsave(&info->lock,flags); in program_hw()
2701 rx_stop(info); in program_hw()
2702 tx_stop(info); in program_hw()
2704 info->tx_count = info->tx_put = info->tx_get = 0; in program_hw()
2706 if (info->params.mode == MGSL_MODE_HDLC || info->netcount) in program_hw()
2707 hdlc_mode(info); in program_hw()
2709 async_mode(info); in program_hw()
2711 set_signals(info); in program_hw()
2713 info->dcd_chkcount = 0; in program_hw()
2714 info->cts_chkcount = 0; in program_hw()
2715 info->ri_chkcount = 0; in program_hw()
2716 info->dsr_chkcount = 0; in program_hw()
2718 info->ie1_value |= (CDCD|CCTS); in program_hw()
2719 write_reg(info, IE1, info->ie1_value); in program_hw()
2721 get_signals(info); in program_hw()
2723 if (info->netcount || (info->tty && info->tty->termios->c_cflag & CREAD) ) in program_hw()
2724 rx_start(info); in program_hw()
2726 spin_unlock_irqrestore(&info->lock,flags); in program_hw()
2731 static void change_params(SLMP_INFO *info) in change_params() argument
2736 if (!info->tty || !info->tty->termios) in change_params()
2741 __FILE__,__LINE__, info->device_name ); in change_params()
2743 cflag = info->tty->termios->c_cflag; in change_params()
2748 info->serial_signals |= SerialSignal_RTS + SerialSignal_DTR; in change_params()
2750 info->serial_signals &= ~(SerialSignal_RTS + SerialSignal_DTR); in change_params()
2755 case CS5: info->params.data_bits = 5; break; in change_params()
2756 case CS6: info->params.data_bits = 6; break; in change_params()
2757 case CS7: info->params.data_bits = 7; break; in change_params()
2758 case CS8: info->params.data_bits = 8; break; in change_params()
2760 default: info->params.data_bits = 7; break; in change_params()
2764 info->params.stop_bits = 2; in change_params()
2766 info->params.stop_bits = 1; in change_params()
2768 info->params.parity = ASYNC_PARITY_NONE; in change_params()
2771 info->params.parity = ASYNC_PARITY_ODD; in change_params()
2773 info->params.parity = ASYNC_PARITY_EVEN; in change_params()
2776 info->params.parity = ASYNC_PARITY_SPACE; in change_params()
2783 bits_per_char = info->params.data_bits + in change_params()
2784 info->params.stop_bits + 1; in change_params()
2790 if (info->params.data_rate <= 460800) { in change_params()
2791 info->params.data_rate = tty_get_baud_rate(info->tty); in change_params()
2794 if ( info->params.data_rate ) { in change_params()
2795 info->timeout = (32*HZ*bits_per_char) / in change_params()
2796 info->params.data_rate; in change_params()
2798 info->timeout += HZ/50; /* Add .02 seconds of slop */ in change_params()
2801 info->flags |= ASYNC_CTS_FLOW; in change_params()
2803 info->flags &= ~ASYNC_CTS_FLOW; in change_params()
2806 info->flags &= ~ASYNC_CHECK_CD; in change_params()
2808 info->flags |= ASYNC_CHECK_CD; in change_params()
2812 info->read_status_mask2 = OVRN; in change_params()
2813 if (I_INPCK(info->tty)) in change_params()
2814 info->read_status_mask2 |= PE | FRME; in change_params()
2815 if (I_BRKINT(info->tty) || I_PARMRK(info->tty)) in change_params()
2816 info->read_status_mask1 |= BRKD; in change_params()
2817 if (I_IGNPAR(info->tty)) in change_params()
2818 info->ignore_status_mask2 |= PE | FRME; in change_params()
2819 if (I_IGNBRK(info->tty)) { in change_params()
2820 info->ignore_status_mask1 |= BRKD; in change_params()
2824 if (I_IGNPAR(info->tty)) in change_params()
2825 info->ignore_status_mask2 |= OVRN; in change_params()
2828 program_hw(info); in change_params()
2831 static int get_stats(SLMP_INFO * info, struct mgsl_icount *user_icount) in get_stats() argument
2837 __FILE__,__LINE__, info->device_name); in get_stats()
2839 COPY_TO_USER(err,user_icount, &info->icount, sizeof(struct mgsl_icount)); in get_stats()
2843 __FILE__,__LINE__,info->device_name); in get_stats()
2850 static int get_params(SLMP_INFO * info, MGSL_PARAMS *user_params) in get_params() argument
2855 __FILE__,__LINE__, info->device_name); in get_params()
2857 COPY_TO_USER(err,user_params, &info->params, sizeof(MGSL_PARAMS)); in get_params()
2861 __FILE__,__LINE__,info->device_name); in get_params()
2868 static int set_params(SLMP_INFO * info, MGSL_PARAMS *new_params) in set_params() argument
2876 __FILE__,__LINE__,info->device_name ); in set_params()
2881 __FILE__,__LINE__,info->device_name); in set_params()
2885 spin_lock_irqsave(&info->lock,flags); in set_params()
2886 memcpy(&info->params,&tmp_params,sizeof(MGSL_PARAMS)); in set_params()
2887 spin_unlock_irqrestore(&info->lock,flags); in set_params()
2889 change_params(info); in set_params()
2894 static int get_txidle(SLMP_INFO * info, int*idle_mode) in get_txidle() argument
2900 __FILE__,__LINE__, info->device_name, info->idle_mode); in get_txidle()
2902 COPY_TO_USER(err,idle_mode, &info->idle_mode, sizeof(int)); in get_txidle()
2906 __FILE__,__LINE__,info->device_name); in get_txidle()
2913 static int set_txidle(SLMP_INFO * info, int idle_mode) in set_txidle() argument
2919 __FILE__,__LINE__,info->device_name, idle_mode ); in set_txidle()
2921 spin_lock_irqsave(&info->lock,flags); in set_txidle()
2922 info->idle_mode = idle_mode; in set_txidle()
2923 tx_set_idle( info ); in set_txidle()
2924 spin_unlock_irqrestore(&info->lock,flags); in set_txidle()
2928 static int tx_enable(SLMP_INFO * info, int enable) in tx_enable() argument
2934 __FILE__,__LINE__,info->device_name, enable); in tx_enable()
2936 spin_lock_irqsave(&info->lock,flags); in tx_enable()
2938 if ( !info->tx_enabled ) { in tx_enable()
2939 tx_start(info); in tx_enable()
2942 if ( info->tx_enabled ) in tx_enable()
2943 tx_stop(info); in tx_enable()
2945 spin_unlock_irqrestore(&info->lock,flags); in tx_enable()
2951 static int tx_abort(SLMP_INFO * info) in tx_abort() argument
2957 __FILE__,__LINE__,info->device_name); in tx_abort()
2959 spin_lock_irqsave(&info->lock,flags); in tx_abort()
2960 if ( info->tx_active && info->params.mode == MGSL_MODE_HDLC ) { in tx_abort()
2961 info->ie1_value &= ~UDRN; in tx_abort()
2962 info->ie1_value |= IDLE; in tx_abort()
2963 write_reg(info, IE1, info->ie1_value); /* disable tx status interrupts */ in tx_abort()
2964 write_reg(info, SR1, (unsigned char)(IDLE + UDRN)); /* clear pending */ in tx_abort()
2966 write_reg(info, TXDMA + DSR, 0); /* disable DMA channel */ in tx_abort()
2967 write_reg(info, TXDMA + DCMD, SWABORT); /* reset/init DMA channel */ in tx_abort()
2969 write_reg(info, CMD, TXABORT); in tx_abort()
2971 spin_unlock_irqrestore(&info->lock,flags); in tx_abort()
2975 static int rx_enable(SLMP_INFO * info, int enable) in rx_enable() argument
2981 __FILE__,__LINE__,info->device_name,enable); in rx_enable()
2983 spin_lock_irqsave(&info->lock,flags); in rx_enable()
2985 if ( !info->rx_enabled ) in rx_enable()
2986 rx_start(info); in rx_enable()
2988 if ( info->rx_enabled ) in rx_enable()
2989 rx_stop(info); in rx_enable()
2991 spin_unlock_irqrestore(&info->lock,flags); in rx_enable()
3007 static int wait_mgsl_event(SLMP_INFO * info, int * mask_ptr) in wait_mgsl_event() argument
3025 __FILE__,__LINE__,info->device_name,mask); in wait_mgsl_event()
3027 spin_lock_irqsave(&info->lock,flags); in wait_mgsl_event()
3030 get_signals(info); in wait_mgsl_event()
3031 s = map_status(info->serial_signals); in wait_mgsl_event()
3039 spin_unlock_irqrestore(&info->lock,flags); in wait_mgsl_event()
3044 cprev = info->icount; in wait_mgsl_event()
3045 oldsigs = info->input_signal_events; in wait_mgsl_event()
3049 unsigned char oldval = info->ie1_value; in wait_mgsl_event()
3054 info->ie1_value = newval; in wait_mgsl_event()
3055 write_reg(info, IE1, info->ie1_value); in wait_mgsl_event()
3060 add_wait_queue(&info->event_wait_q, &wait); in wait_mgsl_event()
3062 spin_unlock_irqrestore(&info->lock,flags); in wait_mgsl_event()
3072 spin_lock_irqsave(&info->lock,flags); in wait_mgsl_event()
3073 cnow = info->icount; in wait_mgsl_event()
3074 newsigs = info->input_signal_events; in wait_mgsl_event()
3076 spin_unlock_irqrestore(&info->lock,flags); in wait_mgsl_event()
3111 remove_wait_queue(&info->event_wait_q, &wait); in wait_mgsl_event()
3116 spin_lock_irqsave(&info->lock,flags); in wait_mgsl_event()
3117 if (!waitqueue_active(&info->event_wait_q)) { in wait_mgsl_event()
3119 info->ie1_value &= ~(FLGD|IDLD); in wait_mgsl_event()
3120 write_reg(info, IE1, info->ie1_value); in wait_mgsl_event()
3122 spin_unlock_irqrestore(&info->lock,flags); in wait_mgsl_event()
3131 static int modem_input_wait(SLMP_INFO *info,int arg) in modem_input_wait() argument
3139 spin_lock_irqsave(&info->lock,flags); in modem_input_wait()
3140 cprev = info->icount; in modem_input_wait()
3141 add_wait_queue(&info->status_event_wait_q, &wait); in modem_input_wait()
3143 spin_unlock_irqrestore(&info->lock,flags); in modem_input_wait()
3153 spin_lock_irqsave(&info->lock,flags); in modem_input_wait()
3154 cnow = info->icount; in modem_input_wait()
3156 spin_unlock_irqrestore(&info->lock,flags); in modem_input_wait()
3176 remove_wait_queue(&info->status_event_wait_q, &wait); in modem_input_wait()
3183 static int get_modem_info(SLMP_INFO * info, unsigned int *value) in get_modem_info() argument
3189 spin_lock_irqsave(&info->lock,flags); in get_modem_info()
3190 get_signals(info); in get_modem_info()
3191 spin_unlock_irqrestore(&info->lock,flags); in get_modem_info()
3193 result = ((info->serial_signals & SerialSignal_RTS) ? TIOCM_RTS:0) + in get_modem_info()
3194 ((info->serial_signals & SerialSignal_DTR) ? TIOCM_DTR:0) + in get_modem_info()
3195 ((info->serial_signals & SerialSignal_DCD) ? TIOCM_CAR:0) + in get_modem_info()
3196 ((info->serial_signals & SerialSignal_RI) ? TIOCM_RNG:0) + in get_modem_info()
3197 ((info->serial_signals & SerialSignal_DSR) ? TIOCM_DSR:0) + in get_modem_info()
3198 ((info->serial_signals & SerialSignal_CTS) ? TIOCM_CTS:0); in get_modem_info()
3202 __FILE__,__LINE__, info->device_name, result ); in get_modem_info()
3214 static int set_modem_info(SLMP_INFO * info, unsigned int cmd, in set_modem_info() argument
3223 __FILE__,__LINE__,info->device_name ); in set_modem_info()
3232 info->serial_signals |= SerialSignal_RTS; in set_modem_info()
3234 info->serial_signals |= SerialSignal_DTR; in set_modem_info()
3238 info->serial_signals &= ~SerialSignal_RTS; in set_modem_info()
3240 info->serial_signals &= ~SerialSignal_DTR; in set_modem_info()
3244 info->serial_signals |= SerialSignal_RTS; in set_modem_info()
3246 info->serial_signals &= ~SerialSignal_RTS; in set_modem_info()
3249 info->serial_signals |= SerialSignal_DTR; in set_modem_info()
3251 info->serial_signals &= ~SerialSignal_DTR; in set_modem_info()
3257 spin_lock_irqsave(&info->lock,flags); in set_modem_info()
3258 set_signals(info); in set_modem_info()
3259 spin_unlock_irqrestore(&info->lock,flags); in set_modem_info()
3269 SLMP_INFO *info) in block_til_ready() argument
3283 if (info->flags & ASYNC_NORMAL_ACTIVE) in block_til_ready()
3285 if ((info->flags & ASYNC_CALLOUT_ACTIVE) && in block_til_ready()
3286 (info->flags & ASYNC_SESSION_LOCKOUT) && in block_til_ready()
3287 (info->session != current->session)) in block_til_ready()
3289 if ((info->flags & ASYNC_CALLOUT_ACTIVE) && in block_til_ready()
3290 (info->flags & ASYNC_PGRP_LOCKOUT) && in block_til_ready()
3291 (info->pgrp != current->pgrp)) in block_til_ready()
3293 info->flags |= ASYNC_CALLOUT_ACTIVE; in block_til_ready()
3300 if (info->flags & ASYNC_CALLOUT_ACTIVE) in block_til_ready()
3302 info->flags |= ASYNC_NORMAL_ACTIVE; in block_til_ready()
3306 if (info->flags & ASYNC_CALLOUT_ACTIVE) { in block_til_ready()
3307 if (info->normal_termios.c_cflag & CLOCAL) in block_til_ready()
3322 add_wait_queue(&info->open_wait, &wait); in block_til_ready()
3326 __FILE__,__LINE__, tty->driver.name, info->count ); in block_til_ready()
3331 info->count--; in block_til_ready()
3334 info->blocked_open++; in block_til_ready()
3337 if (!(info->flags & ASYNC_CALLOUT_ACTIVE) && in block_til_ready()
3339 spin_lock_irqsave(&info->lock,flags); in block_til_ready()
3340 info->serial_signals |= SerialSignal_RTS + SerialSignal_DTR; in block_til_ready()
3341 set_signals(info); in block_til_ready()
3342 spin_unlock_irqrestore(&info->lock,flags); in block_til_ready()
3347 if (tty_hung_up_p(filp) || !(info->flags & ASYNC_INITIALIZED)){ in block_til_ready()
3348 retval = (info->flags & ASYNC_HUP_NOTIFY) ? in block_til_ready()
3353 spin_lock_irqsave(&info->lock,flags); in block_til_ready()
3354 get_signals(info); in block_til_ready()
3355 spin_unlock_irqrestore(&info->lock,flags); in block_til_ready()
3357 if (!(info->flags & ASYNC_CALLOUT_ACTIVE) && in block_til_ready()
3358 !(info->flags & ASYNC_CLOSING) && in block_til_ready()
3359 (do_clocal || (info->serial_signals & SerialSignal_DCD)) ) { in block_til_ready()
3370 __FILE__,__LINE__, tty->driver.name, info->count ); in block_til_ready()
3376 remove_wait_queue(&info->open_wait, &wait); in block_til_ready()
3379 info->count++; in block_til_ready()
3380 info->blocked_open--; in block_til_ready()
3384 __FILE__,__LINE__, tty->driver.name, info->count ); in block_til_ready()
3387 info->flags |= ASYNC_NORMAL_ACTIVE; in block_til_ready()
3392 int alloc_dma_bufs(SLMP_INFO *info) in alloc_dma_bufs() argument
3402 info->port_array[0]->last_mem_alloc = (SCA_MEM_SIZE/4) * info->port_num; in alloc_dma_bufs()
3409 BuffersPerFrame = (unsigned short)(info->max_frame_size/SCABUFSIZE); in alloc_dma_bufs()
3410 if ( info->max_frame_size % SCABUFSIZE ) in alloc_dma_bufs()
3424 info->tx_buf_count = BuffersPerFrame + 1; in alloc_dma_bufs()
3427 if (info->tx_buf_count > (BufferCount/2)) in alloc_dma_bufs()
3428 info->tx_buf_count = BufferCount/2; in alloc_dma_bufs()
3430 if (info->tx_buf_count > SCAMAXDESC) in alloc_dma_bufs()
3431 info->tx_buf_count = SCAMAXDESC; in alloc_dma_bufs()
3434 info->rx_buf_count = BufferCount - info->tx_buf_count; in alloc_dma_bufs()
3436 if (info->rx_buf_count > SCAMAXDESC) in alloc_dma_bufs()
3437 info->rx_buf_count = SCAMAXDESC; in alloc_dma_bufs()
3441 __FILE__,__LINE__, info->device_name, in alloc_dma_bufs()
3442 info->tx_buf_count,info->rx_buf_count); in alloc_dma_bufs()
3444 if ( alloc_buf_list( info ) < 0 || in alloc_dma_bufs()
3445 alloc_frame_bufs(info, in alloc_dma_bufs()
3446 info->rx_buf_list, in alloc_dma_bufs()
3447 info->rx_buf_list_ex, in alloc_dma_bufs()
3448 info->rx_buf_count) < 0 || in alloc_dma_bufs()
3449 alloc_frame_bufs(info, in alloc_dma_bufs()
3450 info->tx_buf_list, in alloc_dma_bufs()
3451 info->tx_buf_list_ex, in alloc_dma_bufs()
3452 info->tx_buf_count) < 0 || in alloc_dma_bufs()
3453 alloc_tmp_rx_buf(info) < 0 ) { in alloc_dma_bufs()
3455 __FILE__,__LINE__, info->device_name); in alloc_dma_bufs()
3459 rx_reset_buffers( info ); in alloc_dma_bufs()
3466 int alloc_buf_list(SLMP_INFO *info) in alloc_buf_list() argument
3471 info->buffer_list = info->memory_base + info->port_array[0]->last_mem_alloc; in alloc_buf_list()
3472 info->buffer_list_phys = info->port_array[0]->last_mem_alloc; in alloc_buf_list()
3473 info->port_array[0]->last_mem_alloc += BUFFERLISTSIZE; in alloc_buf_list()
3475 memset(info->buffer_list, 0, BUFFERLISTSIZE); in alloc_buf_list()
3480 info->rx_buf_list = (SCADESC *)info->buffer_list; in alloc_buf_list()
3482 info->tx_buf_list = (SCADESC *)info->buffer_list; in alloc_buf_list()
3483 info->tx_buf_list += info->rx_buf_count; in alloc_buf_list()
3491 for ( i = 0; i < info->rx_buf_count; i++ ) { in alloc_buf_list()
3493 info->rx_buf_list_ex[i].phys_entry = in alloc_buf_list()
3494 info->buffer_list_phys + (i * sizeof(SCABUFSIZE)); in alloc_buf_list()
3498 info->rx_buf_list[i].next = info->buffer_list_phys; in alloc_buf_list()
3499 if ( i < info->rx_buf_count - 1 ) in alloc_buf_list()
3500 info->rx_buf_list[i].next += (i + 1) * sizeof(SCADESC); in alloc_buf_list()
3502 info->rx_buf_list[i].length = SCABUFSIZE; in alloc_buf_list()
3505 for ( i = 0; i < info->tx_buf_count; i++ ) { in alloc_buf_list()
3507 info->tx_buf_list_ex[i].phys_entry = info->buffer_list_phys + in alloc_buf_list()
3508 ((info->rx_buf_count + i) * sizeof(SCADESC)); in alloc_buf_list()
3513 info->tx_buf_list[i].next = info->buffer_list_phys + in alloc_buf_list()
3514 info->rx_buf_count * sizeof(SCADESC); in alloc_buf_list()
3516 if ( i < info->tx_buf_count - 1 ) in alloc_buf_list()
3517 info->tx_buf_list[i].next += (i + 1) * sizeof(SCADESC); in alloc_buf_list()
3525 int alloc_frame_bufs(SLMP_INFO *info, SCADESC *buf_list,SCADESC_EX *buf_list_ex,int count) in alloc_frame_bufs() argument
3531 buf_list_ex[i].virt_addr = info->memory_base + info->port_array[0]->last_mem_alloc; in alloc_frame_bufs()
3532 phys_addr = info->port_array[0]->last_mem_alloc; in alloc_frame_bufs()
3533 info->port_array[0]->last_mem_alloc += SCABUFSIZE; in alloc_frame_bufs()
3542 void free_dma_bufs(SLMP_INFO *info) in free_dma_bufs() argument
3544 info->buffer_list = NULL; in free_dma_bufs()
3545 info->rx_buf_list = NULL; in free_dma_bufs()
3546 info->tx_buf_list = NULL; in free_dma_bufs()
3552 int alloc_tmp_rx_buf(SLMP_INFO *info) in alloc_tmp_rx_buf() argument
3554 info->tmp_rx_buf = kmalloc(info->max_frame_size, GFP_KERNEL); in alloc_tmp_rx_buf()
3555 if (info->tmp_rx_buf == NULL) in alloc_tmp_rx_buf()
3560 void free_tmp_rx_buf(SLMP_INFO *info) in free_tmp_rx_buf() argument
3562 if (info->tmp_rx_buf) in free_tmp_rx_buf()
3563 kfree(info->tmp_rx_buf); in free_tmp_rx_buf()
3564 info->tmp_rx_buf = NULL; in free_tmp_rx_buf()
3567 int claim_resources(SLMP_INFO *info) in claim_resources() argument
3569 if (request_mem_region(info->phys_memory_base,SCA_MEM_SIZE,"synclinkmp") == NULL) { in claim_resources()
3571 __FILE__,__LINE__,info->device_name, info->phys_memory_base); in claim_resources()
3572 info->init_error = DiagStatus_AddressConflict; in claim_resources()
3576 info->shared_mem_requested = 1; in claim_resources()
3578 if (request_mem_region(info->phys_lcr_base + info->lcr_offset,128,"synclinkmp") == NULL) { in claim_resources()
3580 __FILE__,__LINE__,info->device_name, info->phys_lcr_base); in claim_resources()
3581 info->init_error = DiagStatus_AddressConflict; in claim_resources()
3585 info->lcr_mem_requested = 1; in claim_resources()
3587 …if (request_mem_region(info->phys_sca_base + info->sca_offset,SCA_BASE_SIZE,"synclinkmp") == NULL)… in claim_resources()
3589 __FILE__,__LINE__,info->device_name, info->phys_sca_base); in claim_resources()
3590 info->init_error = DiagStatus_AddressConflict; in claim_resources()
3594 info->sca_base_requested = 1; in claim_resources()
3596 …if (request_mem_region(info->phys_statctrl_base + info->statctrl_offset,SCA_REG_SIZE,"synclinkmp")… in claim_resources()
3598 __FILE__,__LINE__,info->device_name, info->phys_statctrl_base); in claim_resources()
3599 info->init_error = DiagStatus_AddressConflict; in claim_resources()
3603 info->sca_statctrl_requested = 1; in claim_resources()
3605 info->memory_base = ioremap(info->phys_memory_base,SCA_MEM_SIZE); in claim_resources()
3606 if (!info->memory_base) { in claim_resources()
3608 __FILE__,__LINE__,info->device_name, info->phys_memory_base ); in claim_resources()
3609 info->init_error = DiagStatus_CantAssignPciResources; in claim_resources()
3613 info->lcr_base = ioremap(info->phys_lcr_base,PAGE_SIZE); in claim_resources()
3614 if (!info->lcr_base) { in claim_resources()
3616 __FILE__,__LINE__,info->device_name, info->phys_lcr_base ); in claim_resources()
3617 info->init_error = DiagStatus_CantAssignPciResources; in claim_resources()
3620 info->lcr_base += info->lcr_offset; in claim_resources()
3622 info->sca_base = ioremap(info->phys_sca_base,PAGE_SIZE); in claim_resources()
3623 if (!info->sca_base) { in claim_resources()
3625 __FILE__,__LINE__,info->device_name, info->phys_sca_base ); in claim_resources()
3626 info->init_error = DiagStatus_CantAssignPciResources; in claim_resources()
3629 info->sca_base += info->sca_offset; in claim_resources()
3631 info->statctrl_base = ioremap(info->phys_statctrl_base,PAGE_SIZE); in claim_resources()
3632 if (!info->statctrl_base) { in claim_resources()
3634 __FILE__,__LINE__,info->device_name, info->phys_statctrl_base ); in claim_resources()
3635 info->init_error = DiagStatus_CantAssignPciResources; in claim_resources()
3638 info->statctrl_base += info->statctrl_offset; in claim_resources()
3640 if ( !memory_test(info) ) { in claim_resources()
3642 __FILE__,__LINE__,info->device_name, info->phys_memory_base ); in claim_resources()
3643 info->init_error = DiagStatus_MemoryError; in claim_resources()
3650 release_resources( info ); in claim_resources()
3654 void release_resources(SLMP_INFO *info) in release_resources() argument
3658 __FILE__,__LINE__,info->device_name ); in release_resources()
3660 if ( info->irq_requested ) { in release_resources()
3661 free_irq(info->irq_level, info); in release_resources()
3662 info->irq_requested = 0; in release_resources()
3665 if ( info->shared_mem_requested ) { in release_resources()
3666 release_mem_region(info->phys_memory_base,SCA_MEM_SIZE); in release_resources()
3667 info->shared_mem_requested = 0; in release_resources()
3669 if ( info->lcr_mem_requested ) { in release_resources()
3670 release_mem_region(info->phys_lcr_base + info->lcr_offset,128); in release_resources()
3671 info->lcr_mem_requested = 0; in release_resources()
3673 if ( info->sca_base_requested ) { in release_resources()
3674 release_mem_region(info->phys_sca_base + info->sca_offset,SCA_BASE_SIZE); in release_resources()
3675 info->sca_base_requested = 0; in release_resources()
3677 if ( info->sca_statctrl_requested ) { in release_resources()
3678 release_mem_region(info->phys_statctrl_base + info->statctrl_offset,SCA_REG_SIZE); in release_resources()
3679 info->sca_statctrl_requested = 0; in release_resources()
3682 if (info->memory_base){ in release_resources()
3683 iounmap(info->memory_base); in release_resources()
3684 info->memory_base = 0; in release_resources()
3687 if (info->sca_base) { in release_resources()
3688 iounmap(info->sca_base - info->sca_offset); in release_resources()
3689 info->sca_base=0; in release_resources()
3692 if (info->statctrl_base) { in release_resources()
3693 iounmap(info->statctrl_base - info->statctrl_offset); in release_resources()
3694 info->statctrl_base=0; in release_resources()
3697 if (info->lcr_base){ in release_resources()
3698 iounmap(info->lcr_base - info->lcr_offset); in release_resources()
3699 info->lcr_base = 0; in release_resources()
3704 __FILE__,__LINE__,info->device_name ); in release_resources()
3710 void add_device(SLMP_INFO *info) in add_device() argument
3712 info->next_device = NULL; in add_device()
3713 info->line = synclinkmp_device_count; in add_device()
3714 sprintf(info->device_name,"ttySLM%dp%d",info->adapter_num,info->port_num); in add_device()
3716 if (info->line < MAX_DEVICES) { in add_device()
3717 if (maxframe[info->line]) in add_device()
3718 info->max_frame_size = maxframe[info->line]; in add_device()
3719 info->dosyncppp = dosyncppp[info->line]; in add_device()
3725 synclinkmp_device_list = info; in add_device()
3730 current_dev->next_device = info; in add_device()
3733 if ( info->max_frame_size < 4096 ) in add_device()
3734 info->max_frame_size = 4096; in add_device()
3735 else if ( info->max_frame_size > 65535 ) in add_device()
3736 info->max_frame_size = 65535; in add_device()
3740 info->device_name, in add_device()
3741 info->phys_sca_base, in add_device()
3742 info->phys_memory_base, in add_device()
3743 info->phys_statctrl_base, in add_device()
3744 info->phys_lcr_base, in add_device()
3745 info->irq_level, in add_device()
3746 info->max_frame_size ); in add_device()
3749 if (info->dosyncppp) in add_device()
3750 sppp_init(info); in add_device()
3760 SLMP_INFO *info; in alloc_dev() local
3762 info = (SLMP_INFO *)kmalloc(sizeof(SLMP_INFO), in alloc_dev()
3765 if (!info) { in alloc_dev()
3769 memset(info, 0, sizeof(SLMP_INFO)); in alloc_dev()
3770 info->magic = MGSL_MAGIC; in alloc_dev()
3771 info->task.sync = 0; in alloc_dev()
3772 info->task.routine = bh_handler; in alloc_dev()
3773 info->task.data = info; in alloc_dev()
3774 info->max_frame_size = 4096; in alloc_dev()
3775 info->close_delay = 5*HZ/10; in alloc_dev()
3776 info->closing_wait = 30*HZ; in alloc_dev()
3777 init_waitqueue_head(&info->open_wait); in alloc_dev()
3778 init_waitqueue_head(&info->close_wait); in alloc_dev()
3779 init_waitqueue_head(&info->status_event_wait_q); in alloc_dev()
3780 init_waitqueue_head(&info->event_wait_q); in alloc_dev()
3781 spin_lock_init(&info->netlock); in alloc_dev()
3782 memcpy(&info->params,&default_params,sizeof(MGSL_PARAMS)); in alloc_dev()
3783 info->idle_mode = HDLC_TXIDLE_FLAGS; in alloc_dev()
3784 info->adapter_num = adapter_num; in alloc_dev()
3785 info->port_num = port_num; in alloc_dev()
3788 info->irq_level = pdev->irq; in alloc_dev()
3789 info->phys_lcr_base = pci_resource_start(pdev,0); in alloc_dev()
3790 info->phys_sca_base = pci_resource_start(pdev,2); in alloc_dev()
3791 info->phys_memory_base = pci_resource_start(pdev,3); in alloc_dev()
3792 info->phys_statctrl_base = pci_resource_start(pdev,4); in alloc_dev()
3798 info->lcr_offset = info->phys_lcr_base & (PAGE_SIZE-1); in alloc_dev()
3799 info->phys_lcr_base &= ~(PAGE_SIZE-1); in alloc_dev()
3801 info->sca_offset = info->phys_sca_base & (PAGE_SIZE-1); in alloc_dev()
3802 info->phys_sca_base &= ~(PAGE_SIZE-1); in alloc_dev()
3804 info->statctrl_offset = info->phys_statctrl_base & (PAGE_SIZE-1); in alloc_dev()
3805 info->phys_statctrl_base &= ~(PAGE_SIZE-1); in alloc_dev()
3807 info->bus_type = MGSL_BUS_TYPE_PCI; in alloc_dev()
3808 info->irq_flags = SA_SHIRQ; in alloc_dev()
3819 info->misc_ctrl_value = 0x087e4546; in alloc_dev()
3827 info->init_error = -1; in alloc_dev()
3830 return info; in alloc_dev()
3893 SLMP_INFO *info; in synclinkmp_init() local
3981 info = synclinkmp_device_list; in synclinkmp_init()
3982 while(info){ in synclinkmp_init()
3983 info->callout_termios = callout_driver.init_termios; in synclinkmp_init()
3984 info->normal_termios = serial_driver.init_termios; in synclinkmp_init()
3985 info = info->next_device; in synclinkmp_init()
3995 SLMP_INFO *info; in synclinkmp_exit() local
4010 info = synclinkmp_device_list; in synclinkmp_exit()
4011 while(info) { in synclinkmp_exit()
4012 reset_port(info); in synclinkmp_exit()
4013 info = info->next_device; in synclinkmp_exit()
4017 info = synclinkmp_device_list; in synclinkmp_exit()
4018 while(info) { in synclinkmp_exit()
4020 if (info->dosyncppp) in synclinkmp_exit()
4021 sppp_delete(info); in synclinkmp_exit()
4023 free_dma_bufs(info); in synclinkmp_exit()
4024 free_tmp_rx_buf(info); in synclinkmp_exit()
4025 if ( info->port_num == 0 ) { in synclinkmp_exit()
4026 if (info->sca_base) in synclinkmp_exit()
4027 write_reg(info, LPR, 1); /* set low power mode */ in synclinkmp_exit()
4028 release_resources(info); in synclinkmp_exit()
4030 tmp = info; in synclinkmp_exit()
4031 info = info->next_device; in synclinkmp_exit()
4045 void enable_loopback(SLMP_INFO *info, int enable) in enable_loopback() argument
4051 write_reg(info, MD2, (unsigned char)(read_reg(info, MD2) | (BIT1 + BIT0))); in enable_loopback()
4054 info->port_array[0]->ctrlreg_value |= (BIT0 << (info->port_num * 2)); in enable_loopback()
4055 write_control_reg(info); in enable_loopback()
4062 write_reg(info, RXS, 0x40); in enable_loopback()
4063 write_reg(info, TXS, 0x40); in enable_loopback()
4069 write_reg(info, MD2, (unsigned char)(read_reg(info, MD2) & ~(BIT1 + BIT0))); in enable_loopback()
4076 write_reg(info, RXS, 0x00); in enable_loopback()
4077 write_reg(info, TXS, 0x00); in enable_loopback()
4081 if (info->params.clock_speed) in enable_loopback()
4082 set_rate(info, info->params.clock_speed); in enable_loopback()
4084 set_rate(info, 3686400); in enable_loopback()
4092 void set_rate( SLMP_INFO *info, u32 data_rate ) in set_rate() argument
4123 write_reg(info, TXS, in set_rate()
4124 (unsigned char)((read_reg(info, TXS) & 0xf0) | BRValue)); in set_rate()
4125 write_reg(info, RXS, in set_rate()
4126 (unsigned char)((read_reg(info, RXS) & 0xf0) | BRValue)); in set_rate()
4127 write_reg(info, TMC, (unsigned char)TMCValue); in set_rate()
4130 write_reg(info, TXS,0); in set_rate()
4131 write_reg(info, RXS,0); in set_rate()
4132 write_reg(info, TMC, 0); in set_rate()
4138 void rx_stop(SLMP_INFO *info) in rx_stop() argument
4142 __FILE__,__LINE__, info->device_name ); in rx_stop()
4144 write_reg(info, CMD, RXRESET); in rx_stop()
4146 info->ie0_value &= ~RXRDYE; in rx_stop()
4147 write_reg(info, IE0, info->ie0_value); /* disable Rx data interrupts */ in rx_stop()
4149 write_reg(info, RXDMA + DSR, 0); /* disable Rx DMA */ in rx_stop()
4150 write_reg(info, RXDMA + DCMD, SWABORT); /* reset/init Rx DMA */ in rx_stop()
4151 write_reg(info, RXDMA + DIR, 0); /* disable Rx DMA interrupts */ in rx_stop()
4153 info->rx_enabled = 0; in rx_stop()
4154 info->rx_overflow = 0; in rx_stop()
4159 void rx_start(SLMP_INFO *info) in rx_start() argument
4165 __FILE__,__LINE__, info->device_name ); in rx_start()
4167 write_reg(info, CMD, RXRESET); in rx_start()
4169 if ( info->params.mode == MGSL_MODE_HDLC ) { in rx_start()
4171 info->ie0_value &= ~RXRDYE; in rx_start()
4172 write_reg(info, IE0, info->ie0_value); in rx_start()
4175 write_reg(info, RXDMA + DSR, 0); /* disable Rx DMA */ in rx_start()
4176 write_reg(info, RXDMA + DCMD, SWABORT); /* reset/init Rx DMA */ in rx_start()
4178 for (i = 0; i < info->rx_buf_count; i++) { in rx_start()
4179 info->rx_buf_list[i].status = 0xff; in rx_start()
4184 read_status_reg(info); in rx_start()
4186 info->current_rx_buf = 0; in rx_start()
4189 write_reg16(info, RXDMA + CDA, in rx_start()
4190 info->rx_buf_list_ex[0].phys_entry); in rx_start()
4193 write_reg16(info, RXDMA + EDA, in rx_start()
4194 info->rx_buf_list_ex[info->rx_buf_count - 1].phys_entry); in rx_start()
4197 write_reg16(info, RXDMA + BFL, SCABUFSIZE); in rx_start()
4199 write_reg(info, RXDMA + DIR, 0x60); /* enable Rx DMA interrupts (EOM/BOF) */ in rx_start()
4200 write_reg(info, RXDMA + DSR, 0xf2); /* clear Rx DMA IRQs, enable Rx DMA */ in rx_start()
4203 info->ie0_value |= RXRDYE; in rx_start()
4204 write_reg(info, IE0, info->ie0_value); in rx_start()
4207 write_reg(info, CMD, RXENABLE); in rx_start()
4209 info->rx_overflow = FALSE; in rx_start()
4210 info->rx_enabled = 1; in rx_start()
4216 void tx_start(SLMP_INFO *info) in tx_start() argument
4220 __FILE__,__LINE__, info->device_name,info->tx_count ); in tx_start()
4222 if (!info->tx_enabled ) { in tx_start()
4223 write_reg(info, CMD, TXRESET); in tx_start()
4224 write_reg(info, CMD, TXENABLE); in tx_start()
4225 info->tx_enabled = TRUE; in tx_start()
4228 if ( info->tx_count ) { in tx_start()
4234 info->drop_rts_on_tx_done = 0; in tx_start()
4236 if (info->params.mode != MGSL_MODE_ASYNC) { in tx_start()
4238 if ( info->params.flags & HDLC_FLAG_AUTO_RTS ) { in tx_start()
4239 get_signals( info ); in tx_start()
4240 if ( !(info->serial_signals & SerialSignal_RTS) ) { in tx_start()
4241 info->serial_signals |= SerialSignal_RTS; in tx_start()
4242 set_signals( info ); in tx_start()
4243 info->drop_rts_on_tx_done = 1; in tx_start()
4247 write_reg16(info, TRC0, in tx_start()
4250 write_reg(info, TXDMA + DSR, 0); /* disable DMA channel */ in tx_start()
4251 write_reg(info, TXDMA + DCMD, SWABORT); /* reset/init DMA channel */ in tx_start()
4254 write_reg16(info, TXDMA + CDA, in tx_start()
4255 info->tx_buf_list_ex[0].phys_entry); in tx_start()
4258 write_reg16(info, TXDMA + EDA, in tx_start()
4259 info->tx_buf_list_ex[info->last_tx_buf].phys_entry); in tx_start()
4262 info->ie1_value &= ~IDLE; in tx_start()
4263 info->ie1_value |= UDRN; in tx_start()
4264 write_reg(info, IE1, info->ie1_value); in tx_start()
4265 write_reg(info, SR1, (unsigned char)(IDLE + UDRN)); in tx_start()
4267 write_reg(info, TXDMA + DIR, 0x40); /* enable Tx DMA interrupts (EOM) */ in tx_start()
4268 write_reg(info, TXDMA + DSR, 0xf2); /* clear Tx DMA IRQs, enable Tx DMA */ in tx_start()
4270 info->tx_timer.expires = jiffies + jiffies_from_ms(5000); in tx_start()
4271 add_timer(&info->tx_timer); in tx_start()
4274 tx_load_fifo(info); in tx_start()
4276 info->ie0_value |= TXRDYE; in tx_start()
4277 write_reg(info, IE0, info->ie0_value); in tx_start()
4280 info->tx_active = 1; in tx_start()
4286 void tx_stop( SLMP_INFO *info ) in tx_stop() argument
4290 __FILE__,__LINE__, info->device_name ); in tx_stop()
4292 del_timer(&info->tx_timer); in tx_stop()
4294 write_reg(info, TXDMA + DSR, 0); /* disable DMA channel */ in tx_stop()
4295 write_reg(info, TXDMA + DCMD, SWABORT); /* reset/init DMA channel */ in tx_stop()
4297 write_reg(info, CMD, TXRESET); in tx_stop()
4299 info->ie1_value &= ~(UDRN + IDLE); in tx_stop()
4300 write_reg(info, IE1, info->ie1_value); /* disable tx status interrupts */ in tx_stop()
4301 write_reg(info, SR1, (unsigned char)(IDLE + UDRN)); /* clear pending */ in tx_stop()
4303 info->ie0_value &= ~TXRDYE; in tx_stop()
4304 write_reg(info, IE0, info->ie0_value); /* disable tx data interrupts */ in tx_stop()
4306 info->tx_enabled = 0; in tx_stop()
4307 info->tx_active = 0; in tx_stop()
4313 void tx_load_fifo(SLMP_INFO *info) in tx_load_fifo() argument
4319 if ( !info->tx_count && !info->x_char ) in tx_load_fifo()
4324 while( info->tx_count && (read_reg(info,SR0) & BIT1) ) { in tx_load_fifo()
4329 if ( (info->tx_count > 1) && !info->x_char ) { in tx_load_fifo()
4331 TwoBytes[0] = info->tx_buf[info->tx_get++]; in tx_load_fifo()
4332 if (info->tx_get >= info->max_frame_size) in tx_load_fifo()
4333 info->tx_get -= info->max_frame_size; in tx_load_fifo()
4334 TwoBytes[1] = info->tx_buf[info->tx_get++]; in tx_load_fifo()
4335 if (info->tx_get >= info->max_frame_size) in tx_load_fifo()
4336 info->tx_get -= info->max_frame_size; in tx_load_fifo()
4338 write_reg16(info, TRB, *((u16 *)TwoBytes)); in tx_load_fifo()
4340 info->tx_count -= 2; in tx_load_fifo()
4341 info->icount.tx += 2; in tx_load_fifo()
4345 if (info->x_char) { in tx_load_fifo()
4347 write_reg(info, TRB, info->x_char); in tx_load_fifo()
4348 info->x_char = 0; in tx_load_fifo()
4350 write_reg(info, TRB, info->tx_buf[info->tx_get++]); in tx_load_fifo()
4351 if (info->tx_get >= info->max_frame_size) in tx_load_fifo()
4352 info->tx_get -= info->max_frame_size; in tx_load_fifo()
4353 info->tx_count--; in tx_load_fifo()
4355 info->icount.tx++; in tx_load_fifo()
4362 void reset_port(SLMP_INFO *info) in reset_port() argument
4364 if (info->sca_base) { in reset_port()
4366 tx_stop(info); in reset_port()
4367 rx_stop(info); in reset_port()
4369 info->serial_signals &= ~(SerialSignal_DTR + SerialSignal_RTS); in reset_port()
4370 set_signals(info); in reset_port()
4373 info->ie0_value = 0; in reset_port()
4374 info->ie1_value = 0; in reset_port()
4375 info->ie2_value = 0; in reset_port()
4376 write_reg(info, IE0, info->ie0_value); in reset_port()
4377 write_reg(info, IE1, info->ie1_value); in reset_port()
4378 write_reg(info, IE2, info->ie2_value); in reset_port()
4380 write_reg(info, CMD, CHRESET); in reset_port()
4386 void reset_adapter(SLMP_INFO *info) in reset_adapter() argument
4391 if (info->port_array[i]) in reset_adapter()
4392 reset_port(info->port_array[i]); in reset_adapter()
4398 void async_mode(SLMP_INFO *info) in async_mode() argument
4403 tx_stop(info); in async_mode()
4404 rx_stop(info); in async_mode()
4417 if (info->params.stop_bits != 1) in async_mode()
4419 write_reg(info, MD0, RegValue); in async_mode()
4431 switch (info->params.data_bits) { in async_mode()
4436 if (info->params.parity != ASYNC_PARITY_NONE) { in async_mode()
4438 if (info->params.parity == ASYNC_PARITY_ODD) in async_mode()
4441 write_reg(info, MD1, RegValue); in async_mode()
4451 write_reg(info, MD2, RegValue); in async_mode()
4460 write_reg(info, RXS, RegValue); in async_mode()
4469 write_reg(info, TXS, RegValue); in async_mode()
4475 info->port_array[0]->ctrlreg_value |= (BIT0 << (info->port_num * 2)); in async_mode()
4476 write_control_reg(info); in async_mode()
4478 tx_set_idle(info); in async_mode()
4485 write_reg(info, RRC, 0x00); in async_mode()
4492 write_reg(info, TRC0, 0x10); in async_mode()
4499 write_reg(info, TRC1, 0x1e); in async_mode()
4514 if (!(info->serial_signals & SerialSignal_RTS)) in async_mode()
4516 write_reg(info, CTL, RegValue); in async_mode()
4519 info->ie0_value |= TXINTE + RXINTE; in async_mode()
4520 write_reg(info, IE0, info->ie0_value); in async_mode()
4523 info->ie1_value = BRKD; in async_mode()
4524 write_reg(info, IE1, info->ie1_value); in async_mode()
4527 info->ie2_value = OVRN; in async_mode()
4528 write_reg(info, IE2, info->ie2_value); in async_mode()
4530 set_rate( info, info->params.data_rate * 16 ); in async_mode()
4532 if (info->params.loopback) in async_mode()
4533 enable_loopback(info,1); in async_mode()
4538 void hdlc_mode(SLMP_INFO *info) in hdlc_mode() argument
4547 info->params.flags &= ~(HDLC_FLAG_TXC_DPLL + HDLC_FLAG_RXC_DPLL); in hdlc_mode()
4550 write_reg(info, TXDMA + DIR, 0); in hdlc_mode()
4551 write_reg(info, RXDMA + DIR, 0); in hdlc_mode()
4565 if (info->params.flags & HDLC_FLAG_AUTO_CTS) in hdlc_mode()
4567 if (info->params.flags & HDLC_FLAG_AUTO_DCD) in hdlc_mode()
4569 if (info->params.crc_type == HDLC_CRC_16_CCITT) in hdlc_mode()
4571 write_reg(info, MD0, RegValue); in hdlc_mode()
4583 write_reg(info, MD1, RegValue); in hdlc_mode()
4596 switch(info->params.encoding) { in hdlc_mode()
4607 if ( info->params.flags & HDLC_FLAG_DPLL_DIV16 ) { in hdlc_mode()
4610 } else if ( info->params.flags & HDLC_FLAG_DPLL_DIV8 ) { in hdlc_mode()
4616 write_reg(info, MD2, RegValue); in hdlc_mode()
4626 if (info->params.flags & HDLC_FLAG_RXC_BRG) in hdlc_mode()
4628 if (info->params.flags & HDLC_FLAG_RXC_DPLL) in hdlc_mode()
4630 write_reg(info, RXS, RegValue); in hdlc_mode()
4639 if (info->params.flags & HDLC_FLAG_TXC_BRG) in hdlc_mode()
4641 if (info->params.flags & HDLC_FLAG_TXC_DPLL) in hdlc_mode()
4643 write_reg(info, TXS, RegValue); in hdlc_mode()
4645 if (info->params.flags & HDLC_FLAG_RXC_DPLL) in hdlc_mode()
4646 set_rate(info, info->params.clock_speed * DpllDivisor); in hdlc_mode()
4648 set_rate(info, info->params.clock_speed); in hdlc_mode()
4654 if (info->params.flags & HDLC_FLAG_TXC_BRG) in hdlc_mode()
4655 info->port_array[0]->ctrlreg_value |= (BIT0 << (info->port_num * 2)); in hdlc_mode()
4657 info->port_array[0]->ctrlreg_value &= ~(BIT0 << (info->port_num * 2)); in hdlc_mode()
4658 write_control_reg(info); in hdlc_mode()
4665 write_reg(info, RRC, rx_active_fifo_level); in hdlc_mode()
4672 write_reg(info, TRC0, tx_active_fifo_level); in hdlc_mode()
4679 write_reg(info, TRC1, (unsigned char)(tx_negate_fifo_level - 1)); in hdlc_mode()
4692 write_reg(info, TXDMA + DMR, 0x14); in hdlc_mode()
4693 write_reg(info, RXDMA + DMR, 0x14); in hdlc_mode()
4696 write_reg(info, RXDMA + CPB, in hdlc_mode()
4697 (unsigned char)(info->buffer_list_phys >> 16)); in hdlc_mode()
4700 write_reg(info, TXDMA + CPB, in hdlc_mode()
4701 (unsigned char)(info->buffer_list_phys >> 16)); in hdlc_mode()
4706 info->ie0_value |= TXINTE + RXINTE; in hdlc_mode()
4707 write_reg(info, IE0, info->ie0_value); in hdlc_mode()
4722 if (!(info->serial_signals & SerialSignal_RTS)) in hdlc_mode()
4724 write_reg(info, CTL, RegValue); in hdlc_mode()
4728 tx_set_idle(info); in hdlc_mode()
4729 tx_stop(info); in hdlc_mode()
4730 rx_stop(info); in hdlc_mode()
4732 set_rate(info, info->params.clock_speed); in hdlc_mode()
4734 if (info->params.loopback) in hdlc_mode()
4735 enable_loopback(info,1); in hdlc_mode()
4740 void tx_set_idle(SLMP_INFO *info) in tx_set_idle() argument
4745 switch(info->idle_mode) { in tx_set_idle()
4755 write_reg(info, IDL, RegValue); in tx_set_idle()
4760 void get_signals(SLMP_INFO *info) in get_signals() argument
4762 u16 status = read_reg(info, SR3); in get_signals()
4763 u16 gpstatus = read_status_reg(info); in get_signals()
4767 info->serial_signals &= SerialSignal_DTR + SerialSignal_RTS; in get_signals()
4772 info->serial_signals |= SerialSignal_CTS; in get_signals()
4775 info->serial_signals |= SerialSignal_DCD; in get_signals()
4777 testbit = BIT1 << (info->port_num * 2); // Port 0..3 RI is GPDATA<1,3,5,7> in get_signals()
4779 info->serial_signals |= SerialSignal_RI; in get_signals()
4781 testbit = BIT0 << (info->port_num * 2); // Port 0..3 DSR is GPDATA<0,2,4,6> in get_signals()
4783 info->serial_signals |= SerialSignal_DSR; in get_signals()
4789 void set_signals(SLMP_INFO *info) in set_signals() argument
4794 RegValue = read_reg(info, CTL); in set_signals()
4795 if (info->serial_signals & SerialSignal_RTS) in set_signals()
4799 write_reg(info, CTL, RegValue); in set_signals()
4802 EnableBit = BIT1 << (info->port_num*2); in set_signals()
4803 if (info->serial_signals & SerialSignal_DTR) in set_signals()
4804 info->port_array[0]->ctrlreg_value &= ~EnableBit; in set_signals()
4806 info->port_array[0]->ctrlreg_value |= EnableBit; in set_signals()
4807 write_control_reg(info); in set_signals()
4818 void rx_reset_buffers(SLMP_INFO *info) in rx_reset_buffers() argument
4820 rx_free_frame_buffers(info, 0, info->rx_buf_count - 1); in rx_reset_buffers()
4829 void rx_free_frame_buffers(SLMP_INFO *info, unsigned int first, unsigned int last) in rx_free_frame_buffers() argument
4835 info->rx_buf_list[first].status = 0xff; in rx_free_frame_buffers()
4840 write_reg16(info, RXDMA + EDA, info->rx_buf_list_ex[first].phys_entry); in rx_free_frame_buffers()
4844 if (first == info->rx_buf_count) in rx_free_frame_buffers()
4849 info->current_rx_buf = first; in rx_free_frame_buffers()
4857 int rx_get_frame(SLMP_INFO *info) in rx_get_frame() argument
4864 struct tty_struct *tty = info->tty; in rx_get_frame()
4880 StartIndex = EndIndex = info->current_rx_buf; in rx_get_frame()
4883 desc = &info->rx_buf_list[EndIndex]; in rx_get_frame()
4884 desc_ex = &info->rx_buf_list_ex[EndIndex]; in rx_get_frame()
4889 if (framesize == 0 && info->params.addr_filter != 0xff) in rx_get_frame()
4899 if (EndIndex == info->rx_buf_count) in rx_get_frame()
4902 if (EndIndex == info->current_rx_buf) { in rx_get_frame()
4905 if ( info->rx_enabled ){ in rx_get_frame()
4906 spin_lock_irqsave(&info->lock,flags); in rx_get_frame()
4907 rx_start(info); in rx_get_frame()
4908 spin_unlock_irqrestore(&info->lock,flags); in rx_get_frame()
4931 if (info->params.crc_type == HDLC_CRC_NONE) in rx_get_frame()
4935 (addr_field != 0xff && addr_field != info->params.addr_filter)) { in rx_get_frame()
4939 rx_free_frame_buffers(info, StartIndex, EndIndex); in rx_get_frame()
4951 info->icount.rxshort++; in rx_get_frame()
4953 info->icount.rxabort++; in rx_get_frame()
4955 info->icount.rxover++; in rx_get_frame()
4957 info->icount.rxcrc++; in rx_get_frame()
4962 info->netstats.rx_errors++; in rx_get_frame()
4963 info->netstats.rx_frame_errors++; in rx_get_frame()
4969 __FILE__,__LINE__,info->device_name,status,framesize); in rx_get_frame()
4972 trace_block(info,info->rx_buf_list_ex[StartIndex].virt_addr, in rx_get_frame()
4976 if (framesize > info->max_frame_size) in rx_get_frame()
4977 info->icount.rxlong++; in rx_get_frame()
4982 unsigned char *ptmp = info->tmp_rx_buf; in rx_get_frame()
4983 info->tmp_rx_buf_count = framesize; in rx_get_frame()
4985 info->icount.rxok++; in rx_get_frame()
4990 info->rx_buf_list_ex[index].virt_addr, in rx_get_frame()
4995 if ( ++index == info->rx_buf_count ) in rx_get_frame()
5000 if (info->netcount) { in rx_get_frame()
5002 sppp_rx_done(info,info->tmp_rx_buf,framesize); in rx_get_frame()
5006 ldisc_receive_buf(tty,info->tmp_rx_buf, in rx_get_frame()
5007 info->flag_buf, framesize); in rx_get_frame()
5011 rx_free_frame_buffers( info, StartIndex, EndIndex ); in rx_get_frame()
5016 if ( info->rx_enabled && info->rx_overflow ) { in rx_get_frame()
5020 if (info->rx_buf_list[EndIndex].status == 0xff) { in rx_get_frame()
5021 spin_lock_irqsave(&info->lock,flags); in rx_get_frame()
5022 rx_start(info); in rx_get_frame()
5023 spin_unlock_irqrestore(&info->lock,flags); in rx_get_frame()
5032 void tx_load_dma_buffer(SLMP_INFO *info, const char *buf, unsigned int count) in tx_load_dma_buffer() argument
5040 trace_block(info,buf, MIN(count,SCABUFSIZE), 1); in tx_load_dma_buffer()
5049 desc = &info->tx_buf_list[i]; in tx_load_dma_buffer()
5050 desc_ex = &info->tx_buf_list_ex[i]; in tx_load_dma_buffer()
5052 load_pci_memory(info, desc_ex->virt_addr,buf,copy_count); in tx_load_dma_buffer()
5064 if (i >= info->tx_buf_count) in tx_load_dma_buffer()
5068 info->tx_buf_list[i].status = 0x81; /* set EOM and EOT status */ in tx_load_dma_buffer()
5069 info->last_tx_buf = ++i; in tx_load_dma_buffer()
5072 int register_test(SLMP_INFO *info) in register_test() argument
5080 spin_lock_irqsave(&info->lock,flags); in register_test()
5081 reset_port(info); in register_test()
5084 info->init_error = DiagStatus_AddressFailure; in register_test()
5090 write_reg(info, TMC, testval[i]); in register_test()
5091 write_reg(info, IDL, testval[(i+1)%count]); in register_test()
5092 write_reg(info, SA0, testval[(i+2)%count]); in register_test()
5093 write_reg(info, SA1, testval[(i+3)%count]); in register_test()
5095 if ( (read_reg(info, TMC) != testval[i]) || in register_test()
5096 (read_reg(info, IDL) != testval[(i+1)%count]) || in register_test()
5097 (read_reg(info, SA0) != testval[(i+2)%count]) || in register_test()
5098 (read_reg(info, SA1) != testval[(i+3)%count]) ) in register_test()
5105 reset_port(info); in register_test()
5106 spin_unlock_irqrestore(&info->lock,flags); in register_test()
5111 int irq_test(SLMP_INFO *info) in irq_test() argument
5116 unsigned char timer = (info->port_num & 1) ? TIMER2 : TIMER0; in irq_test()
5118 spin_lock_irqsave(&info->lock,flags); in irq_test()
5119 reset_port(info); in irq_test()
5122 info->init_error = DiagStatus_IrqFailure; in irq_test()
5123 info->irq_occurred = FALSE; in irq_test()
5128 write_reg(info, IER2, (unsigned char)((info->port_num & 1) ? BIT6 : BIT4)); in irq_test()
5130 write_reg(info, (unsigned char)(timer + TEPR), 0); /* timer expand prescale */ in irq_test()
5131 write_reg16(info, (unsigned char)(timer + TCONR), 1); /* timer constant */ in irq_test()
5144 write_reg(info, (unsigned char)(timer + TMCS), 0x50); in irq_test()
5146 spin_unlock_irqrestore(&info->lock,flags); in irq_test()
5149 while( timeout-- && !info->irq_occurred ) { in irq_test()
5154 spin_lock_irqsave(&info->lock,flags); in irq_test()
5155 reset_port(info); in irq_test()
5156 spin_unlock_irqrestore(&info->lock,flags); in irq_test()
5158 return info->irq_occurred; in irq_test()
5163 int sca_init(SLMP_INFO *info) in sca_init() argument
5166 write_reg(info, PABR0, 0); /* wait controller addr boundary 0 */ in sca_init()
5167 write_reg(info, PABR1, 0); /* wait controller addr boundary 1 */ in sca_init()
5168 write_reg(info, WCRL, 0); /* wait controller low range */ in sca_init()
5169 write_reg(info, WCRM, 0); /* wait controller mid range */ in sca_init()
5170 write_reg(info, WCRH, 0); /* wait controller high range */ in sca_init()
5181 write_reg(info, DPCR, dma_priority); in sca_init()
5184 write_reg(info, DMER, 0x80); in sca_init()
5187 write_reg(info, IER0, 0xff); /* TxRDY,RxRDY,TxINT,RxINT (ports 0-1) */ in sca_init()
5188 write_reg(info, IER1, 0xff); /* DMIB,DMIA (channels 0-3) */ in sca_init()
5189 write_reg(info, IER2, 0xf0); /* TIRQ (timers 0-3) */ in sca_init()
5197 write_reg(info, ITCR, 0); in sca_init()
5204 int init_adapter(SLMP_INFO *info) in init_adapter() argument
5209 volatile u32 *MiscCtrl = (u32 *)(info->lcr_base + 0x50); in init_adapter()
5212 info->misc_ctrl_value |= BIT30; in init_adapter()
5213 *MiscCtrl = info->misc_ctrl_value; in init_adapter()
5223 info->misc_ctrl_value &= ~BIT30; in init_adapter()
5224 *MiscCtrl = info->misc_ctrl_value; in init_adapter()
5227 info->ctrlreg_value = 0xaa; in init_adapter()
5228 write_control_reg(info); in init_adapter()
5231 volatile u32 *LCR1BRDR = (u32 *)(info->lcr_base + 0x2c); in init_adapter()
5254 sca_init(info->port_array[0]); in init_adapter()
5255 sca_init(info->port_array[2]); in init_adapter()
5263 int loopback_test(SLMP_INFO *info) in loopback_test() argument
5273 struct tty_struct *oldtty = info->tty; in loopback_test()
5274 u32 speed = info->params.clock_speed; in loopback_test()
5276 info->params.clock_speed = 3686400; in loopback_test()
5277 info->tty = 0; in loopback_test()
5280 info->init_error = DiagStatus_DmaFailure; in loopback_test()
5286 memset(info->tmp_rx_buf,0,TESTFRAMESIZE); in loopback_test()
5289 spin_lock_irqsave(&info->lock,flags); in loopback_test()
5290 hdlc_mode(info); in loopback_test()
5291 enable_loopback(info,1); in loopback_test()
5292 rx_start(info); in loopback_test()
5293 info->tx_count = count; in loopback_test()
5294 tx_load_dma_buffer(info,buf,count); in loopback_test()
5295 tx_start(info); in loopback_test()
5296 spin_unlock_irqrestore(&info->lock,flags); in loopback_test()
5304 if (rx_get_frame(info)) { in loopback_test()
5312 ( info->tmp_rx_buf_count != count || in loopback_test()
5313 memcmp(buf, info->tmp_rx_buf,count))) { in loopback_test()
5317 spin_lock_irqsave(&info->lock,flags); in loopback_test()
5318 reset_adapter(info); in loopback_test()
5319 spin_unlock_irqrestore(&info->lock,flags); in loopback_test()
5321 info->params.clock_speed = speed; in loopback_test()
5322 info->tty = oldtty; in loopback_test()
5329 int adapter_test( SLMP_INFO *info ) in adapter_test() argument
5334 __FILE__,__LINE__,info->device_name ); in adapter_test()
5336 spin_lock_irqsave(&info->lock,flags); in adapter_test()
5337 init_adapter(info); in adapter_test()
5338 spin_unlock_irqrestore(&info->lock,flags); in adapter_test()
5340 info->port_array[0]->port_count = 0; in adapter_test()
5342 if ( register_test(info->port_array[0]) && in adapter_test()
5343 register_test(info->port_array[1])) { in adapter_test()
5345 info->port_array[0]->port_count = 2; in adapter_test()
5347 if ( register_test(info->port_array[2]) && in adapter_test()
5348 register_test(info->port_array[3]) ) in adapter_test()
5349 info->port_array[0]->port_count += 2; in adapter_test()
5353 __FILE__,__LINE__,info->device_name, (unsigned long)(info->phys_sca_base)); in adapter_test()
5357 if ( !irq_test(info->port_array[0]) || in adapter_test()
5358 !irq_test(info->port_array[1]) || in adapter_test()
5359 (info->port_count == 4 && !irq_test(info->port_array[2])) || in adapter_test()
5360 (info->port_count == 4 && !irq_test(info->port_array[3]))) { in adapter_test()
5362 __FILE__,__LINE__,info->device_name, (unsigned short)(info->irq_level) ); in adapter_test()
5366 if (!loopback_test(info->port_array[0]) || in adapter_test()
5367 !loopback_test(info->port_array[1]) || in adapter_test()
5368 (info->port_count == 4 && !loopback_test(info->port_array[2])) || in adapter_test()
5369 (info->port_count == 4 && !loopback_test(info->port_array[3]))) { in adapter_test()
5371 __FILE__,__LINE__,info->device_name); in adapter_test()
5377 __FILE__,__LINE__,info->device_name ); in adapter_test()
5379 info->port_array[0]->init_error = 0; in adapter_test()
5380 info->port_array[1]->init_error = 0; in adapter_test()
5381 if ( info->port_count > 2 ) { in adapter_test()
5382 info->port_array[2]->init_error = 0; in adapter_test()
5383 info->port_array[3]->init_error = 0; in adapter_test()
5391 int memory_test(SLMP_INFO *info) in memory_test() argument
5398 unsigned long * addr = (unsigned long *)info->memory_base; in memory_test()
5416 addr = (unsigned long *)info->memory_base; in memory_test()
5424 memset( info->memory_base, 0, SCA_MEM_SIZE ); in memory_test()
5443 void load_pci_memory(SLMP_INFO *info, char* dest, const char* src, unsigned short count) in load_pci_memory() argument
5454 read_status_reg(info); in load_pci_memory()
5462 void trace_block(SLMP_INFO *info,const char* data, int count, int xmit) in trace_block() argument
5467 printk("%s tx data:\n",info->device_name); in trace_block()
5469 printk("%s rx data:\n",info->device_name); in trace_block()
5499 SLMP_INFO *info = (SLMP_INFO*)context; in tx_timeout() local
5504 __FILE__,__LINE__,info->device_name); in tx_timeout()
5505 if(info->tx_active && info->params.mode == MGSL_MODE_HDLC) { in tx_timeout()
5506 info->icount.txtimeout++; in tx_timeout()
5508 spin_lock_irqsave(&info->lock,flags); in tx_timeout()
5509 info->tx_active = 0; in tx_timeout()
5510 info->tx_count = info->tx_put = info->tx_get = 0; in tx_timeout()
5512 spin_unlock_irqrestore(&info->lock,flags); in tx_timeout()
5515 if (info->netcount) in tx_timeout()
5516 sppp_tx_done(info); in tx_timeout()
5519 bh_transmit(info); in tx_timeout()
5527 SLMP_INFO *info = (SLMP_INFO*)context; in status_timeout() local
5532 spin_lock_irqsave(&info->lock,flags); in status_timeout()
5533 get_signals(info); in status_timeout()
5534 spin_unlock_irqrestore(&info->lock,flags); in status_timeout()
5538 delta = info->old_signals ^ info->serial_signals; in status_timeout()
5539 info->old_signals = info->serial_signals; in status_timeout()
5542 status |= MISCSTATUS_DSR_LATCHED|(info->serial_signals&SerialSignal_DSR); in status_timeout()
5545 status |= MISCSTATUS_RI_LATCHED|(info->serial_signals&SerialSignal_RI); in status_timeout()
5548 status |= MISCSTATUS_DCD_LATCHED|(info->serial_signals&SerialSignal_DCD); in status_timeout()
5551 status |= MISCSTATUS_CTS_LATCHED|(info->serial_signals&SerialSignal_CTS); in status_timeout()
5554 isr_io_pin(info,status); in status_timeout()
5556 info->status_timer.data = (unsigned long)info; in status_timeout()
5557 info->status_timer.function = status_timeout; in status_timeout()
5558 info->status_timer.expires = jiffies + jiffies_from_ms(10); in status_timeout()
5559 add_timer(&info->status_timer); in status_timeout()
5567 unsigned char * RegAddr = (unsigned char*)(info->sca_base + Addr); \
5568 if (info->port_num > 1) \
5570 if ( info->port_num & 1) { \
5578 unsigned char read_reg(SLMP_INFO * info, unsigned char Addr) in read_reg() argument
5583 void write_reg(SLMP_INFO * info, unsigned char Addr, unsigned char Value) in write_reg() argument
5589 u16 read_reg16(SLMP_INFO * info, unsigned char Addr) in read_reg16() argument
5595 void write_reg16(SLMP_INFO * info, unsigned char Addr, u16 Value) in write_reg16() argument
5601 unsigned char read_status_reg(SLMP_INFO * info) in read_status_reg() argument
5603 unsigned char *RegAddr = (unsigned char *)info->statctrl_base; in read_status_reg()
5607 void write_control_reg(SLMP_INFO * info) in write_control_reg() argument
5609 unsigned char *RegAddr = (unsigned char *)info->statctrl_base; in write_control_reg()
5610 *RegAddr = info->port_array[0]->ctrlreg_value; in write_control_reg()