summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--recipes-bsp/multitech/mts-io/mts-io.mtcap.init24
1 files changed, 24 insertions, 0 deletions
diff --git a/recipes-bsp/multitech/mts-io/mts-io.mtcap.init b/recipes-bsp/multitech/mts-io/mts-io.mtcap.init
index e54dd2f..2642de9 100644
--- a/recipes-bsp/multitech/mts-io/mts-io.mtcap.init
+++ b/recipes-bsp/multitech/mts-io/mts-io.mtcap.init
@@ -4,6 +4,9 @@ sysdir=/sys/devices/platform/mts-io
i2c=/sys/bus/i2c/devices/
+DEVTREE="/sys/kernel/config/device-tree/overlays/"
+SYSFS="/usr/sbin/mts-io-sysfs"
+
setwificap() {
WIFICAP=0
if [[ -f ${sysdir}/capability/wifi ]] && (($(cat ${sysdir}/capability/wifi) == 1)) ; then
@@ -60,6 +63,26 @@ start_lora_led_updater() {
lora-led-updater &
}
+setdevtree() {
+ hw=$(${SYSFS} show hw-version)
+
+ # add device tree overlays, if they exist.
+ [[ -d /lib/dtoverlays ]] || return 1
+ (
+ cd /lib/dtoverlays
+ for f in $(ls ${hw}*) ; do
+ if ! [[ -d ${DEVTREE} ]] ; then
+ mount configfs
+ fi
+ f1=${f/#${hw}-/}
+ f2=${f1/%.dtbo}
+ # f2 is the extracted device name
+ /bin/mkdir ${DEVTREE}/$f2
+ /bin/cat $f >${DEVTREE}/$f2/dtbo
+ done
+ )
+}
+
case $1 in
start)
# SPI driver for LoRa
@@ -71,6 +94,7 @@ case $1 in
# Point the firmware API at our i2c EEPROMs
echo -n ${i2c} > /sys/module/firmware_class/parameters/path
modprobe mts_io
+ setdevtree
setwificap
wifi_init1
lora_init