0032-ar71xx-backport-ath10k-calibration-data-load-changes.patch 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. From: Matthias Schiffer <mschiffer@universe-factory.net>
  2. Date: Wed, 18 Nov 2015 02:01:55 +0100
  3. Subject: ar71xx: backport ath10k calibration data load changes
  4. The mac80211 update makes is necessary to backport this change as well for
  5. ath10k to load.
  6. diff --git a/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
  7. index dd3f546..7111630 100644
  8. --- a/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
  9. +++ b/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
  10. @@ -8,50 +8,83 @@ ath10kcal_die() {
  11. ath10kcal_from_file() {
  12. local source=$1
  13. local offset=$2
  14. - local target=$3
  15. + local count=$3
  16. - dd if=$source of=$target bs=1 skip=$offset count=2116 2>/dev/null || \
  17. + dd if=$source of=/lib/firmware/$FIRMWARE bs=1 skip=$offset count=$count 2>/dev/null || \
  18. ath10kcal_die "failed to extract calibration data from $source"
  19. }
  20. +ath10kcal_extract() {
  21. + local part=$1
  22. + local offset=$2
  23. + local count=$3
  24. + local mtd
  25. +
  26. + mtd=$(find_mtd_chardev $part)
  27. + [ -n "$mtd" ] || \
  28. + ath10kcal_die "no mtd device found for partition $part"
  29. +
  30. + dd if=$mtd of=/lib/firmware/$FIRMWARE bs=1 skip=$offset count=$count 2>/dev/null || \
  31. + ath10kcal_die "failed to extract calibration data from $mtd"
  32. +}
  33. +
  34. +ath10kcal_patch_mac() {
  35. + local mac=$1
  36. +
  37. + [ -z "$mac" ] && return
  38. +
  39. + macaddr_2bin $mac | dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 seek=6 count=6
  40. +}
  41. +
  42. [ -e /lib/firmware/$FIRMWARE ] && exit 0
  43. . /lib/ar71xx.sh
  44. . /lib/functions.sh
  45. . /lib/functions/system.sh
  46. -ath10kcal_mac=""
  47. -ath10kcal_tmp="/tmp/ath10k-caldata.bin"
  48. -
  49. board=$(ar71xx_board_name)
  50. case "$FIRMWARE" in
  51. -"ath10k/cal-pci-0000:01:00.0.bin")
  52. - case $board in
  53. - rb-911g-5hpacd)
  54. - ath10kcal_from_file "/sys/firmware/routerboot/ext_wlan_data" 20480 $ath10kcal_tmp
  55. - ;;
  56. - esac
  57. - ;;
  58. -
  59. "ath10k/cal-pci-0000:00:00.0.bin")
  60. case $board in
  61. dlan-pro-1200-ac)
  62. - ath10kcal_from_file $(find_mtd_part "art") 20480 $ath10kcal_tmp
  63. + ath10kcal_extract "art" 20480 2116
  64. + ;;
  65. + mc-mac1200r)
  66. + ath10kcal_extract "art" 20480 2116
  67. + ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth1/address) -1)
  68. + ;;
  69. + r6100)
  70. + ath10kcal_extract "caldata" 20480 2116
  71. + ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth1/address) +2)
  72. + ;;
  73. + qihoo-c301)
  74. + ath10kcal_extract "radiocfg" 20480 2116
  75. + ath10kcal_patch_mac $(mtd_get_mac_ascii devdata wlan5mac)
  76. ;;
  77. esr1750 | \
  78. epg5000)
  79. - ath10kcal_from_file $(find_mtd_part "caldata") 20480 $ath10kcal_tmp
  80. + ath10kcal_extract "caldata" 20480 2116
  81. + ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) +1)
  82. + ;;
  83. + esac
  84. + ;;
  85. +"ath10k/cal-pci-0000:01:00.0.bin")
  86. + case $board in
  87. + archer-c5 | \
  88. + archer-c7)
  89. + ath10kcal_extract "art" 20480 2116
  90. + ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth1/address) -2)
  91. + ;;
  92. + nbg6716)
  93. + ath10kcal_extract "RFdata" 20480 2116
  94. + ;;
  95. + rb-911g-5hpacd)
  96. + ath10kcal_from_file "/sys/firmware/routerboot/ext_wlan_data" 20480 2116
  97. ;;
  98. esac
  99. ;;
  100. -
  101. *)
  102. exit 1
  103. ;;
  104. esac
  105. -
  106. -[ -f $ath10kcal_tmp ] && {
  107. - cp $ath10kcal_tmp /lib/firmware/$FIRMWARE
  108. - rm -f $ath10kcal_tmp
  109. -}
  110. diff --git a/target/linux/ar71xx/base-files/lib/preinit/81_load_ath10k_board_bin b/target/linux/ar71xx/base-files/lib/preinit/81_load_ath10k_board_bin
  111. deleted file mode 100644
  112. index 9a32dfc..0000000
  113. --- a/target/linux/ar71xx/base-files/lib/preinit/81_load_ath10k_board_bin
  114. +++ /dev/null
  115. @@ -1,75 +0,0 @@
  116. -#!/bin/sh
  117. -
  118. -. /lib/functions/system.sh
  119. -. /lib/ar71xx.sh
  120. -
  121. -do_load_ath10k_board_bin() {
  122. - # load board.bin
  123. - case $(ar71xx_board_name) in
  124. - nbg6716)
  125. - dd if=/dev/mtdblock2 \
  126. - bs=1 skip=20480 count=2116 \
  127. - of=/tmp/ath10k-board.bin
  128. - ;;
  129. - archer-c5 | \
  130. - archer-c7)
  131. - local mac
  132. - mac=$(macaddr_add $(cat /sys/class/net/eth1/address) -2)
  133. -
  134. - dd if=/dev/mtdblock4 \
  135. - bs=1 skip=20480 count=6 \
  136. - of=/tmp/ath10k-board.bin
  137. - macaddr_2bin $mac >> /tmp/ath10k-board.bin
  138. - dd if=/dev/mtdblock4 \
  139. - bs=1 skip=20492 count=2104 >> /tmp/ath10k-board.bin
  140. - ;;
  141. - mc-mac1200r)
  142. - local mac
  143. - mac=$(macaddr_add $(cat /sys/class/net/eth1/address) -1)
  144. -
  145. - dd if=/dev/mtdblock4 \
  146. - bs=1 skip=20480 count=6 \
  147. - of=/tmp/ath10k-board.bin
  148. - macaddr_2bin $mac >> /tmp/ath10k-board.bin
  149. - dd if=/dev/mtdblock4 \
  150. - bs=1 skip=20492 count=2104 >> /tmp/ath10k-board.bin
  151. - ;;
  152. - r6100)
  153. - local mac
  154. - mac=$(macaddr_add $(cat /sys/class/net/eth1/address) +2)
  155. -
  156. - dd if=/dev/mtdblock2 \
  157. - bs=1 skip=20480 count=6 \
  158. - of=/tmp/ath10k-board.bin
  159. - macaddr_2bin $mac >> /tmp/ath10k-board.bin
  160. - dd if=/dev/mtdblock2 \
  161. - bs=1 skip=20492 count=2104 >> /tmp/ath10k-board.bin
  162. - ;;
  163. - qihoo-c301)
  164. - local mac
  165. -
  166. - mac=$(mtd_get_mac_ascii devdata wlan5mac)
  167. -
  168. - if [ -z "$mac" ]; then
  169. - mac=$(macaddr_add $(cat /sys/class/net/eth0/address) -2)
  170. - fi
  171. -
  172. - dd if=/dev/mtdblock10 \
  173. - bs=1 skip=20480 count=6 \
  174. - of=/tmp/ath10k-board.bin
  175. - macaddr_2bin $mac >> /tmp/ath10k-board.bin
  176. - dd if=/dev/mtdblock10 \
  177. - bs=1 skip=20492 count=2104 >> /tmp/ath10k-board.bin
  178. -
  179. - ;;
  180. - esac
  181. - [ -f /tmp/ath10k-board.bin ] || {
  182. - return
  183. - }
  184. - cmp -s /tmp/ath10k-board.bin /lib/firmware/ath10k/QCA988X/hw2.0/board.bin || {
  185. - cp /tmp/ath10k-board.bin /lib/firmware/ath10k/QCA988X/hw2.0/board.bin
  186. - rm /tmp/ath10k-board.bin
  187. - }
  188. -}
  189. -
  190. -boot_hook_add preinit_main do_load_ath10k_board_bin