Hello.

Recently I tried to use multiport serial card
"Cronyx Omega-PCI (8 port serial)" with
i386 OpenBSD-5.1 and noticed that the kernel
detected serial port chips of this card
incorrectly as "st16650, 32 byte fifo" (dmesg)
but not "st16c654, 64 byte fifo" (as it was,
for example, in OpenBSD-4.2).

I checked the current manual for puc.4
(http://www.openbsd.org/cgi-bin/cvsweb/src/share/man/man4/puc.4?rev=1.46;content-type=text%2Fplain):
Cronyx Omega-PCI is supported by OpenBSD.

I checked the current src/sys/dev/pci/puc.c and
noticed that the appropriate code for "Cronyx Omega-PCI"
was removed in revision 1.20
(http://www.openbsd.org/cgi-bin/cvsweb/src/sys/dev/pci/puc.c.diff?r1=1.19;r2=1.20).

Is it possible to recover the removed code?


--
Alexei Malinin


-------- Original Message --------
Subject: Re: about st16c654
Date: Sun, 17 Dec 2006 22:02:13 +0000
From: Miod Vallat <m...@online.fr>
To: Alexei G. Malinin <alexei.mali...@inetcomm.ru>
CC: Michael Shalayeff <mic...@lucifier.net>

> Comments for st16c654.patch:
> - in sys/dev/pci/puc.c your code forces the uart type for the pci card,
>   but com_attach_subr() in sys/dev/ic/com_subr.c probes for uart type
>   unconditionally; my code fragment in com_attach_subr() does not probe
>   for st16c654 if this uart type is set;

Right, I forgot to add a test to skip the probe in this case.

> - if there is a code which sets the uart type for certain cards then in
>   other places of the kernel there must be the code which sets the uart
>   type of "unknown" for other unknown cards to prevent garbage in
>   sc->sc_uarttype (look at com_attach_subr() in sys/dev/ic/com_subr.c);
>   my example is in sys/dev/puc/com_puc.c: com_puc_attach() - there I set
>   sc->sc_uarttype to 0 for other cards if pa->hwtype is "false";
>   I think that sc->sc_uarttype in com_attach_subr() already must be set
>   to one of known values (COM_UART_UNKNOWN - or 0 - for probing the card
>   or COM_UART_OX16C950|COM_UART_ST16C654|... for known cards) - let's
>   imagine that there is garbage with value of COM_UART_OX16C950 or
>   COM_UART_ST16C654 in sc->sc_uarttype of com_attach_subr(),
>   then com_attach_subr() will say that we have this uart but this will be
>   untrue;
>   my English is not good but I hope that you will understand my idea :-)

There was no bug there - these structures are initialized to zero, so
the hardware type would be COM_UART_UNKNOWN unless it has been
initialized explicitely.

What about this diff, then?

Miod

Index: arch/i386/isa/pccom.c
===================================================================
RCS file: /cvs/src/sys/arch/i386/isa/pccom.c,v
retrieving revision 1.55
diff -u -p -r1.55 pccom.c
--- arch/i386/isa/pccom.c       2006/09/19 11:06:34     1.55
+++ arch/i386/isa/pccom.c       2006/12/17 22:01:07
@@ -541,6 +541,7 @@ comopen(dev_t dev, int flag, int mode, s
                switch (sc->sc_uarttype) {
                case COM_UART_ST16650:
                case COM_UART_ST16650V2:
+               case COM_UART_ST16C654:
                case COM_UART_XR16850:
                case COM_UART_OX16C950:
                        bus_space_write_1(iot, ioh, com_lcr, LCR_EFR);
@@ -571,6 +572,12 @@ comopen(dev_t dev, int flag, int mode, s
                                else
                                        fifo |= 
FIFO_RCV_TRIGGER_28|FIFO_XMT_TRIGGER_30;
                                break;
+                       case COM_UART_ST16C654:
+                               if (tp->t_ispeed <= 1200)
+                                       fifo |= 
FIFO_RCV3_TRIGGER_8|FIFO_XMT3_TRIGGER_8; /* XXX */
+                               else
+                                       fifo |= 
FIFO_RCV3_TRIGGER_60|FIFO_XMT3_TRIGGER_56;
+                               break;
                        case COM_UART_XR16850:
                        case COM_UART_OX16C950:
                                pccom_xr16850_fifo_init(iot, ioh);
@@ -748,6 +755,7 @@ compwroff(struct com_softc *sc)
        switch (sc->sc_uarttype) {
        case COM_UART_ST16650:
        case COM_UART_ST16650V2:
+       case COM_UART_ST16C654:
        case COM_UART_XR16850:
        case COM_UART_OX16C950:
                bus_space_write_1(iot, ioh, com_lcr, LCR_EFR);
@@ -1018,6 +1026,7 @@ comparam(struct tty *tp, struct termios                   
        else
                                        fifo |= 
FIFO_RCV_TRIGGER_28|FIFO_XMT_TRIGGER_30;
                                break;
+                       case COM_UART_ST16C654:
                        case COM_UART_XR16850:
                        case COM_UART_OX16C950:
                                if (t->c_ispeed <= 1200)
Index: arch/i386/isa/pccomvar.h
===================================================================
RCS file: /cvs/src/sys/arch/i386/isa/pccomvar.h,v
retrieving revision 1.18
diff -u -p -r1.18 pccomvar.h
--- arch/i386/isa/pccomvar.h    2006/07/31 11:06:20     1.18
+++ arch/i386/isa/pccomvar.h    2006/12/17 22:01:07
@@ -70,6 +70,7 @@ struct com_softc {
 #define COM_UART_ST16650       0x05            /* no working fifo */
 #define COM_UART_ST16650V2     0x06            /* 32 byte fifo */
 #define COM_UART_TI16750       0x07            /* 64 byte fifo */
+#define        COM_UART_ST16C654       0x08            /* 64 bytes fifo */
 #define COM_UART_XR16850       0x10            /* 128 byte fifo */
 #define COM_UART_OX16C950      0x12            /* 128 byte fifo */
        u_char sc_uartrev;
Index: dev/ic/com_subr.c
===================================================================
RCS file: /cvs/src/sys/dev/ic/com_subr.c,v
retrieving revision 1.7
diff -u -p -r1.7 com_subr.c
--- dev/ic/com_subr.c   2006/07/31 11:06:30     1.7
+++ dev/ic/com_subr.c   2006/12/17 22:01:08
@@ -169,28 +169,24 @@ com_attach_subr(sc)
        bus_space_write_1(iot, ioh, com_fifo, FIFO_ENABLE);
        delay(100);
 -#ifdef COM_PXA2X0
-       /* Attachment driver presets COM_UART_PXA2X0. */
-       if (sc->sc_uarttype != COM_UART_PXA2X0)
-#endif
-#ifdef COM_UART_OX16C950
-       /* Attachment driver presets COM_UART_OX16C950. */
-       if (sc->sc_uarttype != COM_UART_OX16C950)
-#endif
-       switch(bus_space_read_1(iot, ioh, com_iir) >> 6) {
-       case 0:
-               sc->sc_uarttype = COM_UART_16450;
-               break;
-       case 2:
-               sc->sc_uarttype = COM_UART_16550;
-               break;
-       case 3:
-               sc->sc_uarttype = COM_UART_16550A;
-               break;
-       default:
-               sc->sc_uarttype = COM_UART_UNKNOWN;
-               break;
-       }
+       /*
+        * Skip specific probes if attachment code knows it already.
+        */
+       if (sc->sc_uarttype == COM_UART_UNKNOWN)
+               switch (bus_space_read_1(iot, ioh, com_iir) >> 6) {
+               case 0:
+                       sc->sc_uarttype = COM_UART_16450;
+                       break;
+               case 2:
+                       sc->sc_uarttype = COM_UART_16550;
+                       break;
+               case 3:
+                       sc->sc_uarttype = COM_UART_16550A;
+                       break;
+               default:
+                       sc->sc_uarttype = COM_UART_UNKNOWN;
+                       break;
+               }
        if (sc->sc_uarttype == COM_UART_16550A) { /* Probe for ST16650s */
                bus_space_write_1(iot, ioh, com_lcr, lcr | LCR_DLAB);
@@ -300,6 +296,11 @@ com_attach_subr(sc)
                printf(": st16650, %d byte fifo\n", sc->sc_fifolen);
                SET(sc->sc_hwflags, COM_HW_FIFO);
                break;
+       case COM_UART_ST16C654:
+               printf(": st16c654, 64 byte fifo\n");
+               SET(sc->sc_hwflags, COM_HW_FIFO);
+               sc->sc_fifolen = 64;
+               break;
        case COM_UART_TI16750:
                printf(": ti16750, 64 byte fifo\n");
                SET(sc->sc_hwflags, COM_HW_FIFO);
Index: dev/ic/comvar.h
===================================================================
RCS file: /cvs/src/sys/dev/ic/comvar.h,v
retrieving revision 1.39
diff -u -p -r1.39 comvar.h
--- dev/ic/comvar.h     2006/07/31 11:06:30     1.39
+++ dev/ic/comvar.h     2006/12/17 22:01:08
@@ -102,6 +102,7 @@ struct com_softc {
 #define COM_UART_ST16650       0x05            /* no working fifo */
 #define COM_UART_ST16650V2     0x06            /* 32 byte fifo */
 #define COM_UART_TI16750       0x07            /* 64 byte fifo */
+#define        COM_UART_ST16C654       0x08            /* 64 bytes fifo */
 #define        COM_UART_XR16850        0x10            /* 128 byte fifo */
 #define COM_UART_PXA2X0                0x11            /* 16 byte fifo */
 #define        COM_UART_OX16C950       0x12            /* 128 byte fifo */
Index: dev/pci/pcidevs
===================================================================
RCS file: /cvs/src/sys/dev/pci/pcidevs,v
retrieving revision 1.1203
diff -u -p -r1.1203 pcidevs
--- dev/pci/pcidevs     2006/12/17 11:47:05     1.1203
+++ dev/pci/pcidevs     2006/12/17 22:01:10
@@ -3176,6 +3176,7 @@ product PLX 1077          0x1077  I/O 1077
 product PLX 8532_PCIE          0x8532  8532 PCIE
 product PLX 9050               0x9050  I/O 9050
 product PLX 9080               0x9080  I/O 9080
+product        PLX CRONYX_OMEGA        0xc001  Cronyx Omega
  /* Promise products */
 product PROMISE PDC20265       0x0d30  PDC20265
Index: dev/pci/pcidevs.h
===================================================================
RCS file: /cvs/src/sys/dev/pci/pcidevs.h,v
retrieving revision 1.1204
diff -u -p -r1.1204 pcidevs.h
--- dev/pci/pcidevs.h   2006/12/17 11:48:35     1.1204
+++ dev/pci/pcidevs.h   2006/12/17 22:01:11
@@ -3181,6 +3181,7 @@
 #define        PCI_PRODUCT_PLX_8532_PCIE       0x8532          /* 8532 PCIE */
 #define        PCI_PRODUCT_PLX_9050    0x9050          /* I/O 9050 */
 #define        PCI_PRODUCT_PLX_9080    0x9080          /* I/O 9080 */
+#define        PCI_PRODUCT_PLX_CRONYX_OMEGA    0xc001          /* Cronyx Omega 
*/
  /* Promise products */
 #define        PCI_PRODUCT_PROMISE_PDC20265    0x0d30          /* PDC20265 */
Index: dev/pci/pcidevs_data.h
===================================================================
RCS file: /cvs/src/sys/dev/pci/pcidevs_data.h,v
retrieving revision 1.1201
diff -u -p -r1.1201 pcidevs_data.h
--- dev/pci/pcidevs_data.h      2006/12/17 11:48:35     1.1201
+++ dev/pci/pcidevs_data.h      2006/12/17 22:01:12
@@ -9947,6 +9947,10 @@ static const struct pci_known_product pc
            "I/O 9080",
        },
        {
+           PCI_VENDOR_PLX, PCI_PRODUCT_PLX_CRONYX_OMEGA,
+           "Cronyx Omega",
+       },
+       {
            PCI_VENDOR_PROMISE, PCI_PRODUCT_PROMISE_PDC20265,
            "PDC20265",
        },
Index: dev/pci/puc.c
===================================================================
RCS file: /cvs/src/sys/dev/pci/puc.c,v
retrieving revision 1.10
diff -u -p -r1.10 puc.c
--- dev/pci/puc.c       2006/08/01 20:10:29     1.10
+++ dev/pci/puc.c       2006/12/17 22:01:12
@@ -61,6 +61,8 @@
 #include <dev/pci/pcivar.h>
 #include <dev/pci/pucvar.h>
 +#include <dev/pci/pcidevs.h>
+
 struct puc_pci_softc {
        struct puc_softc sc_psc;
 @@ -214,6 +216,15 @@ puc_pci_attach(parent, self, aux)
        paa.hwtype = 0; /* autodetect */
        paa.intr_string = &puc_pci_intr_string;
        paa.intr_establish = &puc_pci_intr_establish;
+
+       /*
+        * If this is a serial card with a known specific chip, provide
+        * the UART type.
+        */
+       if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_PLX &&
+           PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_PLX_CRONYX_OMEGA)
+               paa.hwtype = 0x08;      /* XXX COM_UART_ST16C654 */
+
        puc_common_attach(sc, &paa);
 }
 Index: dev/pci/pucdata.c
===================================================================
RCS file: /cvs/src/sys/dev/pci/pucdata.c,v
retrieving revision 1.44
diff -u -p -r1.44 pucdata.c
--- dev/pci/pucdata.c   2006/11/08 17:46:54     1.44
+++ dev/pci/pucdata.c   2006/12/17 22:01:13
@@ -1263,6 +1263,22 @@ const struct puc_device_description puc_
            },
        },
 +      /* Cronyx Engineering Ltd. Omega-PCI (8 serial port) card. */
+       {    /* "Cronyx Omega­PCI" */
+           {   PCI_VENDOR_PLX, PCI_PRODUCT_PLX_CRONYX_OMEGA,   0, 0 },
+           {   0xffff, 0xffff,                                 0, 0 },
+           {
+               { PUC_PORT_TYPE_COM, 0x18, 0x00, COM_FREQ },
+               { PUC_PORT_TYPE_COM, 0x18, 0x08, COM_FREQ },
+               { PUC_PORT_TYPE_COM, 0x18, 0x10, COM_FREQ },
+               { PUC_PORT_TYPE_COM, 0x18, 0x18, COM_FREQ },
+               { PUC_PORT_TYPE_COM, 0x18, 0x20, COM_FREQ },
+               { PUC_PORT_TYPE_COM, 0x18, 0x28, COM_FREQ },
+               { PUC_PORT_TYPE_COM, 0x18, 0x30, COM_FREQ },
+               { PUC_PORT_TYPE_COM, 0x18, 0x38, COM_FREQ },
+           },
+       },
+
        /* Avlab Technology, Inc. Low Profile PCI 4 Serial: 4S */
        {   /* "Avlab Low Profile PCI 4 Serial" */
            {   PCI_VENDOR_AVLAB, PCI_PRODUCT_AVLAB_LPPCI4S,    0, 0  },

Reply via email to