core_tsunami.h 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. #ifndef __ALPHA_TSUNAMI__H__
  2. #define __ALPHA_TSUNAMI__H__
  3. #include <linux/types.h>
  4. #include <linux/pci.h>
  5. #include <asm/compiler.h>
  6. /*
  7. * TSUNAMI/TYPHOON are the internal names for the core logic chipset which
  8. * provides memory controller and PCI access for the 21264 based systems.
  9. *
  10. * This file is based on:
  11. *
  12. * Tsunami System Programmers Manual
  13. * Preliminary, Chapters 2-5
  14. *
  15. */
  16. /* XXX: Do we need to conditionalize on this? */
  17. #ifdef USE_48_BIT_KSEG
  18. #define TS_BIAS 0x80000000000UL
  19. #else
  20. #define TS_BIAS 0x10000000000UL
  21. #endif
  22. /*
  23. * CChip, DChip, and PChip registers
  24. */
  25. typedef struct {
  26. volatile unsigned long csr __attribute__((aligned(64)));
  27. } tsunami_64;
  28. typedef struct {
  29. tsunami_64 csc;
  30. tsunami_64 mtr;
  31. tsunami_64 misc;
  32. tsunami_64 mpd;
  33. tsunami_64 aar0;
  34. tsunami_64 aar1;
  35. tsunami_64 aar2;
  36. tsunami_64 aar3;
  37. tsunami_64 dim0;
  38. tsunami_64 dim1;
  39. tsunami_64 dir0;
  40. tsunami_64 dir1;
  41. tsunami_64 drir;
  42. tsunami_64 prben;
  43. tsunami_64 iic; /* a.k.a. iic0 */
  44. tsunami_64 wdr; /* a.k.a. iic1 */
  45. tsunami_64 mpr0;
  46. tsunami_64 mpr1;
  47. tsunami_64 mpr2;
  48. tsunami_64 mpr3;
  49. tsunami_64 mctl;
  50. tsunami_64 __pad1;
  51. tsunami_64 ttr;
  52. tsunami_64 tdr;
  53. tsunami_64 dim2;
  54. tsunami_64 dim3;
  55. tsunami_64 dir2;
  56. tsunami_64 dir3;
  57. tsunami_64 iic2;
  58. tsunami_64 iic3;
  59. } tsunami_cchip;
  60. typedef struct {
  61. tsunami_64 dsc;
  62. tsunami_64 str;
  63. tsunami_64 drev;
  64. } tsunami_dchip;
  65. typedef struct {
  66. tsunami_64 wsba[4];
  67. tsunami_64 wsm[4];
  68. tsunami_64 tba[4];
  69. tsunami_64 pctl;
  70. tsunami_64 plat;
  71. tsunami_64 reserved;
  72. tsunami_64 perror;
  73. tsunami_64 perrmask;
  74. tsunami_64 perrset;
  75. tsunami_64 tlbiv;
  76. tsunami_64 tlbia;
  77. tsunami_64 pmonctl;
  78. tsunami_64 pmoncnt;
  79. } tsunami_pchip;
  80. #define TSUNAMI_cchip ((tsunami_cchip *)(IDENT_ADDR+TS_BIAS+0x1A0000000UL))
  81. #define TSUNAMI_dchip ((tsunami_dchip *)(IDENT_ADDR+TS_BIAS+0x1B0000800UL))
  82. #define TSUNAMI_pchip0 ((tsunami_pchip *)(IDENT_ADDR+TS_BIAS+0x180000000UL))
  83. #define TSUNAMI_pchip1 ((tsunami_pchip *)(IDENT_ADDR+TS_BIAS+0x380000000UL))
  84. extern int TSUNAMI_bootcpu;
  85. /*
  86. * TSUNAMI Pchip Error register.
  87. */
  88. #define perror_m_lost 0x1
  89. #define perror_m_serr 0x2
  90. #define perror_m_perr 0x4
  91. #define perror_m_dcrto 0x8
  92. #define perror_m_sge 0x10
  93. #define perror_m_ape 0x20
  94. #define perror_m_ta 0x40
  95. #define perror_m_rdpe 0x80
  96. #define perror_m_nds 0x100
  97. #define perror_m_rto 0x200
  98. #define perror_m_uecc 0x400
  99. #define perror_m_cre 0x800
  100. #define perror_m_addrl 0xFFFFFFFF0000UL
  101. #define perror_m_addrh 0x7000000000000UL
  102. #define perror_m_cmd 0xF0000000000000UL
  103. #define perror_m_syn 0xFF00000000000000UL
  104. union TPchipPERROR {
  105. struct {
  106. unsigned int perror_v_lost : 1;
  107. unsigned perror_v_serr : 1;
  108. unsigned perror_v_perr : 1;
  109. unsigned perror_v_dcrto : 1;
  110. unsigned perror_v_sge : 1;
  111. unsigned perror_v_ape : 1;
  112. unsigned perror_v_ta : 1;
  113. unsigned perror_v_rdpe : 1;
  114. unsigned perror_v_nds : 1;
  115. unsigned perror_v_rto : 1;
  116. unsigned perror_v_uecc : 1;
  117. unsigned perror_v_cre : 1;
  118. unsigned perror_v_rsvd1 : 4;
  119. unsigned perror_v_addrl : 32;
  120. unsigned perror_v_addrh : 3;
  121. unsigned perror_v_rsvd2 : 1;
  122. unsigned perror_v_cmd : 4;
  123. unsigned perror_v_syn : 8;
  124. } perror_r_bits;
  125. int perror_q_whole [2];
  126. };
  127. /*
  128. * TSUNAMI Pchip Window Space Base Address register.
  129. */
  130. #define wsba_m_ena 0x1
  131. #define wsba_m_sg 0x2
  132. #define wsba_m_ptp 0x4
  133. #define wsba_m_addr 0xFFF00000
  134. #define wmask_k_sz1gb 0x3FF00000
  135. union TPchipWSBA {
  136. struct {
  137. unsigned wsba_v_ena : 1;
  138. unsigned wsba_v_sg : 1;
  139. unsigned wsba_v_ptp : 1;
  140. unsigned wsba_v_rsvd1 : 17;
  141. unsigned wsba_v_addr : 12;
  142. unsigned wsba_v_rsvd2 : 32;
  143. } wsba_r_bits;
  144. int wsba_q_whole [2];
  145. };
  146. /*
  147. * TSUNAMI Pchip Control Register
  148. */
  149. #define pctl_m_fdsc 0x1
  150. #define pctl_m_fbtb 0x2
  151. #define pctl_m_thdis 0x4
  152. #define pctl_m_chaindis 0x8
  153. #define pctl_m_tgtlat 0x10
  154. #define pctl_m_hole 0x20
  155. #define pctl_m_mwin 0x40
  156. #define pctl_m_arbena 0x80
  157. #define pctl_m_prigrp 0x7F00
  158. #define pctl_m_ppri 0x8000
  159. #define pctl_m_rsvd1 0x30000
  160. #define pctl_m_eccen 0x40000
  161. #define pctl_m_padm 0x80000
  162. #define pctl_m_cdqmax 0xF00000
  163. #define pctl_m_rev 0xFF000000
  164. #define pctl_m_crqmax 0xF00000000UL
  165. #define pctl_m_ptpmax 0xF000000000UL
  166. #define pctl_m_pclkx 0x30000000000UL
  167. #define pctl_m_fdsdis 0x40000000000UL
  168. #define pctl_m_fdwdis 0x80000000000UL
  169. #define pctl_m_ptevrfy 0x100000000000UL
  170. #define pctl_m_rpp 0x200000000000UL
  171. #define pctl_m_pid 0xC00000000000UL
  172. #define pctl_m_rsvd2 0xFFFF000000000000UL
  173. union TPchipPCTL {
  174. struct {
  175. unsigned pctl_v_fdsc : 1;
  176. unsigned pctl_v_fbtb : 1;
  177. unsigned pctl_v_thdis : 1;
  178. unsigned pctl_v_chaindis : 1;
  179. unsigned pctl_v_tgtlat : 1;
  180. unsigned pctl_v_hole : 1;
  181. unsigned pctl_v_mwin : 1;
  182. unsigned pctl_v_arbena : 1;
  183. unsigned pctl_v_prigrp : 7;
  184. unsigned pctl_v_ppri : 1;
  185. unsigned pctl_v_rsvd1 : 2;
  186. unsigned pctl_v_eccen : 1;
  187. unsigned pctl_v_padm : 1;
  188. unsigned pctl_v_cdqmax : 4;
  189. unsigned pctl_v_rev : 8;
  190. unsigned pctl_v_crqmax : 4;
  191. unsigned pctl_v_ptpmax : 4;
  192. unsigned pctl_v_pclkx : 2;
  193. unsigned pctl_v_fdsdis : 1;
  194. unsigned pctl_v_fdwdis : 1;
  195. unsigned pctl_v_ptevrfy : 1;
  196. unsigned pctl_v_rpp : 1;
  197. unsigned pctl_v_pid : 2;
  198. unsigned pctl_v_rsvd2 : 16;
  199. } pctl_r_bits;
  200. int pctl_q_whole [2];
  201. };
  202. /*
  203. * TSUNAMI Pchip Error Mask Register.
  204. */
  205. #define perrmask_m_lost 0x1
  206. #define perrmask_m_serr 0x2
  207. #define perrmask_m_perr 0x4
  208. #define perrmask_m_dcrto 0x8
  209. #define perrmask_m_sge 0x10
  210. #define perrmask_m_ape 0x20
  211. #define perrmask_m_ta 0x40
  212. #define perrmask_m_rdpe 0x80
  213. #define perrmask_m_nds 0x100
  214. #define perrmask_m_rto 0x200
  215. #define perrmask_m_uecc 0x400
  216. #define perrmask_m_cre 0x800
  217. #define perrmask_m_rsvd 0xFFFFFFFFFFFFF000UL
  218. union TPchipPERRMASK {
  219. struct {
  220. unsigned int perrmask_v_lost : 1;
  221. unsigned perrmask_v_serr : 1;
  222. unsigned perrmask_v_perr : 1;
  223. unsigned perrmask_v_dcrto : 1;
  224. unsigned perrmask_v_sge : 1;
  225. unsigned perrmask_v_ape : 1;
  226. unsigned perrmask_v_ta : 1;
  227. unsigned perrmask_v_rdpe : 1;
  228. unsigned perrmask_v_nds : 1;
  229. unsigned perrmask_v_rto : 1;
  230. unsigned perrmask_v_uecc : 1;
  231. unsigned perrmask_v_cre : 1;
  232. unsigned perrmask_v_rsvd1 : 20;
  233. unsigned perrmask_v_rsvd2 : 32;
  234. } perrmask_r_bits;
  235. int perrmask_q_whole [2];
  236. };
  237. /*
  238. * Memory spaces:
  239. */
  240. #define TSUNAMI_HOSE(h) (((unsigned long)(h)) << 33)
  241. #define TSUNAMI_BASE (IDENT_ADDR + TS_BIAS)
  242. #define TSUNAMI_MEM(h) (TSUNAMI_BASE+TSUNAMI_HOSE(h) + 0x000000000UL)
  243. #define _TSUNAMI_IACK_SC(h) (TSUNAMI_BASE+TSUNAMI_HOSE(h) + 0x1F8000000UL)
  244. #define TSUNAMI_IO(h) (TSUNAMI_BASE+TSUNAMI_HOSE(h) + 0x1FC000000UL)
  245. #define TSUNAMI_CONF(h) (TSUNAMI_BASE+TSUNAMI_HOSE(h) + 0x1FE000000UL)
  246. #define TSUNAMI_IACK_SC _TSUNAMI_IACK_SC(0) /* hack! */
  247. /*
  248. * The canonical non-remaped I/O and MEM addresses have these values
  249. * subtracted out. This is arranged so that folks manipulating ISA
  250. * devices can use their familiar numbers and have them map to bus 0.
  251. */
  252. #define TSUNAMI_IO_BIAS TSUNAMI_IO(0)
  253. #define TSUNAMI_MEM_BIAS TSUNAMI_MEM(0)
  254. /* The IO address space is larger than 0xffff */
  255. #define TSUNAMI_IO_SPACE (TSUNAMI_CONF(0) - TSUNAMI_IO(0))
  256. /* Offset between ram physical addresses and pci64 DAC bus addresses. */
  257. #define TSUNAMI_DAC_OFFSET (1UL << 40)
  258. /*
  259. * Data structure for handling TSUNAMI machine checks:
  260. */
  261. struct el_TSUNAMI_sysdata_mcheck {
  262. };
  263. #ifdef __KERNEL__
  264. #ifndef __EXTERN_INLINE
  265. #define __EXTERN_INLINE extern inline
  266. #define __IO_EXTERN_INLINE
  267. #endif
  268. /*
  269. * I/O functions:
  270. *
  271. * TSUNAMI, the 21??? PCI/memory support chipset for the EV6 (21264)
  272. * can only use linear accesses to get at PCI memory and I/O spaces.
  273. */
  274. /*
  275. * Memory functions. all accesses are done through linear space.
  276. */
  277. extern void __iomem *tsunami_ioportmap(unsigned long addr);
  278. extern void __iomem *tsunami_ioremap(unsigned long addr, unsigned long size);
  279. __EXTERN_INLINE int tsunami_is_ioaddr(unsigned long addr)
  280. {
  281. return addr >= TSUNAMI_BASE;
  282. }
  283. __EXTERN_INLINE int tsunami_is_mmio(const volatile void __iomem *xaddr)
  284. {
  285. unsigned long addr = (unsigned long) xaddr;
  286. return (addr & 0x100000000UL) == 0;
  287. }
  288. #undef __IO_PREFIX
  289. #define __IO_PREFIX tsunami
  290. #define tsunami_trivial_rw_bw 1
  291. #define tsunami_trivial_rw_lq 1
  292. #define tsunami_trivial_io_bw 1
  293. #define tsunami_trivial_io_lq 1
  294. #define tsunami_trivial_iounmap 1
  295. #include <asm/io_trivial.h>
  296. #ifdef __IO_EXTERN_INLINE
  297. #undef __EXTERN_INLINE
  298. #undef __IO_EXTERN_INLINE
  299. #endif
  300. #endif /* __KERNEL__ */
  301. #endif /* __ALPHA_TSUNAMI__H__ */