Skip to contentSkip to conversation

regulator: mt6360: Add support for MT6360 regulator

PATCH Superseded Gene Chen 2 participants 17 messages Aug 20, 2020 – Aug 26, 2020

Subsystems (4)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Gene Chen

author
#0 lore raw

v3 cover regulator: mt6360: Add support for MT6360 regulator

This patch series add MT6360 regulator support contains driver and binding document

Gene Chen (2)
regulator: mt6360: Add support for MT6360 regulator
regulator: mt6360: Add DT binding documentation

 Documentation/devicetree/bindings/regulator/mt6360-regulator.yaml |  109 ++
 drivers/regulator/Kconfig                                         |    9 
 drivers/regulator/Makefile                                        |    1 
 drivers/regulator/mt6360-regulator.c                              |  458 ++++++++++
 include/dt-bindings/regulator/mediatek,mt6360-regulator.h         |   16 
 5 files changed, 593 insertions(+)

changelogs between v1 & v2
- regulator: merge regmap to mfd driver for r/w with crc

changelogs between v2 & v3
- Move regmap define to MFD parent driver
- Add bindings document

author
#7 lore raw

PATCH v3 2/2 regulator: mt6360: Add DT binding documentation

From: Gene Chen <[email protected]>

Add a devicetree binding documentation for the mt6360 regulator driver.

---
 .../bindings/regulator/mt6360-regulator.yaml       | 109 +++++++++++++++++++++
 1 file changed, 109 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/regulator/mt6360-regulator.yaml
Documentation/devicetree/bindings/regulator/mt6360-regulator.yaml new file +109 -0
new file mode 100644
index 0000000..bd66754
@@ -0,0 +1,109 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/regulator/mt6360-regulator.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: MT6360 Regulator from MediaTek Integrated
+
+maintainers:
+  - Gene Chen <[email protected]>
+
+description: |
+  list of regulators provided by this controller, must be named
+  after their hardware counterparts buck1/2 or ldo1/2/3/5/6/7
+
+properties:
+  compatible:
+    const: mediatek,mt6360-regulator
+
+  LDO_VIN3-supply:
+    description: Input supply phandle(s) for LDO3
+
+patternProperties:
+  "^buck[12]$":
+    $ref: "regulator.yaml#"
+
+  "^ldo[123567]$":
+    $ref: "regulator.yaml#"
+
+required:
+  - compatible
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/irq.h>
+    #include <dt-bindings/regulator/mediatek,mt6360-regulator.h>
+    regulator {
+      compatible = "mediatek,mt6360-regulator";
+      LDO_VIN3-supply = <&BUCK2>;
+      buck1 {
+        regulator-compatible = "BUCK1";
+        regulator-name = "mt6360,buck1";
+        regulator-min-microvolt = <300000>;
+        regulator-max-microvolt = <1300000>;
+        regulator-allowed-modes = <MT6360_OPMODE_NORMAL
+             MT6360_OPMODE_LP
+             MT6360_OPMODE_ULP>;
+      };
+      BUCK2: buck2 {
+        regulator-compatible = "BUCK2";
+        regulator-name = "mt6360,buck2";
+        regulator-min-microvolt = <300000>;
+        regulator-max-microvolt = <1300000>;
+        regulator-allowed-modes = <MT6360_OPMODE_NORMAL
+             MT6360_OPMODE_LP
+             MT6360_OPMODE_ULP>;
+      };
+      ldo6 {
+        regulator-compatible = "LDO6";
+        regulator-name = "mt6360,ldo6";
+        regulator-min-microvolt = <500000>;
+        regulator-max-microvolt = <2100000>;
+        regulator-allowed-modes = <MT6360_OPMODE_NORMAL
+             MT6360_OPMODE_LP>;
+      };
+      ldo7 {
+        regulator-compatible = "LDO7";
+        regulator-name = "mt6360,ldo7";
+        regulator-min-microvolt = <500000>;
+        regulator-max-microvolt = <2100000>;
+        regulator-allowed-modes = <MT6360_OPMODE_NORMAL
+             MT6360_OPMODE_LP>;
+      };
+      ldo1 {
+        regulator-compatible = "LDO1";
+        regulator-name = "mt6360,ldo1";
+        regulator-min-microvolt = <1200000>;
+        regulator-max-microvolt = <3600000>;
+        regulator-allowed-modes = <MT6360_OPMODE_NORMAL
+             MT6360_OPMODE_LP>;
+      };
+        ldo2 {
+        regulator-compatible = "LDO2";
+        regulator-name = "mt6360,ldo2";
+        regulator-min-microvolt = <1200000>;
+        regulator-max-microvolt = <3600000>;
+        regulator-allowed-modes = <MT6360_OPMODE_NORMAL
+             MT6360_OPMODE_LP>;
+      };
+      ldo3 {
+        regulator-compatible = "LDO3";
+        regulator-name = "mt6360,ldo3";
+        regulator-min-microvolt = <1200000>;
+        regulator-max-microvolt = <3600000>;
+        regulator-allowed-modes = <MT6360_OPMODE_NORMAL
+             MT6360_OPMODE_LP>;
+      };
+      ldo5 {
+        regulator-compatible = "LDO5";
+        regulator-name = "mt6360,ldo5";
+        regulator-min-microvolt = <2700000>;
+        regulator-max-microvolt = <3600000>;
+        regulator-allowed-modes = <MT6360_OPMODE_NORMAL
+             MT6360_OPMODE_LP>;
+      };
+    };
+...
Signature · 1 line
2.7.4
author
#1 lore raw

