rt2800lib.h 8.12 KB
Newer Older
1
/*
2 3
	Copyright (C) 2010 Willow Garage <http://www.willowgarage.com>
	Copyright (C) 2010 Ivo van Doorn <IvDoorn@gmail.com>
4 5 6 7 8 9 10 11 12 13 14 15 16
	Copyright (C) 2009 Bartlomiej Zolnierkiewicz

	This program is free software; you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation; either version 2 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
17
	along with this program; if not, see <http://www.gnu.org/licenses/>.
18 19 20 21 22 23 24 25
 */

#ifndef RT2800LIB_H
#define RT2800LIB_H

struct rt2800_ops {
	void (*register_read)(struct rt2x00_dev *rt2x00dev,
			      const unsigned int offset, u32 *value);
26 27
	void (*register_read_lock)(struct rt2x00_dev *rt2x00dev,
				   const unsigned int offset, u32 *value);
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
	void (*register_write)(struct rt2x00_dev *rt2x00dev,
			       const unsigned int offset, u32 value);
	void (*register_write_lock)(struct rt2x00_dev *rt2x00dev,
				    const unsigned int offset, u32 value);

	void (*register_multiread)(struct rt2x00_dev *rt2x00dev,
				   const unsigned int offset,
				   void *value, const u32 length);
	void (*register_multiwrite)(struct rt2x00_dev *rt2x00dev,
				    const unsigned int offset,
				    const void *value, const u32 length);

	int (*regbusy_read)(struct rt2x00_dev *rt2x00dev,
			    const unsigned int offset,
			    const struct rt2x00_field32 field, u32 *reg);
43

44
	int (*read_eeprom)(struct rt2x00_dev *rt2x00dev);
45 46
	bool (*hwcrypt_disabled)(struct rt2x00_dev *rt2x00dev);

47 48
	int (*drv_write_firmware)(struct rt2x00_dev *rt2x00dev,
				  const u8 *data, const size_t len);
49
	int (*drv_init_registers)(struct rt2x00_dev *rt2x00dev);
50
	__le32 *(*drv_get_txwi)(struct queue_entry *entry);
51 52 53 54 55 56
};

static inline void rt2800_register_read(struct rt2x00_dev *rt2x00dev,
					const unsigned int offset,
					u32 *value)
{
57
	const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
58 59 60 61

	rt2800ops->register_read(rt2x00dev, offset, value);
}

62 63 64 65
static inline void rt2800_register_read_lock(struct rt2x00_dev *rt2x00dev,
					     const unsigned int offset,
					     u32 *value)
{
66
	const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
67 68 69 70

	rt2800ops->register_read_lock(rt2x00dev, offset, value);
}

71 72 73 74
static inline void rt2800_register_write(struct rt2x00_dev *rt2x00dev,
					 const unsigned int offset,
					 u32 value)
{
75
	const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
76 77 78 79 80 81 82 83

	rt2800ops->register_write(rt2x00dev, offset, value);
}

static inline void rt2800_register_write_lock(struct rt2x00_dev *rt2x00dev,
					      const unsigned int offset,
					      u32 value)
{
84
	const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
85 86 87 88 89 90 91 92

	rt2800ops->register_write_lock(rt2x00dev, offset, value);
}

static inline void rt2800_register_multiread(struct rt2x00_dev *rt2x00dev,
					     const unsigned int offset,
					     void *value, const u32 length)
{
93
	const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
94 95 96 97 98 99 100 101 102

	rt2800ops->register_multiread(rt2x00dev, offset, value, length);
}

static inline void rt2800_register_multiwrite(struct rt2x00_dev *rt2x00dev,
					      const unsigned int offset,
					      const void *value,
					      const u32 length)
{
103
	const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
104 105 106 107 108 109 110 111 112

	rt2800ops->register_multiwrite(rt2x00dev, offset, value, length);
}

static inline int rt2800_regbusy_read(struct rt2x00_dev *rt2x00dev,
				      const unsigned int offset,
				      const struct rt2x00_field32 field,
				      u32 *reg)
{
113
	const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
114 115 116 117

	return rt2800ops->regbusy_read(rt2x00dev, offset, field, reg);
}

118
static inline int rt2800_read_eeprom(struct rt2x00_dev *rt2x00dev)
119 120 121
{
	const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;

122
	return rt2800ops->read_eeprom(rt2x00dev);
123 124 125 126 127 128 129 130 131
}

static inline bool rt2800_hwcrypt_disabled(struct rt2x00_dev *rt2x00dev)
{
	const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;

	return rt2800ops->hwcrypt_disabled(rt2x00dev);
}

132 133 134
static inline int rt2800_drv_write_firmware(struct rt2x00_dev *rt2x00dev,
					    const u8 *data, const size_t len)
{
135
	const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
136 137 138 139

	return rt2800ops->drv_write_firmware(rt2x00dev, data, len);
}

140 141
static inline int rt2800_drv_init_registers(struct rt2x00_dev *rt2x00dev)
{
142
	const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
143 144 145 146

	return rt2800ops->drv_init_registers(rt2x00dev);
}

