M7350v1_en_gpl

This commit is contained in:
T
2024-09-09 08:52:07 +00:00
commit f9cc65cfda
65988 changed files with 26357421 additions and 0 deletions

View File

@@ -0,0 +1,341 @@
#!/bin/sh
#
# Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of The Linux Foundation nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
export KERNEL=`uname -r`
export MODULE_BASE=/lib/modules/$KERNEL/updates
export RETRY_LIMIT=5
export ENUM_RETRY_LIMIT=1
HELP="Usage $0 {start | stop | restart} <ap | ap,ap | sta,ap>"
CONF_FILE="/etc/wlan_config"
DEVICE_PATTERN="device=AR6003"
CHIP="AR6004"
SDIO_POLLING_PATH="/sys/devices/msm_sdcc.3/polling"
INTERFACE_NAME="wlan"
#Default configuration files available
AR6003_HOSTAPD_CONF="/etc/AR6003_hostapd.conf"
AR6003_AP1_HOSTAPD_CONF="/etc/AR6003_AP1_hostapd.conf"
AR6004_HOSTAPD_CONF="/etc/AR6004_hostapd.conf"
AR6004_AP1_HOSTAPD_CONF="/etc/AR6004_AP1_hostapd.conf"
#This is per QCMAP default configuration
#Can be changed per application requirement
HOSTAPD_CONF="/etc/hostapd.conf"
HOSTAPD_AP1_CONF="/etc/hostapd-wlan1.conf"
HOSTAPD_STA_AP_CONF="/etc/sta_mode_hostapd.conf"
retry=0
AR6004_DEVID="0cf3:9374"
# MAC Address
RANDOM_MAC_ADDRESS="00:11:22:33:44:55"
UCI_MAC_ADDRESS="`uci get product.wlan.mac_address`"
# Enable FW error recovery via debug quirks, default is 0x1FC04.
# Disable ATH6KL_MODULE_ENABLE_USB_AUTO_PM(16).
# for more infomation, please refer to debug.h of ath6kl driver.
ATH6KL_DEBUG_QUIRKS="0x4FC04"
# if start FTM
ATH6KL_FTM_QUIRKS="0x10"
# Check existence
if [ ! -n "UCI_MAC_ADDRESS" ]; then
MAC_ADDRESS=$RANDOM_MAC_ADDRESS
else
# Mac address in uci is like: 00-11-22-33-44-55
# But wlan driver need this: 00:11:22:33:44:55
# So convert '-' to ':' in MAC address
MAC_ADDRESS="`echo $UCI_MAC_ADDRESS | sed s/-/:/g`"
fi
# Check if calibration files exist
is_cal_pass () {
# TR961 has no file "calData", just check bdata_self
if [ -e "/misc/bdata_self.bin" ]; then
return 1
else
return 0
fi
}
do_ctrl_ar6004_hsic () {
case "$1" in
start)
echo "Starting WLAN... $@"
echo "WLAN: Starting WLAN... $@" >> /dev/kmsg
# When starts in not FTM mode, and calibration failed, wifi will stop bringing up
ftm_match="`echo $@ | grep "debug_quirks=$ATH6KL_FTM_QUIRKS"`"
if [ -z "$ftm_match" ]; then
# Check if cal passed
is_cal_pass
if [ $? -ne 1 ]; then
echo "Cannot find cal files at /misc, abort."
echo "WLAN: Cannot find cal files at /misc, abort." >> /dev/kmsg
exit 1
fi
else
echo "wifi start in FTM mode"
echo "WLAN: wifi start in FTM mode" >> /dev/kmsg
fi
shift
start_ap1=0
devmode=1
if [ "$1" == "ap,ap" ] || [ "$1" == "sta,ap" ]; then
start_ap1=1
devmode=2
shift
elif [ "$1" == "ap" ]; then
shift
elif [ "$1" == "ap,sta" ]; then
return 1
fi
set -e
insmod $MODULE_BASE/compat/compat.ko
insmod $MODULE_BASE/net/wireless/cfg80211.ko
insmod $MODULE_BASE/drivers/net/wireless/ath/ath6kl/ath6kl_core.ko reg_hint=0 debug_quirks=$ATH6KL_DEBUG_QUIRKS devmode=$devmode enable_ani=1 ath6kl_wifi_mac=$MAC_ADDRESS $@
insmod $MODULE_BASE/drivers/net/wireless/ath/ath6kl/ath6kl_usb.ko
echo hsic 2000 > /sys/bus/platform/devices/usb_bam/inactivity_timer
echo msm_hsic_host > /sys/bus/platform/drivers/msm_hsic_host/bind
set +e
c=1
ifconfig wlan0 up 2> /dev/null
rc=$?
while [ $rc -ne 0 -a $c -le $RETRY_LIMIT ]; do
sleep 1
ifconfig wlan0 up 2> /dev/null
rc=$?
c=`expr $c + 1`
done
if [ $c -gt $RETRY_LIMIT ]; then
echo "WLAN bring-up failed!"
echo "WLAN: WLAN bring-up failed!" >> /dev/kmsg
lsusb | grep -q $AR6004_DEVID
if [ $? -ne 0 -a $retry -lt $ENUM_RETRY_LIMIT ]; then
echo "Enumeration failure, try again!"
echo "WLAN: Enumeration failure, try again!" >> /dev/kmsg
do_ctrl_ar6004_hsic stop
sleep 1
if [ $start_ap1 -eq 1 ]; then
#Assume sta,ap mode as first interface is sta interface
#irrespective of sta,ap or ap,ap request
do_ctrl_ar6004_hsic start sta,ap $@
else
do_ctrl_ar6004_hsic start $@
fi
retry=`expr $retry + 1`
fi
exit 1
fi
if [ $start_ap1 -eq 1 ]; then
echo "Adding second AP interface(wlan1)"
echo "WLAN: Adding second AP interface(wlan1)" >> /dev/kmsg
iw dev wlan0 interface add wlan1 type __ap
ifconfig wlan1 up 2> /dev/null
fi
echo "Starting CXMAPP..."
echo "WLAN: Starting CXMAPP..." >> /dev/kmsg
cxmapp --init
cxmapp &
;;
start_ftm)
do_ctrl_ar6004_hsic start debug_quirks=$ATH6KL_FTM_QUIRKS
;;
stop)
echo "Stopping WLAN..."
echo "WLAN: Stopping WLAN..." >> /dev/kmsg
killall -15 cxmapp
echo msm_hsic_host > /sys/bus/platform/drivers/msm_hsic_host/unbind
echo hsic 0 > /sys/bus/platform/devices/usb_bam/inactivity_timer
rmmod ath6kl_usb
rmmod ath6kl_core
rmmod cfg80211
rmmod compat
;;
restart)
do_ctrl_ar6004_hsic stop
shift
do_ctrl_ar6004_hsic start $@
return $?
;;
*)
return 1
;;
esac
return 0
}
do_ctrl_ar6003 () {
case "$1" in
start)
echo "Starting WLAN... $@"
shift
MODE="ap"
if [ "$1" == "ap,ap" ] || [ "$1" == "sta,ap" ] || [ "$1" == "ap" ]; then
MODE="$1"
shift
elif [ "$1" == "ap,sta" ]; then
return 1
fi
if [ -w $SDIO_POLLING_PATH ]; then
echo 1 > $SDIO_POLLING_PATH
else
echo "Cannot write to $SDIO_POLLING_PATH"
exit 1
fi
set -e
modprobe ar6000 targetconf="router" devmode=$MODE ifname=$INTERFACE_NAME $@
set +e
sleep 1
c=1
ifconfig wlan0 up 2> /dev/null
rc=$?
while [ $rc -ne 0 -a $c -le $RETRY_LIMIT ]; do
sleep 1
ifconfig wlan0 up 2> /dev/null
rc=$?
c=`expr $c + 1`
done
if [ $c -gt $RETRY_LIMIT ]; then
echo "WLAN bring-up failed!"
exit 1
fi
if [ $MODE == "ap,ap" ] || [ $MODE == "sta,ap" ]; then
ifconfig wlan1 up 2> /dev/null
fi
echo 0 > $SDIO_POLLING_PATH
echo "Starting CXMAPP..."
cxmapp --init
cxmapp --ar6003 &
;;
start_ftm)
do_ctrl_ar6003 start testmode=1
;;
stop)
echo "Stopping WLAN..."
echo "WLAN: Stopping WLAN..." >> /dev/kmsg
killall -15 cxmapp
echo 0 > $SDIO_POLLING_PATH
rmmod ar6000
;;
restart)
do_ctrl_ar6003 stop
shift
do_ctrl_ar6003 start $@
if [ $? -ne 0 ]; then
return 1
fi
;;
*)
return 1
;;
esac
}
do_configure_ar6004() {
if [ "$1" == "start" ] || [ "$1" == "restart" ]; then
ln -f -s $AR6004_HOSTAPD_CONF $HOSTAPD_CONF
if [ "$2" == "ap,ap" ]; then
ln -f -s $AR6004_AP1_HOSTAPD_CONF $HOSTAPD_AP1_CONF
fi
if [ "$2" == "sta,ap" ]; then
ln -f -s $AR6004_AP1_HOSTAPD_CONF $HOSTAPD_STA_AP_CONF
fi
fi
}
do_configure_ar6003() {
if [ "$1" == "start" ] || [ "$1" == "restart" ]; then
ln -f -s $AR6003_HOSTAPD_CONF $HOSTAPD_CONF
if [ "$2" == "ap,ap" ]; then
ln -f -s $AR6003_AP1_HOSTAPD_CONF $HOSTAPD_AP1_CONF
fi
if [ "$2" == "sta,ap" ]; then
ln -f -s $AR6003_AP1_HOSTAPD_CONF $HOSTAPD_STA_AP_CONF
fi
fi
}
if [ -r $CONF_FILE ]; then
grep -iq $DEVICE_PATTERN $CONF_FILE
ret=$?
if [ $ret -eq 0 ]; then
CHIP="AR6003"
else
CHIP="AR6004"
fi
fi
echo "$CHIP chip detected!"
if [ $CHIP == "AR6003" ]; then
do_ctrl_ar6003 $@
if [ $? -ne 0 ]; then
echo $HELP >&2
exit 1
fi
do_configure_ar6003 $@
else
do_ctrl_ar6004_hsic $@
if [ $? -ne 0 ]; then
echo $HELP >&2
exit 1
fi
do_configure_ar6004 $@
fi
exit 0