PATCH v3 1/2 regulator: mt6360: Add support for MT6360 regulator

In reply to Gene Chen

From: Gene Chen <[email protected]>

Add MT6360 regulator driver that contains two BUCKs and six LDOs

---
 drivers/regulator/Kconfig                          |   9 +
 drivers/regulator/Makefile                         |   1 +
 drivers/regulator/mt6360-regulator.c               | 458 +++++++++++++++++++++
 .../regulator/mediatek,mt6360-regulator.h          |  16 +
 4 files changed, 484 insertions(+)
 create mode 100644 drivers/regulator/mt6360-regulator.c
 create mode 100644 include/dt-bindings/regulator/mediatek,mt6360-regulator.h
drivers/regulator/Kconfig +9 -0
index de17ef7..8a6c3c6 100644
@@ -711,6 +711,15 @@ config REGULATOR_MT6358
 	  This driver supports the control of different power rails of device
 	  through regulator interface.
 
+config REGULATOR_MT6360
+	tristate "MT6360 SubPMIC Regulator"
+	depends on MFD_MT6360
+	help
+	  Say Y here to enable MT6360 regulator support.
+	  This is support MT6360 PMIC/LDO part include
+	  2-channel buck with Thermal Shutdown and Overload Protection
+	  6-channel High PSRR and Low Dropout LDO.
+
 config REGULATOR_MT6380
 	tristate "MediaTek MT6380 PMIC"
 	depends on MTK_PMIC_WRAP
drivers/regulator/Makefile +1 -0
index d8d3ecf..821a33f 100644
@@ -88,6 +88,7 @@ obj-$(CONFIG_REGULATOR_MPQ7920) += mpq7920.o
 obj-$(CONFIG_REGULATOR_MT6311) += mt6311-regulator.o
 obj-$(CONFIG_REGULATOR_MT6323)	+= mt6323-regulator.o
 obj-$(CONFIG_REGULATOR_MT6358)	+= mt6358-regulator.o
+obj-$(CONFIG_REGULATOR_MT6360) += mt6360-regulator.o
 obj-$(CONFIG_REGULATOR_MT6380)	+= mt6380-regulator.o
 obj-$(CONFIG_REGULATOR_MT6397)	+= mt6397-regulator.o
 obj-$(CONFIG_REGULATOR_QCOM_LABIBB) += qcom-labibb-regulator.o
