Free up the pins from the pinmux helper
[experiments/bbb-gpio-keypad.git] / bbb-gpio-keypad-00A0.dts
1 /*
2  * bbb-gpio-keypad - simple navigation keypad for the BeagleBone Black
3  *
4  * Copyright (C) 2018  Antonio Ospite <ao2@ao2.it>
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  */
19
20 /dts-v1/;
21 /plugin/;
22
23 #include <dt-bindings/board/am335x-bbw-bbb-base.h>
24 #include <dt-bindings/gpio/gpio.h>
25 #include <dt-bindings/pinctrl/am33xx.h>
26
27 / {
28     compatible = "ti,beaglebone", "ti,beaglebone-black";
29
30     // Identification.
31     part-number = "bbb-gpio-keypad";
32     version = "00A0";
33
34     // Resources this cape uses, see also https://ao2.it/137
35     exclusive-use =
36         "P8.07",
37         "P8.08",
38         "P8.09",
39         "P8.10",
40         "P8.26",
41         "P9.15";
42
43     // Free up the pins from the pinmux helper
44     fragment@0 {
45         target = <&ocp>;
46         __overlay__ {
47             P8_07_pinmux { status = "disabled"; };
48             P8_08_pinmux { status = "disabled"; };
49             P8_09_pinmux { status = "disabled"; };
50             P8_10_pinmux { status = "disabled"; };
51             P8_26_pinmux { status = "disabled"; };
52             P9_15_pinmux { status = "disabled"; };
53         };
54     };
55
56     fragment@1 {
57         target = <&am33xx_pinmux>;
58         __overlay__ {
59             keypad_pins: pinmux_gpio_pins {
60                 pinctrl-single,pins = <
61                     BONE_P8_07 (PIN_INPUT_PULLUP | MUX_MODE7)
62                     BONE_P8_08 (PIN_INPUT_PULLUP | MUX_MODE7)
63                     BONE_P8_09 (PIN_INPUT_PULLUP | MUX_MODE7)
64                     BONE_P8_10 (PIN_INPUT_PULLUP | MUX_MODE7)
65                     BONE_P8_26 (PIN_INPUT_PULLUP | MUX_MODE7)
66                     BONE_P9_15 (PIN_INPUT_PULLUP | MUX_MODE7)
67                 >;
68             };
69         };
70     };
71
72     fragment@2 {
73         target-path = "/";
74         __overlay__ {
75             gpio_keys {
76                 compatible = "gpio-keys";
77                 autorepeat;
78                 pinctrl-names = "default";
79                 pinctrl-0 = <&keypad_pins>;
80
81                 up {
82                     label = "GPIO Key UP";
83                     linux,code = <103>;
84                     gpios = <&gpio2 2 GPIO_ACTIVE_LOW>;
85                     debounce_interval = <50>;
86                 };
87                 left {
88                     label = "GPIO Key LEFT";
89                     linux,code = <105>;
90                     gpios = <&gpio2 3 GPIO_ACTIVE_LOW>;
91                     debounce_interval = <50>;
92                 };
93                 right {
94                     label = "GPIO Key RIGHT";
95                     linux,code = <106>;
96                     gpios = <&gpio2 5 GPIO_ACTIVE_LOW>;
97                     debounce_interval = <50>;
98                 };
99                 down {
100                     label = "GPIO Key DOWN";
101                     linux,code = <108>;
102                     gpios = <&gpio2 4 GPIO_ACTIVE_LOW>;
103                     debounce_interval = <50>;
104                 };
105                 enter {
106                     label = "GPIO Key ENTER";
107                     linux,code = <28>;
108                     gpios = <&gpio1 29 GPIO_ACTIVE_LOW>;
109                     debounce_interval = <50>;
110                 };
111                 esc {
112                     label = "GPIO Key ESC";
113                     linux,code = <1>;
114                     gpios = <&gpio1 16 GPIO_ACTIVE_LOW>;
115                     debounce_interval = <50>;
116                 };
117             };
118         };
119     };
120 };