public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 6/6] p2371-2180: Add support for framebuffer carveouts
Date: Fri,  8 Mar 2019 21:11:40 +0100	[thread overview]
Message-ID: <20190308201140.2383-6-thierry.reding@gmail.com> (raw)
In-Reply-To: <20190308201140.2383-1-thierry.reding@gmail.com>

From: Thierry Reding <treding@nvidia.com>

If early firmware initialized the display hardware and the display
controllers are scanning out a framebuffer (e.g. a splash screen), make
sure to pass information about the memory location of that framebuffer
to the kernel before booting to avoid the kernel from using that memory
for the buddy allocator.

This same mechanism can also be used in the kernel to set up early SMMU
mappings and avoid SMMU faults caused by the display controller reading
from memory for which it has no mapping.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 board/nvidia/p2371-2180/p2371-2180.c | 50 ++++++++++++++++++++++++++++
 configs/p2371-2180_defconfig         |  1 +
 2 files changed, 51 insertions(+)

diff --git a/board/nvidia/p2371-2180/p2371-2180.c b/board/nvidia/p2371-2180/p2371-2180.c
index 212037da5ac0..d81deb0cd320 100644
--- a/board/nvidia/p2371-2180/p2371-2180.c
+++ b/board/nvidia/p2371-2180/p2371-2180.c
@@ -6,8 +6,11 @@
 
 #include <common.h>
 #include <i2c.h>
+#include <linux/libfdt.h>
+#include <fdtdec.h>
 #include <asm/arch/gpio.h>
 #include <asm/arch/pinmux.h>
+#include <asm/arch-tegra/cboot.h>
 #include "../p2571/max77620_init.h"
 #include "pinmux-config-p2371-2180.h"
 
@@ -94,3 +97,50 @@ int tegra_pcie_board_init(void)
 	return 0;
 }
 #endif /* PCI */
+
+static int ft_copy_carveout(void *dst, const void *src, const char *node)
+{
+	struct fdt_memory fb;
+	int err;
+
+	err = fdtdec_get_carveout(src, node, "memory-region", 0, &fb);
+	if (err < 0) {
+		if (err != -FDT_ERR_NOTFOUND)
+			printf("failed to get carveout for %s: %d\n", node,
+			       err);
+
+		return err;
+	}
+
+	err = fdtdec_set_carveout(dst, node, "memory-region", 0, "framebuffer",
+				  &fb);
+	if (err < 0) {
+		printf("failed to set carveout for %s: %d\n", node, err);
+		return err;
+	}
+
+	return 0;
+}
+
+int ft_board_setup(void *fdt, bd_t *bd)
+{
+	const void *cboot_fdt = (const void *)cboot_boot_x0;
+	static const char * const nodes[] = {
+		"/host1x at 50000000/dc at 54200000",
+		"/host1x at 50000000/dc@54240000",
+	};
+	unsigned int i;
+	int err;
+
+	for (i = 0; i < ARRAY_SIZE(nodes); i++) {
+		err = ft_copy_carveout(fdt, cboot_fdt, nodes[i]);
+		if (err < 0) {
+			if (err != -FDT_ERR_NOTFOUND)
+				printf("failed to copy carveout for %s: %d\n",
+				       nodes[i], err);
+			continue;
+		}
+	}
+
+	return 0;
+}
diff --git a/configs/p2371-2180_defconfig b/configs/p2371-2180_defconfig
index b662ef143141..b66459e379ac 100644
--- a/configs/p2371-2180_defconfig
+++ b/configs/p2371-2180_defconfig
@@ -5,6 +5,7 @@ CONFIG_TEGRA210=y
 CONFIG_TARGET_P2371_2180=y
 CONFIG_NR_DRAM_BANKS=2
 CONFIG_OF_SYSTEM_SETUP=y
+CONFIG_OF_BOARD_SETUP=y
 CONFIG_CONSOLE_MUX=y
 CONFIG_SYS_STDIO_DEREGISTER=y
 CONFIG_SYS_PROMPT="Tegra210 (P2371-2180) # "
-- 
2.20.1

  parent reply	other threads:[~2019-03-08 20:11 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-08 20:11 [U-Boot] [PATCH 1/6] fdtdec: Add cpu_to_fdt_{addr,size}() macros Thierry Reding
2019-03-08 20:11 ` [U-Boot] [PATCH 2/6] fdtdec: Implement fdtdec_get_max_phandle() Thierry Reding
2019-03-10 21:51   ` Simon Glass
2019-03-11  9:27     ` Thierry Reding
2019-03-19  1:24       ` Simon Glass
2019-03-08 20:11 ` [U-Boot] [PATCH 3/6] fdtdec: Implement fdtdec_set_phandle() Thierry Reding
2019-03-10 21:51   ` Simon Glass
2019-03-11 10:04     ` Thierry Reding
2019-03-19  1:24       ` Simon Glass
2019-03-08 20:11 ` [U-Boot] [PATCH 4/6] fdtdec: Implement fdtdec_add_reserved_memory() Thierry Reding
2019-03-10 21:51   ` Simon Glass
2019-03-11 10:06     ` Thierry Reding
2019-03-19  1:24       ` Simon Glass
2019-03-08 20:11 ` [U-Boot] [PATCH 5/6] fdtdec: Implement carveout support functions Thierry Reding
2019-03-10 21:51   ` Simon Glass
2019-03-08 20:11 ` Thierry Reding [this message]
2019-03-19  1:24   ` [U-Boot] [PATCH 6/6] p2371-2180: Add support for framebuffer carveouts Simon Glass
2019-03-10 21:51 ` [U-Boot] [PATCH 1/6] fdtdec: Add cpu_to_fdt_{addr, size}() macros Simon Glass

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=20190308201140.2383-6-thierry.reding@gmail.com \
    --to=thierry.reding@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox