linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/5] Add MediaTek MT6357 PMIC support
@ 2022-10-05 14:57 Alexandre Mergnat
  2022-10-05 14:57 ` [PATCH v2 1/5] dt-bindings: mfd: mt6397: add binding for MT6357 Alexandre Mergnat
                   ` (4 more replies)
  0 siblings, 5 replies; 18+ messages in thread
From: Alexandre Mergnat @ 2022-10-05 14:57 UTC (permalink / raw)
  To: Lee Jones, Mark Brown, Matthias Brugger, Rob Herring,
	Liam Girdwood, Krzysztof Kozlowski, Dmitry Torokhov, Chen Zhong
  Cc: linux-mediatek, devicetree, linux-arm-kernel, Rob Herring,
	linux-kernel, linux-input, Fabien Parent, Alexandre Mergnat

Hi,
This patch series adds MFD, PMIC keys, and regulator support for MT6357.
MT6357 is a MediaTek PMIC very similar to MT6358.

Regards,
Alex

Changes in v2:
- Rebase
- Fix typo
- Remove dependencies with https://lore.kernel.org/all/20220415153629.1817202-1-fparent@baylibre.com/
  which is no longer relevant.

Previous versions:
v1 - https://lore.kernel.org/all/20220531124959.202787-1-fparent@baylibre.com/

To: Lee Jones <lee@kernel.org>
To: Rob Herring <robh+dt@kernel.org>
To: Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>
To: Matthias Brugger <matthias.bgg@gmail.com>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Chen Zhong <chen.zhong@mediatek.com>
To: Liam Girdwood <lgirdwood@gmail.com>
To: Mark Brown <broonie@kernel.org>
Cc: devicetree@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-mediatek@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-input@vger.kernel.org
Cc: Fabien Parent <fparent@baylibre.com>
Cc: Rob Herring <robh@kernel.org>
Signed-off-by: Alexandre Mergnat <amergnat@baylibre.com>

---
Fabien Parent (5):
      dt-bindings: mfd: mt6397: add binding for MT6357
      dt-bindings: input: mtk-pmic-keys: add binding for MT6357 PMIC
      dt-bindings: regulator: Add binding schema for mt6357 regulators
      regulator: add mt6357 regulator
      Input: mtk-pmic-keys: add MT6357 support

 .../bindings/input/mediatek,pmic-keys.yaml         |   1 +
 Documentation/devicetree/bindings/mfd/mt6397.txt   |   1 +
 .../regulator/mediatek,mt6357-regulator.yaml       | 284 ++++++++++++
 drivers/input/keyboard/mtk-pmic-keys.c             |  17 +
 drivers/regulator/Kconfig                          |   9 +
 drivers/regulator/Makefile                         |   1 +
 drivers/regulator/mt6357-regulator.c               | 485 +++++++++++++++++++++
 include/linux/regulator/mt6357-regulator.h         |  51 +++
 8 files changed, 849 insertions(+)
---
base-commit: 7c69ce28cba3d6ad011f86a5d18dc8c04a921b29
change-id: 20221005-mt6357-support-55308b82e33f

Best regards,
-- 
Alexandre Mergnat <amergnat@baylibre.com>

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH v2 1/5] dt-bindings: mfd: mt6397: add binding for MT6357
  2022-10-05 14:57 [PATCH v2 0/5] Add MediaTek MT6357 PMIC support Alexandre Mergnat
@ 2022-10-05 14:57 ` Alexandre Mergnat
  2022-10-24 12:51   ` Lee Jones
  2022-10-05 14:57 ` [PATCH v2 2/5] dt-bindings: input: mtk-pmic-keys: add binding for MT6357 PMIC Alexandre Mergnat
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 18+ messages in thread
From: Alexandre Mergnat @ 2022-10-05 14:57 UTC (permalink / raw)
  To: Lee Jones, Mark Brown, Matthias Brugger, Rob Herring,
	Liam Girdwood, Krzysztof Kozlowski, Dmitry Torokhov, Chen Zhong
  Cc: linux-mediatek, devicetree, linux-arm-kernel, Rob Herring,
	linux-kernel, linux-input, Fabien Parent, Alexandre Mergnat

From: Fabien Parent <fparent@baylibre.com>

Add binding documentation for the MT6357 PMIC.

Signed-off-by: Fabien Parent <fparent@baylibre.com>
Signed-off-by: Alexandre Mergnat <amergnat@baylibre.com>
Acked-by: Rob Herring <robh@kernel.org>
---
 Documentation/devicetree/bindings/mfd/mt6397.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/mfd/mt6397.txt b/Documentation/devicetree/bindings/mfd/mt6397.txt
index 0088442efca1..518986c44880 100644
--- a/Documentation/devicetree/bindings/mfd/mt6397.txt
+++ b/Documentation/devicetree/bindings/mfd/mt6397.txt
@@ -21,6 +21,7 @@ Required properties:
 compatible:
 	"mediatek,mt6323" for PMIC MT6323
 	"mediatek,mt6331" for PMIC MT6331 and MT6332
+	"mediatek,mt6357" for PMIC MT6357
 	"mediatek,mt6358" for PMIC MT6358 and MT6366
 	"mediatek,mt6359" for PMIC MT6359
 	"mediatek,mt6397" for PMIC MT6397

-- 
b4 0.10.1

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v2 2/5] dt-bindings: input: mtk-pmic-keys: add binding for MT6357 PMIC
  2022-10-05 14:57 [PATCH v2 0/5] Add MediaTek MT6357 PMIC support Alexandre Mergnat
  2022-10-05 14:57 ` [PATCH v2 1/5] dt-bindings: mfd: mt6397: add binding for MT6357 Alexandre Mergnat
