From patchwork Fri May 13 06:26:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Etienne Carriere X-Patchwork-Id: 572072 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:66c4:0:0:0:0 with SMTP id x4csp197956mal; Thu, 12 May 2022 23:30:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxoDZHZk4Z+Lu29oOrKmZQsE8g8PpmVZr7AyBr3t5czRElVVykNyjaThXanYV7ZeaxthFAb X-Received: by 2002:a17:906:730e:b0:6f4:e9e7:4f4 with SMTP id di14-20020a170906730e00b006f4e9e704f4mr2767966ejc.509.1652423400908; Thu, 12 May 2022 23:30:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652423400; cv=none; d=google.com; s=arc-20160816; b=SvfGrLb76yzPuxhXFmwMKTWFn0ZU6BsxPoeH3W3oQ62Ul/tShuKBCE15EeR/f/WEy2 wL1stNa/S1aZmhjBZq+U2WzVXs2xjVwApfZEKp+L4w3iV+j97byo/HwwQD2Y5ocE+hqv c7rQnNvM46x0RH9NGq+EjlKXBX3awSYgQFZGFnryIBxWeo8E8Lf/aTn+QOI7sDxhakwM tDHxTYgwmaj7/ABsbYHRqDWG/vzJ/umkYXf32Um8k8oqFyvcfJV0YJvUQLE33epxF6hj vohMGyULveRu/wqRQOYoZgd0jhu7yB/IMt9jVI1qhUyoDNuA0Ujrl35WkTQzEPKGvcmV 5Tuw== 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=cB91w0HN0mWNy1INhoZb+NF/dnvAQl0H0z9Whkb/1Jk=; b=S5Q+DauseBnJV8WRgXwB/dkJleASNyvbNjDWwMsCyybe64ZuyOH5rmeqqN2fjw1trY HhBBpUzJTlWannyp6EelY2/Q77xs6BSIX5xS9/WQd32YS7ZwE1DExgvC5kQf0Tm/gnqf EcI/1lw/Yd+WABiEga4AXyEQgMEqfcgSfNlj21S35afpKgwxs+89/Y4gtgHZz9K0AGGP Of0xgthaHxUSHGl6unAFQUAmSciZ4NcezAHZIStO7ol6euFQfRCYbTDfXhxlAiUWnmQy aQV8jgObNg5NPcEHRHr5tH+LyKq+5d5E6U4aOI+jyBWL1ZV4006WwXwwPRAz0BbWrjOO IrYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uDJS8HZa; 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 sc40-20020a1709078a2800b006f3a9502509si1462509ejc.121.2022.05.12.23.30.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 May 2022 23:30:00 -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=uDJS8HZa; 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 B208583F2F; Fri, 13 May 2022 08:28: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=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="uDJS8HZa"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0ECA383E49; Fri, 13 May 2022 08:28:38 +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-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) (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 ADADA83D5D for ; Fri, 13 May 2022 08:28: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=etienne.carriere@linaro.org Received: by mail-wm1-x332.google.com with SMTP id n6-20020a05600c3b8600b0039492b44ce7so4174464wms.5 for ; Thu, 12 May 2022 23:28:31 -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=cB91w0HN0mWNy1INhoZb+NF/dnvAQl0H0z9Whkb/1Jk=; b=uDJS8HZaadr7PMrhAQAeAy94NxmfOLTdwu6Uc0TsYXfdewVvGnXrHK5VGlZgkMI7J0 BNFeT4DAzp93C7IcxR/vhlLO1HVQgnjeBZ48etaLXZCedyd7mPt0agfBJn39Jf8qksn0 YVPU5xVRETTm71FZtfKR8dVRja/ISCOLddsaIYE5iD9Ykg/Tmg0uTfD9W+0jbbJUZcUg OBO9onNK8cBfojCammjeQwplaK3sCTxzXPkAPuHqqK5i7xvqW2x++03ukYgQypPW5v68 XLAg281Uc9eIa8BJ1bjtvVh8vgGs3O04zm0QkWmbBcPLGMrjqALpr2O0bqnMrv7ceXWz 1YPA== 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=cB91w0HN0mWNy1INhoZb+NF/dnvAQl0H0z9Whkb/1Jk=; b=vkYmH/D6nTS4l3SxIUpEx16igdMWeLNxhNpqDvrzxXgNfYRaMTL+AOWBxG74t0jgg8 k7liF/2jnEkZ0fbosZCT1OmpTOz/i9hW1/rbHCje1ayovi8rIMAikg+KeCB0C3Z6pgV5 HJRRDI+lHeeW69L7GPsYUbF5f/zopLpg+ZA+ONOOQFmDp0hBG63zDddCgvmhKJrwdU+b q08MOcODTo6GmjDmqG4Kuwe7e+/tDTW4JS168UmkKNUGOVAOjjiSi9+XbyXfC8fGSuS+ Uqc9MdmVJ4DSID+RiAl+rTI6ca4DlFsfzExub9YNDJvnod2JQ5SZqB95Yv892OsSjEYO wAAg== X-Gm-Message-State: AOAM531HyZ25kmaMWswHZNKFHWgBuldOXMkJELZwPbfi4D9GIHQ7ulzA 1VcMQCg0DF8Wb+WTUZg/V1f3g7Xgh2mU9w== X-Received: by 2002:a05:600c:4fd4:b0:394:8e96:6d3b with SMTP id o20-20020a05600c4fd400b003948e966d3bmr3003835wmq.180.1652423310601; Thu, 12 May 2022 23:28:30 -0700 (PDT) Received: from lmecxl1178.lme.st.com ([2a04:cec0:1194:a3aa:dc31:6fc0:bd75:771a]) by smtp.gmail.com with ESMTPSA id s18-20020a7bc0d2000000b003942a244eebsm1414235wmh.48.2022.05.12.23.28.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 May 2022 23:28:30 -0700 (PDT) From: Etienne Carriere To: u-boot@lists.denx.de Cc: Patrick Delaunay , Patrice Chotard , Etienne Carriere Subject: [PATCH 06/14] firmware: scmi: add multi-channel support Date: Fri, 13 May 2022 08:26:14 +0200 Message-Id: <20220513062622.155433-7-etienne.carriere@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220513062622.155433-1-etienne.carriere@linaro.org> References: <20220513062622.155433-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 --- 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 *