summaryrefslogtreecommitdiff
path: root/chip/stm32/uart.c
diff options
context:
space:
mode:
authorDaisuke Nojiri <dnojiri@chromium.org>2016-04-28 12:09:55 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-04-29 07:34:52 -0700
commit2b79492093935e3fe2aa2117216a819a3974d70b (patch)
treef1827fc71dbdc8ca4c74284842c3227eb13c7be8 /chip/stm32/uart.c
parent66473502c94b71b752e72907b062357f943d818c (diff)
downloadchrome-ec-2b79492093935e3fe2aa2117216a819a3974d70b.tar.gz
STM32: Set UART clock sources to SYSCLK
Since uart_freq_change assumes we drive UARTs at system clock, we need to set UARTs clock sources accordingly. This will allow us to clock up the chip without worrying about prescaler values set for HCLK and PCLK or the on/off status of HSI. BUG=none BRANCH=tot TEST=make buildall. Verified LPUART on stm32l476g-eval. Change-Id: I02898921e31b68cacbc2235a29c47a212c350afe Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/341260 Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'chip/stm32/uart.c')
-rw-r--r--chip/stm32/uart.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/chip/stm32/uart.c b/chip/stm32/uart.c
index d18b4b781a..8fbb6a3436 100644
--- a/chip/stm32/uart.c
+++ b/chip/stm32/uart.c
@@ -268,8 +268,12 @@ void uart_init(void)
STM32_RCC_CFGR3 |= 0x030000; /* USART2 clock source from HSI(8MHz) */
#endif /* UARTN */
#elif defined(CHIP_FAMILY_STM32L4)
- STM32_RCC_CCIPR |= (0x2 << STM32_RCC_CCIPR_USART1SEL_SHIFT);
- STM32_RCC_CCIPR |= (0x2 << STM32_RCC_CCIPR_LPUART1SEL_SHIFT);
+ STM32_RCC_CCIPR &= ~STM32_RCC_CCIPR_USART1SEL_MASK;
+ STM32_RCC_CCIPR |= (STM32_RCC_CCIPR_SYSCLK <<
+ STM32_RCC_CCIPR_USART1SEL_SHIFT);
+ STM32_RCC_CCIPR &= ~STM32_RCC_CCIPR_LPUART1SEL_MASK;
+ STM32_RCC_CCIPR |= (STM32_RCC_CCIPR_SYSCLK <<
+ STM32_RCC_CCIPR_LPUART1SEL_SHIFT);
#endif /* CHIP_FAMILY_STM32F0 || CHIP_FAMILY_STM32F3 */
/* Enable USART clock */