mpc85xx: add user-space support for the TL-WDR4900 v1
[openwrt/openwrt.git] / target / linux / mpc85xx / base-files / etc / hotplug.d / firmware / 10-ath9k-eeprom
1 #!/bin/sh
2
3 FW_FILE="/lib/firmware/$FIRMWARE"
4
5 ath9k_eeprom_die() {
6 echo "ath9k eeprom: " "$*" >&2
7 exit 1
8 }
9
10 ath9k_eeprom_extract() {
11 local part=$1
12 local offset=$2
13 local count=$3
14 local mtd
15
16 . /lib/functions.sh
17
18 mtd=$(find_mtd_chardev $part)
19 [ -n "$mtd" ] || \
20 ath9k_eeprom_die "no mtd device found for partition $part"
21
22 dd if=$mtd bs=$offset skip=1 count=1 2>/dev/null | dd of=$FW_FILE bs=$count count=1 2>/dev/null || \
23 ath9k_eeprom_die "failed to extract from $mtd"
24 }
25
26 tpl_set_wireless_mac()
27 {
28 local offset=$1
29 local mac
30
31 . /lib/functions.sh
32
33 mac=$(mtd_get_mac_binary u-boot 326656)
34 mac=$(macaddr_add $mac $offset)
35
36 macaddr_2bin $mac | dd bs=1 count=6 seek=2 conv=notrunc of=$FW_FILE 2>/dev/null
37 }
38
39 [ -e $FW_FILE ] && exit 0
40
41 . /lib/mpc85xx.sh
42
43 board=$(mpc85xx_board_name)
44
45 case "$FIRMWARE" in
46 "pci_wmac0.eeprom")
47 case $board in
48 tl-wdr4900-v1)
49 ath9k_eeprom_extract "caldata" 4096 2048
50 tpl_set_wireless_mac 0
51 ;;
52 *)
53 ath9k_eeprom_die "board $board is not supported yet"
54 ;;
55 esac
56 ;;
57
58 "pci_wmac1.eeprom")
59 case $board in
60 tl-wdr4900-v1)
61 ath9k_eeprom_extract "caldata" 20480 2048
62 tpl_set_wireless_mac -1
63 ;;
64 *)
65 ath9k_eeprom_die "board $board is not supported yet"
66 ;;
67 esac
68 ;;
69 esac