Commit 399aa9a75ad372b301e5050f3653a297a767fdc4

Authored by Lauri Hintsala
Committed by Johan Hovold
1 parent 69e273c0b0

USB: pl2303: use divisors for unsupported baud rates

Use direct method for supported baud rates, otherwise use divisors.
Limit baud rate to 12 Mbaud with HX type.

This change has been tested to work with PL-2303HX at 115200, 500000,
1000000, 2000000, 2500000, 3000000 and 4000000 baud rates.

Signed-off-by: Lauri Hintsala <lauri.hintsala@bluegiga.com>
Signed-off-by: Johan Hovold <johan@kernel.org>

Showing 1 changed file with 7 additions and 6 deletions Side-by-side Diff

drivers/usb/serial/pl2303.c
... ... @@ -162,6 +162,9 @@
162 162 .max_baud_rate = 1228800,
163 163 .quirks = PL2303_QUIRK_LEGACY,
164 164 },
  165 + [TYPE_HX] = {
  166 + .max_baud_rate = 12000000,
  167 + },
165 168 };
166 169  
167 170 static int pl2303_vendor_read(struct usb_serial *serial, u16 value,
168 171  
169 172  
... ... @@ -395,16 +398,14 @@
395 398 if (spriv->type->max_baud_rate)
396 399 baud = min_t(speed_t, baud, spriv->type->max_baud_rate);
397 400 /*
398   - * Set baud rate to nearest supported value.
399   - *
400   - * NOTE: Baud rate 500k can only be set using divisors.
  401 + * Use direct method for supported baud rates, otherwise use divisors.
401 402 */
402 403 baud_sup = pl2303_get_supported_baud_rate(baud);
403 404  
404   - if (baud == 500000)
405   - baud = pl2303_encode_baud_rate_divisor(buf, baud);
  405 + if (baud == baud_sup)
  406 + baud = pl2303_encode_baud_rate_direct(buf, baud);
406 407 else
407   - baud = pl2303_encode_baud_rate_direct(buf, baud_sup);
  408 + baud = pl2303_encode_baud_rate_divisor(buf, baud);
408 409  
409 410 /* Save resulting baud rate */
410 411 tty_encode_baud_rate(tty, baud, baud);