Merge https://gitlab.denx.de/u-boot/custodians/u-boot-riscv
[oweals/u-boot.git] / drivers / video / sunxi / sunxi_de2.c
index 860187323c964128727a7d112a756f4e3a4fe2a9..8333ddc44c08d49c8ac11d41cf082a06c8fdce0b 100644 (file)
@@ -1,15 +1,15 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Allwinner DE2 display driver
  *
  * (C) Copyright 2017 Jernej Skrabec <jernej.skrabec@siol.net>
- *
- * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
 #include <display.h>
 #include <dm.h>
 #include <edid.h>
+#include <efi_loader.h>
 #include <fdtdec.h>
 #include <fdt_support.h>
 #include <video.h>
@@ -222,6 +222,13 @@ static int sunxi_de2_init(struct udevice *dev, ulong fbbase,
        uc_priv->bpix = l2bpp;
        debug("fb=%lx, size=%d %d\n", fbbase, uc_priv->xsize, uc_priv->ysize);
 
+#ifdef CONFIG_EFI_LOADER
+       efi_add_memory_map(fbbase,
+                          ALIGN(timing.hactive.typ * timing.vactive.typ *
+                          (1 << l2bpp) / 8, EFI_PAGE_SIZE) >> EFI_PAGE_SHIFT,
+                          EFI_RESERVED_MEMORY_TYPE, false);
+#endif
+
        return 0;
 }
 
@@ -340,6 +347,9 @@ int sunxi_simplefb_setup(void *blob)
        if (ret) {
                debug("DE2 not present\n");
                return 0;
+       } else if (!device_active(de2)) {
+               debug("DE2 present but not probed\n");
+               return 0;
        }
 
        ret = uclass_find_device_by_name(UCLASS_DISPLAY,