summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorAnup Patel <anup.patel@wdc.com>2021-09-14 19:21:48 +0300
committerAnup Patel <anup@brainfault.org>2021-09-26 17:22:10 +0300
commit12e7af9ab7ef9adf61b9138e2c38e3aeef3c140b (patch)
tree67d388a1d7a4435060beace5dbaba32679adef41 /platform
parent72154f4708de79816f0178b16223afa352b20e30 (diff)
downloadopensbi-12e7af9ab7ef9adf61b9138e2c38e3aeef3c140b.tar.xz
lib: sbi: Add timer frequency to struct sbi_timer_device
Generic mdelay() and udelay() functions can be provided by the sbi_timer framework if timer frequency is available in the timer instance provided by the platform support or timer driver. This patch adds timer frequency (timer_freq) member in the struct sbi_timer_device for above purpose. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Xiang W <wxjstz@126.com>
Diffstat (limited to 'platform')
-rw-r--r--platform/fpga/ariane/platform.c2
-rw-r--r--platform/fpga/openpiton/platform.c7
-rw-r--r--platform/kendryte/k210/platform.c1
-rw-r--r--platform/kendryte/k210/platform.h2
-rw-r--r--platform/nuclei/ux600/platform.c1
-rw-r--r--platform/template/platform.c2
6 files changed, 14 insertions, 1 deletions
diff --git a/platform/fpga/ariane/platform.c b/platform/fpga/ariane/platform.c
index 58a46c0..5acc446 100644
--- a/platform/fpga/ariane/platform.c
+++ b/platform/fpga/ariane/platform.c
@@ -26,6 +26,7 @@
#define ARIANE_PLIC_NUM_SOURCES 3
#define ARIANE_HART_COUNT 1
#define ARIANE_CLINT_ADDR 0x2000000
+#define ARIANE_ACLINT_MTIMER_FREQ 1000000
#define ARIANE_ACLINT_MSWI_ADDR (ARIANE_CLINT_ADDR + \
CLINT_MSWI_OFFSET)
#define ARIANE_ACLINT_MTIMER_ADDR (ARIANE_CLINT_ADDR + \
@@ -44,6 +45,7 @@ static struct aclint_mswi_data mswi = {
};
static struct aclint_mtimer_data mtimer = {
+ .mtime_freq = ARIANE_ACLINT_MTIMER_FREQ,
.mtime_addr = ARIANE_ACLINT_MTIMER_ADDR +
ACLINT_DEFAULT_MTIME_OFFSET,
.mtime_size = ACLINT_DEFAULT_MTIME_SIZE,
diff --git a/platform/fpga/openpiton/platform.c b/platform/fpga/openpiton/platform.c
index a9bfa99..924053e 100644
--- a/platform/fpga/openpiton/platform.c
+++ b/platform/fpga/openpiton/platform.c
@@ -26,6 +26,7 @@
#define OPENPITON_DEFAULT_PLIC_NUM_SOURCES 2
#define OPENPITON_DEFAULT_HART_COUNT 3
#define OPENPITON_DEFAULT_CLINT_ADDR 0xfff1020000
+#define OPENPITON_DEFAULT_ACLINT_MTIMER_FREQ 1000000
#define OPENPITON_DEFAULT_ACLINT_MSWI_ADDR \
(OPENPITON_DEFAULT_CLINT_ADDR + CLINT_MSWI_OFFSET)
#define OPENPITON_DEFAULT_ACLINT_MTIMER_ADDR \
@@ -49,6 +50,7 @@ static struct aclint_mswi_data mswi = {
};
static struct aclint_mtimer_data mtimer = {
+ .mtime_freq = OPENPITON_DEFAULT_ACLINT_MTIMER_FREQ,
.mtime_addr = OPENPITON_DEFAULT_ACLINT_MTIMER_ADDR +
ACLINT_DEFAULT_MTIME_OFFSET,
.mtime_size = ACLINT_DEFAULT_MTIME_SIZE,
@@ -68,6 +70,7 @@ static int openpiton_early_init(bool cold_boot)
void *fdt;
struct platform_uart_data uart_data;
struct plic_data plic_data;
+ unsigned long aclint_freq;
uint64_t clint_addr;
int rc;
@@ -83,6 +86,10 @@ static int openpiton_early_init(bool cold_boot)
if (!rc)
plic = plic_data;
+ rc = fdt_parse_timebase_frequency(fdt, &aclint_freq);
+ if (!rc)
+ mtimer.mtime_freq = aclint_freq;
+
rc = fdt_parse_compat_addr(fdt, &clint_addr, "riscv,clint0");
if (!rc) {
mswi.addr = clint_addr;
diff --git a/platform/kendryte/k210/platform.c b/platform/kendryte/k210/platform.c
index ee4c223..35cec5f 100644
--- a/platform/kendryte/k210/platform.c
+++ b/platform/kendryte/k210/platform.c
@@ -42,6 +42,7 @@ static struct aclint_mswi_data mswi = {
};
static struct aclint_mtimer_data mtimer = {
+ .mtime_freq = K210_ACLINT_MTIMER_FREQ,
.mtime_addr = K210_ACLINT_MTIMER_ADDR +
ACLINT_DEFAULT_MTIME_OFFSET,
.mtime_size = ACLINT_DEFAULT_MTIME_SIZE,
diff --git a/platform/kendryte/k210/platform.h b/platform/kendryte/k210/platform.h
index 0a32530..be52aa3 100644
--- a/platform/kendryte/k210/platform.h
+++ b/platform/kendryte/k210/platform.h
@@ -14,7 +14,7 @@
#define K210_HART_COUNT 2
#define K210_UART_BAUDRATE 115200
-
+#define K210_ACLINT_MTIMER_FREQ 7800000
#define K210_CLK0_FREQ 26000000UL
#define K210_PLIC_NUM_SOURCES 65
diff --git a/platform/nuclei/ux600/platform.c b/platform/nuclei/ux600/platform.c
index ab0becc..6bef4c4 100644
--- a/platform/nuclei/ux600/platform.c
+++ b/platform/nuclei/ux600/platform.c
@@ -74,6 +74,7 @@ static struct aclint_mswi_data mswi = {
};
static struct aclint_mtimer_data mtimer = {
+ .mtime_freq = UX600_TIMER_FREQ,
.mtime_addr = UX600_ACLINT_MTIMER_ADDR +
ACLINT_DEFAULT_MTIME_OFFSET,
.mtime_size = ACLINT_DEFAULT_MTIME_SIZE,
diff --git a/platform/template/platform.c b/platform/template/platform.c
index 4528822..d6806e6 100644
--- a/platform/template/platform.c
+++ b/platform/template/platform.c
@@ -22,6 +22,7 @@
#define PLATFORM_PLIC_NUM_SOURCES 128
#define PLATFORM_HART_COUNT 4
#define PLATFORM_CLINT_ADDR 0x2000000
+#define PLATFORM_ACLINT_MTIMER_FREQ 10000000
#define PLATFORM_ACLINT_MSWI_ADDR (PLATFORM_CLINT_ADDR + \
CLINT_MSWI_OFFSET)
#define PLATFORM_ACLINT_MTIMER_ADDR (PLATFORM_CLINT_ADDR + \
@@ -43,6 +44,7 @@ static struct aclint_mswi_data mswi = {
};
static struct aclint_mtimer_data mtimer = {
+ .mtime_freq = PLATFORM_ACLINT_MTIMER_FREQ,
.mtime_addr = PLATFORM_ACLINT_MTIMER_ADDR +
ACLINT_DEFAULT_MTIME_OFFSET,
.mtime_size = ACLINT_DEFAULT_MTIME_SIZE,