linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] serial: add rs485-mux-gpio dt binding and support
@ 2023-11-20 15:10 Rasmus Villemoes
  2023-11-20 15:10 ` [PATCH 1/2] dt-bindings: serial: rs485: add rs485-mux-gpios binding Rasmus Villemoes
                   ` (2 more replies)
  0 siblings, 3 replies; 37+ messages in thread
From: Rasmus Villemoes @ 2023-11-20 15:10 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, linux-kernel, linux-serial, devicetree
  Cc: Andy Shevchenko, Lukas Wunner, Rasmus Villemoes, Rob Herring

Some boards are wired so that they support both rs232 and rs485, with
a gpio controlling a mux connecting the SOC's pins to the appropriate
external circuitry. Instead of requiring the application to know about
such details and handle the gpio appropriately, allow it to be
described in device tree and let the serial core code handle it if
present.

Tested on a board based on imx8mp.

Rasmus Villemoes (2):
  dt-bindings: serial: rs485: add rs485-mux-gpios binding
  serial: core: implement support for rs485-mux-gpios

 .../devicetree/bindings/serial/rs485.yaml     |  5 +++
 drivers/tty/serial/serial_core.c              | 35 +++++++++++++++++--
 include/linux/serial_core.h                   |  1 +
 3 files changed, 39 insertions(+), 2 deletions(-)

-- 
2.40.1.1.g1c60b9335d


^ permalink raw reply	[flat|nested] 37+ messages in thread
* Re: [PATCH 1/2] dt-bindings: serial: rs485: add rs485-mux-gpios binding
@ 2023-12-27 17:40 Andy Shevchenko
  0 siblings, 0 replies; 37+ messages in thread
From: Andy Shevchenko @ 2023-12-27 17:40 UTC (permalink / raw)
  To: Christoph Niedermaier
  Cc: Lino Sanfilippo, Lukas Wunner, Crescent CY Hsieh,
	Rasmus Villemoes, Greg Kroah-Hartman, Jiri Slaby, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, devicetree, linux-kernel,
	linux-serial, Ilpo Järvinen, brenda.streiff, Tomas Paukrt

On Sun, Dec 24, 2023 at 10:11:17AM +0000, Christoph Niedermaier wrote:
> From: Lino Sanfilippo [mailto:LinoSanfilippo@gmx.de]
> Sent: Saturday, December 23, 2023 2:41 PM
> > On 23.12.23 13:49, Christoph Niedermaier wrote:
> >> From: Lukas Wunner [mailto:lukas@wunner.de]
> >> Sent: Thursday, December 21, 2023 4:53 PM
> >>> On Thu, Dec 14, 2023 at 01:41:47PM +0000, Christoph Niedermaier wrote:
> >>>> I will summarize the current situation from my point of view, maybe it helps:
> >>>>
> >>>> RS-232:
> >>>>   - Full Duplex Point-to-Point connection
> >>>>   - No transceiver control with RTS
> >>>>   - No termination
> >>>>   - No extra struct in use
> >>>>
> >>>> RS-422:
> >>>>   - Full Duplex Point-to-Point connection
> >>>>   - No transceiver control with RTS needed
> >>>>   - Termination possible
> >>>>   - Extra struct serial_rs485 needed if termination is used
> >>>>  => RS-422 can be used in RS-232 operation, but if a termination should be
> >>>>     switchable the RS485 flag has to be enabled. But then also transceiver
> >>>>     control will be enabled. Not a very satisfying situation.
> >>>
> >>> Well why don't we just allow enabling or disabling RS-485 termination
> >>> independently from the SER_RS485_ENABLED bit in struct serial_rs485?
> >>>
> >>> Just let the user issue a TIOCSRS485 ioctl to toggle termination even
> >>> if in RS-232 mode and use that mode for RS-422.
> >>>
> >>> Looks like the simplest solution to me.
> >>
> >> Sounds not bad. The termination should only depend on whether the GPIO is
> >> given or not.
> >>
> >> Irrespective of this, I think the Linos idea of an RS-422 mode is not bad.
> >> This allows you to take care of special features that were previously
> >> overlooked. For example, hardware flow control can be switched off so that
> >> this does not cause any problems.
> >>
> > 
> > Also note, that RS232 and RS422 may NOT always be the same from driver perspective.
> > Take a look at 8250_excar.c for example. That driver has to configure the hardware
> > accordingly when switching from RS232 to RS422 (see iot2040_rs485_config()).
> > 
> > While a SER_RS485_MODE_RS422 flag set by userspace could work to switch to RS422, I
> > still think that the cleanest solution would be another ioctl TIOCSRS422 with a
> > parameter like
> > 
> > struct serial_rs422 {
> >        __u32   flags;
> > #define SER_RS422_ENABLED              (1 << 0)
> > #define SER_RS422_TERMINATE_BUS        (1 << 1)
> >         __u32   padding[7]
> > };
> > 
> > The SER_RS485_MODE_RS422 flag could still be used internally as a hint to the driver.
> > That solution would also be expandable if needed. I planned to send a patch that
> > implements this
> > as a RFC to the mailing list (maybe in the next few days).
> 
> Having your own ioctl is a nice distinction, but when I think about it for a moment,
> questions come to mind:
> 
> From userspace perspective then there are two termination flags
> SER_RS485_TERMINATE_BUS and SER_RS422_TERMINATE_BUS?
> How will they interact internally?
> 
> What about the devicetree property?
> Will there be rs422-term-gpios as well?
> 
> Could the user enable RS422 and RS485 at the same time?

