mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Paul Louvel <paul.louvel@bootlin.com>
To: Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>,  Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	 Conor Dooley <conor+dt@kernel.org>
Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
	 Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
	 Herve Codina <herve.codina@bootlin.com>,
	 Miquel Raynal <miquel.raynal@bootlin.com>,
	 Paul Louvel <paul.louvel@bootlin.com>
Subject: [PATCH v2 3/4] regulator: core: Call set_over_voltage_protection() if OVP limit is fixed after setting new voltage
Date: Tue, 27 Oct 2026 10:39:25 +0100	[thread overview]
Message-ID: <20261027-paul-lm51772-v2-3-b2a767e34722@bootlin.com> (raw)
In-Reply-To: <20261027-paul-lm51772-v2-0-b2a767e34722@bootlin.com>

The over-voltage protection limit is defined as a microvolt offset from
the voltage configured on the regulator, and the hardware is programmed
with this limit once, at regulator registration.

Some devices cannot be configured with an offset because their OVP
threshold is a fixed value. For such devices, the protection must be
reprogrammed every time the output voltage changes.

Introduce a new 'fixed_ovp' member in struct regulator_desc to tell the
core that the registered regulator is such a device. The
set_over_voltage_protection() callback is then called after the
slew-rate delay, so that the protection is never programmed before the
output voltage has settled.

Signed-off-by: Paul Louvel <paul.louvel@bootlin.com>
---
 drivers/regulator/core.c         | 10 ++++++++++
 include/linux/regulator/driver.h |  4 ++++
 2 files changed, 14 insertions(+)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 14422cfe80e2..b1cabe50ac25 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -4014,6 +4014,16 @@ static int _regulator_do_set_voltage(struct regulator_dev *rdev,
 				     (void *)data);
 	}
 
+	if (old_uV != best_val) {
+		if (rdev->desc->fixed_ovp && ops->set_over_voltage_protection) {
+			ret = handle_notify_limits(
+				rdev, ops->set_over_voltage_protection,
+				&rdev->constraints->over_voltage_limits);
+			if (ret == -EOPNOTSUPP)
+				ret = 0;
+		}
+	}
+
 out:
 	trace_regulator_set_voltage_complete(rdev_get_name(rdev), best_val);
 
diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h
index 8a0f3aebdade..248fd8565abc 100644
--- a/include/linux/regulator/driver.h
+++ b/include/linux/regulator/driver.h
@@ -311,6 +311,9 @@ enum regulator_type {
  * @vsel_range_mask: Mask for register bitfield used for range selector
  * @range_applied_by_vsel: A flag to indicate that changes to vsel_range_reg
  *			   are only effective after vsel_reg is written
+ * @fixed_ovp: A flag to indicate that over voltage protection is set with
+ *		           hardcoded value, and need to be set each time
+ *		           when a new voltage is set.
  * @vsel_reg: Register for selector when using ``regulator_map_*_voltage_*``
  * @vsel_reg_oversize: Indicates that the vsel_reg spans on two registers
  * @vsel_mask: Mask for register bitfield used for selector
@@ -405,6 +408,7 @@ struct regulator_desc {
 	unsigned int vsel_range_reg;
 	unsigned int vsel_range_mask;
 	bool range_applied_by_vsel;
+	bool fixed_ovp;
 	unsigned int vsel_reg;
 	bool vsel_reg_oversize;
 	unsigned int vsel_mask;

-- 
2.56.0


  parent reply	other threads:[~2026-10-27  9:40 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-27  9:39 [PATCH v2 0/4] Add TI LM51772 buck-boost voltage regulator Paul Louvel
2026-10-27  9:39 ` [PATCH v2 1/4] regulator: dt-bindings: Add TI LM51772 support Paul Louvel
2026-10-29  8:41   ` Krzysztof Kozlowski
2026-10-29  9:05     ` Paul Louvel
2026-10-29 12:42       ` Krzysztof Kozlowski
2026-10-29 14:13         ` Paul Louvel
2026-10-29 14:17         ` Mark Brown
2026-10-27  9:39 ` [PATCH v2 2/4] regulator: Support regulators where the voltage selector spans two registers Paul Louvel
2026-10-27  9:39 ` Paul Louvel [this message]
2026-10-27  9:39 ` [PATCH v2 4/4] regulator: Add TI LM51772 support Paul Louvel

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=20261027-paul-lm51772-v2-3-b2a767e34722@bootlin.com \
    --to=paul.louvel@bootlin.com \
    --cc=broonie@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=herve.codina@bootlin.com \
    --cc=krzk+dt@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miquel.raynal@bootlin.com \
    --cc=robh@kernel.org \
    --cc=thomas.petazzoni@bootlin.com \
    /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

all inboxes | Powered by JetHome®