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 08A0DCE7A8A for ; Sun, 24 Sep 2023 19:31:33 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id ADC4686C02; Sun, 24 Sep 2023 21:26:35 +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="IT++SA8z"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id F3E6186A38; Sun, 24 Sep 2023 21:26:33 +0200 (CEST) Received: from mail-io1-xd2e.google.com (mail-io1-xd2e.google.com [IPv6:2607:f8b0:4864:20::d2e]) (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 C751886B03 for ; Sun, 24 Sep 2023 21:26:21 +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-io1-xd2e.google.com with SMTP id ca18e2360f4ac-79f96f83270so152810339f.1 for ; Sun, 24 Sep 2023 12:26:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1695583580; x=1696188380; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0eUcn/tAzmGUVh1I7fUUnK57XO2tsoI+4ihyvBUVcgE=; b=IT++SA8zSZoVWZR8YlXSQH3HPih8bkuF3dIRak1E0zSAeH/D0q7M2a3KDx3GFo9Fyt wTVbZL6ipnl7Ih1krovhG0fAz7XCESX9IEVlkS5LgW99rI8y8ZgtFyeq2cbO3kRjFZZS FQwR5MfAFWKbsM2ENHiW/otOK3Z3V7Rtzs+V0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695583580; x=1696188380; 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:message-id:reply-to; bh=0eUcn/tAzmGUVh1I7fUUnK57XO2tsoI+4ihyvBUVcgE=; b=rEqvjWZyd/msSAQiWfk1PBvC+69I2aHe2YEOf3nCtLeEe+ilUIgvQ13otXLD2F3h3b sCeVLj2gYpPrnzeoOmFsIgWim+c9VJYccjbOyUv++wj6YoNZv5ay8coZfgHSUvjyjtU5 kIt/Hj0dOWb4Q7hHrww4VhZQY58BxUwQfKloaAPa/kWxno2jVBZ2x6i5IfY5RnPfFKOV oDBQ+z+1O7b0IcM6YZcEVX2zzy5q0BAOq1bIaM89ulCVBT9vm+0MfSvUeOje4FcSp+gZ OaOZ/7Ah+xk4X2ld+knt7zBiBcbPMlt/8pMrWeJtwwVEIa3wzywgFrQEwObeLKz4kHJE LUoA== X-Gm-Message-State: AOJu0Ywk+YRJIxZQv667Eph1lLxPljrj6/e9seWY/GswExVoK7sVrAIp qC8Nb1nElR4GyW8FQe8xIU0dwfLaTC0J7v2g6zo= X-Google-Smtp-Source: AGHT+IFWKGoXZByL4ODWqQC+M89zpQxDprhr0kG8eK+0XTsi+5c/2gBJiV0+k0+lC4QVgxG/1DUk3g== X-Received: by 2002:a6b:5b13:0:b0:77a:e86a:c24b with SMTP id v19-20020a6b5b13000000b0077ae86ac24bmr6342714ioh.6.1695583580446; Sun, 24 Sep 2023 12:26:20 -0700 (PDT) Received: from sjg1.roam.corp.google.com (c-73-14-173-85.hsd1.co.comcast.net. [73.14.173.85]) by smtp.gmail.com with ESMTPSA id do25-20020a0566384c9900b0043a11ec6517sm2321702jab.171.2023.09.24.12.26.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Sep 2023 12:26:20 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Marek Vasut , Simon Glass , Baruch Siach , Bin Meng , Heinrich Schuchardt , Jerry Van Baren , Michal Simek , Neil Armstrong , Nikhil M Jain , Qu Wenruo , Stefan Roese Subject: [PATCH v3 36/38] fdt: Allow the devicetree to come from a bloblist Date: Sun, 24 Sep 2023 13:25:21 -0600 Message-ID: <20230924192536.1812799-37-sjg@chromium.org> X-Mailer: git-send-email 2.42.0.515.g380fc7ccd1-goog In-Reply-To: <20230924192536.1812799-1-sjg@chromium.org> References: <20230924192536.1812799-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.8 at phobos.denx.de X-Virus-Status: Clean Standard passage provides for a bloblist to be passed from one firmware phase to the next. That can be used to pass the devicetree along as well. Add an option to support this. Tests for this will be added as part of the Universal Payload work. Signed-off-by: Simon Glass --- (no changes since v2) Changes in v2: - No changes as it still seems unclear what should be done common/bloblist.c | 2 ++ doc/develop/devicetree/control.rst | 3 ++ dts/Kconfig | 8 ++++++ include/bloblist.h | 5 ++++ include/fdtdec.h | 3 +- lib/fdtdec.c | 44 ++++++++++++++++++++++-------- 6 files changed, 52 insertions(+), 13 deletions(-) diff --git a/common/bloblist.c b/common/bloblist.c index 6f2a4577708d..b07ede11cfe2 100644 --- a/common/bloblist.c +++ b/common/bloblist.c @@ -48,9 +48,11 @@ static struct tag_name { { BLOBLISTT_ACPI_TABLES, "ACPI tables for x86" }, { BLOBLISTT_SMBIOS_TABLES, "SMBIOS tables for x86" }, { BLOBLISTT_VBOOT_CTX, "Chrome OS vboot context" }, + { BLOBLISTT_CONTROL_FDT, "Control FDT" }, /* BLOBLISTT_PROJECT_AREA */ { BLOBLISTT_U_BOOT_SPL_HANDOFF, "SPL hand-off" }, + { BLOBLISTT_VBE, "VBE" }, { BLOBLISTT_U_BOOT_VIDEO, "SPL video handoff" }, /* BLOBLISTT_VENDOR_AREA */ diff --git a/doc/develop/devicetree/control.rst b/doc/develop/devicetree/control.rst index cbb65c9b177f..56e00090166f 100644 --- a/doc/develop/devicetree/control.rst +++ b/doc/develop/devicetree/control.rst @@ -108,6 +108,9 @@ If CONFIG_OF_BOARD is defined, a board-specific routine will provide the devicetree at runtime, for example if an earlier bootloader stage creates it and passes it to U-Boot. +If CONFIG_OF_BLOBLIST is defined, the devicetree comes from a bloblist passed +from a previous stage. + If CONFIG_SANDBOX is defined, then it will be read from a file on startup. Use the -d flag to U-Boot to specify the file to read, -D for the default and -T for the test devicetree, used to run sandbox unit tests. diff --git a/dts/Kconfig b/dts/Kconfig index 9152f5885e9a..6c1edbddb57b 100644 --- a/dts/Kconfig +++ b/dts/Kconfig @@ -105,6 +105,14 @@ config OF_EMBED endchoice +config OF_BLOBLIST + bool "DTB is provided by a bloblist" + help + Select this to read the devicetree from the bloblist. This allows + using a bloblist to transfer the devicetree between U-Boot phases. + The devicetree is stored in the bloblist by an early phase so that + U-Boot can read it. + config OF_BOARD bool "Provided by the board (e.g a previous loader) at runtime" default y if SANDBOX || OF_HAS_PRIOR_STAGE diff --git a/include/bloblist.h b/include/bloblist.h index 080cc46a1266..e16d122f4fb1 100644 --- a/include/bloblist.h +++ b/include/bloblist.h @@ -103,6 +103,11 @@ enum bloblist_tag_t { BLOBLISTT_ACPI_TABLES = 0x104, /* ACPI tables for x86 */ BLOBLISTT_SMBIOS_TABLES = 0x105, /* SMBIOS tables for x86 */ BLOBLISTT_VBOOT_CTX = 0x106, /* Chromium OS verified boot context */ + /* + * Devicetree for use by firmware. On some platforms this is passed to + * the OS also + */ + BLOBLISTT_CONTROL_FDT = 0x107, /* * Project-specific tags are permitted here. Projects can be open source diff --git a/include/fdtdec.h b/include/fdtdec.h index bd1149f46d08..1888c4645619 100644 --- a/include/fdtdec.h +++ b/include/fdtdec.h @@ -72,7 +72,7 @@ struct bd_info; * U-Boot is packaged as an ELF file, e.g. for debugging purposes * @FDTSRC_ENV: Provided by the fdtcontroladdr environment variable. This should * be used for debugging/development only - * @FDTSRC_NONE: No devicetree at all + * @FDTSRC_BLOBLIST: Provided by a bloblist from an earlier phase */ enum fdt_source_t { FDTSRC_SEPARATE, @@ -80,6 +80,7 @@ enum fdt_source_t { FDTSRC_BOARD, FDTSRC_EMBED, FDTSRC_ENV, + FDTSRC_BLOBLIST, }; /* diff --git a/lib/fdtdec.c b/lib/fdtdec.c index 7a6916764835..bd88e6a418eb 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -7,7 +7,11 @@ */ #ifndef USE_HOSTCC + +#define LOG_CATEGORY LOGC_DT + #include +#include #include #include #include @@ -87,6 +91,7 @@ static const char *const fdt_src_name[] = { [FDTSRC_BOARD] = "board", [FDTSRC_EMBED] = "embed", [FDTSRC_ENV] = "env", + [FDTSRC_BLOBLIST] = "bloblist", }; const char *fdtdec_get_srcname(void) @@ -1666,20 +1671,35 @@ int fdtdec_setup(void) int ret; /* The devicetree is typically appended to U-Boot */ - if (IS_ENABLED(CONFIG_OF_SEPARATE)) { - gd->fdt_blob = fdt_find_separate(); - gd->fdt_src = FDTSRC_SEPARATE; - } else { /* embed dtb in ELF file for testing / development */ - gd->fdt_blob = dtb_dt_embedded(); - gd->fdt_src = FDTSRC_EMBED; - } - - /* Allow the board to override the fdt address. */ - if (IS_ENABLED(CONFIG_OF_BOARD)) { - gd->fdt_blob = board_fdt_blob_setup(&ret); + if (CONFIG_IS_ENABLED(OF_BLOBLIST)) { + ret = bloblist_maybe_init(); if (ret) return ret; - gd->fdt_src = FDTSRC_BOARD; + gd->fdt_blob = bloblist_find(BLOBLISTT_CONTROL_FDT, 0); + if (!gd->fdt_blob) { + printf("Not FDT found in bloblist\n"); + bloblist_show_list(); + return -ENOENT; + } + gd->fdt_src = FDTSRC_BLOBLIST; + bloblist_show_list(); + log_debug("Devicetree is in bloblist at %p\n", gd->fdt_blob); + } else { + if (IS_ENABLED(CONFIG_OF_SEPARATE)) { + gd->fdt_blob = fdt_find_separate(); + gd->fdt_src = FDTSRC_SEPARATE; + } else { /* embed dtb in ELF file for testing / development */ + gd->fdt_blob = dtb_dt_embedded(); + gd->fdt_src = FDTSRC_EMBED; + } + + /* 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; + gd->fdt_src = FDTSRC_BOARD; + } } /* Allow the early environment to override the fdt address */ -- 2.42.0.515.g380fc7ccd1-goog