diff mbox series

[2/5] fdtdec: Add weak function to patch U-Boot DT right after fdtdec_setup()

Message ID 20200411200119.309400-2-marek.vasut+renesas@gmail.com
State New
Headers show
Series [1/5] libfdt: Export overlay_apply_node() as fdt_overlay_apply_node() | expand

Commit Message

Marek Vasut April 11, 2020, 8:01 p.m. UTC
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 at gmail.com>
Cc: Nobuhiro Iwamatsu <iwamatsu at nigauri.org>
Cc: Simon Glass <sjg at chromium.org>
Cc: Tom Rini <trini at konsulko.com>
---
 lib/fdtdec.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

Comments

Simon Glass April 19, 2020, 11:37 p.m. UTC | #1
Hi Marek,

On Sat, 11 Apr 2020 at 14:01, Marek Vasut <marek.vasut at gmail.com> wrote:
>
> 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 at gmail.com>
> Cc: Nobuhiro Iwamatsu <iwamatsu at nigauri.org>
> Cc: Simon Glass <sjg at chromium.org>
> Cc: Tom Rini <trini at konsulko.com>
> ---
>  lib/fdtdec.c | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/lib/fdtdec.c b/lib/fdtdec.c
> index eb11fc898e..3fc28e86bc 100644
> --- a/lib/fdtdec.c
> +++ b/lib/fdtdec.c
> @@ -1466,8 +1466,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)

Please declare this in fdtdec.h. Also, do you want it to be const?

Also update README.fdt-control

> +{
> +       return 0;
> +}
> +
>  int fdtdec_setup(void)
>  {
> +       int ret;
>  #if CONFIG_IS_ENABLED(OF_CONTROL)
>  # if CONFIG_IS_ENABLED(MULTI_DTB_FIT)
>         void *fdt_blob;
> @@ -1520,7 +1526,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)
> --
> 2.25.1
>

Regards,
Simon
diff mbox series

Patch

diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index eb11fc898e..3fc28e86bc 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -1466,8 +1466,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;
@@ -1520,7 +1526,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)