diff options
author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-11-01 12:19:45 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-11-01 12:19:45 -0400 |
commit | 1796a228762cd0b86e14d6d4a3de9ecfe65b3b8d (patch) | |
tree | 3b96653c94f872805963bd9e7afaed8b3ed8e1a0 /drivers/usb | |
parent | 7e12a6fcbf266eb0d5b19761f91b2964ad18e371 (diff) |
Revert "usb: pl2303: fix+improve the divsor based baud rate encoding method"
This reverts commit 57ce61aad748ceaa08c859da04043ad7dae7c15e.
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: Mika Westerberg <mika.westerberg@linux.intel.com>
Cc: Frank Schäfer <fschaefer.oss@googlemail.com>
Acked-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb')
-rw-r--r-- | drivers/usb/serial/pl2303.c | 62 |
1 files changed, 10 insertions, 52 deletions
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c index b93b3b30dec5..244820193e10 100644 --- a/drivers/usb/serial/pl2303.c +++ b/drivers/usb/serial/pl2303.c | |||
@@ -4,11 +4,6 @@ | |||
4 | * Copyright (C) 2001-2007 Greg Kroah-Hartman (greg@kroah.com) | 4 | * Copyright (C) 2001-2007 Greg Kroah-Hartman (greg@kroah.com) |
5 | * Copyright (C) 2003 IBM Corp. | 5 | * Copyright (C) 2003 IBM Corp. |
6 | * | 6 | * |
7 | * Copyright (C) 2009, 2013 Frank Schäfer <fschaefer.oss@googlemail.com> | ||
8 | * - fixes, improvements and documentation for the baud rate encoding methods | ||
9 | * Copyright (C) 2013 Reinhard Max <max@suse.de> | ||
10 | * - fixes and improvements for the divisor based baud rate encoding method | ||
11 | * | ||
12 | * Original driver for 2.2.x by anonymous | 7 | * Original driver for 2.2.x by anonymous |
13 | * | 8 | * |
14 | * This program is free software; you can redistribute it and/or | 9 | * This program is free software; you can redistribute it and/or |
@@ -315,58 +310,21 @@ static void pl2303_encode_baudrate(struct tty_struct *tty, | |||
315 | put_unaligned_le32(baud, buf); | 310 | put_unaligned_le32(baud, buf); |
316 | } else { | 311 | } else { |
317 | /* | 312 | /* |
318 | * Divisor based baud rate encoding method | ||
319 | * | ||
320 | * NOTE: it's not clear if the type_0/1 chips | 313 | * NOTE: it's not clear if the type_0/1 chips |
321 | * support this method | 314 | * support this method |
322 | * | 315 | * |
323 | * divisor = 12MHz * 32 / baudrate = 2^A * B | 316 | * Apparently the formula for higher speeds is: |
324 | * | 317 | * baudrate = 12M * 32 / (2^buf[1]) / buf[0] |
325 | * with | ||
326 | * | ||
327 | * A = buf[1] & 0x0e | ||
328 | * B = buf[0] + (buf[1] & 0x01) << 8 | ||
329 | * | ||
330 | * Special cases: | ||
331 | * => 8 < B < 16: device seems to work not properly | ||
332 | * => B <= 8: device uses the max. value B = 512 instead | ||
333 | */ | 318 | */ |
334 | 319 | unsigned tmp = 12000000 * 32 / baud; | |
335 | /* Determine factors A and B */ | 320 | buf[3] = 0x80; |
336 | unsigned int A = 0; | ||
337 | unsigned int B = 12000000 * 32 / baud; /* 12MHz */ | ||
338 | B <<= 1; /* Add one bit for rounding */ | ||
339 | while (B > (512 << 1) && A <= 14) { | ||
340 | A += 2; | ||
341 | B >>= 2; | ||
342 | } | ||
343 | if (A > 14) { /* max. divisor = min. baudrate reached */ | ||
344 | A = 14; | ||
345 | B = 512; | ||
346 | /* => ~45.78 baud */ | ||
347 | } else { | ||
348 | B = (B + 1) >> 1; /* Round the last bit */ | ||
349 | } | ||
350 | /* Handle special cases */ | ||
351 | if (B == 512) | ||
352 | B = 0; /* also: 1 to 8 */ | ||
353 | else if (B < 16) | ||
354 | /* | ||
355 | * NOTE: With the current algorithm this happens | ||
356 | * only for A=0 and means that the min. divisor | ||
357 | * (respectively: the max. baudrate) is reached. | ||
358 | */ | ||
359 | B = 16; /* => 24 MBaud */ | ||
360 | /* Encode the baud rate */ | ||
361 | buf[3] = 0x80; /* Select divisor encoding method */ | ||
362 | buf[2] = 0; | 321 | buf[2] = 0; |
363 | buf[1] = (A & 0x0e); /* A */ | 322 | buf[1] = (tmp >= 256); |
364 | buf[1] |= ((B & 0x100) >> 8); /* MSB of B */ | 323 | while (tmp >= 256) { |
365 | buf[0] = B & 0xff; /* 8 LSBs of B */ | 324 | tmp >>= 2; |
366 | /* Calculate the actual/resulting baud rate */ | 325 | buf[1] <<= 1; |
367 | if (B <= 8) | 326 | } |
368 | B = 512; | 327 | buf[0] = tmp; |
369 | baud = 12000000 * 32 / ((1 << A) * B); | ||
370 | } | 328 | } |
371 | 329 | ||
372 | /* Save resulting baud rate */ | 330 | /* Save resulting baud rate */ |