Subject: puc(4) card with a weird setup
To: None <tech-kern@netbsd.org>
From: Quentin Garnier <cube@cubidou.net>
List: tech-kern
Date: 10/13/2005 12:15:10
Hi all,

I've just bought 8-serial-ports PCI cards sold by ExSys.  They have two
chips on it: OxSemi OX16PCI954 and OX16C954.  Each of the chips handle 4
serial ports, but the whole thing has a very specific design.

We already have support for the OX16PCI954, function 0.  When it appears
as device ID 0x9501, it is a 4-ports device and all is well, 4 com(4)
ports attach.  No issue here.

The OX16PCI954 chip, however, has extended abilities through another PCI
device at function 1, which can be several things.  It can be a parallel
port, and we have support for it.

But it can also be a bridge to a 8-bits local bus, on which you can have
another chip(s).  In the case of the cards I bought, it is an 0X16C954
(which is pretty much the same thing as the OX16PCI954, sans the PCI
aspect) which handles 4 serial ports.

The following patch makes my card work on NetBSD, but it will only work
in that case.  I don't way a way to make it work in a more generic case.

FWIW, I've looked at what Linux does, and it takes a slightly different
approach.  It looks at the size of the I/O BAR, divides it by the size
for one of the port, and infer the number of them that way.  Basically,
it assumes that there are serial ports on the 8-bits bus, and that it
will access them the same way as the others.

I have no idea how I could detect there is an OX16C954 behind the
bridge.

Any suggestion on how to properly support that card on NetBSD?

Quentin Garnier.

Index: pucdata.c
===================================================================
RCS file: /pub/NetBSD-CVS/src/sys/dev/pci/pucdata.c,v
retrieving revision 1.40
diff -u -r1.40 pucdata.c
--- pucdata.c	27 Feb 2005 00:27:34 -0000	1.40
+++ pucdata.c	13 Oct 2005 09:58:05 -0000
@@ -897,6 +897,18 @@
 	    },
 	},
 
+	/* Oxford Semiconductor OX16PCI954 PCI UARTs on function 1 */
+	{   "Oxford Semiconductor OX16PCI954 Secondary UARTs",
+	    {	0x1415,	0x9511,	0,	0	},
+	    {	0xffff,	0xffff,	0,	0	},
+	    {
+		{ PUC_PORT_TYPE_COM, 0x10, 0x00, COM_FREQ },
+		{ PUC_PORT_TYPE_COM, 0x10, 0x08, COM_FREQ },
+		{ PUC_PORT_TYPE_COM, 0x10, 0x10, COM_FREQ },
+		{ PUC_PORT_TYPE_COM, 0x10, 0x18, COM_FREQ },
+	    },
+	},
+
 	/* Oxford Semiconductor OX16PCI954 PCI Parallel port */
 	{   "Oxford Semiconductor OX16PCI954 Parallel port",
 	    {	0x1415,	0x9513,	0,	0	},