blob: 8f975180727fdf909226db9faa787677ccc220dc [file] [log] [blame]
Bartlomiej Zolnierkiewicz7ef5cc92009-11-04 18:35:32 +01001/*
2 Copyright (C) 2009 Bartlomiej Zolnierkiewicz
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the
16 Free Software Foundation, Inc.,
17 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 */
19
20#ifndef RT2800LIB_H
21#define RT2800LIB_H
22
23struct rt2800_ops {
24 void (*register_read)(struct rt2x00_dev *rt2x00dev,
25 const unsigned int offset, u32 *value);
Gertjan van Wingerde31a4cf12009-11-14 20:20:36 +010026 void (*register_read_lock)(struct rt2x00_dev *rt2x00dev,
27 const unsigned int offset, u32 *value);
Bartlomiej Zolnierkiewicz7ef5cc92009-11-04 18:35:32 +010028 void (*register_write)(struct rt2x00_dev *rt2x00dev,
29 const unsigned int offset, u32 value);
30 void (*register_write_lock)(struct rt2x00_dev *rt2x00dev,
31 const unsigned int offset, u32 value);
32
33 void (*register_multiread)(struct rt2x00_dev *rt2x00dev,
34 const unsigned int offset,
35 void *value, const u32 length);
36 void (*register_multiwrite)(struct rt2x00_dev *rt2x00dev,
37 const unsigned int offset,
38 const void *value, const u32 length);
39
40 int (*regbusy_read)(struct rt2x00_dev *rt2x00dev,
41 const unsigned int offset,
42 const struct rt2x00_field32 field, u32 *reg);
Gertjan van Wingerdee3a896b2010-06-03 10:52:04 +020043
Ivo van Doornf31c9a82010-07-11 12:30:37 +020044 int (*drv_write_firmware)(struct rt2x00_dev *rt2x00dev,
45 const u8 *data, const size_t len);
Gertjan van Wingerdee3a896b2010-06-03 10:52:04 +020046 int (*drv_init_registers)(struct rt2x00_dev *rt2x00dev);
Ivo van Doorn0c5879b2010-08-06 20:47:20 +020047 __le32 *(*drv_get_txwi)(struct queue_entry *entry);
Bartlomiej Zolnierkiewicz7ef5cc92009-11-04 18:35:32 +010048};
49
50static inline void rt2800_register_read(struct rt2x00_dev *rt2x00dev,
51 const unsigned int offset,
52 u32 *value)
53{
Ivo van Doorne7966432010-07-11 12:31:23 +020054 const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
Bartlomiej Zolnierkiewicz7ef5cc92009-11-04 18:35:32 +010055
56 rt2800ops->register_read(rt2x00dev, offset, value);
57}
58
Gertjan van Wingerde31a4cf12009-11-14 20:20:36 +010059static inline void rt2800_register_read_lock(struct rt2x00_dev *rt2x00dev,
60 const unsigned int offset,
61 u32 *value)
62{
Ivo van Doorne7966432010-07-11 12:31:23 +020063 const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
Gertjan van Wingerde31a4cf12009-11-14 20:20:36 +010064
65 rt2800ops->register_read_lock(rt2x00dev, offset, value);
66}
67
Bartlomiej Zolnierkiewicz7ef5cc92009-11-04 18:35:32 +010068static inline void rt2800_register_write(struct rt2x00_dev *rt2x00dev,
69 const unsigned int offset,
70 u32 value)
71{
Ivo van Doorne7966432010-07-11 12:31:23 +020072 const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
Bartlomiej Zolnierkiewicz7ef5cc92009-11-04 18:35:32 +010073
74 rt2800ops->register_write(rt2x00dev, offset, value);
75}
76
77static inline void rt2800_register_write_lock(struct rt2x00_dev *rt2x00dev,
78 const unsigned int offset,
79 u32 value)
80{
Ivo van Doorne7966432010-07-11 12:31:23 +020081 const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
Bartlomiej Zolnierkiewicz7ef5cc92009-11-04 18:35:32 +010082
83 rt2800ops->register_write_lock(rt2x00dev, offset, value);
84}
85
86static inline void rt2800_register_multiread(struct rt2x00_dev *rt2x00dev,
87 const unsigned int offset,
88 void *value, const u32 length)
89{
Ivo van Doorne7966432010-07-11 12:31:23 +020090 const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
Bartlomiej Zolnierkiewicz7ef5cc92009-11-04 18:35:32 +010091
92 rt2800ops->register_multiread(rt2x00dev, offset, value, length);
93}
94
95static inline void rt2800_register_multiwrite(struct rt2x00_dev *rt2x00dev,
96 const unsigned int offset,
97 const void *value,
98 const u32 length)
99{
Ivo van Doorne7966432010-07-11 12:31:23 +0200100 const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
Bartlomiej Zolnierkiewicz7ef5cc92009-11-04 18:35:32 +0100101
102 rt2800ops->register_multiwrite(rt2x00dev, offset, value, length);
103}
104
105static inline int rt2800_regbusy_read(struct rt2x00_dev *rt2x00dev,
106 const unsigned int offset,
107 const struct rt2x00_field32 field,
108 u32 *reg)
109{
Ivo van Doorne7966432010-07-11 12:31:23 +0200110 const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
Bartlomiej Zolnierkiewicz7ef5cc92009-11-04 18:35:32 +0100111
112 return rt2800ops->regbusy_read(rt2x00dev, offset, field, reg);
113}
114
Ivo van Doornf31c9a82010-07-11 12:30:37 +0200115static inline int rt2800_drv_write_firmware(struct rt2x00_dev *rt2x00dev,
116 const u8 *data, const size_t len)
117{
Ivo van Doorne7966432010-07-11 12:31:23 +0200118 const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
Ivo van Doornf31c9a82010-07-11 12:30:37 +0200119
120 return rt2800ops->drv_write_firmware(rt2x00dev, data, len);
121}
122
Gertjan van Wingerdee3a896b2010-06-03 10:52:04 +0200123static inline int rt2800_drv_init_registers(struct rt2x00_dev *rt2x00dev)
124{
Ivo van Doorne7966432010-07-11 12:31:23 +0200125 const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
Gertjan van Wingerdee3a896b2010-06-03 10:52:04 +0200126
127 return rt2800ops->drv_init_registers(rt2x00dev);
128}
129
Ivo van Doorn0c5879b2010-08-06 20:47:20 +0200130static inline __le32 *rt2800_drv_get_txwi(struct queue_entry *entry)
131{
132 const struct rt2800_ops *rt2800ops = entry->queue->rt2x00dev->ops->drv;
133
134 return rt2800ops->drv_get_txwi(entry);
135}
136
Bartlomiej Zolnierkiewicz89297422009-11-04 18:36:24 +0100137void rt2800_mcu_request(struct rt2x00_dev *rt2x00dev,
138 const u8 command, const u8 token,
139 const u8 arg0, const u8 arg1);
140
Ivo van Doornf31c9a82010-07-11 12:30:37 +0200141int rt2800_check_firmware(struct rt2x00_dev *rt2x00dev,
142 const u8 *data, const size_t len);
143int rt2800_load_firmware(struct rt2x00_dev *rt2x00dev,
144 const u8 *data, const size_t len);
145
Ivo van Doorn0c5879b2010-08-06 20:47:20 +0200146void rt2800_write_tx_data(struct queue_entry *entry,
147 struct txentry_desc *txdesc);
Ivo van Doorn74861922010-07-11 12:23:50 +0200148void rt2800_process_rxwi(struct queue_entry *entry, struct rxdone_entry_desc *txdesc);
Gertjan van Wingerde59679b92010-05-08 23:40:21 +0200149
Gertjan van Wingerdef0194b22010-06-03 10:51:53 +0200150void rt2800_write_beacon(struct queue_entry *entry, struct txentry_desc *txdesc);
151
Bartlomiej Zolnierkiewiczf4450612009-11-04 18:36:40 +0100152extern const struct rt2x00debug rt2800_rt2x00debug;
153
154int rt2800_rfkill_poll(struct rt2x00_dev *rt2x00dev);
Bartlomiej Zolnierkiewiczf4450612009-11-04 18:36:40 +0100155int rt2800_config_shared_key(struct rt2x00_dev *rt2x00dev,
156 struct rt2x00lib_crypto *crypto,
157 struct ieee80211_key_conf *key);
158int rt2800_config_pairwise_key(struct rt2x00_dev *rt2x00dev,
159 struct rt2x00lib_crypto *crypto,
160 struct ieee80211_key_conf *key);
161void rt2800_config_filter(struct rt2x00_dev *rt2x00dev,
162 const unsigned int filter_flags);
163void rt2800_config_intf(struct rt2x00_dev *rt2x00dev, struct rt2x00_intf *intf,
164 struct rt2x00intf_conf *conf, const unsigned int flags);
165void rt2800_config_erp(struct rt2x00_dev *rt2x00dev, struct rt2x00lib_erp *erp);
166void rt2800_config_ant(struct rt2x00_dev *rt2x00dev, struct antenna_setup *ant);
167void rt2800_config(struct rt2x00_dev *rt2x00dev,
168 struct rt2x00lib_conf *libconf,
169 const unsigned int flags);
170void rt2800_link_stats(struct rt2x00_dev *rt2x00dev, struct link_qual *qual);
171void rt2800_reset_tuner(struct rt2x00_dev *rt2x00dev, struct link_qual *qual);
172void rt2800_link_tuner(struct rt2x00_dev *rt2x00dev, struct link_qual *qual,
173 const u32 count);
174
Bartlomiej Zolnierkiewiczfcf51542009-11-04 18:36:57 +0100175int rt2800_init_registers(struct rt2x00_dev *rt2x00dev);
176int rt2800_init_bbp(struct rt2x00_dev *rt2x00dev);
177int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev);
Gertjan van Wingerde67a4c1e2009-12-30 11:36:32 +0100178int rt2800_wait_wpdma_ready(struct rt2x00_dev *rt2x00dev);
Bartlomiej Zolnierkiewiczfcf51542009-11-04 18:36:57 +0100179
Bartlomiej Zolnierkiewicz30e84032009-11-08 14:39:48 +0100180int rt2800_efuse_detect(struct rt2x00_dev *rt2x00dev);
181void rt2800_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev);
Bartlomiej Zolnierkiewicz38bd7b82009-11-08 14:39:01 +0100182int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev);
183int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev);
Bartlomiej Zolnierkiewicz4da2933f2009-11-08 14:39:32 +0100184int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev);
Bartlomiej Zolnierkiewicz38bd7b82009-11-08 14:39:01 +0100185
Helmut Schaae7836192010-07-11 12:28:54 +0200186void rt2800_get_tkip_seq(struct ieee80211_hw *hw, u8 hw_key_idx, u32 *iv32,
187 u16 *iv16);
188int rt2800_set_rts_threshold(struct ieee80211_hw *hw, u32 value);
189int rt2800_conf_tx(struct ieee80211_hw *hw, u16 queue_idx,
190 const struct ieee80211_tx_queue_params *params);
191u64 rt2800_get_tsf(struct ieee80211_hw *hw);
192int rt2800_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
193 enum ieee80211_ampdu_mlme_action action,
194 struct ieee80211_sta *sta, u16 tid, u16 *ssn);
Bartlomiej Zolnierkiewicz2ce33992009-11-04 18:37:05 +0100195
Bartlomiej Zolnierkiewicz7ef5cc92009-11-04 18:35:32 +0100196#endif /* RT2800LIB_H */