From patchwork Mon Nov 13 01:49:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 743447 Delivered-To: patch@linaro.org Received: by 2002:a5d:67cf:0:b0:32d:baff:b0ca with SMTP id n15csp1411376wrw; Sun, 12 Nov 2023 17:49:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IHvLYnssGCQ9CNf3WeQOw+qzAfRb68T4SLxX4rvXyFKzuDiJOGY+g3UdLVBU13E3rgguiAP X-Received: by 2002:a17:906:4b57:b0:9b7:2a13:160c with SMTP id j23-20020a1709064b5700b009b72a13160cmr3585748ejv.69.1699840185319; Sun, 12 Nov 2023 17:49:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699840185; cv=none; d=google.com; s=arc-20160816; b=oEUdsTTX1u9sN2Cdji+m9P3h0HozuuL5pIOAyiMIG9g4YLnRtY5DjzLx1ZKawdwuaV 8e4OvoOw+fbhoApztQaLIkQiBcT5uiI629IMz4yQDzrnFvX9G0eIMKUWPEJX/QZ6V7+V 8vwOiMrZu+bdGmsjeSbWy2oz2LhBN5gHI6LmmPgtEFAnnebGDHdrt4OIDotqG3m7N42I u2S0tDIoK3tpYXCf6UDEMdDRv07HxXZ7urkEwL+/HdSYkcvz1nj/zROzzibiR0Wc4uKB 5kgVYESCM/pJQqOCH0mN/CbXCZNF0ayBBNDVd+WZotcKgxqvisE9JzOxBnF47ruMSciB NcTw== 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=RhuXaK1nkfB94SXKHqcAWitSO/acsFBFmPnl2Cf7zBo=; fh=FEXntNvfp44QdEE6WJIcPMgg3VtrFk//sTXqtO2Yfu8=; b=s1k8hdOxHQT3q6EUrijV/duIdpXsh0Xw9vdKju/zzwZIlj5gd47U5ZMbaZNZn7vkG/ iKT45xUxZBohjjMXQfqT8PUWxHem9I+W03tvE5iW9Z/iMg46YXtljn4QjAsDTb35ZsyZ rvW4b/HWTnK/c/YcZRCuzq4qUeOsgMlMDtypyPRLe+tCiNaw2D/OKMGR/ufI16W2kZYI KjOV4Vk57/uuSaghGtT1lNFtdpalTGrxEGD2ZA8V6lqNu7WDhr24W5vp5iHRvFA1m/7Y lr86UboRwO4/ynkBR3l6si7SXoEr9fV4STOjIHznhzJhIhD2iCRJxJWqwQPVVOiWfe89 wfzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OcYs+CEP; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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. [85.214.62.61]) by mx.google.com with ESMTPS id hs14-20020a1709073e8e00b009e740a9fbf8si2228592ejc.508.2023.11.12.17.49.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Nov 2023 17:49:45 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OcYs+CEP; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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 A84F186B9A; Mon, 13 Nov 2023 02:49:37 +0100 (CET) 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="OcYs+CEP"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4A8808701D; Mon, 13 Nov 2023 02:49:36 +0100 (CET) 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, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ot1-x335.google.com (mail-ot1-x335.google.com [IPv6:2607:f8b0:4864:20::335]) (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 BA81786B9A for ; Mon, 13 Nov 2023 02:49:33 +0100 (CET) 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-ot1-x335.google.com with SMTP id 46e09a7af769-6d63e0412faso518076a34.1 for ; Sun, 12 Nov 2023 17:49:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699840172; x=1700444972; 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=RhuXaK1nkfB94SXKHqcAWitSO/acsFBFmPnl2Cf7zBo=; b=OcYs+CEPCH++WJ+pyxVRvbhsQw2cBXeho80URbgE/A8Gx7RsQr8Ai6M+VzN7A591+x OIEaaOQ/I0tviVPy4Z+4JsX44j3gRkMb/tWrvQh9cbvbq+O24y4bh5xcPrYVCyDT2V+X 0t9VILB2woZXuCaJo4Dmkpths/1pF8fffzrbzPQ7WCFYe5lIYq1+qsIYwn5xhDHrlyFh 9tpKzrqucTmx0wcNU7J0dZLaHJ40g6H2mtAdQIuYgzBBrI6XIfYBaVJwCHsj4HbvfSom 41FE/gIKgn7Y1jnsBexn05bnvv4oRWAPBrGfEXBYyos/wKmhL2y7qo8SFhLWgH9iLUQB FHFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699840172; x=1700444972; 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=RhuXaK1nkfB94SXKHqcAWitSO/acsFBFmPnl2Cf7zBo=; b=ZXYPo8XIl4CoE5k5SIIu6LT7rowZ/Ge5ATsOFRQGxIDMDPuQK4Gz9fetKpWAHDMrRf xBqG3xnGRYl/ipCCa1AnsoVdLU6G8Ghe3862hu8+0XVxcClfMkEKNCCj3RnKT9RsqMNN uzQSgemXEH8VDB0z+H0fpo9jfVvHnv6PD2FuiiMJEFsYnSV/8QufTlQV4JdvjZrF6kl7 s132StGKkTLy56zCW9Qrx1lSGsn7mRqU3nbGKANjXIoABfansGMNXCcavAdeWYDb1Gpa FaI2nijZTt5/Tc4F/SQuwWgCzKKH8/o3kUX9LSUYFATUBcrayH1nbeJ+sN23+i5RmnG7 VzRA== X-Gm-Message-State: AOJu0YwclcldCSr7biMtxyXCZPFj58Meo67HWGVEMr0LTvZ67ZONP5MM nUvBaAopo8jFr4pV1JNWWm/e5g== X-Received: by 2002:a05:6830:33e3:b0:6d3:3332:fbfb with SMTP id i3-20020a05683033e300b006d33332fbfbmr5407245otu.0.1699840171852; Sun, 12 Nov 2023 17:49:31 -0800 (PST) Received: from octopus.. ([2400:4050:c3e1:100:ba59:509b:48bc:9f1]) by smtp.gmail.com with ESMTPSA id s14-20020a65644e000000b005b92e60cf57sm2635549pgv.56.2023.11.12.17.49.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Nov 2023 17:49:31 -0800 (PST) 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 Subject: [PATCH v2 1/5] test: dm: skip scmi tests against disabled protocols Date: Mon, 13 Nov 2023 10:49:07 +0900 Message-Id: <20231113014911.3308990-2-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231113014911.3308990-1-takahiro.akashi@linaro.org> References: <20231113014911.3308990-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 is a precautionary change to make scmi tests workable whether or not a specific protocol be enabled. Signed-off-by: AKASHI Takahiro --- test/dm/scmi.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/dm/scmi.c b/test/dm/scmi.c index da45314f2e4c..2f63f2da16fb 100644 --- a/test/dm/scmi.c +++ b/test/dm/scmi.c @@ -217,6 +217,9 @@ static int dm_test_scmi_power_domains(struct unit_test_state *uts) u8 *name; int ret; + if (!IS_ENABLED(CONFIG_SCMI_POWER_DOMAIN)) + return 0; + /* preparation */ ut_assertok(load_sandbox_scmi_test_devices(uts, &agent, &dev)); ut_assertnonnull(agent); @@ -317,6 +320,9 @@ static int dm_test_scmi_clocks(struct unit_test_state *uts) int ret_dev; int ret; + if (!IS_ENABLED(CONFIG_CLK_SCMI)) + return 0; + ret = load_sandbox_scmi_test_devices(uts, &agent, &dev); if (ret) return ret; @@ -382,6 +388,9 @@ static int dm_test_scmi_resets(struct unit_test_state *uts) struct udevice *agent_dev, *reset_dev, *dev = NULL; int ret; + if (!IS_ENABLED(CONFIG_RESET_SCMI)) + return 0; + ret = load_sandbox_scmi_test_devices(uts, &agent, &dev); if (ret) return ret; @@ -418,6 +427,9 @@ static int dm_test_scmi_voltage_domains(struct unit_test_state *uts) struct udevice *dev; struct udevice *regul0_dev; + if (!IS_ENABLED(CONFIG_DM_REGULATOR_SCMI)) + return 0; + ut_assertok(load_sandbox_scmi_test_devices(uts, &agent, &dev)); scmi_devices = sandbox_scmi_devices_ctx(dev); From patchwork Mon Nov 13 01:49:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 743448 Delivered-To: patch@linaro.org Received: by 2002:a5d:67cf:0:b0:32d:baff:b0ca with SMTP id n15csp1411428wrw; Sun, 12 Nov 2023 17:49:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IHkzlINZOCjPGb7rkzCp7Zo/6u05cvgkwLvgI14sdhSVUJrPmdlKHxI5JR3WovPfcKjQxRP X-Received: by 2002:a05:6402:884:b0:545:5674:4293 with SMTP id e4-20020a056402088400b0054556744293mr3725702edy.28.1699840197201; Sun, 12 Nov 2023 17:49:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699840197; cv=none; d=google.com; s=arc-20160816; b=MNwtgFrTxuL6vTyN8g+YKqQd59OjHMgo0jUj3hCk9kufNTV4Am/IdKMiwz4LK8xbFs zt2H2ycCAfq5peXw6k50jQEHeeD+VkGuDW91hxUgxQsTcb57e8C+er4WmEJx43cmyWbO JKxC6xBgO08wQGv2sB+FAoUJCm4Qd1WRGXqR18OSu0Whp+UWUZkAvfCxV9NHXkeTDtbp xKrhJmodsu2kZe+H9iQmnUB2E+I2lIHeABrOGc7wS3M6Uq1aod8g2uPmu43saGM/qY24 rJjTaVZcsDjD0wEPBgo2KtEshQOrB0W7PjJIT5cp2Sh5jvmnrFuxOTRZp5DkHAS13eJH d/IA== 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=d3LRUUtYLKxzsp79cf17RY7bCQAiYMEVXLHLxjAU95k=; fh=FEXntNvfp44QdEE6WJIcPMgg3VtrFk//sTXqtO2Yfu8=; b=obMNcADdO8OwTLhysHYs2CFNqEnr9B1j5DLyP7Z3gTGKD6eZQpBhkfmgf9ReYIz0f+ tDPIjud0iIzVnPCU1Cqt7Hm2w8luB8k2a3EcJN6n1IlLV17TYBHM8MeXVIw885mDXPCf fxQBWjRIWWbNTldRRTtRy0MKtU/wD7Xoj/GYHM/KK3ogdeweSaPABaSjjysfw7mo7E4G tca40AFtjahCIRg/Ha2zdqLo48caPuGGbe9NBGeWRWwKij/lCoMXhfz+MreNPkksFvIl GcNZWKin9Dq86vQacBsWeNiKHrTuZ0PrI8FMBFuLMUqevbRkA1LZ8g/p8uBVJmW+Ab/F Ejzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="n+S/v56H"; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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. [85.214.62.61]) by mx.google.com with ESMTPS id e12-20020a056402190c00b005435b4f879bsi2220741edz.691.2023.11.12.17.49.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Nov 2023 17:49:57 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="n+S/v56H"; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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 D75C386FF4; Mon, 13 Nov 2023 02:49:42 +0100 (CET) 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="n+S/v56H"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 439708703A; Mon, 13 Nov 2023 02:49:38 +0100 (CET) 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, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-oi1-x22f.google.com (mail-oi1-x22f.google.com [IPv6:2607:f8b0:4864:20::22f]) (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 795BF86FF4 for ; Mon, 13 Nov 2023 02:49:35 +0100 (CET) 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-oi1-x22f.google.com with SMTP id 5614622812f47-3b2d9a9c824so473430b6e.0 for ; Sun, 12 Nov 2023 17:49:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699840174; x=1700444974; 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=d3LRUUtYLKxzsp79cf17RY7bCQAiYMEVXLHLxjAU95k=; b=n+S/v56H0+9/5ABnvmz+VIjU6qpu+xyYl9WcQMaUfwO5QHqWToQnyW7IBLXBj1CPEq RwtdJ/k5/aw0u2zzWKEQuwcWKX9ETGMUFD6No4fVzndwYbS6qpl7sznJM2McB26bgK9r 9TYCm/RsTteSR9rGPLnXGWdLcGh4IZK7FtbJONsf3RplOYWonMumnd0npeyL/0GtGb5R xh37KqxPyrpuY8dlY5n0OxEMCkpMxCL+jKLJLUZNOUyYPV/DceA5KolpfogH52LxU+pz tN+uSP7i7WVNMK5FJbGUKuj9MAccAFj3zbKftQuP+0VbmXjwId9nEx+KSu/CO5oFtbZO 7oGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699840174; x=1700444974; 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=d3LRUUtYLKxzsp79cf17RY7bCQAiYMEVXLHLxjAU95k=; b=JwqpNsSOMAUasd+hIfocmXLnfLmLF3o+h/0q+3WHZei7WHWx6gNFn4aIY5tXlE1K89 Pq0vdX8ejoLhrZisTIc5A5eGD4ygva3+DS29nzC+jOkW6oe7p8D7qDL5tgWOy85cK/cN G6nZyjIrMn3NsAEjvcUohCs0wxO2AeqLgroVjRLVPrrbigYBvKSW2E7Rm5NAQ864k/5g M37vwZd357QwAK3UAtpQD4CErzEwVK+VA7lOEHYJd9+LOZQM72Hdf8BhEzlUmA8mwdVt bZ6+om54BL3QxZqeBVCL4v0fF5TWNfgdlPBq8JLGjcwjbwObphb347WGboVa69uy8Iby RiJg== X-Gm-Message-State: AOJu0YwNXCdTMxRNVLSYFo30xa5vpVY1o6pACVF50cONnNDgi2HLPFIi fJExiEmnr8DTz1jZNIrSpK/SYZoaq5MPFX+Blpjbjg== X-Received: by 2002:a05:6870:2888:b0:1e9:e605:27a1 with SMTP id gy8-20020a056870288800b001e9e60527a1mr6242870oab.2.1699840174001; Sun, 12 Nov 2023 17:49:34 -0800 (PST) Received: from octopus.. ([2400:4050:c3e1:100:ba59:509b:48bc:9f1]) by smtp.gmail.com with ESMTPSA id s14-20020a65644e000000b005b92e60cf57sm2635549pgv.56.2023.11.12.17.49.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Nov 2023 17:49:33 -0800 (PST) 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 Subject: [PATCH v2 2/5] firmware: scmi: support protocols on sandbox only if enabled Date: Mon, 13 Nov 2023 10:49:08 +0900 Message-Id: <20231113014911.3308990-3-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231113014911.3308990-1-takahiro.akashi@linaro.org> References: <20231113014911.3308990-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 change will be useful when we manually test SCMI on sandbox by enabling/disabling a specific SCMI protocol. Signed-off-by: AKASHI Takahiro --- drivers/firmware/scmi/sandbox-scmi_agent.c | 27 ++++++- drivers/firmware/scmi/sandbox-scmi_devices.c | 78 ++++++++++++-------- 2 files changed, 72 insertions(+), 33 deletions(-) diff --git a/drivers/firmware/scmi/sandbox-scmi_agent.c b/drivers/firmware/scmi/sandbox-scmi_agent.c index d13180962662..1fc9a0f4ea7e 100644 --- a/drivers/firmware/scmi/sandbox-scmi_agent.c +++ b/drivers/firmware/scmi/sandbox-scmi_agent.c @@ -66,10 +66,18 @@ struct scmi_channel { }; static u8 protocols[] = { +#if IS_ENABLED(CONFIG_SCMI_POWER_DOMAIN) SCMI_PROTOCOL_ID_POWER_DOMAIN, +#endif +#if IS_ENABLED(CONFIG_CLK_SCMI) SCMI_PROTOCOL_ID_CLOCK, +#endif +#if IS_ENABLED(CONFIG_RESET_SCMI) SCMI_PROTOCOL_ID_RESET_DOMAIN, +#endif +#if IS_ENABLED(CONFIG_DM_REGULATOR_SCMI) SCMI_PROTOCOL_ID_VOLTAGE_DOMAIN, +#endif }; #define NUM_PROTOCOLS ARRAY_SIZE(protocols) @@ -1160,6 +1168,9 @@ static int sandbox_scmi_test_process_msg(struct udevice *dev, } break; case SCMI_PROTOCOL_ID_POWER_DOMAIN: + if (!IS_ENABLED(CONFIG_SCMI_POWER_DOMAIN)) + goto not_supported; + switch (msg->message_id) { case SCMI_PROTOCOL_VERSION: return sandbox_scmi_pwd_protocol_version(dev, msg); @@ -1180,6 +1191,9 @@ static int sandbox_scmi_test_process_msg(struct udevice *dev, } break; case SCMI_PROTOCOL_ID_CLOCK: + if (!IS_ENABLED(CONFIG_CLK_SCMI)) + goto not_supported; + switch (msg->message_id) { case SCMI_PROTOCOL_ATTRIBUTES: return sandbox_scmi_clock_protocol_attribs(dev, msg); @@ -1196,6 +1210,9 @@ static int sandbox_scmi_test_process_msg(struct udevice *dev, } break; case SCMI_PROTOCOL_ID_RESET_DOMAIN: + if (!IS_ENABLED(CONFIG_RESET_SCMI)) + goto not_supported; + switch (msg->message_id) { case SCMI_RESET_DOMAIN_ATTRIBUTES: return sandbox_scmi_rd_attribs(dev, msg); @@ -1206,6 +1223,9 @@ static int sandbox_scmi_test_process_msg(struct udevice *dev, } break; case SCMI_PROTOCOL_ID_VOLTAGE_DOMAIN: + if (!IS_ENABLED(CONFIG_DM_REGULATOR_SCMI)) + goto not_supported; + switch (msg->message_id) { case SCMI_VOLTAGE_DOMAIN_ATTRIBUTES: return sandbox_scmi_voltd_attribs(dev, msg); @@ -1224,8 +1244,7 @@ static int sandbox_scmi_test_process_msg(struct udevice *dev, case SCMI_PROTOCOL_ID_SYSTEM: case SCMI_PROTOCOL_ID_PERF: case SCMI_PROTOCOL_ID_SENSOR: - *(u32 *)msg->out_msg = SCMI_NOT_SUPPORTED; - return 0; + goto not_supported; default: break; } @@ -1239,6 +1258,10 @@ static int sandbox_scmi_test_process_msg(struct udevice *dev, /* Intentionnaly report unhandled IDs through the SCMI return code */ *(u32 *)msg->out_msg = SCMI_PROTOCOL_ERROR; return 0; + +not_supported: + *(u32 *)msg->out_msg = SCMI_NOT_SUPPORTED; + return 0; } static int sandbox_scmi_test_remove(struct udevice *dev) diff --git a/drivers/firmware/scmi/sandbox-scmi_devices.c b/drivers/firmware/scmi/sandbox-scmi_devices.c index facb5b06ffb5..0519cf889aa9 100644 --- a/drivers/firmware/scmi/sandbox-scmi_devices.c +++ b/drivers/firmware/scmi/sandbox-scmi_devices.c @@ -62,12 +62,13 @@ static int sandbox_scmi_devices_remove(struct udevice *dev) if (!devices) return 0; - for (n = 0; n < SCMI_TEST_DEVICES_RD_COUNT; n++) { - int ret2 = reset_free(devices->reset + n); + if (IS_ENABLED(CONFIG_RESET_SCMI)) + for (n = 0; n < SCMI_TEST_DEVICES_RD_COUNT; n++) { + int ret2 = reset_free(devices->reset + n); - if (ret2 && !ret) - ret = ret2; - } + if (ret2 && !ret) + ret = ret2; + } return ret; } @@ -89,39 +90,53 @@ static int sandbox_scmi_devices_probe(struct udevice *dev) .regul_count = SCMI_TEST_DEVICES_VOLTD_COUNT, }; - ret = power_domain_get_by_index(dev, priv->devices.pwdom, 0); - if (ret) { - dev_err(dev, "%s: Failed on power domain\n", __func__); - return ret; - } - - for (n = 0; n < SCMI_TEST_DEVICES_CLK_COUNT; n++) { - ret = clk_get_by_index(dev, n, priv->devices.clk + n); + if (IS_ENABLED(CONFIG_SCMI_POWER_DOMAIN)) { + ret = power_domain_get_by_index(dev, priv->devices.pwdom, 0); if (ret) { - dev_err(dev, "%s: Failed on clk %zu\n", __func__, n); + dev_err(dev, "%s: Failed on power domain\n", __func__); return ret; } } - for (n = 0; n < SCMI_TEST_DEVICES_RD_COUNT; n++) { - ret = reset_get_by_index(dev, n, priv->devices.reset + n); - if (ret) { - dev_err(dev, "%s: Failed on reset %zu\n", __func__, n); - goto err_reset; + if (IS_ENABLED(CONFIG_CLK_SCMI)) { + for (n = 0; n < SCMI_TEST_DEVICES_CLK_COUNT; n++) { + ret = clk_get_by_index(dev, n, priv->devices.clk + n); + if (ret) { + dev_err(dev, "%s: Failed on clk %zu\n", + __func__, n); + return ret; + } } } - for (n = 0; n < SCMI_TEST_DEVICES_VOLTD_COUNT; n++) { - char name[32]; - - ret = snprintf(name, sizeof(name), "regul%zu-supply", n); - assert(ret >= 0 && ret < sizeof(name)); + if (IS_ENABLED(CONFIG_RESET_SCMI)) { + for (n = 0; n < SCMI_TEST_DEVICES_RD_COUNT; n++) { + ret = reset_get_by_index(dev, n, + priv->devices.reset + n); + if (ret) { + dev_err(dev, "%s: Failed on reset %zu\n", + __func__, n); + goto err_reset; + } + } + } - ret = device_get_supply_regulator(dev, name, - priv->devices.regul + n); - if (ret) { - dev_err(dev, "%s: Failed on voltd %zu\n", __func__, n); - goto err_regul; + if (IS_ENABLED(CONFIG_DM_REGULATOR_SCMI)) { + for (n = 0; n < SCMI_TEST_DEVICES_VOLTD_COUNT; n++) { + char name[32]; + + ret = snprintf(name, sizeof(name), "regul%zu-supply", + n); + assert(ret >= 0 && ret < sizeof(name)); + + ret = device_get_supply_regulator(dev, name, + priv->devices.regul + + n); + if (ret) { + dev_err(dev, "%s: Failed on voltd %zu\n", + __func__, n); + goto err_regul; + } } } @@ -130,8 +145,9 @@ static int sandbox_scmi_devices_probe(struct udevice *dev) err_regul: n = SCMI_TEST_DEVICES_RD_COUNT; err_reset: - for (; n > 0; n--) - reset_free(priv->devices.reset + n - 1); + if (IS_ENABLED(CONFIG_RESET_SCMI)) + for (; n > 0; n--) + reset_free(priv->devices.reset + n - 1); return ret; } From patchwork Mon Nov 13 01:49:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 743449 Delivered-To: patch@linaro.org Received: by 2002:a5d:67cf:0:b0:32d:baff:b0ca with SMTP id n15csp1411505wrw; Sun, 12 Nov 2023 17:50:09 -0800 (PST) X-Google-Smtp-Source: AGHT+IFxsqhfszfq7SNMvl/wikt1ZBikg3Ny2b+R5/DtaFvZfPYE1CHRsVHGHyvikzLJbGkb71vh X-Received: by 2002:a17:906:4ed8:b0:9e6:cd68:5e57 with SMTP id i24-20020a1709064ed800b009e6cd685e57mr4269265ejv.2.1699840208960; Sun, 12 Nov 2023 17:50:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699840208; cv=none; d=google.com; s=arc-20160816; b=afM4Btwby2TUOUiz8AcY+0wUZWtCDsAPlVtMFbbJYs2aaUhUkrHGGS28jFerh5lrCe lId484e6Ai0UgUyiCGRIYmGYQdrhC1NnWSG78xq+gw3NqzfkVqf/PTq6ugyjlt6hzOiL pPNnhcS0zOwG+X0A7cEXoaC/l3JBpcgiQs8kRJwCgvWpMpadOilIkEp+9fvJrFyebBnP PwDI4pSmtz946XWaWvuUstxLJyOVHeREOUkq3r9U+MY1Ff28WNOds+B1/19fApbKvOn+ 8/jRBK8M7J/e5pgYgvywU5GeOHPSHz06gOwsapKaYrjixqlZmzMsBP0ZHhOgby/cD1Vo GGmw== 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=oONLZU+k1c7pjdGca1S1UQvtxT+y3sBxYGld3kTp6Js=; fh=QZWY3XY+sB907ugYHcr63Nh2/mcdieyH+ES8hS8oMbI=; b=vZ4xY6L5nTfpqGc2bO4qfwrYj419rqhfO3OmwQbhVtE/mnxP7/nDTUveqoLSSqsqE5 6s3wBYpxJycGpng3Tw+2+Zuy0QWlLgMNQxwetgF49Z+64gd2Qi+vkc/fft2LlYK/p7vb zuDtp+xYZQLPoRk1+MIUNhryCF9+dDhB8bNooRSx/9LCyM12tCltxE+ZZBKd3Dhnpwup zbn5Ws29gaqd7LCzJWB5yZ39MCi7AoPgWhN8ZhuKoGGHTLJ0HNAvNVt4YIeVkq9jgoZB SdRBXsnLKUt/A2pFe+X+wVeeC4Yxb5TQLdRFriS1Q9JRY0QwPJ32rFpIty5+SQo4vxiW Pg7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HzRiqlLh; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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. [85.214.62.61]) by mx.google.com with ESMTPS id mb18-20020a170906eb1200b00991f9e2a81asi2233051ejb.238.2023.11.12.17.50.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Nov 2023 17:50:08 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HzRiqlLh; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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 6BE738709A; Mon, 13 Nov 2023 02:49:44 +0100 (CET) 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="HzRiqlLh"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B172386FF4; Mon, 13 Nov 2023 02:49:42 +0100 (CET) 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, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-oi1-x22a.google.com (mail-oi1-x22a.google.com [IPv6:2607:f8b0:4864:20::22a]) (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 B333886F7E for ; Mon, 13 Nov 2023 02:49:37 +0100 (CET) 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-oi1-x22a.google.com with SMTP id 5614622812f47-3b2e08526b9so373662b6e.0 for ; Sun, 12 Nov 2023 17:49:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699840176; x=1700444976; 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=oONLZU+k1c7pjdGca1S1UQvtxT+y3sBxYGld3kTp6Js=; b=HzRiqlLhg7+7bUSggOK02PeEYyAcVLFsxfc/+VvffBvANoLlsnPEX4G1JNZD4ovLUJ v5GqDjten5zCvS1D0LmItmCh3yN3PpRyHdk46uqVhq4kpHPHEto/srdRXwiVT/1gd1oo ovvKjmGWZH6mUFrRaZLkIgLFEFGY4KyrobwSNJ9qUMqUrQUe5HNZdna/SwSslmMqgl25 tpoYtXx6dKQFrOp8gNfJ6ZVWeUSdOiEIQMXOL4GdJLmXF1ycwuQ8trCIonvm/t6FBBrj V9PC4SwCd+V+nhBUXlDtRjI83ESaBggIhLC/xMa6xOxJfOyCE9GuGzjaXYMkdMjoYX+q DagQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699840176; x=1700444976; 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=oONLZU+k1c7pjdGca1S1UQvtxT+y3sBxYGld3kTp6Js=; b=GlIf/27uJJ57VEZhgPiLh4B/2DgNIZqjqRxe/dYB1o8A7rYUuNLmw9Xn3RcJiaumtQ XDxOF6S6w49cj7RNad9fTsy0KSQTljYwNI6LgBbxUdAY3jX9B+8hUGqYLwJPsgle/saH FUYxT9kPNHlV/7VZxn74l+z68ZA1A219N3T0FPiVYhnAFa5axLPswHiqJR1Waz9LMHyW 9+1kZfdCsy1Za7euwHysJtuohX6Ap/Evdk8UoQgNTKiE0MNnoH2RJB9v3v/u/Hfg96S+ 4IGAuEkToBK3PCFXvbbGiMBk97O36K3AoaVjRDM+6G70hMGQTvgILHMOSOuqcMVDyMOo AfbQ== X-Gm-Message-State: AOJu0Yz2uReX6asXOTykNB4BGrjN0csf0FET/MDmvDMPnLvD8Nkg0c3E grvHNafW5i//+539NwTLPgX0HA== X-Received: by 2002:a9d:6e91:0:b0:6cd:74d:1f34 with SMTP id a17-20020a9d6e91000000b006cd074d1f34mr6409871otr.1.1699840176269; Sun, 12 Nov 2023 17:49:36 -0800 (PST) Received: from octopus.. ([2400:4050:c3e1:100:ba59:509b:48bc:9f1]) by smtp.gmail.com with ESMTPSA id s14-20020a65644e000000b005b92e60cf57sm2635549pgv.56.2023.11.12.17.49.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Nov 2023 17:49:35 -0800 (PST) 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 v2 3/5] cmd: add scmi command for SCMI firmware Date: Mon, 13 Nov 2023 10:49:09 +0900 Message-Id: <20231113014911.3308990-4-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231113014911.3308990-1-takahiro.akashi@linaro.org> References: <20231113014911.3308990-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 command, "scmi", may provide a command line interface to various SCMI protocols. It supports at least initially SCMI base protocol and is intended mainly for debug purpose. Signed-off-by: AKASHI Takahiro Reviewed-by: Simon Glass Reviewed-by: Etienne Carriere --- v8 (actually v2 as SCMI cmd) * localize global variables to avoid pytest errors v3 * describe that arguments are in hex at a help message * modify the code for dynamically allocated agent names v2 * remove sub command category, 'scmi base', for simplicity --- cmd/Kconfig | 9 ++ cmd/Makefile | 1 + cmd/scmi.c | 384 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 394 insertions(+) create mode 100644 cmd/scmi.c diff --git a/cmd/Kconfig b/cmd/Kconfig index df6d71c103f9..ca9f742dcf78 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -2559,6 +2559,15 @@ config CMD_CROS_EC a number of sub-commands for performing EC tasks such as updating its flash, accessing a small saved context area and talking to the I2C bus behind the EC (if there is one). + +config CMD_SCMI + bool "Enable scmi command" + depends on SCMI_FIRMWARE + default n + help + This command provides user interfaces to several SCMI (System + Control and Management Interface) protocols available on Arm + platforms to manage system resources. endmenu menu "Filesystem commands" diff --git a/cmd/Makefile b/cmd/Makefile index 9a6790cc1708..320f0b5266eb 100644 --- a/cmd/Makefile +++ b/cmd/Makefile @@ -159,6 +159,7 @@ obj-$(CONFIG_CMD_SATA) += sata.o obj-$(CONFIG_CMD_NVME) += nvme.o obj-$(CONFIG_SANDBOX) += sb.o obj-$(CONFIG_CMD_SF) += sf.o +obj-$(CONFIG_CMD_SCMI) += scmi.o obj-$(CONFIG_CMD_SCSI) += scsi.o disk.o obj-$(CONFIG_CMD_SHA1SUM) += sha1sum.o obj-$(CONFIG_CMD_SEAMA) += seama.o diff --git a/cmd/scmi.c b/cmd/scmi.c new file mode 100644 index 000000000000..664062c4eff5 --- /dev/null +++ b/cmd/scmi.c @@ -0,0 +1,384 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * SCMI (System Control and Management Interface) utility command + * + * Copyright (c) 2023 Linaro Limited + * Author: AKASHI Takahiro + */ + +#include +#include +#include +#include +#include +#include +#include +#include /* uclass_get_device */ +#include +#include + +struct { + enum scmi_std_protocol id; + const char *name; +} protocol_name[] = { + {SCMI_PROTOCOL_ID_BASE, "Base"}, + {SCMI_PROTOCOL_ID_POWER_DOMAIN, "Power domain management"}, + {SCMI_PROTOCOL_ID_SYSTEM, "System power management"}, + {SCMI_PROTOCOL_ID_PERF, "Performance domain management"}, + {SCMI_PROTOCOL_ID_CLOCK, "Clock management"}, + {SCMI_PROTOCOL_ID_SENSOR, "Sensor management"}, + {SCMI_PROTOCOL_ID_RESET_DOMAIN, "Reset domain management"}, + {SCMI_PROTOCOL_ID_VOLTAGE_DOMAIN, "Voltage domain management"}, +}; + +/** + * get_agent() - get SCMI agent device + * + * Return: Pointer to SCMI agent device on success, NULL on failure + */ +static struct udevice *get_agent(void) +{ + struct udevice *agent; + + if (uclass_get_device(UCLASS_SCMI_AGENT, 0, &agent)) { + printf("Cannot find any SCMI agent\n"); + return NULL; + } + + return agent; +} + +/** + * get_base_proto() - get SCMI base protocol device + * @agent: SCMI agent device + * + * Return: Pointer to SCMI base protocol device on success, + * NULL on failure + */ +static struct udevice *get_base_proto(struct udevice *agent) +{ + struct udevice *base_proto; + + if (!agent) { + agent = get_agent(); + if (!agent) + return NULL; + } + + base_proto = scmi_get_protocol(agent, SCMI_PROTOCOL_ID_BASE); + if (!base_proto) { + printf("SCMI base protocol not found\n"); + return NULL; + } + + return base_proto; +} + +/** + * get_proto_name() - get the name of SCMI protocol + * + * @id: SCMI Protocol ID + * + * Get the printable name of the protocol, @id + * + * Return: Name string on success, NULL on failure + */ +static const char *get_proto_name(enum scmi_std_protocol id) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(protocol_name); i++) + if (id == protocol_name[i].id) + return protocol_name[i].name; + + return NULL; +} + +/** + * do_scmi_info() - get the information of SCMI services + * + * @cmdtp: Command table + * @flag: Command flag + * @argc: Number of arguments + * @argv: Argument array + * + * Get the information of SCMI services using various interfaces + * provided by the Base protocol. + * + * Return: CMD_RET_SUCCESS on success, CMD_RET_RET_FAILURE on failure + */ +static int do_scmi_info(struct cmd_tbl *cmdtp, int flag, int argc, + char * const argv[]) +{ + struct udevice *agent, *base_proto; + u32 agent_id, num_protocols; + u8 *agent_name, *protocols; + int i, ret; + + if (argc != 1) + return CMD_RET_USAGE; + + agent = get_agent(); + if (!agent) + return CMD_RET_FAILURE; + base_proto = get_base_proto(agent); + if (!base_proto) + return CMD_RET_FAILURE; + + printf("SCMI device: %s\n", agent->name); + printf(" protocol version: 0x%x\n", scmi_version(agent)); + printf(" # of agents: %d\n", scmi_num_agents(agent)); + for (i = 0; i < scmi_num_agents(agent); i++) { + ret = scmi_base_discover_agent(base_proto, i, &agent_id, + &agent_name); + if (ret) { + if (ret != -EOPNOTSUPP) + printf("base_discover_agent() failed for id: %d (%d)\n", + i, ret); + break; + } + printf(" %c%2d: %s\n", i == scmi_agent_id(agent) ? '>' : ' ', + i, agent_name); + free(agent_name); + } + printf(" # of protocols: %d\n", scmi_num_protocols(agent)); + num_protocols = scmi_num_protocols(agent); + protocols = scmi_protocols(agent); + if (protocols) + for (i = 0; i < num_protocols; i++) + printf(" %s\n", get_proto_name(protocols[i])); + printf(" vendor: %s\n", scmi_vendor(agent)); + printf(" sub vendor: %s\n", scmi_sub_vendor(agent)); + printf(" impl version: 0x%x\n", scmi_impl_version(agent)); + + return CMD_RET_SUCCESS; +} + +/** + * do_scmi_set_dev() - set access permission to device + * + * @cmdtp: Command table + * @flag: Command flag + * @argc: Number of arguments + * @argv: Argument array + * + * Set access permission to device with SCMI_BASE_SET_DEVICE_PERMISSIONS + * + * Return: CMD_RET_SUCCESS on success, CMD_RET_RET_FAILURE on failure + */ +static int do_scmi_set_dev(struct cmd_tbl *cmdtp, int flag, int argc, + char * const argv[]) +{ + u32 agent_id, device_id, flags, attributes; + char *end; + struct udevice *base_proto; + int ret; + + if (argc != 4) + return CMD_RET_USAGE; + + agent_id = simple_strtoul(argv[1], &end, 16); + if (*end != '\0') + return CMD_RET_USAGE; + + device_id = simple_strtoul(argv[2], &end, 16); + if (*end != '\0') + return CMD_RET_USAGE; + + flags = simple_strtoul(argv[3], &end, 16); + if (*end != '\0') + return CMD_RET_USAGE; + + base_proto = get_base_proto(NULL); + if (!base_proto) + return CMD_RET_FAILURE; + + ret = scmi_base_protocol_message_attrs(base_proto, + SCMI_BASE_SET_DEVICE_PERMISSIONS, + &attributes); + if (ret) { + printf("This operation is not supported\n"); + return CMD_RET_FAILURE; + } + + ret = scmi_base_set_device_permissions(base_proto, agent_id, + device_id, flags); + if (ret) { + printf("%s access to device:%u failed (%d)\n", + flags ? "Allowing" : "Denying", device_id, ret); + return CMD_RET_FAILURE; + } + + return CMD_RET_SUCCESS; +} + +/** + * do_scmi_set_proto() - set protocol permission to device + * + * @cmdtp: Command table + * @flag: Command flag + * @argc: Number of arguments + * @argv: Argument array + * + * Set protocol permission to device with SCMI_BASE_SET_PROTOCOL_PERMISSIONS + * + * Return: CMD_RET_SUCCESS on success, CMD_RET_RET_FAILURE on failure + */ +static int do_scmi_set_proto(struct cmd_tbl *cmdtp, int flag, int argc, + char * const argv[]) +{ + u32 agent_id, device_id, protocol_id, flags, attributes; + char *end; + struct udevice *base_proto; + int ret; + + if (argc != 5) + return CMD_RET_USAGE; + + agent_id = simple_strtoul(argv[1], &end, 16); + if (*end != '\0') + return CMD_RET_USAGE; + + device_id = simple_strtoul(argv[2], &end, 16); + if (*end != '\0') + return CMD_RET_USAGE; + + protocol_id = simple_strtoul(argv[3], &end, 16); + if (*end != '\0') + return CMD_RET_USAGE; + + flags = simple_strtoul(argv[4], &end, 16); + if (*end != '\0') + return CMD_RET_USAGE; + + base_proto = get_base_proto(NULL); + if (!base_proto) + return CMD_RET_FAILURE; + + ret = scmi_base_protocol_message_attrs(base_proto, + SCMI_BASE_SET_PROTOCOL_PERMISSIONS, + &attributes); + if (ret) { + printf("This operation is not supported\n"); + return CMD_RET_FAILURE; + } + + ret = scmi_base_set_protocol_permissions(base_proto, agent_id, + device_id, protocol_id, + flags); + if (ret) { + printf("%s access to protocol:0x%x on device:%u failed (%d)\n", + flags ? "Allowing" : "Denying", protocol_id, device_id, + ret); + return CMD_RET_FAILURE; + } + + return CMD_RET_SUCCESS; +} + +/** + * do_scmi_reset() - reset platform resource settings + * + * @cmdtp: Command table + * @flag: Command flag + * @argc: Number of arguments + * @argv: Argument array + * + * Reset platform resource settings with BASE_RESET_AGENT_CONFIGURATION + * + * Return: CMD_RET_SUCCESS on success, CMD_RET_RET_FAILURE on failure + */ +static int do_scmi_reset(struct cmd_tbl *cmdtp, int flag, int argc, + char * const argv[]) +{ + u32 agent_id, flags, attributes; + char *end; + struct udevice *base_proto; + int ret; + + if (argc != 3) + return CMD_RET_USAGE; + + agent_id = simple_strtoul(argv[1], &end, 16); + if (*end != '\0') + return CMD_RET_USAGE; + + flags = simple_strtoul(argv[2], &end, 16); + if (*end != '\0') + return CMD_RET_USAGE; + + base_proto = get_base_proto(NULL); + if (!base_proto) + return CMD_RET_FAILURE; + + ret = scmi_base_protocol_message_attrs(base_proto, + SCMI_BASE_RESET_AGENT_CONFIGURATION, + &attributes); + if (ret) { + printf("Reset is not supported\n"); + return CMD_RET_FAILURE; + } + + ret = scmi_base_reset_agent_configuration(base_proto, agent_id, flags); + if (ret) { + printf("Reset failed (%d)\n", ret); + return CMD_RET_FAILURE; + } + + return CMD_RET_SUCCESS; +} + +static struct cmd_tbl cmd_scmi_sub[] = { + U_BOOT_CMD_MKENT(info, CONFIG_SYS_MAXARGS, 1, + do_scmi_info, "", ""), + U_BOOT_CMD_MKENT(perm_dev, CONFIG_SYS_MAXARGS, 1, + do_scmi_set_dev, "", ""), + U_BOOT_CMD_MKENT(perm_proto, CONFIG_SYS_MAXARGS, 1, + do_scmi_set_proto, "", ""), + U_BOOT_CMD_MKENT(reset, CONFIG_SYS_MAXARGS, 1, + do_scmi_reset, "", ""), +}; + +/** + * do_scmi() - SCMI utility + * + * @cmdtp: Command table + * @flag: Command flag + * @argc: Number of arguments + * @argv: Argument array + * + * Provide user interfaces to SCMI protocols. + * + * Return: CMD_RET_SUCCESS on success, + * CMD_RET_USAGE or CMD_RET_RET_FAILURE on failure + */ +static int do_scmi(struct cmd_tbl *cmdtp, int flag, + int argc, char *const argv[]) +{ + struct cmd_tbl *cp; + + if (argc < 2) + return CMD_RET_USAGE; + + argc--; argv++; + + cp = find_cmd_tbl(argv[0], cmd_scmi_sub, ARRAY_SIZE(cmd_scmi_sub)); + if (!cp) + return CMD_RET_USAGE; + + return cp->cmd(cmdtp, flag, argc, argv); +} + +static char scmi_help_text[] = + " - SCMI utility\n" + " info - get the info of SCMI services\n" + " perm_dev \n" + " - set access permission to device\n" + " perm_proto \n" + " - set protocol permission to device\n" + " reset \n" + " - reset platform resource settings\n" + ""; + +U_BOOT_CMD(scmi, CONFIG_SYS_MAXARGS, 0, do_scmi, "SCMI utility", + scmi_help_text); From patchwork Mon Nov 13 01:49:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 743450 Delivered-To: patch@linaro.org Received: by 2002:a5d:67cf:0:b0:32d:baff:b0ca with SMTP id n15csp1411575wrw; Sun, 12 Nov 2023 17:50:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IEonjpzQatxH0vO0TcmQ08bDkULUMTxMN1q2uxfoLF2SWwdVEV+bhTkwzJWfElu6o+zClKT X-Received: by 2002:a17:907:9870:b0:9d5:9065:90aa with SMTP id ko16-20020a170907987000b009d5906590aamr3612389ejc.76.1699840221368; Sun, 12 Nov 2023 17:50:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699840221; cv=none; d=google.com; s=arc-20160816; b=x0iPO5VIC0K2zRjBAplqJkUFDi5uEyIY8yDr9rswLf4aJhavsan1/GpTORseLR1sNO P8gIxqRah4/f7Bn4NoCVX4agObcgGrcNZhUIA/2Mj1zXASTj5zvxKrl8nY9x1/EZmOdm OEKQyLmW1KvNFrkRbovde9rkUCjW97f1fwFQVlLwNimzNbX4qNuFUuV8zCbd7SKz4bDk EPpIJ3QO4jvLbswD38B+7aapt+PFva5hHVeLbeYIz734WzxKG6gLjLnTo715qvTB6Cmd 3N0EhWhP+bgyzavAwBGj/qGgA722/sXnBRu7N2/2gxDNKYLbewBm9hEuwykYnspxTkO8 cBKw== 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=t9EWYzhzvRnohj45QdHocxpuPdq+TXjcOYtY+RMWKqw=; fh=QZWY3XY+sB907ugYHcr63Nh2/mcdieyH+ES8hS8oMbI=; b=MaB17BdI9BJTYSne53SSNxfg3es+gqwOwaDUJ1HLovI1B04YYEke0ENapw8VTALeFM RDyyrL+DYGq2op7cM3VooQUEMqB68QvsQsDA5MtrU7dGfsl6YNUbKn3DM7D3KqEf3eOY 1VJReUKlHfsfssjQCiR4Vmo3HnJ0pvwHdUe+51lw95QMOCEvdZrkrpyDam32w2eoGht3 eWD4YvYjyaUJEPCzWtvk2UZmi+cUUc0AF8rgssMEMCjTXIsOc81iIF7w/r/1p3UTZxvf YPrWfEvpXkiNltPZKq7sI9sOdvR/zi8EsGGtQuKcgR4hOH3imK17fqMuMVc3BJur+qo6 eHaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="rO/3wm5W"; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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. [85.214.62.61]) by mx.google.com with ESMTPS id qa37-20020a17090786a500b00992ac0466e2si2234538ejc.653.2023.11.12.17.50.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Nov 2023 17:50:21 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="rO/3wm5W"; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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 F39648703A; Mon, 13 Nov 2023 02:49:44 +0100 (CET) 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="rO/3wm5W"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 33B2086F7E; Mon, 13 Nov 2023 02:49:43 +0100 (CET) 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, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-oi1-x232.google.com (mail-oi1-x232.google.com [IPv6:2607:f8b0:4864:20::232]) (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 D2DE387084 for ; Mon, 13 Nov 2023 02:49:39 +0100 (CET) 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-oi1-x232.google.com with SMTP id 5614622812f47-3b2d9a9c824so473448b6e.0 for ; Sun, 12 Nov 2023 17:49:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699840178; x=1700444978; 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=t9EWYzhzvRnohj45QdHocxpuPdq+TXjcOYtY+RMWKqw=; b=rO/3wm5WfN8kVzT/tAlmiLzV+aUtA92SMbz/L0wOLwho2rld/bdjzsfmZsAszZfYFZ /FO1mZTDQX/fAiHGM6VtkhY/aBqh9veeZtorz/vrpJ89fBstxvCKfCBKWNw2dO0H54mj gmFbC+bHREAHRK7M/OpOoGo0QS077dyjxLzOCggf6UF+lZXuu6uvwC8TQCSuc+qJOfh4 gzi1oNZNJj8kZuEwt/HTv3Se1eFfgxauIIrz/g2I0/qzHfWPOsQENqI7ZGuCKmLRxnmq KD2VtaeQPPgjsT9Kzh6l9mLsIahwBH+aqM8/77gT0naL1vy9y6xl3RjwDBWh5SeFZ9xk TD3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699840178; x=1700444978; 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=t9EWYzhzvRnohj45QdHocxpuPdq+TXjcOYtY+RMWKqw=; b=al3j09M2lhz7BJvz/OkXCp+x9fHE1zIWZ+Qr8Jz7Oci1G287JYP4Og6S4ydOoPPMvm TOWfVWDLa51ZabKlqLX7jhw/D1IYoofix6HGbQM3UvUJbFrKKcC/r2UEMAeLUidSiOTr ggZpIrn3cBfgKnOYR1FrZeqc3bPOAsb1cD8t+shVjT5+Bl5Di+b52ObNfxUQMyHfUKFo UqimxHSGZuMuAOZSZ5CjBRgTO6YOaH7nqmr6NiiV15AEgIWJNxklYjxgxV0CDscFrcTs Vr3ghIvOr58AVZEExJKK1z6SRXcFPzRIbM2kk5lBgh560SeK4RbY2eRslC+DZsaqz2gi Luww== X-Gm-Message-State: AOJu0YzdYDfFBQjMgeHWfpE0UWO2Q/xVLSRJjiGVsPaJL5jgog4fim0t Be839kl53xzMmsUxfKgkbGcQ74ZXxqJPWvTT9lbu+w== X-Received: by 2002:a05:6808:1819:b0:3b5:65c2:fef4 with SMTP id bh25-20020a056808181900b003b565c2fef4mr5485828oib.5.1699840178453; Sun, 12 Nov 2023 17:49:38 -0800 (PST) Received: from octopus.. ([2400:4050:c3e1:100:ba59:509b:48bc:9f1]) by smtp.gmail.com with ESMTPSA id s14-20020a65644e000000b005b92e60cf57sm2635549pgv.56.2023.11.12.17.49.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Nov 2023 17:49:38 -0800 (PST) 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 v2 4/5] doc: cmd: add documentation for scmi Date: Mon, 13 Nov 2023 10:49:10 +0900 Message-Id: <20231113014911.3308990-5-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231113014911.3308990-1-takahiro.akashi@linaro.org> References: <20231113014911.3308990-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 is a help text for scmi command. Signed-off-by: AKASHI Takahiro Reviewed-by: Simon Glass Reviewed-by: Etienne Carriere --- v6 * add the manual to doc/usage/index.rst v4 * s/tranport/transport/ v2 * add more descriptions about SCMI --- doc/usage/cmd/scmi.rst | 126 +++++++++++++++++++++++++++++++++++++++++ doc/usage/index.rst | 1 + 2 files changed, 127 insertions(+) create mode 100644 doc/usage/cmd/scmi.rst diff --git a/doc/usage/cmd/scmi.rst b/doc/usage/cmd/scmi.rst new file mode 100644 index 000000000000..9ea7e0e41dad --- /dev/null +++ b/doc/usage/cmd/scmi.rst @@ -0,0 +1,126 @@ +.. SPDX-License-Identifier: GPL-2.0+: + +scmi command +============ + +Synopsis +-------- + +:: + + scmi info + scmi perm_dev + scmi perm_proto + scmi reset + +Description +----------- + +Arm System Control and Management Interface (SCMI hereafter) is a set of +standardised interfaces to manage system resources, like clocks, power +domains, pin controls, reset and so on, in a system-wide manner. + +An entity which provides those services is called a SCMI firmware (or +SCMI server if you like) may be placed/implemented by EL3 software or +by a dedicated system control processor (SCP) or else. + +A user of SCMI interfaces, including U-Boot, is called a SCMI agent and +may issues commands, which are defined in each protocol for specific system +resources, to SCMI server via a communication channel, called a transport. +Those interfaces are independent from the server's implementation thanks to +a transport layer. + +For more details, see the `SCMI specification`_. + +While most of system resources managed under SCMI protocols are implemented +and handled as standard U-Boot devices, for example clk_scmi, scmi command +provides additional management functionality against SCMI server. + +scmi info +~~~~~~~~~ + Show base information about SCMI server and supported protocols + +scmi perm_dev +~~~~~~~~~~~~~ + Allow or deny access permission to the device + +scmi perm_proto +~~~~~~~~~~~~~~~ + Allow or deny access to the protocol on the device + +scmi reset +~~~~~~~~~~ + Reset the already-configured permissions against the device + +Parameters are used as follows: + + + SCMI Agent ID, hex value + + + SCMI Device ID, hex value + + Please note that what a device means is not defined + in the specification. + + + SCMI Protocol ID, hex value + + It must not be 0x10 (base protocol) + + + Flags to control the action, hex value + + 0 to deny, 1 to allow. The other values are reserved and allowed + values may depend on the implemented version of SCMI server in + the future. See SCMI specification for more details. + +Example +------- + +Obtain basic information about SCMI server: + +:: + + => scmi info + SCMI device: scmi + protocol version: 0x20000 + # of agents: 3 + 0: platform + > 1: OSPM + 2: PSCI + # of protocols: 4 + Power domain management + Performance domain management + Clock management + Sensor management + vendor: Linaro + sub vendor: PMWG + impl version: 0x20b0000 + +Ask for access permission to device#0: + +:: + + => scmi perm_dev 1 0 1 + +Reset configurations with all access permission settings retained: + +:: + + => scmi reset 1 0 + +Configuration +------------- + +The scmi command is only available if CONFIG_CMD_SCMI=y. +Default n because this command is mainly for debug purpose. + +Return value +------------ + +The return value ($?) is set to 0 if the operation succeeded, +1 if the operation failed or -1 if the operation failed due to +a syntax error. + +.. _`SCMI specification`: https://developer.arm.com/documentation/den0056/e/?lang=en diff --git a/doc/usage/index.rst b/doc/usage/index.rst index d8e23fcacffb..1a626c03c237 100644 --- a/doc/usage/index.rst +++ b/doc/usage/index.rst @@ -94,6 +94,7 @@ Shell commands cmd/rng cmd/saves cmd/sbi + cmd/scmi cmd/scp03 cmd/seama cmd/setexpr From patchwork Mon Nov 13 01:49:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 743451 Delivered-To: patch@linaro.org Received: by 2002:a5d:67cf:0:b0:32d:baff:b0ca with SMTP id n15csp1411618wrw; Sun, 12 Nov 2023 17:50:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IGdlE3+m1c31dy+8hjwEJgYVhArwG2rRxTsJSawbtxUKWFDTt3hFDTSL/hoPEmaWCQEoGiR X-Received: by 2002:a17:906:55d4:b0:9c7:4dab:20ea with SMTP id z20-20020a17090655d400b009c74dab20eamr3479212ejp.67.1699840230062; Sun, 12 Nov 2023 17:50:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699840230; cv=none; d=google.com; s=arc-20160816; b=YE0T62ZQO8MD8vzRz3sWBS3U/9ogUdBVxapLustAaUIhsl14IsIyWEt2z71MhOXDKG OZEHC3XM3Tib0XIDg1b7oRlHk9S7EgmVhr7LnA7zgFxU62D0ffiUBaNu0VCR+mCOfDeX fta5jbsRdsJ/tWaLOcUq4v+F3OZXRFN5fhzWLT2pkQRi3bQfbkAVXPInnAeNYeNvM4yo /MRXtE0xq8L6fVbzvjKU7a1R8Fdf5l/dA6NEzWlhLwdlBuMQ5PUbSdBISe+Oc6b8WxMn VFTJPRMDf2JR2JY8t4CXP7FILgfbG6a/NMIC4s94ULj/S0wHD1b/ZpQIzRd4mC2ChPPT CbrQ== 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=VVcsVYY843GHoeAsm03ODTeqNlct1/wIMe3XRv6dB1Y=; fh=QZWY3XY+sB907ugYHcr63Nh2/mcdieyH+ES8hS8oMbI=; b=eVe4wYlgzBFUSp9HhOrBklu/uZNlB7IVURpl3fwWfInfre8H4zjz2+nRs4MmTs0yJ3 ZG7A1IhSahDoFSFzpio0LwUIceb/8KUWvOk1sYHBK5F6wI0Ku4O9IfHGbbbWmgRkWuOB akm5whFsVrhiSv9wIH2YwrUWkOEFVn1RbwbelOQQWSiKpP12fmMDXfy4+/7jBcXB68xb 6ebcxjb6L7dUIkyFUUO1V+pOf+f5xhddUQMSOBeIehPCbQDlV4HJv++0gXbgc9z1up9W cxcDYQKA+T2UuqE5JE0cEGYAUwYDVu4OiOsqIOp1vbxyEL5XpujV/4VKEQDok8eUE6Cv I5jg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=U2YzNoZz; 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 qb20-20020a1709077e9400b009c3d72487c8si2242274ejc.504.2023.11.12.17.50.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Nov 2023 17:50:30 -0800 (PST) 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=U2YzNoZz; 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 73F7A87076; Mon, 13 Nov 2023 02:49:46 +0100 (CET) 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="U2YzNoZz"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 82F99870BC; Mon, 13 Nov 2023 02:49:45 +0100 (CET) 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, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) (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 4183D87098 for ; Mon, 13 Nov 2023 02:49:42 +0100 (CET) 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-x431.google.com with SMTP id d2e1a72fcca58-6bcbfecf314so812299b3a.1 for ; Sun, 12 Nov 2023 17:49:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699840180; x=1700444980; 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=VVcsVYY843GHoeAsm03ODTeqNlct1/wIMe3XRv6dB1Y=; b=U2YzNoZzzBGx/Y18oCDmjpqX1LE0L0JMy9dpKu26cMSwISjv7Nj1CtI4evc3D58aaY pbl7DWunSZp3vJCFo9W0AXcfQ/+4DSiav5fo5Ad81dfS4dsWxZkexiA6C4HBwAWW0PCm g2q3/souapRERM8J6O06gYnNE6Z1LR6CHppZjVmhkkZfd2gE6ufW/pXhtP0icODP+z0D 7rnXNvozmPuWCT0EyNhWUinmYx943lDfnpmGONG2u8Qngnuy3x9pKB0gI/EZ8Ww+w049 Fm/76I82fFX7NIwt8giKdPOpO9VrPm64q6pW2OAvHGVcjSbRB+xj4lr53V3nxdYZyixW TYRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699840180; x=1700444980; 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=VVcsVYY843GHoeAsm03ODTeqNlct1/wIMe3XRv6dB1Y=; b=Ret7+pKo4iZeAv3wIsLouPgZgp9kEMy7HPW//FUx1SRjiqyQOX1uvHxJYotZqlaNRi 2tc16IX2iEg9Ng3VO+eBXtc2WgZzN1UgLBk+ZmdTwLv/GYpQn095LTPbqo0fP5CLjnWb rS4BjDDeBk28FRxeRjL842q3UsJEGg8wXaIG2DuoWUruK4G91sxuEpTzXBMdQIX7yRmF ogNYg/IxFRQUIuqr8jmEwGjEp41J3d96i6fWF5A++smNqciZUzkpM6HkHKq+qRRE/jcV KlPJXsUIRGntpy+FZWXocYK4vgFyWByycQg0u71DNmvgXzG1p7f0VYCkOvNU4bYLj/BI 1RYw== X-Gm-Message-State: AOJu0YxpqjuAO9y1+x+NBNLjvBhqSoYQuG0atCJzNbt2I+9RWP4oRbsc U0Mjn+PquEyMBLk58JLrYaQLKA== X-Received: by 2002:a05:6a00:2d0f:b0:68a:6cbe:35a7 with SMTP id fa15-20020a056a002d0f00b0068a6cbe35a7mr6501971pfb.2.1699840180559; Sun, 12 Nov 2023 17:49:40 -0800 (PST) Received: from octopus.. ([2400:4050:c3e1:100:ba59:509b:48bc:9f1]) by smtp.gmail.com with ESMTPSA id s14-20020a65644e000000b005b92e60cf57sm2635549pgv.56.2023.11.12.17.49.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Nov 2023 17:49:40 -0800 (PST) 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 v2 5/5] test: dm: add scmi command test Date: Mon, 13 Nov 2023 10:49:11 +0900 Message-Id: <20231113014911.3308990-6-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231113014911.3308990-1-takahiro.akashi@linaro.org> References: <20231113014911.3308990-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 bc5bcb2a6237..c550af93b0ca 100644 --- a/configs/sandbox_defconfig +++ b/configs/sandbox_defconfig @@ -121,6 +121,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;