Skip to contentSkip to conversation

Add regulator support for mpq7920

PATCH Superseded Saravanan Sekar 2 participants 7 messages Dec 26, 2019 – Jan 3, 2020

Subsystems (3)

v4 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Saravanan Sekar

author maintainer
#0 lore raw

v4 cover Add regulator support for mpq7920

Changes in V4:
- fixed 0-DAY warnings

Changes in V3:
- fixed review comments in Documentation and dt_bindings_check passed

Changes in V2:
- fixed all the review comments in the driver, avoid ternery operator, inline & constant
- fixed/modifed review comments in Documentation

This patch series add support for PMIC regulator driver for Monolithic Power System's MPQ7920 chipset. MPQ7920 provides support for 4-BUCK converter, one fixed voltage RTCLDO and 4-LDO regualtor, accessed over I2C.

Saravanan Sekar (4):
dt-bindings: Add an entry for Monolithic Power System, MPS
dt-bindings: regulator: add document bindings for mpq7920
regulator: mpq7920: add mpq7920 regulator driver
MAINTAINERS: Add entry for mpq7920 PMIC driver

 .../bindings/regulator/mpq7920.yaml           | 143 +++++++
 .../devicetree/bindings/vendor-prefixes.yaml  |   2 +
 MAINTAINERS                                   |   7 +
 drivers/regulator/Kconfig                     |  10 +
 drivers/regulator/Makefile                    |   1 +
 drivers/regulator/mpq7920.c                   | 392 ++++++++++++++++++
 drivers/regulator/mpq7920.h                   |  72 ++++
 7 files changed, 627 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/regulator/mpq7920.yaml
 create mode 100644 drivers/regulator/mpq7920.c
 create mode 100644 drivers/regulator/mpq7920.h
Signature · 1 line
2.17.1
author maintainer
#1 lore raw

PATCH v4 1/4 dt-bindings: Add an entry for Monolithic Power System, MPS

Add an entry for Monolithic Power System, MPS

---
 Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++
 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/vendor-prefixes.yaml +2 -0
index 6046f4555852..5eac9d08bfa8 100644
@@ -605,6 +605,8 @@ patternProperties:
     description: MiraMEMS Sensing Technology Co., Ltd.
   "^mitsubishi,.*":
     description: Mitsubishi Electric Corporation
+  "^mps,.*":
+    description: Monolithic Power Systems, Inc.
   "^mosaixtech,.*":
     description: Mosaix Technologies, Inc.
   "^motorola,.*":
Signature · 1 line
2.17.1
author maintainer
#3 lore raw

PATCH v4 2/4 dt-bindings: regulator: add document bindings for mpq7920

In reply to Saravanan Sekar

Add device tree binding information for mpq7920 regulator driver. Example bindings for mpq7920 are added.

---
 .../bindings/regulator/mpq7920.yaml           | 143 ++++++++++++++++++
 1 file changed, 143 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/regulator/mpq7920.yaml
