From nobody Tue Jun 30 05:28:50 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4A958C2BA4C for ; Tue, 25 Jan 2022 00:05:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2369030AbiAYAAr (ORCPT ); Mon, 24 Jan 2022 19:00:47 -0500 Received: from alexa-out-sd-02.qualcomm.com ([199.106.114.39]:43529 "EHLO alexa-out-sd-02.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1847818AbiAXXUn (ORCPT ); Mon, 24 Jan 2022 18:20:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1643066443; x=1674602443; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=2wr8SGhJDgwc1rii8kTEvDvFvWDeC6rw0Za8FEAfY5c=; b=wuMn6jikAHoC7ajV0Pyy/XREitzsoptc7LFzBcune5vw8ZGU9IrMRwQd tzaqKjAQNqF8050A0hNdlB0zjQIZJR+Faue8wF3MUfraheNPIkmTykAif 4Bs3cjel+hKbsD2N9MCxeKHNROmrYGr33kNIK7l32ZSQ+ek9ZR9M/GOLS Y=; Received: from unknown (HELO ironmsg03-sd.qualcomm.com) ([10.53.140.143]) by alexa-out-sd-02.qualcomm.com with ESMTP; 24 Jan 2022 15:20:42 -0800 X-QCInternal: smtphost Received: from nasanex01b.na.qualcomm.com ([10.46.141.250]) by ironmsg03-sd.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jan 2022 15:20:42 -0800 Received: from collinsd-linux.qualcomm.com (10.80.80.8) by nasanex01b.na.qualcomm.com (10.46.141.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.922.19; Mon, 24 Jan 2022 15:20:41 -0800 From: David Collins To: Rob Herring , Sudeep Holla , CC: David Collins , Mark Brown , Liam Girdwood , Cristian Marussi , , , , "Subbaraman Narayanamurthy" Subject: [RESEND PATCH 1/2] dt-bindings: firmware: arm,scmi: define support for name based regulators Date: Mon, 24 Jan 2022 15:20:01 -0800 Message-ID: <2d78b0f19991f8028d9be913be0a5aefd7d1ee17.1639099631.git.quic_collinsd@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nasanex01b.na.qualcomm.com (10.46.141.250) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Message-ID: <20220124232001.LhbfVHtPpEJh9I7iFbqd5tiNtGThxZLDRdRGf1yavTg@z> Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Allow SCMI regulator subnodes to be specified either by ID using the "reg" property or by name using the "regulator-name" property. Name based SCMI regulator specification helps ensure that an SCMI agent doesn't need to be aware of the numbering scheme used for Voltage Domains by the SCMI platform. It also ensures that the correct Voltage Domain is selected for a given physical regulator. This cannot be guaranteed with numeric Voltage Domain IDs alone. Signed-off-by: David Collins Reviewed-by: Rob Herring --- .../devicetree/bindings/firmware/arm,scmi.yaml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/firmware/arm,scmi.yaml b/Doc= umentation/devicetree/bindings/firmware/arm,scmi.yaml index 5c4c6782e052..bc4a84fe25d2 100644 --- a/Documentation/devicetree/bindings/firmware/arm,scmi.yaml +++ b/Documentation/devicetree/bindings/firmware/arm,scmi.yaml @@ -155,7 +155,7 @@ properties: The list of all regulators provided by this SCMI controller. =20 patternProperties: - '^regulators@[0-9a-f]+$': + '^regulator.+$': type: object $ref: "../regulator/regulator.yaml#" =20 @@ -164,8 +164,13 @@ properties: maxItems: 1 description: Identifier for the voltage regulator. =20 - required: - - reg + regulator-name: true + + anyOf: + - required: + - reg + - required: + - regulator-name =20 additionalProperties: false =20 --=20 2.17.1 From nobody Tue Jun 30 05:28:50 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 135B7C4332F for ; Tue, 25 Jan 2022 00:09:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2370993AbiAYAGp (ORCPT ); Mon, 24 Jan 2022 19:06:45 -0500 Received: from alexa-out-sd-01.qualcomm.com ([199.106.114.38]:65534 "EHLO alexa-out-sd-01.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1847822AbiAXXUn (ORCPT ); Mon, 24 Jan 2022 18:20:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1643066443; x=1674602443; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=lHW3hLnV/NwAlPaJvWLZeYHn/Z13jsz9Dd88QrFizYA=; b=m++m4t7oTvxKU3eDqNBL/kDP212fa18klJqMbqXSBtv7nLcZYjHJO3Kl t26byNRVb3if/tSC3Pyj9zZE7iY/99hJVVGMDDJoiHb5JhCyNftE91C3+ 6974KnoGekKF0PJUxxLkggbzMwzYBegroCdVENYQW3rUaEdMi0bU/Qurm E=; Received: from unknown (HELO ironmsg02-sd.qualcomm.com) ([10.53.140.142]) by alexa-out-sd-01.qualcomm.com with ESMTP; 24 Jan 2022 15:20:42 -0800 X-QCInternal: smtphost Received: from nasanex01b.na.qualcomm.com ([10.46.141.250]) by ironmsg02-sd.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jan 2022 15:20:42 -0800 Received: from collinsd-linux.qualcomm.com (10.80.80.8) by nasanex01b.na.qualcomm.com (10.46.141.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.922.19; Mon, 24 Jan 2022 15:20:41 -0800 From: David Collins To: Mark Brown , Liam Girdwood , Sudeep Holla CC: David Collins , Rob Herring , Cristian Marussi , , , , Subbaraman Narayanamurthy Subject: [RESEND PATCH 2/2] regulator: scmi: add support for registering SCMI regulators by name Date: Mon, 24 Jan 2022 15:20:02 -0800 Message-ID: <916966958cc63e9509f94fb263ad8d3c3ec768da.1639099631.git.quic_collinsd@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nasanex01b.na.qualcomm.com (10.46.141.250) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Message-ID: <20220124232002.wfUraiTMzveo2J9qQVh6VqYeBSbjp7OhZ-_wYC6aLnA@z> Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add support to register SCMI regulator subnodes based on an SCMI Voltage Domain name specified via the 'regulator-name' device tree property. In doing so, make the 'reg' property optional with the constraint that at least one of 'reg' or 'regulator-name' must be specified. If both are specified, then both must match the Voltage Domain data exposed by the SCMI platform. Name based SCMI regulator registration helps ensure that an SCMI agent doesn't need to be aware of the numbering scheme used for Voltage Domains by the SCMI platform. It also ensures that the correct Voltage Domain is selected for a given physical regulator. This cannot be guaranteed with numeric Voltage Domain IDs alone. Signed-off-by: David Collins --- drivers/regulator/scmi-regulator.c | 57 ++++++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 3 deletions(-) diff --git a/drivers/regulator/scmi-regulator.c b/drivers/regulator/scmi-re= gulator.c index 1f02f60ad136..c3287901975e 100644 --- a/drivers/regulator/scmi-regulator.c +++ b/drivers/regulator/scmi-regulator.c @@ -31,6 +31,7 @@ #include #include #include +#include #include =20 static const struct scmi_voltage_proto_ops *voltage_ops; @@ -252,16 +253,66 @@ static int scmi_regulator_common_init(struct scmi_reg= ulator *sreg) return 0; } =20 +static int scmi_regulator_map_name(struct scmi_protocol_handle *ph, + struct scmi_regulator_info *rinfo, + const char *name) +{ + const struct scmi_voltage_info *vinfo; + int i; + + for (i =3D 0; i < rinfo->num_doms; i++) { + vinfo =3D voltage_ops->info_get(ph, i); + if (!vinfo) + continue; + if (!strncmp(vinfo->name, name, sizeof(vinfo->name))) + return i; + } + + return -ENODEV; +} + static int process_scmi_regulator_of_node(struct scmi_device *sdev, struct scmi_protocol_handle *ph, struct device_node *np, struct scmi_regulator_info *rinfo) { u32 dom, ret; + int name_dom; + const char *name; =20 - ret =3D of_property_read_u32(np, "reg", &dom); - if (ret) - return ret; + dom =3D rinfo->num_doms; + if (of_find_property(np, "reg", NULL)) { + ret =3D of_property_read_u32(np, "reg", &dom); + if (ret) + return ret; + + if (dom >=3D rinfo->num_doms) + return -ENODEV; + } + + if (of_find_property(np, "regulator-name", NULL)) { + ret =3D of_property_read_string(np, "regulator-name", &name); + if (ret) + return ret; + + name_dom =3D scmi_regulator_map_name(ph, rinfo, name); + if (name_dom < 0) { + dev_err(&sdev->dev, + "No SCMI Voltage Domain found named %s. Skipping: %s\n", + name, np->full_name); + return name_dom; + } + + if (dom >=3D rinfo->num_doms) + dom =3D name_dom; + + if (name_dom !=3D dom) { + dev_err(&sdev->dev, + "SCMI Voltage Domain %s ID mismatch, %u (DT) !=3D %d (firmware). Skipp= ing: %s\n", + name, dom, name_dom, np->full_name); + return -EINVAL; + } + } =20 if (dom >=3D rinfo->num_doms) return -ENODEV; --=20 2.17.1