Re: Regulator supplies when using Device Tree

From: Michael Bohan
Date: Wed Mar 28 2012 - 15:19:45 EST


On 3/28/2012 3:09 AM, Mark Brown wrote:
On Tue, Mar 27, 2012 at 06:38:30PM -0700, Michael Bohan wrote:
the answer is that we should invent another binding to portray the
name of the supply the driver should be checking against. But then
it would seem silly to have two bindings that pertain to supply
names.

Absolutely not, that would be broken. The whole point here is that
supplies of all kinds are always requested with the name the chip uses
for the supply.

Let's consider an example with two regulators:

regulator@0 {
compatible = "ldo_driver";
foo-supply = <&smps1>;
};

regulator@1 {
compatible = "ldo_driver";
};

How do we write a single regulator driver that supports both of these regulator devices?

Within the regulator driver, we currently have to do an of_get_property(of_node, "foo-supply", NULL) to determine whether the device has a supply, and thus whether we should assign rdesc->supply_name to "foo" or not when calling regulator_register(). Is there a better way to do this? If we don't do this check for the case where a device does not have a supply specified in the Device Tree, then regulator_register() will fail.

Before Device Tree, regulators could get their supply names directly from the board file like so:

http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=blob;f=Documentation/power/regulator/machine.txt;h=ce63af0a8e35ecab32e2f326d13a9a2b33b62909;hb=refs/heads/master#l67

Thus the regulator driver was never concerned about the specifics of a supply name. And if the supply name was not specified, then the regulator_register() would happily succeed without any checks in the driver.

Thanks,
Mike

--
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/