rt2800lib.h 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. /*
  2. Copyright (C) 2010 Willow Garage <http://www.willowgarage.com>
  3. Copyright (C) 2010 Ivo van Doorn <IvDoorn@gmail.com>
  4. Copyright (C) 2009 Bartlomiej Zolnierkiewicz
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, see <http://www.gnu.org/licenses/>.
  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 (*read_eeprom)(struct rt2x00_dev *rt2x00dev);
  37. bool (*hwcrypt_disabled)(struct rt2x00_dev *rt2x00dev);
  38. int (*drv_write_firmware)(struct rt2x00_dev *rt2x00dev,
  39. const u8 *data, const size_t len);
  40. int (*drv_init_registers)(struct rt2x00_dev *rt2x00dev);
  41. __le32 *(*drv_get_txwi)(struct queue_entry *entry);
  42. };
  43. static inline void rt2800_register_read(struct rt2x00_dev *rt2x00dev,
  44. const unsigned int offset,
  45. u32 *value)
  46. {
  47. const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
  48. rt2800ops->register_read(rt2x00dev, offset, value);
  49. }
  50. static inline void rt2800_register_read_lock(struct rt2x00_dev *rt2x00dev,
  51. const unsigned int offset,
  52. u32 *value)
  53. {
  54. const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
  55. rt2800ops->register_read_lock(rt2x00dev, offset, value);
  56. }
  57. static inline void rt2800_register_write(struct rt2x00_dev *rt2x00dev,
  58. const unsigned int offset,
  59. u32 value)
  60. {
  61. const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
  62. rt2800ops->register_write(rt2x00dev, offset, value);
  63. }
  64. static inline void rt2800_register_write_lock(struct rt2x00_dev *rt2x00dev,
  65. const unsigned int offset,
  66. u32 value)
  67. {
  68. const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
  69. rt2800ops->register_write_lock(rt2x00dev, offset, value);
  70. }
  71. static inline void rt2800_register_multiread(struct rt2x00_dev *rt2x00dev,
  72. const unsigned int offset,
  73. void *value, const u32 length)
  74. {
  75. const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
  76. rt2800ops->register_multiread(rt2x00dev, offset, value, length);
  77. }
  78. static inline void rt2800_register_multiwrite(struct rt2x00_dev *rt2x00dev,
  79. const unsigned int offset,
  80. const void *value,
  81. const u32 length)
  82. {
  83. const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
  84. rt2800ops->register_multiwrite(rt2x00dev, offset, value, length);
  85. }
  86. static inline int rt2800_regbusy_read(struct rt2x00_dev *rt2x00dev,
  87. const unsigned int offset,
  88. const struct rt2x00_field32 field,
  89. u32 *reg)
  90. {
  91. const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
  92. return rt2800ops->regbusy_read(rt2x00dev, offset, field, reg);
  93. }
  94. static inline int rt2800_read_eeprom(struct rt2x00_dev *rt2x00dev)
  95. {
  96. const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
  97. return rt2800ops->read_eeprom(rt2x00dev);
  98. }
  99. static inline bool rt2800_hwcrypt_disabled(struct rt2x00_dev *rt2x00dev)
  100. {
  101. const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
  102. return rt2800ops->hwcrypt_disabled(rt2x00dev);
  103. }
  104. static inline int rt2800_drv_write_firmware(struct rt2x00_dev *rt2x00dev,
  105. const u8 *data, const size_t len)
  106. {
  107. const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
  108. return rt2800ops->drv_write_firmware(rt2x00dev, data, len);
  109. }
  110. static inline int rt2800_drv_init_registers(struct rt2x00_dev *rt2x00dev)
  111. {
  112. const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
  113. return rt2800ops->drv_init_registers(rt2x00dev);
  114. }
  115. static inline __le32 *rt2800_drv_get_txwi(struct queue_entry *entry)
  116. {
  117. const struct rt2800_ops *rt2800ops = entry->queue->rt2x00dev->ops->drv;
  118. return rt2800ops->drv_get_txwi(entry);
  119. }
  120. void rt2800_mcu_request(struct rt2x00_dev *rt2x00dev,
  121. const u8 command, const u8 token,
  122. const u8 arg0, const u8 arg1);
  123. int rt2800_wait_csr_ready(struct rt2x00_dev *rt2x00dev);
  124. int rt2800_wait_wpdma_ready(struct rt2x00_dev *rt2x00dev);
  125. int rt2800_check_firmware(struct rt2x00_dev *rt2x00dev,
  126. const u8 *data, const size_t len);
  127. int rt2800_load_firmware(struct rt2x00_dev *rt2x00dev,
  128. const u8 *data, const size_t len);
  129. void rt2800_write_tx_data(struct queue_entry *entry,
  130. struct txentry_desc *txdesc);
  131. void rt2800_process_rxwi(struct queue_entry *entry, struct rxdone_entry_desc *txdesc);
  132. void rt2800_txdone_entry(struct queue_entry *entry, u32 status, __le32* txwi);
  133. void rt2800_write_beacon(struct queue_entry *entry, struct txentry_desc *txdesc);
  134. void rt2800_clear_beacon(struct queue_entry *entry);
  135. extern const struct rt2x00debug rt2800_rt2x00debug;
  136. int rt2800_rfkill_poll(struct rt2x00_dev *rt2x00dev);
  137. int rt2800_config_shared_key(struct rt2x00_dev *rt2x00dev,
  138. struct rt2x00lib_crypto *crypto,
  139. struct ieee80211_key_conf *key);
  140. int rt2800_config_pairwise_key(struct rt2x00_dev *rt2x00dev,
  141. struct rt2x00lib_crypto *crypto,
  142. struct ieee80211_key_conf *key);
  143. int rt2800_sta_add(struct rt2x00_dev *rt2x00dev, struct ieee80211_vif *vif,
  144. struct ieee80211_sta *sta);
  145. int rt2800_sta_remove(struct rt2x00_dev *rt2x00dev, int wcid);
  146. void rt2800_config_filter(struct rt2x00_dev *rt2x00dev,
  147. const unsigned int filter_flags);
  148. void rt2800_config_intf(struct rt2x00_dev *rt2x00dev, struct rt2x00_intf *intf,
  149. struct rt2x00intf_conf *conf, const unsigned int flags);
  150. void rt2800_config_erp(struct rt2x00_dev *rt2x00dev, struct rt2x00lib_erp *erp,
  151. u32 changed);
  152. void rt2800_config_ant(struct rt2x00_dev *rt2x00dev, struct antenna_setup *ant);
  153. void rt2800_config(struct rt2x00_dev *rt2x00dev,
  154. struct rt2x00lib_conf *libconf,
  155. const unsigned int flags);
  156. void rt2800_link_stats(struct rt2x00_dev *rt2x00dev, struct link_qual *qual);
  157. void rt2800_reset_tuner(struct rt2x00_dev *rt2x00dev, struct link_qual *qual);
  158. void rt2800_link_tuner(struct rt2x00_dev *rt2x00dev, struct link_qual *qual,
  159. const u32 count);
  160. void rt2800_gain_calibration(struct rt2x00_dev *rt2x00dev);
  161. void rt2800_vco_calibration(struct rt2x00_dev *rt2x00dev);
  162. int rt2800_enable_radio(struct rt2x00_dev *rt2x00dev);
  163. void rt2800_disable_radio(struct rt2x00_dev *rt2x00dev);
  164. int rt2800_efuse_detect(struct rt2x00_dev *rt2x00dev);
  165. int rt2800_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev);
  166. int rt2800_probe_hw(struct rt2x00_dev *rt2x00dev);
  167. void rt2800_get_key_seq(struct ieee80211_hw *hw,
  168. struct ieee80211_key_conf *key,
  169. struct ieee80211_key_seq *seq);
  170. int rt2800_set_rts_threshold(struct ieee80211_hw *hw, u32 value);
  171. int rt2800_conf_tx(struct ieee80211_hw *hw,
  172. struct ieee80211_vif *vif, u16 queue_idx,
  173. const struct ieee80211_tx_queue_params *params);
  174. u64 rt2800_get_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif);
  175. int rt2800_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
  176. struct ieee80211_ampdu_params *params);
  177. int rt2800_get_survey(struct ieee80211_hw *hw, int idx,
  178. struct survey_info *survey);
  179. void rt2800_disable_wpdma(struct rt2x00_dev *rt2x00dev);
  180. void rt2800_get_txwi_rxwi_size(struct rt2x00_dev *rt2x00dev,
  181. unsigned short *txwi_size,
  182. unsigned short *rxwi_size);
  183. #endif /* RT2800LIB_H */