puc(4): [WIP] TXIC TX382B UART controller support

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

puc(4): [WIP] TXIC TX382B UART controller support

SASANO Takayoshi
Hello,

Recently I bought a cheap PCIe UART adapter.
It uses ASMedia ASM1083 PCIe-PCI bridge and TXIC TX382B UART controller.
There is no details/datasheets about TX382B, but a Chinese seller
saids that it is similar to WCH351Q (aka WinChipHead's CH351Q). [1]

So I add new entry to pucdata.c like CH351.
TX382B may be compatible with 16550A but works with no FIFO
when my diff is applied.

Here is a dmesg.

  ppb1 at pci1 dev 0 function 0 "ASMedia ASM1083/1085 PCIE-PCI" rev 0x04
  pci2 at ppb1 bus 2
  puc0 at pci2 dev 0 function 0 "TXIC TX382B" rev 0x10: ports: 2 com
  com4 at puc0 port 0 apic 5 int 18: ns16550a, 16 byte fifo
  com4: probed fifo depth: 0 bytes
  com5 at puc0 port 1 apic 5 int 18: ns16550a, 16 byte fifo
  com5: probed fifo depth: 0 bytes

Is this problem occurs with WCH's CH351?

[1] http://www.mistertao.com/v2/pages/item/39360600316.html
This site is written in Chinese, use Google Translate.

Regards,
--
SASANO Takayoshi <[hidden email]>

Index: pcidevs
===================================================================
RCS file: /cvs/src/sys/dev/pci/pcidevs,v
retrieving revision 1.1790
diff -u -p -r1.1790 pcidevs
--- pcidevs 15 Mar 2016 07:37:15 -0000 1.1790
+++ pcidevs 16 Mar 2016 03:04:27 -0000
@@ -340,6 +340,7 @@ vendor AVANCE2 0x4005 Avance Logic
 vendor ADDTRON 0x4033 Addtron
 vendor NETXEN 0x4040 NetXen
 vendor WCH 0x4348 Nanjing QinHeng Electronics
+vendor TXIC 0x4651 TXIC
 vendor INDCOMPSRC 0x494f Industrial Computer Source
 vendor NETVIN 0x4a14 NetVin
 vendor GEMTEK 0x5046 Gemtek
@@ -5139,6 +5140,9 @@ product WCH CH352 0x3253 CH352
 product WCH2 CH351 0x2273 CH351
 product WCH2 CH382_1 0x3253 CH382
 product WCH2 CH382_2 0x3250 CH382
+
+/* TXIC */
+product TXIC TX382B 0x3273 TX382B
 
 /* National Datacomm Corp products */
 product NDC NCP130 0x0130 NCP130
Index: pcidevs.h
===================================================================
RCS file: /cvs/src/sys/dev/pci/pcidevs.h,v
retrieving revision 1.1784
diff -u -p -r1.1784 pcidevs.h
--- pcidevs.h 15 Mar 2016 07:37:36 -0000 1.1784
+++ pcidevs.h 16 Mar 2016 03:04:28 -0000
@@ -345,6 +345,7 @@
 #define PCI_VENDOR_ADDTRON 0x4033 /* Addtron */
 #define PCI_VENDOR_NETXEN 0x4040 /* NetXen */
 #define PCI_VENDOR_WCH 0x4348 /* Nanjing QinHeng Electronics */
+#define PCI_VENDOR_TXIC 0x4651 /* TXIC */
 #define PCI_VENDOR_INDCOMPSRC 0x494f /* Industrial Computer Source */
 #define PCI_VENDOR_NETVIN 0x4a14 /* NetVin */
 #define PCI_VENDOR_GEMTEK 0x5046 /* Gemtek */
@@ -5144,6 +5145,9 @@
 #define PCI_PRODUCT_WCH2_CH351 0x2273 /* CH351 */
 #define PCI_PRODUCT_WCH2_CH382_1 0x3253 /* CH382 */
 #define PCI_PRODUCT_WCH2_CH382_2 0x3250 /* CH382 */
+
+/* TXIC */
+#define PCI_PRODUCT_TXIC_TX382B 0x3273 /* TX382B */
 
 /* National Datacomm Corp products */
 #define PCI_PRODUCT_NDC_NCP130 0x0130 /* NCP130 */
Index: pcidevs_data.h
===================================================================
RCS file: /cvs/src/sys/dev/pci/pcidevs_data.h,v
retrieving revision 1.1779
diff -u -p -r1.1779 pcidevs_data.h
--- pcidevs_data.h 15 Mar 2016 07:37:36 -0000 1.1779
+++ pcidevs_data.h 16 Mar 2016 03:04:29 -0000
@@ -17760,6 +17760,10 @@ static const struct pci_known_product pc
     "CH382",
  },
  {
+    PCI_VENDOR_TXIC, PCI_PRODUCT_TXIC_TX382B,
+    "TX382B",
+ },
+ {
     PCI_VENDOR_NDC, PCI_PRODUCT_NDC_NCP130,
     "NCP130",
  },
