linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/8] This is a second edition of a series that implements voltage
@ 2018-12-10 18:42 Priit Laes
  2018-12-10 18:42 ` [PATCH 1/8] mfd: axp20x: name voltage ramping define properly Priit Laes
                   ` (8 more replies)
  0 siblings, 9 replies; 16+ messages in thread
From: Priit Laes @ 2018-12-10 18:42 UTC (permalink / raw)
  To: Lee Jones, Rob Herring, Mark Rutland, Chen-Yu Tsai,
	Maxime Ripard, Liam Girdwood, Mark Brown, devicetree,
	linux-kernel, linux-arm-kernel, Olliver Schinagl, linux-sunxi
  Cc: Priit Laes

ramping for AXP209 DCDC2 and LDO3 regulators and software
based soft-start for AXP209 LDO3 regulator.

Both features are needed to work around a PMIC shutdown when
toggling LDO3 on certain boards with high capacitance on the
LDO3 output.

Similar features (or workarounds) have been also implemented
on u-boot side [1].

Changes since v1:
- Rebased on top of next and dropped already merged patches.
- Dropped LDO4 full range devicetree change for Lime2 (prev patch 9)
  in favor of general pin-bank regulator dependency [2].
- Fixed paths in devicetree bindings (patch 3)
- Added note about software based soft-start for LDO3 (patch 5)

[1] https://lists.denx.de/pipermail/u-boot/2018-November/348612.html
[2] http://lists.infradead.org/pipermail/linux-arm-kernel/2018-December/618459.html

Olliver Schinagl (8):
  mfd: axp20x: name voltage ramping define properly
  regulator: axp20x: add support for set_ramp_delay for AXP209
  dt-bindings: mfd: axp20x: add support for regulator-ramp-delay for AXP209
  regulator: axp20x: add software based soft_start for AXP209 LDO3
  dt-bindings: mfd: axp20x: Add software based soft_start for AXP209 LDO3
  regulator: dts: enable soft-start and ramp delay for the OLinuXino Lime2
  mfd: axp20x: Clean up included headers
  mfd: axp20x: use explicit bit defines

 Documentation/devicetree/bindings/mfd/axp20x.txt |   9 +-
 arch/arm/boot/dts/sun7i-a20-olinuxino-lime2.dts  |   2 +-
 drivers/mfd/axp20x.c                             |  13 +-
 drivers/regulator/axp20x-regulator.c             | 142 +++++++++++++++-
 include/linux/mfd/axp20x.h                       |   4 +-
 5 files changed, 161 insertions(+), 9 deletions(-)

base-commit: 14cf8c1d5b90a0cf6a8ba51ef59db8da8c7a2622
-- 
git-series 0.9.1

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 1/8] mfd: axp20x: name voltage ramping define properly
  2018-12-10 18:42 [PATCH 0/8] This is a second edition of a series that implements voltage Priit Laes
@ 2018-12-10 18:42 ` Priit Laes
  2018-12-13 11:55   ` Mark Brown
  2018-12-10 18:42 ` [PATCH 2/8] regulator: axp20x: add support for set_ramp_delay for AXP209 Priit Laes
                   ` (7 subsequent siblings)
  8 siblings, 1 reply; 16+ messages in thread
From: Priit Laes @ 2018-12-10 18:42 UTC (permalink / raw)
  To: Lee Jones, Rob Herring, Mark Rutland, Chen-Yu Tsai,
	Maxime Ripard, Liam Girdwood, Mark Brown, devicetree,
	linux-kernel, linux-arm-kernel, Olliver Schinagl, linux-sunxi
  Cc: Priit Laes

From: Olliver Schinagl <oliver@schinagl.nl>

The current axp20x names the ramping register 'scal' which probably
means scaling. Since the register really has nothing to do with
scaling, but really is the voltage ramp we rename it appropriately.

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
Signed-off-by: Priit Laes <plaes@plaes.org>
Acked-for-MFD-by: Lee Jones <lee.jones@linaro.org>
---
 include/linux/mfd/axp20x.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/mfd/axp20x.h b/include/linux/mfd/axp20x.h
