1# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
2# Copyright 2019-2020 Artur Rojek
3%YAML 1.2
4---
5$id: "http://devicetree.org/schemas/input/adc-joystick.yaml#"
6$schema: "http://devicetree.org/meta-schemas/core.yaml#"
7
8title: ADC attached joystick
9
10maintainers:
11  - Artur Rojek <contact@artur-rojek.eu>
12
13description: >
14  Bindings for joystick devices connected to ADC controllers supporting
15  the Industrial I/O subsystem.
16
17properties:
18  compatible:
19    const: adc-joystick
20
21  io-channels:
22    minItems: 1
23    maxItems: 1024
24    description: >
25      List of phandle and IIO specifier pairs.
26      Each pair defines one ADC channel to which a joystick axis is connected.
27      See
28      https://github.com/devicetree-org/dt-schema/blob/master/schemas/iio/iio-consumer.yaml
29      for details.
30
31  '#address-cells':
32    const: 1
33
34  '#size-cells':
35    const: 0
36
37required:
38  - compatible
39  - io-channels
40  - '#address-cells'
41  - '#size-cells'
42
43additionalProperties: false
44
45patternProperties:
46  "^axis@[0-9a-f]+$":
47    type: object
48    description: >
49      Represents a joystick axis bound to the given ADC channel.
50      For each entry in the io-channels list, one axis subnode with a matching
51      reg property must be specified.
52
53    properties:
54      reg:
55        minimum: 0
56        maximum: 1023
57        description: Index of an io-channels list entry bound to this axis.
58
59      linux,code:
60        $ref: /schemas/types.yaml#/definitions/uint32
61        description: EV_ABS specific event code generated by the axis.
62
63      abs-range:
64        allOf:
65          - $ref: /schemas/types.yaml#/definitions/uint32-array
66          - items:
67              - description: minimum value
68              - description: maximum value
69        description: >
70          Minimum and maximum values produced by the axis.
71          For an ABS_X axis this will be the left-most and right-most
72          inclination of the joystick. If min > max, it is left to userspace to
73          treat the axis as inverted.
74          This property is interpreted as two signed 32 bit values.
75
76      abs-fuzz:
77        $ref: /schemas/types.yaml#/definitions/uint32
78        description: >
79          Amount of noise in the input value.
80          Omitting this property indicates the axis is precise.
81
82      abs-flat:
83        $ref: /schemas/types.yaml#/definitions/uint32
84        description: >
85          Axial "deadzone", or area around the center position, where the axis
86          is considered to be at rest.
87          Omitting this property indicates the axis always returns to exactly
88          the center position.
89
90    required:
91      - reg
92      - linux,code
93      - abs-range
94
95    additionalProperties: false
96
97examples:
98  - |
99    #include <dt-bindings/iio/adc/ingenic,adc.h>
100    #include <dt-bindings/input/input.h>
101
102    joystick: adc-joystick {
103      compatible = "adc-joystick";
104      io-channels = <&adc INGENIC_ADC_TOUCH_XP>,
105                    <&adc INGENIC_ADC_TOUCH_YP>;
106      #address-cells = <1>;
107      #size-cells = <0>;
108
109      axis@0 {
110              reg = <0>;
111              linux,code = <ABS_X>;
112              abs-range = <3300 0>;
113              abs-fuzz = <4>;
114              abs-flat = <200>;
115      };
116      axis@1 {
117              reg = <1>;
118              linux,code = <ABS_Y>;
119              abs-range = <0 3300>;
120              abs-fuzz = <4>;
121              abs-flat = <200>;
122      };
123    };
124