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
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
10 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
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
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) += \
26 googlevoicehat-soundcard.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
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)
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.
46 +++ b/arch/arm/boot/dts/overlays/fsm-demo-overlay.dts
48 +// Demo overlay for the gpio-fsm driver
52 +#include <dt-bindings/gpio/gpio-fsm.h>
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
61 + compatible = "brcm,bcm2835";
66 + fsm_demo: fsm-demo {
67 + compatible = "rpi,gpio-fsm";
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>;
82 + set = <RED 1>, <AMBER 0>, <GREEN 0>;
83 + start2 = <GF_DELAY 250>;
87 + set = <RED 0>, <AMBER 1>;
88 + go = <GF_DELAY 250>;
92 + set = <RED 0>, <AMBER 0>, <GREEN 1>;
93 + ready_wait = <BUTTON1 0>;
94 + shutdown1 = <GF_SHUTDOWN 0>;
98 + // Clear the soft GPIO
100 + ready = <GF_DELAY 1000>;
101 + shutdown1 = <GF_SHUTDOWN 0>;
105 + stopping = <BUTTON1 1>, <BUTTON2 1>;
106 + shutdown1 = <GF_SHUTDOWN 0>;
110 + set = <GREEN 0>, <AMBER 1>;
111 + stopped = <GF_DELAY 1000>;
115 + set = <AMBER 0>, <RED 1>;
116 + get_set = <GF_DELAY 3000>;
117 + shutdown1 = <GF_SHUTDOWN 0>;
122 + go = <GF_DELAY 1000>;
126 + set = <RED 0>, <AMBER 0>, <GREEN 1>;
127 + shutdown2 = <GF_SHUTDOWN 250>;
131 + set = <AMBER 1>, <GREEN 0>;
132 + shutdown3 = <GF_SHUTDOWN 250>;
136 + set = <RED 1>, <AMBER 0>;
137 + shutdown4 = <GF_SHUTDOWN 250>;
149 + fsm_debug = <&fsm_demo>,"debug:0";