Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 26 May 2011 14:42:11 +0100
From:      "N.J. Mann" <njm@njm.me.uk>
To:        Marcel Moolenaar <marcel@xcllnt.net>
Cc:        John Baldwin <jhb@FreeBSD.org>, freebsd-hardware@FreeBSD.org
Subject:   Re: Sunix 4056A PCI 4 port RS-232 card - only 2 ports configured
Message-ID:  <20110526134211.GB9481@titania.njm.me.uk>
In-Reply-To: <803C09E5-8E10-4289-A8B3-952E8A72C7A1@xcllnt.net>
References:  <20110522110002.GB91694@titania.njm.me.uk> <201105241610.49930.jhb@freebsd.org> <20110524215232.GB92553@titania.njm.me.uk> <201105250946.45653.jhb@freebsd.org> <803C09E5-8E10-4289-A8B3-952E8A72C7A1@xcllnt.net>

next in thread | previous in thread | raw e-mail | index | archive | help
Hi Marcel,


In message <803C09E5-8E10-4289-A8B3-952E8A72C7A1@xcllnt.net>,
	Marcel Moolenaar (marcel@xcllnt.net) wrote:
> 
> On May 25, 2011, at 6:46 AM, John Baldwin wrote:
> 
> *snip*
> 
> >> For the two devices that fail, ns8250_bus_probe() fails on the first
> >> call:
> >> 
> >> UART4
> >> -----
> >> ns8250_bus_probe:: entry
> >> ns8250_probe::uart_getreg REG_IIR = 1
> >> ns8250_probe::uart_getreg REG_MCR = 64
> >> ns8250_bus_probe::ns8250_probe returned 6
> >> 
> >> UART5
> >> -----
> >> ns8250_bus_probe:: entry
> >> ns8250_probe::uart_getreg REG_IIR = 1
> >> ns8250_probe::uart_getreg REG_MCR = 64
> >> ns8250_bus_probe::ns8250_probe returned 6
> >> 
> >> The value returned for the read of REG_MCR is 64, or 0x40, which causes
> >> the premature exit:
> >> 
> >> static int
> >> ns8250_probe(struct uart_bas *bas)
> >> {
> >> 	u_char val;
> >> 
> >> 	/* Check known 0 bits that don't depend on DLAB. */
> >> 	val = uart_getreg(bas, REG_IIR);
> >> 	if (val & 0x30)
> >> 		return (ENXIO);
> >> 	val = uart_getreg(bas, REG_MCR);
> >> 	if (val & 0xe0)
> >> 		return (ENXIO);
> >> 
> >> 	return (0);
> >> }
> >> 
> >> Do you need to know the contents of 'bas'?
> > 
> > This goes beyond my level of knowledge.  I've cc'd Marcel (author of uart) who 
> > can hopefully help with this more.
> 
> The ns8250 family of UARTs typically have bits 5, 6 and 7 of the
> MCR register reserved and thus hardwired to 0. The probe function
> checks for that to make sure that the hardware looks enough like
> a UART that we can claim it without hosing the box.
> 
> That said: newer chips in the family, like the ST16C850/XR16C850,
> have given those bits a function:
> 	bit 5 - Xon-Any enable
> 	bit 6 - Infrared enable
> 	bit 7 - Clock pre-scaler
> 
> It's unclear to me whether those bits are consistently defined
> across the different implementations (for some reason I think
> not) and it's also unclear to me whether the device will work
> correctly with FreeBSD if we simply ignore those bits (again I
> don't think this is always the case).
> 
> I think the first order of business from an architectural point
> of view is to determine how much value register probing still has
> on modern hardware. In the good old days, this was needed. If
> we think it's not really needed anymore, then it makes sense to
> loosen the grip so to speak.
> 
> For you, the first thing is to see whether the UART ports work
> if you tweak the probe functions, like so:
> 
> Index: uart_dev_ns8250.c
> ===================================================================
> --- uart_dev_ns8250.c	(revision 222217)
> +++ uart_dev_ns8250.c	(working copy)
> @@ -243,7 +243,7 @@
>  	if (val & 0x30)
>  		return (ENXIO);
>  	val = uart_getreg(bas, REG_MCR);
> -	if (val & 0xe0)
> +	if (val & 0xa0)
>  		return (ENXIO);
>  
>  	return (0);

I tried this and the result is that ports 3 and 4 now attach okay.
However, the baud rate of these two is wrong.  If I select 9600 they
actually send and receive at 1200, i.e. eight times slower.  The speed
setting for the first two ports is correct.  (I checked all four ports at
9600, 38400 and 115200.)

Here are the relevant lines from a verbose dmesg.  The ns8250_ lines are
debug printf's I added, with the register contents in hex.

%%%%%
puc0: <Timedia technology 4 Port Serial> port 0xe000-0xe01f,0xe400-0xe40f irq 18 at device 10.0 on pci0
puc_config_timedia::PUC_CFG_GET_NPORTS port=0 dev=1 id=1 res=4
ns8250_bus_probe:: entry
ns8250_probe::uart_getreg REG_IIR = 1
ns8250_probe::uart_getreg REG_MCR = 0
ns8250_bus_probe:: exit
ns8250_bus_probe:: entry
ns8250_probe::uart_getreg REG_IIR = c1
ns8250_probe::uart_getreg REG_MCR = 8
ns8250_bus_probe:: exit
uart2: <16550 or compatible> on puc0
uart2: fast interrupt
ns8250_bus_probe:: entry
ns8250_probe::uart_getreg REG_IIR = 1
ns8250_probe::uart_getreg REG_MCR = 0
ns8250_bus_probe:: exit
ns8250_bus_probe:: entry
ns8250_probe::uart_getreg REG_IIR = c1
ns8250_probe::uart_getreg REG_MCR = 8
ns8250_bus_probe:: exit
uart3: <16550 or compatible> on puc0
uart3: fast interrupt
ns8250_bus_probe:: entry
ns8250_probe::uart_getreg REG_IIR = 1
ns8250_probe::uart_getreg REG_MCR = 40
ns8250_bus_probe:: exit
ns8250_bus_probe:: entry
ns8250_probe::uart_getreg REG_IIR = 1
ns8250_probe::uart_getreg REG_MCR = 48
ns8250_bus_probe:: exit
uart4: <Non-standard ns8250 class UART with FIFOs> on puc0
uart4: fast interrupt
ns8250_bus_probe:: entry
ns8250_probe::uart_getreg REG_IIR = 1
ns8250_probe::uart_getreg REG_MCR = 40
ns8250_bus_probe:: exit
ns8250_bus_probe:: entry
ns8250_probe::uart_getreg REG_IIR = 1
ns8250_probe::uart_getreg REG_MCR = 48
ns8250_bus_probe:: exit
uart5: <Non-standard ns8250 class UART with FIFOs> on puc0
uart5: fast interrupt
%%%%%

> Secondly, I'd like to know the vendor of the Quad-port UART. Either
> it's Sunix's own implementation (this seems to be the case), or they
> simply OEM someone else's. In any case: I'd like to see the datasheet
> of the ASIC so as to understand the meaning/function of the bit.

I took the card out of the PC to see exactly what is on it.  There are
three LSI chips, plus four RS-232 interface chips.  The largest of the
LSI chips is a SUN1889 and it appears to connect to ports 1 and 2, and
to the PCI bus.  The other two LSI chips are both SUN1699.  The first of
these seems to be for port 3 and the second for port 4.  I tried finding
data sheets for these chips on the web, but all I could find was
marketing leaflets for various single- and multi-port RS-232 and RS-422
interface cards.  Perhaps you will have better luck in searching than I
did.

Best wishes.


Cheers,
       Nick.
-- 




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20110526134211.GB9481>