public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
From: Johan Hovold <johan@kernel.org>
To: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Cc: Corentin Labbe <clabbe@baylibre.com>,
	gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org,
	linux-usb@vger.kernel.org, david@ixit.cz
Subject: Re: [PATCH v8 1/2] usb: serial: add support for CH348
Date: Tue, 13 Jan 2026 16:31:46 +0100	[thread overview]
Message-ID: <aWZlYuFXYd5eAZTT@hovoldconsulting.com> (raw)
In-Reply-To: <CAFBinCAt1DevnggWJdzBzh3X1Yfb0ScZXYsgkrA1cGrUmfXVwg@mail.gmail.com>

On Mon, Dec 15, 2025 at 03:10:29AM +0100, Martin Blumenstingl wrote:
> On Mon, Dec 1, 2025 at 3:10 PM Johan Hovold <johan@kernel.org> wrote:

> > > Unfortunately I don't know how to read the HW flow control state from
> > > the hardware.
> > > Do you have any suggestions, how I can test HW flow control (after
> > > manually enabling it for a port)?
> >
> > You can try disabling reading from the device (e.g. never submit the
> > read urbs) and see if the RTS is deasserted when the buffer fills up.

> Doing so results in:
> - lots of UART_LSR_OE
> - RTS stays LOW (pulled to GND)
> 
> UART_LSR_OE increasing seems correct as far as I understand this.
> RTS being LOW is wrong and I cannot manage to get ch348 to pull it to HIGH.
> 
> I did some more research and found that ch348 implements UART_IIR_MSI
> and provides a fully standard compatible UART_MSR.
> This is either triggered by a status change on the pins (UART_MSR
> delta bits and the actual status bits), or by requesting an update
> using the VEN_R command (UART_MSR status bits only, no delta bits).
> 
> In a very simple test-case I've used jumper cables on port #0 of ch348:
> - RX and TX connected together
> - CTS and RTS connected together
> 
> If I remove the jumper between CTS and RTS I get:
>   ch348 ttyUSB0: got MSR = 0x01 // jumper removed
>   ch348 ttyUSB0: got MSR = 0x11 // jumper connected again
>   ch348 ttyUSB0: got MSR = 0x01 // jumper removed again
> 
> So the hardware does register the change.
> 
> Earlier I thought I found a fix: I had the values for
> R_C4_HW_FLOW_CONTROL_OFF and R_C4_HW_FLOW_CONTROL_ON swapped.
> That however didn't fix it.
> 
> My current work can be found here: [0]
> If you also don't have any further ideas then I'll drop the whole
> RTS/CTS code for now so the ch348 driver can finally make it into
> Linux 6.20

Or you can include it and just document the known issue with RTS control
for port 1. It seems you have everything else working, right?

> > And in the other direction, verify that writes are buffered after you
> > deassert RTS manually on the other end. That should be easier.

> This seems to work: if I pull CTS up then ch348 stops sending data

So that means hardware flow control (CRTSCTS) is enabled, which could
prevent manual control of RTS. Which port did you test this on? Or is it
the same behaviour on all ports (0-3)?

Going back to archives, it seems like you can control RTS on ports 0, 2
and 3. (And DTR/RTS is not available for ports 4-7).

Hardware flow being enabled on just port 1 may explain the difference
even if you would expect the device to also deassert RTS in the overflow
test (unless there are separate bits for controlling auto-rts and
auto-cts).

> > > In case I can't easily figure it out: would you also accept a driver
> > > that doesn't support RTS/CTS for its initial version?
> >
> > It's good to at least be able to control DTR/RST at open/close (i.e.
> > implement dtr_rts()) so that you can communicate when the other end
> > has hw flow enabled. Sound like you're really close to doing so.

> In the meantime I found out why I had trouble with the DTR signal on port 1.
> It was a user(space) error. I've been using [1] for some of my tests
> and it has a bug where it would clear c_cflag HUPCL [2], which
> prevents the kernel from turning DTR off on port close.

Ah, good that you found that.

Johan

  reply	other threads:[~2026-01-13 15:31 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-04 13:58 [PATCH v8 0/2] usb: serial: add support for CH348 Corentin Labbe
2025-02-04 13:58 ` [PATCH v8 1/2] " Corentin Labbe
2025-03-20 12:56   ` David Heidelberg
2025-05-12 10:03   ` Johan Hovold
2025-07-15 21:20     ` Martin Blumenstingl
2025-07-16  7:44       ` Greg KH
2025-07-16  8:28         ` Martin Blumenstingl
2025-07-16  8:57           ` Greg KH
2025-07-16  9:31             ` Martin Blumenstingl
2025-07-16 10:00               ` Greg KH
2025-07-16 11:24                 ` Martin Blumenstingl
2025-07-25 10:14               ` Johan Hovold
2025-07-25 10:07       ` Johan Hovold
2025-07-26 14:54         ` Martin Blumenstingl
2025-07-29  9:43           ` Johan Hovold
2025-07-29 20:45             ` Martin Blumenstingl
2025-08-04 12:32               ` Johan Hovold
2025-08-04 21:35                 ` Martin Blumenstingl
2025-08-27 10:07                   ` Johan Hovold
2025-11-29 15:59                     ` Martin Blumenstingl
2025-12-01 14:10                       ` Johan Hovold
2025-12-15  2:10                         ` Martin Blumenstingl
2026-01-13 15:31                           ` Johan Hovold [this message]
2025-02-04 13:58 ` [PATCH v8 2/2] usb: serial: add Martin and myself as maintainers of CH348 Corentin Labbe
2025-03-30  1:24 ` [PATCH v8 1/2] usb: serial: add support for CH348 Nicolas Frattaroli
2025-03-30 22:11   ` David Heidelberg
     [not found] ` <CA+j61XMwrtRJhGiJu_T5tt3g14fseOqvOJZLbb2bQGduSJsmxQ@mail.gmail.com>
2025-05-04 21:26   ` [PATCH v8 0/2] " Martin Blumenstingl

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aWZlYuFXYd5eAZTT@hovoldconsulting.com \
    --to=johan@kernel.org \
    --cc=clabbe@baylibre.com \
    --cc=david@ixit.cz \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=martin.blumenstingl@googlemail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox