Re: [PATCH] Winchiphead 340/1: full baud rate and status/control line support

Previous thread: none

Next thread: [PATCH] arch/powerpc/platforms/powermac/pic.c: move of_node_put by Julia Lawall on Sunday, September 21, 2008 - 4:01 am. (2 messages)
From: Tollef Fog Heen
Date: Sunday, September 21, 2008 - 2:22 am

Patch against current git (9824b8f11373b0df806c135a342da9319ef1d893)

From: Tollef Fog Heen <tfheen@err.no>

* Implement support for all baud rates rather than just a hard coded set.
* Make it possible to control status and control lines

Signed-off-by: Tollef Fog Heen <tfheen@err.no>
---
 Documentation/usb/usb-serial.txt |    2 +
 drivers/usb/serial/ch341.c       |  421 +++++++++++++++++++++++++++++++-------
 2 files changed, 348 insertions(+), 75 deletions(-)

diff --git a/Documentation/usb/usb-serial.txt b/Documentation/usb/usb-serial.txt
index ff2c1ff..201ec84 100644
--- a/Documentation/usb/usb-serial.txt
+++ b/Documentation/usb/usb-serial.txt
@@ -434,6 +434,8 @@ Winchiphead CH341 Driver
   The manufacturer's website: http://www.winchiphead.com/.
   For any questions or problems with this driver, please contact
   frank@kingswood-consulting.co.uk.
+  Extensions for universal baudrate settings and modem status/control have
+  been added by werner <at> cornelius-consult.de.
 
 
 Generic Serial driver
diff --git a/drivers/usb/serial/ch341.c b/drivers/usb/serial/ch341.c
index f61e3ca..22ca0c2 100644
--- a/drivers/usb/serial/ch341.c
+++ b/drivers/usb/serial/ch341.c
@@ -1,5 +1,7 @@
 /*
  * Copyright 2007, Frank A Kingswood <frank@kingswood-consulting.co.uk>
+ * Copyright 2007, Werner Cornelius <werner <at> cornelius-consult.de>
+ * Copyright 2008, Tollef Fog Heen <tfheen@err.no>
  *
  * ch341.c implements a serial port driver for the Winchiphead CH341.
  *
@@ -24,6 +26,36 @@
 #define DEFAULT_BAUD_RATE 2400
 #define DEFAULT_TIMEOUT   1000
 
+/* flags for IO-Bits */
+#define CH341_BIT_RTS (1 << 6)
+#define CH341_BIT_DTR (1 << 5)
+
+/******************************/
+/* interrupt pipe definitions */
+/******************************/
+/* always 4 interrupt bytes */
+/* first irq byte normally 0x08 */
+/* second irq byte base 0x7d + below */
+/* third irq byte base 0x94 + below */
+/* fourth irq byte normally 0xee */
+
+/* second interrupt byte */
+#define ...
From: Alan Cox
Date: Sunday, September 21, 2008 - 7:14 am

Can you really get a speed below 1 baud ?

If there is a hangup requested (c_cflag & CBAUD) == B0 then you don't
want to overwrite the baud rate but that you handled in set_termios

close should never be called with tty == NULL unless there is some kind

Open on the other hand is currently called with tty = NULL in the case it
is used as a console device (ugly and something I want to fix but it

set_termios should never be called with tty == NULL nowdays so that test

This could race another set_handshake ? I'm not sure it matters and I'd
suggest that stuff gets fixed after this is submitted separately



--

From: Tollef Fog Heen
Date: Sunday, January 4, 2009 - 3:19 am

]] Alan Cox 

| Some niggles but this is a big improvement to the code.

Thanks.  New patch incoming RSN.

| >  static int ch341_set_baudrate(struct usb_device *dev,
| > +			      struct tty_struct *tty,
| >  			      struct ch341_private *priv)
| > +	baud = CH341_BAUDBASE_FACTOR / t1;
| > +
| > +	if (baud && tty)
| > +		tty_encode_baud_rate(tty, baud, baud);
| 
| Can you really get a speed below 1 baud ?

Unsure what you mean here?  Why would you ever end up with baudrates
below 1?

| > +	control = priv->line_control;
| > +	spin_unlock_irqrestore(&priv->lock, flags);
| > +
| > +	return ch341_set_handshake(port->serial->dev, control);
| > +}
| 
| This could race another set_handshake ? I'm not sure it matters and I'd
| suggest that stuff gets fixed after this is submitted separately

What's the easiest way to fix this?

-- 
Tollef Fog Heen
UNIX is user friendly, it's just picky about who its friends are
--

From: Alan Cox
Date: Sunday, January 4, 2009 - 5:19 am

It can sleep so probably all the cases where handshake lines are updated
need to use a mutex to protect them. That will depend if any occur in the
IRQ paths in which case it gets a lot trickier.
--

Previous thread: none

Next thread: [PATCH] arch/powerpc/platforms/powermac/pic.c: move of_node_put by Julia Lawall on Sunday, September 21, 2008 - 4:01 am. (2 messages)