iwl-3945-io.h 13.6 KB
Newer Older
Z
Zhu Yi 已提交
1 2
/******************************************************************************
 *
R
Reinette Chatre 已提交
3
 * Copyright(c) 2003 - 2008 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 24 25 26 27 28
 *
 * 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:
 * James P. Ketrenos <ipw2100-admin@linux.intel.com>
 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
 *
 *****************************************************************************/

C
Christoph Hellwig 已提交
29 30
#ifndef __iwl3945_io_h__
#define __iwl3945_io_h__
Z
Zhu Yi 已提交
31 32 33

#include <linux/io.h>

34
#include "iwl-3945-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
 * and the current line number is printed in addition to any other debug output.
Z
Zhu Yi 已提交
46 47 48 49 50 51
 *
 * The non-prefixed name is the #define that maps the caller into a
 * #define that provides the caller's __LINE__ to the double prefix version.
 *
 * 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
C
Christoph Hellwig 已提交
52 53
 * routines, for example _iwl3945_read_direct32 calls the non-check version of
 * _iwl3945_read32.)
Z
Zhu Yi 已提交
54 55 56 57 58 59 60 61
 *
 * These declarations are *extremely* useful in quickly isolating code deltas
 * which result in misconfiguring of the hardware I/O.  In combination with
 * git-bisect and the IO debug level you can quickly determine the specific
 * commit which breaks the IO sequence to the hardware.
 *
 */

62
#define _iwl3945_write32(priv, ofs, val) writel((val), (priv)->hw_base + (ofs))
63
#ifdef CONFIG_IWL3945_DEBUG
64
static inline void __iwl3945_write32(const char *f, u32 l, struct iwl3945_priv *priv,
Z
Zhu Yi 已提交
65 66
				 u32 ofs, u32 val)
{
67
	IWL_DEBUG_IO("write32(0x%08X, 0x%08X) - %s %d\n", ofs, val, f, l);
68
	_iwl3945_write32(priv, ofs, val);
Z
Zhu Yi 已提交
69
}
70 71
#define iwl3945_write32(priv, ofs, val) \
	__iwl3945_write32(__FILE__, __LINE__, priv, ofs, val)
Z
Zhu Yi 已提交
72
#else
73
#define iwl3945_write32(priv, ofs, val) _iwl3945_write32(priv, ofs, val)
Z
Zhu Yi 已提交
74 75
#endif

76
#define _iwl3945_read32(priv, ofs) readl((priv)->hw_base + (ofs))
77
#ifdef CONFIG_IWL3945_DEBUG
78
static inline u32 __iwl3945_read32(char *f, u32 l, struct iwl3945_priv *priv, u32 ofs)
Z
Zhu Yi 已提交
79 80
{
	IWL_DEBUG_IO("read_direct32(0x%08X) - %s %d\n", ofs, f, l);
81
	return _iwl3945_read32(priv, ofs);
Z
Zhu Yi 已提交
82
}
83
#define iwl3945_read32(priv, ofs) __iwl3945_read32(__FILE__, __LINE__, priv, ofs)
Z
Zhu Yi 已提交
84
#else
C
Christoph Hellwig 已提交
85
#define iwl3945_read32(p, o) _iwl3945_read32(p, o)
Z
Zhu Yi 已提交
86 87
#endif

C
Christoph Hellwig 已提交
88
static inline int _iwl3945_poll_bit(struct iwl3945_priv *priv, u32 addr,
Z
Zhu Yi 已提交
89 90 91 92 93
				u32 bits, u32 mask, int timeout)
{
	int i = 0;

	do {
C
Christoph Hellwig 已提交
94
		if ((_iwl3945_read32(priv, addr) & mask) == (bits & mask))
Z
Zhu Yi 已提交
95 96 97 98 99 100 101
			return i;
		mdelay(10);
		i += 10;
	} while (i < timeout);

	return -ETIMEDOUT;
}
102
#ifdef CONFIG_IWL3945_DEBUG
C
Christoph Hellwig 已提交
103 104
static inline int __iwl3945_poll_bit(const char *f, u32 l,
				 struct iwl3945_priv *priv, u32 addr,
Z
Zhu Yi 已提交
105 106
				 u32 bits, u32 mask, int timeout)
{
C
Christoph Hellwig 已提交
107
	int ret = _iwl3945_poll_bit(priv, addr, bits, mask, timeout);
108 109 110
	IWL_DEBUG_IO("poll_bit(0x%08X, 0x%08X, 0x%08X) - %s- %s %d\n",
		      addr, bits, mask,
		      unlikely(ret  == -ETIMEDOUT)?"timeout":"", f, l);
111
	return ret;
Z
Zhu Yi 已提交
112
}
113 114
#define iwl3945_poll_bit(priv, addr, bits, mask, timeout) \
	__iwl3945_poll_bit(__FILE__, __LINE__, priv, addr, bits, mask, timeout)