index 2302b62..a353cd2 100644
--- a/include/linux/mfd/axp20x.h
+++ b/include/linux/mfd/axp20x.h
@@ -35,7 +35,7 @@ enum axp20x_variants {
 #define AXP152_ALDO_OP_MODE		0x13
 #define AXP152_LDO0_CTRL		0x15
 #define AXP152_DCDC2_V_OUT		0x23
-#define AXP152_DCDC2_V_SCAL		0x25
+#define AXP152_DCDC2_V_RAMP		0x25
 #define AXP152_DCDC1_V_OUT		0x26
 #define AXP152_DCDC3_V_OUT		0x27
 #define AXP152_ALDO12_V_OUT		0x28
@@ -53,7 +53,7 @@ enum axp20x_variants {
 #define AXP20X_USB_OTG_STATUS		0x02
 #define AXP20X_PWR_OUT_CTRL		0x12
 #define AXP20X_DCDC2_V_OUT		0x23
-#define AXP20X_DCDC2_LDO3_V_SCAL	0x25
+#define AXP20X_DCDC2_LDO3_V_RAMP	0x25
 #define AXP20X_DCDC3_V_OUT		0x27
 #define AXP20X_LDO24_V_OUT		0x28
 #define AXP20X_LDO3_V_OUT		0x29
-- 
git-series 0.9.1

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 2/8] regulator: axp20x: add support for set_ramp_delay for AXP209
  2018-12-10 18:42 [PATCH 0/8] This is a second edition of a series that implements voltage Priit Laes
  2018-12-10 18:42 ` [PATCH 1/8] mfd: axp20x: name voltage ramping define properly Priit Laes
@ 2018-12-10 18:42 ` Priit Laes
  2018-12-11 13:14   ` [linux-sunxi] " Julian Calaby
  2018-12-10 18:42 ` [PATCH 3/8] dt-bindings: mfd: axp20x: add support for regulator-ramp-delay " Priit Laes
                   ` (6 subsequent siblings)
  8 siblings, 1 reply; 16+ messages in thread
From: Priit Laes @ 2018-12-10 18:42 UTC (permalink / raw)
  To: Lee Jones, Rob Herring, Mark Rutland, Chen-Yu Tsai,
	Maxime Ripard, Liam Girdwood, Mark Brown, devicetree,
	linux-kernel, linux-arm-kernel, Olliver Schinagl, linux-sunxi
  Cc: Priit Laes

From: Olliver Schinagl <oliver@schinagl.nl>

The AXP209 supports ramping up voltages on several regulators such as
DCDC2 and LDO3.

This patch adds preliminary support for the regulator-ramp-delay property
for these 2 regulators. Note that the voltage ramp only works when
regulator is already enabled. E.g. when going from say 0.7 V to 3.6 V.

When turning on the regulator, no voltage ramp is performed in hardware.

What this means, is that if the bootloader brings up the voltage at 0.7 V,
the ramp delay property is properly applied. If however, the bootloader
leaves the power off, no ramp delay is applied when the power is
enabled by the regulator framework.

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
Signed-off-by: Priit Laes <plaes@plaes.org>
---
 drivers/regulator/axp20x-regulator.c | 85 +++++++++++++++++++++++++++++-
 1 file changed, 85 insertions(+)

diff --git a/drivers/regulator/axp20x-regulator.c b/drivers/regulator/axp20x-regulator.c
index 9a2db28..1d9fa62 100644
--- a/drivers/regulator/axp20x-regulator.c
+++ b/drivers/regulator/axp20x-regulator.c
@@ -51,6 +51,17 @@
 #define AXP20X_PWR_OUT_DCDC2_MASK	BIT_MASK(4)
 #define AXP20X_PWR_OUT_LDO3_MASK	BIT_MASK(6)
 
+#define AXP20X_DCDC2_LDO3_V_RAMP_DCDC2_RATE_MASK	BIT_MASK(0)
+#define AXP20X_DCDC2_LDO3_V_RAMP_DCDC2_RATE(x) \
+	((x) << 0)
+#define AXP20X_DCDC2_LDO3_V_RAMP_LDO3_RATE_MASK		BIT_MASK(1)
+#define AXP20X_DCDC2_LDO3_V_RAMP_LDO3_RATE(x) \
+	((x) << 1)
+#define AXP20X_DCDC2_LDO3_V_RAMP_DCDC2_EN_MASK		BIT_MASK(2)
+#define AXP20X_DCDC2_LDO3_V_RAMP_DCDC2_EN		BIT(2)
+#define AXP20X_DCDC2_LDO3_V_RAMP_LDO3_EN_MASK		BIT_MASK(3)
+#define AXP20X_DCDC2_LDO3_V_RAMP_LDO3_EN		BIT(3)
+
 #define AXP20X_LDO4_V_OUT_1250mV_START	0x0
 #define AXP20X_LDO4_V_OUT_1250mV_STEPS	0
 #define AXP20X_LDO4_V_OUT_1250mV_END	\
@@ -346,6 +357,79 @@
 		.ops		= &axp20x_ops_range,				\
 	}
 
+static const int axp209_dcdc2_ldo3_slew_rates[] = {
+	1600,
+	 800,
+};
+
+static int axp20x_set_ramp_delay(struct regulator_dev *rdev, int ramp)
+{
+	struct axp20x_dev *axp20x = rdev_get_drvdata(rdev);
+	const struct regulator_desc *desc = rdev->desc;
+	u8 reg, mask, enable, cfg = 0xff;
+	const int *slew_rates;
+	int rate_count = 0;
+
+	if (!rdev)
+		return -EINVAL;
+
+	switch (axp20x->variant) {
+	case AXP209_ID:
+		if (desc->id == AXP20X_DCDC2) {
+			rate_count = ARRAY_SIZE(axp209_dcdc2_ldo3_slew_rates);
+			reg = AXP20X_DCDC2_LDO3_V_RAMP;
+			mask = AXP20X_DCDC2_LDO3_V_RAMP_DCDC2_RATE_MASK |
+			       AXP20X_DCDC2_LDO3_V_RAMP_DCDC2_EN_MASK;
+			enable = (ramp > 0) ?
+				 AXP20X_DCDC2_LDO3_V_RAMP_DCDC2_EN :
+				 !AXP20X_DCDC2_LDO3_V_RAMP_DCDC2_EN;
+			break;
+		}
+
+		if (desc->id == AXP20X_LDO3) {
+			slew_rates = axp209_dcdc2_ldo3_slew_rates;
+			rate_count = ARRAY_SIZE(axp209_dcdc2_ldo3_slew_rates);
+			reg = AXP20X_DCDC2_LDO3_V_RAMP;
+			mask = AXP20X_DCDC2_LDO3_V_RAMP_LDO3_RATE_MASK |
+			       AXP20X_DCDC2_LDO3_V_RAMP_LDO3_EN_MASK;
+			enable = (ramp > 0) ?
+				 AXP20X_DCDC2_LDO3_V_RAMP_LDO3_EN :
+				 !AXP20X_DCDC2_LDO3_V_RAMP_LDO3_EN;
+			break;
+		}
+
+		if (rate_count > 0)
+			break;
+
+		/* fall through */
+	default:
+		/* Not supported for this regulator */
+		return -ENOTSUPP;
+	}
+
+	if (ramp == 0) {
+		cfg = enable;
+	} else {
+		int i;
+
+		for (i = 0; i < rate_count; i++) {
+			if (ramp <= slew_rates[i])
+				cfg = AXP20X_DCDC2_LDO3_V_RAMP_LDO3_RATE(i);
+			else
+				break;
+		}
+
+		if (cfg == 0xff) {
+			dev_err(axp20x->dev, "unsupported ramp value %d", ramp);
+			return -EINVAL;
+		}
+
+		cfg |= enable;
+	}
+
+	return regmap_update_bits(axp20x->regmap, reg, mask, cfg);
+}
+
 static const struct regulator_ops axp20x_ops_fixed = {
 	.list_voltage		= regulator_list_voltage_linear,
 };
@@ -366,6 +450,7 @@ static const struct regulator_ops axp20x_ops = {
 	.enable			= regulator_enable_regmap,
 	.disable		= regulator_disable_regmap,
 	.is_enabled		= regulator_is_enabled_regmap,
+	.set_ramp_delay		= axp20x_set_ramp_delay,
 };
 
 static const struct regulator_ops axp20x_ops_sw = {
-- 
git-series 0.9.1

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 3/8] dt-bindings: mfd: axp20x: add support for regulator-ramp-delay for AXP209
  2018-12-10 18:42 [PATCH 0/8] This is a second edition of a series that implements voltage Priit Laes
  2018-12-10 18:42 ` [PATCH 1/8] mfd: axp20x: name voltage ramping define properly Priit Laes
  2018-12-10 18:42 ` [PATCH 2/8] regulator: axp20x: add support for set_ramp_delay for AXP209 Priit Laes
@ 2018-12-10 18:42 ` Priit Laes
  2018-12-10 18:42 ` [PATCH 4/8] regulator: axp20x: add software based soft_start for AXP209 LDO3 Priit Laes
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 16+ messages in thread
From: Priit Laes @ 2018-12-10 18:42 UTC (permalink / raw)
  To: Lee Jones, Rob Herring, Mark Rutland, Chen-Yu Tsai,
	Maxime Ripard, Liam Girdwood, Mark Brown, devicetree,
	linux-kernel, linux-arm-kernel, Olliver Schinagl, linux-sunxi
  Cc: Priit Laes

From: Olliver Schinagl <oliver@schinagl.nl>

The AXP209 supports ramping up voltages on several regulators such as
DCDC2 and LDO3, therefore we can use the standard 'regulator-ramp-delay'
property for those 2 regulators.

Note that the voltage ramp only works when the regulator is already
enabled. E.g. when going from say 0.7 V to 3.6 V.

When turning on the regulator, no voltage ramp is performed in hardware.

What this means, is that if the bootloader brings up the voltage at 0.7 V,
the ramp delay property is properly applied. If however, the bootloader
leaves the power off, no ramp delay is applied when the power is
enabled by the regulator framework.

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
Signed-off-by: Priit Laes <plaes@plaes.org>
Acked-for-MFD-by: Lee Jones <lee.jones@linaro.org>
---
 Documentation/devicetree/bindings/mfd/axp20x.txt | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/Documentation/devicetree/bindings/mfd/axp20x.txt b/Documentation/devicetree/bindings/mfd/axp20x.txt
index 188f037..c626605 100644
--- a/Documentation/devicetree/bindings/mfd/axp20x.txt
+++ b/Documentation/devicetree/bindings/mfd/axp20x.txt
@@ -32,6 +32,12 @@ Required properties:
 - interrupt-controller: The PMIC has its own internal IRQs
 - #interrupt-cells: Should be set to 1
 
+Supported common regulator properties, see ../regulator/regulator.txt for
+more information:
+- regulator-ramp-delay: sets the ramp up delay in uV/us
+			AXP20x/DCDC2: 1600, 800
+			AXP20x/LDO3:  1600, 800
+
 Optional properties:
 - x-powers,dcdc-freq: defines the work frequency of DC-DC in KHz
 		      AXP152/20X: range:  750-1875, Default: 1.5 MHz
-- 
git-series 0.9.1

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 4/8] regulator: axp20x: add software based soft_start for AXP209 LDO3
  2018-12-10 18:42 [PATCH 0/8] This is a second edition of a series that implements voltage Priit Laes
                   ` (2 preceding siblings ...)
  2018-12-10 18:42 ` [PATCH 3/8] dt-bindings: mfd: axp20x: add support for regulator-ramp-delay " Priit Laes
@ 2018-12-10 18:42 ` Priit Laes
  2018-12-10 18:42 ` [PATCH 5/8] dt-bindings: mfd: axp20x: Add " Priit Laes
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 16+ messages in thread
From: Priit Laes @ 2018-12-10 18:42 UTC (permalink / raw)
  To: Lee Jones, Rob Herring, Mark Rutland, Chen-Yu Tsai,
	Maxime Ripard, Liam Girdwood, Mark Brown, devicetree,
	linux-kernel, linux-arm-kernel, Olliver Schinagl, linux-sunxi
  Cc: Priit Laes

From: Olliver Schinagl <oliver@schinagl.nl>

In the past, there have been words on various lists that if LDO3 is
disabled in u-boot, but enabled in the DTS, the axp209 driver would
fail to continue/hang. Several enable/disable patches have been
issues to devicetree's in both the kernel and u-boot to address
this issue.

What really happened however, was that the AXP209 shuts down without
a notice and without setting an interrupt. This is caused when LDO3
gets overloaded, for example with large capacitors on the LDO3 output.

Normally, we would expect that AXP209 would source 200 mA as per
datasheet and set and trigger an interrupt when being overloaded.
For some reason however, this does not happen.

As a work-around, we use the soft-start constraint of the regulator
node to first bring up the LDO3 to the lowest possible voltage and
then enable the LDO. After that, we can set the requested voltage
as usual.

Combining this setting with the regulator-ramp-delay allows LDO3 to
enable voltage slowly and staggered, potentially reducing overall
inrush current.

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
Signed-off-by: Priit Laes <plaes@plaes.org>
---
 drivers/regulator/axp20x-regulator.c | 57 ++++++++++++++++++++++++++++-
 1 file changed, 56 insertions(+), 1 deletion(-)

diff --git a/drivers/regulator/axp20x-regulator.c b/drivers/regulator/axp20x-regulator.c
index 1d9fa62..e8a895b 100644
--- a/drivers/regulator/axp20x-regulator.c
+++ b/drivers/regulator/axp20x-regulator.c
@@ -14,6 +14,7 @@
  */
 
 #include <linux/bitops.h>
+#include <linux/delay.h>
 #include <linux/err.h>
 #include <linux/init.h>
 #include <linux/mfd/axp20x.h>
@@ -23,6 +24,7 @@
 #include <linux/platform_device.h>
 #include <linux/regmap.h>
 #include <linux/regulator/driver.h>
+#include <linux/regulator/machine.h>
 #include <linux/regulator/of_regulator.h>
 
 #define AXP20X_GPIO0_FUNC_MASK		GENMASK(3, 0)
@@ -430,6 +432,59 @@ static int axp20x_set_ramp_delay(struct regulator_dev *rdev, int ramp)
 	return regmap_update_bits(axp20x->regmap, reg, mask, cfg);
 }
 
+static int axp20x_regulator_enable_regmap(struct regulator_dev *rdev)
+{
+	struct axp20x_dev *axp20x = rdev_get_drvdata(rdev);
+	const struct regulator_desc *desc = rdev->desc;
+
+	if (!rdev)
+		return -EINVAL;
+
+	switch (axp20x->variant) {
+	case AXP209_ID:
+		if ((desc->id == AXP20X_LDO3) &&
+		    rdev->constraints && rdev->constraints->soft_start) {
+			int v_out;
+			int ret;
+
+			/*
+			 * On some boards, the LDO3 can be overloaded when
+			 * turning on, causing the entire PMIC to shutdown
+			 * without warning. Turning it on at the minimal voltage
+			 * and then setting the voltage to the requested value
+			 * works reliably.
+			 */
+			if (regulator_is_enabled_regmap(rdev))
+				break;
+
+			v_out = regulator_get_voltage_sel_regmap(rdev);
+			if (v_out < 0)
+				return v_out;
+
+			if (v_out == 0)
+				break;
+
+			ret = regulator_set_voltage_sel_regmap(rdev, 0x00);
+			/*
+			 * A small pause is needed between
+			 * setting the voltage and enabling the LDO to give the
+			 * internal state machine time to process the request.
+			 */
+			usleep_range(1000, 5000);
+			ret |= regulator_enable_regmap(rdev);
+			ret |= regulator_set_voltage_sel_regmap(rdev, v_out);
+
+			return ret;
+		}
+		break;
+	default:
+		/* No quirks */
+		break;
+	}
+
+	return regulator_enable_regmap(rdev);
+};
+
 static const struct regulator_ops axp20x_ops_fixed = {
 	.list_voltage		= regulator_list_voltage_linear,
 };
@@ -447,7 +502,7 @@ static const struct regulator_ops axp20x_ops = {
 	.set_voltage_sel	= regulator_set_voltage_sel_regmap,
 	.get_voltage_sel	= regulator_get_voltage_sel_regmap,
 	.list_voltage		= regulator_list_voltage_linear,
-	.enable			= regulator_enable_regmap,
+	.enable			= axp20x_regulator_enable_regmap,
 	.disable		= regulator_disable_regmap,
 	.is_enabled		= regulator_is_enabled_regmap,
 	.set_ramp_delay		= axp20x_set_ramp_delay,
-- 
git-series 0.9.1

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 5/8] dt-bindings: mfd: axp20x: Add software based soft_start for AXP209 LDO3
  2018-12-10 18:42 [PATCH 0/8] This is a second edition of a series that implements voltage Priit Laes
                   ` (3 preceding siblings ...)
  2018-12-10 18:42 ` [PATCH 4/8] regulator: axp20x: add software based soft_start for AXP209 LDO3 Priit Laes
@ 2018-12-10 18:42 ` Priit Laes
  2018-12-10 18:42 ` [PATCH 6/8] regulator: dts: enable soft-start and ramp delay for the OLinuXino Lime2 Priit Laes
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 16+ messages in thread
From: Priit Laes @ 2018-12-10 18:42 UTC (permalink / raw)
  To: Lee Jones, Rob Herring, Mark Rutland, Chen-Yu Tsai,
	Maxime Ripard, Liam Girdwood, Mark Brown, devicetree,
	linux-kernel, linux-arm-kernel, Olliver Schinagl, linux-sunxi
  Cc: Priit Laes

From: Olliver Schinagl <oliver@schinagl.nl>

In the past, there have been words on various lists that if LDO3 is
disabled in u-boot, but enabled in the DTS, the axp209 driver would
fail to continue/hang. Several enable/disable patches have been
issues to devicetree's in both the kernel and u-boot to address
this issue.

What really happened however, was that the AXP209 shuts down without
a notice and without setting an interrupt. This is caused when LDO3
gets overloaded, for example with large capacitors on the LDO3 output.

Normally, we would expect that AXP209 would source 200 mA as per
datasheet and set and trigger an interrupt when being overloaded.
For some reason however, this does not happen.

As a work-around, implement software-based 'regulator-soft-start'
property for AXP209 LDO3 regulator, which is used to first bring up
the LDO3 to the lowest possible voltage and then enable the LDO.

After that, we can set the requested voltage as usual.

Combining this setting with the regulator-ramp-delay allows LDO3 to
come up slowly and staggered, potentially reducing overall inrush current.

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
Signed-off-by: Priit Laes <plaes@plaes.org>
---
 Documentation/devicetree/bindings/mfd/axp20x.txt | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Documentation/devicetree/bindings/mfd/axp20x.txt b/Documentation/devicetree/bindings/mfd/axp20x.txt
index c626605..2af4ff9 100644
--- a/Documentation/devicetree/bindings/mfd/axp20x.txt
+++ b/Documentation/devicetree/bindings/mfd/axp20x.txt
@@ -37,6 +37,9 @@ more information:
 - regulator-ramp-delay: sets the ramp up delay in uV/us
 			AXP20x/DCDC2: 1600, 800
 			AXP20x/LDO3:  1600, 800
+- regulator-soft-start:	enable the output at the lowest possible voltage and
+			only then set the desired voltage
+			AXP20x/LDO3: software-based implementation
 
 Optional properties:
 - x-powers,dcdc-freq: defines the work frequency of DC-DC in KHz
-- 
git-series 0.9.1

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 6/8] regulator: dts: enable soft-start and ramp delay for the OLinuXino Lime2
  2018-12-10 18:42 [PATCH 0/8] This is a second edition of a series that implements voltage Priit Laes
                   ` (4 preceding siblings ...)
  2018-12-10 18:42 ` [PATCH 5/8] dt-bindings: mfd: axp20x: Add " Priit Laes
@ 2018-12-10 18:42 ` Priit Laes
  2018-12-10 18:42 ` [PATCH 7/8] mfd: axp20x: Clean up included headers Priit Laes
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 16+ messages in thread
From: Priit Laes @ 2018-12-10 18:42 UTC (permalink / raw)
  To: Lee Jones, Rob Herring, Mark Rutland, Chen-Yu Tsai,
	Maxime Ripard, Liam Girdwood, Mark Brown, devicetree,
	linux-kernel, linux-arm-kernel, Olliver Schinagl, linux-sunxi
  Cc: Priit Laes

From: Olliver Schinagl <oliver@schinagl.nl>

The OLinuXino Lime2 has a big capacitor on its LDO3 output. It is
actually too large, causing the PMIC to shutdown when toggling the LDO3.

By enabling soft-start and ramp delay we increase the time for the
capacitor to charge lowering the current drain on the power regulator.

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
Signed-off-by: Priit Laes <plaes@plaes.org>
---
 arch/arm/boot/dts/sun7i-a20-olinuxino-lime2.dts | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm/boot/dts/sun7i-a20-olinuxino-lime2.dts b/arch/arm/boot/dts/sun7i-a20-olinuxino-lime2.dts
index 55c9086..4e1c590 100644
--- a/arch/arm/boot/dts/sun7i-a20-olinuxino-lime2.dts
+++ b/arch/arm/boot/dts/sun7i-a20-olinuxino-lime2.dts
@@ -232,6 +232,8 @@
 	regulator-min-microvolt = <2800000>;
 	regulator-max-microvolt = <2800000>;
 	regulator-name = "vddio-csi0";
+	regulator-soft-start;
+	regulator-ramp-delay = <1600>;
 };
 
 &reg_ldo4 {
-- 
git-series 0.9.1

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 7/8] mfd: axp20x: Clean up included headers
  2018-12-10 18:42 [PATCH 0/8] This is a second edition of a series that implements voltage Priit Laes
                   ` (5 preceding siblings ...)
  2018-12-10 18:42 ` [PATCH 6/8] regulator: dts: enable soft-start and ramp delay for the OLinuXino Lime2 Priit Laes
@ 2018-12-10 18:42 ` Priit Laes
  2018-12-10 18:42 ` [PATCH 8/8] mfd: axp20x: use explicit bit defines Priit Laes
  2018-12-11  7:11 ` [linux-sunxi] [PATCH 0/8] This is a second edition of a series that implements voltage Priit Laes
  8 siblings, 0 replies; 16+ messages in thread
From: Priit Laes @ 2018-12-10 18:42 UTC (permalink / raw)
  To: Lee Jones, Rob Herring, Mark Rutland, Chen-Yu Tsai,
	Maxime Ripard, Liam Girdwood, Mark Brown, devicetree,
	linux-kernel, linux-arm-kernel, Olliver Schinagl, linux-sunxi
  Cc: Priit Laes

From: Olliver Schinagl <oliver@schinagl.nl>

Add the bitops.h header as we need it, alphabetize header order.

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
Signed-off-by: Priit Laes <plaes@plaes.org>
Acked-for-MFD-by: Lee Jones <lee.jones@linaro.org>
---
 drivers/mfd/axp20x.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c
index dfc3cff..c3f3dbd 100644
--- a/drivers/mfd/axp20x.c
+++ b/drivers/mfd/axp20x.c
@@ -16,18 +16,19 @@
  * published by the Free Software Foundation.
  */
 
-#include <linux/err.h>
+#include <linux/acpi.h>
+#include <linux/bitops.h>
 #include <linux/delay.h>
+#include <linux/err.h>
 #include <linux/interrupt.h>
 #include <linux/kernel.h>
+#include <linux/mfd/axp20x.h>
+#include <linux/mfd/core.h>
 #include <linux/module.h>
+#include <linux/of_device.h>
 #include <linux/pm_runtime.h>
 #include <linux/regmap.h>
 #include <linux/regulator/consumer.h>
-#include <linux/mfd/axp20x.h>
-#include <linux/mfd/core.h>
-#include <linux/of_device.h>
-#include <linux/acpi.h>
 
 #define AXP20X_OFF	0x80
 
-- 
git-series 0.9.1

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 8/8] mfd: axp20x: use explicit bit defines
  2018-12-10 18:42 [PATCH 0/8] This is a second edition of a series that implements voltage Priit Laes
                   ` (6 preceding siblings ...)
  2018-12-10 18:42 ` [PATCH 7/8] mfd: axp20x: Clean up included headers Priit Laes
