чт, 20 лип. 2023 р. о 22:43 Simon Glass <s...@chromium.org> пише:
>
> Hi Svyatoslav,
>
> On Thu, 20 Jul 2023 at 06:38, Svyatoslav Ryhel <clamo...@gmail.com> wrote:
> >
> > Main goal is to probe all regulator childrens for their
> > proper setup but if pmic has non regulator children they
> > should not suffer from this either.
> >
> > Signed-off-by: Svyatoslav Ryhel <clamo...@gmail.com>
> > ---
> >  drivers/power/pmic/pmic-uclass.c | 10 ++++++++++
> >  1 file changed, 10 insertions(+)
> >
> > diff --git a/drivers/power/pmic/pmic-uclass.c 
> > b/drivers/power/pmic/pmic-uclass.c
> > index 0e2f5e1f41..8ca717bd5e 100644
> > --- a/drivers/power/pmic/pmic-uclass.c
> > +++ b/drivers/power/pmic/pmic-uclass.c
> > @@ -16,6 +16,7 @@
> >  #include <dm/device-internal.h>
> >  #include <dm/uclass-internal.h>
> >  #include <power/pmic.h>
> > +#include <power/regulator.h>
> >  #include <linux/ctype.h>
>
> I'm not sure about this.
>
> The idea is that power is handling automatically, e.g. a device is
> probed and so its power is enabled. If you do everything at the start,

Why do you think probe == power on? As for now in u-boot pmic childrens are
mostly regulators with few minor exceptions. Unlike any other devices
regulators have special properties like boot-on or always-on and are
required by other devices to operate correctly.

Before this patch special properties were either neglected or their
establishment was performed with a board call, both ways are bad
solutions. With this patch all pmic regulators are probed and set
according to their dts properties (yes, if the regulator is not in use
it will be turned off so no power consumption issue there) which is
desired behavior.

> doesn't that violate the 'lazy' init side of U-Boot?
>

That 'lazy' init resulted in more issues for me (half working devices,
broken usb) then if it was handled actively. I am not against this
approach, but pmic and regulators is not the device which should
embrace it.

> >
> >  #if CONFIG_IS_ENABLED(PMIC_CHILDREN)
> > @@ -198,9 +199,18 @@ static int pmic_pre_probe(struct udevice *dev)
> >         return 0;
> >  }
> >
> > +static int pmic_post_probe(struct udevice *dev)
> > +{
> > +       struct udevice *child;
> > +
> > +       device_foreach_child_probe(child, dev);
> > +       return 0;
> > +}
> > +
> >  UCLASS_DRIVER(pmic) = {
> >         .id             = UCLASS_PMIC,
> >         .name           = "pmic",
> >         .pre_probe      = pmic_pre_probe,
> > +       .post_probe     = pmic_post_probe,
> >         .per_device_auto        = sizeof(struct uc_pmic_priv),
> >  };
> > --
> > 2.39.2
> >
>
> Regards,
> Simon

Reply via email to