Skip to content

Commit 85f95fd

Browse files
chenzhiwopopcornmix
authored andcommitted
Add device tree overlay for GPIO connected rotary encoder.
See Documentation/input/rotary-encoder.txt for more information.
1 parent fc6a5f8 commit 85f95fd

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

arch/arm/boot/dts/overlays/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ dtbo-$(CONFIG_ARCH_BCM2835) += \
7676
pwm-2chan.dtbo \
7777
qca7000.dtbo \
7878
raspidac3.dtbo \
79+
rotary-encoder.dtbo \
7980
rpi-backlight.dtbo \
8081
rpi-cirrus-wm5102.dtbo \
8182
rpi-dac.dtbo \

arch/arm/boot/dts/overlays/README

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,6 +1122,15 @@ Load: dtoverlay=raspidac3
11221122
Params: <None>
11231123

11241124

1125+
Name: rotary-encoder
1126+
Info: Overlay for GPIO connected rotary encoder.
1127+
Load: dtoverlay=rotary-encoder,<param>=<val>
1128+
Params: rotary0_pin_a GPIO connected to rotary encoder channel A
1129+
(default 4).
1130+
rotary0_pin_b GPIO connected to rotary encoder channel B
1131+
(default 17).
1132+
1133+
11251134
Name: rpi-backlight
11261135
Info: Raspberry Pi official display backlight driver
11271136
Load: dtoverlay=rpi-backlight
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Device tree overlay for GPIO connected rotary encoder.
2+
/dts-v1/;
3+
/plugin/;
4+
5+
/ {
6+
compatible = "brcm,bcm2708";
7+
8+
fragment@0 {
9+
target = <&gpio>;
10+
__overlay__ {
11+
rotary0_pins: rotary0_pins {
12+
brcm,pins = <4 17>; /* gpio 4 17 */
13+
brcm,function = <0 0>; /* input */
14+
brcm,pull = <2 2>; /* pull-up */
15+
};
16+
17+
};
18+
};
19+
20+
fragment@1 {
21+
target-path = "/";
22+
__overlay__ {
23+
rotary0: rotary@0 {
24+
compatible = "rotary-encoder";
25+
status = "okay";
26+
pinctrl-names = "default";
27+
pinctrl-0 = <&rotary0_pins>;
28+
gpios = <&gpio 4 0>, <&gpio 17 0>;
29+
linux,axis = <0>; /* REL_X */
30+
rotary-encoder,encoding = "gray";
31+
rotary-encoder,relative-axis;
32+
};
33+
};
34+
35+
};
36+
37+
__overrides__ {
38+
rotary0_pin_a = <&rotary0>,"gpios:4",
39+
<&rotary0_pins>,"brcm,pins:0";
40+
rotary0_pin_b = <&rotary0>,"gpios:16",
41+
<&rotary0_pins>,"brcm,pins:4";
42+
};
43+
};

0 commit comments

Comments
 (0)