All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sanchayan Maity <maitysanchayan@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 2/6] video: fsl_dcu_fb: fix framebuffer to the end of memory
Date: Thu, 30 Mar 2017 12:44:02 +0530	[thread overview]
Message-ID: <82a30ac12eac6e55ecf603430dc27ca274e111bd.1490856350.git.maitysanchayan@gmail.com> (raw)
In-Reply-To: <cover.1490856350.git.maitysanchayan@gmail.com>

From: Stefan Agner <stefan.agner@toradex.com>

Fix the framebuffer location to the very end of the available memory.
This allows to remove the area from available memory for the kernel,
which in turn allows to display the splash screen through the while
Linux kernel boot process.

Ideas has been taken from the sunxi display driver, e.g.
20779ec3a5 ("sunxi: video: Dynamically reserve framebuffer memory")

Signed-off-by: Stefan Agner <stefan.agner@toradex.com>
Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com>
---
 drivers/video/Kconfig      |  8 ++++++++
 drivers/video/fsl_dcu_fb.c | 45 ++++++++++++++++++++++++++++++++++++++++++---
 include/fsl_dcu_fb.h       |  1 +
 3 files changed, 51 insertions(+), 3 deletions(-)

diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 6aab8af1b3..d1b017cfad 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -402,6 +402,14 @@ config VIDEO_FSL_DCU_FB
 	 This enables support for Freescale Display Control Unit (DCU4)
 	 module found on Freescale Vybrid and QorIQ family of SoCs.
 
+config VIDEO_FSL_DCU_MAX_FB_SIZE_MB
+	int "Freescale DCU framebuffer size"
+	depends on VIDEO_FSL_DCU_FB
+	default 4194304
+	help
+	 Set maximum framebuffer size to be used for Freescale Display
+	 Controller Unit (DCU4).
+
 config VIDEO_ROCKCHIP
 	bool "Enable Rockchip video support"
 	depends on DM_VIDEO
diff --git a/drivers/video/fsl_dcu_fb.c b/drivers/video/fsl_dcu_fb.c
index d4cd382776..801bf3db95 100644
--- a/drivers/video/fsl_dcu_fb.c
+++ b/drivers/video/fsl_dcu_fb.c
@@ -8,6 +8,7 @@
 
 #include <asm/io.h>
 #include <common.h>
+#include <fdt_support.h>
 #include <fsl_dcu_fb.h>
 #include <linux/fb.h>
 #include <malloc.h>
@@ -79,6 +80,8 @@
 #define BPP_24_RGB888			5
 #define BPP_32_ARGB8888			6
 
+DECLARE_GLOBAL_DATA_PTR;
+
 /*
  * This setting is used for the TWR_LCD_RGB card
  */
@@ -254,11 +257,19 @@ int fsl_dcu_init(unsigned int xres, unsigned int yres,
 	struct dcu_reg *regs = (struct dcu_reg *)CONFIG_SYS_DCU_ADDR;
 	unsigned int div, mode;
 
-	/* Memory allocation for framebuffer */
 	info.screen_size =
 		info.var.xres * info.var.yres * (info.var.bits_per_pixel / 8);
-	info.screen_base = (char *)memalign(ARCH_DMA_MINALIGN,
-			roundup(info.screen_size, ARCH_DMA_MINALIGN));
+
+	if (info.screen_size > CONFIG_VIDEO_FSL_DCU_MAX_FB_SIZE_MB) {
+		info.screen_size = 0;
+		return -ENOMEM;
+	}
+
+	/* Resever framebuffer at the end of memory */
+	gd->fb_base = gd->bd->bi_dram[0].start +
+			gd->bd->bi_dram[0].size - info.screen_size;
+	info.screen_base = (char *)gd->fb_base;
+
 	memset(info.screen_base, 0, info.screen_size);
 
 	reset_total_layers();
@@ -305,6 +316,11 @@ int fsl_dcu_init(unsigned int xres, unsigned int yres,
 	return 0;
 }
 
+ulong board_get_usable_ram_top(ulong total_size)
+{
+	return gd->ram_top - CONFIG_VIDEO_FSL_DCU_MAX_FB_SIZE_MB;
+}
+
 void *video_hw_init(void)
 {
 	static GraphicDevice ctfb;
@@ -363,3 +379,26 @@ void *video_hw_init(void)
 
 	return &ctfb;
 }
+
+#if defined(CONFIG_OF_BOARD_SETUP)
+int fsl_dcu_fixedfb_setup(void *blob)
+{
+	u64 start, size;
+	int ret;
+
+	start = gd->bd->bi_dram[0].start;
+	size = gd->bd->bi_dram[0].size - info.screen_size;
+
+	/*
+	 * Align size on section size (1 MiB).
+	 */
+	size &= 0xfff00000;
+	ret = fdt_fixup_memory_banks(blob, &start, &size, 1);
+	if (ret) {
+		eprintf("Cannot setup fb: Error reserving memory\n");
+		return ret;
+	}
+
+	return 0;
+}
+#endif
diff --git a/include/fsl_dcu_fb.h b/include/fsl_dcu_fb.h
index 42632984d3..67e29e74e6 100644
--- a/include/fsl_dcu_fb.h
+++ b/include/fsl_dcu_fb.h
@@ -9,6 +9,7 @@
 
 int fsl_dcu_init(unsigned int xres, unsigned int yres,
 		 unsigned int pixel_format);
+int fsl_dcu_fixedfb_setup(void *blob);
 
 /* Prototypes for external board-specific functions */
 int platform_dcu_init(unsigned int xres, unsigned int yres,
-- 
2.12.1

  parent reply	other threads:[~2017-03-30  7:14 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-30  7:14 [U-Boot] [PATCH v2 0/6] Introduce DCU support for Vybrid Sanchayan Maity
2017-03-30  7:14 ` [U-Boot] [PATCH v2 1/6] Convert CONFIG_FSL_DCU_FB to Kconfig Sanchayan Maity
2017-03-30  7:14 ` Sanchayan Maity [this message]
2017-03-30  7:14 ` [U-Boot] [PATCH v2 3/6] video: fsl_dcu_fb: Enable pixel clock after initialization Sanchayan Maity
2017-03-30  7:14 ` [U-Boot] [PATCH v2 4/6] video: fsl_dcu_fb: Update DCU layers for Vybrid Sanchayan Maity
2017-03-30 15:34   ` Stefan Agner
2017-03-30  7:14 ` [U-Boot] [PATCH v2 5/6] video: fsl_dcu_fb: add additional modes for DCU Sanchayan Maity
2017-03-30  7:14 ` [U-Boot] [PATCH v2 6/6] board: toradex: colibri_vf: Add DCU support for Colibri Vybrid Sanchayan Maity

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=82a30ac12eac6e55ecf603430dc27ca274e111bd.1490856350.git.maitysanchayan@gmail.com \
    --to=maitysanchayan@gmail.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.