nhi_regs.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Thunderbolt driver - NHI registers
  4. *
  5. * Copyright (c) 2014 Andreas Noever <[email protected]>
  6. * Copyright (C) 2018, Intel Corporation
  7. */
  8. #ifndef NHI_REGS_H_
  9. #define NHI_REGS_H_
  10. #include <linux/types.h>
  11. enum ring_flags {
  12. RING_FLAG_ISOCH_ENABLE = 1 << 27, /* TX only? */
  13. RING_FLAG_E2E_FLOW_CONTROL = 1 << 28,
  14. RING_FLAG_PCI_NO_SNOOP = 1 << 29,
  15. RING_FLAG_RAW = 1 << 30, /* ignore EOF/SOF mask, include checksum */
  16. RING_FLAG_ENABLE = 1 << 31,
  17. };
  18. /**
  19. * struct ring_desc - TX/RX ring entry
  20. *
  21. * For TX set length/eof/sof.
  22. * For RX length/eof/sof are set by the NHI.
  23. */
  24. struct ring_desc {
  25. u64 phys;
  26. u32 length:12;
  27. u32 eof:4;
  28. u32 sof:4;
  29. enum ring_desc_flags flags:12;
  30. u32 time; /* write zero */
  31. } __packed;
  32. /* NHI registers in bar 0 */
  33. /*
  34. * 16 bytes per entry, one entry for every hop (REG_HOP_COUNT)
  35. * 00: physical pointer to an array of struct ring_desc
  36. * 08: ring tail (set by NHI)
  37. * 10: ring head (index of first non posted descriptor)
  38. * 12: descriptor count
  39. */
  40. #define REG_TX_RING_BASE 0x00000
  41. /*
  42. * 16 bytes per entry, one entry for every hop (REG_HOP_COUNT)
  43. * 00: physical pointer to an array of struct ring_desc
  44. * 08: ring head (index of first not posted descriptor)
  45. * 10: ring tail (set by NHI)
  46. * 12: descriptor count
  47. * 14: max frame sizes (anything larger than 0x100 has no effect)
  48. */
  49. #define REG_RX_RING_BASE 0x08000
  50. /*
  51. * 32 bytes per entry, one entry for every hop (REG_HOP_COUNT)
  52. * 00: enum_ring_flags
  53. * 04: isoch time stamp ?? (write 0)
  54. * ..: unknown
  55. */
  56. #define REG_TX_OPTIONS_BASE 0x19800
  57. /*
  58. * 32 bytes per entry, one entry for every hop (REG_HOP_COUNT)
  59. * 00: enum ring_flags
  60. * If RING_FLAG_E2E_FLOW_CONTROL is set then bits 13-23 must be set to
  61. * the corresponding TX hop id.
  62. * 04: EOF/SOF mask (ignored for RING_FLAG_RAW rings)
  63. * ..: unknown
  64. */
  65. #define REG_RX_OPTIONS_BASE 0x29800
  66. #define REG_RX_OPTIONS_E2E_HOP_MASK GENMASK(22, 12)
  67. #define REG_RX_OPTIONS_E2E_HOP_SHIFT 12
  68. /*
  69. * three bitfields: tx, rx, rx overflow
  70. * Every bitfield contains one bit for every hop (REG_HOP_COUNT).
  71. * New interrupts are fired only after ALL registers have been
  72. * read (even those containing only disabled rings).
  73. */
  74. #define REG_RING_NOTIFY_BASE 0x37800
  75. #define RING_NOTIFY_REG_COUNT(nhi) ((31 + 3 * nhi->hop_count) / 32)
  76. #define REG_RING_INT_CLEAR 0x37808
  77. /*
  78. * two bitfields: rx, tx
  79. * Both bitfields contains one bit for every hop (REG_HOP_COUNT). To
  80. * enable/disable interrupts set/clear the corresponding bits.
  81. */
  82. #define REG_RING_INTERRUPT_BASE 0x38200
  83. #define RING_INTERRUPT_REG_COUNT(nhi) ((31 + 2 * nhi->hop_count) / 32)
  84. #define REG_RING_INTERRUPT_MASK_CLEAR_BASE 0x38208
  85. #define REG_INT_THROTTLING_RATE 0x38c00
  86. /* Interrupt Vector Allocation */
  87. #define REG_INT_VEC_ALLOC_BASE 0x38c40
  88. #define REG_INT_VEC_ALLOC_BITS 4
  89. #define REG_INT_VEC_ALLOC_MASK GENMASK(3, 0)
  90. #define REG_INT_VEC_ALLOC_REGS (32 / REG_INT_VEC_ALLOC_BITS)
  91. /* The last 11 bits contain the number of hops supported by the NHI port. */
  92. #define REG_HOP_COUNT 0x39640
  93. #define REG_DMA_MISC 0x39864
  94. #define REG_DMA_MISC_INT_AUTO_CLEAR BIT(2)
  95. #define REG_DMA_MISC_DISABLE_AUTO_CLEAR BIT(17)
  96. #define REG_INMAIL_DATA 0x39900
  97. #define REG_INMAIL_CMD 0x39904
  98. #define REG_INMAIL_CMD_MASK GENMASK(7, 0)
  99. #define REG_INMAIL_ERROR BIT(30)
  100. #define REG_INMAIL_OP_REQUEST BIT(31)
  101. #define REG_OUTMAIL_CMD 0x3990c
  102. #define REG_OUTMAIL_CMD_OPMODE_SHIFT 8
  103. #define REG_OUTMAIL_CMD_OPMODE_MASK GENMASK(11, 8)
  104. #define REG_FW_STS 0x39944
  105. #define REG_FW_STS_NVM_AUTH_DONE BIT(31)
  106. #define REG_FW_STS_CIO_RESET_REQ BIT(30)
  107. #define REG_FW_STS_ICM_EN_CPU BIT(2)
  108. #define REG_FW_STS_ICM_EN_INVERT BIT(1)
  109. #define REG_FW_STS_ICM_EN BIT(0)
  110. /* ICL NHI VSEC registers */
  111. /* FW ready */
  112. #define VS_CAP_9 0xc8
  113. #define VS_CAP_9_FW_READY BIT(31)
  114. /* UUID */
  115. #define VS_CAP_10 0xcc
  116. #define VS_CAP_11 0xd0
  117. /* LTR */
  118. #define VS_CAP_15 0xe0
  119. #define VS_CAP_16 0xe4
  120. /* TBT2PCIe */
  121. #define VS_CAP_18 0xec
  122. #define VS_CAP_18_DONE BIT(0)
  123. /* PCIe2TBT */
  124. #define VS_CAP_19 0xf0
  125. #define VS_CAP_19_VALID BIT(0)
  126. #define VS_CAP_19_CMD_SHIFT 1
  127. #define VS_CAP_19_CMD_MASK GENMASK(7, 1)
  128. /* Force power */
  129. #define VS_CAP_22 0xfc
  130. #define VS_CAP_22_FORCE_POWER BIT(1)
  131. #define VS_CAP_22_DMA_DELAY_MASK GENMASK(31, 24)
  132. #define VS_CAP_22_DMA_DELAY_SHIFT 24
  133. /**
  134. * enum icl_lc_mailbox_cmd - ICL specific LC mailbox commands
  135. * @ICL_LC_GO2SX: Ask LC to enter Sx without wake
  136. * @ICL_LC_GO2SX_NO_WAKE: Ask LC to enter Sx with wake
  137. * @ICL_LC_PREPARE_FOR_RESET: Prepare LC for reset
  138. */
  139. enum icl_lc_mailbox_cmd {
  140. ICL_LC_GO2SX = 0x02,
  141. ICL_LC_GO2SX_NO_WAKE = 0x03,
  142. ICL_LC_PREPARE_FOR_RESET = 0x21,
  143. };
  144. #endif