From 24cdb09130c32209485648e106da40f5c2732271 Mon Sep 17 00:00:00 2001
From: Sughosh Ganu <sughosh.ganu@linaro.org>
Date: Thu, 22 May 2025 18:08:38 +0100
Subject: [PATCH 35/36] bootefi: Call the EVT_FT_FIXUP event handler

The bootefi command passes the devicetree to the kernel through the
EFI config table. Call the event handlers for fixing the devicetree
before jumping into the kernel. This removes any devicetree nodes
and/or properties that are specific only to U-Boot, and are not to be
passed to the OS.

Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
Upstream-Status: Denied [RFC: https://lore.kernel.org/u-boot/aca7e6fa-2dec-a7c5-e47e-84c5ffa6f9b7@gmx.de/T/#m16d14ee960427cc88066bdcdd76f0a26738bb66d]
---
 cmd/bootefi.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/cmd/bootefi.c b/cmd/bootefi.c
index c1454ffb948..2599afadf9a 100644
--- a/cmd/bootefi.c
+++ b/cmd/bootefi.c
@@ -118,6 +118,24 @@ static int do_efi_selftest(void)
 	return ret != EFI_SUCCESS;
 }
 
+/**
+ * event_notify_dt_fixup() - call ft_fixup event
+ *
+ * @fdt:	address of the device tree to be passed to the kernel
+ *		through the configuration table
+ * Return:	None
+ */
+static void event_notify_dt_fixup(void *fdt)
+{
+	int ret;
+	struct event_ft_fixup fixup = {0};
+
+	fixup.tree.fdt = fdt;
+	ret = event_notify(EVT_FT_FIXUP, &fixup, sizeof(fixup));
+	if (ret)
+		printf("Error: %d: FDT Fixup event failed\n", ret);
+}
+
 /**
  * do_bootefi() - execute `bootefi` command
  *
@@ -173,6 +191,8 @@ static int do_bootefi(struct cmd_tbl *cmdtp, int flag, int argc,
 		if (ret != EFI_SUCCESS)
 			return CMD_RET_FAILURE;
 
+		event_notify_dt_fixup(fdt);
+
 		return do_efi_selftest();
 	}
 
-- 
2.25.1

