[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <3Nj.ZZr}.5RaPRe7D8AB.1bMzDm@seznam.cz>
Date: Mon, 20 Nov 2023 22:45:20 +0100 (CET)
From: "Tomas Paukrt" <tomaspaukrt@...il.cz>
To: "Krzysztof Kozlowski" <krzk@...nel.org>,
"Rob Herring" <robh+dt@...nel.org>,
"Conor Dooley" <conor+dt@...nel.org>,
"Greg Kroah-Hartman" <gregkh@...uxfoundation.org>,
"Jiri Slaby" <jirislaby@...nel.org>
Cc: <linux-serial@...r.kernel.org>,
"Lino Sanfilippo" <LinoSanfilippo@....de>,
<linux-kernel@...r.kernel.org>, <devicetree@...r.kernel.org>
Subject: Re: [PATCH v3 1/2] serial: core: Add option to enable RS485 mode via GPIO
Add 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".
Signed-off-by: Tomas Paukrt <tomaspaukrt@...il.cz>
---
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..f1bf0b9 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);
+ }
+
+ /*
* Disabling termination by default is the safe choice: Else if many
* bus participants enable it, no communication is possible at all.
* Works fine for short cables and users may enable for longer cables.
--
2.7.4
Powered by blists - more mailing lists