summaryrefslogtreecommitdiff
path: root/recipes-bsp/multitech/mts-io
diff options
context:
space:
mode:
authorJohn Klug <john.klug@multitech.com>2018-10-15 18:52:09 -0500
committerJohn Klug <john.klug@multitech.com>2018-10-15 18:52:09 -0500
commit93302bee4658d43747e953f3b77829f26fa85e61 (patch)
treeaebbf458f4f41c548345d6168fa2b72e586ef68f /recipes-bsp/multitech/mts-io
parent3212a35810c656e1db1350522f3f1277b1b88d06 (diff)
downloadmeta-multitech-93302bee4658d43747e953f3b77829f26fa85e61.tar.gz
meta-multitech-93302bee4658d43747e953f3b77829f26fa85e61.tar.bz2
meta-multitech-93302bee4658d43747e953f3b77829f26fa85e61.zip
Split mts-io driver module into separate modules.
Diffstat (limited to 'recipes-bsp/multitech/mts-io')
-rw-r--r--recipes-bsp/multitech/mts-io/mts-io.init64
1 files changed, 56 insertions, 8 deletions
diff --git a/recipes-bsp/multitech/mts-io/mts-io.init b/recipes-bsp/multitech/mts-io/mts-io.init
index a4a464e..03a4590 100644
--- a/recipes-bsp/multitech/mts-io/mts-io.init
+++ b/recipes-bsp/multitech/mts-io/mts-io.init
@@ -19,6 +19,31 @@ else
LOGDBG=":"
fi
+hw=""
+hw_name=""
+MTAC_MODULES=""
+((HASAP=0))
+
+sethwtype() {
+ # mts-io must be loaded before trying this
+ hw=$(${SYSFS} show hw-version)
+ hw_name=(${hw//-/ })
+
+ # Only MTCDT and MTCDTIP have accessory cards, and
+ # MTCDTIPHP does not have accessory cards.
+ ((HASAP==0))
+ case $hw_name in
+ MTCDTIPHP)
+ ;;
+ MTCDT|MTCDTIP)
+ ((HASAP = 1))
+ ;;
+ *)
+ ;;
+ esac
+ MTAC_MODULES=$(cd /lib/modules/$(uname -r)/extra/;ls mtac_* 2>/dev/null)
+}
+
SYSFS="/usr/sbin/mts-io-sysfs"
LRST="/usr/sbin/mts-util-lora2-reset"
@@ -183,14 +208,9 @@ mfser_init() {
}
set_gpslink() {
- hw=$(${SYSFS} show hw-version)
- # hw_name is the hw-version before the hyphen.
- hw_name=(${hw//-/ })
gpscap=$(cat ${sysdir}/capability/gps)
- # For all hardware except MTCDTIPHP, the gpscapability
- # flag indicates whether or not we have a GPS.
- if [[ ${hw_name} != MTCDTIPHP ]] && ((gpscap == 0)) ; then
+ if ((gpscap == 0)) ; then
return
fi
@@ -204,6 +224,10 @@ set_gpslink() {
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
@@ -219,6 +243,17 @@ case $1 in
if ! modprobe mts_io ; then
((fail++))
fi
+
+ sethwtype
+
+ if ((HASAP == 1)) ; then
+ # install mtac explicitly or any unused modules will cause
+ # junk to the log as mtac is loaded and unloaded each time.
+ modprobe mtac
+ for f in ${MTAC_MODULES} ; do
+ modprobe ${f//.ko} 2>&1 | grep -v 'No such device or address'
+ done
+ fi
set_gpslink # Set GPS symlink.
/usr/bin/logger -t "mts-io" -p daemon.info -s "Resetting system modules"
read_card_info
@@ -251,8 +286,21 @@ case $1 in
;;
stop)
- /usr/bin/logger -t "mts-io" -p daemon.info -s "Unloading mts-io module"
- modprobe -r mts_io
+ /usr/bin/logger -t "mts-io" -p daemon.info -s "Unloading mtac modules and mts-io module"
+ MTAC_MODULES=$(lsmod | grep '^mtac_' | sed -e 's/_/-/' -e 's/ .*//')
+
+ for f in ${MTAC_MODULES} ; do
+ if ! modprobe -r "$f" ; then
+ rmmod "$f"
+ fi
+ done
+ if ! modprobe -r mtac ; then
+ rmmod mtac
+ fi
+
+ if ! modprobe -r mts-io ; then
+ rmmod mtsio
+ fi
RETVAL=$?
if ((RETVAL == 0)) ; then
echo "OK"