diff mbox series

[RFCv2,3/4] dt-bindings: gpio: add Wiegand GPIO driver dt documentation

Message ID 20221005145746.172138-3-m.zatovic1@gmail.com
State New
Headers show
Series [RFCv2,1/4] dt-bindings: bus: add Wiegand bus dt documentation | expand

Commit Message

Martin Zaťovič Oct. 5, 2022, 2:57 p.m. UTC
The Wiegand GPIO driver uses two GPIO lines to transmit data -
data-hi and data-lo. These lines need to be defined in the
devicetree, otherwise the driver will not probe successfully.

Signed-off-by: Martin Zaťovič <m.zatovic1@gmail.com>
---
 .../bindings/gpio/gpio-wiegand.yaml           | 53 +++++++++++++++++++
 1 file changed, 53 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/gpio/gpio-wiegand.yaml

Comments

Rob Herring Oct. 6, 2022, 2:18 a.m. UTC | #1
On Wed, 05 Oct 2022 16:57:45 +0200, Martin Zaťovič wrote:
> The Wiegand GPIO driver uses two GPIO lines to transmit data -
> data-hi and data-lo. These lines need to be defined in the
> devicetree, otherwise the driver will not probe successfully.
> 
> Signed-off-by: Martin Zaťovič <m.zatovic1@gmail.com>
> ---
>  .../bindings/gpio/gpio-wiegand.yaml           | 53 +++++++++++++++++++
>  1 file changed, 53 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/gpio/gpio-wiegand.yaml
> 

My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check'
on your patch (DT_CHECKER_FLAGS is new in v5.13):

yamllint warnings/errors:

dtschema/dtc warnings/errors:
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/gpio/gpio-wiegand.example.dtb: wiegand: wiegand-gpio: {'compatible': ['wiegand,wiegand-gpio'], 'pinctrl-names': ['default'], 'pinctrl-0': [[4294967295]], 'data-hi-gpios': [[4294967295, 7, 6]], 'data-lo-gpios': [[4294967295, 6, 6]]} is not of type 'array'
	From schema: /usr/local/lib/python3.10/dist-packages/dtschema/schemas/gpio/gpio-consumer.yaml
Documentation/devicetree/bindings/gpio/gpio-wiegand.example.dtb:0:0: /example-0/wiegand: failed to match any schema with compatible: ['wiegand']
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/gpio/gpio-wiegand.example.dtb: wiegand-gpio: $nodename:0: 'wiegand-gpio' does not match '^wiegand-gpio@[0-9a-f]+$'
	From schema: /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/gpio/gpio-wiegand.yaml

doc reference errors (make refcheckdocs):

See https://patchwork.ozlabs.org/patch/

This check can fail if there are any dependencies. The base for a patch
series is generally the most recent rc1.

If you already ran 'make dt_binding_check' and didn't see the above
error(s), then make sure 'yamllint' is installed and dt-schema is up to
date:

pip3 install dtschema --upgrade

Please check and re-submit.
Krzysztof Kozlowski Oct. 6, 2022, 8:23 a.m. UTC | #2
On 05/10/2022 16:57, Martin Zaťovič wrote:
> The Wiegand GPIO driver uses two GPIO lines to transmit data -
> data-hi and data-lo. These lines need to be defined in the
> devicetree, otherwise the driver will not probe successfully.
> 
> Signed-off-by: Martin Zaťovič <m.zatovic1@gmail.com>
> ---
>  .../bindings/gpio/gpio-wiegand.yaml           | 53 +++++++++++++++++++
>  1 file changed, 53 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/gpio/gpio-wiegand.yaml
> 
> diff --git a/Documentation/devicetree/bindings/gpio/gpio-wiegand.yaml b/Documentation/devicetree/bindings/gpio/gpio-wiegand.yaml
> new file mode 100644
> index 000000000000..3b235667ae17
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/gpio/gpio-wiegand.yaml
> @@ -0,0 +1,53 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/gpio/gpio-wiegand.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Wiegand GPIO controller
> +
> +description: |
> +  Wiegand GPIO controller running under Wiegand bus.

GPIO controllers need "gpio-controller" property, so this seems to be
something else.

> +
> +maintainers:
> +  - Martin Zaťovič <m.zatovic1@gmail.com>
> +
> +properties:
> +  $nodename:
> +    pattern: "^wiegand-gpio@[0-9a-f]+$"

No need to enforce node name, unless this is for a class of devices. But
then why "gpio" not just "wiegand"?

> +
> +  compatible:
> +    const: wiegand,wiegand-gpio
> +
> +  data-hi-gpios:
> +    description: GPIO spec for data-hi line to use
> +    maxItems: 1
> +
> +  data-lo-gpios:
> +    description: GPIO spec for data-lo line to use
> +    maxItems: 1
> +
> +required:
> +  - compatible
> +  - data-hi-gpios
> +  - data-lo-gpios
> +
> +additionalProperties: false
> +
> +examples:
> +  - |
> +    #include <dt-bindings/gpio/gpio.h>
> +
> +    wiegand {
> +        compatible = "wiegand";
> +
> +        wiegand-gpio {

I have troubles understanding this. The "wiegand" node is the bus,
right? Then what is "wiegand-gpio"? GPIO controller? Then why it is not
marked as GPIO controller? What GPIOs does it control?

> +            compatible = "wiegand,wiegand-gpio";
> +            pinctrl-names = "default";
> +            pinctrl-0 = <&pinctrl_uart2_wiegand>;
> +            data-hi-gpios = <&gpio2 7 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
> +            data-lo-gpios = <&gpio2 6 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;

Aren't these properties of the bus, not the device?

> +        };
> +    };
> +
> +...

