081-ath10k-calibration-variant.patch 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. Origin: upstream, https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d06f26c5c8a41f246a9c40862a77a55725cedbd3
  30. ---
  31. ath10k-4.13/core.c | 40 ++++++++++++++++++++++++++++------
  32. 1 file changed, 33 insertions(+), 7 deletions(-)
  33. --- a/ath10k-4.13/core.c
  34. +++ b/ath10k-4.13/core.c
  35. @@ -891,6 +891,28 @@ static int ath10k_core_check_smbios(stru
  36. return 0;
  37. }
  38. +static int ath10k_core_check_dt(struct ath10k *ar)
  39. +{
  40. + struct device_node *node;
  41. + const char *variant = NULL;
  42. +
  43. + node = ar->dev->of_node;
  44. + if (!node)
  45. + return -ENOENT;
  46. +
  47. + of_property_read_string(node, "qcom,ath10k-calibration-variant",
  48. + &variant);
  49. + if (!variant)
  50. + return -ENODATA;
  51. +
  52. + if (strscpy(ar->id.bdf_ext, variant, sizeof(ar->id.bdf_ext)) < 0)
  53. + ath10k_dbg(ar, ATH10K_DBG_BOOT,
  54. + "bdf variant string is longer than the buffer can accommodate (variant: %s)\n",
  55. + variant);
  56. +
  57. + return 0;
  58. +}
  59. +
  60. static int ath10k_download_and_run_otp(struct ath10k *ar)
  61. {
  62. u32 result, address = ar->hw_params.patch_load_addr;
  63. @@ -1530,19 +1552,19 @@ static int ath10k_core_create_board_name
  64. /* strlen(',variant=') + strlen(ar->id.bdf_ext) */
  65. char variant[9 + ATH10K_SMBIOS_BDF_EXT_STR_LENGTH] = { 0 };
  66. + if (ar->id.bdf_ext[0] != '\0')
  67. + scnprintf(variant, sizeof(variant), ",variant=%s",
  68. + ar->id.bdf_ext);
  69. +
  70. if (ar->id.bmi_ids_valid) {
  71. scnprintf(name, name_len,
  72. - "bus=%s,bmi-chip-id=%d,bmi-board-id=%d",
  73. + "bus=%s,bmi-chip-id=%d,bmi-board-id=%d%s",
  74. ath10k_bus_str(ar->hif.bus),
  75. ar->id.bmi_chip_id,
  76. - ar->id.bmi_board_id);
  77. + ar->id.bmi_board_id, variant);
  78. goto out;
  79. }
  80. - if (ar->id.bdf_ext[0] != '\0')
  81. - scnprintf(variant, sizeof(variant), ",variant=%s",
  82. - ar->id.bdf_ext);
  83. -
  84. scnprintf(name, name_len,
  85. "bus=%s,vendor=%04x,device=%04x,subsystem-vendor=%04x,subsystem-device=%04x%s",
  86. ath10k_bus_str(ar->hif.bus),
  87. @@ -2975,7 +2997,11 @@ static int ath10k_core_probe_fw(struct a
  88. ret = ath10k_core_check_smbios(ar);
  89. if (ret)
  90. - ath10k_dbg(ar, ATH10K_DBG_BOOT, "bdf variant name not set.\n");
  91. + ath10k_dbg(ar, ATH10K_DBG_BOOT, "SMBIOS bdf variant name not set.\n");
  92. +
  93. + ret = ath10k_core_check_dt(ar);
  94. + if (ret)
  95. + ath10k_dbg(ar, ATH10K_DBG_BOOT, "DT bdf variant name not set.\n");
  96. ret = ath10k_core_fetch_board_file(ar);
  97. if (ret) {