diff mbox series

USB: serial: pl2303: Modify the detection method of PL2303HXN (TYPE_HXN)

Message ID 20220617133514.357-1-charlesyeh522@gmail.com (mailing list archive)
State New, archived
Headers show
Series USB: serial: pl2303: Modify the detection method of PL2303HXN (TYPE_HXN) | expand

Commit Message

Charles Yeh June 17, 2022, 1:35 p.m. UTC
The setting value of bcdUSB & bcdDevice of PL2303TA is the same as the
setting value of bcdUSB & bcdDevice of a certain chip of PL2303HXN

The setting value of bcdUSB & bcdDevice of PL2303TB is the same as the
setting value of bcdUSB & bcdDevice of a certain chip of PL2303HXN

The PL2303HXN series currently has several chips on sale, and several chips
are about to be sold.
The PL2303HXN cannot use bcdDevice to determine the type one by one.

Signed-off-by: Charles Yeh <charlesyeh522@gmail.com>
---
 drivers/usb/serial/pl2303.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

Comments

Johan Hovold June 20, 2022, 9:39 a.m. UTC | #1
On Fri, Jun 17, 2022 at 09:35:14PM +0800, Charles Yeh wrote:
> The setting value of bcdUSB & bcdDevice of PL2303TA is the same as the
> setting value of bcdUSB & bcdDevice of a certain chip of PL2303HXN

Which ones would that be?

> The setting value of bcdUSB & bcdDevice of PL2303TB is the same as the
> setting value of bcdUSB & bcdDevice of a certain chip of PL2303HXN

Same question here.

> The PL2303HXN series currently has several chips on sale, and several chips
> are about to be sold.
> The PL2303HXN cannot use bcdDevice to determine the type one by one.

Even if we've found out that the hard way that the documented bdcDevice
for these chips does not match your datasheets, it still seems we're
able to determine the HXN types (GC, GS, etc) based on bcdDevice and
this is something we'll likely need sooner or later.

Could you provide a list of the bcdDevice you use for the various HXN
types instead?

Then we can use the hx_status check for TA and TB whose bcdDevice have
been reused.

> Signed-off-by: Charles Yeh <charlesyeh522@gmail.com>
> ---
>  drivers/usb/serial/pl2303.c | 21 +++++++++++----------
>  1 file changed, 11 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
> index 3506c47e1eef..95e5fdf3b80a 100644
> --- a/drivers/usb/serial/pl2303.c
> +++ b/drivers/usb/serial/pl2303.c
> @@ -436,22 +436,23 @@ static int pl2303_detect_type(struct usb_serial *serial)
>  		break;
>  	case 0x200:
>  		switch (bcdDevice) {
> -		case 0x100:
> -		case 0x105:
> -		case 0x305:
> -		case 0x405:
> -		case 0x605:
> +		case 0x300:
> +			if (!pl2303_supports_hx_status(serial))
> +				return TYPE_HXN;
> +			else
> +				return TYPE_TA;
> +		case 0x500:
> +			if (!pl2303_supports_hx_status(serial))
> +				return TYPE_HXN;
> +			else
> +				return TYPE_TB;
> +		default:
>  			/*
>  			 * Assume it's an HXN-type if the device doesn't
>  			 * support the old read request value.
>  			 */
>  			if (!pl2303_supports_hx_status(serial))
>  				return TYPE_HXN;
> -			break;
> -		case 0x300:
> -			return TYPE_TA;
> -		case 0x500:
> -			return TYPE_TB;
>  		}
>  		break;
>  	}

Johan
Charles Yeh June 20, 2022, 10:51 a.m. UTC | #2
> > The setting value of bcdUSB & bcdDevice of PL2303TA is the same as the
> > setting value of bcdUSB & bcdDevice of a certain chip of PL2303HXN
>
> Which ones would that be?

PL2303GT_R4 (chip version: v4) is the same as PL2303TA.

