linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johan Hovold <johan@kernel.org>
To: linux-usb@vger.kernel.org
Cc: Sheng Long Wang <china_shenglong@163.com>,
	Wang Sheng Long <shenglong.wang.ext@siemens.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Johan Hovold <johan@kernel.org>
Subject: [PATCH 2/6] USB: serial: cp210x: set IXOFF thresholds
Date: Mon, 18 Jan 2021 12:13:27 +0100	[thread overview]
Message-ID: <20210118111331.5048-3-johan@kernel.org> (raw)
In-Reply-To: <20210118111331.5048-1-johan@kernel.org>

At least CP2102 requires the XON/XOFF limits to be initialised in order
for software input flow control (IXOFF) to work. Specifically, XOFF is
never sent if the XOFF limit is left at its default value of zero.

Set the limits so that input is throttled when the FIFO free level drops
below 128 bytes and restarted when the FIFO fill level drops below 128
bytes.

Note that the threshold values have been chosen so that they can be used
also with CP2105 which has the smallest FIFO of the currently supported
device types (288 byte for the SCI port). If needed the limits can be
made device specific later.

Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/usb/serial/cp210x.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
index 5bd14770065b..ee0139eb6636 100644
--- a/drivers/usb/serial/cp210x.c
+++ b/drivers/usb/serial/cp210x.c
@@ -1181,6 +1181,9 @@ static void cp210x_set_flow_control(struct tty_struct *tty,
 	else
 		flow_repl &= ~CP210X_SERIAL_AUTO_TRANSMIT;
 
+	flow_ctl.ulXonLimit = cpu_to_le32(128);
+	flow_ctl.ulXoffLimit = cpu_to_le32(128);
+
 	dev_dbg(&port->dev, "%s - ulControlHandshake=0x%08x, ulFlowReplace=0x%08x\n",
 			__func__, ctl_hs, flow_repl);
 
-- 
2.26.2


  parent reply	other threads:[~2021-01-18 11:18 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-18 11:13 [PATCH 0/6] USB: serial: cp210x: add software flow-control support Johan Hovold
2021-01-18 11:13 ` [PATCH 1/6] USB: serial: cp210x: add support for software flow control Johan Hovold
2021-01-18 12:42   ` Greg Kroah-Hartman
2021-01-18 13:33     ` Johan Hovold
2021-01-18 11:13 ` Johan Hovold [this message]
2021-01-18 11:13 ` [PATCH 3/6] USB: serial: cp210x: update control-characters on every change Johan Hovold
2021-01-18 11:13 ` [PATCH 4/6] USB: serial: cp210x: drop short control-transfer checks Johan Hovold
2021-01-18 11:13 ` [PATCH 5/6] USB: serial: cp210x: drop unused includes Johan Hovold
2021-01-18 11:13 ` [PATCH 6/6] USB: serial: cp210x: add copyright notice Johan Hovold
2021-01-18 12:44 ` [PATCH 0/6] USB: serial: cp210x: add software flow-control support Greg Kroah-Hartman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210118111331.5048-3-johan@kernel.org \
    --to=johan@kernel.org \
    --cc=china_shenglong@163.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=shenglong.wang.ext@siemens.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).