From 50853e54d335f649e46b9d1800ad405af42e177c Mon Sep 17 00:00:00 2001
From: Benjamin Larsson <benjamin.larsson@iopsys.eu>
Date: Tue, 5 May 2020 16:44:28 +0200
Subject: [PATCH] panther: add support for setting gpio pins to fixed values

---
 .../base-files/lib/db/boards/FT-P3410B          |  1 +
 .../base-files/lib/db/boards/XG6846B            |  2 ++
 .../panther/base-files/etc/init.d/hw_setup      | 17 +++++++++++++++++
 3 files changed, 20 insertions(+)
 create mode 100644 iopsys-brcm63xx-arm/panther/base-files/etc/init.d/hw_setup

diff --git a/iopsys-brcm63xx-arm/base-files/lib/db/boards/FT-P3410B b/iopsys-brcm63xx-arm/base-files/lib/db/boards/FT-P3410B
index e7ea0a1b2..b314cff9d 100644
--- a/iopsys-brcm63xx-arm/base-files/lib/db/boards/FT-P3410B
+++ b/iopsys-brcm63xx-arm/base-files/lib/db/boards/FT-P3410B
@@ -19,6 +19,7 @@ config board 'board'
 	option ethernetPortNames 'LAN1 LAN2 LAN3 LAN4 WAN'
 	option ethernetPortOrder 'eth0 eth1 eth2 eth3 eth4'
 	option ethernetLanPorts 'eth0 eth1 eth2 eth3'
+	option gpio_one '67 40 22'
 
 ###############################################################################
 #               Button config, start
diff --git a/iopsys-brcm63xx-arm/base-files/lib/db/boards/XG6846B b/iopsys-brcm63xx-arm/base-files/lib/db/boards/XG6846B
index 3ba05c292..d46da86d6 100644
--- a/iopsys-brcm63xx-arm/base-files/lib/db/boards/XG6846B
+++ b/iopsys-brcm63xx-arm/base-files/lib/db/boards/XG6846B
@@ -21,6 +21,8 @@ config board 'board'
 	option ethernetPortNames 'LAN1 LAN2 LAN3 LAN4 LAN5 WAN'
 	option ethernetPortOrder 'eth0 eth1 eth2 eth3 eth4 eth5'
 	option ethernetLanPorts 'eth0 eth1 eth2 eth3 eth4'
+	option gpio_zero '0 1 3 67'
+	option gpio_one '2 40'
 
 ###############################################################################
 #               Button config, start
diff --git a/iopsys-brcm63xx-arm/panther/base-files/etc/init.d/hw_setup b/iopsys-brcm63xx-arm/panther/base-files/etc/init.d/hw_setup
new file mode 100644
index 000000000..c75a7184d
--- /dev/null
+++ b/iopsys-brcm63xx-arm/panther/base-files/etc/init.d/hw_setup
@@ -0,0 +1,17 @@
+#!/bin/sh /etc/rc.common
+
+START=19
+USE_PROCD=1
+
+boot() {
+        # set static gpios
+        # one
+        for gpio in $(db -q get hw.board.gpio_one); do
+                brcm_fw_tool set -x $gpio -p 1 >/dev/null
+        done
+        # zero
+        for gpio in $(db -q get hw.board.gpio_zero); do
+                brcm_fw_tool set -x $gpio -p 0 >/dev/null
+        done
+}
+
-- 
GitLab