linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michael Hanselmann <public@hansmi.ch>
To: linux-usb@vger.kernel.org, Johan Hovold <johan@kernel.org>
Cc: Michael Hanselmann <public@hansmi.ch>,
	Michael Dreher <michael@5dot1.de>,
	Jonathan Olds <jontio@i4free.co.nz>
Subject: [PATCH 1/4] ch341: Name more registers
Date: Fri,  6 Mar 2020 19:00:42 +0000	[thread overview]
Message-ID: <7a9882c0c5deaa64dcd3199a2d892e9809e6cb8e.1583520568.git.public@hansmi.ch> (raw)
In-Reply-To: <cover.1583520568.git.public@hansmi.ch>

Add more #defines with register names.

Signed-off-by: Michael Hanselmann <public@hansmi.ch>
---
 drivers/usb/serial/ch341.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/serial/ch341.c b/drivers/usb/serial/ch341.c
index c5ecdcd51ffc..518209072c50 100644
--- a/drivers/usb/serial/ch341.c
+++ b/drivers/usb/serial/ch341.c
@@ -59,6 +59,8 @@
 #define CH341_REQ_MODEM_CTRL   0xA4
 
 #define CH341_REG_BREAK        0x05
+#define CH341_REG_PRESCALER    0x12
+#define CH341_REG_DIVISOR      0x13
 #define CH341_REG_LCR          0x18
 #define CH341_NBREAK_BITS      0x01
 
@@ -221,6 +223,7 @@ static int ch341_get_divisor(speed_t speed)
 static int ch341_set_baudrate_lcr(struct usb_device *dev,
 				  struct ch341_private *priv, u8 lcr)
 {
+	uint16_t reg;
 	int val;
 	int r;
 
@@ -237,11 +240,15 @@ static int ch341_set_baudrate_lcr(struct usb_device *dev,
 	 */
 	val |= BIT(7);
 
-	r = ch341_control_out(dev, CH341_REQ_WRITE_REG, 0x1312, val);
+	reg = ((uint16_t)CH341_REG_DIVISOR << 8) | CH341_REG_PRESCALER;
+
+	r = ch341_control_out(dev, CH341_REQ_WRITE_REG, reg, val);
 	if (r)
 		return r;
 
-	r = ch341_control_out(dev, CH341_REQ_WRITE_REG, 0x2518, lcr);
+	reg = ((uint16_t)0x2500) | CH341_REG_LCR;
+
+	r = ch341_control_out(dev, CH341_REQ_WRITE_REG, reg, lcr);
 	if (r)
 		return r;
 
-- 
2.20.1


  reply	other threads:[~2020-03-06 19:00 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-06 19:00 [PATCH 0/4] ch341: Add support for HL340 devices Michael Hanselmann
2020-03-06 19:00 ` Michael Hanselmann [this message]
2020-03-24 10:20   ` [PATCH 1/4] ch341: Name more registers Johan Hovold
2020-03-31 23:34     ` Michael Hanselmann
2020-03-06 19:00 ` [PATCH 2/4] ch341: Detect HL340 variant Michael Hanselmann
2020-03-24 10:31   ` Johan Hovold
2020-03-31 23:35     ` Michael Hanselmann
2020-03-06 19:00 ` [PATCH 3/4] ch341: Limit prescaler on " Michael Hanselmann
2020-03-24 10:41   ` Johan Hovold
2020-03-31 23:35     ` Michael Hanselmann
2020-03-06 19:00 ` [PATCH 4/4] ch341: Simulate break condition " Michael Hanselmann
2020-03-24 10:55   ` Johan Hovold
2020-03-24 10:05 ` [PATCH 0/4] ch341: Add support for HL340 devices Johan Hovold
2020-03-31 23:35   ` Michael Hanselmann

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=7a9882c0c5deaa64dcd3199a2d892e9809e6cb8e.1583520568.git.public@hansmi.ch \
    --to=public@hansmi.ch \
    --cc=johan@kernel.org \
    --cc=jontio@i4free.co.nz \
    --cc=linux-usb@vger.kernel.org \
    --cc=michael@5dot1.de \
    /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).