[PATCH] USB: serial: cp210x: work around silicon bug setting break

From: minyard
Date: Wed Apr 26 2023 - 19:43:07 EST


From: Corey Minyard <cmimyard@xxxxxxxxxx>

At least on the CP2105, sending this once doesn't work, you have to send
it twice to make it happen. If you only send it once, you will get a
really short time (a few bits) where the break is sent, right when the
break is turned off, thus it isn't recognised as a break. Sending it
twice won't hurt anything, so just do it all the time.

Signed-off-by: Corey Minyard <cmimyard@xxxxxxxxxx>
---
I played with this a bit, and found this change fixes the issue. It's
not ideal, I suppose, but it works.

drivers/usb/serial/cp210x.c | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
index cdea1bff3b70..e410a749325b 100644
--- a/drivers/usb/serial/cp210x.c
+++ b/drivers/usb/serial/cp210x.c
@@ -1446,6 +1446,15 @@ static void cp210x_break_ctl(struct tty_struct *tty, int break_state)
dev_dbg(&port->dev, "%s - turning break %s\n", __func__,
state == BREAK_OFF ? "off" : "on");
cp210x_write_u16_reg(port, CP210X_SET_BREAK, state);
+ /*
+ * At least on the CP2105, sending this once doesn't work, you
+ * have to send it twice to make it happen. If you only send
+ * it once, you will get a really short time (a few bits) where
+ * the break is sent, right when the break is turned off, thus
+ * it isn't recognised as a break. Sending it twice won't hurt
+ * anything, so just do it all the time.
+ */
+ cp210x_write_u16_reg(port, CP210X_SET_BREAK, state);
}

#ifdef CONFIG_GPIOLIB
--
2.35.7