ramips: soc wmac eeprom cleanup
[openwrt/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 . /lib/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 FW="/lib/firmware/$FIRMWARE"
25 [ -e "$FW" ] && exit 0
26
27 . /lib/ramips.sh
28
29 board=$(ramips_board_name)
30
31 case "$FIRMWARE" in
32 "soc_wmac.eeprom")
33 case $board in
34 *)
35 rt2x00_eeprom_die "Please define mtd-eeprom in $board DTS file!"
36 ;;
37 esac
38 ;;
39
40 "rt2x00pci_1_0.eeprom")
41 case $board in
42 cy-swr1100)
43 rt2x00_eeprom_extract "factory" 8192 512
44 ;;
45 rt-n56u | whr-600d | whr-1166d)
46 rt2x00_eeprom_extract "factory" 32768 512
47 ;;
48 esac
49 ;;
50 esac