tty/serial: Add st,swap OF option to stm32-usart
Subsystems (3)
PATCH 1/2 tty/serial: Add st,swap OF option to stm32-usart
STM32 F7/H7 usarts supports RX & TX pin swapping.
Add option to turn it on.
Tested on STM32MP157.
--- drivers/tty/serial/stm32-usart.c | 3 ++- drivers/tty/serial/stm32-usart.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-)
drivers/tty/serial/stm32-usart.c +2 -1
@@ -780,7 +780,7 @@ static void stm32_set_termios(struct uart_port *port, struct ktermios *termios, 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);
@@ -1097,6 +1097,7 @@ static struct stm32_port *stm32_of_get_stm32_port(struct platform_device *pdev) stm32_ports[id].hw_flow_control =of_property_read_bool (np,"st,hw-flow-ctrl" ); + stm32_ports[id].swap =of_property_read_bool (np,"st,swap" ); stm32_ports[id].port.line = id; stm32_ports[id].cr1_irq =USART_CR1_RXNEIE ; stm32_ports[id].cr3_irq =0 ;
drivers/tty/serial/stm32-usart.h +1 -0
@@ -275,6 +275,7 @@ struct stm32_port {enum dma_cb rx_dma_cb;/* dma rx callback status */ bool tx_dma_busy;/* dma tx busy */ bool hw_flow_control; +bool swap;/* swap RX & TX pins */ bool fifoen;int wakeirq;struct pinctrl_state *console_pins;
Signature · 7 lines
2.11.0 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 2/2 dt-bindings: serial: Add st,swap to stm32-usart
Add new st,swap property to allow for RX & TX pin swapping.
--- Documentation/devicetree/bindings/serial/st,stm32-usart.txt | 1 + 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/serial/st,stm32-usart.txt +1 -0
@@ -24,6 +24,7 @@ Optional properties: - pinctrl-n: Phandle(s) pointing to pin configuration nodes. For Pinctrl properties see ../pinctrl/pinctrl-bindings.txt - st,hw-flow-ctrl: bool flag to enable hardware flow control. +- st,swap: bool flag to swap RX and TX pins. - rs485-rts-delay, rs485-rx-during-tx, rs485-rts-active-low, linux,rs485-enabled-at-boot-time: see rs485.txt. - dmas: phandle(s) to DMA controller node(s). Refer to stm32-dma.txt
Signature · 7 lines
2.11.0 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH 2/2] dt-bindings: serial: Add st,swap to stm32-usart
Quoted 7 lines · Martin Devera
Add new st,swap property to allow for RX & TX pin swapping.
Signed-off-by Martin Devera <[email protected]>--- Documentation/devicetree/bindings/serial/st,stm32-usart.txt | 1 + 1 file changed, 1 insertion(+)
Rob Herring
maintainerRe: [PATCH 2/2] dt-bindings: serial: Add st,swap to stm32-usart
Quoted 11 lines · Rob Herring
Quoted 7 lines · Martin Devera
Add new st,swap property to allow for RX & TX pin swapping.
Signed-off-by Martin Devera <[email protected]>--- Documentation/devicetree/bindings/serial/st,stm32-usart.txt | 1 + 1 file changed, 1 insertion(+)Acked-by Rob Herring <[email protected]>
I take this back as there's a 2nd binding (Qcom GENI) doing swapping. So can you use 'rx-tx-swap' instead.
Rob
PATCH v2 1/2 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.
--- drivers/tty/serial/stm32-usart.c | 3 ++- drivers/tty/serial/stm32-usart.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-)
drivers/tty/serial/stm32-usart.c +2 -1
@@ -758,7 +758,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 ;
@@ -1078,6 +1078,7 @@ static struct stm32_port *stm32_usart_of_get_port(struct platform_device *pdev) stm32_ports[id].hw_flow_control =of_property_read_bool (np,"st,hw-flow-ctrl" )/*deprecated*/ ||of_property_read_bool (np,"uart-has-rtscts" ); + stm32_ports[id].swap =of_property_read_bool (np,"rx-tx-swap" ); stm32_ports[id].port.line = id; stm32_ports[id].cr1_irq =USART_CR1_RXNEIE ; stm32_ports[id].cr3_irq =0 ;
drivers/tty/serial/stm32-usart.h +1 -0
@@ -271,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;int wakeirq;int rdr_mask;/* receive data register mask */
Signature · 7 lines
2.11.0 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v2 2/2 dt-bindings: serial: Add rx-tx-swap to stm32-usart
Add new rx-tx-swap property to allow for RX & TX pin swapping.
--- Documentation/devicetree/bindings/serial/st,stm32-uart.yaml | 4 ++++ 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/serial/st,stm32-uart.yaml +4 -0
@@ -40,6 +40,10 @@ properties: uart-has-rtscts: true + rx-tx-swap: + type: boolean + maxItems: 1 + dmas: minItems: 1 maxItems: 2
Signature · 7 lines
2.11.0 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH v2 2/2] dt-bindings: serial: Add rx-tx-swap to stm32-usart
Quoted 12 lines · Martin Devera
Add new rx-tx-swap property to allow for RX & TX pin swapping.
Signed-off-by Martin Devera <[email protected]>--- Documentation/devicetree/bindings/serial/st,stm32-uart.yaml | 4 ++++ 1 file changed, 4 insertions(+)Documentation/devicetree/bindings/serial/st,stm32-uart.yaml +0
-0
Documentation/devicetree/bindings/serial/st,stm32-uart.yaml properties: · line 46
Quoted 7 lines
Documentation/devicetree/bindings/serial/st,stm32-uart.yaml +4
-0@@ -40,6 +40,10 @@ properties: uart-has-rtscts: true + rx-tx-swap: + type: boolean + maxItems: 1 +
Hi Martin,
This could be restricted to st,stm32f7-uart and st,stm32h7-uart compatibles. This option isn't available on stm32f4 (e.g. st,stm32-uart compatible)
Thanks for your patch,
Best Regards,
Fabrice
Documentation/devicetree/bindings/serial/st,stm32-uart.yaml properties: · line 49
Quoted 4 lines
Documentation/devicetree/bindings/serial/st,stm32-uart.yaml +0
-0dmas: minItems: 1 maxItems: 2
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH v2 1/2] tty/serial: Add rx-tx-swap OF option to stm32-usart
In reply to Martin DeveraQuoted 15 lines · Martin Devera
STM32 F7/H7 usarts supports RX & TX pin swapping.
Add option to turn it on.
Tested on STM32MP157.Signed-off-by Martin Devera <[email protected]>--- drivers/tty/serial/stm32-usart.c | 3 ++- drivers/tty/serial/stm32-usart.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-)drivers/tty/serial/stm32-usart.c +0
-0
drivers/tty/serial/stm32-usart.c static void stm32_usart_set_termios(struct uart_port *port, · line 761
Quoted 5 lines
drivers/tty/serial/stm32-usart.c +1
-1@@ -758,7 +758,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 ;
Hi Martin,
Same could be done in the startup routine, that enables the port for reception (as described in Documentation/driver-api/serial/driver.rst)
drivers/tty/serial/stm32-usart.c static struct stm32_port *stm32_usart_of_get_port(struct platform_device *pdev) · line 1081
Quoted 8 lines
drivers/tty/serial/stm32-usart.c +1
-0cr3 =readl_relaxed (port->membase + ofs->cr3); cr3 &=USART_CR3_TXFTIE |USART_CR3_RXFTCFG_MASK |USART_CR3_RXFTIE |USART_CR3_TXFTCFG_MASK ;@@ -1078,6 +1078,7 @@ static struct stm32_port *stm32_usart_of_get_port(struct platform_device *pdev) stm32_ports[id].hw_flow_control =of_property_read_bool (np,"st,hw-flow-ctrl" )/*deprecated*/ ||of_property_read_bool (np,"uart-has-rtscts" ); + stm32_ports[id].swap =of_property_read_bool (np,"rx-tx-swap" );
The swap option/bit is available starting with stm32f7 (e.g. not on stm32f4).
This could be added to compatible data, e.g. as done for other capabilities in stm32-usart.h. E.g you could add a "has_swap" in struct stm32_usart_config, then use it at probe time:
if (cfg->has_swap) stm32_ports[id].swap = ...;
Thanks for your patch,
Best regards,
Fabrice
Quoted 16 lines
drivers/tty/serial/stm32-usart.c +0
-0stm32_ports[id].port.line = id; stm32_ports[id].cr1_irq =USART_CR1_RXNEIE ; stm32_ports[id].cr3_irq =0 ;drivers/tty/serial/stm32-usart.h +1
-0@@ -271,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;int wakeirq;int rdr_mask;/* receive data register mask */
Re: [PATCH v2 1/2] tty/serial: Add rx-tx-swap OF option to stm32-usart
Quoted 23 lines · Fabrice Gasnier
Quoted 15 lines · Martin Devera
STM32 F7/H7 usarts supports RX & TX pin swapping.
Add option to turn it on.
Tested on STM32MP157.Signed-off-by Martin Devera <[email protected]>--- drivers/tty/serial/stm32-usart.c | 3 ++- drivers/tty/serial/stm32-usart.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-)drivers/tty/serial/stm32-usart.c +0
-0drivers/tty/serial/stm32-usart.c static void stm32_usart_set_termios(struct uart_port *port, · line 761
Quoted 5 lines
drivers/tty/serial/stm32-usart.c +1
-1@@ -758,7 +758,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 ;Hi Martin,
Quoted 2 lines
Same could be done in the startup routine, that enables the port for reception (as described in
Documentation/driver-api/serial/driver.rst)
Hello Fabrice,
I already incorporated all your comments but I'm struggling with the one above. The code must be in stm32_usart_set_termios too, because CR2 is modified. What is the reason to have it in startup() ?
Is it because USART can be started without calling set_termios at all ? Like to reuse bootloader's last settings ?
Thanks, Martin
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH v2 1/2] tty/serial: Add rx-tx-swap OF option to stm32-usart
Quoted 26 lines · Martin DEVERA
Quoted 25 lines · Fabrice Gasnier
Quoted 16 lines · Martin Devera
STM32 F7/H7 usarts supports RX & TX pin swapping.
Add option to turn it on.
Tested on STM32MP157.Signed-off-by Martin Devera <[email protected]>---
drivers/tty/serial/stm32-usart.c| 3 ++-
drivers/tty/serial/stm32-usart.h| 1 +2 files changed, 3 insertions(+), 1 deletion(-)drivers/tty/serial/stm32-usart.c +0
-0drivers/tty/serial/stm32-usart.c static void stm32_usart_set_termios(struct · line 762
Quoted 6 lines
drivers/tty/serial/stm32-usart.c +1
-1@@ -758,7 +758,7 @@ static void stm32_usart_set_termios(structuart_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;Hi Martin,
Quoted 7 lines
Quoted 2 lines
Same could be done in the startup routine, that enables the port for reception (as described in
Documentation/driver-api/serial/driver.rst)Hello Fabrice,
I already incorporated all your comments but I'm struggling with the one above.
The code must be instm32_usart_set_termiostoo, because CR2 is modified.
Hi Martin,
Yes, sure,
Quoted 1 line
What is the reason to have it in
startup()?
RX is enabled at both places. So the swap setting should be there too.
Quoted 1 line
Is it because USART can be started without calling
set_termiosat all ?
Yes, that's what the driver API expects: "startup(port)" ... "Enable the port for reception."
Best Regards,
Fabrice
Quoted 5 lines
Like
to reuse bootloader's last settings ?Thanks, Martin
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v3 1/2 dt-bindings: serial: Add rx-tx-swap to stm32-usart
In reply to Fabrice GasnierAdd new rx-tx-swap property to allow for RX & TX pin swapping.
--- .../devicetree/bindings/serial/st,stm32-uart.yaml | 32 +++++++++++++++------- 1 file changed, 22 insertions(+), 10 deletions(-)
Documentation/devicetree/bindings/serial/st,stm32-uart.yaml +22 -10
@@ -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
Signature · 1 line
2.11.0
PATCH v3 2/2 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.
--- drivers/tty/serial/stm32-usart.c | 11 ++++++++++- drivers/tty/serial/stm32-usart.h | 5 +++++ 2 files changed, 15 insertions(+), 1 deletion(-)
drivers/tty/serial/stm32-usart.c +10 -1
@@ -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 );
drivers/tty/serial/stm32-usart.h +5 -0
@@ -25,6 +25,7 @@ struct stm32_usart_offsets {struct stm32_usart_config {u8 uart_enable_bit;/* USART_CR1_UE */ bool has_7bits_data; +bool has_swap;bool has_wakeup;bool has_fifo;int fifosize;
@@ -55,6 +56,7 @@ struct stm32_usart_info stm32f4_info = { .cfg = { .uart_enable_bit = 13, .has_7bits_data = false, + .has_swap = false, .fifosize = 1, } };
@@ -76,6 +78,7 @@ struct stm32_usart_info stm32f7_info = { .cfg = { .uart_enable_bit = 0, .has_7bits_data = true, + .has_swap = true, .fifosize = 1, } };
@@ -97,6 +100,7 @@ struct stm32_usart_info stm32h7_info = { .cfg = { .uart_enable_bit = 0, .has_7bits_data = true, + .has_swap = true, .has_wakeup = true, .has_fifo = true, .fifosize = 16,
@@ -271,6 +275,7 @@ struct stm32_port {int last_res;bool tx_dma_busy;/* dma tx busy */ bool hw_flow_control; +bool swap;/* swap RX & TX pins */ bool fifoen;int wakeirq;int rdr_mask;/* receive data register mask */
Signature · 1 line
2.11.0
Re: [PATCH v3 2/2] tty/serial: Add rx-tx-swap OF option to stm32-usart
Quoted 59 lines · Martin Devera
STM32 F7/H7 usarts supports RX & TX pin swapping.
Add option to turn it on.
Tested on STM32MP157.Signed-off-by Martin Devera <[email protected]>--- drivers/tty/serial/stm32-usart.c | 11 ++++++++++- drivers/tty/serial/stm32-usart.h | 5 +++++ 2 files changed, 15 insertions(+), 1 deletion(-)drivers/tty/serial/stm32-usart.c +10
-1@@ -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 );drivers/tty/serial/stm32-usart.h +1
-0@@ -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;
drivers/tty/serial/stm32-usart.h struct stm32_usart_info stm32f4_info = { · line 59
Quoted 4 lines
drivers/tty/serial/stm32-usart.h +1
-0@@ -55,6 +56,7 @@ struct stm32_usart_info stm32f4_info = { .cfg = { .uart_enable_bit = 13, .has_7bits_data = false, + .has_swap = false,
Hi Martin,
Only one minor comment from me here. No need to add a false (zero) initialization in this struct. I'm not sure why this is the case for the has_7bits_data here...
With that fixed, you can add my:
Thanks for your patch,
Best Regards,
Fabrice
Quoted 28 lines
drivers/tty/serial/stm32-usart.h +3
-0.fifosize = 1, } };@@ -76,6 +78,7 @@ struct stm32_usart_info stm32f7_info = { .cfg = { .uart_enable_bit = 0, .has_7bits_data = true, + .has_swap = true, .fifosize = 1, } };@@ -97,6 +100,7 @@ struct stm32_usart_info stm32h7_info = { .cfg = { .uart_enable_bit = 0, .has_7bits_data = true, + .has_swap = true, .has_wakeup = true, .has_fifo = true, .fifosize = 16,@@ -271,6 +275,7 @@ struct stm32_port {int last_res;bool tx_dma_busy;/* dma tx busy */ bool hw_flow_control; +bool swap;/* swap RX & TX pins */ bool fifoen;int wakeirq;int rdr_mask;/* receive data register mask */
PATCH v4 1/2 dt-bindings: serial: Add rx-tx-swap to stm32-usart
Add new rx-tx-swap property to allow for RX & TX pin swapping.
--- .../devicetree/bindings/serial/st,stm32-uart.yaml | 32 +++++++++++++++------- 1 file changed, 22 insertions(+), 10 deletions(-)
Documentation/devicetree/bindings/serial/st,stm32-uart.yaml +22 -10
@@ -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
Signature · 1 line
2.11.0
PATCH v4 2/2 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.
--- 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 +10 -1
@@ -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 );
drivers/tty/serial/stm32-usart.h +4 -0
@@ -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 */
Signature · 1 line
2.11.0
Re: [PATCH v4 2/2] tty/serial: Add rx-tx-swap OF option to stm32-usart
Quoted 9 lines · Martin Devera
STM32 F7/H7 usarts supports RX & TX pin swapping.
Add option to turn it on.
Tested on STM32MP157.Signed-off-by Martin Devera <[email protected]>--- 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:
Thanks for your patch,
Best Regards,
Fabrice
Quoted 74 lines
drivers/tty/serial/stm32-usart.c +10
-1@@ -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 );drivers/tty/serial/stm32-usart.h +4
-0@@ -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 */
Re: [PATCH v4 1/2] dt-bindings: serial: Add rx-tx-swap to stm32-usart
In reply to Martin DeveraQuoted 7 lines · Martin Devera
Add new rx-tx-swap property to allow for RX & TX pin swapping.
Signed-off-by Martin Devera <[email protected]>--- .../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:
Thanks!
Fabrice
Quoted 58 lines
Documentation/devicetree/bindings/serial/st,stm32-uart.yaml +22
-10@@ -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
Rob Herring
maintainerRe: [PATCH v4 1/2] dt-bindings: serial: Add rx-tx-swap to stm32-usart
In reply to Martin DeveraQuoted 22 lines · Martin Devera
Add new rx-tx-swap property to allow for RX & TX pin swapping.
Signed-off-by Martin Devera <[email protected]>--- .../devicetree/bindings/serial/st,stm32-uart.yaml | 32 +++++++++++++++------- 1 file changed, 22 insertions(+), 10 deletions(-)Documentation/devicetree/bindings/serial/st,stm32-uart.yaml +0
-3@@ -9,9 +9,6 @@ maintainers: title: STMicroelectronics STM32 USART bindings -allOf: - - $ref: rs485.yaml - properties: compatible: enum:
Documentation/devicetree/bindings/serial/st,stm32-uart.yaml properties: · line 42
Quoted 6 lines
Documentation/devicetree/bindings/serial/st,stm32-uart.yaml +3
-0@@ -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.
Quoted 6 lines
Documentation/devicetree/bindings/serial/st,stm32-uart.yaml +1
-0+ dmas: minItems: 1 maxItems: 2@@ -66,13 +67,24 @@ properties: linux,rs485-enabled-at-boot-time: true
Documentation/devicetree/bindings/serial/st,stm32-uart.yaml properties: · line 70
Quoted 10 lines
Documentation/devicetree/bindings/serial/st,stm32-uart.yaml +1
-7rs485-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.
Quoted 7 lines
Documentation/devicetree/bindings/serial/st,stm32-uart.yaml +7
-0+ - $ref: rs485.yaml + - if: + required: + - st,hw-flow-ctrl + then: + properties: + cts-gpios: false
Documentation/devicetree/bindings/serial/st,stm32-uart.yaml properties: · line 87
Quoted 10 lines
Documentation/devicetree/bindings/serial/st,stm32-uart.yaml +10
-0+ 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
PATCH v5 1/2 dt-bindings: serial: Add rx-tx-swap to stm32-usart
Add new rx-tx-swap property to allow for RX & TX pin swapping.
--- .../devicetree/bindings/serial/st,stm32-uart.yaml | 29 ++++++++++++++-------- 1 file changed, 19 insertions(+), 10 deletions(-)
Documentation/devicetree/bindings/serial/st,stm32-uart.yaml +19 -10
@@ -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
Signature · 7 lines
2.11.0 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v5 2/2 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.
--- 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 +10 -1
@@ -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 );
drivers/tty/serial/stm32-usart.h +4 -0
@@ -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 */
Signature · 7 lines
2.11.0 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Greg Kroah-Hartman
maintainerRe: [PATCH v5 2/2] tty/serial: Add rx-tx-swap OF option to stm32-usart
Quoted 10 lines · Martin Devera
STM32 F7/H7 usarts supports RX & TX pin swapping.
Add option to turn it on.
Tested on STM32MP157.Signed-off-by Martin Devera <[email protected]>Acked-by Fabrice Gasnier <[email protected]>--- 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
PATCH v6 1/2 dt-bindings: serial: Add rx-tx-swap to stm32-usart
Add new rx-tx-swap property to allow for RX & TX pin swapping.
---
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(-)
Documentation/devicetree/bindings/serial/st,stm32-uart.yaml +19 -10
@@ -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
Signature · 1 line
2.11.0
PATCH v6 2/2 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.
---
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 +10 -1
@@ -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 );
drivers/tty/serial/stm32-usart.h +4 -0
@@ -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 */
Signature · 1 line
2.11.0
Rob Herring
maintainerRe: [PATCH v6 1/2] dt-bindings: serial: Add rx-tx-swap to stm32-usart
In reply to Martin DeveraQuoted 16 lines · Martin Devera
Add new rx-tx-swap property to allow for RX & TX pin swapping.
Signed-off-by Martin Devera <[email protected]>Acked-by Fabrice Gasnier <[email protected]>---
v6:
- add version changelog
v5:
- yaml fixes based on Rob Herring comments
- addserial.yamlreference
- 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)
Quoted 4 lines
--- .../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.
Re: [PATCH v6 1/2] dt-bindings: serial: Add rx-tx-swap to stm32-usart
Quoted 30 lines · Rob Herring
Quoted 16 lines · Martin Devera
Add new rx-tx-swap property to allow for RX & TX pin swapping.
Signed-off-by Martin Devera <[email protected]>Acked-by Fabrice Gasnier <[email protected]>---
v6:
- add version changelog
v5:
- yaml fixes based on Rob Herring comments
- addserial.yamlreference
- 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)Quoted 4 lines
--- .../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:
Quoted 9 lines
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
Re: [PATCH v6 1/2] dt-bindings: serial: Add rx-tx-swap to stm32-usart
Quoted 35 lines · Martin DEVERA
Quoted 34 lines · Rob Herring
Quoted 19 lines · Martin Devera
Add new rx-tx-swap property to allow for RX & TX pin swapping.
Signed-off-by Martin Devera <[email protected]>Acked-by Fabrice Gasnier <[email protected]>---
v6:
- add version changelog
v5:
- yaml fixes based on Rob Herring comments
- addserial.yamlreference
- 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
++++++++++++++--------Quoted 2 lines
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.
Quoted 8 lines
Quoted 6 lines
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.
PATCH v7 1/2 dt-bindings: serial: Add rx-tx-swap to stm32-usart
In reply to Rob HerringAdd new rx-tx-swap property to allow for RX & TX pin swapping.
---
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(-)
Documentation/devicetree/bindings/serial/st,stm32-uart.yaml +19 -10
@@ -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
Signature · 1 line
2.11.0
PATCH v7 2/2 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.
---
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 +10 -1
@@ -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 );
drivers/tty/serial/stm32-usart.h +4 -0
@@ -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 */
Signature · 1 line
2.11.0
Greg Kroah-Hartman
maintainerRe: [PATCH v7 2/2] tty/serial: Add rx-tx-swap OF option to stm32-usart
Quoted 6 lines · Martin Devera
STM32 F7/H7 usarts supports RX & TX pin swapping.
Add option to turn it on.
Tested on STM32MP157.Signed-off-by Martin Devera <[email protected]>Acked-by Fabrice Gasnier <[email protected]>
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
PATCH v8 1/2 dt-bindings: serial: Add rx-tx-swap to stm32-usart
Add new rx-tx-swap property to allow for RX & TX pin swapping.
---
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(-)
Documentation/devicetree/bindings/serial/st,stm32-uart.yaml +19 -10
@@ -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
Signature · 1 line
2.11.0
PATCH v8 2/2 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.
---
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(-)
drivers/tty/serial/stm32-usart.c +10 -1
@@ -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 );
drivers/tty/serial/stm32-usart.h +4 -0
@@ -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 */
Signature · 1 line
2.11.0
Re: [PATCH v7 1/2] dt-bindings: serial: Add rx-tx-swap to stm32-usart
In reply to Martin DeveraQuoted 18 lines · Martin Devera
Add new rx-tx-swap property to allow for RX & TX pin swapping.
Signed-off-by Martin Devera <[email protected]>Acked-by Fabrice Gasnier <[email protected]>---
v7:
- fix yaml linter warning
v6:
- add version changelog
v5:
- yaml fixes based on Rob Herring comments
- addserial.yamlreference
- 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)
Quoted 4 lines
--- .../devicetree/bindings/serial/st,stm32-uart.yaml | 29 ++++++++++++++-------- 1 file changed, 19 insertions(+), 10 deletions(-)
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH v3 2/2] tty/serial: Add rx-tx-swap OF option to stm32-usart
In reply to Fabrice GasnierQuoted 66 lines · Fabrice Gasnier
Quoted 59 lines · Martin Devera
STM32 F7/H7 usarts supports RX & TX pin swapping.
Add option to turn it on.
Tested on STM32MP157.Signed-off-by Martin Devera <[email protected]>--- drivers/tty/serial/stm32-usart.c | 11 ++++++++++- drivers/tty/serial/stm32-usart.h | 5 +++++ 2 files changed, 15 insertions(+), 1 deletion(-)drivers/tty/serial/stm32-usart.c +10
-1@@ -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 );drivers/tty/serial/stm32-usart.h +1
-0@@ -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;drivers/tty/serial/stm32-usart.h struct stm32_usart_info stm32f4_info = { · line 59
Quoted 4 lines
drivers/tty/serial/stm32-usart.h +1
-0@@ -55,6 +56,7 @@ struct stm32_usart_info stm32f4_info = { .cfg = { .uart_enable_bit = 13, .has_7bits_data = false, + .has_swap = false,Hi Martin,
Quoted 7 lines
Only one minor comment from me here. No need to add a false (zero) initialization in this struct. I'm not sure why this is the case for the
has_7bits_datahere...With that fixed, you can add my:
Acked-by Fabrice Gasnier <[email protected]>
The has_7bits_data was what made me a bit unsure. Ok fixed now. Thank you for your review.
Martin
Greg Kroah-Hartman
maintainerQuoted 9 lines · Martin Devera
STM32 F7/H7 usarts supports RX & TX pin swapping.
Add option to turn it on.
Tested on STM32MP157.Signed-off-by Martin Devera <[email protected]>--- drivers/tty/serial/stm32-usart.c | 3 ++- drivers/tty/serial/stm32-usart.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-)
This, and patch 2/2, do not apply to my tty-next branch at all. What did you make them against?
Please rebase and resend the series.
thanks,
greg k-h