10-ath9k-eeprom 730 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/bin/sh
  2. [ -e /lib/firmware/$FIRMWARE ] && exit 0
  3. . /lib/functions.sh
  4. . /lib/functions/system.sh
  5. ath9k_eeprom_die() {
  6. echo "ath9k eeprom: " "$*"
  7. exit 1
  8. }
  9. ath9k_eeprom_extract() {
  10. local part=$1
  11. local offset=$2
  12. local count=$3
  13. local mtd
  14. mtd=$(find_mtd_chardev $part)
  15. [ -n "$mtd" ] || \
  16. ath9k_eeprom_die "no mtd device found for partition $part"
  17. dd if=$mtd of=/lib/firmware/$FIRMWARE bs=1 skip=$offset count=$count 2>/dev/null || \
  18. ath9k_eeprom_die "failed to extract from $mtd"
  19. }
  20. board=$(board_name)
  21. case "$FIRMWARE" in
  22. "ath9k-eeprom-pci-0000:00:00.0.bin")
  23. case $board in
  24. "ubnt,unifi")
  25. ath9k_eeprom_extract "art" 4096 2048
  26. ;;
  27. *)
  28. ath9k_eeprom_die "board $board is not supported yet"
  29. ;;
  30. esac
  31. ;;
  32. esac