4c5b55bc53811b95994098fdd7b9f5444c389921
[openwrt/openwrt.git] / target / linux / ipq806x / 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 count=$3
12
13 dd if=$source of=/lib/firmware/$FIRMWARE bs=1 skip=$offset count=$count 2>/dev/null || \
14 ath10kcal_die "failed to extract calibration data from $source"
15 }
16
17 ath10kcal_extract() {
18 local part=$1
19 local offset=$2
20 local count=$3
21 local mtd
22
23 mtd=$(find_mtd_chardev $part)
24 [ -n "$mtd" ] || \
25 ath10kcal_die "no mtd device found for partition $part"
26
27 dd if=$mtd of=/lib/firmware/$FIRMWARE bs=1 skip=$offset count=$count 2>/dev/null || \
28 ath10kcal_die "failed to extract calibration data from $mtd"
29 }
30
31 ath10kcal_patch_mac() {
32 local mac=$1
33
34 [ -z "$mac" ] && return
35
36 macaddr_2bin $mac | dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 seek=6 count=6
37 }
38
39 [ -e /lib/firmware/$FIRMWARE ] && exit 0
40
41 . /lib/functions.sh
42 . /lib/functions/system.sh
43
44 board=$(board_name)
45
46
47 case "$FIRMWARE" in
48 "ath10k/pre-cal-ahb-a000000.wifi.bin")
49 case "$board" in
50 ap-dk01.1-c1)
51 ath10kcal_extract "ART" 4096 12064
52 ;;
53 fritz4040)
54 /usr/bin/fritz_cal_extract -i 1 -s 0x400 -e 0x207 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader_config")
55 ;;
56 esac
57 ;;
58 "ath10k/pre-cal-ahb-a800000.wifi.bin")
59 case "$board" in
60 ap-dk01.1-c1)
61 ath10kcal_extract "ART" 20480 12064
62 ;;
63 fritz4040)
64 /usr/bin/fritz_cal_extract -i 1 -s 0x400 -e 0x208 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader_config")
65 ;;
66 esac
67 ;;
68
69 "ath10k/pre-cal-pci-0000:01:00.0.bin")
70 case $board in
71 c2600)
72 ath10kcal_extract "radio" 4096 12064
73 # ath10kcal_patch_mac $(macaddr_add $(mtd_get_mac_binary default-mac 8) -1)
74 ;;
75 d7800 |\
76 r7500v2 |\
77 r7800)
78 ath10kcal_extract "art" 4096 12064
79 ;;
80 ea8500)
81 hw_mac_addr=$(mtd_get_mac_ascii devinfo hw_mac_addr)
82 ath10kcal_extract "art" 4096 12064
83 ;;
84 nbg6817)
85 ath10kcal_extract "0:ART" 4096 12064
86 ;;
87 vr2600v)
88 ath10kcal_extract "ART" 4096 12064
89 ;;
90 esac
91 ;;
92 "ath10k/pre-cal-pci-0001:01:00.0.bin")
93 case $board in
94 c2600)
95 ath10kcal_extract "radio" 20480 12064
96 # ath10kcal_patch_mac $(macaddr_add $(mtd_get_mac_binary default-mac 8) -2)
97 ;;
98 d7800 |\
99 r7500v2 |\
100 r7800)
101 ath10kcal_extract "art" 20480 12064
102 ;;
103 ea8500)
104 hw_mac_addr=$(mtd_get_mac_ascii devinfo hw_mac_addr)
105 ath10kcal_extract "art" 20480 12064
106 ;;
107 nbg6817)
108 ath10kcal_extract "0:ART" 20480 12064
109 ;;
110 vr2600v)
111 ath10kcal_extract "ART" 20480 12064
112 ;;
113 esac
114 ;;
115 *)
116 exit 1
117 ;;
118 esac