From patchwork Fri May 13 06:26:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Etienne Carriere X-Patchwork-Id: 572075 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:66c4:0:0:0:0 with SMTP id x4csp198251mal; Thu, 12 May 2022 23:30:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzcu1/2Knmc634LDaq2HY4rB8UOs44WXaZW4HU5Te/bGYmHFwKZE41slh1TWljEsMsV0ES3 X-Received: by 2002:a05:6402:3508:b0:427:b100:b825 with SMTP id b8-20020a056402350800b00427b100b825mr38338768edd.268.1652423436389; Thu, 12 May 2022 23:30:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652423436; cv=none; d=google.com; s=arc-20160816; b=DuKBBAfUjAmfsNYcL7KrAUY9oJaI4qzI/+/tqjArEEbJyUmj6Ck1OVxc0/+0Yt4Wvu 9MqwE70TaFcV8jgoQxcOjeGwGQlFMQKJX6+291r/TsWbJPLdmp9sN9mHnRLDTYqtbcVh sGKRRsqnARTC5NBSO9oNHWL4gvg47LZeOEK1eQEmjyDr2K51eUafSnQ3ijHnmn2BmWi7 TDbdX8SfDoH6T2RvVGDbO9BtDmM+hei9ulvnmbaQ83uo/HJzoYAqgi6wQH5h/rIG7TaE +gazC/BN2mZyv8dQFYX4IQvthyZrzS1EczTQp/ijCYHOE+ZSEnMkMj/NGOHfOSpTbupX Ny9Q== 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=bhY9Kggrb1UVzu8Uz27J07i1suMZXiIjoBxkG2uVzZY=; b=nL9e8zC7Lp8eMqQaI6Dv1QV9Ml3N4xDIS3xUfYCMU3uzGAWBLaqp5FrcVJi1Wj86Az bWWIMetU4WIaL9v3jqBgacaM2lbbKtXub4BlY8AZgGds0bJ/JTMPvXw58ZJciKwgIsNK Y66OYh3Cx1l7WGcYLZPT3AHj+LBSqvxxaRfYBtA0vSxs19QvQzkFZgBKYYdqu6c9oNYD 9e3KdREhkJCvWUAfKCuIzKGOpaXNzxv3ZQFbk40e8RfF8YGvKEHXGjxVy3TSFZh5HblO 5ed2YbOWNwieCBAzQxraQbXqMEUc5CpF2dKmjr8QzKvBCwO0MxgN+aqZ5L54/h/458Tg iQEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tNr6kOd9; 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 oz14-20020a1709077d8e00b006f424a70464si1279460ejc.868.2022.05.12.23.30.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 May 2022 23:30:36 -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=tNr6kOd9; 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 F3154840D8; Fri, 13 May 2022 08:29:19 +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="tNr6kOd9"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 164B783EC5; Fri, 13 May 2022 08:28:42 +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-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) (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 59E3183EC6 for ; Fri, 13 May 2022 08:28:35 +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-x329.google.com with SMTP id 129so4236892wmz.0 for ; Thu, 12 May 2022 23:28:35 -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=bhY9Kggrb1UVzu8Uz27J07i1suMZXiIjoBxkG2uVzZY=; b=tNr6kOd99eFZ9beytdQHwEtVJGvajM1a8HtYWUeR68spObEaAwYvsF0Y8bGZwIhdke tE8DdsJgEfVvLAHah0zfOSX9xgi/SC0q6X5P0cTwzOCABzDoztofCnjoBVzbKAVWveeQ ars70a9V2tgVo8gCfUvkRGkiGLtNt4rfGTcHr3azhr0x6wvFRsusJHC8TUvy86TCpawk KxN0bnkaEkXEigdFkSJ6QAOtXcH5MAHyrOt/Qga9DHho97j9gb0cEoS3PQqY8Ue4/hzj rxfipYNRwGlnsD9v2HV8aIQbzemmTBHOHxgBng67LIygTvv+hPVuWE6dnGoPTFZOI8C2 DDaw== 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=bhY9Kggrb1UVzu8Uz27J07i1suMZXiIjoBxkG2uVzZY=; b=5f5JrttS9IxKpbG+jpkco9mCDVf4RLQ9c+zqtccI6Xt+MKaMlttzSOuGrSywO6MEL/ 7hRfMWwUqgQD8rpH0dci5rebAWk+nQxdrChrTuXfDLNUGtRH0zn+R1VKjNmC4+30sDbb jeD6006B7wMRWVEgtazftFi9sFuxObUver2e+BK0Z94A5uRfSSuMKIWHE7uz5tmbreQ1 xqHbgctSSn96IS44sjtbTsrL28iDVr7q9G77YleXyFjpWggw9fLjtmfwR9YpKEeKok5c 2Xp1x0qX0dEph2NvYfaazVnw4qStIG2e41rNDc4o60tH6jyn+1hhGpz6p2KSW4skAyPb LMrQ== X-Gm-Message-State: AOAM5300FQPsnyPK+/GTrkUUes+h/MJBf6AmHVX2bnvM2tVrnkmhTUYz NAtmoNtSu8PqkQCbEhUSk35m5OAc17oyKw== X-Received: by 2002:a05:600c:190d:b0:394:8241:6454 with SMTP id j13-20020a05600c190d00b0039482416454mr3058118wmq.198.1652423314416; Thu, 12 May 2022 23:28:34 -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.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 May 2022 23:28:34 -0700 (PDT) From: Etienne Carriere To: u-boot@lists.denx.de Cc: Patrick Delaunay , Patrice Chotard , Etienne Carriere , Lukasz Majewski , Sean Anderson Subject: [PATCH 10/14] clk: scmi: support SCMI multi-channel Date: Fri, 13 May 2022 08:26:18 +0200 Message-Id: <20220513062622.155433-11-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 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 --- drivers/clk/clk_scmi.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/drivers/clk/clk_scmi.c b/drivers/clk/clk_scmi.c index 0d0bb72eaf7..5cf7bd73df5 100644 --- a/drivers/clk/clk_scmi.c +++ b/drivers/clk/clk_scmi.c @@ -15,6 +15,7 @@ static int scmi_clk_get_num_clock(struct udevice *dev, size_t *num_clocks) { + struct scmi_channel **scmi_channel_ref = dev_get_priv(dev); struct scmi_clk_protocol_attr_out out; struct scmi_msg msg = { .protocol_id = SCMI_PROTOCOL_ID_CLOCK, @@ -24,7 +25,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, *scmi_channel_ref, &msg); if (ret) return ret; @@ -35,6 +36,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_channel **scmi_channel_ref = dev_get_priv(dev); struct scmi_clk_attribute_in in = { .clock_id = clkid, }; @@ -49,7 +51,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, *scmi_channel_ref, &msg); if (ret) return ret; @@ -60,6 +62,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_channel **scmi_channel_ref = dev_get_priv(clk->dev); struct scmi_clk_state_in in = { .clock_id = clk->id, .attributes = enable, @@ -70,7 +73,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, *scmi_channel_ref, &msg); if (ret) return ret; @@ -89,6 +92,7 @@ static int scmi_clk_disable(struct clk *clk) static ulong scmi_clk_get_rate(struct clk *clk) { + struct scmi_channel **scmi_channel_ref = dev_get_priv(clk->dev); struct scmi_clk_rate_get_in in = { .clock_id = clk->id, }; @@ -98,7 +102,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, *scmi_channel_ref, &msg); if (ret < 0) return ret; @@ -111,6 +115,7 @@ static ulong scmi_clk_get_rate(struct clk *clk) static ulong scmi_clk_set_rate(struct clk *clk, ulong rate) { + struct scmi_channel **scmi_channel_ref = dev_get_priv(clk->dev); struct scmi_clk_rate_set_in in = { .clock_id = clk->id, .flags = SCMI_CLK_RATE_ROUND_CLOSEST, @@ -123,7 +128,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, *scmi_channel_ref, &msg); if (ret < 0) return ret; @@ -136,10 +141,15 @@ static ulong scmi_clk_set_rate(struct clk *clk, ulong rate) static int scmi_clk_probe(struct udevice *dev) { + struct scmi_channel **scmi_channel_ref = dev_get_priv(dev); struct clk *clk; size_t num_clocks, i; int ret; + ret = devm_scmi_of_get_channel(dev, scmi_channel_ref); + if (ret) + return ret; + if (!CONFIG_IS_ENABLED(CLK_CCF)) return 0; @@ -186,5 +196,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_channel *), };