Documentation/devicetree/bindings/regulator/mpq7920.yaml new file +143 -0
new file mode 100644
index 000000000000..54e9177dfd1b
@@ -0,0 +1,143 @@
+# SPDX-License-Identifier: GPL-2.0
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/regulator/mpq7920.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Monolithic Power System MPQ7920 PMIC
+
+maintainers:
+  - Saravanan Sekar <[email protected]>
+
+properties:
+  $nodename:
+    pattern: "pmic@[0-9a-f]{1,2}"
+  compatible:
+    enum:
+      - mps,mpq7920
+
+  reg:
+    maxItems: 1
+
+  mps,time-slot:
+    description:
+      each regulator output shall be delayed during power on/off sequence which
+      based on configurable time slot value, must be one of following corresponding
+      value 0.5ms, 2ms, 8ms, 16ms
+    allOf:
+      - $ref: "/schemas/types.yaml#/definitions/uint8"
+      - enum: [ 0, 1, 2, 3 ]
+      - default: 0
+
+  mps,fixed-on-time:
+     description:
+       select power on sequence with fixed time output delay mentioned in
+       time-slot reg for all the regulators.
+     type: boolean
+
+  mps,fixed-off-time:
+     description:
+        select power off sequence with fixed time output delay mentioned in
+        time-slot reg for all the regulators.
+     type: boolean
+
+  mps,inc-off-time:
+     description: |
+        mutually exclusive to mps,fixed-off-time an array of 8, linearly increase
+        output delay during power off sequence based on factor of time slot/interval
+        for each regulator.
+     allOf:
+       - $ref: "/schemas/types.yaml#/definitions/uint8-array"
+       - minimum: 0
+       - maximum: 15
+       - default: [ 0, 6, 0, 6, 7, 7, 7, 9 ]
+
+  mps,inc-on-time:
+     description: |
+        mutually exclusive to mps,fixed-on-time an array of 8, linearly increase
+        output delay during power on sequence based on factor of time slot/interval
+        for each regulator.
+     allOf:
+       - $ref: "/schemas/types.yaml#/definitions/uint8-array"
+       - minimum: 0
+       - maximum: 15
+       - default: [ 0, 6, 0, 6, 7, 7, 7, 9 ]
+
+  mps,switch-freq:
+     description: |
+        switching frequency must be one of following corresponding value
+        1.1MHz, 1.65MHz, 2.2MHz, 2.75MHz
+     allOf:
+       - $ref: "/schemas/types.yaml#/definitions/uint8"
+       - enum: [ 0, 1, 2, 3 ]
+       - default: 2
+
+  mps,buck-softstart:
+     description: |
+        An array of 4 contains soft start time of each buck, must be one of
+        following corresponding values 150us, 300us, 610us, 920us
+     allOf:
+       - $ref: "/schemas/types.yaml#/definitions/uint8-array"
+       - enum: [ 0, 1, 2, 3 ]
+       - default: [ 1, 1, 1, 1 ]
+
+  mps,buck-ovp:
+     description: |
+        An array of 4 contains over voltage protection of each buck, must be
+        one of above values
+     allOf:
+       - $ref: "/schemas/types.yaml#/definitions/uint8-array"
+       - enum: [ 0, 1 ]
+       - default: [ 1, 1, 1, 1 ]
+
+  mps,buck-phase-delay:
+     description: |
+        An array of 4 contains phase delay of each buck must be one of above values
+        corresponding to 0deg, 90deg, 180deg, 270deg
+     allOf:
+       - $ref: "/schemas/types.yaml#/definitions/uint8-array"
+       - enum: [ 0, 1, 2, 3 ]
+       - default: [ 0, 0, 1, 1 ]
+
+  regulators:
+    type: object
+    description:
+      list of regulators provided by this controller, must be named
+      after their hardware counterparts BUCK[1-4], one LDORTC, and LDO[2-5]
+      The valid names for regulators are
+      buck1, buck2, buck3, buck4, ldortc, ldo2, ldo3, ldo4, ldo5
+
+
+examples:
+  - |
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        pmic@69 {
+          compatible = "mps,mpq7920";
+          reg = <0x69>;
+
+          mps,switch-freq = <1>;
+          mps,buck-softstart = /bits/ 8 <1 2 1 3>;
+          mps,buck-ovp = /bits/ 8 <1 0 1 1>;
+
+          regulators {
+            buck1 {
+             regulator-name = "buck1";
+             regulator-min-microvolt = <400000>;
+             regulator-max-microvolt = <3587500>;
+             regulator-min-microamp  = <460000>;
+             regulator-max-microamp  = <7600000>;
+             regulator-boot-on;
+            };
+
+            ldo2 {
+             regulator-name = "ldo2";
+             regulator-min-microvolt = <650000>;
+             regulator-max-microvolt = <3587500>;
+            };
+         };
+       };
+     };
+...
Signature · 1 line
2.17.1
maintainer
#4 lore raw

Re: [PATCH v4 2/4] dt-bindings: regulator: add document bindings for mpq7920

Quoted 6 lines · Saravanan Sekar

Add device tree binding information for mpq7920 regulator driver. Example bindings for mpq7920 are added.

---
 .../bindings/regulator/mpq7920.yaml           | 143 ++++++++++++++++++

Convention is use the compatible string: mps,mpq7920.yaml

Documentation/devicetree/bindings/regulator/mpq7920.yaml line 1

Quoted 10 lines
 1 file changed, 143 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/regulator/mpq7920.yaml
Documentation/devicetree/bindings/regulator/mpq7920.yaml new file +1 -0
new file mode 100644
index 000000000000..54e9177dfd1b
@@ -0,0 +1,143 @@
+# SPDX-License-Identifier: GPL-2.0

Dual license new bindings:

(GPL-2.0-only OR BSD-2-Clause)

Quoted 15 lines
Documentation/devicetree/bindings/regulator/mpq7920.yaml new file +15 -0
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/regulator/mpq7920.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Monolithic Power System MPQ7920 PMIC
+
+maintainers:
+  - Saravanan Sekar <[email protected]>
+
+properties:
+  $nodename:
+    pattern: "pmic@[0-9a-f]{1,2}"
+  compatible:
+    enum:

Documentation/devicetree/bindings/regulator/mpq7920.yaml line 26

Quoted 10 lines
Documentation/devicetree/bindings/regulator/mpq7920.yaml new file +10 -0
+      - mps,mpq7920
+
+  reg:
+    maxItems: 1
+
+  mps,time-slot:
+    description:
+      each regulator output shall be delayed during power on/off sequence which
+      based on configurable time slot value, must be one of following corresponding
+      value 0.5ms, 2ms, 8ms, 16ms

