iwl-io.h 13.7 KB
Newer Older
Z
Zhu Yi 已提交
1 2
/******************************************************************************
 *
3
 * Copyright(c) 2003 - 2009 Intel Corporation. All rights reserved.
Z
Zhu Yi 已提交
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
 *
 * Portions of this file are derived from the ipw3945 project.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of version 2 of the GNU General Public License as
 * published by the Free Software Foundation.
 *
 * 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 along with
 * this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
 *
 * The full GNU General Public License is included in this distribution in the
 * file called LICENSE.
 *
 * Contact Information:
24
 *  Intel Linux Wireless <ilw@linux.intel.com>
Z
Zhu Yi 已提交
25 26 27 28
 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
 *
 *****************************************************************************/

29 30
#ifndef __iwl_io_h__
#define __iwl_io_h__
Z
Zhu Yi 已提交
31 32 33

#include <linux/io.h>

34
#include "iwl-debug.h"
Z
Zhu Yi 已提交
35 36 37 38 39 40 41 42 43 44

/*
 * IO, register, and NIC memory access functions
 *
 * NOTE on naming convention and macro usage for these
 *
 * A single _ prefix before a an access function means that no state
 * check or debug information is printed when that function is called.
 *
 * A double __ prefix before an access function means that state is checked
45 46
 * and the current line number and caller function name are printed in addition
 * to any other debug output.
Z
Zhu Yi 已提交
47 48
 *
 * The non-prefixed name is the #define that maps the caller into a
49 50
 * #define that provides the caller's name and __LINE__ to the double
 * prefix version.
Z
Zhu Yi 已提交
51 52 53
 *
 * If you wish to call the function without any debug or state checking,
 * you should use the single _ prefix version (as is used by dependent IO
54 55
 * routines, for example _iwl_read_direct32 calls the non-check version of
 * _iwl_read32.)
Z
Zhu Yi 已提交
56 57
 *
 * These declarations are *extremely* useful in quickly isolating code deltas
T
Tomas Winkler 已提交
58
 * which result in misconfiguration of the hardware I/O.  In combination with
Z
Zhu Yi 已提交
59 60 61 62 63
 * git-bisect and the IO debug level you can quickly determine the specific
 * commit which breaks the IO sequence to the hardware.
 *
 */

64
#define _iwl_write32(priv, ofs, val) iowrite32((val), (priv)->hw_base + (ofs))
65
#ifdef CONFIG_IWLWIFI_DEBUG
66
static inline void __iwl_write32(const char *f, u32 l, struct iwl_priv *priv,
Z
Zhu Yi 已提交
67 68
				 u32 ofs, u32 val)
{
69
	IWL_DEBUG_IO(priv, "write32(0x%08X, 0x%08X) - %s %d\n", ofs, val, f, l);
70
	_iwl_write32(priv, ofs, val);
Z
Zhu Yi 已提交
71
}
72 73
#define iwl_write32(priv, ofs, val) \
	__iwl_write32(__FILE__, __LINE__, priv, ofs, val)
Z
Zhu Yi 已提交
74
#else
75
#define iwl_write32(priv, ofs, val) _iwl_write32(priv, ofs, val)
Z
Zhu Yi 已提交
76 77
#endif

78
#define _iwl_read32(priv, ofs) ioread32((priv)->hw_base + (ofs))
79
#ifdef CONFIG_IWLWIFI_DEBUG
80
static inline u32 __iwl_read32(char *f, u32 l, struct iwl_priv *priv, u32 ofs)
Z
Zhu Yi 已提交
81
{
82
	IWL_DEBUG_IO(priv, "read_direct32(0x%08X) - %s %d\n", ofs, f, l);
83
	return _iwl_read32(priv, ofs);
Z
Zhu Yi 已提交
84
}
85
#define iwl_read32(priv, ofs) __iwl_read32(__FILE__, __LINE__, priv, ofs)
Z
Zhu Yi 已提交
86
#else
87
#define iwl_read32(p, o) _iwl_read32(p, o)
Z
Zhu Yi 已提交
88 89
#endif

