diff --git a/meta-digi-dey/recipes-connectivity/bluez/bluez5-init/bluetooth-init_btbcm_hciuart b/meta-digi-dey/recipes-connectivity/bluez/bluez5-init/bluetooth-init_btbcm_hciuart index 0938fecf5..f2fbfe111 100644 --- a/meta-digi-dey/recipes-connectivity/bluez/bluez5-init/bluetooth-init_btbcm_hciuart +++ b/meta-digi-dey/recipes-connectivity/bluez/bluez5-init/bluetooth-init_btbcm_hciuart @@ -18,20 +18,6 @@ RETRIES=3 HCI_IFACE="hci0" MODULE_NAME="hci_uart" -if grep -qs '\' /proc/device-tree/compatible; then - # CCMP13 - BT_REG_EN - GPIO PD13 - GPIO_CHIP="GPIOD" - GPIO_NUMBER="13" -elif grep -qs '\' /proc/device-tree/compatible; then - # CCMP15 - BT_REG_EN - GPIO PZ6 - GPIO_CHIP="GPIOZ" - GPIO_NUMBER="6" -elif grep -qs '\' /proc/device-tree/compatible; then - # CCIMX95 - GPIO_CHIP="1" - GPIO_NUMBER="18" -fi - log() { if type "systemd-cat" >/dev/null 2>/dev/null; then systemd-cat -p "${1}" -t "${SCRIPTNAME}" printf "%s" "${2}" @@ -40,20 +26,16 @@ log() { fi } -bt_power() { - gpioset "${GPIO_CHIP}" "${GPIO_NUMBER}"="${1}" -} - set_btaddr() { - hciconfig hci0 up + hciconfig ${HCI_IFACE} up sleep 0.2 bt_addr=$(hexdump -v -e '1/1 "%02X "' /proc/device-tree/bluetooth/mac-address \ | awk '{ for(i=NF; i>0; i--) printf "0x%s ", $i }' \ | sed 's/ $//') - hcitool -i hci0 cmd 0x3f 0x0001 ${bt_addr} - hciconfig hci0 down + hcitool -i ${HCI_IFACE} cmd 0x3f 0x0001 ${bt_addr} + hciconfig ${HCI_IFACE} down sleep 0.2 - hciconfig hci0 up + hciconfig ${HCI_IFACE} up } is_kernel_module_loaded() { @@ -65,18 +47,16 @@ bt_init() { is_kernel_module_loaded && log info "kernel module already present, skipping" && return 1 for i in $(seq ${RETRIES}); do - # Perform a power cycle - bt_power 0 - sleep 0.5 - bt_power 1 - # Load manually the kernel module modprobe "${MODULE_NAME}" sleep 1 # Reconfigure the HCI interface with the expected MAC address is_kernel_module_loaded && set_btaddr && log info "Bluetooth activated" && return 0 + bt_stop - log err "Cannot initialize Bluetooth, retrying..." + if [ "$i" -lt "$RETRIES" ]; then + log err "Cannot initialize Bluetooth, retrying..." + fi done log err "Failed to initialize Bluetooth interface" @@ -86,10 +66,9 @@ bt_init() { bt_stop() { hciconfig ${HCI_IFACE} down # Unload HCI driver instance - rmmod hci_uart + rmmod "${MODULE_NAME}" rmmod btbcm - # Disable Bluetooth chip - bt_power 0 && log info "Bluetooth disabled" && return 0 + log info "Bluetooth disabled" } case "$1" in