@ 2022-10-05 14:57 ` Alexandre Mergnat
  2022-10-10 18:03   ` Dmitry Torokhov
  2022-10-05 14:57 ` [PATCH v2 3/5] dt-bindings: regulator: Add binding schema for mt6357 regulators Alexandre Mergnat
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 18+ messages in thread
From: Alexandre Mergnat @ 2022-10-05 14:57 UTC (permalink / raw)
  To: Lee Jones, Mark Brown, Matthias Brugger, Rob Herring,
	Liam Girdwood, Krzysztof Kozlowski, Dmitry Torokhov, Chen Zhong
  Cc: linux-mediatek, devicetree, linux-arm-kernel, Rob Herring,
	linux-kernel, linux-input, Fabien Parent, Alexandre Mergnat

From: Fabien Parent <fparent@baylibre.com>

Add binding documentation for the PMIC keys on MT6357.

Signed-off-by: Fabien Parent <fparent@baylibre.com>
Signed-off-by: Alexandre Mergnat <amergnat@baylibre.com>
Acked-by: Rob Herring <robh@kernel.org>
---
 Documentation/devicetree/bindings/input/mediatek,pmic-keys.yaml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/input/mediatek,pmic-keys.yaml b/Documentation/devicetree/bindings/input/mediatek,pmic-keys.yaml
index 2f72ec418415..037c3ae9f1c3 100644
--- a/Documentation/devicetree/bindings/input/mediatek,pmic-keys.yaml
+++ b/Documentation/devicetree/bindings/input/mediatek,pmic-keys.yaml
@@ -26,6 +26,7 @@ properties:
     enum:
       - mediatek,mt6323-keys
       - mediatek,mt6331-keys
+      - mediatek,mt6357-keys
       - mediatek,mt6358-keys
       - mediatek,mt6397-keys
 

-- 
b4 0.10.1

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v2 3/5] dt-bindings: regulator: Add binding schema for mt6357 regulators
  2022-10-05 14:57 [PATCH v2 0/5] Add MediaTek MT6357 PMIC support Alexandre Mergnat
  2022-10-05 14:57 ` [PATCH v2 1/5] dt-bindings: mfd: mt6397: add binding for MT6357 Alexandre Mergnat
  2022-10-05 14:57 ` [PATCH v2 2/5] dt-bindings: input: mtk-pmic-keys: add binding for MT6357 PMIC Alexandre Mergnat
@ 2022-10-05 14:57 ` Alexandre Mergnat
  2022-10-05 16:02   ` Krzysztof Kozlowski
  2022-10-05 14:57 ` [PATCH v2 4/5] regulator: add mt6357 regulator Alexandre Mergnat
  2022-10-05 14:57 ` [PATCH v2 5/5] Input: mtk-pmic-keys: add MT6357 support Alexandre Mergnat
  4 siblings, 1 reply; 18+ messages in thread
From: Alexandre Mergnat @ 2022-10-05 14:57 UTC (permalink / raw)
  To: Lee Jones, Mark Brown, Matthias Brugger, Rob Herring,
	Liam Girdwood, Krzysztof Kozlowski, Dmitry Torokhov, Chen Zhong
  Cc: linux-mediatek, devicetree, linux-arm-kernel, Rob Herring,
	linux-kernel, linux-input, Fabien Parent, Alexandre Mergnat

From: Fabien Parent <fparent@baylibre.com>

Add YAML schema for the MediaTek MT6357 regulators.

Signed-off-by: Fabien Parent <fparent@baylibre.com>
Signed-off-by: Alexandre Mergnat <amergnat@baylibre.com>
---
 .../regulator/mediatek,mt6357-regulator.yaml       | 284 +++++++++++++++++++++
 1 file changed, 284 insertions(+)

diff --git a/Documentation/devicetree/bindings/regulator/mediatek,mt6357-regulator.yaml b/Documentation/devicetree/bindings/regulator/mediatek,mt6357-regulator.yaml
new file mode 100644
index 000000000000..83ce2cf287dd
--- /dev/null
+++ b/Documentation/devicetree/bindings/regulator/mediatek,mt6357-regulator.yaml
@@ -0,0 +1,284 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/regulator/mediatek,mt6357-regulator.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: MediaTek MT6357 Regulators
+
+maintainers:
+  - Fabien Parent <fparent@baylibre.com>
+  - Alexandre Mergnat <amergnat@baylibre.com>
+
+description: |
+  The MT6357 PMIC provides 5 BUCK and 29 LDO.
+  Regulators and nodes are named according to the regulator type:
+  buck-<name> and ldo-<name>.
+  MT6357 regulators node should be sub node of the MT6397 MFD node.
+
+patternProperties:
+  "^buck-v(core|modem|pa|proc|s1)$":
+    type: object
+    $ref: "regulator.yaml#"
+
+    properties:
+      regulator-name:
+        pattern: "^v(core|modem|pa|proc|s1)$"
+
+    unevaluatedProperties: false
+
+  "^ldo-v(aud28|aux18|cama|camd|cn18|cn28|cn33-bt|cn33-wifi|dram)$":
+    type: object
+    $ref: "regulator.yaml#"
+
+    properties:
+      regulator-name:
+        pattern: "^v(aud28|aux18|cama|camd|cn18|cn28|cn33-bt|cn33-wifi|dram)$"
+
+    unevaluatedProperties: false
+
+  "^ldo-v(efuse|emc|ibr|io18|io28|ldo28|mch|rf12|rf18)$":
+    type: object
+    $ref: "regulator.yaml#"
+
+    properties:
+      regulator-name:
+        pattern: "^v(efuse|emc|ibr|io18|io28|ldo28|mch|rf12|rf18)$"
+
+    unevaluatedProperties: false
+
+  "^ldo-v(xo22|sim1,sim2|sram-others|sram-proc|usb33|xo22)$":
+    type: object
+    $ref: "regulator.yaml#"
+
+    properties:
+      regulator-name:
+        pattern: "^v(xo22|sim1,sim2|sram-others|sram-proc|usb33|xo22)$"
+
+    unevaluatedProperties: false
+
+additionalProperties: false
+
+examples:
+  - |
+    pmic {
+      regulators {
+        mt6357_vproc_reg: buck-vproc {
+          regulator-name = "vproc";
+          regulator-min-microvolt = <518750>;
+          regulator-max-microvolt = <1312500>;
+          regulator-ramp-delay = <6250>;
+          regulator-enable-ramp-delay = <220>;
+          regulator-always-on;
+        };
+        mt6357_vcore_reg: buck-vcore {
+          regulator-name = "vcore";
+          regulator-min-microvolt = <518750>;
+          regulator-max-microvolt = <1312500>;
+          regulator-ramp-delay = <6250>;
+          regulator-enable-ramp-delay = <220>;
+          regulator-always-on;
+        };
+        mt6357_vmodem_reg: buck-vmodem {
+          regulator-name = "vmodem";
+          regulator-min-microvolt = <500000>;
+          regulator-max-microvolt = <1193750>;
+          regulator-ramp-delay = <6250>;
+          regulator-enable-ramp-delay = <220>;
+        };
+        mt6357_vs1_reg: buck-vs1 {
+          regulator-name = "vs1";
+          regulator-min-microvolt = <1200000>;
+          regulator-max-microvolt = <2200000>;
+          regulator-ramp-delay = <12500>;
+          regulator-enable-ramp-delay = <220>;
+          regulator-always-on;
+        };
+        mt6357_vpa_reg: buck-vpa {
+          regulator-name = "vpa";
+          regulator-min-microvolt = <500000>;
+          regulator-max-microvolt = <3650000>;
+          regulator-ramp-delay = <50000>;
+          regulator-enable-ramp-delay = <220>;
+        };
+        mt6357_vfe28_reg: ldo-vfe28 {
+          compatible = "regulator-fixed";
+          regulator-name = "vfe28";
+          regulator-min-microvolt = <2800000>;
+          regulator-max-microvolt = <2800000>;
+          regulator-enable-ramp-delay = <264>;
+        };
+        mt6357_vxo22_reg: ldo-vxo22 {
+          regulator-name = "vxo22";
+          regulator-min-microvolt = <2200000>;
+          regulator-max-microvolt = <2400000>;
+          regulator-enable-ramp-delay = <110>;
+        };
+        mt6357_vrf18_reg: ldo-vrf18 {
+          compatible = "regulator-fixed";
+          regulator-name = "vrf18";
+          regulator-min-microvolt = <1800000>;
+          regulator-max-microvolt = <1800000>;
+          regulator-enable-ramp-delay = <110>;
+        };
+        mt6357_vrf12_reg: ldo-vrf12 {
+          compatible = "regulator-fixed";
+          regulator-name = "vrf12";
+          regulator-min-microvolt = <1200000>;
+          regulator-max-microvolt = <1200000>;
+          regulator-enable-ramp-delay = <110>;
+        };
+        mt6357_vefuse_reg: ldo-vefuse {
+          regulator-name = "vefuse";
+          regulator-min-microvolt = <1200000>;
+          regulator-max-microvolt = <3300000>;
+          regulator-enable-ramp-delay = <264>;
+        };
+        mt6357_vcn33_bt_reg: ldo-vcn33-bt {
+          regulator-name = "vcn33-bt";
+          regulator-min-microvolt = <3300000>;
+          regulator-max-microvolt = <3500000>;
+          regulator-enable-ramp-delay = <264>;
+        };
+        mt6357_vcn33_wifi_reg: ldo-vcn33-wifi {
+          regulator-name = "vcn33-wifi";
+          regulator-min-microvolt = <3300000>;
+          regulator-max-microvolt = <3500000>;
+          regulator-enable-ramp-delay = <264>;
+        };
+        mt6357_vcn28_reg: ldo-vcn28 {
+          compatible = "regulator-fixed";
+          regulator-name = "vcn28";
+          regulator-min-microvolt = <2800000>;
+          regulator-max-microvolt = <2800000>;
+          regulator-enable-ramp-delay = <264>;
+        };
+        mt6357_vcn18_reg: ldo-vcn18 {
+          compatible = "regulator-fixed";
+          regulator-name = "vcn18";
+          regulator-min-microvolt = <1800000>;
+          regulator-max-microvolt = <1800000>;
+          regulator-enable-ramp-delay = <264>;
+        };
+        mt6357_vcama_reg: ldo-vcama {
+          regulator-name = "vcama";
+          regulator-min-microvolt = <2500000>;
+          regulator-max-microvolt = <2800000>;
+          regulator-enable-ramp-delay = <264>;
+        };
+        mt6357_vcamd_reg: ldo-vcamd {
+          regulator-name = "vcamd";
+          regulator-min-microvolt = <1000000>;
+          regulator-max-microvolt = <1800000>;
+          regulator-enable-ramp-delay = <264>;
+        };
+        mt6357_vcamio_reg: ldo-vcamio18 {
+          compatible = "regulator-fixed";
+          regulator-name = "vcamio";
+          regulator-min-microvolt = <1800000>;
+          regulator-max-microvolt = <1800000>;
+          regulator-enable-ramp-delay = <264>;
+        };
+        mt6357_vldo28_reg: ldo-vldo28 {
+          regulator-name = "vldo28";
+          regulator-min-microvolt = <2800000>;
+          regulator-max-microvolt = <3000000>;
+          regulator-enable-ramp-delay = <264>;
+        };
+        mt6357_vsram_others_reg: ldo-vsram-others {
+          regulator-name = "vsram-others";
+          regulator-min-microvolt = <518750>;
+          regulator-max-microvolt = <1312500>;
+          regulator-ramp-delay = <6250>;
+          regulator-enable-ramp-delay = <110>;
+          regulator-always-on;
+        };
+        mt6357_vsram_proc_reg: ldo-vsram-proc {
+          regulator-name = "vsram-proc";
+          regulator-min-microvolt = <518750>;
+          regulator-max-microvolt = <1312500>;
+          regulator-ramp-delay = <6250>;
+          regulator-enable-ramp-delay = <110>;
+          regulator-always-on;
+        };
+        mt6357_vaux18_reg: ldo-vaux18 {
+          compatible = "regulator-fixed";
+          regulator-name = "vaux18";
+          regulator-min-microvolt = <1800000>;
+          regulator-max-microvolt = <1800000>;
+          regulator-enable-ramp-delay = <264>;
+        };
+        mt6357_vaud28_reg: ldo-vaud28 {
+          compatible = "regulator-fixed";
+          regulator-name = "vaud28";
+          regulator-min-microvolt = <2800000>;
+          regulator-max-microvolt = <2800000>;
+          regulator-enable-ramp-delay = <264>;
+        };
+        mt6357_vio28_reg: ldo-vio28 {
+          compatible = "regulator-fixed";
+          regulator-name = "vio28";
+          regulator-min-microvolt = <2800000>;
+          regulator-max-microvolt = <2800000>;
+          regulator-enable-ramp-delay = <264>;
+        };
+        mt6357_vio18_reg: ldo-vio18 {
+          compatible = "regulator-fixed";
+          regulator-name = "vio18";
+          regulator-min-microvolt = <1800000>;
+          regulator-max-microvolt = <1800000>;
+          regulator-enable-ramp-delay = <264>;
+          regulator-always-on;
+        };
+        mt6357_vdram_reg: ldo-vdram {
+          regulator-name = "vdram";
+          regulator-min-microvolt = <1100000>;
+          regulator-max-microvolt = <1200000>;
+          regulator-enable-ramp-delay = <3300>;
+        };
+        mt6357_vmc_reg: ldo-vmc {
+          regulator-name = "vmc";
+          regulator-min-microvolt = <1800000>;
+          regulator-max-microvolt = <3300000>;
+          regulator-enable-ramp-delay = <44>;
+        };
+        mt6357_vmch_reg: ldo-vmch {
+          regulator-name = "vmch";
+          regulator-min-microvolt = <2900000>;
+          regulator-max-microvolt = <3300000>;
+          regulator-enable-ramp-delay = <44>;
+        };
+        mt6357_vemc_reg: ldo-vemc {
+          regulator-name = "vemc";
+          regulator-min-microvolt = <2900000>;
+          regulator-max-microvolt = <3300000>;
+          regulator-enable-ramp-delay = <44>;
+          regulator-always-on;
+        };
+        mt6357_vsim1_reg: ldo-vsim1 {
+          regulator-name = "vsim1";
+          regulator-min-microvolt = <1700000>;
+          regulator-max-microvolt = <3100000>;
+          regulator-enable-ramp-delay = <264>;
+        };
+        mt6357_vsim2_reg: ldo-vsim2 {
+          regulator-name = "vsim2";
+          regulator-min-microvolt = <1700000>;
+          regulator-max-microvolt = <3100000>;
+          regulator-enable-ramp-delay = <264>;
+        };
+        mt6357_vibr_reg: ldo-vibr {
+          regulator-name = "vibr";
+          regulator-min-microvolt = <1200000>;
+          regulator-max-microvolt = <3300000>;
+          regulator-enable-ramp-delay = <44>;
+        };
+        mt6357_vusb33_reg: ldo-vusb33 {
+          regulator-name = "vusb33";
+          regulator-min-microvolt = <3000000>;
+          regulator-max-microvolt = <3100000>;
+          regulator-enable-ramp-delay = <264>;
+        };
+      };
+    };
+...

-- 
b4 0.10.1

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v2 4/5] regulator: add mt6357 regulator
  2022-10-05 14:57 [PATCH v2 0/5] Add MediaTek MT6357 PMIC support Alexandre Mergnat
                   ` (2 preceding siblings ...)
  2022-10-05 14:57 ` [PATCH v2 3/5] dt-bindings: regulator: Add binding schema for mt6357 regulators Alexandre Mergnat
@ 2022-10-05 14:57 ` Alexandre Mergnat
  2022-10-05 15:09   ` Mark Brown
  2022-10-06 10:12   ` AngeloGioacchino Del Regno
  2022-10-05 14:57 ` [PATCH v2 5/5] Input: mtk-pmic-keys: add MT6357 support Alexandre Mergnat
  4 siblings, 2 replies; 18+ messages in thread
From: Alexandre Mergnat @ 2022-10-05 14:57 UTC (permalink / raw)
  To: Lee Jones, Mark Brown, Matthias Brugger, Rob Herring,
	Liam Girdwood, Krzysztof Kozlowski, Dmitry Torokhov, Chen Zhong
  Cc: linux-mediatek, devicetree, linux-arm-kernel, Rob Herring,
	linux-kernel, linux-input, Fabien Parent, Alexandre Mergnat

From: Fabien Parent <fparent@baylibre.com>

Add regulator driver for the MT6357 PMIC.

Signed-off-by: Fabien Parent <fparent@baylibre.com>
Signed-off-by: Alexandre Mergnat <amergnat@baylibre.com>
---
 drivers/regulator/Kconfig                  |   9 +
 drivers/regulator/Makefile                 |   1 +
 drivers/regulator/mt6357-regulator.c       | 485 +++++++++++++++++++++++++++++
 include/linux/regulator/mt6357-regulator.h |  51 +++
 4 files changed, 546 insertions(+)

diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index 070e4403c6c2..a659a57438f4 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -805,6 +805,15 @@ config REGULATOR_MT6332
 	  This driver supports the control of different power rails of device
 	  through regulator interface
 
+config REGULATOR_MT6357
+	tristate "MediaTek MT6357 PMIC"
+	depends on MFD_MT6397
+	help
+	  Say y here to select this option to enable the power regulator of
+	  MediaTek MT6357 PMIC.
+	  This driver supports the control of different power rails of device
+	  through regulator interface.
+
 config REGULATOR_MT6358
 	tristate "MediaTek MT6358 PMIC"
 	depends on MFD_MT6397
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
index 5962307e1130..e4d67b7b1af6 100644
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile
@@ -97,6 +97,7 @@ obj-$(CONFIG_REGULATOR_MT6315) += mt6315-regulator.o
 obj-$(CONFIG_REGULATOR_MT6323)	+= mt6323-regulator.o
 obj-$(CONFIG_REGULATOR_MT6331)	+= mt6331-regulator.o
 obj-$(CONFIG_REGULATOR_MT6332)	+= mt6332-regulator.o
+obj-$(CONFIG_REGULATOR_MT6357)	+= mt6357-regulator.o
 obj-$(CONFIG_REGULATOR_MT6358)	+= mt6358-regulator.o
 obj-$(CONFIG_REGULATOR_MT6359)	+= mt6359-regulator.o
 obj-$(CONFIG_REGULATOR_MT6360) += mt6360-regulator.o
diff --git a/drivers/regulator/mt6357-regulator.c b/drivers/regulator/mt6357-regulator.c
new file mode 100644
index 000000000000..4ecd41429448
--- /dev/null
+++ b/drivers/regulator/mt6357-regulator.c
@@ -0,0 +1,485 @@
+// SPDX-License-Identifier: GPL-2.0
+//
+// Copyright (c) 2022 MediaTek Inc.
+// Copyright (c) 2022 BayLibre, SAS.
+// Author: Chen Zhong <chen.zhong@mediatek.com>
+// Author: Fabien Parent <fparent@baylibre.com>
+//
+// Based on mt6397-regulator.c
+//
+
+#include <linux/module.h>
+#include <linux/linear_range.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <linux/regmap.h>
+#include <linux/mfd/mt6397/core.h>
+#include <linux/mfd/mt6357/registers.h>
+#include <linux/regulator/driver.h>
+#include <linux/regulator/machine.h>
+#include <linux/regulator/mt6357-regulator.h>
+#include <linux/regulator/of_regulator.h>
+
+/*
+ * MT6357 regulators' information
+ *
+ * @desc: standard fields of regulator description.
+ * @vselon_reg: Register sections for hardware control mode of bucks
+ * @vselctrl_reg: Register for controlling the buck control mode.
+ * @vselctrl_mask: Mask for query buck's voltage control mode.
+ */
+struct mt6357_regulator_info {
+	struct regulator_desc desc;
+	const u32 *index_table;
+	unsigned int n_table;
+	u32 vsel_shift;
+	u32 da_vsel_reg;
+	u32 da_vsel_mask;
+	u32 da_vsel_shift;
+};
+
+#define MT6357_BUCK(match, vreg, min, max, step,		\
+	volt_ranges, vosel_reg, vosel_mask, _da_vsel_mask)		\
+[MT6357_ID_##vreg] = {	\
+	.desc = {	\
+		.name = #vreg,	\
+		.of_match = of_match_ptr(match),	\
+		.regulators_node = "regulators",			\
+		.ops = &mt6357_volt_range_ops,	\
+		.type = REGULATOR_VOLTAGE,	\
+		.id = MT6357_ID_##vreg,		\
+		.owner = THIS_MODULE,		\
+		.n_voltages = ((max) - (min)) / (step) + 1,	\
+		.linear_ranges = volt_ranges,		\
+		.n_linear_ranges = ARRAY_SIZE(volt_ranges),	\
+		.vsel_reg = vosel_reg,	\
+		.vsel_mask = vosel_mask,	\
+		.enable_reg = MT6357_BUCK_##vreg##_CON0,	\
+		.enable_mask = BIT(0),	\
+	},	\
+	.da_vsel_reg = MT6357_BUCK_##vreg##_DBG0,	\
+	.da_vsel_mask = vosel_mask,	\
+	.da_vsel_shift = 0,	\
+}
+
+#define MT6357_LDO(match, vreg, ldo_volt_table,	\
+	ldo_index_table, enreg, vosel,	\
+	vosel_mask)	\
+[MT6357_ID_##vreg] = {	\
+	.desc = {	\
+		.name = #vreg,	\
+		.of_match = of_match_ptr(match),	\
+		.regulators_node = "regulators",			\
+		.ops = &mt6357_volt_table_ops,	\
+		.type = REGULATOR_VOLTAGE,	\
+		.id = MT6357_ID_##vreg,	\
+		.owner = THIS_MODULE,	\
+		.n_voltages = ARRAY_SIZE(ldo_volt_table),	\
+		.volt_table = ldo_volt_table,	\
+		.vsel_reg = vosel,	\
+		.vsel_mask = vosel_mask << 8,	\
+		.enable_reg = enreg,	\
+		.enable_mask = BIT(0),	\
+	},	\
+	.index_table = ldo_index_table,	\
+	.n_table = ARRAY_SIZE(ldo_index_table),	\
+}
+
+#define MT6357_LDO1(match, vreg, min, max, step, volt_ranges,	\
+	enreg, vosel, vosel_mask)	\
+[MT6357_ID_##vreg] = {	\
+	.desc = {	\
+		.name = #vreg,	\
+		.of_match = of_match_ptr(match),	\
+		.regulators_node = "regulators",			\
+		.ops = &mt6357_volt_range_ops,	\
+		.type = REGULATOR_VOLTAGE,	\
+		.id = MT6357_ID_##vreg,	\
+		.owner = THIS_MODULE,	\
+		.n_voltages = ((max) - (min)) / (step) + 1,	\
+		.linear_ranges = volt_ranges,		\
+		.n_linear_ranges = ARRAY_SIZE(volt_ranges),	\
+		.vsel_reg = vosel,	\
+		.vsel_mask = vosel_mask,	\
+		.enable_reg = enreg,	\
+		.enable_mask = BIT(0),	\
+	},	\
+	.da_vsel_reg = MT6357_LDO_##vreg##_DBG0,	\
+	.da_vsel_mask = 0x7f,	\
+	.da_vsel_shift = 8,	\
+}
+
+#define MT6357_REG_FIXED(match, vreg, volt)	\
+[MT6357_ID_##vreg] = {					\
+	.desc = {					\
+		.name = #vreg,				\
+		.of_match = of_match_ptr(match),	\
+		.regulators_node = "regulators",	\
+		.ops = &mt6357_volt_fixed_ops,		\
+		.type = REGULATOR_VOLTAGE,		\
+		.id = MT6357_ID_##vreg,			\
+		.owner = THIS_MODULE,			\
+		.n_voltages = 1,			\
+		.enable_reg = MT6357_LDO_##vreg##_CON0,	\
+		.enable_mask = BIT(0),			\
+		.min_uV = volt,				\
+	},						\
+}
+
+static int mt6357_set_voltage_sel(struct regulator_dev *rdev,
+				  unsigned int selector)
+{
+	int idx, ret;
+	const u32 *pvol;
+	struct mt6357_regulator_info *info = rdev_get_drvdata(rdev);
+
+	pvol = info->index_table;
+
+	idx = pvol[selector];
+	ret = regmap_update_bits(rdev->regmap, info->desc.vsel_reg,
+				 info->desc.vsel_mask,
+				 idx << 8);
+
+	return ret;
+}
+
+static int mt6357_get_voltage_sel(struct regulator_dev *rdev)
+{
+	int idx, ret;
+	u32 selector;
+	struct mt6357_regulator_info *info = rdev_get_drvdata(rdev);
+	const u32 *pvol;
+
+	ret = regmap_read(rdev->regmap, info->desc.vsel_reg, &selector);
+	if (ret != 0) {
+		dev_info(&rdev->dev,
+			 "Failed to get mt6357 %s vsel reg: %d\n",
+			 info->desc.name, ret);
+		return ret;
+	}
+
+	selector = (selector & info->desc.vsel_mask) >> 8;
+	pvol = info->index_table;
+	for (idx = 0; idx < info->desc.n_voltages; idx++) {
+		if (pvol[idx] == selector)
+			return idx;
+	}
+
+	return -EINVAL;
+}
+
+static int mt6357_get_buck_voltage_sel(struct regulator_dev *rdev)
+{
+	int ret, regval;
+	struct mt6357_regulator_info *info = rdev_get_drvdata(rdev);
+
+	ret = regmap_read(rdev->regmap, info->da_vsel_reg, &regval);
+	if (ret != 0) {
+		dev_err(&rdev->dev,
+			"Failed to get mt6357 Buck %s vsel reg: %d\n",
+			info->desc.name, ret);
+		return ret;
+	}
+
+	ret = (regval & info->da_vsel_mask) >> info->da_vsel_shift;
+
+	return ret;
+}
+
+static const struct regulator_ops mt6357_volt_range_ops = {
+	.list_voltage = regulator_list_voltage_linear_range,
+	.map_voltage = regulator_map_voltage_linear_range,
+	.set_voltage_sel = regulator_set_voltage_sel_regmap,
+	.get_voltage_sel = mt6357_get_buck_voltage_sel,
+	.set_voltage_time_sel = regulator_set_voltage_time_sel,
+	.enable = regulator_enable_regmap,
+	.disable = regulator_disable_regmap,
+	.is_enabled = regulator_is_enabled_regmap,
+};
+
+static const struct regulator_ops mt6357_volt_table_ops = {
+	.list_voltage = regulator_list_voltage_table,
+	.map_voltage = regulator_map_voltage_iterate,
+	.set_voltage_sel = mt6357_set_voltage_sel,
+	.get_voltage_sel = mt6357_get_voltage_sel,
+	.set_voltage_time_sel = regulator_set_voltage_time_sel,
+	.enable = regulator_enable_regmap,
+	.disable = regulator_disable_regmap,
+	.is_enabled = regulator_is_enabled_regmap,
+};
+
+static const struct regulator_ops mt6357_volt_fixed_ops = {
+	.list_voltage = regulator_list_voltage_linear,
+	.enable = regulator_enable_regmap,
+	.disable = regulator_disable_regmap,
+	.is_enabled = regulator_is_enabled_regmap,
+};
+
+static const int vxo22_voltages[] = {
+	2200000,
+	2400000,
+};
+
+static const int vefuse_voltages[] = {
+	1200000,
+	1300000,
+	1500000,
+	1800000,
+	2800000,
+	2900000,
+	3000000,
+	3300000,
+};
+
+static const int vcn33_voltages[] = {
+	3300000,
+	3400000,
+	3500000,
+};
+
+static const int vcama_voltages[] = {
+	2500000,
+	2800000,
+};
+
+static const int vcamd_voltages[] = {
+	1000000,
+	1100000,
+	1200000,
+	1300000,
+	1500000,
+	1800000,
+};
+
+static const int vldo28_voltages[] = {
+	2800000,
+	3000000,
+};
+
+static const int vdram_voltages[] = {
+	1100000,
+	1200000,
+};
+
+static const int vsim_voltages[] = {
+	1700000,
+	1800000,
+	2700000,
+	3000000,
+	3100000,
+};
+
+static const int vibr_voltages[] = {
+	1200000,
+	1300000,
+	1500000,
+	1800000,
+	2000000,
+	2800000,
+	3000000,
+	3300000,
+};
+
+static const int vmc_voltages[] = {
+	1800000,
+	2900000,
+	3000000,
+	3300000,
+};
+
+static const int vmch_voltages[] = {
+	2900000,
+	3000000,
+	3300000,
+};
+
+static const int vemc_voltages[] = {
+	2900000,
+	3000000,
+	3300000,
+};
+
+static const int vusb_voltages[] = {
+	3000000,
+	3100000,
+};
+
+static const int vmc_idx[] = {
+	4, 10, 11, 13,
+};
+
+static const int vmch_idx[] = {
+	2, 3, 5,
+};
+
+static const int vemc_idx[] = {
+	2, 3, 5,
+};
+
+static const int vusb_idx[] = {
+	3, 4,
+};
+
+static const int vxo22_idx[] = {
+	0, 2,
+};
+
+static const int vefuse_idx[] = {
+	0, 1, 2, 4, 9, 10, 11, 13,
+};
+
+static const int vcn33_idx[] = {
+	1, 2, 3,
+};
+
+static const int vcama_idx[] = {
+	7, 10,
+};
+
+static const int vcamd_idx[] = {
+	4, 5, 6, 7, 9, 12,
+};
+
+static const int vldo28_idx[] = {
+	1, 3,
+};
+
+static const int vdram_idx[] = {
+	1, 2,
+};
+
+static const int vsim_idx[] = {
+	3, 4, 8, 11, 12,
+};
+
+static const int vibr_idx[] = {
+	0, 1, 2, 4, 5, 9, 11, 13,
+};
+
+static const struct linear_range buck_volt_range1[] = {
+	REGULATOR_LINEAR_RANGE(518750, 0, 0x7f, 6250),
+};
+
+static const struct linear_range buck_volt_range2[] = {
+	REGULATOR_LINEAR_RANGE(500000, 0, 0x7f, 6250),
+};
+
+static const struct linear_range buck_volt_range3[] = {
+	REGULATOR_LINEAR_RANGE(500000, 0, 0x3f, 50000),
+};
+
+static const struct linear_range buck_volt_range4[] = {
+	REGULATOR_LINEAR_RANGE(1200000, 0, 0x7f, 12500),
+};
+
+/* The array is indexed by id(MT6357_ID_XXX) */
+static struct mt6357_regulator_info mt6357_regulators[] = {
+	/* Bucks */
+	MT6357_BUCK("buck-vcore", VCORE, 518750, 1312500, 6250,
+		buck_volt_range1, MT6357_BUCK_VCORE_ELR0, 0x7f, 0x7f),
+	MT6357_BUCK("buck-vproc", VPROC, 518750, 1312500, 6250,
+		buck_volt_range1, MT6357_BUCK_VPROC_ELR0, 0x7f, 0x7f),
+	MT6357_BUCK("buck-vmodem", VMODEM, 500000, 1293750, 6250,
+		buck_volt_range2, MT6357_BUCK_VMODEM_ELR0, 0x7f, 0x7f),
+	MT6357_BUCK("buck-vpa", VPA, 500000, 3650000, 50000,
+		buck_volt_range3, MT6357_BUCK_VPA_CON1, 0x3f, 0x3f),
+	MT6357_BUCK("buck-vs1", VS1, 1200000, 2787500, 12500,
+		buck_volt_range4, MT6357_BUCK_VS1_ELR0, 0x7f, 0x7f),
+
+	/* LDOs */
+	MT6357_LDO("ldo-vcama", VCAMA, vcama_voltages, vcama_idx,
+		   MT6357_LDO_VCAMA_CON0, MT6357_VCAMA_ANA_CON0, 0xf),
+	MT6357_LDO("ldo-vcamd", VCAMD, vcamd_voltages, vcamd_idx,
+		   MT6357_LDO_VCAMD_CON0, MT6357_VCAMD_ANA_CON0, 0xf),
+	MT6357_LDO("ldo-vcn33-bt", VCN33_BT, vcn33_voltages, vcn33_idx,
+		   MT6357_LDO_VCN33_CON0_0, MT6357_VCN33_ANA_CON0, 0x3),
+	MT6357_LDO("ldo-vcn33-wifi", VCN33_WIFI, vcn33_voltages, vcn33_idx,
+		   MT6357_LDO_VCN33_CON0_1, MT6357_VCN33_ANA_CON0, 0x3),
+	MT6357_LDO("ldo-vdram", VDRAM, vdram_voltages, vdram_idx,
+		   MT6357_LDO_VDRAM_CON0, MT6357_VDRAM_ELR_2, 0x3),
+	MT6357_LDO("ldo-vefuse", VEFUSE, vefuse_voltages, vefuse_idx,
+		   MT6357_LDO_VEFUSE_CON0, MT6357_VEFUSE_ANA_CON0, 0xf),
+	MT6357_LDO("ldo-vemc", VEMC, vemc_voltages, vemc_idx,
+		   MT6357_LDO_VEMC_CON0, MT6357_VEMC_ANA_CON0, 0x7),
+	MT6357_LDO("ldo-vibr", VIBR, vibr_voltages, vibr_idx,
+		   MT6357_LDO_VIBR_CON0, MT6357_VIBR_ANA_CON0, 0xf),
+	MT6357_LDO("ldo-vldo28", VLDO28, vldo28_voltages, vldo28_idx,
+		   MT6357_LDO_VLDO28_CON0_0, MT6357_VLDO28_ANA_CON0, 0x3),
+	MT6357_LDO("ldo-vmc", VMC, vmc_voltages, vmc_idx,
+		   MT6357_LDO_VMC_CON0, MT6357_VMC_ANA_CON0, 0xf),
+	MT6357_LDO("ldo-vmch", VMCH, vmch_voltages, vmch_idx,
+		   MT6357_LDO_VMCH_CON0, MT6357_VMCH_ANA_CON0, 0x7),
+	MT6357_LDO("ldo-vsim1", VSIM1, vsim_voltages, vsim_idx,
+		   MT6357_LDO_VSIM1_CON0, MT6357_VSIM1_ANA_CON0, 0xf),
+	MT6357_LDO("ldo-vsim2", VSIM2, vsim_voltages, vsim_idx,
+		   MT6357_LDO_VSIM2_CON0, MT6357_VSIM2_ANA_CON0, 0xf),
+	MT6357_LDO("ldo-vusb33", VUSB33, vusb_voltages, vusb_idx,
+		   MT6357_LDO_VUSB33_CON0_0, MT6357_VUSB33_ANA_CON0, 0x7),
+	MT6357_LDO("ldo-vxo22", VXO22, vxo22_voltages, vxo22_idx,
+		   MT6357_LDO_VXO22_CON0, MT6357_VXO22_ANA_CON0, 0x3),
+
+	MT6357_LDO1("ldo-vsram-proc", VSRAM_PROC, 518750, 1312500, 6250,
+		   buck_volt_range1, MT6357_LDO_VSRAM_PROC_CON0,
+		   MT6357_LDO_VSRAM_CON0, 0x7f),
+	MT6357_LDO1("ldo-vsram-others", VSRAM_OTHERS, 518750, 1312500, 6250,
+		   buck_volt_range1, MT6357_LDO_VSRAM_OTHERS_CON0,
+		   MT6357_LDO_VSRAM_CON1, 0x7f),
+
+	MT6357_REG_FIXED("ldo-vaud28", VAUD28, 2800000),
+	MT6357_REG_FIXED("ldo-vaux18", VAUX18, 1800000),
+	MT6357_REG_FIXED("ldo-vcamio18", VCAMIO, 1800000),
+	MT6357_REG_FIXED("ldo-vcn18", VCN18, 1800000),
+	MT6357_REG_FIXED("ldo-vcn28", VCN28, 2800000),
+	MT6357_REG_FIXED("ldo-vfe28", VFE28, 2800000),
+	MT6357_REG_FIXED("ldo-vio18", VIO18, 1800000),
+	MT6357_REG_FIXED("ldo-vio28", VIO28, 2800000),
+	MT6357_REG_FIXED("ldo-vrf12", VRF12, 1200000),
+	MT6357_REG_FIXED("ldo-vrf18", VRF18, 1800000),
+};
+
+static int mt6357_regulator_probe(struct platform_device *pdev)
+{
+	struct mt6397_chip *mt6357 = dev_get_drvdata(pdev->dev.parent);
+	struct regulator_config config = {};
+	struct regulator_dev *rdev;
+	int i;
+
+	pdev->dev.of_node = pdev->dev.parent->of_node;
+
+	for (i = 0; i < MT6357_MAX_REGULATOR; i++) {
+		config.dev = &pdev->dev;
+		config.driver_data = &mt6357_regulators[i];
+		config.regmap = mt6357->regmap;
+
+		rdev = devm_regulator_register(&pdev->dev,
+					       &mt6357_regulators[i].desc,
+					       &config);
+		if (IS_ERR(rdev)) {
+			dev_err(&pdev->dev, "failed to register %s\n",
+				mt6357_regulators[i].desc.name);
+			return PTR_ERR(rdev);
+		}
+	}
+
+	return 0;
+}
+
+static const struct platform_device_id mt6357_platform_ids[] = {
+	{ "mt6357-regulator" },
+	{ /* sentinel */ },
+};
+MODULE_DEVICE_TABLE(platform, mt6357_platform_ids);
+
+static struct platform_driver mt6357_regulator_driver = {
+	.driver = {
+		.name = "mt6357-regulator",
+	},
+	.probe = mt6357_regulator_probe,
+	.id_table = mt6357_platform_ids,
+};
+
+module_platform_driver(mt6357_regulator_driver);
+
+MODULE_AUTHOR("Fabien Parent <fparent@baylibre.com>");
+MODULE_DESCRIPTION("Regulator Driver for MediaTek MT6357 PMIC");
+MODULE_LICENSE("GPL");
diff --git a/include/linux/regulator/mt6357-regulator.h b/include/linux/regulator/mt6357-regulator.h
new file mode 100644
index 000000000000..238b1ee77ea6
--- /dev/null
+++ b/include/linux/regulator/mt6357-regulator.h
@@ -0,0 +1,51 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) 2022 MediaTek Inc.
+ */
+
+#ifndef __LINUX_REGULATOR_MT6357_H
+#define __LINUX_REGULATOR_MT6357_H
+
+enum {
+	/* Bucks */
+	MT6357_ID_VCORE,
+	MT6357_ID_VMODEM,
+	MT6357_ID_VPA,
+	MT6357_ID_VPROC,
+	MT6357_ID_VS1,
+
+	/* LDOs */
+	MT6357_ID_VAUX18,
+	MT6357_ID_VAUD28,
+	MT6357_ID_VCAMA,
+	MT6357_ID_VCAMD,
+	MT6357_ID_VCAMIO,
+	MT6357_ID_VCN18,
+	MT6357_ID_VCN28,
+	MT6357_ID_VCN33_BT,
+	MT6357_ID_VCN33_WIFI,
+	MT6357_ID_VDRAM,
+	MT6357_ID_VEFUSE,
+	MT6357_ID_VEMC,
+	MT6357_ID_VFE28,
+	MT6357_ID_VIBR,
+	MT6357_ID_VIO18,
+	MT6357_ID_VIO28,
+	MT6357_ID_VLDO28,
+	MT6357_ID_VMC,
+	MT6357_ID_VMCH,
+	MT6357_ID_VRF12,
+	MT6357_ID_VRF18,
+	MT6357_ID_VSIM1,
+	MT6357_ID_VSIM2,
+	MT6357_ID_VSRAM_OTHERS,
+	MT6357_ID_VSRAM_PROC,
+	MT6357_ID_VUSB33,
+	MT6357_ID_VXO22,
+
+	MT6357_ID_RG_MAX,
+};
+
+#define MT6357_MAX_REGULATOR	MT6357_ID_RG_MAX
+
+#endif /* __LINUX_REGULATOR_MT6357_H */

-- 
b4 0.10.1

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v2 5/5] Input: mtk-pmic-keys: add MT6357 support
  2022-10-05 14:57 [PATCH v2 0/5] Add MediaTek MT6357 PMIC support Alexandre Mergnat
                   ` (3 preceding siblings ...)
  2022-10-05 14:57 ` [PATCH v2 4/5] regulator: add mt6357 regulator Alexandre Mergnat
@ 2022-10-05 14:57 ` Alexandre Mergnat
  2022-10-06  7:40   ` Mattijs Korpershoek
                     ` (2 more replies)
  4 siblings, 3 replies; 18+ messages in thread
