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 16AAFC19F28 for ; Sat, 30 Jul 2022 21:58:26 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D60F384596; Sat, 30 Jul 2022 23:54:24 +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="dqUoDrwm"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 15615844AC; Sat, 30 Jul 2022 23:53:52 +0200 (CEST) Received: from mail-ot1-x336.google.com (mail-ot1-x336.google.com [IPv6:2607:f8b0:4864:20::336]) (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 5AEA38421C for ; Sat, 30 Jul 2022 23:53:49 +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-ot1-x336.google.com with SMTP id y10-20020a9d634a000000b006167f7ce0c5so5683476otk.0 for ; Sat, 30 Jul 2022 14:53:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=Xg/nbmHg3y6cQL5QwJ74ILsc3EcwUZz/jdarT2ysfOU=; b=dqUoDrwmFW1WGfJMjQDGjEpqZ8x8PNysW4Ok009cLwPfj2vysZ/+Ed8RMOiM8i9M/d AmTtsSRDAqKaPDyhoSS+37ohr7JNxekPnA0y2jnvGJuUCZ4lUVKrKClbpGMOiOoa8lw7 csHSQa8RPSzl6RfQuT0yXtZJ6++8OVNybq4cQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=Xg/nbmHg3y6cQL5QwJ74ILsc3EcwUZz/jdarT2ysfOU=; b=pv5nERMXe653VrwHAQjcHCmHf0pkBCq66ppaQRNwhqZm92ZLkYQ8kMM9YDvldiIEwN bkpEBIZPo0UndGVhFsu+USlkYJ3y+u6AfbAyslzlZOXcnc5qU3EPYSa5QjBtHWnA7clu L1YRPMFn/LqcDs52fdH8dLBvwg9qHe/zUKhSzrs+ByJ8SOHEuV2F0oq3aU/nR00yybYL ICtEPPm15AF12Mk05SIjNCwfVHnflEe0d7YEj96PFKKdtLf/VsvnZBdBSbX4zTHbRYXW hKB1B2J0/beGi9fYKGgQ6SLvMCN/8UiyBPGt0rYI1Hf4mwykSbDvMdR3RoX0FqbO22bi ySBA== X-Gm-Message-State: AJIora8tkbtm0ASMZL7Co+3m4/jurE6PS+gyAmsak5yEKuT6NNGp3QX0 xD3VCFiPrM9MAm8fYusK8gcgLBFU1NTWsUZg X-Google-Smtp-Source: AGRyM1sz+02H5a5UsbHIVlx1yZ3j93rE49wMY3IZCKN58srB0ErBTUhe5iPovjsqLfogpGl/NFLOUg== X-Received: by 2002:a05:6830:2707:b0:61c:c565:d72f with SMTP id j7-20020a056830270700b0061cc565d72fmr3703439otu.101.1659218016866; Sat, 30 Jul 2022 14:53:36 -0700 (PDT) Received: from sjg1.lan (c-67-190-102-125.hsd1.co.comcast.net. [67.190.102.125]) by smtp.gmail.com with ESMTPSA id 19-20020a544193000000b0032f75714af1sm1699656oiy.18.2022.07.30.14.53.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 Jul 2022 14:53:36 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Bin Meng , Simon Glass Subject: [PATCH v2 29/35] event: Add an event for device tree fixups Date: Sat, 30 Jul 2022 15:52:31 -0600 Message-Id: <20220730215237.818368-25-sjg@chromium.org> X-Mailer: git-send-email 2.37.1.455.g008518b4e5-goog In-Reply-To: <20220730215237.818368-1-sjg@chromium.org> References: <20220730215237.818368-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 --- (no changes since v1) 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 fb0734ed4e1..e8f2f55c63d 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.1.455.g008518b4e5-goog