From patchwork Wed Jun 28 00:48:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 697203 Delivered-To: patch@linaro.org Received: by 2002:adf:e885:0:0:0:0:0 with SMTP id d5csp4080170wrm; Tue, 27 Jun 2023 17:50:15 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7k4VIfVto+bEZevtUHAVf9i0CsVdamH0gYy/IxuT46OhWr+Vge1PqcQEKO1F23Rjv8go/P X-Received: by 2002:a05:6512:33cf:b0:4f9:74b3:dee8 with SMTP id d15-20020a05651233cf00b004f974b3dee8mr10132093lfg.15.1687913415320; Tue, 27 Jun 2023 17:50:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687913415; cv=none; d=google.com; s=arc-20160816; b=CAeF+howC0Nl3R1moCAfiegtxkILFQOBECxV7CMrI+ZHIJ/QvxRjTVG+0tLCMQD7a6 6vL7TYAy1maVYJO4B+5cyS2YCQK7tG6mnOlHZenNdMGlblkg1e7ijD8Gg7BAAdeNJNW6 fbBydYkG1QCGQP7I0CONpndAIqmCJhsWdhSjiUFLjfpbpUlq/UPnAKDg3yddjVCvO/tk Wjy4Pj7lMIaOqklV6jQxxvq4x0OrOlC2Omux7kf32eZ/ICsdGAx9Uz8nmKFp8uXhCvOU qfJ9z4P5hs68HdOA7+QG41t/ZMLQKsp7pi8/XaxwZQ9RWYGvb7No6IT1HQOt2OU1no61 1Xgw== 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=wUERDMnx2MAtzW+c7TrgxZhn94CPs/Fg4n/Wz7nEEFA=; fh=+s9SE2w9oguEKAMcR35TXtqntCOeVFhiK9u/Kju91lo=; b=GsDqkbpqZ53h0M/+dWOd2xo6KBmmEjrkVvYuAV9k8K9pTXgPFq9ZIsHTY6s/N4pGVf Kd7CSftM5eG/DPtD9ZfYAaqKwWnRre1PoqhpS77Kys6JLEXOEYcAv4PVblb15lzjl5Ao u9ofC6n8r45PTnUbomty34fycCDOg2mVi+NybLhgnbPgtfk3yutyo8EyqRLhvkaSdyT4 ltWkAMGTDpR5/WBlkTFcdk1bFDZY0NlDhmJ5mWjvSrsk01aQEjWz4EpSW8vg1n8zTV0m VFs00BaUqJr440tN+/j6NFjiPIJzWza5F/pBHSQ4AbxdeC2oE+BxzAc+WcJg4lbOwI5s VkOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DEKQOY+C; 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 d13-20020ac241cd000000b004f860a146cfsi2601087lfi.143.2023.06.27.17.50.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Jun 2023 17:50:15 -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=DEKQOY+C; 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 2CA8E86625; Wed, 28 Jun 2023 02:49:59 +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="DEKQOY+C"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9880E865F1; Wed, 28 Jun 2023 02:49:44 +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, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) (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 4B36B86380 for ; Wed, 28 Jun 2023 02:49:34 +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-x432.google.com with SMTP id d2e1a72fcca58-66872dbc2efso1324821b3a.0 for ; Tue, 27 Jun 2023 17:49:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1687913372; x=1690505372; 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=wUERDMnx2MAtzW+c7TrgxZhn94CPs/Fg4n/Wz7nEEFA=; b=DEKQOY+C7hFFHnI9+NWQdrmJ+sU9CcBggog6WHhT6msmItJ5epyDzdoYLd4iFiHWBj LOy9dLtEj889pFc3t1yzQIX1/ZOgKYyZGPm334YPrT4lmzPEy8TMrcgtloFfp/qd60FA gKi31Po79Kb0+WiUzi+BXKVm+OakRmenOkJY38QcT9gnbgU5DcKwa3d1GHkQWQTPWfer Szk2dkybaVrCrDncLGCwRz9xxEBb0xlsS7fQSzoue3XNg92ANVyq9814JNqmpQe8CPTd Ndl9ZrolkP1BDA7nBLzuITGwVioNEn9/3DVkGGF7pr2cag461Rl9Y0kO9uDSBRLVJ3Dy y0Yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687913372; x=1690505372; 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=wUERDMnx2MAtzW+c7TrgxZhn94CPs/Fg4n/Wz7nEEFA=; b=LNkk7pRpJfPEeKclCf/fKtRvIYh1pynICl0qa//0zSTYwE/Jk1g5zsznE8bTpTxKt2 vZ4yWmJaz4xZygmj1W8v4djptaJaZoZPTDUYXJne0JLWTuklvZiN3pA5ygQXXIO5cAYe 2IwSXWIlMvcKWx5zzsuR9hSiq7pARyiCUlUT497wS/AKdU+DriIC0DkHLny0qtJG8WzT pvhVn+MrrJXsvKvRDOwe/RxqP40wKsoRYVLexGs+5zaaY1qpV+IsOi3ttei07fASbry9 I7cFoB6un2g2D+OrrOvFrcA+cCTVQzcaUnAQXmy3AwCOmXRFAriZy+TErtvclJ9RPqgF 721A== X-Gm-Message-State: AC+VfDy5xaVP56K74wuLplE7LMXbROiChYW4zceSUr1KgQMQWEzEEA98 mG7/FhAbyLZ8RDTMCiFxJJvmzg== X-Received: by 2002:a05:6a20:8e18:b0:11a:dbb3:703b with SMTP id y24-20020a056a208e1800b0011adbb3703bmr4732875pzj.6.1687913372429; Tue, 27 Jun 2023 17:49:32 -0700 (PDT) Received: from laputa.. ([2400:4050:c3e1:100:58b2:60ed:38ea:8b1f]) by smtp.gmail.com with ESMTPSA id u13-20020a170903124d00b001b3fb2f0296sm6517278plh.120.2023.06.27.17.49.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Jun 2023 17:49:32 -0700 (PDT) From: AKASHI Takahiro To: trini@konsulko.com, sjg@chromium.org Cc: etienne.carriere@st.com, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH 01/10] firmware: scmi: implement SCMI base protocol Date: Wed, 28 Jun 2023 09:48:32 +0900 Message-ID: <20230628004841.21774-2-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230628004841.21774-1-takahiro.akashi@linaro.org> References: <20230628004841.21774-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 SCMI base protocol is mandatory according to the SCMI specification. With this patch, SCMI base protocol can be accessed via SCMI transport layers. All the commands, except SCMI_BASE_NOTIFY_ERRORS, are supported. This is because U-Boot doesn't support interrupts and the current transport layers are not able to handle asynchronous messages properly. Signed-off-by: AKASHI Takahiro --- drivers/firmware/scmi/Makefile | 1 + drivers/firmware/scmi/base.c | 517 +++++++++++++++++++++++++++++++++ include/dm/uclass-id.h | 1 + include/scmi_protocols.h | 201 ++++++++++++- 4 files changed, 718 insertions(+), 2 deletions(-) create mode 100644 drivers/firmware/scmi/base.c diff --git a/drivers/firmware/scmi/Makefile b/drivers/firmware/scmi/Makefile index b2ff483c75a1..1a23d4981709 100644 --- a/drivers/firmware/scmi/Makefile +++ b/drivers/firmware/scmi/Makefile @@ -1,4 +1,5 @@ obj-y += scmi_agent-uclass.o +obj-y += base.o obj-y += smt.o obj-$(CONFIG_SCMI_AGENT_SMCCC) += smccc_agent.o obj-$(CONFIG_SCMI_AGENT_MAILBOX) += mailbox_agent.o diff --git a/drivers/firmware/scmi/base.c b/drivers/firmware/scmi/base.c new file mode 100644 index 000000000000..04018eb6ecf3 --- /dev/null +++ b/drivers/firmware/scmi/base.c @@ -0,0 +1,517 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * SCMI Base protocol as U-Boot device + * + * Copyright (C) 2023 Linaro Limited + * author: AKASHI Takahiro + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +/** + * struct scmi_base_priv - Private data for SCMI base protocol + * @channel: Reference to the SCMI channel to use + */ +struct scmi_base_priv { + struct scmi_channel *channel; +}; + +/** + * scmi_protocol_version - get protocol version + * @dev: Device + * @version: Pointer to protocol version + * + * Obtain the protocol version number in @version. + * + * Return: 0 on success, error code otherwise + */ +static int scmi_protocol_version(struct udevice *dev, u32 *version) +{ + struct scmi_base_priv *priv = dev_get_priv(dev); + struct scmi_protocol_version_out out; + struct scmi_msg msg = { + .protocol_id = SCMI_PROTOCOL_ID_BASE, + .message_id = SCMI_PROTOCOL_VERSION, + .out_msg = (u8 *)&out, + .out_msg_sz = sizeof(out), + }; + int ret; + + ret = devm_scmi_process_msg(dev, priv->channel, &msg); + if (ret) + return ret; + if (out.status) + return scmi_to_linux_errno(out.status); + + *version = out.version; + + return 0; +} + +/** + * scmi_protocol_attrs - get protocol attributes + * @dev: Device + * @num_agents: Number of agents + * @num_protocols: Number of protocols + * + * Obtain the protocol attributes, the number of agents and the number + * of protocols, in @num_agents and @num_protocols respectively, that + * the device provides. + * + * Return: 0 on success, error code otherwise + */ +static int scmi_protocol_attrs(struct udevice *dev, u32 *num_agents, + u32 *num_protocols) +{ + struct scmi_base_priv *priv = dev_get_priv(dev); + struct scmi_protocol_attrs_out out; + struct scmi_msg msg = { + .protocol_id = SCMI_PROTOCOL_ID_BASE, + .message_id = SCMI_PROTOCOL_ATTRIBUTES, + .out_msg = (u8 *)&out, + .out_msg_sz = sizeof(out), + }; + int ret; + + ret = devm_scmi_process_msg(dev, priv->channel, &msg); + if (ret) + return ret; + if (out.status) + return scmi_to_linux_errno(out.status); + + *num_agents = SCMI_PROTOCOL_ATTRS_NUM_AGENTS(out.attributes); + *num_protocols = SCMI_PROTOCOL_ATTRS_NUM_PROTOCOLS(out.attributes); + + return 0; +} + +/** + * scmi_protocol_message_attrs - get message-specific attributes + * @dev: Device + * @message_id: Identifier of message + * @attributes: Message-specific attributes + * + * Obtain the message-specific attributes in @attributes. + * This command succeeds if the message is implemented and available. + * + * Return: 0 on success, error code otherwise + */ +static int scmi_protocol_message_attrs(struct udevice *dev, u32 message_id, + u32 *attributes) +{ + struct scmi_base_priv *priv = dev_get_priv(dev); + struct scmi_protocol_msg_attrs_out out; + struct scmi_msg msg = { + .protocol_id = SCMI_PROTOCOL_ID_BASE, + .message_id = SCMI_PROTOCOL_MESSAGE_ATTRIBUTES, + .in_msg = (u8 *)&message_id, + .in_msg_sz = sizeof(message_id), + .out_msg = (u8 *)&out, + .out_msg_sz = sizeof(out), + }; + int ret; + + ret = devm_scmi_process_msg(dev, priv->channel, &msg); + if (ret) + return ret; + if (out.status) + return scmi_to_linux_errno(out.status); + + *attributes = out.attributes; + + return 0; +} + +/** + * scmi_base_discover_vendor - get vendor name + * @dev: Device + * @vendor: Vendor name + * + * Obtain the vendor's name in @vendor. + * + * Return: 0 on success, error code otherwise + */ +static int scmi_base_discover_vendor(struct udevice *dev, u8 *vendor) +{ + struct scmi_base_priv *priv = dev_get_priv(dev); + struct scmi_base_discover_vendor_out out; + struct scmi_msg msg = { + .protocol_id = SCMI_PROTOCOL_ID_BASE, + .message_id = SCMI_BASE_DISCOVER_VENDOR, + .out_msg = (u8 *)&out, + .out_msg_sz = sizeof(out), + }; + int ret; + + ret = devm_scmi_process_msg(dev, priv->channel, &msg); + if (ret) + return ret; + if (out.status) + return scmi_to_linux_errno(out.status); + + strcpy(vendor, out.vendor_identifier); + + return 0; +} + +/** + * scmi_base_discover_sub_vendor - get sub-vendor name + * @dev: Device + * @sub_vendor: Sub-vendor name + * + * Obtain the sub-vendor's name in @sub_vendor. + * + * Return: 0 on success, error code otherwise + */ +static int scmi_base_discover_sub_vendor(struct udevice *dev, u8 *sub_vendor) +{ + struct scmi_base_priv *priv = dev_get_priv(dev); + struct scmi_base_discover_vendor_out out; + struct scmi_msg msg = { + .protocol_id = SCMI_PROTOCOL_ID_BASE, + .message_id = SCMI_BASE_DISCOVER_SUB_VENDOR, + .out_msg = (u8 *)&out, + .out_msg_sz = sizeof(out), + }; + int ret; + + ret = devm_scmi_process_msg(dev, priv->channel, &msg); + if (ret) + return ret; + if (out.status) + return scmi_to_linux_errno(out.status); + + strcpy(sub_vendor, out.vendor_identifier); + + return 0; +} + +/** + * scmi_base_discover_impl_version - get implementation version + * @dev: Device + * @impl_version: Pointer to implementation version + * + * Obtain the implementation version number in @impl_version. + * + * Return: 0 on success, error code otherwise + */ +static int scmi_base_discover_impl_version(struct udevice *dev, u32 *impl_version) +{ + struct scmi_base_priv *priv = dev_get_priv(dev); + struct scmi_base_discover_impl_version_out out; + struct scmi_msg msg = { + .protocol_id = SCMI_PROTOCOL_ID_BASE, + .message_id = SCMI_BASE_DISCOVER_IMPL_VERSION, + .out_msg = (u8 *)&out, + .out_msg_sz = sizeof(out), + }; + int ret; + + ret = devm_scmi_process_msg(dev, priv->channel, &msg); + if (ret) + return ret; + if (out.status) + return scmi_to_linux_errno(out.status); + + *impl_version = out.impl_version; + + return 0; +} + +/** + * scmi_base_discover_list_protocols - get list of protocols + * @dev: Device + * @protocols: Pointer to array of protocols + * + * Obtain the list of protocols provided in @protocols. + * The number of elements in @protocols always match to the number of + * protocols returned by smci_protocol_attrs() when this function succeeds. + * It is a caller's responsibility to free @protocols. + * + * Return: the number of protocols in @protocols on success, error code otherwise + */ +static int scmi_base_discover_list_protocols(struct udevice *dev, u8 **protocols) +{ + struct scmi_base_priv *priv = dev_get_priv(dev); + struct scmi_base_discover_list_protocols_out out; + int cur; + struct scmi_msg msg = { + .protocol_id = SCMI_PROTOCOL_ID_BASE, + .message_id = SCMI_BASE_DISCOVER_LIST_PROTOCOLS, + .in_msg = (u8 *)&cur, + .in_msg_sz = sizeof(cur), + .out_msg = (u8 *)&out, + .out_msg_sz = sizeof(out), + }; + u32 num_agents, num_protocols; + u8 *buf; + int i, ret; + + ret = scmi_protocol_attrs(dev, &num_agents, &num_protocols); + if (ret) + return ret; + + buf = calloc(sizeof(u8), num_protocols); + if (!buf) + return -ENOMEM; + + cur = 0; + do { + ret = devm_scmi_process_msg(dev, priv->channel, &msg); + if (ret) + goto err; + if (out.status) { + ret = scmi_to_linux_errno(out.status); + goto err; + } + + for (i = 0; i < out.num_protocols; i++, cur++) + buf[cur] = out.protocols[i / 4] >> ((i % 4) * 8); + } while (cur < num_protocols); + + *protocols = buf; + + return num_protocols; +err: + free(buf); + + return ret; +} + +/** + * scmi_base_discover_agent - identify agent + * @dev: Device + * @agent_id: Identifier of agent + * @ret_agent_id: Pointer to identifier of agent + * @name: Agent name + * + * Obtain the agent's name in @name. If @agent_id is equal to 0xffffffff, + * this function returns the caller's agent id in @ret_agent_id. + * + * Return: 0 on success, error code otherwise + */ +static int scmi_base_discover_agent(struct udevice *dev, u32 agent_id, + u32 *ret_agent_id, u8 *name) +{ + struct scmi_base_priv *priv = dev_get_priv(dev); + struct scmi_base_discover_agent_out out; + struct scmi_msg msg = { + .protocol_id = SCMI_PROTOCOL_ID_BASE, + .message_id = SCMI_BASE_DISCOVER_AGENT, + .in_msg = (u8 *)&agent_id, + .in_msg_sz = sizeof(agent_id), + .out_msg = (u8 *)&out, + .out_msg_sz = sizeof(out), + }; + int ret; + + ret = devm_scmi_process_msg(dev, priv->channel, &msg); + if (ret) + return ret; + if (out.status) + return scmi_to_linux_errno(out.status); + + strcpy(name, out.name); + *ret_agent_id = out.agent_id; + + return 0; +} + +/** + * scmi_base_notify_errors - configure error notification + * @dev: Device + * @enable: Operation + * + * This function is not yet implemented. + * + * Return: always -EOPNOTSUPP + */ +static int scmi_base_notify_errors(struct udevice *dev, u32 enable) +{ + return -EOPNOTSUPP; +} + +/** + * scmi_base_set_device_permissions - configure access permission to device + * @dev: Device + * @agent_id: Identifier of agent + * @device_id: Identifier of device to access + * @flags: A set of flags + * + * Ask for allowing or denying access permission to the device, @device_id. + * The meaning of @flags is defined in SCMI specification. + * + * Return: 0 on success, error code otherwise + */ +static int scmi_base_set_device_permissions(struct udevice *dev, u32 agent_id, + u32 device_id, u32 flags) +{ + struct scmi_base_priv *priv = dev_get_priv(dev); + struct scmi_base_set_device_permissions_in in = { + .agent_id = agent_id, + .device_id = device_id, + .flags = flags, + }; + s32 status; + struct scmi_msg msg = { + .protocol_id = SCMI_PROTOCOL_ID_BASE, + .message_id = SCMI_BASE_SET_DEVICE_PERMISSIONS, + .in_msg = (u8 *)&in, + .in_msg_sz = sizeof(in), + .out_msg = (u8 *)&status, + .out_msg_sz = sizeof(status), + }; + int ret; + + ret = devm_scmi_process_msg(dev, priv->channel, &msg); + if (ret) + return ret; + if (status) + return scmi_to_linux_errno(status); + + return 0; +} + +/** + * scmi_base_set_protocol_permissions - configure access permission to protocol + on device + * @dev: Device + * @agent_id: Identifier of agent + * @device_id: Identifier of device to access + * @command_id: Identifier of command + * @flags: A set of flags + * + * Ask for allowing or denying access permission to the protocol, @command_id, + * on the device, @device_id. + * The meaning of @flags is defined in SCMI specification. + * + * Return: 0 on success, error code otherwise + */ +static int scmi_base_set_protocol_permissions(struct udevice *dev, u32 agent_id, + u32 device_id, u32 command_id, + u32 flags) +{ + struct scmi_base_priv *priv = dev_get_priv(dev); + struct scmi_base_set_protocol_permissions_in in = { + .agent_id = agent_id, + .device_id = device_id, + .command_id = command_id, + .flags = flags, + }; + s32 status; + struct scmi_msg msg = { + .protocol_id = SCMI_PROTOCOL_ID_BASE, + .message_id = SCMI_BASE_SET_PROTOCOL_PERMISSIONS, + .in_msg = (u8 *)&in, + .in_msg_sz = sizeof(in), + .out_msg = (u8 *)&status, + .out_msg_sz = sizeof(status), + }; + int ret; + + ret = devm_scmi_process_msg(dev, priv->channel, &msg); + if (ret) + return ret; + if (status) + return scmi_to_linux_errno(status); + + return 0; +} + +/** + * scmi_base_reset_agent_configuration - reset resource settings + * @dev: Device + * @agent_id: Identifier of agent + * @flags: A set of flags + * + * Ask for allowing or denying access permission to the protocol, @command_id, + * on the device, @device_id. + * The meaning of @flags is defined in SCMI specification. + * + * Return: 0 on success, error code otherwise + */ +static int scmi_base_reset_agent_configuration(struct udevice *dev, u32 agent_id, + u32 flags) +{ + struct scmi_base_priv *priv = dev_get_priv(dev); + struct scmi_base_reset_agent_configuration_in in = { + .agent_id = agent_id, + .flags = flags, + }; + s32 status; + struct scmi_msg msg = { + .protocol_id = SCMI_PROTOCOL_ID_BASE, + .message_id = SCMI_BASE_RESET_AGENT_CONFIGURATION, + .in_msg = (u8 *)&in, + .in_msg_sz = sizeof(in), + .out_msg = (u8 *)&status, + .out_msg_sz = sizeof(status), + }; + int ret; + + ret = devm_scmi_process_msg(dev, priv->channel, &msg); + if (ret) + return ret; + if (status) + return scmi_to_linux_errno(status); + + return 0; +} + +/** + * scmi_base_probe - probe base protocol device + * @dev: Device + * + * Probe the device for SCMI base protocol and initialize the private data. + * + * Return: 0 on success, error code otherwise + */ +static int scmi_base_probe(struct udevice *dev) +{ + struct scmi_base_priv *priv = dev_get_priv(dev); + int ret; + + ret = devm_scmi_of_get_channel(dev, &priv->channel); + if (ret) { + dev_err(dev, "get_channel failed\n"); + return ret; + } + + return ret; +} + +struct scmi_base_ops scmi_base_ops = { + /* Commands */ + .protocol_version = scmi_protocol_version, + .protocol_attrs = scmi_protocol_attrs, + .protocol_message_attrs = scmi_protocol_message_attrs, + .base_discover_vendor = scmi_base_discover_vendor, + .base_discover_sub_vendor = scmi_base_discover_sub_vendor, + .base_discover_impl_version = scmi_base_discover_impl_version, + .base_discover_list_protocols = scmi_base_discover_list_protocols, + .base_discover_agent = scmi_base_discover_agent, + .base_notify_errors = scmi_base_notify_errors, + .base_set_device_permissions = scmi_base_set_device_permissions, + .base_set_protocol_permissions = scmi_base_set_protocol_permissions, + .base_reset_agent_configuration = scmi_base_reset_agent_configuration, +}; + +U_BOOT_DRIVER(scmi_base_drv) = { + .id = UCLASS_SCMI_BASE, + .name = "scmi_base_drv", + .ops = &scmi_base_ops, + .probe = scmi_base_probe, + .priv_auto = sizeof(struct scmi_base_priv *), +}; + +UCLASS_DRIVER(scmi_base) = { + .id = UCLASS_SCMI_BASE, + .name = "scmi_base", +}; diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h index 307ad6931ca7..f7a110852321 100644 --- a/include/dm/uclass-id.h +++ b/include/dm/uclass-id.h @@ -116,6 +116,7 @@ enum uclass_id { UCLASS_RNG, /* Random Number Generator */ UCLASS_RTC, /* Real time clock device */ UCLASS_SCMI_AGENT, /* Interface with an SCMI server */ + UCLASS_SCMI_BASE, /* Interface for SCMI Base protocol */ UCLASS_SCSI, /* SCSI device */ UCLASS_SERIAL, /* Serial UART */ UCLASS_SIMPLE_BUS, /* Bus with child devices */ diff --git a/include/scmi_protocols.h b/include/scmi_protocols.h index a220cb2a91ad..769041654534 100644 --- a/include/scmi_protocols.h +++ b/include/scmi_protocols.h @@ -15,6 +15,8 @@ * https://developer.arm.com/docs/den0056/b */ +#define SCMI_BASE_NAME_LENGTH_MAX 16 + enum scmi_std_protocol { SCMI_PROTOCOL_ID_BASE = 0x10, SCMI_PROTOCOL_ID_POWER_DOMAIN = 0x11, @@ -41,12 +43,207 @@ enum scmi_status_code { }; /* - * Generic message IDs + * SCMI Base Protocol */ -enum scmi_discovery_id { +#define SCMI_BASE_PROTOCOL_VERSION 0x20000 + +enum scmi_base_message_id { SCMI_PROTOCOL_VERSION = 0x0, SCMI_PROTOCOL_ATTRIBUTES = 0x1, SCMI_PROTOCOL_MESSAGE_ATTRIBUTES = 0x2, + SCMI_BASE_DISCOVER_VENDOR = 0x3, + SCMI_BASE_DISCOVER_SUB_VENDOR = 0x4, + SCMI_BASE_DISCOVER_IMPL_VERSION = 0x5, + SCMI_BASE_DISCOVER_LIST_PROTOCOLS = 0x6, + SCMI_BASE_DISCOVER_AGENT = 0x7, + SCMI_BASE_NOTIFY_ERRORS = 0x8, + SCMI_BASE_SET_DEVICE_PERMISSIONS = 0x9, + SCMI_BASE_SET_PROTOCOL_PERMISSIONS = 0xa, + SCMI_BASE_RESET_AGENT_CONFIGURATION = 0xb, +}; + +/** + * struct scmi_protocol_version_out - Response for SCMI_PROTOCOL_VERSION + * command + * @status: SCMI command status + * @version: Protocol version + */ +struct scmi_protocol_version_out { + s32 status; + u32 version; +}; + +/** + * struct scmi_protocol_attrs_out - Response for SCMI_PROTOCOL_ATTRIBUTES + * command + * @status: SCMI command status + * @attributes: Protocol attributes or implementation details + */ +struct scmi_protocol_attrs_out { + s32 status; + u32 attributes; +}; + +#define SCMI_PROTOCOL_ATTRS_NUM_AGENTS(attributes) \ + (((attributes) & GENMASK(15, 8)) >> 8) +#define SCMI_PROTOCOL_ATTRS_NUM_PROTOCOLS(attributes) \ + ((attributes) & GENMASK(7, 0)) + +/** + * struct scmi_protocol_msg_attrs_out - Response for + * SCMI_PROTOCOL_MESSAGE_ATTRIBUTES command + * @status: SCMI command status + * @attributes: Message-specific attributes + */ +struct scmi_protocol_msg_attrs_out { + s32 status; + u32 attributes; +}; + +/** + * struct scmi_base_discover_vendor_out - Response for + * SCMI_BASE_DISCOVER_VENDOR or + * SCMI_BASE_DISCOVER_SUB_VENDOR command + * @status: SCMI command status + * @vendor_identifier: Identifier of vendor or sub-vendor in string + */ +struct scmi_base_discover_vendor_out { + s32 status; + u8 vendor_identifier[SCMI_BASE_NAME_LENGTH_MAX]; +}; + +/** + * struct scmi_base_discover_impl_version_out - Response for + * SCMI_BASE_DISCOVER_IMPL_VERSION command + * @status: SCMI command status + * @impl_version: Vendor-specific implementation version + */ +struct scmi_base_discover_impl_version_out { + s32 status; + u32 impl_version; +}; + +/** + * struct scmi_base_discover_list_protocols_out - Response for + * SCMI_BASE_DISCOVER_LIST_PROTOCOLS command + * @status: SCMI command status + * @num_protocols: Number of protocols in @protocol + * @protocols: Array of packed protocol ID's + */ +struct scmi_base_discover_list_protocols_out { + s32 status; + u32 num_protocols; + u32 protocols[3]; +}; + +/** + * struct scmi_base_discover_agent_out - Response for + * SCMI_BASE_DISCOVER_AGENT command + * @status: SCMI command status + * @agent_id: Identifier of agent + * @name: Name of agent in string + */ +struct scmi_base_discover_agent_out { + s32 status; + u32 agent_id; + u8 name[SCMI_BASE_NAME_LENGTH_MAX]; +}; + +#define SCMI_BASE_NOTIFY_ERRORS_ENABLE BIT(0) + +/** + * struct scmi_base_set_device_permissions_in - Parameters for + * SCMI_BASE_SET_DEVICE_PERMISSIONS command + * @agent_id: Identifier of agent + * @device_id: Identifier of device + * @flags: A set of flags + */ +struct scmi_base_set_device_permissions_in { + u32 agent_id; + u32 device_id; + u32 flags; +}; + +#define SCMI_BASE_SET_DEVICE_PERMISSIONS_ACCESS BIT(0) + +/** + * struct scmi_base_set_protocol_permissions_in - Parameters for + * SCMI_BASE_SET_PROTOCOL_PERMISSIONS command + * @agent_id: Identifier of agent + * @device_id: Identifier of device + * @command_id: Identifier of command + * @flags: A set of flags + */ +struct scmi_base_set_protocol_permissions_in { + u32 agent_id; + u32 device_id; + u32 command_id; + u32 flags; +}; + +#define SCMI_BASE_SET_PROTOCOL_PERMISSIONS_COMMAND GENMASK(7, 0) +#define SCMI_BASE_SET_PROTOCOL_PERMISSIONS_ACCESS BIT(0) + +/** + * struct scmi_base_reset_agent_configuration_in - Parameters for + * SCMI_BASE_RESET_AGENT_CONFIGURATION command + * @agent_id: Identifier of agent + * @flags: A set of flags + */ +struct scmi_base_reset_agent_configuration_in { + u32 agent_id; + u32 flags; +}; + +#define SCMI_BASE_RESET_ALL_ACCESS_PERMISSIONS BIT(0) + +/** + * struct scmi_base_ops - SCMI base protocol interfaces + * @protocol_version: Function pointer for + * PROTOCOL_VERSION + * @protocol_attrs: Function pointer for + * PROTOCOL_ATTRIBUTES + * @protocol_message_attrs: Function pointer for + * PROTOCOL_MESSAGE_ATTRIBUTES + * @base_discover_vendor: Function pointer for + * BASE_DISCOVER_VENDOR + * @base_discover_sub_vendor: Function pointer for + * BASE_DISCOVER_SUB_VENDOR + * @base_discover_impl_version: Function pointer for + * BASE_DISCOVER_IMPLEMENTATION_VERSION + * @base_discover_list_protocols: Function pointer for + * BASE_DISCOVER_LIST_PROTOCOLS + * @base_discover_agent: Function pointer for + * BASE_DISCOVER_AGENT + * @base_notify_errors: Function pointer for + * BASE_NOTIFY_ERRORS + * @base_set_device_permissions: Function pointer for + * BASE_SET_DEVICE_PROTOCOLS + * @base_set_protocol_permissions: Function pointer for + * BASE_SET_PROTOCOL_PERMISSIONS + * @base_reset_agent_configuration: Function pointer for + * BASE_RESET_AGENT_CONFIGURATION + */ +struct scmi_base_ops { + int (*protocol_version)(struct udevice *dev, u32 *version); + int (*protocol_attrs)(struct udevice *dev, u32 *num_agents, + u32 *num_protocols); + int (*protocol_message_attrs)(struct udevice *dev, u32 message_id, + u32 *attributes); + int (*base_discover_vendor)(struct udevice *dev, u8 *vendor); + int (*base_discover_sub_vendor)(struct udevice *dev, u8 *sub_vendor); + int (*base_discover_impl_version)(struct udevice *dev, u32 *impl_version); + int (*base_discover_list_protocols)(struct udevice *dev, u8 **protocols); + int (*base_discover_agent)(struct udevice *dev, u32 agent_id, + u32 *ret_agent_id, u8 *name); + int (*base_notify_errors)(struct udevice *dev, u32 enable); + int (*base_set_device_permissions)(struct udevice *dev, u32 agent_id, + u32 device_id, u32 flags); + int (*base_set_protocol_permissions)(struct udevice *dev, u32 agent_id, + u32 device_id, u32 command_id, + u32 flags); + int (*base_reset_agent_configuration)(struct udevice *dev, u32 agent_id, + u32 flags); }; /* From patchwork Wed Jun 28 00:48:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 697202 Delivered-To: patch@linaro.org Received: by 2002:adf:e885:0:0:0:0:0 with SMTP id d5csp4080087wrm; Tue, 27 Jun 2023 17:49:54 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ68poidTr2lUgY0gGlIAnT7GuaL8Ukeb6/5O4hIn5MAsDYmJ9E2ZLmMugljkVxnohRIIroe X-Received: by 2002:a05:6512:3d25:b0:4fb:7b2a:78de with SMTP id d37-20020a0565123d2500b004fb7b2a78demr5622224lfv.45.1687913394596; Tue, 27 Jun 2023 17:49:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687913394; cv=none; d=google.com; s=arc-20160816; b=Tuh+wYhDkgBz4cz/CNNYyixu7tsHRU3N1VbM278SoRfNk7tUqIJCvrEOHSbrR4lQSg CJ/GRHiSIhslQy+/pKXCX/s/J9DjFmmgjcnCvFDVk/UA5DJ8/MRl8egAsSxzzdHpyuIJ TjW1ca5Tfao7OFehv0S2wHPocqz2tZVEtjkx9PyKhhB8TwF52jjavF0xslwW8R1rV42b TbO7BT3Hb/X0gRTcpmLzaf+vkaEMpj/0r4MkcQWYGbUyL59fZfeByElVcxiG0/G6myyD STPBrDp+pGojfZ18iRqyHl8smjCEGvAobUvbEe2IU4twu8ye7LXTl71VGwO7fSVw0QDz ca1A== 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=V0v+A+makEI14KDnzMTnkzMrbzEEb7geWvIieba4deA=; fh=+s9SE2w9oguEKAMcR35TXtqntCOeVFhiK9u/Kju91lo=; b=j+taFUjQppQGMX4+xj9jjJfEr+rv9L4P3ItyAbEryoLCMnMM8cyn6axj3Ggb7DEUNS iVKRa9v1AeShEEVECcrqBz2mPwXhFaa8ZiFb+TebHHCI8OW6o4GTJqaG9Lij99ZLUHfa M14ym7tTiPjfzBS4YQGGJLwJQtm0tu0QU7QnfLL5Mnoq7vbIvyu4LpfMeZgt1nlNrDmK jkiq4RBUoNd/FVGnQh0NAWFgn1JuAtkjMDuplAO5ef1OGDloPO82oJLgL9iDCSZUCayN 4cDETczLCUsAW8JqMVvGFp7mukC/XZ09fFR8Wlk2OvUicTF/9C+ru9DLeazKhpqZsBcR ZrGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IeXock4M; 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 m17-20020a056512015100b004f621c06aa9si2621588lfo.586.2023.06.27.17.49.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Jun 2023 17:49:54 -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=IeXock4M; 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 1042086614; Wed, 28 Jun 2023 02:49:46 +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="IeXock4M"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B0A9B86609; Wed, 28 Jun 2023 02:49:42 +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, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) (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 25C23865EC for ; Wed, 28 Jun 2023 02:49:36 +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-x633.google.com with SMTP id d9443c01a7336-1b8130e0ac6so3019385ad.1 for ; Tue, 27 Jun 2023 17:49:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1687913374; x=1690505374; 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=V0v+A+makEI14KDnzMTnkzMrbzEEb7geWvIieba4deA=; b=IeXock4MwUjB4cAQeQkNW9LDwQxvMw+6S/cQsTdFNPhBcq0zWUgfK9+Vy/0ieiOdDQ oJ/p4Sni0yJ98ouyVRaqeu8Ky+sqceDn5RW9SVY75BQi/dJH6KdIIl/JnOjgX3A8Bc0C XhOloiXI/IJth0+C3W2iE/g5bFLcnNg672EzjpOwAE3Jig2ar/kjv8+LzTNUHWDOagGY kRzXVcmsyBLRxzM3qVWWGv9dLoELItyFhEF2q127YqGGvnqTihnmY3SyNISvT+KvcfO3 JatSV38rss5LEJT1Kq1bk4NYz+NSN632Pq3Gxj7VscUGr/c77UqLtzD0WDFKOnaEyDPN Sh4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687913374; x=1690505374; 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=V0v+A+makEI14KDnzMTnkzMrbzEEb7geWvIieba4deA=; b=fN9ZFxCsJCNBSQC0B7NGfSp8IFuGTpuYGw49bAfVnaJGQ5/wzkiuCKSFonXCIgO4Yb koKXtXSx73YKdFJjAQvw/E1RRj7wmcK4IGpwGcs/JS8Ldr9thF/tcKwf1F4MQwVlgQnk n6QM4NIPyY9kFIBfPFs1KxNaAHaEVCbbgj3tG7tFSGJ7r6i4Rz1k/a30OS4r+hmv17w3 Han7dwsqwFoGzBSQdpoKl5i/686KqZOjueDXMSGfPTqQljUZFO280LUOr+/U41jbMmUa S8VyzWvUhdzCYaIo6EXzC/qn07MSZeHBZBhFXDWUx8mTuz7RTkaXZR6kwZ6eEEXNCDsN uq0g== X-Gm-Message-State: AC+VfDxH33uum215JcPUXA8MBlx7W1FbK74i1CZ2eKtA7F2PN4YTXdb7 Xlz0aB3wlcogxPKPp9jbw3uNtg== X-Received: by 2002:a17:902:d552:b0:1b3:ec39:f42c with SMTP id z18-20020a170902d55200b001b3ec39f42cmr3343901plf.5.1687913374422; Tue, 27 Jun 2023 17:49:34 -0700 (PDT) Received: from laputa.. ([2400:4050:c3e1:100:58b2:60ed:38ea:8b1f]) by smtp.gmail.com with ESMTPSA id u13-20020a170903124d00b001b3fb2f0296sm6517278plh.120.2023.06.27.17.49.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Jun 2023 17:49:34 -0700 (PDT) From: AKASHI Takahiro To: trini@konsulko.com, sjg@chromium.org Cc: etienne.carriere@st.com, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH 02/10] firmware: scmi: framework for installing additional protocols Date: Wed, 28 Jun 2023 09:48:33 +0900 Message-ID: <20230628004841.21774-3-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230628004841.21774-1-takahiro.akashi@linaro.org> References: <20230628004841.21774-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 framework allows SCMI protocols to be installed and bound to the agent so that the agent can manage and utilize them later. Signed-off-by: AKASHI Takahiro --- drivers/firmware/scmi/scmi_agent-uclass.c | 105 +++++++++++++++++++++- include/scmi_agent-uclass.h | 12 +++ include/scmi_agent.h | 14 +++ 3 files changed, 128 insertions(+), 3 deletions(-) diff --git a/drivers/firmware/scmi/scmi_agent-uclass.c b/drivers/firmware/scmi/scmi_agent-uclass.c index 02de692d66f3..6fd948ae6ddf 100644 --- a/drivers/firmware/scmi/scmi_agent-uclass.c +++ b/drivers/firmware/scmi/scmi_agent-uclass.c @@ -37,6 +37,86 @@ static const struct error_code scmi_linux_errmap[] = { { .scmi = SCMI_PROTOCOL_ERROR, .errno = -EPROTO, }, }; +/* + * NOTE: The only one instance should exist according to + * the current specification and device tree bindings. + */ +struct udevice *scmi_agent; + +struct udevice *scmi_get_protocol(struct udevice *dev, + enum scmi_std_protocol id) +{ + struct scmi_agent_priv *priv; + struct udevice *proto; + + priv = dev_get_uclass_plat(dev); + if (!priv) { + dev_err(dev, "No priv data found\n"); + return NULL; + } + + switch (id) { + case SCMI_PROTOCOL_ID_CLOCK: + proto = priv->clock_dev; + break; + case SCMI_PROTOCOL_ID_RESET_DOMAIN: + proto = priv->resetdom_dev; + break; + case SCMI_PROTOCOL_ID_VOLTAGE_DOMAIN: + proto = priv->voltagedom_dev; + break; + default: + dev_err(dev, "Protocol not supported\n"); + proto = NULL; + break; + } + if (proto && device_probe(proto)) + dev_err(dev, "Probe failed\n"); + + return proto; +} + +/** + * scmi_add_protocol - add protocol to agent + * @dev: SCMI device + * @proto_id: Identifier of protocol + * @proto: Device of protocol instance + * + * Associate the protocol instance, @proto, to the agent, @dev, + * for later use. + * + * Return: 0 on success, error code otherwise + */ +static int scmi_add_protocol(struct udevice *dev, + enum scmi_std_protocol proto_id, + struct udevice *proto) +{ + struct scmi_agent_priv *priv; + + priv = dev_get_uclass_plat(dev); + if (!priv) { + dev_err(dev, "No priv data found\n"); + return -ENODEV; + } + + switch (proto_id) { + case SCMI_PROTOCOL_ID_CLOCK: + priv->clock_dev = proto; + break; + case SCMI_PROTOCOL_ID_RESET_DOMAIN: + priv->resetdom_dev = proto; + break; + case SCMI_PROTOCOL_ID_VOLTAGE_DOMAIN: + priv->voltagedom_dev = proto; + break; + default: + dev_err(dev, "Protocol not supported\n"); + return -EPROTO; + } + + return 0; +} + int scmi_to_linux_errno(s32 scmi_code) { int n; @@ -61,9 +141,15 @@ static int scmi_bind_protocols(struct udevice *dev) int ret = 0; ofnode node; const char *name; + struct driver *drv; + struct udevice *proto; + + if (scmi_agent) { + dev_err(dev, "SCMI agent already exists: %s\n", dev->name); + return -EBUSY; + } dev_for_each_subnode(node, dev) { - struct driver *drv = NULL; u32 protocol_id; if (!ofnode_is_enabled(node)) @@ -72,6 +158,7 @@ static int scmi_bind_protocols(struct udevice *dev) if (ofnode_read_u32(node, "reg", &protocol_id)) continue; + drv = NULL; name = ofnode_get_name(node); switch (protocol_id) { case SCMI_PROTOCOL_ID_CLOCK: @@ -102,11 +189,22 @@ static int scmi_bind_protocols(struct udevice *dev) continue; } - ret = device_bind(dev, drv, name, NULL, node, NULL); - if (ret) + ret = device_bind(dev, drv, name, NULL, node, &proto); + if (ret) { + dev_err(dev, "failed to bind %s protocol\n", drv->name); break; + } + ret = scmi_add_protocol(dev, protocol_id, proto); + if (ret) { + dev_err(dev, "failed to add protocol: %s, ret: %d\n", + proto->name, ret); + break; + } } + if (!ret) + scmi_agent = dev; + return ret; } @@ -168,4 +266,5 @@ UCLASS_DRIVER(scmi_agent) = { .id = UCLASS_SCMI_AGENT, .name = "scmi_agent", .post_bind = scmi_bind_protocols, + .per_device_plat_auto = sizeof(struct scmi_agent_priv), }; diff --git a/include/scmi_agent-uclass.h b/include/scmi_agent-uclass.h index b1c93532c0ea..6c3d1321b1aa 100644 --- a/include/scmi_agent-uclass.h +++ b/include/scmi_agent-uclass.h @@ -9,6 +9,18 @@ struct udevice; struct scmi_msg; struct scmi_channel; +/** + * struct scmi_agent_priv - private data maintained by agent instance + * @clock_dev: SCMI clock protocol device + * @clock_dev: SCMI reset domain protocol device + * @clock_dev: SCMI voltage domain protocol device + */ +struct scmi_agent_priv { + struct udevice *clock_dev; + struct udevice *resetdom_dev; + struct udevice *voltagedom_dev; +}; + /** * struct scmi_transport_ops - The functions that a SCMI transport layer must implement. */ diff --git a/include/scmi_agent.h b/include/scmi_agent.h index ee6286366df7..f77c10f7abfd 100644 --- a/include/scmi_agent.h +++ b/include/scmi_agent.h @@ -11,6 +11,7 @@ #define SCMI_AGENT_H #include +#include struct udevice; struct scmi_channel; @@ -69,6 +70,19 @@ int devm_scmi_of_get_channel(struct udevice *dev, struct scmi_channel **channel) int devm_scmi_process_msg(struct udevice *dev, struct scmi_channel *channel, struct scmi_msg *msg); +/** + * scmi_get_protocol() - get protocol instance + * + * @dev: SCMI device + * @id: Identifier of protocol + * + * Obtain the device instance for given protocol ID, @id. + * + * Return: Pointer to the device if found, null otherwise + */ +struct udevice *scmi_get_protocol(struct udevice *dev, + enum scmi_std_protocol id); + /** * scmi_to_linux_errno() - Convert an SCMI error code into a Linux errno code * From patchwork Wed Jun 28 00:48:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 697205 Delivered-To: patch@linaro.org Received: by 2002:adf:e885:0:0:0:0:0 with SMTP id d5csp4080276wrm; Tue, 27 Jun 2023 17:50:40 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6++OqgQ5iGS+Ahp5or0ROwHZalrgJM38lVJCdEDpVkfT+5Mo8v5ksdDOBmLrk4rNFPX0vT X-Received: by 2002:a2e:8296:0:b0:2b5:a31d:499 with SMTP id y22-20020a2e8296000000b002b5a31d0499mr8034605ljg.52.1687913440078; Tue, 27 Jun 2023 17:50:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687913440; cv=none; d=google.com; s=arc-20160816; b=dCpbcIs+cN2Hi8AeUQgPATht1hKZA5iB41l6/iCgcq7KMKZGTerxW86HU9vCLL33At 15Yn16UhMu/xIA8oyEuk4IxCDlee6oPYQEq6xMNLp5oHQjAmlhtHIm1T+JwKK4N8VGDw 6ZLvU9s14hUasX8trpzeC3pP/e+pv4oZKtl11Dwwp/tLCrM0RQhZRyr+8Uuu9vW3EUpY /2fswZqC/8zz/H3KS6efOwt40gnVDeORGHmtpBFDnJEurI34lTDkgFDPnviIEbBS3Qng aSHS0khVouvF+D7EW8k/B0mR6YaegHm99A1abXrY9fLPisQB6nPtfcC5uanGVpUBCY5h daXQ== 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=bpKIVM96FQ93bUibcxiCrv3RPvrCyPoHlPBsZOOUS2Q=; fh=+s9SE2w9oguEKAMcR35TXtqntCOeVFhiK9u/Kju91lo=; b=quwMhE/SxSI061kN+b4U+PcF2RUefjAOfcsa/LBF9CBYHvaKqWrpXFKHLdPqZjBpZD 9PcVCWDaYVpbRa65TcbwbhUp9LNGnOUB3ouR7hF/ltaTX8Jb19fuSkUx2ExCsSgCPf9V hOICAKlpjHZDX96w1a+SCRiPsgOvJOGgvnoFkl4ZZXU7zPCsJxHvsc+gU189IfzKG2dy r1wX9IPZt9by8HOKOHgncvtJNdpRherRY2MIf/6hRcyEVncOaYRT21kaFghP1Bbq91xc YMus3bDCh9D6kYD6COfGlxcswS5HN7i5mJXZtvtKbMMtco3IA2QQAvAHWpWuBRutEkIm lymQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sHWhsBws; 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 j17-20020a2eb711000000b002b6a7ea1543si1343226ljo.600.2023.06.27.17.50.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Jun 2023 17:50:40 -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=sHWhsBws; 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 53A678661B; Wed, 28 Jun 2023 02:50:28 +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="sHWhsBws"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6B08A865F1; Wed, 28 Jun 2023 02:49:56 +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, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) (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 99882865FF for ; Wed, 28 Jun 2023 02:49:38 +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-x632.google.com with SMTP id d9443c01a7336-1b3ecb17721so9825625ad.0 for ; Tue, 27 Jun 2023 17:49:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1687913377; x=1690505377; 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=bpKIVM96FQ93bUibcxiCrv3RPvrCyPoHlPBsZOOUS2Q=; b=sHWhsBwsusI/j1FRN/ri+McDyn0smfWMwP0NqjURaUWShaB30k3WegOvRYmCd7mC48 4kBUaJ+z8ryL/BGF/aHnRF/M5mEzYSGJhCGHYnll1wKiEjt1JdAc4fL1yJ7++bYh7ZjV ygpsTo7ZDPX26Zc15T/Rso4RJYp87cq2y2cAjzr+RAnluHsMizIei+7P5IKVMWknbfsu BF5Qcw+yM+6rZ7Cpj4gGR7biNPbnPcQGY+timTf1OhW8/3eL2q7EjyrG7ILYX+VInos2 vVcnZsF71vEheWA/aZ4ViPDIj7y32LgXkqAMHSzNIo+0r4wgAtw3I6FYY976qQztPTmr tDSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687913377; x=1690505377; 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=bpKIVM96FQ93bUibcxiCrv3RPvrCyPoHlPBsZOOUS2Q=; b=FU5e2to/gTMkTm5citV7CUTbz1PMZPNEoUKx6GWyDIS1oW1VyTNEZfSj9CZ2sYP5Bo 3kO/Xi6bPUVqvsBseCnZ1BcD4pBMdmDag5Wqt/FILP5+8zU0OXF8gQEHa0kmMBkAljGu zdORhKoOs3VEhoxljVtfsKcVGMJTzWWWR8PQisdnC7hwzg84XjRrto28gT9u5HIxKxVw guBVRvo4UonXr+XI2/M+kEVXdkDR4/5Oa4Ci+ayJ3Xi23+hYpewyeoZhAQMAHj9VPZFz EsjTRzw8Ru1jgVk6dbnjjR1+CmJTzhXt7N6NHT1BpWc2gL1i2fed0Kv++WaJNCWiZhgf XFpw== X-Gm-Message-State: AC+VfDwsrmeaGnID6LOs1Ty6VUILIUEi0ZchQcD59XwkW3eYRJgcLcxy dZ9hB2YpMRMPg78PZbFymh1sOv0f2epWFsPTeUY= X-Received: by 2002:a17:902:d489:b0:1ae:7ba2:1a7e with SMTP id c9-20020a170902d48900b001ae7ba21a7emr39553719plg.6.1687913376547; Tue, 27 Jun 2023 17:49:36 -0700 (PDT) Received: from laputa.. ([2400:4050:c3e1:100:58b2:60ed:38ea:8b1f]) by smtp.gmail.com with ESMTPSA id u13-20020a170903124d00b001b3fb2f0296sm6517278plh.120.2023.06.27.17.49.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Jun 2023 17:49:36 -0700 (PDT) From: AKASHI Takahiro To: trini@konsulko.com, sjg@chromium.org Cc: etienne.carriere@st.com, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH 03/10] firmware: scmi: install base protocol to SCMI agent Date: Wed, 28 Jun 2023 09:48:34 +0900 Message-ID: <20230628004841.21774-4-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230628004841.21774-1-takahiro.akashi@linaro.org> References: <20230628004841.21774-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 SCMI base protocol is mandatory, and once SCMI node is found in a device tree, the protocol handle (udevice) is unconditionally installed to the agent. Then basic information will be retrieved from SCMI server via the protocol and saved into the agent instance's local storage. Signed-off-by: AKASHI Takahiro --- drivers/firmware/scmi/base.c | 6 ++ drivers/firmware/scmi/scmi_agent-uclass.c | 104 ++++++++++++++++++++++ include/scmi_agent-uclass.h | 78 +++++++++++++++- include/scmi_agent.h | 10 +++ 4 files changed, 195 insertions(+), 3 deletions(-) diff --git a/drivers/firmware/scmi/base.c b/drivers/firmware/scmi/base.c index 04018eb6ecf3..224e0ca7a915 100644 --- a/drivers/firmware/scmi/base.c +++ b/drivers/firmware/scmi/base.c @@ -484,6 +484,12 @@ static int scmi_base_probe(struct udevice *dev) return ret; } + ret = scmi_fill_base_info(dev->parent); + if (ret) { + dev_err(dev, "get information failed\n"); + return ret; + } + return ret; } diff --git a/drivers/firmware/scmi/scmi_agent-uclass.c b/drivers/firmware/scmi/scmi_agent-uclass.c index 6fd948ae6ddf..ec15580cc947 100644 --- a/drivers/firmware/scmi/scmi_agent-uclass.c +++ b/drivers/firmware/scmi/scmi_agent-uclass.c @@ -56,6 +56,9 @@ struct udevice *scmi_get_protocol(struct udevice *dev, } switch (id) { + case SCMI_PROTOCOL_ID_BASE: + proto = priv->base_dev; + break; case SCMI_PROTOCOL_ID_CLOCK: proto = priv->clock_dev; break; @@ -100,6 +103,9 @@ static int scmi_add_protocol(struct udevice *dev, } switch (proto_id) { + case SCMI_PROTOCOL_ID_BASE: + priv->base_dev = proto; + break; case SCMI_PROTOCOL_ID_CLOCK: priv->clock_dev = proto; break; @@ -149,6 +155,20 @@ static int scmi_bind_protocols(struct udevice *dev) return -EBUSY; } + drv = DM_DRIVER_GET(scmi_base_drv); + name = "scmi-base.0"; + ret = device_bind(dev, drv, name, NULL, ofnode_null(), &proto); + if (ret) { + dev_err(dev, "failed to bind base protocol\n"); + return ret; + } + ret = scmi_add_protocol(dev, SCMI_PROTOCOL_ID_BASE, proto); + if (ret) { + dev_err(dev, "failed to add protocol: %s, ret: %d\n", + proto->name, ret); + return ret; + } + dev_for_each_subnode(node, dev) { u32 protocol_id; @@ -262,6 +282,90 @@ int devm_scmi_process_msg(struct udevice *dev, struct scmi_channel *channel, return -EPROTONOSUPPORT; } +int scmi_fill_base_info(struct udevice *dev) +{ + struct scmi_agent_priv *priv; + struct udevice *base; + const struct scmi_base_ops *ops; + int ret; + + priv = dev_get_uclass_plat(dev); + + base = priv->base_dev; + if (!base) { + dev_err(dev, "Base protocol not found\n"); + return -EPROTO; + } + + ops = dev_get_driver_ops(base); + if (!ops) { + dev_err(base, "Operations in Base protocol not found\n"); + return -EPROTO; + } + ret = (*ops->protocol_version)(base, &priv->version); + if (ret) { + dev_err(base, "protocol_version() failed (%d)\n", ret); + return ret; + } + /* check for required version */ + if (priv->version < SCMI_BASE_PROTOCOL_VERSION) { + dev_err(base, "base protocol version (%d) lower than expected\n", + priv->version); + return -EPROTO; + } + + ret = (*ops->protocol_attrs)(base, &priv->num_agents, + &priv->num_protocols); + if (ret) { + dev_err(base, "protocol_attrs() failed (%d)\n", ret); + return ret; + } + ret = (*ops->base_discover_vendor)(base, priv->vendor); + if (ret) { + dev_err(base, "base_discover_vendor() failed (%d)\n", ret); + return ret; + } + ret = (*ops->base_discover_sub_vendor)(base, priv->sub_vendor); + if (ret) { + if (ret != -EOPNOTSUPP) { + dev_err(base, "base_discover_sub_vendor() failed (%d)\n", + ret); + return ret; + } + strcpy(priv->sub_vendor, "NA"); + } + ret = (*ops->base_discover_impl_version)(base, + &priv->impl_version); + if (ret) { + dev_err(base, "base_discover_impl_version() failed (%d)\n", + ret); + return ret; + } + + priv->agent_id = 0xffffffff; /* to avoid false claim */ + ret = (*ops->base_discover_agent)(base, 0xffffffff, + &priv->agent_id, priv->agent_name); + if (ret) { + if (ret != -EOPNOTSUPP) { + dev_err(base, + "base_discover_agent() failed for myself (%d)\n", + ret); + return ret; + } + priv->agent_name[0] = '\0'; + } + + ret = (*ops->base_discover_list_protocols)(base, + &priv->protocols); + if (ret != priv->num_protocols) { + dev_err(base, "base_discover_list_protocols() failed (%d)\n", + ret); + return ret; + } + + return 0; +} + UCLASS_DRIVER(scmi_agent) = { .id = UCLASS_SCMI_AGENT, .name = "scmi_agent", diff --git a/include/scmi_agent-uclass.h b/include/scmi_agent-uclass.h index 6c3d1321b1aa..8ead08b38fb1 100644 --- a/include/scmi_agent-uclass.h +++ b/include/scmi_agent-uclass.h @@ -5,22 +5,94 @@ #ifndef _SCMI_AGENT_UCLASS_H #define _SCMI_AGENT_UCLASS_H +#include + struct udevice; struct scmi_msg; struct scmi_channel; /** * struct scmi_agent_priv - private data maintained by agent instance - * @clock_dev: SCMI clock protocol device - * @clock_dev: SCMI reset domain protocol device - * @clock_dev: SCMI voltage domain protocol device + * @version: Version + * @num_agents: Number of agents + * @num_protocols: Number of protocols + * @impl_version: Implementation version + * @protocols: Array of protocol IDs + * @vendor: Vendor name + * @sub_vendor: Sub-vendor name + * @agent_name: Agent name + * agent_id: Identifier of agent + * @base_dev: SCMI base protocol device + * @clock_dev: SCMI block protocol device + * @clock_dev: SCMI reset domain protocol device + * @clock_dev: SCMI voltage domain protocol device */ struct scmi_agent_priv { + u32 version; + u32 num_agents; + u32 num_protocols; + u32 impl_version; + u8 *protocols; + u8 vendor[SCMI_BASE_NAME_LENGTH_MAX]; + u8 sub_vendor[SCMI_BASE_NAME_LENGTH_MAX]; + u8 agent_name[SCMI_BASE_NAME_LENGTH_MAX]; + u32 agent_id; + struct udevice *base_dev; struct udevice *clock_dev; struct udevice *resetdom_dev; struct udevice *voltagedom_dev; }; +static inline u32 scmi_version(struct udevice *dev) +{ + return ((struct scmi_agent_priv *)dev_get_uclass_plat(dev))->version; +} + +static inline u32 scmi_num_agents(struct udevice *dev) +{ + return ((struct scmi_agent_priv *)dev_get_uclass_plat(dev))->num_agents; +} + +static inline u32 scmi_num_protocols(struct udevice *dev) +{ + return ((struct scmi_agent_priv *)dev_get_uclass_plat(dev))->num_protocols; +} + +static inline u32 scmi_impl_version(struct udevice *dev) +{ + return ((struct scmi_agent_priv *)dev_get_uclass_plat(dev))->impl_version; +} + +static inline u8 *scmi_protocols(struct udevice *dev) +{ + return ((struct scmi_agent_priv *)dev_get_uclass_plat(dev))->protocols; +} + +static inline u8 *scmi_vendor(struct udevice *dev) +{ + return ((struct scmi_agent_priv *)dev_get_uclass_plat(dev))->vendor; +} + +static inline u8 *scmi_sub_vendor(struct udevice *dev) +{ + return ((struct scmi_agent_priv *)dev_get_uclass_plat(dev))->sub_vendor; +} + +static inline u8 *scmi_agent_name(struct udevice *dev) +{ + return ((struct scmi_agent_priv *)dev_get_uclass_plat(dev))->agent_name; +} + +static inline u32 scmi_agent_id(struct udevice *dev) +{ + return ((struct scmi_agent_priv *)dev_get_uclass_plat(dev))->agent_id; +} + +static inline struct udevice *scmi_base_dev(struct udevice *dev) +{ + return ((struct scmi_agent_priv *)dev_get_uclass_plat(dev))->base_dev; +} + /** * struct scmi_transport_ops - The functions that a SCMI transport layer must implement. */ diff --git a/include/scmi_agent.h b/include/scmi_agent.h index f77c10f7abfd..07e99f19726e 100644 --- a/include/scmi_agent.h +++ b/include/scmi_agent.h @@ -91,4 +91,14 @@ struct udevice *scmi_get_protocol(struct udevice *dev, */ int scmi_to_linux_errno(s32 scmi_errno); +/** + * scmi_fill_base_info - fill information about services by SCMI server + * @dev: SCMI device + * + * Fill basic information about services provided by SCMI server + * + * Return: 0 on success, error code otherwise + */ +int scmi_fill_base_info(struct udevice *dev); + #endif /* SCMI_H */ From patchwork Wed Jun 28 00:48:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 697204 Delivered-To: patch@linaro.org Received: by 2002:adf:e885:0:0:0:0:0 with SMTP id d5csp4080227wrm; Tue, 27 Jun 2023 17:50:27 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6MSU2meKs6KAspIbyiRHDpPneirnMhbqwmd90VYKM+w006Wde/Z/SnFNtrPw8z75Go2Cc5 X-Received: by 2002:a2e:7001:0:b0:2b5:8a3f:4f5 with SMTP id l1-20020a2e7001000000b002b58a3f04f5mr10537834ljc.50.1687913427742; Tue, 27 Jun 2023 17:50:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687913427; cv=none; d=google.com; s=arc-20160816; b=ssX8EoboxNrjULDE77U6qnT4BBm/+lc667p1RMkCseVCQOCcdqDweTOlASAzzCV1n1 NLfg/HGbTqXr/QxO84Y0PEOO9OUPJRj9Dy/HaU9FLgZMQDwP0yriuVU9LX7KxTCRntyH eJjM3JfCZhO2IyS9w9L4yal8GWMK/BrR8O+DY5EDkirecncbewtDLaoOIOgKeO0isqnC nSKb2Y+R55gD0p61LTZ8KqwmA5JOng8O3t5hM4yBaGyFq0HP2Lqkd8d2u/GpDaS14hBc 1p1Ll//DAeMq7kZr6KcpFXq6krwu/bl2yvr6vsKTaojcBvYgYEG2lamlDcVH8Shm95Ow gK7g== 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=ibWYrXXSuiNgv9F+yr/TXuimIzTB9IOiOdl8TWlCE1I=; fh=+s9SE2w9oguEKAMcR35TXtqntCOeVFhiK9u/Kju91lo=; b=ko/rYv5nEtLYah1ID3Kb9mVYZsJAYBc7IjrIIHW4BL5MtpRjsviOkE/Hr58GJT6WV1 mafxhm5PAFKd2pbNOO1s4ipu7zyElCCLYa5pCkqzcYTh7VywivSSDpT46dHi+QJNWGBR ZCOwBRyFIF2Qpt48wSCVM2I6nCUVdNffBsyv2ByksklTLnTMFnCct2Q6SIJZZFnU8np2 Yw+i+XQ/R2FIGxTpgcaPcWbaGpl5ImOmopSHzmTQsiqNyeKl/N3XOf7u/fnCy5zBLRUx S7l5dN3PZA4mGie9Jby5kY6ttr+LKXzPy4OzPrzEoICoyYunYleOFNNrrewwEhCcbZS+ HRsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TOgzWiK6; 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 e23-20020a2e9857000000b002aef6e1301fsi2849619ljj.106.2023.06.27.17.50.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Jun 2023 17:50:27 -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=TOgzWiK6; 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 E0F3D86612; Wed, 28 Jun 2023 02:50:19 +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="TOgzWiK6"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 17F408661B; Wed, 28 Jun 2023 02:49:51 +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, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) (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 3936C86603 for ; Wed, 28 Jun 2023 02:49:40 +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-x62d.google.com with SMTP id d9443c01a7336-1b7e31154c4so6242785ad.1 for ; Tue, 27 Jun 2023 17:49:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1687913378; x=1690505378; 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=ibWYrXXSuiNgv9F+yr/TXuimIzTB9IOiOdl8TWlCE1I=; b=TOgzWiK67QDw66aLH4j8QC82TcbPHLv0+2yNutIhHHdGx4Iub/frJXINhWzN6QzYK1 r0N4zj/ce9sz7e8AW9zJuu/d7nwYiSR+DvLfhi+e7yB4/ZpV55oakwTeJ8m0bXzViTKx 4hDpQNWnCfmqO200C8vhXcQcPbYz8xeOTDnrSgYz1rcoY3GQ+Gjjl6f74ZgpL52rKlFU DVB5SbLWSAQeJH3kQrftptX8nFIQ3VWIgU/yXMzB3ST0x/V5q4Pf3wP4ofzu+3XX425j TqN5TgENOZBbEaFnX/jEB226K1lLevAGoPXS/gY8Vc2pLTLV/tCMZhIpoaqDfOeOsedD YmdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687913378; x=1690505378; 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=ibWYrXXSuiNgv9F+yr/TXuimIzTB9IOiOdl8TWlCE1I=; b=KJZ9CD+c7DxZMTGePBGmJTLzqrIjU0AfM9YGNazd/635zmaLynO4jmtGAcy05QUrZX hbYOkQmbqOQ2vKICcmikKm8Dq2A5V2zA8zfwawX8UPiYNa+Gil0RkOnLOVrMUAwyBowR 79jiOt5UHdWSl5BIBSKvDwwhtb3ue8qXosuhDDp189v+ltpMW20B1vpQtAaQXwkM69w4 FpmmCWaf5aTwAzabjmkL0J7ggl6rKg8ak8nRmgOYVJID6KjG6Ft82x6bNuHKb4fL9JYS vIaccve84VLM5EvYv+CxRqx2lzYJayl2S4w+1Gwr94jwsyOCv/aKrT6SB2Y+jz4I/QHV MCFg== X-Gm-Message-State: AC+VfDx/Lpal/V7ZWWZE6jB0AsIB0iCIaD+5HzK7L3Qiprjy397G1X+o Uf1sEnoVnG9v7RuTzexfggVjJg== X-Received: by 2002:a17:903:1ca:b0:1b5:32ec:df97 with SMTP id e10-20020a17090301ca00b001b532ecdf97mr39478210plh.5.1687913378509; Tue, 27 Jun 2023 17:49:38 -0700 (PDT) Received: from laputa.. ([2400:4050:c3e1:100:58b2:60ed:38ea:8b1f]) by smtp.gmail.com with ESMTPSA id u13-20020a170903124d00b001b3fb2f0296sm6517278plh.120.2023.06.27.17.49.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Jun 2023 17:49:38 -0700 (PDT) From: AKASHI Takahiro To: trini@konsulko.com, sjg@chromium.org Cc: etienne.carriere@st.com, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH 04/10] sandbox: remove SCMI base node definition from test.dts Date: Wed, 28 Jun 2023 09:48:35 +0900 Message-ID: <20230628004841.21774-5-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230628004841.21774-1-takahiro.akashi@linaro.org> References: <20230628004841.21774-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 SCMI base protocol is mandatory and doesn't need to be listed in a device tree. Signed-off-by: AKASHI Takahiro Reviewed-by: Simon Glass --- arch/sandbox/dts/test.dts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts index ff9f9222e6f9..2aad94681148 100644 --- a/arch/sandbox/dts/test.dts +++ b/arch/sandbox/dts/test.dts @@ -682,10 +682,6 @@ #address-cells = <1>; #size-cells = <0>; - protocol@10 { - reg = <0x10>; - }; - clk_scmi: protocol@14 { reg = <0x14>; #clock-cells = <1>; From patchwork Wed Jun 28 00:48:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 697207 Delivered-To: patch@linaro.org Received: by 2002:adf:e885:0:0:0:0:0 with SMTP id d5csp4080407wrm; Tue, 27 Jun 2023 17:51:08 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5aPVSb7/K0hLDkmqjiAd9DPJMgaJCcduH1z117ilXDjt3uXdq7v+nO3f5aARlnNfPHkV1M X-Received: by 2002:a2e:910f:0:b0:2b6:9c11:24c9 with SMTP id m15-20020a2e910f000000b002b69c1124c9mr5710302ljg.44.1687913468590; Tue, 27 Jun 2023 17:51:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687913468; cv=none; d=google.com; s=arc-20160816; b=NpWvXCllMY+81fGjbt7w7r2i7m+nn8qY4Be2aX3nFIRgJOthhrksWS63gjJJ5CNlxz +a/MlKuc/ujlkoKHR4Rpe1trCCpM8IO8l5c9C4PHMHunxfmgcpQxFi2gu/sDw+AXUsGu v89tDSPnb72wMW6TzSn5B5jcqHsSCDmQDaWpyYqm/JFNdxf/SCUlCym7NVUF0sXoYfty t79dPsxoqJOlvFKns0IveIhqegNB5doN12fW62Mte6h3e1PNq6/K0nBnJlXupZv/0U84 AC/OiYzJ1qdUohX5XEwArAVg+x6uQswBJevLy4jYfoPLBgzzB3DycCcUrudqVpVY4CP4 jvCg== 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=eTL81HD7jbQs1Fo7N1kP/DUtdvZTG8UZ6mrLMfOWgks=; fh=+s9SE2w9oguEKAMcR35TXtqntCOeVFhiK9u/Kju91lo=; b=mcQRDMcpDcP27hfa0va4zkiZFDfefHOM4W0sYAGrVlOO/jI9aMShkxamHwAvrU+uXG +VRWynOg9hq8NfStt2IWIkbZxbzutPVfcMGLZF0JvisdhkXeHo/53sj3VL9oDOzxb8xU 3518r82bwON241Fc//Yf4eyIEKZP4eo0Dtrt41VbMTjd6UnPcHMRZ3PUHrXoKS1MtOrJ SC7+lA3WP0MAm40tTK9XIIZ3KO9lc+hVpYp9qwgvKD/KrCxozDtFamj1mJ6iN6SME3xx XKARr+6BTGf5bFCQ596y18zhqXyWyHCfweTnJfdbO9EvAMRbrvle6YKXc6zsfRbVpW8b ZDPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=snQCy2gB; 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 j6-20020a2e3c06000000b002b47bf2a7efsi2726762lja.332.2023.06.27.17.51.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Jun 2023 17:51:08 -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=snQCy2gB; 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 EE71A8660B; Wed, 28 Jun 2023 02:50:46 +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="snQCy2gB"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1D389865F1; Wed, 28 Jun 2023 02:50:14 +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, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) (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 887ED8660A for ; Wed, 28 Jun 2023 02:49:42 +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-x62b.google.com with SMTP id d9443c01a7336-1b7e0904a3aso5612605ad.0 for ; Tue, 27 Jun 2023 17:49:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1687913381; x=1690505381; 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=eTL81HD7jbQs1Fo7N1kP/DUtdvZTG8UZ6mrLMfOWgks=; b=snQCy2gBCcMxM5fdix5M2iaLkoyGVnYkPVtI7uGhAecpWQ2Km7gyBfOusroMqeNsiy oj/VSKyaScZpcSMLDsC1yKRMPZ2Q37XYQK71G2SNdPlzpUEPnq6dgCwbhk13q9Cf8MJK XtqM5aApv4N2Di7xM7VQQpPxrD4BNUnSvNT5Ik/iKacNykHPj0CVTgX9XXQv7b/yywnj BI0VIyOZLZCSfndcjSuA537zrD7ZUB9nfCCUhUVjsfhJQsYrdmPjtZPq6fmrIWnGJMTm asHJk/Q8RkGKHrIYPvd1mKxTx4sJFWaH2O5Zi8QFDbMolopI8MF14BH8n5uwC2YGRDsG Sltg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687913381; x=1690505381; 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=eTL81HD7jbQs1Fo7N1kP/DUtdvZTG8UZ6mrLMfOWgks=; b=lekSqfqQUVKN0BPnK0qq0CT0Czz9oGdlM887RB5Lb+CQ38pDRA/x8YqKyL/T4Ofxqt /UmTFNAag+8NjZEVSdwJpPHJB7otxbRDTXZUNWtLX5+gw5rLYe/1JhypFUl6q68RTBHQ IK1luCdOQzCP3EDKJoopk60nhBBR4uxnfqOO0gWsapABVXIlrNAe8WxKaxl41ZN9ozGW r33peQwdDy9Nhv/u3z1UQP9itoa3nQYjHH8KhY7VkDNEcWjc/t0sCGs0D6Ioqmao0/A9 TzTGN0CShZ1JaZRP6tTcJE5MF8vKOj6mM89Sz5VqmAUtSE9uRCNAjkcBbjhEYoJvVb5H opvQ== X-Gm-Message-State: AC+VfDzrLXFaVXFmIdrX0or25dX5GZKZxXJJbccXt0D026WP4ftiWR2q kyizhALPz8fT9GrxHNj37KC48g== X-Received: by 2002:a17:903:104c:b0:1b3:d4bb:3515 with SMTP id f12-20020a170903104c00b001b3d4bb3515mr3470418plc.0.1687913380769; Tue, 27 Jun 2023 17:49:40 -0700 (PDT) Received: from laputa.. ([2400:4050:c3e1:100:58b2:60ed:38ea:8b1f]) by smtp.gmail.com with ESMTPSA id u13-20020a170903124d00b001b3fb2f0296sm6517278plh.120.2023.06.27.17.49.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Jun 2023 17:49:40 -0700 (PDT) From: AKASHI Takahiro To: trini@konsulko.com, sjg@chromium.org Cc: etienne.carriere@st.com, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH 05/10] firmware: scmi: fake base protocol commands on sandbox Date: Wed, 28 Jun 2023 09:48:36 +0900 Message-ID: <20230628004841.21774-6-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230628004841.21774-1-takahiro.akashi@linaro.org> References: <20230628004841.21774-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 simple implementation of SCMI base protocol for sandbox. The main use is in SCMI unit test. Signed-off-by: AKASHI Takahiro Reviewed-by: Simon Glass --- drivers/firmware/scmi/sandbox-scmi_agent.c | 359 ++++++++++++++++++++- 1 file changed, 358 insertions(+), 1 deletion(-) diff --git a/drivers/firmware/scmi/sandbox-scmi_agent.c b/drivers/firmware/scmi/sandbox-scmi_agent.c index 031882998dfa..1f0261ea5c94 100644 --- a/drivers/firmware/scmi/sandbox-scmi_agent.c +++ b/drivers/firmware/scmi/sandbox-scmi_agent.c @@ -14,11 +14,14 @@ #include #include #include +#include +#include /* * The sandbox SCMI agent driver simulates to some extend a SCMI message * processing. It simulates few of the SCMI services for some of the * SCMI protocols embedded in U-Boot. Currently: + * - SCMI base protocol * - SCMI clock protocol emulates an agent exposing 2 clocks * - SCMI reset protocol emulates an agent exposing a reset controller * - SCMI voltage domain protocol emulates an agent exposing 2 regulators @@ -33,6 +36,21 @@ * various uclass devices, as clocks and reset controllers. */ +#define SANDBOX_SCMI_BASE_PROTOCOL_VERSION SCMI_BASE_PROTOCOL_VERSION +#define SANDBOX_SCMI_VENDOR "U-Boot" +#define SANDBOX_SCMI_SUB_VENDOR "Sandbox" +#define SANDBOX_SCMI_IMPL_VERSION 0x1 +#define SANDBOX_SCMI_AGENT_NAME "OSPM" +#define SANDBOX_SCMI_PLATFORM_NAME "platform" + +static u8 protocols[] = { + SCMI_PROTOCOL_ID_CLOCK, + SCMI_PROTOCOL_ID_RESET_DOMAIN, + SCMI_PROTOCOL_ID_VOLTAGE_DOMAIN, +}; + +#define NUM_PROTOCOLS ARRAY_SIZE(protocols) + static struct sandbox_scmi_clk scmi_clk[] = { { .rate = 333 }, { .rate = 200 }, @@ -114,6 +132,316 @@ static struct sandbox_scmi_voltd *get_scmi_voltd_state(uint domain_id) * Sandbox SCMI agent ops */ +/* Base Protocol */ + +/** + * sandbox_scmi_base_protocol_version - implement SCMI_BASE_PROTOCOL_VERSION + * @udevice: SCMI device + * @msg: SCMI message + * + * Implement SCMI_BASE_PROTOCOL_VERSION command. + */ +static int sandbox_scmi_base_protocol_version(struct udevice *dev, + struct scmi_msg *msg) +{ + struct scmi_protocol_version_out *out = NULL; + + if (!msg->out_msg || msg->out_msg_sz < sizeof(*out)) + return -EINVAL; + + out = (struct scmi_protocol_version_out *)msg->out_msg; + out->version = SANDBOX_SCMI_BASE_PROTOCOL_VERSION; + out->status = SCMI_SUCCESS; + + return 0; +} + +/** + * sandbox_scmi_base_protocol_attrs - implement SCMI_BASE_PROTOCOL_ATTRIBUTES + * @udevice: SCMI device + * @msg: SCMI message + * + * Implement SCMI_BASE_PROTOCOL_ATTRIBUTES command. + */ +static int sandbox_scmi_base_protocol_attrs(struct udevice *dev, + struct scmi_msg *msg) +{ + struct scmi_protocol_attrs_out *out = NULL; + + if (!msg->out_msg || msg->out_msg_sz < sizeof(*out)) + return -EINVAL; + + out = (struct scmi_protocol_attrs_out *)msg->out_msg; + out->attributes = FIELD_PREP(0xff00, 2) | NUM_PROTOCOLS; + out->status = SCMI_SUCCESS; + + return 0; +} + +/** + * sandbox_scmi_base_message_attrs - implement + * SCMI_BASE_PROTOCOL_MESSAGE_ATTRIBUTES + * @udevice: SCMI device + * @msg: SCMI message + * + * Implement SCMI_BASE_PROTOCOL_MESSAGE_ATTRIBUTES command. + */ +static int sandbox_scmi_base_message_attrs(struct udevice *dev, + struct scmi_msg *msg) +{ + u32 message_id; + struct scmi_protocol_msg_attrs_out *out = NULL; + + if (!msg->in_msg || msg->in_msg_sz < sizeof(message_id) || + !msg->out_msg || msg->out_msg_sz < sizeof(*out)) + return -EINVAL; + + message_id = *(u32 *)msg->in_msg; + out = (struct scmi_protocol_msg_attrs_out *)msg->out_msg; + + if (message_id >= SCMI_PROTOCOL_VERSION && + message_id <= SCMI_BASE_RESET_AGENT_CONFIGURATION && + message_id != SCMI_BASE_NOTIFY_ERRORS) { + out->attributes = 0; + out->status = SCMI_SUCCESS; + } else { + out->status = SCMI_NOT_FOUND; + } + + return 0; +} + +/** + * sandbox_scmi_base_discover_vendor - implement SCMI_BASE_DISCOVER_VENDOR + * @udevice: SCMI device + * @msg: SCMI message + * + * Implement SCMI_BASE_DISCOVER_VENDOR command + */ +static int sandbox_scmi_base_discover_vendor(struct udevice *dev, + struct scmi_msg *msg) +{ + struct scmi_base_discover_vendor_out *out = NULL; + + if (!msg->out_msg || msg->out_msg_sz < sizeof(*out)) + return -EINVAL; + + out = (struct scmi_base_discover_vendor_out *)msg->out_msg; + strcpy(out->vendor_identifier, SANDBOX_SCMI_VENDOR); + out->status = SCMI_SUCCESS; + + return 0; +} + +/** + * sandbox_scmi_base_discover_sub_vendor - implement + * SCMI_BASE_DISCOVER_SUB_VENDOR + * @udevice: SCMI device + * @msg: SCMI message + * + * Implement SCMI_BASE_DISCOVER_SUB_VENDOR command + */ +static int sandbox_scmi_base_discover_sub_vendor(struct udevice *dev, + struct scmi_msg *msg) +{ + struct scmi_base_discover_vendor_out *out = NULL; + + if (!msg->out_msg || msg->out_msg_sz < sizeof(*out)) + return -EINVAL; + + out = (struct scmi_base_discover_vendor_out *)msg->out_msg; + strcpy(out->vendor_identifier, SANDBOX_SCMI_SUB_VENDOR); + out->status = SCMI_SUCCESS; + + return 0; +} + +/** + * sandbox_scmi_base_discover_impl_version - implement + * SCMI_BASE_DISCOVER_IMPLEMENTATION_VERSION + * @udevice: SCMI device + * @msg: SCMI message + * + * Implement SCMI_BASE_DISCOVER_IMPLEMENTATION_VERSION command + */ +static int sandbox_scmi_base_discover_impl_version(struct udevice *dev, + struct scmi_msg *msg) +{ + struct scmi_base_discover_impl_version_out *out = NULL; + + if (!msg->out_msg || msg->out_msg_sz < sizeof(*out)) + return -EINVAL; + + out = (struct scmi_base_discover_impl_version_out *)msg->out_msg; + out->impl_version = SANDBOX_SCMI_IMPL_VERSION; + out->status = SCMI_SUCCESS; + + return 0; +} + +/** + * sandbox_scmi_base_discover_list_protocols - implement + * SCMI_BASE_DISCOVER_LIST_PROTOCOLS + * @udevice: SCMI device + * @msg: SCMI message + * + * Implement SCMI_BASE_DISCOVER_LIST_PROTOCOLS command + */ +static int sandbox_scmi_base_discover_list_protocols(struct udevice *dev, + struct scmi_msg *msg) +{ + struct scmi_base_discover_list_protocols_out *out = NULL; + + if (!msg->out_msg || msg->out_msg_sz < sizeof(*out)) + return -EINVAL; + + out = (struct scmi_base_discover_list_protocols_out *)msg->out_msg; + memcpy(out->protocols, protocols, sizeof(protocols)); + out->num_protocols = NUM_PROTOCOLS; + out->status = SCMI_SUCCESS; + + return 0; +} + +/** + * sandbox_scmi_base_discover_agent - implement SCMI_BASE_DISCOVER_AGENT + * @udevice: SCMI device + * @msg: SCMI message + * + * Implement SCMI_BASE_DISCOVER_AGENT command + */ +static int sandbox_scmi_base_discover_agent(struct udevice *dev, + struct scmi_msg *msg) +{ + u32 agent_id; + struct scmi_base_discover_agent_out *out = NULL; + + if (!msg->in_msg || msg->in_msg_sz < sizeof(agent_id) || + !msg->out_msg || msg->out_msg_sz < sizeof(*out)) + return -EINVAL; + + agent_id = *(u32 *)msg->in_msg; + out = (struct scmi_base_discover_agent_out *)msg->out_msg; + out->status = SCMI_SUCCESS; + if (agent_id == 0xffffffff || agent_id == 1) { + out->agent_id = 1; + strcpy(out->name, SANDBOX_SCMI_AGENT_NAME); + } else if (!agent_id) { + out->agent_id = agent_id; + strcpy(out->name, SANDBOX_SCMI_PLATFORM_NAME); + } else { + out->status = SCMI_NOT_FOUND; + } + + return 0; +} + +/** + * sandbox_scmi_base_set_device_permissions - implement + * SCMI_BASE_SET_DEVICE_PERMISSIONS + * @udevice: SCMI device + * @msg: SCMI message + * + * Implement SCMI_BASE_SET_DEVICE_PERMISSIONS command + */ +static int sandbox_scmi_base_set_device_permissions(struct udevice *dev, + struct scmi_msg *msg) +{ + struct scmi_base_set_device_permissions_in *in = NULL; + u32 *status; + + if (!msg->in_msg || msg->in_msg_sz < sizeof(*in) || + !msg->out_msg || msg->out_msg_sz < sizeof(*status)) + return -EINVAL; + + in = (struct scmi_base_set_device_permissions_in *)msg->in_msg; + status = (u32 *)msg->out_msg; + + if (in->agent_id != 1 || in->device_id != 0) + *status = SCMI_NOT_FOUND; + else if (in->flags & ~SCMI_BASE_SET_DEVICE_PERMISSIONS_ACCESS) + *status = SCMI_INVALID_PARAMETERS; + else if (in->flags & SCMI_BASE_SET_DEVICE_PERMISSIONS_ACCESS) + *status = SCMI_SUCCESS; + else + /* unset not allowed */ + *status = SCMI_DENIED; + + return 0; +} + +/** + * sandbox_scmi_base_set_protocol_permissions - implement + * SCMI_BASE_SET_PROTOCOL_PERMISSIONS + * @udevice: SCMI device + * @msg: SCMI message + * + * Implement SCMI_BASE_SET_PROTOCOL_PERMISSIONS command + */ +static int sandbox_scmi_base_set_protocol_permissions(struct udevice *dev, + struct scmi_msg *msg) +{ + struct scmi_base_set_protocol_permissions_in *in = NULL; + u32 *status; + int i; + + if (!msg->in_msg || msg->in_msg_sz < sizeof(*in) || + !msg->out_msg || msg->out_msg_sz < sizeof(*status)) + return -EINVAL; + + in = (struct scmi_base_set_protocol_permissions_in *)msg->in_msg; + status = (u32 *)msg->out_msg; + + for (i = 0; i < ARRAY_SIZE(protocols); i++) + if (protocols[i] == in->command_id) + break; + if (in->agent_id != 1 || in->device_id != 0 || + i == ARRAY_SIZE(protocols)) + *status = SCMI_NOT_FOUND; + else if (in->flags & ~SCMI_BASE_SET_PROTOCOL_PERMISSIONS_ACCESS) + *status = SCMI_INVALID_PARAMETERS; + else if (in->flags & SCMI_BASE_SET_PROTOCOL_PERMISSIONS_ACCESS) + *status = SCMI_SUCCESS; + else + /* unset not allowed */ + *status = SCMI_DENIED; + + return 0; +} + +/** + * sandbox_scmi_base_reset_agent_configuration - implement + * SCMI_BASE_RESET_AGENT_CONFIGURATION + * @udevice: SCMI device + * @msg: SCMI message + * + * Implement SCMI_BASE_RESET_AGENT_CONFIGURATION command + */ +static int sandbox_scmi_base_reset_agent_configuration(struct udevice *dev, + struct scmi_msg *msg) +{ + struct scmi_base_reset_agent_configuration_in *in = NULL; + u32 *status; + + if (!msg->in_msg || msg->in_msg_sz < sizeof(*in) || + !msg->out_msg || msg->out_msg_sz < sizeof(*status)) + return -EINVAL; + + in = (struct scmi_base_reset_agent_configuration_in *)msg->in_msg; + status = (u32 *)msg->out_msg; + + if (in->agent_id != 1) + *status = SCMI_NOT_FOUND; + else if (in->flags & ~SCMI_BASE_RESET_ALL_ACCESS_PERMISSIONS) + *status = SCMI_INVALID_PARAMETERS; + else + *status = SCMI_DENIED; + + return 0; +} + +/* Clock Protocol */ + static int sandbox_scmi_clock_protocol_attribs(struct udevice *dev, struct scmi_msg *msg) { @@ -475,6 +803,36 @@ static int sandbox_scmi_test_process_msg(struct udevice *dev, struct scmi_msg *msg) { switch (msg->protocol_id) { + case SCMI_PROTOCOL_ID_BASE: + switch (msg->message_id) { + case SCMI_PROTOCOL_VERSION: + return sandbox_scmi_base_protocol_version(dev, msg); + case SCMI_PROTOCOL_ATTRIBUTES: + return sandbox_scmi_base_protocol_attrs(dev, msg); + case SCMI_PROTOCOL_MESSAGE_ATTRIBUTES: + return sandbox_scmi_base_message_attrs(dev, msg); + case SCMI_BASE_DISCOVER_VENDOR: + return sandbox_scmi_base_discover_vendor(dev, msg); + case SCMI_BASE_DISCOVER_SUB_VENDOR: + return sandbox_scmi_base_discover_sub_vendor(dev, msg); + case SCMI_BASE_DISCOVER_IMPL_VERSION: + return sandbox_scmi_base_discover_impl_version(dev, msg); + case SCMI_BASE_DISCOVER_LIST_PROTOCOLS: + return sandbox_scmi_base_discover_list_protocols(dev, msg); + case SCMI_BASE_DISCOVER_AGENT: + return sandbox_scmi_base_discover_agent(dev, msg); + case SCMI_BASE_NOTIFY_ERRORS: + break; + case SCMI_BASE_SET_DEVICE_PERMISSIONS: + return sandbox_scmi_base_set_device_permissions(dev, msg); + case SCMI_BASE_SET_PROTOCOL_PERMISSIONS: + return sandbox_scmi_base_set_protocol_permissions(dev, msg); + case SCMI_BASE_RESET_AGENT_CONFIGURATION: + return sandbox_scmi_base_reset_agent_configuration(dev, msg); + default: + break; + } + break; case SCMI_PROTOCOL_ID_CLOCK: switch (msg->message_id) { case SCMI_PROTOCOL_ATTRIBUTES: @@ -517,7 +875,6 @@ static int sandbox_scmi_test_process_msg(struct udevice *dev, break; } break; - case SCMI_PROTOCOL_ID_BASE: case SCMI_PROTOCOL_ID_POWER_DOMAIN: case SCMI_PROTOCOL_ID_SYSTEM: case SCMI_PROTOCOL_ID_PERF: From patchwork Wed Jun 28 00:48:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 697208 Delivered-To: patch@linaro.org Received: by 2002:adf:e885:0:0:0:0:0 with SMTP id d5csp4080499wrm; Tue, 27 Jun 2023 17:51:23 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6Lj9kJdUNLXPtSNqc6i0C5ujjvfQnK28zUkM5u9s9wD1qs21wUJOJrltZshJrnipkWj70c X-Received: by 2002:a05:6512:2348:b0:4fb:897e:21cc with SMTP id p8-20020a056512234800b004fb897e21ccmr2243597lfu.67.1687913483107; Tue, 27 Jun 2023 17:51:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687913483; cv=none; d=google.com; s=arc-20160816; b=0YDg0tbpx45ebLd71uvH+zvgs8j143qh5h2/tQZPfMdhxby1qutikImt5ApesvaDdk 9oUXclueyYOf9AAOTUkE0qA50Nq8NCjwz05UDb+TFGpmh2pheTu4hsufNGcfws3oH5/q 86O+SkEzz3C/5AzaOXDCuGNgmImsWjYVRnWZNbYLhzW+pLAlsx8neTqHwtXvhiGVg5OP cYlWO9xD8zw4O7G+rYy3+ySAz32SxBfJXEFIVBt9nzUymA/FGV8F5ty9EwXMWtjAuhCk 3kR+P2Ws+iL2SaAU2i8GMC+5tljC3ZADJDiIUoPq/SnrZC7vEP1MuQ2cZPlNF8HtET3T 0oDg== 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=PmGE/j4jI07T4YmSb9D0pV0n8bxJkM8vUZVBePWMyQ4=; fh=+s9SE2w9oguEKAMcR35TXtqntCOeVFhiK9u/Kju91lo=; b=OCmrBqJy/QPv1OcR4APhDSFrP0vFfG8t5Vpx45gXRPX9s+714CQKogzkPucoVJx38A POLPoIshO8+oxw4l32iT5l8ZGOKWxfGFtHmNBhrewZnqWwzrlSu3FD4PYqXJHI5rre6G nVdvgFjk4FGdpKIOoVeYzWAzkn97JliMwndZdRdmV6NRaIkQSSNgbiI2EoZAIflwi67N MYzPrt75Qy5mYN8eivx4xp9gIDX3H9zcBNdrzBtCFBvVWhHcUnyWXWgz0s4PB4gba4EM XfvMEHS92vLck/UVUxFajmWsU03kf38C3Rs3kPXcESbLd/dfRZLEqC3I4N3NwINcVS0A 24CA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rpqPyG2q; 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 i1-20020ac25221000000b004f5d596173fsi2521945lfl.317.2023.06.27.17.51.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Jun 2023 17:51:23 -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=rpqPyG2q; 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 D27418662F; Wed, 28 Jun 2023 02:50:52 +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="rpqPyG2q"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 458BF8662B; Wed, 28 Jun 2023 02:50:13 +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, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) (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 BB8E986615 for ; Wed, 28 Jun 2023 02:49:44 +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-x634.google.com with SMTP id d9443c01a7336-1b3ecb17721so9825885ad.0 for ; Tue, 27 Jun 2023 17:49:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1687913383; x=1690505383; 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=PmGE/j4jI07T4YmSb9D0pV0n8bxJkM8vUZVBePWMyQ4=; b=rpqPyG2qCotOmXSV1M5qBeraDpcf4TKhRvw3mPWktRiKr53FrTgsgIB04BEHRRMMm8 ZYWnCP1NL50pf1ZU35hwb23qkNnNeIoUNwEkfl7BmkB78OEJ5lJu/JN3H8k/bdfA7e8s 0Y4ibbeGjSo9Roeo48PpG1LcfwLG48ueqXVyOhH25du6PF/XBR9q6dvQkbIDRfCYXzrn FjdWZwqA7SEeTl4AxpCQ+agVVWRE3sdfhHGtyDMHnC0DjRwGNBKvSmnr1AGcbtgdeIGh a2v7c0UGZyggf0b4cluoQq2z8M1f//37PH0spyP2pPLM1L8143pAfWou8ZFSk/W4aNMu wmXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687913383; x=1690505383; 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=PmGE/j4jI07T4YmSb9D0pV0n8bxJkM8vUZVBePWMyQ4=; b=IyHeX26lzco+YghmYF0eDcggsF5OgIeEJ59Eb5OaTht2c82yLDidXWRoWOQSOpMlqT 7UZmqya5NnpR97xYaNyGM4WYjr5eNiY5oL3tNguoJi3fZgpdwmH+SygtJyZ2S5wFOzg9 87Ueswlgx6wVAot/LRd5urZl5oOCXFzUGT0Y11EAUusodAzViSrfIaOzibSX6++Dc2Ys cR6xVrBTIbHOouSp6BYiP/Qv3VpgOFgLaDb/R0hZqcvdOeqjT9jXkptySo+CyZWSwzfG lyEzruxwDj2jr+6Wz1apIML9Q0UPNJ9p8dIWO3O+AN/5TaX93Ew0X8CZCSRYp7Kg4oUi So6A== X-Gm-Message-State: AC+VfDwKi+ZisuLaTwH9uf37LA1ldkx2i+XjXu29SckYc1CFNu95rcVl pecX+xgonc5K+x4FJNPuSuWtwQ== X-Received: by 2002:a17:902:da91:b0:1b0:3d54:358f with SMTP id j17-20020a170902da9100b001b03d54358fmr39632270plx.0.1687913382850; Tue, 27 Jun 2023 17:49:42 -0700 (PDT) Received: from laputa.. ([2400:4050:c3e1:100:58b2:60ed:38ea:8b1f]) by smtp.gmail.com with ESMTPSA id u13-20020a170903124d00b001b3fb2f0296sm6517278plh.120.2023.06.27.17.49.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Jun 2023 17:49:42 -0700 (PDT) From: AKASHI Takahiro To: trini@konsulko.com, sjg@chromium.org Cc: etienne.carriere@st.com, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH 06/10] test: dm: simplify SCMI unit test on sandbox Date: Wed, 28 Jun 2023 09:48:37 +0900 Message-ID: <20230628004841.21774-7-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230628004841.21774-1-takahiro.akashi@linaro.org> References: <20230628004841.21774-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 Adding SCMI base protocol makes it inconvenient to hold the agent instance (udevice) locally since the agent device will be re-created per each test. Just remove it and simply the test flows. The test scenario is not changed at all. Signed-off-by: AKASHI Takahiro Reviewed-by: Simon Glass --- arch/sandbox/include/asm/scmi_test.h | 7 ++- drivers/firmware/scmi/sandbox-scmi_agent.c | 20 +------ drivers/firmware/scmi/scmi_agent-uclass.c | 14 ----- test/dm/scmi.c | 64 +++++++--------------- 4 files changed, 26 insertions(+), 79 deletions(-) diff --git a/arch/sandbox/include/asm/scmi_test.h b/arch/sandbox/include/asm/scmi_test.h index c72ec1e1cb25..2718336a9a50 100644 --- a/arch/sandbox/include/asm/scmi_test.h +++ b/arch/sandbox/include/asm/scmi_test.h @@ -89,10 +89,11 @@ struct sandbox_scmi_devices { #ifdef CONFIG_SCMI_FIRMWARE /** - * sandbox_scmi_service_ctx - Get the simulated SCMI services context + * sandbox_scmi_agent_ctx - Get the simulated SCMI agent context + * @dev: Reference to the test agent * @return: Reference to backend simulated resources state */ -struct sandbox_scmi_service *sandbox_scmi_service_ctx(void); +struct sandbox_scmi_agent *sandbox_scmi_agent_ctx(struct udevice *dev); /** * sandbox_scmi_devices_ctx - Get references to devices accessed through SCMI @@ -101,7 +102,7 @@ struct sandbox_scmi_service *sandbox_scmi_service_ctx(void); */ struct sandbox_scmi_devices *sandbox_scmi_devices_ctx(struct udevice *dev); #else -static inline struct sandbox_scmi_service *sandbox_scmi_service_ctx(void) +static struct sandbox_scmi_agent *sandbox_scmi_agent_ctx(struct udevice *dev) { return NULL; } diff --git a/drivers/firmware/scmi/sandbox-scmi_agent.c b/drivers/firmware/scmi/sandbox-scmi_agent.c index 1f0261ea5c94..ab8afb01de40 100644 --- a/drivers/firmware/scmi/sandbox-scmi_agent.c +++ b/drivers/firmware/scmi/sandbox-scmi_agent.c @@ -66,11 +66,9 @@ static struct sandbox_scmi_voltd scmi_voltd[] = { { .id = 1, .voltage_uv = 1800000 }, }; -static struct sandbox_scmi_service sandbox_scmi_service_state; - -struct sandbox_scmi_service *sandbox_scmi_service_ctx(void) +struct sandbox_scmi_agent *sandbox_scmi_agent_ctx(struct udevice *dev) { - return &sandbox_scmi_service_state; + return dev_get_priv(dev); } static void debug_print_agent_state(struct udevice *dev, char *str) @@ -898,16 +896,8 @@ static int sandbox_scmi_test_process_msg(struct udevice *dev, static int sandbox_scmi_test_remove(struct udevice *dev) { - struct sandbox_scmi_agent *agent = dev_get_priv(dev); - - if (agent != sandbox_scmi_service_ctx()->agent) - return -EINVAL; - debug_print_agent_state(dev, "removed"); - /* We only need to dereference the agent in the context */ - sandbox_scmi_service_ctx()->agent = NULL; - return 0; } @@ -915,9 +905,6 @@ static int sandbox_scmi_test_probe(struct udevice *dev) { struct sandbox_scmi_agent *agent = dev_get_priv(dev); - if (sandbox_scmi_service_ctx()->agent) - return -EINVAL; - *agent = (struct sandbox_scmi_agent){ .clk = scmi_clk, .clk_count = ARRAY_SIZE(scmi_clk), @@ -929,9 +916,6 @@ static int sandbox_scmi_test_probe(struct udevice *dev) debug_print_agent_state(dev, "probed"); - /* Save reference for tests purpose */ - sandbox_scmi_service_ctx()->agent = agent; - return 0; }; diff --git a/drivers/firmware/scmi/scmi_agent-uclass.c b/drivers/firmware/scmi/scmi_agent-uclass.c index ec15580cc947..4526f75486ed 100644 --- a/drivers/firmware/scmi/scmi_agent-uclass.c +++ b/drivers/firmware/scmi/scmi_agent-uclass.c @@ -37,12 +37,6 @@ static const struct error_code scmi_linux_errmap[] = { { .scmi = SCMI_PROTOCOL_ERROR, .errno = -EPROTO, }, }; -/* - * NOTE: The only one instance should exist according to - * the current specification and device tree bindings. - */ -struct udevice *scmi_agent; - struct udevice *scmi_get_protocol(struct udevice *dev, enum scmi_std_protocol id) { @@ -150,11 +144,6 @@ static int scmi_bind_protocols(struct udevice *dev) struct driver *drv; struct udevice *proto; - if (scmi_agent) { - dev_err(dev, "SCMI agent already exists: %s\n", dev->name); - return -EBUSY; - } - drv = DM_DRIVER_GET(scmi_base_drv); name = "scmi-base.0"; ret = device_bind(dev, drv, name, NULL, ofnode_null(), &proto); @@ -222,9 +211,6 @@ static int scmi_bind_protocols(struct udevice *dev) } } - if (!ret) - scmi_agent = dev; - return ret; } diff --git a/test/dm/scmi.c b/test/dm/scmi.c index d87e2731ce42..881be3171b7c 100644 --- a/test/dm/scmi.c +++ b/test/dm/scmi.c @@ -23,22 +23,11 @@ #include #include -static int ut_assert_scmi_state_preprobe(struct unit_test_state *uts) -{ - struct sandbox_scmi_service *scmi_ctx = sandbox_scmi_service_ctx(); - - ut_assertnonnull(scmi_ctx); - ut_assertnull(scmi_ctx->agent); - - return 0; -} - static int ut_assert_scmi_state_postprobe(struct unit_test_state *uts, + struct sandbox_scmi_agent *agent, struct udevice *dev) { struct sandbox_scmi_devices *scmi_devices; - struct sandbox_scmi_service *scmi_ctx; - struct sandbox_scmi_agent *agent; /* Device references to check context against test sequence */ scmi_devices = sandbox_scmi_devices_ctx(dev); @@ -48,10 +37,6 @@ static int ut_assert_scmi_state_postprobe(struct unit_test_state *uts, ut_asserteq(2, scmi_devices->regul_count); /* State of the simulated SCMI server exposed */ - scmi_ctx = sandbox_scmi_service_ctx(); - ut_assertnonnull(scmi_ctx); - agent = scmi_ctx->agent; - ut_assertnonnull(agent); ut_asserteq(3, agent->clk_count); ut_assertnonnull(agent->clk); ut_asserteq(1, agent->reset_count); @@ -63,27 +48,32 @@ static int ut_assert_scmi_state_postprobe(struct unit_test_state *uts, } static int load_sandbox_scmi_test_devices(struct unit_test_state *uts, + struct sandbox_scmi_agent **ctx, struct udevice **dev) { - int ret; + struct udevice *agent_dev; - ret = ut_assert_scmi_state_preprobe(uts); - if (ret) - return ret; + ut_assertok(uclass_get_device_by_name(UCLASS_SCMI_AGENT, "scmi", + &agent_dev)); + ut_assertnonnull(agent_dev); + + *ctx = sandbox_scmi_agent_ctx(agent_dev); + ut_assertnonnull(*ctx); + /* probe */ ut_assertok(uclass_get_device_by_name(UCLASS_MISC, "sandbox_scmi", dev)); ut_assertnonnull(*dev); - return ut_assert_scmi_state_postprobe(uts, *dev); + return ut_assert_scmi_state_postprobe(uts, *ctx, *dev); } static int release_sandbox_scmi_test_devices(struct unit_test_state *uts, struct udevice *dev) { + /* un-probe */ ut_assertok(device_remove(dev, DM_REMOVE_NORMAL)); - /* Not sure test devices are fully removed, agent may not be visible */ return 0; } @@ -93,10 +83,11 @@ static int release_sandbox_scmi_test_devices(struct unit_test_state *uts, */ static int dm_test_scmi_sandbox_agent(struct unit_test_state *uts) { + struct sandbox_scmi_agent *ctx; struct udevice *dev = NULL; int ret; - ret = load_sandbox_scmi_test_devices(uts, &dev); + ret = load_sandbox_scmi_test_devices(uts, &ctx, &dev); if (!ret) ret = release_sandbox_scmi_test_devices(uts, dev); @@ -106,23 +97,18 @@ DM_TEST(dm_test_scmi_sandbox_agent, UT_TESTF_SCAN_FDT); static int dm_test_scmi_clocks(struct unit_test_state *uts) { - struct sandbox_scmi_devices *scmi_devices; - struct sandbox_scmi_service *scmi_ctx; struct sandbox_scmi_agent *agent; + struct sandbox_scmi_devices *scmi_devices; struct udevice *dev; int ret_dev; int ret; - ret = load_sandbox_scmi_test_devices(uts, &dev); + ret = load_sandbox_scmi_test_devices(uts, &agent, &dev); if (ret) return ret; scmi_devices = sandbox_scmi_devices_ctx(dev); ut_assertnonnull(scmi_devices); - scmi_ctx = sandbox_scmi_service_ctx(); - ut_assertnonnull(scmi_ctx); - agent = scmi_ctx->agent; - ut_assertnonnull(agent); /* Test SCMI clocks rate manipulation */ ut_asserteq(333, agent->clk[0].rate); @@ -169,22 +155,17 @@ DM_TEST(dm_test_scmi_clocks, UT_TESTF_SCAN_FDT); static int dm_test_scmi_resets(struct unit_test_state *uts) { - struct sandbox_scmi_devices *scmi_devices; - struct sandbox_scmi_service *scmi_ctx; struct sandbox_scmi_agent *agent; + struct sandbox_scmi_devices *scmi_devices; struct udevice *dev = NULL; int ret; - ret = load_sandbox_scmi_test_devices(uts, &dev); + ret = load_sandbox_scmi_test_devices(uts, &agent, &dev); if (ret) return ret; scmi_devices = sandbox_scmi_devices_ctx(dev); ut_assertnonnull(scmi_devices); - scmi_ctx = sandbox_scmi_service_ctx(); - ut_assertnonnull(scmi_ctx); - agent = scmi_ctx->agent; - ut_assertnonnull(agent); /* Test SCMI resect controller manipulation */ ut_assert(!agent->reset[0].asserted); @@ -201,21 +182,16 @@ DM_TEST(dm_test_scmi_resets, UT_TESTF_SCAN_FDT); static int dm_test_scmi_voltage_domains(struct unit_test_state *uts) { - struct sandbox_scmi_devices *scmi_devices; - struct sandbox_scmi_service *scmi_ctx; struct sandbox_scmi_agent *agent; + struct sandbox_scmi_devices *scmi_devices; struct dm_regulator_uclass_plat *uc_pdata; struct udevice *dev; struct udevice *regul0_dev; - ut_assertok(load_sandbox_scmi_test_devices(uts, &dev)); + ut_assertok(load_sandbox_scmi_test_devices(uts, &agent, &dev)); scmi_devices = sandbox_scmi_devices_ctx(dev); ut_assertnonnull(scmi_devices); - scmi_ctx = sandbox_scmi_service_ctx(); - ut_assertnonnull(scmi_ctx); - agent = scmi_ctx->agent; - ut_assertnonnull(agent); /* Set/Get an SCMI voltage domain level */ regul0_dev = scmi_devices->regul[0]; From patchwork Wed Jun 28 00:48:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 697206 Delivered-To: patch@linaro.org Received: by 2002:adf:e885:0:0:0:0:0 with SMTP id d5csp4080341wrm; Tue, 27 Jun 2023 17:50:54 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7ZG1ekK43WfsJCz06SJbnm/monw/UpRSeLNp5EKqHgof/mZI9TG/ueSF8L8PlI7Vv4B7qQ X-Received: by 2002:a05:651c:8f:b0:2b6:a17b:a120 with SMTP id 15-20020a05651c008f00b002b6a17ba120mr5279868ljq.22.1687913454655; Tue, 27 Jun 2023 17:50:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687913454; cv=none; d=google.com; s=arc-20160816; b=mJz27QkOih+GK7KnaTkpVhu0FRZL1o4SBKOaoNhrjpWjWsZrRWyZr4PnuiubFIdds8 c0/fcifzGmqfEV55KpCmcuKwVo+9NVy5iYbRCHMLK6z2XjtSeKevBREzBPKe3eifyup1 MDCwH2GDavFMBxUaei5XRIZDoECTIlR477yzdPPt1IpBU0EDbY3MRa5002DlPhAfN1Ta yyXGE+RdJUSyyswpb2SUwKwXwzdVIWL3DKw32jVhTMkr2yoZSH6ifka0GUmJy1J6LSUK YepVPNsBH3FOjnL0j+4Y5ngndl7rx+rfgHpd3juKaI3IREfhaJwgYjV6DGfDzCD5bW9O 5PYQ== 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=y1sDemrPnZo1ZNJDDmR5Eyix8Xrx1ojgu+L7WRiAdqM=; fh=+s9SE2w9oguEKAMcR35TXtqntCOeVFhiK9u/Kju91lo=; b=pKCXa0bvYCeAMaYJ3owgW37S0bA1lyBOiC4o9u7xct3X6CzY2P5qxOXjzLN+3M3fhO c6kmOEjlGNUgcIEw9E2SAXvRXvSknVOMXkHM18mcs8eEzmQ5x+VIg99ESwyAYIgArxwP kWO6PUD0Wkj/ez6NJ35gVxm33I/bVVvTNdRVZLuCYU2dU5kL1VC9JcEesh92v2XrnSEC OTYlz58F4/mvcpLoBgFiAF+qn6mX+52mZ8SSR/yZapOEz9Qj7My8F3MAQGgHY1VHCy77 PT2hqspk0DCDPfKYEgEzxYJbJNCTdJcVlbneiFddHKdM4fb5ih32GWUZzkkkgJGGvRs1 3zCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Rr4ZChYZ; 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 x26-20020a2e9dda000000b002b69b37c0a3si2330429ljj.295.2023.06.27.17.50.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Jun 2023 17:50:54 -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=Rr4ZChYZ; 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 76C8D8662B; Wed, 28 Jun 2023 02:50:36 +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="Rr4ZChYZ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 47BF78662A; Wed, 28 Jun 2023 02:50: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, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) (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 B0EE286618 for ; Wed, 28 Jun 2023 02:49:46 +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-x634.google.com with SMTP id d9443c01a7336-1b8053aece3so4739525ad.1 for ; Tue, 27 Jun 2023 17:49:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1687913385; x=1690505385; 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=y1sDemrPnZo1ZNJDDmR5Eyix8Xrx1ojgu+L7WRiAdqM=; b=Rr4ZChYZKnIixvFPz+5U5JtC12raCodOUWQavn8e6rQyqs++Pf/PBBt0K9VIcFF23s 2ctrOzX5pJtMVcuZsSmLW3XuGBg43gUeigmXY0sozzafYZ1I7WB/VGmDJbV2VR2KFGQJ lYlLpG5gyFCrxBM0yI5FGGpR7Jea36kaJayjcj0A2tBvBhmOh17WvsW+hkuESiz+UPXM 9DaiYcJUheXhhxRJi06UxL3l/6qGonQ/5fKrimWH2HTKhlTR79AIyhf47CLZK9PVhV6i dk0VjqtEmlRMONFxsVzi1WB43+fk8X7glyPZWvKQvIKpeOiurMV4NhnsOPb0Qxe6KJsY e+hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687913385; x=1690505385; 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=y1sDemrPnZo1ZNJDDmR5Eyix8Xrx1ojgu+L7WRiAdqM=; b=RyYYJprn6cN1iYmDHXH48rLfMU76LQYvhhhpkscYeJr/0WSMrslFStvOxU3U6CArFk 6bH1yYT6XamA26ba7KvtVcsQKlYmqRp+F4GESMlDL/sHt3i5S42pfmC4tbuKX/CExoAV 9nDMXej4QW+9vodp63DdGF1J9CfeU3Yj3nteZKtOCgU8m2MkQeW2ciPvYFogkto/iq+f IAGhdgXsphYevh63mbuhh3pw6Ms+c+ROfjPP5URJgr6+Y6gLq5RhtBG6xQgLI6KjnOHQ zvr3f1ud2j1Gkv8wkeHpXt1yqMFlZBbZhmfwk9u4QtRdpp43f/OrcJiFd78Y6/hWsEaC hjxw== X-Gm-Message-State: AC+VfDy66g6KHH5AGVFo5wzvBdO7FQJ+bsH0oMo6wPDcI+XPcT+zEjbr dLT3MhgfXGD4g9nfRg/V4qP7Kw== X-Received: by 2002:a17:903:338d:b0:1b8:17e8:5482 with SMTP id kb13-20020a170903338d00b001b817e85482mr4459709plb.1.1687913385019; Tue, 27 Jun 2023 17:49:45 -0700 (PDT) Received: from laputa.. ([2400:4050:c3e1:100:58b2:60ed:38ea:8b1f]) by smtp.gmail.com with ESMTPSA id u13-20020a170903124d00b001b3fb2f0296sm6517278plh.120.2023.06.27.17.49.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Jun 2023 17:49:44 -0700 (PDT) From: AKASHI Takahiro To: trini@konsulko.com, sjg@chromium.org Cc: etienne.carriere@st.com, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH 07/10] test: dm: add SCMI base protocol test Date: Wed, 28 Jun 2023 09:48:38 +0900 Message-ID: <20230628004841.21774-8-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230628004841.21774-1-takahiro.akashi@linaro.org> References: <20230628004841.21774-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 Added is a new unit test for SCMI base protocol, which will exercise all the commands provided by the protocol, except SCMI_BASE_NOTIFY_ERRORS. $ ut dm scmi_base It is assumed that test.dtb is used as sandbox's device tree. Signed-off-by: AKASHI Takahiro --- test/dm/scmi.c | 112 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) diff --git a/test/dm/scmi.c b/test/dm/scmi.c index 881be3171b7c..563017bb63e0 100644 --- a/test/dm/scmi.c +++ b/test/dm/scmi.c @@ -16,6 +16,9 @@ #include #include #include +#include +#include +#include #include #include #include @@ -95,6 +98,115 @@ static int dm_test_scmi_sandbox_agent(struct unit_test_state *uts) } DM_TEST(dm_test_scmi_sandbox_agent, UT_TESTF_SCAN_FDT); +static int dm_test_scmi_base(struct unit_test_state *uts) +{ + struct udevice *agent_dev, *base; + struct scmi_agent_priv *priv; + const struct scmi_base_ops *ops; + u32 version, num_agents, num_protocols, impl_version; + u32 attributes, agent_id; + char vendor[SCMI_BASE_NAME_LENGTH_MAX], + agent_name[SCMI_BASE_NAME_LENGTH_MAX]; + u8 *protocols; + int ret; + + /* preparation */ + ut_assertok(uclass_get_device_by_name(UCLASS_SCMI_AGENT, "scmi", + &agent_dev)); + ut_assertnonnull(agent_dev); + ut_assertnonnull(priv = dev_get_uclass_plat(agent_dev)); + ut_assertnonnull(base = scmi_get_protocol(agent_dev, + SCMI_PROTOCOL_ID_BASE)); + ut_assertnonnull(ops = dev_get_driver_ops(base)); + + /* version */ + ret = (*ops->protocol_version)(base, &version); + ut_assertok(ret); + ut_asserteq(priv->version, version); + + /* protocol attributes */ + ret = (*ops->protocol_attrs)(base, &num_agents, &num_protocols); + ut_assertok(ret); + ut_asserteq(priv->num_agents, num_agents); + ut_asserteq(priv->num_protocols, num_protocols); + + /* discover vendor */ + ret = (*ops->base_discover_vendor)(base, vendor); + ut_assertok(ret); + ut_asserteq_str(priv->vendor, vendor); + + /* message attributes */ + ret = (*ops->protocol_message_attrs)(base, + SCMI_BASE_DISCOVER_SUB_VENDOR, + &attributes); + ut_assertok(ret); + ut_assertok(attributes); + + /* discover sub vendor */ + ret = (*ops->base_discover_sub_vendor)(base, vendor); + ut_assertok(ret); + ut_asserteq_str(priv->sub_vendor, vendor); + + /* impl version */ + ret = (*ops->base_discover_impl_version)(base, &impl_version); + ut_assertok(ret); + ut_asserteq(priv->impl_version, impl_version); + + /* discover agent (my self) */ + ret = (*ops->base_discover_agent)(base, 0xffffffff, + &agent_id, agent_name); + ut_assertok(ret); + ut_asserteq(priv->agent_id, agent_id); + ut_asserteq_str(priv->agent_name, agent_name); + + /* discover protocols */ + ret = (*ops->base_discover_list_protocols)(base, &protocols); + ut_asserteq(num_protocols, ret); + ut_asserteq_mem(priv->protocols, protocols, sizeof(u8) * num_protocols); + free(protocols); + + /* + * NOTE: Sandbox SCMI driver handles device-0 only. It supports setting + * access and protocol permissions, but doesn't allow unsetting them nor + * resetting the configurations. + */ + /* set device permissions */ + ret = (*ops->base_set_device_permissions)(base, agent_id, 0, + SCMI_BASE_SET_DEVICE_PERMISSIONS_ACCESS); + ut_assertok(ret); /* SCMI_SUCCESS */ + ret = (*ops->base_set_device_permissions)(base, agent_id, 1, + SCMI_BASE_SET_DEVICE_PERMISSIONS_ACCESS); + ut_asserteq(-ENOENT, ret); /* SCMI_NOT_FOUND */ + ret = (*ops->base_set_device_permissions)(base, agent_id, 0, 0); + ut_asserteq(-EACCES, ret); /* SCMI_DENIED */ + + /* set protocol permissions */ + ret = (*ops->base_set_protocol_permissions)(base, agent_id, 0, + SCMI_PROTOCOL_ID_CLOCK, + SCMI_BASE_SET_PROTOCOL_PERMISSIONS_ACCESS); + ut_assertok(ret); /* SCMI_SUCCESS */ + ret = (*ops->base_set_protocol_permissions)(base, agent_id, 1, + SCMI_PROTOCOL_ID_CLOCK, + SCMI_BASE_SET_PROTOCOL_PERMISSIONS_ACCESS); + ut_asserteq(-ENOENT, ret); /* SCMI_NOT_FOUND */ + ret = (*ops->base_set_protocol_permissions)(base, agent_id, 0, + SCMI_PROTOCOL_ID_CLOCK, 0); + ut_asserteq(-EACCES, ret); /* SCMI_DENIED */ + + /* reset agent configuration */ + ret = (*ops->base_reset_agent_configuration)(base, agent_id, 0); + ut_asserteq(-EACCES, ret); /* SCMI_DENIED */ + ret = (*ops->base_reset_agent_configuration)(base, agent_id, + SCMI_BASE_RESET_ALL_ACCESS_PERMISSIONS); + ut_asserteq(-EACCES, ret); /* SCMI_DENIED */ + ret = (*ops->base_reset_agent_configuration)(base, agent_id, 0); + ut_asserteq(-EACCES, ret); /* SCMI_DENIED */ + + return 0; +} + +DM_TEST(dm_test_scmi_base, UT_TESTF_SCAN_FDT); + static int dm_test_scmi_clocks(struct unit_test_state *uts) { struct sandbox_scmi_agent *agent; From patchwork Wed Jun 28 00:48:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 697211 Delivered-To: patch@linaro.org Received: by 2002:adf:e885:0:0:0:0:0 with SMTP id d5csp4080668wrm; Tue, 27 Jun 2023 17:52:00 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5ZUg4vq7tI5DXR5f5IUZMQj9nA9qe2iXhsovuyepHfCfprhnZISqu0WXVuVpBk2sF+EEOC X-Received: by 2002:a19:8c49:0:b0:4f8:5e3c:f3a7 with SMTP id i9-20020a198c49000000b004f85e3cf3a7mr17714148lfj.43.1687913520129; Tue, 27 Jun 2023 17:52:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687913520; cv=none; d=google.com; s=arc-20160816; b=PDOv32704VUca+PkS17Cbt/DgMO0fKLg+iOhy8lW4+X+SPUY4LE8aAy6dm7DCrI+y4 xE9CskPIkwSw3vEpjYeVwfrSofHYwyu0tHpDICbzHHLA3hPsJXdjeghPNCSPUz7HiPID Hn1xGLbEjeQ0jCf1bJr1hp5Q5do3+pKDRNj1Hirxysacdov8C5FLJUKzKuYLeukJNVLI zTomgGAPg15EoWKprZtOzWLL85FHmfj2Cz1Pvr38Si4m2VPDvzo5RoUbpNTfMlqqPXdp LMbu+Lpn0uHjW3ilsFKideJjByHD6elK67j5WwkZdnr50vrXgLBg2OpyjnX4R7GGgAto 1fjA== 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=PUuJEttX6eCHhIWH0ZZXsJpCl44PC57ltLgFtzHxOvk=; fh=+s9SE2w9oguEKAMcR35TXtqntCOeVFhiK9u/Kju91lo=; b=LeCq6rCwT9VoERCfkXNNXLEiYAM7h2HQwvPyKaGRZgTvRnW9oASugJFl0aKyt2BFF6 ZwiiwFtOphgrlhtYajV03OC/E7F490l0q0MsowplPmAI9XWWIdQKM3kMQhpLijqqnNCV r4wreKFsEV9y8zTXe8aGgbVakKAahzNOPciCgQ90c3G5E2BfLChZ7edquXAt2mcz8EHe g/DIFbNzDaGXJ8VLyHlhIHX7xnxlKLpU5FzRTY9S/jo464xAH8Fbj/+GmsSpRRH5rDJg EahxqwXyt0SgmZ/idgbP6eI6LZTfxws2U9l1mMXi/vILoj+7XPAPg+hM2HtA9QrEvEMX 0Vrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YY2er5WD; 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 f3-20020ac251a3000000b004fb7848bacfsi1477382lfk.125.2023.06.27.17.51.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Jun 2023 17:52:00 -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=YY2er5WD; 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 34C9586648; Wed, 28 Jun 2023 02:51:32 +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="YY2er5WD"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5881186620; Wed, 28 Jun 2023 02:50:28 +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, 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 4927E86613 for ; Wed, 28 Jun 2023 02:49:49 +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-1b3ecb17721so9825965ad.0 for ; Tue, 27 Jun 2023 17:49:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1687913387; x=1690505387; 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=PUuJEttX6eCHhIWH0ZZXsJpCl44PC57ltLgFtzHxOvk=; b=YY2er5WDzDkJIu9/81VQ8z+PgLGWDFZjPtgFMlpv43JB6OK+uLPBye602vY20lU7R/ iTqY9szI//w8CD98BhCguetqyK6YFvyUiRog0CMyI3Fgv30dCXlcxxHKrIaqcUyY9vs4 MuEmVlEx6fx6aHyPaNMr8pjmdT4kh+x9PrGIyqA1IL8h0A1xzAQwduLOEotvtYZC2yae GuyMHvMZA2lv2Tt0wnFj4hAJt68dgf6mCyEve2r027ihs4ryVoS/rvfmmGFNo2FV79S1 VSdtoHVmk8E222WzJfGT+9XHhdA0hdUZLcRW23EWH5jWJapPKtycpMpj95mNYx3ExZ6d QgVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687913387; x=1690505387; 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=PUuJEttX6eCHhIWH0ZZXsJpCl44PC57ltLgFtzHxOvk=; b=A1U7QEgylZR8alPy7R5gV3Y0eRNeQKgvG6Mrv9sgMfFrauS3us5QPLMRpO827PWZkX KDfU4vjjmZRsLZdk3BRJ+HmfONkdEcafwfOk02fzJTNxUoMO8kBOIn03gZOh589f+tB8 Gp+a8ks8G8GEdz7uiKQByJPsmqtWuqNMo+Ofptnm5oV3YWH6psJgVwyBSKK7PM4UN1jN 58qIgb6kY06GfcvdiJV+7jOl1yylIc3rd/zlaJW4VsDjt+UTrahAEzp5UGQScrIYWsLG C2PCg5PupAd7x7uNlAlSDYuMHqRKTFOpmihj0paQA/XRCx0kkScHYCJVnJTJozeXXrLa SxCg== X-Gm-Message-State: AC+VfDzeQtK5rMMFUSo+mlSNgqdEWJDFmk2XGDMWNX7Le/Vd+I9xxYGh ZY+grq+nVruSXl+8Cd9CrBZc+Q== X-Received: by 2002:a17:903:22c3:b0:1b8:17e8:5472 with SMTP id y3-20020a17090322c300b001b817e85472mr4789894plg.1.1687913387217; Tue, 27 Jun 2023 17:49:47 -0700 (PDT) Received: from laputa.. ([2400:4050:c3e1:100:58b2:60ed:38ea:8b1f]) by smtp.gmail.com with ESMTPSA id u13-20020a170903124d00b001b3fb2f0296sm6517278plh.120.2023.06.27.17.49.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Jun 2023 17:49:46 -0700 (PDT) From: AKASHI Takahiro To: trini@konsulko.com, sjg@chromium.org Cc: etienne.carriere@st.com, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH 08/10] cmd: add scmi command for SCMI firmware Date: Wed, 28 Jun 2023 09:48:39 +0900 Message-ID: <20230628004841.21774-9-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230628004841.21774-1-takahiro.akashi@linaro.org> References: <20230628004841.21774-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", provides a command line interface to various SCMI protocols. It supports at least initially SCMI base protocol with the sub command, "base", and is intended mainly for debug purpose. Signed-off-by: AKASHI Takahiro --- cmd/Kconfig | 8 ++ cmd/Makefile | 1 + cmd/scmi.c | 373 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 382 insertions(+) create mode 100644 cmd/scmi.c diff --git a/cmd/Kconfig b/cmd/Kconfig index 02e54f1e50fe..065470a76295 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -2504,6 +2504,14 @@ 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 protocols, + including Base protocol. endmenu menu "Filesystem commands" diff --git a/cmd/Makefile b/cmd/Makefile index 6c37521b4e2b..826e0b74b587 100644 --- a/cmd/Makefile +++ b/cmd/Makefile @@ -156,6 +156,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..c97f77e97d95 --- /dev/null +++ b/cmd/scmi.c @@ -0,0 +1,373 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * SCMI utility command + * + * Copyright (c) 2023 Linaro Limited + * Author: AKASHI Takahiro + */ + +#include +#include +#include +#include /* uclass_get_device */ +#include +#include +#include +#include +#include +#include + +static struct udevice *agent; +static struct udevice *base_proto; +static const struct scmi_base_ops *ops; + +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"}, +}; + +/** + * scmi_convert_id_to_string() - get the name of SCMI protocol + * + * @id: Protocol ID + * + * Get the printable name of the protocol, @id + * + * Return: Name string on success, NULL on failure + */ +static const char *scmi_convert_id_to_string(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_base_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_base_info(struct cmd_tbl *cmdtp, int flag, int argc, + char * const argv[]) +{ + u32 agent_id, num_protocols; + u8 agent_name[SCMI_BASE_NAME_LENGTH_MAX], *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 = (*ops->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); + } + 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", + scmi_convert_id_to_string(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_base_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_base_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 = (*ops->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 = (*ops->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_base_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_base_set_proto(struct cmd_tbl *cmdtp, int flag, int argc, + char * const argv[]) +{ + u32 agent_id, device_id, command_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; + + command_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 = (*ops->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 = (*ops->base_set_protocol_permissions)(base_proto, agent_id, + device_id, command_id, + flags); + if (ret) { + printf("%s access to protocol:0x%x on device:%u failed (%d)\n", + flags ? "Allowing" : "Denying", command_id, device_id, + ret); + return CMD_RET_FAILURE; + } + + return CMD_RET_SUCCESS; +} + +/** + * do_scmi_base_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_base_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 = (*ops->protocol_message_attrs)(base_proto, + SCMI_BASE_RESET_AGENT_CONFIGURATION, + &attributes); + if (ret) { + printf("Reset is not supported\n"); + return CMD_RET_FAILURE; + } + + ret = (*ops->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_base_sub[] = { + U_BOOT_CMD_MKENT(info, CONFIG_SYS_MAXARGS, 1, + do_scmi_base_info, "", ""), + U_BOOT_CMD_MKENT(perm_dev, CONFIG_SYS_MAXARGS, 1, + do_scmi_base_set_dev, "", ""), + U_BOOT_CMD_MKENT(perm_proto, CONFIG_SYS_MAXARGS, 1, + do_scmi_base_set_proto, "", ""), + U_BOOT_CMD_MKENT(reset, CONFIG_SYS_MAXARGS, 1, + do_scmi_base_reset, "", ""), +}; + +/** + * do_scmi_base() - handle SCMI base protocol + * + * @cmdtp: Command table + * @flag: Command flag + * @argc: Number of arguments + * @argv: Argument array + * + * Provide user interfaces to SCMI base protocol. + * + * Return: CMD_RET_SUCCESS on success, + * CMD_RET_USAGE or CMD_RET_RET_FAILURE on failure + */ +static int do_scmi_base(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 (!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; + } + ops = dev_get_driver_ops(base_proto); + + cp = find_cmd_tbl(argv[0], cmd_scmi_base_sub, + ARRAY_SIZE(cmd_scmi_base_sub)); + if (!cp) + return CMD_RET_USAGE; + + return cp->cmd(cmdtp, flag, argc, argv); +} + +static struct cmd_tbl cmd_scmi_sub[] = { + U_BOOT_CMD_MKENT(base, CONFIG_SYS_MAXARGS, 1, do_scmi_base, "", ""), +}; + +/** + * 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; + } + } + + 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" + " base info - get the info of SCMI services\n" + " base perm_dev \n" + " - set access permission to device\n" + " base perm_proto \n" + " - set protocol permission to device\n" + " base 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 Jun 28 00:48:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 697210 Delivered-To: patch@linaro.org Received: by 2002:adf:e885:0:0:0:0:0 with SMTP id d5csp4080599wrm; Tue, 27 Jun 2023 17:51:47 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6Ulh3KnP6osK2qD09r/8Xwy6AsKAuDX+Tv/26tEQjVIGqhJOfXB8zqT3ZDsG9XgyUBWT3r X-Received: by 2002:a05:6512:2315:b0:4f9:6a74:d149 with SMTP id o21-20020a056512231500b004f96a74d149mr11239065lfu.15.1687913507482; Tue, 27 Jun 2023 17:51:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687913507; cv=none; d=google.com; s=arc-20160816; b=FYbfZmrwKYu3B2f3qE1Dk9z+Y2PWgte5rMRmU+GGvlzbWJ8+y3wQumBuADfYkqpxXN 87vS/LKb92uJX3ttzuUu75rhl1W8LtLK8e6iP7906Wa14r42aJ4G5LEmSPYXycjrld5A PdcV+qI/wLXT2zZ3RMzjI0qZA7idyM/CXFJKKSgriHIzORVRlmoGmyV3hhhgPn/CD3Nn wgUwDL+g2qJYIOdJ9VIIQw2mC8NkJiEkktcpfPzVGuNEG9e5kRt4X3GTdN0NuwzrwYzZ BZ9x1Kej4KComa3Clyi38Gz97/oaj52VFLMiBzQt3rfdNdSN8oPVujOgYAi5ZUtEcttH dnIA== 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=o2/W/WeS6uFl1UoXejk4UI9prfCv7n3Y5G853Rg0tSE=; fh=+s9SE2w9oguEKAMcR35TXtqntCOeVFhiK9u/Kju91lo=; b=d03m/CftGgLyYRze4+O6eqK3+lRYTETvhQkRi/58NtaZdBYfM19WZVvSuP39jZm50Q VY5r8/1bywxL1xJ/1tD5yuQ/gFVhctlxFozeUswlQ34jEK0yD91hjuDFflMlToxm89aq OI0YfaYZAroD7qEA97r00MjA6muaqVnXbvzFH5HTD7VKbCOXC5NjQADPyrZMGHFKVAri FGD+zPuLooxz3C4rzh7/j5ProK24kyV4vSLxIoCPIfExpAzowYROyAeL6VwR7Yr69O0d U8+dUxNKU8J7MWbcO/DWfxr3Fkelfi6LOkeroRw0OUXNGgZxl6mKJPsKOQo3snzduSqv iu7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OUIigxR4; 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 r6-20020a19ac46000000b004f252d0f7fesi2621028lfc.79.2023.06.27.17.51.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Jun 2023 17:51:47 -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=OUIigxR4; 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 B6A9B8660F; Wed, 28 Jun 2023 02:51:20 +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="OUIigxR4"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9240D86607; Wed, 28 Jun 2023 02:50:23 +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, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) (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 EC1C58661C for ; Wed, 28 Jun 2023 02:49:50 +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-x62a.google.com with SMTP id d9443c01a7336-1b8130e0ac6so3019635ad.1 for ; Tue, 27 Jun 2023 17:49:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1687913389; x=1690505389; 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=o2/W/WeS6uFl1UoXejk4UI9prfCv7n3Y5G853Rg0tSE=; b=OUIigxR4T9aoLVEMxhfHbN+AITdBJIwt17sSC+eH5LrFOq86pe1TN8/o2eznfcQguJ j12mG/LgZVYEfJv3SbcUxxvt13s4oaH6rgU//9sEec+G/8SsotPub7y6i2qF+YV0Bedr ZmPm9PlDrSRzZC0E+chLLxkw7yDKdAHpvGdKrq5DNaL9ZYzrgn0u/RVLmWBIMBG9n5eG m49UuS4fT3qfozee84Tfp58gHKagDzui7mjLqS1mOVWcyGG10g12auYF1ncewXu9uzLC JwBiv0i9FveljBKCZ2Lq+Q0bQdUzJJ/Q83kKc8ptUbBUr3DX80WTQgBaXUm4wf2fTNMG 08oQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687913389; x=1690505389; 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=o2/W/WeS6uFl1UoXejk4UI9prfCv7n3Y5G853Rg0tSE=; b=g6JGo0rZA4RXjWOz0H8CbDsY3Gi1XXDrFJtFLWrmiC49Z9KX68es9csQEs+J7b05v/ 6n6EVWTqH2HfTZFHTAIMj6UhK5vbFz/z7HXCbaWstWfk4Rb55Jcx16Wq345YNc2zmvWT tsx/oy+J1GiAHLJxO48+A4u4L2pRgIPL++5UgiJKwMdC4dJNhci7YS3CmXqK0fYKue6F pCFSS7uGVQpgkBGk8eXCyjj4EJMz/dz/CRNEqTz4xNVWHV+8EghrBr4ZXmG/HyHSZTEC Wngg9OViyPBvK/+8Qr9/RoyJ7L2HH/yPVoZ5KJ4c8fwmmPVZGvud0LaoiM5uw4E7Uplt 6Bbg== X-Gm-Message-State: AC+VfDx4UDxpcY68dw+m8kI9gZxzZ43POlu5s91sGzKbORs5ha/8PF8w UO97Kzp/zdzcatsdNESz86BquA== X-Received: by 2002:a17:903:104c:b0:1b3:d4bb:3515 with SMTP id f12-20020a170903104c00b001b3d4bb3515mr3470639plc.0.1687913389260; Tue, 27 Jun 2023 17:49:49 -0700 (PDT) Received: from laputa.. ([2400:4050:c3e1:100:58b2:60ed:38ea:8b1f]) by smtp.gmail.com with ESMTPSA id u13-20020a170903124d00b001b3fb2f0296sm6517278plh.120.2023.06.27.17.49.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Jun 2023 17:49:49 -0700 (PDT) From: AKASHI Takahiro To: trini@konsulko.com, sjg@chromium.org Cc: etienne.carriere@st.com, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH 09/10] doc: cmd: add documentation for scmi Date: Wed, 28 Jun 2023 09:48:40 +0900 Message-ID: <20230628004841.21774-10-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230628004841.21774-1-takahiro.akashi@linaro.org> References: <20230628004841.21774-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 --- doc/usage/cmd/scmi.rst | 98 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 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..20cdae4b877d --- /dev/null +++ b/doc/usage/cmd/scmi.rst @@ -0,0 +1,98 @@ +.. SPDX-License-Identifier: GPL-2.0+: + +scmi command +============ + +Synopsis +-------- + +:: + + scmi base info + scmi base perm_dev + scmi base perm_proto + scmi base reset + +Description +----------- + +The scmi command is used to access and operate on SCMI server. + +scmi base info +~~~~~~~~~~~~~~ + Show base information about SCMI server and supported protocols + +scmi base perm_dev +~~~~~~~~~~~~~~~~~~ + Allow or deny access permission to the device + +scmi base perm_proto +~~~~~~~~~~~~~~~~~~~~ + Allow or deny access to the protocol on the device + +scmi base reset +~~~~~~~~~~~~~~~ + Reset the existing configurations + +Parameters are used as follows: + + + Agent ID + + + Device ID + + + Protocol ID, should not be 0x10 (base protocol) + + + Flags to control the action. See SCMI specification for + defined values. + +Example +------- + +Obtain basic information about SCMI server: + +:: + + => scmi base 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 base perm_dev 1 0 1 + +Reset configurations with all access permission settings retained: + +:: + + => scmi base 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. From patchwork Wed Jun 28 00:48:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 697209 Delivered-To: patch@linaro.org Received: by 2002:adf:e885:0:0:0:0:0 with SMTP id d5csp4080557wrm; Tue, 27 Jun 2023 17:51:36 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6N5/2b7ALrl4RXnkXDkjksVFK0wB7QYWCfz0VvD0ItJjP+yrecqAGmamXI4D4RP5ZSPR3O X-Received: by 2002:a2e:9650:0:b0:2b6:9dd5:7a5 with SMTP id z16-20020a2e9650000000b002b69dd507a5mr5550293ljh.12.1687913496600; Tue, 27 Jun 2023 17:51:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687913496; cv=none; d=google.com; s=arc-20160816; b=rsNnk9akTHvW9lJMmVJYPXKL1Dr4sd6YqKMGez0TVAyK9pDhpK057oWBskuRsOrA52 ItedVxVfKIwOhGipsgDloK5mI0fKbbOt0DHFxdwdmKIDJG7/RyjyeKeyfMO54i4Mkj02 6m7eBN02/tLlnnNWSPDaKW6sQFnxgUAlq3SKqL8q36nNntAKq7dBaYnLSaI1DC7ClF8M IJsMGLO+lp6WbWi4HNBFKGqpkOanwEsiHPU48gNhmTuypmFhO069+INOZHND9Jwoy/G6 rn4e3alFb+uXT9bWvvO5YFdvSCxnf0JmPwHqKDc9TI1E9jMZjr9iiBlXT4KBSjuer1ZP VUzw== 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=UNec+yYqM/9p8g33e1zRr4zBUrhLWSTWYQhFZ4LteI4=; fh=+s9SE2w9oguEKAMcR35TXtqntCOeVFhiK9u/Kju91lo=; b=hae6VTLx862Je2SCXAbU3T8mEWEJS8FM7XvOCUfL+sbwQnK4zyHtzbADZS0Z5xxRhD tlTFGrF0uqraYbCAScxVV9nkCXspbeVIKP9rGr9IkEAV84B0xWwf39Dr23HxRX8WdiQV lUE8rmuoNcBFAxEeO/q3+kgS16l6myCH2a45Lk508GU4ZqbL9H4nBzS/XG3kj02B3Igb Nmw6JmHwfNIiiclZc7EA5HDT8VrtBVHIoaAYxbhWPEbcNyCiVjRs7J14ifmrnYDqaWUT uFB3nysfFncmHVwGrqIc+d7HFJ1/6syO9jsR1xtvtVtWQUTqCFNe62QjNZxFUgxT/tyH uQYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=neDlYxKC; 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 r15-20020a2e80cf000000b002b6a164afb5si1843883ljg.372.2023.06.27.17.51.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Jun 2023 17:51:36 -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=neDlYxKC; 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 0736E8662D; Wed, 28 Jun 2023 02:51:10 +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="neDlYxKC"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A004186615; Wed, 28 Jun 2023 02:50:20 +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, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) (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 959CE8660E for ; Wed, 28 Jun 2023 02:49:53 +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-x62c.google.com with SMTP id d9443c01a7336-1b816d30140so3336075ad.0 for ; Tue, 27 Jun 2023 17:49:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1687913391; x=1690505391; 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=UNec+yYqM/9p8g33e1zRr4zBUrhLWSTWYQhFZ4LteI4=; b=neDlYxKCuRK6RNRI3gAz5sP1GBbDzUp25kUPEeSwV4pH8K+vhDHuVzFoSR4AotA+w/ PK/HimR/DTpmfVyB2wvnpF3xxKEQkHcT2yQU0H4N6cyKPZh9PGkkL9hfnVRy5BT3l1U7 yKJHUrc1kuYU4UTjbhbFmtvlZYZ1/TZbi4lysrokYuY62G28+18u5g8MIPEWzK+/fF7c EoV0plerrz1oeuWb7y7bOxVDuXjtzjC+S05aPgTE22YJoljdph1wljvKREnUVOlaEKdY ZJXF9Ahx2EvNmjunmLY9NnYLd8BkzZaDQ0JHcGsCicYcKWmNsTHiJ7F7AUfmes5HlmFs VBAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687913391; x=1690505391; 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=UNec+yYqM/9p8g33e1zRr4zBUrhLWSTWYQhFZ4LteI4=; b=X/DhxbhqvqlHy2lFdeZ938gbI3Gam86Re21aDB2ub7j6ITEUh7k0ovGZDI+5VGfuuD kcb+XscXWDH1OmvTxPOF98jcwrjBEb5/CnWewFkXOBqjMNvD3D1aua/9yrPqZIXU6vMS LR/PG6GoH2/ZxoVZLZH4mI3kdCJh8VH1ieqcqu8riFWL0JjK1L/ths6OuLDFvwQoY7kh O4t0IURU7vE7uAim99jruWtwuWmamDYhWnAqgbUWF35fuI2W7SzGf34RTX+7J4xj0VJN ZN3iRwp4Ip612nsCVgpzWl/b1miEEzul8GybGT5FR1t7hWXe/bde1m/LLvhY6qKz6LvX c6eg== X-Gm-Message-State: AC+VfDyGRRNcoUopFq3bSoKakaBZ8Z6mAf5W+Zw3icvl/v616b2SmT+H CCxV2267t9VkqBIjIfbL+86fCw== X-Received: by 2002:a17:902:f691:b0:1af:adc2:ab5b with SMTP id l17-20020a170902f69100b001afadc2ab5bmr40801291plg.0.1687913391557; Tue, 27 Jun 2023 17:49:51 -0700 (PDT) Received: from laputa.. ([2400:4050:c3e1:100:58b2:60ed:38ea:8b1f]) by smtp.gmail.com with ESMTPSA id u13-20020a170903124d00b001b3fb2f0296sm6517278plh.120.2023.06.27.17.49.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Jun 2023 17:49:51 -0700 (PDT) From: AKASHI Takahiro To: trini@konsulko.com, sjg@chromium.org Cc: etienne.carriere@st.com, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH 10/10] test: dm: add scmi command test Date: Wed, 28 Jun 2023 09:48:41 +0900 Message-ID: <20230628004841.21774-11-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230628004841.21774-1-takahiro.akashi@linaro.org> References: <20230628004841.21774-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" with different sub-commands is tested. 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 --- test/dm/scmi.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/test/dm/scmi.c b/test/dm/scmi.c index 563017bb63e0..b40c84011295 100644 --- a/test/dm/scmi.c +++ b/test/dm/scmi.c @@ -207,6 +207,63 @@ 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, *base; + struct scmi_agent_priv *priv; + + /* preparation */ + ut_assertok(uclass_get_device_by_name(UCLASS_SCMI_AGENT, "scmi", + &agent_dev)); + ut_assertnonnull(agent_dev); + ut_assertnonnull(priv = dev_get_uclass_plat(agent_dev)); + ut_assertnonnull(base = scmi_get_protocol(agent_dev, + SCMI_PROTOCOL_ID_BASE)); + + /* scmi base info */ + ut_assertok(run_command("scmi base info", 0)); + + ut_assert_nextline("SCMI device: scmi"); + ut_assert_nextline(" protocol version: 0x20000"); + ut_assert_nextline(" # of agents: 2"); + ut_assert_nextline(" 0: platform"); + ut_assert_nextline(" > 1: OSPM"); + ut_assert_nextline(" # of protocols: 3"); + ut_assert_nextline(" Clock management"); + ut_assert_nextline(" Reset domain management"); + 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 base perm_dev */ + ut_assertok(run_command("scmi base perm_dev 1 0 1", 0)); + ut_assert_console_end(); + + ut_assert(run_command("scmi base perm_dev 1 0 0", 0)); + ut_assert_nextline("Denying access to device:0 failed (-13)"); + ut_assert_console_end(); + + /* scmi base perm_proto */ + ut_assertok(run_command("scmi base perm_proto 1 0 14 1", 0)); + ut_assert_console_end(); + + ut_assert(run_command("scmi base 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 base reset */ + ut_assert(run_command("scmi base 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_clocks(struct unit_test_state *uts) { struct sandbox_scmi_agent *agent;