542-ath9k_debugfs_diag.patch 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. --- a/drivers/net/wireless/ath/ath9k/debug.c
  2. +++ b/drivers/net/wireless/ath/ath9k/debug.c
  3. @@ -1449,6 +1449,50 @@ static const struct file_operations fops
  4. #endif
  5. +static ssize_t read_file_diag(struct file *file, char __user *user_buf,
  6. + size_t count, loff_t *ppos)
  7. +{
  8. + struct ath_softc *sc = file->private_data;
  9. + struct ath_hw *ah = sc->sc_ah;
  10. + char buf[32];
  11. + unsigned int len;
  12. +
  13. + len = sprintf(buf, "0x%08lx\n", ah->diag);
  14. + return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  15. +}
  16. +
  17. +static ssize_t write_file_diag(struct file *file, const char __user *user_buf,
  18. + size_t count, loff_t *ppos)
  19. +{
  20. + struct ath_softc *sc = file->private_data;
  21. + struct ath_hw *ah = sc->sc_ah;
  22. + unsigned long diag;
  23. + char buf[32];
  24. + ssize_t len;
  25. +
  26. + len = min(count, sizeof(buf) - 1);
  27. + if (copy_from_user(buf, user_buf, len))
  28. + return -EFAULT;
  29. +
  30. + buf[len] = '\0';
  31. + if (kstrtoul(buf, 0, &diag))
  32. + return -EINVAL;
  33. +
  34. + ah->diag = diag;
  35. + ath9k_hw_update_diag(ah);
  36. +
  37. + return count;
  38. +}
  39. +
  40. +static const struct file_operations fops_diag = {
  41. + .read = read_file_diag,
  42. + .write = write_file_diag,
  43. + .open = simple_open,
  44. + .owner = THIS_MODULE,
  45. + .llseek = default_llseek,
  46. +};
  47. +
  48. +
  49. int ath9k_init_debug(struct ath_hw *ah)
  50. {
  51. struct ath_common *common = ath9k_hw_common(ah);
  52. @@ -1476,6 +1520,8 @@ int ath9k_init_debug(struct ath_hw *ah)
  53. debugfs_create_file("gpio_led", S_IWUSR,
  54. sc->debug.debugfs_phy, sc, &fops_gpio_led);
  55. #endif
  56. + debugfs_create_file("diag", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
  57. + sc, &fops_diag);
  58. debugfs_create_devm_seqfile(sc->dev, "dma", sc->debug.debugfs_phy,
  59. read_file_dma);
  60. debugfs_create_devm_seqfile(sc->dev, "interrupt", sc->debug.debugfs_phy,
  61. --- a/drivers/net/wireless/ath/ath9k/hw.h
  62. +++ b/drivers/net/wireless/ath/ath9k/hw.h
  63. @@ -519,6 +519,12 @@ enum {
  64. ATH9K_RESET_COLD,
  65. };
  66. +enum {
  67. + ATH_DIAG_DISABLE_RX,
  68. + ATH_DIAG_DISABLE_TX,
  69. + ATH_DIAG_TRIGGER_ERROR,
  70. +};
  71. +
  72. struct ath9k_hw_version {
  73. u32 magic;
  74. u16 devid;
  75. @@ -804,6 +810,8 @@ struct ath_hw {
  76. u32 rfkill_polarity;
  77. u32 ah_flags;
  78. + unsigned long diag;
  79. +
  80. bool reset_power_on;
  81. bool htc_reset_init;
  82. @@ -1066,6 +1074,7 @@ void ath9k_hw_check_nav(struct ath_hw *a
  83. bool ath9k_hw_check_alive(struct ath_hw *ah);
  84. bool ath9k_hw_setpower(struct ath_hw *ah, enum ath9k_power_mode mode);
  85. +void ath9k_hw_update_diag(struct ath_hw *ah);
  86. /* Generic hw timer primitives */
  87. struct ath_gen_timer *ath_gen_timer_alloc(struct ath_hw *ah,
  88. --- a/drivers/net/wireless/ath/ath9k/hw.c
  89. +++ b/drivers/net/wireless/ath/ath9k/hw.c
  90. @@ -1819,6 +1819,20 @@ u32 ath9k_hw_get_tsf_offset(struct times
  91. }
  92. EXPORT_SYMBOL(ath9k_hw_get_tsf_offset);
  93. +void ath9k_hw_update_diag(struct ath_hw *ah)
  94. +{
  95. + if (test_bit(ATH_DIAG_DISABLE_RX, &ah->diag))
  96. + REG_SET_BIT(ah, AR_DIAG_SW, AR_DIAG_RX_DIS);
  97. + else
  98. + REG_CLR_BIT(ah, AR_DIAG_SW, AR_DIAG_RX_DIS);
  99. +
  100. + if (test_bit(ATH_DIAG_DISABLE_TX, &ah->diag))
  101. + REG_SET_BIT(ah, AR_DIAG_SW, AR_DIAG_LOOP_BACK);
  102. + else
  103. + REG_CLR_BIT(ah, AR_DIAG_SW, AR_DIAG_LOOP_BACK);
  104. +}
  105. +EXPORT_SYMBOL(ath9k_hw_update_diag);
  106. +
  107. int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,
  108. struct ath9k_hw_cal_data *caldata, bool fastcc)
  109. {
  110. @@ -2027,6 +2041,7 @@ int ath9k_hw_reset(struct ath_hw *ah, st
  111. ar9003_hw_disable_phy_restart(ah);
  112. ath9k_hw_apply_gpio_override(ah);
  113. + ath9k_hw_update_diag(ah);
  114. if (AR_SREV_9565(ah) && common->bt_ant_diversity)
  115. REG_SET_BIT(ah, AR_BTCOEX_WL_LNADIV, AR_BTCOEX_WL_LNADIV_FORCE_ON);
  116. --- a/drivers/net/wireless/ath/ath9k/main.c
  117. +++ b/drivers/net/wireless/ath/ath9k/main.c
  118. @@ -533,6 +533,11 @@ irqreturn_t ath_isr(int irq, void *dev)
  119. if (test_bit(ATH_OP_HW_RESET, &common->op_flags))
  120. return IRQ_HANDLED;
  121. + if (test_bit(ATH_DIAG_TRIGGER_ERROR, &ah->diag)) {
  122. + status |= ATH9K_INT_FATAL;
  123. + clear_bit(ATH_DIAG_TRIGGER_ERROR, &ah->diag);
  124. + }
  125. +
  126. /*
  127. * If there are no status bits set, then this interrupt was not
  128. * for me (should have been caught above).