#!/bin/sh /etc/rc.common
. /lib/ar71xx.sh

START=63

bt_up(){
  hciconfig hci0 up

  count=5
  while [ $count -gt 0 ]
  do
    if hciconfig hci0 lestates >/dev/null; then
      break;
    fi
    let count=$count-1
    sleep 1
  done

  if [ $count -eq 0 ];then
    echo "Failed to enable hci0" >> /tmp/log/bccmd
  fi
}

bccmd_init_csr8x11() {
  bt_up
  bccmd -t hci -d hci0 psload /etc/bluetooth/csr8x11-a12-bt4.2-patch.psr
  bccmd -t hci -d hci0 psload /etc/bluetooth/csr8x11-coex.psr
  bccmd -t hci -d hci0 warmreset
  bt_up
}

start() {
  board_name=$(ar71xx_board_name)

  case "$board_name" in
  cus531mp3|\
  cus531mp3-dual|\
  cus531mp3-nand)
    bccmd_init_csr8x11
    ;;
  esac
}

