From 2947896e00850272acf4c8ca494f520c800081c9 Mon Sep 17 00:00:00 2001 From: jklug Date: Thu, 28 Jul 2016 14:02:52 -0500 Subject: Add user space reset of WiFi Bluetooth and driver status. --- recipes-bsp/multitech/mts-io/mts-io.init | 42 ++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/recipes-bsp/multitech/mts-io/mts-io.init b/recipes-bsp/multitech/mts-io/mts-io.init index f27415c..e770f90 100644 --- a/recipes-bsp/multitech/mts-io/mts-io.init +++ b/recipes-bsp/multitech/mts-io/mts-io.init @@ -1,15 +1,28 @@ #!/bin/bash sysdir=/sys/devices/platform/mts-io +gpiodir=/sys/class/gpio +RS9113RST=${sysdir}/wifi-bt-reset + +reset_rs9113() { + /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}" + fi + fi +} read_card_info() { ap1_product_id="" ap2_product_id="" + mts_hw_version="" - if [ -d $sysdir/ap1 ]; then + if [[ -d $sysdir/ap1 ]]; then ap1_product_id=$(cat $sysdir/ap1/product-id) fi - if [ -d $sysdir/ap2 ]; then + if [[ -d $sysdir/ap2 ]]; then ap2_product_id=$(cat $sysdir/ap2/product-id) fi } @@ -17,18 +30,18 @@ read_card_info() { mfser_init() { found_ap1=0 - if [[ "$ap1_product_id" =~ ^MTAC-MFSER- ]]; then - echo "mts-io: Linking /dev/mfser to /dev/ttyAP1" + 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 [[ $ap2_product_id =~ ^MTAC-MFSER- ]]; then if [[ $found_ap1 = 1 ]]; then - echo "mts-io: Linking /dev/mfser-2 to /dev/ttyAP2" + /usr/bin/logger -t "mts-io" -p info -s "Linking /dev/mfser-2 to /dev/ttyAP2" ln -sf /dev/ttyAP2 /dev/mfser-2 else - echo "mts-io: Linking /dev/mfser to /dev/ttyAP2" + /usr/bin/logger -t "mts-io" -p info -s "Linking /dev/mfser to /dev/ttyAP2" ln -sf /dev/ttyAP2 /dev/mfser fi fi @@ -37,17 +50,26 @@ mfser_init() { case $1 in start) - echo "Loading mts-io module" + /usr/bin/logger -t "mts-io" -p info -s "Loading mts-io module" modprobe mts_io read_card_info + reset_rs9113 mfser_init ;; stop) - echo "Unloading mts-io module" + /usr/bin/logger -t "mts-io" -p info -s "Unloading mts-io module" modprobe -r mts_io ;; - + 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}" exit 2 -- cgit v1.2.3