From patchwork Tue Nov 14 02: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: 743756 Delivered-To: patch@linaro.org Received: by 2002:a5d:67cf:0:b0:32d:baff:b0ca with SMTP id n15csp1960129wrw; Mon, 13 Nov 2023 18:14:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IEHM9zQOBTJVGphG2TpRd6FsycbAT2B/Pjw5ivQM/9qm6v0K8Bk983A6wCnGpDR1q9xp4sZ X-Received: by 2002:aa7:c9d9:0:b0:544:1fa7:b6c1 with SMTP id i25-20020aa7c9d9000000b005441fa7b6c1mr6038173edt.0.1699928097637; Mon, 13 Nov 2023 18:14:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699928097; cv=none; d=google.com; s=arc-20160816; b=hc9+GfLIkp8PMASyUundzzREOP8vfwQrvdF844fiQ28ZfdE7PlcTp4Do0XoslFPnqw f7yZhlruSvYhRYjM9IWaI7pR85NA9XJla0LsTuvQVxTdwH6ArNJziH/1Zu3d/mj2yh5b E19tb5sUuq04LF5KZes9VLN9hZJa/3YiL4eOAUp2X4bqycFSoUqV3NRB/Nud/Z7RUy1O t5VemQn+lN13W+h9C+9+KpDowE1nPOmdG4msbMcI+RT2oMWFM7gJCbOVewodUgzMY09f 9CLRNKEYYnUrStx9ryl1df+UscHYbbDSdDKxRjLwePw6mo0DP9vsUp7KUlfP763wG5U6 DAVQ== 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=LMQ30vVJ6x3VuIzzlPgixo+7jt4+e1KA7PiQ5YhXggU=; fh=FEXntNvfp44QdEE6WJIcPMgg3VtrFk//sTXqtO2Yfu8=; b=lrQAoHZX+zAXuUdKfq4YQRLqJn6x5P4R5Jpv0duSR1vN118lgDA8qYE3YBE7T+r9yH lKd5fKPGDhUwHHeiTPHldvJTatMYtHoD6U7Ob/c8TmrHxZAJJlsdlJEID0NKYkEzJbBb w0GvZX5F3czHpjS4c2DzsGyZ/JLRtMc7Ymmq5De6J9F7CdV5XlbGHq6eu3CAlgISV0Ac aq4MPpz02tlg/VsRzlgVJH9dY0lv/aghJsrfABj90YKjZhPomfpHcHiFEYyJ4QRl1/Uh 53nxtXTHrflU07GfyVkjzHPNR30ul5QrYg362y/FONrLofYfiJND2TJGeinJqPI5BSUU pKmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="hCybj/ZD"; 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 t13-20020a50d70d000000b0053e671320a8si3425881edi.377.2023.11.13.18.14.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Nov 2023 18:14: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="hCybj/ZD"; 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 A805A871C1; Tue, 14 Nov 2023 03:14:50 +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="hCybj/ZD"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 889F6871A5; Tue, 14 Nov 2023 03:14:49 +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-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 59237870F6 for ; Tue, 14 Nov 2023 03:14:47 +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-pl1-x635.google.com with SMTP id d9443c01a7336-1cc703d2633so5563575ad.0 for ; Mon, 13 Nov 2023 18:14:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699928085; x=1700532885; 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=LMQ30vVJ6x3VuIzzlPgixo+7jt4+e1KA7PiQ5YhXggU=; b=hCybj/ZDsvbt5ZxHNErB/Q/w/QPzuoSRz3AiFcWrerQ8FKLGapwfbj9Glj3NpBmkSK eJ8xbItjVm/jz4iiD21e+rVvj59c1/wSo6Cmul+qOeh+xItw0Gg7coyHhw6Ss7HSB6cq pr8rPr+s4VkeoU/UQawH9Ct/JTk8+W5YidmgdJi7y00aZ0gXRDi3vcNXmFYgE2cmWNwO dv67BO9wiFsrGyL8Cky07MgdgtgSCpz0XHLJH2f6cI+ZVc2sbeZGvVCn9//OD8r/rLrv Kts7dgLzq3sZLIxSaf2OzDdeWmPE0peekej5V/QAg2B6hD/0OyOznC2f3iNf2Sa8QBD5 krqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699928085; x=1700532885; 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=LMQ30vVJ6x3VuIzzlPgixo+7jt4+e1KA7PiQ5YhXggU=; b=IlayWiP4lgEL8x/PfklzYaHaIbhuyJTJoZ1PVxyBjia7mwOfg/e08DQrXMM2tvt41i IZaD0hpk0Q9O1i9tD4Rv9VHOuSungoxkNnbFs80OtIJQivj7f5W9rFhxD1HJKSuFonIb bahxlMJ7RripoOJRyKNaO8cQ/xkbZg1UvHFApoOTtAg7402wA4wXpxarSImA/1VuFAoB Vl0pz9wpw/jyE7hqIsnAZUVbe8fQOj88I8Xu+8sAjRY6vW2kWpoiNvkaMGI4lc0PP6CC je7FrCGl2xCQ/hWikQGlG56Q80Gr6sGDaUBSLcidiJzOOO2XLWRjhkhCAkc3DNWriDgN IODA== X-Gm-Message-State: AOJu0YxRSfs6UvSOidvDVOMem8Xbliqf9wOS2QI+UtYEC5s+3AnBJbld DAyY3OC4tNiEllh4g7QwrFVbTx5ax47Rr8zRf+ddAA== X-Received: by 2002:a17:902:d2c9:b0:1cc:2bc4:5157 with SMTP id n9-20020a170902d2c900b001cc2bc45157mr1201454plc.1.1699928085520; Mon, 13 Nov 2023 18:14:45 -0800 (PST) Received: from octopus.. ([2400:4050:c3e1:100:66f2:cd5c:3d82:6e6f]) by smtp.gmail.com with ESMTPSA id i4-20020a170902c94400b001c61afa7009sm4680475pla.114.2023.11.13.18.14.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Nov 2023 18:14:45 -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 v3 1/5] test: dm: skip scmi tests against disabled protocols Date: Tue, 14 Nov 2023 11:14:24 +0900 Message-Id: <20231114021428.531887-2-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231114021428.531887-1-takahiro.akashi@linaro.org> References: <20231114021428.531887-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. If a given protocol is not configured, we skip the test by returning -EAGAIN. Signed-off-by: AKASHI Takahiro Reviewed-by: Simon Glass --- v9 * return -EAGAIN if we want to skip a test * use CONFIG_IS_ENABLED() rather than IS_ENABLED() --- test/dm/scmi.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/dm/scmi.c b/test/dm/scmi.c index da45314f2e4c..582485471fff 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 (!CONFIG_IS_ENABLED(SCMI_POWER_DOMAIN)) + return -EAGAIN; + /* 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 (!CONFIG_IS_ENABLED(CLK_SCMI)) + return -EAGAIN; + 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 (!CONFIG_IS_ENABLED(RESET_SCMI)) + return -EAGAIN; + 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 (!CONFIG_IS_ENABLED(DM_REGULATOR_SCMI)) + return -EAGAIN; + ut_assertok(load_sandbox_scmi_test_devices(uts, &agent, &dev)); scmi_devices = sandbox_scmi_devices_ctx(dev); From patchwork Tue Nov 14 02: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: 743757 Delivered-To: patch@linaro.org Received: by 2002:a5d:67cf:0:b0:32d:baff:b0ca with SMTP id n15csp1960215wrw; Mon, 13 Nov 2023 18:15:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IEzjkq10Gx5Ly5Yw8Q11jlRB7/cqIjujjt1CdvGTK2aplDi5roVDmpvq3tPT4hOEIHrZRW8 X-Received: by 2002:a17:906:f217:b0:9e0:2319:16dc with SMTP id gt23-20020a170906f21700b009e0231916dcmr5882403ejb.73.1699928110553; Mon, 13 Nov 2023 18:15:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699928110; cv=none; d=google.com; s=arc-20160816; b=FQ2usQ3ahBWDh36fkPyZKmsxdclwMY88ANWNnx4oU0DpmRCYprt0/bH5SbR46wRosi 9XLo/VgHSbvgYaXhxM2L6j4DpebOfn8UqjqZlhN/S4FgujIktwFFyl+Sk6HV+EPETJQk B4jGRqJXDny5166N23QHw3+rJZ6P4RDzQBJh/aRSRLqZ7Wa3UqLkPwtIi6m5qch+LlS4 UZMUhXQ+0Tbdyte5oalWa5yI9N1nZAV7EMnRlcoIDYXHWzJ1t1afxh2qyA7CEambbyke t7Lu+QHwVowcWUGLfAMbVdcOUS0rOwXjOLYFRPkXU9KwUx9YgizIhUMuRbX91IuXDwYn X1ag== 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=qzrl0Keos0SLcEaLtLMYI7oJd1R9TXvnv53DOnHM4r0=; fh=FEXntNvfp44QdEE6WJIcPMgg3VtrFk//sTXqtO2Yfu8=; b=acekl3gBPUzIb+cTb7qZdjIiDyrJbLvXUK1t070cghozaKabxxWUBecYwCrAO3g7ZI BDH1j8bm49Jl9KX7u73YMJ+ZKIeTFD8AzaPTLZEv4Q9QhOpH3hfOk5wCSJost0W+B/cI sBSYiDkF1MMeqKZATsblwJU+2hp0X/2ylX+uFHlLxikWT1FHUJPEuedy1Xb7a1Mt3t6v nlWHKPROjM6Jw+dFwR5pSvM/CXJZpXu6Q8E/EOaWzimaq/XPFcJXGbh8fSEkO3XNWwCH w5HFw93PEhXkJ/hrbFiPLIiR2m18a/1Q1e43078UV1xCnhbLGRlemjDj0zP0/4oXjpYQ O4zg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Wx/B11Xo"; 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 o7-20020a170906358700b009e29b1dab69si3216734ejb.264.2023.11.13.18.15.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Nov 2023 18:15:10 -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="Wx/B11Xo"; 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 264C9871AB; Tue, 14 Nov 2023 03:14:52 +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="Wx/B11Xo"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CA6B5870F6; Tue, 14 Nov 2023 03:14:51 +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-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 6B13E87183 for ; Tue, 14 Nov 2023 03:14:49 +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-pl1-x62e.google.com with SMTP id d9443c01a7336-1cc4d306fe9so8109475ad.0 for ; Mon, 13 Nov 2023 18:14:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699928088; x=1700532888; 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=qzrl0Keos0SLcEaLtLMYI7oJd1R9TXvnv53DOnHM4r0=; b=Wx/B11Xo7R+FbrJwF5anVBIkpMSsuFR58d/7ymoXd+X7O4d1mNiqsssJUb/m6EkBQn HU2rTR8iPCq7tfaaa19RbJd4We65oZTC56xfZQbmU6qeowqcSICX67VKGPZNLQe5ZuQt XMXA+VHMEAmrzG7CqHOav3L7WJKahHJkJ49h4HLtv8T8WUtIkZJc73u1LO84YcF3Pt4B mQH89imrC/vlRP797WOM5LsXvgbCjpckeK+9GButv0/TXVFO/mNmBsooQ6b9jgv2tZ6p ex0RLJ8kIUj0yVo3ZANYl9Kxc2wCnvLNc0S8Zd5TJ0opwk1mJxFwCNQq3ZNuqwvJdzZj rIhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699928088; x=1700532888; 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=qzrl0Keos0SLcEaLtLMYI7oJd1R9TXvnv53DOnHM4r0=; b=vssCtr105P6hpBDOMemiv4b9kxlTRdPPE0Mk1t8DyZJAIxvR3/bD0uGKnbcmFieZqq NRBxfyQa4G4bhPqTuTHkiQVqK9mwsS5jZnfyzeO52gBDLPavApJL7UiWENWQPNyDY5Vp HdIuGkx5EqEP9ogIvsIYpnn1AxcHXWTYBYSt6j+R36skvPctIiyZz50SAFucCfU9kj8M 3oPHKryvHGKpwSfq891PBvQaETWOE3DRJ2obQuLQ5IpxG3emgUl2Mi3FJBpQwe/Dmum3 XW/uX8oaoJirTfDY8J53jBTBmE5EqUTRZ9AcEjQ8l5smLIqB8uxjNXq8yO0zkrfhzuiD JofQ== X-Gm-Message-State: AOJu0YwX3vIPRmLkNU79Kx4ayNcKhitpODBdJumSH/WCXfQey5ISczwK u9QnSVqiN0Dfr5bzL371WhNTEqcHBJRmuvm04lOK1w== X-Received: by 2002:a17:902:ce92:b0:1cc:2ba2:55f4 with SMTP id f18-20020a170902ce9200b001cc2ba255f4mr1204312plg.0.1699928087682; Mon, 13 Nov 2023 18:14:47 -0800 (PST) Received: from octopus.. ([2400:4050:c3e1:100:66f2:cd5c:3d82:6e6f]) by smtp.gmail.com with ESMTPSA id i4-20020a170902c94400b001c61afa7009sm4680475pla.114.2023.11.13.18.14.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Nov 2023 18:14:47 -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 v3 2/5] firmware: scmi: support protocols on sandbox only if enabled Date: Tue, 14 Nov 2023 11:14:25 +0900 Message-Id: <20231114021428.531887-3-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231114021428.531887-1-takahiro.akashi@linaro.org> References: <20231114021428.531887-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 Reviewed-by: Simon Glass --- v9 * use CONFIG_IS_ENABLED() rather than IS_ENABLED() * remove goto by introducing a not_supported() function --- drivers/firmware/scmi/sandbox-scmi_agent.c | 30 ++++++-- drivers/firmware/scmi/sandbox-scmi_devices.c | 78 ++++++++++++-------- 2 files changed, 71 insertions(+), 37 deletions(-) diff --git a/drivers/firmware/scmi/sandbox-scmi_agent.c b/drivers/firmware/scmi/sandbox-scmi_agent.c index d13180962662..cc9011c7312f 100644 --- a/drivers/firmware/scmi/sandbox-scmi_agent.c +++ b/drivers/firmware/scmi/sandbox-scmi_agent.c @@ -66,10 +66,10 @@ struct scmi_channel { }; static u8 protocols[] = { - SCMI_PROTOCOL_ID_POWER_DOMAIN, - SCMI_PROTOCOL_ID_CLOCK, - SCMI_PROTOCOL_ID_RESET_DOMAIN, - SCMI_PROTOCOL_ID_VOLTAGE_DOMAIN, + CONFIG_IS_ENABLED(SCMI_POWER_DOMAIN, (SCMI_PROTOCOL_ID_POWER_DOMAIN,)) + CONFIG_IS_ENABLED(CLK_SCMI, (SCMI_PROTOCOL_ID_CLOCK,)) + CONFIG_IS_ENABLED(RESET_SCMI, (SCMI_PROTOCOL_ID_RESET_DOMAIN,)) + CONFIG_IS_ENABLED(DM_REGULATOR_SCMI, (SCMI_PROTOCOL_ID_VOLTAGE_DOMAIN,)) }; #define NUM_PROTOCOLS ARRAY_SIZE(protocols) @@ -1124,6 +1124,13 @@ unsigned int sandbox_scmi_channel_id(struct udevice *dev) return chan->channel_id; } +static int sandbox_proto_not_supported(struct scmi_msg *msg) +{ + *(u32 *)msg->out_msg = SCMI_NOT_SUPPORTED; + + return 0; +} + static int sandbox_scmi_test_process_msg(struct udevice *dev, struct scmi_channel *channel, struct scmi_msg *msg) @@ -1160,6 +1167,9 @@ static int sandbox_scmi_test_process_msg(struct udevice *dev, } break; case SCMI_PROTOCOL_ID_POWER_DOMAIN: + if (!CONFIG_IS_ENABLED(SCMI_POWER_DOMAIN)) + return sandbox_proto_not_supported(msg); + switch (msg->message_id) { case SCMI_PROTOCOL_VERSION: return sandbox_scmi_pwd_protocol_version(dev, msg); @@ -1180,6 +1190,9 @@ static int sandbox_scmi_test_process_msg(struct udevice *dev, } break; case SCMI_PROTOCOL_ID_CLOCK: + if (!CONFIG_IS_ENABLED(CLK_SCMI)) + return sandbox_proto_not_supported(msg); + switch (msg->message_id) { case SCMI_PROTOCOL_ATTRIBUTES: return sandbox_scmi_clock_protocol_attribs(dev, msg); @@ -1196,6 +1209,9 @@ static int sandbox_scmi_test_process_msg(struct udevice *dev, } break; case SCMI_PROTOCOL_ID_RESET_DOMAIN: + if (!CONFIG_IS_ENABLED(RESET_SCMI)) + return sandbox_proto_not_supported(msg); + switch (msg->message_id) { case SCMI_RESET_DOMAIN_ATTRIBUTES: return sandbox_scmi_rd_attribs(dev, msg); @@ -1206,6 +1222,9 @@ static int sandbox_scmi_test_process_msg(struct udevice *dev, } break; case SCMI_PROTOCOL_ID_VOLTAGE_DOMAIN: + if (!CONFIG_IS_ENABLED(DM_REGULATOR_SCMI)) + return sandbox_proto_not_supported(msg); + switch (msg->message_id) { case SCMI_VOLTAGE_DOMAIN_ATTRIBUTES: return sandbox_scmi_voltd_attribs(dev, msg); @@ -1224,8 +1243,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; + return sandbox_proto_not_supported(msg); default: break; } diff --git a/drivers/firmware/scmi/sandbox-scmi_devices.c b/drivers/firmware/scmi/sandbox-scmi_devices.c index facb5b06ffb5..603e2bb40aff 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 (CONFIG_IS_ENABLED(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 (CONFIG_IS_ENABLED(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 (CONFIG_IS_ENABLED(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 (CONFIG_IS_ENABLED(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 (CONFIG_IS_ENABLED(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 (CONFIG_IS_ENABLED(RESET_SCMI)) + for (; n > 0; n--) + reset_free(priv->devices.reset + n - 1); return ret; } From patchwork Tue Nov 14 02: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: 743758 Delivered-To: patch@linaro.org Received: by 2002:a5d:67cf:0:b0:32d:baff:b0ca with SMTP id n15csp1960291wrw; Mon, 13 Nov 2023 18:15:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IHRUQtH6Prcu9MgcpPxN5YoUatKVtihZ/GaeTIoe490c+lLwWbCGdMQd+h/WYsQ03++fBbQ X-Received: by 2002:a05:6512:96d:b0:508:1332:558a with SMTP id v13-20020a056512096d00b005081332558amr5745603lft.2.1699928120937; Mon, 13 Nov 2023 18:15:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699928120; cv=none; d=google.com; s=arc-20160816; b=SzkyzFwXM6f5wAsiZHscGIFqfFWp+F8szpl/mU/UqtKMMAwrUegkxjQ06pEQdw/Bg/ bXMrsQSZv73osz5ddlqYdG7qNr742KRd36fKFONjKQ0BWPPRHxvdB5A9lMmRRkXENZlu wvbnMvT9GyTk+Ys+aDOyDN7kyy2xjpjlQ4ktOEmm/DZvdKnL6fXgW3RA9ycRNTtpT8jd QV+eawhqCZC5io+AfGZ7VQuAXmbYdtIFa4UuJbeK1ldYjGEEi1BXLXaZr4YuWbODRy2o 0+La5loWjN3X/wtYHzQX/DhNTR9PSas8Ngj5qy8hdeE8fPLiJmKC3u1mTn932t+EEBF7 stwg== 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=NxZwMKOqmbLbb3KUgPqHrb1iFDk/tMVk++1tuZbX4yOZwZrOYT9gtTKczBRWCJOk4B dHO+kxxY0clVcSAYuO9icRHZDo1MPI10pYcshZc5lzmxuFXByNevZkxlpnGqZyMQkE9e cbFHZ+X1V8OQjAH4JTjaWD84sOou5Vrdb1AysHAhabqVo4kYXQ1h/yoeAwNZiQMeOm/q O9Dcn33TTe2rRdihLB7o93ikI8UrCujjdlZyQy2DQZnI6b3EnoJ3hlS2B7d9ekY2FlSf dzxuILIGEgYH8ckk0+6Q6+BY+mv+OnOT/Q9SaX2VmEwVFxQoD+zJOizOaom314w4KEP/ oWRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Fvcf02QB; 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 jg35-20020a170907972300b009dd6cdb92b1si3313805ejc.664.2023.11.13.18.15.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Nov 2023 18:15:20 -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=Fvcf02QB; 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 BEED8871B1; Tue, 14 Nov 2023 03:14:55 +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="Fvcf02QB"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4570E87183; Tue, 14 Nov 2023 03:14:54 +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-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) (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 AB6AA86484 for ; Tue, 14 Nov 2023 03:14:51 +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-pl1-x62f.google.com with SMTP id d9443c01a7336-1cc4d306fe9so8109505ad.0 for ; Mon, 13 Nov 2023 18:14:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699928090; x=1700532890; 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=Fvcf02QBXfKcO21WH17ESk3HKBpcEDIq3BgL5rmmlxSu6kNEpfj9+0Wc0DZl4Y/KLz pOEf4G0H2Vl5OgBk5iL+cRbhAQqz1kckWi/BwD6f/HFf4rDSEeQ+VeK0i6LW2RGzFf7c S48b1GYyiwWE9TZwf24npTFUH0YBdDUVUH5mgsfRp3p2dRXkKokvarrBfQs2O0I4aT0S 80SGM4TH5MkAcCzYubVF2DFPgJGAtY4BSAvjh7lV9UEhJBRcLQPz0DpZ9Ht17c29Rv89 uZQYUMZXtoWylTI2K/jdqfJhI3aYZjw9fBhw8vWA+OjPNerkaBBkI+ZN0CBuQwcq9G/Y z/Jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699928090; x=1700532890; 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=mNJXecycDQQ8TAA97rQTupFgtERK4jVpfdRb8NU+xm/u0C5qCU0fEhUZiRa+NgkZ6/ c7/gjXszdE+ahjMHIgCnG1tjIKb94zgclOxvX54ZUiQLQJeUohJO16BIl9urA83QEGtG gLcHogmwQ7+SV0PEtuBHUT9c8dlf76cx2PbgsrHIdnJgl3ACdJxwSVhon0gVNZawA2Pv m9DYDjJDBvfICflSv36VGTNzPpKhJUA4BfWCqA5w58Fp55FaBJvnpI8gk7vaGJTBtmVj icp18IKY+DGjK1bvsTehP2AL+1MKKH3LIJcG1B7Iv5YjKJRAUxKstL8b1iLg2xNB+Dib IQdw== X-Gm-Message-State: AOJu0YwotEb6iJzssPYoMZWQkUwoQlwOtwmEPPcxdP+2YBz+RMly2bws rQcr+jsynVLf6XDjSaTr4a2JAg== X-Received: by 2002:a17:902:d2ca:b0:1bb:83ec:832 with SMTP id n10-20020a170902d2ca00b001bb83ec0832mr1131611plc.2.1699928089849; Mon, 13 Nov 2023 18:14:49 -0800 (PST) Received: from octopus.. ([2400:4050:c3e1:100:66f2:cd5c:3d82:6e6f]) by smtp.gmail.com with ESMTPSA id i4-20020a170902c94400b001c61afa7009sm4680475pla.114.2023.11.13.18.14.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Nov 2023 18:14:49 -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 v3 3/5] cmd: add scmi command for SCMI firmware Date: Tue, 14 Nov 2023 11:14:26 +0900 Message-Id: <20231114021428.531887-4-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231114021428.531887-1-takahiro.akashi@linaro.org> References: <20231114021428.531887-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 Tue Nov 14 02: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: 743759 Delivered-To: patch@linaro.org Received: by 2002:a5d:67cf:0:b0:32d:baff:b0ca with SMTP id n15csp1960351wrw; Mon, 13 Nov 2023 18:15:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IEaAySsKMj6XTdPMAnJhhBrUlbBOOKuXjdNWJXc2Dq7qoPbOwckJ0GzDa9SsB+jlJLMLChd X-Received: by 2002:a17:906:29d8:b0:9ae:50e3:7e40 with SMTP id y24-20020a17090629d800b009ae50e37e40mr6138359eje.52.1699928133079; Mon, 13 Nov 2023 18:15:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699928133; cv=none; d=google.com; s=arc-20160816; b=f2Z899Ua1EW138SRRtUKq3xwJV+V24fn12vU/Zgg/72a8WolBaxHlkgyT64ro4aAg1 p+7S4REWfi8zx1u2mP/pQXxrJQVQfmNulZ+HEKFAd+L5pFLvamgC5gUr7LS5Tm0yuI9w bOYaqjWGreaooeV2aHk2XYGilqWYyY66BNXJtU44ai7PDJHgHeilqOg+KeZl75l72Gv7 1wRlxG/Ck9eM4CFDdjnPRMH02Y0Nwx8EEQWit+eYrJZEKt24t5wXL8mkoE2ELpBiWW+H mPGFVU1Q2vdrxVMG+iwkBiyiN9f9LkptUnXK2ByWTDrFXNMTsDSjqn5LNjZ+e0nOE48k aGzA== 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=tHDSn6v087sIS0vdMEgS6KBgdleMrN/nKeRB5WQSHncluiALDYikOIO7alnZXJFOS1 OGpeuG7N1JEYf7wF0N/Ind+E5ILtDBIBsamx4svRKDc2yLXh9qrBXVpUbGU6+7UXFaQt iTtZV53MuGfay1PJKEGJafC+eVtiH670zoYU6Znebgxwed/0uTFIIV/nYCxfr++nNDr6 kmHev4rv5T/jvLI/JoRv+jz8dbdL6F/5Ej7VQWjOS7fQmZRcdT7BiChaeSsBecqePpMu xD/024YkY+wvKOM7+uWxGKGk48tRo0IpO91T062VckfyoDMdxNTtyjX8sDXdOVp/+llj hDxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Cro02O9h; 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 dm4-20020a170907948400b0099cf40fcd23si3547196ejc.276.2023.11.13.18.15.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Nov 2023 18:15:33 -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=Cro02O9h; 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 524E5863C9; Tue, 14 Nov 2023 03:14:57 +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="Cro02O9h"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B14AE871FC; Tue, 14 Nov 2023 03:14:56 +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-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) (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 04C5D8716C for ; Tue, 14 Nov 2023 03:14:54 +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-pl1-x636.google.com with SMTP id d9443c01a7336-1cc703d2633so5563705ad.0 for ; Mon, 13 Nov 2023 18:14:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699928092; x=1700532892; 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=Cro02O9hJgHPGcxPvRRbXBWghYQPZ4/rAGqK0BHWgKYmEeWGTUbGMFdc8tUK5EYIAk xEG7m/8fIXyL/pZvE2fD27PqCFc2JV4KvEnS1JfatcGnUPLk+TwnXztQj+mj0sN/Xxl5 lgeqqNxd/Gd/ieI1LBzFa5C8VVRmhBRsYwedda5QS2bEgo4CS1aamFkJ5acC+OeIBtc5 7YEi0TI1sVQqRcNLI0djMvPnwPPTAIdq4do+6NftVN1vWyVFZiZbIaZmBM71PUXhx4b3 EtSCMv2CqiFPd3F+5YfK5NAnbLxjdYecebWn1xHsr0p0HaYR4RVA6zmkMxi3k54upSCY /1fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699928092; x=1700532892; 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=vHCLnz5t+qN3JVRbf5egEpNLXIvj8K6oFWtt7z6AhgR3qz8Qf4NRthynCUoANt30cY am5DEAFtrtBrvJpN5rWHBETyfwdeCgTxI5MnNfB7RArw1pDc6AoJWYObUgXYLJEOfOug 2B+XpAru4Zd7lbz9E6mXi4zmSgA6ODUMNjc6dT9aEcYwQnvoDnJIjJrareYzXY5vwCVs 4z5zC9mCX23sHcmpwhrUbLcJSfwN9GTS0iKByR73X0vg5WLNR2ve/z1YGaGCNi16fm+E fPHXMK/29uGVfdhkK7+ErRbhaQdmSbquGginr+Qb0FLT3R2LvD85oHtu6bxDOkTnz28V WmOA== X-Gm-Message-State: AOJu0Yx7nUAMKPlmi7kiMTbbXpb2+KdZVJkD5AZ9JwVzOglFZvqSG63r mVsZcWaFjPTKN6bTsG13gaDPkw== X-Received: by 2002:a17:903:234a:b0:1c9:e121:ccc1 with SMTP id c10-20020a170903234a00b001c9e121ccc1mr1099286plh.5.1699928092192; Mon, 13 Nov 2023 18:14:52 -0800 (PST) Received: from octopus.. ([2400:4050:c3e1:100:66f2:cd5c:3d82:6e6f]) by smtp.gmail.com with ESMTPSA id i4-20020a170902c94400b001c61afa7009sm4680475pla.114.2023.11.13.18.14.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Nov 2023 18:14:51 -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 v3 4/5] doc: cmd: add documentation for scmi Date: Tue, 14 Nov 2023 11:14:27 +0900 Message-Id: <20231114021428.531887-5-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231114021428.531887-1-takahiro.akashi@linaro.org> References: <20231114021428.531887-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 Tue Nov 14 02:14:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 743760 Delivered-To: patch@linaro.org Received: by 2002:a5d:67cf:0:b0:32d:baff:b0ca with SMTP id n15csp1960405wrw; Mon, 13 Nov 2023 18:15:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IG0bKup89jD5PYxPeag/dlZyP7wJEpDcHX/2QXO/V9Qh68jNfkpEAxGifgszNZN7M7VyOSA X-Received: by 2002:a05:6402:5189:b0:543:42ac:c9f3 with SMTP id q9-20020a056402518900b0054342acc9f3mr993471edd.19.1699928143409; Mon, 13 Nov 2023 18:15:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699928143; cv=none; d=google.com; s=arc-20160816; b=Gza9nl19KR1udNF2Ni1Dtb0uw/jYYKPDSOP7C6GPzrxqR3YwFZoF1qgprNsviCxDBl pe8RaajxoaRqV9LBym694wzXpueD7vsMy4M/Pp46qHmj0rrS/zDGiuAIYEty9riDy7Zu 9c7Sry9ay5M75/8fHVfFKY8yptdkWnYLvGYhyHeQUfNZEUtjJSjMQU4J9mpBsNH3Ia/Q 2o5GApbUIQkpmZf+JEwrZ+kSLWcBQjHYyL8q3Y7G13Sww68dZNibL4Y8oSxR2/i2Efz8 WDLqocvgnK2Xg7Q8gPSh7+1BsrwP0jCQNt7kIpyQuLSMAjDcO+B3p/pJZZ45/OCx8vdf r8Ng== 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=Cjaloo8fP4ejF1QQKCfPDBSHT99TfpromhN5WcQJSUk=; fh=QZWY3XY+sB907ugYHcr63Nh2/mcdieyH+ES8hS8oMbI=; b=TA7wmtIjXpF0ZgLI+Mrchlmz6zAbDVrU8RQpgMjwNikXxv7rRDboa6aNQng38NHIQj /AI6HFEaXTrJRI33i5QmvcK2oxSTOEYbZoh08yodieTP0YN/aTztVqsWUzsbLApvmx8M f9U0ixGy2qhD3QcQBETlu79S6ncpqPpJJ3ju3ls9gWrE2ARu0SLFsLgLguyrCWYrJuYM rl9wJep4rWRD2yT98DIndSmgs6+P0wRvAGX9IFaxcCc59IY0ed7rNld95mfiD39FNxk/ aCWJ2H/VX1ipPgRJL2SOqCFn7nwxTK2t+iuVj94O/wWVfwru4FsjNR2V8Qw3hdAlXR+x 3zrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Gm8wQwZF; 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 j2-20020a50ed02000000b0053dd945f775si3457261eds.454.2023.11.13.18.15.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Nov 2023 18:15:43 -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=Gm8wQwZF; 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 D056E8716C; Tue, 14 Nov 2023 03:14:59 +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="Gm8wQwZF"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id AB0BB86FB2; Tue, 14 Nov 2023 03:14:58 +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-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 196FB871C0 for ; Tue, 14 Nov 2023 03:14:56 +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-pl1-x635.google.com with SMTP id d9443c01a7336-1cc41afd376so3351555ad.1 for ; Mon, 13 Nov 2023 18:14:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699928094; x=1700532894; 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=Cjaloo8fP4ejF1QQKCfPDBSHT99TfpromhN5WcQJSUk=; b=Gm8wQwZFlSVpTfBvBLE6a5FIOtUNoyjFN73ITe0/cNEmy2suw463oeO6lohrHZ/bfr HDq+d2pLE7mO9SpFUc/l/3wdl3fVGSaCakyBajWiJMi7IEpC+8pbYWkbr+4oVVkidtHp H5TA5UaD2uoSnCTcEATCLMfcdaFEmO3igO07F5BNv8mGHJ/PMzr771CBsD89j0zLxxSW JK29EHQ84WUiFFTA712LfwNdAH+k+B3p7IXZSWu8+wjEeWyJxWuJYXG2bcY8gTaolhvT pafzfcvdeGEEov/ESs8VTG6NQtqZUhiE6jKmTd/CjSHCM6bMuB4j2pHePll0q21h8NIp EFsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699928094; x=1700532894; 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=Cjaloo8fP4ejF1QQKCfPDBSHT99TfpromhN5WcQJSUk=; b=Degdhn3TXWSqjQyURMjrkddVxwp7Tk9jC9c9AgHuMGYge6J2ZxyPaAwwuGt39dlqxU cXzSmO8qGU6V5aMmScTfz3Pc3kvbgfhM+SHo8Yi8YYTkudz4dxNVHEkbScyapMXUHu7J iyHKfj1bhkJK1VgvMnOgC1cbdEv49fKijF+UjHz4cLa0JmJXztmKyipqLlJ9yeFE5dfe 9KbTA/LHGHjQd9asp43hujUv7onJ9akvkfLxrw7W7LdwzJLaIVyR6bc0drmCEcBfUdIF zTUCn/DzxfUwxcutPmnXOSun9qsmk23Ap1wQMj2FLbPp2eQp2qlHM0ZRCq51350aJVUd ojqw== X-Gm-Message-State: AOJu0Ywz4YReKfNkvg8JvdaUut1tPyUpxi//SH5OM4FbOY2Q6YnzwhSK 7YjWOVw+sUaVZYZFs8Gfr32MwQ== X-Received: by 2002:a17:902:ce8c:b0:1cc:e66:f994 with SMTP id f12-20020a170902ce8c00b001cc0e66f994mr1134570plg.1.1699928094262; Mon, 13 Nov 2023 18:14:54 -0800 (PST) Received: from octopus.. ([2400:4050:c3e1:100:66f2:cd5c:3d82:6e6f]) by smtp.gmail.com with ESMTPSA id i4-20020a170902c94400b001c61afa7009sm4680475pla.114.2023.11.13.18.14.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Nov 2023 18:14:54 -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 v3 5/5] test: dm: add scmi command test Date: Tue, 14 Nov 2023 11:14:28 +0900 Message-Id: <20231114021428.531887-6-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231114021428.531887-1-takahiro.akashi@linaro.org> References: <20231114021428.531887-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 --- v9 * return -EAGAIN if we want to skip a test * use CONFIG_IS_ENABLED() rather than IS_ENABLED() 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 582485471fff..e80667ef72a3 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 (!CONFIG_IS_ENABLED(CMD_SCMI)) + return -EAGAIN; + + /* 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 (CONFIG_IS_ENABLED(POWER_DOMAIN)) + num_proto++; + if (CONFIG_IS_ENABLED(CLK_SCMI)) + num_proto++; + if (CONFIG_IS_ENABLED(RESET_SCMI)) + num_proto++; + if (CONFIG_IS_ENABLED(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 (CONFIG_IS_ENABLED(SCMI_POWER_DOMAIN)) + ut_assert_nextline(" Power domain management"); + if (CONFIG_IS_ENABLED(CLK_SCMI)) + ut_assert_nextline(" Clock management"); + if (CONFIG_IS_ENABLED(RESET_SCMI)) + ut_assert_nextline(" Reset domain management"); + if (CONFIG_IS_ENABLED(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;