All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V1 1/1] USB: serial: f81534: fix reading old/new IC config
@ 2018-11-15  2:58 ` Ji-Ze Hong (Peter Hong)
  0 siblings, 0 replies; 4+ messages in thread
From: Ji-Ze Hong (Peter Hong) @ 2018-11-15  2:58 UTC (permalink / raw)
  To: johan
  Cc: gregkh, linux-usb, linux-kernel, peter_hong, Ji-Ze Hong (Peter Hong)

The F81532/534 had a internal configuration space to save & control
IC state with address F81534_CUSTOM_ADDRESS_START (0x2f00). Layout
as following:
	+00h: to indicate the section is valid
	+01h~04h: UART Mode & port availability
	+05h~08h: Output pin control on IC power on
	+09h~12h: Output pin control on working <-- New added

Old driver will use +05~08h as default on working, but newer IC will
configed with shutdown mode(7) in 05h~08h and working mode with RS232(1)
in 09h~12h. It'll make mainstream driver not working.

This patch will make mainstream driver compatible older and newer IC.
If using a old IC, the +05h~08h will be 00h~06h, we'll direct apply it.
If using a new IC, the +05h~08h will be 07h or larger, we'll read +09h~12h
to apply newer configuration.

Signed-off-by: Ji-Ze Hong (Peter Hong) <hpeter+linux_kernel@gmail.com>
---
 drivers/usb/serial/f81534.c | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/serial/f81534.c b/drivers/usb/serial/f81534.c
index 380933db34dd..2b39bda035c7 100644
--- a/drivers/usb/serial/f81534.c
+++ b/drivers/usb/serial/f81534.c
@@ -45,14 +45,17 @@
 #define F81534_CONFIG1_REG		(0x09 + F81534_UART_BASE_ADDRESS)
 
 #define F81534_DEF_CONF_ADDRESS_START	0x3000
-#define F81534_DEF_CONF_SIZE		8
+#define F81534_DEF_CONF_SIZE		12
 
 #define F81534_CUSTOM_ADDRESS_START	0x2f00
 #define F81534_CUSTOM_DATA_SIZE		0x10
 #define F81534_CUSTOM_NO_CUSTOM_DATA	0xff
 #define F81534_CUSTOM_VALID_TOKEN	0xf0
 #define F81534_CONF_OFFSET		1
-#define F81534_CONF_GPIO_OFFSET		4
+#define F81534_CONF_INIT_GPIO_OFFSET	4
+#define F81534_CONF_WORK_GPIO_OFFSET	8
+#define F81534_CONF_GPIO_SHUTDOWN	7
+#define F81534_CONF_GPIO_RS232		1
 
 #define F81534_MAX_DATA_BLOCK		64
 #define F81534_MAX_BUS_RETRY		20
@@ -1337,8 +1340,19 @@ static int f81534_set_port_output_pin(struct usb_serial_port *port)
 	serial_priv = usb_get_serial_data(serial);
 	port_priv = usb_get_serial_port_data(port);
 
-	idx = F81534_CONF_GPIO_OFFSET + port_priv->phy_num;
+	idx = F81534_CONF_INIT_GPIO_OFFSET + port_priv->phy_num;
 	value = serial_priv->conf_data[idx];
+	if (value >= F81534_CONF_GPIO_SHUTDOWN) {
+		/*
+		 * Newer IC configure will make transceiver in shutdown mode on
+		 * initial power on. We need enable it before using UARTs.
+		 */
+		idx = F81534_CONF_WORK_GPIO_OFFSET + port_priv->phy_num;
+		value = serial_priv->conf_data[idx];
+		if (value >= F81534_CONF_GPIO_SHUTDOWN)
+			value = F81534_CONF_GPIO_RS232;
+	}
+
 	pins = &f81534_port_out_pins[port_priv->phy_num];
 
 	for (i = 0; i < ARRAY_SIZE(pins->pin); ++i) {
-- 
2.7.4


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [V1,1/1] USB: serial: f81534: fix reading old/new IC config
@ 2018-11-15  2:58 ` Ji-Ze Hong (Peter Hong)
  0 siblings, 0 replies; 4+ messages in thread
