Skip to contentSkip to conversation

dt-bindings: hwmon: gpio-fan: convert to YAML

PATCH In review Corentin Labbe 2 participants 2 messages Dec 17, 2022 – Dec 20, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 dt-bindings: hwmon: gpio-fan: convert to YAML

Converts hwmon/gpio-fan.txt to YAML

---
Changes since v1:
- Keeped only one example and simplified it

 .../devicetree/bindings/hwmon/gpio-fan.txt    | 41 -------------
 .../devicetree/bindings/hwmon/gpio-fan.yaml   | 59 +++++++++++++++++++
 2 files changed, 59 insertions(+), 41 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/hwmon/gpio-fan.txt
 create mode 100644 Documentation/devicetree/bindings/hwmon/gpio-fan.yaml
Documentation/devicetree/bindings/hwmon/gpio-fan.txt deleted +0 -41
deleted file mode 100644
index f4cfa350f6a1..000000000000
@@ -1,41 +0,0 @@
-Bindings for fan connected to GPIO lines
-
-Required properties:
-- compatible : "gpio-fan"
-
-Optional properties:
-- gpios: Specifies the pins that map to bits in the control value,
-  ordered MSB-->LSB.
-- gpio-fan,speed-map: A mapping of possible fan RPM speeds and the
-  control value that should be set to achieve them. This array
-  must have the RPM values in ascending order.
-- alarm-gpios: This pin going active indicates something is wrong with
-  the fan, and a udev event will be fired.
-- #cooling-cells: If used as a cooling device, must be <2>
-  Also see:
-  Documentation/devicetree/bindings/thermal/thermal-cooling-devices.yaml
-  min and max states are derived from the speed-map of the fan.
-
-Note: At least one the "gpios" or "alarm-gpios" properties must be set.
-
-Examples:
-
-	gpio_fan {
-		compatible = "gpio-fan";
-		gpios = <&gpio1 14 1
-			 &gpio1 13 1>;
-		gpio-fan,speed-map = <0    0
-				      3000 1
-				      6000 2>;
-		alarm-gpios = <&gpio1 15 1>;
-	};
-	gpio_fan_cool: gpio_fan {
-		compatible = "gpio-fan";
-		gpios = <&gpio2 14 1
-			 &gpio2 13 1>;
-		gpio-fan,speed-map =	<0    0>,
-					<3000 1>,
-					<6000 2>;
-		alarm-gpios = <&gpio2 15 1>;
-		#cooling-cells = <2>; /* min followed by max */
-	};
Documentation/devicetree/bindings/hwmon/gpio-fan.yaml new file +59 -0

59 lines not on this page · raw message

Signature · 1 line
2.37.4
maintainer
#1 lore raw
Quoted 1 line · Corentin Labbe

Converts hwmon/gpio-fan.txt to YAML

s/YAML/DT schema\./

Quoted 65 lines

---
Changes since v1:
- Keeped only one example and simplified it

 .../devicetree/bindings/hwmon/gpio-fan.txt    | 41 -------------
 .../devicetree/bindings/hwmon/gpio-fan.yaml   | 59 +++++++++++++++++++
 2 files changed, 59 insertions(+), 41 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/hwmon/gpio-fan.txt
 create mode 100644 Documentation/devicetree/bindings/hwmon/gpio-fan.yaml
Documentation/devicetree/bindings/hwmon/gpio-fan.txt deleted +0 -41
deleted file mode 100644
index f4cfa350f6a1..000000000000
@@ -1,41 +0,0 @@
-Bindings for fan connected to GPIO lines
-
-Required properties:
-- compatible : "gpio-fan"
-
-Optional properties:
-- gpios: Specifies the pins that map to bits in the control value,
-  ordered MSB-->LSB.
-- gpio-fan,speed-map: A mapping of possible fan RPM speeds and the
-  control value that should be set to achieve them. This array
-  must have the RPM values in ascending order.
-- alarm-gpios: This pin going active indicates something is wrong with
-  the fan, and a udev event will be fired.
-- #cooling-cells: If used as a cooling device, must be <2>
-  Also see:
-  Documentation/devicetree/bindings/thermal/thermal-cooling-devices.yaml
-  min and max states are derived from the speed-map of the fan.
-
-Note: At least one the "gpios" or "alarm-gpios" properties must be set.
-
-Examples:
-
-	gpio_fan {
-		compatible = "gpio-fan";
-		gpios = <&gpio1 14 1
-			 &gpio1 13 1>;
-		gpio-fan,speed-map = <0    0
-				      3000 1
-				      6000 2>;
-		alarm-gpios = <&gpio1 15 1>;
-	};
-	gpio_fan_cool: gpio_fan {
-		compatible = "gpio-fan";
-		gpios = <&gpio2 14 1
-			 &gpio2 13 1>;
-		gpio-fan,speed-map =	<0    0>,
-					<3000 1>,
-					<6000 2>;
-		alarm-gpios = <&gpio2 15 1>;
-		#cooling-cells = <2>; /* min followed by max */
-	};
Documentation/devicetree/bindings/hwmon/gpio-fan.yaml new file +0 -0
new file mode 100644
index 000000000000..c522072c0d07

