summaryrefslogtreecommitdiff
path: root/recipes-bsp/multitech/mts-io
diff options
context:
space:
mode:
Diffstat (limited to 'recipes-bsp/multitech/mts-io')
-rw-r--r--recipes-bsp/multitech/mts-io/mts-io.init45
1 files changed, 41 insertions, 4 deletions
diff --git a/recipes-bsp/multitech/mts-io/mts-io.init b/recipes-bsp/multitech/mts-io/mts-io.init
index 52c6d1f..048c697 100644
--- a/recipes-bsp/multitech/mts-io/mts-io.init
+++ b/recipes-bsp/multitech/mts-io/mts-io.init
@@ -19,6 +19,9 @@ else
LOGDBG=":"
fi
+SYSFS="/usr/sbin/mts-io-sysfs"
+LRST="/usr/sbin/mts-util-lora2-reset"
+
${LOGDBG} -p daemon.info 'mts-io script'
sysdir=/sys/devices/platform/mts-io
gpiodir=/sys/class/gpio
@@ -26,6 +29,11 @@ port1=${sysdir}/ap1
port2=${sysdir}/ap2
USBRST=${sysdir}/usbhub-reset
+NEED_I2C_RESET=0
+HWVER=""
+HWNAME=""
+HWLVL=""
+
RST[0]="${sysdir}/wifi-bt-reset"
RST[1]="${sysdir}/mtq-reset"
@@ -144,8 +152,8 @@ read_card_info() {
ap2_product_id=$(cat $sysdir/ap2/product-id)
fi
- lora_hw=$(mts-io-sysfs show lora/hw-version 2> /dev/null)
-
+ lora_hw=$(${SYSFS} show lora/hw-version 2> /dev/null)
+
if [ -d $port1 ] && [[ $(cat $port1/hw-version) = $lora_hw ]]; then
ln -sf /dev/spidev32766.2 /dev/spidev0.0
elif [ -d $port2 ] && [[ $(cat $port2/hw-version) = $lora_hw ]]; then
@@ -174,17 +182,38 @@ mfser_init() {
}
+set_gpslink() {
+ hw=$(${SYSFS} show hw-version)
+ hw_name=(${hw//-/ })
+
+ if ! [[ ${hw} =~ ^MTCDT ]] ; then
+ # No GPS (unless MTR, and that is TBD)
+ return
+ fi
+ if [[ ${hw} == MTCDT ]] && [[ ${HWLVL} == 0.0 ]] ; then
+ # No GPS
+ return
+ fi
+ if [[ ${hw_name} == MTCDTIPHP ]] ; then
+ NEED_I2C_RESET=1
+ ln -sf /dev/ttyXRUSB0 /dev/gps0
+ return
+ fi
+ ln -sf /dev/ttyXRUSB2 /dev/gps0
+}
+
case $1 in
start)
/usr/bin/logger -t "mts-io" -p daemon.info -s "Loading mts-io module"
if ! modprobe mts_io ; then
((fail++))
fi
+ set_gpslink # Set GPS symlink.
/usr/bin/logger -t "mts-io" -p daemon.info -s "Resetting system modules"
read_card_info
/bin/busybox usleep $USLPTIME
reset_array
- [ -w /sys/devices/platform/mts-io/radio-reset ] && mts-io-sysfs store radio-reset 0
+ [ -w ${sysdir}/radio-reset ] && ${SYSFS} store radio-reset 0
mfser_init
waitpins
@@ -193,6 +222,14 @@ case $1 in
if ! reset_path $USBRST ; then
((fail++))
fi
+
+ if ((${#lora_hw} > 0)) && [[ ${lora_hw} =~ ^MTCDTIPHP-LORA-2\.1 ]] ; then
+ if [[ -x ${LRST} ]] ; then
+ ${LRST} -g -f
+ else
+ /usr/bin/logger -t "mts-io" -p daemon.err -s "ERROR: Missing ${LRST} -- Cannot initialize LoRa."
+ fi
+ fi
if ((fail == 0)) ; then
echo "OK"
@@ -224,7 +261,7 @@ case $1 in
fi
/bin/busybox usleep $USLPTIME
reset_array
- mts-io-sysfs store radio-reset 0
+ ${SYSFS} store radio-reset 0
mfser_init
if ((fail == 0)) ; then
echo "OK"