From patchwork Fri Jul 28 00:33:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 707545 Delivered-To: patch@linaro.org Received: by 2002:a5d:6787:0:b0:317:2194:b2bc with SMTP id v7csp648100wru; Thu, 27 Jul 2023 17:34:23 -0700 (PDT) X-Google-Smtp-Source: APBJJlG/DdJqLt9X7qkL5nV679IsFH2yXKsM4xPdBtoMPCmDXVdsGGtaWSv/Oq/VhTmM3h10jhGs X-Received: by 2002:adf:ee89:0:b0:317:6263:1ae2 with SMTP id b9-20020adfee89000000b0031762631ae2mr499904wro.63.1690504463134; Thu, 27 Jul 2023 17:34:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690504463; cv=none; d=google.com; s=arc-20160816; b=CqWHHalKjNIzOx1n7SAyzH4hmhtxWiaA3SWfy/vCk6LHJl2ZrWA6hNTdD/+4uOsp1s MhATQjB3d2rP1Ekhtg8ODSCpvZr6hEPahoCMgzhCNq5w4pkYTTiE+v3pjJzXubnQvvKZ eZYqbBGiWjpsPeFn2RV7eZQRdThbsnbuljiZ2LfPlOlhO/JRXQUJEMJsdXpDj2O1aB0W MLver71ivC+aFLO9GDkR2SPRXBvHSq8560/3Klp31U4ISmc79xjfq82/y3s3E7Np9Xty sK3GgAIcIxvabimWf9zkVnEctiZl6Tca8RXDrx5DUi6dac+G3QilakdkmbK+IMUxqxi7 r+dw== 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=y0Tu2DxmEeJZqNq2c7vSKWib1bfLKO+4Rj76fCMhv84=; fh=RunEgwhbs7jBY7OMfHDvGK9UJp7q8al8FICtW1ZVXno=; b=ys9FM0z5ZVurbwGK/KYcKb4EMcNikLAo+J0/vCU+Z3cHJZRwLJFsaYl86UAVIhVpCC R93qfYeZrAMSysQUWOaSqnspXcVWffClWnmmXGf5W87qxgw/4Csk28XFBS+K74JyMtIP FXmwrQtrrRrp+eJso63Oud37Ut3UN5SHq29CmEPW+FZbwLszfRbaUdkfc7oX7DmsSuaV ffKJ5fH+DPc0hN1E6TMBFZ8vdgTCDllo5QnF9xudTxDjErTvtebbTxdbJXiBbG7PgUel pwMcUc7sjWVYv9MZFcBeAdfQn/zZCrDI2RD2aZSUsVisNDwXYoZOP4z0fFiDOyqQyiHP Ankw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wvprDLdG; 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 k11-20020adfd84b000000b00317847f7c7asi850958wrl.156.2023.07.27.17.34.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jul 2023 17:34: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=wvprDLdG; 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 ABDDA86892; Fri, 28 Jul 2023 02:34:11 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="wvprDLdG"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B53F686887; Fri, 28 Jul 2023 02:33:58 +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 9ADB9863EC for ; Fri, 28 Jul 2023 02:33:54 +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-1b89b0c73d7so2371275ad.1 for ; Thu, 27 Jul 2023 17:33:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1690504432; x=1691109232; 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=y0Tu2DxmEeJZqNq2c7vSKWib1bfLKO+4Rj76fCMhv84=; b=wvprDLdGJtF7JcoSnZCCga8UT7qHWF/bHRCdRQRKfw1bauLW20x4KC9jTMlip2vi3p iHfut4IpDRu0RJpn2LvQ7Nb5POr48LOvT99AOS+lguLyvuE8bZRETQ3gv2lITBcSs1jd uAwhIeU7JMn2ObX2HFJ0vq1Y+uCVIZwQEHG53AoaprIu7Zj1wkHd2gkb7l54ZObYBM7S 5zfozYj4HoNfHGhkz3MMqcJagqQHpqsd7SB9d2Jgx/GWkIpqA9BI9SDxmqdQ4OE8bBAt pu/w0sASg49258G4f1Xzl6OQk3S26iGLTlZPgzdSa/mh3sUzgTvxNGSXAs/rHsznRd0O HEJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690504432; x=1691109232; 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=y0Tu2DxmEeJZqNq2c7vSKWib1bfLKO+4Rj76fCMhv84=; b=Hd5nuENhCxM31p7a7IpW8jboiUuGpes4ETZGO6iUGRjbPs4E1OdYIqkGDQPEXy5E+J oZreIAciQ4ZL7KGvvEGSv+kpvXvCpIHbf/WiG5cBpS1l3FToBMyXLnDZWoNN3USpl2uO hXkEvDrgeu8+/FgfpV99dsZL6oX7b4nb1FrymmAtT109ZrdF2GZxRh8eVyhfHDwX6gRE iQPUbDqhSQNlnKT1FCWamFSAsNnBTX3tj5fjYMr2cC3OKYaVRdI95vWG3D0xxsyJE1u/ wadtbJ0rb4itmNbjONfJ3IrE4XHQW79cTn653H+0ESwWLql7TpUHzMjwygOBLcYWQdWl Vtvw== X-Gm-Message-State: ABy/qLYpqYPVS4bs4MMHGHBBKYZIDxHBNl4Bk4eH5RbQgDXPRSFpQWCJ ok0H0q0tnTq7qvcO1vdbn6nheQ== X-Received: by 2002:a17:902:e803:b0:1b8:35fa:cdcc with SMTP id u3-20020a170902e80300b001b835facdccmr988722plg.5.1690504432552; Thu, 27 Jul 2023 17:33:52 -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.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jul 2023 17:33:52 -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 1/3] firmware: scmi: add a check against availability of protocols Date: Fri, 28 Jul 2023 09:33:11 +0900 Message-ID: <20230728003313.10439-2-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 Now that we have Base protocol support, we will be able to check if a given protocol is really supported by the SCMI server (firmware). Signed-off-by: AKASHI Takahiro Reviewed-by: Etienne Carriere --- drivers/firmware/scmi/scmi_agent-uclass.c | 41 +++++++++++++++++++++-- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/drivers/firmware/scmi/scmi_agent-uclass.c b/drivers/firmware/scmi/scmi_agent-uclass.c index 91cb172f3005..9494dca95bca 100644 --- a/drivers/firmware/scmi/scmi_agent-uclass.c +++ b/drivers/firmware/scmi/scmi_agent-uclass.c @@ -44,6 +44,38 @@ static const struct error_code scmi_linux_errmap[] = { */ struct udevice *scmi_agent; +/** + * scmi_protocol_is_supported - check availability of protocol + * @dev: SCMI agent device + * @proto_id: Identifier of protocol + * + * check if the protocol, @proto_id, is provided by the SCMI agent, + * @dev. + * + * Return: 0 on success, error code otherwise + */ +static bool scmi_protocol_is_supported(struct udevice *dev, + enum scmi_std_protocol proto_id) +{ + struct scmi_agent_priv *priv; + int i; + + if (proto_id == SCMI_PROTOCOL_ID_BASE) + return true; + + priv = dev_get_uclass_plat(dev); + if (!priv) { + dev_err(dev, "No priv data found\n"); + return false; + } + + for (i = 0; i < priv->num_protocols; i++) + if (priv->protocols[i] == proto_id) + return true; + + return false; +} + struct udevice *scmi_get_protocol(struct udevice *dev, enum scmi_std_protocol id) { @@ -372,15 +404,18 @@ static int scmi_bind_protocols(struct udevice *dev) name = ofnode_get_name(node); switch (protocol_id) { case SCMI_PROTOCOL_ID_CLOCK: - if (CONFIG_IS_ENABLED(CLK_SCMI)) + if (CONFIG_IS_ENABLED(CLK_SCMI) && + scmi_protocol_is_supported(dev, protocol_id)) drv = DM_DRIVER_GET(scmi_clock); break; case SCMI_PROTOCOL_ID_RESET_DOMAIN: - if (IS_ENABLED(CONFIG_RESET_SCMI)) + if (IS_ENABLED(CONFIG_RESET_SCMI) && + scmi_protocol_is_supported(dev, protocol_id)) drv = DM_DRIVER_GET(scmi_reset_domain); break; case SCMI_PROTOCOL_ID_VOLTAGE_DOMAIN: - if (IS_ENABLED(CONFIG_DM_REGULATOR_SCMI)) { + if (IS_ENABLED(CONFIG_DM_REGULATOR_SCMI) && + scmi_protocol_is_supported(dev, protocol_id)) { node = ofnode_find_subnode(node, "regulators"); if (!ofnode_valid(node)) { dev_err(dev, "no regulators node\n"); 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: From patchwork Fri Jul 28 00:33:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 707547 Delivered-To: patch@linaro.org Received: by 2002:a5d:6787:0:b0:317:2194:b2bc with SMTP id v7csp648295wru; Thu, 27 Jul 2023 17:34:53 -0700 (PDT) X-Google-Smtp-Source: APBJJlGTdUxg7LrkpVNDbTztl3usg0qJWweSG+75kfwArvPIGzkKBTaKb8f7B2tIhj3L5HLICFA6 X-Received: by 2002:a7b:c5d6:0:b0:3f9:c82e:9d87 with SMTP id n22-20020a7bc5d6000000b003f9c82e9d87mr464022wmk.13.1690504492883; Thu, 27 Jul 2023 17:34:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690504492; cv=none; d=google.com; s=arc-20160816; b=cvyLi3ijlONY5hOW6MKHTup0zfvokZr0lrJKAz/Xo+j4iB5938JxrkMaOByMYn1FsT f9DxnSdYQZCmVfP+AePfZ3QtU9QcCUFI8V5dd29qjWENkWuBhi/PyA5llVxClnYoD4/D FlTFo/7G2HtUxo467384+2Tbnp8zG0djcMeIyjmRfzHxn+PYO2JOU62ta5CXm8P/zjTs KLJRcck3smfLhQidHDrvEVaKSKIPLg1/lz2zQfQMcfod3QwxYQb0ov/KKxjYNuQB04A8 PXrAcIzWgpsrYzRjoecCfjJM4BOC8WaXL6/g7u2E+qjt7F2xp6T6KsSz8iITbc4KADQ5 L3Sg== 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=PzljctpNwsDwSDgwuLTnMzG71tkZzYH1C+lnk8CEWXg=; fh=RunEgwhbs7jBY7OMfHDvGK9UJp7q8al8FICtW1ZVXno=; b=R/e277gzi7w9P5ffCjKdTDTH6ifnsW1YShob7o/vrqcJ+Xr5s0uZ7NuBmQmRKIlEod /2Gb7YuZMh4bEExeazq+FWii8UTPd/lRxdx2th9zsB7IT8aK7UBGU79fbjmyPLGPsvuJ ZF6akKDUd5gAxBKQ09RAQCd7Kxyo8+FvKT77vOpMzIu7gE7cPP6GPVIPon7P6tKevHiw IcgxsHxGnWrEoPSH4MI+crR113/2oCplrCV+cfSf0nhl7RQNGwO6SG3hGsA+CLjfH4eu qe28lu+X0YAIgmKmRtRe3qFZu6JWUxtlzbnMBYh9HZ8FmWfYJre6u11LMWpp4yIX9EPR MBeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="mII/Fbyb"; 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 d16-20020adfe890000000b0031412be0110si1299470wrm.225.2023.07.27.17.34.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jul 2023 17:34:52 -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="mII/Fbyb"; 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 5BEBD86887; Fri, 28 Jul 2023 02:34: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="mII/Fbyb"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6EEA086885; Fri, 28 Jul 2023 02:34:12 +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-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) (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 87662863EE for ; Fri, 28 Jul 2023 02:33: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=takahiro.akashi@linaro.org Received: by mail-pg1-x52e.google.com with SMTP id 41be03b00d2f7-55badd6d6feso258144a12.1 for ; Thu, 27 Jul 2023 17:33:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1690504438; x=1691109238; 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=PzljctpNwsDwSDgwuLTnMzG71tkZzYH1C+lnk8CEWXg=; b=mII/Fbyb1Kl0AnZCw/MTSRtTATWOqpZ0Lvw/jsVQeTXTt43P6h+Ls4AmEZkW3aKJJR iHBinr/srdrQ4Zc7g2yDg47WNqfyGolbMeCzQJzaY/Pl2H/oAx3qIEpQ9o7btDG1a/I1 zMmTiJVP5/WxSn6wzUmlkCLf4NSVbqksZGbKdDWZbsWcBE7xIiO9M5RvK8TQJwNp2oUW pL+6mPnxSFhgMSqwCm+z0h9I3207atOu3mAY1Hqb+JQEW2Pw1czZSrDV3IshUFi9AOeP 2SBmHrSSDM4+Vu26gYEkBN5rL/G4ecO5KMA35IWKPRV+uy5ou1ZGqM4LkT7vcaLTaCsC YsRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690504438; x=1691109238; 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=PzljctpNwsDwSDgwuLTnMzG71tkZzYH1C+lnk8CEWXg=; b=H47d5ovOneQenTwV5NjODTIsCZfd4R2dOCdCji39/TZ2p1U2XmycLrkLXiZBCdykdv KQpsVUcPDSxpj/a/mHp3Ao//uWfeVU0qWdGWfyEh5wYQg94pxp3OmJcs7IadF1j/xvQO yOnFAWCO0KQzMzFmp7tVq9bifalrDfKLtdfQBCqc29uIp67Qfdc0PDDSlFsUG87MPykC zgrdMOGiQ5xWJJy6aSaO2WvRLTfQvBr34shtXRGZLWADxbGt0mH8fLbrKmuyAX/hOBYi SHhlEKlcPogtje7MDxohdbdVrawin2uq6FWd0i+7MK/dBKWDWj4WpJEIGSf+jCz3t+4r n/lw== X-Gm-Message-State: ABy/qLbqbhHjavMgBnprvl33TJQFbI9K4JbcoyeADmJnCnWquKa4LOK7 mYggCIfw1IoLfzd/WsqfQJ/hyQ== X-Received: by 2002:a17:902:eccc:b0:1b3:d8ac:8db3 with SMTP id a12-20020a170902eccc00b001b3d8ac8db3mr981853plh.6.1690504437593; Thu, 27 Jul 2023 17:33:57 -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.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jul 2023 17:33:57 -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 3/3] firmware: scmi: add a sanity check against protocol version Date: Fri, 28 Jul 2023 09:33:13 +0900 Message-ID: <20230728003313.10439-4-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 SCMI_PROTOCOL_VERSION is a mandatory command for all the SCMI protocols. With this patch, this command is implemented on each protocol. Then, we can assure that the feature set implemented by SCMI Server (firmware) is compatible with U-Boot, that is, each protocol's version must be equal to or higher than the one that U-Boot's corresponding driver expects. Signed-off-by: AKASHI Takahiro --- drivers/clk/clk_scmi.c | 6 ++++++ drivers/power/regulator/scmi_regulator.c | 6 ++++++ drivers/reset/reset-scmi.c | 14 +++++++++++++- include/scmi_protocols.h | 6 ++++++ 4 files changed, 31 insertions(+), 1 deletion(-) diff --git a/drivers/clk/clk_scmi.c b/drivers/clk/clk_scmi.c index 34a49363a51a..3591acb6d3a9 100644 --- a/drivers/clk/clk_scmi.c +++ b/drivers/clk/clk_scmi.c @@ -138,12 +138,18 @@ static int scmi_clk_probe(struct udevice *dev) { struct clk *clk; size_t num_clocks, i; + u32 version; int ret; ret = devm_scmi_of_get_channel(dev); if (ret) return ret; + ret = scmi_generic_protocol_version(dev, SCMI_PROTOCOL_ID_CLOCK, + &version); + if (ret || version < SCMI_CLOCK_PROTOCOL_VERSION) + return -EINVAL; + if (!CONFIG_IS_ENABLED(CLK_CCF)) return 0; diff --git a/drivers/power/regulator/scmi_regulator.c b/drivers/power/regulator/scmi_regulator.c index 08918b20872c..936768d0eeeb 100644 --- a/drivers/power/regulator/scmi_regulator.c +++ b/drivers/power/regulator/scmi_regulator.c @@ -138,12 +138,18 @@ static int scmi_regulator_probe(struct udevice *dev) .out_msg = (u8 *)&out, .out_msg_sz = sizeof(out), }; + u32 version; int ret; ret = devm_scmi_of_get_channel(dev); if (ret) return ret; + ret = scmi_generic_protocol_version(dev, SCMI_PROTOCOL_ID_VOLTAGE_DOMAIN, + &version); + if (ret || version < SCMI_VOLTDOM_PROTOCOL_VERSION) + return -EINVAL; + /* Check voltage domain is known from SCMI server */ in.domain_id = pdata->domain_id; diff --git a/drivers/reset/reset-scmi.c b/drivers/reset/reset-scmi.c index b76711f0a8fb..dbd98dbdbc4f 100644 --- a/drivers/reset/reset-scmi.c +++ b/drivers/reset/reset-scmi.c @@ -73,7 +73,19 @@ static const struct reset_ops scmi_reset_domain_ops = { static int scmi_reset_probe(struct udevice *dev) { - return devm_scmi_of_get_channel(dev); + u32 version; + int ret; + + ret = devm_scmi_of_get_channel(dev); + if (ret) + return ret; + + ret = scmi_generic_protocol_version(dev, SCMI_PROTOCOL_ID_RESET_DOMAIN, + &version); + if (ret || version < SCMI_RESETDOM_PROTOCOL_VERSION) + return -EINVAL; + + return 0; } U_BOOT_DRIVER(scmi_reset_domain) = { diff --git a/include/scmi_protocols.h b/include/scmi_protocols.h index 64fd740472b5..6ab16efd49cc 100644 --- a/include/scmi_protocols.h +++ b/include/scmi_protocols.h @@ -398,6 +398,8 @@ int scmi_generic_protocol_version(struct udevice *dev, * SCMI Clock Protocol */ +#define SCMI_CLOCK_PROTOCOL_VERSION 0x20000 + enum scmi_clock_message_id { SCMI_CLOCK_ATTRIBUTES = 0x3, SCMI_CLOCK_RATE_SET = 0x5, @@ -509,6 +511,8 @@ struct scmi_clk_rate_set_out { * SCMI Reset Domain Protocol */ +#define SCMI_RESETDOM_PROTOCOL_VERSION 0x30000 + enum scmi_reset_domain_message_id { SCMI_RESET_DOMAIN_ATTRIBUTES = 0x3, SCMI_RESET_DOMAIN_RESET = 0x4, @@ -569,6 +573,8 @@ struct scmi_rd_reset_out { * SCMI Voltage Domain Protocol */ +#define SCMI_VOLTDOM_PROTOCOL_VERSION 0x20000 + enum scmi_voltage_domain_message_id { SCMI_VOLTAGE_DOMAIN_ATTRIBUTES = 0x3, SCMI_VOLTAGE_DOMAIN_CONFIG_SET = 0x5,