summaryrefslogtreecommitdiff
path: root/scripts/bt-dev-start.sh
blob: b2783c43486389627c3b72002f66c7a434ef766c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/sh

#
# Script for registering Marvell 89XX SDIO BT device
#

SETBD=/usr/etc/bluetooth/bt-set-addr.sh
RFKILL=/usr/sbin/rfkill
GREP=/usr/bin/pgrep
HCI_CONFIG=/usr/bin/hciconfig
CP="/bin/cp"
KERNEL_DIR=`uname -a | awk '{print($3)}'`
DRV_DIR=/lib/modules/$KERNEL_DIR/kernel
BT_DRIVER=$DRV_DIR/drivers/net/wireless/sd8977/mbt_src/bt8xxx.ko

echo "MARVELL89XX BT START"

echo "Insert BT driver module"
/usr/sbin/insmod $BT_DRIVER

echo "create bd address and write bd address via /sys/module/bt8xxx/parameters/bt_mac"
${SETBD}

echo "Unblock bluetooth RFKILL"
${RFKILL} unblock bluetooth

echo "Power On"
echo 1 > /sys/devices/platform/sd8x-rfkill/pwr_ctrl

TIMEOUT=20

for (( i=1; i<=$TIMEOUT; i++))
do
	/bin/sleep 0.1

        if [ $i -eq $TIMEOUT ]
        then
                echo "time expired happen $i"
                ${RFKILL} block bluetooth
                exit 1
        fi

	if (${HCI_CONFIG} | ${GREP} hci); then
		echo "Bluetooth device is made"
		break
	fi
	echo "Continue...$i"
done
exit 0