const char *property = "regulator-name";
uc_pdata = dev_get_uclass_plat(dev);
+ uc_pdata->always_on = dev_read_bool(dev, "regulator-always-on");
+ uc_pdata->boot_on = dev_read_bool(dev, "regulator-boot-on");
/* Regulator's mandatory constraint */
uc_pdata->name = dev_read_string(dev, property);
return -EINVAL;
}
- if (regulator_name_is_unique(dev, uc_pdata->name))
- return 0;
+ if (!regulator_name_is_unique(dev, uc_pdata->name)) {
+ debug("'%s' of dev: '%s', has nonunique value: '%s\n",
+ property, dev->name, uc_pdata->name);
+ return -EINVAL;
+ }
- debug("'%s' of dev: '%s', has nonunique value: '%s\n",
- property, dev->name, uc_pdata->name);
+ /*
+ * In case the regulator has regulator-always-on or
+ * regulator-boot-on DT property, trigger probe() to
+ * configure its default state during startup.
+ */
+ if (uc_pdata->always_on || uc_pdata->boot_on)
+ dev_or_flags(dev, DM_FLAG_PROBE_AFTER_BIND);
- return -EINVAL;
+ return 0;
}
static int regulator_pre_probe(struct udevice *dev)
-ENODATA);
uc_pdata->max_uA = dev_read_u32_default(dev, "regulator-max-microamp",
-ENODATA);
- uc_pdata->always_on = dev_read_bool(dev, "regulator-always-on");
- uc_pdata->boot_on = dev_read_bool(dev, "regulator-boot-on");
uc_pdata->ramp_delay = dev_read_u32_default(dev, "regulator-ramp-delay",
0);
uc_pdata->force_off = dev_read_bool(dev, "regulator-force-boot-off");
ut_assertok(sandbox_pwm_get_config(pwm, 0, &period_ns, &duty_ns,
&enable, &polarity));
ut_asserteq(false, enable);
- ut_asserteq(false, regulator_get_enable(reg));
+ ut_asserteq(true, regulator_get_enable(reg));
ut_assertok(panel_enable_backlight(dev));
ut_assertok(sandbox_pwm_get_config(pwm, 0, &period_ns, &duty_ns,
/* Get BUCK1 - always on regulator */
platname = regulator_names[BUCK1][PLATNAME];
- ut_assertok(regulator_autoset_by_name(platname, &dev_autoset));
+ ut_asserteq(-EALREADY, regulator_autoset_by_name(platname, &dev_autoset));
ut_assertok(regulator_get_by_platname(platname, &dev));
/* Try disabling always-on regulator */
* Expected output state: uV=1200000; uA=200000; output enabled
*/
platname = regulator_names[BUCK1][PLATNAME];
- ut_assertok(regulator_autoset_by_name(platname, &dev_autoset));
+ ut_asserteq(-EALREADY, regulator_autoset_by_name(platname, &dev_autoset));
/* Check, that the returned device is proper */
ut_assertok(regulator_get_by_platname(platname, &dev));