#!/bin/sh -l #=============================================================================== # # 10-atheros_pre-up # # Copyright (C) 2012 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: Load Atheros' wireless driver # #=============================================================================== set -e [ "${IFACE}" != "wlan0" ] && exit 0 FIRMWARE_DIR="/lib/firmware/ath6k/AR6003/hw2.1.1" RAM_DRIVE="/var/run" MAC_FILENAME="softmac" # # Get the wlan MAC address from NVRAM. Use a default # value if the address has not been set. # # TODO: Hardcoded until passed to kernel command line from U-Boot. #MAC_ADDR="$(nvram print module ethaddr2 | sed 's,ethaddr2=,,g')" #if [ -z "${MAC_ADDR}" -o "${MAC_ADDR}" = "00:00:00:00:00:00" ]; then MAC_ADDR="00:04:F3:4C:B1:D3" #fi mac1="$(echo ${MAC_ADDR} | cut -d':' -f1)" mac2="$(echo ${MAC_ADDR} | cut -d':' -f2)" mac3="$(echo ${MAC_ADDR} | cut -d':' -f3)" mac4="$(echo ${MAC_ADDR} | cut -d':' -f4)" mac5="$(echo ${MAC_ADDR} | cut -d':' -f5)" mac6="$(echo ${MAC_ADDR} | cut -d':' -f6)" printf "\x${mac1}\x${mac2}\x${mac3}\x${mac4}\x${mac5}\x${mac6}" > ${RAM_DRIVE}/${MAC_FILENAME} # We need to write the WLAN MAC address to softmac in the ath6k firmware # directory. However, we don't want to rewrite the file if it already exists # and the address is the same because we don't want to wear out NAND flash. # # So create the file on the RAM DRIVE first and compare the two. Only update # the copy on NAND if the address has changed. # if ! cmp -s ${RAM_DRIVE}/${MAC_FILENAME} ${FIRMWARE_DIR}/${MAC_FILENAME}; then cp ${RAM_DRIVE}/${MAC_FILENAME} ${FIRMWARE_DIR}/${MAC_FILENAME} fi rm -f ${RAM_DRIVE}/${MAC_FILENAME} # 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" REGION_CODE="$(cat /sys/kernel/ccardxmx28/mod_cert)" if [ -z "${REGION_CODE}" -o "${US_CODE}" = "${REGION_CODE}" ]; then BDATA_SOURCE=Digi_6203-6233-US.bin else BDATA_SOURCE=Digi_6203-6233-World.bin fi # We don't want to rewrite NAND every time we boot so only # change the link if it is wrong. BDATA_LINK="${FIRMWARE_DIR}/bdata.bin" if [ ! -e "${BDATA_LINK}" ] || ! cmp -s "${BDATA_LINK}" "${FIRMWARE_DIR}/${BDATA_SOURCE}"; then ln -sf "${BDATA_SOURCE}" "${BDATA_LINK}" fi # ath6kl_sdio.ko ATH6KL_PARAMS="" [ -f "/root/wifi_test_mode" ] && { ATH6KL_PARAMS="${ATH6KL_PARAMS} testmode=1"; test_mode_str=" in test mode"; } grep -qs ath6kl_sdio /proc/modules || \ /sbin/modprobe -q ath6kl_sdio ${ATH6KL_PARAMS} || echo "Loading ath6kl_sdio module${test_mode_str}: [FAILED]" # Delay required for the interface 'wlan0' to settle down before trying to configure it. sleep 0.5