obtaining a regulator from a phandle

Thierry Reding thierry.reding at avionic-design.de
Tue Mar 6 02:21:57 EST 2012


Hi,

I'm working on getting DT support for PCIe on Tegra working. The Tegra PCIe
controller needs a specific voltage supplied by a regulator on the board that
I use (Harmony-compatible), so what I did was add DT support for the PMU
(tps6586x) to provide the corresponding regulator:

	pmu: tps6586x at 34 {
		[...]
		regulators {
			...
			ldo0_reg: ldo0 {
				regulator-min-microvolt = <3300000>;
				regulator-max-microvolt = <3300000>;
			};
		};
		[...]
	};

Within the device node of the PCIe controller, I reference the ldo0 regulator
like so:

	pcie at 80000000 {
		pex-clk-supply = <&ldo0_reg>;
	};

This all works well, except there seems to be no API to obtain a regulator
from the DT phandle. I'm wondering whether this is because nobody has had any
use for it or whether I'm using it wrongly.

I could possibly work around this by giving the ldo0 an explicit name via the
regulator-name property and then look up that property from the phandle and
then obtain a reference to the regulator by calling the normal regulator_get()
and passing the name. That seems wasteful, though, because I already have a
direct link to the regulator (via its struct device_node) and all I really
need is to look up the corresponding struct regulator.

So my question really is if it would be acceptable to add such a helper, or
whether I have completely misunderstood how this works. In the latter case,
could anyone point me in the right direction?

Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.ozlabs.org/pipermail/devicetree-discuss/attachments/20120305/ae8c5f8f/attachment.pgp>


More information about the devicetree-discuss mailing list