cvmx-address.h 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  1. /***********************license start***************
  2. * Author: Cavium Networks
  3. *
  4. * Contact: [email protected]
  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. #ifdef __BIG_ENDIAN_BITFIELD
  101. /* mapped or unmapped virtual address */
  102. struct {
  103. uint64_t R:2;
  104. uint64_t offset:62;
  105. } sva;
  106. /* mapped USEG virtual addresses (typically) */
  107. struct {
  108. uint64_t zeroes:33;
  109. uint64_t offset:31;
  110. } suseg;
  111. /* mapped or unmapped virtual address */
  112. struct {
  113. uint64_t ones:33;
  114. uint64_t sp:2;
  115. uint64_t offset:29;
  116. } sxkseg;
  117. /*
  118. * physical address accessed through xkphys unmapped virtual
  119. * address.
  120. */
  121. struct {
  122. uint64_t R:2; /* CVMX_MIPS_SPACE_XKPHYS in this case */
  123. uint64_t cca:3; /* ignored by octeon */
  124. uint64_t mbz:10;
  125. uint64_t pa:49; /* physical address */
  126. } sxkphys;
  127. /* physical address */
  128. struct {
  129. uint64_t mbz:15;
  130. /* if set, the address is uncached and resides on MCB bus */
  131. uint64_t is_io:1;
  132. /*
  133. * the hardware ignores this field when is_io==0, else
  134. * device ID.
  135. */
  136. uint64_t did:8;
  137. /* the hardware ignores <39:36> in Octeon I */
  138. uint64_t unaddr:4;
  139. uint64_t offset:36;
  140. } sphys;
  141. /* physical mem address */
  142. struct {
  143. /* technically, <47:40> are dont-cares */
  144. uint64_t zeroes:24;
  145. /* the hardware ignores <39:36> in Octeon I */
  146. uint64_t unaddr:4;
  147. uint64_t offset:36;
  148. } smem;
  149. /* physical IO address */
  150. struct {
  151. uint64_t mem_region:2;
  152. uint64_t mbz:13;
  153. /* 1 in this case */
  154. uint64_t is_io:1;
  155. /*
  156. * The hardware ignores this field when is_io==0, else
  157. * device ID.
  158. */
  159. uint64_t did:8;
  160. /* the hardware ignores <39:36> in Octeon I */
  161. uint64_t unaddr:4;
  162. uint64_t offset:36;
  163. } sio;
  164. /*
  165. * Scratchpad virtual address - accessed through a window at
  166. * the end of kseg3
  167. */
  168. struct {
  169. uint64_t ones:49;
  170. /* CVMX_ADD_WIN_SCR (0) in this case */
  171. cvmx_add_win_dec_t csrdec:2;
  172. uint64_t addr:13;
  173. } sscr;
  174. /* there should only be stores to IOBDMA space, no loads */
  175. /*
  176. * IOBDMA virtual address - accessed through a window at the
  177. * end of kseg3
  178. */
  179. struct {
  180. uint64_t ones:49;
  181. uint64_t csrdec:2; /* CVMX_ADD_WIN_DMA (1) in this case */
  182. uint64_t unused2:3;
  183. uint64_t type:3;
  184. uint64_t addr:7;
  185. } sdma;
  186. struct {
  187. uint64_t didspace:24;
  188. uint64_t unused:40;
  189. } sfilldidspace;
  190. #else
  191. struct {
  192. uint64_t offset:62;
  193. uint64_t R:2;
  194. } sva;
  195. struct {
  196. uint64_t offset:31;
  197. uint64_t zeroes:33;
  198. } suseg;
  199. struct {
  200. uint64_t offset:29;
  201. uint64_t sp:2;
  202. uint64_t ones:33;
  203. } sxkseg;
  204. struct {
  205. uint64_t pa:49;
  206. uint64_t mbz:10;
  207. uint64_t cca:3;
  208. uint64_t R:2;
  209. } sxkphys;
  210. struct {
  211. uint64_t offset:36;
  212. uint64_t unaddr:4;
  213. uint64_t did:8;
  214. uint64_t is_io:1;
  215. uint64_t mbz:15;
  216. } sphys;
  217. struct {
  218. uint64_t offset:36;
  219. uint64_t unaddr:4;
  220. uint64_t zeroes:24;
  221. } smem;
  222. struct {
  223. uint64_t offset:36;
  224. uint64_t unaddr:4;
  225. uint64_t did:8;
  226. uint64_t is_io:1;
  227. uint64_t mbz:13;
  228. uint64_t mem_region:2;
  229. } sio;
  230. struct {
  231. uint64_t addr:13;
  232. cvmx_add_win_dec_t csrdec:2;
  233. uint64_t ones:49;
  234. } sscr;
  235. struct {
  236. uint64_t addr:7;
  237. uint64_t type:3;
  238. uint64_t unused2:3;
  239. uint64_t csrdec:2;
  240. uint64_t ones:49;
  241. } sdma;
  242. struct {
  243. uint64_t unused:40;
  244. uint64_t didspace:24;
  245. } sfilldidspace;
  246. #endif
  247. } cvmx_addr_t;
  248. /* These macros for used by 32 bit applications */
  249. #define CVMX_MIPS32_SPACE_KSEG0 1l
  250. #define CVMX_ADD_SEG32(segment, add) \
  251. (((int32_t)segment << 31) | (int32_t)(add))
  252. /*
  253. * Currently all IOs are performed using XKPHYS addressing. Linux uses
  254. * the CvmMemCtl register to enable XKPHYS addressing to IO space from
  255. * user mode. Future OSes may need to change the upper bits of IO
  256. * addresses. The following define controls the upper two bits for all
  257. * IO addresses generated by the simple executive library.
  258. */
  259. #define CVMX_IO_SEG CVMX_MIPS_SPACE_XKPHYS
  260. /* These macros simplify the process of creating common IO addresses */
  261. #define CVMX_ADD_SEG(segment, add) ((((uint64_t)segment) << 62) | (add))
  262. #ifndef CVMX_ADD_IO_SEG
  263. #define CVMX_ADD_IO_SEG(add) CVMX_ADD_SEG(CVMX_IO_SEG, (add))
  264. #endif
  265. #define CVMX_ADDR_DIDSPACE(did) (((CVMX_IO_SEG) << 22) | ((1ULL) << 8) | (did))
  266. #define CVMX_ADDR_DID(did) (CVMX_ADDR_DIDSPACE(did) << 40)
  267. #define CVMX_FULL_DID(did, subdid) (((did) << 3) | (subdid))
  268. /* from include/ncb_rsl_id.v */
  269. #define CVMX_OCT_DID_MIS 0ULL /* misc stuff */
  270. #define CVMX_OCT_DID_GMX0 1ULL
  271. #define CVMX_OCT_DID_GMX1 2ULL
  272. #define CVMX_OCT_DID_PCI 3ULL
  273. #define CVMX_OCT_DID_KEY 4ULL
  274. #define CVMX_OCT_DID_FPA 5ULL
  275. #define CVMX_OCT_DID_DFA 6ULL
  276. #define CVMX_OCT_DID_ZIP 7ULL
  277. #define CVMX_OCT_DID_RNG 8ULL
  278. #define CVMX_OCT_DID_IPD 9ULL
  279. #define CVMX_OCT_DID_PKT 10ULL
  280. #define CVMX_OCT_DID_TIM 11ULL
  281. #define CVMX_OCT_DID_TAG 12ULL
  282. /* the rest are not on the IO bus */
  283. #define CVMX_OCT_DID_L2C 16ULL
  284. #define CVMX_OCT_DID_LMC 17ULL
  285. #define CVMX_OCT_DID_SPX0 18ULL
  286. #define CVMX_OCT_DID_SPX1 19ULL
  287. #define CVMX_OCT_DID_PIP 20ULL
  288. #define CVMX_OCT_DID_ASX0 22ULL
  289. #define CVMX_OCT_DID_ASX1 23ULL
  290. #define CVMX_OCT_DID_IOB 30ULL
  291. #define CVMX_OCT_DID_PKT_SEND CVMX_FULL_DID(CVMX_OCT_DID_PKT, 2ULL)
  292. #define CVMX_OCT_DID_TAG_SWTAG CVMX_FULL_DID(CVMX_OCT_DID_TAG, 0ULL)
  293. #define CVMX_OCT_DID_TAG_TAG1 CVMX_FULL_DID(CVMX_OCT_DID_TAG, 1ULL)
  294. #define CVMX_OCT_DID_TAG_TAG2 CVMX_FULL_DID(CVMX_OCT_DID_TAG, 2ULL)
  295. #define CVMX_OCT_DID_TAG_TAG3 CVMX_FULL_DID(CVMX_OCT_DID_TAG, 3ULL)
  296. #define CVMX_OCT_DID_TAG_NULL_RD CVMX_FULL_DID(CVMX_OCT_DID_TAG, 4ULL)
  297. #define CVMX_OCT_DID_TAG_CSR CVMX_FULL_DID(CVMX_OCT_DID_TAG, 7ULL)
  298. #define CVMX_OCT_DID_FAU_FAI CVMX_FULL_DID(CVMX_OCT_DID_IOB, 0ULL)
  299. #define CVMX_OCT_DID_TIM_CSR CVMX_FULL_DID(CVMX_OCT_DID_TIM, 0ULL)
  300. #define CVMX_OCT_DID_KEY_RW CVMX_FULL_DID(CVMX_OCT_DID_KEY, 0ULL)
  301. #define CVMX_OCT_DID_PCI_6 CVMX_FULL_DID(CVMX_OCT_DID_PCI, 6ULL)
  302. #define CVMX_OCT_DID_MIS_BOO CVMX_FULL_DID(CVMX_OCT_DID_MIS, 0ULL)
  303. #define CVMX_OCT_DID_PCI_RML CVMX_FULL_DID(CVMX_OCT_DID_PCI, 0ULL)
  304. #define CVMX_OCT_DID_IPD_CSR CVMX_FULL_DID(CVMX_OCT_DID_IPD, 7ULL)
  305. #define CVMX_OCT_DID_DFA_CSR CVMX_FULL_DID(CVMX_OCT_DID_DFA, 7ULL)
  306. #define CVMX_OCT_DID_MIS_CSR CVMX_FULL_DID(CVMX_OCT_DID_MIS, 7ULL)
  307. #define CVMX_OCT_DID_ZIP_CSR CVMX_FULL_DID(CVMX_OCT_DID_ZIP, 0ULL)
  308. #endif /* __CVMX_ADDRESS_H__ */