From patchwork Fri Feb 11 12:07:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Etienne Carriere X-Patchwork-Id: 541783 Delivered-To: patch@linaro.org Received: by 2002:ad5:420f:0:0:0:0:0 with SMTP id e15csp3020422imo; Fri, 11 Feb 2022 04:08:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJyaLw15o6zbytCoH0OP8C6rDkRPr+tEfVScDrCXQWEb6OPaEpGw3K4RDynlW1z2tavSowOj X-Received: by 2002:aa7:cd18:: with SMTP id b24mr1556266edw.294.1644581290239; Fri, 11 Feb 2022 04:08:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644581290; cv=none; d=google.com; s=arc-20160816; b=yTLGM1UZRwkjan5nPDBfbRgTHGt/VLfk+TprnYJu3eCdKAKjXfVEp+HJNmXDRy9um7 TzKbqaWO5qeLsvacWQXzRZZkTX/XZLmbqShmJ2tp8dVUVEAGsdMHT6kfwXUYpaHKTkg4 bUq2Qj4DPJWgvntWod+ernvjIwBZH6pFpmmeL3aHdTGXK22CngNoGdB5YeUqDVSYdtRD OPTfEOjFpvW/miYslsnoI4jtLpTa+/QyXYh5whY//0lo2Xm/1OzP5fT+hzkrBbuV1ZcK nsNeyL0gCGmvDCsXrW+IiaPrwZLREJhxg65mGCO9+B4XFRu0yDf7VfQkIQgep0BGUVb3 /e1A== 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:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=Vx6zo6YtGO7mZ7zNDRXIGvOOZZTt8yiMuNeaYy4NhwI=; b=gtqc3HLtxBSA710+XvfHcu/Pot53iAPhj427QI504w0f6/UCXJxQw0E3sJWBVdyU/2 wYGszyuB7jynKEMctK97DBSKxFjlb2DGb/usVEzRxbTwlbG/0kXXG3Hfl+knrssoODl1 kyvfQ+NMWr7X58qlkxv6HwWjnF2fpuOLwaVHLZcEsSXFCDB6rS0nO2LFIvpGKIiV6e4b lsE9M1ljxBKfQWpjzf+Q/95uYxIMsPqx7EeVqX+fslvaSfQQJDrFvD2rvsxIoCBq1wAB CsbOpwQL+DMRbGhFilKvXav7FHR9E1Kp6okOu9jOpRnhIx/vGE0GwqMgWRxEDS+vAVuU ilug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IzzbFfVR; 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 hc42si16426666ejc.304.2022.02.11.04.08.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Feb 2022 04:08:10 -0800 (PST) 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=IzzbFfVR; 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 99BA583A84; Fri, 11 Feb 2022 13:07:50 +0100 (CET) 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="IzzbFfVR"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1ACA583A82; Fri, 11 Feb 2022 13:07:48 +0100 (CET) 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-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) (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 86D2683A64 for ; Fri, 11 Feb 2022 13:07:39 +0100 (CET) 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-x32a.google.com with SMTP id k127-20020a1ca185000000b0037bc4be8713so7113530wme.3 for ; Fri, 11 Feb 2022 04:07:39 -0800 (PST) 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; bh=Vx6zo6YtGO7mZ7zNDRXIGvOOZZTt8yiMuNeaYy4NhwI=; b=IzzbFfVRkCcPM6oVZfxzvoZULcKjhRKiFDrvPCNWOmWes09ReWhGnhvgj5AYHr1DMm NnC3pecF4PzX0M09GcJY0ZXpnN0YdIB1wRIStKnEJ8gT/Tlm9mY44VtaobVQ/cfM4UIU CbBEfyLxYC7sOVfc0LfkUWFy9IEyVc3FXb/TDZg3iRZyHRQkAlC9joN9exCavqpN04rF Vlrx/GFk66Ju0aEM1rDhh5BreVBgBIKaY9U1ZblRndVFRb3KtLWpxn7v20T/csBi+E6e MZ5UZwinlPtyldumJy2JEmUU2mGfa9QQM3EQfjMwd9BCZ/itoKMDCrf5xtlY4tAYsmMM hjUA== 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; bh=Vx6zo6YtGO7mZ7zNDRXIGvOOZZTt8yiMuNeaYy4NhwI=; b=l2Pd0BooreIzmzDi1fWfbiRkC5Ngs+9ZrXRpOJQN3FXV8shvmaNqVzPv7oO3TZwQSk qE0EAXBuKtARgB2k1iFFJ8inXGJnF7ppYgWMV4G5j9WIcythzxU3K21SFGOfpyo/V5Aw W8N23GTo7auReiw/eraGlNhKpUREC7+tGUbFrz6By34Yc6xbSJ/bbZ7HH9vBsirA6jbh MBR17Noy/k21aXRS2bXvRPLyYmajQdYzpLhzh8tDw53DNYZ7xJm1MA5GyATmGGO1qREZ 95DQ+IH4GXHt+R557fOdt9Awsb+62EHkNqDzp8LhUaGOWJie6lbqyqXnXxVrVHOuYIeE wgKg== X-Gm-Message-State: AOAM530jd0GhZxDlrpWHudePohcBU9TlBakgGURzLhAFT85hqD+eAOZN BPZPntTekEjN45mNfzFlvMgOvhoeCZRBmQ== X-Received: by 2002:a05:600c:1d06:: with SMTP id l6mr51716wms.80.1644581258841; Fri, 11 Feb 2022 04:07:38 -0800 (PST) Received: from lmecxl0524.lme.st.com ([2a04:cec0:1057:737f:9927:5b5d:6280:5a68]) by smtp.gmail.com with ESMTPSA id u14sm4964439wmq.41.2022.02.11.04.07.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Feb 2022 04:07:38 -0800 (PST) From: Etienne Carriere To: u-boot@lists.denx.de Cc: Etienne Carriere , Lukasz Majewski , Sean Anderson , Jaehoon Chung , Patrick Delaunay Subject: [PATCH 3/5] scmi: change parameter dev in devm_scmi_process_msg Date: Fri, 11 Feb 2022 13:07:23 +0100 Message-Id: <20220211120725.25358-3-etienne.carriere@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220211120725.25358-1-etienne.carriere@linaro.org> References: <20220211120725.25358-1-etienne.carriere@linaro.org> 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 Changes devm_scmi_process_msg() first argument from target parent device to current SCMI device and lookup the SCMI agent device among SCMI device parents for find the SCMI agent operator needed for communication with the firmware. This change is needed in order to support CCF in clk_scmi driver unless what CCF will fail to find the right udevice related to exposed SCMI clocks. This patch allows to simplify the caller sequence, using SCMI device reference as parameter instead of knowing SCMI uclass topology. This change also adds some protection in case devm_scmi_process_msg() API function is called for an invalid device type. Cc: Lukasz Majewski Cc: Sean Anderson Cc: Jaehoon Chung Cc: Patrick Delaunay Signed-off-by: Etienne Carriere Reviewed-by: Patrick Delaunay --- drivers/clk/clk_scmi.c | 6 +++--- drivers/firmware/scmi/scmi_agent-uclass.c | 17 +++++++++++++++-- drivers/power/regulator/scmi_regulator.c | 10 +++++----- drivers/reset/reset-scmi.c | 4 ++-- include/scmi_agent.h | 2 +- 5 files changed, 26 insertions(+), 13 deletions(-) diff --git a/drivers/clk/clk_scmi.c b/drivers/clk/clk_scmi.c index 9a0a6f6643..42fbab0d21 100644 --- a/drivers/clk/clk_scmi.c +++ b/drivers/clk/clk_scmi.c @@ -24,7 +24,7 @@ static int scmi_clk_gate(struct clk *clk, int enable) in, out); int ret; - ret = devm_scmi_process_msg(clk->dev->parent, &msg); + ret = devm_scmi_process_msg(clk->dev, &msg); if (ret) return ret; @@ -52,7 +52,7 @@ static ulong scmi_clk_get_rate(struct clk *clk) in, out); int ret; - ret = devm_scmi_process_msg(clk->dev->parent, &msg); + ret = devm_scmi_process_msg(clk->dev, &msg); if (ret < 0) return ret; @@ -77,7 +77,7 @@ static ulong scmi_clk_set_rate(struct clk *clk, ulong rate) in, out); int ret; - ret = devm_scmi_process_msg(clk->dev->parent, &msg); + ret = devm_scmi_process_msg(clk->dev, &msg); if (ret < 0) return ret; diff --git a/drivers/firmware/scmi/scmi_agent-uclass.c b/drivers/firmware/scmi/scmi_agent-uclass.c index 4f5870b483..3819f2fa99 100644 --- a/drivers/firmware/scmi/scmi_agent-uclass.c +++ b/drivers/firmware/scmi/scmi_agent-uclass.c @@ -116,10 +116,23 @@ static const struct scmi_agent_ops *transport_dev_ops(struct udevice *dev) int devm_scmi_process_msg(struct udevice *dev, struct scmi_msg *msg) { - const struct scmi_agent_ops *ops = transport_dev_ops(dev); + const struct scmi_agent_ops *ops; + struct udevice *parent = dev; + + /* Find related SCMI agent device */ + do { + parent = dev_get_parent(parent); + } while (parent && device_get_uclass_id(parent) != UCLASS_SCMI_AGENT); + + if (!parent) { + dev_err(dev, "Invalid SCMI device, agent not found\n"); + return -ENODEV; + } + + ops = transport_dev_ops(parent); if (ops->process_msg) - return ops->process_msg(dev, msg); + return ops->process_msg(parent, msg); return -EPROTONOSUPPORT; } diff --git a/drivers/power/regulator/scmi_regulator.c b/drivers/power/regulator/scmi_regulator.c index 3ddeaf4adc..2966bdcf83 100644 --- a/drivers/power/regulator/scmi_regulator.c +++ b/drivers/power/regulator/scmi_regulator.c @@ -38,7 +38,7 @@ static int scmi_voltd_set_enable(struct udevice *dev, bool enable) in, out); int ret; - ret = devm_scmi_process_msg(dev->parent->parent, &msg); + ret = devm_scmi_process_msg(dev, &msg); if (ret) return ret; @@ -61,7 +61,7 @@ static int scmi_voltd_get_enable(struct udevice *dev) in, out); int ret; - ret = devm_scmi_process_msg(dev->parent->parent, &msg); + ret = devm_scmi_process_msg(dev, &msg); if (ret < 0) return ret; @@ -85,7 +85,7 @@ static int scmi_voltd_set_voltage_level(struct udevice *dev, int uV) in, out); int ret; - ret = devm_scmi_process_msg(dev->parent->parent, &msg); + ret = devm_scmi_process_msg(dev, &msg); if (ret < 0) return ret; @@ -104,7 +104,7 @@ static int scmi_voltd_get_voltage_level(struct udevice *dev) in, out); int ret; - ret = devm_scmi_process_msg(dev->parent->parent, &msg); + ret = devm_scmi_process_msg(dev, &msg); if (ret < 0) return ret; @@ -147,7 +147,7 @@ static int scmi_regulator_probe(struct udevice *dev) /* Check voltage domain is known from SCMI server */ in.domain_id = pdata->domain_id; - ret = devm_scmi_process_msg(dev->parent->parent, &scmi_msg); + ret = devm_scmi_process_msg(dev, &scmi_msg); if (ret) { dev_err(dev, "Failed to query voltage domain %u: %d\n", pdata->domain_id, ret); diff --git a/drivers/reset/reset-scmi.c b/drivers/reset/reset-scmi.c index ca0135a420..850cb18886 100644 --- a/drivers/reset/reset-scmi.c +++ b/drivers/reset/reset-scmi.c @@ -26,7 +26,7 @@ static int scmi_reset_set_level(struct reset_ctl *rst, bool assert_not_deassert) in, out); int ret; - ret = devm_scmi_process_msg(rst->dev->parent, &msg); + ret = devm_scmi_process_msg(rst->dev, &msg); if (ret) return ret; @@ -58,7 +58,7 @@ static int scmi_reset_request(struct reset_ctl *rst) * We don't really care about the attribute, just check * the reset domain exists. */ - ret = devm_scmi_process_msg(rst->dev->parent, &msg); + ret = devm_scmi_process_msg(rst->dev, &msg); if (ret) return ret; diff --git a/include/scmi_agent.h b/include/scmi_agent.h index 5015c06be9..18bcd48a9d 100644 --- a/include/scmi_agent.h +++ b/include/scmi_agent.h @@ -51,7 +51,7 @@ struct scmi_msg { * Caller sets scmi_msg::out_msg_sz to the output message buffer size. * On return, scmi_msg::out_msg_sz stores the response payload size. * - * @dev: SCMI agent device + * @dev: SCMI device * @msg: Message structure reference * Return: 0 on success and a negative errno on failure */