treewide: move calibration data extraction function to library
[openwrt/openwrt.git] / target / linux / apm821xx / base-files / etc / hotplug.d / firmware / 10-ath9k-eeprom
1 #!/bin/sh
2
3 [ -e /lib/firmware/$FIRMWARE ] && exit 0
4
5 . /lib/functions/caldata.sh
6
7 ath9k_patch_firmware_mac() {
8 local mac=$1
9
10 [ -z "$mac" ] && return
11
12 macaddr_2bin $mac | dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 seek=2 count=6
13 }
14
15 board=$(board_name)
16
17 case "$FIRMWARE" in
18 "pci_wmac0.eeprom")
19 case $board in
20 netgear,wndr4700)
21 . /lib/upgrade/nand.sh
22
23 if [ -n "$(nand_find_volume ubi0 caldata)" ]; then
24 caldata_extract_ubi "caldata" 0x5000 0x1000
25 else
26 caldata_extract "wifi_data" 0x5000 0x1000
27 ath9k_patch_firmware_mac $(mtd_get_mac_binary wifi_data 0xc)
28 fi
29 ;;
30 *)
31 caldata_die "board $board is not supported yet"
32 ;;
33 esac
34 ;;
35
36 "pci_wmac1.eeprom")
37 case $board in
38 netgear,wndr4700)
39 . /lib/upgrade/nand.sh
40
41 if [ -n "$(nand_find_volume ubi0 caldata)" ]; then
42 caldata_extract_ubi "caldata" 0x1000 0x1000
43 else
44 caldata_extract "wifi_data" 0x1000 0x1000
45 ath9k_patch_firmware_mac $(mtd_get_mac_binary wifi_data 0x0)
46 fi
47 ;;
48 *)
49 caldata_die "board $board is not supported yet"
50 ;;
51 esac
52 ;;
53 esac