Patchwork [v2] USB:serial:pl2303:add new Pull-Up mode to support PL2303HXD (TYPE_HX)

login
register
mail settings
Submitter Charles Yeh
Date Feb. 12, 2019, 12:50 p.m.
Message ID <20190212125049.12108-1-charlesyeh522@gmail.com>
Download mbox | patch
Permalink /patch/723887/
State New
Headers show

Comments

Charles Yeh - Feb. 12, 2019, 12:50 p.m.
Pull-Up mode is disabled (default) in PL2303HXD.
When the Pull-Up mode is activated, its TX/DTR/RTS external resistor will start the output function.

How to enable the Pull-Up mode of PL2303HXD
1.TX/DTR/RTS external resistor is required on the circuit diagram (PCB)
2.PL2303HXD OTP needs to be programmed to have a Pull-Up mode through 6.5V (USB_VCC,5V->6.5V)

The patch driver will read whether the PL2303HXD has a Pull-Up mode,and if so,
it will be set to enable Pull-Up mode function.

Signed-off-by: Charles Yeh <charlesyeh522@gmail.com>
---
 drivers/usb/serial/pl2303.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
Charles Yeh - Feb. 19, 2019, 6:41 a.m.
Hi Johan & Greg,


Do you have received a new patch"[PATCH] [v2]USB:serial:pl2303:add new
Pull-Up mode to support PL2303HXD (TYPE_HX)"?

If you have received a new patch, has the content been confirmed?

Or tell me where needs to be modified.

Charles Yeh <charlesyeh522@gmail.com> 於 2019年2月12日 週二 下午8:51寫道:
>
> Pull-Up mode is disabled (default) in PL2303HXD.
> When the Pull-Up mode is activated, its TX/DTR/RTS external resistor will start the output function.
>
> How to enable the Pull-Up mode of PL2303HXD
> 1.TX/DTR/RTS external resistor is required on the circuit diagram (PCB)
> 2.PL2303HXD OTP needs to be programmed to have a Pull-Up mode through 6.5V (USB_VCC,5V->6.5V)
>
> The patch driver will read whether the PL2303HXD has a Pull-Up mode,and if so,
> it will be set to enable Pull-Up mode function.
>
> Signed-off-by: Charles Yeh <charlesyeh522@gmail.com>
> ---
>  drivers/usb/serial/pl2303.c | 24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
>
> diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
> index bb3f9aa4a909..e5d00e4a495d 100644
> --- a/drivers/usb/serial/pl2303.c
> +++ b/drivers/usb/serial/pl2303.c
> @@ -145,6 +145,16 @@ MODULE_DEVICE_TABLE(usb, id_table);
>  #define UART_OVERRUN_ERROR             0x40
>  #define UART_CTS                       0x80
>
> +#define        TYPE_HX_READ_PUM_STATUS_REG     0x8484
> +#define        TYPE_HX_READ_PUM_ADD            0x0404
> +#define        TYPE_HX_READ_PUM_DATA_REG       0x8383
> +#define        TYPE_HX_PULLUP_MODE_DATA        0x08
> +#define        TYPE_HX_PULLUP_MODE_REG         0x09
> +#define        TYPE_HX_PUM_ADD0                0x00
> +#define        TYPE_HX_PUM_DATA0               0x31
> +#define        TYPE_HX_PUM_ADD1                0x01
> +#define        TYPE_HX_PUM_DATA1               0x08
> +
>  static void pl2303_set_break(struct usb_serial_port *port, bool enable);
>
>  enum pl2303_type {
> @@ -688,6 +698,20 @@ static void pl2303_set_termios(struct tty_struct *tty,
>                 pl2303_vendor_write(serial, 0x0, 0x0);
>         }
>
> +       if (spriv->type == &pl2303_type_data[TYPE_HX]) {
> +               pl2303_vendor_read(serial, TYPE_HX_READ_PUM_STATUS_REG, buf);
> +               pl2303_vendor_write(serial, TYPE_HX_READ_PUM_ADD,
> +                                       TYPE_HX_PULLUP_MODE_REG);
> +               pl2303_vendor_read(serial, TYPE_HX_READ_PUM_STATUS_REG, buf);
> +               pl2303_vendor_read(serial, TYPE_HX_READ_PUM_DATA_REG, buf);
> +               if (*buf == TYPE_HX_PULLUP_MODE_DATA) {
> +                       pl2303_vendor_write(serial, TYPE_HX_PUM_ADD0,
> +                                               TYPE_HX_PUM_DATA0);
> +                       pl2303_vendor_write(serial, TYPE_HX_PUM_ADD1,
> +                                               TYPE_HX_PUM_DATA1);
> +               }
> +       }
> +
>         kfree(buf);
>  }
>
> --
> 2.19.1
>
Johan Hovold - Feb. 19, 2019, 8:51 a.m.
On Tue, Feb 19, 2019 at 02:41:28PM +0800, Charles Yeh wrote:
> Hi Johan & Greg,
> 
> 
> Do you have received a new patch"[PATCH] [v2]USB:serial:pl2303:add new
> Pull-Up mode to support PL2303HXD (TYPE_HX)"?
> 
> If you have received a new patch, has the content been confirmed?
> 
> Or tell me where needs to be modified.

Yes, both patches you sent last week are in my queue. I just haven't had
time to review them yet.

Johan

Patch

diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index bb3f9aa4a909..e5d00e4a495d 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -145,6 +145,16 @@  MODULE_DEVICE_TABLE(usb, id_table);
 #define UART_OVERRUN_ERROR		0x40
 #define UART_CTS			0x80
 
+#define	TYPE_HX_READ_PUM_STATUS_REG	0x8484
+#define	TYPE_HX_READ_PUM_ADD		0x0404
+#define	TYPE_HX_READ_PUM_DATA_REG	0x8383
+#define	TYPE_HX_PULLUP_MODE_DATA	0x08
+#define	TYPE_HX_PULLUP_MODE_REG		0x09
+#define	TYPE_HX_PUM_ADD0		0x00
+#define	TYPE_HX_PUM_DATA0		0x31
+#define	TYPE_HX_PUM_ADD1		0x01
+#define	TYPE_HX_PUM_DATA1		0x08
+
 static void pl2303_set_break(struct usb_serial_port *port, bool enable);
 
 enum pl2303_type {
@@ -688,6 +698,20 @@  static void pl2303_set_termios(struct tty_struct *tty,
 		pl2303_vendor_write(serial, 0x0, 0x0);
 	}
 
+	if (spriv->type == &pl2303_type_data[TYPE_HX]) {
+		pl2303_vendor_read(serial, TYPE_HX_READ_PUM_STATUS_REG, buf);
+		pl2303_vendor_write(serial, TYPE_HX_READ_PUM_ADD,
+					TYPE_HX_PULLUP_MODE_REG);
+		pl2303_vendor_read(serial, TYPE_HX_READ_PUM_STATUS_REG, buf);
+		pl2303_vendor_read(serial, TYPE_HX_READ_PUM_DATA_REG, buf);
+		if (*buf == TYPE_HX_PULLUP_MODE_DATA) {
+			pl2303_vendor_write(serial, TYPE_HX_PUM_ADD0,
+						TYPE_HX_PUM_DATA0);
+			pl2303_vendor_write(serial, TYPE_HX_PUM_ADD1,
+						TYPE_HX_PUM_DATA1);
+		}
+	}
+
 	kfree(buf);
 }