hubmd.h 26 KB

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