numachip_csr.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Numascale NumaConnect-Specific Header file
  7. *
  8. * Copyright (C) 2011 Numascale AS. All rights reserved.
  9. *
  10. * Send feedback to <support@numascale.com>
  11. *
  12. */
  13. #ifndef _ASM_X86_NUMACHIP_NUMACHIP_CSR_H
  14. #define _ASM_X86_NUMACHIP_NUMACHIP_CSR_H
  15. #include <linux/numa.h>
  16. #include <linux/percpu.h>
  17. #include <linux/io.h>
  18. #include <linux/swab.h>
  19. #include <asm/types.h>
  20. #include <asm/processor.h>
  21. #define CSR_NODE_SHIFT 16
  22. #define CSR_NODE_BITS(p) (((unsigned long)(p)) << CSR_NODE_SHIFT)
  23. #define CSR_NODE_MASK 0x0fff /* 4K nodes */
  24. /* 32K CSR space, b15 indicates geo/non-geo */
  25. #define CSR_OFFSET_MASK 0x7fffUL
  26. /* Global CSR space covers all 4K possible nodes with 64K CSR space per node */
  27. #define NUMACHIP_GCSR_BASE 0x3fff00000000ULL
  28. #define NUMACHIP_GCSR_LIM 0x3fff0fffffffULL
  29. #define NUMACHIP_GCSR_SIZE (NUMACHIP_GCSR_LIM - NUMACHIP_GCSR_BASE + 1)
  30. /*
  31. * Local CSR space starts in global CSR space with "nodeid" = 0xfff0, however
  32. * when using the direct mapping on x86_64, both start and size needs to be
  33. * aligned with PMD_SIZE which is 2M
  34. */
  35. #define NUMACHIP_LCSR_BASE 0x3ffffe000000ULL
  36. #define NUMACHIP_LCSR_LIM 0x3fffffffffffULL
  37. #define NUMACHIP_LCSR_SIZE (NUMACHIP_LCSR_LIM - NUMACHIP_LCSR_BASE + 1)
  38. static inline void *gcsr_address(int node, unsigned long offset)
  39. {
  40. return __va(NUMACHIP_GCSR_BASE | (1UL << 15) |
  41. CSR_NODE_BITS(node & CSR_NODE_MASK) | (offset & CSR_OFFSET_MASK));
  42. }
  43. static inline void *lcsr_address(unsigned long offset)
  44. {
  45. return __va(NUMACHIP_LCSR_BASE | (1UL << 15) |
  46. CSR_NODE_BITS(0xfff0) | (offset & CSR_OFFSET_MASK));
  47. }
  48. static inline unsigned int read_gcsr(int node, unsigned long offset)
  49. {
  50. return swab32(readl(gcsr_address(node, offset)));
  51. }
  52. static inline void write_gcsr(int node, unsigned long offset, unsigned int val)
  53. {
  54. writel(swab32(val), gcsr_address(node, offset));
  55. }
  56. static inline unsigned int read_lcsr(unsigned long offset)
  57. {
  58. return swab32(readl(lcsr_address(offset)));
  59. }
  60. static inline void write_lcsr(unsigned long offset, unsigned int val)
  61. {
  62. writel(swab32(val), lcsr_address(offset));
  63. }
  64. /* ========================================================================= */
  65. /* CSR_G0_STATE_CLEAR */
  66. /* ========================================================================= */
  67. #define CSR_G0_STATE_CLEAR (0x000 + (0 << 12))
  68. union numachip_csr_g0_state_clear {
  69. unsigned int v;
  70. struct numachip_csr_g0_state_clear_s {
  71. unsigned int _state:2;
  72. unsigned int _rsvd_2_6:5;
  73. unsigned int _lost:1;
  74. unsigned int _rsvd_8_31:24;
  75. } s;
  76. };
  77. /* ========================================================================= */
  78. /* CSR_G0_NODE_IDS */
  79. /* ========================================================================= */
  80. #define CSR_G0_NODE_IDS (0x008 + (0 << 12))
  81. union numachip_csr_g0_node_ids {
  82. unsigned int v;
  83. struct numachip_csr_g0_node_ids_s {
  84. unsigned int _initialid:16;
  85. unsigned int _nodeid:12;
  86. unsigned int _rsvd_28_31:4;
  87. } s;
  88. };
  89. /* ========================================================================= */
  90. /* CSR_G3_EXT_IRQ_GEN */
  91. /* ========================================================================= */
  92. #define CSR_G3_EXT_IRQ_GEN (0x030 + (3 << 12))
  93. union numachip_csr_g3_ext_irq_gen {
  94. unsigned int v;
  95. struct numachip_csr_g3_ext_irq_gen_s {
  96. unsigned int _vector:8;
  97. unsigned int _msgtype:3;
  98. unsigned int _index:5;
  99. unsigned int _destination_apic_id:16;
  100. } s;
  101. };
  102. /* ========================================================================= */
  103. /* CSR_G3_EXT_IRQ_STATUS */
  104. /* ========================================================================= */
  105. #define CSR_G3_EXT_IRQ_STATUS (0x034 + (3 << 12))
  106. union numachip_csr_g3_ext_irq_status {
  107. unsigned int v;
  108. struct numachip_csr_g3_ext_irq_status_s {
  109. unsigned int _result:32;
  110. } s;
  111. };
  112. /* ========================================================================= */
  113. /* CSR_G3_EXT_IRQ_DEST */
  114. /* ========================================================================= */
  115. #define CSR_G3_EXT_IRQ_DEST (0x038 + (3 << 12))
  116. union numachip_csr_g3_ext_irq_dest {
  117. unsigned int v;
  118. struct numachip_csr_g3_ext_irq_dest_s {
  119. unsigned int _irq:8;
  120. unsigned int _rsvd_8_31:24;
  121. } s;
  122. };
  123. /* ========================================================================= */
  124. /* CSR_G3_NC_ATT_MAP_SELECT */
  125. /* ========================================================================= */
  126. #define CSR_G3_NC_ATT_MAP_SELECT (0x7fc + (3 << 12))
  127. union numachip_csr_g3_nc_att_map_select {
  128. unsigned int v;
  129. struct numachip_csr_g3_nc_att_map_select_s {
  130. unsigned int _upper_address_bits:4;
  131. unsigned int _select_ram:4;
  132. unsigned int _rsvd_8_31:24;
  133. } s;
  134. };
  135. /* ========================================================================= */
  136. /* CSR_G3_NC_ATT_MAP_SELECT_0-255 */
  137. /* ========================================================================= */
  138. #define CSR_G3_NC_ATT_MAP_SELECT_0 (0x800 + (3 << 12))
  139. #endif /* _ASM_X86_NUMACHIP_NUMACHIP_CSR_H */