From patchwork Fri May 13 06:26:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Etienne Carriere X-Patchwork-Id: 572079 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:66c4:0:0:0:0 with SMTP id x4csp198638mal; Thu, 12 May 2022 23:31:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxIinRm0FdskmlIIOnEEMOtYMynI2E/B/Ta1+sheSD6jwIOtOGHMhcrBVuumzWa4bX7QIXn X-Received: by 2002:a17:907:2d8e:b0:6f4:92ad:e38a with SMTP id gt14-20020a1709072d8e00b006f492ade38amr2904408ejc.365.1652423478949; Thu, 12 May 2022 23:31:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652423478; cv=none; d=google.com; s=arc-20160816; b=eKbflwfO+OePNFk407YaSjcbQljJTPEuZjfN1nDEW2E0KJw6hxWgaDTk4sZhSIycrN G34E3VZBzCkcmEC7mrvMDGBPlOcsN9bHPTcn2xuvK+kJtXvB2dS6UgddAEWNMzmBQZPq g2oL8ydlZpEi5a4FnZ4MGGRT/q9Y2/AKGClAABqx0VDYjJN1dY7TCyfALJqkjZtTkOch e8KEhm8aJer/f2/i6JK9Nd/HSfbgYz4L4rSQAKw/1LMhLppBnQdPMKF9VSYQabArTRpj 53D2jGRChPa2GoTQkaZyTFiBxtwenPgdobifQxkQAqKSO0Ipt4PKCLUMRMVVHby/SWJZ MtJg== 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=ni+hQevD7eIpweO9wJM4jc4KEFesOk3xEfJogXHSGGs=; b=IqFY6SnvclaxmWTSp8FUwAnoa1D1//lFBzTPD56UE3CDOQIsxBDulic4vsLb3PxF4D iDj6EkU5kJyD5ptbCnexQCMC5w3sXRTe/N6F7b8XNsFytANylI0Qt+PkkzWDoimfUI3x hMWahKGlrzEJuTJWb3YcL0l22DWuqj43xhR5mOBZjUrd1Bxf78WL8iR5FLFpp6qf167G FVr1phDEOo9q/73Gi7CLpjb4kij0p3pKWrW8H6bWI648t8QOblFY9P13A/f/JIh/HtW/ C3sbPW58vMGGktJn4vNo7ZS1kdUJ7ZN578ZhaVkZdGthMhvTiNdyMPjyhZbM3upHFUPN Bsbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MNrWh5Bk; 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 r18-20020a1709060d5200b006f391d80336si1293067ejh.218.2022.05.12.23.31.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 May 2022 23:31:18 -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=MNrWh5Bk; 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 1BE8283EA1; Fri, 13 May 2022 08:29: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=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="MNrWh5Bk"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 14CEA83EC5; Fri, 13 May 2022 08:28:45 +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-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) (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 5911A83B2F for ; Fri, 13 May 2022 08:28:37 +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-x429.google.com with SMTP id k2so10054403wrd.5 for ; Thu, 12 May 2022 23:28:37 -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=ni+hQevD7eIpweO9wJM4jc4KEFesOk3xEfJogXHSGGs=; b=MNrWh5BkvQZG+FxOJedEDEWpK3cp0oY4sfG8FUu8pbWjJMULaJ5mGqhhnmmoOm7xRw kLgX6zP6/wCo6kLYy21DSSvePWpBM4z+0yCvaD0nw37TVzsXnQeGII6tWM4uOycW7so5 e7fAqb1YQnR5M8cBmIFnl/Kcx7Khn7AA0r/8Y7DdVs2GAX7S5zMvpf+i5HipMTeim59G eDRw6HhHitI0Hv0NLCVNokUF6auOJoT9HUAwg0wHnoWTRiBoYHthxj9k3YS/TxDcTnFe 5Td5nwCKyfeYlGwGCtJyP40nIqToE0DDj3qg1ejC/LrAm86AdeWKqGv/XuooFlMxH0Af lUww== 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=ni+hQevD7eIpweO9wJM4jc4KEFesOk3xEfJogXHSGGs=; b=uLDqwwrckz/NFQcCyYZkCKpxPVfel0wWEY8+cS0dm6uZg52Zf3MHoaRGmS39G8gkji caQYO0EVVEvuFPkac8TrYnRXXZiTIYwoezenHj/Z/zQSVLdjlvTaPJCoRzyXwm2jx8Z8 DhnX/UT400+uqeHbvgKWXnwE5Z60pynLZkDKxzt80yBPIvw2KEWZMsTVZwFrm8YsWtjc FwZ4lCOic1+nSEp3DdmcFWmOf9de22ide8IBpH62HYeyXq41NVjEpDJAX+us0OUnBsAR v/+Qh5b+BSnx5OesnzI5yvuZBs9r8dHffs5obsMNekWuHys1lYLL0zKMj16+PYCO/adt fLkw== X-Gm-Message-State: AOAM531sU94mV2WuV53XdLAybie+s6geBMUeINm4JunrKvr9C5b0Vefl yJ9Sc58izcyeFU4rdfyzYWcE4U6WqGwj1g== X-Received: by 2002:a05:6000:1ac7:b0:20c:6c81:c8e5 with SMTP id i7-20020a0560001ac700b0020c6c81c8e5mr2606770wry.580.1652423316447; Thu, 12 May 2022 23:28:36 -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.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 May 2022 23:28:36 -0700 (PDT) From: Etienne Carriere To: u-boot@lists.denx.de Cc: Patrick Delaunay , Patrice Chotard , Etienne Carriere , Jaehoon Chung Subject: [PATCH 12/14] power: regulator: scmi: support SCMI multi-channel Date: Fri, 13 May 2022 08:26:20 +0200 Message-Id: <20220513062622.155433-13-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 regulator controller driver to get its assigned SCMI channel during initialization. This change allows SCMI voltage domain protocol to use a dedicated channel when defined in the DT. The reference is saved in SCMI regulator controller driver private data. Cc: Jaehoon Chung Signed-off-by: Etienne Carriere Reviewed-by: Jaehoon Chung --- drivers/power/regulator/scmi_regulator.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/drivers/power/regulator/scmi_regulator.c b/drivers/power/regulator/scmi_regulator.c index 3325ddaf23b..e0343e913f4 100644 --- a/drivers/power/regulator/scmi_regulator.c +++ b/drivers/power/regulator/scmi_regulator.c @@ -27,6 +27,7 @@ struct scmi_regulator_platdata { static int scmi_voltd_set_enable(struct udevice *dev, bool enable) { + struct scmi_channel **scmi_channel_ref = dev_get_priv(dev); struct scmi_regulator_platdata *pdata = dev_get_plat(dev); struct scmi_voltd_config_set_in in = { .domain_id = pdata->domain_id, @@ -38,7 +39,7 @@ static int scmi_voltd_set_enable(struct udevice *dev, bool enable) in, out); int ret; - ret = devm_scmi_process_msg(dev, NULL, &msg); + ret = devm_scmi_process_msg(dev, *scmi_channel_ref, &msg); if (ret) return ret; @@ -51,6 +52,7 @@ static int scmi_voltd_set_enable(struct udevice *dev, bool enable) static int scmi_voltd_get_enable(struct udevice *dev) { + struct scmi_channel **scmi_channel_ref = dev_get_priv(dev); struct scmi_regulator_platdata *pdata = dev_get_plat(dev); struct scmi_voltd_config_get_in in = { .domain_id = pdata->domain_id, @@ -61,7 +63,7 @@ static int scmi_voltd_get_enable(struct udevice *dev) in, out); int ret; - ret = devm_scmi_process_msg(dev, NULL, &msg); + ret = devm_scmi_process_msg(dev, *scmi_channel_ref, &msg); if (ret < 0) return ret; @@ -74,6 +76,7 @@ static int scmi_voltd_get_enable(struct udevice *dev) static int scmi_voltd_set_voltage_level(struct udevice *dev, int uV) { + struct scmi_channel **scmi_channel_ref = dev_get_priv(dev); struct scmi_regulator_platdata *pdata = dev_get_plat(dev); struct scmi_voltd_level_set_in in = { .domain_id = pdata->domain_id, @@ -85,7 +88,7 @@ static int scmi_voltd_set_voltage_level(struct udevice *dev, int uV) in, out); int ret; - ret = devm_scmi_process_msg(dev, NULL, &msg); + ret = devm_scmi_process_msg(dev, *scmi_channel_ref, &msg); if (ret < 0) return ret; @@ -94,6 +97,7 @@ static int scmi_voltd_set_voltage_level(struct udevice *dev, int uV) static int scmi_voltd_get_voltage_level(struct udevice *dev) { + struct scmi_channel **scmi_channel_ref = dev_get_priv(dev); struct scmi_regulator_platdata *pdata = dev_get_plat(dev); struct scmi_voltd_level_get_in in = { .domain_id = pdata->domain_id, @@ -104,7 +108,7 @@ static int scmi_voltd_get_voltage_level(struct udevice *dev) in, out); int ret; - ret = devm_scmi_process_msg(dev, NULL, &msg); + ret = devm_scmi_process_msg(dev, *scmi_channel_ref, &msg); if (ret < 0) return ret; @@ -131,6 +135,7 @@ static int scmi_regulator_of_to_plat(struct udevice *dev) static int scmi_regulator_probe(struct udevice *dev) { + struct scmi_channel **scmi_channel_ref = dev_get_priv(dev); struct scmi_regulator_platdata *pdata = dev_get_plat(dev); struct scmi_voltd_attr_in in = { 0 }; struct scmi_voltd_attr_out out = { 0 }; @@ -144,10 +149,14 @@ static int scmi_regulator_probe(struct udevice *dev) }; int ret; + ret = devm_scmi_of_get_channel(dev->parent, scmi_channel_ref); + if (ret) + return ret; + /* Check voltage domain is known from SCMI server */ in.domain_id = pdata->domain_id; - ret = devm_scmi_process_msg(dev, NULL, &scmi_msg); + ret = devm_scmi_process_msg(dev, *scmi_channel_ref, &scmi_msg); if (ret) { dev_err(dev, "Failed to query voltage domain %u: %d\n", pdata->domain_id, ret); @@ -171,6 +180,7 @@ U_BOOT_DRIVER(scmi_regulator) = { .probe = scmi_regulator_probe, .of_to_plat = scmi_regulator_of_to_plat, .plat_auto = sizeof(struct scmi_regulator_platdata), + .priv_auto = sizeof(struct scmi_channel *), }; static int scmi_regulator_bind(struct udevice *dev)