From 2a22c0e32ddd41dfecc8ef83e21301af602c29d1 Mon Sep 17 00:00:00 2001 From: Eero Nurkkala Date: Fri, 21 Jan 2022 16:31:26 +0200 Subject: [PATCH] risc-v/mpfs: OpenSBI: utilize an index2id table Hart index to hart id table is used to track unused and used harts. This table is useful when configuring only some of the harts for OpenSBI use. Mpfs will always have the hart0 unused, so mark it with -1. Signed-off-by: Eero Nurkkala --- arch/risc-v/src/mpfs/mpfs_opensbi.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/arch/risc-v/src/mpfs/mpfs_opensbi.c b/arch/risc-v/src/mpfs/mpfs_opensbi.c index f45ff512613..b2fdee25121 100644 --- a/arch/risc-v/src/mpfs/mpfs_opensbi.c +++ b/arch/risc-v/src/mpfs/mpfs_opensbi.c @@ -178,13 +178,27 @@ static struct aclint_mswi_data mpfs_mswi = .hart_count = MPFS_HART_COUNT, }; -const struct sbi_platform platform = +/* OpenSBI picks the used and unused harts via the hart_index2id table. + * Unused hart is marked with -1. Mpfs will always have the hart0 unused. + */ + +static const u32 mpfs_hart_index2id[MPFS_HART_COUNT] = +{ + [0] = -1, + [1] = 1, + [2] = 2, + [3] = 3, + [4] = 4, +}; + +static const struct sbi_platform platform = { .opensbi_version = OPENSBI_VERSION, .platform_version = SBI_PLATFORM_VERSION(0x0, 0x01), .name = "Microchip PolarFire(R) SoC", .features = SBI_PLATFORM_DEFAULT_FEATURES, .hart_count = MPFS_HART_COUNT, + .hart_index2id = mpfs_hart_index2id, .hart_stack_size = SBI_PLATFORM_DEFAULT_HART_STACK_SIZE, .platform_ops_addr = (unsigned long)&platform_ops, .firmware_context = 0