regulator: core: Fix the init of DT defined fixed regulators
PATCH 1/1 regulator: core: Fix the init of DT defined fixed regulators
When a regulator is defined using DT and it has a single voltage the regulator init always tries to apply this voltage. However this fails if the regulator isn't settable. So skip this step if the regulator doesn't provides any set method.
--- drivers/regulator/core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/regulator/core.c +3 -1
@@ -843,7 +843,9 @@ static int machine_constraints_voltage(struct regulator_dev *rdev,/* do we need to apply the constraint voltage */ if (rdev->constraints->apply_uV && - rdev->constraints->min_uV == rdev->constraints->max_uV) { + rdev->constraints->min_uV == rdev->constraints->max_uV && + (rdev->desc->ops->set_voltage || + rdev->desc->ops->set_voltage_sel)) { ret =_regulator_do_set_voltage (rdev, rdev->constraints->min_uV, rdev->constraints->max_uV);
Signature · 1 line
1.9.3
Mark Brown
maintainerQuoted 4 lines · Alban Bedel
When a regulator is defined using DT and it has a single voltage the regulator init always tries to apply this voltage. However this fails if the regulator isn't settable. So skip this step if the regulator doesn't provides any set method.
No, this means we'll just ignore the voltage someone tried to set. A bigger question is why someone is trying to configure the voltage of a fixed voltage regulator in DT...
Quoted 10 lines · On Mon, 19 May 2014 15:39:49 +0100 Mark Brown <[email protected]> wrote:
Quoted 4 lines · Alban Bedel
When a regulator is defined using DT and it has a single voltage the regulator init always tries to apply this voltage. However this fails if the regulator isn't settable. So skip this step if the regulator doesn't provides any set method.
No, this means we'll just ignore the voltage someone tried to set. A bigger question is why someone is trying to configure the voltage of a fixed voltage regulator in DT...
We have a platform where a TPS658621 has been replaced by a TPS658640 in newer version of the hardware. One of the few difference between both regulator is that one output is now fixed. One could write a new DT that doesn't "set" this output. But IMHO the current DT should still be usable as the voltage declared for the now fixed regulator is still correct.
Would checking that the regulator is at the voltage declared in the DT better? Or should I just add a pseudo set method to the regulator driver that only accept the current voltage? That could also be implemented at the core level using a default method for all regulators that have a get but no set method.
Alban
Mark Brown
maintainerQuoted 5 lines · Alban Bedel
Would checking that the regulator is at the voltage declared in the DT better? Or should I just add a pseudo set method to the regulator driver that only accept the current voltage? That could also be implemented at the core level using a default method for all regulators that have a get but no set method.
We already have code in the core to accept set_voltage() on fixed voltage regulators - are you sure you're working with current code? Otherwise fixing things to go through the standard set_voltage() path would be OK. There should be no need to add a dummy function for setting.
Quoted 8 lines · On Mon, 19 May 2014 17:18:38 +0100 Mark Brown <[email protected]> wrote:
Quoted 5 lines · Alban Bedel
Would checking that the regulator is at the voltage declared in the DT better? Or should I just add a pseudo set method to the regulator driver that only accept the current voltage? That could also be implemented at the core level using a default method for all regulators that have a get but no set method.
Quoted 5 lines
We already have code in the core to accept
set_voltage()on fixed voltage regulators - are you sure you're working with current code? Otherwise fixing things to go through the standardset_voltage()path would be OK. There should be no need to add a dummy function for setting.
The regulator_set_voltage() function do have code to handle such read-only regulators. However the regulator init directly call the low level function _regulator_do_set_voltage() which just error out when no set method is available, hence my original patch.
Unless there is some better proposal, or objections, I'll submit a new patch tomorrow to call _regulator_do_set_voltage() only if the current voltage isn't correct.
Alban
Mark Brown
maintainerQuoted 3 lines · Alban Bedel
Unless there is some better proposal, or objections, I'll submit a new patch tomorrow to call
_regulator_do_set_voltage()only if the current voltage isn't correct.
Right, that's the best solution.