From patchwork Mon Oct 30 19:36:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artur Weber X-Patchwork-Id: 13440839 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 EB676C4332F for ; Mon, 30 Oct 2023 19:37:42 +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=0AWwS1fj5dBH+v wa7uPkGixpJChQVfuvRaf//61wAtBmW9g5F2qgQExt0bsVxVSpdk8SYgJ3P79YDWQ4IhFb684mFNp hrNcSy3UC+7XO7ybtpe97qqVI6EoB7KNhOnOdG8OKW+8gZgz+/OqhCOS/0iWEmRbifAffU+fFeazK ZeEvReEfiPKHD5d6gFlAXQIwg8XWQGXHS0PbCVRVJnmbNJQ+ZdF+GONC4gSLai5+zzd/rkVPFPEre 01XWiPDdlXqGlpXUY8JKcgmdNPmDREXOaq0uj7n5gmK/7f6PNB39MkSdzmvO1g5Z2sNQbvXbEkLkh DgXDwyRojeUKpFKI6eQg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qxY4d-003waS-0W; Mon, 30 Oct 2023 19:37:19 +0000 Received: from mail-lf1-x136.google.com ([2a00:1450:4864:20::136]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qxY4H-003wPc-15; Mon, 30 Oct 2023 19:37:00 +0000 Received: by mail-lf1-x136.google.com with SMTP id 2adb3069b0e04-507a3b8b113so7050701e87.0; Mon, 30 Oct 2023 12:36:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698694612; x=1699299412; 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=Dyp3TZOOOhJHLb3ckoX+L1zUzI+eTe3swFt5o8IQ0FOyV+o95DtExCUI84U8qipv75 Jg0g/DO0zPoJsC7p2W9Qt1aE+2Snb5oO1Yog/HEUsB7N0qj/+wtRKUxsh8BOh1SPV41h CyjUCvw/rqdC62JsqWaUW/9TN8Bq/l0gMRRiI7Y7zdzg6+BT+I3oYY9nrCR91QHFzSsM 8/CPpxbbuYZKGQMyOqC6ywW/NU2+uNauyMpRGq7EJtUJ9QtnsCAV31KOsN9RFUSP2K/e iYBLXD/zKiqrL3cvlF83/VYP5ELauf5g5VAN6eVITC5d3uSupj1+/I08IMi/4iU6/39h Drpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698694612; x=1699299412; 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=pzjcCuKLuQqO/oyfwVSwSobXYpuqba/qVabaVMLc1DN4SyQuIZInjuIRZv8Q3WDHwT eQ24jR1fneD6qXe6VIp2pBlcwHxI6SqU0rOn92qCBvT7vAtIOboBV2IUG3KDdIreDS1v QadNp7RPKNSZ2GnFOcSzR86j8LBQKSTr1S47PG+BVXEfZp0iD8bvzSgrT53qHDmqqTko RViiSfI80XoiKz1VGEUUZx/Bt0Vhz1FTjY9Dx9mwDL8dr0TwPUNpKsrs17cAKJ5oIdlf lPy6AI/VUhASXke91/7heo6WArr1E4mYG7bK2XW8UVbWV0cYBR7aPn54ek4DaGehb+z5 LwWQ== X-Gm-Message-State: AOJu0YxkFdNnG14DecLQ3Te4D/KXdxkQj4mhl73Z8N8Jygu/4UFtyoTI /gEQw+s+l0OOrqBi8oHeYqA= X-Google-Smtp-Source: AGHT+IHYbNe4KBt+CBTopPnMMMZtMSCUiv8wrfgJIVyNXLh+MeRN2a7zjDK6KPfXhkRi+LHbdUhLhg== X-Received: by 2002:a05:6512:489a:b0:502:9fce:b6d4 with SMTP id eq26-20020a056512489a00b005029fceb6d4mr7018134lfb.25.1698694612133; Mon, 30 Oct 2023 12:36:52 -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 a27-20020ac2521b000000b0050482b29ac8sm1510781lfl.31.2023.10.30.12.36.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 12:36:51 -0700 (PDT) From: Artur Weber Date: Mon, 30 Oct 2023 20:36:38 +0100 Subject: [PATCH 1/6] dt-bindings: mfd: brcm,bcm59056: Convert to YAML MIME-Version: 1.0 Message-Id: <20231030-bcm59054-v1-1-3517f980c1e3@gmail.com> References: <20231030-bcm59054-v1-0-3517f980c1e3@gmail.com> In-Reply-To: <20231030-bcm59054-v1-0-3517f980c1e3@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-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Artur Weber X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1698694608; l=4521; i=aweber.kernel@gmail.com; s=20231030; h=from:subject:message-id; bh=Y62BQBGtAcPv02Fu046rbEKVHmHWcxt/VeMRr4coqwE=; b=NXn9onAcbC7xKz6CkbyIxg5LEEu9GFFO0hSS76/oKuLrVrPcz57N+/GGBvnxVJPYP/i02U1hu RnJrwGYM67tDIxoQUuTf/QZUxB0QkMPSRR+FqKBij5kYBfJHDe4kBy8 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_123657_378109_DB17B240 X-CRM114-Status: GOOD ( 14.37 ) 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:36:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artur Weber X-Patchwork-Id: 13440837 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 D8242C4332F for ; Mon, 30 Oct 2023 19:37:25 +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=c4Wb0XV1UANz0T 94kKSxY7EwU4n0kq8S5prOpS9GBW48DRuAxdM5dLHMOO48TBsHN1GOJ2iSuqvUnYhHM4uj53BzYI8 gtrIXBUzHXryvyz9ez52A8eWANaJc16MGs58NUVfVVUs4c1eeRASiv/dv8kk2UDUiE0MRYqdiDcMe KFtKyEnxlL2DQvKTNWBAYn6tW90outxxvnGRGsU7BTWPIVnUDR4dbV5XU/NMAOkaYH/DQ4VZdW2+z j1Z4GiZUJ9s7IWyipHXIKd+AgIIzxx7QqvjQW427alkVjHyjjyctLjKLLg73+2l5zQIFEtEWhhwZ+ x1U7In4lXuqeVPTTb25A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qxY4K-003wSS-2z; Mon, 30 Oct 2023 19:37:00 +0000 Received: from mail-lf1-x134.google.com ([2a00:1450:4864:20::134]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qxY4H-003wPl-0J; Mon, 30 Oct 2023 19:36:58 +0000 Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-507b96095abso7016044e87.3; Mon, 30 Oct 2023 12:36:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698694614; x=1699299414; 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=aVA1tlAMIdu34kD1UWbEaMkmuF8cyHiNnTRxGCelrXOyK2ZKRNcIKrsiRJ91D1NcxE w11sCXeuLHwGL9u3TyUEacH357loj/ZidWUE3cSQ37bAAGY4CipPiOU/g2R6sxOLHzfn tz5jMqiz8qulhZDj8t9s/9Cu8/zxz+F7jIGM4340F8NT8LpNPz4/15HkFyzMMvkK07YJ fxBDq7oxzVQw2xdPYWEq4yXPX+xIFkQ8AccFvwbEn5cqqvqQlKezfwoxaT8Cg66kgump UImS7uhXqg28b4uUsKjL9V2gKWTdwhX1QdoXlw5Wy+oEXcN1UjsA2365q4o6JGkpT09i WVcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698694614; x=1699299414; 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=l6a/NTGvztdBkS789BZADe0eeVCf0a8Kxxg/O61IaVwCEtATy2VDFTB0r2Z+jGt79i lmSdVDOuyYdHTtGS6oPl9rsvYrueOMutoHjvfzFrqjwai7dNPIqNmE3TdBduCkZJSonA Aod8BKTUtKGFXFDtsV5C1msa2xoz1e3PeJ87Ib16nMFh55/JLurI9iCVGdu0b+AAjsNc +RjoKWswkZQ5gUFdG1rZRegPT4fVZiMA9+OQ04rVaSPLtvoUha8TsNGEKhABOY4Mx+DO JtSud0AFX/xRdnT9IgGkKqt2an0tY/SutK7ytT6Km4sozXiYAQtp9bYI96IHbQyR/UrV EKrg== X-Gm-Message-State: AOJu0Yzj5SVA0OfsjiA8W88jTrkgfXE1XcANbS7FFR31iUagnhs2BWWU jtCjcgjlbKvyy//WzM68Hog= X-Google-Smtp-Source: AGHT+IFB+RKv2I5H6bnmHVz+Aw2ioB6q7i0G0n1NYuRW/nXkfYXYrsukRucFQUg8sOwllWzNENVKKA== X-Received: by 2002:a05:6512:1107:b0:508:1178:efa4 with SMTP id l7-20020a056512110700b005081178efa4mr9370551lfg.55.1698694613737; Mon, 30 Oct 2023 12:36: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 a27-20020ac2521b000000b0050482b29ac8sm1510781lfl.31.2023.10.30.12.36.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 12:36:53 -0700 (PDT) From: Artur Weber Date: Mon, 30 Oct 2023 20:36:39 +0100 Subject: [PATCH 2/6] dt-bindings: mfd: brcm,bcm59056: Add compatible for BCM59054 MIME-Version: 1.0 Message-Id: <20231030-bcm59054-v1-2-3517f980c1e3@gmail.com> References: <20231030-bcm59054-v1-0-3517f980c1e3@gmail.com> In-Reply-To: <20231030-bcm59054-v1-0-3517f980c1e3@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-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Artur Weber X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1698694608; l=4952; i=aweber.kernel@gmail.com; s=20231030; h=from:subject:message-id; bh=J5qoqMtHdHEbtDpozL70617xHH15jYDWQN+WwVZOQIk=; b=CpQns/5NHRryN35mhzpRZ+QiuHTlaUGPSZFCWeE6W3Z8X9lMl5FOSeWs+7HRasA6qKs7eWOcJ 8oyHAAdrH3xCipZMdjS0mBZ0GxHEdOmrenJwRdWMVZdvFBP8uxydgTm 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_123657_138653_C8B1BEAB X-CRM114-Status: UNSURE ( 9.61 ) X-CRM114-Notice: Please train this message. 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:36:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artur Weber X-Patchwork-Id: 13440840 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 B36ACC4332F for ; Mon, 30 Oct 2023 19:37:46 +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=mQJZkAStxh00r+ LYlFAxUDEM5CWqmAnhrVxPnnlAiV9JA7fNUKwZNSqsJ8q36hiCA+KwLWvjHf4BsnxkjQQCEOXWYa6 1+pu5yTHsBsXrXfqpnIEGV8yWHziRC731I5/UwWHNjQ4D1BHdCdFSU4tqJ3RlAnxnuYzHOnQZ4Pnn 1FNTOozozuZUPVv8UHC9qBgyYKFRS6k3Av8gDRUU/4cmLJqfNlFQaAKASQfELktWw2ugehY+6iEac PtlHubkHUF21jA/6mX9gXMtc8gRg6glfFWZjzopBdHvXOXoVpq+W5CbBwTbTLniZAzdtVys1yfG+3 A0DN6xJ0rbXywL5+i4nA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qxY4c-003wa5-20; Mon, 30 Oct 2023 19:37:18 +0000 Received: from mail-lf1-x131.google.com ([2a00:1450:4864:20::131]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qxY4H-003wPu-1I; Mon, 30 Oct 2023 19:37:00 +0000 Received: by mail-lf1-x131.google.com with SMTP id 2adb3069b0e04-507d1cc0538so6752448e87.2; Mon, 30 Oct 2023 12:36:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698694615; x=1699299415; 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=WaEQqM8mAQBhclauSunICWOnJpMLJD+zwlc7Jm+M1/Q1gKcdI1G40NbjqLgv9gMNrW hqx1y+vK0bdOMoy7ARid1bRvdpxTqxVccEUq8pgiACshw9Kj5NnbCLycd9vjQH0PSP4b XjvndaWLmrLOgiWZZ6Ttequ2ahUa+px2PdYfykEJE4AcJNUnusYvpF/CM48KeqohUxJo U56JNq8LuibK1nzck0jNalAwgdIkuFPrvN+jaH7WlAafvJbyhEHNR5caMRQPYZLDHQMw Rc3oh4ZOFMySh3E8qJiCu2YyQWKPy1CJiex3syC7Z/Xup1Q1BlvlmozSeuYWnNqhxAwb qV1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698694615; x=1699299415; 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=PRy4BTrBN/ygRVnoohoqVIlVsN27HAomNjwiqys1RrNHggTCqSEuzinKWBAL/U9g2q yKF8J0lXc5Cfa9xWp6FgP50HFwoqlAnILb/j1FBeGBNlDV15cr7NhX7gIVfN8LF8KkX+ 99MNgl1kDLuUgmA5haqwF6Evpc6dLj4vHq5jZXjTH8GMUuseWJLIzvQDmRL6t3mBm13h mHvLfPA6k7zwv8rZE8x32YZIk2MD8YvyrpWmZfGotnk46xaZen5IWa+edYCr38PjD9/E 8sKvXtbDckAg1/9d6LlXB35aBuqrfb8Pr4ZBl/Pk9aekT1vH1k51h7pGZzmuNHOZ9uLY N3LA== X-Gm-Message-State: AOJu0Yzc0qXkK8qN8qM3m4GDG6PV7G9pk5lKnglg4BrjhMbY3wDkhkQM frxZma/h8B1Vpzr8oJl93mU= X-Google-Smtp-Source: AGHT+IH4tyRtZxoFgaCdcYiyDVNGjcMgbv6ArWgd/XQf8AUJ2MXWhaZebmU+QV/0TBLyx0L18j6UVw== X-Received: by 2002:a05:6512:3e09:b0:503:19d8:8dc3 with SMTP id i9-20020a0565123e0900b0050319d88dc3mr9284816lfv.31.1698694615292; Mon, 30 Oct 2023 12:36: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 a27-20020ac2521b000000b0050482b29ac8sm1510781lfl.31.2023.10.30.12.36.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 12:36:54 -0700 (PDT) From: Artur Weber Date: Mon, 30 Oct 2023 20:36:40 +0100 Subject: [PATCH 3/6] ARM: dts: Drop DTS for BCM59056 PMIC MIME-Version: 1.0 Message-Id: <20231030-bcm59054-v1-3-3517f980c1e3@gmail.com> References: <20231030-bcm59054-v1-0-3517f980c1e3@gmail.com> In-Reply-To: <20231030-bcm59054-v1-0-3517f980c1e3@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-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Artur Weber X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1698694608; l=3995; i=aweber.kernel@gmail.com; s=20231030; h=from:subject:message-id; bh=DBtpuYO/zr95rgnLU/rQbbV2xjIrUTq43L7BHBrPA9U=; b=hZdG9wUjwVxv+mKU8AxupCxa7wqP/eesbom+u4x00YcCHX2XrH7KzI07mJSBw3r5HgIZBwjah DN7mNasV6LeCrxA/gv2MoC855gyUl/PFMS7JhkQ8aXq3b+MPu7jsmk3 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_123657_445469_4B473D51 X-CRM114-Status: GOOD ( 12.51 ) 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:36:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artur Weber X-Patchwork-Id: 13440841 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 75742C4167D for ; Mon, 30 Oct 2023 19:37: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: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=euFRsjZfUVHL6q D3EKlZqC2ZTld3fJgrEVeY5cyceJ/aUtIIJEaavov+I7G5QwzU75WpuPgFAUIz75MNcx1hS3BW/DK j2mx+aH6soxI0xmizMKkHpA/jo9GNFi733EermPh4XMCpIs01ODbuvShx77uaQB3XXQzXwBrviQpr VIFp24aQsLGr9VpkVfsDuO2xlr+kdNPzqX76z+JcCgEjM5l+1PKB/AyIX8Smt0MWPFQ9KRbidVY7V LZmCoYlkp3iYDhZ587Md20mq8jnSX7ES/3KDa7Mjl71YhpgrGwx/KH2qeRdEcfBBSf5UeAv7SI4N9 /Eg9glKr4DVZwoLGiA7A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qxY4e-003wb4-0b; Mon, 30 Oct 2023 19:37:20 +0000 Received: from mail-lf1-x133.google.com ([2a00:1450:4864:20::133]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qxY4K-003wR8-08; Mon, 30 Oct 2023 19:37:01 +0000 Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-5079f6efd64so6819045e87.2; Mon, 30 Oct 2023 12:36:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698694617; x=1699299417; 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=gp6ug4JNHUSBW/6mYYpAN8w+b14kTqOBbF/0kcNOirjMNUMFV0VmfpaitpQf+ap/32 fV3kCNlMH005QCnOJVDykXoe9tRPdvUnA6h9YJDbINZ07vsaZX0HoKD0P5TrcWsiohlL vMcIxPAgVfpyYOImK7d3VwVnK1aHLQfdiYZBAT/hvV90/qkaYmPpeCOCz7J4VV7Zebem BbhI2WblCd93IcI1i0QSh8Rc2w75WzTfCAylQW7UPYRds51Htsc0T9tDwjqUVXXkH60/ pFQI7nMBSJe+BbLrYKBzPRFWR1h54nDwz2ln+7LzF4HT4XKEGP8RznL3pDNHQLpNh14M Yyhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698694617; x=1699299417; 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=gKQlDxdYAPn03CG7pevChuk2QPg1lwicVPdaiZhYxhAvxIAzJGK4H2nurIU+Gawxh1 MHFxE4mpjy76fV4H9Q1mAWV1OKHBvMUnXJfyTtRi/t89QBa23NBCiUoxPyg5hxsdnttF 0tXicl/Ls37gp17hGeQl3saCM+DxDFCq0gPJP7ZyYfrr8eXNvdi2tiyimeYnW8x/AjOV Xq4xleUWcko5fcRJNMeoUklmwea2/nHRcS46tjIdDyzfLkQ2zJZGa79aIiGSEN/3hTfF sI+577NESoHBZtCcSgNQaKwFRcjwG2N2LXvz3GfS+KMenNjqOAQ1a7joy/DLiyhaVlLO lRAg== X-Gm-Message-State: AOJu0YxQtMzXkPobnLZHIuQOd33+7xQbmYi+iiSB9RITxxm58H4yQStP WEEBpJhIH6xT1PkK+3Ap8wQ= X-Google-Smtp-Source: AGHT+IEFYLc0LWk2+gubsWmVoJUJJhCLxugkEYB/uIxSQB6LHNJIH24jVFny2uBAM3G+f/x8iu3Jjw== X-Received: by 2002:ac2:424f:0:b0:502:9a2c:f766 with SMTP id m15-20020ac2424f000000b005029a2cf766mr7192644lfl.30.1698694616903; Mon, 30 Oct 2023 12:36:56 -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 a27-20020ac2521b000000b0050482b29ac8sm1510781lfl.31.2023.10.30.12.36.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 12:36:56 -0700 (PDT) From: Artur Weber Date: Mon, 30 Oct 2023 20:36:41 +0100 Subject: [PATCH 4/6] mfd: bcm590xx: Add compatible for BCM59054 MIME-Version: 1.0 Message-Id: <20231030-bcm59054-v1-4-3517f980c1e3@gmail.com> References: <20231030-bcm59054-v1-0-3517f980c1e3@gmail.com> In-Reply-To: <20231030-bcm59054-v1-0-3517f980c1e3@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-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Artur Weber X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1698694608; l=1936; i=aweber.kernel@gmail.com; s=20231030; h=from:subject:message-id; bh=GaZAs1pHOm9g/5MXQbdGtce8n4JeiRhmO5EZ2BKjVhk=; b=iXnXR/iUSsOy5Qa5LWnXMndbYTWYQ0arqnxQ5RAfnU1nadKV2ZmXXoLfF5IdKOLigzM8FZ/6i NxuD1yo/ADECA98t5VkRwFb8psKKdYFIGg5911KUgycrohoLdBS8NHv 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_123700_075839_8FFE84AA X-CRM114-Status: GOOD ( 16.86 ) 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:36:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artur Weber X-Patchwork-Id: 13440843 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 4F26CC4332F for ; Mon, 30 Oct 2023 19:38:13 +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=i6PmEvN2bmyQGp RHYN0cyK6gheSBiEPAAklG84/29WsG1bER66mdxYzfnoLO79vXYNMDDsBjokyBQ7hjEFQDmySz5Hp OElQLChpPo5zFCmsBCOr8nB1QwVcvyB/uk8dueJf97Hyhgt5HKQ8CUPzYVglDWYSM6A3mxzgkbAxD KiaotIfpq126pq1fqreWarDEsf9rUex1itfOyF2+Yxrbb2Cj5o0lXxeMN5TU454ga8G+V+egYKMfw ONQiq5jDGV1gxcdyS4lliVqdM4dAycsDoO6qjvSqibada0EOAHmZ9qK6HUMse3sL/F7/jWnhYVvb6 PcrUDLSMw5Jg1R2UwYUg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qxY53-003wjz-0e; Mon, 30 Oct 2023 19:37:45 +0000 Received: from mail-lj1-x231.google.com ([2a00:1450:4864:20::231]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qxY4P-003wTO-2v; Mon, 30 Oct 2023 19:37:09 +0000 Received: by mail-lj1-x231.google.com with SMTP id 38308e7fff4ca-2c6b30acacdso32126351fa.2; Mon, 30 Oct 2023 12:37:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698694619; x=1699299419; 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=Pu7dIXkNlJrU1iG5i6UMH88rJG6X3acJEPCa8CrjVn1Y6CurgcaxBzTDQrqjOv3vir LHbqHoF68uPLo+3iaEyEL6CIud/Sva8QXuLsbF8GpkhRCuMwQ4mGlakISs8EaOjKrjIY moGyzl/GoDVPMEF9d5wyci1zXdKGmVWu87me/ZlmWCw/u2hNqRVV3lBtWd/ca87saWfV nK2zeiYZ7D5s8hoGTuHBcFcOxqMBgrS6OaTB+xc0nlZOtt2RJ6PM46VrUyYsKuQL6uim +kO9SRYA/ccZiCpgX/+WBlg8WRNpT/9wakBo4xfCSPb4K5f48Qr3kNW2++xidl+gJhh8 JHKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698694619; x=1699299419; 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=aVq4RVbDCUkQr98HFi3OmQ4q0CaXriXjAH5xDOoi8Ud984ynh2NGKBM+KZQ46lcBFX 88RgE07wQCJR4BS+HyI3Lu3+BpS23KAZyr5M+IMAgcUwwNUJpFebylVgb66utNt/Efxf +pd5vljouklh0G8APRLY80fszwnkG3w/TGBxz9HAtpXUZMTnQ4gWInxUtlSVSAjucDCf /RyG2uXx60wFu8Wua7EGXsnlgsQAvZRYKaRAw0xra2tYR0FT0f3WJFIpTU8AL0SnxS19 gFJdt9ru+El7oVJcENunRF2L5pC01ZB4Zl3mkhNj8voXoUESCfqlL25zFRb6/GsZ8S1P NqTg== X-Gm-Message-State: AOJu0YxSksyeWyxym+3pWrQGjheEcHRf45ZzUJBxzBPp7UGP5RwKHwRr c0s7HXOyYLtuWog2dmv78QQ= X-Google-Smtp-Source: AGHT+IFjAfTRF7Z5S5TvcRlo1LcgavZ2GsIv4KF44urDAfOXEd0pFMELvOHq+y9eoxMOo2w9Pp4UmA== X-Received: by 2002:ac2:4982:0:b0:509:d86:fb2c with SMTP id f2-20020ac24982000000b005090d86fb2cmr4519162lfl.58.1698694618550; Mon, 30 Oct 2023 12:36:58 -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 a27-20020ac2521b000000b0050482b29ac8sm1510781lfl.31.2023.10.30.12.36.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 12:36:58 -0700 (PDT) From: Artur Weber Date: Mon, 30 Oct 2023 20:36:42 +0100 Subject: [PATCH 5/6] regulator: bcm590xx: Add support for BCM59054 MIME-Version: 1.0 Message-Id: <20231030-bcm59054-v1-5-3517f980c1e3@gmail.com> References: <20231030-bcm59054-v1-0-3517f980c1e3@gmail.com> In-Reply-To: <20231030-bcm59054-v1-0-3517f980c1e3@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-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Artur Weber X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1698694609; l=25592; i=aweber.kernel@gmail.com; s=20231030; h=from:subject:message-id; bh=Vcld9l2CUccXXlMEKsE/QRX28i7sxc2Cj+81kZnastM=; b=I7E3jM0U+2Pr1ZGIQOUAO1WDPZ9JI75vWZXHUFRy3uXRWEIZuL7tE4DXsQXvqrf6tA6l2uJXh OtjgaGlbPy8BqomOVt1Ud8U9gJNkeKcGvcQFSnuHzwrAityvc0MnsjL 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_123705_954409_69C7F15D X-CRM114-Status: GOOD ( 16.65 ) 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:36: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: 13440842 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 BFD99C4332F for ; Mon, 30 Oct 2023 19:38:08 +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=HemXwpS9t5NQuCn6e05VJ4MfUpnkIUiQzHCExMstMTQ=; b=NCg2mNl6mJKIV8 KPEDd5WPejzicZloNXFSkF8Tqwgm0SeCyxMiQE58wXssbjoC21c6QQ/F+XZ5D1SQA8FidA1AGjfg4 Z27BhhmrMXlF7/MtQF21/m5Po3zplX+0YZ4gS+RIdskMiQsv6RK8T9w55D6c9tDu9Qs4HqjUeUpdw G9c5idB4XBSYpE1Rk34yiaxx9gPeRPvTZK7oV/TREmKrFwwZELze9UlGPEcKdRLvROIyemfj5J0wO +0QXIn+vI6tHytxfQIgJ/EzJFrh2PvLi3kRCpuTDbtxm6vwZ7M9SfUHZNfeCNAPk4RVZkp2NX0kd8 ESFLyzyMPdQfWdA2dzkA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qxY52-003wjd-29; Mon, 30 Oct 2023 19:37:44 +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 1qxY4O-003wSR-0B; Mon, 30 Oct 2023 19:37:06 +0000 Received: by mail-lf1-x12f.google.com with SMTP id 2adb3069b0e04-507bd64814fso6773009e87.1; Mon, 30 Oct 2023 12:37:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698694620; x=1699299420; 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=uwXnAshIuXsmpFP6ZIFMKGGNeGj7WNhS2BXuQMS+QJM=; b=bdle2w/ktxH3/XSHF8ALaou8WNi9cBINb+zsridj4R85aPn7ni4D/Jvo/yqMUlHrzA She0y8oi7Tm3lbU+5vqlB3tJ1wsoXgYE+FOK5lzv0zDTDhh6vd2+JQzuhb4uXH1Ny7kj zzhmNSIphz+8IQiYf5bW+Y+KDsrnSbT5/DKN/LBmqkXpRGEpr5/jC3NhliObuCjgfgjc I2Sck9xVdlgentDUzGAV6aYiEfUbzt40ImB+LVRWWZzuEfumYgCXz/1U+PxIubr9SxFR 1ztFQq7pU4iSQEfpMKbgezhzijFYJhezt4ZgpwriBqXSPzOriWCJboRLcE/dUGGshXCz 2gHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698694620; x=1699299420; 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=uwXnAshIuXsmpFP6ZIFMKGGNeGj7WNhS2BXuQMS+QJM=; b=L8aAkjRXmzAPnijkmwEv0z7qbxImA3hjDj5lyIGlDbE5jLlsmdoXOeDn+w0zI5tePD nwZNzfxaK6ULINnJj40/L+I0BCw1iVYN2Ny6KPiWI+BrXaL4xjXwSidm0ZG8veN7OO7l igKnHW3xEaNglU2AlRcvEm9pEFF6z0MYxBEIrke1ErdZ8ng/neFUpPLcAZ7OIGl25+Cx Jh7MO5GGLuhGhOSZghhoUugIrKyP3roIHfVgJdHCN6Q/1EdNGZ6h/53+p+4T2m4MjAOR Vb281zNwSCZyzGWCWhpTRlSAUurSZKFiu9g+FSxo7NK5XJnQ8muaCYa1RYtiXfTNqy8I jTJQ== X-Gm-Message-State: AOJu0YwrV6NMXS8vUkDqWpIVibxCQieJKwSXFP7TNB4hUS7Ir3LxF8De v1g8TEtb1Okm92s6vYCfgTl9Q3ZG3ehbhw== X-Google-Smtp-Source: AGHT+IFvIxIDhwho7uMSNNRiwCjSCpofIojv/AfGtUzON6IrmgPM1/93uYFq5GGdgiAuQgoPfwaekA== X-Received: by 2002:a05:6512:2356:b0:505:73e7:b478 with SMTP id p22-20020a056512235600b0050573e7b478mr10105643lfu.16.1698694620093; Mon, 30 Oct 2023 12:37:00 -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 a27-20020ac2521b000000b0050482b29ac8sm1510781lfl.31.2023.10.30.12.36.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 12:36:59 -0700 (PDT) From: Artur Weber Date: Mon, 30 Oct 2023 20:36:43 +0100 Subject: [PATCH 6/6] regulator: bcm590xx: Add proper handling for PMMODE registers MIME-Version: 1.0 Message-Id: <20231030-bcm59054-v1-6-3517f980c1e3@gmail.com> References: <20231030-bcm59054-v1-0-3517f980c1e3@gmail.com> In-Reply-To: <20231030-bcm59054-v1-0-3517f980c1e3@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-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Artur Weber X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1698694609; l=7020; i=aweber.kernel@gmail.com; s=20231030; h=from:subject:message-id; bh=vGWxlubqG22n2W7FyOydxEYR5xcja22aiT/FglbYjSU=; b=LwTI49czaQgXy+5jSMH/AMrNyEFElVZMMqdxn1sCgPGj+Y3HhWVjJ0Sydd/AngGQTBqtPYJji Yd7moFxuDFTAeY5jsQnH7/Go9Jq0QJ+Yzkp4x33aatFhGTA2OcU8c+c 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_123704_112661_39AD0B62 X-CRM114-Status: GOOD ( 24.54 ) 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 | 100 ++++++++++++++++++++++++++++----- 1 file changed, 86 insertions(+), 14 deletions(-) diff --git a/drivers/regulator/bcm590xx-regulator.c b/drivers/regulator/bcm590xx-regulator.c index 8b90eae06ca6..af1ab8735ea7 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 */ @@ -435,16 +444,16 @@ static int bcm590xx_get_vsel_register(struct bcm590xx_reg *pmu, int id) 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); + return BCM59056_RFLDOCTRL + (id - BCM59054_REG_RFLDO); else if (bcm590xx_reg_is_gpldo(pmu, id)) - return BCM59056_GPLDO1CTRL + (id - BCM59056_REG_GPLDO1); + return BCM59056_GPLDO1CTRL + (id - BCM59054_REG_GPLDO1); else return BCM59056_CSRVOUT1 + (id - BCM59056_REG_CSR) * 3; } 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;