hubmd.h 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790
  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. * Derived from IRIX <sys/SN/SN0/hubmd.h>, revision 1.59.
  7. *
  8. * Copyright (C) 1992 - 1997, 1999 Silicon Graphics, Inc.
  9. * Copyright (C) 1999 by Ralf Baechle
  10. */
  11. #ifndef _ASM_SN_SN0_HUBMD_H
  12. #define _ASM_SN_SN0_HUBMD_H
  13. #include <linux/config.h>
  14. /*
  15. * Hub Memory/Directory interface registers
  16. */
  17. #define CACHE_SLINE_SIZE 128 /* Secondary cache line size on SN0 */
  18. #define MAX_REGIONS 64
  19. /* Hardware page size and shift */
  20. #define MD_PAGE_SIZE 4096 /* Page size in bytes */
  21. #define MD_PAGE_NUM_SHFT 12 /* Address to page number shift */
  22. /* Register offsets from LOCAL_HUB or REMOTE_HUB */
  23. #define MD_BASE 0x200000
  24. #define MD_BASE_PERF 0x210000
  25. #define MD_BASE_JUNK 0x220000
  26. #define MD_IO_PROTECT 0x200000 /* MD and core register protection */
  27. #define MD_IO_PROT_OVRRD 0x200008 /* Clear my bit in MD_IO_PROTECT */
  28. #define MD_HSPEC_PROTECT 0x200010 /* BDDIR, LBOOT, RBOOT protection */
  29. #define MD_MEMORY_CONFIG 0x200018 /* Memory/Directory DIMM control */
  30. #define MD_REFRESH_CONTROL 0x200020 /* Memory/Directory refresh ctrl */
  31. #define MD_FANDOP_CAC_STAT 0x200028 /* Fetch-and-op cache status */
  32. #define MD_MIG_DIFF_THRESH 0x200030 /* Page migr. count diff thresh. */
  33. #define MD_MIG_VALUE_THRESH 0x200038 /* Page migr. count abs. thresh. */
  34. #define MD_MIG_CANDIDATE 0x200040 /* Latest page migration candidate */
  35. #define MD_MIG_CANDIDATE_CLR 0x200048 /* Clear page migration candidate */
  36. #define MD_DIR_ERROR 0x200050 /* Directory DIMM error */
  37. #define MD_DIR_ERROR_CLR 0x200058 /* Directory DIMM error clear */
  38. #define MD_PROTOCOL_ERROR 0x200060 /* Directory protocol error */
  39. #define MD_PROTOCOL_ERROR_CLR 0x200068 /* Directory protocol error clear */
  40. #define MD_MEM_ERROR 0x200070 /* Memory DIMM error */
  41. #define MD_MEM_ERROR_CLR 0x200078 /* Memory DIMM error clear */
  42. #define MD_MISC_ERROR 0x200080 /* Miscellaneous MD error */
  43. #define MD_MISC_ERROR_CLR 0x200088 /* Miscellaneous MD error clear */
  44. #define MD_MEM_DIMM_INIT 0x200090 /* Memory DIMM mode initization. */
  45. #define MD_DIR_DIMM_INIT 0x200098 /* Directory DIMM mode init. */
  46. #define MD_MOQ_SIZE 0x2000a0 /* MD outgoing queue size */
  47. #define MD_MLAN_CTL 0x2000a8 /* NIC (Microlan) control register */
  48. #define MD_PERF_SEL 0x210000 /* Select perf monitor events */
  49. #define MD_PERF_CNT0 0x210010 /* Performance counter 0 */
  50. #define MD_PERF_CNT1 0x210018 /* Performance counter 1 */
  51. #define MD_PERF_CNT2 0x210020 /* Performance counter 2 */
  52. #define MD_PERF_CNT3 0x210028 /* Performance counter 3 */
  53. #define MD_PERF_CNT4 0x210030 /* Performance counter 4 */
  54. #define MD_PERF_CNT5 0x210038 /* Performance counter 5 */
  55. #define MD_UREG0_0 0x220000 /* uController/UART 0 register */
  56. #define MD_UREG0_1 0x220008 /* uController/UART 0 register */
  57. #define MD_UREG0_2 0x220010 /* uController/UART 0 register */
  58. #define MD_UREG0_3 0x220018 /* uController/UART 0 register */
  59. #define MD_UREG0_4 0x220020 /* uController/UART 0 register */
  60. #define MD_UREG0_5 0x220028 /* uController/UART 0 register */
  61. #define MD_UREG0_6 0x220030 /* uController/UART 0 register */
  62. #define MD_UREG0_7 0x220038 /* uController/UART 0 register */
  63. #define MD_SLOTID_USTAT 0x220048 /* Hub slot ID & UART/uCtlr status */
  64. #define MD_LED0 0x220050 /* Eight-bit LED for CPU A */
  65. #define MD_LED1 0x220058 /* Eight-bit LED for CPU B */
  66. #define MD_UREG1_0 0x220080 /* uController/UART 1 register */
  67. #define MD_UREG1_1 0x220088 /* uController/UART 1 register */
  68. #define MD_UREG1_2 0x220090 /* uController/UART 1 register */
  69. #define MD_UREG1_3 0x220098 /* uController/UART 1 register */
  70. #define MD_UREG1_4 0x2200a0 /* uController/UART 1 register */
  71. #define MD_UREG1_5 0x2200a8 /* uController/UART 1 register */
  72. #define MD_UREG1_6 0x2200b0 /* uController/UART 1 register */
  73. #define MD_UREG1_7 0x2200b8 /* uController/UART 1 register */
  74. #define MD_UREG1_8 0x2200c0 /* uController/UART 1 register */
  75. #define MD_UREG1_9 0x2200c8 /* uController/UART 1 register */
  76. #define MD_UREG1_10 0x2200d0 /* uController/UART 1 register */
  77. #define MD_UREG1_11 0x2200d8 /* uController/UART 1 register */
  78. #define MD_UREG1_12 0x2200e0 /* uController/UART 1 register */
  79. #define MD_UREG1_13 0x2200e8 /* uController/UART 1 register */
  80. #define MD_UREG1_14 0x2200f0 /* uController/UART 1 register */
  81. #define MD_UREG1_15 0x2200f8 /* uController/UART 1 register */
  82. #ifdef CONFIG_SGI_SN0_N_MODE
  83. #define MD_MEM_BANKS 4 /* 4 banks of memory max in N mode */
  84. #else
  85. #define MD_MEM_BANKS 8 /* 8 banks of memory max in M mode */
  86. #endif
  87. /*
  88. * MD_MEMORY_CONFIG fields
  89. *
  90. * MD_SIZE_xxx are useful for representing the size of a SIMM or bank
  91. * (SIMM pair). They correspond to the values needed for the bit
  92. * triplets (MMC_BANK_MASK) in the MD_MEMORY_CONFIG register for bank size.
  93. * Bits not used by the MD are used by software.
  94. */
  95. #define MD_SIZE_EMPTY 0 /* Valid in MEMORY_CONFIG */
  96. #define MD_SIZE_8MB 1
  97. #define MD_SIZE_16MB 2
  98. #define MD_SIZE_32MB 3 /* Broken in Hub 1 */
  99. #define MD_SIZE_64MB 4 /* Valid in MEMORY_CONFIG */
  100. #define MD_SIZE_128MB 5 /* Valid in MEMORY_CONFIG */
  101. #define MD_SIZE_256MB 6
  102. #define MD_SIZE_512MB 7 /* Valid in MEMORY_CONFIG */
  103. #define MD_SIZE_1GB 8
  104. #define MD_SIZE_2GB 9
  105. #define MD_SIZE_4GB 10
  106. #define MD_SIZE_BYTES(size) ((size) == 0 ? 0 : 0x400000L << (size))
  107. #define MD_SIZE_MBYTES(size) ((size) == 0 ? 0 : 4 << (size))
  108. #define MMC_FPROM_CYC_SHFT 49 /* Have to use UINT64_CAST, instead */
  109. #define MMC_FPROM_CYC_MASK (UINT64_CAST 31 << 49) /* of 'L' suffix, */
  110. #define MMC_FPROM_WR_SHFT 44 /* for assembler */
  111. #define MMC_FPROM_WR_MASK (UINT64_CAST 31 << 44)
  112. #define MMC_UCTLR_CYC_SHFT 39
  113. #define MMC_UCTLR_CYC_MASK (UINT64_CAST 31 << 39)
  114. #define MMC_UCTLR_WR_SHFT 34
  115. #define MMC_UCTLR_WR_MASK (UINT64_CAST 31 << 34)
  116. #define MMC_DIMM0_SEL_SHFT 32
  117. #define MMC_DIMM0_SEL_MASK (UINT64_CAST 3 << 32)
  118. #define MMC_IO_PROT_EN_SHFT 31
  119. #define MMC_IO_PROT_EN_MASK (UINT64_CAST 1 << 31)
  120. #define MMC_IO_PROT (UINT64_CAST 1 << 31)
  121. #define MMC_ARB_MLSS_SHFT 30
  122. #define MMC_ARB_MLSS_MASK (UINT64_CAST 1 << 30)
  123. #define MMC_ARB_MLSS (UINT64_CAST 1 << 30)
  124. #define MMC_IGNORE_ECC_SHFT 29
  125. #define MMC_IGNORE_ECC_MASK (UINT64_CAST 1 << 29)
  126. #define MMC_IGNORE_ECC (UINT64_CAST 1 << 29)
  127. #define MMC_DIR_PREMIUM_SHFT 28
  128. #define MMC_DIR_PREMIUM_MASK (UINT64_CAST 1 << 28)
  129. #define MMC_DIR_PREMIUM (UINT64_CAST 1 << 28)
  130. #define MMC_REPLY_GUAR_SHFT 24
  131. #define MMC_REPLY_GUAR_MASK (UINT64_CAST 15 << 24)
  132. #define MMC_BANK_SHFT(_b) ((_b) * 3)
  133. #define MMC_BANK_MASK(_b) (UINT64_CAST 7 << MMC_BANK_SHFT(_b))
  134. #define MMC_BANK_ALL_MASK 0xffffff
  135. #define MMC_RESET_DEFAULTS (UINT64_CAST 0x0f << MMC_FPROM_CYC_SHFT | \
  136. UINT64_CAST 0x07 << MMC_FPROM_WR_SHFT | \
  137. UINT64_CAST 0x1f << MMC_UCTLR_CYC_SHFT | \
  138. UINT64_CAST 0x0f << MMC_UCTLR_WR_SHFT | \
  139. MMC_IGNORE_ECC | MMC_DIR_PREMIUM | \
  140. UINT64_CAST 0x0f << MMC_REPLY_GUAR_SHFT | \
  141. MMC_BANK_ALL_MASK)
  142. /* MD_REFRESH_CONTROL fields */
  143. #define MRC_ENABLE_SHFT 63
  144. #define MRC_ENABLE_MASK (UINT64_CAST 1 << 63)
  145. #define MRC_ENABLE (UINT64_CAST 1 << 63)
  146. #define MRC_COUNTER_SHFT 12
  147. #define MRC_COUNTER_MASK (UINT64_CAST 0xfff << 12)
  148. #define MRC_CNT_THRESH_MASK 0xfff
  149. #define MRC_RESET_DEFAULTS (UINT64_CAST 0x400)
  150. /* MD_MEM_DIMM_INIT and MD_DIR_DIMM_INIT fields */
  151. #define MDI_SELECT_SHFT 32
  152. #define MDI_SELECT_MASK (UINT64_CAST 0x0f << 32)
  153. #define MDI_DIMM_MODE_MASK (UINT64_CAST 0xfff)
  154. /* MD_MOQ_SIZE fields */
  155. #define MMS_RP_SIZE_SHFT 8
  156. #define MMS_RP_SIZE_MASK (UINT64_CAST 0x3f << 8)
  157. #define MMS_RQ_SIZE_SHFT 0
  158. #define MMS_RQ_SIZE_MASK (UINT64_CAST 0x1f)
  159. #define MMS_RESET_DEFAULTS (0x32 << 8 | 0x12)
  160. /* MD_FANDOP_CAC_STAT fields */
  161. #define MFC_VALID_SHFT 63
  162. #define MFC_VALID_MASK (UINT64_CAST 1 << 63)
  163. #define MFC_VALID (UINT64_CAST 1 << 63)
  164. #define MFC_ADDR_SHFT 6
  165. #define MFC_ADDR_MASK (UINT64_CAST 0x3ffffff)
  166. /* MD_MLAN_CTL fields */
  167. #define MLAN_PHI1_SHFT 27
  168. #define MLAN_PHI1_MASK (UINT64_CAST 0x7f << 27)
  169. #define MLAN_PHI0_SHFT 20
  170. #define MLAN_PHI0_MASK (UINT64_CAST 0x7f << 27)
  171. #define MLAN_PULSE_SHFT 10
  172. #define MLAN_PULSE_MASK (UINT64_CAST 0x3ff << 10)
  173. #define MLAN_SAMPLE_SHFT 2
  174. #define MLAN_SAMPLE_MASK (UINT64_CAST 0xff << 2)
  175. #define MLAN_DONE_SHFT 1
  176. #define MLAN_DONE_MASK 2
  177. #define MLAN_DONE (UINT64_CAST 0x02)
  178. #define MLAN_RD_DATA (UINT64_CAST 0x01)
  179. #define MLAN_RESET_DEFAULTS (UINT64_CAST 0x31 << MLAN_PHI1_SHFT | \
  180. UINT64_CAST 0x31 << MLAN_PHI0_SHFT)
  181. /* MD_SLOTID_USTAT bit definitions */
  182. #define MSU_CORECLK_TST_SHFT 7 /* You don't wanna know */
  183. #define MSU_CORECLK_TST_MASK (UINT64_CAST 1 << 7)
  184. #define MSU_CORECLK_TST (UINT64_CAST 1 << 7)
  185. #define MSU_CORECLK_SHFT 6 /* You don't wanna know */
  186. #define MSU_CORECLK_MASK (UINT64_CAST 1 << 6)
  187. #define MSU_CORECLK (UINT64_CAST 1 << 6)
  188. #define MSU_NETSYNC_SHFT 5 /* You don't wanna know */
  189. #define MSU_NETSYNC_MASK (UINT64_CAST 1 << 5)
  190. #define MSU_NETSYNC (UINT64_CAST 1 << 5)
  191. #define MSU_FPROMRDY_SHFT 4 /* Flash PROM ready bit */
  192. #define MSU_FPROMRDY_MASK (UINT64_CAST 1 << 4)
  193. #define MSU_FPROMRDY (UINT64_CAST 1 << 4)
  194. #define MSU_I2CINTR_SHFT 3 /* I2C interrupt bit */
  195. #define MSU_I2CINTR_MASK (UINT64_CAST 1 << 3)
  196. #define MSU_I2CINTR (UINT64_CAST 1 << 3)
  197. #define MSU_SLOTID_MASK 0xff
  198. #define MSU_SN0_SLOTID_SHFT 0 /* Slot ID */
  199. #define MSU_SN0_SLOTID_MASK (UINT64_CAST 7)
  200. #define MSU_SN00_SLOTID_SHFT 7
  201. #define MSU_SN00_SLOTID_MASK (UINT64_CAST 0x80)
  202. #define MSU_PIMM_PSC_SHFT 4
  203. #define MSU_PIMM_PSC_MASK (0xf << MSU_PIMM_PSC_SHFT)
  204. /* MD_MIG_DIFF_THRESH bit definitions */
  205. #define MD_MIG_DIFF_THRES_VALID_MASK (UINT64_CAST 0x1 << 63)
  206. #define MD_MIG_DIFF_THRES_VALID_SHFT 63
  207. #define MD_MIG_DIFF_THRES_VALUE_MASK (UINT64_CAST 0xfffff)
  208. /* MD_MIG_VALUE_THRESH bit definitions */
  209. #define MD_MIG_VALUE_THRES_VALID_MASK (UINT64_CAST 0x1 << 63)
  210. #define MD_MIG_VALUE_THRES_VALID_SHFT 63
  211. #define MD_MIG_VALUE_THRES_VALUE_MASK (UINT64_CAST 0xfffff)
  212. /* MD_MIG_CANDIDATE bit definitions */
  213. #define MD_MIG_CANDIDATE_VALID_MASK (UINT64_CAST 0x1 << 63)
  214. #define MD_MIG_CANDIDATE_VALID_SHFT 63
  215. #define MD_MIG_CANDIDATE_TYPE_MASK (UINT64_CAST 0x1 << 30)
  216. #define MD_MIG_CANDIDATE_TYPE_SHFT 30
  217. #define MD_MIG_CANDIDATE_OVERRUN_MASK (UINT64_CAST 0x1 << 29)
  218. #define MD_MIG_CANDIDATE_OVERRUN_SHFT 29
  219. #define MD_MIG_CANDIDATE_INITIATOR_MASK (UINT64_CAST 0x7ff << 18)
  220. #define MD_MIG_CANDIDATE_INITIATOR_SHFT 18
  221. #define MD_MIG_CANDIDATE_NODEID_MASK (UINT64_CAST 0x1ff << 20)
  222. #define MD_MIG_CANDIDATE_NODEID_SHFT 20
  223. #define MD_MIG_CANDIDATE_ADDR_MASK (UINT64_CAST 0x3ffff)
  224. #define MD_MIG_CANDIDATE_ADDR_SHFT 14 /* The address starts at bit 14 */
  225. /* Other MD definitions */
  226. #define MD_BANK_SHFT 29 /* log2(512 MB) */
  227. #define MD_BANK_MASK (UINT64_CAST 7 << 29)
  228. #define MD_BANK_SIZE (UINT64_CAST 1 << MD_BANK_SHFT) /* 512 MB */
  229. #define MD_BANK_OFFSET(_b) (UINT64_CAST (_b) << MD_BANK_SHFT)
  230. /*
  231. * The following definitions cover the bit field definitions for the
  232. * various MD registers. For multi-bit registers, we define both
  233. * a shift amount and a mask value. By convention, if you want to
  234. * isolate a field, you should mask the field and then shift it down,
  235. * since this makes the masks useful without a shift.
  236. */
  237. /* Directory entry states for both premium and standard SIMMs. */
  238. #define MD_DIR_SHARED (UINT64_CAST 0x0) /* 000 */
  239. #define MD_DIR_POISONED (UINT64_CAST 0x1) /* 001 */
  240. #define MD_DIR_EXCLUSIVE (UINT64_CAST 0x2) /* 010 */
  241. #define MD_DIR_BUSY_SHARED (UINT64_CAST 0x3) /* 011 */
  242. #define MD_DIR_BUSY_EXCL (UINT64_CAST 0x4) /* 100 */
  243. #define MD_DIR_WAIT (UINT64_CAST 0x5) /* 101 */
  244. #define MD_DIR_UNOWNED (UINT64_CAST 0x7) /* 111 */
  245. /*
  246. * The MD_DIR_FORCE_ECC bit can be added directory entry write data
  247. * to forcing the ECC to be written as-is instead of recalculated.
  248. */
  249. #define MD_DIR_FORCE_ECC (UINT64_CAST 1 << 63)
  250. /*
  251. * Premium SIMM directory entry shifts and masks. Each is valid only in the
  252. * context(s) indicated, where A, B, and C indicate the directory entry format
  253. * as shown, and low and/or high indicates which double-word of the entry.
  254. *
  255. * Format A: STATE = shared, FINE = 1
  256. * Format B: STATE = shared, FINE = 0
  257. * Format C: STATE != shared (FINE must be 0)
  258. */
  259. #define MD_PDIR_MASK 0xffffffffffff /* Whole entry */
  260. #define MD_PDIR_ECC_SHFT 0 /* ABC low or high */
  261. #define MD_PDIR_ECC_MASK 0x7f
  262. #define MD_PDIR_PRIO_SHFT 8 /* ABC low */
  263. #define MD_PDIR_PRIO_MASK (0xf << 8)
  264. #define MD_PDIR_AX_SHFT 7 /* ABC low */
  265. #define MD_PDIR_AX_MASK (1 << 7)
  266. #define MD_PDIR_AX (1 << 7)
  267. #define MD_PDIR_FINE_SHFT 12 /* ABC low */
  268. #define MD_PDIR_FINE_MASK (1 << 12)
  269. #define MD_PDIR_FINE (1 << 12)
  270. #define MD_PDIR_OCT_SHFT 13 /* A low */
  271. #define MD_PDIR_OCT_MASK (7 << 13)
  272. #define MD_PDIR_STATE_SHFT 13 /* BC low */
  273. #define MD_PDIR_STATE_MASK (7 << 13)
  274. #define MD_PDIR_ONECNT_SHFT 16 /* BC low */
  275. #define MD_PDIR_ONECNT_MASK (0x3f << 16)
  276. #define MD_PDIR_PTR_SHFT 22 /* C low */
  277. #define MD_PDIR_PTR_MASK (UINT64_CAST 0x7ff << 22)
  278. #define MD_PDIR_VECMSB_SHFT 22 /* AB low */
  279. #define MD_PDIR_VECMSB_BITMASK 0x3ffffff
  280. #define MD_PDIR_VECMSB_BITSHFT 27
  281. #define MD_PDIR_VECMSB_MASK (UINT64_CAST MD_PDIR_VECMSB_BITMASK << 22)
  282. #define MD_PDIR_CWOFF_SHFT 7 /* C high */
  283. #define MD_PDIR_CWOFF_MASK (7 << 7)
  284. #define MD_PDIR_VECLSB_SHFT 10 /* AB high */
  285. #define MD_PDIR_VECLSB_BITMASK (UINT64_CAST 0x3fffffffff)
  286. #define MD_PDIR_VECLSB_BITSHFT 0
  287. #define MD_PDIR_VECLSB_MASK (MD_PDIR_VECLSB_BITMASK << 10)
  288. /*
  289. * Directory initialization values
  290. */
  291. #define MD_PDIR_INIT_LO (MD_DIR_UNOWNED << MD_PDIR_STATE_SHFT | \
  292. MD_PDIR_AX)
  293. #define MD_PDIR_INIT_HI 0
  294. #define MD_PDIR_INIT_PROT (MD_PROT_RW << MD_PPROT_IO_SHFT | \
  295. MD_PROT_RW << MD_PPROT_SHFT)
  296. /*
  297. * Standard SIMM directory entry shifts and masks. Each is valid only in the
  298. * context(s) indicated, where A and C indicate the directory entry format
  299. * as shown, and low and/or high indicates which double-word of the entry.
  300. *
  301. * Format A: STATE == shared
  302. * Format C: STATE != shared
  303. */
  304. #define MD_SDIR_MASK 0xffff /* Whole entry */
  305. #define MD_SDIR_ECC_SHFT 0 /* AC low or high */
  306. #define MD_SDIR_ECC_MASK 0x1f
  307. #define MD_SDIR_PRIO_SHFT 6 /* AC low */
  308. #define MD_SDIR_PRIO_MASK (1 << 6)
  309. #define MD_SDIR_AX_SHFT 5 /* AC low */
  310. #define MD_SDIR_AX_MASK (1 << 5)
  311. #define MD_SDIR_AX (1 << 5)
  312. #define MD_SDIR_STATE_SHFT 7 /* AC low */
  313. #define MD_SDIR_STATE_MASK (7 << 7)
  314. #define MD_SDIR_PTR_SHFT 10 /* C low */
  315. #define MD_SDIR_PTR_MASK (0x3f << 10)
  316. #define MD_SDIR_CWOFF_SHFT 5 /* C high */
  317. #define MD_SDIR_CWOFF_MASK (7 << 5)
  318. #define MD_SDIR_VECMSB_SHFT 11 /* A low */
  319. #define MD_SDIR_VECMSB_BITMASK 0x1f
  320. #define MD_SDIR_VECMSB_BITSHFT 7
  321. #define MD_SDIR_VECMSB_MASK (MD_SDIR_VECMSB_BITMASK << 11)
  322. #define MD_SDIR_VECLSB_SHFT 5 /* A high */
  323. #define MD_SDIR_VECLSB_BITMASK 0x7ff
  324. #define MD_SDIR_VECLSB_BITSHFT 0
  325. #define MD_SDIR_VECLSB_MASK (MD_SDIR_VECLSB_BITMASK << 5)
  326. /*
  327. * Directory initialization values
  328. */
  329. #define MD_SDIR_INIT_LO (MD_DIR_UNOWNED << MD_SDIR_STATE_SHFT | \
  330. MD_SDIR_AX)
  331. #define MD_SDIR_INIT_HI 0
  332. #define MD_SDIR_INIT_PROT (MD_PROT_RW << MD_SPROT_SHFT)
  333. /* Protection and migration field values */
  334. #define MD_PROT_RW (UINT64_CAST 0x6)
  335. #define MD_PROT_RO (UINT64_CAST 0x3)
  336. #define MD_PROT_NO (UINT64_CAST 0x0)
  337. #define MD_PROT_BAD (UINT64_CAST 0x5)
  338. /* Premium SIMM protection entry shifts and masks. */
  339. #define MD_PPROT_SHFT 0 /* Prot. field */
  340. #define MD_PPROT_MASK 7
  341. #define MD_PPROT_MIGMD_SHFT 3 /* Migration mode */
  342. #define MD_PPROT_MIGMD_MASK (3 << 3)
  343. #define MD_PPROT_REFCNT_SHFT 5 /* Reference count */
  344. #define MD_PPROT_REFCNT_WIDTH 0x7ffff
  345. #define MD_PPROT_REFCNT_MASK (MD_PPROT_REFCNT_WIDTH << 5)
  346. #define MD_PPROT_IO_SHFT 45 /* I/O Prot field */
  347. #define MD_PPROT_IO_MASK (UINT64_CAST 7 << 45)
  348. /* Standard SIMM protection entry shifts and masks. */
  349. #define MD_SPROT_SHFT 0 /* Prot. field */
  350. #define MD_SPROT_MASK 7
  351. #define MD_SPROT_MIGMD_SHFT 3 /* Migration mode */
  352. #define MD_SPROT_MIGMD_MASK (3 << 3)
  353. #define MD_SPROT_REFCNT_SHFT 5 /* Reference count */
  354. #define MD_SPROT_REFCNT_WIDTH 0x7ff
  355. #define MD_SPROT_REFCNT_MASK (MD_SPROT_REFCNT_WIDTH << 5)
  356. /* Migration modes used in protection entries */
  357. #define MD_PROT_MIGMD_IREL (UINT64_CAST 0x3 << 3)
  358. #define MD_PROT_MIGMD_IABS (UINT64_CAST 0x2 << 3)
  359. #define MD_PROT_MIGMD_PREL (UINT64_CAST 0x1 << 3)
  360. #define MD_PROT_MIGMD_OFF (UINT64_CAST 0x0 << 3)
  361. /*
  362. * Operations on page migration threshold register
  363. */
  364. #ifndef __ASSEMBLY__
  365. /*
  366. * LED register macros
  367. */
  368. #define CPU_LED_ADDR(_nasid, _slice) \
  369. (private.p_sn00 ? \
  370. REMOTE_HUB_ADDR((_nasid), MD_UREG1_0 + ((_slice) << 5)) : \
  371. REMOTE_HUB_ADDR((_nasid), MD_LED0 + ((_slice) << 3)))
  372. #define SET_CPU_LEDS(_nasid, _slice, _val) \
  373. (HUB_S(CPU_LED_ADDR(_nasid, _slice), (_val)))
  374. #define SET_MY_LEDS(_v) \
  375. SET_CPU_LEDS(get_nasid(), get_slice(), (_v))
  376. /*
  377. * Operations on Memory/Directory DIMM control register
  378. */
  379. #define DIRTYPE_PREMIUM 1
  380. #define DIRTYPE_STANDARD 0
  381. #define MD_MEMORY_CONFIG_DIR_TYPE_GET(region) (\
  382. (REMOTE_HUB_L(region, MD_MEMORY_CONFIG) & MMC_DIR_PREMIUM_MASK) >> \
  383. MMC_DIR_PREMIUM_SHFT)
  384. /*
  385. * Operations on page migration count difference and absolute threshold
  386. * registers
  387. */
  388. #define MD_MIG_DIFF_THRESH_GET(region) ( \
  389. REMOTE_HUB_L((region), MD_MIG_DIFF_THRESH) & \
  390. MD_MIG_DIFF_THRES_VALUE_MASK)
  391. #define MD_MIG_DIFF_THRESH_SET(region, value) ( \
  392. REMOTE_HUB_S((region), MD_MIG_DIFF_THRESH, \
  393. MD_MIG_DIFF_THRES_VALID_MASK | (value)))
  394. #define MD_MIG_DIFF_THRESH_DISABLE(region) ( \
  395. REMOTE_HUB_S((region), MD_MIG_DIFF_THRESH, \
  396. REMOTE_HUB_L((region), MD_MIG_DIFF_THRESH) \
  397. & ~MD_MIG_DIFF_THRES_VALID_MASK))
  398. #define MD_MIG_DIFF_THRESH_ENABLE(region) ( \
  399. REMOTE_HUB_S((region), MD_MIG_DIFF_THRESH, \
  400. REMOTE_HUB_L((region), MD_MIG_DIFF_THRESH) \
  401. | MD_MIG_DIFF_THRES_VALID_MASK))
  402. #define MD_MIG_DIFF_THRESH_IS_ENABLED(region) ( \
  403. REMOTE_HUB_L((region), MD_MIG_DIFF_THRESH) & \
  404. MD_MIG_DIFF_THRES_VALID_MASK)
  405. #define MD_MIG_VALUE_THRESH_GET(region) ( \
  406. REMOTE_HUB_L((region), MD_MIG_VALUE_THRESH) & \
  407. MD_MIG_VALUE_THRES_VALUE_MASK)
  408. #define MD_MIG_VALUE_THRESH_SET(region, value) ( \
  409. REMOTE_HUB_S((region), MD_MIG_VALUE_THRESH, \
  410. MD_MIG_VALUE_THRES_VALID_MASK | (value)))
  411. #define MD_MIG_VALUE_THRESH_DISABLE(region) ( \
  412. REMOTE_HUB_S((region), MD_MIG_VALUE_THRESH, \
  413. REMOTE_HUB_L(region, MD_MIG_VALUE_THRESH) \
  414. & ~MD_MIG_VALUE_THRES_VALID_MASK))
  415. #define MD_MIG_VALUE_THRESH_ENABLE(region) ( \
  416. REMOTE_HUB_S((region), MD_MIG_VALUE_THRESH, \
  417. REMOTE_HUB_L((region), MD_MIG_VALUE_THRESH) \
  418. | MD_MIG_VALUE_THRES_VALID_MASK))
  419. #define MD_MIG_VALUE_THRESH_IS_ENABLED(region) ( \
  420. REMOTE_HUB_L((region), MD_MIG_VALUE_THRESH) & \
  421. MD_MIG_VALUE_THRES_VALID_MASK)
  422. /*
  423. * Operations on page migration candidate register
  424. */
  425. #define MD_MIG_CANDIDATE_GET(my_region_id) ( \
  426. REMOTE_HUB_L((my_region_id), MD_MIG_CANDIDATE_CLR))
  427. #define MD_MIG_CANDIDATE_HWPFN(value) ((value) & MD_MIG_CANDIDATE_ADDR_MASK)
  428. #define MD_MIG_CANDIDATE_NODEID(value) ( \
  429. ((value) & MD_MIG_CANDIDATE_NODEID_MASK) >> MD_MIG_CANDIDATE_NODEID_SHFT)
  430. #define MD_MIG_CANDIDATE_TYPE(value) ( \
  431. ((value) & MD_MIG_CANDIDATE_TYPE_MASK) >> MD_MIG_CANDIDATE_TYPE_SHFT)
  432. #define MD_MIG_CANDIDATE_VALID(value) ( \
  433. ((value) & MD_MIG_CANDIDATE_VALID_MASK) >> MD_MIG_CANDIDATE_VALID_SHFT)
  434. /*
  435. * Macros to retrieve fields in the protection entry
  436. */
  437. /* for Premium SIMM */
  438. #define MD_PPROT_REFCNT_GET(value) ( \
  439. ((value) & MD_PPROT_REFCNT_MASK) >> MD_PPROT_REFCNT_SHFT)
  440. #define MD_PPROT_MIGMD_GET(value) ( \
  441. ((value) & MD_PPROT_MIGMD_MASK) >> MD_PPROT_MIGMD_SHFT)
  442. /* for Standard SIMM */
  443. #define MD_SPROT_REFCNT_GET(value) ( \
  444. ((value) & MD_SPROT_REFCNT_MASK) >> MD_SPROT_REFCNT_SHFT)
  445. #define MD_SPROT_MIGMD_GET(value) ( \
  446. ((value) & MD_SPROT_MIGMD_MASK) >> MD_SPROT_MIGMD_SHFT)
  447. /*
  448. * Format of dir_error, mem_error, protocol_error and misc_error registers
  449. */
  450. struct dir_error_reg {
  451. u64 uce_vld: 1, /* 63: valid directory uce */
  452. ae_vld: 1, /* 62: valid dir prot ecc error */
  453. ce_vld: 1, /* 61: valid correctable ECC err*/
  454. rsvd1: 19, /* 60-42: reserved */
  455. bad_prot: 3, /* 41-39: encoding, bad access rights*/
  456. bad_syn: 7, /* 38-32: bad dir syndrome */
  457. rsvd2: 2, /* 31-30: reserved */
  458. hspec_addr:27, /* 29-03: bddir space bad entry */
  459. uce_ovr: 1, /* 2: multiple dir uce's */
  460. ae_ovr: 1, /* 1: multiple prot ecc errs*/
  461. ce_ovr: 1; /* 0: multiple correctable errs */
  462. };
  463. typedef union md_dir_error {
  464. u64 derr_reg; /* the entire register */
  465. struct dir_error_reg derr_fmt; /* the register format */
  466. } md_dir_error_t;
  467. struct mem_error_reg {
  468. u64 uce_vld: 1, /* 63: valid memory uce */
  469. ce_vld: 1, /* 62: valid correctable ECC err*/
  470. rsvd1: 22, /* 61-40: reserved */
  471. bad_syn: 8, /* 39-32: bad mem ecc syndrome */
  472. address: 29, /* 31-03: bad entry pointer */
  473. rsvd2: 1, /* 2: reserved */
  474. uce_ovr: 1, /* 1: multiple mem uce's */
  475. ce_ovr: 1; /* 0: multiple correctable errs */
  476. };
  477. typedef union md_mem_error {
  478. u64 merr_reg; /* the entire register */
  479. struct mem_error_reg merr_fmt; /* format of the mem_error reg */
  480. } md_mem_error_t;
  481. struct proto_error_reg {
  482. u64 valid: 1, /* 63: valid protocol error */
  483. rsvd1: 2, /* 62-61: reserved */
  484. initiator:11, /* 60-50: id of request initiator*/
  485. backoff: 2, /* 49-48: backoff control */
  486. msg_type: 8, /* 47-40: type of request */
  487. access: 2, /* 39-38: access rights of initiator*/
  488. priority: 1, /* 37: priority level of requestor*/
  489. dir_state: 4, /* 36-33: state of directory */
  490. pointer_me:1, /* 32: initiator same as dir ptr */
  491. address: 29, /* 31-03: request address */
  492. rsvd2: 2, /* 02-01: reserved */
  493. overrun: 1; /* 0: multiple protocol errs */
  494. };
  495. typedef union md_proto_error {
  496. u64 perr_reg; /* the entire register */
  497. struct proto_error_reg perr_fmt; /* format of the register */
  498. } md_proto_error_t;
  499. struct md_sdir_high_fmt {
  500. unsigned short sd_hi_bvec : 11,
  501. sd_hi_ecc : 5;
  502. };
  503. typedef union md_sdir_high {
  504. /* The 16 bits of standard directory, upper word */
  505. unsigned short sd_hi_val;
  506. struct md_sdir_high_fmt sd_hi_fmt;
  507. }md_sdir_high_t;
  508. struct md_sdir_low_shared_fmt {
  509. /* The meaning of lower directory, shared */
  510. unsigned short sds_lo_bvec : 5,
  511. sds_lo_unused: 1,
  512. sds_lo_state : 3,
  513. sds_lo_prio : 1,
  514. sds_lo_ax : 1,
  515. sds_lo_ecc : 5;
  516. };
  517. struct md_sdir_low_exclusive_fmt {
  518. /* The meaning of lower directory, exclusive */
  519. unsigned short sde_lo_ptr : 6,
  520. sde_lo_state : 3,
  521. sde_lo_prio : 1,
  522. sde_lo_ax : 1,
  523. sde_lo_ecc : 5;
  524. };
  525. typedef union md_sdir_low {
  526. /* The 16 bits of standard directory, lower word */
  527. unsigned short sd_lo_val;
  528. struct md_sdir_low_exclusive_fmt sde_lo_fmt;
  529. struct md_sdir_low_shared_fmt sds_lo_fmt;
  530. }md_sdir_low_t;
  531. struct md_pdir_high_fmt {
  532. u64 pd_hi_unused : 16,
  533. pd_hi_bvec : 38,
  534. pd_hi_unused1 : 3,
  535. pd_hi_ecc : 7;
  536. };
  537. typedef union md_pdir_high {
  538. /* The 48 bits of standard directory, upper word */
  539. u64 pd_hi_val;
  540. struct md_pdir_high_fmt pd_hi_fmt;
  541. }md_pdir_high_t;
  542. struct md_pdir_low_shared_fmt {
  543. /* The meaning of lower directory, shared */
  544. u64 pds_lo_unused : 16,
  545. pds_lo_bvec : 26,
  546. pds_lo_cnt : 6,
  547. pds_lo_state : 3,
  548. pds_lo_ste : 1,
  549. pds_lo_prio : 4,
  550. pds_lo_ax : 1,
  551. pds_lo_ecc : 7;
  552. };
  553. struct md_pdir_low_exclusive_fmt {
  554. /* The meaning of lower directory, exclusive */
  555. u64 pde_lo_unused : 31,
  556. pde_lo_ptr : 11,
  557. pde_lo_unused1 : 6,
  558. pde_lo_state : 3,
  559. pde_lo_ste : 1,
  560. pde_lo_prio : 4,
  561. pde_lo_ax : 1,
  562. pde_lo_ecc : 7;
  563. };
  564. typedef union md_pdir_loent {
  565. /* The 48 bits of premium directory, lower word */
  566. u64 pd_lo_val;
  567. struct md_pdir_low_exclusive_fmt pde_lo_fmt;
  568. struct md_pdir_low_shared_fmt pds_lo_fmt;
  569. }md_pdir_low_t;
  570. /*
  571. * the following two "union" definitions and two
  572. * "struct" definitions are used in vmdump.c to
  573. * represent directory memory information.
  574. */
  575. typedef union md_dir_high {
  576. md_sdir_high_t md_sdir_high;
  577. md_pdir_high_t md_pdir_high;
  578. } md_dir_high_t;
  579. typedef union md_dir_low {
  580. md_sdir_low_t md_sdir_low;
  581. md_pdir_low_t md_pdir_low;
  582. } md_dir_low_t;
  583. typedef struct bddir_entry {
  584. md_dir_low_t md_dir_low;
  585. md_dir_high_t md_dir_high;
  586. } bddir_entry_t;
  587. typedef struct dir_mem_entry {
  588. u64 prcpf[MAX_REGIONS];
  589. bddir_entry_t directory_words[MD_PAGE_SIZE/CACHE_SLINE_SIZE];
  590. } dir_mem_entry_t;
  591. typedef union md_perf_sel {
  592. u64 perf_sel_reg;
  593. struct {
  594. u64 perf_rsvd : 60,
  595. perf_en : 1,
  596. perf_sel : 3;
  597. } perf_sel_bits;
  598. } md_perf_sel_t;
  599. typedef union md_perf_cnt {
  600. u64 perf_cnt;
  601. struct {
  602. u64 perf_rsvd : 44,
  603. perf_cnt : 20;
  604. } perf_cnt_bits;
  605. } md_perf_cnt_t;
  606. #endif /* !__ASSEMBLY__ */
  607. #define DIR_ERROR_VALID_MASK 0xe000000000000000
  608. #define DIR_ERROR_VALID_SHFT 61
  609. #define DIR_ERROR_VALID_UCE 0x8000000000000000
  610. #define DIR_ERROR_VALID_AE 0x4000000000000000
  611. #define DIR_ERROR_VALID_CE 0x2000000000000000
  612. #define MEM_ERROR_VALID_MASK 0xc000000000000000
  613. #define MEM_ERROR_VALID_SHFT 62
  614. #define MEM_ERROR_VALID_UCE 0x8000000000000000
  615. #define MEM_ERROR_VALID_CE 0x4000000000000000
  616. #define PROTO_ERROR_VALID_MASK 0x8000000000000000
  617. #define MISC_ERROR_VALID_MASK 0x3ff
  618. /*
  619. * Mask for hspec address that is stored in the dir error register.
  620. * This represents bits 29 through 3.
  621. */
  622. #define DIR_ERR_HSPEC_MASK 0x3ffffff8
  623. #define ERROR_HSPEC_MASK 0x3ffffff8
  624. #define ERROR_HSPEC_SHFT 3
  625. #define ERROR_ADDR_MASK 0xfffffff8
  626. #define ERROR_ADDR_SHFT 3
  627. /*
  628. * MD_MISC_ERROR register defines.
  629. */
  630. #define MMCE_VALID_MASK 0x3ff
  631. #define MMCE_ILL_MSG_SHFT 8
  632. #define MMCE_ILL_MSG_MASK (UINT64_CAST 0x03 << MMCE_ILL_MSG_SHFT)
  633. #define MMCE_ILL_REV_SHFT 6
  634. #define MMCE_ILL_REV_MASK (UINT64_CAST 0x03 << MMCE_ILL_REV_SHFT)
  635. #define MMCE_LONG_PACK_SHFT 4
  636. #define MMCE_LONG_PACK_MASK (UINT64_CAST 0x03 << MMCE_lONG_PACK_SHFT)
  637. #define MMCE_SHORT_PACK_SHFT 2
  638. #define MMCE_SHORT_PACK_MASK (UINT64_CAST 0x03 << MMCE_SHORT_PACK_SHFT)
  639. #define MMCE_BAD_DATA_SHFT 0
  640. #define MMCE_BAD_DATA_MASK (UINT64_CAST 0x03 << MMCE_BAD_DATA_SHFT)
  641. #define MD_PERF_COUNTERS 6
  642. #define MD_PERF_SETS 6
  643. #define MEM_DIMM_MASK 0xe0000000
  644. #define MEM_DIMM_SHFT 29
  645. #endif /* _ASM_SN_SN0_HUBMD_H */