linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johan Hovold <johan@kernel.org>
To: Johan Hovold <johan@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Karoly Pados <pados@pados.hu>,
	linux-usb@vger.kernel.org
Subject: [5/5] USB: serial: cp210x: improve line-speed handling for CP2104 and CP2105
Date: Wed, 18 Jul 2018 14:25:01 +0200	[thread overview]
Message-ID: <20180718122501.14926-6-johan@kernel.org> (raw)

CP2104 and the ECI interface of CP2105 support further baud rates than
the ones specified in AN205 table 1, and we can use the same equations
as for CP2102N to determine and report back the actual baud rates used.

Note that this could eventually be generalised also to CP2108, which
uses a different base clock. There appears to be an error in the CP2108
equations which needs to be confirmed on actual hardware first however
(specifically, the subtraction of one from the divisor appears to be
incorrect as it introduces larger errors).

Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/usb/serial/cp210x.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
index 957406aac9bd..4a118eb13590 100644
--- a/drivers/usb/serial/cp210x.c
+++ b/drivers/usb/serial/cp210x.c
@@ -1537,14 +1537,19 @@ static void cp210x_init_max_speed(struct usb_serial *serial)
 		max = 1000000;
 		break;
 	case CP210X_PARTNUM_CP2104:
+		use_actual_rate = true;
+		max = 2000000;
+		break;
 	case CP210X_PARTNUM_CP2108:
 		max = 2000000;
 		break;
 	case CP210X_PARTNUM_CP2105:
-		if (cp210x_interface_num(serial) == 0)
+		if (cp210x_interface_num(serial) == 0) {
+			use_actual_rate = true;
 			max = 2000000;	/* ECI */
-		else
+		} else {
 			max = 921600;	/* SCI */
+		}
 		break;
 	case CP210X_PARTNUM_CP2102N_QFN28:
 	case CP210X_PARTNUM_CP2102N_QFN24:

             reply	other threads:[~2018-07-18 12:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-18 12:25 Johan Hovold [this message]
  -- strict thread matches above, loose matches on Subject: below --
2018-07-18 13:26 [5/5] USB: serial: cp210x: improve line-speed handling for CP2104 and CP2105 Greg Kroah-Hartman
2018-07-18 19:57 Johan Hovold

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=20180718122501.14926-6-johan@kernel.org \
    --to=johan@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=pados@pados.hu \
    /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;
as well as URLs for NNTP newsgroup(s).