From 978c785494031a90fd8b5d414d5d2e29378b6f90 Mon Sep 17 00:00:00 2001 From: jklug Date: Fri, 29 Jul 2016 10:02:30 -0500 Subject: Reset the conduit systems -- first USB hub, then the others. --- recipes-bsp/multitech/mts-io/mts-io.init | 74 +++++++++++++++++++++++++++++--- 1 file changed, 67 insertions(+), 7 deletions(-) mode change 100644 => 100755 recipes-bsp/multitech/mts-io/mts-io.init diff --git a/recipes-bsp/multitech/mts-io/mts-io.init b/recipes-bsp/multitech/mts-io/mts-io.init old mode 100644 new mode 100755 index e770f90..24b891d --- a/recipes-bsp/multitech/mts-io/mts-io.init +++ b/recipes-bsp/multitech/mts-io/mts-io.init @@ -1,18 +1,72 @@ #!/bin/bash +fail=0 + sysdir=/sys/devices/platform/mts-io gpiodir=/sys/class/gpio -RS9113RST=${sysdir}/wifi-bt-reset +USBRST=${sysdir}/usbhub-reset + +RST[0]="${sysdir}/wifi-bt-reset" +RST[1]="${sysdir}/ap1-reset" +RST[2]="${sysdir}/ap2-reset" +RST[3]="${sysdir}/gnss-reset" +RST[4]="${sysdir}/radio-reset" +RST[5]="${sysdir}/ap2-reset" +RST[6]="${sysdir}/ap2-reset" +RST[7]="${sysdir}/mtq-reset" +RST[8]="${sysdir}/secure-reset" +RST[9]="${sysdir}/eth-reset" +RST[10]="${sysdir}/mtq-reset" + +USLPTIME=30000 # 30 milliseconds +WAIT="/bin/busybox usleep ${USLPTIME}" -reset_rs9113() { +reset_usb() { /usr/bin/logger -t "mts-io" -p info Reset the WiFi Bluetooth device - if [[ -f ${RS9113RST} ]] ; then - if ! ( (echo 1 >${RS9113RST}) && (echo 0 >${RS9113RST}) && (echo 1 >${RS9113RST}) ) ; then - /usr/bin/logger -t "mts-io" -p error -s "Failed write to ${RS9113RST}" + if [[ -f ${USBRST} ]] ; then + if ! ( (echo 1 >${USBRST}) && (echo 0 >${USBRST}) && ${WAIT} && (echo 1 >${USBRST}) ) ; then + /usr/bin/logger -t "mts-io" -p error -s "Failed write to ${USBRST}" fi + else + /usr/bin/logger -t "mts-io" -p error -s "${USBRST} 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="" @@ -51,10 +105,16 @@ mfser_init() { case $1 in start) /usr/bin/logger -t "mts-io" -p info -s "Loading mts-io module" - modprobe mts_io + if ! modprobe mts_io ; then + ((fail++)) + fi read_card_info - reset_rs9113 + if ! reset_usb ; then + ((fail++)) + fi + reset_array mfser_init + exit $fail ;; stop) -- cgit v1.2.3