bluez-init: check on the device tree if the variant has bluetooth

The script was basing on the variant coded in the HWID to determine
if the variant had bluetooth, by comparing to an array of hard-coded variants.
This required the script to be updated with every new variant that supported
Bluetooth.
The patch checks instead if the node 'bluetooth' exists at all in the device tree
to determine if the variant supports Bluetooth.

https://jira.digi.com/browse/DEL-1933

Signed-off-by: Isaac Hermida <isaac.hermida@digi.com>
This commit is contained in:
Isaac Hermida 2015-11-10 12:42:06 +01:00
parent 52b4cfe35c
commit 599627f214
1 changed files with 11 additions and 26 deletions

View File

@ -22,25 +22,12 @@ if [ "${1}" != "start" ]; then
fi fi
SCRIPTNAME="$(basename "${0}")" SCRIPTNAME="$(basename "${0}")"
MACHINENAME="$(cat /proc/device-tree/digi,machine,name 2>/dev/null)"
bt_init() { bt_init() {
# Exit if this hardware does not support Bluetooth
if [ "${MACHINENAME}" = "ccardimx28" ]; then if [ "${MACHINENAME}" = "ccardimx28" ]; then
BLUETOOTH_VARIANTS="0x02 0x03 0x10 0x11 0x12"
MOD_VARIANT="$(cat /proc/device-tree/digi,hwid,variant 2>/dev/null || \
cat "/sys/kernel/${MACHINENAME}/mod_variant")"
if ! echo "${BLUETOOTH_VARIANTS}" | grep -qs "${MOD_VARIANT}"; then
echo "${SCRIPTNAME}: variant ${MOD_VARIANT} does not support bluetooth"
exit
fi
BT_PWR_GPIO_NR="21" BT_PWR_GPIO_NR="21"
elif [ "${MACHINENAME}" = "ccimx6sbc" ]; then elif [ "${MACHINENAME}" = "ccimx6sbc" ]; then
BLUETOOTH_VARIANTS="0x01 0x02 0x03 0x04 0x06 0x0b 0x11 0x12"
MOD_VARIANT="$(cat /proc/device-tree/digi,hwid,variant)"
if ! echo "${BLUETOOTH_VARIANTS}" | grep -qs "${MOD_VARIANT}"; then
echo "${SCRIPTNAME}: variant ${MOD_VARIANT} does not support bluetooth"
exit
fi
BT_PWR_GPIO_NR="244" BT_PWR_GPIO_NR="244"
fi fi
@ -63,8 +50,7 @@ bt_init() {
[ -f "${FW_MAC}" ] && [ "$(cat ${FW_MAC})" = "${BTADDR}" ] || echo ${BTADDR} > ${FW_MAC} [ -f "${FW_MAC}" ] && [ "$(cat ${FW_MAC})" = "${BTADDR}" ] || echo ${BTADDR} > ${FW_MAC}
JPN_REGCODE="0x2" JPN_REGCODE="0x2"
REGCODE="$(cat /proc/device-tree/digi,hwid,cert 2>/dev/null || \ REGCODE="$(cat /proc/device-tree/digi,hwid,cert 2>/dev/null)"
cat "/sys/kernel/${MACHINENAME}/mod_cert")"
BT_CLASS_LINK="PS_ASIC.pst" BT_CLASS_LINK="PS_ASIC.pst"
BT_CLASS_FILE="PS_ASIC_class_1.pst" BT_CLASS_FILE="PS_ASIC_class_1.pst"
if [ -n "${REGCODE}" ] && [ "${JPN_REGCODE}" = "${REGCODE}" ]; then if [ -n "${REGCODE}" ] && [ "${JPN_REGCODE}" = "${REGCODE}" ]; then
@ -104,17 +90,16 @@ bt_init() {
echo "${SCRIPTNAME}: FAILED (abtfilt)" echo "${SCRIPTNAME}: FAILED (abtfilt)"
exit exit
fi fi
if hciconfig hci0 up; then
: # No-op
else
echo "${SCRIPTNAME}: FAILED"
exit
fi
} }
echo "Starting bluetooth services." echo "Starting bluetooth services."
start-stop-daemon -S --background --exec /usr/lib/bluez5/bluetooth/bluetoothd
# Initialize driver for 'ccardimx28js' # Check if this hardware does support Bluetooth
MACHINENAME="$(cat /proc/device-tree/digi,machine,name 2>/dev/null || cat /sys/kernel/machine/name)" [ -d "/proc/device-tree/bluetooth" ] && bt_init
[ "${MACHINENAME}" = "ccardimx28" -o "${MACHINENAME}" = "ccimx6sbc" ] && bt_init
# Run bluetooth daemon
if hciconfig hci0 up && start-stop-daemon -S --background --exec /usr/lib/bluez5/bluetooth/bluetoothd; then
: # No-op
else
echo "${SCRIPTNAME}: FAILED"
fi