diff options
author | Toshifumi NISHINAGA <tnishinaga.dev@gmail.com> | 2016-07-08 01:02:24 +0900 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2016-07-14 18:22:41 -0400 |
commit | ba0a3c16e0c6697f0254644cc7a9849b77000eb8 (patch) | |
tree | 476ef70d03a07553b2371a0e77e5fddff090e6e9 /drivers/serial | |
parent | a3e2efcb42be378659a5443346ca5c77317c30b9 (diff) | |
download | u-boot-ba0a3c16e0c6697f0254644cc7a9849b77000eb8.tar.gz |
stm32: clk: Add 200MHz clock configuration for stm32f746 discovery board
This patch adds 200MHz clock configuration for stm32f746 discovery board.
This patch is based on STM32F4 and emcraft's[1].
[1]: https://github.com/EmcraftSystems/u-boot
Signed-off-by: Toshifumi NISHINAGA <tnishinaga.dev@gmail.com>
Diffstat (limited to 'drivers/serial')
-rw-r--r-- | drivers/serial/serial_stm32x7.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/drivers/serial/serial_stm32x7.c b/drivers/serial/serial_stm32x7.c index cfbfab7e41..592c0bde36 100644 --- a/drivers/serial/serial_stm32x7.c +++ b/drivers/serial/serial_stm32x7.c @@ -9,6 +9,7 @@ #include <dm.h> #include <asm/io.h> #include <serial.h> +#include <asm/arch/stm32.h> #include <dm/platform_data/serial_stm32x7.h> #include "serial_stm32x7.h" @@ -18,7 +19,20 @@ static int stm32_serial_setbrg(struct udevice *dev, int baudrate) { struct stm32x7_serial_platdata *plat = dev->platdata; struct stm32_usart *const usart = plat->base; - writel(plat->clock/baudrate, &usart->brr); + u32 clock, int_div, frac_div, tmp; + + if (((u32)usart & STM32_BUS_MASK) == APB1_PERIPH_BASE) + clock = clock_get(CLOCK_APB1); + else if (((u32)usart & STM32_BUS_MASK) == APB2_PERIPH_BASE) + clock = clock_get(CLOCK_APB2); + else + return -EINVAL; + + int_div = (25 * clock) / (4 * baudrate); + tmp = ((int_div / 100) << USART_BRR_M_SHIFT) & USART_BRR_M_MASK; + frac_div = int_div - (100 * (tmp >> USART_BRR_M_SHIFT)); + tmp |= (((frac_div * 16) + 50) / 100) & USART_BRR_F_MASK; + writel(tmp, &usart->brr); return 0; } |