From: Maxime Ripard <maxime.ripard@bootlin.com>
To: Priit Laes <plaes@plaes.org>
Cc: Lee Jones <lee.jones@linaro.org>,
Rob Herring <robh+dt@kernel.org>,
Mark Rutland <mark.rutland@arm.com>, Chen-Yu Tsai <wens@csie.org>,
Sebastian Reichel <sre@kernel.org>,
Hans de Goede <hdegoede@redhat.com>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org,
Olliver Schinagl <oliver@schinagl.nl>
Subject: Re: [PATCH 06/14] regulator: axp20x: add software based soft_start for AXP209 LDO3
Date: Tue, 27 Nov 2018 10:36:19 +0100 [thread overview]
Message-ID: <20181127093619.72ensythkx2mhdf5@flea> (raw)
In-Reply-To: <41cb1b4dac3a15595c89fa962b78d3f68f370021.1543245984.git-series.plaes@plaes.org>
[-- Attachment #1: Type: text/plain, Size: 4007 bytes --]
On Mon, Nov 26, 2018 at 05:27:47PM +0200, Priit Laes wrote:
> 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);
> +};
> +
This is some pretty generic code, and could be useful to some other
users. I guess a generic function would be better for this.
Maxime
--
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
next prev parent reply other threads:[~2018-11-27 9:36 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-26 15:27 [PATCH 00/14] regulator: axp20x: Stop AXP209 from crashing when enabling LDO3 Priit Laes
2018-11-26 15:27 ` [PATCH 01/14] regulator: axp20x: use defines for masks Priit Laes
2018-11-26 15:27 ` [PATCH 02/14] regulator: axp20x: name voltage ramping define properly Priit Laes
2018-11-28 9:26 ` Lee Jones
2018-11-26 15:27 ` [PATCH 03/14] regulator: core: enable power when setting up constraints Priit Laes
2018-11-26 15:27 ` [PATCH 04/14] regulator: axp20x: add support for set_ramp_delay for AXP209 Priit Laes
2018-11-26 15:27 ` [PATCH 05/14] dt-bindings: mfd: axp20x: add support for regulator-ramp-delay " Priit Laes
2018-11-28 9:28 ` Lee Jones
2018-11-26 15:27 ` [PATCH 06/14] regulator: axp20x: add software based soft_start for AXP209 LDO3 Priit Laes
2018-11-27 9:36 ` Maxime Ripard [this message]
2018-12-04 13:31 ` Priit Laes
2018-12-04 15:09 ` Mark Brown
2018-11-26 15:27 ` [PATCH 07/14] dt-bindings: mfd: axp20x: Add " Priit Laes
2018-11-26 16:58 ` Mark Brown
2018-11-28 9:31 ` Lee Jones
2018-11-26 15:27 ` [PATCH 08/14] regulator: dts: enable soft-start and ramp delay for the OLinuXino Lime2 Priit Laes
2018-11-26 15:27 ` [PATCH 09/14] regulator: dts: add full voltage range to LDO4 on the Lime2 Priit Laes
2018-11-26 16:57 ` Mark Brown
2018-11-27 9:38 ` Maxime Ripard
2018-11-28 9:56 ` Maxime Ripard
2018-12-04 14:47 ` Priit Laes
2018-11-26 15:27 ` [PATCH 10/14] regulator: dts: set proper lradc vref on OLinuXino Lime2 Priit Laes
2018-11-27 9:37 ` Maxime Ripard
2018-11-27 9:41 ` Chen-Yu Tsai
2018-11-27 9:47 ` Maxime Ripard
2018-11-26 15:27 ` [PATCH 11/14] mfd: axp20x: Clean up included headers Priit Laes
2018-11-28 9:33 ` Lee Jones
2018-11-26 15:27 ` [PATCH 12/14] mfd: axp20x: use explicit bit defines Priit Laes
2018-11-28 9:33 ` Lee Jones
2018-11-26 15:27 ` [PATCH 13/14] power: supply: axp20x: add missing include bitops.h Priit Laes
2018-12-05 17:43 ` Sebastian Reichel
2018-11-26 15:27 ` [PATCH 14/14] power: supply: axp288: use the BIT() macro Priit Laes
2018-12-05 17:43 ` Sebastian Reichel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181127093619.72ensythkx2mhdf5@flea \
--to=maxime.ripard@bootlin.com \
--cc=broonie@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=hdegoede@redhat.com \
--cc=lee.jones@linaro.org \
--cc=lgirdwood@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=oliver@schinagl.nl \
--cc=plaes@plaes.org \
--cc=robh+dt@kernel.org \
--cc=sre@kernel.org \
--cc=wens@csie.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).