orangepi-zero-i2c1.dtsi 3.7 KB

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