11-ath10k-caldata 1.1 KB

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