Exactly, if you are going for this, just make a new entry into union, and
use flags for that. So, you probably will have the same IOCTL, but which
will serve RS422/RS385 purposes excluding odds of the use of the pieces.

-- 
With Best Regards,
Andy Shevchenko


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

end of thread, other threads:[~2023-12-28 23:25 UTC | newest]

Thread overview: 37+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-20 15:10 [PATCH 0/2] serial: add rs485-mux-gpio dt binding and support Rasmus Villemoes
2023-11-20 15:10 ` [PATCH 1/2] dt-bindings: serial: rs485: add rs485-mux-gpios binding Rasmus Villemoes
2023-11-21  7:52   ` Krzysztof Kozlowski
2023-11-21  8:27     ` Rasmus Villemoes
2023-11-21  8:34       ` Krzysztof Kozlowski
2023-11-21  9:28         ` Rasmus Villemoes
2023-11-22 18:00           ` Krzysztof Kozlowski
2023-11-22 14:53   ` Lukas Wunner
2023-11-23 10:07     ` Rasmus Villemoes
2023-11-23 10:38       ` Lukas Wunner
2023-11-23 13:48         ` Rasmus Villemoes
2023-11-25 23:40     ` Lino Sanfilippo
2023-11-27 12:14       ` Christoph Niedermaier
2023-12-06 15:42         ` Lino Sanfilippo
2023-12-07 12:35           ` Andy Shevchenko
2023-12-09 11:24             ` Lino Sanfilippo
2023-12-09 11:47           ` Lino Sanfilippo
2023-12-11 13:07             ` Andy Shevchenko
2023-12-14  8:52               ` Lino Sanfilippo
2023-12-14 10:24               ` Crescent CY Hsieh
2023-12-14 13:41                 ` Christoph Niedermaier
2023-12-14 14:04                   ` Lino Sanfilippo
2023-12-14 14:50                     ` Christoph Niedermaier
2023-12-15 22:13                       ` Lino Sanfilippo
2023-12-18  9:08                         ` Christoph Niedermaier
2023-12-21 15:53                   ` Lukas Wunner
2023-12-23 12:49                     ` Christoph Niedermaier
2023-12-23 13:40                       ` Lino Sanfilippo
2023-12-24 10:11                         ` Christoph Niedermaier
2023-12-28 23:25                         ` Lukas Wunner
2023-11-20 15:10 ` [PATCH 2/2] serial: core: implement support for rs485-mux-gpios Rasmus Villemoes
2023-11-20 23:28   ` Lino Sanfilippo
2023-11-21 10:49   ` Dan Carpenter
2023-11-22 15:10   ` Lukas Wunner
2023-12-04  5:00   ` Dan Carpenter
2023-11-22 14:57 ` [PATCH 0/2] serial: add rs485-mux-gpio dt binding and support Andy Shevchenko
2023-12-27 17:40 [PATCH 1/2] dt-bindings: serial: rs485: add rs485-mux-gpios binding 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).