Re: [PATCH] serial: core: Add option to enable RS485 mode via GPIO

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On 15.11.23 at 21:07, Tomas Paukrt wrote:
> This patch provides an option to enable the RS485 mode at boot time
> based on the state of a GPIO pin (DIP switch or configuration jumper).
> The GPIO is defined by the device tree property "rs485-mode-gpio".

This needs documentation in rs485.yaml.

>
> Signed-off-by: Tomas Paukrt <tomaspaukrt@xxxxxxxx>
> ---
>  drivers/tty/serial/serial_core.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
>
> diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
> index f1348a5..444d7fd 100644
> --- a/drivers/tty/serial/serial_core.c
> +++ b/drivers/tty/serial/serial_core.c
> @@ -3603,6 +3603,18 @@ int uart_get_rs485_mode(struct uart_port *port)
>  	}
>
>  	/*
> +	 * Enable the RS485 mode based on the state of a GPIO pin.
> +	 */
> +	desc = devm_gpiod_get_optional(dev, "rs485-mode", GPIOD_IN);
> +	if (IS_ERR(desc))
> +		return dev_err_probe(dev, PTR_ERR(desc), "Cannot get rs485-mode-gpio\n");
> +	if (desc) {
> +		if (gpiod_get_value(desc))
> +			rs485conf->flags |= SER_RS485_ENABLED;
> +		devm_gpiod_put(dev, desc);
> +	}

So this means RS485 cannot be disabled any more after that. Then we must not allow
to unset SER_RS485_ENABLED if userspace tries to do so via TIOCSRS485.

Regards,
Lino





[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux PPP]     [Linux FS]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Linmodem]     [Device Mapper]     [Linux Kernel for ARM]

  Powered by Linux