Message ID | 20221201110237.7917-4-cniedermaier@dh-electronics.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [V3,1/4] dt-bindings: serial: rs485: Add GPIO controlling RX enable during TX | expand |
On Thu, 1 Dec 2022, Christoph Niedermaier wrote: > If a RX_DURING_TX GPIO is defined by the DT property "rs485-rx-during-tx-gpios" > this patch switches this GPIO accordingly to the RS485 flag RX_DURING_TX in user > space. Controlled by this GPIO, now the hardware is responsible for connecting > or disconnecting RX during TX. > > Signed-off-by: Christoph Niedermaier <cniedermaier@dh-electronics.com> > --- > Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> > Cc: Jiri Slaby <jirislaby@kernel.org> > Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com> > Cc: Alexandre Torgue <alexandre.torgue@foss.st.com> > Cc: Alexander Dahl <ada@thorsis.com> > Cc: Marek Vasut <marex@denx.de> > Cc: kernel@dh-electronics.com > Cc: linux-stm32@st-md-mailman.stormreply.com > To: linux-serial@vger.kernel.org > To: linux-arm-kernel@lists.infradead.org > --- > V2: - Rework of the commit message > V3: - No changes > --- > drivers/tty/serial/stm32-usart.c | 9 ++++++++- > 1 file changed, 8 insertions(+), 1 deletion(-) > > diff --git a/drivers/tty/serial/stm32-usart.c b/drivers/tty/serial/stm32-usart.c > index a1490033aa16..0f2cca9054ba 100644 > --- a/drivers/tty/serial/stm32-usart.c > +++ b/drivers/tty/serial/stm32-usart.c > @@ -226,7 +226,14 @@ static int stm32_usart_config_rs485(struct uart_port *port, struct ktermios *ter > > stm32_usart_clr_bits(port, ofs->cr1, BIT(cfg->uart_enable_bit)); > > - rs485conf->flags |= SER_RS485_RX_DURING_TX; > + if (port->rs485_rx_during_tx_gpio) { > + if (rs485conf->flags & SER_RS485_RX_DURING_TX) > + gpiod_set_value_cansleep(port->rs485_rx_during_tx_gpio, 1); > + else > + gpiod_set_value_cansleep(port->rs485_rx_during_tx_gpio, 0); gpiod_set_value_cansleep(port->rs485_rx_during_tx_gpio, !!(rs485conf->flags & SER_RS485_RX_DURING_TX)); And the same comment also for the other patch.
diff --git a/drivers/tty/serial/stm32-usart.c b/drivers/tty/serial/stm32-usart.c index a1490033aa16..0f2cca9054ba 100644 --- a/drivers/tty/serial/stm32-usart.c +++ b/drivers/tty/serial/stm32-usart.c @@ -226,7 +226,14 @@ static int stm32_usart_config_rs485(struct uart_port *port, struct ktermios *ter stm32_usart_clr_bits(port, ofs->cr1, BIT(cfg->uart_enable_bit)); - rs485conf->flags |= SER_RS485_RX_DURING_TX; + if (port->rs485_rx_during_tx_gpio) { + if (rs485conf->flags & SER_RS485_RX_DURING_TX) + gpiod_set_value_cansleep(port->rs485_rx_during_tx_gpio, 1); + else + gpiod_set_value_cansleep(port->rs485_rx_during_tx_gpio, 0); + } else { + rs485conf->flags |= SER_RS485_RX_DURING_TX; + } if (rs485conf->flags & SER_RS485_ENABLED) { cr1 = readl_relaxed(port->membase + ofs->cr1);
If a RX_DURING_TX GPIO is defined by the DT property "rs485-rx-during-tx-gpios" this patch switches this GPIO accordingly to the RS485 flag RX_DURING_TX in user space. Controlled by this GPIO, now the hardware is responsible for connecting or disconnecting RX during TX. Signed-off-by: Christoph Niedermaier <cniedermaier@dh-electronics.com> --- Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Jiri Slaby <jirislaby@kernel.org> Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com> Cc: Alexandre Torgue <alexandre.torgue@foss.st.com> Cc: Alexander Dahl <ada@thorsis.com> Cc: Marek Vasut <marex@denx.de> Cc: kernel@dh-electronics.com Cc: linux-stm32@st-md-mailman.stormreply.com To: linux-serial@vger.kernel.org To: linux-arm-kernel@lists.infradead.org --- V2: - Rework of the commit message V3: - No changes --- drivers/tty/serial/stm32-usart.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)