10-ath9k-eeprom 1.2 KB

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