Skip to contentSkip to conversation

Add support of nxp pf8x00 regulator

PATCH In review Adrien Grassein 5 participants 11 messages Dec 14, 2020 – Dec 15, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v3 cover Add support of nxp pf8x00 regulator

Hello,

this set of patch intends to add the support of the pf8x00 PMIC regulators. This family of PMIC contains 12 regulators (7 bucks converters, 4 LDO, 1 RTC supply). All these 12 regulators are configurable via an OTP memory and by i2c at runtime for some specific properties.

1: Adds the dt-binding corresponding to the new driver; 2: Adds the driver itself.

This is th 3rd version of the patch set. In this version I fixed:
- Bad default values were described in the description;
- The configuration is now done at parsing time;
- The code doesn't attempt to parse the regulator properties;
- Remove the unnecessary new "nxp,illim-microamp" property;
- Use the "regulator-max-microamp" of the regulator instead;
- Cut the code in multiple function to obtain a better readability.
- Rework some code part;

Thanks,

Adrien Grassein (2):
dt-bindings: regulator: add pf8x00 PMIC
regulator: pf8x00: add support of nxp pf8x00 regulator

 .../regulator/nxp,pf8x00-regulator.yaml       | 220 +++++
 MAINTAINERS                                   |   7 +
 drivers/regulator/Kconfig                     |  12 +
 drivers/regulator/Makefile                    |   1 +
 drivers/regulator/pf8x00-regulator.c          | 798 ++++++++++++++++++
 5 files changed, 1038 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml
 create mode 100644 drivers/regulator/pf8x00-regulator.c
Signature · 1 line
2.20.1
#4 lore raw

PATCH v3 2/2 regulator: pf8x00: add support of nxp pf8x00 regulator

NXP pf8100 and pf8200 are 12-channel
PMIC for high performance applications.

This driver introduces the support of the 12
regulators available on the PMIC.

Imported from Boundary Devices kernel
with some modifications.

This driver was teste using a Boundary Nitrogen 8M Mini board that features this PMIC.

---
 MAINTAINERS                          |   1 +
 drivers/regulator/Kconfig            |  12 +
 drivers/regulator/Makefile           |   1 +
 drivers/regulator/pf8x00-regulator.c | 798 +++++++++++++++++++++++++++
 4 files changed, 812 insertions(+)
 create mode 100644 drivers/regulator/pf8x00-regulator.c
MAINTAINERS +1 -0
index 878e6f25aab7..a7b40ac6a671 100644
@@ -13809,6 +13809,7 @@ M:	Adrien Grassein <[email protected]>
 L:	[email protected]
 S:	Maintained
 F:	Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml
+F:	drivers/regulator/pf8x00-regulator.c
 
 PHOENIX RC FLIGHT CONTROLLER ADAPTER
 M:	Marcus Folkesson <[email protected]>
drivers/regulator/Kconfig +12 -0
index 020a00d6696b..d2aba4b487f4 100644
@@ -791,6 +791,18 @@ config REGULATOR_PCF50633
 	 Say Y here to support the voltage regulators and converters
 	 on PCF50633
 
+config REGULATOR_PF8X00
+	tristate "NXP PF8x00 regulator driver"
+	depends on I2C
+	select REGMAP_I2C
+	help
+	 Say y here to support the regulators found on the NXP
+	 PF8100/PF8200 PMIC
+
+	 Say M here if you want to include support for tte regulators found
+	 on the NXP PF8100/PF8200 PMIC. The module will be named
+	 "pf8x00-regulator".
+
 config REGULATOR_PFUZE100
 	tristate "Freescale PFUZE100/200/3000/3001 regulator driver"
 	depends on I2C
drivers/regulator/Makefile +1 -0
index 6ebae516258e..a9fb449a0dc8 100644
@@ -100,6 +100,7 @@ obj-$(CONFIG_REGULATOR_QCOM_SPMI) += qcom_spmi-regulator.o
 obj-$(CONFIG_REGULATOR_QCOM_USB_VBUS) += qcom_usb_vbus-regulator.o
 obj-$(CONFIG_REGULATOR_PALMAS) += palmas-regulator.o
 obj-$(CONFIG_REGULATOR_PCA9450) += pca9450-regulator.o
