From patchwork Mon Oct 30 19:41:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artur Weber X-Patchwork-Id: 13440845 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 D6DFAC4332F for ; Mon, 30 Oct 2023 19:42:24 +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:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=u4h040XhgV6CveCEPfBd8s5sJB3pRHZV3pYrl4hMkCA=; b=iiCCuCUptj9W/l 8G2KYwppocZSeDdiW3oeEsVXjCC0GN4kUA6R/CBaxp1Bx+shLbkhyVszhg5tG3eKXtl2AtImRos4p TbNy0QrmkxHkS7UIM7Bl3KRLxEZHNnp7pEPInEFC2+lE67unr/nhalYsObwY07JUik8euioVhj9xg Vefl0pA0ZdMmngfDxje3V0cJjuWCRuLNjx9In9j7smQaTtOJ3cGlEvbIjzMWjGcP68YxuKhLvo3Yy eFEBXOf9QwYOCfStyYR1nxBYVMYqZsf2L4dNRaPdZlGkWA580LAVUx6crNava4E/pYlNCXYwDzbpq PnyE+NM6rfi1cHNPmn4A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qxY9B-003xK8-2q; Mon, 30 Oct 2023 19:42:01 +0000 Received: from mail-lf1-x12c.google.com ([2a00:1450:4864:20::12c]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qxY92-003xG4-1d for linux-arm-kernel@lists.infradead.org; Mon, 30 Oct 2023 19:41:54 +0000 Received: by mail-lf1-x12c.google.com with SMTP id 2adb3069b0e04-50930f126b1so113686e87.3 for ; Mon, 30 Oct 2023 12:41:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698694909; x=1699299709; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=swATsRm/D/rD5LWbhxOgcaqNC48PvNHzrc6mwlQlkRo=; b=OtDhxkDFzFqLRLjK4Ocn0kW+r96KrTG1utvg6nHHWK3/Um1Dv/YFYCKz+Q7A/cM2Uo LFZ+JPjPOj9YPTvyYZt8zbfkI7a1uZM0Xogv6icLvpwd82khbjJAPiuQglzgh+/4AXcf 3vLWm0kMdLKI2VtazeTZXdJSKEyFgByvB4XwKeiu7MQ1hf8LEdjaCduYPNQQAD2C9Wxs IUaXHEwIEEf5HJBnj9lLqiQNiL7oXxu/MhcMHE5KFjtwfUwhq01ghrBeOlyq1twyvdJs qdh2l94VF0L1EOuuS9MLB2vMvK3WpyGkRyMp+vSPSU2QVILySPtxcP8X8ANsoB9nRl1l cR8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698694909; x=1699299709; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=swATsRm/D/rD5LWbhxOgcaqNC48PvNHzrc6mwlQlkRo=; b=tATp/v6ae4G5R2QyE5p5dXHFj84CJI7ghgPnVDR6yYQdqMdPjmUttjmFe+ZdofS1Mp OfvWTsCMJfjGeRorzqtq/JHdIwlBb/q4qZ+4niEBK2I9xmaFOYuJKcYaPiSHwRlajLeH QQJYZju5bThWS6NQQPkwnMlAKCVi5uP7MfDBXXr+BN5kZ6Z2Dc4N17uUb9gFhO0G2oQp bfOrXhVzfLP8QY9gqAZCkSyHfSY+zjwB0eO8fvy7D/DeYdYO6qj9WzPtvUNIdLMQbWm/ 4uEEqqK2oK5++yRAbLdvU0GvAreXkbudMGL4uLJhzR7l+QzeWiyTO5ZYNd0vx7isE/Qj /98A== X-Gm-Message-State: AOJu0YxCYJxO3eY3CRf/RuiQyq2uLydNz3/Y5ApBr8Ald2qQX05oXC6c Gw38ved5rQ8zTBDK+BcgUUE= X-Google-Smtp-Source: AGHT+IHDjgogZloqvF0vTFY93o5pdCKouALhCREZfA40vWUlSo3ELseYviRwZ7oOCxUJTw0ha3c1Mw== X-Received: by 2002:a05:6512:1109:b0:4f8:714e:27a8 with SMTP id l9-20020a056512110900b004f8714e27a8mr9469763lfg.0.1698694909024; Mon, 30 Oct 2023 12:41:49 -0700 (PDT) Received: from hex.my.domain (83.11.208.51.ipv4.supernova.orange.pl. [83.11.208.51]) by smtp.gmail.com with ESMTPSA id m10-20020ac2428a000000b005057184ae62sm1527802lfh.96.2023.10.30.12.41.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 12:41:48 -0700 (PDT) From: Artur Weber Date: Mon, 30 Oct 2023 20:41:43 +0100 Subject: [PATCH v2 1/6] dt-bindings: mfd: brcm,bcm59056: Convert to YAML MIME-Version: 1.0 Message-Id: <20231030-bcm59054-v2-1-5fa4011aa5ba@gmail.com> References: <20231030-bcm59054-v2-0-5fa4011aa5ba@gmail.com> In-Reply-To: <20231030-bcm59054-v2-0-5fa4011aa5ba@gmail.com> To: Lee Jones , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Florian Fainelli , Ray Jui , Scott Branden , Broadcom internal kernel review list , Liam Girdwood , Mark Brown Cc: Stanislav Jakubek , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Artur Weber X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1698694906; l=4521; i=aweber.kernel@gmail.com; s=20231030; h=from:subject:message-id; bh=Y62BQBGtAcPv02Fu046rbEKVHmHWcxt/VeMRr4coqwE=; b=nx2q3J0EGQzhBlh4CNujQQbnjJb61qCJNAkQKsR4ky9V7rmn4T7KziV5xY9FTTpXm56BySP/+ MJ52RAUBHWrADwtKPq44YGhq1lav7wc3rBoleVHhkWMeAupfSYnw7G0 X-Developer-Key: i=aweber.kernel@gmail.com; a=ed25519; pk=RhDBfWbJEHqDibXbhNEBAnc9FMkyznGxX/hwfhL8bv8= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231030_124152_546427_21878A65 X-CRM114-Status: GOOD ( 15.67 ) 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 Convert devicetree bindings for the Broadcom BCM59056 PMU MFD from TXT to YAML format. This patch does not change any functionality; the bindings remain the same. Signed-off-by: Artur Weber --- .../devicetree/bindings/mfd/brcm,bcm59056.txt | 39 ---------- .../devicetree/bindings/mfd/brcm,bcm59056.yaml | 91 ++++++++++++++++++++++ 2 files changed, 91 insertions(+), 39 deletions(-) diff --git a/Documentation/devicetree/bindings/mfd/brcm,bcm59056.txt b/Documentation/devicetree/bindings/mfd/brcm,bcm59056.txt deleted file mode 100644 index be51a15e05f9..000000000000 --- a/Documentation/devicetree/bindings/mfd/brcm,bcm59056.txt +++ /dev/null @@ -1,39 +0,0 @@ -------------------------------- -BCM590xx Power Management Units -------------------------------- - -Required properties: -- compatible: "brcm,bcm59056" -- reg: I2C slave address -- interrupts: interrupt for the PMU. Generic interrupt client node bindings - are described in interrupt-controller/interrupts.txt - ------------------- -Voltage Regulators ------------------- - -Optional child nodes: -- regulators: container node for regulators following the generic - regulator binding in regulator/regulator.txt - - The valid regulator node names for BCM59056 are: - rfldo, camldo1, camldo2, simldo1, simldo2, sdldo, sdxldo, - mmcldo1, mmcldo2, audldo, micldo, usbldo, vibldo, - csr, iosr1, iosr2, msr, sdsr1, sdsr2, vsr, - gpldo1, gpldo2, gpldo3, gpldo4, gpldo5, gpldo6, - vbus - -Example: - pmu: bcm59056@8 { - compatible = "brcm,bcm59056"; - reg = <0x08>; - interrupts = ; - regulators { - rfldo_reg: rfldo { - regulator-min-microvolt = <1200000>; - regulator-max-microvolt = <3300000>; - }; - - ... - }; - }; diff --git a/Documentation/devicetree/bindings/mfd/brcm,bcm59056.yaml b/Documentation/devicetree/bindings/mfd/brcm,bcm59056.yaml new file mode 100644 index 000000000000..6d6acc9fd312 --- /dev/null +++ b/Documentation/devicetree/bindings/mfd/brcm,bcm59056.yaml @@ -0,0 +1,91 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/mfd/brcm,bcm59056.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: BCM590xx Power Management Unit MFD + +maintainers: + - Artur Weber + +properties: + compatible: + enum: + - "brcm,bcm59056" + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + regulators: + type: object + description: Container node for regulators. + + # The valid regulator node names for BCM59056 are: + # rfldo, camldo1, camldo2, simldo1, simldo2, sdldo, sdxldo, + # mmcldo1, mmcldo2, audldo, micldo, usbldo, vibldo, + # csr, iosr1, iosr2, msr, sdsr1, sdsr2, vsr, + # gpldo1, gpldo2, gpldo3, gpldo4, gpldo5, gpldo6, + # vbus + patternProperties: + "^(cam|sim|mmc)ldo[1-2]$": + type: object + $ref: /schemas/regulator/regulator.yaml# + unevaluatedProperties: false + + "^(rf|sd|sdx|aud|mic|usb|vib)ldo$": + type: object + $ref: /schemas/regulator/regulator.yaml# + unevaluatedProperties: false + + "^(c|m|v)sr$": + type: object + $ref: /schemas/regulator/regulator.yaml# + unevaluatedProperties: false + + "^(io|sd)sr[1-2]$": + type: object + $ref: /schemas/regulator/regulator.yaml# + unevaluatedProperties: false + + "^gpldo[1-6]$": + type: object + $ref: /schemas/regulator/regulator.yaml# + unevaluatedProperties: false + + properties: + "vbus": + type: object + $ref: /schemas/regulator/regulator.yaml# + unevaluatedProperties: false + +required: + - compatible + - reg + - interrupts + +additionalProperties: false + +examples: + - | + #include + + i2c { + #address-cells = <1>; + #size-cells = <0>; + + pmu: bcm59056@8 { + compatible = "brcm,bcm59056"; + reg = <0x08>; + interrupts = <0 215 IRQ_TYPE_LEVEL_HIGH>; + regulators { + rfldo_reg: rfldo { + regulator-min-microvolt = <1200000>; + regulator-max-microvolt = <3300000>; + }; + }; + }; + }; From patchwork Mon Oct 30 19:41:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artur Weber X-Patchwork-Id: 13440846 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 914BDC4332F for ; Mon, 30 Oct 2023 19:42:27 +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:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=90ZcLYxMkYAYXLKJu+u1tzTw6HlIn1Fa4HDIqZjS0YY=; b=lq9FUXbWPhzOF1 QNeX3oGLMbP5E8PMAAuToJtG9+ro7FzliFPDm5f1GKOXYsdLoq1MweDsSoOtrz/SwapfkqMPZqZ5E 002KTukGEhJ8G8Z2zBXXJtR1Xtze8VtGl8+IMWuio2kVN35fGOdnMbKOJkawwruY67nHZfxDc3zT8 Ui2+CzcuE0QtQhyQfQtqs3QfPL0O/PInp7RDsselidniDSaq9K5N3mXLzh9BbisiFJ41S7cagaa5H +c953IsyJyfwVOqlbJbLSP7pI95QsipojWzt+pdjPYbCBwNC867Wnz41nrhemBdMThVmBbO7xP1HN lw57kOXY11ZHq5y+datw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qxY9C-003xKl-2r; Mon, 30 Oct 2023 19:42:02 +0000 Received: from mail-lf1-x12e.google.com ([2a00:1450:4864:20::12e]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qxY93-003xGN-1o for linux-arm-kernel@lists.infradead.org; Mon, 30 Oct 2023 19:41:55 +0000 Received: by mail-lf1-x12e.google.com with SMTP id 2adb3069b0e04-507e85ebf50so6833877e87.1 for ; Mon, 30 Oct 2023 12:41:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698694910; x=1699299710; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=rsTszCSXFvrVoDKYOUlX0fXU0RZFKqac+kUpQnY46h0=; b=mVnibZk5I4mxTgKP/FryZLQQo3yr3gjqtUF1if+TESwMgoNC1xLryQIPx27ABD1E6n hsK2bBo2fXEc2J2C0117GL/QfEN0O2yurOkQ2vUg90WSX1dRxi7gbk/2cvWOuQJIhdHc ZIO4iFwQIfOjSwgcPgZWeGTQD9yMIVJwVrW6R9PIm2JV29D1H454fp8UIzm8TpoqGqTk MNw3fP8Asn+M9Scr8aLkB/t/HeXzAC52P4n/jBnhYrQ/7ISGfA58XBGox9SjuUQwxenP J7QCdsq0OiaFZqqYihLsi7WfVDdxtXMI9MoeTZo7xY722roXpSoqd8n7VhbV1XYoS4HA AhCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698694910; x=1699299710; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rsTszCSXFvrVoDKYOUlX0fXU0RZFKqac+kUpQnY46h0=; b=jROjH13MFYMjW31pM1ZzjC6mzMTfesFoHZzlMFuq47V+/ZbAqJPh5b1gUyJt6wswyR KDappMfQySG4mQrf2T+e1LcvEdYFOsOYONl+vujvLXWmNBCyxkrZmsl6/VV0hPATgwqk ApWJVI7vzH61UvdY3SQZQrXylxnHsaVPIqsnLHGHX7fQFFOw7QaBgyqtmtmCeNWSvowu fVyegNvaLlAepMYISBXU0LXSUy5mSC+EVaivX9KWYeDMktEz4o6bCakTnENH5kJIPDOd l5EppezUKFrker3CQzuAYbBvUS97VHzROWZJCFdQSo07WMX+5ggF7Wh3qCzI5CW6l7Ou GzpA== X-Gm-Message-State: AOJu0YzZjTUYvBIGfe2vPTAVt8TT44oLpb7VrmQETzz3tPaRZNT8Ns1f EABj7kNAariKXrmRt8YsUm8= X-Google-Smtp-Source: AGHT+IGYQoyMZ2H8yEcSdfZq8bBvetLhpTMgf6kX8yku45ElmdjlVHmmTYqp+in7EJYqqhmJszyYjQ== X-Received: by 2002:a05:6512:3683:b0:507:ba28:1bc5 with SMTP id d3-20020a056512368300b00507ba281bc5mr6645678lfs.3.1698694910355; Mon, 30 Oct 2023 12:41:50 -0700 (PDT) Received: from hex.my.domain (83.11.208.51.ipv4.supernova.orange.pl. [83.11.208.51]) by smtp.gmail.com with ESMTPSA id m10-20020ac2428a000000b005057184ae62sm1527802lfh.96.2023.10.30.12.41.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 12:41:50 -0700 (PDT) From: Artur Weber Date: Mon, 30 Oct 2023 20:41:44 +0100 Subject: [PATCH v2 2/6] dt-bindings: mfd: brcm,bcm59056: Add compatible for BCM59054 MIME-Version: 1.0 Message-Id: <20231030-bcm59054-v2-2-5fa4011aa5ba@gmail.com> References: <20231030-bcm59054-v2-0-5fa4011aa5ba@gmail.com> In-Reply-To: <20231030-bcm59054-v2-0-5fa4011aa5ba@gmail.com> To: Lee Jones , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Florian Fainelli , Ray Jui , Scott Branden , Broadcom internal kernel review list , Liam Girdwood , Mark Brown Cc: Stanislav Jakubek , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Artur Weber X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1698694906; l=4952; i=aweber.kernel@gmail.com; s=20231030; h=from:subject:message-id; bh=J5qoqMtHdHEbtDpozL70617xHH15jYDWQN+WwVZOQIk=; b=LHx9ucpq3SWxJ6vasg2DPvwm7bIGrPH0ju2dTB62mEmMJUxxHVvKhNbmxUw6WbgWB7NDaVEsO 8Iyv36IpHN6Ba0VZxh/EHiNyjt6gM7KznFdrkZp6z73J+GV5eu0g4c+ X-Developer-Key: i=aweber.kernel@gmail.com; a=ed25519; pk=RhDBfWbJEHqDibXbhNEBAnc9FMkyznGxX/hwfhL8bv8= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231030_124153_608805_FB626A01 X-CRM114-Status: GOOD ( 10.98 ) 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 The BCM59054 MFD is fairly similar to the BCM59056, and will use the same driver. Add compatible and specify the allowed regulator nodes. Signed-off-by: Artur Weber --- .../devicetree/bindings/mfd/brcm,bcm59056.yaml | 125 +++++++++++++++------ 1 file changed, 88 insertions(+), 37 deletions(-) diff --git a/Documentation/devicetree/bindings/mfd/brcm,bcm59056.yaml b/Documentation/devicetree/bindings/mfd/brcm,bcm59056.yaml index 6d6acc9fd312..5b5044867eca 100644 --- a/Documentation/devicetree/bindings/mfd/brcm,bcm59056.yaml +++ b/Documentation/devicetree/bindings/mfd/brcm,bcm59056.yaml @@ -12,6 +12,7 @@ maintainers: properties: compatible: enum: + - "brcm,bcm59054" - "brcm,bcm59056" reg: @@ -24,43 +25,93 @@ properties: type: object description: Container node for regulators. - # The valid regulator node names for BCM59056 are: - # rfldo, camldo1, camldo2, simldo1, simldo2, sdldo, sdxldo, - # mmcldo1, mmcldo2, audldo, micldo, usbldo, vibldo, - # csr, iosr1, iosr2, msr, sdsr1, sdsr2, vsr, - # gpldo1, gpldo2, gpldo3, gpldo4, gpldo5, gpldo6, - # vbus - patternProperties: - "^(cam|sim|mmc)ldo[1-2]$": - type: object - $ref: /schemas/regulator/regulator.yaml# - unevaluatedProperties: false - - "^(rf|sd|sdx|aud|mic|usb|vib)ldo$": - type: object - $ref: /schemas/regulator/regulator.yaml# - unevaluatedProperties: false - - "^(c|m|v)sr$": - type: object - $ref: /schemas/regulator/regulator.yaml# - unevaluatedProperties: false - - "^(io|sd)sr[1-2]$": - type: object - $ref: /schemas/regulator/regulator.yaml# - unevaluatedProperties: false - - "^gpldo[1-6]$": - type: object - $ref: /schemas/regulator/regulator.yaml# - unevaluatedProperties: false - - properties: - "vbus": - type: object - $ref: /schemas/regulator/regulator.yaml# - unevaluatedProperties: false +allOf: + - if: + properties: + compatible: + contains: + const: "brcm,bcm59056" + then: + properties: + regulators: + # The valid regulator node names for BCM59056 are: + # rfldo, camldo1, camldo2, simldo1, simldo2, sdldo, sdxldo, + # mmcldo1, mmcldo2, audldo, micldo, usbldo, vibldo, + # csr, iosr1, iosr2, msr, sdsr1, sdsr2, vsr, + # gpldo1, gpldo2, gpldo3, gpldo4, gpldo5, gpldo6, + # vbus + patternProperties: + "^(cam|sim|mmc)ldo[1-2]$": + type: object + $ref: /schemas/regulator/regulator.yaml# + + "^(rf|sd|sdx|aud|mic|usb|vib)ldo$": + type: object + $ref: /schemas/regulator/regulator.yaml# + + "^(c|m|v)sr$": + type: object + $ref: /schemas/regulator/regulator.yaml# + + "^(io|sd)sr[1-2]$": + type: object + $ref: /schemas/regulator/regulator.yaml# + + "^gpldo[1-6]$": + type: object + $ref: /schemas/regulator/regulator.yaml# + + properties: + "vbus": + type: object + $ref: /schemas/regulator/regulator.yaml# + + additionalProperties: false + + - if: + properties: + compatible: + contains: + const: "brcm,bcm59054" + then: + properties: + regulators: + # The valid regulator node names for BCM59054 are: + # rfldo, camldo1, camldo2, simldo1, simldo2, sdldo, sdxldo, + # mmcldo1, mmcldo2, audldo, micldo, usbldo, vibldo, + # csr, iosr1, iosr2, mmsr, sdsr1, sdsr2, vsr, + # gpldo1, gpldo2, gpldo3, tcxldo, lvldo1, lvldo2 + patternProperties: + "^(cam|sim|mmc)ldo[1-2]$": + type: object + $ref: /schemas/regulator/regulator.yaml# + + "^(rf|sd|sdx|aud|mic|usb|vib|tcx)ldo$": + type: object + $ref: /schemas/regulator/regulator.yaml# + + "^(c|mm|v)sr$": + type: object + $ref: /schemas/regulator/regulator.yaml# + + "^(io|sd)sr[1-2]$": + type: object + $ref: /schemas/regulator/regulator.yaml# + + "^gpldo[1-3]$": + type: object + $ref: /schemas/regulator/regulator.yaml# + + "^lvldo[1-2]$": + type: object + $ref: /schemas/regulator/regulator.yaml# + + properties: + "vbus": + type: object + $ref: /schemas/regulator/regulator.yaml# + + additionalProperties: false required: - compatible From patchwork Mon Oct 30 19:41:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artur Weber X-Patchwork-Id: 13440848 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 04B04C4332F for ; Mon, 30 Oct 2023 19:42:30 +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:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=aVqCG5XXj4wxnRjUT5pXtkYSKq9h5zQu896WdgmdEQo=; b=VwPnfThX38wZhQ cQUxXs3UbKi//qO39pQ54ku6TQHeedqoBX1isUcEFOs+FxAhdCs3zA36NQuDgS9XKYG21tpz7NGRY 4b7fQ5k84t/CTU9+eGbKub536y7IL8TVWT8o8TxJyXkGWX/ZrmrM9N3NJU/Ek/8kutxHUyU1byv3r 7UZtdeo6zuKNn5TCvSfZVbbM8f6CigyES4gDyEstddciVwUMkv88caH+Fz1OPVb5PbMf/LMiRrTXN vmm4XGemY40sEG3oo1XZmtJZib/MBYA3QFlYY+7w42ggjkHaEyYlsCJYvMsCzxwCljv056/MRaGqr tU/gvug4TLIfQBZP01/w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qxY9C-003xKR-1F; Mon, 30 Oct 2023 19:42:02 +0000 Received: from mail-lf1-x12f.google.com ([2a00:1450:4864:20::12f]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qxY93-003xGT-1M for linux-arm-kernel@lists.infradead.org; Mon, 30 Oct 2023 19:41:54 +0000 Received: by mail-lf1-x12f.google.com with SMTP id 2adb3069b0e04-507adc3381cso6998550e87.3 for ; Mon, 30 Oct 2023 12:41:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698694912; x=1699299712; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=3545GZ4rTilRPlMK6OENQjdsYfS2hQ9SURsOYUBvQmk=; b=IIiw3bnukGdQA32TQMQBdU1RtVL8uLC7xvC00uCIcHqN+NUR9pD6o9W7UDRL71szgl 6HKxU1RV2HpjvP2IMIv1wKV63ox+SmUK4oxzwECrPV6vUDUsrmGFdUCWxQKIj892ET7X 5JIDYdSTBFgi7hLP2YsLuL6hOEmkir4TNDXbRuKpFBP9TeTyjKm9ha8CI39OIJiSv98s fLqUVHi4XYb/d+hVC+TBb/1s+nY2OpRRl1dC/j2wxtUOHBfEg1Lf5MzKPChMfiLG8kbr QdMY25PHYCG9qsrE6AAxefjy5c4dk9PuiN65KoGTVcp+7NSs4UnJIw/EsYv/fZ+PpuC6 qwbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698694912; x=1699299712; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3545GZ4rTilRPlMK6OENQjdsYfS2hQ9SURsOYUBvQmk=; b=mMZJ8qK51mZtye8y79ii7gdVLy8ul4KvAtKvcL1rlF4f1J2YbZy4l0Yvw2n5c/FuWc tnyx0WTAOCe7DSrWFQl7XLxbEf8WLuPM27o3Evyy833mmx2ags1arZnuszvLHnzXDVGn c1ifUjwlQDUodyeAHMXidH71nBcPmjcGgiRhm4E6xMnsYCsZGPM7ZOQaQD1gjcEdyjKC rAFK6g2unHn2/lOwmAUzVmCNWcQ+Ytm3lQIyuEQysahzUC8+f/bxKvrSyo/N8MYfqEro 10Mql8W3inSxsK6sXKmFkfSeU7Aeh7/3Ev3q0qFRbHrPmEgUkX8bNVyoADk5jmJhP4/I T6+g== X-Gm-Message-State: AOJu0YwV+7Js7cWNCZ9ntXXLFQtdhBiFtLfYICj1DGnlCb3hUfDaBvHt KVK04shiVs0yIeDvsBI5jUM= X-Google-Smtp-Source: AGHT+IGWswxESjDHXYLTl5Cpnzaj8IEwQ99AVQmntdpTDHIAk6Pqzn4ikpab+YANcim3rmmp2FIGqA== X-Received: by 2002:a19:f80e:0:b0:500:7f71:e46b with SMTP id a14-20020a19f80e000000b005007f71e46bmr8209208lff.1.1698694911772; Mon, 30 Oct 2023 12:41:51 -0700 (PDT) Received: from hex.my.domain (83.11.208.51.ipv4.supernova.orange.pl. [83.11.208.51]) by smtp.gmail.com with ESMTPSA id m10-20020ac2428a000000b005057184ae62sm1527802lfh.96.2023.10.30.12.41.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 12:41:51 -0700 (PDT) From: Artur Weber Date: Mon, 30 Oct 2023 20:41:45 +0100 Subject: [PATCH v2 3/6] ARM: dts: Drop DTS for BCM59056 PMIC MIME-Version: 1.0 Message-Id: <20231030-bcm59054-v2-3-5fa4011aa5ba@gmail.com> References: <20231030-bcm59054-v2-0-5fa4011aa5ba@gmail.com> In-Reply-To: <20231030-bcm59054-v2-0-5fa4011aa5ba@gmail.com> To: Lee Jones , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Florian Fainelli , Ray Jui , Scott Branden , Broadcom internal kernel review list , Liam Girdwood , Mark Brown Cc: Stanislav Jakubek , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Artur Weber X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1698694906; l=3995; i=aweber.kernel@gmail.com; s=20231030; h=from:subject:message-id; bh=DBtpuYO/zr95rgnLU/rQbbV2xjIrUTq43L7BHBrPA9U=; b=HDu0zf8GfviM5rEV5zkbcvF2LUTvgWofykCLZFC+mAUEKB0AesBtIFkSJQRg/3R/1a1/uY2vW 2Lnqvief9jhAomuborD/4Csi+k8a/E1A0MHcWibrdbGm9siphhSAZMh X-Developer-Key: i=aweber.kernel@gmail.com; a=ed25519; pk=RhDBfWbJEHqDibXbhNEBAnc9FMkyznGxX/hwfhL8bv8= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231030_124153_456974_7F576E42 X-CRM114-Status: GOOD ( 13.72 ) 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 The BCM59056 PMIC has its own separate DTSI, meant to be included in a DTS file after defining the pmu node on some I2C bus. I'm not aware of many other devices that do this, and it seems very unintuitive. Drop the DTS in favor of adding the BCM59056 PMIC node directly into the device DTS files. Signed-off-by: Artur Weber --- arch/arm/boot/dts/broadcom/bcm28155-ap.dts | 68 +++++++++++----------- arch/arm/boot/dts/broadcom/bcm59056.dtsi | 91 ------------------------------ 2 files changed, 32 insertions(+), 127 deletions(-) diff --git a/arch/arm/boot/dts/broadcom/bcm28155-ap.dts b/arch/arm/boot/dts/broadcom/bcm28155-ap.dts index 2f3634545e64..cefaa9a3c45c 100644 --- a/arch/arm/boot/dts/broadcom/bcm28155-ap.dts +++ b/arch/arm/boot/dts/broadcom/bcm28155-ap.dts @@ -37,7 +37,39 @@ &pmu_bsc { status = "okay"; pmu: pmu@8 { + compatible = "brcm,bcm59056"; + interrupts = ; reg = <0x08>; + + regulators { + camldo1_reg: camldo1 { + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + regulator-always-on; + }; + + sdldo_reg: sdldo { + regulator-min-microvolt = <3000000>; + regulator-max-microvolt = <3000000>; + }; + + sdxldo_reg: sdxldo { + regulator-min-microvolt = <2700000>; + regulator-max-microvolt = <3300000>; + }; + + usbldo_reg: usbldo { + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + regulator-always-on; + }; + + iosr1_reg: iosr1 { + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + regulator-always-on; + }; + }; }; }; @@ -74,39 +106,3 @@ &usbotg { &usbphy { status = "okay"; }; - -#include "bcm59056.dtsi" - -&pmu { - compatible = "brcm,bcm59056"; - interrupts = ; - regulators { - camldo1_reg: camldo1 { - regulator-min-microvolt = <3300000>; - regulator-max-microvolt = <3300000>; - regulator-always-on; - }; - - sdldo_reg: sdldo { - regulator-min-microvolt = <3000000>; - regulator-max-microvolt = <3000000>; - }; - - sdxldo_reg: sdxldo { - regulator-min-microvolt = <2700000>; - regulator-max-microvolt = <3300000>; - }; - - usbldo_reg: usbldo { - regulator-min-microvolt = <3300000>; - regulator-max-microvolt = <3300000>; - regulator-always-on; - }; - - iosr1_reg: iosr1 { - regulator-min-microvolt = <1800000>; - regulator-max-microvolt = <1800000>; - regulator-always-on; - }; - }; -}; diff --git a/arch/arm/boot/dts/broadcom/bcm59056.dtsi b/arch/arm/boot/dts/broadcom/bcm59056.dtsi deleted file mode 100644 index a9bb7ad81378..000000000000 --- a/arch/arm/boot/dts/broadcom/bcm59056.dtsi +++ /dev/null @@ -1,91 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/* -* Copyright 2014 Linaro Limited -* Author: Matt Porter -*/ - -&pmu { - compatible = "brcm,bcm59056"; - regulators { - rfldo_reg: rfldo { - }; - - camldo1_reg: camldo1 { - }; - - camldo2_reg: camldo2 { - }; - - simldo1_reg: simldo1 { - }; - - simldo2_reg: simldo2 { - }; - - sdldo_reg: sdldo { - }; - - sdxldo_reg: sdxldo { - }; - - mmcldo1_reg: mmcldo1 { - }; - - mmcldo2_reg: mmcldo2 { - }; - - audldo_reg: audldo { - }; - - micldo_reg: micldo { - }; - - usbldo_reg: usbldo { - }; - - vibldo_reg: vibldo { - }; - - csr_reg: csr { - }; - - iosr1_reg: iosr1 { - }; - - iosr2_reg: iosr2 { - }; - - msr_reg: msr { - }; - - sdsr1_reg: sdsr1 { - }; - - sdsr2_reg: sdsr2 { - }; - - vsr_reg: vsr { - }; - - gpldo1_reg: gpldo1 { - }; - - gpldo2_reg: gpldo2 { - }; - - gpldo3_reg: gpldo3 { - }; - - gpldo4_reg: gpldo4 { - }; - - gpldo5_reg: gpldo5 { - }; - - gpldo6_reg: gpldo6 { - }; - - vbus_reg: vbus { - }; - }; -}; From patchwork Mon Oct 30 19:41:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artur Weber X-Patchwork-Id: 13440849 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 41944C00142 for ; Mon, 30 Oct 2023 19:42:31 +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:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=06Ylylavdhw0cRhufyCs7lbPpONTAry4WoDPoHcEgD0=; b=MopfcyeCy7cSjv YMnAzuKesT7+bFUnJ/9ovqDjYIi80uigEvuuU7tLDOx23R40yU0TAuDQLIn7dz5eSyf30RsiZmxcu T438cCnAlyHtUBk1lvauBiAUctrtupUz5KbNVTvImENcL4fL0HECdUEobxRD6t2+a6wGuWDGGv4pP 03rgx//ASHoh32KKEsZ+f9lMQ86C1QMTqRV8vkv/426O4T1qhiqucRBckd9V6hbNooo1viyUSwEvv +rV4NJKummwf1Oat1uYydNQUZo/SvJD1ywHEmiJyg0nfHikLqyfXIfo03tUWq00rrGkO+PzZNEncf we18fQ/l51+gcPYBnvdA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qxY9D-003xLE-1K; Mon, 30 Oct 2023 19:42:03 +0000 Received: from mail-lf1-x130.google.com ([2a00:1450:4864:20::130]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qxY97-003xHC-1I for linux-arm-kernel@lists.infradead.org; Mon, 30 Oct 2023 19:41:59 +0000 Received: by mail-lf1-x130.google.com with SMTP id 2adb3069b0e04-507e85ebf50so6833935e87.1 for ; Mon, 30 Oct 2023 12:41:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698694913; x=1699299713; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=MVGWdNdmpu8vSibrYJC/RZxDG0iblOVJzHPyX+FabSU=; b=VTc2Bm66zeu7VMhnba934MJuAMnYkPtdiaYlT2VVRZcnFSC+Q6HvugmzauC7PHSamG eBGlHHRnSKHz3ZRXgU81smm691WtItMAY/n1KBK+BhmgMWsia4WTYwHnl59MYLfIFOuj UiGWZkadOQLHiKZTUBBqrL1w2UGrzgQ237eHxK9R25H2xHJxO9EvhYHC6qtlwEn+W5fO fSrhDsqrkZIYXGE9XSguoB9kEKmNjJFruwDr8cQ4yuWXyldCWHMxP5ah3sjHtpCR/tUH cCGheG9b41nV+ldj0mYCf6rMAh5v6Ec+gDDAnLCmMmuXHYr1arRP2ytCc01RsErnZo2n 5dxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698694913; x=1699299713; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MVGWdNdmpu8vSibrYJC/RZxDG0iblOVJzHPyX+FabSU=; b=wx+wgt+8L1D14mM8K5sxfw4y9g8WcHZ8t8VH6RGTuYZTXiOEgMuBiWD+rkObizCG8v hnDeVPvcZIzjkIyawcwb/wryEC3ROSKsMsbCVtsbSmMkH9bdG2rXccNy8zO2AqZJ0Csc I9ya7zgR5s6zGd0dKg2yq1/DD6em9EDPPfb6JF4LNSvqhh+qAdL2qDVP7Evj4vjEfvHA 7Y4gnHHH4ZiXEwLBI9njOu/fX7UD6/tdatBxpzX9igOcie8O3wZx8yDf+hKj1Ko8QCld B/Ic+vJJW7XrJeB3BLcUrLnCSZ8Vi4Ga03Zj2r/gwv6oHxTQntJFdmPrensduNLpi041 ttAA== X-Gm-Message-State: AOJu0Yy6u9+cOcOv1H4Ra0dJ7/baA55zVLMQyloReyeGd/pTxhFtwQZy /uiETLS0L6I50si//04MDDo= X-Google-Smtp-Source: AGHT+IG2fWFrzQ7B0lInjhmgmbToxPfdp7+yDm6KzfqHnJxQ2uEdEnXUVAgy07VZr7nveCyziVdYyA== X-Received: by 2002:ac2:55aa:0:b0:505:98a8:fa39 with SMTP id y10-20020ac255aa000000b0050598a8fa39mr7131537lfg.18.1698694913087; Mon, 30 Oct 2023 12:41:53 -0700 (PDT) Received: from hex.my.domain (83.11.208.51.ipv4.supernova.orange.pl. [83.11.208.51]) by smtp.gmail.com with ESMTPSA id m10-20020ac2428a000000b005057184ae62sm1527802lfh.96.2023.10.30.12.41.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 12:41:52 -0700 (PDT) From: Artur Weber Date: Mon, 30 Oct 2023 20:41:46 +0100 Subject: [PATCH v2 4/6] mfd: bcm590xx: Add compatible for BCM59054 MIME-Version: 1.0 Message-Id: <20231030-bcm59054-v2-4-5fa4011aa5ba@gmail.com> References: <20231030-bcm59054-v2-0-5fa4011aa5ba@gmail.com> In-Reply-To: <20231030-bcm59054-v2-0-5fa4011aa5ba@gmail.com> To: Lee Jones , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Florian Fainelli , Ray Jui , Scott Branden , Broadcom internal kernel review list , Liam Girdwood , Mark Brown Cc: Stanislav Jakubek , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Artur Weber X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1698694906; l=1936; i=aweber.kernel@gmail.com; s=20231030; h=from:subject:message-id; bh=GaZAs1pHOm9g/5MXQbdGtce8n4JeiRhmO5EZ2BKjVhk=; b=AD/A0qChov9/UuR+aIEJvoDFuKb6QmCISZGXUmJiKCiDvIrqzPckzH/r1BjXFz0+orh2oldKb oaNuSd6xQuBALsUkb2Zqe1I8ORVi7y7c2fmGpP6RT8VIQpNkC9hgNzX X-Developer-Key: i=aweber.kernel@gmail.com; a=ed25519; pk=RhDBfWbJEHqDibXbhNEBAnc9FMkyznGxX/hwfhL8bv8= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231030_124157_441953_1FE55604 X-CRM114-Status: GOOD ( 18.62 ) 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 The BCM59056 supported by the bcm590xx driver is similar to the BCM59054 MFD. Add a compatible for it in the driver, in preparation for adding support for this chip in the bcm590xx regulator driver. Signed-off-by: Artur Weber --- drivers/mfd/bcm590xx.c | 5 ++++- include/linux/mfd/bcm590xx.h | 7 +++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/mfd/bcm590xx.c b/drivers/mfd/bcm590xx.c index 92eede9a5e61..f5c5fa97ca9a 100644 --- a/drivers/mfd/bcm590xx.c +++ b/drivers/mfd/bcm590xx.c @@ -50,6 +50,8 @@ static int bcm590xx_i2c_probe(struct i2c_client *i2c_pri) bcm590xx->dev = &i2c_pri->dev; bcm590xx->i2c_pri = i2c_pri; + bcm590xx->device_type = (unsigned int)of_device_get_match_data(bcm590xx->dev); + bcm590xx->regmap_pri = devm_regmap_init_i2c(i2c_pri, &bcm590xx_regmap_config_pri); if (IS_ERR(bcm590xx->regmap_pri)) { @@ -91,7 +93,8 @@ static int bcm590xx_i2c_probe(struct i2c_client *i2c_pri) } static const struct of_device_id bcm590xx_of_match[] = { - { .compatible = "brcm,bcm59056" }, + { .compatible = "brcm,bcm59054", .data = (void *)BCM59054_TYPE }, + { .compatible = "brcm,bcm59056", .data = (void *)BCM59056_TYPE }, { } }; MODULE_DEVICE_TABLE(of, bcm590xx_of_match); diff --git a/include/linux/mfd/bcm590xx.h b/include/linux/mfd/bcm590xx.h index 6b8791da6119..ed0d8be6387c 100644 --- a/include/linux/mfd/bcm590xx.h +++ b/include/linux/mfd/bcm590xx.h @@ -13,12 +13,19 @@ #include #include +/* device types */ +enum { + BCM59054_TYPE, + BCM59056_TYPE, +}; + /* max register address */ #define BCM590XX_MAX_REGISTER_PRI 0xe7 #define BCM590XX_MAX_REGISTER_SEC 0xf0 struct bcm590xx { struct device *dev; + unsigned int device_type; struct i2c_client *i2c_pri; struct i2c_client *i2c_sec; struct regmap *regmap_pri; From patchwork Mon Oct 30 19:41:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artur Weber X-Patchwork-Id: 13440850 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 0A23AC4332F for ; Mon, 30 Oct 2023 19:42:36 +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:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=STvzBVAuIHX0Zys7V69s5R1D4xa8B8w+ATjZtf9h87c=; b=kYywE8abyOmWDw YzicKVYXkTxamzO/xfuqN5LREI14hsUtDLW7Al28chE3sEF2ieNehWVaQ8VabxXOImAhEjhqOe+4Q osLfnHfoF5ygnEEEL54GE3qf6WxnQz541ERYydjlSVz9Sd4Ud/gnhfBtomvm10XpD/j0ajzAxLD/y 8YC6Cbfv39pBl7IRfVoOicXJUnXMzjJg5CQASTF0Viest/Fp1uEt2Lv2bNcmjendX+Xq7zuBLhHL1 r9Upn0yiELFX/PeKqVr8Q8d+5UDDGLhADhJ+IeKlK+LGmnl98hW/YLa29xYCpWEs8R+wywhWv/fGK 4PmBrWeU3QtkqoQwnELw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qxY9F-003xNd-3C; Mon, 30 Oct 2023 19:42:05 +0000 Received: from mail-lf1-x12a.google.com ([2a00:1450:4864:20::12a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qxY99-003xHo-00 for linux-arm-kernel@lists.infradead.org; Mon, 30 Oct 2023 19:42:01 +0000 Received: by mail-lf1-x12a.google.com with SMTP id 2adb3069b0e04-5079f6efd64so6825646e87.2 for ; Mon, 30 Oct 2023 12:41:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698694914; x=1699299714; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=lar4q5BLMYdDXvaz2nduMcPI3LQymFQyRA6QLE+IUPA=; b=VG4/a192YRah02+8K95RPIfLaoOF62rAgUAGffXMfllRj9dSxayH9OWbjQ+ePEsfnv yYf700wxmhLtZouj6vMpT+FOv8EDLBPXeh3PyelzHRng34L1RMxdVx+HBVI+WkqdDZmy l0GW9m6dmREkJzeuTuhqsk0qzY3jmkuxkn8n4dDugpjP5Fi0OTMN0Rj3Hftgjp6NnJOC dtgUximE/VGNt+i1vmwJ0Yz+8m8X9FRUyDJDHBOlf/MgeX5uGVUQbcOgWV5tnJkKfUBq D/O/y8J6fO0B2pHxoLjnJQeC3ZnYAh0DUgcVHLvdCPYw9qJZkHng0bIvnfm60ikIbf00 IDBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698694914; x=1699299714; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lar4q5BLMYdDXvaz2nduMcPI3LQymFQyRA6QLE+IUPA=; b=VgzkIWVuHj9Bg6xuUKkFrBQC8XZfMXdIyLgMQoyPR8VL3rBS0R0vRg3P06T5iTJV+z 41Vn0gWWe7leP7Itv33HLsrGxrWuialcpx+cy0ok2I9QEHk5jxpLgSeDnhf+4yZVE46p bezVe6H9Gh+59DIZ/G1zPEF3mNYRjMHbJ2pBHjtlJRKFT+1Gdk1RIv2geB+tFmpNloTf y4EGl6uUrxH6OUYis8cE+yhxCytH+Xop9ngzHzHGcsfLOmq/lJg7QRlWadr6M5pLSLeb lD9BBj50d39SaujsRPKHPIamJUAge5N+UAPsNXGBpcHUR7wwHOYlIpeqfIzGH1BGBunO PhZg== X-Gm-Message-State: AOJu0Yz1gnfje5FZWkxSacq3ZTYugZ8jj2GOmeHqq2xAkx1liSDRNR23 6qIQtYmjsFLiANJSLGpVZnQ= X-Google-Smtp-Source: AGHT+IH+3c0llFdOIqdvRFMxP4l3aG+SHTpOangVXSQK9c8H1rpB1Edje3c0vyxB5BwAnebEomqDfw== X-Received: by 2002:a19:9112:0:b0:503:2561:adbc with SMTP id t18-20020a199112000000b005032561adbcmr7309202lfd.64.1698694914471; Mon, 30 Oct 2023 12:41:54 -0700 (PDT) Received: from hex.my.domain (83.11.208.51.ipv4.supernova.orange.pl. [83.11.208.51]) by smtp.gmail.com with ESMTPSA id m10-20020ac2428a000000b005057184ae62sm1527802lfh.96.2023.10.30.12.41.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 12:41:54 -0700 (PDT) From: Artur Weber Date: Mon, 30 Oct 2023 20:41:47 +0100 Subject: [PATCH v2 5/6] regulator: bcm590xx: Add support for BCM59054 MIME-Version: 1.0 Message-Id: <20231030-bcm59054-v2-5-5fa4011aa5ba@gmail.com> References: <20231030-bcm59054-v2-0-5fa4011aa5ba@gmail.com> In-Reply-To: <20231030-bcm59054-v2-0-5fa4011aa5ba@gmail.com> To: Lee Jones , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Florian Fainelli , Ray Jui , Scott Branden , Broadcom internal kernel review list , Liam Girdwood , Mark Brown Cc: Stanislav Jakubek , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Artur Weber X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1698694906; l=25592; i=aweber.kernel@gmail.com; s=20231030; h=from:subject:message-id; bh=Vcld9l2CUccXXlMEKsE/QRX28i7sxc2Cj+81kZnastM=; b=vNEL/nJ5tg2zZ09Wpqx0YFdPp6HrOb5rioB+TITbaS0ZPxsttDnPv+1NES3QWZv/HlqhJx6rq imSwO7rbcv8AdCkAFf0CHw8HXQkq06GVciubF04biqhkEtrOWjBzLJU X-Developer-Key: i=aweber.kernel@gmail.com; a=ed25519; pk=RhDBfWbJEHqDibXbhNEBAnc9FMkyznGxX/hwfhL8bv8= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231030_124159_050315_5CB1F882 X-CRM114-Status: GOOD ( 18.41 ) 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 The BCM59054 is fairly similar in terms of regulators to the already supported BCM59056, as included in the BCM590XX driver. Add support for the BCM59054's regulators to the BCM590XX driver. Switch from using defines for common checks to using functions which return different values depending on the identified MFD model. While we're at it, fix a bug where the enable/vsel register offsets for GPLDO and LDO regulators were calculated incorrectly. Also, change the regulator enable bitmask to cover the entire PMMODE register. Signed-off-by: Artur Weber --- drivers/regulator/bcm590xx-regulator.c | 624 ++++++++++++++++++++++++--------- 1 file changed, 465 insertions(+), 159 deletions(-) diff --git a/drivers/regulator/bcm590xx-regulator.c b/drivers/regulator/bcm590xx-regulator.c index 9f0cda46b015..8b90eae06ca6 100644 --- a/drivers/regulator/bcm590xx-regulator.c +++ b/drivers/regulator/bcm590xx-regulator.c @@ -18,37 +18,54 @@ #include #include +struct bcm590xx_info { + const char *name; + const char *vin_name; + u8 n_voltages; + const unsigned int *volt_table; + u8 n_linear_ranges; + const struct linear_range *linear_ranges; +}; + +struct bcm590xx_reg { + struct regulator_desc *desc; + struct bcm590xx *mfd; +}; + +#define BCM590XX_REG_ENABLE GENMASK(7, 0) +#define BCM590XX_REG_3BIT_ENABLE (GENMASK(4, 3) | GENMASK(1, 0)) +#define BCM590XX_VBUS_ENABLE BIT(2) +#define BCM590XX_LDO_VSEL_MASK GENMASK(5, 3) +#define BCM590XX_SR_VSEL_MASK GENMASK(5, 0) + +/* BCM59056 registers */ + /* I2C slave 0 registers */ -#define BCM590XX_RFLDOPMCTRL1 0x60 -#define BCM590XX_IOSR1PMCTRL1 0x7a -#define BCM590XX_IOSR2PMCTRL1 0x7c -#define BCM590XX_CSRPMCTRL1 0x7e -#define BCM590XX_SDSR1PMCTRL1 0x82 -#define BCM590XX_SDSR2PMCTRL1 0x86 -#define BCM590XX_MSRPMCTRL1 0x8a -#define BCM590XX_VSRPMCTRL1 0x8e -#define BCM590XX_RFLDOCTRL 0x96 -#define BCM590XX_CSRVOUT1 0xc0 +#define BCM59056_RFLDOPMCTRL1 0x60 +#define BCM59056_IOSR1PMCTRL1 0x7a +#define BCM59056_IOSR2PMCTRL1 0x7c +#define BCM59056_CSRPMCTRL1 0x7e +#define BCM59056_SDSR1PMCTRL1 0x82 +#define BCM59056_SDSR2PMCTRL1 0x86 +#define BCM59056_MSRPMCTRL1 0x8a +#define BCM59056_VSRPMCTRL1 0x8e +#define BCM59056_RFLDOCTRL 0x96 +#define BCM59056_CSRVOUT1 0xc0 /* I2C slave 1 registers */ -#define BCM590XX_GPLDO5PMCTRL1 0x16 -#define BCM590XX_GPLDO6PMCTRL1 0x18 -#define BCM590XX_GPLDO1CTRL 0x1a -#define BCM590XX_GPLDO2CTRL 0x1b -#define BCM590XX_GPLDO3CTRL 0x1c -#define BCM590XX_GPLDO4CTRL 0x1d -#define BCM590XX_GPLDO5CTRL 0x1e -#define BCM590XX_GPLDO6CTRL 0x1f -#define BCM590XX_OTG_CTRL 0x40 -#define BCM590XX_GPLDO1PMCTRL1 0x57 -#define BCM590XX_GPLDO2PMCTRL1 0x59 -#define BCM590XX_GPLDO3PMCTRL1 0x5b -#define BCM590XX_GPLDO4PMCTRL1 0x5d - -#define BCM590XX_REG_ENABLE BIT(7) -#define BCM590XX_VBUS_ENABLE BIT(2) -#define BCM590XX_LDO_VSEL_MASK GENMASK(5, 3) -#define BCM590XX_SR_VSEL_MASK GENMASK(5, 0) +#define BCM59056_GPLDO5PMCTRL1 0x16 +#define BCM59056_GPLDO6PMCTRL1 0x18 +#define BCM59056_GPLDO1CTRL 0x1a +#define BCM59056_GPLDO2CTRL 0x1b +#define BCM59056_GPLDO3CTRL 0x1c +#define BCM59056_GPLDO4CTRL 0x1d +#define BCM59056_GPLDO5CTRL 0x1e +#define BCM59056_GPLDO6CTRL 0x1f +#define BCM59056_OTG_CTRL 0x40 +#define BCM59056_GPLDO1PMCTRL1 0x57 +#define BCM59056_GPLDO2PMCTRL1 0x59 +#define BCM59056_GPLDO3PMCTRL1 0x5b +#define BCM59056_GPLDO4PMCTRL1 0x5d /* * RFLDO to VSR regulators are @@ -56,74 +73,69 @@ */ /* LDO regulator IDs */ -#define BCM590XX_REG_RFLDO 0 -#define BCM590XX_REG_CAMLDO1 1 -#define BCM590XX_REG_CAMLDO2 2 -#define BCM590XX_REG_SIMLDO1 3 -#define BCM590XX_REG_SIMLDO2 4 -#define BCM590XX_REG_SDLDO 5 -#define BCM590XX_REG_SDXLDO 6 -#define BCM590XX_REG_MMCLDO1 7 -#define BCM590XX_REG_MMCLDO2 8 -#define BCM590XX_REG_AUDLDO 9 -#define BCM590XX_REG_MICLDO 10 -#define BCM590XX_REG_USBLDO 11 -#define BCM590XX_REG_VIBLDO 12 +#define BCM59056_REG_RFLDO 0 +#define BCM59056_REG_CAMLDO1 1 +#define BCM59056_REG_CAMLDO2 2 +#define BCM59056_REG_SIMLDO1 3 +#define BCM59056_REG_SIMLDO2 4 +#define BCM59056_REG_SDLDO 5 +#define BCM59056_REG_SDXLDO 6 +#define BCM59056_REG_MMCLDO1 7 +#define BCM59056_REG_MMCLDO2 8 +#define BCM59056_REG_AUDLDO 9 +#define BCM59056_REG_MICLDO 10 +#define BCM59056_REG_USBLDO 11 +#define BCM59056_REG_VIBLDO 12 /* DCDC regulator IDs */ -#define BCM590XX_REG_CSR 13 -#define BCM590XX_REG_IOSR1 14 -#define BCM590XX_REG_IOSR2 15 -#define BCM590XX_REG_MSR 16 -#define BCM590XX_REG_SDSR1 17 -#define BCM590XX_REG_SDSR2 18 -#define BCM590XX_REG_VSR 19 +#define BCM59056_REG_CSR 13 +#define BCM59056_REG_IOSR1 14 +#define BCM59056_REG_IOSR2 15 +#define BCM59056_REG_MSR 16 +#define BCM59056_REG_SDSR1 17 +#define BCM59056_REG_SDSR2 18 +#define BCM59056_REG_VSR 19 /* * GPLDO1 to VBUS regulators are * accessed via I2C slave 1 */ -#define BCM590XX_REG_GPLDO1 20 -#define BCM590XX_REG_GPLDO2 21 -#define BCM590XX_REG_GPLDO3 22 -#define BCM590XX_REG_GPLDO4 23 -#define BCM590XX_REG_GPLDO5 24 -#define BCM590XX_REG_GPLDO6 25 -#define BCM590XX_REG_VBUS 26 - -#define BCM590XX_NUM_REGS 27 +#define BCM59056_REG_GPLDO1 20 +#define BCM59056_REG_GPLDO2 21 +#define BCM59056_REG_GPLDO3 22 +#define BCM59056_REG_GPLDO4 23 +#define BCM59056_REG_GPLDO5 24 +#define BCM59056_REG_GPLDO6 25 +#define BCM59056_REG_VBUS 26 -#define BCM590XX_REG_IS_LDO(n) (n < BCM590XX_REG_CSR) -#define BCM590XX_REG_IS_GPLDO(n) \ - ((n > BCM590XX_REG_VSR) && (n < BCM590XX_REG_VBUS)) -#define BCM590XX_REG_IS_VBUS(n) (n == BCM590XX_REG_VBUS) +#define BCM59056_NUM_REGS 27 /* LDO group A: supported voltages in microvolts */ -static const unsigned int ldo_a_table[] = { +static const unsigned int bcm59056_ldo_a_table[] = { 1200000, 1800000, 2500000, 2700000, 2800000, 2900000, 3000000, 3300000, }; /* LDO group C: supported voltages in microvolts */ -static const unsigned int ldo_c_table[] = { +static const unsigned int bcm59056_ldo_c_table[] = { 3100000, 1800000, 2500000, 2700000, 2800000, 2900000, 3000000, 3300000, }; -static const unsigned int ldo_vbus[] = { +static const unsigned int bcm59056_ldo_vbus[] = { 5000000, }; /* DCDC group CSR: supported voltages in microvolts */ -static const struct linear_range dcdc_csr_ranges[] = { +static const struct linear_range bcm59056_dcdc_csr_ranges[] = { REGULATOR_LINEAR_RANGE(860000, 2, 50, 10000), REGULATOR_LINEAR_RANGE(1360000, 51, 55, 20000), REGULATOR_LINEAR_RANGE(900000, 56, 63, 0), }; /* DCDC group IOSR1: supported voltages in microvolts */ -static const struct linear_range dcdc_iosr1_ranges[] = { +static const struct linear_range bcm59056_dcdc_iosr1_ranges[] = { REGULATOR_LINEAR_RANGE(860000, 2, 51, 10000), REGULATOR_LINEAR_RANGE(1500000, 52, 52, 0), REGULATOR_LINEAR_RANGE(1800000, 53, 53, 0), @@ -131,121 +143,404 @@ static const struct linear_range dcdc_iosr1_ranges[] = { }; /* DCDC group SDSR1: supported voltages in microvolts */ -static const struct linear_range dcdc_sdsr1_ranges[] = { +static const struct linear_range bcm59056_dcdc_sdsr1_ranges[] = { REGULATOR_LINEAR_RANGE(860000, 2, 50, 10000), REGULATOR_LINEAR_RANGE(1340000, 51, 51, 0), REGULATOR_LINEAR_RANGE(900000, 52, 63, 0), }; -struct bcm590xx_info { - const char *name; - const char *vin_name; - u8 n_voltages; - const unsigned int *volt_table; - u8 n_linear_ranges; - const struct linear_range *linear_ranges; +#define BCM59056_REG_TABLE(_name, _table) \ + { \ + .name = #_name, \ + .n_voltages = ARRAY_SIZE(bcm59056_##_table), \ + .volt_table = bcm59056_##_table, \ + } + +#define BCM59056_REG_RANGES(_name, _ranges) \ + { \ + .name = #_name, \ + .n_voltages = 64, \ + .n_linear_ranges = ARRAY_SIZE(bcm59056_##_ranges), \ + .linear_ranges = bcm59056_##_ranges, \ + } + +static struct bcm590xx_info bcm59056_regs[] = { + BCM59056_REG_TABLE(rfldo, ldo_a_table), + BCM59056_REG_TABLE(camldo1, ldo_c_table), + BCM59056_REG_TABLE(camldo2, ldo_c_table), + BCM59056_REG_TABLE(simldo1, ldo_a_table), + BCM59056_REG_TABLE(simldo2, ldo_a_table), + BCM59056_REG_TABLE(sdldo, ldo_c_table), + BCM59056_REG_TABLE(sdxldo, ldo_a_table), + BCM59056_REG_TABLE(mmcldo1, ldo_a_table), + BCM59056_REG_TABLE(mmcldo2, ldo_a_table), + BCM59056_REG_TABLE(audldo, ldo_a_table), + BCM59056_REG_TABLE(micldo, ldo_a_table), + BCM59056_REG_TABLE(usbldo, ldo_a_table), + BCM59056_REG_TABLE(vibldo, ldo_c_table), + BCM59056_REG_RANGES(csr, dcdc_csr_ranges), + BCM59056_REG_RANGES(iosr1, dcdc_iosr1_ranges), + BCM59056_REG_RANGES(iosr2, dcdc_iosr1_ranges), + BCM59056_REG_RANGES(msr, dcdc_iosr1_ranges), + BCM59056_REG_RANGES(sdsr1, dcdc_sdsr1_ranges), + BCM59056_REG_RANGES(sdsr2, dcdc_iosr1_ranges), + BCM59056_REG_RANGES(vsr, dcdc_iosr1_ranges), + BCM59056_REG_TABLE(gpldo1, ldo_a_table), + BCM59056_REG_TABLE(gpldo2, ldo_a_table), + BCM59056_REG_TABLE(gpldo3, ldo_a_table), + BCM59056_REG_TABLE(gpldo4, ldo_a_table), + BCM59056_REG_TABLE(gpldo5, ldo_a_table), + BCM59056_REG_TABLE(gpldo6, ldo_a_table), + BCM59056_REG_TABLE(vbus, ldo_vbus), +}; + +/* BCM59054 registers */ + +/* I2C slave 0 registers */ +#define BCM59054_RFLDOPMCTRL1 0x60 +#define BCM59054_IOSR1PMCTRL1 0x7a +#define BCM59054_IOSR2PMCTRL1 0x7c +#define BCM59054_CSRPMCTRL1 0x7e +#define BCM59054_SDSR1PMCTRL1 0x82 +#define BCM59054_SDSR2PMCTRL1 0x86 +#define BCM59054_MMSRPMCTRL1 0x8a +#define BCM59054_VSRPMCTRL1 0x8e +#define BCM59054_RFLDOCTRL 0x96 +#define BCM59054_CSRVOUT1 0xc0 + +/* I2C slave 1 registers */ +#define BCM59054_LVLDO1PMCTRL1 0x16 +#define BCM59054_LVLDO2PMCTRL1 0x18 +#define BCM59054_GPLDO1CTRL 0x1a +#define BCM59054_GPLDO2CTRL 0x1b +#define BCM59054_GPLDO3CTRL 0x1c +#define BCM59054_TCXLDOCTRL 0x1d +#define BCM59054_LVLDO1CTRL 0x1e +#define BCM59054_LVLDO2CTRL 0x1f +#define BCM59054_OTG_CTRL 0x40 +#define BCM59054_GPLDO1PMCTRL1 0x57 +#define BCM59054_GPLDO2PMCTRL1 0x59 +#define BCM59054_GPLDO3PMCTRL1 0x5b +#define BCM59054_TCXLDOPMCTRL1 0x5d + +/* + * RFLDO to VSR regulators are + * accessed via I2C slave 0 + */ + +/* LDO regulator IDs */ +#define BCM59054_REG_RFLDO 0 +#define BCM59054_REG_CAMLDO1 1 +#define BCM59054_REG_CAMLDO2 2 +#define BCM59054_REG_SIMLDO1 3 +#define BCM59054_REG_SIMLDO2 4 +#define BCM59054_REG_SDLDO 5 +#define BCM59054_REG_SDXLDO 6 +#define BCM59054_REG_MMCLDO1 7 +#define BCM59054_REG_MMCLDO2 8 +#define BCM59054_REG_AUDLDO 9 +#define BCM59054_REG_MICLDO 10 +#define BCM59054_REG_USBLDO 11 +#define BCM59054_REG_VIBLDO 12 + +/* DCDC regulator IDs */ +#define BCM59054_REG_CSR 13 +#define BCM59054_REG_IOSR1 14 +#define BCM59054_REG_IOSR2 15 +#define BCM59054_REG_MMSR 16 +#define BCM59054_REG_SDSR1 17 +#define BCM59054_REG_SDSR2 18 +#define BCM59054_REG_VSR 19 + +/* + * GPLDO1 to VBUS regulators are + * accessed via I2C slave 1 + */ + +#define BCM59054_REG_GPLDO1 20 +#define BCM59054_REG_GPLDO2 21 +#define BCM59054_REG_GPLDO3 22 +#define BCM59054_REG_TCXLDO 23 +#define BCM59054_REG_LVLDO1 24 +#define BCM59054_REG_LVLDO2 25 +#define BCM59054_REG_VBUS 26 + +#define BCM59054_NUM_REGS 27 + +/* LDO group 1: supported voltages in microvolts */ +static const unsigned int bcm59054_ldo_1_table[] = { + 1200000, 1800000, 2500000, 2700000, 2800000, + 2900000, 3000000, 3300000, +}; + +/* LDO group 2: supported voltages in microvolts */ +static const unsigned int bcm59054_ldo_2_table[] = { + 3100000, 1800000, 2500000, 2700000, 2800000, + 2900000, 3000000, 3300000, +}; + +/* LDO group 3: supported voltages in microvolts */ +static const unsigned int bcm59054_ldo_3_table[] = { + 1000000, 1107000, 1143000, 1214000, 1250000, + 1464000, 1500000, 1786000, +}; + +static const unsigned int bcm59054_ldo_vbus[] = { + 5000000, +}; + +/* DCDC group SR: supported voltages in microvolts */ +static const struct linear_range bcm59054_dcdc_sr_ranges[] = { + REGULATOR_LINEAR_RANGE(0, 0, 1, 0), + REGULATOR_LINEAR_RANGE(860000, 2, 60, 10000), + REGULATOR_LINEAR_RANGE(1500000, 61, 61, 0), + REGULATOR_LINEAR_RANGE(1800000, 62, 62, 0), + REGULATOR_LINEAR_RANGE(900000, 63, 63, 0), +}; + +/* DCDC group VSR: supported voltages in microvolts */ +static const struct linear_range bcm59054_dcdc_vsr_ranges[] = { + REGULATOR_LINEAR_RANGE(0, 0, 1, 0), + REGULATOR_LINEAR_RANGE(860000, 2, 59, 10000), + REGULATOR_LINEAR_RANGE(1700000, 60, 60, 0), + REGULATOR_LINEAR_RANGE(1500000, 61, 61, 0), + REGULATOR_LINEAR_RANGE(1800000, 62, 62, 0), + REGULATOR_LINEAR_RANGE(1600000, 63, 63, 0), }; -#define BCM590XX_REG_TABLE(_name, _table) \ +/* DCDC group CSR: supported voltages in microvolts */ +static const struct linear_range bcm59054_dcdc_csr_ranges[] = { + REGULATOR_LINEAR_RANGE(700000, 0, 1, 100000), + REGULATOR_LINEAR_RANGE(860000, 2, 60, 10000), + REGULATOR_LINEAR_RANGE(900000, 61, 63, 0), +}; + +#define BCM59054_REG_TABLE(_name, _table) \ { \ .name = #_name, \ - .n_voltages = ARRAY_SIZE(_table), \ - .volt_table = _table, \ + .n_voltages = ARRAY_SIZE(bcm59054_##_table), \ + .volt_table = bcm59054_##_table, \ } -#define BCM590XX_REG_RANGES(_name, _ranges) \ +#define BCM59054_REG_RANGES(_name, _ranges) \ { \ .name = #_name, \ .n_voltages = 64, \ - .n_linear_ranges = ARRAY_SIZE(_ranges), \ - .linear_ranges = _ranges, \ + .n_linear_ranges = ARRAY_SIZE(bcm59054_##_ranges), \ + .linear_ranges = bcm59054_##_ranges, \ } -static struct bcm590xx_info bcm590xx_regs[] = { - BCM590XX_REG_TABLE(rfldo, ldo_a_table), - BCM590XX_REG_TABLE(camldo1, ldo_c_table), - BCM590XX_REG_TABLE(camldo2, ldo_c_table), - BCM590XX_REG_TABLE(simldo1, ldo_a_table), - BCM590XX_REG_TABLE(simldo2, ldo_a_table), - BCM590XX_REG_TABLE(sdldo, ldo_c_table), - BCM590XX_REG_TABLE(sdxldo, ldo_a_table), - BCM590XX_REG_TABLE(mmcldo1, ldo_a_table), - BCM590XX_REG_TABLE(mmcldo2, ldo_a_table), - BCM590XX_REG_TABLE(audldo, ldo_a_table), - BCM590XX_REG_TABLE(micldo, ldo_a_table), - BCM590XX_REG_TABLE(usbldo, ldo_a_table), - BCM590XX_REG_TABLE(vibldo, ldo_c_table), - BCM590XX_REG_RANGES(csr, dcdc_csr_ranges), - BCM590XX_REG_RANGES(iosr1, dcdc_iosr1_ranges), - BCM590XX_REG_RANGES(iosr2, dcdc_iosr1_ranges), - BCM590XX_REG_RANGES(msr, dcdc_iosr1_ranges), - BCM590XX_REG_RANGES(sdsr1, dcdc_sdsr1_ranges), - BCM590XX_REG_RANGES(sdsr2, dcdc_iosr1_ranges), - BCM590XX_REG_RANGES(vsr, dcdc_iosr1_ranges), - BCM590XX_REG_TABLE(gpldo1, ldo_a_table), - BCM590XX_REG_TABLE(gpldo2, ldo_a_table), - BCM590XX_REG_TABLE(gpldo3, ldo_a_table), - BCM590XX_REG_TABLE(gpldo4, ldo_a_table), - BCM590XX_REG_TABLE(gpldo5, ldo_a_table), - BCM590XX_REG_TABLE(gpldo6, ldo_a_table), - BCM590XX_REG_TABLE(vbus, ldo_vbus), +static struct bcm590xx_info bcm59054_regs[] = { + BCM59054_REG_TABLE(rfldo, ldo_1_table), + BCM59054_REG_TABLE(camldo1, ldo_2_table), + BCM59054_REG_TABLE(camldo2, ldo_2_table), + BCM59054_REG_TABLE(simldo1, ldo_1_table), + BCM59054_REG_TABLE(simldo2, ldo_1_table), + BCM59054_REG_TABLE(sdldo, ldo_2_table), + BCM59054_REG_TABLE(sdxldo, ldo_1_table), + BCM59054_REG_TABLE(mmcldo1, ldo_1_table), + BCM59054_REG_TABLE(mmcldo2, ldo_1_table), + BCM59054_REG_TABLE(audldo, ldo_1_table), + BCM59054_REG_TABLE(micldo, ldo_1_table), + BCM59054_REG_TABLE(usbldo, ldo_1_table), + BCM59054_REG_TABLE(vibldo, ldo_2_table), + BCM59054_REG_RANGES(csr, dcdc_csr_ranges), + BCM59054_REG_RANGES(iosr1, dcdc_sr_ranges), + BCM59054_REG_RANGES(iosr2, dcdc_sr_ranges), + BCM59054_REG_RANGES(mmsr, dcdc_sr_ranges), + BCM59054_REG_RANGES(sdsr1, dcdc_sr_ranges), + BCM59054_REG_RANGES(sdsr2, dcdc_sr_ranges), + BCM59054_REG_RANGES(vsr, dcdc_vsr_ranges), + BCM59054_REG_TABLE(gpldo1, ldo_1_table), + BCM59054_REG_TABLE(gpldo2, ldo_1_table), + BCM59054_REG_TABLE(gpldo3, ldo_1_table), + BCM59054_REG_TABLE(tcxldo, ldo_1_table), + BCM59054_REG_TABLE(lvldo1, ldo_3_table), + BCM59054_REG_TABLE(lvldo2, ldo_3_table), + BCM59054_REG_TABLE(vbus, ldo_vbus), }; -struct bcm590xx_reg { - struct regulator_desc *desc; - struct bcm590xx *mfd; -}; +static int bcm590xx_reg_is_ldo(struct bcm590xx_reg *pmu, int id) +{ + switch (pmu->mfd->device_type) { + case BCM59054_TYPE: + return (id < BCM59054_REG_CSR); + case BCM59056_TYPE: + return (id < BCM59056_REG_CSR); + } + return -EINVAL; +} -static int bcm590xx_get_vsel_register(int id) +static int bcm590xx_reg_is_gpldo(struct bcm590xx_reg *pmu, int id) { - if (BCM590XX_REG_IS_LDO(id)) - return BCM590XX_RFLDOCTRL + id; - else if (BCM590XX_REG_IS_GPLDO(id)) - return BCM590XX_GPLDO1CTRL + id; - else - return BCM590XX_CSRVOUT1 + (id - BCM590XX_REG_CSR) * 3; + switch (pmu->mfd->device_type) { + case BCM59054_TYPE: + return ((id > BCM59054_REG_VSR) && (id < BCM59054_REG_VBUS)); + case BCM59056_TYPE: + return ((id > BCM59056_REG_VSR) && (id < BCM59056_REG_VBUS)); + } + return -EINVAL; +} + +static int bcm590xx_reg_is_vbus(struct bcm590xx_reg *pmu, int id) +{ + switch (pmu->mfd->device_type) { + case BCM59054_TYPE: + return (id == BCM59054_REG_VBUS); + case BCM59056_TYPE: + return (id == BCM59056_REG_VBUS); + } + return -EINVAL; +} + +static int bcm590xx_reg_is_static(struct bcm590xx_reg *pmu, int id) +{ + return bcm590xx_reg_is_vbus(pmu, id); +} + +static int bcm590xx_reg_is_secondary(struct bcm590xx_reg *pmu, int id) +{ + switch (pmu->mfd->device_type) { + case BCM59054_TYPE: + return (bcm590xx_reg_is_gpldo(pmu, id) || \ + id == BCM59054_REG_VBUS); + case BCM59056_TYPE: + return (bcm590xx_reg_is_gpldo(pmu, id) || \ + id == BCM59056_REG_VBUS); + } + return -EINVAL; +} + +static int bcm590xx_reg_mode_is_3bit(struct bcm590xx_reg *pmu, int id) +{ + switch (pmu->mfd->device_type) { + case BCM59054_TYPE: + return (id == BCM59054_REG_CSR || \ + (id > BCM59054_REG_IOSR2 && id < BCM59054_REG_GPLDO1)); + case BCM59056_TYPE: + return false; + } + return -EINVAL; +} + +static int bcm590xx_get_vsel_register(struct bcm590xx_reg *pmu, int id) +{ + switch (pmu->mfd->device_type) { + case BCM59054_TYPE: + if (bcm590xx_reg_is_ldo(pmu, id)) + return BCM59054_RFLDOCTRL + (id - BCM59054_REG_RFLDO); + else if (bcm590xx_reg_is_gpldo(pmu, id)) + return BCM59054_GPLDO1CTRL + (id - BCM59054_REG_GPLDO1); + else + return BCM59054_CSRVOUT1 + (id - BCM59054_REG_CSR) * 3; + case BCM59056_TYPE: + if (bcm590xx_reg_is_ldo(pmu, id)) + return BCM59056_RFLDOCTRL + (id - BCM59056_REG_RFLDO); + else if (bcm590xx_reg_is_gpldo(pmu, id)) + return BCM59056_GPLDO1CTRL + (id - BCM59056_REG_GPLDO1); + else + return BCM59056_CSRVOUT1 + (id - BCM59056_REG_CSR) * 3; + } + return -EINVAL; } -static int bcm590xx_get_enable_register(int id) +static int bcm59054_get_enable_register(struct bcm590xx_reg *pmu, int id) { int reg = 0; - if (BCM590XX_REG_IS_LDO(id)) - reg = BCM590XX_RFLDOPMCTRL1 + id * 2; - else if (BCM590XX_REG_IS_GPLDO(id)) - reg = BCM590XX_GPLDO1PMCTRL1 + id * 2; + if (bcm590xx_reg_is_ldo(pmu, id)) + reg = BCM59054_RFLDOPMCTRL1 + (id - BCM59054_REG_RFLDO) * 2; + else if (bcm590xx_reg_is_gpldo(pmu, id)) + reg = BCM59054_GPLDO1PMCTRL1 + (id - BCM59054_REG_GPLDO1) * 2; else switch (id) { - case BCM590XX_REG_CSR: - reg = BCM590XX_CSRPMCTRL1; + case BCM59054_REG_VSR: + reg = BCM59054_VSRPMCTRL1; break; - case BCM590XX_REG_IOSR1: - reg = BCM590XX_IOSR1PMCTRL1; + case BCM59054_REG_CSR: + reg = BCM59054_CSRPMCTRL1; break; - case BCM590XX_REG_IOSR2: - reg = BCM590XX_IOSR2PMCTRL1; + case BCM59054_REG_MMSR: + reg = BCM59054_MMSRPMCTRL1; break; - case BCM590XX_REG_MSR: - reg = BCM590XX_MSRPMCTRL1; + case BCM59054_REG_SDSR1: + reg = BCM59054_SDSR1PMCTRL1; break; - case BCM590XX_REG_SDSR1: - reg = BCM590XX_SDSR1PMCTRL1; + case BCM59054_REG_SDSR2: + reg = BCM59054_SDSR2PMCTRL1; break; - case BCM590XX_REG_SDSR2: - reg = BCM590XX_SDSR2PMCTRL1; + case BCM59054_REG_IOSR1: + reg = BCM59054_IOSR1PMCTRL1; break; - case BCM590XX_REG_VSR: - reg = BCM590XX_VSRPMCTRL1; + case BCM59054_REG_IOSR2: + reg = BCM59054_IOSR2PMCTRL1; break; - case BCM590XX_REG_VBUS: - reg = BCM590XX_OTG_CTRL; + case BCM59054_REG_VBUS: + reg = BCM59054_OTG_CTRL; break; } + return reg; +} + +static int bcm59056_get_enable_register(struct bcm590xx_reg *pmu, int id) +{ + int reg = 0; + + if (bcm590xx_reg_is_ldo(pmu, id)) + reg = BCM59056_RFLDOPMCTRL1 + (id - BCM59056_REG_RFLDO) * 2; + else if (bcm590xx_reg_is_gpldo(pmu, id)) + reg = BCM59056_GPLDO1PMCTRL1 + (id - BCM59056_REG_GPLDO1) * 2; + else + switch (id) { + case BCM59056_REG_CSR: + reg = BCM59056_CSRPMCTRL1; + break; + case BCM59056_REG_IOSR1: + reg = BCM59056_IOSR1PMCTRL1; + break; + case BCM59056_REG_IOSR2: + reg = BCM59056_IOSR2PMCTRL1; + break; + case BCM59056_REG_MSR: + reg = BCM59056_MSRPMCTRL1; + break; + case BCM59056_REG_SDSR1: + reg = BCM59056_SDSR1PMCTRL1; + break; + case BCM59056_REG_SDSR2: + reg = BCM59056_SDSR2PMCTRL1; + break; + case BCM59056_REG_VSR: + reg = BCM59056_VSRPMCTRL1; + break; + case BCM59056_REG_VBUS: + reg = BCM59056_OTG_CTRL; + break; + } return reg; } +static int bcm590xx_get_enable_register(struct bcm590xx_reg *pmu, int id) +{ + switch (pmu->mfd->device_type) { + case BCM59054_TYPE: + return bcm59054_get_enable_register(pmu, id); + case BCM59056_TYPE: + return bcm59056_get_enable_register(pmu, id); + } + return -EINVAL; +} + +static int bcm590xx_get_enable_mask(struct bcm590xx_reg *pmu, int id) +{ + if (bcm590xx_reg_mode_is_3bit(pmu, id)) + return BCM590XX_REG_3BIT_ENABLE; + + return BCM590XX_REG_ENABLE; +} + static const struct regulator_ops bcm590xx_ops_ldo = { .is_enabled = regulator_is_enabled_regmap, .enable = regulator_enable_regmap, @@ -266,7 +561,7 @@ static const struct regulator_ops bcm590xx_ops_dcdc = { .map_voltage = regulator_map_voltage_linear_range, }; -static const struct regulator_ops bcm590xx_ops_vbus = { +static const struct regulator_ops bcm590xx_ops_static = { .is_enabled = regulator_is_enabled_regmap, .enable = regulator_enable_regmap, .disable = regulator_disable_regmap, @@ -279,6 +574,7 @@ static int bcm590xx_probe(struct platform_device *pdev) struct regulator_config config = { }; struct bcm590xx_info *info; struct regulator_dev *rdev; + int n_regulators; int i; pmu = devm_kzalloc(&pdev->dev, sizeof(*pmu), GFP_KERNEL); @@ -289,17 +585,23 @@ static int bcm590xx_probe(struct platform_device *pdev) platform_set_drvdata(pdev, pmu); + if (pmu->mfd->device_type == BCM59054_TYPE) { + info = bcm59054_regs; + n_regulators = BCM59054_NUM_REGS; + } else if (pmu->mfd->device_type == BCM59056_TYPE) { + info = bcm59056_regs; + n_regulators = BCM59056_NUM_REGS; + } + pmu->desc = devm_kcalloc(&pdev->dev, - BCM590XX_NUM_REGS, + n_regulators, sizeof(struct regulator_desc), GFP_KERNEL); if (!pmu->desc) return -ENOMEM; - info = bcm590xx_regs; - - for (i = 0; i < BCM590XX_NUM_REGS; i++, info++) { - /* Register the regulators */ + /* Register the regulators */ + for (i = 0; i < n_regulators; i++, info++) { pmu->desc[i].name = info->name; pmu->desc[i].of_match = of_match_ptr(info->name); pmu->desc[i].regulators_node = of_match_ptr("regulators"); @@ -310,33 +612,37 @@ static int bcm590xx_probe(struct platform_device *pdev) pmu->desc[i].linear_ranges = info->linear_ranges; pmu->desc[i].n_linear_ranges = info->n_linear_ranges; - if ((BCM590XX_REG_IS_LDO(i)) || (BCM590XX_REG_IS_GPLDO(i))) { + if (bcm590xx_reg_is_ldo(pmu, i) || \ + bcm590xx_reg_is_gpldo(pmu, i)) { pmu->desc[i].ops = &bcm590xx_ops_ldo; pmu->desc[i].vsel_mask = BCM590XX_LDO_VSEL_MASK; - } else if (BCM590XX_REG_IS_VBUS(i)) - pmu->desc[i].ops = &bcm590xx_ops_vbus; - else { + } else if (bcm590xx_reg_is_static(pmu, i)) { + pmu->desc[i].ops = &bcm590xx_ops_static; + } else { pmu->desc[i].ops = &bcm590xx_ops_dcdc; pmu->desc[i].vsel_mask = BCM590XX_SR_VSEL_MASK; } - if (BCM590XX_REG_IS_VBUS(i)) + if (bcm590xx_reg_is_vbus(pmu, i)) { pmu->desc[i].enable_mask = BCM590XX_VBUS_ENABLE; - else { - pmu->desc[i].vsel_reg = bcm590xx_get_vsel_register(i); + } else { + pmu->desc[i].vsel_reg = \ + bcm590xx_get_vsel_register(pmu, i); + pmu->desc[i].enable_mask = \ + bcm590xx_get_enable_mask(pmu, i); pmu->desc[i].enable_is_inverted = true; - pmu->desc[i].enable_mask = BCM590XX_REG_ENABLE; } - pmu->desc[i].enable_reg = bcm590xx_get_enable_register(i); + pmu->desc[i].enable_reg = \ + bcm590xx_get_enable_register(pmu, i); pmu->desc[i].type = REGULATOR_VOLTAGE; pmu->desc[i].owner = THIS_MODULE; - config.dev = bcm590xx->dev; + config.dev = pmu->mfd->dev; config.driver_data = pmu; - if (BCM590XX_REG_IS_GPLDO(i) || BCM590XX_REG_IS_VBUS(i)) - config.regmap = bcm590xx->regmap_sec; + if (bcm590xx_reg_is_secondary(pmu, i)) + config.regmap = pmu->mfd->regmap_sec; else - config.regmap = bcm590xx->regmap_pri; + config.regmap = pmu->mfd->regmap_pri; rdev = devm_regulator_register(&pdev->dev, &pmu->desc[i], &config); From patchwork Mon Oct 30 19:41:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artur Weber X-Patchwork-Id: 13440847 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 22357C4167B for ; Mon, 30 Oct 2023 19:42:29 +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:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=10kteaiDU1jFffo6iU91h1b3a8eLNuvARNJ0XeRWFNw=; b=BYxfMGdMGp4vwB pq5LLin2LkZuQfXsLWJtlOs1R+S5MQboeyrRBD8/ULS+cGX5ysvgC0LS01usJhsYHyFDXB7zA8niC gQJOUk9SavlLycMm+zn+m/kBMNDYKSRSaiiiGK5575FlvE/3LYkSBaTJtpV3bMJEO7TN3iKyA5g7K WXmExqhdxfD3by3SjSnvFIQIQBiQP4TSES3KJvTfT/Av+p6f3px4qMMxZAO6wou4iCLLjK5CTaLP7 e9t+GCmzMzw3BCBZ5DRpk49sPokcvDlqK9k2HwobB81BdEUIEZN6a5A0hnEtyiiz2EH669ej5xk6Q MR7FHYUyYtnNowM27l/w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qxY9E-003xLh-0T; Mon, 30 Oct 2023 19:42:04 +0000 Received: from mail-lf1-x135.google.com ([2a00:1450:4864:20::135]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qxY98-003xIQ-2y for linux-arm-kernel@lists.infradead.org; Mon, 30 Oct 2023 19:42:00 +0000 Received: by mail-lf1-x135.google.com with SMTP id 2adb3069b0e04-507c78d258fso7073282e87.2 for ; Mon, 30 Oct 2023 12:41:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698694916; x=1699299716; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=nV4Ai08tkpOWFMEbSJPptM95Z5+f/6Xg1fGxclm9cNA=; b=QtydaA6xQtyXPoQBphvwBfWfb4Dp76F8wGjN/X+/qJAL/1uEp4qgKyM7jpfKQH7tTU BTlH9R9CmlCrCKWg0jtYxtKY615/gB5j3L8PaN6Ie31WM6lR47vPcPaqIw7yet3HrMKO qdtMnQ+/Mcny3AFHljVPTqxK9XFw9rhlwaM6R6mzzML1myoNfSvpR8ru1hVQqlgmle7Q sZ7l9qTFFpmiSp1/VGQhhB00he3XdgyhDgAKhJCQOMmbtQsaoUPmukfHXJcZQAW2hY7I xnOLnIzND7Ek5ItXPxl1mu2sWfvB1TOkHxm+LMM0mVkXjGk5w90btmzg1FOza8VBh+Wh ibvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698694916; x=1699299716; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nV4Ai08tkpOWFMEbSJPptM95Z5+f/6Xg1fGxclm9cNA=; b=YLsxG3FF4JLFxtEyshKkMVTHFao7ADpO46J1fugV9kx2xVaIoTz8qKnUnEK7gF/21P IurwkKTndKpM2f687k4xq7+prMYKMp5sjup/Kgp/xYJ23gQLrEwpEUQXhVerhsTjLaty Uk4h2TGCa5tAvqloGfVoxZCmSQgrlXt2XSXY8LuVFABRFiMADJEXALgq9pivPjJx1xrM qO/ud2fSP/22NvF4PCZ8Xtg6MuV6RdclRIGHG56BfJmASFo8IGrISmQW4xk/fsScgl8A sONpLtXOH2UpYmYBCGc/3kWha0mVxZEIzhLNvd1FZr9AyzialV7eo3Lypsxp5gCr//0n Xlow== X-Gm-Message-State: AOJu0YwdtXc4QTgpB2Hw5wbJvZuNBx/jzdM/xtcY3amslQlRCV/sxm96 xdXfFC+Vn9ABHlY7n+g7ikWpBmbJzRKBpw== X-Google-Smtp-Source: AGHT+IGlIeZzyq3CXKnAFKiUZLlTEcTypiCnxmVZUhW20jITO9bthnPr+fPPYDRtfYBZCJdUShAiFA== X-Received: by 2002:a19:ad44:0:b0:4fb:9f93:365f with SMTP id s4-20020a19ad44000000b004fb9f93365fmr7587568lfd.38.1698694915815; Mon, 30 Oct 2023 12:41:55 -0700 (PDT) Received: from hex.my.domain (83.11.208.51.ipv4.supernova.orange.pl. [83.11.208.51]) by smtp.gmail.com with ESMTPSA id m10-20020ac2428a000000b005057184ae62sm1527802lfh.96.2023.10.30.12.41.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 12:41:55 -0700 (PDT) From: Artur Weber Date: Mon, 30 Oct 2023 20:41:48 +0100 Subject: [PATCH v2 6/6] regulator: bcm590xx: Add proper handling for PMMODE registers MIME-Version: 1.0 Message-Id: <20231030-bcm59054-v2-6-5fa4011aa5ba@gmail.com> References: <20231030-bcm59054-v2-0-5fa4011aa5ba@gmail.com> In-Reply-To: <20231030-bcm59054-v2-0-5fa4011aa5ba@gmail.com> To: Lee Jones , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Florian Fainelli , Ray Jui , Scott Branden , Broadcom internal kernel review list , Liam Girdwood , Mark Brown Cc: Stanislav Jakubek , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Artur Weber X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1698694906; l=6532; i=aweber.kernel@gmail.com; s=20231030; h=from:subject:message-id; bh=MOr6P062Hw1cr9IL31CLgUIsSEz/SzMD3p5bHJ1QOHY=; b=kLCeoKqnWrubrHw320soyDTW4OEXc3S5QCIyFAvROBe8Aa6eK7SRWEca6BdODbEslTI1mCmHT 0z/YbvmoUDSBuEf3a86eSCoh/CRt+rotHIRF/NlMuvrk5sv7l8RL8qk X-Developer-Key: i=aweber.kernel@gmail.com; a=ed25519; pk=RhDBfWbJEHqDibXbhNEBAnc9FMkyznGxX/hwfhL8bv8= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231030_124158_963708_7890EEF1 X-CRM114-Status: GOOD ( 26.09 ) 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 The state of BCM590XX regulators is controlled by writing to the PMCTRL registers; there are 7 selectable mode entries in those registers, each storing a specific mode value - OFF, LPM or ON. Which entry is selected depends on the combination of enabled PC pins (PC1, PC2 and the optional PC3). Add a new function to write a specific mode value to all entries, and make a custom enable/disable function to make use of it. Keep the is_enabled function using the naive regmap method (a potential improvement here would be to add support for getting the state of the PC pins to figure out the selected mode). It should also be possible to extend this to support regulator modes, though some work may be needed to make sure it doesn't interfere with the enabled/disabled state. Signed-off-by: Artur Weber --- drivers/regulator/bcm590xx-regulator.c | 96 +++++++++++++++++++++++++++++----- 1 file changed, 84 insertions(+), 12 deletions(-) diff --git a/drivers/regulator/bcm590xx-regulator.c b/drivers/regulator/bcm590xx-regulator.c index 8b90eae06ca6..1905dc2a4111 100644 --- a/drivers/regulator/bcm590xx-regulator.c +++ b/drivers/regulator/bcm590xx-regulator.c @@ -38,6 +38,15 @@ struct bcm590xx_reg { #define BCM590XX_LDO_VSEL_MASK GENMASK(5, 3) #define BCM590XX_SR_VSEL_MASK GENMASK(5, 0) +#define BCM590XX_PMMODE_ON 0x0 +#define BCM590XX_PMMODE_LPM 0x1 +#define BCM590XX_PMMODE_OFF 0x2 + +#define PMMODE_3BIT_MASK(mode) \ + ((mode << 3) | mode) +#define PMMODE_2BIT_MASK(mode) \ + ((mode << 6) | (mode << 4) | (mode << 2) | mode) + /* BCM59056 registers */ /* I2C slave 0 registers */ @@ -444,7 +453,7 @@ static int bcm590xx_get_vsel_register(struct bcm590xx_reg *pmu, int id) return -EINVAL; } -static int bcm59054_get_enable_register(struct bcm590xx_reg *pmu, int id) +static int bcm59054_get_pmctrl_register(struct bcm590xx_reg *pmu, int id) { int reg = 0; @@ -483,7 +492,7 @@ static int bcm59054_get_enable_register(struct bcm590xx_reg *pmu, int id) return reg; } -static int bcm59056_get_enable_register(struct bcm590xx_reg *pmu, int id) +static int bcm59056_get_pmctrl_register(struct bcm590xx_reg *pmu, int id) { int reg = 0; @@ -522,13 +531,13 @@ static int bcm59056_get_enable_register(struct bcm590xx_reg *pmu, int id) return reg; } -static int bcm590xx_get_enable_register(struct bcm590xx_reg *pmu, int id) +static int bcm590xx_get_pmctrl_register(struct bcm590xx_reg *pmu, int id) { switch (pmu->mfd->device_type) { case BCM59054_TYPE: - return bcm59054_get_enable_register(pmu, id); + return bcm59054_get_pmctrl_register(pmu, id); case BCM59056_TYPE: - return bcm59056_get_enable_register(pmu, id); + return bcm59056_get_pmctrl_register(pmu, id); } return -EINVAL; } @@ -541,10 +550,73 @@ static int bcm590xx_get_enable_mask(struct bcm590xx_reg *pmu, int id) return BCM590XX_REG_ENABLE; } +/* + * The state of BCM590XX regulators is controlled by the PM mode; most + * regulators have 3 such modes (off, low-power and on). + * + * These modes are then stored in the PMCTRL registers - there are 7 + * PMMODE entries within these registers for any given regulator. + * Which one is selected is decided by the PC1 and PC2 pins (and the + * optional PC3 pin, if configured). + * + * For simplicity, to set a PM mode, we write it to all available + * PMMODE registers. + */ +static int +_bcm590xx_set_pmmode(struct bcm590xx_reg *pmu, int reg_id, unsigned int mode) +{ + struct regmap *regmap; + u8 pmctrl_addr = bcm590xx_get_pmctrl_register(pmu, reg_id); + unsigned int i; + int pmctrl_count; + int mode_mask; + int ret; + + /* + * Regulators using 2-bit mode controls have 2 PMCTRL registers; + * regulators using 3-bit mode controls have 4 PMCTRL registers. + * This is to accommodate all 7 selectable modes. + */ + if (bcm590xx_reg_mode_is_3bit(pmu, reg_id)) { + pmctrl_count = 4; + mode_mask = PMMODE_3BIT_MASK(mode); + } else { + pmctrl_count = 2; + mode_mask = PMMODE_2BIT_MASK(mode); + } + + if (bcm590xx_reg_is_secondary(pmu, reg_id)) + regmap = pmu->mfd->regmap_sec; + else + regmap = pmu->mfd->regmap_pri; + + for (i = 0; i < pmctrl_count; i++) { + ret = regmap_write(regmap, pmctrl_addr + i, mode_mask); + if (ret) + return ret; + } + + return 0; +} + +static int bcm590xx_regulator_enable(struct regulator_dev *rdev) +{ + struct bcm590xx_reg *pmu = rdev->reg_data; + + return _bcm590xx_set_pmmode(pmu, rdev->desc->id, BCM590XX_PMMODE_ON); +} + +static int bcm590xx_regulator_disable(struct regulator_dev *rdev) +{ + struct bcm590xx_reg *pmu = rdev->reg_data; + + return _bcm590xx_set_pmmode(pmu, rdev->desc->id, BCM590XX_PMMODE_OFF); +} + static const struct regulator_ops bcm590xx_ops_ldo = { .is_enabled = regulator_is_enabled_regmap, - .enable = regulator_enable_regmap, - .disable = regulator_disable_regmap, + .enable = bcm590xx_regulator_enable, + .disable = bcm590xx_regulator_disable, .get_voltage_sel = regulator_get_voltage_sel_regmap, .set_voltage_sel = regulator_set_voltage_sel_regmap, .list_voltage = regulator_list_voltage_table, @@ -553,8 +625,8 @@ static const struct regulator_ops bcm590xx_ops_ldo = { static const struct regulator_ops bcm590xx_ops_dcdc = { .is_enabled = regulator_is_enabled_regmap, - .enable = regulator_enable_regmap, - .disable = regulator_disable_regmap, + .enable = bcm590xx_regulator_enable, + .disable = bcm590xx_regulator_disable, .get_voltage_sel = regulator_get_voltage_sel_regmap, .set_voltage_sel = regulator_set_voltage_sel_regmap, .list_voltage = regulator_list_voltage_linear_range, @@ -563,8 +635,8 @@ static const struct regulator_ops bcm590xx_ops_dcdc = { static const struct regulator_ops bcm590xx_ops_static = { .is_enabled = regulator_is_enabled_regmap, - .enable = regulator_enable_regmap, - .disable = regulator_disable_regmap, + .enable = bcm590xx_regulator_enable, + .disable = bcm590xx_regulator_disable, }; static int bcm590xx_probe(struct platform_device *pdev) @@ -633,7 +705,7 @@ static int bcm590xx_probe(struct platform_device *pdev) pmu->desc[i].enable_is_inverted = true; } pmu->desc[i].enable_reg = \ - bcm590xx_get_enable_register(pmu, i); + bcm590xx_get_pmctrl_register(pmu, i); pmu->desc[i].type = REGULATOR_VOLTAGE; pmu->desc[i].owner = THIS_MODULE;