950-2-4-ath10k-Clean-up-growing-hw-checks-during-safe-and-full-reset.patch 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. From 0fc7e270523bf3757687e930c02bb46e3dcedde9 Mon Sep 17 00:00:00 2001
  2. From: Vasanthakumar Thiagarajan <vthiagar@qti.qualcomm.com>
  3. Date: Mon, 23 May 2016 23:12:43 +0300
  4. Subject: ath10k: clean up growing hw checks during safe and full reset
  5. Store pci chip secific reset funtions in struct ath10k_pci
  6. as callbacks during early ath10k_pci_probe() and use the
  7. callback to perform chip specific resets. This patch essentially
  8. adds two callback in ath10k_pci, one for doing soft reset and
  9. the other for hard reset. By using callbacks we can get rid of
  10. those hw revision checks in ath10k_pci_safe_chip_reset() and
  11. ath10k_pci_chip_reset(). As such this patch does not fix
  12. any issue.
  13. Signed-off-by: Vasanthakumar Thiagarajan <vthiagar@qti.qualcomm.com>
  14. Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
  15. ---
  16. drivers/net/wireless/ath/ath10k/pci.c | 44 ++++++++++++++++++++++-------------
  17. drivers/net/wireless/ath/ath10k/pci.h | 6 +++++
  18. 2 files changed, 34 insertions(+), 16 deletions(-)
  19. diff --git a/drivers/net/wireless/ath/ath10k/pci.c b/drivers/net/wireless/ath/ath10k/pci.c
  20. index 8133d7b..81d6bad 100644
  21. --- a/drivers/net/wireless/ath/ath10k/pci.c
  22. +++ b/drivers/net/wireless/ath/ath10k/pci.c
  23. @@ -2293,16 +2293,20 @@ static int ath10k_pci_warm_reset(struct ath10k *ar)
  24. return 0;
  25. }
  26. +static int ath10k_pci_qca99x0_soft_chip_reset(struct ath10k *ar)
  27. +{
  28. + ath10k_pci_irq_disable(ar);
  29. + return ath10k_pci_qca99x0_chip_reset(ar);
  30. +}
  31. +
  32. static int ath10k_pci_safe_chip_reset(struct ath10k *ar)
  33. {
  34. - if (QCA_REV_988X(ar) || QCA_REV_6174(ar)) {
  35. - return ath10k_pci_warm_reset(ar);
  36. - } else if (QCA_REV_99X0(ar)) {
  37. - ath10k_pci_irq_disable(ar);
  38. - return ath10k_pci_qca99x0_chip_reset(ar);
  39. - } else {
  40. + struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
  41. +
  42. + if (!ar_pci->pci_soft_reset)
  43. return -ENOTSUPP;
  44. - }
  45. +
  46. + return ar_pci->pci_soft_reset(ar);
  47. }
  48. static int ath10k_pci_qca988x_chip_reset(struct ath10k *ar)
  49. @@ -2437,16 +2441,12 @@ static int ath10k_pci_qca99x0_chip_reset(struct ath10k *ar)
  50. static int ath10k_pci_chip_reset(struct ath10k *ar)
  51. {
  52. - if (QCA_REV_988X(ar))
  53. - return ath10k_pci_qca988x_chip_reset(ar);
  54. - else if (QCA_REV_6174(ar))
  55. - return ath10k_pci_qca6174_chip_reset(ar);
  56. - else if (QCA_REV_9377(ar))
  57. - return ath10k_pci_qca6174_chip_reset(ar);
  58. - else if (QCA_REV_99X0(ar))
  59. - return ath10k_pci_qca99x0_chip_reset(ar);
  60. - else
  61. + struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
  62. +
  63. + if (WARN_ON(!ar_pci->pci_hard_reset))
  64. return -ENOTSUPP;
  65. +
  66. + return ar_pci->pci_hard_reset(ar);
  67. }
  68. static int ath10k_pci_hif_power_up(struct ath10k *ar)
  69. @@ -2976,24 +2976,34 @@ static int ath10k_pci_probe(struct pci_dev *pdev,
  70. enum ath10k_hw_rev hw_rev;
  71. u32 chip_id;
  72. bool pci_ps;
  73. + int (*pci_soft_reset)(struct ath10k *ar);
  74. + int (*pci_hard_reset)(struct ath10k *ar);
  75. switch (pci_dev->device) {
  76. case QCA988X_2_0_DEVICE_ID:
  77. hw_rev = ATH10K_HW_QCA988X;
  78. pci_ps = false;
  79. + pci_soft_reset = ath10k_pci_warm_reset;
  80. + pci_hard_reset = ath10k_pci_qca988x_chip_reset;
  81. break;
  82. case QCA6164_2_1_DEVICE_ID:
  83. case QCA6174_2_1_DEVICE_ID:
  84. hw_rev = ATH10K_HW_QCA6174;
  85. pci_ps = true;
  86. + pci_soft_reset = ath10k_pci_warm_reset;
  87. + pci_hard_reset = ath10k_pci_qca6174_chip_reset;
  88. break;
  89. case QCA99X0_2_0_DEVICE_ID:
  90. hw_rev = ATH10K_HW_QCA99X0;
  91. pci_ps = false;
  92. + pci_soft_reset = ath10k_pci_qca99x0_soft_chip_reset;
  93. + pci_hard_reset = ath10k_pci_qca99x0_chip_reset;
  94. break;
  95. case QCA9377_1_0_DEVICE_ID:
  96. hw_rev = ATH10K_HW_QCA9377;
  97. pci_ps = true;
  98. + pci_soft_reset = NULL;
  99. + pci_hard_reset = ath10k_pci_qca6174_chip_reset;
  100. break;
  101. default:
  102. WARN_ON(1);
  103. @@ -3018,6 +3028,8 @@ static int ath10k_pci_probe(struct pci_dev *pdev,
  104. ar->dev_id = pci_dev->device;
  105. ar_pci->pci_ps = pci_ps;
  106. ar_pci->bus_ops = &ath10k_pci_bus_ops;
  107. + ar_pci->pci_soft_reset = pci_soft_reset;
  108. + ar_pci->pci_hard_reset = pci_hard_reset;
  109. ar->id.vendor = pdev->vendor;
  110. ar->id.device = pdev->device;
  111. diff --git a/drivers/net/wireless/ath/ath10k/pci.h b/drivers/net/wireless/ath/ath10k/pci.h
  112. index 959dc32..6eca1df 100644
  113. --- a/drivers/net/wireless/ath/ath10k/pci.h
  114. +++ b/drivers/net/wireless/ath/ath10k/pci.h
  115. @@ -234,6 +234,12 @@ struct ath10k_pci {
  116. const struct ath10k_bus_ops *bus_ops;
  117. + /* Chip specific pci reset routine used to do a safe reset */
  118. + int (*pci_soft_reset)(struct ath10k *ar);
  119. +
  120. + /* Chip specific pci full reset function */
  121. + int (*pci_hard_reset)(struct ath10k *ar);
  122. +
  123. /* Keep this entry in the last, memory for struct ath10k_ahb is
  124. * allocated (ahb support enabled case) in the continuation of
  125. * this struct.
  126. --
  127. cgit v0.12