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