@ 2018-12-10 18:42 ` Priit Laes
  2018-12-11  7:11 ` [linux-sunxi] [PATCH 0/8] This is a second edition of a series that implements voltage Priit Laes
  8 siblings, 0 replies; 16+ messages in thread
From: Priit Laes @ 2018-12-10 18:42 UTC (permalink / raw)
  To: Lee Jones, Rob Herring, Mark Rutland, Chen-Yu Tsai,
	Maxime Ripard, Liam Girdwood, Mark Brown, devicetree,
	linux-kernel, linux-arm-kernel, Olliver Schinagl, linux-sunxi
  Cc: Priit Laes

From: Olliver Schinagl <oliver@schinagl.nl>

The AXP20X_OFF define is an actual specific bit, define it as such.

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
Signed-off-by: Priit Laes <plaes@plaes.org>
Acked-for-MFD-by: Lee Jones <lee.jones@linaro.org>
---
 drivers/mfd/axp20x.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c
index c3f3dbd..d183ed8 100644
--- a/drivers/mfd/axp20x.c
+++ b/drivers/mfd/axp20x.c
@@ -30,7 +30,7 @@
 #include <linux/regmap.h>
 #include <linux/regulator/consumer.h>
 
-#define AXP20X_OFF	0x80
+#define AXP20X_OFF	BIT(7)
 
 #define AXP806_REG_ADDR_EXT_ADDR_MASTER_MODE	0
 #define AXP806_REG_ADDR_EXT_ADDR_SLAVE_MODE	BIT(4)
