Bug 225932 - uplcom Prolific PL2302 doesn't support high baud rates
Summary: uplcom Prolific PL2302 doesn't support high baud rates
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 11.1-RELEASE
Hardware: Any Any
: --- Affects Some People
Assignee: Hans Petter Selasky
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2018-02-15 19:53 UTC by Gabor Simon
Modified: 2018-10-29 12:13 UTC (History)
5 users (show)

See Also:


Attachments
proposed patch for high baudrate support (9.58 KB, patch)
2018-02-15 19:53 UTC, Gabor Simon
no flags Details | Diff
modified file for easier review (30.54 KB, text/plain)
2018-02-15 19:54 UTC, Gabor Simon
no flags Details
pattern generator for frequency measurements (1.30 KB, text/plain)
2018-02-15 19:55 UTC, Gabor Simon
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Gabor Simon 2018-02-15 19:53:21 UTC
Created attachment 190665 [details]
proposed patch for high baudrate support

1., Current uplcom module supports only the pre-defined baud rates, because free baudrate setting requires a divisor calculating formula.

The product page of the vendor refers to the Linux module source as a reference application (http://lxr.free-electrons.com/source/drivers/usb/serial/pl2303.c), in which the formula is implemented clearly.

(The baseline frequency constant is about 1/1000 off from the one actually used by the binary drivers though.)

After porting the formula, the baud rate can be set to any arbitrary value.


2., The current chip type detection is kind of black magic, while the ID values of the bcdDevice[0] are officially documented in the product datasheets (http://www.prolific.com.tw/US/ShowProduct.aspx?pcid=41&showlevel=0017-0037-0041)

The current detection could not identify the type HXD chips, so disables the baud rates above 6 Mbaud, while the chip supports up to 12Mbaud.


3., The current interrupt callback doesn't process neither the overrun/parity/frame/break error flags, nor the RI and DSR status flags.


As I needed the high bitrates, ported the baudrate formula from the Linux code , please decide if it is legal or not, there already was a "Determine the chip type.  This algorithm is taken from Linux." comment in the code.

I also checked the formula against the values used by the binary driver and corrected the baseline frequency.

Also checked the so-called standard baudrates (that shall work by directly writing them to dwDTERate register) on a PL2303HX, and removed the non-working ones.

(For those who want to play with the values: writing 0xf0-s with 8bit no parity produces one square wave per 10 bits (1 start, 8 data, 1 stop), so measuring the freqency on TxD gives 1/10th of the actual baud rate :D)

I've attached the patch, the changed file (for an easier review) and the small freqency test I used.

NOTE: I have only a PL2303HX (bcdDevice[0]==3) at hand now, so it would be great if someone with other models could test at least the detection code.
Comment 1 Gabor Simon 2018-02-15 19:54:14 UTC
Created attachment 190666 [details]
modified file for easier review
Comment 2 Gabor Simon 2018-02-15 19:55:25 UTC
Created attachment 190667 [details]
pattern generator for frequency measurements
Comment 3 Val Packett 2018-07-30 12:57:15 UTC
Confirming that this fixes 1.5M baud rate (as used by Rockchip devices) on PL2303HX.
Comment 4 Kyle Evans freebsd_committer freebsd_triage 2018-08-08 21:43:04 UTC
Hi,

Can I bug you to shuffle this over to Phabricator [0] and tag myself (@kevans) and @hselasky to start with? Refer to [1] for creating a revision on Phabricator -- notably, please do include the full context.

Thanks,

Kyle Evans

[0] https://reviews.freebsd.org
[1] https://wiki.freebsd.org/Phabricator#Create_a_Revision
Comment 5 Gabor Simon 2018-08-09 10:03:20 UTC
(In reply to Kyle Evans from comment #4)
Hi,

Here's the revision link:
https://reviews.freebsd.org/D16639

I hope I did it according to the process.
I haven't used Phabricator before, so if I missed something, please give a hint how to do it right :).

Regards,

Gabor Simon
Comment 6 commit-hook freebsd_committer freebsd_triage 2018-10-22 11:58:43 UTC
A commit references this bug:

Author: hselasky
Date: Mon Oct 22 11:58:31 UTC 2018
New revision: 339587
URL: https://svnweb.freebsd.org/changeset/base/339587

Log:
  Added support for formula-based arbitrary baud rates, in contrast to
  the current fixed values, which enables use of rates above 1 Mbps.
  Improved the detection of HXD chips, and the status flag handling as
  well.

  Submitted by:		Gabor Simon <gabor.simon75@gmail.com>
  PR:			225932
  Differential revision:	https://reviews.freebsd.org/D16639
  MFC after:		1 week
  Sponsored by:		Mellanox Technologies

Changes:
  head/sys/dev/usb/serial/uplcom.c
Comment 7 Hans Petter Selasky freebsd_committer freebsd_triage 2018-10-22 11:59:11 UTC
Will MFC later.
Comment 8 commit-hook freebsd_committer freebsd_triage 2018-10-29 12:08:26 UTC
A commit references this bug:

Author: hselasky
Date: Mon Oct 29 12:08:15 UTC 2018
New revision: 339851
URL: https://svnweb.freebsd.org/changeset/base/339851

Log:
  MFC r339587:
  Added support for formula-based arbitrary baud rates, in contrast to
  the current fixed values, which enables use of rates above 1 Mbps.
  Improved the detection of HXD chips, and the status flag handling as
  well.

  Submitted by:		Gabor Simon <gabor.simon75@gmail.com>
  PR:			225932
  Approved by:		re (kib)
  Differential revision:	https://reviews.freebsd.org/D16639
  Sponsored by:		Mellanox Technologies

Changes:
_U  stable/12/
  stable/12/sys/dev/usb/serial/uplcom.c
Comment 9 commit-hook freebsd_committer freebsd_triage 2018-10-29 12:10:31 UTC
A commit references this bug:

Author: hselasky
Date: Mon Oct 29 12:10:07 UTC 2018
New revision: 339852
URL: https://svnweb.freebsd.org/changeset/base/339852

Log:
  MFC r339587:
  Added support for formula-based arbitrary baud rates, in contrast to
  the current fixed values, which enables use of rates above 1 Mbps.
  Improved the detection of HXD chips, and the status flag handling as
  well.

  Submitted by:		Gabor Simon <gabor.simon75@gmail.com>
  PR:			225932
  Differential revision:	https://reviews.freebsd.org/D16639
  Sponsored by:		Mellanox Technologies

Changes:
_U  stable/11/
  stable/11/sys/dev/usb/serial/uplcom.c
Comment 10 commit-hook freebsd_committer freebsd_triage 2018-10-29 12:11:34 UTC
A commit references this bug:

Author: hselasky
Date: Mon Oct 29 12:11:28 UTC 2018
New revision: 339853
URL: https://svnweb.freebsd.org/changeset/base/339853

Log:
  MFC r339587:
  Added support for formula-based arbitrary baud rates, in contrast to
  the current fixed values, which enables use of rates above 1 Mbps.
  Improved the detection of HXD chips, and the status flag handling as
  well.

  Submitted by:		Gabor Simon <gabor.simon75@gmail.com>
  PR:			225932
  Differential revision:	https://reviews.freebsd.org/D16639
  Sponsored by:		Mellanox Technologies

Changes:
_U  stable/10/
  stable/10/sys/dev/usb/serial/uplcom.c
Comment 11 commit-hook freebsd_committer freebsd_triage 2018-10-29 12:13:38 UTC
A commit references this bug:

Author: hselasky
Date: Mon Oct 29 12:13:05 UTC 2018
New revision: 339854
URL: https://svnweb.freebsd.org/changeset/base/339854

Log:
  MFC r339587:
  Added support for formula-based arbitrary baud rates, in contrast to
  the current fixed values, which enables use of rates above 1 Mbps.
  Improved the detection of HXD chips, and the status flag handling as
  well.

  Submitted by:		Gabor Simon <gabor.simon75@gmail.com>
  PR:			225932
  Differential revision:	https://reviews.freebsd.org/D16639
  Sponsored by:		Mellanox Technologies

Changes:
_U  stable/9/sys/
  stable/9/sys/dev/usb/serial/uplcom.c