* [PATCH v4 1/2] dt-bindings: serial: Add rx-tx-swap to stm32-usart
@ 2021-03-02 19:03 ` Martin Devera
0 siblings, 0 replies; 69+ messages in thread
From: Martin Devera @ 2021-03-02 19:03 UTC (permalink / raw)
To: linux-kernel
Cc: Martin Devera, Greg Kroah-Hartman, Rob Herring, Maxime Coquelin,
Alexandre Torgue, Jiri Slaby, Le Ray, fabrice.gasnier,
linux-serial, devicetree, linux-stm32, linux-arm-kernel
Add new rx-tx-swap property to allow for RX & TX pin swapping.
Signed-off-by: Martin Devera <devik@eaxlabs.cz>
---
.../devicetree/bindings/serial/st,stm32-uart.yaml | 32 +++++++++++++++-------
1 file changed, 22 insertions(+), 10 deletions(-)
diff --git a/Documentation/devicetree/bindings/serial/st,stm32-uart.yaml b/Documentation/devicetree/bindings/serial/st,stm32-uart.yaml
index 8631678283f9..6eab2debebb5 100644
--- a/Documentation/devicetree/bindings/serial/st,stm32-uart.yaml
+++ b/Documentation/devicetree/bindings/serial/st,stm32-uart.yaml
@@ -9,9 +9,6 @@ maintainers:
title: STMicroelectronics STM32 USART bindings
-allOf:
- - $ref: rs485.yaml
-
properties:
compatible:
enum:
@@ -40,6 +37,10 @@ properties:
uart-has-rtscts: true
+ rx-tx-swap:
+ type: boolean
+ maxItems: 1
+
dmas:
minItems: 1
maxItems: 2
@@ -66,13 +67,24 @@ properties:
linux,rs485-enabled-at-boot-time: true
rs485-rx-during-tx: true
-if:
- required:
- - st,hw-flow-ctrl
-then:
- properties:
- cts-gpios: false
- rts-gpios: false
+allOf:
+ - $ref: rs485.yaml
+ - if:
+ required:
+ - st,hw-flow-ctrl
+ then:
+ properties:
+ cts-gpios: false
+ rts-gpios: false
+ - if:
+ required:
+ - rx-tx-swap
+ then:
+ properties:
+ compatible:
+ enum:
+ - st,stm32f7-uart
+ - st,stm32h7-uart
required:
- compatible
--
2.11.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [PATCH v4 2/2] tty/serial: Add rx-tx-swap OF option to stm32-usart
2021-03-02 19:03 ` Martin Devera
@ 2021-03-02 19:03 ` Martin Devera
-1 siblings, 0 replies; 69+ messages in thread
From: Martin Devera @ 2021-03-02 19:03 UTC (permalink / raw)
To: linux-kernel
Cc: Martin Devera, Greg Kroah-Hartman, Rob Herring, Maxime Coquelin,
Alexandre Torgue, Jiri Slaby, Le Ray, fabrice.gasnier,
linux-serial, devicetree, linux-stm32, linux-arm-kernel
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 | 4 ++++
2 files changed, 14 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..a85391e71e8e 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;
@@ -76,6 +77,7 @@ struct stm32_usart_info stm32f7_info = {
.cfg = {
.uart_enable_bit = 0,
.has_7bits_data = true,
+ .has_swap = true,
.fifosize = 1,
}
};
@@ -97,6 +99,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 +274,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 */
--
2.11.0
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [PATCH v4 2/2] tty/serial: Add rx-tx-swap OF option to stm32-usart
@ 2021-03-02 19:03 ` Martin Devera
0 siblings, 0 replies; 69+ messages in thread
From: Martin Devera @ 2021-03-02 19:03 UTC (permalink / raw)
To: linux-kernel
Cc: Martin Devera, Greg Kroah-Hartman, Rob Herring, Maxime Coquelin,
Alexandre Torgue, Jiri Slaby, Le Ray, fabrice.gasnier,
linux-serial, devicetree, linux-stm32, linux-arm-kernel
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 | 4 ++++
2 files changed, 14 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..a85391e71e8e 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;
@@ -76,6 +77,7 @@ struct stm32_usart_info stm32f7_info = {
.cfg = {
.uart_enable_bit = 0,
.has_7bits_data = true,
+ .has_swap = true,
.fifosize = 1,
}
};
@@ -97,6 +99,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 +274,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 */
--
2.11.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 69+ messages in thread
* Re: [PATCH v4 2/2] tty/serial: Add rx-tx-swap OF option to stm32-usart
2021-03-02 19:03 ` Martin Devera
@ 2021-03-03 16:06 ` Fabrice Gasnier
-1 siblings, 0 replies; 69+ messages in thread
From: Fabrice Gasnier @ 2021-03-03 16:06 UTC (permalink / raw)
To: Martin Devera, linux-kernel
Cc: Greg Kroah-Hartman, Rob Herring, Maxime Coquelin,
Alexandre Torgue, Jiri Slaby, Le Ray, linux-serial, devicetree,
linux-stm32, linux-arm-kernel
On 3/2/21 8:03 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 | 4 ++++
> 2 files changed, 14 insertions(+), 1 deletion(-)
Hi Martin,
You can add my:
Acked-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
Thanks for your patch,
Best Regards,
Fabrice
>
> 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..a85391e71e8e 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;
> @@ -76,6 +77,7 @@ struct stm32_usart_info stm32f7_info = {
> .cfg = {
> .uart_enable_bit = 0,
> .has_7bits_data = true,
> + .has_swap = true,
> .fifosize = 1,
> }
> };
> @@ -97,6 +99,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 +274,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 */
>
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH v4 2/2] tty/serial: Add rx-tx-swap OF option to stm32-usart
@ 2021-03-03 16:06 ` Fabrice Gasnier
0 siblings, 0 replies; 69+ messages in thread
From: Fabrice Gasnier @ 2021-03-03 16:06 UTC (permalink / raw)
To: Martin Devera, linux-kernel
Cc: Greg Kroah-Hartman, Rob Herring, Maxime Coquelin,
Alexandre Torgue, Jiri Slaby, Le Ray, linux-serial, devicetree,
linux-stm32, linux-arm-kernel
On 3/2/21 8:03 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 | 4 ++++
> 2 files changed, 14 insertions(+), 1 deletion(-)
Hi Martin,
You can add my:
Acked-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
Thanks for your patch,
Best Regards,
Fabrice
>
> 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..a85391e71e8e 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;
> @@ -76,6 +77,7 @@ struct stm32_usart_info stm32f7_info = {
> .cfg = {
> .uart_enable_bit = 0,
> .has_7bits_data = true,
> + .has_swap = true,
> .fifosize = 1,
> }
> };
> @@ -97,6 +99,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 +274,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
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH v4 1/2] dt-bindings: serial: Add rx-tx-swap to stm32-usart
2021-03-02 19:03 ` Martin Devera
@ 2021-03-03 17:23 ` Fabrice Gasnier
-1 siblings, 0 replies; 69+ messages in thread
From: Fabrice Gasnier @ 2021-03-03 17:23 UTC (permalink / raw)
To: Martin Devera, linux-kernel
Cc: Greg Kroah-Hartman, Rob Herring, Maxime Coquelin,
Alexandre Torgue, Jiri Slaby, Le Ray, linux-serial, devicetree,
linux-stm32, linux-arm-kernel
On 3/2/21 8:03 PM, Martin Devera wrote:
> Add new rx-tx-swap property to allow for RX & TX pin swapping.
>
> Signed-off-by: Martin Devera <devik@eaxlabs.cz>
> ---
> .../devicetree/bindings/serial/st,stm32-uart.yaml | 32 +++++++++++++++-------
> 1 file changed, 22 insertions(+), 10 deletions(-)
>
Hi Martin,
I'm only wondering on moving the allOf and the st,hw-flow-ctrl prop. But
others may comment on this.
Feel free to add my:
Acked-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
Thanks!
Fabrice
> diff --git a/Documentation/devicetree/bindings/serial/st,stm32-uart.yaml b/Documentation/devicetree/bindings/serial/st,stm32-uart.yaml
> index 8631678283f9..6eab2debebb5 100644
> --- a/Documentation/devicetree/bindings/serial/st,stm32-uart.yaml
> +++ b/Documentation/devicetree/bindings/serial/st,stm32-uart.yaml
> @@ -9,9 +9,6 @@ maintainers:
>
> title: STMicroelectronics STM32 USART bindings
>
> -allOf:
> - - $ref: rs485.yaml
> -
> properties:
> compatible:
> enum:
> @@ -40,6 +37,10 @@ properties:
>
> uart-has-rtscts: true
>
> + rx-tx-swap:
> + type: boolean
> + maxItems: 1
> +
> dmas:
> minItems: 1
> maxItems: 2
> @@ -66,13 +67,24 @@ properties:
> linux,rs485-enabled-at-boot-time: true
> rs485-rx-during-tx: true
>
> -if:
> - required:
> - - st,hw-flow-ctrl
> -then:
> - properties:
> - cts-gpios: false
> - rts-gpios: false
> +allOf:
> + - $ref: rs485.yaml
> + - if:
> + required:
> + - st,hw-flow-ctrl
> + then:
> + properties:
> + cts-gpios: false
> + rts-gpios: false
> + - if:
> + required:
> + - rx-tx-swap
> + then:
> + properties:
> + compatible:
> + enum:
> + - st,stm32f7-uart
> + - st,stm32h7-uart
>
> required:
> - compatible
>
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH v4 1/2] dt-bindings: serial: Add rx-tx-swap to stm32-usart
@ 2021-03-03 17:23 ` Fabrice Gasnier
0 siblings, 0 replies; 69+ messages in thread
From: Fabrice Gasnier @ 2021-03-03 17:23 UTC (permalink / raw)
To: Martin Devera, linux-kernel
Cc: Greg Kroah-Hartman, Rob Herring, Maxime Coquelin,
Alexandre Torgue, Jiri Slaby, Le Ray, linux-serial, devicetree,
linux-stm32, linux-arm-kernel
On 3/2/21 8:03 PM, Martin Devera wrote:
> Add new rx-tx-swap property to allow for RX & TX pin swapping.
>
> Signed-off-by: Martin Devera <devik@eaxlabs.cz>
> ---
> .../devicetree/bindings/serial/st,stm32-uart.yaml | 32 +++++++++++++++-------
> 1 file changed, 22 insertions(+), 10 deletions(-)
>
Hi Martin,
I'm only wondering on moving the allOf and the st,hw-flow-ctrl prop. But
others may comment on this.
Feel free to add my:
Acked-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
Thanks!
Fabrice
> diff --git a/Documentation/devicetree/bindings/serial/st,stm32-uart.yaml b/Documentation/devicetree/bindings/serial/st,stm32-uart.yaml
> index 8631678283f9..6eab2debebb5 100644
> --- a/Documentation/devicetree/bindings/serial/st,stm32-uart.yaml
> +++ b/Documentation/devicetree/bindings/serial/st,stm32-uart.yaml
> @@ -9,9 +9,6 @@ maintainers:
>
> title: STMicroelectronics STM32 USART bindings
>
> -allOf:
> - - $ref: rs485.yaml
> -
> properties:
> compatible:
> enum:
> @@ -40,6 +37,10 @@ properties:
>
> uart-has-rtscts: true
>
> + rx-tx-swap:
> + type: boolean
> + maxItems: 1
> +
> dmas:
> minItems: 1
> maxItems: 2
> @@ -66,13 +67,24 @@ properties:
> linux,rs485-enabled-at-boot-time: true
> rs485-rx-during-tx: true
>
> -if:
> - required:
> - - st,hw-flow-ctrl
> -then:
> - properties:
> - cts-gpios: false
> - rts-gpios: false
> +allOf:
> + - $ref: rs485.yaml
> + - if:
> + required:
> + - st,hw-flow-ctrl
> + then:
> + properties:
> + cts-gpios: false
> + rts-gpios: false
> + - if:
> + required:
> + - rx-tx-swap
> + then:
> + properties:
> + compatible:
> + enum:
> + - st,stm32f7-uart
> + - st,stm32h7-uart
>
> required:
> - compatible
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH v4 1/2] dt-bindings: serial: Add rx-tx-swap to stm32-usart
2021-03-02 19:03 ` Martin Devera
@ 2021-03-08 19:20 ` Rob Herring
-1 siblings, 0 replies; 69+ messages in thread
From: Rob Herring @ 2021-03-08 19:20 UTC (permalink / raw)
To: Martin Devera
Cc: linux-kernel, Greg Kroah-Hartman, Maxime Coquelin,
Alexandre Torgue, Jiri Slaby, Le Ray, fabrice.gasnier,
linux-serial, devicetree, linux-stm32, linux-arm-kernel
On Tue, Mar 02, 2021 at 08:03:02PM +0100, Martin Devera wrote:
> Add new rx-tx-swap property to allow for RX & TX pin swapping.
>
> Signed-off-by: Martin Devera <devik@eaxlabs.cz>
> ---
> .../devicetree/bindings/serial/st,stm32-uart.yaml | 32 +++++++++++++++-------
> 1 file changed, 22 insertions(+), 10 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/serial/st,stm32-uart.yaml b/Documentation/devicetree/bindings/serial/st,stm32-uart.yaml
> index 8631678283f9..6eab2debebb5 100644
> --- a/Documentation/devicetree/bindings/serial/st,stm32-uart.yaml
> +++ b/Documentation/devicetree/bindings/serial/st,stm32-uart.yaml
> @@ -9,9 +9,6 @@ maintainers:
>
> title: STMicroelectronics STM32 USART bindings
>
> -allOf:
> - - $ref: rs485.yaml
> -
> properties:
> compatible:
> enum:
> @@ -40,6 +37,10 @@ properties:
>
> uart-has-rtscts: true
>
> + rx-tx-swap:
> + type: boolean
> + maxItems: 1
Type is boolean, but 'maxItems' applies to arrays.
In any case, this is already defined in serial.yaml, so just
'rx-tx-swap: true' here.
> +
> dmas:
> minItems: 1
> maxItems: 2
> @@ -66,13 +67,24 @@ properties:
> linux,rs485-enabled-at-boot-time: true
> rs485-rx-during-tx: true
>
> -if:
> - required:
> - - st,hw-flow-ctrl
> -then:
> - properties:
> - cts-gpios: false
> - rts-gpios: false
> +allOf:
And add '- $ref: serial.yaml#' here.
> + - $ref: rs485.yaml
> + - if:
> + required:
> + - st,hw-flow-ctrl
> + then:
> + properties:
> + cts-gpios: false
> + rts-gpios: false
> + - if:
> + required:
> + - rx-tx-swap
> + then:
> + properties:
> + compatible:
> + enum:
> + - st,stm32f7-uart
> + - st,stm32h7-uart
The normal pattern is the 'if' has compatible. You can put the other
compatible strings in the if, and then 'then' is:
then:
properties:
rx-tx-swap: false
Rob
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH v4 1/2] dt-bindings: serial: Add rx-tx-swap to stm32-usart
@ 2021-03-08 19:20 ` Rob Herring
0 siblings, 0 replies; 69+ messages in thread
From: Rob Herring @ 2021-03-08 19:20 UTC (permalink / raw)
To: Martin Devera
Cc: linux-kernel, Greg Kroah-Hartman, Maxime Coquelin,
Alexandre Torgue, Jiri Slaby, Le Ray, fabrice.gasnier,
linux-serial, devicetree, linux-stm32, linux-arm-kernel
On Tue, Mar 02, 2021 at 08:03:02PM +0100, Martin Devera wrote:
> Add new rx-tx-swap property to allow for RX & TX pin swapping.
>
> Signed-off-by: Martin Devera <devik@eaxlabs.cz>
> ---
> .../devicetree/bindings/serial/st,stm32-uart.yaml | 32 +++++++++++++++-------
> 1 file changed, 22 insertions(+), 10 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/serial/st,stm32-uart.yaml b/Documentation/devicetree/bindings/serial/st,stm32-uart.yaml
> index 8631678283f9..6eab2debebb5 100644
> --- a/Documentation/devicetree/bindings/serial/st,stm32-uart.yaml
> +++ b/Documentation/devicetree/bindings/serial/st,stm32-uart.yaml
> @@ -9,9 +9,6 @@ maintainers:
>
> title: STMicroelectronics STM32 USART bindings
>
> -allOf:
> - - $ref: rs485.yaml
> -
> properties:
> compatible:
> enum:
> @@ -40,6 +37,10 @@ properties:
>
> uart-has-rtscts: true
>
> + rx-tx-swap:
> + type: boolean
> + maxItems: 1
Type is boolean, but 'maxItems' applies to arrays.
In any case, this is already defined in serial.yaml, so just
'rx-tx-swap: true' here.
> +
> dmas:
> minItems: 1
> maxItems: 2
> @@ -66,13 +67,24 @@ properties:
> linux,rs485-enabled-at-boot-time: true
> rs485-rx-during-tx: true
>
> -if:
> - required:
> - - st,hw-flow-ctrl
> -then:
> - properties:
> - cts-gpios: false
> - rts-gpios: false
> +allOf:
And add '- $ref: serial.yaml#' here.
> + - $ref: rs485.yaml
> + - if:
> + required:
> + - st,hw-flow-ctrl
> + then:
> + properties:
> + cts-gpios: false
> + rts-gpios: false
> + - if:
> + required:
> + - rx-tx-swap
> + then:
> + properties:
> + compatible:
> + enum:
> + - st,stm32f7-uart
> + - st,stm32h7-uart
The normal pattern is the 'if' has compatible. You can put the other
compatible strings in the if, and then 'then' is:
then:
properties:
rx-tx-swap: false
Rob
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 69+ messages in thread
* [PATCH v5 1/2] dt-bindings: serial: Add rx-tx-swap to stm32-usart
2021-03-08 19:20 ` Rob Herring
@ 2021-03-11 21:51 ` Martin Devera
-1 siblings, 0 replies; 69+ messages in thread
From: Martin Devera @ 2021-03-11 21:51 UTC (permalink / raw)
To: linux-kernel
Cc: Martin Devera, Greg Kroah-Hartman, Rob Herring, Maxime Coquelin,
Alexandre Torgue, Jiri Slaby, Le Ray, fabrice.gasnier,
linux-serial, devicetree, linux-stm32, linux-arm-kernel
Add new rx-tx-swap property to allow for RX & TX pin swapping.
Signed-off-by: Martin Devera <devik@eaxlabs.cz>
Acked-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
---
.../devicetree/bindings/serial/st,stm32-uart.yaml | 29 ++++++++++++++--------
1 file changed, 19 insertions(+), 10 deletions(-)
diff --git a/Documentation/devicetree/bindings/serial/st,stm32-uart.yaml b/Documentation/devicetree/bindings/serial/st,stm32-uart.yaml
index 8631678283f9..68a0f3ce8328 100644
--- a/Documentation/devicetree/bindings/serial/st,stm32-uart.yaml
+++ b/Documentation/devicetree/bindings/serial/st,stm32-uart.yaml
@@ -9,9 +9,6 @@ maintainers:
title: STMicroelectronics STM32 USART bindings
-allOf:
- - $ref: rs485.yaml
-
properties:
compatible:
enum:
@@ -40,6 +37,8 @@ properties:
uart-has-rtscts: true
+ rx-tx-swap: true
+
dmas:
minItems: 1
maxItems: 2
@@ -66,13 +65,23 @@ properties:
linux,rs485-enabled-at-boot-time: true
rs485-rx-during-tx: true
-if:
- required:
- - st,hw-flow-ctrl
-then:
- properties:
- cts-gpios: false
- rts-gpios: false
+allOf:
+ - $ref: rs485.yaml#
+ - $ref: serial.yaml#
+ - if:
+ required:
+ - st,hw-flow-ctrl
+ then:
+ properties:
+ cts-gpios: false
+ rts-gpios: false
+ - if:
+ properties:
+ compatible:
+ const: st,stm32-uart
+ then:
+ properties:
+ rx-tx-swap: false
required:
- compatible
--
2.11.0
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [PATCH v5 1/2] dt-bindings: serial: Add rx-tx-swap to stm32-usart
@ 2021-03-11 21:51 ` Martin Devera
0 siblings, 0 replies; 69+ messages in thread
From: Martin Devera @ 2021-03-11 21:51 UTC (permalink / raw)
To: linux-kernel
Cc: Martin Devera, Greg Kroah-Hartman, Rob Herring, Maxime Coquelin,
Alexandre Torgue, Jiri Slaby, Le Ray, fabrice.gasnier,
linux-serial, devicetree, linux-stm32, linux-arm-kernel
Add new rx-tx-swap property to allow for RX & TX pin swapping.
Signed-off-by: Martin Devera <devik@eaxlabs.cz>
Acked-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
---
.../devicetree/bindings/serial/st,stm32-uart.yaml | 29 ++++++++++++++--------
1 file changed, 19 insertions(+), 10 deletions(-)
diff --git a/Documentation/devicetree/bindings/serial/st,stm32-uart.yaml b/Documentation/devicetree/bindings/serial/st,stm32-uart.yaml
index 8631678283f9..68a0f3ce8328 100644
--- a/Documentation/devicetree/bindings/serial/st,stm32-uart.yaml
+++ b/Documentation/devicetree/bindings/serial/st,stm32-uart.yaml
@@ -9,9 +9,6 @@ maintainers:
title: STMicroelectronics STM32 USART bindings
-allOf:
- - $ref: rs485.yaml
-
properties:
compatible:
enum:
@@ -40,6 +37,8 @@ properties:
uart-has-rtscts: true
+ rx-tx-swap: true
+
dmas:
minItems: 1
maxItems: 2
@@ -66,13 +65,23 @@ properties:
linux,rs485-enabled-at-boot-time: true
rs485-rx-during-tx: true
-if:
- required:
- - st,hw-flow-ctrl
-then:
- properties:
- cts-gpios: false
- rts-gpios: false
+allOf:
+ - $ref: rs485.yaml#
+ - $ref: serial.yaml#
+ - if:
+ required:
+ - st,hw-flow-ctrl
+ then:
+ properties:
+ cts-gpios: false
+ rts-gpios: false
+ - if:
+ properties:
+ compatible:
+ const: st,stm32-uart
+ then:
+ properties:
+ rx-tx-swap: false
required:
- compatible
--
2.11.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [PATCH v5 2/2] tty/serial: Add rx-tx-swap OF option to stm32-usart
2021-03-11 21:51 ` Martin Devera
@ 2021-03-11 21:51 ` Martin Devera
-1 siblings, 0 replies; 69+ messages in thread
From: Martin Devera @ 2021-03-11 21:51 UTC (permalink / raw)
To: linux-kernel
Cc: Martin Devera, Greg Kroah-Hartman, Rob Herring, Maxime Coquelin,
Alexandre Torgue, Jiri Slaby, Le Ray, fabrice.gasnier,
linux-serial, devicetree, linux-stm32, linux-arm-kernel
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>
Acked-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
---
drivers/tty/serial/stm32-usart.c | 11 ++++++++++-
drivers/tty/serial/stm32-usart.h | 4 ++++
2 files changed, 14 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..a85391e71e8e 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;
@@ -76,6 +77,7 @@ struct stm32_usart_info stm32f7_info = {
.cfg = {
.uart_enable_bit = 0,
.has_7bits_data = true,
+ .has_swap = true,
.fifosize = 1,
}
};
@@ -97,6 +99,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 +274,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 */
--
2.11.0
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [PATCH v5 2/2] tty/serial: Add rx-tx-swap OF option to stm32-usart
@ 2021-03-11 21:51 ` Martin Devera
0 siblings, 0 replies; 69+ messages in thread
From: Martin Devera @ 2021-03-11 21:51 UTC (permalink / raw)
To: linux-kernel
Cc: Martin Devera, Greg Kroah-Hartman, Rob Herring, Maxime Coquelin,
Alexandre Torgue, Jiri Slaby, Le Ray, fabrice.gasnier,
linux-serial, devicetree, linux-stm32, linux-arm-kernel
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>
Acked-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
---
drivers/tty/serial/stm32-usart.c | 11 ++++++++++-
drivers/tty/serial/stm32-usart.h | 4 ++++
2 files changed, 14 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..a85391e71e8e 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;
@@ -76,6 +77,7 @@ struct stm32_usart_info stm32f7_info = {
.cfg = {
.uart_enable_bit = 0,
.has_7bits_data = true,
+ .has_swap = true,
.fifosize = 1,
}
};
@@ -97,6 +99,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 +274,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 */
--
2.11.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 69+ messages in thread
* Re: [PATCH v5 2/2] tty/serial: Add rx-tx-swap OF option to stm32-usart
2021-03-11 21:51 ` Martin Devera
@ 2021-03-12 8:15 ` Greg Kroah-Hartman
-1 siblings, 0 replies; 69+ messages in thread
From: Greg Kroah-Hartman @ 2021-03-12 8:15 UTC (permalink / raw)
To: Martin Devera
Cc: linux-kernel, Rob Herring, Maxime Coquelin, Alexandre Torgue,
Jiri Slaby, Le Ray, fabrice.gasnier, linux-serial, devicetree,
linux-stm32, linux-arm-kernel
On Thu, Mar 11, 2021 at 10:51:53PM +0100, 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>
> Acked-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
> ---
> drivers/tty/serial/stm32-usart.c | 11 ++++++++++-
> drivers/tty/serial/stm32-usart.h | 4 ++++
> 2 files changed, 14 insertions(+), 1 deletion(-)
What changed from v4-v1 on this patch series? That needs to go below
the --- line as documented.
Please fix up and send v6.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH v5 2/2] tty/serial: Add rx-tx-swap OF option to stm32-usart
@ 2021-03-12 8:15 ` Greg Kroah-Hartman
0 siblings, 0 replies; 69+ messages in thread
From: Greg Kroah-Hartman @ 2021-03-12 8:15 UTC (permalink / raw)
To: Martin Devera
Cc: linux-kernel, Rob Herring, Maxime Coquelin, Alexandre Torgue,
Jiri Slaby, Le Ray, fabrice.gasnier, linux-serial, devicetree,
linux-stm32, linux-arm-kernel
On Thu, Mar 11, 2021 at 10:51:53PM +0100, 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>
> Acked-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
> ---
> drivers/tty/serial/stm32-usart.c | 11 ++++++++++-
> drivers/tty/serial/stm32-usart.h | 4 ++++
> 2 files changed, 14 insertions(+), 1 deletion(-)
What changed from v4-v1 on this patch series? That needs to go below
the --- line as documented.
Please fix up and send v6.
thanks,
greg k-h
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 69+ messages in thread
* [PATCH v6 1/2] dt-bindings: serial: Add rx-tx-swap to stm32-usart
2021-03-12 8:15 ` Greg Kroah-Hartman
@ 2021-03-12 10:27 ` Martin Devera
-1 siblings, 0 replies; 69+ messages in thread
From: Martin Devera @ 2021-03-12 10:27 UTC (permalink / raw)
To: linux-kernel
Cc: Martin Devera, Greg Kroah-Hartman, Rob Herring, Maxime Coquelin,
Alexandre Torgue, Jiri Slaby, Le Ray, fabrice.gasnier,
linux-serial, devicetree, linux-stm32, linux-arm-kernel
Add new rx-tx-swap property to allow for RX & TX pin swapping.
Signed-off-by: Martin Devera <devik@eaxlabs.cz>
Acked-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
---
v6:
- add version changelog
v5:
- yaml fixes based on Rob Herring comments
- add serial.yaml reference
- move compatible from 'then' to 'if'
v3:
- don't allow rx-tx-swap for st,stm32-uart (suggested
by Fabrice Gasnier)
v2:
- change st,swap to rx-tx-swap (suggested by Rob Herring)
---
.../devicetree/bindings/serial/st,stm32-uart.yaml | 29 ++++++++++++++--------
1 file changed, 19 insertions(+), 10 deletions(-)
diff --git a/Documentation/devicetree/bindings/serial/st,stm32-uart.yaml b/Documentation/devicetree/bindings/serial/st,stm32-uart.yaml
index 8631678283f9..68a0f3ce8328 100644
--- a/Documentation/devicetree/bindings/serial/st,stm32-uart.yaml
+++ b/Documentation/devicetree/bindings/serial/st,stm32-uart.yaml
@@ -9,9 +9,6 @@ maintainers:
title: STMicroelectronics STM32 USART bindings
-allOf:
- - $ref: rs485.yaml
-
properties:
compatible:
enum:
@@ -40,6 +37,8 @@ properties:
uart-has-rtscts: true
+ rx-tx-swap: true
+
dmas:
minItems: 1
maxItems: 2
@@ -66,13 +65,23 @@ properties:
linux,rs485-enabled-at-boot-time: true
rs485-rx-during-tx: true
-if:
- required:
- - st,hw-flow-ctrl
-then:
- properties:
- cts-gpios: false
- rts-gpios: false
+allOf:
+ - $ref: rs485.yaml#
+ - $ref: serial.yaml#
+ - if:
+ required:
+ - st,hw-flow-ctrl
+ then:
+ properties:
+ cts-gpios: false
+ rts-gpios: false
+ - if:
+ properties:
+ compatible:
+ const: st,stm32-uart
+ then:
+ properties:
+ rx-tx-swap: false
required:
- compatible
--
2.11.0
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [PATCH v6 1/2] dt-bindings: serial: Add rx-tx-swap to stm32-usart
@ 2021-03-12 10:27 ` Martin Devera
0 siblings, 0 replies; 69+ messages in thread
From: Martin Devera @ 2021-03-12 10:27 UTC (permalink / raw)
To: linux-kernel
Cc: Martin Devera, Greg Kroah-Hartman, Rob Herring, Maxime Coquelin,
Alexandre Torgue, Jiri Slaby, Le Ray, fabrice.gasnier,
linux-serial, devicetree, linux-stm32, linux-arm-kernel
Add new rx-tx-swap property to allow for RX & TX pin swapping.
Signed-off-by: Martin Devera <devik@eaxlabs.cz>
Acked-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
---
v6:
- add version changelog
v5:
- yaml fixes based on Rob Herring comments
- add serial.yaml reference
- move compatible from 'then' to 'if'
v3:
- don't allow rx-tx-swap for st,stm32-uart (suggested
by Fabrice Gasnier)
v2:
- change st,swap to rx-tx-swap (suggested by Rob Herring)
---
.../devicetree/bindings/serial/st,stm32-uart.yaml | 29 ++++++++++++++--------
1 file changed, 19 insertions(+), 10 deletions(-)
diff --git a/Documentation/devicetree/bindings/serial/st,stm32-uart.yaml b/Documentation/devicetree/bindings/serial/st,stm32-uart.yaml
index 8631678283f9..68a0f3ce8328 100644
--- a/Documentation/devicetree/bindings/serial/st,stm32-uart.yaml
+++ b/Documentation/devicetree/bindings/serial/st,stm32-uart.yaml
@@ -9,9 +9,6 @@ maintainers:
title: STMicroelectronics STM32 USART bindings
-allOf:
- - $ref: rs485.yaml
-
properties:
compatible:
enum:
@@ -40,6 +37,8 @@ properties:
uart-has-rtscts: true
+ rx-tx-swap: true
+
dmas:
minItems: 1
maxItems: 2
@@ -66,13 +65,23 @@ properties:
linux,rs485-enabled-at-boot-time: true
rs485-rx-during-tx: true
-if:
- required:
- - st,hw-flow-ctrl
-then:
- properties:
- cts-gpios: false
- rts-gpios: false
+allOf:
+ - $ref: rs485.yaml#
+ - $ref: serial.yaml#
+ - if:
+ required:
+ - st,hw-flow-ctrl
+ then:
+ properties:
+ cts-gpios: false
+ rts-gpios: false
+ - if:
+ properties:
+ compatible:
+ const: st,stm32-uart
+ then:
+ properties:
+ rx-tx-swap: false
required:
- compatible
--
2.11.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [PATCH v6 2/2] tty/serial: Add rx-tx-swap OF option to stm32-usart
2021-03-12 10:27 ` Martin Devera
@ 2021-03-12 10:27 ` Martin Devera
-1 siblings, 0 replies; 69+ messages in thread
From: Martin Devera @ 2021-03-12 10:27 UTC (permalink / raw)
To: linux-kernel
Cc: Martin Devera, Greg Kroah-Hartman, Rob Herring, Maxime Coquelin,
Alexandre Torgue, Jiri Slaby, Le Ray, fabrice.gasnier,
linux-serial, devicetree, linux-stm32, linux-arm-kernel
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>
Acked-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
---
v6:
- add version changelog
v4:
- delete superfluous has_swap=false
v3:
- add has_swap to stm32_usart_info (because F4 line
doesn't support swapping)
- move swap variable init from stm32_usart_of_get_port
to stm32_usart_init_port because info struct is not
initialized in stm32_usart_of_get_port yet
- set USART_CR2_SWAP in stm32_usart_startup too
v2:
- change st,swap to rx-tx-swap (pointed out by Rob Herring)
- rebase patches as suggested by Greg Kroah-Hartman
---
drivers/tty/serial/stm32-usart.c | 11 ++++++++++-
drivers/tty/serial/stm32-usart.h | 4 ++++
2 files changed, 14 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..a85391e71e8e 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;
@@ -76,6 +77,7 @@ struct stm32_usart_info stm32f7_info = {
.cfg = {
.uart_enable_bit = 0,
.has_7bits_data = true,
+ .has_swap = true,
.fifosize = 1,
}
};
@@ -97,6 +99,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 +274,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 */
--
2.11.0
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [PATCH v6 2/2] tty/serial: Add rx-tx-swap OF option to stm32-usart
@ 2021-03-12 10:27 ` Martin Devera
0 siblings, 0 replies; 69+ messages in thread
From: Martin Devera @ 2021-03-12 10:27 UTC (permalink / raw)
To: linux-kernel
Cc: Martin Devera, Greg Kroah-Hartman, Rob Herring, Maxime Coquelin,
Alexandre Torgue, Jiri Slaby, Le Ray, fabrice.gasnier,
linux-serial, devicetree, linux-stm32, linux-arm-kernel
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>
Acked-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
---
v6:
- add version changelog
v4:
- delete superfluous has_swap=false
v3:
- add has_swap to stm32_usart_info (because F4 line
doesn't support swapping)
- move swap variable init from stm32_usart_of_get_port
to stm32_usart_init_port because info struct is not
initialized in stm32_usart_of_get_port yet
- set USART_CR2_SWAP in stm32_usart_startup too
v2:
- change st,swap to rx-tx-swap (pointed out by Rob Herring)
- rebase patches as suggested by Greg Kroah-Hartman
---
drivers/tty/serial/stm32-usart.c | 11 ++++++++++-
drivers/tty/serial/stm32-usart.h | 4 ++++
2 files changed, 14 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..a85391e71e8e 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;
@@ -76,6 +77,7 @@ struct stm32_usart_info stm32f7_info = {
.cfg = {
.uart_enable_bit = 0,
.has_7bits_data = true,
+ .has_swap = true,
.fifosize = 1,
}
};
@@ -97,6 +99,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 +274,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 */
--
2.11.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 69+ messages in thread
* Re: [PATCH v6 1/2] dt-bindings: serial: Add rx-tx-swap to stm32-usart
2021-03-12 10:27 ` Martin Devera
@ 2021-03-12 14:23 ` Rob Herring
-1 siblings, 0 replies; 69+ messages in thread
From: Rob Herring @ 2021-03-12 14:23 UTC (permalink / raw)
To: Martin Devera
Cc: linux-kernel, Jiri Slaby, Rob Herring, Alexandre Torgue, Le Ray,
linux-stm32, fabrice.gasnier, linux-arm-kernel, Maxime Coquelin,
Greg Kroah-Hartman, devicetree, linux-serial
On Fri, 12 Mar 2021 11:27:12 +0100, Martin Devera wrote:
> Add new rx-tx-swap property to allow for RX & TX pin swapping.
>
> Signed-off-by: Martin Devera <devik@eaxlabs.cz>
> Acked-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
> ---
> v6:
> - add version changelog
> v5:
> - yaml fixes based on Rob Herring comments
> - add serial.yaml reference
> - move compatible from 'then' to 'if'
> v3:
> - don't allow rx-tx-swap for st,stm32-uart (suggested
> by Fabrice Gasnier)
> v2:
> - change st,swap to rx-tx-swap (suggested by Rob Herring)
> ---
> .../devicetree/bindings/serial/st,stm32-uart.yaml | 29 ++++++++++++++--------
> 1 file changed, 19 insertions(+), 10 deletions(-)
>
My bot found errors running 'make dt_binding_check' on your patch:
yamllint warnings/errors:
./Documentation/devicetree/bindings/serial/st,stm32-uart.yaml:81:12: [warning] wrong indentation: expected 10 but found 11 (indentation)
dtschema/dtc warnings/errors:
See https://patchwork.ozlabs.org/patch/1451861
This check can fail if there are any dependencies. The base for a patch
series is generally the most recent rc1.
If you already ran 'make dt_binding_check' and didn't see the above
error(s), then make sure 'yamllint' is installed and dt-schema is up to
date:
pip3 install dtschema --upgrade
Please check and re-submit.
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH v6 1/2] dt-bindings: serial: Add rx-tx-swap to stm32-usart
@ 2021-03-12 14:23 ` Rob Herring
0 siblings, 0 replies; 69+ messages in thread
From: Rob Herring @ 2021-03-12 14:23 UTC (permalink / raw)
To: Martin Devera
Cc: linux-kernel, Jiri Slaby, Rob Herring, Alexandre Torgue, Le Ray,
linux-stm32, fabrice.gasnier, linux-arm-kernel, Maxime Coquelin,
Greg Kroah-Hartman, devicetree, linux-serial
On Fri, 12 Mar 2021 11:27:12 +0100, Martin Devera wrote:
> Add new rx-tx-swap property to allow for RX & TX pin swapping.
>
> Signed-off-by: Martin Devera <devik@eaxlabs.cz>
> Acked-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
> ---
> v6:
> - add version changelog
> v5:
> - yaml fixes based on Rob Herring comments
> - add serial.yaml reference
> - move compatible from 'then' to 'if'
> v3:
> - don't allow rx-tx-swap for st,stm32-uart (suggested
> by Fabrice Gasnier)
> v2:
> - change st,swap to rx-tx-swap (suggested by Rob Herring)
> ---
> .../devicetree/bindings/serial/st,stm32-uart.yaml | 29 ++++++++++++++--------
> 1 file changed, 19 insertions(+), 10 deletions(-)
>
My bot found errors running 'make dt_binding_check' on your patch:
yamllint warnings/errors:
./Documentation/devicetree/bindings/serial/st,stm32-uart.yaml:81:12: [warning] wrong indentation: expected 10 but found 11 (indentation)
dtschema/dtc warnings/errors:
See https://patchwork.ozlabs.org/patch/1451861
This check can fail if there are any dependencies. The base for a patch
series is generally the most recent rc1.
If you already ran 'make dt_binding_check' and didn't see the above
error(s), then make sure 'yamllint' is installed and dt-schema is up to
date:
pip3 install dtschema --upgrade
Please check and re-submit.
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH v6 1/2] dt-bindings: serial: Add rx-tx-swap to stm32-usart
2021-03-12 14:23 ` Rob Herring
@ 2021-03-12 14:56 ` Martin DEVERA
-1 siblings, 0 replies; 69+ messages in thread
From: Martin DEVERA @ 2021-03-12 14:56 UTC (permalink / raw)
To: Rob Herring
Cc: linux-kernel, Rob Herring, Alexandre Torgue, Le Ray, linux-stm32,
fabrice.gasnier, linux-arm-kernel, Maxime Coquelin,
Greg Kroah-Hartman, devicetree, linux-serial
On 3/12/21 3:23 PM, Rob Herring wrote:
> On Fri, 12 Mar 2021 11:27:12 +0100, Martin Devera wrote:
>> Add new rx-tx-swap property to allow for RX & TX pin swapping.
>>
>> Signed-off-by: Martin Devera <devik@eaxlabs.cz>
>> Acked-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
>> ---
>> v6:
>> - add version changelog
>> v5:
>> - yaml fixes based on Rob Herring comments
>> - add serial.yaml reference
>> - move compatible from 'then' to 'if'
>> v3:
>> - don't allow rx-tx-swap for st,stm32-uart (suggested
>> by Fabrice Gasnier)
>> v2:
>> - change st,swap to rx-tx-swap (suggested by Rob Herring)
>> ---
>> .../devicetree/bindings/serial/st,stm32-uart.yaml | 29 ++++++++++++++--------
>> 1 file changed, 19 insertions(+), 10 deletions(-)
>>
> My bot found errors running 'make dt_binding_check' on your patch:
>
> yamllint warnings/errors:
> ./Documentation/devicetree/bindings/serial/st,stm32-uart.yaml:81:12: [warning] wrong indentation: expected 10 but found 11 (indentation)
>
> dtschema/dtc warnings/errors:
>
> See https://patchwork.ozlabs.org/patch/1451861
>
> This check can fail if there are any dependencies. The base for a patch
> series is generally the most recent rc1.
>
> If you already ran 'make dt_binding_check' and didn't see the above
> error(s), then make sure 'yamllint' is installed and dt-schema is up to
> date:
>
> pip3 install dtschema --upgrade
>
Yoy are right, there is one extra space. But for some reason the check
doesn't
find it:
$ make dt_binding_check
DT_SCHEMA_FILES=Documentation/devicetree/bindings/serial/st,stm32-uart.yaml
CHKDT Documentation/devicetree/bindings/processed-schema-examples.json
SCHEMA Documentation/devicetree/bindings/processed-schema-examples.json
/home/devik/.local/lib/python3.9/site-packages/dtschema/schemas/serial/rs485.yaml:
duplicate '$id' value 'http://devicetree.org/schemas/serial/rs485.yaml#'
DTEX Documentation/devicetree/bindings/serial/st,stm32-uart.example.dts
DTC
Documentation/devicetree/bindings/serial/st,stm32-uart.example.dt.yaml
CHECK
Documentation/devicetree/bindings/serial/st,stm32-uart.example.dt.yaml
$ git describe
v5.12-rc2-2-g2f2a4a95dd38
$ pip3 show dtschema
Name: dtschema
Version: 2021.2.1
Any idea why ?
Thanks, Martin
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH v6 1/2] dt-bindings: serial: Add rx-tx-swap to stm32-usart
@ 2021-03-12 14:56 ` Martin DEVERA
0 siblings, 0 replies; 69+ messages in thread
From: Martin DEVERA @ 2021-03-12 14:56 UTC (permalink / raw)
To: Rob Herring
Cc: linux-kernel, Rob Herring, Alexandre Torgue, Le Ray, linux-stm32,
fabrice.gasnier, linux-arm-kernel, Maxime Coquelin,
Greg Kroah-Hartman, devicetree, linux-serial
On 3/12/21 3:23 PM, Rob Herring wrote:
> On Fri, 12 Mar 2021 11:27:12 +0100, Martin Devera wrote:
>> Add new rx-tx-swap property to allow for RX & TX pin swapping.
>>
>> Signed-off-by: Martin Devera <devik@eaxlabs.cz>
>> Acked-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
>> ---
>> v6:
>> - add version changelog
>> v5:
>> - yaml fixes based on Rob Herring comments
>> - add serial.yaml reference
>> - move compatible from 'then' to 'if'
>> v3:
>> - don't allow rx-tx-swap for st,stm32-uart (suggested
>> by Fabrice Gasnier)
>> v2:
>> - change st,swap to rx-tx-swap (suggested by Rob Herring)
>> ---
>> .../devicetree/bindings/serial/st,stm32-uart.yaml | 29 ++++++++++++++--------
>> 1 file changed, 19 insertions(+), 10 deletions(-)
>>
> My bot found errors running 'make dt_binding_check' on your patch:
>
> yamllint warnings/errors:
> ./Documentation/devicetree/bindings/serial/st,stm32-uart.yaml:81:12: [warning] wrong indentation: expected 10 but found 11 (indentation)
>
> dtschema/dtc warnings/errors:
>
> See https://patchwork.ozlabs.org/patch/1451861
>
> This check can fail if there are any dependencies. The base for a patch
> series is generally the most recent rc1.
>
> If you already ran 'make dt_binding_check' and didn't see the above
> error(s), then make sure 'yamllint' is installed and dt-schema is up to
> date:
>
> pip3 install dtschema --upgrade
>
Yoy are right, there is one extra space. But for some reason the check
doesn't
find it:
$ make dt_binding_check
DT_SCHEMA_FILES=Documentation/devicetree/bindings/serial/st,stm32-uart.yaml
CHKDT Documentation/devicetree/bindings/processed-schema-examples.json
SCHEMA Documentation/devicetree/bindings/processed-schema-examples.json
/home/devik/.local/lib/python3.9/site-packages/dtschema/schemas/serial/rs485.yaml:
duplicate '$id' value 'http://devicetree.org/schemas/serial/rs485.yaml#'
DTEX Documentation/devicetree/bindings/serial/st,stm32-uart.example.dts
DTC
Documentation/devicetree/bindings/serial/st,stm32-uart.example.dt.yaml
CHECK
Documentation/devicetree/bindings/serial/st,stm32-uart.example.dt.yaml
$ git describe
v5.12-rc2-2-g2f2a4a95dd38
$ pip3 show dtschema
Name: dtschema
Version: 2021.2.1
Any idea why ?
Thanks, Martin
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH v6 1/2] dt-bindings: serial: Add rx-tx-swap to stm32-usart
2021-03-12 14:56 ` Martin DEVERA
@ 2021-03-12 15:03 ` Martin DEVERA
-1 siblings, 0 replies; 69+ messages in thread
From: Martin DEVERA @ 2021-03-12 15:03 UTC (permalink / raw)
To: Rob Herring
Cc: linux-kernel, Rob Herring, Alexandre Torgue, Le Ray, linux-stm32,
fabrice.gasnier, linux-arm-kernel, Maxime Coquelin,
Greg Kroah-Hartman, devicetree, linux-serial
On 3/12/21 3:56 PM, Martin DEVERA wrote:
> On 3/12/21 3:23 PM, Rob Herring wrote:
>> On Fri, 12 Mar 2021 11:27:12 +0100, Martin Devera wrote:
>>> Add new rx-tx-swap property to allow for RX & TX pin swapping.
>>>
>>> Signed-off-by: Martin Devera <devik@eaxlabs.cz>
>>> Acked-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
>>> ---
>>> v6:
>>> - add version changelog
>>> v5:
>>> - yaml fixes based on Rob Herring comments
>>> - add serial.yaml reference
>>> - move compatible from 'then' to 'if'
>>> v3:
>>> - don't allow rx-tx-swap for st,stm32-uart (suggested
>>> by Fabrice Gasnier)
>>> v2:
>>> - change st,swap to rx-tx-swap (suggested by Rob Herring)
>>> ---
>>> .../devicetree/bindings/serial/st,stm32-uart.yaml | 29
>>> ++++++++++++++--------
>>> 1 file changed, 19 insertions(+), 10 deletions(-)
>>>
>> My bot found errors running 'make dt_binding_check' on your patch:
>>
>> yamllint warnings/errors:
>> ./Documentation/devicetree/bindings/serial/st,stm32-uart.yaml:81:12:
>> [warning] wrong indentation: expected 10 but found 11 (indentation)
>>
>> dtschema/dtc warnings/errors:
>>
>> See https://patchwork.ozlabs.org/patch/1451861
>>
>> This check can fail if there are any dependencies. The base for a patch
>> series is generally the most recent rc1.
>>
>> If you already ran 'make dt_binding_check' and didn't see the above
>> error(s), then make sure 'yamllint' is installed and dt-schema is up to
>> date:
>>
>> pip3 install dtschema --upgrade
>>
> Yoy are right, there is one extra space. But for some reason the check
> doesn't
> find it:
Argh... sorry, ignore it please. It seems I removed yamllint.
I see the error now.
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH v6 1/2] dt-bindings: serial: Add rx-tx-swap to stm32-usart
@ 2021-03-12 15:03 ` Martin DEVERA
0 siblings, 0 replies; 69+ messages in thread
From: Martin DEVERA @ 2021-03-12 15:03 UTC (permalink / raw)
To: Rob Herring
Cc: linux-kernel, Rob Herring, Alexandre Torgue, Le Ray, linux-stm32,
fabrice.gasnier, linux-arm-kernel, Maxime Coquelin,
Greg Kroah-Hartman, devicetree, linux-serial
On 3/12/21 3:56 PM, Martin DEVERA wrote:
> On 3/12/21 3:23 PM, Rob Herring wrote:
>> On Fri, 12 Mar 2021 11:27:12 +0100, Martin Devera wrote:
>>> Add new rx-tx-swap property to allow for RX & TX pin swapping.
>>>
>>> Signed-off-by: Martin Devera <devik@eaxlabs.cz>
>>> Acked-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
>>> ---
>>> v6:
>>> - add version changelog
>>> v5:
>>> - yaml fixes based on Rob Herring comments
>>> - add serial.yaml reference
>>> - move compatible from 'then' to 'if'
>>> v3:
>>> - don't allow rx-tx-swap for st,stm32-uart (suggested
>>> by Fabrice Gasnier)
>>> v2:
>>> - change st,swap to rx-tx-swap (suggested by Rob Herring)
>>> ---
>>> .../devicetree/bindings/serial/st,stm32-uart.yaml | 29
>>> ++++++++++++++--------
>>> 1 file changed, 19 insertions(+), 10 deletions(-)
>>>
>> My bot found errors running 'make dt_binding_check' on your patch:
>>
>> yamllint warnings/errors:
>> ./Documentation/devicetree/bindings/serial/st,stm32-uart.yaml:81:12:
>> [warning] wrong indentation: expected 10 but found 11 (indentation)
>>
>> dtschema/dtc warnings/errors:
>>
>> See https://patchwork.ozlabs.org/patch/1451861
>>
>> This check can fail if there are any dependencies. The base for a patch
>> series is generally the most recent rc1.
>>
>> If you already ran 'make dt_binding_check' and didn't see the above
>> error(s), then make sure 'yamllint' is installed and dt-schema is up to
>> date:
>>
>> pip3 install dtschema --upgrade
>>
> Yoy are right, there is one extra space. But for some reason the check
> doesn't
> find it:
Argh... sorry, ignore it please. It seems I removed yamllint.
I see the error now.
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 69+ messages in thread
* [PATCH v7 1/2] dt-bindings: serial: Add rx-tx-swap to stm32-usart
2021-03-12 14:23 ` Rob Herring
@ 2021-03-12 15:37 ` Martin Devera
-1 siblings, 0 replies; 69+ messages in thread
From: Martin Devera @ 2021-03-12 15:37 UTC (permalink / raw)
To: linux-kernel
Cc: Martin Devera, Greg Kroah-Hartman, Rob Herring, Maxime Coquelin,
Alexandre Torgue, Jiri Slaby, Le Ray, fabrice.gasnier,
linux-serial, devicetree, linux-stm32, linux-arm-kernel
Add new rx-tx-swap property to allow for RX & TX pin swapping.
Signed-off-by: Martin Devera <devik@eaxlabs.cz>
Acked-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
---
v7:
- fix yaml linter warning
v6:
- add version changelog
v5:
- yaml fixes based on Rob Herring comments
- add serial.yaml reference
- move compatible from 'then' to 'if'
v3:
- don't allow rx-tx-swap for st,stm32-uart (suggested
by Fabrice Gasnier)
v2:
- change st,swap to rx-tx-swap (suggested by Rob Herring)
---
.../devicetree/bindings/serial/st,stm32-uart.yaml | 29 ++++++++++++++--------
1 file changed, 19 insertions(+), 10 deletions(-)
diff --git a/Documentation/devicetree/bindings/serial/st,stm32-uart.yaml b/Documentation/devicetree/bindings/serial/st,stm32-uart.yaml
index 8631678283f9..68a0f3ce8328 100644
--- a/Documentation/devicetree/bindings/serial/st,stm32-uart.yaml
+++ b/Documentation/devicetree/bindings/serial/st,stm32-uart.yaml
@@ -9,9 +9,6 @@ maintainers:
title: STMicroelectronics STM32 USART bindings
-allOf:
- - $ref: rs485.yaml
-
properties:
compatible:
enum:
@@ -40,6 +37,8 @@ properties:
uart-has-rtscts: true
+ rx-tx-swap: true
+
dmas:
minItems: 1
maxItems: 2
@@ -66,13 +65,23 @@ properties:
linux,rs485-enabled-at-boot-time: true
rs485-rx-during-tx: true
-if:
- required:
- - st,hw-flow-ctrl
-then:
- properties:
- cts-gpios: false
- rts-gpios: false
+allOf:
+ - $ref: rs485.yaml#
+ - $ref: serial.yaml#
+ - if:
+ required:
+ - st,hw-flow-ctrl
+ then:
+ properties:
+ cts-gpios: false
+ rts-gpios: false
+ - if:
+ properties:
+ compatible:
+ const: st,stm32-uart
+ then:
+ properties:
+ rx-tx-swap: false
required:
- compatible
--
2.11.0
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [PATCH v7 1/2] dt-bindings: serial: Add rx-tx-swap to stm32-usart
@ 2021-03-12 15:37 ` Martin Devera
0 siblings, 0 replies; 69+ messages in thread
From: Martin Devera @ 2021-03-12 15:37 UTC (permalink / raw)
To: linux-kernel
Cc: Martin Devera, Greg Kroah-Hartman, Rob Herring, Maxime Coquelin,
Alexandre Torgue, Jiri Slaby, Le Ray, fabrice.gasnier,
linux-serial, devicetree, linux-stm32, linux-arm-kernel
Add new rx-tx-swap property to allow for RX & TX pin swapping.
Signed-off-by: Martin Devera <devik@eaxlabs.cz>
Acked-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
---
v7:
- fix yaml linter warning
v6:
- add version changelog
v5:
- yaml fixes based on Rob Herring comments
- add serial.yaml reference
- move compatible from 'then' to 'if'
v3:
- don't allow rx-tx-swap for st,stm32-uart (suggested
by Fabrice Gasnier)
v2:
- change st,swap to rx-tx-swap (suggested by Rob Herring)
---
.../devicetree/bindings/serial/st,stm32-uart.yaml | 29 ++++++++++++++--------
1 file changed, 19 insertions(+), 10 deletions(-)
diff --git a/Documentation/devicetree/bindings/serial/st,stm32-uart.yaml b/Documentation/devicetree/bindings/serial/st,stm32-uart.yaml
index 8631678283f9..68a0f3ce8328 100644
--- a/Documentation/devicetree/bindings/serial/st,stm32-uart.yaml
+++ b/Documentation/devicetree/bindings/serial/st,stm32-uart.yaml
@@ -9,9 +9,6 @@ maintainers:
title: STMicroelectronics STM32 USART bindings
-allOf:
- - $ref: rs485.yaml
-
properties:
compatible:
enum:
@@ -40,6 +37,8 @@ properties:
uart-has-rtscts: true
+ rx-tx-swap: true
+
dmas:
minItems: 1
maxItems: 2
@@ -66,13 +65,23 @@ properties:
linux,rs485-enabled-at-boot-time: true
rs485-rx-during-tx: true
-if:
- required:
- - st,hw-flow-ctrl
-then:
- properties:
- cts-gpios: false
- rts-gpios: false
+allOf:
+ - $ref: rs485.yaml#
+ - $ref: serial.yaml#
+ - if:
+ required:
+ - st,hw-flow-ctrl
+ then:
+ properties:
+ cts-gpios: false
+ rts-gpios: false
+ - if:
+ properties:
+ compatible:
+ const: st,stm32-uart
+ then:
+ properties:
+ rx-tx-swap: false
required:
- compatible
--
2.11.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [PATCH v7 2/2] tty/serial: Add rx-tx-swap OF option to stm32-usart
2021-03-12 15:37 ` Martin Devera
@ 2021-03-12 15:37 ` Martin Devera
-1 siblings, 0 replies; 69+ messages in thread
From: Martin Devera @ 2021-03-12 15:37 UTC (permalink / raw)
To: linux-kernel
Cc: Martin Devera, Greg Kroah-Hartman, Rob Herring, Maxime Coquelin,
Alexandre Torgue, Jiri Slaby, Le Ray, fabrice.gasnier,
linux-serial, devicetree, linux-stm32, linux-arm-kernel
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>
Acked-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
---
v6:
- add version changelog
v4:
- delete superfluous has_swap=false
v3:
- add has_swap to stm32_usart_info (because F4 line
doesn't support swapping)
- move swap variable init from stm32_usart_of_get_port
to stm32_usart_init_port because info struct is not
initialized in stm32_usart_of_get_port yet
- set USART_CR2_SWAP in stm32_usart_startup too
v2:
- change st,swap to rx-tx-swap (pointed out by Rob Herring)
- rebase patches as suggested by Greg Kroah-Hartman
---
drivers/tty/serial/stm32-usart.c | 11 ++++++++++-
drivers/tty/serial/stm32-usart.h | 4 ++++
2 files changed, 14 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..a85391e71e8e 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;
@@ -76,6 +77,7 @@ struct stm32_usart_info stm32f7_info = {
.cfg = {
.uart_enable_bit = 0,
.has_7bits_data = true,
+ .has_swap = true,
.fifosize = 1,
}
};
@@ -97,6 +99,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 +274,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 */
--
2.11.0
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [PATCH v7 2/2] tty/serial: Add rx-tx-swap OF option to stm32-usart
@ 2021-03-12 15:37 ` Martin Devera
0 siblings, 0 replies; 69+ messages in thread
From: Martin Devera @ 2021-03-12 15:37 UTC (permalink / raw)
To: linux-kernel
Cc: Martin Devera, Greg Kroah-Hartman, Rob Herring, Maxime Coquelin,
Alexandre Torgue, Jiri Slaby, Le Ray, fabrice.gasnier,
linux-serial, devicetree, linux-stm32, linux-arm-kernel
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>
Acked-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
---
v6:
- add version changelog
v4:
- delete superfluous has_swap=false
v3:
- add has_swap to stm32_usart_info (because F4 line
doesn't support swapping)
- move swap variable init from stm32_usart_of_get_port
to stm32_usart_init_port because info struct is not
initialized in stm32_usart_of_get_port yet
- set USART_CR2_SWAP in stm32_usart_startup too
v2:
- change st,swap to rx-tx-swap (pointed out by Rob Herring)
- rebase patches as suggested by Greg Kroah-Hartman
---
drivers/tty/serial/stm32-usart.c | 11 ++++++++++-
drivers/tty/serial/stm32-usart.h | 4 ++++
2 files changed, 14 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..a85391e71e8e 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;
@@ -76,6 +77,7 @@ struct stm32_usart_info stm32f7_info = {
.cfg = {
.uart_enable_bit = 0,
.has_7bits_data = true,
+ .has_swap = true,
.fifosize = 1,
}
};
@@ -97,6 +99,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 +274,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 */
--
2.11.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 69+ messages in thread
* Re: [PATCH v7 2/2] tty/serial: Add rx-tx-swap OF option to stm32-usart
2021-03-12 15:37 ` Martin Devera
@ 2021-03-26 14:18 ` Greg Kroah-Hartman
-1 siblings, 0 replies; 69+ messages in thread
From: Greg Kroah-Hartman @ 2021-03-26 14:18 UTC (permalink / raw)
To: Martin Devera
Cc: linux-kernel, Rob Herring, Maxime Coquelin, Alexandre Torgue,
Jiri Slaby, Le Ray, fabrice.gasnier, linux-serial, devicetree,
linux-stm32, linux-arm-kernel
On Fri, Mar 12, 2021 at 04:37:02PM +0100, 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>
> Acked-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
This does not apply to my tty-next branch at all. Can you please rebase
this series (and keep Rob's ack of patch 1) and resend?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH v7 2/2] tty/serial: Add rx-tx-swap OF option to stm32-usart
@ 2021-03-26 14:18 ` Greg Kroah-Hartman
0 siblings, 0 replies; 69+ messages in thread
From: Greg Kroah-Hartman @ 2021-03-26 14:18 UTC (permalink / raw)
To: Martin Devera
Cc: linux-kernel, Rob Herring, Maxime Coquelin, Alexandre Torgue,
Jiri Slaby, Le Ray, fabrice.gasnier, linux-serial, devicetree,
linux-stm32, linux-arm-kernel
On Fri, Mar 12, 2021 at 04:37:02PM +0100, 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>
> Acked-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
This does not apply to my tty-next branch at all. Can you please rebase
this series (and keep Rob's ack of patch 1) and resend?
thanks,
greg k-h
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 69+ messages in thread
* [PATCH v8 1/2] dt-bindings: serial: Add rx-tx-swap to stm32-usart
2021-03-26 14:18 ` Greg Kroah-Hartman
@ 2021-03-28 15:43 ` Martin Devera
-1 siblings, 0 replies; 69+ messages in thread
From: Martin Devera @ 2021-03-28 15:43 UTC (permalink / raw)
To: linux-kernel
Cc: Martin Devera, Greg Kroah-Hartman, Rob Herring, Maxime Coquelin,
Alexandre Torgue, Jiri Slaby, Le Ray, fabrice.gasnier,
linux-serial, devicetree, linux-stm32, linux-arm-kernel
Add new rx-tx-swap property to allow for RX & TX pin swapping.
Signed-off-by: Martin Devera <devik@eaxlabs.cz>
Acked-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
Reviewed-by: Rob Herring <robh@kernel.org>
---
v8:
- rebase to the latest tty-next
v7:
- fix yaml linter warning
v6:
- add version changelog
v5:
- yaml fixes based on Rob Herring comments
- add serial.yaml reference
- move compatible from 'then' to 'if'
v3:
- don't allow rx-tx-swap for st,stm32-uart (suggested
by Fabrice Gasnier)
v2:
- change st,swap to rx-tx-swap (suggested by Rob Herring)
---
.../devicetree/bindings/serial/st,stm32-uart.yaml | 29 ++++++++++++++--------
1 file changed, 19 insertions(+), 10 deletions(-)
---
.../devicetree/bindings/serial/st,stm32-uart.yaml | 29 ++++++++++++++--------
1 file changed, 19 insertions(+), 10 deletions(-)
diff --git a/Documentation/devicetree/bindings/serial/st,stm32-uart.yaml b/Documentation/devicetree/bindings/serial/st,stm32-uart.yaml
index 8631678283f9..126e07566965 100644
--- a/Documentation/devicetree/bindings/serial/st,stm32-uart.yaml
+++ b/Documentation/devicetree/bindings/serial/st,stm32-uart.yaml
@@ -9,9 +9,6 @@ maintainers:
title: STMicroelectronics STM32 USART bindings
-allOf:
- - $ref: rs485.yaml
-
properties:
compatible:
enum:
@@ -40,6 +37,8 @@ properties:
uart-has-rtscts: true
+ rx-tx-swap: true
+
dmas:
minItems: 1
maxItems: 2
@@ -66,13 +65,23 @@ properties:
linux,rs485-enabled-at-boot-time: true
rs485-rx-during-tx: true
-if:
- required:
- - st,hw-flow-ctrl
-then:
- properties:
- cts-gpios: false
- rts-gpios: false
+allOf:
+ - $ref: rs485.yaml#
+ - $ref: serial.yaml#
+ - if:
+ required:
+ - st,hw-flow-ctrl
+ then:
+ properties:
+ cts-gpios: false
+ rts-gpios: false
+ - if:
+ properties:
+ compatible:
+ const: st,stm32-uart
+ then:
+ properties:
+ rx-tx-swap: false
required:
- compatible
--
2.11.0
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [PATCH v8 1/2] dt-bindings: serial: Add rx-tx-swap to stm32-usart
@ 2021-03-28 15:43 ` Martin Devera
0 siblings, 0 replies; 69+ messages in thread
From: Martin Devera @ 2021-03-28 15:43 UTC (permalink / raw)
To: linux-kernel
Cc: Martin Devera, Greg Kroah-Hartman, Rob Herring, Maxime Coquelin,
Alexandre Torgue, Jiri Slaby, Le Ray, fabrice.gasnier,
linux-serial, devicetree, linux-stm32, linux-arm-kernel
Add new rx-tx-swap property to allow for RX & TX pin swapping.
Signed-off-by: Martin Devera <devik@eaxlabs.cz>
Acked-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
Reviewed-by: Rob Herring <robh@kernel.org>
---
v8:
- rebase to the latest tty-next
v7:
- fix yaml linter warning
v6:
- add version changelog
v5:
- yaml fixes based on Rob Herring comments
- add serial.yaml reference
- move compatible from 'then' to 'if'
v3:
- don't allow rx-tx-swap for st,stm32-uart (suggested
by Fabrice Gasnier)
v2:
- change st,swap to rx-tx-swap (suggested by Rob Herring)
---
.../devicetree/bindings/serial/st,stm32-uart.yaml | 29 ++++++++++++++--------
1 file changed, 19 insertions(+), 10 deletions(-)
---
.../devicetree/bindings/serial/st,stm32-uart.yaml | 29 ++++++++++++++--------
1 file changed, 19 insertions(+), 10 deletions(-)
diff --git a/Documentation/devicetree/bindings/serial/st,stm32-uart.yaml b/Documentation/devicetree/bindings/serial/st,stm32-uart.yaml
index 8631678283f9..126e07566965 100644
--- a/Documentation/devicetree/bindings/serial/st,stm32-uart.yaml
+++ b/Documentation/devicetree/bindings/serial/st,stm32-uart.yaml
@@ -9,9 +9,6 @@ maintainers:
title: STMicroelectronics STM32 USART bindings
-allOf:
- - $ref: rs485.yaml
-
properties:
compatible:
enum:
@@ -40,6 +37,8 @@ properties:
uart-has-rtscts: true
+ rx-tx-swap: true
+
dmas:
minItems: 1
maxItems: 2
@@ -66,13 +65,23 @@ properties:
linux,rs485-enabled-at-boot-time: true
rs485-rx-during-tx: true
-if:
- required:
- - st,hw-flow-ctrl
-then:
- properties:
- cts-gpios: false
- rts-gpios: false
+allOf:
+ - $ref: rs485.yaml#
+ - $ref: serial.yaml#
+ - if:
+ required:
+ - st,hw-flow-ctrl
+ then:
+ properties:
+ cts-gpios: false
+ rts-gpios: false
+ - if:
+ properties:
+ compatible:
+ const: st,stm32-uart
+ then:
+ properties:
+ rx-tx-swap: false
required:
- compatible
--
2.11.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [PATCH v8 2/2] tty/serial: Add rx-tx-swap OF option to stm32-usart
2021-03-28 15:43 ` Martin Devera
@ 2021-03-28 15:43 ` Martin Devera
-1 siblings, 0 replies; 69+ messages in thread
From: Martin Devera @ 2021-03-28 15:43 UTC (permalink / raw)
To: linux-kernel
Cc: Martin Devera, Greg Kroah-Hartman, Rob Herring, Maxime Coquelin,
Alexandre Torgue, Jiri Slaby, Le Ray, fabrice.gasnier,
linux-serial, devicetree, linux-stm32, linux-arm-kernel
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>
Acked-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
---
v8:
- rebase to the latest tty-next
v6:
- add version changelog
v4:
- delete superfluous has_swap=false
v3:
- add has_swap to stm32_usart_info (because F4 line
doesn't support swapping)
- move swap variable init from stm32_usart_of_get_port
to stm32_usart_init_port because info struct is not
initialized in stm32_usart_of_get_port yet
- set USART_CR2_SWAP in stm32_usart_startup too
v2:
- change st,swap to rx-tx-swap (pointed out by Rob Herring)
- rebase patches as suggested by Greg Kroah-Hartman
---
drivers/tty/serial/stm32-usart.c | 11 ++++++++++-
drivers/tty/serial/stm32-usart.h | 4 ++++
2 files changed, 14 insertions(+), 1 deletion(-)
---
drivers/tty/serial/stm32-usart.c | 11 ++++++++++-
drivers/tty/serial/stm32-usart.h | 4 ++++
2 files changed, 14 insertions(+), 1 deletion(-)
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);
diff --git a/drivers/tty/serial/stm32-usart.h b/drivers/tty/serial/stm32-usart.h
index a86773f1a4c4..77d1ac082e89 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;
@@ -76,6 +77,7 @@ struct stm32_usart_info stm32f7_info = {
.cfg = {
.uart_enable_bit = 0,
.has_7bits_data = true,
+ .has_swap = true,
.fifosize = 1,
}
};
@@ -97,6 +99,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,
@@ -268,6 +271,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;
bool wakeup_src;
int rdr_mask; /* receive data register mask */
--
2.11.0
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [PATCH v8 2/2] tty/serial: Add rx-tx-swap OF option to stm32-usart
@ 2021-03-28 15:43 ` Martin Devera
0 siblings, 0 replies; 69+ messages in thread
From: Martin Devera @ 2021-03-28 15:43 UTC (permalink / raw)
To: linux-kernel
Cc: Martin Devera, Greg Kroah-Hartman, Rob Herring, Maxime Coquelin,
Alexandre Torgue, Jiri Slaby, Le Ray, fabrice.gasnier,
linux-serial, devicetree, linux-stm32, linux-arm-kernel
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>
Acked-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
---
v8:
- rebase to the latest tty-next
v6:
- add version changelog
v4:
- delete superfluous has_swap=false
v3:
- add has_swap to stm32_usart_info (because F4 line
doesn't support swapping)
- move swap variable init from stm32_usart_of_get_port
to stm32_usart_init_port because info struct is not
initialized in stm32_usart_of_get_port yet
- set USART_CR2_SWAP in stm32_usart_startup too
v2:
- change st,swap to rx-tx-swap (pointed out by Rob Herring)
- rebase patches as suggested by Greg Kroah-Hartman
---
drivers/tty/serial/stm32-usart.c | 11 ++++++++++-
drivers/tty/serial/stm32-usart.h | 4 ++++
2 files changed, 14 insertions(+), 1 deletion(-)
---
drivers/tty/serial/stm32-usart.c | 11 ++++++++++-
drivers/tty/serial/stm32-usart.h | 4 ++++
2 files changed, 14 insertions(+), 1 deletion(-)
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);
diff --git a/drivers/tty/serial/stm32-usart.h b/drivers/tty/serial/stm32-usart.h
index a86773f1a4c4..77d1ac082e89 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;
@@ -76,6 +77,7 @@ struct stm32_usart_info stm32f7_info = {
.cfg = {
.uart_enable_bit = 0,
.has_7bits_data = true,
+ .has_swap = true,
.fifosize = 1,
}
};
@@ -97,6 +99,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,
@@ -268,6 +271,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;
bool wakeup_src;
int rdr_mask; /* receive data register mask */
--
2.11.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 69+ messages in thread
* Re: [PATCH v7 1/2] dt-bindings: serial: Add rx-tx-swap to stm32-usart
2021-03-12 15:37 ` Martin Devera
@ 2021-03-23 22:30 ` Rob Herring
-1 siblings, 0 replies; 69+ messages in thread
From: Rob Herring @ 2021-03-23 22:30 UTC (permalink / raw)
To: Martin Devera
Cc: Le Ray, linux-stm32, fabrice.gasnier, linux-kernel,
Alexandre Torgue, linux-serial, Jiri Slaby, Rob Herring,
linux-arm-kernel, Greg Kroah-Hartman, devicetree,
Maxime Coquelin
On Fri, 12 Mar 2021 16:37:01 +0100, Martin Devera wrote:
> Add new rx-tx-swap property to allow for RX & TX pin swapping.
>
> Signed-off-by: Martin Devera <devik@eaxlabs.cz>
> Acked-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
> ---
> v7:
> - fix yaml linter warning
> v6:
> - add version changelog
> v5:
> - yaml fixes based on Rob Herring comments
> - add serial.yaml reference
> - move compatible from 'then' to 'if'
> v3:
> - don't allow rx-tx-swap for st,stm32-uart (suggested
> by Fabrice Gasnier)
> v2:
> - change st,swap to rx-tx-swap (suggested by Rob Herring)
> ---
> .../devicetree/bindings/serial/st,stm32-uart.yaml | 29 ++++++++++++++--------
> 1 file changed, 19 insertions(+), 10 deletions(-)
>
Reviewed-by: Rob Herring <robh@kernel.org>
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH v7 1/2] dt-bindings: serial: Add rx-tx-swap to stm32-usart
@ 2021-03-23 22:30 ` Rob Herring
0 siblings, 0 replies; 69+ messages in thread
From: Rob Herring @ 2021-03-23 22:30 UTC (permalink / raw)
To: Martin Devera
Cc: Le Ray, linux-stm32, fabrice.gasnier, linux-kernel,
Alexandre Torgue, linux-serial, Jiri Slaby, Rob Herring,
linux-arm-kernel, Greg Kroah-Hartman, devicetree,
Maxime Coquelin
On Fri, 12 Mar 2021 16:37:01 +0100, Martin Devera wrote:
> Add new rx-tx-swap property to allow for RX & TX pin swapping.
>
> Signed-off-by: Martin Devera <devik@eaxlabs.cz>
> Acked-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
> ---
> v7:
> - fix yaml linter warning
> v6:
> - add version changelog
> v5:
> - yaml fixes based on Rob Herring comments
> - add serial.yaml reference
> - move compatible from 'then' to 'if'
> v3:
> - don't allow rx-tx-swap for st,stm32-uart (suggested
> by Fabrice Gasnier)
> v2:
> - change st,swap to rx-tx-swap (suggested by Rob Herring)
> ---
> .../devicetree/bindings/serial/st,stm32-uart.yaml | 29 ++++++++++++++--------
> 1 file changed, 19 insertions(+), 10 deletions(-)
>
Reviewed-by: Rob Herring <robh@kernel.org>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 69+ messages in thread