Z
Zhu Yi 已提交
115
#else
C
Christoph Hellwig 已提交
116
#define iwl3945_poll_bit(p, a, b, m, t) _iwl3945_poll_bit(p, a, b, m, t)
Z
Zhu Yi 已提交
117 118
#endif

C
Christoph Hellwig 已提交
119
static inline void _iwl3945_set_bit(struct iwl3945_priv *priv, u32 reg, u32 mask)
Z
Zhu Yi 已提交
120
{
C
Christoph Hellwig 已提交
121
	_iwl3945_write32(priv, reg, _iwl3945_read32(priv, reg) | mask);
Z
Zhu Yi 已提交
122
}
123
#ifdef CONFIG_IWL3945_DEBUG
C
Christoph Hellwig 已提交
124 125
static inline void __iwl3945_set_bit(const char *f, u32 l,
				 struct iwl3945_priv *priv, u32 reg, u32 mask)
Z
Zhu Yi 已提交
126
{
C
Christoph Hellwig 已提交
127
	u32 val = _iwl3945_read32(priv, reg) | mask;
Z
Zhu Yi 已提交
128
	IWL_DEBUG_IO("set_bit(0x%08X, 0x%08X) = 0x%08X\n", reg, mask, val);
C
Christoph Hellwig 已提交
129
	_iwl3945_write32(priv, reg, val);
Z
Zhu Yi 已提交
130
}
C
Christoph Hellwig 已提交
131
#define iwl3945_set_bit(p, r, m) __iwl3945_set_bit(__FILE__, __LINE__, p, r, m)
Z
Zhu Yi 已提交
132
#else
C
Christoph Hellwig 已提交
133
#define iwl3945_set_bit(p, r, m) _iwl3945_set_bit(p, r, m)
Z
Zhu Yi 已提交
134 135
#endif

C
Christoph Hellwig 已提交
136
static inline void _iwl3945_clear_bit(struct iwl3945_priv *priv, u32 reg, u32 mask)
Z
Zhu Yi 已提交
137
{
C
Christoph Hellwig 已提交
138
	_iwl3945_write32(priv, reg, _iwl3945_read32(priv, reg) & ~mask);
Z
Zhu Yi 已提交
139
}
140
#ifdef CONFIG_IWL3945_DEBUG
C
Christoph Hellwig 已提交
141 142
static inline void __iwl3945_clear_bit(const char *f, u32 l,
				   struct iwl3945_priv *priv, u32 reg, u32 mask)
Z
Zhu Yi 已提交
143
{
C
Christoph Hellwig 已提交
144
	u32 val = _iwl3945_read32(priv, reg) & ~mask;
Z
Zhu Yi 已提交
145
	IWL_DEBUG_IO("clear_bit(0x%08X, 0x%08X) = 0x%08X\n", reg, mask, val);
C
Christoph Hellwig 已提交
146
	_iwl3945_write32(priv, reg, val);
Z
Zhu Yi 已提交
147
}
C
Christoph Hellwig 已提交
148
#define iwl3945_clear_bit(p, r, m) __iwl3945_clear_bit(__FILE__, __LINE__, p, r, m)
Z
Zhu Yi 已提交
149
#else
C
Christoph Hellwig 已提交
150
#define iwl3945_clear_bit(p, r, m) _iwl3945_clear_bit(p, r, m)
Z
Zhu Yi 已提交
151 152
#endif