These values map to 0-3?

This value is how long each time slot is?

Documentation/devicetree/bindings/regulator/mpq7920.yaml line 30

Quoted 4 lines
Documentation/devicetree/bindings/regulator/mpq7920.yaml new file +4 -0
+    allOf:
+      - $ref: "/schemas/types.yaml#/definitions/uint8"
+      - enum: [ 0, 1, 2, 3 ]
+      - default: 0

Only $ref needs to be under the allOf, so move enum and default to same level as allOf.

Quoted 13 lines
Documentation/devicetree/bindings/regulator/mpq7920.yaml new file +13 -0
+
+  mps,fixed-on-time:
+     description:
+       select power on sequence with fixed time output delay mentioned in
+       time-slot reg for all the regulators.
+     type: boolean
+
+  mps,fixed-off-time:
+     description:
+        select power off sequence with fixed time output delay mentioned in
+        time-slot reg for all the regulators.
+     type: boolean
+

Documentation/devicetree/bindings/regulator/mpq7920.yaml line 53

Quoted 10 lines
Documentation/devicetree/bindings/regulator/mpq7920.yaml new file +10 -0
+  mps,inc-off-time:
+     description: |
+        mutually exclusive to mps,fixed-off-time an array of 8, linearly increase
+        output delay during power off sequence based on factor of time slot/interval
+        for each regulator.
+     allOf:
+       - $ref: "/schemas/types.yaml#/definitions/uint8-array"
+       - minimum: 0
+       - maximum: 15
+       - default: [ 0, 6, 0, 6, 7, 7, 7, 9 ]

Each value corresponds to a regulator? Why not a per regulator property?

Quoted 6 lines
Documentation/devicetree/bindings/regulator/mpq7920.yaml new file +6 -0
+
+  mps,inc-on-time:
+     description: |
+        mutually exclusive to mps,fixed-on-time an array of 8, linearly increase
+        output delay during power on sequence based on factor of time slot/interval
+        for each regulator.

Documentation/devicetree/bindings/regulator/mpq7920.yaml line 69

Quoted 10 lines
Documentation/devicetree/bindings/regulator/mpq7920.yaml new file +10 -0
+     allOf:
+       - $ref: "/schemas/types.yaml#/definitions/uint8-array"
+       - minimum: 0
+       - maximum: 15
+       - default: [ 0, 6, 0, 6, 7, 7, 7, 9 ]
+
+  mps,switch-freq:
+     description: |
+        switching frequency must be one of following corresponding value
+        1.1MHz, 1.65MHz, 2.2MHz, 2.75MHz

Seems like this should be a common property.

Documentation/devicetree/bindings/regulator/mpq7920.yaml line 81

Quoted 12 lines
Documentation/devicetree/bindings/regulator/mpq7920.yaml new file +12 -0
+     allOf:
+       - $ref: "/schemas/types.yaml#/definitions/uint8"
+       - enum: [ 0, 1, 2, 3 ]
+       - default: 2
+
+  mps,buck-softstart:
+     description: |
+        An array of 4 contains soft start time of each buck, must be one of
+        following corresponding values 150us, 300us, 610us, 920us
+     allOf:
+       - $ref: "/schemas/types.yaml#/definitions/uint8-array"
+       - enum: [ 0, 1, 2, 3 ]

As this is an array, should be:

items:
enum: ...

Constraints on the size of the array?

Though again, why not a per regulator property? Also, a fairly common thing for buck regulators?

Quoted 17 lines
Documentation/devicetree/bindings/regulator/mpq7920.yaml new file +17 -0
+       - default: [ 1, 1, 1, 1 ]
+
+  mps,buck-ovp:
+     description: |
+        An array of 4 contains over voltage protection of each buck, must be
+        one of above values
+     allOf:
+       - $ref: "/schemas/types.yaml#/definitions/uint8-array"
+       - enum: [ 0, 1 ]
+       - default: [ 1, 1, 1, 1 ]
+
+  mps,buck-phase-delay:
+     description: |
+        An array of 4 contains phase delay of each buck must be one of above values
+        corresponding to 0deg, 90deg, 180deg, 270deg
+     allOf:
+       - $ref: "/schemas/types.yaml#/definitions/uint8-array"

Documentation/devicetree/bindings/regulator/mpq7920.yaml line 108

Quoted 10 lines
Documentation/devicetree/bindings/regulator/mpq7920.yaml new file +10 -0
+       - enum: [ 0, 1, 2, 3 ]
+       - default: [ 0, 0, 1, 1 ]
+
+  regulators:
+    type: object
+    description:
+      list of regulators provided by this controller, must be named
+      after their hardware counterparts BUCK[1-4], one LDORTC, and LDO[2-5]
+      The valid names for regulators are
+      buck1, buck2, buck3, buck4, ldortc, ldo2, ldo3, ldo4, ldo5

