linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tty: 8250_of: Use software emulated RS485 direction control
@ 2019-09-13  5:01 Heiko Schocher
  2019-09-13 10:24 ` Andy Shevchenko
  0 siblings, 1 reply; 4+ messages in thread
From: Heiko Schocher @ 2019-09-13  5:01 UTC (permalink / raw)
  To: linux-serial
  Cc: Heiko Schocher, Alexander Sverdlin, Andy Shevchenko,
	Darwin Dingel, Greg Kroah-Hartman, Jiri Slaby, John Garry,
	Linus Walleij, Lubomir Rintel, Rob Herring, Thierry Reding,
	linux-kernel

Use software emulated RS485 direction control to provide RS485 API

Currently it is not possible to use rs485 as pointer to
rs485_config struct in struct uart_port is NULL in case we
configure the port through device tree.

Signed-off-by: Heiko Schocher <hs@denx.de>

---
Patch is based on:
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
commit:
505a8ec7e11a - Revert "drm/i915/userptr: Acquire the page lock around set_page_dirty()"

checkpatch output:
$ ./scripts/checkpatch.pl 0001-tty-8250_of-Use-software-emulated-RS485-direction-co.patch
total: 0 errors, 0 warnings, 43 lines checked

0001-tty-8250_of-Use-software-emulated-RS485-direction-co.patch has no obvious style problems and is ready for submission.

 drivers/tty/serial/8250/8250_of.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/drivers/tty/serial/8250/8250_of.c b/drivers/tty/serial/8250/8250_of.c
index 0826cfdbd4063..92fbf46ce3bd9 100644
--- a/drivers/tty/serial/8250/8250_of.c
+++ b/drivers/tty/serial/8250/8250_of.c
@@ -48,6 +48,36 @@ static inline void tegra_serial_handle_break(struct uart_port *port)
 }
 #endif
 
+static int of_8250_rs485_config(struct uart_port *port,
+				  struct serial_rs485 *rs485)
+{
+	struct uart_8250_port *up = up_to_u8250p(port);
+
+	/* Clamp the delays to [0, 100ms] */
+	rs485->delay_rts_before_send = min(rs485->delay_rts_before_send, 100U);
+	rs485->delay_rts_after_send  = min(rs485->delay_rts_after_send, 100U);
+
+	port->rs485 = *rs485;
+
+	/*
+	 * Both serial8250_em485_init and serial8250_em485_destroy
+	 * are idempotent
+	 */
+	if (rs485->flags & SER_RS485_ENABLED) {
+		int ret = serial8250_em485_init(up);
+
+		if (ret) {
+			rs485->flags &= ~SER_RS485_ENABLED;
+			port->rs485.flags &= ~SER_RS485_ENABLED;
+		}
+		return ret;
+	}
+
+	serial8250_em485_destroy(up);
+
+	return 0;
+}
+
 /*
  * Fill a struct uart_port for a given device node
  */
@@ -178,6 +208,7 @@ static int of_platform_serial_setup(struct platform_device *ofdev,
 		port->flags |= UPF_SKIP_TEST;
 
 	port->dev = &ofdev->dev;
+	port->rs485_config = of_8250_rs485_config;
 
 	switch (type) {
 	case PORT_TEGRA:
-- 
2.21.0


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

* Re: [PATCH] tty: 8250_of: Use software emulated RS485 direction control
  2019-09-13  5:01 [PATCH] tty: 8250_of: Use software emulated RS485 direction control Heiko Schocher
@ 2019-09-13 10:24 ` Andy Shevchenko
  2019-09-13 14:51   ` Heiko Schocher
  0 siblings, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2019-09-13 10:24 UTC (permalink / raw)
  To: Heiko Schocher
  Cc: linux-serial, Alexander Sverdlin, Darwin Dingel,
	Greg Kroah-Hartman, Jiri Slaby, John Garry, Linus Walleij,
	Lubomir Rintel, Rob Herring, Thierry Reding, linux-kernel

On Fri, Sep 13, 2019 at 07:01:05AM +0200, Heiko Schocher wrote:
> Use software emulated RS485 direction control to provide RS485 API
> 
> Currently it is not possible to use rs485 as pointer to
> rs485_config struct in struct uart_port is NULL in case we
> configure the port through device tree.

Thank you for the patch, few recommendations for the future submissions.

> Patch is based on:
> git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> commit:
> 505a8ec7e11a - Revert "drm/i915/userptr: Acquire the page lock around set_page_dirty()"

More reliably is to base on corresponding subsystem tree, i.e. tty-next for
this case.

> checkpatch output:
> $ ./scripts/checkpatch.pl 0001-tty-8250_of-Use-software-emulated-RS485-direction-co.patch
> total: 0 errors, 0 warnings, 43 lines checked
> 
> 0001-tty-8250_of-Use-software-emulated-RS485-direction-co.patch has no obvious style problems and is ready for submission.

There is no need to mention this. It's supposed that submitter did that
themselves.

When you gather people to send the patch to, I recommend to use some threshold,
e.g. `scripts/get_maintainer.pl --git --git-min-percent=67 ...`

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH] tty: 8250_of: Use software emulated RS485 direction control
  2019-09-13 10:24 ` Andy Shevchenko
