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