dm: regulator: drop regulator-state-mem initial from autoset
init regulator-state-mem wastes time a lot and is only needed when system suspend is called, so provide regulators_enable_state_mem() the driver that implements system suspend. Change-Id: I2499df7caa9224879eed057d9269e8dcdce11c51 Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
This commit is contained in:
parent
7bd9afa1c6
commit
0ae9790ca7
|
|
@ -244,6 +244,20 @@ int device_get_supply_regulator(struct udevice *dev, const char *supply_name,
|
|||
supply_name, devp);
|
||||
}
|
||||
|
||||
static int regulator_init_suspend(struct udevice *dev)
|
||||
{
|
||||
struct dm_regulator_uclass_platdata *uc_pdata;
|
||||
int ret;
|
||||
|
||||
uc_pdata = dev_get_uclass_platdata(dev);
|
||||
|
||||
ret = regulator_set_suspend_enable(dev, uc_pdata->suspend_on);
|
||||
if (!ret && uc_pdata->suspend_on)
|
||||
return regulator_set_suspend_value(dev, uc_pdata->suspend_uV);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int regulator_autoset(struct udevice *dev)
|
||||
{
|
||||
struct dm_regulator_uclass_platdata *uc_pdata;
|
||||
|
|
@ -254,16 +268,6 @@ int regulator_autoset(struct udevice *dev)
|
|||
if (uc_pdata->ramp_delay != -ENODATA)
|
||||
regulator_set_ramp_delay(dev, uc_pdata->ramp_delay);
|
||||
|
||||
/*
|
||||
* Suspend configure is not necessary and should not influence normal
|
||||
* configure, so that we set "ret=0" even failed here.
|
||||
*/
|
||||
ret = regulator_set_suspend_enable(dev, uc_pdata->suspend_on);
|
||||
if (!ret && uc_pdata->suspend_on)
|
||||
regulator_set_suspend_value(dev, uc_pdata->suspend_uV);
|
||||
else
|
||||
ret = 0;
|
||||
|
||||
if (!uc_pdata->always_on && !uc_pdata->boot_on)
|
||||
return -EMEDIUMTYPE;
|
||||
|
||||
|
|
@ -464,6 +468,31 @@ static int regulator_pre_probe(struct udevice *dev)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int regulators_enable_state_mem(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_init_suspend(dev);
|
||||
|
||||
if (ret == -EMEDIUMTYPE)
|
||||
ret = 0;
|
||||
if (verbose)
|
||||
regulator_show(dev, ret);
|
||||
if (ret == -ENOSYS)
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int regulators_enable_boot_on(bool verbose)
|
||||
{
|
||||
struct udevice *dev;
|
||||
|
|
@ -477,6 +506,7 @@ int regulators_enable_boot_on(bool verbose)
|
|||
dev;
|
||||
uclass_next_device(&dev)) {
|
||||
ret = regulator_autoset(dev);
|
||||
|
||||
if (ret == -EMEDIUMTYPE)
|
||||
ret = 0;
|
||||
if (verbose)
|
||||
|
|
|
|||
|
|
@ -394,23 +394,11 @@ int regulator_set_mode(struct udevice *dev, int mode_id);
|
|||
int regulators_enable_boot_on(bool verbose);
|
||||
|
||||
/**
|
||||
* regulator_autoset: setup the voltage/current on a regulator
|
||||
* regulators_enable_state_mem() - enable regulators state mem configure
|
||||
*
|
||||
* The setup depends on constraints found in device's uclass's platform data
|
||||
* (struct dm_regulator_uclass_platdata):
|
||||
*
|
||||
* - Enable - will set - if any of: 'always_on' or 'boot_on' is set to true,
|
||||
* or if both are unset, then the function returns
|
||||
* - Voltage value - will set - if '.min_uV' and '.max_uV' values are equal
|
||||
* - Current limit - will set - if '.min_uA' and '.max_uA' values are equal
|
||||
*
|
||||
* The function returns on the first-encountered error.
|
||||
*
|
||||
* @platname - expected string for dm_regulator_uclass_platdata .name field
|
||||
* @devp - returned pointer to the regulator device - if non-NULL passed
|
||||
* @return: 0 on success or negative value of errno.
|
||||
* This sets regulator-state-mem state for all regulators ;
|
||||
*/
|
||||
int regulator_autoset(struct udevice *dev);
|
||||
int regulators_enable_state_mem(bool verbose);
|
||||
|
||||
/**
|
||||
* regulator_autoset_by_name: setup the regulator given by its uclass's
|
||||
|
|
|
|||
Loading…
Reference in New Issue