Skip to content

Commit ba35b4d

Browse files
kbidanidkalowsk
authored andcommitted
driver: uart: stm32: Disable UART DMA before shutdown
Use LL_USART_DisableDMAReq_RX to disable UART RX DMA requests. This should be called before entering shutdown mode. Force to use UART_STM32U5_ERRATA_DMAT_LOWPOWER when POWEROFF is selected. This ensure the system to shut down properly instead of hanging due to DMA staying active. Signed-off-by: Khaoula Bidani <[email protected]> Signed-off-by: Julien Racki <[email protected]>
1 parent 0a87817 commit ba35b4d

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

drivers/serial/Kconfig.stm32

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ if UART_STM32U5_ERRATA_DMAT_AFFECTED
3939

4040
choice UART_STM32U5_ERRATA_DMAT
4141
prompt "Workaround for DMAT errata on selected devices"
42-
default UART_STM32U5_ERRATA_DMAT_LOWPOWER if PM
4342
default UART_STM32U5_ERRATA_DMAT_NOCLEAR if !PM
43+
default UART_STM32U5_ERRATA_DMAT_LOWPOWER
4444
help
4545
Handles erratum "USART does not generate DMA requests after
4646
setting/clearing DMAT bit" as described in the errata sheets:
@@ -59,6 +59,7 @@ config UART_STM32U5_ERRATA_DMAT_LOWPOWER
5959

6060
config UART_STM32U5_ERRATA_DMAT_NOCLEAR
6161
bool "Do not clear DMAT"
62+
depends on !POWEROFF # DMAT must be clear to enter LL_PWR_SHUTDOWN_MODE
6263
help
6364
This option keeps DMAT bit set. This may cause additional power
6465
consumption in STOP low-power modes.

drivers/serial/uart_stm32.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1508,8 +1508,11 @@ static inline void uart_stm32_dma_rx_enable(const struct device *dev)
15081508

15091509
static inline void uart_stm32_dma_rx_disable(const struct device *dev)
15101510
{
1511+
const struct uart_stm32_config *config = dev->config;
15111512
struct uart_stm32_data *data = dev->data;
15121513

1514+
LL_USART_DisableDMAReq_RX(config->usart);
1515+
15131516
data->dma_rx.enabled = false;
15141517
}
15151518

0 commit comments

Comments
 (0)