From cd253b370bcf02083a6a1f89dd23d8fb4353f4f6 Mon Sep 17 00:00:00 2001 From: Isaac Hermida Date: Wed, 20 Jul 2016 13:42:52 +0200 Subject: [PATCH] kernel-module-qualcomm: load specific firmware file per region The country region is programmed in the OTP bits. Based on that value we need to load the firmware file for the specific country region. https://jira.digi.com/browse/DEL-2774 Signed-off-by: Isaac Hermida --- .../kernel-module-qualcomm/qualcomm-pre-up | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) 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 f9f4e232d..6300dd65d 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 @@ -17,7 +17,8 @@ [ "${IFACE}" != "wlan0" ] && exit 0 -MACFILE="/lib/firmware/wlan/wlan_mac.bin" +FIRMWARE_DIR="/lib/firmware" +MACFILE="${FIRMWARE_DIR}/wlan/wlan_mac.bin" TMP_MACFILE="$(mktemp -t wlan_mac.XXXXXX)" # Read the MACs from DeviceTree. We can have up to four wireless interfaces @@ -49,6 +50,31 @@ if ! cmp -s ${TMP_MACFILE} ${MACFILE}; then fi rm -f ${TMP_MACFILE} +REGION_CODE="$(cat /proc/device-tree/digi,hwid,cert 2>/dev/null)" +US_CODE="0x0" +WW_CODE="0x1" +JP_CODE="0x2" +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 + ${US_CODE}) + logger -t qca6564 "Setting US wireless region";; + ${WW_CODE}|${JP_CODE}) + logger -t qca6564 "Setting WW (world wide) wireless region" + BDATA_SOURCE="${FIRMWARE_DIR}/bdwlan30_World.bin";; + "") + logger -t qca6564 "[WARN] region code not found, using US";; + *) + logger -t qca6564 "[WARN] Invalid region code, using US";; +esac + +# We don't want to rewrite NAND every time we boot so only +# change the link if it is wrong. +if [ ! -e "${BDATA_LINK}" ] || ! cmp -s "${BDATA_LINK}" "${BDATA_SOURCE}"; then + ln -sf "${BDATA_SOURCE}" "${BDATA_LINK}" +fi + # Check the version of modprobe installed to compound the arguments. if readlink -f $(which modprobe) | grep -qs kmod; then MODPROBE_ARGS="-i"