90
#define IWL_POLL_INTERVAL 10	/* microseconds */
91
static inline int _iwl_poll_bit(struct iwl_priv *priv, u32 addr,
Z
Zhu Yi 已提交
92 93
				u32 bits, u32 mask, int timeout)
{
94
	int t = 0;
Z
Zhu Yi 已提交
95 96

	do {
97
		if ((_iwl_read32(priv, addr) & mask) == (bits & mask))
98 99 100 101
			return t;
		udelay(IWL_POLL_INTERVAL);
		t += IWL_POLL_INTERVAL;
	} while (t < timeout);
Z
Zhu Yi 已提交
102 103 104

	return -ETIMEDOUT;
}
105
#ifdef CONFIG_IWLWIFI_DEBUG
106
static inline int __iwl_poll_bit(const char *f, u32 l,
107
				 struct iwl_priv *priv, u32 addr,
Z
Zhu Yi 已提交
108 109
				 u32 bits, u32 mask, int timeout)
{
110
	int ret = _iwl_poll_bit(priv, addr, bits, mask, timeout);
111
	IWL_DEBUG_IO(priv, "poll_bit(0x%08X, 0x%08X, 0x%08X) - %s- %s %d\n",
112
		     addr, bits, mask,
113
		     unlikely(ret  == -ETIMEDOUT) ? "timeout" : "", f, l);
114
	return ret;
Z
Zhu Yi 已提交
115
}
116 117
#define iwl_poll_bit(priv, addr, bits, mask, timeout) \
	__iwl_poll_bit(__FILE__, __LINE__, priv, addr, bits, mask, timeout)
Z
Zhu Yi 已提交
118
#else
119
#define iwl_poll_bit(p, a, b, m, t) _iwl_poll_bit(p, a, b, m, t)
Z
Zhu Yi 已提交
120 121
#endif

122
static inline void _iwl_set_bit(struct iwl_priv *priv, u32 reg, u32 mask)
Z
Zhu Yi 已提交
123
{
124
	_iwl_write32(priv, reg, _iwl_read32(priv, reg) | mask);
Z
Zhu Yi 已提交
125
}
126
#ifdef CONFIG_IWLWIFI_DEBUG
127
static inline void __iwl_set_bit(const char *f, u32 l,
128
				 struct iwl_priv *priv, u32 reg, u32 mask)
Z
Zhu Yi 已提交
129
{
130
	u32 val = _iwl_read32(priv, reg) | mask;
131
	IWL_DEBUG_IO(priv, "set_bit(0x%08X, 0x%08X) = 0x%08X\n", reg, mask, val);
132
	_iwl_write32(priv, reg, val);
Z
Zhu Yi 已提交
133
}
M
Mohamed Abbas 已提交
134 135 136 137 138 139 140 141
static inline void iwl_set_bit(struct iwl_priv *p, u32 r, u32 m)
{
	unsigned long reg_flags;

	spin_lock_irqsave(&p->reg_lock, reg_flags);
	__iwl_set_bit(__FILE__, __LINE__, p, r, m);
	spin_unlock_irqrestore(&p->reg_lock, reg_flags);
}
Z
Zhu Yi 已提交
142
#else
M
Mohamed Abbas 已提交
143 144 145 146 147 148 149 150
static inline void iwl_set_bit(struct iwl_priv *p, u32 r, u32 m)
{
	unsigned long reg_flags;

	spin_lock_irqsave(&p->reg_lock, reg_flags);
	_iwl_set_bit(p, r, m);
	spin_unlock_irqrestore(&p->reg_lock, reg_flags);
}
Z
Zhu Yi 已提交
151 152
#endif

153
static inline void _iwl_clear_bit(struct iwl_priv *priv, u32 reg, u32 mask)
Z
Zhu Yi 已提交
154
{
155
	_iwl_write32(priv, reg, _iwl_read32(priv, reg) & ~mask);
Z
Zhu Yi 已提交
156
}
157
#ifdef CONFIG_IWLWIFI_DEBUG
158
static inline void __iwl_clear_bit(const char *f, u32 l,
159
				   struct iwl_priv *priv, u32 reg, u32 mask)
