From nobody Thu Nov 14 06:15:59 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 03A0DC83005 for ; Fri, 9 Jun 2023 08:32:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240110AbjFIIcN (ORCPT ); Fri, 9 Jun 2023 04:32:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240846AbjFIIbR (ORCPT ); Fri, 9 Jun 2023 04:31:17 -0400 Received: from mail-il1-x12f.google.com (mail-il1-x12f.google.com [IPv6:2607:f8b0:4864:20::12f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C4F31FEC for ; Fri, 9 Jun 2023 01:30:40 -0700 (PDT) Received: by mail-il1-x12f.google.com with SMTP id e9e14a558f8ab-33e53672aa6so6594935ab.1 for ; Fri, 09 Jun 2023 01:30:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1686299437; x=1688891437; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6mun1nGQ80ZyVZjdi0M4IzGfNqFd85FTe1SFditmWTE=; b=CocMFGYDJ28ZQWX5/Zb+FWOJDAAQ8XIC34Mc06ztwspA6x7UOg9DlOAYTqPm8CZpHw dIi8y8dHV2bbmb3Mh+rDMd7prp+hWGQ1XdDLsMOx6QuXcgGyiFLn5LnJq+3ZptBy6g2D 5BhgwyaKRjPBGEcMy9y/35wR02MRZ9JHVlYjY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686299437; x=1688891437; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6mun1nGQ80ZyVZjdi0M4IzGfNqFd85FTe1SFditmWTE=; b=OB4UTh13JeReapjgbz68oA0PI7ldALxEbeBhZrpLtTgO/G+k9scgRNM5UvNnsR9XNh 8+XZP82Q56+HiP5f4KxkZFadZmgwLYG5a5Q+vQkR+qr0YdPQoqiqHY5A6fzXIJk4d6k+ xHw/trFik7f9ajsF/+eC2fwPiNht3w1jPDbDONw0/TuqFPeO0KzjheRQQO26UB+on45e c4apFKjRDEyv25w1T5amx94D7zM6QxNOwK6bUI10XFJ4hA4CR0sCN3/4Fr5f1qyhzZUF YF9clOBy/sBC9UloOhYLtuCEvtqaE1gzRD2/KYU2pn/v36FJCqdJQlWEDbqV8/hybqOp qLdw== X-Gm-Message-State: AC+VfDz7c0aVFE31FpEBScteMcyGMKZzkbV/52RinlAILc+hQEBkLc/j AOy6pvZh/rRQVHVNtbePu94lUQ== X-Google-Smtp-Source: ACHHUZ4xGILPF6LRehHfcnbwmynkR+03VjZMBahqygYIt5vljilPzTSm4E0iZ0dYLkUzfyQF4wBwuA== X-Received: by 2002:a05:6e02:4cf:b0:335:fef6:6b76 with SMTP id f15-20020a056e0204cf00b00335fef66b76mr1159316ils.6.1686299437720; Fri, 09 Jun 2023 01:30:37 -0700 (PDT) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:c2ea:d8e4:1fe8:21f0]) by smtp.gmail.com with ESMTPSA id 23-20020aa79157000000b0063b806b111csm2184327pfi.169.2023.06.09.01.30.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jun 2023 01:30:37 -0700 (PDT) From: Chen-Yu Tsai To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Mark Brown , Liam Girdwood , Matthias Brugger , AngeloGioacchino Del Regno Cc: Chen-Yu Tsai , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/9] regulator: dt-bindings: mt6358: Merge ldo_vcn33_* regulators Date: Fri, 9 Jun 2023 16:29:58 +0800 Message-ID: <20230609083009.2822259-2-wenst@chromium.org> X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog In-Reply-To: <20230609083009.2822259-1-wenst@chromium.org> References: <20230609083009.2822259-1-wenst@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The ldo_vcn33_bt and ldo_vcn33_wifi regulators are actually the same regulator, having the same voltage setting and output pin. There are simply two enable bits that are ORed together to enable the regulator. Having two regulators representing the same output pin is misleading from a design matching standpoint, and also error-prone in driver implementations. Merge the two as ldo_vcn33. Neither vcn33 regulators are referenced in upstream device trees. As far as hardware designs go, none of the Chromebooks using MT8183 w/ MT6358 use this output. Signed-off-by: Chen-Yu Tsai Acked-by: Krzysztof Kozlowski Reviewed-by: Matthias Brugger --- .../bindings/regulator/mt6358-regulator.txt | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/Documentation/devicetree/bindings/regulator/mt6358-regulator.t= xt b/Documentation/devicetree/bindings/regulator/mt6358-regulator.txt index 7034cdca54e0..b22b956d1cbe 100644 --- a/Documentation/devicetree/bindings/regulator/mt6358-regulator.txt +++ b/Documentation/devicetree/bindings/regulator/mt6358-regulator.txt @@ -15,8 +15,7 @@ LDO: ldo_vcamd, ldo_vcn18, ldo_vfe28, ldo_vsram_proc11, ldo_vcn28, ldo_vsram_= others, ldo_vsram_others_sshub, ldo_vsram_gpu, ldo_vxo22, ldo_vefuse, ldo_vaux18, ldo_vmch, ldo_vbif28, ldo_vsram_proc12, ldo_vcama1, ldo_vemc, ldo_vio28,= ldo_va12, - ldo_vrf18, ldo_vcn33_bt, ldo_vcn33_wifi, ldo_vcama2, ldo_vmc, ldo_vldo28= , ldo_vaud28, - ldo_vsim2 + ldo_vrf18, ldo_vcn33, ldo_vcama2, ldo_vmc, ldo_vldo28, ldo_vaud28, ldo_v= sim2 =20 Example: =20 @@ -305,15 +304,8 @@ Example: regulator-enable-ramp-delay =3D <120>; }; =20 - mt6358_vcn33_bt_reg: ldo_vcn33_bt { - regulator-name =3D "vcn33_bt"; - regulator-min-microvolt =3D <3300000>; - regulator-max-microvolt =3D <3500000>; - regulator-enable-ramp-delay =3D <270>; - }; - - mt6358_vcn33_wifi_reg: ldo_vcn33_wifi { - regulator-name =3D "vcn33_wifi"; + mt6358_vcn33_reg: ldo_vcn33 { + regulator-name =3D "vcn33"; regulator-min-microvolt =3D <3300000>; regulator-max-microvolt =3D <3500000>; regulator-enable-ramp-delay =3D <270>; --=20 2.41.0.162.gfafddb0af9-goog From nobody Thu Nov 14 06:15:59 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6D8EFC87FE2 for ; Fri, 9 Jun 2023 08:32:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240817AbjFIIcU (ORCPT ); Fri, 9 Jun 2023 04:32:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240860AbjFIIbS (ORCPT ); Fri, 9 Jun 2023 04:31:18 -0400 Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84D323A81 for ; Fri, 9 Jun 2023 01:30:41 -0700 (PDT) Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-6563ccf5151so1613240b3a.0 for ; Fri, 09 Jun 2023 01:30:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1686299440; x=1688891440; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pV7h1an/oO2QW199ipAcSJcet1wN/x+kczYWmCEHXCs=; b=b0G1iIy8jk/1e2oWh3myUohkTqLjDg0Tq4CI+kRftvzNkQ+LNJSu9h43XZZDqjHAcF aVFHd6NQRs/njmFY3G5znn5uTEUTh8V7mtbk62R4LQdUwfocAsD1FguzA4P6CavM94M6 81xCOIZEPqOUAAig7M5fAjSrPCkXkQO5Lpl9o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686299440; x=1688891440; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pV7h1an/oO2QW199ipAcSJcet1wN/x+kczYWmCEHXCs=; b=jLuv6DUhzbHOAAHGLHX+MW4whdl7TvhanwajOsWkJxqG1L0pPqXoVgRDhZT4NuoEEW e33CRJ6pUlCHh8DynlR4gno7FuEJh1P1sn0kIZTP02b5t6dg3S8fxa8tO+BSIPUCqsrV WyQkP+jzeytjVF2Lw4MAwBl0dkyyw3/n0EYJRWEQPhSf0H7bp8uR+9MUG2Q+8bUEWDNL HH3t6O2IrVkykffervxP9m4IGWfBjogJEU8F1TmnKa3hKGNO0A3d9O/iXN9GyJ+Kl8rd rGLQJba66TYNIkPvny3fpoEXZtDDOsbT6HWM/OoGdLVICBs8c0qoAMZcutSMzHKhfDEK Z6Sw== X-Gm-Message-State: AC+VfDzj457ssoLXmmAXSiRBmkfGbI8Ig5YMUqGi3v1Did26NDuJJ/0g +6xFgxxSItvsFsWAJXQmgWpemg== X-Google-Smtp-Source: ACHHUZ7p3XkQr5FHYZbK/Vmz8eSNTD+4ARfbwf52+TqDOmtzhBxLxHEzsmwDfC/hfUuoqPRfSuN+wg== X-Received: by 2002:a05:6a00:1783:b0:662:c48b:47e2 with SMTP id s3-20020a056a00178300b00662c48b47e2mr922501pfg.19.1686299440039; Fri, 09 Jun 2023 01:30:40 -0700 (PDT) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:c2ea:d8e4:1fe8:21f0]) by smtp.gmail.com with ESMTPSA id 23-20020aa79157000000b0063b806b111csm2184327pfi.169.2023.06.09.01.30.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jun 2023 01:30:39 -0700 (PDT) From: Chen-Yu Tsai To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Mark Brown , Liam Girdwood , Matthias Brugger , AngeloGioacchino Del Regno Cc: Chen-Yu Tsai , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/9] regulator: dt-bindings: mt6358: Drop *_sshub regulators Date: Fri, 9 Jun 2023 16:29:59 +0800 Message-ID: <20230609083009.2822259-3-wenst@chromium.org> X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog In-Reply-To: <20230609083009.2822259-1-wenst@chromium.org> References: <20230609083009.2822259-1-wenst@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The *_sshub regulators are actually alternate configuration interfaces for their non *_sshub counterparts. They are not separate regulator outputs. These registers are intended for the companion processor to use to configure the power rails while the main processor is sleeping. They are not intended for the main operating system to use. Since they are not real outputs they shouldn't be modeled separately. Remove them. Luckily no device tree actually uses them. Signed-off-by: Chen-Yu Tsai Acked-by: Krzysztof Kozlowski Reviewed-by: Matthias Brugger --- .../bindings/regulator/mt6358-regulator.txt | 22 +++++-------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/Documentation/devicetree/bindings/regulator/mt6358-regulator.t= xt b/Documentation/devicetree/bindings/regulator/mt6358-regulator.txt index b22b956d1cbe..b6384306db5c 100644 --- a/Documentation/devicetree/bindings/regulator/mt6358-regulator.txt +++ b/Documentation/devicetree/bindings/regulator/mt6358-regulator.txt @@ -8,14 +8,14 @@ Documentation/devicetree/bindings/regulator/regulator.txt. =20 The valid names for regulators are:: BUCK: - buck_vdram1, buck_vcore, buck_vcore_sshub, buck_vpa, buck_vproc11, - buck_vproc12, buck_vgpu, buck_vs2, buck_vmodem, buck_vs1 + buck_vdram1, buck_vcore, buck_vpa, buck_vproc11, buck_vproc12, buck_vgpu, + buck_vs2, buck_vmodem, buck_vs1 LDO: ldo_vdram2, ldo_vsim1, ldo_vibr, ldo_vrf12, ldo_vio18, ldo_vusb, ldo_vca= mio, ldo_vcamd, ldo_vcn18, ldo_vfe28, ldo_vsram_proc11, ldo_vcn28, ldo_vsram_= others, - ldo_vsram_others_sshub, ldo_vsram_gpu, ldo_vxo22, ldo_vefuse, ldo_vaux18, - ldo_vmch, ldo_vbif28, ldo_vsram_proc12, ldo_vcama1, ldo_vemc, ldo_vio28,= ldo_va12, - ldo_vrf18, ldo_vcn33, ldo_vcama2, ldo_vmc, ldo_vldo28, ldo_vaud28, ldo_v= sim2 + ldo_vsram_gpu, ldo_vxo22, ldo_vefuse, ldo_vaux18, ldo_vmch, ldo_vbif28, + ldo_vsram_proc12, ldo_vcama1, ldo_vemc, ldo_vio28, ldo_va12, ldo_vrf18, + ldo_vcn33, ldo_vcama2, ldo_vmc, ldo_vldo28, ldo_vaud28, ldo_vsim2 =20 Example: =20 @@ -346,17 +346,5 @@ Example: regulator-max-microvolt =3D <3100000>; regulator-enable-ramp-delay =3D <540>; }; - - mt6358_vcore_sshub_reg: buck_vcore_sshub { - regulator-name =3D "vcore_sshub"; - regulator-min-microvolt =3D <500000>; - regulator-max-microvolt =3D <1293750>; - }; - - mt6358_vsram_others_sshub_reg: ldo_vsram_others_sshub { - regulator-name =3D "vsram_others_sshub"; - regulator-min-microvolt =3D <500000>; - regulator-max-microvolt =3D <1293750>; - }; }; }; --=20 2.41.0.162.gfafddb0af9-goog From nobody Thu Nov 14 06:15:59 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5DFB1C87FE7 for ; Fri, 9 Jun 2023 08:32:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240655AbjFIIcQ (ORCPT ); Fri, 9 Jun 2023 04:32:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240885AbjFIIbT (ORCPT ); Fri, 9 Jun 2023 04:31:19 -0400 Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A0052134 for ; Fri, 9 Jun 2023 01:30:44 -0700 (PDT) Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-662b85f4640so1253686b3a.0 for ; Fri, 09 Jun 2023 01:30:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1686299442; x=1688891442; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vqxK91xXLVCmyIE2hj+zcOaCJHi9/iXuXSTsY2AWMsY=; b=HKEhHSvW+XGShwykMDWBYvXaSN432HhV7S+TskFxFGAV689Sin+0Aiws8R8dDhC0r0 zuujnLGLNb9rG4YjqWbnoNFd/CJUWeKsYvVlA262xSTmlmzf5YM1R6JpLf6C6Q+r+ndG xlqCBMsM7tDYqAEkvAuoe4vxLMbOQXrlxn5EA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686299442; x=1688891442; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vqxK91xXLVCmyIE2hj+zcOaCJHi9/iXuXSTsY2AWMsY=; b=gU6vPu1GFfvOn7UuTamTz7Qvbfq/g17YMjTI2oz7SqnKfFRR5d2B3LodCi7RZmn+2Z o5Nl6Z79jI0J5hqASXCGwh3S5i8zp8PXMEUuq/k9x0sR38ZTkNvoReyrIE0IE0Pd6fBZ sovDtCZu1wLoSWdVc2R6sUNW/rysWNf+EuxgXO2VaxjhNwRrISvA+H+YUm+dxpjxr9L3 y7CsNeMj19hhFwl+z4u60hg7XaxQqYrkhrViTBs1wGJkbDRHw4iA0pqVJg7/cI1RmvTv S7Wy1jLMI5g+eadYQQACSAj67OfMWxveZm7MVwcx5F98AvkwAxAs/6/PV/JG54j+2+bI nCRQ== X-Gm-Message-State: AC+VfDz4DxQKuTelLTew5wfKt9JDXN8VG6PFLxT6P09OSJgA3EazWF2f Bsot9yp3Ksq7X8DkqFJfzI4Ryg== X-Google-Smtp-Source: ACHHUZ6YMqjtq8gGiDzkbMNQ/MHSSYVCOEJDCYDPRfCczx0TmFk+RepR0z45VJZLZcnHXWZANi7t9A== X-Received: by 2002:a05:6a00:21d6:b0:644:d775:60bb with SMTP id t22-20020a056a0021d600b00644d77560bbmr508528pfj.20.1686299442388; Fri, 09 Jun 2023 01:30:42 -0700 (PDT) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:c2ea:d8e4:1fe8:21f0]) by smtp.gmail.com with ESMTPSA id 23-20020aa79157000000b0063b806b111csm2184327pfi.169.2023.06.09.01.30.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jun 2023 01:30:42 -0700 (PDT) From: Chen-Yu Tsai To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Mark Brown , Liam Girdwood , Matthias Brugger , AngeloGioacchino Del Regno Cc: Chen-Yu Tsai , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/9] regulator: mt6358: Merge VCN33_* regulators Date: Fri, 9 Jun 2023 16:30:00 +0800 Message-ID: <20230609083009.2822259-4-wenst@chromium.org> X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog In-Reply-To: <20230609083009.2822259-1-wenst@chromium.org> References: <20230609083009.2822259-1-wenst@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The VCN33_BT and VCN33_WIFI regulators are actually the same regulator, having the same voltage setting and output pin. There are simply two enable bits that are ORed together to enable the regulator. Having two regulators representing the same output pin is misleading from a design matching standpoint, and also error-prone in driver implementations. If consumers try to set different voltages on either regulator, the one set later would override the one set before. There are ways around this, such as chaining them together and having the downstream one act as a switch. But given there's only one output pin, such a workaround doesn't match reality. Remove the VCN33_WIFI regulator. During the probe phase, have the driver sync the enable status of VCN33_WIFI to VCN33_BT. Also drop the suffix so that the regulator name matches the pin name in the datasheet. Signed-off-by: Chen-Yu Tsai --- drivers/regulator/mt6358-regulator.c | 65 +++++++++++++++++----- include/linux/regulator/mt6358-regulator.h | 6 +- 2 files changed, 52 insertions(+), 19 deletions(-) diff --git a/drivers/regulator/mt6358-regulator.c b/drivers/regulator/mt635= 8-regulator.c index c9e16bd092f6..faf6b0757019 100644 --- a/drivers/regulator/mt6358-regulator.c +++ b/drivers/regulator/mt6358-regulator.c @@ -277,7 +277,7 @@ static const unsigned int vcama_voltages[] =3D { 2800000, 2900000, 3000000, }; =20 -static const unsigned int vcn33_bt_wifi_voltages[] =3D { +static const unsigned int vcn33_voltages[] =3D { 3300000, 3400000, 3500000, }; =20 @@ -321,7 +321,7 @@ static const u32 vcama_idx[] =3D { 0, 7, 9, 10, 11, 12, }; =20 -static const u32 vcn33_bt_wifi_idx[] =3D { +static const u32 vcn33_idx[] =3D { 1, 2, 3, }; =20 @@ -566,12 +566,8 @@ static struct mt6358_regulator_info mt6358_regulators[= ] =3D { MT6358_LDO_VCAMA1_CON0, 0, MT6358_VCAMA1_ANA_CON0, 0xf00), MT6358_LDO("ldo_vemc", VEMC, vmch_vemc_voltages, vmch_vemc_idx, MT6358_LDO_VEMC_CON0, 0, MT6358_VEMC_ANA_CON0, 0x700), - MT6358_LDO("ldo_vcn33_bt", VCN33_BT, vcn33_bt_wifi_voltages, - vcn33_bt_wifi_idx, MT6358_LDO_VCN33_CON0_0, - 0, MT6358_VCN33_ANA_CON0, 0x300), - MT6358_LDO("ldo_vcn33_wifi", VCN33_WIFI, vcn33_bt_wifi_voltages, - vcn33_bt_wifi_idx, MT6358_LDO_VCN33_CON0_1, - 0, MT6358_VCN33_ANA_CON0, 0x300), + MT6358_LDO("ldo_vcn33", VCN33, vcn33_voltages, vcn33_idx, + MT6358_LDO_VCN33_CON0_0, 0, MT6358_VCN33_ANA_CON0, 0x300), MT6358_LDO("ldo_vcama2", VCAMA2, vcama_voltages, vcama_idx, MT6358_LDO_VCAMA2_CON0, 0, MT6358_VCAMA2_ANA_CON0, 0xf00), MT6358_LDO("ldo_vmc", VMC, vmc_voltages, vmc_idx, @@ -662,12 +658,8 @@ static struct mt6358_regulator_info mt6366_regulators[= ] =3D { MT6358_LDO_VMCH_CON0, 0, MT6358_VMCH_ANA_CON0, 0x700), MT6366_LDO("ldo_vemc", VEMC, vmch_vemc_voltages, vmch_vemc_idx, MT6358_LDO_VEMC_CON0, 0, MT6358_VEMC_ANA_CON0, 0x700), - MT6366_LDO("ldo_vcn33_bt", VCN33_BT, vcn33_bt_wifi_voltages, - vcn33_bt_wifi_idx, MT6358_LDO_VCN33_CON0_0, - 0, MT6358_VCN33_ANA_CON0, 0x300), - MT6366_LDO("ldo_vcn33_wifi", VCN33_WIFI, vcn33_bt_wifi_voltages, - vcn33_bt_wifi_idx, MT6358_LDO_VCN33_CON0_1, - 0, MT6358_VCN33_ANA_CON0, 0x300), + MT6366_LDO("ldo_vcn33", VCN33, vcn33_voltages, vcn33_idx, + MT6358_LDO_VCN33_CON0_0, 0, MT6358_VCN33_ANA_CON0, 0x300), MT6366_LDO("ldo_vmc", VMC, vmc_voltages, vmc_idx, MT6358_LDO_VMC_CON0, 0, MT6358_VMC_ANA_CON0, 0xf00), MT6366_LDO("ldo_vsim2", VSIM2, vsim_voltages, vsim_idx, @@ -690,13 +682,56 @@ static struct mt6358_regulator_info mt6366_regulators= [] =3D { MT6358_LDO_VSRAM_CON1, 0x7f), }; =20 +static int mt6358_sync_vcn33_setting(struct device *dev) +{ + struct mt6397_chip *mt6397 =3D dev_get_drvdata(dev->parent); + unsigned int val; + int ret; + + /* + * VCN33_WIFI and VCN33_BT are two separate enable bits for the same + * regulator. They share the same voltage setting and output pin. + * Instead of having two potentially conflicting regulators, just have + * one VCN33 regulator. Sync the two enable bits and only use one in + * the regulator device. + */ + ret =3D regmap_read(mt6397->regmap, MT6358_LDO_VCN33_CON0_1, &val); + if (ret) { + dev_err(dev, "Failed to read VCN33_WIFI setting\n"); + return ret; + } + + if (!(val & BIT(0))) + return 0; + + /* Sync VCN33_WIFI enable status to VCN33_BT */ + ret =3D regmap_update_bits(mt6397->regmap, MT6358_LDO_VCN33_CON0_0, BIT(0= ), BIT(0)); + if (ret) { + dev_err(dev, "Failed to sync VCN33_WIFI setting to VCN33_BT\n"); + return ret; + } + + /* Disable VCN33_WIFI */ + ret =3D regmap_update_bits(mt6397->regmap, MT6358_LDO_VCN33_CON0_1, BIT(0= ), 0); + if (ret) { + dev_err(dev, "Failed to disable VCN33_BT\n"); + return ret; + } + + return 0; +} + static int mt6358_regulator_probe(struct platform_device *pdev) { struct mt6397_chip *mt6397 =3D dev_get_drvdata(pdev->dev.parent); struct regulator_config config =3D {}; struct regulator_dev *rdev; struct mt6358_regulator_info *mt6358_info; - int i, max_regulator; + int i, max_regulator, ret; + + ret =3D mt6358_sync_vcn33_setting(&pdev->dev); + if (ret) + return ret; =20 if (mt6397->chip_id =3D=3D MT6366_CHIP_ID) { max_regulator =3D MT6366_MAX_REGULATOR; diff --git a/include/linux/regulator/mt6358-regulator.h b/include/linux/reg= ulator/mt6358-regulator.h index bdcf83cd719e..a4307cd9edd6 100644 --- a/include/linux/regulator/mt6358-regulator.h +++ b/include/linux/regulator/mt6358-regulator.h @@ -41,8 +41,7 @@ enum { MT6358_ID_VIO28, MT6358_ID_VA12, MT6358_ID_VRF18, - MT6358_ID_VCN33_BT, - MT6358_ID_VCN33_WIFI, + MT6358_ID_VCN33, MT6358_ID_VCAMA2, MT6358_ID_VMC, MT6358_ID_VLDO28, @@ -85,8 +84,7 @@ enum { MT6366_ID_VIO28, MT6366_ID_VA12, MT6366_ID_VRF18, - MT6366_ID_VCN33_BT, - MT6366_ID_VCN33_WIFI, + MT6366_ID_VCN33, MT6366_ID_VMC, MT6366_ID_VAUD28, MT6366_ID_VSIM2, --=20 2.41.0.162.gfafddb0af9-goog From nobody Thu Nov 14 06:15:59 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8388DC87FF1 for ; Fri, 9 Jun 2023 08:32:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240880AbjFIIcW (ORCPT ); Fri, 9 Jun 2023 04:32:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240899AbjFIIbU (ORCPT ); Fri, 9 Jun 2023 04:31:20 -0400 Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE2EC3A94 for ; Fri, 9 Jun 2023 01:30:46 -0700 (PDT) Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-64d44b198baso1184328b3a.0 for ; Fri, 09 Jun 2023 01:30:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1686299445; x=1688891445; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=11zc4FsjjThT9aF4m1qk+2IflC0iJrne6V3Jm40ZBR0=; b=WMoYiK/iXxPeqvuSRQWk/tYTcNjJU80QxtgpGB3hlLcCXiJQnqNF15avOkmQ0GpyLx eKy8+A8sRWAeorUOpjs6DmNg4x6M9M53n99aD7PcmPhHY7VafIuaT+b5NDGJ+TUXiofz eMoLcBQ1o8hK+kMDaGcJauXBShrpPGiPGuHMw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686299445; x=1688891445; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=11zc4FsjjThT9aF4m1qk+2IflC0iJrne6V3Jm40ZBR0=; b=YU+OlcynumVcdM2+ELzwa3uxbQi8AdcNh2zRDAUDM5GQ7KAbmVchEY/ahADBBON0pA mmqq72Hz/yVoTTbsPtPu/YH0XRYo51R4s0N2nWLLt6XV3rstlkFwkrAnk8Jo25UROyke Zyo7x3FyIDNYNZhG5PIZG0D0xY2r89bT9NLLRkJGJNJTyaX4zqZpDntkzVqdwcAuUo7R 2hNYpKh0uVccmBNI4aN/wVQv9sUeI7n3obYWAZ45eXo6FO+xHkjP3L+7H1ufBeNMWghd UAfGXO/BxecoImRoeiYC85+DCbHg0hrOorZUeS0mZs014Eu/E8j+vMfud5Ajo1wmosIZ xSqA== X-Gm-Message-State: AC+VfDxHERhqk2qb4PqGWiXC4GMSgK9+djrwEwHMq48Cd/9Eli+cbhIs 6mnU3OqJsJ8LA3J7DMeSjCYO2A== X-Google-Smtp-Source: ACHHUZ5xpoOoksvbDS28+5deuwiplC6Vp3HHVXsrSO8dFl4pdVvNkxHNkySvOoAhhlJXej2Ra8nmsg== X-Received: by 2002:a05:6a21:6d84:b0:116:fc1b:fa38 with SMTP id wl4-20020a056a216d8400b00116fc1bfa38mr1344531pzb.7.1686299444790; Fri, 09 Jun 2023 01:30:44 -0700 (PDT) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:c2ea:d8e4:1fe8:21f0]) by smtp.gmail.com with ESMTPSA id 23-20020aa79157000000b0063b806b111csm2184327pfi.169.2023.06.09.01.30.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jun 2023 01:30:44 -0700 (PDT) From: Chen-Yu Tsai To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Mark Brown , Liam Girdwood , Matthias Brugger , AngeloGioacchino Del Regno Cc: Chen-Yu Tsai , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/9] regulator: mt6358: Drop *_SSHUB regulators Date: Fri, 9 Jun 2023 16:30:01 +0800 Message-ID: <20230609083009.2822259-5-wenst@chromium.org> X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog In-Reply-To: <20230609083009.2822259-1-wenst@chromium.org> References: <20230609083009.2822259-1-wenst@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The *_SSHUB regulators are actually alternate configuration interfaces for their non *_SSHUB counterparts. They are not separate regulator outputs. These registers are intended for the companion processor to use to configure the power rails while the main processor is sleeping. They are not intended for the main operating system to use. Since they are not real outputs they shouldn't be modeled separately. Remove them. Luckily no device tree actually uses them. Signed-off-by: Chen-Yu Tsai Reviewed-by: AngeloGioacchino Del Regno Reviewed-by: Matthias Brugger --- drivers/regulator/mt6358-regulator.c | 14 -------------- include/linux/regulator/mt6358-regulator.h | 4 ---- 2 files changed, 18 deletions(-) diff --git a/drivers/regulator/mt6358-regulator.c b/drivers/regulator/mt635= 8-regulator.c index faf6b0757019..946a251a8b3a 100644 --- a/drivers/regulator/mt6358-regulator.c +++ b/drivers/regulator/mt6358-regulator.c @@ -505,9 +505,6 @@ static struct mt6358_regulator_info mt6358_regulators[]= =3D { MT6358_BUCK("buck_vcore", VCORE, 500000, 1293750, 6250, buck_volt_range1, 0x7f, MT6358_BUCK_VCORE_DBG0, 0x7f, MT6358_VCORE_VGPU_ANA_CON0, 1), - MT6358_BUCK("buck_vcore_sshub", VCORE_SSHUB, 500000, 1293750, 6250, - buck_volt_range1, 0x7f, MT6358_BUCK_VCORE_SSHUB_ELR0, 0x7f, - MT6358_VCORE_VGPU_ANA_CON0, 1), MT6358_BUCK("buck_vpa", VPA, 500000, 3650000, 50000, buck_volt_range3, 0x3f, MT6358_BUCK_VPA_DBG0, 0x3f, MT6358_VPA_ANA_CON0, 3), @@ -583,10 +580,6 @@ static struct mt6358_regulator_info mt6358_regulators[= ] =3D { MT6358_LDO1("ldo_vsram_others", VSRAM_OTHERS, 500000, 1293750, 6250, buck_volt_range1, MT6358_LDO_VSRAM_OTHERS_DBG0, 0x7f00, MT6358_LDO_VSRAM_CON2, 0x7f), - MT6358_LDO1("ldo_vsram_others_sshub", VSRAM_OTHERS_SSHUB, 500000, - 1293750, 6250, buck_volt_range1, - MT6358_LDO_VSRAM_OTHERS_SSHUB_CON1, 0x7f, - MT6358_LDO_VSRAM_OTHERS_SSHUB_CON1, 0x7f), MT6358_LDO1("ldo_vsram_gpu", VSRAM_GPU, 500000, 1293750, 6250, buck_volt_range1, MT6358_LDO_VSRAM_GPU_DBG0, 0x7f00, MT6358_LDO_VSRAM_CON3, 0x7f), @@ -603,9 +596,6 @@ static struct mt6358_regulator_info mt6366_regulators[]= =3D { MT6366_BUCK("buck_vcore", VCORE, 500000, 1293750, 6250, buck_volt_range1, 0x7f, MT6358_BUCK_VCORE_DBG0, 0x7f, MT6358_VCORE_VGPU_ANA_CON0, 1), - MT6366_BUCK("buck_vcore_sshub", VCORE_SSHUB, 500000, 1293750, 6250, - buck_volt_range1, 0x7f, MT6358_BUCK_VCORE_SSHUB_ELR0, 0x7f, - MT6358_VCORE_VGPU_ANA_CON0, 1), MT6366_BUCK("buck_vpa", VPA, 500000, 3650000, 50000, buck_volt_range3, 0x3f, MT6358_BUCK_VPA_DBG0, 0x3f, MT6358_VPA_ANA_CON0, 3), @@ -670,10 +660,6 @@ static struct mt6358_regulator_info mt6366_regulators[= ] =3D { MT6366_LDO1("ldo_vsram_others", VSRAM_OTHERS, 500000, 1293750, 6250, buck_volt_range1, MT6358_LDO_VSRAM_OTHERS_DBG0, 0x7f00, MT6358_LDO_VSRAM_CON2, 0x7f), - MT6366_LDO1("ldo_vsram_others_sshub", VSRAM_OTHERS_SSHUB, 500000, - 1293750, 6250, buck_volt_range1, - MT6358_LDO_VSRAM_OTHERS_SSHUB_CON1, 0x7f, - MT6358_LDO_VSRAM_OTHERS_SSHUB_CON1, 0x7f), MT6366_LDO1("ldo_vsram_gpu", VSRAM_GPU, 500000, 1293750, 6250, buck_volt_range1, MT6358_LDO_VSRAM_GPU_DBG0, 0x7f00, MT6358_LDO_VSRAM_CON3, 0x7f), diff --git a/include/linux/regulator/mt6358-regulator.h b/include/linux/reg= ulator/mt6358-regulator.h index a4307cd9edd6..c71a6a9fce7a 100644 --- a/include/linux/regulator/mt6358-regulator.h +++ b/include/linux/regulator/mt6358-regulator.h @@ -47,8 +47,6 @@ enum { MT6358_ID_VLDO28, MT6358_ID_VAUD28, MT6358_ID_VSIM2, - MT6358_ID_VCORE_SSHUB, - MT6358_ID_VSRAM_OTHERS_SSHUB, MT6358_ID_RG_MAX, }; =20 @@ -88,8 +86,6 @@ enum { MT6366_ID_VMC, MT6366_ID_VAUD28, MT6366_ID_VSIM2, - MT6366_ID_VCORE_SSHUB, - MT6366_ID_VSRAM_OTHERS_SSHUB, MT6366_ID_RG_MAX, }; =20 --=20 2.41.0.162.gfafddb0af9-goog From nobody Thu Nov 14 06:15:59 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 948FAC88C83 for ; Fri, 9 Jun 2023 08:32:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240952AbjFIIcZ (ORCPT ); Fri, 9 Jun 2023 04:32:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240914AbjFIIbV (ORCPT ); Fri, 9 Jun 2023 04:31:21 -0400 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D93803A9F for ; Fri, 9 Jun 2023 01:30:47 -0700 (PDT) Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-651e298be3fso1570316b3a.2 for ; Fri, 09 Jun 2023 01:30:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1686299447; x=1688891447; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Y20hfxdBlfIy/ItHN/HqfoEN5rlOgkF1Vq6pZHwBBZQ=; b=b1z1ImptZRD1QiXEaYQtBkKMiaM1FzlNwl9m2l0/VOouTX+wm5uYRm2cqqdIywDi3P wzrJ7EddFJviATlgeX9kWgCVwZciNX1ZoNozWzT9lc9gWLb6dNIASTx2pNtphn3V/ple MVgElzNSNJNs36hcTdccf0alSjZNX1fHWvlzI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686299447; x=1688891447; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Y20hfxdBlfIy/ItHN/HqfoEN5rlOgkF1Vq6pZHwBBZQ=; b=hs/ezg/+nYPuv6bA16DjGvnsFMBwcUaoa26nltkJKlN+2PhXfn6roJwafFJgZnMGEZ hGsvKeh0wPEsjl9mKuRqrK8sgsNhAAOV5qBTKVecRzVoQWJ4CFmvOcE0L0aqIm2o3tcM DLsbtpDTQavcU0pxjU2wNeTA35rG0lKEcm7rdBJD12gW2XkCwvdKe3UN5FHJcgIR50Yn NaGr2H2fGI7OTKS3NVwu7c7by7xWfTzXsuQnVawMW7vJsUuMmQYdlllxW+q9h4MiIdV0 1EIJ4Zu7TLkqV3lQ8OYRZgd1zbZuP93guC3Rtwp/3LT8OPaFTp9IrvOhU1rrvNtJoJjz /cvg== X-Gm-Message-State: AC+VfDzaHC/2nwD2DT2QWXRUemeXi3XCGnzGeKt4wofF+dWD52jSGd5K PQNN5UBwAa7WEzy6k1K8wEHeEQ== X-Google-Smtp-Source: ACHHUZ5Put2IsUN+JeMEl0ftnTU8g4YJZw9JRRCey+z+DaRPLycmDKsBgW74WLrRp8KgF+PhgfXgTg== X-Received: by 2002:a05:6a20:1606:b0:10f:708b:bb28 with SMTP id l6-20020a056a20160600b0010f708bbb28mr797120pzj.7.1686299447295; Fri, 09 Jun 2023 01:30:47 -0700 (PDT) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:c2ea:d8e4:1fe8:21f0]) by smtp.gmail.com with ESMTPSA id 23-20020aa79157000000b0063b806b111csm2184327pfi.169.2023.06.09.01.30.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jun 2023 01:30:46 -0700 (PDT) From: Chen-Yu Tsai To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Mark Brown , Liam Girdwood , Matthias Brugger , AngeloGioacchino Del Regno Cc: Chen-Yu Tsai , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/9] regulator: mt6358: Const-ify mt6358_regulator_info data structures Date: Fri, 9 Jun 2023 16:30:02 +0800 Message-ID: <20230609083009.2822259-6-wenst@chromium.org> X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog In-Reply-To: <20230609083009.2822259-1-wenst@chromium.org> References: <20230609083009.2822259-1-wenst@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" In the MT6358 regulator driver, each regulator is described by a |struct regulator_desc| wrapped by a |struct mt6358_regulator_info|. The latter was tied to the regulator device using the config's driver_data field, which meant that the variables could not be constant. Since each regulator device has a pointer to its regulator_desc, and mt6358_regulator_info wraps that, the driver could use container_of() to retrieve it instead. Switch to using container_of(), drop tha driver_data setting, and const-ify all the regulator descriptions. Signed-off-by: Chen-Yu Tsai --- drivers/regulator/mt6358-regulator.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/regulator/mt6358-regulator.c b/drivers/regulator/mt635= 8-regulator.c index 946a251a8b3a..2851ef53ac63 100644 --- a/drivers/regulator/mt6358-regulator.c +++ b/drivers/regulator/mt6358-regulator.c @@ -34,6 +34,8 @@ struct mt6358_regulator_info { u32 modeset_mask; }; =20 +#define to_regulator_info(x) container_of((x), struct mt6358_regulator_inf= o, desc) + #define MT6358_BUCK(match, vreg, min, max, step, \ volt_ranges, vosel_mask, _da_vsel_reg, _da_vsel_mask, \ _modeset_reg, _modeset_shift) \ @@ -342,9 +344,9 @@ static unsigned int mt6358_map_mode(unsigned int mode) static int mt6358_set_voltage_sel(struct regulator_dev *rdev, unsigned int selector) { + const struct mt6358_regulator_info *info =3D to_regulator_info(rdev->desc= ); int idx, ret; const u32 *pvol; - struct mt6358_regulator_info *info =3D rdev_get_drvdata(rdev); =20 pvol =3D info->index_table; =20 @@ -358,9 +360,9 @@ static int mt6358_set_voltage_sel(struct regulator_dev = *rdev, =20 static int mt6358_get_voltage_sel(struct regulator_dev *rdev) { + const struct mt6358_regulator_info *info =3D to_regulator_info(rdev->desc= ); int idx, ret; u32 selector; - struct mt6358_regulator_info *info =3D rdev_get_drvdata(rdev); const u32 *pvol; =20 ret =3D regmap_read(rdev->regmap, info->desc.vsel_reg, &selector); @@ -384,8 +386,8 @@ static int mt6358_get_voltage_sel(struct regulator_dev = *rdev) =20 static int mt6358_get_buck_voltage_sel(struct regulator_dev *rdev) { + const struct mt6358_regulator_info *info =3D to_regulator_info(rdev->desc= ); int ret, regval; - struct mt6358_regulator_info *info =3D rdev_get_drvdata(rdev); =20 ret =3D regmap_read(rdev->regmap, info->da_vsel_reg, ®val); if (ret !=3D 0) { @@ -402,9 +404,9 @@ static int mt6358_get_buck_voltage_sel(struct regulator= _dev *rdev) =20 static int mt6358_get_status(struct regulator_dev *rdev) { + const struct mt6358_regulator_info *info =3D to_regulator_info(rdev->desc= ); int ret; u32 regval; - struct mt6358_regulator_info *info =3D rdev_get_drvdata(rdev); =20 ret =3D regmap_read(rdev->regmap, info->status_reg, ®val); if (ret !=3D 0) { @@ -418,7 +420,7 @@ static int mt6358_get_status(struct regulator_dev *rdev) static int mt6358_regulator_set_mode(struct regulator_dev *rdev, unsigned int mode) { - struct mt6358_regulator_info *info =3D rdev_get_drvdata(rdev); + const struct mt6358_regulator_info *info =3D to_regulator_info(rdev->desc= ); int val; =20 switch (mode) { @@ -443,7 +445,7 @@ static int mt6358_regulator_set_mode(struct regulator_d= ev *rdev, =20 static unsigned int mt6358_regulator_get_mode(struct regulator_dev *rdev) { - struct mt6358_regulator_info *info =3D rdev_get_drvdata(rdev); + const struct mt6358_regulator_info *info =3D to_regulator_info(rdev->desc= ); int ret, regval; =20 ret =3D regmap_read(rdev->regmap, info->modeset_reg, ®val); @@ -498,7 +500,7 @@ static const struct regulator_ops mt6358_volt_fixed_ops= =3D { }; =20 /* The array is indexed by id(MT6358_ID_XXX) */ -static struct mt6358_regulator_info mt6358_regulators[] =3D { +static const struct mt6358_regulator_info mt6358_regulators[] =3D { MT6358_BUCK("buck_vdram1", VDRAM1, 500000, 2087500, 12500, buck_volt_range2, 0x7f, MT6358_BUCK_VDRAM1_DBG0, 0x7f, MT6358_VDRAM1_ANA_CON0, 8), @@ -589,7 +591,7 @@ static struct mt6358_regulator_info mt6358_regulators[]= =3D { }; =20 /* The array is indexed by id(MT6366_ID_XXX) */ -static struct mt6358_regulator_info mt6366_regulators[] =3D { +static const struct mt6358_regulator_info mt6366_regulators[] =3D { MT6366_BUCK("buck_vdram1", VDRAM1, 500000, 2087500, 12500, buck_volt_range2, 0x7f, MT6358_BUCK_VDRAM1_DBG0, 0x7f, MT6358_VDRAM1_ANA_CON0, 8), @@ -712,7 +714,7 @@ static int mt6358_regulator_probe(struct platform_devic= e *pdev) struct mt6397_chip *mt6397 =3D dev_get_drvdata(pdev->dev.parent); struct regulator_config config =3D {}; struct regulator_dev *rdev; - struct mt6358_regulator_info *mt6358_info; + const struct mt6358_regulator_info *mt6358_info; int i, max_regulator, ret; =20 ret =3D mt6358_sync_vcn33_setting(&pdev->dev); @@ -729,7 +731,6 @@ static int mt6358_regulator_probe(struct platform_devic= e *pdev) =20 for (i =3D 0; i < max_regulator; i++) { config.dev =3D &pdev->dev; - config.driver_data =3D &mt6358_info[i]; config.regmap =3D mt6397->regmap; =20 rdev =3D devm_regulator_register(&pdev->dev, --=20 2.41.0.162.gfafddb0af9-goog From nobody Thu Nov 14 06:15:59 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A46FCC87FF2 for ; Fri, 9 Jun 2023 08:32:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241019AbjFIIc3 (ORCPT ); Fri, 9 Jun 2023 04:32:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60570 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240970AbjFIIb2 (ORCPT ); Fri, 9 Jun 2023 04:31:28 -0400 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A272C4204 for ; Fri, 9 Jun 2023 01:30:53 -0700 (PDT) Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-65311774e52so1158190b3a.3 for ; Fri, 09 Jun 2023 01:30:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1686299449; x=1688891449; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hfBApkKJFoC1LAXLIDHIMvLkHHtkxFJ1T+708z95fzw=; b=l8aMM0p/UA1wQFt8yk6HMlhCR9W3WJlICkTKzNmjrwrJw4MI54RIo/Ai1uOkPIo9D3 BMSy+9T+qP1txmuTuyeqHPzHJZLsqfZZbcMjpZF4DIJxVqsoQvNms0QMvgOdCpAG76gG uHzlwXr88LeEhaaxSoQ6wWPbYBzv8RXREuOow= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686299449; x=1688891449; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hfBApkKJFoC1LAXLIDHIMvLkHHtkxFJ1T+708z95fzw=; b=VsswOXc0zefPCcuUAMY6AiB799F18HCBOqV2U+aBrk2VVwV2Ll9pQvHL6v3Lj5Elke dMd801UoYgVjrxQFD4+wJ8vDC+LKRfGS5cX4h5QvRsDh9MES56AXFTHDL+0yObFDnWJ/ SFDnKN7Tb8NZuOwM1G0DE3F0TbPhjm0vsMkvLQlAvESOgaM8ePI0ZrVJcIE3uZTdbDTt AxLePS5jBF4rM+eaTyl40vBvpfdqMQ5RoZ/YR39ulogrFjc+AnrBve3SSSMbiVuqYUxS WLTLajGdKOIauxScTrQvH1paViPRv75pGD3EohQfPfbrmRxyGAWYeg1a/Jx1IJf9fL4Y Nuww== X-Gm-Message-State: AC+VfDxhLwT2CY1pjY4ccZWvB/nPTlOVPrYWRk7D8FivYUciO7Ib78RH QVKuxf9yuzq1pVRaGjDuUOb6Pg== X-Google-Smtp-Source: ACHHUZ7vJ9BIbKrQXjopUBUG+0xKj1EqO3eRRU94itAGa4DToaoaq9ACVKLMXxLV0j4CWSWbQ5Jd/Q== X-Received: by 2002:a05:6a00:13a9:b0:65a:cbf3:4687 with SMTP id t41-20020a056a0013a900b0065acbf34687mr708335pfg.0.1686299449617; Fri, 09 Jun 2023 01:30:49 -0700 (PDT) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:c2ea:d8e4:1fe8:21f0]) by smtp.gmail.com with ESMTPSA id 23-20020aa79157000000b0063b806b111csm2184327pfi.169.2023.06.09.01.30.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jun 2023 01:30:49 -0700 (PDT) From: Chen-Yu Tsai To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Mark Brown , Liam Girdwood , Matthias Brugger , AngeloGioacchino Del Regno Cc: Chen-Yu Tsai , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 6/9] regulator: mt6358: Use linear voltage helpers for single range regulators Date: Fri, 9 Jun 2023 16:30:03 +0800 Message-ID: <20230609083009.2822259-7-wenst@chromium.org> X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog In-Reply-To: <20230609083009.2822259-1-wenst@chromium.org> References: <20230609083009.2822259-1-wenst@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Some of the regulators on the MT6358/MT6366 PMICs have just one linear voltage range. These are the bulk regulators and VSRAM_* LDOs. Currently they are modeled with one linear range, but also have their minimum, maximum, and step voltage described. Convert them to the linear voltage helpers. These helpers are a bit simpler, and we can also drop the linear range definitions. Also reflow the touched lines now that they are shorter. Signed-off-by: Chen-Yu Tsai --- drivers/regulator/mt6358-regulator.c | 121 +++++++++------------------ 1 file changed, 40 insertions(+), 81 deletions(-) diff --git a/drivers/regulator/mt6358-regulator.c b/drivers/regulator/mt635= 8-regulator.c index 2851ef53ac63..31a16fb28ecd 100644 --- a/drivers/regulator/mt6358-regulator.c +++ b/drivers/regulator/mt6358-regulator.c @@ -37,7 +37,7 @@ struct mt6358_regulator_info { #define to_regulator_info(x) container_of((x), struct mt6358_regulator_inf= o, desc) =20 #define MT6358_BUCK(match, vreg, min, max, step, \ - volt_ranges, vosel_mask, _da_vsel_reg, _da_vsel_mask, \ + vosel_mask, _da_vsel_reg, _da_vsel_mask, \ _modeset_reg, _modeset_shift) \ [MT6358_ID_##vreg] =3D { \ .desc =3D { \ @@ -48,8 +48,8 @@ struct mt6358_regulator_info { .id =3D MT6358_ID_##vreg, \ .owner =3D THIS_MODULE, \ .n_voltages =3D ((max) - (min)) / (step) + 1, \ - .linear_ranges =3D volt_ranges, \ - .n_linear_ranges =3D ARRAY_SIZE(volt_ranges), \ + .min_uV =3D (min), \ + .uV_step =3D (step), \ .vsel_reg =3D MT6358_BUCK_##vreg##_ELR0, \ .vsel_mask =3D vosel_mask, \ .enable_reg =3D MT6358_BUCK_##vreg##_CON0, \ @@ -89,7 +89,7 @@ struct mt6358_regulator_info { } =20 #define MT6358_LDO1(match, vreg, min, max, step, \ - volt_ranges, _da_vsel_reg, _da_vsel_mask, \ + _da_vsel_reg, _da_vsel_mask, \ vosel, vosel_mask) \ [MT6358_ID_##vreg] =3D { \ .desc =3D { \ @@ -100,8 +100,8 @@ struct mt6358_regulator_info { .id =3D MT6358_ID_##vreg, \ .owner =3D THIS_MODULE, \ .n_voltages =3D ((max) - (min)) / (step) + 1, \ - .linear_ranges =3D volt_ranges, \ - .n_linear_ranges =3D ARRAY_SIZE(volt_ranges), \ + .min_uV =3D (min), \ + .uV_step =3D (step), \ .vsel_reg =3D vosel, \ .vsel_mask =3D vosel_mask, \ .enable_reg =3D MT6358_LDO_##vreg##_CON0, \ @@ -133,7 +133,7 @@ struct mt6358_regulator_info { } =20 #define MT6366_BUCK(match, vreg, min, max, step, \ - volt_ranges, vosel_mask, _da_vsel_reg, _da_vsel_mask, \ + vosel_mask, _da_vsel_reg, _da_vsel_mask, \ _modeset_reg, _modeset_shift) \ [MT6366_ID_##vreg] =3D { \ .desc =3D { \ @@ -144,8 +144,8 @@ struct mt6358_regulator_info { .id =3D MT6366_ID_##vreg, \ .owner =3D THIS_MODULE, \ .n_voltages =3D ((max) - (min)) / (step) + 1, \ - .linear_ranges =3D volt_ranges, \ - .n_linear_ranges =3D ARRAY_SIZE(volt_ranges), \ + .min_uV =3D (min), \ + .uV_step =3D (step), \ .vsel_reg =3D MT6358_BUCK_##vreg##_ELR0, \ .vsel_mask =3D vosel_mask, \ .enable_reg =3D MT6358_BUCK_##vreg##_CON0, \ @@ -185,7 +185,7 @@ struct mt6358_regulator_info { } =20 #define MT6366_LDO1(match, vreg, min, max, step, \ - volt_ranges, _da_vsel_reg, _da_vsel_mask, \ + _da_vsel_reg, _da_vsel_mask, \ vosel, vosel_mask) \ [MT6366_ID_##vreg] =3D { \ .desc =3D { \ @@ -196,8 +196,8 @@ struct mt6358_regulator_info { .id =3D MT6366_ID_##vreg, \ .owner =3D THIS_MODULE, \ .n_voltages =3D ((max) - (min)) / (step) + 1, \ - .linear_ranges =3D volt_ranges, \ - .n_linear_ranges =3D ARRAY_SIZE(volt_ranges), \ + .min_uV =3D (min), \ + .uV_step =3D (step), \ .vsel_reg =3D vosel, \ .vsel_mask =3D vosel_mask, \ .enable_reg =3D MT6358_LDO_##vreg##_CON0, \ @@ -228,21 +228,6 @@ struct mt6358_regulator_info { .qi =3D BIT(15), \ } =20 -static const struct linear_range buck_volt_range1[] =3D { - REGULATOR_LINEAR_RANGE(500000, 0, 0x7f, 6250), -}; - -static const struct linear_range buck_volt_range2[] =3D { - REGULATOR_LINEAR_RANGE(500000, 0, 0x7f, 12500), -}; - -static const struct linear_range buck_volt_range3[] =3D { - REGULATOR_LINEAR_RANGE(500000, 0, 0x3f, 50000), -}; - -static const struct linear_range buck_volt_range4[] =3D { - REGULATOR_LINEAR_RANGE(1000000, 0, 0x7f, 12500), -}; =20 static const unsigned int vdram2_voltages[] =3D { 600000, 1800000, @@ -466,8 +451,8 @@ static unsigned int mt6358_regulator_get_mode(struct re= gulator_dev *rdev) } =20 static const struct regulator_ops mt6358_volt_range_ops =3D { - .list_voltage =3D regulator_list_voltage_linear_range, - .map_voltage =3D regulator_map_voltage_linear_range, + .list_voltage =3D regulator_list_voltage_linear, + .map_voltage =3D regulator_map_voltage_linear, .set_voltage_sel =3D regulator_set_voltage_sel_regmap, .get_voltage_sel =3D mt6358_get_buck_voltage_sel, .set_voltage_time_sel =3D regulator_set_voltage_time_sel, @@ -502,32 +487,23 @@ static const struct regulator_ops mt6358_volt_fixed_o= ps =3D { /* The array is indexed by id(MT6358_ID_XXX) */ static const struct mt6358_regulator_info mt6358_regulators[] =3D { MT6358_BUCK("buck_vdram1", VDRAM1, 500000, 2087500, 12500, - buck_volt_range2, 0x7f, MT6358_BUCK_VDRAM1_DBG0, 0x7f, - MT6358_VDRAM1_ANA_CON0, 8), + 0x7f, MT6358_BUCK_VDRAM1_DBG0, 0x7f, MT6358_VDRAM1_ANA_CON0, 8), MT6358_BUCK("buck_vcore", VCORE, 500000, 1293750, 6250, - buck_volt_range1, 0x7f, MT6358_BUCK_VCORE_DBG0, 0x7f, - MT6358_VCORE_VGPU_ANA_CON0, 1), + 0x7f, MT6358_BUCK_VCORE_DBG0, 0x7f, MT6358_VCORE_VGPU_ANA_CON0, 1), MT6358_BUCK("buck_vpa", VPA, 500000, 3650000, 50000, - buck_volt_range3, 0x3f, MT6358_BUCK_VPA_DBG0, 0x3f, - MT6358_VPA_ANA_CON0, 3), + 0x3f, MT6358_BUCK_VPA_DBG0, 0x3f, MT6358_VPA_ANA_CON0, 3), MT6358_BUCK("buck_vproc11", VPROC11, 500000, 1293750, 6250, - buck_volt_range1, 0x7f, MT6358_BUCK_VPROC11_DBG0, 0x7f, - MT6358_VPROC_ANA_CON0, 1), + 0x7f, MT6358_BUCK_VPROC11_DBG0, 0x7f, MT6358_VPROC_ANA_CON0, 1), MT6358_BUCK("buck_vproc12", VPROC12, 500000, 1293750, 6250, - buck_volt_range1, 0x7f, MT6358_BUCK_VPROC12_DBG0, 0x7f, - MT6358_VPROC_ANA_CON0, 2), + 0x7f, MT6358_BUCK_VPROC12_DBG0, 0x7f, MT6358_VPROC_ANA_CON0, 2), MT6358_BUCK("buck_vgpu", VGPU, 500000, 1293750, 6250, - buck_volt_range1, 0x7f, MT6358_BUCK_VGPU_ELR0, 0x7f, - MT6358_VCORE_VGPU_ANA_CON0, 2), + 0x7f, MT6358_BUCK_VGPU_ELR0, 0x7f, MT6358_VCORE_VGPU_ANA_CON0, 2), MT6358_BUCK("buck_vs2", VS2, 500000, 2087500, 12500, - buck_volt_range2, 0x7f, MT6358_BUCK_VS2_DBG0, 0x7f, - MT6358_VS2_ANA_CON0, 8), + 0x7f, MT6358_BUCK_VS2_DBG0, 0x7f, MT6358_VS2_ANA_CON0, 8), MT6358_BUCK("buck_vmodem", VMODEM, 500000, 1293750, 6250, - buck_volt_range1, 0x7f, MT6358_BUCK_VMODEM_DBG0, 0x7f, - MT6358_VMODEM_ANA_CON0, 8), + 0x7f, MT6358_BUCK_VMODEM_DBG0, 0x7f, MT6358_VMODEM_ANA_CON0, 8), MT6358_BUCK("buck_vs1", VS1, 1000000, 2587500, 12500, - buck_volt_range4, 0x7f, MT6358_BUCK_VS1_DBG0, 0x7f, - MT6358_VS1_ANA_CON0, 8), + 0x7f, MT6358_BUCK_VS1_DBG0, 0x7f, MT6358_VS1_ANA_CON0, 8), MT6358_REG_FIXED("ldo_vrf12", VRF12, MT6358_LDO_VRF12_CON0, 0, 1200000), MT6358_REG_FIXED("ldo_vio18", VIO18, @@ -577,48 +553,35 @@ static const struct mt6358_regulator_info mt6358_regu= lators[] =3D { MT6358_LDO("ldo_vsim2", VSIM2, vsim_voltages, vsim_idx, MT6358_LDO_VSIM2_CON0, 0, MT6358_VSIM2_ANA_CON0, 0xf00), MT6358_LDO1("ldo_vsram_proc11", VSRAM_PROC11, 500000, 1293750, 6250, - buck_volt_range1, MT6358_LDO_VSRAM_PROC11_DBG0, 0x7f00, - MT6358_LDO_VSRAM_CON0, 0x7f), + MT6358_LDO_VSRAM_PROC11_DBG0, 0x7f00, MT6358_LDO_VSRAM_CON0, 0x7f), MT6358_LDO1("ldo_vsram_others", VSRAM_OTHERS, 500000, 1293750, 6250, - buck_volt_range1, MT6358_LDO_VSRAM_OTHERS_DBG0, 0x7f00, - MT6358_LDO_VSRAM_CON2, 0x7f), + MT6358_LDO_VSRAM_OTHERS_DBG0, 0x7f00, MT6358_LDO_VSRAM_CON2, 0x7f), MT6358_LDO1("ldo_vsram_gpu", VSRAM_GPU, 500000, 1293750, 6250, - buck_volt_range1, MT6358_LDO_VSRAM_GPU_DBG0, 0x7f00, - MT6358_LDO_VSRAM_CON3, 0x7f), + MT6358_LDO_VSRAM_GPU_DBG0, 0x7f00, MT6358_LDO_VSRAM_CON3, 0x7f), MT6358_LDO1("ldo_vsram_proc12", VSRAM_PROC12, 500000, 1293750, 6250, - buck_volt_range1, MT6358_LDO_VSRAM_PROC12_DBG0, 0x7f00, - MT6358_LDO_VSRAM_CON1, 0x7f), + MT6358_LDO_VSRAM_PROC12_DBG0, 0x7f00, MT6358_LDO_VSRAM_CON1, 0x7f), }; =20 /* The array is indexed by id(MT6366_ID_XXX) */ static const struct mt6358_regulator_info mt6366_regulators[] =3D { MT6366_BUCK("buck_vdram1", VDRAM1, 500000, 2087500, 12500, - buck_volt_range2, 0x7f, MT6358_BUCK_VDRAM1_DBG0, 0x7f, - MT6358_VDRAM1_ANA_CON0, 8), + 0x7f, MT6358_BUCK_VDRAM1_DBG0, 0x7f, MT6358_VDRAM1_ANA_CON0, 8), MT6366_BUCK("buck_vcore", VCORE, 500000, 1293750, 6250, - buck_volt_range1, 0x7f, MT6358_BUCK_VCORE_DBG0, 0x7f, - MT6358_VCORE_VGPU_ANA_CON0, 1), + 0x7f, MT6358_BUCK_VCORE_DBG0, 0x7f, MT6358_VCORE_VGPU_ANA_CON0, 1), MT6366_BUCK("buck_vpa", VPA, 500000, 3650000, 50000, - buck_volt_range3, 0x3f, MT6358_BUCK_VPA_DBG0, 0x3f, - MT6358_VPA_ANA_CON0, 3), + 0x3f, MT6358_BUCK_VPA_DBG0, 0x3f, MT6358_VPA_ANA_CON0, 3), MT6366_BUCK("buck_vproc11", VPROC11, 500000, 1293750, 6250, - buck_volt_range1, 0x7f, MT6358_BUCK_VPROC11_DBG0, 0x7f, - MT6358_VPROC_ANA_CON0, 1), + 0x7f, MT6358_BUCK_VPROC11_DBG0, 0x7f, MT6358_VPROC_ANA_CON0, 1), MT6366_BUCK("buck_vproc12", VPROC12, 500000, 1293750, 6250, - buck_volt_range1, 0x7f, MT6358_BUCK_VPROC12_DBG0, 0x7f, - MT6358_VPROC_ANA_CON0, 2), + 0x7f, MT6358_BUCK_VPROC12_DBG0, 0x7f, MT6358_VPROC_ANA_CON0, 2), MT6366_BUCK("buck_vgpu", VGPU, 500000, 1293750, 6250, - buck_volt_range1, 0x7f, MT6358_BUCK_VGPU_ELR0, 0x7f, - MT6358_VCORE_VGPU_ANA_CON0, 2), + 0x7f, MT6358_BUCK_VGPU_ELR0, 0x7f, MT6358_VCORE_VGPU_ANA_CON0, 2), MT6366_BUCK("buck_vs2", VS2, 500000, 2087500, 12500, - buck_volt_range2, 0x7f, MT6358_BUCK_VS2_DBG0, 0x7f, - MT6358_VS2_ANA_CON0, 8), + 0x7f, MT6358_BUCK_VS2_DBG0, 0x7f, MT6358_VS2_ANA_CON0, 8), MT6366_BUCK("buck_vmodem", VMODEM, 500000, 1293750, 6250, - buck_volt_range1, 0x7f, MT6358_BUCK_VMODEM_DBG0, 0x7f, - MT6358_VMODEM_ANA_CON0, 8), + 0x7f, MT6358_BUCK_VMODEM_DBG0, 0x7f, MT6358_VMODEM_ANA_CON0, 8), MT6366_BUCK("buck_vs1", VS1, 1000000, 2587500, 12500, - buck_volt_range4, 0x7f, MT6358_BUCK_VS1_DBG0, 0x7f, - MT6358_VS1_ANA_CON0, 8), + 0x7f, MT6358_BUCK_VS1_DBG0, 0x7f, MT6358_VS1_ANA_CON0, 8), MT6366_REG_FIXED("ldo_vrf12", VRF12, MT6358_LDO_VRF12_CON0, 0, 1200000), MT6366_REG_FIXED("ldo_vio18", VIO18, @@ -657,17 +620,13 @@ static const struct mt6358_regulator_info mt6366_regu= lators[] =3D { MT6366_LDO("ldo_vsim2", VSIM2, vsim_voltages, vsim_idx, MT6358_LDO_VSIM2_CON0, 0, MT6358_VSIM2_ANA_CON0, 0xf00), MT6366_LDO1("ldo_vsram_proc11", VSRAM_PROC11, 500000, 1293750, 6250, - buck_volt_range1, MT6358_LDO_VSRAM_PROC11_DBG0, 0x7f00, - MT6358_LDO_VSRAM_CON0, 0x7f), + MT6358_LDO_VSRAM_PROC11_DBG0, 0x7f00, MT6358_LDO_VSRAM_CON0, 0x7f), MT6366_LDO1("ldo_vsram_others", VSRAM_OTHERS, 500000, 1293750, 6250, - buck_volt_range1, MT6358_LDO_VSRAM_OTHERS_DBG0, 0x7f00, - MT6358_LDO_VSRAM_CON2, 0x7f), + MT6358_LDO_VSRAM_OTHERS_DBG0, 0x7f00, MT6358_LDO_VSRAM_CON2, 0x7f), MT6366_LDO1("ldo_vsram_gpu", VSRAM_GPU, 500000, 1293750, 6250, - buck_volt_range1, MT6358_LDO_VSRAM_GPU_DBG0, 0x7f00, - MT6358_LDO_VSRAM_CON3, 0x7f), + MT6358_LDO_VSRAM_GPU_DBG0, 0x7f00, MT6358_LDO_VSRAM_CON3, 0x7f), MT6366_LDO1("ldo_vsram_proc12", VSRAM_PROC12, 500000, 1293750, 6250, - buck_volt_range1, MT6358_LDO_VSRAM_PROC12_DBG0, 0x7f00, - MT6358_LDO_VSRAM_CON1, 0x7f), + MT6358_LDO_VSRAM_PROC12_DBG0, 0x7f00, MT6358_LDO_VSRAM_CON1, 0x7f), }; =20 static int mt6358_sync_vcn33_setting(struct device *dev) --=20 2.41.0.162.gfafddb0af9-goog From nobody Thu Nov 14 06:15:59 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B55E0C88C85 for ; Fri, 9 Jun 2023 08:32:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241186AbjFIIcd (ORCPT ); Fri, 9 Jun 2023 04:32:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240978AbjFIIb2 (ORCPT ); Fri, 9 Jun 2023 04:31:28 -0400 Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5FC632712 for ; Fri, 9 Jun 2023 01:30:56 -0700 (PDT) Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-653f9c7b3e4so1184526b3a.2 for ; Fri, 09 Jun 2023 01:30:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1686299452; x=1688891452; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7N2GTAVTvejg4XyTSwRcmbBdgk1J778IcSYe2G8moyk=; b=jhiOWWyQyji2Fh7ueCNL9nKUQBwj8te65HJnaRK08rO8tB8OZiLAgJdxIiWj5tbUNz OFQS9ZqqPMzNmvrN/itYzZDHeeG2yef05RZtBC7sSub2qPk2bjSRlzEFHbFVKVSIcEXn 6o3koOM9dba2BZJUpOBz3AQ608t4h9ILRdcHg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686299452; x=1688891452; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7N2GTAVTvejg4XyTSwRcmbBdgk1J778IcSYe2G8moyk=; b=CijauDtTqHtRnuewcAReH1Fj/BSKoKRUfLkxQ8cF9aBs9zZP24sKZeQk4lFETkbRuH e5A9CgA1nqX4lqwi+cygEVOTelc+1UoxsGOZApQQFwlC+A8P5qtME7OcfwxZ9xb9vcm1 hBx9iCdH+gmVYTIf8CFKSW7897tYfr5Omya3EM45X83jNYMvv6UNe9L6+TC9hGzu9H/7 CpqbbQqcuXmbsHmrYw9Fb1pG7GfZGQQZtOqcPPGqgAUgHfYNHA5T76/s1+8K3DUeV9DY NDwOFwmYfXxdutR6BT087jlvNGxoJHV/LKPcpTR/Xe5zXPvcPsVRYDcCv/33INvBxMTy RQHg== X-Gm-Message-State: AC+VfDw3/a2kLCjXl7F6GggCfmLnbVHfId/j5cOLGvz7vMUgN2n9fArF mIN/V3amJtjLcoYITrTctPVQjw== X-Google-Smtp-Source: ACHHUZ5lDIRC/zAwCIUKvqzUz89u9ILnKYLfuUpakL+u3IyTJ/LdwHmfnWZrLngRPiMikJDodvdkjQ== X-Received: by 2002:a05:6a00:1408:b0:65b:945:f221 with SMTP id l8-20020a056a00140800b0065b0945f221mr468676pfu.34.1686299451909; Fri, 09 Jun 2023 01:30:51 -0700 (PDT) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:c2ea:d8e4:1fe8:21f0]) by smtp.gmail.com with ESMTPSA id 23-20020aa79157000000b0063b806b111csm2184327pfi.169.2023.06.09.01.30.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jun 2023 01:30:51 -0700 (PDT) From: Chen-Yu Tsai To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Mark Brown , Liam Girdwood , Matthias Brugger , AngeloGioacchino Del Regno Cc: Chen-Yu Tsai , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 7/9] regulator: mt6358: Add output voltage fine tuning to fixed regulators Date: Fri, 9 Jun 2023 16:30:04 +0800 Message-ID: <20230609083009.2822259-8-wenst@chromium.org> X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog In-Reply-To: <20230609083009.2822259-1-wenst@chromium.org> References: <20230609083009.2822259-1-wenst@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The "fixed" LDO regulators found on the MT6358 and MT6366 PMICs have either no voltage selection register, or only one valid setting. However these do have a fine voltage calibration setting that can slightly boost the output voltage from 0 mV to 100 mV, in 10 mV increments. Add support for this by changing these into linear range regulators. Signed-off-by: Chen-Yu Tsai Reviewed-by: AngeloGioacchino Del Regno --- drivers/regulator/mt6358-regulator.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/regulator/mt6358-regulator.c b/drivers/regulator/mt635= 8-regulator.c index 31a16fb28ecd..26060909cf90 100644 --- a/drivers/regulator/mt6358-regulator.c +++ b/drivers/regulator/mt6358-regulator.c @@ -123,10 +123,13 @@ struct mt6358_regulator_info { .type =3D REGULATOR_VOLTAGE, \ .id =3D MT6358_ID_##vreg, \ .owner =3D THIS_MODULE, \ - .n_voltages =3D 1, \ + .n_voltages =3D 11, \ + .vsel_reg =3D MT6358_##vreg##_ANA_CON0, \ + .vsel_mask =3D GENMASK(3, 0), \ .enable_reg =3D enreg, \ .enable_mask =3D BIT(enbit), \ .min_uV =3D volt, \ + .uV_step =3D 10000, \ }, \ .status_reg =3D MT6358_LDO_##vreg##_CON1, \ .qi =3D BIT(15), \ @@ -219,10 +222,13 @@ struct mt6358_regulator_info { .type =3D REGULATOR_VOLTAGE, \ .id =3D MT6366_ID_##vreg, \ .owner =3D THIS_MODULE, \ - .n_voltages =3D 1, \ + .n_voltages =3D 11, \ + .vsel_reg =3D MT6358_##vreg##_ANA_CON0, \ + .vsel_mask =3D GENMASK(3, 0), \ .enable_reg =3D enreg, \ .enable_mask =3D BIT(enbit), \ .min_uV =3D volt, \ + .uV_step =3D 10000, \ }, \ .status_reg =3D MT6358_LDO_##vreg##_CON1, \ .qi =3D BIT(15), \ @@ -476,8 +482,13 @@ static const struct regulator_ops mt6358_volt_table_op= s =3D { .get_status =3D mt6358_get_status, }; =20 +/* "Fixed" LDOs with output voltage calibration +0 ~ +10 mV */ static const struct regulator_ops mt6358_volt_fixed_ops =3D { .list_voltage =3D regulator_list_voltage_linear, + .map_voltage =3D regulator_map_voltage_linear, + .set_voltage_sel =3D regulator_set_voltage_sel_regmap, + .get_voltage_sel =3D mt6358_get_buck_voltage_sel, + .set_voltage_time_sel =3D regulator_set_voltage_time_sel, .enable =3D regulator_enable_regmap, .disable =3D regulator_disable_regmap, .is_enabled =3D regulator_is_enabled_regmap, --=20 2.41.0.162.gfafddb0af9-goog From nobody Thu Nov 14 06:15:59 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C5B66C88C84 for ; Fri, 9 Jun 2023 08:32:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241221AbjFIIci (ORCPT ); Fri, 9 Jun 2023 04:32:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240998AbjFIIbb (ORCPT ); Fri, 9 Jun 2023 04:31:31 -0400 Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B28DE2D7F for ; Fri, 9 Jun 2023 01:30:58 -0700 (PDT) Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-64d44b198baso1184444b3a.0 for ; Fri, 09 Jun 2023 01:30:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1686299454; x=1688891454; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=R4DshCBZIDkFYoMuhJgsoew8/ayv9n43XprldxD053E=; b=Ng1skn4wUaI2EyhPGGcvHwAlTbvhKPnC+365Lxgv3zVLRHwpuZpCAyMkEEcHuZHyZK KNunQENb189q94YDG4NV44A8RelzzNYpEYvQteguAf/Ry3iiJk9cjmZ8/nhjGZt0bP59 /u2vpDfhXSonLEcJig7+resY5rcqOxn3TIoeU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686299454; x=1688891454; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=R4DshCBZIDkFYoMuhJgsoew8/ayv9n43XprldxD053E=; b=W/cARBd37Xd2m7S1tNCSeZzOnuGAaySzkPyjHvk6UAhey9+SQHmOJ1GwDgJuU4Udjr qyRwDcpGuaGnqwLes+USjZEiU1KI5QFsXq51+jqnOg4JKZ8MM0qDqEliBQN3WcBKOFbg oZiVkRg46QISepV3UEFPXkXHPuvT5vv2UGacmD7fFk6dsT16L8X1SxT3DKfcGb3UATCD zVo+2Dz1LGBGDK4Ur1SM/YQlsg9qM1RDoXemVfw20MLwsjEVLKJclCdvDdLv0V4xSZ+T Kxy2A4nlUb0ijIjZx+obfsX0PPWvFol+8s4kPYMijMR+wnUb8SdqVBQa3qSxJ77Oh+oN MrTA== X-Gm-Message-State: AC+VfDyWm+2QZvtfB8IypMgiIvlE93S9S4k0ex5oznI+xaCryBYOTPgd 2axbaEBT5+koYsk2ivhnRmuiQg== X-Google-Smtp-Source: ACHHUZ4f8C1a0Yq0zaxuBjWwZbXZ/D/IugIwKnKoiugNJc3y7SyOt5JF5kW73QF5yt57KVjGWHuVZQ== X-Received: by 2002:a05:6a00:1311:b0:65c:d458:cedc with SMTP id j17-20020a056a00131100b0065cd458cedcmr1260709pfu.12.1686299454265; Fri, 09 Jun 2023 01:30:54 -0700 (PDT) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:c2ea:d8e4:1fe8:21f0]) by smtp.gmail.com with ESMTPSA id 23-20020aa79157000000b0063b806b111csm2184327pfi.169.2023.06.09.01.30.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jun 2023 01:30:54 -0700 (PDT) From: Chen-Yu Tsai To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Mark Brown , Liam Girdwood , Matthias Brugger , AngeloGioacchino Del Regno Cc: Chen-Yu Tsai , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 8/9] regulator: mt6358: Add output voltage fine tuning to variable LDOs Date: Fri, 9 Jun 2023 16:30:05 +0800 Message-ID: <20230609083009.2822259-9-wenst@chromium.org> X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog In-Reply-To: <20230609083009.2822259-1-wenst@chromium.org> References: <20230609083009.2822259-1-wenst@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Some of the LDO regulators in the MT6358/MT6366 have sparsely populated voltage tables, supported by custom get/set operators. While it works, it requires more code and an extra field to store the lookup table. These LDOs also have fine voltage calibration settings that can slightly boost the output voltage from 0 mV to 100 mV, in 10 mV increments. These combined could be modeled as a pickable set of linear ranges. The coarse voltage setting is modeled as the range selector, while each range has 11 selectors, starting from the range's base voltage, up to +100 mV, in 10mV increments. Signed-off-by: Chen-Yu Tsai Reviewed-by: AngeloGioacchino Del Regno --- drivers/regulator/mt6358-regulator.c | 275 +++++++++++---------------- 1 file changed, 115 insertions(+), 160 deletions(-) diff --git a/drivers/regulator/mt6358-regulator.c b/drivers/regulator/mt635= 8-regulator.c index 26060909cf90..0b186b66ae29 100644 --- a/drivers/regulator/mt6358-regulator.c +++ b/drivers/regulator/mt6358-regulator.c @@ -26,8 +26,6 @@ struct mt6358_regulator_info { struct regulator_desc desc; u32 status_reg; u32 qi; - const u32 *index_table; - unsigned int n_table; u32 da_vsel_reg; u32 da_vsel_mask; u32 modeset_reg; @@ -64,9 +62,7 @@ struct mt6358_regulator_info { .modeset_mask =3D BIT(_modeset_shift), \ } =20 -#define MT6358_LDO(match, vreg, ldo_volt_table, \ - ldo_index_table, enreg, enbit, vosel, \ - vosel_mask) \ +#define MT6358_LDO(match, vreg, volt_ranges, enreg, enbit, vosel, vosel_ma= sk) \ [MT6358_ID_##vreg] =3D { \ .desc =3D { \ .name =3D #vreg, \ @@ -75,17 +71,19 @@ struct mt6358_regulator_info { .type =3D REGULATOR_VOLTAGE, \ .id =3D MT6358_ID_##vreg, \ .owner =3D THIS_MODULE, \ - .n_voltages =3D ARRAY_SIZE(ldo_volt_table), \ - .volt_table =3D ldo_volt_table, \ - .vsel_reg =3D vosel, \ - .vsel_mask =3D vosel_mask, \ + .n_voltages =3D ARRAY_SIZE(volt_ranges##_ranges) * 11, \ + .linear_ranges =3D volt_ranges##_ranges, \ + .linear_range_selectors =3D volt_ranges##_selectors, \ + .n_linear_ranges =3D ARRAY_SIZE(volt_ranges##_ranges), \ + .vsel_range_reg =3D vosel, \ + .vsel_range_mask =3D vosel_mask, \ + .vsel_reg =3D MT6358_##vreg##_ANA_CON0, \ + .vsel_mask =3D GENMASK(3, 0), \ .enable_reg =3D enreg, \ .enable_mask =3D BIT(enbit), \ }, \ .status_reg =3D MT6358_LDO_##vreg##_CON1, \ .qi =3D BIT(15), \ - .index_table =3D ldo_index_table, \ - .n_table =3D ARRAY_SIZE(ldo_index_table), \ } =20 #define MT6358_LDO1(match, vreg, min, max, step, \ @@ -163,9 +161,7 @@ struct mt6358_regulator_info { .modeset_mask =3D BIT(_modeset_shift), \ } =20 -#define MT6366_LDO(match, vreg, ldo_volt_table, \ - ldo_index_table, enreg, enbit, vosel, \ - vosel_mask) \ +#define MT6366_LDO(match, vreg, volt_ranges, enreg, enbit, vosel, vosel_ma= sk) \ [MT6366_ID_##vreg] =3D { \ .desc =3D { \ .name =3D #vreg, \ @@ -174,17 +170,19 @@ struct mt6358_regulator_info { .type =3D REGULATOR_VOLTAGE, \ .id =3D MT6366_ID_##vreg, \ .owner =3D THIS_MODULE, \ - .n_voltages =3D ARRAY_SIZE(ldo_volt_table), \ - .volt_table =3D ldo_volt_table, \ - .vsel_reg =3D vosel, \ - .vsel_mask =3D vosel_mask, \ + .n_voltages =3D ARRAY_SIZE(volt_ranges##_ranges) * 11, \ + .linear_ranges =3D volt_ranges##_ranges, \ + .linear_range_selectors =3D volt_ranges##_selectors, \ + .n_linear_ranges =3D ARRAY_SIZE(volt_ranges##_ranges), \ + .vsel_range_reg =3D vosel, \ + .vsel_range_mask =3D vosel_mask, \ + .vsel_reg =3D MT6358_##vreg##_ANA_CON0, \ + .vsel_mask =3D GENMASK(3, 0), \ .enable_reg =3D enreg, \ .enable_mask =3D BIT(enbit), \ }, \ .status_reg =3D MT6358_LDO_##vreg##_CON1, \ .qi =3D BIT(15), \ - .index_table =3D ldo_index_table, \ - .n_table =3D ARRAY_SIZE(ldo_index_table), \ } =20 #define MT6366_LDO1(match, vreg, min, max, step, \ @@ -235,95 +233,95 @@ struct mt6358_regulator_info { } =20 =20 -static const unsigned int vdram2_voltages[] =3D { - 600000, 1800000, -}; - -static const unsigned int vsim_voltages[] =3D { - 1700000, 1800000, 2700000, 3000000, 3100000, -}; - -static const unsigned int vibr_voltages[] =3D { - 1200000, 1300000, 1500000, 1800000, - 2000000, 2800000, 3000000, 3300000, +/* VDRAM2 voltage selector not shown in datasheet */ +static const unsigned int vdram2_selectors[] =3D { 0, 12 }; +static const struct linear_range vdram2_ranges[] =3D { + REGULATOR_LINEAR_RANGE(600000, 0, 10, 10000), + REGULATOR_LINEAR_RANGE(1800000, 11, 21, 10000), }; =20 -static const unsigned int vusb_voltages[] =3D { - 3000000, 3100000, +static const unsigned int vsim_selectors[] =3D { 3, 4, 8, 11, 12 }; +static const struct linear_range vsim_ranges[] =3D { + REGULATOR_LINEAR_RANGE(1700000, 0, 10, 10000), + REGULATOR_LINEAR_RANGE(1800000, 11, 21, 10000), + REGULATOR_LINEAR_RANGE(2700000, 22, 32, 10000), + REGULATOR_LINEAR_RANGE(3000000, 33, 43, 10000), + REGULATOR_LINEAR_RANGE(3100000, 44, 54, 10000), }; =20 -static const unsigned int vcamd_voltages[] =3D { - 900000, 1000000, 1100000, 1200000, - 1300000, 1500000, 1800000, +static const unsigned int vibr_selectors[] =3D { 0, 1, 2, 4, 5, 9, 11, 13 = }; +static const struct linear_range vibr_ranges[] =3D { + REGULATOR_LINEAR_RANGE(1200000, 0, 10, 10000), + REGULATOR_LINEAR_RANGE(1300000, 11, 21, 10000), + REGULATOR_LINEAR_RANGE(1500000, 22, 32, 10000), + REGULATOR_LINEAR_RANGE(1800000, 33, 43, 10000), + REGULATOR_LINEAR_RANGE(2000000, 44, 54, 10000), + REGULATOR_LINEAR_RANGE(2800000, 55, 65, 10000), + REGULATOR_LINEAR_RANGE(3000000, 66, 76, 10000), + REGULATOR_LINEAR_RANGE(3300000, 77, 87, 10000), }; =20 -static const unsigned int vefuse_voltages[] =3D { - 1700000, 1800000, 1900000, +/* VUSB voltage selector not shown in datasheet */ +static const unsigned int vusb_selectors[] =3D { 3, 4 }; +static const struct linear_range vusb_ranges[] =3D { + REGULATOR_LINEAR_RANGE(3000000, 0, 10, 10000), + REGULATOR_LINEAR_RANGE(3100000, 11, 21, 10000), }; =20 -static const unsigned int vmch_vemc_voltages[] =3D { - 2900000, 3000000, 3300000, +static const unsigned int vcamd_selectors[] =3D { 3, 4, 5, 6, 7, 9, 12 }; +static const struct linear_range vcamd_ranges[] =3D { + REGULATOR_LINEAR_RANGE(900000, 0, 10, 10000), + REGULATOR_LINEAR_RANGE(1000000, 11, 21, 10000), + REGULATOR_LINEAR_RANGE(1100000, 22, 32, 10000), + REGULATOR_LINEAR_RANGE(1200000, 33, 43, 10000), + REGULATOR_LINEAR_RANGE(1300000, 44, 54, 10000), + REGULATOR_LINEAR_RANGE(1500000, 55, 65, 10000), + REGULATOR_LINEAR_RANGE(1800000, 66, 76, 10000), }; =20 -static const unsigned int vcama_voltages[] =3D { - 1800000, 2500000, 2700000, - 2800000, 2900000, 3000000, +static const unsigned int vefuse_selectors[] =3D { 11, 12, 13 }; +static const struct linear_range vefuse_ranges[] =3D { + REGULATOR_LINEAR_RANGE(1700000, 0, 10, 10000), + REGULATOR_LINEAR_RANGE(1800000, 11, 21, 10000), + REGULATOR_LINEAR_RANGE(1900000, 22, 32, 10000), }; =20 -static const unsigned int vcn33_voltages[] =3D { - 3300000, 3400000, 3500000, +static const unsigned int vmch_vemc_selectors[] =3D { 2, 3, 5 }; +static const struct linear_range vmch_vemc_ranges[] =3D { + REGULATOR_LINEAR_RANGE(2900000, 0, 10, 10000), + REGULATOR_LINEAR_RANGE(3000000, 11, 21, 10000), + REGULATOR_LINEAR_RANGE(3300000, 22, 32, 10000), }; =20 -static const unsigned int vmc_voltages[] =3D { - 1800000, 2900000, 3000000, 3300000, +static const unsigned int vcama_selectors[] =3D { 0, 7, 9, 10, 11, 12 }; +static const struct linear_range vcama_ranges[] =3D { + REGULATOR_LINEAR_RANGE(1800000, 0, 10, 10000), + REGULATOR_LINEAR_RANGE(2500000, 11, 21, 10000), + REGULATOR_LINEAR_RANGE(2700000, 22, 32, 10000), + REGULATOR_LINEAR_RANGE(2800000, 33, 43, 10000), + REGULATOR_LINEAR_RANGE(2900000, 44, 54, 10000), + REGULATOR_LINEAR_RANGE(3000000, 55, 65, 10000), }; =20 -static const unsigned int vldo28_voltages[] =3D { - 2800000, 3000000, +static const unsigned int vcn33_selectors[] =3D { 1, 2, 3 }; +static const struct linear_range vcn33_ranges[] =3D { + REGULATOR_LINEAR_RANGE(3300000, 0, 10, 10000), + REGULATOR_LINEAR_RANGE(3400000, 11, 21, 10000), + REGULATOR_LINEAR_RANGE(3500000, 22, 32, 10000), }; =20 -static const u32 vdram2_idx[] =3D { - 0, 12, +static const unsigned int vmc_selectors[] =3D { 4, 10, 11, 13 }; +static const struct linear_range vmc_ranges[] =3D { + REGULATOR_LINEAR_RANGE(1800000, 0, 10, 10000), + REGULATOR_LINEAR_RANGE(2900000, 11, 21, 10000), + REGULATOR_LINEAR_RANGE(3000000, 22, 32, 10000), + REGULATOR_LINEAR_RANGE(3300000, 33, 43, 10000), }; =20 -static const u32 vsim_idx[] =3D { - 3, 4, 8, 11, 12, -}; - -static const u32 vibr_idx[] =3D { - 0, 1, 2, 4, 5, 9, 11, 13, -}; - -static const u32 vusb_idx[] =3D { - 3, 4, -}; - -static const u32 vcamd_idx[] =3D { - 3, 4, 5, 6, 7, 9, 12, -}; - -static const u32 vefuse_idx[] =3D { - 11, 12, 13, -}; - -static const u32 vmch_vemc_idx[] =3D { - 2, 3, 5, -}; - -static const u32 vcama_idx[] =3D { - 0, 7, 9, 10, 11, 12, -}; - -static const u32 vcn33_idx[] =3D { - 1, 2, 3, -}; - -static const u32 vmc_idx[] =3D { - 4, 10, 11, 13, -}; - -static const u32 vldo28_idx[] =3D { - 1, 3, +static const unsigned int vldo28_selectors[] =3D { 1, 3 }; +static const struct linear_range vldo28_ranges[] =3D { + REGULATOR_LINEAR_RANGE(2800000, 0, 10, 10000), + REGULATOR_LINEAR_RANGE(3000000, 11, 21, 10000), }; =20 static unsigned int mt6358_map_mode(unsigned int mode) @@ -332,49 +330,6 @@ static unsigned int mt6358_map_mode(unsigned int mode) REGULATOR_MODE_NORMAL : REGULATOR_MODE_FAST; } =20 -static int mt6358_set_voltage_sel(struct regulator_dev *rdev, - unsigned int selector) -{ - const struct mt6358_regulator_info *info =3D to_regulator_info(rdev->desc= ); - int idx, ret; - const u32 *pvol; - - pvol =3D info->index_table; - - idx =3D pvol[selector]; - idx <<=3D ffs(info->desc.vsel_mask) - 1; - ret =3D regmap_update_bits(rdev->regmap, info->desc.vsel_reg, - info->desc.vsel_mask, idx); - - return ret; -} - -static int mt6358_get_voltage_sel(struct regulator_dev *rdev) -{ - const struct mt6358_regulator_info *info =3D to_regulator_info(rdev->desc= ); - int idx, ret; - u32 selector; - const u32 *pvol; - - ret =3D regmap_read(rdev->regmap, info->desc.vsel_reg, &selector); - if (ret !=3D 0) { - dev_info(&rdev->dev, - "Failed to get mt6358 %s vsel reg: %d\n", - info->desc.name, ret); - return ret; - } - - selector =3D (selector & info->desc.vsel_mask) >> - (ffs(info->desc.vsel_mask) - 1); - pvol =3D info->index_table; - for (idx =3D 0; idx < info->desc.n_voltages; idx++) { - if (pvol[idx] =3D=3D selector) - return idx; - } - - return -EINVAL; -} - static int mt6358_get_buck_voltage_sel(struct regulator_dev *rdev) { const struct mt6358_regulator_info *info =3D to_regulator_info(rdev->desc= ); @@ -471,10 +426,10 @@ static const struct regulator_ops mt6358_volt_range_o= ps =3D { }; =20 static const struct regulator_ops mt6358_volt_table_ops =3D { - .list_voltage =3D regulator_list_voltage_table, - .map_voltage =3D regulator_map_voltage_iterate, - .set_voltage_sel =3D mt6358_set_voltage_sel, - .get_voltage_sel =3D mt6358_get_voltage_sel, + .list_voltage =3D regulator_list_voltage_pickable_linear_range, + .map_voltage =3D regulator_map_voltage_pickable_linear_range, + .set_voltage_sel =3D regulator_set_voltage_sel_pickable_regmap, + .get_voltage_sel =3D regulator_get_voltage_sel_pickable_regmap, .set_voltage_time_sel =3D regulator_set_voltage_time_sel, .enable =3D regulator_enable_regmap, .disable =3D regulator_disable_regmap, @@ -534,34 +489,34 @@ static const struct mt6358_regulator_info mt6358_regu= lators[] =3D { MT6358_REG_FIXED("ldo_vrf18", VRF18, MT6358_LDO_VRF18_CON0, 0, 1800000), MT6358_REG_FIXED("ldo_vaud28", VAUD28, MT6358_LDO_VAUD28_CON0, 0, 2800000), - MT6358_LDO("ldo_vdram2", VDRAM2, vdram2_voltages, vdram2_idx, + MT6358_LDO("ldo_vdram2", VDRAM2, vdram2, MT6358_LDO_VDRAM2_CON0, 0, MT6358_LDO_VDRAM2_ELR0, 0xf), - MT6358_LDO("ldo_vsim1", VSIM1, vsim_voltages, vsim_idx, + MT6358_LDO("ldo_vsim1", VSIM1, vsim, MT6358_LDO_VSIM1_CON0, 0, MT6358_VSIM1_ANA_CON0, 0xf00), - MT6358_LDO("ldo_vibr", VIBR, vibr_voltages, vibr_idx, + MT6358_LDO("ldo_vibr", VIBR, vibr, MT6358_LDO_VIBR_CON0, 0, MT6358_VIBR_ANA_CON0, 0xf00), - MT6358_LDO("ldo_vusb", VUSB, vusb_voltages, vusb_idx, + MT6358_LDO("ldo_vusb", VUSB, vusb, MT6358_LDO_VUSB_CON0_0, 0, MT6358_VUSB_ANA_CON0, 0x700), - MT6358_LDO("ldo_vcamd", VCAMD, vcamd_voltages, vcamd_idx, + MT6358_LDO("ldo_vcamd", VCAMD, vcamd, MT6358_LDO_VCAMD_CON0, 0, MT6358_VCAMD_ANA_CON0, 0xf00), - MT6358_LDO("ldo_vefuse", VEFUSE, vefuse_voltages, vefuse_idx, + MT6358_LDO("ldo_vefuse", VEFUSE, vefuse, MT6358_LDO_VEFUSE_CON0, 0, MT6358_VEFUSE_ANA_CON0, 0xf00), - MT6358_LDO("ldo_vmch", VMCH, vmch_vemc_voltages, vmch_vemc_idx, + MT6358_LDO("ldo_vmch", VMCH, vmch_vemc, MT6358_LDO_VMCH_CON0, 0, MT6358_VMCH_ANA_CON0, 0x700), - MT6358_LDO("ldo_vcama1", VCAMA1, vcama_voltages, vcama_idx, + MT6358_LDO("ldo_vcama1", VCAMA1, vcama, MT6358_LDO_VCAMA1_CON0, 0, MT6358_VCAMA1_ANA_CON0, 0xf00), - MT6358_LDO("ldo_vemc", VEMC, vmch_vemc_voltages, vmch_vemc_idx, + MT6358_LDO("ldo_vemc", VEMC, vmch_vemc, MT6358_LDO_VEMC_CON0, 0, MT6358_VEMC_ANA_CON0, 0x700), - MT6358_LDO("ldo_vcn33", VCN33, vcn33_voltages, vcn33_idx, + MT6358_LDO("ldo_vcn33", VCN33, vcn33, MT6358_LDO_VCN33_CON0_0, 0, MT6358_VCN33_ANA_CON0, 0x300), - MT6358_LDO("ldo_vcama2", VCAMA2, vcama_voltages, vcama_idx, + MT6358_LDO("ldo_vcama2", VCAMA2, vcama, MT6358_LDO_VCAMA2_CON0, 0, MT6358_VCAMA2_ANA_CON0, 0xf00), - MT6358_LDO("ldo_vmc", VMC, vmc_voltages, vmc_idx, + MT6358_LDO("ldo_vmc", VMC, vmc, MT6358_LDO_VMC_CON0, 0, MT6358_VMC_ANA_CON0, 0xf00), - MT6358_LDO("ldo_vldo28", VLDO28, vldo28_voltages, vldo28_idx, + MT6358_LDO("ldo_vldo28", VLDO28, vldo28, MT6358_LDO_VLDO28_CON0_0, 0, MT6358_VLDO28_ANA_CON0, 0x300), - MT6358_LDO("ldo_vsim2", VSIM2, vsim_voltages, vsim_idx, + MT6358_LDO("ldo_vsim2", VSIM2, vsim, MT6358_LDO_VSIM2_CON0, 0, MT6358_VSIM2_ANA_CON0, 0xf00), MT6358_LDO1("ldo_vsram_proc11", VSRAM_PROC11, 500000, 1293750, 6250, MT6358_LDO_VSRAM_PROC11_DBG0, 0x7f00, MT6358_LDO_VSRAM_CON0, 0x7f), @@ -610,25 +565,25 @@ static const struct mt6358_regulator_info mt6366_regu= lators[] =3D { MT6366_REG_FIXED("ldo_vrf18", VRF18, MT6358_LDO_VRF18_CON0, 0, 1800000), MT6366_REG_FIXED("ldo_vaud28", VAUD28, MT6358_LDO_VAUD28_CON0, 0, 2800000), - MT6366_LDO("ldo_vdram2", VDRAM2, vdram2_voltages, vdram2_idx, + MT6366_LDO("ldo_vdram2", VDRAM2, vdram2, MT6358_LDO_VDRAM2_CON0, 0, MT6358_LDO_VDRAM2_ELR0, 0x10), - MT6366_LDO("ldo_vsim1", VSIM1, vsim_voltages, vsim_idx, + MT6366_LDO("ldo_vsim1", VSIM1, vsim, MT6358_LDO_VSIM1_CON0, 0, MT6358_VSIM1_ANA_CON0, 0xf00), - MT6366_LDO("ldo_vibr", VIBR, vibr_voltages, vibr_idx, + MT6366_LDO("ldo_vibr", VIBR, vibr, MT6358_LDO_VIBR_CON0, 0, MT6358_VIBR_ANA_CON0, 0xf00), - MT6366_LDO("ldo_vusb", VUSB, vusb_voltages, vusb_idx, + MT6366_LDO("ldo_vusb", VUSB, vusb, MT6358_LDO_VUSB_CON0_0, 0, MT6358_VUSB_ANA_CON0, 0x700), - MT6366_LDO("ldo_vefuse", VEFUSE, vefuse_voltages, vefuse_idx, + MT6366_LDO("ldo_vefuse", VEFUSE, vefuse, MT6358_LDO_VEFUSE_CON0, 0, MT6358_VEFUSE_ANA_CON0, 0xf00), - MT6366_LDO("ldo_vmch", VMCH, vmch_vemc_voltages, vmch_vemc_idx, + MT6366_LDO("ldo_vmch", VMCH, vmch_vemc, MT6358_LDO_VMCH_CON0, 0, MT6358_VMCH_ANA_CON0, 0x700), - MT6366_LDO("ldo_vemc", VEMC, vmch_vemc_voltages, vmch_vemc_idx, + MT6366_LDO("ldo_vemc", VEMC, vmch_vemc, MT6358_LDO_VEMC_CON0, 0, MT6358_VEMC_ANA_CON0, 0x700), - MT6366_LDO("ldo_vcn33", VCN33, vcn33_voltages, vcn33_idx, + MT6366_LDO("ldo_vcn33", VCN33, vcn33, MT6358_LDO_VCN33_CON0_0, 0, MT6358_VCN33_ANA_CON0, 0x300), - MT6366_LDO("ldo_vmc", VMC, vmc_voltages, vmc_idx, + MT6366_LDO("ldo_vmc", VMC, vmc, MT6358_LDO_VMC_CON0, 0, MT6358_VMC_ANA_CON0, 0xf00), - MT6366_LDO("ldo_vsim2", VSIM2, vsim_voltages, vsim_idx, + MT6366_LDO("ldo_vsim2", VSIM2, vsim, MT6358_LDO_VSIM2_CON0, 0, MT6358_VSIM2_ANA_CON0, 0xf00), MT6366_LDO1("ldo_vsram_proc11", VSRAM_PROC11, 500000, 1293750, 6250, MT6358_LDO_VSRAM_PROC11_DBG0, 0x7f00, MT6358_LDO_VSRAM_CON0, 0x7f), --=20 2.41.0.162.gfafddb0af9-goog From nobody Thu Nov 14 06:15:59 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 561F3C7EE25 for ; Fri, 9 Jun 2023 08:32:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230427AbjFIIco (ORCPT ); Fri, 9 Jun 2023 04:32:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241004AbjFIIbb (ORCPT ); Fri, 9 Jun 2023 04:31:31 -0400 Received: from mail-oi1-x22e.google.com (mail-oi1-x22e.google.com [IPv6:2607:f8b0:4864:20::22e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD5EA4210 for ; Fri, 9 Jun 2023 01:31:01 -0700 (PDT) Received: by mail-oi1-x22e.google.com with SMTP id 5614622812f47-38c35975545so423531b6e.1 for ; Fri, 09 Jun 2023 01:31:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1686299457; x=1688891457; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=wKG2swLU2cxH0fvGtChiGmTQPvwznm6/vNPt46Id5GA=; b=cyjo9eyx+bMWokEPapCIqNtrmXeWN2VUQZKHM9v8TisgDQANJ7603ZSrMpYCAta5ws mw/rs0y9gEUTZw0dYlNT5hsLYMK8R3vxSumcCFeE54eAPlOcw5HhYUMLZrzUSuH9RvjK Vaw4WqzBuH+ku+IoYHhNzDoZMD+ikODetptvo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686299457; x=1688891457; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wKG2swLU2cxH0fvGtChiGmTQPvwznm6/vNPt46Id5GA=; b=hdFxfNq2IEpYxNlIYJWfww7DWdZm4DbFSxBScyXsGiXf0Z72G4+8X3zFPrQETh8Nfl jQTFG0ioeO3hRjbYUOLjl8UTIiT8HxTZHPUPS4rll6Zz8GgtATRcjQSd3fxL4/XVbWTb ZaP5jFAjUZ/K1LPz1x+RzaS3ziw/QdB4Rrqvxq4h9LUyK6ESnx5/ZU1T/pedOhvneaGc woxxcKK5L39w10VDRhdc70Ak0v/IQh6nBA97bOsxl9s16C+9PshmOF+aRGgkKaMBGFie qocf0V10oEIjzBq7WrzPnODjVKsUKKBXIec8WruOBiEmBOj+sQ1zig+unAmGf5GihBgA QhmQ== X-Gm-Message-State: AC+VfDxksbohvuLJcaBHzB4fdJ4BpmH4AoQ3lK4qmXdIY20YfWox/DnC WHG0dnRpCPS8HUOu6akkBHAl3Q== X-Google-Smtp-Source: ACHHUZ7ikIDh/64RRC8hcnVVQEVUF207vgCR8uMYtPbLyaQXl+JT9HwYbPpYEclmygdxv8frpXyIvw== X-Received: by 2002:a05:6808:1829:b0:398:6008:f465 with SMTP id bh41-20020a056808182900b003986008f465mr1162071oib.4.1686299456598; Fri, 09 Jun 2023 01:30:56 -0700 (PDT) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:c2ea:d8e4:1fe8:21f0]) by smtp.gmail.com with ESMTPSA id 23-20020aa79157000000b0063b806b111csm2184327pfi.169.2023.06.09.01.30.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jun 2023 01:30:56 -0700 (PDT) From: Chen-Yu Tsai To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Mark Brown , Liam Girdwood , Matthias Brugger , AngeloGioacchino Del Regno Cc: Chen-Yu Tsai , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 9/9] arm64: dts: mediatek: mt6358: Merge ldo_vcn33_* regulators Date: Fri, 9 Jun 2023 16:30:06 +0800 Message-ID: <20230609083009.2822259-10-wenst@chromium.org> X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog In-Reply-To: <20230609083009.2822259-1-wenst@chromium.org> References: <20230609083009.2822259-1-wenst@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The ldo_vcn33_bt and ldo_vcn33_wifi regulators are actually the same regulator, having the same voltage setting and output pin. There are simply two enable bits that are ORed together to enable the regulator. Having two regulators representing the same output pin is misleading from a design matching standpoint, and also error-prone in driver implementations. Now that the bindings have these two merged, merge them in the device tree as well. Neither vcn33 regulators are referenced in upstream device trees. As far as hardware designs go, none of the Chromebooks using MT8183 w/ MT6358 use this output. Signed-off-by: Chen-Yu Tsai --- arch/arm64/boot/dts/mediatek/mt6358.dtsi | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/arch/arm64/boot/dts/mediatek/mt6358.dtsi b/arch/arm64/boot/dts= /mediatek/mt6358.dtsi index b605313bed99..186898f9384b 100644 --- a/arch/arm64/boot/dts/mediatek/mt6358.dtsi +++ b/arch/arm64/boot/dts/mediatek/mt6358.dtsi @@ -304,15 +304,8 @@ mt6358_vrf18_reg: ldo_vrf18 { regulator-enable-ramp-delay =3D <120>; }; =20 - mt6358_vcn33_bt_reg: ldo_vcn33_bt { - regulator-name =3D "vcn33_bt"; - regulator-min-microvolt =3D <3300000>; - regulator-max-microvolt =3D <3500000>; - regulator-enable-ramp-delay =3D <270>; - }; - - mt6358_vcn33_wifi_reg: ldo_vcn33_wifi { - regulator-name =3D "vcn33_wifi"; + mt6358_vcn33_reg: ldo_vcn33 { + regulator-name =3D "vcn33"; regulator-min-microvolt =3D <3300000>; regulator-max-microvolt =3D <3500000>; regulator-enable-ramp-delay =3D <270>; --=20 2.41.0.162.gfafddb0af9-goog