PL2303TA:
Bus 003 Device 002: ID 067b:2303 Prolific Technology, Inc. PL2303
Serial Port / Mobile Action MA-8910P
Couldn't open device, some information will be missing
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0
  bDeviceSubClass         0
  bDeviceProtocol         0
  bMaxPacketSize0        64
  idVendor           0x067b Prolific Technology, Inc.
  idProduct          0x2303 PL2303 Serial Port / Mobile Action MA-8910P
  bcdDevice            3.00
  iManufacturer           1 Prolific Technology Inc.
  iProduct                2 USB-Serial Controller
  iSerial                 0
  bNumConfigurations      1


PL2303GT_R4 (chip version: v4)
Bus 001 Device 005: ID 067b:23c3 Prolific Technology, Inc. USB-Serial Controller
Couldn't open device, some information will be missing
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0
  bDeviceSubClass         0
  bDeviceProtocol         0
  bMaxPacketSize0        64
  idVendor           0x067b Prolific Technology, Inc.
  idProduct          0x23c3
  bcdDevice            3.00
  iManufacturer           1 Prolific Technology Inc.
  iProduct                2 USB-Serial Controller
  iSerial                 3 BGEK6178R45
  bNumConfigurations      1


> > The setting value of bcdUSB & bcdDevice of PL2303TB is the same as the
> > setting value of bcdUSB & bcdDevice of a certain chip of PL2303HXN
>
> Same question here.

PL2303GE_R4 (chip version: v4) is the same as PL2303TB.


> Could you provide a list of the bcdDevice you use for the various HXN
> types instead?

I also hope to have a complete list of all HXN versions..
But it is difficult.. I use PL2303GT as an example.
PL2303GT is currently divided into PL2303GT_R4 / PL2303GT_R5 / PL2303GT_R5+

PL2303GT_R4  : idProduct : 0x23C3, bcdDevice: 0x0300
PL2303GT_R5  : idProduct : 0x23C3, bcdDevice: 0x0305
PL2303GT_R5+ : idProduct : 0x23A3, bcdDevice: 0x0305

The above three kinds of PL2303GT are currently available in the market.

From the bcdUSB & bcdDevice of PL2303GT_R4, it is the same as PL2303TA.
So it needs to be checked again with hx_status check.

As mentioned earlier, some HXNs are currently on sale,
and some HXN versions are coming out (bcdDevice will have other settings),
HXN cannot use bcdDevice to determine the type one by one.


Charles.
Johan Hovold June 20, 2022, 12:41 p.m. UTC | #3
On Mon, Jun 20, 2022 at 06:51:58PM +0800, Charles Yeh wrote:
> > > The setting value of bcdUSB & bcdDevice of PL2303TA is the same as the
> > > setting value of bcdUSB & bcdDevice of a certain chip of PL2303HXN
> >
> > Which ones would that be?
> 
> PL2303GT_R4 (chip version: v4) is the same as PL2303TA.

[...]

> > > The setting value of bcdUSB & bcdDevice of PL2303TB is the same as the
> > > setting value of bcdUSB & bcdDevice of a certain chip of PL2303HXN
> >
> > Same question here.
> 
> PL2303GE_R4 (chip version: v4) is the same as PL2303TB.

Thanks for the details.

> > Could you provide a list of the bcdDevice you use for the various HXN
> > types instead?
> 
> I also hope to have a complete list of all HXN versions..
> But it is difficult.. I use PL2303GT as an example.
> PL2303GT is currently divided into PL2303GT_R4 / PL2303GT_R5 / PL2303GT_R5+
> 
> PL2303GT_R4  : idProduct : 0x23C3, bcdDevice: 0x0300
> PL2303GT_R5  : idProduct : 0x23C3, bcdDevice: 0x0305
> PL2303GT_R5+ : idProduct : 0x23A3, bcdDevice: 0x0305
> 
> The above three kinds of PL2303GT are currently available in the market.

Ok, but the above could be handled with two entries or if needed we can
just check the major number (i.e. the MSB, 0x03)?

Do the other types follow a similar pattern?