Z
Zhu Yi 已提交
160
{
161
	u32 val = _iwl_read32(priv, reg) & ~mask;
162
	IWL_DEBUG_IO(priv, "clear_bit(0x%08X, 0x%08X) = 0x%08X\n", reg, mask, val);
163
	_iwl_write32(priv, reg, val);
Z
Zhu Yi 已提交
164
}
M
Mohamed Abbas 已提交
165 166 167 168 169 170 171 172
static inline void iwl_clear_bit(struct iwl_priv *p, u32 r, u32 m)
{
	unsigned long reg_flags;

	spin_lock_irqsave(&p->reg_lock, reg_flags);
	__iwl_clear_bit(__FILE__, __LINE__, p, r, m);
	spin_unlock_irqrestore(&p->reg_lock, reg_flags);
}
Z
Zhu Yi 已提交
173
#else
M
Mohamed Abbas 已提交
174 175 176 177 178 179 180 181
static inline void iwl_clear_bit(struct iwl_priv *p, u32 r, u32 m)
{
	unsigned long reg_flags;

	spin_lock_irqsave(&p->reg_lock, reg_flags);
	_iwl_clear_bit(p, r, m);
	spin_unlock_irqrestore(&p->reg_lock, reg_flags);
}
Z
Zhu Yi 已提交
182 183
#endif

184
static inline int _iwl_grab_nic_access(struct iwl_priv *priv)
Z
Zhu Yi 已提交
185
{
186
	int ret;
187
	u32 val;
M
Mohamed Abbas 已提交
188

Z
Zhu Yi 已提交
189
	/* this bit wakes up the NIC */
190 191
	_iwl_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ);
	ret = _iwl_poll_bit(priv, CSR_GP_CNTRL,
Z
Zhu Yi 已提交
192 193
			   CSR_GP_CNTRL_REG_VAL_MAC_ACCESS_EN,
			   (CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY |
194
			    CSR_GP_CNTRL_REG_FLAG_GOING_TO_SLEEP), 15000);
195
	if (ret < 0) {
196 197
		val = _iwl_read32(priv, CSR_GP_CNTRL);
		IWL_ERR(priv, "MAC is in deep sleep!.  CSR_GP_CNTRL = 0x%08X\n", val);
M
Mohamed Abbas 已提交
198
		_iwl_write32(priv, CSR_RESET, CSR_RESET_REG_FLAG_FORCE_NMI);
Z
Zhu Yi 已提交
199 200 201 202 203 204
		return -EIO;
	}

	return 0;
}

205
#ifdef CONFIG_IWLWIFI_DEBUG
206
static inline int __iwl_grab_nic_access(const char *f, u32 l,
207
					       struct iwl_priv *priv)
Z
Zhu Yi 已提交
208
{
209
	IWL_DEBUG_IO(priv, "grabbing nic access - %s %d\n", f, l);
210
	return _iwl_grab_nic_access(priv);
Z
Zhu Yi 已提交
211
}
212 213
#define iwl_grab_nic_access(priv) \
	__iwl_grab_nic_access(__FILE__, __LINE__, priv)
Z
Zhu Yi 已提交
214
#else
215 216
#define iwl_grab_nic_access(priv) \
	_iwl_grab_nic_access(priv)
Z
Zhu Yi 已提交
217 218
#endif

219
static inline void _iwl_release_nic_access(struct iwl_priv *priv)
Z
Zhu Yi 已提交
220
{
M
Mohamed Abbas 已提交
221 222
	_iwl_clear_bit(priv, CSR_GP_CNTRL,
			CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ);
Z
Zhu Yi 已提交
223
}
224
#ifdef CONFIG_IWLWIFI_DEBUG
225
static inline void __iwl_release_nic_access(const char *f, u32 l,
226
					    struct iwl_priv *priv)
Z
Zhu Yi 已提交
227 228
{

229
	IWL_DEBUG_IO(priv, "releasing nic access - %s %d\n", f, l);
230
	_iwl_release_nic_access(priv);
Z
Zhu Yi 已提交
231
}
232 233
#define iwl_release_nic_access(priv) \
	__iwl_release_nic_access(__FILE__, __LINE__, priv)
Z
Zhu Yi 已提交
234
#else
235 236
#define iwl_release_nic_access(priv) \
	_iwl_release_nic_access(priv)
Z
Zhu Yi 已提交
237 238
#endif

239
static inline u32 _iwl_read_direct32(struct iwl_priv *priv, u32 reg)
Z
Zhu Yi 已提交
240
{
241
	return _iwl_read32(priv, reg);
Z
Zhu Yi 已提交
242
}
243
#ifdef CONFIG_IWLWIFI_DEBUG
244
static inline u32 __iwl_read_direct32(const char *f, u32 l,
245
					struct iwl_priv *priv, u32 reg)
