[PATCH v2025.09.y 49/58] regulator: fixed: handle startup-delay-us property

Ahmad Fatoum a.fatoum at pengutronix.de
Fri Mar 13 06:25:33 PDT 2026


From: Sascha Hauer <s.hauer at pengutronix.de>

The "startup-delay-us" property of the fixed regulator has never been
handled by barebox. Handle it now.

The "startup-delay-us" property is specified as:

| startup time in microseconds

Then there's a regulator generic property "regulator-enable-ramp-delay"
which barebox handles, specified as:

| The time taken, in microseconds, for the supply rail to
| reach the target voltage, plus/minus whatever tolerance the board
| design requires. This property describes the total system ramp time
| required due to the combination of internal ramping of the regulator
| itself, and board design issues such as trace capacitance and load
| on the supply.

We just use the bigger of the two times as the time a regulator needs
to become stable.

(cherry picked from commit 531cdd2463c3038c59c18087d4ddee9e1f4feaf9)

Reviewed-by: Marco Felsch <m.felsch at pengutronix.de>
Link: https://lore.barebox.org/20260129-regulator-ramp-v1-2-6269bd55d432@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 drivers/regulator/core.c  | 10 ++++++++--
 drivers/regulator/fixed.c |  3 +++
 include/regulator.h       |  2 ++
 3 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 6e18bc8a2d32..ec2ca4b19e62 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -297,6 +297,7 @@ int of_regulator_register(struct regulator_dev *rdev, struct device_node *node)
 {
 	const char *name;
 	int ret;
+	u32 val = 0;
 
 	if (!rdev || !node)
 		return -EINVAL;
@@ -313,12 +314,17 @@ int of_regulator_register(struct regulator_dev *rdev, struct device_node *node)
 
 	if (rdev->desc->off_on_delay)
 		rdev->off_on_delay = rdev->desc->off_on_delay;
+	if (rdev->desc->enable_time_us)
+		rdev->enable_time_us = rdev->desc->enable_time_us;
 
 	if (rdev->desc->fixed_uV && rdev->desc->n_voltages == 1)
 		rdev->min_uv = rdev->max_uv = rdev->desc->fixed_uV;
 
-	of_property_read_u32(node, "regulator-enable-ramp-delay",
-			&rdev->enable_time_us);
+	/* might be set by the regulator implementation already. Use the bigger value */
+	of_property_read_u32(node, "regulator-enable-ramp-delay", &val);
+	if (val > rdev->enable_time_us)
+		rdev->enable_time_us = val;
+
 	of_property_read_u32(node, "regulator-min-microvolt",
 			&rdev->min_uv);
 	of_property_read_u32(node, "regulator-max-microvolt",
diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c
index 0edb5ceb104b..e00519c2fed5 100644
--- a/drivers/regulator/fixed.c
+++ b/drivers/regulator/fixed.c
@@ -61,6 +61,9 @@ static int regulator_fixed_probe(struct device *dev)
 	if (!of_property_read_u32(np, "off-on-delay-us", &delay))
 		fix->rdesc.off_on_delay = delay;
 
+	if (!of_property_read_u32(np, "startup-delay-us", &delay))
+		fix->rdesc.enable_time_us = delay;
+
 	if (of_find_property(np, "vin-supply", NULL))
 		fix->rdesc.supply_name = "vin";
 
diff --git a/include/regulator.h b/include/regulator.h
index 0b46714fcfa2..61920763d58f 100644
--- a/include/regulator.h
+++ b/include/regulator.h
@@ -64,6 +64,7 @@ struct regulator_bulk_data {
  * @volt_table: Voltage mapping table (if table based mapping)
  * @fixed_uV: Fixed voltage of rails.
  * @off_on_delay: guard time (in uS), before re-enabling a regulator
+ * @enable_time_us: Time taken for initial enable of regulator (in uS).
  */
 
 struct regulator_desc {
@@ -94,6 +95,7 @@ struct regulator_desc {
 	const unsigned int *volt_table;
 	int fixed_uV;
 	unsigned int off_on_delay;
+	unsigned int enable_time_us;
 };
 
 /**
-- 
2.47.3




More information about the barebox mailing list