From 5a24afadb821076c14bc9f054790c99fedeac1dc Mon Sep 17 00:00:00 2001 From: Kumar Gala Date: Thu, 4 Oct 2018 17:06:25 -0500 Subject: [PATCH] drivers: serial: uart_sifive: Get clock frequency from device tree Move to getting the clock frequency of the uart from the device tree instead of a define in the board file. Cleaned up hifive1 board code to reflect this change in addition to the driver. Signed-off-by: Kumar Gala --- boards/riscv32/hifive1/board.h | 10 ---------- boards/riscv32/hifive1/dts.fixup | 2 ++ boards/riscv32/hifive1/hifive1.dts | 5 +++++ drivers/serial/uart_sifive.c | 4 ++-- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/boards/riscv32/hifive1/board.h b/boards/riscv32/hifive1/board.h index 236825e6c86..7f321e76352 100644 --- a/boards/riscv32/hifive1/board.h +++ b/boards/riscv32/hifive1/board.h @@ -10,14 +10,4 @@ #include -/* - * UART clock configurations - * - * Define them here so that it can be replaced by global variables - * on other boards where the uart clock is determined dynamically - * following the PLL configuration - */ -#define uart_sifive_port_0_clk_freq 16000000 -#define uart_sifive_port_1_clk_freq 16000000 - #endif /* __INC_BOARD_H */ diff --git a/boards/riscv32/hifive1/dts.fixup b/boards/riscv32/hifive1/dts.fixup index a800e2c28a2..8fca623449d 100644 --- a/boards/riscv32/hifive1/dts.fixup +++ b/boards/riscv32/hifive1/dts.fixup @@ -46,10 +46,12 @@ #define CONFIG_SIFIVE_UART_0_IRQ_0 SIFIVE_UART0_10013000_IRQ_0 #define CONFIG_SIFIVE_UART_0_LABEL SIFIVE_UART0_10013000_LABEL #define CONFIG_SIFIVE_UART_0_SIZE SIFIVE_UART0_10013000_SIZE +#define CONFIG_SIFIVE_UART_0_CLK_FREQ SIFIVE_UART0_10013000_CLOCK_FREQUENCY /* UART 1 */ #define CONFIG_SIFIVE_UART_1_BASE_ADDR SIFIVE_UART0_10023000_BASE_ADDRESS #define CONFIG_SIFIVE_UART_1_CURRENT_SPEED SIFIVE_UART0_10023000_CURRENT_SPEED #define CONFIG_SIFIVE_UART_1_IRQ_0 SIFIVE_UART0_10023000_IRQ_0 #define CONFIG_SIFIVE_UART_1_SIZE SIFIVE_UART0_10023000_SIZE +#define CONFIG_SIFIVE_UART_1_CLK_FREQ SIFIVE_UART0_10023000_CLOCK_FREQUENCY diff --git a/boards/riscv32/hifive1/hifive1.dts b/boards/riscv32/hifive1/hifive1.dts index 139aa81f178..677a45d852f 100644 --- a/boards/riscv32/hifive1/hifive1.dts +++ b/boards/riscv32/hifive1/hifive1.dts @@ -39,6 +39,11 @@ &uart0 { status = "ok"; current-speed = <115200>; + clock-frequency = <16000000>; +}; + +&uart1 { + clock-frequency = <16000000>; }; &spi0 { diff --git a/drivers/serial/uart_sifive.c b/drivers/serial/uart_sifive.c index 447cc4aa56f..d4026bec034 100644 --- a/drivers/serial/uart_sifive.c +++ b/drivers/serial/uart_sifive.c @@ -386,7 +386,7 @@ static void uart_sifive_irq_cfg_func_0(void); static const struct uart_sifive_device_config uart_sifive_dev_cfg_0 = { .port = CONFIG_SIFIVE_UART_0_BASE_ADDR, - .sys_clk_freq = uart_sifive_port_0_clk_freq, + .sys_clk_freq = CONFIG_SIFIVE_UART_0_CLK_FREQ, .baud_rate = CONFIG_SIFIVE_UART_0_CURRENT_SPEED, .rxcnt_irq = CONFIG_UART_SIFIVE_PORT_0_RXCNT_IRQ, .txcnt_irq = CONFIG_UART_SIFIVE_PORT_0_TXCNT_IRQ, @@ -425,7 +425,7 @@ static void uart_sifive_irq_cfg_func_1(void); static const struct uart_sifive_device_config uart_sifive_dev_cfg_1 = { .port = CONFIG_SIFIVE_UART_1_BASE_ADDR, - .sys_clk_freq = uart_sifive_port_1_clk_freq, + .sys_clk_freq = CONFIG_SIFIVE_UART_1_CLK_FREQ, .baud_rate = CONFIG_SIFIVE_UART_1_CURRENT_SPEED, .rxcnt_irq = CONFIG_UART_SIFIVE_PORT_1_RXCNT_IRQ, .txcnt_irq = CONFIG_UART_SIFIVE_PORT_1_TXCNT_IRQ,