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 a31329971133946d383fc16fc2eaf99d78f0bcbb..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()) {
@@ -52,6 +65,27 @@ void __init efi_runtime_init(void)
        set_bit(EFI_RUNTIME_SERVICES, &efi.flags);
 }
 
+unsigned long __initdata screen_info_table = EFI_INVALID_TABLE_ADDR;
+
+static void __init init_screen_info(void)
+{
+       struct screen_info *si;
+
+       if (screen_info_table == EFI_INVALID_TABLE_ADDR)
+               return;
+
+       si = early_memremap(screen_info_table, sizeof(*si));
+       if (!si) {
+               pr_err("Could not map screen_info config table\n");
+               return;
+       }
+       screen_info = *si;
+       memset(si, 0, sizeof(*si));
+       early_memunmap(si, sizeof(*si));
+
+       memblock_reserve(screen_info.lfb_base, screen_info.lfb_size);
+}
+
 void __init efi_init(void)
 {
        int size;
@@ -80,8 +114,7 @@ void __init efi_init(void)
 
        set_bit(EFI_CONFIG_TABLES, &efi.flags);
 
-       if (screen_info.orig_video_isVGA == VIDEO_TYPE_EFI)
-               memblock_reserve(screen_info.lfb_base, screen_info.lfb_size);
+       init_screen_info();
 
        if (boot_memmap == EFI_INVALID_TABLE_ADDR)
                return;