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 9A7BFC433EF for ; Fri, 17 Dec 2021 04:04:44 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8D29783788; Fri, 17 Dec 2021 05:02:31 +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="d85b1tGQ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 265E983076; Fri, 17 Dec 2021 05:01:01 +0100 (CET) Received: from mail-ot1-x333.google.com (mail-ot1-x333.google.com [IPv6:2607:f8b0:4864:20::333]) (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 F046A830A0 for ; Fri, 17 Dec 2021 05:00:27 +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-ot1-x333.google.com with SMTP id n104-20020a9d2071000000b005799790cf0bso1368100ota.5 for ; Thu, 16 Dec 2021 20:00:27 -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=N3X7gIGVuqKnGWt0ZVdeop6cMyZidAy97M3+b5ylXx4=; b=d85b1tGQPB6jGtn+8VyY+e1MeOpeMIccAhbpcrqJOV0NnEtdIJ24ypf6r7XEi/DNDD r6SISAUOvhfzi+T65uwpWemq/p9IJ52XFXzLhb/oY7EO0sjhq4vwKa64MUeDn9RiYP2C 0mxEequlLMXgDIfCfIfWmhgx1vc40wSPh4nTk= 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=N3X7gIGVuqKnGWt0ZVdeop6cMyZidAy97M3+b5ylXx4=; b=cX75N8jHJN2VpWUvySUSj1+EQe+6zJwrOvU/Ivc2upDqdpMmejIjw4yQPOa1jyIyvr Nku4oVjMBcRc6oIAXgInMXXNQ3T8JWu7bRDee22DEJct8PY7IMv207xBNZhUW1s47qB4 6fBuD1k6WCAQy1+ssnyJAEsZi1ciJZsPlrwg8AHu3oFjXJzG2ht1zbg8+UiCDVnv9oyw Z+leer6DRtQ5C5idPX7DzOzOg/rxmh8i1jXcNvSVjmqRI2PXqOuPSgp5VrGWEQZa628a /lGjruRUAyOXHFLNhemj5e8rOz85g4d++n+EK1UlLigeRjYNVxcyDPA0nmD99782xg6T pSAA== X-Gm-Message-State: AOAM531oR4UheI9OyKuoejolPCO8N6Jz66rEbB88aziW62VUkxnzuNox MYl7zq/zFI8yf2DkG+1rZ6L43pCVVag+Og== X-Google-Smtp-Source: ABdhPJzBE3W3cJerZx6cH8VCK5idzZshLFcH+pWE07Dqc6Dtn1SgWCtpf7qCZHhtjSEYLnhNb/uwZw== X-Received: by 2002:a05:6830:4cf:: with SMTP id s15mr883918otd.219.1639713626437; Thu, 16 Dec 2021 20:00:26 -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.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Dec 2021 20:00:26 -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 26/32] fdt: Record where the devicetree came from Date: Thu, 16 Dec 2021 20:59:33 -0700 Message-Id: <20211216205905.v8.26.I60f02bbc201166267fc11bf3159d1a93764d201f@changeid> 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 Keep track of where the devicetree came from, so we can report this later. Signed-off-by: Simon Glass --- (no changes since v7) Changes in v7: - Drop FDTSRC_PASSAGE for now include/asm-generic/global_data.h | 4 ++++ include/fdtdec.h | 32 +++++++++++++++++++++++++++++++ lib/fdtdec.c | 20 ++++++++++++++----- 3 files changed, 51 insertions(+), 5 deletions(-) diff --git a/include/asm-generic/global_data.h b/include/asm-generic/global_data.h index 99daa20c765..104282bd479 100644 --- a/include/asm-generic/global_data.h +++ b/include/asm-generic/global_data.h @@ -244,6 +244,10 @@ struct global_data { * @fdt_size: space reserved for relocated device space */ unsigned long fdt_size; + /** + * @fdt_src: Source of FDT + */ + enum fdt_source_t fdt_src; #if CONFIG_IS_ENABLED(OF_LIVE) /** * @of_root: root node of the live tree diff --git a/include/fdtdec.h b/include/fdtdec.h index 68a36f10583..09525ce510a 100644 --- a/include/fdtdec.h +++ b/include/fdtdec.h @@ -55,6 +55,31 @@ struct bd_info; #define SPL_BUILD 0 #endif +/** + * enum fdt_source_t - indicates where the devicetree came from + * + * These are listed in approximate order of desirability after FDTSRC_NONE + * + * @FDTSRC_SEPARATE: Appended to U-Boot. This is the normal approach if U-Boot + * is the only firmware being booted + * @FDTSRC_FIT: Found in a multi-dtb FIT. This should be used when U-Boot must + * select a devicetree from many options + * @FDTSRC_BOARD: Located by custom board code. This should only be used when + * the prior stage does not support FDTSRC_PASSAGE + * @FDTSRC_EMBED: Embedded into U-Boot executable. This should onyl be used when + * 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 + */ +enum fdt_source_t { + FDTSRC_SEPARATE, + FDTSRC_FIT, + FDTSRC_BOARD, + FDTSRC_EMBED, + FDTSRC_ENV, +}; + /* * Information about a resource. start is the first address of the resource * and end is the last address (inclusive). The length of the resource will @@ -1215,4 +1240,11 @@ int fdtdec_decode_ram_size(const void *blob, const char *area, int board_id, phys_addr_t *basep, phys_size_t *sizep, struct bd_info *bd); +/** + * fdtdec_get_srcname() - Get the name of where the devicetree comes from + * + * @return source name + */ +const char *fdtdec_get_srcname(void); + #endif diff --git a/lib/fdtdec.c b/lib/fdtdec.c index 31a509bc221..8cfa958fb96 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -1618,6 +1618,7 @@ static void setup_multi_dtb_fit(void) if (blob) { gd_set_multi_dtb_fit(gd->fdt_blob); gd->fdt_blob = blob; + gd->fdt_src = FDTSRC_FIT; } } @@ -1626,22 +1627,31 @@ int fdtdec_setup(void) int ret; /* The devicetree is typically appended to U-Boot */ - if (IS_ENABLED(CONFIG_OF_SEPARATE)) + if (IS_ENABLED(CONFIG_OF_SEPARATE)) { gd->fdt_blob = fdt_find_separate(); - else /* embed dtb in ELF file for testing / development */ + 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 */ if (!IS_ENABLED(CONFIG_SPL_BUILD)) { - /* Allow the early environment to override the fdt address */ - gd->fdt_blob = map_sysmem(env_get_ulong("fdtcontroladdr", 16, - (unsigned long)map_to_sysmem(gd->fdt_blob)), 0); + ulong addr; + + addr = env_get_hex("fdtcontroladdr", 0); + if (addr) { + gd->fdt_blob = map_sysmem(addr, 0); + gd->fdt_src = FDTSRC_ENV; + } } if (CONFIG_IS_ENABLED(MULTI_DTB_FIT)) -- 2.34.1.173.g76aa8bc2d0-goog