From owner-freebsd-bugs Tue May 6 12:40:04 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id MAA00568 for bugs-outgoing; Tue, 6 May 1997 12:40:04 -0700 (PDT) Received: (from gnats@localhost) by hub.freebsd.org (8.8.5/8.8.5) id MAA00543; Tue, 6 May 1997 12:40:02 -0700 (PDT) Resent-Date: Tue, 6 May 1997 12:40:02 -0700 (PDT) Resent-Message-Id: <199705061940.MAA00543@hub.freebsd.org> Resent-From: gnats (GNATS Management) Resent-To: freebsd-bugs Resent-Reply-To: FreeBSD-gnats@FreeBSD.ORG, vak@cronyx.ru Received: from crox.net.kiae.su (crox.net.kiae.su [144.206.130.72]) by hub.freebsd.org (8.8.5/8.8.5) with ESMTP id MAA00342 for ; Tue, 6 May 1997 12:35:56 -0700 (PDT) Received: by crox.net.kiae.su id XAA00455; (8.8.5/vak/1.8a) Tue, 6 May 1997 23:35:48 +0400 (MSD) Message-Id: <199705061935.XAA00455@crox.net.kiae.su> Date: Tue, 6 May 1997 23:35:48 +0400 (MSD) From: vak@cronyx.ru Reply-To: vak@cronyx.ru To: FreeBSD-gnats-submit@FreeBSD.ORG X-Send-Pr-Version: 3.2 Subject: i386/3523: [patch] sio: automatic detection of 16550/16750 controllers Sender: owner-bugs@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk >Number: 3523 >Category: i386 >Synopsis: sio driver: added automatic detection of 16650/16750 UARTs >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Class: change-request >Submitter-Id: current-users >Arrival-Date: Tue May 6 12:40:01 PDT 1997 >Last-Modified: >Originator: Serge V.Vakulenko >Organization: Cronyx Engineering Ltd. >Release: FreeBSD 2.2.1-RELEASE i386 >Environment: FreeBSD 2.2.1 with Cronyx-Omega multiport serial card (Based on Startech 16c654 UARTs). Or any other serial adapter with 16650 or 16750 chips. >Description: The driver detects UARTs as 16550A which is not correct. >How-To-Repeat: >Fix: Apply the following patch: --- sio221.c Sat Feb 1 19:19:05 1997 +++ sio.c Tue May 6 23:28:37 1997 @@ -856,12 +856,46 @@ 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)) { >Audit-Trail: >Unformatted: