On 04/17/2013 12:52 PM, Mark Brown wrote:
On Wed, Apr 17, 2013 at 10:25:30AM -0600, Stephen Warren wrote:
On 04/17/2013 09:28 AM, Mark Brown wrote:
You can do the same thing with DT as you do with board files - make those supplies an optional property and then if the property is missing do the default thing.
But then, you end up with an optional regulator, and the driver has to do things like:
if (!IS_ERR(x->reg_foo)) regulator_enable(x->reg_foo);
Not if you do it at the other end - do it during device registration. If nothing is set up then feed the regulator API whatever the default configuration is for the device, otherwise use what you were given. The consumer side can't tell where the configuration came from and will always have one.
This does mean you need to do the regulator driver if you support non-default configurations but that's no bad thing.
OK, so something like:
During DT parsing:
if (!dt_property_exits()) // regulator API call to set up a dummy regulator for this device
Somewhere later in the probe() path:
x->reg = regulator_get();
The one thing I may have forgotten to mention here for the LDO1 case is that if we don't explicitly support regulators right away, then instead the driver needs to explicitly request a GPIO to control the LDO1_EN input on the chip; without that, the device won't even respond to I2C accesses. And hence, that GPIO also needs to be described in device tree. The other regulators could certainly all work as you're pointing out.