From: Ji-Ze Hong (Peter Hong) @ 2018-11-15  2:58 UTC (permalink / raw)
  To: johan
  Cc: gregkh, linux-usb, linux-kernel, peter_hong, Ji-Ze Hong (Peter Hong)

The F81532/534 had a internal configuration space to save & control
IC state with address F81534_CUSTOM_ADDRESS_START (0x2f00). Layout
as following:
	+00h: to indicate the section is valid
	+01h~04h: UART Mode & port availability
	+05h~08h: Output pin control on IC power on
	+09h~12h: Output pin control on working <-- New added

Old driver will use +05~08h as default on working, but newer IC will
configed with shutdown mode(7) in 05h~08h and working mode with RS232(1)
in 09h~12h. It'll make mainstream driver not working.

This patch will make mainstream driver compatible older and newer IC.
If using a old IC, the +05h~08h will be 00h~06h, we'll direct apply it.
If using a new IC, the +05h~08h will be 07h or larger, we'll read +09h~12h
to apply newer configuration.

Signed-off-by: Ji-Ze Hong (Peter Hong) <hpeter+linux_kernel@gmail.com>
---
 drivers/usb/serial/f81534.c | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/serial/f81534.c b/drivers/usb/serial/f81534.c
index 380933db34dd..2b39bda035c7 100644
--- a/drivers/usb/serial/f81534.c
+++ b/drivers/usb/serial/f81534.c
@@ -45,14 +45,17 @@
 #define F81534_CONFIG1_REG		(0x09 + F81534_UART_BASE_ADDRESS)
 
 #define F81534_DEF_CONF_ADDRESS_START	0x3000
-#define F81534_DEF_CONF_SIZE		8
+#define F81534_DEF_CONF_SIZE		12
 
 #define F81534_CUSTOM_ADDRESS_START	0x2f00
 #define F81534_CUSTOM_DATA_SIZE		0x10
 #define F81534_CUSTOM_NO_CUSTOM_DATA	0xff
 #define F81534_CUSTOM_VALID_TOKEN	0xf0
 #define F81534_CONF_OFFSET		1
-#define F81534_CONF_GPIO_OFFSET		4
+#define F81534_CONF_INIT_GPIO_OFFSET	4
+#define F81534_CONF_WORK_GPIO_OFFSET	8
+#define F81534_CONF_GPIO_SHUTDOWN	7
+#define F81534_CONF_GPIO_RS232		1
 
 #define F81534_MAX_DATA_BLOCK		64
 #define F81534_MAX_BUS_RETRY		20
@@ -1337,8 +1340,19 @@ static int f81534_set_port_output_pin(struct usb_serial_port *port)
 	serial_priv = usb_get_serial_data(serial);
 	port_priv = usb_get_serial_port_data(port);
 
-	idx = F81534_CONF_GPIO_OFFSET + port_priv->phy_num;
+	idx = F81534_CONF_INIT_GPIO_OFFSET + port_priv->phy_num;
 	value = serial_priv->conf_data[idx];
