aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/brcm2708/patches-4.14/950-0218-Generic-Rotary-Encoder-overlay-for-multiple-instance.patch
blob: b85d5450333b297ed9d98c178cdb56f87d2f66e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
From d61d506099a7e3dc2823927c89ac56478ef9f3a5 Mon Sep 17 00:00:00 2001
From: Ismael Asensio <isma.af@gmail.com>
Date: Sun, 18 Feb 2018 18:53:58 +0100
Subject: [PATCH 218/454] Generic Rotary Encoder overlay for multiple instances
 (#2388)

Modify the rotary-encoder overlay to support multiple instances.
---
 arch/arm/boot/dts/overlays/README             |  4 +-
 .../dts/overlays/rotary-encoder-overlay.dts   | 54 +++++++++++--------
 2 files changed, 33 insertions(+), 25 deletions(-)

--- a/arch/arm/boot/dts/overlays/README
+++ b/arch/arm/boot/dts/overlays/README
@@ -1345,9 +1345,9 @@ Params: <None>
 Name:   rotary-encoder
 Info:   Overlay for GPIO connected rotary encoder.
 Load:   dtoverlay=rotary-encoder,<param>=<val>
-Params: rotary0_pin_a           GPIO connected to rotary encoder channel A
+Params: pin_a                   GPIO connected to rotary encoder channel A
                                 (default 4).
-        rotary0_pin_b           GPIO connected to rotary encoder channel B
+        pin_b                   GPIO connected to rotary encoder channel B
                                 (default 17).
         relative_axis           register a relative axis rather than an
                                 absolute one. Relative axis will only
--- a/arch/arm/boot/dts/overlays/rotary-encoder-overlay.dts
+++ b/arch/arm/boot/dts/overlays/rotary-encoder-overlay.dts
@@ -8,7 +8,7 @@
 	fragment@0 {
 		target = <&gpio>;
 		__overlay__ {
-			rotary0_pins: rotary0_pins {
+			rotary_pins: rotary_pins@4 {
 				brcm,pins = <4 17>; /* gpio 4 17 */
 				brcm,function = <0 0>; /* input */
 				brcm,pull = <2 2>; /* pull-up */
@@ -20,32 +20,40 @@
 	fragment@1 {
 		target-path = "/";
 		__overlay__ {
-			rotary0: rotary@0 {
-					compatible = "rotary-encoder";
-					status = "okay";
-					pinctrl-names = "default";
-					pinctrl-0 = <&rotary0_pins>;
-					gpios = <&gpio 4 0>, <&gpio 17 0>;
-					linux,axis = <0>; /* REL_X */
-					rotary-encoder,encoding = "gray";
-					rotary-encoder,steps = <24>; /* 24 default */
-					rotary-encoder,steps-per-period = <1>; /* corresponds to full period mode. See README */
+			rotary: rotary@4 {
+				compatible = "rotary-encoder";
+				status = "okay";
+				pinctrl-names = "default";
+				pinctrl-0 = <&rotary_pins>;
+				gpios = <&gpio 4 0>, <&gpio 17 0>;
+				linux,axis = <0>; /* REL_X */
+				rotary-encoder,encoding = "gray";
+				rotary-encoder,steps = <24>; /* 24 default */
+				rotary-encoder,steps-per-period = <1>; /* corresponds to full period mode. See README */
 			};
 		};
 
 	};  
 
 	__overrides__ {
-		rotary0_pin_a =     <&rotary0>,"gpios:4",
-		                    <&rotary0_pins>,"brcm,pins:0";
-		rotary0_pin_b =     <&rotary0>,"gpios:16",
-		                    <&rotary0_pins>,"brcm,pins:4";
-		relative_axis =     <&rotary0>,"rotary-encoder,relative-axis?";
-		linux_axis =        <&rotary0>,"linux,axis:0";
-		rollover =          <&rotary0>,"rotary-encoder,rollover?";
-		steps-per-period =  <&rotary0>,"rotary-encoder,steps-per-period:0";
-		steps =             <&rotary0>,"rotary-encoder,steps:0";
-		wakeup =            <&rotary0>,"wakeup-source?";
-		encoding =          <&rotary0>,"rotary-encoder,encoding";
-	};  
+		pin_a =		    <&rotary>,"gpios:4",
+				    <&rotary_pins>,"brcm,pins:0",
+				    /* modify reg values to allow multiple instantiation */
+				    <&rotary>,"reg:0",
+				    <&rotary_pins>,"reg:0";
+		pin_b =		    <&rotary>,"gpios:16",
+				    <&rotary_pins>,"brcm,pins:4";
+		relative_axis =     <&rotary>,"rotary-encoder,relative-axis?";
+		linux_axis =        <&rotary>,"linux,axis:0";
+		rollover =          <&rotary>,"rotary-encoder,rollover?";
+		steps-per-period =  <&rotary>,"rotary-encoder,steps-per-period:0";
+		steps =             <&rotary>,"rotary-encoder,steps:0";
+		wakeup =            <&rotary>,"wakeup-source?";
+		encoding =          <&rotary>,"rotary-encoder,encoding";
+                /* legacy parameters*/
+		rotary0_pin_a =     <&rotary>,"gpios:4",
+		                    <&rotary_pins>,"brcm,pins:0";
+		rotary0_pin_b =     <&rotary>,"gpios:16",
+		                    <&rotary_pins>,"brcm,pins:4";
+	};
 };