Просмотр исходного кода

fdtdec: Add weak function to patch U-Boot DT right after fdtdec_setup()

Add weak function which is called right after fdtdec_setup() configured
the U-Boot DT. This permits board-specific adjustments to the U-Boot DT
before U-Boot starts parsing the DT. This could be used e.g. to patch in
various custom nodes or merge in DT fragments from prior-stage firmware.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
Cc: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>
Marek Vasut 4 лет назад
Родитель
Сommit
0e2afc8368
2 измененных файлов с 15 добавлено и 1 удалено
  1. 5 0
      include/fdtdec.h
  2. 10 1
      lib/fdtdec.c

+ 5 - 0
include/fdtdec.h

@@ -1155,6 +1155,11 @@ int fdtdec_set_carveout(void *blob, const char *node, const char *prop_name,
  */
 int fdtdec_setup(void);
 
+/**
+ * Perform board-specific early DT adjustments
+ */
+int fdtdec_board_setup(const void *fdt_blob);
+
 #if CONFIG_IS_ENABLED(MULTI_DTB_FIT)
 /**
  * fdtdec_resetup()  - Set up the device tree again

+ 10 - 1
lib/fdtdec.c

@@ -1474,8 +1474,14 @@ int fdtdec_set_carveout(void *blob, const char *node, const char *prop_name,
 	return 0;
 }
 
+__weak int fdtdec_board_setup(const void *fdt_blob)
+{
+	return 0;
+}
+
 int fdtdec_setup(void)
 {
+	int ret;
 #if CONFIG_IS_ENABLED(OF_CONTROL)
 # if CONFIG_IS_ENABLED(MULTI_DTB_FIT)
 	void *fdt_blob;
@@ -1528,7 +1534,10 @@ int fdtdec_setup(void)
 # endif
 #endif
 
-	return fdtdec_prepare_fdt();
+	ret = fdtdec_prepare_fdt();
+	if (!ret)
+		ret = fdtdec_board_setup(gd->fdt_blob);
+	return ret;
 }
 
 #if CONFIG_IS_ENABLED(MULTI_DTB_FIT)