drivers/regulator/mt6360-regulator.c new file +458 -0

458 lines not on this page · raw message

include/dt-bindings/regulator/mediatek,mt6360-regulator.h new file +16 -0
new file mode 100644
index 0000000..21c75de
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#ifndef __DT_BINDINGS_MEDIATEK_MT6360_REGULATOR_H__
+#define __DT_BINDINGS_MEDIATEK_MT6360_REGULATOR_H__
+
+/*
+ * BUCK/LDO mode constants which may be used in devicetree properties
+ * (eg. regulator-allowed-modes).
+ * See the manufacturer's datasheet for more information on these modes.
+ */
+
+#define MT6360_OPMODE_LP		2
+#define MT6360_OPMODE_ULP		3
+#define MT6360_OPMODE_NORMAL		0
+
+#endif
Signature · 1 line
2.7.4
maintainer
#8 lore raw

Re: [PATCH v3 2/2] regulator: mt6360: Add DT binding documentation

In reply to Gene Chen

Documentation/devicetree/bindings/regulator/mt6360-regulator.yaml line 22

Quoted 7 lines · Gene Chen
Documentation/devicetree/bindings/regulator/mt6360-regulator.yaml new file +7 -0
+properties:
+  compatible:
+    const: mediatek,mt6360-regulator
+
+  LDO_VIN3-supply:
+    description: Input supply phandle(s) for LDO3
+

Only LDO3 needs a supply?

_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek

maintainer
#2 lore raw
In reply to Gene Chen

drivers/regulator/mt6360-regulator.c line 445

Quoted 11 lines · Gene Chen
drivers/regulator/mt6360-regulator.c new file +10 -0
+	mrd->regmap = dev_get_regmap(pdev->dev.parent, NULL);
+	if (!mrd->regmap) {
+		dev_err(&pdev->dev, "Failed to get parent regmap\n");
+		return -ENODEV;
+	}
 
+static const struct of_device_id __maybe_unused mt6360_regulator_of_id[] = {
+	{ .compatible = "mediatek,mt6360-regulator", },
+	{},
+};
+MODULE_DEVICE_TABLE(of, mt6360_regulator_of_id);

This device only exists in the context of a single parent device, there should be no need for a compatible string here - this is just a detail of how Linux does things. The MFD should just instntiate the platform device.

_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek

author
#9 lore raw

Re: [PATCH v3 2/2] regulator: mt6360: Add DT binding documentation

In reply to Mark Brown

⊕

Mark Brown <[email protected]> 於 2020年8月20日 週四 下午7:30寫道:

Quoted 12 lines · Gene Chen

Documentation/devicetree/bindings/regulator/mt6360-regulator.yaml line 22

Quoted 8 lines
Documentation/devicetree/bindings/regulator/mt6360-regulator.yaml new file +7 -0
+properties:
+  compatible:
+    const: mediatek,mt6360-regulator
+
+  LDO_VIN3-supply:
+    description: Input supply phandle(s) for LDO3
+

Only LDO3 needs a supply?

LDO_VIN1/LDO_VIN2 is real MT6360 pin supply from VSYS to LDO1/2/3/5 LDO_VIN3 is also real pin supply from BUCK2 to LDO6/7

author
#3 lore raw
In reply to Mark Brown

Mark Brown <[email protected]> 於 2020年8月20日 週四 下午7:45寫道:

Quoted 9 lines · Gene Chen
Quoted 6 lines
drivers/regulator/mt6360-regulator.c new file +5 -0
+     mrd->regmap = dev_get_regmap(pdev->dev.parent, NULL);
+     if (!mrd->regmap) {
+             dev_err(&pdev->dev, "Failed to get parent regmap\n");
+             return -ENODEV;
+     }
Quoted 10 lines

