ar71xx: wndr4300: set official mac addresses
[openwrt/svn-archive/archive.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
35 board=$(ar71xx_board_name)
36
37 case "$FIRMWARE" in
38 "soc_wmac.eeprom")
39 case $board in
40 wndr4300)
41 ath9k_eeprom_extract "caldata" 4096 2048
42 ath9k_patch_firmware_mac $(mtd_get_mac_binary caldata 0)
43 ;;
44 *)
45 ath9k_eeprom_die "board $board is not supported yet"
46 ;;
47 esac
48 ;;
49
50 "pci_wmac0.eeprom")
51 case $board in
52 wndr4300)
53 ath9k_eeprom_extract "caldata" 20480 2048
54 ath9k_patch_firmware_mac $(mtd_get_mac_binary caldata 12)
55 ;;
56 *)
57 ath9k_eeprom_die "board $board is not supported yet"
58 ;;
59 esac
60 ;;
61 esac