gpio-keys.yaml 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. # SPDX-License-Identifier: GPL-2.0-only
  2. %YAML 1.2
  3. ---
  4. $id: http://devicetree.org/schemas/input/gpio-keys.yaml#
  5. $schema: http://devicetree.org/meta-schemas/core.yaml#
  6. title: GPIO attached keys
  7. maintainers:
  8. - Rob Herring <robh@kernel.org>
  9. properties:
  10. compatible:
  11. enum:
  12. - gpio-keys
  13. - gpio-keys-polled
  14. autorepeat: true
  15. label:
  16. description: Name of entire device
  17. poll-interval: true
  18. patternProperties:
  19. "^(button|event|key|switch|(button|event|key|switch)-[a-z0-9-]+|[a-z0-9-]+-(button|event|key|switch))$":
  20. $ref: input.yaml#
  21. properties:
  22. gpios:
  23. maxItems: 1
  24. interrupts:
  25. oneOf:
  26. - items:
  27. - description: Optional key interrupt or wakeup interrupt
  28. - items:
  29. - description: Key interrupt
  30. - description: Wakeup interrupt
  31. interrupt-names:
  32. description:
  33. Optional interrupt names, can be used to specify a separate dedicated
  34. wake-up interrupt in addition to the gpio irq
  35. oneOf:
  36. - items:
  37. - enum: [ irq, wakeup ]
  38. - items:
  39. - const: irq
  40. - const: wakeup
  41. label:
  42. description: Descriptive name of the key.
  43. linux,code:
  44. description: Key / Axis code to emit.
  45. linux,input-type:
  46. default: 1 # EV_KEY
  47. linux,input-value:
  48. description: |
  49. If linux,input-type is EV_ABS or EV_REL then this
  50. value is sent for events this button generates when pressed.
  51. EV_ABS/EV_REL axis will generate an event with a value of 0
  52. when all buttons with linux,input-type == type and
  53. linux,code == axis are released. This value is interpreted
  54. as a signed 32 bit value, e.g. to make a button generate a
  55. value of -1 use:
  56. linux,input-value = <0xffffffff>; /* -1 */
  57. $ref: /schemas/types.yaml#/definitions/uint32
  58. debounce-interval:
  59. description:
  60. Debouncing interval time in milliseconds. If not specified defaults to 5.
  61. $ref: /schemas/types.yaml#/definitions/uint32
  62. default: 5
  63. wakeup-source:
  64. description: Button can wake-up the system.
  65. wakeup-event-action:
  66. description: |
  67. Specifies whether the key should wake the system when asserted, when
  68. deasserted, or both. This property is only valid for keys that wake up the
  69. system (e.g., when the "wakeup-source" property is also provided).
  70. Supported values are defined in linux-event-codes.h:
  71. EV_ACT_ANY - both asserted and deasserted
  72. EV_ACT_ASSERTED - asserted
  73. EV_ACT_DEASSERTED - deasserted
  74. $ref: /schemas/types.yaml#/definitions/uint32
  75. enum: [0, 1, 2]
  76. linux,can-disable:
  77. description:
  78. Indicates that button is connected to dedicated (not shared) interrupt
  79. which can be disabled to suppress events from the button.
  80. type: boolean
  81. required:
  82. - linux,code
  83. anyOf:
  84. - required:
  85. - interrupts
  86. - required:
  87. - interrupts-extended
  88. - required:
  89. - gpios
  90. allOf:
  91. - if:
  92. properties:
  93. interrupts:
  94. minItems: 2
  95. required:
  96. - interrupts
  97. then:
  98. properties:
  99. interrupt-names:
  100. minItems: 2
  101. required:
  102. - interrupt-names
  103. dependencies:
  104. wakeup-event-action: [ wakeup-source ]
  105. linux,input-value: [ gpios ]
  106. unevaluatedProperties: false
  107. allOf:
  108. - $ref: input.yaml#
  109. - if:
  110. properties:
  111. compatible:
  112. const: gpio-keys-polled
  113. then:
  114. required:
  115. - poll-interval
  116. else:
  117. properties:
  118. poll-interval: false
  119. additionalProperties: false
  120. examples:
  121. - |
  122. #include <dt-bindings/interrupt-controller/irq.h>
  123. gpio-keys {
  124. compatible = "gpio-keys";
  125. autorepeat;
  126. key-up {
  127. label = "GPIO Key UP";
  128. linux,code = <103>;
  129. gpios = <&gpio1 0 1>;
  130. };
  131. key-down {
  132. label = "GPIO Key DOWN";
  133. linux,code = <108>;
  134. interrupts = <1 IRQ_TYPE_EDGE_FALLING>;
  135. };
  136. key-wakeup {
  137. label = "GPIO Key WAKEUP";
  138. linux,code = <143>;
  139. interrupts-extended = <&intc 2 IRQ_TYPE_EDGE_FALLING>,
  140. <&intc_wakeup 0 IRQ_TYPE_LEVEL_HIGH>;
  141. interrupt-names = "irq", "wakeup";
  142. wakeup-source;
  143. };
  144. };
  145. ...