Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C80C3C43334 for ; Wed, 20 Jul 2022 17:02:43 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 681EC84119; Wed, 20 Jul 2022 19:00:56 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="H7lIpr0H"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0989C840BB; Wed, 20 Jul 2022 19:00:37 +0200 (CEST) Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 95514840D1 for ; Wed, 20 Jul 2022 19:00:30 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-wr1-x42d.google.com with SMTP id a5so26965668wrx.12 for ; Wed, 20 Jul 2022 10:00:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hNHAzs0R/HQK/Y66Yx/RGpsmFOxxyt30z97B6Qam/tg=; b=H7lIpr0HTQVh0IB5R+2lyb1UtgvYvWZoA5m1z2CCwM4voCxFUaso3B0OcSkZvdwH0Q 2xcj6Kop+mDz6kV5Cf7Y5id/od6+FdisqJtmpt3tlH/HrhzbjKyVIMas/TNlRskIeJq2 Yi1X9gLNBj+FqAcPqLqoH1VVxHv6fV2Ig6ErQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hNHAzs0R/HQK/Y66Yx/RGpsmFOxxyt30z97B6Qam/tg=; b=11fFKXRJIMIXeuGjuhmUPnDSJ5Nw4oXXHDrPJ/hTH5v87phaZeYeDqh7v+EWZpRilI dBTYSdTxOrNTVFtBLJegHi1qWxa9UVTybtIZzAoPbW/T6ae/P10NVHtpjL9/HWp4EUjf X0XVMYmX/d5AE2FP+gIp3pN9ZiOKQFtPRj9QnhVQz+Q2zTlwgzTvAirrdzofwBLuugJm jl7/yBvrTesPHc0YJly/YAkxyYWm67DCSQty2U41qro3FSuX9yJSecZveSnq/GyKMeXn gieSwMMeec4ynTlQr11/U4GLu3GxGNg8BBPJAqy5YvQivhHvg1wKQQHk48mwXd0PXrk5 eK+w== X-Gm-Message-State: AJIora83uNiiDkycxsPmHrTnAgriqM0vEdR6ZsUW4XfpjFaPKL7/EUY7 mkGgGlAdooCmzVFbrH1pOxJhLyjJMavcUCzx X-Google-Smtp-Source: AGRyM1srEPJ7vz1BxZ/smqA0/CPcrNOU5e9v0dELFHunEKn0VVz+yCoGCW1ZSE/Nng6tYQHCSoc4eQ== X-Received: by 2002:a05:6000:18d2:b0:21d:6661:60b5 with SMTP id w18-20020a05600018d200b0021d666160b5mr31452705wrq.475.1658336427343; Wed, 20 Jul 2022 10:00:27 -0700 (PDT) Received: from sjg1.roam.corp.google.com ([62.48.169.138]) by smtp.gmail.com with ESMTPSA id u16-20020a05600c00d000b003a31c4f6f74sm3690906wmm.32.2022.07.20.10.00.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Jul 2022 10:00:26 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Alexandru Gagniuc , Artem Lapkin , Daniel Golle , Heinrich Schuchardt , Marek Vasut Subject: [PATCH 12/19] event: Add an event for device tree fixups Date: Wed, 20 Jul 2022 10:59:40 -0600 Message-Id: <20220720165947.12728-11-sjg@chromium.org> X-Mailer: git-send-email 2.37.0.170.g444d1eabd0-goog In-Reply-To: <20220720165947.12728-1-sjg@chromium.org> References: <20220720165947.12728-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean 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 --- boot/image-fdt.c | 11 +++++++++++ common/event.c | 3 +++ include/event.h | 14 ++++++++++++++ test/py/tests/test_event_dump.py | 1 + 4 files changed, 29 insertions(+) diff --git a/boot/image-fdt.c b/boot/image-fdt.c index 9db2cee9942..5e5b24674d3 100644 --- a/boot/image-fdt.c +++ b/boot/image-fdt.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #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) diff --git a/common/event.c b/common/event.c index af1ed4121d8..3e345509783 100644 --- a/common/event.c +++ b/common/event.c @@ -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"); diff --git a/include/event.h b/include/event.h index c00c4fb68dc..05802019820 100644 --- a/include/event.h +++ b/include/event.h @@ -10,6 +10,8 @@ #ifndef __event_h #define __event_h +#include + /** * 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; }; /** diff --git a/test/py/tests/test_event_dump.py b/test/py/tests/test_event_dump.py index b753e804ac3..17001777247 100644 --- a/test/py/tests/test_event_dump.py +++ b/test/py/tests/test_event_dump.py @@ -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 -- 2.37.0.170.g444d1eabd0-goog