Skip to contentSkip to conversation

dt-bindings: regulator: Add pf8x00 regulator

PATCH Superseded Adrien Grassein 4 participants 13 messages Dec 6, 2020 – Dec 12, 2020

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 dt-bindings: regulator: Add pf8x00 regulator

Add dt-bindings for the pf8x00 driver.

---
 .../regulator/nxp,pf8x00-regulator.yaml       | 223 ++++++++++++++++++
 MAINTAINERS                                   |   6 +
 2 files changed, 229 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml
Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml new file +223 -0
new file mode 100644
index 000000000000..f4e4f545c5a3
@@ -0,0 +1,223 @@
+# 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,pf8x00
+
+  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:
+          regulator-name:
+            pattern: "^ldo[1-4]$"
+            description: |
+              should be ldo1", ..., "ldo4"
+
+          nxp,hw-en:
+            $ref: /schemas/types.yaml#definitions/flag
+            description: |
+              Only available for ldo2. Used to enable or disable ld02.
+
+          nxp,vselect-en:
+            $ref: /schemas/types.yaml#definitions/flag
+            description: |
+              Only available for ldo2. When specified, use the VSELECT pin
+              of the chip to control the output voltage of the ldo02 regulator.
+
+        unevaluatedProperties: false
+
+      "^sw[1-7]$":
+        type: object
+        $ref: regulator.yaml#
+        description: |
+          Properties for single SW regulator.
+
+        properties:
+          regulator-name:
+            pattern: "^sw[1-7]$"
+            description: |
+              should be sw1", ..., "sw7"
+
+          nxp,ilim-ma:
+            $ref: /schemas/types.yaml#definitions/uint32
+            minimum: 2100
+            maximum: 4500
+            default: 2100
+            enum: [ 2100, 2600, 3000, 4500 ]
+            description: |
+              Defines the maximum current delivered by the regulator (in mA).
+
+          nxp,phase:
+            $ref: /schemas/types.yaml#definitions/uint32
+            minimum: 0
+            maximum: 315
+            default: 0
+            enum: [ 0, 45, 90, 135, 180, 225, 270, 315 ]
+            description: |
+               This controls the phase shift of the switching frequency.
+
+          nxp,fsl,fast-slew:
+            $ref: /schemas/types.yaml#definitions/flag
+            description: |
+              Controls the DVS ramp of the regulator.
+
+          nxp,quad-phase:
+            $ref: /schemas/types.yaml#definitions/flag
+            description: |
+              This allow regulators  sw1 and sw2, or sw3 and sw4 or sw4 and sw5
+              to work together to deliver a maximum 10A current.
+
+          nxp,dual-phase:
+            $ref: /schemas/types.yaml#definitions/flag
+            description: |
+              This allow regulators  sw1, sw2, sw3 and sw4 to work together
+              to deliver a maximum 5A current.
+
+        unevaluatedProperties: false
+
+      "^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: pf8100@8 {
+        compatible = "nxp,pf8x00";
+        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>;
+              nxp,ilim-ma = <4500>;
+              regulator-always-on;
+              regulator-boot-on;
+              regulator-max-microvolt = <1800000>;
+              regulator-min-microvolt =  <400000>;
+            };
+
+            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 = <1>;
+            };
+
+            reg_sw4: sw4 {
+              regulator-always-on;
+              regulator-boot-on;
+              regulator-max-microvolt = <1800000>;
+              regulator-min-microvolt =  <400000>;
+              nxp,fast-slew = <1>;
+            };
+
+            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 ebe4829cdd4d..4e266f1e9a2f 100644
@@ -13730,6 +13730,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
#1 lore raw

PATCH 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 | 870 +++++++++++++++++++++++++++
 4 files changed, 884 insertions(+)
 create mode 100644 drivers/regulator/pf8x00-regulator.c
MAINTAINERS +1 -0
index 4e266f1e9a2f..72522a7fd329 100644
@@ -13735,6 +13735,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 +870 -0

870 lines not on this page · raw message

Signature · 1 line
2.20.1
maintainer
#2 lore raw

Re: [PATCH 2/2] regulator: pf8x00: add support of nxp pf8x00 regulator

drivers/regulator/pf8x00-regulator.c line 206

