2d5e09d01519491285ecabf8431e093e8f9d4fa4
[openwrt/openwrt.git] / target / linux / lantiq / base-files / etc / hotplug.d / firmware / 10-rt2x00-eeprom
1 #!/bin/sh
2 # based on gabors ralink wisoc implementation
3
4 rt2x00_eeprom_die() {
5 echo "rt2x00 eeprom: " "$*"
6 exit 1
7 }
8
9 rt2x00_eeprom_extract() {
10 local part=$1
11 local offset=$2
12 local count=$3
13 local mtd
14
15 . /lib/functions.sh
16
17 mtd=$(find_mtd_part $part)
18 [ -n "$mtd" ] || \
19 rt2x00_eeprom_die "no mtd device found for partition $part"
20
21 dd if=$mtd of=/lib/firmware/$FIRMWARE bs=1 skip=$offset count=$count || \
22 rt2x00_eeprom_die "failed to extract from $mtd"
23 }
24
25 [ -e /lib/firmware/$FIRMWARE ] && exit 0
26 . /lib/functions/lantiq.sh
27
28 case "$FIRMWARE" in
29 "RT2860.eeprom" )
30 local board=$(lantiq_board_id)
31 case $board in
32 ARV7510PW22|ARV7525PW|ARV752DPW|ARV752DPW22)
33 rt2x00_eeprom_extract "board_config" 1040 512
34 ;;
35 *)
36 rt2x00_eeprom_die "board $board is not supported yet"
37 ;;
38 esac
39 ;;
40 esac