1. 04 Nov, 2019 1 commit
    • Johan Hovold's avatar
      USB: serial: ch341: reimplement line-speed handling · 35714565
      Johan Hovold authored
      The current ch341 divisor algorithm was known to give inaccurate results
      for certain higher line speeds. Jonathan Olds <jontio@i4free.co.nz>
      investigated this, determined the basic equations used to derive the
      divisors and confirmed them experimentally [1].
      
      The equations Jonathan used could be generalised further to:
      
      	baudrate = 48000000 / (2^(12 - 3 * ps - fact) * div), where
      
      		0 <= ps <= 3,
      		0 <= fact <= 1,
      		2 <= div <= 256 if fact = 0, or
      		9 <= div <= 256 if fact = 1
      
      which will also give better results for lower rates.
      
      Notably the error is reduced for the following standard rates:
      
      	1152000	(4.0% instead of 15% error)
      	 921600	(0.16% instead of -7.5% error)
      	 576000	(-0.80% instead of -5.6% error)
      	    200	(0.16% instead of -0.69% error)
      	    134	(-0.05% instead of -0.63% error)
      	    110	(0.03% instead of -0.44% error)
      
      but also for many non-standard ones.
      
      The current algorithm also suffered from rounding issues (e.g.
      requesting 2950000 Bd resulted in a rate of 2 MBd instead of 3 MBd and
      thus a -32% instead of 1.7% error).
      
      The new algorithm was inspired by the current vendor driver even if that
      one only handles two higher rates that require fact=1 by hard coding the
      corresponding divisors [2].
      
      Michael Dreher <michael@5dot1.de> also did a similar generalisation of
      Jonathan's work and has published his results with a very good summary
      that provides further insights into how this device works [3].
      
      [1] https://lkml.kernel.org/r/000001d51f34$bad6afd0$30840f70$@co.nz
      [2] http://www.wch.cn/download/CH341SER_LINUX_ZIP.html
      [3] https://github.com/nospam2000/ch341-baudrate-calculationReported-by: default avatarJonathan Olds <jontio@i4free.co.nz>
      Tested-by: default avatarJonathan Olds <jontio@i4free.co.nz>
      Cc: Michael Dreher <michael@5dot1.de>
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      35714565
  2. 23 Oct, 2019 1 commit
    • Charles Yeh's avatar
      USB: serial: pl2303: add support for PL2303HXN · ebd09f1c
      Charles Yeh authored
      Prolific has developed a new USB to UART chip: PL2303HXN
      PL2303HXN : PL2303GC/PL2303GS/PL2303GT/PL2303GL/PL2303GE/PL2303GB
      The Vendor request used by the PL2303HXN (TYPE_HXN) is different from
      the existing PL2303 series (TYPE_HX & TYPE_01).
      Therefore, different Vendor requests are used to issue related commands.
      
      1. Added a new TYPE_HXN type in pl2303_type_data, and then executes
         new Vendor request,new flow control and other related instructions
         if TYPE_HXN is recognized.
      
      2. Because the new PL2303HXN only accept the new Vendor request,
         the old Vendor request cannot be accepted (the error message
         will be returned)
         So first determine the TYPE_HX or TYPE_HXN through
         PL2303_READ_TYPE_HX_STATUS in pl2303_startup.
      
        2.1 If the return message is "1", then the PL2303 is the existing
            TYPE_HX/ TYPE_01 series.
            The other settings in pl2303_startup are to continue execution.
        2.2 If the return message is "not 1", then the PL2303 is the new
            TYPE_HXN series.
            The other settings in pl2303_startup are ignored.
            (PL2303HXN will directly use the default value in the hardware,
             no need to add additional settings through the software)
      
      3. In pl2303_open: Because TYPE_HXN is different from the instruction of reset
         down/up stream used by TYPE_HX.
         Therefore, we will also execute different instructions here.
      
      4. In pl2303_set_termios: The UART flow control instructions used by
         TYPE_HXN/TYPE_HX/TYPE_01 are different.
         Therefore, we will also execute different instructions here.
      
      5. In pl2303_vendor_read & pl2303_vendor_write, since TYPE_HXN is different
         from the vendor request instruction used by TYPE_HX/TYPE_01,
         it will also execute different instructions here.
      
      6. In pl2303_update_reg: TYPE_HXN used different register for flow control.
         Therefore, we will also execute different instructions here.
      Signed-off-by: default avatarCharles Yeh <charlesyeh522@gmail.com>
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      ebd09f1c
  3. 13 Oct, 2019 16 commits
  4. 12 Oct, 2019 22 commits