Quoted 5 lines · Adrien Grassein
drivers/regulator/pf8x00-regulator.c new file +5 -0
+/* sw1 to sw6 voltages, from 0.4V to 1.49375V with 0.006250V increments */
+#define SWV(i)	(6250 * i + 400000)
+
+static const int pf8x00_sw1_to_6_voltages[] = {
+	SWV(0), SWV(1), SWV(2), SWV(3), SWV(4), SWV(5), SWV(6), SWV(7),

There are helpers for linear mappings, please use them directly rather than open coding - this is clearer and much more efficient at runtime.

drivers/regulator/pf8x00-regulator.c line 248

Quoted 5 lines
drivers/regulator/pf8x00-regulator.c new file +5 -0
+static const struct i2c_device_id pf8x_device_id[] = {
+	{.name = "pf8x00",},
+	{ }
+};
+MODULE_DEVICE_TABLE(i2c, pf8x_device_id);

There should be separate IDs for the individual parts as with the OF compatible.

drivers/regulator/pf8x00-regulator.c line 305

Quoted 13 lines
drivers/regulator/pf8x00-regulator.c new file +13 -0
+static int pf8x00_regulator_set_voltage_time_sel(struct regulator_dev *rdev,
+		unsigned int old_sel, unsigned int new_sel)
+{
+	struct pf8x_chip *pf = rdev_get_drvdata(rdev);
+	struct pf8x_regulator *rdesc = container_of(rdev->desc, struct pf8x_regulator, desc);
+	const unsigned int *volt_table = rdev->desc->volt_table;
+	int old_v = volt_table[old_sel];
+	int new_v = volt_table[new_sel];
+	int change = (new_v - old_v);
+	unsigned int index;
+	unsigned int slew;
+
+	index = (rdesc->fast_slew & 1) ? 2 : 0;

Please write normal conditional statements to make things easier to read.

drivers/regulator/pf8x00-regulator.c line 392

Quoted 9 lines
drivers/regulator/pf8x00-regulator.c new file +9 -0
+	if ((desc->id != REG_SW1) && quad_phase) {
+		dev_err(pf->dev, "ignoring, only sw1 can use quad-phase\n");
+		quad_phase = 0;
+	}
+	if ((desc->id != REG_SW1) && (desc->id != REG_SW4)
+			 && (desc->id != REG_SW5) && dual_phase) {
+		dev_err(pf->dev, "ignoring, only sw1/sw4/sw5 can use dual-phase\n");
+		dual_phase = 0;
+	}

This wasn't in the binding document...

Quoted 8 lines
drivers/regulator/pf8x00-regulator.c new file +8 -0
+static int pf8x_parse_regulators_dt(struct pf8x_chip *pf)
+{
+	struct device *dev = pf->dev;
+	struct device_node *np, *parent;
+	int ret;
+
+	np = of_node_get(dev->of_node);
+	if (!np)

drivers/regulator/pf8x00-regulator.c line 569

Quoted 10 lines
drivers/regulator/pf8x00-regulator.c new file +10 -0
+		return -EINVAL;
+
+	parent = of_get_child_by_name(np, "regulators");
+	if (!parent) {
+		dev_err(dev, "regulators node not found\n");
+		return -EINVAL;
+	}
+
+	ret = of_regulator_match(dev, parent, pf8x00_matches,
+				 ARRAY_SIZE(pf8x00_matches));

Don't open code binding parsing, just specify the relevant names in the regulator decriptors, register them and and let the core parse things for you.

drivers/regulator/pf8x00-regulator.c line 770

Quoted 8 lines
drivers/regulator/pf8x00-regulator.c new file +8 -0
+			if (ilim <= 3) {
+				mask |= 3 << 3;
+				val |= ilim << 3;
+			}
+			if (fast_slew <= 1) {
+				mask |= 1 << 5;
+				val |= fast_slew << 5;
+			}

More blank lines between blocks please.

drivers/regulator/pf8x00-regulator.c line 839

Quoted 9 lines
drivers/regulator/pf8x00-regulator.c new file +9 -0
+static int pf8x_suspend(struct device *dev)
+{
+	return 0;
+}
+
+static int pf8x_resume(struct device *dev)
+{
+	return 0;
+}

Remove empty functions.

drivers/regulator/pf8x00-regulator.c line 859

Quoted 5 lines
drivers/regulator/pf8x00-regulator.c new file +5 -0
+static int __init pf8x_init(void)
+{
+	return i2c_add_driver(&pf8x_driver);
+}
+subsys_initcall(pf8x_init);

You should be able to use module_i2c_driver() here.

#3 lore raw

Re: [PATCH 2/2] regulator: pf8x00: add support of nxp pf8x00 regulator

In reply to Adrien Grassein
I love your patch! Perhaps something to improve:

Hi Adrien,

I love your patch! Perhaps something to improve:

[auto build test WARNING on robh/for-next]
[also build test WARNING on linus/master v5.10-rc7]
[cannot apply to regulator/for-next next-20201207]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Adrien-Grassein/dt-bindings-regulator-Add-pf8x00-regulator/20201206-083433
base:   https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next
config: s390-randconfig-r036-20201207 (attached as .config)
compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project a2f922140f5380571fb74179f2bf622b3b925697)

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# install s390 cross compiling tool for clang build
# apt-get install binutils-s390x-linux-gnu
# https://github.com/0day-ci/linux/commit/efbdd07e33c1265802f429333ea350f206b26406
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Adrien-Grassein/dt-bindings-regulator-Add-pf8x00-regulator/20201206-083433 git checkout efbdd07e33c1265802f429333ea350f206b26406
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=s390

If you fix the issue, kindly add following tag as appropriate

All warnings (new ones prefixed by >>):

In file included from include/linux/swap.h:9:
In file included from include/linux/memcontrol.h:22:
In file included from include/linux/writeback.h:14:
In file included from include/linux/blk-cgroup.h:23:
In file included from include/linux/blkdev.h:26:
In file included from include/linux/scatterlist.h:9:
In file included from arch/s390/include/asm/io.h:80:
include/asm-generic/io.h:490:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]

           val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
                                                           ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/big_endian.h:34:59: note: expanded from macro '__le32_to_cpu'
   #define __le32_to_cpu(x) __swab32((__force __u32)(__le32)(x))
                                                             ^
   include/uapi/linux/swab.h:119:21: note: expanded from macro '__swab32'
           ___constant_swab32(x) :                 \
                              ^
   include/uapi/linux/swab.h:21:12: note: expanded from macro '___constant_swab32'
           (((__u32)(x) & (__u32)0x00ff0000UL) >>  8) |            \
                     ^
   In file included from drivers/regulator/pf8x00-regulator.c:15:
   In file included from include/linux/regulator/driver.h:18:
   In file included from include/linux/regulator/consumer.h:35:
   In file included from include/linux/suspend.h:5:
   In file included from include/linux/swap.h:9:
   In file included from include/linux/memcontrol.h:22:
   In file included from include/linux/writeback.h:14:
   In file included from include/linux/blk-cgroup.h:23:
   In file included from include/linux/blkdev.h:26:
   In file included from include/linux/scatterlist.h:9:
   In file included from arch/s390/include/asm/io.h:80:
   include/asm-generic/io.h:490:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
                                                           ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/big_endian.h:34:59: note: expanded from macro '__le32_to_cpu'
   #define __le32_to_cpu(x) __swab32((__force __u32)(__le32)(x))
                                                             ^
   include/uapi/linux/swab.h:119:21: note: expanded from macro '__swab32'
           ___constant_swab32(x) :                 \
                              ^
   include/uapi/linux/swab.h:22:12: note: expanded from macro '___constant_swab32'
           (((__u32)(x) & (__u32)0xff000000UL) >> 24)))
                     ^
   In file included from drivers/regulator/pf8x00-regulator.c:15:
   In file included from include/linux/regulator/driver.h:18:
   In file included from include/linux/regulator/consumer.h:35:
   In file included from include/linux/suspend.h:5:
   In file included from include/linux/swap.h:9:
   In file included from include/linux/memcontrol.h:22:
   In file included from include/linux/writeback.h:14:
   In file included from include/linux/blk-cgroup.h:23:
   In file included from include/linux/blkdev.h:26:
   In file included from include/linux/scatterlist.h:9:
   In file included from arch/s390/include/asm/io.h:80:
   include/asm-generic/io.h:490:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
                                                           ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/big_endian.h:34:59: note: expanded from macro '__le32_to_cpu'
   #define __le32_to_cpu(x) __swab32((__force __u32)(__le32)(x))
                                                             ^
   include/uapi/linux/swab.h:120:12: note: expanded from macro '__swab32'
           __fswab32(x))
                     ^
   In file included from drivers/regulator/pf8x00-regulator.c:15:
   In file included from include/linux/regulator/driver.h:18:
   In file included from include/linux/regulator/consumer.h:35:
   In file included from include/linux/suspend.h:5:
   In file included from include/linux/swap.h:9:
   In file included from include/linux/memcontrol.h:22:
   In file included from include/linux/writeback.h:14:
   In file included from include/linux/blk-cgroup.h:23:
   In file included from include/linux/blkdev.h:26:
   In file included from include/linux/scatterlist.h:9:
   In file included from arch/s390/include/asm/io.h:80:
   include/asm-generic/io.h:501:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writeb(value, PCI_IOBASE + addr);
                               ~~~~~~~~~~ ^
   include/asm-generic/io.h:511:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
                                                         ~~~~~~~~~~ ^
   include/asm-generic/io.h:521:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
                                                         ~~~~~~~~~~ ^
   include/asm-generic/io.h:609:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           readsb(PCI_IOBASE + addr, buffer, count);
                  ~~~~~~~~~~ ^
   include/asm-generic/io.h:617:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           readsw(PCI_IOBASE + addr, buffer, count);
                  ~~~~~~~~~~ ^
   include/asm-generic/io.h:625:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           readsl(PCI_IOBASE + addr, buffer, count);
                  ~~~~~~~~~~ ^
   include/asm-generic/io.h:634:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           writesb(PCI_IOBASE + addr, buffer, count);
                   ~~~~~~~~~~ ^
   include/asm-generic/io.h:643:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           writesw(PCI_IOBASE + addr, buffer, count);
                   ~~~~~~~~~~ ^
   include/asm-generic/io.h:652:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           writesl(PCI_IOBASE + addr, buffer, count);
                   ~~~~~~~~~~ ^
