From 871da6f0d6b7726ef338242033920048860f4393 Mon Sep 17 00:00:00 2001 From: Hector Palacios Date: Thu, 31 May 2018 17:37:20 +0200 Subject: [PATCH] bluez5: add support for ConnectCore 8X on Bluez5-5.46 - The variable containing the list of patches has been renamed to a more generic prefix QCA65XX_. - The ConnectCore 8X uses GPIO3_10 (394) for BT_EN. Signed-off-by: Hector Palacios https://jira.digi.com/browse/DEL-5936 --- .../bluez/bluez5-5.46/ccimx8x/bluetooth-init | 93 +++++++++++++++++++ .../bluez/bluez5-5.46/ccimx8x/main.conf | 12 +++ .../bluez/bluez5_5.41.bbappend | 6 +- .../bluez/bluez5_5.46.bbappend | 7 +- 4 files changed, 112 insertions(+), 6 deletions(-) create mode 100644 meta-digi-dey/recipes-connectivity/bluez/bluez5-5.46/ccimx8x/bluetooth-init create mode 100644 meta-digi-dey/recipes-connectivity/bluez/bluez5-5.46/ccimx8x/main.conf diff --git a/meta-digi-dey/recipes-connectivity/bluez/bluez5-5.46/ccimx8x/bluetooth-init b/meta-digi-dey/recipes-connectivity/bluez/bluez5-5.46/ccimx8x/bluetooth-init new file mode 100644 index 000000000..0a6a70cc4 --- /dev/null +++ b/meta-digi-dey/recipes-connectivity/bluez/bluez5-5.46/ccimx8x/bluetooth-init @@ -0,0 +1,93 @@ +#!/bin/sh +#=============================================================================== +# +# Copyright (C) 2018 by Digi International Inc. +# All rights reserved. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 as published by +# the Free Software Foundation. +# +# +# !Description: Initialize bluetooth hardware +# +#=============================================================================== + +# Bluetooth power GPIO +BT_EN_QCA_GPIO_NR="394" + +# set_gpio_value +set_gpio_value() { + local SG_GPIONR="${1}" + local SG_GPIOVAL="${2}" + local SG_GPIOPATH="/sys/class/gpio/gpio${SG_GPIONR}" + + [ -d "${SG_GPIOPATH}" ] || printf "%s" "${SG_GPIONR}" > /sys/class/gpio/export + printf out > "${SG_GPIOPATH}/direction" && sleep .2 + printf "${SG_GPIOVAL}" > "${SG_GPIOPATH}/value" && sleep .2 + [ -d "${SG_GPIOPATH}" ] && printf "%s" "${SG_GPIONR}" > /sys/class/gpio/unexport +} + +# powercycle_gpio +powercycle_gpio() { + set_gpio_value "${1}" 0 + set_gpio_value "${1}" 1 +} + +error() { + echo ${1} + exit 1 +} + +bluetooth_init() { + # Get MAC address from the device tree. Use a default value if it has not been set. + BT_MACADDR="$(hexdump -ve '1/1 "%02X" ":"' /proc/device-tree/bluetooth/mac-address 2>/dev/null | sed 's/:$//g')" + if [ -z "${BT_MACADDR}" ] || [ "${BT_MACADDR}" = "00:00:00:00:00:00" ]; then + BT_MACADDR="00:04:F3:FF:FF:BB" + fi + + # Start the Bluetooth driver and bring up the interface + HCIATTACH_LOG="/var/log/hciattach.log" + + for RETRY in $(seq 1 5) + do + killproc hciattach + powercycle_gpio "${BT_EN_QCA_GPIO_NR}" + if hciattach ttyBt qca ${BT_RATE:-3000000} -t30 ${BT_FLOW:-flow} unused ${BT_MACADDR} >${HCIATTACH_LOG} 2>&1; then + return + fi + sleep 1 + done + BT_ERROR="FAIL (hciattach)" +} + +# Source function library +. /etc/init.d/functions + +case "$1" in + start) + if [ -d "/proc/device-tree/bluetooth" ]; then + echo -n "Starting bluetooth hardware: " + bluetooth_init + echo "${BT_ERROR:-done.}" + fi + ;; + stop) + if [ -d "/sys/class/bluetooth/hci0" ]; then + echo -n "Stopping bluetooth hardware: " + killproc hciattach + # Power down bluetooth + set_gpio_value "${BT_EN_QCA_GPIO_NR}" 0 + echo "done." + fi + ;; + restart) + $0 stop + sleep 1 + $0 start + ;; + *) + echo "Usage: $0 {start|stop|restart}" + exit 1 + ;; +esac diff --git a/meta-digi-dey/recipes-connectivity/bluez/bluez5-5.46/ccimx8x/main.conf b/meta-digi-dey/recipes-connectivity/bluez/bluez5-5.46/ccimx8x/main.conf new file mode 100644 index 000000000..1fae07f0e --- /dev/null +++ b/meta-digi-dey/recipes-connectivity/bluez/bluez5-5.46/ccimx8x/main.conf @@ -0,0 +1,12 @@ +[General] + +# Default adapter name +# Defaults to 'BlueZ X.YZ' +Name = cc8x + +[Policy] + +# AutoEnable defines option to enable all controllers when they are found. +# This includes adapters present on start as well as adapters that are plugged +# in later on. Defaults to 'false'. +AutoEnable=true diff --git a/meta-digi-dey/recipes-connectivity/bluez/bluez5_5.41.bbappend b/meta-digi-dey/recipes-connectivity/bluez/bluez5_5.41.bbappend index 368f0f698..d786b748d 100644 --- a/meta-digi-dey/recipes-connectivity/bluez/bluez5_5.41.bbappend +++ b/meta-digi-dey/recipes-connectivity/bluez/bluez5_5.41.bbappend @@ -18,15 +18,15 @@ SRC_URI += " \ file://0011-core-Fix-BR-EDR-pairing-for-dual-mode-devices.patch \ " -QCA6564_COMMON_PATCHES = " \ +QCA65XX_COMMON_PATCHES = " \ file://0012-QCA_bluetooth_chip_support.patch \ file://0013-hciattach_rome-Respect-the-user-indication-for-noflo.patch \ file://0014-hciattach-If-the-user-supplies-a-bdaddr-use-it.patch \ file://0015-hciattach-Add-verbosity-option.patch \ " -SRC_URI_append_ccimx6ul = " ${QCA6564_COMMON_PATCHES}" -SRC_URI_append_ccimx6qpsbc = " ${QCA6564_COMMON_PATCHES}" +SRC_URI_append_ccimx6ul = " ${QCA65XX_COMMON_PATCHES}" +SRC_URI_append_ccimx6qpsbc = " ${QCA65XX_COMMON_PATCHES}" inherit update-rc.d diff --git a/meta-digi-dey/recipes-connectivity/bluez/bluez5_5.46.bbappend b/meta-digi-dey/recipes-connectivity/bluez/bluez5_5.46.bbappend index 6246491eb..01d97f9c7 100644 --- a/meta-digi-dey/recipes-connectivity/bluez/bluez5_5.46.bbappend +++ b/meta-digi-dey/recipes-connectivity/bluez/bluez5_5.46.bbappend @@ -10,15 +10,16 @@ SRC_URI += " \ file://0003-port-test-discovery-to-python3.patch \ " -QCA6564_COMMON_PATCHES = " \ +QCA65XX_COMMON_PATCHES = " \ file://0004-QCA_bluetooth_chip_support.patch \ file://0005-hciattach_rome-Respect-the-user-indication-for-noflo.patch \ file://0006-hciattach-If-the-user-supplies-a-bdaddr-use-it.patch \ file://0007-hciattach-Add-verbosity-option.patch \ " -SRC_URI_append_ccimx6ul = " ${QCA6564_COMMON_PATCHES}" -SRC_URI_append_ccimx6qpsbc = " ${QCA6564_COMMON_PATCHES}" +SRC_URI_append_ccimx6ul = " ${QCA65XX_COMMON_PATCHES}" +SRC_URI_append_ccimx6qpsbc = " ${QCA65XX_COMMON_PATCHES}" +SRC_URI_append_ccimx8x = " ${QCA65XX_COMMON_PATCHES}" inherit update-rc.d