Patchwork [RFC,v2,1/3] power_supply: Define Binding for supplied-nodes

login
register
mail settings
Submitter Rhyland Klein
Date Feb. 21, 2013, 11:11 p.m.
Message ID <1361488272-21010-2-git-send-email-rklein@nvidia.com>
Download mbox | patch
Permalink /patch/222437/
State Not Applicable, archived
Headers show

Comments

Rhyland Klein - Feb. 21, 2013, 11:11 p.m.
This property is meant to be used in device nodes which represent
power_supply devices that wish to provide a list of supplies to
which they provide power. A common case is a AC Charger with
the batteries it powers.

Signed-off-by: Rhyland Klein <rklein@nvidia.com>
---
v2:
  - Changed property to "power-supply" which should be contained in the
    battery rather than the charger. Also updated example to match.

 .../bindings/power_supply/power_supply.txt         |   23 ++++++++++++++++++++
 1 file changed, 23 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/power_supply/power_supply.txt
Stephen Warren - Feb. 22, 2013, 7:46 p.m.
On 02/21/2013 04:11 PM, Rhyland Klein wrote:
> This property is meant to be used in device nodes which represent
> power_supply devices that wish to provide a list of supplies to
> which they provide power. A common case is a AC Charger with
> the batteries it powers.

> diff --git a/Documentation/devicetree/bindings/power_supply/power_supply.txt b/Documentation/devicetree/bindings/power_supply/power_supply.txt

> +Optional Properties:
> + - power-supply : This property is added to a supply in order to list the
> +   devices which supply it power, referenced by their phandles.

DT properties that reference resources are usually named in the plural,
so "power-supplies" would be more appropriate here.

It seems plausible that a single DT node could represent/instantiate
multiple separate supply objects. I think we want to employ the standard
pattern of <phandle args*> rather than just <phandle>.

That way, each supply that can supply others would have something like a
#supply-cells = <n>, where n is the number of cells that the supply uses
to name the multiple supplies provided by that node. 0 would be a common
value here. 1 might be used for a node that represents many supplies.

When a client supply uses a providing supply as the supply(!), do you
need any flags to parameterize the connection? If so, that might be
cause for a supplier to have a larger #supply-cells, so the flags could
be represented.

That all said, regulators assume 1 node == 1 regulator, so an
alternative would be for a multi-supply node to include a child node per
supply, e.g.:

power@xxx {
    ...
    supply1 {
        ...
    };
    supply2 {
        ...
    };
};

client {
    supplies = <&supply1> <&supply2>;
};

I don't recall why regulators went for the style above rather than the
#supply-cells style. Cc Mark Brown for any comment here.

Also, do supplies and regulators need to inter-operate in any way (e.g.
reference each-other in DT)?

> +Example:
> +
> +	usb-charger: power@e {
> +		compatible = "some,usb-charger";
> +		...
> +	};
> +
> +	ac-charger: power@e {
> +		compatible = "some,ac-charger";
> +		...
> +	};
> +
> +	battery@b {
> +		compatible = "some,battery";
> +		...
> +		power-supply = <&usb-charger>, <&ac-charger>;
> +	};

--
To unsubscribe from this list: send the line "unsubscribe linux-tegra" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Rhyland Klein - Feb. 22, 2013, 10:05 p.m.
On 2/22/2013 2:46 PM, Stephen Warren wrote:
> On 02/21/2013 04:11 PM, Rhyland Klein wrote:
>> This property is meant to be used in device nodes which represent
>> power_supply devices that wish to provide a list of supplies to
>> which they provide power. A common case is a AC Charger with
>> the batteries it powers.
>> diff --git a/Documentation/devicetree/bindings/power_supply/power_supply.txt b/Documentation/devicetree/bindings/power_supply/power_supply.txt
>> +Optional Properties:
>> + - power-supply : This property is added to a supply in order to list the
>> +   devices which supply it power, referenced by their phandles.
> DT properties that reference resources are usually named in the plural,
> so "power-supplies" would be more appropriate here.
>
> It seems plausible that a single DT node could represent/instantiate
> multiple separate supply objects. I think we want to employ the standard
> pattern of <phandle args*> rather than just <phandle>.
>
> That way, each supply that can supply others would have something like a
> #supply-cells = <n>, where n is the number of cells that the supply uses
> to name the multiple supplies provided by that node. 0 would be a common
> value here. 1 might be used for a node that represents many supplies.
>
> When a client supply uses a providing supply as the supply(!), do you
> need any flags to parameterize the connection? If so, that might be
> cause for a supplier to have a larger #supply-cells, so the flags could
> be represented.
>
> That all said, regulators assume 1 node == 1 regulator, so an
> alternative would be for a multi-supply node to include a child node per
> supply, e.g.:
>
> power@xxx {
>      ...
>      supply1 {
>          ...
>      };
>      supply2 {
>          ...
>      };
> };
>
> client {
>      supplies = <&supply1> <&supply2>;
> };
>
> I don't recall why regulators went for the style above rather than the
> #supply-cells style. Cc Mark Brown for any comment here.
>
> Also, do supplies and regulators need to inter-operate in any way (e.g.
> reference each-other in DT)?
>
>> +Example:
>> +
>> +	usb-charger: power@e {
>> +		compatible = "some,usb-charger";
>> +		...
>> +	};
>> +
>> +	ac-charger: power@e {
>> +		compatible = "some,ac-charger";
>> +		...
>> +	};
>> +
>> +	battery@b {
>> +		compatible = "some,battery";
>> +		...
>> +		power-supply = <&usb-charger>, <&ac-charger>;
>> +	};

The "connection" between supplier and supplies isn't really a hard 
connection.
Essentially, the core code uses the names/nodes in the list and iterates 
over
all the power_supplies that are registered and does matching.

I don't have any experience working with a single node that would spawn 
multiple
supplies, though the situation I am sure is possible. I am interested to 
see what
the consensus is around this design for multiple supplies, as I don't have a
preference either way.

-rhyland

Patch

diff --git a/Documentation/devicetree/bindings/power_supply/power_supply.txt b/Documentation/devicetree/bindings/power_supply/power_supply.txt
new file mode 100644
index 0000000..7d8951c
--- /dev/null
+++ b/Documentation/devicetree/bindings/power_supply/power_supply.txt
@@ -0,0 +1,23 @@ 
+Power Supply Core Support
+
+Optional Properties:
+ - power-supply : This property is added to a supply in order to list the
+   devices which supply it power, referenced by their phandles.
+
+Example:
+
+	usb-charger: power@e {
+		compatible = "some,usb-charger";
+		...
+	};
+
+	ac-charger: power@e {
+		compatible = "some,ac-charger";
+		...
+	};
+
+	battery@b {
+		compatible = "some,battery";
+		...
+		power-supply = <&usb-charger>, <&ac-charger>;
+	};