summaryrefslogtreecommitdiffstats
path: root/target
diff options
context:
space:
mode:
authorMathew McBride <matt@traverse.com.au>2024-04-01 14:44:47 +1100
committerDaniel Golle <daniel@makrotopia.org>2024-05-07 13:01:20 +0100
commitffbc4c897fe643845bdf9746be7335938db374e4 (patch)
tree9d5689152125a7e7195c38081c14ed62ca9683d8 /target
parent5f609d8960f0ad4f5bd59a69facaeb2739c6e625 (diff)
downloadopenwrt-ffbc4c897fe643845bdf9746be7335938db374e4.tar.gz
openwrt-ffbc4c897fe643845bdf9746be7335938db374e4.tar.bz2
openwrt-ffbc4c897fe643845bdf9746be7335938db374e4.zip
base-files: armsr: add script to migrate GPIO switches on Ten64 board
Due to a change in kernel 6.2, the GPIO numbers on certain architectures (including arm64) have changed. This script will update any defined GPIO switches to the new numbering. See https://lists.openwrt.org/pipermail/openwrt-devel/2024-March/042448.html for more information. In the future, the GPIO switch mechanism will likely be replaced with something using libgpiod. Signed-off-by: Mathew McBride <matt@traverse.com.au>
Diffstat (limited to 'target')
-rw-r--r--target/linux/armsr/base-files/etc/uci-defaults/05-migrate-ten64-gpio37
1 files changed, 37 insertions, 0 deletions
diff --git a/target/linux/armsr/base-files/etc/uci-defaults/05-migrate-ten64-gpio b/target/linux/armsr/base-files/etc/uci-defaults/05-migrate-ten64-gpio
new file mode 100644
index 0000000000..dc8648e570
--- /dev/null
+++ b/target/linux/armsr/base-files/etc/uci-defaults/05-migrate-ten64-gpio
@@ -0,0 +1,37 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+# This script migrates GPIO switch pin numbers
+# from kernel versions prior to 6.6
+# See https://lists.openwrt.org/pipermail/openwrt-devel/2024-March/042448.html
+
+. /lib/functions.sh
+
+ten64_update_gpioswitch_num() {
+ local section="$1"
+ config_get gpio_pin "${section}" gpio_pin
+ config_get gpio_name "${section}" name
+ if [ -z "${gpio_pin}" ]; then
+ return
+ fi
+ local this_pin_name=$(uci get "system.${section}.name")
+ if [ "${gpio_pin}" -lt 640 ]; then
+ new_pin_value=$(( $gpio_pin + 272 ))
+ uci set "system.${section}.gpio_pin=${new_pin_value}"
+ fi
+}
+
+board=$(board_name)
+if [ "${board}" != "traverse,ten64" ]; then
+ exit 0
+fi
+
+KERNEL_MINOR=$(uname -r | awk -F '.' '{print $2}')
+if [ "${KERNEL_MINOR}" -lt "6" ]; then
+ exit 0
+fi
+
+config_load system
+config_foreach ten64_update_gpioswitch_num gpio_switch
+
+exit 0 \ No newline at end of file