]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
common: add fdt_simplefb_enable_and_mem_rsv function
authorPatrick Delaunay <patrick.delaunay@foss.st.com>
Mon, 15 Nov 2021 15:32:21 +0000 (16:32 +0100)
committerPatrice Chotard <patrice.chotard@foss.st.com>
Tue, 30 Nov 2021 15:43:28 +0000 (16:43 +0100)
Add a new function to activate an existing simple frame buffer node
and add the associated reserved memory, with no-map properties.

This device tree update is only done when the video device is active
and the video buffer is used.

This patch uses '#if CONFIG_IS_ENABLED(DM_VIDEO)' because
gd->video_bottom and gd->video_top are only defined when CONFIG_DM_VIDEO
is activated.

Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
common/fdt_simplefb.c
include/fdt_simplefb.h

index 32173030ab74602bb5739fa121fb6c32251871b4..c52846f4bc59476ccc19bce8975e1ddadbfebedb 100644 (file)
@@ -89,3 +89,30 @@ int fdt_simplefb_enable_existing_node(void *blob)
 
        return fdt_simplefb_configure_node(blob, off);
 }
+
+#if CONFIG_IS_ENABLED(DM_VIDEO)
+int fdt_simplefb_enable_and_mem_rsv(void *blob)
+{
+       struct fdt_memory mem;
+       int ret;
+
+       /* nothing to do when video is not active */
+       if (!video_is_active())
+               return 0;
+
+       ret = fdt_simplefb_enable_existing_node(blob);
+       if (ret)
+               return ret;
+
+       /* nothing to do when the frame buffer is not defined */
+       if (gd->video_bottom == gd->video_top)
+               return 0;
+
+       /* reserved with no-map tag the video buffer */
+       mem.start = gd->video_bottom;
+       mem.end = gd->video_top - 1;
+
+       return fdtdec_add_reserved_memory(blob, "framebuffer", &mem, NULL, 0, NULL,
+                                         FDTDEC_RESERVED_MEMORY_NO_MAP);
+}
+#endif
index 7e5472359127408df34c55232cf48eeb3388a6c6..41cd740ac05731bea67185dbb1f0f2fc4860170b 100644 (file)
@@ -10,4 +10,5 @@
 #define _FDT_SIMPLEFB_H_
 int fdt_simplefb_add_node(void *blob);
 int fdt_simplefb_enable_existing_node(void *blob);
+int fdt_simplefb_enable_and_mem_rsv(void *blob);
 #endif