-- 
git-series 0.9.1

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [linux-sunxi] [PATCH 0/8] This is a second edition of a series that implements voltage
  2018-12-10 18:42 [PATCH 0/8] This is a second edition of a series that implements voltage Priit Laes
                   ` (7 preceding siblings ...)
  2018-12-10 18:42 ` [PATCH 8/8] mfd: axp20x: use explicit bit defines Priit Laes
@ 2018-12-11  7:11 ` Priit Laes
  2018-12-11  7:46   ` Lee Jones
  8 siblings, 1 reply; 16+ messages in thread
From: Priit Laes @ 2018-12-11  7:11 UTC (permalink / raw)
  To: Lee Jones, Rob Herring, Mark Rutland, Chen-Yu Tsai,
	Maxime Ripard, Liam Girdwood, Mark Brown, devicetree,
	linux-kernel, linux-arm-kernel, Olliver Schinagl, linux-sunxi

On Mon, Dec 10, 2018 at 08:42:11PM +0200, Priit Laes wrote:
> ramping for AXP209 DCDC2 and LDO3 regulators and software
> based soft-start for AXP209 LDO3 regulator.

Ugh.. managed to botch this series. I'll send a fixed one
today.

> 
> Both features are needed to work around a PMIC shutdown when
> toggling LDO3 on certain boards with high capacitance on the
> LDO3 output.
> 
> Similar features (or workarounds) have been also implemented
> on u-boot side [1].
> 
> Changes since v1:
> - Rebased on top of next and dropped already merged patches.
> - Dropped LDO4 full range devicetree change for Lime2 (prev patch 9)
>   in favor of general pin-bank regulator dependency [2].
> - Fixed paths in devicetree bindings (patch 3)
> - Added note about software based soft-start for LDO3 (patch 5)
> 
> [1] https://lists.denx.de/pipermail/u-boot/2018-November/348612.html
> [2] http://lists.infradead.org/pipermail/linux-arm-kernel/2018-December/618459.html
> 
> Olliver Schinagl (8):
>   mfd: axp20x: name voltage ramping define properly
>   regulator: axp20x: add support for set_ramp_delay for AXP209
>   dt-bindings: mfd: axp20x: add support for regulator-ramp-delay for AXP209
>   regulator: axp20x: add software based soft_start for AXP209 LDO3
>   dt-bindings: mfd: axp20x: Add software based soft_start for AXP209 LDO3
>   regulator: dts: enable soft-start and ramp delay for the OLinuXino Lime2
>   mfd: axp20x: Clean up included headers
>   mfd: axp20x: use explicit bit defines
> 
>  Documentation/devicetree/bindings/mfd/axp20x.txt |   9 +-
>  arch/arm/boot/dts/sun7i-a20-olinuxino-lime2.dts  |   2 +-
>  drivers/mfd/axp20x.c                             |  13 +-
>  drivers/regulator/axp20x-regulator.c             | 142 +++++++++++++++-
>  include/linux/mfd/axp20x.h                       |   4 +-
>  5 files changed, 161 insertions(+), 9 deletions(-)
> 
> base-commit: 14cf8c1d5b90a0cf6a8ba51ef59db8da8c7a2622
> -- 
> git-series 0.9.1
> 
> -- 
> You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [linux-sunxi] [PATCH 0/8] This is a second edition of a series that implements voltage
  2018-12-11  7:11 ` [linux-sunxi] [PATCH 0/8] This is a second edition of a series that implements voltage Priit Laes
@ 2018-12-11  7:46   ` Lee Jones
  0 siblings, 0 replies; 16+ messages in thread
