Page MenuHomeFreeBSD

uchcom(4): add support for CH9102 and CH343 uarts
Needs ReviewPublic

Authored by kevlo on Aug 14 2024, 9:08 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Jan 5, 4:01 PM
Unknown Object (File)
Fri, Jan 3, 10:10 AM
Unknown Object (File)
Tue, Dec 31, 1:33 AM
Unknown Object (File)
Sun, Dec 29, 6:20 PM
Unknown Object (File)
Sun, Dec 29, 7:52 AM
Unknown Object (File)
Thu, Dec 26, 7:32 PM
Unknown Object (File)
Sun, Dec 15, 5:55 PM
Unknown Object (File)
Sun, Dec 15, 4:15 PM
Subscribers

Details

Reviewers
imp
hrs
emaste
Summary

This patch adds support for CH9102 and CH343 serial adapters.
The WinChipHead CH9102 and CH343 chips support any baud rate up to 6 Mbps.

Test Plan

ugen0.4: <vendor 0x1a86 USB Single Serial> at usbus0
uchcom0 on uhub0
uchcom0: <vendor 0x1a86 USB Single Serial, class 2/0, rev 1.10/4.45, addr 27> on usbus0
uchcom0: CH343 detected

ugen0.4: <vendor 0x1a86 USB2.0-Serial> at usbus0
uchcom0 on uhub0
uchcom0: <vendor 0x1a86 USB2.0-Serial, rev 1.10/2.54, addr 28> on usbus0
uchcom0: CH340 detected

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

kevlo requested review of this revision.Aug 14 2024, 9:08 AM
kevlo created this revision.

I can't test the hardware, nor do I have the hardware spec sheet... but this looks good to my eye...

This revision is now accepted and ready to land.Aug 14 2024, 8:56 PM

Remove unused sc_data_iface_no

This revision now requires review to proceed.Aug 15 2024, 2:47 AM

The only thing I would comment is don't forget to update the .Dd field in manual page. :)

Bump a date in .Dd field in man page.

The only thing I would comment is don't forget to update the .Dd field in manual page. :)

I missed that, thanks for spotting!

joerg added inline comments.
sys/dev/usb/serial/uchcom.c
822

Referring to the discussion in

https://github.com/avrdudes/avrdude/discussions/1639

It seems other BSDs only refuse parity and 5/6/7 bit control for a certain (old) revision of CH340. Do you think it would be possible to implement a somewhat more generic functionality here, rather than restricting it to only CH343?

Add support for line modes other than 8-bit/no-parity/1-stop on
CH340/CH341 chips.

sys/dev/usb/serial/uchcom.c
822

The original goal was to support WCH343, but since you asked whether it's
possible to support 5/6/7 data bits, I think it’s feasible.

kevlo marked an inline comment as not done.Aug 19 2024, 7:27 AM
kevlo added inline comments.
sys/dev/usb/serial/uchcom.c
822

The original goal was to support WCH343, but since you asked whether the
CH340/CH341 could support 5/6/7 data bits, I think it’s feasible.
Please try this revised patch, thanks.

sys/dev/usb/serial/uchcom.c
822

Thanks!
I'll try to find a CH340, and give it a try.

I had someone testing the driver, and he told me that the chip is still buffering data.
I made one inline comment where it's a bit suspicious to me about two register write operations that I think got lost now.

sys/dev/usb/serial/uchcom.c
630

Where did those two uchcom_write_reg operations go to in the patched version? I only see a write to UCHCOM_REG_BPS_PRE later on in uchcom_cfg_open(), but only to a default configuration.