]> git.baikalelectronics.ru Git - uboot.git/commitdiff
event: Add an event for device tree fixups
authorSimon Glass <sjg@chromium.org>
Sat, 30 Jul 2022 21:52:31 +0000 (15:52 -0600)
committerTom Rini <trini@konsulko.com>
Fri, 12 Aug 2022 12:17:11 +0000 (08:17 -0400)
At present there is a confusing array of functions that handle the
device tree fix-ups needed for booting an OS. We should be able to switch
to using events to clean this up.

As a first step, create a new event type and call it from the standard
place.

Note that this event uses the ofnode interface only, since this can
support live tree which is more efficient when making lots of updates.

Signed-off-by: Simon Glass <sjg@chromium.org>
boot/image-fdt.c
common/event.c
include/event.h
test/py/tests/test_event_dump.py

index 9db2cee99423b9d449f4902e3a2e00086b009089..5e5b24674d376de931fe98045e9c17d1478b7c82 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/libfdt.h>
 #include <mapmem.h>
 #include <asm/io.h>
+#include <dm/ofnode.h>
 #include <tee/optee.h>
 
 #ifndef CONFIG_SYS_FDT_PAD
@@ -668,6 +669,16 @@ int image_setup_libfdt(bootm_headers_t *images, void *blob,
                        goto err;
                }
        }
+       if (CONFIG_IS_ENABLED(EVENT)) {
+               struct event_ft_fixup fixup;
+
+               fixup.tree = oftree_default();
+               ret = event_notify(EVT_FT_FIXUP, &fixup, sizeof(fixup));
+               if (ret) {
+                       printf("ERROR: fdt fixup event failed: %d\n", ret);
+                       goto err;
+               }
+       }
 
        /* Delete the old LMB reservation */
        if (lmb)
index af1ed4121d8a86cb01a4f678f4381b8c6ecc9d70..3e345509783918fe3742074ba2785f87e0809b05 100644 (file)
@@ -35,6 +35,9 @@ const char *const type_name[] = {
 
        /* init hooks */
        "misc_init_f",
+
+       /* fdt hooks */
+       "ft_fixup",
 };
 
 _Static_assert(ARRAY_SIZE(type_name) == EVT_COUNT, "event type_name size");
index fb0734ed4e137dad7cb826240f5e143e5a1516b5..e8f2f55c63da8176f584b91be0e4e30c1d3380f4 100644 (file)
@@ -10,6 +10,8 @@
 #ifndef __event_h
 #define __event_h
 
+#include <dm/ofnode_decl.h>
+
 /**
  * enum event_t - Types of events supported by U-Boot
  *
@@ -29,6 +31,9 @@ enum event_t {
        /* Init hooks */
        EVT_MISC_INIT_F,
 
+       /* Device tree fixups before booting */
+       EVT_FT_FIXUP,
+
        EVT_COUNT
 };
 
@@ -50,6 +55,15 @@ union event_data {
        struct event_dm {
                struct udevice *dev;
        } dm;
+
+       /**
+        * struct event_ft_fixup - FDT fixup before booting
+        *
+        * @tree: tree to update
+        */
+       struct event_ft_fixup {
+               oftree tree;
+       } ft_fixup;
 };
 
 /**
index b753e804ac342140f2cbb4d1436bd28d9959a845..17001777247be8417b00c92076e1a661dd003f41 100644 (file)
@@ -16,5 +16,6 @@ def test_event_dump(u_boot_console):
     out = util.run_and_log(cons, ['scripts/event_dump.py', sandbox])
     expect = '''.*Event type            Id                              Source location
 --------------------  ------------------------------  ------------------------------
+EVT_FT_FIXUP          bootmeth_vbe_simple_ft_fixup    boot/vbe_simple.c:.*
 EVT_MISC_INIT_F       sandbox_misc_init_f             .*arch/sandbox/cpu/start.c:'''
     assert re.match(expect, out, re.MULTILINE) is not None