From patchwork Fri Dec 10 01:54:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Collins X-Patchwork-Id: 12695554 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BA2A5C433F5 for ; Fri, 10 Dec 2021 01:56:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=B9xsjfJwYUYDGI4ZusBSaiG3gQ5eoNuvGd3cOapqeaI=; b=OKkywTU+/5RgTI tRUyyeKoPZ9tdVcMkCiVjiHCJyT8AfTV65LIJIPL1tajLo9rWG015A2xZJcdm2ml136oediVIZ2dg EVhInUbZuEjJn/M7fMMR9pR+G8DPePA3DosADx1iTYCMVMLUntKZPxL7aEWnLHvRudH0m/xo9Q3pp hYZk66UtWzCIl8OgFotoRMyICVnjoFa2LNOdv9r9w9WKUD5LTv7GpuJB02b3QJ1c3T0SEJObkysRi AU6aymsPPF8fWiZBqsFmZA+nEwCaTbOLUiPWKE2Kk6ok1aydW+sR4GnYDqJ8MNk1Bt3AI7kOfUR4D oKHcY5IInU+nvSOqXasA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mvV86-000cco-1H; Fri, 10 Dec 2021 01:55:22 +0000 Received: from alexa-out-sd-02.qualcomm.com ([199.106.114.39]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mvV81-000cbQ-0h for linux-arm-kernel@lists.infradead.org; Fri, 10 Dec 2021 01:55:18 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1639101317; x=1670637317; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=RcDUI0O2vEznTQ0sfknLbOncw+pzz8jl9FF8nIbdcf0=; b=TnV0/6HFNEVIEnrIrFHDRpTJ97VaN5Mls665TN6z+JrFafq/3JMryxHD BW4uisVxuJhc4gtuQy2DTUC6u3S6kglcUu76lmuQlyJL9AA8lOGK5GMLW EMagIYrt69KUYIuRwRHv95unHzeERdPlir5/KItBNtBmemh4v3qSvY4If A=; Received: from unknown (HELO ironmsg03-sd.qualcomm.com) ([10.53.140.143]) by alexa-out-sd-02.qualcomm.com with ESMTP; 09 Dec 2021 17:55:14 -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; 09 Dec 2021 17:55:13 -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; Thu, 9 Dec 2021 17:55:13 -0800 From: David Collins To: Rob Herring , Sudeep Holla , CC: David Collins , Mark Brown , Liam Girdwood , Cristian Marussi , , , , "Subbaraman Narayanamurthy" Subject: [PATCH 1/2] dt-bindings: firmware: arm, scmi: define support for name based regulators Date: Thu, 9 Dec 2021 17:54:41 -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) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211209_175517_139336_66CA0B87 X-CRM114-Status: GOOD ( 11.26 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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/Documentation/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. patternProperties: - '^regulators@[0-9a-f]+$': + '^regulator.+$': type: object $ref: "../regulator/regulator.yaml#" @@ -164,8 +164,13 @@ properties: maxItems: 1 description: Identifier for the voltage regulator. - required: - - reg + regulator-name: true + + anyOf: + - required: + - reg + - required: + - regulator-name additionalProperties: false From patchwork Fri Dec 10 01:54:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Collins X-Patchwork-Id: 12695556 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 824A8C433EF for ; Fri, 10 Dec 2021 01:57:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=0K06kmd66AUE1sVl+C9mZE1mstYCYU6y+fiH2WDWWi8=; b=jKmzKgOmxzkupm gWED25CFMOlDJeQ49gshF0Qz02+W9zg631VyoHBGrPvUEvjril5VPXIkmufb0bgIiv4CW3vzIRqWX 4jlBwTgShs0uxy7li9ezMIDVMzMSwLFxXaNk/3J8l3tOBHQwd4pEQF7oXhNRiWQtx2vv0Y0c5K57j d1kk3ol7eS8NGZ3U25x5FcQxflbvauux2XHPMb0g/3eM24xXZ+f2ZvfyQqbSDXUk4WLX0V4Jx2eKS bjNJUOKfklRawI9UP/tOxWIDcO5bD9XP9vKQW730EVSnDIWumfKRGZJdjfZtqzgLJZN43vR/5L1Zj XwMEvzQUqxZBd3jFImAQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mvV8P-000cfN-N9; Fri, 10 Dec 2021 01:55:41 +0000 Received: from alexa-out-sd-01.qualcomm.com ([199.106.114.38]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mvV82-000cbP-G8 for linux-arm-kernel@lists.infradead.org; Fri, 10 Dec 2021 01:55:19 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1639101318; x=1670637318; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=lHW3hLnV/NwAlPaJvWLZeYHn/Z13jsz9Dd88QrFizYA=; b=Bk1LtIE5ntlLAu3+fEoDKMTpIZs2qlmjfp1z0WDxe7s4gd1AhYBE/EfT zF3gkvHwj0up2qFP4Ngu5C/MXtMTMVRGFJ+fYjNFL14IJW4QND9Sc+rvO 4kO2e2V+mf6mlgvasBq1r6Dk6O+6essmubAXzhFsKxYGmjbi3Yd+61HYU 0=; Received: from unknown (HELO ironmsg05-sd.qualcomm.com) ([10.53.140.145]) by alexa-out-sd-01.qualcomm.com with ESMTP; 09 Dec 2021 17:55:14 -0800 X-QCInternal: smtphost Received: from nasanex01b.na.qualcomm.com ([10.46.141.250]) by ironmsg05-sd.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Dec 2021 17:55:14 -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; Thu, 9 Dec 2021 17:55:13 -0800 From: David Collins To: Mark Brown , Liam Girdwood , Sudeep Holla CC: David Collins , Rob Herring , Cristian Marussi , , , , Subbaraman Narayanamurthy Subject: [PATCH 2/2] regulator: scmi: add support for registering SCMI regulators by name Date: Thu, 9 Dec 2021 17:54:42 -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) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211209_175518_597098_76153F1E X-CRM114-Status: GOOD ( 17.88 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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-regulator.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 static const struct scmi_voltage_proto_ops *voltage_ops; @@ -252,16 +253,66 @@ static int scmi_regulator_common_init(struct scmi_regulator *sreg) return 0; } +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 = 0; i < rinfo->num_doms; i++) { + vinfo = 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; - ret = of_property_read_u32(np, "reg", &dom); - if (ret) - return ret; + dom = rinfo->num_doms; + if (of_find_property(np, "reg", NULL)) { + ret = of_property_read_u32(np, "reg", &dom); + if (ret) + return ret; + + if (dom >= rinfo->num_doms) + return -ENODEV; + } + + if (of_find_property(np, "regulator-name", NULL)) { + ret = of_property_read_string(np, "regulator-name", &name); + if (ret) + return ret; + + name_dom = 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 >= rinfo->num_doms) + dom = name_dom; + + if (name_dom != dom) { + dev_err(&sdev->dev, + "SCMI Voltage Domain %s ID mismatch, %u (DT) != %d (firmware). Skipping: %s\n", + name, dom, name_dom, np->full_name); + return -EINVAL; + } + } if (dom >= rinfo->num_doms) return -ENODEV;