Z
Zhu Yi 已提交
246
{
247
	u32 value = _iwl_read_direct32(priv, reg);
248
	IWL_DEBUG_IO(priv, "read_direct32(0x%4X) = 0x%08x - %s %d \n", reg, value,
Z
Zhu Yi 已提交
249 250 251
		     f, l);
	return value;
}
M
Mohamed Abbas 已提交
252 253 254 255 256 257 258 259 260 261 262 263 264
static inline u32 iwl_read_direct32(struct iwl_priv *priv, u32 reg)
{
	u32 value;
	unsigned long reg_flags;

	spin_lock_irqsave(&priv->reg_lock, reg_flags);
	iwl_grab_nic_access(priv);
	value = __iwl_read_direct32(__FILE__, __LINE__, priv, reg);
	iwl_release_nic_access(priv);
	spin_unlock_irqrestore(&priv->reg_lock, reg_flags);
	return value;
}

Z
Zhu Yi 已提交
265
#else
M
Mohamed Abbas 已提交
266 267 268 269 270 271 272 273 274 275 276 277 278
static inline u32 iwl_read_direct32(struct iwl_priv *priv, u32 reg)
{
	u32 value;
	unsigned long reg_flags;

	spin_lock_irqsave(&priv->reg_lock, reg_flags);
	iwl_grab_nic_access(priv);
	value = _iwl_read_direct32(priv, reg);
	iwl_release_nic_access(priv);
	spin_unlock_irqrestore(&priv->reg_lock, reg_flags);
	return value;

}
Z
Zhu Yi 已提交
279 280
#endif

281
static inline void _iwl_write_direct32(struct iwl_priv *priv,
Z
Zhu Yi 已提交
282 283
					 u32 reg, u32 value)
{
284
	_iwl_write32(priv, reg, value);
Z
Zhu Yi 已提交
285
}
M
Mohamed Abbas 已提交
286
static inline void iwl_write_direct32(struct iwl_priv *priv, u32 reg, u32 value)
Z
Zhu Yi 已提交
287
{
M
Mohamed Abbas 已提交
288 289 290 291 292 293 294 295
	unsigned long reg_flags;

	spin_lock_irqsave(&priv->reg_lock, reg_flags);
	if (!iwl_grab_nic_access(priv)) {
		_iwl_write_direct32(priv, reg, value);
		iwl_release_nic_access(priv);
	}
	spin_unlock_irqrestore(&priv->reg_lock, reg_flags);
Z
Zhu Yi 已提交
296 297
}

298
static inline void iwl_write_reg_buf(struct iwl_priv *priv,
Z
Zhu Yi 已提交
299 300 301 302 303 304
					       u32 reg, u32 len, u32 *values)
{
	u32 count = sizeof(u32);

	if ((priv != NULL) && (values != NULL)) {
		for (; 0 < len; len -= count, reg += count, values++)
M
Mohamed Abbas 已提交
305
			iwl_write_direct32(priv, reg, *values);
Z
Zhu Yi 已提交
306 307 308
	}
}

Z
Zhu, Yi 已提交
309 310
static inline int _iwl_poll_direct_bit(struct iwl_priv *priv, u32 addr,
				       u32 mask, int timeout)
Z
Zhu Yi 已提交
311
{
M
Mohamed Abbas 已提交
312 313 314 315 316 317 318 319 320 321
	int t = 0;

	do {
		if ((iwl_read_direct32(priv, addr) & mask) == mask)
			return t;
		udelay(IWL_POLL_INTERVAL);
		t += IWL_POLL_INTERVAL;
	} while (t < timeout);

	return -ETIMEDOUT;
Z
Zhu Yi 已提交
322 323
}

324
#ifdef CONFIG_IWLWIFI_DEBUG
325
static inline int __iwl_poll_direct_bit(const char *f, u32 l,
326
					    struct iwl_priv *priv,
Z
Zhu Yi 已提交
327 328
					    u32 addr, u32 mask, int timeout)
{
329
	int ret  = _iwl_poll_direct_bit(priv, addr, mask, timeout);
Z
Zhu Yi 已提交
330

331
	if (unlikely(ret == -ETIMEDOUT))
332
		IWL_DEBUG_IO(priv, "poll_direct_bit(0x%08X, 0x%08X) - "
Z
Zhu Yi 已提交
333 334
			     "timedout - %s %d\n", addr, mask, f, l);
	else
335
		IWL_DEBUG_IO(priv, "poll_direct_bit(0x%08X, 0x%08X) = 0x%08X "
336 337
			     "- %s %d\n", addr, mask, ret, f, l);
	return ret;
Z
Zhu Yi 已提交
338
}
339 340
#define iwl_poll_direct_bit(priv, addr, mask, timeout) \
	__iwl_poll_direct_bit(__FILE__, __LINE__, priv, addr, mask, timeout)
Z
Zhu Yi 已提交
341
#else
342
#define iwl_poll_direct_bit _iwl_poll_direct_bit
Z
Zhu Yi 已提交
343 344
#endif

345
static inline u32 _iwl_read_prph(struct iwl_priv *priv, u32 reg)
Z
Zhu Yi 已提交
346
{
347
	_iwl_write_direct32(priv, HBUS_TARG_PRPH_RADDR, reg | (3 << 24));
348
	rmb();
349
	return _iwl_read_direct32(priv, HBUS_TARG_PRPH_RDAT);
Z
Zhu Yi 已提交
350
}
M
Mohamed Abbas 已提交
351
static inline u32 iwl_read_prph(struct iwl_priv *priv, u32 reg)
Z
Zhu Yi 已提交
352
{
M
Mohamed Abbas 已提交
353 354
	unsigned long reg_flags;
	u32 val;
Z
Zhu Yi 已提交
355

M
Mohamed Abbas 已提交
356 357 358 359 360 361 362
	spin_lock_irqsave(&priv->reg_lock, reg_flags);
	iwl_grab_nic_access(priv);
	val = _iwl_read_prph(priv, reg);
	iwl_release_nic_access(priv);
	spin_unlock_irqrestore(&priv->reg_lock, reg_flags);
	return val;
}
Z
Zhu Yi 已提交
363

364
static inline void _iwl_write_prph(struct iwl_priv *priv,
Z
Zhu Yi 已提交
365 366
					     u32 addr, u32 val)
{
367
	_iwl_write_direct32(priv, HBUS_TARG_PRPH_WADDR,
Z
Zhu Yi 已提交
368
			      ((addr & 0x0000FFFF) | (3 << 24)));
369
	wmb();
370
	_iwl_write_direct32(priv, HBUS_TARG_PRPH_WDAT, val);
Z
Zhu Yi 已提交
371
}
M
Mohamed Abbas 已提交
372 373

static inline void iwl_write_prph(struct iwl_priv *priv, u32 addr, u32 val)
Z
Zhu Yi 已提交
374
{
M
Mohamed Abbas 已提交
375
	unsigned long reg_flags;
Z
Zhu Yi 已提交
376

M
Mohamed Abbas 已提交
377 378 379 380 381 382 383
	spin_lock_irqsave(&priv->reg_lock, reg_flags);
	if (!iwl_grab_nic_access(priv)) {
		_iwl_write_prph(priv, addr, val);
		iwl_release_nic_access(priv);
	}
	spin_unlock_irqrestore(&priv->reg_lock, reg_flags);
}
Z
Zhu Yi 已提交
384

385 386
#define _iwl_set_bits_prph(priv, reg, mask) \
	_iwl_write_prph(priv, reg, (_iwl_read_prph(priv, reg) | mask))
M
Mohamed Abbas 已提交
387 388

static inline void iwl_set_bits_prph(struct iwl_priv *priv, u32 reg, u32 mask)
Z
Zhu Yi 已提交
389
{
M
Mohamed Abbas 已提交
390
	unsigned long reg_flags;
391

M
Mohamed Abbas 已提交
392 393
	spin_lock_irqsave(&priv->reg_lock, reg_flags);
	iwl_grab_nic_access(priv);
394
	_iwl_set_bits_prph(priv, reg, mask);
M
Mohamed Abbas 已提交
395 396
	iwl_release_nic_access(priv);
	spin_unlock_irqrestore(&priv->reg_lock, reg_flags);
Z
Zhu Yi 已提交
397 398
}

