From patchwork Wed Oct 25 05:14:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 737799 Delivered-To: patch@linaro.org Received: by 2002:adf:f842:0:b0:32d:baff:b0ca with SMTP id d2csp110556wrq; Tue, 24 Oct 2023 22:15:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGhyLVG7MLhDe7Im/HDnoS+TRKPmGwSb5EY+7YHNvZlnqSTV60qqy85bYPpqyrsPJKlA6YJ X-Received: by 2002:adf:fdd1:0:b0:32d:dd04:bb81 with SMTP id i17-20020adffdd1000000b0032ddd04bb81mr15876308wrs.17.1698210908551; Tue, 24 Oct 2023 22:15:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698210908; cv=none; d=google.com; s=arc-20160816; b=fkcKQWlJxgeeWc7+grCEA1tECcRAB/OtFFaY5SQ7Wtj0tHPdisVKvJ+AxWZzaf5AkO t/UL8mLr94jR4WVkqg8Sf1LYoNfIwncdh/m+osLzdUVj04FOk30oGuGZfsXNt2kVVuyH 7iysThnIZ0DT6hA8upHPOLfcuITUulL+jiL3kCxMwzQa30WkGPMg1dgUwSvvx31YFJEy 6gxtdHfSkFQNkHA6/8l8J2kc6qXAvm96BfUJWdv3Fv78tBDMjI+Jd+1b9rOoDnefFPKU RII0sL6zPiL51OFpr/26wcUO/xFqMG6ErtMALj4YLhpwzgetdmbqpJP+IEp26QJs7cJo dMEQ== 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=SUMAbMzHoHPTo3By3XoRLcFc4qPp57JA/75ABBehsIw=; fh=FEXntNvfp44QdEE6WJIcPMgg3VtrFk//sTXqtO2Yfu8=; b=kEf1Wb8qHOyn79lWjS2f35sdrbmCONVujjlqLhjrly1sq2QzN+j5doKAyDzGp3zqZh dt0UquPr19TXxWvPy9K9VWe0kFMXlm+MxTR6b6vhi/5AlLMWqD8CfZb+D8RwIfLsBYdF t5kFd+Vh+fU4hH/Jy8z42GyNBCRc+s7ADoTSDEtCuWo/6pAWY7OrWf3TBsKWEnGnc8bT dwQKVAI8Hofmf2WWU+usjfpl00T0UKsaXs36Sabrds830agiv9oxMkCf4B1xHbWxkqKJ z2gPOJQosd+gFcA9CClSZaHRaTi/wi+xVXKAGFrfQXbBR7z5hL3FsvNynwWzBT+QuhjN UZSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fmRRCHwd; 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 c21-20020a05600c4a1500b003feb1b6cc6csi10371669wmp.75.2023.10.24.22.15.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 22:15:08 -0700 (PDT) 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=fmRRCHwd; 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 E96BB87A02; Wed, 25 Oct 2023 07:15:00 +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="fmRRCHwd"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 22082879DF; Wed, 25 Oct 2023 07:15:00 +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-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) (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 EFD63879DF for ; Wed, 25 Oct 2023 07:14:57 +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-pj1-x102e.google.com with SMTP id 98e67ed59e1d1-27d797f349fso1206211a91.1 for ; Tue, 24 Oct 2023 22:14:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698210896; x=1698815696; 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=SUMAbMzHoHPTo3By3XoRLcFc4qPp57JA/75ABBehsIw=; b=fmRRCHwd7lElgJoIZx5DKxN3p557VwtHNUx7MI/vb/0yafvLW11RJipy/c8hDZkTNZ BJRY5GSgzCvygREsZfE4ERxsFL0BevRHAmTNy3l+eM5NPgbAjri2a/ZrYjVwlOIsp7Zb mFDaU6dDhh0ly9RBOELgDvkhXxQUm2P2qtyMxYQGcUDvsUkg/uEVZSgCTZTsT0tSAkQo /WlgewZG7RW0Tt+T23qs9G2l/CC9eA4nk3YlF+MBgtJfN0IovsXPDxXqdZfRuYx5r9wa ra/ARNBrvpC2gTJ68Fl3PpOp3ts1uZ7U/9aK8gGMeOYtzANz0JCdR9Y0JPkh3x+F/qAw kK8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698210896; x=1698815696; 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=SUMAbMzHoHPTo3By3XoRLcFc4qPp57JA/75ABBehsIw=; b=E8AqdtmwbyCowsVfP6jaMKVt452oJBjlfsShy/xKY3VUBR8ocgRSaPGxZwwYaoux6H 4WExY0u3VLJhYlT0WcVh+UdSf8oPisB7Xg9aiq/8S3SIyuZ7Ekq63xI/NMOvvBdk9m6W s5VTrWA/1/qq7/eWVW9GzslQ7oycGYAl7fNVIx/L9ChArUnkHPWrTZFh3dusziFuZoc3 zSBVTuA8iY91NB9+WYmLD7ezjqhY7lsrBUxH4lO2e0uhDnZYWu4oao0UC8ZKmTN4Go4O yf6DoY7WBisFbMW5Z3L8lmjliBunf2Qzx4dtX4MLQR8CBdF8GKnMNuOWn7BW8cz8t3FJ k2gw== X-Gm-Message-State: AOJu0YzritbGG0yws7Hx4a51lY5hjoXtnt6ZVLKVpVhe9xPEdcLXfdJo pi5HtSApxbkOBE30JSO9bPFdaQ== X-Received: by 2002:a05:6a21:9998:b0:15c:b7bb:2bd9 with SMTP id ve24-20020a056a21999800b0015cb7bb2bd9mr16042722pzb.6.1698210896127; Tue, 24 Oct 2023 22:14:56 -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.14.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 22:14:55 -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 Subject: [PATCH 1/5] test: dm: skip scmi tests against disabled protocols Date: Wed, 25 Oct 2023 14:14:23 +0900 Message-Id: <20231025051427.509602-2-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 This is a precautious 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 Wed Oct 25 05:14:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 737800 Delivered-To: patch@linaro.org Received: by 2002:adf:f842:0:b0:32d:baff:b0ca with SMTP id d2csp110614wrq; Tue, 24 Oct 2023 22:15:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFIXj89TlmrrawXX4cTAeBWYqxIgAa/uvdbVpy4SKIpl7byKjF1nzDEQAtNGWLoOIi845i8 X-Received: by 2002:adf:ecd1:0:b0:31d:caae:982d with SMTP id s17-20020adfecd1000000b0031dcaae982dmr12578775wro.12.1698210920380; Tue, 24 Oct 2023 22:15:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698210920; cv=none; d=google.com; s=arc-20160816; b=RNxfFSiNBgdkZVX9uLvErvRXRgpQUH+b4QxJ5C3anHveTOgYiKxyqlIKE8pP8lsmqx 63Dxug4R4groRHFw8MHxE8Bi+XWrEfpD0VRpHmJkXds3lOoswCBBslRnfndGCfKAjyM1 TZLaFkrVb7ZxgMDNUDJiiNE7R0KNclvTlzpWkBJmSOuv/TuhHKoNrOqZCLQ5F5v7CSFi OvgTWAM2OFChr8/szSaEP+ookwTybwxuvuI4IqcYFfy2w52/YVwSrzMmlY0AxKEWgha9 GuOAx8TW8boSVnPPfJ1AAFNqqvKFjIpZZ1aS0N/ISNhw6tbH7BrHvGXAwMK1K9MSrqHY aN2Q== 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=sPAlpRoESH8lrGECxp00xcCu19eRpWsI/45A4TwB8Uk=; fh=FEXntNvfp44QdEE6WJIcPMgg3VtrFk//sTXqtO2Yfu8=; b=VLUjkMX/WTjleV7oGaUdAlxH1InpYBJSxp5UEJ8AWOxWXFOxRDhhsT2LxFTbP7eWsE 6Y1TXDJZVVgl8nGfctfC8tsBrPq1kWUqg1j1qAL3xq+R4YhtCidPUWjHYMHzHlTCLGrz cACUc8kGCLiRGblfcw5UCDRLUbNmPDvCn2uMFNCeMtbHu0wvttnTMGQUM1WVKcebQ/Gd huF7yZ6/hC+y5Xmm2Qs55OgFyNxdRour15hZI5KaBiZ0s0qFP7C6oJ0HlmaK7Di/a1oE c8qdOUl7OgTGDQv/1MS9hHWO7hE9Sslvl/4KcBhdyfXOsoSjHzIr6PhE40EIDdR/NKQO ACiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=t3F7R5TA; 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 j5-20020a5d4525000000b0031fe1b44f6esi6925460wra.275.2023.10.24.22.15.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 22:15:20 -0700 (PDT) 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=t3F7R5TA; 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 8215A879E1; Wed, 25 Oct 2023 07:15:03 +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="t3F7R5TA"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5A3B8879E5; Wed, 25 Oct 2023 07:15:02 +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-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) (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 1656F879EE for ; Wed, 25 Oct 2023 07:15:00 +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-pl1-x62e.google.com with SMTP id d9443c01a7336-1c9ba72f6a1so10082195ad.1 for ; Tue, 24 Oct 2023 22:15:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698210898; x=1698815698; 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=sPAlpRoESH8lrGECxp00xcCu19eRpWsI/45A4TwB8Uk=; b=t3F7R5TAAi4eeElQS+fYoGltAj2LUermFtc37WZtpsoHSx0psqSFM8sQ8gCt2oVcW4 ZIR/lzk2A5SQTuBQPUGoXrnyBhY54hj/+SKH/4MQ1VV3G7Co/X1NTuj/bOJkxQKU8o6T 3Inug3N8FHBcPrXlxNY4FOisNnRd0iKn9chHUP0/8wN6ojEvsyid4N4S4EEPbbznHkNc qObMOkRoRdvxvHVJs90wDlH1xFq6kqLdhU9ptUxbTn0LDPo+9weiL//igzUqr7oJh1gl w/KX9eY0WFUWyws4+sHX4fFCVzdyflT1oaxxKLwfGPRK9Xm/9fn1sI294SRnzKy1p3Km E0fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698210898; x=1698815698; 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=sPAlpRoESH8lrGECxp00xcCu19eRpWsI/45A4TwB8Uk=; b=FR39GuqFtlScq5B/3uTtX3L3D0AEwvN/MNz/U3kmoEKIPIQo7ifbW8ioTAoCFbowiQ gRkJJ5Xcte12EfOrbQxuTTCb+wbPbgNlQPMP4yLaPZxEd478RSxxynscJtgQGneyGcxF 9LKSuuZpbTjdSGJjJehTDB+y2E7nhZeneFXPDpKVoDt2rFabJHqdQon0g9qoYxuLYTFi PVXYflLpJYnerpzBBXJvZHOcSVjbZwVQs/iTwWuzTUHpZYcU8iR+QqfdPCGZ0sxNWVps oY7GiOpccpkO4mmk3Tkq2/jW/FfA5+oDqKuIj2ImkNr14vBhYpTzLKcHqvsiEPp34vDT PpgQ== X-Gm-Message-State: AOJu0YxSFsxZ5df7He82pqSBYvwnkn3sevQwH/n9QFd8bxhGw+oPhmlw bPJLicdwghub3Czpjku1QfBZID5QZbjBCfsplUJZVQ== X-Received: by 2002:a17:90b:4b8f:b0:27c:f653:37b2 with SMTP id lr15-20020a17090b4b8f00b0027cf65337b2mr16464672pjb.1.1698210898333; Tue, 24 Oct 2023 22:14:58 -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.14.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 22:14:58 -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 Subject: [PATCH 2/5] firmware: scmi: support protocols on sandbox only if enabled Date: Wed, 25 Oct 2023 14:14:24 +0900 Message-Id: <20231025051427.509602-3-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 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 9f5f497e0a6c..e1b9b5f5f2d8 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 Wed Oct 25 05:14:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 737801 Delivered-To: patch@linaro.org Received: by 2002:adf:f842:0:b0:32d:baff:b0ca with SMTP id d2csp110672wrq; Tue, 24 Oct 2023 22:15:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFRcjEzG124oP3OIe02VG7THbpaw8AeLXBd91vioQuAvhz+FC1KxhWctjX0/R8kYHQU03Fn X-Received: by 2002:ac2:4103:0:b0:507:b911:6706 with SMTP id b3-20020ac24103000000b00507b9116706mr9280236lfi.25.1698210936115; Tue, 24 Oct 2023 22:15:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698210936; cv=none; d=google.com; s=arc-20160816; b=rbYMyp0PNly0DXtXZME919YCUADowmkPaCnLJ7mPqVsUQEConwHEKBbepx7ihrQb3S HdfS6bT3PDx16lwocfXmvxZRdPEi9LKaaYaaVsGq0MMrNMKSlpgqTaQ3uzvyjrpTXUFb sjdfLXIy3XT20e6qVj8HsBxlTPX3Qq0S2ESskmrsBfziCkQxJcMS+lqnSNOwcU853hMn mSR9zEC4dSqEsAYLoWqO8OlNOdgtXRj6NkKZ86dne7a/lHHv1evNwuFpg0ydfRbXhHPN hcncv8/sEfZ8JrzIAP68eosWGIBm+F3CzheaLOcNdwkd/cQ+38DaC1NykdC2hb1OfVof QT1Q== 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=NZ9sVFCLuArFUju00771+2Rb+1/4MVULU7abCRgwwJQ=; fh=QZWY3XY+sB907ugYHcr63Nh2/mcdieyH+ES8hS8oMbI=; b=KRs6jklLvXk3Qll7DCunMOp7lZ+lmHaV8tbE3jt54YwkNQyJFJcCalIz43p/bH1b+m B4HQ6oHNRDo4r8RWFXGgbH9GJusQZf0zGocavSYtylf7hjEv4re4CHQFl+nxTDsyQJ1x Fkh+wutWV+lGBseerNgoOrfNeit7llfAQfMaJy9t3r5tghwGOprKLJD4KbrHIqKLhLEY oy+kCkghNxVC5IQ1GcU83di5o8muovPcFs7PnhDmXH0BWfvKfghQoIzptIM5/WScmMNH sxahIN1odCcCuiLB/UbwA+51khy1m2L8ptN2ISWVXd/TEum2rm8XgrMVcjEyHlP6u3KU d6Zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QmeTR6YA; 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 k13-20020a5d518d000000b0031ffdfbcfb0si7052592wrv.741.2023.10.24.22.15.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 22:15:36 -0700 (PDT) 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=QmeTR6YA; 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 CB1A987A29; Wed, 25 Oct 2023 07:15:06 +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="QmeTR6YA"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 16493879FF; Wed, 25 Oct 2023 07:15:05 +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-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) (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 95972879DF for ; Wed, 25 Oct 2023 07:15:02 +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-pl1-x635.google.com with SMTP id d9443c01a7336-1cacf449c1aso8033645ad.0 for ; Tue, 24 Oct 2023 22:15:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698210901; x=1698815701; 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=NZ9sVFCLuArFUju00771+2Rb+1/4MVULU7abCRgwwJQ=; b=QmeTR6YA2Za92wxMdQ3IUk1CRUFmtiOGnuF9NiBlmbD7HNzEzCeT0mD3pyk4zuSFKK MU8TkSU4LqmO4PMSr6fCf1gVNuDe5x9jtW+RplHoctj1n44TrEEgu1IwMkQ4+R1Ehjxt XMjIs1oN7Q9M/jSwdYso+jImgaTGQqxvrT2gbqk5Ulcm4KZRnwiJ+pj1RdbvBhRJaZEK fxZpmsIFJlmGKnKu08j4zYpy46vu2nJdjnkOeEw3kCxZHEhE24iJCeInD/jgQJYZIxhc kWrsIVamQ9NlCvMgQI+k9jBWFzji96bkDItMea6EEHPsQ7sZd7xctTNp7kq7WFguNUSZ bzUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698210901; x=1698815701; 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=NZ9sVFCLuArFUju00771+2Rb+1/4MVULU7abCRgwwJQ=; b=H+PBDB5aox+IuFlrSlgy8dpRZ7DMeWBVK/RoVH+L351t1Qg6dIoTt7pFJ5GWTZpN6k /XzPuT6Lz7jgdeo7QWeMB3hXHiFtzlxNmp8tAkwERO4A1ADxh/jgJ8c889P+VyfaJWSs 6vpo1Xs/bKC9M10xRuoKtawhDWziV235/YzDHHJQNw9EnHu+3YtgLjznlXHtMmf9c83A oO16O5lzylbIcgm8Ew+JQY1Xd3OvkNH8QLQa8OsQVOWkn3jqiXrh9XT9iY9OAay21G8x m5mYn4UGYTrKaFqLz94++MyxZKPEBd884S21hiYJEHN34wDk4goE3sfJgYqRAL2zsEXx vgMw== X-Gm-Message-State: AOJu0YzEYI3O7kes515U7RC3N/E6zzDQ0Nc4TJV7QXQlrQ9Kn/2tLZ4l lZnkhMVnaBI125bZS3IJaMHzoA== X-Received: by 2002:a17:90b:38c1:b0:27c:f88f:11a5 with SMTP id nn1-20020a17090b38c100b0027cf88f11a5mr16310660pjb.2.1698210900825; Tue, 24 Oct 2023 22:15:00 -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.14.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 22:15:00 -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 3/5] cmd: add scmi command for SCMI firmware Date: Wed, 25 Oct 2023 14:14:25 +0900 Message-Id: <20231025051427.509602-4-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 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 --- 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 | 335 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 345 insertions(+) create mode 100644 cmd/scmi.c diff --git a/cmd/Kconfig b/cmd/Kconfig index 205df2f1fb65..c940051eba91 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -2550,6 +2550,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..f8f54f84cff8 --- /dev/null +++ b/cmd/scmi.c @@ -0,0 +1,335 @@ +// 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 + +static struct udevice *agent; +static struct udevice *base_proto; + +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_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[]) +{ + u32 agent_id, num_protocols; + u8 *agent_name, *protocols; + int i, ret; + + if (argc != 1) + return CMD_RET_USAGE; + + 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; + 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; + + 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; + 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; + + 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; + 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; + + 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++; + + if (!agent) { + if (uclass_get_device(UCLASS_SCMI_AGENT, 0, &agent)) { + printf("Cannot find any SCMI agent\n"); + return CMD_RET_FAILURE; + } + } + + if (!base_proto) + base_proto = scmi_get_protocol(agent, SCMI_PROTOCOL_ID_BASE); + if (!base_proto) { + printf("SCMI base protocol not found\n"); + return CMD_RET_FAILURE; + } + + 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 Wed Oct 25 05:14:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 737802 Delivered-To: patch@linaro.org Received: by 2002:adf:f842:0:b0:32d:baff:b0ca with SMTP id d2csp110721wrq; Tue, 24 Oct 2023 22:15:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFeqi3ZiWgFKR/AQcOn2P9KHuz/KeZY9D79ZmVXuLZwdviSvLDX53tsXl/8Dt6lhQHu6W2F X-Received: by 2002:a05:6512:318a:b0:507:ba75:b016 with SMTP id i10-20020a056512318a00b00507ba75b016mr11958697lfe.3.1698210948571; Tue, 24 Oct 2023 22:15:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698210948; cv=none; d=google.com; s=arc-20160816; b=nAn+Un8+ogCzY8KkugSZXBAy4P/l01kAELvAmdkAxEH8uEgU0MXzzjwJE9vUd5m17n oJv2wRSrQZ5JbSUAaXmIR36vr695Xc13ra2R0FYgScR+G+ncDcZxVFYhqkGrcImzuB3L N0C1dROUIjrhhVBs8ASvawbmqcQ/ZmqhS+7EBF7mXc/Vg6vmul8IuCuw/CaIMFcfdLXA Wymhp+RbMJ2rokeSTeJI13gwaj+h4XN4WfhPc9jMRk7Y6mIr4NKnnMqalEeBCjJOQ8wt YKR7HIdypzdSuMb3c7KZ9RwdCCFG+SCq4rCrECpyq8Vum40NUackDU59WQfrxDKr8WPG XjIQ== 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=w+djceTQJzCP0hxdrJH/X9e8wVGWuFJVMsZPdaTaUu8=; fh=QZWY3XY+sB907ugYHcr63Nh2/mcdieyH+ES8hS8oMbI=; b=Kedd2JIKG8ZiNIXy7pTd5l0oEdKagBjEG1EVXoUnhlGRPwEa+jbzhtZNCTl5HL67qV DRMbZA5tbOAVtUU+yrfDR8qqDifEzcr7TRtNqI8srrUAIZRe91S7kUlRkiOri00ZW4oT cDt6iJ3PNyFDL2hJth6LNfnpEgpclx+1sTjmyO3khLYwUk57dKN4LUIOXBPJXKDpEYeQ pzNXHZBcnrKUt3j+RTt24yQP3YSxrbEIcmj+Eaj9PwZfX4ByxTR/2M+zjezQyj8HoxFY EnUh6jz6TvH8LfQnKrajfJ8GOkm7OQ0pROUao0IkwnzS9Vjx7WPCQiYTu+xGDNfnKZHy FhqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TZvO1yES; 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 m14-20020a056000180e00b0032dad9367bdsi6654403wrh.245.2023.10.24.22.15.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 22:15:48 -0700 (PDT) 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=TZvO1yES; 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 414C1879F6; Wed, 25 Oct 2023 07:15:09 +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="TZvO1yES"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id AA11E87A38; Wed, 25 Oct 2023 07:15:07 +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-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) (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 CEC6B879F6 for ; Wed, 25 Oct 2023 07:15:04 +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-pj1-x102a.google.com with SMTP id 98e67ed59e1d1-27fe16e8e02so30505a91.0 for ; Tue, 24 Oct 2023 22:15:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698210903; x=1698815703; 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=w+djceTQJzCP0hxdrJH/X9e8wVGWuFJVMsZPdaTaUu8=; b=TZvO1yESiW7W2eLtj56jH219yHsvsbogThHEqzmJOz2Z0nYb0v0yBz/et/Eo2favpn /58ygT4GBM8shSd/SHu6WyChBEbzwoGhdoh5SgnsA71R0RNAW+HpVUmzG2sjVh0DxkiR kx/ydfkVJniztwYvYL6fHYr06bFKIw3VOIIopBCcluTqLbuSfRKOT3u0cpS6O4kl2gdN SDpfIKN83SfhP22G8ek+KPZTqenWPMuJHr/mh63gYz4ioVKjuvsTP/qmOIQ5Hxje+jop nEeFhTmWZm+K88JGl8ugLqdWSsQc4CMXFHFklwtLnt6vcRB3rjiK0zw9xHHNoBvJZC/2 cUhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698210903; x=1698815703; 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=w+djceTQJzCP0hxdrJH/X9e8wVGWuFJVMsZPdaTaUu8=; b=o1wIYh+sAgwGCPopUw610M0urWZ3SBSbj+MhlST8pXPe+9T9bht1pP75yJz/8XMCYm eBmwQT+ELNrBZJvW8JpEcvxYkfqIMg802dCKhFcRxSmwFZVnkkfEK2NaiKL4OxcjgKxX CjOxcBoen1McUnQPpmi34kChRDCiSJEZ9MfXg75l5MxEs2Q1cxYTk+kJZ4GVQ9WaJqWS 0+gcA8kxWqZKe3qvWRQcJxSSnvGkFiPcvBf7y8P6dj2LCNHt6CbCMnpPlXvFhryRoAbu fVMJyrzNWVsN0BI+2D+tG9QgBQJPbd3uUzgTQZIeIgYgAsFyF0tJ+0jC5pZeKktqUDny meLQ== X-Gm-Message-State: AOJu0YxwHnCUi8FpIAxgN1q5YTRUGnKFHxVZDl22GmMKMWpjYAcWWpiz LjHxh9Ktt/TOHaXJddNgzMJSig== X-Received: by 2002:a17:90b:224b:b0:27d:55b4:e72 with SMTP id hk11-20020a17090b224b00b0027d55b40e72mr16449462pjb.2.1698210903035; Tue, 24 Oct 2023 22:15:03 -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.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 22:15:02 -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 4/5] doc: cmd: add documentation for scmi Date: Wed, 25 Oct 2023 14:14:26 +0900 Message-Id: <20231025051427.509602-5-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 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 98b4719c4088..9a65b50aeed7 100644 --- a/doc/usage/index.rst +++ b/doc/usage/index.rst @@ -94,6 +94,7 @@ Shell commands cmd/saves cmd/sbi cmd/sf + cmd/scmi cmd/scp03 cmd/seama cmd/setexpr 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;