mbox series

[V9,0/3] Add rs485 support to uartps driver

Message ID 20240118074003.2334348-1-manikanta.guntupalli@amd.com
Headers show
Series Add rs485 support to uartps driver | expand

Message

Manikanta Guntupalli Jan. 18, 2024, 7:40 a.m. UTC
Add reference to rs485.yaml.
Add rs485 support to uartps driver.
---
Changes for V2:
Modify optional gpio name to xlnx,phy-ctrl-gpios.
Update commit description.
Add support for RTS, delay_rts_before_send and delay_rts_after_send in RS485 mode.

Changes for V3:
Modify optional gpio name to rts-gpios.
Update commit description.
Move cdns_uart_tx_empty function to avoid prototype statement.
Remove assignment of struct serial_rs485 to port->rs485 as
serial core performs that.
Switch to native RTS in non GPIO case.
Handle rs485 during stop tx.
Remove explicit calls to configure gpio direction and value,
as devm_gpiod_get_optional performs that by using GPIOD_OUT_LOW argument.
Update implementation to support configuration of GPIO/RTS value
based on user configuration of SER_RS485_RTS_ON_SEND and
SER_RS485_RTS_AFTER_SEND. Move implementation to start_tx from handle_tx.

Changes for V4:
Update rts-gpios description.
Create separate patch for cdns_uart_tx_empty relocation.
Call cdns_rs485_rx_setup() before uart_add_one_port() in probe.
Update gpio descriptor name to gpiod_rts.
Instead of cdns_rs485_config_gpio_rts_high() and
cdns_rs485_config_gpio_rts_low() functions for RTS/GPIO value
configuration implement cdns_rts_gpio_enable().
Disable auto rts and call cdns_uart_stop_tx() from cdns_rs485_config.
Use timer instead of mdelay for delay_rts_before_send and delay_rts_after_send.
Update cdns_uart_set_mctrl to support GPIO/RTS.

Changes for V5:
Remove rts-gpios description.
Update commit message and description.

Changes for V6:
Update commit description.
Disable the TX and RX in cdns_rs485_config() when rs485 disabled.
Hold lock for cdns_uart_handle_tx() in cdns_rs485_tx_callback().

Changes for V7:
Update commit description.

Changes for V8:
Use hrtimer instead of timer list.
Simplify cdns_rs485_tx_setup() and cdns_rs485_rx_setup().
Update argument of cdns_rts_gpio_enable() in cdns_uart_set_mctrl().
Add cdns_calc_after_tx_delay() to calculate required delay after tx.
Add hrtimer setup in cdns_rs485_config().
Move enable TX Empty interrupt and rs485 rx callback scheduling part to
cdns_uart_handle_tx().

Changes for V9:
Update return check with uart_tx_stopped() in cdns_uart_handle_tx().
Update description of cdns_uart_handle_tx() and add clear TX Empty interrupt
comment cdns_uart_start_tx().
Remove stop tx timer.
Remove hrtimer_cancel() call from cdns_uart_start_tx().
Handle gpio case separately in cdns_uart_set_mctrl().
Move hrtimer_cancel() call from below to above in cdns_uart_shutdown().

Manikanta Guntupalli (3):
  dt-bindings: Add reference to rs485.yaml
  tty: serial: uartps: Relocate cdns_uart_tx_empty to facilitate rs485
  tty: serial: uartps: Add rs485 support to uartps driver

 .../devicetree/bindings/serial/cdns,uart.yaml |   1 +
 drivers/tty/serial/xilinx_uartps.c            | 235 ++++++++++++++++--
 2 files changed, 215 insertions(+), 21 deletions(-)

Comments

Maarten Brock Jan. 22, 2024, 4:49 p.m. UTC | #1
> -----Original Message-----
> From: Manikanta Guntupalli <manikanta.guntupalli@amd.com>
> Sent: Thursday, 18 January 2024 08:40
> Subject: [PATCH V9 2/3] tty: serial: uartps: Relocate cdns_uart_tx_empty to
> facilitate rs485
> 
> Relocate cdns_uart_tx_empty function to avoid prototype statement in
> rs485 changes.
> Update return check with uart_tx_stopped() in cdns_uart_handle_tx().
> 
> Signed-off-by: Manikanta Guntupalli <manikanta.guntupalli@amd.com>
> ---
> --- a/drivers/tty/serial/xilinx_uartps.c
> +++ b/drivers/tty/serial/xilinx_uartps.c
> @@ -316,7 +331,7 @@ static void cdns_uart_handle_tx(void *dev_id)
>  	struct circ_buf *xmit = &port->state->xmit;
>  	unsigned int numbytes;
> 
> -	if (uart_circ_empty(xmit)) {
> +	if (uart_circ_empty(xmit) || uart_tx_stopped(port)) {

Can you please also insert a comment here?
+ 		/* Disable the TX Empty interrupt */

>  		writel(CDNS_UART_IXR_TXEMPTY, port->membase +
> CDNS_UART_IDR);
>  		return;
>  	}
 
Kind regards,
Maarten Brock