11-ath10k-caldata 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/bin/sh
  2. # Based on ar71xx 11-ath10k-caldata and 10-rt2x00-eeprom
  3. [ -e /lib/firmware/$FIRMWARE ] && exit 0
  4. . /lib/functions.sh
  5. . /lib/functions/system.sh
  6. . /lib/upgrade/nand.sh
  7. ath10k_caldata_die() {
  8. echo "ath10k caldata: " "$*"
  9. exit 1
  10. }
  11. ath10k_caldata_extract_ubi() {
  12. local part=$1
  13. local offset=$2
  14. local count=$3
  15. local ubidev=$(nand_find_ubi $CI_UBIPART)
  16. local ubi
  17. ubi=$(nand_find_volume $ubidev $part)
  18. [ -n "$ubi" ] || \
  19. ath10k_caldata_die "no UBI volume found for $part"
  20. dd if=/dev/$ubi of=/lib/firmware/$FIRMWARE bs=1 skip=$offset count=$count 2>/dev/null || \
  21. ath10k_caldata_die "failed to extract from $ubi"
  22. }
  23. ath10k_caldata_set_macaddr() {
  24. local macaddr=$1
  25. macaddr_2bin $macaddr | dd of=/lib/firmware/$FIRMWARE \
  26. conv=notrunc bs=1 seek=6 count=6
  27. }
  28. case "$FIRMWARE" in
  29. "ath10k/cal-pci-0000:02:00.0.bin")
  30. board=$(board_name)
  31. case $board in
  32. BTHOMEHUBV5A)
  33. ath10k_caldata_extract_ubi "caldata" 20480 2116
  34. ath10k_caldata_set_macaddr $(macaddr_add $(mtd_get_mac_binary_ubi caldata 4364) +3)
  35. ;;
  36. *)
  37. ath10k_caldata_die "board $board is not supported yet"
  38. ;;
  39. esac
  40. ;;
  41. esac