From patchwork Fri Jul 28 00:33:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 707546 Delivered-To: patch@linaro.org Received: by 2002:a5d:6787:0:b0:317:2194:b2bc with SMTP id v7csp648267wru; Thu, 27 Jul 2023 17:34:45 -0700 (PDT) X-Google-Smtp-Source: APBJJlFRHfYrG+QNuzeMTiwjFq/gqt0mRtNOHhlU8RA6LntA/ZjqhCtn20aXUK0+8xTZLcCDqLi9 X-Received: by 2002:a7b:cb8d:0:b0:3fb:b832:d79a with SMTP id m13-20020a7bcb8d000000b003fbb832d79amr437977wmi.38.1690504484943; Thu, 27 Jul 2023 17:34:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690504484; cv=none; d=google.com; s=arc-20160816; b=guzwWAUl0c/Q230q3C+JUajR9RCL5zHOK5FHVKjZNnHTEYeqBjKYmP6jEU43r1XuNF Aez9Gg2Lcag1UHSAQjq6Qu3TzPYVu/PRrBwCjkc5dsTGMiIVp9tcLA8aFmM4nuYhgjeP k/UsveSn1zCT+i4wn50i/YAfPhugvTha2gE5WfJsVZcMx226ItRzm0dvxacVQz5DZxHp IAkv/v+mrMpcLudTc8s0iEGNPW1V69O8p+5UglaCyOotq/eHVDJZWeRfPr2u64lCTZfD vWPD9vBE8f/81I3HLrgiDcmlxCo6LFTLJTaoP1ZWpydpl/WvvW/IatnUkrVfSBQdpC6X lZTQ== 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=6BEd7mCYNhKqpjiL6+9qttehbMpYA8qn8TF0IXJRPk0=; fh=RunEgwhbs7jBY7OMfHDvGK9UJp7q8al8FICtW1ZVXno=; b=EwTXjSS7FJUrBXBgzXCCrXWNDIQTgD47psLxEbaBkBkig2A+3zPdY47ZAOV11SstLi sC6K03LhQGQuBS2Nc0STgdNCn8m69WdM1Ag8mw+bnBe86EbqwlZNNYy43vqxIRAH183+ 73I/sitTQ/26w85H27of64js5EDZGriFLjuCPq/0Zfjm4Zn55H2Zq3YN7E6kNBdV6TLy VIyhtvbVK5Bqm9sosamo34Z8PKLybAeJ8C3QTAL1b59BKqEd6u/Dm7SAaEw8xCabiFjd F+G9hwhTITx5xCbvFUHpGJvi9tLgrCFblTrn5x6FMo7o0HSxWx6gTU2Q6gIhBIMZ2Kva TdxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BuxH9hrp; 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 k11-20020a5d628b000000b00316f14548dbsi1288275wru.145.2023.07.27.17.34.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jul 2023 17:34:44 -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=BuxH9hrp; 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 474A2865BC; Fri, 28 Jul 2023 02:34: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=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="BuxH9hrp"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D068E86213; Fri, 28 Jul 2023 02:34: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=unavailable autolearn_force=no version=3.4.2 Received: from mail-pg1-x531.google.com (mail-pg1-x531.google.com [IPv6:2607:f8b0:4864:20::531]) (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 29A0C86885 for ; Fri, 28 Jul 2023 02:33:57 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pg1-x531.google.com with SMTP id 41be03b00d2f7-56366112d64so198691a12.0 for ; Thu, 27 Jul 2023 17:33:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1690504435; x=1691109235; 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=6BEd7mCYNhKqpjiL6+9qttehbMpYA8qn8TF0IXJRPk0=; b=BuxH9hrpRIhbLrTrsAqwdgXe1YDyZdI7I55ZYNHRaMFPoDgprEJXW7TbG7wREAcyx2 dt8vixF01k1JDABkCWThaIYV4whYZcC1H+fH0u/sUZa6iCGqZ41rVKm+Q8JQBgeE1X7E gnUPOQqmnNKQ8ep9hmaMbzK2keML/35mv2iX8lF4AXcvr5qXzdPXMoTpQfYzeaDLCQ4B Px+va4bOEA34S5f0phny69qQdoH8L7NMbv1FZgT0y5p4cLbrhhpGgMR8DLLcjZLIWIAK yg/Vr/qy0VpE9ASgq2lUnCz3Gv76XxRzPFdwYxqxYom6hSkBetfQpnjaUC7CzvYjprqP HB+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690504435; x=1691109235; 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=6BEd7mCYNhKqpjiL6+9qttehbMpYA8qn8TF0IXJRPk0=; b=N1mD8PhbVj1beSo7h81G+fDSV4j3AF0TAlqoYEAPFr37/0hEcJThJZAU9xRwKHAwEF HTCcgFsjs41+LMKWKmweP8DpahBkWIzSeCeYRpA6inWMgWj4b8rM+Q9+IBy+DJbhbYlJ AUS5zoU2zr0zHoJH6lc3AAzUVHMVlVFFIMoP5ZOUpAfj8uzV9CPMdSXzCoXNjvSvrnk9 tCybd1/FryTq95cXNmvusQXBayWX00YO9VUKLlC3w6MBJtSeVx7xhzPrlPUtPSdWQfrC jofuJVntBJNS4r57r8KZ+x++KNsoKrhQ6JdJTqm2cMW2nSLa1IZGMrNLvAdIXcJK0nHj 2+9Q== X-Gm-Message-State: ABy/qLaGmmGnH3eJodij+Qy6lJGL2n1D7FwrSghd8BFCHxWSPIJaMBRJ of1IO8WcwHpzq44PCiEFeJPm9w== X-Received: by 2002:a17:902:e885:b0:1b8:5827:8763 with SMTP id w5-20020a170902e88500b001b858278763mr1040667plg.4.1690504435120; Thu, 27 Jul 2023 17:33:55 -0700 (PDT) Received: from laputa.. ([2400:4050:c3e1:100:25dd:d673:efea:dbcc]) by smtp.gmail.com with ESMTPSA id g14-20020a1709029f8e00b001b9dab0397bsm2228540plq.29.2023.07.27.17.33.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jul 2023 17:33:54 -0700 (PDT) From: AKASHI Takahiro To: trini@konsulko.com, lukma@denx.de, seanga2@gmail.com, jh80.chung@samsung.com Cc: sjg@chromium.org, etienne.carriere@st.com, u-boot@lists.denx.de, AKASHI Takahiro Subject: [RFC 2/3] firmware: scmi: add PROTOCOL_VERSION support for existing protocols on sandbox Date: Fri, 28 Jul 2023 09:33:12 +0900 Message-ID: <20230728003313.10439-3-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230728003313.10439-1-takahiro.akashi@linaro.org> References: <20230728003313.10439-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 the next patch, SCMI_PROTOCOL_VERSION support is added on the existing SCMI protocols and the version check will be introduced. To finish "ut dm scmi_[clocks|resets|voltage_domains]" tests, sandbox SCMI agent should also implement/mimic this command. Signed-off-by: AKASHI Takahiro Reviewed-by: Etienne Carriere preferrably with typos fixed. --- drivers/firmware/scmi/sandbox-scmi_agent.c | 80 ++++++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/drivers/firmware/scmi/sandbox-scmi_agent.c b/drivers/firmware/scmi/sandbox-scmi_agent.c index ab8afb01de40..a99fcb0ad4a9 100644 --- a/drivers/firmware/scmi/sandbox-scmi_agent.c +++ b/drivers/firmware/scmi/sandbox-scmi_agent.c @@ -43,6 +43,10 @@ #define SANDBOX_SCMI_AGENT_NAME "OSPM" #define SANDBOX_SCMI_PLATFORM_NAME "platform" +#define SANDBOX_SCMI_CLOCK_PROTOCOL_VERSION SCMI_CLOCK_PROTOCOL_VERSION +#define SANDBOX_SCMI_RD_PROTOCOL_VERSION SCMI_RESETDOM_PROTOCOL_VERSION +#define SANDBOX_SCMI_VOLTD_PROTOCOL_VERSION SCMI_VOLTDOM_PROTOCOL_VERSION + static u8 protocols[] = { SCMI_PROTOCOL_ID_CLOCK, SCMI_PROTOCOL_ID_RESET_DOMAIN, @@ -440,6 +444,28 @@ static int sandbox_scmi_base_reset_agent_configuration(struct udevice *dev, /* Clock Protocol */ +/** + * sandbox_scmi_clock_protocol_version - implement SCMI_PROTOCOL_VERSION + * @udevice: SCMI device + * @msg: SCMI message + * + * Implement SCMI_PROTOCOL_VERSION command. + */ +static int sandbox_scmi_clock_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_CLOCK_PROTOCOL_VERSION; + out->status = SCMI_SUCCESS; + + return 0; +} + static int sandbox_scmi_clock_protocol_attribs(struct udevice *dev, struct scmi_msg *msg) { @@ -577,6 +603,30 @@ static int sandbox_scmi_clock_gate(struct udevice *dev, struct scmi_msg *msg) return 0; } +/* Reset Domain Protocol */ + +/** + * sandbox_scmi_rd_protocol_version - implement SCMI_PROTOCOL_VERSION + * @udevice: SCMI device + * @msg: SCMI message + * + * Implement SCMI_PROTOCOL_VERSION command. + */ +static int sandbox_scmi_rd_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_RD_PROTOCOL_VERSION; + out->status = SCMI_SUCCESS; + + return 0; +} + static int sandbox_scmi_rd_attribs(struct udevice *dev, struct scmi_msg *msg) { struct scmi_rd_attr_in *in = NULL; @@ -647,6 +697,30 @@ static int sandbox_scmi_rd_reset(struct udevice *dev, struct scmi_msg *msg) return 0; } +/* Voltage Domain Protocol */ + +/** + * sandbox_scmi_voltd_protocol_version - implement SCMI_PROTOCOL_VERSION + * @udevice: SCMI device + * @msg: SCMI message + * + * Implement SCMI_PROTOCOL_VERSION command. + */ +static int sandbox_scmi_voltd_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_VOLTD_PROTOCOL_VERSION; + out->status = SCMI_SUCCESS; + + return 0; +} + static int sandbox_scmi_voltd_attribs(struct udevice *dev, struct scmi_msg *msg) { struct scmi_voltd_attr_in *in = NULL; @@ -833,6 +907,8 @@ static int sandbox_scmi_test_process_msg(struct udevice *dev, break; case SCMI_PROTOCOL_ID_CLOCK: switch (msg->message_id) { + case SCMI_PROTOCOL_VERSION: + return sandbox_scmi_clock_protocol_version(dev, msg); case SCMI_PROTOCOL_ATTRIBUTES: return sandbox_scmi_clock_protocol_attribs(dev, msg); case SCMI_CLOCK_ATTRIBUTES: @@ -849,6 +925,8 @@ static int sandbox_scmi_test_process_msg(struct udevice *dev, break; case SCMI_PROTOCOL_ID_RESET_DOMAIN: switch (msg->message_id) { + case SCMI_PROTOCOL_VERSION: + return sandbox_scmi_rd_protocol_version(dev, msg); case SCMI_RESET_DOMAIN_ATTRIBUTES: return sandbox_scmi_rd_attribs(dev, msg); case SCMI_RESET_DOMAIN_RESET: @@ -859,6 +937,8 @@ static int sandbox_scmi_test_process_msg(struct udevice *dev, break; case SCMI_PROTOCOL_ID_VOLTAGE_DOMAIN: switch (msg->message_id) { + case SCMI_PROTOCOL_VERSION: + return sandbox_scmi_voltd_protocol_version(dev, msg); case SCMI_VOLTAGE_DOMAIN_ATTRIBUTES: return sandbox_scmi_voltd_attribs(dev, msg); case SCMI_VOLTAGE_DOMAIN_CONFIG_SET: