¿ªÔÆÌåÓý

ctrl + shift + ? for shortcuts
© 2025 Groups.io

[PATCH v3 2/4] power: regulator: Convert regulators_enable_boot_on/off() to regulator_post_probe


Marek Vasut
 

Turn regulators_enable_boot_on() and regulators_enable_boot_off() into
empty functions. Implement matching functionality in regulator_post_probe=
()
instead. The regulator_post_probe() is called for all regulators after th=
ey
probe, and regulators that have regulator-always-on or regulator-boot-on =
DT
properties now always probe due to DM_FLAG_PROBE_AFTER_BIND being set on
such regulators in regulator_post_bind().

Finally, fold regulator_unset() functionality into regulator_autoset().

Signed-off-by: Marek Vasut <marex@...>
---
Cc: Ben Wolsieffer <benwolsieffer@...>
Cc: Caleb Connolly <caleb.connolly@...>
Cc: Chris Morgan <macromorgan@...>
Cc: Dragan Simic <dsimic@...>
Cc: Eugen Hristev <eugen.hristev@...>
Cc: Francesco Dolcini <francesco.dolcini@...>
Cc: Heinrich Schuchardt <xypron.glpk@...>
Cc: Jaehoon Chung <jh80.chung@...>
Cc: Jagan Teki <jagan@...>
Cc: Jonas Karlman <jonas@...>
Cc: Kever Yang <kever.yang@...>
Cc: Matteo Lisi <matteo.lisi@...>
Cc: Mattijs Korpershoek <mkorpershoek@...>
Cc: Max Krummenacher <max.krummenacher@...>
Cc: Neil Armstrong <neil.armstrong@...>
Cc: Patrice Chotard <patrice.chotard@...>
Cc: Patrick Delaunay <patrick.delaunay@...>
Cc: Philipp Tomsich <philipp.tomsich@...>
Cc: Quentin Schulz <quentin.schulz@...>
Cc: Sam Day <me@...>
Cc: Simon Glass <sjg@...>
Cc: Sumit Garg <sumit.garg@...>
Cc: Svyatoslav Ryhel <clamor95@...>
Cc: Thierry Reding <treding@...>
Cc: Tom Rini <trini@...>
Cc: Volodymyr Babchuk <Volodymyr_Babchuk@...>
Cc: [email protected]
Cc: [email protected]
Cc: u-boot@...
Cc: u-boot@...
Cc: uboot-stm32@...
---
V2: Rebase on current u-boot/next
V3: No change
---
drivers/power/regulator/regulator-uclass.c | 60 +++++++---------------
1 file changed, 19 insertions(+), 41 deletions(-)

diff --git a/drivers/power/regulator/regulator-uclass.c b/drivers/power/r=
egulator/regulator-uclass.c
index 1a970004540..9fcc4bd85b9 100644
--- a/drivers/power/regulator/regulator-uclass.c
+++ b/drivers/power/regulator/regulator-uclass.c
@@ -314,6 +314,11 @@ int regulator_autoset(struct udevice *dev)
return ret;
}
=20
+ if (uc_pdata->force_off) {
+ ret =3D regulator_set_enable(dev, false);
+ goto out;
+ }
+
if (!uc_pdata->always_on && !uc_pdata->boot_on) {
ret =3D -EMEDIUMTYPE;
goto out;
@@ -518,56 +523,28 @@ static int regulator_pre_probe(struct udevice *dev)
return 0;
}
=20
-int regulators_enable_boot_on(bool verbose)
+static int regulator_post_probe(struct udevice *dev)
{
- struct udevice *dev;
- struct uclass *uc;
int ret;
=20
- ret =3D uclass_get(UCLASS_REGULATOR, &uc);
- if (ret)
+ ret =3D regulator_autoset(dev);
+ if (ret && ret !=3D -EMEDIUMTYPE && ret !=3D -EALREADY && ret !=3D ENOS=
YS)
return ret;
- for (uclass_first_device(UCLASS_REGULATOR, &dev);
- dev;
- uclass_next_device(&dev)) {
- ret =3D regulator_autoset(dev);
- if (ret =3D=3D -EMEDIUMTYPE || ret =3D=3D -EALREADY) {
- ret =3D 0;
- continue;
- }
- if (verbose)
- regulator_show(dev, ret);
- if (ret =3D=3D -ENOSYS)
- ret =3D 0;
- }
=20
- return ret;
+ if (_DEBUG)
+ regulator_show(dev, ret);
+
+ return 0;
}
=20
-int regulators_enable_boot_off(bool verbose)
+int regulators_enable_boot_on(bool verbose)
{
- struct udevice *dev;
- struct uclass *uc;
- int ret;
-
- ret =3D uclass_get(UCLASS_REGULATOR, &uc);
- if (ret)
- return ret;
- for (uclass_first_device(UCLASS_REGULATOR, &dev);
- dev;
- uclass_next_device(&dev)) {
- ret =3D regulator_unset(dev);
- if (ret =3D=3D -EMEDIUMTYPE) {
- ret =3D 0;
- continue;
- }
- if (verbose)
- regulator_show(dev, ret);
- if (ret =3D=3D -ENOSYS)
- ret =3D 0;
- }
+ return 0;
+}
=20
- return ret;
+int regulators_enable_boot_off(bool verbose)
+{
+ return 0;
}
=20
UCLASS_DRIVER(regulator) =3D {
@@ -575,5 +552,6 @@ UCLASS_DRIVER(regulator) =3D {
.name =3D "regulator",
.post_bind =3D regulator_post_bind,
.pre_probe =3D regulator_pre_probe,
+ .post_probe =3D regulator_post_probe,
.per_device_plat_auto =3D sizeof(struct dm_regulator_uclass_plat),
};
--=20
2.45.2


Simon Glass
 

Hi Tom,

On Wed, 2 Oct 2024 at 19:40, Tom Rini <trini@...> wrote:

On Wed, Oct 02, 2024 at 04:55:39PM -0600, Simon Glass wrote:
Hi,

On Thu, 26 Sept 2024 at 17:15, Marek Vasut <marex@...> wrote:

Turn regulators_enable_boot_on() and regulators_enable_boot_off() into
empty functions. Implement matching functionality in regulator_post_probe()
instead. The regulator_post_probe() is called for all regulators after they
probe, and regulators that have regulator-always-on or regulator-boot-on DT
properties now always probe due to DM_FLAG_PROBE_AFTER_BIND being set on
such regulators in regulator_post_bind().

Finally, fold regulator_unset() functionality into regulator_autoset().

Signed-off-by: Marek Vasut <marex@...>
---
Cc: Ben Wolsieffer <benwolsieffer@...>
Cc: Caleb Connolly <caleb.connolly@...>
Cc: Chris Morgan <macromorgan@...>
Cc: Dragan Simic <dsimic@...>
Cc: Eugen Hristev <eugen.hristev@...>
Cc: Francesco Dolcini <francesco.dolcini@...>
Cc: Heinrich Schuchardt <xypron.glpk@...>
Cc: Jaehoon Chung <jh80.chung@...>
Cc: Jagan Teki <jagan@...>
Cc: Jonas Karlman <jonas@...>
Cc: Kever Yang <kever.yang@...>
Cc: Matteo Lisi <matteo.lisi@...>
Cc: Mattijs Korpershoek <mkorpershoek@...>
Cc: Max Krummenacher <max.krummenacher@...>
Cc: Neil Armstrong <neil.armstrong@...>
Cc: Patrice Chotard <patrice.chotard@...>
Cc: Patrick Delaunay <patrick.delaunay@...>
Cc: Philipp Tomsich <philipp.tomsich@...>
Cc: Quentin Schulz <quentin.schulz@...>
Cc: Sam Day <me@...>
Cc: Simon Glass <sjg@...>
Cc: Sumit Garg <sumit.garg@...>
Cc: Svyatoslav Ryhel <clamor95@...>
Cc: Thierry Reding <treding@...>
Cc: Tom Rini <trini@...>
Cc: Volodymyr Babchuk <Volodymyr_Babchuk@...>
Cc: [email protected]
Cc: [email protected]
Cc: u-boot@...
Cc: u-boot@...
Cc: uboot-stm32@...
---
V2: Rebase on current u-boot/next
V3: No change
---
drivers/power/regulator/regulator-uclass.c | 60 +++++++---------------
1 file changed, 19 insertions(+), 41 deletions(-)

diff --git a/drivers/power/regulator/regulator-uclass.c b/drivers/power/regulator/regulator-uclass.c
index 1a970004540..9fcc4bd85b9 100644
--- a/drivers/power/regulator/regulator-uclass.c
+++ b/drivers/power/regulator/regulator-uclass.c
@@ -314,6 +314,11 @@ int regulator_autoset(struct udevice *dev)
return ret;
}

+ if (uc_pdata->force_off) {
+ ret = regulator_set_enable(dev, false);
+ goto out;
+ }
+
if (!uc_pdata->always_on && !uc_pdata->boot_on) {
ret = -EMEDIUMTYPE;
goto out;
@@ -518,56 +523,28 @@ static int regulator_pre_probe(struct udevice *dev)
return 0;
}

-int regulators_enable_boot_on(bool verbose)
+static int regulator_post_probe(struct udevice *dev)
{
- struct udevice *dev;
- struct uclass *uc;
int ret;

- ret = uclass_get(UCLASS_REGULATOR, &uc);
- if (ret)
+ ret = regulator_autoset(dev);
+ if (ret && ret != -EMEDIUMTYPE && ret != -EALREADY && ret != ENOSYS)
return ret;
- for (uclass_first_device(UCLASS_REGULATOR, &dev);
- dev;
- uclass_next_device(&dev)) {
- ret = regulator_autoset(dev);
- if (ret == -EMEDIUMTYPE || ret == -EALREADY) {
- ret = 0;
- continue;
- }
- if (verbose)
- regulator_show(dev, ret);
- if (ret == -ENOSYS)
- ret = 0;
- }

- return ret;
+ if (_DEBUG)
+ regulator_show(dev, ret);
+
+ return 0;
}

-int regulators_enable_boot_off(bool verbose)
+int regulators_enable_boot_on(bool verbose)
{
- struct udevice *dev;
- struct uclass *uc;
- int ret;
-
- ret = uclass_get(UCLASS_REGULATOR, &uc);
- if (ret)
- return ret;
- for (uclass_first_device(UCLASS_REGULATOR, &dev);
- dev;
- uclass_next_device(&dev)) {
- ret = regulator_unset(dev);
- if (ret == -EMEDIUMTYPE) {
- ret = 0;
- continue;
- }
- if (verbose)
- regulator_show(dev, ret);
- if (ret == -ENOSYS)
- ret = 0;
- }
+ return 0;
+}

- return ret;
+int regulators_enable_boot_off(bool verbose)
+{
+ return 0;
}

UCLASS_DRIVER(regulator) = {
@@ -575,5 +552,6 @@ UCLASS_DRIVER(regulator) = {
.name = "regulator",
.post_bind = regulator_post_bind,
.pre_probe = regulator_pre_probe,
+ .post_probe = regulator_post_probe,
.per_device_plat_auto = sizeof(struct dm_regulator_uclass_plat),
};
--
2.45.2
I thought I objected to this patch, but it seems to be in -next? Does
anyone know what has happened here?
Yes, you missed me noting that this fixes real problems and has been
needing to be fixed for a while. I said you should provide your
alternative approach and we'll get this sorted out in -next and I took
the work-around for master so the release wouldn't be broken.
OK ta. So long as we can revert/change that is fine.


I am seeing these errors now when running sandbox 'u-boot -D':

i2c_emul_find() No emulators for device 'sandbox_pmic'
sandbox_pmic_write() write error to device: 0000000018c49db0 register: 0x0!
out_set_value() PMIC write failed: -5
i2c_emul_find() No emulators for device 'sandbox_pmic'
sandbox_pmic_write() write error to device: 0000000018c49db0 register: 0x0!
out_set_value() PMIC write failed: -5
I suppose the good news is that perhaps this is also related to the
problem that Svyatoslav was reporting.
OK, I actually never fully understood the problem, but yes, sandbox is
supposed to work similarly.

Regards,
Simon


Marek Vasut
 

On 10/3/24 12:55 AM, Simon Glass wrote:
Hi,
On Thu, 26 Sept 2024 at 17:15, Marek Vasut <marex@...> wrote:

Turn regulators_enable_boot_on() and regulators_enable_boot_off() into
empty functions. Implement matching functionality in regulator_post_probe()
instead. The regulator_post_probe() is called for all regulators after they
probe, and regulators that have regulator-always-on or regulator-boot-on DT
properties now always probe due to DM_FLAG_PROBE_AFTER_BIND being set on
such regulators in regulator_post_bind().

Finally, fold regulator_unset() functionality into regulator_autoset().

Signed-off-by: Marek Vasut <marex@...>
---
Cc: Ben Wolsieffer <benwolsieffer@...>
Cc: Caleb Connolly <caleb.connolly@...>
Cc: Chris Morgan <macromorgan@...>
Cc: Dragan Simic <dsimic@...>
Cc: Eugen Hristev <eugen.hristev@...>
Cc: Francesco Dolcini <francesco.dolcini@...>
Cc: Heinrich Schuchardt <xypron.glpk@...>
Cc: Jaehoon Chung <jh80.chung@...>
Cc: Jagan Teki <jagan@...>
Cc: Jonas Karlman <jonas@...>
Cc: Kever Yang <kever.yang@...>
Cc: Matteo Lisi <matteo.lisi@...>
Cc: Mattijs Korpershoek <mkorpershoek@...>
Cc: Max Krummenacher <max.krummenacher@...>
Cc: Neil Armstrong <neil.armstrong@...>
Cc: Patrice Chotard <patrice.chotard@...>
Cc: Patrick Delaunay <patrick.delaunay@...>
Cc: Philipp Tomsich <philipp.tomsich@...>
Cc: Quentin Schulz <quentin.schulz@...>
Cc: Sam Day <me@...>
Cc: Simon Glass <sjg@...>
Cc: Sumit Garg <sumit.garg@...>
Cc: Svyatoslav Ryhel <clamor95@...>
Cc: Thierry Reding <treding@...>
Cc: Tom Rini <trini@...>
Cc: Volodymyr Babchuk <Volodymyr_Babchuk@...>
Cc: [email protected]
Cc: [email protected]
Cc: u-boot@...
Cc: u-boot@...
Cc: uboot-stm32@...
---
V2: Rebase on current u-boot/next
V3: No change
---
drivers/power/regulator/regulator-uclass.c | 60 +++++++---------------
1 file changed, 19 insertions(+), 41 deletions(-)

diff --git a/drivers/power/regulator/regulator-uclass.c b/drivers/power/regulator/regulator-uclass.c
index 1a970004540..9fcc4bd85b9 100644
--- a/drivers/power/regulator/regulator-uclass.c
+++ b/drivers/power/regulator/regulator-uclass.c
@@ -314,6 +314,11 @@ int regulator_autoset(struct udevice *dev)
return ret;
}

+ if (uc_pdata->force_off) {
+ ret = regulator_set_enable(dev, false);
+ goto out;
+ }
+
if (!uc_pdata->always_on && !uc_pdata->boot_on) {
ret = -EMEDIUMTYPE;
goto out;
@@ -518,56 +523,28 @@ static int regulator_pre_probe(struct udevice *dev)
return 0;
}

-int regulators_enable_boot_on(bool verbose)
+static int regulator_post_probe(struct udevice *dev)
{
- struct udevice *dev;
- struct uclass *uc;
int ret;

- ret = uclass_get(UCLASS_REGULATOR, &uc);
- if (ret)
+ ret = regulator_autoset(dev);
+ if (ret && ret != -EMEDIUMTYPE && ret != -EALREADY && ret != ENOSYS)
return ret;
- for (uclass_first_device(UCLASS_REGULATOR, &dev);
- dev;
- uclass_next_device(&dev)) {
- ret = regulator_autoset(dev);
- if (ret == -EMEDIUMTYPE || ret == -EALREADY) {
- ret = 0;
- continue;
- }
- if (verbose)
- regulator_show(dev, ret);
- if (ret == -ENOSYS)
- ret = 0;
- }

- return ret;
+ if (_DEBUG)
+ regulator_show(dev, ret);
+
+ return 0;
}

-int regulators_enable_boot_off(bool verbose)
+int regulators_enable_boot_on(bool verbose)
{
- struct udevice *dev;
- struct uclass *uc;
- int ret;
-
- ret = uclass_get(UCLASS_REGULATOR, &uc);
- if (ret)
- return ret;
- for (uclass_first_device(UCLASS_REGULATOR, &dev);
- dev;
- uclass_next_device(&dev)) {
- ret = regulator_unset(dev);
- if (ret == -EMEDIUMTYPE) {
- ret = 0;
- continue;
- }
- if (verbose)
- regulator_show(dev, ret);
- if (ret == -ENOSYS)
- ret = 0;
- }
+ return 0;
+}

- return ret;
+int regulators_enable_boot_off(bool verbose)
+{
+ return 0;
}

UCLASS_DRIVER(regulator) = {
@@ -575,5 +552,6 @@ UCLASS_DRIVER(regulator) = {
.name = "regulator",
.post_bind = regulator_post_bind,
.pre_probe = regulator_pre_probe,
+ .post_probe = regulator_post_probe,
.per_device_plat_auto = sizeof(struct dm_regulator_uclass_plat),
};
--
2.45.2
I thought I objected to this patch, but it seems to be in -next? Does
anyone know what has happened here?
I am seeing these errors now when running sandbox 'u-boot -D':
i2c_emul_find() No emulators for device 'sandbox_pmic'
sandbox_pmic_write() write error to device: 0000000018c49db0 register: 0x0!
out_set_value() PMIC write failed: -5
i2c_emul_find() No emulators for device 'sandbox_pmic'
sandbox_pmic_write() write error to device: 0000000018c49db0 register: 0x0!
out_set_value() PMIC write failed: -5
See Re: [PATCH] sandbox: i2c: Make sure phandle dependency is probed , let's continue it there.


Tom Rini
 

On Wed, Oct 02, 2024 at 04:55:39PM -0600, Simon Glass wrote:
Hi,

On Thu, 26 Sept 2024 at 17:15, Marek Vasut <marex@...> wrote:

Turn regulators_enable_boot_on() and regulators_enable_boot_off() into
empty functions. Implement matching functionality in regulator_post_probe()
instead. The regulator_post_probe() is called for all regulators after they
probe, and regulators that have regulator-always-on or regulator-boot-on DT
properties now always probe due to DM_FLAG_PROBE_AFTER_BIND being set on
such regulators in regulator_post_bind().

Finally, fold regulator_unset() functionality into regulator_autoset().

Signed-off-by: Marek Vasut <marex@...>
---
Cc: Ben Wolsieffer <benwolsieffer@...>
Cc: Caleb Connolly <caleb.connolly@...>
Cc: Chris Morgan <macromorgan@...>
Cc: Dragan Simic <dsimic@...>
Cc: Eugen Hristev <eugen.hristev@...>
Cc: Francesco Dolcini <francesco.dolcini@...>
Cc: Heinrich Schuchardt <xypron.glpk@...>
Cc: Jaehoon Chung <jh80.chung@...>
Cc: Jagan Teki <jagan@...>
Cc: Jonas Karlman <jonas@...>
Cc: Kever Yang <kever.yang@...>
Cc: Matteo Lisi <matteo.lisi@...>
Cc: Mattijs Korpershoek <mkorpershoek@...>
Cc: Max Krummenacher <max.krummenacher@...>
Cc: Neil Armstrong <neil.armstrong@...>
Cc: Patrice Chotard <patrice.chotard@...>
Cc: Patrick Delaunay <patrick.delaunay@...>
Cc: Philipp Tomsich <philipp.tomsich@...>
Cc: Quentin Schulz <quentin.schulz@...>
Cc: Sam Day <me@...>
Cc: Simon Glass <sjg@...>
Cc: Sumit Garg <sumit.garg@...>
Cc: Svyatoslav Ryhel <clamor95@...>
Cc: Thierry Reding <treding@...>
Cc: Tom Rini <trini@...>
Cc: Volodymyr Babchuk <Volodymyr_Babchuk@...>
Cc: [email protected]
Cc: [email protected]
Cc: u-boot@...
Cc: u-boot@...
Cc: uboot-stm32@...
---
V2: Rebase on current u-boot/next
V3: No change
---
drivers/power/regulator/regulator-uclass.c | 60 +++++++---------------
1 file changed, 19 insertions(+), 41 deletions(-)

diff --git a/drivers/power/regulator/regulator-uclass.c b/drivers/power/regulator/regulator-uclass.c
index 1a970004540..9fcc4bd85b9 100644
--- a/drivers/power/regulator/regulator-uclass.c
+++ b/drivers/power/regulator/regulator-uclass.c
@@ -314,6 +314,11 @@ int regulator_autoset(struct udevice *dev)
return ret;
}

+ if (uc_pdata->force_off) {
+ ret = regulator_set_enable(dev, false);
+ goto out;
+ }
+
if (!uc_pdata->always_on && !uc_pdata->boot_on) {
ret = -EMEDIUMTYPE;
goto out;
@@ -518,56 +523,28 @@ static int regulator_pre_probe(struct udevice *dev)
return 0;
}

-int regulators_enable_boot_on(bool verbose)
+static int regulator_post_probe(struct udevice *dev)
{
- struct udevice *dev;
- struct uclass *uc;
int ret;

- ret = uclass_get(UCLASS_REGULATOR, &uc);
- if (ret)
+ ret = regulator_autoset(dev);
+ if (ret && ret != -EMEDIUMTYPE && ret != -EALREADY && ret != ENOSYS)
return ret;
- for (uclass_first_device(UCLASS_REGULATOR, &dev);
- dev;
- uclass_next_device(&dev)) {
- ret = regulator_autoset(dev);
- if (ret == -EMEDIUMTYPE || ret == -EALREADY) {
- ret = 0;
- continue;
- }
- if (verbose)
- regulator_show(dev, ret);
- if (ret == -ENOSYS)
- ret = 0;
- }

- return ret;
+ if (_DEBUG)
+ regulator_show(dev, ret);
+
+ return 0;
}

-int regulators_enable_boot_off(bool verbose)
+int regulators_enable_boot_on(bool verbose)
{
- struct udevice *dev;
- struct uclass *uc;
- int ret;
-
- ret = uclass_get(UCLASS_REGULATOR, &uc);
- if (ret)
- return ret;
- for (uclass_first_device(UCLASS_REGULATOR, &dev);
- dev;
- uclass_next_device(&dev)) {
- ret = regulator_unset(dev);
- if (ret == -EMEDIUMTYPE) {
- ret = 0;
- continue;
- }
- if (verbose)
- regulator_show(dev, ret);
- if (ret == -ENOSYS)
- ret = 0;
- }
+ return 0;
+}

- return ret;
+int regulators_enable_boot_off(bool verbose)
+{
+ return 0;
}

