From: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
To: Martin Devera <devik@eaxlabs.cz>, <linux-kernel@vger.kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Rob Herring <robh+dt@kernel.org>,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
"Alexandre Torgue" <alexandre.torgue@st.com>,
Jiri Slaby <jirislaby@kernel.org>, Le Ray <erwan.leray@st.com>,
<linux-serial@vger.kernel.org>, <devicetree@vger.kernel.org>,
<linux-stm32@st-md-mailman.stormreply.com>,
<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH v3 2/2] tty/serial: Add rx-tx-swap OF option to stm32-usart
Date: Tue, 2 Mar 2021 18:44:26 +0100 [thread overview]
Message-ID: <aeefa74e-fa19-6c31-5240-0f14fca89298@foss.st.com> (raw)
In-Reply-To: <20210302131558.19375-2-devik@eaxlabs.cz>
On 3/2/21 2:15 PM, Martin Devera wrote:
> STM32 F7/H7 usarts supports RX & TX pin swapping.
> Add option to turn it on.
> Tested on STM32MP157.
>
> Signed-off-by: Martin Devera <devik@eaxlabs.cz>
> ---
> drivers/tty/serial/stm32-usart.c | 11 ++++++++++-
> drivers/tty/serial/stm32-usart.h | 5 +++++
> 2 files changed, 15 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/tty/serial/stm32-usart.c b/drivers/tty/serial/stm32-usart.c
> index b3675cf25a69..d390f7da1441 100644
> --- a/drivers/tty/serial/stm32-usart.c
> +++ b/drivers/tty/serial/stm32-usart.c
> @@ -644,6 +644,12 @@ static int stm32_usart_startup(struct uart_port *port)
> if (ret)
> return ret;
>
> + if (stm32_port->swap) {
> + val = readl_relaxed(port->membase + ofs->cr2);
> + val |= USART_CR2_SWAP;
> + writel_relaxed(val, port->membase + ofs->cr2);
> + }
> +
> /* RX FIFO Flush */
> if (ofs->rqr != UNDEF_REG)
> stm32_usart_set_bits(port, ofs->rqr, USART_RQR_RXFRQ);
> @@ -758,7 +764,7 @@ static void stm32_usart_set_termios(struct uart_port *port,
> cr1 = USART_CR1_TE | USART_CR1_RE;
> if (stm32_port->fifoen)
> cr1 |= USART_CR1_FIFOEN;
> - cr2 = 0;
> + cr2 = stm32_port->swap ? USART_CR2_SWAP : 0;
> cr3 = readl_relaxed(port->membase + ofs->cr3);
> cr3 &= USART_CR3_TXFTIE | USART_CR3_RXFTCFG_MASK | USART_CR3_RXFTIE
> | USART_CR3_TXFTCFG_MASK;
> @@ -1006,6 +1012,9 @@ static int stm32_usart_init_port(struct stm32_port *stm32port,
> return stm32port->wakeirq ? : -ENODEV;
> }
>
> + stm32port->swap = stm32port->info->cfg.has_swap &&
> + of_property_read_bool(pdev->dev.of_node, "rx-tx-swap");
> +
> stm32port->fifoen = stm32port->info->cfg.has_fifo;
>
> res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> diff --git a/drivers/tty/serial/stm32-usart.h b/drivers/tty/serial/stm32-usart.h
> index cb4f327c46db..bd18dd1c1bcd 100644
> --- a/drivers/tty/serial/stm32-usart.h
> +++ b/drivers/tty/serial/stm32-usart.h
> @@ -25,6 +25,7 @@ struct stm32_usart_offsets {
> struct stm32_usart_config {
> u8 uart_enable_bit; /* USART_CR1_UE */
> bool has_7bits_data;
> + bool has_swap;
> bool has_wakeup;
> bool has_fifo;
> int fifosize;
> @@ -55,6 +56,7 @@ struct stm32_usart_info stm32f4_info = {
> .cfg = {
> .uart_enable_bit = 13,
> .has_7bits_data = false,
> + .has_swap = false,
Hi Martin,
Only one minor comment from me here. No need to add a false (zero)
initialization in this struct. I'm not sure why this is the case for the
has_7bits_data here...
With that fixed, you can add my:
Acked-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
Thanks for your patch,
Best Regards,
Fabrice
> .fifosize = 1,
> }
> };
> @@ -76,6 +78,7 @@ struct stm32_usart_info stm32f7_info = {
> .cfg = {
> .uart_enable_bit = 0,
> .has_7bits_data = true,
> + .has_swap = true,
> .fifosize = 1,
> }
> };
> @@ -97,6 +100,7 @@ struct stm32_usart_info stm32h7_info = {
> .cfg = {
> .uart_enable_bit = 0,
> .has_7bits_data = true,
> + .has_swap = true,
> .has_wakeup = true,
> .has_fifo = true,
> .fifosize = 16,
> @@ -271,6 +275,7 @@ struct stm32_port {
> int last_res;
> bool tx_dma_busy; /* dma tx busy */
> bool hw_flow_control;
> + bool swap; /* swap RX & TX pins */
> bool fifoen;
> int wakeirq;
> int rdr_mask; /* receive data register mask */
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2021-03-03 17:05 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-29 16:05 [PATCH 1/2] tty/serial: Add st,swap OF option to stm32-usart Martin Devera
2020-02-29 16:05 ` [PATCH 2/2] dt-bindings: serial: Add st,swap " Martin Devera
2020-03-10 19:00 ` Rob Herring
2020-03-20 18:05 ` Rob Herring
2021-02-27 16:41 ` [PATCH v2 1/2] tty/serial: Add rx-tx-swap OF option " Martin Devera
2021-02-27 16:41 ` [PATCH v2 2/2] dt-bindings: serial: Add rx-tx-swap " Martin Devera
2021-03-01 10:36 ` Fabrice Gasnier
2021-03-01 10:28 ` [PATCH v2 1/2] tty/serial: Add rx-tx-swap OF option " Fabrice Gasnier
2021-03-01 22:40 ` Martin DEVERA
2021-03-02 10:20 ` Fabrice Gasnier
2021-03-02 13:15 ` [PATCH v3 1/2] dt-bindings: serial: Add rx-tx-swap " Martin Devera
2021-03-02 13:15 ` [PATCH v3 2/2] tty/serial: Add rx-tx-swap OF option " Martin Devera
2021-03-02 17:44 ` Fabrice Gasnier [this message]
2021-03-02 19:03 ` [PATCH v4 1/2] dt-bindings: serial: Add rx-tx-swap " Martin Devera
2021-03-02 19:03 ` [PATCH v4 2/2] tty/serial: Add rx-tx-swap OF option " Martin Devera
2021-03-03 16:06 ` Fabrice Gasnier
2021-03-03 17:23 ` [PATCH v4 1/2] dt-bindings: serial: Add rx-tx-swap " Fabrice Gasnier
2021-03-08 19:20 ` Rob Herring
2021-03-11 21:51 ` [PATCH v5 " Martin Devera
2021-03-11 21:51 ` [PATCH v5 2/2] tty/serial: Add rx-tx-swap OF option " Martin Devera
2021-03-12 8:15 ` Greg Kroah-Hartman
2021-03-12 10:27 ` [PATCH v6 1/2] dt-bindings: serial: Add rx-tx-swap " Martin Devera
2021-03-12 10:27 ` [PATCH v6 2/2] tty/serial: Add rx-tx-swap OF option " Martin Devera
2021-03-12 14:23 ` [PATCH v6 1/2] dt-bindings: serial: Add rx-tx-swap " Rob Herring
2021-03-12 14:56 ` Martin DEVERA
2021-03-12 15:03 ` Martin DEVERA
2021-03-12 15:37 ` [PATCH v7 " Martin Devera
2021-03-12 15:37 ` [PATCH v7 2/2] tty/serial: Add rx-tx-swap OF option " Martin Devera
2021-03-26 14:18 ` Greg Kroah-Hartman
2021-03-28 15:43 ` [PATCH v8 1/2] dt-bindings: serial: Add rx-tx-swap " Martin Devera
2021-03-28 15:43 ` [PATCH v8 2/2] tty/serial: Add rx-tx-swap OF option " Martin Devera
2021-03-23 22:30 ` [PATCH v7 1/2] dt-bindings: serial: Add rx-tx-swap " Rob Herring
2021-03-02 19:06 ` [PATCH v3 2/2] tty/serial: Add rx-tx-swap OF option " Martin DEVERA
2020-03-12 9:02 ` [PATCH 1/2] tty/serial: Add st,swap " 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=aeefa74e-fa19-6c31-5240-0f14fca89298@foss.st.com \
--to=fabrice.gasnier@foss.st.com \
--cc=alexandre.torgue@st.com \
--cc=devicetree@vger.kernel.org \
--cc=devik@eaxlabs.cz \
--cc=erwan.leray@st.com \
--cc=gregkh@linuxfoundation.org \
--cc=jirislaby@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=mcoquelin.stm32@gmail.com \
--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;
as well as URLs for NNTP newsgroup(s).