#!/bin/sh -e
# Bluetooth initialization on maguro
#
# Bluetooth initialization job, specifically for the Galaxy Nexus device
# (maguro), uses brcm-patchram-plus to patch firmware, set line discipline and
# write the bluetooth address for the device.
#


env PATCHRAM_ARGS="--patchram /system/vendor/firmware/bcm4330.hcd \
                   --no2bytes \
                   --i2s=1,1,0,1 \
                   --enable_hci \
                   --enable_lpm \
                   --baudrate 3000000 --use_baudrate_for_download \
                   --tosleep=50000 \
                   --bd_addr `cat /factory/bluetooth/bt_addr`"

chmod 0660 /sys/class/rfkill/rfkill0/state
chmod 0660 /sys/class/rfkill/rfkill0/type
chgrp dialout /sys/class/rfkill/rfkill0/state
chgrp dialout /sys/class/rfkill/rfkill0/type
rfkill unblock bluetooth

/usr/bin/brcm_patchram_plus $PATCHRAM_ARGS /dev/ttyO1 &