From: Lee Jones @ 2018-12-11  7:46 UTC (permalink / raw)
  To: Priit Laes
  Cc: Rob Herring, Mark Rutland, Chen-Yu Tsai, Maxime Ripard,
	Liam Girdwood, Mark Brown, devicetree, linux-kernel,
	linux-arm-kernel, Olliver Schinagl, linux-sunxi

On Tue, 11 Dec 2018, Priit Laes wrote:

> On Mon, Dec 10, 2018 at 08:42:11PM +0200, Priit Laes wrote:
> > ramping for AXP209 DCDC2 and LDO3 regulators and software
> > based soft-start for AXP209 LDO3 regulator.
> 
> Ugh.. managed to botch this series. I'll send a fixed one
> today.

While you're at it, please don't forget to add the version number in
the patch subject lines.  Each patch should have read "[PATCH v2]
<...>" in this submission.

> > Both features are needed to work around a PMIC shutdown when
> > toggling LDO3 on certain boards with high capacitance on the
> > LDO3 output.
> > 
> > Similar features (or workarounds) have been also implemented
> > on u-boot side [1].
> > 
> > Changes since v1:
> > - Rebased on top of next and dropped already merged patches.
> > - Dropped LDO4 full range devicetree change for Lime2 (prev patch 9)
> >   in favor of general pin-bank regulator dependency [2].
> > - Fixed paths in devicetree bindings (patch 3)
> > - Added note about software based soft-start for LDO3 (patch 5)
> > 
> > [1] https://lists.denx.de/pipermail/u-boot/2018-November/348612.html
> > [2] http://lists.infradead.org/pipermail/linux-arm-kernel/2018-December/618459.html
> > 
> > Olliver Schinagl (8):
> >   mfd: axp20x: name voltage ramping define properly
> >   regulator: axp20x: add support for set_ramp_delay for AXP209
> >   dt-bindings: mfd: axp20x: add support for regulator-ramp-delay for AXP209
> >   regulator: axp20x: add software based soft_start for AXP209 LDO3
> >   dt-bindings: mfd: axp20x: Add software based soft_start for AXP209 LDO3
> >   regulator: dts: enable soft-start and ramp delay for the OLinuXino Lime2
> >   mfd: axp20x: Clean up included headers
> >   mfd: axp20x: use explicit bit defines
> > 
> >  Documentation/devicetree/bindings/mfd/axp20x.txt |   9 +-
> >  arch/arm/boot/dts/sun7i-a20-olinuxino-lime2.dts  |   2 +-
> >  drivers/mfd/axp20x.c                             |  13 +-
> >  drivers/regulator/axp20x-regulator.c             | 142 +++++++++++++++-
> >  include/linux/mfd/axp20x.h                       |   4 +-
> >  5 files changed, 161 insertions(+), 9 deletions(-)
> > 
> > base-commit: 14cf8c1d5b90a0cf6a8ba51ef59db8da8c7a2622

