diff options
author | Anup Patel <anup.patel@wdc.com> | 2018-12-26 15:57:35 +0300 |
---|---|---|
committer | Anup Patel <anup@brainfault.org> | 2018-12-27 07:05:09 +0300 |
commit | e34aa8a6719dd6c225e576e0617d05735776af6f (patch) | |
tree | 59b041b592b1f139cb7850a522813f392a28c70b /platform/kendryte | |
parent | 7b59571758a5dec75c89928a60d982b29629cee6 (diff) | |
download | opensbi-e34aa8a6719dd6c225e576e0617d05735776af6f.tar.xz |
lib: Simplify sbi_platform irqchip_init() hooks
Instead of having separate irqchip_init() hooks for cold and
warm boot, this patch updates struct sbi_platform to have just
one irqchip_init() hook. The type of boot (cold or warm) is now
a boolean flag parameter for the updated irqchip_init() hook.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Diffstat (limited to 'platform/kendryte')
-rw-r--r-- | platform/kendryte/k210/platform.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/platform/kendryte/k210/platform.c b/platform/kendryte/k210/platform.c index ccb0ad6..43c3244 100644 --- a/platform/kendryte/k210/platform.c +++ b/platform/kendryte/k210/platform.c @@ -35,17 +35,21 @@ static char k210_console_getc(void) return uarths_getc(); } -static int k210_cold_irqchip_init(void) +static int k210_irqchip_init(u32 hartid, bool cold_boot) { - return plic_cold_irqchip_init(PLIC_BASE_ADDR, PLIC_NUM_SOURCES, - K210_HART_COUNT); -} - -static int k210_warm_irqchip_init(u32 core_id) -{ - return plic_warm_irqchip_init(core_id, - (2 * core_id), - (2 * core_id + 1)); + int rc; + + if (cold_boot) { + rc = plic_cold_irqchip_init(PLIC_BASE_ADDR, + PLIC_NUM_SOURCES, + K210_HART_COUNT); + if (rc) + return rc; + } + + return plic_warm_irqchip_init(hartid, + (2 * hartid), + (2 * hartid + 1)); } static int k210_cold_ipi_init(void) @@ -87,8 +91,7 @@ struct sbi_platform platform = { .console_putc = k210_console_putc, .console_getc = k210_console_getc, - .cold_irqchip_init = k210_cold_irqchip_init, - .warm_irqchip_init = k210_warm_irqchip_init, + .irqchip_init = k210_irqchip_init, .cold_ipi_init = k210_cold_ipi_init, .warm_ipi_init = clint_warm_ipi_init, |