You need buck[1-4] and ldo(rtc|[2-5]) child nodes defined here which reference regulators.yaml.

Quoted 38 lines
Documentation/devicetree/bindings/regulator/mpq7920.yaml new file +35 -0
+
+
+examples:
+  - |
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        pmic@69 {
+          compatible = "mps,mpq7920";
+          reg = <0x69>;
+
+          mps,switch-freq = <1>;
+          mps,buck-softstart = /bits/ 8 <1 2 1 3>;
+          mps,buck-ovp = /bits/ 8 <1 0 1 1>;
+
+          regulators {
+            buck1 {
+             regulator-name = "buck1";
+             regulator-min-microvolt = <400000>;
+             regulator-max-microvolt = <3587500>;
+             regulator-min-microamp  = <460000>;
+             regulator-max-microamp  = <7600000>;
+             regulator-boot-on;
+            };
+
+            ldo2 {
+             regulator-name = "ldo2";
+             regulator-min-microvolt = <650000>;
+             regulator-max-microvolt = <3587500>;
+            };
+         };
+       };
+     };
+...
Signature · 1 line
2.17.1
author maintainer
#5 lore raw

PATCH v4 3/4 regulator: mpq7920: add mpq7920 regulator driver

In reply to Saravanan Sekar

Adding regulator driver for the device mpq7920.
The MPQ7920 PMIC device contains four DC-DC buck converters and five regulators, is designed for automotive and accessed over I2C.

---
 drivers/regulator/Kconfig   |  10 +
 drivers/regulator/Makefile  |   1 +
 drivers/regulator/mpq7920.c | 392 ++++++++++++++++++++++++++++++++++++
 drivers/regulator/mpq7920.h |  72 +++++++
 4 files changed, 475 insertions(+)
 create mode 100644 drivers/regulator/mpq7920.c
 create mode 100644 drivers/regulator/mpq7920.h
drivers/regulator/Kconfig +10 -0
index 74eb5af7295f..e10adc2e57da 100644
@@ -600,6 +600,16 @@ config REGULATOR_MCP16502
 	  through the regulator interface. In addition it enables
 	  suspend-to-ram/standby transition.
 
+config REGULATOR_MPQ7920
+	tristate "Monolithic MPQ7920 PMIC"
+	depends on I2C && OF
+	select REGMAP_I2C
+	help
+	  Say y here to support the MPQ7920 PMIC. This will enable supports
+	  the software controllable 4 buck and 5 LDO regulators.
+	  This driver supports the control of different power rails of device
+	  through regulator interface.
+
 config REGULATOR_MT6311
 	tristate "MediaTek MT6311 PMIC"
 	depends on I2C
drivers/regulator/Makefile +1 -0
index 2210ba56f9bd..fd11002507e4 100644
@@ -77,6 +77,7 @@ obj-$(CONFIG_REGULATOR_MC13783) += mc13783-regulator.o
 obj-$(CONFIG_REGULATOR_MC13892) += mc13892-regulator.o
 obj-$(CONFIG_REGULATOR_MC13XXX_CORE) +=  mc13xxx-regulator-core.o
 obj-$(CONFIG_REGULATOR_MCP16502) += mcp16502.o
+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
drivers/regulator/mpq7920.c new file +392 -0

392 lines not on this page · raw message

drivers/regulator/mpq7920.h new file +72 -0

72 lines not on this page · raw message

Signature · 1 line
2.17.1
author maintainer
#6 lore raw

PATCH v4 4/4 MAINTAINERS: Add entry for mpq7920 PMIC driver

In reply to Saravanan Sekar

Add MAINTAINERS entry for Monolithic Power Systems mpq7920 PMIC driver.

---
 MAINTAINERS | 7 +++++++
 1 file changed, 7 insertions(+)
MAINTAINERS +7 -0
index 0fd82e674cf4..8a31285b59c6 100644
@@ -11128,6 +11128,13 @@ S:	Maintained
 F:	Documentation/driver-api/serial/moxa-smartio.rst
 F:	drivers/tty/mxser.*
 
+MONOLITHIC POWER SYSTEM PMIC DRIVER
+M:	Saravanan Sekar <[email protected]>
+S:	Maintained
+F:	Documentation/devicetree/bindings/regulator/mpq7920.yaml
+F:	drivers/regulator/mpq7920.c
+F:	drivers/regulator/mpq7920.h
+
 MR800 AVERMEDIA USB FM RADIO DRIVER
 M:	Alexey Klimov <[email protected]>
 L:	[email protected]
Signature · 1 line
2.17.1