Lines Matching refs:bp
242 static inline int board_No (struct specialix_board * bp) in board_No() argument
244 return bp - sx_board; in board_No()
263 static inline unsigned char sx_in(struct specialix_board * bp, unsigned short reg) in sx_in() argument
265 bp->reg = reg | 0x80; in sx_in()
266 outb (reg | 0x80, bp->base + SX_ADDR_REG); in sx_in()
267 return inb (bp->base + SX_DATA_REG); in sx_in()
272 static inline void sx_out(struct specialix_board * bp, unsigned short reg, in sx_out() argument
275 bp->reg = reg | 0x80; in sx_out()
276 outb (reg | 0x80, bp->base + SX_ADDR_REG); in sx_out()
277 outb (val, bp->base + SX_DATA_REG); in sx_out()
282 static inline unsigned char sx_in_off(struct specialix_board * bp, unsigned short reg) in sx_in_off() argument
284 bp->reg = reg; in sx_in_off()
285 outb (reg, bp->base + SX_ADDR_REG); in sx_in_off()
286 return inb (bp->base + SX_DATA_REG); in sx_in_off()
291 static inline void sx_out_off(struct specialix_board * bp, unsigned short reg, in sx_out_off() argument
294 bp->reg = reg; in sx_out_off()
295 outb (reg, bp->base + SX_ADDR_REG); in sx_out_off()
296 outb (val, bp->base + SX_DATA_REG); in sx_out_off()
301 static inline void sx_wait_CCR(struct specialix_board * bp) in sx_wait_CCR() argument
306 if (!sx_in(bp, CD186x_CCR)) in sx_wait_CCR()
309 printk(KERN_ERR "sx%d: Timeout waiting for CCR.\n", board_No(bp)); in sx_wait_CCR()
314 static inline void sx_wait_CCR_off(struct specialix_board * bp) in sx_wait_CCR_off() argument
319 if (!sx_in_off(bp, CD186x_CCR)) in sx_wait_CCR_off()
322 printk(KERN_ERR "sx%d: Timeout waiting for CCR.\n", board_No(bp)); in sx_wait_CCR_off()
330 static inline int sx_check_io_range(struct specialix_board * bp) in sx_check_io_range() argument
332 return check_region (bp->base, SX_IO_SPACE); in sx_check_io_range()
336 static inline void sx_request_io_range(struct specialix_board * bp) in sx_request_io_range() argument
338 request_region(bp->base, in sx_request_io_range()
339 bp->flags&SX_BOARD_IS_PCI?SX_PCI_IO_SPACE:SX_IO_SPACE, in sx_request_io_range()
344 static inline void sx_release_io_range(struct specialix_board * bp) in sx_release_io_range() argument
346 release_region(bp->base, in sx_release_io_range()
347 bp->flags&SX_BOARD_IS_PCI?SX_PCI_IO_SPACE:SX_IO_SPACE); in sx_release_io_range()
364 int sx_set_irq ( struct specialix_board *bp) in sx_set_irq() argument
369 if (bp->flags & SX_BOARD_IS_PCI) in sx_set_irq()
371 switch (bp->irq) { in sx_set_irq()
377 default: printk (KERN_ERR "Speclialix: cannot set irq to %d.\n", bp->irq); in sx_set_irq()
382 sx_out(bp, CD186x_CAR, i); in sx_set_irq()
383 sx_out(bp, CD186x_MSVRTS, ((virq >> i) & 0x1)? MSVR_RTS:0); in sx_set_irq()
390 static int sx_init_CD186x(struct specialix_board * bp) in sx_init_CD186x() argument
398 sx_wait_CCR_off(bp); /* Wait for CCR ready */ in sx_init_CD186x()
399 sx_out_off(bp, CD186x_CCR, CCR_HARDRESET); /* Reset CD186x chip */ in sx_init_CD186x()
403 sx_out_off(bp, CD186x_GIVR, SX_ID); /* Set ID for this chip */ in sx_init_CD186x()
404 sx_out_off(bp, CD186x_GICR, 0); /* Clear all bits */ in sx_init_CD186x()
405 sx_out_off(bp, CD186x_PILR1, SX_ACK_MINT); /* Prio for modem intr */ in sx_init_CD186x()
406 sx_out_off(bp, CD186x_PILR2, SX_ACK_TINT); /* Prio for transmitter intr */ in sx_init_CD186x()
407 sx_out_off(bp, CD186x_PILR3, SX_ACK_RINT); /* Prio for receiver intr */ in sx_init_CD186x()
409 sx_out_off(bp, CD186x_SRCR, sx_in (bp, CD186x_SRCR) | SRCR_REGACKEN); in sx_init_CD186x()
414 sx_out_off(bp, CD186x_PPRH, scaler >> 8); in sx_init_CD186x()
415 sx_out_off(bp, CD186x_PPRL, scaler & 0xff); in sx_init_CD186x()
417 if (!sx_set_irq (bp)) { in sx_init_CD186x()
419 printk (KERN_ERR "Cannot set irq to %d.\n", bp->irq); in sx_init_CD186x()
428 int read_cross_byte (struct specialix_board *bp, int reg, int bit) in read_cross_byte() argument
434 sx_out_off (bp, CD186x_CAR, i); in read_cross_byte()
435 if (sx_in_off (bp, reg) & bit) in read_cross_byte()
461 static int sx_probe(struct specialix_board *bp) in sx_probe() argument
471 if (sx_check_io_range(bp)) in sx_probe()
475 sx_out_off(bp, CD186x_PPRL, 0x5a); in sx_probe()
477 val1 = sx_in_off(bp, CD186x_PPRL); in sx_probe()
479 sx_out_off(bp, CD186x_PPRL, 0xa5); in sx_probe()
481 val2 = sx_in_off(bp, CD186x_PPRL); in sx_probe()
486 board_No(bp), bp->base); in sx_probe()
492 val1 = read_cross_byte (bp, CD186x_MSVR, MSVR_DSR); in sx_probe()
493 val2 = read_cross_byte (bp, CD186x_MSVR, MSVR_RTS); in sx_probe()
496 board_No(bp), val1, val2); in sx_probe()
502 val2 = (bp->flags & SX_BOARD_IS_PCI)?0x4d : 0xb2; in sx_probe()
505 board_No(bp), val2, bp->base, val1); in sx_probe()
514 sx_init_CD186x(bp); /* Reset CD186x chip */ in sx_probe()
515 sx_out(bp, CD186x_CAR, 2); /* Select port 2 */ in sx_probe()
516 sx_wait_CCR(bp); in sx_probe()
517 sx_out(bp, CD186x_CCR, CCR_TXEN); /* Enable transmitter */ in sx_probe()
518 sx_out(bp, CD186x_IER, IER_TXRDY); /* Enable tx empty intr */ in sx_probe()
523 printk (KERN_DEBUG "SRSR = %02x, ", sx_in(bp, CD186x_SRSR)); in sx_probe()
524 printk ( "TRAR = %02x, ", sx_in(bp, CD186x_TRAR)); in sx_probe()
525 printk ( "GIVR = %02x, ", sx_in(bp, CD186x_GIVR)); in sx_probe()
526 printk ( "GICR = %02x, ", sx_in(bp, CD186x_GICR)); in sx_probe()
530 if (!sx_init_CD186x(bp)) { in sx_probe()
543 board_No(bp), bp->base); in sx_probe()
547 printk (KERN_INFO "Started with irq=%d, but now have irq=%d.\n", bp->irq, irqs); in sx_probe()
549 bp->irq = irqs; in sx_probe()
552 if (!sx_init_CD186x(bp)) { in sx_probe()
556 sx_request_io_range(bp); in sx_probe()
557 bp->flags |= SX_BOARD_PRESENT; in sx_probe()
569 switch (sx_in_off(bp, CD186x_GFRCR)) { in sx_probe()
578 printk (KERN_DEBUG " GFCR = 0x%02x\n", sx_in_off(bp, CD186x_GFRCR) ); in sx_probe()
584 missed_irq_timer.data = (unsigned long) bp; in sx_probe()
590 board_No(bp), in sx_probe()
591 bp->base, bp->irq, in sx_probe()
619 static inline struct specialix_port * sx_get_port(struct specialix_board * bp, in sx_get_port() argument
625 channel = sx_in(bp, CD186x_GICR) >> GICR_CHAN_OFF; in sx_get_port()
627 port = &sx_port[board_No(bp) * SX_NPORT + channel]; in sx_get_port()
633 board_No(bp), what, channel); in sx_get_port()
638 static inline void sx_receive_exc(struct specialix_board * bp) in sx_receive_exc() argument
645 if (!(port = sx_get_port(bp, "Receive"))) in sx_receive_exc()
651 board_No(bp), port_No(port)); in sx_receive_exc()
656 status = sx_in(bp, CD186x_RCSR); in sx_receive_exc()
661 board_No(bp), port_No(port), port->overrun); in sx_receive_exc()
666 status = sx_in(bp, CD186x_RCSR) & port->mark_mask; in sx_receive_exc()
668 ch = sx_in(bp, CD186x_RDR); in sx_receive_exc()
674 board_No(bp), port_No(port)); in sx_receive_exc()
680 board_No(bp), port_No(port)); in sx_receive_exc()
704 static inline void sx_receive(struct specialix_board * bp) in sx_receive() argument
710 if (!(port = sx_get_port(bp, "Receive"))) in sx_receive()
715 count = sx_in(bp, CD186x_RDCR); in sx_receive()
724 board_No(bp), port_No(port)); in sx_receive()
727 *tty->flip.char_buf_ptr++ = sx_in(bp, CD186x_RDR); in sx_receive()
735 static inline void sx_transmit(struct specialix_board * bp) in sx_transmit() argument
742 if (!(port = sx_get_port(bp, "Transmit"))) in sx_transmit()
749 sx_out(bp, CD186x_CAR, port_No(port)); in sx_transmit()
751 sx_out(bp, CD186x_IER, port->IER); in sx_transmit()
757 sx_out(bp, CD186x_CAR, port_No(port)); in sx_transmit()
759 sx_out(bp, CD186x_IER, port->IER); in sx_transmit()
766 sx_out(bp, CD186x_TDR, CD186x_C_ESC); in sx_transmit()
767 sx_out(bp, CD186x_TDR, CD186x_C_SBRK); in sx_transmit()
771 sx_out(bp, CD186x_TDR, CD186x_C_ESC); in sx_transmit()
772 sx_out(bp, CD186x_TDR, CD186x_C_DELAY); in sx_transmit()
773 sx_out(bp, CD186x_TDR, count); in sx_transmit()
777 sx_out(bp, CD186x_TDR, CD186x_C_ESC); in sx_transmit()
778 sx_out(bp, CD186x_TDR, CD186x_C_EBRK); in sx_transmit()
779 sx_out(bp, CD186x_COR2, port->COR2); in sx_transmit()
780 sx_wait_CCR(bp); in sx_transmit()
781 sx_out(bp, CD186x_CCR, CCR_CORCHG2); in sx_transmit()
789 sx_out(bp, CD186x_TDR, port->xmit_buf[port->xmit_tail++]); in sx_transmit()
796 sx_out(bp, CD186x_CAR, port_No(port)); in sx_transmit()
798 sx_out(bp, CD186x_IER, port->IER); in sx_transmit()
805 static inline void sx_check_modem(struct specialix_board * bp) in sx_check_modem() argument
814 if (!(port = sx_get_port(bp, "Modem"))) in sx_check_modem()
819 mcr = sx_in(bp, CD186x_MCR); in sx_check_modem()
826 if (sx_in(bp, CD186x_MSVR) & MSVR_CD) { in sx_check_modem()
849 if (sx_in(bp, CD186x_MSVR) & MSVR_CTS) { in sx_check_modem()
858 sx_out(bp, CD186x_IER, port->IER); in sx_check_modem()
861 if (sx_in(bp, CD186x_MSVR) & MSVR_DSR) { in sx_check_modem()
870 sx_out(bp, CD186x_IER, port->IER); in sx_check_modem()
875 sx_out(bp, CD186x_MCR, 0); in sx_check_modem()
884 struct specialix_board *bp; in sx_interrupt() local
888 bp = dev_id; in sx_interrupt()
890 if (!bp || !(bp->flags & SX_BOARD_ACTIVE)) { in sx_interrupt()
897 saved_reg = bp->reg; in sx_interrupt()
899 while ((++loop < 16) && (status = (sx_in(bp, CD186x_SRSR) & in sx_interrupt()
904 ack = sx_in(bp, CD186x_RRAR); in sx_interrupt()
907 sx_receive(bp); in sx_interrupt()
909 sx_receive_exc(bp); in sx_interrupt()
912 board_No(bp), ack); in sx_interrupt()
915 ack = sx_in(bp, CD186x_TRAR); in sx_interrupt()
918 sx_transmit(bp); in sx_interrupt()
921 board_No(bp), ack); in sx_interrupt()
923 ack = sx_in(bp, CD186x_MRAR); in sx_interrupt()
926 sx_check_modem(bp); in sx_interrupt()
929 board_No(bp), ack); in sx_interrupt()
933 sx_out(bp, CD186x_EOIR, 0); /* Mark end of interrupt */ in sx_interrupt()
935 bp->reg = saved_reg; in sx_interrupt()
936 outb (bp->reg, bp->base + SX_ADDR_REG); in sx_interrupt()
944 void turn_ints_off (struct specialix_board *bp) in turn_ints_off() argument
946 if (bp->flags & SX_BOARD_IS_PCI) { in turn_ints_off()
952 (void) sx_in_off (bp, 0); /* Turn off interrupts. */ in turn_ints_off()
955 void turn_ints_on (struct specialix_board *bp) in turn_ints_on() argument
957 if (bp->flags & SX_BOARD_IS_PCI) { in turn_ints_on()
960 (void) sx_in (bp, 0); /* Turn ON interrupts. */ in turn_ints_on()
965 static inline int sx_setup_board(struct specialix_board * bp) in sx_setup_board() argument
969 if (bp->flags & SX_BOARD_ACTIVE) in sx_setup_board()
972 if (bp->flags & SX_BOARD_IS_PCI) in sx_setup_board()
973 error = request_irq(bp->irq, sx_interrupt, SA_INTERRUPT | SA_SHIRQ, "specialix IO8+", bp); in sx_setup_board()
975 error = request_irq(bp->irq, sx_interrupt, SA_INTERRUPT, "specialix IO8+", bp); in sx_setup_board()
980 turn_ints_on (bp); in sx_setup_board()
981 bp->flags |= SX_BOARD_ACTIVE; in sx_setup_board()
989 static inline void sx_shutdown_board(struct specialix_board *bp) in sx_shutdown_board() argument
991 if (!(bp->flags & SX_BOARD_ACTIVE)) in sx_shutdown_board()
994 bp->flags &= ~SX_BOARD_ACTIVE; in sx_shutdown_board()
997 printk ("Freeing IRQ%d for board %d.\n", bp->irq, board_No (bp)); in sx_shutdown_board()
999 free_irq(bp->irq, bp); in sx_shutdown_board()
1001 turn_ints_off (bp); in sx_shutdown_board()
1011 static void sx_change_speed(struct specialix_board *bp, struct specialix_port *port) in sx_change_speed() argument
1026 sx_out(bp, CD186x_CAR, port_No(port)); in sx_change_speed()
1031 port->MSVR = MSVR_DTR | (sx_in(bp, CD186x_MSVR) & MSVR_RTS); in sx_change_speed()
1033 port->MSVR = (sx_in(bp, CD186x_MSVR) & MSVR_RTS); in sx_change_speed()
1061 sx_out(bp, CD186x_MSVR, port->MSVR ); in sx_change_speed()
1106 sx_out(bp, CD186x_RBPRH, (tmp >> 8) & 0xff); in sx_change_speed()
1107 sx_out(bp, CD186x_TBPRH, (tmp >> 8) & 0xff); in sx_change_speed()
1108 sx_out(bp, CD186x_RBPRL, tmp & 0xff); in sx_change_speed()
1109 sx_out(bp, CD186x_TBPRL, tmp & 0xff); in sx_change_speed()
1125 sx_out(bp, CD186x_RTPR, tmp); in sx_change_speed()
1173 tty->hw_stopped = !(sx_in(bp, CD186x_MSVR) & (MSVR_CTS|MSVR_DSR)); in sx_change_speed()
1185 sx_out(bp, CD186x_SCHR1, START_CHAR(tty)); in sx_change_speed()
1186 sx_out(bp, CD186x_SCHR2, STOP_CHAR(tty)); in sx_change_speed()
1187 sx_out(bp, CD186x_SCHR3, START_CHAR(tty)); in sx_change_speed()
1188 sx_out(bp, CD186x_SCHR4, STOP_CHAR(tty)); in sx_change_speed()
1204 sx_out(bp, CD186x_COR1, cor1); in sx_change_speed()
1205 sx_out(bp, CD186x_COR2, port->COR2); in sx_change_speed()
1206 sx_out(bp, CD186x_COR3, cor3); in sx_change_speed()
1208 sx_wait_CCR(bp); in sx_change_speed()
1209 sx_out(bp, CD186x_CCR, CCR_CORCHG1 | CCR_CORCHG2 | CCR_CORCHG3); in sx_change_speed()
1214 sx_out(bp, CD186x_MCOR1, mcor1); in sx_change_speed()
1215 sx_out(bp, CD186x_MCOR2, mcor2); in sx_change_speed()
1217 sx_wait_CCR(bp); in sx_change_speed()
1218 sx_out(bp, CD186x_CCR, CCR_TXEN | CCR_RXEN); in sx_change_speed()
1220 sx_out(bp, CD186x_IER, port->IER); in sx_change_speed()
1222 sx_out(bp, CD186x_MSVR, port->MSVR); in sx_change_speed()
1227 static int sx_setup_port(struct specialix_board *bp, struct specialix_port *port) in sx_setup_port() argument
1254 bp->count++; in sx_setup_port()
1257 sx_change_speed(bp, port); in sx_setup_port()
1266 static void sx_shutdown_port(struct specialix_board *bp, struct specialix_port *port) in sx_shutdown_port() argument
1275 board_No(bp), port_No(port), port->overrun); in sx_shutdown_port()
1282 board_No(bp), port_No(port)); in sx_shutdown_port()
1295 sx_out(bp, CD186x_CAR, port_No(port)); in sx_shutdown_port()
1299 sx_out(bp, CD186x_MSVDTR, 0); in sx_shutdown_port()
1303 sx_wait_CCR(bp); in sx_shutdown_port()
1304 sx_out(bp, CD186x_CCR, CCR_SOFTRESET); in sx_shutdown_port()
1307 sx_out(bp, CD186x_IER, port->IER); in sx_shutdown_port()
1313 if (--bp->count < 0) { in sx_shutdown_port()
1315 board_No(bp), bp->count); in sx_shutdown_port()
1316 bp->count = 0; in sx_shutdown_port()
1323 if (!bp->count) in sx_shutdown_port()
1324 sx_shutdown_board(bp); in sx_shutdown_port()
1332 struct specialix_board *bp = port_Board(port); in block_til_ready() local
1404 sx_out(bp, CD186x_CAR, port_No(port)); in block_til_ready()
1405 CD = sx_in(bp, CD186x_MSVR) & MSVR_CD; in block_til_ready()
1410 sx_out (bp, CD186x_MSVR, port->MSVR); in block_til_ready()
1414 sx_out (bp, CD186x_MSVR, port->MSVR); in block_til_ready()
1455 struct specialix_board * bp; in sx_open() local
1463 bp = &sx_board[board]; in sx_open()
1468 board, bp, port, SX_PORT(MINOR(tty->device))); in sx_open()
1474 if ((error = sx_setup_board(bp))) in sx_open()
1481 if ((error = sx_setup_port(bp, port))) in sx_open()
1493 sx_change_speed(bp, port); in sx_open()
1506 struct specialix_board *bp; in sx_close() local
1519 bp = port_Board(port); in sx_close()
1523 board_No(bp), port->count); in sx_close()
1528 board_No(bp), port_No(port), port->count); in sx_close()
1561 sx_out(bp, CD186x_CAR, port_No(port)); in sx_close()
1562 sx_out(bp, CD186x_IER, port->IER); in sx_close()
1579 sx_shutdown_port(bp, port); in sx_close()
1604 struct specialix_board *bp; in sx_write() local
1616 bp = port_Board(port); in sx_write()
1674 sx_out(bp, CD186x_CAR, port_No(port)); in sx_write()
1675 sx_out(bp, CD186x_IER, port->IER); in sx_write()
1776 struct specialix_board * bp; in sx_get_modem_info() local
1781 bp = port_Board(port); in sx_get_modem_info()
1783 sx_out(bp, CD186x_CAR, port_No(port)); in sx_get_modem_info()
1784 status = sx_in(bp, CD186x_MSVR); in sx_get_modem_info()
1788 port_No(port), status, sx_in (bp, CD186x_CAR)); in sx_get_modem_info()
1815 struct specialix_board *bp = port_Board(port); in sx_set_modem_info() local
1869 sx_out(bp, CD186x_CAR, port_No(port)); in sx_set_modem_info()
1870 sx_out(bp, CD186x_MSVR, port->MSVR); in sx_set_modem_info()
1878 struct specialix_board *bp = port_Board(port); in sx_send_break() local
1885 sx_out(bp, CD186x_CAR, port_No(port)); in sx_send_break()
1886 sx_out(bp, CD186x_COR2, port->COR2); in sx_send_break()
1887 sx_out(bp, CD186x_IER, port->IER); in sx_send_break()
1888 sx_wait_CCR(bp); in sx_send_break()
1889 sx_out(bp, CD186x_CCR, CCR_CORCHG2); in sx_send_break()
1890 sx_wait_CCR(bp); in sx_send_break()
1899 struct specialix_board *bp = port_Board(port); in sx_set_serial_info() local
1912 if ((tmp.irq != bp->irq) || in sx_set_serial_info()
1913 (tmp.port != bp->base) || in sx_set_serial_info()
1944 sx_change_speed(bp, port); in sx_set_serial_info()
1955 struct specialix_board *bp = port_Board(port); in sx_get_serial_info() local
1965 tmp.port = bp->base; in sx_get_serial_info()
1966 tmp.irq = bp->irq; in sx_get_serial_info()
2042 struct specialix_board *bp; in sx_throttle() local
2048 bp = port_Board(port); in sx_throttle()
2063 sx_out(bp, CD186x_CAR, port_No(port)); in sx_throttle()
2065 sx_wait_CCR(bp); in sx_throttle()
2066 sx_out(bp, CD186x_CCR, CCR_SSCH2); in sx_throttle()
2067 sx_wait_CCR(bp); in sx_throttle()
2069 sx_out(bp, CD186x_MSVR, port->MSVR); in sx_throttle()
2077 struct specialix_board *bp; in sx_unthrottle() local
2083 bp = port_Board(port); in sx_unthrottle()
2091 sx_out(bp, CD186x_CAR, port_No(port)); in sx_unthrottle()
2093 sx_wait_CCR(bp); in sx_unthrottle()
2094 sx_out(bp, CD186x_CCR, CCR_SSCH1); in sx_unthrottle()
2095 sx_wait_CCR(bp); in sx_unthrottle()
2097 sx_out(bp, CD186x_MSVR, port->MSVR); in sx_unthrottle()
2105 struct specialix_board *bp; in sx_stop() local
2111 bp = port_Board(port); in sx_stop()
2115 sx_out(bp, CD186x_CAR, port_No(port)); in sx_stop()
2116 sx_out(bp, CD186x_IER, port->IER); in sx_stop()
2124 struct specialix_board *bp; in sx_start() local
2130 bp = port_Board(port); in sx_start()
2135 sx_out(bp, CD186x_CAR, port_No(port)); in sx_start()
2136 sx_out(bp, CD186x_IER, port->IER); in sx_start()
2166 struct specialix_board *bp; in sx_hangup() local
2171 bp = port_Board(port); in sx_hangup()
2173 sx_shutdown_port(bp, port); in sx_hangup()