summaryrefslogtreecommitdiff
path: root/recipes-bsp
diff options
context:
space:
mode:
authorjklug <jklug@jklugUB14LTS>2016-07-29 12:07:31 -0500
committerjklug <jklug@jklugUB14LTS>2016-07-29 12:07:31 -0500
commitb073fb71800a2ed16a8585b801603a1a196b737f (patch)
tree25d956569e729087d5f8f36ce14b4f1497390aad /recipes-bsp
parent28e453540f0b0882ddda8557bf2fa25e9f81de08 (diff)
downloadmeta-multitech-b073fb71800a2ed16a8585b801603a1a196b737f.tar.gz
meta-multitech-b073fb71800a2ed16a8585b801603a1a196b737f.tar.bz2
meta-multitech-b073fb71800a2ed16a8585b801603a1a196b737f.zip
Jesse Gilles bitbake layer for the RS9113
Diffstat (limited to 'recipes-bsp')
-rwxr-xr-xrecipes-bsp/multitech/mts-io/mts-io163
1 files changed, 163 insertions, 0 deletions
diff --git a/recipes-bsp/multitech/mts-io/mts-io b/recipes-bsp/multitech/mts-io/mts-io
new file mode 100755
index 0000000..565b1a7
--- /dev/null
+++ b/recipes-bsp/multitech/mts-io/mts-io
@@ -0,0 +1,163 @@
+#!/bin/bash
+### BEGIN INIT INFO
+# Provides: mts-io
+# Default-Start: 2345
+# Default-Stop: 016
+# Short-Description: load the mts-io driver
+# Description: mts-io driver initializes the Conduit hardware and
+# provides user mode access through the driver to the
+# Conduit features.
+### END INIT INFO
+
+((fail=0))
+
+sysdir=/sys/devices/platform/mts-io
+gpiodir=/sys/class/gpio
+
+USBRST=${sysdir}/usbhub-reset
+
+RST[0]="${sysdir}/mtq-reset"
+RST[1]="${sysdir}/ap1-reset"
+RST[2]="${sysdir}/ap2-reset"
+RST[3]="${sysdir}/gnss-reset"
+RST[4]="${sysdir}/radio-reset"
+RST[5]="${sysdir}/secure-reset"
+RST[6]="${sysdir}/eth-reset"
+#RST[7]="${sysdir}/wifi-bt-reset"
+RS9113RST="${sysdir}/wifi-bt-reset"
+
+USLPTIME=30000 # 30 milliseconds
+WAIT="/bin/busybox usleep ${USLPTIME}"
+
+reset_path() {
+ pin=$1
+ /usr/bin/logger -t "mts-io" -p info Reset $pin
+
+ if [[ -f ${pin} ]] ; then
+ if ! ( (echo 1 >${pin}) && (echo 0 >${pin}) && ${WAIT} && (echo 1 >${pin}) ) ; then
+ /usr/bin/logger -t "mts-io" -p error -s "Failed write to ${pin}"
+ fi
+ else
+ /usr/bin/logger -t "mts-io" -p error -s "${pin} does not exist"
+ return 1
+ fi
+ return 0
+}
+reset_array() {
+ ((i=${#RST[@]}-1))
+ while ((i>=0)) ; do
+ if [[ -f ${RST[$i]} ]] ; then
+ if ! ( (echo 1 >${RST[i]}) ) ; then
+ /usr/bin/logger -t "mts-io" -p error -s "Failed write to ${RST[$i]}"
+ fi
+ else
+ /usr/bin/logger -t "mts-io" -p info -s "${RST[$i]} does not exist"
+ RST[$i]=""
+ fi
+ ((i--))
+ done
+ while ((i>0)) ; do
+ if ((${#RST[$i] > 0)) && [[ -f ${RST[$i]} ]] ; then
+ if ! ( (echo 0 >${RST[i]}) ) ; then
+ /usr/bin/logger -t "mts-io" -p error -s "Failed write to ${RST[$i]}"
+ fi
+ else
+ /usr/bin/logger -t "mts-io" -p info -s "${RST[$i]} does not exist"
+ fi
+ done
+ ${WAIT}
+ while ((i>0)) ; do
+ if ((${#RST[$i] > 0)) && [[ -f ${RST[$i]} ]] ; then
+ if ! ( (echo 1 >${RST[i]}) ) ; then
+ /usr/bin/logger -t "mts-io" -p error -s "Failed write to ${RST[$i]}"
+ fi
+ else
+ /usr/bin/logger -t "mts-io" -p info -s "${RST[$i]} does not exist"
+ fi
+ done
+}
+read_card_info() {
+ ap1_product_id=""
+ ap2_product_id=""
+ mts_hw_version=""
+
+ if [[ -d $sysdir/ap1 ]]; then
+ ap1_product_id=$(cat $sysdir/ap1/product-id)
+ fi
+ if [[ -d $sysdir/ap2 ]]; then
+ ap2_product_id=$(cat $sysdir/ap2/product-id)
+ fi
+}
+
+mfser_init() {
+ found_ap1=0
+
+ if [[ $ap1_product_id =~ ^MTAC-MFSER- ]]; then
+ /usr/bin/logger -t "mts-io" -p info -s "Linking /dev/mfser to /dev/ttyAP1"
+ ln -sf /dev/ttyAP1 /dev/mfser
+ found_ap1=1
+ fi
+
+ if [[ $ap2_product_id =~ ^MTAC-MFSER- ]]; then
+ if [[ $found_ap1 = 1 ]]; then
+ /usr/bin/logger -t "mts-io" -p info -s "Linking /dev/mfser-2 to /dev/ttyAP2"
+ ln -sf /dev/ttyAP2 /dev/mfser-2
+ else
+ /usr/bin/logger -t "mts-io" -p info -s "Linking /dev/mfser to /dev/ttyAP2"
+ ln -sf /dev/ttyAP2 /dev/mfser
+ fi
+ fi
+
+}
+
+case $1 in
+ start)
+ /usr/bin/logger -t "mts-io" -p info -s "Loading mts-io module"
+ if ! modprobe mts_io ; then
+ ((fail++))
+ fi
+ read_card_info
+ if ! reset_path $USBRST ; then
+ ((fail++))
+ fi
+ usleep 200
+ reset_array
+ mfser_init
+ if ! reset_path $RS9113RST ; then
+ ((fail++))
+ fi
+
+ if ((fail == 0)) ; then
+ echo "OK"
+ else
+ echo "FAIL"
+ fi
+ exit $fail
+ ;;
+
+ stop)
+ /usr/bin/logger -t "mts-io" -p info -s "Unloading mts-io module"
+ modprobe -r mts_io
+ RETVAL=$?
+ if ((RETVAL == 0)) ; then
+ echo "OK"
+ else
+ echo "FAIL"
+ fi
+ ;;
+ status)
+ if [[ -d ${sysdir} ]] ; then
+ echo Driver is loaded
+ exit 0
+ else
+ echo Driver is not loaded
+ exit 3
+ fi
+ ;;
+ *)
+ echo "Usage: $0 {start|stop|status}"
+ exit 2
+ ;;
+esac
+
+