obio.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * obio.h: Some useful locations in 0xFXXXXXXXX PA obio space on sun4d.
  4. *
  5. * Copyright (C) 1997 Jakub Jelinek <[email protected]>
  6. */
  7. #ifndef _SPARC_OBIO_H
  8. #define _SPARC_OBIO_H
  9. #include <asm/asi.h>
  10. /* This weird monster likes to use the very upper parts of
  11. 36bit PA for these things :) */
  12. /* CSR space (for each XDBUS)
  13. * ------------------------------------------------------------------------
  14. * | 0xFE | DEVID | | XDBUS ID | |
  15. * ------------------------------------------------------------------------
  16. * 35 28 27 20 19 10 9 8 7 0
  17. */
  18. #define CSR_BASE_ADDR 0xe0000000
  19. #define CSR_CPU_SHIFT (32 - 4 - 5)
  20. #define CSR_XDBUS_SHIFT 8
  21. #define CSR_BASE(cpu) (((CSR_BASE_ADDR >> CSR_CPU_SHIFT) + cpu) << CSR_CPU_SHIFT)
  22. /* ECSR space (not for each XDBUS)
  23. * ------------------------------------------------------------------------
  24. * | 0xF | DEVID[7:1] | |
  25. * ------------------------------------------------------------------------
  26. * 35 32 31 25 24 0
  27. */
  28. #define ECSR_BASE_ADDR 0x00000000
  29. #define ECSR_CPU_SHIFT (32 - 5)
  30. #define ECSR_DEV_SHIFT (32 - 8)
  31. #define ECSR_BASE(cpu) ((cpu) << ECSR_CPU_SHIFT)
  32. #define ECSR_DEV_BASE(devid) ((devid) << ECSR_DEV_SHIFT)
  33. /* Bus Watcher */
  34. #define BW_LOCAL_BASE 0xfff00000
  35. #define BW_CID 0x00000000
  36. #define BW_DBUS_CTRL 0x00000008
  37. #define BW_DBUS_DATA 0x00000010
  38. #define BW_CTRL 0x00001000
  39. #define BW_INTR_TABLE 0x00001040
  40. #define BW_INTR_TABLE_CLEAR 0x00001080
  41. #define BW_PRESCALER 0x000010c0
  42. #define BW_PTIMER_LIMIT 0x00002000
  43. #define BW_PTIMER_COUNTER2 0x00002004
  44. #define BW_PTIMER_NDLIMIT 0x00002008
  45. #define BW_PTIMER_CTRL 0x0000200c
  46. #define BW_PTIMER_COUNTER 0x00002010
  47. #define BW_TIMER_LIMIT 0x00003000
  48. #define BW_TIMER_COUNTER2 0x00003004
  49. #define BW_TIMER_NDLIMIT 0x00003008
  50. #define BW_TIMER_CTRL 0x0000300c
  51. #define BW_TIMER_COUNTER 0x00003010
  52. /* BW Control */
  53. #define BW_CTRL_USER_TIMER 0x00000004 /* Is User Timer Free run enabled */
  54. /* Boot Bus */
  55. #define BB_LOCAL_BASE 0xf0000000
  56. #define BB_STAT1 0x00100000
  57. #define BB_STAT2 0x00120000
  58. #define BB_STAT3 0x00140000
  59. #define BB_LEDS 0x002e0000
  60. /* Bits in BB_STAT2 */
  61. #define BB_STAT2_AC_INTR 0x04 /* Aiee! 5ms and power is gone... */
  62. #define BB_STAT2_TMP_INTR 0x10 /* My Penguins are burning. Are you able to smell it? */
  63. #define BB_STAT2_FAN_INTR 0x20 /* My fan refuses to work */
  64. #define BB_STAT2_PWR_INTR 0x40 /* On SC2000, one of the two ACs died. Ok, we go on... */
  65. #define BB_STAT2_MASK (BB_STAT2_AC_INTR|BB_STAT2_TMP_INTR|BB_STAT2_FAN_INTR|BB_STAT2_PWR_INTR)
  66. /* Cache Controller */
  67. #define CC_BASE 0x1F00000
  68. #define CC_DATSTREAM 0x1F00000 /* Data stream register */
  69. #define CC_DATSIZE 0x1F0003F /* Size */
  70. #define CC_SRCSTREAM 0x1F00100 /* Source stream register */
  71. #define CC_DESSTREAM 0x1F00200 /* Destination stream register */
  72. #define CC_RMCOUNT 0x1F00300 /* Count of references and misses */
  73. #define CC_IPEN 0x1F00406 /* Pending Interrupts */
  74. #define CC_IMSK 0x1F00506 /* Interrupt Mask */
  75. #define CC_ICLR 0x1F00606 /* Clear pending Interrupts */
  76. #define CC_IGEN 0x1F00704 /* Generate Interrupt register */
  77. #define CC_STEST 0x1F00804 /* Internal self-test */
  78. #define CC_CREG 0x1F00A04 /* Control register */
  79. #define CC_SREG 0x1F00B00 /* Status register */
  80. #define CC_RREG 0x1F00C04 /* Reset register */
  81. #define CC_EREG 0x1F00E00 /* Error code register */
  82. #define CC_CID 0x1F00F04 /* Component ID */
  83. #ifndef __ASSEMBLY__
  84. static inline int bw_get_intr_mask(int sbus_level)
  85. {
  86. int mask;
  87. __asm__ __volatile__ ("lduha [%1] %2, %0" :
  88. "=r" (mask) :
  89. "r" (BW_LOCAL_BASE + BW_INTR_TABLE + (sbus_level << 3)),
  90. "i" (ASI_M_CTL));
  91. return mask;
  92. }
  93. static inline void bw_clear_intr_mask(int sbus_level, int mask)
  94. {
  95. __asm__ __volatile__ ("stha %0, [%1] %2" : :
  96. "r" (mask),
  97. "r" (BW_LOCAL_BASE + BW_INTR_TABLE_CLEAR + (sbus_level << 3)),
  98. "i" (ASI_M_CTL));
  99. }
  100. static inline unsigned int bw_get_prof_limit(int cpu)
  101. {
  102. unsigned int limit;
  103. __asm__ __volatile__ ("lda [%1] %2, %0" :
  104. "=r" (limit) :
  105. "r" (CSR_BASE(cpu) + BW_PTIMER_LIMIT),
  106. "i" (ASI_M_CTL));
  107. return limit;
  108. }
  109. static inline void bw_set_prof_limit(int cpu, unsigned int limit)
  110. {
  111. __asm__ __volatile__ ("sta %0, [%1] %2" : :
  112. "r" (limit),
  113. "r" (CSR_BASE(cpu) + BW_PTIMER_LIMIT),
  114. "i" (ASI_M_CTL));
  115. }
  116. static inline unsigned int bw_get_ctrl(int cpu)
  117. {
  118. unsigned int ctrl;
  119. __asm__ __volatile__ ("lda [%1] %2, %0" :
  120. "=r" (ctrl) :
  121. "r" (CSR_BASE(cpu) + BW_CTRL),
  122. "i" (ASI_M_CTL));
  123. return ctrl;
  124. }
  125. static inline void bw_set_ctrl(int cpu, unsigned int ctrl)
  126. {
  127. __asm__ __volatile__ ("sta %0, [%1] %2" : :
  128. "r" (ctrl),
  129. "r" (CSR_BASE(cpu) + BW_CTRL),
  130. "i" (ASI_M_CTL));
  131. }
  132. static inline unsigned int cc_get_ipen(void)
  133. {
  134. unsigned int pending;
  135. __asm__ __volatile__ ("lduha [%1] %2, %0" :
  136. "=r" (pending) :
  137. "r" (CC_IPEN),
  138. "i" (ASI_M_MXCC));
  139. return pending;
  140. }
  141. static inline void cc_set_iclr(unsigned int clear)
  142. {
  143. __asm__ __volatile__ ("stha %0, [%1] %2" : :
  144. "r" (clear),
  145. "r" (CC_ICLR),
  146. "i" (ASI_M_MXCC));
  147. }
  148. static inline unsigned int cc_get_imsk(void)
  149. {
  150. unsigned int mask;
  151. __asm__ __volatile__ ("lduha [%1] %2, %0" :
  152. "=r" (mask) :
  153. "r" (CC_IMSK),
  154. "i" (ASI_M_MXCC));
  155. return mask;
  156. }
  157. static inline void cc_set_imsk(unsigned int mask)
  158. {
  159. __asm__ __volatile__ ("stha %0, [%1] %2" : :
  160. "r" (mask),
  161. "r" (CC_IMSK),
  162. "i" (ASI_M_MXCC));
  163. }
  164. static inline unsigned int cc_get_imsk_other(int cpuid)
  165. {
  166. unsigned int mask;
  167. __asm__ __volatile__ ("lduha [%1] %2, %0" :
  168. "=r" (mask) :
  169. "r" (ECSR_BASE(cpuid) | CC_IMSK),
  170. "i" (ASI_M_CTL));
  171. return mask;
  172. }
  173. static inline void cc_set_imsk_other(int cpuid, unsigned int mask)
  174. {
  175. __asm__ __volatile__ ("stha %0, [%1] %2" : :
  176. "r" (mask),
  177. "r" (ECSR_BASE(cpuid) | CC_IMSK),
  178. "i" (ASI_M_CTL));
  179. }
  180. static inline void cc_set_igen(unsigned int gen)
  181. {
  182. __asm__ __volatile__ ("sta %0, [%1] %2" : :
  183. "r" (gen),
  184. "r" (CC_IGEN),
  185. "i" (ASI_M_MXCC));
  186. }
  187. #endif /* !__ASSEMBLY__ */
  188. #endif /* !(_SPARC_OBIO_H) */