// SPDX-License-Identifier: (GPL-2.0+ OR MIT) /* * Example for a board device tree (not an overlay): the panel (U1, 0x74), * the key expander (U2, 0x76) and the 13 keys on i2c1 of an Orange Pi Zero * (Allwinner H2+). Running on real hardware, built into the board DTB. * * Include it after the mainline board file, e.g. * * #include "sun8i-h2-plus-orangepi-zero.dts" * #include "orangepi-zero-i2c1.dtsi" * * For another board: change the bus (&i2c1, its pinctrl) and the INT pin * (PA6 here, in &pio and in the interrupts of gpio@76). Without INT wired, * drop the interrupt properties and use "gpio-keys-polled" with * poll-interval = <20> instead of "gpio-keys". * * The key table matches dts/radio-panel.dts. Keep the two the same. */ #include #include #include / { aliases { i2c1 = &i2c1; /* keep /dev/i2c-1 */ }; }; /* * PA18 (SCL) / PA19 (SDA). 400 kHz relies on the pull-ups on the panel * board; the SoC's internal ones are too weak for that speed. */ &i2c1 { pinctrl-names = "default"; pinctrl-0 = <&i2c1_pins>; clock-frequency = <400000>; status = "okay"; /* "k4be" is not a registered vendor prefix: dtbs_check warns here */ panel@74 { compatible = "k4be,s1d13700-tca9539"; reg = <0x74>; }; /* U2: A1=H, A0=L. INT is open drain, active low, on PA6. */ radio_u2: gpio@76 { compatible = "ti,tca9539"; reg = <0x76>; pinctrl-names = "default"; pinctrl-0 = <&radio_u2_int_pin>; gpio-controller; #gpio-cells = <2>; interrupt-controller; #interrupt-cells = <2>; interrupt-parent = <&pio>; interrupts = <0 6 IRQ_TYPE_LEVEL_LOW>; /* PA6 */ }; }; &pio { radio_u2_int_pin: radio-u2-int-pin { pins = "PA6"; function = "irq"; bias-pull-up; }; }; / { /* * Keys are active high: one pin each to the supply, with an external * pull-down. Pins 0-7 are P0.0-7, 8-15 are P1.0-7; P0.0-2 unused. */ radio-keys { compatible = "gpio-keys"; label = "radio-keys"; autorepeat; key-next { label = "next"; gpios = <&radio_u2 3 GPIO_ACTIVE_HIGH>; linux,code = ; debounce-interval = <20>; }; key-left { label = "left"; gpios = <&radio_u2 4 GPIO_ACTIVE_HIGH>; linux,code = ; debounce-interval = <20>; }; key-down { label = "down"; gpios = <&radio_u2 5 GPIO_ACTIVE_HIGH>; linux,code = ; debounce-interval = <20>; }; key-up { label = "up"; gpios = <&radio_u2 6 GPIO_ACTIVE_HIGH>; linux,code = ; debounce-interval = <20>; }; key-right { label = "right"; gpios = <&radio_u2 7 GPIO_ACTIVE_HIGH>; linux,code = ; debounce-interval = <20>; }; key-esc { label = "esc"; gpios = <&radio_u2 8 GPIO_ACTIVE_HIGH>; linux,code = ; debounce-interval = <20>; }; key-ok { label = "ok"; gpios = <&radio_u2 9 GPIO_ACTIVE_HIGH>; linux,code = ; debounce-interval = <20>; }; key-menu { label = "menu"; gpios = <&radio_u2 10 GPIO_ACTIVE_HIGH>; linux,code = ; debounce-interval = <20>; }; key-list { label = "list"; gpios = <&radio_u2 11 GPIO_ACTIVE_HIGH>; linux,code = ; debounce-interval = <20>; }; key-stop { label = "stop"; gpios = <&radio_u2 12 GPIO_ACTIVE_HIGH>; linux,code = ; debounce-interval = <20>; }; key-pause { label = "pause"; gpios = <&radio_u2 13 GPIO_ACTIVE_HIGH>; linux,code = ; debounce-interval = <20>; }; key-play { label = "play"; gpios = <&radio_u2 14 GPIO_ACTIVE_HIGH>; linux,code = ; debounce-interval = <20>; }; key-prev { label = "prev"; gpios = <&radio_u2 15 GPIO_ACTIVE_HIGH>; linux,code = ; debounce-interval = <20>; }; }; };