summaryrefslogtreecommitdiff
path: root/recipes-kernel/rsi-91x/files/rs9113.init
diff options
context:
space:
mode:
authorJohn Klug <john.klug@multitech.com>2022-12-12 19:04:30 -0600
committerJohn Klug <john.klug@multitech.com>2023-01-10 16:42:56 -0600
commit7b5feeca46ea9eecc2d20b95cbcddba4fb5cc286 (patch)
tree5892196b5c80acdd087ac9a547553104d240ec0c /recipes-kernel/rsi-91x/files/rs9113.init
parentf8423158593151b0c934040b945129bb88d22f74 (diff)
downloadmeta-multitech-atmel-7b5feeca46ea9eecc2d20b95cbcddba4fb5cc286.tar.gz
meta-multitech-atmel-7b5feeca46ea9eecc2d20b95cbcddba4fb5cc286.tar.bz2
meta-multitech-atmel-7b5feeca46ea9eecc2d20b95cbcddba4fb5cc286.zip
Start of rsi-91x driver
Diffstat (limited to 'recipes-kernel/rsi-91x/files/rs9113.init')
-rwxr-xr-xrecipes-kernel/rsi-91x/files/rs9113.init130
1 files changed, 130 insertions, 0 deletions
diff --git a/recipes-kernel/rsi-91x/files/rs9113.init b/recipes-kernel/rsi-91x/files/rs9113.init
new file mode 100755
index 0000000..2eb7697
--- /dev/null
+++ b/recipes-kernel/rsi-91x/files/rs9113.init
@@ -0,0 +1,130 @@
+#!/bin/bash
+# Note that none of the INIT stuff below works in the current open-embedded.
+### BEGIN INIT INFO
+# Provides: rs9116
+# Required-Start: mts-io
+# Default-Start: S
+# Default-Stop: 0 6
+# X-Start-Before: networking
+# Short-Description: load the rs9116 drivers
+# Description: rs9116 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
+RS9116_RESET=${MTS_IODIR}/wifi-bt-reset
+
+[ -f $CONFIG ] || exit 1
+
+. $CONFIG
+
+pid=$$
+LOG_ERR=3
+LOG_INFO=6
+name=rs9116
+format="%s[%d] %12.2fs: %s"
+function has_reset {
+ for i in {1..10} ; do
+ if [[ -f $RS9116_RESET ]] ; then
+ if [[ -f $RS9116_RESET ]] ; then
+ return 0
+ fi
+ return 1
+ fi
+ usleep $SLEEPTIME
+ done
+ return 1
+}
+
+function syslog {
+ pr=$1
+ shift
+ [[ $(cat /proc/uptime) =~ ([^[:space:]]+) ]]
+ s=$(printf "${format}" $name $pid ${BASH_REMATCH[1]} "$@")
+ echo "<${pr}>${s}" >/dev/kmsg
+}
+
+function logpipe {
+ OIFS="${IFS}"
+ IFS=$'\n'
+ while read ln ; do
+ syslog $1 $ln
+ done
+ IFS="${OIFS}"
+}
+
+function rs9116_reset {
+
+ for i in {1..10} ; do
+ if [[ -f $RS9116_RESET ]] ; then
+ break
+ fi
+ usleep 10000
+ done
+
+ # Reset the RS9116 chip is ready, and
+ # wait for it to settle.
+ if [[ -f $RS9116_RESET ]] ; then
+ echo 0 >$RS9116_RESET
+ usleep $SLEEPTIME
+ echo 1 >$RS9116_RESET
+ else
+ # No WiFi BT, but return 0 for development
+ return 0
+ fi
+}
+
+case "$1" in
+ start)
+ if ((RS9113_LOAD == 0)) ; then
+ # We don't want the driver loaded.
+ exit 0
+ fi
+ rs9116_reset
+ syslog $LOG_INFO "Loading rs9116 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)
+ syslog $LOG_INFO "Unloading rs9116 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
+ ;;
+ reset)
+ rs9116_reset
+ ;;
+ *)
+ echo "Usage: $0 {start|stop|status|restart|reset}"
+ exit 2
+ ;;
+esac
+
+exit 0
+