@@ -26754,6 +26758,10 @@ static const struct pci_known_vendor pci
  {
     PCI_VENDOR_WCH,
     "Nanjing QinHeng Electronics",
+ },
+ {
+    PCI_VENDOR_TXIC,
+    "TXIC",
  },
  {
     PCI_VENDOR_INDCOMPSRC,
Index: pucdata.c
===================================================================
RCS file: /cvs/src/sys/dev/pci/pucdata.c,v
retrieving revision 1.102
diff -u -p -r1.102 pucdata.c
--- pucdata.c 15 Mar 2016 07:39:27 -0000 1.102
+++ pucdata.c 16 Mar 2016 03:04:29 -0000
@@ -2166,6 +2166,14 @@ const struct puc_device_description puc_
  { PUC_COM_POW2(0), 0x10, 0x00c8 },
     },
  },
+ {   /* "TXIC TX382B (2S)", */
+    { PCI_VENDOR_TXIC, PCI_PRODUCT_TXIC_TX382B, 0, 0 },
+    { 0xffff, 0xffff, 0, 0 },
+    {
+ { PUC_COM_POW2(0), 0x10, 0x0000 },
+ { PUC_COM_POW2(0), 0x14, 0x0000 },
+    }
+ },
  {   /* "NetMos NM9820 UART" */
     {   PCI_VENDOR_NETMOS, PCI_PRODUCT_NETMOS_NM9820, 0, 0 },
     { 0xffff, 0xffff, 0, 0 },

Reply | Threaded
Open this post in threaded view
|

Re: puc(4): [WIP] TXIC TX382B UART controller support

SASANO Takayoshi
Hello,

The diff is committed (ok by deraadt@), and I am testing the behavior of
TX382B's FIFO.

> Here is a dmesg.
>
>   ppb1 at pci1 dev 0 function 0 "ASMedia ASM1083/1085 PCIE-PCI" rev 0x04
>   pci2 at ppb1 bus 2
>   puc0 at pci2 dev 0 function 0 "TXIC TX382B" rev 0x10: ports: 2 com
>   com4 at puc0 port 0 apic 5 int 18: ns16550a, 16 byte fifo
>   com4: probed fifo depth: 0 bytes
>   com5 at puc0 port 1 apic 5 int 18: ns16550a, 16 byte fifo
>   com5: probed fifo depth: 0 bytes

com_fifo_probe() (at src/sys/dev/ic/com.c) checks the depth of Tx/Rx FIFO,
it uses MCR_LOOPBACK to enter loopback mode.

I found TX382B does not loopback with setting MCR_LOOPBACK,
and this cause com_fifo_probe() detects no FIFO.

It is difficult to write a special code to com.c, I think TX382B should
work without Tx/Rx FIFO. There is other good and cheap UART chip!

Regards,
--
SASANO Takayoshi <[hidden email]>