From patchwork Mon Oct 16 05:39:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 734018 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:1045:b0:32d:baff:b0ca with SMTP id c5csp52491wrx; Sun, 15 Oct 2023 22:41:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHyiV54ibtFJPPJ2WTZAS5N19c49HVAAsRi5koZWVshFuUO01SE0znHhtxPYOIEBIWyKnxO X-Received: by 2002:a05:600c:5103:b0:406:8498:3d3a with SMTP id o3-20020a05600c510300b0040684983d3amr28409611wms.14.1697434885188; Sun, 15 Oct 2023 22:41:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697434885; cv=none; d=google.com; s=arc-20160816; b=W4KWsvcLWNsGV/l+lV4u99jTkCKuzVXwSckUHP93FDiPlteQJSZTljx4c2hzpF/5YK SaGSdjvdkw1lLd5PxsH3dAyq/knuEKiLEbKGiUr2Vpfu2XoPaWFCi3JGAOhTA0JJUS0J ELPjTL3VhgBa2rtWlLiaMn8X2Dzd2K+dgaCzFELTqHQYd0oSq5aedKk6tEn2gO5roB5s dq1R0rW6VEi21rXiugFbjpXIXM/hFijohhpYHMQn5fN5HwwwprEtuxYhRKsZ67VH7oV2 hfQs4Z3a5oZeEeATJ9dBYcjS4BRXbkwJIfc0n3KxtE/dfyEKv+SiXQh+vde6vMhASHsb tv7A== 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=l0j2SXDyOINzcNZpUi2TReN/FcwaT02Nc3ilNBW+hho=; fh=+s9SE2w9oguEKAMcR35TXtqntCOeVFhiK9u/Kju91lo=; b=jNT1cFe8J5XzR4thFzOfkRgA3+VnCiRlcpWu+oWIfJ/sd199lYGbZTSmAc7IJlNGRl /fj6SAi0iAgvkVr2ty6YgxTJ2LoOz0sjFriKDQC2izl/3/XPh9x5I0b0WeqaP5EhlFBJ LpAQuDtJrAVyxIALOq91nhVGrx3/15FSkkMKwAeGfqubjJDfw8x0FesVdSPmwkKnQkx0 DuNN8OXpO5pijppgvEiVGEE0QsKOQ+uuiVchfN8avSlBdb1OU+64fiDfNJuwQpQaPOjg 0jFUT/1giBV9VPXJksYkHob9iX5AnUfyPh/g4GAcRoV5Y12nqlX1zTYqW6SSW7a8+2rb N0Dg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZwzW2AvI; 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 m3-20020a05600c160300b00401fcebcfa0si2254187wmn.171.2023.10.15.22.41.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Oct 2023 22:41:25 -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=ZwzW2AvI; 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 3BEE886C65; Mon, 16 Oct 2023 07:41:24 +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="ZwzW2AvI"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 770C886958; Mon, 16 Oct 2023 07:40:31 +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-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) (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 7FEF286DA2 for ; Mon, 16 Oct 2023 07:40:14 +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-pg1-x52c.google.com with SMTP id 41be03b00d2f7-5a0dc313058so79158a12.0 for ; Sun, 15 Oct 2023 22:40:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697434812; x=1698039612; 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=l0j2SXDyOINzcNZpUi2TReN/FcwaT02Nc3ilNBW+hho=; b=ZwzW2AvIbq4nUNn5qAQ5WUT1ynJUjkV8pchJdj8+kkhc23R0MKyPmxa7FQoJ95sL7f +Nl/CKuouDdnmR1fLNx7rPc3/vmyjCjqtoOzu0odW6ojNyDLs62FN8FR73sg4LASBSdg 82hy9yhOYYplnwZj1CFS7nr+fJld8/aCJdJIk/fQ9u6je1HrHODqrhzcY/yUBFC6Yb5u 5An6dRlc4a1TkRqz0/VmLMqE1NPtKM5hD7ldmOwOpbAr6ymKtCejWjUVyAQhPaHOSuZY AMtS1lIyrXmJ033AXalVeDMfb6xainzfFAf6Z/eYAG7/N0xsn4i1/gYlrReXZiWejDaI sbfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697434812; x=1698039612; 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=l0j2SXDyOINzcNZpUi2TReN/FcwaT02Nc3ilNBW+hho=; b=j2H7vewduSCvFUbch97dsWyQIUhjtgm6jWuHA7pGWcbb7Spbahba4zRh1iUTqh7uCV K2ceMHzclmuLRDCIKzZWGxwauTaRqlBtBlQocYLmIO46xdQ4p7bZ/aygGAeKOg8bkcGF +SfopbEY5x5Yl0P+hvpYjsEx2vEDiZ8u/hdV5wNt8AW5HNd8xs/YrAYFQRLO6Eygxn43 vTp1eHRfNb+4vYcm8dbnL8so7/RaGR+CLQat89hOt5WJrANocigL92k77vA8GUEP12EO /F13AJFYWv8LPbTJU1btITpXYUvBaWJUaM0qXDzTy5olnoua9ZZQHLdvIGWKzLkpy+E9 CFFw== X-Gm-Message-State: AOJu0Yx+//PpyZhdK/8HGFfghagAU2AYqEJt068qoSUpgZKboCr0hpFk jsXpixJkMLT7+RdnCm85DLnRMA== X-Received: by 2002:a17:90b:4b04:b0:27d:1593:2b08 with SMTP id lx4-20020a17090b4b0400b0027d15932b08mr12694459pjb.0.1697434812436; Sun, 15 Oct 2023 22:40:12 -0700 (PDT) Received: from octopus.. ([2400:4050:c3e1:100:4c30:a6e6:b316:7d31]) by smtp.gmail.com with ESMTPSA id lb18-20020a17090b4a5200b002636dfcc6f5sm3878134pjb.3.2023.10.15.22.40.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Oct 2023 22:40:12 -0700 (PDT) From: AKASHI Takahiro To: trini@konsulko.com, sjg@chromium.org Cc: etienne.carriere@st.com, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH v2 4/4] test: dm: add SCMI power domain protocol test Date: Mon, 16 Oct 2023 14:39:46 +0900 Message-Id: <20231016053946.470458-5-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231016053946.470458-1-takahiro.akashi@linaro.org> References: <20231016053946.470458-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 This ut has tests for the SCMI power domain protocol as well as DM interfaces for power domain devices. Signed-off-by: AKASHI Takahiro Reviewed-by: Simon Glass --- v2 * remove a change at "test_scmi_cmd" because "scmi" command is no longer provided --- test/dm/scmi.c | 103 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) diff --git a/test/dm/scmi.c b/test/dm/scmi.c index d4ff60e00069..da45314f2e4c 100644 --- a/test/dm/scmi.c +++ b/test/dm/scmi.c @@ -206,6 +206,109 @@ 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_power_domains(struct unit_test_state *uts) +{ + struct sandbox_scmi_agent *agent; + struct sandbox_scmi_devices *scmi_devices; + struct udevice *agent_dev, *pwd, *dev; + u32 version, count, attributes, pstate; + u64 stats_addr; + size_t stats_len; + u8 *name; + int ret; + + /* preparation */ + ut_assertok(load_sandbox_scmi_test_devices(uts, &agent, &dev)); + ut_assertnonnull(agent); + scmi_devices = sandbox_scmi_devices_ctx(dev); + ut_assertnonnull(scmi_devices); + ut_asserteq(2, scmi_devices->pwdom->id); /* in test.dts */ + + ut_assertok(uclass_get_device_by_name(UCLASS_SCMI_AGENT, "scmi", + &agent_dev)); + ut_assertnonnull(agent_dev); + pwd = scmi_get_protocol(agent_dev, SCMI_PROTOCOL_ID_POWER_DOMAIN); + ut_assertnonnull(pwd); + + /* + * SCMI Power domain management protocol interfaces + */ + /* version */ + ret = scmi_generic_protocol_version(pwd, SCMI_PROTOCOL_ID_POWER_DOMAIN, + &version); + ut_assertok(ret); + ut_asserteq(agent->pwdom_version, version); + + /* protocol attributes */ + ret = scmi_pwd_protocol_attrs(pwd, &count, &stats_addr, &stats_len); + ut_assertok(ret); + ut_asserteq(agent->pwdom_count, count); + ut_asserteq(0, stats_len); + + /* protocol message attributes */ + ret = scmi_pwd_protocol_message_attrs(pwd, SCMI_PWD_STATE_SET, + &attributes); + ut_assertok(ret); + ret = scmi_pwd_protocol_message_attrs(pwd, SCMI_PWD_STATE_NOTIFY, + &attributes); + ut_asserteq(-ENOENT, ret); /* the protocol not supported */ + + /* power domain attributes */ + ret = scmi_pwd_attrs(pwd, 0, &attributes, &name); + ut_assertok(ret); + ut_asserteq_str("power-domain--0", name); + free(name); + + ret = scmi_pwd_attrs(pwd, 10, &attributes, &name); + ut_asserteq(-ENOENT, ret); /* domain-10 doesn't exist */ + + /* power domain state set/get */ + ret = scmi_pwd_state_set(pwd, 0, 0, 0); + ut_assertok(ret); + ret = scmi_pwd_state_get(pwd, 0, &pstate); + ut_assertok(ret); + ut_asserteq(0, pstate); /* ON */ + + ret = scmi_pwd_state_set(pwd, 0, 0, SCMI_PWD_PSTATE_TYPE_LOST); + ut_assertok(ret); + ret = scmi_pwd_state_get(pwd, 0, &pstate); + ut_assertok(ret); + ut_asserteq(SCMI_PWD_PSTATE_TYPE_LOST, pstate); /* OFF */ + + ret = scmi_pwd_state_set(pwd, 0, 10, 0); + ut_asserteq(-ENOENT, ret); + + /* power domain name get */ + ret = scmi_pwd_name_get(pwd, 0, &name); + ut_assertok(ret); + ut_asserteq_str("power-domain--0-extended", name); + free(name); + + ret = scmi_pwd_name_get(pwd, 10, &name); + ut_asserteq(-ENOENT, ret); /* domain-10 doesn't exist */ + + /* + * U-Boot driver model interfaces + */ + /* power_domain_on */ + ret = power_domain_on(scmi_devices->pwdom); + ut_assertok(ret); + ret = scmi_pwd_state_get(pwd, scmi_devices->pwdom->id, &pstate); + ut_assertok(ret); + ut_asserteq(0, pstate); /* ON */ + + /* power_domain_off */ + ret = power_domain_off(scmi_devices->pwdom); + ut_assertok(ret); + ret = scmi_pwd_state_get(pwd, scmi_devices->pwdom->id, &pstate); + ut_assertok(ret); + ut_asserteq(SCMI_PWD_PSTATE_TYPE_LOST, pstate); /* OFF */ + + return release_sandbox_scmi_test_devices(uts, dev); +} + +DM_TEST(dm_test_scmi_power_domains, UT_TESTF_SCAN_FDT); + static int dm_test_scmi_clocks(struct unit_test_state *uts) { struct sandbox_scmi_agent *agent;