Merge tag 'loongarch-6.2' of git://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai...
[sfrench/cifs-2.6.git] / arch / loongarch / kernel / efi.c
index d75ce73e8ff82b77a3491aeb15a772740084b085..3d448fef3af454ce46dc5b52e2cbcfa56d0be11d 100644 (file)
@@ -28,16 +28,29 @@ static unsigned long efi_nr_tables;
 static unsigned long efi_config_table;
 
 static unsigned long __initdata boot_memmap = EFI_INVALID_TABLE_ADDR;
+static unsigned long __initdata fdt_pointer = EFI_INVALID_TABLE_ADDR;
 
 static efi_system_table_t *efi_systab;
 static efi_config_table_type_t arch_tables[] __initdata = {
        {LINUX_EFI_BOOT_MEMMAP_GUID,    &boot_memmap,   "MEMMAP" },
+       {DEVICE_TREE_GUID,              &fdt_pointer,   "FDTPTR" },
        {},
 };
 
+void __init *efi_fdt_pointer(void)
+{
+       if (!efi_systab)
+               return NULL;
+
+       if (fdt_pointer == EFI_INVALID_TABLE_ADDR)
+               return NULL;
+
+       return early_memremap_ro(fdt_pointer, SZ_64K);
+}
+
 void __init efi_runtime_init(void)
 {
-       if (!efi_enabled(EFI_BOOT))
+       if (!efi_enabled(EFI_BOOT) || !efi_systab->runtime)
                return;
 
        if (efi_runtime_disabled()) {