summaryrefslogtreecommitdiff
path: root/recipes-kernel/rsi-91x/files
diff options
context:
space:
mode:
Diffstat (limited to 'recipes-kernel/rsi-91x/files')
-rwxr-xr-xrecipes-kernel/rsi-91x/files/onebox_util.sh25
-rw-r--r--recipes-kernel/rsi-91x/files/rs9113.default66
-rwxr-xr-xrecipes-kernel/rsi-91x/files/rs9113.init130
-rwxr-xr-xrecipes-kernel/rsi-91x/files/rs9113.reset25
-rwxr-xr-xrecipes-kernel/rsi-91x/files/rs9113_load_modules.sh189
-rwxr-xr-xrecipes-kernel/rsi-91x/files/rs9113_remove_modules.sh28
-rw-r--r--recipes-kernel/rsi-91x/files/rsi-91x-config.patch31
-rw-r--r--recipes-kernel/rsi-91x/files/rsi-bt91x-config.patch41
-rw-r--r--recipes-kernel/rsi-91x/files/rsi_91x.conf14
9 files changed, 549 insertions, 0 deletions
diff --git a/recipes-kernel/rsi-91x/files/onebox_util.sh b/recipes-kernel/rsi-91x/files/onebox_util.sh
new file mode 100755
index 0000000..5a20d2b
--- /dev/null
+++ b/recipes-kernel/rsi-91x/files/onebox_util.sh
@@ -0,0 +1,25 @@
+#!/bin/bash
+# The purpose of this script is to allow
+# the rs9113 onebox_util functionality to
+# be implemented seamlessly for the rsi
+# driver.
+
+rpine=$1
+cmd=$2
+interface=$3
+
+if [[ $cmd == delete_vap ]] ; then
+ ip link set $interface down || exit 0
+ exit 0
+fi
+
+if [[ -L /sys/class/net/$interface ]] ; then
+ exit 0
+fi
+cd /sys/class/net/
+for d in wlan[0-9]* ; do
+ if ip link set $d down ; then
+ ip link set $d name $interface
+ exit 0
+ fi
+done
diff --git a/recipes-kernel/rsi-91x/files/rs9113.default b/recipes-kernel/rsi-91x/files/rs9113.default
new file mode 100644
index 0000000..ddafe92
--- /dev/null
+++ b/recipes-kernel/rsi-91x/files/rs9113.default
@@ -0,0 +1,66 @@
+#
+# Skip loading the RS9113 related drivers if
+# set to zero.
+#
+RS9113_LOAD=1
+
+# Parameters for rs9113 driver
+#
+# Enable Antenna Diversity (1)
+RSI_ANTENNA_DIVERSITY=0
+
+# COEX_MODE options:
+# 1 WLAN STATION or WLAN ACCESS POINT
+# 4 BT EDR MODE
+# 5 WLAN STATION + BT EDR MODE
+# 6 WLAN ACCESS POINT + BT EDR MODE
+# 8 BT LE MODE
+# 9 WLAN STATION + BT LE MODE
+# 10 WLAN ACCESS POINT + BT LE MODE
+# 12 BT EDR + BT LE MODE
+# 13 WLAN STATION + BT EDR MODE + BT LE MODE
+# 14 WLAN ACCESS POINT + BT EDR MODE+ BT LE MODE
+COEX_MODE=1
+
+
+# 2 – Select internal antenna
+# 3 – Select external antenna
+ANT_SEL_VAL=2
+
+RSI_ANTENNA_DIVERSITY=0
+
+# Parameters are described here:
+# https://github.com/SiliconLabs/RS911X-nLink-OSD/blob/master/rsi/rsi_91x_main.c
+#
+# RX_DATA_INACTIVE_INTERVAL
+# SLEEP_IND_GPIO_SEL"
+# ULP_GPIO_READ
+# ULP_GPIO_WRITE"
+# PS_SLEEP_TYPE
+# MAX_SP_LEN
+# ENABLED_UAPSD
+# LP_HANDSHAKE_MODE
+# ULP_HANDSHAKE_MODE
+# PEER_DIST
+# BT_FEATURE_BITMAP
+# UART_DEBUG
+# EXT_OPT
+# BLE_ROLES
+# BT_BDR_MODE
+# THREE_WIRE_COEX
+# ANCHOR_POINT_GAP
+# HOST_INTF_ON_DEMAND
+# SLEEP_CLK_SOURCE_SEL
+# FEATURE_BITMAP_9116
+# ENABLE_40MHZ_IN_2G
+# XTAL_GOOD_TIME
+# RSI_ZONE_ENABLED
+
+
+# Time to hold high, then hold low on reset during driver load reset
+SLEEPTIME=100000
+
+# Time to wait while looping for interrupt and wake-up pins
+# to go high.
+INTSLEEPTIME=100000
+
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
+
diff --git a/recipes-kernel/rsi-91x/files/rs9113.reset b/recipes-kernel/rsi-91x/files/rs9113.reset
new file mode 100755
index 0000000..7992f7d
--- /dev/null
+++ b/recipes-kernel/rsi-91x/files/rs9113.reset
@@ -0,0 +1,25 @@
+#!/bin/sh
+# Reset rs9113
+# Must be done after /etc/init.d/mts-io executes, and
+# before any code that probes the USB bus.
+function do_reset {
+ if ! [[ -w /sys/devices/platform/mts-io/wifi-bt-reset ]] ; then
+ exit 0
+ fi
+ /etc/init.d/rs9113 reset
+}
+
+case $1 in
+ start)
+ do_reset
+ ;;
+ stop)
+ ;;
+ reload)
+ do_reset
+ ;;
+ *)
+ echo "Usage: $0 {start|stop|reload}"
+ exit 2
+ ;;
+esac
diff --git a/recipes-kernel/rsi-91x/files/rs9113_load_modules.sh b/recipes-kernel/rsi-91x/files/rs9113_load_modules.sh
new file mode 100755
index 0000000..b77a781
--- /dev/null
+++ b/recipes-kernel/rsi-91x/files/rs9113_load_modules.sh
@@ -0,0 +1,189 @@
+#!/bin/bash
+
+UNBIND=/sys/devices/soc0/soc/2100000.aips-bus/2190000.usdhc/driver/unbind
+if [[ -f $UNBIND ]] ; then
+ echo 2190000.usdhc >$UNBIND
+fi
+sleep 1
+
+BIND="/sys/bus/soc/devices/soc0/soc/2100000.aips-bus/2190000.usdhc/subsystem/drivers/sdhci-esdhc-imx/bind"
+if [[ -f $BIND ]] ; then
+ echo 2190000.usdhc >$BIND
+fi
+
+defaults=/etc/default/rs9113
+usage()
+{
+ echo "Configuration values:"
+ echo " COEX_MODE"
+ echo " RSI_ANTENNA_DIVERSITY"
+ echo " ANT_SEL_VAL"
+ echo " RX_DATA_INACTIVE_INTERVAL"
+ echo " SLEEP_IND_GPIO_SEL"
+ echo " ULP_GPIO_READ"
+ echo " ULP_GPIO_WRITE"
+ echo " PS_SLEEP_TYPE"
+ echo " MAX_SP_LEN"
+ echo " ENABLED_UAPSD"
+ echo " LP_HANDSHAKE_MODE"
+ echo " ULP_HANDSHAKE_MODE"
+ echo " PEER_DIST"
+ echo " BT_FEATURE_BITMAP"
+ echo " UART_DEBUG"
+ echo " EXT_OPT"
+ echo " BLE_ROLES"
+ echo " BT_BDR_MODE"
+ echo " THREE_WIRE_COEX"
+ echo " ANCHOR_POINT_GAP"
+ echo " HOST_INTF_ON_DEMAND"
+ echo " SLEEP_CLK_SOURCE_SEL"
+ echo " FEATURE_BITMAP_9116"
+ echo " ENABLE_40MHZ_IN_2G"
+ echo " XTAL_GOOD_TIME"
+ echo " RSI_ZONE_ENABLED"
+ echo "Usage: $(basename $0) [config file]"
+ echo ""
+ echo "Config file is typically
+ /etc/default/rs9113 with the above parameters."
+ exit 1
+}
+if (($# > 1)); then
+ usage
+fi
+
+if ((${#COEX_MODE}==0)) && [[ -r $defaults ]]; then
+ set -e
+ . $defaults
+ set +e
+fi
+
+if (($# > 0)) && [[ -r $1 ]]; then
+ set -e
+ . $1
+ set +e
+fi
+
+err=0
+for x in COEX_MODE RSI_ANTENNA_DIVERSITY ANT_SEL_VAL ; do
+ if [[ -z ${!x} ]] ; then
+ echo Need to provide ${x} for configuration
+ err=1
+ fi
+done
+
+if((err)) ; then
+ usage
+fi
+cd /opt/rs9113/modules
+
+modprobe mac80211
+modprobe bluetooth
+
+# rs9116
+# dev_oper_mode
+# 1 STA or AP
+# 4 BT EDR
+# 5 STA and BT EDR
+# 6 AP and BT EDR
+# 8 BT LE
+# 9 STA and BT LE
+# 10 AP and BT LE
+# 12 BT EDR and BT LE
+# 13 STA and BT EDR and BT LE
+# 14 AP and BT EDR and BT LE
+usbd="rsi_usb.ko"
+sdiod="rsi_sdio.ko"
+rsid="rsi_91x.ko"
+
+case ${COEX_MODE} in
+ 1|2|3)
+ DEV_OPER_MODE=1
+ ;;
+ 4)
+ DEV_OPER_MODE=4
+ usbd="rsi_btusb.ko"
+ sdiod="rsi_btsdio.ko"
+ rsid="rsi_bt91x.ko"
+ ;;
+ 5)
+ DEV_OPER_MODE=5
+ ;;
+ 6)
+ DEV_OPER_MODE=6
+ ;;
+ 8)
+ DEV_OPER_MODE=8
+ usbd="rsi_btusb.ko"
+ sdiod="rsi_btsdio.ko"
+ rsid="rsi_bt91x.ko"
+ ;;
+ 9)
+ DEV_OPER_MODE=9
+ ;;
+ 10)
+ DEV_OPER_MODE=10
+ ;;
+ 12)
+ DEV_OPER_MODE=12
+ usbd="rsi_btusb.ko"
+ sdiod="rsi_btsdio.ko"
+ rsid="rsi_bt91x.ko"
+ ;;
+ 13)
+ DEV_OPER_MODE=13
+ ;;
+ 14)
+ DEV_OPER_MODE=14
+ ;;
+ *)
+ logger -s -p daemon.error "Coexistance mode $COEX_MODE does not exist"
+ usage9116
+ esac
+
+# Modes 4,8,12 require BT only driver
+
+PARAMS=" dev_oper_mode=$DEV_OPER_MODE antenna_diversity=$RSI_ANTENNA_DIVERSITY antenna_sel=$ANT_SEL_VAL"
+
+RS9116_VARS="RSI_ZONE_ENABLED LP_HANDSHAKE_MODE ULP_HANDSHAKE_MODE"
+RS9116_VARS+=" BT_FEATURE_BITMAP CONFIG_PEER_DISTANCE ENABLE_40MHZ_IN_2G"
+RS9116_VARS+=" THREE_WIRE_COEX ANCHOR_POINT_GAP HOST_INTF_ON_DEMAND"
+RS9116_VARS+=" SLEEP_CLK_SOURCE_SEL FEATURE_BITMAP_9116"
+
+
+for v in ${RS9116_VARS} ; do
+ if [[ -n ${!v} ]] ; then
+ PARAMS += ${v,,}=${!v}
+ fi
+done
+
+hosts=$(find /sys/devices -type d -name mmc_host)
+
+shim=$usbd
+for d in $hosts ; do
+ vendor=$(find $d -type f -name vendor)
+ devname=$(find $d -type f -name device)
+ if [[ -n $vendor ]] ; then
+ VENDOR=$(cat $vendor)
+ fi
+ if [[ -n $vendor ]] ; then
+ DEVNAME=$(cat $devname)
+ fi
+ if [[ $VENDOR == 0x041b ]] && [[ $DEVNAME == 0x9116 ]] ; then
+ shim=$sdiod
+ fi
+done
+
+#Use awk to split a very long line.
+if ! insmod $rsid $PARAMS ; then
+ echo "Failed: insmod $rsid $PARAMS" | awk '{printf gensub("(.{0,60})","\\1\n","g")}' | logger -s -t rs9113_load_modules.sh -p daemon.error
+fi
+insmod $shim
+# Wait for driver to load
+((count=0))
+while ((count < 10)) ; do
+ if [[ -L /sys/class/bluetooth/hci0 ]] || [[ -L /sys/class/net/wlan0 ]] ; then
+ break;
+ fi
+ usleep 100000
+ ((count++))
+done
diff --git a/recipes-kernel/rsi-91x/files/rs9113_remove_modules.sh b/recipes-kernel/rsi-91x/files/rs9113_remove_modules.sh
new file mode 100755
index 0000000..f468545
--- /dev/null
+++ b/recipes-kernel/rsi-91x/files/rs9113_remove_modules.sh
@@ -0,0 +1,28 @@
+#!/bin/bash
+killall -9 wpa_supplicant
+killall -9 hostapd
+killall -9 bluetoothd
+rm -rf /var/run/wpa_supplicant/
+sleep 2
+
+modules=" "$(lsmod)" "
+### COMMON HAL MODULES
+for mod in rsi_btsdio rsi_btusb rsi_bt91x rsi_sdio rsi_usb rsi_91x mac80211 cfg80211 bluetooth rfkill ; do
+ if [[ ${modules} =~ [[:space:]]${mod}[[:space:]] ]] ; then
+ result+=$(rmmod $mod 2>&1)
+ last=$?
+ if [[ -n $result ]] ; then
+ echo "$result" | logger -s -p daemon.notice
+ fi
+ fi
+done
+
+if ((last > 0)) ; then
+ echo "${result}" | logger -s -p daemon.notice
+ lsmod | grep rsi | logger -s -p daemon.notice
+fi
+UNBIND=/sys/devices/soc0/soc/2100000.aips-bus/2190000.usdhc/driver/unbind
+if [[ -f $UNBIND ]] ; then
+ echo 2190000.usdhc >$UNBIND
+fi
+
diff --git a/recipes-kernel/rsi-91x/files/rsi-91x-config.patch b/recipes-kernel/rsi-91x/files/rsi-91x-config.patch
new file mode 100644
index 0000000..c711698
--- /dev/null
+++ b/recipes-kernel/rsi-91x/files/rsi-91x-config.patch
@@ -0,0 +1,31 @@
+diff --git a/rsi/Makefile b/rsi/Makefile
+index 64f7742..e74d971 100644
+--- a/rsi/Makefile
++++ b/rsi/Makefile
+@@ -45,7 +45,7 @@ KERNELDIR=/lib/modules/$(KERNELRELEASE)/build
+ #CONFIG_RSI_BT_ALONE=y
+
+ # Uncomment below line for Wi-Fi BT coex mode
+-#CONFIG_RSI_COEX_MODE=y
++CONFIG_RSI_COEX_MODE=y
+
+ # Uncomment below line for WLAN + Zigbee coex mode
+ #CONFIG_RSI_ZIGB=y
+@@ -196,10 +196,15 @@ rsi_usb-objs := $(COMMON_USB_OBJS)
+ rsi_91x-objs := $(RSI_91X_OBJS)
+
+ all:
++ @echo env is:
++ env
+ @echo -e "\033[32mCompiling RSI drivers...\033[0m"
+ make -C$(KERNELDIR)/ M=$(PWD) modules
+- @echo -e "application compilation"
+- make CC="$(CC)" ROOT_DIR=$(ROOT_DIR) -C $(PWD)/apps
++ # @echo -e "application compilation"
++ # make CC="$(CC)" ROOT_DIR=$(ROOT_DIR) -C $(PWD)/apps
++
++modules_install:
++ $(MAKE) -C $(KERNELDIR) M=$(PWD) modules_install
+
+ clean:
+ make -C$(KERNELDIR)/ M=$(PWD) clean
diff --git a/recipes-kernel/rsi-91x/files/rsi-bt91x-config.patch b/recipes-kernel/rsi-91x/files/rsi-bt91x-config.patch
new file mode 100644
index 0000000..3bda909
--- /dev/null
+++ b/recipes-kernel/rsi-91x/files/rsi-bt91x-config.patch
@@ -0,0 +1,41 @@
+diff --git a/rsi/Makefile b/rsi/Makefile
+index 64f7742..bc088b8 100644
+--- a/rsi/Makefile
++++ b/rsi/Makefile
+@@ -42,7 +42,7 @@ KERNELDIR=/lib/modules/$(KERNELRELEASE)/build
+ #CONFIG_SDIO_INTR_POLL=y
+
+ # Uncomment below line for BT alone (Classic/LE/Dual) mode
+-#CONFIG_RSI_BT_ALONE=y
++CONFIG_RSI_BT_ALONE=y
+
+ # Uncomment below line for Wi-Fi BT coex mode
+ #CONFIG_RSI_COEX_MODE=y
+@@ -190,16 +190,21 @@ ifeq ($(OFFLOAD_SCAN_TO_DEVICE), y)
+ EXTRA_CFLAGS += -DOFFLOAD_SCAN_TO_DEVICE
+ endif
+
+-obj-m := rsi_sdio.o rsi_usb.o rsi_91x.o
+-rsi_sdio-objs := $(COMMON_SDIO_OBJS)
+-rsi_usb-objs := $(COMMON_USB_OBJS)
+-rsi_91x-objs := $(RSI_91X_OBJS)
++obj-m := rsi_btsdio.o rsi_btusb.o rsi_bt91x.o
++rsi_btsdio-objs := $(COMMON_SDIO_OBJS)
++rsi_btusb-objs := $(COMMON_USB_OBJS)
++rsi_bt91x-objs := $(RSI_91X_OBJS)
+
+ all:
++ @echo env is:
++ env
+ @echo -e "\033[32mCompiling RSI drivers...\033[0m"
+ make -C$(KERNELDIR)/ M=$(PWD) modules
+- @echo -e "application compilation"
+- make CC="$(CC)" ROOT_DIR=$(ROOT_DIR) -C $(PWD)/apps
++ # @echo -e "application compilation"
++ # make CC="$(CC)" ROOT_DIR=$(ROOT_DIR) -C $(PWD)/apps
++
++modules_install:
++ $(MAKE) -C $(KERNELDIR) M=$(PWD) modules_install
+
+ clean:
+ make -C$(KERNELDIR)/ M=$(PWD) clean
diff --git a/recipes-kernel/rsi-91x/files/rsi_91x.conf b/recipes-kernel/rsi-91x/files/rsi_91x.conf
new file mode 100644
index 0000000..6d08138
--- /dev/null
+++ b/recipes-kernel/rsi-91x/files/rsi_91x.conf
@@ -0,0 +1,14 @@
+# /etc/modules-load.d/rsi_91x
+#
+# dev_oper_mode for driver load
+# 1 STA or AP
+# 4 BT EDR
+# 5 STA and BT EDR
+# 6 AP and BT EDR
+# 8 BT LE
+# 9 STA and BT LE
+# 10 AP and BT LE
+# 12 BT EDR and BT LE
+# 13 STA and BT EDR and BT LE
+# 14 AP and BT EDR and BT LE
+options rsi_91x dev_oper_mode=1