]> git.sur5r.net Git - u-boot/blobdiff - drivers/video/sunxi/sunxi_de2.c
video: sunxi: de2: Reserve the fb region in the EFI memory map
[u-boot] / drivers / video / sunxi / sunxi_de2.c
index e8903400ec7e3a327d2f895d49b8b10e50f44e10..4ed035d556a852d49903374a1d19bdf92838a772 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;
 }
 
@@ -319,7 +326,7 @@ U_BOOT_DEVICE(sunxi_de2) = {
 #if defined(CONFIG_OF_BOARD_SETUP) && defined(CONFIG_VIDEO_DT_SIMPLEFB)
 int sunxi_simplefb_setup(void *blob)
 {
-       struct udevice *de2, *hdmi;
+       struct udevice *de2, *hdmi, *lcd;
        struct video_priv *de2_priv;
        struct video_uc_platdata *de2_plat;
        int mux;
@@ -346,13 +353,28 @@ int sunxi_simplefb_setup(void *blob)
                                         "sunxi_dw_hdmi", &hdmi);
        if (ret) {
                debug("HDMI not present\n");
-               return 0;
+       } else if (device_active(hdmi)) {
+               if (mux == 0)
+                       pipeline = "mixer0-lcd0-hdmi";
+               else
+                       pipeline = "mixer1-lcd1-hdmi";
+       } else {
+               debug("HDMI present but not probed\n");
        }
 
-       if (mux == 0)
-               pipeline = "mixer0-lcd0-hdmi";
+       ret = uclass_find_device_by_name(UCLASS_DISPLAY,
+                                        "sunxi_lcd", &lcd);
+       if (ret)
+               debug("LCD not present\n");
+       else if (device_active(lcd))
+               pipeline = "mixer0-lcd0";
        else
-               pipeline = "mixer1-lcd1-hdmi";
+               debug("LCD present but not probed\n");
+
+       if (!pipeline) {
+               debug("No active display present\n");
+               return 0;
+       }
 
        de2_priv = dev_get_uclass_priv(de2);
        de2_plat = dev_get_uclass_platdata(de2);