+obj-$(CONFIG_REGULATOR_PF8X00) += pf8x00-regulator.o
 obj-$(CONFIG_REGULATOR_PFUZE100) += pfuze100-regulator.o
 obj-$(CONFIG_REGULATOR_PV88060) += pv88060-regulator.o
 obj-$(CONFIG_REGULATOR_PV88080) += pv88080-regulator.o
drivers/regulator/pf8x00-regulator.c new file +798 -0

798 lines not on this page · raw message

Signature · 1 line
2.20.1
#1 lore raw

PATCH v3 1/2 dt-bindings: regulator: add pf8x00 PMIC

In reply to Adrien Grassein

Add a devicetree binding documentation for the pf8x00 regulator driver.

---
 .../regulator/nxp,pf8x00-regulator.yaml       | 220 ++++++++++++++++++
 MAINTAINERS                                   |   6 +
 2 files changed, 226 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml
Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml new file +220 -0
new file mode 100644
index 000000000000..a17ab3b22913
@@ -0,0 +1,220 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/regulator/nxp,pf8x00-regulator.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: NXP PF8x00 Power Management Integrated Circuit regulators
+
+maintainers:
+  - Adrien Grassein <[email protected]>
+
+description:
+  pf8x00 are a 12-chanel regulator PMIC family. Regulators nodes should
+  be named to ldo<>, sw<> and vnss. The definition for each of these nodes
+  is defined using the standard binding for regulators at
+  Documentation/devicetree/bindings/regulator/regulator.txt.
+  Datasheet is available at https://www.nxp.com/docs/en/data-sheet/PF8100_PF8200.pdf
+
+properties:
+  compatible:
+    enum:
+      - nxp,pf8100
+      - nxp,pf8121a
+      - nxp,pf8200
+
+  reg:
+    maxItems: 1
+
+  regulators:
+    type: object
+    description:
+      list of regulators provided by this controller
+
+    patternProperties:
+      "^ldo[1-4]$":
+        type: object
+        $ref: regulator.yaml#
+        description:
+          Properties for single LDO regulator.
+
+        properties:
+          nxp,hw-en:
+            $ref: /schemas/types.yaml#definitions/flag
+            description:
+              Only available for ldo2. If present, use LDO2EN input pin
+              to enable or disable ldo2. (LDO2EN should be in HIGH state
+              to enable LDO2 if nxp,hw-en is specified).
+
+          nxp,vselect-en:
+            $ref: /schemas/types.yaml#definitions/flag
+            description:
+              Only available for ldo2. When specified, use the VSELECT
+              input pin of the chip to control the output voltage of the
+              ldo02 regulator. (3.3V if VSELECT is LOW, 1.8V if HIGH).
+
+        unevaluatedProperties: false
+
+      "^sw[1-7]$":
+        type: object
+        $ref: regulator.yaml#
+        description:
+          Properties for single SW regulator.
+
+        properties:
+          nxp,phase:
+            $ref: /schemas/types.yaml#definitions/uint32
+            minimum: 0
+            maximum: 315
+            enum: [ 0, 45, 90, 135, 180, 225, 270, 315 ]
+            description:
+               This controls the phase shift of the switching frequency.
+               Default value is the one written in the OTP configuration.
+
+          nxp,fast-slew:
+            $ref: /schemas/types.yaml#definitions/flag
+            description:
+              Enables the fast DVS ramp of the regulator.
+              Default is slow DVS ramp.
+              Not available for sw7 regulator.
+              Default value is the one written in the OTP configuration.
+
+          nxp,dual-phase:
+            $ref: /schemas/types.yaml#definitions/flag
+            description:
+              This allow regulators  sw1 and sw2, sw3 and sw4, sw5 and sw6,
+              to work together to deliver a maximum 5A current.
+              Should be only specified for sw1, sw3 and sw5.
+              If set, sw2, sw4 and sw6 configuration will be totally ignored.
+              This is not a configuration property. It's only used to control
+              the consistency of the OTP confguration.
+
+          nxp,quad-phase:
+            $ref: /schemas/types.yaml#definitions/flag
+            description:
+              This allow regulators  sw1, sw2, sw3 and sw4 to work together
+              to deliver a maximum 10A current. Should be only specified for
+              sw1. If set, sw2, sw3 and sw4 configuration will be totally ignored.
+              This is not a configuration property. It's only used to control
+              the consistency of the OTP confguration.
+
+        unevaluatedProperties: false
+
+    properties:
+      vsnvs:
+        type: object
+        $ref: regulator.yaml#
+        description:
+          Properties for vsnvs regulator.
+
+        unevaluatedProperties: false
+
+    additionalProperties: false
+
+required:
+  - compatible
+  - reg
+  - regulators
+
+additionalProperties: false
+
+examples:
+  - |
+    i2c {
+      #address-cells = <1>;
+      #size-cells = <0>;
+      pmic@8 {
+        compatible = "nxp,pf8100";
+        reg = <0x08>;
+
+        regulators {
+            reg_ldo1: ldo1 {
+              regulator-always-on;
+              regulator-boot-on;
+              regulator-max-microvolt = <5000000>;
+              regulator-min-microvolt = <1500000>;
+            };
+
+            reg_ldo2: ldo2 {
+              regulator-always-on;
+              regulator-boot-on;
+              regulator-max-microvolt = <5000000>;
+              regulator-min-microvolt = <1500000>;
+            };
+
+            reg_ldo3: ldo3 {
+              regulator-always-on;
+              regulator-boot-on;
+              regulator-max-microvolt = <5000000>;
+              regulator-min-microvolt = <1500000>;
+            };
+
+            reg_ldo4: ldo4 {
+              regulator-always-on;
+              regulator-boot-on;
+              regulator-max-microvolt = <5000000>;
+              regulator-min-microvolt = <1500000>;
+            };
+
+            reg_sw1: sw1 {
+              nxp,phase = <0>;
+              regulator-always-on;
+              regulator-boot-on;
+              regulator-max-microvolt = <1800000>;
+              regulator-min-microvolt = <400000>;
+              regulator-max-microamp  = <4500000>;
+            };
+
+            reg_sw2: sw2 {
+              regulator-always-on;
+              regulator-boot-on;
+              regulator-max-microvolt = <1800000>;
+              regulator-min-microvolt =  <400000>;
+            };
+
+            reg_sw3: sw3 {
+              regulator-always-on;
+              regulator-boot-on;
+              regulator-max-microvolt = <1800000>;
+              regulator-min-microvolt =  <400000>;
+              nxp,fast-slew;
+            };
+
+            reg_sw4: sw4 {
+              regulator-always-on;
+              regulator-boot-on;
+              regulator-max-microvolt = <1800000>;
+              regulator-min-microvolt =  <400000>;
+              nxp,fast-slew;
+            };
+
+            reg_sw5: sw5 {
+              regulator-always-on;
+              regulator-boot-on;
+              regulator-max-microvolt = <1800000>;
+              regulator-min-microvolt =  <400000>;
+            };
+
+           reg_sw6: sw6 {
+             regulator-always-on;
+             regulator-boot-on;
+             regulator-max-microvolt = <1800000>;
+             regulator-min-microvolt =  <400000>;
+           };
+
+           reg_sw7: sw7 {
+             regulator-always-on;
+             regulator-boot-on;
+             regulator-max-microvolt = <4100000>;
+             regulator-min-microvolt = <1000000>;
+           };
+
+          reg_vsnvs: vsnvs {
+            regulator-always-on;
+            regulator-boot-on;
+            regulator-max-microvolt = <3300000>;
+            regulator-min-microvolt = <1800000>;
+          };
+        };
+      };
+    };
MAINTAINERS +6 -0
index fb75813e23d4..878e6f25aab7 100644
@@ -13804,6 +13804,12 @@ S:	Maintained
 F:	include/linux/personality.h
 F:	include/uapi/linux/personality.h
 