drivers/regulator/mt6360-regulator.c line 445

Quoted 5 lines
drivers/regulator/mt6360-regulator.c new file +5 -0
+static const struct of_device_id __maybe_unused mt6360_regulator_of_id[] = {
+     { .compatible = "mediatek,mt6360-regulator", },
+     {},
+};
+MODULE_DEVICE_TABLE(of, mt6360_regulator_of_id);

This device only exists in the context of a single parent device, there should be no need for a compatible string here - this is just a detail of how Linux does things. The MFD should just instntiate the platform device.

Trying to autoload module without of_id_table will cause run-time error:
ueventd: LoadWithAliases was unable to load of:NregulatorT(null)Cmediatek,mt6360-regulator

https://lore.kernel.org/patchwork/patch/726691/
According to this patch, autoload can't load module which doesn't include add id_table or of_id_table in module.alias
So I need keep of_if_table for auto load success

maintainer
#4 lore raw
Quoted 10 lines · Gene Chen

Mark Brown <[email protected]> 於 2020年8月20日 週四 下午7:45寫道:

Quoted 4 lines

This device only exists in the context of a single parent device, there should be no need for a compatible string here - this is just a detail of how Linux does things. The MFD should just instntiate the platform device.

Trying to autoload module without of_id_table will cause run-time error:
ueventd: LoadWithAliases was unable to load of:NregulatorT(null)Cmediatek,mt6360-regulator

You shouldn't have this described in the device tree at all, like I say the MFD should just instantiate the platform device.

maintainer
#10 lore raw

Re: [PATCH v3 2/2] regulator: mt6360: Add DT binding documentation

In reply to Gene Chen
Quoted 9 lines · Gene Chen
Quoted 6 lines · Gene Chen

Documentation/devicetree/bindings/regulator/mt6360-regulator.yaml line 21

Quoted 3 lines
Documentation/devicetree/bindings/regulator/mt6360-regulator.yaml new file +2 -0
+  LDO_VIN3-supply:
+    description: Input supply phandle(s) for LDO3

Only LDO3 needs a supply?

LDO_VIN1/LDO_VIN2 is real MT6360 pin supply from VSYS to LDO1/2/3/5 LDO_VIN3 is also real pin supply from BUCK2 to LDO6/7

So shouldn't there be a documented LDO_VIN1/2 then?

author
#5 lore raw
In reply to Mark Brown

Mark Brown <[email protected]> 於 2020年8月24日 週一 下午7:05寫道:

Quoted 9 lines · Gene Chen
Quoted 6 lines

Mark Brown <[email protected]> 於 2020年8月20日 週四 下午7:45寫道:

Quoted 4 lines

This device only exists in the context of a single parent device, there should be no need for a compatible string here - this is just a detail of how Linux does things. The MFD should just instntiate the platform device.

Quoted 6 lines
Quoted 3 lines

Trying to autoload module without of_id_table will cause run-time error:
ueventd: LoadWithAliases was unable to load of:NregulatorT(null)Cmediatek,mt6360-regulator

You shouldn't have this described in the device tree at all, like I say the MFD should just instantiate the platform device.

After I replace of_device_id by platform_device_id as below, I can autoload module.
But I can't get of_node to parse init_data.
Should I use dev->parent->of_node and set regulator_desc.regulator_node to parse each regulator definition in device tree?

drivers/mfd/mt6360-core.c +1 -1
index e995220..444dc8e 100644
@@ -328,7 +328,7 @@ static const struct mfd_cell mt6360_devs[] = {
        OF_MFD_CELL("mt6360-led", mt6360_led_resources,
                    NULL, 0, 0, "mediatek,mt6360-led"),
        OF_MFD_CELL("mt6360-regulator", mt6360_regulator_resources,
-                   NULL, 0, 0, "mediatek,mt6360-regulator"),
+                   NULL, 0, 0, NULL),
        OF_MFD_CELL("mt6360-tcpc", NULL,
                    NULL, 0, 0, "mediatek,mt6360-tcpc"),
 };
