diff options
author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-11-01 12:16:09 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-11-01 12:16:09 -0400 |
commit | e8bbd5c42b65b662756d67290a5c4dcda1abc596 (patch) | |
tree | 86c8b393817a19dcc0832e5fdfe858a9a48a3c8e /drivers | |
parent | 09169197c9f5e3b42f0c83c6d7071b3e9c94153e (diff) |
Revert "pl2303: improve the chip type detection/distinction"
This reverts commit 034d1527adebd302115c87ef343497a889638275.
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')
-rw-r--r-- | drivers/usb/serial/pl2303.c | 95 |
1 files changed, 23 insertions, 72 deletions
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c index e7a84f0f5179..409000a836dd 100644 --- a/drivers/usb/serial/pl2303.c +++ b/drivers/usb/serial/pl2303.c | |||
@@ -134,17 +134,10 @@ MODULE_DEVICE_TABLE(usb, id_table); | |||
134 | 134 | ||
135 | 135 | ||
136 | enum pl2303_type { | 136 | enum pl2303_type { |
137 | type_0, /* H version ? */ | 137 | type_0, /* don't know the difference between type 0 and */ |
138 | type_1, /* H version ? */ | 138 | type_1, /* type 1, until someone from prolific tells us... */ |
139 | HX_TA, /* HX(A) / X(A) / TA version */ /* TODO: improve */ | 139 | HX, /* HX version of the pl2303 chip */ |
140 | HXD_EA_RA_SA, /* HXD / EA / RA / SA version */ /* TODO: improve */ | ||
141 | TB, /* TB version */ | ||
142 | }; | 140 | }; |
143 | /* | ||
144 | * NOTE: don't know the difference between type 0 and type 1, | ||
145 | * until someone from Prolific tells us... | ||
146 | * TODO: distinguish between X/HX, TA and HXD, EA, RA, SA variants | ||
147 | */ | ||
148 | 141 | ||
149 | struct pl2303_serial_private { | 142 | struct pl2303_serial_private { |
150 | enum pl2303_type type; | 143 | enum pl2303_type type; |
@@ -201,28 +194,8 @@ static int pl2303_startup(struct usb_serial *serial) | |||
201 | type = type_0; | 194 | type = type_0; |
202 | type_str = "type_0"; | 195 | type_str = "type_0"; |
203 | } else if (serial->dev->descriptor.bMaxPacketSize0 == 0x40) { | 196 | } else if (serial->dev->descriptor.bMaxPacketSize0 == 0x40) { |
204 | /* | 197 | type = HX; |
205 | * NOTE: The bcdDevice version is the only difference between | 198 | type_str = "X/HX"; |
206 | * the device descriptors of the X/HX, HXD, EA, RA, SA, TA, TB | ||
207 | */ | ||
208 | if (le16_to_cpu(serial->dev->descriptor.bcdDevice) == 0x300) { | ||
209 | type = HX_TA; | ||
210 | type_str = "X/HX/TA"; | ||
211 | } else if (le16_to_cpu(serial->dev->descriptor.bcdDevice) | ||
212 | == 0x400) { | ||
213 | type = HXD_EA_RA_SA; | ||
214 | type_str = "HXD/EA/RA/SA"; | ||
215 | } else if (le16_to_cpu(serial->dev->descriptor.bcdDevice) | ||
216 | == 0x500) { | ||
217 | type = TB; | ||
218 | type_str = "TB"; | ||
219 | } else { | ||
220 | dev_info(&serial->interface->dev, | ||
221 | "unknown/unsupported device type\n"); | ||
222 | kfree(spriv); | ||
223 | kfree(buf); | ||
224 | return -ENODEV; | ||
225 | } | ||
226 | } else if (serial->dev->descriptor.bDeviceClass == 0x00 | 199 | } else if (serial->dev->descriptor.bDeviceClass == 0x00 |
227 | || serial->dev->descriptor.bDeviceClass == 0xFF) { | 200 | || serial->dev->descriptor.bDeviceClass == 0xFF) { |
228 | type = type_1; | 201 | type = type_1; |
@@ -243,10 +216,10 @@ static int pl2303_startup(struct usb_serial *serial) | |||
243 | pl2303_vendor_read(0x8383, 0, serial, buf); | 216 | pl2303_vendor_read(0x8383, 0, serial, buf); |
244 | pl2303_vendor_write(0, 1, serial); | 217 | pl2303_vendor_write(0, 1, serial); |
245 | pl2303_vendor_write(1, 0, serial); | 218 | pl2303_vendor_write(1, 0, serial); |
246 | if (type == type_0 || type == type_1) | 219 | if (type == HX) |
247 | pl2303_vendor_write(2, 0x24, serial); | ||
248 | else | ||
249 | pl2303_vendor_write(2, 0x44, serial); | 220 | pl2303_vendor_write(2, 0x44, serial); |
221 | else | ||
222 | pl2303_vendor_write(2, 0x24, serial); | ||
250 | 223 | ||
251 | kfree(buf); | 224 | kfree(buf); |
252 | return 0; | 225 | return 0; |
@@ -311,19 +284,12 @@ static int pl2303_baudrate_encode_direct(int baud, enum pl2303_type type, | |||
311 | const int baud_sup[] = { 75, 150, 300, 600, 1200, 1800, 2400, 3600, | 284 | const int baud_sup[] = { 75, 150, 300, 600, 1200, 1800, 2400, 3600, |
312 | 4800, 7200, 9600, 14400, 19200, 28800, 38400, | 285 | 4800, 7200, 9600, 14400, 19200, 28800, 38400, |
313 | 57600, 115200, 230400, 460800, 614400, 921600, | 286 | 57600, 115200, 230400, 460800, 614400, 921600, |
314 | 1228800, 2457600, 3000000, 6000000, 12000000 }; | 287 | 1228800, 2457600, 3000000, 6000000 }; |
315 | /* | 288 | /* |
316 | * NOTE: With the exception of type_0/1 devices, the following | 289 | * NOTE: The PL2303HX (tested with rev. 3A) also supports the following |
317 | * additional baud rates are supported (tested with HX rev. 3A only): | 290 | * baud rates: 128000, 134400, 161280, 201600, 268800, 403200, 806400. |
318 | * 110*, 56000*, 128000, 134400, 161280, 201600, 256000*, 268800, | 291 | * As long as we are not using this encoding method for them, there is |
319 | * 403200, 806400. (*: not HX) | 292 | * no point in complicating the code to support them. |
320 | * | ||
321 | * Maximum values: HXD, TB: 12000000; HX, TA: 6000000; | ||
322 | * type_0+1: 1228800; RA: 921600; SA: 115200 | ||
323 | * | ||
324 | * As long as we are not using this encoding method for anything else | ||
325 | * than the type_0+1 and HX chips, there is no point in complicating | ||
326 | * the code to support them. | ||
327 | */ | 293 | */ |
328 | int i; | 294 | int i; |
329 | 295 | ||
@@ -338,14 +304,8 @@ static int pl2303_baudrate_encode_direct(int baud, enum pl2303_type type, | |||
338 | baud = baud_sup[i - 1]; | 304 | baud = baud_sup[i - 1]; |
339 | else | 305 | else |
340 | baud = baud_sup[i]; | 306 | baud = baud_sup[i]; |
341 | /* Respect the chip type specific baud rate limits */ | 307 | /* type_0, type_1 only support up to 1228800 baud */ |
342 | /* | 308 | if (type != HX) |
343 | * FIXME: as long as we don't know how to distinguish between the | ||
344 | * HXD, EA, RA, and SA chip variants, allow the max. value of 12M. | ||
345 | */ | ||
346 | if (type == HX_TA) | ||
347 | baud = min_t(int, baud, 6000000); | ||
348 | else if (type == type_0 || type == type_1) | ||
349 | baud = min_t(int, baud, 1228800); | 309 | baud = min_t(int, baud, 1228800); |
350 | /* Direct (standard) baud rate encoding method */ | 310 | /* Direct (standard) baud rate encoding method */ |
351 | put_unaligned_le32(baud, buf); | 311 | put_unaligned_le32(baud, buf); |
@@ -384,19 +344,10 @@ static int pl2303_baudrate_encode_divisor(int baud, enum pl2303_type type, | |||
384 | * Baud rates smaller than the specified 75 baud are definitely working | 344 | * Baud rates smaller than the specified 75 baud are definitely working |
385 | * fine. | 345 | * fine. |
386 | */ | 346 | */ |
387 | if (type == type_0 || type == type_1) | 347 | if (type == HX) |
388 | baud = min_t(int, baud, 1228800 * 1.1); | ||
389 | else if (type == HX_TA) | ||
390 | baud = min_t(int, baud, 6000000 * 1.1); | 348 | baud = min_t(int, baud, 6000000 * 1.1); |
391 | else if (type == HXD_EA_RA_SA) | 349 | else |
392 | /* HXD, EA: 12Mbps; RA: 1Mbps; SA: 115200 bps */ | 350 | baud = min_t(int, baud, 1228800 * 1.1); |
393 | /* | ||
394 | * FIXME: as long as we don't know how to distinguish between | ||
395 | * these chip variants, allow the max. of these values | ||
396 | */ | ||
397 | baud = min_t(int, baud, 12000000 * 1.1); | ||
398 | else if (type == TB) | ||
399 | baud = min_t(int, baud, 12000000 * 1.1); | ||
400 | /* Determine factors A and B */ | 351 | /* Determine factors A and B */ |
401 | A = 0; | 352 | A = 0; |
402 | B = 12000000 * 32 / baud; /* 12MHz */ | 353 | B = 12000000 * 32 / baud; /* 12MHz */ |
@@ -460,7 +411,7 @@ static void pl2303_encode_baudrate(struct tty_struct *tty, | |||
460 | * the device likely uses the same baud rate generator for both methods | 411 | * the device likely uses the same baud rate generator for both methods |
461 | * so that there is likley no difference. | 412 | * so that there is likley no difference. |
462 | */ | 413 | */ |
463 | if (type == type_0 || type == type_1) | 414 | if (type != HX) |
464 | baud = pl2303_baudrate_encode_direct(baud, type, buf); | 415 | baud = pl2303_baudrate_encode_direct(baud, type, buf); |
465 | else | 416 | else |
466 | baud = pl2303_baudrate_encode_divisor(baud, type, buf); | 417 | baud = pl2303_baudrate_encode_divisor(baud, type, buf); |
@@ -598,10 +549,10 @@ static void pl2303_set_termios(struct tty_struct *tty, | |||
598 | dev_dbg(&port->dev, "0xa1:0x21:0:0 %d - %7ph\n", i, buf); | 549 | dev_dbg(&port->dev, "0xa1:0x21:0:0 %d - %7ph\n", i, buf); |
599 | 550 | ||
600 | if (C_CRTSCTS(tty)) { | 551 | if (C_CRTSCTS(tty)) { |
601 | if (spriv->type == type_0 || spriv->type == type_1) | 552 | if (spriv->type == HX) |
602 | pl2303_vendor_write(0x0, 0x41, serial); | ||
603 | else | ||
604 | pl2303_vendor_write(0x0, 0x61, serial); | 553 | pl2303_vendor_write(0x0, 0x61, serial); |
554 | else | ||
555 | pl2303_vendor_write(0x0, 0x41, serial); | ||
605 | } else { | 556 | } else { |
606 | pl2303_vendor_write(0x0, 0x0, serial); | 557 | pl2303_vendor_write(0x0, 0x0, serial); |
607 | } | 558 | } |
@@ -638,7 +589,7 @@ static int pl2303_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
638 | struct pl2303_serial_private *spriv = usb_get_serial_data(serial); | 589 | struct pl2303_serial_private *spriv = usb_get_serial_data(serial); |
639 | int result; | 590 | int result; |
640 | 591 | ||
641 | if (spriv->type == type_0 || spriv->type == type_1) { | 592 | if (spriv->type != HX) { |
642 | usb_clear_halt(serial->dev, port->write_urb->pipe); | 593 | usb_clear_halt(serial->dev, port->write_urb->pipe); |
643 | usb_clear_halt(serial->dev, port->read_urb->pipe); | 594 | usb_clear_halt(serial->dev, port->read_urb->pipe); |
644 | } else { | 595 | } else { |