C
Christoph Hellwig 已提交
153
static inline int _iwl3945_grab_nic_access(struct iwl3945_priv *priv)
Z
Zhu Yi 已提交
154
{
155
	int ret;
Z
Zhu Yi 已提交
156 157
	u32 gp_ctl;

158
#ifdef CONFIG_IWL3945_DEBUG
Z
Zhu Yi 已提交
159 160 161 162 163 164 165 166 167
	if (atomic_read(&priv->restrict_refcnt))
		return 0;
#endif
	if (test_bit(STATUS_RF_KILL_HW, &priv->status) ||
	    test_bit(STATUS_RF_KILL_SW, &priv->status)) {
		IWL_WARNING("WARNING: Requesting MAC access during RFKILL "
			"wakes up NIC\n");

		/* 10 msec allows time for NIC to complete its data save */
C
Christoph Hellwig 已提交
168
		gp_ctl = _iwl3945_read32(priv, CSR_GP_CNTRL);
Z
Zhu Yi 已提交
169 170 171 172 173 174 175 176 177 178
		if (gp_ctl & CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY) {
			IWL_DEBUG_RF_KILL("Wait for complete power-down, "
				"gpctl = 0x%08x\n", gp_ctl);
			mdelay(10);
		} else
			IWL_DEBUG_RF_KILL("power-down complete, "
					  "gpctl = 0x%08x\n", gp_ctl);
	}

	/* this bit wakes up the NIC */
C
Christoph Hellwig 已提交
179 180
	_iwl3945_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ);
	ret = _iwl3945_poll_bit(priv, CSR_GP_CNTRL,
Z
Zhu Yi 已提交
181 182 183
			   CSR_GP_CNTRL_REG_VAL_MAC_ACCESS_EN,
			   (CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY |
			    CSR_GP_CNTRL_REG_FLAG_GOING_TO_SLEEP), 50);
184
	if (ret < 0) {
Z
Zhu Yi 已提交
185 186 187 188
		IWL_ERROR("MAC is in deep sleep!\n");
		return -EIO;
	}

189
#ifdef CONFIG_IWL3945_DEBUG
Z
Zhu Yi 已提交
190 191 192 193 194
	atomic_inc(&priv->restrict_refcnt);
#endif
	return 0;
}

195
#ifdef CONFIG_IWL3945_DEBUG
C
Christoph Hellwig 已提交
196 197
static inline int __iwl3945_grab_nic_access(const char *f, u32 l,
					       struct iwl3945_priv *priv)
Z
Zhu Yi 已提交
198 199 200 201 202
{
	if (atomic_read(&priv->restrict_refcnt))
		IWL_DEBUG_INFO("Grabbing access while already held at "
			       "line %d.\n", l);

203
	IWL_DEBUG_IO("grabbing nic access - %s %d\n", f, l);
C
Christoph Hellwig 已提交
204
	return _iwl3945_grab_nic_access(priv);
Z
Zhu Yi 已提交
205
}
C
Christoph Hellwig 已提交
206 207
#define iwl3945_grab_nic_access(priv) \
	__iwl3945_grab_nic_access(__FILE__, __LINE__, priv)
Z
Zhu Yi 已提交
208
#else
C
Christoph Hellwig 已提交
209 210
#define iwl3945_grab_nic_access(priv) \
	_iwl3945_grab_nic_access(priv)
Z
Zhu Yi 已提交
211 212
#endif

C
Christoph Hellwig 已提交
213
static inline void _iwl3945_release_nic_access(struct iwl3945_priv *priv)
Z
Zhu Yi 已提交
214
{
215
#ifdef CONFIG_IWL3945_DEBUG
Z
Zhu Yi 已提交
216 217
	if (atomic_dec_and_test(&priv->restrict_refcnt))
#endif
C
Christoph Hellwig 已提交
218
		_iwl3945_clear_bit(priv, CSR_GP_CNTRL,
Z
Zhu Yi 已提交
219 220
			       CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ);
}
221
#ifdef CONFIG_IWL3945_DEBUG
C
Christoph Hellwig 已提交
222 223
static inline void __iwl3945_release_nic_access(const char *f, u32 l,
					    struct iwl3945_priv *priv)
Z
Zhu Yi 已提交
224 225
{
	if (atomic_read(&priv->restrict_refcnt) <= 0)
226
		IWL_ERROR("Release unheld nic access at line %d.\n", l);
Z
Zhu Yi 已提交
227

228
	IWL_DEBUG_IO("releasing nic access - %s %d\n", f, l);
C
Christoph Hellwig 已提交
229
	_iwl3945_release_nic_access(priv);
Z
Zhu Yi 已提交
230
}
C
Christoph Hellwig 已提交
231 232
#define iwl3945_release_nic_access(priv) \
	__iwl3945_release_nic_access(__FILE__, __LINE__, priv)
Z
Zhu Yi 已提交
233
#else
C
Christoph Hellwig 已提交
234 235
#define iwl3945_release_nic_access(priv) \
	_iwl3945_release_nic_access(priv)
Z
Zhu Yi 已提交
236 237
#endif

