blob: a128ceadcb3e733620c37fa03e49666cf80b2e09 [file] [log] [blame]
Bartlomiej Zolnierkiewicz7ef5cc92009-11-04 18:35:32 +01001/*
Ivo van Doorn96481b22010-08-06 20:47:57 +02002 Copyright (C) 2010 Willow Garage <http://www.willowgarage.com>
3 Copyright (C) 2010 Ivo van Doorn <IvDoorn@gmail.com>
Bartlomiej Zolnierkiewicz7ef5cc92009-11-04 18:35:32 +01004 Copyright (C) 2009 Bartlomiej Zolnierkiewicz
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the
18 Free Software Foundation, Inc.,
19 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 */
21
22#ifndef RT2800LIB_H
23#define RT2800LIB_H
24
25struct rt2800_ops {
26 void (*register_read)(struct rt2x00_dev *rt2x00dev,
27 const unsigned int offset, u32 *value);
Gertjan van Wingerde31a4cf12009-11-14 20:20:36 +010028 void (*register_read_lock)(struct rt2x00_dev *rt2x00dev,
29 const unsigned int offset, u32 *value);
Bartlomiej Zolnierkiewicz7ef5cc92009-11-04 18:35:32 +010030 void (*register_write)(struct rt2x00_dev *rt2x00dev,
31 const unsigned int offset, u32 value);
32 void (*register_write_lock)(struct rt2x00_dev *rt2x00dev,
33 const unsigned int offset, u32 value);
34
35 void (*register_multiread)(struct rt2x00_dev *rt2x00dev,
36 const unsigned int offset,
37 void *value, const u32 length);
38 void (*register_multiwrite)(struct rt2x00_dev *rt2x00dev,
39 const unsigned int offset,
40 const void *value, const u32 length);
41
42 int (*regbusy_read)(struct rt2x00_dev *rt2x00dev,
43 const unsigned int offset,
44 const struct rt2x00_field32 field, u32 *reg);
Gertjan van Wingerdee3a896b2010-06-03 10:52:04 +020045
Gertjan van Wingerdead417a52012-09-03 03:25:51 +020046 void (*read_eeprom)(struct rt2x00_dev *rt2x00dev);
47 bool (*hwcrypt_disabled)(struct rt2x00_dev *rt2x00dev);
48
Ivo van Doornf31c9a82010-07-11 12:30:37 +020049 int (*drv_write_firmware)(struct rt2x00_dev *rt2x00dev,
50 const u8 *data, const size_t len);
Gertjan van Wingerdee3a896b2010-06-03 10:52:04 +020051 int (*drv_init_registers)(struct rt2x00_dev *rt2x00dev);
Ivo van Doorn0c5879b2010-08-06 20:47:20 +020052 __le32 *(*drv_get_txwi)(struct queue_entry *entry);
Bartlomiej Zolnierkiewicz7ef5cc92009-11-04 18:35:32 +010053};
54
55static inline void rt2800_register_read(struct rt2x00_dev *rt2x00dev,
56 const unsigned int offset,
57 u32 *value)
58{
Ivo van Doorne7966432010-07-11 12:31:23 +020059 const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
Bartlomiej Zolnierkiewicz7ef5cc92009-11-04 18:35:32 +010060
61 rt2800ops->register_read(rt2x00dev, offset, value);
62}
63
Gertjan van Wingerde31a4cf12009-11-14 20:20:36 +010064static inline void rt2800_register_read_lock(struct rt2x00_dev *rt2x00dev,
65 const unsigned int offset,
66 u32 *value)
67{
Ivo van Doorne7966432010-07-11 12:31:23 +020068 const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
Gertjan van Wingerde31a4cf12009-11-14 20:20:36 +010069
70 rt2800ops->register_read_lock(rt2x00dev, offset, value);
71}
72
Bartlomiej Zolnierkiewicz7ef5cc92009-11-04 18:35:32 +010073static inline void rt2800_register_write(struct rt2x00_dev *rt2x00dev,
74 const unsigned int offset,
75 u32 value)
76{
Ivo van Doorne7966432010-07-11 12:31:23 +020077 const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
Bartlomiej Zolnierkiewicz7ef5cc92009-11-04 18:35:32 +010078
79 rt2800ops->register_write(rt2x00dev, offset, value);
80}
81
82static inline void rt2800_register_write_lock(struct rt2x00_dev *rt2x00dev,
83 const unsigned int offset,
84 u32 value)
85{
Ivo van Doorne7966432010-07-11 12:31:23 +020086 const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
Bartlomiej Zolnierkiewicz7ef5cc92009-11-04 18:35:32 +010087
88 rt2800ops->register_write_lock(rt2x00dev, offset, value);
89}
90
91static inline void rt2800_register_multiread(struct rt2x00_dev *rt2x00dev,
92 const unsigned int offset,
93 void *value, const u32 length)
94{
Ivo van Doorne7966432010-07-11 12:31:23 +020095 const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
Bartlomiej Zolnierkiewicz7ef5cc92009-11-04 18:35:32 +010096
97 rt2800ops->register_multiread(rt2x00dev, offset, value, length);
98}
99
100static inline void rt2800_register_multiwrite(struct rt2x00_dev *rt2x00dev,
101 const unsigned int offset,
102 const void *value,
103 const u32 length)
104{
Ivo van Doorne7966432010-07-11 12:31:23 +0200105 const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
Bartlomiej Zolnierkiewicz7ef5cc92009-11-04 18:35:32 +0100106
107 rt2800ops->register_multiwrite(rt2x00dev, offset, value, length);
108}
109
110static inline int rt2800_regbusy_read(struct rt2x00_dev *rt2x00dev,
111 const unsigned int offset,
112 const struct rt2x00_field32 field,
113 u32 *reg)
114{
Ivo van Doorne7966432010-07-11 12:31:23 +0200115 const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
Bartlomiej Zolnierkiewicz7ef5cc92009-11-04 18:35:32 +0100116
117 return rt2800ops->regbusy_read(rt2x00dev, offset, field, reg);
118}
119
Gertjan van Wingerdead417a52012-09-03 03:25:51 +0200120static inline void rt2800_read_eeprom(struct rt2x00_dev *rt2x00dev)
121{
122 const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
123
124 rt2800ops->read_eeprom(rt2x00dev);
125}
126
127static inline bool rt2800_hwcrypt_disabled(struct rt2x00_dev *rt2x00dev)
128{
129 const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
130
131 return rt2800ops->hwcrypt_disabled(rt2x00dev);
132}
133
Ivo van Doornf31c9a82010-07-11 12:30:37 +0200134static inline int rt2800_drv_write_firmware(struct rt2x00_dev *rt2x00dev,
135 const u8 *data, const size_t len)
136{
Ivo van Doorne7966432010-07-11 12:31:23 +0200137 const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
Ivo van Doornf31c9a82010-07-11 12:30:37 +0200138
139 return rt2800ops->drv_write_firmware(rt2x00dev, data, len);
140}
141
Gertjan van Wingerdee3a896b2010-06-03 10:52:04 +0200142static inline int rt2800_drv_init_registers(struct rt2x00_dev *rt2x00dev)
143{
Ivo van Doorne7966432010-07-11 12:31:23 +0200144 const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
Gertjan van Wingerdee3a896b2010-06-03 10:52:04 +0200145
146 return rt2800ops->drv_init_registers(rt2x00dev);
147}
148
Ivo van Doorn0c5879b2010-08-06 20:47:20 +0200149static inline __le32 *rt2800_drv_get_txwi(struct queue_entry *entry)
150{
151 const struct rt2800_ops *rt2800ops = entry->queue->rt2x00dev->ops->drv;
152
153 return rt2800ops->drv_get_txwi(entry);
154}
155
Bartlomiej Zolnierkiewicz89297422009-11-04 18:36:24 +0100156void rt2800_mcu_request(struct rt2x00_dev *rt2x00dev,
157 const u8 command, const u8 token,
158 const u8 arg0, const u8 arg1);
159
Ivo van Doorn5ffddc42010-08-30 21:13:08 +0200160int rt2800_wait_csr_ready(struct rt2x00_dev *rt2x00dev);
Ivo van Doornb9a07ae2010-08-23 19:55:22 +0200161int rt2800_wait_wpdma_ready(struct rt2x00_dev *rt2x00dev);
162
Ivo van Doornf31c9a82010-07-11 12:30:37 +0200163int rt2800_check_firmware(struct rt2x00_dev *rt2x00dev,
164 const u8 *data, const size_t len);
165int rt2800_load_firmware(struct rt2x00_dev *rt2x00dev,
166 const u8 *data, const size_t len);
167
Ivo van Doorn0c5879b2010-08-06 20:47:20 +0200168void rt2800_write_tx_data(struct queue_entry *entry,
169 struct txentry_desc *txdesc);
Ivo van Doorn74861922010-07-11 12:23:50 +0200170void rt2800_process_rxwi(struct queue_entry *entry, struct rxdone_entry_desc *txdesc);
Gertjan van Wingerde59679b92010-05-08 23:40:21 +0200171
Helmut Schaa31937c42011-09-07 20:10:02 +0200172void rt2800_txdone_entry(struct queue_entry *entry, u32 status, __le32* txwi);
Ivo van Doorn96481b22010-08-06 20:47:57 +0200173
Gertjan van Wingerdef0194b22010-06-03 10:51:53 +0200174void rt2800_write_beacon(struct queue_entry *entry, struct txentry_desc *txdesc);
Helmut Schaa69cf36a2011-01-30 13:16:03 +0100175void rt2800_clear_beacon(struct queue_entry *entry);
Gertjan van Wingerdef0194b22010-06-03 10:51:53 +0200176
Bartlomiej Zolnierkiewiczf4450612009-11-04 18:36:40 +0100177extern const struct rt2x00debug rt2800_rt2x00debug;
178
179int rt2800_rfkill_poll(struct rt2x00_dev *rt2x00dev);
Bartlomiej Zolnierkiewiczf4450612009-11-04 18:36:40 +0100180int rt2800_config_shared_key(struct rt2x00_dev *rt2x00dev,
181 struct rt2x00lib_crypto *crypto,
182 struct ieee80211_key_conf *key);
183int rt2800_config_pairwise_key(struct rt2x00_dev *rt2x00dev,
184 struct rt2x00lib_crypto *crypto,
185 struct ieee80211_key_conf *key);
Helmut Schaaa2b13282011-09-08 14:38:01 +0200186int rt2800_sta_add(struct rt2x00_dev *rt2x00dev, struct ieee80211_vif *vif,
187 struct ieee80211_sta *sta);
188int rt2800_sta_remove(struct rt2x00_dev *rt2x00dev, int wcid);
Bartlomiej Zolnierkiewiczf4450612009-11-04 18:36:40 +0100189void rt2800_config_filter(struct rt2x00_dev *rt2x00dev,
190 const unsigned int filter_flags);
191void rt2800_config_intf(struct rt2x00_dev *rt2x00dev, struct rt2x00_intf *intf,
192 struct rt2x00intf_conf *conf, const unsigned int flags);
Helmut Schaa02044642010-09-08 20:56:32 +0200193void rt2800_config_erp(struct rt2x00_dev *rt2x00dev, struct rt2x00lib_erp *erp,
194 u32 changed);
Bartlomiej Zolnierkiewiczf4450612009-11-04 18:36:40 +0100195void rt2800_config_ant(struct rt2x00_dev *rt2x00dev, struct antenna_setup *ant);
196void rt2800_config(struct rt2x00_dev *rt2x00dev,
197 struct rt2x00lib_conf *libconf,
198 const unsigned int flags);
199void rt2800_link_stats(struct rt2x00_dev *rt2x00dev, struct link_qual *qual);
200void rt2800_reset_tuner(struct rt2x00_dev *rt2x00dev, struct link_qual *qual);
201void rt2800_link_tuner(struct rt2x00_dev *rt2x00dev, struct link_qual *qual,
202 const u32 count);
Helmut Schaa9e33a352011-03-28 13:33:40 +0200203void rt2800_gain_calibration(struct rt2x00_dev *rt2x00dev);
John Li2e9c43d2012-02-16 21:40:57 +0800204void rt2800_vco_calibration(struct rt2x00_dev *rt2x00dev);
Bartlomiej Zolnierkiewiczf4450612009-11-04 18:36:40 +0100205
Ivo van Doornb9a07ae2010-08-23 19:55:22 +0200206int rt2800_enable_radio(struct rt2x00_dev *rt2x00dev);
207void rt2800_disable_radio(struct rt2x00_dev *rt2x00dev);
Bartlomiej Zolnierkiewiczfcf51542009-11-04 18:36:57 +0100208
Bartlomiej Zolnierkiewicz30e84032009-11-08 14:39:48 +0100209int rt2800_efuse_detect(struct rt2x00_dev *rt2x00dev);
210void rt2800_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev);
Gertjan van Wingerdead417a52012-09-03 03:25:51 +0200211
212int rt2800_probe_hw(struct rt2x00_dev *rt2x00dev);
Bartlomiej Zolnierkiewicz38bd7b82009-11-08 14:39:01 +0100213
Helmut Schaae7836192010-07-11 12:28:54 +0200214void rt2800_get_tkip_seq(struct ieee80211_hw *hw, u8 hw_key_idx, u32 *iv32,
215 u16 *iv16);
216int rt2800_set_rts_threshold(struct ieee80211_hw *hw, u32 value);
Eliad Peller8a3a3c82011-10-02 10:15:52 +0200217int rt2800_conf_tx(struct ieee80211_hw *hw,
218 struct ieee80211_vif *vif, u16 queue_idx,
Helmut Schaae7836192010-07-11 12:28:54 +0200219 const struct ieee80211_tx_queue_params *params);
Eliad Peller37a41b42011-09-21 14:06:11 +0300220u64 rt2800_get_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif);
Helmut Schaae7836192010-07-11 12:28:54 +0200221int rt2800_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
222 enum ieee80211_ampdu_mlme_action action,
Johannes Berg0b01f032011-01-18 13:51:05 +0100223 struct ieee80211_sta *sta, u16 tid, u16 *ssn,
224 u8 buf_size);
Helmut Schaa977206d2010-12-13 12:31:58 +0100225int rt2800_get_survey(struct ieee80211_hw *hw, int idx,
226 struct survey_info *survey);
Jakub Kicinskif7b395e2012-04-03 03:40:47 +0200227void rt2800_disable_wpdma(struct rt2x00_dev *rt2x00dev);
Bartlomiej Zolnierkiewicz2ce33992009-11-04 18:37:05 +0100228
Bartlomiej Zolnierkiewicz7ef5cc92009-11-04 18:35:32 +0100229#endif /* RT2800LIB_H */