538047b42d15d2c6fb7b7f3a2caf6ea776945b95
[openwrt.git] / target / linux / ramips / base-files / etc / hotplug.d / firmware / 10-rt2x00-eeprom
1 #!/bin/sh
2
3 rt2x00_eeprom_die() {
4         echo "rt2x00 eeprom: " "$*"
5         exit 1
6 }
7
8 rt2x00_eeprom_extract() {
9         local part=$1
10         local offset=$2
11         local count=$3
12         local mtd
13
14         . /lib/functions.sh
15
16         mtd=$(find_mtd_part $part)
17         [ -n "$mtd" ] || \
18                 rt2x00_eeprom_die "no mtd device found for partition $part"
19
20         dd if=$mtd of=/lib/firmware/$FIRMWARE bs=1 skip=$offset count=$count 2>/dev/null || \
21                 rt2x00_eeprom_die "failed to extract from $mtd"
22 }
23
24 [ -e /lib/firmware/$FIRMWARE ] && exit 0
25
26 . /lib/ramips.sh
27
28 board=$(ramips_board_name)
29
30 case "$FIRMWARE" in
31 "soc_wmac.eeprom")
32         case $board in
33         asl26555 | \
34         dir-300-b1 | \
35         dir-600-b1 | \
36         dir-600-b2 | \
37         dir-615-d)
38                 rt2x00_eeprom_extract "devdata" 16384 272
39                 ;;
40
41         dap-1350)
42                 rt2x00_eeprom_extract "devdata" 0 272
43                 ;;
44
45         rt-n10-plus | \
46         rt-g32-b1)
47                 rt2x00_eeprom_extract "devconf" 0 272
48                 ;;
49
50         f5d8235-v1 | \
51         f5d8235-v2)
52                 rt2x00_eeprom_extract "u-boot" 262144 272
53                 ;;
54
55         3g-6200n | \
56         3g-6200nl | \
57         3g300m | \
58         air3gii | \
59         all0239-3g | \
60         all0256n | \
61         all5002 | \
62         argus-atp52b | \
63         bc2 | \
64         br6425 | \
65         broadway | \
66         br6524n | \
67         carambola | \
68         d105 | \
69         dir-615-h1 | \
70         dir-620-a1 | \
71         dir-620-d1 | \
72         esr-9753 | \
73         fonera20n | \
74         rt-n13u | \
75         freestation5 | \
76         hw550-3g | \
77         mofi3500-3gn | \
78         pwh2004 | \
79         nbg-419n | \
80         nw718 | \
81         omni-emb | \
82         omni-emb-hpm | \
83         psr-680w | \
84         rt-n15 | \
85         rt-n56u | \
86         sl-r7205 | \
87         v11st-fe | \
88         v22rw-2x2 | \
89         w306r-v20 | \
90         w150m | \
91         w502u | \
92         wcr-150gn | \
93         whr-g300n | \
94         wl-330n | \
95         wl-330n3g | \
96         wl-351 | \
97         wli-tx4-ag300n | \
98         wnce2001 | \
99         wr512-3gn | \
100         wr6202 | \
101         mzk-w300nh2 | \
102         ur-326n4g | \
103         ur-336un | \
104         xdxrn502j)
105                 rt2x00_eeprom_extract "factory" 0 272
106                 ;;
107
108         wl341v3)
109                 rt2x00_eeprom_extract "board-nvram" 64880 272
110                 ;;
111
112         *)
113                 rt2x00_eeprom_die "board $board is not supported yet"
114                 ;;
115         esac
116         ;;
117
118 "rt2x00pci_1_0.eeprom")
119         case $board in
120         rt-n56u)
121                 rt2x00_eeprom_extract "factory" 32768 272
122                 ;;
123         esac
124         ;;
125 esac