Bartlomiej Zolnierkiewicz | 7ef5cc9 | 2009-11-04 18:35:32 +0100 | [diff] [blame] | 1 | /* |
| 2 | Copyright (C) 2009 Bartlomiej Zolnierkiewicz |
| 3 | |
| 4 | This program is free software; you can redistribute it and/or modify |
| 5 | it under the terms of the GNU General Public License as published by |
| 6 | the Free Software Foundation; either version 2 of the License, or |
| 7 | (at your option) any later version. |
| 8 | |
| 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 | |
| 14 | You should have received a copy of the GNU General Public License |
| 15 | along with this program; if not, write to the |
| 16 | Free Software Foundation, Inc., |
| 17 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 18 | */ |
| 19 | |
| 20 | #ifndef RT2800LIB_H |
| 21 | #define RT2800LIB_H |
| 22 | |
| 23 | struct rt2800_ops { |
| 24 | void (*register_read)(struct rt2x00_dev *rt2x00dev, |
| 25 | const unsigned int offset, u32 *value); |
Gertjan van Wingerde | 31a4cf1 | 2009-11-14 20:20:36 +0100 | [diff] [blame] | 26 | void (*register_read_lock)(struct rt2x00_dev *rt2x00dev, |
| 27 | const unsigned int offset, u32 *value); |
Bartlomiej Zolnierkiewicz | 7ef5cc9 | 2009-11-04 18:35:32 +0100 | [diff] [blame] | 28 | void (*register_write)(struct rt2x00_dev *rt2x00dev, |
| 29 | const unsigned int offset, u32 value); |
| 30 | void (*register_write_lock)(struct rt2x00_dev *rt2x00dev, |
| 31 | const unsigned int offset, u32 value); |
| 32 | |
| 33 | void (*register_multiread)(struct rt2x00_dev *rt2x00dev, |
| 34 | const unsigned int offset, |
| 35 | void *value, const u32 length); |
| 36 | void (*register_multiwrite)(struct rt2x00_dev *rt2x00dev, |
| 37 | const unsigned int offset, |
| 38 | const void *value, const u32 length); |
| 39 | |
| 40 | int (*regbusy_read)(struct rt2x00_dev *rt2x00dev, |
| 41 | const unsigned int offset, |
| 42 | const struct rt2x00_field32 field, u32 *reg); |
Gertjan van Wingerde | e3a896b | 2010-06-03 10:52:04 +0200 | [diff] [blame] | 43 | |
Ivo van Doorn | f31c9a8 | 2010-07-11 12:30:37 +0200 | [diff] [blame] | 44 | int (*drv_write_firmware)(struct rt2x00_dev *rt2x00dev, |
| 45 | const u8 *data, const size_t len); |
Gertjan van Wingerde | e3a896b | 2010-06-03 10:52:04 +0200 | [diff] [blame] | 46 | int (*drv_init_registers)(struct rt2x00_dev *rt2x00dev); |
Bartlomiej Zolnierkiewicz | 7ef5cc9 | 2009-11-04 18:35:32 +0100 | [diff] [blame] | 47 | }; |
| 48 | |
| 49 | static inline void rt2800_register_read(struct rt2x00_dev *rt2x00dev, |
| 50 | const unsigned int offset, |
| 51 | u32 *value) |
| 52 | { |
Ivo van Doorn | e796643 | 2010-07-11 12:31:23 +0200 | [diff] [blame] | 53 | const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv; |
Bartlomiej Zolnierkiewicz | 7ef5cc9 | 2009-11-04 18:35:32 +0100 | [diff] [blame] | 54 | |
| 55 | rt2800ops->register_read(rt2x00dev, offset, value); |
| 56 | } |
| 57 | |
Gertjan van Wingerde | 31a4cf1 | 2009-11-14 20:20:36 +0100 | [diff] [blame] | 58 | static inline void rt2800_register_read_lock(struct rt2x00_dev *rt2x00dev, |
| 59 | const unsigned int offset, |
| 60 | u32 *value) |
| 61 | { |
Ivo van Doorn | e796643 | 2010-07-11 12:31:23 +0200 | [diff] [blame] | 62 | const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv; |
Gertjan van Wingerde | 31a4cf1 | 2009-11-14 20:20:36 +0100 | [diff] [blame] | 63 | |
| 64 | rt2800ops->register_read_lock(rt2x00dev, offset, value); |
| 65 | } |
| 66 | |
Bartlomiej Zolnierkiewicz | 7ef5cc9 | 2009-11-04 18:35:32 +0100 | [diff] [blame] | 67 | static inline void rt2800_register_write(struct rt2x00_dev *rt2x00dev, |
| 68 | const unsigned int offset, |
| 69 | u32 value) |
| 70 | { |
Ivo van Doorn | e796643 | 2010-07-11 12:31:23 +0200 | [diff] [blame] | 71 | const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv; |
Bartlomiej Zolnierkiewicz | 7ef5cc9 | 2009-11-04 18:35:32 +0100 | [diff] [blame] | 72 | |
| 73 | rt2800ops->register_write(rt2x00dev, offset, value); |
| 74 | } |
| 75 | |
| 76 | static inline void rt2800_register_write_lock(struct rt2x00_dev *rt2x00dev, |
| 77 | const unsigned int offset, |
| 78 | u32 value) |
| 79 | { |
Ivo van Doorn | e796643 | 2010-07-11 12:31:23 +0200 | [diff] [blame] | 80 | const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv; |
Bartlomiej Zolnierkiewicz | 7ef5cc9 | 2009-11-04 18:35:32 +0100 | [diff] [blame] | 81 | |
| 82 | rt2800ops->register_write_lock(rt2x00dev, offset, value); |
| 83 | } |
| 84 | |
| 85 | static inline void rt2800_register_multiread(struct rt2x00_dev *rt2x00dev, |
| 86 | const unsigned int offset, |
| 87 | void *value, const u32 length) |
| 88 | { |
Ivo van Doorn | e796643 | 2010-07-11 12:31:23 +0200 | [diff] [blame] | 89 | const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv; |
Bartlomiej Zolnierkiewicz | 7ef5cc9 | 2009-11-04 18:35:32 +0100 | [diff] [blame] | 90 | |
| 91 | rt2800ops->register_multiread(rt2x00dev, offset, value, length); |
| 92 | } |
| 93 | |
| 94 | static inline void rt2800_register_multiwrite(struct rt2x00_dev *rt2x00dev, |
| 95 | const unsigned int offset, |
| 96 | const void *value, |
| 97 | const u32 length) |
| 98 | { |
Ivo van Doorn | e796643 | 2010-07-11 12:31:23 +0200 | [diff] [blame] | 99 | const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv; |
Bartlomiej Zolnierkiewicz | 7ef5cc9 | 2009-11-04 18:35:32 +0100 | [diff] [blame] | 100 | |
| 101 | rt2800ops->register_multiwrite(rt2x00dev, offset, value, length); |
| 102 | } |
| 103 | |
| 104 | static inline int rt2800_regbusy_read(struct rt2x00_dev *rt2x00dev, |
| 105 | const unsigned int offset, |
| 106 | const struct rt2x00_field32 field, |
| 107 | u32 *reg) |
| 108 | { |
Ivo van Doorn | e796643 | 2010-07-11 12:31:23 +0200 | [diff] [blame] | 109 | const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv; |
Bartlomiej Zolnierkiewicz | 7ef5cc9 | 2009-11-04 18:35:32 +0100 | [diff] [blame] | 110 | |
| 111 | return rt2800ops->regbusy_read(rt2x00dev, offset, field, reg); |
| 112 | } |
| 113 | |
Ivo van Doorn | f31c9a8 | 2010-07-11 12:30:37 +0200 | [diff] [blame] | 114 | static inline int rt2800_drv_write_firmware(struct rt2x00_dev *rt2x00dev, |
| 115 | const u8 *data, const size_t len) |
| 116 | { |
Ivo van Doorn | e796643 | 2010-07-11 12:31:23 +0200 | [diff] [blame] | 117 | const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv; |
Ivo van Doorn | f31c9a8 | 2010-07-11 12:30:37 +0200 | [diff] [blame] | 118 | |
| 119 | return rt2800ops->drv_write_firmware(rt2x00dev, data, len); |
| 120 | } |
| 121 | |
Gertjan van Wingerde | e3a896b | 2010-06-03 10:52:04 +0200 | [diff] [blame] | 122 | static inline int rt2800_drv_init_registers(struct rt2x00_dev *rt2x00dev) |
| 123 | { |
Ivo van Doorn | e796643 | 2010-07-11 12:31:23 +0200 | [diff] [blame] | 124 | const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv; |
Gertjan van Wingerde | e3a896b | 2010-06-03 10:52:04 +0200 | [diff] [blame] | 125 | |
| 126 | return rt2800ops->drv_init_registers(rt2x00dev); |
| 127 | } |
| 128 | |
Bartlomiej Zolnierkiewicz | 8929742 | 2009-11-04 18:36:24 +0100 | [diff] [blame] | 129 | void rt2800_mcu_request(struct rt2x00_dev *rt2x00dev, |
| 130 | const u8 command, const u8 token, |
| 131 | const u8 arg0, const u8 arg1); |
| 132 | |
Ivo van Doorn | f31c9a8 | 2010-07-11 12:30:37 +0200 | [diff] [blame] | 133 | int rt2800_check_firmware(struct rt2x00_dev *rt2x00dev, |
| 134 | const u8 *data, const size_t len); |
| 135 | int rt2800_load_firmware(struct rt2x00_dev *rt2x00dev, |
| 136 | const u8 *data, const size_t len); |
| 137 | |
Gertjan van Wingerde | 0b8004a | 2010-06-03 10:51:45 +0200 | [diff] [blame] | 138 | void rt2800_write_txwi(__le32 *txwi, struct txentry_desc *txdesc); |
Ivo van Doorn | 7486192 | 2010-07-11 12:23:50 +0200 | [diff] [blame] | 139 | void rt2800_process_rxwi(struct queue_entry *entry, struct rxdone_entry_desc *txdesc); |
Gertjan van Wingerde | 59679b9 | 2010-05-08 23:40:21 +0200 | [diff] [blame] | 140 | |
Gertjan van Wingerde | f0194b2 | 2010-06-03 10:51:53 +0200 | [diff] [blame] | 141 | void rt2800_write_beacon(struct queue_entry *entry, struct txentry_desc *txdesc); |
| 142 | |
Bartlomiej Zolnierkiewicz | f445061 | 2009-11-04 18:36:40 +0100 | [diff] [blame] | 143 | extern const struct rt2x00debug rt2800_rt2x00debug; |
| 144 | |
| 145 | int rt2800_rfkill_poll(struct rt2x00_dev *rt2x00dev); |
Bartlomiej Zolnierkiewicz | f445061 | 2009-11-04 18:36:40 +0100 | [diff] [blame] | 146 | int rt2800_config_shared_key(struct rt2x00_dev *rt2x00dev, |
| 147 | struct rt2x00lib_crypto *crypto, |
| 148 | struct ieee80211_key_conf *key); |
| 149 | int rt2800_config_pairwise_key(struct rt2x00_dev *rt2x00dev, |
| 150 | struct rt2x00lib_crypto *crypto, |
| 151 | struct ieee80211_key_conf *key); |
| 152 | void rt2800_config_filter(struct rt2x00_dev *rt2x00dev, |
| 153 | const unsigned int filter_flags); |
| 154 | void rt2800_config_intf(struct rt2x00_dev *rt2x00dev, struct rt2x00_intf *intf, |
| 155 | struct rt2x00intf_conf *conf, const unsigned int flags); |
| 156 | void rt2800_config_erp(struct rt2x00_dev *rt2x00dev, struct rt2x00lib_erp *erp); |
| 157 | void rt2800_config_ant(struct rt2x00_dev *rt2x00dev, struct antenna_setup *ant); |
| 158 | void rt2800_config(struct rt2x00_dev *rt2x00dev, |
| 159 | struct rt2x00lib_conf *libconf, |
| 160 | const unsigned int flags); |
| 161 | void rt2800_link_stats(struct rt2x00_dev *rt2x00dev, struct link_qual *qual); |
| 162 | void rt2800_reset_tuner(struct rt2x00_dev *rt2x00dev, struct link_qual *qual); |
| 163 | void rt2800_link_tuner(struct rt2x00_dev *rt2x00dev, struct link_qual *qual, |
| 164 | const u32 count); |
| 165 | |
Bartlomiej Zolnierkiewicz | fcf5154 | 2009-11-04 18:36:57 +0100 | [diff] [blame] | 166 | int rt2800_init_registers(struct rt2x00_dev *rt2x00dev); |
| 167 | int rt2800_init_bbp(struct rt2x00_dev *rt2x00dev); |
| 168 | int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev); |
Gertjan van Wingerde | 67a4c1e | 2009-12-30 11:36:32 +0100 | [diff] [blame] | 169 | int rt2800_wait_wpdma_ready(struct rt2x00_dev *rt2x00dev); |
Bartlomiej Zolnierkiewicz | fcf5154 | 2009-11-04 18:36:57 +0100 | [diff] [blame] | 170 | |
Bartlomiej Zolnierkiewicz | 30e8403 | 2009-11-08 14:39:48 +0100 | [diff] [blame] | 171 | int rt2800_efuse_detect(struct rt2x00_dev *rt2x00dev); |
| 172 | void rt2800_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev); |
Bartlomiej Zolnierkiewicz | 38bd7b8 | 2009-11-08 14:39:01 +0100 | [diff] [blame] | 173 | int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev); |
| 174 | int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev); |
Bartlomiej Zolnierkiewicz | 4da2933f | 2009-11-08 14:39:32 +0100 | [diff] [blame] | 175 | int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev); |
Bartlomiej Zolnierkiewicz | 38bd7b8 | 2009-11-08 14:39:01 +0100 | [diff] [blame] | 176 | |
Helmut Schaa | e783619 | 2010-07-11 12:28:54 +0200 | [diff] [blame] | 177 | void rt2800_get_tkip_seq(struct ieee80211_hw *hw, u8 hw_key_idx, u32 *iv32, |
| 178 | u16 *iv16); |
| 179 | int rt2800_set_rts_threshold(struct ieee80211_hw *hw, u32 value); |
| 180 | int rt2800_conf_tx(struct ieee80211_hw *hw, u16 queue_idx, |
| 181 | const struct ieee80211_tx_queue_params *params); |
| 182 | u64 rt2800_get_tsf(struct ieee80211_hw *hw); |
| 183 | int rt2800_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
| 184 | enum ieee80211_ampdu_mlme_action action, |
| 185 | struct ieee80211_sta *sta, u16 tid, u16 *ssn); |
Bartlomiej Zolnierkiewicz | 2ce3399 | 2009-11-04 18:37:05 +0100 | [diff] [blame] | 186 | |
Bartlomiej Zolnierkiewicz | 7ef5cc9 | 2009-11-04 18:35:32 +0100 | [diff] [blame] | 187 | #endif /* RT2800LIB_H */ |