Jonathan Neuschäfer has uploaded this change for review. ( https://review.coreboot.org/29335
Change subject: soc/sifive/fu540: Add helper function to get tlclk frequency ......................................................................
soc/sifive/fu540: Add helper function to get tlclk frequency
tlclk is not specific to the UART block in the FU540, so let's calculate its frequency in clock.c.
Change-Id: I270920027f1132253e413a1bf9feb4fe279b651a Signed-off-by: Jonathan Neuschäfer j.neuschaefer@gmx.net --- M src/soc/sifive/fu540/clock.c M src/soc/sifive/fu540/include/soc/clock.h M src/soc/sifive/fu540/uart.c 3 files changed, 13 insertions(+), 5 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/35/29335/1
diff --git a/src/soc/sifive/fu540/clock.c b/src/soc/sifive/fu540/clock.c index a8b61f1..edebe42 100644 --- a/src/soc/sifive/fu540/clock.c +++ b/src/soc/sifive/fu540/clock.c @@ -262,3 +262,14 @@ / (divr + 1) / (1ul << divq); } + +/* Get the TileLink clock's frequency, in KHz */ +int clock_get_tlclk_khz(void) +{ + /* + * The TileLink bus and most peripherals use tlclk, which is coreclk/2, + * as input. + */ + + return clock_get_coreclk_khz() / 2; +} diff --git a/src/soc/sifive/fu540/include/soc/clock.h b/src/soc/sifive/fu540/include/soc/clock.h index d54c666..706c9c0 100644 --- a/src/soc/sifive/fu540/include/soc/clock.h +++ b/src/soc/sifive/fu540/include/soc/clock.h @@ -18,5 +18,6 @@
void clock_init(void); int clock_get_coreclk_khz(void); +int clock_get_tlclk_khz(void);
#endif /* __SOC_SIFIVE_HIFIFE_U_CLOCK_H__ */ diff --git a/src/soc/sifive/fu540/uart.c b/src/soc/sifive/fu540/uart.c index 454b13d..b59b789 100644 --- a/src/soc/sifive/fu540/uart.c +++ b/src/soc/sifive/fu540/uart.c @@ -29,9 +29,5 @@
unsigned int uart_platform_refclk(void) { - /* - * The SiFive UART uses tlclk, which is coreclk/2, as input - */ - - return clock_get_coreclk_khz() * KHz / 2; + return clock_get_tlclk_khz() * KHz; }