From d27d1447e49bc6ffa92f787f7bc5c2eea29ba7d2 Mon Sep 17 00:00:00 2001 From: Phil Elwell Date: Wed, 30 Sep 2020 12:08:08 +0100 Subject: [PATCH] overlays: Add fsm-demo overlay fsm-demo demonstrates the usage of the gpio-fsm driver. It is designed to be used with a set of "traffic light" LEDs on GPIOs 7, 8 and 25. Signed-off-by: Phil Elwell --- arch/arm/boot/dts/overlays/Makefile | 1 + arch/arm/boot/dts/overlays/README | 8 ++ .../boot/dts/overlays/fsm-demo-overlay.dts | 104 ++++++++++++++++++ 3 files changed, 113 insertions(+) create mode 100644 arch/arm/boot/dts/overlays/fsm-demo-overlay.dts --- a/arch/arm/boot/dts/overlays/Makefile +++ b/arch/arm/boot/dts/overlays/Makefile @@ -44,6 +44,7 @@ dtbo-$(CONFIG_ARCH_BCM2835) += \ enc28j60-spi2.dtbo \ exc3000.dtbo \ fe-pi-audio.dtbo \ + fsm-demo.dtbo \ goodix.dtbo \ googlevoicehat-soundcard.dtbo \ gpio-fan.dtbo \ --- a/arch/arm/boot/dts/overlays/README +++ b/arch/arm/boot/dts/overlays/README @@ -767,6 +767,14 @@ Load: dtoverlay=fe-pi-audio Params: +Name: fsm-demo +Info: A demonstration of the gpio-fsm driver. The GPIOs are chosen to work + nicely with a "traffic-light" display of red, amber and green LEDs on + GPIOs 7, 8 and 25 respectively. +Load: dtoverlay=fsm-demo,= +Params: fsm_debug Enable debug logging (default off) + + Name: goodix Info: Enables I2C connected Goodix gt9271 multiple touch controller using GPIOs 4 and 17 (pins 7 and 11 on GPIO header) for interrupt and reset. --- /dev/null +++ b/arch/arm/boot/dts/overlays/fsm-demo-overlay.dts @@ -0,0 +1,104 @@ +// Demo overlay for the gpio-fsm driver +/dts-v1/; +/plugin/; + +#include + +#define BUTTON1 GF_IP(0) +#define BUTTON2 GF_SW(0) +#define RED GF_OP(0) // GPIO7 +#define AMBER GF_OP(1) // GPIO8 +#define GREEN GF_OP(2) // GPIO25 + +/{ + compatible = "brcm,bcm2835"; + + fragment@0 { + target-path = "/"; + __overlay__ { + fsm_demo: fsm-demo { + compatible = "rpi,gpio-fsm"; + + debug = <0>; + gpio-controller; + #gpio-cells = <2>; + num-soft-gpios = <1>; + gpio-line-names = "button2"; + input-gpios = <&gpio 6 1>; // BUTTON1 (active-low) + output-gpios = <&gpio 7 0>, // RED + <&gpio 8 0>, // AMBER + <&gpio 25 0>; // GREEN + shutdown-timeout-ms = <2000>; + + start { + start_state; + set = , , ; + start2 = ; + }; + + start2 { + set = , ; + go = ; + }; + + go { + set = , , ; + ready_wait = ; + shutdown1 = ; + }; + + ready_wait { + // Clear the soft GPIO + set = ; + ready = ; + shutdown1 = ; + }; + + ready { + stopping = , ; + shutdown1 = ; + }; + + stopping { + set = , ; + stopped = ; + }; + + stopped { + set = , ; + get_set = ; + shutdown1 = ; + }; + + get_set { + set = ; + go = ; + }; + + shutdown1 { + set = , , ; + shutdown2 = ; + }; + + shutdown2 { + set = , ; + shutdown3 = ; + }; + + shutdown3 { + set = , ; + shutdown4 = ; + }; + + shutdown4 { + shutdown_state; + set = ; + }; + }; + }; + }; + + __overrides__ { + fsm_debug = <&fsm_demo>,"debug:0"; + }; +};