orangepi-zero-i2c1-keys.dtsi 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. // SPDX-License-Identifier: (GPL-2.0+ OR MIT)
  2. /*
  3. * Example for a board device tree (not an overlay): the key expander (U2,
  4. * 0x76) and the 13 keys on i2c1 of an Orange Pi Zero (Allwinner H2+).
  5. * Running on real hardware, built into the board DTB.
  6. *
  7. * Include it after the mainline board file and the bus setup, e.g. the
  8. * panel's example from the s1d13700-tca repository, which enables i2c1:
  9. *
  10. * #include "sun8i-h2-plus-orangepi-zero.dts"
  11. * #include "orangepi-zero-i2c1.dtsi" (s1d13700-tca)
  12. * #include "orangepi-zero-i2c1-keys.dtsi"
  13. *
  14. * For another board: change the bus (&i2c1) and the INT pin (PA6 here, in
  15. * &pio and in the interrupts of gpio@76). Without INT wired, drop the
  16. * interrupt properties and use "gpio-keys-polled" with poll-interval = <20>
  17. * instead of "gpio-keys".
  18. *
  19. * The key table matches dts/radio-keys.dts. Keep the two the same.
  20. */
  21. #include <dt-bindings/gpio/gpio.h>
  22. #include <dt-bindings/input/input.h>
  23. #include <dt-bindings/interrupt-controller/irq.h>
  24. &i2c1 {
  25. status = "okay";
  26. /* U2: A1=H, A0=L. INT is open drain, active low, on PA6. */
  27. radio_u2: gpio@76 {
  28. compatible = "ti,tca9539";
  29. reg = <0x76>;
  30. pinctrl-names = "default";
  31. pinctrl-0 = <&radio_u2_int_pin>;
  32. gpio-controller;
  33. #gpio-cells = <2>;
  34. interrupt-controller;
  35. #interrupt-cells = <2>;
  36. interrupt-parent = <&pio>;
  37. interrupts = <0 6 IRQ_TYPE_LEVEL_LOW>; /* PA6 */
  38. };
  39. };
  40. &pio {
  41. radio_u2_int_pin: radio-u2-int-pin {
  42. pins = "PA6";
  43. function = "irq";
  44. bias-pull-up;
  45. };
  46. };
  47. / {
  48. /*
  49. * Keys are active high: one pin each to the supply, with an external
  50. * pull-down. Pins 0-7 are P0.0-7, 8-15 are P1.0-7; P0.0-2 unused.
  51. */
  52. radio-keys {
  53. compatible = "gpio-keys";
  54. label = "radio-keys";
  55. autorepeat;
  56. key-next { label = "next"; gpios = <&radio_u2 3 GPIO_ACTIVE_HIGH>; linux,code = <KEY_NEXTSONG>; debounce-interval = <20>; };
  57. key-left { label = "left"; gpios = <&radio_u2 4 GPIO_ACTIVE_HIGH>; linux,code = <KEY_LEFT>; debounce-interval = <20>; };
  58. key-down { label = "down"; gpios = <&radio_u2 5 GPIO_ACTIVE_HIGH>; linux,code = <KEY_DOWN>; debounce-interval = <20>; };
  59. key-up { label = "up"; gpios = <&radio_u2 6 GPIO_ACTIVE_HIGH>; linux,code = <KEY_UP>; debounce-interval = <20>; };
  60. key-right { label = "right"; gpios = <&radio_u2 7 GPIO_ACTIVE_HIGH>; linux,code = <KEY_RIGHT>; debounce-interval = <20>; };
  61. key-esc { label = "esc"; gpios = <&radio_u2 8 GPIO_ACTIVE_HIGH>; linux,code = <KEY_ESC>; debounce-interval = <20>; };
  62. key-ok { label = "ok"; gpios = <&radio_u2 9 GPIO_ACTIVE_HIGH>; linux,code = <KEY_OK>; debounce-interval = <20>; };
  63. key-menu { label = "menu"; gpios = <&radio_u2 10 GPIO_ACTIVE_HIGH>; linux,code = <KEY_MENU>; debounce-interval = <20>; };
  64. key-list { label = "list"; gpios = <&radio_u2 11 GPIO_ACTIVE_HIGH>; linux,code = <KEY_LIST>; debounce-interval = <20>; };
  65. key-stop { label = "stop"; gpios = <&radio_u2 12 GPIO_ACTIVE_HIGH>; linux,code = <KEY_STOPCD>; debounce-interval = <20>; };
  66. key-pause { label = "pause"; gpios = <&radio_u2 13 GPIO_ACTIVE_HIGH>; linux,code = <KEY_PAUSECD>; debounce-interval = <20>; };
  67. key-play { label = "play"; gpios = <&radio_u2 14 GPIO_ACTIVE_HIGH>; linux,code = <KEY_PLAYCD>; debounce-interval = <20>; };
  68. key-prev { label = "prev"; gpios = <&radio_u2 15 GPIO_ACTIVE_HIGH>; linux,code = <KEY_PREVIOUSSONG>; debounce-interval = <20>; };
  69. };
  70. };