Commit 163f080e authored by Christoph Niedermaier's avatar Christoph Niedermaier Committed by Greg Kroah-Hartman

serial: core: Add option to output RS485 RX_DURING_TX state via GPIO

This patch provides a generic GPIO variable for outputting the state
of RS485 RX_DURING_TX. The GPIO is defined by the devicetree property
"rs485-rx-during-tx-gpios". To use it in a low level serial driver,
the evaluation of this variable must be implemented there accordingly.
Signed-off-by: default avatarChristoph Niedermaier <cniedermaier@dh-electronics.com>
Link: https://lore.kernel.org/r/20221202104127.122761-2-cniedermaier@dh-electronics.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 45c1d967
...@@ -3410,6 +3410,7 @@ int uart_get_rs485_mode(struct uart_port *port) ...@@ -3410,6 +3410,7 @@ int uart_get_rs485_mode(struct uart_port *port)
struct device *dev = port->dev; struct device *dev = port->dev;
u32 rs485_delay[2]; u32 rs485_delay[2];
int ret; int ret;
int rx_during_tx_gpio_flag;
ret = device_property_read_u32_array(dev, "rs485-rts-delay", ret = device_property_read_u32_array(dev, "rs485-rts-delay",
rs485_delay, 2); rs485_delay, 2);
...@@ -3458,6 +3459,17 @@ int uart_get_rs485_mode(struct uart_port *port) ...@@ -3458,6 +3459,17 @@ int uart_get_rs485_mode(struct uart_port *port)
if (port->rs485_term_gpio) if (port->rs485_term_gpio)
port->rs485_supported.flags |= SER_RS485_TERMINATE_BUS; port->rs485_supported.flags |= SER_RS485_TERMINATE_BUS;
rx_during_tx_gpio_flag = (rs485conf->flags & SER_RS485_RX_DURING_TX) ?
GPIOD_OUT_HIGH : GPIOD_OUT_LOW;
port->rs485_rx_during_tx_gpio = devm_gpiod_get_optional(dev,
"rs485-rx-during-tx",
rx_during_tx_gpio_flag);
if (IS_ERR(port->rs485_rx_during_tx_gpio)) {
ret = PTR_ERR(port->rs485_rx_during_tx_gpio);
port->rs485_rx_during_tx_gpio = NULL;
return dev_err_probe(dev, ret, "Cannot get rs485-rx-during-tx-gpios\n");
}
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(uart_get_rs485_mode); EXPORT_SYMBOL_GPL(uart_get_rs485_mode);
......
...@@ -579,6 +579,7 @@ struct uart_port { ...@@ -579,6 +579,7 @@ struct uart_port {
struct serial_rs485 rs485; struct serial_rs485 rs485;
struct serial_rs485 rs485_supported; /* Supported mask for serial_rs485 */ struct serial_rs485 rs485_supported; /* Supported mask for serial_rs485 */
struct gpio_desc *rs485_term_gpio; /* enable RS485 bus termination */ struct gpio_desc *rs485_term_gpio; /* enable RS485 bus termination */
struct gpio_desc *rs485_rx_during_tx_gpio; /* Output GPIO that sets the state of RS485 RX during TX */
struct serial_iso7816 iso7816; struct serial_iso7816 iso7816;
void *private_data; /* generic platform data pointer */ void *private_data; /* generic platform data pointer */
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment