From 46c7508ee3013883cef67f666893167f654968c1 Mon Sep 17 00:00:00 2001 From: Isaac Hermida Date: Thu, 21 Jul 2016 10:22:49 +0200 Subject: [PATCH] kernel-module-qualcomm: add support to override the region code The region code is programmed in the OTP bits. We want to allow to be able to override this behavior by setting the new value as a property in the device tree called "regulatory-domain". This can be done by setting the variable "regdomain=" in uboot or well by defining that entry in the device tree. https://jira.digi.com/browse/DEL-2799 Signed-off-by: Isaac Hermida --- .../kernel-module-qualcomm/qualcomm-pre-up | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/meta-digi-arm/recipes-kernel/kernel-module-qualcomm/kernel-module-qualcomm/qualcomm-pre-up b/meta-digi-arm/recipes-kernel/kernel-module-qualcomm/kernel-module-qualcomm/qualcomm-pre-up index 6300dd65d..922b0ce17 100644 --- a/meta-digi-arm/recipes-kernel/kernel-module-qualcomm/kernel-module-qualcomm/qualcomm-pre-up +++ b/meta-digi-arm/recipes-kernel/kernel-module-qualcomm/kernel-module-qualcomm/qualcomm-pre-up @@ -50,14 +50,25 @@ if ! cmp -s ${TMP_MACFILE} ${MACFILE}; then fi rm -f ${TMP_MACFILE} -REGION_CODE="$(cat /proc/device-tree/digi,hwid,cert 2>/dev/null)" +OTP_REGION_CODE="$(cat /proc/device-tree/digi,hwid,cert 2>/dev/null)" +DTB_REGION_CODE="$(cat /proc/device-tree/wireless/regulatory-domain 2>/dev/null)" US_CODE="0x0" WW_CODE="0x1" JP_CODE="0x2" +# Check if the DTB_REGION_CODE is in the list of valid codes, +# if not use the OTP programmed value. +case "${DTB_REGION_CODE}" in + ${US_CODE}|${WW_CODE}|${JP_CODE}) + REGULATORY_DOMAIN=${DTB_REGION_CODE};; + *) + logger -t qca6564 "[ERROR] Invalid region code in device tree, using OTP value" + REGULATORY_DOMAIN=${OTP_REGION_CODE};; +esac + BDATA_LINK="${FIRMWARE_DIR}/bdwlan30.bin" # Create a symbolic link to the FW file for the specific country region. BDATA_SOURCE="${FIRMWARE_DIR}/bdwlan30_US.bin" -case "${REGION_CODE}" in +case "${REGULATORY_DOMAIN}" in ${US_CODE}) logger -t qca6564 "Setting US wireless region";; ${WW_CODE}|${JP_CODE})