rt2800lib.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. /*
  2. Copyright (C) 2009 Bartlomiej Zolnierkiewicz
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the
  13. Free Software Foundation, Inc.,
  14. 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  15. */
  16. #ifndef RT2800LIB_H
  17. #define RT2800LIB_H
  18. struct rt2800_ops {
  19. void (*register_read)(struct rt2x00_dev *rt2x00dev,
  20. const unsigned int offset, u32 *value);
  21. void (*register_read_lock)(struct rt2x00_dev *rt2x00dev,
  22. const unsigned int offset, u32 *value);
  23. void (*register_write)(struct rt2x00_dev *rt2x00dev,
  24. const unsigned int offset, u32 value);
  25. void (*register_write_lock)(struct rt2x00_dev *rt2x00dev,
  26. const unsigned int offset, u32 value);
  27. void (*register_multiread)(struct rt2x00_dev *rt2x00dev,
  28. const unsigned int offset,
  29. void *value, const u32 length);
  30. void (*register_multiwrite)(struct rt2x00_dev *rt2x00dev,
  31. const unsigned int offset,
  32. const void *value, const u32 length);
  33. int (*regbusy_read)(struct rt2x00_dev *rt2x00dev,
  34. const unsigned int offset,
  35. const struct rt2x00_field32 field, u32 *reg);
  36. int (*drv_write_firmware)(struct rt2x00_dev *rt2x00dev,
  37. const u8 *data, const size_t len);
  38. int (*drv_init_registers)(struct rt2x00_dev *rt2x00dev);
  39. };
  40. static inline void rt2800_register_read(struct rt2x00_dev *rt2x00dev,
  41. const unsigned int offset,
  42. u32 *value)
  43. {
  44. const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
  45. rt2800ops->register_read(rt2x00dev, offset, value);
  46. }
  47. static inline void rt2800_register_read_lock(struct rt2x00_dev *rt2x00dev,
  48. const unsigned int offset,
  49. u32 *value)
  50. {
  51. const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
  52. rt2800ops->register_read_lock(rt2x00dev, offset, value);
  53. }
  54. static inline void rt2800_register_write(struct rt2x00_dev *rt2x00dev,
  55. const unsigned int offset,
  56. u32 value)
  57. {
  58. const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
  59. rt2800ops->register_write(rt2x00dev, offset, value);
  60. }
  61. static inline void rt2800_register_write_lock(struct rt2x00_dev *rt2x00dev,
  62. const unsigned int offset,
  63. u32 value)
  64. {
  65. const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
  66. rt2800ops->register_write_lock(rt2x00dev, offset, value);
  67. }
  68. static inline void rt2800_register_multiread(struct rt2x00_dev *rt2x00dev,
  69. const unsigned int offset,
  70. void *value, const u32 length)
  71. {
  72. const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
  73. rt2800ops->register_multiread(rt2x00dev, offset, value, length);
  74. }
  75. static inline void rt2800_register_multiwrite(struct rt2x00_dev *rt2x00dev,
  76. const unsigned int offset,
  77. const void *value,
  78. const u32 length)
  79. {
  80. const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
  81. rt2800ops->register_multiwrite(rt2x00dev, offset, value, length);
  82. }
  83. static inline int rt2800_regbusy_read(struct rt2x00_dev *rt2x00dev,
  84. const unsigned int offset,
  85. const struct rt2x00_field32 field,
  86. u32 *reg)
  87. {
  88. const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
  89. return rt2800ops->regbusy_read(rt2x00dev, offset, field, reg);
  90. }
  91. static inline int rt2800_drv_write_firmware(struct rt2x00_dev *rt2x00dev,
  92. const u8 *data, const size_t len)
  93. {
  94. const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
  95. return rt2800ops->drv_write_firmware(rt2x00dev, data, len);
  96. }
  97. static inline int rt2800_drv_init_registers(struct rt2x00_dev *rt2x00dev)
  98. {
  99. const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
  100. return rt2800ops->drv_init_registers(rt2x00dev);
  101. }
  102. void rt2800_mcu_request(struct rt2x00_dev *rt2x00dev,
  103. const u8 command, const u8 token,
  104. const u8 arg0, const u8 arg1);
  105. int rt2800_check_firmware(struct rt2x00_dev *rt2x00dev,
  106. const u8 *data, const size_t len);
  107. int rt2800_load_firmware(struct rt2x00_dev *rt2x00dev,
  108. const u8 *data, const size_t len);
  109. void rt2800_write_txwi(__le32 *txwi, struct txentry_desc *txdesc);
  110. void rt2800_process_rxwi(struct queue_entry *entry, struct rxdone_entry_desc *txdesc);
  111. void rt2800_write_beacon(struct queue_entry *entry, struct txentry_desc *txdesc);
  112. extern const struct rt2x00debug rt2800_rt2x00debug;
  113. int rt2800_rfkill_poll(struct rt2x00_dev *rt2x00dev);
  114. int rt2800_config_shared_key(struct rt2x00_dev *rt2x00dev,
  115. struct rt2x00lib_crypto *crypto,
  116. struct ieee80211_key_conf *key);
  117. int rt2800_config_pairwise_key(struct rt2x00_dev *rt2x00dev,
  118. struct rt2x00lib_crypto *crypto,
  119. struct ieee80211_key_conf *key);
  120. void rt2800_config_filter(struct rt2x00_dev *rt2x00dev,
  121. const unsigned int filter_flags);
  122. void rt2800_config_intf(struct rt2x00_dev *rt2x00dev, struct rt2x00_intf *intf,
  123. struct rt2x00intf_conf *conf, const unsigned int flags);
  124. void rt2800_config_erp(struct rt2x00_dev *rt2x00dev, struct rt2x00lib_erp *erp);
  125. void rt2800_config_ant(struct rt2x00_dev *rt2x00dev, struct antenna_setup *ant);
  126. void rt2800_config(struct rt2x00_dev *rt2x00dev,
  127. struct rt2x00lib_conf *libconf,
  128. const unsigned int flags);
  129. void rt2800_link_stats(struct rt2x00_dev *rt2x00dev, struct link_qual *qual);
  130. void rt2800_reset_tuner(struct rt2x00_dev *rt2x00dev, struct link_qual *qual);
  131. void rt2800_link_tuner(struct rt2x00_dev *rt2x00dev, struct link_qual *qual,
  132. const u32 count);
  133. int rt2800_init_registers(struct rt2x00_dev *rt2x00dev);
  134. int rt2800_init_bbp(struct rt2x00_dev *rt2x00dev);
  135. int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev);
  136. int rt2800_wait_wpdma_ready(struct rt2x00_dev *rt2x00dev);
  137. int rt2800_efuse_detect(struct rt2x00_dev *rt2x00dev);
  138. void rt2800_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev);
  139. int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev);
  140. int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev);
  141. int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev);
  142. void rt2800_get_tkip_seq(struct ieee80211_hw *hw, u8 hw_key_idx, u32 *iv32,
  143. u16 *iv16);
  144. int rt2800_set_rts_threshold(struct ieee80211_hw *hw, u32 value);
  145. int rt2800_conf_tx(struct ieee80211_hw *hw, u16 queue_idx,
  146. const struct ieee80211_tx_queue_params *params);
  147. u64 rt2800_get_tsf(struct ieee80211_hw *hw);
  148. int rt2800_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
  149. enum ieee80211_ampdu_mlme_action action,
  150. struct ieee80211_sta *sta, u16 tid, u16 *ssn);
  151. #endif /* RT2800LIB_H */