From mboxrd@z Thu Jan 1 00:00:00 1970 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 001F1C433EF for ; Fri, 17 Dec 2021 04:04:23 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6BEDA83762; Fri, 17 Dec 2021 05:02:23 +0100 (CET) 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="fsLmq9D3"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BBB6383076; Fri, 17 Dec 2021 05:00:52 +0100 (CET) Received: from mail-oi1-x231.google.com (mail-oi1-x231.google.com [IPv6:2607:f8b0:4864:20::231]) (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 D8E1D831D7 for ; Fri, 17 Dec 2021 05:00:25 +0100 (CET) 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-oi1-x231.google.com with SMTP id t23so1857231oiw.3 for ; Thu, 16 Dec 2021 20:00:25 -0800 (PST) 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=hafoAIu/tyYbPSAzFqjHcjDW+f+7pGmxG7lBiADgHPg=; b=fsLmq9D3URK1BQX0kK6R4b3+Sf9mLQmQDqPB4l4MRXNKQUdShIO8xJZzhssiFYoljb uAC4DvlcKsWii339XG1fWsXRlPGKGgW9yqSChxFHNVuhpkmdWGhuA8Wf6oMFFcOk2nA5 QPtDHn0Equd4wj6x1WW9muZvCE1HiXtn0xjzw= 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=hafoAIu/tyYbPSAzFqjHcjDW+f+7pGmxG7lBiADgHPg=; b=VlohmdXjk4k1D9fuKWY4cac5nqUpARyEG74cn1RcWMlxY/N0P5PbRc7as/c5KxHZiG fAb/6sZEgA4gdvO/chufKQZ/kG4sKd3Kzt0IlM2BNIJaYV9znR0IuQSZqTzv/fB6hCMS muDikxTP365XeBIAMxZAHBGy+feLa6MpzL3VkBk2y20peJoidfcqVnQ0YjWpiiBrQCBQ UlftCH5OdnU2GuwUET4PKaYpyPT1XE3QHrb0r9on3BEN0VdSa67Iz50/G6AhQ+hH/82f SA3oSvezMbAcGlH6UMORGXXFWlAQ8YNBTscIUg969E4B6HFTo81S33Y4sH73VsPl/QZG ayEg== X-Gm-Message-State: AOAM5306ErMXk9FCwTvULiENcMlSHMGmLJSsTDgzY6vBZ7wNQke+9C+1 emSWsX3Cssdi7PissRuBE+yjGYxcgMv8Vw== X-Google-Smtp-Source: ABdhPJx9McvYa8AX/kP2LvMfffjmLVNQCp9SASR6/YMc9Fq0mEQ55tF1MHS0n7svsFkOClEN4HIFpg== X-Received: by 2002:a54:4789:: with SMTP id o9mr6613580oic.74.1639713624465; Thu, 16 Dec 2021 20:00:24 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id h14sm1431249ots.22.2021.12.16.20.00.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Dec 2021 20:00:24 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Ilias Apalodimas , Sean Anderson , Heinrich Schuchardt , Tom Rini , Mark Kettenis , =?UTF-8?q?Fran=C3=A7ois=20Ozog?= , Simon Glass , Jerry Van Baren Subject: [PATCH v8 24/32] fdt: Don't call board_fdt_blob_setup() without OF_BOARD Date: Thu, 16 Dec 2021 20:59:31 -0700 Message-Id: <20211217035939.670884-25-sjg@chromium.org> X-Mailer: git-send-email 2.34.1.173.g76aa8bc2d0-goog In-Reply-To: <20211217035939.670884-1-sjg@chromium.org> References: <20211217035939.670884-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 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.2 at phobos.denx.de X-Virus-Status: Clean At present this override function is called even when OF_BOARD is not enabled. This makes it impossible to disable this feature and in fact makes the OF_BOARD option useless. Reinstate its intended purpose, so that it is possible to switch between the appended devicetree and one provided by the board's custom function. A follower patch adds warnings for this scenario, but for now we don't have a Kconfig that definitively tells us that OF_BOARD should be used. Signed-off-by: Simon Glass --- Changes in v8: - Mention the follower patch Changes in v7: - Fix 'Is' typo in commit message Changes in v5: - Add new patches to clean up fdtdec_setup() and surrounds include/fdtdec.h | 7 +++++-- lib/fdtdec.c | 21 ++++++++++++--------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/include/fdtdec.h b/include/fdtdec.h index 68786111a44..68a36f10583 100644 --- a/include/fdtdec.h +++ b/include/fdtdec.h @@ -1170,10 +1170,13 @@ int fdtdec_resetup(int *rescan); /** * Board-specific FDT initialization. Returns the address to a device tree blob. - * Called when CONFIG_OF_BOARD is defined, or if CONFIG_OF_SEPARATE is defined - * and the board implements it. + * + * Called when CONFIG_OF_BOARD is defined. + * + * The existing devicetree is available at gd->fdt_blob * * @err internal error code if we fail to setup a DTB + * @returns new devicetree blob pointer */ void *board_fdt_blob_setup(int *err); diff --git a/lib/fdtdec.c b/lib/fdtdec.c index a7f62123a94..31a509bc221 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -1203,15 +1203,15 @@ static int uncompress_blob(const void *src, ulong sz_src, void **dstp) return 0; } -/* - * For CONFIG_OF_SEPARATE, the board may optionally implement this to - * provide and/or fixup the fdt. +/** + * fdt_find_separate() - Find a devicetree at the end of the image + * + * @return pointer to FDT blob */ -__weak void *board_fdt_blob_setup(int *err) +static void *fdt_find_separate(void) { void *fdt_blob = NULL; - *err = 0; #ifdef CONFIG_SPL_BUILD /* FDT is at end of BSS unless it is in a different memory region */ if (IS_ENABLED(CONFIG_SPL_SEPARATE_BSS)) @@ -1626,13 +1626,16 @@ int fdtdec_setup(void) int ret; /* The devicetree is typically appended to U-Boot */ - if (IS_ENABLED(CONFIG_OF_SEPARATE) || IS_ENABLED(CONFIG_OF_BOARD)) { - /* Allow the board to override the fdt address. */ + if (IS_ENABLED(CONFIG_OF_SEPARATE)) + gd->fdt_blob = fdt_find_separate(); + else /* embed dtb in ELF file for testing / development */ + gd->fdt_blob = dtb_dt_embedded(); + + /* Allow the board to override the fdt address. */ + if (IS_ENABLED(CONFIG_OF_BOARD)) { gd->fdt_blob = board_fdt_blob_setup(&ret); if (ret) return ret; - } else { /* embed dtb in ELF file for testing / development */ - gd->fdt_blob = dtb_dt_embedded(); } if (!IS_ENABLED(CONFIG_SPL_BUILD)) { -- 2.34.1.173.g76aa8bc2d0-goog