From: "Tomas Paukrt" <tomaspaukrt@email.cz>
To: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Jiri Slaby" <jirislaby@kernel.org>,
"Rob Herring" <robh+dt@kernel.org>,
"Krzysztof Kozlowski" <krzysztof.kozlowski+dt@linaro.org>,
"Conor Dooley" <conor+dt@kernel.org>
Cc: <linux-kernel@vger.kernel.org>, <linux-serial@vger.kernel.org>,
<devicetree@vger.kernel.org>
Subject: [PATCH v4 1/2] serial: core: Add support for enabling RS485 mode via GPIO at boot time
Date: Tue, 21 Nov 2023 09:28:10 +0100 (CET) [thread overview]
Message-ID: <3Za.ZZs}.ndXI8CMee4.1bN6eQ@seznam.cz> (raw)
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 "linux,rs485-mode-gpio".
Signed-off-by: Tomas Paukrt <tomaspaukrt@email.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, "linux,rs485-mode", GPIOD_IN);
+ if (IS_ERR(desc))
+ return dev_err_probe(dev, PTR_ERR(desc), "Cannot get linux,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
next reply other threads:[~2023-11-21 8:28 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-21 8:28 Tomas Paukrt [this message]
2023-11-23 14:18 ` Greg Kroah-Hartman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='3Za.ZZs}.ndXI8CMee4.1bN6eQ@seznam.cz' \
--to=tomaspaukrt@email.cz \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=jirislaby@kernel.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=robh+dt@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®