heart.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * HEART chip definitions
  4. *
  5. * Copyright (C) 2004-2007 Stanislaw Skowronek <[email protected]>
  6. * 2009 Johannes Dickgreber <[email protected]>
  7. * 2007-2015 Joshua Kinard <[email protected]>
  8. */
  9. #ifndef __ASM_SGI_HEART_H
  10. #define __ASM_SGI_HEART_H
  11. #include <linux/types.h>
  12. #include <linux/time.h>
  13. /*
  14. * There are 8 DIMM slots on an IP30 system
  15. * board, which are grouped into four banks
  16. */
  17. #define HEART_MEMORY_BANKS 4
  18. /* HEART can support up to four CPUs */
  19. #define HEART_MAX_CPUS 4
  20. #define HEART_XKPHYS_BASE ((void *)(IO_BASE | 0x000000000ff00000ULL))
  21. /**
  22. * struct ip30_heart_regs - struct that maps IP30 HEART registers.
  23. * @mode: HEART_MODE - Purpose Unknown, machine reset called from here.
  24. * @sdram_mode: HEART_SDRAM_MODE - purpose unknown.
  25. * @mem_refresh: HEART_MEM_REF - purpose unknown.
  26. * @mem_req_arb: HEART_MEM_REQ_ARB - purpose unknown.
  27. * @mem_cfg.q: union for 64bit access to HEART_MEMCFG - 4x 64bit registers.
  28. * @mem_cfg.l: union for 32bit access to HEART_MEMCFG - 8x 32bit registers.
  29. * @fc_mode: HEART_FC_MODE - Purpose Unknown, possibly for GFX flow control.
  30. * @fc_timer_limit: HEART_FC_TIMER_LIMIT - purpose unknown.
  31. * @fc_addr: HEART_FC0_ADDR, HEART_FC1_ADDR - purpose unknown.
  32. * @fc_credit_cnt: HEART_FC0_CR_CNT, HEART_FC1_CR_CNT - purpose unknown.
  33. * @fc_timer: HEART_FC0_TIMER, HEART_FC1_TIMER - purpose unknown.
  34. * @status: HEART_STATUS - HEART status information.
  35. * @bus_err_addr: HEART_BERR_ADDR - likely contains addr of recent SIGBUS.
  36. * @bus_err_misc: HEART_BERR_MISC - purpose unknown.
  37. * @mem_err_addr: HEART_MEMERR_ADDR - likely contains addr of recent mem err.
  38. * @mem_err_data: HEART_MEMERR_DATA - purpose unknown.
  39. * @piur_acc_err: HEART_PIUR_ACC_ERR - likely for access err to HEART regs.
  40. * @mlan_clock_div: HEART_MLAN_CLK_DIV - MicroLAN clock divider.
  41. * @mlan_ctrl: HEART_MLAN_CTL - MicroLAN control.
  42. * @__pad0: 0x0f40 bytes of padding -> next HEART register 0x01000.
  43. * @undefined: Undefined/diag register, write to it triggers PIUR_ACC_ERR.
  44. * @__pad1: 0xeff8 bytes of padding -> next HEART register 0x10000.
  45. * @imr: HEART_IMR0 to HEART_IMR3 - per-cpu interrupt mask register.
  46. * @set_isr: HEART_SET_ISR - set interrupt status register.
  47. * @clear_isr: HEART_CLR_ISR - clear interrupt status register.
  48. * @isr: HEART_ISR - interrupt status register (read-only).
  49. * @imsr: HEART_IMSR - purpose unknown.
  50. * @cause: HEART_CAUSE - HEART cause information.
  51. * @__pad2: 0xffb8 bytes of padding -> next HEART register 0x20000.
  52. * @count: HEART_COUNT - 52-bit counter.
  53. * @__pad3: 0xfff8 bytes of padding -> next HEART register 0x30000.
  54. * @compare: HEART_COMPARE - 24-bit compare.
  55. * @__pad4: 0xfff8 bytes of padding -> next HEART register 0x40000.
  56. * @trigger: HEART_TRIGGER - purpose unknown.
  57. * @__pad5: 0xfff8 bytes of padding -> next HEART register 0x50000.
  58. * @cpuid: HEART_PRID - contains CPU ID of CPU currently accessing HEART.
  59. * @__pad6: 0xfff8 bytes of padding -> next HEART register 0x60000.
  60. * @sync: HEART_SYNC - purpose unknown.
  61. *
  62. * HEART is the main system controller ASIC for IP30 system. It incorporates
  63. * a memory controller, interrupt status/cause/set/clear management, basic
  64. * timer with count/compare, and other functionality. For Linux, not all of
  65. * HEART's functions are fully understood.
  66. *
  67. * Implementation note: All HEART registers are 64bits-wide, but the mem_cfg
  68. * register only reports correct values if queried in 32bits. Hence the need
  69. * for a union. Even though mem_cfg.l has 8 array slots, we only ever query
  70. * up to 4 of those. IP30 has 8 DIMM slots arranged into 4 banks, w/ 2 DIMMs
  71. * per bank. Each 32bit read accesses one of these banks. Perhaps HEART was
  72. * designed to address up to 8 banks (16 DIMMs)? We may never know.
  73. */
  74. struct ip30_heart_regs { /* 0x0ff00000 */
  75. u64 mode; /* + 0x00000 */
  76. /* Memory */
  77. u64 sdram_mode; /* + 0x00008 */
  78. u64 mem_refresh; /* + 0x00010 */
  79. u64 mem_req_arb; /* + 0x00018 */
  80. union {
  81. u64 q[HEART_MEMORY_BANKS]; /* readq() */
  82. u32 l[HEART_MEMORY_BANKS * 2]; /* readl() */
  83. } mem_cfg; /* + 0x00020 */
  84. /* Flow control (gfx?) */
  85. u64 fc_mode; /* + 0x00040 */
  86. u64 fc_timer_limit; /* + 0x00048 */
  87. u64 fc_addr[2]; /* + 0x00050 */
  88. u64 fc_credit_cnt[2]; /* + 0x00060 */
  89. u64 fc_timer[2]; /* + 0x00070 */
  90. /* Status */
  91. u64 status; /* + 0x00080 */
  92. /* Bus error */
  93. u64 bus_err_addr; /* + 0x00088 */
  94. u64 bus_err_misc; /* + 0x00090 */
  95. /* Memory error */
  96. u64 mem_err_addr; /* + 0x00098 */
  97. u64 mem_err_data; /* + 0x000a0 */
  98. /* Misc */
  99. u64 piur_acc_err; /* + 0x000a8 */
  100. u64 mlan_clock_div; /* + 0x000b0 */
  101. u64 mlan_ctrl; /* + 0x000b8 */
  102. u64 __pad0[0x01e8]; /* + 0x000c0 + 0x0f40 */
  103. /* Undefined */
  104. u64 undefined; /* + 0x01000 */
  105. u64 __pad1[0x1dff]; /* + 0x01008 + 0xeff8 */
  106. /* Interrupts */
  107. u64 imr[HEART_MAX_CPUS]; /* + 0x10000 */
  108. u64 set_isr; /* + 0x10020 */
  109. u64 clear_isr; /* + 0x10028 */
  110. u64 isr; /* + 0x10030 */
  111. u64 imsr; /* + 0x10038 */
  112. u64 cause; /* + 0x10040 */
  113. u64 __pad2[0x1ff7]; /* + 0x10048 + 0xffb8 */
  114. /* Timer */
  115. u64 count; /* + 0x20000 */
  116. u64 __pad3[0x1fff]; /* + 0x20008 + 0xfff8 */
  117. u64 compare; /* + 0x30000 */
  118. u64 __pad4[0x1fff]; /* + 0x30008 + 0xfff8 */
  119. u64 trigger; /* + 0x40000 */
  120. u64 __pad5[0x1fff]; /* + 0x40008 + 0xfff8 */
  121. /* Misc */
  122. u64 cpuid; /* + 0x50000 */
  123. u64 __pad6[0x1fff]; /* + 0x50008 + 0xfff8 */
  124. u64 sync; /* + 0x60000 */
  125. };
  126. /* For timer-related bits. */
  127. #define HEART_NS_PER_CYCLE 80
  128. #define HEART_CYCLES_PER_SEC (NSEC_PER_SEC / HEART_NS_PER_CYCLE)
  129. /*
  130. * XXX: Everything below this comment will either go away or be cleaned
  131. * up to fit in better with Linux. A lot of the bit definitions for
  132. * HEART were derived from IRIX's sys/RACER/heart.h header file.
  133. */
  134. /* HEART Masks */
  135. #define HEART_ATK_MASK 0x0007ffffffffffff /* HEART attack mask */
  136. #define HEART_ACK_ALL_MASK 0xffffffffffffffff /* Ack everything */
  137. #define HEART_CLR_ALL_MASK 0x0000000000000000 /* Clear all */
  138. #define HEART_BR_ERR_MASK 0x7ff8000000000000 /* BRIDGE error mask */
  139. #define HEART_CPU0_ERR_MASK 0x8ff8000000000000 /* CPU0 error mask */
  140. #define HEART_CPU1_ERR_MASK 0x97f8000000000000 /* CPU1 error mask */
  141. #define HEART_CPU2_ERR_MASK 0xa7f8000000000000 /* CPU2 error mask */
  142. #define HEART_CPU3_ERR_MASK 0xc7f8000000000000 /* CPU3 error mask */
  143. #define HEART_ERR_MASK 0x1ff /* HEART error mask */
  144. #define HEART_ERR_MASK_START 51 /* HEART error start */
  145. #define HEART_ERR_MASK_END 63 /* HEART error end */
  146. /* Bits in the HEART_MODE register. */
  147. #define HM_PROC_DISABLE_SHFT 60
  148. #define HM_PROC_DISABLE_MSK (0xfUL << HM_PROC_DISABLE_SHFT)
  149. #define HM_PROC_DISABLE(x) (0x1UL << (x) + HM_PROC_DISABLE_SHFT)
  150. #define HM_MAX_PSR (0x7UL << 57)
  151. #define HM_MAX_IOSR (0x7UL << 54)
  152. #define HM_MAX_PEND_IOSR (0x7UL << 51)
  153. #define HM_TRIG_SRC_SEL_MSK (0x7UL << 48)
  154. #define HM_TRIG_HEART_EXC (0x0UL << 48)
  155. #define HM_TRIG_REG_BIT (0x1UL << 48)
  156. #define HM_TRIG_SYSCLK (0x2UL << 48)
  157. #define HM_TRIG_MEMCLK_2X (0x3UL << 48)
  158. #define HM_TRIG_MEMCLK (0x4UL << 48)
  159. #define HM_TRIG_IOCLK (0x5UL << 48)
  160. #define HM_PIU_TEST_MODE (0xfUL << 40)
  161. #define HM_GP_FLAG_MSK (0xfUL << 36)
  162. #define HM_GP_FLAG(x) BIT((x) + 36)
  163. #define HM_MAX_PROC_HYST (0xfUL << 32)
  164. #define HM_LLP_WRST_AFTER_RST BIT(28)
  165. #define HM_LLP_LINK_RST BIT(27)
  166. #define HM_LLP_WARM_RST BIT(26)
  167. #define HM_COR_ECC_LCK BIT(25)
  168. #define HM_REDUCED_PWR BIT(24)
  169. #define HM_COLD_RST BIT(23)
  170. #define HM_SW_RST BIT(22)
  171. #define HM_MEM_FORCE_WR BIT(21)
  172. #define HM_DB_ERR_GEN BIT(20)
  173. #define HM_SB_ERR_GEN BIT(19)
  174. #define HM_CACHED_PIO_EN BIT(18)
  175. #define HM_CACHED_PROM_EN BIT(17)
  176. #define HM_PE_SYS_COR_ERE BIT(16)
  177. #define HM_GLOBAL_ECC_EN BIT(15)
  178. #define HM_IO_COH_EN BIT(14)
  179. #define HM_INT_EN BIT(13)
  180. #define HM_DATA_CHK_EN BIT(12)
  181. #define HM_REF_EN BIT(11)
  182. #define HM_BAD_SYSWR_ERE BIT(10)
  183. #define HM_BAD_SYSRD_ERE BIT(9)
  184. #define HM_SYSSTATE_ERE BIT(8)
  185. #define HM_SYSCMD_ERE BIT(7)
  186. #define HM_NCOR_SYS_ERE BIT(6)
  187. #define HM_COR_SYS_ERE BIT(5)
  188. #define HM_DATA_ELMNT_ERE BIT(4)
  189. #define HM_MEM_ADDR_PROC_ERE BIT(3)
  190. #define HM_MEM_ADDR_IO_ERE BIT(2)
  191. #define HM_NCOR_MEM_ERE BIT(1)
  192. #define HM_COR_MEM_ERE BIT(0)
  193. /* Bits in the HEART_MEM_REF register. */
  194. #define HEART_MEMREF_REFS(x) ((0xfUL & (x)) << 16)
  195. #define HEART_MEMREF_PERIOD(x) ((0xffffUL & (x)))
  196. #define HEART_MEMREF_REFS_VAL HEART_MEMREF_REFS(8)
  197. #define HEART_MEMREF_PERIOD_VAL HEART_MEMREF_PERIOD(0x4000)
  198. #define HEART_MEMREF_VAL (HEART_MEMREF_REFS_VAL | \
  199. HEART_MEMREF_PERIOD_VAL)
  200. /* Bits in the HEART_MEM_REQ_ARB register. */
  201. #define HEART_MEMARB_IODIS (1 << 20)
  202. #define HEART_MEMARB_MAXPMWRQS (15 << 16)
  203. #define HEART_MEMARB_MAXPMRRQS (15 << 12)
  204. #define HEART_MEMARB_MAXPMRQS (15 << 8)
  205. #define HEART_MEMARB_MAXRRRQS (15 << 4)
  206. #define HEART_MEMARB_MAXGBRRQS (15)
  207. /* Bits in the HEART_MEMCFG<x> registers. */
  208. #define HEART_MEMCFG_VALID 0x80000000 /* Bank is valid */
  209. #define HEART_MEMCFG_DENSITY 0x01c00000 /* Mem density */
  210. #define HEART_MEMCFG_SIZE_MASK 0x003f0000 /* Mem size mask */
  211. #define HEART_MEMCFG_ADDR_MASK 0x000001ff /* Base addr mask */
  212. #define HEART_MEMCFG_SIZE_SHIFT 16 /* Mem size shift */
  213. #define HEART_MEMCFG_DENSITY_SHIFT 22 /* Density Shift */
  214. #define HEART_MEMCFG_UNIT_SHIFT 25 /* Unit Shift, 32MB */
  215. /* Bits in the HEART_STATUS register */
  216. #define HEART_STAT_HSTL_SDRV BIT(14)
  217. #define HEART_STAT_FC_CR_OUT(x) BIT((x) + 12)
  218. #define HEART_STAT_DIR_CNNCT BIT(11)
  219. #define HEART_STAT_TRITON BIT(10)
  220. #define HEART_STAT_R4K BIT(9)
  221. #define HEART_STAT_BIG_ENDIAN BIT(8)
  222. #define HEART_STAT_PROC_SHFT 4
  223. #define HEART_STAT_PROC_MSK (0xfUL << HEART_STAT_PROC_SHFT)
  224. #define HEART_STAT_PROC_ACTIVE(x) (0x1UL << ((x) + HEART_STAT_PROC_SHFT))
  225. #define HEART_STAT_WIDGET_ID 0xf
  226. /* Bits in the HEART_CAUSE register */
  227. #define HC_PE_SYS_COR_ERR_MSK (0xfUL << 60)
  228. #define HC_PE_SYS_COR_ERR(x) BIT((x) + 60)
  229. #define HC_PIOWDB_OFLOW BIT(44)
  230. #define HC_PIORWRB_OFLOW BIT(43)
  231. #define HC_PIUR_ACC_ERR BIT(42)
  232. #define HC_BAD_SYSWR_ERR BIT(41)
  233. #define HC_BAD_SYSRD_ERR BIT(40)
  234. #define HC_SYSSTATE_ERR_MSK (0xfUL << 36)
  235. #define HC_SYSSTATE_ERR(x) BIT((x) + 36)
  236. #define HC_SYSCMD_ERR_MSK (0xfUL << 32)
  237. #define HC_SYSCMD_ERR(x) BIT((x) + 32)
  238. #define HC_NCOR_SYSAD_ERR_MSK (0xfUL << 28)
  239. #define HC_NCOR_SYSAD_ERR(x) BIT((x) + 28)
  240. #define HC_COR_SYSAD_ERR_MSK (0xfUL << 24)
  241. #define HC_COR_SYSAD_ERR(x) BIT((x) + 24)
  242. #define HC_DATA_ELMNT_ERR_MSK (0xfUL << 20)
  243. #define HC_DATA_ELMNT_ERR(x) BIT((x) + 20)
  244. #define HC_WIDGET_ERR BIT(16)
  245. #define HC_MEM_ADDR_ERR_PROC_MSK (0xfUL << 4)
  246. #define HC_MEM_ADDR_ERR_PROC(x) BIT((x) + 4)
  247. #define HC_MEM_ADDR_ERR_IO BIT(2)
  248. #define HC_NCOR_MEM_ERR BIT(1)
  249. #define HC_COR_MEM_ERR BIT(0)
  250. /*
  251. * HEART has 64 interrupt vectors available to it, subdivided into five
  252. * priority levels. They are numbered 0 to 63.
  253. */
  254. #define HEART_NUM_IRQS 64
  255. /*
  256. * These are the five interrupt priority levels and their corresponding
  257. * CPU IPx interrupt pins.
  258. *
  259. * Level 4 - Error Interrupts.
  260. * Level 3 - HEART timer interrupt.
  261. * Level 2 - CPU IPI, CPU debug, power putton, general device interrupts.
  262. * Level 1 - General device interrupts.
  263. * Level 0 - General device GFX flow control interrupts.
  264. */
  265. #define HEART_L4_INT_MASK 0xfff8000000000000ULL /* IP6 */
  266. #define HEART_L3_INT_MASK 0x0004000000000000ULL /* IP5 */
  267. #define HEART_L2_INT_MASK 0x0003ffff00000000ULL /* IP4 */
  268. #define HEART_L1_INT_MASK 0x00000000ffff0000ULL /* IP3 */
  269. #define HEART_L0_INT_MASK 0x000000000000ffffULL /* IP2 */
  270. /* HEART L0 Interrupts (Low Priority) */
  271. #define HEART_L0_INT_GENERIC 0
  272. #define HEART_L0_INT_FLOW_CTRL_HWTR_0 1
  273. #define HEART_L0_INT_FLOW_CTRL_HWTR_1 2
  274. /* HEART L2 Interrupts (High Priority) */
  275. #define HEART_L2_INT_RESCHED_CPU_0 46
  276. #define HEART_L2_INT_RESCHED_CPU_1 47
  277. #define HEART_L2_INT_CALL_CPU_0 48
  278. #define HEART_L2_INT_CALL_CPU_1 49
  279. /* HEART L3 Interrupts (Compare/Counter Timer) */
  280. #define HEART_L3_INT_TIMER 50
  281. /* HEART L4 Interrupts (Errors) */
  282. #define HEART_L4_INT_XWID_ERR_9 51
  283. #define HEART_L4_INT_XWID_ERR_A 52
  284. #define HEART_L4_INT_XWID_ERR_B 53
  285. #define HEART_L4_INT_XWID_ERR_C 54
  286. #define HEART_L4_INT_XWID_ERR_D 55
  287. #define HEART_L4_INT_XWID_ERR_E 56
  288. #define HEART_L4_INT_XWID_ERR_F 57
  289. #define HEART_L4_INT_XWID_ERR_XBOW 58
  290. #define HEART_L4_INT_CPU_BUS_ERR_0 59
  291. #define HEART_L4_INT_CPU_BUS_ERR_1 60
  292. #define HEART_L4_INT_CPU_BUS_ERR_2 61
  293. #define HEART_L4_INT_CPU_BUS_ERR_3 62
  294. #define HEART_L4_INT_HEART_EXCP 63
  295. extern struct ip30_heart_regs __iomem *heart_regs;
  296. #define heart_read ____raw_readq
  297. #define heart_write ____raw_writeq
  298. #endif /* __ASM_SGI_HEART_H */