meta-agl-bsp: enable HCI UART for i.MX8MQ EVK
[AGL/meta-agl.git] / meta-agl-bsp / meta-freescale-layer / recipes-connectivity / hci-uart-helper / files / hci-uart-helper.sh
1 #!/bin/sh
2 #
3 # Script to attach HCI UART devices on i.MX8MQ EVK/EVKB
4 #
5 # NOTE:
6 # For the most part errors are ignored and the script returns
7 # 0/success so BlueZ will still be started if the script is somehow
8 # run on a board without the expected hardware.  However, if the
9 # various probing succeeds and hciattach is run, the script returns
10 # the resulting exit code if hciattach fails.
11
12 COMPAT=/sys/firmware/devicetree/base/compatible
13 HCITTY=/dev/ttymxc2
14 PCIDEV=/sys/bus/pci/devices/0000:01:00.0
15
16 if [ ! \( -f "$COMPAT" -a -c "$HCITTY" \) ]; then
17     exit 0
18 fi
19
20 found=false
21 for c in `cat $COMPAT | tr '\0' ' '`; do
22     echo "c = $c"
23     if echo $c | grep -q '^fsl,imx8mq-evk$'; then
24         found=true
25         break
26     fi
27 done
28 if ! $found; then
29     echo "i.MX8MQ EVK not found!"
30     exit 0
31 fi
32
33 if [ -f "$PCIDEV/vendor" -a -f "$PCIDEV/device" ]; then
34     vendor=`cat $PCIDEV/vendor`
35     device=`cat $PCIDEV/device`
36 fi
37
38 rc=0
39 if [ "$vendor" = "0x14e4" -a "$device" = "0x43ec" ]; then
40     # Broadcom 5436 on EVKB
41     hciattach $HCITTY bcm43xx
42     rc=$?
43 elif [ "$vendor" = "0x168c" -a "$device" = "0x003e" ]; then
44     # Qualcomm (nee Atheros) 6174 on EVK
45     hciattach $HCITTY qualcomm
46     rc=$?
47 fi
48 exit $rc