summaryrefslogtreecommitdiffstats
path: root/src/soc/sifive
diff options
context:
space:
mode:
Diffstat (limited to 'src/soc/sifive')
-rw-r--r--src/soc/sifive/fu540/clock.c11
-rw-r--r--src/soc/sifive/fu540/include/soc/clock.h1
-rw-r--r--src/soc/sifive/fu540/uart.c6
3 files changed, 13 insertions, 5 deletions
diff --git a/src/soc/sifive/fu540/clock.c b/src/soc/sifive/fu540/clock.c
index 8aaba35d6cb6..597b2069db02 100644
--- a/src/soc/sifive/fu540/clock.c
+++ b/src/soc/sifive/fu540/clock.c
@@ -250,3 +250,14 @@ int clock_get_coreclk_khz(void)
/ (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 d54c6662c211..706c9c00f7ed 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 454b13d11146..b59b78902a7d 100644
--- a/src/soc/sifive/fu540/uart.c
+++ b/src/soc/sifive/fu540/uart.c
@@ -29,9 +29,5 @@ uintptr_t uart_platform_base(int idx)
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;
}