a0e2e9d1237bdfaa5d00e7a07aa7d98cacf8efe7
[openwrt/openwrt.git] / target / linux / ipq806x / base-files / etc / hotplug.d / firmware / 11-ath10k-caldata
1 #!/bin/sh
2
3 [ -e /lib/firmware/$FIRMWARE ] && exit 0
4
5 . /lib/functions/caldata.sh
6
7 board=$(board_name)
8
9 dt_base64_extract() {
10 local target_dir="/sys$DEVPATH"
11 local source="$target_dir/../../of_node/qcom,ath10k-calibration-data-base64"
12
13 [ -e "$source" ] || caldata_die "cannot find base64 calibration data: $source"
14 [ -d "$target_dir" ] || \
15 caldata_die "no sysfs dir to write: $target"
16
17 echo 1 > "$target_dir/loading"
18 base64decode.uc "$source" > "$target_dir/data"
19 if [ $? != 0 ]; then
20 echo 1 > "$target_dir/loading"
21 caldata_die \
22 "failed to write calibration data to $target_dir/data"
23 else
24 echo 0 > "$target_dir/loading"
25 fi
26 }
27
28 case "$FIRMWARE" in
29 "ath10k/cal-pci-0000:01:00.0.bin")
30 case "$board" in
31 asus,onhub |\
32 tplink,onhub)
33 dt_base64_extract
34 ;;
35 meraki,mr52)
36 CI_UBIPART=art
37 caldata_extract_ubi "ART" 0x1000 0x844
38 ;;
39 esac
40 ;;
41 "ath10k/pre-cal-pci-0000:01:00.0.bin")
42 case $board in
43 asrock,g10)
44 caldata_extract "0:art" 0x1000 0x2f20
45 ;;
46 linksys,ea7500-v1 |\
47 linksys,ea8500)
48 caldata_extract "art" 0x1000 0x2f20
49 ath10k_patch_mac $(macaddr_add $(mtd_get_mac_ascii devinfo hw_mac_addr) 1)
50 ;;
51 meraki,mr42)
52 CI_UBIPART=art
53 caldata_extract_ubi "ART" 0x1000 0x2f20
54 ;;
55 zyxel,nbg6817)
56 caldata_extract "0:art" 0x1000 0x2f20
57 ath10k_patch_mac $(macaddr_add $(mtd_get_mac_ascii 0:appsblenv ethaddr) 1)
58 ;;
59 esac
60 ;;
61 "ath10k/cal-pci-0001:01:00.0.bin")
62 case "$board" in
63 asus,onhub |\
64 tplink,onhub)
65 dt_base64_extract
66 ;;
67 esac
68 ;;
69 "ath10k/pre-cal-pci-0001:01:00.0.bin")
70 case $board in
71 asrock,g10)
72 caldata_extract "0:art" 0x5000 0x2f20
73 ;;
74 edgecore,ecw5410)
75 caldata_extract "0:art" 0x1000 0x2f20
76 ;;
77 linksys,ea7500-v1 |\
78 linksys,ea8500)
79 caldata_extract "art" 0x5000 0x2f20
80 ath10k_patch_mac $(macaddr_add $(mtd_get_mac_ascii devinfo hw_mac_addr) 2)
81 ;;
82 meraki,mr42 |\
83 meraki,mr52)
84 CI_UBIPART=art
85 caldata_extract_ubi "ART" 0x5000 0x2f20
86 ;;
87 zyxel,nbg6817)
88 caldata_extract "0:art" 0x5000 0x2f20
89 ath10k_patch_mac $(mtd_get_mac_ascii 0:appsblenv ethaddr)
90 ;;
91 esac
92 ;;
93 "ath10k/cal-pci-0002:01:00.0.bin")
94 case "$board" in
95 asus,onhub |\
96 tplink,onhub)
97 dt_base64_extract
98 ;;
99 meraki,mr42)
100 CI_UBIPART=art
101 caldata_extract_ubi "ART" 0x9000 0x844
102 ;;
103 esac
104 ;;
105 "ath10k/pre-cal-pci-0002:01:00.0.bin")
106 case $board in
107 edgecore,ecw5410)
108 caldata_extract "0:art" 0x5000 0x2f20
109 ;;
110 meraki,mr52)
111 CI_UBIPART=art
112 caldata_extract_ubi "ART" 0x9000 0x2f20
113 ;;
114 esac
115 ;;
116 *)
117 exit 1
118 ;;
119 esac