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
);
68 unsigned int (*drv_get_dma_done
)(struct data_queue
*queue
);
71 static inline u32
rt2800_register_read(struct rt2x00_dev
*rt2x00dev
,
72 const unsigned int offset
)
74 const struct rt2800_ops
*rt2800ops
= rt2x00dev
->ops
->drv
;
76 return rt2800ops
->register_read(rt2x00dev
, offset
);
79 static inline u32
rt2800_register_read_lock(struct rt2x00_dev
*rt2x00dev
,
80 const unsigned int offset
)
82 const struct rt2800_ops
*rt2800ops
= rt2x00dev
->ops
->drv
;
84 return rt2800ops
->register_read_lock(rt2x00dev
, offset
);
87 static inline void rt2800_register_write(struct rt2x00_dev
*rt2x00dev
,
88 const unsigned int offset
,
91 const struct rt2800_ops
*rt2800ops
= rt2x00dev
->ops
->drv
;
93 rt2800ops
->register_write(rt2x00dev
, offset
, value
);
96 static inline void rt2800_register_write_lock(struct rt2x00_dev
*rt2x00dev
,
97 const unsigned int offset
,
100 const struct rt2800_ops
*rt2800ops
= rt2x00dev
->ops
->drv
;
102 rt2800ops
->register_write_lock(rt2x00dev
, offset
, value
);
105 static inline void rt2800_register_multiread(struct rt2x00_dev
*rt2x00dev
,
106 const unsigned int offset
,
107 void *value
, const u32 length
)
109 const struct rt2800_ops
*rt2800ops
= rt2x00dev
->ops
->drv
;
111 rt2800ops
->register_multiread(rt2x00dev
, offset
, value
, length
);
114 static inline void rt2800_register_multiwrite(struct rt2x00_dev
*rt2x00dev
,
115 const unsigned int offset
,
119 const struct rt2800_ops
*rt2800ops
= rt2x00dev
->ops
->drv
;
121 rt2800ops
->register_multiwrite(rt2x00dev
, offset
, value
, length
);
124 static inline int rt2800_regbusy_read(struct rt2x00_dev
*rt2x00dev
,
125 const unsigned int offset
,
126 const struct rt2x00_field32 field
,
129 const struct rt2800_ops
*rt2800ops
= rt2x00dev
->ops
->drv
;
131 return rt2800ops
->regbusy_read(rt2x00dev
, offset
, field
, reg
);
134 static inline int rt2800_read_eeprom(struct rt2x00_dev
*rt2x00dev
)
136 const struct rt2800_ops
*rt2800ops
= rt2x00dev
->ops
->drv
;
138 return rt2800ops
->read_eeprom(rt2x00dev
);
141 static inline bool rt2800_hwcrypt_disabled(struct rt2x00_dev
*rt2x00dev
)
143 const struct rt2800_ops
*rt2800ops
= rt2x00dev
->ops
->drv
;
145 return rt2800ops
->hwcrypt_disabled(rt2x00dev
);
148 static inline int rt2800_drv_write_firmware(struct rt2x00_dev
*rt2x00dev
,
149 const u8
*data
, const size_t len
)
151 const struct rt2800_ops
*rt2800ops
= rt2x00dev
->ops
->drv
;
153 return rt2800ops
->drv_write_firmware(rt2x00dev
, data
, len
);
156 static inline int rt2800_drv_init_registers(struct rt2x00_dev
*rt2x00dev
)
158 const struct rt2800_ops
*rt2800ops
= rt2x00dev
->ops
->drv
;
160 return rt2800ops
->drv_init_registers(rt2x00dev
);
163 static inline __le32
*rt2800_drv_get_txwi(struct queue_entry
*entry
)
165 const struct rt2800_ops
*rt2800ops
= entry
->queue
->rt2x00dev
->ops
->drv
;
167 return rt2800ops
->drv_get_txwi(entry
);
170 static inline unsigned int rt2800_drv_get_dma_done(struct data_queue
*queue
)
172 const struct rt2800_ops
*rt2800ops
= queue
->rt2x00dev
->ops
->drv
;
174 return rt2800ops
->drv_get_dma_done(queue
);
177 void rt2800_mcu_request(struct rt2x00_dev
*rt2x00dev
,
178 const u8 command
, const u8 token
,
179 const u8 arg0
, const u8 arg1
);
181 int rt2800_wait_csr_ready(struct rt2x00_dev
*rt2x00dev
);
182 int rt2800_wait_wpdma_ready(struct rt2x00_dev
*rt2x00dev
);
184 int rt2800_check_firmware(struct rt2x00_dev
*rt2x00dev
,
185 const u8
*data
, const size_t len
);
186 int rt2800_load_firmware(struct rt2x00_dev
*rt2x00dev
,
187 const u8
*data
, const size_t len
);
189 void rt2800_write_tx_data(struct queue_entry
*entry
,
190 struct txentry_desc
*txdesc
);
191 void rt2800_process_rxwi(struct queue_entry
*entry
, struct rxdone_entry_desc
*txdesc
);
193 void rt2800_txdone_entry(struct queue_entry
*entry
, u32 status
, __le32
*txwi
,
195 void rt2800_txdone(struct rt2x00_dev
*rt2x00dev
, unsigned int quota
);
196 void rt2800_txdone_nostatus(struct rt2x00_dev
*rt2x00dev
);
197 bool rt2800_txstatus_timeout(struct rt2x00_dev
*rt2x00dev
);
198 bool rt2800_txstatus_pending(struct rt2x00_dev
*rt2x00dev
);
200 void rt2800_watchdog(struct rt2x00_dev
*rt2x00dev
);
202 void rt2800_write_beacon(struct queue_entry
*entry
, struct txentry_desc
*txdesc
);
203 void rt2800_clear_beacon(struct queue_entry
*entry
);
205 extern const struct rt2x00debug rt2800_rt2x00debug
;
207 int rt2800_rfkill_poll(struct rt2x00_dev
*rt2x00dev
);
208 int rt2800_config_shared_key(struct rt2x00_dev
*rt2x00dev
,
209 struct rt2x00lib_crypto
*crypto
,
210 struct ieee80211_key_conf
*key
);
211 int rt2800_config_pairwise_key(struct rt2x00_dev
*rt2x00dev
,
212 struct rt2x00lib_crypto
*crypto
,
213 struct ieee80211_key_conf
*key
);
214 int rt2800_sta_add(struct ieee80211_hw
*hw
, struct ieee80211_vif
*vif
,
215 struct ieee80211_sta
*sta
);
216 int rt2800_sta_remove(struct ieee80211_hw
*hw
, struct ieee80211_vif
*vif
,
217 struct ieee80211_sta
*sta
);
218 void rt2800_config_filter(struct rt2x00_dev
*rt2x00dev
,
219 const unsigned int filter_flags
);
220 void rt2800_config_intf(struct rt2x00_dev
*rt2x00dev
, struct rt2x00_intf
*intf
,
221 struct rt2x00intf_conf
*conf
, const unsigned int flags
);
222 void rt2800_config_erp(struct rt2x00_dev
*rt2x00dev
, struct rt2x00lib_erp
*erp
,
224 void rt2800_config_ant(struct rt2x00_dev
*rt2x00dev
, struct antenna_setup
*ant
);
225 void rt2800_config(struct rt2x00_dev
*rt2x00dev
,
226 struct rt2x00lib_conf
*libconf
,
227 const unsigned int flags
);
228 void rt2800_link_stats(struct rt2x00_dev
*rt2x00dev
, struct link_qual
*qual
);
229 void rt2800_reset_tuner(struct rt2x00_dev
*rt2x00dev
, struct link_qual
*qual
);
230 void rt2800_link_tuner(struct rt2x00_dev
*rt2x00dev
, struct link_qual
*qual
,
232 void rt2800_gain_calibration(struct rt2x00_dev
*rt2x00dev
);
233 void rt2800_vco_calibration(struct rt2x00_dev
*rt2x00dev
);
235 int rt2800_enable_radio(struct rt2x00_dev
*rt2x00dev
);
236 void rt2800_disable_radio(struct rt2x00_dev
*rt2x00dev
);
238 int rt2800_efuse_detect(struct rt2x00_dev
*rt2x00dev
);
239 int rt2800_read_eeprom_efuse(struct rt2x00_dev
*rt2x00dev
);
241 int rt2800_probe_hw(struct rt2x00_dev
*rt2x00dev
);
243 void rt2800_get_key_seq(struct ieee80211_hw
*hw
,
244 struct ieee80211_key_conf
*key
,
245 struct ieee80211_key_seq
*seq
);
246 int rt2800_set_rts_threshold(struct ieee80211_hw
*hw
, u32 value
);
247 int rt2800_conf_tx(struct ieee80211_hw
*hw
,
248 struct ieee80211_vif
*vif
, u16 queue_idx
,
249 const struct ieee80211_tx_queue_params
*params
);
250 u64
rt2800_get_tsf(struct ieee80211_hw
*hw
, struct ieee80211_vif
*vif
);
251 int rt2800_ampdu_action(struct ieee80211_hw
*hw
, struct ieee80211_vif
*vif
,
252 struct ieee80211_ampdu_params
*params
);
253 int rt2800_get_survey(struct ieee80211_hw
*hw
, int idx
,
254 struct survey_info
*survey
);
255 void rt2800_disable_wpdma(struct rt2x00_dev
*rt2x00dev
);
257 void rt2800_get_txwi_rxwi_size(struct rt2x00_dev
*rt2x00dev
,
258 unsigned short *txwi_size
,
259 unsigned short *rxwi_size
);
260 void rt2800_pre_reset_hw(struct rt2x00_dev
*rt2x00dev
);
262 #endif /* RT2800LIB_H */