rt2800lib.h 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  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. /*
  19. * Hardware has 255 WCID table entries. First 32 entries are reserved for
  20. * shared keys. Since parts of the pairwise key table might be shared with
  21. * the beacon frame buffers 6 & 7 we could only use the first 222 entries.
  22. */
  23. #define WCID_START 33
  24. #define WCID_END 222
  25. #define STA_IDS_SIZE (WCID_END - WCID_START + 2)
  26. /* RT2800 driver data structure */
  27. struct rt2800_drv_data {
  28. u8 calibration_bw20;
  29. u8 calibration_bw40;
  30. char rx_calibration_bw20;
  31. char rx_calibration_bw40;
  32. char tx_calibration_bw20;
  33. char tx_calibration_bw40;
  34. u8 bbp25;
  35. u8 bbp26;
  36. u8 txmixer_gain_24g;
  37. u8 txmixer_gain_5g;
  38. u8 max_psdu;
  39. unsigned int tbtt_tick;
  40. unsigned int ampdu_factor_cnt[4];
  41. DECLARE_BITMAP(sta_ids, STA_IDS_SIZE);
  42. struct ieee80211_sta *wcid_to_sta[STA_IDS_SIZE];
  43. };
  44. struct rt2800_ops {
  45. void (*register_read)(struct rt2x00_dev *rt2x00dev,
  46. const unsigned int offset, u32 *value);
  47. void (*register_read_lock)(struct rt2x00_dev *rt2x00dev,
  48. const unsigned int offset, u32 *value);
  49. void (*register_write)(struct rt2x00_dev *rt2x00dev,
  50. const unsigned int offset, u32 value);
  51. void (*register_write_lock)(struct rt2x00_dev *rt2x00dev,
  52. const unsigned int offset, u32 value);
  53. void (*register_multiread)(struct rt2x00_dev *rt2x00dev,
  54. const unsigned int offset,
  55. void *value, const u32 length);
  56. void (*register_multiwrite)(struct rt2x00_dev *rt2x00dev,
  57. const unsigned int offset,
  58. const void *value, const u32 length);
  59. int (*regbusy_read)(struct rt2x00_dev *rt2x00dev,
  60. const unsigned int offset,
  61. const struct rt2x00_field32 field, u32 *reg);
  62. int (*read_eeprom)(struct rt2x00_dev *rt2x00dev);
  63. bool (*hwcrypt_disabled)(struct rt2x00_dev *rt2x00dev);
  64. int (*drv_write_firmware)(struct rt2x00_dev *rt2x00dev,
  65. const u8 *data, const size_t len);
  66. int (*drv_init_registers)(struct rt2x00_dev *rt2x00dev);
  67. __le32 *(*drv_get_txwi)(struct queue_entry *entry);
  68. };
  69. static inline void rt2800_register_read(struct rt2x00_dev *rt2x00dev,
  70. const unsigned int offset,
  71. u32 *value)
  72. {
  73. const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
  74. rt2800ops->register_read(rt2x00dev, offset, value);
  75. }
  76. static inline void rt2800_register_read_lock(struct rt2x00_dev *rt2x00dev,
  77. const unsigned int offset,
  78. u32 *value)
  79. {
  80. const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
  81. rt2800ops->register_read_lock(rt2x00dev, offset, value);
  82. }
  83. static inline void rt2800_register_write(struct rt2x00_dev *rt2x00dev,
  84. const unsigned int offset,
  85. u32 value)
  86. {
  87. const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
  88. rt2800ops->register_write(rt2x00dev, offset, value);
  89. }
  90. static inline void rt2800_register_write_lock(struct rt2x00_dev *rt2x00dev,
  91. const unsigned int offset,
  92. u32 value)
  93. {
  94. const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
  95. rt2800ops->register_write_lock(rt2x00dev, offset, value);
  96. }
  97. static inline void rt2800_register_multiread(struct rt2x00_dev *rt2x00dev,
  98. const unsigned int offset,
  99. void *value, const u32 length)
  100. {
  101. const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
  102. rt2800ops->register_multiread(rt2x00dev, offset, value, length);
  103. }
  104. static inline void rt2800_register_multiwrite(struct rt2x00_dev *rt2x00dev,
  105. const unsigned int offset,
  106. const void *value,
  107. const u32 length)
  108. {
  109. const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
  110. rt2800ops->register_multiwrite(rt2x00dev, offset, value, length);
  111. }
  112. static inline int rt2800_regbusy_read(struct rt2x00_dev *rt2x00dev,
  113. const unsigned int offset,
  114. const struct rt2x00_field32 field,
  115. u32 *reg)
  116. {
  117. const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
  118. return rt2800ops->regbusy_read(rt2x00dev, offset, field, reg);
  119. }
  120. static inline int rt2800_read_eeprom(struct rt2x00_dev *rt2x00dev)
  121. {
  122. const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
  123. return rt2800ops->read_eeprom(rt2x00dev);
  124. }
  125. static inline bool rt2800_hwcrypt_disabled(struct rt2x00_dev *rt2x00dev)
  126. {
  127. const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
  128. return rt2800ops->hwcrypt_disabled(rt2x00dev);
  129. }
  130. static inline int rt2800_drv_write_firmware(struct rt2x00_dev *rt2x00dev,
  131. const u8 *data, const size_t len)
  132. {
  133. const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
  134. return rt2800ops->drv_write_firmware(rt2x00dev, data, len);
  135. }
  136. static inline int rt2800_drv_init_registers(struct rt2x00_dev *rt2x00dev)
  137. {
  138. const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
  139. return rt2800ops->drv_init_registers(rt2x00dev);
  140. }
  141. static inline __le32 *rt2800_drv_get_txwi(struct queue_entry *entry)
  142. {
  143. const struct rt2800_ops *rt2800ops = entry->queue->rt2x00dev->ops->drv;
  144. return rt2800ops->drv_get_txwi(entry);
  145. }
  146. void rt2800_mcu_request(struct rt2x00_dev *rt2x00dev,
  147. const u8 command, const u8 token,
  148. const u8 arg0, const u8 arg1);
  149. int rt2800_wait_csr_ready(struct rt2x00_dev *rt2x00dev);
  150. int rt2800_wait_wpdma_ready(struct rt2x00_dev *rt2x00dev);
  151. int rt2800_check_firmware(struct rt2x00_dev *rt2x00dev,
  152. const u8 *data, const size_t len);
  153. int rt2800_load_firmware(struct rt2x00_dev *rt2x00dev,
  154. const u8 *data, const size_t len);
  155. void rt2800_write_tx_data(struct queue_entry *entry,
  156. struct txentry_desc *txdesc);
  157. void rt2800_process_rxwi(struct queue_entry *entry, struct rxdone_entry_desc *txdesc);
  158. void rt2800_txdone_entry(struct queue_entry *entry, u32 status, __le32 *txwi,
  159. bool match);
  160. void rt2800_write_beacon(struct queue_entry *entry, struct txentry_desc *txdesc);
  161. void rt2800_clear_beacon(struct queue_entry *entry);
  162. extern const struct rt2x00debug rt2800_rt2x00debug;
  163. int rt2800_rfkill_poll(struct rt2x00_dev *rt2x00dev);
  164. int rt2800_config_shared_key(struct rt2x00_dev *rt2x00dev,
  165. struct rt2x00lib_crypto *crypto,
  166. struct ieee80211_key_conf *key);
  167. int rt2800_config_pairwise_key(struct rt2x00_dev *rt2x00dev,
  168. struct rt2x00lib_crypto *crypto,
  169. struct ieee80211_key_conf *key);
  170. int rt2800_sta_add(struct rt2x00_dev *rt2x00dev, struct ieee80211_vif *vif,
  171. struct ieee80211_sta *sta);
  172. int rt2800_sta_remove(struct rt2x00_dev *rt2x00dev, struct ieee80211_sta *sta);
  173. void rt2800_config_filter(struct rt2x00_dev *rt2x00dev,
  174. const unsigned int filter_flags);
  175. void rt2800_config_intf(struct rt2x00_dev *rt2x00dev, struct rt2x00_intf *intf,
  176. struct rt2x00intf_conf *conf, const unsigned int flags);
  177. void rt2800_config_erp(struct rt2x00_dev *rt2x00dev, struct rt2x00lib_erp *erp,
  178. u32 changed);
  179. void rt2800_config_ant(struct rt2x00_dev *rt2x00dev, struct antenna_setup *ant);
  180. void rt2800_config(struct rt2x00_dev *rt2x00dev,
  181. struct rt2x00lib_conf *libconf,
  182. const unsigned int flags);
  183. void rt2800_link_stats(struct rt2x00_dev *rt2x00dev, struct link_qual *qual);
  184. void rt2800_reset_tuner(struct rt2x00_dev *rt2x00dev, struct link_qual *qual);
  185. void rt2800_link_tuner(struct rt2x00_dev *rt2x00dev, struct link_qual *qual,
  186. const u32 count);
  187. void rt2800_gain_calibration(struct rt2x00_dev *rt2x00dev);
  188. void rt2800_vco_calibration(struct rt2x00_dev *rt2x00dev);
  189. int rt2800_enable_radio(struct rt2x00_dev *rt2x00dev);
  190. void rt2800_disable_radio(struct rt2x00_dev *rt2x00dev);
  191. int rt2800_efuse_detect(struct rt2x00_dev *rt2x00dev);
  192. int rt2800_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev);
  193. int rt2800_probe_hw(struct rt2x00_dev *rt2x00dev);
  194. void rt2800_get_key_seq(struct ieee80211_hw *hw,
  195. struct ieee80211_key_conf *key,
  196. struct ieee80211_key_seq *seq);
  197. int rt2800_set_rts_threshold(struct ieee80211_hw *hw, u32 value);
  198. int rt2800_conf_tx(struct ieee80211_hw *hw,
  199. struct ieee80211_vif *vif, u16 queue_idx,
  200. const struct ieee80211_tx_queue_params *params);
  201. u64 rt2800_get_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif);
  202. int rt2800_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
  203. struct ieee80211_ampdu_params *params);
  204. int rt2800_get_survey(struct ieee80211_hw *hw, int idx,
  205. struct survey_info *survey);
  206. void rt2800_disable_wpdma(struct rt2x00_dev *rt2x00dev);
  207. void rt2800_get_txwi_rxwi_size(struct rt2x00_dev *rt2x00dev,
  208. unsigned short *txwi_size,
  209. unsigned short *rxwi_size);
  210. #endif /* RT2800LIB_H */