11-ath10k-caldata 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #!/bin/sh
  2. ath10kcal_die() {
  3. echo "ath10cal: " "$*"
  4. exit 1
  5. }
  6. ath10kcal_from_file() {
  7. local source=$1
  8. local offset=$2
  9. local count=$3
  10. dd if=$source of=/lib/firmware/$FIRMWARE bs=1 skip=$offset count=$count 2>/dev/null || \
  11. ath10kcal_die "failed to extract calibration data from $source"
  12. }
  13. ath10kcal_extract() {
  14. local part=$1
  15. local offset=$2
  16. local count=$3
  17. local mtd
  18. mtd=$(find_mtd_chardev $part)
  19. [ -n "$mtd" ] || \
  20. ath10kcal_die "no mtd device found for partition $part"
  21. dd if=$mtd of=/lib/firmware/$FIRMWARE bs=1 skip=$offset count=$count 2>/dev/null || \
  22. ath10kcal_die "failed to extract calibration data from $mtd"
  23. }
  24. ath10kcal_patch_mac() {
  25. local mac=$1
  26. [ -z "$mac" ] && return
  27. macaddr_2bin $mac | dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 seek=6 count=6
  28. }
  29. [ -e /lib/firmware/$FIRMWARE ] && exit 0
  30. . /lib/ipq806x.sh
  31. . /lib/functions.sh
  32. . /lib/functions/system.sh
  33. board=$(ipq806x_board_name)
  34. case "$FIRMWARE" in
  35. "ath10k/cal-pci-0000:01:00.0.bin")
  36. case $board in
  37. c2600)
  38. ath10kcal_extract "radio" 4096 12064
  39. # ath10kcal_patch_mac $(macaddr_add $(mtd_get_mac_binary default-mac 8) -1)
  40. ;;
  41. ea8500)
  42. hw_mac_addr=$(mtd_get_mac_ascii devinfo hw_mac_addr)
  43. ath10kcal_extract "art" 4096 12064
  44. ;;
  45. r7500v2 |\
  46. r7800)
  47. ath10kcal_extract "art" 4096 12064
  48. ;;
  49. esac
  50. ;;
  51. "ath10k/cal-pci-0001:01:00.0.bin")
  52. case $board in
  53. c2600)
  54. ath10kcal_extract "radio" 20480 12064
  55. # ath10kcal_patch_mac $(macaddr_add $(mtd_get_mac_binary default-mac 8) -2)
  56. ;;
  57. ea8500)
  58. hw_mac_addr=$(mtd_get_mac_ascii devinfo hw_mac_addr)
  59. ath10kcal_extract "art" 20480 12064
  60. ;;
  61. r7500v2 |\
  62. r7800)
  63. ath10kcal_extract "art" 20480 12064
  64. ;;
  65. esac
  66. ;;
  67. *)
  68. exit 1
  69. ;;
  70. esac