Commit 7e12a6fc authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

Revert "usb: pl2303: do not round to the next nearest standard baud rate for...

Revert "usb: pl2303: do not round to the next nearest standard baud rate for the divisor based baud rate encoding method"

This reverts commit 75417d9f.

Revert all of the pl2303 changes that went into 3.12-rc1 and -rc2 as
they cause regressions on some versions of the chip.  This will all be
revisited for later kernel versions when we can figure out how to handle
this in a way that does not break working devices.
Reported-by: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
Cc: Frank Schäfer <fschaefer.oss@googlemail.com>
Acked-by: default avatarJohan Hovold <jhovold@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 336b9daf
...@@ -273,28 +273,26 @@ static void pl2303_encode_baudrate(struct tty_struct *tty, ...@@ -273,28 +273,26 @@ static void pl2303_encode_baudrate(struct tty_struct *tty,
struct usb_serial_port *port, struct usb_serial_port *port,
u8 buf[4]) u8 buf[4])
{ {
const int baud_sup[] = { 75, 150, 300, 600, 1200, 1800, 2400, 3600,
4800, 7200, 9600, 14400, 19200, 28800, 38400,
57600, 115200, 230400, 460800, 500000, 614400,
921600, 1228800, 2457600, 3000000, 6000000 };
struct usb_serial *serial = port->serial; struct usb_serial *serial = port->serial;
struct pl2303_serial_private *spriv = usb_get_serial_data(serial); struct pl2303_serial_private *spriv = usb_get_serial_data(serial);
int baud; int baud;
int i;
/*
* NOTE: Only the values defined in baud_sup are supported!
* => if unsupported values are set, the PL2303 seems to use
* 9600 baud (at least my PL2303X always does)
*/
baud = tty_get_baud_rate(tty); baud = tty_get_baud_rate(tty);
dev_dbg(&port->dev, "baud requested = %d\n", baud); dev_dbg(&port->dev, "baud requested = %d\n", baud);
if (!baud) if (!baud)
return; return;
if (spriv->type != HX || baud <= 115200) {
/*
* NOTE: Only the values defined in baud_sup are supported !
* => if unsupported values are set, the PL2303 seems to
* use 9600 baud (at least my PL2303X always does)
*/
const int baud_sup[] = { 75, 150, 300, 600, 1200, 1800, 2400,
3600, 4800, 7200, 9600, 14400, 19200,
28800, 38400, 57600, 115200, 230400,
460800, 500000, 614400, 921600,
1228800, 2457600, 3000000, 6000000 };
int i;
/* Set baudrate to nearest supported value */ /* Set baudrate to nearest supported value */
for (i = 0; i < ARRAY_SIZE(baud_sup); ++i) { for (i = 0; i < ARRAY_SIZE(baud_sup); ++i) {
if (baud_sup[i] > baud) if (baud_sup[i] > baud)
...@@ -303,8 +301,7 @@ static void pl2303_encode_baudrate(struct tty_struct *tty, ...@@ -303,8 +301,7 @@ static void pl2303_encode_baudrate(struct tty_struct *tty,
if (i == ARRAY_SIZE(baud_sup)) if (i == ARRAY_SIZE(baud_sup))
baud = baud_sup[i - 1]; baud = baud_sup[i - 1];
else if (i > 0 else if (i > 0 && (baud_sup[i] - baud) > (baud - baud_sup[i - 1]))
&& (baud_sup[i] - baud) > (baud - baud_sup[i - 1]))
baud = baud_sup[i - 1]; baud = baud_sup[i - 1];
else else
baud = baud_sup[i]; baud = baud_sup[i];
...@@ -313,6 +310,7 @@ static void pl2303_encode_baudrate(struct tty_struct *tty, ...@@ -313,6 +310,7 @@ static void pl2303_encode_baudrate(struct tty_struct *tty,
if (spriv->type != HX) if (spriv->type != HX)
baud = min_t(int, baud, 1228800); baud = min_t(int, baud, 1228800);
if (spriv->type != HX || baud <= 115200) {
/* Direct (standard) baud rate encoding method */ /* Direct (standard) baud rate encoding method */
put_unaligned_le32(baud, buf); put_unaligned_le32(baud, buf);
} else { } else {
...@@ -333,17 +331,10 @@ static void pl2303_encode_baudrate(struct tty_struct *tty, ...@@ -333,17 +331,10 @@ static void pl2303_encode_baudrate(struct tty_struct *tty,
* => 8 < B < 16: device seems to work not properly * => 8 < B < 16: device seems to work not properly
* => B <= 8: device uses the max. value B = 512 instead * => B <= 8: device uses the max. value B = 512 instead
*/ */
unsigned int A, B;
/* Respect the specified baud rate limits */
baud = max_t(int, baud, 75);
if (spriv->type == HX)
baud = min_t(int, baud, 6000000);
else
baud = min_t(int, baud, 1228800);
/* Determine factors A and B */ /* Determine factors A and B */
A = 0; unsigned int A = 0;
B = 12000000 * 32 / baud; /* 12MHz */ unsigned int B = 12000000 * 32 / baud; /* 12MHz */
B <<= 1; /* Add one bit for rounding */ B <<= 1; /* Add one bit for rounding */
while (B > (512 << 1) && A <= 14) { while (B > (512 << 1) && A <= 14) {
A += 2; A += 2;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment