uqmi: update to the latest version, also set 802.3 data format via the WDA service
[openwrt/openwrt.git] / target / linux / ar71xx / base-files / etc / hotplug.d / firmware / 10-ath9k-eeprom
1 #!/bin/sh
2
3 ath9k_eeprom_die() {
4 echo "ath9k eeprom: " "$*"
5 exit 1
6 }
7
8 ath9k_eeprom_extract() {
9 local part=$1
10 local offset=$2
11 local count=$3
12 local mtd
13
14 mtd=$(find_mtd_chardev $part)
15 [ -n "$mtd" ] || \
16 ath9k_eeprom_die "no mtd device found for partition $part"
17
18 dd if=$mtd of=/lib/firmware/$FIRMWARE bs=1 skip=$offset count=$count 2>/dev/null || \
19 ath9k_eeprom_die "failed to extract from $mtd"
20 }
21
22 ath9k_patch_firmware_mac() {
23 local mac=$1
24
25 [ -z "$mac" ] && return
26
27 macaddr_2bin $mac | dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 seek=2 count=6
28 }
29
30 [ -e /lib/firmware/$FIRMWARE ] && exit 0
31
32 . /lib/ar71xx.sh
33 . /lib/functions.sh
34 . /lib/functions/system.sh
35
36 board=$(ar71xx_board_name)
37
38 case "$FIRMWARE" in
39 "soc_wmac.eeprom")
40 case $board in
41 wndr3700v4 | \
42 wndr4300)
43 ath9k_eeprom_extract "caldata" 4096 2048
44 ath9k_patch_firmware_mac $(mtd_get_mac_binary caldata 0)
45 ;;
46 *)
47 ath9k_eeprom_die "board $board is not supported yet"
48 ;;
49 esac
50 ;;
51
52 "pci_wmac0.eeprom")
53 case $board in
54 wndr3700v4 | \
55 wndr4300)
56 ath9k_eeprom_extract "caldata" 20480 2048
57 ath9k_patch_firmware_mac $(mtd_get_mac_binary caldata 12)
58 ;;
59 *)
60 ath9k_eeprom_die "board $board is not supported yet"
61 ;;
62 esac
63 ;;
64 esac