obio.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. /*
  2. * obio.h: Some useful locations in 0xFXXXXXXXX PA obio space on sun4d.
  3. *
  4. * Copyright (C) 1997 Jakub Jelinek <[email protected]>
  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 int bw_get_prof_limit(int cpu)
  100. {
  101. unsigned int 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 int 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 int bw_get_ctrl(int cpu)
  116. {
  117. unsigned int 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 int 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. static inline unsigned int cc_get_ipen(void)
  132. {
  133. unsigned int pending;
  134. __asm__ __volatile__ ("lduha [%1] %2, %0" :
  135. "=r" (pending) :
  136. "r" (CC_IPEN),
  137. "i" (ASI_M_MXCC));
  138. return pending;
  139. }
  140. static inline void cc_set_iclr(unsigned int clear)
  141. {
  142. __asm__ __volatile__ ("stha %0, [%1] %2" : :
  143. "r" (clear),
  144. "r" (CC_ICLR),
  145. "i" (ASI_M_MXCC));
  146. }
  147. static inline unsigned int cc_get_imsk(void)
  148. {
  149. unsigned int mask;
  150. __asm__ __volatile__ ("lduha [%1] %2, %0" :
  151. "=r" (mask) :
  152. "r" (CC_IMSK),
  153. "i" (ASI_M_MXCC));
  154. return mask;
  155. }
  156. static inline void cc_set_imsk(unsigned int mask)
  157. {
  158. __asm__ __volatile__ ("stha %0, [%1] %2" : :
  159. "r" (mask),
  160. "r" (CC_IMSK),
  161. "i" (ASI_M_MXCC));
  162. }
  163. static inline unsigned int cc_get_imsk_other(int cpuid)
  164. {
  165. unsigned int mask;
  166. __asm__ __volatile__ ("lduha [%1] %2, %0" :
  167. "=r" (mask) :
  168. "r" (ECSR_BASE(cpuid) | CC_IMSK),
  169. "i" (ASI_M_CTL));
  170. return mask;
  171. }
  172. static inline void cc_set_imsk_other(int cpuid, unsigned int mask)
  173. {
  174. __asm__ __volatile__ ("stha %0, [%1] %2" : :
  175. "r" (mask),
  176. "r" (ECSR_BASE(cpuid) | CC_IMSK),
  177. "i" (ASI_M_CTL));
  178. }
  179. static inline void cc_set_igen(unsigned int gen)
  180. {
  181. __asm__ __volatile__ ("sta %0, [%1] %2" : :
  182. "r" (gen),
  183. "r" (CC_IGEN),
  184. "i" (ASI_M_MXCC));
  185. }
  186. #endif /* !__ASSEMBLY__ */
  187. #endif /* !(_SPARC_OBIO_H) */