From patchwork Tue May 31 16:09:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Etienne Carriere X-Patchwork-Id: 577456 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:330b:0:0:0:0 with SMTP id f11csp1302141mag; Tue, 31 May 2022 09:11:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxBIkALXfKQDxBs0KTtx1cFRVi964pTAeyEAsQq63E3n7sc02h8saN3KNDAsGpom73XCzmz X-Received: by 2002:a05:6e02:1c45:b0:2d3:bb0c:9559 with SMTP id d5-20020a056e021c4500b002d3bb0c9559mr2852783ilg.251.1654013515307; Tue, 31 May 2022 09:11:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654013515; cv=none; d=google.com; s=arc-20160816; b=lGPMG/sqi3ND4TiOVwtOFXedHJJYyr2NQJsvLikLCTPs4/TDmROxbIMY+XgodtQ2eJ i8Pm1ae149KTncDNK6CPEMc1Aza31EzY2sOdOoilylKYrsY6aqG38AIEG9WuFSGhVI70 BBcJsUU4lk7HVzPcJJPpUH3eQS/p2l73jhTi4rztu0HQRuJ6M1EPZbViYQqrX/kEqJNu NS4V6PfINQqIx40i3EM6z+HFqCsInxj/lFv/XAOh47EkuOtH1mdoDn9ZebxJCKsqLIrS 5/0sDuMLY1oIm3s71uWL3myuysRXCiUvHJ3tcklCFluGyqUaYdHchVuRHQDpNaAxoizN 3uPA== 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=/2DYzo6aKwa+iW9Y8HNcQlnWBb1YlYUSK8becWxcOos=; b=Cx7t/Qw7z6B0b1nQC8LDLCB4lDzyvk1ZtpLLpTaleePrBMh28a1marNPQ6cAq6wQFa JRC83gR61y0in15r2Df22LoB8ah4KpwTYucTjBB2xu9rfqf9GRQZtnppKgav4yuaCel7 lrkehRqFhX3AJBIbyNr9DbLA5LCS3be/GpTt1f7lyBgcAoERO2gUAwtFLcIubBkmRWO4 9W1z9IA9D3LATk34n9Rt7hG1nSt1lsqMAjEjej54C6VeIOHVSYkgMMYDQeiVdQARbsHp cdNHPnfNXWSIeG96thuBUpQsY9QRgEyAYvt63KviEUldc+IzPoLTtcz3PKZf6BQ3xce5 K8uA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="zHTb3jx/"; 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 i4-20020a026004000000b0032e22157263si11790704jac.122.2022.05.31.09.11.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 May 2022 09:11:55 -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="zHTb3jx/"; 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 EC381842DB; Tue, 31 May 2022 18:10:34 +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="zHTb3jx/"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1236383E3C; Tue, 31 May 2022 18:09:57 +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=unavailable 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 057F484271 for ; Tue, 31 May 2022 18:09:48 +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 q21so8155258wra.2 for ; Tue, 31 May 2022 09:09:47 -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=/2DYzo6aKwa+iW9Y8HNcQlnWBb1YlYUSK8becWxcOos=; b=zHTb3jx/5epWR/PvG1KfrlJ1JEZpawdblUkcqC5jsRQQ1DEDv/gF4uLgUyNQ0DZHkC 3EiBSwmXeLD2LpblGaOb0uKHNslsZOaUZU/ix0E2yPNNVbXYc7MsU06BgwAv4CCKO1Uq msvy6V3j/x4M5LcmNGyze6VontaOxf2oOvNhBhq76QUazH9qmoz2zEpxuvhzgkODxBB0 6tnHtCAsBFOIx/inPNRG9ahbF+81tRkDpLpiOUOgTVnc3Q862WTvVUnm/7mrJIFIzzyZ vEORzGb9p0+NM95avdet1xcKZSJ0SdqnkgzAcNM+3UmDvpsSaMBc6MFMCdM8TJXlTJqi ruLQ== 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=/2DYzo6aKwa+iW9Y8HNcQlnWBb1YlYUSK8becWxcOos=; b=4y5mWvns5U+ZS21tlvNg6yta4HA2+kiUwQXXK5CwwaDVZkwTLK9fACTp4MLyHZjgET l+jLEL8vlcZ6GszOZBtZ36d9t485LEypL0dG4Mw1APKKoaIpYbPNHeM5aFwrGZ7f3Ofw oQqB2VwNnPVzZTkIdn+/ljY4NcfYyW5HYhMKRNzYSertlkYFXWu0Zau/DN8IGgAyFXcV wHEDfQQpTRidcdyznhWqn7h4gzLs8TglwGJhVish/05qQ/PHVUwKEdGqu5i5c13FvAvO zIVs9Odg7qzpE6BR9J822/3ryQwKF2rLCGLYiozgtxgddcOYpHHJAkRi4fCO3GXG1CHB pAhQ== X-Gm-Message-State: AOAM5306mDBSLYIAkshcnaQL1H3hfP0yJvpaPzKdRM2CUbPxQVB6mA9h gE+w3l/zxyM08Ygt5aZcZJOEiWDHFE3tug== X-Received: by 2002:adf:fd10:0:b0:20d:c38:d43a with SMTP id e16-20020adffd10000000b0020d0c38d43amr51560624wrr.84.1654013386891; Tue, 31 May 2022 09:09:46 -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.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 May 2022 09:09:46 -0700 (PDT) From: Etienne Carriere To: u-boot@lists.denx.de Cc: Patrick Delaunay , Patrice Chotard , etienne.carriere@linaro.org, Lukasz Majewski , Sean Anderson Subject: [PATCH v2 10/14] clk: scmi: support SCMI multi-channel Date: Tue, 31 May 2022 18:09:25 +0200 Message-Id: <20220531160929.931150-11-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 Update SCMI clock driver to get its assigned SCMI channel during initialization. This change allows SCMI clock protocol to use a dedicated channel when defined in the DT. The reference is saved in SCMI clock driver private data. Cc: Lukasz Majewski Cc: Sean Anderson Signed-off-by: Etienne Carriere Reviewed-by: Sean Anderson --- Changes since v1: - Define a private struct to hold channel reference rather than using device private data reference as opaque channel reference. --- drivers/clk/clk_scmi.c | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/drivers/clk/clk_scmi.c b/drivers/clk/clk_scmi.c index 0d0bb72eaf7..d172fed24c9 100644 --- a/drivers/clk/clk_scmi.c +++ b/drivers/clk/clk_scmi.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0+ /* - * Copyright (C) 2019-2020 Linaro Limited + * Copyright (C) 2019-2022 Linaro Limited */ #define LOG_CATEGORY UCLASS_CLK @@ -13,8 +13,17 @@ #include #include +/** + * struct scmi_clk_priv - Private data for SCMI clocks + * @channel: Reference to the SCMI channel to use + */ +struct scmi_clk_priv { + struct scmi_channel *channel; +}; + static int scmi_clk_get_num_clock(struct udevice *dev, size_t *num_clocks) { + struct scmi_clk_priv *priv = dev_get_priv(dev); struct scmi_clk_protocol_attr_out out; struct scmi_msg msg = { .protocol_id = SCMI_PROTOCOL_ID_CLOCK, @@ -24,7 +33,7 @@ static int scmi_clk_get_num_clock(struct udevice *dev, size_t *num_clocks) }; int ret; - ret = devm_scmi_process_msg(dev, NULL, &msg); + ret = devm_scmi_process_msg(dev, priv->channel, &msg); if (ret) return ret; @@ -35,6 +44,7 @@ static int scmi_clk_get_num_clock(struct udevice *dev, size_t *num_clocks) static int scmi_clk_get_attibute(struct udevice *dev, int clkid, char **name) { + struct scmi_clk_priv *priv = dev_get_priv(dev); struct scmi_clk_attribute_in in = { .clock_id = clkid, }; @@ -49,7 +59,7 @@ static int scmi_clk_get_attibute(struct udevice *dev, int clkid, char **name) }; int ret; - ret = devm_scmi_process_msg(dev, NULL, &msg); + ret = devm_scmi_process_msg(dev, priv->channel, &msg); if (ret) return ret; @@ -60,6 +70,7 @@ static int scmi_clk_get_attibute(struct udevice *dev, int clkid, char **name) static int scmi_clk_gate(struct clk *clk, int enable) { + struct scmi_clk_priv *priv = dev_get_priv(clk->dev); struct scmi_clk_state_in in = { .clock_id = clk->id, .attributes = enable, @@ -70,7 +81,7 @@ static int scmi_clk_gate(struct clk *clk, int enable) in, out); int ret; - ret = devm_scmi_process_msg(clk->dev, NULL, &msg); + ret = devm_scmi_process_msg(clk->dev, priv->channel, &msg); if (ret) return ret; @@ -89,6 +100,7 @@ static int scmi_clk_disable(struct clk *clk) static ulong scmi_clk_get_rate(struct clk *clk) { + struct scmi_clk_priv *priv = dev_get_priv(clk->dev); struct scmi_clk_rate_get_in in = { .clock_id = clk->id, }; @@ -98,7 +110,7 @@ static ulong scmi_clk_get_rate(struct clk *clk) in, out); int ret; - ret = devm_scmi_process_msg(clk->dev, NULL, &msg); + ret = devm_scmi_process_msg(clk->dev, priv->channel, &msg); if (ret < 0) return ret; @@ -111,6 +123,7 @@ static ulong scmi_clk_get_rate(struct clk *clk) static ulong scmi_clk_set_rate(struct clk *clk, ulong rate) { + struct scmi_clk_priv *priv = dev_get_priv(clk->dev); struct scmi_clk_rate_set_in in = { .clock_id = clk->id, .flags = SCMI_CLK_RATE_ROUND_CLOSEST, @@ -123,7 +136,7 @@ static ulong scmi_clk_set_rate(struct clk *clk, ulong rate) in, out); int ret; - ret = devm_scmi_process_msg(clk->dev, NULL, &msg); + ret = devm_scmi_process_msg(clk->dev, priv->channel, &msg); if (ret < 0) return ret; @@ -136,10 +149,15 @@ static ulong scmi_clk_set_rate(struct clk *clk, ulong rate) static int scmi_clk_probe(struct udevice *dev) { + struct scmi_clk_priv *priv = dev_get_priv(dev); struct clk *clk; size_t num_clocks, i; int ret; + ret = devm_scmi_of_get_channel(dev, &priv->channel); + if (ret) + return ret; + if (!CONFIG_IS_ENABLED(CLK_CCF)) return 0; @@ -186,5 +204,6 @@ U_BOOT_DRIVER(scmi_clock) = { .name = "scmi_clk", .id = UCLASS_CLK, .ops = &scmi_clk_ops, - .probe = &scmi_clk_probe, + .probe = scmi_clk_probe, + .priv_auto = sizeof(struct scmi_clk_priv *), };