1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 Copyright (C) 2010 Willow Garage <http://www.willowgarage.com>
4 Copyright (C) 2010 Ivo van Doorn <IvDoorn@gmail.com>
5 Copyright (C) 2009 Bartlomiej Zolnierkiewicz
13 * Hardware has 255 WCID table entries. First 32 entries are reserved for
14 * shared keys. Since parts of the pairwise key table might be shared with
15 * the beacon frame buffers 6 & 7 we could only use the first 222 entries.
19 #define STA_IDS_SIZE (WCID_END - WCID_START + 2)
21 /* RT2800 driver data structure */
22 struct rt2800_drv_data
{
25 char rx_calibration_bw20
;
26 char rx_calibration_bw40
;
27 char tx_calibration_bw20
;
28 char tx_calibration_bw40
;
34 unsigned int tbtt_tick
;
35 unsigned int ampdu_factor_cnt
[4];
36 DECLARE_BITMAP(sta_ids
, STA_IDS_SIZE
);
37 struct ieee80211_sta
*wcid_to_sta
[STA_IDS_SIZE
];
41 u32 (*register_read
)(struct rt2x00_dev
*rt2x00dev
,
42 const unsigned int offset
);
43 u32 (*register_read_lock
)(struct rt2x00_dev
*rt2x00dev
,
44 const unsigned int offset
);
45 void (*register_write
)(struct rt2x00_dev
*rt2x00dev
,
46 const unsigned int offset
, u32 value
);
47 void (*register_write_lock
)(struct rt2x00_dev
*rt2x00dev
,
48 const unsigned int offset
, u32 value
);
50 void (*register_multiread
)(struct rt2x00_dev
*rt2x00dev
,
51 const unsigned int offset
,
52 void *value
, const u32 length
);
53 void (*register_multiwrite
)(struct rt2x00_dev
*rt2x00dev
,
54 const unsigned int offset
,
55 const void *value
, const u32 length
);
57 int (*regbusy_read
)(struct rt2x00_dev
*rt2x00dev
,
58 const unsigned int offset
,
59 const struct rt2x00_field32 field
, u32
*reg
);
61 int (*read_eeprom
)(struct rt2x00_dev
*rt2x00dev
);
62 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
);
70 static inline u32
rt2800_register_read(struct rt2x00_dev
*rt2x00dev
,
71 const unsigned int offset
)
73 const struct rt2800_ops
*rt2800ops
= rt2x00dev
->ops
->drv
;
75 return rt2800ops
->register_read(rt2x00dev
, offset
);
78 static inline u32
rt2800_register_read_lock(struct rt2x00_dev
*rt2x00dev
,
79 const unsigned int offset
)
81 const struct rt2800_ops
*rt2800ops
= rt2x00dev
->ops
->drv
;
83 return rt2800ops
->register_read_lock(rt2x00dev
, offset
);
86 static inline void rt2800_register_write(struct rt2x00_dev
*rt2x00dev
,
87 const unsigned int offset
,
90 const struct rt2800_ops
*rt2800ops
= rt2x00dev
->ops
->drv
;
92 rt2800ops
->register_write(rt2x00dev
, offset
, value
);
95 static inline void rt2800_register_write_lock(struct rt2x00_dev
*rt2x00dev
,
96 const unsigned int offset
,
99 const struct rt2800_ops
*rt2800ops
= rt2x00dev
->ops
->drv
;
101 rt2800ops
->register_write_lock(rt2x00dev
, offset
, value
);
104 static inline void rt2800_register_multiread(struct rt2x00_dev
*rt2x00dev
,
105 const unsigned int offset
,
106 void *value
, const u32 length
)
108 const struct rt2800_ops
*rt2800ops
= rt2x00dev
->ops
->drv
;
110 rt2800ops
->register_multiread(rt2x00dev
, offset
, value
, length
);
113 static inline void rt2800_register_multiwrite(struct rt2x00_dev
*rt2x00dev
,
114 const unsigned int offset
,
118 const struct rt2800_ops
*rt2800ops
= rt2x00dev
->ops
->drv
;
120 rt2800ops
->register_multiwrite(rt2x00dev
, offset
, value
, length
);
123 static inline int rt2800_regbusy_read(struct rt2x00_dev
*rt2x00dev
,
124 const unsigned int offset
,
125 const struct rt2x00_field32 field
,
128 const struct rt2800_ops
*rt2800ops
= rt2x00dev
->ops
->drv
;
130 return rt2800ops
->regbusy_read(rt2x00dev
, offset
, field
, reg
);
133 static inline int rt2800_read_eeprom(struct rt2x00_dev
*rt2x00dev
)
135 const struct rt2800_ops
*rt2800ops
= rt2x00dev
->ops
->drv
;
137 return rt2800ops
->read_eeprom(rt2x00dev
);
140 static inline bool rt2800_hwcrypt_disabled(struct rt2x00_dev
*rt2x00dev
)
142 const struct rt2800_ops
*rt2800ops
= rt2x00dev
->ops
->drv
;
144 return rt2800ops
->hwcrypt_disabled(rt2x00dev
);
147 static inline int rt2800_drv_write_firmware(struct rt2x00_dev
*rt2x00dev
,
148 const u8
*data
, const size_t len
)
150 const struct rt2800_ops
*rt2800ops
= rt2x00dev
->ops
->drv
;
152 return rt2800ops
->drv_write_firmware(rt2x00dev
, data
, len
);
155 static inline int rt2800_drv_init_registers(struct rt2x00_dev
*rt2x00dev
)
157 const struct rt2800_ops
*rt2800ops
= rt2x00dev
->ops
->drv
;
159 return rt2800ops
->drv_init_registers(rt2x00dev
);
162 static inline __le32
*rt2800_drv_get_txwi(struct queue_entry
*entry
)
164 const struct rt2800_ops
*rt2800ops
= entry
->queue
->rt2x00dev
->ops
->drv
;
166 return rt2800ops
->drv_get_txwi(entry
);
169 void rt2800_mcu_request(struct rt2x00_dev
*rt2x00dev
,
170 const u8 command
, const u8 token
,
171 const u8 arg0
, const u8 arg1
);
173 int rt2800_wait_csr_ready(struct rt2x00_dev
*rt2x00dev
);
174 int rt2800_wait_wpdma_ready(struct rt2x00_dev
*rt2x00dev
);
176 int rt2800_check_firmware(struct rt2x00_dev
*rt2x00dev
,
177 const u8
*data
, const size_t len
);
178 int rt2800_load_firmware(struct rt2x00_dev
*rt2x00dev
,
179 const u8
*data
, const size_t len
);
181 void rt2800_write_tx_data(struct queue_entry
*entry
,
182 struct txentry_desc
*txdesc
);
183 void rt2800_process_rxwi(struct queue_entry
*entry
, struct rxdone_entry_desc
*txdesc
);
185 void rt2800_txdone_entry(struct queue_entry
*entry
, u32 status
, __le32
*txwi
,
187 void rt2800_txdone(struct rt2x00_dev
*rt2x00dev
, unsigned int quota
);
188 void rt2800_txdone_nostatus(struct rt2x00_dev
*rt2x00dev
);
189 bool rt2800_txstatus_timeout(struct rt2x00_dev
*rt2x00dev
);
190 bool rt2800_txstatus_pending(struct rt2x00_dev
*rt2x00dev
);
192 void rt2800_write_beacon(struct queue_entry
*entry
, struct txentry_desc
*txdesc
);
193 void rt2800_clear_beacon(struct queue_entry
*entry
);
195 extern const struct rt2x00debug rt2800_rt2x00debug
;
197 int rt2800_rfkill_poll(struct rt2x00_dev
*rt2x00dev
);
198 int rt2800_config_shared_key(struct rt2x00_dev
*rt2x00dev
,
199 struct rt2x00lib_crypto
*crypto
,
200 struct ieee80211_key_conf
*key
);
201 int rt2800_config_pairwise_key(struct rt2x00_dev
*rt2x00dev
,
202 struct rt2x00lib_crypto
*crypto
,
203 struct ieee80211_key_conf
*key
);
204 int rt2800_sta_add(struct ieee80211_hw
*hw
, struct ieee80211_vif
*vif
,
205 struct ieee80211_sta
*sta
);
206 int rt2800_sta_remove(struct ieee80211_hw
*hw
, struct ieee80211_vif
*vif
,
207 struct ieee80211_sta
*sta
);
208 void rt2800_config_filter(struct rt2x00_dev
*rt2x00dev
,
209 const unsigned int filter_flags
);
210 void rt2800_config_intf(struct rt2x00_dev
*rt2x00dev
, struct rt2x00_intf
*intf
,
211 struct rt2x00intf_conf
*conf
, const unsigned int flags
);
212 void rt2800_config_erp(struct rt2x00_dev
*rt2x00dev
, struct rt2x00lib_erp
*erp
,
214 void rt2800_config_ant(struct rt2x00_dev
*rt2x00dev
, struct antenna_setup
*ant
);
215 void rt2800_config(struct rt2x00_dev
*rt2x00dev
,
216 struct rt2x00lib_conf
*libconf
,
217 const unsigned int flags
);
218 void rt2800_link_stats(struct rt2x00_dev
*rt2x00dev
, struct link_qual
*qual
);
219 void rt2800_reset_tuner(struct rt2x00_dev
*rt2x00dev
, struct link_qual
*qual
);
220 void rt2800_link_tuner(struct rt2x00_dev
*rt2x00dev
, struct link_qual
*qual
,
222 void rt2800_gain_calibration(struct rt2x00_dev
*rt2x00dev
);
223 void rt2800_vco_calibration(struct rt2x00_dev
*rt2x00dev
);
225 int rt2800_enable_radio(struct rt2x00_dev
*rt2x00dev
);
226 void rt2800_disable_radio(struct rt2x00_dev
*rt2x00dev
);
228 int rt2800_efuse_detect(struct rt2x00_dev
*rt2x00dev
);
229 int rt2800_read_eeprom_efuse(struct rt2x00_dev
*rt2x00dev
);
231 int rt2800_probe_hw(struct rt2x00_dev
*rt2x00dev
);
233 void rt2800_get_key_seq(struct ieee80211_hw
*hw
,
234 struct ieee80211_key_conf
*key
,
235 struct ieee80211_key_seq
*seq
);
236 int rt2800_set_rts_threshold(struct ieee80211_hw
*hw
, u32 value
);
237 int rt2800_conf_tx(struct ieee80211_hw
*hw
,
238 struct ieee80211_vif
*vif
, u16 queue_idx
,
239 const struct ieee80211_tx_queue_params
*params
);
240 u64
rt2800_get_tsf(struct ieee80211_hw
*hw
, struct ieee80211_vif
*vif
);
241 int rt2800_ampdu_action(struct ieee80211_hw
*hw
, struct ieee80211_vif
*vif
,
242 struct ieee80211_ampdu_params
*params
);
243 int rt2800_get_survey(struct ieee80211_hw
*hw
, int idx
,
244 struct survey_info
*survey
);
245 void rt2800_disable_wpdma(struct rt2x00_dev
*rt2x00dev
);
247 void rt2800_get_txwi_rxwi_size(struct rt2x00_dev
*rt2x00dev
,
248 unsigned short *txwi_size
,
249 unsigned short *rxwi_size
);
251 #endif /* RT2800LIB_H */