081-ath10k-calibration-variant.patch 3.5 KB

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