From: Alexandre Mergnat @ 2022-10-05 14:57 UTC (permalink / raw)
  To: Lee Jones, Mark Brown, Matthias Brugger, Rob Herring,
	Liam Girdwood, Krzysztof Kozlowski, Dmitry Torokhov, Chen Zhong
  Cc: linux-mediatek, devicetree, linux-arm-kernel, Rob Herring,
	linux-kernel, linux-input, Fabien Parent, Alexandre Mergnat

From: Fabien Parent <fparent@baylibre.com>

Add PMIC Keys support on MT6357 SoC.

Signed-off-by: Fabien Parent <fparent@baylibre.com>
Signed-off-by: Alexandre Mergnat <amergnat@baylibre.com>
---
 drivers/input/keyboard/mtk-pmic-keys.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/input/keyboard/mtk-pmic-keys.c b/drivers/input/keyboard/mtk-pmic-keys.c
index 9b34da0ec260..2a63e0718eb6 100644
--- a/drivers/input/keyboard/mtk-pmic-keys.c
+++ b/drivers/input/keyboard/mtk-pmic-keys.c
@@ -10,6 +10,7 @@
 #include <linux/kernel.h>
 #include <linux/mfd/mt6323/registers.h>
 #include <linux/mfd/mt6331/registers.h>
