cvmx-address.h 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. /***********************license start***************
  2. * Author: Cavium Networks
  3. *
  4. * Contact: support@caviumnetworks.com
  5. * This file is part of the OCTEON SDK
  6. *
  7. * Copyright (c) 2003-2009 Cavium Networks
  8. *
  9. * This file is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License, Version 2, as
  11. * published by the Free Software Foundation.
  12. *
  13. * This file is distributed in the hope that it will be useful, but
  14. * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
  15. * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
  16. * NONINFRINGEMENT. See the GNU General Public License for more
  17. * details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this file; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  22. * or visit http://www.gnu.org/licenses/.
  23. *
  24. * This file may also be available under a different license from Cavium.
  25. * Contact Cavium Networks for more information
  26. ***********************license end**************************************/
  27. /**
  28. * Typedefs and defines for working with Octeon physical addresses.
  29. *
  30. */
  31. #ifndef __CVMX_ADDRESS_H__
  32. #define __CVMX_ADDRESS_H__
  33. #if 0
  34. typedef enum {
  35. CVMX_MIPS_SPACE_XKSEG = 3LL,
  36. CVMX_MIPS_SPACE_XKPHYS = 2LL,
  37. CVMX_MIPS_SPACE_XSSEG = 1LL,
  38. CVMX_MIPS_SPACE_XUSEG = 0LL
  39. } cvmx_mips_space_t;
  40. #endif
  41. typedef enum {
  42. CVMX_MIPS_XKSEG_SPACE_KSEG0 = 0LL,
  43. CVMX_MIPS_XKSEG_SPACE_KSEG1 = 1LL,
  44. CVMX_MIPS_XKSEG_SPACE_SSEG = 2LL,
  45. CVMX_MIPS_XKSEG_SPACE_KSEG3 = 3LL
  46. } cvmx_mips_xkseg_space_t;
  47. /* decodes <14:13> of a kseg3 window address */
  48. typedef enum {
  49. CVMX_ADD_WIN_SCR = 0L,
  50. /* see cvmx_add_win_dma_dec_t for further decode */
  51. CVMX_ADD_WIN_DMA = 1L,
  52. CVMX_ADD_WIN_UNUSED = 2L,
  53. CVMX_ADD_WIN_UNUSED2 = 3L
  54. } cvmx_add_win_dec_t;
  55. /* decode within DMA space */
  56. typedef enum {
  57. /*
  58. * Add store data to the write buffer entry, allocating it if
  59. * necessary.
  60. */
  61. CVMX_ADD_WIN_DMA_ADD = 0L,
  62. /* send out the write buffer entry to DRAM */
  63. CVMX_ADD_WIN_DMA_SENDMEM = 1L,
  64. /* store data must be normal DRAM memory space address in this case */
  65. /* send out the write buffer entry as an IOBDMA command */
  66. CVMX_ADD_WIN_DMA_SENDDMA = 2L,
  67. /* see CVMX_ADD_WIN_DMA_SEND_DEC for data contents */
  68. /* send out the write buffer entry as an IO write */
  69. CVMX_ADD_WIN_DMA_SENDIO = 3L,
  70. /* store data must be normal IO space address in this case */
  71. /* send out a single-tick command on the NCB bus */
  72. CVMX_ADD_WIN_DMA_SENDSINGLE = 4L,
  73. /* no write buffer data needed/used */
  74. } cvmx_add_win_dma_dec_t;
  75. /*
  76. * Physical Address Decode
  77. *
  78. * Octeon-I HW never interprets this X (<39:36> reserved
  79. * for future expansion), software should set to 0.
  80. *
  81. * - 0x0 XXX0 0000 0000 to DRAM Cached
  82. * - 0x0 XXX0 0FFF FFFF
  83. *
  84. * - 0x0 XXX0 1000 0000 to Boot Bus Uncached (Converted to 0x1 00X0 1000 0000
  85. * - 0x0 XXX0 1FFF FFFF + EJTAG to 0x1 00X0 1FFF FFFF)
  86. *
  87. * - 0x0 XXX0 2000 0000 to DRAM Cached
  88. * - 0x0 XXXF FFFF FFFF
  89. *
  90. * - 0x1 00X0 0000 0000 to Boot Bus Uncached
  91. * - 0x1 00XF FFFF FFFF
  92. *
  93. * - 0x1 01X0 0000 0000 to Other NCB Uncached
  94. * - 0x1 FFXF FFFF FFFF devices
  95. *
  96. * Decode of all Octeon addresses
  97. */
  98. typedef union {
  99. uint64_t u64;
  100. /* mapped or unmapped virtual address */
  101. struct {
  102. uint64_t R:2;
  103. uint64_t offset:62;
  104. } sva;
  105. /* mapped USEG virtual addresses (typically) */
  106. struct {
  107. uint64_t zeroes:33;
  108. uint64_t offset:31;
  109. } suseg;
  110. /* mapped or unmapped virtual address */
  111. struct {
  112. uint64_t ones:33;
  113. uint64_t sp:2;
  114. uint64_t offset:29;
  115. } sxkseg;
  116. /*
  117. * physical address accessed through xkphys unmapped virtual
  118. * address.
  119. */
  120. struct {
  121. uint64_t R:2; /* CVMX_MIPS_SPACE_XKPHYS in this case */
  122. uint64_t cca:3; /* ignored by octeon */
  123. uint64_t mbz:10;
  124. uint64_t pa:49; /* physical address */
  125. } sxkphys;
  126. /* physical address */
  127. struct {
  128. uint64_t mbz:15;
  129. /* if set, the address is uncached and resides on MCB bus */
  130. uint64_t is_io:1;
  131. /*
  132. * the hardware ignores this field when is_io==0, else
  133. * device ID.
  134. */
  135. uint64_t did:8;
  136. /* the hardware ignores <39:36> in Octeon I */
  137. uint64_t unaddr:4;
  138. uint64_t offset:36;
  139. } sphys;
  140. /* physical mem address */
  141. struct {
  142. /* techically, <47:40> are dont-cares */
  143. uint64_t zeroes:24;
  144. /* the hardware ignores <39:36> in Octeon I */
  145. uint64_t unaddr:4;
  146. uint64_t offset:36;
  147. } smem;
  148. /* physical IO address */
  149. struct {
  150. uint64_t mem_region:2;
  151. uint64_t mbz:13;
  152. /* 1 in this case */
  153. uint64_t is_io:1;
  154. /*
  155. * The hardware ignores this field when is_io==0, else
  156. * device ID.
  157. */
  158. uint64_t did:8;
  159. /* the hardware ignores <39:36> in Octeon I */
  160. uint64_t unaddr:4;
  161. uint64_t offset:36;
  162. } sio;
  163. /*
  164. * Scratchpad virtual address - accessed through a window at
  165. * the end of kseg3
  166. */
  167. struct {
  168. uint64_t ones:49;
  169. /* CVMX_ADD_WIN_SCR (0) in this case */
  170. cvmx_add_win_dec_t csrdec:2;
  171. uint64_t addr:13;
  172. } sscr;
  173. /* there should only be stores to IOBDMA space, no loads */
  174. /*
  175. * IOBDMA virtual address - accessed through a window at the
  176. * end of kseg3
  177. */
  178. struct {
  179. uint64_t ones:49;
  180. uint64_t csrdec:2; /* CVMX_ADD_WIN_DMA (1) in this case */
  181. uint64_t unused2:3;
  182. uint64_t type:3;
  183. uint64_t addr:7;
  184. } sdma;
  185. struct {
  186. uint64_t didspace:24;
  187. uint64_t unused:40;
  188. } sfilldidspace;
  189. } cvmx_addr_t;
  190. /* These macros for used by 32 bit applications */
  191. #define CVMX_MIPS32_SPACE_KSEG0 1l
  192. #define CVMX_ADD_SEG32(segment, add) \
  193. (((int32_t)segment << 31) | (int32_t)(add))
  194. /*
  195. * Currently all IOs are performed using XKPHYS addressing. Linux uses
  196. * the CvmMemCtl register to enable XKPHYS addressing to IO space from
  197. * user mode. Future OSes may need to change the upper bits of IO
  198. * addresses. The following define controls the upper two bits for all
  199. * IO addresses generated by the simple executive library.
  200. */
  201. #define CVMX_IO_SEG CVMX_MIPS_SPACE_XKPHYS
  202. /* These macros simplify the process of creating common IO addresses */
  203. #define CVMX_ADD_SEG(segment, add) ((((uint64_t)segment) << 62) | (add))
  204. #ifndef CVMX_ADD_IO_SEG
  205. #define CVMX_ADD_IO_SEG(add) CVMX_ADD_SEG(CVMX_IO_SEG, (add))
  206. #endif
  207. #define CVMX_ADDR_DIDSPACE(did) (((CVMX_IO_SEG) << 22) | ((1ULL) << 8) | (did))
  208. #define CVMX_ADDR_DID(did) (CVMX_ADDR_DIDSPACE(did) << 40)
  209. #define CVMX_FULL_DID(did, subdid) (((did) << 3) | (subdid))
  210. /* from include/ncb_rsl_id.v */
  211. #define CVMX_OCT_DID_MIS 0ULL /* misc stuff */
  212. #define CVMX_OCT_DID_GMX0 1ULL
  213. #define CVMX_OCT_DID_GMX1 2ULL
  214. #define CVMX_OCT_DID_PCI 3ULL
  215. #define CVMX_OCT_DID_KEY 4ULL
  216. #define CVMX_OCT_DID_FPA 5ULL
  217. #define CVMX_OCT_DID_DFA 6ULL
  218. #define CVMX_OCT_DID_ZIP 7ULL
  219. #define CVMX_OCT_DID_RNG 8ULL
  220. #define CVMX_OCT_DID_IPD 9ULL
  221. #define CVMX_OCT_DID_PKT 10ULL
  222. #define CVMX_OCT_DID_TIM 11ULL
  223. #define CVMX_OCT_DID_TAG 12ULL
  224. /* the rest are not on the IO bus */
  225. #define CVMX_OCT_DID_L2C 16ULL
  226. #define CVMX_OCT_DID_LMC 17ULL
  227. #define CVMX_OCT_DID_SPX0 18ULL
  228. #define CVMX_OCT_DID_SPX1 19ULL
  229. #define CVMX_OCT_DID_PIP 20ULL
  230. #define CVMX_OCT_DID_ASX0 22ULL
  231. #define CVMX_OCT_DID_ASX1 23ULL
  232. #define CVMX_OCT_DID_IOB 30ULL
  233. #define CVMX_OCT_DID_PKT_SEND CVMX_FULL_DID(CVMX_OCT_DID_PKT, 2ULL)
  234. #define CVMX_OCT_DID_TAG_SWTAG CVMX_FULL_DID(CVMX_OCT_DID_TAG, 0ULL)
  235. #define CVMX_OCT_DID_TAG_TAG1 CVMX_FULL_DID(CVMX_OCT_DID_TAG, 1ULL)
  236. #define CVMX_OCT_DID_TAG_TAG2 CVMX_FULL_DID(CVMX_OCT_DID_TAG, 2ULL)
  237. #define CVMX_OCT_DID_TAG_TAG3 CVMX_FULL_DID(CVMX_OCT_DID_TAG, 3ULL)
  238. #define CVMX_OCT_DID_TAG_NULL_RD CVMX_FULL_DID(CVMX_OCT_DID_TAG, 4ULL)
  239. #define CVMX_OCT_DID_TAG_CSR CVMX_FULL_DID(CVMX_OCT_DID_TAG, 7ULL)
  240. #define CVMX_OCT_DID_FAU_FAI CVMX_FULL_DID(CVMX_OCT_DID_IOB, 0ULL)
  241. #define CVMX_OCT_DID_TIM_CSR CVMX_FULL_DID(CVMX_OCT_DID_TIM, 0ULL)
  242. #define CVMX_OCT_DID_KEY_RW CVMX_FULL_DID(CVMX_OCT_DID_KEY, 0ULL)
  243. #define CVMX_OCT_DID_PCI_6 CVMX_FULL_DID(CVMX_OCT_DID_PCI, 6ULL)
  244. #define CVMX_OCT_DID_MIS_BOO CVMX_FULL_DID(CVMX_OCT_DID_MIS, 0ULL)
  245. #define CVMX_OCT_DID_PCI_RML CVMX_FULL_DID(CVMX_OCT_DID_PCI, 0ULL)
  246. #define CVMX_OCT_DID_IPD_CSR CVMX_FULL_DID(CVMX_OCT_DID_IPD, 7ULL)
  247. #define CVMX_OCT_DID_DFA_CSR CVMX_FULL_DID(CVMX_OCT_DID_DFA, 7ULL)
  248. #define CVMX_OCT_DID_MIS_CSR CVMX_FULL_DID(CVMX_OCT_DID_MIS, 7ULL)
  249. #define CVMX_OCT_DID_ZIP_CSR CVMX_FULL_DID(CVMX_OCT_DID_ZIP, 0ULL)
  250. #endif /* __CVMX_ADDRESS_H__ */