ramips: rt305x: add user-space support for the Asus RT-N13U
[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 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 "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         dap-1350)
42                 rt2x00_eeprom_extract "devdata" 0 272
43                 ;;
44
45         dir-615-d | \
46         rt-n10-plus | \
47         rt-g32-b1)
48                 rt2x00_eeprom_extract "devconf" 0 272
49                 ;;
50
51         f5d8235-v1 | \
52         f5d8235-v2)
53                 rt2x00_eeprom_extract "u-boot" 262144 272
54                 ;;
55
56         3g-6200n | \
57         all0239-3g | \
58         all0256n | \
59         all5002 | \
60         argus-atp52b | \
61         bc2 | \
62         carambola | \
63         dir-615-h1 | \
64         dir-620-a1 | \
65         esr-9753 | \
66         fonera20n | \
67         rt-n13u | \
68         freestation5 | \
69         hw550-3g | \
70         mofi3500-3gn | \
71         pwh2004 | \
72         nbg-419n | \
73         nw718 | \
74         omni-emb | \
75         psr-680w | \
76         rt-n15 | \
77         rt-n56u | \
78         sl-r7205 | \
79         v11st-fe | \
80         v22rw-2x2 | \
81         w306r-v20 | \
82         w502u | \
83         wcr-150gn | \
84         whr-g300n | \
85         wl-330n | \
86         wl-330n3g | \
87         wl-351 | \
88         wli-tx4-ag300n | \
89         wr512-3gn | \
90         wr6202 | \
91         ur-336un | \
92         xdxrn502j)
93                 rt2x00_eeprom_extract "factory" 0 272
94                 ;;
95
96         wl341v3)
97                 rt2x00_eeprom_extract "board-nvram" 64880 272
98                 ;;
99
100         *)
101                 rt2x00_eeprom_die "board $board is not supported yet"
102                 ;;
103         esac
104         ;;
105
106 "rt2x00pci_1_0.eeprom")
107         case $board in
108         rt-n56u)
109                 rt2x00_eeprom_extract "factory" 32768 272
110                 ;;
111         esac
112         ;;
113 esac