[...]

> > the CH341 is the one that I have and where I tested dlg's diff
> > beforehand:

[...]

> mine is a CH341 too:

Ok, what about the following diff then? It works for me, does it work
for you?

Index: uchcom.c
===================================================================
RCS file: /OpenBSD/src/sys/dev/usb/uchcom.c,v
retrieving revision 1.29
diff -u -p -r1.29 uchcom.c
--- uchcom.c    2 Nov 2021 09:52:40 -0000       1.29
+++ uchcom.c    12 Nov 2021 07:14:13 -0000
@@ -128,6 +128,7 @@ struct uchcom_softc
        u_char                  *sc_intr_buf;
        int                      sc_isize;
        /* */
+       int                      sc_release;
        uint8_t                  sc_version;
        int                      sc_dtr;
        int                      sc_rts;
@@ -266,10 +267,11 @@ uchcom_attach(struct device *parent, str
 
         sc->sc_udev = dev;
        sc->sc_dtr = sc->sc_rts = -1;
+       sc->sc_release = uaa->release;
 
        DPRINTF(("\n\nuchcom attach: sc=%p\n", sc));
 
-       switch (uaa->release) {
+       switch (sc->sc_release) {
        case UCHCOM_REV_CH340:
                printf("%s: CH340\n", sc->sc_dev.dv_xname);
                break;
@@ -678,6 +680,26 @@ uchcom_set_line_control(struct uchcom_so
 {
        usbd_status err;
        uint8_t lcr = 0, lcr2 = 0;
+
+       if (sc->sc_release == UCHCOM_REV_CH340) {
+               /*
+                * XXX: it is difficult to handle the line control
+                * appropriately on CH340:
+                *   work as chip default - CS8, no parity, !CSTOPB
+                *   other modes are not supported.
+                */
+               switch (ISSET(cflag, CSIZE)) {
+               case CS5:
+               case CS6:
+               case CS7:
+                       return EINVAL;
+               case CS8:
+                       break;
+               }
+               if (ISSET(cflag, PARENB) || ISSET(cflag, CSTOPB))
+                       return EINVAL;
+               return 0;
+       }
 
        err = uchcom_read_reg(sc, UCHCOM_REG_LCR, &lcr,
            UCHCOM_REG_LCR2, &lcr2);

Reply via email to