From 336f75a3f37aa9d2941af7682812bfc871f66b01 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Tue, 31 Jan 2012 13:17:58 -0800 Subject: [PATCH] 3.0-stable patches added patches: usb-cp210x-allow-more-baud-rates-above-1mbaud.patch usb-cp210x-call-generic-open-last-in-open.patch usb-cp210x-clean-up-refactor-and-document-speed-handling.patch usb-cp210x-do-not-map-baud-rates-to-b0.patch usb-cp210x-fix-cp2104-baudrate-usage.patch usb-cp210x-fix-up-set_termios-variables.patch usb-cp210x-initialise-baud-rate-at-open.patch usb-serial-cp210x-added-usb-id-for-the-link-instruments-mso-19.patch --- queue-3.0/series | 8 ++ ...x-allow-more-baud-rates-above-1mbaud.patch | 46 +++++++ ...p210x-call-generic-open-last-in-open.patch | 45 +++++++ ...refactor-and-document-speed-handling.patch | 117 ++++++++++++++++++ ...b-cp210x-do-not-map-baud-rates-to-b0.patch | 32 +++++ ...usb-cp210x-fix-cp2104-baudrate-usage.patch | 76 ++++++++++++ ...-cp210x-fix-up-set_termios-variables.patch | 42 +++++++ ...-cp210x-initialise-baud-rate-at-open.patch | 33 +++++ ...b-id-for-the-link-instruments-mso-19.patch | 29 +++++ 9 files changed, 428 insertions(+) create mode 100644 queue-3.0/usb-cp210x-allow-more-baud-rates-above-1mbaud.patch create mode 100644 queue-3.0/usb-cp210x-call-generic-open-last-in-open.patch create mode 100644 queue-3.0/usb-cp210x-clean-up-refactor-and-document-speed-handling.patch create mode 100644 queue-3.0/usb-cp210x-do-not-map-baud-rates-to-b0.patch create mode 100644 queue-3.0/usb-cp210x-fix-cp2104-baudrate-usage.patch create mode 100644 queue-3.0/usb-cp210x-fix-up-set_termios-variables.patch create mode 100644 queue-3.0/usb-cp210x-initialise-baud-rate-at-open.patch create mode 100644 queue-3.0/usb-serial-cp210x-added-usb-id-for-the-link-instruments-mso-19.patch diff --git a/queue-3.0/series b/queue-3.0/series index 31ddf7d7fae..f4f55ab13fa 100644 --- a/queue-3.0/series +++ b/queue-3.0/series @@ -55,3 +55,11 @@ net-bpf_jit-fix-divide-by-0-generation.patch rds-make-rds_sock_lock-bh-rather-than-irq-safe.patch tcp-fix-tcp_trim_head-to-adjust-segment-count-with-skb-mss.patch tcp-md5-using-remote-adress-for-md5-lookup-in-rst-packet.patch +usb-serial-cp210x-added-usb-id-for-the-link-instruments-mso-19.patch +usb-cp210x-call-generic-open-last-in-open.patch +usb-cp210x-fix-cp2104-baudrate-usage.patch +usb-cp210x-do-not-map-baud-rates-to-b0.patch +usb-cp210x-fix-up-set_termios-variables.patch +usb-cp210x-clean-up-refactor-and-document-speed-handling.patch +usb-cp210x-initialise-baud-rate-at-open.patch +usb-cp210x-allow-more-baud-rates-above-1mbaud.patch diff --git a/queue-3.0/usb-cp210x-allow-more-baud-rates-above-1mbaud.patch b/queue-3.0/usb-cp210x-allow-more-baud-rates-above-1mbaud.patch new file mode 100644 index 00000000000..3d24b9ef177 --- /dev/null +++ b/queue-3.0/usb-cp210x-allow-more-baud-rates-above-1mbaud.patch @@ -0,0 +1,46 @@ +From d1620ca9e7bb0030068c3b45b653defde8839dac Mon Sep 17 00:00:00 2001 +From: Johan Hovold +Date: Mon, 16 Jan 2012 00:36:53 +0100 +Subject: USB: cp210x: allow more baud rates above 1Mbaud + +From: Johan Hovold + +commit d1620ca9e7bb0030068c3b45b653defde8839dac upstream. + +Allow more baud rates to be set in [1M,2M] baud. + +Signed-off-by: Johan Hovold +Cc: Preston Fick +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/usb/serial/cp210x.c | 11 ++++++----- + 1 file changed, 6 insertions(+), 5 deletions(-) + +--- a/drivers/usb/serial/cp210x.c ++++ b/drivers/usb/serial/cp210x.c +@@ -388,10 +388,10 @@ static unsigned int cp210x_quantise_baud + else if (baud <= 491520) baud = 460800; + else if (baud <= 567138) baud = 500000; + else if (baud <= 670254) baud = 576000; +- else if (baud <= 1053257) baud = 921600; +- else if (baud <= 1474560) baud = 1228800; +- else if (baud <= 2457600) baud = 1843200; +- else baud = 3686400; ++ else if (baud < 1000000) ++ baud = 921600; ++ else if (baud > 2000000) ++ baud = 2000000; + return baud; + } + +@@ -611,7 +611,8 @@ static void cp210x_change_speed(struct t + + baud = tty->termios->c_ospeed; + +- /* This maps the requested rate to a rate valid on cp2102 or cp2103. ++ /* This maps the requested rate to a rate valid on cp2102 or cp2103, ++ * or to an arbitrary rate in [1M,2M]. + * + * NOTE: B0 is not implemented. + */ diff --git a/queue-3.0/usb-cp210x-call-generic-open-last-in-open.patch b/queue-3.0/usb-cp210x-call-generic-open-last-in-open.patch new file mode 100644 index 00000000000..0d6c930e75d --- /dev/null +++ b/queue-3.0/usb-cp210x-call-generic-open-last-in-open.patch @@ -0,0 +1,45 @@ +From 55b2afbb92ad92e9f6b0aa4354eb1c94589280c3 Mon Sep 17 00:00:00 2001 +From: Johan Hovold +Date: Mon, 16 Jan 2012 00:36:48 +0100 +Subject: USB: cp210x: call generic open last in open + +From: Johan Hovold + +commit 55b2afbb92ad92e9f6b0aa4354eb1c94589280c3 upstream. + +Make sure port is fully initialised before calling generic open. + +Signed-off-by: Johan Hovold +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/usb/serial/cp210x.c | 9 ++------- + 1 file changed, 2 insertions(+), 7 deletions(-) + +--- a/drivers/usb/serial/cp210x.c ++++ b/drivers/usb/serial/cp210x.c +@@ -393,8 +393,6 @@ static unsigned int cp210x_quantise_baud + + static int cp210x_open(struct tty_struct *tty, struct usb_serial_port *port) + { +- int result; +- + dbg("%s - port %d", __func__, port->number); + + if (cp210x_set_config_single(port, CP210X_IFC_ENABLE, UART_ENABLE)) { +@@ -403,13 +401,10 @@ static int cp210x_open(struct tty_struct + return -EPROTO; + } + +- result = usb_serial_generic_open(tty, port); +- if (result) +- return result; +- + /* Configure the termios structure */ + cp210x_get_termios(tty, port); +- return 0; ++ ++ return usb_serial_generic_open(tty, port); + } + + static void cp210x_close(struct usb_serial_port *port) diff --git a/queue-3.0/usb-cp210x-clean-up-refactor-and-document-speed-handling.patch b/queue-3.0/usb-cp210x-clean-up-refactor-and-document-speed-handling.patch new file mode 100644 index 00000000000..49b7601a472 --- /dev/null +++ b/queue-3.0/usb-cp210x-clean-up-refactor-and-document-speed-handling.patch @@ -0,0 +1,117 @@ +From e5990874e511d5bbca23b3396419480cb2ca0ee7 Mon Sep 17 00:00:00 2001 +From: Johan Hovold +Date: Mon, 16 Jan 2012 00:36:51 +0100 +Subject: USB: cp210x: clean up, refactor and document speed handling + +From: Johan Hovold + +commit e5990874e511d5bbca23b3396419480cb2ca0ee7 upstream. + +Clean up and refactor speed handling. +Document baud rate handling for CP210{1,2,4,5,10}. + +Signed-off-by: Johan Hovold +Cc: Preston Fick +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/usb/serial/cp210x.c | 69 +++++++++++++++++++++++++++++++++++--------- + 1 file changed, 56 insertions(+), 13 deletions(-) + +--- a/drivers/usb/serial/cp210x.c ++++ b/drivers/usb/serial/cp210x.c +@@ -39,6 +39,8 @@ static void cp210x_get_termios(struct tt + struct usb_serial_port *port); + static void cp210x_get_termios_port(struct usb_serial_port *port, + unsigned int *cflagp, unsigned int *baudp); ++static void cp210x_change_speed(struct tty_struct *, struct usb_serial_port *, ++ struct ktermios *); + static void cp210x_set_termios(struct tty_struct *, struct usb_serial_port *, + struct ktermios*); + static int cp210x_tiocmget(struct tty_struct *); +@@ -572,11 +574,62 @@ static void cp210x_get_termios_port(stru + *cflagp = cflag; + } + ++/* ++ * CP2101 supports the following baud rates: ++ * ++ * 300, 600, 1200, 1800, 2400, 4800, 7200, 9600, 14400, 19200, 28800, ++ * 38400, 56000, 57600, 115200, 128000, 230400, 460800, 921600 ++ * ++ * CP2102 and CP2103 support the following additional rates: ++ * ++ * 4000, 16000, 51200, 64000, 76800, 153600, 250000, 256000, 500000, ++ * 576000 ++ * ++ * The device will map a requested rate to a supported one, but the result ++ * of requests for rates greater than 1053257 is undefined (see AN205). ++ * ++ * CP2104, CP2105 and CP2110 support most rates up to 2M, 921k and 1M baud, ++ * respectively, with an error less than 1%. The actual rates are determined ++ * by ++ * ++ * div = round(freq / (2 x prescale x request)) ++ * actual = freq / (2 x prescale x div) ++ * ++ * For CP2104 and CP2105 freq is 48Mhz and prescale is 4 for request <= 365bps ++ * or 1 otherwise. ++ * For CP2110 freq is 24Mhz and prescale is 4 for request <= 300bps or 1 ++ * otherwise. ++ */ ++static void cp210x_change_speed(struct tty_struct *tty, ++ struct usb_serial_port *port, struct ktermios *old_termios) ++{ ++ u32 baud; ++ ++ baud = tty->termios->c_ospeed; ++ ++ /* This maps the requested rate to a rate valid on cp2102 or cp2103. ++ * ++ * NOTE: B0 is not implemented. ++ */ ++ baud = cp210x_quantise_baudrate(baud); ++ ++ dbg("%s - setting baud rate to %u", __func__, baud); ++ if (cp210x_set_config(port, CP210X_SET_BAUDRATE, &baud, ++ sizeof(baud))) { ++ dev_warn(&port->dev, "failed to set baud rate to %u\n", baud); ++ if (old_termios) ++ baud = old_termios->c_ospeed; ++ else ++ baud = 9600; ++ } ++ ++ tty_encode_baud_rate(tty, baud, baud); ++} ++ + static void cp210x_set_termios(struct tty_struct *tty, + struct usb_serial_port *port, struct ktermios *old_termios) + { + unsigned int cflag, old_cflag; +- u32 baud; + unsigned int bits; + unsigned int modem_ctl[4]; + +@@ -588,19 +641,9 @@ static void cp210x_set_termios(struct tt + tty->termios->c_cflag &= ~CMSPAR; + cflag = tty->termios->c_cflag; + old_cflag = old_termios->c_cflag; +- baud = cp210x_quantise_baudrate(tty_get_baud_rate(tty)); + +- /* If the baud rate is to be updated*/ +- if (baud != tty_termios_baud_rate(old_termios) && baud != 0) { +- dbg("%s - Setting baud rate to %d baud", __func__, +- baud); +- if (cp210x_set_config(port, CP210X_SET_BAUDRATE, &baud, sizeof(baud))) { +- dbg("Baud rate requested not supported by device"); +- baud = tty_termios_baud_rate(old_termios); +- } +- } +- /* Report back the resulting baud rate */ +- tty_encode_baud_rate(tty, baud, baud); ++ if (tty->termios->c_ospeed != old_termios->c_ospeed) ++ cp210x_change_speed(tty, port, old_termios); + + /* If the number of data bits is to be updated */ + if ((cflag & CSIZE) != (old_cflag & CSIZE)) { diff --git a/queue-3.0/usb-cp210x-do-not-map-baud-rates-to-b0.patch b/queue-3.0/usb-cp210x-do-not-map-baud-rates-to-b0.patch new file mode 100644 index 00000000000..db1708b2321 --- /dev/null +++ b/queue-3.0/usb-cp210x-do-not-map-baud-rates-to-b0.patch @@ -0,0 +1,32 @@ +From be125d9c8d59560e7cc2d6e2b65c8fd233498ab7 Mon Sep 17 00:00:00 2001 +From: Johan Hovold +Date: Mon, 16 Jan 2012 00:36:50 +0100 +Subject: USB: cp210x: do not map baud rates to B0 + +From: Johan Hovold + +commit be125d9c8d59560e7cc2d6e2b65c8fd233498ab7 upstream. + +We do not implement B0 hangup yet so map low baudrates to 300bps. + +Signed-off-by: Johan Hovold +Cc: Preston Fick +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/usb/serial/cp210x.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- a/drivers/usb/serial/cp210x.c ++++ b/drivers/usb/serial/cp210x.c +@@ -357,8 +357,8 @@ static inline int cp210x_set_config_sing + * Quantises the baud rate as per AN205 Table 1 + */ + static unsigned int cp210x_quantise_baudrate(unsigned int baud) { +- if (baud <= 56) baud = 0; +- else if (baud <= 300) baud = 300; ++ if (baud <= 300) ++ baud = 300; + else if (baud <= 600) baud = 600; + else if (baud <= 1200) baud = 1200; + else if (baud <= 1800) baud = 1800; diff --git a/queue-3.0/usb-cp210x-fix-cp2104-baudrate-usage.patch b/queue-3.0/usb-cp210x-fix-cp2104-baudrate-usage.patch new file mode 100644 index 00000000000..32f4b873bba --- /dev/null +++ b/queue-3.0/usb-cp210x-fix-cp2104-baudrate-usage.patch @@ -0,0 +1,76 @@ +From 7f482fc88ac47662228d6b1f05759797c8936a30 Mon Sep 17 00:00:00 2001 +From: Preston Fick +Date: Mon, 16 Jan 2012 18:14:09 -0600 +Subject: USB: cp210x: fix CP2104 baudrate usage + +From: Preston Fick + +commit 7f482fc88ac47662228d6b1f05759797c8936a30 upstream. + +This fix changes the way baudrates are set on the CP210x devices from +Silicon Labs. The CP2101/2/3 will respond to both a GET/SET_BAUDDIV +command, and GET/SET_BAUDRATE command, while CP2104 and higher devices +only respond to GET/SET_BAUDRATE. The current cp210x.ko driver in +kernel version 3.2.0 only implements the GET/SET_BAUDDIV command. + +This patch implements the two new codes for the GET/SET_BAUDRATE +commands. Then there is a change in the way that the baudrate is +assigned or retrieved. This is done according to the CP210x USB +specification in AN571. This document can be found here: +http://www.silabs.com/pages/DownloadDoc.aspx?FILEURL=Support%20Documents/TechnicalDocs/AN571.pdf&src=DocumentationWebPart + +Sections 5.3/5.4 describe the USB packets for the old baudrate method. +Sections 5.5/5.6 describe the USB packets for the new method. This +patch also implements the new request scheme, and eliminates the +unnecessary baudrate calculations since it uses the "actual baudrate" +method. + +This patch solves the problem reported for the CP2104 in bug 42586, +and also keeps support for all other devices (CP2101/2/3). + +This patchfile is also attached to the bug report on +bugzilla.kernel.org. This patch has been developed and test on the +3.2.0 mainline kernel version under Ubuntu 10.11. + +Signed-off-by: Preston Fick +[duplicate patch also sent by Johan - gregkh] +Signed-off-by: Johan Hovold +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/usb/serial/cp210x.c | 10 ++++------ + 1 file changed, 4 insertions(+), 6 deletions(-) + +--- a/drivers/usb/serial/cp210x.c ++++ b/drivers/usb/serial/cp210x.c +@@ -202,6 +202,8 @@ static struct usb_serial_driver cp210x_d + #define CP210X_EMBED_EVENTS 0x15 + #define CP210X_GET_EVENTSTATE 0x16 + #define CP210X_SET_CHARS 0x19 ++#define CP210X_GET_BAUDRATE 0x1D ++#define CP210X_SET_BAUDRATE 0x1E + + /* CP210X_IFC_ENABLE */ + #define UART_ENABLE 0x0001 +@@ -456,10 +458,7 @@ static void cp210x_get_termios_port(stru + + dbg("%s - port %d", __func__, port->number); + +- cp210x_get_config(port, CP210X_GET_BAUDDIV, &baud, 2); +- /* Convert to baudrate */ +- if (baud) +- baud = cp210x_quantise_baudrate((BAUD_RATE_GEN_FREQ + baud/2)/ baud); ++ cp210x_get_config(port, CP210X_GET_BAUDRATE, &baud, 4); + + dbg("%s - baud rate = %d", __func__, baud); + *baudp = baud; +@@ -594,8 +593,7 @@ static void cp210x_set_termios(struct tt + if (baud != tty_termios_baud_rate(old_termios) && baud != 0) { + dbg("%s - Setting baud rate to %d baud", __func__, + baud); +- if (cp210x_set_config_single(port, CP210X_SET_BAUDDIV, +- ((BAUD_RATE_GEN_FREQ + baud/2) / baud))) { ++ if (cp210x_set_config(port, CP210X_SET_BAUDRATE, &baud, 4)) { + dbg("Baud rate requested not supported by device"); + baud = tty_termios_baud_rate(old_termios); + } diff --git a/queue-3.0/usb-cp210x-fix-up-set_termios-variables.patch b/queue-3.0/usb-cp210x-fix-up-set_termios-variables.patch new file mode 100644 index 00000000000..91d514a8810 --- /dev/null +++ b/queue-3.0/usb-cp210x-fix-up-set_termios-variables.patch @@ -0,0 +1,42 @@ +From 34b76fcaee574017862ea3fa0efdcd77a9d0e57d Mon Sep 17 00:00:00 2001 +From: Johan Hovold +Date: Mon, 16 Jan 2012 00:36:49 +0100 +Subject: USB: cp210x: fix up set_termios variables + +From: Johan Hovold + +commit 34b76fcaee574017862ea3fa0efdcd77a9d0e57d upstream. + +[Based on a patch from Johan, mangled by gregkh to keep things in line] + +Fix up the variable usage in the set_termios call. + +Signed-off-by: Johan Hovold +Cc: Preston Fick +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/usb/serial/cp210x.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +--- a/drivers/usb/serial/cp210x.c ++++ b/drivers/usb/serial/cp210x.c +@@ -576,7 +576,8 @@ static void cp210x_set_termios(struct tt + struct usb_serial_port *port, struct ktermios *old_termios) + { + unsigned int cflag, old_cflag; +- unsigned int baud = 0, bits; ++ u32 baud; ++ unsigned int bits; + unsigned int modem_ctl[4]; + + dbg("%s - port %d", __func__, port->number); +@@ -593,7 +594,7 @@ static void cp210x_set_termios(struct tt + if (baud != tty_termios_baud_rate(old_termios) && baud != 0) { + dbg("%s - Setting baud rate to %d baud", __func__, + baud); +- if (cp210x_set_config(port, CP210X_SET_BAUDRATE, &baud, 4)) { ++ if (cp210x_set_config(port, CP210X_SET_BAUDRATE, &baud, sizeof(baud))) { + dbg("Baud rate requested not supported by device"); + baud = tty_termios_baud_rate(old_termios); + } diff --git a/queue-3.0/usb-cp210x-initialise-baud-rate-at-open.patch b/queue-3.0/usb-cp210x-initialise-baud-rate-at-open.patch new file mode 100644 index 00000000000..af7ff95d53b --- /dev/null +++ b/queue-3.0/usb-cp210x-initialise-baud-rate-at-open.patch @@ -0,0 +1,33 @@ +From cdc32fd6f7b2b2580d7f1b74563f888e4dd9eb8a Mon Sep 17 00:00:00 2001 +From: Johan Hovold +Date: Mon, 16 Jan 2012 00:36:52 +0100 +Subject: USB: cp210x: initialise baud rate at open + +From: Johan Hovold + +commit cdc32fd6f7b2b2580d7f1b74563f888e4dd9eb8a upstream. + +The newer cp2104 devices require the baud rate to be initialised after +power on. Make sure it is set when port is opened. + +Signed-off-by: Johan Hovold +Cc: Preston Fick +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/usb/serial/cp210x.c | 4 ++++ + 1 file changed, 4 insertions(+) + +--- a/drivers/usb/serial/cp210x.c ++++ b/drivers/usb/serial/cp210x.c +@@ -408,6 +408,10 @@ static int cp210x_open(struct tty_struct + /* Configure the termios structure */ + cp210x_get_termios(tty, port); + ++ /* The baud rate must be initialised on cp2104 */ ++ if (tty) ++ cp210x_change_speed(tty, port, NULL); ++ + return usb_serial_generic_open(tty, port); + } + diff --git a/queue-3.0/usb-serial-cp210x-added-usb-id-for-the-link-instruments-mso-19.patch b/queue-3.0/usb-serial-cp210x-added-usb-id-for-the-link-instruments-mso-19.patch new file mode 100644 index 00000000000..fcb25c783df --- /dev/null +++ b/queue-3.0/usb-serial-cp210x-added-usb-id-for-the-link-instruments-mso-19.patch @@ -0,0 +1,29 @@ +From 791b7d7cf69de11275e4dccec2f538eec02cbff6 Mon Sep 17 00:00:00 2001 +From: Renato Caldas +Date: Fri, 6 Jan 2012 15:20:51 +0000 +Subject: USB: serial: CP210x: Added USB-ID for the Link Instruments MSO-19 + +From: Renato Caldas + +commit 791b7d7cf69de11275e4dccec2f538eec02cbff6 upstream. + +This device is a Oscilloscope/Logic Analizer/Pattern Generator/TDR, +using a Silabs CP2103 USB to UART Bridge. + +Signed-off-by: Renato Caldas +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/usb/serial/cp210x.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/drivers/usb/serial/cp210x.c ++++ b/drivers/usb/serial/cp210x.c +@@ -138,6 +138,7 @@ static const struct usb_device_id id_tab + { USB_DEVICE(0x1843, 0x0200) }, /* Vaisala USB Instrument Cable */ + { USB_DEVICE(0x18EF, 0xE00F) }, /* ELV USB-I2C-Interface */ + { USB_DEVICE(0x1BE3, 0x07A6) }, /* WAGO 750-923 USB Service Cable */ ++ { USB_DEVICE(0x3195, 0xF190) }, /* Link Instruments MSO-19 */ + { USB_DEVICE(0x413C, 0x9500) }, /* DW700 GPS USB interface */ + { } /* Terminating Entry */ + }; -- 2.47.3