diff --git a/sys/pc98/cbus/sio.c b/sys/pc98/cbus/sio.c index 320740868ab1..62e95214c075 100644 --- a/sys/pc98/cbus/sio.c +++ b/sys/pc98/cbus/sio.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * from: @(#)com.c 7.5 (Berkeley) 5/16/91 - * $Id: sio.c,v 1.22 1997/04/19 14:54:32 kato Exp $ + * $Id: sio.c,v 1.23 1997/04/27 13:22:09 kato Exp $ */ #include "opt_comconsole.h" @@ -198,6 +198,7 @@ #define COM_LOSESOUTINTS(dev) ((dev)->id_flags & 0x08) #define COM_NOFIFO(dev) ((dev)->id_flags & 0x02) #define COM_VERBOSE(dev) ((dev)->id_flags & 0x80) +#define COM_NOTST3(dev) ((dev)->id_flags & 0x10000) #ifndef PC98 #define com_scr 7 /* scratch register for 16450-16550 (R/W) */ @@ -965,7 +966,7 @@ sioprobe(dev) failures[1] = inb(iobase + com_ier) - IER_ETXRDY; failures[2] = inb(iobase + com_mcr) - mcr_image; DELAY(10000); /* Some internal modems need this time */ - if (idev->id_irq != 0) + if (idev->id_irq != 0 && !COM_NOTST3(idev)) failures[3] = isa_irq_pending(idev) ? 0 : 1; failures[4] = (inb(iobase + com_iir) & IIR_IMASK) - IIR_TXRDY; DELAY(1000); /* XXX */ @@ -1235,12 +1236,47 @@ sioattach(isdp) printf(" 16550?"); break; case FIFO_RX_HIGH: - printf(" 16550A"); if (COM_NOFIFO(isdp)) { - printf(" fifo disabled"); + printf(" 16550A fifo disabled"); } else { + /* Detect the fifo size. */ + int i, n; + + /* Enable and reset the FIFO. */ + outb (iobase+com_fifo, FIFO_ENABLE | FIFO_RCV_RST | FIFO_XMT_RST); + + /* Set the loopback mode, 57600 baud. */ + outb (iobase+com_cfcr, CFCR_DLAB); + outb (iobase+com_dlbh, 0); + outb (iobase+com_dlbl, 2); + outb (iobase+com_cfcr, CFCR_8BITS); + outb (iobase+com_mcr, MCR_LOOPBACK); + inb (iobase+com_lsr); + + /* Put data into transmit FIFO and wait until overrun. */ + for (i=n=0; i<20000; ++i) { + unsigned char lsr = inb (iobase+com_lsr); + if (lsr & LSR_OE) + break; + if (lsr & LSR_TXRDY) { + outb (iobase+com_data, 0x5A); + ++n; + } + } + outb (iobase+com_mcr, 0); + outb (iobase+com_fifo, 0); + com->hasfifo = TRUE; - com->tx_fifo_size = 16; + if (n > 40) { + com->tx_fifo_size = 64; + printf(" 16750"); + } else if (n > 24) { + com->tx_fifo_size = 32; + printf(" 16650"); + } else { + com->tx_fifo_size = 16; + printf(" 16550A"); + } #ifdef COM_ESP for (espp = likely_esp_ports; *espp != 0; espp++) if (espattach(isdp, com, *espp)) { diff --git a/sys/pc98/pc98/sio.c b/sys/pc98/pc98/sio.c index 320740868ab1..62e95214c075 100644 --- a/sys/pc98/pc98/sio.c +++ b/sys/pc98/pc98/sio.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * from: @(#)com.c 7.5 (Berkeley) 5/16/91 - * $Id: sio.c,v 1.22 1997/04/19 14:54:32 kato Exp $ + * $Id: sio.c,v 1.23 1997/04/27 13:22:09 kato Exp $ */ #include "opt_comconsole.h" @@ -198,6 +198,7 @@ #define COM_LOSESOUTINTS(dev) ((dev)->id_flags & 0x08) #define COM_NOFIFO(dev) ((dev)->id_flags & 0x02) #define COM_VERBOSE(dev) ((dev)->id_flags & 0x80) +#define COM_NOTST3(dev) ((dev)->id_flags & 0x10000) #ifndef PC98 #define com_scr 7 /* scratch register for 16450-16550 (R/W) */ @@ -965,7 +966,7 @@ sioprobe(dev) failures[1] = inb(iobase + com_ier) - IER_ETXRDY; failures[2] = inb(iobase + com_mcr) - mcr_image; DELAY(10000); /* Some internal modems need this time */ - if (idev->id_irq != 0) + if (idev->id_irq != 0 && !COM_NOTST3(idev)) failures[3] = isa_irq_pending(idev) ? 0 : 1; failures[4] = (inb(iobase + com_iir) & IIR_IMASK) - IIR_TXRDY; DELAY(1000); /* XXX */ @@ -1235,12 +1236,47 @@ sioattach(isdp) printf(" 16550?"); break; case FIFO_RX_HIGH: - printf(" 16550A"); if (COM_NOFIFO(isdp)) { - printf(" fifo disabled"); + printf(" 16550A fifo disabled"); } else { + /* Detect the fifo size. */ + int i, n; + + /* Enable and reset the FIFO. */ + outb (iobase+com_fifo, FIFO_ENABLE | FIFO_RCV_RST | FIFO_XMT_RST); + + /* Set the loopback mode, 57600 baud. */ + outb (iobase+com_cfcr, CFCR_DLAB); + outb (iobase+com_dlbh, 0); + outb (iobase+com_dlbl, 2); + outb (iobase+com_cfcr, CFCR_8BITS); + outb (iobase+com_mcr, MCR_LOOPBACK); + inb (iobase+com_lsr); + + /* Put data into transmit FIFO and wait until overrun. */ + for (i=n=0; i<20000; ++i) { + unsigned char lsr = inb (iobase+com_lsr); + if (lsr & LSR_OE) + break; + if (lsr & LSR_TXRDY) { + outb (iobase+com_data, 0x5A); + ++n; + } + } + outb (iobase+com_mcr, 0); + outb (iobase+com_fifo, 0); + com->hasfifo = TRUE; - com->tx_fifo_size = 16; + if (n > 40) { + com->tx_fifo_size = 64; + printf(" 16750"); + } else if (n > 24) { + com->tx_fifo_size = 32; + printf(" 16650"); + } else { + com->tx_fifo_size = 16; + printf(" 16550A"); + } #ifdef COM_ESP for (espp = likely_esp_ports; *espp != 0; espp++) if (espattach(isdp, com, *espp)) {