UCLASS_DRIVER(regulator) = {
@@ -575,5 +552,6 @@ UCLASS_DRIVER(regulator) = {
.name = "regulator",
.post_bind = regulator_post_bind,
.pre_probe = regulator_pre_probe,
+ .post_probe = regulator_post_probe,
.per_device_plat_auto = sizeof(struct dm_regulator_uclass_plat),
};
--
2.45.2
I thought I objected to this patch, but it seems to be in -next? Does
anyone know what has happened here?
Yes, you missed me noting that this fixes real problems and has been
needing to be fixed for a while. I said you should provide your
alternative approach and we'll get this sorted out in -next and I took
the work-around for master so the release wouldn't be broken.

I am seeing these errors now when running sandbox 'u-boot -D':

i2c_emul_find() No emulators for device 'sandbox_pmic'
sandbox_pmic_write() write error to device: 0000000018c49db0 register: 0x0!
out_set_value() PMIC write failed: -5
i2c_emul_find() No emulators for device 'sandbox_pmic'
sandbox_pmic_write() write error to device: 0000000018c49db0 register: 0x0!
out_set_value() PMIC write failed: -5
I suppose the good news is that perhaps this is also related to the
problem that Svyatoslav was reporting.

--
Tom


Simon Glass
 

Hi,

On Thu, 26 Sept 2024 at 17:15, Marek Vasut <marex@...> wrote:

Turn regulators_enable_boot_on() and regulators_enable_boot_off() into
empty functions. Implement matching functionality in regulator_post_probe()
instead. The regulator_post_probe() is called for all regulators after they
probe, and regulators that have regulator-always-on or regulator-boot-on DT
properties now always probe due to DM_FLAG_PROBE_AFTER_BIND being set on
such regulators in regulator_post_bind().

Finally, fold regulator_unset() functionality into regulator_autoset().

Signed-off-by: Marek Vasut <marex@...>
---
Cc: Ben Wolsieffer <benwolsieffer@...>
Cc: Caleb Connolly <caleb.connolly@...>
Cc: Chris Morgan <macromorgan@...>
Cc: Dragan Simic <dsimic@...>
Cc: Eugen Hristev <eugen.hristev@...>
Cc: Francesco Dolcini <francesco.dolcini@...>
Cc: Heinrich Schuchardt <xypron.glpk@...>
Cc: Jaehoon Chung <jh80.chung@...>
Cc: Jagan Teki <jagan@...>
Cc: Jonas Karlman <jonas@...>
Cc: Kever Yang <kever.yang@...>
Cc: Matteo Lisi <matteo.lisi@...>
Cc: Mattijs Korpershoek <mkorpershoek@...>
Cc: Max Krummenacher <max.krummenacher@...>
Cc: Neil Armstrong <neil.armstrong@...>
Cc: Patrice Chotard <patrice.chotard@...>
Cc: Patrick Delaunay <patrick.delaunay@...>
Cc: Philipp Tomsich <philipp.tomsich@...>
Cc: Quentin Schulz <quentin.schulz@...>
Cc: Sam Day <me@...>
Cc: Simon Glass <sjg@...>
Cc: Sumit Garg <sumit.garg@...>
Cc: Svyatoslav Ryhel <clamor95@...>
Cc: Thierry Reding <treding@...>
Cc: Tom Rini <trini@...>
Cc: Volodymyr Babchuk <Volodymyr_Babchuk@...>
Cc: [email protected]
Cc: [email protected]
Cc: u-boot@...
Cc: u-boot@...
Cc: uboot-stm32@...
---
V2: Rebase on current u-boot/next
V3: No change
---
drivers/power/regulator/regulator-uclass.c | 60 +++++++---------------
1 file changed, 19 insertions(+), 41 deletions(-)

diff --git a/drivers/power/regulator/regulator-uclass.c b/drivers/power/regulator/regulator-uclass.c
index 1a970004540..9fcc4bd85b9 100644
--- a/drivers/power/regulator/regulator-uclass.c
+++ b/drivers/power/regulator/regulator-uclass.c
@@ -314,6 +314,11 @@ int regulator_autoset(struct udevice *dev)
return ret;
}

+ if (uc_pdata->force_off) {
+ ret = regulator_set_enable(dev, false);
+ goto out;
+ }
+
if (!uc_pdata->always_on && !uc_pdata->boot_on) {
ret = -EMEDIUMTYPE;
goto out;
@@ -518,56 +523,28 @@ static int regulator_pre_probe(struct udevice *dev)
return 0;
}