-- 
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [linux-sunxi] [PATCH 2/8] regulator: axp20x: add support for set_ramp_delay for AXP209
  2018-12-10 18:42 ` [PATCH 2/8] regulator: axp20x: add support for set_ramp_delay for AXP209 Priit Laes
@ 2018-12-11 13:14   ` Julian Calaby
  2018-12-12 11:02     ` Priit Laes
  0 siblings, 1 reply; 16+ messages in thread
From: Julian Calaby @ 2018-12-11 13:14 UTC (permalink / raw)
  To: Priit Laes, Olliver Schinagl
  Cc: Lee Jones, Rob Herring, Mark Rutland, Chen-Yu Tsai,
	Maxime Ripard, Liam Girdwood, Mark Brown, devicetree,
	linux-kernel, Mailing List, Arm, linux-sunxi

Hi Priit and Olliver,

On Tue, Dec 11, 2018 at 5:42 AM Priit Laes <plaes@plaes.org> wrote:
>
> From: Olliver Schinagl <oliver@schinagl.nl>
>
> The AXP209 supports ramping up voltages on several regulators such as
> DCDC2 and LDO3.
>
> This patch adds preliminary support for the regulator-ramp-delay property
> for these 2 regulators. Note that the voltage ramp only works when
> regulator is already enabled. E.g. when going from say 0.7 V to 3.6 V.
>
> When turning on the regulator, no voltage ramp is performed in hardware.
>
> What this means, is that if the bootloader brings up the voltage at 0.7 V,
> the ramp delay property is properly applied. If however, the bootloader
> leaves the power off, no ramp delay is applied when the power is
> enabled by the regulator framework.
>
> Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
> Signed-off-by: Priit Laes <plaes@plaes.org>
> ---
>  drivers/regulator/axp20x-regulator.c | 85 +++++++++++++++++++++++++++++-
>  1 file changed, 85 insertions(+)
>
> diff --git a/drivers/regulator/axp20x-regulator.c b/drivers/regulator/axp20x-regulator.c
> index 9a2db28..1d9fa62 100644
> --- a/drivers/regulator/axp20x-regulator.c
> +++ b/drivers/regulator/axp20x-regulator.c
> @@ -346,6 +357,79 @@
>                 .ops            = &axp20x_ops_range,                            \
>         }
>
> +static const int axp209_dcdc2_ldo3_slew_rates[] = {
> +       1600,
> +        800,
> +};
> +
> +static int axp20x_set_ramp_delay(struct regulator_dev *rdev, int ramp)
> +{
> +       struct axp20x_dev *axp20x = rdev_get_drvdata(rdev);
> +       const struct regulator_desc *desc = rdev->desc;
> +       u8 reg, mask, enable, cfg = 0xff;
> +       const int *slew_rates;
> +       int rate_count = 0;
> +
> +       if (!rdev)
> +               return -EINVAL;
> +
> +       switch (axp20x->variant) {
> +       case AXP209_ID:
> +               if (desc->id == AXP20X_DCDC2) {

Is slew_rates supposed to be set here?

> +                       rate_count = ARRAY_SIZE(axp209_dcdc2_ldo3_slew_rates);
> +                       reg = AXP20X_DCDC2_LDO3_V_RAMP;
> +                       mask = AXP20X_DCDC2_LDO3_V_RAMP_DCDC2_RATE_MASK |
> +                              AXP20X_DCDC2_LDO3_V_RAMP_DCDC2_EN_MASK;
> +                       enable = (ramp > 0) ?
> +                                AXP20X_DCDC2_LDO3_V_RAMP_DCDC2_EN :
> +                                !AXP20X_DCDC2_LDO3_V_RAMP_DCDC2_EN;
> +                       break;
> +               }
> +
> +               if (desc->id == AXP20X_LDO3) {
> +                       slew_rates = axp209_dcdc2_ldo3_slew_rates;
> +                       rate_count = ARRAY_SIZE(axp209_dcdc2_ldo3_slew_rates);
> +                       reg = AXP20X_DCDC2_LDO3_V_RAMP;
> +                       mask = AXP20X_DCDC2_LDO3_V_RAMP_LDO3_RATE_MASK |
> +                              AXP20X_DCDC2_LDO3_V_RAMP_LDO3_EN_MASK;
> +                       enable = (ramp > 0) ?
> +                                AXP20X_DCDC2_LDO3_V_RAMP_LDO3_EN :
> +                                !AXP20X_DCDC2_LDO3_V_RAMP_LDO3_EN;
> +                       break;
> +               }
> +
> +               if (rate_count > 0)
> +                       break;

You could save one to two tests by combining the above three if statements, i.e.

if (DCDC2) {
    // set DCDC2 stuff

    break;
} else if (LDO3) {
    // set LDO3 stuff

    break;
}

As written, the rate_count > 0 test will never be true as every block
that sets rate_count breaks out of the switch block.

You could then calculate rate_count below the switch block.

> +
> +               /* fall through */
> +       default:
> +               /* Not supported for this regulator */
> +               return -ENOTSUPP;
> +       }
> +
> +       if (ramp == 0) {
> +               cfg = enable;
> +       } else {
> +               int i;
> +
> +               for (i = 0; i < rate_count; i++) {
> +                       if (ramp <= slew_rates[i])
> +                               cfg = AXP20X_DCDC2_LDO3_V_RAMP_LDO3_RATE(i);
> +                       else
> +                               break;
> +               }
> +
> +               if (cfg == 0xff) {
> +                       dev_err(axp20x->dev, "unsupported ramp value %d", ramp);
> +                       return -EINVAL;
> +               }
> +
> +               cfg |= enable;
> +       }
> +
> +       return regmap_update_bits(axp20x->regmap, reg, mask, cfg);
> +}
> +



-- 
Julian Calaby

Email: julian.calaby@gmail.com
Profile: http://www.google.com/profiles/julian.calaby/

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [linux-sunxi] [PATCH 2/8] regulator: axp20x: add support for set_ramp_delay for AXP209
  2018-12-11 13:14   ` [linux-sunxi] " Julian Calaby
