LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Martin Kepplinger <martin.kepplinger@ginzinger.com>
To: <gregkh@linuxfoundation.org>, <robh+dt@kernel.org>,
	<mark.rutland@arm.com>, <jslaby@suse.com>, <corbet@lwn.net>,
	<richard.genoud@gmail.com>, <nicolas.ferre@microchip.com>,
	<alexandre.belloni@bootlin.com>,
	<ludovic.desroches@microchip.com>, <mcoquelin.stm32@gmail.com>,
	<alexandre.torgue@st.com>, <linux-serial@vger.kernel.org>,
	<devicetree@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-stm32@st-md-mailman.stormreply.com>
Cc: <linux-kernel@vger.kernel.org>
Subject: [PATCH 1/9] serial: uapi: add SER_RS485_DELAY_IN_USEC flag to struct serial_rs485
Date: Wed, 20 Feb 2019 16:27:23 +0100	[thread overview]
Message-ID: <20190220152731.4051-1-martin.kepplinger@ginzinger.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 2537 bytes --]

This extends the user interface for rs485 communication:

We add a new flag, SER_RS485_DELAY_IN_USEC, to struct serial_rs485 that
indicates that delay_rts_before_send and delay_rts_after_send values are
interpreted in microsecond units.

Up until now, the code comment defined these values to hold the delays in
millisecond units. Especially with fast data rates (1Mbaut or more) that
are not too uncommon for RS485, 1ms become quite long. Users need to be
able to set shorter delays than 1 ms in order not to slow down the channel
unnecessarily.

So when delays are needed, but not as long as 1ms, this enables faster
communication channels without changing the baudrate.

Signed-off-by: Martin Kepplinger <martin.kepplinger@ginzinger.com>
---
Hi,

We have this totally quirky patch that uses udelay() in our tree
for a looong time now because of the above reasons - and because we are lazy.
This is an attempt to get rid of said patch on our side and fix this properly.

What do you thing about adding a flag in general?

The following patches should integrate this idea in devicetree and drivers.
These changes are NOT tested on hardware but should behave predictably
enough. I use the delays in a driver that doesn't implement them yet at
all. I'll do that after this (or something similar) is merged - it's a 2-liner
then.

Also, a patch to the rs485conf tool, that is sometimes used instead of
ioctl() directly, will be prepared as well.

thanks

                                 martin



 include/uapi/linux/serial.h | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/include/uapi/linux/serial.h b/include/uapi/linux/serial.h
index 93eb3c496ff1..c16c950ebca2 100644
--- a/include/uapi/linux/serial.h
+++ b/include/uapi/linux/serial.h
@@ -126,8 +126,15 @@ struct serial_rs485 {
 #define SER_RS485_TERMINATE_BUS		(1 << 5)	/* Enable bus
 							   termination
 							   (if supported) */
-	__u32	delay_rts_before_send;	/* Delay before send (milliseconds) */
-	__u32	delay_rts_after_send;	/* Delay after send (milliseconds) */
+#define SER_RS485_DELAY_IN_USEC		(1 << 6)	/* delay_rts_*_send
+							   values are given in
+							   microseconds */
+	__u32	delay_rts_before_send;	/* Delay before send (milliseconds
+					   by default. microseconds if flag
+					   is set) */
+	__u32	delay_rts_after_send;	/* Delay after send (milliseconds
+					   by default. microseconds if flag
+					   is set) */
 	__u32	padding[5];		/* Memory is cheap, new structs
 					   are a royal PITA .. */
 };
-- 
2.20.1


[-- Attachment #2: smime.p7s --]
[-- Type: application/x-pkcs7-signature, Size: 3616 bytes --]

             reply	other threads:[~2019-02-20 15:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-20 15:27 Martin Kepplinger [this message]
2019-02-20 15:27 ` [PATCH 2/9] Documentation: serial-rs485: document SER_RS485_DELAY_IN_USEC flag Martin Kepplinger
2019-02-20 15:27 ` [PATCH 3/9] serial: core: add rs485-rts-delay-us devicetree property for RS485 Martin Kepplinger
2019-02-20 15:27 ` [PATCH 4/9] serial: 8250: add support for rs485 RTS delays in microseconds Martin Kepplinger
2019-02-20 15:27 ` [PATCH 5/9] serial: omap-serial: " Martin Kepplinger

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=20190220152731.4051-1-martin.kepplinger@ginzinger.com \
    --to=martin.kepplinger@ginzinger.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=alexandre.torgue@st.com \
    --cc=corbet@lwn.net \
    --cc=devicetree@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jslaby@suse.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=ludovic.desroches@microchip.com \
    --cc=mark.rutland@arm.com \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=nicolas.ferre@microchip.com \
    --cc=richard.genoud@gmail.com \
    --cc=robh+dt@kernel.org \
    --subject='Re: [PATCH 1/9] serial: uapi: add SER_RS485_DELAY_IN_USEC flag to struct serial_rs485' \
    /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

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).