(quoted diff) +0 -0

b/drivers/regulator/mt6360-regulator.c
index 97c16a2..d525bf1 100644

drivers/regulator/mt6360-regulator.c +0 -0
@@ -438,11 +438,18 @@ static int mt6360_regulator_probe(struct

platform_device *pdev)

        return 0;

}

+static const struct platform_device_id mt6360_regulator_id[] = {
+ { "mt6360-regulator", },
+ { },
+};
+MODULE_DEVICE_TABLE(platform, mt6360_regulator_id);
+

 static struct platform_driver mt6360_regulator_driver = {
        .driver = {
                .name = "mt6360-regulator",
        },
        .probe = mt6360_regulator_probe,

+ .id_table = mt6360_regulator_id,
};

author
#11 lore raw

Re: [PATCH v3 2/2] regulator: mt6360: Add DT binding documentation

In reply to Mark Brown

Mark Brown <[email protected]> 於 2020年8月25日 週二 上午3:49寫道:

Quoted 7 lines · Gene Chen
Quoted 4 lines
Quoted 4 lines · Gene Chen
Quoted 3 lines
Documentation/devicetree/bindings/regulator/mt6360-regulator.yaml new file +2 -0
+  LDO_VIN3-supply:
+    description: Input supply phandle(s) for LDO3
Quoted 6 lines
Quoted 4 lines
Quoted 1 line

Only LDO3 needs a supply?

LDO_VIN1/LDO_VIN2 is real MT6360 pin supply from VSYS to LDO1/2/3/5 LDO_VIN3 is also real pin supply from BUCK2 to LDO6/7

So shouldn't there be a documented LDO_VIN1/2 then?

LDO_VINx is HW design layout, so actually it can't be changed by device tree. LDO_VIN1/LDO_VIN2 supply from VSYS, not regulator, so I think usually not to show the supply from in device tree.
or I should declare a dummy reference to system power like "*-supply = <&system_power>;"?

maintainer
#6 lore raw
In reply to Gene Chen
Quoted 3 lines · Gene Chen

Should I use dev->parent->of_node and set regulator_desc.regulator_node to parse each regulator definition in device tree?

Yes.

maintainer
#12 lore raw

Re: [PATCH v3 2/2] regulator: mt6360: Add DT binding documentation

In reply to Gene Chen
Quoted 9 lines · Gene Chen

Mark Brown <[email protected]> 於 2020年8月25日 週二 上午3:49寫道:

Quoted 1 line

So shouldn't there be a documented LDO_VIN1/2 then?

LDO_VINx is HW design layout, so actually it can't be changed by device tree. LDO_VIN1/LDO_VIN2 supply from VSYS, not regulator, so I think usually not to show the supply from in device tree.
or I should declare a dummy reference to system power like "*-supply = <&system_power>;"?

When you say it's from the hardware design do you mean it's fixed by the silicon or is this something that's fixed in the board?

author
#13 lore raw

Re: [PATCH v3 2/2] regulator: mt6360: Add DT binding documentation

Mark Brown <[email protected]> 於 2020年8月25日 週二 下午5:34寫道:

Quoted 6 lines · Gene Chen
Quoted 3 lines

Mark Brown <[email protected]> 於 2020年8月25日 週二 上午3:49寫道:

Quoted 1 line

So shouldn't there be a documented LDO_VIN1/2 then?

Quoted 8 lines
Quoted 5 lines

LDO_VINx is HW design layout, so actually it can't be changed by device tree. LDO_VIN1/LDO_VIN2 supply from VSYS, not regulator, so I think usually not to show the supply from in device tree.
or I should declare a dummy reference to system power like "*-supply = <&system_power>;"?