@ 2018-12-12 11:02     ` Priit Laes
  0 siblings, 0 replies; 16+ messages in thread
From: Priit Laes @ 2018-12-12 11:02 UTC (permalink / raw)
  To: Julian Calaby
  Cc: Olliver Schinagl, Lee Jones, Rob Herring, Mark Rutland,
	Chen-Yu Tsai, Maxime Ripard, Liam Girdwood, Mark Brown,
	devicetree, linux-kernel, Mailing List, Arm, linux-sunxi

On Wed, Dec 12, 2018 at 12:14:57AM +1100, Julian Calaby wrote:
> Hi Priit and Olliver,
> 
> On Tue, Dec 11, 2018 at 5:42 AM Priit Laes <plaes@plaes.org> wrote:
> >
> > From: Olliver Schinagl <oliver@schinagl.nl>
> >
> > The AXP209 supports ramping up voltages on several regulators such as
> > DCDC2 and LDO3.
> >
> > This patch adds preliminary support for the regulator-ramp-delay property
> > for these 2 regulators. Note that the voltage ramp only works when
> > regulator is already enabled. E.g. when going from say 0.7 V to 3.6 V.
> >
> > When turning on the regulator, no voltage ramp is performed in hardware.
> >
> > What this means, is that if the bootloader brings up the voltage at 0.7 V,
> > the ramp delay property is properly applied. If however, the bootloader
> > leaves the power off, no ramp delay is applied when the power is
> > enabled by the regulator framework.
> >
> > Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
> > Signed-off-by: Priit Laes <plaes@plaes.org>
> > ---
> >  drivers/regulator/axp20x-regulator.c | 85 +++++++++++++++++++++++++++++-
> >  1 file changed, 85 insertions(+)
> >
> > diff --git a/drivers/regulator/axp20x-regulator.c b/drivers/regulator/axp20x-regulator.c
> > index 9a2db28..1d9fa62 100644
> > --- a/drivers/regulator/axp20x-regulator.c
> > +++ b/drivers/regulator/axp20x-regulator.c
> > @@ -346,6 +357,79 @@
> >                 .ops            = &axp20x_ops_range,                            \
> >         }
> >
> > +static const int axp209_dcdc2_ldo3_slew_rates[] = {
> > +       1600,
> > +        800,
> > +};
> > +
> > +static int axp20x_set_ramp_delay(struct regulator_dev *rdev, int ramp)
> > +{
> > +       struct axp20x_dev *axp20x = rdev_get_drvdata(rdev);
> > +       const struct regulator_desc *desc = rdev->desc;
> > +       u8 reg, mask, enable, cfg = 0xff;
> > +       const int *slew_rates;
> > +       int rate_count = 0;
> > +
> > +       if (!rdev)
> > +               return -EINVAL;
> > +
> > +       switch (axp20x->variant) {
> > +       case AXP209_ID:
> > +               if (desc->id == AXP20X_DCDC2) {
> 
> Is slew_rates supposed to be set here?

Yes, nice catch.
> 
> > +                       rate_count = ARRAY_SIZE(axp209_dcdc2_ldo3_slew_rates);
> > +                       reg = AXP20X_DCDC2_LDO3_V_RAMP;
> > +                       mask = AXP20X_DCDC2_LDO3_V_RAMP_DCDC2_RATE_MASK |
> > +                              AXP20X_DCDC2_LDO3_V_RAMP_DCDC2_EN_MASK;
> > +                       enable = (ramp > 0) ?
> > +                                AXP20X_DCDC2_LDO3_V_RAMP_DCDC2_EN :
> > +                                !AXP20X_DCDC2_LDO3_V_RAMP_DCDC2_EN;
> > +                       break;
> > +               }
> > +
> > +               if (desc->id == AXP20X_LDO3) {
> > +                       slew_rates = axp209_dcdc2_ldo3_slew_rates;
> > +                       rate_count = ARRAY_SIZE(axp209_dcdc2_ldo3_slew_rates);
> > +                       reg = AXP20X_DCDC2_LDO3_V_RAMP;
> > +                       mask = AXP20X_DCDC2_LDO3_V_RAMP_LDO3_RATE_MASK |
> > +                              AXP20X_DCDC2_LDO3_V_RAMP_LDO3_EN_MASK;
> > +                       enable = (ramp > 0) ?
> > +                                AXP20X_DCDC2_LDO3_V_RAMP_LDO3_EN :
> > +                                !AXP20X_DCDC2_LDO3_V_RAMP_LDO3_EN;
> > +                       break;
> > +               }
> > +
> > +               if (rate_count > 0)
> > +                       break;
> 
> You could save one to two tests by combining the above three if statements, i.e.
> 
> if (DCDC2) {
>     // set DCDC2 stuff
> 
>     break;
> } else if (LDO3) {
>     // set LDO3 stuff
> 
>     break;
> }

OK, will look into it.
> 
> As written, the rate_count > 0 test will never be true as every block
> that sets rate_count breaks out of the switch block.

Yes, it is somewhat superfluous, as each regulator which supports ramping
should break out of the switch itself.

> You could then calculate rate_count below the switch block.
>
> > +
> > +               /* fall through */
> > +       default:
> > +               /* Not supported for this regulator */
> > +               return -ENOTSUPP;
> > +       }
> > +
> > +       if (ramp == 0) {
> > +               cfg = enable;
> > +       } else {
> > +               int i;
> > +
> > +               for (i = 0; i < rate_count; i++) {
> > +                       if (ramp <= slew_rates[i])
> > +                               cfg = AXP20X_DCDC2_LDO3_V_RAMP_LDO3_RATE(i);
> > +                       else
> > +                               break;
> > +               }
> > +
> > +               if (cfg == 0xff) {
> > +                       dev_err(axp20x->dev, "unsupported ramp value %d", ramp);
> > +                       return -EINVAL;
> > +               }
> > +
> > +               cfg |= enable;
> > +       }
> > +
> > +       return regmap_update_bits(axp20x->regmap, reg, mask, cfg);
> > +}
> > +
> 
> 
> 
> -- 
> Julian Calaby
> 
> Email: julian.calaby@gmail.com
> Profile: http://www.google.com/profiles/julian.calaby/

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 1/8] mfd: axp20x: name voltage ramping define properly
  2018-12-10 18:42 ` [PATCH 1/8] mfd: axp20x: name voltage ramping define properly Priit Laes
