From patchwork Tue May 31 16:09:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Etienne Carriere X-Patchwork-Id: 577455 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:330b:0:0:0:0 with SMTP id f11csp1301930mag; Tue, 31 May 2022 09:11:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwdsjV5zrq7F9UtpwrRg6dFaOb73Tn7Ep3az0XPqNUeRIJSYeYH8RENCxeEMaYyE+3kwnFw X-Received: by 2002:a05:6e02:1aa7:b0:2d1:6593:9709 with SMTP id l7-20020a056e021aa700b002d165939709mr31188051ilv.218.1654013503008; Tue, 31 May 2022 09:11:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654013503; cv=none; d=google.com; s=arc-20160816; b=ftQwIO6symldvD19rz4QxV8lSm7TyJySDbYv81c5NzjO6xarg/JlY12UFGsgaOvnc7 XqnYCAGu+XSmYzP4qmxK7O9DBnS5VYQrJIL9QRiWM6yVS3YjNGxSWP0tXss8xfVSAADa +9BKbyoaHBERDaCX4GemrTFZ12S42ea7BgJVV+Ry8N4wftwdhNyvBkjOqqHL9iUD+pbS vTJIjOEFzyi83y4i2K5J5UyPqiDgxWK1v0Zr6EHTVAQpdtn+8jf2TEBqjnbS2gUQrVWL fsRWI/1tlY6Axtai5R3WPF7m6lH5khHlg7wxf5CVfriwvxw/TwMCqCU4Dx2KNvn4uWxb L4lQ== 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=r8pNsDQzbpvBIWSDWJ/onVvJdb2emRTZixzGNvnyISw=; b=B7QlGNFZbXA+MjYVgcJL74ufgNKDnnnWvzzyClxoGoRbkn4Y7EBnQc/a5lu+z+77XC WmuY5qLAxGfvXdI+RCNuMpeyR9McwKz9KGVMUhcoaya3PEZvKbJzHdRknZMiE+PMAigl 40/4GdtKz4rSBoJRz+JznqAqR9oV3Eu4vvVJU4LE5mGjIz3nIHD/Up/VGknaT6so8Xkk 8oAYXK4/2na2KEuiu725rXmUl6EGrqoSlprI+MiL4RV3YmQsj5z0hAcb5qNNFikzYJGM fw0wFc3GAm4DmLYeA9DQ3PzBl0UmATjugQ2oMp6UaTzgQfn5hlwE6mUfTh/07+cBUmjO NACw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=p0QJaUSc; 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 q13-20020a92ca4d000000b002d16e85a00asi18024342ilo.118.2022.05.31.09.11.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 May 2022 09:11:42 -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=p0QJaUSc; 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 8CE48842F2; Tue, 31 May 2022 18:10:31 +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="p0QJaUSc"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D57C183F33; Tue, 31 May 2022 18:09:49 +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-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) (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 8CF9B83D90 for ; Tue, 31 May 2022 18:09:43 +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=etienne.carriere@linaro.org Received: by mail-wr1-x434.google.com with SMTP id h5so11265169wrb.0 for ; Tue, 31 May 2022 09:09:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=r8pNsDQzbpvBIWSDWJ/onVvJdb2emRTZixzGNvnyISw=; b=p0QJaUScVO2LMXlIUGAzBHqc+9aR+NvK5m3PBSvAm3QduQUmobi6DFqXaF7CG4ZAhO 70/TWr5DxnZreZ2IQsZrrMUBohwKrKiu/YoRuKU0ZZP0zKp2HJKhp0sedBqnCQ0vD95g BLUzfc2nzUj1XhvCF+ZM2JlIndIisKPyUH24FrG2j00I6imGZhlYuPoA2ou8Vcb8BvYt weTEh0dW955z4Io3JnjLWyUGQ8Nufk89y0HaGYmNLXSuIxj+0m29eyxMw2XnWXBrVt1H AgeBYiBs4sPwa4H/Vu6PNQOPBraxaPzW8fBMoc+gsW7fMHbOsK/S2xetZP9onjrPnPs9 YAYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=r8pNsDQzbpvBIWSDWJ/onVvJdb2emRTZixzGNvnyISw=; b=ZcqmER/VJNSM3bDVqqHg3f9tJ20aGDYCnoY/dRyTd4KGxQ0JjL7+BvB8YaQgCSrOC8 voEQKVW7p1Q511raKG+LaZOWgAG8mk55OnV5XkVXVf49qE3g3QedLuxFJIk30ert6RWN k/3JJbTnLQ6Dv+fQZxvol+w+4YslAN7xYc9TbS+7VazAKKkEfhhjbzFjirSY9G7KQGTV XdboNgT+NlDxQreLmKhChh7AlX8RjSSgU7RVwu3arb6az7iHfQEThBIiZfaWDcwGhJ3R 5vablshgkaJ06AqSHQ3YZ97gyduym2T9RCuXOkMcEXc3z1CH9fXivlHhiAouDikd55R3 aylw== X-Gm-Message-State: AOAM531fIU4NTC/Gz7WBQhSebxOVBggcVgUmIYvw/a+jrjf917x4VbP+ 0/dUxlR6SfOZ7ZCvH7LzIXoFrPUG99aEkQ== X-Received: by 2002:a05:6000:15c1:b0:20f:c1d3:8a89 with SMTP id y1-20020a05600015c100b0020fc1d38a89mr44999485wry.287.1654013382546; Tue, 31 May 2022 09:09:42 -0700 (PDT) Received: from lmecxl1178.lme.st.com ([2a04:cec0:117a:a94e:9569:2e63:8a35:2cc5]) by smtp.gmail.com with ESMTPSA id r23-20020a05600c321700b0039aa4d054f8sm2884035wmp.5.2022.05.31.09.09.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 May 2022 09:09:42 -0700 (PDT) From: Etienne Carriere To: u-boot@lists.denx.de Cc: Patrick Delaunay , Patrice Chotard , etienne.carriere@linaro.org Subject: [PATCH v2 06/14] firmware: scmi: add multi-channel support Date: Tue, 31 May 2022 18:09:21 +0200 Message-Id: <20220531160929.931150-7-etienne.carriere@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220531160929.931150-1-etienne.carriere@linaro.org> References: <20220531160929.931150-1-etienne.carriere@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.5 at phobos.denx.de X-Virus-Status: Clean Adds resources for SCMI protocols to possibly use a dedicated SCMI channel instead of the default channel allocated by the SCMI agent during initialization. As per DT binding documentation, some SCMI transports can define a specific SCMI communication channel for given SCMI protocols. It allows SCMI protocols to pass messages concurrently each other. This change introduces new scmi agent uclass API function devm_scmi_of_get_channel() for SCMI drivers probe sequences to get a reference to the SCMI channel assigned to its related SCMI protocol. The function queries the channel reference to its SCMI transport driver through new scmi agent uclass operator .of_get_channel that uses Device Tree information from related SCMI agent node. Operator .of_get_channel returns a reference to the SCMI channel assigned to SCMI protocol used by the caller device. SCMI transport drivers that do not support multi-channel are not mandated to register this operator. When so, API function devm_scmi_of_get_channel() returns NULL and SCMI transport driver are expected to retrieve by their own means the reference to the unique SCMI channel, for example using platform data as these drivers currently do in U-Boot source tree. Signed-off-by: Etienne Carriere --- No change since v1. --- drivers/firmware/scmi/scmi_agent-uclass.c | 19 ++++++++++++++++++- include/scmi_agent-uclass.h | 9 +++++++++ include/scmi_agent.h | 9 +++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/drivers/firmware/scmi/scmi_agent-uclass.c b/drivers/firmware/scmi/scmi_agent-uclass.c index f7fa5df214c..2b6211c4e6a 100644 --- a/drivers/firmware/scmi/scmi_agent-uclass.c +++ b/drivers/firmware/scmi/scmi_agent-uclass.c @@ -128,6 +128,23 @@ static const struct scmi_agent_ops *transport_dev_ops(struct udevice *dev) return (const struct scmi_agent_ops *)dev->driver->ops; } +int devm_scmi_of_get_channel(struct udevice *dev, struct scmi_channel **channel) +{ + struct udevice *parent; + + parent = find_scmi_transport_device(dev); + if (!parent) + return -ENODEV; + + if (transport_dev_ops(parent)->of_get_channel) + return transport_dev_ops(parent)->of_get_channel(dev, channel); + + /* Drivers without a get_channel operator don't need a channel ref */ + *channel = NULL; + + return 0; +} + int devm_scmi_process_msg(struct udevice *dev, struct scmi_channel *channel, struct scmi_msg *msg) { @@ -141,7 +158,7 @@ int devm_scmi_process_msg(struct udevice *dev, struct scmi_channel *channel, ops = transport_dev_ops(parent); if (ops->process_msg) - return ops->process_msg(parent, NULL, msg); + return ops->process_msg(parent, channel, msg); return -EPROTONOSUPPORT; } diff --git a/include/scmi_agent-uclass.h b/include/scmi_agent-uclass.h index 562a4cc99af..b1c93532c0e 100644 --- a/include/scmi_agent-uclass.h +++ b/include/scmi_agent-uclass.h @@ -13,6 +13,15 @@ struct scmi_channel; * struct scmi_transport_ops - The functions that a SCMI transport layer must implement. */ struct scmi_agent_ops { + /* + * of_get_channel - Get SCMI channel from SCMI agent device tree node + * + * @dev: SCMI protocol device using the transport + * @channel: Output reference to SCMI channel upon success + * Return 0 upon success and a negative errno on failure + */ + int (*of_get_channel)(struct udevice *dev, struct scmi_channel **channel); + /* * process_msg - Request transport to get the SCMI message processed * diff --git a/include/scmi_agent.h b/include/scmi_agent.h index f4d85cae773..ee6286366df 100644 --- a/include/scmi_agent.h +++ b/include/scmi_agent.h @@ -45,6 +45,15 @@ struct scmi_msg { .out_msg_sz = sizeof(_out_array), \ } +/** + * devm_scmi_of_get_channel() - Get SCMI channel handle from SCMI agent DT node + * + * @dev: Device requesting a channel + * @channel: Output reference to the SCMI channel upon success + * @return 0 on success and a negative errno on failure + */ +int devm_scmi_of_get_channel(struct udevice *dev, struct scmi_channel **channel); + /** * devm_scmi_process_msg() - Send and process an SCMI message *