So far I've gathered that

	0x100	GC
	0x105	GC
	0x300	GT / TA
	0x305	GT
	0x405	GL
	0x500	GE / TB
	0x605	GS

So it look like we could use the major version number.

Anything more we need to add to the above list?

> From the bcdUSB & bcdDevice of PL2303GT_R4, it is the same as PL2303TA.
> So it needs to be checked again with hx_status check.

Right, the 0x300 and 0x500 need special handling.

> As mentioned earlier, some HXNs are currently on sale,
> and some HXN versions are coming out (bcdDevice will have other settings),
> HXN cannot use bcdDevice to determine the type one by one.

Surely you have way to determine the types since they have different
features. Are you not using bcdDevice for this for that other OS?

Johan
Charles Yeh June 21, 2022, 4:41 a.m. UTC | #4
> Ok, but the above could be handled with two entries or if needed we can
> just check the major number (i.e. the MSB, 0x03)?

No , MSB:0x03 represents the HXN_GT (PL2303GT) version,
but the current HXN version has multiple IC types,
for example, the bcdDevice_MSB of HXN_GS uses 0x60.

HXN_GS: PL2303GS_R4 : idProduct : 0x23F3, bcdDevice: 0x0600
HXN_GS: PL2303GS_R5 : idProduct : 0x23F3, bcdDevice: 0x0605
HXN_GS: PL2303GS_R5+ : idProduct : 0x23A3, bcdDevice: 0x0605

The difference between R4 and R5 is that bcdDevice is a different set value.
The difference between R5 and R5+ is that idProduct is a different set value.
But PL2303GS_R4 / PL2303GS_R5 / PL2303GS_R5+ all represent HXN_GS chip.


> So far I've gathered that
>
>         0x100   GC
>         0x105   GC
>         0x300   GT / TA
>         0x305   GT
>         0x405   GL
>         0x500   GE / TB
>         0x605   GS
>
> So it look like we could use the major version number.
>
> Anything more we need to add to the above list?

Currently there are HXN ICs on the market:
PL2303GC : 0x0100 / 0x0105
PL2303GT : 0x0300 / 0x0305
PL2303GL : 0x0400 / 0x0405
PL2303GE : 0x0500 / 0x0505
PL2303GS : 0x0600 / 0x0605
PL2303GR : 0x0700 / 0x0705

I think it is not very good to add the above bcdDevice to the list.

Because the company's PM/Sales are still planning some HXN ICs
(these ICs will be sold according to market behavior in the future,
and there will be different bcdDevices: 0x0800 / 0x0805/ 0x0900 / 0x0905.....).
so in the future Time, it will become to add different bcdDevice values
from time to time, which will become the patch file is always updated.


In the current newest Linux driver program design,
using bcdUSB (0x0100 / 0x0200) as a judgment.
I hope that when bcdUSB==0x0200 is encountered,
I only need to judge whether it is PL2303TA/PL2303TB chip,
and the rest is to use HX_Status to judge whether it is HXN_TYPE chip.

There is no need to use bcdDevice one by one to determine which HXN_TYPE
(PL2303GC, PL2303GT....)

At present, if our customers need special functions or
chip version control in HXN_TYPE IC ,
we will provide special customized files or patch files

General customers only need to identify as HXN_TYPE on Linux OS.

Charles.
Johan Hovold June 21, 2022, 8:06 a.m. UTC | #5
On Tue, Jun 21, 2022 at 12:41:39PM +0800, Charles Yeh wrote:
> > Ok, but the above could be handled with two entries or if needed we can
> > just check the major number (i.e. the MSB, 0x03)?
> 
> No , MSB:0x03 represents the HXN_GT (PL2303GT) version,
> but the current HXN version has multiple IC types,
> for example, the bcdDevice_MSB of HXN_GS uses 0x60.

That's precisely what I was referring to.
 