>> drivers/regulator/pf8x00-regulator.c:263:23: warning: no previous prototype for function 'get_id_name' [-Wmissing-prototypes]
   const struct id_name *get_id_name(enum chips id)
                         ^
   drivers/regulator/pf8x00-regulator.c:263:7: note: declare 'static' if the function is not intended to be used outside of this translation unit
   const struct id_name *get_id_name(enum chips id)
         ^
   static 
   drivers/regulator/pf8x00-regulator.c:831:12: warning: unused function 'pf8x_suspend' [-Wunused-function]
   static int pf8x_suspend(struct device *dev)
              ^
   drivers/regulator/pf8x00-regulator.c:836:12: warning: unused function 'pf8x_resume' [-Wunused-function]
   static int pf8x_resume(struct device *dev)
              ^

23 warnings generated.

vim +/get_id_name +263 drivers/regulator/pf8x00-regulator.c

262

 > 263	const struct id_name *get_id_name(enum chips id)

264 {
265 const struct id_name *p = id_list;
266
267 while (p->id) {
268 if (p->id == id)
269 break;
270 p++;
271 }
272 return p;
273 }
274

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

maintainer
#4 lore raw
In reply to Adrien Grassein
Quoted 1 line · Adrien Grassein

Add dt-bindings for the pf8x00 driver.

Please submit patches using subject lines reflecting the style for the subsystem, this makes it easier for people to identify relevant patches. Look at what existing commits in the area you're changing are doing and make sure your subject lines visually resemble what they're doing. There's no need to resubmit to fix this alone.

Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml line 22

Quoted 3 lines
Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml new file +3 -0
+  compatible:
+    enum:
+      - nxp,pf8x00

Compatible strings should be for specific devices not wildcards.

Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml line 48

Quoted 4 lines
Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml new file +4 -0
+          nxp,hw-en:
+            $ref: /schemas/types.yaml#definitions/flag
+            description: |
+              Only available for ldo2. Used to enable or disable ld02.

I don't understand what this is documenting - what is "hw-en" and how is it used to enable or disable LDO2?

Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml line 54

Quoted 5 lines
Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml new file +5 -0
+          nxp,vselect-en:
+            $ref: /schemas/types.yaml#definitions/flag
+            description: |
+              Only available for ldo2. When specified, use the VSELECT pin
+              of the chip to control the output voltage of the ldo02 regulator.

Shouldn't there be a GPIO specified somewhere or something so that the VSELECT pin can be controlled?

Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml line 77

Quoted 8 lines
Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml new file +8 -0
+          nxp,ilim-ma:
+            $ref: /schemas/types.yaml#definitions/uint32
+            minimum: 2100
+            maximum: 4500
+            default: 2100
+            enum: [ 2100, 2600, 3000, 4500 ]
+            description: |
+              Defines the maximum current delivered by the regulator (in mA).

Is this not a fixed property of the regulator?

Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml line 97

Quoted 5 lines
Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml new file +5 -0
+          nxp,quad-phase:
+            $ref: /schemas/types.yaml#definitions/flag
+            description: |
+              This allow regulators  sw1 and sw2, or sw3 and sw4 or sw4 and sw5
+              to work together to deliver a maximum 10A current.

Presumably this must be set on both the regulators being grouped together?

#5 lore raw

Hi,

Thanks for reviewing my patches.

Quoted 10 lines · Mark Brown
Quoted 1 line · Adrien Grassein

Add dt-bindings for the pf8x00 driver.

Please submit patches using subject lines reflecting the style for the subsystem, this makes it easier for people to identify relevant patches. Look at what existing commits in the area you're changing are doing and make sure your subject lines visually resemble what they're doing. There's no need to resubmit to fix this alone.

For v2 I just copy-paste another commit message to be sure to be conform.

Quoted 6 lines

Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml line 22

Quoted 3 lines
Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml new file +3 -0
+  compatible:
+    enum:
+      - nxp,pf8x00

Compatible strings should be for specific devices not wildcards.

Quoted 7 lines

Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml line 48

Quoted 4 lines
Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml new file +4 -0
+          nxp,hw-en:
+            $ref: /schemas/types.yaml#definitions/flag
+            description: |
+              Only available for ldo2. Used to enable or disable ld02.

I don't understand what this is documenting - what is "hw-en" and how is it used to enable or disable LDO2?

I think I read better documentation for this point. Sorry, it was very unclear.

Quoted 9 lines

Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml line 54

Quoted 6 lines
Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml new file +5 -0
+          nxp,vselect-en:
+            $ref: /schemas/types.yaml#definitions/flag
+            description: |
+              Only available for ldo2. When specified, use the VSELECT pin
+              of the chip to control the output voltage of the ldo02 regulator.

Shouldn't there be a GPIO specified somewhere or something so that the VSELECT pin can be controlled?

I think I read better documentation for this point. Sorry, it was very unclear. VSELECT is in fact an input pin of the chip. The configuration just enabled it.

Quoted 11 lines

Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml line 77

Quoted 9 lines
Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml new file +8 -0
+          nxp,ilim-ma:
+            $ref: /schemas/types.yaml#definitions/uint32
+            minimum: 2100
+            maximum: 4500
+            default: 2100
+            enum: [ 2100, 2600, 3000, 4500 ]
+            description: |
+              Defines the maximum current delivered by the regulator (in mA).

Is this not a fixed property of the regulator?

It's not. It's configurable by software.

Quoted 9 lines

Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml line 97

Quoted 6 lines
Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml new file +5 -0
+          nxp,quad-phase:
+            $ref: /schemas/types.yaml#definitions/flag
+            description: |
+              This allow regulators  sw1 and sw2, or sw3 and sw4 or sw4 and sw5
+              to work together to deliver a maximum 10A current.

Presumably this must be set on both the regulators being grouped together?

Not. Only the sw1 configuration will be taken in account.

Thanks again,
Adrien

maintainer
#6 lore raw
Quoted 5 lines · Adrien Grassein
Quoted 3 lines · Mark Brown
Quoted 1 line · Adrien Grassein

Add dt-bindings for the pf8x00 driver.

Quoted 7 lines
Quoted 5 lines

Please submit patches using subject lines reflecting the style for the subsystem, this makes it easier for people to identify relevant patches. Look at what existing commits in the area you're changing are doing and make sure your subject lines visually resemble what they're doing. There's no need to resubmit to fix this alone.

For v2 I just copy-paste another commit message to be sure to be conform.

For patches for a given subsystem you should use the prefix the subsystem uses, for regulator that's "regulator: ".

Quoted 10 lines
Quoted 7 lines

Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml line 54

Quoted 4 lines
Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml new file +4 -0
+            $ref: /schemas/types.yaml#definitions/flag
+            description: |
+              Only available for ldo2. When specified, use the VSELECT pin
+              of the chip to control the output voltage of the ldo02 regulator.

Shouldn't there be a GPIO specified somewhere or something so that the VSELECT pin can be controlled?

I think I read better documentation for this point. Sorry, it was very unclear. VSELECT is in fact an input pin of the chip. The configuration just enabled it.

Then presumably you need some binding to specify how to control this input too?

Quoted 10 lines
Quoted 8 lines

Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml line 97

Quoted 5 lines
Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml new file +5 -0
+          nxp,quad-phase:
+            $ref: /schemas/types.yaml#definitions/flag
+            description: |
+              This allow regulators  sw1 and sw2, or sw3 and sw4 or sw4 and sw5
+              to work together to deliver a maximum 10A current.

Presumably this must be set on both the regulators being grouped together?

Not. Only the sw1 configuration will be taken in account.

That needs to be documented then.

maintainer
#7 lore raw
In reply to Adrien Grassein
Quoted 34 lines · Adrien Grassein

Add dt-bindings for the pf8x00 driver.

---
 .../regulator/nxp,pf8x00-regulator.yaml       | 223 ++++++++++++++++++
 MAINTAINERS                                   |   6 +
 2 files changed, 229 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml
Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml new file +19 -0
new file mode 100644
index 000000000000..f4e4f545c5a3
@@ -0,0 +1,223 @@
+# 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:

Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml line 29

Quoted 10 lines
Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml new file +10 -0
+  compatible:
+    enum:
+      - nxp,pf8x00
+
+  reg:
+    maxItems: 1
+
+  regulators:
+    type: object
+    description: |

Don't need '|' if no formatting.

Quoted 31 lines
Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml new file +31 -0
+      list of regulators provided by this controller
+
+    patternProperties:
+      "^ldo[1-4]$":
+        type: object
+        $ref: regulator.yaml#
+        description: |
+          Properties for single LDO regulator.
+
+        properties:
+          regulator-name:
+            pattern: "^ldo[1-4]$"
+            description: |
+              should be ldo1", ..., "ldo4"
+
+          nxp,hw-en:
+            $ref: /schemas/types.yaml#definitions/flag
+            description: |
+              Only available for ldo2. Used to enable or disable ld02.
+
+          nxp,vselect-en:
+            $ref: /schemas/types.yaml#definitions/flag
+            description: |
+              Only available for ldo2. When specified, use the VSELECT pin
+              of the chip to control the output voltage of the ldo02 regulator.
+
+        unevaluatedProperties: false
+
+      "^sw[1-7]$":
+        type: object
+        $ref: regulator.yaml#

Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml line 70

Quoted 10 lines
Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml new file +10 -0
+        description: |
+          Properties for single SW regulator.
+
+        properties:
+          regulator-name:
+            pattern: "^sw[1-7]$"
+            description: |
+              should be sw1", ..., "sw7"
+
+          nxp,ilim-ma:

Use unit suffix defined in property-units.txt.

Quoted 8 lines
Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml new file +8 -0
+            $ref: /schemas/types.yaml#definitions/uint32
+            minimum: 2100
+            maximum: 4500
+            default: 2100
+            enum: [ 2100, 2600, 3000, 4500 ]
+            description: |
+              Defines the maximum current delivered by the regulator (in mA).
+

Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml line 88

Quoted 10 lines
Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml new file +10 -0
+          nxp,phase:
+            $ref: /schemas/types.yaml#definitions/uint32
+            minimum: 0
+            maximum: 315
+            default: 0
+            enum: [ 0, 45, 90, 135, 180, 225, 270, 315 ]
+            description: |
+               This controls the phase shift of the switching frequency.
+
+          nxp,fsl,fast-slew:

nxp or fsl?

Quoted 9 lines
Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml new file +9 -0
+            $ref: /schemas/types.yaml#definitions/flag
+            description: |
+              Controls the DVS ramp of the regulator.
+
+          nxp,quad-phase:
+            $ref: /schemas/types.yaml#definitions/flag
+            description: |
+              This allow regulators  sw1 and sw2, or sw3 and sw4 or sw4 and sw5
+              to work together to deliver a maximum 10A current.

Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml line 107

Quoted 10 lines
Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml new file +10 -0
+
+          nxp,dual-phase:
+            $ref: /schemas/types.yaml#definitions/flag
+            description: |
+              This allow regulators  sw1, sw2, sw3 and sw4 to work together
+              to deliver a maximum 5A current.
+
+        unevaluatedProperties: false
+
+      "^vsnvs$":

Move to 'properties', not a pattern.

Quoted 12 lines
Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml new file +12 -0
+        type: object
+        $ref: regulator.yaml#
+        description: |
+          Properties for vsnvs regulator.
+
+        unevaluatedProperties: false
+
+    additionalProperties: false
+
+required:
+  - compatible
+  - reg

Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml line 129

Quoted 10 lines
Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml new file +10 -0
+  - regulators
+
+additionalProperties: false
+
+examples:
+  - |
+    i2c {
+      #address-cells = <1>;
+      #size-cells = <0>;
+      pmic: pf8100@8 {

pmic@8

Quoted 114 lines
Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml new file +94 -0
+        compatible = "nxp,pf8x00";
+        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>;
+              nxp,ilim-ma = <4500>;
+              regulator-always-on;
+              regulator-boot-on;
+              regulator-max-microvolt = <1800000>;
+              regulator-min-microvolt =  <400000>;
+            };
+
+            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 = <1>;
+            };
+
+            reg_sw4: sw4 {
+              regulator-always-on;
+              regulator-boot-on;
+              regulator-max-microvolt = <1800000>;
+              regulator-min-microvolt =  <400000>;
+              nxp,fast-slew = <1>;
+            };
+
+            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 ebe4829cdd4d..4e266f1e9a2f 100644
@@ -13730,6 +13730,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
#8 lore raw

PATCH v2 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       | 232 ++++++++++++++++++
 MAINTAINERS                                   |   6 +
 2 files changed, 238 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml
Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml new file +232 -0
new file mode 100644
index 000000000000..98cb0d281bf1
@@ -0,0 +1,232 @@
+# 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:
+          regulator-name:
+            pattern: "^ldo[1-4]$"
+            description:
+              should be ldo1", ..., "ldo4"
+
+          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:
+          regulator-name:
+            pattern: "^sw[1-7]$"
+            description:
+              should be sw1", ..., "sw7"
+
+          nxp,ilim-microamp:
+            $ref: /schemas/types.yaml#definitions/uint32
+            minimum: 2100
+            maximum: 4500
+            default: 2100
+            enum: [ 2100, 2600, 3000, 4500 ]
+            description:
+              Defines the maximum current delivered by the regulator in microamp.
+
+          nxp,phase:
+            $ref: /schemas/types.yaml#definitions/uint32
+            minimum: 0
+            maximum: 315
+            default: 0
+            enum: [ 0, 45, 90, 135, 180, 225, 270, 315 ]
+            description:
+               This controls the phase shift of the switching frequency.
+
+          nxp,fast-slew:
+            $ref: /schemas/types.yaml#definitions/flag
+            description:
+              Enables the fast DVS ramp of the regulator.
+              Default is slow DVS ramp.
+
+          nxp,dual-phase:
+            $ref: /schemas/types.yaml#definitions/flag
+            description:
+              This allow regulators  sw1 and sw2, to work together to
+              deliver a maximum 5A current. Should be only specified
+              for sw1. If set, sw2 configuration will be totally ignored.
+
+          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.
+
+        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>;
+              nxp,ilim-microamp = <4500>;
+              regulator-always-on;
+              regulator-boot-on;
+              regulator-max-microvolt = <1800000>;
+              regulator-min-microvolt =  <400000>;
+            };
+
+            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 52086876ce40..71b4476a7619 100644
@@ -13737,6 +13737,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
#9 lore raw

PATCH v2 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 | 844 +++++++++++++++++++++++++++
 4 files changed, 858 insertions(+)
 create mode 100644 drivers/regulator/pf8x00-regulator.c
MAINTAINERS +1 -0
index 71b4476a7619..46401dbfe991 100644
@@ -13742,6 +13742,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 +844 -0

844 lines not on this page · raw message

Signature · 1 line
2.20.1
maintainer
#10 lore raw

Re: [PATCH v2 2/2] regulator: pf8x00: add support of nxp pf8x00 regulator

drivers/regulator/pf8x00-regulator.c line 241

Quoted 11 lines · Adrien Grassein
drivers/regulator/pf8x00-regulator.c new file +11 -0
+	{ .compatible = "nxp,pf8200",},
+	{ }
+};
+MODULE_DEVICE_TABLE(of, pf8x_dt_ids);
+
+const struct id_name id_list[] = {
+	{PF8100, "PF8100"},
+	{PF8121A, "PF8121A"},
+	{PF8200, "PF8200"},
+	{0, "???"},
+};

It's strange to see the list terminated with this ??? entry - these things usually have a NULL for both the ID and the string. The string on the terminator is never used so may as well stick with the usual pattern.

Quoted 4 lines
drivers/regulator/pf8x00-regulator.c new file +4 -0
+static int encode_phase(struct pf8x_chip *pf, int phase)
+{
+	int ph;
+

drivers/regulator/pf8x00-regulator.c line 328

Quoted 10 lines
drivers/regulator/pf8x00-regulator.c new file +10 -0
+	if (phase < 0)
+		return -1;
+
+	ph = phase / 45;
+	if ((ph * 45) != phase) {
+		dev_err(pf->dev, "ignoring, illegal phase %d\n", phase);
+		return -1;
+	}
+
+	return (ph >= 1) ? ph - 1 : 7;

As I said on the previousl review please write normal condidional statements to improve the legibility of the code.

drivers/regulator/pf8x00-regulator.c line 580

Quoted 9 lines
drivers/regulator/pf8x00-regulator.c new file +9 -0
+static inline struct regulator_init_data *match_init_data(int index)
+{
+	return pf8x00_matches[index].init_data;
+}
+
+static inline struct device_node *match_of_node(int index)
+{
+	return pf8x00_matches[index].of_node;
+}

If you need these your driver has a problem, as previously advised please use the standard DT parsing support.

drivers/regulator/pf8x00-regulator.c line 715

Quoted 2 lines
drivers/regulator/pf8x00-regulator.c new file +2 -0
+	memcpy(pf->regulator_descs, pf8x00_regulators,
+		sizeof(pf->regulator_descs));

Why do you need to take a copy of this? The descriptors should not be being modified.

drivers/regulator/pf8x00-regulator.c line 729

Quoted 13 lines
drivers/regulator/pf8x00-regulator.c new file +13 -0
+	num_regulators = ARRAY_SIZE(pf->regulator_descs);
+	for (i = 0; i < num_regulators; i++) {
+		struct regulator_init_data *init_data;
+		struct regulator_desc *desc;
+
+		desc = &pf->regulator_descs[i].desc;
+		init_data = match_init_data(i);
+
+		config.dev = &client->dev;
+		config.init_data = init_data;
+		config.driver_data = pf;
+		config.of_node = match_of_node(i);
+		config.ena_gpiod = NULL;

You've not done anything to parse the init data (which is good) so the init data handling is at best redundant.

Quoted 4 lines
drivers/regulator/pf8x00-regulator.c new file +3 -0
+		if ((i >= REG_SW1) && (i <= REG_SW7)) {
 
+			if (mask) {
+				ret = regmap_update_bits(pf->regmap, reg, mask,

drivers/regulator/pf8x00-regulator.c line 772

Quoted 10 lines
drivers/regulator/pf8x00-regulator.c new file +10 -0
+						val);
+			}
+
+			if (fast_slew > 1) {
+				ret = regmap_read(pf->regmap, reg, &fast_slew);
+				fast_slew &= 0x20;
+				if (ret < 0)
+					fast_slew = 0;
+				pf->regulator_descs[i].fast_slew = fast_slew >> 5;
+			}

May as well just write configurations out when you parse them, no need to defer to here and it makes things simpler.

drivers/regulator/pf8x00-regulator.c line 839

Quoted 7 lines
drivers/regulator/pf8x00-regulator.c new file +7 -0
+module_i2c_driver(pf8x_driver);
+
+static void __exit pf8x_exit(void)
+{
+	i2c_del_driver(&pf8x_driver);
+}
+module_exit(pf8x_exit);

Does this build cleanly? module_i2c_driver() does both the add and delete.

maintainer
#11 lore raw

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

In reply to Adrien Grassein
Quoted 1 line · Adrien Grassein

Add a devicetree binding documentation for the pf8x00 regulator driver.

Please don't send new patches in reply to old threads, it makes it hard to keep track of what is going on.

Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml line 45

Quoted 4 lines
Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml new file +4 -0
+          regulator-name:
+            pattern: "^ldo[1-4]$"
+            description:
+              should be ldo1", ..., "ldo4"

This is part of the generic regulator binding and since it's for board specific usage it should not be constrained by the chip binding.

Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml line 59

Quoted 6 lines
Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml new file +6 -0
+          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).

How is VSELECT used without a binding specifying some mechanism for control?

Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml line 82

Quoted 8 lines
Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml new file +8 -0
+          nxp,ilim-microamp:
+            $ref: /schemas/types.yaml#definitions/uint32
+            minimum: 2100
+            maximum: 4500
+            default: 2100
+            enum: [ 2100, 2600, 3000, 4500 ]
+            description:
+              Defines the maximum current delivered by the regulator in microamp.

Instead of implementing a custom property this should use the already existing properties for current limits, this is a common thing for hardware to have so we shouldn't have custom bindings. We'll need to relax the check the code currently has for a non-zero minimum limit but otherwise everything should already be there.

#12 lore raw

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

Hello,

Quoted 6 lines · Mark Brown
Quoted 1 line · Adrien Grassein

Add a devicetree binding documentation for the pf8x00 regulator driver.

Please don't send new patches in reply to old threads, it makes it hard to keep track of what is going on.

Sorry. Should I create a new mail each time I send a new version of the patch?

Quoted 8 lines

Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml line 45

Quoted 5 lines
Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml new file +4 -0
+          regulator-name:
+            pattern: "^ldo[1-4]$"
+            description:
+              should be ldo1", ..., "ldo4"

This is part of the generic regulator binding and since it's for board specific usage it should not be constrained by the chip binding.

Ok.

Quoted 10 lines

Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml line 59

Quoted 7 lines
Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml new file +6 -0
+          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).

How is VSELECT used without a binding specifying some mechanism for control?

I think that VSELECT input should be controlled by the sub system that uses it (via maybe a GPIO).
On my board, it's directly controlled by another chip (so without a GPIO).

Quoted 10 lines

Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml line 82

Quoted 9 lines
Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml new file +8 -0
+          nxp,ilim-microamp:
+            $ref: /schemas/types.yaml#definitions/uint32
+            minimum: 2100
+            maximum: 4500
+            default: 2100
+            enum: [ 2100, 2600, 3000, 4500 ]
+            description:
+              Defines the maximum current delivered by the regulator in microamp.
Quoted 5 lines

Instead of implementing a custom property this should use the already existing properties for current limits, this is a common thing for hardware to have so we shouldn't have custom bindings. We'll need to relax the check the code currently has for a non-zero minimum limit but otherwise everything should already be there.

Ok I now use "regulator-max-microamp" property from the regulator that acts like my property.
I was wrong with the default value. I re-read the documentation and the default value is stored in OTP
memory. So if someone skipped this property, it's OK to not send any value.

Thanks again,
Regards,