btcoex.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. * Copyright (c) 2009 Atheros Communications Inc.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for any
  5. * purpose with or without fee is hereby granted, provided that the above
  6. * copyright notice and this permission notice appear in all copies.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  11. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  14. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #ifndef BTCOEX_H
  17. #define BTCOEX_H
  18. #define ATH_WLANACTIVE_GPIO 5
  19. #define ATH_BTACTIVE_GPIO 6
  20. #define ATH_BTPRIORITY_GPIO 7
  21. #define ATH_BTCOEX_DEF_BT_PERIOD 45
  22. #define ATH_BTCOEX_DEF_DUTY_CYCLE 55
  23. #define ATH_BTCOEX_BMISS_THRESH 50
  24. #define ATH_BT_PRIORITY_TIME_THRESHOLD 1000 /* ms */
  25. #define ATH_BT_CNT_THRESHOLD 3
  26. enum ath_btcoex_scheme {
  27. ATH_BTCOEX_CFG_NONE,
  28. ATH_BTCOEX_CFG_2WIRE,
  29. ATH_BTCOEX_CFG_3WIRE,
  30. };
  31. enum ath_stomp_type {
  32. ATH_BTCOEX_NO_STOMP,
  33. ATH_BTCOEX_STOMP_ALL,
  34. ATH_BTCOEX_STOMP_LOW,
  35. ATH_BTCOEX_STOMP_NONE
  36. };
  37. enum ath_bt_mode {
  38. ATH_BT_COEX_MODE_LEGACY, /* legacy rx_clear mode */
  39. ATH_BT_COEX_MODE_UNSLOTTED, /* untimed/unslotted mode */
  40. ATH_BT_COEX_MODE_SLOTTED, /* slotted mode */
  41. ATH_BT_COEX_MODE_DISALBED, /* coexistence disabled */
  42. };
  43. struct ath_btcoex_config {
  44. u8 bt_time_extend;
  45. bool bt_txstate_extend;
  46. bool bt_txframe_extend;
  47. enum ath_bt_mode bt_mode; /* coexistence mode */
  48. bool bt_quiet_collision;
  49. bool bt_rxclear_polarity; /* invert rx_clear as WLAN_ACTIVE*/
  50. u8 bt_priority_time;
  51. u8 bt_first_slot_time;
  52. bool bt_hold_rx_clear;
  53. };
  54. struct ath_btcoex_info {
  55. enum ath_btcoex_scheme btcoex_scheme;
  56. u8 wlanactive_gpio;
  57. u8 btactive_gpio;
  58. u8 btpriority_gpio;
  59. u8 bt_duty_cycle; /* BT duty cycle in percentage */
  60. int bt_stomp_type; /* Types of BT stomping */
  61. u32 bt_coex_mode; /* Register setting for AR_BT_COEX_MODE */
  62. u32 bt_coex_weights; /* Register setting for AR_BT_COEX_WEIGHT */
  63. u32 bt_coex_mode2; /* Register setting for AR_BT_COEX_MODE2 */
  64. u32 btcoex_no_stomp; /* in usec */
  65. u32 btcoex_period; /* in usec */
  66. u32 bt_priority_cnt;
  67. unsigned long bt_priority_time;
  68. bool hw_timer_enabled;
  69. spinlock_t btcoex_lock;
  70. struct timer_list period_timer; /* Timer for BT period */
  71. struct ath_gen_timer *no_stomp_timer; /*Timer for no BT stomping*/
  72. };
  73. bool ath_btcoex_supported(u16 subsysid);
  74. int ath9k_hw_btcoex_init(struct ath_hw *ah);
  75. void ath9k_hw_btcoex_enable(struct ath_hw *ah);
  76. void ath9k_hw_btcoex_disable(struct ath_hw *ah);
  77. void ath_btcoex_timer_resume(struct ath_softc *sc,
  78. struct ath_btcoex_info *btinfo);
  79. void ath_btcoex_timer_pause(struct ath_softc *sc,
  80. struct ath_btcoex_info *btinfo);
  81. static inline void ath_btcoex_set_weight(struct ath_btcoex_info *btcoex_info,
  82. u32 bt_weight,
  83. u32 wlan_weight)
  84. {
  85. btcoex_info->bt_coex_weights = SM(bt_weight, AR_BTCOEX_BT_WGHT) |
  86. SM(wlan_weight, AR_BTCOEX_WL_WGHT);
  87. }
  88. #endif