mbox series

[0/4] tty: serial: Add ability to control rs485 RX_DURING_TX via a GPIO

Message ID 20221026165049.9541-1-cniedermaier@dh-electronics.com
Headers show
Series tty: serial: Add ability to control rs485 RX_DURING_TX via a GPIO | expand

Message

Christoph Niedermaier Oct. 26, 2022, 4:50 p.m. UTC
This patch series add the ability to control the RS485 feature RX_DURING_TX via
a GPIO. Currently it is handled by the low level serial driver and it depends
on the ability of the serial hardware. In case of that RX_DURING_TX is disabled
the serial hardware must be capable to turn off the receiver during sending.
The idea is to have an electrical circuit that connects/disconnects the Rx by
using the RX_DURING_TX GPIO. On one hand by using this GPIO the use of RS485
RX_DURING_TX becomes independent of the capability of the serial hardware, and
on the other hand possible software-caused switch-off and switch-on times of the
receiver in case of RX_DURING_TX is disabled (default state) can also be avoided.

The core patch adds a generic GPIO variable for the use of this RS485 feature
controlled by a GPIO. The GPIO is defined by the devicetree property
"rs485-rx-during-tx-gpios".

The low-level implementation is done for the STM32 and the i.MX serial driver.
Other platforms are not covered in this series, but can easily be added.

I tested it with a DHCOM i.MX6DL and DHCOM STM32MP1 on a PicoITX board.

In this series the devicetree bindings description is also included.


Christoph Niedermaier (4):
  dt_bindings: rs485: Add binding for GPIO that controls Rx enable
    during Tx
  serial: core: Add option to control rs485 RX_DURING_TX by a GPIO
  serial: imx: Add support for rs485 RX_DURING_TX GPIO
  serial: stm32: Add support for rs485 RX_DURING_TX GPIO

 Documentation/devicetree/bindings/serial/rs485.yaml |  4 ++++
 drivers/tty/serial/imx.c                            | 13 +++++++++++--
 drivers/tty/serial/serial_core.c                    | 12 ++++++++++++
 drivers/tty/serial/stm32-usart.c                    |  9 ++++++++-
 include/linux/serial_core.h                         |  1 +
 5 files changed, 36 insertions(+), 3 deletions(-)

Comments

Rob Herring Oct. 26, 2022, 8:59 p.m. UTC | #1
On Wed, Oct 26, 2022 at 06:50:46PM +0200, Christoph Niedermaier wrote:
> Add the binding for a generic definition of a GPIO, that controls whether Rx
> is connected or disconnected by an electrical circuit to have the ability
> to receive the signals on the bus during sending or disable receiving during
> sending.
> 
> Signed-off-by: Christoph Niedermaier <cniedermaier@dh-electronics.com>
> ---
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: Rob Herring <robh+dt@kernel.org>
> Cc: Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>
> Cc: Marek Vasut <marex@denx.de>
> Cc: devicetree@vger.kernel.org
> To: linux-serial@vger.kernel.org
> To: linux-arm-kernel@lists.infradead.org
> ---
>  Documentation/devicetree/bindings/serial/rs485.yaml | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/serial/rs485.yaml b/Documentation/devicetree/bindings/serial/rs485.yaml
> index 90a1bab40f05..0ebd7690f85d 100644
> --- a/Documentation/devicetree/bindings/serial/rs485.yaml
> +++ b/Documentation/devicetree/bindings/serial/rs485.yaml
> @@ -51,6 +51,10 @@ properties:
>      description: GPIO pin to enable RS485 bus termination.
>      maxItems: 1
>  
> +  rs485-rx-during-tx-gpios:
> +    description: GPIO pin to control RS485 Rx enable during Tx.

Active state means do what? And inactive? This is an output gating the 
RX signal or an input telling the receiver what to do during tx? The 
description is not adequate.

How does this property relate to 'rs485-rx-during-tx' Any combination of 
the 2 being present or not is okay? If not, you need some constraints.

Rob