-int regulators_enable_boot_on(bool verbose)
+static int regulator_post_probe(struct udevice *dev)
{
- struct udevice *dev;
- struct uclass *uc;
int ret;

- ret = uclass_get(UCLASS_REGULATOR, &uc);
- if (ret)
+ ret = regulator_autoset(dev);
+ if (ret && ret != -EMEDIUMTYPE && ret != -EALREADY && ret != ENOSYS)
return ret;
- for (uclass_first_device(UCLASS_REGULATOR, &dev);
- dev;
- uclass_next_device(&dev)) {
- ret = regulator_autoset(dev);
- if (ret == -EMEDIUMTYPE || ret == -EALREADY) {
- ret = 0;
- continue;
- }
- if (verbose)
- regulator_show(dev, ret);
- if (ret == -ENOSYS)
- ret = 0;
- }

- return ret;
+ if (_DEBUG)
+ regulator_show(dev, ret);
+
+ return 0;
}

-int regulators_enable_boot_off(bool verbose)
+int regulators_enable_boot_on(bool verbose)
{
- struct udevice *dev;
- struct uclass *uc;
- int ret;
-
- ret = uclass_get(UCLASS_REGULATOR, &uc);
- if (ret)
- return ret;
- for (uclass_first_device(UCLASS_REGULATOR, &dev);
- dev;
- uclass_next_device(&dev)) {
- ret = regulator_unset(dev);
- if (ret == -EMEDIUMTYPE) {
- ret = 0;
- continue;
- }
- if (verbose)
- regulator_show(dev, ret);
- if (ret == -ENOSYS)
- ret = 0;
- }
+ return 0;
+}

- return ret;
+int regulators_enable_boot_off(bool verbose)
+{
+ return 0;
}

UCLASS_DRIVER(regulator) = {
@@ -575,5 +552,6 @@ UCLASS_DRIVER(regulator) = {
.name = "regulator",
.post_bind = regulator_post_bind,
.pre_probe = regulator_pre_probe,
+ .post_probe = regulator_post_probe,
.per_device_plat_auto = sizeof(struct dm_regulator_uclass_plat),
};
--
2.45.2
I thought I objected to this patch, but it seems to be in -next? Does
anyone know what has happened here?

I am seeing these errors now when running sandbox 'u-boot -D':

i2c_emul_find() No emulators for device 'sandbox_pmic'
sandbox_pmic_write() write error to device: 0000000018c49db0 register: 0x0!
out_set_value() PMIC write failed: -5
i2c_emul_find() No emulators for device 'sandbox_pmic'
sandbox_pmic_write() write error to device: 0000000018c49db0 register: 0x0!
out_set_value() PMIC write failed: -5

Regards,
Simon


Svyatoslav Ryhel
 

§é§ä, 3 §Ø§à§Ó§ä. 2024?§â. §à 18:03 Simon Glass <sjg@...> §á§Ú§ê§Ö:

Hi Tom,

On Wed, 2 Oct 2024 at 19:40, Tom Rini <trini@...> wrote:

On Wed, Oct 02, 2024 at 04:55:39PM -0600, Simon Glass wrote:
Hi,

On Thu, 26 Sept 2024 at 17:15, Marek Vasut <marex@...> wrote:

Turn regulators_enable_boot_on() and regulators_enable_boot_off() into
empty functions. Implement matching functionality in regulator_post_probe()
instead. The regulator_post_probe() is called for all regulators after they
probe, and regulators that have regulator-always-on or regulator-boot-on DT
properties now always probe due to DM_FLAG_PROBE_AFTER_BIND being set on
such regulators in regulator_post_bind().

Finally, fold regulator_unset() functionality into regulator_autoset().

Signed-off-by: Marek Vasut <marex@...>
---
Cc: Ben Wolsieffer <benwolsieffer@...>
Cc: Caleb Connolly <caleb.connolly@...>
Cc: Chris Morgan <macromorgan@...>
Cc: Dragan Simic <dsimic@...>
Cc: Eugen Hristev <eugen.hristev@...>
Cc: Francesco Dolcini <francesco.dolcini@...>
Cc: Heinrich Schuchardt <xypron.glpk@...>
Cc: Jaehoon Chung <jh80.chung@...>
Cc: Jagan Teki <jagan@...>
Cc: Jonas Karlman <jonas@...>
Cc: Kever Yang <kever.yang@...>
Cc: Matteo Lisi <matteo.lisi@...>
Cc: Mattijs Korpershoek <mkorpershoek@...>
Cc: Max Krummenacher <max.krummenacher@...>
Cc: Neil Armstrong <neil.armstrong@...>
Cc: Patrice Chotard <patrice.chotard@...>
Cc: Patrick Delaunay <patrick.delaunay@...>
Cc: Philipp Tomsich <philipp.tomsich@...>
Cc: Quentin Schulz <quentin.schulz@...>
Cc: Sam Day <me@...>
Cc: Simon Glass <sjg@...>
Cc: Sumit Garg <sumit.garg@...>
Cc: Svyatoslav Ryhel <clamor95@...>
Cc: Thierry Reding <treding@...>
Cc: Tom Rini <trini@...>
Cc: Volodymyr Babchuk <Volodymyr_Babchuk@...>
Cc: [email protected]
Cc: [email protected]
Cc: u-boot@...
Cc: u-boot@...
Cc: uboot-stm32@...
---
V2: Rebase on current u-boot/next
V3: No change
---
drivers/power/regulator/regulator-uclass.c | 60 +++++++---------------
1 file changed, 19 insertions(+), 41 deletions(-)

diff --git a/drivers/power/regulator/regulator-uclass.c b/drivers/power/regulator/regulator-uclass.c
index 1a970004540..9fcc4bd85b9 100644
--- a/drivers/power/regulator/regulator-uclass.c
+++ b/drivers/power/regulator/regulator-uclass.c
@@ -314,6 +314,11 @@ int regulator_autoset(struct udevice *dev)
return ret;
}