Documentation/devicetree/bindings/hwmon/gpio-fan.yaml line 7

Quoted 7 lines
Documentation/devicetree/bindings/hwmon/gpio-fan.yaml new file +7 -0
@@ -0,0 +1,59 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/hwmon/gpio-fan.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Bindings for fan connected to GPIO lines

Drop 'Bindings for'. Really, just 'GPIO controlled Fan' is good.

Documentation/devicetree/bindings/hwmon/gpio-fan.yaml line 10

Quoted 3 lines
Documentation/devicetree/bindings/hwmon/gpio-fan.yaml new file +3 -0
+
+maintainers:
+  - OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS <[email protected]>

Should be a person. You can put me.

Documentation/devicetree/bindings/hwmon/gpio-fan.yaml line 17

Quoted 7 lines
Documentation/devicetree/bindings/hwmon/gpio-fan.yaml new file +7 -0
+
+properties:
+  compatible:
+    const: gpio-fan
+
+  gpios:
+    $ref: /schemas/types.yaml#/definitions/phandle-array

Already has a type. Perhaps 'maxItems: N' where N is 'should be enough'. I'd guess 4 is more than enough. Any sane design would go with a PWM controlled fan if that much control is needed.

Documentation/devicetree/bindings/hwmon/gpio-fan.yaml line 25

Quoted 8 lines
Documentation/devicetree/bindings/hwmon/gpio-fan.yaml new file +8 -0
+    description: Specifies the pins that map to bits in the control value,
+      ordered MSB-->LSB.
+
+  gpio-fan,speed-map:
+    $ref: /schemas/types.yaml#/definitions/uint32-matrix
+    description: A mapping of possible fan RPM speeds and the
+      control value that should be set to achieve them. This array
+      must have the RPM values in ascending order.

Needs some constraints and the entries can be better described:

minItems: 2 (I would assume there is no point in 1 entry?)
maxItems: N
items:
items:
- description: Speed in RPM
- description: GPIO Control value

Documentation/devicetree/bindings/hwmon/gpio-fan.yaml line 28

Quoted 3 lines
Documentation/devicetree/bindings/hwmon/gpio-fan.yaml new file +3 -0
+
+  alarm-gpios:
+    $ref: /schemas/types.yaml#/definitions/phandle-array

Drop.

maxItems: 1

Documentation/devicetree/bindings/hwmon/gpio-fan.yaml line 30

Quoted 2 lines
Documentation/devicetree/bindings/hwmon/gpio-fan.yaml new file +2 -0
+    description: This pin going active indicates something is wrong with
+      the fan, and a udev event will be fired.

'udev event' is way outside the scope of a binding.

Documentation/devicetree/bindings/hwmon/gpio-fan.yaml line 34

Quoted 4 lines
Documentation/devicetree/bindings/hwmon/gpio-fan.yaml new file +4 -0
+
+  "#cooling-cells":
+    const: 2
+    description: If used as a cooling device, must be <2>

If not used as a cooling device can be any number of cells?

Don't repeat constraints in free form text.

Documentation/devicetree/bindings/hwmon/gpio-fan.yaml line 35

Quoted 1 line
Documentation/devicetree/bindings/hwmon/gpio-fan.yaml new file +1 -0
+      Also see Documentation/devicetree/bindings/thermal/thermal-cooling-devices.yaml

No need to reference schema for common properties.

Documentation/devicetree/bindings/hwmon/gpio-fan.yaml line 36

Quoted 1 line
Documentation/devicetree/bindings/hwmon/gpio-fan.yaml new file +1 -0
+      min and max states are derived from the speed-map of the fan.

This IS unique to this binding, so it should stay.

Quoted 11 lines
Documentation/devicetree/bindings/hwmon/gpio-fan.yaml new file +11 -0
+
+anyOf:
+  - required:
+      - gpios
+  - required:
+      - alarm-gpios
+
+additionalProperties: False
+
+examples:
+  - |

Documentation/devicetree/bindings/hwmon/gpio-fan.yaml line 57

Quoted 10 lines
Documentation/devicetree/bindings/hwmon/gpio-fan.yaml new file +10 -0
+    #include <dt-bindings/interrupt-controller/irq.h>
+    #include <dt-bindings/clock/cortina,gemini-clock.h>
+    #include <dt-bindings/reset/cortina,gemini-reset.h>
+    #include <dt-bindings/gpio/gpio.h>
+    gpio_fan {
+      compatible = "gpio-fan";
+        gpios = <&gpio1 8 GPIO_ACTIVE_HIGH>;
+        gpio-fan,speed-map = <0    0>,
+                             <3000 1>,
+                             <6000 2>;

How does a single GPIO encode 3 states?

Quoted 6 lines
Documentation/devicetree/bindings/hwmon/gpio-fan.yaml new file +2 -0
+        alarm-gpios = <&gpio1 15 GPIO_ACTIVE_HIGH>;
+    };
Signature · 1 line
2.37.4