@ 2019-09-13 14:51   ` Heiko Schocher
  2019-09-13 15:05     ` Andy Shevchenko
  0 siblings, 1 reply; 4+ messages in thread
From: Heiko Schocher @ 2019-09-13 14:51 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: linux-serial, Alexander Sverdlin, Darwin Dingel,
	Greg Kroah-Hartman, Jiri Slaby, John Garry, Linus Walleij,
	Lubomir Rintel, Rob Herring, Thierry Reding, linux-kernel

Hello Andy,

Am 13.09.2019 um 12:24 schrieb Andy Shevchenko:
> On Fri, Sep 13, 2019 at 07:01:05AM +0200, Heiko Schocher wrote:
>> Use software emulated RS485 direction control to provide RS485 API
>>
>> Currently it is not possible to use rs485 as pointer to
>> rs485_config struct in struct uart_port is NULL in case we
>> configure the port through device tree.
> 
> Thank you for the patch, few recommendations for the future submissions.
> 
>> Patch is based on:
>> git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
>> commit:
>> 505a8ec7e11a - Revert "drm/i915/userptr: Acquire the page lock around set_page_dirty()"
> 
> More reliably is to base on corresponding subsystem tree, i.e. tty-next for
> this case.

Ok, should I send a rebased v2 (I tend to wait for other comments)?

>> checkpatch output:
>> $ ./scripts/checkpatch.pl 0001-tty-8250_of-Use-software-emulated-RS485-direction-co.patch
>> total: 0 errors, 0 warnings, 43 lines checked
>>
>> 0001-tty-8250_of-Use-software-emulated-RS485-direction-co.patch has no obvious style problems and is ready for submission.
> 
> There is no need to mention this. It's supposed that submitter did that
> themselves.

Hmm... ok.

> When you gather people to send the patch to, I recommend to use some threshold,
> e.g. `scripts/get_maintainer.pl --git --git-min-percent=67 ...`

Ah, good tip, thanks!

bye,
Heiko
-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: hs@denx.de

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

* Re: [PATCH] tty: 8250_of: Use software emulated RS485 direction control
  2019-09-13 14:51   ` Heiko Schocher
@ 2019-09-13 15:05     ` Andy Shevchenko
  0 siblings, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2019-09-13 15:05 UTC (permalink / raw)
  To: Heiko Schocher
  Cc: linux-serial, Alexander Sverdlin, Darwin Dingel,
	Greg Kroah-Hartman, Jiri Slaby, John Garry, Linus Walleij,
	Lubomir Rintel, Rob Herring, Thierry Reding, linux-kernel

On Fri, Sep 13, 2019 at 04:51:30PM +0200, Heiko Schocher wrote:
> Am 13.09.2019 um 12:24 schrieb Andy Shevchenko:
> > On Fri, Sep 13, 2019 at 07:01:05AM +0200, Heiko Schocher wrote:

> > > Patch is based on:
> > > git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> > > commit:
> > > 505a8ec7e11a - Revert "drm/i915/userptr: Acquire the page lock around set_page_dirty()"
> > 
> > More reliably is to base on corresponding subsystem tree, i.e. tty-next for
> > this case.
> 
> Ok, should I send a rebased v2 (I tend to wait for other comments)?

I didn't give any comments WRT patch itself, so, I don't see any needs to send
v2 right now.

-- 
With Best Regards,
Andy Shevchenko



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

end of thread, other threads:[~2019-09-13 15:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-13  5:01 [PATCH] tty: 8250_of: Use software emulated RS485 direction control Heiko Schocher
2019-09-13 10:24 ` Andy Shevchenko
2019-09-13 14:51   ` Heiko Schocher
2019-09-13 15:05     ` Andy Shevchenko

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