From patchwork Tue Sep 26 06:57:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 726389 Delivered-To: patch@linaro.org Received: by 2002:adf:ea87:0:b0:31d:da82:a3b4 with SMTP id s7csp2780324wrm; Tue, 26 Sep 2023 00:00:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGB5BzTNj2iEWhKRL/nVSmGrVe2MQzG+4nJbWQbKGa9LyhzTykjjl3B4yt5L8Bzy4DuUENG X-Received: by 2002:a5d:4577:0:b0:31f:f9de:6a4e with SMTP id a23-20020a5d4577000000b0031ff9de6a4emr7389344wrc.69.1695711607080; Tue, 26 Sep 2023 00:00:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695711607; cv=none; d=google.com; s=arc-20160816; b=Mrp/et9J5Zxxo3/hG/8PErdabz2rtIMbqOctyTDJinV4oYIO7ePKXn94h0ax9hJqQF cau4DuGTNLfoqjF3twm1mD1qnF9uuV3XvFonF5fuADoUWts3Jh+jtvquwc/isM24HELN e48X8Ybv207lfl7ftbseNkuivvSjZpUeHZQDdW1GbQloyztHSsdPHrK7J1o9V7ZjJVK7 268GdFE/xvdes/z1SySvtPtX6q79W8B1gRUc9X3hDEh73J/GhkqdHaY1v5areuNavEgy 1jlR9oOjHrNgbO/RZZ5YfdIxpaFWbyquqT5aWCig4VBVmu59B1dMNL1nlGvrwZcAEKZ2 gHpA== 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=vXcB1ML+GNN0PvOeGj9YekhiQKMztwG+L5FTsmlR42k=; fh=K4dQhL74gef2glEqNOnE2YOBTqRi7qf0ycKBewrN6K8=; b=ArRW0LSE+3QYjp4jiFfEQBPYZnHz5Y9R31XpiU4xkghb/kedxNsjLsvkMAS5J+nYgA Ye9jAC7Rep/ms4ikbAPBQQ+8gVHkpb24rYRLBjVdEELbMD+TdW2lcsk4Udp0gfL4Hmig depD7bOOnz/PK1jq7+URyyJJA/Zwf3fhh8rBYmrnUYASpWplmVUD1TVQ/vy9eZul5Lab fE7dKgfOjfM4tfRws15JBDRof9No32Ns/c8P7qW90FD95/YwAvduIDC+QMYzKhWvXe1t VEFPw7aYDpG5LHDEV3HNJVy4aWQwmbQc78sh9HQKPEUwoUI04W8ndLETdg845HSvKot9 inDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MyYf8Ibm; 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 a8-20020adfeec8000000b0032168aadfa6si5627143wrp.990.2023.09.26.00.00.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 00:00:07 -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=MyYf8Ibm; 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 A858186D56; Tue, 26 Sep 2023 08:58:39 +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="MyYf8Ibm"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0D59B86D56; Tue, 26 Sep 2023 08:58:39 +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 autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-oa1-x31.google.com (mail-oa1-x31.google.com [IPv6:2001:4860:4864:20::31]) (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 E658286C00 for ; Tue, 26 Sep 2023 08:58: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-oa1-x31.google.com with SMTP id 586e51a60fabf-1dd22266f51so362830fac.0 for ; Mon, 25 Sep 2023 23:58:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1695711515; x=1696316315; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vXcB1ML+GNN0PvOeGj9YekhiQKMztwG+L5FTsmlR42k=; b=MyYf8IbmcMj4tBd0lVHJnyWtpkiQn9F+H66ajdKdlKxGOd6+F2+wfmi15HNJxkvXQU tX4n2Co2zEePxXu3C0qQxkhHZFvz4wWgpAs1x67KHc3Nf6yL9/JMmsULVJ1PHY+t5Rse 6JFMQVIKKtS3w6g3mqWFch5EoM2jRwKjMt9bmCqrOhuJuvPYs++LaDdlY/c9XgaVICHF Z+F747oAnls7eCkIeVgH5arA/OoYwGrlXd88MuQQw+7k4TZGvUBVcTYpU5QKHT+X0QhT vC6NzVsum8+Nkp3oe89K3t2L3QnrdxuwzLSGDbC1uMZlnNiiKpGicpIufmgvhKx4wDCD Sjtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695711515; x=1696316315; 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=vXcB1ML+GNN0PvOeGj9YekhiQKMztwG+L5FTsmlR42k=; b=irTW5ZammWLa4AJtLsVwfu0/pk9wMADEe5mJ+y/cf9VpcF+6wppnbD/2dLGKH3YgK+ +KG9G1kTwJ30OIzX5ZJQ2WjGZMgCacGzlr9krfqFi7nzbiVqVNoHlp6SsU8zDczb84hy Xol3V1eBTCItSRRFuTOB5UxDcxjXDLLBIc3jV0T2NxqmhkKE+jU26K8shzXPgLxHXO9I o8EKXOv4/xCVTLDPbytnw+/lsHvC02QT3FGgtWYeEqS4Rn9zColOwakKMvmTKNcJOzPX Zweq+1C37nYyP/fRqTTH1UKbVGvioV/ZTJ7tzpMOIGdG9zO9PwWFRha9pmG+pcG632SE CwVg== X-Gm-Message-State: AOJu0YzAwkCDEEBALJYiob7LMNInM2jZjB8/l/WP8PhrRp9KonzwJ2Xs efMljHJOaDw9zzziz/3Lb1Gn9g== X-Received: by 2002:a05:6358:c12a:b0:142:d40a:82a9 with SMTP id fh42-20020a056358c12a00b00142d40a82a9mr6903848rwb.2.1695711515366; Mon, 25 Sep 2023 23:58:35 -0700 (PDT) Received: from octopus.. ([2400:4050:c3e1:100:6585:aea6:5002:a825]) by smtp.gmail.com with ESMTPSA id s2-20020a639242000000b0057825bd3448sm8758874pgn.51.2023.09.25.23.58.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 23:58: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 , Etienne Carriere Subject: [PATCH v5 11/16] firmware: scmi: add a check against availability of protocols Date: Tue, 26 Sep 2023 15:57:45 +0900 Message-Id: <20230926065750.734440-12-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230926065750.734440-1-takahiro.akashi@linaro.org> References: <20230926065750.734440-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 Reviewed-by: Simon Glass --- v3 * new; import this patch from my followup patch set --- 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 b1a9c36310c1..6f585b96f740 100644 --- a/drivers/firmware/scmi/scmi_agent-uclass.c +++ b/drivers/firmware/scmi/scmi_agent-uclass.c @@ -38,6 +38,38 @@ static const struct error_code scmi_linux_errmap[] = { { .scmi = SCMI_PROTOCOL_ERROR, .errno = -EPROTO, }, }; +/** + * 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) { @@ -374,15 +406,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");