diff options
author | Anup Patel <anup.patel@wdc.com> | 2020-05-12 18:38:31 +0530 |
---|---|---|
committer | Anup Patel <anup@brainfault.org> | 2020-05-23 10:36:43 +0530 |
commit | a9a97511851198559e75640a9e5e67f65695dc2e (patch) | |
tree | 3c7a01bfa30aab552fbb049f5fea25b8007a2d83 /platform/template | |
parent | d30bb684481b6be642a0eaa9e7f0778d6519cc15 (diff) |
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/template')
-rw-r--r-- | platform/template/platform.c | 21 |
1 files changed, 13 insertions, 8 deletions
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; } |