+	if (value >= F81534_CONF_GPIO_SHUTDOWN) {
+		/*
+		 * Newer IC configure will make transceiver in shutdown mode on
+		 * initial power on. We need enable it before using UARTs.
+		 */
+		idx = F81534_CONF_WORK_GPIO_OFFSET + port_priv->phy_num;
+		value = serial_priv->conf_data[idx];
+		if (value >= F81534_CONF_GPIO_SHUTDOWN)
+			value = F81534_CONF_GPIO_RS232;
+	}
+
 	pins = &f81534_port_out_pins[port_priv->phy_num];
 
 	for (i = 0; i < ARRAY_SIZE(pins->pin); ++i) {

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH V1 1/1] USB: serial: f81534: fix reading old/new IC config
@ 2018-11-20 17:29   ` Johan Hovold
  0 siblings, 0 replies; 4+ messages in thread
From: Johan Hovold @ 2018-11-20 17:29 UTC (permalink / raw)
  To: Ji-Ze Hong (Peter Hong)
  Cc: johan, gregkh, linux-usb, linux-kernel, peter_hong,
	Ji-Ze Hong (Peter Hong)

On Thu, Nov 15, 2018 at 10:58:44AM +0800, Ji-Ze Hong (Peter Hong) wrote:
> The F81532/534 had a internal configuration space to save & control
> IC state with address F81534_CUSTOM_ADDRESS_START (0x2f00). Layout
> as following:
> 	+00h: to indicate the section is valid
> 	+01h~04h: UART Mode & port availability
> 	+05h~08h: Output pin control on IC power on
> 	+09h~12h: Output pin control on working <-- New added
> 
> Old driver will use +05~08h as default on working, but newer IC will
> configed with shutdown mode(7) in 05h~08h and working mode with RS232(1)
> in 09h~12h. It'll make mainstream driver not working.
> 
> This patch will make mainstream driver compatible older and newer IC.
> If using a old IC, the +05h~08h will be 00h~06h, we'll direct apply it.
> If using a new IC, the +05h~08h will be 07h or larger, we'll read +09h~12h
> to apply newer configuration.
> 
> Signed-off-by: Ji-Ze Hong (Peter Hong) <hpeter+linux_kernel@gmail.com>

Applied for -next. I guess you can ask Greg if he's willing to take this
into stable once 4.21-rc1 is out (as it is enabling support for a new
class of devices).

Thanks,
Johan

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [V1,1/1] USB: serial: f81534: fix reading old/new IC config
@ 2018-11-20 17:29   ` Johan Hovold
  0 siblings, 0 replies; 4+ messages in thread
From: Johan Hovold @ 2018-11-20 17:29 UTC (permalink / raw)
  To: Ji-Ze Hong (Peter Hong)
  Cc: johan, gregkh, linux-usb, linux-kernel, peter_hong,
	Ji-Ze Hong (Peter Hong)

On Thu, Nov 15, 2018 at 10:58:44AM +0800, Ji-Ze Hong (Peter Hong) wrote:
> The F81532/534 had a internal configuration space to save & control
> IC state with address F81534_CUSTOM_ADDRESS_START (0x2f00). Layout
> as following:
> 	+00h: to indicate the section is valid
> 	+01h~04h: UART Mode & port availability
> 	+05h~08h: Output pin control on IC power on
> 	+09h~12h: Output pin control on working <-- New added
> 
> Old driver will use +05~08h as default on working, but newer IC will
> configed with shutdown mode(7) in 05h~08h and working mode with RS232(1)
> in 09h~12h. It'll make mainstream driver not working.
> 
> This patch will make mainstream driver compatible older and newer IC.
> If using a old IC, the +05h~08h will be 00h~06h, we'll direct apply it.
> If using a new IC, the +05h~08h will be 07h or larger, we'll read +09h~12h
> to apply newer configuration.
> 
> Signed-off-by: Ji-Ze Hong (Peter Hong) <hpeter+linux_kernel@gmail.com>

Applied for -next. I guess you can ask Greg if he's willing to take this
into stable once 4.21-rc1 is out (as it is enabling support for a new
class of devices).

Thanks,
Johan

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-11-20 17:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-15  2:58 [PATCH V1 1/1] USB: serial: f81534: fix reading old/new IC config Ji-Ze Hong (Peter Hong)
2018-11-15  2:58 ` [V1,1/1] " Ji-Ze Hong (Peter Hong)
2018-11-20 17:29 ` [PATCH V1 1/1] " Johan Hovold
2018-11-20 17:29   ` [V1,1/1] " Johan Hovold

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.