iwl-io.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
  2. /*
  3. * Copyright (C) 2018-2021 Intel Corporation
  4. */
  5. #ifndef __iwl_io_h__
  6. #define __iwl_io_h__
  7. #include "iwl-devtrace.h"
  8. #include "iwl-trans.h"
  9. void iwl_write8(struct iwl_trans *trans, u32 ofs, u8 val);
  10. void iwl_write32(struct iwl_trans *trans, u32 ofs, u32 val);
  11. void iwl_write64(struct iwl_trans *trans, u64 ofs, u64 val);
  12. u32 iwl_read32(struct iwl_trans *trans, u32 ofs);
  13. static inline void iwl_set_bit(struct iwl_trans *trans, u32 reg, u32 mask)
  14. {
  15. iwl_trans_set_bits_mask(trans, reg, mask, mask);
  16. }
  17. static inline void iwl_clear_bit(struct iwl_trans *trans, u32 reg, u32 mask)
  18. {
  19. iwl_trans_set_bits_mask(trans, reg, mask, 0);
  20. }
  21. int iwl_poll_bit(struct iwl_trans *trans, u32 addr,
  22. u32 bits, u32 mask, int timeout);
  23. int iwl_poll_direct_bit(struct iwl_trans *trans, u32 addr, u32 mask,
  24. int timeout);
  25. u32 iwl_read_direct32(struct iwl_trans *trans, u32 reg);
  26. void iwl_write_direct32(struct iwl_trans *trans, u32 reg, u32 value);
  27. void iwl_write_direct64(struct iwl_trans *trans, u64 reg, u64 value);
  28. u32 iwl_read_prph_no_grab(struct iwl_trans *trans, u32 ofs);
  29. u32 iwl_read_prph(struct iwl_trans *trans, u32 ofs);
  30. void iwl_write_prph_no_grab(struct iwl_trans *trans, u32 ofs, u32 val);
  31. void iwl_write_prph64_no_grab(struct iwl_trans *trans, u64 ofs, u64 val);
  32. void iwl_write_prph_delay(struct iwl_trans *trans, u32 ofs,
  33. u32 val, u32 delay_ms);
  34. static inline void iwl_write_prph(struct iwl_trans *trans, u32 ofs, u32 val)
  35. {
  36. iwl_write_prph_delay(trans, ofs, val, 0);
  37. }
  38. int iwl_poll_prph_bit(struct iwl_trans *trans, u32 addr,
  39. u32 bits, u32 mask, int timeout);
  40. void iwl_set_bits_prph(struct iwl_trans *trans, u32 ofs, u32 mask);
  41. void iwl_set_bits_mask_prph(struct iwl_trans *trans, u32 ofs,
  42. u32 bits, u32 mask);
  43. void iwl_clear_bits_prph(struct iwl_trans *trans, u32 ofs, u32 mask);
  44. void iwl_force_nmi(struct iwl_trans *trans);
  45. int iwl_finish_nic_init(struct iwl_trans *trans);
  46. /* Error handling */
  47. int iwl_dump_fh(struct iwl_trans *trans, char **buf);
  48. /*
  49. * UMAC periphery address space changed from 0xA00000 to 0xD00000 starting from
  50. * device family AX200. So peripheries used in families above and below AX200
  51. * should go through iwl_..._umac_..._prph.
  52. */
  53. static inline u32 iwl_umac_prph(struct iwl_trans *trans, u32 ofs)
  54. {
  55. return ofs + trans->trans_cfg->umac_prph_offset;
  56. }
  57. static inline u32 iwl_read_umac_prph_no_grab(struct iwl_trans *trans, u32 ofs)
  58. {
  59. return iwl_read_prph_no_grab(trans, ofs +
  60. trans->trans_cfg->umac_prph_offset);
  61. }
  62. static inline u32 iwl_read_umac_prph(struct iwl_trans *trans, u32 ofs)
  63. {
  64. return iwl_read_prph(trans, ofs + trans->trans_cfg->umac_prph_offset);
  65. }
  66. static inline void iwl_write_umac_prph_no_grab(struct iwl_trans *trans, u32 ofs,
  67. u32 val)
  68. {
  69. iwl_write_prph_no_grab(trans, ofs + trans->trans_cfg->umac_prph_offset,
  70. val);
  71. }
  72. static inline void iwl_write_umac_prph(struct iwl_trans *trans, u32 ofs,
  73. u32 val)
  74. {
  75. iwl_write_prph(trans, ofs + trans->trans_cfg->umac_prph_offset, val);
  76. }
  77. static inline int iwl_poll_umac_prph_bit(struct iwl_trans *trans, u32 addr,
  78. u32 bits, u32 mask, int timeout)
  79. {
  80. return iwl_poll_prph_bit(trans, addr +
  81. trans->trans_cfg->umac_prph_offset,
  82. bits, mask, timeout);
  83. }
  84. #endif