> HXN_GS: PL2303GS_R4 : idProduct : 0x23F3, bcdDevice: 0x0600
> HXN_GS: PL2303GS_R5 : idProduct : 0x23F3, bcdDevice: 0x0605
> HXN_GS: PL2303GS_R5+ : idProduct : 0x23A3, bcdDevice: 0x0605
> 
> The difference between R4 and R5 is that bcdDevice is a different set value.
> The difference between R5 and R5+ is that idProduct is a different set value.
> But PL2303GS_R4 / PL2303GS_R5 / PL2303GS_R5+ all represent HXN_GS chip.

Right.

> > So far I've gathered that
> >
> >         0x100   GC
> >         0x105   GC
> >         0x300   GT / TA
> >         0x305   GT
> >         0x405   GL
> >         0x500   GE / TB
> >         0x605   GS
> >
> > So it look like we could use the major version number.
> >
> > Anything more we need to add to the above list?
> 
> Currently there are HXN ICs on the market:
> PL2303GC : 0x0100 / 0x0105
> PL2303GT : 0x0300 / 0x0305
> PL2303GL : 0x0400 / 0x0405
> PL2303GE : 0x0500 / 0x0505
> PL2303GS : 0x0600 / 0x0605
> PL2303GR : 0x0700 / 0x0705

Thanks for filling in the blanks.

> I think it is not very good to add the above bcdDevice to the list.
> 
> Because the company's PM/Sales are still planning some HXN ICs
> (these ICs will be sold according to market behavior in the future,
> and there will be different bcdDevices: 0x0800 / 0x0805/ 0x0900 / 0x0905.....).
> so in the future Time, it will become to add different bcdDevice values
> from time to time, which will become the patch file is always updated.

That's no problem. We'd be happy to add support for any new types as
well.

It's much easier to get this right from the start than to try to
retrofit it when you realise that you need it (e.g. as we had to do with
the older types).

> In the current newest Linux driver program design,
> using bcdUSB (0x0100 / 0x0200) as a judgment.
> I hope that when bcdUSB==0x0200 is encountered,
> I only need to judge whether it is PL2303TA/PL2303TB chip,
> and the rest is to use HX_Status to judge whether it is HXN_TYPE chip.

I understand, and that would be enough to detect HXN, but not the
individual HXN types which is what I want to do.

> There is no need to use bcdDevice one by one to determine which HXN_TYPE
> (PL2303GC, PL2303GT....)
> 
> At present, if our customers need special functions or
> chip version control in HXN_TYPE IC ,
> we will provide special customized files or patch files

That's not a practice I would recommend, it's better that you add proper
support to the mainline driver so that all users can benefit.

I'm sure your customers would prefer to use a mainline driver as well.

> General customers only need to identify as HXN_TYPE on Linux OS.

I'm afraid I don't agree with that.

I'll prepare a patch that adds support for the missing HXN types.

Johan
Charles Yeh June 21, 2022, 8:17 a.m. UTC | #6
> I'll prepare a patch that adds support for the missing HXN types.

OK. Thanks for your kindly help.

Charles.
diff mbox series

Patch

diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index 3506c47e1eef..95e5fdf3b80a 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -436,22 +436,23 @@  static int pl2303_detect_type(struct usb_serial *serial)
 		break;
 	case 0x200:
 		switch (bcdDevice) {
-		case 0x100:
-		case 0x105:
-		case 0x305:
-		case 0x405:
-		case 0x605:
+		case 0x300:
+			if (!pl2303_supports_hx_status(serial))
+				return TYPE_HXN;
+			else
+				return TYPE_TA;
+		case 0x500:
+			if (!pl2303_supports_hx_status(serial))
+				return TYPE_HXN;
+			else
+				return TYPE_TB;
+		default:
 			/*
 			 * Assume it's an HXN-type if the device doesn't
 			 * support the old read request value.
 			 */
 			if (!pl2303_supports_hx_status(serial))
 				return TYPE_HXN;
-			break;
-		case 0x300:
-			return TYPE_TA;
-		case 0x500:
-			return TYPE_TB;
 		}
 		break;
 	}