git: 9ed5901048ae - main - puc: add the WCH CH382 2S dual serial card

From: Nick Price <nprice_at_FreeBSD.org>
Date: Sat, 12 Sep 2026 21:59:15 UTC
The branch main has been updated by nprice:

URL: https://cgit.FreeBSD.org/src/commit/?id=9ed5901048aeec0c7cd74e96db6a99c818186d65

commit 9ed5901048aeec0c7cd74e96db6a99c818186d65
Author:     Nick Price <nprice@FreeBSD.org>
AuthorDate: 2026-09-12 21:58:55 +0000
Commit:     Nick Price <nprice@FreeBSD.org>
CommitDate: 2026-09-12 21:59:00 +0000

    puc: add the WCH CH382 2S dual serial card
    
    Two 16850 UARTs in the first I/O BAR at offset 0xc0, 8 bytes apart.
    
    Approved by:    adrian (mentor)
    Reviewed by:    imp, adrian
    Differential Revision:  https://reviews.freebsd.org/D59512
    
    Signed-off-by: Nick Price <nprice@FreeBSD.org>
---
 sys/dev/puc/pucdata.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/sys/dev/puc/pucdata.c b/sys/dev/puc/pucdata.c
index 436af76001da..cfef8d8e214c 100644
--- a/sys/dev/puc/pucdata.c
+++ b/sys/dev/puc/pucdata.c
@@ -67,6 +67,7 @@ static puc_config_f puc_config_sunix;
 static puc_config_f puc_config_systembase;
 static puc_config_f puc_config_timedia;
 static puc_config_f puc_config_titan;
+static puc_config_f puc_config_wch_ch38x;
 
 const struct puc_cfg puc_pci_devices[] = {
 	{   0x0009, 0x7168, 0xffff, 0,
@@ -1504,6 +1505,14 @@ const struct puc_cfg puc_pci_devices[] = {
 	    .config_function = puc_config_syba
 	},
 
+	{   0x1c00, 0x3253, 0xffff, 0,
+	    "WCH CH382 2S PCIe Dual Port Serial",
+	    DEFAULT_RCLK,
+	    PUC_PORT_2S, 0x10, 0, -1,
+	    .flags = PUC_FLAGS_NO_MSI,
+	    .config_function = puc_config_wch_ch38x
+	},
+
 	{   0x1fd4, 0x1999, 0x1fd4, 0x0002,
 	    "Sunix SER5xxxx 2-port serial",
 	    DEFAULT_RCLK * 8,
@@ -2337,3 +2346,14 @@ puc_config_systembase(struct puc_softc *sc __unused,
 	}
 	return (ENXIO);
 }
+
+static int
+puc_config_wch_ch38x(struct puc_softc *sc __unused, enum puc_cfg_cmd cmd,
+    int port, intptr_t *res)
+{
+	if (cmd == PUC_CFG_GET_OFS) {
+		*res = 0xc0 + (port * 8);
+		return (0);
+	}
+	return (ENXIO);
+}