10-ath9k-eeprom 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #!/bin/sh
  2. ath9k_eeprom_die() {
  3. echo "ath9k eeprom: " "$*"
  4. exit 1
  5. }
  6. ath9k_eeprom_extract() {
  7. local part=$1
  8. local offset=$2
  9. local count=$3
  10. local mtd
  11. mtd=$(find_mtd_chardev $part)
  12. [ -n "$mtd" ] || \
  13. ath9k_eeprom_die "no mtd device found for partition $part"
  14. dd if=$mtd of=/lib/firmware/$FIRMWARE bs=1 skip=$offset count=$count 2>/dev/null || \
  15. ath9k_eeprom_die "failed to extract from $mtd"
  16. }
  17. ath9k_patch_firmware_mac() {
  18. local mac=$1
  19. [ -z "$mac" ] && return
  20. macaddr_2bin $mac | dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 seek=2 count=6
  21. }
  22. [ -e /lib/firmware/$FIRMWARE ] && exit 0
  23. . /lib/ar71xx.sh
  24. . /lib/functions.sh
  25. . /lib/functions/system.sh
  26. board=$(ar71xx_board_name)
  27. case "$FIRMWARE" in
  28. "soc_wmac.eeprom")
  29. case $board in
  30. r6100 | \
  31. wndr3700v4 | \
  32. wndr4300)
  33. ath9k_eeprom_extract "caldata" 4096 2048
  34. ath9k_patch_firmware_mac $(mtd_get_mac_binary caldata 0)
  35. ;;
  36. *)
  37. ath9k_eeprom_die "board $board is not supported yet"
  38. ;;
  39. esac
  40. ;;
  41. "pci_wmac0.eeprom")
  42. case $board in
  43. wndr3700v4 | \
  44. wndr4300)
  45. ath9k_eeprom_extract "caldata" 20480 2048
  46. ath9k_patch_firmware_mac $(mtd_get_mac_binary caldata 12)
  47. ;;
  48. *)
  49. ath9k_eeprom_die "board $board is not supported yet"
  50. ;;
  51. esac
  52. ;;
  53. esac