From patchwork Wed Sep 7 02:27:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1675088 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=bptVkkBO; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MMmSt6TNdz1yhd for ; Wed, 7 Sep 2022 12:30:38 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CCA0C84A92; Wed, 7 Sep 2022 04:28:42 +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="bptVkkBO"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8307684ABC; Wed, 7 Sep 2022 04:28:30 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_FILL_THIS_FORM_SHORT,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-oa1-x32.google.com (mail-oa1-x32.google.com [IPv6:2001:4860:4864:20::32]) (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 B7B7A84A78 for ; Wed, 7 Sep 2022 04:28:20 +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-x32.google.com with SMTP id 586e51a60fabf-1278a61bd57so14256348fac.7 for ; Tue, 06 Sep 2022 19:28:20 -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=C3k4xxPkq0xKr8IKS/qqMkYAc7kHm1safX/20ozvzSU=; b=bptVkkBOlyVLdL1P8FwVa5xebA87kLVvIf3GSuq5yA072EBTR35bLMMxVV3vd4Mtpe yoY/nEm8PrikGmd+xllA6Naaqar3ild5RSm70ctszpof2dQ74lWKUIQfOTLof0f+e2w3 bW2iWukfL8ijxXqWiGyAwWR3S11ESpblTfw5Y= 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=C3k4xxPkq0xKr8IKS/qqMkYAc7kHm1safX/20ozvzSU=; b=XAsvkZFr2o1WGiJpLg/ycs//9OHKkzyJCc1e1Fg3klpcCfwIimTTb4za5lSMUZzk+t c8/mtSoRfh/7EAzANcyakevYXkmsfvBDs8TUKKNQ89P9SxbtXQVXD6OygC9FrQzYJlOE uJM0VglCNKo+n+vfxqojdjRCvppCf9c4ur7biVsrQKOZUZ/k4Us37gK/kwV+ePhCyQlp 2jzK3MCoCrbLCWwmTZ55na26T6gcmr4dW0Jl2iPyrl2i2s64Ln3aS7LJ5A6Bw2sVZg6h p6cCgCM5sf3cHZt+YB5R5wPJ2Z86TFhuOdNpT5e1++TDLkM6RJJExhqmNZid0Rgo/hgx K8wQ== X-Gm-Message-State: ACgBeo1ICr9erwCBTFcoY8T7kBkxCoTvRjEq26zX5piAVxDyblgyc873 YXrg/tW5xEecvcINUefZ3/zpWzsd341vDA== X-Google-Smtp-Source: AA6agR4yfaY80SQoYkfyR6p1kCvhu5ayuXTul7DtDcXMIvk4NKwGSWtS0XfU3D/cG/99F3N4ux3R3w== X-Received: by 2002:a05:6870:7089:b0:11e:a4e8:e669 with SMTP id v9-20020a056870708900b0011ea4e8e669mr13985161oae.156.1662517699930; Tue, 06 Sep 2022 19:28:19 -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 b10-20020a05687051ca00b0011e73536301sm7605046oaj.52.2022.09.06.19.28.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 19:28:19 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Kishon Vijay Abraham I , Michal Simek , =?utf-8?q?Marek_Beh=C3=BAn?= , Tom Rini , Simon Glass , Heinrich Schuchardt , Rasmus Villemoes Subject: [PATCH v2 21/45] sandbox: Support loading the other FDT Date: Tue, 6 Sep 2022 20:27:09 -0600 Message-Id: <20220907022733.66423-22-sjg@chromium.org> X-Mailer: git-send-email 2.37.2.789.g6183377224-goog In-Reply-To: <20220907022733.66423-1-sjg@chromium.org> References: <20220907022733.66423-1-sjg@chromium.org> MIME-Version: 1.0 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 We need an 'other' FDT which is different from the control FDT, so we can check that the ofnode tests correctly handle them both. Add this to the build along with a way to read it into the sandbox state. Signed-off-by: Simon Glass --- (no changes since v1) arch/sandbox/cpu/state.c | 26 ++++++++++++++++++++++++ arch/sandbox/dts/Makefile | 2 +- arch/sandbox/dts/other.dts | 35 ++++++++++++++++++++++++++++++++ arch/sandbox/include/asm/state.h | 16 +++++++++++++++ 4 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 arch/sandbox/dts/other.dts diff --git a/arch/sandbox/cpu/state.c b/arch/sandbox/cpu/state.c index 787e0216594..fcc4a337e59 100644 --- a/arch/sandbox/cpu/state.c +++ b/arch/sandbox/cpu/state.c @@ -418,6 +418,32 @@ int state_get_rel_filename(const char *rel_path, char *buf, int size) return len; } +int state_load_other_fdt(const char **bufp, int *sizep) +{ + struct sandbox_state *state = state_get_current(); + char fname[256]; + int len, ret; + + /* load the file if needed */ + if (!state->other_fdt_buf) { + len = state_get_rel_filename("arch/sandbox/dts/other.dtb", + fname, sizeof(fname)); + if (len < 0) + return len; + + ret = os_read_file(fname, &state->other_fdt_buf, + &state->other_size); + if (ret) { + log_err("Cannot read file '%s'\n", fname); + return ret; + } + } + *bufp = state->other_fdt_buf; + *sizep = state->other_size; + + return 0; +} + int state_init(void) { state = &main_state; diff --git a/arch/sandbox/dts/Makefile b/arch/sandbox/dts/Makefile index 6cbc9bbcaa1..b6a88479b22 100644 --- a/arch/sandbox/dts/Makefile +++ b/arch/sandbox/dts/Makefile @@ -5,7 +5,7 @@ dtb-$(CONFIG_SANDBOX) += sandbox64.dtb else dtb-$(CONFIG_SANDBOX) += sandbox.dtb endif -dtb-$(CONFIG_UT_DM) += test.dtb +dtb-$(CONFIG_UT_DM) += test.dtb other.dtb dtb-$(CONFIG_CMD_EXTENSION) += overlay0.dtbo overlay1.dtbo include $(srctree)/scripts/Makefile.dts diff --git a/arch/sandbox/dts/other.dts b/arch/sandbox/dts/other.dts new file mode 100644 index 00000000000..395a7923228 --- /dev/null +++ b/arch/sandbox/dts/other.dts @@ -0,0 +1,35 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Other devicetree file for running sandbox tests + * + * This used for tests which want to check they can access multiple device + * trees. This one is loaded and checks are made that it is actually visible. + */ + +/dts-v1/; + +/ { + compatible = "sandbox-other"; + #address-cells = <1>; + #size-cells = <1>; + + node { + target = <&target 3 4>; + + subnode { + compatible = "sandbox-other2"; + str-prop = "other"; + }; + + subnode2 { + }; + }; + + target: target { + compatible = "sandbox-other2"; + #gpio-cells = <2>; + str-prop = "other"; + reg = <0x8000 0x100>; + status = "disabled"; + }; +}; diff --git a/arch/sandbox/include/asm/state.h b/arch/sandbox/include/asm/state.h index 12741ee064a..fd42daad51c 100644 --- a/arch/sandbox/include/asm/state.h +++ b/arch/sandbox/include/asm/state.h @@ -108,6 +108,9 @@ struct sandbox_state { bool hwspinlock; /* Hardware Spinlock status */ bool allow_memio; /* Allow readl() etc. to work */ + void *other_fdt_buf; /* 'other' FDT blob used by tests */ + int other_size; /* size of other FDT blob */ + /* * This struct is getting large. * @@ -279,6 +282,19 @@ void state_show(struct sandbox_state *state); */ int state_get_rel_filename(const char *rel_path, char *buf, int size); +/** + * state_load_other_fdt() - load the 'other' FDT into a buffer + * + * This loads the other.dtb file into a buffer. This is typically used in tests. + * + * @bufp: Place to put allocated buffer pointer. The buffer is read using + * os_read_file() which calls os_malloc(), so does affect U-Boot's own malloc() + * space + * @sizep: Returns the size of the buffer + * @return 0 if OK, -ve on error + */ +int state_load_other_fdt(const char **bufp, int *sizep); + /** * Initialize the test system state */