081-ath10k-calibration-variant.patch 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. From: Sven Eckelmann <[email protected]>
  2. Date: Fri, 10 Mar 2017 09:06:15 +0100
  3. Subject: ath10k: search DT for qcom,ath10k-calibration-variant
  4. Board Data File (BDF) is loaded upon driver boot-up procedure. The right
  5. board data file is identified on QCA4019 using bus, bmi-chip-id and
  6. bmi-board-id.
  7. The problem, however, can occur when the (default) board data file cannot
  8. fulfill the vendor requirements and it is necessary to use a different
  9. board data file.
  10. This problem was solved for SMBIOS by adding a special SMBIOS type 0xF8.
  11. Something similar has to be provided for systems without SMBIOS but with
  12. device trees. No solution was specified by QCA and therefore a new one has
  13. to be found for ath10k.
  14. The device tree requires addition strings to define the variant name
  15. wifi@a000000 {
  16. status = "okay";
  17. qcom,ath10k-calibration-variant = "RT-AC58U";
  18. };
  19. wifi@a800000 {
  20. status = "okay";
  21. qcom,ath10k-calibration-variant = "RT-AC58U";
  22. };
  23. This would create the boarddata identifiers for the board-2.bin search
  24. * bus=ahb,bmi-chip-id=0,bmi-board-id=16,variant=RT-AC58U
  25. * bus=ahb,bmi-chip-id=0,bmi-board-id=17,variant=RT-AC58U
  26. Signed-off-by: Sven Eckelmann <[email protected]>
  27. Origin: other, https://patchwork.kernel.org/patch/9615185/
  28. ---
  29. --- a/drivers/net/wireless/ath/ath10k/core.c
  30. +++ b/drivers/net/wireless/ath/ath10k/core.c
  31. @@ -860,6 +860,25 @@ static int ath10k_core_check_smbios(stru
  32. return 0;
  33. }
  34. +static int ath10k_core_check_dt(struct ath10k *ar)
  35. +{
  36. + struct device_node *node;
  37. + const char *variant = NULL;
  38. +
  39. + node = ar->dev->of_node;
  40. + if (!node)
  41. + return -ENOENT;
  42. +
  43. + of_property_read_string(node, "qcom,ath10k-calibration-variant",
  44. + &variant);
  45. + if (!variant)
  46. + return -ENODATA;
  47. +
  48. + strscpy(ar->id.bdf_ext, variant, sizeof(ar->id.bdf_ext));
  49. +
  50. + return 0;
  51. +}
  52. +
  53. static int ath10k_download_and_run_otp(struct ath10k *ar)
  54. {
  55. u32 result, address = ar->hw_params.patch_load_addr;
  56. @@ -1231,19 +1250,19 @@ static int ath10k_core_create_board_name
  57. /* strlen(',variant=') + strlen(ar->id.bdf_ext) */
  58. char variant[9 + ATH10K_SMBIOS_BDF_EXT_STR_LENGTH] = { 0 };
  59. + if (ar->id.bdf_ext[0] != '\0')
  60. + scnprintf(variant, sizeof(variant), ",variant=%s",
  61. + ar->id.bdf_ext);
  62. +
  63. if (ar->id.bmi_ids_valid) {
  64. scnprintf(name, name_len,
  65. - "bus=%s,bmi-chip-id=%d,bmi-board-id=%d",
  66. + "bus=%s,bmi-chip-id=%d,bmi-board-id=%d%s",
  67. ath10k_bus_str(ar->hif.bus),
  68. ar->id.bmi_chip_id,
  69. - ar->id.bmi_board_id);
  70. + ar->id.bmi_board_id, variant);
  71. goto out;
  72. }
  73. - if (ar->id.bdf_ext[0] != '\0')
  74. - scnprintf(variant, sizeof(variant), ",variant=%s",
  75. - ar->id.bdf_ext);
  76. -
  77. scnprintf(name, name_len,
  78. "bus=%s,vendor=%04x,device=%04x,subsystem-vendor=%04x,subsystem-device=%04x%s",
  79. ath10k_bus_str(ar->hif.bus),
  80. @@ -2343,7 +2362,11 @@ static int ath10k_core_probe_fw(struct a
  81. ret = ath10k_core_check_smbios(ar);
  82. if (ret)
  83. - ath10k_dbg(ar, ATH10K_DBG_BOOT, "bdf variant name not set.\n");
  84. + ath10k_dbg(ar, ATH10K_DBG_BOOT, "SMBIOS bdf variant name not set.\n");
  85. +
  86. + ret = ath10k_core_check_dt(ar);
  87. + if (ret)
  88. + ath10k_dbg(ar, ATH10K_DBG_BOOT, "DT bdf variant name not set.\n");
  89. ret = ath10k_core_fetch_board_file(ar);
  90. if (ret) {