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");