+ if (uc_pdata->force_off) {
+ ret = regulator_set_enable(dev, false);
+ goto out;
+ }
+
if (!uc_pdata->always_on && !uc_pdata->boot_on) {
ret = -EMEDIUMTYPE;
goto out;
@@ -518,56 +523,28 @@ static int regulator_pre_probe(struct udevice *dev)
return 0;
}

-int regulators_enable_boot_on(bool verbose)
+static int regulator_post_probe(struct udevice *dev)
{
- struct udevice *dev;
- struct uclass *uc;
int ret;

- ret = uclass_get(UCLASS_REGULATOR, &uc);
- if (ret)
+ ret = regulator_autoset(dev);
+ if (ret && ret != -EMEDIUMTYPE && ret != -EALREADY && ret != ENOSYS)
return ret;
- for (uclass_first_device(UCLASS_REGULATOR, &dev);
- dev;
- uclass_next_device(&dev)) {
- ret = regulator_autoset(dev);
- if (ret == -EMEDIUMTYPE || ret == -EALREADY) {
- ret = 0;
- continue;
- }
- if (verbose)
- regulator_show(dev, ret);
- if (ret == -ENOSYS)
- ret = 0;
- }

- return ret;
+ if (_DEBUG)
+ regulator_show(dev, ret);
+
+ return 0;
}

-int regulators_enable_boot_off(bool verbose)
+int regulators_enable_boot_on(bool verbose)
{
- struct udevice *dev;
- struct uclass *uc;
- int ret;
-
- ret = uclass_get(UCLASS_REGULATOR, &uc);
- if (ret)
- return ret;
- for (uclass_first_device(UCLASS_REGULATOR, &dev);
- dev;
- uclass_next_device(&dev)) {
- ret = regulator_unset(dev);
- if (ret == -EMEDIUMTYPE) {
- ret = 0;
- continue;
- }
- if (verbose)
- regulator_show(dev, ret);
- if (ret == -ENOSYS)
- ret = 0;
- }
+ return 0;
+}

- return ret;
+int regulators_enable_boot_off(bool verbose)
+{
+ return 0;
}

UCLASS_DRIVER(regulator) = {
@@ -575,5 +552,6 @@ UCLASS_DRIVER(regulator) = {
.name = "regulator",
.post_bind = regulator_post_bind,
.pre_probe = regulator_pre_probe,
+ .post_probe = regulator_post_probe,
.per_device_plat_auto = sizeof(struct dm_regulator_uclass_plat),
};
--
2.45.2
I thought I objected to this patch, but it seems to be in -next? Does
anyone know what has happened here?
Yes, you missed me noting that this fixes real problems and has been
needing to be fixed for a while. I said you should provide your
alternative approach and we'll get this sorted out in -next and I took
the work-around for master so the release wouldn't be broken.
OK ta. So long as we can revert/change that is fine.


I am seeing these errors now when running sandbox 'u-boot -D':

i2c_emul_find() No emulators for device 'sandbox_pmic'
sandbox_pmic_write() write error to device: 0000000018c49db0 register: 0x0!
out_set_value() PMIC write failed: -5
i2c_emul_find() No emulators for device 'sandbox_pmic'
sandbox_pmic_write() write error to device: 0000000018c49db0 register: 0x0!
out_set_value() PMIC write failed: -5
I suppose the good news is that perhaps this is also related to the
problem that Svyatoslav was reporting.
OK, I actually never fully understood the problem, but yes, sandbox is
supposed to work similarly.

Regards,
Simon
Simon,

Please inform me when you come up with a solution, I would like to
test it. Thanks.