obio.h 7.0 KB

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