C
Christoph Hellwig 已提交
238
static inline u32 _iwl3945_read_direct32(struct iwl3945_priv *priv, u32 reg)
Z
Zhu Yi 已提交
239
{
C
Christoph Hellwig 已提交
240
	return _iwl3945_read32(priv, reg);
Z
Zhu Yi 已提交
241
}
242
#ifdef CONFIG_IWL3945_DEBUG
C
Christoph Hellwig 已提交
243 244
static inline u32 __iwl3945_read_direct32(const char *f, u32 l,
					struct iwl3945_priv *priv, u32 reg)
Z
Zhu Yi 已提交
245
{
C
Christoph Hellwig 已提交
246
	u32 value = _iwl3945_read_direct32(priv, reg);
Z
Zhu Yi 已提交
247
	if (!atomic_read(&priv->restrict_refcnt))
248 249
		IWL_ERROR("Nic access not held from %s %d\n", f, l);
	IWL_DEBUG_IO("read_direct32(0x%4X) = 0x%08x - %s %d \n", reg, value,
Z
Zhu Yi 已提交
250 251 252
		     f, l);
	return value;
}
C
Christoph Hellwig 已提交
253 254
#define iwl3945_read_direct32(priv, reg) \
	__iwl3945_read_direct32(__FILE__, __LINE__, priv, reg)
Z
Zhu Yi 已提交
255
#else
C
Christoph Hellwig 已提交
256
#define iwl3945_read_direct32 _iwl3945_read_direct32
Z
Zhu Yi 已提交
257 258
#endif

C
Christoph Hellwig 已提交
259
static inline void _iwl3945_write_direct32(struct iwl3945_priv *priv,
Z
Zhu Yi 已提交
260 261
					 u32 reg, u32 value)
{
C
Christoph Hellwig 已提交
262
	_iwl3945_write32(priv, reg, value);
Z
Zhu Yi 已提交
263
}
264
#ifdef CONFIG_IWL3945_DEBUG
C
Christoph Hellwig 已提交
265 266
static void __iwl3945_write_direct32(u32 line,
				   struct iwl3945_priv *priv, u32 reg, u32 value)
Z
Zhu Yi 已提交
267 268
{
	if (!atomic_read(&priv->restrict_refcnt))
269
		IWL_ERROR("Nic access not held from line %d\n", line);
C
Christoph Hellwig 已提交
270
	_iwl3945_write_direct32(priv, reg, value);
Z
Zhu Yi 已提交
271
}
C
Christoph Hellwig 已提交
272 273
#define iwl3945_write_direct32(priv, reg, value) \
	__iwl3945_write_direct32(__LINE__, priv, reg, value)
Z
Zhu Yi 已提交
274
#else
C
Christoph Hellwig 已提交
275
#define iwl3945_write_direct32 _iwl3945_write_direct32
Z
Zhu Yi 已提交
276 277
#endif

C
Christoph Hellwig 已提交
278
static inline void iwl3945_write_reg_buf(struct iwl3945_priv *priv,
Z
Zhu Yi 已提交
279 280 281 282 283 284
					       u32 reg, u32 len, u32 *values)
{
	u32 count = sizeof(u32);

	if ((priv != NULL) && (values != NULL)) {
		for (; 0 < len; len -= count, reg += count, values++)
C
Christoph Hellwig 已提交
285
			_iwl3945_write_direct32(priv, reg, *values);
Z
Zhu Yi 已提交
286 287 288
	}
}

C
Christoph Hellwig 已提交
289
static inline int _iwl3945_poll_direct_bit(struct iwl3945_priv *priv,
Z
Zhu Yi 已提交
290 291 292 293 294
					   u32 addr, u32 mask, int timeout)
{
	int i = 0;

	do {
C
Christoph Hellwig 已提交
295
		if ((_iwl3945_read_direct32(priv, addr) & mask) == mask)
Z
Zhu Yi 已提交
296 297 298 299 300 301 302 303
			return i;
		mdelay(10);
		i += 10;
	} while (i < timeout);

	return -ETIMEDOUT;
}

304
#ifdef CONFIG_IWL3945_DEBUG
C
Christoph Hellwig 已提交
305 306
static inline int __iwl3945_poll_direct_bit(const char *f, u32 l,
					    struct iwl3945_priv *priv,
Z
Zhu Yi 已提交
307 308
					    u32 addr, u32 mask, int timeout)
{
C
Christoph Hellwig 已提交
309
	int ret  = _iwl3945_poll_direct_bit(priv, addr, mask, timeout);
Z
Zhu Yi 已提交
310

311 312
	if (unlikely(ret == -ETIMEDOUT))
		IWL_DEBUG_IO("poll_direct_bit(0x%08X, 0x%08X) - "
Z
Zhu Yi 已提交
313 314
			     "timedout - %s %d\n", addr, mask, f, l);
	else
315 316 317
		IWL_DEBUG_IO("poll_direct_bit(0x%08X, 0x%08X) = 0x%08X "
			     "- %s %d\n", addr, mask, ret, f, l);
	return ret;
Z
Zhu Yi 已提交
318
}
319 320
#define iwl3945_poll_direct_bit(priv, addr, mask, timeout) \
	__iwl3945_poll_direct_bit(__FILE__, __LINE__, priv, addr, mask, timeout)
Z
Zhu Yi 已提交
321
#else
C
Christoph Hellwig 已提交
322
#define iwl3945_poll_direct_bit _iwl3945_poll_direct_bit
Z
Zhu Yi 已提交
323 324
#endif

C
Christoph Hellwig 已提交
325
static inline u32 _iwl3945_read_prph(struct iwl3945_priv *priv, u32 reg)
Z
Zhu Yi 已提交
326
{
C
Christoph Hellwig 已提交
327 328
	_iwl3945_write_direct32(priv, HBUS_TARG_PRPH_RADDR, reg | (3 << 24));
	return _iwl3945_read_direct32(priv, HBUS_TARG_PRPH_RDAT);
Z
Zhu Yi 已提交
329
}
330
#ifdef CONFIG_IWL3945_DEBUG
C
Christoph Hellwig 已提交
331
static inline u32 __iwl3945_read_prph(u32 line, struct iwl3945_priv *priv, u32 reg)
Z
Zhu Yi 已提交
332 333
{
	if (!atomic_read(&priv->restrict_refcnt))
334
		IWL_ERROR("Nic access not held from line %d\n", line);
C
Christoph Hellwig 已提交
335
	return _iwl3945_read_prph(priv, reg);
Z
Zhu Yi 已提交
336 337
}

C
Christoph Hellwig 已提交
338 339
#define iwl3945_read_prph(priv, reg) \
	__iwl3945_read_prph(__LINE__, priv, reg)
Z
Zhu Yi 已提交
340
#else
C
Christoph Hellwig 已提交
341
#define iwl3945_read_prph _iwl3945_read_prph
Z
Zhu Yi 已提交
342 343
#endif

C
Christoph Hellwig 已提交
344
static inline void _iwl3945_write_prph(struct iwl3945_priv *priv,
Z
Zhu Yi 已提交
345 346
					     u32 addr, u32 val)
{
C
Christoph Hellwig 已提交
347
	_iwl3945_write_direct32(priv, HBUS_TARG_PRPH_WADDR,
Z
Zhu Yi 已提交
348
			      ((addr & 0x0000FFFF) | (3 << 24)));
C
Christoph Hellwig 已提交
349
	_iwl3945_write_direct32(priv, HBUS_TARG_PRPH_WDAT, val);
Z
Zhu Yi 已提交
350
}
351
#ifdef CONFIG_IWL3945_DEBUG
C
Christoph Hellwig 已提交
352
static inline void __iwl3945_write_prph(u32 line, struct iwl3945_priv *priv,
Z
Zhu Yi 已提交
353 354 355
					      u32 addr, u32 val)
{
	if (!atomic_read(&priv->restrict_refcnt))
356
		IWL_ERROR("Nic access from line %d\n", line);
C
Christoph Hellwig 已提交
357
	_iwl3945_write_prph(priv, addr, val);
Z
Zhu Yi 已提交
358 359
}

C
Christoph Hellwig 已提交
360 361
#define iwl3945_write_prph(priv, addr, val) \
	__iwl3945_write_prph(__LINE__, priv, addr, val);
Z
Zhu Yi 已提交
362
#else
C
Christoph Hellwig 已提交
363
#define iwl3945_write_prph _iwl3945_write_prph
Z
Zhu Yi 已提交
364 365
#endif

C
Christoph Hellwig 已提交
366 367
#define _iwl3945_set_bits_prph(priv, reg, mask) \
	_iwl3945_write_prph(priv, reg, (_iwl3945_read_prph(priv, reg) | mask))
