fef89eae0e947e2983914f4db27e47587b1407fd
[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 512
39                 ;;
40
41         dap-1350)
42                 rt2x00_eeprom_extract "devdata" 0 512
43                 ;;
44
45         rt-n10-plus | \
46         rt-g32-b1)
47                 rt2x00_eeprom_extract "devconf" 0 512
48                 ;;
49
50         f5d8235-v1 | \
51         f5d8235-v2)
52                 rt2x00_eeprom_extract "u-boot" 262144 512
53                 ;;
54
55         3g-6200n | \
56         3g-6200nl | \
57         3g300m | \
58         air3gii | \
59         all0239-3g | \
60         all0256n | \
61         all5002 | \
62         all5003 | \
63         argus-atp52b | \
64         bc2 | \
65         br6425 | \
66         broadway | \
67         br6524n | \
68         carambola | \
69         d105 | \
70         dir-615-h1 | \
71         dir-620-a1 | \
72         dir-620-d1 | \
73         esr-9753 | \
74         f7c027 | \
75         fonera20n | \
76         rt-n13u | \
77         freestation5 | \
78         hw550-3g | \
79         mofi3500-3gn | \
80         mpr-a2 | \
81         pwh2004 | \
82         nbg-419n | \
83         nw718 | \
84         omni-emb | \
85         omni-emb-hpm | \
86         psr-680w | \
87         rt-n15 | \
88         rt-n56u | \
89         sl-r7205 | \
90         v11st-fe | \
91         v22rw-2x2 | \
92         w306r-v20 | \
93         w150m | \
94         w502u | \
95         wcr-150gn | \
96         whr-g300n | \
97         wl-330n | \
98         wl-330n3g | \
99         wl-351 | \
100         wli-tx4-ag300n | \
101         wnce2001 | \
102         wr512-3gn | \
103         wr6202 | \
104         mzk-w300nh2 | \
105         ur-326n4g | \
106         ur-336un | \
107         xdxrn502j)
108                 rt2x00_eeprom_extract "factory" 0 512
109                 ;;
110
111         wl341v3)
112                 rt2x00_eeprom_extract "board-nvram" 64880 512
113                 ;;
114
115         *)
116                 rt2x00_eeprom_die "board $board is not supported yet"
117                 ;;
118         esac
119         ;;
120
121 "rt2x00pci_1_0.eeprom")
122         case $board in
123         rt-n56u)
124                 rt2x00_eeprom_extract "factory" 32768 512
125                 ;;
126         esac
127         ;;
128 esac