summaryrefslogtreecommitdiff
path: root/recipes-kernel/rs9113/files/rs9113/rs9113.init
diff options
context:
space:
mode:
Diffstat (limited to 'recipes-kernel/rs9113/files/rs9113/rs9113.init')
-rwxr-xr-xrecipes-kernel/rs9113/files/rs9113/rs9113.init100
1 files changed, 100 insertions, 0 deletions
diff --git a/recipes-kernel/rs9113/files/rs9113/rs9113.init b/recipes-kernel/rs9113/files/rs9113/rs9113.init
new file mode 100755
index 0000000..4ef6f4b
--- /dev/null
+++ b/recipes-kernel/rs9113/files/rs9113/rs9113.init
@@ -0,0 +1,100 @@
+#!/bin/bash
+# Note that none of the INIT stuff below works in the current open-embedded.
+### BEGIN INIT INFO
+# Provides: rs9113
+# Required-Start: mts-io
+# Default-Start: S
+# Default-Stop: 0 6
+# X-Start-Before: networking
+# Short-Description: load the rs9113 drivers
+# Description: rs9113 drivers are used to provide access to Bluetooth
+# and WiFi.
+### END INIT INFO
+
+CONFIG=${CONFIG:-/etc/default/rs9113}
+MTS_IODIR=/sys/devices/platform/mts-io
+RS9113_RESET=${MTS_IODIR}/wifi-bt-reset
+RS9113_INT=${MTS_IODIR}/wifi-bt-int
+RS9113_WKUP=${MTS_IODIR}/wifi-bt-lpwkup
+
+[ -f $CONFIG ] || exit 1
+
+. $CONFIG
+
+case "$1" in
+ start)
+ if ((RS9113_LOAD == 0)) ; then
+ # We don't want the driver loaded.
+ exit 0
+ fi
+ # Reset the RS9113 chip is ready, and
+ # wait for it to settle.
+ if [ -f "$RS9113_RESET" ] ; then
+ echo 1 >$RS9113_RESET
+ usleep $SLEEPTIME
+ echo 0 >$RS9113_RESET
+ usleep $SLEEPTIME
+ echo 1 >$RS9113_RESET
+ N=1
+ while [ $N -lt 20 ] ; do
+ INT=$(cat $RS9113_INT)
+ WKUP=$(cat $RS9113_WKUP)
+ if [ $INT -ne 1 -o $WKUP -ne 1 ] ; then
+ usleep $INTSLEEPTIME
+ else
+ break
+ fi
+ done
+ if [ $INT -ne 1 ] ; then
+ logger -t rs9113 -p error -s "$RS9113_INT is $INT"
+ fi
+ if [ $WKUP -ne 1 ] ; then
+ logger -t rs9113 -p error -s "$RS9113_WKUP is $WKUP"
+ fi
+ else
+ # No WiFi BT, so exit quietly
+ exit 0
+ fi
+ /usr/bin/logger -t "rs9113" -p info -s "Loading rs9113 modules with COEX=$COEX_MODE and Country=$SET_COUNTRY_CODE"
+ /usr/sbin/rs9113_load_modules.sh $CONFIG
+ RETVAL=$?
+ if [ $RETVAL -eq 0 ] ; then
+ echo "OK"
+ else
+ echo "FAIL"
+ fi
+ ;;
+
+ stop)
+ /usr/bin/logger -t "rs9113" -p info -s "Unloading rs9113 modules"
+ /usr/sbin/rs9113_remove_modules.sh
+ RETVAL=$?
+ if [ $RETVAL -eq 0 ] ; then
+ echo "OK"
+ else
+ echo "FAIL"
+ fi
+ ;;
+ restart)
+ $0 stop
+ sleep 1
+ $0 start
+ ;;
+ status)
+ for dir in /sys/class/net/rpine[0-9]* ; do
+ if [[ -d ${dir} ]] ; then
+ echo Driver is loaded
+ exit 0
+ fi
+ done
+ echo Driver is not loaded
+ exit 3
+ ;;
+ *)
+ "Usage: $0 {start|stop|status|restart}"
+ exit 2
+ ;;
+esac
+
+exit 0
+