399 400
#define _iwl_set_bits_mask_prph(priv, reg, bits, mask) \
	_iwl_write_prph(priv, reg, ((_iwl_read_prph(priv, reg) & mask) | bits))
401

M
Mohamed Abbas 已提交
402 403
static inline void iwl_set_bits_mask_prph(struct iwl_priv *priv, u32 reg,
				u32 bits, u32 mask)
Z
Zhu Yi 已提交
404
{
M
Mohamed Abbas 已提交
405 406 407 408
	unsigned long reg_flags;

	spin_lock_irqsave(&priv->reg_lock, reg_flags);
	iwl_grab_nic_access(priv);
409
	_iwl_set_bits_mask_prph(priv, reg, bits, mask);
M
Mohamed Abbas 已提交
410 411
	iwl_release_nic_access(priv);
	spin_unlock_irqrestore(&priv->reg_lock, reg_flags);
Z
Zhu Yi 已提交
412 413
}

414
static inline void iwl_clear_bits_prph(struct iwl_priv
Z
Zhu Yi 已提交
415 416
						 *priv, u32 reg, u32 mask)
{
M
Mohamed Abbas 已提交
417 418 419 420 421 422
	unsigned long reg_flags;
	u32 val;

	spin_lock_irqsave(&priv->reg_lock, reg_flags);
	iwl_grab_nic_access(priv);
	val = _iwl_read_prph(priv, reg);
423
	_iwl_write_prph(priv, reg, (val & ~mask));
M
Mohamed Abbas 已提交
424 425
	iwl_release_nic_access(priv);
	spin_unlock_irqrestore(&priv->reg_lock, reg_flags);
Z
Zhu Yi 已提交
426 427
}

428
static inline u32 iwl_read_targ_mem(struct iwl_priv *priv, u32 addr)
Z
Zhu Yi 已提交
429
{
M
Mohamed Abbas 已提交
430 431 432 433 434 435 436
	unsigned long reg_flags;
	u32 value;

	spin_lock_irqsave(&priv->reg_lock, reg_flags);
	iwl_grab_nic_access(priv);

	_iwl_write_direct32(priv, HBUS_TARG_MEM_RADDR, addr);
437
	rmb();
M
Mohamed Abbas 已提交
438 439 440 441 442
	value = _iwl_read_direct32(priv, HBUS_TARG_MEM_RDAT);

	iwl_release_nic_access(priv);
	spin_unlock_irqrestore(&priv->reg_lock, reg_flags);
	return value;
Z
Zhu Yi 已提交
443 444
}

445
static inline void iwl_write_targ_mem(struct iwl_priv *priv, u32 addr, u32 val)
Z
Zhu Yi 已提交
446
{
M
Mohamed Abbas 已提交
447 448 449 450 451 452 453 454 455 456
	unsigned long reg_flags;

	spin_lock_irqsave(&priv->reg_lock, reg_flags);
	if (!iwl_grab_nic_access(priv)) {
		_iwl_write_direct32(priv, HBUS_TARG_MEM_WADDR, addr);
		wmb();
		_iwl_write_direct32(priv, HBUS_TARG_MEM_WDAT, val);
		iwl_release_nic_access(priv);
	}
	spin_unlock_irqrestore(&priv->reg_lock, reg_flags);
Z
Zhu Yi 已提交
457 458
}

459
static inline void iwl_write_targ_mem_buf(struct iwl_priv *priv, u32 addr,
460
					  u32 len, u32 *values)
Z
Zhu Yi 已提交
461
{
M
Mohamed Abbas 已提交
462 463 464 465 466 467 468 469 470 471 472 473
	unsigned long reg_flags;

	spin_lock_irqsave(&priv->reg_lock, reg_flags);
	if (!iwl_grab_nic_access(priv)) {
		_iwl_write_direct32(priv, HBUS_TARG_MEM_WADDR, addr);
		wmb();
		for (; 0 < len; len -= sizeof(u32), values++)
			_iwl_write_direct32(priv, HBUS_TARG_MEM_WDAT, *values);

		iwl_release_nic_access(priv);
	}
	spin_unlock_irqrestore(&priv->reg_lock, reg_flags);
Z
Zhu Yi 已提交
474 475
}
#endif