eb756a5e5f82a0fce21e2c348d0171d34cbd954c
[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         . /etc/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 || \
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 "RT288X.eeprom" | \
32 "RT305X.eeprom" | \
33 "RT3883.eeprom")
34         case $board in
35         dir-300-b1 | \
36         dir-600-b1 | \
37         dir-600-b2)
38                 rt2x00_eeprom_extract "devdata" 16384 272
39                 ;;
40
41         rt-g32-b1)
42                 rt2x00_eeprom_extract "devconf" 0 272
43                 ;;
44
45         f5d8235-v1 | \
46         f5d8235-v2)
47                 rt2x00_eeprom_extract "u-boot" 262144 272
48                 ;;
49
50         all0256n | \
51         argus-atp52b | \
52         bc2 | \
53         esr-9753 | \
54         fonera20n | \
55         hw550-3g | \
56         mofi3500-3gn | \
57         pwh2004 | \
58         nbg-419n | \
59         nw718 | \
60         omni-emb | \
61         rt-n15 | \
62         rt-n56u | \
63         sl-r7205 | \
64         v11st-fe | \
65         v22rw-2x2 | \
66         w502u | \
67         wcr-150gn | \
68         whr-g300n | \
69         wl-351 | \
70         wli-tx4-ag300n | \
71         wr512-3gn | \
72         wr6202)
73                 rt2x00_eeprom_extract "factory" 0 272
74                 ;;
75
76         wl341v3)
77                 rt2x00_eeprom_extract "board-nvram" 64880 272
78                 ;;
79
80         *)
81                 rt2x00_eeprom_die "board $board is not supported yet"
82                 ;;
83         esac
84         ;;
85
86 "rt2x00pci_1_0.eeprom")
87         case $board in
88         rt-n56u)
89                 rt2x00_eeprom_extract "factory" 32768 272
90                 ;;
91         esac
92         ;;
93 esac