10-rt2x00-eeprom 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #!/bin/sh
  2. # based on gabors ralink wisoc implementation
  3. rt2x00_eeprom_die() {
  4. echo "rt2x00 eeprom: " "$*"
  5. exit 1
  6. }
  7. rt2x00_eeprom_extract() {
  8. local part=$1
  9. local offset=$2
  10. local count=$3
  11. local swab=$4
  12. local mtd
  13. . /lib/functions.sh
  14. mtd=$(find_mtd_part $part)
  15. [ -n "$mtd" ] || \
  16. rt2x00_eeprom_die "no mtd device found for partition $part"
  17. if [ $swab -gt 0 ]; then
  18. dd if=$mtd of=/lib/firmware/$FIRMWARE bs=2 skip=$offset count=$count conv=swab || \
  19. rt2x00_eeprom_die "failed to extract from $mtd"
  20. else
  21. dd if=$mtd of=/lib/firmware/$FIRMWARE bs=1 skip=$offset count=$count || \
  22. rt2x00_eeprom_die "failed to extract from $mtd"
  23. fi
  24. }
  25. [ -e /lib/firmware/$FIRMWARE ] && exit 0
  26. . /lib/functions/lantiq.sh
  27. case "$FIRMWARE" in
  28. "RT2860.eeprom" )
  29. local board=$(lantiq_board_name)
  30. case $board in
  31. ARV7510PW22|ARV7519PW|ARV752DPW|ARV752DPW22|VGV7519)
  32. rt2x00_eeprom_extract "board_config" 520 256 1
  33. ;;
  34. ARV7525PW)
  35. rt2x00_eeprom_extract "board_config" 1040 512 0
  36. ;;
  37. *)
  38. rt2x00_eeprom_die "board $board is not supported yet"
  39. ;;
  40. esac
  41. ;;
  42. "RT3062.eeprom" )
  43. local board=$(lantiq_board_name)
  44. case $board in
  45. VGV7510KW22)
  46. rt2x00_eeprom_extract "board_config" 520 256 1
  47. ;;
  48. *)
  49. rt2x00_eeprom_die "board $board is not supported yet"
  50. ;;
  51. esac
  52. ;;
  53. esac