aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlwifi/iwl-io.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl-io.c')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-io.c53
1 files changed, 45 insertions, 8 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-io.c b/drivers/net/wireless/iwlwifi/iwl-io.c
index 081dd34d2387..66c873399aba 100644
--- a/drivers/net/wireless/iwlwifi/iwl-io.c
+++ b/drivers/net/wireless/iwlwifi/iwl-io.c
@@ -27,6 +27,7 @@
27 *****************************************************************************/ 27 *****************************************************************************/
28#include <linux/delay.h> 28#include <linux/delay.h>
29#include <linux/device.h> 29#include <linux/device.h>
30#include <linux/export.h>
30 31
31#include "iwl-io.h" 32#include "iwl-io.h"
32#include"iwl-csr.h" 33#include"iwl-csr.h"
@@ -52,6 +53,7 @@ void iwl_set_bit(struct iwl_trans *trans, u32 reg, u32 mask)
52 __iwl_set_bit(trans, reg, mask); 53 __iwl_set_bit(trans, reg, mask);
53 spin_unlock_irqrestore(&trans->reg_lock, flags); 54 spin_unlock_irqrestore(&trans->reg_lock, flags);
54} 55}
56EXPORT_SYMBOL_GPL(iwl_set_bit);
55 57
56void iwl_clear_bit(struct iwl_trans *trans, u32 reg, u32 mask) 58void iwl_clear_bit(struct iwl_trans *trans, u32 reg, u32 mask)
57{ 59{
@@ -61,6 +63,25 @@ void iwl_clear_bit(struct iwl_trans *trans, u32 reg, u32 mask)
61 __iwl_clear_bit(trans, reg, mask); 63 __iwl_clear_bit(trans, reg, mask);
62 spin_unlock_irqrestore(&trans->reg_lock, flags); 64 spin_unlock_irqrestore(&trans->reg_lock, flags);
63} 65}
66EXPORT_SYMBOL_GPL(iwl_clear_bit);
67
68void iwl_set_bits_mask(struct iwl_trans *trans, u32 reg, u32 mask, u32 value)
69{
70 unsigned long flags;
71 u32 v;
72
73#ifdef CONFIG_IWLWIFI_DEBUG
74 WARN_ON_ONCE(value & ~mask);
75#endif
76
77 spin_lock_irqsave(&trans->reg_lock, flags);
78 v = iwl_read32(trans, reg);
79 v &= ~mask;
80 v |= value;
81 iwl_write32(trans, reg, v);
82 spin_unlock_irqrestore(&trans->reg_lock, flags);
83}
84EXPORT_SYMBOL_GPL(iwl_set_bits_mask);
64 85
65int iwl_poll_bit(struct iwl_trans *trans, u32 addr, 86int iwl_poll_bit(struct iwl_trans *trans, u32 addr,
66 u32 bits, u32 mask, int timeout) 87 u32 bits, u32 mask, int timeout)
@@ -76,6 +97,7 @@ int iwl_poll_bit(struct iwl_trans *trans, u32 addr,
76 97
77 return -ETIMEDOUT; 98 return -ETIMEDOUT;
78} 99}
100EXPORT_SYMBOL_GPL(iwl_poll_bit);
79 101
80int iwl_grab_nic_access_silent(struct iwl_trans *trans) 102int iwl_grab_nic_access_silent(struct iwl_trans *trans)
81{ 103{
@@ -117,6 +139,7 @@ int iwl_grab_nic_access_silent(struct iwl_trans *trans)
117 139
118 return 0; 140 return 0;
119} 141}
142EXPORT_SYMBOL_GPL(iwl_grab_nic_access_silent);
120 143
121bool iwl_grab_nic_access(struct iwl_trans *trans) 144bool iwl_grab_nic_access(struct iwl_trans *trans)
122{ 145{
@@ -130,6 +153,7 @@ bool iwl_grab_nic_access(struct iwl_trans *trans)
130 153
131 return true; 154 return true;
132} 155}
156EXPORT_SYMBOL_GPL(iwl_grab_nic_access);
133 157
134void iwl_release_nic_access(struct iwl_trans *trans) 158void iwl_release_nic_access(struct iwl_trans *trans)
135{ 159{
@@ -144,6 +168,7 @@ void iwl_release_nic_access(struct iwl_trans *trans)
144 */ 168 */
145 mmiowb(); 169 mmiowb();
146} 170}
171EXPORT_SYMBOL_GPL(iwl_release_nic_access);
147 172
148u32 iwl_read_direct32(struct iwl_trans *trans, u32 reg) 173u32 iwl_read_direct32(struct iwl_trans *trans, u32 reg)
149{ 174{
@@ -158,6 +183,7 @@ u32 iwl_read_direct32(struct iwl_trans *trans, u32 reg)
158 183
159 return value; 184 return value;
160} 185}
186EXPORT_SYMBOL_GPL(iwl_read_direct32);
161 187
162void iwl_write_direct32(struct iwl_trans *trans, u32 reg, u32 value) 188void iwl_write_direct32(struct iwl_trans *trans, u32 reg, u32 value)
163{ 189{
@@ -170,6 +196,7 @@ void iwl_write_direct32(struct iwl_trans *trans, u32 reg, u32 value)
170 } 196 }
171 spin_unlock_irqrestore(&trans->reg_lock, flags); 197 spin_unlock_irqrestore(&trans->reg_lock, flags);
172} 198}
199EXPORT_SYMBOL_GPL(iwl_write_direct32);
173 200
174int iwl_poll_direct_bit(struct iwl_trans *trans, u32 addr, u32 mask, 201int iwl_poll_direct_bit(struct iwl_trans *trans, u32 addr, u32 mask,
175 int timeout) 202 int timeout)
@@ -185,6 +212,7 @@ int iwl_poll_direct_bit(struct iwl_trans *trans, u32 addr, u32 mask,
185 212
186 return -ETIMEDOUT; 213 return -ETIMEDOUT;
187} 214}
215EXPORT_SYMBOL_GPL(iwl_poll_direct_bit);
188 216
189static inline u32 __iwl_read_prph(struct iwl_trans *trans, u32 reg) 217static inline u32 __iwl_read_prph(struct iwl_trans *trans, u32 reg)
190{ 218{
@@ -211,6 +239,7 @@ u32 iwl_read_prph(struct iwl_trans *trans, u32 reg)
211 spin_unlock_irqrestore(&trans->reg_lock, flags); 239 spin_unlock_irqrestore(&trans->reg_lock, flags);
212 return val; 240 return val;
213} 241}
242EXPORT_SYMBOL_GPL(iwl_read_prph);
214 243
215void iwl_write_prph(struct iwl_trans *trans, u32 addr, u32 val) 244void iwl_write_prph(struct iwl_trans *trans, u32 addr, u32 val)
216{ 245{
@@ -223,6 +252,7 @@ void iwl_write_prph(struct iwl_trans *trans, u32 addr, u32 val)
223 } 252 }
224 spin_unlock_irqrestore(&trans->reg_lock, flags); 253 spin_unlock_irqrestore(&trans->reg_lock, flags);
225} 254}
255EXPORT_SYMBOL_GPL(iwl_write_prph);
226 256
227void iwl_set_bits_prph(struct iwl_trans *trans, u32 reg, u32 mask) 257void iwl_set_bits_prph(struct iwl_trans *trans, u32 reg, u32 mask)
228{ 258{
@@ -236,6 +266,7 @@ void iwl_set_bits_prph(struct iwl_trans *trans, u32 reg, u32 mask)
236 } 266 }
237 spin_unlock_irqrestore(&trans->reg_lock, flags); 267 spin_unlock_irqrestore(&trans->reg_lock, flags);
238} 268}
269EXPORT_SYMBOL_GPL(iwl_set_bits_prph);
239 270
240void iwl_set_bits_mask_prph(struct iwl_trans *trans, u32 reg, 271void iwl_set_bits_mask_prph(struct iwl_trans *trans, u32 reg,
241 u32 bits, u32 mask) 272 u32 bits, u32 mask)
@@ -250,6 +281,7 @@ void iwl_set_bits_mask_prph(struct iwl_trans *trans, u32 reg,
250 } 281 }
251 spin_unlock_irqrestore(&trans->reg_lock, flags); 282 spin_unlock_irqrestore(&trans->reg_lock, flags);
252} 283}
284EXPORT_SYMBOL_GPL(iwl_set_bits_mask_prph);
253 285
254void iwl_clear_bits_prph(struct iwl_trans *trans, u32 reg, u32 mask) 286void iwl_clear_bits_prph(struct iwl_trans *trans, u32 reg, u32 mask)
255{ 287{
@@ -264,9 +296,10 @@ void iwl_clear_bits_prph(struct iwl_trans *trans, u32 reg, u32 mask)
264 } 296 }
265 spin_unlock_irqrestore(&trans->reg_lock, flags); 297 spin_unlock_irqrestore(&trans->reg_lock, flags);
266} 298}
299EXPORT_SYMBOL_GPL(iwl_clear_bits_prph);
267 300
268void _iwl_read_targ_mem_words(struct iwl_trans *trans, u32 addr, 301void _iwl_read_targ_mem_dwords(struct iwl_trans *trans, u32 addr,
269 void *buf, int words) 302 void *buf, int dwords)
270{ 303{
271 unsigned long flags; 304 unsigned long flags;
272 int offs; 305 int offs;
@@ -275,24 +308,26 @@ void _iwl_read_targ_mem_words(struct iwl_trans *trans, u32 addr,
275 spin_lock_irqsave(&trans->reg_lock, flags); 308 spin_lock_irqsave(&trans->reg_lock, flags);
276 if (likely(iwl_grab_nic_access(trans))) { 309 if (likely(iwl_grab_nic_access(trans))) {
277 iwl_write32(trans, HBUS_TARG_MEM_RADDR, addr); 310 iwl_write32(trans, HBUS_TARG_MEM_RADDR, addr);
278 for (offs = 0; offs < words; offs++) 311 for (offs = 0; offs < dwords; offs++)
279 vals[offs] = iwl_read32(trans, HBUS_TARG_MEM_RDAT); 312 vals[offs] = iwl_read32(trans, HBUS_TARG_MEM_RDAT);
280 iwl_release_nic_access(trans); 313 iwl_release_nic_access(trans);
281 } 314 }
282 spin_unlock_irqrestore(&trans->reg_lock, flags); 315 spin_unlock_irqrestore(&trans->reg_lock, flags);
283} 316}
317EXPORT_SYMBOL_GPL(_iwl_read_targ_mem_dwords);
284 318
285u32 iwl_read_targ_mem(struct iwl_trans *trans, u32 addr) 319u32 iwl_read_targ_mem(struct iwl_trans *trans, u32 addr)
286{ 320{
287 u32 value; 321 u32 value;
288 322
289 _iwl_read_targ_mem_words(trans, addr, &value, 1); 323 _iwl_read_targ_mem_dwords(trans, addr, &value, 1);
290 324
291 return value; 325 return value;
292} 326}
327EXPORT_SYMBOL_GPL(iwl_read_targ_mem);
293 328
294int _iwl_write_targ_mem_words(struct iwl_trans *trans, u32 addr, 329int _iwl_write_targ_mem_dwords(struct iwl_trans *trans, u32 addr,
295 void *buf, int words) 330 void *buf, int dwords)
296{ 331{
297 unsigned long flags; 332 unsigned long flags;
298 int offs, result = 0; 333 int offs, result = 0;
@@ -301,7 +336,7 @@ int _iwl_write_targ_mem_words(struct iwl_trans *trans, u32 addr,
301 spin_lock_irqsave(&trans->reg_lock, flags); 336 spin_lock_irqsave(&trans->reg_lock, flags);
302 if (likely(iwl_grab_nic_access(trans))) { 337 if (likely(iwl_grab_nic_access(trans))) {
303 iwl_write32(trans, HBUS_TARG_MEM_WADDR, addr); 338 iwl_write32(trans, HBUS_TARG_MEM_WADDR, addr);
304 for (offs = 0; offs < words; offs++) 339 for (offs = 0; offs < dwords; offs++)
305 iwl_write32(trans, HBUS_TARG_MEM_WDAT, vals[offs]); 340 iwl_write32(trans, HBUS_TARG_MEM_WDAT, vals[offs]);
306 iwl_release_nic_access(trans); 341 iwl_release_nic_access(trans);
307 } else 342 } else
@@ -310,8 +345,10 @@ int _iwl_write_targ_mem_words(struct iwl_trans *trans, u32 addr,
310 345
311 return result; 346 return result;
312} 347}
348EXPORT_SYMBOL_GPL(_iwl_write_targ_mem_dwords);
313 349
314int iwl_write_targ_mem(struct iwl_trans *trans, u32 addr, u32 val) 350int iwl_write_targ_mem(struct iwl_trans *trans, u32 addr, u32 val)
315{ 351{
316 return _iwl_write_targ_mem_words(trans, addr, &val, 1); 352 return _iwl_write_targ_mem_dwords(trans, addr, &val, 1);
317} 353}
354EXPORT_SYMBOL_GPL(iwl_write_targ_mem);