define relay as leds
authorDobrica Pavlinusic <dpavlin@rot13.org>
Wed, 18 Apr 2018 08:18:33 +0000 (08:18 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Wed, 18 Apr 2018 08:18:33 +0000 (08:18 +0000)
This allows us to take over pins right after kernel boot as opposed
to waiting for userland to start up. This configuration starts with
relays off so that brightness values in /sys/class/leds is correct

device-tree/relay-leds.dts [new file with mode: 0644]

diff --git a/device-tree/relay-leds.dts b/device-tree/relay-leds.dts
new file mode 100644 (file)
index 0000000..0136477
--- /dev/null
@@ -0,0 +1,28 @@
+/dts-v1/;
+/plugin/;
+/* dtc -I dts -O dtb relay-leds.dts > /boot/overlays/relay-leds.dtbo */
+/ {
+       fragment@0 {
+               target = <&leds>;
+               __overlay__ {
+                       compatible = "gpio-leds";
+                       relay1: relay@1 {
+                               label = "relay1";
+                               gpios = <&gpio 12 1>; /* 0 = active low, 1 = active high */
+                               linux,default-trigger = "none"; /* default-on */
+                       };
+                       relay2: relay@2 {
+                               label = "relay2";
+                               gpios = <&gpio 16 1>;
+                       };
+                       relay3: relay@3 {
+                               label = "relay3";
+                               gpios = <&gpio 20 1>;
+                       };
+                       relay4: relay@4 {
+                               label = "relay4";
+                               gpios = <&gpio 21 1>;
+                       };
+               };
+       };
+};