368
#ifdef CONFIG_IWL3945_DEBUG
C
Christoph Hellwig 已提交
369
static inline void __iwl3945_set_bits_prph(u32 line, struct iwl3945_priv *priv,
370
					u32 reg, u32 mask)
Z
Zhu Yi 已提交
371 372
{
	if (!atomic_read(&priv->restrict_refcnt))
373 374
		IWL_ERROR("Nic access not held from line %d\n", line);

C
Christoph Hellwig 已提交
375
	_iwl3945_set_bits_prph(priv, reg, mask);
Z
Zhu Yi 已提交
376
}
C
Christoph Hellwig 已提交
377 378
#define iwl3945_set_bits_prph(priv, reg, mask) \
	__iwl3945_set_bits_prph(__LINE__, priv, reg, mask)
Z
Zhu Yi 已提交
379
#else
C
Christoph Hellwig 已提交
380
#define iwl3945_set_bits_prph _iwl3945_set_bits_prph
Z
Zhu Yi 已提交
381 382
#endif

C
Christoph Hellwig 已提交
383 384
#define _iwl3945_set_bits_mask_prph(priv, reg, bits, mask) \
	_iwl3945_write_prph(priv, reg, ((_iwl3945_read_prph(priv, reg) & mask) | bits))
385

386
#ifdef CONFIG_IWL3945_DEBUG
C
Christoph Hellwig 已提交
387 388
static inline void __iwl3945_set_bits_mask_prph(u32 line,
		struct iwl3945_priv *priv, u32 reg, u32 bits, u32 mask)
Z
Zhu Yi 已提交
389 390
{
	if (!atomic_read(&priv->restrict_refcnt))
391
		IWL_ERROR("Nic access not held from line %d\n", line);
C
Christoph Hellwig 已提交
392
	_iwl3945_set_bits_mask_prph(priv, reg, bits, mask);
Z
Zhu Yi 已提交
393
}
C
Christoph Hellwig 已提交
394 395
#define iwl3945_set_bits_mask_prph(priv, reg, bits, mask) \
	__iwl3945_set_bits_mask_prph(__LINE__, priv, reg, bits, mask)
Z
Zhu Yi 已提交
396
#else
C
Christoph Hellwig 已提交
397
#define iwl3945_set_bits_mask_prph _iwl3945_set_bits_mask_prph
Z
Zhu Yi 已提交
398 399
#endif

C
Christoph Hellwig 已提交
400
static inline void iwl3945_clear_bits_prph(struct iwl3945_priv
Z
Zhu Yi 已提交
401 402
						 *priv, u32 reg, u32 mask)
{
C
Christoph Hellwig 已提交
403 404
	u32 val = _iwl3945_read_prph(priv, reg);
	_iwl3945_write_prph(priv, reg, (val & ~mask));
Z
Zhu Yi 已提交
405 406
}

C
Christoph Hellwig 已提交
407
static inline u32 iwl3945_read_targ_mem(struct iwl3945_priv *priv, u32 addr)
Z
Zhu Yi 已提交
408
{
C
Christoph Hellwig 已提交
409 410
	iwl3945_write_direct32(priv, HBUS_TARG_MEM_RADDR, addr);
	return iwl3945_read_direct32(priv, HBUS_TARG_MEM_RDAT);
Z
Zhu Yi 已提交
411 412
}

C
Christoph Hellwig 已提交
413
static inline void iwl3945_write_targ_mem(struct iwl3945_priv *priv, u32 addr, u32 val)
Z
Zhu Yi 已提交
414
{
C
Christoph Hellwig 已提交
415 416
	iwl3945_write_direct32(priv, HBUS_TARG_MEM_WADDR, addr);
	iwl3945_write_direct32(priv, HBUS_TARG_MEM_WDAT, val);
Z
Zhu Yi 已提交
417 418
}

C
Christoph Hellwig 已提交
419
static inline void iwl3945_write_targ_mem_buf(struct iwl3945_priv *priv, u32 addr,
420
					  u32 len, u32 *values)
Z
Zhu Yi 已提交
421
{
C
Christoph Hellwig 已提交
422
	iwl3945_write_direct32(priv, HBUS_TARG_MEM_WADDR, addr);
Z
Zhu Yi 已提交
423
	for (; 0 < len; len -= sizeof(u32), values++)
C
Christoph Hellwig 已提交
424
		iwl3945_write_direct32(priv, HBUS_TARG_MEM_WDAT, *values);
Z
Zhu Yi 已提交
425 426
}
#endif