11-ath10k-caldata 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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/ar71xx.sh
  31. . /lib/functions.sh
  32. . /lib/functions/system.sh
  33. board=$(ar71xx_board_name)
  34. case "$FIRMWARE" in
  35. "ath10k/cal-pci-0000:00:00.0.bin")
  36. case $board in
  37. dlan-pro-1200-ac)
  38. ath10kcal_extract "art" 20480 2116
  39. ;;
  40. dw33d)
  41. ath10kcal_extract "art" 20480 2116
  42. ath10kcal_patch_mac $(mtd_get_mac_binary art 18)
  43. ;;
  44. mc-mac1200r)
  45. ath10kcal_extract "art" 20480 2116
  46. ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth1/address) -1)
  47. ;;
  48. tl-wdr6500-v2)
  49. ath10kcal_extract "art" 20480 2116
  50. ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth1/address) -2)
  51. ;;
  52. r6100)
  53. ath10kcal_extract "caldata" 20480 2116
  54. ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth1/address) +2)
  55. ;;
  56. qihoo-c301)
  57. ath10kcal_extract "radiocfg" 20480 2116
  58. ath10kcal_patch_mac $(mtd_get_mac_ascii devdata wlan5mac)
  59. ;;
  60. esr1750 | \
  61. epg5000)
  62. ath10kcal_extract "caldata" 20480 2116
  63. ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) +1)
  64. ;;
  65. mr1750 | \
  66. mr1750v2 | \
  67. om5p-acv2)
  68. ath10kcal_extract "ART" 20480 2116
  69. ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) +16)
  70. ;;
  71. unifiac-lite | \
  72. unifiac-pro)
  73. ath10kcal_extract "EEPROM" 20480 2116
  74. ;;
  75. esac
  76. ;;
  77. "ath10k/cal-pci-0000:01:00.0.bin")
  78. case $board in
  79. archer-c5 | \
  80. archer-c7)
  81. ath10kcal_extract "art" 20480 2116
  82. ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth1/address) -2)
  83. ;;
  84. nbg6616 | \
  85. nbg6716)
  86. ath10kcal_extract "RFdata" 20480 2116
  87. ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth1/address) -2)
  88. ;;
  89. rb-911g-5hpacd)
  90. ath10kcal_from_file "/sys/firmware/routerboot/ext_wlan_data" 20480 2116
  91. ;;
  92. om5p-ac)
  93. ath10kcal_extract "ART" 20480 2116
  94. ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) +16)
  95. ;;
  96. esac
  97. ;;
  98. *)
  99. exit 1
  100. ;;
  101. esac