aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/pl2303.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/serial/pl2303.c')
-rw-r--r--drivers/usb/serial/pl2303.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index 30461fcc2206..1d33260de014 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -91,6 +91,7 @@ static const struct usb_device_id id_table[] = {
91 { USB_DEVICE(SONY_VENDOR_ID, SONY_QN3USB_PRODUCT_ID) }, 91 { USB_DEVICE(SONY_VENDOR_ID, SONY_QN3USB_PRODUCT_ID) },
92 { USB_DEVICE(SANWA_VENDOR_ID, SANWA_PRODUCT_ID) }, 92 { USB_DEVICE(SANWA_VENDOR_ID, SANWA_PRODUCT_ID) },
93 { USB_DEVICE(ADLINK_VENDOR_ID, ADLINK_ND6530_PRODUCT_ID) }, 93 { USB_DEVICE(ADLINK_VENDOR_ID, ADLINK_ND6530_PRODUCT_ID) },
94 { USB_DEVICE(WINCHIPHEAD_VENDOR_ID, WINCHIPHEAD_USBSER_PRODUCT_ID) },
94 { } /* Terminating entry */ 95 { } /* Terminating entry */
95}; 96};
96 97
@@ -342,10 +343,28 @@ static void pl2303_set_termios(struct tty_struct *tty,
342 baud = 6000000; 343 baud = 6000000;
343 } 344 }
344 dbg("%s - baud set = %d", __func__, baud); 345 dbg("%s - baud set = %d", __func__, baud);
345 buf[0] = baud & 0xff; 346 if (baud <= 115200) {
346 buf[1] = (baud >> 8) & 0xff; 347 buf[0] = baud & 0xff;
347 buf[2] = (baud >> 16) & 0xff; 348 buf[1] = (baud >> 8) & 0xff;
348 buf[3] = (baud >> 24) & 0xff; 349 buf[2] = (baud >> 16) & 0xff;
350 buf[3] = (baud >> 24) & 0xff;
351 } else {
352 /* apparently the formula for higher speeds is:
353 * baudrate = 12M * 32 / (2^buf[1]) / buf[0]
354 */
355 unsigned tmp = 12*1000*1000*32 / baud;
356 buf[3] = 0x80;
357 buf[2] = 0;
358 buf[1] = (tmp >= 256);
359 while (tmp >= 256) {
360 tmp >>= 2;
361 buf[1] <<= 1;
362 }
363 if (tmp > 256) {
364 tmp %= 256;
365 }
366 buf[0] = tmp;
367 }
349 } 368 }
350 369
351 /* For reference buf[4]=0 is 1 stop bits */ 370 /* For reference buf[4]=0 is 1 stop bits */