add chaos_calmer branch
[15.05/openwrt.git] / target / linux / ar71xx / base-files / etc / hotplug.d / firmware / 11-ath10k-caldata
1 #!/bin/sh
2
3 ath10kcal_die() {
4         echo "ath10cal: " "$*"
5         exit 1
6 }
7
8 ath10kcal_from_file() {
9         local source=$1
10         local offset=$2
11         local target=$3
12
13         dd if=$source of=$target bs=1 skip=$offset count=2116 2>/dev/null || \
14                 ath10kcal_die "failed to extract calibration data from $source"
15 }
16
17 [ -e /lib/firmware/$FIRMWARE ] && exit 0
18
19 . /lib/ar71xx.sh
20 . /lib/functions.sh
21 . /lib/functions/system.sh
22
23 ath10kcal_mac=""
24 ath10kcal_tmp="/tmp/ath10k-caldata.bin"
25
26 board=$(ar71xx_board_name)
27
28 case "$FIRMWARE" in
29 "ath10k/cal-pci-0000:01:00.0.bin")
30         case $board in
31         rb-911g-5hpacd)
32                 ath10kcal_from_file "/sys/firmware/routerboot/ext_wlan_data" 20480 $ath10kcal_tmp
33                 ;;
34         esac
35         ;;
36
37 *)
38         exit 1
39         ;;
40 esac
41
42 [ -f $ath10kcal_tmp ] && {
43         cp $ath10kcal_tmp /lib/firmware/$FIRMWARE
44         rm -f $ath10kcal_tmp
45 }