42d4d3b4c7c09d049232d69107eca52c8175c233
[platform/adaptation/bluetooth-firmware-bcm.git] / scripts / bt-dev-start.sh
1 #!/bin/sh
2
3 # Script for registering Broadcom UART BT device
4 BT_UART_DEVICE=/dev/ttySAC3
5 BT_CHIP_TYPE=bcm2035
6 #BCM_TOOL=/usr/bin/bcmtool_4330b1
7 BCM_TOOL=/usr/bin/bcmtool_4358a1
8
9 BT_PLATFORM_DEFAULT_HCI_NAME="TIZEN-Mobile"
10 UART_SPEED=3000000
11
12 #set default firmware
13 #BCM_FIRMWARE=BT_FW_BCM4330B1_002.001.003.0221.0265.hcd
14 BCM_FIRMWARE=BT_FW_BCM4358A1_001.002.005.0032.0066.hcd
15
16 REVISION_NUM=`grep Revision /proc/cpuinfo | awk "{print \\$3}"`
17 REVISION_HIGH=`echo $REVISION_NUM| cut -c1-2`
18 REVISION_LOW=`echo $REVISION_NUM| cut -c3-`
19
20 HARDWARE=`grep Hardware /proc/cpuinfo | awk "{print \\$3}"`
21
22 if [ ! -e "$BT_UART_DEVICE" ]
23 then
24         mknod $BT_UART_DEVICE c 204 64
25 fi
26
27 if [ ! -e /opt/etc/.bd_addr ]
28 then
29         # Set BT address
30         /usr/bin/setbd
31 fi
32
33 # Trun-on Bluetooth Chip
34 rfkill unblock bluetooth
35
36 echo "Check for Bluetooth device status"
37 if (/usr/sbin/hciconfig | grep hci); then
38         echo "Bluetooth device is UP"
39         /usr/sbin/hciconfig hci0 up
40 else
41         echo "Bluetooth device is DOWN"
42         echo "Registering Bluetooth device"
43
44         $BCM_TOOL $BT_UART_DEVICE -FILE=/usr/etc/bluetooth/$BCM_FIRMWARE -BAUD=$UART_SPEED -ADDR=/opt/etc/.bd_addr -SETSCO=0,0,0,0,0,0,0,3,3,0 -LP > /dev/null 2>&1
45
46         # Attaching Broadcom device
47         if (/usr/sbin/hciattach $BT_UART_DEVICE -s $UART_SPEED $BT_CHIP_TYPE $UART_SPEED flow); then
48                 sleep 0.1
49                 /usr/sbin/hciconfig hci0 up
50                 /usr/sbin/hciconfig hci0 name $BT_PLATFORM_DEFAULT_HCI_NAME
51                 /usr/sbin/hciconfig hci0 sspmode 1
52                 echo "HCIATTACH success"
53         else
54                 echo "HCIATTACH failed"
55                 rfkill block bluetooth
56         fi
57 fi