Best regards,
Krzysztof
Krzysztof Kozlowski Oct. 6, 2022, 8:34 a.m. UTC | #3
On 06/10/2022 10:23, Krzysztof Kozlowski wrote:
> On 05/10/2022 16:57, Martin Zaťovič wrote:
>> The Wiegand GPIO driver uses two GPIO lines to transmit data -
>> data-hi and data-lo. These lines need to be defined in the
>> devicetree, otherwise the driver will not probe successfully.
>>
>> Signed-off-by: Martin Zaťovič <m.zatovic1@gmail.com>
>> ---
>>  .../bindings/gpio/gpio-wiegand.yaml           | 53 +++++++++++++++++++
>>  1 file changed, 53 insertions(+)
>>  create mode 100644 Documentation/devicetree/bindings/gpio/gpio-wiegand.yaml
>>
>> diff --git a/Documentation/devicetree/bindings/gpio/gpio-wiegand.yaml b/Documentation/devicetree/bindings/gpio/gpio-wiegand.yaml
>> new file mode 100644
>> index 000000000000..3b235667ae17
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/gpio/gpio-wiegand.yaml
>> @@ -0,0 +1,53 @@
>> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
>> +%YAML 1.2
>> +---
>> +$id: http://devicetree.org/schemas/gpio/gpio-wiegand.yaml#
>> +$schema: http://devicetree.org/meta-schemas/core.yaml#
>> +
>> +title: Wiegand GPIO controller
>> +
>> +description: |
>> +  Wiegand GPIO controller running under Wiegand bus.
> 
> GPIO controllers need "gpio-controller" property, so this seems to be
> something else.
> 
>> +
>> +maintainers:
>> +  - Martin Zaťovič <m.zatovic1@gmail.com>
>> +
>> +properties:
>> +  $nodename:
>> +    pattern: "^wiegand-gpio@[0-9a-f]+$"
> 
> No need to enforce node name, unless this is for a class of devices. But
> then why "gpio" not just "wiegand"?
> 
>> +
>> +  compatible:
>> +    const: wiegand,wiegand-gpio
>> +
>> +  data-hi-gpios:
>> +    description: GPIO spec for data-hi line to use
>> +    maxItems: 1
>> +
>> +  data-lo-gpios:
>> +    description: GPIO spec for data-lo line to use
>> +    maxItems: 1
>> +
>> +required:
>> +  - compatible
>> +  - data-hi-gpios
>> +  - data-lo-gpios
>> +
>> +additionalProperties: false
>> +
>> +examples:
>> +  - |
>> +    #include <dt-bindings/gpio/gpio.h>
>> +
>> +    wiegand {
>> +        compatible = "wiegand";
>> +
>> +        wiegand-gpio {
> 
> I have troubles understanding this. The "wiegand" node is the bus,
> right? Then what is "wiegand-gpio"? GPIO controller? Then why it is not
> marked as GPIO controller? What GPIOs does it control?
> 
>> +            compatible = "wiegand,wiegand-gpio";
>> +            pinctrl-names = "default";
>> +            pinctrl-0 = <&pinctrl_uart2_wiegand>;
>> +            data-hi-gpios = <&gpio2 7 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
>> +            data-lo-gpios = <&gpio2 6 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
> 
> Aren't these properties of the bus, not the device?

So this looks like specific implementation of Wiegand bus - a Wiegand
bus controller. If it is correct, it should not be represented as child
of a bus... because this is a bus. IOW, just like SPI or I2C controllers
(why is this one different?), the bus is defined by SPI controller:

wiegand {
	compatible = "wiegand,wiegand-gpio";
	data-hi-gpios = <&gpio2 7 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
	data-lo-gpios = <&gpio2 6 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;

	child-device, e.g. some-card {
		compatible = "foo,bar";
		// more properties of the device
	};
};

Best regards,
Krzysztof
diff mbox series

Patch

diff --git a/Documentation/devicetree/bindings/gpio/gpio-wiegand.yaml b/Documentation/devicetree/bindings/gpio/gpio-wiegand.yaml
new file mode 100644
index 000000000000..3b235667ae17
--- /dev/null
+++ b/Documentation/devicetree/bindings/gpio/gpio-wiegand.yaml
@@ -0,0 +1,53 @@ 
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/gpio/gpio-wiegand.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Wiegand GPIO controller
+
+description: |
+  Wiegand GPIO controller running under Wiegand bus.
+
+maintainers:
+  - Martin Zaťovič <m.zatovic1@gmail.com>
+
+properties:
+  $nodename:
+    pattern: "^wiegand-gpio@[0-9a-f]+$"
+
+  compatible:
+    const: wiegand,wiegand-gpio
+
+  data-hi-gpios:
+    description: GPIO spec for data-hi line to use
+    maxItems: 1
+
+  data-lo-gpios:
+    description: GPIO spec for data-lo line to use
+    maxItems: 1
+
+required:
+  - compatible
+  - data-hi-gpios
+  - data-lo-gpios
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+
+    wiegand {
+        compatible = "wiegand";
+
+        wiegand-gpio {
+            compatible = "wiegand,wiegand-gpio";
+            pinctrl-names = "default";
+            pinctrl-0 = <&pinctrl_uart2_wiegand>;
+            data-hi-gpios = <&gpio2 7 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
+            data-lo-gpios = <&gpio2 6 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
+        };
+    };
+
+...