platform: generic: add extensions_init handler and platform-override
authorHeiko Stuebner <heiko@sntech.de>
Tue, 4 Oct 2022 16:42:26 +0000 (18:42 +0200)
committerAnup Patel <anup@brainfault.org>
Thu, 13 Oct 2022 04:22:06 +0000 (09:52 +0530)
Init of non-standard extensions is a platform-specific thing,
so allow generic platforms to do this via a platform-override.

Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
Reviewed-by: Guo Ren <guoren@kernel.org>
Reviewed-by: Anup Patel <anup@brainfault.org>
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
platform/generic/include/platform_override.h
platform/generic/platform.c

index e55da25..7f1558d 100644 (file)
@@ -10,6 +10,7 @@
 #ifndef __PLATFORM_OVERRIDE_H__
 #define __PLATFORM_OVERRIDE_H__
 
+#include <sbi/sbi_hart.h>
 #include <sbi/sbi_types.h>
 #include <sbi/sbi_trap.h>
 
@@ -22,6 +23,8 @@ struct platform_override {
        void (*early_exit)(const struct fdt_match *match);
        void (*final_exit)(const struct fdt_match *match);
        int (*fdt_fixup)(void *fdt, const struct fdt_match *match);
+       int (*extensions_init)(const struct fdt_match *match,
+                              struct sbi_hart_features *hfeatures);
        int (*vendor_ext_check)(long extid, const struct fdt_match *match);
        int (*vendor_ext_provider)(long extid, long funcid,
                                   const struct sbi_trap_regs *regs,
index bf51aba..595b0fd 100644 (file)
@@ -204,6 +204,15 @@ static void generic_final_exit(void)
                generic_plat->final_exit(generic_plat_match);
 }
 
+static int generic_extensions_init(struct sbi_hart_features *hfeatures)
+{
+       if (generic_plat && generic_plat->extensions_init)
+               return generic_plat->extensions_init(generic_plat_match,
+                                                    hfeatures);
+
+       return 0;
+}
+
 static int generic_domains_init(void)
 {
        return fdt_domains_populate(fdt_get_address());
@@ -257,6 +266,7 @@ const struct sbi_platform_operations platform_ops = {
        .final_init             = generic_final_init,
        .early_exit             = generic_early_exit,
        .final_exit             = generic_final_exit,
+       .extensions_init        = generic_extensions_init,
        .domains_init           = generic_domains_init,
        .console_init           = generic_console_init,
        .irqchip_init           = fdt_irqchip_init,