fe31ed323dfbb63ba7eb2a0282222db17f6ac09f
[openwrt/openwrt.git] / target / linux / brcm63xx / 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 mtd=$(find_mtd_part $part)
16 [ -n "$mtd" ] || \
17 rt2x00_eeprom_die "no mtd device found for partition $part"
18
19 dd if=$mtd of=/lib/firmware/$FIRMWARE bs=1 skip=$offset count=$count || \
20 rt2x00_eeprom_die "failed to extract from $mtd"
21 }
22
23 [ -e /lib/firmware/$FIRMWARE ] && exit 0
24
25 . /lib/functions.sh
26
27 board=$(board_name)
28
29 case "$FIRMWARE" in
30 "rt2x00.eeprom" )
31 case $board in
32 hg556a_c)
33 rt2x00_eeprom_extract "cal_data" 130560 512
34 ;;
35 hg622 |\
36 hg655b)
37 rt2x00_eeprom_extract "cal_data" 0 512
38 ;;
39 *)
40 rt2x00_eeprom_die "board $board is not supported yet"
41 ;;
42 esac
43 ;;
44 esac