diff mbox series

[4/4] dt-bindings: arm: add support for SCMI Regulators

Message ID 20201005222623.1123-5-cristian.marussi@arm.com (mailing list archive)
State New, archived
Headers show
Series Add support for SCMIv3.0 Voltage Domain Protocol and SCMI-Regulator | expand

Commit Message

Cristian Marussi Oct. 5, 2020, 10:26 p.m. UTC
Add devicetree bindings to support regulators based on SCMI Voltage
Domain Protocol.

Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
---
 .../devicetree/bindings/arm/arm,scmi.txt      | 44 +++++++++++++++++++
 1 file changed, 44 insertions(+)

Comments

Mark Brown Oct. 6, 2020, 10:59 a.m. UTC | #1
On Mon, Oct 05, 2020 at 11:26:23PM +0100, Cristian Marussi wrote:

> +An SCMI Regulator is permanently bound to a well defined SCMI Voltage Domain,
> +and should be always positioned as a root regulator.
> +It does not support negative voltages nor any current operation.

Support for negative voltages is an implementation detail of Linux, IIRC
there's nothing in the generic regulator binding preventing it and even
if there were updates to the generic binding are what are relevant here
- they could start working with no updates to this binding.

> +Optional properties:
> + - regulator-min-microvolt: when defined should be non-negative.
> + - regulator-max-microvolt: when defined should be non-negative.

These are covered by the generic regulator binding, no need to duplicate
the documentation here.
Cristian Marussi Oct. 7, 2020, 8:06 a.m. UTC | #2
Hi Mark

thanks for reviewing this series.
 
On Tue, Oct 06, 2020 at 11:59:22AM +0100, Mark Brown wrote:
> On Mon, Oct 05, 2020 at 11:26:23PM +0100, Cristian Marussi wrote:
> 
> > +An SCMI Regulator is permanently bound to a well defined SCMI Voltage Domain,
> > +and should be always positioned as a root regulator.
> > +It does not support negative voltages nor any current operation.
> 
> Support for negative voltages is an implementation detail of Linux, IIRC
> there's nothing in the generic regulator binding preventing it and even
> if there were updates to the generic binding are what are relevant here
> - they could start working with no updates to this binding.
> 
> > +Optional properties:
> > + - regulator-min-microvolt: when defined should be non-negative.
> > + - regulator-max-microvolt: when defined should be non-negative.
> 
> These are covered by the generic regulator binding, no need to duplicate
> the documentation here.

Right I'll drop this references to negative voltages in the bindings.

Anyway, the underlying SCMI Voltage Domain protocol do support negatives
and just expose a negative_volts_allowed flags in the Voltage descriptor
if the domain is advertised by fw as supporting negatives.

Based on that, since the regulator framework as of now cannot report
negative voltages (since the .get ops return an int which is used also
for reporting negative error codes), the SCMI regulator driver in this
series just checks for that flag on every found Voltage Domain and refuse
to handle it like:

if (vinfo->negative_volts_allowed) {
+		dev_warn(dev, "Negative voltages NOT supported...skip %s\n",
+			 sreg->of_node->full_name);
+		return -EOPNOTSUPP;
+	}

So the driver itself will need to be patched in this regards the day the
regulator framework should support negatives, it won't just work.
(but I suppose this is not a problem since it will need to be changed anyway
to use properly this possible new API handling negatives.)

Thanks

Cristian
diff mbox series

Patch

diff --git a/Documentation/devicetree/bindings/arm/arm,scmi.txt b/Documentation/devicetree/bindings/arm/arm,scmi.txt
index 55deb68230eb..c6a008737631 100644
--- a/Documentation/devicetree/bindings/arm/arm,scmi.txt
+++ b/Documentation/devicetree/bindings/arm/arm,scmi.txt
@@ -62,6 +62,30 @@  Required properties:
  - #power-domain-cells : Should be 1. Contains the device or the power
 			 domain ID value used by SCMI commands.
 
+Regulator bindings for the SCMI Regulator based on SCMI Message Protocol
+------------------------------------------------------------
+
+An SCMI Regulator is permanently bound to a well defined SCMI Voltage Domain,
+and should be always positioned as a root regulator.
+It does not support negative voltages nor any current operation.
+
+This binding uses the common regulator binding[6].
+
+SCMI Regulators are grouped under a 'regulators' node which in turn is a child
+of the SCMI Voltage protocol node inside the desired SCMI instance node.
+
+Required properties:
+ - reg : shall identify an existent SCMI Voltage Domain.
+
+Optional properties:
+ - regulator-min-microvolt: when defined should be non-negative.
+ - regulator-max-microvolt: when defined should be non-negative.
+ - all of the other standard regulator bindings as in [6]: note that, since
+   the SCMI Protocol itself aims in fact to hide away many of the operational
+   capabilities usually exposed by the properties of a standard regulator,
+   most of the usual regulator bindings could have just no effect in the
+   context of this SCMI regulator.
+
 Sensor bindings for the sensors based on SCMI Message Protocol
 --------------------------------------------------------------
 SCMI provides an API to access the various sensors on the SoC.
@@ -105,6 +129,7 @@  Required sub-node properties:
 [3] Documentation/devicetree/bindings/thermal/thermal*.yaml
 [4] Documentation/devicetree/bindings/sram/sram.yaml
 [5] Documentation/devicetree/bindings/reset/reset.txt
+[6] Documentation/devicetree/bindings/regulator/regulator.yaml
 
 Example:
 
@@ -169,6 +194,25 @@  firmware {
 			reg = <0x16>;
 			#reset-cells = <1>;
 		};
+
+		scmi_voltage: protocol@17 {
+			reg = <0x17>;
+
+			regulators {
+				regulator_cpu: regulator_scmi_cpu@0 {
+					reg = <0x0>;
+					regulator-max-microvolt = <3300000>;
+				};
+
+				regulator_gpu: regulator_scmi_gpu@9 {
+					reg = <0x9>;
+					regulator-min-microvolt = <500000>;
+					regulator-max-microvolt = <4200000>;
+				};
+
+				...
+			};
+		};
 	};
 };