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 03CF5ECAAA1 for ; Wed, 31 Aug 2022 03:11:23 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0551884A3E; Wed, 31 Aug 2022 05:10:10 +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="lm8n9qUd"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7C969849B5; Wed, 31 Aug 2022 05:09:44 +0200 (CEST) Received: from mail-oa1-x2b.google.com (mail-oa1-x2b.google.com [IPv6:2001:4860:4864:20::2b]) (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 D0713849B9 for ; Wed, 31 Aug 2022 05:09:39 +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-oa1-x2b.google.com with SMTP id 586e51a60fabf-11e7e0a63e2so20500463fac.4 for ; Tue, 30 Aug 2022 20:09:39 -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:subject:date; bh=ir6Q0NbfJiJGUjUUA8b9vBdHkn+h7YSwQYJunCWj/5I=; b=lm8n9qUdDzWxSEaA7nsJucz6Vsh6CpvimKxIIlUpGi4iCyZ0bybcCSfBkKMJNqzwNo JKpoUyZRIJgzkHamm07fXWYvjNdcIj0QOXxTqR6jOHTJdKFXLONKXhcs8tgEOpiFyZUH nkB/n0Obeyh4QdEB/32rrPQVtHxS1Q92cue7c= 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 :subject:date; bh=ir6Q0NbfJiJGUjUUA8b9vBdHkn+h7YSwQYJunCWj/5I=; b=lOGApd2/tdHbErD89wY4gw4xwOylWSi+IPIylFzq4V6Xu+Y98xDDkaNywOb0bU6wnc lcFi8w5+n+bgsQ7sIfZJBB38KLxWrvssuLBLhM7K83gUXR7jWX8THuF2M76f/t/FNMS1 oHum6HoGLmB6ry6F9R36L++HmKrmpyzNvg4DDEan72XzCyU0/iL1iDQhyjhlnX2Yqxi0 A+Pwr9aqwk58tunLP8Dni+qUPszQyW5Fy3x1/1f5Aogiomu77WOYtT8wNKe8fKrzI2lv mqdKdgwIdTBR0byeRhUqtQ5Zj/MYmqscnlIh83RxlqyjbjWw96BqlC6Cu0HlKZJtKkAS mFUw== X-Gm-Message-State: ACgBeo0oYQvPt9hbpdcxEzAD3yS0HnWsrjLiUCM9dudi+x0Idk9obNWJ NAC0yGW07ulp2uJw3nNJePCq8Ev53EzEoA== X-Google-Smtp-Source: AA6agR52ejxwMCloMj+/5GbM02MGrnFPZjgepPGkrst0mI8M229VIBdMbgWmoiZGxpLzQeTrUwGCYg== X-Received: by 2002:a05:6808:f8e:b0:342:ff09:2c2d with SMTP id o14-20020a0568080f8e00b00342ff092c2dmr440910oiw.200.1661915353416; Tue, 30 Aug 2022 20:09:13 -0700 (PDT) Received: from sjg1.roam.corp.google.com (c-67-190-102-125.hsd1.co.comcast.net. [67.190.102.125]) by smtp.gmail.com with ESMTPSA id fp39-20020a05687065a700b00116d5103487sm9282605oab.31.2022.08.30.20.09.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 20:09:13 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Michal Simek , =?UTF-8?q?Marek=20Beh=C3=BAn?= , Kishon Vijay Abraham I , Tom Rini , Simon Glass , Dzmitry Sankouski , Heinrich Schuchardt , Marek Vasut , Ovidiu Panait , Pavel Herrmann , Rasmus Villemoes , Rick Chen Subject: [PATCH 14/21] dm: core: Provide a way to reset the device tree Date: Tue, 30 Aug 2022 21:08:10 -0600 Message-Id: <20220831030817.27804-15-sjg@chromium.org> X-Mailer: git-send-email 2.37.2.672.g94769d06f0-goog In-Reply-To: <20220831030817.27804-1-sjg@chromium.org> References: <20220831030817.27804-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 only one device tree used by the ofnode functions, except for some esoteric use of live tree. In preparation for supporting more than one, add a way to reset the list of device trees. For now this does nothing. Signed-off-by: Simon Glass --- common/board_r.c | 2 ++ include/dm/ofnode.h | 8 ++++++++ lib/fdtdec.c | 5 ++++- test/test-main.c | 2 ++ 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/common/board_r.c b/common/board_r.c index 56eb60fa275..77e9ca0581f 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -233,6 +233,8 @@ static int initr_dm(void) { int ret; + oftree_reset(); + /* Save the pre-reloc driver model and start a new one */ gd->dm_root_f = gd->dm_root; gd->dm_root = NULL; diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h index 3b7ef793057..2b047c57d89 100644 --- a/include/dm/ofnode.h +++ b/include/dm/ofnode.h @@ -27,6 +27,14 @@ struct ofnode_phandle_args { uint32_t args[OF_MAX_PHANDLE_ARGS]; }; +/** + * oftree_reset() - reset the state of the oftree list + * + * Reset the oftree list so it can be started again. This should be called + * once the control FDT is in place, but before the ofnode interface is used. + */ +static inline void oftree_reset(void) {} + /** * ofnode_to_np() - convert an ofnode to a live DT node pointer * diff --git a/lib/fdtdec.c b/lib/fdtdec.c index 96b6b71a606..ffe3993aa76 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -13,7 +13,6 @@ #include #include #include -#include #include #include #include @@ -24,6 +23,8 @@ #include #include #include +#include +#include #include #include #include @@ -1668,6 +1669,8 @@ int fdtdec_setup(void) ret = fdtdec_prepare_fdt(); if (!ret) ret = fdtdec_board_setup(gd->fdt_blob); + oftree_reset(); + return ret; } diff --git a/test/test-main.c b/test/test-main.c index 97ba25d927c..beca15041e0 100644 --- a/test/test-main.c +++ b/test/test-main.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -95,6 +96,7 @@ static int dm_test_pre_run(struct unit_test_state *uts) /* Determine whether to make the live tree available */ gd_set_of_root(of_live ? uts->of_root : NULL); + oftree_reset(); ut_assertok(dm_init(of_live)); uts->root = dm_root(); -- 2.37.2.672.g94769d06f0-goog