11-ath10k-caldata 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. d7800 |\
  42. r7500v2 |\
  43. r7800)
  44. ath10kcal_extract "art" 4096 12064
  45. ;;
  46. ea8500)
  47. hw_mac_addr=$(mtd_get_mac_ascii devinfo hw_mac_addr)
  48. ath10kcal_extract "art" 4096 12064
  49. ;;
  50. nbg6817)
  51. ath10kcal_extract "0:ART" 4096 12064
  52. ;;
  53. vr2600v)
  54. ath10kcal_extract "ART" 4096 12064
  55. ;;
  56. esac
  57. ;;
  58. "ath10k/cal-pci-0001:01:00.0.bin")
  59. case $board in
  60. c2600)
  61. ath10kcal_extract "radio" 20480 12064
  62. # ath10kcal_patch_mac $(macaddr_add $(mtd_get_mac_binary default-mac 8) -2)
  63. ;;
  64. d7800 |\
  65. r7500v2 |\
  66. r7800)
  67. ath10kcal_extract "art" 20480 12064
  68. ;;
  69. ea8500)
  70. hw_mac_addr=$(mtd_get_mac_ascii devinfo hw_mac_addr)
  71. ath10kcal_extract "art" 20480 12064
  72. ;;
  73. nbg6817)
  74. ath10kcal_extract "0:ART" 20480 12064
  75. ;;
  76. vr2600v)
  77. ath10kcal_extract "ART" 20480 12064
  78. ;;
  79. esac
  80. ;;
  81. *)
  82. exit 1
  83. ;;
  84. esac