10-ath9k-eeprom 1.2 KB

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