ipq806x: add initial support for Netgear R7800
[openwrt/staging/yousong.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/ipq806x.sh
42 . /lib/functions.sh
43 . /lib/functions/system.sh
44
45 board=$(ipq806x_board_name)
46
47
48 case "$FIRMWARE" in
49 "ath10k/cal-pci-0000:01:00.0.bin")
50 case $board in
51 c2600)
52 ath10kcal_extract "radio" 4096 12064
53 # ath10kcal_patch_mac $(macaddr_add $(mtd_get_mac_binary default-mac 8) -1)
54 ;;
55 ea8500)
56 hw_mac_addr=$(mtd_get_mac_ascii devinfo hw_mac_addr)
57 ath10kcal_extract "art" 4096 12064
58 ;;
59 r7800)
60 ath10kcal_extract "art" 4096 12064
61 ;;
62 esac
63 ;;
64 "ath10k/cal-pci-0001:01:00.0.bin")
65 case $board in
66 c2600)
67 ath10kcal_extract "radio" 20480 12064
68 # ath10kcal_patch_mac $(macaddr_add $(mtd_get_mac_binary default-mac 8) -2)
69 ;;
70 ea8500)
71 hw_mac_addr=$(mtd_get_mac_ascii devinfo hw_mac_addr)
72 ath10kcal_extract "art" 20480 12064
73 ;;
74 r7800)
75 ath10kcal_extract "art" 20480 12064
76 ;;
77 esac
78 ;;
79 *)
80 exit 1
81 ;;
82 esac