[PATCH 2/2] serial: stm32: BRR must be set only when usart is disable
Patrice Chotard
patrice.chotard at foss.st.com
Wed May 31 08:01:31 CEST 2023
To avoid spurious chars, BRR register must only be written when
USART is disabled.
Signed-off-by: Patrice Chotard <patrice.chotard at foss.st.com>
---
drivers/serial/serial_stm32.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/serial/serial_stm32.c b/drivers/serial/serial_stm32.c
index 93f70947eec..0085113f674 100644
--- a/drivers/serial/serial_stm32.c
+++ b/drivers/serial/serial_stm32.c
@@ -29,6 +29,10 @@ static void _stm32_serial_setbrg(fdt_addr_t base,
{
bool stm32f4 = uart_info->stm32f4;
u32 int_div, mantissa, fraction, oversampling;
+ u8 uart_enable_bit = uart_info->uart_enable_bit;
+
+ /* BRR register must be set when uart is disabled */
+ clrbits_le32(base + CR1_OFFSET(stm32f4), BIT(uart_enable_bit));
int_div = DIV_ROUND_CLOSEST(clock_rate, baudrate);
@@ -44,6 +48,8 @@ static void _stm32_serial_setbrg(fdt_addr_t base,
fraction = int_div % oversampling;
writel(mantissa | fraction, base + BRR_OFFSET(stm32f4));
+
+ setbits_le32(base + CR1_OFFSET(stm32f4), BIT(uart_enable_bit));
}
static int stm32_serial_setbrg(struct udevice *dev, int baudrate)
--
2.25.1
More information about the U-Boot
mailing list