[v3,24/26] imx8mn_bsh_smm_s2/pro: support simple frame-buffer

Message ID 20261202102716.572884-25-dario.binacchi@amarulasolutions.com
State New
Headers
Series Support display on the BSH SMM S2/PRO boards |

Commit Message

Dario Binacchi Dec. 2, 2026, 10:26 a.m. UTC
If you want to pass the frame-buffer to the kernel, the video output is
initialized by U-Boot, and kept by the kernel. The commit modifies the
device tree to be passed to the kernel just before launching it, to
prevent the kernel from reinitializing hardware that has already been
configured by the bootloader.

Co-developed-by: Michael Trimarchi <michael@amarulasolutions.com>
Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
---

(no changes since v2)

Changes in v2:
- Drop the custom boot-on properties added to the Linux device tree
- Drop the #if guard around smm_s2_setup_simplefb()
- Fix the style of a comment

 board/bsh/imx8mn_smm_s2/imx8mn_smm_s2.c | 72 +++++++++++++++++++++++++
 1 file changed, 72 insertions(+)
  

Patch

diff --git a/board/bsh/imx8mn_smm_s2/imx8mn_smm_s2.c b/board/bsh/imx8mn_smm_s2/imx8mn_smm_s2.c
index c4a85c4aa440..902d5304249a 100644
--- a/board/bsh/imx8mn_smm_s2/imx8mn_smm_s2.c
+++ b/board/bsh/imx8mn_smm_s2/imx8mn_smm_s2.c
@@ -5,6 +5,8 @@ 
 
 #include <asm/arch/sys_proto.h>
 #include <env.h>
+#include <fdt_simplefb.h>
+#include <fdt_support.h>
 
 int board_late_init(void)
 {
@@ -15,3 +17,73 @@  int board_late_init(void)
 
 	return 0;
 }
+
+static void smm_s2_setup_simplefb(void *blob)
+{
+#define DT_BLK_CTRL_NODE_PATH "/soc@0/bus@32c00000/blk-ctrl@32e28000"
+#define DT_GPC_NODE_PATH "/soc@0/bus@30000000/gpc@303a0000"
+#define DT_LCDIF_NODE_PATH "/soc@0/bus@32c00000/lcdif@32e00000"
+
+	struct dt_addprop {
+		const char *node;
+		const char *prop;
+		const u32 *val;
+		int len;
+	} dt_addprops[] = {
+		{"/regulator-3v3-O2", "regulator-boot-on", NULL, 0},
+		{"/regulator-3v3-O3", "regulator-boot-on", NULL, 0},
+	};
+	const char *dt_delprops[][2] = {
+		{DT_BLK_CTRL_NODE_PATH, "assigned-clock-rates"},
+		/* pgc_dispmix */
+		{DT_GPC_NODE_PATH "/pgc/power-domain@3", "assigned-clock-rates"},
+		{DT_LCDIF_NODE_PATH, "assigned-clock-rates"},
+	};
+	int i, ret, offset;
+
+	ret = fdt_simplefb_enable_and_mem_rsv(blob);
+	if (ret) {
+		printf("Failed to enable framebuffer DTS node\n");
+		return;
+	}
+
+	for (i = 0; i < ARRAY_SIZE(dt_addprops); i++) {
+		const char *node = dt_addprops[i].node;
+		const char *prop = dt_addprops[i].prop;
+		const void *val = dt_addprops[i].val;
+		const int len = dt_addprops[i].len;
+
+		ret = fdt_find_and_setprop(blob, node, prop, val, len, 1);
+		if (ret < 0)
+			printf("Failed to add property %s:%s, err=%s\n", node, prop,
+			       fdt_strerror(ret));
+		else
+			debug("Add property %s:%s\n", node, prop);
+	}
+
+	for (i = 0; i < ARRAY_SIZE(dt_delprops); i++) {
+		const char *node = dt_delprops[i][0];
+		const char *prop = dt_delprops[i][1];
+
+		offset = fdt_path_offset(blob, node);
+		if (offset < 0) {
+			printf("Missing node %s\n", node);
+			continue;
+		}
+
+		ret = fdt_delprop(blob, offset, prop);
+		if (ret < 0)
+			printf("Failed to delete property %s:%s\n", node, prop);
+		else
+			debug("Delete property %s:%s\n", node, prop);
+	}
+}
+
+int ft_board_setup(void *blob, struct bd_info *bd)
+{
+	if (IS_ENABLED(CONFIG_OF_LIBFDT) && IS_ENABLED(CONFIG_FDT_SIMPLEFB) &&
+	    IS_ENABLED(CONFIG_VIDEO))
+		smm_s2_setup_simplefb(blob);
+
+	return 0;
+}