+PF8x00 PMIC REGULATORS DRIVERS
+M:	Adrien Grassein <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml
+
 PHOENIX RC FLIGHT CONTROLLER ADAPTER
 M:	Marcus Folkesson <[email protected]>
 L:	[email protected]
Signature · 1 line
2.20.1
maintainer
#5 lore raw
In reply to Adrien Grassein
Quoted 5 lines · Adrien Grassein

this set of patch intends to add the support of the pf8x00 PMIC regulators. This family of PMIC contains 12 regulators (7 bucks converters, 4 LDO, 1 RTC supply). All these 12 regulators are configurable via an OTP memory and by i2c at runtime for some specific properties.

This looks to have raced with the addition of support for the same device by Jagan Teki - unfortunately I didn't register that I'd seen other patches for the same driver go past so I applied Jagan's version (both look to be based on original work by Troy), sorry about that. Could you please take a look at what got merged and send incremental improvements on top of it - I do notice that I missed the use of the wildcard compatible in there so that needs fixing at least. :/

#6 lore raw
Quoted 9 lines · Mark Brown
Quoted 5 lines · Adrien Grassein

this set of patch intends to add the support of the pf8x00 PMIC regulators. This family of PMIC contains 12 regulators (7 bucks converters, 4 LDO, 1 RTC supply). All these 12 regulators are configurable via an OTP memory and by i2c at runtime for some specific properties.

