From patchwork Wed Oct 25 05:14:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 737803 Delivered-To: patch@linaro.org Received: by 2002:adf:f842:0:b0:32d:baff:b0ca with SMTP id d2csp110781wrq; Tue, 24 Oct 2023 22:16:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHrJUQsJgRdcV3pPLWaiDBzdrm3f6WPg/VJlDWdoCB/4VZiUqtnsaXEgPkhAojF23mR01Fy X-Received: by 2002:a5d:54c1:0:b0:32d:9b32:8a7e with SMTP id x1-20020a5d54c1000000b0032d9b328a7emr9054618wrv.71.1698210961548; Tue, 24 Oct 2023 22:16:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698210961; cv=none; d=google.com; s=arc-20160816; b=ATjbCPGOumgaYBTvsvZ4MpDmdeBvze4I60WhRjG8ghiH/JoCcx8j+GXsGgv3nhx7YQ drbVeegWbZwfH/AIhbuP93SmpxoopRfK88uS0JNZHF0to0m6sp+pA5nSzz0NVgVSj3Dq ZlHnYZPTWm5/GV59zlOvp6GIBdrn2RIJgISR1dXTSHuHXTD64s7Uef/QMICt21o9wY+G jzk+OkCxkVqQ37IpPLBOALBFzvwNaJ4BBFwtLlr6TEdx3+p6XVGrl1z/Vvk13+JmHyhv xxVTmJoVC9x27hqV1LnRJtgcTuNpQC6PRJdUwHzZrtJCVBfuh1g3YUh56CcCaEvU66dD 75nQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=hD60SfHV9nxHXcrI7Ny6Jjph+UCCDkTfF34GTIduQEo=; fh=QZWY3XY+sB907ugYHcr63Nh2/mcdieyH+ES8hS8oMbI=; b=PnyOuTrBznyr1EzijVZokvo9ipxB4obVCyx+tdR8aQgHQQbVz5bgtSErpOPppFhABF we41hjgf4e1fXT5BauTX/UR/D+/MpFHoYQUa13R+AuPouLsgpfC/IaMNU5KIYReIHouf Zn0iWaAdrJT8Rp3X0Tlv21VrQ7g8OQzDyrpNER+Gody0BlUf83bivUSmXu1RCFAc7qCC rpUFNJ+IJaAyPFN0EufYpUfusebnfEW6KFIgb/y8X7URJkzkSqPLp5DOi48tDvqZeoPV Yrl/PcHSN63gpZxhDX/dqFtHBMJi8jifSEHbKkwR4qnC2iklPs+0ReZRyeyEiGnVZJts pbmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=V+qLWoRu; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id f8-20020a5d4dc8000000b0032330c33aa7si6639017wru.632.2023.10.24.22.16.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 22:16:01 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=V+qLWoRu; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9FF9887A4A; Wed, 25 Oct 2023 07:15:11 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="V+qLWoRu"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 89B3C87A3C; Wed, 25 Oct 2023 07:15:09 +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,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) (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 28D2C87A36 for ; Wed, 25 Oct 2023 07:15:07 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-6bcbfecf314so1138833b3a.1 for ; Tue, 24 Oct 2023 22:15:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698210905; x=1698815705; 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=hD60SfHV9nxHXcrI7Ny6Jjph+UCCDkTfF34GTIduQEo=; b=V+qLWoRuB5nW6i8P0WbE3obToz0k8MwSbsbJSqzkTbQ0wLToYd44b5he/Q1gWpyV98 VZ3oaldh1aBc7MhoJGQs8Ir5mN62BbIiTwHatdFWWH8nd94urSegQmbmQSGhvRd7JR7Z qJvWnItOpV3v5ArrgN5CrqJ83qtdrm3p3rpOi21PEjXsmvt9sFe2vJY05Y9U8geq/R4W FoRSW+kIzIkHYyFzrm/EgAHFKQ0YdOXWtFVOPXzEKd1GapGwhm6goWholMce2Bo/hujT 5+mGh5a6k8+SLPS4ghTheYVsIzq/8ki/7gWasb9wo9umYHiuGvElWDCrKYfVS0koOZmT 7j0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698210905; x=1698815705; 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=hD60SfHV9nxHXcrI7Ny6Jjph+UCCDkTfF34GTIduQEo=; b=fRs2N4/2PYaQX/vJCWrv5uAT80guyWc2PvpfpBHcoFAvlSd/UOWirxJwLT9etem3HN UAl/7PNOTlMtg0RiLq5xsjjf97+HVHcRbYV0vRnSHyYY76JSj87TcSeX2MoAE2Z1/q6K DkmV/ajXEkUwTxgMQLefjfuSjz5sI0UIYT0T1oeN9VU4rQEokEDcHFDKSRMINPx9V27y UMxsto5znnz+5UG2qeFrKAAP3zqmtqT6L4Czs6rabIisP2IczLfpUdtgS6j340RVHX08 a5yRZ1VYuw+f1Nzi2MefkbvVrR4qEVhrNXUk+aiuv+wFGu5BqF0JBJln/OowmpEiX3wn jCTQ== X-Gm-Message-State: AOJu0Yzp0sZs4MKO/wc5hAwxgjJS+3MSYSG8GEFb0rVHCuwpuSGspJGr adF5m2qv30gbQXcWKOTfB4CYVA== X-Received: by 2002:a17:90b:4b8f:b0:27c:f653:37b2 with SMTP id lr15-20020a17090b4b8f00b0027cf65337b2mr16464858pjb.1.1698210905512; Tue, 24 Oct 2023 22:15:05 -0700 (PDT) Received: from octopus.. ([2400:4050:c3e1:100:65fc:df7c:6edb:619f]) by smtp.gmail.com with ESMTPSA id fz3-20020a17090b024300b002609cadc56esm7715815pjb.11.2023.10.24.22.15.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 22:15:05 -0700 (PDT) From: AKASHI Takahiro To: trini@konsulko.com, sjg@chromium.org Cc: etienne.carriere@st.com, michal.simek@amd.com, u-boot@lists.denx.de, AKASHI Takahiro , Etienne Carriere Subject: [PATCH 5/5] test: dm: add scmi command test Date: Wed, 25 Oct 2023 14:14:27 +0900 Message-Id: <20231025051427.509602-6-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231025051427.509602-1-takahiro.akashi@linaro.org> References: <20231025051427.509602-1-takahiro.akashi@linaro.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.8 at phobos.denx.de X-Virus-Status: Clean In this test, "scmi" command is tested against different sub-commands. Please note that scmi command is for debug purpose and is not intended in production system. Signed-off-by: AKASHI Takahiro Reviewed-by: Simon Glass Reviewed-by: Etienne Carriere --- v7 * make test assertions more flexible depending on the number of provided protocols v4 * move 'base'-related changes to the prior commit * add CONFIG_CMD_SCMI to sandbox_defconfig v3 * change char to u8 in vendor/agent names v2 * use helper functions, removing direct uses of ops --- configs/sandbox_defconfig | 1 + test/dm/scmi.c | 81 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+) diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig index e3a2f9eb1708..34e3cc281d7f 100644 --- a/configs/sandbox_defconfig +++ b/configs/sandbox_defconfig @@ -120,6 +120,7 @@ CONFIG_CMD_REGULATOR=y CONFIG_CMD_AES=y CONFIG_CMD_TPM=y CONFIG_CMD_TPM_TEST=y +CONFIG_CMD_SCMI=y CONFIG_CMD_BTRFS=y CONFIG_CMD_CBFS=y CONFIG_CMD_CRAMFS=y diff --git a/test/dm/scmi.c b/test/dm/scmi.c index 2f63f2da16fb..2bcf7ac6fcc3 100644 --- a/test/dm/scmi.c +++ b/test/dm/scmi.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -206,6 +207,86 @@ static int dm_test_scmi_base(struct unit_test_state *uts) DM_TEST(dm_test_scmi_base, UT_TESTF_SCAN_FDT); +static int dm_test_scmi_cmd(struct unit_test_state *uts) +{ + struct udevice *agent_dev; + int num_proto = 0; + char cmd_out[30]; + + if (!IS_ENABLED(CONFIG_CMD_SCMI)) + return 0; + + /* preparation */ + ut_assertok(uclass_get_device_by_name(UCLASS_SCMI_AGENT, "scmi", + &agent_dev)); + ut_assertnonnull(agent_dev); + + /* + * Estimate the number of provided protocols. + * This estimation is correct as far as a corresponding + * protocol support is added to sandbox fake serer. + */ + if (IS_ENABLED(CONFIG_SCMI_POWER_DOMAIN)) + num_proto++; + if (IS_ENABLED(CONFIG_CLK_SCMI)) + num_proto++; + if (IS_ENABLED(CONFIG_RESET_SCMI)) + num_proto++; + if (IS_ENABLED(CONFIG_DM_REGULATOR_SCMI)) + num_proto++; + + /* scmi info */ + ut_assertok(run_command("scmi info", 0)); + + ut_assert_nextline("SCMI device: scmi"); + snprintf(cmd_out, 30, " protocol version: 0x%x", + SCMI_BASE_PROTOCOL_VERSION); + ut_assert_nextline(cmd_out); + ut_assert_nextline(" # of agents: 2"); + ut_assert_nextline(" 0: platform"); + ut_assert_nextline(" > 1: OSPM"); + snprintf(cmd_out, 30, " # of protocols: %d", num_proto); + ut_assert_nextline(cmd_out); + if (IS_ENABLED(CONFIG_SCMI_POWER_DOMAIN)) + ut_assert_nextline(" Power domain management"); + if (IS_ENABLED(CONFIG_CLK_SCMI)) + ut_assert_nextline(" Clock management"); + if (IS_ENABLED(CONFIG_RESET_SCMI)) + ut_assert_nextline(" Reset domain management"); + if (IS_ENABLED(CONFIG_DM_REGULATOR_SCMI)) + ut_assert_nextline(" Voltage domain management"); + ut_assert_nextline(" vendor: U-Boot"); + ut_assert_nextline(" sub vendor: Sandbox"); + ut_assert_nextline(" impl version: 0x1"); + + ut_assert_console_end(); + + /* scmi perm_dev */ + ut_assertok(run_command("scmi perm_dev 1 0 1", 0)); + ut_assert_console_end(); + + ut_assert(run_command("scmi perm_dev 1 0 0", 0)); + ut_assert_nextline("Denying access to device:0 failed (-13)"); + ut_assert_console_end(); + + /* scmi perm_proto */ + ut_assertok(run_command("scmi perm_proto 1 0 14 1", 0)); + ut_assert_console_end(); + + ut_assert(run_command("scmi perm_proto 1 0 14 0", 0)); + ut_assert_nextline("Denying access to protocol:0x14 on device:0 failed (-13)"); + ut_assert_console_end(); + + /* scmi reset */ + ut_assert(run_command("scmi reset 1 1", 0)); + ut_assert_nextline("Reset failed (-13)"); + ut_assert_console_end(); + + return 0; +} + +DM_TEST(dm_test_scmi_cmd, UT_TESTF_SCAN_FDT); + static int dm_test_scmi_power_domains(struct unit_test_state *uts) { struct sandbox_scmi_agent *agent;