bcm27xx: import latest patches from the RPi foundation
[openwrt/openwrt.git] / target / linux / bcm27xx / patches-5.4 / 950-0987-overlays-Add-fsm-demo-overlay.patch
1 From d27d1447e49bc6ffa92f787f7bc5c2eea29ba7d2 Mon Sep 17 00:00:00 2001
2 From: Phil Elwell <phil@raspberrypi.com>
3 Date: Wed, 30 Sep 2020 12:08:08 +0100
4 Subject: [PATCH] overlays: Add fsm-demo overlay
5
6 fsm-demo demonstrates the usage of the gpio-fsm driver. It is
7 designed to be used with a set of "traffic light" LEDs on GPIOs
8 7, 8 and 25.
9
10 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
11 ---
12 arch/arm/boot/dts/overlays/Makefile | 1 +
13 arch/arm/boot/dts/overlays/README | 8 ++
14 .../boot/dts/overlays/fsm-demo-overlay.dts | 104 ++++++++++++++++++
15 3 files changed, 113 insertions(+)
16 create mode 100644 arch/arm/boot/dts/overlays/fsm-demo-overlay.dts
17
18 --- a/arch/arm/boot/dts/overlays/Makefile
19 +++ b/arch/arm/boot/dts/overlays/Makefile
20 @@ -44,6 +44,7 @@ dtbo-$(CONFIG_ARCH_BCM2835) += \
21 enc28j60-spi2.dtbo \
22 exc3000.dtbo \
23 fe-pi-audio.dtbo \
24 + fsm-demo.dtbo \
25 goodix.dtbo \
26 googlevoicehat-soundcard.dtbo \
27 gpio-fan.dtbo \
28 --- a/arch/arm/boot/dts/overlays/README
29 +++ b/arch/arm/boot/dts/overlays/README
30 @@ -767,6 +767,14 @@ Load: dtoverlay=fe-pi-audio
31 Params: <None>
32
33
34 +Name: fsm-demo
35 +Info: A demonstration of the gpio-fsm driver. The GPIOs are chosen to work
36 + nicely with a "traffic-light" display of red, amber and green LEDs on
37 + GPIOs 7, 8 and 25 respectively.
38 +Load: dtoverlay=fsm-demo,<param>=<val>
39 +Params: fsm_debug Enable debug logging (default off)
40 +
41 +
42 Name: goodix
43 Info: Enables I2C connected Goodix gt9271 multiple touch controller using
44 GPIOs 4 and 17 (pins 7 and 11 on GPIO header) for interrupt and reset.
45 --- /dev/null
46 +++ b/arch/arm/boot/dts/overlays/fsm-demo-overlay.dts
47 @@ -0,0 +1,104 @@
48 +// Demo overlay for the gpio-fsm driver
49 +/dts-v1/;
50 +/plugin/;
51 +
52 +#include <dt-bindings/gpio/gpio-fsm.h>
53 +
54 +#define BUTTON1 GF_IP(0)
55 +#define BUTTON2 GF_SW(0)
56 +#define RED GF_OP(0) // GPIO7
57 +#define AMBER GF_OP(1) // GPIO8
58 +#define GREEN GF_OP(2) // GPIO25
59 +
60 +/{
61 + compatible = "brcm,bcm2835";
62 +
63 + fragment@0 {
64 + target-path = "/";
65 + __overlay__ {
66 + fsm_demo: fsm-demo {
67 + compatible = "rpi,gpio-fsm";
68 +
69 + debug = <0>;
70 + gpio-controller;
71 + #gpio-cells = <2>;
72 + num-soft-gpios = <1>;
73 + gpio-line-names = "button2";
74 + input-gpios = <&gpio 6 1>; // BUTTON1 (active-low)
75 + output-gpios = <&gpio 7 0>, // RED
76 + <&gpio 8 0>, // AMBER
77 + <&gpio 25 0>; // GREEN
78 + shutdown-timeout-ms = <2000>;
79 +
80 + start {
81 + start_state;
82 + set = <RED 1>, <AMBER 0>, <GREEN 0>;
83 + start2 = <GF_DELAY 250>;
84 + };
85 +
86 + start2 {
87 + set = <RED 0>, <AMBER 1>;
88 + go = <GF_DELAY 250>;
89 + };
90 +
91 + go {
92 + set = <RED 0>, <AMBER 0>, <GREEN 1>;
93 + ready_wait = <BUTTON1 0>;
94 + shutdown1 = <GF_SHUTDOWN 0>;
95 + };
96 +
97 + ready_wait {
98 + // Clear the soft GPIO
99 + set = <BUTTON2 0>;
100 + ready = <GF_DELAY 1000>;
101 + shutdown1 = <GF_SHUTDOWN 0>;
102 + };
103 +
104 + ready {
105 + stopping = <BUTTON1 1>, <BUTTON2 1>;
106 + shutdown1 = <GF_SHUTDOWN 0>;
107 + };
108 +
109 + stopping {
110 + set = <GREEN 0>, <AMBER 1>;
111 + stopped = <GF_DELAY 1000>;
112 + };
113 +
114 + stopped {
115 + set = <AMBER 0>, <RED 1>;
116 + get_set = <GF_DELAY 3000>;
117 + shutdown1 = <GF_SHUTDOWN 0>;
118 + };
119 +
120 + get_set {
121 + set = <AMBER 1>;
122 + go = <GF_DELAY 1000>;
123 + };
124 +
125 + shutdown1 {
126 + set = <RED 0>, <AMBER 0>, <GREEN 1>;
127 + shutdown2 = <GF_SHUTDOWN 250>;
128 + };
129 +
130 + shutdown2 {
131 + set = <AMBER 1>, <GREEN 0>;
132 + shutdown3 = <GF_SHUTDOWN 250>;
133 + };
134 +
135 + shutdown3 {
136 + set = <RED 1>, <AMBER 0>;
137 + shutdown4 = <GF_SHUTDOWN 250>;
138 + };
139 +
140 + shutdown4 {
141 + shutdown_state;
142 + set = <RED 0>;
143 + };
144 + };
145 + };
146 + };
147 +
148 + __overrides__ {
149 + fsm_debug = <&fsm_demo>,"debug:0";
150 + };
151 +};