Quoted 7 lines

This looks to have raced with the addition of support for the same device by Jagan Teki - unfortunately I didn't register that I'd seen other patches for the same driver go past so I applied Jagan's version (both look to be based on original work by Troy), sorry about that. Could you please take a look at what got merged and send incremental improvements on top of it - I do notice that I missed the use of the wildcard compatible in there so that needs fixing at least. :/

No problem for me, I learned many things about trying to upstream this driver :)

Could you please tell me where this driver was merged? I checked the main kernel Linux and I can find out this one.

Thanks again,
Adrien

maintainer
#8 lore raw
Quoted 8 lines · Fabio Estevam
Quoted 2 lines · Adrien Grassein

Could you please tell me where this driver was merged? I checked the main kernel Linux and I can find out this one.

It is in the linux-next tree:
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/drivers?h=next-20201215&id=d3795d6321ecaa55d94dc24c3b1e3cce608aabd6

Coming to there from my for-next branch - it's also already been sent in a pull request to Linus so will hopefully be hitting his tree soonish.

#9 lore raw

I just cloned the linux-next repo.

I will try to fix things Mark tells me to fix on my own driver.

Thanks again,

Adrien

Quoted 13 lines · Mark Brown
Quoted 8 lines · Fabio Estevam
Quoted 2 lines · Adrien Grassein

Could you please tell me where this driver was merged? I checked the main kernel Linux and I can find out this one.

It is in the linux-next tree:
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/drivers?h=next-20201215&id=d3795d6321ecaa55d94dc24c3b1e3cce608aabd6

Coming to there from my for-next branch - it's also already been sent in a pull request to Linus so will hopefully be hitting his tree soonish.

maintainer
#2 lore raw

Re: [PATCH v3 1/2] dt-bindings: regulator: add pf8x00 PMIC

In reply to Adrien Grassein
Quoted 9 lines · Adrien Grassein

Add a devicetree binding documentation for the pf8x00 regulator driver.

---
 .../regulator/nxp,pf8x00-regulator.yaml       | 220 ++++++++++++++++++
 MAINTAINERS                                   |   6 +
 2 files changed, 226 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml

My bot found errors running 'make dt_binding_check' on your patch:

yamllint warnings/errors:
./Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml:71:16: [warning] wrong indentation: expected 14 but found 15 (indentation)

dtschema/dtc warnings/errors:

See https://patchwork.ozlabs.org/patch/1416222

This check can fail if there are any dependencies. The base for a patch series is generally the most recent rc1.

If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:

pip3 install dtschema --upgrade

Please check and re-submit.

maintainer Reviewed-by on v3 1/2
#3 lore raw

Re: [PATCH v3 1/2] dt-bindings: regulator: add pf8x00 PMIC

In reply to Adrien Grassein
Quoted 9 lines · Adrien Grassein

Add a devicetree binding documentation for the pf8x00 regulator driver.

---
 .../regulator/nxp,pf8x00-regulator.yaml       | 220 ++++++++++++++++++
 MAINTAINERS                                   |   6 +
 2 files changed, 226 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml

With the whitespace fixed,

maintainer
#10 lore raw
In reply to Mark Brown
Quoted 9 lines · Mark Brown
Quoted 5 lines · Adrien Grassein

this set of patch intends to add the support of the pf8x00 PMIC regulators. This family of PMIC contains 12 regulators (7 bucks converters, 4 LDO, 1 RTC supply). All these 12 regulators are configurable via an OTP memory and by i2c at runtime for some specific properties.

Quoted 7 lines

This looks to have raced with the addition of support for the same device by Jagan Teki - unfortunately I didn't register that I'd seen other patches for the same driver go past so I applied Jagan's version (both look to be based on original work by Troy), sorry about that. Could you please take a look at what got merged and send incremental improvements on top of it - I do notice that I missed the use of the wildcard compatible in there so that needs fixing at least. :/

Sorry, I'm unable to understand the pharse here. is there any issue with the existing patchset?

Thanks,
Jagan.