blob: deb10b14157ba52e522d62bc6f22149da4adc6ba [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
Ivo van Doornf31c9a82010-07-11 12:30:37 +020046 int (*drv_write_firmware)(struct rt2x00_dev *rt2x00dev,
47 const u8 *data, const size_t len);
Gertjan van Wingerdee3a896b2010-06-03 10:52:04 +020048 int (*drv_init_registers)(struct rt2x00_dev *rt2x00dev);
Ivo van Doorn0c5879b2010-08-06 20:47:20 +020049 __le32 *(*drv_get_txwi)(struct queue_entry *entry);
Bartlomiej Zolnierkiewicz7ef5cc92009-11-04 18:35:32 +010050};
51
52static inline void rt2800_register_read(struct rt2x00_dev *rt2x00dev,
53 const unsigned int offset,
54 u32 *value)
55{
Ivo van Doorne7966432010-07-11 12:31:23 +020056 const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
Bartlomiej Zolnierkiewicz7ef5cc92009-11-04 18:35:32 +010057
58 rt2800ops->register_read(rt2x00dev, offset, value);
59}
60
Gertjan van Wingerde31a4cf12009-11-14 20:20:36 +010061static inline void rt2800_register_read_lock(struct rt2x00_dev *rt2x00dev,
62 const unsigned int offset,
63 u32 *value)
64{
Ivo van Doorne7966432010-07-11 12:31:23 +020065 const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
Gertjan van Wingerde31a4cf12009-11-14 20:20:36 +010066
67 rt2800ops->register_read_lock(rt2x00dev, offset, value);
68}
69
Bartlomiej Zolnierkiewicz7ef5cc92009-11-04 18:35:32 +010070static inline void rt2800_register_write(struct rt2x00_dev *rt2x00dev,
71 const unsigned int offset,
72 u32 value)
73{
Ivo van Doorne7966432010-07-11 12:31:23 +020074 const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
Bartlomiej Zolnierkiewicz7ef5cc92009-11-04 18:35:32 +010075
76 rt2800ops->register_write(rt2x00dev, offset, value);
77}
78
79static inline void rt2800_register_write_lock(struct rt2x00_dev *rt2x00dev,
80 const unsigned int offset,
81 u32 value)
82{
Ivo van Doorne7966432010-07-11 12:31:23 +020083 const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
Bartlomiej Zolnierkiewicz7ef5cc92009-11-04 18:35:32 +010084
85 rt2800ops->register_write_lock(rt2x00dev, offset, value);
86}
87
88static inline void rt2800_register_multiread(struct rt2x00_dev *rt2x00dev,
89 const unsigned int offset,
90 void *value, const u32 length)
91{
Ivo van Doorne7966432010-07-11 12:31:23 +020092 const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
Bartlomiej Zolnierkiewicz7ef5cc92009-11-04 18:35:32 +010093
94 rt2800ops->register_multiread(rt2x00dev, offset, value, length);
95}
96
97static inline void rt2800_register_multiwrite(struct rt2x00_dev *rt2x00dev,
98 const unsigned int offset,
99 const void *value,
100 const u32 length)
101{
Ivo van Doorne7966432010-07-11 12:31:23 +0200102 const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
Bartlomiej Zolnierkiewicz7ef5cc92009-11-04 18:35:32 +0100103
104 rt2800ops->register_multiwrite(rt2x00dev, offset, value, length);
105}
106
107static inline int rt2800_regbusy_read(struct rt2x00_dev *rt2x00dev,
108 const unsigned int offset,
109 const struct rt2x00_field32 field,
110 u32 *reg)
111{
Ivo van Doorne7966432010-07-11 12:31:23 +0200112 const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
Bartlomiej Zolnierkiewicz7ef5cc92009-11-04 18:35:32 +0100113
114 return rt2800ops->regbusy_read(rt2x00dev, offset, field, reg);
115}
116
Ivo van Doornf31c9a82010-07-11 12:30:37 +0200117static inline int rt2800_drv_write_firmware(struct rt2x00_dev *rt2x00dev,
118 const u8 *data, const size_t len)
119{
Ivo van Doorne7966432010-07-11 12:31:23 +0200120 const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
Ivo van Doornf31c9a82010-07-11 12:30:37 +0200121
122 return rt2800ops->drv_write_firmware(rt2x00dev, data, len);
123}
124
Gertjan van Wingerdee3a896b2010-06-03 10:52:04 +0200125static inline int rt2800_drv_init_registers(struct rt2x00_dev *rt2x00dev)
126{
Ivo van Doorne7966432010-07-11 12:31:23 +0200127 const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
Gertjan van Wingerdee3a896b2010-06-03 10:52:04 +0200128
129 return rt2800ops->drv_init_registers(rt2x00dev);
130}
131
Ivo van Doorn0c5879b2010-08-06 20:47:20 +0200132static inline __le32 *rt2800_drv_get_txwi(struct queue_entry *entry)
133{
134 const struct rt2800_ops *rt2800ops = entry->queue->rt2x00dev->ops->drv;
135
136 return rt2800ops->drv_get_txwi(entry);
137}
138
Bartlomiej Zolnierkiewicz89297422009-11-04 18:36:24 +0100139void rt2800_mcu_request(struct rt2x00_dev *rt2x00dev,
140 const u8 command, const u8 token,
141 const u8 arg0, const u8 arg1);
142
Ivo van Doornb9a07ae2010-08-23 19:55:22 +0200143int rt2800_wait_wpdma_ready(struct rt2x00_dev *rt2x00dev);
144
Ivo van Doornf31c9a82010-07-11 12:30:37 +0200145int rt2800_check_firmware(struct rt2x00_dev *rt2x00dev,
146 const u8 *data, const size_t len);
147int rt2800_load_firmware(struct rt2x00_dev *rt2x00dev,
148 const u8 *data, const size_t len);
149
Ivo van Doorn0c5879b2010-08-06 20:47:20 +0200150void rt2800_write_tx_data(struct queue_entry *entry,
151 struct txentry_desc *txdesc);
Ivo van Doorn74861922010-07-11 12:23:50 +0200152void rt2800_process_rxwi(struct queue_entry *entry, struct rxdone_entry_desc *txdesc);
Gertjan van Wingerde59679b92010-05-08 23:40:21 +0200153
Ivo van Doorn96481b22010-08-06 20:47:57 +0200154void rt2800_txdone(struct rt2x00_dev *rt2x00dev);
155
Gertjan van Wingerdef0194b22010-06-03 10:51:53 +0200156void rt2800_write_beacon(struct queue_entry *entry, struct txentry_desc *txdesc);
157
Bartlomiej Zolnierkiewiczf4450612009-11-04 18:36:40 +0100158extern const struct rt2x00debug rt2800_rt2x00debug;
159
160int rt2800_rfkill_poll(struct rt2x00_dev *rt2x00dev);
Bartlomiej Zolnierkiewiczf4450612009-11-04 18:36:40 +0100161int rt2800_config_shared_key(struct rt2x00_dev *rt2x00dev,
162 struct rt2x00lib_crypto *crypto,
163 struct ieee80211_key_conf *key);
164int rt2800_config_pairwise_key(struct rt2x00_dev *rt2x00dev,
165 struct rt2x00lib_crypto *crypto,
166 struct ieee80211_key_conf *key);
167void rt2800_config_filter(struct rt2x00_dev *rt2x00dev,
168 const unsigned int filter_flags);
169void rt2800_config_intf(struct rt2x00_dev *rt2x00dev, struct rt2x00_intf *intf,
170 struct rt2x00intf_conf *conf, const unsigned int flags);
171void rt2800_config_erp(struct rt2x00_dev *rt2x00dev, struct rt2x00lib_erp *erp);
172void rt2800_config_ant(struct rt2x00_dev *rt2x00dev, struct antenna_setup *ant);
173void rt2800_config(struct rt2x00_dev *rt2x00dev,
174 struct rt2x00lib_conf *libconf,
175 const unsigned int flags);
176void rt2800_link_stats(struct rt2x00_dev *rt2x00dev, struct link_qual *qual);
177void rt2800_reset_tuner(struct rt2x00_dev *rt2x00dev, struct link_qual *qual);
178void rt2800_link_tuner(struct rt2x00_dev *rt2x00dev, struct link_qual *qual,
179 const u32 count);
180
Ivo van Doornb9a07ae2010-08-23 19:55:22 +0200181int rt2800_enable_radio(struct rt2x00_dev *rt2x00dev);
182void rt2800_disable_radio(struct rt2x00_dev *rt2x00dev);
Bartlomiej Zolnierkiewiczfcf51542009-11-04 18:36:57 +0100183
Bartlomiej Zolnierkiewicz30e84032009-11-08 14:39:48 +0100184int rt2800_efuse_detect(struct rt2x00_dev *rt2x00dev);
185void rt2800_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev);
Bartlomiej Zolnierkiewicz38bd7b82009-11-08 14:39:01 +0100186int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev);
187int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev);
Bartlomiej Zolnierkiewicz4da2933f2009-11-08 14:39:32 +0100188int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev);
Bartlomiej Zolnierkiewicz38bd7b82009-11-08 14:39:01 +0100189
Helmut Schaae7836192010-07-11 12:28:54 +0200190void rt2800_get_tkip_seq(struct ieee80211_hw *hw, u8 hw_key_idx, u32 *iv32,
191 u16 *iv16);
192int rt2800_set_rts_threshold(struct ieee80211_hw *hw, u32 value);
193int rt2800_conf_tx(struct ieee80211_hw *hw, u16 queue_idx,
194 const struct ieee80211_tx_queue_params *params);
195u64 rt2800_get_tsf(struct ieee80211_hw *hw);
196int rt2800_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
197 enum ieee80211_ampdu_mlme_action action,
198 struct ieee80211_sta *sta, u16 tid, u16 *ssn);
Bartlomiej Zolnierkiewicz2ce33992009-11-04 18:37:05 +0100199
Bartlomiej Zolnierkiewicz7ef5cc92009-11-04 18:35:32 +0100200#endif /* RT2800LIB_H */