Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1370020

[PATCH v2 03/14] USB: ch341: add LCR register definitions

From Grigori Goronzy <greg@chown.ath.cx>
Newsgroups linux.kernel
Subject [PATCH v2 03/14] USB: ch341: add LCR register definitions
Date 2016-04-02 19:30 +0200
Message-ID <rjxx0-78K-9@gated-at.bofh.it> (permalink)
References <rjxnk-74U-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


BREAK2 seems to be a misnomer, the register configures various aspects
of the UART configuration.

Signed-off-by: Grigori Goronzy <greg@chown.ath.cx>
---
 drivers/usb/serial/ch341.c | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/serial/ch341.c b/drivers/usb/serial/ch341.c
index 9fb9089..788c75a 100644
--- a/drivers/usb/serial/ch341.c
+++ b/drivers/usb/serial/ch341.c
@@ -65,10 +65,19 @@
 #define CH341_REQ_WRITE_REG    0x9A
 #define CH341_REQ_READ_REG     0x95
 #define CH341_REG_BREAK1       0x05
-#define CH341_REG_BREAK2       0x18
+#define CH341_REG_LCR          0x18
 #define CH341_NBREAK_BITS_REG1 0x01
-#define CH341_NBREAK_BITS_REG2 0x40
 
+#define CH341_LCR_ENABLE_RX    0x80
+#define CH341_LCR_ENABLE_TX    0x40
+#define CH341_LCR_MARK_SPACE   0x20
+#define CH341_LCR_PAR_EVEN     0x10
+#define CH341_LCR_ENABLE_PAR   0x08
+#define CH341_LCR_STOP_BITS_2  0x04
+#define CH341_LCR_CS8          0x03
+#define CH341_LCR_CS7          0x02
+#define CH341_LCR_CS6          0x01
+#define CH341_LCR_CS5          0x00
 
 static const struct usb_device_id id_table[] = {
 	{ USB_DEVICE(0x4348, 0x5523) },
@@ -371,7 +380,7 @@ static void ch341_set_termios(struct tty_struct *tty,
 static void ch341_break_ctl(struct tty_struct *tty, int break_state)
 {
 	const uint16_t ch341_break_reg =
-		CH341_REG_BREAK1 | ((uint16_t) CH341_REG_BREAK2 << 8);
+		CH341_REG_BREAK1 | ((uint16_t) CH341_REG_LCR << 8);
 	struct usb_serial_port *port = tty->driver_data;
 	int r;
 	uint16_t reg_contents;
@@ -393,11 +402,11 @@ static void ch341_break_ctl(struct tty_struct *tty, int break_state)
 	if (break_state != 0) {
 		dev_dbg(&port->dev, "%s - Enter break state requested\n", __func__);
 		break_reg[0] &= ~CH341_NBREAK_BITS_REG1;
-		break_reg[1] &= ~CH341_NBREAK_BITS_REG2;
+		break_reg[1] &= ~CH341_LCR_ENABLE_TX;
 	} else {
 		dev_dbg(&port->dev, "%s - Leave break state requested\n", __func__);
 		break_reg[0] |= CH341_NBREAK_BITS_REG1;
-		break_reg[1] |= CH341_NBREAK_BITS_REG2;
+		break_reg[1] |= CH341_LCR_ENABLE_TX;
 	}
 	dev_dbg(&port->dev, "%s - New ch341 break register contents - reg1: %x, reg2: %x\n",
 		__func__, break_reg[0], break_reg[1]);
-- 
1.9.1

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Major improvements to the ch341 driver Grigori Goronzy <greg@chown.ath.cx> - 2016-04-02 19:20 +0200
  [PATCH v2 04/14] USB: ch341: add definitions for modem control Grigori Goronzy <greg@chown.ath.cx> - 2016-04-02 19:30 +0200
  [PATCH v2 13/14] USB: ch341: get rid of default configuration Grigori Goronzy <greg@chown.ath.cx> - 2016-04-02 19:30 +0200
  [PATCH v2 09/14] USB: ch341: add support for RTS/CTS flow control Grigori Goronzy <greg@chown.ath.cx> - 2016-04-02 19:30 +0200
  [PATCH v2 05/14] USB: ch341: fix USB buffer allocations Grigori Goronzy <greg@chown.ath.cx> - 2016-04-02 19:30 +0200
    Re: [PATCH v2 05/14] USB: ch341: fix USB buffer allocations Oliver Neukum <oneukum@suse.com> - 2016-04-04 09:20 +0200
  [PATCH v2 03/14] USB: ch341: add LCR register definitions Grigori Goronzy <greg@chown.ath.cx> - 2016-04-02 19:30 +0200
  [PATCH v2 07/14] USB: ch341: add support for parity, frame length, stop bits Grigori Goronzy <greg@chown.ath.cx> - 2016-04-02 19:30 +0200
    Re: [PATCH v2 07/14] USB: ch341: add support for parity, frame length,  stop bits Karl Palsson <karlp@tweak.net.au> - 2016-04-03 18:00 +0200
    Re: [PATCH v2 07/14] USB: ch341: add support for parity, frame  length, stop bits One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk> - 2016-04-06 14:10 +0200

csiph-web