* Applied "regulator: axp20x: add support for set_ramp_delay for AXP209" to the regulator tree
@ 2018-12-13 18:11 Mark Brown
2018-12-14 8:08 ` Priit Laes
0 siblings, 1 reply; 3+ messages in thread
From: Mark Brown @ 2018-12-13 18:11 UTC (permalink / raw)
To: Olliver Schinagl; +Cc: Priit Laes, Mark Brown, linux-kernel
The patch
regulator: axp20x: add support for set_ramp_delay for AXP209
has been applied to the regulator tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
From d29f54df8b167be6174881f265b12453a558e48a Mon Sep 17 00:00:00 2001
From: Olliver Schinagl <oliver@schinagl.nl>
Date: Tue, 11 Dec 2018 17:17:06 +0200
Subject: [PATCH] regulator: axp20x: add support for set_ramp_delay for AXP209
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>
Signed-off-by: Mark Brown <broonie@kernel.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 9a2db28effb5..1d9fa6238aec 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 = {
--
2.19.0.rc2
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Applied "regulator: axp20x: add support for set_ramp_delay for AXP209" to the regulator tree
2018-12-13 18:11 Applied "regulator: axp20x: add support for set_ramp_delay for AXP209" to the regulator tree Mark Brown
@ 2018-12-14 8:08 ` Priit Laes
2018-12-14 11:33 ` Mark Brown
0 siblings, 1 reply; 3+ messages in thread
From: Priit Laes @ 2018-12-14 8:08 UTC (permalink / raw)
To: Mark Brown; +Cc: Olliver Schinagl, linux-kernel
On Thu, Dec 13, 2018 at 06:11:42PM +0000, Mark Brown wrote:
> The patch
>
Heya, Mark!
Unfortunately, one error crept in, please see below:
[...]
>
> From d29f54df8b167be6174881f265b12453a558e48a Mon Sep 17 00:00:00 2001
> From: Olliver Schinagl <oliver@schinagl.nl>
> Date: Tue, 11 Dec 2018 17:17:06 +0200
> Subject: [PATCH] regulator: axp20x: add support for set_ramp_delay for AXP209
>
> 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>
> Signed-off-by: Mark Brown <broonie@kernel.org>
> ---
> drivers/regulator/axp20x-regulator.c | 85 ++++++++++++++++++++++++++++
> 1 file changed, 85 insertions(+)
>
[...]
>
> +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) {
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_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 = {
> --
> 2.19.0.rc2
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Applied "regulator: axp20x: add support for set_ramp_delay for AXP209" to the regulator tree
2018-12-14 8:08 ` Priit Laes
@ 2018-12-14 11:33 ` Mark Brown
0 siblings, 0 replies; 3+ messages in thread
From: Mark Brown @ 2018-12-14 11:33 UTC (permalink / raw)
To: Priit Laes; +Cc: Olliver Schinagl, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 184 bytes --]
On Fri, Dec 14, 2018 at 08:08:20AM +0000, Priit Laes wrote:
> Unfortunately, one error crept in, please see below:
Please send an incremental patch with any fixes that are required.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-12-14 11:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-13 18:11 Applied "regulator: axp20x: add support for set_ramp_delay for AXP209" to the regulator tree Mark Brown
2018-12-14 8:08 ` Priit Laes
2018-12-14 11:33 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®