From patchwork Tue May 31 16:09:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Etienne Carriere X-Patchwork-Id: 577458 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:330b:0:0:0:0 with SMTP id f11csp1302507mag; Tue, 31 May 2022 09:12:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwDA23yQb52bdPMCCepYoJjeBoVVIqE4zh2Xo/zZcoB/s/P9mvfnOiFZHksBXXVrw/ny3Ov X-Received: by 2002:a6b:5a0c:0:b0:660:d32b:df5b with SMTP id o12-20020a6b5a0c000000b00660d32bdf5bmr21944773iob.39.1654013540172; Tue, 31 May 2022 09:12:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654013540; cv=none; d=google.com; s=arc-20160816; b=ZEOmP8WATrD7N3NBS8FVdM1NFTuNMxcC2GXgm/30ClSrTF9bS6X2XMUop6cvzN8CFR 2lwM8bu495I1125tctsELWbiyGy8JMChNtnHOQZLoQJynnLS2HVXAbR3RVA6qV5nLScn Nvm4czTEQJQVnXkgXFnZLK+E12BUqEjg8u+8VZhxev47ERoF6YzXbT5huE9xeHuN6Dc3 +j94qDyauMkajXkKCVT8EyWbjIFVEJGoJHNmLbcC/Dpgc89Fgen/bLOhU74zR6bRI7cU TkuXJSC6tNITVD2fG6th8vtVeBWRDPcVpglDUnYFP3pxSWhWhVCT7o8BgGk9ROv2ZrWC FSUA== 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=bBHdViJGuJjkkaael2/r5JxOOahuH/fZqg55eEXV9yg=; b=adHwaHe/j72GV9awK1gYYpTu1KmzifBbdLdyHNx4Yf0TCRcQ0WXcOyZd7pBuKwsfcM aNW+bt/cLmJT5trU5qzOsnOJlsEEMX+ZlsdN3So3ieYl3chH6Iq3u/iwnG8TtICZ4ALK nw9nQqcFBe5U2ceRA9EjyVVOJlvDHMd0r75vvsCl0PC3zxxBWkgbe5Di9xOFGKGaL1vo NRJdOMK8oU86Nc9j6Ilg5LvH9AYNlT8P3XmfDlPe13yoeQWzRmLDEobNrpp0p6xnFJdQ GnNyd5h+dlvNkBQsKxGeJRdOXnYAdrUWqS1S69zw6iUd7/F7W/TAafD41OuaNp0QSeY1 kTJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=b8ILpFH5; 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 m2-20020a056e02158200b002d1d77fb959si15544347ilu.85.2022.05.31.09.12.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 May 2022 09:12:20 -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=b8ILpFH5; 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 CC14884318; Tue, 31 May 2022 18:10:41 +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="b8ILpFH5"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0CA1B83E3C; Tue, 31 May 2022 18:09:59 +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-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) (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 A489684282 for ; Tue, 31 May 2022 18:09:50 +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-x436.google.com with SMTP id d26so13743230wrb.13 for ; Tue, 31 May 2022 09:09:50 -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=bBHdViJGuJjkkaael2/r5JxOOahuH/fZqg55eEXV9yg=; b=b8ILpFH52t1Bi9ldDAw83ZHQBd8846dEPAjLU06HTcoCSUtKaM++wn+3AaPmpwpX8O Sab/3Ly2uyWrP/jpn/eucuf43EvEGyZWPYh387i9fpLzf7chMid/9CThgwnivtcigOOB Qa6Vyem7JHa9hOmHIWKZzRxGVfZNF7RA9gbFsyBq8O9hk2zbcdnPHd9lnCW+3eTff9O2 +6uywUGUulktkgzZXBDKZ/fOVNpI7Qyv6+FujA2F5fhmmWqfA20Q4Yxy62qjZFps+tvH NYgLVtIOcAekdAyZ6AZHG+HskrPWF4HZP1u8HcbRdn242VzSiKV/Nx5tdX9jU8gD7EM3 QNig== 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=bBHdViJGuJjkkaael2/r5JxOOahuH/fZqg55eEXV9yg=; b=fseVD1ys68zWtQGeNRB/vwIUtcMmJoHh3r7Rqj/qMaGkRetgydYjvGhrStCvnmzf+V yUKSpM5qMJkGw0bFuATWX1+h0TFo2rq5MfATmFKstmijULepVXO8ngLyjzL8F9Wsj+O6 ROepESNwnTnzzBNDrTkWCbUtXiiMeyijSlgYVb9BM6+OtWVpuFdhJ1FZn1zzIq8UgV8c 6pkmoQBfmopQRfri+ehCXOV0JqJIvTMNJ2H3J2sIbOFLhyU0FVhbfVW5TvEleddx+0f7 /02F8DUV6q7BbeM0mpG+xcfBWBCUe5cNriBAiysxOqkyHu+mU2tCnwkmImrPfOkbG1tp pE+Q== X-Gm-Message-State: AOAM530r5ATNSwC7Kej0hsHrd7zHtdTDQavwZflyoBByHZ5oc0XM136y TP5w6NS1sUMx9+SHvRUyAjn8/tlnhx1OJg== X-Received: by 2002:a5d:540a:0:b0:20e:69db:4dc5 with SMTP id g10-20020a5d540a000000b0020e69db4dc5mr48814458wrv.337.1654013389390; Tue, 31 May 2022 09:09:49 -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.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 May 2022 09:09:49 -0700 (PDT) From: Etienne Carriere To: u-boot@lists.denx.de Cc: Patrick Delaunay , Patrice Chotard , etienne.carriere@linaro.org, Jaehoon Chung Subject: [PATCH v2 12/14] power: regulator: scmi: support SCMI multi-channel Date: Tue, 31 May 2022 18:09:27 +0200 Message-Id: <20220531160929.931150-13-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 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 --- Changes since v1: - Define a private struct to hold channel reference rather than using device private data reference as opaque channel reference. --- drivers/power/regulator/scmi_regulator.c | 30 +++++++++++++++++++----- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/drivers/power/regulator/scmi_regulator.c b/drivers/power/regulator/scmi_regulator.c index 3325ddaf23b..352daa9bbc9 100644 --- a/drivers/power/regulator/scmi_regulator.c +++ b/drivers/power/regulator/scmi_regulator.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0+ /* - * Copyright (C) 2020-2021 Linaro Limited + * Copyright (C) 2020-2022 Linaro Limited */ #define LOG_CATEGORY UCLASS_REGULATOR @@ -25,9 +25,18 @@ struct scmi_regulator_platdata { u32 domain_id; }; +/** + * struct scmi_regulator_priv - Private data for SCMI voltage regulator + * @channel: Reference to the SCMI channel to use + */ +struct scmi_regulator_priv { + struct scmi_channel *channel; +}; + static int scmi_voltd_set_enable(struct udevice *dev, bool enable) { struct scmi_regulator_platdata *pdata = dev_get_plat(dev); + struct scmi_regulator_priv *priv = dev_get_priv(dev); struct scmi_voltd_config_set_in in = { .domain_id = pdata->domain_id, .config = enable ? SCMI_VOLTD_CONFIG_ON : SCMI_VOLTD_CONFIG_OFF, @@ -38,7 +47,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, priv->channel, &msg); if (ret) return ret; @@ -52,6 +61,7 @@ static int scmi_voltd_set_enable(struct udevice *dev, bool enable) static int scmi_voltd_get_enable(struct udevice *dev) { struct scmi_regulator_platdata *pdata = dev_get_plat(dev); + struct scmi_regulator_priv *priv = dev_get_priv(dev); struct scmi_voltd_config_get_in in = { .domain_id = pdata->domain_id, }; @@ -61,7 +71,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, priv->channel, &msg); if (ret < 0) return ret; @@ -74,6 +84,7 @@ static int scmi_voltd_get_enable(struct udevice *dev) static int scmi_voltd_set_voltage_level(struct udevice *dev, int uV) { + struct scmi_regulator_priv *priv = 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 +96,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, priv->channel, &msg); if (ret < 0) return ret; @@ -94,6 +105,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_regulator_priv *priv = 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 +116,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, priv->channel, &msg); if (ret < 0) return ret; @@ -132,6 +144,7 @@ static int scmi_regulator_of_to_plat(struct udevice *dev) static int scmi_regulator_probe(struct udevice *dev) { struct scmi_regulator_platdata *pdata = dev_get_plat(dev); + struct scmi_regulator_priv *priv = dev_get_priv(dev); struct scmi_voltd_attr_in in = { 0 }; struct scmi_voltd_attr_out out = { 0 }; struct scmi_msg scmi_msg = { @@ -144,10 +157,14 @@ static int scmi_regulator_probe(struct udevice *dev) }; int ret; + ret = devm_scmi_of_get_channel(dev->parent, &priv->channel); + 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, priv->channel, &scmi_msg); if (ret) { dev_err(dev, "Failed to query voltage domain %u: %d\n", pdata->domain_id, ret); @@ -171,6 +188,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_regulator_priv *), }; static int scmi_regulator_bind(struct udevice *dev)