summaryrefslogtreecommitdiff
path: root/recipes-kernel/rsi-91x/files/rs9113_load_modules.sh
diff options
context:
space:
mode:
Diffstat (limited to 'recipes-kernel/rsi-91x/files/rs9113_load_modules.sh')
-rwxr-xr-xrecipes-kernel/rsi-91x/files/rs9113_load_modules.sh189
1 files changed, 189 insertions, 0 deletions
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