iwl-io.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved.
  4. *
  5. * Portions of this file are derived from the ipw3945 project.
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of version 2 of the GNU General Public License as
  9. * published by the Free Software Foundation.
  10. *
  11. * This program is distributed in the hope that it will be useful, but WITHOUT
  12. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  14. * more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along with
  17. * this program; if not, write to the Free Software Foundation, Inc.,
  18. * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
  19. *
  20. * The full GNU General Public License is included in this distribution in the
  21. * file called LICENSE.
  22. *
  23. * Contact Information:
  24. * Intel Linux Wireless <ilw@linux.intel.com>
  25. * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  26. *
  27. *****************************************************************************/
  28. #ifndef __iwl_legacy_io_h__
  29. #define __iwl_legacy_io_h__
  30. #include <linux/io.h>
  31. #include "iwl-dev.h"
  32. #include "iwl-debug.h"
  33. #include "iwl-devtrace.h"
  34. /*
  35. * IO, register, and NIC memory access functions
  36. *
  37. * NOTE on naming convention and macro usage for these
  38. *
  39. * A single _ prefix before a an access function means that no state
  40. * check or debug information is printed when that function is called.
  41. *
  42. * A double __ prefix before an access function means that state is checked
  43. * and the current line number and caller function name are printed in addition
  44. * to any other debug output.
  45. *
  46. * The non-prefixed name is the #define that maps the caller into a
  47. * #define that provides the caller's name and __LINE__ to the double
  48. * prefix version.
  49. *
  50. * If you wish to call the function without any debug or state checking,
  51. * you should use the single _ prefix version (as is used by dependent IO
  52. * routines, for example _iwl_legacy_read_direct32 calls the non-check version of
  53. * _iwl_legacy_read32.)
  54. *
  55. * These declarations are *extremely* useful in quickly isolating code deltas
  56. * which result in misconfiguration of the hardware I/O. In combination with
  57. * git-bisect and the IO debug level you can quickly determine the specific
  58. * commit which breaks the IO sequence to the hardware.
  59. *
  60. */
  61. static inline void _iwl_legacy_write8(struct iwl_priv *priv, u32 ofs, u8 val)
  62. {
  63. trace_iwlwifi_legacy_dev_iowrite8(priv, ofs, val);
  64. iowrite8(val, priv->hw_base + ofs);
  65. }
  66. #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG
  67. static inline void
  68. __iwl_legacy_write8(const char *f, u32 l, struct iwl_priv *priv,
  69. u32 ofs, u8 val)
  70. {
  71. IWL_DEBUG_IO(priv, "write8(0x%08X, 0x%02X) - %s %d\n", ofs, val, f, l);
  72. _iwl_legacy_write8(priv, ofs, val);
  73. }
  74. #define iwl_write8(priv, ofs, val) \
  75. __iwl_legacy_write8(__FILE__, __LINE__, priv, ofs, val)
  76. #else
  77. #define iwl_write8(priv, ofs, val) _iwl_legacy_write8(priv, ofs, val)
  78. #endif
  79. static inline void _iwl_legacy_write32(struct iwl_priv *priv, u32 ofs, u32 val)
  80. {
  81. trace_iwlwifi_legacy_dev_iowrite32(priv, ofs, val);
  82. iowrite32(val, priv->hw_base + ofs);
  83. }
  84. #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG
  85. static inline void
  86. __iwl_legacy_write32(const char *f, u32 l, struct iwl_priv *priv,
  87. u32 ofs, u32 val)
  88. {
  89. IWL_DEBUG_IO(priv, "write32(0x%08X, 0x%08X) - %s %d\n", ofs, val, f, l);
  90. _iwl_legacy_write32(priv, ofs, val);
  91. }
  92. #define iwl_write32(priv, ofs, val) \
  93. __iwl_legacy_write32(__FILE__, __LINE__, priv, ofs, val)
  94. #else
  95. #define iwl_write32(priv, ofs, val) _iwl_legacy_write32(priv, ofs, val)
  96. #endif
  97. static inline u32 _iwl_legacy_read32(struct iwl_priv *priv, u32 ofs)
  98. {
  99. u32 val = ioread32(priv->hw_base + ofs);
  100. trace_iwlwifi_legacy_dev_ioread32(priv, ofs, val);
  101. return val;
  102. }
  103. #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG
  104. static inline u32
  105. __iwl_legacy_read32(char *f, u32 l, struct iwl_priv *priv, u32 ofs)
  106. {
  107. IWL_DEBUG_IO(priv, "read_direct32(0x%08X) - %s %d\n", ofs, f, l);
  108. return _iwl_legacy_read32(priv, ofs);
  109. }
  110. #define iwl_read32(priv, ofs) __iwl_legacy_read32(__FILE__, __LINE__, priv, ofs)
  111. #else
  112. #define iwl_read32(p, o) _iwl_legacy_read32(p, o)
  113. #endif
  114. #define IWL_POLL_INTERVAL 10 /* microseconds */
  115. static inline int
  116. _iwl_legacy_poll_bit(struct iwl_priv *priv, u32 addr,
  117. u32 bits, u32 mask, int timeout)
  118. {
  119. int t = 0;
  120. do {
  121. if ((_iwl_legacy_read32(priv, addr) & mask) == (bits & mask))
  122. return t;
  123. udelay(IWL_POLL_INTERVAL);
  124. t += IWL_POLL_INTERVAL;
  125. } while (t < timeout);
  126. return -ETIMEDOUT;
  127. }
  128. #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG
  129. static inline int __iwl_legacy_poll_bit(const char *f, u32 l,
  130. struct iwl_priv *priv, u32 addr,
  131. u32 bits, u32 mask, int timeout)
  132. {
  133. int ret = _iwl_legacy_poll_bit(priv, addr, bits, mask, timeout);
  134. IWL_DEBUG_IO(priv, "poll_bit(0x%08X, 0x%08X, 0x%08X) - %s- %s %d\n",
  135. addr, bits, mask,
  136. unlikely(ret == -ETIMEDOUT) ? "timeout" : "", f, l);
  137. return ret;
  138. }
  139. #define iwl_poll_bit(priv, addr, bits, mask, timeout) \
  140. __iwl_legacy_poll_bit(__FILE__, __LINE__, priv, addr, \
  141. bits, mask, timeout)
  142. #else
  143. #define iwl_poll_bit(p, a, b, m, t) _iwl_legacy_poll_bit(p, a, b, m, t)
  144. #endif
  145. static inline void _iwl_legacy_set_bit(struct iwl_priv *priv, u32 reg, u32 mask)
  146. {
  147. _iwl_legacy_write32(priv, reg, _iwl_legacy_read32(priv, reg) | mask);
  148. }
  149. #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG
  150. static inline void __iwl_legacy_set_bit(const char *f, u32 l,
  151. struct iwl_priv *priv, u32 reg, u32 mask)
  152. {
  153. u32 val = _iwl_legacy_read32(priv, reg) | mask;
  154. IWL_DEBUG_IO(priv, "set_bit(0x%08X, 0x%08X) = 0x%08X\n", reg,
  155. mask, val);
  156. _iwl_legacy_write32(priv, reg, val);
  157. }
  158. static inline void iwl_legacy_set_bit(struct iwl_priv *p, u32 r, u32 m)
  159. {
  160. unsigned long reg_flags;
  161. spin_lock_irqsave(&p->reg_lock, reg_flags);
  162. __iwl_legacy_set_bit(__FILE__, __LINE__, p, r, m);
  163. spin_unlock_irqrestore(&p->reg_lock, reg_flags);
  164. }
  165. #else
  166. static inline void iwl_legacy_set_bit(struct iwl_priv *p, u32 r, u32 m)
  167. {
  168. unsigned long reg_flags;
  169. spin_lock_irqsave(&p->reg_lock, reg_flags);
  170. _iwl_legacy_set_bit(p, r, m);
  171. spin_unlock_irqrestore(&p->reg_lock, reg_flags);
  172. }
  173. #endif
  174. static inline void
  175. _iwl_legacy_clear_bit(struct iwl_priv *priv, u32 reg, u32 mask)
  176. {
  177. _iwl_legacy_write32(priv, reg, _iwl_legacy_read32(priv, reg) & ~mask);
  178. }
  179. #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG
  180. static inline void
  181. __iwl_legacy_clear_bit(const char *f, u32 l,
  182. struct iwl_priv *priv, u32 reg, u32 mask)
  183. {
  184. u32 val = _iwl_legacy_read32(priv, reg) & ~mask;
  185. IWL_DEBUG_IO(priv, "clear_bit(0x%08X, 0x%08X) = 0x%08X\n", reg, mask, val);
  186. _iwl_legacy_write32(priv, reg, val);
  187. }
  188. static inline void iwl_legacy_clear_bit(struct iwl_priv *p, u32 r, u32 m)
  189. {
  190. unsigned long reg_flags;
  191. spin_lock_irqsave(&p->reg_lock, reg_flags);
  192. __iwl_legacy_clear_bit(__FILE__, __LINE__, p, r, m);
  193. spin_unlock_irqrestore(&p->reg_lock, reg_flags);
  194. }
  195. #else
  196. static inline void iwl_legacy_clear_bit(struct iwl_priv *p, u32 r, u32 m)
  197. {
  198. unsigned long reg_flags;
  199. spin_lock_irqsave(&p->reg_lock, reg_flags);
  200. _iwl_legacy_clear_bit(p, r, m);
  201. spin_unlock_irqrestore(&p->reg_lock, reg_flags);
  202. }
  203. #endif
  204. static inline int _iwl_legacy_grab_nic_access(struct iwl_priv *priv)
  205. {
  206. int ret;
  207. u32 val;
  208. /* this bit wakes up the NIC */
  209. _iwl_legacy_set_bit(priv, CSR_GP_CNTRL,
  210. CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ);
  211. /*
  212. * These bits say the device is running, and should keep running for
  213. * at least a short while (at least as long as MAC_ACCESS_REQ stays 1),
  214. * but they do not indicate that embedded SRAM is restored yet;
  215. * 3945 and 4965 have volatile SRAM, and must save/restore contents
  216. * to/from host DRAM when sleeping/waking for power-saving.
  217. * Each direction takes approximately 1/4 millisecond; with this
  218. * overhead, it's a good idea to grab and hold MAC_ACCESS_REQUEST if a
  219. * series of register accesses are expected (e.g. reading Event Log),
  220. * to keep device from sleeping.
  221. *
  222. * CSR_UCODE_DRV_GP1 register bit MAC_SLEEP == 0 indicates that
  223. * SRAM is okay/restored. We don't check that here because this call
  224. * is just for hardware register access; but GP1 MAC_SLEEP check is a
  225. * good idea before accessing 3945/4965 SRAM (e.g. reading Event Log).
  226. *
  227. */
  228. ret = _iwl_legacy_poll_bit(priv, CSR_GP_CNTRL,
  229. CSR_GP_CNTRL_REG_VAL_MAC_ACCESS_EN,
  230. (CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY |
  231. CSR_GP_CNTRL_REG_FLAG_GOING_TO_SLEEP), 15000);
  232. if (ret < 0) {
  233. val = _iwl_legacy_read32(priv, CSR_GP_CNTRL);
  234. IWL_ERR(priv,
  235. "MAC is in deep sleep!. CSR_GP_CNTRL = 0x%08X\n", val);
  236. _iwl_legacy_write32(priv, CSR_RESET,
  237. CSR_RESET_REG_FLAG_FORCE_NMI);
  238. return -EIO;
  239. }
  240. return 0;
  241. }
  242. #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG
  243. static inline int __iwl_legacy_grab_nic_access(const char *f, u32 l,
  244. struct iwl_priv *priv)
  245. {
  246. IWL_DEBUG_IO(priv, "grabbing nic access - %s %d\n", f, l);
  247. return _iwl_legacy_grab_nic_access(priv);
  248. }
  249. #define iwl_grab_nic_access(priv) \
  250. __iwl_legacy_grab_nic_access(__FILE__, __LINE__, priv)
  251. #else
  252. #define iwl_grab_nic_access(priv) \
  253. _iwl_legacy_grab_nic_access(priv)
  254. #endif
  255. static inline void _iwl_legacy_release_nic_access(struct iwl_priv *priv)
  256. {
  257. _iwl_legacy_clear_bit(priv, CSR_GP_CNTRL,
  258. CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ);
  259. }
  260. #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG
  261. static inline void __iwl_legacy_release_nic_access(const char *f, u32 l,
  262. struct iwl_priv *priv)
  263. {
  264. IWL_DEBUG_IO(priv, "releasing nic access - %s %d\n", f, l);
  265. _iwl_legacy_release_nic_access(priv);
  266. }
  267. #define iwl_release_nic_access(priv) \
  268. __iwl_legacy_release_nic_access(__FILE__, __LINE__, priv)
  269. #else
  270. #define iwl_release_nic_access(priv) \
  271. _iwl_legacy_release_nic_access(priv)
  272. #endif
  273. static inline u32 _iwl_legacy_read_direct32(struct iwl_priv *priv, u32 reg)
  274. {
  275. return _iwl_legacy_read32(priv, reg);
  276. }
  277. #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG
  278. static inline u32 __iwl_legacy_read_direct32(const char *f, u32 l,
  279. struct iwl_priv *priv, u32 reg)
  280. {
  281. u32 value = _iwl_legacy_read_direct32(priv, reg);
  282. IWL_DEBUG_IO(priv,
  283. "read_direct32(0x%4X) = 0x%08x - %s %d\n", reg, value,
  284. f, l);
  285. return value;
  286. }
  287. static inline u32 iwl_legacy_read_direct32(struct iwl_priv *priv, u32 reg)
  288. {
  289. u32 value;
  290. unsigned long reg_flags;
  291. spin_lock_irqsave(&priv->reg_lock, reg_flags);
  292. iwl_grab_nic_access(priv);
  293. value = __iwl_legacy_read_direct32(__FILE__, __LINE__, priv, reg);
  294. iwl_release_nic_access(priv);
  295. spin_unlock_irqrestore(&priv->reg_lock, reg_flags);
  296. return value;
  297. }
  298. #else
  299. static inline u32 iwl_legacy_read_direct32(struct iwl_priv *priv, u32 reg)
  300. {
  301. u32 value;
  302. unsigned long reg_flags;
  303. spin_lock_irqsave(&priv->reg_lock, reg_flags);
  304. iwl_grab_nic_access(priv);
  305. value = _iwl_legacy_read_direct32(priv, reg);
  306. iwl_release_nic_access(priv);
  307. spin_unlock_irqrestore(&priv->reg_lock, reg_flags);
  308. return value;
  309. }
  310. #endif
  311. static inline void _iwl_legacy_write_direct32(struct iwl_priv *priv,
  312. u32 reg, u32 value)
  313. {
  314. _iwl_legacy_write32(priv, reg, value);
  315. }
  316. static inline void
  317. iwl_legacy_write_direct32(struct iwl_priv *priv, u32 reg, u32 value)
  318. {
  319. unsigned long reg_flags;
  320. spin_lock_irqsave(&priv->reg_lock, reg_flags);
  321. if (!iwl_grab_nic_access(priv)) {
  322. _iwl_legacy_write_direct32(priv, reg, value);
  323. iwl_release_nic_access(priv);
  324. }
  325. spin_unlock_irqrestore(&priv->reg_lock, reg_flags);
  326. }
  327. static inline void iwl_legacy_write_reg_buf(struct iwl_priv *priv,
  328. u32 reg, u32 len, u32 *values)
  329. {
  330. u32 count = sizeof(u32);
  331. if ((priv != NULL) && (values != NULL)) {
  332. for (; 0 < len; len -= count, reg += count, values++)
  333. iwl_legacy_write_direct32(priv, reg, *values);
  334. }
  335. }
  336. static inline int _iwl_legacy_poll_direct_bit(struct iwl_priv *priv, u32 addr,
  337. u32 mask, int timeout)
  338. {
  339. int t = 0;
  340. do {
  341. if ((iwl_legacy_read_direct32(priv, addr) & mask) == mask)
  342. return t;
  343. udelay(IWL_POLL_INTERVAL);
  344. t += IWL_POLL_INTERVAL;
  345. } while (t < timeout);
  346. return -ETIMEDOUT;
  347. }
  348. #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG
  349. static inline int __iwl_legacy_poll_direct_bit(const char *f, u32 l,
  350. struct iwl_priv *priv,
  351. u32 addr, u32 mask, int timeout)
  352. {
  353. int ret = _iwl_legacy_poll_direct_bit(priv, addr, mask, timeout);
  354. if (unlikely(ret == -ETIMEDOUT))
  355. IWL_DEBUG_IO(priv, "poll_direct_bit(0x%08X, 0x%08X) - "
  356. "timedout - %s %d\n", addr, mask, f, l);
  357. else
  358. IWL_DEBUG_IO(priv, "poll_direct_bit(0x%08X, 0x%08X) = 0x%08X "
  359. "- %s %d\n", addr, mask, ret, f, l);
  360. return ret;
  361. }
  362. #define iwl_poll_direct_bit(priv, addr, mask, timeout) \
  363. __iwl_legacy_poll_direct_bit(__FILE__, __LINE__, priv, addr, mask, timeout)
  364. #else
  365. #define iwl_poll_direct_bit _iwl_legacy_poll_direct_bit
  366. #endif
  367. static inline u32 _iwl_legacy_read_prph(struct iwl_priv *priv, u32 reg)
  368. {
  369. _iwl_legacy_write_direct32(priv, HBUS_TARG_PRPH_RADDR, reg | (3 << 24));
  370. rmb();
  371. return _iwl_legacy_read_direct32(priv, HBUS_TARG_PRPH_RDAT);
  372. }
  373. static inline u32 iwl_legacy_read_prph(struct iwl_priv *priv, u32 reg)
  374. {
  375. unsigned long reg_flags;
  376. u32 val;
  377. spin_lock_irqsave(&priv->reg_lock, reg_flags);
  378. iwl_grab_nic_access(priv);
  379. val = _iwl_legacy_read_prph(priv, reg);
  380. iwl_release_nic_access(priv);
  381. spin_unlock_irqrestore(&priv->reg_lock, reg_flags);
  382. return val;
  383. }
  384. static inline void _iwl_legacy_write_prph(struct iwl_priv *priv,
  385. u32 addr, u32 val)
  386. {
  387. _iwl_legacy_write_direct32(priv, HBUS_TARG_PRPH_WADDR,
  388. ((addr & 0x0000FFFF) | (3 << 24)));
  389. wmb();
  390. _iwl_legacy_write_direct32(priv, HBUS_TARG_PRPH_WDAT, val);
  391. }
  392. static inline void
  393. iwl_legacy_write_prph(struct iwl_priv *priv, u32 addr, u32 val)
  394. {
  395. unsigned long reg_flags;
  396. spin_lock_irqsave(&priv->reg_lock, reg_flags);
  397. if (!iwl_grab_nic_access(priv)) {
  398. _iwl_legacy_write_prph(priv, addr, val);
  399. iwl_release_nic_access(priv);
  400. }
  401. spin_unlock_irqrestore(&priv->reg_lock, reg_flags);
  402. }
  403. #define _iwl_legacy_set_bits_prph(priv, reg, mask) \
  404. _iwl_legacy_write_prph(priv, reg, (_iwl_legacy_read_prph(priv, reg) | mask))
  405. static inline void
  406. iwl_legacy_set_bits_prph(struct iwl_priv *priv, u32 reg, u32 mask)
  407. {
  408. unsigned long reg_flags;
  409. spin_lock_irqsave(&priv->reg_lock, reg_flags);
  410. iwl_grab_nic_access(priv);
  411. _iwl_legacy_set_bits_prph(priv, reg, mask);
  412. iwl_release_nic_access(priv);
  413. spin_unlock_irqrestore(&priv->reg_lock, reg_flags);
  414. }
  415. #define _iwl_legacy_set_bits_mask_prph(priv, reg, bits, mask) \
  416. _iwl_legacy_write_prph(priv, reg, \
  417. ((_iwl_legacy_read_prph(priv, reg) & mask) | bits))
  418. static inline void iwl_legacy_set_bits_mask_prph(struct iwl_priv *priv, u32 reg,
  419. u32 bits, u32 mask)
  420. {
  421. unsigned long reg_flags;
  422. spin_lock_irqsave(&priv->reg_lock, reg_flags);
  423. iwl_grab_nic_access(priv);
  424. _iwl_legacy_set_bits_mask_prph(priv, reg, bits, mask);
  425. iwl_release_nic_access(priv);
  426. spin_unlock_irqrestore(&priv->reg_lock, reg_flags);
  427. }
  428. static inline void iwl_legacy_clear_bits_prph(struct iwl_priv
  429. *priv, u32 reg, u32 mask)
  430. {
  431. unsigned long reg_flags;
  432. u32 val;
  433. spin_lock_irqsave(&priv->reg_lock, reg_flags);
  434. iwl_grab_nic_access(priv);
  435. val = _iwl_legacy_read_prph(priv, reg);
  436. _iwl_legacy_write_prph(priv, reg, (val & ~mask));
  437. iwl_release_nic_access(priv);
  438. spin_unlock_irqrestore(&priv->reg_lock, reg_flags);
  439. }
  440. static inline u32 iwl_legacy_read_targ_mem(struct iwl_priv *priv, u32 addr)
  441. {
  442. unsigned long reg_flags;
  443. u32 value;
  444. spin_lock_irqsave(&priv->reg_lock, reg_flags);
  445. iwl_grab_nic_access(priv);
  446. _iwl_legacy_write_direct32(priv, HBUS_TARG_MEM_RADDR, addr);
  447. rmb();
  448. value = _iwl_legacy_read_direct32(priv, HBUS_TARG_MEM_RDAT);
  449. iwl_release_nic_access(priv);
  450. spin_unlock_irqrestore(&priv->reg_lock, reg_flags);
  451. return value;
  452. }
  453. static inline void
  454. iwl_legacy_write_targ_mem(struct iwl_priv *priv, u32 addr, u32 val)
  455. {
  456. unsigned long reg_flags;
  457. spin_lock_irqsave(&priv->reg_lock, reg_flags);
  458. if (!iwl_grab_nic_access(priv)) {
  459. _iwl_legacy_write_direct32(priv, HBUS_TARG_MEM_WADDR, addr);
  460. wmb();
  461. _iwl_legacy_write_direct32(priv, HBUS_TARG_MEM_WDAT, val);
  462. iwl_release_nic_access(priv);
  463. }
  464. spin_unlock_irqrestore(&priv->reg_lock, reg_flags);
  465. }
  466. static inline void
  467. iwl_legacy_write_targ_mem_buf(struct iwl_priv *priv, u32 addr,
  468. u32 len, u32 *values)
  469. {
  470. unsigned long reg_flags;
  471. spin_lock_irqsave(&priv->reg_lock, reg_flags);
  472. if (!iwl_grab_nic_access(priv)) {
  473. _iwl_legacy_write_direct32(priv, HBUS_TARG_MEM_WADDR, addr);
  474. wmb();
  475. for (; 0 < len; len -= sizeof(u32), values++)
  476. _iwl_legacy_write_direct32(priv,
  477. HBUS_TARG_MEM_WDAT, *values);
  478. iwl_release_nic_access(priv);
  479. }
  480. spin_unlock_irqrestore(&priv->reg_lock, reg_flags);
  481. }
  482. #endif