stm32 usart wakeup rework
cover stm32 usart wakeup rework
This series reworks stm32 usart wakeup management.
Alexandre Torgue (1):
serial: stm32: update wakeup IRQ management
Erwan Le Ray (4):
serial: stm32: rework wakeup management
serial: stm32: clean wakeup handling in serial_suspend irqchip/stm32: add usart instances exti direct event support
ARM: dts: stm32: Add wakeup management on stm32mp15x UART nodes
arch/arm/boot/dts/stm32mp151.dtsi | 24 ++++++++++++------- drivers/irqchip/irq-stm32-exti.c | 7 ++++++ drivers/tty/serial/stm32-usart.c | 40 +++++++++++-------------------- drivers/tty/serial/stm32-usart.h | 2 +- 4 files changed, 38 insertions(+), 35 deletions(-)
Signature · 7 lines
2.17.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 1/5 serial: stm32: rework wakeup management
Rework wakeup management by activating uart as wakeup source when usart device OR its tty virtual device parent is wakeup source.
This patch aim to avoid potential misalignment between serial and tty wakeup flags.
drivers/tty/serial/stm32-usart.c +3 -3
@@ -1534,7 +1534,7 @@ static int __maybe_unused stm32_usart_serial_suspend(struct device *dev)uart_suspend_port (&stm32_usart_driver, port); -if (device_may_wakeup (dev)) +if (device_may_wakeup (dev) ||device_wakeup_path (dev))stm32_usart_serial_en_wakeup (port, true);else stm32_usart_serial_en_wakeup (port, false);
@@ -1546,7 +1546,7 @@ static int __maybe_unused stm32_usart_serial_suspend(struct device *dev)* capabilities. */ if (console_suspend_enabled || !uart_console (port)) { -if (device_may_wakeup (dev)) +if (device_may_wakeup (dev) ||device_wakeup_path (dev))pinctrl_pm_select_idle_state (dev);else pinctrl_pm_select_sleep_state (dev);
@@ -1561,7 +1561,7 @@ static int __maybe_unused stm32_usart_serial_resume(struct device *dev)pinctrl_pm_select_default_state (dev); -if (device_may_wakeup (dev)) +if (device_may_wakeup (dev) ||device_wakeup_path (dev))stm32_usart_serial_en_wakeup (port, false);return uart_resume_port (&stm32_usart_driver, port);
Signature · 7 lines
2.17.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 2/5 serial: stm32: clean wakeup handling in serial_suspend
In reply to Erwan Le RayRemove useless call to stm32_usart_serial_en_wakeup() routine in suspend callback. When called with "false" argument, this routine is clearing UESM and WUFIE bits if usart is not wakeup source. Those bits are already cleared in set_termios(), and then in serial_resume() callback when usart is wakeup source.
drivers/tty/serial/stm32-usart.c +0 -2
@@ -1536,8 +1536,6 @@ static int __maybe_unused stm32_usart_serial_suspend(struct device *dev)if (device_may_wakeup (dev) ||device_wakeup_path (dev))stm32_usart_serial_en_wakeup (port, true); -else -stm32_usart_serial_en_wakeup (port, false);/* * When "no_console_suspend" is enabled, keep the pinctrl default state
Signature · 1 line
2.17.1
PATCH 3/5 irqchip/stm32: add usart instances exti direct event support
In reply to Erwan Le RayAdd following usart instances exti direct event support (used for UART wake up).
- exti 26 (USART1) is mapped to GIC 37
- exti 27 (USART2) is mapped to GIC 38
- exti 28 (USART3) is mapped to GIC 39
- exti 29 (USART6) is mapped to GIC 71
- exti 31 (UART5) is mapped to GIC 53
- exti 32 (UART7) is mapped to GIC 82
- exti 33 (UART8) is mapped to GIC 83
drivers/irqchip/irq-stm32-exti.c +7 -0
@@ -193,7 +193,14 @@ static const struct stm32_desc_irq stm32mp1_desc_irq[] = { { .exti = 23, .irq_parent = 72, .chip = &stm32_exti_h_chip_direct }, { .exti = 24, .irq_parent = 95, .chip = &stm32_exti_h_chip_direct }, { .exti = 25, .irq_parent = 107, .chip = &stm32_exti_h_chip_direct }, + { .exti = 26, .irq_parent = 37, .chip = &stm32_exti_h_chip_direct }, + { .exti = 27, .irq_parent = 38, .chip = &stm32_exti_h_chip_direct }, + { .exti = 28, .irq_parent = 39, .chip = &stm32_exti_h_chip_direct }, + { .exti = 29, .irq_parent = 71, .chip = &stm32_exti_h_chip_direct }, { .exti = 30, .irq_parent = 52, .chip = &stm32_exti_h_chip_direct }, + { .exti = 31, .irq_parent = 53, .chip = &stm32_exti_h_chip_direct }, + { .exti = 32, .irq_parent = 82, .chip = &stm32_exti_h_chip_direct }, + { .exti = 33, .irq_parent = 83, .chip = &stm32_exti_h_chip_direct }, { .exti = 47, .irq_parent = 93, .chip = &stm32_exti_h_chip_direct }, { .exti = 48, .irq_parent = 138, .chip = &stm32_exti_h_chip_direct }, { .exti = 50, .irq_parent = 139, .chip = &stm32_exti_h_chip_direct },
Signature · 1 line
2.17.1
[irqchip: irq/irqchip-next] irqchip/stm32: Add usart instances exti direct event support
The following commit has been merged into the irq/irqchip-next branch of irqchip:
The following commit has been merged into the irq/irqchip-next branch of irqchip:
Commit-ID: e12c455055e9abc7403ce532616c0124a9d85ee7 Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms/e12c455055e9abc7403ce532616c0124a9d85ee7 Author: Erwan Le Ray <[email protected]> AuthorDate: Fri, 19 Mar 2021 19:42:51 +01:00 Committer: Marc Zyngier <[email protected]> CommitterDate: Wed, 07 Apr 2021 13:25:52 +01:00
irqchip/stm32: Add usart instances exti direct event support
Add following usart instances exti direct event support (used for UART wake up).
- exti 26 (USART1) is mapped to GIC 37
- exti 27 (USART2) is mapped to GIC 38
- exti 28 (USART3) is mapped to GIC 39
- exti 29 (USART6) is mapped to GIC 71
- exti 31 (UART5) is mapped to GIC 53
- exti 32 (UART7) is mapped to GIC 82
- exti 33 (UART8) is mapped to GIC 83
--- drivers/irqchip/irq-stm32-exti.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/irqchip/irq-stm32-exti.c +7 -0
@@ -193,7 +193,14 @@ static const struct stm32_desc_irq stm32mp1_desc_irq[] = { { .exti = 23, .irq_parent = 72, .chip = &stm32_exti_h_chip_direct }, { .exti = 24, .irq_parent = 95, .chip = &stm32_exti_h_chip_direct }, { .exti = 25, .irq_parent = 107, .chip = &stm32_exti_h_chip_direct }, + { .exti = 26, .irq_parent = 37, .chip = &stm32_exti_h_chip_direct }, + { .exti = 27, .irq_parent = 38, .chip = &stm32_exti_h_chip_direct }, + { .exti = 28, .irq_parent = 39, .chip = &stm32_exti_h_chip_direct }, + { .exti = 29, .irq_parent = 71, .chip = &stm32_exti_h_chip_direct }, { .exti = 30, .irq_parent = 52, .chip = &stm32_exti_h_chip_direct }, + { .exti = 31, .irq_parent = 53, .chip = &stm32_exti_h_chip_direct }, + { .exti = 32, .irq_parent = 82, .chip = &stm32_exti_h_chip_direct }, + { .exti = 33, .irq_parent = 83, .chip = &stm32_exti_h_chip_direct }, { .exti = 47, .irq_parent = 93, .chip = &stm32_exti_h_chip_direct }, { .exti = 48, .irq_parent = 138, .chip = &stm32_exti_h_chip_direct }, { .exti = 50, .irq_parent = 139, .chip = &stm32_exti_h_chip_direct },
PATCH 4/5 serial: stm32: update wakeup IRQ management
In reply to Erwan Le RayFrom: Alexandre Torgue <[email protected]>
The wakeup specific IRQ management is no more needed to wake up the stm32 plaform. A relationship has been established between the EXTI and the EVENT IRQ, just need to declare the EXTI interrupt instead of the UART event IRQ.
drivers/tty/serial/stm32-usart.c +11 -21
@@ -924,7 +924,7 @@ static void stm32_usart_set_termios(struct uart_port *port, }/* Configure wake up from low power on start bit detection */ -if (stm32_port->wakeirq >0 ) { +if (stm32_port->wakeup_src) { cr3 &= ~USART_CR3_WUS_MASK ; cr3 |=USART_CR3_WUS_START_BIT ; }
@@ -1044,11 +1044,8 @@ static int stm32_usart_init_port(struct stm32_port *stm32port,if (ret)return ret; -if (stm32port->info->cfg.has_wakeup) { - stm32port->wakeirq =platform_get_irq_optional (pdev,1 ); -if (stm32port->wakeirq <=0 && stm32port->wakeirq != -ENXIO ) -return stm32port->wakeirq ? : -ENODEV ; - } + stm32port->wakeup_src = stm32port->info->cfg.has_wakeup && +of_property_read_bool (pdev->dev.of_node,"wakeup-source" ); stm32port->fifoen = stm32port->info->cfg.has_fifo;
@@ -1283,17 +1280,11 @@ static int stm32_usart_serial_probe(struct platform_device *pdev)if (ret)return ret; -if (stm32port->wakeirq >0 ) { - ret =device_init_wakeup (&pdev->dev, true); -if (ret) - goto err_uninit; - - ret =dev_pm_set_dedicated_wake_irq (&pdev->dev, - stm32port->wakeirq); +if (stm32port->wakeup_src) { +device_set_wakeup_capable (&pdev->dev, true); + ret =dev_pm_set_wake_irq (&pdev->dev, stm32port->port.irq);if (ret) goto err_nowup; - -device_set_wakeup_enable (&pdev->dev, false); } ret =stm32_usart_of_dma_rx_probe (stm32port, pdev);
@@ -1343,14 +1334,13 @@ static int stm32_usart_serial_probe(struct platform_device *pdev)TX_BUF_L , stm32port->tx_buf, stm32port->tx_dma_buf); -if (stm32port->wakeirq >0 ) +if (stm32port->wakeup_src)dev_pm_clear_wake_irq (&pdev->dev); err_nowup: -if (stm32port->wakeirq >0 ) -device_init_wakeup (&pdev->dev, false); +if (stm32port->wakeup_src) +device_set_wakeup_capable (&pdev->dev, false); -err_uninit:stm32_usart_deinit_port (stm32port);return ret;
@@ -1396,7 +1386,7 @@ static int stm32_usart_serial_remove(struct platform_device *pdev)TX_BUF_L , stm32_port->tx_buf, stm32_port->tx_dma_buf); -if (stm32_port->wakeirq >0 ) { +if (stm32_port->wakeup_src) {dev_pm_clear_wake_irq (&pdev->dev);device_init_wakeup (&pdev->dev, false); }
@@ -1512,7 +1502,7 @@ static void __maybe_unused stm32_usart_serial_en_wakeup(struct uart_port *port,struct stm32_port *stm32_port =to_stm32_port (port);const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; -if (stm32_port->wakeirq <=0 ) +if (!stm32_port->wakeup_src)return ;/*
drivers/tty/serial/stm32-usart.h +1 -1
@@ -269,7 +269,7 @@ struct stm32_port {bool tx_dma_busy;/* dma tx busy */ bool hw_flow_control;bool fifoen; -int wakeirq; +bool wakeup_src;int rdr_mask;/* receive data register mask */ struct mctrl_gpios *gpios;/* modem control gpios */ };
Signature · 1 line
2.17.1
PATCH 5/5 ARM: dts: stm32: Add wakeup management on stm32mp15x UART nodes
In reply to Erwan Le RayAdd EXTI lines to the following UART nodes which are used for wakeup from CStop.
- EXTI line 26 to USART1
- EXTI line 27 to USART2
- EXTI line 28 to USART3
- EXTI line 29 to USART6
- EXTI line 30 to UART4
- EXTI line 31 to UART5
- EXTI line 32 to UART7
- EXTI line 33 to UART8
arch/arm/boot/dts/stm32mp151.dtsi +16 -8
@@ -452,32 +452,36 @@ usart2: serial@4000e000 { compatible = "st,stm32h7-uart"; reg = <0x4000e000 0x400>; - interrupts = <GIC_SPI 38 IRQ_TYPE_LEVEL_HIGH>; + interrupts-extended = <&exti 27 IRQ_TYPE_LEVEL_HIGH>; clocks = <&rcc USART2_K>; + wakeup-source; status = "disabled"; }; usart3: serial@4000f000 { compatible = "st,stm32h7-uart"; reg = <0x4000f000 0x400>; - interrupts = <GIC_SPI 39 IRQ_TYPE_LEVEL_HIGH>; + interrupts-extended = <&exti 28 IRQ_TYPE_LEVEL_HIGH>; clocks = <&rcc USART3_K>; + wakeup-source; status = "disabled"; }; uart4: serial@40010000 { compatible = "st,stm32h7-uart"; reg = <0x40010000 0x400>; - interrupts = <GIC_SPI 52 IRQ_TYPE_LEVEL_HIGH>; + interrupts-extended = <&exti 30 IRQ_TYPE_LEVEL_HIGH>; clocks = <&rcc UART4_K>; + wakeup-source; status = "disabled"; }; uart5: serial@40011000 { compatible = "st,stm32h7-uart"; reg = <0x40011000 0x400>; - interrupts = <GIC_SPI 53 IRQ_TYPE_LEVEL_HIGH>; + interrupts-extended = <&exti 31 IRQ_TYPE_LEVEL_HIGH>; clocks = <&rcc UART5_K>; + wakeup-source; status = "disabled"; };
@@ -577,16 +581,18 @@ uart7: serial@40018000 { compatible = "st,stm32h7-uart"; reg = <0x40018000 0x400>; - interrupts = <GIC_SPI 82 IRQ_TYPE_LEVEL_HIGH>; + interrupts-extended = <&exti 32 IRQ_TYPE_LEVEL_HIGH>; clocks = <&rcc UART7_K>; + wakeup-source; status = "disabled"; }; uart8: serial@40019000 { compatible = "st,stm32h7-uart"; reg = <0x40019000 0x400>; - interrupts = <GIC_SPI 83 IRQ_TYPE_LEVEL_HIGH>; + interrupts-extended = <&exti 33 IRQ_TYPE_LEVEL_HIGH>; clocks = <&rcc UART8_K>; + wakeup-source; status = "disabled"; };
@@ -665,8 +671,9 @@ usart6: serial@44003000 { compatible = "st,stm32h7-uart"; reg = <0x44003000 0x400>; - interrupts = <GIC_SPI 71 IRQ_TYPE_LEVEL_HIGH>; + interrupts-extended = <&exti 29 IRQ_TYPE_LEVEL_HIGH>; clocks = <&rcc USART6_K>; + wakeup-source; status = "disabled"; };
@@ -1505,8 +1512,9 @@ usart1: serial@5c000000 { compatible = "st,stm32h7-uart"; reg = <0x5c000000 0x400>; - interrupts = <GIC_SPI 37 IRQ_TYPE_LEVEL_HIGH>; + interrupts-extended = <&exti 26 IRQ_TYPE_LEVEL_HIGH>; clocks = <&rcc USART1_K>; + wakeup-source; status = "disabled"; };
Signature · 1 line
2.17.1
Marc Zyngier
AppliedRe: (subset) [PATCH 0/5] stm32 usart wakeup rework
In reply to Erwan Le RayQuoted 5 lines · Erwan Le Ray
This series reworks stm32 usart wakeup management.
Alexandre Torgue (1):
serial: stm32: update wakeup IRQ management
Quoted 7 lines
Erwan Le Ray (4):
serial: stm32: rework wakeup management
serial: stm32: clean wakeup handling inserial_suspendirqchip/stm32: add usart instances exti direct event support
ARM: dts: stm32: Add wakeup management on stm32mp15x UART nodes[...]
Applied to irq/irqchip-next, thanks!
[3/5] irqchip/stm32: add usart instances exti direct event support
commit: e12c455055e9abc7403ce532616c0124a9d85ee7
Cheers,
M.
Signature · 1 line
Without deviation from the norm, progress is not possible.