147 148 149 150 151 152 153
static inline __le32 *rt2800_drv_get_txwi(struct queue_entry *entry)
{
	const struct rt2800_ops *rt2800ops = entry->queue->rt2x00dev->ops->drv;

	return rt2800ops->drv_get_txwi(entry);
}

154 155 156 157
void rt2800_mcu_request(struct rt2x00_dev *rt2x00dev,
			const u8 command, const u8 token,
			const u8 arg0, const u8 arg1);

158
int rt2800_wait_csr_ready(struct rt2x00_dev *rt2x00dev);
159 160
int rt2800_wait_wpdma_ready(struct rt2x00_dev *rt2x00dev);

161 162 163 164 165
int rt2800_check_firmware(struct rt2x00_dev *rt2x00dev,
			  const u8 *data, const size_t len);
int rt2800_load_firmware(struct rt2x00_dev *rt2x00dev,
			 const u8 *data, const size_t len);

166 167
void rt2800_write_tx_data(struct queue_entry *entry,
			  struct txentry_desc *txdesc);
168
void rt2800_process_rxwi(struct queue_entry *entry, struct rxdone_entry_desc *txdesc);
169

170
void rt2800_txdone_entry(struct queue_entry *entry, u32 status, __le32* txwi);
171

172
void rt2800_write_beacon(struct queue_entry *entry, struct txentry_desc *txdesc);
173
void rt2800_clear_beacon(struct queue_entry *entry);
174

175 176 177 178 179 180 181 182 183
extern const struct rt2x00debug rt2800_rt2x00debug;

int rt2800_rfkill_poll(struct rt2x00_dev *rt2x00dev);
int rt2800_config_shared_key(struct rt2x00_dev *rt2x00dev,
			     struct rt2x00lib_crypto *crypto,
			     struct ieee80211_key_conf *key);
int rt2800_config_pairwise_key(struct rt2x00_dev *rt2x00dev,
			       struct rt2x00lib_crypto *crypto,
			       struct ieee80211_key_conf *key);
184 185
int rt2800_sta_add(struct rt2x00_dev *rt2x00dev, struct ieee80211_vif *vif,
		   struct ieee80211_sta *sta);
186
int rt2800_sta_remove(struct rt2x00_dev *rt2x00dev, struct ieee80211_sta *sta);
187 188 189 190
void rt2800_config_filter(struct rt2x00_dev *rt2x00dev,
			  const unsigned int filter_flags);
void rt2800_config_intf(struct rt2x00_dev *rt2x00dev, struct rt2x00_intf *intf,
			struct rt2x00intf_conf *conf, const unsigned int flags);
191 192
void rt2800_config_erp(struct rt2x00_dev *rt2x00dev, struct rt2x00lib_erp *erp,
		       u32 changed);
193 194 195 196 197 198 199 200
void rt2800_config_ant(struct rt2x00_dev *rt2x00dev, struct antenna_setup *ant);
void rt2800_config(struct rt2x00_dev *rt2x00dev,
		   struct rt2x00lib_conf *libconf,
		   const unsigned int flags);
void rt2800_link_stats(struct rt2x00_dev *rt2x00dev, struct link_qual *qual);
void rt2800_reset_tuner(struct rt2x00_dev *rt2x00dev, struct link_qual *qual);
void rt2800_link_tuner(struct rt2x00_dev *rt2x00dev, struct link_qual *qual,
		       const u32 count);
201
void rt2800_gain_calibration(struct rt2x00_dev *rt2x00dev);
John Li's avatar
John Li committed
202
void rt2800_vco_calibration(struct rt2x00_dev *rt2x00dev);
203

204 205
int rt2800_enable_radio(struct rt2x00_dev *rt2x00dev);
void rt2800_disable_radio(struct rt2x00_dev *rt2x00dev);
206

207
int rt2800_efuse_detect(struct rt2x00_dev *rt2x00dev);
208
int rt2800_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev);
209 210

int rt2800_probe_hw(struct rt2x00_dev *rt2x00dev);
211

212 213 214
void rt2800_get_key_seq(struct ieee80211_hw *hw,
			struct ieee80211_key_conf *key,
			struct ieee80211_key_seq *seq);
215
int rt2800_set_rts_threshold(struct ieee80211_hw *hw, u32 value);
216 217
int rt2800_conf_tx(struct ieee80211_hw *hw,
		   struct ieee80211_vif *vif, u16 queue_idx,
218
		   const struct ieee80211_tx_queue_params *params);
219
u64 rt2800_get_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif);
220
int rt2800_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
221
			struct ieee80211_ampdu_params *params);
222 223
int rt2800_get_survey(struct ieee80211_hw *hw, int idx,
		      struct survey_info *survey);
224
void rt2800_disable_wpdma(struct rt2x00_dev *rt2x00dev);
225

226 227 228 229
void rt2800_get_txwi_rxwi_size(struct rt2x00_dev *rt2x00dev,
			       unsigned short *txwi_size,
			       unsigned short *rxwi_size);

230
#endif /* RT2800LIB_H */