From 4e76f14e4292ec3afa675a35c91c93bc6963a224 Mon Sep 17 00:00:00 2001 From: Alex Gonzalez Date: Thu, 22 Aug 2013 18:06:34 +0200 Subject: [PATCH] meta-digi: Use proc device tree information for hwid information. Modify the atheros and bluetooth init scripts to fetch the hwid details from the device tree. https://jira.digi.com/browse/DEL-572 Signed-off-by: Alex Gonzalez --- .../ccardimx28js/atheros | 28 +++++++++++-------- .../btfilter/files/bluez-init | 20 +++++++++++-- 2 files changed, 33 insertions(+), 15 deletions(-) diff --git a/meta-digi-arm/recipes-kernel/kernel-module-atheros/kernel-module-atheros/ccardimx28js/atheros b/meta-digi-arm/recipes-kernel/kernel-module-atheros/kernel-module-atheros/ccardimx28js/atheros index ffe894661..1dc23cbb8 100644 --- a/meta-digi-arm/recipes-kernel/kernel-module-atheros/kernel-module-atheros/ccardimx28js/atheros +++ b/meta-digi-arm/recipes-kernel/kernel-module-atheros/kernel-module-atheros/ccardimx28js/atheros @@ -53,22 +53,26 @@ if ! cmp -s ${RAM_DRIVE}/${MAC_FILENAME} ${FIRMWARE_DIR}/${MAC_FILENAME}; then fi rm -f ${RAM_DRIVE}/${MAC_FILENAME} -BDATA_SOURCE="Digi_6203-6233-World.bin" +# Figure out which wireless region we are in. The US has rules for +# what channels can be used and at what power level. We use a different set of +# rules for the other regions in the world that we sell into. The mod_cert field +# in OTP will be set to 0x0 for the US. Once we know the region, make sure the +# appropriate calibration file is loaded. +# if [ -e "/sys/kernel/machine/name" ]; then - # Figure out which wireless region we are in. The US has rules for - # what channels can be used and at what power level. We use a different set of - # rules for the other regions in the world that we sell into. The mod_cert field - # in OTP will be set to 0x0 for the US. Once we know the region, make sure the - # appropriate calibration file is loaded. - # - US_CODE="0x0" MACHINE="$(cat /sys/kernel/machine/name)" REGION_CODE="$(cat /sys/kernel/${MACHINE}/mod_cert)" - if [ -z "${REGION_CODE}" -o "${US_CODE}" = "${REGION_CODE}" ]; then - BDATA_SOURCE="Digi_6203-6233-US.bin" - fi +elif [ -e "/proc/device-tree/digi,hwid,cert" ]; then + REGION_CODE="$(cat /proc/device-tree/digi,hwid,cert)" +fi + +US_CODE="0x0" +BDATA_SOURCE="Digi_6203-6233-World.bin" +if [ -n "${REGION_CODE}" -a "${US_CODE}" = "${REGION_CODE}" ]; then + BDATA_SOURCE="Digi_6203-6233-US.bin" + logger -t atheros "Setting US wireless region." else - logger -t atheros "Undefined machine, defaulting to world region." + logger -t atheros "Setting non-US (world) wireless region." fi # We don't want to rewrite NAND every time we boot so only diff --git a/meta-digi-dey/recipes-connectivity/btfilter/files/bluez-init b/meta-digi-dey/recipes-connectivity/btfilter/files/bluez-init index 56a36896b..6f15c45f6 100755 --- a/meta-digi-dey/recipes-connectivity/btfilter/files/bluez-init +++ b/meta-digi-dey/recipes-connectivity/btfilter/files/bluez-init @@ -28,7 +28,11 @@ ccardimx28js_bt_init() { # Exit if this hardware does not support Bluetooth # BLUE_TOOTH_VARIANTS="0x02 0x03 0x10 0x11" - MOD_VARIANT="$(cat /sys/kernel/ccardimx28/mod_variant)" + if [ -e "/proc/device-tree/digi,hwid,variant" ]; then + MOD_VARIANT="$(cat /proc/device-tree/digi,hwid,variant)" + elif [ -e "/sys/kernel/ccardimx28/mod_variant" ]; then + MOD_VARIANT="$(cat /sys/kernel/ccardimx28/mod_variant)" + fi if ! echo ${BLUE_TOOTH_VARIANTS} | grep -qs ${MOD_VARIANT}; then echo "${SCRIPTNAME}: FAILED (variant ${MOD_VARIANT} does not support bluetooth)" exit @@ -63,7 +67,11 @@ ccardimx28js_bt_init() { # for class 2 Bluetooth. # JAPANESE_REGION_CODE="0x2" - REGION_CODE="$(cat /sys/kernel/ccardimx28/mod_cert)" + if [ -e "/proc/device-tree/digi,hwid,cert" ]; then + REGION_CODE="$(cat /proc/device-tree/digi,hwid,cert)" + elif [ -e "/sys/kernel/ccardimx28/mod_cert" ]; then + REGION_CODE="$(cat /sys/kernel/ccardimx28/mod_cert)" + fi if [ -n "${REGION_CODE}" -a "${JAPANESE_REGION_CODE}" = "${REGION_CODE}" ]; then # # We don't want to wear out flash rewriting the configuration file, @@ -123,7 +131,13 @@ ccardimx28js_bt_init() { echo "Starting bluetooth services." # Initialize driver for 'ccardimx28js' -[ "$(cat /sys/kernel/machine/name)" = "ccardimx28" ] && ccardimx28js_bt_init +if [ -e "/proc/device-tree/digi,machine,name" ]; then + MACHINENAME="$(cat /proc/device-tree/digi,machine,name)" +elif [ -e "/sys/kernel/machine/name" ]; then + MACHINENAME="$(cat /sys/kernel/machine/name)" +fi + +[ "${MACHINENAME}" = "ccardimx28" ] && ccardimx28js_bt_init # Run bluetooth daemon if hciconfig hci0 up && bluetoothd; then