351-ath9k_hw-issue-external-reset-for-QCA955x.patch 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. From: Felix Fietkau <[email protected]>
  2. Date: Sat, 9 Jul 2016 15:26:44 +0200
  3. Subject: [PATCH] ath9k_hw: issue external reset for QCA955x
  4. The RTC interface on the SoC needs to be reset along with the rest of
  5. the WMAC.
  6. Signed-off-by: Felix Fietkau <[email protected]>
  7. ---
  8. --- a/drivers/net/wireless/ath/ath9k/hw.c
  9. +++ b/drivers/net/wireless/ath/ath9k/hw.c
  10. @@ -1271,39 +1271,56 @@ void ath9k_hw_get_delta_slope_vals(struc
  11. *coef_exponent = coef_exp - 16;
  12. }
  13. -/* AR9330 WAR:
  14. - * call external reset function to reset WMAC if:
  15. - * - doing a cold reset
  16. - * - we have pending frames in the TX queues.
  17. - */
  18. -static bool ath9k_hw_ar9330_reset_war(struct ath_hw *ah, int type)
  19. +static bool ath9k_hw_need_external_reset(struct ath_hw *ah, int type)
  20. {
  21. - int i, npend = 0;
  22. + int i;
  23. - for (i = 0; i < AR_NUM_QCU; i++) {
  24. - npend = ath9k_hw_numtxpending(ah, i);
  25. - if (npend)
  26. - break;
  27. + if (type == ATH9K_RESET_COLD)
  28. + return true;
  29. +
  30. + if (AR_SREV_9550(ah))
  31. + return true;
  32. +
  33. + /* AR9330 WAR:
  34. + * call external reset function to reset WMAC if:
  35. + * - doing a cold reset
  36. + * - we have pending frames in the TX queues.
  37. + */
  38. + if (AR_SREV_9330(ah)) {
  39. + for (i = 0; i < AR_NUM_QCU; i++) {
  40. + if (ath9k_hw_numtxpending(ah, i))
  41. + return true;
  42. + }
  43. }
  44. - if (ah->external_reset &&
  45. - (npend || type == ATH9K_RESET_COLD)) {
  46. - int reset_err = 0;
  47. + return false;
  48. +}
  49. - ath_dbg(ath9k_hw_common(ah), RESET,
  50. - "reset MAC via external reset\n");
  51. +static bool ath9k_hw_external_reset(struct ath_hw *ah, int type)
  52. +{
  53. + int err;
  54. - reset_err = ah->external_reset();
  55. - if (reset_err) {
  56. - ath_err(ath9k_hw_common(ah),
  57. - "External reset failed, err=%d\n",
  58. - reset_err);
  59. - return false;
  60. - }
  61. + if (!ah->external_reset || !ath9k_hw_need_external_reset(ah, type))
  62. + return true;
  63. - REG_WRITE(ah, AR_RTC_RESET, 1);
  64. + ath_dbg(ath9k_hw_common(ah), RESET,
  65. + "reset MAC via external reset\n");
  66. +
  67. + err = ah->external_reset();
  68. + if (err) {
  69. + ath_err(ath9k_hw_common(ah),
  70. + "External reset failed, err=%d\n", err);
  71. + return false;
  72. + }
  73. +
  74. + if (AR_SREV_9550(ah)) {
  75. + REG_WRITE(ah, AR_RTC_RESET, 0);
  76. + udelay(10);
  77. }
  78. + REG_WRITE(ah, AR_RTC_RESET, 1);
  79. + udelay(10);
  80. +
  81. return true;
  82. }
  83. @@ -1356,24 +1373,24 @@ static bool ath9k_hw_set_reset(struct at
  84. rst_flags |= AR_RTC_RC_MAC_COLD;
  85. }
  86. - if (AR_SREV_9330(ah)) {
  87. - if (!ath9k_hw_ar9330_reset_war(ah, type))
  88. - return false;
  89. - }
  90. -
  91. if (ath9k_hw_mci_is_enabled(ah))
  92. ar9003_mci_check_gpm_offset(ah);
  93. /* DMA HALT added to resolve ar9300 and ar9580 bus error during
  94. - * RTC_RC reg read
  95. + * RTC_RC reg read. Also needed for AR9550 external reset
  96. */
  97. - if (AR_SREV_9300(ah) || AR_SREV_9580(ah)) {
  98. + if (AR_SREV_9300(ah) || AR_SREV_9580(ah) || AR_SREV_9550(ah)) {
  99. REG_SET_BIT(ah, AR_CFG, AR_CFG_HALT_REQ);
  100. ath9k_hw_wait(ah, AR_CFG, AR_CFG_HALT_ACK, AR_CFG_HALT_ACK,
  101. 20 * AH_WAIT_TIMEOUT);
  102. - REG_CLR_BIT(ah, AR_CFG, AR_CFG_HALT_REQ);
  103. }
  104. + if (!AR_SREV_9100(ah))
  105. + ath9k_hw_external_reset(ah, type);
  106. +
  107. + if (AR_SREV_9300(ah) || AR_SREV_9580(ah))
  108. + REG_CLR_BIT(ah, AR_CFG, AR_CFG_HALT_REQ);
  109. +
  110. REG_WRITE(ah, AR_RTC_RC, rst_flags);
  111. REGWRITE_BUFFER_FLUSH(ah);