+#include <linux/mfd/mt6357/registers.h>
 #include <linux/mfd/mt6358/registers.h>
 #include <linux/mfd/mt6397/core.h>
 #include <linux/mfd/mt6397/registers.h>
@@ -90,6 +91,19 @@ static const struct mtk_pmic_regs mt6331_regs = {
 	.rst_lprst_mask = MTK_PMIC_MT6331_RST_DU_MASK,
 };
 
+static const struct mtk_pmic_regs mt6357_regs = {
+	.keys_regs[MTK_PMIC_PWRKEY_INDEX] =
+		MTK_PMIC_KEYS_REGS(MT6357_TOPSTATUS,
+				   0x2, MT6357_PSC_TOP_INT_CON0, 0x5,
+				   MTK_PMIC_PWRKEY_RST),
+	.keys_regs[MTK_PMIC_HOMEKEY_INDEX] =
+		MTK_PMIC_KEYS_REGS(MT6357_TOPSTATUS,
+				   0x8, MT6357_PSC_TOP_INT_CON0, 0xa,
+				   MTK_PMIC_HOMEKEY_INDEX),
+	.pmic_rst_reg = MT6357_TOP_RST_MISC,
+	.rst_lprst_mask = MTK_PMIC_RST_DU_MASK,
+};
+
 static const struct mtk_pmic_regs mt6358_regs = {
 	.keys_regs[MTK_PMIC_PWRKEY_INDEX] =
 		MTK_PMIC_KEYS_REGS(MT6358_TOPSTATUS,
@@ -276,6 +290,9 @@ static const struct of_device_id of_mtk_pmic_keys_match_tbl[] = {
 	}, {
 		.compatible = "mediatek,mt6331-keys",
 		.data = &mt6331_regs,
+	}, {
+		.compatible = "mediatek,mt6357-keys",
+		.data = &mt6357_regs,
 	}, {
 		.compatible = "mediatek,mt6358-keys",
 		.data = &mt6358_regs,

-- 
b4 0.10.1

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [PATCH v2 4/5] regulator: add mt6357 regulator
  2022-10-05 14:57 ` [PATCH v2 4/5] regulator: add mt6357 regulator Alexandre Mergnat
@ 2022-10-05 15:09   ` Mark Brown
  2022-10-06 10:12   ` AngeloGioacchino Del Regno
  1 sibling, 0 replies; 18+ messages in thread
From: Mark Brown @ 2022-10-05 15:09 UTC (permalink / raw)
  To: Alexandre Mergnat
  Cc: Lee Jones, Matthias Brugger, Rob Herring, Liam Girdwood,
	Krzysztof Kozlowski, Dmitry Torokhov, Chen Zhong, linux-mediatek,
	devicetree, linux-arm-kernel, Rob Herring, linux-kernel,
	linux-input, Fabien Parent

[-- Attachment #1: Type: text/plain, Size: 611 bytes --]

On Wed, Oct 05, 2022 at 04:57:24PM +0200, Alexandre Mergnat wrote:

> +static int mt6357_set_voltage_sel(struct regulator_dev *rdev,
> +				  unsigned int selector)
> +{
> +	int idx, ret;
> +	const u32 *pvol;
> +	struct mt6357_regulator_info *info = rdev_get_drvdata(rdev);
> +
> +	pvol = info->index_table;
> +
> +	idx = pvol[selector];
> +	ret = regmap_update_bits(rdev->regmap, info->desc.vsel_reg,
> +				 info->desc.vsel_mask,
> +				 idx << 8);
> +
> +	return ret;
> +}

There's a bunch of other Mediatek drivers doing this and multiple
instances in this driver, the helper should really be factored out.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v2 3/5] dt-bindings: regulator: Add binding schema for mt6357 regulators
  2022-10-05 14:57 ` [PATCH v2 3/5] dt-bindings: regulator: Add binding schema for mt6357 regulators Alexandre Mergnat
@ 2022-10-05 16:02   ` Krzysztof Kozlowski
  2022-10-11  9:30     ` Alexandre Mergnat
  0 siblings, 1 reply; 18+ messages in thread
From: Krzysztof Kozlowski @ 2022-10-05 16:02 UTC (permalink / raw)
  To: Alexandre Mergnat, Lee Jones, Mark Brown, Matthias Brugger,
	Rob Herring, Liam Girdwood, Krzysztof Kozlowski, Dmitry Torokhov,
	Chen Zhong
  Cc: linux-mediatek, devicetree, linux-arm-kernel, Rob Herring,
	linux-kernel, linux-input, Fabien Parent

On 05/10/2022 16:57, Alexandre Mergnat wrote:
> From: Fabien Parent <fparent@baylibre.com>
> 
> Add YAML schema for the MediaTek MT6357 regulators.
> 
> Signed-off-by: Fabien Parent <fparent@baylibre.com>
> Signed-off-by: Alexandre Mergnat <amergnat@baylibre.com>
> ---
>  .../regulator/mediatek,mt6357-regulator.yaml       | 284 +++++++++++++++++++++
>  1 file changed, 284 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/regulator/mediatek,mt6357-regulator.yaml b/Documentation/devicetree/bindings/regulator/mediatek,mt6357-regulator.yaml
> new file mode 100644
> index 000000000000..83ce2cf287dd
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/regulator/mediatek,mt6357-regulator.yaml
> @@ -0,0 +1,284 @@
> +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/regulator/mediatek,mt6357-regulator.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: MediaTek MT6357 Regulators
> +
> +maintainers:
> +  - Fabien Parent <fparent@baylibre.com>

The email might be not correct.

> +  - Alexandre Mergnat <amergnat@baylibre.com>
> +
> +description: |
> +  The MT6357 PMIC provides 5 BUCK and 29 LDO.
> +  Regulators and nodes are named according to the regulator type:
> +  buck-<name> and ldo-<name>.
> +  MT6357 regulators node should be sub node of the MT6397 MFD node.
> +
> +patternProperties:
> +  "^buck-v(core|modem|pa|proc|s1)$":
> +    type: object
> +    $ref: "regulator.yaml#"

Drop quotes.

> +
> +    properties:
> +      regulator-name:
> +        pattern: "^v(core|modem|pa|proc|s1)$"

Why enforcing particular name of the regulator?

Both comments apply to all other cases.

Best regards,
Krzysztof


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v2 5/5] Input: mtk-pmic-keys: add MT6357 support
  2022-10-05 14:57 ` [PATCH v2 5/5] Input: mtk-pmic-keys: add MT6357 support Alexandre Mergnat
@ 2022-10-06  7:40   ` Mattijs Korpershoek
  2022-10-06 10:12   ` AngeloGioacchino Del Regno
  2022-10-10 18:04   ` Dmitry Torokhov
  2 siblings, 0 replies; 18+ messages in thread
From: Mattijs Korpershoek @ 2022-10-06  7:40 UTC (permalink / raw)
  To: Alexandre Mergnat, Lee Jones, Mark Brown, Matthias Brugger,
	Rob Herring, Liam Girdwood, Krzysztof Kozlowski, Dmitry Torokhov,
	Chen Zhong
  Cc: linux-mediatek, devicetree, linux-arm-kernel, Rob Herring,
	linux-kernel, linux-input, Fabien Parent, Alexandre Mergnat

On Wed, Oct 05, 2022 at 16:57, Alexandre Mergnat <amergnat@baylibre.com> wrote:

> From: Fabien Parent <fparent@baylibre.com>
>
> Add PMIC Keys support on MT6357 SoC.
>
> Signed-off-by: Fabien Parent <fparent@baylibre.com>
> Signed-off-by: Alexandre Mergnat <amergnat@baylibre.com>

Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>

> ---
>  drivers/input/keyboard/mtk-pmic-keys.c | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
>
> diff --git a/drivers/input/keyboard/mtk-pmic-keys.c b/drivers/input/keyboard/mtk-pmic-keys.c
> index 9b34da0ec260..2a63e0718eb6 100644
> --- a/drivers/input/keyboard/mtk-pmic-keys.c
> +++ b/drivers/input/keyboard/mtk-pmic-keys.c
> @@ -10,6 +10,7 @@
>  #include <linux/kernel.h>
>  #include <linux/mfd/mt6323/registers.h>
>  #include <linux/mfd/mt6331/registers.h>
> +#include <linux/mfd/mt6357/registers.h>
>  #include <linux/mfd/mt6358/registers.h>
>  #include <linux/mfd/mt6397/core.h>
>  #include <linux/mfd/mt6397/registers.h>
> @@ -90,6 +91,19 @@ static const struct mtk_pmic_regs mt6331_regs = {
>  	.rst_lprst_mask = MTK_PMIC_MT6331_RST_DU_MASK,
>  };
>  
> +static const struct mtk_pmic_regs mt6357_regs = {
> +	.keys_regs[MTK_PMIC_PWRKEY_INDEX] =
> +		MTK_PMIC_KEYS_REGS(MT6357_TOPSTATUS,
> +				   0x2, MT6357_PSC_TOP_INT_CON0, 0x5,
> +				   MTK_PMIC_PWRKEY_RST),
> +	.keys_regs[MTK_PMIC_HOMEKEY_INDEX] =
> +		MTK_PMIC_KEYS_REGS(MT6357_TOPSTATUS,
> +				   0x8, MT6357_PSC_TOP_INT_CON0, 0xa,
> +				   MTK_PMIC_HOMEKEY_INDEX),
> +	.pmic_rst_reg = MT6357_TOP_RST_MISC,
> +	.rst_lprst_mask = MTK_PMIC_RST_DU_MASK,
> +};
> +
>  static const struct mtk_pmic_regs mt6358_regs = {
>  	.keys_regs[MTK_PMIC_PWRKEY_INDEX] =
>  		MTK_PMIC_KEYS_REGS(MT6358_TOPSTATUS,
> @@ -276,6 +290,9 @@ static const struct of_device_id of_mtk_pmic_keys_match_tbl[] = {
>  	}, {
>  		.compatible = "mediatek,mt6331-keys",
>  		.data = &mt6331_regs,
> +	}, {
> +		.compatible = "mediatek,mt6357-keys",
> +		.data = &mt6357_regs,
>  	}, {
>  		.compatible = "mediatek,mt6358-keys",
>  		.data = &mt6358_regs,
>
> -- 
> b4 0.10.1

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v2 4/5] regulator: add mt6357 regulator
  2022-10-05 14:57 ` [PATCH v2 4/5] regulator: add mt6357 regulator Alexandre Mergnat
  2022-10-05 15:09   ` Mark Brown
@ 2022-10-06 10:12   ` AngeloGioacchino Del Regno
  1 sibling, 0 replies; 18+ messages in thread
From: AngeloGioacchino Del Regno @ 2022-10-06 10:12 UTC (permalink / raw)
  To: Alexandre Mergnat, Lee Jones, Mark Brown, Matthias Brugger,
	Rob Herring, Liam Girdwood, Krzysztof Kozlowski, Dmitry Torokhov,
	Chen Zhong
  Cc: linux-mediatek, devicetree, linux-arm-kernel, Rob Herring,
	linux-kernel, linux-input, Fabien Parent

Il 05/10/22 16:57, Alexandre Mergnat ha scritto:
> From: Fabien Parent <fparent@baylibre.com>
> 
> Add regulator driver for the MT6357 PMIC.
> 
> Signed-off-by: Fabien Parent <fparent@baylibre.com>
> Signed-off-by: Alexandre Mergnat <amergnat@baylibre.com>
> ---
>   drivers/regulator/Kconfig                  |   9 +
>   drivers/regulator/Makefile                 |   1 +
>   drivers/regulator/mt6357-regulator.c       | 485 +++++++++++++++++++++++++++++
>   include/linux/regulator/mt6357-regulator.h |  51 +++
>   4 files changed, 546 insertions(+)
> 
> diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
> index 070e4403c6c2..a659a57438f4 100644
> --- a/drivers/regulator/Kconfig
> +++ b/drivers/regulator/Kconfig
> @@ -805,6 +805,15 @@ config REGULATOR_MT6332
>   	  This driver supports the control of different power rails of device
>   	  through regulator interface
>   
> +config REGULATOR_MT6357
> +	tristate "MediaTek MT6357 PMIC"
> +	depends on MFD_MT6397
> +	help
> +	  Say y here to select this option to enable the power regulator of
> +	  MediaTek MT6357 PMIC.
> +	  This driver supports the control of different power rails of device
> +	  through regulator interface.
> +
>   config REGULATOR_MT6358
>   	tristate "MediaTek MT6358 PMIC"
>   	depends on MFD_MT6397
> diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
> index 5962307e1130..e4d67b7b1af6 100644
> --- a/drivers/regulator/Makefile
> +++ b/drivers/regulator/Makefile
> @@ -97,6 +97,7 @@ obj-$(CONFIG_REGULATOR_MT6315) += mt6315-regulator.o
>   obj-$(CONFIG_REGULATOR_MT6323)	+= mt6323-regulator.o
>   obj-$(CONFIG_REGULATOR_MT6331)	+= mt6331-regulator.o
>   obj-$(CONFIG_REGULATOR_MT6332)	+= mt6332-regulator.o
> +obj-$(CONFIG_REGULATOR_MT6357)	+= mt6357-regulator.o
>   obj-$(CONFIG_REGULATOR_MT6358)	+= mt6358-regulator.o
>   obj-$(CONFIG_REGULATOR_MT6359)	+= mt6359-regulator.o
>   obj-$(CONFIG_REGULATOR_MT6360) += mt6360-regulator.o
> diff --git a/drivers/regulator/mt6357-regulator.c b/drivers/regulator/mt6357-regulator.c
> new file mode 100644
> index 000000000000..4ecd41429448
> --- /dev/null
> +++ b/drivers/regulator/mt6357-regulator.c
> @@ -0,0 +1,485 @@
> +// SPDX-License-Identifier: GPL-2.0
> +//
> +// Copyright (c) 2022 MediaTek Inc.
> +// Copyright (c) 2022 BayLibre, SAS.
> +// Author: Chen Zhong <chen.zhong@mediatek.com>
> +// Author: Fabien Parent <fparent@baylibre.com>
> +//
> +// Based on mt6397-regulator.c
> +//
> +
> +#include <linux/module.h>
> +#include <linux/linear_range.h>
> +#include <linux/of.h>
> +#include <linux/platform_device.h>
> +#include <linux/regmap.h>
> +#include <linux/mfd/mt6397/core.h>
> +#include <linux/mfd/mt6357/registers.h>
> +#include <linux/regulator/driver.h>
> +#include <linux/regulator/machine.h>
> +#include <linux/regulator/mt6357-regulator.h>
> +#include <linux/regulator/of_regulator.h>
> +
> +/*
> + * MT6357 regulators' information
> + *
> + * @desc: standard fields of regulator description.
> + * @vselon_reg: Register sections for hardware control mode of bucks
> + * @vselctrl_reg: Register for controlling the buck control mode.
> + * @vselctrl_mask: Mask for query buck's voltage control mode.
> + */
> +struct mt6357_regulator_info {
> +	struct regulator_desc desc;
> +	const u32 *index_table;
> +	unsigned int n_table;
> +	u32 vsel_shift;
> +	u32 da_vsel_reg;
> +	u32 da_vsel_mask;
> +	u32 da_vsel_shift;
> +};
> +
> +#define MT6357_BUCK(match, vreg, min, max, step,		\
> +	volt_ranges, vosel_reg, vosel_mask, _da_vsel_mask)		\
> +[MT6357_ID_##vreg] = {	\
> +	.desc = {	\
> +		.name = #vreg,	\
> +		.of_match = of_match_ptr(match),	\
> +		.regulators_node = "regulators",			\
> +		.ops = &mt6357_volt_range_ops,	\
> +		.type = REGULATOR_VOLTAGE,	\
> +		.id = MT6357_ID_##vreg,		\
> +		.owner = THIS_MODULE,		\
> +		.n_voltages = ((max) - (min)) / (step) + 1,	\
> +		.linear_ranges = volt_ranges,		\
> +		.n_linear_ranges = ARRAY_SIZE(volt_ranges),	\
> +		.vsel_reg = vosel_reg,	\
> +		.vsel_mask = vosel_mask,	\
> +		.enable_reg = MT6357_BUCK_##vreg##_CON0,	\
> +		.enable_mask = BIT(0),	\
> +	},	\
> +	.da_vsel_reg = MT6357_BUCK_##vreg##_DBG0,	\
> +	.da_vsel_mask = vosel_mask,	\
> +	.da_vsel_shift = 0,	\
> +}
> +
> +#define MT6357_LDO(match, vreg, ldo_volt_table,	\
> +	ldo_index_table, enreg, vosel,	\
> +	vosel_mask)	\
> +[MT6357_ID_##vreg] = {	\
> +	.desc = {	\
> +		.name = #vreg,	\
> +		.of_match = of_match_ptr(match),	\
> +		.regulators_node = "regulators",			\
> +		.ops = &mt6357_volt_table_ops,	\
> +		.type = REGULATOR_VOLTAGE,	\
> +		.id = MT6357_ID_##vreg,	\
> +		.owner = THIS_MODULE,	\
> +		.n_voltages = ARRAY_SIZE(ldo_volt_table),	\
> +		.volt_table = ldo_volt_table,	\
> +		.vsel_reg = vosel,	\
> +		.vsel_mask = vosel_mask << 8,	\
> +		.enable_reg = enreg,	\
> +		.enable_mask = BIT(0),	\
> +	},	\
> +	.index_table = ldo_index_table,	\
> +	.n_table = ARRAY_SIZE(ldo_index_table),	\
> +}
> +
> +#define MT6357_LDO1(match, vreg, min, max, step, volt_ranges,	\
> +	enreg, vosel, vosel_mask)	\
> +[MT6357_ID_##vreg] = {	\
> +	.desc = {	\
> +		.name = #vreg,	\
> +		.of_match = of_match_ptr(match),	\
> +		.regulators_node = "regulators",			\
> +		.ops = &mt6357_volt_range_ops,	\
> +		.type = REGULATOR_VOLTAGE,	\
> +		.id = MT6357_ID_##vreg,	\
> +		.owner = THIS_MODULE,	\
> +		.n_voltages = ((max) - (min)) / (step) + 1,	\
> +		.linear_ranges = volt_ranges,		\
> +		.n_linear_ranges = ARRAY_SIZE(volt_ranges),	\
> +		.vsel_reg = vosel,	\
> +		.vsel_mask = vosel_mask,	\
> +		.enable_reg = enreg,	\
> +		.enable_mask = BIT(0),	\
> +	},	\
> +	.da_vsel_reg = MT6357_LDO_##vreg##_DBG0,	\
> +	.da_vsel_mask = 0x7f,	\
> +	.da_vsel_shift = 8,	\

There's something wrong here: ((val & 0x7f) >> 8) is always zero,
and you're using mt6357_volt_range_ops, that is using function
mt6357_get_buck_voltage_sel, which is doing exactly that.

Regards,
Angelo


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v2 5/5] Input: mtk-pmic-keys: add MT6357 support
  2022-10-05 14:57 ` [PATCH v2 5/5] Input: mtk-pmic-keys: add MT6357 support Alexandre Mergnat
  2022-10-06  7:40   ` Mattijs Korpershoek
@ 2022-10-06 10:12   ` AngeloGioacchino Del Regno
  2022-10-10 18:04   ` Dmitry Torokhov
  2 siblings, 0 replies; 18+ messages in thread
From: AngeloGioacchino Del Regno @ 2022-10-06 10:12 UTC (permalink / raw)
  To: Alexandre Mergnat, Lee Jones, Mark Brown, Matthias Brugger,
	Rob Herring, Liam Girdwood, Krzysztof Kozlowski, Dmitry Torokhov,
	Chen Zhong
  Cc: linux-mediatek, devicetree, linux-arm-kernel, Rob Herring,
	linux-kernel, linux-input, Fabien Parent

Il 05/10/22 16:57, Alexandre Mergnat ha scritto:
> From: Fabien Parent <fparent@baylibre.com>
> 
> Add PMIC Keys support on MT6357 SoC.
> 
> Signed-off-by: Fabien Parent <fparent@baylibre.com>
> Signed-off-by: Alexandre Mergnat <amergnat@baylibre.com>
> Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>



^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v2 2/5] dt-bindings: input: mtk-pmic-keys: add binding for MT6357 PMIC
  2022-10-05 14:57 ` [PATCH v2 2/5] dt-bindings: input: mtk-pmic-keys: add binding for MT6357 PMIC Alexandre Mergnat
@ 2022-10-10 18:03   ` Dmitry Torokhov
  0 siblings, 0 replies; 18+ messages in thread
From: Dmitry Torokhov @ 2022-10-10 18:03 UTC (permalink / raw)
  To: Alexandre Mergnat
  Cc: Lee Jones, Mark Brown, Matthias Brugger, Rob Herring,
	Liam Girdwood, Krzysztof Kozlowski, Chen Zhong, linux-mediatek,
	devicetree, linux-arm-kernel, Rob Herring, linux-kernel,
	linux-input, Fabien Parent

On Wed, Oct 05, 2022 at 04:57:22PM +0200, Alexandre Mergnat wrote:
> From: Fabien Parent <fparent@baylibre.com>
> 
> Add binding documentation for the PMIC keys on MT6357.
> 
> Signed-off-by: Fabien Parent <fparent@baylibre.com>
> Signed-off-by: Alexandre Mergnat <amergnat@baylibre.com>
> Acked-by: Rob Herring <robh@kernel.org>

Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

Please merge through MFD with the rest of the patches.

> ---
>  Documentation/devicetree/bindings/input/mediatek,pmic-keys.yaml | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/Documentation/devicetree/bindings/input/mediatek,pmic-keys.yaml b/Documentation/devicetree/bindings/input/mediatek,pmic-keys.yaml
> index 2f72ec418415..037c3ae9f1c3 100644
> --- a/Documentation/devicetree/bindings/input/mediatek,pmic-keys.yaml
> +++ b/Documentation/devicetree/bindings/input/mediatek,pmic-keys.yaml
> @@ -26,6 +26,7 @@ properties:
>      enum:
>        - mediatek,mt6323-keys
>        - mediatek,mt6331-keys
> +      - mediatek,mt6357-keys
>        - mediatek,mt6358-keys
>        - mediatek,mt6397-keys
>  
> 
> -- 
> b4 0.10.1

Thanks.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v2 5/5] Input: mtk-pmic-keys: add MT6357 support
  2022-10-05 14:57 ` [PATCH v2 5/5] Input: mtk-pmic-keys: add MT6357 support Alexandre Mergnat
  2022-10-06  7:40   ` Mattijs Korpershoek
  2022-10-06 10:12   ` AngeloGioacchino Del Regno
@ 2022-10-10 18:04   ` Dmitry Torokhov
  2022-10-24 12:50     ` Lee Jones
  2 siblings, 1 reply; 18+ messages in thread
From: Dmitry Torokhov @ 2022-10-10 18:04 UTC (permalink / raw)
  To: Alexandre Mergnat
  Cc: Lee Jones, Mark Brown, Matthias Brugger, Rob Herring,
	Liam Girdwood, Krzysztof Kozlowski, Chen Zhong, linux-mediatek,
	devicetree, linux-arm-kernel, Rob Herring, linux-kernel,
	linux-input, Fabien Parent

On Wed, Oct 05, 2022 at 04:57:25PM +0200, Alexandre Mergnat wrote:
> From: Fabien Parent <fparent@baylibre.com>
> 
> Add PMIC Keys support on MT6357 SoC.
> 
> Signed-off-by: Fabien Parent <fparent@baylibre.com>
> Signed-off-by: Alexandre Mergnat <amergnat@baylibre.com>

Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

Please merge through MFD tree with the rest of the patches.

> ---
>  drivers/input/keyboard/mtk-pmic-keys.c | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
> 
> diff --git a/drivers/input/keyboard/mtk-pmic-keys.c b/drivers/input/keyboard/mtk-pmic-keys.c
> index 9b34da0ec260..2a63e0718eb6 100644
> --- a/drivers/input/keyboard/mtk-pmic-keys.c
> +++ b/drivers/input/keyboard/mtk-pmic-keys.c
> @@ -10,6 +10,7 @@
>  #include <linux/kernel.h>
>  #include <linux/mfd/mt6323/registers.h>
>  #include <linux/mfd/mt6331/registers.h>
> +#include <linux/mfd/mt6357/registers.h>
>  #include <linux/mfd/mt6358/registers.h>
>  #include <linux/mfd/mt6397/core.h>
>  #include <linux/mfd/mt6397/registers.h>
> @@ -90,6 +91,19 @@ static const struct mtk_pmic_regs mt6331_regs = {
>  	.rst_lprst_mask = MTK_PMIC_MT6331_RST_DU_MASK,
>  };
>  
> +static const struct mtk_pmic_regs mt6357_regs = {
> +	.keys_regs[MTK_PMIC_PWRKEY_INDEX] =
> +		MTK_PMIC_KEYS_REGS(MT6357_TOPSTATUS,
> +				   0x2, MT6357_PSC_TOP_INT_CON0, 0x5,
> +				   MTK_PMIC_PWRKEY_RST),
> +	.keys_regs[MTK_PMIC_HOMEKEY_INDEX] =
> +		MTK_PMIC_KEYS_REGS(MT6357_TOPSTATUS,
> +				   0x8, MT6357_PSC_TOP_INT_CON0, 0xa,
> +				   MTK_PMIC_HOMEKEY_INDEX),
> +	.pmic_rst_reg = MT6357_TOP_RST_MISC,
> +	.rst_lprst_mask = MTK_PMIC_RST_DU_MASK,
> +};
> +
>  static const struct mtk_pmic_regs mt6358_regs = {
>  	.keys_regs[MTK_PMIC_PWRKEY_INDEX] =
>  		MTK_PMIC_KEYS_REGS(MT6358_TOPSTATUS,
> @@ -276,6 +290,9 @@ static const struct of_device_id of_mtk_pmic_keys_match_tbl[] = {
>  	}, {
>  		.compatible = "mediatek,mt6331-keys",
>  		.data = &mt6331_regs,
> +	}, {
> +		.compatible = "mediatek,mt6357-keys",
> +		.data = &mt6357_regs,
>  	}, {
>  		.compatible = "mediatek,mt6358-keys",
>  		.data = &mt6358_regs,
> 
> -- 
> b4 0.10.1

Thanks.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v2 3/5] dt-bindings: regulator: Add binding schema for mt6357 regulators
  2022-10-05 16:02   ` Krzysztof Kozlowski
@ 2022-10-11  9:30     ` Alexandre Mergnat
  2022-10-11 10:36       ` Mark Brown
  2022-10-11 12:03       ` Krzysztof Kozlowski
  0 siblings, 2 replies; 18+ messages in thread
From: Alexandre Mergnat @ 2022-10-11  9:30 UTC (permalink / raw)
  To: krzysztof.kozlowski
  Cc: amergnat, broonie, chen.zhong, devicetree, dmitry.torokhov,
	fparent, krzysztof.kozlowski+dt, lee, lgirdwood,
	linux-arm-kernel, linux-input, linux-kernel, linux-mediatek,
	matthias.bgg, robh+dt, robh

Hi Krzysztof,

Thanks for your review !

 >> +
 >> +    properties:
 >> +      regulator-name:
 >> +        pattern: "^v(core|modem|pa|proc|s1)$"
 >
 > Why enforcing particular name of the regulator?

The regulator names are forced to match with the datasheet names.

I think it's a good practice to increase visibility between HW & SW.

Also, that keep consistency with other Mediatek PMIC schema.


Best regards,

Alexandre


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v2 3/5] dt-bindings: regulator: Add binding schema for mt6357 regulators
  2022-10-11  9:30     ` Alexandre Mergnat
@ 2022-10-11 10:36       ` Mark Brown
  2022-10-11 12:03       ` Krzysztof Kozlowski
  1 sibling, 0 replies; 18+ messages in thread
From: Mark Brown @ 2022-10-11 10:36 UTC (permalink / raw)
  To: Alexandre Mergnat
  Cc: krzysztof.kozlowski, chen.zhong, devicetree, dmitry.torokhov,
	fparent, krzysztof.kozlowski+dt, lee, lgirdwood,
	linux-arm-kernel, linux-input, linux-kernel, linux-mediatek,
	matthias.bgg, robh+dt, robh

[-- Attachment #1: Type: text/plain, Size: 454 bytes --]

On Tue, Oct 11, 2022 at 11:30:58AM +0200, Alexandre Mergnat wrote:

> > Why enforcing particular name of the regulator?

> The regulator names are forced to match with the datasheet names.

> I think it's a good practice to increase visibility between HW & SW.

> Also, that keep consistency with other Mediatek PMIC schema.

No, this is bad practice which completely misses the point of what the
names are for and the other Mediatek drivers are broken.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v2 3/5] dt-bindings: regulator: Add binding schema for mt6357 regulators
  2022-10-11  9:30     ` Alexandre Mergnat
  2022-10-11 10:36       ` Mark Brown
@ 2022-10-11 12:03       ` Krzysztof Kozlowski
  1 sibling, 0 replies; 18+ messages in thread
From: Krzysztof Kozlowski @ 2022-10-11 12:03 UTC (permalink / raw)
  To: Alexandre Mergnat
  Cc: broonie, chen.zhong, devicetree, dmitry.torokhov, fparent,
	krzysztof.kozlowski+dt, lee, lgirdwood, linux-arm-kernel,
	linux-input, linux-kernel, linux-mediatek, matthias.bgg, robh+dt,
	robh

On 11/10/2022 05:30, Alexandre Mergnat wrote:
> Hi Krzysztof,
> 
> Thanks for your review !
> 
>  >> +
>  >> +    properties:
>  >> +      regulator-name:
>  >> +        pattern: "^v(core|modem|pa|proc|s1)$"
>  >
>  > Why enforcing particular name of the regulator?
> 
> The regulator names are forced to match with the datasheet names.
> 
> I think it's a good practice to increase visibility between HW & SW.

Enforcing is not a good practice.

> 
> Also, that keep consistency with other Mediatek PMIC schema.

So there is a bad practice and instead of fixing it, you align to it... No.


Best regards,
Krzysztof


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v2 5/5] Input: mtk-pmic-keys: add MT6357 support
  2022-10-10 18:04   ` Dmitry Torokhov
@ 2022-10-24 12:50     ` Lee Jones
  0 siblings, 0 replies; 18+ messages in thread
From: Lee Jones @ 2022-10-24 12:50 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Alexandre Mergnat, Mark Brown, Matthias Brugger, Rob Herring,
	Liam Girdwood, Krzysztof Kozlowski, Chen Zhong, linux-mediatek,
	devicetree, linux-arm-kernel, Rob Herring, linux-kernel,
	linux-input, Fabien Parent

On Mon, 10 Oct 2022, Dmitry Torokhov wrote:

> On Wed, Oct 05, 2022 at 04:57:25PM +0200, Alexandre Mergnat wrote:
> > From: Fabien Parent <fparent@baylibre.com>
> > 
> > Add PMIC Keys support on MT6357 SoC.
> > 
> > Signed-off-by: Fabien Parent <fparent@baylibre.com>
> > Signed-off-by: Alexandre Mergnat <amergnat@baylibre.com>
> 
> Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> 
> Please merge through MFD tree with the rest of the patches.

The MFD part is only a small doc change.  The Input and Regulator
changes should be merged through their own subsystems IMHO.

-- 
Lee Jones [李琼斯]

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v2 1/5] dt-bindings: mfd: mt6397: add binding for MT6357
  2022-10-05 14:57 ` [PATCH v2 1/5] dt-bindings: mfd: mt6397: add binding for MT6357 Alexandre Mergnat
@ 2022-10-24 12:51   ` Lee Jones
  0 siblings, 0 replies; 18+ messages in thread
From: Lee Jones @ 2022-10-24 12:51 UTC (permalink / raw)
  To: Alexandre Mergnat
  Cc: Mark Brown, Matthias Brugger, Rob Herring, Liam Girdwood,
	Krzysztof Kozlowski, Dmitry Torokhov, Chen Zhong, linux-mediatek,
	devicetree, linux-arm-kernel, Rob Herring, linux-kernel,
	linux-input, Fabien Parent

On Wed, 05 Oct 2022, Alexandre Mergnat wrote:

> From: Fabien Parent <fparent@baylibre.com>
> 
> Add binding documentation for the MT6357 PMIC.
> 
> Signed-off-by: Fabien Parent <fparent@baylibre.com>
> Signed-off-by: Alexandre Mergnat <amergnat@baylibre.com>
> Acked-by: Rob Herring <robh@kernel.org>
> ---
>  Documentation/devicetree/bindings/mfd/mt6397.txt | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/Documentation/devicetree/bindings/mfd/mt6397.txt b/Documentation/devicetree/bindings/mfd/mt6397.txt
> index 0088442efca1..518986c44880 100644
> --- a/Documentation/devicetree/bindings/mfd/mt6397.txt
> +++ b/Documentation/devicetree/bindings/mfd/mt6397.txt
> @@ -21,6 +21,7 @@ Required properties:
>  compatible:
>  	"mediatek,mt6323" for PMIC MT6323
>  	"mediatek,mt6331" for PMIC MT6331 and MT6332
> +	"mediatek,mt6357" for PMIC MT6357
>  	"mediatek,mt6358" for PMIC MT6358 and MT6366
>  	"mediatek,mt6359" for PMIC MT6359
>  	"mediatek,mt6397" for PMIC MT6397

Let me know when it's safe to merge this.

-- 
Lee Jones [李琼斯]

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2022-10-24 21:11 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-05 14:57 [PATCH v2 0/5] Add MediaTek MT6357 PMIC support Alexandre Mergnat
2022-10-05 14:57 ` [PATCH v2 1/5] dt-bindings: mfd: mt6397: add binding for MT6357 Alexandre Mergnat
2022-10-24 12:51   ` Lee Jones
2022-10-05 14:57 ` [PATCH v2 2/5] dt-bindings: input: mtk-pmic-keys: add binding for MT6357 PMIC Alexandre Mergnat
2022-10-10 18:03   ` Dmitry Torokhov
2022-10-05 14:57 ` [PATCH v2 3/5] dt-bindings: regulator: Add binding schema for mt6357 regulators Alexandre Mergnat
2022-10-05 16:02   ` Krzysztof Kozlowski
2022-10-11  9:30     ` Alexandre Mergnat
2022-10-11 10:36       ` Mark Brown
2022-10-11 12:03       ` Krzysztof Kozlowski
2022-10-05 14:57 ` [PATCH v2 4/5] regulator: add mt6357 regulator Alexandre Mergnat
2022-10-05 15:09   ` Mark Brown
2022-10-06 10:12   ` AngeloGioacchino Del Regno
2022-10-05 14:57 ` [PATCH v2 5/5] Input: mtk-pmic-keys: add MT6357 support Alexandre Mergnat
2022-10-06  7:40   ` Mattijs Korpershoek
2022-10-06 10:12   ` AngeloGioacchino Del Regno
2022-10-10 18:04   ` Dmitry Torokhov
2022-10-24 12:50     ` Lee Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).