diff options
author | Martin Devera <devik@eaxlabs.cz> | 2021-03-28 18:43:06 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2021-04-05 13:06:52 +0300 |
commit | 3cd66593725a234662955baaf78d2ce5333de56d (patch) | |
tree | 23ec4270a758fc328c50ed92cb659b2439db3795 /drivers/tty/serial/stm32-usart.c | |
parent | 1b8dc3988dd204aef296047a02364b5ad823f1b4 (diff) | |
download | linux-3cd66593725a234662955baaf78d2ce5333de56d.tar.xz |
tty/serial: Add rx-tx-swap OF option to stm32-usart
STM32 F7/H7 usarts supports RX & TX pin swapping.
Add option to turn it on.
Tested on STM32MP157.
Acked-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
Signed-off-by: Martin Devera <devik@eaxlabs.cz>
Link: https://lore.kernel.org/r/20210328154306.22674-2-devik@eaxlabs.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/serial/stm32-usart.c')
-rw-r--r-- | drivers/tty/serial/stm32-usart.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/drivers/tty/serial/stm32-usart.c b/drivers/tty/serial/stm32-usart.c index cba4f4ddf164..4d277804c63e 100644 --- a/drivers/tty/serial/stm32-usart.c +++ b/drivers/tty/serial/stm32-usart.c @@ -671,6 +671,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) writel_relaxed(USART_RQR_RXFRQ, port->membase + ofs->rqr); @@ -789,7 +795,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; /* Tx and RX FIFO configuration */ cr3 = readl_relaxed(port->membase + ofs->cr3); @@ -1047,6 +1053,9 @@ static int stm32_usart_init_port(struct stm32_port *stm32port, stm32port->wakeup_src = stm32port->info->cfg.has_wakeup && of_property_read_bool(pdev->dev.of_node, "wakeup-source"); + 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); |