2024-01-13 22:47:13

by Martin Blumenstingl

[permalink] [raw]
Subject: [RFC PATCH v2 0/3] regulator: pwm-regulator: Fixes for disabled PWMs at boot

This is the second version of an attempt to fix booting mainline Linux
on Meson8b Odroid-C1.
This series is an update to an RFC patch that I sent some time ago [0]
and incorporates a lot of the feedback from that v1.

The main changes since v1 [0] are:
- new patch checking the voltage limits in pwm_regulator_get_voltage()
- updated calculation for disabled regulators in+
pwm_regulator_get_voltage() utilizing above limit checking
- new pwm_regulator_init_boot_on() to preserve the output voltage when
pwm_regulator_enable() later enables the PWM output without and
preceding pwm_regulator_set_voltage().


[0] https://lore.kernel.org/linux-pwm/[email protected]/


Martin Blumenstingl (3):
regulator: pwm-regulator: Add validity checks in continuous
.get_voltage
regulator: pwm-regulator: Calculate the output voltage for disabled
PWMs
regulator: pwm-regulator: Manage boot-on with disabled PWM channels

drivers/regulator/pwm-regulator.c | 43 +++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)

--
2.43.0



2024-01-13 22:47:31

by Martin Blumenstingl

[permalink] [raw]
Subject: [RFC PATCH v2 2/3] regulator: pwm-regulator: Calculate the output voltage for disabled PWMs

If a PWM output is disabled then it's voltage has to be calculated
based on a zero duty cycle (for normal polarity) or duty cycle being
equal to the PWM period (for inverted polarity). Add support for this
to pwm_regulator_get_voltage().

Signed-off-by: Martin Blumenstingl <[email protected]>
---
Changes from v1 -> v2:
- update pstate.duty_cycle to catch out-of-range values with the new
check from the first patch in this series


drivers/regulator/pwm-regulator.c | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/drivers/regulator/pwm-regulator.c b/drivers/regulator/pwm-regulator.c
index 226ca4c62673..d27b9a7a30c9 100644
--- a/drivers/regulator/pwm-regulator.c
+++ b/drivers/regulator/pwm-regulator.c
@@ -157,6 +157,13 @@ static int pwm_regulator_get_voltage(struct regulator_dev *rdev)

pwm_get_state(drvdata->pwm, &pstate);

+ if (!pstate.enabled) {
+ if (pstate.polarity == PWM_POLARITY_INVERSED)
+ pstate.duty_cycle = pstate.period;
+ else
+ pstate.duty_cycle = 0;
+ }
+
voltage = pwm_get_relative_duty_cycle(&pstate, duty_unit);
if (voltage < min(max_uV_duty, min_uV_duty) ||
voltage > max(max_uV_duty, min_uV_duty))
--
2.43.0


2024-01-22 20:50:18

by Mark Brown

[permalink] [raw]
Subject: Re: [RFC PATCH v2 0/3] regulator: pwm-regulator: Fixes for disabled PWMs at boot

On Sat, 13 Jan 2024 23:46:25 +0100, Martin Blumenstingl wrote:
> This is the second version of an attempt to fix booting mainline Linux
> on Meson8b Odroid-C1.
> This series is an update to an RFC patch that I sent some time ago [0]
> and incorporates a lot of the feedback from that v1.
>
> The main changes since v1 [0] are:
> - new patch checking the voltage limits in pwm_regulator_get_voltage()
> - updated calculation for disabled regulators in+
> pwm_regulator_get_voltage() utilizing above limit checking
> - new pwm_regulator_init_boot_on() to preserve the output voltage when
> pwm_regulator_enable() later enables the PWM output without and
> preceding pwm_regulator_set_voltage().
>
> [...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-next

Thanks!

[1/3] regulator: pwm-regulator: Add validity checks in continuous .get_voltage
commit: c92688cac239794e4a1d976afa5203a4d3a2ac0e
[2/3] regulator: pwm-regulator: Calculate the output voltage for disabled PWMs
commit: 6a7d11efd6915d80a025f2a0be4ae09d797b91ec
[3/3] regulator: pwm-regulator: Manage boot-on with disabled PWM channels
commit: b3cbdcc191819b75c04178142e2d0d4c668f68c0

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