@ 2018-12-13 11:55   ` Mark Brown
  2018-12-13 13:28     ` Lee Jones
  0 siblings, 1 reply; 16+ messages in thread
From: Mark Brown @ 2018-12-13 11:55 UTC (permalink / raw)
  To: Priit Laes
  Cc: Lee Jones, Rob Herring, Mark Rutland, Chen-Yu Tsai,
	Maxime Ripard, Liam Girdwood, devicetree, linux-kernel,
	linux-arm-kernel, Olliver Schinagl, linux-sunxi

[-- Attachment #1: Type: text/plain, Size: 342 bytes --]

On Mon, Dec 10, 2018 at 08:42:12PM +0200, Priit Laes wrote:

> Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
> Signed-off-by: Priit Laes <plaes@plaes.org>
> Acked-for-MFD-by: Lee Jones <lee.jones@linaro.org>

What's going on with this patch?  Will you be applying it or is this an
ack for it to be applied with the rest of the series?

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 1/8] mfd: axp20x: name voltage ramping define properly
  2018-12-13 11:55   ` Mark Brown
@ 2018-12-13 13:28     ` Lee Jones
  2018-12-13 14:46       ` Mark Brown
  0 siblings, 1 reply; 16+ messages in thread
From: Lee Jones @ 2018-12-13 13:28 UTC (permalink / raw)
  To: Mark Brown
  Cc: Priit Laes, Rob Herring, Mark Rutland, Chen-Yu Tsai,
	Maxime Ripard, Liam Girdwood, devicetree, linux-kernel,
	linux-arm-kernel, Olliver Schinagl, linux-sunxi

On Thu, 13 Dec 2018, Mark Brown wrote:

> On Mon, Dec 10, 2018 at 08:42:12PM +0200, Priit Laes wrote:
> 
> > Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
> > Signed-off-by: Priit Laes <plaes@plaes.org>
> > Acked-for-MFD-by: Lee Jones <lee.jones@linaro.org>
> 
> What's going on with this patch?  Will you be applying it or is this an
> ack for it to be applied with the rest of the series?

I don't have anything else queued for include/linux/mfd/axp20x.h, so
you can take it if you want.  Just make sure you 's/-for-MFD//'. 

-- 
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 1/8] mfd: axp20x: name voltage ramping define properly
  2018-12-13 13:28     ` Lee Jones
@ 2018-12-13 14:46       ` Mark Brown
  0 siblings, 0 replies; 16+ messages in thread
From: Mark Brown @ 2018-12-13 14:46 UTC (permalink / raw)
  To: Lee Jones
  Cc: Priit Laes, Rob Herring, Mark Rutland, Chen-Yu Tsai,
	Maxime Ripard, Liam Girdwood, devicetree, linux-kernel,
	linux-arm-kernel, Olliver Schinagl, linux-sunxi

[-- Attachment #1: Type: text/plain, Size: 401 bytes --]

On Thu, Dec 13, 2018 at 01:28:02PM +0000, Lee Jones wrote:
> On Thu, 13 Dec 2018, Mark Brown wrote:

> > What's going on with this patch?  Will you be applying it or is this an
> > ack for it to be applied with the rest of the series?

> I don't have anything else queued for include/linux/mfd/axp20x.h, so
> you can take it if you want.  Just make sure you 's/-for-MFD//'. 

Great, thanks!

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2018-12-13 14:47 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-10 18:42 [PATCH 0/8] This is a second edition of a series that implements voltage Priit Laes
2018-12-10 18:42 ` [PATCH 1/8] mfd: axp20x: name voltage ramping define properly Priit Laes
2018-12-13 11:55   ` Mark Brown
2018-12-13 13:28     ` Lee Jones
2018-12-13 14:46       ` Mark Brown
2018-12-10 18:42 ` [PATCH 2/8] regulator: axp20x: add support for set_ramp_delay for AXP209 Priit Laes
2018-12-11 13:14   ` [linux-sunxi] " Julian Calaby
2018-12-12 11:02     ` Priit Laes
2018-12-10 18:42 ` [PATCH 3/8] dt-bindings: mfd: axp20x: add support for regulator-ramp-delay " Priit Laes
2018-12-10 18:42 ` [PATCH 4/8] regulator: axp20x: add software based soft_start for AXP209 LDO3 Priit Laes
2018-12-10 18:42 ` [PATCH 5/8] dt-bindings: mfd: axp20x: Add " Priit Laes
2018-12-10 18:42 ` [PATCH 6/8] regulator: dts: enable soft-start and ramp delay for the OLinuXino Lime2 Priit Laes
2018-12-10 18:42 ` [PATCH 7/8] mfd: axp20x: Clean up included headers Priit Laes
2018-12-10 18:42 ` [PATCH 8/8] mfd: axp20x: use explicit bit defines Priit Laes
2018-12-11  7:11 ` [linux-sunxi] [PATCH 0/8] This is a second edition of a series that implements voltage Priit Laes
2018-12-11  7:46   ` Lee Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).