[openwrt/openwrt] base-files: armsr: number Ten64 GPIOs according to kernel version

LEDE Commits lede-commits at lists.infradead.org
Tue May 7 05:02:32 PDT 2024


dangole pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/5f609d8960f0ad4f5bd59a69facaeb2739c6e625

commit 5f609d8960f0ad4f5bd59a69facaeb2739c6e625
Author: Mathew McBride <matt at traverse.com.au>
AuthorDate: Mon Mar 18 13:03:55 2024 +1100

    base-files: armsr: number Ten64 GPIOs according to kernel version
    
    A change in kernel 6.2[1] caused the base numbers of GPIOs to
    change significantly on some architectures like aarch64.
    
    We have to number our GPIOs accordingly.
    Ideally the board.d scripts should look through sysfs
    to find the basenum (like cat "/sys/devices/platform/soc/2000000.i2c/
    i2c-0/0-0076/gpio/gpiochip640/base"), but the problem is
    that this occurs before modules are loaded, meaning I2C and other
    runtime devices may be missing.
    
    Signed-off-by: Mathew McBride <matt at traverse.com.au>
    
    [1] https://lore.kernel.org/lkml/cover.1662116601.git.christophe.leroy@csgroup.eu/T/
---
 .../armsr/base-files/etc/board.d/03_gpio_switches    | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/target/linux/armsr/base-files/etc/board.d/03_gpio_switches b/target/linux/armsr/base-files/etc/board.d/03_gpio_switches
index cf07bc0f54..72f310277a 100644
--- a/target/linux/armsr/base-files/etc/board.d/03_gpio_switches
+++ b/target/linux/armsr/base-files/etc/board.d/03_gpio_switches
@@ -3,18 +3,26 @@
 
 . /lib/functions/uci-defaults.sh
 
+KERNEL_MAJOR=$(uname -r | awk -F '.' '{print $1}')
+KERNEL_MINOR=$(uname -r | awk -F '.' '{print $2}')
+
 board_config_update
 
 board=$(board_name)
 
 case "$board" in
 traverse,ten64)
-	ucidef_add_gpio_switch "lte_reset" "Cell Modem Reset" "376"
-	ucidef_add_gpio_switch "lte_power" "Cell Modem Power" "377"
-	ucidef_add_gpio_switch "lte_disable" "Cell Modem Airplane mode" "378"
-	ucidef_add_gpio_switch "gnss_disable" "Cell Modem Disable GNSS receiver" "379"
-	ucidef_add_gpio_switch "lower_sfp_txidsable" "Lower SFP+ TX Disable" "369"
-	ucidef_add_gpio_switch "upper_sfp_txdisable" "Upper SFP+ TX Disable" "373"
+	if [ "${KERNEL_MAJOR}" -ge "6" ] && [ "${KERNEL_MINOR}" -ge "6" ]; then
+		I2C_GPIO_BASE=640
+	else
+		I2C_GPIO_BASE=368
+	fi
+	ucidef_add_gpio_switch "lte_reset" "Cell Modem Reset" "$(($I2C_GPIO_BASE + 8))"
+	ucidef_add_gpio_switch "lte_power" "Cell Modem Power" "$(($I2C_GPIO_BASE + 9))"
+	ucidef_add_gpio_switch "lte_disable" "Cell Modem Airplane mode" "$((I2C_GPIO_BASE + 10))"
+	ucidef_add_gpio_switch "gnss_disable" "Cell Modem Disable GNSS receiver" "$(($I2C_GPIO_BASE + 11))"
+	ucidef_add_gpio_switch "lower_sfp_txidsable" "Lower SFP+ TX Disable" "$(($I2C_GPIO_BASE + 1))"
+	ucidef_add_gpio_switch "upper_sfp_txdisable" "Upper SFP+ TX Disable" "$(($I2C_GPIO_BASE + 5))"
 	;;
 esac
 




More information about the lede-commits mailing list