0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef RT2800LIB_H
0010 #define RT2800LIB_H
0011
0012
0013
0014
0015
0016
0017 #define WCID_START 33
0018 #define WCID_END 222
0019 #define STA_IDS_SIZE (WCID_END - WCID_START + 2)
0020
0021
0022 struct rt2800_drv_data {
0023 u8 calibration_bw20;
0024 u8 calibration_bw40;
0025 char rx_calibration_bw20;
0026 char rx_calibration_bw40;
0027 char tx_calibration_bw20;
0028 char tx_calibration_bw40;
0029 u8 bbp25;
0030 u8 bbp26;
0031 u8 txmixer_gain_24g;
0032 u8 txmixer_gain_5g;
0033 u8 max_psdu;
0034 unsigned int tbtt_tick;
0035 unsigned int ampdu_factor_cnt[4];
0036 DECLARE_BITMAP(sta_ids, STA_IDS_SIZE);
0037 struct ieee80211_sta *wcid_to_sta[STA_IDS_SIZE];
0038 };
0039
0040 struct rt2800_ops {
0041 u32 (*register_read)(struct rt2x00_dev *rt2x00dev,
0042 const unsigned int offset);
0043 u32 (*register_read_lock)(struct rt2x00_dev *rt2x00dev,
0044 const unsigned int offset);
0045 void (*register_write)(struct rt2x00_dev *rt2x00dev,
0046 const unsigned int offset, u32 value);
0047 void (*register_write_lock)(struct rt2x00_dev *rt2x00dev,
0048 const unsigned int offset, u32 value);
0049
0050 void (*register_multiread)(struct rt2x00_dev *rt2x00dev,
0051 const unsigned int offset,
0052 void *value, const u32 length);
0053 void (*register_multiwrite)(struct rt2x00_dev *rt2x00dev,
0054 const unsigned int offset,
0055 const void *value, const u32 length);
0056
0057 int (*regbusy_read)(struct rt2x00_dev *rt2x00dev,
0058 const unsigned int offset,
0059 const struct rt2x00_field32 field, u32 *reg);
0060
0061 int (*read_eeprom)(struct rt2x00_dev *rt2x00dev);
0062 bool (*hwcrypt_disabled)(struct rt2x00_dev *rt2x00dev);
0063
0064 int (*drv_write_firmware)(struct rt2x00_dev *rt2x00dev,
0065 const u8 *data, const size_t len);
0066 int (*drv_init_registers)(struct rt2x00_dev *rt2x00dev);
0067 __le32 *(*drv_get_txwi)(struct queue_entry *entry);
0068 unsigned int (*drv_get_dma_done)(struct data_queue *queue);
0069 };
0070
0071 static inline u32 rt2800_register_read(struct rt2x00_dev *rt2x00dev,
0072 const unsigned int offset)
0073 {
0074 const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
0075
0076 return rt2800ops->register_read(rt2x00dev, offset);
0077 }
0078
0079 static inline u32 rt2800_register_read_lock(struct rt2x00_dev *rt2x00dev,
0080 const unsigned int offset)
0081 {
0082 const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
0083
0084 return rt2800ops->register_read_lock(rt2x00dev, offset);
0085 }
0086
0087 static inline void rt2800_register_write(struct rt2x00_dev *rt2x00dev,
0088 const unsigned int offset,
0089 u32 value)
0090 {
0091 const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
0092
0093 rt2800ops->register_write(rt2x00dev, offset, value);
0094 }
0095
0096 static inline void rt2800_register_write_lock(struct rt2x00_dev *rt2x00dev,
0097 const unsigned int offset,
0098 u32 value)
0099 {
0100 const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
0101
0102 rt2800ops->register_write_lock(rt2x00dev, offset, value);
0103 }
0104
0105 static inline void rt2800_register_multiread(struct rt2x00_dev *rt2x00dev,
0106 const unsigned int offset,
0107 void *value, const u32 length)
0108 {
0109 const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
0110
0111 rt2800ops->register_multiread(rt2x00dev, offset, value, length);
0112 }
0113
0114 static inline void rt2800_register_multiwrite(struct rt2x00_dev *rt2x00dev,
0115 const unsigned int offset,
0116 const void *value,
0117 const u32 length)
0118 {
0119 const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
0120
0121 rt2800ops->register_multiwrite(rt2x00dev, offset, value, length);
0122 }
0123
0124 static inline int rt2800_regbusy_read(struct rt2x00_dev *rt2x00dev,
0125 const unsigned int offset,
0126 const struct rt2x00_field32 field,
0127 u32 *reg)
0128 {
0129 const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
0130
0131 return rt2800ops->regbusy_read(rt2x00dev, offset, field, reg);
0132 }
0133
0134 static inline int rt2800_read_eeprom(struct rt2x00_dev *rt2x00dev)
0135 {
0136 const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
0137
0138 return rt2800ops->read_eeprom(rt2x00dev);
0139 }
0140
0141 static inline bool rt2800_hwcrypt_disabled(struct rt2x00_dev *rt2x00dev)
0142 {
0143 const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
0144
0145 return rt2800ops->hwcrypt_disabled(rt2x00dev);
0146 }
0147
0148 static inline int rt2800_drv_write_firmware(struct rt2x00_dev *rt2x00dev,
0149 const u8 *data, const size_t len)
0150 {
0151 const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
0152
0153 return rt2800ops->drv_write_firmware(rt2x00dev, data, len);
0154 }
0155
0156 static inline int rt2800_drv_init_registers(struct rt2x00_dev *rt2x00dev)
0157 {
0158 const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
0159
0160 return rt2800ops->drv_init_registers(rt2x00dev);
0161 }
0162
0163 static inline __le32 *rt2800_drv_get_txwi(struct queue_entry *entry)
0164 {
0165 const struct rt2800_ops *rt2800ops = entry->queue->rt2x00dev->ops->drv;
0166
0167 return rt2800ops->drv_get_txwi(entry);
0168 }
0169
0170 static inline unsigned int rt2800_drv_get_dma_done(struct data_queue *queue)
0171 {
0172 const struct rt2800_ops *rt2800ops = queue->rt2x00dev->ops->drv;
0173
0174 return rt2800ops->drv_get_dma_done(queue);
0175 }
0176
0177 void rt2800_mcu_request(struct rt2x00_dev *rt2x00dev,
0178 const u8 command, const u8 token,
0179 const u8 arg0, const u8 arg1);
0180
0181 int rt2800_wait_csr_ready(struct rt2x00_dev *rt2x00dev);
0182 int rt2800_wait_wpdma_ready(struct rt2x00_dev *rt2x00dev);
0183
0184 int rt2800_check_firmware(struct rt2x00_dev *rt2x00dev,
0185 const u8 *data, const size_t len);
0186 int rt2800_load_firmware(struct rt2x00_dev *rt2x00dev,
0187 const u8 *data, const size_t len);
0188
0189 void rt2800_write_tx_data(struct queue_entry *entry,
0190 struct txentry_desc *txdesc);
0191 void rt2800_process_rxwi(struct queue_entry *entry, struct rxdone_entry_desc *txdesc);
0192
0193 void rt2800_txdone_entry(struct queue_entry *entry, u32 status, __le32 *txwi,
0194 bool match);
0195 void rt2800_txdone(struct rt2x00_dev *rt2x00dev, unsigned int quota);
0196 void rt2800_txdone_nostatus(struct rt2x00_dev *rt2x00dev);
0197 bool rt2800_txstatus_timeout(struct rt2x00_dev *rt2x00dev);
0198 bool rt2800_txstatus_pending(struct rt2x00_dev *rt2x00dev);
0199
0200 void rt2800_watchdog(struct rt2x00_dev *rt2x00dev);
0201
0202 void rt2800_write_beacon(struct queue_entry *entry, struct txentry_desc *txdesc);
0203 void rt2800_clear_beacon(struct queue_entry *entry);
0204
0205 extern const struct rt2x00debug rt2800_rt2x00debug;
0206
0207 int rt2800_rfkill_poll(struct rt2x00_dev *rt2x00dev);
0208 int rt2800_config_shared_key(struct rt2x00_dev *rt2x00dev,
0209 struct rt2x00lib_crypto *crypto,
0210 struct ieee80211_key_conf *key);
0211 int rt2800_config_pairwise_key(struct rt2x00_dev *rt2x00dev,
0212 struct rt2x00lib_crypto *crypto,
0213 struct ieee80211_key_conf *key);
0214 int rt2800_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
0215 struct ieee80211_sta *sta);
0216 int rt2800_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
0217 struct ieee80211_sta *sta);
0218 void rt2800_config_filter(struct rt2x00_dev *rt2x00dev,
0219 const unsigned int filter_flags);
0220 void rt2800_config_intf(struct rt2x00_dev *rt2x00dev, struct rt2x00_intf *intf,
0221 struct rt2x00intf_conf *conf, const unsigned int flags);
0222 void rt2800_config_erp(struct rt2x00_dev *rt2x00dev, struct rt2x00lib_erp *erp,
0223 u32 changed);
0224 void rt2800_config_ant(struct rt2x00_dev *rt2x00dev, struct antenna_setup *ant);
0225 void rt2800_config(struct rt2x00_dev *rt2x00dev,
0226 struct rt2x00lib_conf *libconf,
0227 const unsigned int flags);
0228 void rt2800_link_stats(struct rt2x00_dev *rt2x00dev, struct link_qual *qual);
0229 void rt2800_reset_tuner(struct rt2x00_dev *rt2x00dev, struct link_qual *qual);
0230 void rt2800_link_tuner(struct rt2x00_dev *rt2x00dev, struct link_qual *qual,
0231 const u32 count);
0232 void rt2800_gain_calibration(struct rt2x00_dev *rt2x00dev);
0233 void rt2800_vco_calibration(struct rt2x00_dev *rt2x00dev);
0234
0235 int rt2800_enable_radio(struct rt2x00_dev *rt2x00dev);
0236 void rt2800_disable_radio(struct rt2x00_dev *rt2x00dev);
0237
0238 int rt2800_efuse_detect(struct rt2x00_dev *rt2x00dev);
0239 int rt2800_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev);
0240
0241 int rt2800_probe_hw(struct rt2x00_dev *rt2x00dev);
0242
0243 void rt2800_get_key_seq(struct ieee80211_hw *hw,
0244 struct ieee80211_key_conf *key,
0245 struct ieee80211_key_seq *seq);
0246 int rt2800_set_rts_threshold(struct ieee80211_hw *hw, u32 value);
0247 int rt2800_conf_tx(struct ieee80211_hw *hw,
0248 struct ieee80211_vif *vif,
0249 unsigned int link_id, u16 queue_idx,
0250 const struct ieee80211_tx_queue_params *params);
0251 u64 rt2800_get_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif);
0252 int rt2800_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
0253 struct ieee80211_ampdu_params *params);
0254 int rt2800_get_survey(struct ieee80211_hw *hw, int idx,
0255 struct survey_info *survey);
0256 void rt2800_disable_wpdma(struct rt2x00_dev *rt2x00dev);
0257
0258 void rt2800_get_txwi_rxwi_size(struct rt2x00_dev *rt2x00dev,
0259 unsigned short *txwi_size,
0260 unsigned short *rxwi_size);
0261 void rt2800_pre_reset_hw(struct rt2x00_dev *rt2x00dev);
0262
0263 #endif