When you say it's from the hardware design do you mean it's fixed by the silicon or is this something that's fixed in the board?

fixed in the board, not silicon.

maintainer
#14 lore raw

Re: [PATCH v3 2/2] regulator: mt6360: Add DT binding documentation

Quoted 8 lines · Gene Chen

Mark Brown <[email protected]> 於 2020年8月25日 週二 下午5:34寫道:

Quoted 5 lines
Quoted 5 lines

LDO_VINx is HW design layout, so actually it can't be changed by device tree. LDO_VIN1/LDO_VIN2 supply from VSYS, not regulator, so I think usually not to show the supply from in device tree.
or I should declare a dummy reference to system power like "*-supply = <&system_power>;"?

Quoted 4 lines
Quoted 2 lines

When you say it's from the hardware design do you mean it's fixed by the silicon or is this something that's fixed in the board?

fixed in the board, not silicon.

Ah, if it's fixed by the board that's exactly the sort of thing that should be in DT - the DT describes the board so if some other system has a different configuration then it will have a different DT. With supply properties you can just leave them missing in the DT, you're not supposed to but so many systems do it that the framework will handle it. Otherwise if you want to represent VSYS you can have a fixed voltage regulator with no control and hook them up to it.

author
#15 lore raw

Re: [PATCH v3 2/2] regulator: mt6360: Add DT binding documentation

Mark Brown <[email protected]> 於 2020年8月25日 週二 下午6:08寫道:

Quoted 15 lines · Gene Chen
Quoted 8 lines

Mark Brown <[email protected]> 於 2020年8月25日 週二 下午5:34寫道:

Quoted 5 lines
Quoted 5 lines

LDO_VINx is HW design layout, so actually it can't be changed by device tree. LDO_VIN1/LDO_VIN2 supply from VSYS, not regulator, so I think usually not to show the supply from in device tree.
or I should declare a dummy reference to system power like "*-supply = <&system_power>;"?

Quoted 4 lines
Quoted 2 lines

When you say it's from the hardware design do you mean it's fixed by the silicon or is this something that's fixed in the board?

fixed in the board, not silicon.

Quoted 7 lines

Ah, if it's fixed by the board that's exactly the sort of thing that should be in DT - the DT describes the board so if some other system has a different configuration then it will have a different DT. With supply properties you can just leave them missing in the DT, you're not supposed to but so many systems do it that the framework will handle it. Otherwise if you want to represent VSYS you can have a fixed voltage regulator with no control and hook them up to it.

ok, I think I will follow the framework to handle it.
I will add supply description in devicetree
LDO_VIN1-supply:
description: Input supply phandle(s) for LDO1/2/3 which is supply from VSYS
LDO_VIN2-supply:
description: Input supply phandle(s) for LDO5 which is supply from
VSYS
LDO_VIN3-supply:
description: Input supply phandle(s) for LDO6/7

maintainer
#16 lore raw
In reply to Gene Chen
Quoted 6 lines · Gene Chen

This patch series add MT6360 regulator support contains driver and binding document

Gene Chen (2)
regulator: mt6360: Add support for MT6360 regulator
regulator: mt6360: Add DT binding documentation

Quoted 8 lines
 Documentation/devicetree/bindings/regulator/mt6360-regulator.yaml |  109 ++
 drivers/regulator/Kconfig                                         |    9
 drivers/regulator/Makefile                                        |    1
 drivers/regulator/mt6360-regulator.c                              |  458 ++++++++++
 include/dt-bindings/regulator/mediatek,mt6360-regulator.h         |   16
 5 files changed, 593 insertions(+)

[...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-next

Thanks!

[1/2] regulator: mt6360: Add support for MT6360 regulator

      commit: d321571d5e4c2d5511b75e6cf1a910e0a0c2a2e9

[2/2] regulator: mt6360: Add DT binding documentation
(no commit info)

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark