Skip to contentSkip to conversation

slg51000: regulator driver submission

PATCH Superseded Eric Jeong 2 participants 8 messages Apr 16, 2019 – Apr 17, 2019

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Eric Jeong

author
#0 lore raw

cover slg51000: regulator driver submission

From: Eric Jeong <[email protected]>

This patch adds support for the Dialog SLG51000 regulator device.

In this patch set the following is provided:

[PATCH V1 1/3] MAINTAINERS file update for SLG51000 [PATCH V1 2/3] SLG51000 DT binding
[PATCH V1 3/3] SLG51000 regulator driver

This patch applies against linux-next and next-20190415

Thank you,
Eric Jeong, Dialog Semiconductor Ltd.

Eric Jeong (3):
MAINTAINERS: slg51000 updates to the Dialog Semiconductor search
terms
Documentation: devicetree: regulator: add binding for slg51000
regulator: slg51000: add slg51000 regulator driver

 .../devicetree/bindings/regulator/slg51000.txt     |   88 ++++
 MAINTAINERS                                        |    2 +
 drivers/regulator/Kconfig                          |    9 +
 drivers/regulator/Makefile                         |    1 +
 drivers/regulator/slg51000-regulator.c             |  548 ++++++++++++++++++++
 drivers/regulator/slg51000-regulator.h             |  505 ++++++++++++++++++
 6 files changed, 1153 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/regulator/slg51000.txt
 create mode 100644 drivers/regulator/slg51000-regulator.c
 create mode 100644 drivers/regulator/slg51000-regulator.h
Signature · 1 line
end-of-patch for PATCH V1
author
#1 lore raw

PATCH 1/3 MAINTAINERS: slg51000 updates to the Dialog Semiconductor search terms

From: Eric Jeong <[email protected]>

This patch adds the slg51000 bindings doc and driver to the Dialog Semiconductor support list.

---

 MAINTAINERS |    2 ++
 1 file changed, 2 insertions(+)
MAINTAINERS +2 -0
index 002d564..9783eba 100644
@@ -4632,6 +4632,7 @@ F:	Documentation/devicetree/bindings/mfd/da90*.txt
 F:	Documentation/devicetree/bindings/input/da90??-onkey.txt
 F:	Documentation/devicetree/bindings/thermal/da90??-thermal.txt
 F:	Documentation/devicetree/bindings/regulator/da92*.txt
+F:	Documentation/devicetree/bindings/regulator/slg51000.txt
 F:	Documentation/devicetree/bindings/watchdog/da90??-wdt.txt
 F:	Documentation/devicetree/bindings/sound/da[79]*.txt
 F:	drivers/gpio/gpio-da90??.c
@@ -4647,6 +4648,7 @@ F:	drivers/power/supply/da9052-battery.c
 F:	drivers/power/supply/da91??-*.c
 F:	drivers/regulator/da903x.c
 F:	drivers/regulator/da9???-regulator.[ch]
+F:	drivers/regulator/slg51000-regulator.[ch]
 F:	drivers/thermal/da90??-thermal.c
 F:	drivers/rtc/rtc-da90??.c
 F:	drivers/video/backlight/da90??_bl.c
Signature · 1 line
end-of-patch for PATCH V1
author
#2 lore raw

PATCH 2/3 Documentation: devicetree: regulator: add binding for slg51000

In reply to Eric Jeong

From: Eric Jeong <[email protected]>

Add device tree binding information for slg51000 regulator driver.

---
This patch applies against linux-next and next-20190415

 .../devicetree/bindings/regulator/slg51000.txt     |   88 ++++++++++++++++++++
 1 file changed, 88 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/regulator/slg51000.txt
Documentation/devicetree/bindings/regulator/slg51000.txt new file +88 -0
new file mode 100644
index 0000000..aa0733e
@@ -0,0 +1,88 @@
+* Dialog Semiconductor SLG51000 Voltage Regulator
+
+Required properties:
+- compatible : Should be "dlg,slg51000" for SLG51000
+- reg : Specifies the I2C slave address.
+- xxx-supply: Input voltage supply regulator for ldo3 to ldo7.
+  These entries are required if regulators are enabled for a device.
+  An absence of these properties can cause the regulator registration to fail.
+  If some of input supply is powered through battery or always-on supply then
+  also it is required to have these parameters with proper node handle of always
+  on power supply.
+    vin3-supply: Input supply for ldo3
+    vin4-supply: Input supply for ldo4
+    vin5-supply: Input supply for ldo5
+    vin6-supply: Input supply for ldo6
+    vin7-supply: Input supply for ldo7
+
+Optional properties:
+- interrupt-parent : Specifies the reference to the interrupt controller.
+- interrupts : IRQ line information.
+- dlg,cs-gpios : Specify a valid GPIO for chip select
+
+Sub-nodes:
+- regulators : This node defines the settings for the regulators.
+  The content of the sub-node is defined by the standard binding
+  for regulators; see regulator.txt.
+
+  The SLG51000 regulators are bound using their names listed below:
+    ldo1
+    ldo2
+    ldo3
+    ldo4
+    ldo5
+    ldo6
+    ldo7
+
+Optional properties for regulators:
+- enable-gpios : Specify a valid GPIO for platform control of the regulator.
+
+Example:
+	pmic: slg51000@75 {
+		compatible = "dlg,slg51000";
+		reg = <0x75>;
+
+		regulators {
+			ldo1 {
+			        regulator-name = "ldo1";
+			        regulator-min-microvolt = <2400000>;
+			        regulator-max-microvolt = <3300000>;
+			};
+
+			ldo2 {
+			        regulator-name = "ldo2";
+			        regulator-min-microvolt = <2400000>;
+			        regulator-max-microvolt = <3300000>;
+			};
+
+			ldo3 {
+			        regulator-name = "ldo3";
+			        regulator-min-microvolt = <1200000>;
+			        regulator-max-microvolt = <3750000>;
+			};
+
+			ldo4 {
+			        regulator-name = "ldo4";
+			        regulator-min-microvolt = <1200000>;
+			        regulator-max-microvolt = <3750000>;
+			};
+
+			ldo5 {
+			        regulator-name = "ldo5";
+			        regulator-min-microvolt = <500000>;
+			        regulator-max-microvolt = <1200000>;
+			};
+
+			ldo6 {
+			        regulator-name = "ldo6";
+			        regulator-min-microvolt = <500000>;
+			        regulator-max-microvolt = <1200000>;
+			};
+
+			ldo7 {
+			        regulator-name = "ldo7";
+			        regulator-min-microvolt = <1200000>;
+			        regulator-max-microvolt = <3750000>;
+			};
+		};
+	};
Signature · 1 line
end-of-patch for PATCH V1
maintainer
#3 lore raw

Re: [PATCH V1 2/3] Documentation: devicetree: regulator: add binding for slg51000

Quoted 4 lines · Eric Jeong

From: Eric Jeong <[email protected]>

Add device tree binding information for slg51000 regulator driver.

Please use subject lines matching the style for the subsystem. This makes it easier for people to identify relevant patches. The binding itself looks good, just the subject for the patch.

author
#4 lore raw

PATCH 3/3 regulator: slg51000: add slg51000 regulator driver

In reply to Eric Jeong

From: Eric Jeong <[email protected]>

Adding regulator driver for the device Dialog SLG51000.

The SLG51000 device contains seven compact and customizable low dropout regulators and is designed for high performance camera modules and other small multi-rail applications.

---
This patch applies against linux-next and next-20190415

 drivers/regulator/Kconfig              |    9 +
 drivers/regulator/Makefile             |    1 +
 drivers/regulator/slg51000-regulator.c |  548 ++++++++++++++++++++++++++++++++
 drivers/regulator/slg51000-regulator.h |  505 +++++++++++++++++++++++++++++
 4 files changed, 1063 insertions(+)
 create mode 100644 drivers/regulator/slg51000-regulator.c
 create mode 100644 drivers/regulator/slg51000-regulator.h
drivers/regulator/Kconfig +9 -0
index c4dc2bc..a85acd4 100644
@@ -828,6 +828,15 @@ config REGULATOR_SKY81452
 	  This driver can also be built as a module. If so, the module
 	  will be called sky81452-regulator.
 
+config REGULATOR_SLG51000
+        tristate "Dialog Semiconductor SLG51000 regulators"
+        depends on I2C
+        select REGMAP_I2C
+        help
+	  Say y here to support for the Dialog Semiconductor SLG51000.
+	  The SLG51000 is seven compact and customizable low dropout
+	  regulators.
+
 config REGULATOR_STM32_VREFBUF
 	tristate "STMicroelectronics STM32 VREFBUF"
 	depends on ARCH_STM32 || COMPILE_TEST
drivers/regulator/Makefile +1 -0
index 1169f8a..827d19a 100644
@@ -104,6 +104,7 @@ obj-$(CONFIG_REGULATOR_S2MPS11) += s2mps11.o
 obj-$(CONFIG_REGULATOR_S5M8767) += s5m8767.o
 obj-$(CONFIG_REGULATOR_SC2731) += sc2731-regulator.o
 obj-$(CONFIG_REGULATOR_SKY81452) += sky81452-regulator.o
+obj-$(CONFIG_REGULATOR_SLG51000) += slg51000-regulator.o
 obj-$(CONFIG_REGULATOR_STM32_VREFBUF) += stm32-vrefbuf.o
 obj-$(CONFIG_REGULATOR_STPMIC1) += stpmic1_regulator.o
 obj-$(CONFIG_REGULATOR_STW481X_VMMC) += stw481x-vmmc.o
drivers/regulator/slg51000-regulator.c new file +548 -0

548 lines not on this page · raw message

drivers/regulator/slg51000-regulator.h new file +505 -0

505 lines not on this page · raw message

Signature · 1 line
end-of-patch for PATCH V1
maintainer
#5 lore raw

Re: [PATCH V1 3/3] regulator: slg51000: add slg51000 regulator driver

Quoted 8 lines · Eric Jeong
drivers/regulator/slg51000-regulator.c new file +8 -0
+static int slg51000_regulator_is_enabled(struct regulator_dev *rdev)
+{
+	struct slg51000 *chip = rdev_get_drvdata(rdev);
+	int ret, id = rdev_get_id(rdev);
+	unsigned int state;
+
+	ret = regmap_read(chip->regmap, es_reg[id].sreg, &state);
+	if (ret < 0) {

drivers/regulator/slg51000-regulator.c line 203

Quoted 10 lines
drivers/regulator/slg51000-regulator.c new file +10 -0
+		dev_err(chip->dev, "Failed to read status register(%d)\n",
+			ret);
+		return ret;
+	}
+
+	if (!(state & SLG51000_STA_ILIM_FLAG_MASK) &&
+	    (state & SLG51000_STA_VOUT_OK_FLAG_MASK))
+		return 1;
+	else
+		return 0;

This looks like it should be a get_status() operation as it's reading status bits rather than the command we sent to the device - for that just use regulator_is_enabled_regmap().

Otherwise this all looks great.

#6 lore raw

RE: [PATCH V1 3/3] regulator: slg51000: add slg51000 regulator driver

Quoted 16 lines · Mark Brown
Quoted 14 lines · Eric Jeong
drivers/regulator/slg51000-regulator.c new file +14 -0
+static int slg51000_regulator_is_enabled(struct regulator_dev *rdev)
+{
+	struct slg51000 *chip = rdev_get_drvdata(rdev);
+	int ret, id = rdev_get_id(rdev);
+	unsigned int state;
+
+	ret = regmap_read(chip->regmap, es_reg[id].sreg, &state);
+	if (ret < 0) {
+		dev_err(chip->dev, "Failed to read status register(%d)\n",
+			ret);
+		return ret;
+	}
+
+	if (!(state & SLG51000_STA_ILIM_FLAG_MASK) &&
Quoted 8 lines

drivers/regulator/slg51000-regulator.c line 203

Quoted 4 lines
drivers/regulator/slg51000-regulator.c new file +4 -0
+	    (state & SLG51000_STA_VOUT_OK_FLAG_MASK))
+		return 1;
+	else
+		return 0;

This looks like it should be a get_status() operation as it's reading status bits rather than the command we sent to the device - for that just use regulator_is_enabled_regmap().

I thought that it needs to return current status of a regulator when the function is called. I am wondering that the *is_enabled()* function is just to check
If a regulator has been turned on or not rather than getting current status of the regulator.

Thanks
Eric

maintainer
#7 lore raw

Re: [PATCH V1 3/3] regulator: slg51000: add slg51000 regulator driver

Quoted 9 lines · Eric Hyeung Dong Jeong
Quoted 3 lines · Mark Brown

This looks like it should be a get_status() operation as it's reading status bits rather than the command we sent to the device - for that just use regulator_is_enabled_regmap().

I thought that it needs to return current status of a regulator when the function is called. I am wondering that the *is_enabled()* function is just to check
If a regulator has been turned on or not rather than getting current status of the regulator.

It should say if we told the hardware to enable the regulator so the former - basically, is the hardware in the same state it'd be in after we called _enable() or _disable(). If there's a fault then that should only affect is_enabled() if it resets the enable bit that _enable() set.