Subject: kern/33566: another PCI ID for pucdata.c (MOXA CP104 V2)
To: None <kern-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: None <gert@greenie.muc.de>
List: netbsd-bugs
Date: 05/26/2006 21:00:00
>Number:         33566
>Category:       kern
>Synopsis:       extention of PCI ID table in pucdata.c for MOXA CP104 V2
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Fri May 26 21:00:00 +0000 2006
>Originator:     Gert Doering
>Release:        NetBSD 2.0.3_STABLE
>Organization:
	
>Environment:
System: NetBSD scotty.greenie.muc.de 2.0.3_STABLE NetBSD 2.0.3_STABLE (SCOTTY) #3: Fri May 26 18:57:40 CEST 2006 gert@scotty.greenie.muc.de:/usr/src-2.0/sys/arch/sparc64/compile/SCOTTY sparc64
Architecture: sparc64
Machine: sparc64
>Description:
	The MOXA CP104 V2 PCI serial card (4x RS232) has a different PCI ID
        than the MOXA CP104 card already listed in pucdata.c (from -current).
        (pucdata.c from -current works fine on 2.0.3 - this is independent
        of the actual NetBSD version)
>How-To-Repeat:
	add a MOXA CP104 V2 and find it non-recognized by puc/com:

	pci2: i/o space, memory space enabled
	unknown vendor 0x1393 product 0x1042 (serial communications, interface 0x02) at 
	pci2 dev 2 function 0 not configured

>Fix:
	the following table entry makes it work for me (copied from the 
        CP104, and changed the "0x1041" to "0x1042").

        I'm not sure about the "COM_FREQ * 8" - but if I understand that
        right, it specifies the crystal on the card, and if the number is
        wrong, the resulting serial port speeds would not be right.  I've
        tested with 9600 and 38400 vs. a dumb vt100 terminal, and both
        rates came out correctly.  So I think I guessed right.

        I've only tested this on Sparc64, but as this is very generic
        stuff, it should be portable to all other platforms as well.

        With the fix, the kernel messages read:

	pci2: i/o space, memory space enabled
	puc0 at pci2 dev 2 function 0: Moxa Technologies, SmartIO CP104-V2/PCI (com, com, com, com)
	com2 at puc0 port 0: interrupting at ivec 14
	com2: ns16550a, working fifo
	com3 at puc0 port 1: interrupting at ivec 14
	com3: ns16550a, working fifo
	com4 at puc0 port 2: interrupting at ivec 14
	com4: ns16550a, working fifo
	com5 at puc0 port 3: interrupting at ivec 14
	com5: ns16550a, working fifo


diff -u -r1.44 pucdata.c
--- pucdata.c   9 Mar 2006 15:16:13 -0000       1.44
+++ pucdata.c   26 May 2006 20:41:40 -0000
@@ -918,6 +918,18 @@
            },
        },
 
+       /* Moxa Technologies Co., Ltd. PCI I/O Card 4S RS232 */
+       {   "Moxa Technologies, SmartIO CP104-V2/PCI",
+           {   0x1393, 0x1042, 0,      0    },
+           {   0xffff, 0xffff, 0,      0    },
+           {
+               { PUC_PORT_TYPE_COM, 0x18, 0x00, COM_FREQ * 8 },
+               { PUC_PORT_TYPE_COM, 0x18, 0x08, COM_FREQ * 8 },
+               { PUC_PORT_TYPE_COM, 0x18, 0x10, COM_FREQ * 8 },
+               { PUC_PORT_TYPE_COM, 0x18, 0x18, COM_FREQ * 8 },
+           },
+       },
+
        /* NetMos 1P PCI : 1P */
        {   "NetMos NM9805 1284 Printer port",
            {   0x9710, 0x9805, 0,      0       },