lede/target/linux/ipq60xx/base-files/etc/hotplug.d/firmware/11-ath11k-caldata
2022-11-16 22:25:49 +08:00

82 lines
1.5 KiB
Bash

#!/bin/sh
[ -e /lib/firmware/$FIRMWARE ] && exit 0
. /lib/functions/caldata.sh
. /lib/functions/system.sh
board=$(board_name)
ath11k_generate_macs() {
case "$board" in
linksys,mr7350)
eth=$(mtd_get_mac_ascii devinfo hw_mac_addr)
;;
*)
eth=$(cat /sys/class/net/eth0/address)
;;
esac
touch /lib/firmware/ath11k-macs
mac1=$(macaddr_add $eth 2)
mac2=$(macaddr_add $eth 3)
mac3=$(macaddr_add $eth 4)
echo -ne \\x${mac1//:/\\x} >> /lib/firmware/ath11k-macs
echo -ne \\x${mac2//:/\\x} >> /lib/firmware/ath11k-macs
echo -ne \\x${mac3//:/\\x} >> /lib/firmware/ath11k-macs
}
ath11kcal_die() {
echo "ath11cal: " "$*"
exit 1
}
ath11kcal_extract() {
local part=$1
local offset=$2
local count=$3
local mtd
mtd=$(find_mtd_chardev $part)
[ -n "$mtd" ] || \
ath11kcal_die "no mtd device found for partition $part"
dd if=$mtd of=/lib/firmware/$FIRMWARE iflag=skip_bytes bs=$count skip=$offset count=1 2>/dev/null || \
ath11kcal_die "failed to extract calibration data from $mtd"
}
case "$FIRMWARE" in
"ath11k/IPQ6018/hw1.0/cal-ahb-c000000.wifi.bin")
case "$board" in
cmiot,ax18|\
linksys,mr7350|\
qihoo,v6|\
zn,m2)
caldata_extract "0:art" 0x1000 0x10000
;;
tplink,eap610-outdoor)
# /tmp/factory_data should be mounted by preinit
cp /tmp/factory_data/radio "/lib/firmware/$FIRMWARE"
;;
*)
caldata_die "Don't know how to read caldata for $board"
;;
esac
;;
ath11k-macs)
case "$board" in
cmiot,ax18|\
linksys,mr7350|\
qihoo,v6|\
zn,m2)
ath11k_generate_macs
;;
esac
;;
*)
exit 1
;;
esac