summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorAnup Patel <anup.patel@wdc.com>2020-05-12 16:08:31 +0300
committerAnup Patel <anup@brainfault.org>2020-05-23 08:06:43 +0300
commita9a97511851198559e75640a9e5e67f65695dc2e (patch)
tree3c7a01bfa30aab552fbb049f5fea25b8007a2d83 /platform
parentd30bb684481b6be642a0eaa9e7f0778d6519cc15 (diff)
downloadopensbi-a9a97511851198559e75640a9e5e67f65695dc2e.tar.xz
lib: utils: Allow CLINT functions to be used for multiple CLINTs
We extend CLINT cold init function to have a "struct clint_data *" parameter pointing to CLINT details. This allows platforms to use CLINT functions for multiple CLINT instances. When multiple CLINTs are present, the platform can also provide one of the CLINT as reference CLINT for other CLINTs. This will help CLINTs to sync their time value with reference CLINT using a time_delta computed in warm init function. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
Diffstat (limited to 'platform')
-rw-r--r--platform/fpga/ariane/platform.c15
-rw-r--r--platform/fpga/openpiton/platform.c20
-rw-r--r--platform/kendryte/k210/platform.c13
-rw-r--r--platform/nuclei/ux600/platform.c12
-rw-r--r--platform/sifive/fu540/platform.c12
-rw-r--r--platform/template/platform.c21
-rw-r--r--platform/thead/c910/platform.c14
7 files changed, 73 insertions, 34 deletions
diff --git a/platform/fpga/ariane/platform.c b/platform/fpga/ariane/platform.c
index 275f2ce..a4d437e 100644
--- a/platform/fpga/ariane/platform.c
+++ b/platform/fpga/ariane/platform.c
@@ -24,13 +24,20 @@
#define ARIANE_PLIC_ADDR 0xc000000
#define ARIANE_PLIC_NUM_SOURCES 3
#define ARIANE_HART_COUNT 1
-#define ARIANE_CLINT_ADDR 0x2000000
+#define ARIANE_CLINT_ADDR 0x2000000
static struct plic_data plic = {
.addr = ARIANE_PLIC_ADDR,
.num_src = ARIANE_PLIC_NUM_SOURCES,
};
+static struct clint_data clint = {
+ .addr = ARIANE_CLINT_ADDR,
+ .first_hartid = 0,
+ .hart_count = ARIANE_HART_COUNT,
+ .has_64bit_mmio = TRUE,
+};
+
/*
* Ariane platform early initialization.
*/
@@ -116,8 +123,7 @@ static int ariane_ipi_init(bool cold_boot)
int ret;
if (cold_boot) {
- ret = clint_cold_ipi_init(ARIANE_CLINT_ADDR,
- ARIANE_HART_COUNT);
+ ret = clint_cold_ipi_init(&clint);
if (ret)
return ret;
}
@@ -133,8 +139,7 @@ static int ariane_timer_init(bool cold_boot)
int ret;
if (cold_boot) {
- ret = clint_cold_timer_init(ARIANE_CLINT_ADDR,
- ARIANE_HART_COUNT, TRUE);
+ ret = clint_cold_timer_init(&clint, NULL);
if (ret)
return ret;
}
diff --git a/platform/fpga/openpiton/platform.c b/platform/fpga/openpiton/platform.c
index e56ee51..095004d 100644
--- a/platform/fpga/openpiton/platform.c
+++ b/platform/fpga/openpiton/platform.c
@@ -35,7 +35,13 @@ static struct plic_data plic = {
.addr = OPENPITON_DEFAULT_PLIC_ADDR,
.num_src = OPENPITON_DEFAULT_PLIC_NUM_SOURCES,
};
-static unsigned long clint_addr = OPENPITON_DEFAULT_CLINT_ADDR;
+
+static struct clint_data clint = {
+ .addr = OPENPITON_DEFAULT_CLINT_ADDR,
+ .first_hartid = 0,
+ .hart_count = OPENPITON_DEFAULT_HART_COUNT,
+ .has_64bit_mmio = TRUE,
+};
/*
* OpenPiton platform early initialization.
@@ -45,7 +51,7 @@ static int openpiton_early_init(bool cold_boot)
void *fdt;
struct platform_uart_data uart_data;
struct plic_data plic_data;
- unsigned long clint_data;
+ unsigned long clint_addr;
int rc;
if (!cold_boot)
@@ -60,9 +66,9 @@ static int openpiton_early_init(bool cold_boot)
if (!rc)
plic = plic_data;
- rc = fdt_parse_compat_addr(fdt, &clint_data, "riscv,clint0");
+ rc = fdt_parse_compat_addr(fdt, &clint_addr, "riscv,clint0");
if (!rc)
- clint_addr = clint_data;
+ clint.addr = clint_addr;
return 0;
}
@@ -143,8 +149,7 @@ static int openpiton_ipi_init(bool cold_boot)
int ret;
if (cold_boot) {
- ret = clint_cold_ipi_init(clint_addr,
- OPENPITON_DEFAULT_HART_COUNT);
+ ret = clint_cold_ipi_init(&clint);
if (ret)
return ret;
}
@@ -160,8 +165,7 @@ static int openpiton_timer_init(bool cold_boot)
int ret;
if (cold_boot) {
- ret = clint_cold_timer_init(clint_addr,
- OPENPITON_DEFAULT_HART_COUNT, TRUE);
+ ret = clint_cold_timer_init(&clint, NULL);
if (ret)
return ret;
}
diff --git a/platform/kendryte/k210/platform.c b/platform/kendryte/k210/platform.c
index db2186a..ef0f18f 100644
--- a/platform/kendryte/k210/platform.c
+++ b/platform/kendryte/k210/platform.c
@@ -22,6 +22,13 @@ static struct plic_data plic = {
.num_src = K210_PLIC_NUM_SOURCES,
};
+static struct clint_data clint = {
+ .addr = K210_CLINT_BASE_ADDR,
+ .first_hartid = 0,
+ .hart_count = K210_HART_COUNT,
+ .has_64bit_mmio = TRUE,
+};
+
static u32 k210_get_clk_freq(void)
{
u32 clksel0, pll0;
@@ -76,8 +83,7 @@ static int k210_ipi_init(bool cold_boot)
int rc;
if (cold_boot) {
- rc = clint_cold_ipi_init(K210_CLINT_BASE_ADDR,
- K210_HART_COUNT);
+ rc = clint_cold_ipi_init(&clint);
if (rc)
return rc;
}
@@ -90,8 +96,7 @@ static int k210_timer_init(bool cold_boot)
int rc;
if (cold_boot) {
- rc = clint_cold_timer_init(K210_CLINT_BASE_ADDR,
- K210_HART_COUNT, TRUE);
+ rc = clint_cold_timer_init(&clint, NULL);
if (rc)
return rc;
}
diff --git a/platform/nuclei/ux600/platform.c b/platform/nuclei/ux600/platform.c
index f999c99..ad4ba2b 100644
--- a/platform/nuclei/ux600/platform.c
+++ b/platform/nuclei/ux600/platform.c
@@ -48,6 +48,13 @@ static struct plic_data plic = {
.num_src = UX600_PLIC_NUM_SOURCES,
};
+static struct clint_data clint = {
+ .addr = UX600_CLINT_TIMER_ADDR,
+ .first_hartid = 0,
+ .hart_count = UX600_HART_COUNT,
+ .has_64bit_mmio = TRUE,
+};
+
static void ux600_modify_dt(void *fdt)
{
fdt_fixups(fdt);
@@ -92,7 +99,7 @@ static int ux600_ipi_init(bool cold_boot)
int rc;
if (cold_boot) {
- rc = clint_cold_ipi_init(UX600_CLINT_TIMER_ADDR, UX600_HART_COUNT);
+ rc = clint_cold_ipi_init(&clint);
if (rc)
return rc;
}
@@ -105,8 +112,7 @@ static int ux600_timer_init(bool cold_boot)
int rc;
if (cold_boot) {
- rc = clint_cold_timer_init(UX600_CLINT_TIMER_ADDR,
- UX600_HART_COUNT, TRUE);
+ rc = clint_cold_timer_init(&clint, NULL);
if (rc)
return rc;
}
diff --git a/platform/sifive/fu540/platform.c b/platform/sifive/fu540/platform.c
index 7a62fc3..48d887f 100644
--- a/platform/sifive/fu540/platform.c
+++ b/platform/sifive/fu540/platform.c
@@ -51,6 +51,13 @@ static struct plic_data plic = {
.num_src = FU540_PLIC_NUM_SOURCES,
};
+static struct clint_data clint = {
+ .addr = FU540_CLINT_ADDR,
+ .first_hartid = 0,
+ .hart_count = FU540_HART_COUNT,
+ .has_64bit_mmio = TRUE,
+};
+
static void fu540_modify_dt(void *fdt)
{
fdt_cpu_fixup(fdt);
@@ -107,7 +114,7 @@ static int fu540_ipi_init(bool cold_boot)
int rc;
if (cold_boot) {
- rc = clint_cold_ipi_init(FU540_CLINT_ADDR, FU540_HART_COUNT);
+ rc = clint_cold_ipi_init(&clint);
if (rc)
return rc;
}
@@ -125,8 +132,7 @@ static int fu540_timer_init(bool cold_boot)
int rc;
if (cold_boot) {
- rc = clint_cold_timer_init(FU540_CLINT_ADDR,
- FU540_HART_COUNT, TRUE);
+ rc = clint_cold_timer_init(&clint, NULL);
if (rc)
return rc;
}
diff --git a/platform/template/platform.c b/platform/template/platform.c
index c845380..9cd750e 100644
--- a/platform/template/platform.c
+++ b/platform/template/platform.c
@@ -17,10 +17,10 @@
#include <sbi_utils/serial/uart8250.h>
#include <sbi_utils/sys/clint.h>
-#define PLATFORM_PLIC_ADDR 0xc000000
-#define PLATFORM_PLIC_NUM_SOURCES 128
-#define PLATFORM_HART_COUNT 4
-#define PLATFORM_CLINT_ADDR 0x2000000
+#define PLATFORM_PLIC_ADDR 0xc000000
+#define PLATFORM_PLIC_NUM_SOURCES 128
+#define PLATFORM_HART_COUNT 4
+#define PLATFORM_CLINT_ADDR 0x2000000
#define PLATFORM_UART_ADDR 0x09000000
#define PLATFORM_UART_INPUT_FREQ 10000000
#define PLATFORM_UART_BAUDRATE 115200
@@ -30,6 +30,13 @@ static struct plic_data plic = {
.num_src = PLATFORM_PLIC_NUM_SOURCES,
};
+static struct clint_data clint = {
+ .addr = PLATFORM_CLINT_ADDR,
+ .first_hartid = 0,
+ .hart_count = PLATFORM_HART_COUNT,
+ .has_64bit_mmio = TRUE,
+};
+
/*
* Platform early initialization.
*/
@@ -100,8 +107,7 @@ static int platform_ipi_init(bool cold_boot)
/* Example if the generic CLINT driver is used */
if (cold_boot) {
- ret = clint_cold_ipi_init(PLATFORM_CLINT_ADDR,
- PLATFORM_HART_COUNT);
+ ret = clint_cold_ipi_init(&clint, NULL);
if (ret)
return ret;
}
@@ -136,8 +142,7 @@ static int platform_timer_init(bool cold_boot)
/* Example if the generic CLINT driver is used */
if (cold_boot) {
- ret = clint_cold_timer_init(PLATFORM_CLINT_ADDR,
- PLATFORM_HART_COUNT, TRUE);
+ ret = clint_cold_timer_init(&clint);
if (ret)
return ret;
}
diff --git a/platform/thead/c910/platform.c b/platform/thead/c910/platform.c
index 82f910a..df7658a 100644
--- a/platform/thead/c910/platform.c
+++ b/platform/thead/c910/platform.c
@@ -15,6 +15,13 @@
static struct c910_regs_struct c910_regs;
+static struct clint_data clint = {
+ .addr = 0, /* Updated at cold boot time */
+ .first_hartid = 0,
+ .hart_count = C910_HART_COUNT,
+ .has_64bit_mmio = FALSE,
+};
+
static int c910_early_init(bool cold_boot)
{
if (cold_boot) {
@@ -78,7 +85,8 @@ static int c910_ipi_init(bool cold_boot)
int rc;
if (cold_boot) {
- rc = clint_cold_ipi_init(c910_regs.clint_base_addr, C910_HART_COUNT);
+ clint.addr = c910_regs.clint_base_addr;
+ rc = clint_cold_ipi_init(&clint);
if (rc)
return rc;
}
@@ -91,8 +99,8 @@ static int c910_timer_init(bool cold_boot)
int ret;
if (cold_boot) {
- ret = clint_cold_timer_init(c910_regs.clint_base_addr,
- C910_HART_COUNT, FALSE);
+ clint.addr = c910_regs.clint_base_addr;
+ ret = clint_cold_timer_init(&clint, NULL);
if (ret)
return ret;
}